@cdx-ui/components 0.2.5 → 0.3.1
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/coverage.svg +1 -1
- package/docs/components/bottom-sheet/content.md +2 -0
- package/docs/components/calendar/content.md +25 -1
- package/docs/components/carousel/content.md +1 -1
- package/docs/components/data-grid/content.md +50 -8
- package/docs/components/icon-button/content.md +23 -1
- package/docs/components/month-calendar/content.md +2 -0
- package/docs/components/range-calendar/content.md +3 -1
- package/docs/components/toast/content.md +23 -7
- package/docs/llms.txt +2 -0
- package/docs/resources/release-notes/0.2.5/content.md +25 -0
- package/docs/resources/release-notes/0.3.0/content.md +19 -0
- package/docs/resources/release-notes/content.md +2 -0
- package/lib/commonjs/components/BottomSheet/index.js +25 -1
- package/lib/commonjs/components/BottomSheet/index.js.map +1 -1
- package/lib/commonjs/components/BottomSheet/styles.js +8 -2
- package/lib/commonjs/components/BottomSheet/styles.js.map +1 -1
- package/lib/commonjs/components/Calendar/CalendarMonthHeader.js +15 -5
- package/lib/commonjs/components/Calendar/CalendarMonthHeader.js.map +1 -1
- package/lib/commonjs/components/Calendar/CalendarYearList.js +116 -0
- package/lib/commonjs/components/Calendar/CalendarYearList.js.map +1 -0
- package/lib/commonjs/components/Calendar/CalendarYearPickerGrid.js +58 -31
- package/lib/commonjs/components/Calendar/CalendarYearPickerGrid.js.map +1 -1
- package/lib/commonjs/components/Calendar/flashCalendarAdapter.js +22 -3
- package/lib/commonjs/components/Calendar/flashCalendarAdapter.js.map +1 -1
- package/lib/commonjs/components/Calendar/index.js +6 -2
- package/lib/commonjs/components/Calendar/index.js.map +1 -1
- package/lib/commonjs/components/Calendar/styles.js +16 -2
- package/lib/commonjs/components/Calendar/styles.js.map +1 -1
- package/lib/commonjs/components/IconButton/styles.js +107 -2
- package/lib/commonjs/components/IconButton/styles.js.map +1 -1
- package/lib/commonjs/components/MonthCalendar/index.js +39 -13
- package/lib/commonjs/components/MonthCalendar/index.js.map +1 -1
- package/lib/commonjs/components/RangeCalendar/index.js +6 -2
- package/lib/commonjs/components/RangeCalendar/index.js.map +1 -1
- package/lib/commonjs/components/Toast/index.js +5 -2
- package/lib/commonjs/components/Toast/index.js.map +1 -1
- package/lib/module/components/BottomSheet/index.js +27 -3
- package/lib/module/components/BottomSheet/index.js.map +1 -1
- package/lib/module/components/BottomSheet/styles.js +8 -2
- package/lib/module/components/BottomSheet/styles.js.map +1 -1
- package/lib/module/components/Calendar/CalendarMonthHeader.js +15 -5
- package/lib/module/components/Calendar/CalendarMonthHeader.js.map +1 -1
- package/lib/module/components/Calendar/CalendarYearList.js +112 -0
- package/lib/module/components/Calendar/CalendarYearList.js.map +1 -0
- package/lib/module/components/Calendar/CalendarYearPickerGrid.js +61 -34
- package/lib/module/components/Calendar/CalendarYearPickerGrid.js.map +1 -1
- package/lib/module/components/Calendar/flashCalendarAdapter.js +20 -2
- package/lib/module/components/Calendar/flashCalendarAdapter.js.map +1 -1
- package/lib/module/components/Calendar/index.js +7 -3
- package/lib/module/components/Calendar/index.js.map +1 -1
- package/lib/module/components/Calendar/styles.js +15 -1
- package/lib/module/components/Calendar/styles.js.map +1 -1
- package/lib/module/components/IconButton/styles.js +107 -2
- package/lib/module/components/IconButton/styles.js.map +1 -1
- package/lib/module/components/MonthCalendar/index.js +42 -15
- package/lib/module/components/MonthCalendar/index.js.map +1 -1
- package/lib/module/components/RangeCalendar/index.js +7 -3
- package/lib/module/components/RangeCalendar/index.js.map +1 -1
- package/lib/module/components/Toast/index.js +5 -2
- package/lib/module/components/Toast/index.js.map +1 -1
- package/lib/typescript/components/BottomSheet/index.d.ts +8 -0
- package/lib/typescript/components/BottomSheet/index.d.ts.map +1 -1
- package/lib/typescript/components/BottomSheet/styles.d.ts +5 -1
- package/lib/typescript/components/BottomSheet/styles.d.ts.map +1 -1
- package/lib/typescript/components/Calendar/CalendarMonthHeader.d.ts.map +1 -1
- package/lib/typescript/components/Calendar/CalendarYearList.d.ts +23 -0
- package/lib/typescript/components/Calendar/CalendarYearList.d.ts.map +1 -0
- package/lib/typescript/components/Calendar/CalendarYearPickerGrid.d.ts +5 -1
- package/lib/typescript/components/Calendar/CalendarYearPickerGrid.d.ts.map +1 -1
- package/lib/typescript/components/Calendar/flashCalendarAdapter.d.ts +8 -0
- package/lib/typescript/components/Calendar/flashCalendarAdapter.d.ts.map +1 -1
- package/lib/typescript/components/Calendar/index.d.ts.map +1 -1
- package/lib/typescript/components/Calendar/styles.d.ts +7 -1
- package/lib/typescript/components/Calendar/styles.d.ts.map +1 -1
- package/lib/typescript/components/IconButton/styles.d.ts +2 -2
- package/lib/typescript/components/IconButton/styles.d.ts.map +1 -1
- package/lib/typescript/components/MonthCalendar/index.d.ts.map +1 -1
- package/lib/typescript/components/RangeCalendar/index.d.ts.map +1 -1
- package/lib/typescript/components/Toast/index.d.ts.map +1 -1
- package/lib/typescript/components/ToggleButton/styles.d.ts +1 -1
- package/package.json +5 -5
- package/src/components/BottomSheet/index.tsx +174 -138
- package/src/components/BottomSheet/styles.ts +11 -3
- package/src/components/Calendar/CalendarMonthHeader.tsx +29 -22
- package/src/components/Calendar/CalendarYearList.tsx +136 -0
- package/src/components/Calendar/CalendarYearPickerGrid.tsx +60 -33
- package/src/components/Calendar/flashCalendarAdapter.ts +27 -2
- package/src/components/Calendar/index.tsx +8 -3
- package/src/components/Calendar/styles.ts +17 -1
- package/src/components/IconButton/styles.ts +111 -0
- package/src/components/MonthCalendar/index.tsx +55 -33
- package/src/components/RangeCalendar/index.tsx +8 -3
- package/src/components/Toast/index.tsx +13 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forwardRef, useCallback,
|
|
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
|
-
{
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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(
|
|
170
|
+
className={cn(calendarYearPickerListVariants(), className)}
|
|
153
171
|
style={style}
|
|
154
172
|
accessibilityRole="none"
|
|
155
173
|
{...props}
|
|
156
174
|
>
|
|
157
|
-
|
|
158
|
-
|
|
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 } =
|
|
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={
|
|
141
|
-
calendarRowVerticalSpacing={
|
|
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}
|
|
@@ -441,9 +441,18 @@ const ToastAction = forwardRef<View, ToastActionProps>((props, ref) => {
|
|
|
441
441
|
// --------------------------------------------------
|
|
442
442
|
|
|
443
443
|
const ToastClose = forwardRef<View, ToastCloseProps>((props, ref) => {
|
|
444
|
-
const {
|
|
444
|
+
const {
|
|
445
|
+
children,
|
|
446
|
+
size = 'small',
|
|
447
|
+
className,
|
|
448
|
+
onPress,
|
|
449
|
+
iconClassName,
|
|
450
|
+
color: colorProp,
|
|
451
|
+
as = CloseIcon,
|
|
452
|
+
...restProps
|
|
453
|
+
} = props;
|
|
445
454
|
const { hide, id, color: toastColor } = useToastStyleContext();
|
|
446
|
-
const usesNeutralStandIn = toastColor === 'neutral';
|
|
455
|
+
const usesNeutralStandIn = toastColor === 'neutral' && colorProp == null;
|
|
447
456
|
|
|
448
457
|
/**
|
|
449
458
|
* Handle close button press
|
|
@@ -463,12 +472,13 @@ const ToastClose = forwardRef<View, ToastCloseProps>((props, ref) => {
|
|
|
463
472
|
<IconButton
|
|
464
473
|
ref={ref}
|
|
465
474
|
variant="ghost"
|
|
475
|
+
color={colorProp ?? toastColor}
|
|
466
476
|
size={size}
|
|
467
477
|
aria-label="Close"
|
|
468
478
|
className={cn(usesNeutralStandIn ? toastCloseRootVariants() : undefined, className)}
|
|
469
479
|
iconClassName={cn(usesNeutralStandIn ? toastCloseIconVariants() : undefined, iconClassName)}
|
|
470
480
|
onPress={handlePress}
|
|
471
|
-
as={
|
|
481
|
+
as={as}
|
|
472
482
|
{...restProps}
|
|
473
483
|
/>
|
|
474
484
|
);
|