@equinor/eds-core-react 2.4.1 → 2.5.0-beta.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/build/index.css +871 -103
- package/build/index.min.css +1 -1
- package/dist/eds-core-react.cjs +19 -9
- package/dist/esm/components/Autocomplete/MultipleInput.js +17 -3
- package/dist/esm/components/Autocomplete/useAutocomplete.js +2 -1
- package/dist/esm/components/Banner/Banner.tokens.js +0 -1
- package/dist/esm/components/Icon/Icon.js +0 -2
- package/dist/esm/components/Pagination/Pagination.js +0 -1
- package/dist/esm/components/Tabs/Tabs.js +0 -1
- package/dist/esm-next/components/next/Button/Button.js +52 -25
- package/dist/esm-next/components/next/Chip/Chip.js +77 -0
- package/dist/esm-next/components/next/Link/Link.js +19 -7
- package/dist/esm-next/components/next/Slot/Slot.js +47 -0
- package/dist/esm-next/index.next.js +2 -0
- package/dist/index.next.cjs +244 -90
- package/dist/types/components/Autocomplete/Autocomplete.d.ts +16 -2
- package/dist/types/components/Autocomplete/AutocompleteContext.d.ts +6 -2
- package/dist/types/components/Autocomplete/Option.d.ts +5 -3
- package/dist/types/components/Autocomplete/useAutocomplete.d.ts +4 -2
- package/dist/types/components/Chip/Icon.d.ts +18 -2
- package/dist/types/components/Datepicker/calendars/CalendarWrapper.d.ts +1 -1
- package/dist/types/components/Switch/Switch.styles.d.ts +3 -3
- package/dist/types/components/Typography/Typography.stories.shared.d.ts +18 -16
- package/dist/types/components/next/Button/Button.d.ts +4 -1
- package/dist/types/components/next/Button/Button.types.d.ts +13 -2
- package/dist/types/components/next/Chip/Chip.d.ts +8 -0
- package/dist/types/components/next/Chip/Chip.figma.d.ts +1 -0
- package/dist/types/components/next/Chip/Chip.types.d.ts +68 -0
- package/dist/types/components/next/Chip/index.d.ts +2 -0
- package/dist/types/components/next/Link/Link.d.ts +2 -2
- package/dist/types/components/next/Link/Link.types.d.ts +5 -3
- package/dist/types/components/next/Slot/Slot.d.ts +3 -0
- package/dist/types/components/next/Slot/Slot.types.d.ts +4 -0
- package/dist/types/components/next/Slot/index.d.ts +2 -0
- package/dist/types/components/next/index.d.ts +4 -0
- package/package.json +23 -15
package/dist/eds-core-react.cjs
CHANGED
|
@@ -3318,7 +3318,6 @@ const StyledPath$2 = styled__default.default.path.attrs(({
|
|
|
3318
3318
|
componentId: "sc-6evbi1-1"
|
|
3319
3319
|
})([""]);
|
|
3320
3320
|
const findIcon = (name, data, size) => {
|
|
3321
|
-
// eslint-disable-next-line prefer-const
|
|
3322
3321
|
const icon = data ?? get(name);
|
|
3323
3322
|
if (size < 24) {
|
|
3324
3323
|
// fallback to normal icon if small is not made yet
|
|
@@ -3335,7 +3334,6 @@ const Icon$2 = /*#__PURE__*/react.forwardRef(function Icon({
|
|
|
3335
3334
|
data,
|
|
3336
3335
|
...rest
|
|
3337
3336
|
}, ref) {
|
|
3338
|
-
// eslint-disable-next-line prefer-const
|
|
3339
3337
|
const icon = findIcon(name, data, size);
|
|
3340
3338
|
if (typeof icon === 'undefined') {
|
|
3341
3339
|
throw Error(`Icon "${name}" not found. Have you added it using Icon.add() or using data props?`);
|
|
@@ -4133,7 +4131,6 @@ const Tabs$1 = /*#__PURE__*/react.forwardRef(function Tabs({
|
|
|
4133
4131
|
return () => {
|
|
4134
4132
|
if (tabs) tabs.removeEventListener('keyup', checkIfTabWasPressed);
|
|
4135
4133
|
};
|
|
4136
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4137
4134
|
}, []);
|
|
4138
4135
|
const {
|
|
4139
4136
|
density
|
|
@@ -6888,7 +6885,6 @@ Popover.Content.displayName = 'Popover.Content';
|
|
|
6888
6885
|
Popover.Header.displayName = 'Popover.Header';
|
|
6889
6886
|
Popover.Actions.displayName = 'Popover.Actions';
|
|
6890
6887
|
|
|
6891
|
-
/* eslint-disable camelcase */
|
|
6892
6888
|
const {
|
|
6893
6889
|
typography: {
|
|
6894
6890
|
paragraph: {
|
|
@@ -8459,7 +8455,6 @@ const Pagination = /*#__PURE__*/react.forwardRef(function Pagination({
|
|
|
8459
8455
|
setActivePage(1);
|
|
8460
8456
|
onChange?.(null, 1);
|
|
8461
8457
|
}
|
|
8462
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8463
8458
|
}, [itemsPerPage]);
|
|
8464
8459
|
const props = {
|
|
8465
8460
|
ref,
|
|
@@ -9577,6 +9572,7 @@ const MultipleInput = () => {
|
|
|
9577
9572
|
hideClearButton,
|
|
9578
9573
|
restHtmlProps,
|
|
9579
9574
|
consolidatedEvents,
|
|
9575
|
+
chipCount,
|
|
9580
9576
|
inputRef
|
|
9581
9577
|
} = useAutocompleteContext();
|
|
9582
9578
|
const chipRefs = react.useRef(new Map());
|
|
@@ -9584,7 +9580,9 @@ const MultipleInput = () => {
|
|
|
9584
9580
|
if (isKeyboardEvent && selectedItems.length > 1) {
|
|
9585
9581
|
const isLastChip = index === selectedItems.length - 1;
|
|
9586
9582
|
const nextItem = selectedItems[isLastChip ? index - 1 : index + 1];
|
|
9587
|
-
chipRefs.current.get(getLabel(nextItem))
|
|
9583
|
+
const nextRef = chipRefs.current.get(getLabel(nextItem));
|
|
9584
|
+
// Fall back to input when next chip is hidden (beyond chipCount)
|
|
9585
|
+
if (nextRef) nextRef.focus();else inputRef.current?.focus();
|
|
9588
9586
|
} else if (!isKeyboardEvent) {
|
|
9589
9587
|
inputRef.current?.focus();
|
|
9590
9588
|
}
|
|
@@ -9613,7 +9611,7 @@ const MultipleInput = () => {
|
|
|
9613
9611
|
"data-density": density,
|
|
9614
9612
|
children: /*#__PURE__*/jsxRuntime.jsxs(ChipContainer, {
|
|
9615
9613
|
$density: density,
|
|
9616
|
-
children: [selectionDisplay === 'chips' && selectedItems.map((item, index) => /*#__PURE__*/jsxRuntime.jsx(Chip, {
|
|
9614
|
+
children: [selectionDisplay === 'chips' && selectedItems.slice(0, chipCount > 0 ? chipCount : undefined).map((item, index) => /*#__PURE__*/jsxRuntime.jsx(Chip, {
|
|
9617
9615
|
ref: el => {
|
|
9618
9616
|
if (el) chipRefs.current.set(getLabel(item), el);else chipRefs.current.delete(getLabel(item));
|
|
9619
9617
|
},
|
|
@@ -9629,7 +9627,18 @@ const MultipleInput = () => {
|
|
|
9629
9627
|
onClick: handleChipClick(item, index),
|
|
9630
9628
|
disabled: readOnly,
|
|
9631
9629
|
children: getLabel(item)
|
|
9632
|
-
}, getLabel(item))), /*#__PURE__*/jsxRuntime.
|
|
9630
|
+
}, getLabel(item))), selectionDisplay === 'chips' && chipCount && selectedItems.length > chipCount && /*#__PURE__*/jsxRuntime.jsxs(Chip, {
|
|
9631
|
+
style: {
|
|
9632
|
+
outline: '1px solid var(--eds_interactive_primary__resting, rgba(0, 112, 121, 1))',
|
|
9633
|
+
...(density === 'compact' && {
|
|
9634
|
+
height: '16px',
|
|
9635
|
+
fontSize: '12px',
|
|
9636
|
+
gridGap: '0px'
|
|
9637
|
+
})
|
|
9638
|
+
},
|
|
9639
|
+
disabled: readOnly,
|
|
9640
|
+
children: ["+", selectedItems.length - chipCount, " more"]
|
|
9641
|
+
}), /*#__PURE__*/jsxRuntime.jsx(UnstyledInput, {
|
|
9633
9642
|
...restHtmlProps,
|
|
9634
9643
|
...inputProps,
|
|
9635
9644
|
...consolidatedEvents,
|
|
@@ -10245,6 +10254,7 @@ const useAutocomplete = ({
|
|
|
10245
10254
|
onInputChange,
|
|
10246
10255
|
selectedOptions: _selectedOptions,
|
|
10247
10256
|
selectionDisplay = 'summary',
|
|
10257
|
+
chipCount,
|
|
10248
10258
|
multiple,
|
|
10249
10259
|
itemToKey: _itemToKey,
|
|
10250
10260
|
itemCompare: _itemCompare,
|
|
@@ -10402,7 +10412,6 @@ const useAutocomplete = ({
|
|
|
10402
10412
|
return item;
|
|
10403
10413
|
}
|
|
10404
10414
|
try {
|
|
10405
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
10406
10415
|
return item?.toString();
|
|
10407
10416
|
} catch {
|
|
10408
10417
|
throw new Error('Unable to find label, make sure your are using options as documented');
|
|
@@ -10817,6 +10826,7 @@ const useAutocomplete = ({
|
|
|
10817
10826
|
onInputChange,
|
|
10818
10827
|
selectedOptions,
|
|
10819
10828
|
selectionDisplay,
|
|
10829
|
+
chipCount,
|
|
10820
10830
|
itemToKey,
|
|
10821
10831
|
itemCompare,
|
|
10822
10832
|
allowSelectAll,
|
|
@@ -35,6 +35,7 @@ const MultipleInput = () => {
|
|
|
35
35
|
hideClearButton,
|
|
36
36
|
restHtmlProps,
|
|
37
37
|
consolidatedEvents,
|
|
38
|
+
chipCount,
|
|
38
39
|
inputRef
|
|
39
40
|
} = useAutocompleteContext();
|
|
40
41
|
const chipRefs = useRef(new Map());
|
|
@@ -42,7 +43,9 @@ const MultipleInput = () => {
|
|
|
42
43
|
if (isKeyboardEvent && selectedItems.length > 1) {
|
|
43
44
|
const isLastChip = index === selectedItems.length - 1;
|
|
44
45
|
const nextItem = selectedItems[isLastChip ? index - 1 : index + 1];
|
|
45
|
-
chipRefs.current.get(getLabel(nextItem))
|
|
46
|
+
const nextRef = chipRefs.current.get(getLabel(nextItem));
|
|
47
|
+
// Fall back to input when next chip is hidden (beyond chipCount)
|
|
48
|
+
if (nextRef) nextRef.focus();else inputRef.current?.focus();
|
|
46
49
|
} else if (!isKeyboardEvent) {
|
|
47
50
|
inputRef.current?.focus();
|
|
48
51
|
}
|
|
@@ -71,7 +74,7 @@ const MultipleInput = () => {
|
|
|
71
74
|
"data-density": density,
|
|
72
75
|
children: /*#__PURE__*/jsxs(ChipContainer, {
|
|
73
76
|
$density: density,
|
|
74
|
-
children: [selectionDisplay === 'chips' && selectedItems.map((item, index) => /*#__PURE__*/jsx(Chip, {
|
|
77
|
+
children: [selectionDisplay === 'chips' && selectedItems.slice(0, chipCount > 0 ? chipCount : undefined).map((item, index) => /*#__PURE__*/jsx(Chip, {
|
|
75
78
|
ref: el => {
|
|
76
79
|
if (el) chipRefs.current.set(getLabel(item), el);else chipRefs.current.delete(getLabel(item));
|
|
77
80
|
},
|
|
@@ -87,7 +90,18 @@ const MultipleInput = () => {
|
|
|
87
90
|
onClick: handleChipClick(item, index),
|
|
88
91
|
disabled: readOnly,
|
|
89
92
|
children: getLabel(item)
|
|
90
|
-
}, getLabel(item))), /*#__PURE__*/
|
|
93
|
+
}, getLabel(item))), selectionDisplay === 'chips' && chipCount && selectedItems.length > chipCount && /*#__PURE__*/jsxs(Chip, {
|
|
94
|
+
style: {
|
|
95
|
+
outline: '1px solid var(--eds_interactive_primary__resting, rgba(0, 112, 121, 1))',
|
|
96
|
+
...(density === 'compact' && {
|
|
97
|
+
height: '16px',
|
|
98
|
+
fontSize: '12px',
|
|
99
|
+
gridGap: '0px'
|
|
100
|
+
})
|
|
101
|
+
},
|
|
102
|
+
disabled: readOnly,
|
|
103
|
+
children: ["+", selectedItems.length - chipCount, " more"]
|
|
104
|
+
}), /*#__PURE__*/jsx(UnstyledInput, {
|
|
91
105
|
...restHtmlProps,
|
|
92
106
|
...inputProps,
|
|
93
107
|
...consolidatedEvents,
|
|
@@ -23,6 +23,7 @@ const useAutocomplete = ({
|
|
|
23
23
|
onInputChange,
|
|
24
24
|
selectedOptions: _selectedOptions,
|
|
25
25
|
selectionDisplay = 'summary',
|
|
26
|
+
chipCount,
|
|
26
27
|
multiple,
|
|
27
28
|
itemToKey: _itemToKey,
|
|
28
29
|
itemCompare: _itemCompare,
|
|
@@ -180,7 +181,6 @@ const useAutocomplete = ({
|
|
|
180
181
|
return item;
|
|
181
182
|
}
|
|
182
183
|
try {
|
|
183
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
184
184
|
return item?.toString();
|
|
185
185
|
} catch {
|
|
186
186
|
throw new Error('Unable to find label, make sure your are using options as documented');
|
|
@@ -595,6 +595,7 @@ const useAutocomplete = ({
|
|
|
595
595
|
onInputChange,
|
|
596
596
|
selectedOptions,
|
|
597
597
|
selectionDisplay,
|
|
598
|
+
chipCount,
|
|
598
599
|
itemToKey,
|
|
599
600
|
itemCompare,
|
|
600
601
|
allowSelectAll,
|
|
@@ -32,7 +32,6 @@ const StyledPath = styled.path.attrs(({
|
|
|
32
32
|
componentId: "sc-6evbi1-1"
|
|
33
33
|
})([""]);
|
|
34
34
|
const findIcon = (name, data, size) => {
|
|
35
|
-
// eslint-disable-next-line prefer-const
|
|
36
35
|
const icon = data ?? get(name);
|
|
37
36
|
if (size < 24) {
|
|
38
37
|
// fallback to normal icon if small is not made yet
|
|
@@ -49,7 +48,6 @@ const Icon = /*#__PURE__*/forwardRef(function Icon({
|
|
|
49
48
|
data,
|
|
50
49
|
...rest
|
|
51
50
|
}, ref) {
|
|
52
|
-
// eslint-disable-next-line prefer-const
|
|
53
51
|
const icon = findIcon(name, data, size);
|
|
54
52
|
if (typeof icon === 'undefined') {
|
|
55
53
|
throw Error(`Icon "${name}" not found. Have you added it using Icon.add() or using data props?`);
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
1
|
+
import { forwardRef, Children, isValidElement } from 'react';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import {
|
|
3
|
+
import { Slot } from '../Slot/Slot.js';
|
|
4
4
|
|
|
5
5
|
const SIZE_MAPPING = {
|
|
6
6
|
small: 'sm',
|
|
7
|
-
default: 'md'
|
|
8
|
-
large: 'lg'
|
|
7
|
+
default: 'md'
|
|
9
8
|
};
|
|
10
|
-
const sizeToTypography = SIZE_MAPPING;
|
|
11
9
|
const sizeToSelectableSpace = SIZE_MAPPING;
|
|
12
10
|
const Button = /*#__PURE__*/forwardRef(function Button({
|
|
13
11
|
variant = 'primary',
|
|
@@ -15,6 +13,8 @@ const Button = /*#__PURE__*/forwardRef(function Button({
|
|
|
15
13
|
tone = 'accent',
|
|
16
14
|
icon = false,
|
|
17
15
|
round = false,
|
|
16
|
+
multiline = false,
|
|
17
|
+
asChild,
|
|
18
18
|
children,
|
|
19
19
|
className,
|
|
20
20
|
disabled,
|
|
@@ -22,29 +22,56 @@ const Button = /*#__PURE__*/forwardRef(function Button({
|
|
|
22
22
|
...rest
|
|
23
23
|
}, ref) {
|
|
24
24
|
const classes = ['eds-button', className].filter(Boolean).join(' ');
|
|
25
|
-
const typographySize = sizeToTypography[size];
|
|
26
25
|
const selectableSpace = sizeToSelectableSpace[size];
|
|
27
|
-
|
|
28
|
-
ref
|
|
29
|
-
type: type,
|
|
26
|
+
const sharedProps = {
|
|
27
|
+
ref,
|
|
30
28
|
className: classes,
|
|
31
|
-
disabled
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
lineHeight: "squished",
|
|
45
|
-
baseline: "center",
|
|
29
|
+
disabled,
|
|
30
|
+
'data-variant': variant,
|
|
31
|
+
'data-selectable-space': selectableSpace,
|
|
32
|
+
'data-space-proportions': 'squished',
|
|
33
|
+
'data-color-appearance': disabled ? 'neutral' : tone,
|
|
34
|
+
'data-icon-only': icon || undefined,
|
|
35
|
+
'data-round': icon && round ? true : undefined,
|
|
36
|
+
'data-multiline': multiline || undefined,
|
|
37
|
+
...rest
|
|
38
|
+
};
|
|
39
|
+
if (asChild) {
|
|
40
|
+
return /*#__PURE__*/jsx(Slot, {
|
|
41
|
+
...sharedProps,
|
|
46
42
|
children: children
|
|
47
|
-
})
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return /*#__PURE__*/jsx("button", {
|
|
46
|
+
type: type,
|
|
47
|
+
...sharedProps,
|
|
48
|
+
children: (() => {
|
|
49
|
+
const out = [];
|
|
50
|
+
let buf = [];
|
|
51
|
+
let labelGroupIndex = 0;
|
|
52
|
+
Children.toArray(children).forEach(child => {
|
|
53
|
+
const isLabelNode = typeof child === 'string' || typeof child === 'number' || /*#__PURE__*/isValidElement(child) && child.type === 'br';
|
|
54
|
+
if (isLabelNode) {
|
|
55
|
+
buf.push(child);
|
|
56
|
+
} else {
|
|
57
|
+
if (buf.length) {
|
|
58
|
+
out.push(/*#__PURE__*/jsx("span", {
|
|
59
|
+
className: "label",
|
|
60
|
+
children: buf
|
|
61
|
+
}, `label-${labelGroupIndex++}`));
|
|
62
|
+
buf = [];
|
|
63
|
+
}
|
|
64
|
+
out.push(child);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
if (buf.length) {
|
|
68
|
+
out.push(/*#__PURE__*/jsx("span", {
|
|
69
|
+
className: "label",
|
|
70
|
+
children: buf
|
|
71
|
+
}, "label-end"));
|
|
72
|
+
}
|
|
73
|
+
return out;
|
|
74
|
+
})()
|
|
48
75
|
});
|
|
49
76
|
});
|
|
50
77
|
Button.displayName = 'Button';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { check, close, arrow_drop_up, arrow_drop_down } from '@equinor/eds-icons';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { Icon } from '../Icon/Icon.js';
|
|
5
|
+
import { TypographyNext } from '../../Typography/Typography.new.js';
|
|
6
|
+
|
|
7
|
+
const Chip = /*#__PURE__*/forwardRef(function Chip({
|
|
8
|
+
tone = 'neutral',
|
|
9
|
+
variant = 'default',
|
|
10
|
+
selected = false,
|
|
11
|
+
onDelete,
|
|
12
|
+
dropdown = false,
|
|
13
|
+
onClick,
|
|
14
|
+
children,
|
|
15
|
+
className,
|
|
16
|
+
onKeyDown,
|
|
17
|
+
...rest
|
|
18
|
+
}, ref) {
|
|
19
|
+
const classes = ['eds-chip', className].filter(Boolean).join(' ');
|
|
20
|
+
const deletable = typeof onDelete === 'function';
|
|
21
|
+
const toggleable = !deletable && !dropdown;
|
|
22
|
+
const handleClick = event => {
|
|
23
|
+
if (deletable) {
|
|
24
|
+
onDelete?.(event);
|
|
25
|
+
} else {
|
|
26
|
+
onClick?.(event);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const handleKeyDown = event => {
|
|
30
|
+
if (deletable && (event.key === 'Backspace' || event.key === 'Delete')) {
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
onDelete?.(event);
|
|
33
|
+
}
|
|
34
|
+
onKeyDown?.(event);
|
|
35
|
+
};
|
|
36
|
+
return /*#__PURE__*/jsxs("button", {
|
|
37
|
+
ref: ref,
|
|
38
|
+
type: "button",
|
|
39
|
+
className: classes,
|
|
40
|
+
"data-variant": variant,
|
|
41
|
+
"data-color-appearance": tone,
|
|
42
|
+
"data-font-family": "ui",
|
|
43
|
+
"data-font-size": "md",
|
|
44
|
+
"data-selectable-space": "sm",
|
|
45
|
+
"data-space-proportions": "squished",
|
|
46
|
+
"data-selected": selected || undefined,
|
|
47
|
+
"aria-pressed": toggleable ? selected : undefined,
|
|
48
|
+
"aria-expanded": dropdown ? selected : undefined,
|
|
49
|
+
onClick: handleClick,
|
|
50
|
+
onKeyDown: handleKeyDown,
|
|
51
|
+
...rest,
|
|
52
|
+
children: [selected && !dropdown && !deletable && /*#__PURE__*/jsx(Icon, {
|
|
53
|
+
data: check,
|
|
54
|
+
"aria-hidden": true,
|
|
55
|
+
className: "icon"
|
|
56
|
+
}), /*#__PURE__*/jsx(TypographyNext, {
|
|
57
|
+
as: "span",
|
|
58
|
+
className: "label",
|
|
59
|
+
family: "ui",
|
|
60
|
+
size: "md",
|
|
61
|
+
lineHeight: "squished",
|
|
62
|
+
baseline: "center",
|
|
63
|
+
children: children
|
|
64
|
+
}), deletable && /*#__PURE__*/jsx(Icon, {
|
|
65
|
+
data: close,
|
|
66
|
+
title: "Remove",
|
|
67
|
+
className: "icon"
|
|
68
|
+
}), !deletable && dropdown && /*#__PURE__*/jsx(Icon, {
|
|
69
|
+
data: selected ? arrow_drop_up : arrow_drop_down,
|
|
70
|
+
"aria-hidden": true,
|
|
71
|
+
className: "icon"
|
|
72
|
+
})]
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
Chip.displayName = 'Chip';
|
|
76
|
+
|
|
77
|
+
export { Chip };
|
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Slot } from '../Slot/Slot.js';
|
|
3
4
|
|
|
4
5
|
const Link = /*#__PURE__*/forwardRef(function Link({
|
|
5
6
|
variant = 'inline',
|
|
7
|
+
asChild,
|
|
6
8
|
className,
|
|
7
9
|
children,
|
|
8
10
|
...rest
|
|
9
11
|
}, ref) {
|
|
10
12
|
const classes = ['eds-link', className].filter(Boolean).join(' ');
|
|
11
|
-
|
|
12
|
-
ref
|
|
13
|
+
const sharedProps = {
|
|
14
|
+
ref,
|
|
13
15
|
className: classes,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
'data-variant': variant,
|
|
17
|
+
'data-color-appearance': 'info',
|
|
18
|
+
'data-font-family': variant === 'standalone' ? 'ui' : undefined,
|
|
19
|
+
'data-font-size': variant === 'standalone' ? 'md' : undefined,
|
|
20
|
+
'data-line-height': variant === 'standalone' ? 'squished' : undefined,
|
|
21
|
+
...rest
|
|
22
|
+
};
|
|
23
|
+
if (asChild) {
|
|
24
|
+
return /*#__PURE__*/jsx(Slot, {
|
|
25
|
+
...sharedProps,
|
|
26
|
+
children: children
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return /*#__PURE__*/jsx("a", {
|
|
30
|
+
...sharedProps,
|
|
19
31
|
children: children
|
|
20
32
|
});
|
|
21
33
|
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { forwardRef, isValidElement, cloneElement } from 'react';
|
|
2
|
+
|
|
3
|
+
function mergeClassNames(...classNames) {
|
|
4
|
+
return classNames.filter(Boolean).join(' ');
|
|
5
|
+
}
|
|
6
|
+
function mergeProps(slotProps, childProps) {
|
|
7
|
+
const merged = {
|
|
8
|
+
...childProps
|
|
9
|
+
};
|
|
10
|
+
for (const key of Object.keys(slotProps)) {
|
|
11
|
+
const slotValue = slotProps[key];
|
|
12
|
+
const childValue = childProps[key];
|
|
13
|
+
if (key === 'className') {
|
|
14
|
+
merged[key] = mergeClassNames(slotValue, childValue);
|
|
15
|
+
} else if (key === 'style') {
|
|
16
|
+
merged[key] = {
|
|
17
|
+
...slotValue,
|
|
18
|
+
...childValue
|
|
19
|
+
};
|
|
20
|
+
} else if (typeof slotValue === 'function' && typeof childValue === 'function') {
|
|
21
|
+
merged[key] = (...args) => {
|
|
22
|
+
childValue(...args);
|
|
23
|
+
slotValue(...args);
|
|
24
|
+
};
|
|
25
|
+
} else if (slotValue !== undefined) {
|
|
26
|
+
merged[key] = slotValue;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return merged;
|
|
30
|
+
}
|
|
31
|
+
const Slot = /*#__PURE__*/forwardRef(function Slot({
|
|
32
|
+
children,
|
|
33
|
+
...slotProps
|
|
34
|
+
}, ref) {
|
|
35
|
+
if (! /*#__PURE__*/isValidElement(children)) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const child = children;
|
|
39
|
+
const merged = mergeProps(slotProps, child.props);
|
|
40
|
+
return /*#__PURE__*/cloneElement(child, {
|
|
41
|
+
...merged,
|
|
42
|
+
ref
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
Slot.displayName = 'Slot';
|
|
46
|
+
|
|
47
|
+
export { Slot };
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export { Banner } from './components/next/Banner/Banner.js';
|
|
2
2
|
export { Button } from './components/next/Button/Button.js';
|
|
3
3
|
export { Checkbox } from './components/next/Checkbox/Checkbox.js';
|
|
4
|
+
export { Chip } from './components/next/Chip/Chip.js';
|
|
4
5
|
export { Field } from './components/next/Field/Field.js';
|
|
5
6
|
export { Icon } from './components/next/Icon/Icon.js';
|
|
6
7
|
export { Input } from './components/next/Input/Input.js';
|
|
7
8
|
export { Link } from './components/next/Link/Link.js';
|
|
8
9
|
export { Radio } from './components/next/Radio/Radio.js';
|
|
9
10
|
export { Search } from './components/next/Search/Search.js';
|
|
11
|
+
export { Slot } from './components/next/Slot/Slot.js';
|
|
10
12
|
export { Switch } from './components/next/Switch/Switch.js';
|
|
11
13
|
export { TextArea } from './components/next/TextArea/TextArea.js';
|
|
12
14
|
export { TextField } from './components/next/TextField/TextField.js';
|