@cognitap/radiant 0.0.90 → 0.0.92
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 +18 -0
- package/dist/library/a2ui/A2uiPlaceholder.d.ts +14 -0
- package/dist/library/a2ui/A2uiPlaceholder.d.ts.map +1 -0
- package/dist/library/a2ui/A2uiPlaceholder.js +44 -0
- package/dist/library/a2ui/A2uiPlaceholder.js.map +1 -0
- package/dist/library/a2ui/A2uiSurface.d.ts +33 -0
- package/dist/library/a2ui/A2uiSurface.d.ts.map +1 -0
- package/dist/library/a2ui/A2uiSurface.js +542 -0
- package/dist/library/a2ui/A2uiSurface.js.map +1 -0
- package/dist/library/a2ui/accessibility.d.ts +31 -0
- package/dist/library/a2ui/accessibility.d.ts.map +1 -0
- package/dist/library/a2ui/accessibility.js +108 -0
- package/dist/library/a2ui/accessibility.js.map +1 -0
- package/dist/library/a2ui/accessibilityRules.d.ts +28 -0
- package/dist/library/a2ui/accessibilityRules.d.ts.map +1 -0
- package/dist/library/a2ui/accessibilityRules.js +73 -0
- package/dist/library/a2ui/accessibilityRules.js.map +1 -0
- package/dist/library/a2ui/catalogGenerator.d.ts +29 -0
- package/dist/library/a2ui/catalogGenerator.d.ts.map +1 -0
- package/dist/library/a2ui/catalogGenerator.js +578 -0
- package/dist/library/a2ui/catalogGenerator.js.map +1 -0
- package/dist/library/a2ui/coerce.d.ts +16 -0
- package/dist/library/a2ui/coerce.d.ts.map +1 -0
- package/dist/library/a2ui/coerce.js +254 -0
- package/dist/library/a2ui/coerce.js.map +1 -0
- package/dist/library/a2ui/entries.d.ts +6 -0
- package/dist/library/a2ui/entries.d.ts.map +1 -0
- package/dist/library/a2ui/entries.js +277 -0
- package/dist/library/a2ui/entries.js.map +1 -0
- package/dist/library/a2ui/fixtures.d.ts +38 -0
- package/dist/library/a2ui/fixtures.d.ts.map +1 -0
- package/dist/library/a2ui/fixtures.js +389 -0
- package/dist/library/a2ui/fixtures.js.map +1 -0
- package/dist/library/a2ui/index.d.ts +17 -0
- package/dist/library/a2ui/index.d.ts.map +1 -0
- package/dist/library/a2ui/index.js +9 -0
- package/dist/library/a2ui/index.js.map +1 -0
- package/dist/library/a2ui/protocolErrors.d.ts +13 -0
- package/dist/library/a2ui/protocolErrors.d.ts.map +1 -0
- package/dist/library/a2ui/protocolErrors.js +48 -0
- package/dist/library/a2ui/protocolErrors.js.map +1 -0
- package/dist/library/a2ui/registry.d.ts +58 -0
- package/dist/library/a2ui/registry.d.ts.map +1 -0
- package/dist/library/a2ui/registry.js +128 -0
- package/dist/library/a2ui/registry.js.map +1 -0
- package/dist/library/a2ui/sanitize.d.ts +7 -0
- package/dist/library/a2ui/sanitize.d.ts.map +1 -0
- package/dist/library/a2ui/sanitize.js +54 -0
- package/dist/library/a2ui/sanitize.js.map +1 -0
- package/dist/library/a2ui/surfaceRuntime.d.ts +34 -0
- package/dist/library/a2ui/surfaceRuntime.d.ts.map +1 -0
- package/dist/library/a2ui/surfaceRuntime.js +284 -0
- package/dist/library/a2ui/surfaceRuntime.js.map +1 -0
- package/dist/library/catalog/actions.d.ts +40 -0
- package/dist/library/catalog/actions.d.ts.map +1 -0
- package/dist/library/catalog/actions.js +70 -0
- package/dist/library/catalog/actions.js.map +1 -0
- package/dist/library/catalog/coerce.d.ts +70 -0
- package/dist/library/catalog/coerce.d.ts.map +1 -0
- package/dist/library/catalog/coerce.js +332 -0
- package/dist/library/catalog/coerce.js.map +1 -0
- package/dist/library/catalog/index.d.ts +9 -0
- package/dist/library/catalog/index.d.ts.map +1 -0
- package/dist/library/catalog/index.js +6 -0
- package/dist/library/catalog/index.js.map +1 -0
- package/dist/library/catalog/radiantCatalog.d.ts +9 -0
- package/dist/library/catalog/radiantCatalog.d.ts.map +1 -0
- package/dist/library/catalog/radiantCatalog.js +902 -0
- package/dist/library/catalog/radiantCatalog.js.map +1 -0
- package/dist/library/catalog/types.d.ts +113 -0
- package/dist/library/catalog/types.d.ts.map +1 -0
- package/dist/library/catalog/types.js +27 -0
- package/dist/library/catalog/types.js.map +1 -0
- package/dist/library/catalog/validate.d.ts +31 -0
- package/dist/library/catalog/validate.d.ts.map +1 -0
- package/dist/library/catalog/validate.js +420 -0
- package/dist/library/catalog/validate.js.map +1 -0
- package/dist/library/components/Card/Card.d.ts +6 -2
- package/dist/library/components/Card/Card.d.ts.map +1 -1
- package/dist/library/components/Card/Card.js +12 -4
- package/dist/library/components/Card/Card.js.map +1 -1
- package/dist/library/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/library/components/Checkbox/Checkbox.js +2 -2
- package/dist/library/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/library/components/Collapsible/Collapsible.js +1 -1
- package/dist/library/components/Collapsible/Collapsible.js.map +1 -1
- package/dist/library/components/InputGroup/InputGroup.js +1 -1
- package/dist/library/components/InputGroup/InputGroup.js.map +1 -1
- package/dist/library/components/NavLink/NavLink.d.ts.map +1 -1
- package/dist/library/components/NavLink/NavLink.js +1 -1
- package/dist/library/components/NavLink/NavLink.js.map +1 -1
- package/dist/library/components/RadioGroup/RadioGroup.d.ts.map +1 -1
- package/dist/library/components/RadioGroup/RadioGroup.js +3 -3
- package/dist/library/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/library/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/library/components/ScrollArea/ScrollArea.js +4 -1
- package/dist/library/components/ScrollArea/ScrollArea.js.map +1 -1
- package/dist/library/components/Switch/Switch.d.ts.map +1 -1
- package/dist/library/components/Switch/Switch.js +2 -2
- package/dist/library/components/Switch/Switch.js.map +1 -1
- package/dist/library/components/Table/Table.d.ts +6 -2
- package/dist/library/components/Table/Table.d.ts.map +1 -1
- package/dist/library/components/Table/Table.js +10 -4
- package/dist/library/components/Table/Table.js.map +1 -1
- package/dist/library/components/TagsInput/TagsInput.d.ts.map +1 -1
- package/dist/library/components/TagsInput/TagsInput.js +1 -1
- package/dist/library/components/TagsInput/TagsInput.js.map +1 -1
- package/dist/library/components/TimeInput/TimeInput.d.ts.map +1 -1
- package/dist/library/components/TimeInput/TimeInput.js +28 -20
- package/dist/library/components/TimeInput/TimeInput.js.map +1 -1
- package/dist/library/components/Toast/Toast.js +1 -1
- package/dist/library/components/Toast/Toast.js.map +1 -1
- package/dist/library/components/ToggleGroup/ToggleGroup.js +1 -1
- package/dist/library/components/ToggleGroup/ToggleGroup.js.map +1 -1
- package/dist/library/index.d.ts +1 -1
- package/dist/library/index.d.ts.map +1 -1
- package/dist/library/presentation.d.ts +3 -0
- package/dist/library/presentation.d.ts.map +1 -1
- package/dist/library/styles.css +1 -1
- package/dist/library/themes/components.d.ts +6 -0
- package/dist/library/themes/components.d.ts.map +1 -1
- package/dist/library/themes/components.js +6 -0
- package/dist/library/themes/components.js.map +1 -1
- package/dist/library/themes/tokens.d.ts +4 -0
- package/dist/library/themes/tokens.d.ts.map +1 -1
- package/dist/library/themes/tokens.js +3 -0
- package/dist/library/themes/tokens.js.map +1 -1
- package/docs/accessibility.md +6 -0
- package/docs/architecture.md +20 -1
- package/docs/theming.md +13 -0
- package/package.json +17 -5
- package/src/a2ui/A2uiPlaceholder.tsx +64 -0
- package/src/a2ui/A2uiSurface.tsx +790 -0
- package/src/a2ui/accessibility.ts +145 -0
- package/src/a2ui/accessibilityRules.ts +106 -0
- package/src/a2ui/catalog.json +317 -0
- package/src/a2ui/catalogGenerator.ts +717 -0
- package/src/a2ui/coerce.ts +379 -0
- package/src/a2ui/entries.tsx +519 -0
- package/src/a2ui/fixtures.ts +402 -0
- package/src/a2ui/index.ts +50 -0
- package/src/a2ui/protocolErrors.ts +63 -0
- package/src/a2ui/registry.ts +221 -0
- package/src/a2ui/sanitize.ts +51 -0
- package/src/a2ui/surfaceRuntime.ts +317 -0
- package/src/catalog/actions.ts +108 -0
- package/src/catalog/coerce.ts +447 -0
- package/src/catalog/index.ts +67 -0
- package/src/catalog/radiantCatalog.ts +949 -0
- package/src/catalog/types.ts +159 -0
- package/src/catalog/validate.ts +454 -0
- package/src/components/Card/Card.tsx +35 -19
- package/src/components/Checkbox/Checkbox.tsx +2 -0
- package/src/components/Collapsible/Collapsible.tsx +1 -1
- package/src/components/InputGroup/InputGroup.tsx +2 -2
- package/src/components/NavLink/NavLink.tsx +1 -6
- package/src/components/RadioGroup/RadioGroup.tsx +3 -0
- package/src/components/ScrollArea/ScrollArea.tsx +5 -1
- package/src/components/Switch/Switch.tsx +2 -0
- package/src/components/Table/Table.tsx +16 -3
- package/src/components/TagsInput/TagsInput.tsx +1 -0
- package/src/components/TimeInput/TimeInput.tsx +100 -75
- package/src/components/Toast/Toast.tsx +1 -1
- package/src/components/ToggleGroup/ToggleGroup.tsx +1 -1
- package/src/index.ts +1 -1
- package/src/presentation.ts +3 -0
- package/src/themes/baseline.css +3 -0
- package/src/themes/components.ts +6 -0
- package/src/themes/tokens.ts +7 -0
|
@@ -121,6 +121,7 @@ export function Checkbox({
|
|
|
121
121
|
})
|
|
122
122
|
const controlNode = (
|
|
123
123
|
<span
|
|
124
|
+
dir={!labelled ? props.dir : undefined}
|
|
124
125
|
className={cn(
|
|
125
126
|
'relative inline-grid w-fit shrink-0',
|
|
126
127
|
indicatorPressClass,
|
|
@@ -186,6 +187,7 @@ export function Checkbox({
|
|
|
186
187
|
|
|
187
188
|
return (
|
|
188
189
|
<label
|
|
190
|
+
dir={props.dir}
|
|
189
191
|
className={cn(rowClass, parts?.wrapper?.className)}
|
|
190
192
|
style={parts?.wrapper?.style}
|
|
191
193
|
data-slot="checkbox-wrapper"
|
|
@@ -56,7 +56,7 @@ const collapsibleTriggerVariants = cva([
|
|
|
56
56
|
const collapsibleMarkerVariants = cva([
|
|
57
57
|
'size-4 shrink-0',
|
|
58
58
|
'transition-transform duration-[var(--rad-collapsible-duration,var(--rad-motion-disclosure-duration,150ms))] ease-out',
|
|
59
|
-
'[details[open]>summary>&]:rotate-90',
|
|
59
|
+
'rtl:rotate-180 [details[open]>summary>&]:rotate-90 rtl:[details[open]>summary>&]:rotate-90',
|
|
60
60
|
'motion-reduce:transition-none'
|
|
61
61
|
])
|
|
62
62
|
|
|
@@ -64,8 +64,8 @@ export function InputGroup({
|
|
|
64
64
|
'font-[family-name:var(--rad-typography-roles-ui-body-family,system-ui,sans-serif)] text-[length:var(--_rad-control-font-size)] leading-[var(--rad-typography-roles-ui-body-line-height,1.5)]',
|
|
65
65
|
focusWithinRingClass,
|
|
66
66
|
'focus-within:[--_rad-focus-color:var(--rad-input-group-focus-color)] focus-within:[--_rad-focus-width:var(--rad-input-group-focus-width)] focus-within:[--_rad-focus-offset:var(--rad-input-group-focus-offset)] focus-within:[--_rad-focus-style:var(--rad-input-group-focus-style)]',
|
|
67
|
-
'has-[>[data-invalid]]:[border-color:var(--rad-input-group-invalid-border,var(--rad-color-invalid,oklch(0.56_0.19_25)))]',
|
|
68
|
-
'has-[>input:disabled]:cursor-not-allowed has-[>textarea:disabled]:cursor-not-allowed has-[>input:disabled]:bg-[var(--rad-color-disabled-background,oklch(0.96_0.005_286))] has-[>textarea:disabled]:bg-[var(--rad-color-disabled-background,oklch(0.96_0.005_286))]',
|
|
67
|
+
'has-[>[data-invalid],[data-slot~=input-group-input][data-invalid]]:[border-color:var(--rad-input-group-invalid-border,var(--rad-color-invalid,oklch(0.56_0.19_25)))]',
|
|
68
|
+
'has-[>input:disabled,[data-slot~=input-group-input]:disabled]:cursor-not-allowed has-[>textarea:disabled]:cursor-not-allowed has-[>input:disabled,[data-slot~=input-group-input]:disabled]:bg-[var(--rad-color-disabled-background,oklch(0.96_0.005_286))] has-[>textarea:disabled]:bg-[var(--rad-color-disabled-background,oklch(0.96_0.005_286))]',
|
|
69
69
|
'forced-colors:border-[CanvasText] forced-colors:bg-[Canvas] forced-colors:text-[CanvasText]',
|
|
70
70
|
className
|
|
71
71
|
)}
|
|
@@ -160,12 +160,7 @@ export function NavLinkGroupTrigger({
|
|
|
160
160
|
{...native}
|
|
161
161
|
data-slot={joinIds('nav-link-group-trigger', slot)}
|
|
162
162
|
data-control-size={controlSize}
|
|
163
|
-
className={cn(
|
|
164
|
-
controlMetrics({ controlSize }),
|
|
165
|
-
itemClass,
|
|
166
|
-
'rtl:[&>svg]:rotate-180 rtl:data-[state=open]:[&>svg]:rotate-90',
|
|
167
|
-
className
|
|
168
|
-
)}
|
|
163
|
+
className={cn(controlMetrics({ controlSize }), itemClass, className)}
|
|
169
164
|
>
|
|
170
165
|
<Content {...{ icon, description, parts, children }} />
|
|
171
166
|
</CollapsibleTrigger>
|
|
@@ -232,6 +232,7 @@ export function Radio({
|
|
|
232
232
|
}, [controlled, selected])
|
|
233
233
|
const controlNode = (
|
|
234
234
|
<span
|
|
235
|
+
dir={!labelled && !described ? props.dir : undefined}
|
|
235
236
|
className={cn(
|
|
236
237
|
'relative inline-grid shrink-0',
|
|
237
238
|
indicatorPressClass,
|
|
@@ -273,6 +274,7 @@ export function Radio({
|
|
|
273
274
|
|
|
274
275
|
const row = labelled ? (
|
|
275
276
|
<label
|
|
277
|
+
dir={!described ? props.dir : undefined}
|
|
276
278
|
className={cn(rowClass, !described && parts?.wrapper?.className)}
|
|
277
279
|
style={!described ? parts?.wrapper?.style : undefined}
|
|
278
280
|
data-slot={!described ? 'radio-wrapper' : undefined}
|
|
@@ -294,6 +296,7 @@ export function Radio({
|
|
|
294
296
|
|
|
295
297
|
return (
|
|
296
298
|
<div
|
|
299
|
+
dir={props.dir}
|
|
297
300
|
className={cn('grid min-w-0 max-w-full justify-items-start', parts?.wrapper?.className)}
|
|
298
301
|
style={parts?.wrapper?.style}
|
|
299
302
|
data-slot="radio-wrapper"
|
|
@@ -182,7 +182,8 @@ export function ScrollArea({
|
|
|
182
182
|
})
|
|
183
183
|
}
|
|
184
184
|
const resize = new win.ResizeObserver(schedule),
|
|
185
|
-
mutation = new win.MutationObserver(schedule)
|
|
185
|
+
mutation = new win.MutationObserver(schedule),
|
|
186
|
+
direction = new win.MutationObserver(schedule)
|
|
186
187
|
resize.observe(node)
|
|
187
188
|
resize.observe(body)
|
|
188
189
|
mutation.observe(body, {
|
|
@@ -191,6 +192,8 @@ export function ScrollArea({
|
|
|
191
192
|
characterData: true,
|
|
192
193
|
attributes: true
|
|
193
194
|
})
|
|
195
|
+
for (let ancestor: HTMLElement | null = node; ancestor; ancestor = ancestor.parentElement)
|
|
196
|
+
direction.observe(ancestor, { attributes: true, attributeFilter: ['dir', 'class', 'style'] })
|
|
194
197
|
body.addEventListener('load', schedule, true)
|
|
195
198
|
body.addEventListener('loadedmetadata', schedule, true)
|
|
196
199
|
node.ownerDocument.fonts?.addEventListener('loadingdone', schedule)
|
|
@@ -198,6 +201,7 @@ export function ScrollArea({
|
|
|
198
201
|
return () => {
|
|
199
202
|
resize.disconnect()
|
|
200
203
|
mutation.disconnect()
|
|
204
|
+
direction.disconnect()
|
|
201
205
|
body.removeEventListener('load', schedule, true)
|
|
202
206
|
body.removeEventListener('loadedmetadata', schedule, true)
|
|
203
207
|
node.ownerDocument.fonts?.removeEventListener('loadingdone', schedule)
|
|
@@ -111,6 +111,7 @@ export function Switch({
|
|
|
111
111
|
})
|
|
112
112
|
const controlNode = (
|
|
113
113
|
<span
|
|
114
|
+
dir={!labelled ? props.dir : undefined}
|
|
114
115
|
className={cn('relative inline-grid w-fit shrink-0', !labelled && parts?.wrapper?.className)}
|
|
115
116
|
style={!labelled ? parts?.wrapper?.style : undefined}
|
|
116
117
|
data-slot={!labelled ? 'switch-wrapper' : undefined}
|
|
@@ -163,6 +164,7 @@ export function Switch({
|
|
|
163
164
|
if (!labelled) return controlNode
|
|
164
165
|
return (
|
|
165
166
|
<label
|
|
167
|
+
dir={props.dir}
|
|
166
168
|
className={cn(rowClass, parts?.wrapper?.className)}
|
|
167
169
|
style={parts?.wrapper?.style}
|
|
168
170
|
data-slot="switch-wrapper"
|
|
@@ -5,10 +5,14 @@ import { joinIds } from '../../internal/ids.js'
|
|
|
5
5
|
import type { ThemeStyle } from '../../themes/defineTheme.js'
|
|
6
6
|
import { scrollbarClass } from '../shared/scrollbarStyles.js'
|
|
7
7
|
import { focusRingClass } from '../shared/focusStyles.js'
|
|
8
|
+
import type { Spacing } from '../../presentation.js'
|
|
8
9
|
type Part<
|
|
9
10
|
Host extends 'table' | 'caption' | 'thead' | 'tbody' | 'tfoot' | 'tr' | 'th' | 'td' | 'section'
|
|
10
11
|
> = Omit<ComponentProps<Host>, 'role' | 'style'> & { style?: ThemeStyle; 'data-slot'?: string }
|
|
11
|
-
export type TableProps = Part<'table'>
|
|
12
|
+
export type TableProps = Part<'table'> & {
|
|
13
|
+
/** Step of the cell padding scale; `normal` keeps `--rad-table-padding-inline` and `-block`. */
|
|
14
|
+
density?: Spacing
|
|
15
|
+
}
|
|
12
16
|
export type TableCaptionProps = Part<'caption'>
|
|
13
17
|
export type TableHeadProps = Part<'thead'>
|
|
14
18
|
export type TableBodyProps = Part<'tbody'>
|
|
@@ -21,15 +25,24 @@ export type TableContainerProps = Omit<
|
|
|
21
25
|
'aria-label' | 'aria-labelledby' | 'tabIndex'
|
|
22
26
|
> &
|
|
23
27
|
AccessibleName
|
|
28
|
+
// Density sets a step override and a scale on the table; cells resolve them against their own padding tokens.
|
|
29
|
+
const densityClass: Record<Spacing, string> = {
|
|
30
|
+
tight:
|
|
31
|
+
'[--_rad-table-density:calc(2/3)] [--_rad-table-padding-inline:var(--rad-table-padding-inline-tight)] [--_rad-table-padding-block:var(--rad-table-padding-block-tight)]',
|
|
32
|
+
normal:
|
|
33
|
+
'[--_rad-table-density:initial] [--_rad-table-padding-inline:initial] [--_rad-table-padding-block:initial]',
|
|
34
|
+
airy: '[--_rad-table-density:calc(4/3)] [--_rad-table-padding-inline:var(--rad-table-padding-inline-airy)] [--_rad-table-padding-block:var(--rad-table-padding-block-airy)]'
|
|
35
|
+
}
|
|
24
36
|
const cellClass =
|
|
25
|
-
'px-[var(--rad-table-padding-inline,var(--rad-control-small-padding-inline,0.75rem))] py-[var(--rad-table-padding-block,0.625rem)] text-start align-top [overflow-wrap:anywhere]'
|
|
26
|
-
export function Table({ className, ...props }: TableProps) {
|
|
37
|
+
'px-[var(--_rad-table-padding-inline,calc(var(--_rad-table-density,1)*var(--rad-table-padding-inline,var(--rad-control-small-padding-inline,0.75rem))))] py-[var(--_rad-table-padding-block,calc(var(--_rad-table-density,1)*var(--rad-table-padding-block,0.625rem)))] text-start align-top [overflow-wrap:anywhere]'
|
|
38
|
+
export function Table({ density = 'normal', className, ...props }: TableProps) {
|
|
27
39
|
const nativeProps = { ...props, role: undefined }
|
|
28
40
|
return (
|
|
29
41
|
<table
|
|
30
42
|
{...nativeProps}
|
|
31
43
|
data-slot={joinIds('table', props['data-slot'])}
|
|
32
44
|
className={cn(
|
|
45
|
+
densityClass[density],
|
|
33
46
|
'w-full border-collapse text-start bg-[var(--rad-table-background,var(--rad-color-surface,white))] [color:var(--rad-table-color,var(--rad-color-foreground))] font-[family-name:var(--rad-typography-roles-ui-body-family,system-ui,sans-serif)] text-[length:var(--rad-table-font-size,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)] forced-colors:bg-[Canvas] forced-colors:text-[CanvasText]',
|
|
34
47
|
className
|
|
35
48
|
)}
|
|
@@ -149,7 +149,9 @@ export function TimeInput({
|
|
|
149
149
|
edit({ ...parts, [part]: text })
|
|
150
150
|
if (text.length === 2) {
|
|
151
151
|
const segments = Array.from(
|
|
152
|
-
input
|
|
152
|
+
input
|
|
153
|
+
.closest('[data-slot~="time-input"]')
|
|
154
|
+
?.querySelectorAll<HTMLElement>('[data-segment]') ?? []
|
|
153
155
|
)
|
|
154
156
|
segments[segments.indexOf(input) + 1]?.focus()
|
|
155
157
|
}
|
|
@@ -175,6 +177,84 @@ export function TimeInput({
|
|
|
175
177
|
owner.request(isoTime(next, withSeconds))
|
|
176
178
|
}
|
|
177
179
|
|
|
180
|
+
const isClock = (type: string) => type === 'hour' || type === 'minute' || type === 'second'
|
|
181
|
+
const firstClock = format.parts.findIndex(({ type }) => isClock(type))
|
|
182
|
+
const lastClock = format.parts.reduce(
|
|
183
|
+
(last, part, index) => (isClock(part.type) ? index : last),
|
|
184
|
+
-1
|
|
185
|
+
)
|
|
186
|
+
const renderPart = ({ type: part, value: literal }: Intl.DateTimeFormatPart, index: number) => {
|
|
187
|
+
if (part === 'dayPeriod')
|
|
188
|
+
return (
|
|
189
|
+
<Button
|
|
190
|
+
key={part}
|
|
191
|
+
type="button"
|
|
192
|
+
variant="ghost"
|
|
193
|
+
tone="neutral"
|
|
194
|
+
motion="off"
|
|
195
|
+
data-slot="time-input-period"
|
|
196
|
+
data-segment={part}
|
|
197
|
+
aria-label={[format.names.of(part), format[parts.dayPeriod]].filter(Boolean).join(' ')}
|
|
198
|
+
aria-describedby={control['aria-describedby']}
|
|
199
|
+
controlSize={controlSize}
|
|
200
|
+
disabled={control.disabled || readOnly}
|
|
201
|
+
onClick={togglePeriod}
|
|
202
|
+
onKeyDown={event => {
|
|
203
|
+
if (event.altKey || event.metaKey || event.ctrlKey || event.defaultPrevented) return
|
|
204
|
+
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
|
|
205
|
+
event.preventDefault()
|
|
206
|
+
togglePeriod()
|
|
207
|
+
}
|
|
208
|
+
}}
|
|
209
|
+
className={cn(
|
|
210
|
+
inlineActionClass,
|
|
211
|
+
focusRingInsetClass,
|
|
212
|
+
'min-h-[max(1.5rem,calc(var(--_rad-control-height)-0.75rem))] min-w-6 [--rad-button-border-width:0px] px-1 leading-none',
|
|
213
|
+
'text-[color:var(--rad-time-input-period-color,var(--rad-color-foreground))] underline decoration-dotted decoration-[color:var(--rad-time-input-period-indicator-color,var(--rad-color-muted-foreground))] underline-offset-4 enabled:hover:decoration-solid disabled:no-underline'
|
|
214
|
+
)}
|
|
215
|
+
>
|
|
216
|
+
{format[parts.dayPeriod]}
|
|
217
|
+
</Button>
|
|
218
|
+
)
|
|
219
|
+
if (part !== 'hour' && part !== 'minute' && part !== 'second')
|
|
220
|
+
return (
|
|
221
|
+
<span
|
|
222
|
+
key={index}
|
|
223
|
+
aria-hidden="true"
|
|
224
|
+
>
|
|
225
|
+
{literal}
|
|
226
|
+
</span>
|
|
227
|
+
)
|
|
228
|
+
return (
|
|
229
|
+
<InputGroupInput
|
|
230
|
+
key={part}
|
|
231
|
+
data-segment={part}
|
|
232
|
+
// oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- Localized digits need text entry with per-segment spinbutton semantics.
|
|
233
|
+
role="spinbutton"
|
|
234
|
+
aria-valuemin={part === 'hour' ? format.hourMin : 0}
|
|
235
|
+
aria-valuemax={part === 'hour' ? format.hourMax : 59}
|
|
236
|
+
aria-valuenow={parts[part] ? Number(parts[part]) : undefined}
|
|
237
|
+
ref={part === 'hour' ? editorRef : undefined}
|
|
238
|
+
id={part === 'hour' ? control.id : undefined}
|
|
239
|
+
form={form}
|
|
240
|
+
disabled={control.disabled}
|
|
241
|
+
readOnly={readOnly}
|
|
242
|
+
required={control.required}
|
|
243
|
+
aria-label={format.names.of(part)}
|
|
244
|
+
aria-describedby={control['aria-describedby']}
|
|
245
|
+
aria-invalid={invalid || control['aria-invalid'] || undefined}
|
|
246
|
+
placeholder="––"
|
|
247
|
+
autoComplete="off"
|
|
248
|
+
inputMode="numeric"
|
|
249
|
+
className="w-[2.7ch] flex-none text-center tabular-nums focus-visible:underline"
|
|
250
|
+
value={format.localize(parts[part])}
|
|
251
|
+
onFocus={event => event.currentTarget.select()}
|
|
252
|
+
onChange={event => editNumber(part, event.currentTarget)}
|
|
253
|
+
onKeyDown={event => advance(event, part)}
|
|
254
|
+
/>
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
|
|
178
258
|
return (
|
|
179
259
|
<InputGroup
|
|
180
260
|
data-slot="time-input"
|
|
@@ -187,80 +267,25 @@ export function TimeInput({
|
|
|
187
267
|
style={style}
|
|
188
268
|
>
|
|
189
269
|
<WithoutField>
|
|
190
|
-
{
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (event.altKey || event.metaKey || event.ctrlKey || event.defaultPrevented)
|
|
210
|
-
return
|
|
211
|
-
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
|
|
212
|
-
event.preventDefault()
|
|
213
|
-
togglePeriod()
|
|
214
|
-
}
|
|
215
|
-
}}
|
|
216
|
-
className={cn(
|
|
217
|
-
inlineActionClass,
|
|
218
|
-
focusRingInsetClass,
|
|
219
|
-
'min-h-[max(1.5rem,calc(var(--_rad-control-height)-0.75rem))] min-w-6 [--rad-button-border-width:0px] px-1 leading-none',
|
|
220
|
-
'text-[color:var(--rad-time-input-period-color,var(--rad-color-foreground))] underline decoration-dotted decoration-[color:var(--rad-time-input-period-indicator-color,var(--rad-color-muted-foreground))] underline-offset-4 enabled:hover:decoration-solid disabled:no-underline'
|
|
221
|
-
)}
|
|
222
|
-
>
|
|
223
|
-
{format[parts.dayPeriod]}
|
|
224
|
-
</Button>
|
|
225
|
-
)
|
|
226
|
-
if (part !== 'hour' && part !== 'minute' && part !== 'second')
|
|
227
|
-
return (
|
|
228
|
-
<span
|
|
229
|
-
key={index}
|
|
230
|
-
aria-hidden="true"
|
|
231
|
-
>
|
|
232
|
-
{literal}
|
|
233
|
-
</span>
|
|
234
|
-
)
|
|
235
|
-
return (
|
|
236
|
-
<InputGroupInput
|
|
237
|
-
key={part}
|
|
238
|
-
data-segment={part}
|
|
239
|
-
// oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- Localized digits need text entry with per-segment spinbutton semantics.
|
|
240
|
-
role="spinbutton"
|
|
241
|
-
aria-valuemin={part === 'hour' ? format.hourMin : 0}
|
|
242
|
-
aria-valuemax={part === 'hour' ? format.hourMax : 59}
|
|
243
|
-
aria-valuenow={parts[part] ? Number(parts[part]) : undefined}
|
|
244
|
-
ref={part === 'hour' ? editorRef : undefined}
|
|
245
|
-
id={part === 'hour' ? control.id : undefined}
|
|
246
|
-
form={form}
|
|
247
|
-
disabled={control.disabled}
|
|
248
|
-
readOnly={readOnly}
|
|
249
|
-
required={control.required}
|
|
250
|
-
aria-label={format.names.of(part)}
|
|
251
|
-
aria-describedby={control['aria-describedby']}
|
|
252
|
-
aria-invalid={invalid || control['aria-invalid'] || undefined}
|
|
253
|
-
placeholder="––"
|
|
254
|
-
autoComplete="off"
|
|
255
|
-
inputMode="numeric"
|
|
256
|
-
className="w-[2.7ch] flex-none text-center tabular-nums focus-visible:underline"
|
|
257
|
-
value={format.localize(parts[part])}
|
|
258
|
-
onFocus={event => event.currentTarget.select()}
|
|
259
|
-
onChange={event => editNumber(part, event.currentTarget)}
|
|
260
|
-
onKeyDown={event => advance(event, part)}
|
|
261
|
-
/>
|
|
262
|
-
)
|
|
263
|
-
})}
|
|
270
|
+
{firstClock >= 0 ? (
|
|
271
|
+
<>
|
|
272
|
+
{format.parts.slice(0, firstClock).map((part, index) => renderPart(part, index))}
|
|
273
|
+
<span
|
|
274
|
+
dir="ltr"
|
|
275
|
+
data-slot="time-input-clock"
|
|
276
|
+
className="inline-flex items-center"
|
|
277
|
+
>
|
|
278
|
+
{format.parts
|
|
279
|
+
.slice(firstClock, lastClock + 1)
|
|
280
|
+
.map((part, offset) => renderPart(part, firstClock + offset))}
|
|
281
|
+
</span>
|
|
282
|
+
{format.parts
|
|
283
|
+
.slice(lastClock + 1)
|
|
284
|
+
.map((part, offset) => renderPart(part, lastClock + 1 + offset))}
|
|
285
|
+
</>
|
|
286
|
+
) : (
|
|
287
|
+
format.parts.map(renderPart)
|
|
288
|
+
)}
|
|
264
289
|
</WithoutField>
|
|
265
290
|
<input
|
|
266
291
|
type="hidden"
|
|
@@ -401,7 +401,7 @@ export function ToastViewport({ hotkey = true, ref, className, ...props }: Toast
|
|
|
401
401
|
tabIndex={-1}
|
|
402
402
|
data-slot={joinIds('toast-viewport', props['data-slot'])}
|
|
403
403
|
className={cn(
|
|
404
|
-
'pointer-events-none fixed
|
|
404
|
+
'pointer-events-none fixed end-[var(--rad-toast-inset,1rem)] bottom-[var(--rad-toast-inset,1rem)] z-[var(--rad-toast-z-index,50)] grid min-w-0 w-[var(--rad-toast-width,24rem)] max-w-[calc(100vw-2rem)] max-h-[calc(100dvh-2rem)] overflow-visible',
|
|
405
405
|
className
|
|
406
406
|
)}
|
|
407
407
|
/>
|
|
@@ -331,7 +331,7 @@ function Indicator({
|
|
|
331
331
|
attributeFilter: ['aria-pressed', 'class', 'style', 'hidden', 'dir']
|
|
332
332
|
})
|
|
333
333
|
for (let parent = root.parentElement; parent; parent = parent.parentElement)
|
|
334
|
-
changes.observe(parent, { attributes: true, attributeFilter: ['dir'] })
|
|
334
|
+
changes.observe(parent, { attributes: true, attributeFilter: ['dir', 'class', 'style'] })
|
|
335
335
|
observe()
|
|
336
336
|
measure()
|
|
337
337
|
view.addEventListener('resize', schedule)
|
package/src/index.ts
CHANGED
|
@@ -265,7 +265,7 @@ export { getLocaleAttributes } from './internal/locale.js'
|
|
|
265
265
|
export type { ButtonProps, ButtonRenderProps, ButtonVariant } from './components/Button/Button.js'
|
|
266
266
|
export { generateTypography, typographyPresets, typographyRoles } from './typography/index.js'
|
|
267
267
|
export type * from './typography/types.js'
|
|
268
|
-
export type { ControlSize, Orientation, Tone } from './presentation.js'
|
|
268
|
+
export type { ControlSize, Orientation, Spacing, Tone } from './presentation.js'
|
|
269
269
|
|
|
270
270
|
export {
|
|
271
271
|
defineThemeDocument,
|
package/src/presentation.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CatalogSpacing } from './catalog/types.js'
|
|
1
2
|
import type { VariantProps } from 'class-variance-authority'
|
|
2
3
|
import type { actionVariants } from './components/shared/actionStyles.js'
|
|
3
4
|
import type { ThemeStyle } from './themes/defineTheme.js'
|
|
@@ -7,6 +8,8 @@ type ActionPresentation = VariantProps<typeof actionVariants>
|
|
|
7
8
|
export type ButtonVariant = NonNullable<ActionPresentation['variant']>
|
|
8
9
|
export type Tone = NonNullable<ActionPresentation['tone']>
|
|
9
10
|
export type ControlSize = 'small' | 'medium' | 'large'
|
|
11
|
+
/** Steps of the theme spacing scale: `tight`, `normal` (the default) and `airy`. */
|
|
12
|
+
export type Spacing = CatalogSpacing
|
|
10
13
|
export type Orientation = 'horizontal' | 'vertical'
|
|
11
14
|
|
|
12
15
|
export type PartStyle = { className?: string; style?: ThemeStyle }
|
package/src/themes/baseline.css
CHANGED
|
@@ -241,6 +241,9 @@
|
|
|
241
241
|
--rad-motion-press-shift-x: 0px;
|
|
242
242
|
--rad-motion-press-shift-y: 0px;
|
|
243
243
|
--rad-motion-hover-lift: 0px;
|
|
244
|
+
--rad-spacing-tight: 0.5rem;
|
|
245
|
+
--rad-spacing-normal: 1rem;
|
|
246
|
+
--rad-spacing-airy: 1.5rem;
|
|
244
247
|
--rad-spacing-label-gap: 0.5rem;
|
|
245
248
|
--rad-spacing-field-gap: 0.375rem;
|
|
246
249
|
--rad-spacing-group-gap: 0.75rem;
|
package/src/themes/components.ts
CHANGED
|
@@ -576,6 +576,8 @@ export const componentRegistry = {
|
|
|
576
576
|
borderStyle: 'css',
|
|
577
577
|
borderColor: 'css',
|
|
578
578
|
padding: 'css',
|
|
579
|
+
paddingTight: 'css',
|
|
580
|
+
paddingAiry: 'css',
|
|
579
581
|
gap: 'css',
|
|
580
582
|
headerGap: 'css',
|
|
581
583
|
footerGap: 'css',
|
|
@@ -703,6 +705,10 @@ export const componentRegistry = {
|
|
|
703
705
|
shadow: 'css',
|
|
704
706
|
paddingInline: 'css',
|
|
705
707
|
paddingBlock: 'css',
|
|
708
|
+
paddingInlineTight: 'css',
|
|
709
|
+
paddingBlockTight: 'css',
|
|
710
|
+
paddingInlineAiry: 'css',
|
|
711
|
+
paddingBlockAiry: 'css',
|
|
706
712
|
fontSize: 'css'
|
|
707
713
|
},
|
|
708
714
|
fieldset: { gap: 'css' },
|
package/src/themes/tokens.ts
CHANGED
|
@@ -175,7 +175,11 @@ export interface SharedTokens {
|
|
|
175
175
|
pressShiftY: string
|
|
176
176
|
hoverLift: string
|
|
177
177
|
}
|
|
178
|
+
/** `tight`, `normal` and `airy` form the semantic gap scale; the role-named gaps stay independent. */
|
|
178
179
|
spacing: {
|
|
180
|
+
tight: string
|
|
181
|
+
normal: string
|
|
182
|
+
airy: string
|
|
179
183
|
labelGap: string
|
|
180
184
|
fieldGap: string
|
|
181
185
|
groupGap: string
|
|
@@ -360,6 +364,9 @@ const light: SharedTokens = {
|
|
|
360
364
|
hoverLift: '0px'
|
|
361
365
|
},
|
|
362
366
|
spacing: {
|
|
367
|
+
tight: '0.5rem',
|
|
368
|
+
normal: '1rem',
|
|
369
|
+
airy: '1.5rem',
|
|
363
370
|
labelGap: '0.5rem',
|
|
364
371
|
fieldGap: '0.375rem',
|
|
365
372
|
groupGap: '0.75rem',
|