@equinor/eds-core-react 1.0.2 → 2.0.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/README.md +16 -1
- package/dist/eds-core-react.cjs +421 -136
- package/dist/esm/components/Accordion/Accordion.js +4 -3
- package/dist/esm/components/Autocomplete/Autocomplete.js +90 -23
- 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/fields/FieldWrapper.js +8 -2
- package/dist/esm/components/Icon/Icon.js +2 -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/InputWrapper/useInputField.js +61 -0
- package/dist/esm/components/SideBar/SideBarAccordion/index.js +4 -3
- package/dist/esm/components/Slider/Slider.js +8 -5
- package/dist/esm/components/Table/DataCell/DataCell.tokens.js +1 -1
- package/dist/esm/components/Tabs/Tabs.js +4 -3
- package/dist/esm/components/TextField/TextField.js +23 -56
- package/dist/esm/components/Textarea/Textarea.js +64 -33
- package/dist/esm/components/Typography/Heading.js +51 -0
- package/dist/esm/components/Typography/Paragraph.js +28 -0
- package/dist/esm/components/Typography/Typography.js +15 -1
- package/dist/esm/components/Typography/Typography.new.js +67 -0
- package/dist/esm/index.js +5 -0
- package/dist/types/components/Button/tokens/contained.d.ts +3 -4
- package/dist/types/components/Button/tokens/outlined.d.ts +3 -4
- package/dist/types/components/InputWrapper/index.d.ts +3 -0
- package/dist/types/components/InputWrapper/types.d.ts +21 -0
- package/dist/types/components/InputWrapper/useInputField.d.ts +31 -0
- package/dist/types/components/TextField/TextField.d.ts +5 -25
- package/dist/types/components/Textarea/Textarea.d.ts +6 -27
- package/dist/types/components/Typography/Heading.d.ts +7 -0
- package/dist/types/components/Typography/Heading.types.d.ts +6 -0
- package/dist/types/components/Typography/Paragraph.d.ts +7 -0
- package/dist/types/components/Typography/Paragraph.types.d.ts +7 -0
- package/dist/types/components/Typography/Typography.d.ts +13 -0
- package/dist/types/components/Typography/Typography.new.d.ts +43 -0
- package/dist/types/components/Typography/Typography.new.types.d.ts +28 -0
- package/dist/types/components/Typography/Typography.stories.shared.d.ts +79 -0
- package/dist/types/components/Typography/index.d.ts +7 -0
- package/dist/types/components/Typography/types.d.ts +9 -0
- package/dist/types/components/Typography/utils.d.ts +15 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +56 -40
- /package/dist/esm/node_modules/.pnpm/{ramda@0.31.3 → ramda@0.32.0}/node_modules/ramda/es/internal/_curry1.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{ramda@0.31.3 → ramda@0.32.0}/node_modules/ramda/es/internal/_curry2.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{ramda@0.31.3 → ramda@0.32.0}/node_modules/ramda/es/internal/_curry3.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{ramda@0.31.3 → ramda@0.32.0}/node_modules/ramda/es/internal/_has.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{ramda@0.31.3 → ramda@0.32.0}/node_modules/ramda/es/internal/_isObject.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{ramda@0.31.3 → ramda@0.32.0}/node_modules/ramda/es/internal/_isPlaceholder.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{ramda@0.31.3 → ramda@0.32.0}/node_modules/ramda/es/mergeDeepRight.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{ramda@0.31.3 → ramda@0.32.0}/node_modules/ramda/es/mergeDeepWithKey.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{ramda@0.31.3 → ramda@0.32.0}/node_modules/ramda/es/mergeWith.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{ramda@0.31.3 → ramda@0.32.0}/node_modules/ramda/es/mergeWithKey.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{ramda@0.31.3 → ramda@0.32.0}/node_modules/ramda/es/pickBy.js +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { forwardRef, Children, cloneElement } from 'react';
|
|
1
|
+
import { forwardRef, useId, Children, cloneElement } from 'react';
|
|
2
2
|
import { ThemeProvider } from 'styled-components';
|
|
3
3
|
import { accordion } from './Accordion.tokens.js';
|
|
4
|
-
import {
|
|
4
|
+
import { useToken } from '@equinor/eds-utils';
|
|
5
5
|
import { jsx } from 'react/jsx-runtime';
|
|
6
6
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
7
7
|
|
|
@@ -12,7 +12,8 @@ const Accordion = /*#__PURE__*/forwardRef(function Accordion({
|
|
|
12
12
|
id,
|
|
13
13
|
...props
|
|
14
14
|
}, ref) {
|
|
15
|
-
const
|
|
15
|
+
const generatedAccordionId = useId();
|
|
16
|
+
const accordionId = id ?? generatedAccordionId;
|
|
16
17
|
const {
|
|
17
18
|
density
|
|
18
19
|
} = useEds();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forwardRef, useMemo, useCallback,
|
|
1
|
+
import { forwardRef, useState, useMemo, useCallback, useRef, useImperativeHandle, useEffect } from 'react';
|
|
2
2
|
import { useMultipleSelection, useCombobox } from 'downshift';
|
|
3
3
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
4
4
|
import styled, { ThemeProvider, css } from 'styled-components';
|
|
@@ -13,8 +13,8 @@ import { AutocompleteOption } from './Option.js';
|
|
|
13
13
|
import { useFloating, offset, flip, size, useInteractions, autoUpdate } from '@floating-ui/react';
|
|
14
14
|
import { AddNewOption } from './AddNewOption.js';
|
|
15
15
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
16
|
-
import pickBy from '../../node_modules/.pnpm/ramda@0.
|
|
17
|
-
import mergeWith from '../../node_modules/.pnpm/ramda@0.
|
|
16
|
+
import pickBy from '../../node_modules/.pnpm/ramda@0.32.0/node_modules/ramda/es/pickBy.js';
|
|
17
|
+
import mergeWith from '../../node_modules/.pnpm/ramda@0.32.0/node_modules/ramda/es/mergeWith.js';
|
|
18
18
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
19
19
|
import { Label } from '../Label/Label.js';
|
|
20
20
|
import { Input } from '../Input/Input.js';
|
|
@@ -158,6 +158,8 @@ const defaultOptionDisabled = () => false;
|
|
|
158
158
|
|
|
159
159
|
// MARK: component
|
|
160
160
|
function AutocompleteInner(props, ref) {
|
|
161
|
+
const [controlledHighlightedIndex, setControlledHighlightedIndex] = useState(0);
|
|
162
|
+
const [lastScrollOffset, setLastScrollOffset] = useState(0);
|
|
161
163
|
const {
|
|
162
164
|
options = [],
|
|
163
165
|
totalOptions,
|
|
@@ -229,6 +231,7 @@ function AutocompleteInner(props, ref) {
|
|
|
229
231
|
if (onAddNewOption) return [AddSymbol, ..._availableItems];
|
|
230
232
|
return _availableItems;
|
|
231
233
|
}, [_availableItems, showSelectAll, onAddNewOption]);
|
|
234
|
+
const getSelectedIndex = useCallback(selectedItem => availableItems.findIndex(item => itemCompare ? itemCompare(item, selectedItem) : item === selectedItem), [availableItems, itemCompare]);
|
|
232
235
|
|
|
233
236
|
//issue 2304, update dataset when options are added dynamically
|
|
234
237
|
useEffect(() => {
|
|
@@ -366,20 +369,18 @@ function AutocompleteInner(props, ref) {
|
|
|
366
369
|
}));
|
|
367
370
|
},
|
|
368
371
|
onHighlightedIndexChange({
|
|
369
|
-
highlightedIndex
|
|
370
|
-
type
|
|
372
|
+
highlightedIndex
|
|
371
373
|
}) {
|
|
372
|
-
if (
|
|
373
|
-
|
|
374
|
-
|
|
374
|
+
if (highlightedIndex >= 0 && rowVirtualizer.getVirtualItems) {
|
|
375
|
+
const visibleIndexes = rowVirtualizer.getVirtualItems().map(v => v.index);
|
|
376
|
+
if (!visibleIndexes.includes(highlightedIndex)) {
|
|
375
377
|
rowVirtualizer.scrollToIndex(highlightedIndex, {
|
|
376
378
|
align: allowSelectAll ? 'center' : 'auto'
|
|
377
379
|
});
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
});
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
if (typeof rowVirtualizer.scrollOffset === 'number') {
|
|
383
|
+
setLastScrollOffset(rowVirtualizer.scrollOffset);
|
|
383
384
|
}
|
|
384
385
|
},
|
|
385
386
|
onIsOpenChange: ({
|
|
@@ -387,6 +388,19 @@ function AutocompleteInner(props, ref) {
|
|
|
387
388
|
}) => {
|
|
388
389
|
if (!multiple && selectedItem !== null) {
|
|
389
390
|
setAvailableItems(options);
|
|
391
|
+
setTimeout(() => {
|
|
392
|
+
if (controlledHighlightedIndex === 0) {
|
|
393
|
+
rowVirtualizer.scrollToOffset?.(0);
|
|
394
|
+
} else if (rowVirtualizer.scrollToOffset && lastScrollOffset > 0) {
|
|
395
|
+
rowVirtualizer.scrollToOffset(lastScrollOffset);
|
|
396
|
+
}
|
|
397
|
+
const visibleIndexes = rowVirtualizer.getVirtualItems?.().map(v => v.index) || [];
|
|
398
|
+
if (!visibleIndexes.includes(controlledHighlightedIndex)) {
|
|
399
|
+
rowVirtualizer.scrollToIndex(controlledHighlightedIndex, {
|
|
400
|
+
align: allowSelectAll ? 'center' : 'auto'
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
}, 10);
|
|
390
404
|
}
|
|
391
405
|
},
|
|
392
406
|
onStateChange: ({
|
|
@@ -426,6 +440,8 @@ function AutocompleteInner(props, ref) {
|
|
|
426
440
|
...comboBoxProps,
|
|
427
441
|
onSelectedItemChange: changes => {
|
|
428
442
|
if (changes.selectedItem === AddSymbol) return;
|
|
443
|
+
const idx = getSelectedIndex(changes.selectedItem);
|
|
444
|
+
setControlledHighlightedIndex(idx >= 0 ? idx : 0);
|
|
429
445
|
if (onOptionsChange) {
|
|
430
446
|
let {
|
|
431
447
|
selectedItem
|
|
@@ -438,7 +454,7 @@ function AutocompleteInner(props, ref) {
|
|
|
438
454
|
});
|
|
439
455
|
}
|
|
440
456
|
},
|
|
441
|
-
stateReducer: (
|
|
457
|
+
stateReducer: (state, actionAndChanges) => {
|
|
442
458
|
const {
|
|
443
459
|
changes,
|
|
444
460
|
type
|
|
@@ -447,19 +463,25 @@ function AutocompleteInner(props, ref) {
|
|
|
447
463
|
case useCombobox.stateChangeTypes.InputClick:
|
|
448
464
|
return {
|
|
449
465
|
...changes,
|
|
450
|
-
isOpen: !(disabled || readOnly)
|
|
466
|
+
isOpen: !(disabled || readOnly),
|
|
467
|
+
highlightedIndex: controlledHighlightedIndex
|
|
451
468
|
};
|
|
452
469
|
case useCombobox.stateChangeTypes.InputKeyDownEnter:
|
|
453
470
|
case useCombobox.stateChangeTypes.ItemClick:
|
|
454
|
-
|
|
471
|
+
{
|
|
472
|
+
if (changes.selectedItem === AddSymbol) {
|
|
473
|
+
return {
|
|
474
|
+
...changes,
|
|
475
|
+
inputValue: ''
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
const idx = getSelectedIndex(changes.selectedItem);
|
|
479
|
+
setControlledHighlightedIndex(idx >= 0 ? idx : 0);
|
|
455
480
|
return {
|
|
456
481
|
...changes,
|
|
457
|
-
|
|
482
|
+
highlightedIndex: idx >= 0 ? idx : 0
|
|
458
483
|
};
|
|
459
484
|
}
|
|
460
|
-
return {
|
|
461
|
-
...changes
|
|
462
|
-
};
|
|
463
485
|
case useCombobox.stateChangeTypes.InputBlur:
|
|
464
486
|
return {
|
|
465
487
|
...changes,
|
|
@@ -471,13 +493,19 @@ function AutocompleteInner(props, ref) {
|
|
|
471
493
|
...changes
|
|
472
494
|
};
|
|
473
495
|
case useCombobox.stateChangeTypes.InputKeyDownArrowDown:
|
|
474
|
-
case useCombobox.stateChangeTypes.InputKeyDownHome:
|
|
475
496
|
if (readOnly) {
|
|
476
497
|
return {
|
|
477
498
|
...changes,
|
|
478
499
|
isOpen: false
|
|
479
500
|
};
|
|
480
501
|
}
|
|
502
|
+
if (state.isOpen === false) {
|
|
503
|
+
return {
|
|
504
|
+
...changes,
|
|
505
|
+
isOpen: true,
|
|
506
|
+
highlightedIndex: controlledHighlightedIndex
|
|
507
|
+
};
|
|
508
|
+
}
|
|
481
509
|
return {
|
|
482
510
|
...changes,
|
|
483
511
|
highlightedIndex: findNextIndex({
|
|
@@ -487,14 +515,36 @@ function AutocompleteInner(props, ref) {
|
|
|
487
515
|
allDisabled
|
|
488
516
|
})
|
|
489
517
|
};
|
|
518
|
+
case useCombobox.stateChangeTypes.InputKeyDownHome:
|
|
519
|
+
if (readOnly) {
|
|
520
|
+
return {
|
|
521
|
+
...changes,
|
|
522
|
+
isOpen: false
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
return {
|
|
526
|
+
...changes,
|
|
527
|
+
highlightedIndex: findNextIndex({
|
|
528
|
+
index: 0,
|
|
529
|
+
availableItems,
|
|
530
|
+
optionDisabled,
|
|
531
|
+
allDisabled
|
|
532
|
+
})
|
|
533
|
+
};
|
|
490
534
|
case useCombobox.stateChangeTypes.InputKeyDownArrowUp:
|
|
491
|
-
case useCombobox.stateChangeTypes.InputKeyDownEnd:
|
|
492
535
|
if (readOnly) {
|
|
493
536
|
return {
|
|
494
537
|
...changes,
|
|
495
538
|
isOpen: false
|
|
496
539
|
};
|
|
497
540
|
}
|
|
541
|
+
if (state.isOpen === false) {
|
|
542
|
+
return {
|
|
543
|
+
...changes,
|
|
544
|
+
isOpen: true,
|
|
545
|
+
highlightedIndex: controlledHighlightedIndex
|
|
546
|
+
};
|
|
547
|
+
}
|
|
498
548
|
return {
|
|
499
549
|
...changes,
|
|
500
550
|
highlightedIndex: findPrevIndex({
|
|
@@ -504,10 +554,27 @@ function AutocompleteInner(props, ref) {
|
|
|
504
554
|
allDisabled
|
|
505
555
|
})
|
|
506
556
|
};
|
|
557
|
+
case useCombobox.stateChangeTypes.InputKeyDownEnd:
|
|
558
|
+
if (readOnly) {
|
|
559
|
+
return {
|
|
560
|
+
...changes,
|
|
561
|
+
isOpen: false
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
return {
|
|
565
|
+
...changes,
|
|
566
|
+
highlightedIndex: findPrevIndex({
|
|
567
|
+
index: availableItems.length - 1,
|
|
568
|
+
availableItems,
|
|
569
|
+
optionDisabled,
|
|
570
|
+
allDisabled
|
|
571
|
+
})
|
|
572
|
+
};
|
|
507
573
|
case useCombobox.stateChangeTypes.ControlledPropUpdatedSelectedItem:
|
|
508
574
|
setSelectedItems([changes.selectedItem]);
|
|
509
575
|
return {
|
|
510
|
-
...changes
|
|
576
|
+
...changes,
|
|
577
|
+
highlightedIndex: controlledHighlightedIndex
|
|
511
578
|
};
|
|
512
579
|
default:
|
|
513
580
|
return changes;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { tokens } from '@equinor/eds-tokens';
|
|
2
|
-
import mergeDeepRight from '../../node_modules/.pnpm/ramda@0.
|
|
2
|
+
import mergeDeepRight from '../../node_modules/.pnpm/ramda@0.32.0/node_modules/ramda/es/mergeDeepRight.js';
|
|
3
3
|
|
|
4
4
|
const {
|
|
5
5
|
typography,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { tokens } from '@equinor/eds-tokens';
|
|
2
2
|
import { button } from './button.js';
|
|
3
|
-
import mergeDeepRight from '../../../node_modules/.pnpm/ramda@0.
|
|
3
|
+
import mergeDeepRight from '../../../node_modules/.pnpm/ramda@0.32.0/node_modules/ramda/es/mergeDeepRight.js';
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
6
|
colors: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { tokens } from '@equinor/eds-tokens';
|
|
2
2
|
import { primary as primary$1, secondary as secondary$1, danger as danger$1 } from './contained.js';
|
|
3
|
-
import mergeDeepRight from '../../../node_modules/.pnpm/ramda@0.
|
|
3
|
+
import mergeDeepRight from '../../../node_modules/.pnpm/ramda@0.32.0/node_modules/ramda/es/mergeDeepRight.js';
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
6
|
clickbounds: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { tokens } from '@equinor/eds-tokens';
|
|
2
2
|
import { button } from './button.js';
|
|
3
|
-
import mergeDeepRight from '../../../node_modules/.pnpm/ramda@0.
|
|
3
|
+
import mergeDeepRight from '../../../node_modules/.pnpm/ramda@0.32.0/node_modules/ramda/es/mergeDeepRight.js';
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
6
|
colors: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { tokens } from '@equinor/eds-tokens';
|
|
2
2
|
import { button } from './button.js';
|
|
3
|
-
import mergeDeepRight from '../../../node_modules/.pnpm/ramda@0.
|
|
3
|
+
import mergeDeepRight from '../../../node_modules/.pnpm/ramda@0.32.0/node_modules/ramda/es/mergeDeepRight.js';
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
6
|
colors: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { tokens } from '@equinor/eds-tokens';
|
|
2
2
|
import { button } from './button.js';
|
|
3
|
-
import mergeDeepRight from '../../../node_modules/.pnpm/ramda@0.
|
|
3
|
+
import mergeDeepRight from '../../../node_modules/.pnpm/ramda@0.32.0/node_modules/ramda/es/mergeDeepRight.js';
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
6
|
colors: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
import { tokens } from '@equinor/eds-tokens';
|
|
3
|
-
import { forwardRef, useEffect } from 'react';
|
|
3
|
+
import { forwardRef, useState, useEffect } from 'react';
|
|
4
4
|
import { Popover } from '../../Popover/index.js';
|
|
5
5
|
import { filterDOMProps } from '@react-aria/utils';
|
|
6
6
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
@@ -101,6 +101,12 @@ const FieldWrapper = /*#__PURE__*/forwardRef(({
|
|
|
101
101
|
readonly,
|
|
102
102
|
...props
|
|
103
103
|
}, ref) => {
|
|
104
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (ref && typeof ref !== 'function' && ref.current) {
|
|
107
|
+
setAnchorEl(ref.current);
|
|
108
|
+
}
|
|
109
|
+
}, [ref]);
|
|
104
110
|
useEffect(() => {
|
|
105
111
|
if (isOpen === false) {
|
|
106
112
|
// Focus the first segment in the input field
|
|
@@ -123,7 +129,7 @@ const FieldWrapper = /*#__PURE__*/forwardRef(({
|
|
|
123
129
|
}), /*#__PURE__*/jsx(Popover, {
|
|
124
130
|
open: isOpen ?? false,
|
|
125
131
|
onClose: () => setIsOpen(false),
|
|
126
|
-
anchorEl:
|
|
132
|
+
anchorEl: anchorEl,
|
|
127
133
|
placement: 'bottom-start',
|
|
128
134
|
children: calendar
|
|
129
135
|
})]
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { useId } from '
|
|
2
|
-
import { forwardRef } from 'react';
|
|
1
|
+
import { forwardRef, useId } from 'react';
|
|
3
2
|
import styled from 'styled-components';
|
|
4
3
|
import { get } from './library.js';
|
|
5
4
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
@@ -72,7 +71,7 @@ const Icon = /*#__PURE__*/forwardRef(function Icon({
|
|
|
72
71
|
};
|
|
73
72
|
|
|
74
73
|
// Accessibility
|
|
75
|
-
const titleId = useId(
|
|
74
|
+
const titleId = useId();
|
|
76
75
|
if (title) {
|
|
77
76
|
svgProps = {
|
|
78
77
|
...svgProps,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { tokens } from '@equinor/eds-tokens';
|
|
2
|
-
import mergeDeepRight from '../../node_modules/.pnpm/ramda@0.
|
|
2
|
+
import mergeDeepRight from '../../node_modules/.pnpm/ramda@0.32.0/node_modules/ramda/es/mergeDeepRight.js';
|
|
3
3
|
|
|
4
4
|
const {
|
|
5
5
|
colors: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { tokens } from '@equinor/eds-tokens';
|
|
2
|
-
import mergeDeepRight from '../../node_modules/.pnpm/ramda@0.
|
|
2
|
+
import mergeDeepRight from '../../node_modules/.pnpm/ramda@0.32.0/node_modules/ramda/es/mergeDeepRight.js';
|
|
3
3
|
|
|
4
4
|
const {
|
|
5
5
|
colors: {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { useId } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared hook for TextField and Textarea that handles common logic
|
|
5
|
+
* for IDs, labels, helper text, and ARIA attributes
|
|
6
|
+
*/
|
|
7
|
+
const useInputField = ({
|
|
8
|
+
id,
|
|
9
|
+
label,
|
|
10
|
+
meta,
|
|
11
|
+
helperText,
|
|
12
|
+
helperIcon,
|
|
13
|
+
variant,
|
|
14
|
+
disabled,
|
|
15
|
+
className,
|
|
16
|
+
style
|
|
17
|
+
}) => {
|
|
18
|
+
const generatedFieldId = useId();
|
|
19
|
+
const generatedHelperTextId = useId();
|
|
20
|
+
|
|
21
|
+
// Use provided ID or fall back to generated one
|
|
22
|
+
const fieldId = id ?? generatedFieldId;
|
|
23
|
+
const helperTextId = generatedHelperTextId;
|
|
24
|
+
const hasHelperText = Boolean(helperText);
|
|
25
|
+
const containerProps = {
|
|
26
|
+
className,
|
|
27
|
+
style: {
|
|
28
|
+
width: '100%',
|
|
29
|
+
...style
|
|
30
|
+
},
|
|
31
|
+
color: variant
|
|
32
|
+
};
|
|
33
|
+
const labelProps = {
|
|
34
|
+
htmlFor: fieldId,
|
|
35
|
+
label,
|
|
36
|
+
meta,
|
|
37
|
+
disabled
|
|
38
|
+
};
|
|
39
|
+
const helperProps = {
|
|
40
|
+
id: hasHelperText ? helperTextId : null,
|
|
41
|
+
text: helperText,
|
|
42
|
+
icon: helperIcon
|
|
43
|
+
};
|
|
44
|
+
const ariaProps = {
|
|
45
|
+
id: fieldId,
|
|
46
|
+
'aria-invalid': variant === 'error' || undefined,
|
|
47
|
+
...(hasHelperText && {
|
|
48
|
+
'aria-describedby': helperTextId
|
|
49
|
+
})
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
fieldId,
|
|
53
|
+
helperTextId: hasHelperText ? helperTextId : null,
|
|
54
|
+
containerProps,
|
|
55
|
+
labelProps,
|
|
56
|
+
helperProps,
|
|
57
|
+
ariaProps
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export { useInputField };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { forwardRef, useState, useMemo, Children } from 'react';
|
|
1
|
+
import { forwardRef, useId, useState, useMemo, Children } from 'react';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
|
-
import {
|
|
3
|
+
import { mergeRefs, bordersTemplate, outlineTemplate } from '@equinor/eds-utils';
|
|
4
4
|
import { chevron_up, chevron_down, arrow_drop_down } from '@equinor/eds-icons';
|
|
5
5
|
import { useSideBar } from '../SideBar.context.js';
|
|
6
6
|
import { sidebar } from '../SideBar.tokens.js';
|
|
@@ -104,7 +104,8 @@ const SideBarAccordion = /*#__PURE__*/forwardRef(function SideBarAccordion({
|
|
|
104
104
|
disabled,
|
|
105
105
|
...rest
|
|
106
106
|
}, ref) {
|
|
107
|
-
const
|
|
107
|
+
const generatedAccordionId = useId();
|
|
108
|
+
const accordionId = id ?? generatedAccordionId;
|
|
108
109
|
const [menuIsOpen, setMenuIsOpen] = useState(false);
|
|
109
110
|
const [accordionIsOpen, setAccordionIsOpen] = useState(isExpanded);
|
|
110
111
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { forwardRef, useState, useEffect, useRef, useCallback } from 'react';
|
|
1
|
+
import { forwardRef, useState, useEffect, useRef, useId, useCallback } from 'react';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
import { slider } from './Slider.tokens.js';
|
|
4
4
|
import { MinMax } from './MinMax.js';
|
|
5
5
|
import { Output } from './Output.js';
|
|
6
6
|
import { SliderInput } from './SliderInput.js';
|
|
7
|
-
import {
|
|
7
|
+
import { bordersTemplate } from '@equinor/eds-utils';
|
|
8
8
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
9
9
|
|
|
10
10
|
const {
|
|
@@ -216,9 +216,12 @@ const Slider = /*#__PURE__*/forwardRef(function Slider({
|
|
|
216
216
|
setMousePressed(false);
|
|
217
217
|
}
|
|
218
218
|
};
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
219
|
+
const generatedInputIdA = useId();
|
|
220
|
+
const generatedInputIdB = useId();
|
|
221
|
+
const generatedInputId = useId();
|
|
222
|
+
let inputIdA = generatedInputIdA;
|
|
223
|
+
let inputIdB = generatedInputIdB;
|
|
224
|
+
let inputId = generatedInputId;
|
|
222
225
|
if (rest['id']) {
|
|
223
226
|
const overrideId = rest['id'];
|
|
224
227
|
inputIdA = `${overrideId}-thumb-a`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { tokens } from '@equinor/eds-tokens';
|
|
2
|
-
import mergeDeepRight from '../../../node_modules/.pnpm/ramda@0.
|
|
2
|
+
import mergeDeepRight from '../../../node_modules/.pnpm/ramda@0.32.0/node_modules/ramda/es/mergeDeepRight.js';
|
|
3
3
|
|
|
4
4
|
const {
|
|
5
5
|
typography: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { forwardRef, useRef, useMemo, useState, useEffect } from 'react';
|
|
1
|
+
import { forwardRef, useId, useRef, useMemo, useState, useEffect } from 'react';
|
|
2
2
|
import { TabsProvider } from './Tabs.context.js';
|
|
3
3
|
import { token } from './Tabs.tokens.js';
|
|
4
|
-
import {
|
|
4
|
+
import { mergeRefs, useToken } from '@equinor/eds-utils';
|
|
5
5
|
import { ThemeProvider } from 'styled-components';
|
|
6
6
|
import { jsx } from 'react/jsx-runtime';
|
|
7
7
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
@@ -16,7 +16,8 @@ const Tabs = /*#__PURE__*/forwardRef(function Tabs({
|
|
|
16
16
|
id,
|
|
17
17
|
...props
|
|
18
18
|
}, ref) {
|
|
19
|
-
const
|
|
19
|
+
const generatedTabsId = useId();
|
|
20
|
+
const tabsId = id ?? generatedTabsId;
|
|
20
21
|
const tabsRef = useRef(null);
|
|
21
22
|
const combinedTabsRef = useMemo(() => mergeRefs(tabsRef, ref), [tabsRef, ref]);
|
|
22
23
|
const [tabsFocused, setTabsFocused] = useState(false);
|
|
@@ -1,93 +1,60 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { useInputField } from '../InputWrapper/useInputField.js';
|
|
4
4
|
import { InputWrapper } from '../InputWrapper/InputWrapper.js';
|
|
5
|
-
import { Textarea } from '../Textarea/Textarea.js';
|
|
6
5
|
import { Input } from '../Input/Input.js';
|
|
7
6
|
|
|
8
|
-
/** Proxy component for working around typescript and element type switching */
|
|
9
|
-
const Field = /*#__PURE__*/forwardRef(function Field(props, ref) {
|
|
10
|
-
return props.$multiline ? /*#__PURE__*/jsx(Textarea, {
|
|
11
|
-
ref: ref,
|
|
12
|
-
...props
|
|
13
|
-
}) : /*#__PURE__*/jsx(Input, {
|
|
14
|
-
ref: ref,
|
|
15
|
-
...props
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
7
|
const TextField = /*#__PURE__*/forwardRef(function TextField({
|
|
19
|
-
id
|
|
8
|
+
id,
|
|
20
9
|
label,
|
|
21
10
|
meta,
|
|
22
11
|
unit,
|
|
23
12
|
helperText,
|
|
24
13
|
placeholder,
|
|
25
14
|
disabled,
|
|
26
|
-
multiline = false,
|
|
27
15
|
className,
|
|
28
16
|
variant,
|
|
29
17
|
inputIcon,
|
|
30
18
|
helperIcon,
|
|
31
19
|
style,
|
|
32
|
-
rowsMax,
|
|
33
|
-
textareaRef,
|
|
34
20
|
inputRef,
|
|
35
21
|
...other
|
|
36
22
|
}, ref) {
|
|
37
|
-
const
|
|
38
|
-
|
|
23
|
+
const {
|
|
24
|
+
ariaProps,
|
|
25
|
+
containerProps,
|
|
26
|
+
labelProps,
|
|
27
|
+
helperProps
|
|
28
|
+
} = useInputField({
|
|
29
|
+
id,
|
|
30
|
+
label,
|
|
31
|
+
meta,
|
|
32
|
+
helperText,
|
|
33
|
+
helperIcon,
|
|
34
|
+
variant,
|
|
35
|
+
disabled,
|
|
36
|
+
className,
|
|
37
|
+
style
|
|
38
|
+
});
|
|
39
39
|
const hasRightAdornments = Boolean(unit || inputIcon);
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
const fieldProps = {
|
|
41
|
+
...ariaProps,
|
|
42
42
|
disabled,
|
|
43
43
|
placeholder,
|
|
44
|
-
id,
|
|
45
44
|
variant,
|
|
46
45
|
rightAdornments: hasRightAdornments && /*#__PURE__*/jsxs(Fragment, {
|
|
47
46
|
children: [inputIcon, /*#__PURE__*/jsx("span", {
|
|
48
47
|
children: unit
|
|
49
48
|
})]
|
|
50
49
|
}),
|
|
51
|
-
|
|
52
|
-
ref: ref || inputRef || textareaRef,
|
|
53
|
-
$multiline: multiline,
|
|
50
|
+
ref: ref || inputRef,
|
|
54
51
|
...other
|
|
55
52
|
};
|
|
56
|
-
let helperProps = {
|
|
57
|
-
id: null,
|
|
58
|
-
text: helperText,
|
|
59
|
-
icon: helperIcon,
|
|
60
|
-
disabled
|
|
61
|
-
};
|
|
62
|
-
const containerProps = {
|
|
63
|
-
className,
|
|
64
|
-
style: {
|
|
65
|
-
width: '100%',
|
|
66
|
-
...style
|
|
67
|
-
},
|
|
68
|
-
color: variant
|
|
69
|
-
};
|
|
70
|
-
const labelProps = {
|
|
71
|
-
htmlFor: id,
|
|
72
|
-
label,
|
|
73
|
-
meta,
|
|
74
|
-
disabled
|
|
75
|
-
};
|
|
76
|
-
if (helperText) {
|
|
77
|
-
fieldProps = {
|
|
78
|
-
'aria-describedby': helperTextId,
|
|
79
|
-
...fieldProps
|
|
80
|
-
};
|
|
81
|
-
helperProps = {
|
|
82
|
-
...helperProps,
|
|
83
|
-
id: helperTextId
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
53
|
return /*#__PURE__*/jsx(InputWrapper, {
|
|
87
54
|
helperProps: helperProps,
|
|
88
55
|
labelProps: labelProps,
|
|
89
56
|
...containerProps,
|
|
90
|
-
children: /*#__PURE__*/jsx(
|
|
57
|
+
children: /*#__PURE__*/jsx(Input, {
|
|
91
58
|
...fieldProps
|
|
92
59
|
})
|
|
93
60
|
});
|