@cognitap/radiant 0.0.65 → 0.0.67

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.
Files changed (75) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/library/AppShell.d.ts +71 -0
  3. package/dist/library/AppShell.d.ts.map +1 -0
  4. package/dist/library/AppShell.js +189 -0
  5. package/dist/library/AppShell.js.map +1 -0
  6. package/dist/library/Button.d.ts +2 -7
  7. package/dist/library/Button.d.ts.map +1 -1
  8. package/dist/library/Button.js.map +1 -1
  9. package/dist/library/ButtonGroup.d.ts +4 -1
  10. package/dist/library/ButtonGroup.d.ts.map +1 -1
  11. package/dist/library/ButtonGroup.js +2 -1
  12. package/dist/library/ButtonGroup.js.map +1 -1
  13. package/dist/library/CheckboxGroup.d.ts +6 -4
  14. package/dist/library/CheckboxGroup.d.ts.map +1 -1
  15. package/dist/library/CheckboxGroup.js +17 -21
  16. package/dist/library/CheckboxGroup.js.map +1 -1
  17. package/dist/library/Command.d.ts +1 -2
  18. package/dist/library/Command.d.ts.map +1 -1
  19. package/dist/library/Command.js +1 -1
  20. package/dist/library/Command.js.map +1 -1
  21. package/dist/library/Drawer.d.ts +8 -17
  22. package/dist/library/Drawer.d.ts.map +1 -1
  23. package/dist/library/Drawer.js +2 -2
  24. package/dist/library/Drawer.js.map +1 -1
  25. package/dist/library/Field.d.ts.map +1 -1
  26. package/dist/library/Field.js +1 -1
  27. package/dist/library/Field.js.map +1 -1
  28. package/dist/library/PasswordInput.d.ts.map +1 -1
  29. package/dist/library/PasswordInput.js +1 -1
  30. package/dist/library/PasswordInput.js.map +1 -1
  31. package/dist/library/ScrollArea.d.ts +2 -2
  32. package/dist/library/ScrollArea.d.ts.map +1 -1
  33. package/dist/library/cn.d.ts.map +1 -1
  34. package/dist/library/cn.js +10 -0
  35. package/dist/library/cn.js.map +1 -1
  36. package/dist/library/index.d.ts +2 -0
  37. package/dist/library/index.d.ts.map +1 -1
  38. package/dist/library/index.js +1 -0
  39. package/dist/library/index.js.map +1 -1
  40. package/dist/library/motion/host.d.ts +2 -1
  41. package/dist/library/motion/host.d.ts.map +1 -1
  42. package/dist/library/motion/host.js.map +1 -1
  43. package/dist/library/motion/layoutHost.d.ts +5 -0
  44. package/dist/library/motion/layoutHost.d.ts.map +1 -0
  45. package/dist/library/motion/layoutHost.js +24 -0
  46. package/dist/library/motion/layoutHost.js.map +1 -0
  47. package/dist/library/motion/press.d.ts.map +1 -1
  48. package/dist/library/motion/press.js +6 -5
  49. package/dist/library/motion/press.js.map +1 -1
  50. package/dist/library/motion/react.d.ts.map +1 -1
  51. package/dist/library/motion/react.js +3 -1
  52. package/dist/library/motion/react.js.map +1 -1
  53. package/dist/library/styles.css +1 -1
  54. package/dist/library/themes/components.d.ts +22 -0
  55. package/dist/library/themes/components.d.ts.map +1 -1
  56. package/dist/library/themes/components.js +22 -0
  57. package/dist/library/themes/components.js.map +1 -1
  58. package/docs/architecture.md +10 -7
  59. package/package.json +1 -1
  60. package/src/AppShell.tsx +517 -0
  61. package/src/Button.tsx +2 -4
  62. package/src/ButtonGroup.tsx +6 -2
  63. package/src/CheckboxGroup.tsx +33 -25
  64. package/src/Command.tsx +2 -13
  65. package/src/Drawer.tsx +10 -14
  66. package/src/Field.tsx +5 -1
  67. package/src/PasswordInput.tsx +1 -2
  68. package/src/ScrollArea.tsx +3 -3
  69. package/src/cn.ts +10 -0
  70. package/src/index.ts +26 -0
  71. package/src/motion/host.ts +2 -1
  72. package/src/motion/layoutHost.ts +25 -0
  73. package/src/motion/press.ts +6 -5
  74. package/src/motion/react.ts +3 -1
  75. package/src/themes/components.ts +22 -0
package/src/Command.tsx CHANGED
@@ -29,7 +29,6 @@ import {
29
29
  type ComboboxItemProps
30
30
  } from './Combobox.js'
