@cognitap/radiant 0.0.7 → 0.0.9
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/CHANGELOG.md +9 -1
- package/README.md +2 -2
- package/dist/library/Dialog.js +1 -1
- package/dist/library/Dialog.js.map +1 -1
- package/dist/library/Select.d.ts +87 -0
- package/dist/library/Select.d.ts.map +1 -0
- package/dist/library/Select.js +454 -0
- package/dist/library/Select.js.map +1 -0
- package/dist/library/Textarea.d.ts +15 -0
- package/dist/library/Textarea.d.ts.map +1 -0
- package/dist/library/Textarea.js +54 -0
- package/dist/library/Textarea.js.map +1 -0
- package/dist/library/cn.d.ts.map +1 -1
- package/dist/library/cn.js +45 -3
- package/dist/library/cn.js.map +1 -1
- package/dist/library/examples/glass.d.ts.map +1 -1
- package/dist/library/examples/glass.js +5 -0
- package/dist/library/examples/glass.js.map +1 -1
- package/dist/library/index.d.ts +4 -0
- package/dist/library/index.d.ts.map +1 -1
- package/dist/library/index.js +2 -0
- package/dist/library/index.js.map +1 -1
- package/dist/library/internal/select.d.ts +37 -0
- package/dist/library/internal/select.d.ts.map +1 -0
- package/dist/library/internal/select.js +42 -0
- package/dist/library/internal/select.js.map +1 -0
- package/dist/library/motion/host.d.ts +2 -1
- package/dist/library/motion/host.d.ts.map +1 -1
- package/dist/library/motion/host.js.map +1 -1
- package/dist/library/motion/popup.d.ts +5 -0
- package/dist/library/motion/popup.d.ts.map +1 -0
- package/dist/library/motion/popup.js +60 -0
- package/dist/library/motion/popup.js.map +1 -0
- package/dist/library/motion/react.d.ts.map +1 -1
- package/dist/library/motion/react.js +3 -1
- package/dist/library/motion/react.js.map +1 -1
- package/dist/library/react/useControllableState.d.ts +1 -0
- package/dist/library/react/useControllableState.d.ts.map +1 -1
- package/dist/library/react/useControllableState.js +8 -1
- package/dist/library/react/useControllableState.js.map +1 -1
- package/dist/library/selectStyles.d.ts +4 -0
- package/dist/library/selectStyles.d.ts.map +1 -0
- package/dist/library/selectStyles.js +32 -0
- package/dist/library/selectStyles.js.map +1 -0
- package/dist/library/styles.css +1 -1
- package/dist/library/themes/components.d.ts +47 -0
- package/dist/library/themes/components.d.ts.map +1 -1
- package/dist/library/themes/components.js +47 -0
- package/dist/library/themes/components.js.map +1 -1
- package/docs/architecture.md +17 -5
- package/docs/motion.md +4 -4
- package/docs/theming.md +2 -2
- package/package.json +6 -8
- package/src/Dialog.tsx +1 -1
- package/src/Select.tsx +781 -0
- package/src/Textarea.tsx +92 -0
- package/src/cn.ts +45 -3
- package/src/examples/glass.ts +5 -0
- package/src/index.ts +29 -0
- package/src/internal/select.ts +80 -0
- package/src/motion/host.ts +2 -1
- package/src/motion/popup.ts +55 -0
- package/src/motion/react.ts +3 -1
- package/src/react/useControllableState.ts +7 -1
- package/src/selectStyles.ts +34 -0
- package/src/themes/components.ts +47 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../../src/motion/react.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AACZ,OAAO,EACL,UAAU,EACV,SAAS,EACT,eAAe,EACf,MAAM,EACN,QAAQ,EACR,oBAAoB,EAErB,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,aAAa,EAA0B,MAAM,aAAa,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAqD,MAAM,WAAW,CAAA;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAyB,MAAM,cAAc,CAAA;AAClE,OAAO,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QACD,IAAI,CAAC,GAAG,CAAC,OAAO;YAAE,OAAM;QACxB,IAAI,CAAC,OAAO,CAAC,OAAO;YAClB,OAAO,CAAC,OAAO,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,gBAAgB,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAA;aACzF,CAAC;YACJ,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;YAC9C,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,CAAA;QACtC,CAAC;IACH,CAAC,CAAC,CAAA;IACF,eAAe,CACb,GAAG,EAAE,CAAC,GAAG,EAAE;QACT,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,CAAA;QACrC,OAAO,CAAC,OAAO,GAAG,IAAI,CAAA;IACxB,CAAC,EACD,EAAE,CACH,CAAA;IACD,OAAO,UAAU,CAAA;AACnB,CAAC","sourcesContent":["'use client'\nimport {\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n useSyncExternalStore,\n type RefObject\n} from 'react'\nimport { createElement, type ReactNode } from 'react'\nimport { MotionHostContext } from './host.js'\nimport { bindDisclosureMotion, bindDialogMotion } from './transitions.js'\nimport { bindPressMotion } from './press.js'\nimport { MotionProfileContext } from './context.js'\nimport { resolveMotion, type MotionInteraction } from './config.js'\nimport { createSpringDrag, type SpringDragController, type SpringDragOptions } from './drag.js'\nimport { bindSpringDrag } from './dragBrowser.js'\nimport { createSpring, type SpringController } from './runtime.js'\nimport { bindSpringStyle, type SpringStyleProperty } from './browser.js'\nimport { bindSpringSource, type SpringSource } from './follow.js'\nimport { bindSpringLayout, type SpringLayoutController } from './layoutDom.js'\n\n// Start conservatively for SSR/hydration; only subscribing reads the browser.\nconst listeners = new Set<() => void>()\nlet query: MediaQueryList | undefined\nfunction subscribeReduced(listener: () => void) {\n if (!query) query = window.matchMedia('(prefers-reduced-motion: reduce)')\n const current = query\n const notify = () => listener()\n listeners.add(notify)\n current.addEventListener('change', notify)\n return () => {\n listeners.delete(notify)\n current.removeEventListener('change', notify)\n if (!listeners.size) query = undefined\n }\n}\nexport function useReducedMotion(): boolean {\n return useSyncExternalStore(\n subscribeReduced,\n () => query?.matches ?? true,\n () => true\n )\n}\nexport function useSpring(\n initial: number,\n interaction: MotionInteraction = 'follow',\n reducedValue?: number\n): SpringController {\n const profile = useContext(MotionProfileContext)\n const reduced = useReducedMotion()\n const resolved = resolveMotion(profile, interaction, reduced)\n const owned = useRef<SpringController | null>(null)\n const requested = useRef(initial)\n const requestedVelocity = useRef<number | undefined>(undefined)\n const callbacks = useRef(new Set<(value: number) => void>())\n const initialOptions = useRef({ ...resolved, reducedValue })\n const policy = useRef(resolved.enabled)\n const initialValue = useRef(initial)\n const [controller] = useState<SpringController>(() => ({\n get: () => owned.current?.get() ?? requested.current,\n getVelocity: () => owned.current?.getVelocity() ?? 0,\n isAnimating: () => owned.current?.isAnimating() ?? false,\n to(next, velocity) {\n if (velocity !== undefined && !Number.isFinite(velocity))\n throw new TypeError('Velocity must be finite.')\n requestedVelocity.current = velocity\n if (!Number.isFinite(next)) throw new TypeError('Spring value must be finite.')\n requested.current = next\n owned.current?.to(next, velocity)\n },\n jump(next) {\n if (!Number.isFinite(next)) throw new TypeError('Spring value must be finite.')\n requested.current = next\n owned.current?.jump(next)\n },\n stop() {\n owned.current?.stop()\n requested.current = owned.current?.get() ?? requested.current\n },\n configure(next) {\n owned.current?.configure({ ...next, enabled: policy.current && (next.enabled ?? true) })\n },\n subscribe(listener) {\n callbacks.current.add(listener)\n return () => {\n callbacks.current.delete(listener)\n }\n },\n destroy() {\n owned.current?.destroy()\n }\n }))\n useEffect(() => {\n const spring = createSpring(initialValue.current, initialOptions.current)\n owned.current = spring\n const off = spring.subscribe(next => callbacks.current.forEach(listener => listener(next)))\n spring.to(requested.current, requestedVelocity.current)\n return () => {\n off()\n spring.destroy()\n owned.current = null\n }\n }, [])\n const { stiffness, damping, mass } = resolved.parameters\n useEffect(() => {\n policy.current = resolved.enabled\n owned.current?.configure({\n enabled: resolved.enabled,\n parameters: { stiffness, damping, mass },\n reducedValue\n })\n }, [resolved.enabled, stiffness, damping, mass, reducedValue])\n return controller\n}\n/** Use the real native ref; events/state remain with the component and caller. */\nexport function useSpringStyle(\n ref: RefObject<HTMLElement | null>,\n property: SpringStyleProperty,\n initial: number,\n interaction: MotionInteraction = 'follow',\n reducedValue?: number\n): SpringController {\n const spring = useSpring(initial, interaction, reducedValue)\n // Rebind after every commit to handle a replaced render host; no animation state enters React.\n useEffect(() => {\n if (!ref.current) return\n return bindSpringStyle(ref.current, spring, property)\n })\n return spring\n}\n\nconst hostRuntime = {\n press: bindPressMotion,\n disclosure: bindDisclosureMotion,\n dialog: bindDialogMotion\n}\n/** Opt into native Radiant spring interactions without adding a DOM wrapper. */\nexport function MotionProvider({ children }: { children?: ReactNode }) {\n return createElement(MotionHostContext.Provider, { value: hostRuntime }, children)\n}\nexport { MotionLink } from './MotionLink.js'\nexport type { MotionLinkProps } from './MotionLink.js'\n\n/** Dedicated one-axis handle binding; explicit native keyboard controls are retained. */\nexport function useSpringDrag(\n ref: RefObject<HTMLElement | null>,\n initial: number,\n options: Omit<SpringDragOptions, 'parameters' | 'enabled'> & { axis?: 'x' | 'y' }\n) {\n const profile = useContext(MotionProfileContext)\n const reduced = useReducedMotion()\n const resolved = resolveMotion(profile, 'drag', reduced)\n const latest = useRef({ initial, options, resolved })\n const owned = useRef<SpringDragController | null>(null)\n const [control] = useState(() => ({\n get: () => owned.current?.get() ?? initial,\n getVelocity: () => owned.current?.getVelocity() ?? 0,\n subscribe: (listener: (value: number) => void) =>\n owned.current?.subscribe(listener) ?? (() => {}),\n to: (target: number) => owned.current?.to(target),\n cancel: () => owned.current?.cancel(),\n step: (direction: -1 | 1 | 'first' | 'last') => owned.current?.step(direction),\n isAnimating: () => owned.current?.isAnimating() ?? false\n }))\n useEffect(() => {\n const current = latest.current\n const drag = createSpringDrag(current.initial, { ...current.options, ...current.resolved })\n owned.current = drag\n return () => {\n drag.destroy()\n owned.current = null\n }\n }, [])\n const points = options.snapPoints?.join(',')\n const { stiffness, damping, mass } = resolved.parameters\n useEffect(() => {\n owned.current?.configure({\n min: options.min,\n max: options.max,\n snapPoints: points?.split(',').map(Number),\n parameters: { stiffness, damping, mass },\n enabled: resolved.enabled\n })\n }, [options.min, options.max, points, stiffness, damping, mass, resolved.enabled])\n const binding = useRef<{\n node: HTMLElement\n axis: 'x' | 'y' | undefined\n cleanup: () => void\n } | null>(null)\n useEffect(() => {\n if (\n binding.current &&\n (binding.current.node !== ref.current || binding.current.axis !== options.axis)\n ) {\n binding.current.cleanup()\n binding.current = null\n }\n if (!binding.current && ref.current && owned.current)\n binding.current = {\n node: ref.current,\n axis: options.axis,\n cleanup: bindSpringDrag(ref.current, owned.current, options.axis)\n }\n })\n useEffect(\n () => () => {\n binding.current?.cleanup()\n binding.current = null\n },\n []\n )\n return control\n}\n\n/** Follow committed numeric props or an external source without rendering each spring frame. */\nexport function useSpringFollow(\n target: number | SpringSource,\n interaction: MotionInteraction = 'follow',\n reducedValue?: number\n): SpringController {\n const spring = useSpring(\n typeof target === 'number' ? target : target.get(),\n interaction,\n reducedValue\n )\n useEffect(() => {\n if (typeof target === 'number') spring.to(target)\n else return bindSpringSource(spring, target)\n }, [spring, target])\n return spring\n}\n\n/** Batch direct-child layout slots after each commit and observe later intrinsic changes. */\nexport function useSpringLayout(\n ref: RefObject<HTMLElement | null>\n): Pick<SpringLayoutController, 'measure' | 'get' | 'getVelocity' | 'isAnimating'> {\n const profile = useContext(MotionProfileContext)\n const reduced = useReducedMotion()\n const resolved = resolveMotion(profile, 'layout', reduced)\n const binding = useRef<{ node: HTMLElement; controller: SpringLayoutController } | null>(null)\n const [controller] = useState<\n Pick<SpringLayoutController, 'measure' | 'get' | 'getVelocity' | 'isAnimating'>\n >(() => ({\n measure: () => binding.current?.controller.measure(),\n get: slot => binding.current?.controller.get(slot),\n getVelocity: slot => binding.current?.controller.getVelocity(slot),\n isAnimating: () => binding.current?.controller.isAnimating() ?? false\n }))\n useLayoutEffect(() => {\n if (binding.current?.node !== ref.current) {\n binding.current?.controller.destroy()\n binding.current = null\n }\n if (!ref.current) return\n if (!binding.current)\n binding.current = { node: ref.current, controller: bindSpringLayout(ref.current, resolved) }\n else {\n binding.current.controller.configure(resolved)\n binding.current.controller.measure()\n }\n })\n useLayoutEffect(\n () => () => {\n binding.current?.controller.destroy()\n binding.current = null\n },\n []\n )\n return controller\n}\n"]}
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../../src/motion/react.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AACZ,OAAO,EACL,UAAU,EACV,SAAS,EACT,eAAe,EACf,MAAM,EACN,QAAQ,EACR,oBAAoB,EAErB,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,aAAa,EAA0B,MAAM,aAAa,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAqD,MAAM,WAAW,CAAA;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAyB,MAAM,cAAc,CAAA;AAClE,OAAO,EAAE,eAAe,EAA4B,MAAM,cAAc,CAAA;AACxE,OAAO,EAAE,gBAAgB,EAAqB,MAAM,aAAa,CAAA;AACjE,OAAO,EAAE,gBAAgB,EAA+B,MAAM,gBAAg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G,EAAE,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,gBAAgB,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAA;aACzF,CAAC;YACJ,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;YAC9C,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,CAAA;QACtC,CAAC;IACH,CAAC,CAAC,CAAA;IACF,eAAe,CACb,GAAG,EAAE,CAAC,GAAG,EAAE;QACT,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,CAAA;QACrC,OAAO,CAAC,OAAO,GAAG,IAAI,CAAA;IACxB,CAAC,EACD,EAAE,CACH,CAAA;IACD,OAAO,UAAU,CAAA;AACnB,CAAC","sourcesContent":["'use client'\nimport {\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n useSyncExternalStore,\n type RefObject\n} from 'react'\nimport { createElement, type ReactNode } from 'react'\nimport { MotionHostContext } from './host.js'\nimport { bindDisclosureMotion, bindDialogMotion } from './transitions.js'\nimport { bindPressMotion } from './press.js'\nimport { bindPopupMotion } from './popup.js'\nimport { MotionProfileContext } from './context.js'\nimport { resolveMotion, type MotionInteraction } from './config.js'\nimport { createSpringDrag, type SpringDragController, type SpringDragOptions } from './drag.js'\nimport { bindSpringDrag } from './dragBrowser.js'\nimport { createSpring, type SpringController } from './runtime.js'\nimport { bindSpringStyle, type SpringStyleProperty } from './browser.js'\nimport { bindSpringSource, type SpringSource } from './follow.js'\nimport { bindSpringLayout, type SpringLayoutController } from './layoutDom.js'\n\n// Start conservatively for SSR/hydration; only subscribing reads the browser.\nconst listeners = new Set<() => void>()\nlet query: MediaQueryList | undefined\nfunction subscribeReduced(listener: () => void) {\n if (!query) query = window.matchMedia('(prefers-reduced-motion: reduce)')\n const current = query\n const notify = () => listener()\n listeners.add(notify)\n current.addEventListener('change', notify)\n return () => {\n listeners.delete(notify)\n current.removeEventListener('change', notify)\n if (!listeners.size) query = undefined\n }\n}\nexport function useReducedMotion(): boolean {\n return useSyncExternalStore(\n subscribeReduced,\n () => query?.matches ?? true,\n () => true\n )\n}\nexport function useSpring(\n initial: number,\n interaction: MotionInteraction = 'follow',\n reducedValue?: number\n): SpringController {\n const profile = useContext(MotionProfileContext)\n const reduced = useReducedMotion()\n const resolved = resolveMotion(profile, interaction, reduced)\n const owned = useRef<SpringController | null>(null)\n const requested = useRef(initial)\n const requestedVelocity = useRef<number | undefined>(undefined)\n const callbacks = useRef(new Set<(value: number) => void>())\n const initialOptions = useRef({ ...resolved, reducedValue })\n const policy = useRef(resolved.enabled)\n const initialValue = useRef(initial)\n const [controller] = useState<SpringController>(() => ({\n get: () => owned.current?.get() ?? requested.current,\n getVelocity: () => owned.current?.getVelocity() ?? 0,\n isAnimating: () => owned.current?.isAnimating() ?? false,\n to(next, velocity) {\n if (velocity !== undefined && !Number.isFinite(velocity))\n throw new TypeError('Velocity must be finite.')\n requestedVelocity.current = velocity\n if (!Number.isFinite(next)) throw new TypeError('Spring value must be finite.')\n requested.current = next\n owned.current?.to(next, velocity)\n },\n jump(next) {\n if (!Number.isFinite(next)) throw new TypeError('Spring value must be finite.')\n requested.current = next\n owned.current?.jump(next)\n },\n stop() {\n owned.current?.stop()\n requested.current = owned.current?.get() ?? requested.current\n },\n configure(next) {\n owned.current?.configure({ ...next, enabled: policy.current && (next.enabled ?? true) })\n },\n subscribe(listener) {\n callbacks.current.add(listener)\n return () => {\n callbacks.current.delete(listener)\n }\n },\n destroy() {\n owned.current?.destroy()\n }\n }))\n useEffect(() => {\n const spring = createSpring(initialValue.current, initialOptions.current)\n owned.current = spring\n const off = spring.subscribe(next => callbacks.current.forEach(listener => listener(next)))\n spring.to(requested.current, requestedVelocity.current)\n return () => {\n off()\n spring.destroy()\n owned.current = null\n }\n }, [])\n const { stiffness, damping, mass } = resolved.parameters\n useEffect(() => {\n policy.current = resolved.enabled\n owned.current?.configure({\n enabled: resolved.enabled,\n parameters: { stiffness, damping, mass },\n reducedValue\n })\n }, [resolved.enabled, stiffness, damping, mass, reducedValue])\n return controller\n}\n/** Use the real native ref; events/state remain with the component and caller. */\nexport function useSpringStyle(\n ref: RefObject<HTMLElement | null>,\n property: SpringStyleProperty,\n initial: number,\n interaction: MotionInteraction = 'follow',\n reducedValue?: number\n): SpringController {\n const spring = useSpring(initial, interaction, reducedValue)\n // Rebind after every commit to handle a replaced render host; no animation state enters React.\n useEffect(() => {\n if (!ref.current) return\n return bindSpringStyle(ref.current, spring, property)\n })\n return spring\n}\n\nconst hostRuntime = {\n press: bindPressMotion,\n disclosure: bindDisclosureMotion,\n dialog: bindDialogMotion,\n popup: bindPopupMotion\n}\n/** Opt into native Radiant spring interactions without adding a DOM wrapper. */\nexport function MotionProvider({ children }: { children?: ReactNode }) {\n return createElement(MotionHostContext.Provider, { value: hostRuntime }, children)\n}\nexport { MotionLink } from './MotionLink.js'\nexport type { MotionLinkProps } from './MotionLink.js'\n\n/** Dedicated one-axis handle binding; explicit native keyboard controls are retained. */\nexport function useSpringDrag(\n ref: RefObject<HTMLElement | null>,\n initial: number,\n options: Omit<SpringDragOptions, 'parameters' | 'enabled'> & { axis?: 'x' | 'y' }\n) {\n const profile = useContext(MotionProfileContext)\n const reduced = useReducedMotion()\n const resolved = resolveMotion(profile, 'drag', reduced)\n const latest = useRef({ initial, options, resolved })\n const owned = useRef<SpringDragController | null>(null)\n const [control] = useState(() => ({\n get: () => owned.current?.get() ?? initial,\n getVelocity: () => owned.current?.getVelocity() ?? 0,\n subscribe: (listener: (value: number) => void) =>\n owned.current?.subscribe(listener) ?? (() => {}),\n to: (target: number) => owned.current?.to(target),\n cancel: () => owned.current?.cancel(),\n step: (direction: -1 | 1 | 'first' | 'last') => owned.current?.step(direction),\n isAnimating: () => owned.current?.isAnimating() ?? false\n }))\n useEffect(() => {\n const current = latest.current\n const drag = createSpringDrag(current.initial, { ...current.options, ...current.resolved })\n owned.current = drag\n return () => {\n drag.destroy()\n owned.current = null\n }\n }, [])\n const points = options.snapPoints?.join(',')\n const { stiffness, damping, mass } = resolved.parameters\n useEffect(() => {\n owned.current?.configure({\n min: options.min,\n max: options.max,\n snapPoints: points?.split(',').map(Number),\n parameters: { stiffness, damping, mass },\n enabled: resolved.enabled\n })\n }, [options.min, options.max, points, stiffness, damping, mass, resolved.enabled])\n const binding = useRef<{\n node: HTMLElement\n axis: 'x' | 'y' | undefined\n cleanup: () => void\n } | null>(null)\n useEffect(() => {\n if (\n binding.current &&\n (binding.current.node !== ref.current || binding.current.axis !== options.axis)\n ) {\n binding.current.cleanup()\n binding.current = null\n }\n if (!binding.current && ref.current && owned.current)\n binding.current = {\n node: ref.current,\n axis: options.axis,\n cleanup: bindSpringDrag(ref.current, owned.current, options.axis)\n }\n })\n useEffect(\n () => () => {\n binding.current?.cleanup()\n binding.current = null\n },\n []\n )\n return control\n}\n\n/** Follow committed numeric props or an external source without rendering each spring frame. */\nexport function useSpringFollow(\n target: number | SpringSource,\n interaction: MotionInteraction = 'follow',\n reducedValue?: number\n): SpringController {\n const spring = useSpring(\n typeof target === 'number' ? target : target.get(),\n interaction,\n reducedValue\n )\n useEffect(() => {\n if (typeof target === 'number') spring.to(target)\n else return bindSpringSource(spring, target)\n }, [spring, target])\n return spring\n}\n\n/** Batch direct-child layout slots after each commit and observe later intrinsic changes. */\nexport function useSpringLayout(\n ref: RefObject<HTMLElement | null>\n): Pick<SpringLayoutController, 'measure' | 'get' | 'getVelocity' | 'isAnimating'> {\n const profile = useContext(MotionProfileContext)\n const reduced = useReducedMotion()\n const resolved = resolveMotion(profile, 'layout', reduced)\n const binding = useRef<{ node: HTMLElement; controller: SpringLayoutController } | null>(null)\n const [controller] = useState<\n Pick<SpringLayoutController, 'measure' | 'get' | 'getVelocity' | 'isAnimating'>\n >(() => ({\n measure: () => binding.current?.controller.measure(),\n get: slot => binding.current?.controller.get(slot),\n getVelocity: slot => binding.current?.controller.getVelocity(slot),\n isAnimating: () => binding.current?.controller.isAnimating() ?? false\n }))\n useLayoutEffect(() => {\n if (binding.current?.node !== ref.current) {\n binding.current?.controller.destroy()\n binding.current = null\n }\n if (!ref.current) return\n if (!binding.current)\n binding.current = { node: ref.current, controller: bindSpringLayout(ref.current, resolved) }\n else {\n binding.current.controller.configure(resolved)\n binding.current.controller.measure()\n }\n })\n useLayoutEffect(\n () => () => {\n binding.current?.controller.destroy()\n binding.current = null\n },\n []\n )\n return controller\n}\n"]}
|
|
@@ -11,6 +11,7 @@ export declare function useControllableState<Value>({ name, value, defaultValue,
|
|
|
11
11
|
value: Value;
|
|
12
12
|
request: (update: Value | ((current: Value) => Value)) => void;
|
|
13
13
|
controlled: boolean;
|
|
14
|
+
reset: () => void;
|
|
14
15
|
};
|
|
15
16
|
export {};
|
|
16
17
|
//# sourceMappingURL=useControllableState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useControllableState.d.ts","sourceRoot":"","sources":["../../../src/react/useControllableState.ts"],"names":[],"mappings":"AAIA,KAAK,YAAY,CAAC,KAAK,IAAI;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,KAAK,GAAG,SAAS,CAAA;IACxB,YAAY,EAAE,KAAK,GAAG,SAAS,CAAA;IAC/B,YAAY,EAAE,KAAK,CAAA;IACnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IACjC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,KAAK,OAAO,CAAA;CAC/C,CAAA;AAED,kFAAkF;AAClF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,EAC1C,IAAI,EACJ,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,KAAiB,EAClB,EAAE,YAAY,CAAC,KAAK,CAAC;;
|
|
1
|
+
{"version":3,"file":"useControllableState.d.ts","sourceRoot":"","sources":["../../../src/react/useControllableState.ts"],"names":[],"mappings":"AAIA,KAAK,YAAY,CAAC,KAAK,IAAI;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,KAAK,GAAG,SAAS,CAAA;IACxB,YAAY,EAAE,KAAK,GAAG,SAAS,CAAA;IAC/B,YAAY,EAAE,KAAK,CAAA;IACnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IACjC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,KAAK,OAAO,CAAA;CAC/C,CAAA;AAED,kFAAkF;AAClF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,EAC1C,IAAI,EACJ,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,KAAiB,EAClB,EAAE,YAAY,CAAC,KAAK,CAAC;;sBAgBK,KAAK,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,KAAK,KAAK,CAAC;;;EAkB7D"}
|
|
@@ -11,6 +11,7 @@ export function useControllableState({ name, value, defaultValue, initialValue,
|
|
|
11
11
|
throw new TypeError(`${name} accepts a controlled value or a default, not both.`);
|
|
12
12
|
}
|
|
13
13
|
const current = value !== undefined ? value : uncontrolled;
|
|
14
|
+
const initial = useRef(uncontrolled);
|
|
14
15
|
const accepted = useRef(current);
|
|
15
16
|
const request = (update) => {
|
|
16
17
|
const previous = controlled ? current : accepted.current;
|
|
@@ -24,6 +25,12 @@ export function useControllableState({ name, value, defaultValue, initialValue,
|
|
|
24
25
|
}
|
|
25
26
|
onChange?.(next);
|
|
26
27
|
};
|
|
27
|
-
|
|
28
|
+
const reset = () => {
|
|
29
|
+
if (controlled)
|
|
30
|
+
return;
|
|
31
|
+
accepted.current = initial.current;
|
|
32
|
+
setUncontrolled(initial.current);
|
|
33
|
+
};
|
|
34
|
+
return { value: current, request, controlled, reset };
|
|
28
35
|
}
|
|
29
36
|
//# sourceMappingURL=useControllableState.js.map
|
|
@@ -1 +1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S,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAA;IAC1D,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA;IACpC,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;IAChC,MAAM,OAAO,GAAG,CAAC,MAA2C,EAAE,EAAE;QAC9D,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAA;QACxD,MAAM,IAAI,GACR,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAE,MAAoC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;QACzF,IAAI,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC;YAAE,OAAM;QACjC,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,wEAAwE;YACxE,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAA;YACvB,eAAe,CAAC,IAAI,CAAC,CAAA;QACvB,CAAC;QACD,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAA;IAClB,CAAC,CAAA;IACD,MAAM,KAAK,GAAG,GAAG,EAAE;QACjB,IAAI,UAAU;YAAE,OAAM;QACtB,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAClC,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAClC,CAAC,CAAA;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAA;AACvD,CAAC","sourcesContent":["'use client'\n\nimport { useRef, useState } from 'react'\n\ntype StateOptions<Value> = {\n name: string\n value: Value | undefined\n defaultValue: Value | undefined\n initialValue: Value\n onChange?: (value: Value) => void\n equal?: (left: Value, right: Value) => boolean\n}\n\n/** One owner per mount. Native observations are separate from change requests. */\nexport function useControllableState<Value>({\n name,\n value,\n defaultValue,\n initialValue,\n onChange,\n equal = Object.is\n}: StateOptions<Value>) {\n const [controlled] = useState(value !== undefined)\n const [uncontrolled, setUncontrolled] = useState(() =>\n defaultValue !== undefined ? defaultValue : initialValue\n )\n if (controlled !== (value !== undefined)) {\n throw new TypeError(\n `${name} cannot switch between controlled and uncontrolled state. Remount with a new key.`\n )\n }\n if (value !== undefined && defaultValue !== undefined) {\n throw new TypeError(`${name} accepts a controlled value or a default, not both.`)\n }\n const current = value !== undefined ? value : uncontrolled\n const initial = useRef(uncontrolled)\n const accepted = useRef(current)\n const request = (update: Value | ((current: Value) => Value)) => {\n const previous = controlled ? current : accepted.current\n const next =\n typeof update === 'function' ? (update as (current: Value) => Value)(previous) : update\n if (equal(previous, next)) return\n if (!controlled) {\n // Deduplicate accepted requests in the same event before React commits.\n accepted.current = next\n setUncontrolled(next)\n }\n onChange?.(next)\n }\n const reset = () => {\n if (controlled) return\n accepted.current = initial.current\n setUncontrolled(initial.current)\n }\n return { value: current, request, controlled, reset }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectStyles.d.ts","sourceRoot":"","sources":["../../src/selectStyles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,QAYpB,CAAA;AAEX,eAAO,MAAM,kBAAkB,QASpB,CAAA;AAEX,eAAO,MAAM,eAAe,QAMjB,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { controlBorderClass } from './controlStyles.js';
|
|
2
|
+
export const selectTriggerClass = [
|
|
3
|
+
controlBorderClass,
|
|
4
|
+
'box-border flex w-full min-w-0 items-center justify-between gap-2 text-start',
|
|
5
|
+
'[&>span:first-child]:w-full [&>span:first-child]:min-w-0 [&>span:first-child]:justify-between',
|
|
6
|
+
'h-[var(--rad-select-height,var(--_rad-control-height))] px-[var(--rad-select-padding,var(--_rad-control-padding))]',
|
|
7
|
+
'font-[family-name:var(--rad-select-font-family,var(--rad-typography-roles-ui-body-family,system-ui,sans-serif))] text-[length:var(--rad-select-font-size,var(--_rad-control-font-size))] font-[number:var(--rad-select-font-weight,var(--rad-typography-roles-ui-body-weight,400))] leading-[var(--rad-typography-roles-ui-body-line-height,1.5)] tracking-[var(--rad-typography-roles-ui-body-letter-spacing,-0.011em)]',
|
|
8
|
+
'[color:var(--rad-select-color,var(--rad-color-foreground,oklch(0.21_0.006_286)))] bg-[var(--rad-select-background,var(--rad-color-surface,white))]',
|
|
9
|
+
'[border-width:var(--rad-select-border-width,var(--rad-control-border-width,1px))] [border-style:var(--rad-select-border-style,var(--rad-control-border-style,solid))] [border-color:var(--rad-select-border-color,var(--_rad-control-border))]',
|
|
10
|
+
'rounded-[var(--rad-select-radius,var(--rad-control-radius,0.5rem))] [corner-shape:var(--rad-select-corner-shape,var(--rad-control-corner-shape,round))] [box-shadow:var(--rad-select-shadow,none)]',
|
|
11
|
+
'focus-visible:outline-solid focus-visible:[outline-color:var(--rad-select-focus-color,var(--rad-color-focus))] focus-visible:[outline-width:var(--rad-focus-width,2px)] focus-visible:[outline-offset:var(--rad-focus-offset,2px)]',
|
|
12
|
+
'data-invalid:[border-color:var(--rad-color-invalid)] disabled:cursor-not-allowed disabled:bg-[var(--rad-color-disabled-background)]',
|
|
13
|
+
'forced-colors:border-[CanvasText] forced-colors:bg-[Canvas] forced-colors:text-[CanvasText] forced-colors:disabled:text-[GrayText]'
|
|
14
|
+
].join(' ');
|
|
15
|
+
export const selectContentClass = [
|
|
16
|
+
'fixed right-auto bottom-auto m-0 box-border min-w-0 overflow-hidden overscroll-contain',
|
|
17
|
+
'left-[var(--_rad-select-left,0px)] top-[var(--_rad-select-top,0px)] w-[var(--_rad-select-width,auto)] max-h-[var(--_rad-select-max-height,calc(100dvh-1rem))]',
|
|
18
|
+
'p-[var(--rad-select-content-padding,0.25rem)] rounded-[var(--rad-select-content-radius,var(--rad-surface-radius,0.75rem))]',
|
|
19
|
+
'[border-width:var(--rad-select-border-width,var(--rad-surface-border-width,1px))] [border-style:var(--rad-select-border-style,var(--rad-surface-border-style,solid))] [border-color:var(--rad-select-border-color,var(--rad-color-border))]',
|
|
20
|
+
'bg-[var(--rad-select-content-background,var(--rad-color-surface,white))] [color:var(--rad-select-color,var(--rad-color-foreground))] [box-shadow:var(--rad-select-content-shadow,var(--rad-surface-overlay-shadow,0_8px_32px_#0003))]',
|
|
21
|
+
'[backdrop-filter:var(--rad-select-content-backdrop-filter,none)]',
|
|
22
|
+
'font-[family-name:var(--rad-select-font-family,var(--rad-typography-roles-ui-body-family,system-ui,sans-serif))] text-[length:var(--rad-select-font-size,var(--_rad-control-font-size))] leading-[var(--rad-typography-roles-ui-body-line-height,1.5)] font-[number:var(--rad-select-font-weight,var(--rad-typography-roles-ui-body-weight,400))]',
|
|
23
|
+
'outline-none forced-colors:border-[CanvasText] forced-colors:bg-[Canvas] forced-colors:text-[CanvasText]'
|
|
24
|
+
].join(' ');
|
|
25
|
+
export const selectItemClass = [
|
|
26
|
+
'relative flex min-w-0 cursor-default select-none items-center gap-2 break-words rounded-[var(--rad-select-item-radius,var(--rad-control-radius,0.5rem))]',
|
|
27
|
+
'min-h-[var(--_rad-control-height,2.5rem)] px-[var(--_rad-control-padding,1rem)] py-2 outline-none',
|
|
28
|
+
'focus:[background:var(--rad-select-item-background,var(--rad-color-accent))] focus:[color:var(--rad-select-item-color,var(--rad-color-accent-foreground))]',
|
|
29
|
+
'data-disabled:opacity-[var(--rad-state-disabled-opacity,0.5)] data-disabled:cursor-not-allowed',
|
|
30
|
+
'forced-colors:focus:bg-[Highlight] forced-colors:focus:text-[HighlightText] forced-colors:data-disabled:text-[GrayText] forced-colors:data-disabled:opacity-100'
|
|
31
|
+
].join(' ');
|
|
32
|
+
//# sourceMappingURL=selectStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectStyles.js","sourceRoot":"","sources":["../../src/selectStyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAEvD,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,kBAAkB;IAClB,8EAA8E;IAC9E,+FAA+F;IAC/F,oHAAoH;IACpH,0ZAA0Z;IAC1Z,oJAAoJ;IACpJ,gPAAgP;IAChP,oMAAoM;IACpM,oOAAoO;IACpO,qIAAqI;IACrI,oIAAoI;CACrI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAEX,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,wFAAwF;IACxF,+JAA+J;IAC/J,4HAA4H;IAC5H,6OAA6O;IAC7O,uOAAuO;IACvO,kEAAkE;IAClE,mVAAmV;IACnV,0GAA0G;CAC3G,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAEX,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,0JAA0J;IAC1J,mGAAmG;IACnG,4JAA4J;IAC5J,gGAAgG;IAChG,iKAAiK;CAClK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA","sourcesContent":["import { controlBorderClass } from './controlStyles.js'\n\nexport const selectTriggerClass = [\n controlBorderClass,\n 'box-border flex w-full min-w-0 items-center justify-between gap-2 text-start',\n '[&>span:first-child]:w-full [&>span:first-child]:min-w-0 [&>span:first-child]:justify-between',\n 'h-[var(--rad-select-height,var(--_rad-control-height))] px-[var(--rad-select-padding,var(--_rad-control-padding))]',\n 'font-[family-name:var(--rad-select-font-family,var(--rad-typography-roles-ui-body-family,system-ui,sans-serif))] text-[length:var(--rad-select-font-size,var(--_rad-control-font-size))] font-[number:var(--rad-select-font-weight,var(--rad-typography-roles-ui-body-weight,400))] leading-[var(--rad-typography-roles-ui-body-line-height,1.5)] tracking-[var(--rad-typography-roles-ui-body-letter-spacing,-0.011em)]',\n '[color:var(--rad-select-color,var(--rad-color-foreground,oklch(0.21_0.006_286)))] bg-[var(--rad-select-background,var(--rad-color-surface,white))]',\n '[border-width:var(--rad-select-border-width,var(--rad-control-border-width,1px))] [border-style:var(--rad-select-border-style,var(--rad-control-border-style,solid))] [border-color:var(--rad-select-border-color,var(--_rad-control-border))]',\n 'rounded-[var(--rad-select-radius,var(--rad-control-radius,0.5rem))] [corner-shape:var(--rad-select-corner-shape,var(--rad-control-corner-shape,round))] [box-shadow:var(--rad-select-shadow,none)]',\n 'focus-visible:outline-solid focus-visible:[outline-color:var(--rad-select-focus-color,var(--rad-color-focus))] focus-visible:[outline-width:var(--rad-focus-width,2px)] focus-visible:[outline-offset:var(--rad-focus-offset,2px)]',\n 'data-invalid:[border-color:var(--rad-color-invalid)] disabled:cursor-not-allowed disabled:bg-[var(--rad-color-disabled-background)]',\n 'forced-colors:border-[CanvasText] forced-colors:bg-[Canvas] forced-colors:text-[CanvasText] forced-colors:disabled:text-[GrayText]'\n].join(' ')\n\nexport const selectContentClass = [\n 'fixed right-auto bottom-auto m-0 box-border min-w-0 overflow-hidden overscroll-contain',\n 'left-[var(--_rad-select-left,0px)] top-[var(--_rad-select-top,0px)] w-[var(--_rad-select-width,auto)] max-h-[var(--_rad-select-max-height,calc(100dvh-1rem))]',\n 'p-[var(--rad-select-content-padding,0.25rem)] rounded-[var(--rad-select-content-radius,var(--rad-surface-radius,0.75rem))]',\n '[border-width:var(--rad-select-border-width,var(--rad-surface-border-width,1px))] [border-style:var(--rad-select-border-style,var(--rad-surface-border-style,solid))] [border-color:var(--rad-select-border-color,var(--rad-color-border))]',\n 'bg-[var(--rad-select-content-background,var(--rad-color-surface,white))] [color:var(--rad-select-color,var(--rad-color-foreground))] [box-shadow:var(--rad-select-content-shadow,var(--rad-surface-overlay-shadow,0_8px_32px_#0003))]',\n '[backdrop-filter:var(--rad-select-content-backdrop-filter,none)]',\n 'font-[family-name:var(--rad-select-font-family,var(--rad-typography-roles-ui-body-family,system-ui,sans-serif))] text-[length:var(--rad-select-font-size,var(--_rad-control-font-size))] leading-[var(--rad-typography-roles-ui-body-line-height,1.5)] font-[number:var(--rad-select-font-weight,var(--rad-typography-roles-ui-body-weight,400))]',\n 'outline-none forced-colors:border-[CanvasText] forced-colors:bg-[Canvas] forced-colors:text-[CanvasText]'\n].join(' ')\n\nexport const selectItemClass = [\n 'relative flex min-w-0 cursor-default select-none items-center gap-2 break-words rounded-[var(--rad-select-item-radius,var(--rad-control-radius,0.5rem))]',\n 'min-h-[var(--_rad-control-height,2.5rem)] px-[var(--_rad-control-padding,1rem)] py-2 outline-none',\n 'focus:[background:var(--rad-select-item-background,var(--rad-color-accent))] focus:[color:var(--rad-select-item-color,var(--rad-color-accent-foreground))]',\n 'data-disabled:opacity-[var(--rad-state-disabled-opacity,0.5)] data-disabled:cursor-not-allowed',\n 'forced-colors:focus:bg-[Highlight] forced-colors:focus:text-[HighlightText] forced-colors:data-disabled:text-[GrayText] forced-colors:data-disabled:opacity-100'\n].join(' ')\n"]}
|