@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.
Files changed (62) hide show
  1. package/dist/components/Calendar/Calendar.css.d.ts +8 -0
  2. package/dist/components/Calendar/Calendar.css.d.ts.map +1 -0
  3. package/dist/components/Calendar/Calendar.css.js +113 -0
  4. package/dist/components/Calendar/Calendar.d.ts +64 -0
  5. package/dist/components/Calendar/Calendar.d.ts.map +1 -0
  6. package/dist/components/Calendar/Calendar.js +122 -0
  7. package/dist/components/Calendar/CalendarButton.d.ts +7 -0
  8. package/dist/components/Calendar/CalendarButton.d.ts.map +1 -0
  9. package/dist/components/{DateTimePicker → Calendar}/CalendarButton.js +3 -2
  10. package/dist/components/{DateTimePicker → Calendar}/CalendarGrid.d.ts +4 -1
  11. package/dist/components/Calendar/CalendarGrid.d.ts.map +1 -0
  12. package/dist/components/{DateTimePicker → Calendar}/CalendarGrid.js +7 -6
  13. package/dist/components/Calendar/index.d.ts +3 -0
  14. package/dist/components/Calendar/index.d.ts.map +1 -0
  15. package/dist/components/Calendar/index.js +3 -0
  16. package/dist/components/DatePicker/DatePicker.css.d.ts +2 -1
  17. package/dist/components/DatePicker/DatePicker.css.d.ts.map +1 -1
  18. package/dist/components/DatePicker/DatePicker.css.js +60 -30
  19. package/dist/components/DatePicker/DatePicker.d.ts +83 -5
  20. package/dist/components/DatePicker/DatePicker.d.ts.map +1 -1
  21. package/dist/components/DatePicker/DatePicker.js +160 -43
  22. package/dist/components/DateTimePicker/DateTimePicker.css.d.ts +0 -7
  23. package/dist/components/DateTimePicker/DateTimePicker.css.d.ts.map +1 -1
  24. package/dist/components/DateTimePicker/DateTimePicker.css.js +0 -110
  25. package/dist/components/DateTimePicker/DateTimePicker.d.ts +5 -2
  26. package/dist/components/DateTimePicker/DateTimePicker.d.ts.map +1 -1
  27. package/dist/components/DateTimePicker/DateTimePicker.js +24 -80
  28. package/dist/components/OptionList/OptionList.d.ts +5 -5
  29. package/dist/components/Popover/Popover.css.d.ts +4 -0
  30. package/dist/components/Popover/Popover.css.d.ts.map +1 -0
  31. package/dist/components/Popover/Popover.css.js +46 -0
  32. package/dist/components/Popover/Popover.d.ts +34 -0
  33. package/dist/components/Popover/Popover.d.ts.map +1 -0
  34. package/dist/components/Popover/Popover.js +127 -0
  35. package/dist/components/Popover/PopoverTrigger.d.ts +51 -0
  36. package/dist/components/Popover/PopoverTrigger.d.ts.map +1 -0
  37. package/dist/components/Popover/PopoverTrigger.js +94 -0
  38. package/dist/components/Popover/index.d.ts +5 -0
  39. package/dist/components/Popover/index.d.ts.map +1 -0
  40. package/dist/components/Popover/index.js +4 -0
  41. package/dist/components/Slider/Slider.css.d.ts +9 -0
  42. package/dist/components/Slider/Slider.css.d.ts.map +1 -0
  43. package/dist/components/Slider/Slider.css.js +92 -0
  44. package/dist/components/Slider/Slider.d.ts +47 -0
  45. package/dist/components/Slider/Slider.d.ts.map +1 -0
  46. package/dist/components/Slider/Slider.js +137 -0
  47. package/dist/components/Slider/index.d.ts +2 -0
  48. package/dist/components/Slider/index.d.ts.map +1 -0
  49. package/dist/components/Slider/index.js +3 -0
  50. package/dist/components/index.d.ts +1 -0
  51. package/dist/components/index.d.ts.map +1 -1
  52. package/dist/components/index.js +1 -0
  53. package/dist/styles/selectors.d.ts +2 -1
  54. package/dist/styles/selectors.d.ts.map +1 -1
  55. package/dist/styles/selectors.js +2 -1
  56. package/dist/utils/dateFormat.d.ts +24 -0
  57. package/dist/utils/dateFormat.d.ts.map +1 -0
  58. package/dist/utils/dateFormat.js +57 -0
  59. package/package.json +18 -18
  60. package/dist/components/DateTimePicker/CalendarButton.d.ts +0 -4
  61. package/dist/components/DateTimePicker/CalendarButton.d.ts.map +0 -1
  62. package/dist/components/DateTimePicker/CalendarGrid.d.ts.map +0 -1
