@autoguru/overdrive 4.46.0 → 4.47.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.css.d.ts +8 -0
- package/dist/components/Calendar/Calendar.css.d.ts.map +1 -0
- package/dist/components/Calendar/Calendar.css.js +113 -0
- package/dist/components/Calendar/Calendar.d.ts +64 -0
- package/dist/components/Calendar/Calendar.d.ts.map +1 -0
- package/dist/components/Calendar/Calendar.js +122 -0
- package/dist/components/Calendar/CalendarButton.d.ts +7 -0
- package/dist/components/Calendar/CalendarButton.d.ts.map +1 -0
- package/dist/components/{DateTimePicker → Calendar}/CalendarButton.js +3 -2
- package/dist/components/{DateTimePicker → Calendar}/CalendarGrid.d.ts +4 -1
- package/dist/components/Calendar/CalendarGrid.d.ts.map +1 -0
- package/dist/components/{DateTimePicker → Calendar}/CalendarGrid.js +7 -6
- package/dist/components/Calendar/index.d.ts +3 -0
- package/dist/components/Calendar/index.d.ts.map +1 -0
- package/dist/components/Calendar/index.js +3 -0
- package/dist/components/DatePicker/DatePicker.css.d.ts +2 -1
- package/dist/components/DatePicker/DatePicker.css.d.ts.map +1 -1
- package/dist/components/DatePicker/DatePicker.css.js +60 -30
- package/dist/components/DatePicker/DatePicker.d.ts +83 -5
- package/dist/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/components/DatePicker/DatePicker.js +160 -43
- package/dist/components/DateTimePicker/DateTimePicker.css.d.ts +0 -7
- package/dist/components/DateTimePicker/DateTimePicker.css.d.ts.map +1 -1
- package/dist/components/DateTimePicker/DateTimePicker.css.js +0 -110
- package/dist/components/DateTimePicker/DateTimePicker.d.ts +5 -2
- package/dist/components/DateTimePicker/DateTimePicker.d.ts.map +1 -1
- package/dist/components/DateTimePicker/DateTimePicker.js +24 -80
- package/dist/components/OptionList/OptionList.d.ts +5 -5
- package/dist/components/Popover/Popover.css.d.ts +4 -0
- package/dist/components/Popover/Popover.css.d.ts.map +1 -0
- package/dist/components/Popover/Popover.css.js +46 -0
- package/dist/components/Popover/Popover.d.ts +34 -0
- package/dist/components/Popover/Popover.d.ts.map +1 -0
- package/dist/components/Popover/Popover.js +127 -0
- package/dist/components/Popover/PopoverTrigger.d.ts +51 -0
- package/dist/components/Popover/PopoverTrigger.d.ts.map +1 -0
- package/dist/components/Popover/PopoverTrigger.js +94 -0
- package/dist/components/Popover/index.d.ts +5 -0
- package/dist/components/Popover/index.d.ts.map +1 -0
- package/dist/components/Popover/index.js +4 -0
- package/dist/components/Slider/Slider.css.d.ts +9 -0
- package/dist/components/Slider/Slider.css.d.ts.map +1 -0
- package/dist/components/Slider/Slider.css.js +92 -0
- package/dist/components/Slider/Slider.d.ts +47 -0
- package/dist/components/Slider/Slider.d.ts.map +1 -0
- package/dist/components/Slider/Slider.js +137 -0
- package/dist/components/Slider/index.d.ts +2 -0
- package/dist/components/Slider/index.d.ts.map +1 -0
- package/dist/components/Slider/index.js +3 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/styles/selectors.d.ts +2 -1
- package/dist/styles/selectors.d.ts.map +1 -1
- package/dist/styles/selectors.js +2 -1
- package/dist/utils/dateFormat.d.ts +24 -0
- package/dist/utils/dateFormat.d.ts.map +1 -0
- package/dist/utils/dateFormat.js +57 -0
- package/package.json +18 -18
- package/dist/components/DateTimePicker/CalendarButton.d.ts +0 -4
- package/dist/components/DateTimePicker/CalendarButton.d.ts.map +0 -1
- package/dist/components/DateTimePicker/CalendarGrid.d.ts.map +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const calendarGridStyle: string;
|
|
2
|
+
export declare const calendarStyle: string;
|
|
3
|
+
export declare const cellStyle: string;
|
|
4
|
+
export declare const buttonStyle: string;
|
|
5
|
+
export declare const thStyle: string;
|
|
6
|
+
export declare const tdStyle: string;
|
|
7
|
+
export declare const titleStyle: string;
|
|
8
|
+
//# sourceMappingURL=Calendar.css.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Calendar.css.d.ts","sourceRoot":"","sources":["../../../lib/components/Calendar/Calendar.css.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,iBAAiB,QAM5B,CAAC;AAEH,eAAO,MAAM,aAAa,QAQxB,CAAC;AAIH,eAAO,MAAM,SAAS,QAmCpB,CAAC;AAIH,eAAO,MAAM,WAAW,QAoCtB,CAAC;AAEH,eAAO,MAAM,OAAO,QAMlB,CAAC;AAEH,eAAO,MAAM,OAAO,QAGlB,CAAC;AAGH,eAAO,MAAM,UAAU,QAGrB,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import * as __vanilla_filescope__ from '@vanilla-extract/css/fileScope';
|
|
4
|
+
__vanilla_filescope__.setFileScope("lib/components/Calendar/Calendar.css.ts", "@autoguru/overdrive");
|
|
5
|
+
import { style } from '@vanilla-extract/css';
|
|
6
|
+
import { focusOutlineStyle } from "../../styles/focusOutline.css.js";
|
|
7
|
+
import { cssLayerComponent } from "../../styles/layers.css.js";
|
|
8
|
+
import { selectors } from "../../styles/selectors.js";
|
|
9
|
+
import { sprinkles } from "../../styles/sprinkles.css.js";
|
|
10
|
+
import { overdriveTokens as tokens } from "../../themes/theme.css.js";
|
|
11
|
+
export const calendarGridStyle = style({
|
|
12
|
+
'@layer': {
|
|
13
|
+
[cssLayerComponent]: {
|
|
14
|
+
width: '100%'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}, "calendarGridStyle");
|
|
18
|
+
export const calendarStyle = style([sprinkles({
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
display: 'flex',
|
|
21
|
+
justifyContent: 'spaceBetween',
|
|
22
|
+
mb: '2',
|
|
23
|
+
px: '1'
|
|
24
|
+
})], "calendarStyle");
|
|
25
|
+
|
|
26
|
+
// === Cell styles
|
|
27
|
+
|
|
28
|
+
export const cellStyle = style([sprinkles({
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
display: 'flex',
|
|
31
|
+
justifyContent: 'center',
|
|
32
|
+
size: '7',
|
|
33
|
+
borderRadius: 'md'
|
|
34
|
+
}), {
|
|
35
|
+
'@layer': {
|
|
36
|
+
[cssLayerComponent]: {
|
|
37
|
+
background: tokens.colours.background.body,
|
|
38
|
+
color: tokens.colours.foreground.body,
|
|
39
|
+
cursor: 'pointer',
|
|
40
|
+
selectors: {
|
|
41
|
+
[selectors.focusVisible]: {
|
|
42
|
+
background: tokens.colours.gamut.gray200
|
|
43
|
+
},
|
|
44
|
+
[selectors.selected]: {
|
|
45
|
+
background: tokens.colours.foreground.body,
|
|
46
|
+
color: tokens.colours.background.body
|
|
47
|
+
},
|
|
48
|
+
[selectors.hoverNotSelected]: {
|
|
49
|
+
background: tokens.colours.gamut.gray200
|
|
50
|
+
},
|
|
51
|
+
[`${selectors.disabled}, ${selectors.unavailable}`]: {
|
|
52
|
+
background: tokens.colours.background.body,
|
|
53
|
+
color: tokens.colours.gamut.gray400,
|
|
54
|
+
cursor: 'default'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}, focusOutlineStyle], "cellStyle");
|
|
60
|
+
|
|
61
|
+
// === Button styles
|
|
62
|
+
|
|
63
|
+
export const buttonStyle = style([sprinkles({
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
borderColour: 'gray',
|
|
66
|
+
borderRadius: 'md',
|
|
67
|
+
borderStyle: 'solid',
|
|
68
|
+
borderWidth: '1',
|
|
69
|
+
display: 'flex',
|
|
70
|
+
justifyContent: 'center',
|
|
71
|
+
padding: 'none',
|
|
72
|
+
size: '7'
|
|
73
|
+
}), {
|
|
74
|
+
'@layer': {
|
|
75
|
+
[cssLayerComponent]: {
|
|
76
|
+
background: tokens.colours.background.body,
|
|
77
|
+
color: tokens.colours.gamut.gray600,
|
|
78
|
+
cursor: 'pointer',
|
|
79
|
+
selectors: {
|
|
80
|
+
[selectors.hoverNotDisabled]: {
|
|
81
|
+
background: tokens.colours.gamut.gray200
|
|
82
|
+
},
|
|
83
|
+
[selectors.focusVisible]: {
|
|
84
|
+
background: tokens.colours.gamut.gray200
|
|
85
|
+
},
|
|
86
|
+
[selectors.disabled]: {
|
|
87
|
+
background: tokens.colours.background.body,
|
|
88
|
+
borderColor: tokens.border.colours.light,
|
|
89
|
+
color: tokens.colours.gamut.gray300,
|
|
90
|
+
cursor: 'not-allowed'
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}, focusOutlineStyle], "buttonStyle");
|
|
96
|
+
export const thStyle = style({
|
|
97
|
+
'@layer': {
|
|
98
|
+
[cssLayerComponent]: {
|
|
99
|
+
color: tokens.colours.gamut.gray600
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}, "thStyle");
|
|
103
|
+
export const tdStyle = sprinkles({
|
|
104
|
+
padding: '1',
|
|
105
|
+
textAlign: 'center'
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// === Heading styles
|
|
109
|
+
export const titleStyle = sprinkles({
|
|
110
|
+
fontWeight: 'bold',
|
|
111
|
+
margin: 'none'
|
|
112
|
+
});
|
|
113
|
+
__vanilla_filescope__.endFileScope();
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type AriaCalendarProps, type DateValue } from 'react-aria';
|
|
3
|
+
import type { TestIdProp } from '../../types';
|
|
4
|
+
declare const defaultEnglish: {
|
|
5
|
+
readonly nextLabel: "Next month";
|
|
6
|
+
readonly prevLabel: "Previous month";
|
|
7
|
+
};
|
|
8
|
+
type LanguageEntries = Partial<Record<keyof typeof defaultEnglish, string>>;
|
|
9
|
+
export interface CalendarProps extends TestIdProp {
|
|
10
|
+
/**
|
|
11
|
+
* Calendar props passed through to the react-aria hook
|
|
12
|
+
* ([docs](https://react-spectrum.adobe.com/react-aria/useCalendar.html))
|
|
13
|
+
*
|
|
14
|
+
* *Defaults*
|
|
15
|
+
* - `defaultValue`: Today's date
|
|
16
|
+
* - `firstDayOfWeek`: Sunday
|
|
17
|
+
*/
|
|
18
|
+
calendarOptions?: Exclude<AriaCalendarProps<DateValue>, 'onChange'>;
|
|
19
|
+
/**
|
|
20
|
+
* Allow date in the past
|
|
21
|
+
*/
|
|
22
|
+
allowPastDate?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Custom event handler return value when a date is selected
|
|
25
|
+
*/
|
|
26
|
+
onChange?: (value: DateValue) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Language content override
|
|
29
|
+
*/
|
|
30
|
+
lang?: LanguageEntries;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Calendar component for selecting a date using react-aria. Supports full localization and accessibility.
|
|
34
|
+
* Uses the Gregorian calendar system.
|
|
35
|
+
*
|
|
36
|
+
* This component implements the react-aria `useCalendar` hook and supports controlled state
|
|
37
|
+
* ([docs](https://react-spectrum.adobe.com/react-aria/useCalendar.html))
|
|
38
|
+
*
|
|
39
|
+
* ## Features
|
|
40
|
+
* - Full keyboard navigation and screen reader support
|
|
41
|
+
* - Localization and internationalization
|
|
42
|
+
* - Configurable date restrictions (past dates, specific dates, date ranges)
|
|
43
|
+
* - Custom default values and date ranges
|
|
44
|
+
* - Flexible styling and theming
|
|
45
|
+
*
|
|
46
|
+
* ## Date Restrictions
|
|
47
|
+
* You can restrict date selection using the `calendar` prop with react-aria calendar properties:
|
|
48
|
+
* - `minValue` / `maxValue`: Define selectable date range
|
|
49
|
+
* - `isDateUnavailable`: Function to disable specific dates
|
|
50
|
+
* - `allowPastDate` prop: Convenient way to allow/disallow past dates
|
|
51
|
+
*
|
|
52
|
+
* ## Examples
|
|
53
|
+
* See the Calendar stories for comprehensive examples including:
|
|
54
|
+
* - Disabled specific dates and weekends
|
|
55
|
+
* - Disabled date ranges
|
|
56
|
+
* - Custom validation rules
|
|
57
|
+
* - Localization examples
|
|
58
|
+
*/
|
|
59
|
+
export declare const Calendar: {
|
|
60
|
+
({ allowPastDate, calendarOptions, lang, onChange, testId, }: CalendarProps): React.JSX.Element;
|
|
61
|
+
displayName: string;
|
|
62
|
+
};
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=Calendar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../../../lib/components/Calendar/Calendar.tsx"],"names":[],"mappings":"AAOA,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,EAGN,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAS9C,QAAA,MAAM,cAAc;;;CAGV,CAAC;AAEX,KAAK,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,OAAO,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;AAE5E,MAAM,WAAW,aAAc,SAAQ,UAAU;IAChD;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,CAAC;IACpE;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IACtC;;OAEG;IACH,IAAI,CAAC,EAAE,eAAe,CAAC;CACvB;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,QAAQ;kEAMlB,aAAa;;CA0Df,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
+
import { ChevronLeftIcon, ChevronRightIcon } from '@autoguru/icons';
|
|
7
|
+
import { getLocalTimeZone,
|
|
8
|
+
// currently only supporting western-style Gregorian calendar
|
|
9
|
+
GregorianCalendar, today } from '@internationalized/date';
|
|
10
|
+
import React, { useEffect, useRef } from 'react';
|
|
11
|
+
import { useCalendar, useLocale } from 'react-aria';
|
|
12
|
+
import { useCalendarState } from 'react-stately';
|
|
13
|
+
import { dataAttrs } from "../../utils/dataAttrs.js";
|
|
14
|
+
import { Icon } from "../Icon/index.js";
|
|
15
|
+
import { calendarStyle, titleStyle } from "./Calendar.css.js";
|
|
16
|
+
import { CalendarButton } from "./CalendarButton.js";
|
|
17
|
+
import { CalendarGrid } from "./CalendarGrid.js";
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
const FIRST_DAY_OF_WEEK = 'mon';
|
|
20
|
+
const defaultEnglish = {
|
|
21
|
+
nextLabel: 'Next month',
|
|
22
|
+
prevLabel: 'Previous month'
|
|
23
|
+
};
|
|
24
|
+
function createCalendar(identifier) {
|
|
25
|
+
if (identifier === 'gregory') {
|
|
26
|
+
return new GregorianCalendar();
|
|
27
|
+
}
|
|
28
|
+
throw new Error(`Unsupported calendar configured ${identifier}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Calendar component for selecting a date using react-aria. Supports full localization and accessibility.
|
|
33
|
+
* Uses the Gregorian calendar system.
|
|
34
|
+
*
|
|
35
|
+
* This component implements the react-aria `useCalendar` hook and supports controlled state
|
|
36
|
+
* ([docs](https://react-spectrum.adobe.com/react-aria/useCalendar.html))
|
|
37
|
+
*
|
|
38
|
+
* ## Features
|
|
39
|
+
* - Full keyboard navigation and screen reader support
|
|
40
|
+
* - Localization and internationalization
|
|
41
|
+
* - Configurable date restrictions (past dates, specific dates, date ranges)
|
|
42
|
+
* - Custom default values and date ranges
|
|
43
|
+
* - Flexible styling and theming
|
|
44
|
+
*
|
|
45
|
+
* ## Date Restrictions
|
|
46
|
+
* You can restrict date selection using the `calendar` prop with react-aria calendar properties:
|
|
47
|
+
* - `minValue` / `maxValue`: Define selectable date range
|
|
48
|
+
* - `isDateUnavailable`: Function to disable specific dates
|
|
49
|
+
* - `allowPastDate` prop: Convenient way to allow/disallow past dates
|
|
50
|
+
*
|
|
51
|
+
* ## Examples
|
|
52
|
+
* See the Calendar stories for comprehensive examples including:
|
|
53
|
+
* - Disabled specific dates and weekends
|
|
54
|
+
* - Disabled date ranges
|
|
55
|
+
* - Custom validation rules
|
|
56
|
+
* - Localization examples
|
|
57
|
+
*/
|
|
58
|
+
export const Calendar = ({
|
|
59
|
+
allowPastDate = false,
|
|
60
|
+
calendarOptions,
|
|
61
|
+
lang,
|
|
62
|
+
onChange,
|
|
63
|
+
testId
|
|
64
|
+
}) => {
|
|
65
|
+
var _lang$prevLabel, _lang$nextLabel;
|
|
66
|
+
const selectedDate = useRef(null);
|
|
67
|
+
const calendarComponentProps = _objectSpread({
|
|
68
|
+
defaultValue: today(getLocalTimeZone()),
|
|
69
|
+
firstDayOfWeek: FIRST_DAY_OF_WEEK,
|
|
70
|
+
minValue: allowPastDate ? undefined : today(getLocalTimeZone()),
|
|
71
|
+
onChange: value => {
|
|
72
|
+
selectedDate.current = value;
|
|
73
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
74
|
+
}
|
|
75
|
+
}, calendarOptions);
|
|
76
|
+
const {
|
|
77
|
+
locale
|
|
78
|
+
} = useLocale();
|
|
79
|
+
const state = useCalendarState(_objectSpread(_objectSpread({}, calendarComponentProps), {}, {
|
|
80
|
+
locale,
|
|
81
|
+
createCalendar
|
|
82
|
+
}));
|
|
83
|
+
const {
|
|
84
|
+
calendarProps,
|
|
85
|
+
prevButtonProps,
|
|
86
|
+
nextButtonProps,
|
|
87
|
+
title: calendarTitle
|
|
88
|
+
} = useCalendar(calendarComponentProps, state);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (state.value) {
|
|
91
|
+
selectedDate.current = state.value;
|
|
92
|
+
}
|
|
93
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- run only once
|
|
94
|
+
}, []);
|
|
95
|
+
return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({}, dataAttrs({
|
|
96
|
+
testid: testId
|
|
97
|
+
})), {}, {
|
|
98
|
+
children: [/*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({}, calendarProps), {}, {
|
|
99
|
+
className: calendarStyle,
|
|
100
|
+
children: [/*#__PURE__*/_jsx(CalendarButton, _objectSpread(_objectSpread({}, prevButtonProps), {}, {
|
|
101
|
+
"aria-label": (_lang$prevLabel = lang === null || lang === void 0 ? void 0 : lang.prevLabel) !== null && _lang$prevLabel !== void 0 ? _lang$prevLabel : defaultEnglish.prevLabel,
|
|
102
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
103
|
+
icon: ChevronLeftIcon,
|
|
104
|
+
size: "medium"
|
|
105
|
+
})
|
|
106
|
+
})), /*#__PURE__*/_jsx("h4", {
|
|
107
|
+
className: titleStyle,
|
|
108
|
+
children: calendarTitle
|
|
109
|
+
}), /*#__PURE__*/_jsx(CalendarButton, _objectSpread(_objectSpread({}, nextButtonProps), {}, {
|
|
110
|
+
"aria-label": (_lang$nextLabel = lang === null || lang === void 0 ? void 0 : lang.nextLabel) !== null && _lang$nextLabel !== void 0 ? _lang$nextLabel : defaultEnglish.nextLabel,
|
|
111
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
112
|
+
icon: ChevronRightIcon,
|
|
113
|
+
size: "medium"
|
|
114
|
+
})
|
|
115
|
+
}))]
|
|
116
|
+
})), /*#__PURE__*/_jsx(CalendarGrid, {
|
|
117
|
+
state: state,
|
|
118
|
+
firstDayOfWeek: calendarComponentProps.firstDayOfWeek
|
|
119
|
+
})]
|
|
120
|
+
}));
|
|
121
|
+
};
|
|
122
|
+
Calendar.displayName = 'Calendar';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CalendarButton.d.ts","sourceRoot":"","sources":["../../../lib/components/Calendar/CalendarButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiB,MAAM,OAAO,CAAC;AACtC,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAI7D,eAAO,MAAM,cAAc;YAAW,eAAe;;CAQpD,CAAC"}
|
|
@@ -5,7 +5,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
5
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
6
|
import React, { useRef } from 'react';
|
|
7
7
|
import { useButton } from 'react-aria';
|
|
8
|
-
import { buttonStyle } from "./
|
|
8
|
+
import { buttonStyle } from "./Calendar.css.js";
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
export const CalendarButton = props => {
|
|
11
11
|
const ref = useRef(null);
|
|
@@ -17,4 +17,5 @@ export const CalendarButton = props => {
|
|
|
17
17
|
ref: ref,
|
|
18
18
|
children: props.children
|
|
19
19
|
}));
|
|
20
|
-
};
|
|
20
|
+
};
|
|
21
|
+
CalendarButton.displayName = 'CalendarButton';
|
|
@@ -4,6 +4,9 @@ import type { CalendarState } from 'react-stately';
|
|
|
4
4
|
interface CalendarGridProps extends AriaCalendarGridProps {
|
|
5
5
|
state: CalendarState;
|
|
6
6
|
}
|
|
7
|
-
export declare const CalendarGrid:
|
|
7
|
+
export declare const CalendarGrid: {
|
|
8
|
+
({ state, ...props }: CalendarGridProps): React.JSX.Element;
|
|
9
|
+
displayName: string;
|
|
10
|
+
};
|
|
8
11
|
export {};
|
|
9
12
|
//# sourceMappingURL=CalendarGrid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CalendarGrid.d.ts","sourceRoot":"","sources":["../../../lib/components/Calendar/CalendarGrid.tsx"],"names":[],"mappings":"AACA,OAAO,KAAiB,MAAM,OAAO,CAAC;AACtC,OAAO,EAKN,KAAK,qBAAqB,EAC1B,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAyCnD,UAAU,iBAAkB,SAAQ,qBAAqB;IACxD,KAAK,EAAE,aAAa,CAAC;CACrB;AAED,eAAO,MAAM,YAAY;0BAAyB,iBAAiB;;CA2ClE,CAAC"}
|
|
@@ -10,7 +10,7 @@ import { getWeeksInMonth } from '@internationalized/date';
|
|
|
10
10
|
import React, { useRef } from 'react';
|
|
11
11
|
import { useCalendarCell, useCalendarGrid, useLocale } from 'react-aria';
|
|
12
12
|
import { dataAttrs } from "../../utils/dataAttrs.js";
|
|
13
|
-
import { calendarGridStyle, cellStyle, tdStyle, thStyle } from "./
|
|
13
|
+
import { calendarGridStyle, cellStyle, tdStyle, thStyle } from "./Calendar.css.js";
|
|
14
14
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
15
|
const CalendarCell = ({
|
|
16
16
|
state,
|
|
@@ -37,7 +37,7 @@ const CalendarCell = ({
|
|
|
37
37
|
}, dataAttrs({
|
|
38
38
|
selected: isSelected,
|
|
39
39
|
disabled: isDisabled,
|
|
40
|
-
|
|
40
|
+
unavailable: isUnavailable
|
|
41
41
|
})), {}, {
|
|
42
42
|
children: formattedDate
|
|
43
43
|
}))
|
|
@@ -61,10 +61,10 @@ export const CalendarGrid = _ref => {
|
|
|
61
61
|
className: calendarGridStyle,
|
|
62
62
|
children: [/*#__PURE__*/_jsx("thead", _objectSpread(_objectSpread({}, headerProps), {}, {
|
|
63
63
|
children: /*#__PURE__*/_jsx("tr", {
|
|
64
|
-
children: weekDays.map(day => /*#__PURE__*/_jsx("th", {
|
|
64
|
+
children: weekDays.map((day, index) => /*#__PURE__*/_jsx("th", {
|
|
65
65
|
className: thStyle,
|
|
66
66
|
children: day
|
|
67
|
-
},
|
|
67
|
+
}, index))
|
|
68
68
|
})
|
|
69
69
|
})), /*#__PURE__*/_jsx("tbody", {
|
|
70
70
|
children: _toConsumableArray(Array.from({
|
|
@@ -73,8 +73,9 @@ export const CalendarGrid = _ref => {
|
|
|
73
73
|
children: state.getDatesInWeek(weekIndex).map((date, idx) => date ? /*#__PURE__*/_jsx(CalendarCell, {
|
|
74
74
|
state: state,
|
|
75
75
|
date: date
|
|
76
|
-
},
|
|
76
|
+
}, `${date.year}-${date.month}-${date.day}`) : /*#__PURE__*/_jsx("td", {}, `empty-${weekIndex}-${idx}`))
|
|
77
77
|
}, weekIndex))
|
|
78
78
|
})]
|
|
79
79
|
}));
|
|
80
|
-
};
|
|
80
|
+
};
|
|
81
|
+
CalendarGrid.displayName = 'CalendarGrid';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/Calendar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
export declare const inputContainer: string;
|
|
1
2
|
export declare const input: string;
|
|
3
|
+
export declare const inputOverlay: string;
|
|
2
4
|
export declare const contents: Record<"default" | "withLabel", string>;
|
|
3
5
|
export declare const disabled: Record<"default" | "root", string>;
|
|
4
|
-
export declare const spinner: string;
|
|
5
6
|
//# sourceMappingURL=DatePicker.css.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.css.d.ts","sourceRoot":"","sources":["../../../lib/components/DatePicker/DatePicker.css.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DatePicker.css.d.ts","sourceRoot":"","sources":["../../../lib/components/DatePicker/DatePicker.css.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc,QAOzB,CAAC;AAEH,eAAO,MAAM,KAAK,QAsBhB,CAAC;AAEH,eAAO,MAAM,YAAY,QAQvB,CAAC;AAEH,eAAO,MAAM,QAAQ,yCAmBnB,CAAC;AAEH,eAAO,MAAM,QAAQ,oCAenB,CAAC"}
|
|
@@ -3,52 +3,82 @@
|
|
|
3
3
|
import * as __vanilla_filescope__ from '@vanilla-extract/css/fileScope';
|
|
4
4
|
__vanilla_filescope__.setFileScope("lib/components/DatePicker/DatePicker.css.ts", "@autoguru/overdrive");
|
|
5
5
|
import { style, styleVariants } from '@vanilla-extract/css';
|
|
6
|
+
import { cssLayerComponent } from "../../styles/layers.css.js";
|
|
6
7
|
import { overdriveTokens as vars } from "../../themes/theme.css.js";
|
|
8
|
+
export const inputContainer = style({
|
|
9
|
+
'@layer': {
|
|
10
|
+
[cssLayerComponent]: {
|
|
11
|
+
display: 'grid',
|
|
12
|
+
position: 'relative'
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}, "inputContainer");
|
|
7
16
|
export const input = style({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
left: 0,
|
|
11
|
-
opacity: 0,
|
|
12
|
-
right: 0,
|
|
13
|
-
top: 0,
|
|
14
|
-
selectors: {
|
|
15
|
-
'&::-webkit-calendar-picker-indicator': {
|
|
16
|
-
background: 'transparent',
|
|
17
|
-
bottom: 0,
|
|
18
|
-
color: 'transparent',
|
|
17
|
+
'@layer': {
|
|
18
|
+
[cssLayerComponent]: {
|
|
19
19
|
cursor: 'pointer',
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
position: '
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
gridArea: '1 / 1',
|
|
21
|
+
opacity: 0,
|
|
22
|
+
position: 'relative',
|
|
23
|
+
zIndex: 1,
|
|
24
|
+
selectors: {
|
|
25
|
+
'&::-webkit-calendar-picker-indicator': {
|
|
26
|
+
background: 'transparent',
|
|
27
|
+
color: 'transparent',
|
|
28
|
+
cursor: 'pointer',
|
|
29
|
+
height: '100%',
|
|
30
|
+
left: 0,
|
|
31
|
+
position: 'absolute',
|
|
32
|
+
top: 0,
|
|
33
|
+
width: '100%'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
26
36
|
}
|
|
27
37
|
}
|
|
28
38
|
}, "input");
|
|
39
|
+
export const inputOverlay = style({
|
|
40
|
+
'@layer': {
|
|
41
|
+
[cssLayerComponent]: {
|
|
42
|
+
gridArea: '1 / 1',
|
|
43
|
+
pointerEvents: 'none',
|
|
44
|
+
zIndex: 0
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}, "inputOverlay");
|
|
29
48
|
export const contents = styleVariants({
|
|
30
49
|
default: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
50
|
+
'@layer': {
|
|
51
|
+
[cssLayerComponent]: {
|
|
52
|
+
alignItems: 'center',
|
|
53
|
+
display: 'grid',
|
|
54
|
+
gridGap: vars.space['1'],
|
|
55
|
+
gridTemplateColumns: 'auto',
|
|
56
|
+
justifyContent: 'flex-start'
|
|
57
|
+
}
|
|
58
|
+
}
|
|
36
59
|
},
|
|
37
60
|
withLabel: {
|
|
38
|
-
|
|
61
|
+
'@layer': {
|
|
62
|
+
[cssLayerComponent]: {
|
|
63
|
+
gridTemplateColumns: 'auto auto'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
39
66
|
}
|
|
40
67
|
}, "contents");
|
|
41
68
|
export const disabled = styleVariants({
|
|
42
69
|
default: {
|
|
43
|
-
|
|
70
|
+
'@layer': {
|
|
71
|
+
[cssLayerComponent]: {
|
|
72
|
+
cursor: 'not-allowed'
|
|
73
|
+
}
|
|
74
|
+
}
|
|
44
75
|
},
|
|
45
76
|
root: {
|
|
46
|
-
|
|
77
|
+
'@layer': {
|
|
78
|
+
[cssLayerComponent]: {
|
|
79
|
+
opacity: '0.3'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
47
82
|
}
|
|
48
83
|
}, "disabled");
|
|
49
|
-
export const spinner = style({
|
|
50
|
-
left: '50%',
|
|
51
|
-
top: '50%',
|
|
52
|
-
transform: 'translate(-50%, -50%)'
|
|
53
|
-
}, "spinner");
|
|
54
84
|
__vanilla_filescope__.endFileScope();
|
|
@@ -1,15 +1,93 @@
|
|
|
1
1
|
import { IconType } from '@autoguru/icons';
|
|
2
|
-
import
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { TestIdProp } from '../../types';
|
|
4
|
+
import { type CalendarProps } from '../Calendar';
|
|
3
5
|
type SizeScale = 'small' | 'medium' | 'large';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
declare const defaultEnglish: {
|
|
7
|
+
readonly openCalendar: "open calendar";
|
|
8
|
+
};
|
|
9
|
+
type LanguageEntries = Partial<Record<keyof typeof defaultEnglish, string>>;
|
|
10
|
+
export interface DatePickerProps extends Pick<HTMLInputElement, 'id' | 'name'>, TestIdProp {
|
|
11
|
+
/**
|
|
12
|
+
* Options to customise the calendar: `allowPastDate`, `lang`, etc.
|
|
13
|
+
*/
|
|
14
|
+
calendarOptions?: Omit<CalendarProps, 'onChange'>;
|
|
6
15
|
className?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the picker is disabled and non-interactive
|
|
18
|
+
*/
|
|
7
19
|
disabled?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Icon to render inside the picker (defaults to calendar icon)
|
|
22
|
+
*/
|
|
8
23
|
icon?: IconType;
|
|
24
|
+
/**
|
|
25
|
+
* Show a loading state spinner instead of the icon
|
|
26
|
+
*/
|
|
9
27
|
isLoading?: boolean;
|
|
28
|
+
onChange(date: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* Visual size of the picker control (small, medium, large)
|
|
31
|
+
*/
|
|
32
|
+
size?: SizeScale;
|
|
33
|
+
/**
|
|
34
|
+
* Fallback label to display when no date value is selected.
|
|
35
|
+
*/
|
|
10
36
|
valueLabel?: string;
|
|
11
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Use native browser date picker instead of Calendar popover
|
|
39
|
+
*/
|
|
40
|
+
useNativePicker?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Language content override for DatePicker
|
|
43
|
+
*/
|
|
44
|
+
lang?: LanguageEntries;
|
|
12
45
|
}
|
|
13
|
-
|
|
46
|
+
/**
|
|
47
|
+
* The DatePicker has been updated to render the Calendar component with a Popover while
|
|
48
|
+
* maintaining backwards compatability.
|
|
49
|
+
*
|
|
50
|
+
* ## Props
|
|
51
|
+
* - Visual size controlled by `size` (small | medium | large)
|
|
52
|
+
* - Icon can be customized via the `icon` prop
|
|
53
|
+
*
|
|
54
|
+
* ## Event handling
|
|
55
|
+
* - `onChange` is always invoked with the raw ISO date string (or empty string when cleared)
|
|
56
|
+
*
|
|
57
|
+
* ## Compatibility mode
|
|
58
|
+
* - Setting `useNativePicker={true}` preserves the original browser-specific experience.
|
|
59
|
+
*
|
|
60
|
+
* ## Internationalization
|
|
61
|
+
* - Override text values via `lang={{ openCalendar: 'open calendar' }}`
|
|
62
|
+
* - Calendar options including `lang`can be passed via `calendarOptions` prop
|
|
63
|
+
* - Date formatting helper available in `...utils/dateFormat.ts` or use `@internationalized/date` utils
|
|
64
|
+
* - Advanced i18n and localization handled by [React Aria I18Provider](https://react-spectrum.adobe.com/react-aria/I18nProvider.html)
|
|
65
|
+
* - Read more about [International calendars](https://react-spectrum.adobe.com/react-aria/useDatePicker.html#international-calendars)
|
|
66
|
+
*
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* <DatePicker
|
|
70
|
+
* name="bookingDate"
|
|
71
|
+
* valueLabel="Select a date"
|
|
72
|
+
* onChange={(isoDate) => console.log('Selected date:', isoDate)}
|
|
73
|
+
* calendarOptions={{
|
|
74
|
+
* allowPastDate: false,
|
|
75
|
+
* weekdayFormat: 'short',
|
|
76
|
+
* }}
|
|
77
|
+
* />
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* // Native date picker usage
|
|
81
|
+
* <DatePicker
|
|
82
|
+
* name="startDate"
|
|
83
|
+
* useNativePicker
|
|
84
|
+
* value={initialDateISO} // e.g., "2025-03-12"
|
|
85
|
+
* onChange={(isoDate) => console.log('Native picked date:', isoDate)}
|
|
86
|
+
* />
|
|
87
|
+
*/
|
|
88
|
+
export declare const DatePicker: {
|
|
89
|
+
({ calendarOptions, className, disabled, icon, isLoading, lang, onChange, size, testId, useNativePicker, valueLabel, ...inputProps }: DatePickerProps): React.JSX.Element;
|
|
90
|
+
displayName: string;
|
|
91
|
+
};
|
|
14
92
|
export {};
|
|
15
93
|
//# sourceMappingURL=DatePicker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../lib/components/DatePicker/DatePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,QAAQ,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../lib/components/DatePicker/DatePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAQzD,OAAO,KAA8C,MAAM,OAAO,CAAC;AAInE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAS3D,KAAK,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE9C,QAAA,MAAM,cAAc;;CAEV,CAAC;AAEX,KAAK,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,OAAO,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;AAE5E,MAAM,WAAW,eAChB,SAAQ,IAAI,CAAC,gBAAgB,EAAE,IAAI,GAAG,MAAM,CAAC,EAC5C,UAAU;IACX;;OAEG;IACH,eAAe,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,eAAe,CAAC;CACvB;AAqBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,UAAU;0IAcpB,eAAe;;CA2HjB,CAAC"}
|