npm package diff
Package: @radix-ui/react-primitive
Versions: 1.0.3 - 2.0.0
Removed:package/dist/index.d.ts.map
Modified:package/dist/index.d.mts
Index: package/dist/index.d.mts
===================================================================
--- package/dist/index.d.mts
+++ package/dist/index.d.mts
@@ -1,17 +1,16 @@
-import * as React from "react";
+import * as React from 'react';
+
declare const NODES: readonly ["a", "button", "div", "form", "h2", "h3", "img", "input", "label", "li", "nav", "ol", "p", "span", "svg", "ul"];
-type PropsWithoutRef<P> = P extends any ? ('ref' extends keyof P ? Pick<P, Exclude<keyof P, 'ref'>> : P) : P;
-export type ComponentPropsWithoutRef<T extends React.ElementType> = PropsWithoutRef<React.ComponentProps<T>>;
type Primitives = {
- [E in typeof NODES[number]]: PrimitiveForwardRefComponent<E>;
+ [E in (typeof NODES)[number]]: PrimitiveForwardRefComponent<E>;
};
-export type PrimitivePropsWithRef<E extends React.ElementType> = React.ComponentPropsWithRef<E> & {
+type PrimitivePropsWithRef<E extends React.ElementType> = React.ComponentPropsWithRef<E> & {
asChild?: boolean;
};
interface PrimitiveForwardRefComponent<E extends React.ElementType> extends React.ForwardRefExoticComponent<PrimitivePropsWithRef<E>> {
}
-export const Primitive: Primitives;
+declare const Primitive: Primitives;
/**
* Flush custom event dispatch
* https://github.com/radix-ui/primitives/pull/1378
*
@@ -46,8 +45,8 @@
* Note: though React classifies `focus`, `focusin` and `focusout` events as `discrete`, it's not recommended to use
* this utility with them. This is because it's possible for those handlers to be called implicitly during render
* e.g. when focus is within a component as it is unmounted, or when managing focus on mount.
*/
-export function dispatchDiscreteCustomEvent<E extends CustomEvent>(target: E['target'], event: E): void;
-export const Root: Primitives;
+declare function dispatchDiscreteCustomEvent<E extends CustomEvent>(target: E['target'], event: E): void;
+declare const Root: Primitives;
-//# sourceMappingURL=index.d.ts.map
+export { Primitive, type PrimitivePropsWithRef, Root, dispatchDiscreteCustomEvent };
Modified:package/dist/index.d.ts
Index: package/dist/index.d.ts
===================================================================
--- package/dist/index.d.ts
+++ package/dist/index.d.ts
@@ -1,17 +1,16 @@
-import * as React from "react";
+import * as React from 'react';
+
declare const NODES: readonly ["a", "button", "div", "form", "h2", "h3", "img", "input", "label", "li", "nav", "ol", "p", "span", "svg", "ul"];
-type PropsWithoutRef<P> = P extends any ? ('ref' extends keyof P ? Pick<P, Exclude<keyof P, 'ref'>> : P) : P;
-export type ComponentPropsWithoutRef<T extends React.ElementType> = PropsWithoutRef<React.ComponentProps<T>>;
type Primitives = {
- [E in typeof NODES[number]]: PrimitiveForwardRefComponent<E>;
+ [E in (typeof NODES)[number]]: PrimitiveForwardRefComponent<E>;
};
-export type PrimitivePropsWithRef<E extends React.ElementType> = React.ComponentPropsWithRef<E> & {
+type PrimitivePropsWithRef<E extends React.ElementType> = React.ComponentPropsWithRef<E> & {
asChild?: boolean;
};
interface PrimitiveForwardRefComponent<E extends React.ElementType> extends React.ForwardRefExoticComponent<PrimitivePropsWithRef<E>> {
}
-export const Primitive: Primitives;
+declare const Primitive: Primitives;
/**
* Flush custom event dispatch
* https://github.com/radix-ui/primitives/pull/1378
*
@@ -46,8 +45,8 @@
* Note: though React classifies `focus`, `focusin` and `focusout` events as `discrete`, it's not recommended to use
* this utility with them. This is because it's possible for those handlers to be called implicitly during render
* e.g. when focus is within a component as it is unmounted, or when managing focus on mount.
*/
-export function dispatchDiscreteCustomEvent<E extends CustomEvent>(target: E['target'], event: E): void;
-export const Root: Primitives;
+declare function dispatchDiscreteCustomEvent<E extends CustomEvent>(target: E['target'], event: E): void;
+declare const Root: Primitives;
-//# sourceMappingURL=index.d.ts.map
+export { Primitive, type PrimitivePropsWithRef, Root, dispatchDiscreteCustomEvent };
Modified:package/dist/index.js
Index: package/dist/index.js
===================================================================
--- package/dist/index.js
+++ package/dist/index.js
@@ -1,105 +1,78 @@
-var $iMixA$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
-var $iMixA$react = require("react");
-var $iMixA$reactdom = require("react-dom");
-var $iMixA$radixuireactslot = require("@radix-ui/react-slot");
+"use strict";
+var __create = Object.create;
+var __defProp = Object.defineProperty;
+var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
+var __getOwnPropNames = Object.getOwnPropertyNames;
+var __getProtoOf = Object.getPrototypeOf;
+var __hasOwnProp = Object.prototype.hasOwnProperty;
+var __export = (target, all) => {
+ for (var name in all)
+ __defProp(target, name, { get: all[name], enumerable: true });
+};
+var __copyProps = (to, from, except, desc) => {
+ if (from && typeof from === "object" || typeof from === "function") {
+ for (let key of __getOwnPropNames(from))
+ if (!__hasOwnProp.call(to, key) && key !== except)
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
+ }
+ return to;
+};
+var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
+ // If the importer is in node compatibility mode or this is not an ESM
+ // file that has been converted to a CommonJS file using a Babel-
+ // compatible transform (i.e. "__esModule" has not been set), then set
+ // "default" to the CommonJS "module.exports" for node compatibility.
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
+ mod
+));
+var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
-function $parcel$export(e, n, v, s) {
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
-}
-function $parcel$interopDefault(a) {
- return a && a.__esModule ? a.default : a;
-}
+// packages/react/primitive/src/index.ts
+var src_exports = {};
+__export(src_exports, {
+ Primitive: () => Primitive,
+ Root: () => Root,
+ dispatchDiscreteCustomEvent: () => dispatchDiscreteCustomEvent
+});
+module.exports = __toCommonJS(src_exports);
-$parcel$export(module.exports, "Primitive", () => $c3def6332c2749a6$export$250ffa63cdc0d034);
-$parcel$export(module.exports, "Root", () => $c3def6332c2749a6$export$be92b6f5f03c0fe9);
-$parcel$export(module.exports, "dispatchDiscreteCustomEvent", () => $c3def6332c2749a6$export$6d1a0317bde7de7f);
-
-
-
-
-const $c3def6332c2749a6$var$NODES = [
- 'a',
- 'button',
- 'div',
- 'form',
- 'h2',
- 'h3',
- 'img',
- 'input',
- 'label',
- 'li',
- 'nav',
- 'ol',
- 'p',
- 'span',
- 'svg',
- 'ul'
-]; // Temporary while we await merge of this fix:
-// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/55396
-// prettier-ignore
-/* -------------------------------------------------------------------------------------------------
- * Primitive
- * -----------------------------------------------------------------------------------------------*/ const $c3def6332c2749a6$export$250ffa63cdc0d034 = $c3def6332c2749a6$var$NODES.reduce((primitive, node)=>{
- const Node = /*#__PURE__*/ $iMixA$react.forwardRef((props, forwardedRef)=>{
- const { asChild: asChild , ...primitiveProps } = props;
- const Comp = asChild ? $iMixA$radixuireactslot.Slot : node;
- $iMixA$react.useEffect(()=>{
- window[Symbol.for('radix-ui')] = true;
- }, []);
- return /*#__PURE__*/ $iMixA$react.createElement(Comp, ($parcel$interopDefault($iMixA$babelruntimehelpersextends))({}, primitiveProps, {
- ref: forwardedRef
- }));
- });
- Node.displayName = `Primitive.${node}`;
- return {
- ...primitive,
- [node]: Node
- };
+// packages/react/primitive/src/Primitive.tsx
+var React = __toESM(require("react"));
+var ReactDOM = __toESM(require("react-dom"));
+var import_react_slot = require("@radix-ui/react-slot");
+var import_jsx_runtime = require("react/jsx-runtime");
+var NODES = [
+ "a",
+ "button",
+ "div",
+ "form",
+ "h2",
+ "h3",
+ "img",
+ "input",
+ "label",
+ "li",
+ "nav",
+ "ol",
+ "p",
+ "span",
+ "svg",
+ "ul"
+];
+var Primitive = NODES.reduce((primitive, node) => {
+ const Node = React.forwardRef((props, forwardedRef) => {
+ const { asChild, ...primitiveProps } = props;
+ const Comp = asChild ? import_react_slot.Slot : node;
+ if (typeof window !== "undefined") {
+ window[Symbol.for("radix-ui")] = true;
+ }
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Comp, { ...primitiveProps, ref: forwardedRef });
+ });
+ Node.displayName = `Primitive.${node}`;
+ return { ...primitive, [node]: Node };
}, {});
-/* -------------------------------------------------------------------------------------------------
- * Utils
- * -----------------------------------------------------------------------------------------------*/ /**
- * Flush custom event dispatch
- * https://github.com/radix-ui/primitives/pull/1378
- *
- * React batches *all* event handlers since version 18, this introduces certain considerations when using custom event types.
- *
- * Internally, React prioritises events in the following order:
- * - discrete
- * - continuous
- * - default
- *
- * https://github.com/facebook/react/blob/a8a4742f1c54493df00da648a3f9d26e3db9c8b5/packages/react-dom/src/events/ReactDOMEventListener.js#L294-L350
- *
- * `discrete` is an important distinction as updates within these events are applied immediately.
- * React however, is not able to infer the priority of custom event types due to how they are detected internally.
- * Because of this, it's possible for updates from custom events to be unexpectedly batched when
- * dispatched by another `discrete` event.
- *
- * In order to ensure that updates from custom events are applied predictably, we need to manually flush the batch.
- * This utility should be used when dispatching a custom event from within another `discrete` event, this utility
- * is not nessesary when dispatching known event types, or if dispatching a custom type inside a non-discrete event.
- * For example:
- *
- * dispatching a known click 👎
- * target.dispatchEvent(new Event(‘click’))
- *
- * dispatching a custom type within a non-discrete event 👎
- * onScroll={(event) => event.target.dispatchEvent(new CustomEvent(‘customType’))}
- *
- * dispatching a custom type within a `discrete` event 👍
- * onPointerDown={(event) => dispatchDiscreteCustomEvent(event.target, new CustomEvent(‘customType’))}
- *
- * Note: though React classifies `focus`, `focusin` and `focusout` events as `discrete`, it's not recommended to use
- * this utility with them. This is because it's possible for those handlers to be called implicitly during render
- * e.g. when focus is within a component as it is unmounted, or when managing focus on mount.
- */ function $c3def6332c2749a6$export$6d1a0317bde7de7f(target, event) {
- if (target) $iMixA$reactdom.flushSync(()=>target.dispatchEvent(event)
- );
+function dispatchDiscreteCustomEvent(target, event) {
+ if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));
}
-/* -----------------------------------------------------------------------------------------------*/ const $c3def6332c2749a6$export$be92b6f5f03c0fe9 = $c3def6332c2749a6$export$250ffa63cdc0d034;
-
-
-
-
+var Root = Primitive;
//# sourceMappingURL=index.js.map
Modified:package/dist/index.js.map
Index: package/dist/index.js.map
===================================================================
--- package/dist/index.js.map
+++ package/dist/index.js.map
@@ -1,1 +1,7 @@
-{"mappings":";;;;;;;;;;;;;;;A;;;;ACIA,MAAMM,2BAAK,GAAG;IACZ,GADY;IAEZ,QAFY;IAGZ,KAHY;IAIZ,MAJY;IAKZ,IALY;IAMZ,IANY;IAOZ,KAPY;IAQZ,OARY;IASZ,OATY;IAUZ,IAVY;IAWZ,KAXY;IAYZ,IAZY;IAaZ,GAbY;IAcZ,MAdY;IAeZ,KAfY;IAgBZ,IAhBY;CAAd,A,EAmBA,8CAnBA;AAoBA,gEAAA;AACA,kBAAA;AAcA;;oGAEA,CAEA,MAAMN,yCAAS,GAAGM,2BAAK,CAACC,MAAN,CAAa,CAACC,SAAD,EAAYC,IAAZ,GAAqB;IAClD,MAAMC,IAAI,GAAA,aAAGP,CAAAA,uBAAA,CAAiB,CAACS,KAAD,EAA4CC,YAA5C,GAAkE;QAC9F,MAAM,E,SAAEC,OAAF,CAAA,EAAW,GAAGC,cAAH,EAAX,GAAiCH,KAAvC,AAAM;QACN,MAAMI,IAAS,GAAGF,OAAO,GAAGT,4BAAH,GAAUI,IAAnC,AAAA;QAEAN,sBAAA,CAAgB,IAAM;YACnBe,MAAD,CAAgBC,MAAM,CAACC,GAAP,CAAW,UAAX,CAAhB,CAAA,GAA0C,IAA1C,CAACF;SADH,EAEG,EAFH,CAEC,CAAA;QAED,OAAA,aAAO,CAAA,0BAAA,CAAC,IAAD,EAAA,2DAAA,CAAA,EAAA,EAAUH,cAAV,EAAP;YAAiC,GAAG,EAAEF,YAAL;SAA1B,CAAA,CAAP,CAAO;KARI,CAAb,AASC;IAEDH,IAAI,CAACW,WAAL,GAAoB,CAAA,UAAA,EAAYZ,IAAK,CAAA,CAArC,CAAAC;IAEA,OAAO;QAAE,GAAGF,SAAL;QAAgB,CAACC,IAAD,CAAA,EAAQC,IAAR;KAAvB,CAAO;CAdS,EAef,EAfe,CAAlB,AAeC;AAED;;oGAEA,CAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCA,CAEA,SAASR,yCAAT,CAA4DoB,MAA5D,EAAiFC,KAAjF,EAA2F;IACzF,IAAID,MAAJ,EAAYlB,yBAAA,CAAmB,IAAMkB,MAAM,CAACG,aAAP,CAAqBF,KAArB,CAAzB;IAAA,CAAZ,CAAA;CACD;AAED,oGAAA,CAEA,MAAMtB,yCAAI,GAAGD,yCAAb,AAAA;;AD3GA","sources":["packages/react/primitive/src/index.ts","packages/react/primitive/src/Primitive.tsx"],"sourcesContent":["export {\n Primitive,\n //\n Root,\n //\n dispatchDiscreteCustomEvent,\n} from './Primitive';\nexport type { ComponentPropsWithoutRef, PrimitivePropsWithRef } from './Primitive';\n","import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { Slot } from '@radix-ui/react-slot';\n\nconst NODES = [\n 'a',\n 'button',\n 'div',\n 'form',\n 'h2',\n 'h3',\n 'img',\n 'input',\n 'label',\n 'li',\n 'nav',\n 'ol',\n 'p',\n 'span',\n 'svg',\n 'ul',\n] as const;\n\n// Temporary while we await merge of this fix:\n// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/55396\n// prettier-ignore\ntype PropsWithoutRef<P> = P extends any ? ('ref' extends keyof P ? Pick<P, Exclude<keyof P, 'ref'>> : P) : P;\ntype ComponentPropsWithoutRef<T extends React.ElementType> = PropsWithoutRef<\n React.ComponentProps<T>\n>;\n\ntype Primitives = { [E in typeof NODES[number]]: PrimitiveForwardRefComponent<E> };\ntype PrimitivePropsWithRef<E extends React.ElementType> = React.ComponentPropsWithRef<E> & {\n asChild?: boolean;\n};\n\ninterface PrimitiveForwardRefComponent<E extends React.ElementType>\n extends React.ForwardRefExoticComponent<PrimitivePropsWithRef<E>> {}\n\n/* -------------------------------------------------------------------------------------------------\n * Primitive\n * -----------------------------------------------------------------------------------------------*/\n\nconst Primitive = NODES.reduce((primitive, node) => {\n const Node = React.forwardRef((props: PrimitivePropsWithRef<typeof node>, forwardedRef: any) => {\n const { asChild, ...primitiveProps } = props;\n const Comp: any = asChild ? Slot : node;\n\n React.useEffect(() => {\n (window as any)[Symbol.for('radix-ui')] = true;\n }, []);\n\n return <Comp {...primitiveProps} ref={forwardedRef} />;\n });\n\n Node.displayName = `Primitive.${node}`;\n\n return { ...primitive, [node]: Node };\n}, {} as Primitives);\n\n/* -------------------------------------------------------------------------------------------------\n * Utils\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * Flush custom event dispatch\n * https://github.com/radix-ui/primitives/pull/1378\n *\n * React batches *all* event handlers since version 18, this introduces certain considerations when using custom event types.\n *\n * Internally, React prioritises events in the following order:\n * - discrete\n * - continuous\n * - default\n *\n * https://github.com/facebook/react/blob/a8a4742f1c54493df00da648a3f9d26e3db9c8b5/packages/react-dom/src/events/ReactDOMEventListener.js#L294-L350\n *\n * `discrete` is an important distinction as updates within these events are applied immediately.\n * React however, is not able to infer the priority of custom event types due to how they are detected internally.\n * Because of this, it's possible for updates from custom events to be unexpectedly batched when\n * dispatched by another `discrete` event.\n *\n * In order to ensure that updates from custom events are applied predictably, we need to manually flush the batch.\n * This utility should be used when dispatching a custom event from within another `discrete` event, this utility\n * is not nessesary when dispatching known event types, or if dispatching a custom type inside a non-discrete event.\n * For example:\n *\n * dispatching a known click 👎\n * target.dispatchEvent(new Event(‘click’))\n *\n * dispatching a custom type within a non-discrete event 👎\n * onScroll={(event) => event.target.dispatchEvent(new CustomEvent(‘customType’))}\n *\n * dispatching a custom type within a `discrete` event 👍\n * onPointerDown={(event) => dispatchDiscreteCustomEvent(event.target, new CustomEvent(‘customType’))}\n *\n * Note: though React classifies `focus`, `focusin` and `focusout` events as `discrete`, it's not recommended to use\n * this utility with them. This is because it's possible for those handlers to be called implicitly during render\n * e.g. when focus is within a component as it is unmounted, or when managing focus on mount.\n */\n\nfunction dispatchDiscreteCustomEvent<E extends CustomEvent>(target: E['target'], event: E) {\n if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Root = Primitive;\n\nexport {\n Primitive,\n //\n Root,\n //\n dispatchDiscreteCustomEvent,\n};\nexport type { ComponentPropsWithoutRef, PrimitivePropsWithRef };\n"],"names":["Primitive","Root","dispatchDiscreteCustomEvent","React","ReactDOM","Slot","NODES","reduce","primitive","node","Node","forwardRef","props","forwardedRef","asChild","primitiveProps","Comp","useEffect","window","Symbol","for","displayName","target","event","flushSync","dispatchEvent"],"version":3,"file":"index.js.map"}
\ No newline at end of file
+{
+ "version": 3,
+ "sources": ["../src/index.ts", "../src/Primitive.tsx"],
+ "sourcesContent": ["export {\n Primitive,\n //\n Root,\n //\n dispatchDiscreteCustomEvent,\n} from './Primitive';\nexport type { PrimitivePropsWithRef } from './Primitive';\n", "import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { Slot } from '@radix-ui/react-slot';\n\nconst NODES = [\n 'a',\n 'button',\n 'div',\n 'form',\n 'h2',\n 'h3',\n 'img',\n 'input',\n 'label',\n 'li',\n 'nav',\n 'ol',\n 'p',\n 'span',\n 'svg',\n 'ul',\n] as const;\n\ntype Primitives = { [E in (typeof NODES)[number]]: PrimitiveForwardRefComponent<E> };\ntype PrimitivePropsWithRef<E extends React.ElementType> = React.ComponentPropsWithRef<E> & {\n asChild?: boolean;\n};\n\ninterface PrimitiveForwardRefComponent<E extends React.ElementType>\n extends React.ForwardRefExoticComponent<PrimitivePropsWithRef<E>> {}\n\n/* -------------------------------------------------------------------------------------------------\n * Primitive\n * -----------------------------------------------------------------------------------------------*/\n\nconst Primitive = NODES.reduce((primitive, node) => {\n const Node = React.forwardRef((props: PrimitivePropsWithRef<typeof node>, forwardedRef: any) => {\n const { asChild, ...primitiveProps } = props;\n const Comp: any = asChild ? Slot : node;\n\n if (typeof window !== 'undefined') {\n (window as any)[Symbol.for('radix-ui')] = true;\n }\n\n return <Comp {...primitiveProps} ref={forwardedRef} />;\n });\n\n Node.displayName = `Primitive.${node}`;\n\n return { ...primitive, [node]: Node };\n}, {} as Primitives);\n\n/* -------------------------------------------------------------------------------------------------\n * Utils\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * Flush custom event dispatch\n * https://github.com/radix-ui/primitives/pull/1378\n *\n * React batches *all* event handlers since version 18, this introduces certain considerations when using custom event types.\n *\n * Internally, React prioritises events in the following order:\n * - discrete\n * - continuous\n * - default\n *\n * https://github.com/facebook/react/blob/a8a4742f1c54493df00da648a3f9d26e3db9c8b5/packages/react-dom/src/events/ReactDOMEventListener.js#L294-L350\n *\n * `discrete` is an important distinction as updates within these events are applied immediately.\n * React however, is not able to infer the priority of custom event types due to how they are detected internally.\n * Because of this, it's possible for updates from custom events to be unexpectedly batched when\n * dispatched by another `discrete` event.\n *\n * In order to ensure that updates from custom events are applied predictably, we need to manually flush the batch.\n * This utility should be used when dispatching a custom event from within another `discrete` event, this utility\n * is not nessesary when dispatching known event types, or if dispatching a custom type inside a non-discrete event.\n * For example:\n *\n * dispatching a known click \uD83D\uDC4E\n * target.dispatchEvent(new Event(\u2018click\u2019))\n *\n * dispatching a custom type within a non-discrete event \uD83D\uDC4E\n * onScroll={(event) => event.target.dispatchEvent(new CustomEvent(\u2018customType\u2019))}\n *\n * dispatching a custom type within a `discrete` event \uD83D\uDC4D\n * onPointerDown={(event) => dispatchDiscreteCustomEvent(event.target, new CustomEvent(\u2018customType\u2019))}\n *\n * Note: though React classifies `focus`, `focusin` and `focusout` events as `discrete`, it's not recommended to use\n * this utility with them. This is because it's possible for those handlers to be called implicitly during render\n * e.g. when focus is within a component as it is unmounted, or when managing focus on mount.\n */\n\nfunction dispatchDiscreteCustomEvent<E extends CustomEvent>(target: E['target'], event: E) {\n if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Root = Primitive;\n\nexport {\n Primitive,\n //\n Root,\n //\n dispatchDiscreteCustomEvent,\n};\nexport type { PrimitivePropsWithRef };\n"],
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,eAA0B;AAC1B,wBAAqB;AA0CV;AAxCX,IAAM,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAcA,IAAM,YAAY,MAAM,OAAO,CAAC,WAAW,SAAS;AAClD,QAAM,OAAa,iBAAW,CAAC,OAA2C,iBAAsB;AAC9F,UAAM,EAAE,SAAS,GAAG,eAAe,IAAI;AACvC,UAAM,OAAY,UAAU,yBAAO;AAEnC,QAAI,OAAO,WAAW,aAAa;AACjC,MAAC,OAAe,OAAO,IAAI,UAAU,CAAC,IAAI;AAAA,IAC5C;AAEA,WAAO,4CAAC,QAAM,GAAG,gBAAgB,KAAK,cAAc;AAAA,EACtD,CAAC;AAED,OAAK,cAAc,aAAa,IAAI;AAEpC,SAAO,EAAE,GAAG,WAAW,CAAC,IAAI,GAAG,KAAK;AACtC,GAAG,CAAC,CAAe;AA2CnB,SAAS,4BAAmD,QAAqB,OAAU;AACzF,MAAI,OAAQ,CAAS,mBAAU,MAAM,OAAO,cAAc,KAAK,CAAC;AAClE;AAIA,IAAM,OAAO;",
+ "names": []
+}
Modified:package/dist/index.mjs
Index: package/dist/index.mjs
===================================================================
--- package/dist/index.mjs
+++ package/dist/index.mjs
@@ -1,96 +1,45 @@
-import $4q5Fq$babelruntimehelpersesmextends from "@babel/runtime/helpers/esm/extends";
-import {forwardRef as $4q5Fq$forwardRef, useEffect as $4q5Fq$useEffect, createElement as $4q5Fq$createElement} from "react";
-import {flushSync as $4q5Fq$flushSync} from "react-dom";
-import {Slot as $4q5Fq$Slot} from "@radix-ui/react-slot";
-
-
-
-
-
-const $8927f6f2acc4f386$var$NODES = [
- 'a',
- 'button',
- 'div',
- 'form',
- 'h2',
- 'h3',
- 'img',
- 'input',
- 'label',
- 'li',
- 'nav',
- 'ol',
- 'p',
- 'span',
- 'svg',
- 'ul'
-]; // Temporary while we await merge of this fix:
-// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/55396
-// prettier-ignore
-/* -------------------------------------------------------------------------------------------------
- * Primitive
- * -----------------------------------------------------------------------------------------------*/ const $8927f6f2acc4f386$export$250ffa63cdc0d034 = $8927f6f2acc4f386$var$NODES.reduce((primitive, node)=>{
- const Node = /*#__PURE__*/ $4q5Fq$forwardRef((props, forwardedRef)=>{
- const { asChild: asChild , ...primitiveProps } = props;
- const Comp = asChild ? $4q5Fq$Slot : node;
- $4q5Fq$useEffect(()=>{
- window[Symbol.for('radix-ui')] = true;
- }, []);
- return /*#__PURE__*/ $4q5Fq$createElement(Comp, $4q5Fq$babelruntimehelpersesmextends({}, primitiveProps, {
- ref: forwardedRef
- }));
- });
- Node.displayName = `Primitive.${node}`;
- return {
- ...primitive,
- [node]: Node
- };
+// packages/react/primitive/src/Primitive.tsx
+import * as React from "react";
+import * as ReactDOM from "react-dom";
+import { Slot } from "@radix-ui/react-slot";
+import { jsx } from "react/jsx-runtime";
+var NODES = [
+ "a",
+ "button",
+ "div",
+ "form",
+ "h2",
+ "h3",
+ "img",
+ "input",
+ "label",
+ "li",
+ "nav",
+ "ol",
+ "p",
+ "span",
+ "svg",
+ "ul"
+];
+var Primitive = NODES.reduce((primitive, node) => {
+ const Node = React.forwardRef((props, forwardedRef) => {
+ const { asChild, ...primitiveProps } = props;
+ const Comp = asChild ? Slot : node;
+ if (typeof window !== "undefined") {
+ window[Symbol.for("radix-ui")] = true;
+ }
+ return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });
+ });
+ Node.displayName = `Primitive.${node}`;
+ return { ...primitive, [node]: Node };
}, {});
-/* -------------------------------------------------------------------------------------------------
- * Utils
- * -----------------------------------------------------------------------------------------------*/ /**
- * Flush custom event dispatch
- * https://github.com/radix-ui/primitives/pull/1378
- *
- * React batches *all* event handlers since version 18, this introduces certain considerations when using custom event types.
- *
- * Internally, React prioritises events in the following order:
- * - discrete
- * - continuous
- * - default
- *
- * https://github.com/facebook/react/blob/a8a4742f1c54493df00da648a3f9d26e3db9c8b5/packages/react-dom/src/events/ReactDOMEventListener.js#L294-L350
- *
- * `discrete` is an important distinction as updates within these events are applied immediately.
- * React however, is not able to infer the priority of custom event types due to how they are detected internally.
- * Because of this, it's possible for updates from custom events to be unexpectedly batched when
- * dispatched by another `discrete` event.
- *
- * In order to ensure that updates from custom events are applied predictably, we need to manually flush the batch.
- * This utility should be used when dispatching a custom event from within another `discrete` event, this utility
- * is not nessesary when dispatching known event types, or if dispatching a custom type inside a non-discrete event.
- * For example:
- *
- * dispatching a known click 👎
- * target.dispatchEvent(new Event(‘click’))
- *
- * dispatching a custom type within a non-discrete event 👎
- * onScroll={(event) => event.target.dispatchEvent(new CustomEvent(‘customType’))}
- *
- * dispatching a custom type within a `discrete` event 👍
- * onPointerDown={(event) => dispatchDiscreteCustomEvent(event.target, new CustomEvent(‘customType’))}
- *
- * Note: though React classifies `focus`, `focusin` and `focusout` events as `discrete`, it's not recommended to use
- * this utility with them. This is because it's possible for those handlers to be called implicitly during render
- * e.g. when focus is within a component as it is unmounted, or when managing focus on mount.
- */ function $8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event) {
- if (target) $4q5Fq$flushSync(()=>target.dispatchEvent(event)
- );
+function dispatchDiscreteCustomEvent(target, event) {
+ if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));
}
-/* -----------------------------------------------------------------------------------------------*/ const $8927f6f2acc4f386$export$be92b6f5f03c0fe9 = $8927f6f2acc4f386$export$250ffa63cdc0d034;
-
-
-
-
-export {$8927f6f2acc4f386$export$250ffa63cdc0d034 as Primitive, $8927f6f2acc4f386$export$be92b6f5f03c0fe9 as Root, $8927f6f2acc4f386$export$6d1a0317bde7de7f as dispatchDiscreteCustomEvent};
+var Root = Primitive;
+export {
+ Primitive,
+ Root,
+ dispatchDiscreteCustomEvent
+};
//# sourceMappingURL=index.mjs.map
Modified:package/dist/index.mjs.map
Index: package/dist/index.mjs.map
===================================================================
--- package/dist/index.mjs.map
+++ package/dist/index.mjs.map
@@ -1,1 +1,7 @@
-{"mappings":";;;;;A;;;;ACIA,MAAMM,2BAAK,GAAG;IACZ,GADY;IAEZ,QAFY;IAGZ,KAHY;IAIZ,MAJY;IAKZ,IALY;IAMZ,IANY;IAOZ,KAPY;IAQZ,OARY;IASZ,OATY;IAUZ,IAVY;IAWZ,KAXY;IAYZ,IAZY;IAaZ,GAbY;IAcZ,MAdY;IAeZ,KAfY;IAgBZ,IAhBY;CAAd,A,EAmBA,8CAnBA;AAoBA,gEAAA;AACA,kBAAA;AAcA;;oGAEA,CAEA,MAAMN,yCAAS,GAAGM,2BAAK,CAACC,MAAN,CAAa,CAACC,SAAD,EAAYC,IAAZ,GAAqB;IAClD,MAAMC,IAAI,GAAA,aAAGP,CAAAA,iBAAA,CAAiB,CAACS,KAAD,EAA4CC,YAA5C,GAAkE;QAC9F,MAAM,E,SAAEC,OAAF,CAAA,EAAW,GAAGC,cAAH,EAAX,GAAiCH,KAAvC,AAAM;QACN,MAAMI,IAAS,GAAGF,OAAO,GAAGT,WAAH,GAAUI,IAAnC,AAAA;QAEAN,gBAAA,CAAgB,IAAM;YACnBe,MAAD,CAAgBC,MAAM,CAACC,GAAP,CAAW,UAAX,CAAhB,CAAA,GAA0C,IAA1C,CAACF;SADH,EAEG,EAFH,CAEC,CAAA;QAED,OAAA,aAAO,CAAA,oBAAA,CAAC,IAAD,EAAA,oCAAA,CAAA,EAAA,EAAUH,cAAV,EAAP;YAAiC,GAAG,EAAEF,YAAL;SAA1B,CAAA,CAAP,CAAO;KARI,CAAb,AASC;IAEDH,IAAI,CAACW,WAAL,GAAoB,CAAA,UAAA,EAAYZ,IAAK,CAAA,CAArC,CAAAC;IAEA,OAAO;QAAE,GAAGF,SAAL;QAAgB,CAACC,IAAD,CAAA,EAAQC,IAAR;KAAvB,CAAO;CAdS,EAef,EAfe,CAAlB,AAeC;AAED;;oGAEA,CAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCA,CAEA,SAASR,yCAAT,CAA4DoB,MAA5D,EAAiFC,KAAjF,EAA2F;IACzF,IAAID,MAAJ,EAAYlB,gBAAA,CAAmB,IAAMkB,MAAM,CAACG,aAAP,CAAqBF,KAArB,CAAzB;IAAA,CAAZ,CAAA;CACD;AAED,oGAAA,CAEA,MAAMtB,yCAAI,GAAGD,yCAAb,AAAA;;AD3GA","sources":["packages/react/primitive/src/index.ts","packages/react/primitive/src/Primitive.tsx"],"sourcesContent":["export {\n Primitive,\n //\n Root,\n //\n dispatchDiscreteCustomEvent,\n} from './Primitive';\nexport type { ComponentPropsWithoutRef, PrimitivePropsWithRef } from './Primitive';\n","import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { Slot } from '@radix-ui/react-slot';\n\nconst NODES = [\n 'a',\n 'button',\n 'div',\n 'form',\n 'h2',\n 'h3',\n 'img',\n 'input',\n 'label',\n 'li',\n 'nav',\n 'ol',\n 'p',\n 'span',\n 'svg',\n 'ul',\n] as const;\n\n// Temporary while we await merge of this fix:\n// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/55396\n// prettier-ignore\ntype PropsWithoutRef<P> = P extends any ? ('ref' extends keyof P ? Pick<P, Exclude<keyof P, 'ref'>> : P) : P;\ntype ComponentPropsWithoutRef<T extends React.ElementType> = PropsWithoutRef<\n React.ComponentProps<T>\n>;\n\ntype Primitives = { [E in typeof NODES[number]]: PrimitiveForwardRefComponent<E> };\ntype PrimitivePropsWithRef<E extends React.ElementType> = React.ComponentPropsWithRef<E> & {\n asChild?: boolean;\n};\n\ninterface PrimitiveForwardRefComponent<E extends React.ElementType>\n extends React.ForwardRefExoticComponent<PrimitivePropsWithRef<E>> {}\n\n/* -------------------------------------------------------------------------------------------------\n * Primitive\n * -----------------------------------------------------------------------------------------------*/\n\nconst Primitive = NODES.reduce((primitive, node) => {\n const Node = React.forwardRef((props: PrimitivePropsWithRef<typeof node>, forwardedRef: any) => {\n const { asChild, ...primitiveProps } = props;\n const Comp: any = asChild ? Slot : node;\n\n React.useEffect(() => {\n (window as any)[Symbol.for('radix-ui')] = true;\n }, []);\n\n return <Comp {...primitiveProps} ref={forwardedRef} />;\n });\n\n Node.displayName = `Primitive.${node}`;\n\n return { ...primitive, [node]: Node };\n}, {} as Primitives);\n\n/* -------------------------------------------------------------------------------------------------\n * Utils\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * Flush custom event dispatch\n * https://github.com/radix-ui/primitives/pull/1378\n *\n * React batches *all* event handlers since version 18, this introduces certain considerations when using custom event types.\n *\n * Internally, React prioritises events in the following order:\n * - discrete\n * - continuous\n * - default\n *\n * https://github.com/facebook/react/blob/a8a4742f1c54493df00da648a3f9d26e3db9c8b5/packages/react-dom/src/events/ReactDOMEventListener.js#L294-L350\n *\n * `discrete` is an important distinction as updates within these events are applied immediately.\n * React however, is not able to infer the priority of custom event types due to how they are detected internally.\n * Because of this, it's possible for updates from custom events to be unexpectedly batched when\n * dispatched by another `discrete` event.\n *\n * In order to ensure that updates from custom events are applied predictably, we need to manually flush the batch.\n * This utility should be used when dispatching a custom event from within another `discrete` event, this utility\n * is not nessesary when dispatching known event types, or if dispatching a custom type inside a non-discrete event.\n * For example:\n *\n * dispatching a known click 👎\n * target.dispatchEvent(new Event(‘click’))\n *\n * dispatching a custom type within a non-discrete event 👎\n * onScroll={(event) => event.target.dispatchEvent(new CustomEvent(‘customType’))}\n *\n * dispatching a custom type within a `discrete` event 👍\n * onPointerDown={(event) => dispatchDiscreteCustomEvent(event.target, new CustomEvent(‘customType’))}\n *\n * Note: though React classifies `focus`, `focusin` and `focusout` events as `discrete`, it's not recommended to use\n * this utility with them. This is because it's possible for those handlers to be called implicitly during render\n * e.g. when focus is within a component as it is unmounted, or when managing focus on mount.\n */\n\nfunction dispatchDiscreteCustomEvent<E extends CustomEvent>(target: E['target'], event: E) {\n if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Root = Primitive;\n\nexport {\n Primitive,\n //\n Root,\n //\n dispatchDiscreteCustomEvent,\n};\nexport type { ComponentPropsWithoutRef, PrimitivePropsWithRef };\n"],"names":["Primitive","Root","dispatchDiscreteCustomEvent","React","ReactDOM","Slot","NODES","reduce","primitive","node","Node","forwardRef","props","forwardedRef","asChild","primitiveProps","Comp","useEffect","window","Symbol","for","displayName","target","event","flushSync","dispatchEvent"],"version":3,"file":"index.mjs.map"}
\ No newline at end of file
+{
+ "version": 3,
+ "sources": ["../src/Primitive.tsx"],
+ "sourcesContent": ["import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { Slot } from '@radix-ui/react-slot';\n\nconst NODES = [\n 'a',\n 'button',\n 'div',\n 'form',\n 'h2',\n 'h3',\n 'img',\n 'input',\n 'label',\n 'li',\n 'nav',\n 'ol',\n 'p',\n 'span',\n 'svg',\n 'ul',\n] as const;\n\ntype Primitives = { [E in (typeof NODES)[number]]: PrimitiveForwardRefComponent<E> };\ntype PrimitivePropsWithRef<E extends React.ElementType> = React.ComponentPropsWithRef<E> & {\n asChild?: boolean;\n};\n\ninterface PrimitiveForwardRefComponent<E extends React.ElementType>\n extends React.ForwardRefExoticComponent<PrimitivePropsWithRef<E>> {}\n\n/* -------------------------------------------------------------------------------------------------\n * Primitive\n * -----------------------------------------------------------------------------------------------*/\n\nconst Primitive = NODES.reduce((primitive, node) => {\n const Node = React.forwardRef((props: PrimitivePropsWithRef<typeof node>, forwardedRef: any) => {\n const { asChild, ...primitiveProps } = props;\n const Comp: any = asChild ? Slot : node;\n\n if (typeof window !== 'undefined') {\n (window as any)[Symbol.for('radix-ui')] = true;\n }\n\n return <Comp {...primitiveProps} ref={forwardedRef} />;\n });\n\n Node.displayName = `Primitive.${node}`;\n\n return { ...primitive, [node]: Node };\n}, {} as Primitives);\n\n/* -------------------------------------------------------------------------------------------------\n * Utils\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * Flush custom event dispatch\n * https://github.com/radix-ui/primitives/pull/1378\n *\n * React batches *all* event handlers since version 18, this introduces certain considerations when using custom event types.\n *\n * Internally, React prioritises events in the following order:\n * - discrete\n * - continuous\n * - default\n *\n * https://github.com/facebook/react/blob/a8a4742f1c54493df00da648a3f9d26e3db9c8b5/packages/react-dom/src/events/ReactDOMEventListener.js#L294-L350\n *\n * `discrete` is an important distinction as updates within these events are applied immediately.\n * React however, is not able to infer the priority of custom event types due to how they are detected internally.\n * Because of this, it's possible for updates from custom events to be unexpectedly batched when\n * dispatched by another `discrete` event.\n *\n * In order to ensure that updates from custom events are applied predictably, we need to manually flush the batch.\n * This utility should be used when dispatching a custom event from within another `discrete` event, this utility\n * is not nessesary when dispatching known event types, or if dispatching a custom type inside a non-discrete event.\n * For example:\n *\n * dispatching a known click \uD83D\uDC4E\n * target.dispatchEvent(new Event(\u2018click\u2019))\n *\n * dispatching a custom type within a non-discrete event \uD83D\uDC4E\n * onScroll={(event) => event.target.dispatchEvent(new CustomEvent(\u2018customType\u2019))}\n *\n * dispatching a custom type within a `discrete` event \uD83D\uDC4D\n * onPointerDown={(event) => dispatchDiscreteCustomEvent(event.target, new CustomEvent(\u2018customType\u2019))}\n *\n * Note: though React classifies `focus`, `focusin` and `focusout` events as `discrete`, it's not recommended to use\n * this utility with them. This is because it's possible for those handlers to be called implicitly during render\n * e.g. when focus is within a component as it is unmounted, or when managing focus on mount.\n */\n\nfunction dispatchDiscreteCustomEvent<E extends CustomEvent>(target: E['target'], event: E) {\n if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Root = Primitive;\n\nexport {\n Primitive,\n //\n Root,\n //\n dispatchDiscreteCustomEvent,\n};\nexport type { PrimitivePropsWithRef };\n"],
+ "mappings": ";AAAA,YAAY,WAAW;AACvB,YAAY,cAAc;AAC1B,SAAS,YAAY;AA0CV;AAxCX,IAAM,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAcA,IAAM,YAAY,MAAM,OAAO,CAAC,WAAW,SAAS;AAClD,QAAM,OAAa,iBAAW,CAAC,OAA2C,iBAAsB;AAC9F,UAAM,EAAE,SAAS,GAAG,eAAe,IAAI;AACvC,UAAM,OAAY,UAAU,OAAO;AAEnC,QAAI,OAAO,WAAW,aAAa;AACjC,MAAC,OAAe,OAAO,IAAI,UAAU,CAAC,IAAI;AAAA,IAC5C;AAEA,WAAO,oBAAC,QAAM,GAAG,gBAAgB,KAAK,cAAc;AAAA,EACtD,CAAC;AAED,OAAK,cAAc,aAAa,IAAI;AAEpC,SAAO,EAAE,GAAG,WAAW,CAAC,IAAI,GAAG,KAAK;AACtC,GAAG,CAAC,CAAe;AA2CnB,SAAS,4BAAmD,QAAqB,OAAU;AACzF,MAAI,OAAQ,CAAS,mBAAU,MAAM,OAAO,cAAc,KAAK,CAAC;AAClE;AAIA,IAAM,OAAO;",
+ "names": []
+}
Modified:package/package.json
Index: package/package.json
===================================================================
--- package/package.json
+++ package/package.json
@@ -1,7 +1,7 @@
{
"name": "@radix-ui/react-primitive",
- "version": "1.0.3",
+ "version": "2.0.0",
"license": "MIT",
"exports": {
".": {
"import": {
@@ -27,19 +27,18 @@
"clean": "rm -rf dist",
"version": "yarn version"
},
"dependencies": {
- "@babel/runtime": "^7.13.10",
- "@radix-ui/react-slot": "1.0.2"
+ "@radix-ui/react-slot": "1.1.0"
},
"devDependencies": {
"@testing-library/react": "^10.4.8"
},
"peerDependencies": {
"@types/react": "*",
"@types/react-dom": "*",
- "react": "^16.8 || ^17.0 || ^18.0",
- "react-dom": "^16.8 || ^17.0 || ^18.0"
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true