@equinor/eds-core-react 0.44.0 → 0.45.1
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 +60 -52
- package/dist/esm/components/Autocomplete/Autocomplete.js +22 -6
- package/dist/esm/components/Banner/Banner.js +3 -3
- package/dist/esm/components/Breadcrumbs/Breadcrumb.js +1 -1
- package/dist/esm/components/Button/Button.js +20 -11
- package/dist/esm/components/Button/ButtonGroup/ButtonGroup.js +1 -1
- package/dist/esm/components/Button/ButtonGroup/ButtonGroup.tokens.js +0 -1
- package/dist/esm/components/Button/tokens/index.js +12 -12
- package/dist/esm/components/Checkbox/Input.js +1 -1
- package/dist/esm/components/Datepicker/DatePicker.js +1 -1
- package/dist/esm/components/Datepicker/DateRangePicker.js +1 -1
- package/dist/esm/components/Datepicker/calendars/CalendarCell.js +1 -1
- package/dist/esm/components/Datepicker/fields/DateFieldSegments.js +2 -1
- package/dist/esm/components/Datepicker/fields/Toggle.js +5 -2
- package/dist/esm/components/Datepicker/utils/get-calendar-date.js +1 -1
- package/dist/esm/components/Datepicker/utils/useGetLocale.js +7 -5
- package/dist/esm/components/Dialog/Dialog.js +3 -3
- package/dist/esm/components/EdsProvider/eds.context.js +1 -1
- package/dist/esm/components/Input/Input.js +1 -1
- package/dist/esm/components/InputWrapper/HelperText/HelperText.token.js +2 -6
- package/dist/esm/components/InputWrapper/InputWrapper.js +1 -1
- package/dist/esm/components/Label/Label.tokens.js +1 -4
- package/dist/esm/components/Menu/Menu.context.js +1 -1
- package/dist/esm/components/Menu/Menu.js +2 -2
- package/dist/esm/components/Menu/MenuItem.js +1 -1
- package/dist/esm/components/Pagination/Pagination.js +1 -1
- package/dist/esm/components/Paper/Paper.js +1 -1
- package/dist/esm/components/Popover/Popover.js +4 -4
- package/dist/esm/components/Progress/Circular/CircularProgress.js +1 -1
- package/dist/esm/components/Progress/Star/StarProgress.js +1 -1
- package/dist/esm/components/Radio/Radio.js +1 -1
- package/dist/esm/components/Search/Search.js +1 -1
- package/dist/esm/components/Select/NativeSelect.js +2 -2
- package/dist/esm/components/SideBar/SideBar.js +2 -2
- package/dist/esm/components/SideBar/SideBarAccordion/index.js +1 -1
- package/dist/esm/components/Slider/Slider.js +1 -1
- package/dist/esm/components/Slider/Slider.tokens.js +2 -6
- package/dist/esm/components/Slider/SliderInput.js +3 -3
- package/dist/esm/components/Snackbar/Snackbar.js +3 -3
- package/dist/esm/components/Switch/Switch.js +2 -2
- package/dist/esm/components/Switch/SwitchDefault.js +1 -1
- package/dist/esm/components/Switch/SwitchSmall.js +1 -1
- package/dist/esm/components/Table/DataCell/DataCell.js +2 -2
- package/dist/esm/components/Table/FooterCell/FooterCell.js +2 -2
- package/dist/esm/components/Table/HeaderCell/HeaderCell.js +3 -3
- package/dist/esm/components/TableOfContents/TableOfContents.js +3 -3
- package/dist/esm/components/TextField/TextField.js +2 -3
- package/dist/esm/components/Tooltip/Tooltip.js +2 -2
- package/dist/esm/components/Tooltip/Tooltip.tokens.js +1 -11
- package/dist/esm/components/TopBar/TopBar.js +3 -3
- package/dist/esm/components/Typography/Typography.js +1 -1
- package/dist/types/components/Autocomplete/Autocomplete.d.ts +7 -2
- package/dist/types/components/TextField/TextField.d.ts +1 -1
- package/package.json +33 -33
package/dist/eds-core-react.cjs
CHANGED
|
@@ -988,6 +988,16 @@ const ButtonBase = styled__default.default.button.withConfig({
|
|
|
988
988
|
} = states;
|
|
989
989
|
return styled.css(["box-sizing:border-box;margin:0;padding:0;text-decoration:none;position:relative;cursor:pointer;display:inline-block;background:", ";height:", ";width:", ";svg{justify-self:center;}", " ", " ", " &::after{position:absolute;top:-", ";left:-", ";width:", ";height:", ";content:'';}@media (hover:hover) and (pointer:fine){&:hover{background:", ";color:", ";", ";}}&:focus{outline:none;}&[data-focus-visible-added]:focus{", "}&:focus-visible{", "}&::-moz-focus-inner{border:0;}&:disabled,&[aria-disabled='true']{cursor:not-allowed;background:", ";", ";", ";@media (hover:hover) and (pointer:fine){&:hover{background:", ";}}}"], theme.background, theme.height, theme.width, edsUtils.spacingsTemplate(theme.spacings), edsUtils.bordersTemplate(theme.border), edsUtils.typographyTemplate(theme.typography), clickbound?.offset?.top, clickbound?.offset?.left, clickbound?.width, clickbound?.height, hover.background, hover.typography?.color, edsUtils.bordersTemplate(hover?.border), edsUtils.outlineTemplate(focus.outline), edsUtils.outlineTemplate(focus.outline), disabled.background, edsUtils.bordersTemplate(disabled.border), edsUtils.typographyTemplate(disabled.typography), disabled.background);
|
|
990
990
|
});
|
|
991
|
+
const getElementType$1 = (disabled, customType, href) => {
|
|
992
|
+
if (disabled) return 'button';
|
|
993
|
+
if (customType) return customType;
|
|
994
|
+
if (href) return 'a';
|
|
995
|
+
return 'button';
|
|
996
|
+
};
|
|
997
|
+
const getButtonType = (href, customElementType) => {
|
|
998
|
+
if (href || customElementType) return undefined;
|
|
999
|
+
return 'button';
|
|
1000
|
+
};
|
|
991
1001
|
const Button$2 = /*#__PURE__*/react.forwardRef(function Button({
|
|
992
1002
|
color = 'primary',
|
|
993
1003
|
variant = 'contained',
|
|
@@ -1004,25 +1014,24 @@ const Button$2 = /*#__PURE__*/react.forwardRef(function Button({
|
|
|
1004
1014
|
const token = edsUtils.useToken({
|
|
1005
1015
|
density
|
|
1006
1016
|
}, getToken$1(variant, color));
|
|
1007
|
-
const as =
|
|
1008
|
-
const type = href
|
|
1009
|
-
|
|
1017
|
+
const as = getElementType$1(disabled, other.as, href);
|
|
1018
|
+
const type = getButtonType(href, other.as);
|
|
1019
|
+
const adjustedTabIndex = disabled ? -1 : tabIndex;
|
|
1010
1020
|
const buttonProps = {
|
|
1011
1021
|
ref,
|
|
1012
|
-
as,
|
|
1013
1022
|
href,
|
|
1014
1023
|
type,
|
|
1015
1024
|
disabled,
|
|
1016
|
-
tabIndex,
|
|
1017
|
-
...other
|
|
1025
|
+
tabIndex: adjustedTabIndex,
|
|
1026
|
+
...other,
|
|
1027
|
+
as
|
|
1018
1028
|
};
|
|
1029
|
+
const Container = fullWidth ? InnerFullWidth : Inner;
|
|
1019
1030
|
return /*#__PURE__*/jsxRuntime.jsx(styled.ThemeProvider, {
|
|
1020
1031
|
theme: token,
|
|
1021
1032
|
children: /*#__PURE__*/jsxRuntime.jsx(ButtonBase, {
|
|
1022
1033
|
...buttonProps,
|
|
1023
|
-
children:
|
|
1024
|
-
children: children
|
|
1025
|
-
}) : /*#__PURE__*/jsxRuntime.jsx(Inner, {
|
|
1034
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Container, {
|
|
1026
1035
|
children: children
|
|
1027
1036
|
})
|
|
1028
1037
|
})
|
|
@@ -1038,7 +1047,6 @@ const {
|
|
|
1038
1047
|
} = edsTokens.tokens;
|
|
1039
1048
|
const group = {
|
|
1040
1049
|
border: {
|
|
1041
|
-
type: 'border',
|
|
1042
1050
|
radius: borderRadius$8
|
|
1043
1051
|
}
|
|
1044
1052
|
};
|
|
@@ -1046,7 +1054,7 @@ const group = {
|
|
|
1046
1054
|
const {
|
|
1047
1055
|
border: border$5
|
|
1048
1056
|
} = group;
|
|
1049
|
-
const radius$1 = border$5.
|
|
1057
|
+
const radius$1 = border$5.radius;
|
|
1050
1058
|
const ButtonGroupBase = styled__default.default.div.withConfig({
|
|
1051
1059
|
displayName: "ButtonGroup__ButtonGroupBase",
|
|
1052
1060
|
componentId: "sc-1fn8jon-0"
|
|
@@ -1109,19 +1117,9 @@ const tooltip = {
|
|
|
1109
1117
|
radius: borderRadius$7
|
|
1110
1118
|
},
|
|
1111
1119
|
entities: {
|
|
1112
|
-
tooltip: {
|
|
1113
|
-
height: spacingXlarge
|
|
1114
|
-
},
|
|
1115
1120
|
arrow: {
|
|
1116
1121
|
width: '6px',
|
|
1117
|
-
height: spacingSmall$4
|
|
1118
|
-
spacings: {
|
|
1119
|
-
bottom: '-6px',
|
|
1120
|
-
top: '-6px',
|
|
1121
|
-
left: '-6px',
|
|
1122
|
-
right: '-6px'
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1122
|
+
height: spacingSmall$4}
|
|
1125
1123
|
},
|
|
1126
1124
|
spacings: {
|
|
1127
1125
|
left: spacingSmall$4,
|
|
@@ -1878,7 +1876,7 @@ const StyledTableCell$1 = styled__default.default.th.withConfig({
|
|
|
1878
1876
|
const CellInner$1 = styled__default.default.div.withConfig({
|
|
1879
1877
|
displayName: "HeaderCell__CellInner",
|
|
1880
1878
|
componentId: "sc-18w2o3a-1"
|
|
1881
|
-
})(["display:flex;align-items:center;"]);
|
|
1879
|
+
})(["display:flex;align-items:center;height:100%;"]);
|
|
1882
1880
|
const TableHeaderCell = /*#__PURE__*/react.forwardRef(function TableHeaderCell({
|
|
1883
1881
|
children,
|
|
1884
1882
|
sort,
|
|
@@ -2261,10 +2259,7 @@ const label = {
|
|
|
2261
2259
|
},
|
|
2262
2260
|
spacings: {
|
|
2263
2261
|
left: comfortable$5.small,
|
|
2264
|
-
right: comfortable$5.small,
|
|
2265
|
-
top: '6px',
|
|
2266
|
-
bottom: '6px'
|
|
2267
|
-
},
|
|
2262
|
+
right: comfortable$5.small},
|
|
2268
2263
|
states: {
|
|
2269
2264
|
disabled: {
|
|
2270
2265
|
typography: {
|
|
@@ -2322,15 +2317,11 @@ const helperText = {
|
|
|
2322
2317
|
comfortable: {
|
|
2323
2318
|
left: comfortable$4.small,
|
|
2324
2319
|
right: comfortable$4.small,
|
|
2325
|
-
top: comfortable$4.small,
|
|
2326
|
-
bottom: '6px'
|
|
2327
|
-
},
|
|
2320
|
+
top: comfortable$4.small},
|
|
2328
2321
|
compact: {
|
|
2329
2322
|
left: comfortable$4.small,
|
|
2330
2323
|
right: comfortable$4.small,
|
|
2331
|
-
top: comfortable$4.xx_small
|
|
2332
|
-
bottom: '6px'
|
|
2333
|
-
}
|
|
2324
|
+
top: comfortable$4.xx_small}
|
|
2334
2325
|
}
|
|
2335
2326
|
};
|
|
2336
2327
|
|
|
@@ -3045,7 +3036,7 @@ const TextField = /*#__PURE__*/react.forwardRef(function TextField({
|
|
|
3045
3036
|
})]
|
|
3046
3037
|
}),
|
|
3047
3038
|
rowsMax,
|
|
3048
|
-
ref: inputRef || textareaRef,
|
|
3039
|
+
ref: ref || inputRef || textareaRef,
|
|
3049
3040
|
$multiline: multiline,
|
|
3050
3041
|
...other
|
|
3051
3042
|
};
|
|
@@ -3056,7 +3047,6 @@ const TextField = /*#__PURE__*/react.forwardRef(function TextField({
|
|
|
3056
3047
|
disabled
|
|
3057
3048
|
};
|
|
3058
3049
|
const containerProps = {
|
|
3059
|
-
ref,
|
|
3060
3050
|
className,
|
|
3061
3051
|
style: {
|
|
3062
3052
|
width: '100%',
|
|
@@ -5613,11 +5603,9 @@ const slider = {
|
|
|
5613
5603
|
background: indicatorColor,
|
|
5614
5604
|
states: {
|
|
5615
5605
|
hover: {
|
|
5616
|
-
|
|
5617
|
-
},
|
|
5606
|
+
},
|
|
5618
5607
|
disabled: {
|
|
5619
|
-
|
|
5620
|
-
}
|
|
5608
|
+
}
|
|
5621
5609
|
}
|
|
5622
5610
|
}
|
|
5623
5611
|
},
|
|
@@ -5669,7 +5657,6 @@ const slider = {
|
|
|
5669
5657
|
hover: {
|
|
5670
5658
|
background: primaryHoverAlt$3,
|
|
5671
5659
|
border: {
|
|
5672
|
-
type: 'border',
|
|
5673
5660
|
color: primaryHover$1
|
|
5674
5661
|
}
|
|
5675
5662
|
}
|
|
@@ -5694,7 +5681,6 @@ const slider = {
|
|
|
5694
5681
|
disabled: {
|
|
5695
5682
|
background: backgroundColorDisabled,
|
|
5696
5683
|
border: {
|
|
5697
|
-
type: 'border',
|
|
5698
5684
|
color: backgroundColorMedium$1
|
|
5699
5685
|
}
|
|
5700
5686
|
}
|
|
@@ -5754,9 +5740,9 @@ const {
|
|
|
5754
5740
|
} = slider;
|
|
5755
5741
|
const track$1 = styled.css(["width:100%;height:100%;cursor:pointer;background:none;"]);
|
|
5756
5742
|
const thumb = styled.css(["", " height:", ";width:", ";background:", ";cursor:pointer;position:relative;z-index:1;"], edsUtils.bordersTemplate(handle$1.border), handle$1.height, handle$1.width, handle$1.background);
|
|
5757
|
-
const thumbHover = styled.css(["@media (hover:hover) and (pointer:fine){box-shadow:0px 0px 0px 6px ", ";border-color:", ";}"], handle$1.states.hover.background, handle$1.states.hover.border.
|
|
5743
|
+
const thumbHover = styled.css(["@media (hover:hover) and (pointer:fine){box-shadow:0px 0px 0px 6px ", ";border-color:", ";}"], handle$1.states.hover.background, handle$1.states.hover.border.color);
|
|
5758
5744
|
const thumbHoverAndDisabled = styled.css(["@media (hover:hover) and (pointer:fine){cursor:not-allowed;box-shadow:none;}"]);
|
|
5759
|
-
const thumbDisabled = styled.css(["background-color:", ";border-color:", ";"], _disabled.background, _disabled.border.
|
|
5745
|
+
const thumbDisabled = styled.css(["background-color:", ";border-color:", ";"], _disabled.background, _disabled.border.color);
|
|
5760
5746
|
const StyledSliderInput = styled__default.default.input.attrs(() => ({
|
|
5761
5747
|
type: 'range'
|
|
5762
5748
|
})).withConfig({
|
|
@@ -9663,7 +9649,8 @@ function AutocompleteInner(props, ref) {
|
|
|
9663
9649
|
onInputChange,
|
|
9664
9650
|
selectedOptions: _selectedOptions,
|
|
9665
9651
|
multiple,
|
|
9666
|
-
|
|
9652
|
+
itemToKey: _itemToKey,
|
|
9653
|
+
itemCompare: _itemCompare,
|
|
9667
9654
|
allowSelectAll,
|
|
9668
9655
|
initialSelectedOptions: _initialSelectedOptions = [],
|
|
9669
9656
|
optionDisabled = defaultOptionDisabled,
|
|
@@ -9682,6 +9669,19 @@ function AutocompleteInner(props, ref) {
|
|
|
9682
9669
|
onClear,
|
|
9683
9670
|
...other
|
|
9684
9671
|
} = props;
|
|
9672
|
+
const itemCompare = react.useMemo(() => {
|
|
9673
|
+
if (_itemCompare && _itemToKey) {
|
|
9674
|
+
console.error('Error: Specifying both itemCompare and itemToKey. itemCompare is deprecated, while itemToKey should be used instead of it. Please only use one.');
|
|
9675
|
+
return _itemCompare;
|
|
9676
|
+
}
|
|
9677
|
+
if (_itemToKey) {
|
|
9678
|
+
return (o1, o2) => _itemToKey(o1) === _itemToKey(o2);
|
|
9679
|
+
}
|
|
9680
|
+
return _itemCompare;
|
|
9681
|
+
}, [_itemCompare, _itemToKey]);
|
|
9682
|
+
const itemToKey = react.useCallback(item => {
|
|
9683
|
+
return _itemToKey ? _itemToKey(item) : item;
|
|
9684
|
+
}, [_itemToKey]);
|
|
9685
9685
|
|
|
9686
9686
|
// MARK: initializing data/setup
|
|
9687
9687
|
const selectedOptions = _selectedOptions ? itemCompare ? options.filter(item => _selectedOptions.some(compare => itemCompare(item, compare))) : _selectedOptions : undefined;
|
|
@@ -9691,6 +9691,7 @@ function AutocompleteInner(props, ref) {
|
|
|
9691
9691
|
const [_availableItems, setAvailableItems] = react.useState(inputOptions);
|
|
9692
9692
|
const [typedInputValue, setTypedInputValue] = react.useState('');
|
|
9693
9693
|
const inputRef = react.useRef(null);
|
|
9694
|
+
react.useImperativeHandle(ref, () => inputRef.current);
|
|
9694
9695
|
const showSelectAll = react.useMemo(() => {
|
|
9695
9696
|
if (!multiple && allowSelectAll) {
|
|
9696
9697
|
throw new Error(`allowSelectAll can only be used with multiple`);
|
|
@@ -9722,6 +9723,7 @@ function AutocompleteInner(props, ref) {
|
|
|
9722
9723
|
const tokens = token();
|
|
9723
9724
|
let placeholderText = placeholder;
|
|
9724
9725
|
let multipleSelectionProps = {
|
|
9726
|
+
itemToKey,
|
|
9725
9727
|
initialSelectedItems: multiple ? initialSelectedOptions : initialSelectedOptions[0] ? [initialSelectedOptions[0]] : []
|
|
9726
9728
|
};
|
|
9727
9729
|
if (multiple) {
|
|
@@ -9824,6 +9826,7 @@ function AutocompleteInner(props, ref) {
|
|
|
9824
9826
|
isItemDisabled(item) {
|
|
9825
9827
|
return optionDisabled(item);
|
|
9826
9828
|
},
|
|
9829
|
+
itemToKey,
|
|
9827
9830
|
itemToString: getLabel,
|
|
9828
9831
|
onInputValueChange: ({
|
|
9829
9832
|
inputValue
|
|
@@ -10233,7 +10236,6 @@ function AutocompleteInner(props, ref) {
|
|
|
10233
10236
|
children: /*#__PURE__*/jsxRuntime.jsxs(Container$2, {
|
|
10234
10237
|
className: className,
|
|
10235
10238
|
style: style,
|
|
10236
|
-
ref: ref,
|
|
10237
10239
|
children: [/*#__PURE__*/jsxRuntime.jsx(Label$3, {
|
|
10238
10240
|
...getLabelProps(),
|
|
10239
10241
|
label: label,
|
|
@@ -11884,7 +11886,8 @@ const DateFieldSegments = /*#__PURE__*/react.forwardRef((props, ref) => {
|
|
|
11884
11886
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
11885
11887
|
...fieldProps,
|
|
11886
11888
|
style: {
|
|
11887
|
-
display: 'flex'
|
|
11889
|
+
display: 'flex',
|
|
11890
|
+
fontFamily: 'Equinor, Arial, sans-serif'
|
|
11888
11891
|
},
|
|
11889
11892
|
ref: ref,
|
|
11890
11893
|
children: state.segments.map((segment, i) => /*#__PURE__*/jsxRuntime.jsx(DateSegment, {
|
|
@@ -11964,7 +11967,10 @@ const Toggle = ({
|
|
|
11964
11967
|
showClearButton,
|
|
11965
11968
|
readonly
|
|
11966
11969
|
}) => {
|
|
11967
|
-
return
|
|
11970
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
11971
|
+
style: {
|
|
11972
|
+
visibility: readonly || disabled ? 'hidden' : 'visible'
|
|
11973
|
+
},
|
|
11968
11974
|
children: [showClearButton && /*#__PURE__*/jsxRuntime.jsx(StyledButton, {
|
|
11969
11975
|
disabled: disabled,
|
|
11970
11976
|
variant: 'ghost_icon',
|
|
@@ -12006,12 +12012,14 @@ const getCalendarDate = (value, timezone, showTimeInput = false) => {
|
|
|
12006
12012
|
|
|
12007
12013
|
const useGetLocale = locale => {
|
|
12008
12014
|
const {
|
|
12009
|
-
locale:
|
|
12015
|
+
locale: currentLocale
|
|
12010
12016
|
} = reactAria.useLocale();
|
|
12011
|
-
//
|
|
12012
|
-
|
|
12013
|
-
|
|
12014
|
-
|
|
12017
|
+
// Priority:
|
|
12018
|
+
// 1. Explicitly passed locale prop
|
|
12019
|
+
// 2. Locale from I18nProvider
|
|
12020
|
+
// 3. Fallback to browser's default
|
|
12021
|
+
const browserLocale = new Intl.DateTimeFormat().resolvedOptions().locale;
|
|
12022
|
+
return locale ?? currentLocale ?? browserLocale;
|
|
12015
12023
|
};
|
|
12016
12024
|
|
|
12017
12025
|
const DatePicker = /*#__PURE__*/react.forwardRef(({
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { forwardRef, useState, useRef,
|
|
1
|
+
import { forwardRef, useMemo, useCallback, useState, useRef, useImperativeHandle, useEffect } from 'react';
|
|
2
2
|
import { useMultipleSelection, useCombobox } from 'downshift';
|
|
3
3
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
4
|
-
import styled, {
|
|
4
|
+
import styled, { ThemeProvider, css } from 'styled-components';
|
|
5
5
|
import { Button } from '../Button/index.js';
|
|
6
6
|
import { List } from '../List/index.js';
|
|
7
7
|
import { Icon } from '../Icon/index.js';
|
|
8
8
|
import { Progress } from '../Progress/index.js';
|
|
9
9
|
import { close, arrow_drop_up, arrow_drop_down } from '@equinor/eds-icons';
|
|
10
10
|
import { multiSelect, selectTokens } from './Autocomplete.tokens.js';
|
|
11
|
-
import {
|
|
11
|
+
import { useToken, useIsomorphicLayoutEffect, bordersTemplate } from '@equinor/eds-utils';
|
|
12
12
|
import { AutocompleteOption } from './Option.js';
|
|
13
13
|
import { useFloating, offset, flip, size, useInteractions, autoUpdate } from '@floating-ui/react';
|
|
14
14
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
15
15
|
import pickBy from '../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/pickBy.js';
|
|
16
16
|
import mergeWith from '../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/mergeWith.js';
|
|
17
|
-
import { HelperText as TextfieldHelperText } from '../InputWrapper/HelperText/HelperText.js';
|
|
18
17
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
19
18
|
import { Label } from '../Label/Label.js';
|
|
20
19
|
import { Input } from '../Input/Input.js';
|
|
20
|
+
import { HelperText as TextfieldHelperText } from '../InputWrapper/HelperText/HelperText.js';
|
|
21
21
|
|
|
22
22
|
const Container = styled.div.withConfig({
|
|
23
23
|
displayName: "Autocomplete__Container",
|
|
@@ -169,7 +169,8 @@ function AutocompleteInner(props, ref) {
|
|
|
169
169
|
onInputChange,
|
|
170
170
|
selectedOptions: _selectedOptions,
|
|
171
171
|
multiple,
|
|
172
|
-
|
|
172
|
+
itemToKey: _itemToKey,
|
|
173
|
+
itemCompare: _itemCompare,
|
|
173
174
|
allowSelectAll,
|
|
174
175
|
initialSelectedOptions: _initialSelectedOptions = [],
|
|
175
176
|
optionDisabled = defaultOptionDisabled,
|
|
@@ -188,6 +189,19 @@ function AutocompleteInner(props, ref) {
|
|
|
188
189
|
onClear,
|
|
189
190
|
...other
|
|
190
191
|
} = props;
|
|
192
|
+
const itemCompare = useMemo(() => {
|
|
193
|
+
if (_itemCompare && _itemToKey) {
|
|
194
|
+
console.error('Error: Specifying both itemCompare and itemToKey. itemCompare is deprecated, while itemToKey should be used instead of it. Please only use one.');
|
|
195
|
+
return _itemCompare;
|
|
196
|
+
}
|
|
197
|
+
if (_itemToKey) {
|
|
198
|
+
return (o1, o2) => _itemToKey(o1) === _itemToKey(o2);
|
|
199
|
+
}
|
|
200
|
+
return _itemCompare;
|
|
201
|
+
}, [_itemCompare, _itemToKey]);
|
|
202
|
+
const itemToKey = useCallback(item => {
|
|
203
|
+
return _itemToKey ? _itemToKey(item) : item;
|
|
204
|
+
}, [_itemToKey]);
|
|
191
205
|
|
|
192
206
|
// MARK: initializing data/setup
|
|
193
207
|
const selectedOptions = _selectedOptions ? itemCompare ? options.filter(item => _selectedOptions.some(compare => itemCompare(item, compare))) : _selectedOptions : undefined;
|
|
@@ -197,6 +211,7 @@ function AutocompleteInner(props, ref) {
|
|
|
197
211
|
const [_availableItems, setAvailableItems] = useState(inputOptions);
|
|
198
212
|
const [typedInputValue, setTypedInputValue] = useState('');
|
|
199
213
|
const inputRef = useRef(null);
|
|
214
|
+
useImperativeHandle(ref, () => inputRef.current);
|
|
200
215
|
const showSelectAll = useMemo(() => {
|
|
201
216
|
if (!multiple && allowSelectAll) {
|
|
202
217
|
throw new Error(`allowSelectAll can only be used with multiple`);
|
|
@@ -228,6 +243,7 @@ function AutocompleteInner(props, ref) {
|
|
|
228
243
|
const tokens = token();
|
|
229
244
|
let placeholderText = placeholder;
|
|
230
245
|
let multipleSelectionProps = {
|
|
246
|
+
itemToKey,
|
|
231
247
|
initialSelectedItems: multiple ? initialSelectedOptions : initialSelectedOptions[0] ? [initialSelectedOptions[0]] : []
|
|
232
248
|
};
|
|
233
249
|
if (multiple) {
|
|
@@ -330,6 +346,7 @@ function AutocompleteInner(props, ref) {
|
|
|
330
346
|
isItemDisabled(item) {
|
|
331
347
|
return optionDisabled(item);
|
|
332
348
|
},
|
|
349
|
+
itemToKey,
|
|
333
350
|
itemToString: getLabel,
|
|
334
351
|
onInputValueChange: ({
|
|
335
352
|
inputValue
|
|
@@ -739,7 +756,6 @@ function AutocompleteInner(props, ref) {
|
|
|
739
756
|
children: /*#__PURE__*/jsxs(Container, {
|
|
740
757
|
className: className,
|
|
741
758
|
style: style,
|
|
742
|
-
ref: ref,
|
|
743
759
|
children: [/*#__PURE__*/jsx(Label, {
|
|
744
760
|
...getLabelProps(),
|
|
745
761
|
label: label,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { forwardRef, Children, isValidElement } from 'react';
|
|
2
|
-
import styled, {
|
|
3
|
-
import {
|
|
2
|
+
import styled, { ThemeProvider, css } from 'styled-components';
|
|
3
|
+
import { useToken, spacingsTemplate } from '@equinor/eds-utils';
|
|
4
4
|
import { enabled } from './Banner.tokens.js';
|
|
5
5
|
import { BannerIcon } from './BannerIcon.js';
|
|
6
6
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
|
-
import { Divider } from '../Divider/Divider.js';
|
|
8
7
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
9
8
|
import { Paper } from '../Paper/Paper.js';
|
|
9
|
+
import { Divider } from '../Divider/Divider.js';
|
|
10
10
|
|
|
11
11
|
const Content = styled.div.withConfig({
|
|
12
12
|
displayName: "Banner__Content",
|
|
@@ -2,8 +2,8 @@ import { forwardRef, useMemo } from 'react';
|
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
import { breadcrumbs } from './Breadcrumbs.tokens.js';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
|
-
import { Typography } from '../Typography/Typography.js';
|
|
6
5
|
import { Tooltip } from '../Tooltip/Tooltip.js';
|
|
6
|
+
import { Typography } from '../Typography/Typography.js';
|
|
7
7
|
|
|
8
8
|
const {
|
|
9
9
|
states,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
|
-
import styled, {
|
|
2
|
+
import styled, { ThemeProvider, css } from 'styled-components';
|
|
3
3
|
import { token } from './tokens/index.js';
|
|
4
|
-
import { spacingsTemplate, bordersTemplate, typographyTemplate, outlineTemplate
|
|
4
|
+
import { useToken, spacingsTemplate, bordersTemplate, typographyTemplate, outlineTemplate } from '@equinor/eds-utils';
|
|
5
5
|
import { InnerFullWidth } from './InnerFullWidth.js';
|
|
6
6
|
import { jsx } from 'react/jsx-runtime';
|
|
7
7
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
@@ -53,6 +53,16 @@ const ButtonBase = styled.button.withConfig({
|
|
|
53
53
|
} = states;
|
|
54
54
|
return css(["box-sizing:border-box;margin:0;padding:0;text-decoration:none;position:relative;cursor:pointer;display:inline-block;background:", ";height:", ";width:", ";svg{justify-self:center;}", " ", " ", " &::after{position:absolute;top:-", ";left:-", ";width:", ";height:", ";content:'';}@media (hover:hover) and (pointer:fine){&:hover{background:", ";color:", ";", ";}}&:focus{outline:none;}&[data-focus-visible-added]:focus{", "}&:focus-visible{", "}&::-moz-focus-inner{border:0;}&:disabled,&[aria-disabled='true']{cursor:not-allowed;background:", ";", ";", ";@media (hover:hover) and (pointer:fine){&:hover{background:", ";}}}"], theme.background, theme.height, theme.width, spacingsTemplate(theme.spacings), bordersTemplate(theme.border), typographyTemplate(theme.typography), clickbound?.offset?.top, clickbound?.offset?.left, clickbound?.width, clickbound?.height, hover.background, hover.typography?.color, bordersTemplate(hover?.border), outlineTemplate(focus.outline), outlineTemplate(focus.outline), disabled.background, bordersTemplate(disabled.border), typographyTemplate(disabled.typography), disabled.background);
|
|
55
55
|
});
|
|
56
|
+
const getElementType = (disabled, customType, href) => {
|
|
57
|
+
if (disabled) return 'button';
|
|
58
|
+
if (customType) return customType;
|
|
59
|
+
if (href) return 'a';
|
|
60
|
+
return 'button';
|
|
61
|
+
};
|
|
62
|
+
const getButtonType = (href, customElementType) => {
|
|
63
|
+
if (href || customElementType) return undefined;
|
|
64
|
+
return 'button';
|
|
65
|
+
};
|
|
56
66
|
const Button = /*#__PURE__*/forwardRef(function Button({
|
|
57
67
|
color = 'primary',
|
|
58
68
|
variant = 'contained',
|
|
@@ -69,25 +79,24 @@ const Button = /*#__PURE__*/forwardRef(function Button({
|
|
|
69
79
|
const token = useToken({
|
|
70
80
|
density
|
|
71
81
|
}, getToken(variant, color));
|
|
72
|
-
const as =
|
|
73
|
-
const type = href
|
|
74
|
-
|
|
82
|
+
const as = getElementType(disabled, other.as, href);
|
|
83
|
+
const type = getButtonType(href, other.as);
|
|
84
|
+
const adjustedTabIndex = disabled ? -1 : tabIndex;
|
|
75
85
|
const buttonProps = {
|
|
76
86
|
ref,
|
|
77
|
-
as,
|
|
78
87
|
href,
|
|
79
88
|
type,
|
|
80
89
|
disabled,
|
|
81
|
-
tabIndex,
|
|
82
|
-
...other
|
|
90
|
+
tabIndex: adjustedTabIndex,
|
|
91
|
+
...other,
|
|
92
|
+
as
|
|
83
93
|
};
|
|
94
|
+
const Container = fullWidth ? InnerFullWidth : Inner;
|
|
84
95
|
return /*#__PURE__*/jsx(ThemeProvider, {
|
|
85
96
|
theme: token,
|
|
86
97
|
children: /*#__PURE__*/jsx(ButtonBase, {
|
|
87
98
|
...buttonProps,
|
|
88
|
-
children:
|
|
89
|
-
children: children
|
|
90
|
-
}) : /*#__PURE__*/jsx(Inner, {
|
|
99
|
+
children: /*#__PURE__*/jsx(Container, {
|
|
91
100
|
children: children
|
|
92
101
|
})
|
|
93
102
|
})
|
|
@@ -6,7 +6,7 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
6
6
|
const {
|
|
7
7
|
border
|
|
8
8
|
} = group;
|
|
9
|
-
const radius = border.
|
|
9
|
+
const radius = border.radius;
|
|
10
10
|
const ButtonGroupBase = styled.div.withConfig({
|
|
11
11
|
displayName: "ButtonGroup__ButtonGroupBase",
|
|
12
12
|
componentId: "sc-1fn8jon-0"
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import { primary, secondary, danger } from './contained.js';
|
|
2
|
-
import { primary as primary$
|
|
3
|
-
import { primary as primary$
|
|
2
|
+
import { primary as primary$2, secondary as secondary$2, danger as danger$2 } from './outlined.js';
|
|
3
|
+
import { primary as primary$4, secondary as secondary$4, danger as danger$4 } from './ghost.js';
|
|
4
4
|
import { primary as primary$3, secondary as secondary$3, danger as danger$3 } from './icon.js';
|
|
5
|
-
import { primary as primary$
|
|
5
|
+
import { primary as primary$1, secondary as secondary$1, danger as danger$1 } from './contained_icon.js';
|
|
6
6
|
|
|
7
7
|
const token = {
|
|
8
8
|
primary: {
|
|
9
9
|
contained: primary,
|
|
10
|
-
outlined: primary$
|
|
11
|
-
ghost: primary$
|
|
10
|
+
outlined: primary$2,
|
|
11
|
+
ghost: primary$4,
|
|
12
12
|
ghost_icon: primary$3,
|
|
13
|
-
contained_icon: primary$
|
|
13
|
+
contained_icon: primary$1
|
|
14
14
|
},
|
|
15
15
|
secondary: {
|
|
16
16
|
contained: secondary,
|
|
17
|
-
outlined: secondary$
|
|
18
|
-
ghost: secondary$
|
|
17
|
+
outlined: secondary$2,
|
|
18
|
+
ghost: secondary$4,
|
|
19
19
|
ghost_icon: secondary$3,
|
|
20
|
-
contained_icon: secondary$
|
|
20
|
+
contained_icon: secondary$1
|
|
21
21
|
},
|
|
22
22
|
danger: {
|
|
23
23
|
contained: danger,
|
|
24
|
-
outlined: danger$
|
|
25
|
-
ghost: danger$
|
|
24
|
+
outlined: danger$2,
|
|
25
|
+
ghost: danger$4,
|
|
26
26
|
ghost_icon: danger$3,
|
|
27
|
-
contained_icon: danger$
|
|
27
|
+
contained_icon: danger$1
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
|
|
@@ -2,7 +2,7 @@ import { forwardRef } from 'react';
|
|
|
2
2
|
import styled, { ThemeProvider } from 'styled-components';
|
|
3
3
|
import { checkbox_indeterminate, checkbox as checkbox$1, checkbox_outline } from '@equinor/eds-icons';
|
|
4
4
|
import { checkbox } from './Checkbox.tokens.js';
|
|
5
|
-
import {
|
|
5
|
+
import { useToken, spacingsTemplate, outlineTemplate } from '@equinor/eds-utils';
|
|
6
6
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
7
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
8
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { forwardRef, useState, useRef, useCallback, useEffect } from 'react';
|
|
2
2
|
import { Calendar } from './calendars/Calendar.js';
|
|
3
3
|
import { DateField } from './fields/DateField.js';
|
|
4
|
-
import {
|
|
4
|
+
import { calendar, warning_outlined } from '@equinor/eds-icons';
|
|
5
5
|
import { useConvertedValidationFunctions } from './utils/useConvertedValidationFunctions.js';
|
|
6
6
|
import { FieldWrapper } from './fields/FieldWrapper.js';
|
|
7
7
|
import { Toggle } from './fields/Toggle.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { forwardRef, useState, useRef, useCallback, useEffect } from 'react';
|
|
2
2
|
import { RangeCalendar } from './calendars/RangeCalendar.js';
|
|
3
|
-
import {
|
|
3
|
+
import { calendar_date_range, warning_outlined } from '@equinor/eds-icons';
|
|
4
4
|
import { useConvertedValidationFunctions } from './utils/useConvertedValidationFunctions.js';
|
|
5
5
|
import { FieldWrapper } from './fields/FieldWrapper.js';
|
|
6
6
|
import { Toggle } from './fields/Toggle.js';
|
|
@@ -3,8 +3,8 @@ import { tokens } from '@equinor/eds-tokens';
|
|
|
3
3
|
import { useRef, useMemo } from 'react';
|
|
4
4
|
import { useCalendarCell } from 'react-aria';
|
|
5
5
|
import { jsx } from 'react/jsx-runtime';
|
|
6
|
-
import { Typography } from '../../Typography/Typography.js';
|
|
7
6
|
import { useEds } from '../../EdsProvider/eds.context.js';
|
|
7
|
+
import { Typography } from '../../Typography/Typography.js';
|
|
8
8
|
|
|
9
9
|
const StyledCell = styled(Typography).withConfig({
|
|
10
10
|
displayName: "CalendarCell__StyledCell",
|
|
@@ -26,7 +26,8 @@ const DateFieldSegments = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
26
26
|
return /*#__PURE__*/jsx("div", {
|
|
27
27
|
...fieldProps,
|
|
28
28
|
style: {
|
|
29
|
-
display: 'flex'
|
|
29
|
+
display: 'flex',
|
|
30
|
+
fontFamily: 'Equinor, Arial, sans-serif'
|
|
30
31
|
},
|
|
31
32
|
ref: ref,
|
|
32
33
|
children: state.segments.map((segment, i) => /*#__PURE__*/jsx(DateSegment, {
|
|
@@ -3,7 +3,7 @@ import { close } from '@equinor/eds-icons';
|
|
|
3
3
|
import { Button } from '../../Button/Button.js';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
import { filterDOMProps } from '@react-aria/utils';
|
|
6
|
-
import { jsxs,
|
|
6
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
7
7
|
|
|
8
8
|
const StyledButton = styled(Button).withConfig({
|
|
9
9
|
displayName: "Toggle__StyledButton",
|
|
@@ -24,7 +24,10 @@ const Toggle = ({
|
|
|
24
24
|
showClearButton,
|
|
25
25
|
readonly
|
|
26
26
|
}) => {
|
|
27
|
-
return
|
|
27
|
+
return /*#__PURE__*/jsxs("div", {
|
|
28
|
+
style: {
|
|
29
|
+
visibility: readonly || disabled ? 'hidden' : 'visible'
|
|
30
|
+
},
|
|
28
31
|
children: [showClearButton && /*#__PURE__*/jsx(StyledButton, {
|
|
29
32
|
disabled: disabled,
|
|
30
33
|
variant: 'ghost_icon',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toCalendarDateTime,
|
|
1
|
+
import { toCalendarDateTime, toCalendarDate, fromDate } from '@internationalized/date';
|
|
2
2
|
|
|
3
3
|
const getCalendarDate = (value, timezone, showTimeInput = false) => {
|
|
4
4
|
if (!value) return null;
|
|
@@ -2,12 +2,14 @@ import { useLocale } from 'react-aria';
|
|
|
2
2
|
|
|
3
3
|
const useGetLocale = locale => {
|
|
4
4
|
const {
|
|
5
|
-
locale:
|
|
5
|
+
locale: currentLocale
|
|
6
6
|
} = useLocale();
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
// Priority:
|
|
8
|
+
// 1. Explicitly passed locale prop
|
|
9
|
+
// 2. Locale from I18nProvider
|
|
10
|
+
// 3. Fallback to browser's default
|
|
11
|
+
const browserLocale = new Intl.DateTimeFormat().resolvedOptions().locale;
|
|
12
|
+
return locale ?? currentLocale ?? browserLocale;
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
export { useGetLocale };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { forwardRef, useRef, useMemo, useEffect } from 'react';
|
|
2
|
-
import styled, {
|
|
3
|
-
import {
|
|
2
|
+
import styled, { ThemeProvider, css } from 'styled-components';
|
|
3
|
+
import { useToken, mergeRefs, useHideBodyScroll, useGlobalKeyPress, bordersTemplate, typographyTemplate } from '@equinor/eds-utils';
|
|
4
4
|
import { dialog } from './Dialog.tokens.js';
|
|
5
5
|
import { jsx } from 'react/jsx-runtime';
|
|
6
|
-
import { Paper } from '../Paper/Paper.js';
|
|
7
6
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
7
|
+
import { Paper } from '../Paper/Paper.js';
|
|
8
8
|
|
|
9
9
|
const StyledDialog = styled(Paper).attrs({
|
|
10
10
|
'aria-labelledby': 'eds-dialog-title',
|