pdyform 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -1
- package/example/README.md +36 -0
- package/example/react-demo/dist/assets/index-BBU9cJqy.css +1 -0
- package/example/react-demo/dist/assets/index-DeJS8UcQ.js +105 -0
- package/example/react-demo/dist/index.html +13 -0
- package/example/react-demo/index.html +12 -0
- package/example/react-demo/node_modules/.bin/browserslist +17 -0
- package/example/react-demo/node_modules/.bin/tsc +17 -0
- package/example/react-demo/node_modules/.bin/tsserver +17 -0
- package/example/react-demo/node_modules/.bin/vite +17 -0
- package/example/react-demo/node_modules/.vite/deps/@radix-ui_react-checkbox.js +300 -0
- package/example/react-demo/node_modules/.vite/deps/@radix-ui_react-checkbox.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/@radix-ui_react-label.js +194 -0
- package/example/react-demo/node_modules/.vite/deps/@radix-ui_react-label.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/@radix-ui_react-radio-group.js +530 -0
- package/example/react-demo/node_modules/.vite/deps/@radix-ui_react-radio-group.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/@radix-ui_react-select.js +4808 -0
- package/example/react-demo/node_modules/.vite/deps/@radix-ui_react-select.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/_metadata.json +115 -0
- package/example/react-demo/node_modules/.vite/deps/chunk-3D5PZ6F6.js +49 -0
- package/example/react-demo/node_modules/.vite/deps/chunk-3D5PZ6F6.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/chunk-5Q2RBQLA.js +127 -0
- package/example/react-demo/node_modules/.vite/deps/chunk-5Q2RBQLA.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/chunk-G3PMV62Z.js +36 -0
- package/example/react-demo/node_modules/.vite/deps/chunk-G3PMV62Z.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/chunk-GX7YZ5KV.js +370 -0
- package/example/react-demo/node_modules/.vite/deps/chunk-GX7YZ5KV.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/chunk-PUFJGYAC.js +928 -0
- package/example/react-demo/node_modules/.vite/deps/chunk-PUFJGYAC.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/chunk-SIU35MPB.js +21 -0
- package/example/react-demo/node_modules/.vite/deps/chunk-SIU35MPB.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/chunk-TOMGVNQP.js +1906 -0
- package/example/react-demo/node_modules/.vite/deps/chunk-TOMGVNQP.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/chunk-YYN6DZAU.js +21628 -0
- package/example/react-demo/node_modules/.vite/deps/chunk-YYN6DZAU.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/chunk-ZE5VSJFE.js +144 -0
- package/example/react-demo/node_modules/.vite/deps/chunk-ZE5VSJFE.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/class-variance-authority.js +51 -0
- package/example/react-demo/node_modules/.vite/deps/class-variance-authority.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/clsx.js +10 -0
- package/example/react-demo/node_modules/.vite/deps/clsx.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/lucide-react.js +29725 -0
- package/example/react-demo/node_modules/.vite/deps/lucide-react.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/package.json +3 -0
- package/example/react-demo/node_modules/.vite/deps/react-dom.js +7 -0
- package/example/react-demo/node_modules/.vite/deps/react-dom.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/react-dom_client.js +39 -0
- package/example/react-demo/node_modules/.vite/deps/react-dom_client.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/react.js +6 -0
- package/example/react-demo/node_modules/.vite/deps/react.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/react_jsx-dev-runtime.js +913 -0
- package/example/react-demo/node_modules/.vite/deps/react_jsx-dev-runtime.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/react_jsx-runtime.js +7 -0
- package/example/react-demo/node_modules/.vite/deps/react_jsx-runtime.js.map +7 -0
- package/example/react-demo/node_modules/.vite/deps/tailwind-merge.js +2534 -0
- package/example/react-demo/node_modules/.vite/deps/tailwind-merge.js.map +7 -0
- package/example/react-demo/package.json +23 -0
- package/example/react-demo/postcss.config.mjs +6 -0
- package/example/react-demo/src/App.tsx +64 -0
- package/example/react-demo/src/main.tsx +10 -0
- package/example/react-demo/src/styles.css +102 -0
- package/example/react-demo/tailwind.config.mjs +50 -0
- package/example/react-demo/tsconfig.json +16 -0
- package/example/react-demo/vite.config.ts +14 -0
- package/example/shared/defaultSchema.ts +68 -0
- package/example/vue-demo/dist/assets/index-BhWj3D5x.css +1 -0
- package/example/vue-demo/dist/assets/index-Bw3THsrD.js +44 -0
- package/example/vue-demo/dist/index.html +13 -0
- package/example/vue-demo/index.html +12 -0
- package/example/vue-demo/node_modules/.bin/tsc +17 -0
- package/example/vue-demo/node_modules/.bin/tsserver +17 -0
- package/example/vue-demo/node_modules/.bin/vite +17 -0
- package/example/vue-demo/node_modules/.vite/deps/_metadata.json +46 -0
- package/example/vue-demo/node_modules/.vite/deps/chunk-PZ5AY32C.js +10 -0
- package/example/vue-demo/node_modules/.vite/deps/chunk-PZ5AY32C.js.map +7 -0
- package/example/vue-demo/node_modules/.vite/deps/chunk-TCXBSQ4M.js +12877 -0
- package/example/vue-demo/node_modules/.vite/deps/chunk-TCXBSQ4M.js.map +7 -0
- package/example/vue-demo/node_modules/.vite/deps/clsx.js +22 -0
- package/example/vue-demo/node_modules/.vite/deps/clsx.js.map +7 -0
- package/example/vue-demo/node_modules/.vite/deps/lucide-vue-next.js +29720 -0
- package/example/vue-demo/node_modules/.vite/deps/lucide-vue-next.js.map +7 -0
- package/example/vue-demo/node_modules/.vite/deps/package.json +3 -0
- package/example/vue-demo/node_modules/.vite/deps/radix-vue.js +24321 -0
- package/example/vue-demo/node_modules/.vite/deps/radix-vue.js.map +7 -0
- package/example/vue-demo/node_modules/.vite/deps/tailwind-merge.js +2534 -0
- package/example/vue-demo/node_modules/.vite/deps/tailwind-merge.js.map +7 -0
- package/example/vue-demo/node_modules/.vite/deps/vue.js +348 -0
- package/example/vue-demo/node_modules/.vite/deps/vue.js.map +7 -0
- package/example/vue-demo/package.json +20 -0
- package/example/vue-demo/postcss.config.mjs +6 -0
- package/example/vue-demo/src/App.vue +61 -0
- package/example/vue-demo/src/env.d.ts +1 -0
- package/example/vue-demo/src/main.ts +5 -0
- package/example/vue-demo/src/style.css +102 -0
- package/example/vue-demo/tailwind.config.mjs +50 -0
- package/example/vue-demo/tsconfig.json +15 -0
- package/example/vue-demo/vite.config.ts +14 -0
- package/package.json +10 -2
- package/packages/core/dist/{chunk-KQR3LFND.js → chunk-GQASS6PM.js} +20 -0
- package/packages/core/dist/index.cjs +20 -0
- package/packages/core/dist/index.js +1 -1
- package/packages/core/dist/utils.cjs +20 -0
- package/packages/core/dist/utils.js +1 -1
- package/packages/core/node_modules/.bin/jiti +17 -0
- package/packages/core/node_modules/.bin/tsup +2 -2
- package/packages/core/node_modules/.bin/tsup-node +2 -2
- package/packages/core/node_modules/.vite/vitest/results.json +1 -1
- package/packages/core/src/utils.ts +21 -0
- package/packages/core/test/utils.test.ts +99 -0
- package/packages/react/dist/index.cjs +383 -110
- package/packages/react/dist/index.d.cts +80 -4
- package/packages/react/dist/index.d.ts +80 -4
- package/packages/react/dist/index.js +355 -110
- package/packages/react/node_modules/.bin/jiti +17 -0
- package/packages/react/node_modules/.bin/tsup +2 -2
- package/packages/react/node_modules/.bin/tsup-node +2 -2
- package/packages/react/node_modules/.bin/vite +4 -4
- package/packages/react/node_modules/.vite/vitest/results.json +1 -1
- package/packages/react/package.json +7 -2
- package/packages/react/postcss.config.mjs +6 -0
- package/packages/react/src/FormFieldRenderer.tsx +32 -112
- package/packages/react/src/components/Checkbox.tsx +28 -0
- package/packages/react/src/components/CheckboxRenderer.tsx +37 -0
- package/packages/react/src/components/Input.tsx +24 -0
- package/packages/react/src/components/InputRenderer.tsx +29 -0
- package/packages/react/src/components/Label.tsx +24 -0
- package/packages/react/src/components/RadioGroup.tsx +42 -0
- package/packages/react/src/components/RadioRenderer.tsx +29 -0
- package/packages/react/src/components/Select.tsx +93 -0
- package/packages/react/src/components/SelectRenderer.tsx +27 -0
- package/packages/react/src/components/Textarea.tsx +23 -0
- package/packages/react/src/components/TextareaRenderer.tsx +17 -0
- package/packages/react/src/components/index.ts +55 -0
- package/packages/react/src/components/types.ts +17 -0
- package/packages/react/src/index.tsx +1 -0
- package/packages/react/src/utils.ts +7 -0
- package/packages/react/tailwind.config.mjs +10 -0
- package/packages/react/test/FormFieldRenderer.test.tsx +127 -0
- package/packages/vue/dist/index.d.ts +33 -0
- package/packages/vue/dist/index.js +28 -1
- package/packages/vue/dist/index.mjs +6798 -142
- package/packages/vue/node_modules/.bin/tsc +2 -2
- package/packages/vue/node_modules/.bin/tsserver +2 -2
- package/packages/vue/node_modules/.bin/vite +2 -2
- package/packages/vue/node_modules/.bin/vitest +2 -2
- package/packages/vue/node_modules/.bin/vue-tsc +2 -2
- package/packages/vue/node_modules/.vite/vitest/results.json +1 -1
- package/packages/vue/package.json +4 -2
- package/packages/vue/postcss.config.mjs +6 -0
- package/packages/vue/src/FormFieldRenderer.vue +46 -90
- package/packages/vue/src/components/Checkbox.vue +28 -0
- package/packages/vue/src/components/CheckboxRenderer.vue +35 -0
- package/packages/vue/src/components/Input.vue +21 -0
- package/packages/vue/src/components/InputRenderer.vue +28 -0
- package/packages/vue/src/components/Label.vue +21 -0
- package/packages/vue/src/components/RadioGroup.vue +30 -0
- package/packages/vue/src/components/RadioGroupItem.vue +26 -0
- package/packages/vue/src/components/RadioRenderer.vue +24 -0
- package/packages/vue/src/components/Select.vue +40 -0
- package/packages/vue/src/components/SelectContent.vue +38 -0
- package/packages/vue/src/components/SelectItem.vue +43 -0
- package/packages/vue/src/components/SelectRenderer.vue +30 -0
- package/packages/vue/src/components/SelectTrigger.vue +27 -0
- package/packages/vue/src/components/Textarea.vue +19 -0
- package/packages/vue/src/components/TextareaRenderer.vue +18 -0
- package/packages/vue/src/components/index.ts +24 -0
- package/packages/vue/src/fieldComponentMap.ts +34 -0
- package/packages/vue/src/index.ts +2 -0
- package/packages/vue/src/utils.ts +6 -0
- package/packages/vue/tailwind.config.mjs +10 -0
- package/packages/vue/test/FormFieldRenderer.test.ts +133 -0
- package/pnpm-workspace.yaml +1 -1
- package/packages/core/src/index.test.ts +0 -37
- /package/packages/react/{src → test}/DynamicForm.test.tsx +0 -0
- /package/packages/vue/{src → test}/DynamicForm.test.ts +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../node_modules/.pnpm/@radix-ui+react-label@2.1.8_@types+react-dom@18.3.7_@types+react@18.3.28__@types+react@18.3.2_ikkobmmbjpasbqgco5lgrwp2hu/node_modules/@radix-ui/react-label/src/label.tsx", "../../../../../node_modules/.pnpm/@radix-ui+react-primitive@2.1.4_@types+react-dom@18.3.7_@types+react@18.3.28__@types+react@18_5m4njbrt5jjaaqsixv4pcsp64y/node_modules/@radix-ui/react-primitive/src/primitive.tsx", "../../../../../node_modules/.pnpm/@radix-ui+react-slot@1.2.4_@types+react@18.3.28_react@18.3.1/node_modules/@radix-ui/react-slot/src/slot.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport { Primitive } from '@radix-ui/react-primitive';\n\n/* -------------------------------------------------------------------------------------------------\n * Label\n * -----------------------------------------------------------------------------------------------*/\n\nconst NAME = 'Label';\n\ntype LabelElement = React.ComponentRef<typeof Primitive.label>;\ntype PrimitiveLabelProps = React.ComponentPropsWithoutRef<typeof Primitive.label>;\ninterface LabelProps extends PrimitiveLabelProps {}\n\nconst Label = React.forwardRef<LabelElement, LabelProps>((props, forwardedRef) => {\n return (\n <Primitive.label\n {...props}\n ref={forwardedRef}\n onMouseDown={(event) => {\n // only prevent text selection if clicking inside the label itself\n const target = event.target as HTMLElement;\n if (target.closest('button, input, select, textarea')) return;\n\n props.onMouseDown?.(event);\n // prevent text selection when double clicking label\n if (!event.defaultPrevented && event.detail > 1) event.preventDefault();\n }}\n />\n );\n});\n\nLabel.displayName = NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Root = Label;\n\nexport {\n Label,\n //\n Root,\n};\nexport type { LabelProps };\n", "import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { createSlot } 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 'select',\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 Slot = createSlot(`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 necessary 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", "import * as React from 'react';\nimport { composeRefs } from '@radix-ui/react-compose-refs';\n\ndeclare module 'react' {\n interface ReactElement {\n $$typeof?: symbol | string;\n }\n}\n\nconst REACT_LAZY_TYPE = Symbol.for('react.lazy');\n\ninterface LazyReactElement extends React.ReactElement {\n $$typeof: typeof REACT_LAZY_TYPE;\n _payload: PromiseLike<Exclude<React.ReactNode, PromiseLike<any>>>;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\nexport type Usable<T> = PromiseLike<T> | React.Context<T>;\nconst use: typeof React.use | undefined = (React as any)[' use '.trim().toString()];\n\ninterface SlotProps extends React.HTMLAttributes<HTMLElement> {\n children?: React.ReactNode;\n}\n\nfunction isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return typeof value === 'object' && value !== null && 'then' in value;\n}\n\nfunction isLazyComponent(element: React.ReactNode): element is LazyReactElement {\n return (\n element != null &&\n typeof element === 'object' &&\n '$$typeof' in element &&\n element.$$typeof === REACT_LAZY_TYPE &&\n '_payload' in element &&\n isPromiseLike(element._payload)\n );\n}\n\n/* @__NO_SIDE_EFFECTS__ */ export function createSlot(ownerName: string) {\n const SlotClone = createSlotClone(ownerName);\n const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n let { children, ...slotProps } = props;\n if (isLazyComponent(children) && typeof use === 'function') {\n children = use(children._payload);\n }\n const childrenArray = React.Children.toArray(children);\n const slottable = childrenArray.find(isSlottable);\n\n if (slottable) {\n // the new element to render is the one passed as a child of `Slottable`\n const newElement = slottable.props.children;\n\n const newChildren = childrenArray.map((child) => {\n if (child === slottable) {\n // because the new element will be the one rendered, we are only interested\n // in grabbing its children (`newElement.props.children`)\n if (React.Children.count(newElement) > 1) return React.Children.only(null);\n return React.isValidElement(newElement)\n ? (newElement.props as { children: React.ReactNode }).children\n : null;\n } else {\n return child;\n }\n });\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {React.isValidElement(newElement)\n ? React.cloneElement(newElement, undefined, newChildren)\n : null}\n </SlotClone>\n );\n }\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n );\n });\n\n Slot.displayName = `${ownerName}.Slot`;\n return Slot;\n}\n\nconst Slot = createSlot('Slot');\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n children: React.ReactNode;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ function createSlotClone(ownerName: string) {\n const SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n let { children, ...slotProps } = props;\n if (isLazyComponent(children) && typeof use === 'function') {\n children = use(children._payload);\n }\n\n if (React.isValidElement(children)) {\n const childrenRef = getElementRef(children);\n const props = mergeProps(slotProps, children.props as AnyProps);\n // do not pass ref to React.Fragment for React 19 compatibility\n if (children.type !== React.Fragment) {\n props.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;\n }\n return React.cloneElement(children, props);\n }\n\n return React.Children.count(children) > 1 ? React.Children.only(null) : null;\n });\n\n SlotClone.displayName = `${ownerName}.SlotClone`;\n return SlotClone;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nconst SLOTTABLE_IDENTIFIER = Symbol('radix.slottable');\n\ninterface SlottableProps {\n children: React.ReactNode;\n}\n\ninterface SlottableComponent extends React.FC<SlottableProps> {\n __radixId: symbol;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ export function createSlottable(ownerName: string) {\n const Slottable: SlottableComponent = ({ children }) => {\n return <>{children}</>;\n };\n Slottable.displayName = `${ownerName}.Slottable`;\n Slottable.__radixId = SLOTTABLE_IDENTIFIER;\n return Slottable;\n}\n\nconst Slottable = createSlottable('Slottable');\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>;\n\nfunction isSlottable(\n child: React.ReactNode,\n): child is React.ReactElement<SlottableProps, typeof Slottable> {\n return (\n React.isValidElement(child) &&\n typeof child.type === 'function' &&\n '__radixId' in child.type &&\n child.type.__radixId === SLOTTABLE_IDENTIFIER\n );\n}\n\nfunction mergeProps(slotProps: AnyProps, childProps: AnyProps) {\n // all child props should override\n const overrideProps = { ...childProps };\n\n for (const propName in childProps) {\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n\n const isHandler = /^on[A-Z]/.test(propName);\n if (isHandler) {\n // if the handler exists on both, we compose them\n if (slotPropValue && childPropValue) {\n overrideProps[propName] = (...args: unknown[]) => {\n const result = childPropValue(...args);\n slotPropValue(...args);\n return result;\n };\n }\n // but if it exists only on the slot, we use only this one\n else if (slotPropValue) {\n overrideProps[propName] = slotPropValue;\n }\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue };\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ');\n }\n }\n\n return { ...slotProps, ...overrideProps };\n}\n\n// Before React 19 accessing `element.props.ref` will throw a warning and suggest using `element.ref`\n// After React 19 accessing `element.ref` does the opposite.\n// https://github.com/facebook/react/pull/28348\n//\n// Access the ref using the method that doesn't yield a warning.\nfunction getElementRef(element: React.ReactElement) {\n // React <=18 in DEV\n let getter = Object.getOwnPropertyDescriptor(element.props, 'ref')?.get;\n let mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n if (mayWarn) {\n return (element as any).ref;\n }\n\n // React 19 in DEV\n getter = Object.getOwnPropertyDescriptor(element, 'ref')?.get;\n mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n if (mayWarn) {\n return (element.props as { ref?: React.Ref<unknown> }).ref;\n }\n\n // Not DEV\n return (element.props as { ref?: React.Ref<unknown> }).ref || (element as any).ref;\n}\n\nexport {\n Slot,\n Slottable,\n //\n Slot as Root,\n};\nexport type { SlotProps };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAuB;;;ACAvB,IAAAC,SAAuB;AACvB,eAA0B;;;ACD1B,YAAuB;AAsEf,yBAAA;AA7DR,IAAM,kBAAkB,OAAO,IAAI,YAAY;AAY/C,IAAM,MAAqC,MAAc,QAAQ,KAAK,EAAE,SAAS,CAAC;AAMlF,SAAS,cAAc,OAA+C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AAe;;;ADrCf,IAAAC,sBAAA;AARJ,IAAM,OAAO;AAMb,IAAM,QAAc,kBAAqC,CAAC,OAAO,iBAAiB;AAChF,aACE;IAAC,UAAU;IAAV;MACE,GAAG;MACJ,KAAK;MACL,aAAa,CAAC,UAAU;;AAEtB,cAAM,SAAS,MAAM;AACrB,YAAI,OAAO,QAAQ,iCAAiC,EAAG;AAEvD,oBAAM,gBAAN,+BAAoB;AAEpB,YAAI,CAAC,MAAM,oBAAoB,MAAM,SAAS,EAAG,OAAM,eAAe;MACxE;IAAA;EACF;AAEJ,CAAC;AAED,MAAM,cAAc;AAIpB,IAAM,OAAO;",
|
|
6
|
+
"names": ["React", "React", "Slot", "props", "Slottable", "Fragment", "import_jsx_runtime", "Slot", "import_jsx_runtime"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Presence
|
|
4
|
+
} from "./chunk-ZE5VSJFE.js";
|
|
5
|
+
import {
|
|
6
|
+
createCollection,
|
|
7
|
+
useCallbackRef,
|
|
8
|
+
useDirection,
|
|
9
|
+
useId
|
|
10
|
+
} from "./chunk-5Q2RBQLA.js";
|
|
11
|
+
import {
|
|
12
|
+
Primitive,
|
|
13
|
+
composeEventHandlers,
|
|
14
|
+
createContextScope,
|
|
15
|
+
useControllableState,
|
|
16
|
+
usePrevious,
|
|
17
|
+
useSize
|
|
18
|
+
} from "./chunk-GX7YZ5KV.js";
|
|
19
|
+
import {
|
|
20
|
+
useComposedRefs
|
|
21
|
+
} from "./chunk-3D5PZ6F6.js";
|
|
22
|
+
import "./chunk-YYN6DZAU.js";
|
|
23
|
+
import {
|
|
24
|
+
require_jsx_runtime
|
|
25
|
+
} from "./chunk-PUFJGYAC.js";
|
|
26
|
+
import {
|
|
27
|
+
require_react
|
|
28
|
+
} from "./chunk-TOMGVNQP.js";
|
|
29
|
+
import {
|
|
30
|
+
__toESM
|
|
31
|
+
} from "./chunk-G3PMV62Z.js";
|
|
32
|
+
|
|
33
|
+
// ../../node_modules/.pnpm/@radix-ui+react-radio-group@1.3.8_@types+react-dom@18.3.7_@types+react@18.3.28__@types+react@_ikqgihfiueu52yvwwtlqfp4l7u/node_modules/@radix-ui/react-radio-group/dist/index.mjs
|
|
34
|
+
var React2 = __toESM(require_react(), 1);
|
|
35
|
+
|
|
36
|
+
// ../../node_modules/.pnpm/@radix-ui+react-roving-focus@1.1.11_@types+react-dom@18.3.7_@types+react@18.3.28__@types+reac_hp3yyvshcme64xtgeexy2xq53y/node_modules/@radix-ui/react-roving-focus/dist/index.mjs
|
|
37
|
+
var React = __toESM(require_react(), 1);
|
|
38
|
+
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
39
|
+
var ENTRY_FOCUS = "rovingFocusGroup.onEntryFocus";
|
|
40
|
+
var EVENT_OPTIONS = { bubbles: false, cancelable: true };
|
|
41
|
+
var GROUP_NAME = "RovingFocusGroup";
|
|
42
|
+
var [Collection, useCollection, createCollectionScope] = createCollection(GROUP_NAME);
|
|
43
|
+
var [createRovingFocusGroupContext, createRovingFocusGroupScope] = createContextScope(
|
|
44
|
+
GROUP_NAME,
|
|
45
|
+
[createCollectionScope]
|
|
46
|
+
);
|
|
47
|
+
var [RovingFocusProvider, useRovingFocusContext] = createRovingFocusGroupContext(GROUP_NAME);
|
|
48
|
+
var RovingFocusGroup = React.forwardRef(
|
|
49
|
+
(props, forwardedRef) => {
|
|
50
|
+
return (0, import_jsx_runtime.jsx)(Collection.Provider, { scope: props.__scopeRovingFocusGroup, children: (0, import_jsx_runtime.jsx)(Collection.Slot, { scope: props.__scopeRovingFocusGroup, children: (0, import_jsx_runtime.jsx)(RovingFocusGroupImpl, { ...props, ref: forwardedRef }) }) });
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
RovingFocusGroup.displayName = GROUP_NAME;
|
|
54
|
+
var RovingFocusGroupImpl = React.forwardRef((props, forwardedRef) => {
|
|
55
|
+
const {
|
|
56
|
+
__scopeRovingFocusGroup,
|
|
57
|
+
orientation,
|
|
58
|
+
loop = false,
|
|
59
|
+
dir,
|
|
60
|
+
currentTabStopId: currentTabStopIdProp,
|
|
61
|
+
defaultCurrentTabStopId,
|
|
62
|
+
onCurrentTabStopIdChange,
|
|
63
|
+
onEntryFocus,
|
|
64
|
+
preventScrollOnEntryFocus = false,
|
|
65
|
+
...groupProps
|
|
66
|
+
} = props;
|
|
67
|
+
const ref = React.useRef(null);
|
|
68
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
69
|
+
const direction = useDirection(dir);
|
|
70
|
+
const [currentTabStopId, setCurrentTabStopId] = useControllableState({
|
|
71
|
+
prop: currentTabStopIdProp,
|
|
72
|
+
defaultProp: defaultCurrentTabStopId ?? null,
|
|
73
|
+
onChange: onCurrentTabStopIdChange,
|
|
74
|
+
caller: GROUP_NAME
|
|
75
|
+
});
|
|
76
|
+
const [isTabbingBackOut, setIsTabbingBackOut] = React.useState(false);
|
|
77
|
+
const handleEntryFocus = useCallbackRef(onEntryFocus);
|
|
78
|
+
const getItems = useCollection(__scopeRovingFocusGroup);
|
|
79
|
+
const isClickFocusRef = React.useRef(false);
|
|
80
|
+
const [focusableItemsCount, setFocusableItemsCount] = React.useState(0);
|
|
81
|
+
React.useEffect(() => {
|
|
82
|
+
const node = ref.current;
|
|
83
|
+
if (node) {
|
|
84
|
+
node.addEventListener(ENTRY_FOCUS, handleEntryFocus);
|
|
85
|
+
return () => node.removeEventListener(ENTRY_FOCUS, handleEntryFocus);
|
|
86
|
+
}
|
|
87
|
+
}, [handleEntryFocus]);
|
|
88
|
+
return (0, import_jsx_runtime.jsx)(
|
|
89
|
+
RovingFocusProvider,
|
|
90
|
+
{
|
|
91
|
+
scope: __scopeRovingFocusGroup,
|
|
92
|
+
orientation,
|
|
93
|
+
dir: direction,
|
|
94
|
+
loop,
|
|
95
|
+
currentTabStopId,
|
|
96
|
+
onItemFocus: React.useCallback(
|
|
97
|
+
(tabStopId) => setCurrentTabStopId(tabStopId),
|
|
98
|
+
[setCurrentTabStopId]
|
|
99
|
+
),
|
|
100
|
+
onItemShiftTab: React.useCallback(() => setIsTabbingBackOut(true), []),
|
|
101
|
+
onFocusableItemAdd: React.useCallback(
|
|
102
|
+
() => setFocusableItemsCount((prevCount) => prevCount + 1),
|
|
103
|
+
[]
|
|
104
|
+
),
|
|
105
|
+
onFocusableItemRemove: React.useCallback(
|
|
106
|
+
() => setFocusableItemsCount((prevCount) => prevCount - 1),
|
|
107
|
+
[]
|
|
108
|
+
),
|
|
109
|
+
children: (0, import_jsx_runtime.jsx)(
|
|
110
|
+
Primitive.div,
|
|
111
|
+
{
|
|
112
|
+
tabIndex: isTabbingBackOut || focusableItemsCount === 0 ? -1 : 0,
|
|
113
|
+
"data-orientation": orientation,
|
|
114
|
+
...groupProps,
|
|
115
|
+
ref: composedRefs,
|
|
116
|
+
style: { outline: "none", ...props.style },
|
|
117
|
+
onMouseDown: composeEventHandlers(props.onMouseDown, () => {
|
|
118
|
+
isClickFocusRef.current = true;
|
|
119
|
+
}),
|
|
120
|
+
onFocus: composeEventHandlers(props.onFocus, (event) => {
|
|
121
|
+
const isKeyboardFocus = !isClickFocusRef.current;
|
|
122
|
+
if (event.target === event.currentTarget && isKeyboardFocus && !isTabbingBackOut) {
|
|
123
|
+
const entryFocusEvent = new CustomEvent(ENTRY_FOCUS, EVENT_OPTIONS);
|
|
124
|
+
event.currentTarget.dispatchEvent(entryFocusEvent);
|
|
125
|
+
if (!entryFocusEvent.defaultPrevented) {
|
|
126
|
+
const items = getItems().filter((item) => item.focusable);
|
|
127
|
+
const activeItem = items.find((item) => item.active);
|
|
128
|
+
const currentItem = items.find((item) => item.id === currentTabStopId);
|
|
129
|
+
const candidateItems = [activeItem, currentItem, ...items].filter(
|
|
130
|
+
Boolean
|
|
131
|
+
);
|
|
132
|
+
const candidateNodes = candidateItems.map((item) => item.ref.current);
|
|
133
|
+
focusFirst(candidateNodes, preventScrollOnEntryFocus);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
isClickFocusRef.current = false;
|
|
137
|
+
}),
|
|
138
|
+
onBlur: composeEventHandlers(props.onBlur, () => setIsTabbingBackOut(false))
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
});
|
|
144
|
+
var ITEM_NAME = "RovingFocusGroupItem";
|
|
145
|
+
var RovingFocusGroupItem = React.forwardRef(
|
|
146
|
+
(props, forwardedRef) => {
|
|
147
|
+
const {
|
|
148
|
+
__scopeRovingFocusGroup,
|
|
149
|
+
focusable = true,
|
|
150
|
+
active = false,
|
|
151
|
+
tabStopId,
|
|
152
|
+
children,
|
|
153
|
+
...itemProps
|
|
154
|
+
} = props;
|
|
155
|
+
const autoId = useId();
|
|
156
|
+
const id = tabStopId || autoId;
|
|
157
|
+
const context = useRovingFocusContext(ITEM_NAME, __scopeRovingFocusGroup);
|
|
158
|
+
const isCurrentTabStop = context.currentTabStopId === id;
|
|
159
|
+
const getItems = useCollection(__scopeRovingFocusGroup);
|
|
160
|
+
const { onFocusableItemAdd, onFocusableItemRemove, currentTabStopId } = context;
|
|
161
|
+
React.useEffect(() => {
|
|
162
|
+
if (focusable) {
|
|
163
|
+
onFocusableItemAdd();
|
|
164
|
+
return () => onFocusableItemRemove();
|
|
165
|
+
}
|
|
166
|
+
}, [focusable, onFocusableItemAdd, onFocusableItemRemove]);
|
|
167
|
+
return (0, import_jsx_runtime.jsx)(
|
|
168
|
+
Collection.ItemSlot,
|
|
169
|
+
{
|
|
170
|
+
scope: __scopeRovingFocusGroup,
|
|
171
|
+
id,
|
|
172
|
+
focusable,
|
|
173
|
+
active,
|
|
174
|
+
children: (0, import_jsx_runtime.jsx)(
|
|
175
|
+
Primitive.span,
|
|
176
|
+
{
|
|
177
|
+
tabIndex: isCurrentTabStop ? 0 : -1,
|
|
178
|
+
"data-orientation": context.orientation,
|
|
179
|
+
...itemProps,
|
|
180
|
+
ref: forwardedRef,
|
|
181
|
+
onMouseDown: composeEventHandlers(props.onMouseDown, (event) => {
|
|
182
|
+
if (!focusable) event.preventDefault();
|
|
183
|
+
else context.onItemFocus(id);
|
|
184
|
+
}),
|
|
185
|
+
onFocus: composeEventHandlers(props.onFocus, () => context.onItemFocus(id)),
|
|
186
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
187
|
+
if (event.key === "Tab" && event.shiftKey) {
|
|
188
|
+
context.onItemShiftTab();
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (event.target !== event.currentTarget) return;
|
|
192
|
+
const focusIntent = getFocusIntent(event, context.orientation, context.dir);
|
|
193
|
+
if (focusIntent !== void 0) {
|
|
194
|
+
if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return;
|
|
195
|
+
event.preventDefault();
|
|
196
|
+
const items = getItems().filter((item) => item.focusable);
|
|
197
|
+
let candidateNodes = items.map((item) => item.ref.current);
|
|
198
|
+
if (focusIntent === "last") candidateNodes.reverse();
|
|
199
|
+
else if (focusIntent === "prev" || focusIntent === "next") {
|
|
200
|
+
if (focusIntent === "prev") candidateNodes.reverse();
|
|
201
|
+
const currentIndex = candidateNodes.indexOf(event.currentTarget);
|
|
202
|
+
candidateNodes = context.loop ? wrapArray(candidateNodes, currentIndex + 1) : candidateNodes.slice(currentIndex + 1);
|
|
203
|
+
}
|
|
204
|
+
setTimeout(() => focusFirst(candidateNodes));
|
|
205
|
+
}
|
|
206
|
+
}),
|
|
207
|
+
children: typeof children === "function" ? children({ isCurrentTabStop, hasTabStop: currentTabStopId != null }) : children
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
RovingFocusGroupItem.displayName = ITEM_NAME;
|
|
215
|
+
var MAP_KEY_TO_FOCUS_INTENT = {
|
|
216
|
+
ArrowLeft: "prev",
|
|
217
|
+
ArrowUp: "prev",
|
|
218
|
+
ArrowRight: "next",
|
|
219
|
+
ArrowDown: "next",
|
|
220
|
+
PageUp: "first",
|
|
221
|
+
Home: "first",
|
|
222
|
+
PageDown: "last",
|
|
223
|
+
End: "last"
|
|
224
|
+
};
|
|
225
|
+
function getDirectionAwareKey(key, dir) {
|
|
226
|
+
if (dir !== "rtl") return key;
|
|
227
|
+
return key === "ArrowLeft" ? "ArrowRight" : key === "ArrowRight" ? "ArrowLeft" : key;
|
|
228
|
+
}
|
|
229
|
+
function getFocusIntent(event, orientation, dir) {
|
|
230
|
+
const key = getDirectionAwareKey(event.key, dir);
|
|
231
|
+
if (orientation === "vertical" && ["ArrowLeft", "ArrowRight"].includes(key)) return void 0;
|
|
232
|
+
if (orientation === "horizontal" && ["ArrowUp", "ArrowDown"].includes(key)) return void 0;
|
|
233
|
+
return MAP_KEY_TO_FOCUS_INTENT[key];
|
|
234
|
+
}
|
|
235
|
+
function focusFirst(candidates, preventScroll = false) {
|
|
236
|
+
const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
|
|
237
|
+
for (const candidate of candidates) {
|
|
238
|
+
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
239
|
+
candidate.focus({ preventScroll });
|
|
240
|
+
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function wrapArray(array, startIndex) {
|
|
244
|
+
return array.map((_, index) => array[(startIndex + index) % array.length]);
|
|
245
|
+
}
|
|
246
|
+
var Root = RovingFocusGroup;
|
|
247
|
+
var Item = RovingFocusGroupItem;
|
|
248
|
+
|
|
249
|
+
// ../../node_modules/.pnpm/@radix-ui+react-radio-group@1.3.8_@types+react-dom@18.3.7_@types+react@18.3.28__@types+react@_ikqgihfiueu52yvwwtlqfp4l7u/node_modules/@radix-ui/react-radio-group/dist/index.mjs
|
|
250
|
+
var React3 = __toESM(require_react(), 1);
|
|
251
|
+
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
|
|
252
|
+
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
|
|
253
|
+
var RADIO_NAME = "Radio";
|
|
254
|
+
var [createRadioContext, createRadioScope] = createContextScope(RADIO_NAME);
|
|
255
|
+
var [RadioProvider, useRadioContext] = createRadioContext(RADIO_NAME);
|
|
256
|
+
var Radio = React3.forwardRef(
|
|
257
|
+
(props, forwardedRef) => {
|
|
258
|
+
const {
|
|
259
|
+
__scopeRadio,
|
|
260
|
+
name,
|
|
261
|
+
checked = false,
|
|
262
|
+
required,
|
|
263
|
+
disabled,
|
|
264
|
+
value = "on",
|
|
265
|
+
onCheck,
|
|
266
|
+
form,
|
|
267
|
+
...radioProps
|
|
268
|
+
} = props;
|
|
269
|
+
const [button, setButton] = React3.useState(null);
|
|
270
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));
|
|
271
|
+
const hasConsumerStoppedPropagationRef = React3.useRef(false);
|
|
272
|
+
const isFormControl = button ? form || !!button.closest("form") : true;
|
|
273
|
+
return (0, import_jsx_runtime2.jsxs)(RadioProvider, { scope: __scopeRadio, checked, disabled, children: [
|
|
274
|
+
(0, import_jsx_runtime2.jsx)(
|
|
275
|
+
Primitive.button,
|
|
276
|
+
{
|
|
277
|
+
type: "button",
|
|
278
|
+
role: "radio",
|
|
279
|
+
"aria-checked": checked,
|
|
280
|
+
"data-state": getState(checked),
|
|
281
|
+
"data-disabled": disabled ? "" : void 0,
|
|
282
|
+
disabled,
|
|
283
|
+
value,
|
|
284
|
+
...radioProps,
|
|
285
|
+
ref: composedRefs,
|
|
286
|
+
onClick: composeEventHandlers(props.onClick, (event) => {
|
|
287
|
+
if (!checked) onCheck == null ? void 0 : onCheck();
|
|
288
|
+
if (isFormControl) {
|
|
289
|
+
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
290
|
+
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
|
|
291
|
+
}
|
|
292
|
+
})
|
|
293
|
+
}
|
|
294
|
+
),
|
|
295
|
+
isFormControl && (0, import_jsx_runtime2.jsx)(
|
|
296
|
+
RadioBubbleInput,
|
|
297
|
+
{
|
|
298
|
+
control: button,
|
|
299
|
+
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
300
|
+
name,
|
|
301
|
+
value,
|
|
302
|
+
checked,
|
|
303
|
+
required,
|
|
304
|
+
disabled,
|
|
305
|
+
form,
|
|
306
|
+
style: { transform: "translateX(-100%)" }
|
|
307
|
+
}
|
|
308
|
+
)
|
|
309
|
+
] });
|
|
310
|
+
}
|
|
311
|
+
);
|
|
312
|
+
Radio.displayName = RADIO_NAME;
|
|
313
|
+
var INDICATOR_NAME = "RadioIndicator";
|
|
314
|
+
var RadioIndicator = React3.forwardRef(
|
|
315
|
+
(props, forwardedRef) => {
|
|
316
|
+
const { __scopeRadio, forceMount, ...indicatorProps } = props;
|
|
317
|
+
const context = useRadioContext(INDICATOR_NAME, __scopeRadio);
|
|
318
|
+
return (0, import_jsx_runtime2.jsx)(Presence, { present: forceMount || context.checked, children: (0, import_jsx_runtime2.jsx)(
|
|
319
|
+
Primitive.span,
|
|
320
|
+
{
|
|
321
|
+
"data-state": getState(context.checked),
|
|
322
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
323
|
+
...indicatorProps,
|
|
324
|
+
ref: forwardedRef
|
|
325
|
+
}
|
|
326
|
+
) });
|
|
327
|
+
}
|
|
328
|
+
);
|
|
329
|
+
RadioIndicator.displayName = INDICATOR_NAME;
|
|
330
|
+
var BUBBLE_INPUT_NAME = "RadioBubbleInput";
|
|
331
|
+
var RadioBubbleInput = React3.forwardRef(
|
|
332
|
+
({
|
|
333
|
+
__scopeRadio,
|
|
334
|
+
control,
|
|
335
|
+
checked,
|
|
336
|
+
bubbles = true,
|
|
337
|
+
...props
|
|
338
|
+
}, forwardedRef) => {
|
|
339
|
+
const ref = React3.useRef(null);
|
|
340
|
+
const composedRefs = useComposedRefs(ref, forwardedRef);
|
|
341
|
+
const prevChecked = usePrevious(checked);
|
|
342
|
+
const controlSize = useSize(control);
|
|
343
|
+
React3.useEffect(() => {
|
|
344
|
+
const input = ref.current;
|
|
345
|
+
if (!input) return;
|
|
346
|
+
const inputProto = window.HTMLInputElement.prototype;
|
|
347
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
348
|
+
inputProto,
|
|
349
|
+
"checked"
|
|
350
|
+
);
|
|
351
|
+
const setChecked = descriptor.set;
|
|
352
|
+
if (prevChecked !== checked && setChecked) {
|
|
353
|
+
const event = new Event("click", { bubbles });
|
|
354
|
+
setChecked.call(input, checked);
|
|
355
|
+
input.dispatchEvent(event);
|
|
356
|
+
}
|
|
357
|
+
}, [prevChecked, checked, bubbles]);
|
|
358
|
+
return (0, import_jsx_runtime2.jsx)(
|
|
359
|
+
Primitive.input,
|
|
360
|
+
{
|
|
361
|
+
type: "radio",
|
|
362
|
+
"aria-hidden": true,
|
|
363
|
+
defaultChecked: checked,
|
|
364
|
+
...props,
|
|
365
|
+
tabIndex: -1,
|
|
366
|
+
ref: composedRefs,
|
|
367
|
+
style: {
|
|
368
|
+
...props.style,
|
|
369
|
+
...controlSize,
|
|
370
|
+
position: "absolute",
|
|
371
|
+
pointerEvents: "none",
|
|
372
|
+
opacity: 0,
|
|
373
|
+
margin: 0
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
);
|
|
379
|
+
RadioBubbleInput.displayName = BUBBLE_INPUT_NAME;
|
|
380
|
+
function getState(checked) {
|
|
381
|
+
return checked ? "checked" : "unchecked";
|
|
382
|
+
}
|
|
383
|
+
var ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"];
|
|
384
|
+
var RADIO_GROUP_NAME = "RadioGroup";
|
|
385
|
+
var [createRadioGroupContext, createRadioGroupScope] = createContextScope(RADIO_GROUP_NAME, [
|
|
386
|
+
createRovingFocusGroupScope,
|
|
387
|
+
createRadioScope
|
|
388
|
+
]);
|
|
389
|
+
var useRovingFocusGroupScope = createRovingFocusGroupScope();
|
|
390
|
+
var useRadioScope = createRadioScope();
|
|
391
|
+
var [RadioGroupProvider, useRadioGroupContext] = createRadioGroupContext(RADIO_GROUP_NAME);
|
|
392
|
+
var RadioGroup = React2.forwardRef(
|
|
393
|
+
(props, forwardedRef) => {
|
|
394
|
+
const {
|
|
395
|
+
__scopeRadioGroup,
|
|
396
|
+
name,
|
|
397
|
+
defaultValue,
|
|
398
|
+
value: valueProp,
|
|
399
|
+
required = false,
|
|
400
|
+
disabled = false,
|
|
401
|
+
orientation,
|
|
402
|
+
dir,
|
|
403
|
+
loop = true,
|
|
404
|
+
onValueChange,
|
|
405
|
+
...groupProps
|
|
406
|
+
} = props;
|
|
407
|
+
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);
|
|
408
|
+
const direction = useDirection(dir);
|
|
409
|
+
const [value, setValue] = useControllableState({
|
|
410
|
+
prop: valueProp,
|
|
411
|
+
defaultProp: defaultValue ?? null,
|
|
412
|
+
onChange: onValueChange,
|
|
413
|
+
caller: RADIO_GROUP_NAME
|
|
414
|
+
});
|
|
415
|
+
return (0, import_jsx_runtime3.jsx)(
|
|
416
|
+
RadioGroupProvider,
|
|
417
|
+
{
|
|
418
|
+
scope: __scopeRadioGroup,
|
|
419
|
+
name,
|
|
420
|
+
required,
|
|
421
|
+
disabled,
|
|
422
|
+
value,
|
|
423
|
+
onValueChange: setValue,
|
|
424
|
+
children: (0, import_jsx_runtime3.jsx)(
|
|
425
|
+
Root,
|
|
426
|
+
{
|
|
427
|
+
asChild: true,
|
|
428
|
+
...rovingFocusGroupScope,
|
|
429
|
+
orientation,
|
|
430
|
+
dir: direction,
|
|
431
|
+
loop,
|
|
432
|
+
children: (0, import_jsx_runtime3.jsx)(
|
|
433
|
+
Primitive.div,
|
|
434
|
+
{
|
|
435
|
+
role: "radiogroup",
|
|
436
|
+
"aria-required": required,
|
|
437
|
+
"aria-orientation": orientation,
|
|
438
|
+
"data-disabled": disabled ? "" : void 0,
|
|
439
|
+
dir: direction,
|
|
440
|
+
...groupProps,
|
|
441
|
+
ref: forwardedRef
|
|
442
|
+
}
|
|
443
|
+
)
|
|
444
|
+
}
|
|
445
|
+
)
|
|
446
|
+
}
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
);
|
|
450
|
+
RadioGroup.displayName = RADIO_GROUP_NAME;
|
|
451
|
+
var ITEM_NAME2 = "RadioGroupItem";
|
|
452
|
+
var RadioGroupItem = React2.forwardRef(
|
|
453
|
+
(props, forwardedRef) => {
|
|
454
|
+
const { __scopeRadioGroup, disabled, ...itemProps } = props;
|
|
455
|
+
const context = useRadioGroupContext(ITEM_NAME2, __scopeRadioGroup);
|
|
456
|
+
const isDisabled = context.disabled || disabled;
|
|
457
|
+
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);
|
|
458
|
+
const radioScope = useRadioScope(__scopeRadioGroup);
|
|
459
|
+
const ref = React2.useRef(null);
|
|
460
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
461
|
+
const checked = context.value === itemProps.value;
|
|
462
|
+
const isArrowKeyPressedRef = React2.useRef(false);
|
|
463
|
+
React2.useEffect(() => {
|
|
464
|
+
const handleKeyDown = (event) => {
|
|
465
|
+
if (ARROW_KEYS.includes(event.key)) {
|
|
466
|
+
isArrowKeyPressedRef.current = true;
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
const handleKeyUp = () => isArrowKeyPressedRef.current = false;
|
|
470
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
471
|
+
document.addEventListener("keyup", handleKeyUp);
|
|
472
|
+
return () => {
|
|
473
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
474
|
+
document.removeEventListener("keyup", handleKeyUp);
|
|
475
|
+
};
|
|
476
|
+
}, []);
|
|
477
|
+
return (0, import_jsx_runtime3.jsx)(
|
|
478
|
+
Item,
|
|
479
|
+
{
|
|
480
|
+
asChild: true,
|
|
481
|
+
...rovingFocusGroupScope,
|
|
482
|
+
focusable: !isDisabled,
|
|
483
|
+
active: checked,
|
|
484
|
+
children: (0, import_jsx_runtime3.jsx)(
|
|
485
|
+
Radio,
|
|
486
|
+
{
|
|
487
|
+
disabled: isDisabled,
|
|
488
|
+
required: context.required,
|
|
489
|
+
checked,
|
|
490
|
+
...radioScope,
|
|
491
|
+
...itemProps,
|
|
492
|
+
name: context.name,
|
|
493
|
+
ref: composedRefs,
|
|
494
|
+
onCheck: () => context.onValueChange(itemProps.value),
|
|
495
|
+
onKeyDown: composeEventHandlers((event) => {
|
|
496
|
+
if (event.key === "Enter") event.preventDefault();
|
|
497
|
+
}),
|
|
498
|
+
onFocus: composeEventHandlers(itemProps.onFocus, () => {
|
|
499
|
+
var _a;
|
|
500
|
+
if (isArrowKeyPressedRef.current) (_a = ref.current) == null ? void 0 : _a.click();
|
|
501
|
+
})
|
|
502
|
+
}
|
|
503
|
+
)
|
|
504
|
+
}
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
);
|
|
508
|
+
RadioGroupItem.displayName = ITEM_NAME2;
|
|
509
|
+
var INDICATOR_NAME2 = "RadioGroupIndicator";
|
|
510
|
+
var RadioGroupIndicator = React2.forwardRef(
|
|
511
|
+
(props, forwardedRef) => {
|
|
512
|
+
const { __scopeRadioGroup, ...indicatorProps } = props;
|
|
513
|
+
const radioScope = useRadioScope(__scopeRadioGroup);
|
|
514
|
+
return (0, import_jsx_runtime3.jsx)(RadioIndicator, { ...radioScope, ...indicatorProps, ref: forwardedRef });
|
|
515
|
+
}
|
|
516
|
+
);
|
|
517
|
+
RadioGroupIndicator.displayName = INDICATOR_NAME2;
|
|
518
|
+
var Root2 = RadioGroup;
|
|
519
|
+
var Item2 = RadioGroupItem;
|
|
520
|
+
var Indicator = RadioGroupIndicator;
|
|
521
|
+
export {
|
|
522
|
+
Indicator,
|
|
523
|
+
Item2 as Item,
|
|
524
|
+
RadioGroup,
|
|
525
|
+
RadioGroupIndicator,
|
|
526
|
+
RadioGroupItem,
|
|
527
|
+
Root2 as Root,
|
|
528
|
+
createRadioGroupScope
|
|
529
|
+
};
|
|
530
|
+
//# sourceMappingURL=@radix-ui_react-radio-group.js.map
|