@equinor/eds-core-react 0.29.2-dev14022023 → 0.30.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.js +183 -100
- package/dist/esm/components/Accordion/AccordionItem.js +17 -7
- package/dist/esm/components/Autocomplete/Autocomplete.js +18 -5
- package/dist/esm/components/Breadcrumbs/Breadcrumb.js +4 -3
- package/dist/esm/components/Breadcrumbs/Breadcrumbs.js +18 -9
- package/dist/esm/components/Dialog/DialogHeader.js +1 -1
- package/dist/esm/components/Input/Input.js +1 -1
- package/dist/esm/components/Menu/Menu.js +20 -5
- package/dist/esm/components/Select/NativeSelect/NativeSelect.js +2 -1
- package/dist/esm/components/Slider/Output.js +8 -9
- package/dist/esm/components/Slider/Slider.js +98 -61
- package/dist/types/components/Accordion/AccordionItem.d.ts +12 -2
- package/dist/types/components/Autocomplete/Autocomplete.d.ts +66 -14
- package/dist/types/components/Breadcrumbs/Breadcrumb.d.ts +2 -0
- package/dist/types/components/Breadcrumbs/Breadcrumbs.d.ts +16 -0
- package/dist/types/components/Menu/Menu.d.ts +4 -0
- package/package.json +3 -3
|
@@ -9,6 +9,7 @@ import styled, { css, ThemeProvider } from 'styled-components';
|
|
|
9
9
|
import { Button } from '../Button/index.js';
|
|
10
10
|
import { List } from '../List/index.js';
|
|
11
11
|
import { Icon } from '../Icon/index.js';
|
|
12
|
+
import { Progress } from '../Progress/index.js';
|
|
12
13
|
import { close, arrow_drop_up, arrow_drop_down } from '@equinor/eds-icons';
|
|
13
14
|
import { multiSelect, selectTokens } from './Autocomplete.tokens.js';
|
|
14
15
|
import { bordersTemplate, useToken, useIsomorphicLayoutEffect } from '@equinor/eds-utils';
|
|
@@ -19,7 +20,7 @@ import { useEds } from '../EdsProvider/eds.context.js';
|
|
|
19
20
|
import { Label } from '../Label/Label.js';
|
|
20
21
|
import { Input } from '../Input/Input.js';
|
|
21
22
|
|
|
22
|
-
var _excluded = ["options", "label", "meta", "className", "style", "disabled", "readOnly", "hideClearButton", "onOptionsChange", "selectedOptions", "multiple", "initialSelectedOptions", "disablePortal", "optionDisabled", "optionsFilter", "autoWidth", "placeholder", "optionLabel", "clearSearchOnChange", "multiline"];
|
|
23
|
+
var _excluded = ["options", "label", "meta", "className", "style", "disabled", "readOnly", "loading", "hideClearButton", "onOptionsChange", "onInputChange", "selectedOptions", "multiple", "initialSelectedOptions", "disablePortal", "optionDisabled", "optionsFilter", "autoWidth", "placeholder", "optionLabel", "clearSearchOnChange", "multiline", "dropdownHeight"];
|
|
23
24
|
var Container = styled.div.withConfig({
|
|
24
25
|
displayName: "Autocomplete__Container",
|
|
25
26
|
componentId: "sc-yvif0e-0"
|
|
@@ -29,7 +30,7 @@ var StyledList = styled(List).withConfig({
|
|
|
29
30
|
componentId: "sc-yvif0e-1"
|
|
30
31
|
})(function (_ref) {
|
|
31
32
|
var theme = _ref.theme;
|
|
32
|
-
return css(["background-color:", ";box-shadow:", ";", " overflow-y:auto;overflow-x:hidden;
|
|
33
|
+
return css(["background-color:", ";box-shadow:", ";", " overflow-y:auto;overflow-x:hidden;padding:0;display:grid;"], theme.background, theme.boxShadow, bordersTemplate(theme.border));
|
|
33
34
|
});
|
|
34
35
|
var StyledButton = styled(Button).withConfig({
|
|
35
36
|
displayName: "Autocomplete__StyledButton",
|
|
@@ -108,9 +109,12 @@ function AutocompleteInner(props, ref) {
|
|
|
108
109
|
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
109
110
|
_props$readOnly = props.readOnly,
|
|
110
111
|
readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
|
|
112
|
+
_props$loading = props.loading,
|
|
113
|
+
loading = _props$loading === void 0 ? false : _props$loading,
|
|
111
114
|
_props$hideClearButto = props.hideClearButton,
|
|
112
115
|
hideClearButton = _props$hideClearButto === void 0 ? false : _props$hideClearButto,
|
|
113
116
|
onOptionsChange = props.onOptionsChange,
|
|
117
|
+
onInputChange = props.onInputChange,
|
|
114
118
|
selectedOptions = props.selectedOptions,
|
|
115
119
|
multiple = props.multiple,
|
|
116
120
|
_props$initialSelecte = props.initialSelectedOptions,
|
|
@@ -128,6 +132,8 @@ function AutocompleteInner(props, ref) {
|
|
|
128
132
|
clearSearchOnChange = _props$clearSearchOnC === void 0 ? true : _props$clearSearchOnC,
|
|
129
133
|
_props$multiline = props.multiline,
|
|
130
134
|
multiline = _props$multiline === void 0 ? false : _props$multiline,
|
|
135
|
+
_props$dropdownHeight = props.dropdownHeight,
|
|
136
|
+
dropdownHeight = _props$dropdownHeight === void 0 ? 300 : _props$dropdownHeight,
|
|
131
137
|
other = _objectWithoutProperties(props, _excluded);
|
|
132
138
|
var isControlled = Boolean(selectedOptions);
|
|
133
139
|
var _useState = useState(options),
|
|
@@ -231,6 +237,7 @@ function AutocompleteInner(props, ref) {
|
|
|
231
237
|
itemToString: getLabel,
|
|
232
238
|
onInputValueChange: function onInputValueChange(_ref6) {
|
|
233
239
|
var inputValue = _ref6.inputValue;
|
|
240
|
+
onInputChange && onInputChange(inputValue);
|
|
234
241
|
setAvailableItems(options.filter(function (item) {
|
|
235
242
|
if (optionsFilter) {
|
|
236
243
|
return optionsFilter(item, inputValue);
|
|
@@ -434,7 +441,10 @@ function AutocompleteInner(props, ref) {
|
|
|
434
441
|
})), {}, {
|
|
435
442
|
children: /*#__PURE__*/jsxs(StyledList, _objectSpread(_objectSpread({}, getMenuProps({
|
|
436
443
|
'aria-multiselectable': multiple ? 'true' : null,
|
|
437
|
-
ref: scrollContainer
|
|
444
|
+
ref: scrollContainer,
|
|
445
|
+
style: {
|
|
446
|
+
maxHeight: "".concat(dropdownHeight, "px")
|
|
447
|
+
}
|
|
438
448
|
}, {
|
|
439
449
|
suppressRefError: true
|
|
440
450
|
})), {}, {
|
|
@@ -502,9 +512,11 @@ function AutocompleteInner(props, ref) {
|
|
|
502
512
|
readOnly: readOnly,
|
|
503
513
|
onFocus: openSelect,
|
|
504
514
|
onClick: openSelect,
|
|
505
|
-
rightAdornmentsWidth:
|
|
515
|
+
rightAdornmentsWidth: hideClearButton ? 24 + 8 : 24 * 2 + 8,
|
|
506
516
|
rightAdornments: /*#__PURE__*/jsxs(Fragment, {
|
|
507
|
-
children: [
|
|
517
|
+
children: [loading && /*#__PURE__*/jsx(Progress.Circular, {
|
|
518
|
+
size: 16
|
|
519
|
+
}), showClearButton && /*#__PURE__*/jsx(StyledButton, {
|
|
508
520
|
variant: "ghost_icon",
|
|
509
521
|
disabled: disabled || readOnly,
|
|
510
522
|
"aria-label": 'clear options',
|
|
@@ -528,6 +540,7 @@ function AutocompleteInner(props, ref) {
|
|
|
528
540
|
})
|
|
529
541
|
}, other))
|
|
530
542
|
}), disablePortal ? optionsList : /*#__PURE__*/jsx(FloatingPortal, {
|
|
543
|
+
id: "eds-autocomplete-container",
|
|
531
544
|
children: optionsList
|
|
532
545
|
})]
|
|
533
546
|
})
|
|
@@ -7,13 +7,13 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
7
7
|
import { Typography } from '../Typography/Typography.js';
|
|
8
8
|
import { Tooltip } from '../Tooltip/Tooltip.js';
|
|
9
9
|
|
|
10
|
-
var _excluded = ["children", "maxWidth", "href", "as"];
|
|
10
|
+
var _excluded = ["children", "maxWidth", "forceTooltip", "href", "as"];
|
|
11
11
|
var states = breadcrumbs.states,
|
|
12
12
|
typography = breadcrumbs.typography;
|
|
13
13
|
var StyledTypography = styled(Typography).withConfig({
|
|
14
14
|
displayName: "Breadcrumb__StyledTypography",
|
|
15
15
|
componentId: "sc-10nvwte-0"
|
|
16
|
-
})(["@media (hover:hover) and (pointer:fine){&:hover{text-decoration:underline;color:", ";cursor:pointer;}}white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:inline-block;text-decoration:none;color:", ";", ""], states.hover.typography.color, typography.color, function (_ref) {
|
|
16
|
+
})(["@media (hover:hover) and (pointer:fine){&:hover{text-decoration:underline;color:", ";cursor:pointer;}}white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:inline-block;text-decoration:none;color:", ";width:100%;", ""], states.hover.typography.color, typography.color, function (_ref) {
|
|
17
17
|
var $maxWidth = _ref.$maxWidth;
|
|
18
18
|
return css({
|
|
19
19
|
maxWidth: $maxWidth
|
|
@@ -22,6 +22,7 @@ var StyledTypography = styled(Typography).withConfig({
|
|
|
22
22
|
var Breadcrumb = /*#__PURE__*/forwardRef(function Breadcrumb(_ref2, ref) {
|
|
23
23
|
var children = _ref2.children,
|
|
24
24
|
maxWidth = _ref2.maxWidth,
|
|
25
|
+
forceTooltip = _ref2.forceTooltip,
|
|
25
26
|
href = _ref2.href,
|
|
26
27
|
as = _ref2.as,
|
|
27
28
|
other = _objectWithoutProperties(_ref2, _excluded);
|
|
@@ -29,7 +30,7 @@ var Breadcrumb = /*#__PURE__*/forwardRef(function Breadcrumb(_ref2, ref) {
|
|
|
29
30
|
href: href,
|
|
30
31
|
ref: ref
|
|
31
32
|
});
|
|
32
|
-
var showTooltip = maxWidth > 0;
|
|
33
|
+
var showTooltip = maxWidth > 0 || forceTooltip;
|
|
33
34
|
var isHrefDefined = href !== undefined;
|
|
34
35
|
var forwardedAs = useMemo(function () {
|
|
35
36
|
return as ? as : isHrefDefined ? 'a' : 'span';
|
|
@@ -8,18 +8,21 @@ import { spacingsTemplate } from '@equinor/eds-utils';
|
|
|
8
8
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
9
9
|
import { Typography } from '../Typography/Typography.js';
|
|
10
10
|
|
|
11
|
-
var _excluded = ["children", "collapse"];
|
|
11
|
+
var _excluded = ["children", "collapse", "wrap"];
|
|
12
12
|
var spacings = breadcrumbs.spacings,
|
|
13
13
|
typography = breadcrumbs.typography,
|
|
14
14
|
states = breadcrumbs.states;
|
|
15
15
|
var OrderedList = styled.ol.withConfig({
|
|
16
16
|
displayName: "Breadcrumbs__OrderedList",
|
|
17
17
|
componentId: "sc-12awlbz-0"
|
|
18
|
-
})(["list-style:none;display:flex;padding:0;margin:0;flex-wrap:wrap;"])
|
|
18
|
+
})(["list-style:none;display:flex;padding:0;margin:0;flex-wrap:wrap;flex-wrap:", ";"], function (_ref) {
|
|
19
|
+
var $wrap = _ref.$wrap;
|
|
20
|
+
return $wrap ? 'wrap' : 'nowrap';
|
|
21
|
+
});
|
|
19
22
|
var ListItem = styled.li.withConfig({
|
|
20
23
|
displayName: "Breadcrumbs__ListItem",
|
|
21
24
|
componentId: "sc-12awlbz-1"
|
|
22
|
-
})(["display:inline-block;"]);
|
|
25
|
+
})(["display:inline-block;min-width:30px;"]);
|
|
23
26
|
var Separator = styled(Typography).withConfig({
|
|
24
27
|
displayName: "Breadcrumbs__Separator",
|
|
25
28
|
componentId: "sc-12awlbz-2"
|
|
@@ -28,10 +31,12 @@ var Collapsed = styled(Typography).withConfig({
|
|
|
28
31
|
displayName: "Breadcrumbs__Collapsed",
|
|
29
32
|
componentId: "sc-12awlbz-3"
|
|
30
33
|
})(["@media (hover:hover) and (pointer:fine){&:hover{text-decoration:underline;color:", ";}}color:", ";text-decoration:none;"], states.hover.typography.color, typography.color);
|
|
31
|
-
var Breadcrumbs = /*#__PURE__*/forwardRef(function Breadcrumbs(
|
|
32
|
-
var children =
|
|
33
|
-
collapse =
|
|
34
|
-
|
|
34
|
+
var Breadcrumbs = /*#__PURE__*/forwardRef(function Breadcrumbs(_ref2, ref) {
|
|
35
|
+
var children = _ref2.children,
|
|
36
|
+
collapse = _ref2.collapse,
|
|
37
|
+
_ref2$wrap = _ref2.wrap,
|
|
38
|
+
wrap = _ref2$wrap === void 0 ? true : _ref2$wrap,
|
|
39
|
+
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
35
40
|
var props = _objectSpread(_objectSpread({}, rest), {}, {
|
|
36
41
|
ref: ref
|
|
37
42
|
});
|
|
@@ -42,8 +47,8 @@ var Breadcrumbs = /*#__PURE__*/forwardRef(function Breadcrumbs(_ref, ref) {
|
|
|
42
47
|
var collapsedCrumbs = function collapsedCrumbs(allCrumbs) {
|
|
43
48
|
var handleExpandClick = function handleExpandClick(e) {
|
|
44
49
|
setExpanded(true);
|
|
45
|
-
var
|
|
46
|
-
key =
|
|
50
|
+
var _ref3 = e,
|
|
51
|
+
key = _ref3.key;
|
|
47
52
|
if (key === 'Enter') {
|
|
48
53
|
setExpanded(true);
|
|
49
54
|
}
|
|
@@ -53,6 +58,9 @@ var Breadcrumbs = /*#__PURE__*/forwardRef(function Breadcrumbs(_ref, ref) {
|
|
|
53
58
|
}
|
|
54
59
|
return [allCrumbs[0], /*#__PURE__*/jsxs(Fragment, {
|
|
55
60
|
children: [/*#__PURE__*/jsx(ListItem, {
|
|
61
|
+
style: {
|
|
62
|
+
minWidth: 'unset'
|
|
63
|
+
},
|
|
56
64
|
children: /*#__PURE__*/jsx(Collapsed, {
|
|
57
65
|
link: true,
|
|
58
66
|
role: "button",
|
|
@@ -91,6 +99,7 @@ var Breadcrumbs = /*#__PURE__*/forwardRef(function Breadcrumbs(_ref, ref) {
|
|
|
91
99
|
return /*#__PURE__*/jsx("nav", _objectSpread(_objectSpread({}, props), {}, {
|
|
92
100
|
"aria-label": "breadcrumbs",
|
|
93
101
|
children: /*#__PURE__*/jsx(OrderedList, {
|
|
102
|
+
$wrap: wrap,
|
|
94
103
|
children: collapse && !expanded ? collapsedCrumbs(allCrumbs) : allCrumbs
|
|
95
104
|
})
|
|
96
105
|
}));
|
|
@@ -11,7 +11,7 @@ var StyledDialogHeader = styled.div.withConfig({
|
|
|
11
11
|
componentId: "sc-mbwcos-0"
|
|
12
12
|
})(function (_ref) {
|
|
13
13
|
var theme = _ref.theme;
|
|
14
|
-
return css(["display:flex;justify-content:space-
|
|
14
|
+
return css(["display:flex;justify-content:space-between;align-items:center;padding:", " ", " 0 ", ";"], theme.entities.children.spacings.top, theme.entities.children.spacings.right, theme.entities.children.spacings.left);
|
|
15
15
|
});
|
|
16
16
|
var StyledDivider = styled(Divider).withConfig({
|
|
17
17
|
displayName: "DialogHeader__StyledDivider",
|
|
@@ -19,7 +19,7 @@ var Container = styled.div.withConfig({
|
|
|
19
19
|
readOnly = _ref.readOnly;
|
|
20
20
|
var states = token.states,
|
|
21
21
|
entities = token.entities;
|
|
22
|
-
return css(["--eds-input-adornment-color:", ";--eds-input-color:", ";position:relative;height:", ";width:", ";display:flex;flex-direction:row;border:none;box-sizing:border-box;box-shadow:", ";background:var(--eds-input-background,", ");", " &:focus-within{--eds-input-adornment-color:", ";box-shadow:none;", "}", " ", ""], entities.adornment.typography.color, token.typography.color, token.height, token.width, token.boxShadow, token.background, outlineTemplate(token.outline), (_entities$adornment = entities.adornment) === null || _entities$adornment === void 0 ? void 0 : (_entities$adornment$s = _entities$adornment.states.focus) === null || _entities$adornment$s === void 0 ? void 0 : _entities$adornment$s.outline.color, outlineTemplate(states.focus.outline), disabled && css(["--eds-input-adornment-color:", ";--eds-input-color:", ";cursor:not-allowed;box-shadow:none;"], states.disabled.typography.color, states.disabled.typography.color), readOnly && css({
|
|
22
|
+
return css(["--eds-input-adornment-color:", ";--eds-input-color:", ";position:relative;height:", ";width:", ";display:flex;flex-direction:row;border:none;box-sizing:border-box;box-shadow:", ";background:var(--eds-input-background,", ");", " &:focus-within{--eds-input-adornment-color:", ";box-shadow:none;", "}", " ", " & > input{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}"], entities.adornment.typography.color, token.typography.color, token.height, token.width, token.boxShadow, token.background, outlineTemplate(token.outline), (_entities$adornment = entities.adornment) === null || _entities$adornment === void 0 ? void 0 : (_entities$adornment$s = _entities$adornment.states.focus) === null || _entities$adornment$s === void 0 ? void 0 : _entities$adornment$s.outline.color, outlineTemplate(states.focus.outline), disabled && css(["--eds-input-adornment-color:", ";--eds-input-color:", ";cursor:not-allowed;box-shadow:none;"], states.disabled.typography.color, states.disabled.typography.color), readOnly && css({
|
|
23
23
|
background: states.readOnly.background,
|
|
24
24
|
boxShadow: states.readOnly.boxShadow
|
|
25
25
|
}));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
1
2
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
3
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
4
|
import { forwardRef, useEffect, useMemo } from 'react';
|
|
@@ -6,13 +7,13 @@ import { MenuProvider, useMenu } from './Menu.context.js';
|
|
|
6
7
|
import { MenuList } from './MenuList.js';
|
|
7
8
|
import { bordersTemplate, useToken, mergeRefs, useIsomorphicLayoutEffect, useGlobalKeyPress } from '@equinor/eds-utils';
|
|
8
9
|
import { menu } from './Menu.tokens.js';
|
|
9
|
-
import {
|
|
10
|
+
import { offset, flip, shift, size, useFloating, autoUpdate, useInteractions, useDismiss, FloatingPortal } from '@floating-ui/react';
|
|
10
11
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
11
12
|
import { Paper } from '../Paper/Paper.js';
|
|
12
13
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
13
14
|
|
|
14
15
|
var _excluded = ["children", "anchorEl", "onClose", "open"],
|
|
15
|
-
_excluded2 = ["anchorEl", "open", "placement", "onClose", "style", "className"];
|
|
16
|
+
_excluded2 = ["anchorEl", "open", "placement", "matchAnchorWidth", "onClose", "style", "className"];
|
|
16
17
|
var border = menu.border;
|
|
17
18
|
var MenuPaper = styled(Paper).withConfig({
|
|
18
19
|
displayName: "Menu__MenuPaper",
|
|
@@ -101,6 +102,8 @@ var Menu = /*#__PURE__*/forwardRef(function Menu(_ref3, ref) {
|
|
|
101
102
|
open = _ref3.open,
|
|
102
103
|
_ref3$placement = _ref3.placement,
|
|
103
104
|
placement = _ref3$placement === void 0 ? 'bottom' : _ref3$placement,
|
|
105
|
+
_ref3$matchAnchorWidt = _ref3.matchAnchorWidth,
|
|
106
|
+
matchAnchorWidth = _ref3$matchAnchorWidt === void 0 ? false : _ref3$matchAnchorWidt,
|
|
104
107
|
onClose = _ref3.onClose,
|
|
105
108
|
style = _ref3.style,
|
|
106
109
|
className = _ref3.className,
|
|
@@ -110,13 +113,25 @@ var Menu = /*#__PURE__*/forwardRef(function Menu(_ref3, ref) {
|
|
|
110
113
|
var token = useToken({
|
|
111
114
|
density: density
|
|
112
115
|
}, menu);
|
|
116
|
+
var floatingMiddleware = [offset(4), flip(), shift({
|
|
117
|
+
padding: 8
|
|
118
|
+
})];
|
|
119
|
+
if (matchAnchorWidth) {
|
|
120
|
+
floatingMiddleware = [].concat(_toConsumableArray(floatingMiddleware), [size({
|
|
121
|
+
apply: function apply(_ref4) {
|
|
122
|
+
var rects = _ref4.rects,
|
|
123
|
+
elements = _ref4.elements;
|
|
124
|
+
Object.assign(elements.floating.style, {
|
|
125
|
+
width: "".concat(rects.reference.width, "px")
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
})]);
|
|
129
|
+
}
|
|
113
130
|
var _useFloating = useFloating({
|
|
114
131
|
placement: placement,
|
|
115
132
|
open: open,
|
|
116
133
|
onOpenChange: onClose,
|
|
117
|
-
middleware:
|
|
118
|
-
padding: 8
|
|
119
|
-
})]
|
|
134
|
+
middleware: floatingMiddleware
|
|
120
135
|
}),
|
|
121
136
|
x = _useFloating.x,
|
|
122
137
|
y = _useFloating.y,
|
|
@@ -52,7 +52,8 @@ var NativeSelect = /*#__PURE__*/forwardRef(function NativeSelect(_ref2, ref) {
|
|
|
52
52
|
var labelProps = {
|
|
53
53
|
htmlFor: id,
|
|
54
54
|
label: label,
|
|
55
|
-
meta: meta
|
|
55
|
+
meta: meta,
|
|
56
|
+
disabled: disabled
|
|
56
57
|
};
|
|
57
58
|
var showLabel = label || meta;
|
|
58
59
|
return /*#__PURE__*/jsx(ThemeProvider, {
|
|
@@ -10,17 +10,16 @@ var _tokens$entities = slider.entities,
|
|
|
10
10
|
var StyledOutput = styled.output.withConfig({
|
|
11
11
|
displayName: "Output__StyledOutput",
|
|
12
12
|
componentId: "sc-1dy945x-0"
|
|
13
|
-
})(["--
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var children = _ref2.children,
|
|
19
|
-
value = _ref2.value,
|
|
20
|
-
htmlFor = _ref2.htmlFor;
|
|
13
|
+
})(["--realWidth:calc(100% - 12px);width:fit-content;position:relative;z-index:1;", " background:", ";padding:0 5px;top:", ";pointer-events:none;margin-left:calc((var(--val) - var(--min)) / var(--dif) * var(--realWidth));transform:translate(calc(-1 * calc(var(--realWidth) / 2)));grid-row:2;grid-column:1 / -1;"], typographyTemplate(output.typography), slider.background, track.spacings.top);
|
|
14
|
+
var Output = /*#__PURE__*/forwardRef(function Output(_ref, ref) {
|
|
15
|
+
var children = _ref.children,
|
|
16
|
+
value = _ref.value,
|
|
17
|
+
htmlFor = _ref.htmlFor;
|
|
21
18
|
return /*#__PURE__*/jsx(StyledOutput, {
|
|
22
19
|
ref: ref,
|
|
23
|
-
|
|
20
|
+
style: {
|
|
21
|
+
'--val': value
|
|
22
|
+
},
|
|
24
23
|
htmlFor: htmlFor,
|
|
25
24
|
children: children
|
|
26
25
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
1
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
2
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
4
4
|
import { forwardRef, useState, useEffect, useRef, useCallback } from 'react';
|
|
5
5
|
import styled, { css } from 'styled-components';
|
|
6
6
|
import { slider } from './Slider.tokens.js';
|
|
@@ -21,41 +21,44 @@ var fakeTrackBgHover = css({
|
|
|
21
21
|
});
|
|
22
22
|
var trackFill = css(["grid-column:1 / span 2;grid-row:2;height:", ";margin-bottom:", ";align-self:end;content:'';"], track.height, track.spacings.bottom);
|
|
23
23
|
var wrapperGrid = css(["display:grid;grid-template-rows:max-content 24px;grid-template-columns:1fr 1fr;width:100%;position:relative;"]);
|
|
24
|
-
var RangeWrapper = styled.div.
|
|
24
|
+
var RangeWrapper = styled.div.attrs(function (_ref) {
|
|
25
|
+
var $min = _ref.$min,
|
|
26
|
+
$max = _ref.$max,
|
|
27
|
+
valA = _ref.valA,
|
|
28
|
+
valB = _ref.valB,
|
|
29
|
+
disabled = _ref.disabled,
|
|
30
|
+
style = _ref.style;
|
|
31
|
+
return {
|
|
32
|
+
style: _objectSpread({
|
|
33
|
+
'--a': valA,
|
|
34
|
+
'--b': valB,
|
|
35
|
+
'--min': $min,
|
|
36
|
+
'--max': $max,
|
|
37
|
+
'--background': disabled ? track.entities.indicator.states.disabled.background : track.entities.indicator.background
|
|
38
|
+
}, style)
|
|
39
|
+
};
|
|
40
|
+
}).withConfig({
|
|
25
41
|
displayName: "Slider__RangeWrapper",
|
|
26
42
|
componentId: "sc-n1grrg-0"
|
|
27
|
-
})(["--
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
var Wrapper = styled.div.withConfig({
|
|
43
|
+
})(["--dif:calc(var(--max) - var(--min));--realWidth:calc(100% - 12px);", " ", " &::before,&::after{", ";background:var(--background);}&::before{margin-left:calc( calc(", " / 2) + (var(--a) - var(--min)) / var(--dif) * var(--realWidth) );width:calc((var(--b) - var(--a)) / var(--dif) * var(--realWidth));}&::after{margin-left:calc( calc(", " / 2) + (var(--b) - var(--min)) / var(--dif) * var(--realWidth) );width:calc((var(--a) - var(--b)) / var(--dif) * var(--realWidth));}@media (hover:hover) and (pointer:fine){&:hover:not([disabled]){", " &::before,&::after{background:", ";}}}"], wrapperGrid, fakeTrackBg, trackFill, handle.width, handle.width, fakeTrackBgHover, track.entities.indicator.states.hover.background);
|
|
44
|
+
var Wrapper = styled.div.attrs(function (_ref2) {
|
|
45
|
+
var $min = _ref2.$min,
|
|
46
|
+
$max = _ref2.$max,
|
|
47
|
+
value = _ref2.value,
|
|
48
|
+
disabled = _ref2.disabled,
|
|
49
|
+
style = _ref2.style;
|
|
50
|
+
return {
|
|
51
|
+
style: _objectSpread({
|
|
52
|
+
'--min': $min,
|
|
53
|
+
'--max': $max,
|
|
54
|
+
'--value': value,
|
|
55
|
+
'--background': disabled ? track.entities.indicator.states.disabled.background : track.entities.indicator.background
|
|
56
|
+
}, style)
|
|
57
|
+
};
|
|
58
|
+
}).withConfig({
|
|
44
59
|
displayName: "Slider__Wrapper",
|
|
45
60
|
componentId: "sc-n1grrg-1"
|
|
46
|
-
})(["--
|
|
47
|
-
var min = _ref6.min;
|
|
48
|
-
return min;
|
|
49
|
-
}, function (_ref7) {
|
|
50
|
-
var max = _ref7.max;
|
|
51
|
-
return max;
|
|
52
|
-
}, function (_ref8) {
|
|
53
|
-
var value = _ref8.value;
|
|
54
|
-
return value;
|
|
55
|
-
}, wrapperGrid, fakeTrackBg, trackFill, function (_ref9) {
|
|
56
|
-
var disabled = _ref9.disabled;
|
|
57
|
-
return disabled ? track.entities.indicator.states.disabled.background : track.entities.indicator.background;
|
|
58
|
-
}, fakeTrackBgHover, track.entities.indicator.states.hover.background);
|
|
61
|
+
})(["--dif:calc(var(--max) - var(--min));--realWidth:calc(100% - 12px);", " ", " &::after{", " background:var(--background)}&::after{margin-right:calc( (var(--max) - var(--value)) / var(--dif) * var(--realWidth) );margin-left:3px;}@media (hover:hover) and (pointer:fine){&:hover:not([disabled]){", " &::after{background:", ";}}}"], wrapperGrid, fakeTrackBg, trackFill, fakeTrackBgHover, track.entities.indicator.states.hover.background);
|
|
59
62
|
var WrapperGroupLabel = styled.div.withConfig({
|
|
60
63
|
displayName: "Slider__WrapperGroupLabel",
|
|
61
64
|
componentId: "sc-n1grrg-2"
|
|
@@ -68,26 +71,26 @@ var SrOnlyLabel = styled.label.withConfig({
|
|
|
68
71
|
displayName: "Slider__SrOnlyLabel",
|
|
69
72
|
componentId: "sc-n1grrg-4"
|
|
70
73
|
})(["position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0;"]);
|
|
71
|
-
var Slider = /*#__PURE__*/forwardRef(function Slider(
|
|
72
|
-
var
|
|
73
|
-
min =
|
|
74
|
-
|
|
75
|
-
max =
|
|
76
|
-
|
|
77
|
-
value =
|
|
78
|
-
outputFunction =
|
|
79
|
-
onChange =
|
|
80
|
-
onChangeCommitted =
|
|
81
|
-
|
|
82
|
-
minMaxDots =
|
|
83
|
-
|
|
84
|
-
minMaxValues =
|
|
85
|
-
|
|
86
|
-
step =
|
|
87
|
-
disabled =
|
|
88
|
-
ariaLabelledby =
|
|
89
|
-
ariaLabelledbyNative =
|
|
90
|
-
rest = _objectWithoutProperties(
|
|
74
|
+
var Slider = /*#__PURE__*/forwardRef(function Slider(_ref3, ref) {
|
|
75
|
+
var _ref3$min = _ref3.min,
|
|
76
|
+
min = _ref3$min === void 0 ? 0 : _ref3$min,
|
|
77
|
+
_ref3$max = _ref3.max,
|
|
78
|
+
max = _ref3$max === void 0 ? 100 : _ref3$max,
|
|
79
|
+
_ref3$value = _ref3.value,
|
|
80
|
+
value = _ref3$value === void 0 ? [40, 60] : _ref3$value,
|
|
81
|
+
outputFunction = _ref3.outputFunction,
|
|
82
|
+
onChange = _ref3.onChange,
|
|
83
|
+
onChangeCommitted = _ref3.onChangeCommitted,
|
|
84
|
+
_ref3$minMaxDots = _ref3.minMaxDots,
|
|
85
|
+
minMaxDots = _ref3$minMaxDots === void 0 ? true : _ref3$minMaxDots,
|
|
86
|
+
_ref3$minMaxValues = _ref3.minMaxValues,
|
|
87
|
+
minMaxValues = _ref3$minMaxValues === void 0 ? true : _ref3$minMaxValues,
|
|
88
|
+
_ref3$step = _ref3.step,
|
|
89
|
+
step = _ref3$step === void 0 ? 1 : _ref3$step,
|
|
90
|
+
disabled = _ref3.disabled,
|
|
91
|
+
ariaLabelledby = _ref3.ariaLabelledby,
|
|
92
|
+
ariaLabelledbyNative = _ref3['aria-labelledby'],
|
|
93
|
+
rest = _objectWithoutProperties(_ref3, _excluded);
|
|
91
94
|
var isRangeSlider = Array.isArray(value);
|
|
92
95
|
var parsedValue = isRangeSlider ? value : [value];
|
|
93
96
|
var _useState = useState(parsedValue),
|
|
@@ -98,6 +101,10 @@ var Slider = /*#__PURE__*/forwardRef(function Slider(_ref10, ref) {
|
|
|
98
101
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
99
102
|
sliderValue = _useState4[0],
|
|
100
103
|
setSliderValue = _useState4[1];
|
|
104
|
+
var _useState5 = useState(false),
|
|
105
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
106
|
+
mousePressed = _useState6[0],
|
|
107
|
+
setMousePressed = _useState6[1];
|
|
101
108
|
useEffect(function () {
|
|
102
109
|
if (isRangeSlider) {
|
|
103
110
|
if (value[0] !== initalValue[0] || value[1] !== initalValue[1]) {
|
|
@@ -118,6 +125,18 @@ var Slider = /*#__PURE__*/forwardRef(function Slider(_ref10, ref) {
|
|
|
118
125
|
if (isRangeSlider) {
|
|
119
126
|
var _newValue = sliderValue.slice();
|
|
120
127
|
_newValue[valueArrIdx] = changedValue;
|
|
128
|
+
|
|
129
|
+
//Prevent min/max values from crossing eachother
|
|
130
|
+
if (valueArrIdx === 0 && _newValue[0] >= _newValue[1]) {
|
|
131
|
+
var _maxRange$current;
|
|
132
|
+
_newValue[0] = _newValue[1];
|
|
133
|
+
(_maxRange$current = maxRange.current) === null || _maxRange$current === void 0 ? void 0 : _maxRange$current.focus();
|
|
134
|
+
}
|
|
135
|
+
if (valueArrIdx === 1 && _newValue[1] <= _newValue[0]) {
|
|
136
|
+
var _minRange$current;
|
|
137
|
+
_newValue[1] = _newValue[0];
|
|
138
|
+
(_minRange$current = minRange.current) === null || _minRange$current === void 0 ? void 0 : _minRange$current.focus();
|
|
139
|
+
}
|
|
121
140
|
setSliderValue(_newValue);
|
|
122
141
|
if (onChange) {
|
|
123
142
|
// Callback for provided onChange func
|
|
@@ -146,18 +165,18 @@ var Slider = /*#__PURE__*/forwardRef(function Slider(_ref10, ref) {
|
|
|
146
165
|
};
|
|
147
166
|
var findClosestRange = function findClosestRange(event) {
|
|
148
167
|
var target = event.target;
|
|
149
|
-
if (target.type === 'output') {
|
|
168
|
+
if (target.type === 'output' || mousePressed) {
|
|
150
169
|
return;
|
|
151
170
|
}
|
|
152
171
|
var bounds = target.getBoundingClientRect();
|
|
153
172
|
var x = event.clientX - bounds.left;
|
|
154
173
|
var inputWidth = minRange.current.offsetWidth;
|
|
155
|
-
var minValue = minRange.current.value;
|
|
156
|
-
var maxValue = maxRange.current.value;
|
|
174
|
+
var minValue = parseFloat(minRange.current.value);
|
|
175
|
+
var maxValue = parseFloat(maxRange.current.value);
|
|
157
176
|
var diff = max - min;
|
|
158
177
|
var normX = x / inputWidth * diff + min;
|
|
159
|
-
var maxX = Math.abs(normX -
|
|
160
|
-
var minX = Math.abs(normX -
|
|
178
|
+
var maxX = Math.abs(normX - maxValue);
|
|
179
|
+
var minX = Math.abs(normX - minValue);
|
|
161
180
|
if (minX > maxX) {
|
|
162
181
|
minRange.current.style.zIndex = '10';
|
|
163
182
|
maxRange.current.style.zIndex = '20';
|
|
@@ -165,6 +184,22 @@ var Slider = /*#__PURE__*/forwardRef(function Slider(_ref10, ref) {
|
|
|
165
184
|
minRange.current.style.zIndex = '20';
|
|
166
185
|
maxRange.current.style.zIndex = '10';
|
|
167
186
|
}
|
|
187
|
+
//special cases where both thumbs are all the way to the left or right
|
|
188
|
+
if (minValue === maxValue && minValue === min) {
|
|
189
|
+
minRange.current.style.zIndex = '10';
|
|
190
|
+
maxRange.current.style.zIndex = '20';
|
|
191
|
+
}
|
|
192
|
+
if (minValue === maxValue && maxValue === max) {
|
|
193
|
+
minRange.current.style.zIndex = '20';
|
|
194
|
+
maxRange.current.style.zIndex = '10';
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
var handleDragging = function handleDragging(e) {
|
|
198
|
+
if (e.type === 'mousedown') {
|
|
199
|
+
setMousePressed(true);
|
|
200
|
+
} else {
|
|
201
|
+
setMousePressed(false);
|
|
202
|
+
}
|
|
168
203
|
};
|
|
169
204
|
var inputIdA = useId(null, 'inputA');
|
|
170
205
|
var inputIdB = useId(null, 'inputB');
|
|
@@ -187,10 +222,12 @@ var Slider = /*#__PURE__*/forwardRef(function Slider(_ref10, ref) {
|
|
|
187
222
|
"aria-labelledby": getAriaLabelledby(),
|
|
188
223
|
valA: sliderValue[0],
|
|
189
224
|
valB: sliderValue[1],
|
|
190
|
-
max: max,
|
|
191
|
-
min: min,
|
|
225
|
+
$max: max,
|
|
226
|
+
$min: min,
|
|
192
227
|
disabled: disabled,
|
|
193
228
|
onMouseMove: findClosestRange,
|
|
229
|
+
onMouseDown: handleDragging,
|
|
230
|
+
onMouseUp: handleDragging,
|
|
194
231
|
children: [minMaxDots && /*#__PURE__*/jsx(WrapperGroupLabelDots, {}), /*#__PURE__*/jsx(SrOnlyLabel, {
|
|
195
232
|
htmlFor: inputIdA,
|
|
196
233
|
children: "Value A"
|
|
@@ -256,8 +293,8 @@ var Slider = /*#__PURE__*/forwardRef(function Slider(_ref10, ref) {
|
|
|
256
293
|
})]
|
|
257
294
|
})) : /*#__PURE__*/jsxs(Wrapper, _objectSpread(_objectSpread({}, rest), {}, {
|
|
258
295
|
ref: ref,
|
|
259
|
-
max: max,
|
|
260
|
-
min: min,
|
|
296
|
+
$max: max,
|
|
297
|
+
$min: min,
|
|
261
298
|
value: sliderValue[0],
|
|
262
299
|
disabled: disabled,
|
|
263
300
|
children: [/*#__PURE__*/jsx(SliderInput, {
|
|
@@ -5,7 +5,12 @@ export type AccordionItemProps = {
|
|
|
5
5
|
accordionId?: string;
|
|
6
6
|
/** Is AccordionItem expanded */
|
|
7
7
|
isExpanded?: boolean;
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Callback fired with expanded state change.
|
|
10
|
+
* When this prop is present, the accordion is in controlled state
|
|
11
|
+
*/
|
|
12
|
+
onExpandedChange?: (isExpanded: boolean) => void;
|
|
13
|
+
/** Accordion item is disabled */
|
|
9
14
|
disabled?: boolean;
|
|
10
15
|
} & HTMLAttributes<HTMLDivElement> & AccordionProps;
|
|
11
16
|
declare const AccordionItem: import("react").ForwardRefExoticComponent<{
|
|
@@ -13,7 +18,12 @@ declare const AccordionItem: import("react").ForwardRefExoticComponent<{
|
|
|
13
18
|
accordionId?: string;
|
|
14
19
|
/** Is AccordionItem expanded */
|
|
15
20
|
isExpanded?: boolean;
|
|
16
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Callback fired with expanded state change.
|
|
23
|
+
* When this prop is present, the accordion is in controlled state
|
|
24
|
+
*/
|
|
25
|
+
onExpandedChange?: (isExpanded: boolean) => void;
|
|
26
|
+
/** Accordion item is disabled */
|
|
17
27
|
disabled?: boolean;
|
|
18
28
|
} & HTMLAttributes<HTMLDivElement> & AccordionProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
19
29
|
export { AccordionItem };
|