@autoguru/overdrive 4.46.0 → 4.47.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/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 +69 -0
- package/dist/components/Calendar/Calendar.d.ts.map +1 -0
- package/dist/components/Calendar/Calendar.js +129 -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 +106 -5
- package/dist/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/components/DatePicker/DatePicker.js +188 -44
- 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 +141 -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,69 @@
|
|
|
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
|
+
* ## Working with dates
|
|
47
|
+
* - Use `parseDate('YYYY-MM-DD')` from `@internationalized/date` to create
|
|
48
|
+
* DateValue objects.
|
|
49
|
+
* - Other useful utilities include `today(getLocalTimeZone())` for current
|
|
50
|
+
* date, and `date.add({ days: 7, months: 1 })` for date arithmetic.
|
|
51
|
+
*
|
|
52
|
+
* ## Date Restrictions
|
|
53
|
+
* You can restrict date selection using the `calendar` prop with react-aria calendar properties:
|
|
54
|
+
* - `minValue` / `maxValue`: Define selectable date range
|
|
55
|
+
* - `isDateUnavailable`: Function to disable specific dates
|
|
56
|
+
* - `allowPastDate` prop: Convenient way to allow/disallow past dates
|
|
57
|
+
*
|
|
58
|
+
* ## Internationalization
|
|
59
|
+
* - Override text values via `lang={{ openCalendar: 'open calendar' }}`
|
|
60
|
+
* - Date formatting helper available in `...utils/dateFormat.ts` or use `@internationalized/date` utils
|
|
61
|
+
* - Advanced i18n and localization handled by [React Aria I18Provider](https://react-spectrum.adobe.com/react-aria/I18nProvider.html)
|
|
62
|
+
* - Read more about [International calendars](https://react-spectrum.adobe.com/react-aria/useDatePicker.html#international-calendars)
|
|
63
|
+
*/
|
|
64
|
+
export declare const Calendar: {
|
|
65
|
+
({ allowPastDate, calendarOptions, lang, onChange, testId, }: CalendarProps): React.JSX.Element;
|
|
66
|
+
displayName: string;
|
|
67
|
+
};
|
|
68
|
+
export {};
|
|
69
|
+
//# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,QAAQ;kEAMlB,aAAa;;CA8Df,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
* ## Working with dates
|
|
46
|
+
* - Use `parseDate('YYYY-MM-DD')` from `@internationalized/date` to create
|
|
47
|
+
* DateValue objects.
|
|
48
|
+
* - Other useful utilities include `today(getLocalTimeZone())` for current
|
|
49
|
+
* date, and `date.add({ days: 7, months: 1 })` for date arithmetic.
|
|
50
|
+
*
|
|
51
|
+
* ## Date Restrictions
|
|
52
|
+
* You can restrict date selection using the `calendar` prop with react-aria calendar properties:
|
|
53
|
+
* - `minValue` / `maxValue`: Define selectable date range
|
|
54
|
+
* - `isDateUnavailable`: Function to disable specific dates
|
|
55
|
+
* - `allowPastDate` prop: Convenient way to allow/disallow past dates
|
|
56
|
+
*
|
|
57
|
+
* ## Internationalization
|
|
58
|
+
* - Override text values via `lang={{ openCalendar: 'open calendar' }}`
|
|
59
|
+
* - Date formatting helper available in `...utils/dateFormat.ts` or use `@internationalized/date` utils
|
|
60
|
+
* - Advanced i18n and localization handled by [React Aria I18Provider](https://react-spectrum.adobe.com/react-aria/I18nProvider.html)
|
|
61
|
+
* - Read more about [International calendars](https://react-spectrum.adobe.com/react-aria/useDatePicker.html#international-calendars)
|
|
62
|
+
*/
|
|
63
|
+
export const Calendar = ({
|
|
64
|
+
allowPastDate = false,
|
|
65
|
+
calendarOptions,
|
|
66
|
+
lang,
|
|
67
|
+
onChange,
|
|
68
|
+
testId
|
|
69
|
+
}) => {
|
|
70
|
+
var _lang$prevLabel, _lang$nextLabel;
|
|
71
|
+
const selectedDate = useRef(null);
|
|
72
|
+
const hasValue = !!(calendarOptions !== null && calendarOptions !== void 0 && calendarOptions.value) || !!(calendarOptions !== null && calendarOptions !== void 0 && calendarOptions.defaultValue);
|
|
73
|
+
const fallbackDefaultValue = hasValue ? {} : {
|
|
74
|
+
defaultValue: today(getLocalTimeZone())
|
|
75
|
+
};
|
|
76
|
+
const calendarComponentProps = _objectSpread(_objectSpread({
|
|
77
|
+
firstDayOfWeek: FIRST_DAY_OF_WEEK,
|
|
78
|
+
minValue: allowPastDate ? undefined : today(getLocalTimeZone()),
|
|
79
|
+
onChange: value => {
|
|
80
|
+
selectedDate.current = value;
|
|
81
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
82
|
+
}
|
|
83
|
+
}, calendarOptions), fallbackDefaultValue);
|
|
84
|
+
const {
|
|
85
|
+
locale
|
|
86
|
+
} = useLocale();
|
|
87
|
+
const state = useCalendarState(_objectSpread(_objectSpread({}, calendarComponentProps), {}, {
|
|
88
|
+
locale,
|
|
89
|
+
createCalendar
|
|
90
|
+
}));
|
|
91
|
+
const {
|
|
92
|
+
calendarProps,
|
|
93
|
+
prevButtonProps,
|
|
94
|
+
nextButtonProps,
|
|
95
|
+
title: calendarTitle
|
|
96
|
+
} = useCalendar(calendarComponentProps, state);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (state.value) {
|
|
99
|
+
selectedDate.current = state.value;
|
|
100
|
+
}
|
|
101
|
+
}, [state.value]);
|
|
102
|
+
return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({}, dataAttrs({
|
|
103
|
+
testid: testId
|
|
104
|
+
})), {}, {
|
|
105
|
+
children: [/*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({}, calendarProps), {}, {
|
|
106
|
+
className: calendarStyle,
|
|
107
|
+
children: [/*#__PURE__*/_jsx(CalendarButton, _objectSpread(_objectSpread({}, prevButtonProps), {}, {
|
|
108
|
+
"aria-label": (_lang$prevLabel = lang === null || lang === void 0 ? void 0 : lang.prevLabel) !== null && _lang$prevLabel !== void 0 ? _lang$prevLabel : defaultEnglish.prevLabel,
|
|
109
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
110
|
+
icon: ChevronLeftIcon,
|
|
111
|
+
size: "medium"
|
|
112
|
+
})
|
|
113
|
+
})), /*#__PURE__*/_jsx("h4", {
|
|
114
|
+
className: titleStyle,
|
|
115
|
+
children: calendarTitle
|
|
116
|
+
}), /*#__PURE__*/_jsx(CalendarButton, _objectSpread(_objectSpread({}, nextButtonProps), {}, {
|
|
117
|
+
"aria-label": (_lang$nextLabel = lang === null || lang === void 0 ? void 0 : lang.nextLabel) !== null && _lang$nextLabel !== void 0 ? _lang$nextLabel : defaultEnglish.nextLabel,
|
|
118
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
119
|
+
icon: ChevronRightIcon,
|
|
120
|
+
size: "medium"
|
|
121
|
+
})
|
|
122
|
+
}))]
|
|
123
|
+
})), /*#__PURE__*/_jsx(CalendarGrid, {
|
|
124
|
+
state: state,
|
|
125
|
+
firstDayOfWeek: calendarComponentProps.firstDayOfWeek
|
|
126
|
+
})]
|
|
127
|
+
}));
|
|
128
|
+
};
|
|
129
|
+
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();
|