@equinor/eds-core-react 0.32.3 → 0.32.4
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 +115 -35
- package/dist/esm/components/Autocomplete/Autocomplete.js +36 -21
- package/dist/esm/components/Autocomplete/Option.js +5 -2
- package/dist/esm/components/Chip/Chip.js +2 -2
- package/dist/esm/components/Chip/Icon.js +1 -1
- package/dist/esm/components/Dialog/Dialog.js +5 -6
- package/dist/esm/components/Icon/Icon.js +3 -3
- package/dist/esm/node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/mergeWith.js +36 -0
- package/dist/esm/node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/pickBy.js +36 -0
- package/dist/types/components/Autocomplete/Autocomplete.d.ts +2 -2
- package/dist/types/components/Autocomplete/Option.d.ts +2 -2
- package/package.json +3 -3
package/dist/eds-core-react.cjs
CHANGED
|
@@ -369,6 +369,71 @@ _curry2(function mergeDeepRight(lObj, rObj) {
|
|
|
369
369
|
});
|
|
370
370
|
var mergeDeepRight$1 = mergeDeepRight;
|
|
371
371
|
|
|
372
|
+
/**
|
|
373
|
+
* Creates a new object with the own properties of the two provided objects. If
|
|
374
|
+
* a key exists in both objects, the provided function is applied to the values
|
|
375
|
+
* associated with the key in each object, with the result being used as the
|
|
376
|
+
* value associated with the key in the returned object.
|
|
377
|
+
*
|
|
378
|
+
* @func
|
|
379
|
+
* @memberOf R
|
|
380
|
+
* @since v0.19.0
|
|
381
|
+
* @category Object
|
|
382
|
+
* @sig ((a, a) -> a) -> {a} -> {a} -> {a}
|
|
383
|
+
* @param {Function} fn
|
|
384
|
+
* @param {Object} l
|
|
385
|
+
* @param {Object} r
|
|
386
|
+
* @return {Object}
|
|
387
|
+
* @see R.mergeDeepWith, R.merge, R.mergeWithKey
|
|
388
|
+
* @example
|
|
389
|
+
*
|
|
390
|
+
* R.mergeWith(R.concat,
|
|
391
|
+
* { a: true, values: [10, 20] },
|
|
392
|
+
* { b: true, values: [15, 35] });
|
|
393
|
+
* //=> { a: true, b: true, values: [10, 20, 15, 35] }
|
|
394
|
+
*/
|
|
395
|
+
|
|
396
|
+
var mergeWith = /*#__PURE__*/
|
|
397
|
+
_curry3(function mergeWith(fn, l, r) {
|
|
398
|
+
return mergeWithKey(function (_, _l, _r) {
|
|
399
|
+
return fn(_l, _r);
|
|
400
|
+
}, l, r);
|
|
401
|
+
});
|
|
402
|
+
var mergeWith$1 = mergeWith;
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Returns a partial copy of an object containing only the keys that satisfy
|
|
406
|
+
* the supplied predicate.
|
|
407
|
+
*
|
|
408
|
+
* @func
|
|
409
|
+
* @memberOf R
|
|
410
|
+
* @since v0.8.0
|
|
411
|
+
* @category Object
|
|
412
|
+
* @sig ((v, k) -> Boolean) -> {k: v} -> {k: v}
|
|
413
|
+
* @param {Function} pred A predicate to determine whether or not a key
|
|
414
|
+
* should be included on the output object.
|
|
415
|
+
* @param {Object} obj The object to copy from
|
|
416
|
+
* @return {Object} A new object with only properties that satisfy `pred`
|
|
417
|
+
* on it.
|
|
418
|
+
* @see R.pick, R.filter
|
|
419
|
+
* @example
|
|
420
|
+
*
|
|
421
|
+
* const isUpperCase = (val, key) => key.toUpperCase() === key;
|
|
422
|
+
* R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); //=> {A: 3, B: 4}
|
|
423
|
+
*/
|
|
424
|
+
|
|
425
|
+
var pickBy = /*#__PURE__*/
|
|
426
|
+
_curry2(function pickBy(test, obj) {
|
|
427
|
+
var result = {};
|
|
428
|
+
for (var prop in obj) {
|
|
429
|
+
if (test(obj[prop], prop, obj)) {
|
|
430
|
+
result[prop] = obj[prop];
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
return result;
|
|
434
|
+
});
|
|
435
|
+
var pickBy$1 = pickBy;
|
|
436
|
+
|
|
372
437
|
var _tokens$colors$k = edsTokens.tokens.colors,
|
|
373
438
|
primaryWhite$2 = _tokens$colors$k.text.static_icons__primary_white.rgba,
|
|
374
439
|
_tokens$colors$intera$k = _tokens$colors$k.interactive,
|
|
@@ -2627,13 +2692,13 @@ var StyledSvg = styled__default.default.svg.attrs(function (_ref2) {
|
|
|
2627
2692
|
componentId: "sc-6evbi1-0"
|
|
2628
2693
|
})(["", ""], transform);
|
|
2629
2694
|
var StyledPath$2 = styled__default.default.path.attrs(function (_ref3) {
|
|
2630
|
-
var height = _ref3
|
|
2695
|
+
var $height = _ref3.$height,
|
|
2631
2696
|
size = _ref3.size;
|
|
2632
2697
|
return {
|
|
2633
2698
|
size: null,
|
|
2634
2699
|
fillRule: 'evenodd',
|
|
2635
2700
|
clipRule: 'evenodd',
|
|
2636
|
-
transform: size / height !== 1 ? "scale(".concat(size / height, ")") : null
|
|
2701
|
+
transform: size / $height !== 1 ? "scale(".concat(size / $height, ")") : null
|
|
2637
2702
|
};
|
|
2638
2703
|
}).withConfig({
|
|
2639
2704
|
displayName: "Icon__StyledPath",
|
|
@@ -2689,7 +2754,7 @@ var Icon$2 = /*#__PURE__*/react.forwardRef(function Icon(_ref5, ref) {
|
|
|
2689
2754
|
};
|
|
2690
2755
|
var pathProps = {
|
|
2691
2756
|
d: icon.svgPathData,
|
|
2692
|
-
height: icon.height ? icon.height : size,
|
|
2757
|
+
$height: icon.height ? icon.height : size,
|
|
2693
2758
|
size: size || icon.height
|
|
2694
2759
|
};
|
|
2695
2760
|
|
|
@@ -4003,13 +4068,12 @@ var Dialog$1 = /*#__PURE__*/react.forwardRef(function Dialog(_ref3, ref) {
|
|
|
4003
4068
|
return edsUtils.mergeRefs(localRef, dialogRef);
|
|
4004
4069
|
}, [localRef, dialogRef]);
|
|
4005
4070
|
react.useEffect(function () {
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
localRef === null || localRef === void 0 ? void 0 : (_localRef$current2 = localRef.current) === null || _localRef$current2 === void 0 ? void 0 : _localRef$current2.showModal();
|
|
4071
|
+
if (open) {
|
|
4072
|
+
var _localRef$current;
|
|
4073
|
+
localRef === null || localRef === void 0 ? void 0 : (_localRef$current = localRef.current) === null || _localRef$current === void 0 ? void 0 : _localRef$current.showModal();
|
|
4010
4074
|
} else {
|
|
4011
|
-
var _localRef$
|
|
4012
|
-
localRef === null || localRef === void 0 ? void 0 : (_localRef$
|
|
4075
|
+
var _localRef$current2;
|
|
4076
|
+
localRef === null || localRef === void 0 ? void 0 : (_localRef$current2 = localRef.current) === null || _localRef$current2 === void 0 ? void 0 : _localRef$current2.close();
|
|
4013
4077
|
}
|
|
4014
4078
|
}, [open]);
|
|
4015
4079
|
|
|
@@ -4562,7 +4626,7 @@ var enabled$2 = enabled$3,
|
|
|
4562
4626
|
var Icon = styled__default.default(Icon$1).withConfig({
|
|
4563
4627
|
displayName: "Icon",
|
|
4564
4628
|
componentId: "sc-50ffvg-0"
|
|
4565
|
-
})(["cursor:pointer;padding:1px;", "
|
|
4629
|
+
})(["cursor:pointer;padding:1px;", " &:hover{", ";}", ""], edsUtils.bordersTemplate(enabled$2.entities.icon.border), function (_ref) {
|
|
4566
4630
|
var variant = _ref.variant;
|
|
4567
4631
|
switch (variant) {
|
|
4568
4632
|
case 'error':
|
|
@@ -4594,9 +4658,9 @@ var StyledChips = styled__default.default.div.attrs(function (_ref) {
|
|
|
4594
4658
|
}).withConfig({
|
|
4595
4659
|
displayName: "Chip__StyledChips",
|
|
4596
4660
|
componentId: "sc-wzsllq-0"
|
|
4597
|
-
})(["background:", ";height:", ";width:fit-content;display:grid;grid-gap:8px;grid-auto-flow:column;grid-auto-columns:max-content;align-items:center;svg{fill:", ";}
|
|
4661
|
+
})(["background:", ";height:", ";width:fit-content;display:grid;grid-gap:8px;grid-auto-flow:column;grid-auto-columns:max-content;align-items:center;svg{fill:", ";}&:focus{outline:none;}&[data-focus-visible-added]:focus{", "}&:focus-visible{", "}", " ", " ", " ", " ", " ", " ", " ", ""], background$4, height, typography$7.color, edsUtils.outlineTemplate(states$2.focus.outline), edsUtils.outlineTemplate(states$2.focus.outline), edsUtils.bordersTemplate(border$2), edsUtils.spacingsTemplate(spacings$1), edsUtils.typographyTemplate(typography$7), function (_ref2) {
|
|
4598
4662
|
var clickable = _ref2.clickable;
|
|
4599
|
-
return clickable && styled.css(["@media (hover:hover) and (pointer:fine){&:hover{cursor:pointer;}}"]);
|
|
4663
|
+
return clickable && styled.css(["@media (hover:hover) and (pointer:fine){&:hover{cursor:pointer;color:", ";svg{fill:", ";}}}"], states$2.hover.typography.color, states$2.hover.typography.color);
|
|
4600
4664
|
}, function (_ref3) {
|
|
4601
4665
|
var variant = _ref3.variant;
|
|
4602
4666
|
switch (variant) {
|
|
@@ -8268,7 +8332,7 @@ var StyledListItem = styled__default.default.li.withConfig({
|
|
|
8268
8332
|
active = _ref.active,
|
|
8269
8333
|
isdisabled = _ref.isdisabled;
|
|
8270
8334
|
var backgroundColor = highlighted === 'true' ? theme.states.hover.background : active === 'true' ? theme.states.active.background : theme.background;
|
|
8271
|
-
return styled.css(["display:flex;grid-area:1 / -1;align-items:center;align-self:start;margin:0;list-style:none;background-color:", ";user-select:none;overflow:hidden;cursor:", ";", " ", " ", ""], backgroundColor, highlighted === 'true' ? 'pointer' : 'default', edsUtils.typographyTemplate(theme.typography), edsUtils.spacingsTemplate(theme.spacings), isdisabled === 'true' ? styled.css(["color:", ";"], theme.states.disabled.typography.color) : '');
|
|
8335
|
+
return styled.css(["display:flex;grid-area:1 / -1;align-items:center;align-self:start;margin:0;list-style:none;background-color:", ";user-select:none;overflow:hidden;touch-action:manipulation;cursor:", ";", " ", " ", ""], backgroundColor, highlighted === 'true' ? 'pointer' : 'default', edsUtils.typographyTemplate(theme.typography), edsUtils.spacingsTemplate(theme.spacings), isdisabled === 'true' ? styled.css(["color:", ";"], theme.states.disabled.typography.color) : '');
|
|
8272
8336
|
});
|
|
8273
8337
|
var Label = styled__default.default.span.withConfig({
|
|
8274
8338
|
displayName: "Option__Label",
|
|
@@ -8294,7 +8358,10 @@ function AutocompleteOptionInner(props, ref) {
|
|
|
8294
8358
|
"aria-hidden": isDisabled,
|
|
8295
8359
|
active: !multiple && isSelected ? 'true' : 'false',
|
|
8296
8360
|
onClick: function onClick(e) {
|
|
8297
|
-
|
|
8361
|
+
//timeout: workaround for "Maximum update depth exceeded" error that happens when touch input
|
|
8362
|
+
setTimeout(function () {
|
|
8363
|
+
!isDisabled && _onClick(e);
|
|
8364
|
+
}, 0);
|
|
8298
8365
|
},
|
|
8299
8366
|
"aria-selected": multiple ? isSelected : ariaSelected
|
|
8300
8367
|
}, other), {}, {
|
|
@@ -8351,6 +8418,19 @@ var findIndex = function findIndex(_ref3) {
|
|
|
8351
8418
|
}
|
|
8352
8419
|
return index;
|
|
8353
8420
|
};
|
|
8421
|
+
var isEvent = function isEvent(val, key) {
|
|
8422
|
+
return /^on[A-Z](.*)/.test(key) && typeof val === 'function';
|
|
8423
|
+
};
|
|
8424
|
+
function mergeEventsFromRight(props1, props2) {
|
|
8425
|
+
var events1 = pickBy$1(isEvent, props1);
|
|
8426
|
+
var events2 = pickBy$1(isEvent, props2);
|
|
8427
|
+
return mergeWith$1(function (event1, event2) {
|
|
8428
|
+
return function () {
|
|
8429
|
+
event1.apply(void 0, arguments);
|
|
8430
|
+
event2.apply(void 0, arguments);
|
|
8431
|
+
};
|
|
8432
|
+
}, events1, events2);
|
|
8433
|
+
}
|
|
8354
8434
|
var findNextIndex = function findNextIndex(_ref4) {
|
|
8355
8435
|
var index = _ref4.index,
|
|
8356
8436
|
optionDisabled = _ref4.optionDisabled,
|
|
@@ -8531,6 +8611,9 @@ function AutocompleteInner(props, ref) {
|
|
|
8531
8611
|
var comboBoxProps = {
|
|
8532
8612
|
items: availableItems,
|
|
8533
8613
|
initialSelectedItem: initialSelectedOptions[0],
|
|
8614
|
+
isItemDisabled: function isItemDisabled(item) {
|
|
8615
|
+
return optionDisabled(item);
|
|
8616
|
+
},
|
|
8534
8617
|
itemToString: getLabel,
|
|
8535
8618
|
onInputValueChange: function onInputValueChange(_ref6) {
|
|
8536
8619
|
var inputValue = _ref6.inputValue;
|
|
@@ -8579,6 +8662,10 @@ function AutocompleteInner(props, ref) {
|
|
|
8579
8662
|
var changes = actionAndChanges.changes,
|
|
8580
8663
|
type = actionAndChanges.type;
|
|
8581
8664
|
switch (type) {
|
|
8665
|
+
case downshift.useCombobox.stateChangeTypes.InputClick:
|
|
8666
|
+
return _objectSpread__default.default(_objectSpread__default.default({}, changes), {}, {
|
|
8667
|
+
isOpen: !(disabled || readOnly)
|
|
8668
|
+
});
|
|
8582
8669
|
case downshift.useCombobox.stateChangeTypes.InputKeyDownArrowDown:
|
|
8583
8670
|
case downshift.useCombobox.stateChangeTypes.InputKeyDownHome:
|
|
8584
8671
|
return _objectSpread__default.default(_objectSpread__default.default({}, changes), {}, {
|
|
@@ -8676,7 +8763,6 @@ function AutocompleteInner(props, ref) {
|
|
|
8676
8763
|
getInputProps = _useCombobox.getInputProps,
|
|
8677
8764
|
highlightedIndex = _useCombobox.highlightedIndex,
|
|
8678
8765
|
getItemProps = _useCombobox.getItemProps,
|
|
8679
|
-
openMenu = _useCombobox.openMenu,
|
|
8680
8766
|
inputValue = _useCombobox.inputValue,
|
|
8681
8767
|
resetCombobox = _useCombobox.reset;
|
|
8682
8768
|
react.useEffect(function () {
|
|
@@ -8684,11 +8770,6 @@ function AutocompleteInner(props, ref) {
|
|
|
8684
8770
|
setSelectedItems(selectedOptions);
|
|
8685
8771
|
}
|
|
8686
8772
|
}, [isControlled, selectedOptions, setSelectedItems]);
|
|
8687
|
-
var openSelect = function openSelect() {
|
|
8688
|
-
if (!isOpen && !(disabled || readOnly)) {
|
|
8689
|
-
openMenu();
|
|
8690
|
-
}
|
|
8691
|
-
};
|
|
8692
8773
|
var _useFloating = react$1.useFloating({
|
|
8693
8774
|
placement: 'bottom-start',
|
|
8694
8775
|
middleware: [react$1.offset(4), react$1.flip(), react$1.shift({
|
|
@@ -8776,7 +8857,6 @@ function AutocompleteInner(props, ref) {
|
|
|
8776
8857
|
}), {}, {
|
|
8777
8858
|
item: item,
|
|
8778
8859
|
index: index,
|
|
8779
|
-
disabled: disabled,
|
|
8780
8860
|
style: _objectSpread__default.default({
|
|
8781
8861
|
transform: "translateY(".concat(virtualItem.start, "px)")
|
|
8782
8862
|
}, !multiline && {
|
|
@@ -8786,6 +8866,18 @@ function AutocompleteInner(props, ref) {
|
|
|
8786
8866
|
})]
|
|
8787
8867
|
}))
|
|
8788
8868
|
}));
|
|
8869
|
+
var inputProps = getInputProps(
|
|
8870
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
8871
|
+
getDropdownProps({
|
|
8872
|
+
preventKeyAction: multiple ? isOpen : undefined,
|
|
8873
|
+
disabled: disabled,
|
|
8874
|
+
ref: refs.setReference,
|
|
8875
|
+
onChange: function onChange(e) {
|
|
8876
|
+
var _e$currentTarget;
|
|
8877
|
+
return setTypedInputValue(e === null || e === void 0 ? void 0 : (_e$currentTarget = e.currentTarget) === null || _e$currentTarget === void 0 ? void 0 : _e$currentTarget.value);
|
|
8878
|
+
}
|
|
8879
|
+
}));
|
|
8880
|
+
var consolidatedEvents = mergeEventsFromRight(other, inputProps);
|
|
8789
8881
|
return /*#__PURE__*/jsxRuntime.jsx(styled.ThemeProvider, {
|
|
8790
8882
|
theme: token,
|
|
8791
8883
|
children: /*#__PURE__*/jsxRuntime.jsxs(Container$2, {
|
|
@@ -8797,21 +8889,9 @@ function AutocompleteInner(props, ref) {
|
|
|
8797
8889
|
meta: meta,
|
|
8798
8890
|
disabled: disabled
|
|
8799
8891
|
})), /*#__PURE__*/jsxRuntime.jsx(Container$2, {
|
|
8800
|
-
children: /*#__PURE__*/jsxRuntime.jsx(Input$4, _objectSpread__default.default(_objectSpread__default.default({},
|
|
8801
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
8802
|
-
getDropdownProps({
|
|
8803
|
-
preventKeyAction: multiple ? isOpen : undefined,
|
|
8804
|
-
disabled: disabled,
|
|
8805
|
-
ref: refs.setReference,
|
|
8806
|
-
onChange: function onChange(e) {
|
|
8807
|
-
var _e$currentTarget;
|
|
8808
|
-
return setTypedInputValue(e === null || e === void 0 ? void 0 : (_e$currentTarget = e.currentTarget) === null || _e$currentTarget === void 0 ? void 0 : _e$currentTarget.value);
|
|
8809
|
-
}
|
|
8810
|
-
}))), {}, {
|
|
8892
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Input$4, _objectSpread__default.default(_objectSpread__default.default(_objectSpread__default.default({}, inputProps), {}, {
|
|
8811
8893
|
placeholder: placeholderText,
|
|
8812
8894
|
readOnly: readOnly,
|
|
8813
|
-
onFocus: openSelect,
|
|
8814
|
-
onClick: openSelect,
|
|
8815
8895
|
rightAdornmentsWidth: hideClearButton ? 24 + 8 : 24 * 2 + 8,
|
|
8816
8896
|
rightAdornments: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
8817
8897
|
children: [loading && /*#__PURE__*/jsxRuntime.jsx(Progress.Circular, {
|
|
@@ -8838,7 +8918,7 @@ function AutocompleteInner(props, ref) {
|
|
|
8838
8918
|
})
|
|
8839
8919
|
}))]
|
|
8840
8920
|
})
|
|
8841
|
-
}, other))
|
|
8921
|
+
}, other), consolidatedEvents))
|
|
8842
8922
|
}), disablePortal || inDialog ? optionsList : /*#__PURE__*/jsxRuntime.jsx(react$1.FloatingPortal, {
|
|
8843
8923
|
id: "eds-autocomplete-container",
|
|
8844
8924
|
children: optionsList
|
|
@@ -16,6 +16,8 @@ import { bordersTemplate, useToken, useIsomorphicLayoutEffect, useIsInDialog } f
|
|
|
16
16
|
import { AutocompleteOption } from './Option.js';
|
|
17
17
|
import { useFloating, offset, flip, shift, size, useInteractions, autoUpdate, FloatingPortal } from '@floating-ui/react';
|
|
18
18
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
19
|
+
import pickBy from '../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/pickBy.js';
|
|
20
|
+
import mergeWith from '../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/mergeWith.js';
|
|
19
21
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
20
22
|
import { Label } from '../Label/Label.js';
|
|
21
23
|
import { Input } from '../Input/Input.js';
|
|
@@ -56,6 +58,19 @@ var findIndex = function findIndex(_ref3) {
|
|
|
56
58
|
}
|
|
57
59
|
return index;
|
|
58
60
|
};
|
|
61
|
+
var isEvent = function isEvent(val, key) {
|
|
62
|
+
return /^on[A-Z](.*)/.test(key) && typeof val === 'function';
|
|
63
|
+
};
|
|
64
|
+
function mergeEventsFromRight(props1, props2) {
|
|
65
|
+
var events1 = pickBy(isEvent, props1);
|
|
66
|
+
var events2 = pickBy(isEvent, props2);
|
|
67
|
+
return mergeWith(function (event1, event2) {
|
|
68
|
+
return function () {
|
|
69
|
+
event1.apply(void 0, arguments);
|
|
70
|
+
event2.apply(void 0, arguments);
|
|
71
|
+
};
|
|
72
|
+
}, events1, events2);
|
|
73
|
+
}
|
|
59
74
|
var findNextIndex = function findNextIndex(_ref4) {
|
|
60
75
|
var index = _ref4.index,
|
|
61
76
|
optionDisabled = _ref4.optionDisabled,
|
|
@@ -236,6 +251,9 @@ function AutocompleteInner(props, ref) {
|
|
|
236
251
|
var comboBoxProps = {
|
|
237
252
|
items: availableItems,
|
|
238
253
|
initialSelectedItem: initialSelectedOptions[0],
|
|
254
|
+
isItemDisabled: function isItemDisabled(item) {
|
|
255
|
+
return optionDisabled(item);
|
|
256
|
+
},
|
|
239
257
|
itemToString: getLabel,
|
|
240
258
|
onInputValueChange: function onInputValueChange(_ref6) {
|
|
241
259
|
var inputValue = _ref6.inputValue;
|
|
@@ -284,6 +302,10 @@ function AutocompleteInner(props, ref) {
|
|
|
284
302
|
var changes = actionAndChanges.changes,
|
|
285
303
|
type = actionAndChanges.type;
|
|
286
304
|
switch (type) {
|
|
305
|
+
case useCombobox.stateChangeTypes.InputClick:
|
|
306
|
+
return _objectSpread(_objectSpread({}, changes), {}, {
|
|
307
|
+
isOpen: !(disabled || readOnly)
|
|
308
|
+
});
|
|
287
309
|
case useCombobox.stateChangeTypes.InputKeyDownArrowDown:
|
|
288
310
|
case useCombobox.stateChangeTypes.InputKeyDownHome:
|
|
289
311
|
return _objectSpread(_objectSpread({}, changes), {}, {
|
|
@@ -381,7 +403,6 @@ function AutocompleteInner(props, ref) {
|
|
|
381
403
|
getInputProps = _useCombobox.getInputProps,
|
|
382
404
|
highlightedIndex = _useCombobox.highlightedIndex,
|
|
383
405
|
getItemProps = _useCombobox.getItemProps,
|
|
384
|
-
openMenu = _useCombobox.openMenu,
|
|
385
406
|
inputValue = _useCombobox.inputValue,
|
|
386
407
|
resetCombobox = _useCombobox.reset;
|
|
387
408
|
useEffect(function () {
|
|
@@ -389,11 +410,6 @@ function AutocompleteInner(props, ref) {
|
|
|
389
410
|
setSelectedItems(selectedOptions);
|
|
390
411
|
}
|
|
391
412
|
}, [isControlled, selectedOptions, setSelectedItems]);
|
|
392
|
-
var openSelect = function openSelect() {
|
|
393
|
-
if (!isOpen && !(disabled || readOnly)) {
|
|
394
|
-
openMenu();
|
|
395
|
-
}
|
|
396
|
-
};
|
|
397
413
|
var _useFloating = useFloating({
|
|
398
414
|
placement: 'bottom-start',
|
|
399
415
|
middleware: [offset(4), flip(), shift({
|
|
@@ -481,7 +497,6 @@ function AutocompleteInner(props, ref) {
|
|
|
481
497
|
}), {}, {
|
|
482
498
|
item: item,
|
|
483
499
|
index: index,
|
|
484
|
-
disabled: disabled,
|
|
485
500
|
style: _objectSpread({
|
|
486
501
|
transform: "translateY(".concat(virtualItem.start, "px)")
|
|
487
502
|
}, !multiline && {
|
|
@@ -491,6 +506,18 @@ function AutocompleteInner(props, ref) {
|
|
|
491
506
|
})]
|
|
492
507
|
}))
|
|
493
508
|
}));
|
|
509
|
+
var inputProps = getInputProps(
|
|
510
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
511
|
+
getDropdownProps({
|
|
512
|
+
preventKeyAction: multiple ? isOpen : undefined,
|
|
513
|
+
disabled: disabled,
|
|
514
|
+
ref: refs.setReference,
|
|
515
|
+
onChange: function onChange(e) {
|
|
516
|
+
var _e$currentTarget;
|
|
517
|
+
return setTypedInputValue(e === null || e === void 0 ? void 0 : (_e$currentTarget = e.currentTarget) === null || _e$currentTarget === void 0 ? void 0 : _e$currentTarget.value);
|
|
518
|
+
}
|
|
519
|
+
}));
|
|
520
|
+
var consolidatedEvents = mergeEventsFromRight(other, inputProps);
|
|
494
521
|
return /*#__PURE__*/jsx(ThemeProvider, {
|
|
495
522
|
theme: token,
|
|
496
523
|
children: /*#__PURE__*/jsxs(Container, {
|
|
@@ -502,21 +529,9 @@ function AutocompleteInner(props, ref) {
|
|
|
502
529
|
meta: meta,
|
|
503
530
|
disabled: disabled
|
|
504
531
|
})), /*#__PURE__*/jsx(Container, {
|
|
505
|
-
children: /*#__PURE__*/jsx(Input, _objectSpread(_objectSpread({},
|
|
506
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
507
|
-
getDropdownProps({
|
|
508
|
-
preventKeyAction: multiple ? isOpen : undefined,
|
|
509
|
-
disabled: disabled,
|
|
510
|
-
ref: refs.setReference,
|
|
511
|
-
onChange: function onChange(e) {
|
|
512
|
-
var _e$currentTarget;
|
|
513
|
-
return setTypedInputValue(e === null || e === void 0 ? void 0 : (_e$currentTarget = e.currentTarget) === null || _e$currentTarget === void 0 ? void 0 : _e$currentTarget.value);
|
|
514
|
-
}
|
|
515
|
-
}))), {}, {
|
|
532
|
+
children: /*#__PURE__*/jsx(Input, _objectSpread(_objectSpread(_objectSpread({}, inputProps), {}, {
|
|
516
533
|
placeholder: placeholderText,
|
|
517
534
|
readOnly: readOnly,
|
|
518
|
-
onFocus: openSelect,
|
|
519
|
-
onClick: openSelect,
|
|
520
535
|
rightAdornmentsWidth: hideClearButton ? 24 + 8 : 24 * 2 + 8,
|
|
521
536
|
rightAdornments: /*#__PURE__*/jsxs(Fragment, {
|
|
522
537
|
children: [loading && /*#__PURE__*/jsx(Progress.Circular, {
|
|
@@ -543,7 +558,7 @@ function AutocompleteInner(props, ref) {
|
|
|
543
558
|
})
|
|
544
559
|
}))]
|
|
545
560
|
})
|
|
546
|
-
}, other))
|
|
561
|
+
}, other), consolidatedEvents))
|
|
547
562
|
}), disablePortal || inDialog ? optionsList : /*#__PURE__*/jsx(FloatingPortal, {
|
|
548
563
|
id: "eds-autocomplete-container",
|
|
549
564
|
children: optionsList
|
|
@@ -16,7 +16,7 @@ var StyledListItem = styled.li.withConfig({
|
|
|
16
16
|
active = _ref.active,
|
|
17
17
|
isdisabled = _ref.isdisabled;
|
|
18
18
|
var backgroundColor = highlighted === 'true' ? theme.states.hover.background : active === 'true' ? theme.states.active.background : theme.background;
|
|
19
|
-
return css(["display:flex;grid-area:1 / -1;align-items:center;align-self:start;margin:0;list-style:none;background-color:", ";user-select:none;overflow:hidden;cursor:", ";", " ", " ", ""], backgroundColor, highlighted === 'true' ? 'pointer' : 'default', typographyTemplate(theme.typography), spacingsTemplate(theme.spacings), isdisabled === 'true' ? css(["color:", ";"], theme.states.disabled.typography.color) : '');
|
|
19
|
+
return css(["display:flex;grid-area:1 / -1;align-items:center;align-self:start;margin:0;list-style:none;background-color:", ";user-select:none;overflow:hidden;touch-action:manipulation;cursor:", ";", " ", " ", ""], backgroundColor, highlighted === 'true' ? 'pointer' : 'default', typographyTemplate(theme.typography), spacingsTemplate(theme.spacings), isdisabled === 'true' ? css(["color:", ";"], theme.states.disabled.typography.color) : '');
|
|
20
20
|
});
|
|
21
21
|
var Label = styled.span.withConfig({
|
|
22
22
|
displayName: "Option__Label",
|
|
@@ -42,7 +42,10 @@ function AutocompleteOptionInner(props, ref) {
|
|
|
42
42
|
"aria-hidden": isDisabled,
|
|
43
43
|
active: !multiple && isSelected ? 'true' : 'false',
|
|
44
44
|
onClick: function onClick(e) {
|
|
45
|
-
|
|
45
|
+
//timeout: workaround for "Maximum update depth exceeded" error that happens when touch input
|
|
46
|
+
setTimeout(function () {
|
|
47
|
+
!isDisabled && _onClick(e);
|
|
48
|
+
}, 0);
|
|
46
49
|
},
|
|
47
50
|
"aria-selected": multiple ? isSelected : ariaSelected
|
|
48
51
|
}, other), {}, {
|
|
@@ -26,9 +26,9 @@ var StyledChips = styled.div.attrs(function (_ref) {
|
|
|
26
26
|
}).withConfig({
|
|
27
27
|
displayName: "Chip__StyledChips",
|
|
28
28
|
componentId: "sc-wzsllq-0"
|
|
29
|
-
})(["background:", ";height:", ";width:fit-content;display:grid;grid-gap:8px;grid-auto-flow:column;grid-auto-columns:max-content;align-items:center;svg{fill:", ";}
|
|
29
|
+
})(["background:", ";height:", ";width:fit-content;display:grid;grid-gap:8px;grid-auto-flow:column;grid-auto-columns:max-content;align-items:center;svg{fill:", ";}&:focus{outline:none;}&[data-focus-visible-added]:focus{", "}&:focus-visible{", "}", " ", " ", " ", " ", " ", " ", " ", ""], background, height, typography.color, outlineTemplate(states.focus.outline), outlineTemplate(states.focus.outline), bordersTemplate(border), spacingsTemplate(spacings), typographyTemplate(typography), function (_ref2) {
|
|
30
30
|
var clickable = _ref2.clickable;
|
|
31
|
-
return clickable && css(["@media (hover:hover) and (pointer:fine){&:hover{cursor:pointer;}}"]);
|
|
31
|
+
return clickable && css(["@media (hover:hover) and (pointer:fine){&:hover{cursor:pointer;color:", ";svg{fill:", ";}}}"], states.hover.typography.color, states.hover.typography.color);
|
|
32
32
|
}, function (_ref3) {
|
|
33
33
|
var variant = _ref3.variant;
|
|
34
34
|
switch (variant) {
|
|
@@ -12,7 +12,7 @@ var enabled = enabled$1,
|
|
|
12
12
|
var Icon = styled(Icon$1).withConfig({
|
|
13
13
|
displayName: "Icon",
|
|
14
14
|
componentId: "sc-50ffvg-0"
|
|
15
|
-
})(["cursor:pointer;padding:1px;", "
|
|
15
|
+
})(["cursor:pointer;padding:1px;", " &:hover{", ";}", ""], bordersTemplate(enabled.entities.icon.border), function (_ref) {
|
|
16
16
|
var variant = _ref.variant;
|
|
17
17
|
switch (variant) {
|
|
18
18
|
case 'error':
|
|
@@ -44,13 +44,12 @@ var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref3, ref) {
|
|
|
44
44
|
return mergeRefs(localRef, dialogRef);
|
|
45
45
|
}, [localRef, dialogRef]);
|
|
46
46
|
useEffect(function () {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
localRef === null || localRef === void 0 ? void 0 : (_localRef$current2 = localRef.current) === null || _localRef$current2 === void 0 ? void 0 : _localRef$current2.showModal();
|
|
47
|
+
if (open) {
|
|
48
|
+
var _localRef$current;
|
|
49
|
+
localRef === null || localRef === void 0 ? void 0 : (_localRef$current = localRef.current) === null || _localRef$current === void 0 ? void 0 : _localRef$current.showModal();
|
|
51
50
|
} else {
|
|
52
|
-
var _localRef$
|
|
53
|
-
localRef === null || localRef === void 0 ? void 0 : (_localRef$
|
|
51
|
+
var _localRef$current2;
|
|
52
|
+
localRef === null || localRef === void 0 ? void 0 : (_localRef$current2 = localRef.current) === null || _localRef$current2 === void 0 ? void 0 : _localRef$current2.close();
|
|
54
53
|
}
|
|
55
54
|
}, [open]);
|
|
56
55
|
|
|
@@ -26,13 +26,13 @@ var StyledSvg = styled.svg.attrs(function (_ref2) {
|
|
|
26
26
|
componentId: "sc-6evbi1-0"
|
|
27
27
|
})(["", ""], transform);
|
|
28
28
|
var StyledPath = styled.path.attrs(function (_ref3) {
|
|
29
|
-
var height = _ref3
|
|
29
|
+
var $height = _ref3.$height,
|
|
30
30
|
size = _ref3.size;
|
|
31
31
|
return {
|
|
32
32
|
size: null,
|
|
33
33
|
fillRule: 'evenodd',
|
|
34
34
|
clipRule: 'evenodd',
|
|
35
|
-
transform: size / height !== 1 ? "scale(".concat(size / height, ")") : null
|
|
35
|
+
transform: size / $height !== 1 ? "scale(".concat(size / $height, ")") : null
|
|
36
36
|
};
|
|
37
37
|
}).withConfig({
|
|
38
38
|
displayName: "Icon__StyledPath",
|
|
@@ -88,7 +88,7 @@ var Icon = /*#__PURE__*/forwardRef(function Icon(_ref5, ref) {
|
|
|
88
88
|
};
|
|
89
89
|
var pathProps = {
|
|
90
90
|
d: icon.svgPathData,
|
|
91
|
-
height: icon.height ? icon.height : size,
|
|
91
|
+
$height: icon.height ? icon.height : size,
|
|
92
92
|
size: size || icon.height
|
|
93
93
|
};
|
|
94
94
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _curry3 from './internal/_curry3.js';
|
|
2
|
+
import mergeWithKey from './mergeWithKey.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new object with the own properties of the two provided objects. If
|
|
6
|
+
* a key exists in both objects, the provided function is applied to the values
|
|
7
|
+
* associated with the key in each object, with the result being used as the
|
|
8
|
+
* value associated with the key in the returned object.
|
|
9
|
+
*
|
|
10
|
+
* @func
|
|
11
|
+
* @memberOf R
|
|
12
|
+
* @since v0.19.0
|
|
13
|
+
* @category Object
|
|
14
|
+
* @sig ((a, a) -> a) -> {a} -> {a} -> {a}
|
|
15
|
+
* @param {Function} fn
|
|
16
|
+
* @param {Object} l
|
|
17
|
+
* @param {Object} r
|
|
18
|
+
* @return {Object}
|
|
19
|
+
* @see R.mergeDeepWith, R.merge, R.mergeWithKey
|
|
20
|
+
* @example
|
|
21
|
+
*
|
|
22
|
+
* R.mergeWith(R.concat,
|
|
23
|
+
* { a: true, values: [10, 20] },
|
|
24
|
+
* { b: true, values: [15, 35] });
|
|
25
|
+
* //=> { a: true, b: true, values: [10, 20, 15, 35] }
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
var mergeWith = /*#__PURE__*/
|
|
29
|
+
_curry3(function mergeWith(fn, l, r) {
|
|
30
|
+
return mergeWithKey(function (_, _l, _r) {
|
|
31
|
+
return fn(_l, _r);
|
|
32
|
+
}, l, r);
|
|
33
|
+
});
|
|
34
|
+
var mergeWith$1 = mergeWith;
|
|
35
|
+
|
|
36
|
+
export { mergeWith$1 as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _curry2 from './internal/_curry2.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns a partial copy of an object containing only the keys that satisfy
|
|
5
|
+
* the supplied predicate.
|
|
6
|
+
*
|
|
7
|
+
* @func
|
|
8
|
+
* @memberOf R
|
|
9
|
+
* @since v0.8.0
|
|
10
|
+
* @category Object
|
|
11
|
+
* @sig ((v, k) -> Boolean) -> {k: v} -> {k: v}
|
|
12
|
+
* @param {Function} pred A predicate to determine whether or not a key
|
|
13
|
+
* should be included on the output object.
|
|
14
|
+
* @param {Object} obj The object to copy from
|
|
15
|
+
* @return {Object} A new object with only properties that satisfy `pred`
|
|
16
|
+
* on it.
|
|
17
|
+
* @see R.pick, R.filter
|
|
18
|
+
* @example
|
|
19
|
+
*
|
|
20
|
+
* const isUpperCase = (val, key) => key.toUpperCase() === key;
|
|
21
|
+
* R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); //=> {A: 3, B: 4}
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
var pickBy = /*#__PURE__*/
|
|
25
|
+
_curry2(function pickBy(test, obj) {
|
|
26
|
+
var result = {};
|
|
27
|
+
for (var prop in obj) {
|
|
28
|
+
if (test(obj[prop], prop, obj)) {
|
|
29
|
+
result[prop] = obj[prop];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
});
|
|
34
|
+
var pickBy$1 = pickBy;
|
|
35
|
+
|
|
36
|
+
export { pickBy$1 as default };
|
|
@@ -44,7 +44,7 @@ export type AutocompleteProps<T> = {
|
|
|
44
44
|
onInputChange?: (text: string) => void;
|
|
45
45
|
/** Enable multiselect */
|
|
46
46
|
multiple?: boolean;
|
|
47
|
-
/** Custom option label */
|
|
47
|
+
/** Custom option label. NOTE: This is required when option is an object */
|
|
48
48
|
optionLabel?: (option: T) => string;
|
|
49
49
|
/** Custom option template */
|
|
50
50
|
optionComponent?: (option: T, isSelected: boolean) => ReactNode;
|
|
@@ -116,7 +116,7 @@ export declare const Autocomplete: <T>(props: {
|
|
|
116
116
|
onInputChange?: (text: string) => void;
|
|
117
117
|
/** Enable multiselect */
|
|
118
118
|
multiple?: boolean;
|
|
119
|
-
/** Custom option label */
|
|
119
|
+
/** Custom option label. NOTE: This is required when option is an object */
|
|
120
120
|
optionLabel?: (option: T) => string;
|
|
121
121
|
/** Custom option template */
|
|
122
122
|
optionComponent?: (option: T, isSelected: boolean) => ReactNode;
|
|
@@ -6,7 +6,7 @@ export type AutocompleteOptionProps<T> = {
|
|
|
6
6
|
isSelected: boolean;
|
|
7
7
|
isDisabled?: boolean;
|
|
8
8
|
multiline: boolean;
|
|
9
|
-
optionComponent?:
|
|
9
|
+
optionComponent?: ReactNode;
|
|
10
10
|
} & LiHTMLAttributes<HTMLLIElement>;
|
|
11
11
|
declare function AutocompleteOptionInner<T>(props: AutocompleteOptionProps<T>, ref: React.ForwardedRef<HTMLLIElement>): JSX.Element;
|
|
12
12
|
export declare const AutocompleteOption: <T>(props: {
|
|
@@ -16,7 +16,7 @@ export declare const AutocompleteOption: <T>(props: {
|
|
|
16
16
|
isSelected: boolean;
|
|
17
17
|
isDisabled?: boolean;
|
|
18
18
|
multiline: boolean;
|
|
19
|
-
optionComponent?:
|
|
19
|
+
optionComponent?: ReactNode;
|
|
20
20
|
} & LiHTMLAttributes<HTMLLIElement> & {
|
|
21
21
|
ref?: React.ForwardedRef<HTMLLIElement>;
|
|
22
22
|
displayName?: string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/eds-core-react",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.4",
|
|
4
4
|
"description": "The React implementation of the Equinor Design System",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"**/*.css"
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
85
|
"@babel/runtime": "^7.22.5",
|
|
86
|
-
"@floating-ui/react": "^0.
|
|
86
|
+
"@floating-ui/react": "^0.25.1",
|
|
87
87
|
"@tanstack/react-virtual": "3.0.0-beta.54",
|
|
88
|
-
"downshift": "^
|
|
88
|
+
"downshift": "^8.1.0",
|
|
89
89
|
"@equinor/eds-icons": "^0.19.3",
|
|
90
90
|
"@equinor/eds-tokens": "0.9.2",
|
|
91
91
|
"@equinor/eds-utils": "0.8.1"
|