@charcoal-ui/react 2.0.1 → 2.1.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.
Files changed (63) hide show
  1. package/dist/_lib/compat.d.ts +13 -13
  2. package/dist/_lib/index.d.ts +25 -25
  3. package/dist/components/Button/index.d.ts +21 -21
  4. package/dist/components/Button/index.story.d.ts +35 -35
  5. package/dist/components/Checkbox/index.d.ts +20 -20
  6. package/dist/components/Checkbox/index.story.d.ts +15 -15
  7. package/dist/components/Clickable/index.d.ts +18 -18
  8. package/dist/components/Clickable/index.story.d.ts +8 -8
  9. package/dist/components/DropdownSelector/Listbox.d.ts +9 -9
  10. package/dist/components/DropdownSelector/Popover.d.ts +9 -9
  11. package/dist/components/DropdownSelector/index.d.ts +31 -31
  12. package/dist/components/DropdownSelector/index.story.d.ts +21 -21
  13. package/dist/components/FieldLabel/index.d.ts +10 -10
  14. package/dist/components/Icon/index.d.ts +11 -11
  15. package/dist/components/Icon/index.story.d.ts +23 -23
  16. package/dist/components/IconButton/index.d.ts +13 -13
  17. package/dist/components/IconButton/index.story.d.ts +28 -28
  18. package/dist/components/LoadingSpinner/index.d.ts +14 -14
  19. package/dist/components/LoadingSpinner/index.story.d.ts +9 -9
  20. package/dist/components/Modal/ModalPlumbing.d.ts +4 -4
  21. package/dist/components/Modal/index.d.ts +41 -17
  22. package/dist/components/Modal/index.d.ts.map +1 -1
  23. package/dist/components/Modal/index.story.d.ts +32 -32
  24. package/dist/components/MultiSelect/context.d.ts +13 -13
  25. package/dist/components/MultiSelect/index.d.ts +23 -23
  26. package/dist/components/MultiSelect/index.story.d.ts +74 -74
  27. package/dist/components/MultiSelect/index.test.d.ts +1 -1
  28. package/dist/components/Radio/index.d.ts +23 -23
  29. package/dist/components/Radio/index.story.d.ts +33 -33
  30. package/dist/components/Radio/index.test.d.ts +1 -1
  31. package/dist/components/SegmentedControl/RadioGroupContext.d.ts +8 -8
  32. package/dist/components/SegmentedControl/index.d.ts +19 -19
  33. package/dist/components/SegmentedControl/index.story.d.ts +10 -10
  34. package/dist/components/Switch/index.d.ts +15 -15
  35. package/dist/components/Switch/index.story.d.ts +13 -13
  36. package/dist/components/TagItem/index.d.ts +25 -0
  37. package/dist/components/TagItem/index.d.ts.map +1 -0
  38. package/dist/components/TagItem/index.story.d.ts +26 -0
  39. package/dist/components/TagItem/index.story.d.ts.map +1 -0
  40. package/dist/components/TextField/index.d.ts +43 -43
  41. package/dist/components/TextField/index.story.d.ts +29 -29
  42. package/dist/components/a11y.test.d.ts +1 -1
  43. package/dist/core/ComponentAbstraction.d.ts +23 -23
  44. package/dist/core/OverlayProvider.d.ts +2 -0
  45. package/dist/core/OverlayProvider.d.ts.map +1 -0
  46. package/dist/core/SSRProvider.d.ts +1 -1
  47. package/dist/index.cjs +3333 -3297
  48. package/dist/index.cjs.map +1 -1
  49. package/dist/index.d.ts +18 -16
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +4401 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/styled.d.ts +92 -92
  54. package/package.json +16 -14
  55. package/src/components/Modal/index.tsx +24 -0
  56. package/src/components/TagItem/index.story.tsx +188 -0
  57. package/src/components/TagItem/index.tsx +176 -0
  58. package/src/core/OverlayProvider.tsx +1 -0
  59. package/src/index.ts +2 -0
  60. package/dist/index.modern.js +0 -4685
  61. package/dist/index.modern.js.map +0 -1
  62. package/dist/index.module.js +0 -4371
  63. package/dist/index.module.js.map +0 -1
