@cdx-ui/components 0.2.4 → 0.3.0

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 (165) hide show
  1. package/docs/components/accordion/content.md +2 -2
  2. package/docs/components/alert/content.md +1 -1
  3. package/docs/components/badge/content.md +5 -15
  4. package/docs/components/bottom-sheet/content.md +18 -14
  5. package/docs/components/box/content.md +141 -0
  6. package/docs/components/breadcrumbs/content.md +9 -9
  7. package/docs/components/button/content.md +19 -19
  8. package/docs/components/calendar/content.md +25 -1
  9. package/docs/components/card/content.md +2 -2
  10. package/docs/components/carousel/content.md +9 -8
  11. package/docs/components/chip/content.md +1 -1
  12. package/docs/components/color-area/content.md +3 -5
  13. package/docs/components/color-field/content.md +3 -5
  14. package/docs/components/color-picker/content.md +5 -4
  15. package/docs/components/color-slider/content.md +3 -5
  16. package/docs/components/color-swatch/content.md +3 -5
  17. package/docs/components/color-swatch-picker/content.md +3 -5
  18. package/docs/components/content.md +10 -9
  19. package/docs/components/data-grid/content.md +10 -11
  20. package/docs/components/drawer/content.md +17 -25
  21. package/docs/components/full-screen-dialog/content.md +2 -2
  22. package/docs/components/icon/content.md +1 -1
  23. package/docs/components/icon-button/content.md +3 -3
  24. package/docs/components/input/content.md +65 -0
  25. package/docs/components/list-item/content.md +9 -9
  26. package/docs/components/menu/content.md +57 -50
  27. package/docs/components/month-calendar/content.md +2 -0
  28. package/docs/components/range-calendar/content.md +3 -1
  29. package/docs/components/reorderable-list/content.md +5 -3
  30. package/docs/components/scoped-theme/content.md +1 -1
  31. package/docs/components/scroll-shadow/content.md +43 -36
  32. package/docs/components/select/content.md +80 -7
  33. package/docs/components/skeleton/content.md +7 -6
  34. package/docs/components/table/content.md +2 -2
  35. package/docs/components/tabs/content.md +14 -9
  36. package/docs/components/tile/content.md +9 -10
  37. package/docs/components/toggle-button/content.md +1 -1
  38. package/docs/components/tooltip/content.md +9 -9
  39. package/docs/components/virtualized-list/content.md +14 -14
  40. package/docs/getting-started/developers/content.md +2 -2
  41. package/docs/getting-started/developers/styling/content.md +20 -18
  42. package/docs/llms.txt +12 -9
  43. package/docs/patterns/authentication/content.md +4 -6
  44. package/docs/patterns/dashboard/content.md +8 -13
  45. package/docs/patterns/empty-states/content.md +7 -6
  46. package/docs/patterns/forms/content.md +6 -7
  47. package/docs/patterns/onboarding/content.md +4 -4
  48. package/docs/patterns/settings/content.md +5 -5
  49. package/docs/resources/release-notes/0.2.4/content.md +17 -0
  50. package/docs/resources/release-notes/0.2.5/content.md +25 -0
  51. package/docs/resources/release-notes/content.md +2 -0
  52. package/lib/commonjs/components/BottomSheet/index.js +25 -1
  53. package/lib/commonjs/components/BottomSheet/index.js.map +1 -1
  54. package/lib/commonjs/components/BottomSheet/styles.js +8 -2
  55. package/lib/commonjs/components/BottomSheet/styles.js.map +1 -1
  56. package/lib/commonjs/components/Box/Box.js +9 -1
  57. package/lib/commonjs/components/Box/Box.js.map +1 -1
  58. package/lib/commonjs/components/Breadcrumbs/index.js +28 -3
  59. package/lib/commonjs/components/Breadcrumbs/index.js.map +1 -1
  60. package/lib/commonjs/components/Breadcrumbs/styles.js +27 -0
  61. package/lib/commonjs/components/Breadcrumbs/styles.js.map +1 -1
  62. package/lib/commonjs/components/Calendar/CalendarMonthHeader.js +15 -5
  63. package/lib/commonjs/components/Calendar/CalendarMonthHeader.js.map +1 -1
  64. package/lib/commonjs/components/Calendar/CalendarYearList.js +116 -0
  65. package/lib/commonjs/components/Calendar/CalendarYearList.js.map +1 -0
  66. package/lib/commonjs/components/Calendar/CalendarYearPickerGrid.js +58 -31
  67. package/lib/commonjs/components/Calendar/CalendarYearPickerGrid.js.map +1 -1
  68. package/lib/commonjs/components/Calendar/flashCalendarAdapter.js +22 -3
  69. package/lib/commonjs/components/Calendar/flashCalendarAdapter.js.map +1 -1
  70. package/lib/commonjs/components/Calendar/index.js +6 -2
  71. package/lib/commonjs/components/Calendar/index.js.map +1 -1
  72. package/lib/commonjs/components/Calendar/styles.js +16 -2
  73. package/lib/commonjs/components/Calendar/styles.js.map +1 -1
  74. package/lib/commonjs/components/MonthCalendar/index.js +39 -13
  75. package/lib/commonjs/components/MonthCalendar/index.js.map +1 -1
  76. package/lib/commonjs/components/RangeCalendar/index.js +6 -2
  77. package/lib/commonjs/components/RangeCalendar/index.js.map +1 -1
  78. package/lib/commonjs/components/Stack/HStack.js +6 -2
  79. package/lib/commonjs/components/Stack/HStack.js.map +1 -1
  80. package/lib/commonjs/components/Stack/VStack.js +6 -2
  81. package/lib/commonjs/components/Stack/VStack.js.map +1 -1
  82. package/lib/commonjs/index.js +10 -10
  83. package/lib/commonjs/index.js.map +1 -1
  84. package/lib/module/components/BottomSheet/index.js +27 -3
  85. package/lib/module/components/BottomSheet/index.js.map +1 -1
  86. package/lib/module/components/BottomSheet/styles.js +8 -2
  87. package/lib/module/components/BottomSheet/styles.js.map +1 -1
  88. package/lib/module/components/Box/Box.js +9 -1
  89. package/lib/module/components/Box/Box.js.map +1 -1
  90. package/lib/module/components/Breadcrumbs/index.js +29 -4
  91. package/lib/module/components/Breadcrumbs/index.js.map +1 -1
  92. package/lib/module/components/Breadcrumbs/styles.js +26 -0
  93. package/lib/module/components/Breadcrumbs/styles.js.map +1 -1
  94. package/lib/module/components/Calendar/CalendarMonthHeader.js +15 -5
  95. package/lib/module/components/Calendar/CalendarMonthHeader.js.map +1 -1
  96. package/lib/module/components/Calendar/CalendarYearList.js +112 -0
  97. package/lib/module/components/Calendar/CalendarYearList.js.map +1 -0
  98. package/lib/module/components/Calendar/CalendarYearPickerGrid.js +61 -34
  99. package/lib/module/components/Calendar/CalendarYearPickerGrid.js.map +1 -1
  100. package/lib/module/components/Calendar/flashCalendarAdapter.js +20 -2
  101. package/lib/module/components/Calendar/flashCalendarAdapter.js.map +1 -1
  102. package/lib/module/components/Calendar/index.js +7 -3
  103. package/lib/module/components/Calendar/index.js.map +1 -1
  104. package/lib/module/components/Calendar/styles.js +15 -1
  105. package/lib/module/components/Calendar/styles.js.map +1 -1
  106. package/lib/module/components/MonthCalendar/index.js +42 -15
  107. package/lib/module/components/MonthCalendar/index.js.map +1 -1
  108. package/lib/module/components/RangeCalendar/index.js +7 -3
  109. package/lib/module/components/RangeCalendar/index.js.map +1 -1
  110. package/lib/module/components/Stack/HStack.js +6 -2
  111. package/lib/module/components/Stack/HStack.js.map +1 -1
  112. package/lib/module/components/Stack/VStack.js +6 -2
  113. package/lib/module/components/Stack/VStack.js.map +1 -1
  114. package/lib/module/index.js +6 -1
  115. package/lib/module/index.js.map +1 -1
  116. package/lib/typescript/animation/hooks/usePopupDialogContentAnimation.d.ts +2 -2
  117. package/lib/typescript/animation/hooks/usePopupOverlayAnimation.d.ts +2 -2
  118. package/lib/typescript/components/BottomSheet/index.d.ts +8 -0
  119. package/lib/typescript/components/BottomSheet/index.d.ts.map +1 -1
  120. package/lib/typescript/components/BottomSheet/styles.d.ts +5 -1
  121. package/lib/typescript/components/BottomSheet/styles.d.ts.map +1 -1
  122. package/lib/typescript/components/Box/Box.d.ts +4 -0
  123. package/lib/typescript/components/Box/Box.d.ts.map +1 -1
  124. package/lib/typescript/components/Breadcrumbs/index.d.ts +3 -1
  125. package/lib/typescript/components/Breadcrumbs/index.d.ts.map +1 -1
  126. package/lib/typescript/components/Breadcrumbs/styles.d.ts +2 -0
  127. package/lib/typescript/components/Breadcrumbs/styles.d.ts.map +1 -1
  128. package/lib/typescript/components/Calendar/CalendarMonthHeader.d.ts.map +1 -1
  129. package/lib/typescript/components/Calendar/CalendarYearList.d.ts +23 -0
  130. package/lib/typescript/components/Calendar/CalendarYearList.d.ts.map +1 -0
  131. package/lib/typescript/components/Calendar/CalendarYearPickerGrid.d.ts +5 -1
  132. package/lib/typescript/components/Calendar/CalendarYearPickerGrid.d.ts.map +1 -1
  133. package/lib/typescript/components/Calendar/flashCalendarAdapter.d.ts +8 -0
  134. package/lib/typescript/components/Calendar/flashCalendarAdapter.d.ts.map +1 -1
  135. package/lib/typescript/components/Calendar/index.d.ts.map +1 -1
  136. package/lib/typescript/components/Calendar/styles.d.ts +7 -1
  137. package/lib/typescript/components/Calendar/styles.d.ts.map +1 -1
  138. package/lib/typescript/components/MonthCalendar/index.d.ts.map +1 -1
  139. package/lib/typescript/components/RangeCalendar/index.d.ts.map +1 -1
  140. package/lib/typescript/components/Stack/HStack.d.ts +3 -2
  141. package/lib/typescript/components/Stack/HStack.d.ts.map +1 -1
  142. package/lib/typescript/components/Stack/VStack.d.ts +3 -2
  143. package/lib/typescript/components/Stack/VStack.d.ts.map +1 -1
  144. package/lib/typescript/components/Toast/animation.d.ts +3 -3
  145. package/lib/typescript/components/Toast/animation.d.ts.map +1 -1
  146. package/lib/typescript/components/ToggleButton/styles.d.ts +1 -1
  147. package/lib/typescript/index.d.ts +6 -1
  148. package/lib/typescript/index.d.ts.map +1 -1
  149. package/package.json +8 -8
  150. package/src/components/BottomSheet/index.tsx +174 -138
  151. package/src/components/BottomSheet/styles.ts +11 -3
  152. package/src/components/Box/Box.tsx +18 -4
  153. package/src/components/Breadcrumbs/index.tsx +28 -4
  154. package/src/components/Breadcrumbs/styles.ts +30 -0
  155. package/src/components/Calendar/CalendarMonthHeader.tsx +29 -22
  156. package/src/components/Calendar/CalendarYearList.tsx +136 -0
  157. package/src/components/Calendar/CalendarYearPickerGrid.tsx +60 -33
  158. package/src/components/Calendar/flashCalendarAdapter.ts +27 -2
  159. package/src/components/Calendar/index.tsx +8 -3
  160. package/src/components/Calendar/styles.ts +17 -1
  161. package/src/components/MonthCalendar/index.tsx +55 -33
  162. package/src/components/RangeCalendar/index.tsx +8 -3
  163. package/src/components/Stack/HStack.tsx +8 -4
  164. package/src/components/Stack/VStack.tsx +8 -4
  165. package/src/index.ts +8 -1
