@wallarm-org/design-system 0.11.0 → 0.12.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.
- package/dist/components/Calendar/Calendar.d.ts +75 -0
- package/dist/components/Calendar/Calendar.figma.d.ts +1 -0
- package/dist/components/Calendar/Calendar.figma.js +324 -0
- package/dist/components/Calendar/Calendar.js +187 -0
- package/dist/components/Calendar/CalendarApplyButton.d.ts +10 -0
- package/dist/components/Calendar/CalendarApplyButton.js +20 -0
- package/dist/components/Calendar/CalendarBody.d.ts +12 -0
- package/dist/components/Calendar/CalendarBody.js +10 -0
- package/dist/components/Calendar/CalendarContent.d.ts +12 -0
- package/dist/components/Calendar/CalendarContent.js +15 -0
- package/dist/components/Calendar/CalendarContext.d.ts +27 -0
- package/dist/components/Calendar/CalendarContext.js +17 -0
- package/dist/components/Calendar/CalendarDayName.d.ts +6 -0
- package/dist/components/Calendar/CalendarDayName.js +8 -0
- package/dist/components/Calendar/CalendarFooter.d.ts +19 -0
- package/dist/components/Calendar/CalendarFooter.js +10 -0
- package/dist/components/Calendar/CalendarFooterControls.d.ts +12 -0
- package/dist/components/Calendar/CalendarFooterControls.js +10 -0
- package/dist/components/Calendar/CalendarGrid.d.ts +16 -0
- package/dist/components/Calendar/CalendarGrid.js +117 -0
- package/dist/components/Calendar/CalendarGrids.d.ts +10 -0
- package/dist/components/Calendar/CalendarGrids.js +25 -0
- package/dist/components/Calendar/CalendarHeader.d.ts +20 -0
- package/dist/components/Calendar/CalendarHeader.js +140 -0
- package/dist/components/Calendar/CalendarInputHeader.d.ts +12 -0
- package/dist/components/Calendar/CalendarInputHeader.js +117 -0
- package/dist/components/Calendar/CalendarKeyboardHints.d.ts +9 -0
- package/dist/components/Calendar/CalendarKeyboardHints.js +63 -0
- package/dist/components/Calendar/CalendarPresetItem.d.ts +18 -0
- package/dist/components/Calendar/CalendarPresetItem.js +32 -0
- package/dist/components/Calendar/CalendarPresets.d.ts +33 -0
- package/dist/components/Calendar/CalendarPresets.js +66 -0
- package/dist/components/Calendar/CalendarResetButton.d.ts +10 -0
- package/dist/components/Calendar/CalendarResetButton.js +20 -0
- package/dist/components/Calendar/CalendarTrigger.d.ts +12 -0
- package/dist/components/Calendar/CalendarTrigger.js +12 -0
- package/dist/components/Calendar/const.d.ts +2 -0
- package/dist/components/Calendar/const.js +24 -0
- package/dist/components/Calendar/index.d.ts +19 -0
- package/dist/components/Calendar/index.js +19 -0
- package/dist/components/Calendar/types.d.ts +10 -0
- package/dist/components/Calendar/types.js +0 -0
- package/dist/components/DateInput/DateInput.d.ts +22 -0
- package/dist/components/DateInput/DateInput.js +54 -0
- package/dist/components/DateInput/DateInputInternal.d.ts +7 -0
- package/dist/components/DateInput/DateInputInternal.js +100 -0
- package/dist/components/DateInput/index.d.ts +3 -0
- package/dist/components/DateInput/index.js +3 -0
- package/dist/components/DateInput/types.d.ts +22 -0
- package/dist/components/DateInput/types.js +0 -0
- package/dist/components/DateRangeInput/DateRangeClear.d.ts +2 -0
- package/dist/components/DateRangeInput/DateRangeClear.js +16 -0
- package/dist/components/DateRangeInput/DateRangeContext/DateRangeProvider.d.ts +24 -0
- package/dist/components/DateRangeInput/DateRangeContext/DateRangeProvider.js +68 -0
- package/dist/components/DateRangeInput/DateRangeContext/context.d.ts +2 -0
- package/dist/components/DateRangeInput/DateRangeContext/context.js +3 -0
- package/dist/components/DateRangeInput/DateRangeContext/index.d.ts +3 -0
- package/dist/components/DateRangeInput/DateRangeContext/index.js +3 -0
- package/dist/components/DateRangeInput/DateRangeContext/types.d.ts +24 -0
- package/dist/components/DateRangeInput/DateRangeContext/types.js +0 -0
- package/dist/components/DateRangeInput/DateRangeContext/useDateRangeContext.d.ts +23 -0
- package/dist/components/DateRangeInput/DateRangeContext/useDateRangeContext.js +4 -0
- package/dist/components/DateRangeInput/DateRangeEnd.d.ts +2 -0
- package/dist/components/DateRangeInput/DateRangeEnd.js +30 -0
- package/dist/components/DateRangeInput/DateRangeEndValue.d.ts +16 -0
- package/dist/components/DateRangeInput/DateRangeEndValue.js +14 -0
- package/dist/components/DateRangeInput/DateRangeGroup.d.ts +6 -0
- package/dist/components/DateRangeInput/DateRangeGroup.js +20 -0
- package/dist/components/DateRangeInput/DateRangeInput.d.ts +30 -0
- package/dist/components/DateRangeInput/DateRangeInput.js +14 -0
- package/dist/components/DateRangeInput/DateRangeInputInternal.d.ts +4 -0
- package/dist/components/DateRangeInput/DateRangeInputInternal.js +64 -0
- package/dist/components/DateRangeInput/DateRangeSegment.d.ts +7 -0
- package/dist/components/DateRangeInput/DateRangeSegment.js +11 -0
- package/dist/components/DateRangeInput/DateRangeSegmentGroup.d.ts +7 -0
- package/dist/components/DateRangeInput/DateRangeSegmentGroup.js +123 -0
- package/dist/components/DateRangeInput/DateRangeSeparator.d.ts +13 -0
- package/dist/components/DateRangeInput/DateRangeSeparator.js +12 -0
- package/dist/components/DateRangeInput/DateRangeStart.d.ts +2 -0
- package/dist/components/DateRangeInput/DateRangeStart.js +30 -0
- package/dist/components/DateRangeInput/DateRangeStartValue.d.ts +16 -0
- package/dist/components/DateRangeInput/DateRangeStartValue.js +14 -0
- package/dist/components/DateRangeInput/index.d.ts +6 -0
- package/dist/components/DateRangeInput/index.js +6 -0
- package/dist/components/DateRangeInput/types.d.ts +38 -0
- package/dist/components/DateRangeInput/types.js +0 -0
- package/dist/components/DropdownMenu/DropdownMenuInput.js +3 -4
- package/dist/components/Flex/Flex.d.ts +1 -1
- package/dist/components/Input/Input.js +4 -2
- package/dist/components/Input/classes.js +4 -12
- package/dist/components/InputGroup/InputGroup.js +1 -1
- package/dist/components/InputGroup/InputGroupAddon.js +1 -1
- package/dist/components/InputGroup/InputGroupInput.d.ts +1 -4
- package/dist/components/InputGroup/InputGroupInput.js +0 -15
- package/dist/components/InputGroup/index.d.ts +0 -1
- package/dist/components/InputGroup/index.js +1 -2
- package/dist/components/SegmentedControl/SegmentedControlSeparator.d.ts +1 -1
- package/dist/components/Select/SelectSearchInput.js +3 -2
- package/dist/components/Separator/Separator.d.ts +1 -1
- package/dist/components/Stack/Stack.d.ts +1 -1
- package/dist/components/TemporalCore/TemporalClear.d.ts +7 -0
- package/dist/components/TemporalCore/TemporalClear.js +12 -0
- package/dist/components/TemporalCore/TemporalPlaceholder.d.ts +10 -0
- package/dist/components/TemporalCore/TemporalPlaceholder.js +8 -0
- package/dist/components/TemporalCore/TemporalSegment.d.ts +12 -0
- package/dist/components/TemporalCore/TemporalSegment.js +55 -0
- package/dist/components/TemporalCore/TemporalSegmentGroup.d.ts +10 -0
- package/dist/components/TemporalCore/TemporalSegmentGroup.js +96 -0
- package/dist/components/TemporalCore/TimeDropdown.d.ts +24 -0
- package/dist/components/TemporalCore/TimeDropdown.js +172 -0
- package/dist/components/TemporalCore/index.d.ts +7 -0
- package/dist/components/TemporalCore/index.js +8 -0
- package/dist/components/TemporalCore/useTemporalField.d.ts +10 -0
- package/dist/components/TemporalCore/useTemporalField.js +16 -0
- package/dist/components/TemporalCore/useTimeDropdownKeyCapture.d.ts +16 -0
- package/dist/components/TemporalCore/useTimeDropdownKeyCapture.js +53 -0
- package/dist/components/TemporalCore/utils.d.ts +2 -0
- package/dist/components/TemporalCore/utils.js +11 -0
- package/dist/components/TimeInput/TimeInput.d.ts +20 -0
- package/dist/components/TimeInput/TimeInput.js +50 -0
- package/dist/components/TimeInput/index.d.ts +1 -0
- package/dist/components/TimeInput/index.js +2 -0
- package/dist/icons/Calendar.d.ts +3 -0
- package/dist/icons/Calendar.js +12 -0
- package/dist/icons/CalendarCheck.d.ts +3 -0
- package/dist/icons/CalendarCheck.js +12 -0
- package/dist/icons/CalendarCheck2.d.ts +3 -0
- package/dist/icons/CalendarCheck2.js +12 -0
- package/dist/icons/CalendarClock.d.ts +3 -0
- package/dist/icons/CalendarClock.js +12 -0
- package/dist/icons/CalendarCog.d.ts +3 -0
- package/dist/icons/CalendarCog.js +12 -0
- package/dist/icons/CalendarDays.d.ts +3 -0
- package/dist/icons/CalendarDays.js +12 -0
- package/dist/icons/CalendarFold.d.ts +3 -0
- package/dist/icons/CalendarFold.js +12 -0
- package/dist/icons/CalendarHeart.d.ts +3 -0
- package/dist/icons/CalendarHeart.js +12 -0
- package/dist/icons/CalendarMinus.d.ts +3 -0
- package/dist/icons/CalendarMinus.js +12 -0
- package/dist/icons/CalendarMinus2.d.ts +3 -0
- package/dist/icons/CalendarMinus2.js +12 -0
- package/dist/icons/CalendarOff.d.ts +3 -0
- package/dist/icons/CalendarOff.js +12 -0
- package/dist/icons/CalendarPlus.d.ts +3 -0
- package/dist/icons/CalendarPlus.js +12 -0
- package/dist/icons/CalendarPlus2.d.ts +3 -0
- package/dist/icons/CalendarPlus2.js +12 -0
- package/dist/icons/CalendarRange.d.ts +3 -0
- package/dist/icons/CalendarRange.js +12 -0
- package/dist/icons/CalendarSearch.d.ts +3 -0
- package/dist/icons/CalendarSearch.js +12 -0
- package/dist/icons/CalendarX.d.ts +3 -0
- package/dist/icons/CalendarX.js +12 -0
- package/dist/icons/CalendarX2.d.ts +3 -0
- package/dist/icons/CalendarX2.js +12 -0
- package/dist/icons/Clock.d.ts +3 -0
- package/dist/icons/Clock.js +12 -0
- package/dist/icons/Copy.js +5 -5
- package/dist/icons/CornerUpLeft.d.ts +3 -0
- package/dist/icons/CornerUpLeft.js +12 -0
- package/dist/icons/CornerUpRight.d.ts +3 -0
- package/dist/icons/CornerUpRight.js +12 -0
- package/dist/icons/GripVertical.js +18 -11
- package/dist/icons/MoveDown.js +2 -2
- package/dist/icons/MoveUp.js +2 -2
- package/dist/icons/Pin.js +1 -1
- package/dist/icons/PinOff.js +3 -3
- package/dist/icons/Settings.js +7 -5
- package/dist/icons/index.d.ts +20 -7
- package/dist/icons/index.js +21 -8
- package/dist/index.d.ts +5 -1
- package/dist/index.js +6 -2
- package/dist/metadata/components.json +1595 -227
- package/package.json +7 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { type FC, type ReactNode } from 'react';
|
|
2
|
+
import type { CalendarType, DateValue, PresetConfig } from './types';
|
|
3
|
+
export interface CalendarProps {
|
|
4
|
+
/** Calendar type: 'single' for one month, 'range' for two months (date range selection) */
|
|
5
|
+
type?: CalendarType;
|
|
6
|
+
/** Show time selection (affects input placeholder text) */
|
|
7
|
+
showTime?: boolean;
|
|
8
|
+
/** Show keyboard shortcut hints in presets and footer */
|
|
9
|
+
showKeyboardHints?: boolean;
|
|
10
|
+
/** Controlled value - array of selected dates */
|
|
11
|
+
value?: DateValue[];
|
|
12
|
+
/** Default value for uncontrolled mode */
|
|
13
|
+
defaultValue?: DateValue[];
|
|
14
|
+
/** Callback fired when selected value changes */
|
|
15
|
+
onChange?: (value: DateValue[]) => void;
|
|
16
|
+
/** Minimum selectable date */
|
|
17
|
+
minDate?: DateValue;
|
|
18
|
+
/** Maximum selectable date */
|
|
19
|
+
maxDate?: DateValue;
|
|
20
|
+
/**
|
|
21
|
+
* Function to determine if a specific date should be unavailable/disabled.
|
|
22
|
+
* DateValue has year, month (1-12), and day properties.
|
|
23
|
+
* To get day of week, use: new Date(date.year, date.month - 1, date.day).getDay()
|
|
24
|
+
* where Sunday = 0, Saturday = 6.
|
|
25
|
+
*/
|
|
26
|
+
isDateUnavailable?: (date: DateValue) => boolean;
|
|
27
|
+
/**
|
|
28
|
+
* When true, prevents selecting a range that contains any unavailable dates.
|
|
29
|
+
* Requires controlled mode (value + onChange props) to work properly.
|
|
30
|
+
*/
|
|
31
|
+
disallowDisabledDatesInRange?: boolean;
|
|
32
|
+
/** Controlled open state of the calendar popover */
|
|
33
|
+
open?: boolean;
|
|
34
|
+
/** Default open state for uncontrolled mode */
|
|
35
|
+
defaultOpen?: boolean;
|
|
36
|
+
/** Callback fired when popover open state changes */
|
|
37
|
+
onOpenChange?: (open: boolean) => void;
|
|
38
|
+
/** Whether to close calendar on date selection. Default: true */
|
|
39
|
+
closeOnSelect?: boolean;
|
|
40
|
+
/** Whether calendar is readonly (display only, no date selection allowed). Default: false */
|
|
41
|
+
readonly?: boolean;
|
|
42
|
+
/** Compound components (CalendarTrigger, CalendarContent, etc.) */
|
|
43
|
+
children?: ReactNode;
|
|
44
|
+
}
|
|
45
|
+
/** Default presets for single date selection */
|
|
46
|
+
export declare const DEFAULT_SINGLE_PRESETS: PresetConfig[];
|
|
47
|
+
/** Default presets for range selection */
|
|
48
|
+
export declare const DEFAULT_RANGE_PRESETS: PresetConfig[];
|
|
49
|
+
/**
|
|
50
|
+
* Calendar component for date and date range selection.
|
|
51
|
+
*
|
|
52
|
+
* Uses compound pattern — compose sub-components for full control:
|
|
53
|
+
* ```tsx
|
|
54
|
+
* <Calendar type='range'>
|
|
55
|
+
* <CalendarTrigger>
|
|
56
|
+
* <Button>Select date</Button>
|
|
57
|
+
* </CalendarTrigger>
|
|
58
|
+
* <CalendarContent>
|
|
59
|
+
* <CalendarPresets presets={myPresets} />
|
|
60
|
+
* <CalendarBody>
|
|
61
|
+
* <CalendarInputHeader />
|
|
62
|
+
* <CalendarGrids />
|
|
63
|
+
* <CalendarFooter>
|
|
64
|
+
* <CalendarKeyboardHints />
|
|
65
|
+
* <CalendarFooterControls>
|
|
66
|
+
* <CalendarResetButton />
|
|
67
|
+
* <CalendarApplyButton />
|
|
68
|
+
* </CalendarFooterControls>
|
|
69
|
+
* </CalendarFooter>
|
|
70
|
+
* </CalendarBody>
|
|
71
|
+
* </CalendarContent>
|
|
72
|
+
* </Calendar>
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare const Calendar: FC<CalendarProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import code_connect from "@figma/code-connect";
|
|
3
|
+
import { Button } from "../Button/index.js";
|
|
4
|
+
import { Calendar } from "./Calendar.js";
|
|
5
|
+
import { CalendarApplyButton } from "./CalendarApplyButton.js";
|
|
6
|
+
import { CalendarBody } from "./CalendarBody.js";
|
|
7
|
+
import { CalendarContent } from "./CalendarContent.js";
|
|
8
|
+
import { CalendarFooter } from "./CalendarFooter.js";
|
|
9
|
+
import { CalendarFooterControls } from "./CalendarFooterControls.js";
|
|
10
|
+
import { CalendarGrids } from "./CalendarGrids.js";
|
|
11
|
+
import { CalendarInputHeader } from "./CalendarInputHeader.js";
|
|
12
|
+
import { CalendarKeyboardHints } from "./CalendarKeyboardHints.js";
|
|
13
|
+
import { CalendarPresets } from "./CalendarPresets.js";
|
|
14
|
+
import { CalendarResetButton } from "./CalendarResetButton.js";
|
|
15
|
+
import { CalendarTrigger } from "./CalendarTrigger.js";
|
|
16
|
+
const figmaNodeUrl = 'https://www.figma.com/design/VKb5gW46uSGw0rqrhZsbXT/WADS-Components?node-id=2233-8455';
|
|
17
|
+
code_connect.connect(Calendar, figmaNodeUrl, {
|
|
18
|
+
variant: {
|
|
19
|
+
Type: 'Single',
|
|
20
|
+
Presets: false,
|
|
21
|
+
Input: false,
|
|
22
|
+
Footer: false
|
|
23
|
+
},
|
|
24
|
+
example: ()=>/*#__PURE__*/ jsxs(Calendar, {
|
|
25
|
+
type: "single",
|
|
26
|
+
children: [
|
|
27
|
+
/*#__PURE__*/ jsx(CalendarTrigger, {
|
|
28
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
29
|
+
variant: "outline",
|
|
30
|
+
color: "neutral",
|
|
31
|
+
children: "Select date"
|
|
32
|
+
})
|
|
33
|
+
}),
|
|
34
|
+
/*#__PURE__*/ jsx(CalendarContent, {
|
|
35
|
+
children: /*#__PURE__*/ jsx(CalendarBody, {
|
|
36
|
+
children: /*#__PURE__*/ jsx(CalendarGrids, {})
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
]
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
code_connect.connect(Calendar, figmaNodeUrl, {
|
|
43
|
+
variant: {
|
|
44
|
+
Type: 'Single',
|
|
45
|
+
Presets: false,
|
|
46
|
+
Input: true,
|
|
47
|
+
Footer: false
|
|
48
|
+
},
|
|
49
|
+
example: ()=>/*#__PURE__*/ jsxs(Calendar, {
|
|
50
|
+
type: "single",
|
|
51
|
+
children: [
|
|
52
|
+
/*#__PURE__*/ jsx(CalendarTrigger, {
|
|
53
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
54
|
+
variant: "outline",
|
|
55
|
+
color: "neutral",
|
|
56
|
+
children: "Select date"
|
|
57
|
+
})
|
|
58
|
+
}),
|
|
59
|
+
/*#__PURE__*/ jsx(CalendarContent, {
|
|
60
|
+
children: /*#__PURE__*/ jsxs(CalendarBody, {
|
|
61
|
+
children: [
|
|
62
|
+
/*#__PURE__*/ jsx(CalendarInputHeader, {}),
|
|
63
|
+
/*#__PURE__*/ jsx(CalendarGrids, {})
|
|
64
|
+
]
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
]
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
code_connect.connect(Calendar, figmaNodeUrl, {
|
|
71
|
+
variant: {
|
|
72
|
+
Type: 'Single',
|
|
73
|
+
Presets: true,
|
|
74
|
+
Input: false,
|
|
75
|
+
Footer: false
|
|
76
|
+
},
|
|
77
|
+
example: ()=>/*#__PURE__*/ jsxs(Calendar, {
|
|
78
|
+
type: "single",
|
|
79
|
+
children: [
|
|
80
|
+
/*#__PURE__*/ jsx(CalendarTrigger, {
|
|
81
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
82
|
+
variant: "outline",
|
|
83
|
+
color: "neutral",
|
|
84
|
+
children: "Select date"
|
|
85
|
+
})
|
|
86
|
+
}),
|
|
87
|
+
/*#__PURE__*/ jsxs(CalendarContent, {
|
|
88
|
+
children: [
|
|
89
|
+
/*#__PURE__*/ jsx(CalendarPresets, {}),
|
|
90
|
+
/*#__PURE__*/ jsx(CalendarBody, {
|
|
91
|
+
children: /*#__PURE__*/ jsx(CalendarGrids, {})
|
|
92
|
+
})
|
|
93
|
+
]
|
|
94
|
+
})
|
|
95
|
+
]
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
code_connect.connect(Calendar, figmaNodeUrl, {
|
|
99
|
+
variant: {
|
|
100
|
+
Type: 'Single',
|
|
101
|
+
Presets: true,
|
|
102
|
+
Input: true,
|
|
103
|
+
Footer: false
|
|
104
|
+
},
|
|
105
|
+
example: ()=>/*#__PURE__*/ jsxs(Calendar, {
|
|
106
|
+
type: "single",
|
|
107
|
+
children: [
|
|
108
|
+
/*#__PURE__*/ jsx(CalendarTrigger, {
|
|
109
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
110
|
+
variant: "outline",
|
|
111
|
+
color: "neutral",
|
|
112
|
+
children: "Select date"
|
|
113
|
+
})
|
|
114
|
+
}),
|
|
115
|
+
/*#__PURE__*/ jsxs(CalendarContent, {
|
|
116
|
+
children: [
|
|
117
|
+
/*#__PURE__*/ jsx(CalendarPresets, {}),
|
|
118
|
+
/*#__PURE__*/ jsxs(CalendarBody, {
|
|
119
|
+
children: [
|
|
120
|
+
/*#__PURE__*/ jsx(CalendarInputHeader, {}),
|
|
121
|
+
/*#__PURE__*/ jsx(CalendarGrids, {})
|
|
122
|
+
]
|
|
123
|
+
})
|
|
124
|
+
]
|
|
125
|
+
})
|
|
126
|
+
]
|
|
127
|
+
})
|
|
128
|
+
});
|
|
129
|
+
code_connect.connect(Calendar, figmaNodeUrl, {
|
|
130
|
+
variant: {
|
|
131
|
+
Type: 'Single',
|
|
132
|
+
Presets: true,
|
|
133
|
+
Input: true,
|
|
134
|
+
Footer: true
|
|
135
|
+
},
|
|
136
|
+
example: ()=>/*#__PURE__*/ jsxs(Calendar, {
|
|
137
|
+
type: "single",
|
|
138
|
+
children: [
|
|
139
|
+
/*#__PURE__*/ jsx(CalendarTrigger, {
|
|
140
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
141
|
+
variant: "outline",
|
|
142
|
+
color: "neutral",
|
|
143
|
+
children: "Select date"
|
|
144
|
+
})
|
|
145
|
+
}),
|
|
146
|
+
/*#__PURE__*/ jsxs(CalendarContent, {
|
|
147
|
+
children: [
|
|
148
|
+
/*#__PURE__*/ jsx(CalendarPresets, {}),
|
|
149
|
+
/*#__PURE__*/ jsxs(CalendarBody, {
|
|
150
|
+
children: [
|
|
151
|
+
/*#__PURE__*/ jsx(CalendarInputHeader, {}),
|
|
152
|
+
/*#__PURE__*/ jsx(CalendarGrids, {}),
|
|
153
|
+
/*#__PURE__*/ jsxs(CalendarFooter, {
|
|
154
|
+
children: [
|
|
155
|
+
/*#__PURE__*/ jsx(CalendarKeyboardHints, {}),
|
|
156
|
+
/*#__PURE__*/ jsxs(CalendarFooterControls, {
|
|
157
|
+
children: [
|
|
158
|
+
/*#__PURE__*/ jsx(CalendarResetButton, {}),
|
|
159
|
+
/*#__PURE__*/ jsx(CalendarApplyButton, {})
|
|
160
|
+
]
|
|
161
|
+
})
|
|
162
|
+
]
|
|
163
|
+
})
|
|
164
|
+
]
|
|
165
|
+
})
|
|
166
|
+
]
|
|
167
|
+
})
|
|
168
|
+
]
|
|
169
|
+
})
|
|
170
|
+
});
|
|
171
|
+
code_connect.connect(Calendar, figmaNodeUrl, {
|
|
172
|
+
variant: {
|
|
173
|
+
Type: 'Double',
|
|
174
|
+
Presets: false,
|
|
175
|
+
Input: false,
|
|
176
|
+
Footer: false
|
|
177
|
+
},
|
|
178
|
+
example: ()=>/*#__PURE__*/ jsxs(Calendar, {
|
|
179
|
+
type: "range",
|
|
180
|
+
children: [
|
|
181
|
+
/*#__PURE__*/ jsx(CalendarTrigger, {
|
|
182
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
183
|
+
variant: "outline",
|
|
184
|
+
color: "neutral",
|
|
185
|
+
children: "Select date range"
|
|
186
|
+
})
|
|
187
|
+
}),
|
|
188
|
+
/*#__PURE__*/ jsx(CalendarContent, {
|
|
189
|
+
children: /*#__PURE__*/ jsx(CalendarBody, {
|
|
190
|
+
children: /*#__PURE__*/ jsx(CalendarGrids, {})
|
|
191
|
+
})
|
|
192
|
+
})
|
|
193
|
+
]
|
|
194
|
+
})
|
|
195
|
+
});
|
|
196
|
+
code_connect.connect(Calendar, figmaNodeUrl, {
|
|
197
|
+
variant: {
|
|
198
|
+
Type: 'Double',
|
|
199
|
+
Presets: false,
|
|
200
|
+
Input: true,
|
|
201
|
+
Footer: false
|
|
202
|
+
},
|
|
203
|
+
example: ()=>/*#__PURE__*/ jsxs(Calendar, {
|
|
204
|
+
type: "range",
|
|
205
|
+
children: [
|
|
206
|
+
/*#__PURE__*/ jsx(CalendarTrigger, {
|
|
207
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
208
|
+
variant: "outline",
|
|
209
|
+
color: "neutral",
|
|
210
|
+
children: "Select date range"
|
|
211
|
+
})
|
|
212
|
+
}),
|
|
213
|
+
/*#__PURE__*/ jsx(CalendarContent, {
|
|
214
|
+
children: /*#__PURE__*/ jsxs(CalendarBody, {
|
|
215
|
+
children: [
|
|
216
|
+
/*#__PURE__*/ jsx(CalendarInputHeader, {}),
|
|
217
|
+
/*#__PURE__*/ jsx(CalendarGrids, {})
|
|
218
|
+
]
|
|
219
|
+
})
|
|
220
|
+
})
|
|
221
|
+
]
|
|
222
|
+
})
|
|
223
|
+
});
|
|
224
|
+
code_connect.connect(Calendar, figmaNodeUrl, {
|
|
225
|
+
variant: {
|
|
226
|
+
Type: 'Double',
|
|
227
|
+
Presets: true,
|
|
228
|
+
Input: false,
|
|
229
|
+
Footer: false
|
|
230
|
+
},
|
|
231
|
+
example: ()=>/*#__PURE__*/ jsxs(Calendar, {
|
|
232
|
+
type: "range",
|
|
233
|
+
children: [
|
|
234
|
+
/*#__PURE__*/ jsx(CalendarTrigger, {
|
|
235
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
236
|
+
variant: "outline",
|
|
237
|
+
color: "neutral",
|
|
238
|
+
children: "Select date range"
|
|
239
|
+
})
|
|
240
|
+
}),
|
|
241
|
+
/*#__PURE__*/ jsxs(CalendarContent, {
|
|
242
|
+
children: [
|
|
243
|
+
/*#__PURE__*/ jsx(CalendarPresets, {}),
|
|
244
|
+
/*#__PURE__*/ jsx(CalendarBody, {
|
|
245
|
+
children: /*#__PURE__*/ jsx(CalendarGrids, {})
|
|
246
|
+
})
|
|
247
|
+
]
|
|
248
|
+
})
|
|
249
|
+
]
|
|
250
|
+
})
|
|
251
|
+
});
|
|
252
|
+
code_connect.connect(Calendar, figmaNodeUrl, {
|
|
253
|
+
variant: {
|
|
254
|
+
Type: 'Double',
|
|
255
|
+
Presets: true,
|
|
256
|
+
Input: true,
|
|
257
|
+
Footer: false
|
|
258
|
+
},
|
|
259
|
+
example: ()=>/*#__PURE__*/ jsxs(Calendar, {
|
|
260
|
+
type: "range",
|
|
261
|
+
children: [
|
|
262
|
+
/*#__PURE__*/ jsx(CalendarTrigger, {
|
|
263
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
264
|
+
variant: "outline",
|
|
265
|
+
color: "neutral",
|
|
266
|
+
children: "Select date range"
|
|
267
|
+
})
|
|
268
|
+
}),
|
|
269
|
+
/*#__PURE__*/ jsxs(CalendarContent, {
|
|
270
|
+
children: [
|
|
271
|
+
/*#__PURE__*/ jsx(CalendarPresets, {}),
|
|
272
|
+
/*#__PURE__*/ jsxs(CalendarBody, {
|
|
273
|
+
children: [
|
|
274
|
+
/*#__PURE__*/ jsx(CalendarInputHeader, {}),
|
|
275
|
+
/*#__PURE__*/ jsx(CalendarGrids, {})
|
|
276
|
+
]
|
|
277
|
+
})
|
|
278
|
+
]
|
|
279
|
+
})
|
|
280
|
+
]
|
|
281
|
+
})
|
|
282
|
+
});
|
|
283
|
+
code_connect.connect(Calendar, figmaNodeUrl, {
|
|
284
|
+
variant: {
|
|
285
|
+
Type: 'Double',
|
|
286
|
+
Presets: true,
|
|
287
|
+
Input: true,
|
|
288
|
+
Footer: true
|
|
289
|
+
},
|
|
290
|
+
example: ()=>/*#__PURE__*/ jsxs(Calendar, {
|
|
291
|
+
type: "range",
|
|
292
|
+
children: [
|
|
293
|
+
/*#__PURE__*/ jsx(CalendarTrigger, {
|
|
294
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
295
|
+
variant: "outline",
|
|
296
|
+
color: "neutral",
|
|
297
|
+
children: "Select date range"
|
|
298
|
+
})
|
|
299
|
+
}),
|
|
300
|
+
/*#__PURE__*/ jsxs(CalendarContent, {
|
|
301
|
+
children: [
|
|
302
|
+
/*#__PURE__*/ jsx(CalendarPresets, {}),
|
|
303
|
+
/*#__PURE__*/ jsxs(CalendarBody, {
|
|
304
|
+
children: [
|
|
305
|
+
/*#__PURE__*/ jsx(CalendarInputHeader, {}),
|
|
306
|
+
/*#__PURE__*/ jsx(CalendarGrids, {}),
|
|
307
|
+
/*#__PURE__*/ jsxs(CalendarFooter, {
|
|
308
|
+
children: [
|
|
309
|
+
/*#__PURE__*/ jsx(CalendarKeyboardHints, {}),
|
|
310
|
+
/*#__PURE__*/ jsxs(CalendarFooterControls, {
|
|
311
|
+
children: [
|
|
312
|
+
/*#__PURE__*/ jsx(CalendarResetButton, {}),
|
|
313
|
+
/*#__PURE__*/ jsx(CalendarApplyButton, {})
|
|
314
|
+
]
|
|
315
|
+
})
|
|
316
|
+
]
|
|
317
|
+
})
|
|
318
|
+
]
|
|
319
|
+
})
|
|
320
|
+
]
|
|
321
|
+
})
|
|
322
|
+
]
|
|
323
|
+
})
|
|
324
|
+
});
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { DatePicker } from "@ark-ui/react";
|
|
4
|
+
import { CalendarDate, endOfMonth, getLocalTimeZone, startOfMonth, today } from "@internationalized/date";
|
|
5
|
+
import { CalendarProvider } from "./CalendarContext.js";
|
|
6
|
+
const toDateValue = (date)=>date;
|
|
7
|
+
const getThisMonthRange = ()=>{
|
|
8
|
+
const now = today(getLocalTimeZone());
|
|
9
|
+
return [
|
|
10
|
+
toDateValue(startOfMonth(now)),
|
|
11
|
+
toDateValue(endOfMonth(now))
|
|
12
|
+
];
|
|
13
|
+
};
|
|
14
|
+
const getRelativeDate = (daysAgo)=>{
|
|
15
|
+
const now = today(getLocalTimeZone());
|
|
16
|
+
return [
|
|
17
|
+
toDateValue(now.subtract({
|
|
18
|
+
days: daysAgo
|
|
19
|
+
}))
|
|
20
|
+
];
|
|
21
|
+
};
|
|
22
|
+
const getFirstOfThisMonth = ()=>{
|
|
23
|
+
const now = today(getLocalTimeZone());
|
|
24
|
+
return [
|
|
25
|
+
toDateValue(startOfMonth(now))
|
|
26
|
+
];
|
|
27
|
+
};
|
|
28
|
+
const getFirstOfLastMonth = ()=>{
|
|
29
|
+
const now = today(getLocalTimeZone());
|
|
30
|
+
return [
|
|
31
|
+
toDateValue(startOfMonth(now.subtract({
|
|
32
|
+
months: 1
|
|
33
|
+
})))
|
|
34
|
+
];
|
|
35
|
+
};
|
|
36
|
+
const DEFAULT_SINGLE_PRESETS = [
|
|
37
|
+
{
|
|
38
|
+
label: 'Today',
|
|
39
|
+
value: getRelativeDate(0),
|
|
40
|
+
shortcut: 'T'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
label: 'Yesterday',
|
|
44
|
+
value: getRelativeDate(1),
|
|
45
|
+
shortcut: 'Y'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
label: '1 week ago',
|
|
49
|
+
value: getRelativeDate(7),
|
|
50
|
+
shortcut: 'W'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
label: '2 weeks ago',
|
|
54
|
+
value: getRelativeDate(14),
|
|
55
|
+
shortcut: '2'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
label: '1st of this month',
|
|
59
|
+
value: getFirstOfThisMonth(),
|
|
60
|
+
shortcut: 'M'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
label: '1st of last month',
|
|
64
|
+
value: getFirstOfLastMonth(),
|
|
65
|
+
shortcut: 'L'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
label: '1 month ago',
|
|
69
|
+
value: getRelativeDate(30),
|
|
70
|
+
shortcut: '3'
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
label: '3 months ago',
|
|
74
|
+
value: getRelativeDate(90),
|
|
75
|
+
shortcut: '9'
|
|
76
|
+
}
|
|
77
|
+
];
|
|
78
|
+
const DEFAULT_RANGE_PRESETS = [
|
|
79
|
+
{
|
|
80
|
+
label: 'Today',
|
|
81
|
+
value: 'last3Days',
|
|
82
|
+
shortcut: 'T'
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
label: 'Last week',
|
|
86
|
+
value: 'lastWeek',
|
|
87
|
+
shortcut: 'W'
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
label: 'Last 2 weeks',
|
|
91
|
+
value: 'last14Days',
|
|
92
|
+
shortcut: '2'
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
label: 'This month',
|
|
96
|
+
value: getThisMonthRange(),
|
|
97
|
+
shortcut: 'M'
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
label: 'Last month',
|
|
101
|
+
value: 'lastMonth',
|
|
102
|
+
shortcut: 'L'
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
label: 'Last 3 months',
|
|
106
|
+
value: 'lastQuarter',
|
|
107
|
+
shortcut: '3'
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
label: 'Last 90 days',
|
|
111
|
+
value: 'last90Days',
|
|
112
|
+
shortcut: '9'
|
|
113
|
+
}
|
|
114
|
+
];
|
|
115
|
+
const Calendar = ({ type = 'single', showTime = false, showKeyboardHints = true, value, defaultValue, onChange, minDate, maxDate, isDateUnavailable, disallowDisabledDatesInRange = false, open, defaultOpen, onOpenChange, closeOnSelect = true, readonly = false, children })=>{
|
|
116
|
+
const isRange = 'range' === type;
|
|
117
|
+
const numOfMonths = isRange ? 2 : 1;
|
|
118
|
+
const hasUnavailableDateInRange = useCallback((start, end)=>{
|
|
119
|
+
if (!isDateUnavailable) return false;
|
|
120
|
+
let current = new CalendarDate(start.year, start.month, start.day);
|
|
121
|
+
const endDate = new CalendarDate(end.year, end.month, end.day);
|
|
122
|
+
while(current.compare(endDate) <= 0){
|
|
123
|
+
if (isDateUnavailable(toDateValue(current))) return true;
|
|
124
|
+
current = current.add({
|
|
125
|
+
days: 1
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
}, [
|
|
130
|
+
isDateUnavailable
|
|
131
|
+
]);
|
|
132
|
+
const handleValueChange = useCallback((details)=>{
|
|
133
|
+
const newValue = details.value;
|
|
134
|
+
if (isRange && 2 === newValue.length) {
|
|
135
|
+
const [start, end] = newValue;
|
|
136
|
+
if (start && end) {
|
|
137
|
+
const startDate = new CalendarDate(start.year, start.month, start.day);
|
|
138
|
+
const endDate = new CalendarDate(end.year, end.month, end.day);
|
|
139
|
+
if (endDate.compare(startDate) < 0) return;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (disallowDisabledDatesInRange && isRange && 2 === newValue.length) {
|
|
143
|
+
const [start, end] = newValue;
|
|
144
|
+
if (start && end && hasUnavailableDateInRange(start, end)) return;
|
|
145
|
+
}
|
|
146
|
+
onChange?.(newValue);
|
|
147
|
+
}, [
|
|
148
|
+
onChange,
|
|
149
|
+
disallowDisabledDatesInRange,
|
|
150
|
+
isRange,
|
|
151
|
+
hasUnavailableDateInRange
|
|
152
|
+
]);
|
|
153
|
+
const handleOpenChange = useCallback((details)=>{
|
|
154
|
+
onOpenChange?.(details.open);
|
|
155
|
+
}, [
|
|
156
|
+
onOpenChange
|
|
157
|
+
]);
|
|
158
|
+
const isControlled = void 0 !== value;
|
|
159
|
+
const contextValue = {
|
|
160
|
+
type,
|
|
161
|
+
isRange,
|
|
162
|
+
showKeyboardHints,
|
|
163
|
+
showTime,
|
|
164
|
+
readonly
|
|
165
|
+
};
|
|
166
|
+
return /*#__PURE__*/ jsx(DatePicker.Root, {
|
|
167
|
+
selectionMode: isRange ? 'range' : 'single',
|
|
168
|
+
numOfMonths: numOfMonths,
|
|
169
|
+
value: isControlled ? value : void 0,
|
|
170
|
+
defaultValue: defaultValue,
|
|
171
|
+
onValueChange: handleValueChange,
|
|
172
|
+
open: open,
|
|
173
|
+
defaultOpen: defaultOpen,
|
|
174
|
+
onOpenChange: handleOpenChange,
|
|
175
|
+
min: minDate,
|
|
176
|
+
max: maxDate,
|
|
177
|
+
isDateUnavailable: isDateUnavailable,
|
|
178
|
+
outsideDaySelectable: true,
|
|
179
|
+
closeOnSelect: closeOnSelect,
|
|
180
|
+
children: /*#__PURE__*/ jsx(CalendarProvider, {
|
|
181
|
+
value: contextValue,
|
|
182
|
+
children: children
|
|
183
|
+
})
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
Calendar.displayName = 'Calendar';
|
|
187
|
+
export { Calendar, DEFAULT_RANGE_PRESETS, DEFAULT_SINGLE_PRESETS };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ButtonProps } from '../Button';
|
|
2
|
+
export interface CalendarApplyButtonProps extends Omit<ButtonProps, 'onClick'> {
|
|
3
|
+
/** Callback fired before closing calendar */
|
|
4
|
+
onClick?: () => void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Apply button for the calendar footer.
|
|
8
|
+
* Calls onClick, then closes the calendar.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CalendarApplyButton: import("react").ForwardRefExoticComponent<Omit<CalendarApplyButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { DatePicker } from "@ark-ui/react";
|
|
4
|
+
import { Button } from "../Button/index.js";
|
|
5
|
+
const CalendarApplyButton = /*#__PURE__*/ forwardRef(({ onClick, children = 'Apply', variant = 'primary', color = 'brand', size = 'small', ...props }, ref)=>/*#__PURE__*/ jsx(DatePicker.Context, {
|
|
6
|
+
children: (api)=>/*#__PURE__*/ jsx(Button, {
|
|
7
|
+
ref: ref,
|
|
8
|
+
variant: variant,
|
|
9
|
+
color: color,
|
|
10
|
+
size: size,
|
|
11
|
+
onClick: ()=>{
|
|
12
|
+
onClick?.();
|
|
13
|
+
api.setOpen(false);
|
|
14
|
+
},
|
|
15
|
+
...props,
|
|
16
|
+
children: children
|
|
17
|
+
})
|
|
18
|
+
}));
|
|
19
|
+
CalendarApplyButton.displayName = 'CalendarApplyButton';
|
|
20
|
+
export { CalendarApplyButton };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export interface CalendarBodyProps {
|
|
3
|
+
/** Content to render (InputHeader, Grid(s), etc.) */
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/** Additional className for styling */
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Container for the main calendar body content.
|
|
10
|
+
* Wraps InputHeader, Grid(s), and optionally Footer.
|
|
11
|
+
*/
|
|
12
|
+
export declare const CalendarBody: import("react").ForwardRefExoticComponent<CalendarBodyProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
const CalendarBody = /*#__PURE__*/ forwardRef(({ children, className }, ref)=>/*#__PURE__*/ jsx("div", {
|
|
5
|
+
ref: ref,
|
|
6
|
+
className: cn('flex flex-col', className),
|
|
7
|
+
children: children
|
|
8
|
+
}));
|
|
9
|
+
CalendarBody.displayName = 'CalendarBody';
|
|
10
|
+
export { CalendarBody };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export interface CalendarContentProps {
|
|
3
|
+
/** Content to render inside the calendar popover */
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/** Additional className for styling */
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Content container for the calendar popover.
|
|
10
|
+
* Renders within a Portal with positioning and animation.
|
|
11
|
+
*/
|
|
12
|
+
export declare const CalendarContent: import("react").ForwardRefExoticComponent<CalendarContentProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { DatePicker, Portal } from "@ark-ui/react";
|
|
4
|
+
import { cn } from "../../utils/cn.js";
|
|
5
|
+
const CalendarContent = /*#__PURE__*/ forwardRef(({ children, className }, ref)=>/*#__PURE__*/ jsx(Portal, {
|
|
6
|
+
children: /*#__PURE__*/ jsx(DatePicker.Positioner, {
|
|
7
|
+
children: /*#__PURE__*/ jsx(DatePicker.Content, {
|
|
8
|
+
ref: ref,
|
|
9
|
+
className: cn('flex bg-bg-surface-1 rounded-12 shadow-lg', 'border border-border-primary-light', 'data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95', 'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95', className),
|
|
10
|
+
children: children
|
|
11
|
+
})
|
|
12
|
+
})
|
|
13
|
+
}));
|
|
14
|
+
CalendarContent.displayName = 'CalendarContent';
|
|
15
|
+
export { CalendarContent };
|