@cognitap/radiant 0.0.17 → 0.0.18

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 (105) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/dist/library/Accordion.js.map +1 -1
  3. package/dist/library/Alert.d.ts +37 -0
  4. package/dist/library/Alert.d.ts.map +1 -0
  5. package/dist/library/Alert.js +28 -0
  6. package/dist/library/Alert.js.map +1 -0
  7. package/dist/library/AlertDialog.js.map +1 -1
  8. package/dist/library/Button.js.map +1 -1
  9. package/dist/library/Card.js.map +1 -1
  10. package/dist/library/Checkbox.js.map +1 -1
  11. package/dist/library/Collapsible.js.map +1 -1
  12. package/dist/library/Combobox.js.map +1 -1
  13. package/dist/library/Dialog.js.map +1 -1
  14. package/dist/library/Field.js.map +1 -1
  15. package/dist/library/Input.js.map +1 -1
  16. package/dist/library/Link.js.map +1 -1
  17. package/dist/library/Menu.js.map +1 -1
  18. package/dist/library/Popover.js.map +1 -1
  19. package/dist/library/RadioGroup.js.map +1 -1
  20. package/dist/library/Select.js.map +1 -1
  21. package/dist/library/Slider.js.map +1 -1
  22. package/dist/library/Switch.js.map +1 -1
  23. package/dist/library/Tabs.js.map +1 -1
  24. package/dist/library/Textarea.js.map +1 -1
  25. package/dist/library/ThemeScope.js.map +1 -1
  26. package/dist/library/Tooltip.js.map +1 -1
  27. package/dist/library/actionStyles.js +1 -1
  28. package/dist/library/actionStyles.js.map +1 -1
  29. package/dist/library/cn.d.ts.map +1 -1
  30. package/dist/library/cn.js +9 -0
  31. package/dist/library/cn.js.map +1 -1
  32. package/dist/library/color/colorFamilies.js.map +1 -1
  33. package/dist/library/color/generateColorWall.js.map +1 -1
  34. package/dist/library/color/index.js.map +1 -1
  35. package/dist/library/color/oklch.js.map +1 -1
  36. package/dist/library/color/recommendColorPalette.js.map +1 -1
  37. package/dist/library/comboboxStyles.js.map +1 -1
  38. package/dist/library/controlStyles.js.map +1 -1
  39. package/dist/library/examples/expressive.js.map +1 -1
  40. package/dist/library/examples/glass.js.map +1 -1
  41. package/dist/library/examples/index.js.map +1 -1
  42. package/dist/library/examples/jelly.js.map +1 -1
  43. package/dist/library/examples/preset-values.js.map +1 -1
  44. package/dist/library/examples/radiant.js.map +1 -1
  45. package/dist/library/examples/sharp-3d.js.map +1 -1
  46. package/dist/library/examples/soft-squircle.js.map +1 -1
  47. package/dist/library/examples/ticket.js.map +1 -1
  48. package/dist/library/index.d.ts +2 -0
  49. package/dist/library/index.d.ts.map +1 -1
  50. package/dist/library/index.js +1 -0
  51. package/dist/library/index.js.map +1 -1
  52. package/dist/library/internal/events.js.map +1 -1
  53. package/dist/library/internal/ids.js.map +1 -1
  54. package/dist/library/internal/popover.js.map +1 -1
  55. package/dist/library/internal/select.js.map +1 -1
  56. package/dist/library/internal/selection.js.map +1 -1
  57. package/dist/library/internal/switchDrag.js.map +1 -1
  58. package/dist/library/motion/MotionLink.js.map +1 -1
  59. package/dist/library/motion/browser.js.map +1 -1
  60. package/dist/library/motion/config.js.map +1 -1
  61. package/dist/library/motion/context.js.map +1 -1
  62. package/dist/library/motion/drag.js.map +1 -1
  63. package/dist/library/motion/dragBrowser.js.map +1 -1
  64. package/dist/library/motion/follow.js.map +1 -1
  65. package/dist/library/motion/host.js.map +1 -1
  66. package/dist/library/motion/index.js.map +1 -1
  67. package/dist/library/motion/layout.js.map +1 -1
  68. package/dist/library/motion/layoutDom.js.map +1 -1
  69. package/dist/library/motion/popup.js.map +1 -1
  70. package/dist/library/motion/press.js.map +1 -1
  71. package/dist/library/motion/pressPolicy.js.map +1 -1
  72. package/dist/library/motion/react.js.map +1 -1
  73. package/dist/library/motion/runtime.js.map +1 -1
  74. package/dist/library/motion/transitions.js.map +1 -1
  75. package/dist/library/presentation.js.map +1 -1
  76. package/dist/library/react/useComboboxPopup.js.map +1 -1
  77. package/dist/library/react/useComposedRefs.js.map +1 -1
  78. package/dist/library/react/useControllableState.js.map +1 -1
  79. package/dist/library/react/useNativeOwner.js.map +1 -1
  80. package/dist/library/react/usePopoverSurface.js.map +1 -1
  81. package/dist/library/react/useSwitchDrag.js.map +1 -1
  82. package/dist/library/selectStyles.js.map +1 -1
  83. package/dist/library/styles.css +1 -1
  84. package/dist/library/themes/components.d.ts +14 -0
  85. package/dist/library/themes/components.d.ts.map +1 -1
  86. package/dist/library/themes/components.js +14 -0
  87. package/dist/library/themes/components.js.map +1 -1
  88. package/dist/library/themes/default.js.map +1 -1
  89. package/dist/library/themes/defineTheme.js.map +1 -1
  90. package/dist/library/themes/index.js.map +1 -1
  91. package/dist/library/themes/themeDocument.js.map +1 -1
  92. package/dist/library/themes/themeDocumentTypes.js.map +1 -1
  93. package/dist/library/themes/tokens.js.map +1 -1
  94. package/dist/library/themes/types.js.map +1 -1
  95. package/dist/library/themes/updateThemeAppearance.js.map +1 -1
  96. package/dist/library/typography/index.js.map +1 -1
  97. package/dist/library/typography/types.js.map +1 -1
  98. package/docs/architecture.md +3 -3
  99. package/docs/theming.md +1 -1
  100. package/package.json +1 -1
  101. package/src/Alert.tsx +95 -0
  102. package/src/actionStyles.ts +1 -1
  103. package/src/cn.ts +9 -0
  104. package/src/index.ts +10 -0
  105. package/src/themes/components.ts +14 -0
