@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,359 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { isSameDay } from "@internationalized/date";
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
import { DialogTrigger, GridList } from "react-aria-components";
|
|
6
|
+
import { useControlledOpenState, useEventListener } from "../hooks/index.js";
|
|
7
|
+
import { getDateFromObj, getNow, getObjFromDate } from "./CalendarParts/utils.js";
|
|
8
|
+
import DateRangePicker from "./Inputs/DateRangePicker.js";
|
|
9
|
+
import AriaButton from "./Inputs/helpers/AriaButton.js";
|
|
10
|
+
import TextInput from "./Inputs/TextInput.js";
|
|
11
|
+
import GridListItem from "./ListBoxParts/GridListItem.js";
|
|
12
|
+
import ListStyles from "./ListHelpers/ListStyles.js";
|
|
13
|
+
import MotionPopover from "./MotionPopover.js";
|
|
14
|
+
import Radio from "./Radio.js";
|
|
15
|
+
const rangeOptions = [
|
|
16
|
+
{
|
|
17
|
+
id: 'today',
|
|
18
|
+
value: 'Today'
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 'yesterday',
|
|
22
|
+
value: 'Yesterday'
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: 'thisWeek',
|
|
26
|
+
value: 'This Week'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: 'lastWeek',
|
|
30
|
+
value: 'Last Week'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: 'lastMonth',
|
|
34
|
+
value: 'Last Month'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'last3Months',
|
|
38
|
+
value: 'Last 3 Months'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'last6Months',
|
|
42
|
+
value: 'Last 6 Months'
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'lastYear',
|
|
46
|
+
value: 'Last Year'
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: 'custom',
|
|
50
|
+
value: 'Custom'
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
const getThisWeekRange = (now)=>{
|
|
54
|
+
const daysSinceSunday = getDateFromObj(now).getDay();
|
|
55
|
+
const weekStart = now.subtract({
|
|
56
|
+
days: daysSinceSunday
|
|
57
|
+
});
|
|
58
|
+
const weekEnd = weekStart.add({
|
|
59
|
+
days: 6
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
start: weekStart,
|
|
63
|
+
end: weekEnd
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
const getLastWeekRange = (now)=>{
|
|
67
|
+
const daysSinceSunday = getDateFromObj(now).getDay();
|
|
68
|
+
const currentWeekStart = now.subtract({
|
|
69
|
+
days: daysSinceSunday
|
|
70
|
+
});
|
|
71
|
+
const lastWeekStart = currentWeekStart.subtract({
|
|
72
|
+
days: 7
|
|
73
|
+
});
|
|
74
|
+
const lastWeekEnd = lastWeekStart.add({
|
|
75
|
+
days: 6
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
start: lastWeekStart,
|
|
79
|
+
end: lastWeekEnd
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
const getLastNMonthsRange = (now, months)=>{
|
|
83
|
+
const currentMonthStart = now.set({
|
|
84
|
+
day: 1
|
|
85
|
+
});
|
|
86
|
+
const start = currentMonthStart.subtract({
|
|
87
|
+
months
|
|
88
|
+
});
|
|
89
|
+
const end = currentMonthStart.subtract({
|
|
90
|
+
days: 1
|
|
91
|
+
});
|
|
92
|
+
return {
|
|
93
|
+
start,
|
|
94
|
+
end
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
const getRangeIdFromDates = ({ start, end })=>{
|
|
98
|
+
const today = getNow();
|
|
99
|
+
const startDate = getObjFromDate(start);
|
|
100
|
+
const endDate = getObjFromDate(end);
|
|
101
|
+
if (isSameDay(startDate, today) && isSameDay(endDate, today)) return 'today';
|
|
102
|
+
const yesterday = today.subtract({
|
|
103
|
+
days: 1
|
|
104
|
+
});
|
|
105
|
+
if (isSameDay(startDate, yesterday) && isSameDay(endDate, yesterday)) return 'yesterday';
|
|
106
|
+
const thisWeek = getThisWeekRange(today);
|
|
107
|
+
if (isSameDay(startDate, thisWeek.start) && isSameDay(endDate, thisWeek.end)) return 'thisWeek';
|
|
108
|
+
const lastWeek = getLastWeekRange(today);
|
|
109
|
+
if (isSameDay(startDate, lastWeek.start) && isSameDay(endDate, lastWeek.end)) return 'lastWeek';
|
|
110
|
+
const lastMonth = getLastNMonthsRange(today, 1);
|
|
111
|
+
if (isSameDay(startDate, lastMonth.start) && isSameDay(endDate, lastMonth.end)) return 'lastMonth';
|
|
112
|
+
const last3Months = getLastNMonthsRange(today, 3);
|
|
113
|
+
if (isSameDay(startDate, last3Months.start) && isSameDay(endDate, last3Months.end)) return 'last3Months';
|
|
114
|
+
const last6Months = getLastNMonthsRange(today, 6);
|
|
115
|
+
if (isSameDay(startDate, last6Months.start) && isSameDay(endDate, last6Months.end)) return 'last6Months';
|
|
116
|
+
const lastYear = getLastNMonthsRange(today, 12);
|
|
117
|
+
if (isSameDay(startDate, lastYear.start) && isSameDay(endDate, lastYear.end)) return 'lastYear';
|
|
118
|
+
return 'custom';
|
|
119
|
+
};
|
|
120
|
+
const getDisplayValue = (range)=>{
|
|
121
|
+
const start = range.start.toLocaleDateString();
|
|
122
|
+
const end = range.end.toLocaleDateString();
|
|
123
|
+
if (start === end) return start;
|
|
124
|
+
return `${start} - ${end}`;
|
|
125
|
+
};
|
|
126
|
+
const DateRangeSelect = ({ children, open, label, placeholder = 'Select', width, loading, hideCaret, color, disabled, readOnly, placeholderColor, fontSize, fontWeight, description, errorMessage, position, backgroundColor, iconLeft, value, preventPast, preventFuture, hide, onChange, onOpenChange, afterShow, afterHide, ...props })=>{
|
|
127
|
+
const [isOpen, handleOpenChange] = useControlledOpenState({
|
|
128
|
+
open,
|
|
129
|
+
onOpenChange,
|
|
130
|
+
afterShow,
|
|
131
|
+
afterHide
|
|
132
|
+
});
|
|
133
|
+
const [displayValue, setDisplayValue] = useState();
|
|
134
|
+
const [selectedOptionId, setSelectedOptionId] = useState();
|
|
135
|
+
const [customDateRange, setCustomDateRange] = useState(()=>{
|
|
136
|
+
const now = getNow();
|
|
137
|
+
const yesterday = now.subtract({
|
|
138
|
+
days: 1
|
|
139
|
+
});
|
|
140
|
+
return {
|
|
141
|
+
start: getDateFromObj(yesterday),
|
|
142
|
+
end: getDateFromObj(now)
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
const filteredRangeOptions = hide ? rangeOptions.filter(({ id })=>{
|
|
146
|
+
const hideArray = Array.isArray(hide) ? hide : [
|
|
147
|
+
hide
|
|
148
|
+
];
|
|
149
|
+
return !hideArray.includes(id);
|
|
150
|
+
}) : rangeOptions;
|
|
151
|
+
useEffect(()=>{
|
|
152
|
+
if (hide && 1 === filteredRangeOptions.length && 'custom' === filteredRangeOptions[0].id) setSelectedOptionId('custom');
|
|
153
|
+
}, [
|
|
154
|
+
hide,
|
|
155
|
+
filteredRangeOptions
|
|
156
|
+
]);
|
|
157
|
+
useEffect(()=>{
|
|
158
|
+
if (value?.start && value?.end) {
|
|
159
|
+
const optionId = getRangeIdFromDates(value);
|
|
160
|
+
setSelectedOptionId(optionId);
|
|
161
|
+
if ('custom' === optionId) setCustomDateRange(value);
|
|
162
|
+
setDisplayValue(getDisplayValue(value));
|
|
163
|
+
}
|
|
164
|
+
}, [
|
|
165
|
+
value
|
|
166
|
+
]);
|
|
167
|
+
const triggerRef = useRef(null);
|
|
168
|
+
const listRef = useRef(null);
|
|
169
|
+
const handleDateRangeChange = (start, end)=>{
|
|
170
|
+
start.setHours(0, 0, 0, 0);
|
|
171
|
+
end.setHours(23, 59, 59, 999);
|
|
172
|
+
setCustomDateRange({
|
|
173
|
+
start,
|
|
174
|
+
end
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
const handleRangeOptionChange = (optionId)=>{
|
|
178
|
+
setSelectedOptionId(optionId);
|
|
179
|
+
if ('custom' !== optionId) {
|
|
180
|
+
saveChanges(optionId);
|
|
181
|
+
handleOpenChange(false);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
const saveChanges = (id)=>{
|
|
185
|
+
let dateRange = customDateRange;
|
|
186
|
+
const optionId = id || selectedOptionId;
|
|
187
|
+
if (!optionId) return;
|
|
188
|
+
if ('custom' !== optionId) {
|
|
189
|
+
const now = getNow();
|
|
190
|
+
let range;
|
|
191
|
+
switch(optionId){
|
|
192
|
+
case 'today':
|
|
193
|
+
range = {
|
|
194
|
+
start: now,
|
|
195
|
+
end: now
|
|
196
|
+
};
|
|
197
|
+
break;
|
|
198
|
+
case 'yesterday':
|
|
199
|
+
{
|
|
200
|
+
const yesterday = now.subtract({
|
|
201
|
+
days: 1
|
|
202
|
+
});
|
|
203
|
+
range = {
|
|
204
|
+
start: yesterday,
|
|
205
|
+
end: yesterday
|
|
206
|
+
};
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
case 'thisWeek':
|
|
210
|
+
range = getThisWeekRange(now);
|
|
211
|
+
break;
|
|
212
|
+
case 'lastWeek':
|
|
213
|
+
range = getLastWeekRange(now);
|
|
214
|
+
break;
|
|
215
|
+
case 'lastMonth':
|
|
216
|
+
range = getLastNMonthsRange(now, 1);
|
|
217
|
+
break;
|
|
218
|
+
case 'last3Months':
|
|
219
|
+
range = getLastNMonthsRange(now, 3);
|
|
220
|
+
break;
|
|
221
|
+
case 'last6Months':
|
|
222
|
+
range = getLastNMonthsRange(now, 6);
|
|
223
|
+
break;
|
|
224
|
+
case 'lastYear':
|
|
225
|
+
range = getLastNMonthsRange(now, 12);
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
const startDate = getDateFromObj(range.start);
|
|
229
|
+
const endDate = getDateFromObj(range.end);
|
|
230
|
+
startDate.setHours(0, 0, 0, 0);
|
|
231
|
+
endDate.setHours(23, 59, 59, 999);
|
|
232
|
+
dateRange = {
|
|
233
|
+
start: startDate,
|
|
234
|
+
end: endDate
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
const newDisplayValue = getDisplayValue(dateRange);
|
|
238
|
+
setDisplayValue(newDisplayValue);
|
|
239
|
+
if (newDisplayValue !== displayValue) {
|
|
240
|
+
const start = new Date(dateRange.start);
|
|
241
|
+
const end = new Date(dateRange.end);
|
|
242
|
+
const timezoneOffset = end.getTimezoneOffset();
|
|
243
|
+
end.setMinutes(end.getMinutes() - timezoneOffset);
|
|
244
|
+
onChange({
|
|
245
|
+
start,
|
|
246
|
+
end
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
const handlePopoverOpenChange = (show)=>{
|
|
251
|
+
handleOpenChange(show);
|
|
252
|
+
if (!show && selectedOptionId) saveChanges();
|
|
253
|
+
};
|
|
254
|
+
const handleEscape = (e)=>{
|
|
255
|
+
if ('Escape' === e.key) handlePopoverOpenChange(false);
|
|
256
|
+
};
|
|
257
|
+
useEventListener(listRef, 'keydown', handleEscape, isOpen, [
|
|
258
|
+
saveChanges
|
|
259
|
+
]);
|
|
260
|
+
return /*#__PURE__*/ jsxs(DialogTrigger, {
|
|
261
|
+
isOpen: isOpen,
|
|
262
|
+
onOpenChange: handlePopoverOpenChange,
|
|
263
|
+
children: [
|
|
264
|
+
/*#__PURE__*/ jsx(InputWrapper, {
|
|
265
|
+
...props,
|
|
266
|
+
ref: triggerRef,
|
|
267
|
+
width: width ?? '100%',
|
|
268
|
+
isDisabled: disabled || readOnly || loading,
|
|
269
|
+
backgroundColor: backgroundColor,
|
|
270
|
+
children: /*#__PURE__*/ jsx(TextInput, {
|
|
271
|
+
value: displayValue,
|
|
272
|
+
disabled: disabled,
|
|
273
|
+
readOnly: readOnly || loading,
|
|
274
|
+
placeholder: placeholder,
|
|
275
|
+
placeholderColor: placeholderColor,
|
|
276
|
+
loading: loading,
|
|
277
|
+
label: label,
|
|
278
|
+
description: description,
|
|
279
|
+
errorMessage: errorMessage,
|
|
280
|
+
fontSize: fontSize,
|
|
281
|
+
fontWeight: fontWeight,
|
|
282
|
+
backgroundColor: backgroundColor,
|
|
283
|
+
color: color,
|
|
284
|
+
iconLeft: iconLeft,
|
|
285
|
+
iconRight: hideCaret ? void 0 : isOpen ? 'caret-up' : 'caret-down',
|
|
286
|
+
paddingLeft: iconLeft ? 8 : void 0,
|
|
287
|
+
paddingRight: 8,
|
|
288
|
+
asTrigger: true
|
|
289
|
+
})
|
|
290
|
+
}),
|
|
291
|
+
/*#__PURE__*/ jsx(MotionPopover, {
|
|
292
|
+
triggerRef: triggerRef,
|
|
293
|
+
offset: 2,
|
|
294
|
+
placement: position,
|
|
295
|
+
children: ({ isEntering, isExiting })=>/*#__PURE__*/ jsxs(MenuContainer, {
|
|
296
|
+
width: width || triggerRef?.current?.offsetWidth,
|
|
297
|
+
readOnly: isEntering || isExiting,
|
|
298
|
+
children: [
|
|
299
|
+
/*#__PURE__*/ jsx(GridList, {
|
|
300
|
+
"aria-label": label || 'Date Range Select',
|
|
301
|
+
selectionMode: "single",
|
|
302
|
+
selectedKeys: selectedOptionId ? [
|
|
303
|
+
selectedOptionId
|
|
304
|
+
] : [],
|
|
305
|
+
onSelectionChange: (keys)=>{
|
|
306
|
+
const key = keys instanceof Set ? Array.from(keys)[0] : keys;
|
|
307
|
+
if (key) handleRangeOptionChange(key);
|
|
308
|
+
else handlePopoverOpenChange(false);
|
|
309
|
+
},
|
|
310
|
+
style: {
|
|
311
|
+
outline: 'none'
|
|
312
|
+
},
|
|
313
|
+
ref: listRef,
|
|
314
|
+
autoFocus: true,
|
|
315
|
+
children: filteredRangeOptions.map((option)=>/*#__PURE__*/ jsx(GridListItem, {
|
|
316
|
+
id: option.id,
|
|
317
|
+
value: option.value,
|
|
318
|
+
leftElement: /*#__PURE__*/ jsx(Radio, {
|
|
319
|
+
name: "wavv-ui-range-options",
|
|
320
|
+
marginRight: 8,
|
|
321
|
+
checked: selectedOptionId === option.id,
|
|
322
|
+
readOnly: true
|
|
323
|
+
})
|
|
324
|
+
}, option.id))
|
|
325
|
+
}),
|
|
326
|
+
'custom' === selectedOptionId && /*#__PURE__*/ jsx("div", {
|
|
327
|
+
style: {
|
|
328
|
+
padding: '8px 16px'
|
|
329
|
+
},
|
|
330
|
+
children: /*#__PURE__*/ jsx(DateRangePicker, {
|
|
331
|
+
startValue: customDateRange.start,
|
|
332
|
+
endValue: customDateRange.end,
|
|
333
|
+
onChange: handleDateRangeChange,
|
|
334
|
+
preventPast: preventPast,
|
|
335
|
+
preventFuture: preventFuture
|
|
336
|
+
})
|
|
337
|
+
})
|
|
338
|
+
]
|
|
339
|
+
})
|
|
340
|
+
})
|
|
341
|
+
]
|
|
342
|
+
});
|
|
343
|
+
};
|
|
344
|
+
const InputWrapper = styled(AriaButton)(({ theme: { input }, isDisabled, backgroundColor })=>({
|
|
345
|
+
cursor: isDisabled ? 'default' : void 0,
|
|
346
|
+
'&:hover > div': {
|
|
347
|
+
backgroundColor: isDisabled || backgroundColor ? void 0 : input.background.hover,
|
|
348
|
+
'& > label': {
|
|
349
|
+
color: isDisabled ? void 0 : input.labelColor.hover
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}));
|
|
353
|
+
const MenuContainer = styled.div(ListStyles, ({ readOnly })=>({
|
|
354
|
+
'& > div > *': {
|
|
355
|
+
pointerEvents: readOnly ? 'none' : void 0
|
|
356
|
+
}
|
|
357
|
+
}));
|
|
358
|
+
const components_DateRangeSelect = DateRangeSelect;
|
|
359
|
+
export { components_DateRangeSelect as default };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import styled from "@emotion/styled";
|
|
2
|
+
const Table = styled.table(({ theme })=>({
|
|
3
|
+
border: `1px solid ${theme.scale1}`,
|
|
4
|
+
borderSpacing: 0,
|
|
5
|
+
borderCollapse: 'separate',
|
|
6
|
+
borderRadius: theme.size.xs,
|
|
7
|
+
overflow: 'hidden',
|
|
8
|
+
width: '100%',
|
|
9
|
+
'& thead': {
|
|
10
|
+
backgroundColor: theme.scale1,
|
|
11
|
+
borderTopLeftRadius: theme.size.xs,
|
|
12
|
+
borderTopRightRadius: theme.size.xs
|
|
13
|
+
},
|
|
14
|
+
'& th, & td': {
|
|
15
|
+
border: 'none',
|
|
16
|
+
padding: 10,
|
|
17
|
+
textAlign: 'left'
|
|
18
|
+
},
|
|
19
|
+
'& td': {
|
|
20
|
+
borderTop: `1px solid ${theme.scale1}`,
|
|
21
|
+
lineHeight: '28px'
|
|
22
|
+
},
|
|
23
|
+
'& th': {
|
|
24
|
+
fontWeight: 'bold',
|
|
25
|
+
whiteSpace: 'nowrap'
|
|
26
|
+
},
|
|
27
|
+
'& td:not(:last-of-type)': {
|
|
28
|
+
whiteSpace: 'nowrap'
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
const DocTable = Table;
|
|
32
|
+
export { DocTable as default };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useTheme } from "@emotion/react";
|
|
3
|
+
import styled from "@emotion/styled";
|
|
4
|
+
import { marginProps, positionProps } from "./helpers/styledProps.js";
|
|
5
|
+
const Dot_Dot = ({ children, type, color, size = 'tiny', ...props })=>{
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
let dotColor = color || theme.color.brand;
|
|
8
|
+
let dotSize = size;
|
|
9
|
+
switch(size){
|
|
10
|
+
case 'tiny':
|
|
11
|
+
dotSize = 8;
|
|
12
|
+
break;
|
|
13
|
+
case 'small':
|
|
14
|
+
dotSize = 16;
|
|
15
|
+
break;
|
|
16
|
+
case 'medium':
|
|
17
|
+
dotSize = 24;
|
|
18
|
+
break;
|
|
19
|
+
case 'large':
|
|
20
|
+
dotSize = 32;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
if (type && !color) switch(type){
|
|
24
|
+
case 'error':
|
|
25
|
+
dotColor = theme.color.error;
|
|
26
|
+
break;
|
|
27
|
+
case 'success':
|
|
28
|
+
dotColor = theme.color.success;
|
|
29
|
+
break;
|
|
30
|
+
case 'warning':
|
|
31
|
+
dotColor = theme.color.warning;
|
|
32
|
+
break;
|
|
33
|
+
case 'alert':
|
|
34
|
+
dotColor = theme.color.alert;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
return /*#__PURE__*/ jsx(StyledDot, {
|
|
38
|
+
color: dotColor,
|
|
39
|
+
size: dotSize,
|
|
40
|
+
hasContent: !!children,
|
|
41
|
+
...props,
|
|
42
|
+
children: children
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
const StyledDot = styled.div(({ theme: { font, scale10 }, color, size, textColor })=>({
|
|
46
|
+
borderRadius: '50%',
|
|
47
|
+
backgroundColor: color,
|
|
48
|
+
width: size,
|
|
49
|
+
height: size,
|
|
50
|
+
minWidth: size,
|
|
51
|
+
minHeight: size,
|
|
52
|
+
display: 'flex',
|
|
53
|
+
alignItems: 'center',
|
|
54
|
+
justifyContent: 'center',
|
|
55
|
+
fontFamily: font.family.light,
|
|
56
|
+
fontSize: font.size.sm,
|
|
57
|
+
color: textColor || scale10
|
|
58
|
+
}), marginProps, positionProps);
|
|
59
|
+
const Dot = Dot_Dot;
|
|
60
|
+
export { Dot as default };
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { Editor, RichUtils } from "draft-js";
|
|
4
|
+
import { isEqual } from "es-toolkit/predicate";
|
|
5
|
+
import { useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
6
|
+
import { createStateWithContent, getEntities, getFocusStateAtEnd, getPastedState, getRawState, hasMissingEntities, insertFieldEntity } from "./draftUtils.js";
|
|
7
|
+
import { Description, InputContainer, InputWrapper, Label, isInputFilled, useInputFocus } from "./InputHelpers.js";
|
|
8
|
+
const DraftEditor_DraftEditor = ({ value, onChange, onEnterKey, onFocus, onBlur, mergeFields = [], placeholder = 'Text...', description, invalid, width, height, maxHeight, noPadding = false, readOnly = false, displayMergedValues = false, color, overflow, clampLines, label, disabled, borderRadius, backgroundColor, fontSize, textOnly, margin, marginLeft, marginRight, marginTop, marginBottom, ref, className, ...rest })=>{
|
|
9
|
+
const [editorState, setEditorState] = useState(()=>createStateWithContent(value, mergeFields, displayMergedValues));
|
|
10
|
+
const { focused, handleFocus, handleBlur } = useInputFocus(onFocus, onBlur);
|
|
11
|
+
const [missingField, setMissingField] = useState(false);
|
|
12
|
+
const editorRef = useRef(null);
|
|
13
|
+
const fieldsRef = useRef(mergeFields);
|
|
14
|
+
const heightVar = maxHeight ?? height;
|
|
15
|
+
const editorMaxHeight = heightVar;
|
|
16
|
+
const handleChange = (state)=>{
|
|
17
|
+
setEditorState(state);
|
|
18
|
+
const hasMissing = hasMissingEntities(state);
|
|
19
|
+
setMissingField(hasMissing);
|
|
20
|
+
const text = getRawState(state);
|
|
21
|
+
const reason = state.getLastChangeType();
|
|
22
|
+
if (onChange) onChange(text, hasMissing, reason);
|
|
23
|
+
};
|
|
24
|
+
const insertField = (field)=>{
|
|
25
|
+
const newState = insertFieldEntity(field, mergeFields, editorState, displayMergedValues);
|
|
26
|
+
handleChange(newState);
|
|
27
|
+
};
|
|
28
|
+
const focusAtEnd = ()=>{
|
|
29
|
+
if (editorRef?.current) editorRef.current.focus();
|
|
30
|
+
const atEnd = getFocusStateAtEnd(editorState);
|
|
31
|
+
setEditorState(atEnd);
|
|
32
|
+
};
|
|
33
|
+
useImperativeHandle(ref, ()=>({
|
|
34
|
+
insertField,
|
|
35
|
+
focusAtEnd
|
|
36
|
+
}));
|
|
37
|
+
const setEditorText = (text)=>{
|
|
38
|
+
const selection = editorState.getSelection();
|
|
39
|
+
const updatedState = createStateWithContent(text, mergeFields, displayMergedValues);
|
|
40
|
+
const updatedWithFocus = getFocusStateAtEnd(updatedState);
|
|
41
|
+
const newState = selection.getHasFocus() ? updatedWithFocus : updatedState;
|
|
42
|
+
handleChange(newState);
|
|
43
|
+
};
|
|
44
|
+
useEffect(()=>{
|
|
45
|
+
const editorText = getRawState(editorState);
|
|
46
|
+
if (editorText !== value) setEditorText(value);
|
|
47
|
+
}, [
|
|
48
|
+
value
|
|
49
|
+
]);
|
|
50
|
+
useEffect(()=>{
|
|
51
|
+
fieldsRef.current = mergeFields;
|
|
52
|
+
}, []);
|
|
53
|
+
useEffect(()=>{
|
|
54
|
+
const { current: prevFields } = fieldsRef;
|
|
55
|
+
const areEqual = isEqual(prevFields, mergeFields);
|
|
56
|
+
const entities = getEntities(editorState);
|
|
57
|
+
if (!areEqual && entities.length > 0) {
|
|
58
|
+
fieldsRef.current = mergeFields;
|
|
59
|
+
const newState = createStateWithContent(value, mergeFields, displayMergedValues);
|
|
60
|
+
handleChange(newState);
|
|
61
|
+
}
|
|
62
|
+
}, [
|
|
63
|
+
mergeFields
|
|
64
|
+
]);
|
|
65
|
+
const handleContainerClick = (event)=>{
|
|
66
|
+
if (!readOnly) event.stopPropagation();
|
|
67
|
+
const selection = editorState.getSelection();
|
|
68
|
+
if (!selection.getHasFocus()) focusAtEnd();
|
|
69
|
+
};
|
|
70
|
+
const handleEditorReturn = (event)=>{
|
|
71
|
+
const stateWithNewLine = RichUtils.insertSoftNewline(editorState);
|
|
72
|
+
if (event.shiftKey || !onEnterKey) handleChange(stateWithNewLine);
|
|
73
|
+
else onEnterKey(event);
|
|
74
|
+
return 'handled';
|
|
75
|
+
};
|
|
76
|
+
const handlePaste = (text, _html, state)=>{
|
|
77
|
+
const newState = getPastedState(text, state);
|
|
78
|
+
handleChange(newState);
|
|
79
|
+
return 'handled';
|
|
80
|
+
};
|
|
81
|
+
return /*#__PURE__*/ jsxs(EditorContainer, {
|
|
82
|
+
onClick: handleContainerClick,
|
|
83
|
+
width: width,
|
|
84
|
+
height: height,
|
|
85
|
+
editorMaxHeight: editorMaxHeight,
|
|
86
|
+
noPadding: noPadding || textOnly,
|
|
87
|
+
readOnly: readOnly,
|
|
88
|
+
color: color,
|
|
89
|
+
overflow: overflow,
|
|
90
|
+
clampLines: clampLines,
|
|
91
|
+
filled: isInputFilled(value),
|
|
92
|
+
invalid: invalid || missingField,
|
|
93
|
+
textOnly: textOnly,
|
|
94
|
+
borderRadius: borderRadius,
|
|
95
|
+
backgroundColor: backgroundColor,
|
|
96
|
+
fontSize: fontSize,
|
|
97
|
+
margin: margin,
|
|
98
|
+
marginLeft: marginLeft,
|
|
99
|
+
marginRight: marginRight,
|
|
100
|
+
marginTop: marginTop,
|
|
101
|
+
marginBottom: marginBottom,
|
|
102
|
+
focused: focused,
|
|
103
|
+
disabled: disabled,
|
|
104
|
+
hasLabel: !!label,
|
|
105
|
+
hideEditor: !isInputFilled(value) && !!label && !focused,
|
|
106
|
+
className: className,
|
|
107
|
+
children: [
|
|
108
|
+
/*#__PURE__*/ jsxs(InputWrapper, {
|
|
109
|
+
readOnly: readOnly,
|
|
110
|
+
children: [
|
|
111
|
+
label && /*#__PURE__*/ jsx(Label, {
|
|
112
|
+
filled: isInputFilled(value),
|
|
113
|
+
focused: focused,
|
|
114
|
+
disabled: disabled,
|
|
115
|
+
children: label
|
|
116
|
+
}),
|
|
117
|
+
/*#__PURE__*/ jsx(Editor, {
|
|
118
|
+
ref: editorRef,
|
|
119
|
+
editorState: editorState,
|
|
120
|
+
onChange: handleChange,
|
|
121
|
+
placeholder: placeholder,
|
|
122
|
+
readOnly: readOnly,
|
|
123
|
+
handleReturn: handleEditorReturn,
|
|
124
|
+
handlePastedText: handlePaste,
|
|
125
|
+
onFocus: handleFocus,
|
|
126
|
+
onBlur: handleBlur,
|
|
127
|
+
...rest
|
|
128
|
+
})
|
|
129
|
+
]
|
|
130
|
+
}),
|
|
131
|
+
description && /*#__PURE__*/ jsx(Description, {
|
|
132
|
+
invalid: invalid,
|
|
133
|
+
children: description
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
const EditorContainer = styled(InputContainer)(({ theme, height, noPadding, disabled, readOnly, color })=>({
|
|
139
|
+
alignItems: height ? 'flex-start' : void 0,
|
|
140
|
+
minHeight: height,
|
|
141
|
+
height: 'max-content',
|
|
142
|
+
padding: noPadding ? 0 : void 0,
|
|
143
|
+
color: disabled ? theme.input.color.disabled : color || theme.input.color.default,
|
|
144
|
+
cursor: readOnly ? 'inherit' : 'text',
|
|
145
|
+
'&:hover': {
|
|
146
|
+
backgroundColor: readOnly ? theme.input.background.default : void 0,
|
|
147
|
+
borderBottom: readOnly ? `1px solid ${theme.input.borderColor.default}` : void 0,
|
|
148
|
+
Label: {
|
|
149
|
+
color: readOnly ? theme.input.labelColor.filled : void 0
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}), ({ theme, height, hasLabel, editorMaxHeight, overflow, clampLines, hideEditor, fontSize, noPadding, filled })=>({
|
|
153
|
+
'& .public-DraftEditor-content': {
|
|
154
|
+
maxHeight: editorMaxHeight || height,
|
|
155
|
+
overflow: overflow || 'auto',
|
|
156
|
+
lineHeight: hasLabel ? '19px' : '21px',
|
|
157
|
+
position: hideEditor ? 'absolute' : 'relative',
|
|
158
|
+
fontSize: fontSize || theme.font.size.lg,
|
|
159
|
+
top: !filled || hasLabel || noPadding ? void 0 : 1,
|
|
160
|
+
caretColor: theme.accent
|
|
161
|
+
},
|
|
162
|
+
'& .public-DraftStyleDefault-block': {
|
|
163
|
+
WebkitLineClamp: clampLines,
|
|
164
|
+
overflow: clampLines ? 'hidden' : overflow || 'auto',
|
|
165
|
+
display: clampLines ? '-webkit-box' : void 0,
|
|
166
|
+
WebkitBoxOrient: clampLines ? 'vertical' : void 0,
|
|
167
|
+
wordBreak: clampLines ? 'break-word' : void 0
|
|
168
|
+
},
|
|
169
|
+
'& .public-DraftEditorPlaceholder-root': {
|
|
170
|
+
color: theme.input.color.placeholder,
|
|
171
|
+
position: 'relative',
|
|
172
|
+
visibility: hideEditor ? 'hidden' : void 0,
|
|
173
|
+
fontSize: fontSize || theme.font.size.lg
|
|
174
|
+
}
|
|
175
|
+
}), ({ noPadding, hasLabel })=>{
|
|
176
|
+
let top;
|
|
177
|
+
if (noPadding) top = -1;
|
|
178
|
+
if (hasLabel) top = -2;
|
|
179
|
+
return {
|
|
180
|
+
'& .public-DraftEditorPlaceholder-inner': {
|
|
181
|
+
position: 'absolute',
|
|
182
|
+
pointerEvents: 'none',
|
|
183
|
+
top
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
});
|
|
187
|
+
const DraftEditor = DraftEditor_DraftEditor;
|
|
188
|
+
export { DraftEditor as default };
|