@equinor/eds-core-react 0.20.4 → 0.21.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 +8 -0
- package/dist/eds-core-react.cjs.js +573 -309
- package/dist/esm/components/Accordion/Accordion.tokens.js +7 -0
- package/dist/esm/components/Accordion/AccordionHeader.js +4 -0
- package/dist/esm/components/Accordion/AccordionHeaderActions.js +3 -1
- package/dist/esm/components/Accordion/AccordionHeaderTitle.js +3 -1
- package/dist/esm/components/Accordion/AccordionPanel.js +2 -2
- package/dist/esm/components/Autocomplete/Autocomplete.js +86 -66
- package/dist/esm/components/Breadcrumbs/Breadcrumb.js +4 -2
- package/dist/esm/components/Button/Button.js +4 -1
- package/dist/esm/components/Button/ButtonGroup/ButtonGroup.js +37 -0
- package/dist/esm/components/Button/ButtonGroup/ButtonGroup.tokens.js +17 -0
- package/dist/esm/components/Button/index.js +8 -0
- package/dist/esm/components/Button/tokens/contained_icon.js +56 -0
- package/dist/esm/components/Button/tokens/index.js +7 -3
- package/dist/esm/components/Card/Card.js +3 -12
- package/dist/esm/components/Checkbox/Checkbox.js +4 -0
- package/dist/esm/components/Checkbox/Input.js +5 -1
- package/dist/esm/components/Menu/Menu.js +56 -40
- package/dist/esm/components/Menu/MenuItem.js +2 -2
- package/dist/esm/components/Pagination/Pagination.js +1 -1
- package/dist/esm/components/Pagination/PaginationItem.js +1 -1
- package/dist/esm/components/Popover/Popover.js +90 -35
- package/dist/esm/components/Radio/Radio.js +4 -0
- package/dist/esm/components/Scrim/Scrim.js +3 -3
- package/dist/esm/components/Search/Search.js +7 -4
- package/dist/esm/components/Select/NativeSelect/NativeSelect.js +3 -1
- package/dist/esm/components/Select/commonStyles.js +1 -1
- package/dist/esm/components/SideSheet/SideSheet.js +8 -6
- package/dist/esm/components/SideSheet/SideSheet.tokens.js +7 -0
- package/dist/esm/components/Switch/Switch.js +6 -0
- package/dist/esm/components/Switch/SwitchDefault.js +4 -0
- package/dist/esm/components/Switch/SwitchSmall.js +4 -0
- package/dist/esm/components/Tabs/TabList.js +2 -3
- package/dist/esm/components/Tabs/Tabs.js +3 -3
- package/dist/esm/components/Textarea/Textarea.js +4 -3
- package/dist/esm/components/Tooltip/Tooltip.js +102 -83
- package/dist/esm/components/TopBar/TopBar.tokens.js +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/types/components/Autocomplete/Autocomplete.d.ts +4 -0
- package/dist/types/components/Breadcrumbs/Breadcrumb.d.ts +9 -6
- package/dist/types/components/Button/Button.d.ts +8 -26
- package/dist/types/components/Button/Button.types.d.ts +1 -0
- package/dist/types/components/Button/ButtonGroup/ButtonGroup.d.ts +9 -0
- package/dist/types/components/{Group/Group.tokens.d.ts → Button/ButtonGroup/ButtonGroup.tokens.d.ts} +0 -0
- package/dist/types/components/Button/ButtonGroup/index.d.ts +1 -0
- package/dist/types/components/Button/index.d.ts +8 -1
- package/dist/types/components/Button/tokens/contained_icon.d.ts +4 -0
- package/dist/types/components/Checkbox/Checkbox.d.ts +13 -5
- package/dist/types/components/Checkbox/Input.d.ts +10 -5
- package/dist/types/components/Icon/Icon.d.ts +1 -1
- package/dist/types/components/Menu/Menu.d.ts +1 -1
- package/dist/types/components/Popover/Popover.d.ts +1 -1
- package/dist/types/components/Progress/Circular/CircularProgress.d.ts +1 -1
- package/dist/types/components/Progress/Dots/DotProgress.d.ts +1 -1
- package/dist/types/components/Progress/Star/StarProgress.d.ts +1 -1
- package/dist/types/components/Radio/Radio.d.ts +8 -5
- package/dist/types/components/Select/commonStyles.d.ts +5 -9
- package/dist/types/components/SideSheet/SideSheet.d.ts +4 -0
- package/dist/types/components/Switch/Switch.d.ts +10 -5
- package/dist/types/components/Switch/SwitchDefault.d.ts +3 -5
- package/dist/types/components/Switch/SwitchSmall.d.ts +3 -5
- package/dist/types/components/Tooltip/Tooltip.d.ts +1 -1
- package/dist/types/components/Typography/Typography.d.ts +11 -3
- package/package.json +4 -4
- package/dist/types/components/Group/Group.d.ts +0 -3
- package/dist/types/components/Group/index.d.ts +0 -1
|
@@ -47,6 +47,11 @@ const {
|
|
|
47
47
|
focused: {
|
|
48
48
|
width: focusOutlineWidth
|
|
49
49
|
}
|
|
50
|
+
},
|
|
51
|
+
typography: {
|
|
52
|
+
input: {
|
|
53
|
+
text
|
|
54
|
+
}
|
|
50
55
|
}
|
|
51
56
|
} = tokens;
|
|
52
57
|
const accordion = {
|
|
@@ -104,6 +109,8 @@ const accordion = {
|
|
|
104
109
|
left: mediumSpacing,
|
|
105
110
|
right: mediumSpacing,
|
|
106
111
|
top: mediumSpacing
|
|
112
|
+
},
|
|
113
|
+
typography: { ...text
|
|
107
114
|
}
|
|
108
115
|
},
|
|
109
116
|
icon: {
|
|
@@ -100,6 +100,8 @@ const AccordionHeader = /*#__PURE__*/forwardRef(function AccordionHeader(_ref5,
|
|
|
100
100
|
children,
|
|
101
101
|
toggleExpanded,
|
|
102
102
|
disabled,
|
|
103
|
+
className,
|
|
104
|
+
style,
|
|
103
105
|
...props
|
|
104
106
|
} = _ref5;
|
|
105
107
|
|
|
@@ -171,6 +173,8 @@ const AccordionHeader = /*#__PURE__*/forwardRef(function AccordionHeader(_ref5,
|
|
|
171
173
|
disabled: disabled,
|
|
172
174
|
parentIndex: parentIndex,
|
|
173
175
|
as: headerLevel,
|
|
176
|
+
className: className,
|
|
177
|
+
style: style,
|
|
174
178
|
children: [/*#__PURE__*/jsx(StyledAccordionHeaderButton, {
|
|
175
179
|
isExpanded: isExpanded,
|
|
176
180
|
disabled: disabled,
|
|
@@ -30,12 +30,14 @@ const AccordionHeaderActions = /*#__PURE__*/forwardRef(function AccordionHeaderA
|
|
|
30
30
|
let {
|
|
31
31
|
isExpanded,
|
|
32
32
|
disabled,
|
|
33
|
-
children
|
|
33
|
+
children,
|
|
34
|
+
...rest
|
|
34
35
|
} = _ref2;
|
|
35
36
|
return /*#__PURE__*/jsx(StyledAccordionHeaderActions, {
|
|
36
37
|
ref: ref,
|
|
37
38
|
isExpanded: isExpanded,
|
|
38
39
|
disabled: disabled,
|
|
40
|
+
...rest,
|
|
39
41
|
children: children
|
|
40
42
|
});
|
|
41
43
|
});
|
|
@@ -24,12 +24,14 @@ const AccordionHeaderTitle = /*#__PURE__*/forwardRef(function AccordionHeaderTit
|
|
|
24
24
|
let {
|
|
25
25
|
isExpanded,
|
|
26
26
|
disabled,
|
|
27
|
-
children
|
|
27
|
+
children,
|
|
28
|
+
...rest
|
|
28
29
|
} = _ref2;
|
|
29
30
|
return /*#__PURE__*/jsx(StyledAccordionHeaderTitle, {
|
|
30
31
|
ref: ref,
|
|
31
32
|
isExpanded: isExpanded,
|
|
32
33
|
disabled: disabled,
|
|
34
|
+
...rest,
|
|
33
35
|
children: children
|
|
34
36
|
});
|
|
35
37
|
}); // AccordionHeaderTitle.displayName = 'AccordionHeaderTitle'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
|
-
import { bordersTemplate, spacingsTemplate } from '@equinor/eds-utils';
|
|
3
|
+
import { bordersTemplate, spacingsTemplate, typographyTemplate } from '@equinor/eds-utils';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
6
|
const StyledAccordionPanel = styled.div.attrs(_ref => {
|
|
@@ -25,7 +25,7 @@ const StyledAccordionPanel = styled.div.attrs(_ref => {
|
|
|
25
25
|
},
|
|
26
26
|
border
|
|
27
27
|
} = theme;
|
|
28
|
-
return css(["", " ", " background:", ";min-height:96px;box-sizing:border-box;"], bordersTemplate(border), spacingsTemplate(panel.spacings), header.background);
|
|
28
|
+
return css(["", " ", " ", " background:", ";min-height:96px;box-sizing:border-box;"], bordersTemplate(border), spacingsTemplate(panel.spacings), typographyTemplate(panel.typography), header.background);
|
|
29
29
|
});
|
|
30
30
|
const AccordionPanel = /*#__PURE__*/forwardRef(function AccordionPanel(_ref3, ref) {
|
|
31
31
|
let {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { forwardRef, useRef, useState, useEffect, useMemo, useCallback } from 'react';
|
|
2
|
-
import { createPortal } from 'react-dom';
|
|
1
|
+
import { forwardRef, useRef, useState, useEffect, useMemo, useCallback, useLayoutEffect } from 'react';
|
|
3
2
|
import { useMultipleSelection, useCombobox } from 'downshift';
|
|
4
3
|
import styled, { css, ThemeProvider } from 'styled-components';
|
|
5
|
-
import { Button } from '../Button/
|
|
4
|
+
import { Button } from '../Button/index.js';
|
|
6
5
|
import { List } from '../List/index.js';
|
|
7
6
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
8
7
|
import { Label } from '../Label/Label.js';
|
|
@@ -10,8 +9,9 @@ import { Icon } from '../Icon/index.js';
|
|
|
10
9
|
import { Input } from '../Input/Input.js';
|
|
11
10
|
import { close, arrow_drop_up, arrow_drop_down } from '@equinor/eds-icons';
|
|
12
11
|
import { multiSelect, selectTokens } from './Autocomplete.tokens.js';
|
|
13
|
-
import { bordersTemplate,
|
|
12
|
+
import { bordersTemplate, useToken } from '@equinor/eds-utils';
|
|
14
13
|
import { AutocompleteOption } from './Option.js';
|
|
14
|
+
import { useFloating, offset, flip, shift, size, useInteractions, autoUpdate, FloatingPortal } from '@floating-ui/react-dom-interactions';
|
|
15
15
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
16
16
|
|
|
17
17
|
const Container = styled.div.withConfig({
|
|
@@ -38,7 +38,7 @@ const StyledList = styled(List).withConfig({
|
|
|
38
38
|
let {
|
|
39
39
|
theme
|
|
40
40
|
} = _ref2;
|
|
41
|
-
return css(["background-color:", ";box-shadow:", ";", " overflow-y:auto;max-height:300px;padding:0;
|
|
41
|
+
return css(["background-color:", ";box-shadow:", ";", " overflow-y:auto;max-height:300px;padding:0;"], theme.background, theme.boxShadow, bordersTemplate(theme.border));
|
|
42
42
|
});
|
|
43
43
|
const StyledButton = styled(Button).withConfig({
|
|
44
44
|
displayName: "Autocomplete__StyledButton",
|
|
@@ -130,8 +130,10 @@ function AutocompleteInner(props, ref) {
|
|
|
130
130
|
label,
|
|
131
131
|
meta,
|
|
132
132
|
className,
|
|
133
|
+
style,
|
|
133
134
|
disabled = false,
|
|
134
135
|
readOnly = false,
|
|
136
|
+
hideClearButton = false,
|
|
135
137
|
onOptionsChange,
|
|
136
138
|
selectedOptions,
|
|
137
139
|
multiple,
|
|
@@ -144,10 +146,7 @@ function AutocompleteInner(props, ref) {
|
|
|
144
146
|
optionLabel,
|
|
145
147
|
...other
|
|
146
148
|
} = props;
|
|
147
|
-
const anchorRef = useRef();
|
|
148
|
-
const [anchorEl, setAnchorEl] = useState();
|
|
149
|
-
const [containerEl, setContainerEl] = useState();
|
|
150
|
-
const isMounted = useIsMounted();
|
|
149
|
+
const anchorRef = useRef(null);
|
|
151
150
|
const isControlled = Boolean(selectedOptions);
|
|
152
151
|
const [inputOptions, setInputOptions] = useState(options);
|
|
153
152
|
useEffect(() => {
|
|
@@ -400,40 +399,10 @@ function AutocompleteInner(props, ref) {
|
|
|
400
399
|
reset: resetCombobox
|
|
401
400
|
} = useCombobox(comboBoxProps);
|
|
402
401
|
useEffect(() => {
|
|
403
|
-
if (anchorRef.current && isOpen) {
|
|
404
|
-
setAnchorEl(anchorRef.current);
|
|
405
|
-
} else {
|
|
406
|
-
setAnchorEl(null);
|
|
407
|
-
}
|
|
408
|
-
|
|
409
402
|
if (isControlled) {
|
|
410
403
|
setSelectedItems(selectedOptions);
|
|
411
404
|
}
|
|
412
|
-
|
|
413
|
-
return () => {
|
|
414
|
-
setAnchorEl(null);
|
|
415
|
-
setContainerEl(null);
|
|
416
|
-
};
|
|
417
|
-
}, [anchorRef, isControlled, isOpen, selectedOptions, setSelectedItems]); //"Turn on" popper on load to position menu correctly and then turn it off
|
|
418
|
-
|
|
419
|
-
useEffect(() => {
|
|
420
|
-
if (anchorRef.current) {
|
|
421
|
-
setAnchorEl(anchorRef.current);
|
|
422
|
-
setTimeout(() => {
|
|
423
|
-
setAnchorEl(null);
|
|
424
|
-
}, 1);
|
|
425
|
-
}
|
|
426
|
-
}, []);
|
|
427
|
-
const {
|
|
428
|
-
styles,
|
|
429
|
-
attributes
|
|
430
|
-
} = usePopper({
|
|
431
|
-
anchorEl,
|
|
432
|
-
popperEl: containerEl,
|
|
433
|
-
placement: 'bottom-start',
|
|
434
|
-
offset: 4,
|
|
435
|
-
autoWidth
|
|
436
|
-
});
|
|
405
|
+
}, [isControlled, selectedOptions, setSelectedItems]);
|
|
437
406
|
|
|
438
407
|
const openSelect = () => {
|
|
439
408
|
if (!isOpen && !(disabled || readOnly)) {
|
|
@@ -441,38 +410,85 @@ function AutocompleteInner(props, ref) {
|
|
|
441
410
|
}
|
|
442
411
|
};
|
|
443
412
|
|
|
413
|
+
const {
|
|
414
|
+
x,
|
|
415
|
+
y,
|
|
416
|
+
refs,
|
|
417
|
+
update,
|
|
418
|
+
reference,
|
|
419
|
+
floating,
|
|
420
|
+
strategy
|
|
421
|
+
} = useFloating({
|
|
422
|
+
placement: 'bottom-start',
|
|
423
|
+
middleware: [offset(4), flip(), shift({
|
|
424
|
+
padding: 8
|
|
425
|
+
}), size({
|
|
426
|
+
apply(_ref10) {
|
|
427
|
+
let {
|
|
428
|
+
rects,
|
|
429
|
+
availableHeight,
|
|
430
|
+
elements
|
|
431
|
+
} = _ref10;
|
|
432
|
+
const anchorWidth = "".concat(rects.reference.width, "px");
|
|
433
|
+
Object.assign(elements.floating.style, {
|
|
434
|
+
width: "".concat(autoWidth ? anchorWidth : 'auto'),
|
|
435
|
+
maxHeight: "".concat(availableHeight, "px")
|
|
436
|
+
});
|
|
437
|
+
},
|
|
438
|
+
|
|
439
|
+
padding: 10
|
|
440
|
+
})]
|
|
441
|
+
});
|
|
442
|
+
const {
|
|
443
|
+
getFloatingProps
|
|
444
|
+
} = useInteractions([]);
|
|
445
|
+
useLayoutEffect(() => {
|
|
446
|
+
reference(anchorRef.current);
|
|
447
|
+
}, [anchorRef, reference]);
|
|
448
|
+
useLayoutEffect(() => {
|
|
449
|
+
if (refs.reference.current && refs.floating.current && isOpen) {
|
|
450
|
+
return autoUpdate(refs.reference.current, refs.floating.current, update);
|
|
451
|
+
}
|
|
452
|
+
}, [refs.reference, refs.floating, update, isOpen]);
|
|
453
|
+
|
|
444
454
|
const clear = () => {
|
|
445
455
|
resetCombobox();
|
|
446
456
|
resetSelection();
|
|
447
457
|
};
|
|
448
458
|
|
|
449
|
-
const showClearButton = (selectedItems.length > 0 || inputValue) && !readOnly;
|
|
459
|
+
const showClearButton = (selectedItems.length > 0 || inputValue) && !readOnly && !hideClearButton;
|
|
450
460
|
const selectedItemsLabels = useMemo(() => selectedItems.map(getLabel), [selectedItems, getLabel]);
|
|
451
461
|
|
|
452
|
-
const optionsList = /*#__PURE__*/jsx(
|
|
453
|
-
ref:
|
|
454
|
-
style:
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
462
|
+
const optionsList = /*#__PURE__*/jsx("div", { ...getFloatingProps({
|
|
463
|
+
ref: floating,
|
|
464
|
+
style: {
|
|
465
|
+
position: strategy,
|
|
466
|
+
top: y !== null && y !== void 0 ? y : 0,
|
|
467
|
+
left: x !== null && x !== void 0 ? x : 0
|
|
468
|
+
}
|
|
459
469
|
}),
|
|
460
|
-
children:
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
isSelected
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
index,
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
470
|
+
children: /*#__PURE__*/jsx(StyledList, { ...getMenuProps({
|
|
471
|
+
'aria-multiselectable': multiple ? 'true' : null
|
|
472
|
+
}, {
|
|
473
|
+
suppressRefError: true
|
|
474
|
+
}),
|
|
475
|
+
children: !isOpen ? null : availableItems.map((item, index) => {
|
|
476
|
+
const label = getLabel(item);
|
|
477
|
+
const isDisabled = optionDisabled(item);
|
|
478
|
+
const isSelected = selectedItemsLabels.includes(label);
|
|
479
|
+
return /*#__PURE__*/jsx(AutocompleteOption, {
|
|
480
|
+
value: label,
|
|
481
|
+
multiple: multiple,
|
|
482
|
+
highlighted: highlightedIndex === index && !isDisabled ? 'true' : 'false',
|
|
483
|
+
isSelected: isSelected,
|
|
484
|
+
isDisabled: isDisabled,
|
|
485
|
+
...getItemProps({
|
|
486
|
+
item,
|
|
487
|
+
index,
|
|
488
|
+
disabled
|
|
489
|
+
})
|
|
490
|
+
}, label);
|
|
491
|
+
})
|
|
476
492
|
})
|
|
477
493
|
});
|
|
478
494
|
|
|
@@ -480,6 +496,7 @@ function AutocompleteInner(props, ref) {
|
|
|
480
496
|
theme: token,
|
|
481
497
|
children: /*#__PURE__*/jsxs(Container, {
|
|
482
498
|
className: className,
|
|
499
|
+
style: style,
|
|
483
500
|
ref: ref,
|
|
484
501
|
children: [/*#__PURE__*/jsx(Label, { ...getLabelProps(),
|
|
485
502
|
label: label,
|
|
@@ -490,7 +507,7 @@ function AutocompleteInner(props, ref) {
|
|
|
490
507
|
getDropdownProps({
|
|
491
508
|
preventKeyAction: multiple ? isOpen : undefined,
|
|
492
509
|
disabled,
|
|
493
|
-
ref:
|
|
510
|
+
ref: refs.reference
|
|
494
511
|
})),
|
|
495
512
|
placeholder: placeholderText,
|
|
496
513
|
readOnly: readOnly,
|
|
@@ -521,7 +538,10 @@ function AutocompleteInner(props, ref) {
|
|
|
521
538
|
data: isOpen ? arrow_drop_up : arrow_drop_down
|
|
522
539
|
})
|
|
523
540
|
})]
|
|
524
|
-
}), disablePortal ? optionsList :
|
|
541
|
+
}), disablePortal ? optionsList : /*#__PURE__*/jsx(FloatingPortal, {
|
|
542
|
+
id: "eds-autocomplete-container",
|
|
543
|
+
children: optionsList
|
|
544
|
+
})]
|
|
525
545
|
})
|
|
526
546
|
});
|
|
527
547
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
1
|
+
import { forwardRef, useMemo } from 'react';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
import { Typography } from '../Typography/Typography.js';
|
|
4
4
|
import { Tooltip } from '../Tooltip/Tooltip.js';
|
|
@@ -25,6 +25,7 @@ const Breadcrumb = /*#__PURE__*/forwardRef(function Breadcrumb(_ref2, ref) {
|
|
|
25
25
|
children,
|
|
26
26
|
maxWidth,
|
|
27
27
|
href,
|
|
28
|
+
as,
|
|
28
29
|
...other
|
|
29
30
|
} = _ref2;
|
|
30
31
|
const props = { ...other,
|
|
@@ -34,10 +35,11 @@ const Breadcrumb = /*#__PURE__*/forwardRef(function Breadcrumb(_ref2, ref) {
|
|
|
34
35
|
};
|
|
35
36
|
const showTooltip = maxWidth > 0;
|
|
36
37
|
const isHrefDefined = href !== undefined;
|
|
38
|
+
const forwardedAs = useMemo(() => as ? as : isHrefDefined ? 'a' : 'span', [as, isHrefDefined]);
|
|
37
39
|
|
|
38
40
|
const crumb = /*#__PURE__*/jsx(StyledTypography, {
|
|
39
41
|
link: isHrefDefined,
|
|
40
|
-
forwardedAs:
|
|
42
|
+
forwardedAs: forwardedAs,
|
|
41
43
|
variant: "body_short",
|
|
42
44
|
...props,
|
|
43
45
|
children: children
|
|
@@ -17,6 +17,9 @@ const getVariant = (tokenSet, variant) => {
|
|
|
17
17
|
case 'outlined':
|
|
18
18
|
return tokenSet.outlined;
|
|
19
19
|
|
|
20
|
+
case 'contained_icon':
|
|
21
|
+
return tokenSet.contained_icon;
|
|
22
|
+
|
|
20
23
|
case 'contained':
|
|
21
24
|
default:
|
|
22
25
|
return tokenSet.contained;
|
|
@@ -59,7 +62,7 @@ const ButtonBase = styled.button.withConfig({
|
|
|
59
62
|
hover,
|
|
60
63
|
disabled
|
|
61
64
|
} = states;
|
|
62
|
-
return css(["margin:0;padding:0;text-decoration:none;position:relative;cursor:pointer;display:inline-block;background:", ";height:", ";width:", ";svg{justify-self:center;}", " ", " ", " &::before{position:absolute;top:0;left:0;width:auto;min-height:auto;content:'';}&::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{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 === null || clickbound === void 0 ? void 0 : (_clickbound$offset = clickbound.offset) === null || _clickbound$offset === void 0 ? void 0 : _clickbound$offset.top, clickbound === null || clickbound === void 0 ? void 0 : (_clickbound$offset2 = clickbound.offset) === null || _clickbound$offset2 === void 0 ? void 0 : _clickbound$offset2.left, clickbound === null || clickbound === void 0 ? void 0 : clickbound.width, clickbound === null || clickbound === void 0 ? void 0 : clickbound.height, hover.background, (_hover$typography = hover.typography) === null || _hover$typography === void 0 ? void 0 : _hover$typography.color, bordersTemplate(hover === null || hover === void 0 ? void 0 : hover.border), outlineTemplate(focus.outline), outlineTemplate(focus.outline), disabled.background, bordersTemplate(disabled.border), typographyTemplate(disabled.typography), disabled.background);
|
|
65
|
+
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;}", " ", " ", " &::before{position:absolute;top:0;left:0;width:auto;min-height:auto;content:'';}&::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{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 === null || clickbound === void 0 ? void 0 : (_clickbound$offset = clickbound.offset) === null || _clickbound$offset === void 0 ? void 0 : _clickbound$offset.top, clickbound === null || clickbound === void 0 ? void 0 : (_clickbound$offset2 = clickbound.offset) === null || _clickbound$offset2 === void 0 ? void 0 : _clickbound$offset2.left, clickbound === null || clickbound === void 0 ? void 0 : clickbound.width, clickbound === null || clickbound === void 0 ? void 0 : clickbound.height, hover.background, (_hover$typography = hover.typography) === null || _hover$typography === void 0 ? void 0 : _hover$typography.color, bordersTemplate(hover === null || hover === void 0 ? void 0 : hover.border), outlineTemplate(focus.outline), outlineTemplate(focus.outline), disabled.background, bordersTemplate(disabled.border), typographyTemplate(disabled.typography), disabled.background);
|
|
63
66
|
});
|
|
64
67
|
const Button = /*#__PURE__*/forwardRef(function Button(_ref2, ref) {
|
|
65
68
|
let {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
import { group } from './ButtonGroup.tokens.js';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
border
|
|
8
|
+
} = group;
|
|
9
|
+
const radius = border.type === 'border' && border.radius;
|
|
10
|
+
const ButtonGroupBase = styled.div.withConfig({
|
|
11
|
+
displayName: "ButtonGroup__ButtonGroupBase",
|
|
12
|
+
componentId: "sc-1fn8jon-0"
|
|
13
|
+
})(["display:inline-flex;> *{border-radius:0;@media (hover:hover) and (pointer:fine){&:hover{border-radius:0;}}}", ""], _ref => {
|
|
14
|
+
let {
|
|
15
|
+
vertical
|
|
16
|
+
} = _ref;
|
|
17
|
+
return vertical ? css(["flex-direction:column;> :first-child{border-top-left-radius:", ";border-top-right-radius:", ";}> :last-child{border-bottom-left-radius:", ";border-bottom-right-radius:", ";}> :not(:last-child){border-bottom:none;}"], radius, radius, radius, radius) : css(["> :first-child{border-top-left-radius:", ";border-bottom-left-radius:", ";}> :last-child{border-top-right-radius:", ";border-bottom-right-radius:", ";}> :not(:last-child){border-right:none;}"], radius, radius, radius, radius);
|
|
18
|
+
});
|
|
19
|
+
const ButtonGroup = /*#__PURE__*/forwardRef(function ButtonGroup(_ref2, ref) {
|
|
20
|
+
let {
|
|
21
|
+
children,
|
|
22
|
+
vertical,
|
|
23
|
+
...rest
|
|
24
|
+
} = _ref2;
|
|
25
|
+
const props = {
|
|
26
|
+
ref,
|
|
27
|
+
vertical,
|
|
28
|
+
...rest
|
|
29
|
+
};
|
|
30
|
+
return /*#__PURE__*/jsx(ButtonGroupBase, {
|
|
31
|
+
role: "group",
|
|
32
|
+
...props,
|
|
33
|
+
children: children
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export { ButtonGroup };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { tokens } from '@equinor/eds-tokens';
|
|
2
|
+
import mergeDeepRight from '../../../node_modules/.pnpm/ramda@0.28.0/node_modules/ramda/es/mergeDeepRight.js';
|
|
3
|
+
import { primary as primary$1, secondary as secondary$1, danger as danger$1 } from './contained.js';
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
clickbounds: {
|
|
7
|
+
default__base: clicboundHeight,
|
|
8
|
+
compact__standard: compactClickboundHeight
|
|
9
|
+
},
|
|
10
|
+
shape
|
|
11
|
+
} = tokens;
|
|
12
|
+
const contained_icon = {
|
|
13
|
+
height: shape.icon_button.minHeight,
|
|
14
|
+
width: shape.icon_button.minWidth,
|
|
15
|
+
border: {
|
|
16
|
+
width: '0px',
|
|
17
|
+
radius: '50%'
|
|
18
|
+
},
|
|
19
|
+
spacings: {
|
|
20
|
+
left: '0',
|
|
21
|
+
right: '0'
|
|
22
|
+
},
|
|
23
|
+
clickbound: {
|
|
24
|
+
width: clicboundHeight,
|
|
25
|
+
offset: {
|
|
26
|
+
top: '0',
|
|
27
|
+
left: "".concat((parseInt(clicboundHeight) - parseInt('40px')) / 2, "px")
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
states: {
|
|
31
|
+
hover: {
|
|
32
|
+
border: {
|
|
33
|
+
width: '0px',
|
|
34
|
+
radius: '50%'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
modes: {
|
|
39
|
+
compact: {
|
|
40
|
+
height: shape._modes.compact.icon_button.minHeight,
|
|
41
|
+
width: shape._modes.compact.icon_button.minWidth,
|
|
42
|
+
clickbound: {
|
|
43
|
+
width: compactClickboundHeight,
|
|
44
|
+
offset: {
|
|
45
|
+
top: '0',
|
|
46
|
+
left: "".concat((parseInt(compactClickboundHeight) - parseInt(shape._modes.compact.icon_button.minWidth)) / 2, "px")
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const primary = mergeDeepRight(primary$1, contained_icon);
|
|
53
|
+
const secondary = mergeDeepRight(secondary$1, contained_icon);
|
|
54
|
+
const danger = mergeDeepRight(danger$1, contained_icon);
|
|
55
|
+
|
|
56
|
+
export { danger, primary, secondary };
|
|
@@ -2,25 +2,29 @@ import { primary, secondary, danger } from './contained.js';
|
|
|
2
2
|
import { primary as primary$1, secondary as secondary$1, danger as danger$1 } from './outlined.js';
|
|
3
3
|
import { primary as primary$2, secondary as secondary$2, danger as danger$2 } 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$4, secondary as secondary$4, danger as danger$4 } from './contained_icon.js';
|
|
5
6
|
|
|
6
7
|
const token = {
|
|
7
8
|
primary: {
|
|
8
9
|
contained: primary,
|
|
9
10
|
outlined: primary$1,
|
|
10
11
|
ghost: primary$2,
|
|
11
|
-
ghost_icon: primary$3
|
|
12
|
+
ghost_icon: primary$3,
|
|
13
|
+
contained_icon: primary$4
|
|
12
14
|
},
|
|
13
15
|
secondary: {
|
|
14
16
|
contained: secondary,
|
|
15
17
|
outlined: secondary$1,
|
|
16
18
|
ghost: secondary$2,
|
|
17
|
-
ghost_icon: secondary$3
|
|
19
|
+
ghost_icon: secondary$3,
|
|
20
|
+
contained_icon: secondary$4
|
|
18
21
|
},
|
|
19
22
|
danger: {
|
|
20
23
|
contained: danger,
|
|
21
24
|
outlined: danger$1,
|
|
22
25
|
ghost: danger$2,
|
|
23
|
-
ghost_icon: danger$3
|
|
26
|
+
ghost_icon: danger$3,
|
|
27
|
+
contained_icon: danger$4
|
|
24
28
|
}
|
|
25
29
|
};
|
|
26
30
|
|
|
@@ -11,38 +11,29 @@ const {
|
|
|
11
11
|
const StyledCard = styled(Paper).withConfig({
|
|
12
12
|
displayName: "Card__StyledCard",
|
|
13
13
|
componentId: "sc-bjucjn-0"
|
|
14
|
-
})(["width:100%;position:relative;background-color:", ";box-sizing:border-box;display:flex;flex-direction:column;grid-gap:16px;
|
|
14
|
+
})(["width:100%;position:relative;background-color:", ";box-sizing:border-box;display:flex;flex-direction:column;grid-gap:16px;", ";"], _ref => {
|
|
15
15
|
let {
|
|
16
16
|
background
|
|
17
17
|
} = _ref;
|
|
18
18
|
return background;
|
|
19
|
-
}, _ref2 => {
|
|
20
|
-
let {
|
|
21
|
-
cursor
|
|
22
|
-
} = _ref2;
|
|
23
|
-
return cursor;
|
|
24
19
|
}, bordersTemplate(primary.border));
|
|
25
|
-
const Card = /*#__PURE__*/forwardRef(function Card(
|
|
20
|
+
const Card = /*#__PURE__*/forwardRef(function Card(_ref2, ref) {
|
|
26
21
|
let {
|
|
27
22
|
children,
|
|
28
23
|
variant = 'default',
|
|
29
24
|
elevation = 'none',
|
|
30
|
-
onClick,
|
|
31
25
|
...rest
|
|
32
|
-
} =
|
|
33
|
-
const cursor = onClick ? 'pointer' : 'default';
|
|
26
|
+
} = _ref2;
|
|
34
27
|
const cardVariant = variant === 'default' ? 'primary' : variant;
|
|
35
28
|
const token = Card_tokens[cardVariant];
|
|
36
29
|
const props = {
|
|
37
30
|
ref,
|
|
38
31
|
background: token.background,
|
|
39
|
-
cursor,
|
|
40
32
|
...rest
|
|
41
33
|
};
|
|
42
34
|
return /*#__PURE__*/jsx(StyledCard, {
|
|
43
35
|
elevation: elevation,
|
|
44
36
|
...props,
|
|
45
|
-
onClick: onClick,
|
|
46
37
|
children: children
|
|
47
38
|
});
|
|
48
39
|
});
|
|
@@ -25,11 +25,13 @@ const Checkbox = /*#__PURE__*/forwardRef(function Checkbox(_ref2, ref) {
|
|
|
25
25
|
disabled = false,
|
|
26
26
|
indeterminate,
|
|
27
27
|
className,
|
|
28
|
+
style,
|
|
28
29
|
...rest
|
|
29
30
|
} = _ref2;
|
|
30
31
|
return label ? /*#__PURE__*/jsxs(StyledLabel, {
|
|
31
32
|
disabled: disabled,
|
|
32
33
|
className: className,
|
|
34
|
+
style: style,
|
|
33
35
|
children: [/*#__PURE__*/jsx(CheckboxInput, { ...rest,
|
|
34
36
|
disabled: disabled,
|
|
35
37
|
ref: ref,
|
|
@@ -38,6 +40,8 @@ const Checkbox = /*#__PURE__*/forwardRef(function Checkbox(_ref2, ref) {
|
|
|
38
40
|
children: label
|
|
39
41
|
})]
|
|
40
42
|
}) : /*#__PURE__*/jsx(CheckboxInput, { ...rest,
|
|
43
|
+
className: className,
|
|
44
|
+
style: style,
|
|
41
45
|
disabled: disabled,
|
|
42
46
|
ref: ref,
|
|
43
47
|
indeterminate: indeterminate
|
|
@@ -87,6 +87,8 @@ const CheckboxInput = /*#__PURE__*/forwardRef(function CheckboxInput(_ref10, ref
|
|
|
87
87
|
let {
|
|
88
88
|
disabled = false,
|
|
89
89
|
indeterminate,
|
|
90
|
+
style,
|
|
91
|
+
className,
|
|
90
92
|
...rest
|
|
91
93
|
} = _ref10;
|
|
92
94
|
const {
|
|
@@ -98,7 +100,9 @@ const CheckboxInput = /*#__PURE__*/forwardRef(function CheckboxInput(_ref10, ref
|
|
|
98
100
|
const iconSize = 24;
|
|
99
101
|
const fill = disabled ? checkbox.states.disabled.background : checkbox.background;
|
|
100
102
|
const inputWrapperProps = {
|
|
101
|
-
disabled
|
|
103
|
+
disabled,
|
|
104
|
+
style,
|
|
105
|
+
className
|
|
102
106
|
};
|
|
103
107
|
const inputProps = {
|
|
104
108
|
ref,
|