@autoguru/overdrive 4.49.0 → 4.51.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 (63) hide show
  1. package/dist/components/Box/useBox/useBox.d.ts +1 -1
  2. package/dist/components/Calendar/Calendar.css.d.ts.map +1 -1
  3. package/dist/components/Calendar/Calendar.css.js +4 -4
  4. package/dist/components/Calendar/Calendar.d.ts +3 -10
  5. package/dist/components/Calendar/Calendar.d.ts.map +1 -1
  6. package/dist/components/Calendar/Calendar.js +4 -11
  7. package/dist/components/DatePicker/DatePicker.d.ts +10 -4
  8. package/dist/components/DatePicker/DatePicker.d.ts.map +1 -1
  9. package/dist/components/DatePicker/DatePicker.js +36 -63
  10. package/dist/components/DatePicker/hooks/useCalendarPopover.d.ts +38 -0
  11. package/dist/components/DatePicker/hooks/useCalendarPopover.d.ts.map +1 -0
  12. package/dist/components/DatePicker/hooks/useCalendarPopover.js +44 -0
  13. package/dist/components/DateTimeField/DateField/DateField.d.ts +40 -0
  14. package/dist/components/DateTimeField/DateField/DateField.d.ts.map +1 -0
  15. package/dist/components/DateTimeField/DateField/DateField.js +110 -0
  16. package/dist/components/DateTimeField/DateTimeField.css.d.ts +21 -0
  17. package/dist/components/DateTimeField/DateTimeField.css.d.ts.map +1 -0
  18. package/dist/components/DateTimeField/DateTimeField.css.js +127 -0
  19. package/dist/components/DateTimeField/DateTimeField.d.ts +116 -0
  20. package/dist/components/DateTimeField/DateTimeField.d.ts.map +1 -0
  21. package/dist/components/DateTimeField/DateTimeField.js +107 -0
  22. package/dist/components/DateTimeField/TimeField/TimeField.d.ts +26 -0
  23. package/dist/components/DateTimeField/TimeField/TimeField.d.ts.map +1 -0
  24. package/dist/components/DateTimeField/TimeField/TimeField.js +99 -0
  25. package/dist/components/DateTimeField/default.d.ts +2 -0
  26. package/dist/components/DateTimeField/default.d.ts.map +1 -0
  27. package/dist/components/DateTimeField/default.js +3 -0
  28. package/dist/components/DateTimeField/index.d.ts +5 -0
  29. package/dist/components/DateTimeField/index.d.ts.map +1 -0
  30. package/dist/components/DateTimeField/index.js +5 -0
  31. package/dist/components/DateTimeField/types.d.ts +34 -0
  32. package/dist/components/DateTimeField/types.d.ts.map +1 -0
  33. package/dist/components/DateTimeField/types.js +3 -0
  34. package/dist/components/DropDown/DropDown.d.ts +1 -0
  35. package/dist/components/DropDown/DropDown.d.ts.map +1 -1
  36. package/dist/components/DropDown/DropDown.js +23 -7
  37. package/dist/components/Popover/Popover.d.ts +2 -2
  38. package/dist/components/Popover/Popover.d.ts.map +1 -1
  39. package/dist/components/Popover/Popover.js +2 -2
  40. package/dist/components/Popover/PopoverTrigger.d.ts +9 -6
  41. package/dist/components/Popover/PopoverTrigger.d.ts.map +1 -1
  42. package/dist/components/Popover/PopoverTrigger.js +6 -3
  43. package/dist/components/index.d.ts +2 -0
  44. package/dist/components/index.d.ts.map +1 -1
  45. package/dist/components/index.js +2 -0
  46. package/dist/styles/selectors.d.ts +1 -0
  47. package/dist/styles/selectors.d.ts.map +1 -1
  48. package/dist/styles/selectors.js +1 -0
  49. package/dist/utils/dateFormat.d.ts +5 -4
  50. package/dist/utils/dateFormat.d.ts.map +1 -1
  51. package/dist/utils/dateFormat.js +9 -9
  52. package/dist/utils/responsiveStyle.d.ts +1 -1
  53. package/dist/utils/responsiveStyle.d.ts.map +1 -1
  54. package/package.json +42 -42
  55. package/dist/components/DateTimePicker/DateTimePicker.css.d.ts +0 -4
  56. package/dist/components/DateTimePicker/DateTimePicker.css.d.ts.map +0 -1
  57. package/dist/components/DateTimePicker/DateTimePicker.css.js +0 -30
  58. package/dist/components/DateTimePicker/DateTimePicker.d.ts +0 -68
  59. package/dist/components/DateTimePicker/DateTimePicker.d.ts.map +0 -1
  60. package/dist/components/DateTimePicker/DateTimePicker.js +0 -130
  61. package/dist/components/DateTimePicker/default.d.ts +0 -2
  62. package/dist/components/DateTimePicker/default.d.ts.map +0 -1
  63. package/dist/components/DateTimePicker/default.js +0 -3
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+
3
+ import * as __vanilla_filescope__ from '@vanilla-extract/css/fileScope';
4
+ __vanilla_filescope__.setFileScope("lib/components/DateTimeField/DateTimeField.css.ts", "@autoguru/overdrive");
5
+ import { style } from '@vanilla-extract/css';
6
+ import { recipe } from '@vanilla-extract/recipes';
7
+ import { focusOutline, focusOutlineStyle } from "../../styles/focusOutline.css.js";
8
+ import { cssLayerComponent } from "../../styles/layers.css.js";
9
+ import { selectors } from "../../styles/selectors.js";
10
+ import { sprinkles } from "../../styles/sprinkles.css.js";
11
+ import { textStyles } from "../../styles/typography.js";
12
+ import { overdriveTokens } from "../../themes/index.js";
13
+ const baseFieldStyle = style([sprinkles({
14
+ backgroundColor: 'page',
15
+ borderColor: 'default',
16
+ borderRadius: 'lg',
17
+ borderStyle: 'solid',
18
+ borderWidth: '1',
19
+ display: 'flex',
20
+ flexDirection: 'column',
21
+ justifyContent: 'space-between',
22
+ padding: '3',
23
+ position: 'relative',
24
+ textAlign: 'left'
25
+ }), {
26
+ '@layer': {
27
+ [cssLayerComponent]: {
28
+ transition: `border-color 0.2s ${overdriveTokens.animation.easing.decelerate} 0s`,
29
+ selectors: {
30
+ [selectors.hover]: {
31
+ cursor: 'pointer'
32
+ },
33
+ [`&:hover:not(${selectors.disabled}, ${selectors.invalid})`]: {
34
+ borderColor: overdriveTokens.border.colours.dark
35
+ },
36
+ [selectors.invalid]: {
37
+ borderColor: overdriveTokens.color.surface.danger
38
+ },
39
+ [`${selectors.hoverNotDisabled}, ${selectors.invalid}, ${selectors.focusVisible}`]: {
40
+ zIndex: '1'
41
+ },
42
+ [selectors.disabled]: {
43
+ cursor: 'not-allowed'
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }], "baseFieldStyle");
49
+ export const dateFieldStyle = style([baseFieldStyle, {
50
+ '@layer': {
51
+ [cssLayerComponent]: {
52
+ appearance: 'none',
53
+ borderBottomLeftRadius: 0,
54
+ borderBottomRightRadius: 0,
55
+ width: '100%'
56
+ }
57
+ }
58
+ }, focusOutlineStyle], "dateFieldStyle");
59
+ export const timeFieldStyle = style([baseFieldStyle, {
60
+ '@layer': {
61
+ [cssLayerComponent]: {
62
+ borderTopLeftRadius: 0,
63
+ borderTopRightRadius: 0,
64
+ marginTop: '-1px',
65
+ selectors: {
66
+ ['&:focus-within:not(:hover)']: focusOutline
67
+ }
68
+ }
69
+ }
70
+ }], "timeFieldStyle");
71
+ export const labelVariants = recipe({
72
+ base: [textStyles({
73
+ align: 'left',
74
+ size: '2',
75
+ transform: 'uppercase',
76
+ weight: 'bold'
77
+ }), {
78
+ userSelect: 'none'
79
+ }],
80
+ variants: {
81
+ invalid: {
82
+ true: sprinkles({
83
+ color: 'danger'
84
+ })
85
+ },
86
+ disabled: {
87
+ true: {
88
+ '@layer': {
89
+ [cssLayerComponent]: {
90
+ color: overdriveTokens.colours.gamut.black400
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }, "labelVariants");
97
+ export const inputResetStyle = style([{
98
+ '@layer': {
99
+ [cssLayerComponent]: {
100
+ appearance: 'none',
101
+ backgroundColor: 'transparent',
102
+ border: 'none',
103
+ cursor: 'pointer',
104
+ minHeight: overdriveTokens.space[6],
105
+ outline: 'none',
106
+ width: '100%'
107
+ }
108
+ }
109
+ }], "inputResetStyle");
110
+ export const valueStyle = textStyles({
111
+ size: '4',
112
+ transform: 'capitalize'
113
+ });
114
+ export const inputStyle = style([inputResetStyle, valueStyle, {
115
+ '@layer': {
116
+ [cssLayerComponent]: {
117
+ selectors: {
118
+ [selectors.disabled]: {
119
+ color: overdriveTokens.colours.gamut.black300,
120
+ cursor: 'not-allowed',
121
+ opacity: 1
122
+ }
123
+ }
124
+ }
125
+ }
126
+ }], "inputStyle");
127
+ __vanilla_filescope__.endFileScope();
@@ -0,0 +1,116 @@
1
+ import React from 'react';
2
+ import { type UseBoxProps } from '../Box';
3
+ export interface DateTimeFieldProps extends Pick<UseBoxProps, 'as' | 'className' | 'testId'> {
4
+ /**
5
+ * The DateField and TimeField components to render as children.
6
+ * This allows for maximum flexibility in configuration.
7
+ *
8
+ * ```tsx
9
+ * <DateField
10
+ * allowPastDate={false}
11
+ * calendarOptions={{
12
+ * minValue: today(getLocalTimeZone()),
13
+ * isDateUnavailable: (date) => date.day === 0 // Disable Sundays
14
+ * }}
15
+ * name="booking-1-date"
16
+ * onChange={setDateValue}
17
+ * disabled={isSubmitting}
18
+ * />
19
+ * <TimeField
20
+ * timeOptions={timeOptions}
21
+ * name="booking-1-time"
22
+ * onChange={setTimeValue}
23
+ * disabled={isSubmitting}
24
+ * />
25
+ * ```
26
+ */
27
+ children: React.ReactNode;
28
+ }
29
+ /**
30
+ * DateTimeField is a layout-only wrapper component that provides structure for DateField and TimeField components.
31
+ * It doesn't manage state or provide functionality. This allows for simple direct control and updates to each field.
32
+ *
33
+ * All props (name, disabled, loading, etc.) should be passed directly to the individual DateField and TimeField components.
34
+ *
35
+ * ## Child Components
36
+ * - **DateField**: Handles date selection with calendar popover functionality
37
+ * - **TimeField**: Handles time selection from predefined options
38
+ *
39
+ * ## State
40
+ * - **Uncontrolled** (recommended): Pass `defaultValue` prop
41
+ * - **Controlled**: Pass `value` prop
42
+ *
43
+ * ## Internationalization
44
+ * - Override text values via `lang` props on the DateField and TimeField components
45
+ * - Full Calendar options available via `calendarOptions` prop on the DateField
46
+ * - Date formatting helper available in `...utils/dateFormat.ts` or use `@internationalized/date` utils
47
+ * - Advanced i18n and localization handled by [React Aria I18Provider](https://react-spectrum.adobe.com/react-aria/I18nProvider.html)
48
+ * - Read more about [International calendars](https://react-spectrum.adobe.com/react-aria/useDatePicker.html#international-calendars)
49
+ *
50
+ * @example
51
+ * // Basic usage with separate date and time selectors
52
+ * const timeOptions = [
53
+ * { label: '9:00 AM', name: '0900' },
54
+ * { label: '2:00 PM', name: '1400' },
55
+ * { label: '6:00 PM', name: '1800' }
56
+ * ];
57
+ *
58
+ * <DateTimeField>
59
+ * <DateField
60
+ * defaultValue={parseDate(today())}
61
+ * name="booking-date"
62
+ * onChange={(date) => console.log('Date selected:', date)}
63
+ * />
64
+ * <TimeField
65
+ * timeOptions={timeOptions}
66
+ * defaultValue="1400"
67
+ * name="booking-time"
68
+ * onChange={(time) => console.log('Time selected:', time)}
69
+ * />
70
+ * </DateTimeField>
71
+ *
72
+ * @example
73
+ * // With shared state management
74
+ * const [dateValue, setDateValue] = useState(null);
75
+ * const [timeValue, setTimeValue] = useState('');
76
+ *
77
+ * <DateTimeField>
78
+ * <DateField
79
+ * allowPastDate={false}
80
+ * name="booking-1-date"
81
+ * onChange={setDateValue}
82
+ * value={dateValue}
83
+ * disabled={isSubmitting}
84
+ * />
85
+ * <TimeField
86
+ * timeOptions={timeOptions}
87
+ * name="booking-1-time"
88
+ * onChange={setTimeValue}
89
+ * value={timeValue}
90
+ * disabled={isSubmitting}
91
+ * />
92
+ * </DateTimeField>
93
+ *
94
+ * @example
95
+ * // With advanced calendar configuration
96
+ * <DateTimeField>
97
+ * <DateField
98
+ * calendarOptions={{
99
+ * minValue: today(getLocalTimeZone()),
100
+ * isDateUnavailable: (date) => date.day === 0 // Disable Sundays
101
+ * }}
102
+ * lang={{ dateLabel: 'Check-in Date' }}
103
+ * name="booking-date"
104
+ * />
105
+ * <TimeField
106
+ * timeOptions={businessHours}
107
+ * lang={{ timeLabel: 'Arrival Time' }}
108
+ * name="booking-time"
109
+ * />
110
+ * </DateTimeField>
111
+ */
112
+ export declare const DateTimeField: {
113
+ ({ children, ...props }: DateTimeFieldProps): React.JSX.Element;
114
+ displayName: string;
115
+ };
116
+ //# sourceMappingURL=DateTimeField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateTimeField.d.ts","sourceRoot":"","sources":["../../../lib/components/DateTimeField/DateTimeField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,QAAQ,CAAC;AAElD,MAAM,WAAW,kBAChB,SAAQ,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,WAAW,GAAG,QAAQ,CAAC;IACxD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;AACH,eAAO,MAAM,aAAa;6BAA4B,kBAAkB;;CAIvE,CAAC"}
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+
3
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
+ const _excluded = ["children"];
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
+ 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
+ import React from 'react';
9
+ import { useBox } from "../Box/index.js";
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ /**
12
+ * DateTimeField is a layout-only wrapper component that provides structure for DateField and TimeField components.
13
+ * It doesn't manage state or provide functionality. This allows for simple direct control and updates to each field.
14
+ *
15
+ * All props (name, disabled, loading, etc.) should be passed directly to the individual DateField and TimeField components.
16
+ *
17
+ * ## Child Components
18
+ * - **DateField**: Handles date selection with calendar popover functionality
19
+ * - **TimeField**: Handles time selection from predefined options
20
+ *
21
+ * ## State
22
+ * - **Uncontrolled** (recommended): Pass `defaultValue` prop
23
+ * - **Controlled**: Pass `value` prop
24
+ *
25
+ * ## Internationalization
26
+ * - Override text values via `lang` props on the DateField and TimeField components
27
+ * - Full Calendar options available via `calendarOptions` prop on the DateField
28
+ * - Date formatting helper available in `...utils/dateFormat.ts` or use `@internationalized/date` utils
29
+ * - Advanced i18n and localization handled by [React Aria I18Provider](https://react-spectrum.adobe.com/react-aria/I18nProvider.html)
30
+ * - Read more about [International calendars](https://react-spectrum.adobe.com/react-aria/useDatePicker.html#international-calendars)
31
+ *
32
+ * @example
33
+ * // Basic usage with separate date and time selectors
34
+ * const timeOptions = [
35
+ * { label: '9:00 AM', name: '0900' },
36
+ * { label: '2:00 PM', name: '1400' },
37
+ * { label: '6:00 PM', name: '1800' }
38
+ * ];
39
+ *
40
+ * <DateTimeField>
41
+ * <DateField
42
+ * defaultValue={parseDate(today())}
43
+ * name="booking-date"
44
+ * onChange={(date) => console.log('Date selected:', date)}
45
+ * />
46
+ * <TimeField
47
+ * timeOptions={timeOptions}
48
+ * defaultValue="1400"
49
+ * name="booking-time"
50
+ * onChange={(time) => console.log('Time selected:', time)}
51
+ * />
52
+ * </DateTimeField>
53
+ *
54
+ * @example
55
+ * // With shared state management
56
+ * const [dateValue, setDateValue] = useState(null);
57
+ * const [timeValue, setTimeValue] = useState('');
58
+ *
59
+ * <DateTimeField>
60
+ * <DateField
61
+ * allowPastDate={false}
62
+ * name="booking-1-date"
63
+ * onChange={setDateValue}
64
+ * value={dateValue}
65
+ * disabled={isSubmitting}
66
+ * />
67
+ * <TimeField
68
+ * timeOptions={timeOptions}
69
+ * name="booking-1-time"
70
+ * onChange={setTimeValue}
71
+ * value={timeValue}
72
+ * disabled={isSubmitting}
73
+ * />
74
+ * </DateTimeField>
75
+ *
76
+ * @example
77
+ * // With advanced calendar configuration
78
+ * <DateTimeField>
79
+ * <DateField
80
+ * calendarOptions={{
81
+ * minValue: today(getLocalTimeZone()),
82
+ * isDateUnavailable: (date) => date.day === 0 // Disable Sundays
83
+ * }}
84
+ * lang={{ dateLabel: 'Check-in Date' }}
85
+ * name="booking-date"
86
+ * />
87
+ * <TimeField
88
+ * timeOptions={businessHours}
89
+ * lang={{ timeLabel: 'Arrival Time' }}
90
+ * name="booking-time"
91
+ * />
92
+ * </DateTimeField>
93
+ */
94
+ export const DateTimeField = _ref => {
95
+ let {
96
+ children
97
+ } = _ref,
98
+ props = _objectWithoutProperties(_ref, _excluded);
99
+ const {
100
+ Component,
101
+ componentProps
102
+ } = useBox(props);
103
+ return /*#__PURE__*/_jsx(Component, _objectSpread(_objectSpread({}, componentProps), {}, {
104
+ children: children
105
+ }));
106
+ };
107
+ DateTimeField.displayName = 'DateTimeField';
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import type { TestIdProp } from '../../../types';
3
+ import { type OptionItem } from '../../OptionGrid/OptionGrid';
4
+ import type { CommonSelectorProps } from '../types';
5
+ export type TimeFieldTextContent = Record<keyof typeof defaultEnglish, string>;
6
+ export interface TimeFieldProps extends CommonSelectorProps<string>, TestIdProp {
7
+ /**
8
+ * Available time options for selection
9
+ */
10
+ timeOptions: OptionItem[];
11
+ /**
12
+ * Text values for localization
13
+ */
14
+ lang?: Partial<TimeFieldTextContent>;
15
+ }
16
+ declare const defaultEnglish: {
17
+ readonly timeLabel: "time";
18
+ readonly select: "select";
19
+ };
20
+ /**
21
+ * TimeField is a sub-component for selecting a time from predefined options.
22
+ * Presently, this component is primarily used within the DateTimeInput.
23
+ */
24
+ export declare const TimeField: React.ForwardRefExoticComponent<TimeFieldProps & React.RefAttributes<HTMLLabelElement>>;
25
+ export {};
26
+ //# sourceMappingURL=TimeField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimeField.d.ts","sourceRoot":"","sources":["../../../../lib/components/DateTimeField/TimeField/TimeField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAElD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAM9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,OAAO,cAAc,EAAE,MAAM,CAAC,CAAC;AAE/E,MAAM,WAAW,cAChB,SAAQ,mBAAmB,CAAC,MAAM,CAAC,EAClC,UAAU;IACX;;OAEG;IACH,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACrC;AAED,QAAA,MAAM,cAAc;;;CAGV,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,SAAS,yFAkGrB,CAAC"}
@@ -0,0 +1,99 @@
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 React, { forwardRef, useRef } from 'react';
7
+ import { dataAttrs } from "../../../utils/dataAttrs.js";
8
+ import { LoadingBox } from "../../LoadingBox/LoadingBox.js";
9
+ import { inputStyle, labelVariants, timeFieldStyle } from "../DateTimeField.css.js";
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ const defaultEnglish = {
12
+ timeLabel: 'time',
13
+ select: 'select'
14
+ };
15
+
16
+ /**
17
+ * TimeField is a sub-component for selecting a time from predefined options.
18
+ * Presently, this component is primarily used within the DateTimeInput.
19
+ */
20
+ export const TimeField = /*#__PURE__*/forwardRef(({
21
+ defaultValue,
22
+ disabled = false,
23
+ invalid = false,
24
+ lang = {},
25
+ loading = false,
26
+ name,
27
+ onChange,
28
+ testId,
29
+ timeOptions,
30
+ value
31
+ }, ref) => {
32
+ const selectRef = useRef(null);
33
+ const isDisabled = disabled || loading;
34
+ const textValues = _objectSpread(_objectSpread({}, defaultEnglish), lang);
35
+ const handleTimeFieldClick = () => {
36
+ if ('showPicker' in HTMLSelectElement.prototype && selectRef.current) {
37
+ try {
38
+ // programmatically trigger the select menu
39
+ selectRef.current.showPicker();
40
+ } catch {
41
+ // browser doesn't support triggering menu
42
+ }
43
+ }
44
+ };
45
+ const valueProps = value === undefined ? {
46
+ defaultValue: defaultValue !== null && defaultValue !== void 0 ? defaultValue : ''
47
+ } : {
48
+ value
49
+ };
50
+ return /*#__PURE__*/_jsxs("label", _objectSpread(_objectSpread({
51
+ className: timeFieldStyle,
52
+ onClick: handleTimeFieldClick,
53
+ onMouseLeave: () => {
54
+ var _selectRef$current;
55
+ // work-around for :focus-within outline appearing for mouse users
56
+ selectRef === null || selectRef === void 0 ? void 0 : (_selectRef$current = selectRef.current) === null || _selectRef$current === void 0 ? void 0 : _selectRef$current.blur();
57
+ },
58
+ "aria-disabled": isDisabled
59
+ }, dataAttrs({
60
+ invalid,
61
+ loading,
62
+ 'od-component': 'time-field',
63
+ testId
64
+ })), {}, {
65
+ ref: ref,
66
+ children: [/*#__PURE__*/_jsx("div", {
67
+ className: labelVariants({
68
+ disabled,
69
+ invalid
70
+ }),
71
+ children: textValues.timeLabel
72
+ }), loading ? /*#__PURE__*/_jsx(LoadingBox, {
73
+ height: "6"
74
+ }) : /*#__PURE__*/_jsxs("select", _objectSpread(_objectSpread({
75
+ name: name,
76
+ className: inputStyle
77
+ }, valueProps), {}, {
78
+ disabled: isDisabled,
79
+ onChange: event => {
80
+ if (!isDisabled) {
81
+ onChange === null || onChange === void 0 ? void 0 : onChange(event.target.value);
82
+ }
83
+ },
84
+ onClick: event => {
85
+ event.stopPropagation();
86
+ },
87
+ ref: selectRef,
88
+ children: [/*#__PURE__*/_jsx("option", {
89
+ value: "",
90
+ disabled: true,
91
+ children: textValues.select
92
+ }), timeOptions.map(option => /*#__PURE__*/_jsx("option", {
93
+ value: option.name,
94
+ children: option.label
95
+ }, option.name))]
96
+ }))]
97
+ }));
98
+ });
99
+ TimeField.displayName = 'TimeField';
@@ -0,0 +1,2 @@
1
+ export { DateTimeField as default } from './DateTimeField';
2
+ //# sourceMappingURL=default.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../lib/components/DateTimeField/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ export { DateTimeField as default } from "./DateTimeField.js";
@@ -0,0 +1,5 @@
1
+ export { DateTimeField, type DateTimeFieldProps } from './DateTimeField';
2
+ export { DateField, type DateFieldProps } from './DateField/DateField';
3
+ export { TimeField, type TimeFieldProps } from './TimeField/TimeField';
4
+ export { type CommonSelectorProps } from './types';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/DateTimeField/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ export { DateTimeField } from "./DateTimeField.js";
4
+ export { DateField } from "./DateField/DateField.js";
5
+ export { TimeField } from "./TimeField/TimeField.js";
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Common props shared between DateField and TimeField components
3
+ */
4
+ export interface CommonSelectorProps<T> {
5
+ /**
6
+ * Input name attribute for forms
7
+ */
8
+ name?: string;
9
+ /**
10
+ * Disabled the input
11
+ */
12
+ disabled?: boolean;
13
+ /**
14
+ * Invalid field state
15
+ */
16
+ invalid?: boolean;
17
+ /**
18
+ * Loading state - shows spinner and disables interaction
19
+ */
20
+ loading?: boolean;
21
+ /**
22
+ * Uncontrolled default value
23
+ */
24
+ defaultValue?: T;
25
+ /**
26
+ * Controlled value
27
+ */
28
+ value?: T;
29
+ /**
30
+ * Custom event handler when value is selected
31
+ */
32
+ onChange?: (value: T) => void;
33
+ }
34
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../lib/components/DateTimeField/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACrC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,CAAC;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,CAAC,CAAC;IACV;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;CAC9B"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ export {};
@@ -9,6 +9,7 @@ export interface DropDownProps extends ButtonProps, FlyoutProps {
9
9
  label: string;
10
10
  icon?: IconType;
11
11
  isOpen?: boolean;
12
+ onOpenChange?: (isOpen: boolean) => void;
12
13
  onClick?: ComponentProps<typeof Button>['onClick'];
13
14
  }
14
15
  export declare const DropDown: FunctionComponent<DropDownProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"DropDown.d.ts","sourceRoot":"","sources":["../../../lib/components/DropDown/DropDown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmB,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EACN,cAAc,EACd,iBAAiB,EAEjB,SAAS,EAIT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAO1C,KAAK,WAAW,GAAG,IAAI,CACtB,cAAc,CAAC,OAAO,MAAM,CAAC,EAC7B,IAAI,GAAG,UAAU,GAAG,SAAS,CAC7B,CAAC;AACF,KAAK,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;AAEpE,MAAM,WAAW,aAAc,SAAQ,WAAW,EAAE,WAAW;IAC9D,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,cAAc,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC;CACnD;AAED,eAAO,MAAM,QAAQ,EAAE,iBAAiB,CAAC,aAAa,CAsCrD,CAAC"}
1
+ {"version":3,"file":"DropDown.d.ts","sourceRoot":"","sources":["../../../lib/components/DropDown/DropDown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmB,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EACN,cAAc,EACd,iBAAiB,EAEjB,SAAS,EAIT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAO1C,KAAK,WAAW,GAAG,IAAI,CACtB,cAAc,CAAC,OAAO,MAAM,CAAC,EAC7B,IAAI,GAAG,UAAU,GAAG,SAAS,CAC7B,CAAC;AACF,KAAK,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;AAEpE,MAAM,WAAW,aAAc,SAAQ,WAAW,EAAE,WAAW;IAC9D,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC,OAAO,CAAC,EAAE,cAAc,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC;CACnD;AAED,eAAO,MAAM,QAAQ,EAAE,iBAAiB,CAAC,aAAa,CAgErD,CAAC"}
@@ -2,7 +2,7 @@
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 = ["children", "label", "icon", "alignment", "isOpen", "onClick"];
5
+ const _excluded = ["children", "label", "icon", "alignment", "isOpen", "onOpenChange", "onClick"];
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 { ChevronDownIcon } from '@autoguru/icons';
@@ -21,18 +21,33 @@ export const DropDown = _ref => {
21
21
  label,
22
22
  icon = ChevronDownIcon,
23
23
  alignment = EPositionerAlignment.BOTTOM_LEFT,
24
- isOpen: incomingIsOpen = false,
24
+ isOpen: controlledIsOpen,
25
+ onOpenChange,
25
26
  onClick: incomingOnClick
26
27
  } = _ref,
27
28
  buttonProps = _objectWithoutProperties(_ref, _excluded);
28
29
  const buttonRef = useRef(null);
29
30
  const menuRef = useRef(null);
30
- const [isOpen, setIsOpen] = useState(incomingIsOpen);
31
+ const [uncontrolledIsOpen, setUncontrolledIsOpen] = useState(false);
32
+
33
+ // Use controlled state if provided, otherwise use uncontrolled state
34
+ const isOpen = controlledIsOpen !== null && controlledIsOpen !== void 0 ? controlledIsOpen : uncontrolledIsOpen;
35
+ const handleOpenChange = useCallback(newIsOpen => {
36
+ // Always call onOpenChange if provided (for both controlled and uncontrolled)
37
+ onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(newIsOpen);
38
+ // Update internal state only if uncontrolled
39
+ if (controlledIsOpen === undefined) {
40
+ setUncontrolledIsOpen(newIsOpen);
41
+ }
42
+ }, [controlledIsOpen, onOpenChange]);
31
43
  const onMenuClick = useCallback(event => {
32
44
  if (typeof incomingOnClick === 'function') incomingOnClick(event);
33
- setIsOpen(!isOpen);
34
- }, [isOpen, incomingOnClick]);
35
- useOutsideClick([menuRef], () => setIsOpen(false));
45
+ handleOpenChange(!isOpen);
46
+ }, [isOpen, incomingOnClick, handleOpenChange]);
47
+ const handleClose = useCallback(() => {
48
+ handleOpenChange(false);
49
+ }, [handleOpenChange]);
50
+ useOutsideClick([menuRef], handleClose);
36
51
  return /*#__PURE__*/_jsxs(_Fragment, {
37
52
  children: [/*#__PURE__*/_jsxs(Button, _objectSpread(_objectSpread({
38
53
  ref: buttonRef,
@@ -51,4 +66,5 @@ export const DropDown = _ref => {
51
66
  })
52
67
  })]
53
68
  });
54
- };
69
+ };
70
+ DropDown.displayName = 'DropDown';
@@ -4,7 +4,7 @@ import { type OverlayTriggerState } from 'react-stately';
4
4
  declare const defaultEnglish: {
5
5
  readonly close: "close";
6
6
  };
7
- export type Language = Partial<Record<keyof typeof defaultEnglish, string>>;
7
+ export type PopoverTextContent = Record<keyof typeof defaultEnglish, string>;
8
8
  /**
9
9
  * Internal props for the Popover component.
10
10
  */
@@ -24,7 +24,7 @@ export interface PopoverProps extends Omit<AriaPopoverProps, 'popoverRef'> {
24
24
  /**
25
25
  * Language content override
26
26
  */
27
- lang?: Language;
27
+ lang?: Partial<PopoverTextContent>;
28
28
  }
29
29
  export declare const Popover: {
30
30
  ({ children, offset, state, triggerRef, lang, ...props }: PopoverProps): React.JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../lib/components/Popover/Popover.tsx"],"names":[],"mappings":"AACA,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,EAKN,KAAK,gBAAgB,EAErB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AASzD,QAAA,MAAM,cAAc;;CAEV,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,OAAO,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC;IACzE;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;OAEG;IACH,KAAK,EAAE,mBAAmB,CAAC;IAC3B;;OAEG;IACH,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAChD;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;CAChB;AAoBD,eAAO,MAAM,OAAO;8DAOjB,YAAY;;CA6Ed,CAAC"}
1
+ {"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../lib/components/Popover/Popover.tsx"],"names":[],"mappings":"AACA,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,EAKN,KAAK,gBAAgB,EAErB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AASzD,QAAA,MAAM,cAAc;;CAEV,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,OAAO,cAAc,EAAE,MAAM,CAAC,CAAC;AAE7E;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC;IACzE;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;OAEG;IACH,KAAK,EAAE,mBAAmB,CAAC;IAC3B;;OAEG;IACH,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAChD;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACnC;AAoBD,eAAO,MAAM,OAAO;8DAOjB,YAAY;;CA4Ed,CAAC"}