@wavv/ui 2.2.2-alpha.5 → 2.2.2-alpha.7
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/build/assets/icons/CaretDown.js +18 -0
- package/build/assets/icons/CaretUp.js +18 -0
- package/build/assets/icons/Checkbox.js +15 -0
- package/build/assets/icons/CheckboxOff.js +15 -0
- package/build/assets/icons/CheckboxPartial.js +15 -0
- package/build/assets/icons/Dialpad.js +18 -0
- package/build/assets/icons/Exclamation.js +25 -0
- package/build/assets/icons/Phone.js +13 -0
- package/build/assets/icons/PhoneAdd.js +21 -0
- package/build/assets/icons/PhoneBlocked.js +22 -0
- package/build/assets/icons/PhoneCallback.js +21 -0
- package/build/assets/icons/PhoneEnd.js +28 -0
- package/build/assets/icons/PhoneForward.js +22 -0
- package/build/assets/icons/PhoneHistory.js +21 -0
- package/build/assets/icons/PhoneHold.js +22 -0
- package/build/assets/icons/PhoneIncoming.js +22 -0
- package/build/assets/icons/PhoneMissed.js +22 -0
- package/build/assets/icons/PhoneTalk.js +22 -0
- package/build/assets/icons/PhoneTransfer.js +21 -0
- package/build/assets/icons/RadioButton.js +22 -0
- package/build/assets/icons/RadioButtonOff.js +15 -0
- package/build/assets/icons/Record.js +18 -0
- package/build/assets/icons/Screenshot.js +39 -0
- package/build/assets/icons/ShieldWavv.js +30 -0
- package/build/assets/icons/Spotify.js +15 -0
- package/build/assets/icons/SubArrow.js +16 -0
- package/build/assets/icons/ToggleOff.js +15 -0
- package/build/assets/icons/ToggleOn.js +15 -0
- package/build/assets/icons/TransferCancel.js +60 -0
- package/build/components/Accordion/Accordion.js +26 -0
- package/build/components/Accordion/Header.js +86 -0
- package/build/components/Accordion/Item.js +25 -0
- package/build/components/Accordion/Panel.js +64 -0
- package/build/components/Accordion/index.js +2 -0
- package/build/components/Audio.js +248 -0
- package/build/components/BarChart.js +123 -0
- package/build/components/Button/Button.js +258 -0
- package/build/components/Button/ButtonLoader.js +20 -0
- package/build/components/Button/ButtonTypes.js +0 -0
- package/build/components/Button/Group.js +58 -0
- package/build/components/Button/index.js +2 -0
- package/build/components/Calendar.js +49 -0
- package/build/components/CalendarParts/CalendarContainerStyles.js +15 -0
- package/build/components/CalendarParts/CalendarContent.js +138 -0
- package/build/components/CalendarParts/CalendarHeader.js +146 -0
- package/build/components/CalendarParts/useMinMax.js +23 -0
- package/build/components/CalendarParts/utils.js +6 -0
- package/build/components/ChartHelpers.js +121 -0
- package/build/components/Checkbox.js +85 -0
- package/build/components/Code/Code.js +117 -0
- package/build/components/Code/Copy.js +50 -0
- package/build/components/Code/Endpoint.js +82 -0
- package/build/components/Code/index.js +3 -0
- package/build/components/ComboBox.js +190 -0
- package/build/components/CommandMenu/CommandItem.js +32 -0
- package/build/components/CommandMenu/CommandMenu.js +136 -0
- package/build/components/CommandMenu/CommandOptions.js +24 -0
- package/build/components/CommandMenu/CommandSection.js +19 -0
- package/build/components/CommandMenu/index.js +2 -0
- package/build/components/DateRangeSelect.js +359 -0
- package/build/components/DocTable.js +32 -0
- package/build/components/Dot.js +60 -0
- package/build/components/DraftEditor.js +188 -0
- package/build/components/Dropdown.js +130 -0
- package/build/components/DropdownMenu.js +131 -0
- package/build/components/DropdownMenuParts/Menu.js +6 -0
- package/build/components/DropdownMenuParts/MenuItem.js +54 -0
- package/build/components/DropdownMenuParts/MenuOptions.js +47 -0
- package/build/components/DropdownMenuParts/MenuSection.js +14 -0
- package/build/components/DropdownSelect.js +171 -0
- package/build/components/DynamicIcon.js +49 -0
- package/build/components/Editor/Editor.js +356 -0
- package/build/components/Editor/EditorStyles.js +259 -0
- package/build/components/Editor/MergeFieldExtension.js +110 -0
- package/build/components/Editor/RichTextToolbar.js +515 -0
- package/build/components/Editor/editorUtils.js +213 -0
- package/build/components/Editor/index.js +3 -0
- package/build/components/Ellipsis.js +22 -0
- package/build/components/Focusable.js +20 -0
- package/build/components/Form.js +68 -0
- package/build/components/FormControl.js +72 -0
- package/build/components/Grid.js +53 -0
- package/build/components/Icon/Icon.js +89 -0
- package/build/components/Icon/customIcons.js +48 -0
- package/build/components/Icon/icons.js +145 -0
- package/build/components/Icon/index.js +3 -0
- package/build/components/ImageViewer.js +142 -0
- package/build/components/InlineCode.js +10 -0
- package/build/components/InputHelpers.js +106 -0
- package/build/components/Inputs/DatePicker.js +111 -0
- package/build/components/Inputs/DateRangePicker.js +166 -0
- package/build/components/Inputs/InlineInput.js +71 -0
- package/build/components/Inputs/NumberInput.js +117 -0
- package/build/components/Inputs/PhoneInput.js +96 -0
- package/build/components/Inputs/SearchInput.js +84 -0
- package/build/components/Inputs/TextArea.js +164 -0
- package/build/components/Inputs/TextInput.js +74 -0
- package/build/components/Inputs/TimeInput.js +74 -0
- package/build/components/Inputs/helpers/AriaButton.js +19 -0
- package/build/components/Inputs/helpers/DateSegment.js +22 -0
- package/build/components/Inputs/helpers/Description.js +11 -0
- package/build/components/Inputs/helpers/ErrorMessage.js +11 -0
- package/build/components/Inputs/helpers/Input.js +6 -0
- package/build/components/Inputs/helpers/InputContainerStyles.js +78 -0
- package/build/components/Inputs/helpers/InputMessage.js +30 -0
- package/build/components/Inputs/helpers/InputStyles.js +43 -0
- package/build/components/Inputs/helpers/Label.js +42 -0
- package/build/components/Inputs/helpers/LabelWrapper.js +14 -0
- package/build/components/Inputs/helpers/PickerToggle.js +7 -0
- package/build/components/Inputs/helpers/TextArea.js +8 -0
- package/build/components/Inputs/helpers/filterPastedText.js +9 -0
- package/build/components/Inputs/helpers/handlePaste.js +12 -0
- package/build/components/Inputs/helpers/isAcceptable.js +7 -0
- package/build/components/Inputs/helpers/useDynamicWidth.js +39 -0
- package/build/components/Inputs/helpers/useInputFocus.js +19 -0
- package/build/components/Label.js +42 -0
- package/build/components/LineChart.js +80 -0
- package/build/components/ListBoxParts/GridListItem.js +34 -0
- package/build/components/ListBoxParts/ListBoxItem.js +32 -0
- package/build/components/ListBoxParts/ListOptions.js +45 -0
- package/build/components/ListHelpers/GridListHeader.js +14 -0
- package/build/components/ListHelpers/GridListSection.js +14 -0
- package/build/components/ListHelpers/ItemHeaderBody.js +36 -0
- package/build/components/ListHelpers/ListHeader.js +14 -0
- package/build/components/ListHelpers/ListItemStyles.js +52 -0
- package/build/components/ListHelpers/ListRootStyles.js +14 -0
- package/build/components/ListHelpers/ListSection.js +14 -0
- package/build/components/ListHelpers/ListStyles.js +29 -0
- package/build/components/Menu.js +159 -0
- package/build/components/Message.js +107 -0
- package/build/components/MessageHr.js +32 -0
- package/build/components/Modal.js +212 -0
- package/build/components/MotionPopover.js +39 -0
- package/build/components/MultiSelect/MultiSelect.js +263 -0
- package/build/components/MultiSelect/SearchDropdown.js +155 -0
- package/build/components/MultiSelect/index.js +2 -0
- package/build/components/OptionHelpers/Container.js +34 -0
- package/build/components/OptionHelpers/Item.js +59 -0
- package/build/components/OptionHelpers/types.js +0 -0
- package/build/components/Pagination.js +121 -0
- package/build/components/PieChart.js +40 -0
- package/build/components/Popover.js +40 -0
- package/build/components/PortalScope.js +8 -0
- package/build/components/Progress/CirclePercent.js +56 -0
- package/build/components/Progress/Progress.js +59 -0
- package/build/components/Progress/index.js +3 -0
- package/build/components/Radio.js +45 -0
- package/build/components/RangeCalendar.js +60 -0
- package/build/components/Select.js +162 -0
- package/build/components/Slider.js +50 -0
- package/build/components/Spinner.js +70 -0
- package/build/components/Table/Body.js +49 -0
- package/build/components/Table/Cell.js +63 -0
- package/build/components/Table/Check.js +35 -0
- package/build/components/Table/Column.js +129 -0
- package/build/components/Table/ColumnSort.js +26 -0
- package/build/components/Table/Header.js +64 -0
- package/build/components/Table/Resizer.js +25 -0
- package/build/components/Table/Row.js +84 -0
- package/build/components/Table/SortCaret.js +24 -0
- package/build/components/Table/Table.js +88 -0
- package/build/components/Table/contentStyles.js +20 -0
- package/build/components/Table/context.js +4 -0
- package/build/components/Table/index.js +2 -0
- package/build/components/Table/types.js +0 -0
- package/build/components/Tabs.js +151 -0
- package/build/components/Tag.js +71 -0
- package/build/components/Toggle.js +59 -0
- package/build/components/ToggleButton/ToggleButton.js +104 -0
- package/build/components/ToggleButton/ToggleButtonGroup.js +36 -0
- package/build/components/ToggleButton/context.js +8 -0
- package/build/components/ToggleButton/index.js +3 -0
- package/build/components/Tooltip.js +136 -0
- package/build/components/TransferList.js +234 -0
- package/build/components/Tree/Tree.js +69 -0
- package/build/components/Tree/TreeContext.js +3 -0
- package/build/components/Tree/TreeItem.js +93 -0
- package/build/components/Tree/index.js +2 -0
- package/build/components/UnstyledButton.js +8 -0
- package/build/components/Waveform.js +243 -0
- package/build/components/draftUtils.js +193 -0
- package/build/components/helpers/getIcon.js +28 -0
- package/build/components/helpers/getPopPosition.js +20 -0
- package/build/components/helpers/isPropAllowed.js +3 -0
- package/build/components/helpers/mergePadding.js +47 -0
- package/build/components/helpers/styledProps.js +34 -0
- package/build/components/typeDefs/elementTypes.js +0 -0
- package/build/components/typeDefs/inputTypes.js +0 -0
- package/build/components/typeDefs/selectionTypes.js +0 -0
- package/build/components/typeDefs/tagTypes.js +0 -0
- package/build/components/types.js +0 -0
- package/build/global-styles/GlobalStorybookStyles.js +108 -0
- package/build/global-styles/ResetStyles.js +33 -0
- package/build/global-styles/ScrollbarStyles.js +26 -0
- package/build/global-styles/ToastStyles.js +66 -0
- package/build/global-styles/index.js +4 -0
- package/build/hooks/index.js +9 -0
- package/build/hooks/useConfirm.js +91 -0
- package/build/hooks/useControlledOpenState.js +22 -0
- package/build/hooks/useCopy.js +28 -0
- package/build/hooks/useElementObserver.js +6 -0
- package/build/hooks/useEventListener.js +19 -0
- package/build/hooks/useOnClickOutside.js +21 -0
- package/build/hooks/usePrevious.js +12 -0
- package/build/hooks/useSelectAll.js +60 -0
- package/build/hooks/useWindowSize.js +25 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +2 -1
- package/build/theme/ThemeTypes.js +0 -0
- package/build/theme/common/button.js +33 -0
- package/build/theme/common/common.js +38 -0
- package/build/theme/common/index.js +4 -0
- package/build/theme/core/colors.js +77 -0
- package/build/theme/core/dark/dark.js +457 -0
- package/build/theme/core/dark/darkScale.js +36 -0
- package/build/theme/core/light/light.js +456 -0
- package/build/theme/core/light/lightScale.js +35 -0
- package/build/theme/eighties/colors.js +78 -0
- package/build/theme/eighties/dark/dark.js +457 -0
- package/build/theme/eighties/dark/darkScale.js +36 -0
- package/build/theme/eighties/light/light.js +456 -0
- package/build/theme/eighties/light/lightScale.js +35 -0
- package/build/theme/index.js +28 -0
- package/build/utils/chunk.js +13 -0
- package/build/utils/copyToClipboard.js +29 -0
- package/build/utils/flattenListOptions.js +4 -0
- package/build/utils/formatDate.js +55 -0
- package/build/utils/formatNumber.d.ts +8 -0
- package/build/utils/formatNumber.js +32 -0
- package/build/utils/index.js +6 -0
- package/build/utils/numberWithCommas.js +3 -0
- package/build/utils/range.js +11 -0
- package/package.json +14 -15
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { ComboBox, FieldError, ListBoxItem } from "react-aria-components";
|
|
5
|
+
import { useControlledOpenState } from "../hooks/index.js";
|
|
6
|
+
import flattenListOptions from "../utils/flattenListOptions.js";
|
|
7
|
+
import getIcon from "./helpers/getIcon.js";
|
|
8
|
+
import Icon from "./Icon/index.js";
|
|
9
|
+
import AriaButton from "./Inputs/helpers/AriaButton.js";
|
|
10
|
+
import Input from "./Inputs/helpers/Input.js";
|
|
11
|
+
import InputContainerStyles from "./Inputs/helpers/InputContainerStyles.js";
|
|
12
|
+
import InputMessage from "./Inputs/helpers/InputMessage.js";
|
|
13
|
+
import Label from "./Inputs/helpers/Label.js";
|
|
14
|
+
import useDynamicWidth from "./Inputs/helpers/useDynamicWidth.js";
|
|
15
|
+
import ListBoxParts_ListBoxItem from "./ListBoxParts/ListBoxItem.js";
|
|
16
|
+
import ListOptions from "./ListBoxParts/ListOptions.js";
|
|
17
|
+
import ListItemStyles from "./ListHelpers/ListItemStyles.js";
|
|
18
|
+
import ListRootStyles, { preventProps } from "./ListHelpers/ListRootStyles.js";
|
|
19
|
+
import ListSection from "./ListHelpers/ListSection.js";
|
|
20
|
+
import MotionPopover from "./MotionPopover.js";
|
|
21
|
+
import Spinner from "./Spinner.js";
|
|
22
|
+
const ComboBox_ComboBox = ({ backgroundColor, menuBackground, children, fontSize, disabled, invalid, required, readOnly, loading, loadingResults, label, options, placeholder = 'Select', placeholderColor, description, errorMessage, textOnly, value, defaultValue, width, height, maxHeight, iconLeft, leftElement, rightElement, allowRepeatSelection, allowsEmptyCollection, position, fixedPosition, open, onOpenChange, before, after, onChange, onCreate, afterShow, afterHide, onTextChange, ref, ...props })=>{
|
|
23
|
+
const [isOpen, handleOpenChange] = useControlledOpenState({
|
|
24
|
+
open,
|
|
25
|
+
onOpenChange,
|
|
26
|
+
afterShow,
|
|
27
|
+
afterHide
|
|
28
|
+
});
|
|
29
|
+
const [internalValue, setInternalValue] = useState(defaultValue || '');
|
|
30
|
+
const [inputText, setInputText] = useState((value || defaultValue || '').toString());
|
|
31
|
+
const pendingSelectionRef = useRef(null);
|
|
32
|
+
const isControlled = void 0 !== value;
|
|
33
|
+
const currentValue = isControlled ? value : internalValue;
|
|
34
|
+
const [inputWidth, HiddenWidthEl] = useDynamicWidth({
|
|
35
|
+
value: inputText,
|
|
36
|
+
placeholder,
|
|
37
|
+
fontSize,
|
|
38
|
+
active: !!textOnly
|
|
39
|
+
});
|
|
40
|
+
const triggerRef = useRef(null);
|
|
41
|
+
const { margin, marginTop, marginBottom, marginRight, marginLeft } = props;
|
|
42
|
+
const marginProps = {
|
|
43
|
+
margin,
|
|
44
|
+
marginTop,
|
|
45
|
+
marginBottom,
|
|
46
|
+
marginRight,
|
|
47
|
+
marginLeft
|
|
48
|
+
};
|
|
49
|
+
const handleSelect = (val)=>{
|
|
50
|
+
if (!val || !allowRepeatSelection && val === currentValue) return;
|
|
51
|
+
if (!isControlled) {
|
|
52
|
+
setInternalValue(val);
|
|
53
|
+
setInputText(val.toString());
|
|
54
|
+
}
|
|
55
|
+
if (onChange) onChange(val);
|
|
56
|
+
};
|
|
57
|
+
const handleInputChange = (text)=>{
|
|
58
|
+
setInputText(text);
|
|
59
|
+
if (onTextChange) onTextChange(text);
|
|
60
|
+
};
|
|
61
|
+
const hasValue = !!(currentValue || defaultValue || inputText);
|
|
62
|
+
const hidePlaceholder = !!(!hasValue && label);
|
|
63
|
+
const flatOptions = flattenListOptions(options || []);
|
|
64
|
+
const showCreateOption = inputText.length > 0 && onCreate && !flatOptions.some((option)=>option.value === inputText);
|
|
65
|
+
const handleCreateOption = ()=>{
|
|
66
|
+
if (!onCreate) return;
|
|
67
|
+
pendingSelectionRef.current = inputText;
|
|
68
|
+
onCreate(inputText);
|
|
69
|
+
};
|
|
70
|
+
useEffect(()=>{
|
|
71
|
+
const pending = pendingSelectionRef.current;
|
|
72
|
+
if (!pending) return;
|
|
73
|
+
const flat = flattenListOptions(options || []);
|
|
74
|
+
const newOption = flat.find((option)=>pending === option.id || pending === option.value);
|
|
75
|
+
if (!newOption) return;
|
|
76
|
+
const key = newOption.id ?? newOption.value;
|
|
77
|
+
handleSelect(key);
|
|
78
|
+
pendingSelectionRef.current = null;
|
|
79
|
+
}, [
|
|
80
|
+
options
|
|
81
|
+
]);
|
|
82
|
+
return /*#__PURE__*/ jsxs(ComboRoot, {
|
|
83
|
+
onOpenChange: handleOpenChange,
|
|
84
|
+
menuTrigger: "focus",
|
|
85
|
+
onInputChange: handleInputChange,
|
|
86
|
+
onSelectionChange: handleSelect,
|
|
87
|
+
isDisabled: disabled,
|
|
88
|
+
isReadOnly: readOnly || loading,
|
|
89
|
+
isInvalid: invalid,
|
|
90
|
+
isRequired: required,
|
|
91
|
+
shouldFocusWrap: true,
|
|
92
|
+
selectedKey: currentValue,
|
|
93
|
+
defaultSelectedKey: defaultValue,
|
|
94
|
+
textOnly: textOnly,
|
|
95
|
+
width: width,
|
|
96
|
+
allowsEmptyCollection: allowsEmptyCollection || !!onCreate,
|
|
97
|
+
...props,
|
|
98
|
+
children: [
|
|
99
|
+
/*#__PURE__*/ jsxs(ComboContainer, {
|
|
100
|
+
ref: triggerRef,
|
|
101
|
+
hasLabel: !!label,
|
|
102
|
+
textOnly: textOnly,
|
|
103
|
+
backgroundColor: backgroundColor,
|
|
104
|
+
isDisabled: disabled,
|
|
105
|
+
isReadOnly: readOnly || loading,
|
|
106
|
+
isInvalid: invalid,
|
|
107
|
+
iconLeft: !!iconLeft,
|
|
108
|
+
height: height,
|
|
109
|
+
...marginProps,
|
|
110
|
+
children: [
|
|
111
|
+
iconLeft && getIcon(iconLeft, {
|
|
112
|
+
marginRight: 8
|
|
113
|
+
}),
|
|
114
|
+
leftElement,
|
|
115
|
+
/*#__PURE__*/ jsxs(Label, {
|
|
116
|
+
label: label,
|
|
117
|
+
filled: hasValue,
|
|
118
|
+
disabled: disabled,
|
|
119
|
+
children: [
|
|
120
|
+
/*#__PURE__*/ jsx(Input, {
|
|
121
|
+
placeholder: placeholder,
|
|
122
|
+
hide: hidePlaceholder,
|
|
123
|
+
placeholderColor: placeholderColor,
|
|
124
|
+
fontSize: fontSize,
|
|
125
|
+
isDisabled: disabled,
|
|
126
|
+
width: inputWidth,
|
|
127
|
+
ref: ref
|
|
128
|
+
}),
|
|
129
|
+
/*#__PURE__*/ jsx(HiddenWidthEl, {})
|
|
130
|
+
]
|
|
131
|
+
}),
|
|
132
|
+
rightElement,
|
|
133
|
+
loading || loadingResults ? /*#__PURE__*/ jsx(Spinner, {
|
|
134
|
+
size: "small"
|
|
135
|
+
}) : /*#__PURE__*/ jsx(CaretButton, {
|
|
136
|
+
disabled: disabled,
|
|
137
|
+
readOnly: readOnly,
|
|
138
|
+
children: /*#__PURE__*/ jsx(Icon, {
|
|
139
|
+
name: isOpen ? 'caret-up' : 'caret-down'
|
|
140
|
+
})
|
|
141
|
+
}),
|
|
142
|
+
/*#__PURE__*/ jsx(InputMessage, {
|
|
143
|
+
description: description,
|
|
144
|
+
errorMessage: errorMessage
|
|
145
|
+
})
|
|
146
|
+
]
|
|
147
|
+
}),
|
|
148
|
+
/*#__PURE__*/ jsx(FieldError, {}),
|
|
149
|
+
/*#__PURE__*/ jsx(MotionPopover, {
|
|
150
|
+
triggerRef: triggerRef,
|
|
151
|
+
offset: 2,
|
|
152
|
+
placement: position,
|
|
153
|
+
shouldFlip: fixedPosition ? false : void 0,
|
|
154
|
+
maxHeight: maxHeight,
|
|
155
|
+
isOpen: isOpen,
|
|
156
|
+
children: ({ isEntering, isExiting })=>/*#__PURE__*/ jsx(ListOptions, {
|
|
157
|
+
options: options,
|
|
158
|
+
autoWidth: textOnly,
|
|
159
|
+
width: triggerRef?.current?.offsetWidth,
|
|
160
|
+
readOnly: isEntering || isExiting,
|
|
161
|
+
before: before,
|
|
162
|
+
after: after,
|
|
163
|
+
menuBackground: menuBackground,
|
|
164
|
+
createOptionItem: showCreateOption && /*#__PURE__*/ jsx(CreateItem, {
|
|
165
|
+
onAction: handleCreateOption,
|
|
166
|
+
children: `Create "${inputText}"`
|
|
167
|
+
}),
|
|
168
|
+
children: children
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
]
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
const Item = ListBoxParts_ListBoxItem;
|
|
175
|
+
const Section = ListSection;
|
|
176
|
+
const ComboRoot = styled(ComboBox, preventProps)(ListRootStyles);
|
|
177
|
+
const ComboContainer = styled.div(InputContainerStyles, ({ iconLeft, textOnly })=>({
|
|
178
|
+
paddingLeft: iconLeft ? 8 : void 0,
|
|
179
|
+
paddingRight: textOnly ? void 0 : 8
|
|
180
|
+
}));
|
|
181
|
+
const CaretButton = styled(AriaButton)(({ theme, disabled, readOnly })=>({
|
|
182
|
+
color: disabled || readOnly ? theme.input.labelColor.disabled : theme.input.labelColor.default,
|
|
183
|
+
cursor: readOnly ? 'default' : void 0
|
|
184
|
+
}));
|
|
185
|
+
const CreateItem = styled(ListBoxItem, preventProps)(ListItemStyles);
|
|
186
|
+
const components_ComboBox = Object.assign(ComboBox_ComboBox, {
|
|
187
|
+
Item,
|
|
188
|
+
Section
|
|
189
|
+
});
|
|
190
|
+
export { components_ComboBox as default };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { Command } from "cmdk";
|
|
4
|
+
import ItemHeaderBody from "../ListHelpers/ItemHeaderBody.js";
|
|
5
|
+
import ListItemStyles, { preventProps } from "../ListHelpers/ListItemStyles.js";
|
|
6
|
+
const CommandItem = ({ id, value, header, body, leftElement, rightElement, inline, disabled, onClick, ...props })=>/*#__PURE__*/ jsxs(Item, {
|
|
7
|
+
id: id || value,
|
|
8
|
+
disabled: disabled,
|
|
9
|
+
onSelect: onClick,
|
|
10
|
+
...props,
|
|
11
|
+
children: [
|
|
12
|
+
leftElement || null,
|
|
13
|
+
header && body ? /*#__PURE__*/ jsx(ItemHeaderBody, {
|
|
14
|
+
header: header,
|
|
15
|
+
body: body,
|
|
16
|
+
inline: inline
|
|
17
|
+
}) : value,
|
|
18
|
+
rightElement && /*#__PURE__*/ jsx("div", {
|
|
19
|
+
style: {
|
|
20
|
+
marginLeft: 'auto'
|
|
21
|
+
},
|
|
22
|
+
children: rightElement
|
|
23
|
+
})
|
|
24
|
+
]
|
|
25
|
+
});
|
|
26
|
+
const Item = styled(Command.Item, preventProps)(({ theme: { optionItem } })=>({
|
|
27
|
+
'&[data-selected="true"]': {
|
|
28
|
+
backgroundColor: optionItem.background.active
|
|
29
|
+
}
|
|
30
|
+
}), ListItemStyles);
|
|
31
|
+
const CommandMenu_CommandItem = CommandItem;
|
|
32
|
+
export { CommandMenu_CommandItem as default };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useTheme } from "@emotion/react";
|
|
3
|
+
import styled from "@emotion/styled";
|
|
4
|
+
import { CommandEmpty, CommandInput, CommandList, CommandRoot } from "cmdk";
|
|
5
|
+
import { useRef, useState } from "react";
|
|
6
|
+
import { Dialog, Modal, ModalOverlay, Popover } from "react-aria-components";
|
|
7
|
+
import { maxWidthHeightProps, widthHeightProps } from "../helpers/styledProps.js";
|
|
8
|
+
import Icon from "../Icon/index.js";
|
|
9
|
+
import InputContainerStyles from "../Inputs/helpers/InputContainerStyles.js";
|
|
10
|
+
import InputStyles from "../Inputs/helpers/InputStyles.js";
|
|
11
|
+
import ListStyles from "../ListHelpers/ListStyles.js";
|
|
12
|
+
import CommandOptions from "./CommandOptions.js";
|
|
13
|
+
const CommandMenu_CommandMenu = ({ options, inputProps, modalProps, triggerRef, position, offset, open, onChange, setOpen, ...props })=>{
|
|
14
|
+
const [search, setSearch] = useState('');
|
|
15
|
+
const listRef = useRef(null);
|
|
16
|
+
const scrollId = useRef(null);
|
|
17
|
+
const { color } = useTheme();
|
|
18
|
+
const { 'aria-label': ariaLabel, ...rest } = props;
|
|
19
|
+
const handleOpenChange = (isOpen)=>{
|
|
20
|
+
setOpen(isOpen);
|
|
21
|
+
if (!isOpen) setSearch('');
|
|
22
|
+
};
|
|
23
|
+
const handleItemSelect = (item)=>{
|
|
24
|
+
onChange(item);
|
|
25
|
+
handleOpenChange(false);
|
|
26
|
+
};
|
|
27
|
+
const scrollList = ()=>{
|
|
28
|
+
if (scrollId.current) clearTimeout(scrollId.current);
|
|
29
|
+
scrollId.current = setTimeout(()=>{
|
|
30
|
+
if (listRef.current) listRef?.current.scrollTo({
|
|
31
|
+
top: 0
|
|
32
|
+
});
|
|
33
|
+
}, 0);
|
|
34
|
+
};
|
|
35
|
+
const handleSearch = (value)=>{
|
|
36
|
+
setSearch(value);
|
|
37
|
+
scrollList();
|
|
38
|
+
};
|
|
39
|
+
const content = /*#__PURE__*/ jsx(Dialog, {
|
|
40
|
+
"aria-label": ariaLabel,
|
|
41
|
+
style: {
|
|
42
|
+
outline: 'none'
|
|
43
|
+
},
|
|
44
|
+
children: /*#__PURE__*/ jsxs(MenuContainer, {
|
|
45
|
+
...rest,
|
|
46
|
+
children: [
|
|
47
|
+
/*#__PURE__*/ jsxs(InputContainer, {
|
|
48
|
+
margin: 8,
|
|
49
|
+
width: "auto",
|
|
50
|
+
children: [
|
|
51
|
+
/*#__PURE__*/ jsx(Icon, {
|
|
52
|
+
name: "search",
|
|
53
|
+
marginRight: 8
|
|
54
|
+
}),
|
|
55
|
+
/*#__PURE__*/ jsx(Input, {
|
|
56
|
+
placeholder: "Search",
|
|
57
|
+
autoFocus: true,
|
|
58
|
+
value: search,
|
|
59
|
+
onValueChange: handleSearch,
|
|
60
|
+
...inputProps
|
|
61
|
+
}),
|
|
62
|
+
search && /*#__PURE__*/ jsx(Icon, {
|
|
63
|
+
name: "close-circle",
|
|
64
|
+
color: color.brand,
|
|
65
|
+
onClick: ()=>setSearch(''),
|
|
66
|
+
pointer: true
|
|
67
|
+
})
|
|
68
|
+
]
|
|
69
|
+
}),
|
|
70
|
+
/*#__PURE__*/ jsxs(List, {
|
|
71
|
+
ref: listRef,
|
|
72
|
+
children: [
|
|
73
|
+
/*#__PURE__*/ jsxs(Empty, {
|
|
74
|
+
children: [
|
|
75
|
+
"No results found for ",
|
|
76
|
+
`"${search}"`,
|
|
77
|
+
"."
|
|
78
|
+
]
|
|
79
|
+
}),
|
|
80
|
+
options && /*#__PURE__*/ jsx(CommandOptions, {
|
|
81
|
+
options: options,
|
|
82
|
+
onItemSelect: handleItemSelect
|
|
83
|
+
})
|
|
84
|
+
]
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
return triggerRef ? /*#__PURE__*/ jsx(Popover, {
|
|
90
|
+
triggerRef: triggerRef,
|
|
91
|
+
isOpen: open,
|
|
92
|
+
onOpenChange: handleOpenChange,
|
|
93
|
+
placement: position,
|
|
94
|
+
offset: offset,
|
|
95
|
+
children: content
|
|
96
|
+
}) : /*#__PURE__*/ jsx(Overlay, {
|
|
97
|
+
isDismissable: true,
|
|
98
|
+
isOpen: open,
|
|
99
|
+
onOpenChange: handleOpenChange,
|
|
100
|
+
...modalProps,
|
|
101
|
+
children: /*#__PURE__*/ jsx(Modal, {
|
|
102
|
+
children: content
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
const MenuContainer = styled(CommandRoot)(ListStyles, {
|
|
107
|
+
display: 'flex',
|
|
108
|
+
flexDirection: 'column',
|
|
109
|
+
overflow: 'hidden'
|
|
110
|
+
}, maxWidthHeightProps, widthHeightProps);
|
|
111
|
+
const InputContainer = styled.div(InputContainerStyles);
|
|
112
|
+
const Input = styled(CommandInput)(InputStyles);
|
|
113
|
+
const List = styled(CommandList)({
|
|
114
|
+
overflowY: 'auto'
|
|
115
|
+
});
|
|
116
|
+
const Empty = styled(CommandEmpty)(({ theme })=>({
|
|
117
|
+
textAlign: 'center',
|
|
118
|
+
color: theme.scale8,
|
|
119
|
+
paddingTop: 4,
|
|
120
|
+
paddingBottom: 8
|
|
121
|
+
}));
|
|
122
|
+
const Overlay = styled(ModalOverlay)(({ overlayColor, overlayBlur = true, zIndex = 100 })=>({
|
|
123
|
+
position: 'fixed',
|
|
124
|
+
top: 0,
|
|
125
|
+
left: 0,
|
|
126
|
+
zIndex,
|
|
127
|
+
width: '100vw',
|
|
128
|
+
height: 'var(--visual-viewport-height)',
|
|
129
|
+
display: 'flex',
|
|
130
|
+
alignItems: 'center',
|
|
131
|
+
justifyContent: 'center',
|
|
132
|
+
backgroundColor: overlayColor || 'rgba(0, 0, 0, 0.2)',
|
|
133
|
+
backdropFilter: overlayBlur ? `blur(${'number' == typeof overlayBlur ? overlayBlur : 4}px)` : 'none'
|
|
134
|
+
}));
|
|
135
|
+
const CommandMenu = CommandMenu_CommandMenu;
|
|
136
|
+
export { CommandMenu as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import CommandItem from "./CommandItem.js";
|
|
3
|
+
import CommandSection from "./CommandSection.js";
|
|
4
|
+
const CommandOptions = ({ options, onItemSelect })=>/*#__PURE__*/ jsx(Fragment, {
|
|
5
|
+
children: options.map((option)=>{
|
|
6
|
+
if ('options' in option) {
|
|
7
|
+
const section = option;
|
|
8
|
+
return /*#__PURE__*/ jsx(CommandSection, {
|
|
9
|
+
id: section.id,
|
|
10
|
+
title: section.title,
|
|
11
|
+
children: section.options.map((item)=>/*#__PURE__*/ jsx(CommandItem, {
|
|
12
|
+
onClick: ()=>onItemSelect(item),
|
|
13
|
+
...item
|
|
14
|
+
}, item.id || item.value))
|
|
15
|
+
}, section.id);
|
|
16
|
+
}
|
|
17
|
+
return /*#__PURE__*/ jsx(CommandItem, {
|
|
18
|
+
onClick: ()=>onItemSelect(option),
|
|
19
|
+
...option
|
|
20
|
+
}, option.id || option.value);
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
const CommandMenu_CommandOptions = CommandOptions;
|
|
24
|
+
export { CommandMenu_CommandOptions as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { Command } from "cmdk";
|
|
4
|
+
const CommandSection_CommandSection = ({ id, title, children })=>/*#__PURE__*/ jsx(Section, {
|
|
5
|
+
id: id,
|
|
6
|
+
heading: title,
|
|
7
|
+
children: children
|
|
8
|
+
});
|
|
9
|
+
const Section = styled(Command.Group)(({ theme })=>({
|
|
10
|
+
'& > div[cmdk-group-heading]': {
|
|
11
|
+
backgroundColor: theme.scale0,
|
|
12
|
+
padding: '0 16px',
|
|
13
|
+
color: theme.scale6,
|
|
14
|
+
fontWeight: theme.font.weight.medium,
|
|
15
|
+
pointerEvents: 'none'
|
|
16
|
+
}
|
|
17
|
+
}));
|
|
18
|
+
const CommandSection = CommandSection_CommandSection;
|
|
19
|
+
export { CommandSection as default };
|