@autoguru/overdrive 4.49.0 → 4.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Calendar/Calendar.css.d.ts.map +1 -1
- package/dist/components/Calendar/Calendar.css.js +4 -4
- package/dist/components/Calendar/Calendar.d.ts +3 -10
- package/dist/components/Calendar/Calendar.d.ts.map +1 -1
- package/dist/components/Calendar/Calendar.js +4 -11
- package/dist/components/DatePicker/DatePicker.d.ts +10 -4
- package/dist/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/components/DatePicker/DatePicker.js +36 -63
- package/dist/components/DatePicker/hooks/useCalendarPopover.d.ts +38 -0
- package/dist/components/DatePicker/hooks/useCalendarPopover.d.ts.map +1 -0
- package/dist/components/DatePicker/hooks/useCalendarPopover.js +44 -0
- package/dist/components/DateTimeField/DateField/DateField.d.ts +40 -0
- package/dist/components/DateTimeField/DateField/DateField.d.ts.map +1 -0
- package/dist/components/DateTimeField/DateField/DateField.js +110 -0
- package/dist/components/DateTimeField/DateTimeField.css.d.ts +21 -0
- package/dist/components/DateTimeField/DateTimeField.css.d.ts.map +1 -0
- package/dist/components/DateTimeField/DateTimeField.css.js +127 -0
- package/dist/components/DateTimeField/DateTimeField.d.ts +116 -0
- package/dist/components/DateTimeField/DateTimeField.d.ts.map +1 -0
- package/dist/components/DateTimeField/DateTimeField.js +107 -0
- package/dist/components/DateTimeField/TimeField/TimeField.d.ts +26 -0
- package/dist/components/DateTimeField/TimeField/TimeField.d.ts.map +1 -0
- package/dist/components/DateTimeField/TimeField/TimeField.js +99 -0
- package/dist/components/DateTimeField/default.d.ts +2 -0
- package/dist/components/DateTimeField/default.d.ts.map +1 -0
- package/dist/components/DateTimeField/default.js +3 -0
- package/dist/components/DateTimeField/index.d.ts +5 -0
- package/dist/components/DateTimeField/index.d.ts.map +1 -0
- package/dist/components/DateTimeField/index.js +5 -0
- package/dist/components/DateTimeField/types.d.ts +34 -0
- package/dist/components/DateTimeField/types.d.ts.map +1 -0
- package/dist/components/DateTimeField/types.js +3 -0
- package/dist/components/Popover/Popover.d.ts +2 -2
- package/dist/components/Popover/Popover.d.ts.map +1 -1
- package/dist/components/Popover/Popover.js +2 -2
- package/dist/components/Popover/PopoverTrigger.d.ts +9 -6
- package/dist/components/Popover/PopoverTrigger.d.ts.map +1 -1
- package/dist/components/Popover/PopoverTrigger.js +6 -3
- 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 +1 -0
- package/dist/styles/selectors.d.ts.map +1 -1
- package/dist/styles/selectors.js +1 -0
- package/dist/utils/dateFormat.d.ts +5 -4
- package/dist/utils/dateFormat.d.ts.map +1 -1
- package/dist/utils/dateFormat.js +9 -9
- package/package.json +10 -10
- package/dist/components/DateTimePicker/DateTimePicker.css.d.ts +0 -4
- package/dist/components/DateTimePicker/DateTimePicker.css.d.ts.map +0 -1
- package/dist/components/DateTimePicker/DateTimePicker.css.js +0 -30
- package/dist/components/DateTimePicker/DateTimePicker.d.ts +0 -68
- package/dist/components/DateTimePicker/DateTimePicker.d.ts.map +0 -1
- package/dist/components/DateTimePicker/DateTimePicker.js +0 -130
- package/dist/components/DateTimePicker/default.d.ts +0 -2
- package/dist/components/DateTimePicker/default.d.ts.map +0 -1
- 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 @@
|
|
|
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,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,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"}
|
|
@@ -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
|
|
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?:
|
|
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,
|
|
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"}
|
|
@@ -53,6 +53,7 @@ export const Popover = _ref2 => {
|
|
|
53
53
|
const popoverRef = useRef(null);
|
|
54
54
|
const [isTablet] = useMedia(['tablet']);
|
|
55
55
|
const isFullScreen = !isTablet;
|
|
56
|
+
const textValues = _objectSpread(_objectSpread({}, defaultEnglish), lang);
|
|
56
57
|
|
|
57
58
|
// Handle Esc manually since we have two different modes (popover vs fullscreen dialog)
|
|
58
59
|
// and react-aria would need a slightly different ModalTrigger pattern
|
|
@@ -78,7 +79,6 @@ export const Popover = _ref2 => {
|
|
|
78
79
|
|
|
79
80
|
// Fullscreen mode: render Dialog directly without popover positioning
|
|
80
81
|
if (isFullScreen) {
|
|
81
|
-
var _lang$close;
|
|
82
82
|
return /*#__PURE__*/_jsx(Overlay, {
|
|
83
83
|
children: /*#__PURE__*/_jsx(Dialog, {
|
|
84
84
|
children: /*#__PURE__*/_jsx("div", {
|
|
@@ -99,7 +99,7 @@ export const Popover = _ref2 => {
|
|
|
99
99
|
minimal: true,
|
|
100
100
|
rounded: true,
|
|
101
101
|
onClick: state.close,
|
|
102
|
-
"aria-label":
|
|
102
|
+
"aria-label": textValues.close,
|
|
103
103
|
children: /*#__PURE__*/_jsx(Icon, {
|
|
104
104
|
icon: CloseIcon
|
|
105
105
|
})
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type AriaPopoverProps } from 'react-aria';
|
|
3
3
|
import type { TestIdProp } from '../../types';
|
|
4
|
-
import { type
|
|
4
|
+
import { type PopoverTextContent } from './Popover';
|
|
5
|
+
export type OnStateReadyValue = {
|
|
6
|
+
close: () => void;
|
|
7
|
+
isOpen: boolean;
|
|
8
|
+
};
|
|
5
9
|
/**
|
|
6
10
|
* Props for the PopoverTrigger component.
|
|
7
11
|
*/
|
|
@@ -22,13 +26,12 @@ export interface PopoverTriggerProps extends Pick<AriaPopoverProps, 'offset' | '
|
|
|
22
26
|
/**
|
|
23
27
|
* Language content override
|
|
24
28
|
*/
|
|
25
|
-
lang?:
|
|
29
|
+
lang?: Partial<PopoverTextContent>;
|
|
26
30
|
/**
|
|
27
31
|
* Callback that receives the overlay trigger state for external control
|
|
28
32
|
*/
|
|
29
|
-
onStateReady?: (state:
|
|
30
|
-
|
|
31
|
-
}) => void;
|
|
33
|
+
onStateReady?: (state: OnStateReadyValue) => void;
|
|
34
|
+
ref?: React.RefObject<HTMLButtonElement | null>;
|
|
32
35
|
}
|
|
33
36
|
/**
|
|
34
37
|
* A popover component that displays content in an overlay positioned relative to a trigger element.
|
|
@@ -45,7 +48,7 @@ export interface PopoverTriggerProps extends Pick<AriaPopoverProps, 'offset' | '
|
|
|
45
48
|
* ```
|
|
46
49
|
*/
|
|
47
50
|
export declare const PopoverTrigger: {
|
|
48
|
-
({ content, children, isDisabled, offset, placement, shouldCloseOnInteractOutside, shouldFlip, testId, lang, onStateReady, }: PopoverTriggerProps): React.JSX.Element;
|
|
51
|
+
({ content, children, isDisabled, offset, placement, shouldCloseOnInteractOutside, shouldFlip, testId, lang, ref, onStateReady, }: PopoverTriggerProps): React.JSX.Element;
|
|
49
52
|
displayName: string;
|
|
50
53
|
};
|
|
51
54
|
//# sourceMappingURL=PopoverTrigger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopoverTrigger.d.ts","sourceRoot":"","sources":["../../../lib/components/Popover/PopoverTrigger.tsx"],"names":[],"mappings":"AACA,OAAO,KAAiB,MAAM,OAAO,CAAC;AACtC,OAAO,EAGN,KAAK,gBAAgB,EACrB,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAI9C,OAAO,
|
|
1
|
+
{"version":3,"file":"PopoverTrigger.d.ts","sourceRoot":"","sources":["../../../lib/components/Popover/PopoverTrigger.tsx"],"names":[],"mappings":"AACA,OAAO,KAAiB,MAAM,OAAO,CAAC;AACtC,OAAO,EAGN,KAAK,gBAAgB,EACrB,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAI9C,OAAO,EAAW,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAG7D,MAAM,MAAM,iBAAiB,GAAG;IAAE,KAAK,EAAE,MAAM,IAAI,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,mBAChB,SAAQ,IAAI,CACV,gBAAgB,EACd,QAAQ,GACR,WAAW,GACX,8BAA8B,GAC9B,YAAY,CACd,EACD,UAAU;IACX;;OAEG;IACH,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB;;;OAGG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACnC;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAClD,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;CAChD;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc;uIAYxB,mBAAmB;;CAyErB,CAAC"}
|