@redsift/pickers 10.2.0 → 10.3.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +4 -4
- package/index.d.ts +149 -79
- package/index.js +395 -262
- package/index.js.map +1 -1
- package/package.json +8 -8
package/index.js
CHANGED
|
@@ -1,29 +1,9 @@
|
|
|
1
1
|
import React, { forwardRef, useContext, useEffect, useRef, useState, useReducer, useMemo } from 'react';
|
|
2
|
-
import { usePopoverContext, useMergeRefs, FloatingPortal, StyledPopoverContent, PopoverContent, Popover } from '@redsift/popovers';
|
|
3
|
-
import { baseContainer, FocusWithinGroupContext, ListboxContext, isComponent, Item, useListboxItem, useTheme, Flexbox, StyledItem, getContainerProps, partitionComponents, useLocalizedStringFormatter, FocusWithinGroupActionType, ListboxActionType, IconButton, EventKey, ListboxReducer, useId, ThemeProvider, FocusWithinGroup, Text, Theme, Icon } from '@redsift/design-system';
|
|
4
|
-
import { mdiChevronDown } from '@redsift/icons';
|
|
5
2
|
import classNames from 'classnames';
|
|
6
3
|
import styled from 'styled-components';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
const ComboboxSelectionMode = {
|
|
12
|
-
single: 'single',
|
|
13
|
-
multiple: 'multiple'
|
|
14
|
-
};
|
|
15
|
-
const ComboboxVariant = {
|
|
16
|
-
options: 'options',
|
|
17
|
-
suggestions: 'suggestions'
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Context props.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Component props.
|
|
26
|
-
*/
|
|
4
|
+
import { baseContainer, FocusWithinGroupContext, ListboxContext, isComponent, Item, useListboxItem, useTheme, Flexbox, StyledItem, getContainerProps, AppContainerContext, partitionComponents, useId, useMessageFormatter, FocusWithinGroupActionType, IconButton, ListboxActionType, EventKey, ListboxReducer, ThemeProvider, FocusWithinGroup, Text, Theme, Icon } from '@redsift/design-system';
|
|
5
|
+
import { usePopoverContext, useMergeRefs, FloatingPortal, StyledPopoverContent, PopoverContent, Popover } from '@redsift/popovers';
|
|
6
|
+
import { mdiClose, mdiChevronDown } from '@redsift/icons';
|
|
27
7
|
|
|
28
8
|
function ownKeys(object, enumerableOnly) {
|
|
29
9
|
var keys = Object.keys(object);
|
|
@@ -119,69 +99,84 @@ function _toPropertyKey(arg) {
|
|
|
119
99
|
/**
|
|
120
100
|
* Component style.
|
|
121
101
|
*/
|
|
122
|
-
const
|
|
102
|
+
const StyledComboboxContentFooter = styled.div`
|
|
123
103
|
${baseContainer}
|
|
124
104
|
`;
|
|
125
105
|
|
|
126
|
-
const _excluded$
|
|
127
|
-
const COMPONENT_NAME$
|
|
128
|
-
const CLASSNAME$
|
|
129
|
-
const DEFAULT_PROPS$b = {};
|
|
106
|
+
const _excluded$6 = ["children", "className"];
|
|
107
|
+
const COMPONENT_NAME$e = 'ComboboxContentFooter';
|
|
108
|
+
const CLASSNAME$e = 'redsift-combobox-content-footer';
|
|
130
109
|
|
|
131
110
|
/**
|
|
132
|
-
* The
|
|
111
|
+
* The ComboboxContentFooter component.
|
|
133
112
|
*/
|
|
134
|
-
const
|
|
113
|
+
const ComboboxContentFooter = /*#__PURE__*/forwardRef((props, ref) => {
|
|
135
114
|
const {
|
|
136
115
|
children,
|
|
137
116
|
className
|
|
138
117
|
} = props,
|
|
139
|
-
forwardedProps = _objectWithoutProperties(props, _excluded$
|
|
140
|
-
return /*#__PURE__*/React.createElement(
|
|
141
|
-
className: classNames(
|
|
118
|
+
forwardedProps = _objectWithoutProperties(props, _excluded$6);
|
|
119
|
+
return /*#__PURE__*/React.createElement(StyledComboboxContentFooter, _extends({}, forwardedProps, {
|
|
120
|
+
className: classNames(ComboboxContentFooter.className, className),
|
|
142
121
|
ref: ref
|
|
143
122
|
}), children);
|
|
144
123
|
});
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
ComboboxContentHeader.displayName = COMPONENT_NAME$b;
|
|
124
|
+
ComboboxContentFooter.className = CLASSNAME$e;
|
|
125
|
+
ComboboxContentFooter.displayName = COMPONENT_NAME$e;
|
|
148
126
|
|
|
149
127
|
/**
|
|
150
128
|
* Component style.
|
|
151
129
|
*/
|
|
152
|
-
const
|
|
130
|
+
const StyledComboboxContentHeader = styled.div`
|
|
153
131
|
${baseContainer}
|
|
154
132
|
`;
|
|
155
133
|
|
|
156
|
-
const _excluded$
|
|
157
|
-
const COMPONENT_NAME$
|
|
158
|
-
const CLASSNAME$
|
|
159
|
-
const DEFAULT_PROPS$a = {};
|
|
134
|
+
const _excluded$5 = ["children", "className"];
|
|
135
|
+
const COMPONENT_NAME$d = 'ComboboxContentHeader';
|
|
136
|
+
const CLASSNAME$d = 'redsift-combobox-content-header';
|
|
160
137
|
|
|
161
138
|
/**
|
|
162
|
-
* The
|
|
139
|
+
* The ComboboxContentHeader component.
|
|
163
140
|
*/
|
|
164
|
-
const
|
|
141
|
+
const ComboboxContentHeader = /*#__PURE__*/forwardRef((props, ref) => {
|
|
165
142
|
const {
|
|
166
143
|
children,
|
|
167
144
|
className
|
|
168
145
|
} = props,
|
|
169
|
-
forwardedProps = _objectWithoutProperties(props, _excluded$
|
|
170
|
-
return /*#__PURE__*/React.createElement(
|
|
171
|
-
className: classNames(
|
|
146
|
+
forwardedProps = _objectWithoutProperties(props, _excluded$5);
|
|
147
|
+
return /*#__PURE__*/React.createElement(StyledComboboxContentHeader, _extends({}, forwardedProps, {
|
|
148
|
+
className: classNames(ComboboxContentHeader.className, className),
|
|
172
149
|
ref: ref
|
|
173
150
|
}), children);
|
|
174
151
|
});
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
ComboboxContentFooter.displayName = COMPONENT_NAME$a;
|
|
152
|
+
ComboboxContentHeader.className = CLASSNAME$d;
|
|
153
|
+
ComboboxContentHeader.displayName = COMPONENT_NAME$d;
|
|
178
154
|
|
|
179
155
|
const ComboboxContext = /*#__PURE__*/React.createContext(null);
|
|
180
156
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const
|
|
157
|
+
/**
|
|
158
|
+
* Component variant.
|
|
159
|
+
*/
|
|
160
|
+
const ComboboxSelectionMode = {
|
|
161
|
+
single: 'single',
|
|
162
|
+
multiple: 'multiple'
|
|
163
|
+
};
|
|
164
|
+
const ComboboxVariant = {
|
|
165
|
+
options: 'options',
|
|
166
|
+
suggestions: 'suggestions'
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Context props.
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Component props.
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
const _excluded$4 = ["children", "className", "renderFreeTextItem"];
|
|
178
|
+
const COMPONENT_NAME$c = 'ComboboxContentListbox';
|
|
179
|
+
const CLASSNAME$c = 'redsift-combobox-content-listbox';
|
|
185
180
|
|
|
186
181
|
/**
|
|
187
182
|
* The ComboboxContentListbox component.
|
|
@@ -192,7 +187,7 @@ const ComboboxContentListbox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
192
187
|
className,
|
|
193
188
|
renderFreeTextItem
|
|
194
189
|
} = props,
|
|
195
|
-
forwardedProps = _objectWithoutProperties(props, _excluded$
|
|
190
|
+
forwardedProps = _objectWithoutProperties(props, _excluded$4);
|
|
196
191
|
const focusContext = useContext(FocusWithinGroupContext);
|
|
197
192
|
const listboxState = useContext(ListboxContext);
|
|
198
193
|
const comboboxState = useContext(ComboboxContext);
|
|
@@ -270,11 +265,12 @@ const ComboboxContentListbox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
270
265
|
}), canHaveMultipleSelections && canHaveFreeText ? /*#__PURE__*/React.createElement(StyledItem, {
|
|
271
266
|
role: "option",
|
|
272
267
|
id: comboboxState.freeTextItemId,
|
|
273
|
-
$
|
|
268
|
+
$color: "primary",
|
|
269
|
+
$isActive: isSelected,
|
|
274
270
|
$isDisabled: isDisabled,
|
|
275
|
-
$
|
|
276
|
-
$isHovered:
|
|
277
|
-
$
|
|
271
|
+
$isGradient: false,
|
|
272
|
+
$isHovered: isFocused,
|
|
273
|
+
$hasBorder: false,
|
|
278
274
|
$hasCheckbox: false,
|
|
279
275
|
$theme: theme,
|
|
280
276
|
"aria-selected": isSelected,
|
|
@@ -290,18 +286,17 @@ const ComboboxContentListbox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
290
286
|
} : undefined
|
|
291
287
|
}, renderedFreeTextItem) : null, Array.isArray(children) ? renderedChildren : children);
|
|
292
288
|
});
|
|
293
|
-
ComboboxContentListbox.className = CLASSNAME$
|
|
294
|
-
ComboboxContentListbox.
|
|
295
|
-
ComboboxContentListbox.displayName = COMPONENT_NAME$9;
|
|
289
|
+
ComboboxContentListbox.className = CLASSNAME$c;
|
|
290
|
+
ComboboxContentListbox.displayName = COMPONENT_NAME$c;
|
|
296
291
|
|
|
297
|
-
const COMPONENT_NAME$
|
|
298
|
-
const CLASSNAME$
|
|
299
|
-
const DEFAULT_PROPS$8 = {};
|
|
292
|
+
const COMPONENT_NAME$b = 'ComboboxContent';
|
|
293
|
+
const CLASSNAME$b = 'redsift-combobox-content';
|
|
300
294
|
|
|
301
295
|
/**
|
|
302
296
|
* The ComboboxContent component.
|
|
303
297
|
*/
|
|
304
298
|
const BaseComboboxContent = /*#__PURE__*/forwardRef((props, ref) => {
|
|
299
|
+
var _comboboxState$inputV;
|
|
305
300
|
const {
|
|
306
301
|
children,
|
|
307
302
|
className,
|
|
@@ -317,32 +312,35 @@ const BaseComboboxContent = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
317
312
|
y
|
|
318
313
|
} = usePopoverContext();
|
|
319
314
|
const popoverRef = useMergeRefs([refs.setFloating, ref]);
|
|
315
|
+
const appContainerState = useContext(AppContainerContext);
|
|
316
|
+
const comboboxState = useContext(ComboboxContext);
|
|
317
|
+
const focusContext = useContext(FocusWithinGroupContext);
|
|
320
318
|
const listboxState = useContext(ListboxContext);
|
|
321
319
|
const theme = useTheme();
|
|
322
320
|
const [[header], [listbox], [footer]] = partitionComponents(React.Children.toArray(children), [isComponent('ComboboxContentHeader'), isComponent('ComboboxContentListbox'), isComponent('ComboboxContentFooter')]);
|
|
323
321
|
return /*#__PURE__*/React.createElement(FloatingPortal, {
|
|
324
|
-
|
|
322
|
+
root: appContainerState === null || appContainerState === void 0 ? void 0 : appContainerState.appContainerRef.current
|
|
325
323
|
}, isOpen && /*#__PURE__*/React.createElement(StyledPopoverContent, _extends({
|
|
326
324
|
$theme: theme,
|
|
327
|
-
ref: popoverRef
|
|
328
|
-
|
|
325
|
+
ref: popoverRef
|
|
326
|
+
}, getFloatingProps(props), {
|
|
327
|
+
style: _objectSpread2(_objectSpread2({
|
|
329
328
|
position: strategy,
|
|
330
329
|
top: y !== null && y !== void 0 ? y : 0,
|
|
331
330
|
left: x !== null && x !== void 0 ? x : 0
|
|
332
|
-
}, style)
|
|
333
|
-
|
|
331
|
+
}, style), comboboxState !== null && comboboxState !== void 0 && (_comboboxState$inputV = comboboxState.inputValue) !== null && _comboboxState$inputV !== void 0 && _comboboxState$inputV.length && focusContext.state.tabStops.length === 0 ? {
|
|
332
|
+
display: 'none'
|
|
333
|
+
} : {}),
|
|
334
334
|
className: classNames(PopoverContent.className, BaseComboboxContent.className, className),
|
|
335
|
-
"aria-disabled": listboxState.state.isDisabled
|
|
336
|
-
"aria-multiselectable": listboxState.state.selectionMode === 'multiple'
|
|
335
|
+
"aria-disabled": listboxState.state.isDisabled
|
|
337
336
|
}), /*#__PURE__*/React.createElement(Flexbox, _extends({
|
|
338
337
|
flexDirection: "column",
|
|
339
338
|
gap: "0px",
|
|
340
339
|
width: "100%"
|
|
341
340
|
}, containerProps), header, listbox, footer)));
|
|
342
341
|
});
|
|
343
|
-
BaseComboboxContent.className = CLASSNAME$
|
|
344
|
-
BaseComboboxContent.
|
|
345
|
-
BaseComboboxContent.displayName = COMPONENT_NAME$8;
|
|
342
|
+
BaseComboboxContent.className = CLASSNAME$b;
|
|
343
|
+
BaseComboboxContent.displayName = COMPONENT_NAME$b;
|
|
346
344
|
const ComboboxContent = Object.assign(BaseComboboxContent, {
|
|
347
345
|
Header: ComboboxContentHeader,
|
|
348
346
|
Listbox: ComboboxContentListbox,
|
|
@@ -351,16 +349,24 @@ const ComboboxContent = Object.assign(BaseComboboxContent, {
|
|
|
351
349
|
|
|
352
350
|
var collapse$1 = "Collapse";
|
|
353
351
|
var expand$1 = "Expand";
|
|
352
|
+
var selected$1 = "{count, plural, =0 {None selected} other {# selected}}";
|
|
353
|
+
var unselect$1 = "Unselect {label}";
|
|
354
354
|
var enUS = {
|
|
355
355
|
collapse: collapse$1,
|
|
356
|
-
expand: expand$1
|
|
356
|
+
expand: expand$1,
|
|
357
|
+
selected: selected$1,
|
|
358
|
+
unselect: unselect$1
|
|
357
359
|
};
|
|
358
360
|
|
|
359
361
|
var collapse = "Réduire";
|
|
360
362
|
var expand = "Développer";
|
|
363
|
+
var selected = "{count, plural, =0 {Aucun sélectionné} =1 {1 sélectionné} other {# sélectionnés}}";
|
|
364
|
+
var unselect = "Déselectionner {{label}}";
|
|
361
365
|
var frFR = {
|
|
362
366
|
collapse: collapse,
|
|
363
|
-
expand: expand
|
|
367
|
+
expand: expand,
|
|
368
|
+
selected: selected,
|
|
369
|
+
unselect: unselect
|
|
364
370
|
};
|
|
365
371
|
|
|
366
372
|
var intlMessages = {
|
|
@@ -368,22 +374,23 @@ var intlMessages = {
|
|
|
368
374
|
'fr-FR': frFR
|
|
369
375
|
};
|
|
370
376
|
|
|
371
|
-
const _excluded = ["aria-controls", "aria-expanded", "aria-haspopup", "role"];
|
|
372
|
-
const COMPONENT_NAME$
|
|
373
|
-
const CLASSNAME$
|
|
374
|
-
const DEFAULT_PROPS$7 = {};
|
|
377
|
+
const _excluded$3 = ["aria-controls", "aria-expanded", "aria-haspopup", "role"];
|
|
378
|
+
const COMPONENT_NAME$a = 'ComboboxTrigger';
|
|
379
|
+
const CLASSNAME$a = 'redsift-combobox-trigger';
|
|
375
380
|
|
|
376
381
|
/**
|
|
377
382
|
* The ComboboxTrigger component.
|
|
378
383
|
*/
|
|
379
384
|
const ComboboxTrigger = /*#__PURE__*/forwardRef((props, ref) => {
|
|
380
385
|
var _renderedChildren$pro;
|
|
386
|
+
const [id] = useId();
|
|
381
387
|
const {
|
|
382
388
|
children,
|
|
383
389
|
hideExpandButton,
|
|
384
|
-
openOnFocus
|
|
390
|
+
openOnFocus,
|
|
391
|
+
hideClearButton
|
|
385
392
|
} = props;
|
|
386
|
-
const
|
|
393
|
+
const format = useMessageFormatter(intlMessages);
|
|
387
394
|
const {
|
|
388
395
|
getReferenceProps,
|
|
389
396
|
isOpen,
|
|
@@ -402,6 +409,9 @@ const ComboboxTrigger = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
402
409
|
value: comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.value,
|
|
403
410
|
isOpen
|
|
404
411
|
}) : children;
|
|
412
|
+
const isTextArea = isComponent('TextArea')(renderedChildren);
|
|
413
|
+
const isTextField = isComponent('TextField')(renderedChildren);
|
|
414
|
+
const hasMultipleLines = isTextArea && (comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.inputValue.includes('\n'));
|
|
405
415
|
const _inputRef = useRef();
|
|
406
416
|
const inputRef = (_renderedChildren$pro = renderedChildren.props.inputRef) !== null && _renderedChildren$pro !== void 0 ? _renderedChildren$pro : _inputRef;
|
|
407
417
|
const handleChange = value => {
|
|
@@ -431,7 +441,7 @@ const ComboboxTrigger = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
431
441
|
});
|
|
432
442
|
}
|
|
433
443
|
}
|
|
434
|
-
if (
|
|
444
|
+
if ((/^.$/.test(event.key) || code === 'Backspace') && !hasMultipleLines) {
|
|
435
445
|
if (!isOpen) {
|
|
436
446
|
handleOpenPopover(true);
|
|
437
447
|
}
|
|
@@ -457,7 +467,7 @@ const ComboboxTrigger = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
457
467
|
}
|
|
458
468
|
});
|
|
459
469
|
}
|
|
460
|
-
if (code === 'ArrowDown') {
|
|
470
|
+
if (code === 'ArrowDown' && !hasMultipleLines) {
|
|
461
471
|
if (!isOpen) {
|
|
462
472
|
handleOpenPopover(true);
|
|
463
473
|
}
|
|
@@ -473,7 +483,7 @@ const ComboboxTrigger = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
473
483
|
});
|
|
474
484
|
event.preventDefault();
|
|
475
485
|
}
|
|
476
|
-
if (code === 'ArrowUp') {
|
|
486
|
+
if (code === 'ArrowUp' && !hasMultipleLines) {
|
|
477
487
|
if (!isOpen) {
|
|
478
488
|
handleOpenPopover(true);
|
|
479
489
|
}
|
|
@@ -491,41 +501,43 @@ const ComboboxTrigger = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
491
501
|
}
|
|
492
502
|
if (code === 'Enter') {
|
|
493
503
|
var _focusContext$state$a;
|
|
494
|
-
if (
|
|
495
|
-
|
|
504
|
+
if (isTextField || isTextArea && !event.shiftKey) {
|
|
505
|
+
event.preventDefault();
|
|
506
|
+
}
|
|
507
|
+
if (canHaveMultipleSelections && canHaveFreeText && ((_focusContext$state$a = focusContext.state.activedescendant) === null || _focusContext$state$a === void 0 ? void 0 : _focusContext$state$a[0]) === comboboxState.freeTextItemId && comboboxState.inputValue) {
|
|
508
|
+
listboxState.dispatch({
|
|
509
|
+
type: ListboxActionType.TOGGLE,
|
|
510
|
+
payload: {
|
|
511
|
+
value: comboboxState.inputValue,
|
|
512
|
+
activedescendant: [comboboxState.freeTextItemId, comboboxState.inputValue]
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
handleOpenPopover(false);
|
|
516
|
+
} else if (isOpen && focusContext.state.selectedId) {
|
|
517
|
+
if (canHaveMultipleSelections) {
|
|
518
|
+
var _focusContext$state$a2, _focusContext$state$a3;
|
|
496
519
|
listboxState.dispatch({
|
|
497
520
|
type: ListboxActionType.TOGGLE,
|
|
498
521
|
payload: {
|
|
499
|
-
value:
|
|
500
|
-
activedescendant:
|
|
522
|
+
value: (_focusContext$state$a2 = (_focusContext$state$a3 = focusContext.state.activedescendant) === null || _focusContext$state$a3 === void 0 ? void 0 : _focusContext$state$a3[1]) !== null && _focusContext$state$a2 !== void 0 ? _focusContext$state$a2 : '',
|
|
523
|
+
activedescendant: focusContext.state.activedescendant
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
} else {
|
|
527
|
+
var _focusContext$state$a4, _focusContext$state$a5;
|
|
528
|
+
listboxState.dispatch({
|
|
529
|
+
type: ListboxActionType.SET,
|
|
530
|
+
payload: {
|
|
531
|
+
values: [(_focusContext$state$a4 = (_focusContext$state$a5 = focusContext.state.activedescendant) === null || _focusContext$state$a5 === void 0 ? void 0 : _focusContext$state$a5[1]) !== null && _focusContext$state$a4 !== void 0 ? _focusContext$state$a4 : ''],
|
|
532
|
+
activedescendant: focusContext.state.activedescendant
|
|
501
533
|
}
|
|
502
534
|
});
|
|
503
|
-
handleOpenPopover(false);
|
|
504
|
-
}
|
|
505
|
-
} else {
|
|
506
|
-
if (isOpen && focusContext.state.selectedId) {
|
|
507
|
-
if (canHaveMultipleSelections) {
|
|
508
|
-
var _focusContext$state$a2, _focusContext$state$a3;
|
|
509
|
-
listboxState.dispatch({
|
|
510
|
-
type: ListboxActionType.TOGGLE,
|
|
511
|
-
payload: {
|
|
512
|
-
value: (_focusContext$state$a2 = (_focusContext$state$a3 = focusContext.state.activedescendant) === null || _focusContext$state$a3 === void 0 ? void 0 : _focusContext$state$a3[1]) !== null && _focusContext$state$a2 !== void 0 ? _focusContext$state$a2 : '',
|
|
513
|
-
activedescendant: focusContext.state.activedescendant
|
|
514
|
-
}
|
|
515
|
-
});
|
|
516
|
-
} else {
|
|
517
|
-
var _focusContext$state$a4, _focusContext$state$a5;
|
|
518
|
-
listboxState.dispatch({
|
|
519
|
-
type: ListboxActionType.SET,
|
|
520
|
-
payload: {
|
|
521
|
-
values: [(_focusContext$state$a4 = (_focusContext$state$a5 = focusContext.state.activedescendant) === null || _focusContext$state$a5 === void 0 ? void 0 : _focusContext$state$a5[1]) !== null && _focusContext$state$a4 !== void 0 ? _focusContext$state$a4 : ''],
|
|
522
|
-
activedescendant: focusContext.state.activedescendant
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
535
|
}
|
|
536
|
+
} else if (!event.shiftKey) {
|
|
537
|
+
var _comboboxState$formRe, _comboboxState$formRe2, _comboboxState$submit, _comboboxState$submit2;
|
|
538
|
+
comboboxState === null || comboboxState === void 0 ? void 0 : (_comboboxState$formRe = comboboxState.formRef) === null || _comboboxState$formRe === void 0 ? void 0 : (_comboboxState$formRe2 = _comboboxState$formRe.current) === null || _comboboxState$formRe2 === void 0 ? void 0 : _comboboxState$formRe2.submit();
|
|
539
|
+
comboboxState === null || comboboxState === void 0 ? void 0 : (_comboboxState$submit = comboboxState.submitRef) === null || _comboboxState$submit === void 0 ? void 0 : (_comboboxState$submit2 = _comboboxState$submit.current) === null || _comboboxState$submit2 === void 0 ? void 0 : _comboboxState$submit2.click();
|
|
527
540
|
}
|
|
528
|
-
event.preventDefault();
|
|
529
541
|
}
|
|
530
542
|
};
|
|
531
543
|
const handleOpen = () => {
|
|
@@ -607,8 +619,8 @@ const ComboboxTrigger = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
607
619
|
handleOpenPopover(false);
|
|
608
620
|
}
|
|
609
621
|
}, [listboxState.state]);
|
|
610
|
-
if (
|
|
611
|
-
var _props$children, _focusContext$state$a7;
|
|
622
|
+
if (isTextField || isTextArea) {
|
|
623
|
+
var _props$children, _focusContext$state$a7, _comboboxState$value;
|
|
612
624
|
const _getReferenceProps = getReferenceProps(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
613
625
|
ref: triggerRef
|
|
614
626
|
}, props), renderedChildren.props), {}, {
|
|
@@ -620,42 +632,64 @@ const ComboboxTrigger = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
620
632
|
'aria-haspopup': ariaHaspopup,
|
|
621
633
|
role
|
|
622
634
|
} = _getReferenceProps,
|
|
623
|
-
forwardedProps = _objectWithoutProperties(_getReferenceProps, _excluded);
|
|
635
|
+
forwardedProps = _objectWithoutProperties(_getReferenceProps, _excluded$3);
|
|
636
|
+
const inputProps = {
|
|
637
|
+
'aria-activedescendant': isOpen ? (_focusContext$state$a7 = focusContext.state.activedescendant) === null || _focusContext$state$a7 === void 0 ? void 0 : _focusContext$state$a7[0] : undefined,
|
|
638
|
+
'aria-controls': ariaControls,
|
|
639
|
+
'aria-expanded': ariaExpanded,
|
|
640
|
+
'aria-haspopup': ariaHaspopup,
|
|
641
|
+
autoComplete: 'off',
|
|
642
|
+
autoCapitalize: 'off',
|
|
643
|
+
autoCorrect: 'off',
|
|
644
|
+
spellCheck: 'false',
|
|
645
|
+
'aria-autocomplete': canHaveMultipleSelections ? 'list' : undefined,
|
|
646
|
+
'aria-description': canHaveMultipleSelections ? format('selected', {
|
|
647
|
+
count: comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.value.length
|
|
648
|
+
}) : undefined,
|
|
649
|
+
onKeyDown: handleKeyDown,
|
|
650
|
+
role
|
|
651
|
+
};
|
|
624
652
|
return /*#__PURE__*/React.cloneElement(renderedChildren, _objectSpread2(_objectSpread2({}, forwardedProps), {}, {
|
|
625
|
-
inputProps: {
|
|
626
|
-
'aria-activedescendant': isOpen ? (_focusContext$state$a7 = focusContext.state.activedescendant) === null || _focusContext$state$a7 === void 0 ? void 0 : _focusContext$state$a7[0] : undefined,
|
|
627
|
-
'aria-controls': ariaControls,
|
|
628
|
-
'aria-expanded': ariaExpanded,
|
|
629
|
-
'aria-haspopup': ariaHaspopup,
|
|
630
|
-
onKeyDown: handleKeyDown,
|
|
631
|
-
role
|
|
632
|
-
},
|
|
633
653
|
theme,
|
|
634
|
-
|
|
654
|
+
className: classNames(renderedChildren.props.className, comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.triggerClassName),
|
|
635
655
|
isDisabled: comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.isDisabled,
|
|
636
656
|
isInvalid: comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.isInvalid,
|
|
637
|
-
onClear: handleClear,
|
|
638
657
|
onChange: handleChange,
|
|
639
658
|
onBlur: handleBlur,
|
|
640
659
|
onFocus: handleFocus,
|
|
641
|
-
value: comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.inputValue
|
|
660
|
+
value: comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.inputValue
|
|
661
|
+
}, isTextField ? {
|
|
662
|
+
inputProps,
|
|
663
|
+
inputRef,
|
|
664
|
+
onClear: handleClear,
|
|
665
|
+
hasClearButton: hideClearButton ? false : {
|
|
666
|
+
isDisabled: (comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.isDisabled) || (comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.value) && (comboboxState === null || comboboxState === void 0 ? void 0 : (_comboboxState$value = comboboxState.value) === null || _comboboxState$value === void 0 ? void 0 : _comboboxState$value.length) === 0,
|
|
667
|
+
onClick: () => inputRef.current.focus()
|
|
668
|
+
},
|
|
642
669
|
pills: canHaveMultipleSelections ? (comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.value).map(v => ({
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
670
|
+
isDisabled: comboboxState === null || comboboxState === void 0 ? void 0 : comboboxState.isDisabled,
|
|
671
|
+
children: [v, /*#__PURE__*/React.createElement(IconButton, {
|
|
672
|
+
key: `${id}-pill-${v}-icon-button`,
|
|
673
|
+
icon: mdiClose,
|
|
674
|
+
"aria-label": format('unselect', {
|
|
675
|
+
label: v
|
|
676
|
+
}),
|
|
677
|
+
onClick: event => {
|
|
678
|
+
event.preventDefault();
|
|
679
|
+
listboxState.dispatch({
|
|
680
|
+
type: ListboxActionType.TOGGLE,
|
|
681
|
+
payload: {
|
|
682
|
+
value: v,
|
|
683
|
+
activedescendant: focusContext.state.activedescendant
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
})]
|
|
654
688
|
})) : undefined,
|
|
655
689
|
internal: (value, isDisabled, isInvalid, isRequired) => {
|
|
656
690
|
return /*#__PURE__*/React.createElement(React.Fragment, null, typeof renderedChildren.props.internal === 'function' ? renderedChildren.props.internal(value, isDisabled, isInvalid, isRequired) : renderedChildren.props.internal, hideExpandButton ? null : /*#__PURE__*/React.createElement(IconButton, {
|
|
657
691
|
theme: theme,
|
|
658
|
-
"aria-label":
|
|
692
|
+
"aria-label": format(!isOpen ? 'expand' : 'collapse'),
|
|
659
693
|
color: "grey",
|
|
660
694
|
icon: mdiChevronDown,
|
|
661
695
|
onClick: handleOpen,
|
|
@@ -669,25 +703,18 @@ const ComboboxTrigger = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
669
703
|
}
|
|
670
704
|
}));
|
|
671
705
|
}
|
|
706
|
+
} : {
|
|
707
|
+
textareaProps: inputProps,
|
|
708
|
+
textareaRef: inputRef
|
|
672
709
|
}));
|
|
673
710
|
}
|
|
674
711
|
return /*#__PURE__*/React.createElement(React.Fragment, null, renderedChildren);
|
|
675
712
|
});
|
|
676
|
-
ComboboxTrigger.className = CLASSNAME$
|
|
677
|
-
ComboboxTrigger.
|
|
678
|
-
ComboboxTrigger.displayName = COMPONENT_NAME$7;
|
|
713
|
+
ComboboxTrigger.className = CLASSNAME$a;
|
|
714
|
+
ComboboxTrigger.displayName = COMPONENT_NAME$a;
|
|
679
715
|
|
|
680
|
-
const COMPONENT_NAME$
|
|
681
|
-
const CLASSNAME$
|
|
682
|
-
const DEFAULT_PROPS$6 = {
|
|
683
|
-
filter: {
|
|
684
|
-
type: 'startsWith',
|
|
685
|
-
caseSensitive: false
|
|
686
|
-
},
|
|
687
|
-
minWidth: 'trigger-width',
|
|
688
|
-
selectionMode: ComboboxSelectionMode.single,
|
|
689
|
-
variant: ComboboxVariant.options
|
|
690
|
-
};
|
|
716
|
+
const COMPONENT_NAME$9 = 'Combobox';
|
|
717
|
+
const CLASSNAME$9 = 'redsift-combobox';
|
|
691
718
|
|
|
692
719
|
/**
|
|
693
720
|
* The Combobox component.
|
|
@@ -697,17 +724,24 @@ const BaseCombobox = props => {
|
|
|
697
724
|
defaultValue,
|
|
698
725
|
description,
|
|
699
726
|
descriptionProps,
|
|
700
|
-
filter
|
|
727
|
+
filter = {
|
|
728
|
+
type: 'startsWith',
|
|
729
|
+
caseSensitive: false
|
|
730
|
+
},
|
|
731
|
+
formRef,
|
|
732
|
+
submitRef,
|
|
733
|
+
inputValue: propsInputValue,
|
|
701
734
|
isDisabled,
|
|
702
735
|
isInvalid,
|
|
703
736
|
maxOptionsLength,
|
|
737
|
+
minWidth = 'trigger-width',
|
|
704
738
|
onChange,
|
|
705
|
-
value,
|
|
706
739
|
onInputChange,
|
|
707
|
-
|
|
708
|
-
selectionMode,
|
|
740
|
+
selectionMode = ComboboxSelectionMode.single,
|
|
709
741
|
theme: propsTheme,
|
|
710
|
-
|
|
742
|
+
triggerClassName,
|
|
743
|
+
value,
|
|
744
|
+
variant = ComboboxVariant.options,
|
|
711
745
|
wrapperProps
|
|
712
746
|
} = props;
|
|
713
747
|
const theme = useTheme(propsTheme);
|
|
@@ -748,6 +782,8 @@ const BaseCombobox = props => {
|
|
|
748
782
|
/** Combobox context. */
|
|
749
783
|
const state = {
|
|
750
784
|
filter,
|
|
785
|
+
formRef,
|
|
786
|
+
submitRef,
|
|
751
787
|
value: selectedValue,
|
|
752
788
|
inputValue,
|
|
753
789
|
isDisabled: isDisabled || false,
|
|
@@ -756,6 +792,7 @@ const BaseCombobox = props => {
|
|
|
756
792
|
variant,
|
|
757
793
|
freeTextItemRef: freeTextItemRef,
|
|
758
794
|
freeTextItemId,
|
|
795
|
+
triggerClassName,
|
|
759
796
|
setValue(value) {
|
|
760
797
|
if (isDisabled) {
|
|
761
798
|
return;
|
|
@@ -800,7 +837,8 @@ const BaseCombobox = props => {
|
|
|
800
837
|
trigger: 'ComboboxTrigger'
|
|
801
838
|
},
|
|
802
839
|
placement: "bottom-start",
|
|
803
|
-
role: "listbox"
|
|
840
|
+
role: "listbox",
|
|
841
|
+
minWidth: minWidth
|
|
804
842
|
}, props)), description && typeof description === 'string' ? /*#__PURE__*/React.createElement(Text, _extends({
|
|
805
843
|
theme: theme,
|
|
806
844
|
marginTop: "8px",
|
|
@@ -808,22 +846,110 @@ const BaseCombobox = props => {
|
|
|
808
846
|
color: isInvalid ? 'error' : theme === Theme.light ? 'dark-grey' : 'white'
|
|
809
847
|
}, descriptionProps), description) : /*#__PURE__*/React.isValidElement(description) ? description : null)))));
|
|
810
848
|
};
|
|
811
|
-
BaseCombobox.className = CLASSNAME$
|
|
812
|
-
BaseCombobox.
|
|
813
|
-
BaseCombobox.displayName = COMPONENT_NAME$6;
|
|
849
|
+
BaseCombobox.className = CLASSNAME$9;
|
|
850
|
+
BaseCombobox.displayName = COMPONENT_NAME$9;
|
|
814
851
|
const Combobox = Object.assign(BaseCombobox, {
|
|
815
852
|
Trigger: ComboboxTrigger,
|
|
816
853
|
Content: ComboboxContent
|
|
817
854
|
});
|
|
818
855
|
|
|
856
|
+
/**
|
|
857
|
+
* Component style.
|
|
858
|
+
*/
|
|
859
|
+
const StyledMenuButtonContentFooter = styled.div`
|
|
860
|
+
${baseContainer}
|
|
861
|
+
`;
|
|
862
|
+
|
|
863
|
+
const _excluded$2 = ["children", "className"];
|
|
864
|
+
const COMPONENT_NAME$8 = 'MenuButtonContentFooter';
|
|
865
|
+
const CLASSNAME$8 = 'redsift-combobox-content-footer';
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* The MenuButtonContentFooter component.
|
|
869
|
+
*/
|
|
870
|
+
const MenuButtonContentFooter = /*#__PURE__*/forwardRef((props, ref) => {
|
|
871
|
+
const {
|
|
872
|
+
children,
|
|
873
|
+
className
|
|
874
|
+
} = props,
|
|
875
|
+
forwardedProps = _objectWithoutProperties(props, _excluded$2);
|
|
876
|
+
return /*#__PURE__*/React.createElement(StyledMenuButtonContentFooter, _extends({}, forwardedProps, {
|
|
877
|
+
className: classNames(MenuButtonContentFooter.className, className),
|
|
878
|
+
ref: ref
|
|
879
|
+
}), children);
|
|
880
|
+
});
|
|
881
|
+
MenuButtonContentFooter.className = CLASSNAME$8;
|
|
882
|
+
MenuButtonContentFooter.displayName = COMPONENT_NAME$8;
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* Component style.
|
|
886
|
+
*/
|
|
887
|
+
const StyledMenuButtonContentHeader = styled.div`
|
|
888
|
+
${baseContainer}
|
|
889
|
+
`;
|
|
890
|
+
|
|
891
|
+
const _excluded$1 = ["children", "className"];
|
|
892
|
+
const COMPONENT_NAME$7 = 'MenuButtonContentHeader';
|
|
893
|
+
const CLASSNAME$7 = 'redsift-combobox-content-header';
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* The MenuButtonContentHeader component.
|
|
897
|
+
*/
|
|
898
|
+
const MenuButtonContentHeader = /*#__PURE__*/forwardRef((props, ref) => {
|
|
899
|
+
const {
|
|
900
|
+
children,
|
|
901
|
+
className
|
|
902
|
+
} = props,
|
|
903
|
+
forwardedProps = _objectWithoutProperties(props, _excluded$1);
|
|
904
|
+
return /*#__PURE__*/React.createElement(StyledMenuButtonContentHeader, _extends({}, forwardedProps, {
|
|
905
|
+
className: classNames(MenuButtonContentHeader.className, className),
|
|
906
|
+
ref: ref
|
|
907
|
+
}), children);
|
|
908
|
+
});
|
|
909
|
+
MenuButtonContentHeader.className = CLASSNAME$7;
|
|
910
|
+
MenuButtonContentHeader.displayName = COMPONENT_NAME$7;
|
|
911
|
+
|
|
912
|
+
const _excluded = ["children", "className"];
|
|
913
|
+
const COMPONENT_NAME$6 = 'MenuButtonContentMenu';
|
|
914
|
+
const CLASSNAME$6 = 'redsift-menu-button-content-menu';
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* The MenuButtonContentMenu component.
|
|
918
|
+
*/
|
|
919
|
+
const MenuButtonContentMenu = /*#__PURE__*/forwardRef((props, ref) => {
|
|
920
|
+
const {
|
|
921
|
+
children,
|
|
922
|
+
className
|
|
923
|
+
} = props,
|
|
924
|
+
forwardedProps = _objectWithoutProperties(props, _excluded);
|
|
925
|
+
const focusContext = useContext(FocusWithinGroupContext);
|
|
926
|
+
useEffect(() => {
|
|
927
|
+
if (focusContext && focusContext.state.delayedAction && focusContext.state.tabStops.length) {
|
|
928
|
+
focusContext.dispatch(focusContext.state.delayedAction);
|
|
929
|
+
}
|
|
930
|
+
}, [focusContext.state.delayedAction, focusContext.state.tabStops.length]);
|
|
931
|
+
return /*#__PURE__*/React.createElement(Flexbox, _extends({
|
|
932
|
+
flexDirection: "column",
|
|
933
|
+
gap: "8px",
|
|
934
|
+
margin: "8px 0px",
|
|
935
|
+
width: "100%",
|
|
936
|
+
className: classNames(MenuButtonContentMenu.className, className),
|
|
937
|
+
role: "menu",
|
|
938
|
+
as: "ul"
|
|
939
|
+
}, forwardedProps, {
|
|
940
|
+
ref: ref
|
|
941
|
+
}), children);
|
|
942
|
+
});
|
|
943
|
+
MenuButtonContentMenu.className = CLASSNAME$6;
|
|
944
|
+
MenuButtonContentMenu.displayName = COMPONENT_NAME$6;
|
|
945
|
+
|
|
819
946
|
const COMPONENT_NAME$5 = 'MenuButtonContent';
|
|
820
947
|
const CLASSNAME$5 = 'redsift-menu-button-content';
|
|
821
|
-
const DEFAULT_PROPS$5 = {};
|
|
822
948
|
|
|
823
949
|
/**
|
|
824
950
|
* The MenuButtonContent component.
|
|
825
951
|
*/
|
|
826
|
-
const
|
|
952
|
+
const BaseMenuButtonContent = /*#__PURE__*/forwardRef((props, ref) => {
|
|
827
953
|
const {
|
|
828
954
|
children,
|
|
829
955
|
className,
|
|
@@ -836,44 +962,48 @@ const MenuButtonContent = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
836
962
|
refs,
|
|
837
963
|
strategy,
|
|
838
964
|
x,
|
|
839
|
-
y
|
|
965
|
+
y,
|
|
966
|
+
hideInsteadOfClose
|
|
840
967
|
} = usePopoverContext();
|
|
841
968
|
const popoverRef = useMergeRefs([refs.setFloating, ref]);
|
|
842
|
-
const
|
|
969
|
+
const appContainerState = useContext(AppContainerContext);
|
|
843
970
|
const theme = useTheme();
|
|
844
|
-
|
|
845
|
-
if (focusContext && focusContext.state.delayedAction && focusContext.state.tabStops.length) {
|
|
846
|
-
focusContext.dispatch(focusContext.state.delayedAction);
|
|
847
|
-
}
|
|
848
|
-
}, [focusContext.state.delayedAction, focusContext.state.tabStops.length]);
|
|
971
|
+
const [[header], [menu], [footer]] = partitionComponents(React.Children.toArray(children), [isComponent('MenuButtonContentHeader'), isComponent('MenuButtonContentMenu'), isComponent('MenuButtonContentFooter')]);
|
|
849
972
|
return /*#__PURE__*/React.createElement(FloatingPortal, {
|
|
850
|
-
|
|
851
|
-
}, isOpen
|
|
973
|
+
root: appContainerState === null || appContainerState === void 0 ? void 0 : appContainerState.appContainerRef.current
|
|
974
|
+
}, isOpen || hideInsteadOfClose ? /*#__PURE__*/React.createElement(StyledPopoverContent, _extends({
|
|
852
975
|
$theme: theme,
|
|
853
|
-
ref: popoverRef
|
|
976
|
+
ref: popoverRef
|
|
977
|
+
}, getFloatingProps(props), {
|
|
854
978
|
style: _objectSpread2({
|
|
855
979
|
position: strategy,
|
|
856
980
|
top: y !== null && y !== void 0 ? y : 0,
|
|
857
|
-
left: x !== null && x !== void 0 ? x : 0
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
className: classNames(PopoverContent.className,
|
|
861
|
-
}), /*#__PURE__*/React.createElement(Flexbox, _extends({
|
|
981
|
+
left: x !== null && x !== void 0 ? x : 0,
|
|
982
|
+
display: hideInsteadOfClose && !isOpen ? 'none' : 'flex'
|
|
983
|
+
}, style),
|
|
984
|
+
className: classNames(PopoverContent.className, BaseMenuButtonContent.className, className)
|
|
985
|
+
}), !header && !menu && !footer ? /*#__PURE__*/React.createElement(Flexbox, _extends({
|
|
862
986
|
flexDirection: "column",
|
|
863
|
-
gap: "
|
|
864
|
-
margin: "8px 0px",
|
|
987
|
+
gap: "0px",
|
|
865
988
|
width: "100%"
|
|
866
|
-
}, containerProps), children))
|
|
989
|
+
}, containerProps), /*#__PURE__*/React.createElement(MenuButtonContentMenu, null, children)) : /*#__PURE__*/React.createElement(Flexbox, _extends({
|
|
990
|
+
flexDirection: "column",
|
|
991
|
+
gap: "0px",
|
|
992
|
+
width: "100%"
|
|
993
|
+
}, containerProps), header, menu, footer)) : null);
|
|
994
|
+
});
|
|
995
|
+
BaseMenuButtonContent.className = CLASSNAME$5;
|
|
996
|
+
BaseMenuButtonContent.displayName = COMPONENT_NAME$5;
|
|
997
|
+
const MenuButtonContent = Object.assign(BaseMenuButtonContent, {
|
|
998
|
+
Header: MenuButtonContentHeader,
|
|
999
|
+
Menu: MenuButtonContentMenu,
|
|
1000
|
+
Footer: MenuButtonContentFooter
|
|
867
1001
|
});
|
|
868
|
-
MenuButtonContent.className = CLASSNAME$5;
|
|
869
|
-
MenuButtonContent.defaultProps = DEFAULT_PROPS$5;
|
|
870
|
-
MenuButtonContent.displayName = COMPONENT_NAME$5;
|
|
871
1002
|
|
|
872
1003
|
const MenuButtonContext = /*#__PURE__*/React.createContext(null);
|
|
873
1004
|
|
|
874
1005
|
const COMPONENT_NAME$4 = 'MenuButtonTrigger';
|
|
875
1006
|
const CLASSNAME$4 = 'redsift-menu-button-trigger';
|
|
876
|
-
const DEFAULT_PROPS$4 = {};
|
|
877
1007
|
|
|
878
1008
|
/**
|
|
879
1009
|
* The MenuButtonTrigger component.
|
|
@@ -977,8 +1107,9 @@ const MenuButtonTrigger = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
977
1107
|
event.preventDefault();
|
|
978
1108
|
} else if (code === 'Enter') {
|
|
979
1109
|
if (isOpen && focusContext.state.selectedId) {
|
|
980
|
-
var _document$getElementB;
|
|
1110
|
+
var _document$getElementB, _document$getElementB2, _document$getElementB3, _document$getElementB4;
|
|
981
1111
|
(_document$getElementB = document.getElementById(focusContext.state.selectedId)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.click();
|
|
1112
|
+
(_document$getElementB2 = document.getElementById(focusContext.state.selectedId)) === null || _document$getElementB2 === void 0 ? void 0 : (_document$getElementB3 = _document$getElementB2.getElementsByTagName('a')) === null || _document$getElementB3 === void 0 ? void 0 : (_document$getElementB4 = _document$getElementB3[0]) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.click();
|
|
982
1113
|
}
|
|
983
1114
|
}
|
|
984
1115
|
};
|
|
@@ -1022,14 +1153,10 @@ const MenuButtonTrigger = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1022
1153
|
return /*#__PURE__*/React.createElement(React.Fragment, null, renderedChildren);
|
|
1023
1154
|
});
|
|
1024
1155
|
MenuButtonTrigger.className = CLASSNAME$4;
|
|
1025
|
-
MenuButtonTrigger.defaultProps = DEFAULT_PROPS$4;
|
|
1026
1156
|
MenuButtonTrigger.displayName = COMPONENT_NAME$4;
|
|
1027
1157
|
|
|
1028
1158
|
const COMPONENT_NAME$3 = 'MenuButton';
|
|
1029
1159
|
const CLASSNAME$3 = 'redsift-menu-button';
|
|
1030
|
-
const DEFAULT_PROPS$3 = {
|
|
1031
|
-
minWidth: 'trigger-width'
|
|
1032
|
-
};
|
|
1033
1160
|
|
|
1034
1161
|
/**
|
|
1035
1162
|
* The MenuButton component.
|
|
@@ -1037,25 +1164,26 @@ const DEFAULT_PROPS$3 = {
|
|
|
1037
1164
|
const BaseMenuButton = props => {
|
|
1038
1165
|
const {
|
|
1039
1166
|
color,
|
|
1167
|
+
description,
|
|
1168
|
+
descriptionProps,
|
|
1040
1169
|
isDisabled,
|
|
1041
1170
|
label,
|
|
1042
1171
|
labelProps,
|
|
1043
|
-
|
|
1044
|
-
descriptionProps,
|
|
1045
|
-
variant,
|
|
1046
|
-
triggerClassName,
|
|
1172
|
+
minWidth = 'trigger-width',
|
|
1047
1173
|
theme: propsTheme,
|
|
1174
|
+
triggerClassName,
|
|
1175
|
+
variant,
|
|
1048
1176
|
wrapperProps
|
|
1049
1177
|
} = props;
|
|
1050
1178
|
const theme = useTheme(propsTheme);
|
|
1051
1179
|
|
|
1052
1180
|
/** MenuButton context. */
|
|
1053
1181
|
const state = {
|
|
1054
|
-
theme,
|
|
1055
|
-
isDisabled: isDisabled || false,
|
|
1056
1182
|
color,
|
|
1057
|
-
|
|
1058
|
-
|
|
1183
|
+
isDisabled: isDisabled || false,
|
|
1184
|
+
theme,
|
|
1185
|
+
triggerClassName,
|
|
1186
|
+
variant
|
|
1059
1187
|
};
|
|
1060
1188
|
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
1061
1189
|
value: {
|
|
@@ -1078,7 +1206,7 @@ const BaseMenuButton = props => {
|
|
|
1078
1206
|
trigger: 'MenuButtonTrigger'
|
|
1079
1207
|
},
|
|
1080
1208
|
placement: "bottom-end",
|
|
1081
|
-
|
|
1209
|
+
minWidth: minWidth
|
|
1082
1210
|
}, props)), description && typeof description === 'string' ? /*#__PURE__*/React.createElement(Text, _extends({
|
|
1083
1211
|
theme: theme,
|
|
1084
1212
|
marginTop: "8px",
|
|
@@ -1087,7 +1215,6 @@ const BaseMenuButton = props => {
|
|
|
1087
1215
|
}, descriptionProps), description) : description ? description : null))));
|
|
1088
1216
|
};
|
|
1089
1217
|
BaseMenuButton.className = CLASSNAME$3;
|
|
1090
|
-
BaseMenuButton.defaultProps = DEFAULT_PROPS$3;
|
|
1091
1218
|
BaseMenuButton.displayName = COMPONENT_NAME$3;
|
|
1092
1219
|
const MenuButton = Object.assign(BaseMenuButton, {
|
|
1093
1220
|
Trigger: MenuButtonTrigger,
|
|
@@ -1096,7 +1223,6 @@ const MenuButton = Object.assign(BaseMenuButton, {
|
|
|
1096
1223
|
|
|
1097
1224
|
const COMPONENT_NAME$2 = 'SelectContent';
|
|
1098
1225
|
const CLASSNAME$2 = 'redsift-select-content';
|
|
1099
|
-
const DEFAULT_PROPS$2 = {};
|
|
1100
1226
|
|
|
1101
1227
|
/**
|
|
1102
1228
|
* The SelectContent component.
|
|
@@ -1117,6 +1243,7 @@ const SelectContent = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1117
1243
|
y
|
|
1118
1244
|
} = usePopoverContext();
|
|
1119
1245
|
const popoverRef = useMergeRefs([refs.setFloating, ref]);
|
|
1246
|
+
const appContainerState = useContext(AppContainerContext);
|
|
1120
1247
|
const focusContext = useContext(FocusWithinGroupContext);
|
|
1121
1248
|
const listboxState = useContext(ListboxContext);
|
|
1122
1249
|
const theme = useTheme();
|
|
@@ -1126,19 +1253,18 @@ const SelectContent = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1126
1253
|
}
|
|
1127
1254
|
}, [focusContext.state.delayedAction, focusContext.state.tabStops.length]);
|
|
1128
1255
|
return /*#__PURE__*/React.createElement(FloatingPortal, {
|
|
1129
|
-
|
|
1256
|
+
root: appContainerState === null || appContainerState === void 0 ? void 0 : appContainerState.appContainerRef.current
|
|
1130
1257
|
}, isOpen && /*#__PURE__*/React.createElement(StyledPopoverContent, _extends({
|
|
1131
1258
|
$theme: theme,
|
|
1132
|
-
ref: popoverRef
|
|
1259
|
+
ref: popoverRef
|
|
1260
|
+
}, getFloatingProps(props), {
|
|
1133
1261
|
style: _objectSpread2({
|
|
1134
1262
|
position: strategy,
|
|
1135
1263
|
top: y !== null && y !== void 0 ? y : 0,
|
|
1136
1264
|
left: x !== null && x !== void 0 ? x : 0
|
|
1137
|
-
}, style)
|
|
1138
|
-
}, getFloatingProps(props), {
|
|
1265
|
+
}, style),
|
|
1139
1266
|
className: classNames(PopoverContent.className, SelectContent.className, className),
|
|
1140
|
-
"aria-disabled": listboxState.state.isDisabled
|
|
1141
|
-
"aria-multiselectable": listboxState.state.selectionMode === 'multiple'
|
|
1267
|
+
"aria-disabled": listboxState.state.isDisabled
|
|
1142
1268
|
}), /*#__PURE__*/React.createElement(Flexbox, _extends({
|
|
1143
1269
|
flexDirection: "column",
|
|
1144
1270
|
gap: "0px",
|
|
@@ -1147,14 +1273,12 @@ const SelectContent = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1147
1273
|
}, containerProps), children)));
|
|
1148
1274
|
});
|
|
1149
1275
|
SelectContent.className = CLASSNAME$2;
|
|
1150
|
-
SelectContent.defaultProps = DEFAULT_PROPS$2;
|
|
1151
1276
|
SelectContent.displayName = COMPONENT_NAME$2;
|
|
1152
1277
|
|
|
1153
1278
|
const SelectContext = /*#__PURE__*/React.createContext(null);
|
|
1154
1279
|
|
|
1155
1280
|
const COMPONENT_NAME$1 = 'SelectTrigger';
|
|
1156
1281
|
const CLASSNAME$1 = 'redsift-select-trigger';
|
|
1157
|
-
const DEFAULT_PROPS$1 = {};
|
|
1158
1282
|
|
|
1159
1283
|
/**
|
|
1160
1284
|
* The SelectTrigger component.
|
|
@@ -1310,36 +1434,16 @@ const SelectTrigger = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1310
1434
|
handleOpen(false);
|
|
1311
1435
|
}, [listboxState.state]);
|
|
1312
1436
|
if (isComponent('TextField')(renderedChildren)) {
|
|
1313
|
-
var _props$children, _focusContext$state$a8, _props$inputProps;
|
|
1437
|
+
var _props$children, _focusContext$state$a8, _selectContext$color, _selectContext$varian, _props$inputProps;
|
|
1314
1438
|
return /*#__PURE__*/React.cloneElement(renderedChildren, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, getReferenceProps(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
1315
1439
|
ref: triggerRef
|
|
1316
1440
|
}, props), renderedChildren.props), {}, {
|
|
1317
1441
|
children: (_props$children = renderedChildren.props.children) !== null && _props$children !== void 0 ? _props$children : ''
|
|
1318
1442
|
}))), {}, {
|
|
1319
|
-
theme,
|
|
1320
|
-
inputRef,
|
|
1321
|
-
role: 'combobox',
|
|
1322
1443
|
'aria-activedescendant': isOpen ? (_focusContext$state$a8 = focusContext.state.activedescendant) === null || _focusContext$state$a8 === void 0 ? void 0 : _focusContext$state$a8[0] : undefined,
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
}), {}, {
|
|
1327
|
-
onKeyDown: handleKeyDown,
|
|
1328
|
-
onClick: handleClick,
|
|
1329
|
-
isReadOnly: true,
|
|
1330
|
-
isActive: isOpen
|
|
1331
|
-
}, typeof children !== 'function' && (selectContext === null || selectContext === void 0 ? void 0 : selectContext.value) && {
|
|
1332
|
-
value: selectContext.value
|
|
1333
|
-
}), {}, {
|
|
1334
|
-
style: _objectSpread2(_objectSpread2({}, renderedChildren.props.style), {}, {
|
|
1335
|
-
caretColor: 'transparent',
|
|
1336
|
-
cursor: 'pointer'
|
|
1337
|
-
}),
|
|
1338
|
-
inputProps: _objectSpread2(_objectSpread2({}, renderedChildren.props.inputProps), {}, {
|
|
1339
|
-
style: _objectSpread2(_objectSpread2({}, (_props$inputProps = renderedChildren.props.inputProps) === null || _props$inputProps === void 0 ? void 0 : _props$inputProps.style), {}, {
|
|
1340
|
-
cursor: 'pointer'
|
|
1341
|
-
})
|
|
1342
|
-
}),
|
|
1444
|
+
className: classNames(renderedChildren.props.className, selectContext === null || selectContext === void 0 ? void 0 : selectContext.triggerClassName),
|
|
1445
|
+
color: (_selectContext$color = selectContext === null || selectContext === void 0 ? void 0 : selectContext.color) !== null && _selectContext$color !== void 0 ? _selectContext$color : renderedChildren.props.color,
|
|
1446
|
+
inputRef,
|
|
1343
1447
|
internal: (value, isDisabled, isInvalid, isRequired) => {
|
|
1344
1448
|
return /*#__PURE__*/React.createElement(React.Fragment, null, typeof renderedChildren.props.internal === 'function' ? renderedChildren.props.internal(value, isDisabled, isInvalid, isRequired) : renderedChildren.props.internal, hideExpandButton ? null : /*#__PURE__*/React.createElement(Icon, {
|
|
1345
1449
|
color: isDisabled ? 'no-data' : 'question',
|
|
@@ -1350,62 +1454,88 @@ const SelectTrigger = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1350
1454
|
cursor: 'pointer'
|
|
1351
1455
|
}
|
|
1352
1456
|
}));
|
|
1353
|
-
}
|
|
1457
|
+
},
|
|
1458
|
+
isActive: isOpen,
|
|
1459
|
+
isDisabled: selectContext === null || selectContext === void 0 ? void 0 : selectContext.isDisabled,
|
|
1460
|
+
isReadOnly: true,
|
|
1461
|
+
theme,
|
|
1462
|
+
role: 'combobox',
|
|
1463
|
+
onClick: handleClick,
|
|
1464
|
+
onKeyDown: handleKeyDown,
|
|
1465
|
+
style: _objectSpread2(_objectSpread2({}, renderedChildren.props.style), {}, {
|
|
1466
|
+
caretColor: 'transparent',
|
|
1467
|
+
cursor: 'pointer'
|
|
1468
|
+
}),
|
|
1469
|
+
variant: (_selectContext$varian = selectContext === null || selectContext === void 0 ? void 0 : selectContext.variant) !== null && _selectContext$varian !== void 0 ? _selectContext$varian : renderedChildren.props.variant
|
|
1470
|
+
}, (selectContext === null || selectContext === void 0 ? void 0 : selectContext.isInvalid) === true && {
|
|
1471
|
+
color: 'error'
|
|
1472
|
+
}), typeof children !== 'function' && (selectContext === null || selectContext === void 0 ? void 0 : selectContext.value) && {
|
|
1473
|
+
value: selectContext.value
|
|
1474
|
+
}), {}, {
|
|
1475
|
+
inputProps: _objectSpread2(_objectSpread2({}, renderedChildren.props.inputProps), {}, {
|
|
1476
|
+
style: _objectSpread2(_objectSpread2({}, (_props$inputProps = renderedChildren.props.inputProps) === null || _props$inputProps === void 0 ? void 0 : _props$inputProps.style), {}, {
|
|
1477
|
+
cursor: 'pointer'
|
|
1478
|
+
})
|
|
1479
|
+
})
|
|
1354
1480
|
}));
|
|
1355
1481
|
} else if (isComponent('Button')(renderedChildren)) {
|
|
1356
|
-
var _props$children2, _focusContext$state$a9, _props$rightIcon, _props$rightIconProps;
|
|
1357
|
-
|
|
1482
|
+
var _props$children2, _focusContext$state$a9, _props$ariaLabel, _selectContext$color2, _props$rightIcon, _props$rightIconProps, _selectContext$varian2;
|
|
1483
|
+
const children = renderedChildren.props.children;
|
|
1484
|
+
const label = typeof children === 'string' ? children : children === null || children === void 0 ? void 0 : children.textContent;
|
|
1485
|
+
return /*#__PURE__*/React.cloneElement(renderedChildren, _objectSpread2(_objectSpread2(_objectSpread2({}, getReferenceProps(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
1358
1486
|
ref: triggerRef
|
|
1359
1487
|
}, props), renderedChildren.props), {}, {
|
|
1360
1488
|
children: (_props$children2 = renderedChildren.props.children) !== null && _props$children2 !== void 0 ? _props$children2 : ''
|
|
1361
1489
|
}))), {}, {
|
|
1362
|
-
theme,
|
|
1363
|
-
role: 'combobox',
|
|
1364
1490
|
'aria-activedescendant': isOpen ? (_focusContext$state$a9 = focusContext.state.activedescendant) === null || _focusContext$state$a9 === void 0 ? void 0 : _focusContext$state$a9[0] : undefined,
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
color:
|
|
1368
|
-
|
|
1369
|
-
|
|
1491
|
+
'aria-label': (_props$ariaLabel = renderedChildren.props['aria-label']) !== null && _props$ariaLabel !== void 0 ? _props$ariaLabel : label,
|
|
1492
|
+
className: classNames(renderedChildren.props.className, selectContext === null || selectContext === void 0 ? void 0 : selectContext.triggerClassName),
|
|
1493
|
+
color: (_selectContext$color2 = selectContext === null || selectContext === void 0 ? void 0 : selectContext.color) !== null && _selectContext$color2 !== void 0 ? _selectContext$color2 : renderedChildren.props.color,
|
|
1494
|
+
isActive: isOpen,
|
|
1495
|
+
isDisabled: selectContext === null || selectContext === void 0 ? void 0 : selectContext.isDisabled,
|
|
1370
1496
|
onClick: handleClick,
|
|
1371
|
-
|
|
1372
|
-
}, typeof children !== 'function' && (selectContext === null || selectContext === void 0 ? void 0 : selectContext.value) && {
|
|
1373
|
-
children: selectContext.value
|
|
1374
|
-
}), {}, {
|
|
1497
|
+
onKeyDown: handleKeyDown,
|
|
1375
1498
|
rightIcon: (_props$rightIcon = renderedChildren.props.rightIcon) !== null && _props$rightIcon !== void 0 ? _props$rightIcon : mdiChevronDown,
|
|
1376
1499
|
rightIconProps: renderedChildren.props.rightIcon ? renderedChildren.props.rightIconProps : (_props$rightIconProps = renderedChildren.props.rightIconProps) !== null && _props$rightIconProps !== void 0 ? _props$rightIconProps : {
|
|
1377
1500
|
style: {
|
|
1378
1501
|
transition: 'transform 300ms ease-out',
|
|
1379
1502
|
transform: `rotate(${isOpen ? '-180deg' : '0'})`
|
|
1380
1503
|
}
|
|
1381
|
-
}
|
|
1504
|
+
},
|
|
1505
|
+
role: 'combobox',
|
|
1506
|
+
theme,
|
|
1507
|
+
variant: (_selectContext$varian2 = selectContext === null || selectContext === void 0 ? void 0 : selectContext.variant) !== null && _selectContext$varian2 !== void 0 ? _selectContext$varian2 : renderedChildren.props.variant
|
|
1508
|
+
}, (selectContext === null || selectContext === void 0 ? void 0 : selectContext.isInvalid) === true && {
|
|
1509
|
+
color: 'error'
|
|
1510
|
+
}), typeof children !== 'function' && (selectContext === null || selectContext === void 0 ? void 0 : selectContext.value) && {
|
|
1511
|
+
children: selectContext.value
|
|
1382
1512
|
}));
|
|
1383
1513
|
}
|
|
1384
1514
|
return /*#__PURE__*/React.createElement(React.Fragment, null, renderedChildren);
|
|
1385
1515
|
});
|
|
1386
1516
|
SelectTrigger.className = CLASSNAME$1;
|
|
1387
|
-
SelectTrigger.defaultProps = DEFAULT_PROPS$1;
|
|
1388
1517
|
SelectTrigger.displayName = COMPONENT_NAME$1;
|
|
1389
1518
|
|
|
1390
1519
|
const COMPONENT_NAME = 'Select';
|
|
1391
1520
|
const CLASSNAME = 'redsift-select';
|
|
1392
|
-
const DEFAULT_PROPS = {
|
|
1393
|
-
minWidth: 'trigger-width'
|
|
1394
|
-
};
|
|
1395
1521
|
|
|
1396
1522
|
/**
|
|
1397
1523
|
* The Select component.
|
|
1398
1524
|
*/
|
|
1399
1525
|
const BaseSelect = props => {
|
|
1400
1526
|
const {
|
|
1527
|
+
color,
|
|
1401
1528
|
defaultValue,
|
|
1402
|
-
isDisabled,
|
|
1403
|
-
onChange,
|
|
1404
|
-
value,
|
|
1405
1529
|
description,
|
|
1406
1530
|
descriptionProps,
|
|
1531
|
+
isDisabled,
|
|
1407
1532
|
isInvalid,
|
|
1533
|
+
minWidth = 'trigger-width',
|
|
1534
|
+
onChange,
|
|
1408
1535
|
theme: propsTheme,
|
|
1536
|
+
triggerClassName,
|
|
1537
|
+
value,
|
|
1538
|
+
variant,
|
|
1409
1539
|
wrapperProps
|
|
1410
1540
|
} = props;
|
|
1411
1541
|
const theme = useTheme(propsTheme);
|
|
@@ -1436,8 +1566,7 @@ const BaseSelect = props => {
|
|
|
1436
1566
|
|
|
1437
1567
|
/** Select context. */
|
|
1438
1568
|
const state = {
|
|
1439
|
-
|
|
1440
|
-
value: selectedValue,
|
|
1569
|
+
color,
|
|
1441
1570
|
isDisabled: isDisabled || false,
|
|
1442
1571
|
isInvalid: isInvalid || false,
|
|
1443
1572
|
setValue(value) {
|
|
@@ -1449,7 +1578,11 @@ const BaseSelect = props => {
|
|
|
1449
1578
|
if (value !== previousValue && onChange) {
|
|
1450
1579
|
onChange(value);
|
|
1451
1580
|
}
|
|
1452
|
-
}
|
|
1581
|
+
},
|
|
1582
|
+
theme,
|
|
1583
|
+
triggerClassName,
|
|
1584
|
+
value: selectedValue,
|
|
1585
|
+
variant
|
|
1453
1586
|
};
|
|
1454
1587
|
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
1455
1588
|
value: {
|
|
@@ -1473,7 +1606,8 @@ const BaseSelect = props => {
|
|
|
1473
1606
|
trigger: 'SelectTrigger'
|
|
1474
1607
|
},
|
|
1475
1608
|
placement: "bottom-start",
|
|
1476
|
-
role: "listbox"
|
|
1609
|
+
role: "listbox",
|
|
1610
|
+
minWidth: minWidth
|
|
1477
1611
|
}, props)), description && typeof description === 'string' ? /*#__PURE__*/React.createElement(Text, _extends({
|
|
1478
1612
|
theme: theme,
|
|
1479
1613
|
marginTop: "8px",
|
|
@@ -1482,12 +1616,11 @@ const BaseSelect = props => {
|
|
|
1482
1616
|
}, descriptionProps), description) : description ? description : null)))));
|
|
1483
1617
|
};
|
|
1484
1618
|
BaseSelect.className = CLASSNAME;
|
|
1485
|
-
BaseSelect.defaultProps = DEFAULT_PROPS;
|
|
1486
1619
|
BaseSelect.displayName = COMPONENT_NAME;
|
|
1487
1620
|
const Select = Object.assign(BaseSelect, {
|
|
1488
1621
|
Trigger: SelectTrigger,
|
|
1489
1622
|
Content: SelectContent
|
|
1490
1623
|
});
|
|
1491
1624
|
|
|
1492
|
-
export { BaseCombobox, BaseComboboxContent, BaseMenuButton, BaseSelect, Combobox, ComboboxContent, ComboboxContentFooter, ComboboxContentHeader, ComboboxContentListbox, ComboboxSelectionMode, ComboboxTrigger, ComboboxVariant, MenuButton, MenuButtonContent, MenuButtonTrigger, Select, SelectContent, SelectTrigger };
|
|
1625
|
+
export { BaseCombobox, BaseComboboxContent, BaseMenuButton, BaseMenuButtonContent, BaseSelect, Combobox, ComboboxContent, ComboboxContentFooter, ComboboxContentHeader, ComboboxContentListbox, ComboboxSelectionMode, ComboboxTrigger, ComboboxVariant, MenuButton, MenuButtonContent, MenuButtonContentFooter, MenuButtonContentHeader, MenuButtonContentMenu, MenuButtonTrigger, Select, SelectContent, SelectTrigger };
|
|
1493
1626
|
//# sourceMappingURL=index.js.map
|