@@ -1,4371 +0,0 @@
1
- import React, { useContext, useCallback, createContext, useMemo, useRef, useState, useEffect, useImperativeHandle, memo, Fragment, forwardRef } from 'react';
2
- import { useSSRSafeId, useIsSSR } from '@react-aria/ssr';
3
- export { SSRProvider } from '@react-aria/ssr';
4
- import styled, { css, useTheme, keyframes } from 'styled-components';
5
- import { createTheme, useMedia } from '@charcoal-ui/styled';
6
- import { disabledSelector, px, maxWidth } from '@charcoal-ui/utils';
7
- import warning from 'warning';
8
- import { useSwitch } from '@react-aria/switch';
9
- import { useToggleState, useSelectState, Item, useRadioGroupState } from 'react-stately';
10
- import { useTextField } from '@react-aria/textfield';
11
- import { useVisuallyHidden } from '@react-aria/visually-hidden';
12
- import '@charcoal-ui/icons';
13
- import { useOverlay, usePreventScroll, useModalOverlay, Overlay, DismissButton } from '@react-aria/overlays';
14
- import { FocusScope, focusSafely, getFocusableTreeWalker, useFocusRing } from '@react-aria/focus';
15
- import { useDialog } from '@react-aria/dialog';
16
- import { animated, useTransition, easings } from 'react-spring';
17
- import { transparentize } from 'polished';
18
- import { useSelect, HiddenSelect } from '@react-aria/select';
19
- import { useButton } from '@react-aria/button';
20
- import { useRadioGroup, useRadio } from '@react-aria/radio';
21
- import { useCheckbox } from '@react-aria/checkbox';
22
-
23
- function _extends() {
24
- _extends = Object.assign || function (target) {
25
- for (var i = 1; i < arguments.length; i++) {
26
- var source = arguments[i];
27
-
28
- for (var key in source) {
29
- if (Object.prototype.hasOwnProperty.call(source, key)) {
30
- target[key] = source[key];
31
- }
32
- }
33
- }
34
-
35
- return target;
36
- };
37
-
38
- return _extends.apply(this, arguments);
39
- }
40
-
41
- function _objectWithoutPropertiesLoose(source, excluded) {
42
- if (source == null) return {};
43
- var target = {};
44
- var sourceKeys = Object.keys(source);
45
- var key, i;
46
-
47
- for (i = 0; i < sourceKeys.length; i++) {
48
- key = sourceKeys[i];
49
- if (excluded.indexOf(key) >= 0) continue;
50
- target[key] = source[key];
51
- }
52
-
53
- return target;
54
- }
55
-
56
- function _taggedTemplateLiteralLoose(strings, raw) {
57
- if (!raw) {
58
- raw = strings.slice(0);
59
- }
60
-
61
- strings.raw = raw;
62
- return strings;
63
- }
64
-
65
- function _unsupportedIterableToArray(o, minLen) {
66
- if (!o) return;
67
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
68
- var n = Object.prototype.toString.call(o).slice(8, -1);
69
- if (n === "Object" && o.constructor) n = o.constructor.name;
70
- if (n === "Map" || n === "Set") return Array.from(o);
71
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
72
- }
73
-
74
- function _arrayLikeToArray(arr, len) {
75
- if (len == null || len > arr.length) len = arr.length;
76
-
77
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
78
-
79
- return arr2;
80
- }
81
-
82
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
83
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
84
- if (it) return (it = it.call(o)).next.bind(it);
85
-
86
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
87
- if (it) o = it;
88
- var i = 0;
89
- return function () {
90
- if (i >= o.length) return {
91
- done: true
92
- };
93
- return {
94
- done: false,
95
- value: o[i++]
96
- };
97
- };
98
- }
99
-
100
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
101
- }
102
-
103
- var _excluded$d = ["to", "children"];
104
- var DefaultLink = React.forwardRef(function DefaultLink(_ref, ref) {
105
- var to = _ref.to,
106
- children = _ref.children,
107
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$d);
108
-
109
- return /*#__PURE__*/React.createElement("a", _extends({
110
- href: to,
111
- ref: ref
112
- }, rest), children);
113
- });
114
- var DefaultValue = {
115
- Link: DefaultLink
116
- };
117
- var ComponentAbstractionContext = React.createContext(DefaultValue);
118
- function ComponentAbstraction(_ref2) {
119
- var children = _ref2.children,
120
- components = _ref2.components;
121
- return /*#__PURE__*/React.createElement(ComponentAbstractionContext.Provider, {
122
- value: _extends({}, DefaultValue, components)
123
- }, children);
124
- }
125
- function useComponentAbstraction() {
126
- return useContext(ComponentAbstractionContext);
127
- }
128
-
129
- /**
130
- * 今後ポートされる予定の汎用的な関数群
131
- */
132
- function unreachable(value) {
133
- throw new Error(arguments.length === 0 ? 'unreachable' : "unreachable (" + JSON.stringify(value) + ")");
134
- }
135
-
136
- var theme$2 = createTheme(styled);
137
-
138
- var _templateObject$e, _templateObject2$c, _templateObject3$c;
139
-
140
- var _excluded$c = ["onClick", "disabled"];
141
- var Clickable = React.forwardRef(function Clickable(props, ref) {
142
- var _useComponentAbstract = useComponentAbstraction(),
143
- Link = _useComponentAbstract.Link;
144
-
145
- if ('to' in props) {
146
- var onClick = props.onClick,
147
- _props$disabled = props.disabled,
148
- disabled = _props$disabled === void 0 ? false : _props$disabled,
149
- rest = _objectWithoutPropertiesLoose(props, _excluded$c);
150
-
151
- return /*#__PURE__*/React.createElement(A, _extends({}, rest, {
152
- as: disabled ? undefined : Link,
153
- onClick: disabled ? undefined : onClick,
154
- "aria-disabled": disabled,
155
- ref: ref
156
- }));
157
- } else {
158
- return /*#__PURE__*/React.createElement(Button$1, _extends({}, props, {
159
- ref: ref
160
- }));
161
- }
162
- });
163
- var clickableCss = css(_templateObject$e || (_templateObject$e = _taggedTemplateLiteralLoose(["\n /* Clickable style */\n cursor: pointer;\n\n ", " {\n cursor: default;\n }\n"])), disabledSelector);
164
- var Button$1 = styled.button(_templateObject2$c || (_templateObject2$c = _taggedTemplateLiteralLoose(["\n /* Reset button appearance */\n appearance: none;\n background: transparent;\n padding: 0;\n border-style: none;\n outline: none;\n color: inherit;\n text-rendering: inherit;\n letter-spacing: inherit;\n word-spacing: inherit;\n\n &:focus {\n outline: none;\n }\n\n /* Change the font styles in all browsers. */\n font: inherit;\n\n /* Remove the margin in Firefox and Safari. */\n margin: 0;\n\n /* Show the overflow in Edge. */\n overflow: visible;\n\n /* Remove the inheritance of text transform in Firefox. */\n text-transform: none;\n\n /* Remove the inner border and padding in Firefox. */\n &::-moz-focus-inner {\n border-style: none;\n padding: 0;\n }\n\n ", "\n"])), clickableCss);
165
- var A = styled.span(_templateObject3$c || (_templateObject3$c = _taggedTemplateLiteralLoose(["\n /* Reset a-tag appearance */\n color: inherit;\n\n &:focus {\n outline: none;\n }\n\n .text {\n top: calc(1em + 2em);\n }\n\n ", "\n"])), clickableCss);
166
-
167
- var _templateObject$d;
168
-
169
- var _excluded$b = ["children", "variant", "size", "fixed", "disabled"];
170
- var Button = React.forwardRef(function Button(_ref, ref) {
171
- var children = _ref.children,
172
- _ref$variant = _ref.variant,
173
- variant = _ref$variant === void 0 ? 'Default' : _ref$variant,
174
- _ref$size = _ref.size,
175
- size = _ref$size === void 0 ? 'M' : _ref$size,
176
- _ref$fixed = _ref.fixed,
177
- fixed = _ref$fixed === void 0 ? false : _ref$fixed,
178
- _ref$disabled = _ref.disabled,
179
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
180
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$b);
181
-
182
- return /*#__PURE__*/React.createElement(StyledButton, _extends({}, rest, {
183
- disabled: disabled,
184
- variant: variant,
185
- size: size,
186
- fixed: fixed,
187
- ref: ref
188
- }), children);
189
- });
190
- var StyledButton = styled(Clickable).withConfig({
191
- shouldForwardProp: function shouldForwardProp(prop) {
192
- // fixed は <button> 要素に渡ってはいけない
193
- return prop !== 'fixed';
194
- }
195
- }).attrs(styledProps$1)(_templateObject$d || (_templateObject$d = _taggedTemplateLiteralLoose(["\n width: ", ";\n display: inline-grid;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n user-select: none;\n white-space: nowrap;\n\n ", "\n\n /* \u3088\u304F\u8003\u3048\u305F\u3089height=32\u3063\u3066\u5B9A\u7FA9\u304C\u5B58\u5728\u3057\u306A\u3044\u306A... */\n height: ", "px;\n"])), function (p) {
196
- return p.fixed ? 'stretch' : 'min-content';
197
- }, function (p) {
198
- return theme$2(function (o) {
199
- return [o.font[p.font].hover.press, o.bg[p.background].hover.press, o.typography(14).bold.preserveHalfLeading, o.padding.horizontal(p.padding), o.disabled, o.borderRadius('oval'), o.outline["default"].focus];
200
- });
201
- }, function (p) {
202
- return p.height;
203
- });
204
-
205
- function styledProps$1(props) {
206
- return _extends({}, props, variantToProps$1(props.variant), sizeToProps$1(props.size));
207
- }
208
-
209
- function variantToProps$1(variant) {
210
- switch (variant) {
211
- case 'Overlay':
212
- return {
213
- font: 'text5',
214
- background: 'surface4'
215
- };
216
-
217
- case 'Default':
218
- return {
219
- font: 'text2',
220
- background: 'surface3'
221
- };
222
-
223
- case 'Primary':
224
- return {
225
- font: 'text5',
226
- background: 'brand'
227
- };
228
-
229
- case 'Navigation':
230
- return {
231
- font: 'text5',
232
- background: 'surface6'
233
- };
234
-
235
- case 'Danger':
236
- return {
237
- font: 'text5',
238
- background: 'assertive'
239
- };
240
-
241
- default:
242
- return unreachable(variant);
243
- }
244
- }
245
-
246
- function sizeToProps$1(size) {
247
- switch (size) {
248
- case 'S':
249
- return {
250
- height: 32,
251
- padding: 16
252
- };
253
-
254
- case 'M':
255
- return {
256
- height: 40,
257
- padding: 24
258
- };
259
- }
260
- }
261
-
262
- var _templateObject$c;
263
-
264
- var _excluded$a = ["variant", "size", "icon"];
265
- var IconButton = React.forwardRef(function IconButtonInner(_ref, ref) {
266
- var _ref$variant = _ref.variant,
267
- variant = _ref$variant === void 0 ? 'Default' : _ref$variant,
268
- _ref$size = _ref.size,
269
- size = _ref$size === void 0 ? 'M' : _ref$size,
270
- icon = _ref.icon,
271
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$a);
272
-
273
- validateIconSize(size, icon);
274
- return /*#__PURE__*/React.createElement(StyledIconButton, _extends({}, rest, {
275
- ref: ref,
276
- variant: variant,
277
- size: size
278
- }), /*#__PURE__*/React.createElement("pixiv-icon", {
279
- name: icon
280
- }));
281
- });
282
- var StyledIconButton = styled(Clickable).attrs(styledProps)(_templateObject$c || (_templateObject$c = _taggedTemplateLiteralLoose(["\n user-select: none;\n\n width: ", "px;\n height: ", "px;\n display: flex;\n align-items: center;\n justify-content: center;\n\n ", "\n"])), function (p) {
283
- return p.width;
284
- }, function (p) {
285
- return p.height;
286
- }, function (_ref2) {
287
- var font = _ref2.font,
288
- background = _ref2.background;
289
- return theme$2(function (o) {
290
- return [o.font[font], o.bg[background].hover.press, o.disabled, o.borderRadius('oval'), o.outline["default"].focus];
291
- });
292
- });
293
-
294
- function styledProps(props) {
295
- return _extends({}, props, variantToProps(props.variant), sizeToProps(props.size));
296
- }
297
-
298
- function variantToProps(variant) {
299
- switch (variant) {
300
- case 'Default':
301
- return {
302
- font: 'text3',
303
- background: 'transparent'
304
- };
305
-
306
- case 'Overlay':
307
- return {
308
- font: 'text5',
309
- background: 'surface4'
310
- };
311
- }
312
- }
313
-
314
- function sizeToProps(size) {
315
- switch (size) {
316
- case 'XS':
317
- return {
318
- width: 20,
319
- height: 20
320
- };
321
-
322
- case 'S':
323
- return {
324
- width: 32,
325
- height: 32
326
- };
327
-
328
- case 'M':
329
- return {
330
- width: 40,
331
- height: 40
332
- };
333
- }
334
- }
335
- /**
336
- * validates matches of size and icon
337
- */
338
-
339
-
340
- function validateIconSize(size, icon) {
341
- var requiredIconSize;
342
-
343
- switch (size) {
344
- case 'XS':
345
- requiredIconSize = '16';
346
- break;
347
-
348
- case 'S':
349
- case 'M':
350
- requiredIconSize = '24';
351
- break;
352
- } // アイコン名は サイズ/名前
353
-
354
-
355
- var result = /^[0-9]*/.exec(icon);
356
-
357
- if (result == null) {
358
- throw new Error('Invalid icon name');
359
- }
360
-
361
- var iconSize = result[0];
362
-
363
- if (iconSize !== requiredIconSize) {
364
- // eslint-disable-next-line no-console
365
- console.warn("IconButton with size \"" + size + "\" expect icon size \"" + requiredIconSize + ", but got \"" + iconSize + "\"");
366
- }
367
- }
368
-
369
- var _templateObject$b, _templateObject2$b, _templateObject3$b, _templateObject4$9;
370
- function Radio(_ref) {
371
- var value = _ref.value,
372
- _ref$forceChecked = _ref.forceChecked,
373
- forceChecked = _ref$forceChecked === void 0 ? false : _ref$forceChecked,
374
- _ref$disabled = _ref.disabled,
375
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
376
- children = _ref.children;
377
-
378
- var _useContext = useContext(RadioGroupContext),
379
- name = _useContext.name,
380
- selected = _useContext.selected,
381
- isParentDisabled = _useContext.disabled,
382
- readonly = _useContext.readonly,
383
- hasError = _useContext.hasError,
384
- onChange = _useContext.onChange;
385
-
386
- warning( // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
387
- name !== undefined, "\"name\" is not Provided for <Radio>. Perhaps you forgot to wrap with <RadioGroup> ?");
388
- var isSelected = value === selected;
389
- var isDisabled = disabled || isParentDisabled;
390
- var isReadonly = readonly && !isSelected;
391
- var handleChange = useCallback(function (e) {
392
- onChange(e.currentTarget.value);
393
- }, [onChange]);
394
- return /*#__PURE__*/React.createElement(RadioRoot, {
395
- "aria-disabled": isDisabled || isReadonly
396
- }, /*#__PURE__*/React.createElement(RadioInput, {
397
- name: name,
398
- value: value,
399
- checked: forceChecked || isSelected,
400
- hasError: hasError,
401
- onChange: handleChange,
402
- disabled: isDisabled || isReadonly
403
- }), children != null && /*#__PURE__*/React.createElement(RadioLabel$1, null, children));
404
- }
405
- var RadioRoot = styled.label(_templateObject$b || (_templateObject$b = _taggedTemplateLiteralLoose(["\n display: grid;\n grid-template-columns: auto 1fr;\n grid-gap: ", ";\n align-items: center;\n cursor: pointer;\n\n ", "\n"])), function (_ref2) {
406
- var theme = _ref2.theme;
407
- return px(theme.spacing[4]);
408
- }, theme$2(function (o) {
409
- return [o.disabled];
410
- }));
411
- var RadioInput = styled.input.attrs({
412
- type: 'radio'
413
- })(_templateObject2$b || (_templateObject2$b = _taggedTemplateLiteralLoose(["\n /** Make prior to browser default style */\n &[type='radio'] {\n appearance: none;\n display: block;\n box-sizing: border-box;\n\n padding: 6px;\n\n width: 20px;\n height: 20px;\n\n ", ";\n\n &:not(:checked) {\n border-width: 2px;\n border-style: solid;\n border-color: ", ";\n }\n\n &:checked {\n ", "\n\n &::after {\n content: '';\n display: block;\n width: 8px;\n height: 8px;\n pointer-events: none;\n\n ", "\n }\n }\n\n ", "\n }\n"])), function (_ref3) {
414
- var _ref3$hasError = _ref3.hasError,
415
- hasError = _ref3$hasError === void 0 ? false : _ref3$hasError;
416
- return theme$2(function (o) {
417
- return [o.borderRadius('oval'), o.bg.text5.hover.press, hasError && o.outline.assertive];
418
- });
419
- }, function (_ref4) {
420
- var theme = _ref4.theme;
421
- return theme.color.text4;
422
- }, theme$2(function (o) {
423
- return o.bg.brand.hover.press;
424
- }), theme$2(function (o) {
425
- return [o.bg.text5.hover.press, o.borderRadius('oval')];
426
- }), theme$2(function (o) {
427
- return o.outline["default"].focus;
428
- }));
429
- var RadioLabel$1 = styled.div(_templateObject3$b || (_templateObject3$b = _taggedTemplateLiteralLoose(["\n ", "\n"])), theme$2(function (o) {
430
- return [o.typography(14)];
431
- })); // TODO: use (or polyfill) flex gap
432
-
433
- var StyledRadioGroup = styled.div(_templateObject4$9 || (_templateObject4$9 = _taggedTemplateLiteralLoose(["\n display: grid;\n grid-template-columns: 1fr;\n grid-gap: ", ";\n"])), function (_ref5) {
434
- var theme = _ref5.theme;
435
- return px(theme.spacing[8]);
436
- });
437
- var RadioGroupContext = React.createContext({
438
- name: undefined,
439
- selected: undefined,
440
- disabled: false,
441
- readonly: false,
442
- hasError: false,
443
- onChange: function onChange() {
444
- throw new Error('Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?');
445
- }
446
- });
447
- function RadioGroup(_ref6) {
448
- var className = _ref6.className,
449
- value = _ref6.value,
450
- label = _ref6.label,
451
- name = _ref6.name,
452
- onChange = _ref6.onChange,
453
- disabled = _ref6.disabled,
454
- readonly = _ref6.readonly,
455
- hasError = _ref6.hasError,
456
- children = _ref6.children;
457
- var handleChange = useCallback(function (next) {
458
- onChange(next);
459
- }, [onChange]);
460
- return /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
461
- value: {
462
- name: name,
463
- selected: value,
464
- disabled: disabled != null ? disabled : false,
465
- readonly: readonly != null ? readonly : false,
466
- hasError: hasError != null ? hasError : false,
467
- onChange: handleChange
468
- }
469
- }, /*#__PURE__*/React.createElement(StyledRadioGroup, {
470
- role: "radiogroup",
471
- "aria-orientation": "vertical",
472
- "aria-label": label,
473
- "aria-invalid": hasError,
474
- className: className
475
- }, children));
476
- }
477
-
478
- var MultiSelectGroupContext = createContext({
479
- name: undefined,
480
- selected: [],
481
- disabled: false,
482
- readonly: false,
483
- hasError: false,
484
- onChange: function onChange() {
485
- throw new Error('Cannot find `onChange()` handler. Perhaps you forgot to wrap it with `<MultiSelectGroup />` ?');
486
- }
487
- });
488
-
489
- var _templateObject$a, _templateObject2$a, _templateObject3$a, _templateObject4$8, _templateObject5$7;
490
- function MultiSelect(_ref) {
491
- var value = _ref.value,
492
- _ref$forceChecked = _ref.forceChecked,
493
- forceChecked = _ref$forceChecked === void 0 ? false : _ref$forceChecked,
494
- _ref$disabled = _ref.disabled,
495
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
496
- onChange = _ref.onChange,
497
- _ref$variant = _ref.variant,
498
- variant = _ref$variant === void 0 ? 'default' : _ref$variant,
499
- children = _ref.children;
500
-
501
- var _useContext = useContext(MultiSelectGroupContext),
502
- name = _useContext.name,
503
- selected = _useContext.selected,
504
- parentDisabled = _useContext.disabled,
505
- readonly = _useContext.readonly,
506
- hasError = _useContext.hasError,
507
- parentOnChange = _useContext.onChange;
508
-
509
- warning( // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
510
- name !== undefined, "\"name\" is not Provided for <MultiSelect>. Perhaps you forgot to wrap with <MultiSelectGroup> ?");
511
- var isSelected = selected.includes(value) || forceChecked;
512
- var isDisabled = disabled || parentDisabled || readonly;
513
- var handleChange = useCallback(function (event) {
514
- if (!(event.currentTarget instanceof HTMLInputElement)) {
515
- return;
516
- }
517
-
518
- if (onChange) onChange({
519
- value: value,
520
- selected: event.currentTarget.checked
521
- });
522
- parentOnChange({
523
- value: value,
524
- selected: event.currentTarget.checked
525
- });
526
- }, [onChange, parentOnChange, value]);
527
- return /*#__PURE__*/React.createElement(MultiSelectRoot, {
528
- "aria-disabled": isDisabled
529
- }, /*#__PURE__*/React.createElement(MultiSelectInput, {
530
- name: name,
531
- value: value,
532
- hasError: hasError,
533
- checked: isSelected,
534
- disabled: isDisabled,
535
- onChange: handleChange,
536
- overlay: variant === 'overlay',
537
- "aria-invalid": hasError
538
- }), /*#__PURE__*/React.createElement(MultiSelectInputOverlay, {
539
- overlay: variant === 'overlay',
540
- hasError: hasError,
541
- "aria-hidden": true
542
- }, /*#__PURE__*/React.createElement("pixiv-icon", {
543
- name: "24/Check",
544
- "unsafe-non-guideline-scale": 16 / 24
545
- })), Boolean(children) && /*#__PURE__*/React.createElement(MultiSelectLabel, null, children));
546
- }
547
- var MultiSelectRoot = styled.label(_templateObject$a || (_templateObject$a = _taggedTemplateLiteralLoose(["\n display: grid;\n grid-template-columns: auto 1fr;\n align-items: center;\n position: relative;\n cursor: pointer;\n ", " {\n cursor: default;\n }\n gap: ", ";\n ", "\n"])), disabledSelector, function (_ref2) {
548
- var theme = _ref2.theme;
549
- return px(theme.spacing[4]);
550
- }, theme$2(function (o) {
551
- return o.disabled;
552
- }));
553
- var MultiSelectLabel = styled.div(_templateObject2$a || (_templateObject2$a = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n ", "\n"])), theme$2(function (o) {
554
- return [o.typography(14), o.font.text1];
555
- }));
556
- var MultiSelectInput = styled.input.attrs({
557
- type: 'checkbox'
558
- })(_templateObject3$a || (_templateObject3$a = _taggedTemplateLiteralLoose(["\n &[type='checkbox'] {\n appearance: none;\n display: block;\n width: 20px;\n height: 20px;\n margin: 0;\n\n &:checked {\n ", "\n }\n\n ", ";\n }\n"])), theme$2(function (o) {
559
- return o.bg.brand.hover.press;
560
- }), function (_ref3) {
561
- var hasError = _ref3.hasError,
562
- overlay = _ref3.overlay;
563
- return theme$2(function (o) {
564
- return [o.bg.text3.hover.press, o.borderRadius('oval'), hasError && !overlay && o.outline.assertive, overlay && o.bg.surface4];
565
- });
566
- });
567
- var MultiSelectInputOverlay = styled.div(_templateObject4$8 || (_templateObject4$8 = _taggedTemplateLiteralLoose(["\n position: absolute;\n top: -2px;\n left: -2px;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n\n ", "\n\n ", "\n"])), function (_ref4) {
568
- var hasError = _ref4.hasError,
569
- overlay = _ref4.overlay;
570
- return theme$2(function (o) {
571
- return [o.width.px(24), o.height.px(24), o.borderRadius('oval'), o.font.text5, hasError && overlay && o.outline.assertive];
572
- });
573
- }, function (_ref5) {
574
- var overlay = _ref5.overlay;
575
- return overlay && css(_templateObject5$7 || (_templateObject5$7 = _taggedTemplateLiteralLoose(["\n border-color: ", ";\n border-width: 2px;\n border-style: solid;\n "])), function (_ref6) {
576
- var theme = _ref6.theme;
577
- return theme.color.text5;
578
- });
579
- });
580
- function MultiSelectGroup(_ref7) {
581
- var className = _ref7.className,
582
- name = _ref7.name,
583
- ariaLabel = _ref7.ariaLabel,
584
- selected = _ref7.selected,
585
- onChange = _ref7.onChange,
586
- _ref7$disabled = _ref7.disabled,
587
- disabled = _ref7$disabled === void 0 ? false : _ref7$disabled,
588
- _ref7$readonly = _ref7.readonly,
589
- readonly = _ref7$readonly === void 0 ? false : _ref7$readonly,
590
- _ref7$hasError = _ref7.hasError,
591
- hasError = _ref7$hasError === void 0 ? false : _ref7$hasError,
592
- children = _ref7.children;
593
- var handleChange = useCallback(function (payload) {
594
- var index = selected.indexOf(payload.value);
595
-
596
- if (payload.selected) {
597
- if (index < 0) {
598
- onChange([].concat(selected, [payload.value]));
599
- }
600
- } else {
601
- if (index >= 0) {
602
- onChange([].concat(selected.slice(0, index), selected.slice(index + 1)));
603
- }
604
- }
605
- }, [onChange, selected]);
606
- return /*#__PURE__*/React.createElement(MultiSelectGroupContext.Provider, {
607
- value: {
608
- name: name,
609
- selected: Array.from(new Set(selected)),
610
- disabled: disabled,
611
- readonly: readonly,
612
- hasError: hasError,
613
- onChange: handleChange
614
- }
615
- }, /*#__PURE__*/React.createElement("div", {
616
- className: className,
617
- "aria-label": ariaLabel,
618
- "data-testid": "SelectGroup"
619
- }, children));
620
- }
621
-
622
- var _templateObject$9, _templateObject2$9, _templateObject3$9;
623
-
624
- var _excluded$9 = ["className", "type"];
625
- function SwitchCheckbox(props) {
626
- var disabled = props.disabled,
627
- className = props.className;
628
- var ariaSwitchProps = useMemo(function () {
629
- return _extends({}, props, {
630
- // children がいない場合は aria-label をつけないといけない
631
- 'aria-label': 'children' in props ? undefined : props.label,
632
- isDisabled: props.disabled,
633
- isSelected: props.checked
634
- });
635
- }, [props]);
636
- var state = useToggleState(ariaSwitchProps);
637
- var ref = useRef(null);
638
-
639
- var _useSwitch = useSwitch(ariaSwitchProps, state, ref),
640
- _useSwitch$inputProps = _useSwitch.inputProps,
641
- rest = _objectWithoutPropertiesLoose(_useSwitch$inputProps, _excluded$9);
642
-
643
- return /*#__PURE__*/React.createElement(Label$1, {
644
- className: className,
645
- "aria-disabled": disabled
646
- }, /*#__PURE__*/React.createElement(SwitchInput, _extends({}, rest, {
647
- ref: ref
648
- })), 'children' in props ?
649
- /*#__PURE__*/
650
- // eslint-disable-next-line react/destructuring-assignment
651
- React.createElement(LabelInner, null, props.children) : undefined);
652
- }
653
- var Label$1 = styled.label(_templateObject$9 || (_templateObject$9 = _taggedTemplateLiteralLoose(["\n display: inline-grid;\n grid-template-columns: auto 1fr;\n gap: ", ";\n cursor: pointer;\n outline: 0;\n\n ", "\n\n ", " {\n cursor: default;\n }\n"])), function (_ref) {
654
- var theme = _ref.theme;
655
- return px(theme.spacing[4]);
656
- }, theme$2(function (o) {
657
- return o.disabled;
658
- }), disabledSelector);
659
- var LabelInner = styled.div(_templateObject2$9 || (_templateObject2$9 = _taggedTemplateLiteralLoose(["\n ", "\n"])), theme$2(function (o) {
660
- return o.typography(14);
661
- }));
662
- var SwitchInput = styled.input.attrs({
663
- type: 'checkbox'
664
- })(_templateObject3$9 || (_templateObject3$9 = _taggedTemplateLiteralLoose(["\n &[type='checkbox'] {\n appearance: none;\n display: inline-flex;\n position: relative;\n box-sizing: border-box;\n width: 28px;\n border: 2px solid transparent;\n transition: box-shadow 0.2s, background-color 0.2s;\n cursor: inherit;\n ", "\n\n &::after {\n content: '';\n position: absolute;\n display: block;\n top: 0;\n left: 0;\n width: 12px;\n height: 12px;\n transform: translateX(0);\n transition: transform 0.2s;\n ", "\n }\n\n &:checked {\n ", "\n\n &::after {\n transform: translateX(12px);\n }\n }\n }\n"])), theme$2(function (o) {
665
- return [o.borderRadius(16), o.height.px(16), o.bg.text4.hover.press, o.outline["default"].focus];
666
- }), theme$2(function (o) {
667
- return [o.bg.text5.hover.press, o.borderRadius('oval')];
668
- }), theme$2(function (o) {
669
- return o.bg.brand.hover.press;
670
- }));
671
-
672
- var _templateObject$8, _templateObject2$8, _templateObject3$8, _templateObject4$7;
673
-
674
- var _excluded$8 = ["style", "className", "label", "required", "requiredText", "subLabel"];
675
- var FieldLabel = React.forwardRef(function FieldLabel(_ref, ref) {
676
- var style = _ref.style,
677
- className = _ref.className,
678
- label = _ref.label,
679
- _ref$required = _ref.required,
680
- required = _ref$required === void 0 ? false : _ref$required,
681
- requiredText = _ref.requiredText,
682
- subLabel = _ref.subLabel,
683
- labelProps = _objectWithoutPropertiesLoose(_ref, _excluded$8);
684
-
685
- return /*#__PURE__*/React.createElement(FieldLabelWrapper, {
686
- style: style,
687
- className: className
688
- }, /*#__PURE__*/React.createElement(Label, _extends({
689
- ref: ref
690
- }, labelProps), label), required && /*#__PURE__*/React.createElement(RequiredText, null, requiredText), /*#__PURE__*/React.createElement(SubLabelClickable, null, /*#__PURE__*/React.createElement("span", null, subLabel)));
691
- });
692
- var theme$1 = createTheme(styled);
693
- var Label = styled.label(_templateObject$8 || (_templateObject$8 = _taggedTemplateLiteralLoose(["\n ", "\n"])), theme$1(function (o) {
694
- return [o.typography(14).bold, o.font.text1];
695
- }));
696
- var RequiredText = styled.span(_templateObject2$8 || (_templateObject2$8 = _taggedTemplateLiteralLoose(["\n ", "\n"])), theme$1(function (o) {
697
- return [o.typography(14), o.font.text3];
698
- }));
699
- var SubLabelClickable = styled.div(_templateObject3$8 || (_templateObject3$8 = _taggedTemplateLiteralLoose(["\n ", "\n"])), theme$1(function (o) {
700
- return [o.typography(14), o.font.text3.hover.press, o.outline["default"].focus];
701
- }));
702
- var FieldLabelWrapper = styled.div(_templateObject4$7 || (_templateObject4$7 = _taggedTemplateLiteralLoose(["\n display: inline-flex;\n align-items: center;\n\n > ", " {\n ", "\n }\n\n > ", " {\n ", "\n }\n"])), RequiredText, theme$1(function (o) {
703
- return o.margin.left(4);
704
- }), SubLabelClickable, theme$1(function (o) {
705
- return o.margin.left('auto');
706
- }));
707
-
708
- var _templateObject$7, _templateObject2$7, _templateObject3$7, _templateObject4$6, _templateObject5$6, _templateObject6$3, _templateObject7$2, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14;
709
-
710
- var _excluded$7 = ["onChange"],
711
- _excluded2$1 = ["onChange"];
712
- var theme = createTheme(styled);
713
-
714
- function mergeRefs() {
715
- var _arguments = arguments;
716
- return function (value) {
717
- for (var _iterator = _createForOfIteratorHelperLoose([].slice.call(_arguments)), _step; !(_step = _iterator()).done;) {
718
- var ref = _step.value;
719
-
720
- if (typeof ref === 'function') {
721
- ref(value);
722
- } else if (ref !== null) {
723
- ref.current = value;
724
- }
725
- }
726
- };
727
- }
728
-
729
- function countCodePointsInString(string) {
730
- // [...string] とするとproduction buildで動かなくなる
731
- // cf. https://twitter.com/f_subal/status/1497214727511891972
732
- return Array.from(string).length;
733
- }
734
-
735
- var TextField = React.forwardRef(function TextField(props, ref) {
736
- return props.multiline !== undefined && props.multiline ? /*#__PURE__*/React.createElement(MultiLineTextField, _extends({
737
- ref: ref
738
- }, props)) : /*#__PURE__*/React.createElement(SingleLineTextField, _extends({
739
- ref: ref
740
- }, props));
741
- });
742
- var SingleLineTextField = React.forwardRef(function SingleLineTextFieldInner(_ref, forwardRef) {
743
- var _props$value;
744
-
745
- var onChange = _ref.onChange,
746
- props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
747
-
748
- var className = props.className,
749
- _props$showLabel = props.showLabel,
750
- showLabel = _props$showLabel === void 0 ? false : _props$showLabel,
751
- _props$showCount = props.showCount,
752
- showCount = _props$showCount === void 0 ? false : _props$showCount,
753
- label = props.label,
754
- requiredText = props.requiredText,
755
- subLabel = props.subLabel,
756
- _props$disabled = props.disabled,
757
- disabled = _props$disabled === void 0 ? false : _props$disabled,
758
- required = props.required,
759
- _props$invalid = props.invalid,
760
- invalid = _props$invalid === void 0 ? false : _props$invalid,
761
- assistiveText = props.assistiveText,
762
- maxLength = props.maxLength,
763
- _props$prefix = props.prefix,
764
- prefix = _props$prefix === void 0 ? null : _props$prefix,
765
- _props$suffix = props.suffix,
766
- suffix = _props$suffix === void 0 ? null : _props$suffix;
767
-
768
- var _useVisuallyHidden = useVisuallyHidden(),
769
- visuallyHiddenProps = _useVisuallyHidden.visuallyHiddenProps;
770
-
771
- var ariaRef = useRef(null);
772
- var prefixRef = useRef(null);
773
- var suffixRef = useRef(null);
774
-
775
- var _useState = useState(countCodePointsInString((_props$value = props.value) != null ? _props$value : '')),
776
- count = _useState[0],
777
- setCount = _useState[1];
778
-
779
- var _useState2 = useState(0),
780
- prefixWidth = _useState2[0],
781
- setPrefixWidth = _useState2[1];
782
-
783
- var _useState3 = useState(0),
784
- suffixWidth = _useState3[0],
785
- setSuffixWidth = _useState3[1];
786
-
787
- var nonControlled = props.value === undefined;
788
- var handleChange = useCallback(function (value) {
789
- var count = countCodePointsInString(value);
790
-
791
- if (maxLength !== undefined && count > maxLength) {
792
- return;
793
- }
794
-
795
- if (nonControlled) {
796
- setCount(count);
797
- }
798
-
799
- onChange == null ? void 0 : onChange(value);
800
- }, [maxLength, nonControlled, onChange]);
801
- useEffect(function () {
802
- var _props$value2;
803
-
804
- setCount(countCodePointsInString((_props$value2 = props.value) != null ? _props$value2 : ''));
805
- }, [props.value]);
806
-
807
- var _useTextField = useTextField(_extends({
808
- inputElementType: 'input',
809
- isDisabled: disabled,
810
- isRequired: required,
811
- validationState: invalid ? 'invalid' : 'valid',
812
- description: !invalid && assistiveText,
813
- errorMessage: invalid && assistiveText,
814
- onChange: handleChange
815
- }, props), ariaRef),
816
- inputProps = _useTextField.inputProps,
817
- labelProps = _useTextField.labelProps,
818
- descriptionProps = _useTextField.descriptionProps,
819
- errorMessageProps = _useTextField.errorMessageProps;
820
-
821
- useEffect(function () {
822
- var prefixObserver = new ResizeObserver(function (entries) {
823
- setPrefixWidth(entries[0].contentRect.width);
824
- });
825
- var suffixObserver = new ResizeObserver(function (entries) {
826
- setSuffixWidth(entries[0].contentRect.width);
827
- });
828
-
829
- if (prefixRef.current !== null) {
830
- prefixObserver.observe(prefixRef.current);
831
- }
832
-
833
- if (suffixRef.current !== null) {
834
- suffixObserver.observe(suffixRef.current);
835
- }
836
-
837
- return function () {
838
- suffixObserver.disconnect();
839
- prefixObserver.disconnect();
840
- };
841
- }, []);
842
- return /*#__PURE__*/React.createElement(TextFieldRoot, {
843
- className: className,
844
- isDisabled: disabled
845
- }, /*#__PURE__*/React.createElement(TextFieldLabel, _extends({
846
- label: label,
847
- requiredText: requiredText,
848
- required: required,
849
- subLabel: subLabel
850
- }, labelProps, !showLabel ? visuallyHiddenProps : {})), /*#__PURE__*/React.createElement(StyledInputContainer, null, /*#__PURE__*/React.createElement(PrefixContainer, {
851
- ref: prefixRef
852
- }, /*#__PURE__*/React.createElement(Affix, null, prefix)), /*#__PURE__*/React.createElement(StyledInput, _extends({
853
- ref: mergeRefs(forwardRef, ariaRef),
854
- invalid: invalid,
855
- extraLeftPadding: prefixWidth,
856
- extraRightPadding: suffixWidth
857
- }, inputProps)), /*#__PURE__*/React.createElement(SuffixContainer, {
858
- ref: suffixRef
859
- }, /*#__PURE__*/React.createElement(Affix, null, suffix), showCount && /*#__PURE__*/React.createElement(SingleLineCounter, null, maxLength !== undefined ? count + "/" + maxLength : count))), assistiveText != null && assistiveText.length !== 0 && /*#__PURE__*/React.createElement(AssistiveText, _extends({
860
- invalid: invalid
861
- }, invalid ? errorMessageProps : descriptionProps), assistiveText));
862
- });
863
- var MultiLineTextField = React.forwardRef(function MultiLineTextFieldInner(_ref2, forwardRef) {
864
- var _props$value3;
865
-
866
- var onChange = _ref2.onChange,
867
- props = _objectWithoutPropertiesLoose(_ref2, _excluded2$1);
868
-
869
- var className = props.className,
870
- _props$showCount2 = props.showCount,
871
- showCount = _props$showCount2 === void 0 ? false : _props$showCount2,
872
- _props$showLabel2 = props.showLabel,
873
- showLabel = _props$showLabel2 === void 0 ? false : _props$showLabel2,
874
- label = props.label,
875
- requiredText = props.requiredText,
876
- subLabel = props.subLabel,
877
- _props$disabled2 = props.disabled,
878
- disabled = _props$disabled2 === void 0 ? false : _props$disabled2,
879
- required = props.required,
880
- _props$invalid2 = props.invalid,
881
- invalid = _props$invalid2 === void 0 ? false : _props$invalid2,
882
- assistiveText = props.assistiveText,
883
- maxLength = props.maxLength,
884
- _props$autoHeight = props.autoHeight,
885
- autoHeight = _props$autoHeight === void 0 ? false : _props$autoHeight,
886
- _props$rows = props.rows,
887
- initialRows = _props$rows === void 0 ? 4 : _props$rows;
888
-
889
- var _useVisuallyHidden2 = useVisuallyHidden(),
890
- visuallyHiddenProps = _useVisuallyHidden2.visuallyHiddenProps;
891
-
892
- var textareaRef = useRef(null);
893
- var ariaRef = useRef(null);
894
-
895
- var _useState4 = useState(countCodePointsInString((_props$value3 = props.value) != null ? _props$value3 : '')),
896
- count = _useState4[0],
897
- setCount = _useState4[1];
898
-
899
- var _useState5 = useState(initialRows),
900
- rows = _useState5[0],
901
- setRows = _useState5[1];
902
-
903
- var syncHeight = useCallback(function (textarea) {
904
- var _$match$length, _$match;
905
-
906
- var rows = ((_$match$length = (_$match = (textarea.value + "\n").match(/\n/g)) == null ? void 0 : _$match.length) != null ? _$match$length : 0) || 1;
907
- setRows(initialRows <= rows ? rows : initialRows);
908
- }, [initialRows]);
909
- var nonControlled = props.value === undefined;
910
- var handleChange = useCallback(function (value) {
911
- var count = countCodePointsInString(value);
912
-
913
- if (maxLength !== undefined && count > maxLength) {
914
- return;
915
- }
916
-
917
- if (nonControlled) {
918
- setCount(count);
919
- }
920
-
921
- if (autoHeight && textareaRef.current !== null) {
922
- syncHeight(textareaRef.current);
923
- }
924
-
925
- onChange == null ? void 0 : onChange(value);
926
- }, [autoHeight, maxLength, nonControlled, onChange, syncHeight]);
927
- useEffect(function () {
928
- var _props$value4;
929
-
930
- setCount(countCodePointsInString((_props$value4 = props.value) != null ? _props$value4 : ''));
931
- }, [props.value]);
932
-
933
- var _useTextField2 = useTextField(_extends({
934
- inputElementType: 'textarea',
935
- isDisabled: disabled,
936
- isRequired: required,
937
- validationState: invalid ? 'invalid' : 'valid',
938
- description: !invalid && assistiveText,
939
- errorMessage: invalid && assistiveText,
940
- onChange: handleChange
941
- }, props), ariaRef),
942
- inputProps = _useTextField2.inputProps,
943
- labelProps = _useTextField2.labelProps,
944
- descriptionProps = _useTextField2.descriptionProps,
945
- errorMessageProps = _useTextField2.errorMessageProps;
946
-
947
- useEffect(function () {
948
- if (autoHeight && textareaRef.current !== null) {
949
- syncHeight(textareaRef.current);
950
- }
951
- }, [autoHeight, syncHeight]);
952
- return /*#__PURE__*/React.createElement(TextFieldRoot, {
953
- className: className,
954
- isDisabled: disabled
955
- }, /*#__PURE__*/React.createElement(TextFieldLabel, _extends({
956
- label: label,
957
- requiredText: requiredText,
958
- required: required,
959
- subLabel: subLabel
960
- }, labelProps, !showLabel ? visuallyHiddenProps : {})), /*#__PURE__*/React.createElement(StyledTextareaContainer, {
961
- invalid: invalid,
962
- rows: showCount ? rows + 1 : rows
963
- }, /*#__PURE__*/React.createElement(StyledTextarea, _extends({
964
- ref: mergeRefs(textareaRef, forwardRef, ariaRef),
965
- rows: rows,
966
- noBottomPadding: showCount
967
- }, inputProps)), showCount && /*#__PURE__*/React.createElement(MultiLineCounter, null, maxLength !== undefined ? count + "/" + maxLength : count)), assistiveText != null && assistiveText.length !== 0 && /*#__PURE__*/React.createElement(AssistiveText, _extends({
968
- invalid: invalid
969
- }, invalid ? errorMessageProps : descriptionProps), assistiveText));
970
- });
971
- var TextFieldRoot = styled.div(_templateObject$7 || (_templateObject$7 = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n\n ", "\n"])), function (p) {
972
- return p.isDisabled && {
973
- opacity: p.theme.elementEffect.disabled.opacity
974
- };
975
- });
976
- var TextFieldLabel = styled(FieldLabel)(_templateObject2$7 || (_templateObject2$7 = _taggedTemplateLiteralLoose(["\n ", "\n"])), theme(function (o) {
977
- return o.margin.bottom(8);
978
- }));
979
- var StyledInputContainer = styled.div(_templateObject3$7 || (_templateObject3$7 = _taggedTemplateLiteralLoose(["\n height: 40px;\n display: grid;\n position: relative;\n"])));
980
- var PrefixContainer = styled.span(_templateObject4$6 || (_templateObject4$6 = _taggedTemplateLiteralLoose(["\n position: absolute;\n top: 50%;\n left: 8px;\n transform: translateY(-50%);\n"])));
981
- var SuffixContainer = styled.span(_templateObject5$6 || (_templateObject5$6 = _taggedTemplateLiteralLoose(["\n position: absolute;\n top: 50%;\n right: 8px;\n transform: translateY(-50%);\n\n display: flex;\n gap: 8px;\n"])));
982
- var Affix = styled.span(_templateObject6$3 || (_templateObject6$3 = _taggedTemplateLiteralLoose(["\n user-select: none;\n\n ", "\n"])), theme(function (o) {
983
- return [o.typography(14).preserveHalfLeading, o.font.text2];
984
- }));
985
- var StyledInput = styled.input(_templateObject7$2 || (_templateObject7$2 = _taggedTemplateLiteralLoose(["\n border: none;\n box-sizing: border-box;\n outline: none;\n font-family: inherit;\n\n /* Prevent zooming for iOS Safari */\n transform-origin: top left;\n transform: scale(0.875);\n width: calc(100% / 0.875);\n height: calc(100% / 0.875);\n font-size: calc(14px / 0.875);\n line-height: calc(22px / 0.875);\n padding-left: calc((8px + ", "px) / 0.875);\n padding-right: calc((8px + ", "px) / 0.875);\n border-radius: calc(4px / 0.875);\n\n /* Display box-shadow for iOS Safari */\n appearance: none;\n\n ", "\n\n &::placeholder {\n ", "\n }\n"])), function (p) {
986
- return p.extraLeftPadding;
987
- }, function (p) {
988
- return p.extraRightPadding;
989
- }, function (p) {
990
- return theme(function (o) {
991
- return [o.bg.surface3.hover, o.outline["default"].focus, p.invalid && o.outline.assertive, o.font.text2];
992
- });
993
- }, theme(function (o) {
994
- return o.font.text3;
995
- }));
996
- var StyledTextareaContainer = styled.div(_templateObject8 || (_templateObject8 = _taggedTemplateLiteralLoose(["\n position: relative;\n overflow: hidden;\n padding: 0 8px;\n\n ", "\n\n &:focus-within {\n ", "\n }\n\n ", ";\n"])), function (p) {
997
- return theme(function (o) {
998
- return [o.bg.surface3.hover, p.invalid && o.outline.assertive, o.font.text2, o.borderRadius(4)];
999
- });
1000
- }, function (p) {
1001
- return theme(function (o) {
1002
- return p.invalid ? o.outline.assertive : o.outline["default"];
1003
- });
1004
- }, function (_ref3) {
1005
- var rows = _ref3.rows;
1006
- return css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteralLoose(["\n height: calc(22px * ", " + 18px);\n "])), rows);
1007
- });
1008
- var StyledTextarea = styled.textarea(_templateObject10 || (_templateObject10 = _taggedTemplateLiteralLoose(["\n border: none;\n outline: none;\n resize: none;\n font-family: inherit;\n color: inherit;\n\n /* Prevent zooming for iOS Safari */\n transform-origin: top left;\n transform: scale(0.875);\n width: calc(100% / 0.875);\n font-size: calc(14px / 0.875);\n line-height: calc(22px / 0.875);\n padding: calc(9px / 0.875) 0 ", ";\n\n ", ";\n\n /* Display box-shadow for iOS Safari */\n appearance: none;\n\n background: none;\n\n &::placeholder {\n ", "\n }\n\n /* Hide scrollbar for Chrome, Safari and Opera */\n &::-webkit-scrollbar {\n display: none;\n }\n /* Hide scrollbar for IE, Edge and Firefox */\n -ms-overflow-style: none; /* IE and Edge */\n scrollbar-width: none; /* Firefox */\n"])), function (p) {
1009
- return p.noBottomPadding ? 0 : '';
1010
- }, function (_ref4) {
1011
- var _ref4$rows = _ref4.rows,
1012
- rows = _ref4$rows === void 0 ? 1 : _ref4$rows;
1013
- return css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteralLoose(["\n height: calc(22px / 0.875 * ", ");\n "])), rows);
1014
- }, theme(function (o) {
1015
- return o.font.text3;
1016
- }));
1017
- var SingleLineCounter = styled.span(_templateObject12 || (_templateObject12 = _taggedTemplateLiteralLoose(["\n ", "\n"])), theme(function (o) {
1018
- return [o.typography(14).preserveHalfLeading, o.font.text3];
1019
- }));
1020
- var MultiLineCounter = styled.span(_templateObject13 || (_templateObject13 = _taggedTemplateLiteralLoose(["\n position: absolute;\n bottom: 9px;\n right: 8px;\n\n ", "\n"])), theme(function (o) {
1021
- return [o.typography(14).preserveHalfLeading, o.font.text3];
1022
- }));
1023
- var AssistiveText = styled.p(_templateObject14 || (_templateObject14 = _taggedTemplateLiteralLoose(["\n ", "\n"])), function (p) {
1024
- return theme(function (o) {
1025
- return [o.typography(14), o.margin.top(8), o.margin.bottom(0), o.font[p.invalid ? 'assertive' : 'text1']];
1026
- });
1027
- });
1028
-
1029
- var _excluded$6 = ["name", "scale", "unsafeNonGuidelineScale", "className"];
1030
- var Icon$1 = React.forwardRef(function IconInner(_ref, ref) {
1031
- var name = _ref.name,
1032
- scale = _ref.scale,
1033
- unsafeNonGuidelineScale = _ref.unsafeNonGuidelineScale,
1034
- className = _ref.className,
1035
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
1036
-
1037
- return /*#__PURE__*/React.createElement("pixiv-icon", _extends({
1038
- ref: ref,
1039
- name: name,
1040
- scale: scale,
1041
- "unsafe-non-guideline-scale": unsafeNonGuidelineScale,
1042
- "class": className
1043
- }, rest));
1044
- });
1045
-
1046
- var _BREAKPOINT;
1047
- /**
1048
- * Unit for grid column (px)
1049
- */
1050
-
1051
- var COLUMN_UNIT = 80;
1052
- /**
1053
- * Unit for grid gutter width (px)
1054
- */
1055
-
1056
- var GUTTER_UNIT = 24; // TODO: Grid definition with breakpoint
1057
-
1058
- /**
1059
- * Calculate px occupied by the span of the columns with gutter gap
1060
- *
1061
- * @param span column span count
1062
- */
1063
-
1064
- function columnSystem(span, column, gutter) {
1065
- return span * column + (span - 1) * gutter;
1066
- }
1067
- var HORIZONTAL_MIN_MARGIN = 72;
1068
- (_BREAKPOINT = {}, _BREAKPOINT[6] = columnSystem(6, COLUMN_UNIT, GUTTER_UNIT) + HORIZONTAL_MIN_MARGIN * 2, _BREAKPOINT[8] = columnSystem(8, COLUMN_UNIT, GUTTER_UNIT) + HORIZONTAL_MIN_MARGIN * 2, _BREAKPOINT[10] = columnSystem(10, COLUMN_UNIT, GUTTER_UNIT) + HORIZONTAL_MIN_MARGIN * 2, _BREAKPOINT[12] = columnSystem(12, COLUMN_UNIT, GUTTER_UNIT) + HORIZONTAL_MIN_MARGIN * 2, _BREAKPOINT);
1069
-
1070
- var _templateObject$6, _templateObject2$6, _templateObject3$6, _templateObject4$5, _templateObject5$5, _templateObject6$2, _templateObject7$1;
1071
-
1072
- var _excluded$5 = ["children", "zIndex", "portalContainer"];
1073
- var DEFAULT_Z_INDEX = 10;
1074
- function Modal(_ref) {
1075
- var _useMedia;
1076
-
1077
- var children = _ref.children,
1078
- _ref$zIndex = _ref.zIndex,
1079
- zIndex = _ref$zIndex === void 0 ? DEFAULT_Z_INDEX : _ref$zIndex,
1080
- props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
1081
-
1082
- var title = props.title,
1083
- _props$size = props.size,
1084
- size = _props$size === void 0 ? 'M' : _props$size,
1085
- _props$bottomSheet = props.bottomSheet,
1086
- bottomSheet = _props$bottomSheet === void 0 ? false : _props$bottomSheet,
1087
- isDismissable = props.isDismissable,
1088
- onClose = props.onClose,
1089
- _props$isOpen = props.isOpen,
1090
- isOpen = _props$isOpen === void 0 ? false : _props$isOpen;
1091
- var ref = useRef(null);
1092
-
1093
- var _useOverlay = useOverlay(props, ref),
1094
- overlayProps = _useOverlay.overlayProps,
1095
- underlayProps = _useOverlay.underlayProps;
1096
-
1097
- usePreventScroll();
1098
-
1099
- var _useModalOverlay = useModalOverlay(props, {
1100
- close: onClose,
1101
- isOpen: isOpen,
1102
- // these props are not used actually.
1103
- // https://github.com/adobe/react-spectrum/blob/df14e3fb129b94b310f0397a701b83f006b51dfe/packages/%40react-aria/overlays/src/useModalOverlay.ts
1104
- open: function open() {// nope
1105
- },
1106
- setOpen: function setOpen() {// nope
1107
- },
1108
- toggle: function toggle() {// nope
1109
- }
1110
- }, ref),
1111
- modalProps = _useModalOverlay.modalProps;
1112
-
1113
- var _useDialog = useDialog(props, ref),
1114
- dialogProps = _useDialog.dialogProps,
1115
- titleProps = _useDialog.titleProps;
1116
-
1117
- var theme = useTheme();
1118
- var isMobile = (_useMedia = useMedia(maxWidth(theme.breakpoint.screen1))) != null ? _useMedia : false;
1119
- var transitionEnabled = isMobile && bottomSheet !== false;
1120
- var transition = useTransition(isOpen, {
1121
- from: {
1122
- transform: 'translateY(100%)',
1123
- backgroundColor: 'rgba(0, 0, 0, 0)'
1124
- },
1125
- enter: {
1126
- transform: 'translateY(0%)',
1127
- backgroundColor: 'rgba(0, 0, 0, 0.4)'
1128
- },
1129
- leave: {
1130
- transform: 'translateY(100%)',
1131
- backgroundColor: 'rgba(0, 0, 0, 0)'
1132
- },
1133
- config: transitionEnabled ? {
1134
- duration: 400,
1135
- easing: easings.easeOutQuart
1136
- } : {
1137
- duration: 0
1138
- }
1139
- });
1140
- var showDismiss = !isMobile || bottomSheet !== true;
1141
- return transition(function (_ref2, item) {
1142
- var backgroundColor = _ref2.backgroundColor,
1143
- transform = _ref2.transform;
1144
- return item && /*#__PURE__*/React.createElement(Overlay, null, /*#__PURE__*/React.createElement(ModalBackground, _extends({
1145
- zIndex: zIndex
1146
- }, underlayProps, {
1147
- style: transitionEnabled ? {
1148
- backgroundColor: backgroundColor
1149
- } : {}
1150
- }), /*#__PURE__*/React.createElement(FocusScope, {
1151
- contain: true,
1152
- restoreFocus: true,
1153
- autoFocus: true
1154
- }, /*#__PURE__*/React.createElement(ModalDialog, _extends({
1155
- ref: ref
1156
- }, overlayProps, modalProps, dialogProps, {
1157
- style: transitionEnabled ? {
1158
- transform: transform
1159
- } : {},
1160
- size: size,
1161
- bottomSheet: bottomSheet
1162
- }), /*#__PURE__*/React.createElement(ModalContext.Provider, {
1163
- value: {
1164
- titleProps: titleProps,
1165
- title: title,
1166
- close: onClose,
1167
- showDismiss: showDismiss
1168
- }
1169
- }, children, isDismissable === true && /*#__PURE__*/React.createElement(ModalCrossButton, {
1170
- size: "S",
1171
- icon: "24/Close",
1172
- onClick: onClose
1173
- }))))));
1174
- });
1175
- }
1176
- var ModalContext = React.createContext({
1177
- titleProps: {},
1178
- title: '',
1179
- close: undefined,
1180
- showDismiss: true
1181
- });
1182
- var ModalBackground = animated(styled.div(_templateObject$6 || (_templateObject$6 = _taggedTemplateLiteralLoose(["\n z-index: ", ";\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n\n ", "\n"])), function (_ref3) {
1183
- var zIndex = _ref3.zIndex;
1184
- return zIndex;
1185
- }, theme$2(function (o) {
1186
- return [o.bg.surface4];
1187
- })));
1188
- var ModalDialog = animated(styled.div(_templateObject2$6 || (_templateObject2$6 = _taggedTemplateLiteralLoose(["\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: ", "px;\n\n ", "\n\n @media ", " {\n ", "\n }\n"])), function (p) {
1189
- return p.size === 'S' ? columnSystem(3, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2 : p.size === 'M' ? columnSystem(4, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2 : // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1190
- p.size === 'L' ? columnSystem(6, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2 : unreachable(p.size);
1191
- }, theme$2(function (o) {
1192
- return [o.bg.background1, o.borderRadius(24)];
1193
- }), function (_ref4) {
1194
- var theme = _ref4.theme;
1195
- return maxWidth(theme.breakpoint.screen1);
1196
- }, function (p) {
1197
- return p.bottomSheet === 'full' ? css(_templateObject3$6 || (_templateObject3$6 = _taggedTemplateLiteralLoose(["\n top: auto;\n bottom: 0;\n left: 0;\n transform: none;\n border-radius: 0;\n width: 100%;\n height: 100%;\n "]))) : p.bottomSheet ? css(_templateObject4$5 || (_templateObject4$5 = _taggedTemplateLiteralLoose(["\n top: auto;\n bottom: 0;\n left: 0;\n transform: none;\n border-radius: 0;\n width: 100%;\n "]))) : css(_templateObject5$5 || (_templateObject5$5 = _taggedTemplateLiteralLoose(["\n width: calc(100% - 48px);\n "])));
1198
- }));
1199
- var ModalCrossButton = styled(IconButton)(_templateObject6$2 || (_templateObject6$2 = _taggedTemplateLiteralLoose(["\n position: absolute;\n top: 8px;\n right: 8px;\n\n ", "\n"])), theme$2(function (o) {
1200
- return [o.font.text3.hover.press];
1201
- }));
1202
- function ModalTitle(props) {
1203
- var _useContext = useContext(ModalContext),
1204
- titleProps = _useContext.titleProps,
1205
- title = _useContext.title;
1206
-
1207
- return /*#__PURE__*/React.createElement(ModalHeading, _extends({}, titleProps, props), title);
1208
- }
1209
- var ModalHeading = styled.h3(_templateObject7$1 || (_templateObject7$1 = _taggedTemplateLiteralLoose(["\n margin: 0;\n font-weight: inherit;\n font-size: inherit;\n"])));
1210
-
1211
- var _templateObject$5, _templateObject2$5, _templateObject3$5, _templateObject4$4, _templateObject5$4;
1212
- function ModalHeader() {
1213
- return /*#__PURE__*/React.createElement(ModalHeaderRoot, null, /*#__PURE__*/React.createElement(StyledModalTitle, null));
1214
- }
1215
- var ModalHeaderRoot = styled.div(_templateObject$5 || (_templateObject$5 = _taggedTemplateLiteralLoose(["\n height: 64px;\n display: grid;\n align-content: center;\n justify-content: center;\n"])));
1216
- var StyledModalTitle = styled(ModalTitle)(_templateObject2$5 || (_templateObject2$5 = _taggedTemplateLiteralLoose(["\n ", "\n"])), theme$2(function (o) {
1217
- return [o.font.text1, o.typography(16).bold];
1218
- }));
1219
- var ModalAlign = styled.div(_templateObject3$5 || (_templateObject3$5 = _taggedTemplateLiteralLoose(["\n ", "\n\n @media ", " {\n ", "\n }\n"])), theme$2(function (o) {
1220
- return [o.padding.horizontal(24)];
1221
- }), function (_ref) {
1222
- var theme = _ref.theme;
1223
- return maxWidth(theme.breakpoint.screen1);
1224
- }, theme$2(function (o) {
1225
- return [o.padding.horizontal(16)];
1226
- }));
1227
- var ModalBody = styled.div(_templateObject4$4 || (_templateObject4$4 = _taggedTemplateLiteralLoose(["\n ", "\n"])), theme$2(function (o) {
1228
- return [o.padding.bottom(40)];
1229
- }));
1230
- var ModalButtons = styled.div(_templateObject5$4 || (_templateObject5$4 = _taggedTemplateLiteralLoose(["\n display: grid;\n grid-auto-flow: row;\n grid-row-gap: 8px;\n ", "\n\n @media ", " {\n ", "\n }\n"])), theme$2(function (o) {
1231
- return [o.padding.horizontal(24).top(16)];
1232
- }), function (_ref2) {
1233
- var theme = _ref2.theme;
1234
- return maxWidth(theme.breakpoint.screen1);
1235
- }, theme$2(function (o) {
1236
- return [o.padding.horizontal(16)];
1237
- }));
1238
-
1239
- var _templateObject$4, _templateObject2$4, _templateObject3$4;
1240
- function LoadingSpinner(_ref) {
1241
- var _ref$size = _ref.size,
1242
- size = _ref$size === void 0 ? 48 : _ref$size,
1243
- _ref$padding = _ref.padding,
1244
- padding = _ref$padding === void 0 ? 16 : _ref$padding,
1245
- _ref$transparent = _ref.transparent,
1246
- transparent = _ref$transparent === void 0 ? false : _ref$transparent;
1247
- return /*#__PURE__*/React.createElement(LoadingSpinnerRoot, {
1248
- size: size,
1249
- padding: padding,
1250
- transparent: transparent
1251
- }, /*#__PURE__*/React.createElement(LoadingSpinnerIcon, null));
1252
- }
1253
- var LoadingSpinnerRoot = styled.div.attrs({
1254
- role: 'progressbar'
1255
- })(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteralLoose(["\n margin: auto;\n padding: ", "px;\n border-radius: 8px;\n font-size: ", "px;\n width: ", "px;\n height: ", "px;\n background-color: ", ";\n color: ", ";\n"])), function (props) {
1256
- return props.padding;
1257
- }, function (props) {
1258
- return props.size;
1259
- }, function (props) {
1260
- return props.size;
1261
- }, function (props) {
1262
- return props.size;
1263
- }, function (_ref2) {
1264
- var theme = _ref2.theme,
1265
- transparent = _ref2.transparent;
1266
- return transparent ? 'transparent' : transparentize(0.32, theme.color.background1);
1267
- }, function (_ref3) {
1268
- var theme = _ref3.theme;
1269
- return theme.color.text4;
1270
- });
1271
- var scaleout = keyframes(_templateObject2$4 || (_templateObject2$4 = _taggedTemplateLiteralLoose(["\n from {\n transform: scale(0);\n opacity: 1;\n }\n\n to {\n transform: scale(1);\n opacity: 0;\n }\n"])));
1272
- var Icon = styled.div.attrs({
1273
- role: 'presentation'
1274
- })(_templateObject3$4 || (_templateObject3$4 = _taggedTemplateLiteralLoose(["\n width: 1em;\n height: 1em;\n border-radius: 1em;\n background-color: currentColor;\n animation: ", " 1s both ease-out;\n animation-iteration-count: ", ";\n\n &[data-reset-animation] {\n animation: none;\n }\n"])), scaleout, function (p) {
1275
- return p.once ? 1 : 'infinite';
1276
- });
1277
- var LoadingSpinnerIcon = React.forwardRef(function LoadingSpinnerIcon(_ref4, ref) {
1278
- var _ref4$once = _ref4.once,
1279
- once = _ref4$once === void 0 ? false : _ref4$once;
1280
- var iconRef = useRef(null);
1281
- useImperativeHandle(ref, function () {
1282
- return {
1283
- restart: function restart() {
1284
- if (!iconRef.current) {
1285
- return;
1286
- }
1287
-
1288
- iconRef.current.dataset.resetAnimation = 'true'; // Force reflow hack!
1289
- delete iconRef.current.dataset.resetAnimation;
1290
- }
1291
- };
1292
- });
1293
- return /*#__PURE__*/React.createElement(Icon, {
1294
- ref: iconRef,
1295
- once: once
1296
- });
1297
- });
1298
-
1299
- function toVal(mix) {
1300
- var k,
1301
- y,
1302
- str = '';
1303
-
1304
- if (typeof mix === 'string' || typeof mix === 'number') {
1305
- str += mix;
1306
- } else if (typeof mix === 'object') {
1307
- if (Array.isArray(mix)) {
1308
- for (k = 0; k < mix.length; k++) {
1309
- if (mix[k]) {
1310
- if (y = toVal(mix[k])) {
1311
- str && (str += ' ');
1312
- str += y;
1313
- }
1314
- }
1315
- }
1316
- } else {
1317
- for (k in mix) {
1318
- if (mix[k]) {
1319
- str && (str += ' ');
1320
- str += k;
1321
- }
1322
- }
1323
- }
1324
- }
1325
-
1326
- return str;
1327
- }
1328
-
1329
- function $12uGp$clsx () {
1330
- var i = 0,
1331
- tmp,
1332
- x,
1333
- str = '';
1334
-
1335
- while (i < arguments.length) {
1336
- if (tmp = arguments[i++]) {
1337
- if (x = toVal(tmp)) {
1338
- str && (str += ' ');
1339
- str += x;
1340
- }
1341
- }
1342
- }
1343
-
1344
- return str;
1345
- }
1346
-
1347
- var $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c = typeof window !== 'undefined' ? React.useLayoutEffect : function () {};
1348
- var $bdb11010cef70236$var$idsUpdaterMap = new Map();
1349
-
1350
- function $bdb11010cef70236$export$f680877a34711e37(defaultId) {
1351
- var _$12uGp$useState = useState(defaultId),
1352
- value = _$12uGp$useState[0],
1353
- setValue = _$12uGp$useState[1];
1354
-
1355
- var nextId = useRef(null);
1356
- var res = useSSRSafeId(value);
1357
- var updateValue = useCallback(function (val) {
1358
- nextId.current = val;
1359
- }, []);
1360
- $bdb11010cef70236$var$idsUpdaterMap.set(res, updateValue);
1361
- $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(function () {
1362
- var r = res;
1363
- return function () {
1364
- $bdb11010cef70236$var$idsUpdaterMap["delete"](r);
1365
- };
1366
- }, [res]); // This cannot cause an infinite loop because the ref is updated first.
1367
- // eslint-disable-next-line
1368
-
1369
- useEffect(function () {
1370
- var newId = nextId.current;
1371
-
1372
- if (newId) {
1373
- nextId.current = null;
1374
- setValue(newId);
1375
- }
1376
- });
1377
- return res;
1378
- }
1379
-
1380
- function $bdb11010cef70236$export$cd8c9cb68f842629(idA, idB) {
1381
- if (idA === idB) return idA;
1382
- var setIdA = $bdb11010cef70236$var$idsUpdaterMap.get(idA);
1383
-
1384
- if (setIdA) {
1385
- setIdA(idB);
1386
- return idB;
1387
- }
1388
-
1389
- var setIdB = $bdb11010cef70236$var$idsUpdaterMap.get(idB);
1390
-
1391
- if (setIdB) {
1392
- setIdB(idA);
1393
- return idA;
1394
- }
1395
-
1396
- return idB;
1397
- }
1398
-
1399
- function $bdb11010cef70236$export$b4cc09c592e8fdb8(depArray) {
1400
- if (depArray === void 0) {
1401
- depArray = [];
1402
- }
1403
-
1404
- var id = $bdb11010cef70236$export$f680877a34711e37();
1405
-
1406
- var _$1dbecbe27a04f9af$ex = $1dbecbe27a04f9af$export$14d238f342723f25(id),
1407
- resolvedId = _$1dbecbe27a04f9af$ex[0],
1408
- setResolvedId = _$1dbecbe27a04f9af$ex[1];
1409
-
1410
- var updateId = useCallback(function () {
1411
- setResolvedId( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
1412
- return regeneratorRuntime.wrap(function _callee$(_context) {
1413
- while (1) {
1414
- switch (_context.prev = _context.next) {
1415
- case 0:
1416
- _context.next = 2;
1417
- return id;
1418
-
1419
- case 2:
1420
- _context.next = 4;
1421
- return document.getElementById(id) ? id : undefined;
1422
-
1423
- case 4:
1424
- case "end":
1425
- return _context.stop();
1426
- }
1427
- }
1428
- }, _callee);
1429
- }));
1430
- }, [id, setResolvedId]);
1431
- $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(updateId, [id, updateId].concat(depArray));
1432
- return resolvedId;
1433
- }
1434
-
1435
- function $ff5963eb1fccf552$export$e08e3b67e392101e() {
1436
- var _arguments = arguments;
1437
- return function () {
1438
- for (var _iterator = _createForOfIteratorHelperLoose([].slice.call(_arguments)), _step; !(_step = _iterator()).done;) {
1439
- var callback = _step.value;
1440
- if (typeof callback === 'function') callback.apply(void 0, [].slice.call(arguments));
1441
- }
1442
- };
1443
- }
1444
-
1445
- function $3ef42575df84b30b$export$9d1611c77c2fe928() {
1446
- var args = [].slice.call(arguments);
1447
-
1448
- // Start with a base clone of the first argument. This is a lot faster than starting
1449
- // with an empty object and adding properties as we go.
1450
- var result = _extends({}, args[0]);
1451
-
1452
- for (var i = 1; i < args.length; i++) {
1453
- var props = args[i];
1454
-
1455
- for (var key in props) {
1456
- var a = result[key];
1457
- var b = props[key]; // Chain events
1458
-
1459
- if (typeof a === 'function' && typeof b === 'function' && // This is a lot faster than a regex.
1460
- key[0] === 'o' && key[1] === 'n' && key.charCodeAt(2) >=
1461
- /* 'A' */
1462
- 65 && key.charCodeAt(2) <=
1463
- /* 'Z' */
1464
- 90) result[key] = $ff5963eb1fccf552$export$e08e3b67e392101e(a, b);else if ((key === 'className' || key === 'UNSAFE_className') && typeof a === 'string' && typeof b === 'string') result[key] = $12uGp$clsx(a, b);else if (key === 'id' && a && b) result.id = $bdb11010cef70236$export$cd8c9cb68f842629(a, b);else result[key] = b !== undefined ? b : a;
1465
- }
1466
- }
1467
-
1468
- return result;
1469
- }
1470
-
1471
- var $65484d02dcb7eb3e$var$DOMPropNames = new Set(['id']);
1472
- var $65484d02dcb7eb3e$var$labelablePropNames = new Set(['aria-label', 'aria-labelledby', 'aria-describedby', 'aria-details']);
1473
- var $65484d02dcb7eb3e$var$propRe = /^(data-.*)$/;
1474
-
1475
- function $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, opts) {
1476
- if (opts === void 0) {
1477
- opts = {};
1478
- }
1479
-
1480
- var _opts = opts,
1481
- labelable = _opts.labelable,
1482
- propNames = _opts.propNames;
1483
- var filteredProps = {};
1484
-
1485
- for (var prop in props) {
1486
- if (Object.prototype.hasOwnProperty.call(props, prop) && ($65484d02dcb7eb3e$var$DOMPropNames.has(prop) || labelable && $65484d02dcb7eb3e$var$labelablePropNames.has(prop) || (propNames === null || propNames === void 0 ? void 0 : propNames.has(prop)) || $65484d02dcb7eb3e$var$propRe.test(prop))) filteredProps[prop] = props[prop];
1487
- }
1488
-
1489
- return filteredProps;
1490
- }
1491
-
1492
- function $7215afc6de606d6b$export$de79e2c695e052f3(element) {
1493
- if ($7215afc6de606d6b$var$supportsPreventScroll()) element.focus({
1494
- preventScroll: true
1495
- });else {
1496
- var scrollableElements = $7215afc6de606d6b$var$getScrollableElements(element);
1497
- element.focus();
1498
- $7215afc6de606d6b$var$restoreScrollPosition(scrollableElements);
1499
- }
1500
- }
1501
-
1502
- var $7215afc6de606d6b$var$supportsPreventScrollCached = null;
1503
-
1504
- function $7215afc6de606d6b$var$supportsPreventScroll() {
1505
- if ($7215afc6de606d6b$var$supportsPreventScrollCached == null) {
1506
- $7215afc6de606d6b$var$supportsPreventScrollCached = false;
1507
-
1508
- try {
1509
- var focusElem = document.createElement('div');
1510
- focusElem.focus({
1511
- get preventScroll() {
1512
- $7215afc6de606d6b$var$supportsPreventScrollCached = true;
1513
- return true;
1514
- }
1515
-
1516
- });
1517
- } catch (e) {// Ignore
1518
- }
1519
- }
1520
-
1521
- return $7215afc6de606d6b$var$supportsPreventScrollCached;
1522
- }
1523
-
1524
- function $7215afc6de606d6b$var$getScrollableElements(element) {
1525
- var parent = element.parentNode;
1526
- var scrollableElements = [];
1527
- var rootScrollingElement = document.scrollingElement || document.documentElement;
1528
-
1529
- while (parent instanceof HTMLElement && parent !== rootScrollingElement) {
1530
- if (parent.offsetHeight < parent.scrollHeight || parent.offsetWidth < parent.scrollWidth) scrollableElements.push({
1531
- element: parent,
1532
- scrollTop: parent.scrollTop,
1533
- scrollLeft: parent.scrollLeft
1534
- });
1535
- parent = parent.parentNode;
1536
- }
1537
-
1538
- if (rootScrollingElement instanceof HTMLElement) scrollableElements.push({
1539
- element: rootScrollingElement,
1540
- scrollTop: rootScrollingElement.scrollTop,
1541
- scrollLeft: rootScrollingElement.scrollLeft
1542
- });
1543
- return scrollableElements;
1544
- }
1545
-
1546
- function $7215afc6de606d6b$var$restoreScrollPosition(scrollableElements) {
1547
- for (var _iterator3 = _createForOfIteratorHelperLoose(scrollableElements), _step3; !(_step3 = _iterator3()).done;) {
1548
- var _step3$value = _step3.value,
1549
- element = _step3$value.element,
1550
- scrollTop = _step3$value.scrollTop,
1551
- scrollLeft = _step3$value.scrollLeft;
1552
- element.scrollTop = scrollTop;
1553
- element.scrollLeft = scrollLeft;
1554
- }
1555
- }
1556
- /*
1557
- * Copyright 2020 Adobe. All rights reserved.
1558
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1559
- * you may not use this file except in compliance with the License. You may obtain a copy
1560
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
1561
- *
1562
- * Unless required by applicable law or agreed to in writing, software distributed under
1563
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1564
- * OF ANY KIND, either express or implied. See the License for the specific language
1565
- * governing permissions and limitations under the License.
1566
- */
1567
- // We store a global list of elements that are currently transitioning,
1568
- // mapped to a set of CSS properties that are transitioning for that element.
1569
- // This is necessary rather than a simple count of transitions because of browser
1570
- // bugs, e.g. Chrome sometimes fires both transitionend and transitioncancel rather
1571
- // than one or the other. So we need to track what's actually transitioning so that
1572
- // we can ignore these duplicate events.
1573
-
1574
-
1575
- var $bbed8b41f857bcc0$var$transitionsByElement = new Map(); // A list of callbacks to call once there are no transitioning elements.
1576
-
1577
- var $bbed8b41f857bcc0$var$transitionCallbacks = new Set();
1578
-
1579
- function $bbed8b41f857bcc0$var$setupGlobalEvents() {
1580
- if (typeof window === 'undefined') return;
1581
-
1582
- var onTransitionStart = function onTransitionStart(e) {
1583
- // Add the transitioning property to the list for this element.
1584
- var transitions = $bbed8b41f857bcc0$var$transitionsByElement.get(e.target);
1585
-
1586
- if (!transitions) {
1587
- transitions = new Set();
1588
- $bbed8b41f857bcc0$var$transitionsByElement.set(e.target, transitions); // The transitioncancel event must be registered on the element itself, rather than as a global
1589
- // event. This enables us to handle when the node is deleted from the document while it is transitioning.
1590
- // In that case, the cancel event would have nowhere to bubble to so we need to handle it directly.
1591
-
1592
- e.target.addEventListener('transitioncancel', onTransitionEnd);
1593
- }
1594
-
1595
- transitions.add(e.propertyName);
1596
- };
1597
-
1598
- var onTransitionEnd = function onTransitionEnd(e) {
1599
- // Remove property from list of transitioning properties.
1600
- var properties = $bbed8b41f857bcc0$var$transitionsByElement.get(e.target);
1601
- if (!properties) return;
1602
- properties["delete"](e.propertyName); // If empty, remove transitioncancel event, and remove the element from the list of transitioning elements.
1603
-
1604
- if (properties.size === 0) {
1605
- e.target.removeEventListener('transitioncancel', onTransitionEnd);
1606
- $bbed8b41f857bcc0$var$transitionsByElement["delete"](e.target);
1607
- } // If no transitioning elements, call all of the queued callbacks.
1608
-
1609
-
1610
- if ($bbed8b41f857bcc0$var$transitionsByElement.size === 0) {
1611
- for (var _iterator4 = _createForOfIteratorHelperLoose($bbed8b41f857bcc0$var$transitionCallbacks), _step4; !(_step4 = _iterator4()).done;) {
1612
- var cb = _step4.value;
1613
- cb();
1614
- }
1615
-
1616
- $bbed8b41f857bcc0$var$transitionCallbacks.clear();
1617
- }
1618
- };
1619
-
1620
- document.body.addEventListener('transitionrun', onTransitionStart);
1621
- document.body.addEventListener('transitionend', onTransitionEnd);
1622
- }
1623
-
1624
- if (typeof document !== 'undefined') {
1625
- if (document.readyState !== 'loading') $bbed8b41f857bcc0$var$setupGlobalEvents();else document.addEventListener('DOMContentLoaded', $bbed8b41f857bcc0$var$setupGlobalEvents);
1626
- }
1627
-
1628
- function $bbed8b41f857bcc0$export$24490316f764c430(fn) {
1629
- // Wait one frame to see if an animation starts, e.g. a transition on mount.
1630
- requestAnimationFrame(function () {
1631
- // If no transitions are running, call the function immediately.
1632
- // Otherwise, add it to a list of callbacks to run at the end of the animation.
1633
- if ($bbed8b41f857bcc0$var$transitionsByElement.size === 0) fn();else $bbed8b41f857bcc0$var$transitionCallbacks.add(fn);
1634
- });
1635
- } // Keep track of elements that we are currently handling dragging for via useDrag1D.
1636
-
1637
- function $03deb23ff14920c4$export$4eaf04e54aa8eed6() {
1638
- var globalListeners = useRef(new Map());
1639
- var addGlobalListener = useCallback(function (eventTarget, type, listener, options) {
1640
- // Make sure we remove the listener after it is called with the `once` option.
1641
- var fn = (options === null || options === void 0 ? void 0 : options.once) ? function () {
1642
- globalListeners.current["delete"](listener);
1643
- listener.apply(void 0, [].slice.call(arguments));
1644
- } : listener;
1645
- globalListeners.current.set(listener, {
1646
- type: type,
1647
- eventTarget: eventTarget,
1648
- fn: fn,
1649
- options: options
1650
- });
1651
- eventTarget.addEventListener(type, listener, options);
1652
- }, []);
1653
- var removeGlobalListener = useCallback(function (eventTarget, type, listener, options) {
1654
- var ref;
1655
- var fn = ((ref = globalListeners.current.get(listener)) === null || ref === void 0 ? void 0 : ref.fn) || listener;
1656
- eventTarget.removeEventListener(type, fn, options);
1657
- globalListeners.current["delete"](listener);
1658
- }, []);
1659
- var removeAllGlobalListeners = useCallback(function () {
1660
- globalListeners.current.forEach(function (value, key) {
1661
- removeGlobalListener(value.eventTarget, value.type, key, value.options);
1662
- });
1663
- }, [removeGlobalListener]); // eslint-disable-next-line arrow-body-style
1664
-
1665
- useEffect(function () {
1666
- return removeAllGlobalListeners;
1667
- }, [removeAllGlobalListeners]);
1668
- return {
1669
- addGlobalListener: addGlobalListener,
1670
- removeGlobalListener: removeGlobalListener,
1671
- removeAllGlobalListeners: removeAllGlobalListeners
1672
- };
1673
- }
1674
-
1675
- function $313b98861ee5dd6c$export$d6875122194c7b44(props, defaultLabel) {
1676
- var id = props.id,
1677
- label = props['aria-label'],
1678
- labelledBy = props['aria-labelledby']; // If there is both an aria-label and aria-labelledby,
1679
- // combine them by pointing to the element itself.
1680
-
1681
- id = $bdb11010cef70236$export$f680877a34711e37(id);
1682
-
1683
- if (labelledBy && label) {
1684
- var ids = new Set([].concat(labelledBy.trim().split(/\s+/), [id]));
1685
- labelledBy = [].concat(ids).join(' ');
1686
- } else if (labelledBy) labelledBy = labelledBy.trim().split(/\s+/).join(' '); // If no labels are provided, use the default
1687
-
1688
-
1689
- if (!label && !labelledBy && defaultLabel) label = defaultLabel;
1690
- return {
1691
- id: id,
1692
- 'aria-label': label,
1693
- 'aria-labelledby': labelledBy
1694
- };
1695
- }
1696
-
1697
- function $df56164dff5785e2$export$4338b53315abf666(forwardedRef) {
1698
- var objRef = useRef();
1699
- /**
1700
- * We're using `useLayoutEffect` here instead of `useEffect` because we want
1701
- * to make sure that the `ref` value is up to date before other places in the
1702
- * the execution cycle try to read it.
1703
- */
1704
-
1705
- $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(function () {
1706
- if (!forwardedRef) return;
1707
- if (typeof forwardedRef === 'function') forwardedRef(objRef.current);else forwardedRef.current = objRef.current;
1708
- }, [forwardedRef]);
1709
- return objRef;
1710
- }
1711
-
1712
- function $e7801be82b4b2a53$export$4debdb1a3f0fa79e(context, ref) {
1713
- $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(function () {
1714
- if (context && context.ref && ref) {
1715
- context.ref.current = ref.current;
1716
- return function () {
1717
- context.ref.current = null;
1718
- };
1719
- }
1720
- }, [context, ref]);
1721
- }
1722
-
1723
- var $ef06256079686ba0$var$descriptionId = 0;
1724
- var $ef06256079686ba0$var$descriptionNodes = new Map();
1725
-
1726
- function $ef06256079686ba0$export$f8aeda7b10753fa1(description) {
1727
- var _$12uGp$useState3 = useState(undefined),
1728
- id1 = _$12uGp$useState3[0],
1729
- setId = _$12uGp$useState3[1];
1730
-
1731
- $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(function () {
1732
- if (!description) return;
1733
- var desc = $ef06256079686ba0$var$descriptionNodes.get(description);
1734
-
1735
- if (!desc) {
1736
- var id = "react-aria-description-" + $ef06256079686ba0$var$descriptionId++;
1737
- setId(id);
1738
- var node = document.createElement('div');
1739
- node.id = id;
1740
- node.style.display = 'none';
1741
- node.textContent = description;
1742
- document.body.appendChild(node);
1743
- desc = {
1744
- refCount: 0,
1745
- element: node
1746
- };
1747
- $ef06256079686ba0$var$descriptionNodes.set(description, desc);
1748
- } else setId(desc.element.id);
1749
-
1750
- desc.refCount++;
1751
- return function () {
1752
- if (--desc.refCount === 0) {
1753
- desc.element.remove();
1754
- $ef06256079686ba0$var$descriptionNodes["delete"](description);
1755
- }
1756
- };
1757
- }, [description]);
1758
- return {
1759
- 'aria-describedby': description ? id1 : undefined
1760
- };
1761
- }
1762
- /*
1763
- * Copyright 2020 Adobe. All rights reserved.
1764
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1765
- * you may not use this file except in compliance with the License. You may obtain a copy
1766
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
1767
- *
1768
- * Unless required by applicable law or agreed to in writing, software distributed under
1769
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1770
- * OF ANY KIND, either express or implied. See the License for the specific language
1771
- * governing permissions and limitations under the License.
1772
- */
1773
-
1774
-
1775
- function $c87311424ea30a05$var$testUserAgent(re) {
1776
- var ref;
1777
- if (typeof window === 'undefined' || window.navigator == null) return false;
1778
- return ((ref = window.navigator['userAgentData']) === null || ref === void 0 ? void 0 : ref.brands.some(function (brand) {
1779
- return re.test(brand.brand);
1780
- })) || re.test(window.navigator.userAgent);
1781
- }
1782
-
1783
- function $c87311424ea30a05$var$testPlatform(re) {
1784
- var ref;
1785
- return typeof window !== 'undefined' && window.navigator != null ? re.test(((ref = window.navigator['userAgentData']) === null || ref === void 0 ? void 0 : ref.platform) || window.navigator.platform) : false;
1786
- }
1787
-
1788
- function $c87311424ea30a05$export$9ac100e40613ea10() {
1789
- return $c87311424ea30a05$var$testPlatform(/^Mac/i);
1790
- }
1791
-
1792
- function $c87311424ea30a05$export$186c6964ca17d99() {
1793
- return $c87311424ea30a05$var$testPlatform(/^iPhone/i);
1794
- }
1795
-
1796
- function $c87311424ea30a05$export$7bef049ce92e4224() {
1797
- return $c87311424ea30a05$var$testPlatform(/^iPad/i) || $c87311424ea30a05$export$9ac100e40613ea10() && navigator.maxTouchPoints > 1;
1798
- }
1799
-
1800
- function $c87311424ea30a05$export$fedb369cb70207f1() {
1801
- return $c87311424ea30a05$export$186c6964ca17d99() || $c87311424ea30a05$export$7bef049ce92e4224();
1802
- }
1803
-
1804
- function $c87311424ea30a05$export$e1865c3bedcd822b() {
1805
- return $c87311424ea30a05$export$9ac100e40613ea10() || $c87311424ea30a05$export$fedb369cb70207f1();
1806
- }
1807
-
1808
- function $c87311424ea30a05$export$78551043582a6a98() {
1809
- return $c87311424ea30a05$var$testUserAgent(/AppleWebKit/i) && !$c87311424ea30a05$export$6446a186d09e379e();
1810
- }
1811
-
1812
- function $c87311424ea30a05$export$6446a186d09e379e() {
1813
- return $c87311424ea30a05$var$testUserAgent(/Chrome/i);
1814
- }
1815
-
1816
- function $c87311424ea30a05$export$a11b0059900ceec8() {
1817
- return $c87311424ea30a05$var$testUserAgent(/Android/i);
1818
- }
1819
-
1820
- function $e9faafb641e167db$export$90fc3a17d93f704c(ref, event, handler1, options) {
1821
- var _this = this;
1822
-
1823
- var handlerRef = useRef(handler1);
1824
- handlerRef.current = handler1;
1825
- var isDisabled = handler1 == null;
1826
- useEffect(function () {
1827
- if (isDisabled) return;
1828
- var element = ref.current;
1829
-
1830
- var handler = function handler(e) {
1831
- return handlerRef.current.call(_this, e);
1832
- };
1833
-
1834
- element.addEventListener(event, handler, options);
1835
- return function () {
1836
- element.removeEventListener(event, handler, options);
1837
- };
1838
- }, [ref, event, options, isDisabled]);
1839
- }
1840
-
1841
- function $1dbecbe27a04f9af$export$14d238f342723f25(defaultValue) {
1842
- var _$12uGp$useState4 = useState(defaultValue),
1843
- value = _$12uGp$useState4[0],
1844
- setValue = _$12uGp$useState4[1];
1845
-
1846
- var valueRef = useRef(value);
1847
- var effect = useRef(null);
1848
- valueRef.current = value; // Store the function in a ref so we can always access the current version
1849
- // which has the proper `value` in scope.
1850
-
1851
- var nextRef = useRef(null);
1852
-
1853
- nextRef.current = function () {
1854
- // Run the generator to the next yield.
1855
- var newValue = effect.current.next(); // If the generator is done, reset the effect.
1856
-
1857
- if (newValue.done) {
1858
- effect.current = null;
1859
- return;
1860
- } // If the value is the same as the current value,
1861
- // then continue to the next yield. Otherwise,
1862
- // set the value in state and wait for the next layout effect.
1863
-
1864
-
1865
- if (value === newValue.value) nextRef.current();else setValue(newValue.value);
1866
- };
1867
-
1868
- $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(function () {
1869
- // If there is an effect currently running, continue to the next yield.
1870
- if (effect.current) nextRef.current();
1871
- });
1872
- var queue = useCallback(function (fn) {
1873
- effect.current = fn(valueRef.current);
1874
- nextRef.current();
1875
- }, [effect, nextRef]);
1876
- return [value, queue];
1877
- }
1878
-
1879
- function $2f04cbc44ee30ce0$export$53a0910f038337bd(scrollView, element) {
1880
- var offsetX = $2f04cbc44ee30ce0$var$relativeOffset(scrollView, element, 'left');
1881
- var offsetY = $2f04cbc44ee30ce0$var$relativeOffset(scrollView, element, 'top');
1882
- var width = element.offsetWidth;
1883
- var height = element.offsetHeight;
1884
- var x = scrollView.scrollLeft;
1885
- var y = scrollView.scrollTop;
1886
- var maxX = x + scrollView.offsetWidth;
1887
- var maxY = y + scrollView.offsetHeight;
1888
- if (offsetX <= x) x = offsetX;else if (offsetX + width > maxX) x += offsetX + width - maxX;
1889
- if (offsetY <= y) y = offsetY;else if (offsetY + height > maxY) y += offsetY + height - maxY;
1890
- scrollView.scrollLeft = x;
1891
- scrollView.scrollTop = y;
1892
- }
1893
- /**
1894
- * Computes the offset left or top from child to ancestor by accumulating
1895
- * offsetLeft or offsetTop through intervening offsetParents.
1896
- */
1897
-
1898
-
1899
- function $2f04cbc44ee30ce0$var$relativeOffset(ancestor, child, axis) {
1900
- var prop = axis === 'left' ? 'offsetLeft' : 'offsetTop';
1901
- var sum = 0;
1902
-
1903
- while (child.offsetParent) {
1904
- sum += child[prop];
1905
- if (child.offsetParent === ancestor) break;else if (child.offsetParent.contains(ancestor)) {
1906
- // If the ancestor is not `position:relative`, then we stop at
1907
- // _its_ offset parent, and we subtract off _its_ offset, so that
1908
- // we end up with the proper offset from child to ancestor.
1909
- sum -= ancestor[prop];
1910
- break;
1911
- }
1912
- child = child.offsetParent;
1913
- }
1914
-
1915
- return sum;
1916
- }
1917
-
1918
- function $6a7db85432448f7f$export$60278871457622de(event) {
1919
- // JAWS/NVDA with Firefox.
1920
- if (event.mozInputSource === 0 && event.isTrusted) return true; // Android TalkBack's detail value varies depending on the event listener providing the event so we have specific logic here instead
1921
- // If pointerType is defined, event is from a click listener. For events from mousedown listener, detail === 0 is a sufficient check
1922
- // to detect TalkBack virtual clicks.
1923
-
1924
- if ($c87311424ea30a05$export$a11b0059900ceec8() && event.pointerType) return event.type === 'click' && event.buttons === 1;
1925
- return event.detail === 0 && !event.pointerType;
1926
- }
1927
-
1928
- function $6a7db85432448f7f$export$29bf1b5f2c56cf63(event) {
1929
- // If the pointer size is zero, then we assume it's from a screen reader.
1930
- // Android TalkBack double tap will sometimes return a event with width and height of 1
1931
- // and pointerType === 'mouse' so we need to check for a specific combination of event attributes.
1932
- // Cannot use "event.pressure === 0" as the sole check due to Safari pointer events always returning pressure === 0
1933
- // instead of .5, see https://bugs.webkit.org/show_bug.cgi?id=206216. event.pointerType === 'mouse' is to distingush
1934
- // Talkback double tap from Windows Firefox touch screen press
1935
- return event.width === 0 && event.height === 0 || event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === 'mouse';
1936
- }
1937
-
1938
- var _excluded$4 = ["register"],
1939
- _excluded2 = ["onPress", "onPressChange", "onPressStart", "onPressEnd", "onPressUp", "isDisabled", "isPressed", "preventFocusOnPress", "shouldCancelOnPointerExit", "allowTextSelectionOnPress", "ref"];
1940
- // rather than at the document level so we just need to apply/remove user-select: none for each pressed element individually
1941
-
1942
- var $14c0b72509d70225$var$state = 'default';
1943
- var $14c0b72509d70225$var$savedUserSelect = '';
1944
- var $14c0b72509d70225$var$modifiedElementMap = new WeakMap();
1945
-
1946
- function $14c0b72509d70225$export$16a4697467175487(target) {
1947
- if ($c87311424ea30a05$export$fedb369cb70207f1()) {
1948
- if ($14c0b72509d70225$var$state === 'default') {
1949
- $14c0b72509d70225$var$savedUserSelect = document.documentElement.style.webkitUserSelect;
1950
- document.documentElement.style.webkitUserSelect = 'none';
1951
- }
1952
-
1953
- $14c0b72509d70225$var$state = 'disabled';
1954
- } else if (target instanceof HTMLElement || target instanceof SVGElement) {
1955
- // If not iOS, store the target's original user-select and change to user-select: none
1956
- // Ignore state since it doesn't apply for non iOS
1957
- $14c0b72509d70225$var$modifiedElementMap.set(target, target.style.userSelect);
1958
- target.style.userSelect = 'none';
1959
- }
1960
- }
1961
-
1962
- function $14c0b72509d70225$export$b0d6fa1ab32e3295(target) {
1963
- if ($c87311424ea30a05$export$fedb369cb70207f1()) {
1964
- // If the state is already default, there's nothing to do.
1965
- // If it is restoring, then there's no need to queue a second restore.
1966
- if ($14c0b72509d70225$var$state !== 'disabled') return;
1967
- $14c0b72509d70225$var$state = 'restoring'; // There appears to be a delay on iOS where selection still might occur
1968
- // after pointer up, so wait a bit before removing user-select.
1969
-
1970
- setTimeout(function () {
1971
- // Wait for any CSS transitions to complete so we don't recompute style
1972
- // for the whole page in the middle of the animation and cause jank.
1973
- $bbed8b41f857bcc0$export$24490316f764c430(function () {
1974
- // Avoid race conditions
1975
- if ($14c0b72509d70225$var$state === 'restoring') {
1976
- if (document.documentElement.style.webkitUserSelect === 'none') document.documentElement.style.webkitUserSelect = $14c0b72509d70225$var$savedUserSelect || '';
1977
- $14c0b72509d70225$var$savedUserSelect = '';
1978
- $14c0b72509d70225$var$state = 'default';
1979
- }
1980
- });
1981
- }, 300);
1982
- } else if (target instanceof HTMLElement || target instanceof SVGElement) // If not iOS, restore the target's original user-select if any
1983
- // Ignore state since it doesn't apply for non iOS
1984
- {
1985
- if (target && $14c0b72509d70225$var$modifiedElementMap.has(target)) {
1986
- var targetOldUserSelect = $14c0b72509d70225$var$modifiedElementMap.get(target);
1987
- if (target.style.userSelect === 'none') target.style.userSelect = targetOldUserSelect;
1988
- if (target.getAttribute('style') === '') target.removeAttribute('style');
1989
- $14c0b72509d70225$var$modifiedElementMap["delete"](target);
1990
- }
1991
- }
1992
- }
1993
-
1994
- var $ae1eeba8b9eafd08$export$5165eccb35aaadb5 = React.createContext(null);
1995
- $ae1eeba8b9eafd08$export$5165eccb35aaadb5.displayName = 'PressResponderContext';
1996
-
1997
- function $f6c31cce2adf654f$var$usePressResponderContext(props) {
1998
- // Consume context from <PressResponder> and merge with props.
1999
- var context = useContext($ae1eeba8b9eafd08$export$5165eccb35aaadb5);
2000
-
2001
- if (context) {
2002
- var register = context.register,
2003
- contextProps = _objectWithoutPropertiesLoose(context, _excluded$4);
2004
-
2005
- props = $3ef42575df84b30b$export$9d1611c77c2fe928(contextProps, props);
2006
- register();
2007
- }
2008
-
2009
- $e7801be82b4b2a53$export$4debdb1a3f0fa79e(context, props.ref);
2010
- return props;
2011
- }
2012
-
2013
- function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
2014
- var _$f6c31cce2adf654f$va = $f6c31cce2adf654f$var$usePressResponderContext(props),
2015
- onPress1 = _$f6c31cce2adf654f$va.onPress,
2016
- onPressChange1 = _$f6c31cce2adf654f$va.onPressChange,
2017
- onPressStart1 = _$f6c31cce2adf654f$va.onPressStart,
2018
- onPressEnd1 = _$f6c31cce2adf654f$va.onPressEnd,
2019
- onPressUp1 = _$f6c31cce2adf654f$va.onPressUp,
2020
- isDisabled1 = _$f6c31cce2adf654f$va.isDisabled,
2021
- isPressedProp = _$f6c31cce2adf654f$va.isPressed,
2022
- preventFocusOnPress = _$f6c31cce2adf654f$va.preventFocusOnPress,
2023
- shouldCancelOnPointerExit = _$f6c31cce2adf654f$va.shouldCancelOnPointerExit,
2024
- allowTextSelectionOnPress = _$f6c31cce2adf654f$va.allowTextSelectionOnPress,
2025
- domProps = _objectWithoutPropertiesLoose(_$f6c31cce2adf654f$va, _excluded2);
2026
-
2027
- var propsRef = useRef(null);
2028
- propsRef.current = {
2029
- onPress: onPress1,
2030
- onPressChange: onPressChange1,
2031
- onPressStart: onPressStart1,
2032
- onPressEnd: onPressEnd1,
2033
- onPressUp: onPressUp1,
2034
- isDisabled: isDisabled1,
2035
- shouldCancelOnPointerExit: shouldCancelOnPointerExit
2036
- };
2037
-
2038
- var _$bx7SL$useState = useState(false),
2039
- isPressed = _$bx7SL$useState[0],
2040
- setPressed = _$bx7SL$useState[1];
2041
-
2042
- var ref = useRef({
2043
- isPressed: false,
2044
- ignoreEmulatedMouseEvents: false,
2045
- ignoreClickAfterPress: false,
2046
- didFirePressStart: false,
2047
- activePointerId: null,
2048
- target: null,
2049
- isOverTarget: false,
2050
- pointerType: null
2051
- });
2052
-
2053
- var _$bx7SL$useGlobalList = $03deb23ff14920c4$export$4eaf04e54aa8eed6(),
2054
- addGlobalListener = _$bx7SL$useGlobalList.addGlobalListener,
2055
- removeAllGlobalListeners = _$bx7SL$useGlobalList.removeAllGlobalListeners;
2056
-
2057
- var pressProps1 = useMemo(function () {
2058
- var state = ref.current;
2059
-
2060
- var triggerPressStart = function triggerPressStart(originalEvent, pointerType) {
2061
- var _propsRef$current = propsRef.current,
2062
- onPressStart = _propsRef$current.onPressStart,
2063
- onPressChange = _propsRef$current.onPressChange,
2064
- isDisabled = _propsRef$current.isDisabled;
2065
- if (isDisabled || state.didFirePressStart) return;
2066
- if (onPressStart) onPressStart({
2067
- type: 'pressstart',
2068
- pointerType: pointerType,
2069
- target: originalEvent.currentTarget,
2070
- shiftKey: originalEvent.shiftKey,
2071
- metaKey: originalEvent.metaKey,
2072
- ctrlKey: originalEvent.ctrlKey,
2073
- altKey: originalEvent.altKey
2074
- });
2075
- if (onPressChange) onPressChange(true);
2076
- state.didFirePressStart = true;
2077
- setPressed(true);
2078
- };
2079
-
2080
- var triggerPressEnd = function triggerPressEnd(originalEvent, pointerType, wasPressed) {
2081
- if (wasPressed === void 0) {
2082
- wasPressed = true;
2083
- }
2084
-
2085
- var _propsRef$current2 = propsRef.current,
2086
- onPressEnd = _propsRef$current2.onPressEnd,
2087
- onPressChange = _propsRef$current2.onPressChange,
2088
- onPress = _propsRef$current2.onPress,
2089
- isDisabled = _propsRef$current2.isDisabled;
2090
- if (!state.didFirePressStart) return;
2091
- state.ignoreClickAfterPress = true;
2092
- state.didFirePressStart = false;
2093
- if (onPressEnd) onPressEnd({
2094
- type: 'pressend',
2095
- pointerType: pointerType,
2096
- target: originalEvent.currentTarget,
2097
- shiftKey: originalEvent.shiftKey,
2098
- metaKey: originalEvent.metaKey,
2099
- ctrlKey: originalEvent.ctrlKey,
2100
- altKey: originalEvent.altKey
2101
- });
2102
- if (onPressChange) onPressChange(false);
2103
- setPressed(false);
2104
- if (onPress && wasPressed && !isDisabled) onPress({
2105
- type: 'press',
2106
- pointerType: pointerType,
2107
- target: originalEvent.currentTarget,
2108
- shiftKey: originalEvent.shiftKey,
2109
- metaKey: originalEvent.metaKey,
2110
- ctrlKey: originalEvent.ctrlKey,
2111
- altKey: originalEvent.altKey
2112
- });
2113
- };
2114
-
2115
- var triggerPressUp = function triggerPressUp(originalEvent, pointerType) {
2116
- var _propsRef$current3 = propsRef.current,
2117
- onPressUp = _propsRef$current3.onPressUp,
2118
- isDisabled = _propsRef$current3.isDisabled;
2119
- if (isDisabled) return;
2120
- if (onPressUp) onPressUp({
2121
- type: 'pressup',
2122
- pointerType: pointerType,
2123
- target: originalEvent.currentTarget,
2124
- shiftKey: originalEvent.shiftKey,
2125
- metaKey: originalEvent.metaKey,
2126
- ctrlKey: originalEvent.ctrlKey,
2127
- altKey: originalEvent.altKey
2128
- });
2129
- };
2130
-
2131
- var cancel = function cancel(e) {
2132
- if (state.isPressed) {
2133
- if (state.isOverTarget) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType, false);
2134
- state.isPressed = false;
2135
- state.isOverTarget = false;
2136
- state.activePointerId = null;
2137
- state.pointerType = null;
2138
- removeAllGlobalListeners();
2139
- if (!allowTextSelectionOnPress) $14c0b72509d70225$export$b0d6fa1ab32e3295(state.target);
2140
- }
2141
- };
2142
-
2143
- var pressProps = {
2144
- onKeyDown: function onKeyDown(e) {
2145
- if ($f6c31cce2adf654f$var$isValidKeyboardEvent(e.nativeEvent, e.currentTarget) && e.currentTarget.contains(e.target)) {
2146
- if ($f6c31cce2adf654f$var$shouldPreventDefaultKeyboard(e.target, e.key)) e.preventDefault();
2147
- e.stopPropagation(); // If the event is repeating, it may have started on a different element
2148
- // after which focus moved to the current element. Ignore these events and
2149
- // only handle the first key down event.
2150
-
2151
- if (!state.isPressed && !e.repeat) {
2152
- state.target = e.currentTarget;
2153
- state.isPressed = true;
2154
- triggerPressStart(e, 'keyboard'); // Focus may move before the key up event, so register the event on the document
2155
- // instead of the same element where the key down event occurred.
2156
-
2157
- addGlobalListener(document, 'keyup', onKeyUp, false);
2158
- }
2159
- } else if (e.key === 'Enter' && $f6c31cce2adf654f$var$isHTMLAnchorLink(e.currentTarget)) // If the target is a link, we won't have handled this above because we want the default
2160
- // browser behavior to open the link when pressing Enter. But we still need to prevent
2161
- // default so that elements above do not also handle it (e.g. table row).
2162
- e.stopPropagation();
2163
- },
2164
- onKeyUp: function onKeyUp(e) {
2165
- if ($f6c31cce2adf654f$var$isValidKeyboardEvent(e.nativeEvent, e.currentTarget) && !e.repeat && e.currentTarget.contains(e.target)) triggerPressUp($f6c31cce2adf654f$var$createEvent(state.target, e), 'keyboard');
2166
- },
2167
- onClick: function onClick(e) {
2168
- if (e && !e.currentTarget.contains(e.target)) return;
2169
-
2170
- if (e && e.button === 0) {
2171
- e.stopPropagation();
2172
- if (isDisabled1) e.preventDefault(); // If triggered from a screen reader or by using element.click(),
2173
- // trigger as if it were a keyboard click.
2174
-
2175
- if (!state.ignoreClickAfterPress && !state.ignoreEmulatedMouseEvents && (state.pointerType === 'virtual' || $6a7db85432448f7f$export$60278871457622de(e.nativeEvent))) {
2176
- // Ensure the element receives focus (VoiceOver on iOS does not do this)
2177
- if (!isDisabled1 && !preventFocusOnPress) $7215afc6de606d6b$export$de79e2c695e052f3(e.currentTarget);
2178
- triggerPressStart(e, 'virtual');
2179
- triggerPressUp(e, 'virtual');
2180
- triggerPressEnd(e, 'virtual');
2181
- }
2182
-
2183
- state.ignoreEmulatedMouseEvents = false;
2184
- state.ignoreClickAfterPress = false;
2185
- }
2186
- }
2187
- };
2188
-
2189
- var onKeyUp = function onKeyUp(e) {
2190
- if (state.isPressed && $f6c31cce2adf654f$var$isValidKeyboardEvent(e, state.target)) {
2191
- if ($f6c31cce2adf654f$var$shouldPreventDefaultKeyboard(e.target, e.key)) e.preventDefault();
2192
- e.stopPropagation();
2193
- state.isPressed = false;
2194
- var target = e.target;
2195
- triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), 'keyboard', state.target.contains(target));
2196
- removeAllGlobalListeners(); // If the target is a link, trigger the click method to open the URL,
2197
- // but defer triggering pressEnd until onClick event handler.
2198
-
2199
- if (state.target instanceof HTMLElement && state.target.contains(target) && ($f6c31cce2adf654f$var$isHTMLAnchorLink(state.target) || state.target.getAttribute('role') === 'link')) state.target.click();
2200
- }
2201
- };
2202
-
2203
- if (typeof PointerEvent !== 'undefined') {
2204
- pressProps.onPointerDown = function (e) {
2205
- // Only handle left clicks, and ignore events that bubbled through portals.
2206
- if (e.button !== 0 || !e.currentTarget.contains(e.target)) return; // iOS safari fires pointer events from VoiceOver with incorrect coordinates/target.
2207
- // Ignore and let the onClick handler take care of it instead.
2208
- // https://bugs.webkit.org/show_bug.cgi?id=222627
2209
- // https://bugs.webkit.org/show_bug.cgi?id=223202
2210
-
2211
- if ($6a7db85432448f7f$export$29bf1b5f2c56cf63(e.nativeEvent)) {
2212
- state.pointerType = 'virtual';
2213
- return;
2214
- } // Due to browser inconsistencies, especially on mobile browsers, we prevent
2215
- // default on pointer down and handle focusing the pressable element ourselves.
2216
-
2217
-
2218
- if ($f6c31cce2adf654f$var$shouldPreventDefault(e.currentTarget)) e.preventDefault();
2219
- state.pointerType = e.pointerType;
2220
- e.stopPropagation();
2221
-
2222
- if (!state.isPressed) {
2223
- state.isPressed = true;
2224
- state.isOverTarget = true;
2225
- state.activePointerId = e.pointerId;
2226
- state.target = e.currentTarget;
2227
- if (!isDisabled1 && !preventFocusOnPress) $7215afc6de606d6b$export$de79e2c695e052f3(e.currentTarget);
2228
- if (!allowTextSelectionOnPress) $14c0b72509d70225$export$16a4697467175487(state.target);
2229
- triggerPressStart(e, state.pointerType);
2230
- addGlobalListener(document, 'pointermove', onPointerMove, false);
2231
- addGlobalListener(document, 'pointerup', onPointerUp, false);
2232
- addGlobalListener(document, 'pointercancel', onPointerCancel, false);
2233
- }
2234
- };
2235
-
2236
- pressProps.onMouseDown = function (e) {
2237
- if (!e.currentTarget.contains(e.target)) return;
2238
-
2239
- if (e.button === 0) {
2240
- // Chrome and Firefox on touch Windows devices require mouse down events
2241
- // to be canceled in addition to pointer events, or an extra asynchronous
2242
- // focus event will be fired.
2243
- if ($f6c31cce2adf654f$var$shouldPreventDefault(e.currentTarget)) e.preventDefault();
2244
- e.stopPropagation();
2245
- }
2246
- };
2247
-
2248
- pressProps.onPointerUp = function (e) {
2249
- // iOS fires pointerup with zero width and height, so check the pointerType recorded during pointerdown.
2250
- if (!e.currentTarget.contains(e.target) || state.pointerType === 'virtual') return; // Only handle left clicks
2251
- // Safari on iOS sometimes fires pointerup events, even
2252
- // when the touch isn't over the target, so double check.
2253
-
2254
- if (e.button === 0 && $f6c31cce2adf654f$var$isOverTarget(e, e.currentTarget)) triggerPressUp(e, state.pointerType || e.pointerType);
2255
- }; // Safari on iOS < 13.2 does not implement pointerenter/pointerleave events correctly.
2256
- // Use pointer move events instead to implement our own hit testing.
2257
- // See https://bugs.webkit.org/show_bug.cgi?id=199803
2258
-
2259
-
2260
- var onPointerMove = function onPointerMove(e) {
2261
- if (e.pointerId !== state.activePointerId) return;
2262
-
2263
- if ($f6c31cce2adf654f$var$isOverTarget(e, state.target)) {
2264
- if (!state.isOverTarget) {
2265
- state.isOverTarget = true;
2266
- triggerPressStart($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType);
2267
- }
2268
- } else if (state.isOverTarget) {
2269
- state.isOverTarget = false;
2270
- triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType, false);
2271
- if (propsRef.current.shouldCancelOnPointerExit) cancel(e);
2272
- }
2273
- };
2274
-
2275
- var onPointerUp = function onPointerUp(e) {
2276
- if (e.pointerId === state.activePointerId && state.isPressed && e.button === 0) {
2277
- if ($f6c31cce2adf654f$var$isOverTarget(e, state.target)) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType);else if (state.isOverTarget) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType, false);
2278
- state.isPressed = false;
2279
- state.isOverTarget = false;
2280
- state.activePointerId = null;
2281
- state.pointerType = null;
2282
- removeAllGlobalListeners();
2283
- if (!allowTextSelectionOnPress) $14c0b72509d70225$export$b0d6fa1ab32e3295(state.target);
2284
- }
2285
- };
2286
-
2287
- var onPointerCancel = function onPointerCancel(e) {
2288
- cancel(e);
2289
- };
2290
-
2291
- pressProps.onDragStart = function (e) {
2292
- if (!e.currentTarget.contains(e.target)) return; // Safari does not call onPointerCancel when a drag starts, whereas Chrome and Firefox do.
2293
-
2294
- cancel(e);
2295
- };
2296
- } else {
2297
- pressProps.onMouseDown = function (e) {
2298
- // Only handle left clicks
2299
- if (e.button !== 0 || !e.currentTarget.contains(e.target)) return; // Due to browser inconsistencies, especially on mobile browsers, we prevent
2300
- // default on mouse down and handle focusing the pressable element ourselves.
2301
-
2302
- if ($f6c31cce2adf654f$var$shouldPreventDefault(e.currentTarget)) e.preventDefault();
2303
- e.stopPropagation();
2304
- if (state.ignoreEmulatedMouseEvents) return;
2305
- state.isPressed = true;
2306
- state.isOverTarget = true;
2307
- state.target = e.currentTarget;
2308
- state.pointerType = $6a7db85432448f7f$export$60278871457622de(e.nativeEvent) ? 'virtual' : 'mouse';
2309
- if (!isDisabled1 && !preventFocusOnPress) $7215afc6de606d6b$export$de79e2c695e052f3(e.currentTarget);
2310
- triggerPressStart(e, state.pointerType);
2311
- addGlobalListener(document, 'mouseup', onMouseUp, false);
2312
- };
2313
-
2314
- pressProps.onMouseEnter = function (e) {
2315
- if (!e.currentTarget.contains(e.target)) return;
2316
- e.stopPropagation();
2317
-
2318
- if (state.isPressed && !state.ignoreEmulatedMouseEvents) {
2319
- state.isOverTarget = true;
2320
- triggerPressStart(e, state.pointerType);
2321
- }
2322
- };
2323
-
2324
- pressProps.onMouseLeave = function (e) {
2325
- if (!e.currentTarget.contains(e.target)) return;
2326
- e.stopPropagation();
2327
-
2328
- if (state.isPressed && !state.ignoreEmulatedMouseEvents) {
2329
- state.isOverTarget = false;
2330
- triggerPressEnd(e, state.pointerType, false);
2331
- if (propsRef.current.shouldCancelOnPointerExit) cancel(e);
2332
- }
2333
- };
2334
-
2335
- pressProps.onMouseUp = function (e) {
2336
- if (!e.currentTarget.contains(e.target)) return;
2337
- if (!state.ignoreEmulatedMouseEvents && e.button === 0) triggerPressUp(e, state.pointerType);
2338
- };
2339
-
2340
- var onMouseUp = function onMouseUp(e) {
2341
- // Only handle left clicks
2342
- if (e.button !== 0) return;
2343
- state.isPressed = false;
2344
- removeAllGlobalListeners();
2345
-
2346
- if (state.ignoreEmulatedMouseEvents) {
2347
- state.ignoreEmulatedMouseEvents = false;
2348
- return;
2349
- }
2350
-
2351
- if ($f6c31cce2adf654f$var$isOverTarget(e, state.target)) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType);else if (state.isOverTarget) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType, false);
2352
- state.isOverTarget = false;
2353
- };
2354
-
2355
- pressProps.onTouchStart = function (e) {
2356
- if (!e.currentTarget.contains(e.target)) return;
2357
- e.stopPropagation();
2358
- var touch = $f6c31cce2adf654f$var$getTouchFromEvent(e.nativeEvent);
2359
- if (!touch) return;
2360
- state.activePointerId = touch.identifier;
2361
- state.ignoreEmulatedMouseEvents = true;
2362
- state.isOverTarget = true;
2363
- state.isPressed = true;
2364
- state.target = e.currentTarget;
2365
- state.pointerType = 'touch'; // Due to browser inconsistencies, especially on mobile browsers, we prevent default
2366
- // on the emulated mouse event and handle focusing the pressable element ourselves.
2367
-
2368
- if (!isDisabled1 && !preventFocusOnPress) $7215afc6de606d6b$export$de79e2c695e052f3(e.currentTarget);
2369
- if (!allowTextSelectionOnPress) $14c0b72509d70225$export$16a4697467175487(state.target);
2370
- triggerPressStart(e, state.pointerType);
2371
- addGlobalListener(window, 'scroll', onScroll, true);
2372
- };
2373
-
2374
- pressProps.onTouchMove = function (e) {
2375
- if (!e.currentTarget.contains(e.target)) return;
2376
- e.stopPropagation();
2377
- if (!state.isPressed) return;
2378
- var touch = $f6c31cce2adf654f$var$getTouchById(e.nativeEvent, state.activePointerId);
2379
-
2380
- if (touch && $f6c31cce2adf654f$var$isOverTarget(touch, e.currentTarget)) {
2381
- if (!state.isOverTarget) {
2382
- state.isOverTarget = true;
2383
- triggerPressStart(e, state.pointerType);
2384
- }
2385
- } else if (state.isOverTarget) {
2386
- state.isOverTarget = false;
2387
- triggerPressEnd(e, state.pointerType, false);
2388
- if (propsRef.current.shouldCancelOnPointerExit) cancel(e);
2389
- }
2390
- };
2391
-
2392
- pressProps.onTouchEnd = function (e) {
2393
- if (!e.currentTarget.contains(e.target)) return;
2394
- e.stopPropagation();
2395
- if (!state.isPressed) return;
2396
- var touch = $f6c31cce2adf654f$var$getTouchById(e.nativeEvent, state.activePointerId);
2397
-
2398
- if (touch && $f6c31cce2adf654f$var$isOverTarget(touch, e.currentTarget)) {
2399
- triggerPressUp(e, state.pointerType);
2400
- triggerPressEnd(e, state.pointerType);
2401
- } else if (state.isOverTarget) triggerPressEnd(e, state.pointerType, false);
2402
-
2403
- state.isPressed = false;
2404
- state.activePointerId = null;
2405
- state.isOverTarget = false;
2406
- state.ignoreEmulatedMouseEvents = true;
2407
- if (!allowTextSelectionOnPress) $14c0b72509d70225$export$b0d6fa1ab32e3295(state.target);
2408
- removeAllGlobalListeners();
2409
- };
2410
-
2411
- pressProps.onTouchCancel = function (e) {
2412
- if (!e.currentTarget.contains(e.target)) return;
2413
- e.stopPropagation();
2414
- if (state.isPressed) cancel(e);
2415
- };
2416
-
2417
- var onScroll = function onScroll(e) {
2418
- if (state.isPressed && e.target.contains(state.target)) cancel({
2419
- currentTarget: state.target,
2420
- shiftKey: false,
2421
- ctrlKey: false,
2422
- metaKey: false,
2423
- altKey: false
2424
- });
2425
- };
2426
-
2427
- pressProps.onDragStart = function (e) {
2428
- if (!e.currentTarget.contains(e.target)) return;
2429
- cancel(e);
2430
- };
2431
- }
2432
-
2433
- return pressProps;
2434
- }, [addGlobalListener, isDisabled1, preventFocusOnPress, removeAllGlobalListeners, allowTextSelectionOnPress]); // Remove user-select: none in case component unmounts immediately after pressStart
2435
- // eslint-disable-next-line arrow-body-style
2436
-
2437
- useEffect(function () {
2438
- return function () {
2439
- if (!allowTextSelectionOnPress) // eslint-disable-next-line react-hooks/exhaustive-deps
2440
- $14c0b72509d70225$export$b0d6fa1ab32e3295(ref.current.target);
2441
- };
2442
- }, [allowTextSelectionOnPress]);
2443
- return {
2444
- isPressed: isPressedProp || isPressed,
2445
- pressProps: $3ef42575df84b30b$export$9d1611c77c2fe928(domProps, pressProps1)
2446
- };
2447
- }
2448
-
2449
- function $f6c31cce2adf654f$var$isHTMLAnchorLink(target) {
2450
- return target.tagName === 'A' && target.hasAttribute('href');
2451
- }
2452
-
2453
- function $f6c31cce2adf654f$var$isValidKeyboardEvent(event, currentTarget) {
2454
- var key = event.key,
2455
- code = event.code;
2456
- var element = currentTarget;
2457
- var role = element.getAttribute('role'); // Accessibility for keyboards. Space and Enter only.
2458
- // "Spacebar" is for IE 11
2459
-
2460
- return (key === 'Enter' || key === ' ' || key === 'Spacebar' || code === 'Space') && !(element instanceof HTMLInputElement && !$f6c31cce2adf654f$var$isValidInputKey(element, key) || element instanceof HTMLTextAreaElement || element.isContentEditable) && (!$f6c31cce2adf654f$var$isHTMLAnchorLink(element) || role === 'button' && key !== 'Enter') && // An element with role='link' should only trigger with Enter key
2461
- !(role === 'link' && key !== 'Enter');
2462
- }
2463
-
2464
- function $f6c31cce2adf654f$var$getTouchFromEvent(event) {
2465
- var targetTouches = event.targetTouches;
2466
- if (targetTouches.length > 0) return targetTouches[0];
2467
- return null;
2468
- }
2469
-
2470
- function $f6c31cce2adf654f$var$getTouchById(event, pointerId) {
2471
- var changedTouches = event.changedTouches;
2472
-
2473
- for (var i = 0; i < changedTouches.length; i++) {
2474
- var touch = changedTouches[i];
2475
- if (touch.identifier === pointerId) return touch;
2476
- }
2477
-
2478
- return null;
2479
- }
2480
-
2481
- function $f6c31cce2adf654f$var$createEvent(target, e) {
2482
- return {
2483
- currentTarget: target,
2484
- shiftKey: e.shiftKey,
2485
- ctrlKey: e.ctrlKey,
2486
- metaKey: e.metaKey,
2487
- altKey: e.altKey
2488
- };
2489
- }
2490
-
2491
- function $f6c31cce2adf654f$var$getPointClientRect(point) {
2492
- var offsetX = point.width / 2 || point.radiusX || 0;
2493
- var offsetY = point.height / 2 || point.radiusY || 0;
2494
- return {
2495
- top: point.clientY - offsetY,
2496
- right: point.clientX + offsetX,
2497
- bottom: point.clientY + offsetY,
2498
- left: point.clientX - offsetX
2499
- };
2500
- }
2501
-
2502
- function $f6c31cce2adf654f$var$areRectanglesOverlapping(a, b) {
2503
- // check if they cannot overlap on x axis
2504
- if (a.left > b.right || b.left > a.right) return false; // check if they cannot overlap on y axis
2505
-
2506
- if (a.top > b.bottom || b.top > a.bottom) return false;
2507
- return true;
2508
- }
2509
-
2510
- function $f6c31cce2adf654f$var$isOverTarget(point, target) {
2511
- var rect = target.getBoundingClientRect();
2512
- var pointRect = $f6c31cce2adf654f$var$getPointClientRect(point);
2513
- return $f6c31cce2adf654f$var$areRectanglesOverlapping(rect, pointRect);
2514
- }
2515
-
2516
- function $f6c31cce2adf654f$var$shouldPreventDefault(target) {
2517
- // We cannot prevent default if the target is a draggable element.
2518
- return !(target instanceof HTMLElement) || !target.draggable;
2519
- }
2520
-
2521
- function $f6c31cce2adf654f$var$shouldPreventDefaultKeyboard(target, key) {
2522
- if (target instanceof HTMLInputElement) return !$f6c31cce2adf654f$var$isValidInputKey(target, key);
2523
- if (target instanceof HTMLButtonElement) return target.type !== 'submit';
2524
- return true;
2525
- }
2526
-
2527
- var $f6c31cce2adf654f$var$nonTextInputTypes = new Set(['checkbox', 'radio', 'range', 'color', 'file', 'image', 'button', 'submit', 'reset']);
2528
-
2529
- function $f6c31cce2adf654f$var$isValidInputKey(target, key) {
2530
- // Only space should toggle checkboxes and radios, not enter.
2531
- return target.type === 'checkbox' || target.type === 'radio' ? key === ' ' : $f6c31cce2adf654f$var$nonTextInputTypes.has(target.type);
2532
- }
2533
-
2534
- var $8a9cb279dc87e130$export$905e7fc544a71f36 = /*#__PURE__*/function () {
2535
- var _proto = $8a9cb279dc87e130$export$905e7fc544a71f36.prototype;
2536
-
2537
- _proto.isDefaultPrevented = function isDefaultPrevented() {
2538
- return this.nativeEvent.defaultPrevented;
2539
- };
2540
-
2541
- _proto.preventDefault = function preventDefault() {
2542
- this.defaultPrevented = true;
2543
- this.nativeEvent.preventDefault();
2544
- };
2545
-
2546
- _proto.stopPropagation = function stopPropagation() {
2547
- this.nativeEvent.stopPropagation();
2548
-
2549
- this.isPropagationStopped = function () {
2550
- return true;
2551
- };
2552
- };
2553
-
2554
- _proto.isPropagationStopped = function isPropagationStopped() {
2555
- return false;
2556
- };
2557
-
2558
- _proto.persist = function persist() {};
2559
-
2560
- function $8a9cb279dc87e130$export$905e7fc544a71f36(type, nativeEvent) {
2561
- this.nativeEvent = nativeEvent;
2562
- this.target = nativeEvent.target;
2563
- this.currentTarget = nativeEvent.currentTarget;
2564
- this.relatedTarget = nativeEvent.relatedTarget;
2565
- this.bubbles = nativeEvent.bubbles;
2566
- this.cancelable = nativeEvent.cancelable;
2567
- this.defaultPrevented = nativeEvent.defaultPrevented;
2568
- this.eventPhase = nativeEvent.eventPhase;
2569
- this.isTrusted = nativeEvent.isTrusted;
2570
- this.timeStamp = nativeEvent.timeStamp;
2571
- this.type = type;
2572
- }
2573
-
2574
- return $8a9cb279dc87e130$export$905e7fc544a71f36;
2575
- }();
2576
-
2577
- function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
2578
- var stateRef = useRef({
2579
- isFocused: false,
2580
- onBlur: onBlur,
2581
- observer: null
2582
- });
2583
- stateRef.current.onBlur = onBlur; // Clean up MutationObserver on unmount. See below.
2584
- // eslint-disable-next-line arrow-body-style
2585
-
2586
- $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(function () {
2587
- var state = stateRef.current;
2588
- return function () {
2589
- if (state.observer) {
2590
- state.observer.disconnect();
2591
- state.observer = null;
2592
- }
2593
- };
2594
- }, []); // This function is called during a React onFocus event.
2595
-
2596
- return useCallback(function (e1) {
2597
- // React does not fire onBlur when an element is disabled. https://github.com/facebook/react/issues/9142
2598
- // Most browsers fire a native focusout event in this case, except for Firefox. In that case, we use a
2599
- // MutationObserver to watch for the disabled attribute, and dispatch these events ourselves.
2600
- // For browsers that do, focusout fires before the MutationObserver, so onBlur should not fire twice.
2601
- if (e1.target instanceof HTMLButtonElement || e1.target instanceof HTMLInputElement || e1.target instanceof HTMLTextAreaElement || e1.target instanceof HTMLSelectElement) {
2602
- stateRef.current.isFocused = true;
2603
- var target = e1.target;
2604
-
2605
- var onBlurHandler = function onBlurHandler(e) {
2606
- var // For backward compatibility, dispatch a (fake) React synthetic event.
2607
- _current, ref;
2608
-
2609
- stateRef.current.isFocused = false;
2610
- if (target.disabled) (ref = (_current = stateRef.current).onBlur) === null || ref === void 0 ? void 0 : ref.call(_current, new $8a9cb279dc87e130$export$905e7fc544a71f36('blur', e)); // We no longer need the MutationObserver once the target is blurred.
2611
-
2612
- if (stateRef.current.observer) {
2613
- stateRef.current.observer.disconnect();
2614
- stateRef.current.observer = null;
2615
- }
2616
- };
2617
-
2618
- target.addEventListener('focusout', onBlurHandler, {
2619
- once: true
2620
- });
2621
- stateRef.current.observer = new MutationObserver(function () {
2622
- if (stateRef.current.isFocused && target.disabled) {
2623
- stateRef.current.observer.disconnect();
2624
- target.dispatchEvent(new FocusEvent('blur'));
2625
- target.dispatchEvent(new FocusEvent('focusout', {
2626
- bubbles: true
2627
- }));
2628
- }
2629
- });
2630
- stateRef.current.observer.observe(target, {
2631
- attributes: true,
2632
- attributeFilter: ['disabled']
2633
- });
2634
- }
2635
- }, []);
2636
- }
2637
-
2638
- var $507fabe10e71c6fb$var$currentModality = null;
2639
- var $507fabe10e71c6fb$var$changeHandlers = new Set();
2640
- var $507fabe10e71c6fb$var$hasSetupGlobalListeners = false;
2641
- var $507fabe10e71c6fb$var$hasEventBeforeFocus = false;
2642
- var $507fabe10e71c6fb$var$hasBlurredWindowRecently = false; // Only Tab or Esc keys will make focus visible on text input elements
2643
-
2644
- function $507fabe10e71c6fb$var$triggerChangeHandlers(modality, e) {
2645
- for (var _iterator = _createForOfIteratorHelperLoose($507fabe10e71c6fb$var$changeHandlers), _step; !(_step = _iterator()).done;) {
2646
- var handler = _step.value;
2647
- handler(modality, e);
2648
- }
2649
- }
2650
- /**
2651
- * Helper function to determine if a KeyboardEvent is unmodified and could make keyboard focus styles visible.
2652
- */
2653
-
2654
-
2655
- function $507fabe10e71c6fb$var$isValidKey(e) {
2656
- // Control and Shift keys trigger when navigating back to the tab with keyboard.
2657
- return !(e.metaKey || !$c87311424ea30a05$export$9ac100e40613ea10() && e.altKey || e.ctrlKey || e.key === 'Control' || e.key === 'Shift' || e.key === 'Meta');
2658
- }
2659
-
2660
- function $507fabe10e71c6fb$var$handleKeyboardEvent(e) {
2661
- $507fabe10e71c6fb$var$hasEventBeforeFocus = true;
2662
-
2663
- if ($507fabe10e71c6fb$var$isValidKey(e)) {
2664
- $507fabe10e71c6fb$var$currentModality = 'keyboard';
2665
- $507fabe10e71c6fb$var$triggerChangeHandlers('keyboard', e);
2666
- }
2667
- }
2668
-
2669
- function $507fabe10e71c6fb$var$handlePointerEvent(e) {
2670
- $507fabe10e71c6fb$var$currentModality = 'pointer';
2671
-
2672
- if (e.type === 'mousedown' || e.type === 'pointerdown') {
2673
- $507fabe10e71c6fb$var$hasEventBeforeFocus = true;
2674
- $507fabe10e71c6fb$var$triggerChangeHandlers('pointer', e);
2675
- }
2676
- }
2677
-
2678
- function $507fabe10e71c6fb$var$handleClickEvent(e) {
2679
- if ($6a7db85432448f7f$export$60278871457622de(e)) {
2680
- $507fabe10e71c6fb$var$hasEventBeforeFocus = true;
2681
- $507fabe10e71c6fb$var$currentModality = 'virtual';
2682
- }
2683
- }
2684
-
2685
- function $507fabe10e71c6fb$var$handleFocusEvent(e) {
2686
- // Firefox fires two extra focus events when the user first clicks into an iframe:
2687
- // first on the window, then on the document. We ignore these events so they don't
2688
- // cause keyboard focus rings to appear.
2689
- if (e.target === window || e.target === document) return; // If a focus event occurs without a preceding keyboard or pointer event, switch to virtual modality.
2690
- // This occurs, for example, when navigating a form with the next/previous buttons on iOS.
2691
-
2692
- if (!$507fabe10e71c6fb$var$hasEventBeforeFocus && !$507fabe10e71c6fb$var$hasBlurredWindowRecently) {
2693
- $507fabe10e71c6fb$var$currentModality = 'virtual';
2694
- $507fabe10e71c6fb$var$triggerChangeHandlers('virtual', e);
2695
- }
2696
-
2697
- $507fabe10e71c6fb$var$hasEventBeforeFocus = false;
2698
- $507fabe10e71c6fb$var$hasBlurredWindowRecently = false;
2699
- }
2700
-
2701
- function $507fabe10e71c6fb$var$handleWindowBlur() {
2702
- // When the window is blurred, reset state. This is necessary when tabbing out of the window,
2703
- // for example, since a subsequent focus event won't be fired.
2704
- $507fabe10e71c6fb$var$hasEventBeforeFocus = false;
2705
- $507fabe10e71c6fb$var$hasBlurredWindowRecently = true;
2706
- }
2707
- /**
2708
- * Setup global event listeners to control when keyboard focus style should be visible.
2709
- */
2710
-
2711
-
2712
- function $507fabe10e71c6fb$var$setupGlobalFocusEvents() {
2713
- if (typeof window === 'undefined' || $507fabe10e71c6fb$var$hasSetupGlobalListeners) return; // Programmatic focus() calls shouldn't affect the current input modality.
2714
- // However, we need to detect other cases when a focus event occurs without
2715
- // a preceding user event (e.g. screen reader focus). Overriding the focus
2716
- // method on HTMLElement.prototype is a bit hacky, but works.
2717
-
2718
- var focus = HTMLElement.prototype.focus;
2719
-
2720
- HTMLElement.prototype.focus = function () {
2721
- $507fabe10e71c6fb$var$hasEventBeforeFocus = true;
2722
- focus.apply(this, arguments);
2723
- };
2724
-
2725
- document.addEventListener('keydown', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
2726
- document.addEventListener('keyup', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
2727
- document.addEventListener('click', $507fabe10e71c6fb$var$handleClickEvent, true); // Register focus events on the window so they are sure to happen
2728
- // before React's event listeners (registered on the document).
2729
-
2730
- window.addEventListener('focus', $507fabe10e71c6fb$var$handleFocusEvent, true);
2731
- window.addEventListener('blur', $507fabe10e71c6fb$var$handleWindowBlur, false);
2732
-
2733
- if (typeof PointerEvent !== 'undefined') {
2734
- document.addEventListener('pointerdown', $507fabe10e71c6fb$var$handlePointerEvent, true);
2735
- document.addEventListener('pointermove', $507fabe10e71c6fb$var$handlePointerEvent, true);
2736
- document.addEventListener('pointerup', $507fabe10e71c6fb$var$handlePointerEvent, true);
2737
- } else {
2738
- document.addEventListener('mousedown', $507fabe10e71c6fb$var$handlePointerEvent, true);
2739
- document.addEventListener('mousemove', $507fabe10e71c6fb$var$handlePointerEvent, true);
2740
- document.addEventListener('mouseup', $507fabe10e71c6fb$var$handlePointerEvent, true);
2741
- }
2742
-
2743
- $507fabe10e71c6fb$var$hasSetupGlobalListeners = true;
2744
- }
2745
-
2746
- if (typeof document !== 'undefined') {
2747
- if (document.readyState !== 'loading') $507fabe10e71c6fb$var$setupGlobalFocusEvents();else document.addEventListener('DOMContentLoaded', $507fabe10e71c6fb$var$setupGlobalFocusEvents);
2748
- }
2749
-
2750
- function $507fabe10e71c6fb$export$b9b3dfddab17db27() {
2751
- return $507fabe10e71c6fb$var$currentModality !== 'pointer';
2752
- }
2753
-
2754
- function $9ab94262bd0047c7$export$420e68273165f4ec(props) {
2755
- var isDisabled = props.isDisabled,
2756
- onBlurWithin = props.onBlurWithin,
2757
- onFocusWithin = props.onFocusWithin,
2758
- onFocusWithinChange = props.onFocusWithinChange;
2759
- var state = useRef({
2760
- isFocusWithin: false
2761
- });
2762
- var onBlur = useCallback(function (e) {
2763
- // We don't want to trigger onBlurWithin and then immediately onFocusWithin again
2764
- // when moving focus inside the element. Only trigger if the currentTarget doesn't
2765
- // include the relatedTarget (where focus is moving).
2766
- if (state.current.isFocusWithin && !e.currentTarget.contains(e.relatedTarget)) {
2767
- state.current.isFocusWithin = false;
2768
- if (onBlurWithin) onBlurWithin(e);
2769
- if (onFocusWithinChange) onFocusWithinChange(false);
2770
- }
2771
- }, [onBlurWithin, onFocusWithinChange, state]);
2772
- var onSyntheticFocus = $8a9cb279dc87e130$export$715c682d09d639cc(onBlur);
2773
- var onFocus = useCallback(function (e) {
2774
- if (!state.current.isFocusWithin) {
2775
- if (onFocusWithin) onFocusWithin(e);
2776
- if (onFocusWithinChange) onFocusWithinChange(true);
2777
- state.current.isFocusWithin = true;
2778
- onSyntheticFocus(e);
2779
- }
2780
- }, [onFocusWithin, onFocusWithinChange, onSyntheticFocus]);
2781
- if (isDisabled) return {
2782
- focusWithinProps: {
2783
- onFocus: null,
2784
- onBlur: null
2785
- }
2786
- };
2787
- return {
2788
- focusWithinProps: {
2789
- onFocus: onFocus,
2790
- onBlur: onBlur
2791
- }
2792
- };
2793
- } // iOS fires onPointerEnter twice: once with pointerType="touch" and again with pointerType="mouse".
2794
- // We want to ignore these emulated events so they do not trigger hover behavior.
2795
- // See https://bugs.webkit.org/show_bug.cgi?id=214609.
2796
-
2797
-
2798
- var $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = false;
2799
- var $6179b936705e76d3$var$hoverCount = 0;
2800
-
2801
- function $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents() {
2802
- $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = true; // Clear globalIgnoreEmulatedMouseEvents after a short timeout. iOS fires onPointerEnter
2803
- // with pointerType="mouse" immediately after onPointerUp and before onFocus. On other
2804
- // devices that don't have this quirk, we don't want to ignore a mouse hover sometime in
2805
- // the distant future because a user previously touched the element.
2806
-
2807
- setTimeout(function () {
2808
- $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = false;
2809
- }, 50);
2810
- }
2811
-
2812
- function $6179b936705e76d3$var$handleGlobalPointerEvent(e) {
2813
- if (e.pointerType === 'touch') $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents();
2814
- }
2815
-
2816
- function $6179b936705e76d3$var$setupGlobalTouchEvents() {
2817
- if (typeof document === 'undefined') return;
2818
- if (typeof PointerEvent !== 'undefined') document.addEventListener('pointerup', $6179b936705e76d3$var$handleGlobalPointerEvent);else document.addEventListener('touchend', $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents);
2819
- $6179b936705e76d3$var$hoverCount++;
2820
- return function () {
2821
- $6179b936705e76d3$var$hoverCount--;
2822
- if ($6179b936705e76d3$var$hoverCount > 0) return;
2823
- if (typeof PointerEvent !== 'undefined') document.removeEventListener('pointerup', $6179b936705e76d3$var$handleGlobalPointerEvent);else document.removeEventListener('touchend', $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents);
2824
- };
2825
- }
2826
-
2827
- function $6179b936705e76d3$export$ae780daf29e6d456(props) {
2828
- var onHoverStart = props.onHoverStart,
2829
- onHoverChange = props.onHoverChange,
2830
- onHoverEnd = props.onHoverEnd,
2831
- isDisabled = props.isDisabled;
2832
-
2833
- var _$bx7SL$useState4 = useState(false),
2834
- isHovered = _$bx7SL$useState4[0],
2835
- setHovered = _$bx7SL$useState4[1];
2836
-
2837
- var state = useRef({
2838
- isHovered: false,
2839
- ignoreEmulatedMouseEvents: false,
2840
- pointerType: '',
2841
- target: null
2842
- }).current;
2843
- useEffect($6179b936705e76d3$var$setupGlobalTouchEvents, []);
2844
-
2845
- var _$bx7SL$useMemo = useMemo(function () {
2846
- var triggerHoverStart = function triggerHoverStart(event, pointerType) {
2847
- state.pointerType = pointerType;
2848
- if (isDisabled || pointerType === 'touch' || state.isHovered || !event.currentTarget.contains(event.target)) return;
2849
- state.isHovered = true;
2850
- var target = event.currentTarget;
2851
- state.target = target;
2852
- if (onHoverStart) onHoverStart({
2853
- type: 'hoverstart',
2854
- target: target,
2855
- pointerType: pointerType
2856
- });
2857
- if (onHoverChange) onHoverChange(true);
2858
- setHovered(true);
2859
- };
2860
-
2861
- var triggerHoverEnd = function triggerHoverEnd(event, pointerType) {
2862
- state.pointerType = '';
2863
- state.target = null;
2864
- if (pointerType === 'touch' || !state.isHovered) return;
2865
- state.isHovered = false;
2866
- var target = event.currentTarget;
2867
- if (onHoverEnd) onHoverEnd({
2868
- type: 'hoverend',
2869
- target: target,
2870
- pointerType: pointerType
2871
- });
2872
- if (onHoverChange) onHoverChange(false);
2873
- setHovered(false);
2874
- };
2875
-
2876
- var hoverProps = {};
2877
-
2878
- if (typeof PointerEvent !== 'undefined') {
2879
- hoverProps.onPointerEnter = function (e) {
2880
- if ($6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents && e.pointerType === 'mouse') return;
2881
- triggerHoverStart(e, e.pointerType);
2882
- };
2883
-
2884
- hoverProps.onPointerLeave = function (e) {
2885
- if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e, e.pointerType);
2886
- };
2887
- } else {
2888
- hoverProps.onTouchStart = function () {
2889
- state.ignoreEmulatedMouseEvents = true;
2890
- };
2891
-
2892
- hoverProps.onMouseEnter = function (e) {
2893
- if (!state.ignoreEmulatedMouseEvents && !$6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents) triggerHoverStart(e, 'mouse');
2894
- state.ignoreEmulatedMouseEvents = false;
2895
- };
2896
-
2897
- hoverProps.onMouseLeave = function (e) {
2898
- if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e, 'mouse');
2899
- };
2900
- }
2901
-
2902
- return {
2903
- hoverProps: hoverProps,
2904
- triggerHoverEnd: triggerHoverEnd
2905
- };
2906
- }, [onHoverStart, onHoverChange, onHoverEnd, isDisabled, state]),
2907
- hoverProps1 = _$bx7SL$useMemo.hoverProps,
2908
- triggerHoverEnd1 = _$bx7SL$useMemo.triggerHoverEnd;
2909
-
2910
- useEffect(function () {
2911
- // Call the triggerHoverEnd as soon as isDisabled changes to true
2912
- // Safe to call triggerHoverEnd, it will early return if we aren't currently hovering
2913
- if (isDisabled) triggerHoverEnd1({
2914
- currentTarget: state.target
2915
- }, state.pointerType); // eslint-disable-next-line react-hooks/exhaustive-deps
2916
- }, [isDisabled]);
2917
- return {
2918
- hoverProps: hoverProps1,
2919
- isHovered: isHovered
2920
- };
2921
- }
2922
-
2923
- var $8a26561d2877236e$var$DEFAULT_THRESHOLD = 500;
2924
-
2925
- function $8a26561d2877236e$export$c24ed0104d07eab9(props) {
2926
- var isDisabled = props.isDisabled,
2927
- onLongPressStart = props.onLongPressStart,
2928
- onLongPressEnd = props.onLongPressEnd,
2929
- onLongPress = props.onLongPress,
2930
- _props$threshold = props.threshold,
2931
- threshold = _props$threshold === void 0 ? $8a26561d2877236e$var$DEFAULT_THRESHOLD : _props$threshold,
2932
- accessibilityDescription = props.accessibilityDescription;
2933
- var timeRef = useRef(null);
2934
-
2935
- var _$bx7SL$useGlobalList3 = $03deb23ff14920c4$export$4eaf04e54aa8eed6(),
2936
- addGlobalListener = _$bx7SL$useGlobalList3.addGlobalListener,
2937
- removeGlobalListener = _$bx7SL$useGlobalList3.removeGlobalListener;
2938
-
2939
- var _$f6c31cce2adf654f$ex2 = $f6c31cce2adf654f$export$45712eceda6fad21({
2940
- isDisabled: isDisabled,
2941
- onPressStart: function onPressStart(e1) {
2942
- if (e1.pointerType === 'mouse' || e1.pointerType === 'touch') {
2943
- if (onLongPressStart) onLongPressStart(_extends({}, e1, {
2944
- type: 'longpressstart'
2945
- }));
2946
- timeRef.current = setTimeout(function () {
2947
- // Prevent other usePress handlers from also handling this event.
2948
- e1.target.dispatchEvent(new PointerEvent('pointercancel', {
2949
- bubbles: true
2950
- }));
2951
- if (onLongPress) onLongPress(_extends({}, e1, {
2952
- type: 'longpress'
2953
- }));
2954
- timeRef.current = null;
2955
- }, threshold); // Prevent context menu, which may be opened on long press on touch devices
2956
-
2957
- // Prevent context menu, which may be opened on long press on touch devices
2958
- if (e1.pointerType === 'touch') {
2959
- var onContextMenu = function onContextMenu(e) {
2960
- e.preventDefault();
2961
- };
2962
-
2963
- addGlobalListener(e1.target, 'contextmenu', onContextMenu, {
2964
- once: true
2965
- });
2966
- addGlobalListener(window, 'pointerup', function () {
2967
- // If no contextmenu event is fired quickly after pointerup, remove the handler
2968
- // so future context menu events outside a long press are not prevented.
2969
- setTimeout(function () {
2970
- removeGlobalListener(e1.target, 'contextmenu', onContextMenu);
2971
- }, 30);
2972
- }, {
2973
- once: true
2974
- });
2975
- }
2976
- }
2977
- },
2978
- onPressEnd: function onPressEnd(e) {
2979
- if (timeRef.current) clearTimeout(timeRef.current);
2980
- if (onLongPressEnd && (e.pointerType === 'mouse' || e.pointerType === 'touch')) onLongPressEnd(_extends({}, e, {
2981
- type: 'longpressend'
2982
- }));
2983
- }
2984
- }),
2985
- pressProps = _$f6c31cce2adf654f$ex2.pressProps;
2986
-
2987
- var descriptionProps = $ef06256079686ba0$export$f8aeda7b10753fa1(onLongPress && !isDisabled ? accessibilityDescription : null);
2988
- return {
2989
- longPressProps: $3ef42575df84b30b$export$9d1611c77c2fe928(pressProps, descriptionProps)
2990
- };
2991
- }
2992
-
2993
- function $d191a55c9702f145$export$8467354a121f1b9f(props) {
2994
- var id = props.id,
2995
- label = props.label,
2996
- ariaLabelledby = props['aria-labelledby'],
2997
- ariaLabel = props['aria-label'],
2998
- _props$labelElementTy = props.labelElementType,
2999
- labelElementType = _props$labelElementTy === void 0 ? 'label' : _props$labelElementTy;
3000
- id = $bdb11010cef70236$export$f680877a34711e37(id);
3001
- var labelId = $bdb11010cef70236$export$f680877a34711e37();
3002
- var labelProps = {};
3003
-
3004
- if (label) {
3005
- ariaLabelledby = ariaLabelledby ? ariaLabelledby + " " + labelId : labelId;
3006
- labelProps = {
3007
- id: labelId,
3008
- htmlFor: labelElementType === 'label' ? id : undefined
3009
- };
3010
- } else if (!ariaLabelledby && !ariaLabel) console.warn('If you do not provide a visible label, you must specify an aria-label or aria-labelledby attribute for accessibility');
3011
-
3012
- var fieldProps = $313b98861ee5dd6c$export$d6875122194c7b44({
3013
- id: id,
3014
- 'aria-label': ariaLabel,
3015
- 'aria-labelledby': ariaLabelledby
3016
- });
3017
- return {
3018
- labelProps: labelProps,
3019
- fieldProps: fieldProps
3020
- };
3021
- }
3022
-
3023
- /*
3024
- * Copyright 2020 Adobe. All rights reserved.
3025
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
3026
- * you may not use this file except in compliance with the License. You may obtain a copy
3027
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
3028
- *
3029
- * Unless required by applicable law or agreed to in writing, software distributed under
3030
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
3031
- * OF ANY KIND, either express or implied. See the License for the specific language
3032
- * governing permissions and limitations under the License.
3033
- */
3034
- // https://en.wikipedia.org/wiki/Right-to-left
3035
-
3036
- var $148a7a147e38ea7f$var$RTL_SCRIPTS = new Set(['Arab', 'Syrc', 'Samr', 'Mand', 'Thaa', 'Mend', 'Nkoo', 'Adlm', 'Rohg', 'Hebr']);
3037
- var $148a7a147e38ea7f$var$RTL_LANGS = new Set(['ae', 'ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'glk', 'he', 'ku', 'mzn', 'nqo', 'pnb', 'ps', 'sd', 'ug', 'ur', 'yi']);
3038
-
3039
- function $148a7a147e38ea7f$export$702d680b21cbd764(locale) {
3040
- // If the Intl.Locale API is available, use it to get the script for the locale.
3041
- // This is more accurate than guessing by language, since languages can be written in multiple scripts.
3042
- // @ts-ignore
3043
- if (Intl.Locale) {
3044
- // @ts-ignore
3045
- var script = new Intl.Locale(locale).maximize().script;
3046
- return $148a7a147e38ea7f$var$RTL_SCRIPTS.has(script);
3047
- } // If not, just guess by the language (first part of the locale)
3048
-
3049
-
3050
- var lang = locale.split('-')[0];
3051
- return $148a7a147e38ea7f$var$RTL_LANGS.has(lang);
3052
- }
3053
-
3054
- function $1e5a04cdaf7d1af8$export$f09106e7c6677ec5() {
3055
- // @ts-ignore
3056
- var locale = typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';
3057
-
3058
- try {
3059
- // @ts-ignore
3060
- Intl.DateTimeFormat.supportedLocalesOf([locale]);
3061
- } catch (_err) {
3062
- locale = 'en-US';
3063
- }
3064
-
3065
- return {
3066
- locale: locale,
3067
- direction: $148a7a147e38ea7f$export$702d680b21cbd764(locale) ? 'rtl' : 'ltr'
3068
- };
3069
- }
3070
-
3071
- var $1e5a04cdaf7d1af8$var$currentLocale = $1e5a04cdaf7d1af8$export$f09106e7c6677ec5();
3072
- var $1e5a04cdaf7d1af8$var$listeners = new Set();
3073
-
3074
- function $1e5a04cdaf7d1af8$var$updateLocale() {
3075
- $1e5a04cdaf7d1af8$var$currentLocale = $1e5a04cdaf7d1af8$export$f09106e7c6677ec5();
3076
-
3077
- for (var _iterator = _createForOfIteratorHelperLoose($1e5a04cdaf7d1af8$var$listeners), _step; !(_step = _iterator()).done;) {
3078
- var listener = _step.value;
3079
- listener($1e5a04cdaf7d1af8$var$currentLocale);
3080
- }
3081
- }
3082
-
3083
- function $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a() {
3084
- var isSSR = useIsSSR();
3085
-
3086
- var _$iFADg$useState = useState($1e5a04cdaf7d1af8$var$currentLocale),
3087
- defaultLocale = _$iFADg$useState[0],
3088
- setDefaultLocale = _$iFADg$useState[1];
3089
-
3090
- useEffect(function () {
3091
- if ($1e5a04cdaf7d1af8$var$listeners.size === 0) window.addEventListener('languagechange', $1e5a04cdaf7d1af8$var$updateLocale);
3092
- $1e5a04cdaf7d1af8$var$listeners.add(setDefaultLocale);
3093
- return function () {
3094
- $1e5a04cdaf7d1af8$var$listeners["delete"](setDefaultLocale);
3095
- if ($1e5a04cdaf7d1af8$var$listeners.size === 0) window.removeEventListener('languagechange', $1e5a04cdaf7d1af8$var$updateLocale);
3096
- };
3097
- }, []); // We cannot determine the browser's language on the server, so default to
3098
- // en-US. This will be updated after hydration on the client to the correct value.
3099
-
3100
- if (isSSR) return {
3101
- locale: 'en-US',
3102
- direction: 'ltr'
3103
- };
3104
- return defaultLocale;
3105
- }
3106
-
3107
- var $18f2051aff69b9bf$var$I18nContext = /*#__PURE__*/React.createContext(null);
3108
-
3109
- function $18f2051aff69b9bf$export$43bb16f9c6d9e3f7() {
3110
- var defaultLocale = $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a();
3111
- var context = useContext($18f2051aff69b9bf$var$I18nContext);
3112
- return context || defaultLocale;
3113
- }
3114
-
3115
- var $325a3faab7a68acd$var$cache = new Map();
3116
-
3117
- function $325a3faab7a68acd$export$a16aca283550c30d(options) {
3118
- var _$18f2051aff69b9bf$ex5 = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7(),
3119
- locale = _$18f2051aff69b9bf$ex5.locale;
3120
-
3121
- var cacheKey = locale + (options ? Object.entries(options).sort(function (a, b) {
3122
- return a[0] < b[0] ? -1 : 1;
3123
- }).join() : '');
3124
- if ($325a3faab7a68acd$var$cache.has(cacheKey)) return $325a3faab7a68acd$var$cache.get(cacheKey);
3125
- var formatter = new Intl.Collator(locale, options);
3126
- $325a3faab7a68acd$var$cache.set(cacheKey, formatter);
3127
- return formatter;
3128
- }
3129
-
3130
- function $feb5ffebff200149$export$d3e3bd3e26688c04(e) {
3131
- // Ctrl + Arrow Up/Arrow Down has a system wide meaning on macOS, so use Alt instead.
3132
- // On Windows and Ubuntu, Alt + Space has a system wide meaning.
3133
- return $c87311424ea30a05$export$e1865c3bedcd822b() ? e.altKey : e.ctrlKey;
3134
- }
3135
-
3136
- function $feb5ffebff200149$export$16792effe837dba3(e) {
3137
- if ($c87311424ea30a05$export$9ac100e40613ea10()) return e.metaKey;
3138
- return e.ctrlKey;
3139
- }
3140
- /**
3141
- * Controls how long to wait before clearing the typeahead buffer.
3142
- */
3143
-
3144
-
3145
- var $fb3050f43d946246$var$TYPEAHEAD_DEBOUNCE_WAIT_MS = 1000; // 1 second
3146
-
3147
- function $fb3050f43d946246$export$e32c88dfddc6e1d8(options) {
3148
- var keyboardDelegate = options.keyboardDelegate,
3149
- selectionManager = options.selectionManager,
3150
- onTypeSelect = options.onTypeSelect;
3151
- var state = useRef({
3152
- search: '',
3153
- timeout: null
3154
- }).current;
3155
-
3156
- var onKeyDown = function onKeyDown(e) {
3157
- var character = $fb3050f43d946246$var$getStringForKey(e.key);
3158
- if (!character || e.ctrlKey || e.metaKey) return; // Do not propagate the Spacebar event if it's meant to be part of the search.
3159
- // When we time out, the search term becomes empty, hence the check on length.
3160
- // Trimming is to account for the case of pressing the Spacebar more than once,
3161
- // which should cycle through the selection/deselection of the focused item.
3162
-
3163
- if (character === ' ' && state.search.trim().length > 0) {
3164
- e.preventDefault();
3165
- if (!('continuePropagation' in e)) e.stopPropagation();
3166
- }
3167
-
3168
- state.search += character; // Use the delegate to find a key to focus.
3169
- // Prioritize items after the currently focused item, falling back to searching the whole list.
3170
-
3171
- var key = keyboardDelegate.getKeyForSearch(state.search, selectionManager.focusedKey); // If no key found, search from the top.
3172
-
3173
- if (key == null) key = keyboardDelegate.getKeyForSearch(state.search);
3174
-
3175
- if (key != null) {
3176
- selectionManager.setFocusedKey(key);
3177
- if (onTypeSelect) onTypeSelect(key);
3178
- }
3179
-
3180
- clearTimeout(state.timeout);
3181
- state.timeout = setTimeout(function () {
3182
- state.search = '';
3183
- }, $fb3050f43d946246$var$TYPEAHEAD_DEBOUNCE_WAIT_MS);
3184
- };
3185
-
3186
- return {
3187
- typeSelectProps: {
3188
- // Using a capturing listener to catch the keydown event before
3189
- // other hooks in order to handle the Spacebar event.
3190
- onKeyDownCapture: keyboardDelegate.getKeyForSearch ? onKeyDown : null
3191
- }
3192
- };
3193
- }
3194
-
3195
- function $fb3050f43d946246$var$getStringForKey(key) {
3196
- // If the key is of length 1, it is an ASCII value.
3197
- // Otherwise, if there are no ASCII characters in the key name,
3198
- // it is a Unicode character.
3199
- // See https://www.w3.org/TR/uievents-key/
3200
- if (key.length === 1 || !/^[A-Z]/i.test(key)) return key;
3201
- return '';
3202
- }
3203
-
3204
- function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
3205
- var manager = options.selectionManager,
3206
- delegate = options.keyboardDelegate,
3207
- ref = options.ref,
3208
- _options$autoFocus = options.autoFocus,
3209
- autoFocus = _options$autoFocus === void 0 ? false : _options$autoFocus,
3210
- _options$shouldFocusW = options.shouldFocusWrap,
3211
- shouldFocusWrap = _options$shouldFocusW === void 0 ? false : _options$shouldFocusW,
3212
- _options$disallowEmpt = options.disallowEmptySelection,
3213
- disallowEmptySelection = _options$disallowEmpt === void 0 ? false : _options$disallowEmpt,
3214
- _options$disallowSele = options.disallowSelectAll,
3215
- disallowSelectAll = _options$disallowSele === void 0 ? false : _options$disallowSele,
3216
- _options$selectOnFocu = options.selectOnFocus,
3217
- selectOnFocus = _options$selectOnFocu === void 0 ? manager.selectionBehavior === 'replace' : _options$selectOnFocu,
3218
- _options$disallowType = options.disallowTypeAhead,
3219
- disallowTypeAhead = _options$disallowType === void 0 ? false : _options$disallowType,
3220
- shouldUseVirtualFocus = options.shouldUseVirtualFocus,
3221
- _options$allowsTabNav = options.allowsTabNavigation,
3222
- allowsTabNavigation = _options$allowsTabNav === void 0 ? false : _options$allowsTabNav,
3223
- isVirtualized = options.isVirtualized,
3224
- _options$scrollRef = options.scrollRef,
3225
- scrollRef = _options$scrollRef === void 0 ? ref : _options$scrollRef;
3226
-
3227
- var _$eCAIO$useLocale = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7(),
3228
- direction = _$eCAIO$useLocale.direction;
3229
-
3230
- var onKeyDown = function onKeyDown(e) {
3231
- // Prevent option + tab from doing anything since it doesn't move focus to the cells, only buttons/checkboxes
3232
- if (e.altKey && e.key === 'Tab') e.preventDefault(); // Keyboard events bubble through portals. Don't handle keyboard events
3233
- // for elements outside the collection (e.g. menus).
3234
-
3235
- if (!ref.current.contains(e.target)) return;
3236
-
3237
- var navigateToKey = function navigateToKey(key, childFocus) {
3238
- if (key != null) {
3239
- manager.setFocusedKey(key, childFocus);
3240
- if (e.shiftKey && manager.selectionMode === 'multiple') manager.extendSelection(key);else if (selectOnFocus && !$feb5ffebff200149$export$d3e3bd3e26688c04(e)) manager.replaceSelection(key);
3241
- }
3242
- };
3243
-
3244
- switch (e.key) {
3245
- case 'ArrowDown':
3246
- if (delegate.getKeyBelow) {
3247
- var ref4, ref1;
3248
- e.preventDefault();
3249
- var nextKey = manager.focusedKey != null ? delegate.getKeyBelow(manager.focusedKey) : (ref4 = delegate.getFirstKey) === null || ref4 === void 0 ? void 0 : ref4.call(delegate);
3250
- if (nextKey == null && shouldFocusWrap) nextKey = (ref1 = delegate.getFirstKey) === null || ref1 === void 0 ? void 0 : ref1.call(delegate, manager.focusedKey);
3251
- navigateToKey(nextKey);
3252
- }
3253
-
3254
- break;
3255
-
3256
- case 'ArrowUp':
3257
- if (delegate.getKeyAbove) {
3258
- var ref2, ref3;
3259
- e.preventDefault();
3260
-
3261
- var _nextKey = manager.focusedKey != null ? delegate.getKeyAbove(manager.focusedKey) : (ref2 = delegate.getLastKey) === null || ref2 === void 0 ? void 0 : ref2.call(delegate);
3262
-
3263
- if (_nextKey == null && shouldFocusWrap) _nextKey = (ref3 = delegate.getLastKey) === null || ref3 === void 0 ? void 0 : ref3.call(delegate, manager.focusedKey);
3264
- navigateToKey(_nextKey);
3265
- }
3266
-
3267
- break;
3268
-
3269
- case 'ArrowLeft':
3270
- if (delegate.getKeyLeftOf) {
3271
- e.preventDefault();
3272
-
3273
- var _nextKey2 = delegate.getKeyLeftOf(manager.focusedKey);
3274
-
3275
- navigateToKey(_nextKey2, direction === 'rtl' ? 'first' : 'last');
3276
- }
3277
-
3278
- break;
3279
-
3280
- case 'ArrowRight':
3281
- if (delegate.getKeyRightOf) {
3282
- e.preventDefault();
3283
-
3284
- var _nextKey3 = delegate.getKeyRightOf(manager.focusedKey);
3285
-
3286
- navigateToKey(_nextKey3, direction === 'rtl' ? 'last' : 'first');
3287
- }
3288
-
3289
- break;
3290
-
3291
- case 'Home':
3292
- if (delegate.getFirstKey) {
3293
- e.preventDefault();
3294
- var firstKey = delegate.getFirstKey(manager.focusedKey, $feb5ffebff200149$export$16792effe837dba3(e));
3295
- manager.setFocusedKey(firstKey);
3296
- if ($feb5ffebff200149$export$16792effe837dba3(e) && e.shiftKey && manager.selectionMode === 'multiple') manager.extendSelection(firstKey);else if (selectOnFocus) manager.replaceSelection(firstKey);
3297
- }
3298
-
3299
- break;
3300
-
3301
- case 'End':
3302
- if (delegate.getLastKey) {
3303
- e.preventDefault();
3304
- var lastKey = delegate.getLastKey(manager.focusedKey, $feb5ffebff200149$export$16792effe837dba3(e));
3305
- manager.setFocusedKey(lastKey);
3306
- if ($feb5ffebff200149$export$16792effe837dba3(e) && e.shiftKey && manager.selectionMode === 'multiple') manager.extendSelection(lastKey);else if (selectOnFocus) manager.replaceSelection(lastKey);
3307
- }
3308
-
3309
- break;
3310
-
3311
- case 'PageDown':
3312
- if (delegate.getKeyPageBelow) {
3313
- e.preventDefault();
3314
-
3315
- var _nextKey4 = delegate.getKeyPageBelow(manager.focusedKey);
3316
-
3317
- navigateToKey(_nextKey4);
3318
- }
3319
-
3320
- break;
3321
-
3322
- case 'PageUp':
3323
- if (delegate.getKeyPageAbove) {
3324
- e.preventDefault();
3325
-
3326
- var _nextKey5 = delegate.getKeyPageAbove(manager.focusedKey);
3327
-
3328
- navigateToKey(_nextKey5);
3329
- }
3330
-
3331
- break;
3332
-
3333
- case 'a':
3334
- if ($feb5ffebff200149$export$16792effe837dba3(e) && manager.selectionMode === 'multiple' && disallowSelectAll !== true) {
3335
- e.preventDefault();
3336
- manager.selectAll();
3337
- }
3338
-
3339
- break;
3340
-
3341
- case 'Escape':
3342
- e.preventDefault();
3343
- if (!disallowEmptySelection) manager.clearSelection();
3344
- break;
3345
-
3346
- case 'Tab':
3347
- if (!allowsTabNavigation) {
3348
- // There may be elements that are "tabbable" inside a collection (e.g. in a grid cell).
3349
- // However, collections should be treated as a single tab stop, with arrow key navigation internally.
3350
- // We don't control the rendering of these, so we can't override the tabIndex to prevent tabbing.
3351
- // Instead, we handle the Tab key, and move focus manually to the first/last tabbable element
3352
- // in the collection, so that the browser default behavior will apply starting from that element
3353
- // rather than the currently focused one.
3354
- if (e.shiftKey) ref.current.focus();else {
3355
- var walker = getFocusableTreeWalker(ref.current, {
3356
- tabbable: true
3357
- });
3358
- var next;
3359
- var last;
3360
-
3361
- do {
3362
- last = walker.lastChild();
3363
- if (last) next = last;
3364
- } while (last);
3365
-
3366
- if (next && !next.contains(document.activeElement)) $7215afc6de606d6b$export$de79e2c695e052f3(next);
3367
- }
3368
- break;
3369
- }
3370
-
3371
- }
3372
- }; // Store the scroll position so we can restore it later.
3373
-
3374
-
3375
- var scrollPos = useRef({
3376
- top: 0,
3377
- left: 0
3378
- });
3379
- $e9faafb641e167db$export$90fc3a17d93f704c(scrollRef, 'scroll', isVirtualized ? null : function () {
3380
- scrollPos.current = {
3381
- top: scrollRef.current.scrollTop,
3382
- left: scrollRef.current.scrollLeft
3383
- };
3384
- });
3385
-
3386
- var onFocus = function onFocus(e) {
3387
- if (manager.isFocused) {
3388
- // If a focus event bubbled through a portal, reset focus state.
3389
- if (!e.currentTarget.contains(e.target)) manager.setFocused(false);
3390
- return;
3391
- } // Focus events can bubble through portals. Ignore these events.
3392
-
3393
-
3394
- if (!e.currentTarget.contains(e.target)) return;
3395
- manager.setFocused(true);
3396
-
3397
- if (manager.focusedKey == null) {
3398
- var navigateToFirstKey = function navigateToFirstKey(key) {
3399
- if (key != null) {
3400
- manager.setFocusedKey(key);
3401
- if (selectOnFocus) manager.replaceSelection(key);
3402
- }
3403
- }; // If the user hasn't yet interacted with the collection, there will be no focusedKey set.
3404
- // Attempt to detect whether the user is tabbing forward or backward into the collection
3405
- // and either focus the first or last item accordingly.
3406
-
3407
-
3408
- var relatedTarget = e.relatedTarget;
3409
-
3410
- var _lastSelectedKey, _firstSelectedKey;
3411
-
3412
- if (relatedTarget && e.currentTarget.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING) navigateToFirstKey((_lastSelectedKey = manager.lastSelectedKey) !== null && _lastSelectedKey !== void 0 ? _lastSelectedKey : delegate.getLastKey());else navigateToFirstKey((_firstSelectedKey = manager.firstSelectedKey) !== null && _firstSelectedKey !== void 0 ? _firstSelectedKey : delegate.getFirstKey());
3413
- } else if (!isVirtualized) {
3414
- // Restore the scroll position to what it was before.
3415
- scrollRef.current.scrollTop = scrollPos.current.top;
3416
- scrollRef.current.scrollLeft = scrollPos.current.left; // Refocus and scroll the focused item into view if it exists within the scrollable region.
3417
-
3418
- var element = scrollRef.current.querySelector("[data-key=\"" + manager.focusedKey + "\"]");
3419
-
3420
- if (element) {
3421
- // This prevents a flash of focus on the first/last element in the collection
3422
- $7215afc6de606d6b$export$de79e2c695e052f3(element);
3423
- $2f04cbc44ee30ce0$export$53a0910f038337bd(scrollRef.current, element);
3424
- }
3425
- }
3426
- };
3427
-
3428
- var onBlur = function onBlur(e) {
3429
- // Don't set blurred and then focused again if moving focus within the collection.
3430
- if (!e.currentTarget.contains(e.relatedTarget)) manager.setFocused(false);
3431
- };
3432
-
3433
- var autoFocusRef = useRef(autoFocus);
3434
- useEffect(function () {
3435
- if (autoFocusRef.current) {
3436
- var focusedKey = null; // Check focus strategy to determine which item to focus
3437
-
3438
- if (autoFocus === 'first') focusedKey = delegate.getFirstKey();
3439
- if (autoFocus === 'last') focusedKey = delegate.getLastKey(); // If there are any selected keys, make the first one the new focus target
3440
-
3441
- var selectedKeys = manager.selectedKeys;
3442
- if (selectedKeys.size) focusedKey = selectedKeys.values().next().value;
3443
- manager.setFocused(true);
3444
- manager.setFocusedKey(focusedKey); // If no default focus key is selected, focus the collection itself.
3445
-
3446
- if (focusedKey == null && !shouldUseVirtualFocus) focusSafely(ref.current);
3447
- }
3448
-
3449
- autoFocusRef.current = false; // eslint-disable-next-line react-hooks/exhaustive-deps
3450
- }, []); // If not virtualized, scroll the focused element into view when the focusedKey changes.
3451
- // When virtualized, Virtualizer handles this internally.
3452
-
3453
- useEffect(function () {
3454
- if (!isVirtualized && manager.focusedKey && (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {
3455
- var element = scrollRef.current.querySelector("[data-key=\"" + manager.focusedKey + "\"]");
3456
- if (element) $2f04cbc44ee30ce0$export$53a0910f038337bd(scrollRef.current, element);
3457
- }
3458
- }, [isVirtualized, scrollRef, manager.focusedKey]);
3459
- var handlers = {
3460
- onKeyDown: onKeyDown,
3461
- onFocus: onFocus,
3462
- onBlur: onBlur,
3463
- onMouseDown: function onMouseDown(e) {
3464
- // Ignore events that bubbled through portals.
3465
- if (scrollRef.current === e.target) // Prevent focus going to the collection when clicking on the scrollbar.
3466
- e.preventDefault();
3467
- }
3468
- };
3469
-
3470
- var _$fb3050f43d946246$ex = $fb3050f43d946246$export$e32c88dfddc6e1d8({
3471
- keyboardDelegate: delegate,
3472
- selectionManager: manager
3473
- }),
3474
- typeSelectProps = _$fb3050f43d946246$ex.typeSelectProps;
3475
-
3476
- if (!disallowTypeAhead) handlers = $3ef42575df84b30b$export$9d1611c77c2fe928(typeSelectProps, handlers); // If nothing is focused within the collection, make the collection itself tabbable.
3477
- // This will be marshalled to either the first or last item depending on where focus came from.
3478
- // If using virtual focus, don't set a tabIndex at all so that VoiceOver on iOS 14 doesn't try
3479
- // to move real DOM focus to the element anyway.
3480
-
3481
- var tabIndex;
3482
- if (!shouldUseVirtualFocus) tabIndex = manager.focusedKey == null ? 0 : -1;
3483
- return {
3484
- collectionProps: _extends({}, handlers, {
3485
- tabIndex: tabIndex
3486
- })
3487
- };
3488
- }
3489
-
3490
- function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
3491
- var manager = options.selectionManager,
3492
- key = options.key,
3493
- ref = options.ref,
3494
- shouldSelectOnPressUp = options.shouldSelectOnPressUp,
3495
- isVirtualized = options.isVirtualized,
3496
- shouldUseVirtualFocus = options.shouldUseVirtualFocus,
3497
- focus = options.focus,
3498
- isDisabled = options.isDisabled,
3499
- onAction = options.onAction,
3500
- allowsDifferentPressOrigin = options.allowsDifferentPressOrigin;
3501
-
3502
- var onSelect = function onSelect(e) {
3503
- if (e.pointerType === 'keyboard' && $feb5ffebff200149$export$d3e3bd3e26688c04(e)) manager.toggleSelection(key);else {
3504
- if (manager.selectionMode === 'none') return;
3505
-
3506
- if (manager.selectionMode === 'single') {
3507
- if (manager.isSelected(key) && !manager.disallowEmptySelection) manager.toggleSelection(key);else manager.replaceSelection(key);
3508
- } else if (e && e.shiftKey) manager.extendSelection(key);else if (manager.selectionBehavior === 'toggle' || e && ($feb5ffebff200149$export$16792effe837dba3(e) || e.pointerType === 'touch' || e.pointerType === 'virtual')) // if touch or virtual (VO) then we just want to toggle, otherwise it's impossible to multi select because they don't have modifier keys
3509
- manager.toggleSelection(key);else manager.replaceSelection(key);
3510
- }
3511
- }; // Focus the associated DOM node when this item becomes the focusedKey
3512
-
3513
-
3514
- useEffect(function () {
3515
- var isFocused = key === manager.focusedKey;
3516
-
3517
- if (isFocused && manager.isFocused && !shouldUseVirtualFocus && document.activeElement !== ref.current) {
3518
- if (focus) focus();else focusSafely(ref.current);
3519
- } // eslint-disable-next-line react-hooks/exhaustive-deps
3520
-
3521
- }, [ref, key, manager.focusedKey, manager.childFocusStrategy, manager.isFocused, shouldUseVirtualFocus]);
3522
- isDisabled = isDisabled || manager.isDisabled(key); // Set tabIndex to 0 if the element is focused, or -1 otherwise so that only the last focused
3523
- // item is tabbable. If using virtual focus, don't set a tabIndex at all so that VoiceOver
3524
- // on iOS 14 doesn't try to move real DOM focus to the item anyway.
3525
-
3526
- var itemProps = {};
3527
- if (!shouldUseVirtualFocus && !isDisabled) itemProps = {
3528
- tabIndex: key === manager.focusedKey ? 0 : -1,
3529
- onFocus: function onFocus(e) {
3530
- if (e.target === ref.current) manager.setFocusedKey(key);
3531
- }
3532
- };else if (isDisabled) itemProps.onMouseDown = function (e) {
3533
- // Prevent focus going to the body when clicking on a disabled item.
3534
- e.preventDefault();
3535
- }; // With checkbox selection, onAction (i.e. navigation) becomes primary, and occurs on a single click of the row.
3536
- // Clicking the checkbox enters selection mode, after which clicking anywhere on any row toggles selection for that row.
3537
- // With highlight selection, onAction is secondary, and occurs on double click. Single click selects the row.
3538
- // With touch, onAction occurs on single tap, and long press enters selection mode.
3539
-
3540
- var allowsSelection = !isDisabled && manager.canSelectItem(key);
3541
- var allowsActions = onAction && !isDisabled;
3542
- var hasPrimaryAction = allowsActions && (manager.selectionBehavior === 'replace' ? !allowsSelection : manager.isEmpty);
3543
- var hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior === 'replace';
3544
- var hasAction = hasPrimaryAction || hasSecondaryAction;
3545
- var modality = useRef(null);
3546
- var longPressEnabled = hasAction && allowsSelection;
3547
- var longPressEnabledOnPressStart = useRef(false);
3548
- var hadPrimaryActionOnPressStart = useRef(false); // By default, selection occurs on pointer down. This can be strange if selecting an
3549
- // item causes the UI to disappear immediately (e.g. menus).
3550
- // If shouldSelectOnPressUp is true, we use onPressUp instead of onPressStart.
3551
- // onPress requires a pointer down event on the same element as pointer up. For menus,
3552
- // we want to be able to have the pointer down on the trigger that opens the menu and
3553
- // the pointer up on the menu item rather than requiring a separate press.
3554
- // For keyboard events, selection still occurs on key down.
3555
-
3556
- var itemPressProps = {};
3557
-
3558
- if (shouldSelectOnPressUp) {
3559
- itemPressProps.onPressStart = function (e) {
3560
- modality.current = e.pointerType;
3561
- longPressEnabledOnPressStart.current = longPressEnabled;
3562
- if (e.pointerType === 'keyboard' && (!hasAction || $880e95eb8b93ba9a$var$isSelectionKey())) onSelect(e);
3563
- }; // If allowsDifferentPressOrigin, make selection happen on pressUp (e.g. open menu on press down, selection on menu item happens on press up.)
3564
- // Otherwise, have selection happen onPress (prevents listview row selection when clicking on interactable elements in the row)
3565
-
3566
-
3567
- if (!allowsDifferentPressOrigin) itemPressProps.onPress = function (e) {
3568
- if (hasPrimaryAction || hasSecondaryAction && e.pointerType !== 'mouse') {
3569
- if (e.pointerType === 'keyboard' && !$880e95eb8b93ba9a$var$isActionKey()) return;
3570
- onAction();
3571
- } else if (e.pointerType !== 'keyboard') onSelect(e);
3572
- };else {
3573
- itemPressProps.onPressUp = function (e) {
3574
- if (e.pointerType !== 'keyboard') onSelect(e);
3575
- };
3576
-
3577
- itemPressProps.onPress = hasPrimaryAction ? function () {
3578
- return onAction();
3579
- } : null;
3580
- }
3581
- } else {
3582
- itemPressProps.onPressStart = function (e) {
3583
- modality.current = e.pointerType;
3584
- longPressEnabledOnPressStart.current = longPressEnabled;
3585
- hadPrimaryActionOnPressStart.current = hasPrimaryAction; // Select on mouse down unless there is a primary action which will occur on mouse up.
3586
- // For keyboard, select on key down. If there is an action, the Space key selects on key down,
3587
- // and the Enter key performs onAction on key up.
3588
-
3589
- if (e.pointerType === 'mouse' && !hasPrimaryAction || e.pointerType === 'keyboard' && (!onAction || $880e95eb8b93ba9a$var$isSelectionKey())) onSelect(e);
3590
- };
3591
-
3592
- itemPressProps.onPress = function (e) {
3593
- // Selection occurs on touch up. Primary actions always occur on pointer up.
3594
- // Both primary and secondary actions occur on Enter key up. The only exception
3595
- // is secondary actions, which occur on double click with a mouse.
3596
- if (e.pointerType === 'touch' || e.pointerType === 'pen' || e.pointerType === 'virtual' || e.pointerType === 'keyboard' && hasAction && $880e95eb8b93ba9a$var$isActionKey() || e.pointerType === 'mouse' && hadPrimaryActionOnPressStart.current) {
3597
- if (hasAction) onAction();else onSelect(e);
3598
- }
3599
- };
3600
- }
3601
-
3602
- if (!isVirtualized) itemProps['data-key'] = key;
3603
- itemPressProps.preventFocusOnPress = shouldUseVirtualFocus;
3604
-
3605
- var _$eCAIO$usePress = $f6c31cce2adf654f$export$45712eceda6fad21(itemPressProps),
3606
- pressProps = _$eCAIO$usePress.pressProps,
3607
- isPressed = _$eCAIO$usePress.isPressed; // Double clicking with a mouse with selectionBehavior = 'replace' performs an action.
3608
-
3609
-
3610
- var onDoubleClick = hasSecondaryAction ? function (e) {
3611
- if (modality.current === 'mouse') {
3612
- e.stopPropagation();
3613
- e.preventDefault();
3614
- onAction();
3615
- }
3616
- } : undefined; // Long pressing an item with touch when selectionBehavior = 'replace' switches the selection behavior
3617
- // to 'toggle'. This changes the single tap behavior from performing an action (i.e. navigating) to
3618
- // selecting, and may toggle the appearance of a UI affordance like checkboxes on each item.
3619
-
3620
- var _$eCAIO$useLongPress = $8a26561d2877236e$export$c24ed0104d07eab9({
3621
- isDisabled: !longPressEnabled,
3622
- onLongPress: function onLongPress(e) {
3623
- if (e.pointerType === 'touch') {
3624
- onSelect(e);
3625
- manager.setSelectionBehavior('toggle');
3626
- }
3627
- }
3628
- }),
3629
- longPressProps = _$eCAIO$useLongPress.longPressProps; // Prevent native drag and drop on long press if we also select on long press.
3630
- // Once the user is in selection mode, they can long press again to drag.
3631
- // Use a capturing listener to ensure this runs before useDrag, regardless of
3632
- // the order the props get merged.
3633
-
3634
-
3635
- var onDragStartCapture = function onDragStartCapture(e) {
3636
- if (modality.current === 'touch' && longPressEnabledOnPressStart.current) e.preventDefault();
3637
- };
3638
-
3639
- return {
3640
- itemProps: $3ef42575df84b30b$export$9d1611c77c2fe928(itemProps, allowsSelection || hasPrimaryAction ? pressProps : {}, longPressEnabled ? longPressProps : {}, {
3641
- onDoubleClick: onDoubleClick,
3642
- onDragStartCapture: onDragStartCapture
3643
- }),
3644
- isPressed: isPressed,
3645
- isSelected: manager.isSelected(key),
3646
- isDisabled: isDisabled,
3647
- allowsSelection: allowsSelection,
3648
- hasAction: hasAction
3649
- };
3650
- }
3651
-
3652
- function $880e95eb8b93ba9a$var$isActionKey() {
3653
- var event = window.event;
3654
- return (event === null || event === void 0 ? void 0 : event.key) === 'Enter';
3655
- }
3656
-
3657
- function $880e95eb8b93ba9a$var$isSelectionKey() {
3658
- var event = window.event;
3659
- return (event === null || event === void 0 ? void 0 : event.key) === ' ' || (event === null || event === void 0 ? void 0 : event.code) === 'Space';
3660
- }
3661
-
3662
- var $2a25aae57d74318e$export$a05409b8bb224a5a = /*#__PURE__*/function () {
3663
- var _proto = $2a25aae57d74318e$export$a05409b8bb224a5a.prototype;
3664
-
3665
- _proto.getKeyBelow = function getKeyBelow(key) {
3666
- key = this.collection.getKeyAfter(key);
3667
-
3668
- while (key != null) {
3669
- var item = this.collection.getItem(key);
3670
- if (item.type === 'item' && !this.disabledKeys.has(key)) return key;
3671
- key = this.collection.getKeyAfter(key);
3672
- }
3673
- };
3674
-
3675
- _proto.getKeyAbove = function getKeyAbove(key) {
3676
- key = this.collection.getKeyBefore(key);
3677
-
3678
- while (key != null) {
3679
- var item = this.collection.getItem(key);
3680
- if (item.type === 'item' && !this.disabledKeys.has(key)) return key;
3681
- key = this.collection.getKeyBefore(key);
3682
- }
3683
- };
3684
-
3685
- _proto.getFirstKey = function getFirstKey() {
3686
- var key = this.collection.getFirstKey();
3687
-
3688
- while (key != null) {
3689
- var item = this.collection.getItem(key);
3690
- if (item.type === 'item' && !this.disabledKeys.has(key)) return key;
3691
- key = this.collection.getKeyAfter(key);
3692
- }
3693
- };
3694
-
3695
- _proto.getLastKey = function getLastKey() {
3696
- var key = this.collection.getLastKey();
3697
-
3698
- while (key != null) {
3699
- var item = this.collection.getItem(key);
3700
- if (item.type === 'item' && !this.disabledKeys.has(key)) return key;
3701
- key = this.collection.getKeyBefore(key);
3702
- }
3703
- };
3704
-
3705
- _proto.getItem = function getItem(key) {
3706
- return this.ref.current.querySelector("[data-key=\"" + key + "\"]");
3707
- };
3708
-
3709
- _proto.getKeyPageAbove = function getKeyPageAbove(key) {
3710
- var menu = this.ref.current;
3711
- var item = this.getItem(key);
3712
- if (!item) return null;
3713
- var pageY = Math.max(0, item.offsetTop + item.offsetHeight - menu.offsetHeight);
3714
-
3715
- while (item && item.offsetTop > pageY) {
3716
- key = this.getKeyAbove(key);
3717
- item = this.getItem(key);
3718
- }
3719
-
3720
- return key;
3721
- };
3722
-
3723
- _proto.getKeyPageBelow = function getKeyPageBelow(key) {
3724
- var menu = this.ref.current;
3725
- var item = this.getItem(key);
3726
- if (!item) return null;
3727
- var pageY = Math.min(menu.scrollHeight, item.offsetTop - item.offsetHeight + menu.offsetHeight);
3728
-
3729
- while (item && item.offsetTop < pageY) {
3730
- key = this.getKeyBelow(key);
3731
- item = this.getItem(key);
3732
- }
3733
-
3734
- return key;
3735
- };
3736
-
3737
- _proto.getKeyForSearch = function getKeyForSearch(search, fromKey) {
3738
- if (!this.collator) return null;
3739
- var collection = this.collection;
3740
- var key = fromKey || this.getFirstKey();
3741
-
3742
- while (key != null) {
3743
- var item = collection.getItem(key);
3744
- var substring = item.textValue.slice(0, search.length);
3745
- if (item.textValue && this.collator.compare(substring, search) === 0) return key;
3746
- key = this.getKeyBelow(key);
3747
- }
3748
-
3749
- return null;
3750
- };
3751
-
3752
- function $2a25aae57d74318e$export$a05409b8bb224a5a(collection, disabledKeys, ref, collator) {
3753
- this.collection = collection;
3754
- this.disabledKeys = disabledKeys;
3755
- this.ref = ref;
3756
- this.collator = collator;
3757
- }
3758
-
3759
- return $2a25aae57d74318e$export$a05409b8bb224a5a;
3760
- }();
3761
-
3762
- function $982254629710d113$export$b95089534ab7c1fd(props) {
3763
- var selectionManager = props.selectionManager,
3764
- collection = props.collection,
3765
- disabledKeys = props.disabledKeys,
3766
- ref = props.ref,
3767
- keyboardDelegate = props.keyboardDelegate,
3768
- autoFocus = props.autoFocus,
3769
- shouldFocusWrap = props.shouldFocusWrap,
3770
- isVirtualized = props.isVirtualized,
3771
- disallowEmptySelection = props.disallowEmptySelection,
3772
- _props$selectOnFocus = props.selectOnFocus,
3773
- selectOnFocus = _props$selectOnFocus === void 0 ? selectionManager.selectionBehavior === 'replace' : _props$selectOnFocus,
3774
- disallowTypeAhead = props.disallowTypeAhead,
3775
- shouldUseVirtualFocus = props.shouldUseVirtualFocus,
3776
- allowsTabNavigation = props.allowsTabNavigation; // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
3777
- // When virtualized, the layout object will be passed in as a prop and override this.
3778
-
3779
- var collator = $325a3faab7a68acd$export$a16aca283550c30d({
3780
- usage: 'search',
3781
- sensitivity: 'base'
3782
- });
3783
- var disabledBehavior = selectionManager.disabledBehavior;
3784
- var delegate = useMemo(function () {
3785
- return keyboardDelegate || new $2a25aae57d74318e$export$a05409b8bb224a5a(collection, disabledBehavior === 'selection' ? new Set() : disabledKeys, ref, collator);
3786
- }, [keyboardDelegate, collection, disabledKeys, ref, collator, disabledBehavior]);
3787
-
3788
- var _$ae20dd8cbca75726$ex = $ae20dd8cbca75726$export$d6daf82dcd84e87c({
3789
- ref: ref,
3790
- selectionManager: selectionManager,
3791
- keyboardDelegate: delegate,
3792
- autoFocus: autoFocus,
3793
- shouldFocusWrap: shouldFocusWrap,
3794
- disallowEmptySelection: disallowEmptySelection,
3795
- selectOnFocus: selectOnFocus,
3796
- disallowTypeAhead: disallowTypeAhead,
3797
- shouldUseVirtualFocus: shouldUseVirtualFocus,
3798
- allowsTabNavigation: allowsTabNavigation,
3799
- isVirtualized: isVirtualized,
3800
- scrollRef: ref
3801
- }),
3802
- collectionProps = _$ae20dd8cbca75726$ex.collectionProps;
3803
-
3804
- return {
3805
- listProps: collectionProps
3806
- };
3807
- }
3808
-
3809
- var $453cc9f0df89c0a5$var$cache = new WeakMap();
3810
-
3811
- function $453cc9f0df89c0a5$export$77d5aafae4e095b2(collection) {
3812
- var count = $453cc9f0df89c0a5$var$cache.get(collection);
3813
- if (count != null) return count;
3814
- count = 0;
3815
-
3816
- for (var _iterator10 = _createForOfIteratorHelperLoose(collection), _step10; !(_step10 = _iterator10()).done;) {
3817
- var item = _step10.value;
3818
- if (item.type === 'section') count += $453cc9f0df89c0a5$export$77d5aafae4e095b2(item.childNodes);else count++;
3819
- }
3820
-
3821
- $453cc9f0df89c0a5$var$cache.set(collection, count);
3822
- return count;
3823
- }
3824
-
3825
- var $b1f0cad8af73213b$export$3585ede4d035bf14 = new WeakMap();
3826
-
3827
- function $b1f0cad8af73213b$var$normalizeKey(key) {
3828
- if (typeof key === 'string') return key.replace(/\s*/g, '');
3829
- return '' + key;
3830
- }
3831
-
3832
- function $b1f0cad8af73213b$export$9145995848b05025(state, itemKey) {
3833
- var data = $b1f0cad8af73213b$export$3585ede4d035bf14.get(state);
3834
- if (!data) throw new Error('Unknown list');
3835
- return data.id + "-option-" + $b1f0cad8af73213b$var$normalizeKey(itemKey);
3836
- }
3837
-
3838
- function $c132121280ec012d$export$50eacbbf140a3141(props, state, ref) {
3839
- var domProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
3840
- labelable: true
3841
- });
3842
-
3843
- var _$frWMC$useSelectable = $982254629710d113$export$b95089534ab7c1fd(_extends({}, props, {
3844
- ref: ref,
3845
- selectionManager: state.selectionManager,
3846
- collection: state.collection,
3847
- disabledKeys: state.disabledKeys
3848
- })),
3849
- listProps = _$frWMC$useSelectable.listProps;
3850
-
3851
- var _$frWMC$useFocusWithi = $9ab94262bd0047c7$export$420e68273165f4ec({
3852
- onFocusWithin: props.onFocus,
3853
- onBlurWithin: props.onBlur,
3854
- onFocusWithinChange: props.onFocusChange
3855
- }),
3856
- focusWithinProps = _$frWMC$useFocusWithi.focusWithinProps; // Share list id and some props with child options.
3857
-
3858
-
3859
- var id = $bdb11010cef70236$export$f680877a34711e37(props.id);
3860
- $b1f0cad8af73213b$export$3585ede4d035bf14.set(state, {
3861
- id: id,
3862
- shouldUseVirtualFocus: props.shouldUseVirtualFocus,
3863
- shouldSelectOnPressUp: props.shouldSelectOnPressUp,
3864
- shouldFocusOnHover: props.shouldFocusOnHover,
3865
- isVirtualized: props.isVirtualized,
3866
- onAction: props.onAction
3867
- });
3868
-
3869
- var _$frWMC$useLabel = $d191a55c9702f145$export$8467354a121f1b9f(_extends({}, props, {
3870
- id: id,
3871
- // listbox is not an HTML input element so it
3872
- // shouldn't be labeled by a <label> element.
3873
- labelElementType: 'span'
3874
- })),
3875
- labelProps = _$frWMC$useLabel.labelProps,
3876
- fieldProps = _$frWMC$useLabel.fieldProps;
3877
-
3878
- return {
3879
- labelProps: labelProps,
3880
- listBoxProps: $3ef42575df84b30b$export$9d1611c77c2fe928(domProps, focusWithinProps, state.selectionManager.selectionMode === 'multiple' ? {
3881
- 'aria-multiselectable': 'true'
3882
- } : {}, _extends({
3883
- role: 'listbox'
3884
- }, $3ef42575df84b30b$export$9d1611c77c2fe928(fieldProps, listProps)))
3885
- };
3886
- }
3887
-
3888
- function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
3889
- var key = props.key;
3890
- var data = $b1f0cad8af73213b$export$3585ede4d035bf14.get(state);
3891
-
3892
- var _isDisabled;
3893
-
3894
- var isDisabled = (_isDisabled = props.isDisabled) !== null && _isDisabled !== void 0 ? _isDisabled : state.disabledKeys.has(key);
3895
-
3896
- var _isSelected;
3897
-
3898
- var isSelected = (_isSelected = props.isSelected) !== null && _isSelected !== void 0 ? _isSelected : state.selectionManager.isSelected(key);
3899
- var isFocused = state.selectionManager.focusedKey === key;
3900
-
3901
- var _shouldSelectOnPressUp;
3902
-
3903
- var shouldSelectOnPressUp = (_shouldSelectOnPressUp = props.shouldSelectOnPressUp) !== null && _shouldSelectOnPressUp !== void 0 ? _shouldSelectOnPressUp : data.shouldSelectOnPressUp;
3904
-
3905
- var _shouldFocusOnHover;
3906
-
3907
- var shouldFocusOnHover = (_shouldFocusOnHover = props.shouldFocusOnHover) !== null && _shouldFocusOnHover !== void 0 ? _shouldFocusOnHover : data.shouldFocusOnHover;
3908
-
3909
- var _shouldUseVirtualFocus;
3910
-
3911
- var shouldUseVirtualFocus = (_shouldUseVirtualFocus = props.shouldUseVirtualFocus) !== null && _shouldUseVirtualFocus !== void 0 ? _shouldUseVirtualFocus : data.shouldUseVirtualFocus;
3912
-
3913
- var _isVirtualized;
3914
-
3915
- var isVirtualized = (_isVirtualized = props.isVirtualized) !== null && _isVirtualized !== void 0 ? _isVirtualized : data.isVirtualized;
3916
- var labelId = $bdb11010cef70236$export$b4cc09c592e8fdb8();
3917
- var descriptionId = $bdb11010cef70236$export$b4cc09c592e8fdb8();
3918
- var optionProps = {
3919
- role: 'option',
3920
- 'aria-disabled': isDisabled,
3921
- 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined
3922
- }; // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply "text".
3923
- // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.
3924
- // https://bugs.webkit.org/show_bug.cgi?id=209279
3925
-
3926
- if (!($c87311424ea30a05$export$9ac100e40613ea10() && $c87311424ea30a05$export$78551043582a6a98())) {
3927
- optionProps['aria-label'] = props['aria-label'];
3928
- optionProps['aria-labelledby'] = labelId;
3929
- optionProps['aria-describedby'] = descriptionId;
3930
- }
3931
-
3932
- if (isVirtualized) {
3933
- optionProps['aria-posinset'] = state.collection.getItem(key).index + 1;
3934
- optionProps['aria-setsize'] = $453cc9f0df89c0a5$export$77d5aafae4e095b2(state.collection);
3935
- }
3936
-
3937
- var _$frWMC$useSelectable2 = $880e95eb8b93ba9a$export$ecf600387e221c37({
3938
- selectionManager: state.selectionManager,
3939
- key: key,
3940
- ref: ref,
3941
- shouldSelectOnPressUp: shouldSelectOnPressUp,
3942
- allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,
3943
- isVirtualized: isVirtualized,
3944
- shouldUseVirtualFocus: shouldUseVirtualFocus,
3945
- isDisabled: isDisabled,
3946
- onAction: data.onAction ? function () {
3947
- return data.onAction(key);
3948
- } : undefined
3949
- }),
3950
- itemProps = _$frWMC$useSelectable2.itemProps,
3951
- isPressed = _$frWMC$useSelectable2.isPressed,
3952
- hasAction = _$frWMC$useSelectable2.hasAction,
3953
- allowsSelection = _$frWMC$useSelectable2.allowsSelection;
3954
-
3955
- var _$frWMC$useHover = $6179b936705e76d3$export$ae780daf29e6d456({
3956
- isDisabled: isDisabled || !shouldFocusOnHover,
3957
- onHoverStart: function onHoverStart() {
3958
- if (!$507fabe10e71c6fb$export$b9b3dfddab17db27()) {
3959
- state.selectionManager.setFocused(true);
3960
- state.selectionManager.setFocusedKey(key);
3961
- }
3962
- }
3963
- }),
3964
- hoverProps = _$frWMC$useHover.hoverProps;
3965
-
3966
- return {
3967
- optionProps: _extends({}, optionProps, $3ef42575df84b30b$export$9d1611c77c2fe928(itemProps, hoverProps), {
3968
- id: $b1f0cad8af73213b$export$9145995848b05025(state, key)
3969
- }),
3970
- labelProps: {
3971
- id: labelId
3972
- },
3973
- descriptionProps: {
3974
- id: descriptionId
3975
- },
3976
- isFocused: isFocused,
3977
- isSelected: isSelected,
3978
- isDisabled: isDisabled,
3979
- isPressed: isPressed,
3980
- allowsSelection: allowsSelection,
3981
- hasAction: hasAction
3982
- };
3983
- }
3984
-
3985
- var _templateObject$3, _templateObject2$3, _templateObject3$3, _templateObject4$3, _templateObject5$3, _templateObject6$1;
3986
-
3987
- var _excluded$3 = ["state", "mode"];
3988
-
3989
- var Listbox = function Listbox(_ref) {
3990
- var state = _ref.state,
3991
- _ref$mode = _ref.mode,
3992
- mode = _ref$mode === void 0 ? 'default' : _ref$mode,
3993
- props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
3994
-
3995
- var ref = useRef(null);
3996
-
3997
- var _useListBox = $c132121280ec012d$export$50eacbbf140a3141(props, state, ref),
3998
- listBoxProps = _useListBox.listBoxProps;
3999
-
4000
- var collection = useMemo(function () {
4001
- return [].concat(state.collection).map(function (node, index, self) {
4002
- return {
4003
- node: node,
4004
- first: index === 0,
4005
- last: index === self.length - 1
4006
- };
4007
- });
4008
- }, [state.collection]);
4009
- return /*#__PURE__*/React.createElement(ListboxRoot, _extends({
4010
- ref: ref
4011
- }, listBoxProps), collection.map(function (_ref2) {
4012
- var node = _ref2.node,
4013
- last = _ref2.last;
4014
- return /*#__PURE__*/React.createElement(Fragment, {
4015
- key: node.key
4016
- }, /*#__PURE__*/React.createElement(Option, {
4017
- item: node,
4018
- state: state,
4019
- mode: mode
4020
- }), !last && mode === 'separator' && /*#__PURE__*/React.createElement(Divider, null));
4021
- }));
4022
- };
4023
-
4024
- var Listbox$1 = memo(Listbox);
4025
- var ListboxRoot = styled.ul(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteralLoose(["\n padding-left: 0;\n margin: 0;\n box-sizing: border-box;\n list-style: none;\n\n ", "\n"])), theme$2(function (o) {
4026
- return [o.bg.background1, o.border["default"], o.borderRadius(8), o.outline["default"].focus];
4027
- }));
4028
- var Divider = styled.div.attrs({
4029
- role: 'separator'
4030
- })(_templateObject2$3 || (_templateObject2$3 = _taggedTemplateLiteralLoose(["\n display: flex;\n ", "\n\n &:before {\n content: '';\n display: block;\n width: 100%;\n height: 1px;\n background: #00000014;\n }\n"])), theme$2(function (o) {
4031
- return [o.padding.horizontal(8)];
4032
- }));
4033
-
4034
- var Option = function Option(_ref3) {
4035
- var item = _ref3.item,
4036
- state = _ref3.state,
4037
- mode = _ref3.mode;
4038
- var ref = useRef(null);
4039
-
4040
- var _useOption = $293f70390ea03370$export$497855f14858aa34(item, state, ref),
4041
- optionProps = _useOption.optionProps,
4042
- isSelected = _useOption.isSelected;
4043
-
4044
- var _useFocusRing = useFocusRing(),
4045
- focusProps = _useFocusRing.focusProps;
4046
-
4047
- return /*#__PURE__*/React.createElement(OptionRoot, _extends({}, $3ef42575df84b30b$export$9d1611c77c2fe928(optionProps, focusProps), {
4048
- ref: ref,
4049
- mode: mode
4050
- }), /*#__PURE__*/React.createElement(OptionCheckIcon, {
4051
- name: "16/Check",
4052
- isSelected: isSelected
4053
- }), /*#__PURE__*/React.createElement(OptionText, null, item.rendered));
4054
- };
4055
-
4056
- var OptionRoot = styled.li(_templateObject3$3 || (_templateObject3$3 = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n gap: ", ";\n height: 40px;\n cursor: pointer;\n outline: none;\n\n ", "\n\n &:focus {\n ", "\n }\n"])), function (_ref4) {
4057
- var theme = _ref4.theme;
4058
- return px(theme.spacing[4]);
4059
- }, function (_ref5) {
4060
- var mode = _ref5.mode;
4061
- return theme$2(function (o) {
4062
- return [o.padding.horizontal(8), mode === 'separator' && o.padding.vertical(4)];
4063
- });
4064
- }, theme$2(function (o) {
4065
- return [o.bg.surface3];
4066
- }));
4067
- var OptionCheckIcon = styled(Icon$1)(_templateObject4$3 || (_templateObject4$3 = _taggedTemplateLiteralLoose(["\n visibility: hidden;\n\n ", "\n"])), function (_ref6) {
4068
- var isSelected = _ref6.isSelected;
4069
- return isSelected && css(_templateObject5$3 || (_templateObject5$3 = _taggedTemplateLiteralLoose(["\n visibility: visible;\n "])));
4070
- });
4071
- var OptionText = styled.span(_templateObject6$1 || (_templateObject6$1 = _taggedTemplateLiteralLoose(["\n display: block;\n ", "\n"])), theme$2(function (o) {
4072
- return [o.typography(14)];
4073
- }));
4074
-
4075
- var _excluded$2 = ["open", "onClose", "children"];
4076
-
4077
- var Popover = function Popover(_ref) {
4078
- var open = _ref.open,
4079
- onClose = _ref.onClose,
4080
- children = _ref.children,
4081
- props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
4082
-
4083
- var ref = useRef(null);
4084
-
4085
- var _useOverlay = useOverlay(useMemo(function () {
4086
- return {
4087
- isOpen: open,
4088
- onClose: onClose,
4089
- shouldCloseOnBlur: true,
4090
- isDismissable: true
4091
- };
4092
- }, [onClose, open]), ref),
4093
- overlayProps = _useOverlay.overlayProps;
4094
-
4095
- return /*#__PURE__*/React.createElement(FocusScope, {
4096
- restoreFocus: true
4097
- }, /*#__PURE__*/React.createElement("div", _extends({}, $3ef42575df84b30b$export$9d1611c77c2fe928(overlayProps, props), {
4098
- ref: ref
4099
- }), children, /*#__PURE__*/React.createElement(DismissButton, {
4100
- onDismiss: onClose
4101
- })));
4102
- };
4103
-
4104
- var Popover$1 = memo(Popover);
4105
-
4106
- var _templateObject$2, _templateObject2$2, _templateObject3$2, _templateObject4$2, _templateObject5$2, _templateObject6, _templateObject7;
4107
-
4108
- var _excluded$1 = ["open", "className", "label", "requiredText", "subLabel", "assertiveText", "autoComplete", "invalid", "disabled", "required", "showLabel", "mode"];
4109
-
4110
- var DropdownSelector = function DropdownSelector(_ref) {
4111
- var open = _ref.open,
4112
- className = _ref.className,
4113
- _ref$label = _ref.label,
4114
- label = _ref$label === void 0 ? '' : _ref$label,
4115
- _ref$requiredText = _ref.requiredText,
4116
- requiredText = _ref$requiredText === void 0 ? '' : _ref$requiredText,
4117
- subLabel = _ref.subLabel,
4118
- assertiveText = _ref.assertiveText,
4119
- autoComplete = _ref.autoComplete,
4120
- _ref$invalid = _ref.invalid,
4121
- invalid = _ref$invalid === void 0 ? false : _ref$invalid,
4122
- _ref$disabled = _ref.disabled,
4123
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
4124
- _ref$required = _ref.required,
4125
- required = _ref$required === void 0 ? false : _ref$required,
4126
- _ref$showLabel = _ref.showLabel,
4127
- showLabel = _ref$showLabel === void 0 ? false : _ref$showLabel,
4128
- _ref$mode = _ref.mode,
4129
- mode = _ref$mode === void 0 ? 'default' : _ref$mode,
4130
- props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
4131
-
4132
- var _useVisuallyHidden = useVisuallyHidden(),
4133
- visuallyHiddenProps = _useVisuallyHidden.visuallyHiddenProps;
4134
-
4135
- var triggerRef = useRef(null);
4136
- var selectProps = useMemo(function () {
4137
- return _extends({}, props, {
4138
- label: label,
4139
- isOpen: open,
4140
- isDisabled: disabled,
4141
- isRequired: required,
4142
- errorMessage: invalid && assertiveText,
4143
- validationState: invalid ? 'invalid' : 'valid',
4144
- onSelectionChange: props.onChange,
4145
- selectedKey: props.value,
4146
- defaultSelectedKey: props.defaultValue
4147
- });
4148
- }, [assertiveText, disabled, invalid, label, open, props, required]);
4149
- var state = useSelectState(selectProps);
4150
-
4151
- var _useSelect = useSelect(selectProps, state, triggerRef),
4152
- labelProps = _useSelect.labelProps,
4153
- triggerProps = _useSelect.triggerProps,
4154
- valueProps = _useSelect.valueProps,
4155
- menuProps = _useSelect.menuProps,
4156
- errorMessageProps = _useSelect.errorMessageProps,
4157
- descriptionProps = _useSelect.descriptionProps;
4158
-
4159
- var _useButton = useButton(triggerProps, triggerRef),
4160
- buttonProps = _useButton.buttonProps;
4161
-
4162
- var hasAssertiveText = assertiveText !== undefined && assertiveText.length > 0;
4163
- return /*#__PURE__*/React.createElement(DropdownSelectorRoot, {
4164
- "aria-disabled": disabled,
4165
- className: className
4166
- }, /*#__PURE__*/React.createElement(DropdownFieldLabel, _extends({
4167
- label: label,
4168
- required: required,
4169
- requiredText: requiredText,
4170
- subLabel: subLabel
4171
- }, labelProps, !showLabel ? visuallyHiddenProps : {})), /*#__PURE__*/React.createElement(HiddenSelect, {
4172
- state: state,
4173
- triggerRef: triggerRef,
4174
- label: label,
4175
- name: props.name,
4176
- isDisabled: disabled,
4177
- autoComplete: autoComplete
4178
- }), /*#__PURE__*/React.createElement(DropdownButtonWrapper, null, /*#__PURE__*/React.createElement(DropdownButton, _extends({}, buttonProps, {
4179
- ref: triggerRef,
4180
- invalid: invalid
4181
- }), /*#__PURE__*/React.createElement(DropdownButtonText, valueProps, state.selectedItem ? state.selectedItem.rendered : props.placeholder), /*#__PURE__*/React.createElement(Icon$1, {
4182
- name: "16/Menu"
4183
- })), state.isOpen && /*#__PURE__*/React.createElement(DropdownPopover, {
4184
- open: state.isOpen,
4185
- onClose: function onClose() {
4186
- return state.close();
4187
- }
4188
- }, /*#__PURE__*/React.createElement(Listbox$1, _extends({}, menuProps, {
4189
- state: state,
4190
- mode: mode
4191
- })))), hasAssertiveText && /*#__PURE__*/React.createElement(AssertiveText, _extends({
4192
- invalid: invalid
4193
- }, invalid ? errorMessageProps : descriptionProps), assertiveText));
4194
- };
4195
- var DropdownSelectorItem = Item;
4196
- var DropdownSelectorRoot = styled.div(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteralLoose(["\n position: relative;\n display: inline-block;\n\n ", " {\n cursor: default;\n ", "\n }\n"])), disabledSelector, theme$2(function (o) {
4197
- return o.disabled;
4198
- }));
4199
- var DropdownFieldLabel = styled(FieldLabel)(_templateObject2$2 || (_templateObject2$2 = _taggedTemplateLiteralLoose(["\n width: 100%;\n\n ", "\n"])), theme$2(function (o) {
4200
- return o.margin.bottom(8);
4201
- }));
4202
- var DropdownButtonWrapper = styled.div(_templateObject3$2 || (_templateObject3$2 = _taggedTemplateLiteralLoose(["\n position: relative;\n"])));
4203
- var DropdownButton = styled.button(_templateObject4$2 || (_templateObject4$2 = _taggedTemplateLiteralLoose(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n\n height: 40px;\n width: 288px;\n box-sizing: border-box;\n cursor: pointer;\n\n ", " {\n cursor: default;\n }\n\n ", "\n"])), disabledSelector, function (_ref2) {
4204
- var invalid = _ref2.invalid;
4205
- return theme$2(function (o) {
4206
- return [o.border["default"], o.padding.horizontal(8), o.outline["default"].focus, o.bg.surface3, o.borderRadius(4), invalid && o.outline.assertive];
4207
- });
4208
- });
4209
- var DropdownButtonText = styled.span(_templateObject5$2 || (_templateObject5$2 = _taggedTemplateLiteralLoose(["\n text-align: left;\n\n ", "\n"])), theme$2(function (o) {
4210
- return [o.typography(14), o.font.text2];
4211
- }));
4212
- var AssertiveText = styled.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n ", "\n"])), function (_ref3) {
4213
- var invalid = _ref3.invalid;
4214
- return theme$2(function (o) {
4215
- return [o.typography(14), o.margin.top(8), invalid && o.font.assertive];
4216
- });
4217
- });
4218
- var DropdownPopover = styled(Popover$1)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteralLoose(["\n position: absolute;\n width: 100%;\n\n top: 100%;\n margin-top: 2px;\n"])));
4219
-
4220
- var RadioContext = createContext(null);
4221
- var RadioProvider = function RadioProvider(_ref) {
4222
- var value = _ref.value,
4223
- children = _ref.children;
4224
- return /*#__PURE__*/React.createElement(RadioContext.Provider, {
4225
- value: value
4226
- }, children);
4227
- };
4228
- var useRadioContext = function useRadioContext() {
4229
- var state = useContext(RadioContext);
4230
- if (state === null) throw new Error('`<RadioProvider>` is not likely mounted.');
4231
- return state;
4232
- };
4233
-
4234
- var _templateObject$1, _templateObject2$1, _templateObject3$1, _templateObject4$1, _templateObject5$1;
4235
-
4236
- var _excluded = ["children"];
4237
- var SegmentedControl = forwardRef(function SegmentedControlInner(props, ref) {
4238
- var ariaRadioGroupProps = useMemo(function () {
4239
- return _extends({}, props, {
4240
- isDisabled: props.disabled,
4241
- isReadOnly: props.readonly,
4242
- isRequired: props.required
4243
- });
4244
- }, [props]);
4245
- var state = useRadioGroupState(ariaRadioGroupProps);
4246
-
4247
- var _useRadioGroup = useRadioGroup(ariaRadioGroupProps, state),
4248
- radioGroupProps = _useRadioGroup.radioGroupProps;
4249
-
4250
- var segmentedControlItems = useMemo(function () {
4251
- return props.data.map(function (d) {
4252
- return typeof d === 'string' ? {
4253
- value: d,
4254
- label: d
4255
- } : d;
4256
- });
4257
- }, [props.data]);
4258
- return /*#__PURE__*/React.createElement(SegmentedControlRoot, _extends({
4259
- ref: ref
4260
- }, radioGroupProps), /*#__PURE__*/React.createElement(RadioProvider, {
4261
- value: state
4262
- }, segmentedControlItems.map(function (item) {
4263
- return /*#__PURE__*/React.createElement(Segmented, {
4264
- key: item.value,
4265
- value: item.value,
4266
- disabled: item.disabled
4267
- }, item.label);
4268
- })));
4269
- });
4270
- var index$1 = memo(SegmentedControl);
4271
-
4272
- var Segmented = function Segmented(_ref) {
4273
- var children = _ref.children,
4274
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
4275
-
4276
- var state = useRadioContext();
4277
- var ref = useRef(null);
4278
- var ariaRadioProps = useMemo(function () {
4279
- return _extends({}, props, {
4280
- isDisabled: props.disabled
4281
- });
4282
- }, [props]);
4283
-
4284
- var _useRadio = useRadio(ariaRadioProps, state, ref),
4285
- inputProps = _useRadio.inputProps,
4286
- isDisabled = _useRadio.isDisabled,
4287
- isSelected = _useRadio.isSelected;
4288
-
4289
- return /*#__PURE__*/React.createElement(SegmentedRoot, {
4290
- "aria-disabled": isDisabled || state.isReadOnly,
4291
- checked: isSelected
4292
- }, /*#__PURE__*/React.createElement(SegmentedInput, _extends({}, inputProps, {
4293
- ref: ref
4294
- })), /*#__PURE__*/React.createElement(RadioLabel, null, /*#__PURE__*/React.createElement(SegmentedLabelInner, null, children)));
4295
- };
4296
-
4297
- var SegmentedControlRoot = styled.div(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteralLoose(["\n display: inline-flex;\n align-items: center;\n\n ", "\n"])), theme$2(function (o) {
4298
- return [o.bg.surface3, o.borderRadius(16)];
4299
- }));
4300
- var SegmentedRoot = styled.label(_templateObject2$1 || (_templateObject2$1 = _taggedTemplateLiteralLoose(["\n position: relative;\n display: flex;\n align-items: center;\n cursor: pointer;\n height: 32px;\n\n ", " {\n cursor: default;\n }\n\n ", "\n"])), disabledSelector, function (_ref2) {
4301
- var checked = _ref2.checked;
4302
- return theme$2(function (o) {
4303
- return [o.padding.horizontal(16), o.borderRadius(16), o.disabled, checked === true && o.bg.brand, checked === true ? o.font.text5 : o.font.text2];
4304
- });
4305
- });
4306
- var SegmentedInput = styled.input(_templateObject3$1 || (_templateObject3$1 = _taggedTemplateLiteralLoose(["\n position: absolute;\n\n height: 0px;\n width: 0px;\n padding: 0;\n margin: 0;\n\n appearance: none;\n box-sizing: border-box;\n overflow: hidden;\n white-space: nowrap;\n opacity: 0;\n"])));
4307
- var RadioLabel = styled.div(_templateObject4$1 || (_templateObject4$1 = _taggedTemplateLiteralLoose(["\n background: transparent;\n display: flex;\n align-items: center;\n height: 22px;\n"])));
4308
- var SegmentedLabelInner = styled.div(_templateObject5$1 || (_templateObject5$1 = _taggedTemplateLiteralLoose(["\n ", "\n"])), theme$2(function (o) {
4309
- return [o.typography(14)];
4310
- }));
4311
-
4312
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
4313
- var Checkbox = forwardRef(function CheckboxInner(props, ref) {
4314
- var _props$disabled, _props$readonly;
4315
-
4316
- var ariaCheckboxProps = useMemo(function () {
4317
- return _extends({}, props, {
4318
- isSelected: props.checked,
4319
- defaultSelected: props.defaultChecked,
4320
- // children がいない場合は aria-label をつけないといけない
4321
- 'aria-label': 'children' in props ? undefined : props.label,
4322
- isDisabled: props.disabled
4323
- });
4324
- }, [props]);
4325
- var state = useToggleState(ariaCheckboxProps);
4326
- var objectRef = $df56164dff5785e2$export$4338b53315abf666(ref);
4327
-
4328
- var _useCheckbox = useCheckbox(ariaCheckboxProps, state, objectRef),
4329
- inputProps = _useCheckbox.inputProps;
4330
-
4331
- var isDisabled = ((_props$disabled = props.disabled) != null ? _props$disabled : false) || ((_props$readonly = props.readonly) != null ? _props$readonly : false);
4332
- return /*#__PURE__*/React.createElement(InputRoot, {
4333
- "aria-disabled": isDisabled
4334
- }, /*#__PURE__*/React.createElement(CheckboxInput, _extends({
4335
- type: "checkbox"
4336
- }, inputProps)), /*#__PURE__*/React.createElement(CheckboxInputOverlay, {
4337
- "aria-hidden": true,
4338
- checked: inputProps.checked
4339
- }, /*#__PURE__*/React.createElement(Icon$1, {
4340
- name: "24/Check",
4341
- unsafeNonGuidelineScale: 2 / 3
4342
- })), 'children' in props && /*#__PURE__*/React.createElement(InputLabel, null, props.children));
4343
- });
4344
- var index = memo(Checkbox);
4345
- var hiddenCss = css(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n visibility: hidden;\n"])));
4346
- var InputRoot = styled.label(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n position: relative;\n display: flex;\n align-items: center;\n cursor: pointer;\n ", " {\n cursor: default;\n }\n\n gap: ", ";\n ", "\n"])), disabledSelector, function (_ref) {
4347
- var theme = _ref.theme;
4348
- return px(theme.spacing[4]);
4349
- }, theme$2(function (o) {
4350
- return [o.disabled];
4351
- }));
4352
- var CheckboxInput = styled.input(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n &[type='checkbox'] {\n appearance: none;\n display: block;\n cursor: pointer;\n margin: 0;\n width: 20px;\n height: 20px;\n\n &:checked {\n ", "\n }\n &:not(:checked) {\n border-width: 2px;\n border-style: solid;\n border-color: ", ";\n }\n ", "\n }\n"])), theme$2(function (o) {
4353
- return o.bg.brand.hover.press;
4354
- }), function (_ref2) {
4355
- var theme = _ref2.theme;
4356
- return theme.color.text4;
4357
- }, theme$2(function (o) {
4358
- return [o.outline["default"].focus, o.borderRadius(4)];
4359
- }));
4360
- var CheckboxInputOverlay = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["\n position: absolute;\n top: -2px;\n left: -2px;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n\n ", "\n\n ", ";\n"])), theme$2(function (o) {
4361
- return [o.width.px(24), o.height.px(24), o.font.text5];
4362
- }), function (_ref3) {
4363
- var checked = _ref3.checked;
4364
- return checked !== true && hiddenCss;
4365
- });
4366
- var InputLabel = styled.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n ", "\n"])), theme$2(function (o) {
4367
- return [o.typography(14)];
4368
- }));
4369
-
4370
- export { Button, index as Checkbox, Clickable, ComponentAbstraction, DropdownSelector, DropdownSelectorItem, Icon$1 as Icon, IconButton, LoadingSpinner, LoadingSpinnerIcon, Modal, ModalAlign, ModalBody, ModalButtons, ModalHeader, MultiSelect, MultiSelectGroup, Radio, RadioGroup, index$1 as SegmentedControl, SwitchCheckbox as Switch, TextField, useComponentAbstraction };
4371
- //# sourceMappingURL=index.module.js.map