package/src/Alert.tsx ADDED
@@ -0,0 +1,95 @@
1
+ import type { ComponentProps } from 'react'
2
+ import { cn } from './cn.js'
3
+ import { actionTone } from './actionStyles.js'
4
+ import { joinIds } from './internal/ids.js'
5
+ import type { Tone } from './presentation.js'
6
+ import type { ThemeStyle } from './themes/defineTheme.js'
7
+
8
+ export type AlertAnnouncement = 'off' | 'polite' | 'assertive'
9
+ export type AlertTone = Tone
10
+ export type AlertProps = Omit<
11
+ ComponentProps<'div'>,
12
+ 'style' | 'role' | 'aria-live' | 'aria-atomic'
13
+ > & {
14
+ style?: ThemeStyle
15
+ 'data-slot'?: string
16
+ /** Visual palette only; urgency is chosen independently through announce. */
17
+ tone?: AlertTone
18
+ /** Static information is silent by default. Live roles carry their native ARIA defaults. */
19
+ announce?: AlertAnnouncement
20
+ }
21
+ const headings = { 1: 'h1', 2: 'h2', 3: 'h3', 4: 'h4', 5: 'h5', 6: 'h6' } as const
22
+ export type AlertHeadingLevel = keyof typeof headings
23
+ export type AlertTitleProps = Omit<ComponentProps<'h2'>, 'style'> & {
24
+ style?: ThemeStyle
25
+ 'data-slot'?: string
26
+ level?: AlertHeadingLevel
27
+ }
28
+ export type AlertDescriptionProps = Omit<ComponentProps<'p'>, 'style'> & {
29
+ style?: ThemeStyle
30
+ 'data-slot'?: string
31
+ }
32
+ const colorMotion =
33
+ 'transition-colors duration-[var(--rad-motion-color-duration,150ms)] motion-reduce:transition-none'
34
+
35
+ /** Inline content, never a focus manager, timer, dismissal owner or announcement queue. */
36
+ export function Alert({ announce = 'off', tone = 'neutral', className, ...props }: AlertProps) {
37
+ if (!['off', 'polite', 'assertive'].includes(announce))
38
+ throw new TypeError('Alert announce must be off, polite or assertive.')
39
+ const named = Boolean(props['aria-label'] || props['aria-labelledby'])
40
+ const role =
41
+ announce === 'assertive'
42
+ ? 'alert'
43
+ : announce === 'polite'
44
+ ? 'status'
45
+ : named
46
+ ? 'group'
47
+ : undefined
48
+ return (
49
+ <div
50
+ {...props}
51
+ role={role}
52
+ aria-live={undefined}
53
+ aria-atomic={undefined}
54
+ data-slot={joinIds('alert', props['data-slot'])}
55
+ data-tone={tone}
56
+ data-announce={announce}
57
+ className={cn(
58
+ actionTone({ tone }),
59
+ colorMotion,
60
+ 'box-border grid w-full min-w-0 break-words text-start antialiased gap-[var(--rad-alert-gap,var(--rad-spacing-header-gap,0.375rem))] p-[var(--rad-alert-padding,var(--rad-surface-padding,1.5rem))] rounded-[var(--rad-alert-radius,var(--rad-surface-radius,0.75rem))]',
61
+ 'bg-[var(--rad-alert-background,var(--_action-soft))] [color:var(--rad-alert-color,var(--_action-ink))] [border-color:var(--rad-alert-border-color,var(--_action-edge))] [border-width:var(--rad-alert-border-width,var(--rad-surface-border-width,1px))] [border-style:var(--rad-alert-border-style,var(--rad-surface-border-style,solid))] [box-shadow:var(--rad-alert-shadow,none)]',
62
+ 'font-[family-name:var(--rad-typography-roles-ui-body-family,system-ui,sans-serif)] 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)] tracking-[var(--rad-typography-roles-ui-body-letter-spacing,-0.011em)]',
63
+ 'forced-colors:border-[CanvasText] forced-colors:bg-[Canvas] forced-colors:text-[CanvasText] forced-colors:shadow-none',
64
+ className
65
+ )}
66
+ />
67
+ )
68
+ }
69
+ export function AlertTitle({ level = 2, className, ...props }: AlertTitleProps) {
70
+ const Tag = headings[level]
71
+ return (
72
+ <Tag
73
+ {...props}
74
+ data-slot={joinIds('alert-title', props['data-slot'])}
75
+ className={cn(
76
+ colorMotion,
77
+ 'm-0 min-w-0 break-words font-[family-name:var(--rad-typography-roles-ui-title-family,system-ui,sans-serif)] text-[length:var(--rad-alert-title-size,var(--rad-typography-roles-ui-title-size,1.125rem))] font-[number:var(--rad-alert-title-weight,var(--rad-typography-roles-ui-title-weight,600))] leading-[var(--rad-typography-roles-ui-title-line-height,1.3)] tracking-[var(--rad-typography-roles-ui-title-letter-spacing,-0.015em)]',
78
+ className
79
+ )}
80
+ />
81
+ )
82
+ }
83
+ export function AlertDescription({ className, ...props }: AlertDescriptionProps) {
84
+ return (
85
+ <p
86
+ {...props}
87
+ data-slot={joinIds('alert-description', props['data-slot'])}
88
+ className={cn(
89
+ colorMotion,
90
+ 'm-0 min-w-0 break-words text-[length:var(--rad-alert-description-size,var(--rad-typography-roles-ui-body-size,0.875rem))] leading-[var(--rad-typography-roles-ui-body-line-height,1.5)]',
91
+ className
92
+ )}
93
+ />
94
+ )
95
+ }
@@ -1,6 +1,6 @@
1
1
  import { cva } from 'class-variance-authority'
