@salt-ds/lab 1.0.0-alpha.44 → 1.0.0-alpha.45
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/css/salt-lab.css +32 -84
- package/dist-cjs/calendar/internal/CalendarDay.js +5 -1
- package/dist-cjs/calendar/internal/CalendarDay.js.map +1 -1
- package/dist-cjs/calendar/internal/CalendarNavigation.js +2 -6
- package/dist-cjs/calendar/internal/CalendarNavigation.js.map +1 -1
- package/dist-cjs/calendar/useCalendar.js +4 -4
- package/dist-cjs/calendar/useCalendar.js.map +1 -1
- package/dist-cjs/calendar/useSelection.js +4 -0
- package/dist-cjs/calendar/useSelection.js.map +1 -1
- package/dist-cjs/contact-details/ContactPrimaryInfo.js.map +1 -1
- package/dist-cjs/date-input/DateInput.css.js +1 -1
- package/dist-cjs/date-input/DateInput.js +196 -49
- package/dist-cjs/date-input/DateInput.js.map +1 -1
- package/dist-cjs/date-picker/DatePicker.js +164 -0
- package/dist-cjs/date-picker/DatePicker.js.map +1 -0
- package/dist-cjs/date-picker/DatePickerContext.js +36 -0
- package/dist-cjs/date-picker/DatePickerContext.js.map +1 -0
- package/dist-cjs/date-picker/DatePickerPanel.css.js +6 -0
- package/dist-cjs/date-picker/DatePickerPanel.css.js.map +1 -0
- package/dist-cjs/date-picker/DatePickerPanel.js +139 -0
- package/dist-cjs/date-picker/DatePickerPanel.js.map +1 -0
- package/dist-cjs/index.js +3 -0
- package/dist-cjs/index.js.map +1 -1
- package/dist-cjs/stepped-tracker/TrackerStep/TrackerStep.css.js +1 -1
- package/dist-cjs/stepper-input/StepperInput.css.js +1 -1
- package/dist-cjs/stepper-input/StepperInput.js +25 -74
- package/dist-cjs/stepper-input/StepperInput.js.map +1 -1
- package/dist-cjs/stepper-input/useStepperInput.js +19 -63
- package/dist-cjs/stepper-input/useStepperInput.js.map +1 -1
- package/dist-es/calendar/internal/CalendarDay.js +5 -1
- package/dist-es/calendar/internal/CalendarDay.js.map +1 -1
- package/dist-es/calendar/internal/CalendarNavigation.js +3 -7
- package/dist-es/calendar/internal/CalendarNavigation.js.map +1 -1
- package/dist-es/calendar/useCalendar.js +5 -5
- package/dist-es/calendar/useCalendar.js.map +1 -1
- package/dist-es/calendar/useSelection.js +4 -1
- package/dist-es/calendar/useSelection.js.map +1 -1
- package/dist-es/contact-details/ContactPrimaryInfo.js.map +1 -1
- package/dist-es/date-input/DateInput.css.js +1 -1
- package/dist-es/date-input/DateInput.js +200 -53
- package/dist-es/date-input/DateInput.js.map +1 -1
- package/dist-es/date-picker/DatePicker.js +160 -0
- package/dist-es/date-picker/DatePicker.js.map +1 -0
- package/dist-es/date-picker/DatePickerContext.js +31 -0
- package/dist-es/date-picker/DatePickerContext.js.map +1 -0
- package/dist-es/date-picker/DatePickerPanel.css.js +4 -0
- package/dist-es/date-picker/DatePickerPanel.css.js.map +1 -0
- package/dist-es/date-picker/DatePickerPanel.js +135 -0
- package/dist-es/date-picker/DatePickerPanel.js.map +1 -0
- package/dist-es/index.js +2 -1
- package/dist-es/index.js.map +1 -1
- package/dist-es/stepped-tracker/TrackerStep/TrackerStep.css.js +1 -1
- package/dist-es/stepper-input/StepperInput.css.js +1 -1
- package/dist-es/stepper-input/StepperInput.js +27 -76
- package/dist-es/stepper-input/StepperInput.js.map +1 -1
- package/dist-es/stepper-input/useStepperInput.js +19 -63
- package/dist-es/stepper-input/useStepperInput.js.map +1 -1
- package/dist-types/breadcrumbs/internal/BreadcrumbsCollapsed.d.ts +1 -1
- package/dist-types/breadcrumbs/internal/BreadcrumbsSeparator.d.ts +1 -1
- package/dist-types/button-bar/internal/DescendantContext.d.ts +1 -1
- package/dist-types/calendar/useSelection.d.ts +1 -0
- package/dist-types/combo-box-deprecated/internal/MultiSelectComboBox.d.ts +1 -1
- package/dist-types/combo-box-deprecated/internal/useComboBox.d.ts +54 -60
- package/dist-types/combo-box-deprecated/internal/useMultiSelectComboBox.d.ts +165 -182
- package/dist-types/common-hooks/collectionProvider.d.ts +1 -1
- package/dist-types/contact-details/MailLinkComponent.d.ts +1 -1
- package/dist-types/date-input/DateInput.d.ts +21 -7
- package/dist-types/date-picker/DatePicker.d.ts +55 -0
- package/dist-types/date-picker/DatePickerContext.d.ts +23 -0
- package/dist-types/date-picker/DatePickerPanel.d.ts +8 -0
- package/dist-types/date-picker/index.d.ts +1 -0
- package/dist-types/form-field-legacy/FormActivationIndicator.d.ts +1 -1
- package/dist-types/form-field-legacy/FormHelperText.d.ts +1 -1
- package/dist-types/form-field-legacy/FormLabel.d.ts +1 -1
- package/dist-types/form-field-legacy/NecessityIndicator.d.ts +1 -1
- package/dist-types/form-field-legacy/StatusIndicator.d.ts +1 -1
- package/dist-types/index.d.ts +1 -0
- package/dist-types/list-deprecated/internal/DescendantContext.d.ts +1 -1
- package/dist-types/list-deprecated/internal/Highlighter.d.ts +1 -1
- package/dist-types/query-input/internal/CategoryList.d.ts +1 -1
- package/dist-types/query-input/internal/SearchList.d.ts +1 -1
- package/dist-types/query-input/internal/ValueList.d.ts +1 -1
- package/dist-types/query-input/internal/ValueSelector.d.ts +1 -1
- package/dist-types/responsive/overflowUtils.d.ts +1 -1
- package/dist-types/slider/internal/SliderMarkLabels.d.ts +1 -1
- package/dist-types/slider/internal/SliderRail.d.ts +1 -1
- package/dist-types/slider/internal/SliderRailMarks.d.ts +1 -1
- package/dist-types/slider/internal/SliderSelection.d.ts +1 -1
- package/dist-types/stepped-tracker/SteppedTrackerContext.d.ts +2 -2
- package/dist-types/stepped-tracker/TrackerConnector/TrackerConnector.d.ts +1 -1
- package/dist-types/stepper-input/StepperInput.d.ts +43 -12
- package/dist-types/stepper-input/useStepperInput.d.ts +7 -293
- package/dist-types/tabs/TabActivationIndicator.d.ts +1 -1
- package/dist-types/toolbar/Tooltray.d.ts +1 -1
- package/dist-types/tree/TreeNode.d.ts +1 -1
- package/package.json +2 -2
- package/dist-cjs/stepper-input/internal/useActivationIndicatorPosition.js +0 -38
- package/dist-cjs/stepper-input/internal/useActivationIndicatorPosition.js.map +0 -1
- package/dist-cjs/stepper-input/internal/useDynamicAriaLabel.js +0 -76
- package/dist-cjs/stepper-input/internal/useDynamicAriaLabel.js.map +0 -1
- package/dist-es/stepper-input/internal/useActivationIndicatorPosition.js +0 -34
- package/dist-es/stepper-input/internal/useActivationIndicatorPosition.js.map +0 -1
- package/dist-es/stepper-input/internal/useDynamicAriaLabel.js +0 -72
- package/dist-es/stepper-input/internal/useDynamicAriaLabel.js.map +0 -1
- package/dist-types/stepper-input/internal/useActivationIndicatorPosition.d.ts +0 -2
- package/dist-types/stepper-input/internal/useDynamicAriaLabel.d.ts +0 -3
|
@@ -1,49 +1,95 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
|
-
import { forwardRef, useState } from 'react';
|
|
3
|
+
import { forwardRef, useRef, useState, useCallback, useEffect } from 'react';
|
|
4
4
|
import { useComponentCssInjection } from '@salt-ds/styles';
|
|
5
5
|
import { useWindow } from '@salt-ds/window';
|
|
6
6
|
import css_248z from './DateInput.css.js';
|
|
7
|
-
import { makePrefixer, useFormFieldProps,
|
|
8
|
-
import { DateFormatter } from '@internationalized/date';
|
|
7
|
+
import { makePrefixer, useForkRef, useId, useFormFieldProps, StatusAdornment } from '@salt-ds/core';
|
|
8
|
+
import { DateFormatter, getLocalTimeZone, CalendarDate, parseAbsoluteToLocal } from '@internationalized/date';
|
|
9
|
+
import { useDatePickerContext } from '../date-picker/DatePickerContext.js';
|
|
9
10
|
|
|
10
11
|
const withBaseName = makePrefixer("saltDateInput");
|
|
11
12
|
const isInvalidDate = (value) => value && isNaN(new Date(value));
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const createDate = (date) => {
|
|
14
|
+
if (!date || isInvalidDate(date)) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return new Date(date);
|
|
18
|
+
};
|
|
19
|
+
const getIsoDate = (date) => {
|
|
20
|
+
try {
|
|
21
|
+
return parseAbsoluteToLocal(date == null ? void 0 : date.toISOString());
|
|
22
|
+
} catch (err) {
|
|
23
|
+
return void 0;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
function getCalendarDate(inputDate) {
|
|
27
|
+
const date = createDate(inputDate);
|
|
28
|
+
if (!date)
|
|
29
|
+
return void 0;
|
|
30
|
+
const isoDate = getIsoDate(date);
|
|
31
|
+
return isoDate && new CalendarDate(isoDate.year, isoDate.month, isoDate.day);
|
|
32
|
+
}
|
|
33
|
+
const getDateValidationStatus = (value) => value && isInvalidDate(value) ? "error" : void 0;
|
|
34
|
+
const defaultDateFormatter = (date) => {
|
|
35
|
+
return date ? new DateFormatter("EN-GB", {
|
|
15
36
|
day: "2-digit",
|
|
16
37
|
month: "short",
|
|
17
38
|
year: "numeric"
|
|
18
|
-
}).format(date);
|
|
39
|
+
}).format(date.toDate(getLocalTimeZone())) : "";
|
|
19
40
|
};
|
|
20
41
|
const DateInput = forwardRef(
|
|
21
42
|
function DateInput2({
|
|
22
|
-
"aria-activedescendant": ariaActiveDescendant,
|
|
23
|
-
"aria-expanded": ariaExpanded,
|
|
24
|
-
"aria-owns": ariaOwns,
|
|
25
43
|
className,
|
|
44
|
+
ariaLabel,
|
|
26
45
|
disabled,
|
|
46
|
+
selectionVariant: selectionVariantProp,
|
|
27
47
|
emptyReadOnlyMarker = "\u2014",
|
|
28
48
|
inputProps = {},
|
|
29
|
-
|
|
49
|
+
endAdornment,
|
|
30
50
|
readOnly: readOnlyProp,
|
|
31
|
-
role,
|
|
32
|
-
value: valueProp,
|
|
33
|
-
defaultValue: defaultStartDateProp = valueProp === void 0 ? "" : void 0,
|
|
34
51
|
validationStatus: validationStatusProp,
|
|
35
52
|
variant = "primary",
|
|
36
53
|
dateFormatter = defaultDateFormatter,
|
|
37
54
|
placeholder = "dd mmm yyyy",
|
|
55
|
+
startInputRef,
|
|
56
|
+
endInputRef,
|
|
38
57
|
...rest
|
|
39
58
|
}, ref) {
|
|
40
59
|
var _a;
|
|
60
|
+
const wrapperRef = useRef(null);
|
|
61
|
+
const inputRef = useForkRef(ref, wrapperRef);
|
|
62
|
+
const inputStringFormatter = (input) => {
|
|
63
|
+
const date = getCalendarDate(input);
|
|
64
|
+
return !input || !date ? input : dateFormatter(date);
|
|
65
|
+
};
|
|
41
66
|
const targetWindow = useWindow();
|
|
42
67
|
useComponentCssInjection({
|
|
43
68
|
testId: "salt-dateInput",
|
|
44
69
|
css: css_248z,
|
|
45
70
|
window: targetWindow
|
|
46
71
|
});
|
|
72
|
+
const {
|
|
73
|
+
startDate,
|
|
74
|
+
endDate,
|
|
75
|
+
setStartDate,
|
|
76
|
+
setEndDate,
|
|
77
|
+
selectionVariant: pickerSelectionVariant,
|
|
78
|
+
openState,
|
|
79
|
+
setOpen,
|
|
80
|
+
validationStatusState,
|
|
81
|
+
setValidationStatus
|
|
82
|
+
} = useDatePickerContext();
|
|
83
|
+
const selectionVariant = selectionVariantProp != null ? selectionVariantProp : pickerSelectionVariant;
|
|
84
|
+
const endDateInputID = useId();
|
|
85
|
+
const startDateInputID = useId();
|
|
86
|
+
const [focused, setFocused] = useState(false);
|
|
87
|
+
const [startDateStringValue, setStartDateStringValue] = useState(
|
|
88
|
+
dateFormatter(startDate)
|
|
89
|
+
);
|
|
90
|
+
const [endDateStringValue, setEndDateStringValue] = useState(
|
|
91
|
+
dateFormatter(endDate)
|
|
92
|
+
);
|
|
47
93
|
const {
|
|
48
94
|
a11yProps: {
|
|
49
95
|
"aria-describedby": formFieldDescribedBy,
|
|
@@ -54,27 +100,9 @@ const DateInput = forwardRef(
|
|
|
54
100
|
necessity: formFieldRequired,
|
|
55
101
|
validationStatus: formFieldValidationStatus
|
|
56
102
|
} = useFormFieldProps();
|
|
57
|
-
const restA11yProps = {
|
|
58
|
-
"aria-activedescendant": ariaActiveDescendant,
|
|
59
|
-
"aria-expanded": ariaExpanded,
|
|
60
|
-
"aria-owns": ariaOwns
|
|
61
|
-
};
|
|
62
103
|
const isReadOnly = readOnlyProp || formFieldReadOnly;
|
|
63
|
-
const isEmptyReadOnly = isReadOnly && !defaultStartDateProp && !valueProp;
|
|
64
|
-
const defaultValue = isEmptyReadOnly ? emptyReadOnlyMarker : defaultStartDateProp;
|
|
65
|
-
const [value, setValue] = useControlled({
|
|
66
|
-
controlled: valueProp,
|
|
67
|
-
default: defaultValue,
|
|
68
|
-
name: "DateInput",
|
|
69
|
-
state: "value"
|
|
70
|
-
});
|
|
71
|
-
const getDateValidationStatus = (value2) => isInvalidDate(value2) ? "error" : void 0;
|
|
72
|
-
const [dateStatus, setDateStatus] = useState(
|
|
73
|
-
getDateValidationStatus(value)
|
|
74
|
-
);
|
|
75
104
|
const isDisabled = disabled || formFieldDisabled;
|
|
76
|
-
const validationStatus = (_a =
|
|
77
|
-
const [focused, setFocused] = useState(false);
|
|
105
|
+
const validationStatus = (_a = validationStatusState != null ? validationStatusState : formFieldValidationStatus) != null ? _a : validationStatusProp;
|
|
78
106
|
const {
|
|
79
107
|
"aria-describedby": dateInputDescribedBy,
|
|
80
108
|
"aria-labelledby": dateInputLabelledBy,
|
|
@@ -84,25 +112,92 @@ const DateInput = forwardRef(
|
|
|
84
112
|
required: dateInputPropsRequired,
|
|
85
113
|
...restDateInputProps
|
|
86
114
|
} = inputProps;
|
|
115
|
+
const validateRange = useCallback(() => {
|
|
116
|
+
if (startDate && endDate) {
|
|
117
|
+
setValidationStatus(
|
|
118
|
+
(startDate == null ? void 0 : startDate.compare(endDate)) >= 1 ? "error" : void 0
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
}, [endDate, startDate, setValidationStatus]);
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
setStartDateStringValue(dateFormatter(startDate));
|
|
124
|
+
validateRange();
|
|
125
|
+
}, [startDate, dateFormatter, validateRange]);
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
setEndDateStringValue(dateFormatter(endDate));
|
|
128
|
+
validateRange();
|
|
129
|
+
}, [endDate, dateFormatter, validateRange]);
|
|
87
130
|
const isRequired = formFieldRequired ? ["required", "asterisk"].includes(formFieldRequired) : dateInputPropsRequired;
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
131
|
+
const updateStartDate = (dateString) => {
|
|
132
|
+
var _a2, _b;
|
|
133
|
+
if (!dateString)
|
|
134
|
+
setStartDate(void 0);
|
|
135
|
+
const inputDate = inputStringFormatter(dateString);
|
|
136
|
+
const calendarDate = getCalendarDate(inputDate);
|
|
137
|
+
const emptyDateStatus = !calendarDate && inputDate ? "error" : void 0;
|
|
138
|
+
setValidationStatus(
|
|
139
|
+
(_b = (_a2 = getDateValidationStatus(dateString)) != null ? _a2 : getDateValidationStatus(endDateStringValue)) != null ? _b : emptyDateStatus
|
|
140
|
+
);
|
|
141
|
+
if (calendarDate) {
|
|
142
|
+
setStartDate(calendarDate);
|
|
143
|
+
}
|
|
91
144
|
};
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
145
|
+
const updateEndDate = (dateString) => {
|
|
146
|
+
var _a2, _b;
|
|
147
|
+
if (!dateString)
|
|
148
|
+
setEndDate(void 0);
|
|
149
|
+
const inputDate = inputStringFormatter(dateString);
|
|
150
|
+
const calendarDate = getCalendarDate(inputDate);
|
|
151
|
+
const emptyDateStatus = !calendarDate && inputDate ? "error" : void 0;
|
|
152
|
+
setValidationStatus(
|
|
153
|
+
(_b = (_a2 = getDateValidationStatus(dateString)) != null ? _a2 : getDateValidationStatus(startDateStringValue)) != null ? _b : emptyDateStatus
|
|
154
|
+
);
|
|
155
|
+
if (calendarDate) {
|
|
156
|
+
setEndDate(calendarDate);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const handleFocus = (event) => {
|
|
160
|
+
onFocus == null ? void 0 : onFocus(event);
|
|
161
|
+
setFocused(true);
|
|
95
162
|
};
|
|
96
163
|
const handleStartDateBlur = (event) => {
|
|
97
|
-
|
|
98
|
-
|
|
164
|
+
updateStartDate(event.target.value);
|
|
165
|
+
setFocused(false);
|
|
99
166
|
onBlur == null ? void 0 : onBlur(event);
|
|
100
|
-
|
|
167
|
+
};
|
|
168
|
+
const handleStartDateChange = (event) => {
|
|
169
|
+
setStartDateStringValue(event.target.value);
|
|
170
|
+
onChange == null ? void 0 : onChange(event);
|
|
171
|
+
};
|
|
172
|
+
const handleStartDateKeyDown = (event) => {
|
|
173
|
+
if (event.key === "Enter") {
|
|
174
|
+
updateStartDate(startDateStringValue);
|
|
175
|
+
setOpen(false);
|
|
176
|
+
}
|
|
177
|
+
if (event.key === "Tab" && event.shiftKey && openState) {
|
|
178
|
+
setOpen(false);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
const handleEndDateBlur = (event) => {
|
|
182
|
+
updateEndDate(event.target.value);
|
|
101
183
|
setFocused(false);
|
|
184
|
+
onBlur == null ? void 0 : onBlur(event);
|
|
102
185
|
};
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
186
|
+
const handleEndDateChange = (event) => {
|
|
187
|
+
setEndDateStringValue(event.target.value);
|
|
188
|
+
onChange == null ? void 0 : onChange(event);
|
|
189
|
+
};
|
|
190
|
+
const handleEndDateKeyDown = (event) => {
|
|
191
|
+
if (event.key === "Enter") {
|
|
192
|
+
updateEndDate(endDateStringValue);
|
|
193
|
+
setOpen(false);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
const handleInputClick = (event) => {
|
|
197
|
+
var _a2;
|
|
198
|
+
if (event.target === wrapperRef.current) {
|
|
199
|
+
(_a2 = startInputRef == null ? void 0 : startInputRef.current) == null ? void 0 : _a2.focus();
|
|
200
|
+
}
|
|
106
201
|
};
|
|
107
202
|
return /* @__PURE__ */ jsxs("div", {
|
|
108
203
|
className: clsx(
|
|
@@ -116,27 +211,79 @@ const DateInput = forwardRef(
|
|
|
116
211
|
},
|
|
117
212
|
className
|
|
118
213
|
),
|
|
119
|
-
|
|
214
|
+
onClick: (event) => handleInputClick(event),
|
|
215
|
+
ref: inputRef,
|
|
120
216
|
...rest,
|
|
121
217
|
children: [
|
|
122
218
|
/* @__PURE__ */ jsx("input", {
|
|
219
|
+
autoComplete: "off",
|
|
123
220
|
"aria-describedby": clsx(formFieldDescribedBy, dateInputDescribedBy),
|
|
124
|
-
"aria-labelledby": clsx(
|
|
125
|
-
|
|
221
|
+
"aria-labelledby": clsx(
|
|
222
|
+
formFieldLabelledBy,
|
|
223
|
+
dateInputLabelledBy,
|
|
224
|
+
startDateInputID
|
|
225
|
+
),
|
|
226
|
+
"aria-label": clsx("Start date", ariaLabel),
|
|
227
|
+
id: startDateInputID,
|
|
228
|
+
className: withBaseName("input"),
|
|
126
229
|
disabled: isDisabled,
|
|
127
230
|
readOnly: isReadOnly,
|
|
128
|
-
ref:
|
|
129
|
-
role,
|
|
231
|
+
ref: startInputRef,
|
|
130
232
|
tabIndex: isDisabled ? -1 : 0,
|
|
131
233
|
onBlur: handleStartDateBlur,
|
|
132
234
|
onChange: handleStartDateChange,
|
|
235
|
+
onKeyDown: handleStartDateKeyDown,
|
|
133
236
|
onFocus: !isDisabled ? handleFocus : void 0,
|
|
134
237
|
placeholder,
|
|
135
|
-
|
|
136
|
-
|
|
238
|
+
size: placeholder.length,
|
|
239
|
+
value: isReadOnly && !startDateStringValue ? emptyReadOnlyMarker : startDateStringValue,
|
|
137
240
|
...restDateInputProps,
|
|
138
241
|
required: isRequired
|
|
139
242
|
}),
|
|
243
|
+
selectionVariant === "range" && /* @__PURE__ */ jsxs(Fragment, {
|
|
244
|
+
children: [
|
|
245
|
+
/* @__PURE__ */ jsx("span", {
|
|
246
|
+
children: "-"
|
|
247
|
+
}),
|
|
248
|
+
/* @__PURE__ */ jsx("input", {
|
|
249
|
+
autoComplete: "off",
|
|
250
|
+
"aria-describedby": clsx(
|
|
251
|
+
formFieldDescribedBy,
|
|
252
|
+
dateInputDescribedBy
|
|
253
|
+
),
|
|
254
|
+
"aria-labelledby": clsx(
|
|
255
|
+
formFieldLabelledBy,
|
|
256
|
+
dateInputLabelledBy,
|
|
257
|
+
endDateInputID
|
|
258
|
+
),
|
|
259
|
+
"aria-label": clsx("End date", ariaLabel),
|
|
260
|
+
id: endDateInputID,
|
|
261
|
+
className: withBaseName("input"),
|
|
262
|
+
disabled: isDisabled,
|
|
263
|
+
readOnly: isReadOnly,
|
|
264
|
+
ref: endInputRef,
|
|
265
|
+
tabIndex: isDisabled ? -1 : 0,
|
|
266
|
+
onBlur: handleEndDateBlur,
|
|
267
|
+
onChange: handleEndDateChange,
|
|
268
|
+
onKeyDown: handleEndDateKeyDown,
|
|
269
|
+
onFocus: !isDisabled ? handleFocus : void 0,
|
|
270
|
+
placeholder,
|
|
271
|
+
size: placeholder.length,
|
|
272
|
+
value: isReadOnly && !endDateStringValue ? emptyReadOnlyMarker : endDateStringValue,
|
|
273
|
+
required: isRequired,
|
|
274
|
+
...restDateInputProps
|
|
275
|
+
})
|
|
276
|
+
]
|
|
277
|
+
}),
|
|
278
|
+
/* @__PURE__ */ jsxs("div", {
|
|
279
|
+
className: withBaseName("endAdornmentContainer"),
|
|
280
|
+
children: [
|
|
281
|
+
!isDisabled && !isReadOnly && validationStatus && /* @__PURE__ */ jsx(StatusAdornment, {
|
|
282
|
+
status: validationStatus
|
|
283
|
+
}),
|
|
284
|
+
endAdornment
|
|
285
|
+
]
|
|
286
|
+
}),
|
|
140
287
|
/* @__PURE__ */ jsx("div", {
|
|
141
288
|
className: withBaseName("activationIndicator")
|
|
142
289
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateInput.js","sources":["../src/date-input/DateInput.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport {\n ChangeEvent,\n ComponentPropsWithoutRef,\n FocusEvent,\n forwardRef,\n InputHTMLAttributes,\n Ref,\n useState,\n} from \"react\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\n\nimport dateInputCss from \"./DateInput.css\";\nimport { makePrefixer, useControlled, useFormFieldProps } from \"@salt-ds/core\";\nimport { DateFormatter } from \"@internationalized/date\";\n\nconst withBaseName = makePrefixer(\"saltDateInput\");\n\nconst isInvalidDate = (value: string) =>\n // @ts-ignore evaluating validity of date\n value && isNaN(new Date(value));\n\nconst defaultDateFormatter = (input: string): string => {\n const date = new Date(input);\n\n return isInvalidDate(input)\n ? input\n : new DateFormatter(\"EN-GB\", {\n day: \"2-digit\",\n month: \"short\",\n year: \"numeric\",\n }).format(date);\n};\nexport interface DateInputProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"defaultValue\">,\n Pick<\n ComponentPropsWithoutRef<\"input\">,\n \"disabled\" | \"value\" | \"defaultValue\" | \"placeholder\"\n > {\n /**\n * The marker to use in an empty read only DateInput.\n * Use `''` to disable this feature. Defaults to '—'.\n */\n emptyReadOnlyMarker?: string;\n /**\n * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dateInput#Attributes) applied to the `input` elements.\n */\n inputProps?: InputHTMLAttributes<HTMLInputElement>;\n /**\n * Optional ref for the dateInput component\n */\n inputRef?: Ref<HTMLInputElement>;\n /**\n * If `true`, the component is read only.\n */\n readOnly?: boolean;\n /**\n * Validation status.\n */\n validationStatus?: \"error\" | \"warning\" | \"success\";\n /**\n * Styling variant. Defaults to \"primary\".\n */\n variant?: \"primary\" | \"secondary\";\n /**\n * Function to format the input value.\n */\n dateFormatter?: (input: string) => string;\n}\n\nexport const DateInput = forwardRef<HTMLDivElement, DateInputProps>(\n function DateInput(\n {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n className,\n disabled,\n emptyReadOnlyMarker = \"—\",\n inputProps = {},\n inputRef,\n readOnly: readOnlyProp,\n role,\n value: valueProp,\n defaultValue: defaultStartDateProp = valueProp === undefined\n ? \"\"\n : undefined,\n validationStatus: validationStatusProp,\n variant = \"primary\",\n dateFormatter = defaultDateFormatter,\n placeholder = \"dd mmm yyyy\",\n ...rest\n },\n ref\n ) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-dateInput\",\n css: dateInputCss,\n window: targetWindow,\n });\n\n const {\n a11yProps: {\n \"aria-describedby\": formFieldDescribedBy,\n \"aria-labelledby\": formFieldLabelledBy,\n } = {},\n disabled: formFieldDisabled,\n readOnly: formFieldReadOnly,\n necessity: formFieldRequired,\n validationStatus: formFieldValidationStatus,\n } = useFormFieldProps();\n\n const restA11yProps = {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n };\n\n const isReadOnly = readOnlyProp || formFieldReadOnly;\n const isEmptyReadOnly = isReadOnly && !defaultStartDateProp && !valueProp;\n const defaultValue = isEmptyReadOnly\n ? emptyReadOnlyMarker\n : defaultStartDateProp;\n const [value, setValue] = useControlled({\n controlled: valueProp,\n default: defaultValue,\n name: \"DateInput\",\n state: \"value\",\n });\n\n const getDateValidationStatus = (value: string) =>\n isInvalidDate(value) ? \"error\" : undefined;\n\n const [dateStatus, setDateStatus] = useState<\"error\" | undefined>(\n getDateValidationStatus(value as string)\n );\n\n const isDisabled = disabled || formFieldDisabled;\n const validationStatus =\n dateStatus ?? formFieldValidationStatus ?? validationStatusProp;\n\n const [focused, setFocused] = useState(false);\n\n const {\n \"aria-describedby\": dateInputDescribedBy,\n \"aria-labelledby\": dateInputLabelledBy,\n onBlur,\n onChange,\n onFocus,\n required: dateInputPropsRequired,\n ...restDateInputProps\n } = inputProps;\n\n const isRequired = formFieldRequired\n ? [\"required\", \"asterisk\"].includes(formFieldRequired)\n : dateInputPropsRequired;\n\n const format = (date: string) => {\n const formattedDate = dateFormatter(date);\n setValue(formattedDate);\n };\n const handleStartDateChange = (event: ChangeEvent<HTMLInputElement>) => {\n setValue(event.target.value);\n onChange?.(event);\n };\n\n const handleStartDateBlur = (event: FocusEvent<HTMLInputElement>) => {\n const stringDate = value as string;\n value && format(stringDate);\n onBlur?.(event);\n setDateStatus(getDateValidationStatus(stringDate));\n setFocused(false);\n };\n\n const handleFocus = (event: FocusEvent<HTMLInputElement>) => {\n onFocus?.(event);\n setFocused(true);\n };\n\n return (\n <div\n className={clsx(\n withBaseName(),\n withBaseName(variant),\n {\n [withBaseName(\"focused\")]: !isDisabled && focused,\n [withBaseName(\"disabled\")]: isDisabled,\n [withBaseName(\"readOnly\")]: isReadOnly,\n [withBaseName(validationStatus ?? \"\")]: validationStatus,\n },\n className\n )}\n ref={ref}\n {...rest}\n >\n <input\n aria-describedby={clsx(formFieldDescribedBy, dateInputDescribedBy)}\n aria-labelledby={clsx(formFieldLabelledBy, dateInputLabelledBy)}\n className={clsx(withBaseName(\"input\"), inputProps?.className)}\n disabled={isDisabled}\n readOnly={isReadOnly}\n ref={inputRef}\n role={role}\n tabIndex={isDisabled ? -1 : 0}\n onBlur={handleStartDateBlur}\n onChange={handleStartDateChange}\n onFocus={!isDisabled ? handleFocus : undefined}\n placeholder={placeholder}\n value={value}\n {...restA11yProps}\n {...restDateInputProps}\n required={isRequired}\n />\n <div className={withBaseName(\"activationIndicator\")} />\n </div>\n );\n }\n);\n"],"names":["DateInput","dateInputCss","value"],"mappings":";;;;;;;;;AAiBA,MAAM,YAAA,GAAe,aAAa,eAAe,CAAA,CAAA;AAEjD,MAAM,aAAA,GAAgB,CAAC,KAErB,KAAA,KAAA,IAAS,MAAM,IAAI,IAAA,CAAK,KAAK,CAAC,CAAA,CAAA;AAEhC,MAAM,oBAAA,GAAuB,CAAC,KAA0B,KAAA;AACtD,EAAM,MAAA,IAAA,GAAO,IAAI,IAAA,CAAK,KAAK,CAAA,CAAA;AAE3B,EAAA,OAAO,cAAc,KAAK,CAAA,GACtB,KACA,GAAA,IAAI,cAAc,OAAS,EAAA;AAAA,IACzB,GAAK,EAAA,SAAA;AAAA,IACL,KAAO,EAAA,OAAA;AAAA,IACP,IAAM,EAAA,SAAA;AAAA,GACP,CAAE,C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UAAA;AAAA,UAC5B,CAAC,YAAa,CAAA,UAAU,CAAI,GAAA,UAAA;AAAA,UAC5B,CAAC,YAAA,CAAa,gBAAoB,IAAA,IAAA,GAAA,gBAAA,GAAA,EAAE,CAAI,GAAA,gBAAA;AAAA,SAC1C;AAAA,QACA,SAAA;AAAA,OACF;AAAA,MACA,GAAA;AAAA,MACC,GAAG,IAAA;AAAA,MAEJ,QAAA,EAAA;AAAA,wBAAC,GAAA,CAAA,OAAA,EAAA;AAAA,UACC,kBAAA,EAAkB,IAAK,CAAA,oBAAA,EAAsB,oBAAoB,CAAA;AAAA,UACjE,iBAAA,EAAiB,IAAK,CAAA,mBAAA,EAAqB,mBAAmB,CAAA;AAAA,UAC9D,WAAW,IAAK,CAAA,YAAA,CAAa,OAAO,CAAA,EAAG,yCAAY,SAAS,CAAA;AAAA,UAC5D,QAAU,EAAA,UAAA;AAAA,UACV,QAAU,EAAA,UAAA;AAAA,UACV,GAAK,EAAA,QAAA;AAAA,UACL,IAAA;AAAA,UACA,QAAA,EAAU,aAAa,CAAK,CAAA,GAAA,CAAA;AAAA,UAC5B,MAAQ,EAAA,mBAAA;AAAA,UACR,QAAU,EAAA,qBAAA;AAAA,UACV,OAAA,EAAS,CAAC,UAAA,GAAa,WAAc,GAAA,KAAA,CAAA;AAAA,UACrC,WAAA;AAAA,UACA,KAAA;AAAA,UACC,GAAG,aAAA;AAAA,UACH,GAAG,kBAAA;AAAA,UACJ,QAAU,EAAA,UAAA;AAAA,SACZ,CAAA;AAAA,wBACC,GAAA,CAAA,KAAA,EAAA;AAAA,UAAI,SAAA,EAAW,aAAa,qBAAqB,CAAA;AAAA,SAAG,CAAA;AAAA,OAAA;AAAA,KACvD,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"DateInput.js","sources":["../src/date-input/DateInput.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport {\n ChangeEvent,\n ComponentPropsWithoutRef,\n FocusEvent,\n forwardRef,\n InputHTMLAttributes,\n KeyboardEvent,\n ReactNode,\n RefObject,\n SyntheticEvent,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\n\nimport dateInputCss from \"./DateInput.css\";\nimport {\n makePrefixer,\n StatusAdornment,\n useForkRef,\n useFormFieldProps,\n useId,\n} from \"@salt-ds/core\";\nimport {\n CalendarDate,\n DateFormatter,\n DateValue,\n getLocalTimeZone,\n parseAbsoluteToLocal,\n} from \"@internationalized/date\";\nimport { useDatePickerContext } from \"../date-picker/DatePickerContext\";\n\nconst withBaseName = makePrefixer(\"saltDateInput\");\nconst isInvalidDate = (value: string) =>\n // @ts-ignore evaluating validity of date\n value && isNaN(new Date(value));\nconst createDate = (date: string): Date | null => {\n if (!date || isInvalidDate(date)) {\n return null;\n }\n return new Date(date);\n};\n\nconst getIsoDate = (date: Date) => {\n try {\n return parseAbsoluteToLocal(date?.toISOString());\n } catch (err) {\n return undefined;\n }\n};\n\nfunction getCalendarDate(inputDate: string) {\n const date = createDate(inputDate);\n if (!date) return undefined;\n const isoDate = getIsoDate(date);\n return isoDate && new CalendarDate(isoDate.year, isoDate.month, isoDate.day);\n}\n\nconst getDateValidationStatus = (value: string | undefined) =>\n value && isInvalidDate(value) ? \"error\" : undefined;\n\nconst defaultDateFormatter = (date: DateValue | undefined): string => {\n return date\n ? new DateFormatter(\"EN-GB\", {\n day: \"2-digit\",\n month: \"short\",\n year: \"numeric\",\n }).format(date.toDate(getLocalTimeZone()))\n : \"\";\n};\n\nexport interface DateInputProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"defaultValue\">,\n Pick<ComponentPropsWithoutRef<\"input\">, \"disabled\" | \"placeholder\"> {\n ariaLabel?: string;\n /**\n * The marker to use in an empty read only DateInput.\n * Use `''` to disable this feature. Defaults to '—'.\n */\n emptyReadOnlyMarker?: string;\n /**\n * End adornment component\n */\n endAdornment?: ReactNode;\n /**\n * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dateInput#Attributes) applied to the `input` elements.\n */\n inputProps?: InputHTMLAttributes<HTMLInputElement>;\n /**\n * If `true`, the component is read only.\n */\n readOnly?: boolean;\n /**\n * Validation status.\n */\n validationStatus?: \"error\" | \"warning\" | \"success\";\n /**\n * Styling variant. Defaults to \"primary\".\n */\n variant?: \"primary\" | \"secondary\";\n /**\n * Function to format the input value.\n */\n dateFormatter?: (input: DateValue | undefined) => string;\n /**\n * Reference for the startInput;\n */\n startInputRef?: RefObject<HTMLInputElement>;\n /**\n * Reference for the endInput;\n */\n endInputRef?: RefObject<HTMLInputElement>;\n /**\n * Selection variant. Defaults to single select.\n */\n selectionVariant?: \"default\" | \"range\";\n}\n\nexport const DateInput = forwardRef<HTMLDivElement, DateInputProps>(\n function DateInput(\n {\n className,\n ariaLabel,\n disabled,\n selectionVariant: selectionVariantProp,\n emptyReadOnlyMarker = \"—\",\n inputProps = {},\n endAdornment,\n readOnly: readOnlyProp,\n validationStatus: validationStatusProp,\n variant = \"primary\",\n dateFormatter = defaultDateFormatter,\n placeholder = \"dd mmm yyyy\",\n startInputRef,\n endInputRef,\n ...rest\n },\n ref\n ) {\n const wrapperRef = useRef(null);\n const inputRef = useForkRef<HTMLDivElement>(ref, wrapperRef);\n const inputStringFormatter = (input: string): string => {\n const date = getCalendarDate(input);\n return !input || !date ? input : dateFormatter(date);\n };\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-dateInput\",\n css: dateInputCss,\n window: targetWindow,\n });\n\n const {\n startDate,\n endDate,\n setStartDate,\n setEndDate,\n selectionVariant: pickerSelectionVariant,\n openState,\n setOpen,\n validationStatusState,\n setValidationStatus,\n } = useDatePickerContext();\n\n const selectionVariant = selectionVariantProp ?? pickerSelectionVariant;\n\n const endDateInputID = useId();\n const startDateInputID = useId();\n\n const [focused, setFocused] = useState(false);\n const [startDateStringValue, setStartDateStringValue] = useState<string>(\n dateFormatter(startDate)\n );\n const [endDateStringValue, setEndDateStringValue] = useState<string>(\n dateFormatter(endDate)\n );\n\n const {\n a11yProps: {\n \"aria-describedby\": formFieldDescribedBy,\n \"aria-labelledby\": formFieldLabelledBy,\n } = {},\n disabled: formFieldDisabled,\n readOnly: formFieldReadOnly,\n necessity: formFieldRequired,\n validationStatus: formFieldValidationStatus,\n } = useFormFieldProps();\n\n const isReadOnly = readOnlyProp || formFieldReadOnly;\n const isDisabled = disabled || formFieldDisabled;\n\n const validationStatus =\n validationStatusState ??\n formFieldValidationStatus ??\n validationStatusProp;\n\n const {\n \"aria-describedby\": dateInputDescribedBy,\n \"aria-labelledby\": dateInputLabelledBy,\n onBlur,\n onChange,\n onFocus,\n required: dateInputPropsRequired,\n ...restDateInputProps\n } = inputProps;\n\n const validateRange = useCallback(() => {\n if (startDate && endDate) {\n setValidationStatus(\n startDate?.compare(endDate) >= 1 ? \"error\" : undefined\n );\n }\n }, [endDate, startDate, setValidationStatus]);\n\n // Effects. Update date strings when dates change\n useEffect(() => {\n setStartDateStringValue(dateFormatter(startDate));\n validateRange();\n }, [startDate, dateFormatter, validateRange]);\n\n useEffect(() => {\n setEndDateStringValue(dateFormatter(endDate));\n validateRange();\n }, [endDate, dateFormatter, validateRange]);\n\n const isRequired = formFieldRequired\n ? [\"required\", \"asterisk\"].includes(formFieldRequired)\n : dateInputPropsRequired;\n const updateStartDate = (dateString: string) => {\n if (!dateString) setStartDate(undefined);\n const inputDate = inputStringFormatter(dateString);\n const calendarDate = getCalendarDate(inputDate);\n const emptyDateStatus = !calendarDate && inputDate ? \"error\" : undefined;\n setValidationStatus(\n getDateValidationStatus(dateString) ??\n getDateValidationStatus(endDateStringValue) ??\n emptyDateStatus\n );\n if (calendarDate) {\n setStartDate(calendarDate);\n }\n };\n\n const updateEndDate = (dateString: string) => {\n if (!dateString) setEndDate(undefined);\n const inputDate = inputStringFormatter(dateString);\n const calendarDate = getCalendarDate(inputDate);\n const emptyDateStatus = !calendarDate && inputDate ? \"error\" : undefined;\n setValidationStatus(\n getDateValidationStatus(dateString) ??\n getDateValidationStatus(startDateStringValue) ??\n emptyDateStatus\n );\n if (calendarDate) {\n setEndDate(calendarDate);\n }\n };\n\n // Handlers\n const handleFocus = (event: FocusEvent<HTMLInputElement>) => {\n onFocus?.(event);\n setFocused(true);\n };\n const handleStartDateBlur = (event: FocusEvent<HTMLInputElement>) => {\n updateStartDate(event.target.value);\n setFocused(false);\n onBlur?.(event);\n };\n\n const handleStartDateChange = (event: ChangeEvent<HTMLInputElement>) => {\n setStartDateStringValue(event.target.value);\n onChange?.(event);\n };\n\n const handleStartDateKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === \"Enter\") {\n updateStartDate(startDateStringValue);\n setOpen(false);\n }\n if (event.key === \"Tab\" && event.shiftKey && openState) {\n setOpen(false);\n }\n };\n\n const handleEndDateBlur = (event: FocusEvent<HTMLInputElement>) => {\n updateEndDate(event.target.value);\n setFocused(false);\n onBlur?.(event);\n };\n const handleEndDateChange = (event: ChangeEvent<HTMLInputElement>) => {\n setEndDateStringValue(event.target.value);\n onChange?.(event);\n };\n const handleEndDateKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === \"Enter\") {\n updateEndDate(endDateStringValue);\n setOpen(false);\n }\n };\n\n const handleInputClick = (event: SyntheticEvent<HTMLDivElement>) => {\n if (event.target === wrapperRef.current) {\n startInputRef?.current?.focus();\n }\n };\n\n return (\n <div\n className={clsx(\n withBaseName(),\n withBaseName(variant),\n {\n [withBaseName(\"focused\")]: !isDisabled && focused,\n [withBaseName(\"disabled\")]: isDisabled,\n [withBaseName(\"readOnly\")]: isReadOnly,\n [withBaseName(validationStatus ?? \"\")]: validationStatus,\n },\n className\n )}\n onClick={(event) => handleInputClick(event)}\n ref={inputRef}\n {...rest}\n >\n <input\n autoComplete=\"off\"\n aria-describedby={clsx(formFieldDescribedBy, dateInputDescribedBy)}\n aria-labelledby={clsx(\n formFieldLabelledBy,\n dateInputLabelledBy,\n startDateInputID\n )}\n aria-label={clsx(\"Start date\", ariaLabel)}\n id={startDateInputID}\n className={withBaseName(\"input\")}\n disabled={isDisabled}\n readOnly={isReadOnly}\n ref={startInputRef}\n tabIndex={isDisabled ? -1 : 0}\n onBlur={handleStartDateBlur}\n onChange={handleStartDateChange}\n onKeyDown={handleStartDateKeyDown}\n onFocus={!isDisabled ? handleFocus : undefined}\n placeholder={placeholder}\n size={placeholder.length}\n value={\n isReadOnly && !startDateStringValue\n ? emptyReadOnlyMarker\n : startDateStringValue\n }\n {...restDateInputProps}\n required={isRequired}\n />\n {selectionVariant === \"range\" && (\n <>\n <span>-</span>\n <input\n autoComplete=\"off\"\n aria-describedby={clsx(\n formFieldDescribedBy,\n dateInputDescribedBy\n )}\n aria-labelledby={clsx(\n formFieldLabelledBy,\n dateInputLabelledBy,\n endDateInputID\n )}\n aria-label={clsx(\"End date\", ariaLabel)}\n id={endDateInputID}\n className={withBaseName(\"input\")}\n disabled={isDisabled}\n readOnly={isReadOnly}\n ref={endInputRef}\n tabIndex={isDisabled ? -1 : 0}\n onBlur={handleEndDateBlur}\n onChange={handleEndDateChange}\n onKeyDown={handleEndDateKeyDown}\n onFocus={!isDisabled ? handleFocus : undefined}\n placeholder={placeholder}\n size={placeholder.length}\n value={\n isReadOnly && !endDateStringValue\n ? emptyReadOnlyMarker\n : endDateStringValue\n }\n required={isRequired}\n {...restDateInputProps}\n />\n </>\n )}\n {\n <div className={withBaseName(\"endAdornmentContainer\")}>\n {!isDisabled && !isReadOnly && validationStatus && (\n <StatusAdornment status={validationStatus} />\n )}\n {endAdornment}\n </div>\n }\n <div className={withBaseName(\"activationIndicator\")} />\n </div>\n );\n }\n);\n"],"names":["DateInput","dateInputCss","_a"],"mappings":";;;;;;;;;;AAoCA,MAAM,YAAA,GAAe,aAAa,eAAe,CAAA,CAAA;AACjD,MAAM,aAAA,GAAgB,CAAC,KAErB,KAAA,KAAA,IAAS,MAAM,IAAI,IAAA,CAAK,KAA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cACtC,EAAI,EAAA,cAAA;AAAA,cACJ,SAAA,EAAW,aAAa,OAAO,CAAA;AAAA,cAC/B,QAAU,EAAA,UAAA;AAAA,cACV,QAAU,EAAA,UAAA;AAAA,cACV,GAAK,EAAA,WAAA;AAAA,cACL,QAAA,EAAU,aAAa,CAAK,CAAA,GAAA,CAAA;AAAA,cAC5B,MAAQ,EAAA,iBAAA;AAAA,cACR,QAAU,EAAA,mBAAA;AAAA,cACV,SAAW,EAAA,oBAAA;AAAA,cACX,OAAA,EAAS,CAAC,UAAA,GAAa,WAAc,GAAA,KAAA,CAAA;AAAA,cACrC,WAAA;AAAA,cACA,MAAM,WAAY,CAAA,MAAA;AAAA,cAClB,KACE,EAAA,UAAA,IAAc,CAAC,kBAAA,GACX,mBACA,GAAA,kBAAA;AAAA,cAEN,QAAU,EAAA,UAAA;AAAA,cACT,GAAG,kBAAA;AAAA,aACN,CAAA;AAAA,WAAA;AAAA,SACF,CAAA;AAAA,wBAGC,IAAA,CAAA,KAAA,EAAA;AAAA,UAAI,SAAA,EAAW,aAAa,uBAAuB,CAAA;AAAA,UACjD,QAAA,EAAA;AAAA,YAAA,CAAC,UAAc,IAAA,CAAC,UAAc,IAAA,gBAAA,oBAC5B,GAAA,CAAA,eAAA,EAAA;AAAA,cAAgB,MAAQ,EAAA,gBAAA;AAAA,aAAkB,CAAA;AAAA,YAE5C,YAAA;AAAA,WAAA;AAAA,SACH,CAAA;AAAA,wBAED,GAAA,CAAA,KAAA,EAAA;AAAA,UAAI,SAAA,EAAW,aAAa,qBAAqB,CAAA;AAAA,SAAG,CAAA;AAAA,OAAA;AAAA,KACvD,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import { forwardRef, useState, useRef } from 'react';
|
|
4
|
+
import { makePrefixer, useControlled, useFloatingUI, useFormFieldProps, useForkRef, Button } from '@salt-ds/core';
|
|
5
|
+
import { DatePickerContext } from './DatePickerContext.js';
|
|
6
|
+
import { DatePickerPanel } from './DatePickerPanel.js';
|
|
7
|
+
import { flip, useInteractions, useDismiss } from '@floating-ui/react';
|
|
8
|
+
import { DateInput } from '../date-input/DateInput.js';
|
|
9
|
+
import { today, getLocalTimeZone } from '@internationalized/date';
|
|
10
|
+
import { CalendarIcon } from '@salt-ds/icons';
|
|
11
|
+
import '../calendar/Calendar.js';
|
|
12
|
+
import '../calendar/internal/CalendarContext.js';
|
|
13
|
+
import '../calendar/internal/utils.js';
|
|
14
|
+
import { isRangeOrOffsetSelectionWithStartDate } from '../calendar/useSelection.js';
|
|
15
|
+
|
|
16
|
+
const withBaseName = makePrefixer("saltDatePicker");
|
|
17
|
+
const DatePicker = forwardRef(
|
|
18
|
+
function DatePicker2({
|
|
19
|
+
selectionVariant = "default",
|
|
20
|
+
disabled = false,
|
|
21
|
+
placeholder = "dd mmm yyyy",
|
|
22
|
+
selectedDate: selectedDateProp,
|
|
23
|
+
defaultSelectedDate,
|
|
24
|
+
dateFormatter,
|
|
25
|
+
CalendarProps: CalendarProps2,
|
|
26
|
+
className,
|
|
27
|
+
open: openProp,
|
|
28
|
+
onOpenChange: onOpenChangeProp,
|
|
29
|
+
helperText,
|
|
30
|
+
readOnly: readOnlyProp,
|
|
31
|
+
inputAriaLabel,
|
|
32
|
+
...rest
|
|
33
|
+
}, ref) {
|
|
34
|
+
var _a;
|
|
35
|
+
const [open, setOpen] = useControlled({
|
|
36
|
+
controlled: openProp,
|
|
37
|
+
default: false,
|
|
38
|
+
name: "openPanel",
|
|
39
|
+
state: "openPanel"
|
|
40
|
+
});
|
|
41
|
+
const [startDate, setStartDate] = useControlled({
|
|
42
|
+
controlled: isRangeOrOffsetSelectionWithStartDate(selectedDateProp) ? selectedDateProp.startDate : selectedDateProp,
|
|
43
|
+
default: isRangeOrOffsetSelectionWithStartDate(defaultSelectedDate) ? defaultSelectedDate.startDate : defaultSelectedDate,
|
|
44
|
+
name: "StartDate",
|
|
45
|
+
state: "startDate"
|
|
46
|
+
});
|
|
47
|
+
const [endDate, setEndDate] = useControlled({
|
|
48
|
+
controlled: isRangeOrOffsetSelectionWithStartDate(selectedDateProp) ? selectedDateProp.endDate : selectedDateProp,
|
|
49
|
+
default: isRangeOrOffsetSelectionWithStartDate(defaultSelectedDate) ? defaultSelectedDate.endDate : void 0,
|
|
50
|
+
name: "EndDate",
|
|
51
|
+
state: "endDate"
|
|
52
|
+
});
|
|
53
|
+
const [validationStatusState, setValidationStatus] = useState(void 0);
|
|
54
|
+
const [startVisibleMonth, setStartVisibleMonth] = useState(startDate != null ? startDate : today(getLocalTimeZone()));
|
|
55
|
+
const [endVisibleMonth, setEndVisibleMonth] = useState(
|
|
56
|
+
(_a = endDate != null ? endDate : startDate == null ? void 0 : startDate.add({ months: 1 })) != null ? _a : today(getLocalTimeZone()).add({ months: 1 })
|
|
57
|
+
);
|
|
58
|
+
const onOpenChange = (newState) => {
|
|
59
|
+
var _a2;
|
|
60
|
+
setOpen(newState);
|
|
61
|
+
(_a2 = startInputRef == null ? void 0 : startInputRef.current) == null ? void 0 : _a2.focus();
|
|
62
|
+
onOpenChangeProp == null ? void 0 : onOpenChangeProp(newState);
|
|
63
|
+
};
|
|
64
|
+
const { x, y, strategy, elements, floating, reference, context } = useFloatingUI({
|
|
65
|
+
open,
|
|
66
|
+
onOpenChange,
|
|
67
|
+
placement: "bottom-start",
|
|
68
|
+
middleware: [flip({ fallbackStrategy: "initialPlacement" })]
|
|
69
|
+
});
|
|
70
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
71
|
+
useDismiss(context)
|
|
72
|
+
]);
|
|
73
|
+
const { disabled: formFieldDisabled, readOnly: formFieldReadOnly } = useFormFieldProps();
|
|
74
|
+
const isReadOnly = readOnlyProp || formFieldReadOnly;
|
|
75
|
+
const getPanelPosition = () => {
|
|
76
|
+
var _a2, _b;
|
|
77
|
+
return {
|
|
78
|
+
top: y != null ? y : 0,
|
|
79
|
+
left: x != null ? x : 0,
|
|
80
|
+
position: strategy,
|
|
81
|
+
width: (_a2 = elements.floating) == null ? void 0 : _a2.offsetWidth,
|
|
82
|
+
height: (_b = elements.floating) == null ? void 0 : _b.offsetHeight
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
const panelRef = useRef(null);
|
|
86
|
+
const startInputRef = useRef(null);
|
|
87
|
+
const endInputRef = useRef(null);
|
|
88
|
+
const inputRef = useForkRef(ref, reference);
|
|
89
|
+
const floatingRef = useForkRef(panelRef, floating);
|
|
90
|
+
const handleSelect = () => {
|
|
91
|
+
var _a2;
|
|
92
|
+
if (selectionVariant === "default" && startDate) {
|
|
93
|
+
(_a2 = startInputRef == null ? void 0 : startInputRef.current) == null ? void 0 : _a2.focus();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const handleCalendarButton = () => {
|
|
97
|
+
var _a2;
|
|
98
|
+
(_a2 = startInputRef == null ? void 0 : startInputRef.current) == null ? void 0 : _a2.focus();
|
|
99
|
+
setOpen(!open);
|
|
100
|
+
};
|
|
101
|
+
const datePickerContextValue = {
|
|
102
|
+
openState: open,
|
|
103
|
+
setOpen,
|
|
104
|
+
disabled,
|
|
105
|
+
endDate,
|
|
106
|
+
setEndDate,
|
|
107
|
+
defaultEndDate: isRangeOrOffsetSelectionWithStartDate(defaultSelectedDate) ? defaultSelectedDate.endDate : defaultSelectedDate,
|
|
108
|
+
startDate,
|
|
109
|
+
setStartDate,
|
|
110
|
+
startVisibleMonth,
|
|
111
|
+
setStartVisibleMonth,
|
|
112
|
+
endVisibleMonth,
|
|
113
|
+
setEndVisibleMonth,
|
|
114
|
+
defaultStartDate: isRangeOrOffsetSelectionWithStartDate(
|
|
115
|
+
defaultSelectedDate
|
|
116
|
+
) ? defaultSelectedDate.startDate : defaultSelectedDate,
|
|
117
|
+
selectionVariant,
|
|
118
|
+
context,
|
|
119
|
+
getPanelPosition,
|
|
120
|
+
validationStatusState,
|
|
121
|
+
setValidationStatus
|
|
122
|
+
};
|
|
123
|
+
return /* @__PURE__ */ jsxs(DatePickerContext.Provider, {
|
|
124
|
+
value: datePickerContextValue,
|
|
125
|
+
children: [
|
|
126
|
+
/* @__PURE__ */ jsx(DateInput, {
|
|
127
|
+
className: clsx(withBaseName(), className),
|
|
128
|
+
ref: inputRef,
|
|
129
|
+
...getReferenceProps(),
|
|
130
|
+
startInputRef,
|
|
131
|
+
endInputRef,
|
|
132
|
+
placeholder,
|
|
133
|
+
dateFormatter,
|
|
134
|
+
readOnly: isReadOnly,
|
|
135
|
+
ariaLabel: inputAriaLabel,
|
|
136
|
+
endAdornment: /* @__PURE__ */ jsx(Button, {
|
|
137
|
+
variant: "secondary",
|
|
138
|
+
onClick: handleCalendarButton,
|
|
139
|
+
disabled: disabled || isReadOnly || formFieldDisabled,
|
|
140
|
+
"aria-label": "Open Calendar",
|
|
141
|
+
children: /* @__PURE__ */ jsx(CalendarIcon, {
|
|
142
|
+
"aria-hidden": true
|
|
143
|
+
})
|
|
144
|
+
}),
|
|
145
|
+
...rest
|
|
146
|
+
}),
|
|
147
|
+
/* @__PURE__ */ jsx(DatePickerPanel, {
|
|
148
|
+
ref: floatingRef,
|
|
149
|
+
...getFloatingProps(),
|
|
150
|
+
onSelect: handleSelect,
|
|
151
|
+
CalendarProps: CalendarProps2,
|
|
152
|
+
helperText
|
|
153
|
+
})
|
|
154
|
+
]
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
export { DatePicker };
|
|
160
|
+
//# sourceMappingURL=DatePicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatePicker.js","sources":["../src/date-picker/DatePicker.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport { ComponentPropsWithoutRef, forwardRef, useRef, useState } from \"react\";\n\nimport {\n Button,\n makePrefixer,\n useControlled,\n useFloatingUI,\n useForkRef,\n useFormFieldProps,\n} from \"@salt-ds/core\";\nimport { DatePickerContext } from \"./DatePickerContext\";\nimport { DatePickerPanel } from \"./DatePickerPanel\";\nimport { flip, useDismiss, useInteractions } from \"@floating-ui/react\";\nimport { DateInput } from \"../date-input\";\nimport { DateValue, getLocalTimeZone, today } from \"@internationalized/date\";\nimport { CalendarIcon } from \"@salt-ds/icons\";\nimport {\n CalendarProps,\n isRangeOrOffsetSelectionWithStartDate,\n} from \"../calendar\";\n\nconst withBaseName = makePrefixer(\"saltDatePicker\");\n\nexport interface DatePickerProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"defaultValue\">,\n Pick<\n ComponentPropsWithoutRef<\"input\">,\n \"disabled\" | \"value\" | \"defaultValue\" | \"placeholder\"\n > {\n inputAriaLabel?: string;\n /**\n * Selection variant. Defaults to single select.\n */\n selectionVariant?: \"default\" | \"range\";\n /**\n * If `true`, the component will be disabled.\n */\n disabled?: boolean;\n /**\n * The selected date value. Use when the component is controlled.\n * Can be a single date or an object with start and end dates for range selection.\n */\n selectedDate?: DateValue | { startDate: DateValue; endDate: DateValue };\n /**\n * The default date value. Use when the component is not controlled.\n * Can be a single date or an object with start and end dates for range selection.\n */\n defaultSelectedDate?:\n | DateValue\n | { startDate: DateValue; endDate: DateValue };\n /**\n * Props to be passed to the Calendar component.\n */\n CalendarProps?: Partial<\n Omit<\n CalendarProps,\n | \"selectionVariant\"\n | \"selectedDate\"\n | \"defaultSelectedDate\"\n | \"onSelectedDateChange\"\n >\n >;\n /**\n * Function to format the input value.\n */\n dateFormatter?: (input: DateValue | undefined) => string;\n /**\n * Callback function triggered when open state changes.\n */\n onOpenChange?: (newOpen: boolean) => void;\n /**\n * Display or hide the component.\n */\n open?: boolean;\n /**\n * Helper text to display in the panel\n */\n helperText?: string;\n /**\n * If `true`, the component is read only.\n */\n readOnly?: boolean;\n}\n\nexport const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(\n function DatePicker(\n {\n selectionVariant = \"default\",\n disabled = false,\n placeholder = \"dd mmm yyyy\",\n selectedDate: selectedDateProp,\n defaultSelectedDate,\n dateFormatter,\n CalendarProps,\n className,\n open: openProp,\n onOpenChange: onOpenChangeProp,\n helperText,\n readOnly: readOnlyProp,\n inputAriaLabel,\n ...rest\n },\n ref\n ) {\n const [open, setOpen] = useControlled({\n controlled: openProp,\n default: false,\n name: \"openPanel\",\n state: \"openPanel\",\n });\n\n const [startDate, setStartDate] = useControlled({\n controlled: isRangeOrOffsetSelectionWithStartDate(selectedDateProp)\n ? selectedDateProp.startDate\n : selectedDateProp,\n default: isRangeOrOffsetSelectionWithStartDate(defaultSelectedDate)\n ? defaultSelectedDate.startDate\n : defaultSelectedDate,\n name: \"StartDate\",\n state: \"startDate\",\n });\n const [endDate, setEndDate] = useControlled({\n controlled: isRangeOrOffsetSelectionWithStartDate(selectedDateProp)\n ? selectedDateProp.endDate\n : selectedDateProp,\n default: isRangeOrOffsetSelectionWithStartDate(defaultSelectedDate)\n ? defaultSelectedDate.endDate\n : undefined,\n name: \"EndDate\",\n state: \"endDate\",\n });\n const [validationStatusState, setValidationStatus] = useState<\n \"error\" | undefined\n >(undefined);\n const [startVisibleMonth, setStartVisibleMonth] = useState<\n DateValue | undefined\n >(startDate ?? today(getLocalTimeZone()));\n const [endVisibleMonth, setEndVisibleMonth] = useState<\n DateValue | undefined\n >(\n endDate ??\n startDate?.add({ months: 1 }) ??\n today(getLocalTimeZone()).add({ months: 1 })\n );\n\n const onOpenChange = (newState: boolean) => {\n setOpen(newState);\n startInputRef?.current?.focus();\n onOpenChangeProp?.(newState);\n };\n\n const { x, y, strategy, elements, floating, reference, context } =\n useFloatingUI({\n open: open,\n onOpenChange: onOpenChange,\n placement: \"bottom-start\",\n middleware: [flip({ fallbackStrategy: \"initialPlacement\" })],\n });\n\n const { getReferenceProps, getFloatingProps } = useInteractions([\n useDismiss(context),\n ]);\n const { disabled: formFieldDisabled, readOnly: formFieldReadOnly } =\n useFormFieldProps();\n const isReadOnly = readOnlyProp || formFieldReadOnly;\n\n const getPanelPosition = () => ({\n top: y ?? 0,\n left: x ?? 0,\n position: strategy,\n width: elements.floating?.offsetWidth,\n height: elements.floating?.offsetHeight,\n });\n\n const panelRef = useRef<HTMLDivElement>(null);\n const startInputRef = useRef<HTMLInputElement>(null);\n const endInputRef = useRef<HTMLInputElement>(null);\n const inputRef = useForkRef<HTMLDivElement>(ref, reference);\n const floatingRef = useForkRef<HTMLDivElement>(panelRef, floating);\n\n // Handlers\n const handleSelect = () => {\n if (selectionVariant === \"default\" && startDate) {\n startInputRef?.current?.focus();\n }\n };\n const handleCalendarButton = () => {\n startInputRef?.current?.focus();\n setOpen(!open);\n };\n\n // Context\n const datePickerContextValue = {\n openState: open,\n setOpen,\n disabled,\n endDate,\n setEndDate,\n defaultEndDate: isRangeOrOffsetSelectionWithStartDate(defaultSelectedDate)\n ? defaultSelectedDate.endDate\n : defaultSelectedDate,\n startDate,\n setStartDate,\n startVisibleMonth,\n setStartVisibleMonth,\n endVisibleMonth,\n setEndVisibleMonth,\n defaultStartDate: isRangeOrOffsetSelectionWithStartDate(\n defaultSelectedDate\n )\n ? defaultSelectedDate.startDate\n : defaultSelectedDate,\n selectionVariant,\n context,\n getPanelPosition,\n validationStatusState,\n setValidationStatus,\n };\n\n return (\n <DatePickerContext.Provider value={datePickerContextValue}>\n <DateInput\n className={clsx(withBaseName(), className)}\n ref={inputRef}\n {...getReferenceProps()}\n startInputRef={startInputRef}\n endInputRef={endInputRef}\n placeholder={placeholder}\n dateFormatter={dateFormatter}\n readOnly={isReadOnly}\n ariaLabel={inputAriaLabel}\n endAdornment={\n <Button\n variant=\"secondary\"\n onClick={handleCalendarButton}\n disabled={disabled || isReadOnly || formFieldDisabled}\n aria-label=\"Open Calendar\"\n >\n <CalendarIcon aria-hidden />\n </Button>\n }\n {...rest}\n />\n <DatePickerPanel\n ref={floatingRef}\n {...getFloatingProps()}\n onSelect={handleSelect}\n CalendarProps={CalendarProps}\n helperText={helperText}\n />\n </DatePickerContext.Provider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CAAC,kBAAkB,QAAlB,EAAA;AAAA,MAA2B,KAAO,EAAA,sBAAA;AAAA,MACjC,QAAA,EAAA;AAAA,wBAAC,GAAA,CAAA,SAAA,EAAA;AAAA,UACC,SAAW,EAAA,IAAA,CAAK,YAAa,EAAA,EAAG,SAAS,CAAA;AAAA,UACzC,GAAK,EAAA,QAAA;AAAA,UACJ,GAAG,iBAAkB,EAAA;AAAA,UACtB,aAAA;AAAA,UACA,WAAA;AAAA,UACA,WAAA;AAAA,UACA,aAAA;AAAA,UACA,QAAU,EAAA,UAAA;AAAA,UACV,SAAW,EAAA,cAAA;AAAA,UACX,8BACG,GAAA,CAAA,MAAA,EAAA;AAAA,YACC,OAAQ,EAAA,WAAA;AAAA,YACR,OAAS,EAAA,oBAAA;AAAA,YACT,QAAA,EAAU,YAAY,UAAc,IAAA,iBAAA;AAAA,YACpC,YAAW,EAAA,eAAA;AAAA,YAEX,QAAC,kBAAA,GAAA,CAAA,YAAA,EAAA;AAAA,cAAa,aAAW,EAAA,IAAA;AAAA,aAAC,CAAA;AAAA,WAC5B,CAAA;AAAA,UAED,GAAG,IAAA;AAAA,SACN,CAAA;AAAA,wBACC,GAAA,CAAA,eAAA,EAAA;AAAA,UACC,GAAK,EAAA,WAAA;AAAA,UACJ,GAAG,gBAAiB,EAAA;AAAA,UACrB,QAAU,EAAA,YAAA;AAAA,UACV,aAAeD,EAAAA,cAAAA;AAAA,UACf,UAAA;AAAA,SACF,CAAA;AAAA,OAAA;AAAA,KACF,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createContext } from '@salt-ds/core';
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
|
|
4
|
+
const DatePickerContext = createContext(
|
|
5
|
+
"DatePickerContext",
|
|
6
|
+
{
|
|
7
|
+
openState: false,
|
|
8
|
+
setOpen: () => void 0,
|
|
9
|
+
disabled: false,
|
|
10
|
+
startDate: void 0,
|
|
11
|
+
defaultStartDate: void 0,
|
|
12
|
+
setStartDate: () => void 0,
|
|
13
|
+
startVisibleMonth: void 0,
|
|
14
|
+
setStartVisibleMonth: () => void 0,
|
|
15
|
+
endDate: void 0,
|
|
16
|
+
defaultEndDate: void 0,
|
|
17
|
+
setEndDate: () => void 0,
|
|
18
|
+
validationStatusState: void 0,
|
|
19
|
+
setValidationStatus: () => void 0,
|
|
20
|
+
endVisibleMonth: void 0,
|
|
21
|
+
setEndVisibleMonth: () => void 0,
|
|
22
|
+
selectionVariant: "default",
|
|
23
|
+
getPanelPosition: () => ({})
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
function useDatePickerContext() {
|
|
27
|
+
return useContext(DatePickerContext);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { DatePickerContext, useDatePickerContext };
|
|
31
|
+
//# sourceMappingURL=DatePickerContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatePickerContext.js","sources":["../src/date-picker/DatePickerContext.ts"],"sourcesContent":["import { createContext, UseFloatingUIReturn } from \"@salt-ds/core\";\nimport { useContext } from \"react\";\nimport { DateValue } from \"@internationalized/date\";\n\nexport interface DatePickerContextValue\n extends Partial<Pick<UseFloatingUIReturn, \"context\">> {\n openState: boolean;\n setOpen: (newOpen: boolean) => void;\n disabled: boolean;\n //start date values\n startDate: DateValue | undefined;\n defaultStartDate: DateValue | undefined;\n setStartDate: (newStartDate: DateValue | undefined) => void;\n startVisibleMonth: DateValue | undefined;\n setStartVisibleMonth: (newStartDate: DateValue | undefined) => void;\n // end date values for range picker\n endDate: DateValue | undefined;\n endVisibleMonth: DateValue | undefined;\n setEndVisibleMonth: (newStartDate: DateValue | undefined) => void;\n defaultEndDate: DateValue | undefined;\n setEndDate: (newEndDate: DateValue | undefined) => void;\n validationStatusState: \"error\" | undefined;\n setValidationStatus: (newStatus: \"error\" | undefined) => void;\n selectionVariant: \"default\" | \"range\";\n getPanelPosition: () => Record<string, unknown>;\n}\n\nexport const DatePickerContext = createContext<DatePickerContextValue>(\n \"DatePickerContext\",\n {\n openState: false,\n setOpen: () => undefined,\n disabled: false,\n startDate: undefined,\n defaultStartDate: undefined,\n setStartDate: () => undefined,\n startVisibleMonth: undefined,\n setStartVisibleMonth: () => undefined,\n endDate: undefined,\n defaultEndDate: undefined,\n setEndDate: () => undefined,\n validationStatusState: undefined,\n setValidationStatus: () => undefined,\n endVisibleMonth: undefined,\n setEndVisibleMonth: () => undefined,\n selectionVariant: \"default\",\n getPanelPosition: () => ({}),\n }\n);\n\nexport function useDatePickerContext() {\n return useContext(DatePickerContext);\n}\n"],"names":[],"mappings":";;;AA2BO,MAAM,iBAAoB,GAAA,aAAA;AAAA,EAC/B,mBAAA;AAAA,EACA;AAAA,IACE,SAAW,EAAA,KAAA;AAAA,IACX,SAAS,MAAM,KAAA,CAAA;AAAA,IACf,QAAU,EAAA,KAAA;AAAA,IACV,SAAW,EAAA,KAAA,CAAA;AAAA,IACX,gBAAkB,EAAA,KAAA,CAAA;AAAA,IAClB,cAAc,MAAM,KAAA,CAAA;AAAA,IACpB,iBAAmB,EAAA,KAAA,CAAA;AAAA,IACnB,sBAAsB,MAAM,KAAA,CAAA;AAAA,IAC5B,OAAS,EAAA,KAAA,CAAA;AAAA,IACT,cAAgB,EAAA,KAAA,CAAA;AAAA,IAChB,YAAY,MAAM,KAAA,CAAA;AAAA,IAClB,qBAAuB,EAAA,KAAA,CAAA;AAAA,IACvB,qBAAqB,MAAM,KAAA,CAAA;AAAA,IAC3B,eAAiB,EAAA,KAAA,CAAA;AAAA,IACjB,oBAAoB,MAAM,KAAA,CAAA;AAAA,IAC1B,gBAAkB,EAAA,SAAA;AAAA,IAClB,gBAAA,EAAkB,OAAO,EAAC,CAAA;AAAA,GAC5B;AACF,EAAA;AAEO,SAAS,oBAAuB,GAAA;AACrC,EAAA,OAAO,WAAW,iBAAiB,CAAA,CAAA;AACrC;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var css_248z = ".saltDatePickerPanel {\n background: var(--salt-container-primary-background);\n border: var(--salt-size-border) var(--salt-selectable-borderStyle-selected) var(--salt-selectable-borderColor-selected);\n overflow: hidden;\n overflow-y: auto;\n position: relative;\n z-index: var(--salt-zIndex-popout);\n box-shadow: var(--salt-overlayable-shadow-popout);\n box-sizing: border-box;\n display: flex;\n}\n.saltDatePickerPanel-container {\n width: min-content;\n gap: 1px;\n}\n\n.saltDatePickerPanel-header {\n padding: var(--salt-spacing-100);\n}\n";
|
|
2
|
+
|
|
3
|
+
export { css_248z as default };
|
|
4
|
+
//# sourceMappingURL=DatePickerPanel.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatePickerPanel.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|