@wavv/ui 2.2.2-alpha.5 → 2.2.2-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/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/index.js +6 -0
- package/build/utils/numberWithCommas.js +3 -0
- package/build/utils/range.js +11 -0
- package/package.json +1 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
import { DialogTrigger, GridList } from "react-aria-components";
|
|
5
|
+
import { useControlledOpenState } from "../hooks/index.js";
|
|
6
|
+
import flattenListOptions from "../utils/flattenListOptions.js";
|
|
7
|
+
import AriaButton from "./Inputs/helpers/AriaButton.js";
|
|
8
|
+
import TextInput from "./Inputs/TextInput.js";
|
|
9
|
+
import GridListItem from "./ListBoxParts/GridListItem.js";
|
|
10
|
+
import GridListSection from "./ListHelpers/GridListSection.js";
|
|
11
|
+
import ListStyles from "./ListHelpers/ListStyles.js";
|
|
12
|
+
import MotionPopover from "./MotionPopover.js";
|
|
13
|
+
const Dropdown_Dropdown = ({ children, before, after, open, label, placeholder = 'Select', options = [], width, height, value, defaultValue, loading, hideCaret, color, disabled, readOnly, placeholderColor, fontSize, fontWeight, description, errorMessage, position, backgroundColor, menuBackground, iconLeft, leftElement, rightElement, onChange, onOpenChange, afterShow, afterHide, ...props })=>{
|
|
14
|
+
const [isOpen, handleOpenChange] = useControlledOpenState({
|
|
15
|
+
open,
|
|
16
|
+
onOpenChange,
|
|
17
|
+
afterShow,
|
|
18
|
+
afterHide
|
|
19
|
+
});
|
|
20
|
+
const [internalValue, setInternalValue] = useState(defaultValue || '');
|
|
21
|
+
const triggerRef = useRef(null);
|
|
22
|
+
const isControlled = void 0 !== value;
|
|
23
|
+
const currentValue = isControlled ? value : internalValue;
|
|
24
|
+
const selectedOption = flattenListOptions(options).find((opt)=>opt.id === currentValue);
|
|
25
|
+
const handleSelectionChange = (keys)=>{
|
|
26
|
+
const key = keys instanceof Set ? Array.from(keys)[0] : keys;
|
|
27
|
+
if (key) {
|
|
28
|
+
if (!isControlled) setInternalValue(key);
|
|
29
|
+
if (onChange) onChange(key);
|
|
30
|
+
}
|
|
31
|
+
handleOpenChange(false);
|
|
32
|
+
};
|
|
33
|
+
return /*#__PURE__*/ jsxs(DialogTrigger, {
|
|
34
|
+
isOpen: isOpen,
|
|
35
|
+
onOpenChange: handleOpenChange,
|
|
36
|
+
children: [
|
|
37
|
+
/*#__PURE__*/ jsx(InputWrapper, {
|
|
38
|
+
...props,
|
|
39
|
+
ref: triggerRef,
|
|
40
|
+
width: width ?? '100%',
|
|
41
|
+
isDisabled: disabled || readOnly || loading,
|
|
42
|
+
backgroundColor: backgroundColor,
|
|
43
|
+
children: /*#__PURE__*/ jsx(TextInput, {
|
|
44
|
+
value: selectedOption?.value || currentValue,
|
|
45
|
+
disabled: disabled,
|
|
46
|
+
readOnly: readOnly || loading,
|
|
47
|
+
placeholder: placeholder,
|
|
48
|
+
placeholderColor: placeholderColor,
|
|
49
|
+
loading: loading,
|
|
50
|
+
label: label,
|
|
51
|
+
description: description,
|
|
52
|
+
errorMessage: errorMessage,
|
|
53
|
+
fontSize: fontSize,
|
|
54
|
+
fontWeight: fontWeight,
|
|
55
|
+
backgroundColor: backgroundColor,
|
|
56
|
+
color: color,
|
|
57
|
+
iconLeft: iconLeft,
|
|
58
|
+
leftElement: leftElement,
|
|
59
|
+
rightElement: rightElement,
|
|
60
|
+
iconRight: hideCaret ? void 0 : isOpen ? 'caret-up' : 'caret-down',
|
|
61
|
+
paddingLeft: iconLeft ? 8 : void 0,
|
|
62
|
+
paddingRight: 8,
|
|
63
|
+
height: height,
|
|
64
|
+
asTrigger: true
|
|
65
|
+
})
|
|
66
|
+
}),
|
|
67
|
+
/*#__PURE__*/ jsx(MotionPopover, {
|
|
68
|
+
triggerRef: triggerRef,
|
|
69
|
+
offset: 2,
|
|
70
|
+
placement: position,
|
|
71
|
+
children: ({ isEntering, isExiting })=>/*#__PURE__*/ jsxs(MenuContainer, {
|
|
72
|
+
width: width || triggerRef?.current?.offsetWidth,
|
|
73
|
+
readOnly: isEntering || isExiting,
|
|
74
|
+
background: menuBackground,
|
|
75
|
+
children: [
|
|
76
|
+
before,
|
|
77
|
+
/*#__PURE__*/ jsxs(GridList, {
|
|
78
|
+
"aria-label": label || 'Dropdown',
|
|
79
|
+
selectionMode: "single",
|
|
80
|
+
selectedKeys: currentValue ? [
|
|
81
|
+
currentValue
|
|
82
|
+
] : [],
|
|
83
|
+
onSelectionChange: handleSelectionChange,
|
|
84
|
+
style: {
|
|
85
|
+
outline: 'none'
|
|
86
|
+
},
|
|
87
|
+
autoFocus: true,
|
|
88
|
+
shouldSelectOnPressUp: true,
|
|
89
|
+
children: [
|
|
90
|
+
options.map((option)=>{
|
|
91
|
+
if ('options' in option) {
|
|
92
|
+
const section = option;
|
|
93
|
+
return /*#__PURE__*/ jsx(GridListSection, {
|
|
94
|
+
id: section.id,
|
|
95
|
+
title: section.title,
|
|
96
|
+
children: section.options.map((item)=>/*#__PURE__*/ jsx(GridListItem, {
|
|
97
|
+
...item
|
|
98
|
+
}, item.id || item.value))
|
|
99
|
+
}, section.id);
|
|
100
|
+
}
|
|
101
|
+
const item = option;
|
|
102
|
+
return /*#__PURE__*/ jsx(GridListItem, {
|
|
103
|
+
...item
|
|
104
|
+
}, item.id || item.value);
|
|
105
|
+
}),
|
|
106
|
+
children
|
|
107
|
+
]
|
|
108
|
+
}),
|
|
109
|
+
after
|
|
110
|
+
]
|
|
111
|
+
})
|
|
112
|
+
})
|
|
113
|
+
]
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
const InputWrapper = styled(AriaButton)(({ theme: { input }, isDisabled, backgroundColor })=>({
|
|
117
|
+
cursor: isDisabled ? 'default' : void 0,
|
|
118
|
+
'&:hover > div': {
|
|
119
|
+
backgroundColor: isDisabled || backgroundColor ? void 0 : input.background.hover,
|
|
120
|
+
'& > label': {
|
|
121
|
+
color: isDisabled ? void 0 : input.labelColor.hover
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}));
|
|
125
|
+
const MenuContainer = styled.div(ListStyles);
|
|
126
|
+
const Item = GridListItem;
|
|
127
|
+
const Dropdown = Object.assign(Dropdown_Dropdown, {
|
|
128
|
+
Item
|
|
129
|
+
});
|
|
130
|
+
export { Dropdown as default };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { MenuTrigger, Separator, SubmenuTrigger } from "react-aria-components";
|
|
5
|
+
import { useControlledOpenState } from "../hooks/index.js";
|
|
6
|
+
import Menu from "./DropdownMenuParts/Menu.js";
|
|
7
|
+
import MenuItem from "./DropdownMenuParts/MenuItem.js";
|
|
8
|
+
import MenuOptions from "./DropdownMenuParts/MenuOptions.js";
|
|
9
|
+
import MenuSection from "./DropdownMenuParts/MenuSection.js";
|
|
10
|
+
import Icon from "./Icon/index.js";
|
|
11
|
+
import AriaButton from "./Inputs/helpers/AriaButton.js";
|
|
12
|
+
import MotionPopover from "./MotionPopover.js";
|
|
13
|
+
const DropdownMenu = ({ children, position = 'bottom', fixedPosition, trigger, isTriggerButton, triggerProps, triggerOnContextMenu, menuBackground, options, offset = 4, selectionMode, selectedKeys, before, after, open, afterShow, afterHide, onSelectionChange, onOpenChange, ...props })=>{
|
|
14
|
+
const [selected, setSelected] = useState(new Set());
|
|
15
|
+
const [controlledKeys, setControlledKeys] = useState();
|
|
16
|
+
const [isOpen, handleOpenChange] = useControlledOpenState({
|
|
17
|
+
open,
|
|
18
|
+
onOpenChange,
|
|
19
|
+
afterShow,
|
|
20
|
+
afterHide
|
|
21
|
+
});
|
|
22
|
+
const contextMenuTriggerRef = useRef(null);
|
|
23
|
+
useEffect(()=>{
|
|
24
|
+
if (selectedKeys) {
|
|
25
|
+
if ('single' === selectionMode) setControlledKeys(new Set([
|
|
26
|
+
selectedKeys
|
|
27
|
+
]));
|
|
28
|
+
else if ('multiple' === selectionMode) setControlledKeys('string' == typeof selectedKeys ? selectedKeys : new Set(selectedKeys));
|
|
29
|
+
}
|
|
30
|
+
}, [
|
|
31
|
+
selectedKeys
|
|
32
|
+
]);
|
|
33
|
+
useEffect(()=>()=>{
|
|
34
|
+
handleOpenChange(false);
|
|
35
|
+
}, []);
|
|
36
|
+
const handleContextMenu = (event)=>{
|
|
37
|
+
if (triggerOnContextMenu) {
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
handleOpenChange(true);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const triggerEl = isTriggerButton ? trigger : /*#__PURE__*/ jsx(AriaButton, {
|
|
43
|
+
"aria-label": "Menu",
|
|
44
|
+
...triggerProps,
|
|
45
|
+
children: trigger
|
|
46
|
+
});
|
|
47
|
+
const wrappedTrigger = triggerOnContextMenu ? /*#__PURE__*/ jsx(TriggerWrapper, {
|
|
48
|
+
onContextMenu: handleContextMenu,
|
|
49
|
+
ref: contextMenuTriggerRef,
|
|
50
|
+
children: trigger
|
|
51
|
+
}) : triggerEl;
|
|
52
|
+
const handleSelection = (selection)=>{
|
|
53
|
+
setSelected(selection);
|
|
54
|
+
const values = Array.from(selection);
|
|
55
|
+
if (onSelectionChange) 'single' === selectionMode ? onSelectionChange(values[0]) : onSelectionChange('all' === selection ? selection : values);
|
|
56
|
+
};
|
|
57
|
+
return /*#__PURE__*/ jsxs(MenuTrigger, {
|
|
58
|
+
onOpenChange: handleOpenChange,
|
|
59
|
+
isOpen: isOpen,
|
|
60
|
+
children: [
|
|
61
|
+
wrappedTrigger,
|
|
62
|
+
/*#__PURE__*/ jsx(MotionPopover, {
|
|
63
|
+
placement: position,
|
|
64
|
+
offset: offset,
|
|
65
|
+
shouldFlip: fixedPosition ? false : void 0,
|
|
66
|
+
triggerRef: triggerOnContextMenu ? contextMenuTriggerRef : void 0,
|
|
67
|
+
children: ({ isEntering, isExiting })=>/*#__PURE__*/ jsx(MenuOptions, {
|
|
68
|
+
options: options,
|
|
69
|
+
autoWidth: true,
|
|
70
|
+
selectionMode: selectionMode,
|
|
71
|
+
selectedKeys: controlledKeys || selected,
|
|
72
|
+
onSelectionChange: handleSelection,
|
|
73
|
+
readOnly: isEntering || isExiting,
|
|
74
|
+
before: before,
|
|
75
|
+
after: after,
|
|
76
|
+
menuBackground: menuBackground,
|
|
77
|
+
...props,
|
|
78
|
+
children: children
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
const SubMenu = ({ children, label, disabled })=>/*#__PURE__*/ jsxs(SubmenuTrigger, {
|
|
85
|
+
children: [
|
|
86
|
+
/*#__PURE__*/ jsx(MenuItem, {
|
|
87
|
+
value: label,
|
|
88
|
+
disabled: disabled,
|
|
89
|
+
rightElement: /*#__PURE__*/ jsx(ChevronContainer, {
|
|
90
|
+
children: /*#__PURE__*/ jsx(Chevron, {
|
|
91
|
+
children: /*#__PURE__*/ jsx(Icon, {
|
|
92
|
+
name: "chevron-right",
|
|
93
|
+
size: "small"
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
}),
|
|
98
|
+
/*#__PURE__*/ jsx(MotionPopover, {
|
|
99
|
+
offset: 2,
|
|
100
|
+
children: ({ isEntering, isExiting })=>/*#__PURE__*/ jsx(Menu, {
|
|
101
|
+
autoWidth: true,
|
|
102
|
+
readOnly: isEntering || isExiting,
|
|
103
|
+
children: children
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
]
|
|
107
|
+
});
|
|
108
|
+
SubMenu.displayName = 'DropdownMenu.Sub';
|
|
109
|
+
const DropdownMenu_Separator = styled(Separator)(({ theme })=>({
|
|
110
|
+
height: 1,
|
|
111
|
+
backgroundColor: theme.scale2,
|
|
112
|
+
margin: '4px 8px'
|
|
113
|
+
}));
|
|
114
|
+
const ChevronContainer = styled.div({
|
|
115
|
+
marginLeft: 'auto',
|
|
116
|
+
width: 16,
|
|
117
|
+
height: 16
|
|
118
|
+
});
|
|
119
|
+
const Chevron = styled.div({
|
|
120
|
+
position: 'absolute',
|
|
121
|
+
right: 8
|
|
122
|
+
});
|
|
123
|
+
const TriggerWrapper = styled.div({
|
|
124
|
+
display: 'inline-block'
|
|
125
|
+
});
|
|
126
|
+
DropdownMenu.Item = MenuItem;
|
|
127
|
+
DropdownMenu.Sub = SubMenu;
|
|
128
|
+
DropdownMenu.Section = MenuSection;
|
|
129
|
+
DropdownMenu.Separator = DropdownMenu_Separator;
|
|
130
|
+
const components_DropdownMenu = DropdownMenu;
|
|
131
|
+
export { components_DropdownMenu as default };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import styled from "@emotion/styled";
|
|
2
|
+
import { Menu } from "react-aria-components";
|
|
3
|
+
import ListStyles, { preventProps } from "../ListHelpers/ListStyles.js";
|
|
4
|
+
const Menu_Menu = styled(Menu, preventProps)(ListStyles);
|
|
5
|
+
const DropdownMenuParts_Menu = Menu_Menu;
|
|
6
|
+
export { DropdownMenuParts_Menu as default };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { MenuItem } from "react-aria-components";
|
|
4
|
+
import Checkbox from "../Checkbox.js";
|
|
5
|
+
import Icon from "../Icon/index.js";
|
|
6
|
+
import ItemHeaderBody from "../ListHelpers/ItemHeaderBody.js";
|
|
7
|
+
import ListItemStyles, { preventProps } from "../ListHelpers/ListItemStyles.js";
|
|
8
|
+
const MenuItem_MenuItem = ({ id, value, children, header, body, leftElement, rightElement, inline, disabled, checkbox, onClick, ...props })=>{
|
|
9
|
+
const content = children || value;
|
|
10
|
+
const headerText = header || value;
|
|
11
|
+
return /*#__PURE__*/ jsx(Item, {
|
|
12
|
+
id: id || value,
|
|
13
|
+
textValue: value,
|
|
14
|
+
onAction: onClick,
|
|
15
|
+
isDisabled: disabled,
|
|
16
|
+
...props,
|
|
17
|
+
children: ({ selectionMode, isSelected })=>{
|
|
18
|
+
const showCheck = 'multiple' === selectionMode || 'single' === selectionMode;
|
|
19
|
+
const check = checkbox ? /*#__PURE__*/ jsx(Checkbox, {
|
|
20
|
+
checked: isSelected,
|
|
21
|
+
readOnly: true,
|
|
22
|
+
marginRight: 4
|
|
23
|
+
}) : /*#__PURE__*/ jsx(Icon, {
|
|
24
|
+
name: "check",
|
|
25
|
+
color: isSelected ? void 0 : 'transparent',
|
|
26
|
+
size: "small",
|
|
27
|
+
marginLeft: -12,
|
|
28
|
+
marginRight: 4
|
|
29
|
+
});
|
|
30
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
31
|
+
children: [
|
|
32
|
+
showCheck ? check : null,
|
|
33
|
+
leftElement || null,
|
|
34
|
+
headerText && body ? /*#__PURE__*/ jsx(ItemHeaderBody, {
|
|
35
|
+
header: headerText,
|
|
36
|
+
body: body,
|
|
37
|
+
inline: inline,
|
|
38
|
+
disabled: disabled
|
|
39
|
+
}) : content,
|
|
40
|
+
rightElement && /*#__PURE__*/ jsx("div", {
|
|
41
|
+
style: {
|
|
42
|
+
marginLeft: 'auto'
|
|
43
|
+
},
|
|
44
|
+
children: rightElement
|
|
45
|
+
})
|
|
46
|
+
]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
const Item = styled(MenuItem, preventProps)(ListItemStyles);
|
|
52
|
+
MenuItem_MenuItem.displayName = 'DropdownMenu.Item';
|
|
53
|
+
const DropdownMenuParts_MenuItem = MenuItem_MenuItem;
|
|
54
|
+
export { DropdownMenuParts_MenuItem as default };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { Menu } from "react-aria-components";
|
|
4
|
+
import ListSection from "../ListHelpers/ListSection.js";
|
|
5
|
+
import ListStyles, { preventProps } from "../ListHelpers/ListStyles.js";
|
|
6
|
+
import MenuItem from "./MenuItem.js";
|
|
7
|
+
const MenuOptions_MenuOptions = ({ options, children, autoWidth, itemProps, width, ref, before, after, menuBackground, ...props })=>/*#__PURE__*/ jsxs(MenuContainer, {
|
|
8
|
+
autoWidth: autoWidth,
|
|
9
|
+
width: width,
|
|
10
|
+
background: menuBackground,
|
|
11
|
+
children: [
|
|
12
|
+
before,
|
|
13
|
+
/*#__PURE__*/ jsxs(Menu, {
|
|
14
|
+
shouldFocusWrap: true,
|
|
15
|
+
ref: ref,
|
|
16
|
+
style: {
|
|
17
|
+
outline: 'none'
|
|
18
|
+
},
|
|
19
|
+
...props,
|
|
20
|
+
children: [
|
|
21
|
+
options?.map((option)=>{
|
|
22
|
+
if ('options' in option) {
|
|
23
|
+
const section = option;
|
|
24
|
+
return /*#__PURE__*/ jsx(ListSection, {
|
|
25
|
+
id: section.id,
|
|
26
|
+
title: section.title,
|
|
27
|
+
children: section.options.map((item)=>/*#__PURE__*/ jsx(MenuItem, {
|
|
28
|
+
...item,
|
|
29
|
+
...itemProps
|
|
30
|
+
}, item.id || item.value))
|
|
31
|
+
}, section.id);
|
|
32
|
+
}
|
|
33
|
+
const item = option;
|
|
34
|
+
return /*#__PURE__*/ jsx(MenuItem, {
|
|
35
|
+
...item,
|
|
36
|
+
...itemProps
|
|
37
|
+
}, item.id || item.value);
|
|
38
|
+
}),
|
|
39
|
+
children
|
|
40
|
+
]
|
|
41
|
+
}),
|
|
42
|
+
after
|
|
43
|
+
]
|
|
44
|
+
});
|
|
45
|
+
const MenuContainer = styled('div', preventProps)(ListStyles);
|
|
46
|
+
const MenuOptions = MenuOptions_MenuOptions;
|
|
47
|
+
export { MenuOptions as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { MenuSection } from "react-aria-components";
|
|
3
|
+
import ListHeader from "../ListHelpers/ListHeader.js";
|
|
4
|
+
const MenuSection_MenuSection = ({ id, title, children })=>/*#__PURE__*/ jsxs(MenuSection, {
|
|
5
|
+
id: id,
|
|
6
|
+
children: [
|
|
7
|
+
title && /*#__PURE__*/ jsx(ListHeader, {
|
|
8
|
+
children: title
|
|
9
|
+
}),
|
|
10
|
+
children
|
|
11
|
+
]
|
|
12
|
+
});
|
|
13
|
+
const DropdownMenuParts_MenuSection = MenuSection_MenuSection;
|
|
14
|
+
export { DropdownMenuParts_MenuSection as default };
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
import { MenuTrigger } from "react-aria-components";
|
|
5
|
+
import flattenListOptions from "../utils/flattenListOptions.js";
|
|
6
|
+
import Checkbox from "./Checkbox.js";
|
|
7
|
+
import MenuOptions from "./DropdownMenuParts/MenuOptions.js";
|
|
8
|
+
import Icon from "./Icon/index.js";
|
|
9
|
+
import AriaButton from "./Inputs/helpers/AriaButton.js";
|
|
10
|
+
import InputContainerStyles from "./Inputs/helpers/InputContainerStyles.js";
|
|
11
|
+
import SearchInput from "./Inputs/SearchInput.js";
|
|
12
|
+
import ListStyles from "./ListHelpers/ListStyles.js";
|
|
13
|
+
import MotionPopover from "./MotionPopover.js";
|
|
14
|
+
const filterOptions = (options, searchTerm)=>{
|
|
15
|
+
const includes = (val)=>{
|
|
16
|
+
if (!val) return false;
|
|
17
|
+
const text = searchTerm.toLowerCase();
|
|
18
|
+
const property = val.toString().toLowerCase();
|
|
19
|
+
return property.includes(text);
|
|
20
|
+
};
|
|
21
|
+
return options.reduce((acc, item)=>{
|
|
22
|
+
if ('options' in item) {
|
|
23
|
+
const filteredOptions = filterOptions(item.options, searchTerm);
|
|
24
|
+
if (filteredOptions.length > 0) acc.push({
|
|
25
|
+
...item,
|
|
26
|
+
options: filteredOptions
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
let match = includes(item.value);
|
|
30
|
+
if (!match && 'id' in item) match = includes(item.id);
|
|
31
|
+
if (!match && 'body' in item) match = includes(item.body);
|
|
32
|
+
if (!match && 'header' in item) match = includes(item.header);
|
|
33
|
+
if (match) acc.push(item);
|
|
34
|
+
}
|
|
35
|
+
return acc;
|
|
36
|
+
}, []);
|
|
37
|
+
};
|
|
38
|
+
const DropdownSelect_DropdownSelect = ({ label, options, width, search, onChange, ...props })=>{
|
|
39
|
+
const [selected, setSelected] = useState(new Set());
|
|
40
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
41
|
+
const [searchVal, setSearchVal] = useState('');
|
|
42
|
+
const [allSelected, setAllSelected] = useState(false);
|
|
43
|
+
const [partial, setPartial] = useState(false);
|
|
44
|
+
const [count, setCount] = useState(0);
|
|
45
|
+
const [focus, setFocus] = useState('menu');
|
|
46
|
+
const triggerRef = useRef(null);
|
|
47
|
+
const menuRef = useRef(null);
|
|
48
|
+
const flatOptions = flattenListOptions(options);
|
|
49
|
+
const filtered = filterOptions(options, searchVal);
|
|
50
|
+
const reset = ()=>{
|
|
51
|
+
setSearchVal('');
|
|
52
|
+
setFocus('menu');
|
|
53
|
+
};
|
|
54
|
+
const handleOpenChange = (open)=>{
|
|
55
|
+
setIsOpen(open);
|
|
56
|
+
if (!open) reset();
|
|
57
|
+
};
|
|
58
|
+
const handleSelectionChange = (newSelection)=>{
|
|
59
|
+
setSelected(newSelection);
|
|
60
|
+
const total = flatOptions.length;
|
|
61
|
+
const all = 'all' === newSelection || newSelection.size === total;
|
|
62
|
+
const some = !all && newSelection.size > 0;
|
|
63
|
+
setAllSelected(all);
|
|
64
|
+
setPartial(some);
|
|
65
|
+
setCount(all ? total : newSelection.size);
|
|
66
|
+
const items = all ? flatOptions : flatOptions.filter((option)=>newSelection.has(option.id));
|
|
67
|
+
if (onChange) onChange(items);
|
|
68
|
+
};
|
|
69
|
+
return /*#__PURE__*/ jsxs(Container, {
|
|
70
|
+
width: width,
|
|
71
|
+
ref: triggerRef,
|
|
72
|
+
tabIndex: -1,
|
|
73
|
+
...props,
|
|
74
|
+
children: [
|
|
75
|
+
/*#__PURE__*/ jsxs(Side, {
|
|
76
|
+
children: [
|
|
77
|
+
/*#__PURE__*/ jsx(Checkbox, {
|
|
78
|
+
partial: partial,
|
|
79
|
+
checked: allSelected,
|
|
80
|
+
onChange: ()=>handleSelectionChange(allSelected ? new Set() : 'all')
|
|
81
|
+
}),
|
|
82
|
+
/*#__PURE__*/ jsx(Label, {
|
|
83
|
+
children: label
|
|
84
|
+
})
|
|
85
|
+
]
|
|
86
|
+
}),
|
|
87
|
+
/*#__PURE__*/ jsxs(Side, {
|
|
88
|
+
gap: 8,
|
|
89
|
+
children: [
|
|
90
|
+
(partial || allSelected) && /*#__PURE__*/ jsx(Count, {
|
|
91
|
+
children: partial ? count : 'All'
|
|
92
|
+
}),
|
|
93
|
+
/*#__PURE__*/ jsxs(MenuTrigger, {
|
|
94
|
+
onOpenChange: handleOpenChange,
|
|
95
|
+
children: [
|
|
96
|
+
/*#__PURE__*/ jsx(AriaButton, {
|
|
97
|
+
children: /*#__PURE__*/ jsx(Icon, {
|
|
98
|
+
name: isOpen ? 'caret-up' : 'caret-down'
|
|
99
|
+
})
|
|
100
|
+
}),
|
|
101
|
+
/*#__PURE__*/ jsx(MotionPopover, {
|
|
102
|
+
triggerRef: triggerRef,
|
|
103
|
+
offset: 2,
|
|
104
|
+
children: ({ isEntering, isExiting })=>/*#__PURE__*/ jsxs(MenuContainer, {
|
|
105
|
+
width: width || triggerRef?.current?.offsetWidth,
|
|
106
|
+
readOnly: isEntering || isExiting,
|
|
107
|
+
children: [
|
|
108
|
+
search && /*#__PURE__*/ jsx(SearchInput, {
|
|
109
|
+
value: searchVal,
|
|
110
|
+
onChange: setSearchVal,
|
|
111
|
+
placeholder: "Search",
|
|
112
|
+
padding: "2px 4px",
|
|
113
|
+
margin: 8,
|
|
114
|
+
minHeight: "unset",
|
|
115
|
+
height: "auto",
|
|
116
|
+
width: "auto",
|
|
117
|
+
onFocus: ()=>setFocus('input'),
|
|
118
|
+
onKeyDown: (event)=>{
|
|
119
|
+
if ('ArrowDown' === event.key || 'ArrowUp' === event.key) menuRef.current?.focus();
|
|
120
|
+
}
|
|
121
|
+
}),
|
|
122
|
+
searchVal && 0 === filtered.length && /*#__PURE__*/ jsx(Empty, {
|
|
123
|
+
children: "No results found"
|
|
124
|
+
}),
|
|
125
|
+
/*#__PURE__*/ jsx(MenuOptions, {
|
|
126
|
+
options: filtered,
|
|
127
|
+
selectionMode: "multiple",
|
|
128
|
+
width: "100%",
|
|
129
|
+
selectedKeys: selected,
|
|
130
|
+
onSelectionChange: handleSelectionChange,
|
|
131
|
+
autoFocus: 'menu' === focus,
|
|
132
|
+
ref: menuRef,
|
|
133
|
+
itemProps: {
|
|
134
|
+
checkbox: true
|
|
135
|
+
},
|
|
136
|
+
readOnly: isEntering || isExiting
|
|
137
|
+
})
|
|
138
|
+
]
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
]
|
|
142
|
+
})
|
|
143
|
+
]
|
|
144
|
+
})
|
|
145
|
+
]
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
const Container = styled.div(InputContainerStyles, {
|
|
149
|
+
gap: 16
|
|
150
|
+
});
|
|
151
|
+
const MenuContainer = styled.div(ListStyles);
|
|
152
|
+
const Label = styled.span(({ theme: { font, scale10 } })=>({
|
|
153
|
+
fontSize: font.size.md,
|
|
154
|
+
color: scale10
|
|
155
|
+
}));
|
|
156
|
+
const Side = styled.div(({ gap })=>({
|
|
157
|
+
display: 'flex',
|
|
158
|
+
alignItems: 'center',
|
|
159
|
+
gap: gap || 4
|
|
160
|
+
}));
|
|
161
|
+
const Count = styled.div(({ theme })=>({
|
|
162
|
+
color: theme.scale10
|
|
163
|
+
}));
|
|
164
|
+
const Empty = styled.div(({ theme })=>({
|
|
165
|
+
textAlign: 'center',
|
|
166
|
+
color: theme.scale8,
|
|
167
|
+
paddingTop: 4,
|
|
168
|
+
paddingBottom: 8
|
|
169
|
+
}));
|
|
170
|
+
const DropdownSelect = DropdownSelect_DropdownSelect;
|
|
171
|
+
export { Label, DropdownSelect as default };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { DynamicIcon } from "lucide-react/dynamic";
|
|
4
|
+
import isPropAllowed from "./helpers/isPropAllowed.js";
|
|
5
|
+
import { marginProps } from "./helpers/styledProps.js";
|
|
6
|
+
const DynamicIcon_DynamicIcon = ({ size, onClick, ...props })=>{
|
|
7
|
+
const handleKeyDown = (event)=>{
|
|
8
|
+
if ('Enter' === event.key || ' ' === event.key) {
|
|
9
|
+
event.preventDefault();
|
|
10
|
+
onClick?.();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
return /*#__PURE__*/ jsx(Icon, {
|
|
14
|
+
...props,
|
|
15
|
+
size: size,
|
|
16
|
+
strokeWidth: 1.5,
|
|
17
|
+
onClick: onClick,
|
|
18
|
+
onKeyDown: onClick ? handleKeyDown : void 0
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const Icon = styled(DynamicIcon, {
|
|
22
|
+
shouldForwardProp: (prop)=>isPropAllowed(prop, [
|
|
23
|
+
'pointer',
|
|
24
|
+
'hoverColor',
|
|
25
|
+
'margin',
|
|
26
|
+
'marginLeft',
|
|
27
|
+
'marginRight',
|
|
28
|
+
'marginTop',
|
|
29
|
+
'marginBottom'
|
|
30
|
+
])
|
|
31
|
+
})(({ theme, hoverColor, pointer, animation, size })=>({
|
|
32
|
+
display: 'flex',
|
|
33
|
+
width: size,
|
|
34
|
+
height: size,
|
|
35
|
+
minWidth: size,
|
|
36
|
+
minHeight: size,
|
|
37
|
+
cursor: pointer ? 'pointer' : 'inherit',
|
|
38
|
+
animation,
|
|
39
|
+
outline: 'none',
|
|
40
|
+
'&:hover': {
|
|
41
|
+
stroke: hoverColor
|
|
42
|
+
},
|
|
43
|
+
'&:focus-visible': {
|
|
44
|
+
outline: `${theme.accent} solid 1px`,
|
|
45
|
+
outlineOffset: -1
|
|
46
|
+
}
|
|
47
|
+
}), marginProps);
|
|
48
|
+
const components_DynamicIcon = DynamicIcon_DynamicIcon;
|
|
49
|
+
export { components_DynamicIcon as default };
|