@@ -2,74 +2,191 @@
2
2
 
3
3
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
- const _excluded = ["className", "icon", "size", "disabled", "isLoading", "valueLabel", "onChange"];
5
+ const _excluded = ["calendarOptions", "className", "disabled", "icon", "isLoading", "lang", "onChange", "size", "testId", "useNativePicker", "valueLabel"];
6
6
  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; }
7
7
  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; }
8
8
  import { CalendarIcon } from '@autoguru/icons';
9
+ import { getLocalTimeZone, parseDate, today } from '@internationalized/date';
9
10
  import clsx from 'clsx';
10
- import * as React from 'react';
11
- import { sprinkles } from "../../styles/index.js";
12
- import { Box } from "../Box/Box.js";
11
+ import React, { useMemo, useState } from 'react';
12
+ import { elementStyles } from "../../styles/elementStyles.js";
13
+ import { sprinkles } from "../../styles/sprinkles.css.js";
14
+ import { Calendar } from "../Calendar/index.js";
13
15
  import { Icon } from "../Icon/Icon.js";
16
+ import { PopoverTrigger } from "../Popover/index.js";
14
17
  import { ProgressSpinner } from "../ProgressSpinner/ProgressSpinner.js";
15
18
  import { Text } from "../Text/Text.js";
19
+ import { VisuallyHidden } from "../VisuallyHidden/VisuallyHidden.js";
16
20
  import * as styles from "./DatePicker.css.js";
17
21
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
+ const defaultEnglish = {
23
+ openCalendar: 'open calendar'
24
+ };
18
25
  const textSizeMap = {
19
26
  small: '2',
20
27
  medium: '3',
21
28
  large: '5'
22
29
  };
