@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,146 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useTheme } from "@emotion/react";
|
|
3
|
+
import styled from "@emotion/styled";
|
|
4
|
+
import { CalendarDate } from "@internationalized/date";
|
|
5
|
+
import { range } from "es-toolkit";
|
|
6
|
+
import Icon from "../Icon/index.js";
|
|
7
|
+
import AriaButton from "../Inputs/helpers/AriaButton.js";
|
|
8
|
+
import Select from "../Select.js";
|
|
9
|
+
const CalendarHeader_CalendarHeader = ({ date, setDate })=>{
|
|
10
|
+
const { calendar } = useTheme();
|
|
11
|
+
const months = [
|
|
12
|
+
{
|
|
13
|
+
id: '1',
|
|
14
|
+
value: 'January'
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: '2',
|
|
18
|
+
value: 'February'
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: '3',
|
|
22
|
+
value: 'March'
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: '4',
|
|
26
|
+
value: 'April'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: '5',
|
|
30
|
+
value: 'May'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: '6',
|
|
34
|
+
value: 'June'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: '7',
|
|
38
|
+
value: 'July'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: '8',
|
|
42
|
+
value: 'August'
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: '9',
|
|
46
|
+
value: 'September'
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: '10',
|
|
50
|
+
value: 'October'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: '11',
|
|
54
|
+
value: 'November'
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: '12',
|
|
58
|
+
value: 'December'
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
const years = range(1900, 2100).map((year)=>({
|
|
62
|
+
value: year.toString()
|
|
63
|
+
}));
|
|
64
|
+
const { month: mth, year: yr, day } = date || {};
|
|
65
|
+
const month = mth?.toString() || '';
|
|
66
|
+
const year = yr?.toString() || '';
|
|
67
|
+
const handleMonth = (monthId)=>{
|
|
68
|
+
setDate(new CalendarDate(+year, +monthId, day || 1));
|
|
69
|
+
};
|
|
70
|
+
const handleYear = (yearId)=>{
|
|
71
|
+
setDate(new CalendarDate(+yearId, +month, day || 1));
|
|
72
|
+
};
|
|
73
|
+
return /*#__PURE__*/ jsxs(Header, {
|
|
74
|
+
children: [
|
|
75
|
+
/*#__PURE__*/ jsx(NavButton, {
|
|
76
|
+
slot: "previous",
|
|
77
|
+
children: /*#__PURE__*/ jsx(Icon, {
|
|
78
|
+
name: "chevron-left"
|
|
79
|
+
})
|
|
80
|
+
}),
|
|
81
|
+
/*#__PURE__*/ jsxs(MonthYear, {
|
|
82
|
+
children: [
|
|
83
|
+
/*#__PURE__*/ jsx(Select, {
|
|
84
|
+
options: months,
|
|
85
|
+
value: month,
|
|
86
|
+
onChange: handleMonth,
|
|
87
|
+
textOnly: true,
|
|
88
|
+
fontSize: 12,
|
|
89
|
+
color: calendar.color.monthYear,
|
|
90
|
+
hideCaret: true,
|
|
91
|
+
maxHeight: 200,
|
|
92
|
+
position: "bottom",
|
|
93
|
+
fixedPosition: true
|
|
94
|
+
}),
|
|
95
|
+
/*#__PURE__*/ jsx(Select, {
|
|
96
|
+
options: years,
|
|
97
|
+
value: year,
|
|
98
|
+
onChange: handleYear,
|
|
99
|
+
textOnly: true,
|
|
100
|
+
fontSize: 12,
|
|
101
|
+
color: calendar.color.monthYear,
|
|
102
|
+
hideCaret: true,
|
|
103
|
+
maxHeight: 200,
|
|
104
|
+
position: "bottom",
|
|
105
|
+
fixedPosition: true
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
}),
|
|
109
|
+
/*#__PURE__*/ jsx(NavButton, {
|
|
110
|
+
slot: "next",
|
|
111
|
+
children: /*#__PURE__*/ jsx(Icon, {
|
|
112
|
+
name: "chevron-right"
|
|
113
|
+
})
|
|
114
|
+
})
|
|
115
|
+
]
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
const Header = styled.header({
|
|
119
|
+
display: 'flex',
|
|
120
|
+
justifyContent: 'space-between',
|
|
121
|
+
alignItems: 'center',
|
|
122
|
+
marginBottom: 8
|
|
123
|
+
});
|
|
124
|
+
const MonthYear = styled.div(({ theme: { font, calendar } })=>({
|
|
125
|
+
display: 'flex',
|
|
126
|
+
alignItems: 'center',
|
|
127
|
+
gap: 4,
|
|
128
|
+
fontSize: font.size.sm,
|
|
129
|
+
fontWeight: font.weight.default,
|
|
130
|
+
color: calendar.color.monthYear,
|
|
131
|
+
margin: 0
|
|
132
|
+
}));
|
|
133
|
+
const NavButton = styled(AriaButton)(({ theme })=>({
|
|
134
|
+
color: theme.calendar.color.iconDefault,
|
|
135
|
+
outline: 'none',
|
|
136
|
+
borderRadius: 4,
|
|
137
|
+
'&:hover': {
|
|
138
|
+
color: theme.calendar.color.iconHover
|
|
139
|
+
},
|
|
140
|
+
'&[data-disabled]': {
|
|
141
|
+
color: theme.calendar.color.iconDisabled,
|
|
142
|
+
cursor: 'not-allowed'
|
|
143
|
+
}
|
|
144
|
+
}));
|
|
145
|
+
const CalendarHeader = CalendarHeader_CalendarHeader;
|
|
146
|
+
export { CalendarHeader as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { getNow, getObjFromDate } from "./utils.js";
|
|
3
|
+
const now = getNow();
|
|
4
|
+
const useMinMax_useMinMax = ({ past, future })=>{
|
|
5
|
+
const min = useMemo(()=>{
|
|
6
|
+
if (true === past) return now;
|
|
7
|
+
if (past instanceof Date) return getObjFromDate(past);
|
|
8
|
+
}, [
|
|
9
|
+
past
|
|
10
|
+
]);
|
|
11
|
+
const max = useMemo(()=>{
|
|
12
|
+
if (true === future) return now;
|
|
13
|
+
if (future instanceof Date) return getObjFromDate(future);
|
|
14
|
+
}, [
|
|
15
|
+
future
|
|
16
|
+
]);
|
|
17
|
+
return {
|
|
18
|
+
min,
|
|
19
|
+
max
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const useMinMax = useMinMax_useMinMax;
|
|
23
|
+
export { useMinMax as default };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { getLocalTimeZone, parseDate, today } from "@internationalized/date";
|
|
2
|
+
import { format } from "date-fns";
|
|
3
|
+
const getNow = ()=>today(getLocalTimeZone());
|
|
4
|
+
const getDateFromObj = (val)=>val.toDate(getLocalTimeZone());
|
|
5
|
+
const getObjFromDate = (val)=>parseDate(format(val, 'yyyy-MM-dd'));
|
|
6
|
+
export { getDateFromObj, getNow, getObjFromDate };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Global, useTheme } from "@emotion/react";
|
|
3
|
+
import styled from "@emotion/styled";
|
|
4
|
+
import { Tooltip } from "recharts";
|
|
5
|
+
import { numberWithCommas } from "../utils/index.js";
|
|
6
|
+
import Dot from "./Dot.js";
|
|
7
|
+
import { marginProps } from "./helpers/styledProps.js";
|
|
8
|
+
const ChartStyles = ()=>/*#__PURE__*/ jsx(Global, {
|
|
9
|
+
styles: {
|
|
10
|
+
'.recharts-cartesian-grid-vertical line:first-of-type': {
|
|
11
|
+
strokeOpacity: 0
|
|
12
|
+
},
|
|
13
|
+
'.recharts-cartesian-grid-horizontal line:first-of-type': {
|
|
14
|
+
strokeOpacity: 0
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const ChartContainer = styled.div(({ width, height, maxWidth, maxHeight, responsive })=>({
|
|
19
|
+
width: width || '100%',
|
|
20
|
+
height: height || '100%',
|
|
21
|
+
maxWidth: responsive ? maxWidth || '100%' : void 0,
|
|
22
|
+
maxHeight: responsive ? maxHeight || '100%' : void 0
|
|
23
|
+
}), marginProps);
|
|
24
|
+
const TooltipContent = ({ active, payload, label, legendPostfix })=>active && payload && payload.length ? /*#__PURE__*/ jsxs(TooltipContainer, {
|
|
25
|
+
children: [
|
|
26
|
+
/*#__PURE__*/ jsx(TooltipLabel, {
|
|
27
|
+
children: label
|
|
28
|
+
}),
|
|
29
|
+
payload?.map((item)=>{
|
|
30
|
+
const color = item.color || item.payload?.color;
|
|
31
|
+
const key = `${item.payload?.name}-${item.dataKey}-${item.value}`;
|
|
32
|
+
return /*#__PURE__*/ jsxs(LegendItem, {
|
|
33
|
+
children: [
|
|
34
|
+
color && /*#__PURE__*/ jsx(Dot, {
|
|
35
|
+
color: color
|
|
36
|
+
}),
|
|
37
|
+
/*#__PURE__*/ jsxs("div", {
|
|
38
|
+
className: "item-container",
|
|
39
|
+
children: [
|
|
40
|
+
/*#__PURE__*/ jsx("span", {
|
|
41
|
+
className: "item-name",
|
|
42
|
+
children: item.name
|
|
43
|
+
}),
|
|
44
|
+
": ",
|
|
45
|
+
numberWithCommas(item.value || 0),
|
|
46
|
+
" ",
|
|
47
|
+
legendPostfix
|
|
48
|
+
]
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
}, key);
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
}) : null;
|
|
55
|
+
const ChartHelpers_Tooltip = ({ legendPostfix } = {})=>{
|
|
56
|
+
const { elevation1 } = useTheme();
|
|
57
|
+
return /*#__PURE__*/ jsx(Tooltip, {
|
|
58
|
+
wrapperStyle: {
|
|
59
|
+
outline: 'none',
|
|
60
|
+
boxShadow: elevation1
|
|
61
|
+
},
|
|
62
|
+
cursor: false,
|
|
63
|
+
content: /*#__PURE__*/ jsx(TooltipContent, {
|
|
64
|
+
legendPostfix: legendPostfix
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
const LegendContent = ({ payload, toggleData })=>/*#__PURE__*/ jsx(LegendContainer, {
|
|
69
|
+
children: payload?.map((item)=>/*#__PURE__*/ jsxs(LegendItem, {
|
|
70
|
+
onClick: toggleData ? ()=>toggleData(item) : void 0,
|
|
71
|
+
clickable: !!toggleData,
|
|
72
|
+
inactive: item.inactive,
|
|
73
|
+
children: [
|
|
74
|
+
/*#__PURE__*/ jsx(Dot, {
|
|
75
|
+
color: item.color
|
|
76
|
+
}),
|
|
77
|
+
item.value
|
|
78
|
+
]
|
|
79
|
+
}, `${item.dataKey}-${item.value}`))
|
|
80
|
+
});
|
|
81
|
+
const LegendContainer = styled.div({
|
|
82
|
+
display: 'flex',
|
|
83
|
+
justifyContent: 'center',
|
|
84
|
+
alignItems: 'center',
|
|
85
|
+
columnGap: 16,
|
|
86
|
+
marginTop: 8,
|
|
87
|
+
flexWrap: 'wrap'
|
|
88
|
+
});
|
|
89
|
+
const LegendItem = styled.div(({ theme, clickable, inactive })=>({
|
|
90
|
+
color: theme.scale8,
|
|
91
|
+
fontSize: theme.font.size.sm,
|
|
92
|
+
display: 'flex',
|
|
93
|
+
alignItems: 'center',
|
|
94
|
+
columnGap: 8,
|
|
95
|
+
borderRadius: 8,
|
|
96
|
+
lineHeight: '15px',
|
|
97
|
+
backgroundColor: clickable ? theme.scale1 : void 0,
|
|
98
|
+
padding: clickable ? '4px 8px' : void 0,
|
|
99
|
+
cursor: clickable ? 'pointer' : void 0,
|
|
100
|
+
opacity: inactive ? 0.3 : 1,
|
|
101
|
+
'.item-container': {
|
|
102
|
+
display: 'flex',
|
|
103
|
+
alignItems: 'center'
|
|
104
|
+
},
|
|
105
|
+
'.item-name': {
|
|
106
|
+
textTransform: 'capitalize'
|
|
107
|
+
}
|
|
108
|
+
}));
|
|
109
|
+
const TooltipContainer = styled.div(({ theme })=>({
|
|
110
|
+
background: theme.tooltip.background,
|
|
111
|
+
border: 'none',
|
|
112
|
+
borderRadius: 4,
|
|
113
|
+
padding: 16,
|
|
114
|
+
boxShadow: theme.elevation1
|
|
115
|
+
}));
|
|
116
|
+
const TooltipLabel = styled.div(({ theme })=>({
|
|
117
|
+
fontSize: theme.font.size.md,
|
|
118
|
+
color: theme.tooltip.color.subtext,
|
|
119
|
+
marginBottom: 4
|
|
120
|
+
}));
|
|
121
|
+
export { ChartContainer, ChartStyles, LegendContent, ChartHelpers_Tooltip as Tooltip, TooltipContent };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { Checkbox } from "react-aria-components";
|
|
5
|
+
import icons_Checkbox from "../assets/icons/Checkbox.js";
|
|
6
|
+
import CheckboxOff from "../assets/icons/CheckboxOff.js";
|
|
7
|
+
import CheckboxPartial from "../assets/icons/CheckboxPartial.js";
|
|
8
|
+
import { ControlLabel } from "./FormControl.js";
|
|
9
|
+
import { marginProps } from "./helpers/styledProps.js";
|
|
10
|
+
import Icon from "./Icon/index.js";
|
|
11
|
+
const Checkbox_Checkbox = ({ label, labelPosition, checked, partial, disabled, readOnly, onChange, ...props })=>{
|
|
12
|
+
const [on, setOn] = useState(checked || false);
|
|
13
|
+
const labelRight = 'right' === labelPosition;
|
|
14
|
+
const handleChange = ()=>{
|
|
15
|
+
const value = partial ? true : !on;
|
|
16
|
+
setOn(value);
|
|
17
|
+
if (onChange) onChange(value);
|
|
18
|
+
};
|
|
19
|
+
useEffect(()=>{
|
|
20
|
+
const checkedSet = 'boolean' == typeof checked;
|
|
21
|
+
const value = checkedSet ? checked : on;
|
|
22
|
+
setOn(value);
|
|
23
|
+
}, [
|
|
24
|
+
checked,
|
|
25
|
+
on
|
|
26
|
+
]);
|
|
27
|
+
return /*#__PURE__*/ jsx(ControlContainer, {
|
|
28
|
+
labelRight: labelRight,
|
|
29
|
+
isSelected: on,
|
|
30
|
+
isIndeterminate: partial,
|
|
31
|
+
isDisabled: disabled,
|
|
32
|
+
isReadOnly: readOnly,
|
|
33
|
+
onChange: handleChange,
|
|
34
|
+
...props,
|
|
35
|
+
children: ({ isIndeterminate, isSelected })=>{
|
|
36
|
+
let svg = /*#__PURE__*/ jsx(CheckboxOff, {});
|
|
37
|
+
if (partial || isIndeterminate) svg = /*#__PURE__*/ jsx(CheckboxPartial, {});
|
|
38
|
+
else if (on || isSelected) svg = /*#__PURE__*/ jsx(icons_Checkbox, {});
|
|
39
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
40
|
+
children: [
|
|
41
|
+
label && /*#__PURE__*/ jsx(ControlLabel, {
|
|
42
|
+
children: label
|
|
43
|
+
}),
|
|
44
|
+
/*#__PURE__*/ jsx(Icon, {
|
|
45
|
+
svg: svg,
|
|
46
|
+
pointer: !disabled
|
|
47
|
+
})
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const ControlContainer = styled(Checkbox)(({ theme: { accent, formControl }, labelRight, isDisabled, gap = 8 })=>({
|
|
54
|
+
display: 'inline-flex',
|
|
55
|
+
flexDirection: labelRight ? 'row-reverse' : 'row',
|
|
56
|
+
justifyContent: labelRight ? 'flex-end' : 'flex-start',
|
|
57
|
+
alignItems: 'center',
|
|
58
|
+
gap,
|
|
59
|
+
position: 'relative',
|
|
60
|
+
cursor: isDisabled ? 'not-allowed' : void 0,
|
|
61
|
+
borderRadius: 4,
|
|
62
|
+
outline: 'none',
|
|
63
|
+
outlineOffset: -1,
|
|
64
|
+
'& > div': {
|
|
65
|
+
transition: 'color 0.2s linear',
|
|
66
|
+
color: formControl.color.default
|
|
67
|
+
},
|
|
68
|
+
'&[data-hovered] > div': {
|
|
69
|
+
color: isDisabled ? void 0 : formControl.color.hover
|
|
70
|
+
},
|
|
71
|
+
'&[data-selected] > div, &[data-indeterminate] > div': {
|
|
72
|
+
color: formControl.color.active
|
|
73
|
+
},
|
|
74
|
+
'&[data-hovered][data-selected] > div': {
|
|
75
|
+
color: isDisabled ? void 0 : formControl.color.activeHover
|
|
76
|
+
},
|
|
77
|
+
'&[data-disabled] > div': {
|
|
78
|
+
color: formControl.color.disabled
|
|
79
|
+
},
|
|
80
|
+
'&[data-focus-visible]': {
|
|
81
|
+
outline: `${accent} solid 1px`
|
|
82
|
+
}
|
|
83
|
+
}), marginProps);
|
|
84
|
+
const components_Checkbox = Checkbox_Checkbox;
|
|
85
|
+
export { ControlContainer, components_Checkbox as default };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createElement } from "react";
|
|
3
|
+
import { useTheme } from "@emotion/react";
|
|
4
|
+
import styled from "@emotion/styled";
|
|
5
|
+
import { compact, range } from "es-toolkit";
|
|
6
|
+
import { Highlight, themes } from "prism-react-renderer";
|
|
7
|
+
import { marginProps } from "../helpers/styledProps.js";
|
|
8
|
+
import Copy from "./Copy.js";
|
|
9
|
+
import Endpoint from "./Endpoint.js";
|
|
10
|
+
const Code_Code = ({ children, code, className: metaData, lang: langProp, lineHighlights: lineHighlightsProp, noNumbers: noNumbersProp, margin, marginTop, marginBottom, marginRight, marginLeft })=>{
|
|
11
|
+
const { name: themeName } = useTheme();
|
|
12
|
+
const rest = {
|
|
13
|
+
margin,
|
|
14
|
+
marginTop,
|
|
15
|
+
marginBottom,
|
|
16
|
+
marginRight,
|
|
17
|
+
marginLeft
|
|
18
|
+
};
|
|
19
|
+
const classes = metaData?.replace(/}/g, '').split('{') || [];
|
|
20
|
+
let [lang, lineHighlights, noNumbers] = classes;
|
|
21
|
+
lang = lang || langProp || '';
|
|
22
|
+
lineHighlights = lineHighlights || lineHighlightsProp || '';
|
|
23
|
+
noNumbers = noNumbers || noNumbersProp ? 'nonumbers' : '';
|
|
24
|
+
let language = lang ? lang.replace(/language-/, '') : 'text';
|
|
25
|
+
let endpointMethod = '';
|
|
26
|
+
if (language.includes('rest')) {
|
|
27
|
+
const [key, method] = language.split('-');
|
|
28
|
+
language = key;
|
|
29
|
+
endpointMethod = method?.toUpperCase() || '';
|
|
30
|
+
}
|
|
31
|
+
const hideNumbers = 'nonumbers' === noNumbers.toLowerCase().trim();
|
|
32
|
+
const getLines = (val)=>{
|
|
33
|
+
const separated = val.split(',');
|
|
34
|
+
const numbers = separated.map((item)=>{
|
|
35
|
+
if (item.match(/^\d+$/)) return Number.parseInt(item, 10);
|
|
36
|
+
if (item.includes('-')) {
|
|
37
|
+
const [first, last] = item.split('-');
|
|
38
|
+
const start = Number.parseInt(first, 10);
|
|
39
|
+
const end = Number.parseInt(last, 10);
|
|
40
|
+
const lineRange = start < end ? range(start, end + 1) : range(end, start + 1);
|
|
41
|
+
return lineRange;
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
});
|
|
45
|
+
const flattened = numbers.flat();
|
|
46
|
+
return compact(flattened);
|
|
47
|
+
};
|
|
48
|
+
const isNumHighlight = (num)=>{
|
|
49
|
+
if (lineHighlights) {
|
|
50
|
+
const numbers = getLines(lineHighlights);
|
|
51
|
+
return numbers.some((item)=>num === item);
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
};
|
|
55
|
+
const content = code?.trim() || children?.trim() || '';
|
|
56
|
+
return 'rest' === language ? /*#__PURE__*/ jsx(Endpoint, {
|
|
57
|
+
method: endpointMethod,
|
|
58
|
+
url: content
|
|
59
|
+
}) : /*#__PURE__*/ jsx(Highlight, {
|
|
60
|
+
code: content,
|
|
61
|
+
language: language,
|
|
62
|
+
theme: 'dark' === themeName ? themes.oceanicNext : themes.github,
|
|
63
|
+
children: ({ className, style, tokens, getLineProps, getTokenProps })=>/*#__PURE__*/ jsxs(Pre, {
|
|
64
|
+
className: className,
|
|
65
|
+
style: {
|
|
66
|
+
...style
|
|
67
|
+
},
|
|
68
|
+
...rest,
|
|
69
|
+
"data-testid": "code",
|
|
70
|
+
children: [
|
|
71
|
+
tokens.map((line, i, tokenArray)=>/*#__PURE__*/ createElement(Line, {
|
|
72
|
+
...getLineProps({
|
|
73
|
+
line,
|
|
74
|
+
key: i
|
|
75
|
+
}),
|
|
76
|
+
key: `line-${i + 1}`,
|
|
77
|
+
highlight: isNumHighlight(i + 1),
|
|
78
|
+
children: [
|
|
79
|
+
tokenArray.length > 1 && !hideNumbers && /*#__PURE__*/ jsx(LineNumber, {
|
|
80
|
+
children: i + 1
|
|
81
|
+
}),
|
|
82
|
+
line.map((token, key)=>/*#__PURE__*/ createElement("span", {
|
|
83
|
+
...getTokenProps({
|
|
84
|
+
token,
|
|
85
|
+
key
|
|
86
|
+
}),
|
|
87
|
+
key: `token-${key + 1}`
|
|
88
|
+
}))
|
|
89
|
+
]
|
|
90
|
+
})),
|
|
91
|
+
/*#__PURE__*/ jsx(Copy, {
|
|
92
|
+
content: content
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
const Pre = styled.pre(({ theme })=>({
|
|
99
|
+
overflowX: 'auto',
|
|
100
|
+
position: 'relative',
|
|
101
|
+
padding: theme.size.md,
|
|
102
|
+
borderRadius: theme.size.xs,
|
|
103
|
+
backgroundColor: 'light' === theme.name ? `${theme.scale0} !important` : void 0
|
|
104
|
+
}), marginProps);
|
|
105
|
+
const Line = styled.div(({ theme, highlight })=>({
|
|
106
|
+
backgroundColor: highlight ? theme.scale1 : 'transparent'
|
|
107
|
+
}));
|
|
108
|
+
const LineNumber = styled.span(({ theme })=>({
|
|
109
|
+
display: 'inline-block',
|
|
110
|
+
minWidth: 17,
|
|
111
|
+
textAlign: 'right',
|
|
112
|
+
marginRight: 10,
|
|
113
|
+
color: theme.scale6,
|
|
114
|
+
userSelect: 'none'
|
|
115
|
+
}));
|
|
116
|
+
const Code = Code_Code;
|
|
117
|
+
export { Code as default };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useTheme } from "@emotion/react";
|
|
3
|
+
import styled from "@emotion/styled";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
import { copyToClipboard } from "../../utils/index.js";
|
|
6
|
+
import Icon from "../Icon/index.js";
|
|
7
|
+
const Copy = ({ content })=>{
|
|
8
|
+
const [copied, setCopied] = useState(false);
|
|
9
|
+
const { color, scale10 } = useTheme();
|
|
10
|
+
useEffect(()=>{
|
|
11
|
+
if (copied) setTimeout(()=>{
|
|
12
|
+
setCopied(false);
|
|
13
|
+
}, 2000);
|
|
14
|
+
}, [
|
|
15
|
+
copied
|
|
16
|
+
]);
|
|
17
|
+
const copy = ()=>{
|
|
18
|
+
copyToClipboard(content);
|
|
19
|
+
setCopied(true);
|
|
20
|
+
};
|
|
21
|
+
return /*#__PURE__*/ jsx(CopyContainer, {
|
|
22
|
+
onClick: copy,
|
|
23
|
+
copied: copied,
|
|
24
|
+
children: copied ? /*#__PURE__*/ jsx(Icon, {
|
|
25
|
+
name: "copy-check",
|
|
26
|
+
color: color.success
|
|
27
|
+
}) : /*#__PURE__*/ jsx(Icon, {
|
|
28
|
+
name: "copy",
|
|
29
|
+
color: scale10
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
const CopyContainer = styled.div(({ copied })=>({
|
|
34
|
+
width: 25,
|
|
35
|
+
height: 25,
|
|
36
|
+
padding: 5,
|
|
37
|
+
position: 'absolute',
|
|
38
|
+
top: 5,
|
|
39
|
+
right: 5,
|
|
40
|
+
display: 'flex',
|
|
41
|
+
justifyContent: 'center',
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
cursor: 'pointer',
|
|
44
|
+
opacity: copied ? 1 : 0.3,
|
|
45
|
+
'&:hover': {
|
|
46
|
+
opacity: copied ? 1 : 0.7
|
|
47
|
+
}
|
|
48
|
+
}));
|
|
49
|
+
const Code_Copy = Copy;
|
|
50
|
+
export { Code_Copy as default };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useTheme } from "@emotion/react";
|
|
3
|
+
import styled from "@emotion/styled";
|
|
4
|
+
import Copy from "./Copy.js";
|
|
5
|
+
const getStyles = (method, theme)=>{
|
|
6
|
+
const { color } = theme;
|
|
7
|
+
switch(method){
|
|
8
|
+
case 'GET':
|
|
9
|
+
return {
|
|
10
|
+
borderColor: color.brand,
|
|
11
|
+
backgroundColor: color.brandTint2
|
|
12
|
+
};
|
|
13
|
+
case 'DELETE':
|
|
14
|
+
return {
|
|
15
|
+
borderColor: color.error,
|
|
16
|
+
backgroundColor: color.errorTint2
|
|
17
|
+
};
|
|
18
|
+
case 'POST':
|
|
19
|
+
return {
|
|
20
|
+
borderColor: color.success,
|
|
21
|
+
backgroundColor: color.successTint2
|
|
22
|
+
};
|
|
23
|
+
case 'PUT':
|
|
24
|
+
return {
|
|
25
|
+
borderColor: color.warning,
|
|
26
|
+
backgroundColor: color.warningTint2
|
|
27
|
+
};
|
|
28
|
+
default:
|
|
29
|
+
return {
|
|
30
|
+
borderColor: theme.scale8,
|
|
31
|
+
backgroundColor: theme.scale0
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const Endpoint_Endpoint = ({ method, url })=>{
|
|
36
|
+
const theme = useTheme();
|
|
37
|
+
const styles = getStyles(method.toUpperCase(), theme);
|
|
38
|
+
return /*#__PURE__*/ jsxs(Container, {
|
|
39
|
+
...styles,
|
|
40
|
+
children: [
|
|
41
|
+
/*#__PURE__*/ jsx(EndpointMethod, {
|
|
42
|
+
backgroundColor: styles.borderColor,
|
|
43
|
+
children: method.toUpperCase()
|
|
44
|
+
}),
|
|
45
|
+
/*#__PURE__*/ jsx(Url, {
|
|
46
|
+
children: url
|
|
47
|
+
}),
|
|
48
|
+
/*#__PURE__*/ jsx(Copy, {
|
|
49
|
+
content: url
|
|
50
|
+
})
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const Container = styled.div(({ theme })=>({
|
|
55
|
+
display: 'flex',
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
border: '1px solid',
|
|
58
|
+
borderRadius: theme.size.xs,
|
|
59
|
+
margin: '10px 0',
|
|
60
|
+
position: 'relative'
|
|
61
|
+
}), ({ borderColor, backgroundColor })=>({
|
|
62
|
+
borderColor,
|
|
63
|
+
backgroundColor
|
|
64
|
+
}));
|
|
65
|
+
const EndpointMethod = styled.div(({ theme })=>({
|
|
66
|
+
padding: theme.size.md,
|
|
67
|
+
textAlign: 'center',
|
|
68
|
+
fontFamily: 'monospace',
|
|
69
|
+
whiteSpace: 'pre',
|
|
70
|
+
fontSize: theme.font.size.lg,
|
|
71
|
+
color: '#fff'
|
|
72
|
+
}), ({ backgroundColor })=>({
|
|
73
|
+
backgroundColor
|
|
74
|
+
}));
|
|
75
|
+
const Url = styled.div(({ theme })=>({
|
|
76
|
+
fontFamily: 'monospace',
|
|
77
|
+
whiteSpace: 'pre',
|
|
78
|
+
fontSize: theme.font.size.lg,
|
|
79
|
+
padding: theme.size.md
|
|
80
|
+
}));
|
|
81
|
+
const Endpoint = Endpoint_Endpoint;
|
|
82
|
+
export { Endpoint as default };
|