@cdx-ui/components 0.1.3 → 0.1.4

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 (144) hide show
  1. package/coverage.svg +1 -1
  2. package/lib/commonjs/components/Avatar/index.js +30 -8
  3. package/lib/commonjs/components/Avatar/index.js.map +1 -1
  4. package/lib/commonjs/components/Avatar/styles.js +163 -7
  5. package/lib/commonjs/components/Avatar/styles.js.map +1 -1
  6. package/lib/commonjs/components/CLAUDE.md +2 -1
  7. package/lib/commonjs/components/Chip/styles.js +1 -1
  8. package/lib/commonjs/components/Chip/styles.js.map +1 -1
  9. package/lib/commonjs/components/Drawer/animation.js +13 -0
  10. package/lib/commonjs/components/Drawer/animation.js.map +1 -0
  11. package/lib/commonjs/components/Drawer/index.js +739 -0
  12. package/lib/commonjs/components/Drawer/index.js.map +1 -0
  13. package/lib/commonjs/components/Drawer/styles.js +185 -0
  14. package/lib/commonjs/components/Drawer/styles.js.map +1 -0
  15. package/lib/commonjs/components/Drawer/utils.js +95 -0
  16. package/lib/commonjs/components/Drawer/utils.js.map +1 -0
  17. package/lib/commonjs/components/InsuranceDisclosure/styles.js +1 -1
  18. package/lib/commonjs/components/InsuranceDisclosure/styles.js.map +1 -1
  19. package/lib/commonjs/components/Menu/index.js +187 -61
  20. package/lib/commonjs/components/Menu/index.js.map +1 -1
  21. package/lib/commonjs/components/Menu/styles.js +32 -37
  22. package/lib/commonjs/components/Menu/styles.js.map +1 -1
  23. package/lib/commonjs/components/Select/index.js +2 -10
  24. package/lib/commonjs/components/Select/index.js.map +1 -1
  25. package/lib/commonjs/components/Tabs/styles.js +9 -10
  26. package/lib/commonjs/components/Tabs/styles.js.map +1 -1
  27. package/lib/commonjs/components/Toast/styles.js +1 -1
  28. package/lib/commonjs/components/Toast/styles.js.map +1 -1
  29. package/lib/commonjs/components/index.js +12 -0
  30. package/lib/commonjs/components/index.js.map +1 -1
  31. package/lib/commonjs/figma/Avatar.figma.js +18 -4
  32. package/lib/commonjs/figma/Avatar.figma.js.map +1 -1
  33. package/lib/commonjs/figma/Drawer.Content.figma.js +29 -0
  34. package/lib/commonjs/figma/Drawer.Content.figma.js.map +1 -0
  35. package/lib/commonjs/figma/Drawer.Description.figma.js +20 -0
  36. package/lib/commonjs/figma/Drawer.Description.figma.js.map +1 -0
  37. package/lib/commonjs/figma/Drawer.Footer.figma.js +41 -0
  38. package/lib/commonjs/figma/Drawer.Footer.figma.js.map +1 -0
  39. package/lib/commonjs/figma/Drawer.Header.figma.js +45 -0
  40. package/lib/commonjs/figma/Drawer.Header.figma.js.map +1 -0
  41. package/lib/commonjs/figma/Drawer.Title.figma.js +20 -0
  42. package/lib/commonjs/figma/Drawer.Title.figma.js.map +1 -0
  43. package/lib/commonjs/figma/Drawer.figma.js +41 -0
  44. package/lib/commonjs/figma/Drawer.figma.js.map +1 -0
  45. package/lib/commonjs/figma/Menu.Item.figma.js +33 -5
  46. package/lib/commonjs/figma/Menu.Item.figma.js.map +1 -1
  47. package/lib/commonjs/figma/icons.figma.batch.json +262 -2
  48. package/lib/module/components/Avatar/index.js +30 -8
  49. package/lib/module/components/Avatar/index.js.map +1 -1
  50. package/lib/module/components/Avatar/styles.js +163 -7
  51. package/lib/module/components/Avatar/styles.js.map +1 -1
  52. package/lib/module/components/CLAUDE.md +2 -1
  53. package/lib/module/components/Chip/styles.js +1 -1
  54. package/lib/module/components/Chip/styles.js.map +1 -1
  55. package/lib/module/components/Drawer/animation.js +7 -0
  56. package/lib/module/components/Drawer/animation.js.map +1 -0
  57. package/lib/module/components/Drawer/index.js +724 -0
  58. package/lib/module/components/Drawer/index.js.map +1 -0
  59. package/lib/module/components/Drawer/styles.js +181 -0
  60. package/lib/module/components/Drawer/styles.js.map +1 -0
  61. package/lib/module/components/Drawer/utils.js +86 -0
  62. package/lib/module/components/Drawer/utils.js.map +1 -0
  63. package/lib/module/components/InsuranceDisclosure/styles.js +1 -1
  64. package/lib/module/components/InsuranceDisclosure/styles.js.map +1 -1
  65. package/lib/module/components/Menu/index.js +178 -52
  66. package/lib/module/components/Menu/index.js.map +1 -1
  67. package/lib/module/components/Menu/styles.js +31 -36
  68. package/lib/module/components/Menu/styles.js.map +1 -1
  69. package/lib/module/components/Select/index.js +3 -11
  70. package/lib/module/components/Select/index.js.map +1 -1
  71. package/lib/module/components/Tabs/styles.js +9 -10
  72. package/lib/module/components/Tabs/styles.js.map +1 -1
  73. package/lib/module/components/Toast/styles.js +1 -1
  74. package/lib/module/components/Toast/styles.js.map +1 -1
  75. package/lib/module/components/index.js +1 -0
  76. package/lib/module/components/index.js.map +1 -1
  77. package/lib/module/figma/Avatar.figma.js +18 -4
  78. package/lib/module/figma/Avatar.figma.js.map +1 -1
  79. package/lib/module/figma/Drawer.Content.figma.js +23 -0
  80. package/lib/module/figma/Drawer.Content.figma.js.map +1 -0
  81. package/lib/module/figma/Drawer.Description.figma.js +14 -0
  82. package/lib/module/figma/Drawer.Description.figma.js.map +1 -0
  83. package/lib/module/figma/Drawer.Footer.figma.js +35 -0
  84. package/lib/module/figma/Drawer.Footer.figma.js.map +1 -0
  85. package/lib/module/figma/Drawer.Header.figma.js +39 -0
  86. package/lib/module/figma/Drawer.Header.figma.js.map +1 -0
  87. package/lib/module/figma/Drawer.Title.figma.js +14 -0
  88. package/lib/module/figma/Drawer.Title.figma.js.map +1 -0
  89. package/lib/module/figma/Drawer.figma.js +35 -0
  90. package/lib/module/figma/Drawer.figma.js.map +1 -0
  91. package/lib/module/figma/Menu.Item.figma.js +33 -5
  92. package/lib/module/figma/Menu.Item.figma.js.map +1 -1
  93. package/lib/module/figma/icons.figma.batch.json +262 -2
  94. package/lib/typescript/components/Avatar/index.d.ts +19 -1
  95. package/lib/typescript/components/Avatar/index.d.ts.map +1 -1
  96. package/lib/typescript/components/Avatar/styles.d.ts +10 -1
  97. package/lib/typescript/components/Avatar/styles.d.ts.map +1 -1
  98. package/lib/typescript/components/Drawer/animation.d.ts +9 -0
  99. package/lib/typescript/components/Drawer/animation.d.ts.map +1 -0
  100. package/lib/typescript/components/Drawer/index.d.ts +106 -0
  101. package/lib/typescript/components/Drawer/index.d.ts.map +1 -0
  102. package/lib/typescript/components/Drawer/styles.d.ts +32 -0
  103. package/lib/typescript/components/Drawer/styles.d.ts.map +1 -0
  104. package/lib/typescript/components/Drawer/utils.d.ts +23 -0
  105. package/lib/typescript/components/Drawer/utils.d.ts.map +1 -0
  106. package/lib/typescript/components/InsuranceDisclosure/styles.d.ts.map +1 -1
  107. package/lib/typescript/components/Menu/index.d.ts +29 -2
  108. package/lib/typescript/components/Menu/index.d.ts.map +1 -1
  109. package/lib/typescript/components/Menu/styles.d.ts +6 -2
  110. package/lib/typescript/components/Menu/styles.d.ts.map +1 -1
  111. package/lib/typescript/components/Select/index.d.ts.map +1 -1
  112. package/lib/typescript/components/Tabs/styles.d.ts.map +1 -1
  113. package/lib/typescript/components/index.d.ts +1 -0
  114. package/lib/typescript/components/index.d.ts.map +1 -1
  115. package/lib/typescript/figma/Avatar.figma.d.ts.map +1 -1
  116. package/lib/typescript/figma/Drawer.Content.figma.d.ts +8 -0
  117. package/lib/typescript/figma/Drawer.Content.figma.d.ts.map +1 -0
  118. package/lib/typescript/figma/Drawer.Description.figma.d.ts +8 -0
  119. package/lib/typescript/figma/Drawer.Description.figma.d.ts.map +1 -0
  120. package/lib/typescript/figma/Drawer.Footer.figma.d.ts +11 -0
  121. package/lib/typescript/figma/Drawer.Footer.figma.d.ts.map +1 -0
  122. package/lib/typescript/figma/Drawer.Header.figma.d.ts +8 -0
  123. package/lib/typescript/figma/Drawer.Header.figma.d.ts.map +1 -0
  124. package/lib/typescript/figma/Drawer.Title.figma.d.ts +8 -0
  125. package/lib/typescript/figma/Drawer.Title.figma.d.ts.map +1 -0
  126. package/lib/typescript/figma/Drawer.figma.d.ts +8 -0
  127. package/lib/typescript/figma/Drawer.figma.d.ts.map +1 -0
  128. package/lib/typescript/figma/Menu.Item.figma.d.ts.map +1 -1
  129. package/package.json +5 -5
  130. package/src/components/Avatar/index.tsx +45 -9
  131. package/src/components/Avatar/styles.ts +106 -23
  132. package/src/components/CLAUDE.md +2 -1
  133. package/src/components/Chip/styles.ts +1 -1
  134. package/src/components/Drawer/animation.ts +11 -0
  135. package/src/components/Drawer/index.tsx +896 -0
  136. package/src/components/Drawer/styles.ts +188 -0
  137. package/src/components/Drawer/utils.ts +83 -0
  138. package/src/components/InsuranceDisclosure/styles.ts +1 -3
  139. package/src/components/Menu/index.tsx +204 -62
  140. package/src/components/Menu/styles.ts +44 -54
  141. package/src/components/Select/index.tsx +7 -9
  142. package/src/components/Tabs/styles.ts +9 -10
  143. package/src/components/Toast/styles.ts +1 -1
  144. package/src/components/index.ts +1 -0
