@easypost/easy-ui 1.0.0-alpha.4 → 1.0.0-alpha.6
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/Badge/index.js +32 -26
- package/Badge/index.mjs +32 -26
- package/Banner/index.js +15 -16
- package/Banner/index.mjs +15 -16
- package/Button/Button.d.ts +61 -0
- package/Button/Button.d.ts.map +1 -1
- package/Button/index.js +34 -69
- package/Button/index.mjs +33 -68
- package/CHANGELOG.md +21 -0
- package/Card/index.js +84 -5
- package/Card/index.mjs +84 -5
- package/Checkbox/index.js +84 -72
- package/Checkbox/index.mjs +84 -72
- package/CodeBlock/index.js +43 -49
- package/CodeBlock/index.mjs +43 -49
- package/DropdownButton/DropdownButton.d.ts +48 -0
- package/DropdownButton/DropdownButton.d.ts.map +1 -1
- package/DropdownButton/index.js +29 -101
- package/DropdownButton/index.mjs +29 -85
- package/HorizontalGrid/index.js +11 -31
- package/HorizontalGrid/index.mjs +11 -31
- package/HorizontalStack/index.js +48 -4
- package/HorizontalStack/index.mjs +48 -4
- package/Icon/Icon.d.ts +51 -0
- package/Icon/Icon.d.ts.map +1 -1
- package/Icon/index.js +38 -4
- package/Icon/index.mjs +38 -4
- package/IconButton/IconButton.d.ts +62 -0
- package/IconButton/IconButton.d.ts.map +1 -1
- package/IconButton/index.js +26 -43
- package/IconButton/index.mjs +25 -42
- package/InputField/Label.d.ts +2 -2
- package/InputField/index.js +282 -10
- package/InputField/index.mjs +266 -10
- package/InputField/utilities.d.ts +1 -1
- package/InputField/utilities.d.ts.map +1 -1
- package/Menu/MenuOverlay.d.ts.map +1 -1
- package/Menu/index.js +178 -1958
- package/Menu/index.mjs +168 -1948
- package/Menu/utilities.d.ts +11 -0
- package/Menu/utilities.d.ts.map +1 -0
- package/Notification/index.js +1534 -14
- package/Notification/index.mjs +1518 -14
- package/Provider/index.js +15 -15
- package/Provider/index.mjs +15 -15
- package/RadioGroup/index.js +63 -63
- package/RadioGroup/index.mjs +63 -63
- package/Select/Select.d.ts +88 -0
- package/Select/Select.d.ts.map +1 -0
- package/Select/Select.stories.d.ts +17 -0
- package/Select/Select.stories.d.ts.map +1 -0
- package/Select/Select.test.d.ts +2 -0
- package/Select/Select.test.d.ts.map +1 -0
- package/Select/SelectContext.d.ts +14 -0
- package/Select/SelectContext.d.ts.map +1 -0
- package/Select/SelectField.d.ts +62 -0
- package/Select/SelectField.d.ts.map +1 -0
- package/Select/SelectOption.d.ts +23 -0
- package/Select/SelectOption.d.ts.map +1 -0
- package/Select/SelectOverlay.d.ts +3 -0
- package/Select/SelectOverlay.d.ts.map +1 -0
- package/Select/SelectSection.d.ts +22 -0
- package/Select/SelectSection.d.ts.map +1 -0
- package/Select/SelectTrigger.d.ts +30 -0
- package/Select/SelectTrigger.d.ts.map +1 -0
- package/Select/index.d.ts +2 -0
- package/Select/index.d.ts.map +1 -0
- package/Select/index.js +816 -0
- package/Select/index.mjs +816 -0
- package/SelectorErrorTooltip/index.js +102 -11
- package/SelectorErrorTooltip/index.mjs +86 -11
- package/Text/index.js +85 -4
- package/Text/index.mjs +85 -4
- package/TextField/index.js +19 -38
- package/TextField/index.mjs +19 -38
- package/Textarea/index.js +20 -37
- package/Textarea/index.mjs +20 -37
- package/Theme/index.js +145 -9
- package/Theme/index.mjs +145 -9
- package/Toggle/index.js +51 -50
- package/Toggle/index.mjs +51 -50
- package/Tooltip/index.js +299 -10
- package/Tooltip/index.mjs +299 -10
- package/UnstyledButton/index.js +4 -4
- package/UnstyledButton/index.mjs +3 -3
- package/VerticalStack/index.js +13 -47
- package/VerticalStack/index.mjs +13 -47
- package/__chunks__/ExpandMore400-7c5263a4.mjs +49 -0
- package/__chunks__/ExpandMore400-92646971.js +65 -0
- package/__chunks__/InputIcon-2317befd.mjs +148 -0
- package/__chunks__/InputIcon-d3963cf8.js +147 -0
- package/__chunks__/{import-e7f45c7e.mjs → import-0561e1ba.mjs} +3 -3
- package/__chunks__/{import-b7971a11.mjs → import-19bc38ac.mjs} +72 -34
- package/__chunks__/{import-01299af6.js → import-24a482e1.js} +3 -2
- package/__chunks__/{import-baa3cd0c.mjs → import-29af6941.mjs} +4 -3
- package/__chunks__/{import-0d1b4d93.js → import-2b302763.js} +193 -141
- package/__chunks__/{import-ab878fb6.mjs → import-3d962a94.mjs} +205 -153
- package/__chunks__/{import-86330a7c.mjs → import-6a831ca1.mjs} +16 -15
- package/__chunks__/{import-7545401a.js → import-8b6c0bc7.js} +3 -3
- package/__chunks__/{import-63bf0645.js → import-a1e0f814.js} +47 -9
- package/__chunks__/{import-3ab42f86.js → import-a2023d8f.js} +35 -22
- package/__chunks__/{import-76076ca6.js → import-dea5a24d.js} +15 -14
- package/__chunks__/{import-856e0385.mjs → import-f1f4792a.mjs} +36 -23
- package/__chunks__/{UnstyledButton-883f0c6c.mjs → index-29d7bca9.mjs} +17 -42
- package/__chunks__/{UnstyledButton-96172ec0.js → index-3985350a.js} +17 -42
- package/__chunks__/{overlayscrollbars-react.es-c8369a03.mjs → overlayscrollbars-react.es-7f332a3b.mjs} +4 -4
- package/__chunks__/{overlayscrollbars-react.es-20563393.js → overlayscrollbars-react.es-f2a0bcff.js} +4 -4
- package/__chunks__/{real-module-e4cd2301.mjs → real-module-515df21d.mjs} +1 -1
- package/__chunks__/{real-module-ae2a4342.js → real-module-e36b1436.js} +1 -1
- package/__chunks__/useTriggerWidth-156b038a.js +2030 -0
- package/__chunks__/useTriggerWidth-addcd1d6.mjs +2031 -0
- package/package.json +11 -11
- package/style.css +1423 -1196
- package/utilities/css.js +14 -58
- package/utilities/css.mjs +14 -58
- package/__chunks__/Card-7bbd41e0.mjs +0 -110
- package/__chunks__/Card-dac53c75.js +0 -109
- package/__chunks__/HorizontalStack-a441c63f.mjs +0 -80
- package/__chunks__/HorizontalStack-a862839b.js +0 -79
- package/__chunks__/Icon-3d00481a.js +0 -44
- package/__chunks__/Icon-a75b5201.mjs +0 -45
- package/__chunks__/InputField-4fbaae06.js +0 -487
- package/__chunks__/InputField-a272f602.mjs +0 -472
- package/__chunks__/Notification-b8eafec6.mjs +0 -1456
- package/__chunks__/Notification-c5b34eb3.js +0 -1471
- package/__chunks__/SelectorErrorTooltip-43c5e29e.js +0 -84
- package/__chunks__/SelectorErrorTooltip-b6204987.mjs +0 -69
- package/__chunks__/Text-1ae70c19.js +0 -102
- package/__chunks__/Text-4ae50d5c.mjs +0 -103
- package/__chunks__/Theme-4e498252.mjs +0 -132
- package/__chunks__/Theme-751e5575.js +0 -131
- package/__chunks__/Tooltip-bd55165e.js +0 -317
- package/__chunks__/Tooltip-f7e67b21.mjs +0 -318
package/Select/index.mjs
ADDED
|
@@ -0,0 +1,816 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __knownSymbol = (name, symbol) => {
|
|
8
|
+
if (symbol = Symbol[name])
|
|
9
|
+
return symbol;
|
|
10
|
+
throw Error("Symbol." + name + " is not defined");
|
|
11
|
+
};
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __await = function(promise, isYieldStar) {
|
|
26
|
+
this[0] = promise;
|
|
27
|
+
this[1] = isYieldStar;
|
|
28
|
+
};
|
|
29
|
+
var __yieldStar = (value) => {
|
|
30
|
+
var obj = value[__knownSymbol("asyncIterator")];
|
|
31
|
+
var isAwait = false;
|
|
32
|
+
var method;
|
|
33
|
+
var it = {};
|
|
34
|
+
if (obj == null) {
|
|
35
|
+
obj = value[__knownSymbol("iterator")]();
|
|
36
|
+
method = (k) => it[k] = (x) => obj[k](x);
|
|
37
|
+
} else {
|
|
38
|
+
obj = obj.call(value);
|
|
39
|
+
method = (k) => it[k] = (v) => {
|
|
40
|
+
if (isAwait) {
|
|
41
|
+
isAwait = false;
|
|
42
|
+
if (k === "throw")
|
|
43
|
+
throw v;
|
|
44
|
+
return v;
|
|
45
|
+
}
|
|
46
|
+
isAwait = true;
|
|
47
|
+
return {
|
|
48
|
+
done: false,
|
|
49
|
+
value: new __await(new Promise((resolve) => {
|
|
50
|
+
var x = obj[k](v);
|
|
51
|
+
if (!(x instanceof Object))
|
|
52
|
+
throw TypeError("Object expected");
|
|
53
|
+
resolve(x);
|
|
54
|
+
}), 1)
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => {
|
|
59
|
+
throw x;
|
|
60
|
+
}, "return" in obj && method("return"), it;
|
|
61
|
+
};
|
|
62
|
+
import React__default, { useMemo, useCallback, useRef, useEffect, useState, createContext, useContext } from "react";
|
|
63
|
+
import { classNames, variationName } from "../utilities/css.mjs";
|
|
64
|
+
import { I as InputIcon, L as Label, a as InputCaption } from "../__chunks__/InputIcon-2317befd.mjs";
|
|
65
|
+
import { Text } from "../Text/index.mjs";
|
|
66
|
+
import { E as ExpandMore400 } from "../__chunks__/ExpandMore400-7c5263a4.mjs";
|
|
67
|
+
import { U as UnstyledButton } from "../__chunks__/index-29d7bca9.mjs";
|
|
68
|
+
import { d as $65484d02dcb7eb3e$export$457c3d6518dd4c6f, b as $bdb11010cef70236$export$f680877a34711e37, a as $3ef42575df84b30b$export$9d1611c77c2fe928, $ as $bdb11010cef70236$export$b4cc09c592e8fdb8, p as $c87311424ea30a05$export$9ac100e40613ea10, y as $c87311424ea30a05$export$78551043582a6a98, r as $ff5963eb1fccf552$export$e08e3b67e392101e } from "../__chunks__/import-19bc38ac.mjs";
|
|
69
|
+
import { o as $982254629710d113$export$b95089534ab7c1fd, p as $453cc9f0df89c0a5$export$77d5aafae4e095b2, q as $880e95eb8b93ba9a$export$ecf600387e221c37, r as $2a25aae57d74318e$export$a05409b8bb224a5a, n as $168583247155ddda$export$dc9c12ed27dd1b49, s as $fb3050f43d946246$export$e32c88dfddc6e1d8, $ as $7af3f5b51489e0b5$export$253fe78d46329472, a as $7613b1592d41b092$export$6cd28814d92fa9c9, b as $d496c0a20b6e58ec$export$6c8a5aaad13c9852, m as $a28c903ee9ad8dc5$export$79fefeb1c2091ac3, c as $c1d7fb2ec91bae71$export$6d08773d2e66f8f2, e as $9fc4852771d079eb$export$6e2c8f0811a474ce, g as $f4b273590fab9f93$export$52210f68a14655d0, i as getUnmergedPopoverStyles, k as DEFAULT_WIDTH, O as OVERLAY_PADDING_FROM_CONTAINER, I as ITEM_HEIGHT, Y as Y_PADDING_INSIDE_OVERLAY, l as OVERLAY_OFFSET, j as DEFAULT_PLACEMENT, u as useTriggerWidth } from "../__chunks__/useTriggerWidth-addcd1d6.mjs";
|
|
70
|
+
import { b as $9ab94262bd0047c7$export$420e68273165f4ec, f as $6179b936705e76d3$export$ae780daf29e6d456, k as $507fabe10e71c6fb$export$b9b3dfddab17db27, m as $507fabe10e71c6fb$export$8397ddfc504fdb9a, n as $507fabe10e71c6fb$export$98e20ec92f614cfe } from "../__chunks__/import-3d962a94.mjs";
|
|
71
|
+
import { a as $d191a55c9702f145$export$8467354a121f1b9f, $ as $2baaea4c71418dea$export$294aa081a6c6f55d } from "../__chunks__/import-29af6941.mjs";
|
|
72
|
+
import { e as $5c3e21d68f1c4674$export$a966af930f325cab, b as $f2f8a6077418541e$export$542a6fd13ac93354, c as $f57aed4a881a3485$export$b47c3594eab58386, d as $86ea4cb521eb2e37$export$2317d149ed6f78c4 } from "../__chunks__/import-f1f4792a.mjs";
|
|
73
|
+
import { b as $325a3faab7a68acd$export$a16aca283550c30d } from "../__chunks__/real-module-515df21d.mjs";
|
|
74
|
+
import { $ as $458b0a5536c1a7cf$export$40bfa8c7b0832715 } from "../__chunks__/import-6a831ca1.mjs";
|
|
75
|
+
import "../Icon/index.mjs";
|
|
76
|
+
import "../__chunks__/omit-f17deb8f.mjs";
|
|
77
|
+
import "react-dom";
|
|
78
|
+
const $b1f0cad8af73213b$export$3585ede4d035bf14 = /* @__PURE__ */ new WeakMap();
|
|
79
|
+
function $b1f0cad8af73213b$var$normalizeKey(key) {
|
|
80
|
+
if (typeof key === "string")
|
|
81
|
+
return key.replace(/\s*/g, "");
|
|
82
|
+
return "" + key;
|
|
83
|
+
}
|
|
84
|
+
function $b1f0cad8af73213b$export$9145995848b05025(state, itemKey) {
|
|
85
|
+
let data = $b1f0cad8af73213b$export$3585ede4d035bf14.get(state);
|
|
86
|
+
if (!data)
|
|
87
|
+
throw new Error("Unknown list");
|
|
88
|
+
return `${data.id}-option-${$b1f0cad8af73213b$var$normalizeKey(itemKey)}`;
|
|
89
|
+
}
|
|
90
|
+
function $c132121280ec012d$export$50eacbbf140a3141(props, state, ref) {
|
|
91
|
+
let domProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
|
|
92
|
+
labelable: true
|
|
93
|
+
});
|
|
94
|
+
let { listProps } = $982254629710d113$export$b95089534ab7c1fd(__spreadProps(__spreadValues({}, props), {
|
|
95
|
+
ref,
|
|
96
|
+
selectionManager: state.selectionManager,
|
|
97
|
+
collection: state.collection,
|
|
98
|
+
disabledKeys: state.disabledKeys
|
|
99
|
+
}));
|
|
100
|
+
let { focusWithinProps } = $9ab94262bd0047c7$export$420e68273165f4ec({
|
|
101
|
+
onFocusWithin: props.onFocus,
|
|
102
|
+
onBlurWithin: props.onBlur,
|
|
103
|
+
onFocusWithinChange: props.onFocusChange
|
|
104
|
+
});
|
|
105
|
+
let id = $bdb11010cef70236$export$f680877a34711e37(props.id);
|
|
106
|
+
$b1f0cad8af73213b$export$3585ede4d035bf14.set(state, {
|
|
107
|
+
id,
|
|
108
|
+
shouldUseVirtualFocus: props.shouldUseVirtualFocus,
|
|
109
|
+
shouldSelectOnPressUp: props.shouldSelectOnPressUp,
|
|
110
|
+
shouldFocusOnHover: props.shouldFocusOnHover,
|
|
111
|
+
isVirtualized: props.isVirtualized,
|
|
112
|
+
onAction: props.onAction
|
|
113
|
+
});
|
|
114
|
+
let { labelProps, fieldProps } = $d191a55c9702f145$export$8467354a121f1b9f(__spreadProps(__spreadValues({}, props), {
|
|
115
|
+
id,
|
|
116
|
+
// listbox is not an HTML input element so it
|
|
117
|
+
// shouldn't be labeled by a <label> element.
|
|
118
|
+
labelElementType: "span"
|
|
119
|
+
}));
|
|
120
|
+
return {
|
|
121
|
+
labelProps,
|
|
122
|
+
listBoxProps: $3ef42575df84b30b$export$9d1611c77c2fe928(domProps, focusWithinProps, state.selectionManager.selectionMode === "multiple" ? {
|
|
123
|
+
"aria-multiselectable": "true"
|
|
124
|
+
} : {}, __spreadValues({
|
|
125
|
+
role: "listbox"
|
|
126
|
+
}, $3ef42575df84b30b$export$9d1611c77c2fe928(fieldProps, listProps)))
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
|
|
130
|
+
let { key } = props;
|
|
131
|
+
let data = $b1f0cad8af73213b$export$3585ede4d035bf14.get(state);
|
|
132
|
+
var _props_isDisabled;
|
|
133
|
+
let isDisabled = (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : state.disabledKeys.has(key);
|
|
134
|
+
var _props_isSelected;
|
|
135
|
+
let isSelected = (_props_isSelected = props.isSelected) !== null && _props_isSelected !== void 0 ? _props_isSelected : state.selectionManager.isSelected(key);
|
|
136
|
+
var _props_shouldSelectOnPressUp;
|
|
137
|
+
let shouldSelectOnPressUp = (_props_shouldSelectOnPressUp = props.shouldSelectOnPressUp) !== null && _props_shouldSelectOnPressUp !== void 0 ? _props_shouldSelectOnPressUp : data === null || data === void 0 ? void 0 : data.shouldSelectOnPressUp;
|
|
138
|
+
var _props_shouldFocusOnHover;
|
|
139
|
+
let shouldFocusOnHover = (_props_shouldFocusOnHover = props.shouldFocusOnHover) !== null && _props_shouldFocusOnHover !== void 0 ? _props_shouldFocusOnHover : data === null || data === void 0 ? void 0 : data.shouldFocusOnHover;
|
|
140
|
+
var _props_shouldUseVirtualFocus;
|
|
141
|
+
let shouldUseVirtualFocus = (_props_shouldUseVirtualFocus = props.shouldUseVirtualFocus) !== null && _props_shouldUseVirtualFocus !== void 0 ? _props_shouldUseVirtualFocus : data === null || data === void 0 ? void 0 : data.shouldUseVirtualFocus;
|
|
142
|
+
var _props_isVirtualized;
|
|
143
|
+
let isVirtualized = (_props_isVirtualized = props.isVirtualized) !== null && _props_isVirtualized !== void 0 ? _props_isVirtualized : data === null || data === void 0 ? void 0 : data.isVirtualized;
|
|
144
|
+
let labelId = $bdb11010cef70236$export$b4cc09c592e8fdb8();
|
|
145
|
+
let descriptionId = $bdb11010cef70236$export$b4cc09c592e8fdb8();
|
|
146
|
+
let optionProps = {
|
|
147
|
+
role: "option",
|
|
148
|
+
"aria-disabled": isDisabled || void 0,
|
|
149
|
+
"aria-selected": state.selectionManager.selectionMode !== "none" ? isSelected : void 0
|
|
150
|
+
};
|
|
151
|
+
if (!($c87311424ea30a05$export$9ac100e40613ea10() && $c87311424ea30a05$export$78551043582a6a98())) {
|
|
152
|
+
optionProps["aria-label"] = props["aria-label"];
|
|
153
|
+
optionProps["aria-labelledby"] = labelId;
|
|
154
|
+
optionProps["aria-describedby"] = descriptionId;
|
|
155
|
+
}
|
|
156
|
+
if (isVirtualized) {
|
|
157
|
+
var _state_collection_getItem;
|
|
158
|
+
let index = Number((_state_collection_getItem = state.collection.getItem(key)) === null || _state_collection_getItem === void 0 ? void 0 : _state_collection_getItem.index);
|
|
159
|
+
optionProps["aria-posinset"] = Number.isNaN(index) ? void 0 : index + 1;
|
|
160
|
+
optionProps["aria-setsize"] = $453cc9f0df89c0a5$export$77d5aafae4e095b2(state.collection);
|
|
161
|
+
}
|
|
162
|
+
let { itemProps, isPressed, isFocused, hasAction, allowsSelection } = $880e95eb8b93ba9a$export$ecf600387e221c37({
|
|
163
|
+
selectionManager: state.selectionManager,
|
|
164
|
+
key,
|
|
165
|
+
ref,
|
|
166
|
+
shouldSelectOnPressUp,
|
|
167
|
+
allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,
|
|
168
|
+
isVirtualized,
|
|
169
|
+
shouldUseVirtualFocus,
|
|
170
|
+
isDisabled,
|
|
171
|
+
onAction: (data === null || data === void 0 ? void 0 : data.onAction) ? () => {
|
|
172
|
+
var _data_onAction;
|
|
173
|
+
return data === null || data === void 0 ? void 0 : (_data_onAction = data.onAction) === null || _data_onAction === void 0 ? void 0 : _data_onAction.call(data, key);
|
|
174
|
+
} : void 0
|
|
175
|
+
});
|
|
176
|
+
let { hoverProps } = $6179b936705e76d3$export$ae780daf29e6d456({
|
|
177
|
+
isDisabled: isDisabled || !shouldFocusOnHover,
|
|
178
|
+
onHoverStart() {
|
|
179
|
+
if (!$507fabe10e71c6fb$export$b9b3dfddab17db27()) {
|
|
180
|
+
state.selectionManager.setFocused(true);
|
|
181
|
+
state.selectionManager.setFocusedKey(key);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
return {
|
|
186
|
+
optionProps: __spreadProps(__spreadValues(__spreadValues({}, optionProps), $3ef42575df84b30b$export$9d1611c77c2fe928(itemProps, hoverProps)), {
|
|
187
|
+
id: $b1f0cad8af73213b$export$9145995848b05025(state, key)
|
|
188
|
+
}),
|
|
189
|
+
labelProps: {
|
|
190
|
+
id: labelId
|
|
191
|
+
},
|
|
192
|
+
descriptionProps: {
|
|
193
|
+
id: descriptionId
|
|
194
|
+
},
|
|
195
|
+
isFocused,
|
|
196
|
+
isFocusVisible: isFocused && $507fabe10e71c6fb$export$b9b3dfddab17db27(),
|
|
197
|
+
isSelected,
|
|
198
|
+
isDisabled,
|
|
199
|
+
isPressed,
|
|
200
|
+
allowsSelection,
|
|
201
|
+
hasAction
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function $af383d3bef1cfdc9$export$c3f9f39876e4bc7(props) {
|
|
205
|
+
let { heading, "aria-label": ariaLabel } = props;
|
|
206
|
+
let headingId = $bdb11010cef70236$export$f680877a34711e37();
|
|
207
|
+
return {
|
|
208
|
+
itemProps: {
|
|
209
|
+
role: "presentation"
|
|
210
|
+
},
|
|
211
|
+
headingProps: heading ? {
|
|
212
|
+
// Techincally, listbox cannot contain headings according to ARIA.
|
|
213
|
+
// We hide the heading from assistive technology, using role="presentation",
|
|
214
|
+
// and only use it as a visual label for the nested group.
|
|
215
|
+
id: headingId,
|
|
216
|
+
role: "presentation"
|
|
217
|
+
} : {},
|
|
218
|
+
groupProps: {
|
|
219
|
+
role: "group",
|
|
220
|
+
"aria-label": ariaLabel,
|
|
221
|
+
"aria-labelledby": heading ? headingId : void 0
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
function $58aed456727eb0f3$export$e64b2f635402ca43(props, state, ref) {
|
|
226
|
+
let { keyboardDelegate, isDisabled } = props;
|
|
227
|
+
let collator = $325a3faab7a68acd$export$a16aca283550c30d({
|
|
228
|
+
usage: "search",
|
|
229
|
+
sensitivity: "base"
|
|
230
|
+
});
|
|
231
|
+
let delegate = useMemo(() => keyboardDelegate || new $2a25aae57d74318e$export$a05409b8bb224a5a(state.collection, state.disabledKeys, null, collator), [
|
|
232
|
+
keyboardDelegate,
|
|
233
|
+
state.collection,
|
|
234
|
+
state.disabledKeys,
|
|
235
|
+
collator
|
|
236
|
+
]);
|
|
237
|
+
let { menuTriggerProps, menuProps } = $168583247155ddda$export$dc9c12ed27dd1b49({
|
|
238
|
+
isDisabled,
|
|
239
|
+
type: "listbox"
|
|
240
|
+
}, state, ref);
|
|
241
|
+
let onKeyDown = (e) => {
|
|
242
|
+
switch (e.key) {
|
|
243
|
+
case "ArrowLeft": {
|
|
244
|
+
e.preventDefault();
|
|
245
|
+
let key = state.selectedKey != null ? delegate.getKeyAbove(state.selectedKey) : delegate.getFirstKey();
|
|
246
|
+
if (key)
|
|
247
|
+
state.setSelectedKey(key);
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
case "ArrowRight": {
|
|
251
|
+
e.preventDefault();
|
|
252
|
+
let key = state.selectedKey != null ? delegate.getKeyBelow(state.selectedKey) : delegate.getFirstKey();
|
|
253
|
+
if (key)
|
|
254
|
+
state.setSelectedKey(key);
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
let { typeSelectProps } = $fb3050f43d946246$export$e32c88dfddc6e1d8({
|
|
260
|
+
keyboardDelegate: delegate,
|
|
261
|
+
selectionManager: state.selectionManager,
|
|
262
|
+
onTypeSelect(key) {
|
|
263
|
+
state.setSelectedKey(key);
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
let { labelProps, fieldProps, descriptionProps, errorMessageProps } = $2baaea4c71418dea$export$294aa081a6c6f55d(__spreadProps(__spreadValues({}, props), {
|
|
267
|
+
labelElementType: "span"
|
|
268
|
+
}));
|
|
269
|
+
typeSelectProps.onKeyDown = typeSelectProps.onKeyDownCapture;
|
|
270
|
+
delete typeSelectProps.onKeyDownCapture;
|
|
271
|
+
let domProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
|
|
272
|
+
labelable: true
|
|
273
|
+
});
|
|
274
|
+
let triggerProps = $3ef42575df84b30b$export$9d1611c77c2fe928(typeSelectProps, menuTriggerProps, fieldProps);
|
|
275
|
+
let valueId = $bdb11010cef70236$export$f680877a34711e37();
|
|
276
|
+
return {
|
|
277
|
+
labelProps: __spreadProps(__spreadValues({}, labelProps), {
|
|
278
|
+
onClick: () => {
|
|
279
|
+
if (!props.isDisabled) {
|
|
280
|
+
ref.current.focus();
|
|
281
|
+
$507fabe10e71c6fb$export$8397ddfc504fdb9a("keyboard");
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}),
|
|
285
|
+
triggerProps: $3ef42575df84b30b$export$9d1611c77c2fe928(domProps, __spreadProps(__spreadValues({}, triggerProps), {
|
|
286
|
+
isDisabled,
|
|
287
|
+
onKeyDown: $ff5963eb1fccf552$export$e08e3b67e392101e(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),
|
|
288
|
+
onKeyUp: props.onKeyUp,
|
|
289
|
+
"aria-labelledby": [
|
|
290
|
+
valueId,
|
|
291
|
+
triggerProps["aria-labelledby"],
|
|
292
|
+
triggerProps["aria-label"] && !triggerProps["aria-labelledby"] ? triggerProps.id : null
|
|
293
|
+
].filter(Boolean).join(" "),
|
|
294
|
+
onFocus(e) {
|
|
295
|
+
if (state.isFocused)
|
|
296
|
+
return;
|
|
297
|
+
if (props.onFocus)
|
|
298
|
+
props.onFocus(e);
|
|
299
|
+
if (props.onFocusChange)
|
|
300
|
+
props.onFocusChange(true);
|
|
301
|
+
state.setFocused(true);
|
|
302
|
+
},
|
|
303
|
+
onBlur(e) {
|
|
304
|
+
if (state.isOpen)
|
|
305
|
+
return;
|
|
306
|
+
if (props.onBlur)
|
|
307
|
+
props.onBlur(e);
|
|
308
|
+
if (props.onFocusChange)
|
|
309
|
+
props.onFocusChange(false);
|
|
310
|
+
state.setFocused(false);
|
|
311
|
+
}
|
|
312
|
+
})),
|
|
313
|
+
valueProps: {
|
|
314
|
+
id: valueId
|
|
315
|
+
},
|
|
316
|
+
menuProps: __spreadProps(__spreadValues({}, menuProps), {
|
|
317
|
+
autoFocus: state.focusStrategy || true,
|
|
318
|
+
shouldSelectOnPressUp: true,
|
|
319
|
+
shouldFocusOnHover: true,
|
|
320
|
+
disallowEmptySelection: true,
|
|
321
|
+
onBlur: (e) => {
|
|
322
|
+
if (e.currentTarget.contains(e.relatedTarget))
|
|
323
|
+
return;
|
|
324
|
+
if (props.onBlur)
|
|
325
|
+
props.onBlur(e);
|
|
326
|
+
if (props.onFocusChange)
|
|
327
|
+
props.onFocusChange(false);
|
|
328
|
+
state.setFocused(false);
|
|
329
|
+
},
|
|
330
|
+
"aria-labelledby": [
|
|
331
|
+
fieldProps["aria-labelledby"],
|
|
332
|
+
triggerProps["aria-label"] && !fieldProps["aria-labelledby"] ? triggerProps.id : null
|
|
333
|
+
].filter(Boolean).join(" ")
|
|
334
|
+
}),
|
|
335
|
+
descriptionProps,
|
|
336
|
+
errorMessageProps
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function $bdd25dc72710631f$export$f809e80f58e251d1(props, state, triggerRef) {
|
|
340
|
+
let { autoComplete, name, isDisabled } = props;
|
|
341
|
+
let modality = $507fabe10e71c6fb$export$98e20ec92f614cfe();
|
|
342
|
+
let { visuallyHiddenProps } = $5c3e21d68f1c4674$export$a966af930f325cab();
|
|
343
|
+
var _state_selectedKey;
|
|
344
|
+
return {
|
|
345
|
+
containerProps: __spreadProps(__spreadValues({}, visuallyHiddenProps), {
|
|
346
|
+
"aria-hidden": true
|
|
347
|
+
}),
|
|
348
|
+
inputProps: {
|
|
349
|
+
type: "text",
|
|
350
|
+
tabIndex: modality == null || state.isFocused || state.isOpen ? -1 : 0,
|
|
351
|
+
style: {
|
|
352
|
+
fontSize: 16
|
|
353
|
+
},
|
|
354
|
+
onFocus: () => triggerRef.current.focus(),
|
|
355
|
+
disabled: isDisabled
|
|
356
|
+
},
|
|
357
|
+
selectProps: {
|
|
358
|
+
tabIndex: -1,
|
|
359
|
+
autoComplete,
|
|
360
|
+
disabled: isDisabled,
|
|
361
|
+
name,
|
|
362
|
+
size: state.collection.size,
|
|
363
|
+
value: (_state_selectedKey = state.selectedKey) !== null && _state_selectedKey !== void 0 ? _state_selectedKey : "",
|
|
364
|
+
onChange: (e) => state.setSelectedKey(e.target.value)
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
function $bdd25dc72710631f$export$cbd84cdb2e668835(props) {
|
|
369
|
+
let { state, triggerRef, label, name, isDisabled } = props;
|
|
370
|
+
let { containerProps, inputProps, selectProps } = $bdd25dc72710631f$export$f809e80f58e251d1(props, state, triggerRef);
|
|
371
|
+
var _state_selectedKey;
|
|
372
|
+
if (state.collection.size <= 300)
|
|
373
|
+
return /* @__PURE__ */ React__default.createElement("div", containerProps, /* @__PURE__ */ React__default.createElement("input", inputProps), /* @__PURE__ */ React__default.createElement("label", null, label, /* @__PURE__ */ React__default.createElement("select", selectProps, /* @__PURE__ */ React__default.createElement("option", null), [
|
|
374
|
+
...state.collection.getKeys()
|
|
375
|
+
].map((key) => {
|
|
376
|
+
let item = state.collection.getItem(key);
|
|
377
|
+
if (item.type === "item")
|
|
378
|
+
return /* @__PURE__ */ React__default.createElement("option", {
|
|
379
|
+
key: item.key,
|
|
380
|
+
value: item.key
|
|
381
|
+
}, item.textValue);
|
|
382
|
+
}))));
|
|
383
|
+
else if (name)
|
|
384
|
+
return /* @__PURE__ */ React__default.createElement("input", {
|
|
385
|
+
type: "hidden",
|
|
386
|
+
autoComplete: selectProps.autoComplete,
|
|
387
|
+
name,
|
|
388
|
+
disabled: isDisabled,
|
|
389
|
+
value: (_state_selectedKey = state.selectedKey) !== null && _state_selectedKey !== void 0 ? _state_selectedKey : ""
|
|
390
|
+
});
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
class $a02d57049d202695$export$d085fb9e920b5ca7 {
|
|
394
|
+
*[Symbol.iterator]() {
|
|
395
|
+
yield* __yieldStar(this.iterable);
|
|
396
|
+
}
|
|
397
|
+
get size() {
|
|
398
|
+
return this.keyMap.size;
|
|
399
|
+
}
|
|
400
|
+
getKeys() {
|
|
401
|
+
return this.keyMap.keys();
|
|
402
|
+
}
|
|
403
|
+
getKeyBefore(key) {
|
|
404
|
+
let node = this.keyMap.get(key);
|
|
405
|
+
return node ? node.prevKey : null;
|
|
406
|
+
}
|
|
407
|
+
getKeyAfter(key) {
|
|
408
|
+
let node = this.keyMap.get(key);
|
|
409
|
+
return node ? node.nextKey : null;
|
|
410
|
+
}
|
|
411
|
+
getFirstKey() {
|
|
412
|
+
return this.firstKey;
|
|
413
|
+
}
|
|
414
|
+
getLastKey() {
|
|
415
|
+
return this.lastKey;
|
|
416
|
+
}
|
|
417
|
+
getItem(key) {
|
|
418
|
+
return this.keyMap.get(key);
|
|
419
|
+
}
|
|
420
|
+
at(idx) {
|
|
421
|
+
const keys = [
|
|
422
|
+
...this.getKeys()
|
|
423
|
+
];
|
|
424
|
+
return this.getItem(keys[idx]);
|
|
425
|
+
}
|
|
426
|
+
getChildren(key) {
|
|
427
|
+
let node = this.keyMap.get(key);
|
|
428
|
+
return (node === null || node === void 0 ? void 0 : node.childNodes) || [];
|
|
429
|
+
}
|
|
430
|
+
constructor(nodes) {
|
|
431
|
+
this.keyMap = /* @__PURE__ */ new Map();
|
|
432
|
+
this.iterable = nodes;
|
|
433
|
+
let visit = (node) => {
|
|
434
|
+
this.keyMap.set(node.key, node);
|
|
435
|
+
if (node.childNodes && node.type === "section")
|
|
436
|
+
for (let child of node.childNodes)
|
|
437
|
+
visit(child);
|
|
438
|
+
};
|
|
439
|
+
for (let node of nodes)
|
|
440
|
+
visit(node);
|
|
441
|
+
let last;
|
|
442
|
+
let index = 0;
|
|
443
|
+
for (let [key, node] of this.keyMap) {
|
|
444
|
+
if (last) {
|
|
445
|
+
last.nextKey = key;
|
|
446
|
+
node.prevKey = last.key;
|
|
447
|
+
} else {
|
|
448
|
+
this.firstKey = key;
|
|
449
|
+
node.prevKey = void 0;
|
|
450
|
+
}
|
|
451
|
+
if (node.type === "item")
|
|
452
|
+
node.index = index++;
|
|
453
|
+
last = node;
|
|
454
|
+
last.nextKey = void 0;
|
|
455
|
+
}
|
|
456
|
+
this.lastKey = last === null || last === void 0 ? void 0 : last.key;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
function $e72dd72e1c76a225$export$2f645645f7bca764(props) {
|
|
460
|
+
let { filter } = props;
|
|
461
|
+
let selectionState = $7af3f5b51489e0b5$export$253fe78d46329472(props);
|
|
462
|
+
let disabledKeys = useMemo(() => props.disabledKeys ? new Set(props.disabledKeys) : /* @__PURE__ */ new Set(), [
|
|
463
|
+
props.disabledKeys
|
|
464
|
+
]);
|
|
465
|
+
let factory = useCallback((nodes) => filter ? new $a02d57049d202695$export$d085fb9e920b5ca7(filter(nodes)) : new $a02d57049d202695$export$d085fb9e920b5ca7(nodes), [
|
|
466
|
+
filter
|
|
467
|
+
]);
|
|
468
|
+
let context = useMemo(() => ({
|
|
469
|
+
suppressTextValueWarning: props.suppressTextValueWarning
|
|
470
|
+
}), [
|
|
471
|
+
props.suppressTextValueWarning
|
|
472
|
+
]);
|
|
473
|
+
let collection = $7613b1592d41b092$export$6cd28814d92fa9c9(props, factory, context);
|
|
474
|
+
let selectionManager = useMemo(() => new $d496c0a20b6e58ec$export$6c8a5aaad13c9852(collection, selectionState), [
|
|
475
|
+
collection,
|
|
476
|
+
selectionState
|
|
477
|
+
]);
|
|
478
|
+
const cachedCollection = useRef(null);
|
|
479
|
+
useEffect(() => {
|
|
480
|
+
if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey)) {
|
|
481
|
+
const startItem = cachedCollection.current.getItem(selectionState.focusedKey);
|
|
482
|
+
const cachedItemNodes = [
|
|
483
|
+
...cachedCollection.current.getKeys()
|
|
484
|
+
].map((key) => {
|
|
485
|
+
const itemNode = cachedCollection.current.getItem(key);
|
|
486
|
+
return itemNode.type === "item" ? itemNode : null;
|
|
487
|
+
}).filter((node) => node !== null);
|
|
488
|
+
const itemNodes = [
|
|
489
|
+
...collection.getKeys()
|
|
490
|
+
].map((key) => {
|
|
491
|
+
const itemNode = collection.getItem(key);
|
|
492
|
+
return itemNode.type === "item" ? itemNode : null;
|
|
493
|
+
}).filter((node) => node !== null);
|
|
494
|
+
const diff = cachedItemNodes.length - itemNodes.length;
|
|
495
|
+
let index = Math.min(diff > 1 ? Math.max(startItem.index - diff + 1, 0) : startItem.index, itemNodes.length - 1);
|
|
496
|
+
let newNode;
|
|
497
|
+
while (index >= 0) {
|
|
498
|
+
if (!selectionManager.isDisabled(itemNodes[index].key)) {
|
|
499
|
+
newNode = itemNodes[index];
|
|
500
|
+
break;
|
|
501
|
+
}
|
|
502
|
+
if (index < itemNodes.length - 1)
|
|
503
|
+
index++;
|
|
504
|
+
else {
|
|
505
|
+
if (index > startItem.index)
|
|
506
|
+
index = startItem.index;
|
|
507
|
+
index--;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
selectionState.setFocusedKey(newNode ? newNode.key : null);
|
|
511
|
+
}
|
|
512
|
+
cachedCollection.current = collection;
|
|
513
|
+
}, [
|
|
514
|
+
collection,
|
|
515
|
+
selectionManager,
|
|
516
|
+
selectionState,
|
|
517
|
+
selectionState.focusedKey
|
|
518
|
+
]);
|
|
519
|
+
return {
|
|
520
|
+
collection,
|
|
521
|
+
disabledKeys,
|
|
522
|
+
selectionManager
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
function $a0d645289fe9b86b$export$e7f05e985daf4b5f(props) {
|
|
526
|
+
var _props_defaultSelectedKey;
|
|
527
|
+
let [selectedKey, setSelectedKey] = $458b0a5536c1a7cf$export$40bfa8c7b0832715(props.selectedKey, (_props_defaultSelectedKey = props.defaultSelectedKey) !== null && _props_defaultSelectedKey !== void 0 ? _props_defaultSelectedKey : null, props.onSelectionChange);
|
|
528
|
+
let selectedKeys = useMemo(() => selectedKey != null ? [
|
|
529
|
+
selectedKey
|
|
530
|
+
] : [], [
|
|
531
|
+
selectedKey
|
|
532
|
+
]);
|
|
533
|
+
let { collection, disabledKeys, selectionManager } = $e72dd72e1c76a225$export$2f645645f7bca764(__spreadProps(__spreadValues({}, props), {
|
|
534
|
+
selectionMode: "single",
|
|
535
|
+
disallowEmptySelection: true,
|
|
536
|
+
allowDuplicateSelectionEvents: true,
|
|
537
|
+
selectedKeys,
|
|
538
|
+
onSelectionChange: (keys) => {
|
|
539
|
+
let key = keys.values().next().value;
|
|
540
|
+
if (key === selectedKey && props.onSelectionChange)
|
|
541
|
+
props.onSelectionChange(key);
|
|
542
|
+
setSelectedKey(key);
|
|
543
|
+
}
|
|
544
|
+
}));
|
|
545
|
+
let selectedItem = selectedKey != null ? collection.getItem(selectedKey) : null;
|
|
546
|
+
return {
|
|
547
|
+
collection,
|
|
548
|
+
disabledKeys,
|
|
549
|
+
selectionManager,
|
|
550
|
+
selectedKey,
|
|
551
|
+
setSelectedKey,
|
|
552
|
+
selectedItem
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
function $2bc3a590c5373a4e$export$5159ec8b34d4ec12(props) {
|
|
556
|
+
let triggerState = $a28c903ee9ad8dc5$export$79fefeb1c2091ac3(props);
|
|
557
|
+
let listState = $a0d645289fe9b86b$export$e7f05e985daf4b5f(__spreadProps(__spreadValues({}, props), {
|
|
558
|
+
onSelectionChange: (key) => {
|
|
559
|
+
if (props.onSelectionChange != null)
|
|
560
|
+
props.onSelectionChange(key);
|
|
561
|
+
triggerState.close();
|
|
562
|
+
}
|
|
563
|
+
}));
|
|
564
|
+
let [isFocused, setFocused] = useState(false);
|
|
565
|
+
return __spreadProps(__spreadValues(__spreadValues({}, listState), triggerState), {
|
|
566
|
+
open() {
|
|
567
|
+
if (listState.collection.size !== 0)
|
|
568
|
+
triggerState.open();
|
|
569
|
+
},
|
|
570
|
+
toggle(focusStrategy) {
|
|
571
|
+
if (listState.collection.size !== 0)
|
|
572
|
+
triggerState.toggle(focusStrategy);
|
|
573
|
+
},
|
|
574
|
+
isFocused,
|
|
575
|
+
setFocused
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
const InternalSelectContext = createContext(null);
|
|
579
|
+
function useInternalSelectContext() {
|
|
580
|
+
const selectContext = useContext(InternalSelectContext);
|
|
581
|
+
if (!selectContext) {
|
|
582
|
+
throw new Error("InternalSelectContext must be used inside a <Select />");
|
|
583
|
+
}
|
|
584
|
+
return selectContext;
|
|
585
|
+
}
|
|
586
|
+
const underlay = "_underlay_134q0_5";
|
|
587
|
+
const listboxRoot = "_listboxRoot_134q0_10";
|
|
588
|
+
const listbox = "_listbox_134q0_10";
|
|
589
|
+
const listboxList = "_listboxList_134q0_65";
|
|
590
|
+
const sectionList = "_sectionList_134q0_66";
|
|
591
|
+
const optionContent = "_optionContent_134q0_72";
|
|
592
|
+
const separator = "_separator_134q0_73";
|
|
593
|
+
const option = "_option_134q0_72";
|
|
594
|
+
const fieldRoot = "_fieldRoot_134q0_116";
|
|
595
|
+
const selectField = "_selectField_134q0_137";
|
|
596
|
+
const selectSizeSm = "_selectSizeSm_134q0_176";
|
|
597
|
+
const selectSizeLg = "_selectSizeLg_134q0_190";
|
|
598
|
+
const selectFieldError = "_selectFieldError_134q0_198";
|
|
599
|
+
const selectFieldIconStart = "_selectFieldIconStart_134q0_206";
|
|
600
|
+
const selectFieldIconEnd = "_selectFieldIconEnd_134q0_210";
|
|
601
|
+
const selectFieldIconContainer = "_selectFieldIconContainer_134q0_214";
|
|
602
|
+
const selectFieldText = "_selectFieldText_134q0_220";
|
|
603
|
+
const listboxOpen = "_listboxOpen_134q0_224";
|
|
604
|
+
const styles = {
|
|
605
|
+
underlay,
|
|
606
|
+
listboxRoot,
|
|
607
|
+
listbox,
|
|
608
|
+
listboxList,
|
|
609
|
+
sectionList,
|
|
610
|
+
optionContent,
|
|
611
|
+
separator,
|
|
612
|
+
option,
|
|
613
|
+
fieldRoot,
|
|
614
|
+
selectField,
|
|
615
|
+
selectSizeSm,
|
|
616
|
+
selectSizeLg,
|
|
617
|
+
selectFieldError,
|
|
618
|
+
selectFieldIconStart,
|
|
619
|
+
selectFieldIconEnd,
|
|
620
|
+
selectFieldIconContainer,
|
|
621
|
+
selectFieldText,
|
|
622
|
+
listboxOpen
|
|
623
|
+
};
|
|
624
|
+
function SelectTrigger(props) {
|
|
625
|
+
const { size = "md", valueProps, iconAtStart, hasError, isDisabled, children } = props;
|
|
626
|
+
const { triggerProps, triggerRef, selectState } = useInternalSelectContext();
|
|
627
|
+
const hasStartIcon = !!iconAtStart;
|
|
628
|
+
const className = classNames(styles.selectField, styles.selectFieldIconEnd, selectState.isOpen && styles.listboxOpen, hasError && styles.selectFieldError, hasStartIcon && styles.selectFieldIconStart, styles[variationName("selectSize", size)]);
|
|
629
|
+
return React__default.createElement("div", {
|
|
630
|
+
className: styles.selectFieldIconContainer
|
|
631
|
+
}, hasStartIcon && React__default.createElement(InputIcon, {
|
|
632
|
+
alignment: "start",
|
|
633
|
+
icon: iconAtStart,
|
|
634
|
+
size,
|
|
635
|
+
isDisabled
|
|
636
|
+
}), React__default.createElement(UnstyledButton, __spreadProps(__spreadValues({}, triggerProps), {
|
|
637
|
+
ref: triggerRef,
|
|
638
|
+
className
|
|
639
|
+
}), React__default.createElement("span", __spreadProps(__spreadValues({}, valueProps), {
|
|
640
|
+
className: styles.selectFieldText
|
|
641
|
+
}), children)), React__default.createElement(InputIcon, {
|
|
642
|
+
alignment: "end",
|
|
643
|
+
icon: ExpandMore400,
|
|
644
|
+
size,
|
|
645
|
+
isDisabled
|
|
646
|
+
}));
|
|
647
|
+
}
|
|
648
|
+
function SelectField(props) {
|
|
649
|
+
const { isLabelVisuallyHidden = false, isDisabled = false, validationState = "valid", isLabelEmphasized = false, size = "md", label, errorText, helperText, placeholder, iconAtStart, labelProps, valueProps, errorTextProps, helperTextProps } = props;
|
|
650
|
+
const { triggerRef, selectState } = useInternalSelectContext();
|
|
651
|
+
const hasError = validationState === "invalid";
|
|
652
|
+
const showErrorText = hasError && errorText;
|
|
653
|
+
const showHelperText = !showErrorText && helperText;
|
|
654
|
+
const captionProps = showHelperText ? helperTextProps : errorTextProps;
|
|
655
|
+
const captionText = showHelperText ? helperText : errorText;
|
|
656
|
+
return React__default.createElement("div", {
|
|
657
|
+
className: classNames(styles.fieldRoot)
|
|
658
|
+
}, React__default.createElement(Label, __spreadValues({
|
|
659
|
+
isLabelVisuallyHidden,
|
|
660
|
+
fieldSize: size,
|
|
661
|
+
hasError,
|
|
662
|
+
isLabelEmphasized
|
|
663
|
+
}, labelProps), label), React__default.createElement($bdd25dc72710631f$export$cbd84cdb2e668835, {
|
|
664
|
+
isDisabled,
|
|
665
|
+
state: selectState,
|
|
666
|
+
triggerRef,
|
|
667
|
+
label
|
|
668
|
+
}), React__default.createElement(SelectTrigger, {
|
|
669
|
+
valueProps,
|
|
670
|
+
iconAtStart,
|
|
671
|
+
hasError,
|
|
672
|
+
isDisabled,
|
|
673
|
+
size
|
|
674
|
+
}, selectState.selectedItem ? selectState.selectedItem.rendered : React__default.createElement(Text, {
|
|
675
|
+
color: "subdued"
|
|
676
|
+
}, placeholder)), (showErrorText || showHelperText) && React__default.createElement(InputCaption, __spreadValues({
|
|
677
|
+
variant: showHelperText ? "helper" : "error"
|
|
678
|
+
}, captionProps), captionText));
|
|
679
|
+
}
|
|
680
|
+
function SelectOption(_props) {
|
|
681
|
+
return null;
|
|
682
|
+
}
|
|
683
|
+
Object.assign(SelectOption, $c1d7fb2ec91bae71$export$6d08773d2e66f8f2);
|
|
684
|
+
function SelectOptionContent({ item, state }) {
|
|
685
|
+
const ref = React__default.useRef(null);
|
|
686
|
+
const { optionProps, isSelected, isFocused, isDisabled } = $293f70390ea03370$export$497855f14858aa34({
|
|
687
|
+
key: item.key
|
|
688
|
+
}, state, ref);
|
|
689
|
+
return React__default.createElement("li", __spreadProps(__spreadValues({}, optionProps), {
|
|
690
|
+
ref,
|
|
691
|
+
className: styles.option,
|
|
692
|
+
"data-is-disabled": isDisabled,
|
|
693
|
+
"data-is-focused": isFocused,
|
|
694
|
+
"data-is-selected": isSelected
|
|
695
|
+
}), React__default.createElement("div", {
|
|
696
|
+
className: styles.optionContent
|
|
697
|
+
}, React__default.createElement(Text, {
|
|
698
|
+
variant: "body1",
|
|
699
|
+
truncate: true
|
|
700
|
+
}, item.rendered)));
|
|
701
|
+
}
|
|
702
|
+
function SelectSection(_props) {
|
|
703
|
+
return null;
|
|
704
|
+
}
|
|
705
|
+
Object.assign(SelectSection, $9fc4852771d079eb$export$6e2c8f0811a474ce);
|
|
706
|
+
function SelectSectionContent({ section, state }) {
|
|
707
|
+
const { itemProps, groupProps } = $af383d3bef1cfdc9$export$c3f9f39876e4bc7({
|
|
708
|
+
"aria-label": section["aria-label"]
|
|
709
|
+
});
|
|
710
|
+
const { separatorProps } = $f4b273590fab9f93$export$52210f68a14655d0({
|
|
711
|
+
elementType: "li"
|
|
712
|
+
});
|
|
713
|
+
return React__default.createElement(React__default.Fragment, null, section.key !== state.collection.getFirstKey() && React__default.createElement("li", __spreadProps(__spreadValues({}, separatorProps), {
|
|
714
|
+
className: styles.separator
|
|
715
|
+
})), React__default.createElement("li", __spreadValues({}, itemProps), section.hasChildNodes && React__default.createElement("ul", __spreadProps(__spreadValues({}, groupProps), {
|
|
716
|
+
className: styles.sectionList
|
|
717
|
+
}), [...section.childNodes].map((item) => {
|
|
718
|
+
return React__default.createElement(SelectOptionContent, {
|
|
719
|
+
key: item.key,
|
|
720
|
+
item,
|
|
721
|
+
state
|
|
722
|
+
});
|
|
723
|
+
}))));
|
|
724
|
+
}
|
|
725
|
+
function SelectOverlay() {
|
|
726
|
+
const { selectState, triggerWidth } = useInternalSelectContext();
|
|
727
|
+
if (!selectState.isOpen || triggerWidth === null) {
|
|
728
|
+
return null;
|
|
729
|
+
}
|
|
730
|
+
return React__default.createElement(SelectOverlayContent, null);
|
|
731
|
+
}
|
|
732
|
+
function SelectOverlayContent() {
|
|
733
|
+
const { selectState, triggerRef, listBoxPropsFromSelect, triggerWidth } = useInternalSelectContext();
|
|
734
|
+
const popoverRef = React__default.useRef(null);
|
|
735
|
+
const listBoxRef = React__default.useRef(null);
|
|
736
|
+
const { popoverProps, underlayProps } = $f2f8a6077418541e$export$542a6fd13ac93354({
|
|
737
|
+
containerPadding: OVERLAY_PADDING_FROM_CONTAINER,
|
|
738
|
+
maxHeight: ITEM_HEIGHT * Infinity + Y_PADDING_INSIDE_OVERLAY * 2 + 2,
|
|
739
|
+
offset: OVERLAY_OFFSET,
|
|
740
|
+
placement: DEFAULT_PLACEMENT,
|
|
741
|
+
popoverRef,
|
|
742
|
+
scrollRef: listBoxRef,
|
|
743
|
+
triggerRef
|
|
744
|
+
}, selectState);
|
|
745
|
+
const { listBoxProps } = $c132121280ec012d$export$50eacbbf140a3141(listBoxPropsFromSelect, selectState, listBoxRef);
|
|
746
|
+
const style = __spreadValues(__spreadValues({}, popoverProps.style), getUnmergedPopoverStyles(DEFAULT_WIDTH, triggerWidth));
|
|
747
|
+
return React__default.createElement($f57aed4a881a3485$export$b47c3594eab58386, null, React__default.createElement("div", __spreadProps(__spreadValues({}, underlayProps), {
|
|
748
|
+
className: styles.underlay
|
|
749
|
+
})), React__default.createElement("div", __spreadProps(__spreadValues({}, $3ef42575df84b30b$export$9d1611c77c2fe928(popoverProps, {
|
|
750
|
+
style
|
|
751
|
+
})), {
|
|
752
|
+
ref: popoverRef,
|
|
753
|
+
className: styles.listboxRoot
|
|
754
|
+
}), React__default.createElement($86ea4cb521eb2e37$export$2317d149ed6f78c4, {
|
|
755
|
+
onDismiss: selectState.close
|
|
756
|
+
}), React__default.createElement("div", __spreadProps(__spreadValues({}, listBoxProps), {
|
|
757
|
+
ref: listBoxRef,
|
|
758
|
+
className: styles.listbox,
|
|
759
|
+
"data-width": DEFAULT_WIDTH,
|
|
760
|
+
"data-max-items-until-scroll": Infinity,
|
|
761
|
+
"data-overlayscrollbars-initialize": true
|
|
762
|
+
}), React__default.createElement("ul", {
|
|
763
|
+
className: styles.listboxList
|
|
764
|
+
}, [...selectState.collection].map((item) => {
|
|
765
|
+
return item.type === "section" ? React__default.createElement(SelectSectionContent, {
|
|
766
|
+
key: item.key,
|
|
767
|
+
section: item,
|
|
768
|
+
state: selectState
|
|
769
|
+
}) : React__default.createElement(SelectOptionContent, {
|
|
770
|
+
key: item.key,
|
|
771
|
+
item,
|
|
772
|
+
state: selectState
|
|
773
|
+
});
|
|
774
|
+
}))), React__default.createElement($86ea4cb521eb2e37$export$2317d149ed6f78c4, {
|
|
775
|
+
onDismiss: selectState.close
|
|
776
|
+
})));
|
|
777
|
+
}
|
|
778
|
+
function Select(props) {
|
|
779
|
+
const { isLabelVisuallyHidden, isDisabled, validationState, isLabelEmphasized, size = "md", label, errorText, helperText, placeholder, iconAtStart } = props;
|
|
780
|
+
const triggerRef = React__default.useRef(null);
|
|
781
|
+
const selectState = $2bc3a590c5373a4e$export$5159ec8b34d4ec12(props);
|
|
782
|
+
const { labelProps, valueProps, triggerProps, menuProps: listBoxPropsFromSelect, descriptionProps: helperTextProps, errorMessageProps: errorTextProps } = $58aed456727eb0f3$export$e64b2f635402ca43(props, selectState, triggerRef);
|
|
783
|
+
const triggerWidth = useTriggerWidth(triggerRef);
|
|
784
|
+
const context = useMemo(() => {
|
|
785
|
+
return {
|
|
786
|
+
triggerProps,
|
|
787
|
+
listBoxPropsFromSelect,
|
|
788
|
+
triggerRef,
|
|
789
|
+
selectState,
|
|
790
|
+
triggerWidth
|
|
791
|
+
};
|
|
792
|
+
}, [triggerProps, listBoxPropsFromSelect, selectState, triggerWidth]);
|
|
793
|
+
return React__default.createElement(InternalSelectContext.Provider, {
|
|
794
|
+
value: context
|
|
795
|
+
}, React__default.createElement(SelectField, {
|
|
796
|
+
isLabelVisuallyHidden,
|
|
797
|
+
isDisabled,
|
|
798
|
+
validationState,
|
|
799
|
+
isLabelEmphasized,
|
|
800
|
+
size,
|
|
801
|
+
label,
|
|
802
|
+
errorText,
|
|
803
|
+
helperText,
|
|
804
|
+
placeholder,
|
|
805
|
+
iconAtStart,
|
|
806
|
+
labelProps,
|
|
807
|
+
valueProps,
|
|
808
|
+
helperTextProps,
|
|
809
|
+
errorTextProps
|
|
810
|
+
}), React__default.createElement(SelectOverlay, null));
|
|
811
|
+
}
|
|
812
|
+
Select.Section = SelectSection;
|
|
813
|
+
Select.Option = SelectOption;
|
|
814
|
+
export {
|
|
815
|
+
Select
|
|
816
|
+
};
|