2
2
 
3
- // Palette and readable ink are shared by action-shaped and text links. Ink is
3
+ // Palette and readable ink are shared by actions, text links and inline feedback. Ink is
4
4
  // mixed toward the scope foreground so pale warning/accent fills stay readable
5
5
  // on an unfilled surface in either mode. Neutral preserves the quiet palette.
6
6
  const tones = {
package/src/cn.ts CHANGED
@@ -17,6 +17,7 @@ export const cn: CnFunction = createCn({
17
17
  'font-(--rad-tabs-font-family)'
18
18
  ],
19
19
  'font-weight': [
20
+ 'font-(--rad-alert-title-weight)',
20
21
  'font-(--rad-tooltip-font-weight)',
21
22
  ...roleClasses('font', 'weight'),
22
23
  'font-(--rad-combobox-font-weight)',
@@ -25,6 +26,8 @@ export const cn: CnFunction = createCn({
25
26
  'font-(--rad-tabs-font-weight)'
26
27
  ],
27
28
  'font-size': [
29
+ 'text-(--rad-alert-title-size)',
30
+ 'text-(--rad-alert-description-size)',
28
31
  'text-(--rad-tooltip-font-size)',
29
32
  ...roleClasses('text', 'size'),
30
33
  ...roleClasses('text', 'fluid-size'),
@@ -51,6 +54,7 @@ export const cn: CnFunction = createCn({
51
54
  'max-w': ['max-w-(--rad-tooltip-max-width)'],
52
55
  size: ['size-(--rad-slider-thumb-size)', 'size-(--rad-slider-track-size)'],
53
56
  gap: [
57
+ 'gap-(--rad-alert-gap)',
54
58
  'gap-(--rad-popover-gap)',
55
59
  'gap-(--rad-switch-gap)',
56
60
  'gap-(--rad-tabs-gap)',
@@ -65,6 +69,7 @@ export const cn: CnFunction = createCn({
65
69
  'px-(--rad-tabs-trigger-padding)'
66
70
  ],
67
71
  p: [
72
+ 'p-(--rad-alert-padding)',
68
73
  'p-(--rad-menu-padding)',
69
74
  'p-(--rad-menu-item-padding)',
70
75
  'p-(--rad-tooltip-padding)',
@@ -75,6 +80,7 @@ export const cn: CnFunction = createCn({
75
80
  'p-(--rad-tabs-content-padding)'
76
81
  ],
77
82
  rounded: [
83
+ 'rounded-(--rad-alert-radius)',
78
84
  'rounded-(--rad-menu-radius)',
79
85
  'rounded-(--rad-menu-item-radius)',
80
86
  'rounded-(--rad-tooltip-radius)',
@@ -95,6 +101,7 @@ export const cn: CnFunction = createCn({
95
101
  'rounded-(--rad-tabs-content-radius)'
96
102
  ],
97
103
  'border-w': [
104
+ 'border-(--rad-alert-border-width)',
98
105
  'border-(--rad-menu-border-width)',
99
106
  'border-(--rad-tooltip-border-width)',
100
107
  'border-(--rad-popover-border-width)',
@@ -106,6 +113,7 @@ export const cn: CnFunction = createCn({
106
113
  'border-(--rad-tabs-trigger-border-width)'
107
114
  ],
108
115
  'border-style': [
116
+ 'border-(--rad-alert-border-style)',
109
117
  'border-(--rad-menu-border-style)',
110
118
  'border-(--rad-tooltip-border-style)',
111
119
  'border-(--rad-popover-border-style)',
@@ -115,6 +123,7 @@ export const cn: CnFunction = createCn({
115
123
  'border-(--rad-switch-border-style)'
116
124
  ],
117
125
  shadow: [
126
+ 'shadow-(--rad-alert-shadow)',
118
127
  'shadow-(--rad-menu-shadow)',
119
128
  'shadow-(--rad-tooltip-shadow)',
120
129
  'shadow-(--rad-popover-shadow)',
package/src/index.ts CHANGED
@@ -252,3 +252,13 @@ export type {
252
252
  MenuPortalProps,
253
253
  MenuRenderProps
254
254
  } from './Menu.js'
255
+
256
+ export { Alert, AlertTitle, AlertDescription } from './Alert.js'
257
+ export type {
258
+ AlertProps,
259
+ AlertTitleProps,
260
+ AlertDescriptionProps,
261
+ AlertAnnouncement,
262
+ AlertTone,
263
+ AlertHeadingLevel
264
+ } from './Alert.js'
@@ -396,6 +396,20 @@ export const componentRegistry = {
396
396
  itemFocusBackground: 'css',
397
397
  itemFocusColor: 'css'
398
398
  },
399
+ alert: {
400
+ radius: 'css',
401
+ padding: 'css',
402
+ gap: 'css',
403
+ background: 'css',
404
+ color: 'css',
405
+ borderColor: 'css',
406
+ borderWidth: 'css',
407
+ borderStyle: 'css',
408
+ shadow: 'css',
409
+ titleSize: 'css',
410
+ titleWeight: 'weight',
411
+ descriptionSize: 'css'
412
+ },
399
413
  radioGroup: { gap: 'css' }
400
414
  } as const
401
415