30
+ const formatDateToString = date => {
31
+ if (!date) return '';
32
+ return date.toString(); // ISO format: YYYY-MM-DD to match native input
33
+ };
34
+ const parseDateString = dateString => {
35
+ try {
36
+ return parseDate(dateString);
37
+ } catch {
38
+ return null;
39
+ }
40
+ };
41
+
42
+ /**
43
+ * The DatePicker has been updated to render the Calendar component with a Popover while
44
+ * maintaining backwards compatability.
45
+ *
46
+ * ## Props
47
+ * - Visual size controlled by `size` (small | medium | large)
48
+ * - Icon can be customized via the `icon` prop
49
+ *
50
+ * ## Event handling
51
+ * - `onChange` is always invoked with the raw ISO date string (or empty string when cleared)
52
+ *
53
+ * ## Compatibility mode
54
+ * - Setting `useNativePicker={true}` preserves the original browser-specific experience.
55
+ *
56
+ * ## Internationalization
57
+ * - Override text values via `lang={{ openCalendar: 'open calendar' }}`
58
+ * - Calendar options including `lang`can be passed via `calendarOptions` prop
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
+ *
64
+ * @example
65
+ * <DatePicker
66
+ * name="bookingDate"
67
+ * valueLabel="Select a date"
68
+ * onChange={(isoDate) => console.log('Selected date:', isoDate)}
69
+ * calendarOptions={{
70
+ * allowPastDate: false,
71
+ * weekdayFormat: 'short',
72
+ * }}
73
+ * />
74
+ *
75
+ * @example
76
+ * // Native date picker usage
77
+ * <DatePicker
78
+ * name="startDate"
79
+ * useNativePicker
80
+ * value={initialDateISO} // e.g., "2025-03-12"
81
+ * onChange={(isoDate) => console.log('Native picked date:', isoDate)}
82
+ * />
83
+ */
23
84
  export const DatePicker = _ref => {
85
+ var _lang$openCalendar;
24
86
  let {
25
- className = '',
26
- icon = CalendarIcon,
27
- size = 'medium',
87
+ calendarOptions,
88
+ className,
28
89
  disabled = false,
90
+ icon = CalendarIcon,
29
91
  isLoading = false,
30
- valueLabel,
31
- onChange
92
+ lang,
93
+ onChange,
94
+ size = 'medium',
95
+ testId,
96
+ useNativePicker = false,
97
+ valueLabel
32
98
  } = _ref,
33
99
  inputProps = _objectWithoutProperties(_ref, _excluded);
100
+ const [selectedDate, setSelectedDate] = useState(null);
101
+ const [popoverState, setPopoverState] = useState(null);
34
102
  const onChangeEvent = event => {
103
+ const dateString = event.currentTarget.value;
104
+ if (dateString) {
105
+ const parsedDate = parseDateString(dateString);
106
+ setSelectedDate(parsedDate);
107
+ } else {
108
+ setSelectedDate(null);
109
+ }
35
110
  if (typeof onChange === 'function') {
36
- onChange(event.currentTarget.value);
111
+ onChange(dateString);
37
112
  }
38
113
  };
39
- return /*#__PURE__*/_jsxs(Box, {
40
- position: "relative",
41
- overflow: "hidden",
42
- className: clsx(className, {
114
+ const containerStyle = elementStyles({
115
+ className: [className, {
43
116
  [styles.disabled.default]: disabled,
44
117
  [styles.disabled.root]: disabled
45
- }),
46
- children: [/*#__PURE__*/_jsx(Box, _objectSpread({
47
- as: "input",
48
- position: "absolute",
49
- height: "full",
50
- width: "full",
51
- disabled: disabled,
52
- onChange: onChangeEvent,
53
- className: clsx({
54
- [styles.disabled.default]: disabled
55
- }, styles.input),
56
- type: "date"
57
- }, inputProps)), /*#__PURE__*/_jsxs(Box, {
58
- className: clsx(styles.contents.default, {
59
- [styles.contents.withLabel]: Boolean(valueLabel)
60
- }),
61
- children: [isLoading ? /*#__PURE__*/_jsx(ProgressSpinner, {
62
- className: clsx(styles.spinner, sprinkles({
63
- position: 'absolute'
64
- })),
65
- size: size
66
- }) : /*#__PURE__*/_jsx(Icon, {
67
- icon: icon,
68
- size: size
69
- }), valueLabel && /*#__PURE__*/_jsx(Text, {
70
- size: textSizeMap[size],
71
- children: valueLabel
118
+ }]
119
+ });
120
+ const indicator = isLoading ? /*#__PURE__*/_jsx(ProgressSpinner, {
121
+ size: size
122
+ }) : /*#__PURE__*/_jsx(Icon, {
123
+ icon: icon,
124
+ size: size
125
+ });
126
+ const label = valueLabel ? /*#__PURE__*/_jsx(Text, {
127
+ size: textSizeMap[size],
128
+ children: valueLabel
129
+ }) : null;
130
+ const calendarProps = useMemo(() => ({
131
+ calendar: _objectSpread({
132
+ defaultValue: selectedDate || today(getLocalTimeZone())
133
+ }, calendarOptions),
134
+ onChange: date => {
135
+ setSelectedDate(date);
136
+ if (typeof onChange === 'function') {
137
+ onChange(formatDateToString(date));
138
+ }
139
+ // Close the popover after date selection
140
+ if (popoverState) {
141
+ popoverState.close();
142
+ }
143
+ }
144
+ }), [selectedDate, calendarOptions, onChange, popoverState]);
145
+ const contentCalendar = useMemo(() => /*#__PURE__*/_jsx(Calendar, _objectSpread({}, calendarProps)), [calendarProps]);
146
+
147
+ // Use native picker only if explicitly requested
148
+ if (useNativePicker) {
149
+ return /*#__PURE__*/_jsxs("div", {
150
+ className: clsx(containerStyle, styles.inputContainer),
151
+ children: [/*#__PURE__*/_jsx("input", _objectSpread(_objectSpread({}, inputProps), {}, {
152
+ className: elementStyles({
153
+ className: [styles.input, {
154
+ [styles.disabled.default]: disabled
155
+ }]
156
+ }),
157
+ type: "date",
158
+ disabled: disabled,
159
+ onChange: onChangeEvent
160
+ })), /*#__PURE__*/_jsx("div", {
161
+ className: styles.inputOverlay,
162
+ children: /*#__PURE__*/_jsxs("div", {
163
+ className: clsx(styles.contents.default, {
164
+ [styles.contents.withLabel]: Boolean(valueLabel)
165
+ }),
166
+ children: [indicator, label]
167
+ })
168
+ })]
169
+ });
170
+ }
171
+ return /*#__PURE__*/_jsxs("div", {
172
+ className: clsx(containerStyle, sprinkles({
173
+ display: 'flex',
174
+ alignItems: 'center',
175
+ gap: '1'
176
+ })),
177
+ children: [/*#__PURE__*/_jsxs(PopoverTrigger, {
178
+ content: contentCalendar,
179
+ placement: "bottom left",
180
+ testId: testId,
181
+ isDisabled: disabled,
182
+ onStateReady: setPopoverState,
183
+ children: [indicator, /*#__PURE__*/_jsx(VisuallyHidden, {
184
+ children: (_lang$openCalendar = lang === null || lang === void 0 ? void 0 : lang.openCalendar) !== null && _lang$openCalendar !== void 0 ? _lang$openCalendar : defaultEnglish.openCalendar
72
185
  })]
73
- })]
186
+ }), label, /*#__PURE__*/_jsx("input", _objectSpread(_objectSpread({}, inputProps), {}, {
187
+ value: formatDateToString(selectedDate),
188
+ type: "hidden"
189
+ }))]
74
190
  });
75
- };
191
+ };
192
+ DatePicker.displayName = 'DatePicker';
@@ -1,11 +1,4 @@
1
1
  export declare const queryContainer: string;
2
2
  export declare const queryContainerStyle: string;
3
3
  export declare const layoutStyle: string;
4
- export declare const calendarGridStyle: string;
5
- export declare const calendarStyle: string;
6
- export declare const cellStyle: string;
7
- export declare const buttonStyle: string;
8
- export declare const thStyle: string;
9
- export declare const tdStyle: string;
10
- export declare const titleStyle: string;
11
4
  //# sourceMappingURL=DateTimePicker.css.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimePicker.css.d.ts","sourceRoot":"","sources":["../../../lib/components/DateTimePicker/DateTimePicker.css.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,cAAc,QAAoB,CAAC;AAChD,eAAO,MAAM,mBAAmB,QAO9B,CAAC;AAEH,eAAO,MAAM,WAAW,QAWtB,CAAC;AAEH,eAAO,MAAM,iBAAiB,QAW5B,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"}
1
+ {"version":3,"file":"DateTimePicker.css.d.ts","sourceRoot":"","sources":["../../../lib/components/DateTimePicker/DateTimePicker.css.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,cAAc,QAAoB,CAAC;AAChD,eAAO,MAAM,mBAAmB,QAO9B,CAAC;AAEH,eAAO,MAAM,WAAW,QAWtB,CAAC"}
@@ -3,10 +3,7 @@
3
3
  import * as __vanilla_filescope__ from '@vanilla-extract/css/fileScope';
4
4
  __vanilla_filescope__.setFileScope("lib/components/DateTimePicker/DateTimePicker.css.ts", "@autoguru/overdrive");
5
5
  import { createContainer, style } from '@vanilla-extract/css';
6
- import { focusOutlineStyle } from "../../styles/focusOutline.css.js";
7
6
  import { cssLayerComponent } from "../../styles/layers.css.js";
8
- import { selectors } from "../../styles/selectors.js";
9
- import { sprinkles } from "../../styles/sprinkles.css.js";
10
7
  import { breakpoints } from "../../themes/makeTheme.js";
11
8
  import { overdriveTokens as tokens } from "../../themes/theme.css.js"; // === Container styles
12
9
  export const queryContainer = createContainer("queryContainer");
@@ -30,111 +27,4 @@ export const layoutStyle = style({
30
27
  }
31
28
  }
32
29
  }, "layoutStyle");
33
- export const calendarGridStyle = style({
34
- '@layer': {
35
- [cssLayerComponent]: {
36
- width: '100%',
37
- '@container': {
38
- [`${queryContainer} (min-width: ${breakpoints.tablet})`]: {
39
- width: 'auto'
40
- }
41
- }
42
- }
43
- }
44
- }, "calendarGridStyle");
45
- export const calendarStyle = style([sprinkles({
46
- alignItems: 'center',
47
- display: 'flex',
48
- justifyContent: 'spaceBetween',
49
- mb: '2',
50
- px: '1'
51
- })], "calendarStyle");
52
-
53
- // === Cell styles
54
-
55
- export const cellStyle = style([sprinkles({
56
- alignItems: 'center',
57
- display: 'flex',
58
- justifyContent: 'center',
59
- size: '7',
60
- borderRadius: 'md'
61
- }), {
62
- '@layer': {
63
- [cssLayerComponent]: {
64
- background: tokens.colours.background.body,
65
- color: tokens.colours.foreground.body,
66
- cursor: 'pointer',
67
- selectors: {
68
- [selectors.focusVisible]: {
69
- background: tokens.colours.gamut.gray200
70
- },
71
- [selectors.selected]: {
72
- background: tokens.colours.foreground.body,
73
- color: tokens.colours.background.body
74
- },
75
- [selectors.hoverNotSelected]: {
76
- background: tokens.colours.gamut.gray200
77
- },
78
- [selectors.disabled]: {
79
- background: tokens.colours.background.body,
80
- color: tokens.colours.gamut.gray400,
81
- cursor: 'default'
82
- }
83
- }
84
- }
85
- }
86
- }, focusOutlineStyle], "cellStyle");
87
-
88
- // === Button styles
89
-
90
- export const buttonStyle = style([sprinkles({
91
- alignItems: 'center',
92
- borderColour: 'gray',
93
- borderRadius: 'md',
94
- borderStyle: 'solid',
95
- borderWidth: '1',
96
- display: 'flex',
97
- justifyContent: 'center',
98
- padding: 'none',
99
- size: '7'
100
- }), {
101
- '@layer': {
102
- [cssLayerComponent]: {
103
- background: tokens.colours.background.body,
104
- color: tokens.colours.gamut.gray600,
105
- cursor: 'pointer',
106
- selectors: {
107
- [selectors.hoverNotDisabled]: {
108
- background: tokens.colours.gamut.gray200
109
- },
110
- [selectors.focusVisible]: {
111
- background: tokens.colours.gamut.gray200
112
- },
113
- [selectors.disabled]: {
114
- background: tokens.colours.background.body,
115
- borderColor: tokens.border.colours.light,
116
- color: tokens.colours.gamut.gray300,
117
- cursor: 'not-allowed'
118
- }
119
- }
120
- }
121
- }
122
- }, focusOutlineStyle], "buttonStyle");
123
- export const thStyle = style({
124
- '@layer': {
125
- [cssLayerComponent]: {
126
- color: tokens.colours.gamut.gray600
127
- }
128
- }
129
- }, "thStyle");
130
- export const tdStyle = sprinkles({
131
- padding: '1',
132
- textAlign: 'center'
133
- });
134
-
135
- // === Heading styles
136
- export const titleStyle = sprinkles({
137
- fontWeight: 'bold',
138
- margin: 'none'
139
- });
140
30
  __vanilla_filescope__.endFileScope();
@@ -26,7 +26,7 @@ export interface DateTimePickerProps<D extends DateValue> extends TestIdProp {
26
26
  * - `defaultValue`: Today's date
27
27
  * - `firstDayOfWeek`: Monday
28
28
  */
29
- calendar?: Exclude<AriaCalendarProps<D>, 'onChange'>;
29
+ calendarOptions?: Exclude<AriaCalendarProps<D>, 'onChange'>;
30
30
  /**
31
31
  * `OptionGrid` props used to generate the time picker items. Ensure to include a descriptive `label` value (for
32
32
  * assistive technology). Currently time options are not tied to the day selection.
@@ -60,6 +60,9 @@ export interface DateTimePickerProps<D extends DateValue> extends TestIdProp {
60
60
  * This component implements the react-aria `useCalendar` hook and supports controlled state as well
61
61
  * ([docs](https://react-spectrum.adobe.com/react-aria/useCalendar.html))
62
62
  */
63
- export declare const DateTimePicker: <D extends DateValue>({ allowPastDate, calendar, lang, onChange, timeOptions, title, testId, }: DateTimePickerProps<D>) => React.JSX.Element;
63
+ export declare const DateTimePicker: {
64
+ <D extends DateValue>({ allowPastDate, calendarOptions, lang, onChange, timeOptions, title, testId, }: DateTimePickerProps<D>): React.JSX.Element;
65
+ displayName: string;
66
+ };
64
67
  export {};
65
68
  //# sourceMappingURL=DateTimePicker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimePicker.d.ts","sourceRoot":"","sources":["../../../lib/components/DateTimePicker/DateTimePicker.tsx"],"names":[],"mappings":"AAOA,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,EAKN,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,MAAM,YAAY,CAAC;AAIpB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAI9C,OAAO,EAEN,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,MAAM,0BAA0B,CAAC;AAWlC,QAAA,MAAM,cAAc;;;;;CAKV,CAAC;AAEX,KAAK,WAAW,GAAG,MAAM,OAAO,cAAc,CAAC;AAC/C,MAAM,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,SAAS,CAAE,SAAQ,UAAU;IAC3E;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IACrD;;;OAGG;IACH,WAAW,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;IACzC;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC1C;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;CAC5C;AAgBD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,SAAS,EAAE,0EAQjD,mBAAmB,CAAC,CAAC,CAAC,sBAwHxB,CAAC"}
1
+ {"version":3,"file":"DateTimePicker.d.ts","sourceRoot":"","sources":["../../../lib/components/DateTimePicker/DateTimePicker.tsx"],"names":[],"mappings":"AACA,OAAO,KAAiB,MAAM,OAAO,CAAC;AACtC,OAAO,EAAS,KAAK,iBAAiB,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAI3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAI9C,OAAO,EAEN,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,MAAM,0BAA0B,CAAC;AAIlC,QAAA,MAAM,cAAc;;;;;CAKV,CAAC;AAEX,KAAK,WAAW,GAAG,MAAM,OAAO,cAAc,CAAC;AAC/C,MAAM,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,SAAS,CAAE,SAAQ,UAAU;IAC3E;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IAC5D;;;OAGG;IACH,WAAW,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;IACzC;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC1C;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;CAC5C;AAQD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc;KAAI,CAAC,SAAS,SAAS,mFAQ/C,mBAAmB,CAAC,CAAC,CAAC;;CA+ExB,CAAC"}
@@ -3,23 +3,15 @@
3
3
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
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
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,
12
- // useDateFormatter,
13
- useLocale, useId } from 'react-aria';
14
- import { useCalendarState } from 'react-stately';
6
+ import { getLocalTimeZone, today } from '@internationalized/date';
7
+ import React, { useRef } from 'react';
8
+ import { useId } from 'react-aria';
15
9
  import { sprinkles } from "../../styles/sprinkles.css.js";
16
10
  import { dataAttrs } from "../../utils/dataAttrs.js";
11
+ import { Calendar } from "../Calendar/index.js";
17
12
  import { Heading } from "../Heading/index.js";
18
- import { Icon } from "../Icon/index.js";
19
13
  import { OptionGrid } from "../OptionGrid/OptionGrid.js";
20
- import { CalendarButton } from "./CalendarButton.js";
21
- import { CalendarGrid } from "./CalendarGrid.js";
22
- import { calendarStyle, layoutStyle, queryContainerStyle, titleStyle } from "./DateTimePicker.css.js";
14
+ import { layoutStyle, queryContainerStyle } from "./DateTimePicker.css.js";
23
15
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
16
  const defaultEnglish = {
25
17
  dateLabel: 'Date',
@@ -27,13 +19,6 @@ const defaultEnglish = {
27
19
  nextLabel: 'Next month',
28
20
  prevLabel: 'Previous month'
29
21
  };
30
- function createCalendar(identifier) {
31
- if (identifier === 'gregory') {
32
- return new GregorianCalendar();
33
- }
34
- throw new Error(`Unsupported calendar configured ${identifier}`);
35
- }
36
-
37
22
  // const dateTextPunctuationEN = (text: string) =>
38
23
  // text
39
24
  // .split(' ')
@@ -54,15 +39,15 @@ function createCalendar(identifier) {
54
39
  */
55
40
  export const DateTimePicker = ({
56
41
  allowPastDate = false,
57
- calendar,
42
+ calendarOptions,
58
43
  lang,
59
44
  onChange,
60
45
  timeOptions,
61
46
  title,
62
47
  testId
63
48
  }) => {
64
- var _lang$dateLabel, _lang$prevLabel, _lang$nextLabel, _lang$timeLabel;
65
- const selectedDate = useRef(null);
49
+ var _lang$dateLabel, _lang$timeLabel;
50
+ const selectedDate = useRef(today(getLocalTimeZone()));
66
51
  const selectedTimeOption = useRef(null);
67
52
  const handleChange = () => {
68
53
  var _selectedTimeOption$c;
@@ -73,6 +58,10 @@ export const DateTimePicker = ({
73
58
  });
74
59
  }
75
60
  };
61
+ const handleDateChange = value => {
62
+ selectedDate.current = value;
63
+ handleChange();
64
+ };
76
65
  const handleTimeChange = keys => {
77
66
  if (keys === 'all') return;
78
67
  // we expect only a single value for time picker
@@ -80,15 +69,6 @@ export const DateTimePicker = ({
80
69
  selectedTimeOption.current = time;
81
70
  handleChange();
82
71
  };
83
- const calendarComponentProps = _objectSpread({
84
- defaultValue: today(getLocalTimeZone()),
85
- firstDayOfWeek: 'sun',
86
- minValue: allowPastDate ? undefined : today(getLocalTimeZone()),
87
- onChange: value => {
88
- selectedDate.current = value;
89
- handleChange();
90
- }
91
- }, calendar);
92
72
  const optionGridComponentProps = _objectSpread({
93
73
  columns: '3',
94
74
  onSelectionChange: handleTimeChange,
@@ -96,34 +76,13 @@ export const DateTimePicker = ({
96
76
  selectionMode: 'single',
97
77
  disallowEmptySelection: true
98
78
  }, timeOptions);
99
- const {
100
- locale
101
- } = useLocale();
102
- const state = useCalendarState(_objectSpread(_objectSpread({}, calendarComponentProps), {}, {
103
- locale,
104
- createCalendar
105
- }));
106
- const {
107
- calendarProps,
108
- prevButtonProps,
109
- nextButtonProps,
110
- title: calendarTitle
111
- } = useCalendar(calendarComponentProps, state);
112
79
  const titleId = useId();
113
- useEffect(() => {
114
- if (state.value) {
115
- selectedDate.current = state.value;
116
- }
117
- // eslint-disable-next-line react-hooks/exhaustive-deps -- run only once
118
- }, []);
119
-
120
- // const formatter = useDateFormatter({ dateStyle: 'full' });
121
- // const dateText = state.value
122
- // ? dateTextPunctuationEN(
123
- // formatter.format(state?.value?.toDate(getLocalTimeZone())),
124
- // )
125
- // : '';
126
80
 
81
+ // Create calendar lang props from our lang props
82
+ const calendarLang = lang ? {
83
+ nextLabel: lang.nextLabel,
84
+ prevLabel: lang.prevLabel
85
+ } : undefined;
127
86
  return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({
128
87
  role: "group",
129
88
  "aria-labelledby": titleId,
@@ -148,27 +107,11 @@ export const DateTimePicker = ({
148
107
  mb: "4",
149
108
  size: "6",
150
109
  children: (_lang$dateLabel = lang === null || lang === void 0 ? void 0 : lang.dateLabel) !== null && _lang$dateLabel !== void 0 ? _lang$dateLabel : defaultEnglish.dateLabel
151
- }), /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({}, calendarProps), {}, {
152
- className: calendarStyle,
153
- children: [/*#__PURE__*/_jsx(CalendarButton, _objectSpread(_objectSpread({}, prevButtonProps), {}, {
154
- "aria-label": (_lang$prevLabel = lang === null || lang === void 0 ? void 0 : lang.prevLabel) !== null && _lang$prevLabel !== void 0 ? _lang$prevLabel : defaultEnglish.prevLabel,
155
- children: /*#__PURE__*/_jsx(Icon, {
156
- icon: ChevronLeftIcon,
157
- size: "medium"
158
- })
159
- })), /*#__PURE__*/_jsx("h4", {
160
- className: titleStyle,
161
- children: calendarTitle
162
- }), /*#__PURE__*/_jsx(CalendarButton, _objectSpread(_objectSpread({}, nextButtonProps), {}, {
163
- "aria-label": (_lang$nextLabel = lang === null || lang === void 0 ? void 0 : lang.nextLabel) !== null && _lang$nextLabel !== void 0 ? _lang$nextLabel : defaultEnglish.nextLabel,
164
- children: /*#__PURE__*/_jsx(Icon, {
165
- icon: ChevronRightIcon,
166
- size: "medium"
167
- })
168
- }))]
169
- })), /*#__PURE__*/_jsx(CalendarGrid, {
170
- state: state,
171
- firstDayOfWeek: calendarComponentProps.firstDayOfWeek
110
+ }), /*#__PURE__*/_jsx(Calendar, {
111
+ allowPastDate: allowPastDate,
112
+ calendarOptions: calendarOptions,
113
+ lang: calendarLang,
114
+ onChange: handleDateChange
172
115
  })]
173
116
  }), /*#__PURE__*/_jsxs("div", {
174
117
  className: sprinkles({
@@ -183,4 +126,5 @@ export const DateTimePicker = ({
183
126
  })]
184
127
  })]
185
128
  }));
186
- };
129
+ };
130
+ DateTimePicker.displayName = 'DateTimePicker';
@@ -60,18 +60,18 @@ export declare const OptionList: {
60
60
  onKeyDown?: ((e: import("@react-types/shared").KeyboardEvent) => void) | undefined;
61
61
  onKeyUp?: ((e: import("@react-types/shared").KeyboardEvent) => void) | undefined;
62
62
  onClick?: ((e: React.MouseEvent<import("@react-types/shared").FocusableElement>) => void) | undefined;
63
+ excludeFromTabOrder?: boolean | undefined;
63
64
  isDisabled?: boolean | undefined;
64
- isReadOnly?: boolean | undefined;
65
+ isRequired?: boolean | undefined;
66
+ isInvalid?: boolean | undefined;
67
+ validationState?: import("react-stately").ValidationState | undefined;
65
68
  onFocusChange?: ((isFocused: boolean) => void) | undefined;
66
- excludeFromTabOrder?: boolean | undefined;
69
+ isReadOnly?: boolean | undefined;
67
70
  onPress?: ((e: import("react-aria").PressEvent) => void) | undefined;
68
71
  onPressStart?: ((e: import("react-aria").PressEvent) => void) | undefined;
69
72
  onPressEnd?: ((e: import("react-aria").PressEvent) => void) | undefined;
70
73
  onPressChange?: ((isPressed: boolean) => void) | undefined;
71
74
  onPressUp?: ((e: import("react-aria").PressEvent) => void) | undefined;
72
- isRequired?: boolean | undefined;
73
- isInvalid?: boolean | undefined;
74
- validationState?: import("react-stately").ValidationState | undefined;
75
75
  validationBehavior?: "aria" | "native" | undefined;
76
76
  validate?: ((value: boolean) => import("@react-types/shared").ValidationError | true | null | undefined) | undefined;
77
77
  }): React.JSX.Element;
