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