@jobber/components 4.58.5 → 4.59.1-st-spike-w.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/AnimatedSwitcher/index.js +5 -13
- package/dist/{AnimatedSwitcher-d1e1ddcf.js → AnimatedSwitcher-6ffd5003.js} +9 -15
- package/dist/Autocomplete/index.js +57 -68
- package/dist/Avatar/index.js +7 -15
- package/dist/{Avatar-1aa30ee1.js → Avatar-b2e862de.js} +13 -21
- package/dist/Banner/index.js +29 -38
- package/dist/Button/index.js +8 -16
- package/dist/{Button-db6114a6.js → Button-319d8fa0.js} +15 -22
- package/dist/ButtonDismiss/index.js +9 -17
- package/dist/ButtonDismiss-85986110.js +8 -0
- package/dist/Card/index.js +15 -23
- package/dist/{Card-116af709.js → Card-c1970a7c.js} +27 -34
- package/dist/Checkbox/index.js +11 -19
- package/dist/{Checkbox-bc4bc968.js → Checkbox-e4733fb4.js} +30 -37
- package/dist/Chip/index.js +24 -33
- package/dist/{Chip-4f12eec8.js → Chip-12a64c38.js} +94 -106
- package/dist/{Chip-f8b8fd89.js → Chip-40f5214c.js} +29 -37
- package/dist/Chips/index.js +25 -34
- package/dist/Combobox/Combobox.d.ts +3 -8
- package/dist/Combobox/Combobox.types.d.ts +71 -44
- package/dist/Combobox/ComboboxProvider.d.ts +12 -4
- package/dist/Combobox/components/ComboboxActivator/ComboboxActivator.d.ts +1 -4
- package/dist/Combobox/components/ComboboxOption/ComboboxOption.d.ts +6 -2
- package/dist/Combobox/components/ComboboxTrigger/ComboboxTrigger.d.ts +2 -6
- package/dist/Combobox/components/ComboboxTrigger/index.d.ts +0 -2
- package/dist/Combobox/hooks/useCombobox.d.ts +15 -0
- package/dist/Combobox/hooks/useComboboxAccessibility.d.ts +1 -1
- package/dist/Combobox/hooks/useComboboxContent.d.ts +1 -6
- package/dist/Combobox/hooks/useComboboxValidation.d.ts +11 -9
- package/dist/Combobox/hooks/useMakeComboboxHandlers.d.ts +7 -0
- package/dist/Combobox/index.js +219 -247
- package/dist/ConfirmationModal/index.js +22 -30
- package/dist/{ConfirmationModal-285c3cbe.js → ConfirmationModal-86b42ca0.js} +14 -20
- package/dist/Content/index.js +4 -12
- package/dist/{Content-2ca1ffe1.js → Content-3354c281.js} +8 -14
- package/dist/Countdown/index.js +8 -17
- package/dist/DataDump/index.js +24 -32
- package/dist/DataList/index.js +256 -268
- package/dist/DataTable/index.js +92 -123
- package/dist/DatePicker/index.js +12 -20
- package/dist/{DatePicker-49213434.js → DatePicker-9f1e19a5.js} +30 -39
- package/dist/DescriptionList/index.js +9 -17
- package/dist/Disclosure/index.js +21 -29
- package/dist/Divider/index.js +7 -16
- package/dist/Drawer/index.js +24 -34
- package/dist/Emphasis/index.js +5 -13
- package/dist/Emphasis-edd2af9b.js +13 -0
- package/dist/FeatureSwitch/index.js +39 -48
- package/dist/Flex/index.js +6 -15
- package/dist/Form/index.js +11 -19
- package/dist/FormField/index.js +16 -24
- package/dist/{FormField-fa9254dc.js → FormField-99918ed4.js} +58 -65
- package/dist/FormatDate/index.js +2 -11
- package/dist/{FormatDate-70ea5b43.js → FormatDate-720b39cf.js} +3 -10
- package/dist/FormatEmail/index.js +7 -16
- package/dist/FormatFile/index.js +27 -35
- package/dist/{FormatFile-6423c3b5.js → FormatFile-e1498cb9.js} +44 -52
- package/dist/FormatRelativeDateTime/index.js +7 -15
- package/dist/FormatTime/index.js +3 -11
- package/dist/Gallery/index.js +40 -49
- package/dist/Glimmer/index.js +6 -15
- package/dist/{Glimmer-cfa92a88.js → Glimmer-d3be9219.js} +25 -33
- package/dist/Grid/index.js +14 -24
- package/dist/Heading/index.js +5 -13
- package/dist/{Heading-4cde9989.js → Heading-04994667.js} +4 -10
- package/dist/Icon/index.js +3 -11
- package/dist/Icon-22723fe6.js +34 -0
- package/dist/InlineLabel/index.js +5 -13
- package/dist/{InlineLabel-a24706c4.js → InlineLabel-4df86867.js} +9 -16
- package/dist/InputAvatar/index.js +32 -40
- package/dist/InputDate/index.js +26 -35
- package/dist/InputEmail/index.js +18 -27
- package/dist/InputFile/index.js +14 -23
- package/dist/{InputFile-25c3369b.js → InputFile-3bbaa09e.js} +24 -33
- package/dist/InputGroup/index.js +4 -12
- package/dist/{InputGroup-3fdde16b.js → InputGroup-1b4abd36.js} +9 -16
- package/dist/InputNumber/index.js +17 -25
- package/dist/{InputNumber-ea9fcee1.js → InputNumber-fa8132f3.js} +7 -13
- package/dist/InputPassword/index.js +19 -27
- package/dist/InputPhoneNumber/index.js +28 -36
- package/dist/InputText/index.js +17 -25
- package/dist/{InputText-ab237501.js → InputText-6d262128.js} +9 -15
- package/dist/InputTime/index.js +29 -38
- package/dist/InputValidation/index.js +9 -17
- package/dist/InputValidation-b6adff05.js +23 -0
- package/dist/LightBox/index.js +16 -24
- package/dist/LightBox-8c8f30b1.js +109 -0
- package/dist/Link/index.js +3 -11
- package/dist/List/index.js +47 -59
- package/dist/Markdown/index.js +10 -18
- package/dist/Markdown-2ec28e51.js +55 -0
- package/dist/Menu/index.js +13 -21
- package/dist/{Menu-2e64307a.js → Menu-10681184.js} +40 -47
- package/dist/Modal/index.js +16 -24
- package/dist/{Modal-c17cc105.js → Modal-06dc9551.js} +33 -41
- package/dist/MultiSelect/index.js +38 -47
- package/dist/Option-7967170c.js +12 -0
- package/dist/Page/index.js +48 -57
- package/dist/Popover/index.js +12 -20
- package/dist/{Popover-7c966790.js → Popover-a93db92d.js} +15 -21
- package/dist/ProgressBar/index.js +4 -12
- package/dist/{ProgressBar-5dfc1885.js → ProgressBar-04ee007d.js} +8 -15
- package/dist/RadioGroup/index.js +7 -16
- package/dist/{RadioGroup-9bdd8a59.js → RadioGroup-2ccd0678.js} +16 -23
- package/dist/RecurringSelect/index.js +90 -98
- package/dist/Select/index.js +17 -26
- package/dist/Spinner/index.js +4 -12
- package/dist/{Spinner-9d8fc7ff.js → Spinner-5d8359b8.js} +7 -14
- package/dist/StatusLabel/index.js +12 -21
- package/dist/Switch/index.js +5 -13
- package/dist/{Switch-cc9b645c.js → Switch-8bee06df.js} +17 -24
- package/dist/Table/index.js +19 -35
- package/dist/Tabs/index.js +23 -33
- package/dist/Text/index.js +5 -13
- package/dist/{Text-54334431.js → Text-703e2c21.js} +4 -10
- package/dist/Toast/index.js +32 -40
- package/dist/Tooltip/index.js +7 -15
- package/dist/{Tooltip-6b12f1c2.js → Tooltip-c80b9fb7.js} +22 -30
- package/dist/Typography/index.js +4 -12
- package/dist/{Typography-83915c54.js → Typography-09952a2f.js} +15 -22
- package/dist/{style-inject.es-9d2f5f4e.js → style-inject.es-a0e1a0ba.js} +1 -3
- package/dist/{tslib.es6-5b8768b7.js → tslib.es6-5849cd88.js} +1 -4
- package/package.json +3 -3
- package/rollup.config.js +1 -1
- package/dist/ButtonDismiss-1ccb84ec.js +0 -14
- package/dist/Combobox/components/ComboboxTrigger/ComboboxTriggerButton/ComboboxTriggerButton.d.ts +0 -3
- package/dist/Combobox/components/ComboboxTrigger/ComboboxTriggerChip/ComboboxTriggerChip.d.ts +0 -3
- package/dist/Emphasis-e10dde65.js +0 -19
- package/dist/Icon-405a216c.js +0 -40
- package/dist/InputValidation-377d6c62.js +0 -29
- package/dist/LightBox-93ef99b9.js +0 -117
- package/dist/Markdown-d53b01bf.js +0 -62
- package/dist/Option-07a24acd.js +0 -19
|
@@ -1,37 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var Button = require('./Button-db6114a6.js');
|
|
18
|
-
var Spinner = require('./Spinner-9d8fc7ff.js');
|
|
19
|
-
|
|
20
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
|
-
|
|
22
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
23
|
-
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
24
|
-
var sortBy__default = /*#__PURE__*/_interopDefaultLegacy(sortBy);
|
|
25
|
-
var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
|
|
1
|
+
import React, { useRef, useState, useEffect } from 'react';
|
|
2
|
+
import { v1 } from 'uuid';
|
|
3
|
+
import { s as styleInject } from './style-inject.es-a0e1a0ba.js';
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
import { useAssert } from '@jobber/hooks/useAssert';
|
|
6
|
+
import { I as Icon } from './Icon-22723fe6.js';
|
|
7
|
+
import { A as Avatar } from './Avatar-b2e862de.js';
|
|
8
|
+
import { T as Typography } from './Typography-09952a2f.js';
|
|
9
|
+
import { T as Tooltip } from './Tooltip-c80b9fb7.js';
|
|
10
|
+
import sortBy from 'lodash/sortBy';
|
|
11
|
+
import { useLiveAnnounce } from '@jobber/hooks/useLiveAnnounce';
|
|
12
|
+
import debounce from 'lodash/debounce';
|
|
13
|
+
import { usePopper } from 'react-popper';
|
|
14
|
+
import { T as Text } from './Text-703e2c21.js';
|
|
15
|
+
import { B as Button } from './Button-319d8fa0.js';
|
|
16
|
+
import { S as Spinner } from './Spinner-5d8359b8.js';
|
|
26
17
|
|
|
27
18
|
var css_248z$1 = "/**\n * Used in the wrapping chips component:\n * - InternalChipSingleSelect\n * - InternalChipMultiSelect\n */\n\n.zn6onyiQVmA- {\n display: -ms-flexbox;\n display: flex;\n gap: calc(16px / 2);\n gap: var(--space-small);\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n -ms-flex-align: center;\n align-items: center;\n}\n\n.PEnZzMEgbhU- {\n display: inline-grid;\n position: relative;\n max-width: 100%;\n box-sizing: border-box;\n padding: calc(16px / 2);\n padding: var(--space-small);\n border: calc(16px / 16) solid rgb(225, 225, 225);\n border: var(--border-base) solid var(--color-border);\n border-radius: calc(16px / 2);\n border-radius: var(--radius-larger);\n color: rgba(101, 120, 132, 1);\n color: var(--color-text--secondary);\n text-align: left;\n vertical-align: middle;\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n transition: 200ms ease-in-out;\n transition: var(--timing-base) ease-in-out;\n transition-property: background-color, box-shadow, color;\n grid-template-columns: -webkit-max-content;\n grid-template-columns: max-content;\n -ms-flex-align: center;\n align-items: center;\n gap: calc(16px / 2);\n gap: var(--space-small);\n}\n\n.dtysUhwYdG4-,\n.xGaMCAYsdwA- {\n padding: calc((16px / 4) + (16px / 8)) calc(16px / 2);\n padding: calc(calc(16px / 4) + calc(16px / 8)) calc(16px / 2);\n padding: calc(var(--space-smaller) + var(--space-smallest)) var(--space-small);\n}\n\n.dtysUhwYdG4- {\n grid-template-columns: -webkit-min-content 1fr;\n grid-template-columns: min-content 1fr;\n}\n\n.xGaMCAYsdwA- {\n grid-template-columns: 1fr -webkit-min-content;\n grid-template-columns: 1fr min-content;\n}\n\n.dtysUhwYdG4-.xGaMCAYsdwA- {\n grid-template-columns: -webkit-min-content 1fr -webkit-min-content;\n grid-template-columns: min-content 1fr min-content;\n}\n\n.SNT7gGV-h-o-,\n.W4D98cvEth4- ~ .PEnZzMEgbhU- {\n box-shadow: 0px calc(16px / 16) calc(16px / 4) 0px\n rgba(0, 0, 0, 0.1),\n 0px calc(16px / 4) 12px 0px rgba(0, 0, 0, 0.05);\n box-shadow: var(--shadow-base);\n cursor: pointer;\n -webkit-appearance: none;\n appearance: none;\n}\n\n/**\n * Interaction\n */\n\n.PEnZzMEgbhU-:focus,\n.W4D98cvEth4-:focus ~ .PEnZzMEgbhU- {\n box-shadow: 0px 0px calc(16px / 4) calc(16px / 8)\n rgb(231, 213, 87);\n box-shadow: var(--shadow-focus);\n outline: none;\n}\n\n.SNT7gGV-h-o-:hover,\n.W4D98cvEth4- ~ .PEnZzMEgbhU-:not(._0hEzaTXK9M0-):hover,\n.W4D98cvEth4-:focus ~ .PEnZzMEgbhU-:not(._0hEzaTXK9M0-) {\n background-color: rgb(250, 246, 219);\n background-color: var(--color-surface--hover);\n}\n\n/**\n * States\n */\n\n.PEnZzMEgbhU-._0hEzaTXK9M0- {\n border-color: rgb(1, 41, 57);\n border-color: var(--color-surface--reverse);\n color: rgba(255, 255, 255, 1);\n color: var(--color-text--reverse);\n background-color: rgb(1, 41, 57);\n background-color: var(--color-surface--reverse);\n}\n\n.PEnZzMEgbhU-.JApS2787BU8- {\n border-color: rgb(128, 25, 0);\n border-color: var(--color-critical--onSurface);\n color: rgb(128, 25, 0);\n color: var(--color-critical--onSurface);\n background-color: rgb(255, 226, 219);\n background-color: var(--color-critical--surface);\n}\n\n.PEnZzMEgbhU-.Kg0c8WVgMpg- {\n border-color: rgb(225, 225, 225);\n border-color: var(--color-disabled--secondary);\n color: rgb(181, 181, 181);\n color: var(--color-disabled);\n background-color: rgb(225, 225, 225);\n background-color: var(--color-disabled--secondary);\n}\n\n._0hEzaTXK9M0-.Kg0c8WVgMpg- {\n border-color: rgb(181, 181, 181);\n border-color: var(--color-disabled);\n color: rgba(255, 255, 255, 1);\n color: var(--color-white);\n background-color: rgb(181, 181, 181);\n background-color: var(--color-disabled);\n}\n\n.JApS2787BU8-.Kg0c8WVgMpg- {\n border-color: rgb(201, 66, 33);\n border-color: var(--color-critical);\n}\n\n/**\n * Input checkbox/radio\n *\n * Hide checkbox on UI but not screen readers and still allow focus state\n */\n\n.W4D98cvEth4- {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip: rect(0 0 0 0);\n -webkit-clip-path: inset(100%);\n clip-path: inset(100%);\n white-space: nowrap;\n}\n\n/**\n * Button\n */\n\n._0-ZWexS4Gfg- {\n display: -ms-flexbox;\n display: flex;\n border-radius: calc(16px / 8);\n border-radius: var(--radius-base);\n cursor: pointer;\n transition: background-color 200ms ease;\n}\n\n._0-ZWexS4Gfg-:hover,\n._0-ZWexS4Gfg-:focus {\n background-color: rgb(250, 246, 219);\n background-color: var(--color-surface--hover);\n}\n\n._0-ZWexS4Gfg-:focus,\n.SNT7gGV-h-o- ._0-ZWexS4Gfg-:hover {\n box-shadow: 0px 0px calc(16px / 4) calc(16px / 8)\n rgb(231, 213, 87);\n box-shadow: var(--shadow-focus);\n outline: none;\n}\n\n/**\n * Override icon default colors.\n *\n * NOTE: This is a workaround since some icons have default colors that we don't\n * want to override until the component color prop overrides it.\n * DO NOT COPY!\n */\n\n.DQPnZP4UZpw- > svg {\n fill: rgba(101, 120, 132, 1);\n fill: var(--color-interactive--subtle);\n}\n\n.DQPnZP4UZpw- {\n display: -ms-flexbox;\n display: flex;\n}\n";
|
|
28
19
|
var styles$1 = {"wrapper":"zn6onyiQVmA-","chip":"PEnZzMEgbhU-","hasPrefix":"dtysUhwYdG4-","hasSuffix":"xGaMCAYsdwA-","clickable":"SNT7gGV-h-o-","input":"W4D98cvEth4-","active":"_0hEzaTXK9M0-","invalid":"JApS2787BU8-","disabled":"Kg0c8WVgMpg-","button":"_0-ZWexS4Gfg-","icon":"DQPnZP4UZpw-"};
|
|
29
|
-
|
|
20
|
+
styleInject(css_248z$1);
|
|
30
21
|
|
|
31
22
|
function InternalChipButton({ icon, invalid, disabled, label, onClick, }) {
|
|
32
|
-
const buttonRef =
|
|
33
|
-
return (
|
|
34
|
-
|
|
23
|
+
const buttonRef = useRef();
|
|
24
|
+
return (React.createElement("div", { ref: buttonRef, className: styles$1.button, tabIndex: 0, onKeyUp: handleKeyUp, onKeyDown: handleKeyDown, onClick: handleClick, role: "button", "aria-label": `Remove ${label}`, "aria-hidden": true, "aria-disabled": disabled, "data-testid": "remove-chip-button" },
|
|
25
|
+
React.createElement(Icon, { name: icon, color: getColor() })));
|
|
35
26
|
function handleKeyUp(event) {
|
|
36
27
|
if (document.activeElement === buttonRef.current &&
|
|
37
28
|
(event.key === " " || event.key === "Enter")) {
|
|
@@ -60,19 +51,19 @@ function InternalChipButton({ icon, invalid, disabled, label, onClick, }) {
|
|
|
60
51
|
|
|
61
52
|
function InternalChipAffix({ affix, active, invalid, disabled, }) {
|
|
62
53
|
assertProps();
|
|
63
|
-
if ((affix === null || affix === void 0 ? void 0 : affix.type) === Avatar
|
|
64
|
-
return
|
|
54
|
+
if ((affix === null || affix === void 0 ? void 0 : affix.type) === Avatar) {
|
|
55
|
+
return React.createElement(Avatar, Object.assign({}, affix.props, { size: "small" }));
|
|
65
56
|
}
|
|
66
|
-
if ((affix === null || affix === void 0 ? void 0 : affix.type) === Icon
|
|
57
|
+
if ((affix === null || affix === void 0 ? void 0 : affix.type) === Icon) {
|
|
67
58
|
return renderChipIcon(affix);
|
|
68
59
|
}
|
|
69
60
|
if ((affix === null || affix === void 0 ? void 0 : affix.type) === InternalChipButton) {
|
|
70
|
-
return
|
|
61
|
+
return React.createElement(InternalChipButton, Object.assign({}, affix.props));
|
|
71
62
|
}
|
|
72
|
-
return
|
|
63
|
+
return React.createElement(React.Fragment, null);
|
|
73
64
|
function renderChipIcon(icon) {
|
|
74
65
|
const color = getIconColor();
|
|
75
|
-
return (
|
|
66
|
+
return (React.createElement("div", { className: styles$1.icon }, React.cloneElement(icon, Object.assign({ size: "base" }, (color && { color: color })))));
|
|
76
67
|
}
|
|
77
68
|
function getIconColor() {
|
|
78
69
|
if (disabled && !active)
|
|
@@ -84,17 +75,17 @@ function InternalChipAffix({ affix, active, invalid, disabled, }) {
|
|
|
84
75
|
return;
|
|
85
76
|
}
|
|
86
77
|
function assertProps() {
|
|
87
|
-
const isAvatar = (affix === null || affix === void 0 ? void 0 : affix.type) === Avatar
|
|
88
|
-
const isIcon = (affix === null || affix === void 0 ? void 0 : affix.type) === Icon
|
|
78
|
+
const isAvatar = (affix === null || affix === void 0 ? void 0 : affix.type) === Avatar || false;
|
|
79
|
+
const isIcon = (affix === null || affix === void 0 ? void 0 : affix.type) === Icon || false;
|
|
89
80
|
const isChipButton = (affix === null || affix === void 0 ? void 0 : affix.type) === InternalChipButton || false;
|
|
90
|
-
useAssert
|
|
81
|
+
useAssert(!!affix && !(isAvatar || isIcon || isChipButton), `Prefix prop only accepts "<Avatar />" or "<Icon />" component. You have "${affix === null || affix === void 0 ? void 0 : affix.type}".`);
|
|
91
82
|
}
|
|
92
83
|
}
|
|
93
84
|
|
|
94
85
|
function InternalChip({ label, active = false, disabled = false, invalid = false, prefix, suffix, tabIndex, ariaLabel, onClick, onKeyDown, }) {
|
|
95
|
-
const [truncateRef, setTruncateRef] =
|
|
86
|
+
const [truncateRef, setTruncateRef] = useState();
|
|
96
87
|
const isClickable = onClick && !disabled;
|
|
97
|
-
const classNames =
|
|
88
|
+
const classNames = classnames(styles$1.chip, {
|
|
98
89
|
[styles$1.clickable]: isClickable,
|
|
99
90
|
[styles$1.active]: active,
|
|
100
91
|
[styles$1.disabled]: disabled,
|
|
@@ -104,12 +95,12 @@ function InternalChip({ label, active = false, disabled = false, invalid = false
|
|
|
104
95
|
});
|
|
105
96
|
const affixProps = { active, invalid, disabled };
|
|
106
97
|
const Tag = onClick ? "button" : "div";
|
|
107
|
-
const chip = (
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return isTruncated() ?
|
|
98
|
+
const chip = (React.createElement(Tag, Object.assign({ className: classNames }, (isClickable && { onClick, disabled }), { onKeyDown: onKeyDown, "data-testid": "chip-wrapper", "aria-label": ariaLabel, tabIndex: tabIndex, role: tabIndex !== undefined ? "option" : undefined }),
|
|
99
|
+
React.createElement(InternalChipAffix, Object.assign({ affix: prefix }, affixProps)),
|
|
100
|
+
React.createElement(Typography, { element: "span", numberOfLines: 1, size: "base" },
|
|
101
|
+
React.createElement("span", { ref: setTruncateRef }, label)),
|
|
102
|
+
React.createElement(InternalChipAffix, Object.assign({ affix: suffix }, affixProps))));
|
|
103
|
+
return isTruncated() ? React.createElement(Tooltip, { message: label }, chip) : chip;
|
|
113
104
|
function isTruncated() {
|
|
114
105
|
var _a;
|
|
115
106
|
const truncateParentHeight = ((_a = truncateRef === null || truncateRef === void 0 ? void 0 : truncateRef.parentElement) === null || _a === void 0 ? void 0 : _a.offsetHeight) || 0;
|
|
@@ -118,14 +109,14 @@ function InternalChip({ label, active = false, disabled = false, invalid = false
|
|
|
118
109
|
}
|
|
119
110
|
}
|
|
120
111
|
|
|
121
|
-
function InternalChipSingleSelect({ children, selected, name =
|
|
122
|
-
return (
|
|
112
|
+
function InternalChipSingleSelect({ children, selected, name = v1(), onChange, onClick, }) {
|
|
113
|
+
return (React.createElement("div", { className: styles$1.wrapper, "data-testid": "singleselect-chips" }, React.Children.map(children, child => {
|
|
123
114
|
const isSelected = child.props.value === selected;
|
|
124
|
-
return (
|
|
125
|
-
|
|
115
|
+
return (React.createElement("label", null,
|
|
116
|
+
React.createElement("input", { type: "radio", checked: isSelected, className: styles$1.input, name: name, onClick: handleClick(child.props.value), onKeyUp: handleKeyUp(isSelected, child.props.value), onChange: () => {
|
|
126
117
|
/* No op. onClick handles the change to allow deselecting. */
|
|
127
118
|
}, disabled: child.props.disabled }),
|
|
128
|
-
|
|
119
|
+
React.createElement(InternalChip, Object.assign({}, child.props, { active: isSelected }))));
|
|
129
120
|
})));
|
|
130
121
|
function handleKeyUp(active, value) {
|
|
131
122
|
if (!active)
|
|
@@ -150,11 +141,11 @@ function InternalChipSingleSelect({ children, selected, name = uuid.v1(), onChan
|
|
|
150
141
|
}
|
|
151
142
|
|
|
152
143
|
function InternalChipMultiSelect({ children, selected, onChange, onClick, }) {
|
|
153
|
-
return (
|
|
144
|
+
return (React.createElement("div", { className: styles$1.wrapper, "data-testid": "multiselect-chips" }, React.Children.map(children, chip => {
|
|
154
145
|
const isChipActive = isChipSelected(chip.props.value);
|
|
155
|
-
return (
|
|
156
|
-
|
|
157
|
-
|
|
146
|
+
return (React.createElement("label", null,
|
|
147
|
+
React.createElement("input", { type: "checkbox", checked: isChipActive, className: styles$1.input, onClick: handleClick(chip.props.value), onChange: handleChange(chip.props.value), disabled: chip.props.disabled }),
|
|
148
|
+
React.createElement(InternalChip, Object.assign({}, chip.props, { active: isChipActive, suffix: checkmarkIcon(isChipActive) }))));
|
|
158
149
|
})));
|
|
159
150
|
function isChipSelected(value) {
|
|
160
151
|
return selected.includes(value);
|
|
@@ -189,21 +180,21 @@ function InternalChipMultiSelect({ children, selected, onChange, onClick, }) {
|
|
|
189
180
|
// DO NOT COPY!
|
|
190
181
|
if (!show)
|
|
191
182
|
return;
|
|
192
|
-
return
|
|
183
|
+
return React.createElement(Icon, { name: "checkmark" });
|
|
193
184
|
}
|
|
194
185
|
}
|
|
195
186
|
|
|
196
187
|
var css_248z = ".sCNIjluCskc- {\n display: -ms-flexbox;\n display: flex;\n position: relative;\n box-sizing: border-box;\n border: calc(16px / 16) solid transparent;\n border: var(--border-base) solid transparent;\n border-radius: calc(16px / 8);\n border-radius: var(--radius-base);\n transition: all 200ms;\n transition: all var(--timing-base);\n gap: calc(16px / 2);\n gap: var(--space-small);\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n -ms-flex-align: center;\n align-items: center;\n}\n\n.MFUlz1WQLdk- {\n -ms-flex: 1;\n flex: 1;\n min-width: 120px;\n padding: calc(16px / 2) 0;\n padding: var(--space-small) 0;\n border: none;\n border-radius: 0;\n color: inherit;\n font-family: inherit;\n font-size: inherit;\n font-size: calc(calc(16px * 1) * 0.875);\n font-size: var(--typography--fontSize-base);\n line-height: 1.25;\n line-height: var(--typography--lineHeight-base);\n background: transparent;\n -webkit-appearance: none;\n appearance: none;\n}\n\n.MFUlz1WQLdk-:focus {\n outline: none;\n}\n\n.V9eYJdjPAeY- {\n position: relative;\n z-index: 6;\n z-index: var(--elevation-menu);\n width: 100%;\n}\n\n.LdytkOeCU9c- {\n max-height: 320px;\n box-shadow: 0px calc(16px / 16) calc(16px / 4) 0px\n rgba(0, 0, 0, 0.1),\n 0px calc(16px / 4) 12px 0px rgba(0, 0, 0, 0.05);\n box-shadow: var(--shadow-base);\n padding: calc(16px / 2) 0;\n padding: var(--space-small) 0;\n border-radius: calc(16px / 8);\n border-radius: var(--radius-base);\n overflow-y: scroll;\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n}\n\n.y7Cz2u8BuNE-,\n._-7bmao8Q9As- {\n display: -ms-flexbox;\n display: flex;\n width: 100%;\n padding: calc(16px / 2);\n padding: var(--space-small);\n border: none;\n background-color: transparent;\n cursor: pointer;\n -webkit-appearance: none;\n appearance: none;\n -ms-flex-align: center;\n align-items: center;\n gap: calc(16px / 2);\n gap: var(--space-small);\n}\n\n.y7Cz2u8BuNE-:focus {\n box-shadow: 0px 0px calc(16px / 4) calc(16px / 8)\n rgb(231, 213, 87);\n box-shadow: var(--shadow-focus);\n}\n\n.y7Cz2u8BuNE-:focus,\n.iCwWdcmtInc- {\n outline: none;\n background-color: rgb(250, 246, 219);\n background-color: var(--color-surface--hover);\n}\n\n._-7bmao8Q9As- {\n -ms-flex-pack: center;\n justify-content: center;\n}\n";
|
|
197
188
|
var styles = {"wrapper":"sCNIjluCskc-","input":"MFUlz1WQLdk-","menu":"V9eYJdjPAeY-","menuList":"LdytkOeCU9c-","menuListOption":"y7Cz2u8BuNE-","loadingIndicator":"_-7bmao8Q9As-","activeOption":"iCwWdcmtInc-"};
|
|
198
|
-
|
|
189
|
+
styleInject(css_248z);
|
|
199
190
|
|
|
200
191
|
function useInternalChipDismissible({ children, selected, onChange, onClick, onCustomAdd, }) {
|
|
201
|
-
const ref =
|
|
192
|
+
const ref = useRef(null);
|
|
202
193
|
const chipOptions = children.map(chip => chip.props);
|
|
203
194
|
const visibleChipOptions = chipOptions.filter(chip => selected.includes(chip.value));
|
|
204
|
-
const sortedVisibleChipOptions =
|
|
195
|
+
const sortedVisibleChipOptions = sortBy(visibleChipOptions, chip => selected.indexOf(chip.value));
|
|
205
196
|
const availableChipOptions = chipOptions.filter(chip => !selected.includes(chip.value));
|
|
206
|
-
const { liveAnnounce } = useLiveAnnounce
|
|
197
|
+
const { liveAnnounce } = useLiveAnnounce();
|
|
207
198
|
const actions = {
|
|
208
199
|
handleChipRemove: (value) => {
|
|
209
200
|
return () => {
|
|
@@ -258,24 +249,24 @@ function useInternalChipDismissible({ children, selected, onChange, onClick, onC
|
|
|
258
249
|
availableChipOptions });
|
|
259
250
|
}
|
|
260
251
|
|
|
261
|
-
const menuId =
|
|
252
|
+
const menuId = v1();
|
|
262
253
|
// eslint-disable-next-line max-statements
|
|
263
254
|
function useInternalChipDismissibleInput({ options, isLoadingMore = false, onCustomOptionSelect, onOptionSelect, onSearch, }) {
|
|
264
|
-
const [allOptions, setAllOptions] =
|
|
265
|
-
const [searchValue, setSearchValue] =
|
|
266
|
-
const [menuOpen, setMenuOpen] =
|
|
267
|
-
const [activeIndex, setActiveIndex] =
|
|
268
|
-
const [shouldCancelBlur, setShouldCancelBlur] =
|
|
269
|
-
const [shouldCancelEnter, setShouldCancelEnter] =
|
|
255
|
+
const [allOptions, setAllOptions] = useState([]);
|
|
256
|
+
const [searchValue, setSearchValue] = useState("");
|
|
257
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
258
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
259
|
+
const [shouldCancelBlur, setShouldCancelBlur] = useState(false);
|
|
260
|
+
const [shouldCancelEnter, setShouldCancelEnter] = useState(false);
|
|
270
261
|
const canAddCustomOption = onCustomOptionSelect !== undefined && !isLoadingMore;
|
|
271
262
|
const maxOptionIndex = allOptions.length - 1;
|
|
272
|
-
const { liveAnnounce } = useLiveAnnounce
|
|
273
|
-
|
|
263
|
+
const { liveAnnounce } = useLiveAnnounce();
|
|
264
|
+
useEffect(() => {
|
|
274
265
|
setAllOptions(generateOptions(options, searchValue, canAddCustomOption));
|
|
275
266
|
}, [options]);
|
|
276
267
|
const computed = {
|
|
277
268
|
menuId,
|
|
278
|
-
inputRef:
|
|
269
|
+
inputRef: useRef(null),
|
|
279
270
|
activeOption: allOptions[activeIndex],
|
|
280
271
|
hasAvailableOptions: allOptions.length > 0,
|
|
281
272
|
nextOptionIndex: activeIndex < maxOptionIndex ? activeIndex + 1 : 0,
|
|
@@ -353,7 +344,7 @@ function useInternalChipDismissibleInput({ options, isLoadingMore = false, onCus
|
|
|
353
344
|
}
|
|
354
345
|
handleKeydownEvents(callbacks, event);
|
|
355
346
|
},
|
|
356
|
-
handleDebouncedSearch:
|
|
347
|
+
handleDebouncedSearch: debounce(() => {
|
|
357
348
|
onSearch && onSearch(searchValue);
|
|
358
349
|
setAllOptions(generateOptions(options, searchValue, canAddCustomOption));
|
|
359
350
|
setShouldCancelEnter(false);
|
|
@@ -386,7 +377,7 @@ function generateCustomOptionObject(searchValue) {
|
|
|
386
377
|
return {
|
|
387
378
|
value: searchValue,
|
|
388
379
|
label: searchValue,
|
|
389
|
-
prefix:
|
|
380
|
+
prefix: React.createElement(Icon, { name: "add" }),
|
|
390
381
|
custom: true,
|
|
391
382
|
};
|
|
392
383
|
}
|
|
@@ -402,13 +393,13 @@ function handleKeydownEvents(callbacks, event) {
|
|
|
402
393
|
}
|
|
403
394
|
|
|
404
395
|
function useInView() {
|
|
405
|
-
const ref =
|
|
406
|
-
const [isInView, setIsInView] =
|
|
396
|
+
const ref = useRef(null);
|
|
397
|
+
const [isInView, setIsInView] = useState(false);
|
|
407
398
|
if (window.IntersectionObserver) {
|
|
408
399
|
const observer = new IntersectionObserver(entries => {
|
|
409
400
|
setIsInView(entries[0].isIntersecting);
|
|
410
401
|
});
|
|
411
|
-
|
|
402
|
+
useEffect(() => {
|
|
412
403
|
ref.current && observer.observe(ref.current);
|
|
413
404
|
return () => {
|
|
414
405
|
if (!ref.current)
|
|
@@ -422,8 +413,8 @@ function useInView() {
|
|
|
422
413
|
|
|
423
414
|
function useRepositionMenu(attachTo) {
|
|
424
415
|
var _a;
|
|
425
|
-
const [positionElement, setPositionedElementRef] =
|
|
426
|
-
const popper =
|
|
416
|
+
const [positionElement, setPositionedElementRef] = useState();
|
|
417
|
+
const popper = usePopper(attachTo.current, positionElement, {
|
|
427
418
|
modifiers: [
|
|
428
419
|
{ name: "offset", options: { offset: [0, 8] } },
|
|
429
420
|
{ name: "flip", options: { fallbackPlacements: ["top"] } },
|
|
@@ -434,8 +425,8 @@ function useRepositionMenu(attachTo) {
|
|
|
434
425
|
}
|
|
435
426
|
|
|
436
427
|
function useScrollToActive(index) {
|
|
437
|
-
const ref =
|
|
438
|
-
|
|
428
|
+
const ref = useRef(null);
|
|
429
|
+
useEffect(() => {
|
|
439
430
|
var _a, _b;
|
|
440
431
|
if (!window.HTMLElement.prototype.scrollIntoView)
|
|
441
432
|
return;
|
|
@@ -449,54 +440,54 @@ function useScrollToActive(index) {
|
|
|
449
440
|
}
|
|
450
441
|
|
|
451
442
|
function InternalChipDismissibleInput(props) {
|
|
452
|
-
const { activator =
|
|
443
|
+
const { activator = React.createElement(Button, { icon: "add", type: "secondary", ariaLabel: "Add" }), attachTo, isLoadingMore = false, onLoadMore, } = props;
|
|
453
444
|
const { activeIndex, allOptions, hasAvailableOptions, inputRef, menuId, menuOpen, searchValue, generateDescendantId, handleBlur, handleOpenMenu, handleSearchChange, handleCancelBlur, handleEnableBlur, handleSetActiveOnMouseOver, handleKeyDown, handleSelectOption, handleDebouncedSearch, } = useInternalChipDismissibleInput(props);
|
|
454
445
|
const menuRef = useScrollToActive(activeIndex);
|
|
455
446
|
const { ref: visibleChildRef, isInView } = useInView();
|
|
456
447
|
const { styles: popperStyles, attributes, update, setPositionedElementRef, } = useRepositionMenu(attachTo);
|
|
457
|
-
|
|
448
|
+
useEffect(() => {
|
|
458
449
|
if (menuOpen && update)
|
|
459
450
|
update();
|
|
460
451
|
}, [allOptions]);
|
|
461
|
-
|
|
452
|
+
useEffect(() => {
|
|
462
453
|
handleDebouncedSearch();
|
|
463
454
|
return handleDebouncedSearch.cancel;
|
|
464
455
|
}, [searchValue]);
|
|
465
|
-
|
|
456
|
+
useEffect(() => {
|
|
466
457
|
isInView && onLoadMore && onLoadMore(searchValue);
|
|
467
458
|
}, [isInView]);
|
|
468
459
|
if (!menuOpen) {
|
|
469
|
-
return
|
|
460
|
+
return React.cloneElement(activator, { onClick: handleOpenMenu });
|
|
470
461
|
}
|
|
471
|
-
return (
|
|
472
|
-
|
|
473
|
-
(hasAvailableOptions || isLoadingMore) && (
|
|
474
|
-
|
|
475
|
-
allOptions.map((option, i) => (
|
|
462
|
+
return (React.createElement(React.Fragment, null,
|
|
463
|
+
React.createElement("input", { ref: inputRef, className: styles.input, type: "text", role: "combobox", "aria-label": "Press up and down arrow to cycle through the options or type to narrow down the results", "aria-autocomplete": "list", "aria-owns": menuId, "aria-expanded": hasAvailableOptions, "aria-activedescendant": generateDescendantId(activeIndex), value: searchValue, onChange: handleSearchChange, onKeyDown: handleKeyDown, onBlur: debounce(handleBlur, 200), onFocus: handleOpenMenu, autoFocus: true }),
|
|
464
|
+
(hasAvailableOptions || isLoadingMore) && (React.createElement("div", Object.assign({ ref: setPositionedElementRef, className: styles.menu, style: popperStyles.popper }, attributes.popper),
|
|
465
|
+
React.createElement("div", { ref: menuRef, role: "listbox", id: menuId, className: styles.menuList, "data-testid": "chip-menu" },
|
|
466
|
+
allOptions.map((option, i) => (React.createElement("button", { key: option.value, role: "option", type: "button", id: generateDescendantId(i), className: classnames(styles.menuListOption, {
|
|
476
467
|
[styles.activeOption]: activeIndex === i,
|
|
477
468
|
}), onClick: () => handleSelectOption(option), onMouseEnter: handleSetActiveOnMouseOver(i), onMouseDown: handleCancelBlur, onMouseUp: handleEnableBlur },
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
isLoadingMore && (
|
|
482
|
-
|
|
469
|
+
React.createElement("span", { "aria-hidden": true }, option.prefix),
|
|
470
|
+
React.createElement(Text, null, option.label)))),
|
|
471
|
+
React.createElement("div", { ref: visibleChildRef }),
|
|
472
|
+
isLoadingMore && (React.createElement("div", { className: styles.loadingIndicator },
|
|
473
|
+
React.createElement(Spinner, { size: "small", inline: true }))))))));
|
|
483
474
|
}
|
|
484
475
|
|
|
485
476
|
function InternalChipDismissible(props) {
|
|
486
477
|
const { availableChipOptions, ref: wrapperRef, sortedVisibleChipOptions, handleChipAdd, handleChipClick, handleChipKeyDown, handleChipRemove, handleCustomAdd, handleWrapperKeyDown, } = useInternalChipDismissible(props);
|
|
487
|
-
return (
|
|
488
|
-
sortedVisibleChipOptions.map(chip => (
|
|
489
|
-
|
|
478
|
+
return (React.createElement("div", { ref: wrapperRef, className: styles.wrapper, "data-testid": "dismissible-chips", onKeyDown: handleWrapperKeyDown, role: "listbox" },
|
|
479
|
+
sortedVisibleChipOptions.map(chip => (React.createElement(InternalChip, Object.assign({ key: chip.value }, chip, { onKeyDown: handleChipKeyDown(chip.value), onClick: handleChipClick(chip.value), ariaLabel: `${chip.label}. Press delete or backspace to remove ${chip.label}`, tabIndex: 0, suffix: React.createElement(InternalChipButton, { icon: "remove", invalid: chip.invalid, disabled: chip.disabled, label: chip.label, onClick: handleChipRemove(chip.value) }) })))),
|
|
480
|
+
React.createElement(InternalChipDismissibleInput, { activator: props.activator, attachTo: wrapperRef, isLoadingMore: props.isLoadingMore, options: availableChipOptions, onOptionSelect: handleChipAdd, onCustomOptionSelect: handleCustomAdd, onSearch: props.onSearch, onLoadMore: props.onLoadMore })));
|
|
490
481
|
}
|
|
491
482
|
|
|
492
483
|
function Chips(props) {
|
|
493
484
|
switch (props.type) {
|
|
494
485
|
case "dismissible":
|
|
495
|
-
return
|
|
486
|
+
return React.createElement(InternalChipDismissible, Object.assign({}, props));
|
|
496
487
|
case "multiselect":
|
|
497
|
-
return
|
|
488
|
+
return React.createElement(InternalChipMultiSelect, Object.assign({}, props));
|
|
498
489
|
default:
|
|
499
|
-
return
|
|
490
|
+
return React.createElement(InternalChipSingleSelect, Object.assign({}, props));
|
|
500
491
|
}
|
|
501
492
|
}
|
|
502
493
|
|
|
@@ -504,11 +495,8 @@ function Chips(props) {
|
|
|
504
495
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
505
496
|
function Chip(props) {
|
|
506
497
|
// Throw error when <Chip /> gets used outside of the <Chips />
|
|
507
|
-
useAssert
|
|
508
|
-
return
|
|
498
|
+
useAssert(true, "`<Chip>` component can only be used inside `<Chips>`");
|
|
499
|
+
return React.createElement(React.Fragment, null);
|
|
509
500
|
}
|
|
510
501
|
|
|
511
|
-
|
|
512
|
-
exports.Chips = Chips;
|
|
513
|
-
exports.InternalChip = InternalChip;
|
|
514
|
-
exports.InternalChipButton = InternalChipButton;
|
|
502
|
+
export { Chips as C, InternalChip as I, InternalChipButton as a, Chip as b };
|
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var Typography = require('./Typography-83915c54.js');
|
|
10
|
-
var Tooltip = require('./Tooltip-6b12f1c2.js');
|
|
11
|
-
|
|
12
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
-
|
|
14
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
15
|
-
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
1
|
+
import React, { useMemo, isValidElement } from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import { useInView } from '@jobber/hooks/useInView';
|
|
4
|
+
import { s as styleInject } from './style-inject.es-a0e1a0ba.js';
|
|
5
|
+
import { A as Avatar } from './Avatar-b2e862de.js';
|
|
6
|
+
import { I as Icon } from './Icon-22723fe6.js';
|
|
7
|
+
import { T as Typography } from './Typography-09952a2f.js';
|
|
8
|
+
import { T as Tooltip } from './Tooltip-c80b9fb7.js';
|
|
16
9
|
|
|
17
10
|
var css_248z = ":root {\n --chip--gradient-color-variation: var(--chip-base-bg);\n --chip--gradient-color-variation--hover: var(--chip-base--hover);\n}\n\n.af7U8MvcbHE- {\n --chip-height: 40px;\n --chip-radius: 20px;\n --chip-disabled--bg: var(--color-grey--lighter);\n --chip-bar-color: var(--color-greyBlue--light);\n --chip-base-bg: var(--color-greyBlue--lightest);\n --chip-base--hover: var(--color-greyBlue--lighter);\n display: -ms-flexbox;\n display: flex;\n position: relative;\n height: 40px;\n height: var(--chip-height);\n min-width: 0;\n padding: calc(16px / 2) 16px;\n padding: var(--space-small) var(--base-unit);\n border: calc(16px / 16) solid transparent;\n border: var(--border-base) solid transparent;\n border-radius: 20px;\n border-radius: var(--chip-radius);\n color: rgb(1, 41, 57);\n color: var(--color-heading);\n text-align: left;\n cursor: pointer;\n transition: all var(--ease-both) 100ms;\n transition: all var(--ease-both) var(--timing-quick);\n -ms-flex-align: center;\n align-items: center;\n}\n\n.af7U8MvcbHE-:focus {\n box-shadow: 0px 0px calc(16px / 4) calc(16px / 8)\n rgb(231, 213, 87);\n box-shadow: var(--shadow-focus);\n}\n\n.af7U8MvcbHE- .e905AYK4SCc- {\n margin-left: calc(-1 * (16px / 2));\n margin-left: calc(-1 * calc(16px / 2));\n margin-left: calc(-1 * var(--space-small));\n margin-right: calc(16px / 2);\n margin-right: var(--space-small);\n}\n\n.af7U8MvcbHE- .ySADfZ0FckM- {\n margin-left: calc(16px / 2);\n margin-left: var(--space-small);\n margin-right: calc(-1 * (16px / 2));\n margin-right: calc(-1 * calc(16px / 2));\n margin-right: calc(-1 * var(--space-small));\n}\n\n.af7U8MvcbHE- .e905AYK4SCc-,\n.af7U8MvcbHE- .ySADfZ0FckM- {\n display: -ms-flexbox;\n display: flex;\n width: calc(16px * 1.5);\n width: var(--space-large);\n height: calc(16px * 1.5);\n height: var(--space-large);\n -ms-flex-negative: 0;\n flex-shrink: 0;\n border-radius: 100%;\n border-radius: var(--radius-circle);\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n -ms-flex-align: center;\n align-items: center;\n -ms-flex-pack: center;\n justify-content: center;\n}\n\n.af7U8MvcbHE- .ySADfZ0FckM-:hover,\n.af7U8MvcbHE- .e905AYK4SCc-:hover {\n background-color: rgb(181, 181, 181);\n background-color: var(--color-disabled);\n}\n\n.af7U8MvcbHE- .e905AYK4SCc-.usdkmQ9Sxbk-,\n.af7U8MvcbHE- .ySADfZ0FckM-.usdkmQ9Sxbk- {\n display: none;\n}\n\n.af7U8MvcbHE- .dg1-Izy1eQA- {\n width: calc(16px / 16);\n width: var(--space-minuscule);\n height: 16px;\n height: var(--base-unit);\n margin: 0 calc(16px / 2);\n margin: 0 var(--space-small);\n background-color: var(--chip-bar-color);\n}\n\n.af7U8MvcbHE- .-lz0EYLTDgg- {\n border-radius: 100%;\n border-radius: var(--radius-circle);\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n}\n\n.wSI5L-5rODg- {\n border: calc(16px / 16) solid transparent;\n border: var(--border-base) solid transparent;\n color: rgb(1, 41, 57);\n color: var(--color-heading);\n background-color: var(--chip-base-bg);\n --chip--gradient-color-variation: var(--chip-base-bg);\n}\n\n.wSI5L-5rODg-:hover,\n.wSI5L-5rODg-:focus {\n background-color: var(--chip-base--hover);\n --chip--gradient-color-variation--hover: var(--chip-base--hover);\n}\n\n.SmUxkzpIC84-,\n.SmUxkzpIC84-:hover,\n.SmUxkzpIC84-:focus,\n.Mux23dmZSuw-.SmUxkzpIC84-,\n.Mux23dmZSuw-.SmUxkzpIC84-:hover,\n.Mux23dmZSuw-.SmUxkzpIC84-:focus {\n border: calc(16px / 16) solid rgb(201, 66, 33);\n border: var(--border-base) solid var(--color-critical);\n background-color: rgb(255, 226, 219);\n background-color: var(--color-critical--surface);\n --chip--gradient-color-variation: var(--color-critical--surface);\n --chip--gradient-color-variation--hover: var(--color-critical--surface);\n}\n\n.Mux23dmZSuw- {\n border: calc(16px / 16) solid rgb(225, 225, 225);\n border: var(--border-base) solid var(--color-disabled--secondary);\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n --chip--gradient-color-variation: var(--color-surface);\n}\n\n/* CAUTION: Order is important here since\n* there is are different styles for subtle:focus and subtle:hover\n* and we want hover to take priority\n*/\n\n.Mux23dmZSuw-:focus {\n --chip--gradient-color-variation--hover: var(--color-surface);\n}\n\n.Mux23dmZSuw-:hover {\n border: calc(16px / 16) solid var(--chip-base-bg);\n border: var(--border-base) solid var(--chip-base-bg);\n background-color: var(--chip-base-bg);\n --chip--gradient-color-variation--hover: var(--chip-base-bg);\n}\n\n.MbRItb9vKhc-,\n.MbRItb9vKhc-:hover,\n.MbRItb9vKhc-:focus {\n border: calc(16px / 16) solid var(--chip-disabled--bg);\n border: var(--border-base) solid var(--chip-disabled--bg);\n color: rgb(181, 181, 181);\n color: var(--color-disabled);\n background-color: var(--chip-disabled--bg);\n cursor: auto;\n --chip--gradient-color-variation: var(--chip-disabled--bg);\n --chip--gradient-color-variation--hover: var(--chip-disabled--bg);\n}\n\n.MbRItb9vKhc- .dg1-Izy1eQA- {\n background-color: rgb(181, 181, 181);\n background-color: var(--color-disabled);\n}\n\n.af7U8MvcbHE-.MbRItb9vKhc- .ySADfZ0FckM- {\n background-color: rgb(181, 181, 181);\n background-color: var(--color-disabled);\n}\n\n.tJhURjR2Vec- {\n display: -ms-flexbox;\n display: flex;\n position: relative;\n overflow: hidden;\n -ms-flex-wrap: nowrap;\n flex-wrap: nowrap;\n}\n\n.tJhURjR2Vec- > * {\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n}\n\n.tJhURjR2Vec- > p {\n overflow: hidden;\n white-space: nowrap;\n}\n\n.G3QXY0rNcK0- {\n position: absolute;\n top: 0;\n right: 0;\n width: calc(16px * 1);\n width: var(--space-base);\n height: 100%;\n background: linear-gradient(\n to left,\n var(--chip-base-bg) 5%,\n rgba(255, 255, 255, 0)\n );\n background: linear-gradient(\n to left,\n var(--chip--gradient-color-variation) 5%,\n rgba(255, 255, 255, 0)\n );\n}\n\n.af7U8MvcbHE-:focus .G3QXY0rNcK0-,\n.af7U8MvcbHE-:hover .G3QXY0rNcK0- {\n background: linear-gradient(\n to left,\n var(--chip-base--hover) 5%,\n rgba(255, 255, 255, 0)\n );\n background: linear-gradient(\n to left,\n var(--chip--gradient-color-variation--hover) 5%,\n rgba(255, 255, 255, 0)\n );\n}\n\n.MUKEW6c2nNA- {\n display: inline-block;\n width: 1px;\n}\n";
|
|
18
11
|
var styles = {"chip":"af7U8MvcbHE-","prefix":"e905AYK4SCc-","suffix":"ySADfZ0FckM-","empty":"usdkmQ9Sxbk-","chipBar":"dg1-Izy1eQA-","selected":"-lz0EYLTDgg-","base":"wSI5L-5rODg-","invalid":"SmUxkzpIC84-","subtle":"Mux23dmZSuw-","disabled":"MbRItb9vKhc-","chipContent":"tJhURjR2Vec-","truncateGradient":"G3QXY0rNcK0-","chipLabelRef":"MUKEW6c2nNA-"};
|
|
19
|
-
|
|
12
|
+
styleInject(css_248z);
|
|
20
13
|
|
|
21
14
|
/**
|
|
22
15
|
* Returns the first React Child that receives `true` from isCorrectComponent
|
|
@@ -25,28 +18,28 @@ styleInject_es.styleInject(css_248z);
|
|
|
25
18
|
* @returns The first child component that returns true on isCorrectComponent
|
|
26
19
|
*/
|
|
27
20
|
function useChildComponent(children, isCorrectComponent) {
|
|
28
|
-
return
|
|
29
|
-
return
|
|
21
|
+
return useMemo(() => {
|
|
22
|
+
return React.Children.toArray(children).find(d => isValidElement(d) && isCorrectComponent(d));
|
|
30
23
|
}, [children]);
|
|
31
24
|
}
|
|
32
25
|
|
|
33
26
|
function ChipPrefix({ children }) {
|
|
34
|
-
const singleChild = useChildComponent(children, d => d.type === Avatar
|
|
35
|
-
return (
|
|
27
|
+
const singleChild = useChildComponent(children, d => d.type === Avatar || d.type === Icon);
|
|
28
|
+
return (React.createElement("span", { className: classnames(styles.prefix, !singleChild && styles.empty) }, singleChild));
|
|
36
29
|
}
|
|
37
30
|
|
|
38
31
|
function ChipSuffix({ children, className }) {
|
|
39
32
|
var _a;
|
|
40
|
-
let singleChild = useChildComponent(children, d => d.type === Icon
|
|
33
|
+
let singleChild = useChildComponent(children, d => d.type === Icon);
|
|
41
34
|
if (!allowedSuffixIcons.includes((_a = singleChild === null || singleChild === void 0 ? void 0 : singleChild.props) === null || _a === void 0 ? void 0 : _a.name)) {
|
|
42
35
|
singleChild = undefined;
|
|
43
36
|
}
|
|
44
|
-
return (
|
|
37
|
+
return (React.createElement("span", { className: classnames(styles.suffix, className, !singleChild && styles.empty) }, singleChild));
|
|
45
38
|
}
|
|
46
39
|
const allowedSuffixIcons = ["cross", "add", "checkmark"];
|
|
47
40
|
|
|
48
41
|
const Chip = ({ ariaLabel, disabled, heading, invalid, label, value, onClick, onKeyDown, children, role = "button", tabIndex = 0, variation = "base", }) => {
|
|
49
|
-
const classes =
|
|
42
|
+
const classes = classnames(styles.chip, {
|
|
50
43
|
[styles.invalid]: invalid,
|
|
51
44
|
[styles.base]: variation === "base",
|
|
52
45
|
[styles.subtle]: variation === "subtle",
|
|
@@ -54,22 +47,22 @@ const Chip = ({ ariaLabel, disabled, heading, invalid, label, value, onClick, on
|
|
|
54
47
|
});
|
|
55
48
|
const prefix = useChildComponent(children, d => d.type === Chip.Prefix);
|
|
56
49
|
const suffix = useChildComponent(children, d => d.type === Chip.Suffix);
|
|
57
|
-
const [labelRef, labelFullyVisible] = useInView
|
|
58
|
-
const [headingRef, headingFullyVisible] = useInView
|
|
50
|
+
const [labelRef, labelFullyVisible] = useInView();
|
|
51
|
+
const [headingRef, headingFullyVisible] = useInView();
|
|
59
52
|
const tooltipMessage = getTooltipMessage(labelFullyVisible, headingFullyVisible, label, heading);
|
|
60
|
-
return (
|
|
61
|
-
|
|
53
|
+
return (React.createElement(Tooltip, { message: tooltipMessage },
|
|
54
|
+
React.createElement("button", { className: classes, onClick: (ev) => onClick && onClick(value, ev), tabIndex: tabIndex, onKeyDown: onKeyDown, "aria-label": ariaLabel || label, disabled: disabled, role: role, type: "button" },
|
|
62
55
|
prefix,
|
|
63
|
-
|
|
64
|
-
heading && (
|
|
65
|
-
|
|
56
|
+
React.createElement("div", { className: styles.chipContent },
|
|
57
|
+
heading && (React.createElement(React.Fragment, null,
|
|
58
|
+
React.createElement(Typography, { size: "base", fontWeight: "medium" },
|
|
66
59
|
heading,
|
|
67
|
-
|
|
68
|
-
label &&
|
|
69
|
-
|
|
60
|
+
React.createElement("span", { ref: headingRef, className: styles.chipLabelRef })),
|
|
61
|
+
label && React.createElement("span", { className: styles.chipBar }))),
|
|
62
|
+
React.createElement(Typography, { size: "base" },
|
|
70
63
|
label,
|
|
71
|
-
|
|
72
|
-
!labelFullyVisible && (
|
|
64
|
+
React.createElement("span", { ref: labelRef, className: styles.chipLabelRef })),
|
|
65
|
+
!labelFullyVisible && (React.createElement("div", { className: styles.truncateGradient, "data-testid": "ATL-Chip-Truncation-Gradient" }))),
|
|
73
66
|
suffix)));
|
|
74
67
|
};
|
|
75
68
|
function getTooltipMessage(labelFullyVisible, headingFullyVisible, label, heading) {
|
|
@@ -85,5 +78,4 @@ function getTooltipMessage(labelFullyVisible, headingFullyVisible, label, headin
|
|
|
85
78
|
Chip.Prefix = ChipPrefix;
|
|
86
79
|
Chip.Suffix = ChipSuffix;
|
|
87
80
|
|
|
88
|
-
|
|
89
|
-
exports.styles = styles;
|
|
81
|
+
export { Chip as C, styles as s };
|
package/dist/Chips/index.js
CHANGED
|
@@ -1,38 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
require('../Button-db6114a6.js');
|
|
25
|
-
require('react-router-dom');
|
|
26
|
-
require('../Spinner-9d8fc7ff.js');
|
|
27
|
-
|
|
28
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
29
|
-
|
|
30
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { I as InternalChip, a as InternalChipButton } from '../Chip-12a64c38.js';
|
|
3
|
+
export { b as Chip, C as Chips } from '../Chip-12a64c38.js';
|
|
4
|
+
import 'uuid';
|
|
5
|
+
import '../style-inject.es-a0e1a0ba.js';
|
|
6
|
+
import 'classnames';
|
|
7
|
+
import '@jobber/hooks/useAssert';
|
|
8
|
+
import '../Icon-22723fe6.js';
|
|
9
|
+
import '@jobber/design';
|
|
10
|
+
import '../Avatar-b2e862de.js';
|
|
11
|
+
import 'color';
|
|
12
|
+
import '../Typography-09952a2f.js';
|
|
13
|
+
import '../Tooltip-c80b9fb7.js';
|
|
14
|
+
import 'react-dom';
|
|
15
|
+
import 'framer-motion';
|
|
16
|
+
import 'react-popper';
|
|
17
|
+
import 'lodash/sortBy';
|
|
18
|
+
import '@jobber/hooks/useLiveAnnounce';
|
|
19
|
+
import 'lodash/debounce';
|
|
20
|
+
import '../Text-703e2c21.js';
|
|
21
|
+
import '../Button-319d8fa0.js';
|
|
22
|
+
import 'react-router-dom';
|
|
23
|
+
import '../Spinner-5d8359b8.js';
|
|
31
24
|
|
|
32
25
|
function ChipDismissible({ label, disabled, invalid, prefix, onClick, onRequestRemove, }) {
|
|
33
|
-
return (
|
|
26
|
+
return (React.createElement(InternalChip, { label: label, disabled: disabled, invalid: invalid, prefix: prefix, onClick: onClick, suffix: React.createElement(InternalChipButton, { icon: "remove", label: label, invalid: invalid, disabled: disabled, onClick: onRequestRemove }) }));
|
|
34
27
|
}
|
|
35
28
|
|
|
36
|
-
|
|
37
|
-
exports.Chips = Chip.Chips;
|
|
38
|
-
exports.ChipDismissible = ChipDismissible;
|
|
29
|
+
export { ChipDismissible };
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ComboboxProps } from "./Combobox.types";
|
|
3
|
-
import { ComboboxContent } from "./components/ComboboxContent";
|
|
4
3
|
import { ComboboxAction } from "./components/ComboboxAction";
|
|
5
|
-
import {
|
|
6
|
-
import { ComboboxOption } from "./components/ComboboxOption";
|
|
4
|
+
import { ComboboxOption as ComboboxOptionComponent } from "./components/ComboboxOption/ComboboxOption";
|
|
7
5
|
import { ComboboxActivator } from "./components/ComboboxActivator";
|
|
8
|
-
export declare function Combobox(
|
|
6
|
+
export declare function Combobox(props: ComboboxProps): JSX.Element;
|
|
9
7
|
export declare namespace Combobox {
|
|
10
|
-
var TriggerButton: typeof ComboboxTriggerButton;
|
|
11
|
-
var TriggerChip: typeof ComboboxTriggerChip;
|
|
12
8
|
var Activator: typeof ComboboxActivator;
|
|
13
|
-
var Content: typeof ComboboxContent;
|
|
14
9
|
var Action: typeof ComboboxAction;
|
|
15
|
-
var Option: typeof
|
|
10
|
+
var Option: typeof ComboboxOptionComponent;
|
|
16
11
|
}
|