@@ -0,0 +1,4 @@
1
+ export declare const overlayStyle: string;
2
+ export declare const triggerStyle: string;
3
+ export declare const fullScreenStyle: string;
4
+ //# sourceMappingURL=Popover.css.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Popover.css.d.ts","sourceRoot":"","sources":["../../../lib/components/Popover/Popover.css.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY,QAiBvB,CAAC;AAEH,eAAO,MAAM,YAAY,QASvB,CAAC;AAEH,eAAO,MAAM,eAAe,QAW1B,CAAC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ import * as __vanilla_filescope__ from '@vanilla-extract/css/fileScope';
4
+ __vanilla_filescope__.setFileScope("lib/components/Popover/Popover.css.ts", "@autoguru/overdrive");
5
+ import { style } from '@vanilla-extract/css';
6
+ import { cssLayerComponent } from "../../styles/layers.css.js";
7
+ import { sprinkles } from "../../styles/sprinkles.css.js";
8
+ import { overdriveTokens as tokens } from "../../themes/theme.css.js";
9
+ export const overlayStyle = style([sprinkles({
10
+ borderRadius: 'md',
11
+ borderWidth: '1',
12
+ borderStyle: 'solid',
13
+ borderColour: 'light',
14
+ padding: '4'
15
+ }), {
16
+ '@layer': {
17
+ [cssLayerComponent]: {
18
+ backgroundColor: tokens.colours.background.body,
19
+ boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
20
+ minWidth: '280px'
21
+ }
22
+ }
23
+ }], "overlayStyle");
24
+ export const triggerStyle = style({
25
+ '@layer': {
26
+ [cssLayerComponent]: {
27
+ background: 'transparent',
28
+ border: 'none',
29
+ cursor: 'pointer',
30
+ padding: 0
31
+ }
32
+ }
33
+ }, "triggerStyle");
34
+ export const fullScreenStyle = style({
35
+ '@layer': {
36
+ [cssLayerComponent]: {
37
+ backgroundColor: tokens.colours.background.body,
38
+ bottom: 0,
39
+ left: 0,
40
+ position: 'fixed',
41
+ right: 0,
42
+ top: 0
43
+ }
44
+ }
45
+ }, "fullScreenStyle");
46
+ __vanilla_filescope__.endFileScope();