@equinor/eds-core-react 0.38.0 → 0.39.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
CHANGED
|
@@ -9431,7 +9431,7 @@ const StyledPopover = styled__default.default('div').withConfig({
|
|
|
9431
9431
|
}).withConfig({
|
|
9432
9432
|
displayName: "Autocomplete__StyledPopover",
|
|
9433
9433
|
componentId: "sc-yvif0e-2"
|
|
9434
|
-
})(["inset:unset;border:0;padding:0;margin:0;overflow:visible;"]);
|
|
9434
|
+
})(["inset:unset;border:0;padding:0;margin:0;overflow:visible;&::backdrop{background-color:transparent;}"]);
|
|
9435
9435
|
const HelperText = styled__default.default(TextfieldHelperText).withConfig({
|
|
9436
9436
|
displayName: "Autocomplete__HelperText",
|
|
9437
9437
|
componentId: "sc-yvif0e-3"
|
|
@@ -9542,6 +9542,9 @@ const handleListFocus = e => {
|
|
|
9542
9542
|
});
|
|
9543
9543
|
};
|
|
9544
9544
|
const defaultOptionDisabled = () => false;
|
|
9545
|
+
|
|
9546
|
+
// prettier-ignore
|
|
9547
|
+
|
|
9545
9548
|
function AutocompleteInner(props, ref) {
|
|
9546
9549
|
const {
|
|
9547
9550
|
options = [],
|
|
@@ -9555,10 +9558,11 @@ function AutocompleteInner(props, ref) {
|
|
|
9555
9558
|
hideClearButton = false,
|
|
9556
9559
|
onOptionsChange,
|
|
9557
9560
|
onInputChange,
|
|
9558
|
-
selectedOptions,
|
|
9561
|
+
selectedOptions: _selectedOptions,
|
|
9559
9562
|
multiple,
|
|
9563
|
+
itemCompare,
|
|
9560
9564
|
allowSelectAll,
|
|
9561
|
-
initialSelectedOptions = [],
|
|
9565
|
+
initialSelectedOptions: _initialSelectedOptions = [],
|
|
9562
9566
|
disablePortal,
|
|
9563
9567
|
optionDisabled = defaultOptionDisabled,
|
|
9564
9568
|
optionsFilter,
|
|
@@ -9575,6 +9579,8 @@ function AutocompleteInner(props, ref) {
|
|
|
9575
9579
|
variant,
|
|
9576
9580
|
...other
|
|
9577
9581
|
} = props;
|
|
9582
|
+
const selectedOptions = _selectedOptions ? itemCompare ? options.filter(item => _selectedOptions.some(compare => itemCompare(item, compare))) : _selectedOptions : undefined;
|
|
9583
|
+
const initialSelectedOptions = _initialSelectedOptions ? itemCompare ? options.filter(item => _initialSelectedOptions.some(compare => itemCompare(item, compare))) : _initialSelectedOptions : undefined;
|
|
9578
9584
|
if (disablePortal) {
|
|
9579
9585
|
console.warn('Autocomplete "disablePortal" prop has been deprecated. Autocomplete now uses the native popover api');
|
|
9580
9586
|
}
|
|
@@ -9620,7 +9626,10 @@ function AutocompleteInner(props, ref) {
|
|
|
9620
9626
|
...multipleSelectionProps,
|
|
9621
9627
|
onSelectedItemsChange: changes => {
|
|
9622
9628
|
if (onOptionsChange) {
|
|
9623
|
-
|
|
9629
|
+
let selectedItems = changes.selectedItems.filter(item => item !== AllSymbol);
|
|
9630
|
+
if (itemCompare) {
|
|
9631
|
+
selectedItems = inputOptions.filter(item => selectedItems.some(compare => itemCompare(item, compare)));
|
|
9632
|
+
}
|
|
9624
9633
|
onOptionsChange({
|
|
9625
9634
|
selectedItems
|
|
9626
9635
|
});
|
|
@@ -9767,9 +9776,12 @@ function AutocompleteInner(props, ref) {
|
|
|
9767
9776
|
...comboBoxProps,
|
|
9768
9777
|
onSelectedItemChange: changes => {
|
|
9769
9778
|
if (onOptionsChange) {
|
|
9770
|
-
|
|
9779
|
+
let {
|
|
9771
9780
|
selectedItem
|
|
9772
9781
|
} = changes;
|
|
9782
|
+
if (itemCompare) {
|
|
9783
|
+
selectedItem = inputOptions.find(item => itemCompare(item, selectedItem));
|
|
9784
|
+
}
|
|
9773
9785
|
onOptionsChange({
|
|
9774
9786
|
selectedItems: selectedItem ? [selectedItem] : []
|
|
9775
9787
|
});
|
|
@@ -11607,7 +11619,7 @@ function DateSegment({
|
|
|
11607
11619
|
const formatter = reactAria.useDateFormatter(formatOptions);
|
|
11608
11620
|
const parts = state.value ? formatter.formatToParts(state.value.toDate(timezone)) : [];
|
|
11609
11621
|
const part = parts.find(p => p.type === segment.type);
|
|
11610
|
-
const value = part?.value ?? segment.text;
|
|
11622
|
+
const value = segment.isPlaceholder || segment.type === 'literal' ? segment.text : part?.value ?? segment.text;
|
|
11611
11623
|
const [focus, setFocus] = react.useState(false);
|
|
11612
11624
|
const ref = react.useRef(null);
|
|
11613
11625
|
const {
|
|
@@ -35,7 +35,7 @@ const StyledPopover = styled('div').withConfig({
|
|
|
35
35
|
}).withConfig({
|
|
36
36
|
displayName: "Autocomplete__StyledPopover",
|
|
37
37
|
componentId: "sc-yvif0e-2"
|
|
38
|
-
})(["inset:unset;border:0;padding:0;margin:0;overflow:visible;"]);
|
|
38
|
+
})(["inset:unset;border:0;padding:0;margin:0;overflow:visible;&::backdrop{background-color:transparent;}"]);
|
|
39
39
|
const HelperText = styled(TextfieldHelperText).withConfig({
|
|
40
40
|
displayName: "Autocomplete__HelperText",
|
|
41
41
|
componentId: "sc-yvif0e-3"
|
|
@@ -146,6 +146,9 @@ const handleListFocus = e => {
|
|
|
146
146
|
});
|
|
147
147
|
};
|
|
148
148
|
const defaultOptionDisabled = () => false;
|
|
149
|
+
|
|
150
|
+
// prettier-ignore
|
|
151
|
+
|
|
149
152
|
function AutocompleteInner(props, ref) {
|
|
150
153
|
const {
|
|
151
154
|
options = [],
|
|
@@ -159,10 +162,11 @@ function AutocompleteInner(props, ref) {
|
|
|
159
162
|
hideClearButton = false,
|
|
160
163
|
onOptionsChange,
|
|
161
164
|
onInputChange,
|
|
162
|
-
selectedOptions,
|
|
165
|
+
selectedOptions: _selectedOptions,
|
|
163
166
|
multiple,
|
|
167
|
+
itemCompare,
|
|
164
168
|
allowSelectAll,
|
|
165
|
-
initialSelectedOptions = [],
|
|
169
|
+
initialSelectedOptions: _initialSelectedOptions = [],
|
|
166
170
|
disablePortal,
|
|
167
171
|
optionDisabled = defaultOptionDisabled,
|
|
168
172
|
optionsFilter,
|
|
@@ -179,6 +183,8 @@ function AutocompleteInner(props, ref) {
|
|
|
179
183
|
variant,
|
|
180
184
|
...other
|
|
181
185
|
} = props;
|
|
186
|
+
const selectedOptions = _selectedOptions ? itemCompare ? options.filter(item => _selectedOptions.some(compare => itemCompare(item, compare))) : _selectedOptions : undefined;
|
|
187
|
+
const initialSelectedOptions = _initialSelectedOptions ? itemCompare ? options.filter(item => _initialSelectedOptions.some(compare => itemCompare(item, compare))) : _initialSelectedOptions : undefined;
|
|
182
188
|
if (disablePortal) {
|
|
183
189
|
console.warn('Autocomplete "disablePortal" prop has been deprecated. Autocomplete now uses the native popover api');
|
|
184
190
|
}
|
|
@@ -224,7 +230,10 @@ function AutocompleteInner(props, ref) {
|
|
|
224
230
|
...multipleSelectionProps,
|
|
225
231
|
onSelectedItemsChange: changes => {
|
|
226
232
|
if (onOptionsChange) {
|
|
227
|
-
|
|
233
|
+
let selectedItems = changes.selectedItems.filter(item => item !== AllSymbol);
|
|
234
|
+
if (itemCompare) {
|
|
235
|
+
selectedItems = inputOptions.filter(item => selectedItems.some(compare => itemCompare(item, compare)));
|
|
236
|
+
}
|
|
228
237
|
onOptionsChange({
|
|
229
238
|
selectedItems
|
|
230
239
|
});
|
|
@@ -371,9 +380,12 @@ function AutocompleteInner(props, ref) {
|
|
|
371
380
|
...comboBoxProps,
|
|
372
381
|
onSelectedItemChange: changes => {
|
|
373
382
|
if (onOptionsChange) {
|
|
374
|
-
|
|
383
|
+
let {
|
|
375
384
|
selectedItem
|
|
376
385
|
} = changes;
|
|
386
|
+
if (itemCompare) {
|
|
387
|
+
selectedItem = inputOptions.find(item => itemCompare(item, selectedItem));
|
|
388
|
+
}
|
|
377
389
|
onOptionsChange({
|
|
378
390
|
selectedItems: selectedItem ? [selectedItem] : []
|
|
379
391
|
});
|
|
@@ -26,7 +26,7 @@ function DateSegment({
|
|
|
26
26
|
const formatter = useDateFormatter(formatOptions);
|
|
27
27
|
const parts = state.value ? formatter.formatToParts(state.value.toDate(timezone)) : [];
|
|
28
28
|
const part = parts.find(p => p.type === segment.type);
|
|
29
|
-
const value = part?.value ?? segment.text;
|
|
29
|
+
const value = segment.isPlaceholder || segment.type === 'literal' ? segment.text : part?.value ?? segment.text;
|
|
30
30
|
const [focus, setFocus] = useState(false);
|
|
31
31
|
const ref = useRef(null);
|
|
32
32
|
const {
|
|
@@ -100,6 +100,10 @@ export type AutocompleteProps<T> = {
|
|
|
100
100
|
* @default 300
|
|
101
101
|
*/
|
|
102
102
|
dropdownHeight?: number;
|
|
103
|
+
/**
|
|
104
|
+
* Method that is used to compare objects by value. If omitted, objects are matched by reference.
|
|
105
|
+
*/
|
|
106
|
+
itemCompare?: (value: T, compare: T) => boolean;
|
|
103
107
|
} & HTMLAttributes<HTMLDivElement> & OptionLabelProps<T>;
|
|
104
108
|
declare function AutocompleteInner<T>(props: AutocompleteProps<T>, ref: React.ForwardedRef<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
105
109
|
export declare const Autocomplete: <T>(props: {
|
|
@@ -180,6 +184,10 @@ export declare const Autocomplete: <T>(props: {
|
|
|
180
184
|
* @default 300
|
|
181
185
|
*/
|
|
182
186
|
dropdownHeight?: number;
|
|
187
|
+
/**
|
|
188
|
+
* Method that is used to compare objects by value. If omitted, objects are matched by reference.
|
|
189
|
+
*/
|
|
190
|
+
itemCompare?: (value: T, compare: T) => boolean;
|
|
183
191
|
} & HTMLAttributes<HTMLDivElement> & OptionLabelProps<T> & {
|
|
184
192
|
ref?: React.ForwardedRef<HTMLDivElement>;
|
|
185
193
|
/** @ignore */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/eds-core-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.0",
|
|
4
4
|
"description": "The React implementation of the Equinor Design System",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"**/*.css"
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"react": ">=16.8",
|
|
77
77
|
"react-dom": ">=16.8",
|
|
78
|
-
"styled-components": ">=
|
|
78
|
+
"styled-components": ">=5.1"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@babel/runtime": "^7.24.0",
|