@@ -28,7 +28,6 @@ export const menuRootVariants = cva(
28
28
  export const menuItemVariants = cva(
29
29
  [
30
30
  'flex-row items-center gap-2',
31
- 'min-h-9',
32
31
  'rounded-lg',
33
32
  TRANSITION_COLORS,
34
33
  'data-[disabled=true]:opacity-50 data-[disabled=true]:pointer-events-none',
@@ -36,80 +35,63 @@ export const menuItemVariants = cva(
36
35
  'data-[state=checked]:bg-surface-action-tint data-[state=checked]:font-medium',
37
36
  Platform.select({
38
37
  default: 'data-[active=true]:bg-surface-action-tint-active',
39
- web: 'data-[hover=true]:bg-surface-action-tint-hover data-[active=true]:data-[hover=true]:bg-surface-action-tint-active data-[highlighted=true]:bg-surface-action-tint-hover',
38
+ // Pointer clicks set `data-highlighted` for the roving tab stop. That must not
39
+ // keep the hover fill after the pointer leaves an unchecked item. Keyboard
40
+ // focus paints the fill via `data-focus-visible`.
41
+ web: 'data-[hover=true]:bg-surface-action-tint-hover data-[active=true]:data-[hover=true]:bg-surface-action-tint-active data-[focus-visible=true]:bg-surface-action-tint-hover',
40
42
  }),
41
43
  ],
42
44
  {
43
45
  variants: {
44
46
  color: {
45
47
  neutral: 'text-content-primary',
46
- danger:
47
- 'text-content-danger data-[hover=true]:bg-surface-danger-tint-hover data-[highlighted=true]:bg-surface-danger-tint-hover',
48
+ danger: [
49
+ 'text-content-danger',
50
+ 'data-[hover=true]:bg-surface-danger-tint-hover',
51
+ Platform.select({
52
+ default: 'data-[highlighted=true]:bg-surface-danger-tint-hover',
53
+ web: 'data-[focus-visible=true]:bg-surface-danger-tint-hover',
54
+ }),
55
+ ].join(' '),
48
56
  },
49
57
  inset: {
50
- true: '',
51
- false: '',
58
+ // Label lines up with icon items: px-3 + size-5 icon + gap-2.
59
+ true: 'ps-8 pe-3 py-2',
60
+ false: 'px-3 py-2',
52
61
  },
53
- size: {
54
- default: 'px-3 py-2',
55
- small: 'px-2.5 py-1.5',
62
+ layout: {
63
+ default: 'min-h-9',
64
+ // Filter padding overrides inset so filter chrome stays compact.
65
+ filter: 'min-h-0 px-2 py-1.5',
56
66
  },
57
67
  },
58
- compoundVariants: [
59
- {
60
- inset: true,
61
- size: 'default',
62
- class: 'ps-8 pe-3 py-2',
63
- },
64
- {
65
- inset: true,
66
- size: 'small',
67
- class: 'ps-8 pe-2.5 py-1.5',
68
- },
69
- {
70
- inset: false,
71
- size: 'default',
72
- class: 'px-3 py-2',
73
- },
74
- {
75
- inset: false,
76
- size: 'small',
77
- class: 'px-2.5 py-1.5',
78
- },
79
- ],
80
68
  defaultVariants: {
81
69
  color: 'neutral',
82
70
  inset: false,
83
- size: 'default',
71
+ layout: 'default',
84
72
  },
85
73
  },
86
74
  );
87
75
 
88
- export const menuItemLabelVariants = cva(
89
- [
90
- 'text-start',
91
- Platform.select({
92
- default: 'shrink-0',
93
- web: 'min-w-0 flex-1',
94
- }),
95
- ],
96
- {
97
- variants: {
98
- size: {
99
- default: 'text-[0.875rem]',
100
- small: 'text-[0.75rem]',
101
- },
102
- color: {
103
- neutral: 'text-content-primary',
104
- danger: 'text-content-danger',
105
- },
76
+ export const menuItemLabelVariants = cva(['text-start', 'text-[0.875rem]'], {
77
+ variants: {
78
+ color: {
79
+ neutral: 'text-content-primary',
80
+ danger: 'text-content-danger',
106
81
  },
107
- defaultVariants: {
108
- size: 'default',
109
- color: 'neutral',
82
+ layout: {
83
+ default: Platform.select({
84
+ default: 'shrink-0',
85
+ web: 'min-w-0 flex-1',
86
+ }),
87
+ filter: 'min-w-0 flex-1 break-words',
110
88
  },
111
89
  },
112
- );
90
+ defaultVariants: {
91
+ color: 'neutral',
92
+ layout: 'default',
93
+ },
94
+ });
113
95
 
114
96
  export const menuItemIconVariants = cva(['shrink-0', 'size-5'], {
115
97
  variants: {
@@ -149,5 +131,13 @@ export const menuSeparatorVariants = cva([
149
131
 
150
132
  export const menuSeparatorLineVariants = cva(['h-px w-full bg-stroke-secondary']);
151
133
 
134
+ export const menuGroupHeaderVariants = cva(['flex-row items-center gap-2', 'px-2 py-1.5']);
135
+
136
+ export const menuItemActionVariants = cva(['ms-auto shrink-0']);
137
+
138
+ export const menuItemControlVariants = cva(['shrink-0']);
139
+
140
+ export const menuItemCountVariants = cva(['shrink-0 text-content-secondary', 'text-[0.875rem]']);
141
+
152
142
  export type MenuRootVariantProps = VariantProps<typeof menuRootVariants>;
153
143
  export type MenuItemVariantProps = VariantProps<typeof menuItemVariants>;
@@ -21,7 +21,7 @@ import {
21
21
  import { cn, ParentContext, useParentContext, useStyleContext } from '@cdx-ui/utils';
22
22
  import { Icon, IconProps } from '../Icon';
23
23
  import { Menu } from '../Menu';
24
- import { menuItemLabelVariants, menuItemVariants } from '../Menu/styles';
24
+ import { menuItemVariants } from '../Menu/styles';
25
25
  import { positionToDataIcon, type IconSlotPosition } from '../../utils/positionToDataIcon';
26
26
  import {
27
27
  type SelectVariantProps,
@@ -34,9 +34,6 @@ const SCOPE = 'SELECT';
34
34
 
35
35
  const useSelectStyleContext = () => useStyleContext(SCOPE) as SelectVariantProps;
36
36
 
37
- const toMenuItemSize = (size: SelectVariantProps['size'] | undefined) =>
38
- size === 'small' ? 'small' : 'default';
39
-
40
37
  // =============================================================================
41
38
  // STYLED ROOT
42
39
  // =============================================================================
@@ -297,10 +294,13 @@ const SelectItem = forwardRef<View, SelectItemProps>(
297
294
  ({ asChild, indicator, className, children, style, value: itemValue, ...props }, ref) => {
298
295
  const { size } = useSelectStyleContext();
299
296
  const { value: selectedValue } = useSelectContext();
300
- const menuSize = toMenuItemSize(size);
301
297
  const checked = selectedValue === itemValue;
302
298
 
303
- const computedClassName = cn(menuItemVariants({ size: menuSize }), className);
299
+ const computedClassName = cn(
300
+ menuItemVariants(),
301
+ size === 'small' ? 'px-2.5 py-1.5' : undefined,
302
+ className,
303
+ );
304
304
  const selectedIndicator =
305
305
  indicator === undefined ? (
306
306
  <Menu.ItemIndicator isChecked={checked} />
@@ -351,15 +351,13 @@ const SelectItemLabel = forwardRef<Text, SelectItemLabelProps>(
351
351
  ({ asChild, className, style, children, ...props }, ref) => {
352
352
  const { size } = useSelectStyleContext();
353
353
  const { checked } = useSelectItemContext();
354
- const menuSize = toMenuItemSize(size);
355
354
 
356
355
  return (
357
356
  <Menu.ItemLabel
358
357
  ref={ref}
359
358
  asChild={asChild}
360
359
  isChecked={checked}
361
- size={menuSize}
362
- className={cn(menuItemLabelVariants({ size: menuSize }), className)}
360
+ className={cn(size === 'small' ? 'text-[0.75rem]' : undefined, className)}
363
361
  style={style}
364
362
  {...props}
365
363
  {...mergeDataAttributes(
@@ -321,16 +321,15 @@ export const tabsTabLabelVariants = cva('body-md', {
321
321
  state: {
322
322
  // Selection state is a CVA input (not a `data-[]` selector) so inactive/active
323
323
  // typography reconciles on native — `data-[state=active]:` on `Text` is unreliable
324
- // there, and `font-sans-medium` / `font-sans-semibold` are the same family on iOS/Android
325
- // so weight must come from `font-medium` / `font-semibold` instead.
326
- inactive: Platform.select({
327
- web: 'font-sans-medium text-content-secondary',
328
- default: 'font-medium text-content-secondary',
329
- }),
330
- active: Platform.select({
331
- web: 'font-sans-semibold text-content-primary',
332
- default: 'font-semibold text-content-primary',
333
- }),
324
+ // there.
325
+ //
326
+ // Weight comes from `font-medium` / `font-semibold` over the family `body-md`
327
+ // already sets, which is how every other component expresses weight and is
328
+ // correct on all three platforms. The `font-sans-medium` family tokens are a
329
+ // native concern (React Native needs a family per face) and are not authoring
330
+ // API — see packages/styles/src/webFonts.ts.
331
+ inactive: 'font-medium text-content-secondary',
332
+ active: 'font-semibold text-content-primary',
334
333
  },
335
334
  },
336
335
  defaultVariants: { state: 'inactive' },
@@ -132,7 +132,7 @@ export const toastWrapperVariants = cva(
132
132
  },
133
133
  );
134
134
 
135
- export const toastLabelVariants = cva(['text-base font-sans-medium'], {
135
+ export const toastLabelVariants = cva(['text-base font-medium'], {
136
136
  variants: {
137
137
  color: {
138
138
  neutral: 'text-content-primary',
@@ -23,6 +23,7 @@ export * from './DateTimeList';
23
23
  export * from './DateTimePicker';
24
24
  export * from './Dialog';
25
25
  export * from './Divider';
26
+ export * from './Drawer';
26
27
  export * from './Field';
27
28
  export * from './Form';
28
29
  export * from './Image';