@@ -1,4 +1,4 @@
1
- import { forwardRef, useCallback, useMemo, type ReactNode } from 'react';
1
+ import { forwardRef, useCallback, useState, type ReactNode } from 'react';
2
2
  import { Pressable, Text, View, type ViewProps } from 'react-native';
3
3
  import {
4
4
  dataAttributes,
@@ -21,6 +21,7 @@ import { cn } from '@cdx-ui/utils';
21
21
  import { ChevronLeft, ChevronRight, KeyboardArrowDown } from '@cdx-ui/icons';
22
22
  import { Icon } from '../Icon';
23
23
  import { IconButton } from '../IconButton';
24
+ import { CalendarYearList, getYearRange, YEAR_ROW_HEIGHT } from '../Calendar/CalendarYearList';
24
25
  import {
25
26
  calendarMonthHeaderIconVariants,
26
27
  calendarMonthHeaderLabelVariants,
@@ -31,8 +32,16 @@ import {
31
32
  calendarPillCellVariants,
32
33
  calendarRootVariants,
33
34
  calendarYearPickerGridVariants,
35
+ calendarYearPickerListVariants,
34
36
  } from '../Calendar/styles';
35
37
 
38
+ // The month grid's four rows of pill cells, so the year view matches its height.
39
+ const MONTH_GRID_HEIGHT = 4 * YEAR_ROW_HEIGHT;
40
+
41
+ function renderYearCell(year: number) {
42
+ return <MonthCalendarYearCell year={year} />;
43
+ }
44
+
36
45
  export interface MonthCalendarProps
37
46
  extends Omit<MonthCalendarRootProps, 'children'>, Omit<ViewProps, 'children'> {
38
47
  className?: string;
@@ -109,28 +118,35 @@ const MonthCalendarHeader = forwardRef<View, ViewProps>(({ className, style, ...
109
118
  />
110
119
  </Pressable>
111
120
 
112
- {!isYearView ? (
113
- <View className={calendarMonthHeaderNavVariants()}>
114
- <IconButton
115
- as={ChevronLeft}
116
- variant="ghost"
117
- color="neutral"
118
- size="small"
119
- accessibilityLabel={labels.previousYear}
120
- isDisabled={disabled}
121
- onPress={() => shiftYear(-1)}
122
- />
123
- <IconButton
124
- as={ChevronRight}
125
- variant="ghost"
126
- color="neutral"
127
- size="small"
128
- accessibilityLabel={labels.nextYear}
129
- isDisabled={disabled}
130
- onPress={() => shiftYear(1)}
131
- />
132
- </View>
133
- ) : null}
121
+ {/* Stays mounted in the year view so the header keeps its height and the label does not move. */}
122
+ <View
123
+ className={calendarMonthHeaderNavVariants({ hidden: isYearView })}
124
+ pointerEvents={isYearView ? 'none' : 'auto'}
125
+ accessibilityElementsHidden={isYearView}
126
+ importantForAccessibility={isYearView ? 'no-hide-descendants' : 'auto'}
127
+ {...(isYearView ? { 'aria-hidden': true } : {})}
128
+ >
129
+ <IconButton
130
+ as={ChevronLeft}
131
+ variant="ghost"
132
+ color="neutral"
133
+ size="small"
134
+ accessibilityLabel={labels.previousYear}
135
+ isDisabled={disabled || isYearView}
136
+ focusable={!isYearView}
137
+ onPress={() => shiftYear(-1)}
138
+ />
139
+ <IconButton
140
+ as={ChevronRight}
141
+ variant="ghost"
142
+ color="neutral"
143
+ size="small"
144
+ accessibilityLabel={labels.nextYear}
145
+ isDisabled={disabled || isYearView}
146
+ focusable={!isYearView}
147
+ onPress={() => shiftYear(1)}
148
+ />
149
+ </View>
134
150
  </View>
135
151
  );
136
152
  });
@@ -138,25 +154,31 @@ const MonthCalendarHeader = forwardRef<View, ViewProps>(({ className, style, ...
138
154
  MonthCalendarHeader.displayName = 'MonthCalendar.Header';
139
155
 
140
156
  const MonthCalendarGrid = forwardRef<View, ViewProps>(({ className, style, ...props }, ref) => {
141
- const { view, visibleYear } = useMonthCalendarContext();
142
-
143
- const years = useMemo(
144
- () => Array.from({ length: 12 }, (_, i) => visibleYear - 5 + i),
145
- [visibleYear],
146
- );
157
+ const { view, visibleYear, minValue, maxValue } = useMonthCalendarContext();
158
+ const [todayYear] = useState(() => new Date().getFullYear());
147
159
 
148
160
  if (view === 'year') {
161
+ const { first, last } = getYearRange(
162
+ minValue ? parseMonthId(minValue)?.year : undefined,
163
+ maxValue ? parseMonthId(maxValue)?.year : undefined,
164
+ visibleYear,
165
+ todayYear,
166
+ );
149
167
  return (
150
168
  <View
151
169
  ref={ref}
152
- className={cn(calendarYearPickerGridVariants(), className)}
170
+ className={cn(calendarYearPickerListVariants(), className)}
153
171
  style={style}
154
172
  accessibilityRole="none"
155
173
  {...props}
156
174
  >
157
- {years.map((year) => (
158
- <MonthCalendarYearCell key={year} year={year} />
159
- ))}
175
+ <CalendarYearList
176
+ first={first}
177
+ last={last}
178
+ selectedYear={visibleYear}
179
+ height={MONTH_GRID_HEIGHT}
180
+ renderYear={renderYearCell}
181
+ />
160
182
  </View>
161
183
  );
162
184
  }
@@ -14,6 +14,8 @@ import { CalendarYearPickerGrid } from '../Calendar/CalendarYearPickerGrid';
14
14
  import {
15
15
  FLASH_CALENDAR_DAY_HEIGHT,
16
16
  FLASH_CALENDAR_RANGE_DAY_SPACING,
17
+ FLASH_CALENDAR_ROW_VERTICAL_SPACING,
18
+ FLASH_CALENDAR_WEEK_HEADER_HEIGHT,
17
19
  formatFlashCalendarWeekdayShort,
18
20
  toCalendarDateId,
19
21
  useFlashCalendarRangeTheme,
@@ -78,12 +80,15 @@ RangeCalendarHeader.displayName = 'RangeCalendar.Header';
78
80
 
79
81
  const RangeCalendarYearPicker = forwardRef<View, ViewProps>(
80
82
  ({ className, style, ...props }, ref) => {
81
- const { monthId, onMonthIdChange, disabled, setView, labels } = useRangeCalendarContext();
83
+ const { monthId, onMonthIdChange, minValue, maxValue, disabled, setView, labels } =
84
+ useRangeCalendarContext();
82
85
  return (
83
86
  <CalendarYearPickerGrid
84
87
  ref={ref}
85
88
  monthId={monthId}
86
89
  onMonthIdChange={onMonthIdChange}
90
+ minValue={minValue}
91
+ maxValue={maxValue}
87
92
  disabled={disabled}
88
93
  onViewChange={setView}
89
94
  labels={labels}
@@ -137,8 +142,8 @@ const RangeCalendarGrid = forwardRef<View, ViewProps>(({ className, style, ...pr
137
142
  calendarMaxDateId={maxValue}
138
143
  calendarMonthHeaderHeight={0}
139
144
  calendarDayHeight={FLASH_CALENDAR_DAY_HEIGHT}
140
- calendarWeekHeaderHeight={28}
141
- calendarRowVerticalSpacing={4}
145
+ calendarWeekHeaderHeight={FLASH_CALENDAR_WEEK_HEADER_HEIGHT}
146
+ calendarRowVerticalSpacing={FLASH_CALENDAR_ROW_VERTICAL_SPACING}
142
147
  calendarRowHorizontalSpacing={FLASH_CALENDAR_RANGE_DAY_SPACING}
143
148
  getCalendarMonthFormat={() => ''}
144
149
  getCalendarWeekDayFormat={formatWeekday}
@@ -1,10 +1,12 @@
1
1
  import type { ForwardedRef } from 'react';
2
2
  import { forwardRef } from 'react';
3
- import { View, type ViewProps } from 'react-native';
3
+ import type { View } from 'react-native';
4
+ import { dataAttributes, mergeDataAttributes } from '@cdx-ui/primitives';
4
5
  import { cn } from '@cdx-ui/utils';
6
+ import { Box, type BoxProps } from '../Box';
5
7
  import { hStackRootVariants, type StackSpace } from './styles';
6
8
 
7
- export interface HStackProps extends ViewProps {
9
+ export interface HStackProps extends Omit<BoxProps, 'asChild'> {
8
10
  className?: string;
9
11
  /** Token-based gap between children. */
10
12
  space?: StackSpace;
@@ -22,14 +24,16 @@ export const HStack = forwardRef<View, HStackProps>(
22
24
  ref: ForwardedRef<View>,
23
25
  ) => {
24
26
  return (
25
- <View
27
+ <Box
26
28
  ref={ref}
27
29
  className={cn(hStackRootVariants({ reversed, space }), className)}
28
30
  style={style}
29
31
  {...restProps}
32
+ // Caller-supplied data attributes win so components composed on HStack keep their own slot.
33
+ {...mergeDataAttributes(dataAttributes({ slot: 'hstack' }), restProps)}
30
34
  >
31
35
  {children}
32
- </View>
36
+ </Box>
33
37
  );
34
38
  },
35
39
  );
@@ -1,10 +1,12 @@
1
1
  import type { ForwardedRef } from 'react';
2
2
  import { forwardRef } from 'react';
3
- import { View, type ViewProps } from 'react-native';
3
+ import type { View } from 'react-native';
4
+ import { dataAttributes, mergeDataAttributes } from '@cdx-ui/primitives';
4
5
  import { cn } from '@cdx-ui/utils';
6
+ import { Box, type BoxProps } from '../Box';
5
7
  import { vStackRootVariants, type StackSpace } from './styles';
6
8
 
7
- export interface VStackProps extends ViewProps {
9
+ export interface VStackProps extends Omit<BoxProps, 'asChild'> {
8
10
  className?: string;
9
11
  /** Token-based gap between children. */
10
12
  space?: StackSpace;
@@ -22,14 +24,16 @@ export const VStack = forwardRef<View, VStackProps>(
22
24
  ref: ForwardedRef<View>,
23
25
  ) => {
24
26
  return (
25
- <View
27
+ <Box
26
28
  ref={ref}
27
29
  className={cn(vStackRootVariants({ reversed, space }), className)}
28
30
  style={style}
29
31
  {...restProps}
32
+ // Caller-supplied data attributes win so components composed on VStack keep their own slot.
33
+ {...mergeDataAttributes(dataAttributes({ slot: 'vstack' }), restProps)}
30
34
  >
31
35
  {children}
32
- </View>
36
+ </Box>
33
37
  );
34
38
  },
35
39
  );
package/src/index.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  /// <reference types="uniwind/types" preserve="true" />
2
+ import { View as RNView } from 'react-native';
3
+
2
4
  export * from './components';
3
5
  export * from './hooks';
4
6
  export * from './navigation';
@@ -6,5 +8,10 @@ export { ToastProvider, useToast } from './providers/toast';
6
8
  export type * from './providers/toast';
7
9
  export { ForgeDesignProvider } from './providers/forge-design';
8
10
  export type { ForgeDesignConfig, ForgeDesignProviderProps } from './providers/forge-design';
9
- export { View, ScrollView, KeyboardAvoidingView } from 'react-native';
11
+ export { ScrollView, KeyboardAvoidingView } from 'react-native';
10
12
  export { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context';
13
+
14
+ /** @deprecated Use `Box` instead. */
15
+ export const View = RNView;
16
+ /** @deprecated Use `BoxRef` for refs and `BoxProps` for props instead. */
17
+ export type View = RNView;