@wavv/ui 2.2.2-alpha.5 → 2.2.2-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/assets/icons/CaretDown.js +18 -0
- package/build/assets/icons/CaretUp.js +18 -0
- package/build/assets/icons/Checkbox.js +15 -0
- package/build/assets/icons/CheckboxOff.js +15 -0
- package/build/assets/icons/CheckboxPartial.js +15 -0
- package/build/assets/icons/Dialpad.js +18 -0
- package/build/assets/icons/Exclamation.js +25 -0
- package/build/assets/icons/Phone.js +13 -0
- package/build/assets/icons/PhoneAdd.js +21 -0
- package/build/assets/icons/PhoneBlocked.js +22 -0
- package/build/assets/icons/PhoneCallback.js +21 -0
- package/build/assets/icons/PhoneEnd.js +28 -0
- package/build/assets/icons/PhoneForward.js +22 -0
- package/build/assets/icons/PhoneHistory.js +21 -0
- package/build/assets/icons/PhoneHold.js +22 -0
- package/build/assets/icons/PhoneIncoming.js +22 -0
- package/build/assets/icons/PhoneMissed.js +22 -0
- package/build/assets/icons/PhoneTalk.js +22 -0
- package/build/assets/icons/PhoneTransfer.js +21 -0
- package/build/assets/icons/RadioButton.js +22 -0
- package/build/assets/icons/RadioButtonOff.js +15 -0
- package/build/assets/icons/Record.js +18 -0
- package/build/assets/icons/Screenshot.js +39 -0
- package/build/assets/icons/ShieldWavv.js +30 -0
- package/build/assets/icons/Spotify.js +15 -0
- package/build/assets/icons/SubArrow.js +16 -0
- package/build/assets/icons/ToggleOff.js +15 -0
- package/build/assets/icons/ToggleOn.js +15 -0
- package/build/assets/icons/TransferCancel.js +60 -0
- package/build/components/Accordion/Accordion.js +26 -0
- package/build/components/Accordion/Header.js +86 -0
- package/build/components/Accordion/Item.js +25 -0
- package/build/components/Accordion/Panel.js +64 -0
- package/build/components/Accordion/index.js +2 -0
- package/build/components/Audio.js +248 -0
- package/build/components/BarChart.js +123 -0
- package/build/components/Button/Button.js +258 -0
- package/build/components/Button/ButtonLoader.js +20 -0
- package/build/components/Button/ButtonTypes.js +0 -0
- package/build/components/Button/Group.js +58 -0
- package/build/components/Button/index.js +2 -0
- package/build/components/Calendar.js +49 -0
- package/build/components/CalendarParts/CalendarContainerStyles.js +15 -0
- package/build/components/CalendarParts/CalendarContent.js +138 -0
- package/build/components/CalendarParts/CalendarHeader.js +146 -0
- package/build/components/CalendarParts/useMinMax.js +23 -0
- package/build/components/CalendarParts/utils.js +6 -0
- package/build/components/ChartHelpers.js +121 -0
- package/build/components/Checkbox.js +85 -0
- package/build/components/Code/Code.js +117 -0
- package/build/components/Code/Copy.js +50 -0
- package/build/components/Code/Endpoint.js +82 -0
- package/build/components/Code/index.js +3 -0
- package/build/components/ComboBox.js +190 -0
- package/build/components/CommandMenu/CommandItem.js +32 -0
- package/build/components/CommandMenu/CommandMenu.js +136 -0
- package/build/components/CommandMenu/CommandOptions.js +24 -0
- package/build/components/CommandMenu/CommandSection.js +19 -0
- package/build/components/CommandMenu/index.js +2 -0
- package/build/components/DateRangeSelect.js +359 -0
- package/build/components/DocTable.js +32 -0
- package/build/components/Dot.js +60 -0
- package/build/components/DraftEditor.js +188 -0
- package/build/components/Dropdown.js +130 -0
- package/build/components/DropdownMenu.js +131 -0
- package/build/components/DropdownMenuParts/Menu.js +6 -0
- package/build/components/DropdownMenuParts/MenuItem.js +54 -0
- package/build/components/DropdownMenuParts/MenuOptions.js +47 -0
- package/build/components/DropdownMenuParts/MenuSection.js +14 -0
- package/build/components/DropdownSelect.js +171 -0
- package/build/components/DynamicIcon.js +49 -0
- package/build/components/Editor/Editor.js +356 -0
- package/build/components/Editor/EditorStyles.js +259 -0
- package/build/components/Editor/MergeFieldExtension.js +110 -0
- package/build/components/Editor/RichTextToolbar.js +515 -0
- package/build/components/Editor/editorUtils.js +213 -0
- package/build/components/Editor/index.js +3 -0
- package/build/components/Ellipsis.js +22 -0
- package/build/components/Focusable.js +20 -0
- package/build/components/Form.js +68 -0
- package/build/components/FormControl.js +72 -0
- package/build/components/Grid.js +53 -0
- package/build/components/Icon/Icon.js +89 -0
- package/build/components/Icon/customIcons.js +48 -0
- package/build/components/Icon/icons.js +145 -0
- package/build/components/Icon/index.js +3 -0
- package/build/components/ImageViewer.js +142 -0
- package/build/components/InlineCode.js +10 -0
- package/build/components/InputHelpers.js +106 -0
- package/build/components/Inputs/DatePicker.js +111 -0
- package/build/components/Inputs/DateRangePicker.js +166 -0
- package/build/components/Inputs/InlineInput.js +71 -0
- package/build/components/Inputs/NumberInput.js +117 -0
- package/build/components/Inputs/PhoneInput.js +96 -0
- package/build/components/Inputs/SearchInput.js +84 -0
- package/build/components/Inputs/TextArea.js +164 -0
- package/build/components/Inputs/TextInput.js +74 -0
- package/build/components/Inputs/TimeInput.js +74 -0
- package/build/components/Inputs/helpers/AriaButton.js +19 -0
- package/build/components/Inputs/helpers/DateSegment.js +22 -0
- package/build/components/Inputs/helpers/Description.js +11 -0
- package/build/components/Inputs/helpers/ErrorMessage.js +11 -0
- package/build/components/Inputs/helpers/Input.js +6 -0
- package/build/components/Inputs/helpers/InputContainerStyles.js +78 -0
- package/build/components/Inputs/helpers/InputMessage.js +30 -0
- package/build/components/Inputs/helpers/InputStyles.js +43 -0
- package/build/components/Inputs/helpers/Label.js +42 -0
- package/build/components/Inputs/helpers/LabelWrapper.js +14 -0
- package/build/components/Inputs/helpers/PickerToggle.js +7 -0
- package/build/components/Inputs/helpers/TextArea.js +8 -0
- package/build/components/Inputs/helpers/filterPastedText.js +9 -0
- package/build/components/Inputs/helpers/handlePaste.js +12 -0
- package/build/components/Inputs/helpers/isAcceptable.js +7 -0
- package/build/components/Inputs/helpers/useDynamicWidth.js +39 -0
- package/build/components/Inputs/helpers/useInputFocus.js +19 -0
- package/build/components/Label.js +42 -0
- package/build/components/LineChart.js +80 -0
- package/build/components/ListBoxParts/GridListItem.js +34 -0
- package/build/components/ListBoxParts/ListBoxItem.js +32 -0
- package/build/components/ListBoxParts/ListOptions.js +45 -0
- package/build/components/ListHelpers/GridListHeader.js +14 -0
- package/build/components/ListHelpers/GridListSection.js +14 -0
- package/build/components/ListHelpers/ItemHeaderBody.js +36 -0
- package/build/components/ListHelpers/ListHeader.js +14 -0
- package/build/components/ListHelpers/ListItemStyles.js +52 -0
- package/build/components/ListHelpers/ListRootStyles.js +14 -0
- package/build/components/ListHelpers/ListSection.js +14 -0
- package/build/components/ListHelpers/ListStyles.js +29 -0
- package/build/components/Menu.js +159 -0
- package/build/components/Message.js +107 -0
- package/build/components/MessageHr.js +32 -0
- package/build/components/Modal.js +212 -0
- package/build/components/MotionPopover.js +39 -0
- package/build/components/MultiSelect/MultiSelect.js +263 -0
- package/build/components/MultiSelect/SearchDropdown.js +155 -0
- package/build/components/MultiSelect/index.js +2 -0
- package/build/components/OptionHelpers/Container.js +34 -0
- package/build/components/OptionHelpers/Item.js +59 -0
- package/build/components/OptionHelpers/types.js +0 -0
- package/build/components/Pagination.js +121 -0
- package/build/components/PieChart.js +40 -0
- package/build/components/Popover.js +40 -0
- package/build/components/PortalScope.js +8 -0
- package/build/components/Progress/CirclePercent.js +56 -0
- package/build/components/Progress/Progress.js +59 -0
- package/build/components/Progress/index.js +3 -0
- package/build/components/Radio.js +45 -0
- package/build/components/RangeCalendar.js +60 -0
- package/build/components/Select.js +162 -0
- package/build/components/Slider.js +50 -0
- package/build/components/Spinner.js +70 -0
- package/build/components/Table/Body.js +49 -0
- package/build/components/Table/Cell.js +63 -0
- package/build/components/Table/Check.js +35 -0
- package/build/components/Table/Column.js +129 -0
- package/build/components/Table/ColumnSort.js +26 -0
- package/build/components/Table/Header.js +64 -0
- package/build/components/Table/Resizer.js +25 -0
- package/build/components/Table/Row.js +84 -0
- package/build/components/Table/SortCaret.js +24 -0
- package/build/components/Table/Table.js +88 -0
- package/build/components/Table/contentStyles.js +20 -0
- package/build/components/Table/context.js +4 -0
- package/build/components/Table/index.js +2 -0
- package/build/components/Table/types.js +0 -0
- package/build/components/Tabs.js +151 -0
- package/build/components/Tag.js +71 -0
- package/build/components/Toggle.js +59 -0
- package/build/components/ToggleButton/ToggleButton.js +104 -0
- package/build/components/ToggleButton/ToggleButtonGroup.js +36 -0
- package/build/components/ToggleButton/context.js +8 -0
- package/build/components/ToggleButton/index.js +3 -0
- package/build/components/Tooltip.js +136 -0
- package/build/components/TransferList.js +234 -0
- package/build/components/Tree/Tree.js +69 -0
- package/build/components/Tree/TreeContext.js +3 -0
- package/build/components/Tree/TreeItem.js +93 -0
- package/build/components/Tree/index.js +2 -0
- package/build/components/UnstyledButton.js +8 -0
- package/build/components/Waveform.js +243 -0
- package/build/components/draftUtils.js +193 -0
- package/build/components/helpers/getIcon.js +28 -0
- package/build/components/helpers/getPopPosition.js +20 -0
- package/build/components/helpers/isPropAllowed.js +3 -0
- package/build/components/helpers/mergePadding.js +47 -0
- package/build/components/helpers/styledProps.js +34 -0
- package/build/components/typeDefs/elementTypes.js +0 -0
- package/build/components/typeDefs/inputTypes.js +0 -0
- package/build/components/typeDefs/selectionTypes.js +0 -0
- package/build/components/typeDefs/tagTypes.js +0 -0
- package/build/components/types.js +0 -0
- package/build/global-styles/GlobalStorybookStyles.js +108 -0
- package/build/global-styles/ResetStyles.js +33 -0
- package/build/global-styles/ScrollbarStyles.js +26 -0
- package/build/global-styles/ToastStyles.js +66 -0
- package/build/global-styles/index.js +4 -0
- package/build/hooks/index.js +9 -0
- package/build/hooks/useConfirm.js +91 -0
- package/build/hooks/useControlledOpenState.js +22 -0
- package/build/hooks/useCopy.js +28 -0
- package/build/hooks/useElementObserver.js +6 -0
- package/build/hooks/useEventListener.js +19 -0
- package/build/hooks/useOnClickOutside.js +21 -0
- package/build/hooks/usePrevious.js +12 -0
- package/build/hooks/useSelectAll.js +60 -0
- package/build/hooks/useWindowSize.js +25 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +2 -1
- package/build/theme/ThemeTypes.js +0 -0
- package/build/theme/common/button.js +33 -0
- package/build/theme/common/common.js +38 -0
- package/build/theme/common/index.js +4 -0
- package/build/theme/core/colors.js +77 -0
- package/build/theme/core/dark/dark.js +457 -0
- package/build/theme/core/dark/darkScale.js +36 -0
- package/build/theme/core/light/light.js +456 -0
- package/build/theme/core/light/lightScale.js +35 -0
- package/build/theme/eighties/colors.js +78 -0
- package/build/theme/eighties/dark/dark.js +457 -0
- package/build/theme/eighties/dark/darkScale.js +36 -0
- package/build/theme/eighties/light/light.js +456 -0
- package/build/theme/eighties/light/lightScale.js +35 -0
- package/build/theme/index.js +28 -0
- package/build/utils/chunk.js +13 -0
- package/build/utils/copyToClipboard.js +29 -0
- package/build/utils/flattenListOptions.js +4 -0
- package/build/utils/formatDate.js +55 -0
- package/build/utils/formatNumber.d.ts +8 -0
- package/build/utils/formatNumber.js +32 -0
- package/build/utils/index.js +6 -0
- package/build/utils/numberWithCommas.js +3 -0
- package/build/utils/range.js +11 -0
- package/package.json +14 -15
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useTheme } from "@emotion/react";
|
|
3
|
+
import styled from "@emotion/styled";
|
|
4
|
+
import { darken, lighten } from "polished";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { Button } from "react-aria-components";
|
|
7
|
+
import DropdownMenu from "../DropdownMenu.js";
|
|
8
|
+
import { marginProps } from "../helpers/styledProps.js";
|
|
9
|
+
import Icon from "../Icon/index.js";
|
|
10
|
+
import ButtonLoader from "./ButtonLoader.js";
|
|
11
|
+
import Group from "./Group.js";
|
|
12
|
+
const Button_Button = ({ content, children, dropdown, options, ref, ...rest })=>{
|
|
13
|
+
const text = content || children;
|
|
14
|
+
if (dropdown && options) return /*#__PURE__*/ jsx(DropdownButton, {
|
|
15
|
+
ref: ref,
|
|
16
|
+
options: options,
|
|
17
|
+
...rest,
|
|
18
|
+
children: text
|
|
19
|
+
});
|
|
20
|
+
return /*#__PURE__*/ jsx(BasicButton, {
|
|
21
|
+
ref: ref,
|
|
22
|
+
...rest,
|
|
23
|
+
children: text
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
const BasicButton = ({ children, onClick, onPress, icon, iconPosition, iconColor, joined, size, small, tiny, large, loading, collapse, backgroundColor, color, type, animation, iconAnimation, disabled, ref, ...props })=>{
|
|
27
|
+
const { button } = useTheme();
|
|
28
|
+
const iconOnly = !!(icon && (!children || collapse));
|
|
29
|
+
const iconRight = 'right' === iconPosition;
|
|
30
|
+
let buttonSize = size || 'medium';
|
|
31
|
+
if (small) buttonSize = 'small';
|
|
32
|
+
else if (large) buttonSize = 'large';
|
|
33
|
+
else if (tiny) buttonSize = 'tiny';
|
|
34
|
+
const buttonStyles = button[buttonSize];
|
|
35
|
+
const { iconSize } = buttonStyles;
|
|
36
|
+
const hideText = collapse && icon;
|
|
37
|
+
return /*#__PURE__*/ jsxs(ButtonEl, {
|
|
38
|
+
...props,
|
|
39
|
+
ref: ref,
|
|
40
|
+
isDisabled: disabled,
|
|
41
|
+
type: type || 'button',
|
|
42
|
+
size: buttonSize,
|
|
43
|
+
iconOnly: iconOnly,
|
|
44
|
+
iconRight: iconRight,
|
|
45
|
+
joined: joined,
|
|
46
|
+
onPress: onPress || onClick,
|
|
47
|
+
loading: loading,
|
|
48
|
+
color: color,
|
|
49
|
+
backgroundColor: backgroundColor,
|
|
50
|
+
animation: animation,
|
|
51
|
+
children: [
|
|
52
|
+
icon ? /*#__PURE__*/ jsx(Icon, {
|
|
53
|
+
size: iconSize,
|
|
54
|
+
name: icon,
|
|
55
|
+
marginRight: iconOnly || iconRight ? 0 : 4,
|
|
56
|
+
marginLeft: !iconOnly && iconRight ? 4 : 0,
|
|
57
|
+
color: iconColor,
|
|
58
|
+
animation: iconAnimation
|
|
59
|
+
}) : null,
|
|
60
|
+
!hideText && /*#__PURE__*/ jsx(Inner, {
|
|
61
|
+
children: children
|
|
62
|
+
}),
|
|
63
|
+
loading && /*#__PURE__*/ jsx(ButtonLoader, {
|
|
64
|
+
size: iconSize
|
|
65
|
+
})
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
const DropdownButton = ({ children, options, onClick, onPress, afterShow, afterHide, secondary, negative, positive, caution, outline, subtle, link, size, small, tiny, large, disabled, buttonDisabled, optionsDisabled, loading, direction, collapse, width, hideDivider, gap, ref, ...props })=>{
|
|
70
|
+
const [optionsOpen, setOptionsOpen] = useState(false);
|
|
71
|
+
const buttonStyleProps = {
|
|
72
|
+
secondary,
|
|
73
|
+
negative,
|
|
74
|
+
positive,
|
|
75
|
+
caution,
|
|
76
|
+
outline,
|
|
77
|
+
subtle,
|
|
78
|
+
link,
|
|
79
|
+
size,
|
|
80
|
+
small,
|
|
81
|
+
tiny,
|
|
82
|
+
large
|
|
83
|
+
};
|
|
84
|
+
const handleMainClick = (event)=>{
|
|
85
|
+
const clickHandler = onPress || onClick;
|
|
86
|
+
if (clickHandler) clickHandler(event);
|
|
87
|
+
};
|
|
88
|
+
const handleShow = ()=>{
|
|
89
|
+
if (afterShow) afterShow();
|
|
90
|
+
setOptionsOpen(true);
|
|
91
|
+
};
|
|
92
|
+
const handleHide = ()=>{
|
|
93
|
+
if (afterHide) afterHide();
|
|
94
|
+
setOptionsOpen(false);
|
|
95
|
+
};
|
|
96
|
+
return /*#__PURE__*/ jsx(DropdownContainer, {
|
|
97
|
+
children: /*#__PURE__*/ jsxs(Group, {
|
|
98
|
+
width: collapse ? void 0 : width,
|
|
99
|
+
children: [
|
|
100
|
+
/*#__PURE__*/ jsx(BasicButton, {
|
|
101
|
+
...buttonStyleProps,
|
|
102
|
+
...props,
|
|
103
|
+
ref: ref,
|
|
104
|
+
disabled: disabled || buttonDisabled,
|
|
105
|
+
width: width && !collapse ? '100%' : void 0,
|
|
106
|
+
collapse: collapse,
|
|
107
|
+
loading: loading,
|
|
108
|
+
onPress: handleMainClick,
|
|
109
|
+
hideJoinedBorder: hideDivider,
|
|
110
|
+
joinedPadding: gap,
|
|
111
|
+
children: children && /*#__PURE__*/ jsx(DropdownButtonChildren, {
|
|
112
|
+
children: children
|
|
113
|
+
})
|
|
114
|
+
}),
|
|
115
|
+
/*#__PURE__*/ jsx(DropdownMenu, {
|
|
116
|
+
options: options,
|
|
117
|
+
position: `${direction || 'bottom'} right`,
|
|
118
|
+
afterShow: handleShow,
|
|
119
|
+
afterHide: handleHide,
|
|
120
|
+
isTriggerButton: true,
|
|
121
|
+
trigger: /*#__PURE__*/ jsx(BasicButton, {
|
|
122
|
+
...buttonStyleProps,
|
|
123
|
+
icon: optionsOpen ? 'caret-up' : 'caret-down',
|
|
124
|
+
preventPointerEvents: loading,
|
|
125
|
+
tabIndex: -1,
|
|
126
|
+
joinedPadding: gap,
|
|
127
|
+
disabled: disabled || optionsDisabled
|
|
128
|
+
})
|
|
129
|
+
})
|
|
130
|
+
]
|
|
131
|
+
})
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
const ButtonEl = styled(Button)(({ theme: { accent, font, button }, size = 'medium', joined, circle, iconOnly, iconRight, width, height, animation })=>{
|
|
135
|
+
const isCircle = circle || iconOnly && !joined;
|
|
136
|
+
const buttonSize = button[size];
|
|
137
|
+
const buttonWidth = width || 'max-content';
|
|
138
|
+
const { height: themeHeight, font: fontSize, padding, iconOnlyPadding } = buttonSize;
|
|
139
|
+
const buttonHeight = height || themeHeight;
|
|
140
|
+
const paddingAmount = iconOnly || isCircle ? iconOnlyPadding : padding;
|
|
141
|
+
return {
|
|
142
|
+
display: 'inline-flex',
|
|
143
|
+
alignItems: 'center',
|
|
144
|
+
justifyContent: 'center',
|
|
145
|
+
flexDirection: iconRight ? 'row-reverse' : 'row',
|
|
146
|
+
fontSize,
|
|
147
|
+
width: isCircle ? buttonHeight : buttonWidth,
|
|
148
|
+
height: buttonHeight,
|
|
149
|
+
fontFamily: font.family.default,
|
|
150
|
+
fontWeight: font.weight.bold,
|
|
151
|
+
borderRadius: isCircle ? '50%' : 30,
|
|
152
|
+
cursor: 'pointer',
|
|
153
|
+
outline: 'none',
|
|
154
|
+
outlineOffset: -1,
|
|
155
|
+
padding: `0px ${paddingAmount}px`,
|
|
156
|
+
position: 'relative',
|
|
157
|
+
animation,
|
|
158
|
+
'&:focus-visible': {
|
|
159
|
+
outline: `${accent} solid 1px`
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}, ({ theme, joined, hideJoinedBorder, joinedPadding, iconOnly, outline, negative, positive, caution, secondary, isDisabled, subtle, link })=>{
|
|
163
|
+
const { button, size } = theme;
|
|
164
|
+
let colors = button.primary;
|
|
165
|
+
if (subtle) colors = button.subtle;
|
|
166
|
+
else if (link) colors = button.link;
|
|
167
|
+
else if (isDisabled) colors = button.disabled;
|
|
168
|
+
else if (negative) colors = button.negative;
|
|
169
|
+
else if (positive) colors = button.positive;
|
|
170
|
+
else if (caution) colors = button.caution;
|
|
171
|
+
else if (secondary) colors = button.secondary;
|
|
172
|
+
const buttonBgColor = outline ? colors.outlineBackground : colors.background;
|
|
173
|
+
let buttonTextColor = outline ? colors.outlineColor : colors.color;
|
|
174
|
+
if (link || subtle) {
|
|
175
|
+
let textColors = button.subtle;
|
|
176
|
+
if (link) textColors = button.link;
|
|
177
|
+
if (isDisabled) buttonTextColor = button.disabled.color;
|
|
178
|
+
else if (negative) buttonTextColor = textColors.negativeColor;
|
|
179
|
+
else if (positive) buttonTextColor = textColors.positiveColor;
|
|
180
|
+
else if (caution) buttonTextColor = textColors.cautionColor;
|
|
181
|
+
else if (secondary) buttonTextColor = textColors.secondaryColor;
|
|
182
|
+
}
|
|
183
|
+
const alterLeft = 'left' === joined || 'middle' === joined;
|
|
184
|
+
const alterRight = 'right' === joined || 'middle' === joined;
|
|
185
|
+
const defaultPaddingAmount = iconOnly ? size.xs : size.sm;
|
|
186
|
+
const paddingAmount = joinedPadding || defaultPaddingAmount;
|
|
187
|
+
return {
|
|
188
|
+
background: buttonBgColor.default,
|
|
189
|
+
color: buttonTextColor.default,
|
|
190
|
+
border: outline && !link ? '1px solid' : 'none',
|
|
191
|
+
borderColor: colors.border.default,
|
|
192
|
+
'&:hover': {
|
|
193
|
+
background: buttonBgColor.hover,
|
|
194
|
+
color: buttonTextColor.hover,
|
|
195
|
+
borderColor: outline && !isDisabled ? colors.border.hover : void 0
|
|
196
|
+
},
|
|
197
|
+
'&:active': {
|
|
198
|
+
background: buttonBgColor.active,
|
|
199
|
+
color: buttonTextColor.active,
|
|
200
|
+
borderColor: outline && !isDisabled ? colors.border.active : void 0
|
|
201
|
+
},
|
|
202
|
+
'&:disabled': {
|
|
203
|
+
background: subtle ? 'transparent' : void 0,
|
|
204
|
+
cursor: 'not-allowed'
|
|
205
|
+
},
|
|
206
|
+
borderTopLeftRadius: alterLeft ? 0 : void 0,
|
|
207
|
+
borderBottomLeftRadius: alterLeft ? 0 : void 0,
|
|
208
|
+
borderTopRightRadius: alterRight ? 0 : void 0,
|
|
209
|
+
borderBottomRightRadius: alterRight ? 0 : void 0,
|
|
210
|
+
paddingLeft: alterLeft ? paddingAmount : void 0,
|
|
211
|
+
paddingRight: alterRight ? paddingAmount : void 0,
|
|
212
|
+
borderRight: alterRight && !hideJoinedBorder ? `1px solid ${outline ? colors.border.default : colors.divider}` : void 0,
|
|
213
|
+
borderLeft: alterLeft && !hideJoinedBorder ? 'none' : void 0
|
|
214
|
+
};
|
|
215
|
+
}, ({ link })=>({
|
|
216
|
+
height: link ? 'max-content' : void 0,
|
|
217
|
+
width: link ? 'max-content' : void 0,
|
|
218
|
+
padding: link ? 0 : void 0,
|
|
219
|
+
outlineOffset: link ? 2 : void 0
|
|
220
|
+
}), ({ loading, preventPointerEvents })=>({
|
|
221
|
+
pointerEvents: loading || preventPointerEvents ? 'none' : void 0,
|
|
222
|
+
'& > *': {
|
|
223
|
+
visibility: loading ? 'hidden' : void 0
|
|
224
|
+
},
|
|
225
|
+
'& > .button-loader': {
|
|
226
|
+
visibility: loading ? 'visible' : void 0
|
|
227
|
+
}
|
|
228
|
+
}), ({ theme: { name }, backgroundColor, color, disabled })=>{
|
|
229
|
+
const adjustBgColor = 'dark' === name ? darken : lighten;
|
|
230
|
+
const adjustTextColor = 'dark' === name ? lighten : darken;
|
|
231
|
+
return !disabled && (color || backgroundColor) ? {
|
|
232
|
+
background: backgroundColor,
|
|
233
|
+
color,
|
|
234
|
+
'&:hover': {
|
|
235
|
+
background: backgroundColor ? adjustBgColor(0.05, backgroundColor) : void 0,
|
|
236
|
+
color: color ? adjustTextColor(0.05, color) : void 0
|
|
237
|
+
},
|
|
238
|
+
'&:active': {
|
|
239
|
+
background: backgroundColor ? adjustBgColor(0.1, backgroundColor) : void 0,
|
|
240
|
+
color: color ? adjustTextColor(0.1, color) : void 0
|
|
241
|
+
}
|
|
242
|
+
} : {};
|
|
243
|
+
}, marginProps);
|
|
244
|
+
const DropdownContainer = styled.div({
|
|
245
|
+
display: 'inline-flex',
|
|
246
|
+
flexDirection: 'column',
|
|
247
|
+
position: 'relative'
|
|
248
|
+
});
|
|
249
|
+
const DropdownButtonChildren = styled.div({
|
|
250
|
+
marginRight: 8
|
|
251
|
+
});
|
|
252
|
+
const Inner = styled.span({
|
|
253
|
+
pointerEvents: 'none'
|
|
254
|
+
});
|
|
255
|
+
const components_Button_Button = Object.assign(Button_Button, {
|
|
256
|
+
Group: Group
|
|
257
|
+
});
|
|
258
|
+
export { components_Button_Button as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import Spinner from "../Spinner.js";
|
|
4
|
+
const ButtonLoader = ({ size })=>/*#__PURE__*/ jsx(LoadingContainer, {
|
|
5
|
+
className: "button-loader",
|
|
6
|
+
children: /*#__PURE__*/ jsx(Spinner, {
|
|
7
|
+
size: size
|
|
8
|
+
})
|
|
9
|
+
});
|
|
10
|
+
const LoadingContainer = styled.div({
|
|
11
|
+
position: 'absolute',
|
|
12
|
+
top: '50%',
|
|
13
|
+
left: '50%',
|
|
14
|
+
transform: 'translate(-50%,-50%)',
|
|
15
|
+
display: 'flex',
|
|
16
|
+
justifyContent: 'center',
|
|
17
|
+
alignItems: 'center'
|
|
18
|
+
});
|
|
19
|
+
const Button_ButtonLoader = ButtonLoader;
|
|
20
|
+
export { Button_ButtonLoader as default };
|
|
File without changes
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { Children, cloneElement } from "react";
|
|
4
|
+
import { marginProps } from "../helpers/styledProps.js";
|
|
5
|
+
const Group = ({ children, disabled, outline, size, tiny, small, large, secondary, negative, positive, caution, collapse, ...props })=>{
|
|
6
|
+
if (children) {
|
|
7
|
+
const length = Children.count(children);
|
|
8
|
+
return /*#__PURE__*/ jsx(GroupContainer, {
|
|
9
|
+
...props,
|
|
10
|
+
children: Children.map(children, (child, i)=>{
|
|
11
|
+
let joined;
|
|
12
|
+
if (length > 1) joined = 0 === i ? 'right' : i === length - 1 ? 'left' : 'middle';
|
|
13
|
+
if (child) {
|
|
14
|
+
let element = child;
|
|
15
|
+
if ('trigger' in child.props) element = child.props.trigger;
|
|
16
|
+
const childEl = element;
|
|
17
|
+
const isTiny = tiny || childEl.props.tiny;
|
|
18
|
+
const isSmall = small || childEl.props.small;
|
|
19
|
+
const isLarge = large || childEl.props.large;
|
|
20
|
+
const buttonSize = size || childEl.props.size;
|
|
21
|
+
const isDisabled = disabled || childEl.props.disabled;
|
|
22
|
+
const isOutline = outline || childEl.props.outline;
|
|
23
|
+
const isSecondary = secondary || childEl.props.secondary;
|
|
24
|
+
const isNegative = negative || childEl.props.negative;
|
|
25
|
+
const isPositive = positive || childEl.props.positive;
|
|
26
|
+
const isCaution = caution || childEl.props.caution;
|
|
27
|
+
const isCollapse = collapse || childEl.props.collapse;
|
|
28
|
+
const clonedButton = /*#__PURE__*/ cloneElement(element, {
|
|
29
|
+
joined,
|
|
30
|
+
size: buttonSize,
|
|
31
|
+
tiny: isTiny,
|
|
32
|
+
small: isSmall,
|
|
33
|
+
large: isLarge,
|
|
34
|
+
disabled: isDisabled,
|
|
35
|
+
outline: isOutline,
|
|
36
|
+
secondary: isSecondary,
|
|
37
|
+
negative: isNegative,
|
|
38
|
+
positive: isPositive,
|
|
39
|
+
caution: isCaution,
|
|
40
|
+
collapse: isCollapse
|
|
41
|
+
});
|
|
42
|
+
if ('trigger' in child.props) return /*#__PURE__*/ cloneElement(child, {
|
|
43
|
+
trigger: clonedButton
|
|
44
|
+
});
|
|
45
|
+
return clonedButton;
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
};
|
|
53
|
+
const GroupContainer = styled.div(({ width })=>({
|
|
54
|
+
display: 'inline-flex',
|
|
55
|
+
width
|
|
56
|
+
}), marginProps);
|
|
57
|
+
const Button_Group = Group;
|
|
58
|
+
export { Button_Group as default };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { CalendarDate } from "@internationalized/date";
|
|
4
|
+
import { useRef, useState } from "react";
|
|
5
|
+
import { Calendar } from "react-aria-components";
|
|
6
|
+
import CalendarContainerStyles from "./CalendarParts/CalendarContainerStyles.js";
|
|
7
|
+
import CalendarContent from "./CalendarParts/CalendarContent.js";
|
|
8
|
+
import CalendarHeader from "./CalendarParts/CalendarHeader.js";
|
|
9
|
+
import useMinMax from "./CalendarParts/useMinMax.js";
|
|
10
|
+
import { getDateFromObj, getNow, getObjFromDate } from "./CalendarParts/utils.js";
|
|
11
|
+
const now = getNow();
|
|
12
|
+
const Calendar_Calendar = ({ date, onChange, preventPast, preventFuture, noShadow, ...props })=>{
|
|
13
|
+
const { current: initialDate } = useRef(date ? getObjFromDate(date) : now);
|
|
14
|
+
const [selectedDate, setSelectedDate] = useState(initialDate);
|
|
15
|
+
const [focusedDate, setFocusedDate] = useState(initialDate);
|
|
16
|
+
const { min, max } = useMinMax({
|
|
17
|
+
past: preventPast,
|
|
18
|
+
future: preventFuture
|
|
19
|
+
});
|
|
20
|
+
const handleDateChange = (val)=>{
|
|
21
|
+
const { year, month, day } = val;
|
|
22
|
+
const selected = new CalendarDate(year, month, day);
|
|
23
|
+
setSelectedDate(selected);
|
|
24
|
+
const newDate = getDateFromObj(val);
|
|
25
|
+
if (onChange) onChange(newDate);
|
|
26
|
+
};
|
|
27
|
+
return /*#__PURE__*/ jsxs(CalendarContainer, {
|
|
28
|
+
value: selectedDate,
|
|
29
|
+
onChange: handleDateChange,
|
|
30
|
+
minValue: min,
|
|
31
|
+
maxValue: max,
|
|
32
|
+
noShadow: noShadow,
|
|
33
|
+
focusedValue: focusedDate,
|
|
34
|
+
onFocusChange: setFocusedDate,
|
|
35
|
+
...props,
|
|
36
|
+
children: [
|
|
37
|
+
/*#__PURE__*/ jsx(CalendarHeader, {
|
|
38
|
+
date: focusedDate,
|
|
39
|
+
setDate: setFocusedDate
|
|
40
|
+
}),
|
|
41
|
+
/*#__PURE__*/ jsx(CalendarContent, {
|
|
42
|
+
initialDate: initialDate
|
|
43
|
+
})
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const CalendarContainer = styled(Calendar)(CalendarContainerStyles);
|
|
48
|
+
const components_Calendar = Calendar_Calendar;
|
|
49
|
+
export { components_Calendar as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const baseStyles = ({ theme, noShadow })=>({
|
|
2
|
+
display: 'inline-flex',
|
|
3
|
+
flexDirection: 'column',
|
|
4
|
+
borderRadius: 4,
|
|
5
|
+
width: 'min-content',
|
|
6
|
+
padding: 8,
|
|
7
|
+
backgroundColor: theme.calendar.background.container,
|
|
8
|
+
boxShadow: noShadow ? void 0 : theme.elevation3,
|
|
9
|
+
userSelect: 'none'
|
|
10
|
+
});
|
|
11
|
+
const calendarContainerStyles = [
|
|
12
|
+
baseStyles
|
|
13
|
+
];
|
|
14
|
+
const CalendarContainerStyles = calendarContainerStyles;
|
|
15
|
+
export { CalendarContainerStyles as default };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { isSameDay } from "@internationalized/date";
|
|
4
|
+
import { CalendarCell, CalendarGrid, CalendarGridBody, CalendarGridHeader, CalendarHeaderCell } from "react-aria-components";
|
|
5
|
+
const DATE_SIZE = 28;
|
|
6
|
+
const CalendarContent = ({ range, initialDate })=>/*#__PURE__*/ jsxs(CalendarGrid, {
|
|
7
|
+
children: [
|
|
8
|
+
/*#__PURE__*/ jsx(CalendarGridHeader, {
|
|
9
|
+
children: (day)=>/*#__PURE__*/ jsx(Day, {
|
|
10
|
+
children: day
|
|
11
|
+
})
|
|
12
|
+
}),
|
|
13
|
+
/*#__PURE__*/ jsx(Dates, {
|
|
14
|
+
range: range,
|
|
15
|
+
children: (calDate)=>/*#__PURE__*/ jsx(DateItem, {
|
|
16
|
+
date: calDate,
|
|
17
|
+
current: initialDate ? isSameDay(calDate, initialDate) : void 0,
|
|
18
|
+
range: range
|
|
19
|
+
})
|
|
20
|
+
})
|
|
21
|
+
]
|
|
22
|
+
});
|
|
23
|
+
const Dates = styled(CalendarGridBody)({
|
|
24
|
+
'& > tr > td': {
|
|
25
|
+
padding: '2px 4px'
|
|
26
|
+
},
|
|
27
|
+
'& > tr > td:first-of-type': {
|
|
28
|
+
paddingLeft: 0
|
|
29
|
+
},
|
|
30
|
+
'& > tr > td:last-of-type': {
|
|
31
|
+
paddingRight: 0
|
|
32
|
+
},
|
|
33
|
+
'& > tr:first-of-type > td': {
|
|
34
|
+
paddingTop: 0
|
|
35
|
+
},
|
|
36
|
+
'& > tr:last-of-type > td': {
|
|
37
|
+
paddingBottom: 0
|
|
38
|
+
},
|
|
39
|
+
'& > tr > td[aria-disabled]': {
|
|
40
|
+
cursor: 'default'
|
|
41
|
+
},
|
|
42
|
+
'& > tr > td[aria-selected]': {
|
|
43
|
+
position: 'relative'
|
|
44
|
+
}
|
|
45
|
+
}, ({ theme: { calendar, color }, range })=>range && {
|
|
46
|
+
'& > tr > td[aria-selected]::after': {
|
|
47
|
+
background: calendar.background.activeRange,
|
|
48
|
+
content: '""',
|
|
49
|
+
height: DATE_SIZE,
|
|
50
|
+
left: 0,
|
|
51
|
+
position: 'absolute',
|
|
52
|
+
right: 0,
|
|
53
|
+
top: '50%',
|
|
54
|
+
transform: 'translateY(-50%)',
|
|
55
|
+
zIndex: 0
|
|
56
|
+
},
|
|
57
|
+
'& > tr > td[aria-selected][aria-invalid]::after': {
|
|
58
|
+
backgroundColor: color.errorTint2
|
|
59
|
+
},
|
|
60
|
+
'& > tr > td[aria-selected]:has(div[data-selection-start])::after': {
|
|
61
|
+
left: '50%'
|
|
62
|
+
},
|
|
63
|
+
'& > tr > td[aria-selected]:has(div[data-selection-end])::after': {
|
|
64
|
+
right: '50%'
|
|
65
|
+
},
|
|
66
|
+
'& > tr:first-of-type > td[aria-selected]::after': {
|
|
67
|
+
transform: 'translateY(calc(-50% - 1px))'
|
|
68
|
+
},
|
|
69
|
+
'& > tr:last-of-type > td[aria-selected]::after': {
|
|
70
|
+
transform: 'translateY(calc(-50% + 1px))'
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const DateItem = styled(CalendarCell)(({ theme: { accent, font, calendar, color }, range = false })=>({
|
|
74
|
+
width: DATE_SIZE,
|
|
75
|
+
height: DATE_SIZE,
|
|
76
|
+
lineHeight: `${DATE_SIZE}px`,
|
|
77
|
+
textAlign: 'center',
|
|
78
|
+
borderRadius: '50%',
|
|
79
|
+
cursor: 'pointer',
|
|
80
|
+
border: 'none',
|
|
81
|
+
fontSize: font.size.md,
|
|
82
|
+
fontWeight: font.weight.default,
|
|
83
|
+
color: calendar.color.default,
|
|
84
|
+
outline: 'none',
|
|
85
|
+
outlineOffset: -1,
|
|
86
|
+
position: 'relative',
|
|
87
|
+
zIndex: 1,
|
|
88
|
+
'&[data-disabled]': {
|
|
89
|
+
color: calendar.color.disabled,
|
|
90
|
+
cursor: 'default',
|
|
91
|
+
'&:hover': {
|
|
92
|
+
backgroundColor: 'transparent'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
'&[data-hovered]': {
|
|
96
|
+
backgroundColor: calendar.background.hover
|
|
97
|
+
},
|
|
98
|
+
'&[data-focus-visible]': {
|
|
99
|
+
outline: `${accent} solid 1px`
|
|
100
|
+
},
|
|
101
|
+
'&[data-outside-month]': {
|
|
102
|
+
display: 'none'
|
|
103
|
+
},
|
|
104
|
+
'&[data-selected]': {
|
|
105
|
+
backgroundColor: calendar.background.active,
|
|
106
|
+
color: calendar.color.active,
|
|
107
|
+
'&[data-hovered]': {
|
|
108
|
+
backgroundColor: calendar.background.activeHover
|
|
109
|
+
},
|
|
110
|
+
'&[data-focus-visible]': {
|
|
111
|
+
outline: `${accent} solid 1px`
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
'&[data-selected]:not([data-selection-start]):not([data-selection-end])': {
|
|
115
|
+
backgroundColor: range ? 'transparent' : void 0,
|
|
116
|
+
'&[data-hovered]:not([data-invalid])': {
|
|
117
|
+
backgroundColor: calendar.background.activeHover
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
'&[data-selected][data-invalid]': {
|
|
121
|
+
backgroundColor: color.error,
|
|
122
|
+
'&[data-hovered]': {
|
|
123
|
+
backgroundColor: color.errorShade2
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}), ({ theme: { calendar }, current })=>({
|
|
127
|
+
color: current ? calendar.color.current : void 0
|
|
128
|
+
}));
|
|
129
|
+
const Day = styled(CalendarHeaderCell)(({ theme: { font, calendar } })=>({
|
|
130
|
+
fontSize: font.size.sm,
|
|
131
|
+
fontWeight: font.weight.medium,
|
|
132
|
+
color: calendar.color.weekday,
|
|
133
|
+
textAlign: 'center',
|
|
134
|
+
paddingBottom: 8,
|
|
135
|
+
width: 40
|
|
136
|
+
}));
|
|
137
|
+
const CalendarParts_CalendarContent = CalendarContent;
|
|
138
|
+
export { CalendarParts_CalendarContent as default };
|