31
31
  import type { StateOwner } from './react/useNativeOwner.js'
32
- import type { DistributiveOmit } from './internal/types.js'
33
32
  import { requireAccessibleName, type AccessibleName } from './internal/accessibleName.js'
34
33
  import { WithoutField } from './Field.js'
35
34
  import { Kbd, KbdGroup } from './Kbd.js'
@@ -53,10 +52,7 @@ export type CommandProps = DialogProps &
53
52
  controlSize?: ControlSize
54
53
  }
55
54
  export type CommandRenderProps = DialogRenderProps
56
- export type CommandTriggerProps = DistributiveOmit<
57
- DialogTriggerProps,
58
- 'pressed' | 'defaultPressed' | 'onPressedChange'
59
- >
55
+ export type CommandTriggerProps = DialogTriggerProps
60
56
  export type CommandCloseProps = DialogTriggerProps
61
57
  export type CommandContentProps = DialogContentProps
62
58
  export type CommandTitleProps = DialogTitleProps
@@ -187,14 +183,7 @@ function CommandResults({
187
183
  }
188
184
  export function CommandTrigger(props: CommandTriggerProps) {
189
185
  useCommandContext()
190
- return (
191
- <DialogTrigger
192
- {...props}
193
- pressed={undefined}
194
- defaultPressed={undefined}
195
- onPressedChange={undefined}
196
- />
197
- )
186
+ return <DialogTrigger {...props} />
198
187
  }
199
188
  export function CommandClose(props: CommandCloseProps) {
200
189
  useCommandContext()
package/src/Drawer.tsx CHANGED
@@ -21,27 +21,25 @@ import {
21
21
  } from './Dialog.js'
22
22
  import { cn } from './cn.js'
23
23
  import { composeAction } from './internal/events.js'
24
- import { requireAccessibleName } from './internal/accessibleName.js'
24
+ import { requireAccessibleName, type AccessibleName } from './internal/accessibleName.js'
25
25
  import { joinIds } from './internal/ids.js'
26
26
  import { drawerPoints, type DrawerSide } from './internal/drawer.js'
27
27
  import { useControllableState } from './react/useControllableState.js'
28
28
  import { useDrawerHost } from './motion/host.js'
29
- import type { ThemeStyle } from './themes/defineTheme.js'
29
+ import type { PartStyle } from './presentation.js'
30
+ import type { StateOwner } from './react/useNativeOwner.js'
30
31
 
31
32
  export type { DrawerSide } from './internal/drawer.js'
32
33
  export type DrawerProps = DialogProps &
33
- (
34
- | { snapPoint: number; defaultSnapPoint?: never }
35
- | { snapPoint?: undefined; defaultSnapPoint?: number }
36
- ) & {
34
+ StateOwner<'snapPoint', number> & {
37
35
  /** Distinct visible fractions of Content's maximum size, in (0, 1]. Zero is dismissal. */
38
36
  snapPoints?: readonly number[]
39
- onSnapPointChange?: (point: number) => void
37
+ onSnapPointChange?: (snapPoint: number) => void
40
38
  }
41
39
  export type DrawerState = DialogState & {
42
40
  snapPoint: number
43
41
  snapPoints: readonly number[]
44
- setSnapPoint(point: number): void
42
+ setSnapPoint(snapPoint: number): void
45
43
  snapControlled: boolean
46
44
  }
47
45
  export type DrawerTriggerProps = DialogTriggerProps
@@ -52,7 +50,7 @@ export type DrawerDescriptionProps = DialogDescriptionProps
52
50
  export type DrawerContentProps = DialogContentProps & {
53
51
  side?: DrawerSide
54
52
  /** The native scrolling area inside the actual dialog. */
55
- parts?: { viewport?: { className?: string; style?: ThemeStyle } }
53
+ parts?: { viewport?: PartStyle }
56
54
  }
57
55
  export type DrawerHandleProps = Omit<
58
56
  ButtonProps,
@@ -65,9 +63,8 @@ export type DrawerHandleProps = Omit<
65
63
  | 'aria-pressed'
66
64
  | 'type'
67
65
  | 'motion'
68
- > & {
69
- 'aria-label': string
70
- }
66
+ > &
67
+ AccessibleName
71
68
  type SnapState = Pick<DrawerState, 'snapPoint' | 'snapPoints' | 'setSnapPoint' | 'snapControlled'>
72
69
  const SnapContext = createContext<SnapState | null>(null)
73
70
  const defaults = [0.5, 1] as const
@@ -198,7 +195,7 @@ export function DrawerHandle({ className, onClick, onKeyDown, ...props }: Drawer
198
195
  const state = useDrawerContext(),
199
196
  descriptionId = useId()
200
197
  const points = state.snapPoints
201
- requireAccessibleName('DrawerHandle', { 'aria-label': props['aria-label'] })
198
+ requireAccessibleName('DrawerHandle', props)
202
199
  const choose = (direction: -1 | 1 | 'first' | 'last') => {
203
200
  const target =
204
201
  direction === 'first'
@@ -221,7 +218,6 @@ export function DrawerHandle({ className, onClick, onKeyDown, ...props }: Drawer
221
218
  defaultPressed={undefined}
222
219
  onPressedChange={undefined}
223
220
  aria-pressed={undefined}
224
- aria-labelledby={undefined}
225
221
  variant={props.variant ?? 'ghost'}
226
222
  tone={props.tone ?? 'neutral'}
227
223
  className={cn(
package/src/Field.tsx CHANGED
@@ -239,7 +239,11 @@ export function Field(props: FieldProps) {
239
239
  <>
240
240
  {layout === 'group' ? (
241
241
  <legend
242
- className={cn(labelClass, parts?.label?.className)}
242
+ className={cn(
243
+ labelClass,
244
+ 'mb-[var(--rad-fieldset-gap,var(--rad-spacing-group-gap,0.75rem))]',
245
+ parts?.label?.className
246
+ )}
243
247
  style={parts?.label?.style}
244
248
  data-slot="field-label"
245
249
  id={labelId}
@@ -99,8 +99,7 @@ export function PasswordInput({
99
99
  tone="neutral"
100
100
  motion="off"
101
101
  controlSize={controlSize}
102
- pressed={shown}
103
- onPressedChange={setVisible}
102
+ onClick={() => setVisible(current => !current)}
104
103
  disabled={control.disabled}
105
104
  aria-controls={control.id}
106
105
  data-slot="password-input-toggle"
@@ -16,10 +16,10 @@ import { requireAccessibleName, type AccessibleName } from './internal/accessibl
16
16
  import { cn } from './cn.js'
17
17
  import { joinIds } from './internal/ids.js'
18
18
  import { useComposedRefs } from './react/useComposedRefs.js'
19
- import type { PartStyle } from './presentation.js'
19
+ import type { Orientation, PartStyle } from './presentation.js'
20
20
  import type { ThemeStyle } from './themes/defineTheme.js'
21
21
 
22
- export type ScrollAreaOrientation = 'vertical' | 'horizontal' | 'both'
22
+ export type ScrollAreaOrientation = Orientation | 'both'
23
23
  export type ScrollAreaVisibility = 'hover' | 'scroll' | 'always'
24
24
 
25
25
  export type ScrollAreaProps = Omit<
@@ -33,7 +33,7 @@ export type ScrollAreaProps = Omit<
33
33
  parts?: { content?: PartStyle; scrollbar?: PartStyle; thumb?: PartStyle }
34
34
  'data-slot'?: string
35
35
  }
36
- type Axis = 'vertical' | 'horizontal'
36
+ type Axis = Orientation
37
37
  type Metrics = {
38
38
  width: number
39
39
  height: number
package/src/cn.ts CHANGED
@@ -9,7 +9,9 @@ const roleClasses = (prefix: string, leaf: string) =>
9
9
  export const cn: CnFunction = createCn({
10
10
  extend: {
11
11
  classGroups: {
12
+ 'border-w-e': ['border-e-(--rad-sidebar-border-width)'],
12
13
  'border-w-b': [
14
+ 'border-b-(--rad-app-shell-header-border-width)',
13
15
  'border-b-(--rad-code-block-border-width)',
14
16
  'border-b-(--rad-table-border-width)'
15
17
  ],
@@ -43,6 +45,7 @@ export const cn: CnFunction = createCn({
43
45
  'font-(--rad-tabs-font-weight)'
44
46
  ],
45
47
  'font-size': [
48
+ 'text-(--rad-sidebar-label-size)',
46
49
  'text-(--rad-inline-code-font-size)',
47
50
  'text-(--rad-code-block-font-size)',
48
51
  'text-(--rad-empty-state-title-size)',
@@ -83,6 +86,8 @@ export const cn: CnFunction = createCn({
83
86
  'h-(--rad-slider-length)'
84
87
  ],
85
88
  w: [
89
+ 'w-(--rad-sidebar-width)',
90
+ 'w-(--rad-sidebar-collapsed-width)',
86
91
  'w-(--rad-resizable-handle-size)',
87
92
  'w-(--rad-otp-field-slot-size)',
88
93
  'w-(--rad-drawer-size)',
@@ -113,6 +118,7 @@ export const cn: CnFunction = createCn({
113
118
  ],
114
119
  mb: ['mb-(--rad-multi-select-gap)', 'mb-(--rad-fieldset-gap)'],
115
120
  gap: [
121
+ 'gap-(--rad-sidebar-gap)',
116
122
  'gap-(--rad-navigation-menu-gap)',
117
123
  'gap-(--rad-code-block-header-gap)',
118
124
  'gap-(--rad-empty-state-gap)',
@@ -141,6 +147,7 @@ export const cn: CnFunction = createCn({
141
147
  'gap-(--rad-tabs-list-gap)'
142
148
  ],
143
149
  'min-h': [
150
+ 'min-h-(--rad-app-shell-header-min-height)',
144
151
  'min-h-(--rad-native-select-height)',
145
152
  'min-h-(--rad-textarea-min-height)',
146
153
  'min-h-(--rad-tabs-trigger-height)'
@@ -169,6 +176,9 @@ export const cn: CnFunction = createCn({
169
176
  'px-(--rad-tabs-trigger-padding)'
170
177
  ],
171
178
  p: [
179
+ 'p-(--rad-app-shell-header-padding)',
180
+ 'p-(--rad-app-shell-main-padding)',
181
+ 'p-(--rad-sidebar-padding)',
172
182
  'p-(--rad-navigation-menu-padding)',
173
183
  'p-(--rad-code-block-padding)',
174
184
  'p-(--rad-code-block-header-padding)',
package/src/index.ts CHANGED
@@ -712,3 +712,29 @@ export type {
712
712
  NavigationMenuRenderProps,
713
713
  NavigationMenuLinkRenderProps
714
714
  } from './NavigationMenu.js'
715
+
716
+ export {
717
+ AppShell,
718
+ AppShellHeader,
719
+ AppShellMain,
720
+ AppShellSkipLink,
721
+ Sidebar,
722
+ SidebarTrigger,
723
+ SidebarLabel,
724
+ SidebarContent,
725
+ useAppShell,
726
+ useSidebar
727
+ } from './AppShell.js'
728
+ export type {
729
+ AppShellProps,
730
+ AppShellState,
731
+ AppShellHeaderProps,
732
+ AppShellMainProps,
733
+ AppShellSkipLinkProps,
734
+ AppShellRenderProps,
735
+ SidebarProps,
736
+ SidebarTriggerProps,
737
+ SidebarRenderProps,
738
+ SidebarLabelProps,
739
+ SidebarContentProps
740
+ } from './AppShell.js'
@@ -21,6 +21,7 @@ export interface MotionHostRuntime {
21
21
  disclosure?(node: HTMLElement, profile: MotionProfile): MotionHostBinding
22
22
  dialog?(node: HTMLElement, profile: MotionProfile): MotionHostBinding
23
23
  popup?(node: HTMLElement, profile: MotionProfile): MotionHostBinding
24
+ layout?(node: HTMLElement, profile: MotionProfile): MotionHostBinding
24
25
  indicator?(node: HTMLElement, profile: MotionProfile): MotionHostBinding
25
26
  }
26
27
  export const MotionHostContext = createContext<MotionHostRuntime | null>(null)
@@ -104,7 +105,7 @@ export function usePressHost<Node extends HTMLElement>(
104
105
 
105
106
  /** Shared lifecycle for native presentation adapters; no engine enters the root path. */
106
107
  export function useTransitionHost<Node extends HTMLElement>(
107
- kind: 'disclosure' | 'dialog' | 'popup' | 'indicator',
108
+ kind: 'disclosure' | 'dialog' | 'popup' | 'indicator' | 'layout',
108
109
  ref: Ref<Node> | undefined,
109
110
  disabled: boolean
110
111
  ) {
@@ -0,0 +1,25 @@
1
+ import { bindSpringLayout } from './layoutDom.js'
2
+ import { resolveMotion, type MotionProfile } from './config.js'
3
+ import type { MotionHostBinding } from './host.js'
4
+ /** The optional host bridge shares the public layout adapter and its property leases. */
5
+ export function bindLayoutMotion(node: HTMLElement, initial: MotionProfile): MotionHostBinding {
6
+ const view = node.ownerDocument.defaultView!,
7
+ query = view.matchMedia('(prefers-reduced-motion: reduce)')
8
+ let profile = initial
9
+ const controller = bindSpringLayout(node, resolveMotion(profile, 'layout', query.matches))
10
+ const sync = () => {
11
+ controller.configure(resolveMotion(profile, 'layout', query.matches))
12
+ controller.measure()
13
+ }
14
+ query.addEventListener('change', sync)
15
+ return {
16
+ update(next) {
17
+ profile = next
18
+ sync()
19
+ },
20
+ destroy() {
21
+ query.removeEventListener('change', sync)
22
+ controller.destroy()
23
+ }
24
+ }
25
+ }
@@ -9,7 +9,8 @@ export function bindPressMotion(
9
9
  initialProfile: MotionProfile
10
10
  ): MotionHostBinding {
11
11
  let profile = initialProfile
12
- const query = node.ownerDocument.defaultView!.matchMedia('(prefers-reduced-motion: reduce)')
12
+ const view = node.ownerDocument.defaultView!
13
+ const query = view.matchMedia('(prefers-reduced-motion: reduce)')
13
14
  const spring = createSpring(1, {
14
15
  ...resolveMotion(profile, 'press', query.matches),
15
16
  reducedValue: 1
@@ -43,7 +44,7 @@ export function bindPressMotion(
43
44
  }
44
45
  const changed = () => update(profile)
45
46
  query.addEventListener('change', changed)
46
- const observer = new MutationObserver(() => {
47
+ const observer = new view.MutationObserver(() => {
47
48
  if (blocked()) reset()
48
49
  })
49
50
  observer.observe(node, {
@@ -59,7 +60,7 @@ export function bindPressMotion(
59
60
  document.addEventListener('pointercancel', release)
60
61
  document.addEventListener('keyup', release)
61
62
  const blur = () => release()
62
- document.defaultView!.addEventListener('blur', blur)
63
+ view.addEventListener('blur', blur)
63
64
  return {
64
65
  update,
65
66
  press(event) {
@@ -78,7 +79,7 @@ export function bindPressMotion(
78
79
  pressed = { pointerId: event.pointerId }
79
80
  }
80
81
  const scale = Number(
81
- getComputedStyle(node).getPropertyValue('--rad-button-press-scale').trim() || '.97'
82
+ view.getComputedStyle(node).getPropertyValue('--rad-button-press-scale').trim() || '.97'
82
83
  )
83
84
  spring.to(Number.isFinite(scale) && scale >= 0.5 && scale <= 1 ? scale : 0.97)
84
85
  },
@@ -89,7 +90,7 @@ export function bindPressMotion(
89
90
  document.removeEventListener('pointerup', release)
90
91
  document.removeEventListener('pointercancel', release)
91
92
  document.removeEventListener('keyup', release)
92
- document.defaultView!.removeEventListener('blur', blur)
93
+ view.removeEventListener('blur', blur)
93
94
  spring.destroy()
94
95
  unbind()
95
96
  }
@@ -14,6 +14,7 @@ import { bindDisclosureMotion, bindDialogMotion } from './transitions.js'
14
14
  import { bindPressMotion } from './press.js'
15
15
  import { bindPopupMotion } from './popup.js'
16
16
  import { bindIndicatorMotion } from './indicator.js'
17
+ import { bindLayoutMotion } from './layoutHost.js'
17
18
  import { bindDrawerMotion } from './drawer.js'
18
19
  import { MotionProfileContext } from './context.js'
19
20
  import { resolveMotion, type MotionInteraction } from './config.js'
@@ -140,7 +141,8 @@ const hostRuntime = {
140
141
  disclosure: bindDisclosureMotion,
141
142
  dialog: bindDialogMotion,
142
143
  popup: bindPopupMotion,
143
- indicator: bindIndicatorMotion
144
+ indicator: bindIndicatorMotion,
145
+ layout: bindLayoutMotion
144
146
  }
145
147
  /** Opt into native Radiant spring interactions without adding a DOM wrapper. */
146
148
  export function MotionProvider({ children }: { children?: ReactNode }) {
@@ -73,6 +73,28 @@ export const componentRegistry = {
73
73
  color: 'css',
74
74
  shadow: 'css'
75
75
  },
76
+ appShell: {
77
+ background: 'css',
78
+ color: 'css',
79
+ headerBackground: 'css',
80
+ headerColor: 'css',
81
+ headerPadding: 'css',
82
+ headerMinHeight: 'css',
83
+ headerBorderColor: 'css',
84
+ headerBorderWidth: 'css',
85
+ mainPadding: 'css'
86
+ },
87
+ sidebar: {
88
+ width: 'css',
89
+ collapsedWidth: 'css',
90
+ background: 'css',
91
+ color: 'css',
92
+ padding: 'css',
93
+ gap: 'css',
94
+ borderColor: 'css',
95
+ borderWidth: 'css',
96
+ labelSize: 'css'
97
+ },
76
98
  resizable: {
77
99
  handleSize: 'css',
78
100
  handleColor: 'css',