@cognitap/radiant 0.0.5 → 0.0.7
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 +68 -368
- package/README.md +41 -1006
- package/RELEASE_POLICY.md +3 -3
- package/dist/library/Accordion.d.ts +3 -0
- package/dist/library/Accordion.d.ts.map +1 -1
- package/dist/library/Accordion.js +1 -1
- package/dist/library/Accordion.js.map +1 -1
- package/dist/library/Button.d.ts +8 -1
- package/dist/library/Button.d.ts.map +1 -1
- package/dist/library/Button.js +44 -2
- package/dist/library/Button.js.map +1 -1
- package/dist/library/Card.d.ts +2 -0
- package/dist/library/Card.d.ts.map +1 -1
- package/dist/library/Card.js +1 -1
- package/dist/library/Card.js.map +1 -1
- package/dist/library/Checkbox.d.ts +5 -0
- package/dist/library/Checkbox.d.ts.map +1 -1
- package/dist/library/Checkbox.js +3 -2
- package/dist/library/Checkbox.js.map +1 -1
- package/dist/library/Collapsible.d.ts +6 -1
- package/dist/library/Collapsible.d.ts.map +1 -1
- package/dist/library/Collapsible.js +24 -3
- package/dist/library/Collapsible.js.map +1 -1
- package/dist/library/Dialog.d.ts +5 -1
- package/dist/library/Dialog.d.ts.map +1 -1
- package/dist/library/Dialog.js +5 -2
- package/dist/library/Dialog.js.map +1 -1
- package/dist/library/Field.d.ts +8 -0
- package/dist/library/Field.d.ts.map +1 -1
- package/dist/library/Field.js +2 -0
- package/dist/library/Field.js.map +1 -1
- package/dist/library/Input.d.ts +3 -0
- package/dist/library/Input.d.ts.map +1 -1
- package/dist/library/Input.js +1 -0
- package/dist/library/Input.js.map +1 -1
- package/dist/library/Link.d.ts +5 -0
- package/dist/library/Link.d.ts.map +1 -1
- package/dist/library/Link.js.map +1 -1
- package/dist/library/RadioGroup.d.ts +8 -0
- package/dist/library/RadioGroup.d.ts.map +1 -1
- package/dist/library/RadioGroup.js +4 -2
- package/dist/library/RadioGroup.js.map +1 -1
- package/dist/library/ThemeScope.d.ts.map +1 -1
- package/dist/library/ThemeScope.js +10 -9
- package/dist/library/ThemeScope.js.map +1 -1
- package/dist/library/examples/expressive.d.ts +4 -0
- package/dist/library/examples/expressive.d.ts.map +1 -0
- package/dist/library/{themes → examples}/expressive.js +4 -3
- package/dist/library/examples/expressive.js.map +1 -0
- package/dist/library/examples/glass.d.ts +4 -0
- package/dist/library/examples/glass.d.ts.map +1 -0
- package/dist/library/{themes → examples}/glass.js +4 -3
- package/dist/library/examples/glass.js.map +1 -0
- package/dist/library/examples/index.d.ts +13 -0
- package/dist/library/examples/index.d.ts.map +1 -0
- package/dist/library/examples/index.js +32 -0
- package/dist/library/examples/index.js.map +1 -0
- package/dist/library/examples/jelly.d.ts +4 -0
- package/dist/library/examples/jelly.d.ts.map +1 -0
- package/dist/library/{themes → examples}/jelly.js +4 -3
- package/dist/library/examples/jelly.js.map +1 -0
- package/dist/library/examples/preset-values.d.ts.map +1 -0
- package/dist/library/examples/preset-values.js.map +1 -0
- package/dist/library/examples/radiant.d.ts +4 -0
- package/dist/library/examples/radiant.d.ts.map +1 -0
- package/dist/library/{themes → examples}/radiant.js +4 -3
- package/dist/library/examples/radiant.js.map +1 -0
- package/dist/library/examples/sharp-3d.d.ts +4 -0
- package/dist/library/examples/sharp-3d.d.ts.map +1 -0
- package/dist/library/{themes → examples}/sharp-3d.js +4 -3
- package/dist/library/examples/sharp-3d.js.map +1 -0
- package/dist/library/examples/soft-squircle.d.ts +4 -0
- package/dist/library/examples/soft-squircle.d.ts.map +1 -0
- package/dist/library/{themes → examples}/soft-squircle.js +4 -3
- package/dist/library/examples/soft-squircle.js.map +1 -0
- package/dist/library/examples/ticket.d.ts +4 -0
- package/dist/library/examples/ticket.d.ts.map +1 -0
- package/dist/library/{themes → examples}/ticket.js +4 -3
- package/dist/library/examples/ticket.js.map +1 -0
- package/dist/library/index.d.ts +4 -2
- package/dist/library/index.d.ts.map +1 -1
- package/dist/library/index.js +2 -1
- package/dist/library/index.js.map +1 -1
- package/dist/library/motion/MotionLink.d.ts +8 -0
- package/dist/library/motion/MotionLink.d.ts.map +1 -0
- package/dist/library/motion/MotionLink.js +44 -0
- package/dist/library/motion/MotionLink.js.map +1 -0
- package/dist/library/motion/browser.d.ts +5 -0
- package/dist/library/motion/browser.d.ts.map +1 -0
- package/dist/library/motion/browser.js +35 -0
- package/dist/library/motion/browser.js.map +1 -0
- package/dist/library/motion/config.d.ts +26 -0
- package/dist/library/motion/config.d.ts.map +1 -0
- package/dist/library/motion/config.js +58 -0
- package/dist/library/motion/config.js.map +1 -0
- package/dist/library/motion/context.d.ts +2 -0
- package/dist/library/motion/context.d.ts.map +1 -0
- package/dist/library/motion/context.js +5 -0
- package/dist/library/motion/context.js.map +1 -0
- package/dist/library/motion/drag.d.ts +20 -0
- package/dist/library/motion/drag.d.ts.map +1 -0
- package/dist/library/motion/drag.js +138 -0
- package/dist/library/motion/drag.js.map +1 -0
- package/dist/library/motion/dragBrowser.d.ts +4 -0
- package/dist/library/motion/dragBrowser.d.ts.map +1 -0
- package/dist/library/motion/dragBrowser.js +156 -0
- package/dist/library/motion/dragBrowser.js.map +1 -0
- package/dist/library/motion/follow.d.ts +9 -0
- package/dist/library/motion/follow.d.ts.map +1 -0
- package/dist/library/motion/follow.js +26 -0
- package/dist/library/motion/follow.js.map +1 -0
- package/dist/library/motion/host.d.ts +30 -0
- package/dist/library/motion/host.d.ts.map +1 -0
- package/dist/library/motion/host.js +70 -0
- package/dist/library/motion/host.js.map +1 -0
- package/dist/library/motion/index.d.ts +16 -0
- package/dist/library/motion/index.d.ts.map +1 -0
- package/dist/library/motion/index.js +9 -0
- package/dist/library/motion/index.js.map +1 -0
- package/dist/library/motion/layout.d.ts +20 -0
- package/dist/library/motion/layout.d.ts.map +1 -0
- package/dist/library/motion/layout.js +67 -0
- package/dist/library/motion/layout.js.map +1 -0
- package/dist/library/motion/layoutDom.d.ts +17 -0
- package/dist/library/motion/layoutDom.d.ts.map +1 -0
- package/dist/library/motion/layoutDom.js +272 -0
- package/dist/library/motion/layoutDom.js.map +1 -0
- package/dist/library/motion/press.d.ts +5 -0
- package/dist/library/motion/press.d.ts.map +1 -0
- package/dist/library/motion/press.js +99 -0
- package/dist/library/motion/press.js.map +1 -0
- package/dist/library/motion/pressPolicy.d.ts +5 -0
- package/dist/library/motion/pressPolicy.d.ts.map +1 -0
- package/dist/library/motion/pressPolicy.js +8 -0
- package/dist/library/motion/pressPolicy.js.map +1 -0
- package/dist/library/motion/react.d.ts +35 -0
- package/dist/library/motion/react.d.ts.map +1 -0
- package/dist/library/motion/react.js +224 -0
- package/dist/library/motion/react.js.map +1 -0
- package/dist/library/motion/runtime.d.ts +22 -0
- package/dist/library/motion/runtime.d.ts.map +1 -0
- package/dist/library/motion/runtime.js +117 -0
- package/dist/library/motion/runtime.js.map +1 -0
- package/dist/library/motion/transitions.d.ts +5 -0
- package/dist/library/motion/transitions.d.ts.map +1 -0
- package/dist/library/motion/transitions.js +244 -0
- package/dist/library/motion/transitions.js.map +1 -0
- package/dist/library/styles.css +1 -1
- package/dist/library/themes/defineTheme.d.ts +3 -0
- package/dist/library/themes/defineTheme.d.ts.map +1 -1
- package/dist/library/themes/defineTheme.js +4 -2
- package/dist/library/themes/defineTheme.js.map +1 -1
- package/dist/library/themes/index.d.ts +2 -12
- package/dist/library/themes/index.d.ts.map +1 -1
- package/dist/library/themes/index.js +1 -19
- package/dist/library/themes/index.js.map +1 -1
- package/dist/library/themes/themeDocument.d.ts.map +1 -1
- package/dist/library/themes/themeDocument.js +11 -5
- package/dist/library/themes/themeDocument.js.map +1 -1
- package/dist/library/themes/themeDocumentTypes.d.ts +5 -1
- package/dist/library/themes/themeDocumentTypes.d.ts.map +1 -1
- package/dist/library/themes/themeDocumentTypes.js.map +1 -1
- package/docs/accessibility.md +76 -142
- package/docs/architecture.md +197 -0
- package/docs/motion.md +153 -0
- package/docs/theming.md +275 -882
- package/package.json +22 -7
- package/src/Accordion.tsx +4 -1
- package/src/Button.tsx +55 -1
- package/src/Card.tsx +3 -1
- package/src/Checkbox.tsx +7 -2
- package/src/Collapsible.tsx +38 -2
- package/src/Dialog.tsx +13 -1
- package/src/Field.tsx +8 -0
- package/src/Input.tsx +3 -0
- package/src/Link.tsx +5 -0
- package/src/RadioGroup.tsx +10 -2
- package/src/ThemeScope.tsx +21 -17
- package/src/{themes → examples}/expressive.ts +5 -3
- package/src/{themes → examples}/glass.ts +5 -3
- package/src/examples/index.ts +35 -0
- package/src/{themes → examples}/jelly.ts +5 -3
- package/src/{themes → examples}/radiant.ts +5 -3
- package/src/{themes → examples}/sharp-3d.ts +5 -3
- package/src/{themes → examples}/soft-squircle.ts +5 -3
- package/src/{themes → examples}/ticket.ts +5 -3
- package/src/index.ts +10 -13
- package/src/motion/MotionLink.tsx +69 -0
- package/src/motion/browser.ts +45 -0
- package/src/motion/config.ts +79 -0
- package/src/motion/context.ts +4 -0
- package/src/motion/drag.ts +151 -0
- package/src/motion/dragBrowser.ts +159 -0
- package/src/motion/follow.ts +28 -0
- package/src/motion/host.ts +96 -0
- package/src/motion/index.ts +28 -0
- package/src/motion/layout.ts +78 -0
- package/src/motion/layoutDom.ts +293 -0
- package/src/motion/press.ts +97 -0
- package/src/motion/pressPolicy.ts +14 -0
- package/src/motion/react.ts +272 -0
- package/src/motion/runtime.ts +122 -0
- package/src/motion/transitions.ts +237 -0
- package/src/themes/defineTheme.ts +10 -2
- package/src/themes/index.ts +2 -22
- package/src/themes/themeDocument.ts +14 -6
- package/src/themes/themeDocumentTypes.ts +12 -5
- package/dist/library/themes/expressive.d.ts +0 -2
- package/dist/library/themes/expressive.d.ts.map +0 -1
- package/dist/library/themes/expressive.js.map +0 -1
- package/dist/library/themes/glass.d.ts +0 -2
- package/dist/library/themes/glass.d.ts.map +0 -1
- package/dist/library/themes/glass.js.map +0 -1
- package/dist/library/themes/jelly.d.ts +0 -2
- package/dist/library/themes/jelly.d.ts.map +0 -1
- package/dist/library/themes/jelly.js.map +0 -1
- package/dist/library/themes/preset-values.d.ts.map +0 -1
- package/dist/library/themes/preset-values.js.map +0 -1
- package/dist/library/themes/radiant.d.ts +0 -2
- package/dist/library/themes/radiant.d.ts.map +0 -1
- package/dist/library/themes/radiant.js.map +0 -1
- package/dist/library/themes/sharp-3d.d.ts +0 -2
- package/dist/library/themes/sharp-3d.d.ts.map +0 -1
- package/dist/library/themes/sharp-3d.js.map +0 -1
- package/dist/library/themes/soft-squircle.d.ts +0 -2
- package/dist/library/themes/soft-squircle.d.ts.map +0 -1
- package/dist/library/themes/soft-squircle.js.map +0 -1
- package/dist/library/themes/ticket.d.ts +0 -2
- package/dist/library/themes/ticket.d.ts.map +0 -1
- package/dist/library/themes/ticket.js.map +0 -1
- package/docs/system.md +0 -238
- /package/dist/library/{themes → examples}/preset-values.d.ts +0 -0
- /package/dist/library/{themes → examples}/preset-values.js +0 -0
- /package/src/{themes → examples}/preset-values.ts +0 -0
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cognitap/radiant",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "React interaction components and presentation primitives",
|
|
5
|
-
"homepage": "https://
|
|
5
|
+
"homepage": "https://radiant-docs.pages.dev",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/cognitap/radiant/issues"
|
|
8
8
|
},
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"LICENSE",
|
|
16
16
|
"CHANGELOG.md",
|
|
17
17
|
"RELEASE_POLICY.md",
|
|
18
|
-
"docs/
|
|
18
|
+
"docs/architecture.md",
|
|
19
|
+
"docs/motion.md",
|
|
19
20
|
"docs/accessibility.md",
|
|
20
21
|
"docs/theming.md",
|
|
21
22
|
"dist/library",
|
|
@@ -46,6 +47,18 @@
|
|
|
46
47
|
"./typography": {
|
|
47
48
|
"types": "./dist/library/typography/index.d.ts",
|
|
48
49
|
"default": "./dist/library/typography/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./examples": {
|
|
52
|
+
"types": "./dist/library/examples/index.d.ts",
|
|
53
|
+
"default": "./dist/library/examples/index.js"
|
|
54
|
+
},
|
|
55
|
+
"./motion": {
|
|
56
|
+
"types": "./dist/library/motion/index.d.ts",
|
|
57
|
+
"default": "./dist/library/motion/index.js"
|
|
58
|
+
},
|
|
59
|
+
"./motion/react": {
|
|
60
|
+
"types": "./dist/library/motion/react.d.ts",
|
|
61
|
+
"default": "./dist/library/motion/react.js"
|
|
49
62
|
}
|
|
50
63
|
},
|
|
51
64
|
"publishConfig": {
|
|
@@ -55,7 +68,8 @@
|
|
|
55
68
|
},
|
|
56
69
|
"dependencies": {
|
|
57
70
|
"class-variance-authority": "0.7.1",
|
|
58
|
-
"cn": "0.4.0"
|
|
71
|
+
"cn": "0.4.0",
|
|
72
|
+
"motion": "14.7.1"
|
|
59
73
|
},
|
|
60
74
|
"devDependencies": {
|
|
61
75
|
"@storybook/addon-a11y": "10.6.1",
|
|
@@ -109,14 +123,15 @@
|
|
|
109
123
|
"watch:js": "tsc -p tsconfig.build.json --watch --preserveWatchOutput",
|
|
110
124
|
"watch:styles": "pnpm theme:generate && tailwindcss -i styles/library.css -o dist/library/styles.css --watch=always",
|
|
111
125
|
"build:storybook": "pnpm theme:generate && storybook build --output-dir dist/storybook --disable-telemetry",
|
|
112
|
-
"test": "pnpm build && node --test tests/*.test.mjs && node scripts/verify-package.mjs",
|
|
113
|
-
"test:package": "pnpm build && node scripts/verify-package.mjs",
|
|
126
|
+
"test": "pnpm build && node --test tests/*.test.mjs && node scripts/verify-package.mjs --hydration",
|
|
127
|
+
"test:package": "pnpm build && node scripts/verify-package.mjs --hydration",
|
|
114
128
|
"typecheck": "tsc --noEmit && pnpm typecheck:contracts",
|
|
115
129
|
"typecheck:contracts": "tsc -p docs/contracts/tsconfig.json",
|
|
116
130
|
"lint": "oxlint --deny-warnings",
|
|
117
131
|
"format": "oxfmt",
|
|
118
132
|
"format:check": "oxfmt --check",
|
|
119
|
-
"check:source": "pnpm theme:check && pnpm format:check && pnpm lint && pnpm typecheck",
|
|
133
|
+
"check:source": "pnpm theme:check && pnpm format:check && pnpm lint && pnpm typecheck && pnpm docs:check",
|
|
134
|
+
"docs:check": "node scripts/check-docs.mjs",
|
|
120
135
|
"check:ci": "pnpm check:source && pnpm test && pnpm build:storybook && pnpm test:browser:smoke",
|
|
121
136
|
"check": "pnpm check:source && pnpm test --styles --compositions && pnpm build:storybook && pnpm test:browser",
|
|
122
137
|
"test:compositions": "pnpm build && node scripts/verify-package.mjs --compositions",
|
package/src/Accordion.tsx
CHANGED
|
@@ -16,7 +16,7 @@ import type {
|
|
|
16
16
|
} from './Collapsible.js'
|
|
17
17
|
|
|
18
18
|
const accordionClass =
|
|
19
|
-
'grid w-full gap-[var(--rad-accordion-gap,var(--rad-spacing-group-gap,0.75rem))]'
|
|
19
|
+
'grid w-full min-w-0 gap-[var(--rad-accordion-gap,var(--rad-spacing-group-gap,0.75rem))]'
|
|
20
20
|
const triggerClass =
|
|
21
21
|
'in-[[data-slot~=field][data-disabled]]:[--_rad-disabled-opacity:1] data-disabled:cursor-not-allowed data-disabled:opacity-[var(--_rad-disabled-opacity,var(--rad-state-disabled-opacity,0.5))] forced-colors:data-disabled:opacity-100'
|
|
22
22
|
const headingClass = 'm-0 min-w-0 break-words [font:inherit]'
|
|
@@ -56,6 +56,7 @@ type AccordionMultipleProps = AccordionBaseProps &
|
|
|
56
56
|
|
|
57
57
|
export type AccordionProps = AccordionSingleProps | AccordionMultipleProps
|
|
58
58
|
|
|
59
|
+
/** Stable, distinct value within this owner. Selection and native name belong to Accordion. */
|
|
59
60
|
export type AccordionItemProps = Omit<
|
|
60
61
|
CollapsibleProps,
|
|
61
62
|
'open' | 'defaultOpen' | 'onOpenChange' | 'name'
|
|
@@ -65,6 +66,7 @@ export type AccordionItemProps = Omit<
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
export type AccordionTriggerProps = CollapsibleTriggerProps & {
|
|
69
|
+
/** Heading inside the native summary; null leaves heading composition to the caller. */
|
|
68
70
|
level?: AccordionHeadingLevel | null
|
|
69
71
|
}
|
|
70
72
|
|
|
@@ -76,6 +78,7 @@ export type AccordionState = {
|
|
|
76
78
|
type: 'single' | 'multiple'
|
|
77
79
|
value: AccordionValue
|
|
78
80
|
disabled: boolean
|
|
81
|
+
/** Request selection; a controlled owner may decline. Root disabled guards requests. */
|
|
79
82
|
setItemOpen: (value: string, open: boolean) => void
|
|
80
83
|
}
|
|
81
84
|
|
package/src/Button.tsx
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import type { ComponentProps, ReactElement } from 'react'
|
|
4
4
|
import { Fragment, isValidElement } from 'react'
|
|
5
|
+
import { callerOwnsPress, springPressClass, offPressClass } from './motion/pressPolicy.js'
|
|
6
|
+
import { usePressHost } from './motion/host.js'
|
|
5
7
|
import { actionVariants } from './actionStyles.js'
|
|
6
8
|
import type { ButtonVariant, ControlSize, Tone } from './presentation.js'
|
|
7
9
|
import { cn } from './cn.js'
|
|
@@ -25,16 +27,25 @@ export type ButtonProps = Omit<ComponentProps<'button'>, 'style'> & {
|
|
|
25
27
|
'data-slot'?: string
|
|
26
28
|
/** Forward resolved presentation, children, native attributes and ref to one button host. */
|
|
27
29
|
render?: (props: ButtonRenderProps) => ReactElement
|
|
30
|
+
/** Visual treatment; native submission behavior stays on type. */
|
|
28
31
|
variant?: ButtonVariant
|
|
32
|
+
/** Semantic action palette, independent of treatment. */
|
|
29
33
|
tone?: Tone
|
|
34
|
+
/** Shared action dimensions; defaults to medium. */
|
|
30
35
|
controlSize?: ControlSize
|
|
36
|
+
/** Square action; supply an accessible name for icon-only children. */
|
|
31
37
|
iconOnly?: boolean
|
|
32
38
|
fullWidth?: boolean
|
|
39
|
+
/** Block activation and show progress while preserving focus and the label. */
|
|
33
40
|
pending?: boolean
|
|
41
|
+
/** Requires MotionProvider. Off also suppresses legacy spatial transitions. */
|
|
42
|
+
motion?: 'inherit' | 'off'
|
|
34
43
|
}
|
|
35
44
|
|
|
36
45
|
export function Button({
|
|
37
46
|
render,
|
|
47
|
+
motion = 'inherit',
|
|
48
|
+
ref,
|
|
38
49
|
type = 'button',
|
|
39
50
|
variant = 'solid',
|
|
40
51
|
tone = 'accent',
|
|
@@ -47,15 +58,57 @@ export function Button({
|
|
|
47
58
|
children,
|
|
48
59
|
...props
|
|
49
60
|
}: ButtonProps) {
|
|
61
|
+
const callerOwnsScale = callerOwnsPress(props.style, className)
|
|
62
|
+
const press = usePressHost(ref, motion === 'off' || callerOwnsScale)
|
|
63
|
+
const motionOff = motion === 'off' || press.off
|
|
64
|
+
const spatial = (press.active || motionOff) && !callerOwnsScale
|
|
50
65
|
const buttonProps: ButtonRenderProps = {
|
|
51
66
|
...props,
|
|
67
|
+
ref: press.active ? press.ref : ref,
|
|
68
|
+
onPointerDown: event => {
|
|
69
|
+
props.onPointerDown?.(event)
|
|
70
|
+
if (!pending && !event.defaultPrevented) press.press(event.nativeEvent)
|
|
71
|
+
},
|
|
72
|
+
onPointerUp: event => {
|
|
73
|
+
props.onPointerUp?.(event)
|
|
74
|
+
press.release(event.nativeEvent)
|
|
75
|
+
},
|
|
76
|
+
onPointerCancel: event => {
|
|
77
|
+
props.onPointerCancel?.(event)
|
|
78
|
+
press.release(event.nativeEvent)
|
|
79
|
+
},
|
|
80
|
+
onPointerLeave: event => {
|
|
81
|
+
props.onPointerLeave?.(event)
|
|
82
|
+
press.release(event.nativeEvent)
|
|
83
|
+
},
|
|
84
|
+
onLostPointerCapture: event => {
|
|
85
|
+
props.onLostPointerCapture?.(event)
|
|
86
|
+
press.release(event.nativeEvent)
|
|
87
|
+
},
|
|
88
|
+
onBlur: event => {
|
|
89
|
+
props.onBlur?.(event)
|
|
90
|
+
press.release()
|
|
91
|
+
},
|
|
92
|
+
onKeyDown: event => {
|
|
93
|
+
props.onKeyDown?.(event)
|
|
94
|
+
if (!pending && !event.defaultPrevented) press.press(event.nativeEvent)
|
|
95
|
+
},
|
|
96
|
+
onKeyUp: event => {
|
|
97
|
+
props.onKeyUp?.(event)
|
|
98
|
+
press.release(event.nativeEvent)
|
|
99
|
+
},
|
|
52
100
|
type,
|
|
53
101
|
'aria-busy': pending || props['aria-busy'],
|
|
54
102
|
'data-slot': joinIds('button', props['data-slot']) ?? 'button',
|
|
55
103
|
'data-variant': variant,
|
|
56
104
|
'data-tone': tone,
|
|
57
105
|
'data-control-size': controlSize,
|
|
58
|
-
className: cn(
|
|
106
|
+
className: cn(
|
|
107
|
+
actionVariants({ variant, tone, controlSize, iconOnly, fullWidth }),
|
|
108
|
+
spatial && springPressClass,
|
|
109
|
+
motionOff && !callerOwnsScale && offPressClass,
|
|
110
|
+
className
|
|
111
|
+
),
|
|
59
112
|
onClick: composeAction(
|
|
60
113
|
onClick,
|
|
61
114
|
undefined,
|
|
@@ -76,6 +129,7 @@ export function Button({
|
|
|
76
129
|
)
|
|
77
130
|
}
|
|
78
131
|
if (!render) return <button {...buttonProps}>{buttonProps.children}</button>
|
|
132
|
+
// oxlint-disable-next-line react/refs -- The render contract forwards refs; it does not read ref.current.
|
|
79
133
|
const element = render(buttonProps)
|
|
80
134
|
if (
|
|
81
135
|
!isValidElement(element) ||
|
package/src/Card.tsx
CHANGED
|
@@ -10,7 +10,7 @@ const colorMotionClass =
|
|
|
10
10
|
const cardVariants = cva([
|
|
11
11
|
colorMotionClass,
|
|
12
12
|
'font-[family-name:var(--rad-typography-roles-ui-body-family,system-ui,sans-serif)] tracking-[var(--rad-typography-roles-ui-body-letter-spacing,-0.011em)] text-[length:var(--rad-typography-roles-ui-body-size,0.875rem)] font-[number:var(--rad-typography-roles-ui-body-weight,400)] leading-[var(--rad-typography-roles-ui-body-line-height,1.5)]',
|
|
13
|
-
'box-border grid w-full gap-[var(--rad-card-gap,var(--rad-surface-gap,1rem))] text-start antialiased',
|
|
13
|
+
'box-border grid w-full min-w-0 gap-[var(--rad-card-gap,var(--rad-surface-gap,1rem))] text-start antialiased',
|
|
14
14
|
'rounded-[var(--rad-card-radius,var(--rad-surface-radius,0.75rem))]',
|
|
15
15
|
'[corner-shape:var(--rad-card-corner-shape,var(--rad-surface-corner-shape,round))]',
|
|
16
16
|
'[border-width:var(--rad-card-border-width,var(--rad-surface-border-width,1px))]',
|
|
@@ -67,11 +67,13 @@ type CardPartProps<Host extends 'div' | 'h2' | 'p'> = Omit<ComponentProps<Host>,
|
|
|
67
67
|
'data-slot'?: string
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
/** Passive div host. Compose native actions, form state and dedicated motion wrappers explicitly. */
|
|
70
71
|
export type CardProps = CardPartProps<'div'>
|
|
71
72
|
|
|
72
73
|
export type CardHeaderProps = CardPartProps<'div'>
|
|
73
74
|
|
|
74
75
|
export type CardTitleProps = CardPartProps<'h2'> & {
|
|
76
|
+
/** Semantic heading host; choose a level that fits the surrounding page outline. */
|
|
75
77
|
level?: CardHeadingLevel
|
|
76
78
|
}
|
|
77
79
|
|
package/src/Checkbox.tsx
CHANGED
|
@@ -43,19 +43,23 @@ const markClass =
|
|
|
43
43
|
'pointer-events-none absolute inset-0 size-full scale-65 [color:var(--rad-checkbox-mark,var(--rad-color-accent-foreground,oklch(0.985_0_0)))] peer-disabled:[color:var(--rad-checkbox-mark,var(--rad-color-muted-foreground,oklch(0.45_0.01_286)))] forced-colors:text-[HighlightText] forced-colors:peer-disabled:text-[GrayText]'
|
|
44
44
|
|
|
45
45
|
const rowClass =
|
|
46
|
-
'inline-flex min-h-6 cursor-pointer items-center gap-[var(--rad-checkbox-gap,var(--rad-spacing-label-gap,0.5rem))] select-none has-disabled:cursor-not-allowed'
|
|
46
|
+
'inline-flex min-h-6 min-w-0 max-w-full cursor-pointer items-center gap-[var(--rad-checkbox-gap,var(--rad-spacing-label-gap,0.5rem))] select-none has-disabled:cursor-not-allowed'
|
|
47
47
|
|
|
48
48
|
const labelClass =
|
|
49
|
-
'font-[family-name:var(--rad-typography-roles-ui-label-family,system-ui,sans-serif)] tracking-[var(--rad-typography-roles-ui-label-letter-spacing,-0.011em)] font-[number:var(--rad-typography-roles-ui-label-weight,400)] [color:var(--rad-checkbox-label-color,var(--rad-color-foreground,oklch(0.21_0.006_286)))] text-[length:var(--rad-checkbox-label-size,var(--_rad-control-font-size))] leading-[var(--rad-typography-roles-ui-label-line-height,1.4)]'
|
|
49
|
+
'min-w-0 break-words font-[family-name:var(--rad-typography-roles-ui-label-family,system-ui,sans-serif)] tracking-[var(--rad-typography-roles-ui-label-letter-spacing,-0.011em)] font-[number:var(--rad-typography-roles-ui-label-weight,400)] [color:var(--rad-checkbox-label-color,var(--rad-color-foreground,oklch(0.21_0.006_286)))] text-[length:var(--rad-checkbox-label-size,var(--_rad-control-font-size))] leading-[var(--rad-typography-roles-ui-label-line-height,1.4)]'
|
|
50
50
|
|
|
51
51
|
export type CheckboxProps = Omit<
|
|
52
52
|
ComponentProps<'input'>,
|
|
53
53
|
'type' | 'checked' | 'defaultChecked' | 'style'
|
|
54
54
|
> &
|
|
55
55
|
CheckedOwner & {
|
|
56
|
+
/** Convenience label; omit it when Field supplies the single control's label. */
|
|
56
57
|
label?: ReactNode
|
|
58
|
+
/** Native mixed presentation, independent of checked and the submitted value. */
|
|
57
59
|
indeterminate?: boolean
|
|
60
|
+
/** Shared visual metrics, matching Input and RadioGroup. */
|
|
58
61
|
controlSize?: ControlSize
|
|
62
|
+
/** Input styles. Parts style the wrapper, label and decorative indicators. */
|
|
59
63
|
style?: ThemeStyle
|
|
60
64
|
parts?: ControlParts
|
|
61
65
|
}
|
|
@@ -64,6 +68,7 @@ function hasContent(value: ReactNode) {
|
|
|
64
68
|
return value != null && value !== false && value !== ''
|
|
65
69
|
}
|
|
66
70
|
|
|
71
|
+
/** Native selection and form behavior. Read event.target.checked for state, value for data. */
|
|
67
72
|
export function Checkbox({
|
|
68
73
|
className,
|
|
69
74
|
controlSize = 'medium',
|
package/src/Collapsible.tsx
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import type { ComponentProps, ToggleEvent } from 'react'
|
|
4
|
-
import { createContext, useContext, useId } from 'react'
|
|
4
|
+
import { createContext, useContext, useId, useLayoutEffect, useRef } from 'react'
|
|
5
5
|
import { cva } from 'class-variance-authority'
|
|
6
|
+
import { useTransitionHost } from './motion/host.js'
|
|
6
7
|
import { cn } from './cn.js'
|
|
7
8
|
import { joinIds } from './internal/ids.js'
|
|
8
9
|
import type { ThemeStyle } from './themes/defineTheme.js'
|
|
9
10
|
import { useControllableState } from './react/useControllableState.js'
|
|
11
|
+
import { useComposedRefs } from './react/useComposedRefs.js'
|
|
10
12
|
|
|
11
13
|
const colorMotionClass =
|
|
12
14
|
'transition-colors duration-[var(--rad-motion-color-duration,150ms)] motion-reduce:transition-none'
|
|
@@ -67,7 +69,10 @@ const collapsibleContentVariants = cva([
|
|
|
67
69
|
export type CollapsibleProps = Omit<ComponentProps<'details'>, 'open' | 'onToggle' | 'style'> &
|
|
68
70
|
({ open: boolean; defaultOpen?: never } | { open?: undefined; defaultOpen?: boolean }) & {
|
|
69
71
|
style?: ThemeStyle
|
|
72
|
+
/** Height/marker presentation only. Native disclosure state never waits for motion. */
|
|
73
|
+
motion?: 'inherit' | 'off'
|
|
70
74
|
'data-slot'?: string
|
|
75
|
+
/** Use this to write controlled state; onToggle remains a native observation. */
|
|
71
76
|
onOpenChange?: (open: boolean) => void
|
|
72
77
|
onToggle?: (event: ToggleEvent<HTMLDetailsElement>) => void
|
|
73
78
|
}
|
|
@@ -78,11 +83,13 @@ export type CollapsibleState = {
|
|
|
78
83
|
setOpen: (open: boolean) => void
|
|
79
84
|
}
|
|
80
85
|
|
|
86
|
+
/** One direct-child native summary. Keep buttons and links in Content. */
|
|
81
87
|
export type CollapsibleTriggerProps = Omit<ComponentProps<'summary'>, 'style'> & {
|
|
82
88
|
style?: ThemeStyle
|
|
83
89
|
'data-slot'?: string
|
|
84
90
|
}
|
|
85
91
|
|
|
92
|
+
/** Native div host; keep content in normal flow for natural-height measurement. */
|
|
86
93
|
export type CollapsibleContentProps = Omit<ComponentProps<'div'>, 'style'> & {
|
|
87
94
|
style?: ThemeStyle
|
|
88
95
|
'data-slot'?: string
|
|
@@ -103,13 +110,23 @@ function useCollapsibleContext() {
|
|
|
103
110
|
export function Collapsible({
|
|
104
111
|
open,
|
|
105
112
|
defaultOpen,
|
|
113
|
+
motion = 'inherit',
|
|
114
|
+
ref,
|
|
106
115
|
onOpenChange,
|
|
107
116
|
onToggle,
|
|
108
117
|
className,
|
|
109
118
|
children,
|
|
110
119
|
...props
|
|
111
120
|
}: CollapsibleProps) {
|
|
121
|
+
const node = useRef<HTMLDetailsElement>(null)
|
|
122
|
+
const nativeRef = useComposedRefs(node, ref)
|
|
123
|
+
const transition = useTransitionHost<HTMLDetailsElement>(
|
|
124
|
+
'disclosure',
|
|
125
|
+
nativeRef,
|
|
126
|
+
motion === 'off'
|
|
127
|
+
)
|
|
112
128
|
const contentId = useId()
|
|
129
|
+
const motionOff = motion === 'off' || transition.off
|
|
113
130
|
const {
|
|
114
131
|
value: isOpen,
|
|
115
132
|
request: setOpen,
|
|
@@ -121,12 +138,31 @@ export function Collapsible({
|
|
|
121
138
|
initialValue: false,
|
|
122
139
|
onChange: onOpenChange
|
|
123
140
|
})
|
|
141
|
+
const reconciled = useRef<HTMLDetailsElement | null>(null)
|
|
142
|
+
useLayoutEffect(() => {
|
|
143
|
+
const host = node.current
|
|
144
|
+
if (!host || reconciled.current === host) return
|
|
145
|
+
reconciled.current = host
|
|
146
|
+
// A native toggle may have completed before React installed its listener.
|
|
147
|
+
// Adoption is one local change; restoring a controlled owner is not a request.
|
|
148
|
+
if (controlled) host.open = isOpen
|
|
149
|
+
else setOpen(host.open)
|
|
150
|
+
}, [controlled, isOpen, setOpen])
|
|
124
151
|
|
|
125
152
|
return (
|
|
126
153
|
<CollapsibleContext.Provider value={{ open: isOpen, contentId, setOpen }}>
|
|
127
154
|
<details
|
|
128
155
|
{...props}
|
|
129
|
-
|
|
156
|
+
ref={transition.active ? transition.ref : nativeRef}
|
|
157
|
+
suppressHydrationWarning
|
|
158
|
+
className={cn(
|
|
159
|
+
collapsibleVariants(),
|
|
160
|
+
transition.active &&
|
|
161
|
+
transition.ready &&
|
|
162
|
+
'[&::details-content]:[content-visibility:visible] [&::details-content]:transition-none [&:not([open])::details-content]:h-[var(--_rad-spring-details-height,0px)] open:[&::details-content]:h-[var(--_rad-spring-details-height,auto)]',
|
|
163
|
+
motionOff && '[&::details-content]:transition-none [&>summary>svg]:transition-none',
|
|
164
|
+
className
|
|
165
|
+
)}
|
|
130
166
|
data-slot={joinIds('collapsible', props['data-slot'])}
|
|
131
167
|
data-state={isOpen ? 'open' : 'closed'}
|
|
132
168
|
open={isOpen}
|
package/src/Dialog.tsx
CHANGED
|
@@ -4,6 +4,8 @@ import type { ComponentProps, MouseEvent, ReactNode } from 'react'
|
|
|
4
4
|
import { createContext, useContext, useEffect, useId, useRef, useState } from 'react'
|
|
5
5
|
import { cva } from 'class-variance-authority'
|
|
6
6
|
import { Button, type ButtonProps, type ButtonRenderProps } from './Button.js'
|
|
7
|
+
import { callerOwnsPress } from './motion/pressPolicy.js'
|
|
8
|
+
import { useTransitionHost } from './motion/host.js'
|
|
7
9
|
import { cn } from './cn.js'
|
|
8
10
|
import { composeAction } from './internal/events.js'
|
|
9
11
|
import { joinIds } from './internal/ids.js'
|
|
@@ -65,6 +67,7 @@ export type DialogProps = (
|
|
|
65
67
|
| { open: boolean; defaultOpen?: never }
|
|
66
68
|
| { open?: undefined; defaultOpen?: boolean }
|
|
67
69
|
) & {
|
|
70
|
+
/** A change request. The controlled owner may decline it; prop syncs do not notify. */
|
|
68
71
|
onOpenChange?: (open: boolean) => void
|
|
69
72
|
/** `true` calls `showModal()`. `false` calls `show()` and leaves the rest of the page active. */
|
|
70
73
|
modal?: boolean
|
|
@@ -89,10 +92,13 @@ export type DialogState = {
|
|
|
89
92
|
|
|
90
93
|
export type DialogRenderProps = ButtonRenderProps
|
|
91
94
|
|
|
95
|
+
/** Button props/render/ref contract, with protected dialog relationships. */
|
|
92
96
|
export type DialogTriggerProps = ButtonProps
|
|
93
97
|
|
|
94
98
|
export type DialogContentProps = Omit<ComponentProps<'dialog'>, 'open' | 'style'> & {
|
|
95
99
|
style?: ThemeStyle
|
|
100
|
+
/** Opt-in MotionProvider presentation; native close and focus never wait for an exit. */
|
|
101
|
+
motion?: 'inherit' | 'off'
|
|
96
102
|
}
|
|
97
103
|
|
|
98
104
|
export type DialogTitleProps = Omit<ComponentProps<'h2'>, 'style'> & { style?: ThemeStyle }
|
|
@@ -184,6 +190,7 @@ export function DialogTrigger(props: DialogTriggerProps) {
|
|
|
184
190
|
}
|
|
185
191
|
|
|
186
192
|
export function DialogContent({
|
|
193
|
+
motion = 'inherit',
|
|
187
194
|
className,
|
|
188
195
|
onClick,
|
|
189
196
|
onCancel,
|
|
@@ -193,7 +200,12 @@ export function DialogContent({
|
|
|
193
200
|
}: DialogContentProps) {
|
|
194
201
|
const dialog = useDialogContext()
|
|
195
202
|
const nodeRef = useRef<HTMLDialogElement>(null)
|
|
196
|
-
const
|
|
203
|
+
const transition = useTransitionHost<HTMLDialogElement>(
|
|
204
|
+
'dialog',
|
|
205
|
+
ref,
|
|
206
|
+
motion === 'off' || callerOwnsPress(props.style, className)
|
|
207
|
+
)
|
|
208
|
+
const hostRef = useComposedRefs(nodeRef, transition.active ? transition.ref : ref)
|
|
197
209
|
const unmounting = useRef(false)
|
|
198
210
|
const previousModal = useRef(dialog.modal)
|
|
199
211
|
// Bumps after the browser closes a dialog whose controlled `open` value is still true.
|
package/src/Field.tsx
CHANGED
|
@@ -43,6 +43,7 @@ const requiredClass =
|
|
|
43
43
|
|
|
44
44
|
export type FieldLayout = 'control' | 'group'
|
|
45
45
|
|
|
46
|
+
/** Forward every prop to one native control; merge any external description IDs. */
|
|
46
47
|
export type FieldControlProps = {
|
|
47
48
|
id: string
|
|
48
49
|
required?: boolean
|
|
@@ -68,13 +69,16 @@ export type FieldState = {
|
|
|
68
69
|
type FieldOwn = {
|
|
69
70
|
/** Additional identities; Field always retains its base identity. */
|
|
70
71
|
'data-slot'?: string
|
|
72
|
+
/** The control label, or the group's native legend. */
|
|
71
73
|
label: ReactNode
|
|
72
74
|
description?: ReactNode
|
|
75
|
+
/** Consumer-owned validation content. Present errors immediately mark the owner invalid. */
|
|
73
76
|
error?: ReactNode
|
|
74
77
|
required?: boolean
|
|
75
78
|
disabled?: boolean
|
|
76
79
|
requiredIndicator?: ReactNode
|
|
77
80
|
style?: ThemeStyle
|
|
81
|
+
/** Presentation only; Field keeps each part's IDs, ARIA and native semantics. */
|
|
78
82
|
parts?: {
|
|
79
83
|
label?: PartStyle
|
|
80
84
|
description?: PartStyle
|
|
@@ -88,7 +92,9 @@ type FieldControl = FieldOwn &
|
|
|
88
92
|
layout?: 'control'
|
|
89
93
|
form?: never
|
|
90
94
|
name?: never
|
|
95
|
+
/** The input's ID. Root id/ref still target Field's div. */
|
|
91
96
|
controlId?: string
|
|
97
|
+
/** Radiant controls connect automatically; native adapters forward the callback props. */
|
|
92
98
|
children?: ReactNode | ((control: FieldControlProps) => ReactNode)
|
|
93
99
|
}
|
|
94
100
|
|
|
@@ -103,6 +109,7 @@ export type FieldProps = FieldControl | FieldGroup
|
|
|
103
109
|
|
|
104
110
|
const FieldContext = createContext<FieldState | null>(null)
|
|
105
111
|
|
|
112
|
+
/** Nearest Field metadata, or null. Groups have no single target: controlProps is null. */
|
|
106
113
|
export function useField(): FieldState | null {
|
|
107
114
|
return useContext(FieldContext)
|
|
108
115
|
}
|
|
@@ -144,6 +151,7 @@ function definedProps(props: FieldControlProps): FieldControlProps {
|
|
|
144
151
|
) as FieldControlProps
|
|
145
152
|
}
|
|
146
153
|
|
|
154
|
+
/** Owns label/help/error relationships; the consumer owns values, validation and focus. */
|
|
147
155
|
export function Field(props: FieldProps) {
|
|
148
156
|
const {
|
|
149
157
|
label,
|
package/src/Input.tsx
CHANGED
|
@@ -41,10 +41,13 @@ const inputVariants = cva([
|
|
|
41
41
|
|
|
42
42
|
export type InputProps = Omit<ComponentProps<'input'>, 'value' | 'defaultValue' | 'style'> &
|
|
43
43
|
ValueOwner<Exclude<ComponentProps<'input'>['value'], undefined>> & {
|
|
44
|
+
/** Shared visual metrics. Native size remains a numeric character-width hint. */
|
|
44
45
|
controlSize?: ControlSize
|
|
46
|
+
/** Applied to the native input, including caller-owned motion styles. */
|
|
45
47
|
style?: ThemeStyle
|
|
46
48
|
}
|
|
47
49
|
|
|
50
|
+
/** Native editing, selection, events and ref; Field supplies owned form relationships. */
|
|
48
51
|
export function Input({
|
|
49
52
|
className,
|
|
50
53
|
controlSize = 'medium',
|
package/src/Link.tsx
CHANGED
|
@@ -42,10 +42,15 @@ export type LinkRenderProps = Omit<ComponentProps<'a'>, 'style'> & {
|
|
|
42
42
|
|
|
43
43
|
export type LinkProps = Omit<ComponentProps<'a'>, 'style'> & {
|
|
44
44
|
style?: ThemeStyle
|
|
45
|
+
/** Inline/subtle inherit text metrics; action treatments share Button's presentation. */
|
|
45
46
|
variant?: LinkVariant
|
|
47
|
+
/** Semantic palette, independent of treatment. */
|
|
46
48
|
tone?: Tone
|
|
49
|
+
/** Shared action dimensions; inline/subtle keep their surrounding text size. */
|
|
47
50
|
controlSize?: ControlSize
|
|
51
|
+
/** Default target to _blank and rel to noopener noreferrer; explicit native values win. */
|
|
48
52
|
external?: boolean
|
|
53
|
+
/** Forward every resolved prop, ref and child to one native or router anchor. */
|
|
49
54
|
render?: (props: LinkRenderProps) => ReactElement
|
|
50
55
|
}
|
|
51
56
|
|
package/src/RadioGroup.tsx
CHANGED
|
@@ -44,10 +44,10 @@ const dotClass =
|
|
|
44
44
|
'pointer-events-none absolute inset-[30%] rounded-[var(--rad-radio-radius,999px)] bg-[var(--rad-radio-mark,var(--rad-color-accent-foreground,oklch(0.985_0_0)))] peer-disabled:bg-[var(--rad-radio-mark,var(--rad-color-muted-foreground,oklch(0.45_0.01_286)))] opacity-0 peer-checked:opacity-100 forced-colors:bg-[HighlightText] forced-colors:peer-disabled:bg-[GrayText]'
|
|
45
45
|
|
|
46
46
|
const rowClass =
|
|
47
|
-
'inline-flex min-h-6 cursor-pointer items-center gap-[var(--rad-radio-label-gap,var(--rad-spacing-label-gap,0.5rem))] select-none has-disabled:cursor-not-allowed'
|
|
47
|
+
'inline-flex min-h-6 min-w-0 max-w-full cursor-pointer items-center gap-[var(--rad-radio-label-gap,var(--rad-spacing-label-gap,0.5rem))] select-none has-disabled:cursor-not-allowed'
|
|
48
48
|
|
|
49
49
|
const labelClass =
|
|
50
|
-
'font-[family-name:var(--rad-typography-roles-ui-label-family,system-ui,sans-serif)] tracking-[var(--rad-typography-roles-ui-label-letter-spacing,-0.011em)] font-[number:var(--rad-typography-roles-ui-label-weight,400)] [color:var(--rad-radio-label-color,var(--rad-color-foreground,oklch(0.21_0.006_286)))] text-[length:var(--rad-radio-label-size,var(--_rad-control-font-size))] leading-[var(--rad-typography-roles-ui-label-line-height,1.4)]'
|
|
50
|
+
'min-w-0 break-words font-[family-name:var(--rad-typography-roles-ui-label-family,system-ui,sans-serif)] tracking-[var(--rad-typography-roles-ui-label-letter-spacing,-0.011em)] font-[number:var(--rad-typography-roles-ui-label-weight,400)] [color:var(--rad-radio-label-color,var(--rad-color-foreground,oklch(0.21_0.006_286)))] text-[length:var(--rad-radio-label-size,var(--_rad-control-font-size))] leading-[var(--rad-typography-roles-ui-label-line-height,1.4)]'
|
|
51
51
|
|
|
52
52
|
const optionsClass =
|
|
53
53
|
'grid justify-items-start gap-[var(--rad-radio-group-gap,var(--rad-spacing-group-gap,0.75rem))]'
|
|
@@ -70,10 +70,13 @@ export type RadioGroupProps = Omit<
|
|
|
70
70
|
'layout' | 'children' | 'onChange' | 'defaultValue' | 'parts'
|
|
71
71
|
> &
|
|
72
72
|
ValueOwner<string | null> & {
|
|
73
|
+
/** Stable native group name. Options supply distinct string values, including ''. */
|
|
73
74
|
name: string
|
|
75
|
+
/** Shared Input/Checkbox/Radio metrics; each option may override them. */
|
|
74
76
|
controlSize?: ControlSize
|
|
75
77
|
parts?: NonNullable<FieldProps['parts']> & { options?: PartStyle }
|
|
76
78
|
onChange?: (event: ChangeEvent<HTMLInputElement>) => void
|
|
79
|
+
/** Receives the selected string. Use this or onChange to write state, not both. */
|
|
77
80
|
onValueChange?: (value: string) => void
|
|
78
81
|
children?: ReactNode
|
|
79
82
|
}
|
|
@@ -83,10 +86,13 @@ export type RadioProps = Omit<
|
|
|
83
86
|
'type' | 'value' | 'checked' | 'defaultChecked' | 'style'
|
|
84
87
|
> &
|
|
85
88
|
CheckedOwner & {
|
|
89
|
+
/** Convenience label. Without it, provide an accessible name on the native input. */
|
|
86
90
|
label?: ReactNode
|
|
91
|
+
/** Submitted data, independent of standalone checked/defaultChecked ownership. */
|
|
87
92
|
value: string
|
|
88
93
|
controlSize?: ControlSize
|
|
89
94
|
style?: ThemeStyle
|
|
95
|
+
/** Presentation only. Root styling, native props and ref still reach the input. */
|
|
90
96
|
parts?: ControlParts
|
|
91
97
|
}
|
|
92
98
|
|
|
@@ -94,6 +100,7 @@ function hasContent(value: ReactNode) {
|
|
|
94
100
|
return value != null && value !== false && value !== ''
|
|
95
101
|
}
|
|
96
102
|
|
|
103
|
+
/** Native fieldset: owns option name and selection; controlled form reset belongs to the caller. */
|
|
97
104
|
export function RadioGroup({
|
|
98
105
|
name,
|
|
99
106
|
value,
|
|
@@ -142,6 +149,7 @@ export function RadioGroup({
|
|
|
142
149
|
)
|
|
143
150
|
}
|
|
144
151
|
|
|
152
|
+
/** Native radio. Inside RadioGroup, omit checked/defaultChecked and conflicting names. */
|
|
145
153
|
export function Radio({
|
|
146
154
|
className,
|
|
147
155
|
controlSize: controlSizeProp,
|
package/src/ThemeScope.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
+
import { MotionProfileContext } from './motion/context.js'
|
|
4
|
+
|
|
3
5
|
import { createContext, useContext } from 'react'
|
|
4
6
|
import type { ComponentProps } from 'react'
|
|
5
7
|
import { cn } from './cn.js'
|
|
@@ -42,23 +44,25 @@ export function ThemeScope({ theme, mode, style, className, children, ...props }
|
|
|
42
44
|
|
|
43
45
|
return (
|
|
44
46
|
<ThemeContext.Provider value={{ theme: selected, overrides }}>
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
?
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
47
|
+
<MotionProfileContext.Provider value={selected.motion ?? defaultTheme.motion}>
|
|
48
|
+
<div
|
|
49
|
+
{...props}
|
|
50
|
+
data-rad-theme={theme?.id}
|
|
51
|
+
data-rad-mode={mode}
|
|
52
|
+
className={cn(scopeClass, className)}
|
|
53
|
+
style={{
|
|
54
|
+
...resolved,
|
|
55
|
+
...(mode === undefined
|
|
56
|
+
? parent === null
|
|
57
|
+
? { colorScheme: 'light dark' }
|
|
58
|
+
: {}
|
|
59
|
+
: { colorScheme: mode === 'system' ? 'light dark' : mode }),
|
|
60
|
+
...style
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
{children}
|
|
64
|
+
</div>
|
|
65
|
+
</MotionProfileContext.Provider>
|
|
62
66
|
</ThemeContext.Provider>
|
|
63
67
|
)
|
|
64
68
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineTheme } from '
|
|
1
|
+
import { defineTheme, type ThemeDefinition } from '../themes/defineTheme.js'
|
|
2
2
|
import { spring } from './preset-values.js'
|
|
3
3
|
|
|
4
|
-
export const
|
|
4
|
+
export const expressiveDefinition: ThemeDefinition = {
|
|
5
5
|
id: 'expressive',
|
|
6
6
|
name: 'Expressive',
|
|
7
7
|
tokens: {
|
|
@@ -129,4 +129,6 @@ export const expressive = defineTheme({
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export const expressive = defineTheme(expressiveDefinition)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineTheme } from '
|
|
1
|
+
import { defineTheme, type ThemeDefinition } from '../themes/defineTheme.js'
|
|
2
2
|
import { snap, spring } from './preset-values.js'
|
|
3
3
|
|
|
4
|
-
export const
|
|
4
|
+
export const glassDefinition: ThemeDefinition = {
|
|
5
5
|
id: 'glass',
|
|
6
6
|
name: 'Glass',
|
|
7
7
|
tokens: {
|
|
@@ -132,4 +132,6 @@ export const glass = defineTheme({
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export const glass = defineTheme(glassDefinition)
|