@equinor/eds-core-react 0.37.0 → 0.38.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/eds-core-react.cjs +145 -74
- package/dist/esm/components/Autocomplete/Autocomplete.js +75 -41
- package/dist/esm/components/Autocomplete/Autocomplete.tokens.js +1 -1
- package/dist/esm/components/Button/tokens/contained.js +1 -1
- package/dist/esm/components/Button/tokens/contained_icon.js +1 -1
- package/dist/esm/components/Button/tokens/ghost.js +1 -1
- package/dist/esm/components/Button/tokens/icon.js +1 -1
- package/dist/esm/components/Button/tokens/outlined.js +1 -1
- package/dist/esm/components/Datepicker/DatePicker.js +13 -1
- package/dist/esm/components/Datepicker/DateRangePicker.js +15 -1
- package/dist/esm/components/Datepicker/fields/DateSegment.js +21 -3
- package/dist/esm/components/Datepicker/utils/context.js +6 -3
- package/dist/esm/components/Input/Input.tokens.js +1 -1
- package/dist/esm/components/InputWrapper/InputWrapper.tokens.js +1 -1
- package/dist/esm/components/Table/DataCell/DataCell.tokens.js +1 -1
- package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/internal/_curry1.js +0 -1
- package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/internal/_curry2.js +0 -1
- package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/internal/_curry3.js +0 -1
- package/dist/esm/node_modules/.pnpm/ramda@0.30.0/node_modules/ramda/es/internal/_isPlaceholder.js +7 -0
- package/dist/esm/node_modules/.pnpm/ramda@0.30.0/node_modules/ramda/es/internal/_placeholder.js +5 -0
- package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/mergeDeepRight.js +1 -3
- package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/mergeDeepWithKey.js +1 -3
- package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/mergeWith.js +1 -3
- package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/mergeWithKey.js +1 -3
- package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/pickBy.js +1 -3
- package/dist/types/components/Autocomplete/Autocomplete.d.ts +27 -16
- package/dist/types/components/Chip/Icon.d.ts +2 -6
- package/dist/types/components/Datepicker/DatePicker.d.ts +1 -0
- package/dist/types/components/Datepicker/DateRangePicker.d.ts +1 -0
- package/dist/types/components/Datepicker/calendars/CalendarWrapper.d.ts +1 -272
- package/dist/types/components/Datepicker/props.d.ts +6 -0
- package/dist/types/components/Datepicker/utils/context.d.ts +6 -1
- package/dist/types/components/Switch/Switch.styles.d.ts +4 -844
- package/package.json +13 -13
- package/dist/esm/node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/internal/_isPlaceholder.js +0 -5
- package/dist/types/components/Datepicker/utils/timezone.d.ts +0 -1
- /package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/internal/_has.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/internal/_isObject.js +0 -0
package/dist/eds-core-react.cjs
CHANGED
|
@@ -172,8 +172,12 @@ const button = {
|
|
|
172
172
|
}
|
|
173
173
|
};
|
|
174
174
|
|
|
175
|
+
var _placeholder = {
|
|
176
|
+
'@@functional/placeholder': true
|
|
177
|
+
};
|
|
178
|
+
|
|
175
179
|
function _isPlaceholder(a) {
|
|
176
|
-
return a
|
|
180
|
+
return a === _placeholder;
|
|
177
181
|
}
|
|
178
182
|
|
|
179
183
|
/**
|
|
@@ -184,7 +188,6 @@ function _isPlaceholder(a) {
|
|
|
184
188
|
* @param {Function} fn The function to curry.
|
|
185
189
|
* @return {Function} The curried function.
|
|
186
190
|
*/
|
|
187
|
-
|
|
188
191
|
function _curry1(fn) {
|
|
189
192
|
return function f1(a) {
|
|
190
193
|
if (arguments.length === 0 || _isPlaceholder(a)) {
|
|
@@ -203,7 +206,6 @@ function _curry1(fn) {
|
|
|
203
206
|
* @param {Function} fn The function to curry.
|
|
204
207
|
* @return {Function} The curried function.
|
|
205
208
|
*/
|
|
206
|
-
|
|
207
209
|
function _curry2(fn) {
|
|
208
210
|
return function f2(a, b) {
|
|
209
211
|
switch (arguments.length) {
|
|
@@ -231,7 +233,6 @@ function _curry2(fn) {
|
|
|
231
233
|
* @param {Function} fn The function to curry.
|
|
232
234
|
* @return {Function} The curried function.
|
|
233
235
|
*/
|
|
234
|
-
|
|
235
236
|
function _curry3(fn) {
|
|
236
237
|
return function f3(a, b, c) {
|
|
237
238
|
switch (arguments.length) {
|
|
@@ -300,9 +301,7 @@ function _isObject(x) {
|
|
|
300
301
|
* //=> { a: true, b: true, thing: 'bar', values: [10, 20, 15, 35] }
|
|
301
302
|
* @symb R.mergeWithKey(f, { x: 1, y: 2 }, { y: 5, z: 3 }) = { x: 1, y: f('y', 2, 5), z: 3 }
|
|
302
303
|
*/
|
|
303
|
-
|
|
304
|
-
var mergeWithKey = /*#__PURE__*/
|
|
305
|
-
_curry3(function mergeWithKey(fn, l, r) {
|
|
304
|
+
var mergeWithKey = /*#__PURE__*/_curry3(function mergeWithKey(fn, l, r) {
|
|
306
305
|
var result = {};
|
|
307
306
|
var k;
|
|
308
307
|
l = l || {};
|
|
@@ -348,9 +347,7 @@ _curry3(function mergeWithKey(fn, l, r) {
|
|
|
348
347
|
* { b: true, c: { thing: 'bar', values: [15, 35] }});
|
|
349
348
|
* //=> { a: true, b: true, c: { thing: 'bar', values: [10, 20, 15, 35] }}
|
|
350
349
|
*/
|
|
351
|
-
|
|
352
|
-
var mergeDeepWithKey = /*#__PURE__*/
|
|
353
|
-
_curry3(function mergeDeepWithKey(fn, lObj, rObj) {
|
|
350
|
+
var mergeDeepWithKey = /*#__PURE__*/_curry3(function mergeDeepWithKey(fn, lObj, rObj) {
|
|
354
351
|
return mergeWithKey(function (k, lVal, rVal) {
|
|
355
352
|
if (_isObject(lVal) && _isObject(rVal)) {
|
|
356
353
|
return mergeDeepWithKey(fn, lVal, rVal);
|
|
@@ -381,9 +378,7 @@ _curry3(function mergeDeepWithKey(fn, lObj, rObj) {
|
|
|
381
378
|
* { age: 40, contact: { email: 'baa@example.com' }});
|
|
382
379
|
* //=> { name: 'fred', age: 40, contact: { email: 'baa@example.com' }}
|
|
383
380
|
*/
|
|
384
|
-
|
|
385
|
-
var mergeDeepRight = /*#__PURE__*/
|
|
386
|
-
_curry2(function mergeDeepRight(lObj, rObj) {
|
|
381
|
+
var mergeDeepRight = /*#__PURE__*/_curry2(function mergeDeepRight(lObj, rObj) {
|
|
387
382
|
return mergeDeepWithKey(function (k, lVal, rVal) {
|
|
388
383
|
return rVal;
|
|
389
384
|
}, lObj, rObj);
|
|
@@ -412,9 +407,7 @@ _curry2(function mergeDeepRight(lObj, rObj) {
|
|
|
412
407
|
* { b: true, values: [15, 35] });
|
|
413
408
|
* //=> { a: true, b: true, values: [10, 20, 15, 35] }
|
|
414
409
|
*/
|
|
415
|
-
|
|
416
|
-
var mergeWith = /*#__PURE__*/
|
|
417
|
-
_curry3(function mergeWith(fn, l, r) {
|
|
410
|
+
var mergeWith = /*#__PURE__*/_curry3(function mergeWith(fn, l, r) {
|
|
418
411
|
return mergeWithKey(function (_, _l, _r) {
|
|
419
412
|
return fn(_l, _r);
|
|
420
413
|
}, l, r);
|
|
@@ -440,9 +433,7 @@ _curry3(function mergeWith(fn, l, r) {
|
|
|
440
433
|
* const isUpperCase = (val, key) => key.toUpperCase() === key;
|
|
441
434
|
* R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); //=> {A: 3, B: 4}
|
|
442
435
|
*/
|
|
443
|
-
|
|
444
|
-
var pickBy = /*#__PURE__*/
|
|
445
|
-
_curry2(function pickBy(test, obj) {
|
|
436
|
+
var pickBy = /*#__PURE__*/_curry2(function pickBy(test, obj) {
|
|
446
437
|
var result = {};
|
|
447
438
|
for (var prop in obj) {
|
|
448
439
|
if (test(obj[prop], prop, obj)) {
|
|
@@ -9435,19 +9426,25 @@ const StyledList = styled__default.default(List$1).withConfig({
|
|
|
9435
9426
|
})(({
|
|
9436
9427
|
theme
|
|
9437
9428
|
}) => styled.css(["background-color:", ";box-shadow:", ";", " overflow-y:auto;overflow-x:hidden;padding:0;display:grid;@supports (-moz-appearance:none){scrollbar-width:thin;}"], theme.background, theme.boxShadow, edsUtils.bordersTemplate(theme.border)));
|
|
9429
|
+
const StyledPopover = styled__default.default('div').withConfig({
|
|
9430
|
+
shouldForwardProp: () => true //workaround to avoid warning until popover gets added to react types
|
|
9431
|
+
}).withConfig({
|
|
9432
|
+
displayName: "Autocomplete__StyledPopover",
|
|
9433
|
+
componentId: "sc-yvif0e-2"
|
|
9434
|
+
})(["inset:unset;border:0;padding:0;margin:0;overflow:visible;"]);
|
|
9438
9435
|
const HelperText = styled__default.default(TextfieldHelperText).withConfig({
|
|
9439
9436
|
displayName: "Autocomplete__HelperText",
|
|
9440
|
-
componentId: "sc-yvif0e-
|
|
9437
|
+
componentId: "sc-yvif0e-3"
|
|
9441
9438
|
})(["margin-top:8px;margin-left:8px;"]);
|
|
9442
9439
|
const AutocompleteNoOptions = styled__default.default(AutocompleteOption).withConfig({
|
|
9443
9440
|
displayName: "Autocomplete__AutocompleteNoOptions",
|
|
9444
|
-
componentId: "sc-yvif0e-
|
|
9441
|
+
componentId: "sc-yvif0e-4"
|
|
9445
9442
|
})(({
|
|
9446
9443
|
theme
|
|
9447
9444
|
}) => styled.css(["color:", ";"], theme.entities.noOptions.typography.color));
|
|
9448
9445
|
const StyledButton$1 = styled__default.default(Button$1).withConfig({
|
|
9449
9446
|
displayName: "Autocomplete__StyledButton",
|
|
9450
|
-
componentId: "sc-yvif0e-
|
|
9447
|
+
componentId: "sc-yvif0e-5"
|
|
9451
9448
|
})(({
|
|
9452
9449
|
theme: {
|
|
9453
9450
|
entities: {
|
|
@@ -9531,6 +9528,20 @@ const findPrevIndex = ({
|
|
|
9531
9528
|
}
|
|
9532
9529
|
return prevIndex;
|
|
9533
9530
|
};
|
|
9531
|
+
|
|
9532
|
+
/*When a user clicks the StyledList scrollbar, the input looses focus which breaks downshift
|
|
9533
|
+
* keyboard navigation in the list. This code returns focus to the input on mouseUp
|
|
9534
|
+
*/
|
|
9535
|
+
const handleListFocus = e => {
|
|
9536
|
+
e.preventDefault();
|
|
9537
|
+
e.stopPropagation();
|
|
9538
|
+
window?.addEventListener('mouseup', () => {
|
|
9539
|
+
e.relatedTarget?.focus();
|
|
9540
|
+
}, {
|
|
9541
|
+
once: true
|
|
9542
|
+
});
|
|
9543
|
+
};
|
|
9544
|
+
const defaultOptionDisabled = () => false;
|
|
9534
9545
|
function AutocompleteInner(props, ref) {
|
|
9535
9546
|
const {
|
|
9536
9547
|
options = [],
|
|
@@ -9549,7 +9560,7 @@ function AutocompleteInner(props, ref) {
|
|
|
9549
9560
|
allowSelectAll,
|
|
9550
9561
|
initialSelectedOptions = [],
|
|
9551
9562
|
disablePortal,
|
|
9552
|
-
optionDisabled =
|
|
9563
|
+
optionDisabled = defaultOptionDisabled,
|
|
9553
9564
|
optionsFilter,
|
|
9554
9565
|
autoWidth,
|
|
9555
9566
|
placeholder,
|
|
@@ -9564,6 +9575,9 @@ function AutocompleteInner(props, ref) {
|
|
|
9564
9575
|
variant,
|
|
9565
9576
|
...other
|
|
9566
9577
|
} = props;
|
|
9578
|
+
if (disablePortal) {
|
|
9579
|
+
console.warn('Autocomplete "disablePortal" prop has been deprecated. Autocomplete now uses the native popover api');
|
|
9580
|
+
}
|
|
9567
9581
|
const isControlled = Boolean(selectedOptions);
|
|
9568
9582
|
const [inputOptions, setInputOptions] = react.useState(options);
|
|
9569
9583
|
const [_availableItems, setAvailableItems] = react.useState(inputOptions);
|
|
@@ -9578,13 +9592,8 @@ function AutocompleteInner(props, ref) {
|
|
|
9578
9592
|
if (showSelectAll) return [AllSymbol, ..._availableItems];
|
|
9579
9593
|
return _availableItems;
|
|
9580
9594
|
}, [_availableItems, showSelectAll]);
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
setSelectedItems([]);
|
|
9584
|
-
} else {
|
|
9585
|
-
setSelectedItems(inputOptions);
|
|
9586
|
-
}
|
|
9587
|
-
};
|
|
9595
|
+
|
|
9596
|
+
//issue 2304, update dataset when options are added dynamically
|
|
9588
9597
|
react.useEffect(() => {
|
|
9589
9598
|
const availableHash = JSON.stringify(inputOptions);
|
|
9590
9599
|
const optionsHash = JSON.stringify(options);
|
|
@@ -9595,7 +9604,6 @@ function AutocompleteInner(props, ref) {
|
|
|
9595
9604
|
react.useEffect(() => {
|
|
9596
9605
|
setAvailableItems(inputOptions);
|
|
9597
9606
|
}, [inputOptions]);
|
|
9598
|
-
const disabledItems = react.useMemo(() => options.filter(optionDisabled), [options, optionDisabled]);
|
|
9599
9607
|
const {
|
|
9600
9608
|
density
|
|
9601
9609
|
} = useEds();
|
|
@@ -9631,15 +9639,27 @@ function AutocompleteInner(props, ref) {
|
|
|
9631
9639
|
addSelectedItem,
|
|
9632
9640
|
removeSelectedItem,
|
|
9633
9641
|
selectedItems,
|
|
9634
|
-
reset: resetSelection,
|
|
9635
9642
|
setSelectedItems
|
|
9636
9643
|
} = downshift.useMultipleSelection(multipleSelectionProps);
|
|
9644
|
+
const enabledItems = react.useMemo(() => {
|
|
9645
|
+
const disabledItemsSet = new Set(inputOptions.filter(optionDisabled));
|
|
9646
|
+
return inputOptions.filter(x => !disabledItemsSet.has(x));
|
|
9647
|
+
}, [inputOptions, optionDisabled]);
|
|
9648
|
+
const selectedDisabledItemsSet = react.useMemo(() => new Set(selectedItems.filter(optionDisabled)), [selectedItems, optionDisabled]);
|
|
9649
|
+
const selectedEnabledItems = react.useMemo(() => selectedItems.filter(x => !selectedDisabledItemsSet.has(x)), [selectedItems, selectedDisabledItemsSet]);
|
|
9637
9650
|
const allSelectedState = react.useMemo(() => {
|
|
9638
|
-
if (!
|
|
9639
|
-
if (
|
|
9640
|
-
if (
|
|
9651
|
+
if (!enabledItems || !selectedEnabledItems) return 'NONE';
|
|
9652
|
+
if (enabledItems.length === selectedEnabledItems.length) return 'ALL';
|
|
9653
|
+
if (enabledItems.length != selectedEnabledItems.length && selectedEnabledItems.length > 0) return 'SOME';
|
|
9641
9654
|
return 'NONE';
|
|
9642
|
-
}, [
|
|
9655
|
+
}, [enabledItems, selectedEnabledItems]);
|
|
9656
|
+
const toggleAllSelected = () => {
|
|
9657
|
+
if (selectedEnabledItems.length === enabledItems.length) {
|
|
9658
|
+
setSelectedItems([...selectedDisabledItemsSet]);
|
|
9659
|
+
} else {
|
|
9660
|
+
setSelectedItems([...enabledItems, ...selectedDisabledItemsSet]);
|
|
9661
|
+
}
|
|
9662
|
+
};
|
|
9643
9663
|
const getLabel = react.useCallback(item => {
|
|
9644
9664
|
//note: non strict check for null or undefined to allow 0
|
|
9645
9665
|
if (item == null) {
|
|
@@ -9698,7 +9718,14 @@ function AutocompleteInner(props, ref) {
|
|
|
9698
9718
|
highlightedIndex,
|
|
9699
9719
|
type
|
|
9700
9720
|
}) {
|
|
9701
|
-
if (type
|
|
9721
|
+
if (type == downshift.useCombobox.stateChangeTypes.InputClick || type == downshift.useCombobox.stateChangeTypes.InputKeyDownArrowDown && !isOpen || type == downshift.useCombobox.stateChangeTypes.InputKeyDownArrowUp && !isOpen) {
|
|
9722
|
+
//needs delay for dropdown to render before calling scroll
|
|
9723
|
+
setTimeout(() => {
|
|
9724
|
+
rowVirtualizer.scrollToIndex(highlightedIndex, {
|
|
9725
|
+
align: allowSelectAll ? 'center' : 'auto'
|
|
9726
|
+
});
|
|
9727
|
+
}, 1);
|
|
9728
|
+
} else if (type !== downshift.useCombobox.stateChangeTypes.ItemMouseMove && type !== downshift.useCombobox.stateChangeTypes.MenuMouseLeave && highlightedIndex >= 0) {
|
|
9702
9729
|
rowVirtualizer.scrollToIndex(highlightedIndex, {
|
|
9703
9730
|
align: allowSelectAll ? 'center' : 'auto'
|
|
9704
9731
|
});
|
|
@@ -9809,7 +9836,7 @@ function AutocompleteInner(props, ref) {
|
|
|
9809
9836
|
}
|
|
9810
9837
|
}
|
|
9811
9838
|
if (multiple) {
|
|
9812
|
-
placeholderText = typeof placeholderText !== 'undefined' ? placeholderText : `${selectedItems.length}/${
|
|
9839
|
+
placeholderText = typeof placeholderText !== 'undefined' ? placeholderText : `${selectedItems.length}/${inputOptions.length} selected`;
|
|
9813
9840
|
comboBoxProps = {
|
|
9814
9841
|
...comboBoxProps,
|
|
9815
9842
|
selectedItem: null,
|
|
@@ -9901,11 +9928,6 @@ function AutocompleteInner(props, ref) {
|
|
|
9901
9928
|
inputValue,
|
|
9902
9929
|
reset: resetCombobox
|
|
9903
9930
|
} = downshift.useCombobox(comboBoxProps);
|
|
9904
|
-
react.useEffect(() => {
|
|
9905
|
-
if (isControlled) {
|
|
9906
|
-
setSelectedItems(selectedOptions);
|
|
9907
|
-
}
|
|
9908
|
-
}, [isControlled, selectedOptions, setSelectedItems]);
|
|
9909
9931
|
const {
|
|
9910
9932
|
x,
|
|
9911
9933
|
y,
|
|
@@ -9914,8 +9936,8 @@ function AutocompleteInner(props, ref) {
|
|
|
9914
9936
|
strategy
|
|
9915
9937
|
} = react$1.useFloating({
|
|
9916
9938
|
placement: 'bottom-start',
|
|
9917
|
-
middleware: [react$1.offset(4), react$1.flip(
|
|
9918
|
-
|
|
9939
|
+
middleware: [react$1.offset(4), react$1.flip({
|
|
9940
|
+
boundary: document?.body
|
|
9919
9941
|
}), react$1.size({
|
|
9920
9942
|
apply({
|
|
9921
9943
|
rects,
|
|
@@ -9937,25 +9959,31 @@ function AutocompleteInner(props, ref) {
|
|
|
9937
9959
|
return react$1.autoUpdate(refs.reference.current, refs.floating.current, update);
|
|
9938
9960
|
}
|
|
9939
9961
|
}, [refs.reference, refs.floating, update, isOpen]);
|
|
9962
|
+
edsUtils.useIsomorphicLayoutEffect(() => {
|
|
9963
|
+
if (isOpen) {
|
|
9964
|
+
refs.floating.current.showPopover();
|
|
9965
|
+
} else {
|
|
9966
|
+
refs.floating.current.hidePopover();
|
|
9967
|
+
}
|
|
9968
|
+
}, [isOpen, refs.floating]);
|
|
9940
9969
|
const clear = () => {
|
|
9941
9970
|
resetCombobox();
|
|
9942
|
-
|
|
9971
|
+
//dont clear items if they are selected and disabled
|
|
9972
|
+
setSelectedItems([...selectedDisabledItemsSet]);
|
|
9943
9973
|
setTypedInputValue('');
|
|
9944
9974
|
};
|
|
9945
9975
|
const showClearButton = (selectedItems.length > 0 || inputValue) && !readOnly && !hideClearButton;
|
|
9946
9976
|
const showNoOptions = isOpen && !availableItems.length && noOptionsText.length > 0;
|
|
9947
9977
|
const selectedItemsLabels = react.useMemo(() => selectedItems.map(getLabel), [selectedItems, getLabel]);
|
|
9948
|
-
|
|
9949
|
-
|
|
9950
|
-
const inDialog = edsUtils.useIsInDialog(refs.domReference.current);
|
|
9951
|
-
const optionsList = /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
9978
|
+
const optionsList = /*#__PURE__*/jsxRuntime.jsx(StyledPopover, {
|
|
9979
|
+
popover: "manual",
|
|
9952
9980
|
...getFloatingProps({
|
|
9953
9981
|
ref: refs.setFloating,
|
|
9982
|
+
onFocus: handleListFocus,
|
|
9954
9983
|
style: {
|
|
9955
9984
|
position: strategy,
|
|
9956
9985
|
top: y || 0,
|
|
9957
|
-
left: x || 0
|
|
9958
|
-
zIndex: 1500
|
|
9986
|
+
left: x || 0
|
|
9959
9987
|
}
|
|
9960
9988
|
}),
|
|
9961
9989
|
children: /*#__PURE__*/jsxRuntime.jsxs(StyledList, {
|
|
@@ -10099,10 +10127,7 @@ function AutocompleteInner(props, ref) {
|
|
|
10099
10127
|
color: variant ? tokens.variants[variant].typography.color : undefined,
|
|
10100
10128
|
text: helperText,
|
|
10101
10129
|
icon: helperIcon
|
|
10102
|
-
}),
|
|
10103
|
-
id: "eds-autocomplete-container",
|
|
10104
|
-
children: optionsList
|
|
10105
|
-
})]
|
|
10130
|
+
}), optionsList]
|
|
10106
10131
|
})
|
|
10107
10132
|
});
|
|
10108
10133
|
}
|
|
@@ -11541,6 +11566,26 @@ const FieldWrapper = /*#__PURE__*/react.forwardRef(({
|
|
|
11541
11566
|
InputFieldWrapper.displayName = 'InputFieldWrapper';
|
|
11542
11567
|
FieldWrapper.displayName = 'FieldWrapper';
|
|
11543
11568
|
|
|
11569
|
+
const intl = new Intl.DateTimeFormat();
|
|
11570
|
+
const defaultTimezone = intl.resolvedOptions().timeZone;
|
|
11571
|
+
const DatePickerContext = /*#__PURE__*/react.createContext({
|
|
11572
|
+
timezone: defaultTimezone
|
|
11573
|
+
});
|
|
11574
|
+
const DatePickerProvider = ({
|
|
11575
|
+
timezone,
|
|
11576
|
+
formatOptions,
|
|
11577
|
+
children
|
|
11578
|
+
}) => {
|
|
11579
|
+
return /*#__PURE__*/jsxRuntime.jsx(DatePickerContext.Provider, {
|
|
11580
|
+
value: {
|
|
11581
|
+
timezone: timezone ?? defaultTimezone,
|
|
11582
|
+
formatOptions
|
|
11583
|
+
},
|
|
11584
|
+
children: children
|
|
11585
|
+
});
|
|
11586
|
+
};
|
|
11587
|
+
const useDatePickerContext = () => react.useContext(DatePickerContext);
|
|
11588
|
+
|
|
11544
11589
|
const Segment = styled__default.default.div.withConfig({
|
|
11545
11590
|
displayName: "DateSegment__Segment",
|
|
11546
11591
|
componentId: "sc-19uidpx-0"
|
|
@@ -11555,12 +11600,29 @@ function DateSegment({
|
|
|
11555
11600
|
segment,
|
|
11556
11601
|
state
|
|
11557
11602
|
}) {
|
|
11603
|
+
const {
|
|
11604
|
+
formatOptions,
|
|
11605
|
+
timezone
|
|
11606
|
+
} = useDatePickerContext();
|
|
11607
|
+
const formatter = reactAria.useDateFormatter(formatOptions);
|
|
11608
|
+
const parts = state.value ? formatter.formatToParts(state.value.toDate(timezone)) : [];
|
|
11609
|
+
const part = parts.find(p => p.type === segment.type);
|
|
11610
|
+
const value = part?.value ?? segment.text;
|
|
11611
|
+
const [focus, setFocus] = react.useState(false);
|
|
11558
11612
|
const ref = react.useRef(null);
|
|
11559
11613
|
const {
|
|
11560
11614
|
segmentProps
|
|
11561
11615
|
} = reactAria.useDateSegment(segment, state, ref);
|
|
11562
11616
|
return /*#__PURE__*/jsxRuntime.jsx(Segment, {
|
|
11563
11617
|
...segmentProps,
|
|
11618
|
+
onFocus: e => {
|
|
11619
|
+
setFocus(true);
|
|
11620
|
+
segmentProps.onFocus(e);
|
|
11621
|
+
},
|
|
11622
|
+
onBlur: e => {
|
|
11623
|
+
setFocus(false);
|
|
11624
|
+
segmentProps.onBlur(e);
|
|
11625
|
+
},
|
|
11564
11626
|
$invalid: state.isInvalid,
|
|
11565
11627
|
$disabled: state.isDisabled,
|
|
11566
11628
|
$placeholder: segment.isPlaceholder,
|
|
@@ -11577,7 +11639,7 @@ function DateSegment({
|
|
|
11577
11639
|
},
|
|
11578
11640
|
ref: ref,
|
|
11579
11641
|
className: `segment ${segment.isPlaceholder ? 'placeholder' : ''}`,
|
|
11580
|
-
children: segment.isPlaceholder || segment.type === 'literal' ? segment.text : segment.text.padStart(segment.type === 'year' ? 4 : 2, '0')
|
|
11642
|
+
children: focus ? segment.isPlaceholder || segment.type === 'literal' ? segment.text : segment.text.padStart(segment.type === 'year' ? 4 : 2, '0') : value
|
|
11581
11643
|
});
|
|
11582
11644
|
}
|
|
11583
11645
|
|
|
@@ -11649,23 +11711,6 @@ const DateField = /*#__PURE__*/react.forwardRef(function ({
|
|
|
11649
11711
|
});
|
|
11650
11712
|
DateField.displayName = 'DateField';
|
|
11651
11713
|
|
|
11652
|
-
const intl = new Intl.DateTimeFormat();
|
|
11653
|
-
const defaultTimezone = intl.resolvedOptions().timeZone;
|
|
11654
|
-
const DatePickerContext = /*#__PURE__*/react.createContext({
|
|
11655
|
-
timezone: defaultTimezone
|
|
11656
|
-
});
|
|
11657
|
-
const DatePickerProvider = ({
|
|
11658
|
-
timezone,
|
|
11659
|
-
children
|
|
11660
|
-
}) => {
|
|
11661
|
-
return /*#__PURE__*/jsxRuntime.jsx(DatePickerContext.Provider, {
|
|
11662
|
-
value: {
|
|
11663
|
-
timezone: timezone ?? defaultTimezone
|
|
11664
|
-
},
|
|
11665
|
-
children: children
|
|
11666
|
-
});
|
|
11667
|
-
};
|
|
11668
|
-
|
|
11669
11714
|
const useConvertedValidationFunctions = (minValue, maxValue, isDateUnavailable, timezone) => {
|
|
11670
11715
|
const tz = timezone ?? defaultTimezone;
|
|
11671
11716
|
const _minValue = minValue ? date.toCalendarDate(date.fromDate(minValue, tz)) : undefined;
|
|
@@ -11755,9 +11800,15 @@ const DatePicker = /*#__PURE__*/react.forwardRef(({
|
|
|
11755
11800
|
granularity,
|
|
11756
11801
|
disabled: isDisabled,
|
|
11757
11802
|
readOnly: isReadOnly,
|
|
11803
|
+
formatOptions,
|
|
11758
11804
|
...props
|
|
11759
11805
|
}, forwardedRef) => {
|
|
11760
11806
|
timezone = timezone ?? defaultTimezone;
|
|
11807
|
+
formatOptions = formatOptions ?? {
|
|
11808
|
+
year: 'numeric',
|
|
11809
|
+
month: '2-digit',
|
|
11810
|
+
day: '2-digit'
|
|
11811
|
+
};
|
|
11761
11812
|
const [innerValue, setInnerValue] = react.useState(() => {
|
|
11762
11813
|
const initialValue = value ?? defaultValue;
|
|
11763
11814
|
if (initialValue) {
|
|
@@ -11833,8 +11884,14 @@ const DatePicker = /*#__PURE__*/react.forwardRef(({
|
|
|
11833
11884
|
data: edsIcons.warning_outlined
|
|
11834
11885
|
})
|
|
11835
11886
|
} : undefined;
|
|
11887
|
+
|
|
11888
|
+
// innerValue is used as a fallback, especially for uncontrolled inputs, so it needs to be reset when value / defaultValue is reset
|
|
11889
|
+
react.useEffect(() => {
|
|
11890
|
+
if (!defaultValue && !value) setInnerValue(null);
|
|
11891
|
+
}, [defaultValue, value]);
|
|
11836
11892
|
return /*#__PURE__*/jsxRuntime.jsx(DatePickerProvider, {
|
|
11837
11893
|
timezone: timezone,
|
|
11894
|
+
formatOptions: formatOptions,
|
|
11838
11895
|
children: /*#__PURE__*/jsxRuntime.jsx(FieldWrapper, {
|
|
11839
11896
|
isOpen: isOpen,
|
|
11840
11897
|
readonly: fieldProps.isReadOnly,
|
|
@@ -11987,11 +12044,17 @@ const DateRangePicker = /*#__PURE__*/react.forwardRef(({
|
|
|
11987
12044
|
Header,
|
|
11988
12045
|
timezone,
|
|
11989
12046
|
defaultValue,
|
|
12047
|
+
formatOptions,
|
|
11990
12048
|
disabled: isDisabled,
|
|
11991
12049
|
readOnly: isReadOnly,
|
|
11992
12050
|
...props
|
|
11993
12051
|
}, forwardedRef) => {
|
|
11994
12052
|
timezone = timezone ?? defaultTimezone;
|
|
12053
|
+
formatOptions = formatOptions ?? {
|
|
12054
|
+
year: 'numeric',
|
|
12055
|
+
month: '2-digit',
|
|
12056
|
+
day: '2-digit'
|
|
12057
|
+
};
|
|
11995
12058
|
const [innerValue, setInnerValue] = react.useState(() => {
|
|
11996
12059
|
const initialValue = value ?? defaultValue;
|
|
11997
12060
|
if (initialValue) {
|
|
@@ -12065,8 +12128,16 @@ const DateRangePicker = /*#__PURE__*/react.forwardRef(({
|
|
|
12065
12128
|
day: '2-digit'
|
|
12066
12129
|
});
|
|
12067
12130
|
const valueString = formattedValue ? Object.values(formattedValue).join(' - ') : null;
|
|
12131
|
+
|
|
12132
|
+
// innerValue is used as a fallback, especially for uncontrolled inputs, so it needs to be reset when value / defaultValue is reset
|
|
12133
|
+
react.useEffect(() => {
|
|
12134
|
+
const val = defaultValue ?? value;
|
|
12135
|
+
if (!defaultValue && !value) setInnerValue(null);
|
|
12136
|
+
if (!val?.from && !val?.to) setInnerValue(null);
|
|
12137
|
+
}, [defaultValue, value]);
|
|
12068
12138
|
return /*#__PURE__*/jsxRuntime.jsx(DatePickerProvider, {
|
|
12069
12139
|
timezone: timezone,
|
|
12140
|
+
formatOptions: formatOptions,
|
|
12070
12141
|
children: /*#__PURE__*/jsxRuntime.jsx(FieldWrapper, {
|
|
12071
12142
|
isOpen: isOpen,
|
|
12072
12143
|
color: state.isInvalid ? 'warning' : props.variant,
|