@wavv/ui 2.2.2-alpha.4 → 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/index.js +79 -12348
- 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 +6 -2
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { keyframes } from "@emotion/react";
|
|
3
|
+
import styled from "@emotion/styled";
|
|
4
|
+
import { useRef } from "react";
|
|
5
|
+
import { OverlayArrow, Tooltip, TooltipTrigger } from "react-aria-components";
|
|
6
|
+
import Focusable from "./Focusable.js";
|
|
7
|
+
import isPropAllowed from "./helpers/isPropAllowed.js";
|
|
8
|
+
const Tooltip_Tooltip = ({ trigger, triggerProps, children, content, position, offset = 6, zIndex, width, maxWidth, textAlign, open, disabled, bgColor, color, className, afterShow, afterHide, ...props })=>{
|
|
9
|
+
const triggerRef = useRef(null);
|
|
10
|
+
const handleOpenChange = (show)=>{
|
|
11
|
+
if (afterShow && show) afterShow();
|
|
12
|
+
if (afterHide && !show) afterHide();
|
|
13
|
+
};
|
|
14
|
+
return /*#__PURE__*/ jsxs(TooltipTrigger, {
|
|
15
|
+
delay: 0,
|
|
16
|
+
onOpenChange: handleOpenChange,
|
|
17
|
+
isDisabled: disabled,
|
|
18
|
+
...props,
|
|
19
|
+
children: [
|
|
20
|
+
/*#__PURE__*/ jsx(Focusable, {
|
|
21
|
+
ref: triggerRef,
|
|
22
|
+
...triggerProps,
|
|
23
|
+
children: trigger
|
|
24
|
+
}),
|
|
25
|
+
/*#__PURE__*/ jsxs(TooltipEl, {
|
|
26
|
+
placement: position,
|
|
27
|
+
offset: offset,
|
|
28
|
+
zIndex: zIndex,
|
|
29
|
+
width: width,
|
|
30
|
+
maxWidth: maxWidth,
|
|
31
|
+
textAlign: textAlign,
|
|
32
|
+
bgColor: bgColor,
|
|
33
|
+
textColor: color,
|
|
34
|
+
className: className,
|
|
35
|
+
triggerRef: triggerRef,
|
|
36
|
+
children: [
|
|
37
|
+
/*#__PURE__*/ jsx(OverlayArrow, {
|
|
38
|
+
children: /*#__PURE__*/ jsx("svg", {
|
|
39
|
+
width: 8,
|
|
40
|
+
height: 8,
|
|
41
|
+
viewBox: "0 0 8 8",
|
|
42
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
43
|
+
d: "M0 0 L4 4 L8 0"
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
}),
|
|
47
|
+
content || children
|
|
48
|
+
]
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const slide = keyframes({
|
|
54
|
+
from: {
|
|
55
|
+
transform: 'var(--origin)',
|
|
56
|
+
opacity: 0
|
|
57
|
+
},
|
|
58
|
+
to: {
|
|
59
|
+
transform: 'translateY(0)',
|
|
60
|
+
opacity: 1
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
const time = '300ms cubic-bezier(0.860, 0.000, 0.070, 1.000)';
|
|
64
|
+
const TooltipEl = styled(Tooltip, {
|
|
65
|
+
shouldForwardProp: (prop)=>isPropAllowed(prop, [
|
|
66
|
+
'maxWidth',
|
|
67
|
+
'textAlign',
|
|
68
|
+
'bgColor',
|
|
69
|
+
'textColor',
|
|
70
|
+
'zIndex'
|
|
71
|
+
])
|
|
72
|
+
})(({ theme, width, maxWidth, textAlign = 'center', bgColor, textColor, zIndex })=>{
|
|
73
|
+
const { tooltip, font } = theme;
|
|
74
|
+
const bgTheme = tooltip.background;
|
|
75
|
+
const backgroundColor = bgColor || bgTheme;
|
|
76
|
+
return {
|
|
77
|
+
backgroundColor,
|
|
78
|
+
boxShadow: theme.elevation1,
|
|
79
|
+
color: textColor || tooltip.color.default,
|
|
80
|
+
fontSize: font.size.sm,
|
|
81
|
+
fontFamily: font.family.default,
|
|
82
|
+
borderRadius: 4,
|
|
83
|
+
width,
|
|
84
|
+
maxWidth,
|
|
85
|
+
padding: 16,
|
|
86
|
+
textAlign,
|
|
87
|
+
zIndex,
|
|
88
|
+
'& .react-aria-OverlayArrow svg': {
|
|
89
|
+
display: 'block',
|
|
90
|
+
fill: backgroundColor,
|
|
91
|
+
filter: 'drop-shadow(0px 4px 2px rgba(0, 0, 0, 0.1))'
|
|
92
|
+
},
|
|
93
|
+
'&[data-placement=top]': {
|
|
94
|
+
'--origin': 'translateY(4px)'
|
|
95
|
+
},
|
|
96
|
+
'&[data-placement=bottom]': {
|
|
97
|
+
'--origin': 'translateY(-4px)',
|
|
98
|
+
boxShadow: '0px -1px 4px 2px rgba(0, 0, 0, 0.1)',
|
|
99
|
+
'& .react-aria-OverlayArrow svg': {
|
|
100
|
+
transform: 'rotate(180deg)'
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
'&[data-placement=right]': {
|
|
104
|
+
'--origin': 'translateX(-4px)',
|
|
105
|
+
boxShadow: '2px 0px 4px 2px rgba(0, 0, 0, 0.1)',
|
|
106
|
+
'& .react-aria-OverlayArrow svg': {
|
|
107
|
+
transform: 'rotate(90deg)',
|
|
108
|
+
filter: 'drop-shadow(0px 2px 2px rgba(0, 0, 0, 0.1))'
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
'&[data-placement=left]': {
|
|
112
|
+
'--origin': 'translateX(4px)',
|
|
113
|
+
boxShadow: '-2px 0px 4px 2px rgba(0, 0, 0, 0.1)',
|
|
114
|
+
'& .react-aria-OverlayArrow svg': {
|
|
115
|
+
transform: 'rotate(-90deg)',
|
|
116
|
+
filter: 'drop-shadow(0px 2px 2px rgba(0, 0, 0, 0.1))'
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
'&[data-entering]': {
|
|
120
|
+
animation: `${slide} ${time}`
|
|
121
|
+
},
|
|
122
|
+
'&[data-exiting]': {
|
|
123
|
+
animation: `${slide} ${time} reverse`
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
const TooltipHeader = styled.div(({ theme })=>({
|
|
128
|
+
color: theme.tooltip.color.default
|
|
129
|
+
}));
|
|
130
|
+
const TooltipBody = styled.div(({ theme })=>({
|
|
131
|
+
color: theme.tooltip.color.subtext
|
|
132
|
+
}));
|
|
133
|
+
Tooltip_Tooltip.Header = TooltipHeader;
|
|
134
|
+
Tooltip_Tooltip.Body = TooltipBody;
|
|
135
|
+
const components_Tooltip = Tooltip_Tooltip;
|
|
136
|
+
export { components_Tooltip as default };
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { isEqual } from "es-toolkit/predicate";
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
import Button from "./Button/index.js";
|
|
6
|
+
import { marginProps } from "./helpers/styledProps.js";
|
|
7
|
+
import Icon from "./Icon/index.js";
|
|
8
|
+
const TransferList = ({ items, onChange, beforeItemChange, listTitle, noItemsMessage = 'No items', hideSelectAll, hideRemoveAll, readOnly, width, ...rest })=>{
|
|
9
|
+
const itemsRef = useRef([]);
|
|
10
|
+
const [base, setBase] = useState([]);
|
|
11
|
+
const [selected, setSelected] = useState([]);
|
|
12
|
+
const removeSelected = (item)=>{
|
|
13
|
+
const newItem = {
|
|
14
|
+
...item
|
|
15
|
+
};
|
|
16
|
+
newItem.selected = void 0;
|
|
17
|
+
return newItem;
|
|
18
|
+
};
|
|
19
|
+
useEffect(()=>{
|
|
20
|
+
if (!isEqual(items, itemsRef.current)) {
|
|
21
|
+
itemsRef.current = items;
|
|
22
|
+
const initialSelected = items.filter((item)=>item.selected).map(removeSelected);
|
|
23
|
+
const initialBase = items.filter((item)=>!item.selected).map(removeSelected);
|
|
24
|
+
setSelected(initialSelected);
|
|
25
|
+
setBase(initialBase);
|
|
26
|
+
}
|
|
27
|
+
}, [
|
|
28
|
+
items,
|
|
29
|
+
itemsRef
|
|
30
|
+
]);
|
|
31
|
+
useEffect(()=>{
|
|
32
|
+
onChange(selected);
|
|
33
|
+
}, [
|
|
34
|
+
selected
|
|
35
|
+
]);
|
|
36
|
+
const filterItem = (array, itemToFilter)=>array.filter((item)=>item.id !== itemToFilter.id);
|
|
37
|
+
const doAction = (itemToMove, action)=>{
|
|
38
|
+
const isSelect = 'select' === action;
|
|
39
|
+
const removeAction = isSelect ? setBase : setSelected;
|
|
40
|
+
const addAction = isSelect ? setSelected : setBase;
|
|
41
|
+
removeAction((prevArray)=>filterItem(prevArray, itemToMove));
|
|
42
|
+
addAction((prevArray)=>[
|
|
43
|
+
...prevArray,
|
|
44
|
+
itemToMove
|
|
45
|
+
]);
|
|
46
|
+
};
|
|
47
|
+
const moveItem = (itemToMove, action)=>{
|
|
48
|
+
const next = (newItem)=>doAction(newItem || itemToMove, action);
|
|
49
|
+
if (beforeItemChange) beforeItemChange(itemToMove, action, next);
|
|
50
|
+
else next();
|
|
51
|
+
};
|
|
52
|
+
const moveAllItems = (action)=>{
|
|
53
|
+
const removeAction = 'select' === action ? setBase : setSelected;
|
|
54
|
+
const addAction = 'select' === action ? setSelected : setBase;
|
|
55
|
+
const itemsToMove = 'select' === action ? base : selected;
|
|
56
|
+
addAction((prevArray)=>[
|
|
57
|
+
...prevArray,
|
|
58
|
+
...itemsToMove
|
|
59
|
+
]);
|
|
60
|
+
removeAction([]);
|
|
61
|
+
};
|
|
62
|
+
const itemContents = (item)=>/*#__PURE__*/ jsxs("div", {
|
|
63
|
+
style: {
|
|
64
|
+
display: 'flex',
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
columnGap: 8
|
|
67
|
+
},
|
|
68
|
+
children: [
|
|
69
|
+
item.leftElement || null,
|
|
70
|
+
item.header && item.body ? /*#__PURE__*/ jsxs("div", {
|
|
71
|
+
style: {
|
|
72
|
+
display: 'flex',
|
|
73
|
+
flexDirection: 'column'
|
|
74
|
+
},
|
|
75
|
+
children: [
|
|
76
|
+
/*#__PURE__*/ jsx(ItemHeader, {
|
|
77
|
+
children: item.header
|
|
78
|
+
}),
|
|
79
|
+
/*#__PURE__*/ jsx(ItemSubtext, {
|
|
80
|
+
children: item.body
|
|
81
|
+
})
|
|
82
|
+
]
|
|
83
|
+
}) : item.label,
|
|
84
|
+
item.rightElement && /*#__PURE__*/ jsx("div", {
|
|
85
|
+
style: {
|
|
86
|
+
marginLeft: 'auto'
|
|
87
|
+
},
|
|
88
|
+
children: item.rightElement
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
});
|
|
92
|
+
const keepButtonContainer = !(hideSelectAll && hideRemoveAll);
|
|
93
|
+
return /*#__PURE__*/ jsxs(TransferContainer, {
|
|
94
|
+
width: width,
|
|
95
|
+
readOnly: readOnly,
|
|
96
|
+
...rest,
|
|
97
|
+
children: [
|
|
98
|
+
listTitle && /*#__PURE__*/ jsx(Title, {
|
|
99
|
+
children: listTitle
|
|
100
|
+
}),
|
|
101
|
+
/*#__PURE__*/ jsxs(HalvesWrapper, {
|
|
102
|
+
children: [
|
|
103
|
+
!readOnly && /*#__PURE__*/ jsxs(Half, {
|
|
104
|
+
children: [
|
|
105
|
+
keepButtonContainer && /*#__PURE__*/ jsx(ButtonContainer, {
|
|
106
|
+
children: base.length > 0 && !hideSelectAll && /*#__PURE__*/ jsx(Button, {
|
|
107
|
+
small: true,
|
|
108
|
+
outline: true,
|
|
109
|
+
onClick: ()=>moveAllItems('select'),
|
|
110
|
+
icon: "arrow-right",
|
|
111
|
+
iconPosition: "right",
|
|
112
|
+
children: "All"
|
|
113
|
+
})
|
|
114
|
+
}),
|
|
115
|
+
/*#__PURE__*/ jsx(List, {
|
|
116
|
+
children: base.map((item)=>/*#__PURE__*/ jsxs(ListItem, {
|
|
117
|
+
onClick: ()=>moveItem(item, 'select'),
|
|
118
|
+
color: item.color,
|
|
119
|
+
children: [
|
|
120
|
+
itemContents(item),
|
|
121
|
+
/*#__PURE__*/ jsx(Icon, {
|
|
122
|
+
name: "chevron-right"
|
|
123
|
+
})
|
|
124
|
+
]
|
|
125
|
+
}, item.id))
|
|
126
|
+
})
|
|
127
|
+
]
|
|
128
|
+
}),
|
|
129
|
+
/*#__PURE__*/ jsxs(Half, {
|
|
130
|
+
children: [
|
|
131
|
+
keepButtonContainer && !readOnly && /*#__PURE__*/ jsx(ButtonContainer, {
|
|
132
|
+
children: selected.length > 0 && !hideRemoveAll && !readOnly && /*#__PURE__*/ jsx(Button, {
|
|
133
|
+
small: true,
|
|
134
|
+
outline: true,
|
|
135
|
+
secondary: true,
|
|
136
|
+
onClick: ()=>moveAllItems('remove'),
|
|
137
|
+
icon: "arrow-left",
|
|
138
|
+
children: "All"
|
|
139
|
+
})
|
|
140
|
+
}),
|
|
141
|
+
readOnly && 0 === selected.length ? /*#__PURE__*/ jsx("div", {
|
|
142
|
+
children: noItemsMessage
|
|
143
|
+
}) : /*#__PURE__*/ jsx(List, {
|
|
144
|
+
children: selected.map((item)=>/*#__PURE__*/ jsxs(ListItem, {
|
|
145
|
+
onClick: ()=>moveItem(item, 'remove'),
|
|
146
|
+
color: item.color,
|
|
147
|
+
children: [
|
|
148
|
+
itemContents(item),
|
|
149
|
+
/*#__PURE__*/ jsx(Icon, {
|
|
150
|
+
name: "chevron-left"
|
|
151
|
+
})
|
|
152
|
+
]
|
|
153
|
+
}, item.id))
|
|
154
|
+
})
|
|
155
|
+
]
|
|
156
|
+
})
|
|
157
|
+
]
|
|
158
|
+
})
|
|
159
|
+
]
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
const TransferContainer = styled.div(({ width, readOnly })=>({
|
|
163
|
+
display: 'flex',
|
|
164
|
+
flexDirection: 'column',
|
|
165
|
+
rowGap: 16,
|
|
166
|
+
width,
|
|
167
|
+
pointerEvents: readOnly ? 'none' : void 0
|
|
168
|
+
}), marginProps);
|
|
169
|
+
const Title = styled.div(({ theme })=>({
|
|
170
|
+
fontSize: theme.font.size.lg,
|
|
171
|
+
fontWeight: theme.font.weight.medium
|
|
172
|
+
}));
|
|
173
|
+
const HalvesWrapper = styled.div({
|
|
174
|
+
display: 'grid',
|
|
175
|
+
columnGap: 16,
|
|
176
|
+
gridTemplateColumns: '1fr 1fr'
|
|
177
|
+
});
|
|
178
|
+
const Half = styled.div({
|
|
179
|
+
display: 'flex',
|
|
180
|
+
flexDirection: 'column'
|
|
181
|
+
});
|
|
182
|
+
const ButtonContainer = styled.div({
|
|
183
|
+
display: 'flex',
|
|
184
|
+
alignItems: 'center',
|
|
185
|
+
marginBottom: 8,
|
|
186
|
+
minHeight: 35
|
|
187
|
+
});
|
|
188
|
+
const List = styled.div(({ theme })=>({
|
|
189
|
+
display: 'flex',
|
|
190
|
+
flexDirection: 'column',
|
|
191
|
+
padding: 16,
|
|
192
|
+
border: theme.defaultBorder,
|
|
193
|
+
borderRadius: 4,
|
|
194
|
+
height: '100%',
|
|
195
|
+
backgroundColor: theme.background1,
|
|
196
|
+
rowGap: 4
|
|
197
|
+
}));
|
|
198
|
+
const isThemeColor = (themeColors, color)=>{
|
|
199
|
+
const colorKeys = Object.keys(themeColors);
|
|
200
|
+
return 'string' == typeof color && colorKeys.includes(color);
|
|
201
|
+
};
|
|
202
|
+
const ListItem = styled.div(({ theme, color })=>{
|
|
203
|
+
let borderColor = theme.scale1;
|
|
204
|
+
if (color) borderColor = isThemeColor(theme.color, color) ? theme.color[color] : color;
|
|
205
|
+
return {
|
|
206
|
+
display: 'flex',
|
|
207
|
+
justifyContent: 'space-between',
|
|
208
|
+
alignItems: 'center',
|
|
209
|
+
padding: '4px 8px',
|
|
210
|
+
cursor: 'pointer',
|
|
211
|
+
background: theme.scale0,
|
|
212
|
+
borderLeft: '4px solid',
|
|
213
|
+
borderColor,
|
|
214
|
+
'&:hover': {
|
|
215
|
+
background: theme.scale1
|
|
216
|
+
},
|
|
217
|
+
'& > :last-child': {
|
|
218
|
+
visibility: 'hidden'
|
|
219
|
+
},
|
|
220
|
+
'&:hover > :last-child': {
|
|
221
|
+
visibility: 'visible'
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
});
|
|
225
|
+
const ItemHeader = styled.div(({ theme })=>({
|
|
226
|
+
fontSize: theme.font.size.lg,
|
|
227
|
+
color: theme.scale10
|
|
228
|
+
}));
|
|
229
|
+
const ItemSubtext = styled.div(({ theme })=>({
|
|
230
|
+
fontSize: theme.font.size.sm,
|
|
231
|
+
color: theme.scale6
|
|
232
|
+
}));
|
|
233
|
+
const components_TransferList = TransferList;
|
|
234
|
+
export { components_TransferList as default };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { useCallback, useMemo, useState } from "react";
|
|
4
|
+
import { Tree } from "react-aria-components";
|
|
5
|
+
import { paddingProps } from "../helpers/styledProps.js";
|
|
6
|
+
import { TreeContext } from "./TreeContext.js";
|
|
7
|
+
import TreeItem from "./TreeItem.js";
|
|
8
|
+
const Tree_Tree = ({ backgroundColor, expandedKeys: expandedKeysProp, onExpandedChange, defaultExpandedKeys, selectedKeys, onSelectionChange, ...props })=>{
|
|
9
|
+
const initialExpanded = new Set(defaultExpandedKeys ?? []);
|
|
10
|
+
const [internalExpandedKeys, setInternalExpandedKeys] = useState(initialExpanded);
|
|
11
|
+
const isControlled = void 0 !== expandedKeysProp;
|
|
12
|
+
const expandedKeys = isControlled ? expandedKeysProp : internalExpandedKeys;
|
|
13
|
+
const handleExpandedChange = useCallback((keys)=>{
|
|
14
|
+
if (onExpandedChange) onExpandedChange(keys);
|
|
15
|
+
if (!isControlled) setInternalExpandedKeys(keys);
|
|
16
|
+
}, [
|
|
17
|
+
isControlled,
|
|
18
|
+
onExpandedChange
|
|
19
|
+
]);
|
|
20
|
+
const requestExpand = useCallback((keys)=>{
|
|
21
|
+
if (!keys.length) return;
|
|
22
|
+
if ('all' === expandedKeys) return;
|
|
23
|
+
const next = new Set(expandedKeys);
|
|
24
|
+
keys.forEach((k)=>{
|
|
25
|
+
next.add(k);
|
|
26
|
+
});
|
|
27
|
+
handleExpandedChange(next);
|
|
28
|
+
}, [
|
|
29
|
+
expandedKeys,
|
|
30
|
+
handleExpandedChange
|
|
31
|
+
]);
|
|
32
|
+
const handleSelectionChange = useCallback((keys)=>{
|
|
33
|
+
if ('all' === keys) return;
|
|
34
|
+
onSelectionChange?.(keys);
|
|
35
|
+
}, [
|
|
36
|
+
onSelectionChange
|
|
37
|
+
]);
|
|
38
|
+
const ctx = useMemo(()=>({
|
|
39
|
+
requestExpand
|
|
40
|
+
}), [
|
|
41
|
+
requestExpand
|
|
42
|
+
]);
|
|
43
|
+
return /*#__PURE__*/ jsx(TreeContext.Provider, {
|
|
44
|
+
value: ctx,
|
|
45
|
+
children: /*#__PURE__*/ jsx(TreeContainer, {
|
|
46
|
+
selectionMode: "single",
|
|
47
|
+
disallowEmptySelection: true,
|
|
48
|
+
backgroundColor: backgroundColor,
|
|
49
|
+
expandedKeys: expandedKeys,
|
|
50
|
+
onExpandedChange: handleExpandedChange,
|
|
51
|
+
selectedKeys: selectedKeys,
|
|
52
|
+
onSelectionChange: handleSelectionChange,
|
|
53
|
+
...props,
|
|
54
|
+
children: props.children
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
Tree_Tree.Item = TreeItem;
|
|
59
|
+
const TreeContainer = styled(Tree)(({ theme: { menu }, width, height, backgroundColor })=>({
|
|
60
|
+
display: 'flex',
|
|
61
|
+
flexFlow: 'column',
|
|
62
|
+
overflowY: 'auto',
|
|
63
|
+
backgroundColor: backgroundColor || menu.background,
|
|
64
|
+
padding: '8px 0',
|
|
65
|
+
width: width || '100%',
|
|
66
|
+
height
|
|
67
|
+
}), paddingProps);
|
|
68
|
+
const components_Tree_Tree = Tree_Tree;
|
|
69
|
+
export { components_Tree_Tree as default };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
import { TreeItem, TreeItemContent } from "react-aria-components";
|
|
5
|
+
import getIcon from "../helpers/getIcon.js";
|
|
6
|
+
import Icon from "../Icon/index.js";
|
|
7
|
+
import AriaButton from "../Inputs/helpers/AriaButton.js";
|
|
8
|
+
import { TreeContext } from "./TreeContext.js";
|
|
9
|
+
const Item = ({ children, title, id, iconLeft, iconRight, expandOnSelect, indent, content, ...props })=>{
|
|
10
|
+
const { requestExpand } = useContext(TreeContext);
|
|
11
|
+
return /*#__PURE__*/ jsxs(TreeItemContainer, {
|
|
12
|
+
id: id || title,
|
|
13
|
+
textValue: title,
|
|
14
|
+
indent: indent,
|
|
15
|
+
...expandOnSelect && children ? {
|
|
16
|
+
onPress: ()=>{
|
|
17
|
+
requestExpand?.([
|
|
18
|
+
id || title
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
21
|
+
} : {},
|
|
22
|
+
...props,
|
|
23
|
+
children: [
|
|
24
|
+
/*#__PURE__*/ jsxs(Content, {
|
|
25
|
+
children: [
|
|
26
|
+
iconLeft && getIcon(iconLeft),
|
|
27
|
+
title,
|
|
28
|
+
content,
|
|
29
|
+
iconRight && getIcon(iconRight),
|
|
30
|
+
children && /*#__PURE__*/ jsx(AriaButton, {
|
|
31
|
+
slot: "chevron",
|
|
32
|
+
children: /*#__PURE__*/ jsx(Icon, {
|
|
33
|
+
name: "chevron-right"
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
]
|
|
37
|
+
}),
|
|
38
|
+
children
|
|
39
|
+
]
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
const Content = (props)=>/*#__PURE__*/ jsx(TreeItemContent, {
|
|
43
|
+
...props,
|
|
44
|
+
children: props.children
|
|
45
|
+
});
|
|
46
|
+
const TreeItemContainer = styled(TreeItem)(({ theme: { accent, font, menuItem }, indent = 1 })=>({
|
|
47
|
+
userSelect: 'none',
|
|
48
|
+
border: 'none',
|
|
49
|
+
display: 'flex',
|
|
50
|
+
alignItems: 'center',
|
|
51
|
+
gap: 8,
|
|
52
|
+
color: menuItem.color.inactive,
|
|
53
|
+
backgroundColor: menuItem.background.inactive,
|
|
54
|
+
borderLeft: '4px solid transparent',
|
|
55
|
+
cursor: 'pointer',
|
|
56
|
+
fontSize: font.size.lg,
|
|
57
|
+
paddingLeft: `calc(var(--tree-item-level) * ${16 * indent}px)`,
|
|
58
|
+
paddingRight: 8,
|
|
59
|
+
minHeight: 40,
|
|
60
|
+
'&[data-selected]': {
|
|
61
|
+
backgroundColor: menuItem.background.active,
|
|
62
|
+
color: menuItem.color.active,
|
|
63
|
+
borderLeftColor: menuItem.borderColor
|
|
64
|
+
},
|
|
65
|
+
'&[data-disabled]': {
|
|
66
|
+
color: menuItem.color.inactive,
|
|
67
|
+
backgroundColor: menuItem.background.inactive,
|
|
68
|
+
cursor: 'not-allowed'
|
|
69
|
+
},
|
|
70
|
+
'&[data-hovered]': {
|
|
71
|
+
backgroundColor: menuItem.background.hover,
|
|
72
|
+
color: menuItem.color.hover
|
|
73
|
+
},
|
|
74
|
+
'&:focus-visible': {
|
|
75
|
+
outline: `${accent} solid 1px`,
|
|
76
|
+
outlineOffset: -1
|
|
77
|
+
},
|
|
78
|
+
'& > div > button[slot="chevron"]': {
|
|
79
|
+
marginLeft: 'auto',
|
|
80
|
+
transition: 'transform 0.2s ease-in-out'
|
|
81
|
+
},
|
|
82
|
+
'&[data-expanded] > div > button[slot="chevron"]': {
|
|
83
|
+
transform: 'rotate(90deg)'
|
|
84
|
+
},
|
|
85
|
+
'&[data-level="2"]': {
|
|
86
|
+
fontSize: font.size.md
|
|
87
|
+
},
|
|
88
|
+
'&[data-level="3"]': {
|
|
89
|
+
fontSize: font.size.sm
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
const Tree_TreeItem = Item;
|
|
93
|
+
export { Tree_TreeItem as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from "react-aria-components";
|
|
3
|
+
const UnstyledButton_UnstyledButton = ({ children, ...props })=>/*#__PURE__*/ jsx(Button, {
|
|
4
|
+
...props,
|
|
5
|
+
children: children
|
|
6
|
+
});
|
|
7
|
+
const UnstyledButton = UnstyledButton_UnstyledButton;
|
|
8
|
+
export { UnstyledButton as default };
|