@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.
Files changed (229) hide show
  1. package/build/assets/icons/CaretDown.js +18 -0
  2. package/build/assets/icons/CaretUp.js +18 -0
  3. package/build/assets/icons/Checkbox.js +15 -0
  4. package/build/assets/icons/CheckboxOff.js +15 -0
  5. package/build/assets/icons/CheckboxPartial.js +15 -0
  6. package/build/assets/icons/Dialpad.js +18 -0
  7. package/build/assets/icons/Exclamation.js +25 -0
  8. package/build/assets/icons/Phone.js +13 -0
  9. package/build/assets/icons/PhoneAdd.js +21 -0
  10. package/build/assets/icons/PhoneBlocked.js +22 -0
  11. package/build/assets/icons/PhoneCallback.js +21 -0
  12. package/build/assets/icons/PhoneEnd.js +28 -0
  13. package/build/assets/icons/PhoneForward.js +22 -0
  14. package/build/assets/icons/PhoneHistory.js +21 -0
  15. package/build/assets/icons/PhoneHold.js +22 -0
  16. package/build/assets/icons/PhoneIncoming.js +22 -0
  17. package/build/assets/icons/PhoneMissed.js +22 -0
  18. package/build/assets/icons/PhoneTalk.js +22 -0
  19. package/build/assets/icons/PhoneTransfer.js +21 -0
  20. package/build/assets/icons/RadioButton.js +22 -0
  21. package/build/assets/icons/RadioButtonOff.js +15 -0
  22. package/build/assets/icons/Record.js +18 -0
  23. package/build/assets/icons/Screenshot.js +39 -0
  24. package/build/assets/icons/ShieldWavv.js +30 -0
  25. package/build/assets/icons/Spotify.js +15 -0
  26. package/build/assets/icons/SubArrow.js +16 -0
  27. package/build/assets/icons/ToggleOff.js +15 -0
  28. package/build/assets/icons/ToggleOn.js +15 -0
  29. package/build/assets/icons/TransferCancel.js +60 -0
  30. package/build/components/Accordion/Accordion.js +26 -0
  31. package/build/components/Accordion/Header.js +86 -0
  32. package/build/components/Accordion/Item.js +25 -0
  33. package/build/components/Accordion/Panel.js +64 -0
  34. package/build/components/Accordion/index.js +2 -0
  35. package/build/components/Audio.js +248 -0
  36. package/build/components/BarChart.js +123 -0
  37. package/build/components/Button/Button.js +258 -0
  38. package/build/components/Button/ButtonLoader.js +20 -0
  39. package/build/components/Button/ButtonTypes.js +0 -0
  40. package/build/components/Button/Group.js +58 -0
  41. package/build/components/Button/index.js +2 -0
  42. package/build/components/Calendar.js +49 -0
  43. package/build/components/CalendarParts/CalendarContainerStyles.js +15 -0
  44. package/build/components/CalendarParts/CalendarContent.js +138 -0
  45. package/build/components/CalendarParts/CalendarHeader.js +146 -0
  46. package/build/components/CalendarParts/useMinMax.js +23 -0
  47. package/build/components/CalendarParts/utils.js +6 -0
  48. package/build/components/ChartHelpers.js +121 -0
  49. package/build/components/Checkbox.js +85 -0
  50. package/build/components/Code/Code.js +117 -0
  51. package/build/components/Code/Copy.js +50 -0
  52. package/build/components/Code/Endpoint.js +82 -0
  53. package/build/components/Code/index.js +3 -0
  54. package/build/components/ComboBox.js +190 -0
  55. package/build/components/CommandMenu/CommandItem.js +32 -0
  56. package/build/components/CommandMenu/CommandMenu.js +136 -0
  57. package/build/components/CommandMenu/CommandOptions.js +24 -0
  58. package/build/components/CommandMenu/CommandSection.js +19 -0
  59. package/build/components/CommandMenu/index.js +2 -0
  60. package/build/components/DateRangeSelect.js +359 -0
  61. package/build/components/DocTable.js +32 -0
  62. package/build/components/Dot.js +60 -0
  63. package/build/components/DraftEditor.js +188 -0
  64. package/build/components/Dropdown.js +130 -0
  65. package/build/components/DropdownMenu.js +131 -0
  66. package/build/components/DropdownMenuParts/Menu.js +6 -0
  67. package/build/components/DropdownMenuParts/MenuItem.js +54 -0
  68. package/build/components/DropdownMenuParts/MenuOptions.js +47 -0
  69. package/build/components/DropdownMenuParts/MenuSection.js +14 -0
  70. package/build/components/DropdownSelect.js +171 -0
  71. package/build/components/DynamicIcon.js +49 -0
  72. package/build/components/Editor/Editor.js +356 -0
  73. package/build/components/Editor/EditorStyles.js +259 -0
  74. package/build/components/Editor/MergeFieldExtension.js +110 -0
  75. package/build/components/Editor/RichTextToolbar.js +515 -0
  76. package/build/components/Editor/editorUtils.js +213 -0
  77. package/build/components/Editor/index.js +3 -0
  78. package/build/components/Ellipsis.js +22 -0
  79. package/build/components/Focusable.js +20 -0
  80. package/build/components/Form.js +68 -0
  81. package/build/components/FormControl.js +72 -0
  82. package/build/components/Grid.js +53 -0
  83. package/build/components/Icon/Icon.js +89 -0
  84. package/build/components/Icon/customIcons.js +48 -0
  85. package/build/components/Icon/icons.js +145 -0
  86. package/build/components/Icon/index.js +3 -0
  87. package/build/components/ImageViewer.js +142 -0
  88. package/build/components/InlineCode.js +10 -0
  89. package/build/components/InputHelpers.js +106 -0
  90. package/build/components/Inputs/DatePicker.js +111 -0
  91. package/build/components/Inputs/DateRangePicker.js +166 -0
  92. package/build/components/Inputs/InlineInput.js +71 -0
  93. package/build/components/Inputs/NumberInput.js +117 -0
  94. package/build/components/Inputs/PhoneInput.js +96 -0
  95. package/build/components/Inputs/SearchInput.js +84 -0
  96. package/build/components/Inputs/TextArea.js +164 -0
  97. package/build/components/Inputs/TextInput.js +74 -0
  98. package/build/components/Inputs/TimeInput.js +74 -0
  99. package/build/components/Inputs/helpers/AriaButton.js +19 -0
  100. package/build/components/Inputs/helpers/DateSegment.js +22 -0
  101. package/build/components/Inputs/helpers/Description.js +11 -0
  102. package/build/components/Inputs/helpers/ErrorMessage.js +11 -0
  103. package/build/components/Inputs/helpers/Input.js +6 -0
  104. package/build/components/Inputs/helpers/InputContainerStyles.js +78 -0
  105. package/build/components/Inputs/helpers/InputMessage.js +30 -0
  106. package/build/components/Inputs/helpers/InputStyles.js +43 -0
  107. package/build/components/Inputs/helpers/Label.js +42 -0
  108. package/build/components/Inputs/helpers/LabelWrapper.js +14 -0
  109. package/build/components/Inputs/helpers/PickerToggle.js +7 -0
  110. package/build/components/Inputs/helpers/TextArea.js +8 -0
  111. package/build/components/Inputs/helpers/filterPastedText.js +9 -0
  112. package/build/components/Inputs/helpers/handlePaste.js +12 -0
  113. package/build/components/Inputs/helpers/isAcceptable.js +7 -0
  114. package/build/components/Inputs/helpers/useDynamicWidth.js +39 -0
  115. package/build/components/Inputs/helpers/useInputFocus.js +19 -0
  116. package/build/components/Label.js +42 -0
  117. package/build/components/LineChart.js +80 -0
  118. package/build/components/ListBoxParts/GridListItem.js +34 -0
  119. package/build/components/ListBoxParts/ListBoxItem.js +32 -0
  120. package/build/components/ListBoxParts/ListOptions.js +45 -0
  121. package/build/components/ListHelpers/GridListHeader.js +14 -0
  122. package/build/components/ListHelpers/GridListSection.js +14 -0
  123. package/build/components/ListHelpers/ItemHeaderBody.js +36 -0
  124. package/build/components/ListHelpers/ListHeader.js +14 -0
  125. package/build/components/ListHelpers/ListItemStyles.js +52 -0
  126. package/build/components/ListHelpers/ListRootStyles.js +14 -0
  127. package/build/components/ListHelpers/ListSection.js +14 -0
  128. package/build/components/ListHelpers/ListStyles.js +29 -0
  129. package/build/components/Menu.js +159 -0
  130. package/build/components/Message.js +107 -0
  131. package/build/components/MessageHr.js +32 -0
  132. package/build/components/Modal.js +212 -0
  133. package/build/components/MotionPopover.js +39 -0
  134. package/build/components/MultiSelect/MultiSelect.js +263 -0
  135. package/build/components/MultiSelect/SearchDropdown.js +155 -0
  136. package/build/components/MultiSelect/index.js +2 -0
  137. package/build/components/OptionHelpers/Container.js +34 -0
  138. package/build/components/OptionHelpers/Item.js +59 -0
  139. package/build/components/OptionHelpers/types.js +0 -0
  140. package/build/components/Pagination.js +121 -0
  141. package/build/components/PieChart.js +40 -0
  142. package/build/components/Popover.js +40 -0
  143. package/build/components/PortalScope.js +8 -0
  144. package/build/components/Progress/CirclePercent.js +56 -0
  145. package/build/components/Progress/Progress.js +59 -0
  146. package/build/components/Progress/index.js +3 -0
  147. package/build/components/Radio.js +45 -0
  148. package/build/components/RangeCalendar.js +60 -0
  149. package/build/components/Select.js +162 -0
  150. package/build/components/Slider.js +50 -0
  151. package/build/components/Spinner.js +70 -0
  152. package/build/components/Table/Body.js +49 -0
  153. package/build/components/Table/Cell.js +63 -0
  154. package/build/components/Table/Check.js +35 -0
  155. package/build/components/Table/Column.js +129 -0
  156. package/build/components/Table/ColumnSort.js +26 -0
  157. package/build/components/Table/Header.js +64 -0
  158. package/build/components/Table/Resizer.js +25 -0
  159. package/build/components/Table/Row.js +84 -0
  160. package/build/components/Table/SortCaret.js +24 -0
  161. package/build/components/Table/Table.js +88 -0
  162. package/build/components/Table/contentStyles.js +20 -0
  163. package/build/components/Table/context.js +4 -0
  164. package/build/components/Table/index.js +2 -0
  165. package/build/components/Table/types.js +0 -0
  166. package/build/components/Tabs.js +151 -0
  167. package/build/components/Tag.js +71 -0
  168. package/build/components/Toggle.js +59 -0
  169. package/build/components/ToggleButton/ToggleButton.js +104 -0
  170. package/build/components/ToggleButton/ToggleButtonGroup.js +36 -0
  171. package/build/components/ToggleButton/context.js +8 -0
  172. package/build/components/ToggleButton/index.js +3 -0
  173. package/build/components/Tooltip.js +136 -0
  174. package/build/components/TransferList.js +234 -0
  175. package/build/components/Tree/Tree.js +69 -0
  176. package/build/components/Tree/TreeContext.js +3 -0
  177. package/build/components/Tree/TreeItem.js +93 -0
  178. package/build/components/Tree/index.js +2 -0
  179. package/build/components/UnstyledButton.js +8 -0
  180. package/build/components/Waveform.js +243 -0
  181. package/build/components/draftUtils.js +193 -0
  182. package/build/components/helpers/getIcon.js +28 -0
  183. package/build/components/helpers/getPopPosition.js +20 -0
  184. package/build/components/helpers/isPropAllowed.js +3 -0
  185. package/build/components/helpers/mergePadding.js +47 -0
  186. package/build/components/helpers/styledProps.js +34 -0
  187. package/build/components/typeDefs/elementTypes.js +0 -0
  188. package/build/components/typeDefs/inputTypes.js +0 -0
  189. package/build/components/typeDefs/selectionTypes.js +0 -0
  190. package/build/components/typeDefs/tagTypes.js +0 -0
  191. package/build/components/types.js +0 -0
  192. package/build/global-styles/GlobalStorybookStyles.js +108 -0
  193. package/build/global-styles/ResetStyles.js +33 -0
  194. package/build/global-styles/ScrollbarStyles.js +26 -0
  195. package/build/global-styles/ToastStyles.js +66 -0
  196. package/build/global-styles/index.js +4 -0
  197. package/build/hooks/index.js +9 -0
  198. package/build/hooks/useConfirm.js +91 -0
  199. package/build/hooks/useControlledOpenState.js +22 -0
  200. package/build/hooks/useCopy.js +28 -0
  201. package/build/hooks/useElementObserver.js +6 -0
  202. package/build/hooks/useEventListener.js +19 -0
  203. package/build/hooks/useOnClickOutside.js +21 -0
  204. package/build/hooks/usePrevious.js +12 -0
  205. package/build/hooks/useSelectAll.js +60 -0
  206. package/build/hooks/useWindowSize.js +25 -0
  207. package/build/theme/ThemeTypes.js +0 -0
  208. package/build/theme/common/button.js +33 -0
  209. package/build/theme/common/common.js +38 -0
  210. package/build/theme/common/index.js +4 -0
  211. package/build/theme/core/colors.js +77 -0
  212. package/build/theme/core/dark/dark.js +457 -0
  213. package/build/theme/core/dark/darkScale.js +36 -0
  214. package/build/theme/core/light/light.js +456 -0
  215. package/build/theme/core/light/lightScale.js +35 -0
  216. package/build/theme/eighties/colors.js +78 -0
  217. package/build/theme/eighties/dark/dark.js +457 -0
  218. package/build/theme/eighties/dark/darkScale.js +36 -0
  219. package/build/theme/eighties/light/light.js +456 -0
  220. package/build/theme/eighties/light/lightScale.js +35 -0
  221. package/build/theme/index.js +28 -0
  222. package/build/utils/chunk.js +13 -0
  223. package/build/utils/copyToClipboard.js +29 -0
  224. package/build/utils/flattenListOptions.js +4 -0
  225. package/build/utils/formatDate.js +55 -0
  226. package/build/utils/index.js +6 -0
  227. package/build/utils/numberWithCommas.js +3 -0
  228. package/build/utils/range.js +11 -0
  229. package/package.json +1 -1
@@ -0,0 +1,60 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ const TransferCancel = (props)=>/*#__PURE__*/ jsxs("svg", {
3
+ viewBox: "0 0 24 24",
4
+ fill: "none",
5
+ xmlns: "http://www.w3.org/2000/svg",
6
+ ...props,
7
+ children: [
8
+ /*#__PURE__*/ jsx("path", {
9
+ d: "M16 3L20 7L16 11",
10
+ stroke: "currentColor",
11
+ strokeWidth: "1.5",
12
+ strokeLinecap: "round",
13
+ strokeLinejoin: "round"
14
+ }),
15
+ /*#__PURE__*/ jsx("path", {
16
+ d: "M20 7L11 7",
17
+ stroke: "currentColor",
18
+ strokeWidth: "1.5",
19
+ strokeLinecap: "round",
20
+ strokeLinejoin: "round"
21
+ }),
22
+ /*#__PURE__*/ jsx("path", {
23
+ d: "M7 7H4",
24
+ stroke: "currentColor",
25
+ strokeWidth: "1.5",
26
+ strokeLinecap: "round",
27
+ strokeLinejoin: "round"
28
+ }),
29
+ /*#__PURE__*/ jsx("path", {
30
+ d: "M20 21L4 3",
31
+ stroke: "currentColor",
32
+ strokeWidth: "1.5",
33
+ strokeLinecap: "round",
34
+ strokeLinejoin: "round"
35
+ }),
36
+ /*#__PURE__*/ jsx("path", {
37
+ d: "M8 21L4 17L8 13",
38
+ stroke: "currentColor",
39
+ strokeWidth: "1.5",
40
+ strokeLinecap: "round",
41
+ strokeLinejoin: "round"
42
+ }),
43
+ /*#__PURE__*/ jsx("path", {
44
+ d: "M4 17H16",
45
+ stroke: "currentColor",
46
+ strokeWidth: "1.5",
47
+ strokeLinecap: "round",
48
+ strokeLinejoin: "round"
49
+ }),
50
+ /*#__PURE__*/ jsx("path", {
51
+ d: "M19.5 17H20",
52
+ stroke: "currentColor",
53
+ strokeWidth: "1.5",
54
+ strokeLinecap: "round",
55
+ strokeLinejoin: "round"
56
+ })
57
+ ]
58
+ });
59
+ const icons_TransferCancel = TransferCancel;
60
+ export { icons_TransferCancel as default };
@@ -0,0 +1,26 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import styled from "@emotion/styled";
3
+ import { DisclosureGroup } from "react-aria-components";
4
+ import { marginProps, maxWidthHeightProps, widthHeightProps } from "../helpers/styledProps.js";
5
+ import Header from "./Header.js";
6
+ import Item from "./Item.js";
7
+ import Panel from "./Panel.js";
8
+ const Accordion = ({ children, maxHeight, ...props })=>/*#__PURE__*/ jsx(Container, {
9
+ style: {
10
+ maxHeight
11
+ },
12
+ ...props,
13
+ children: children
14
+ });
15
+ const Container = styled(DisclosureGroup)({
16
+ overflow: 'hidden',
17
+ position: 'relative',
18
+ display: 'flex',
19
+ flexDirection: 'column',
20
+ gap: 8
21
+ }, widthHeightProps, maxWidthHeightProps, marginProps);
22
+ Accordion.Item = Item;
23
+ Accordion.Header = Header;
24
+ Accordion.Panel = Panel;
25
+ const Accordion_Accordion = Accordion;
26
+ export { Accordion_Accordion as default };
@@ -0,0 +1,86 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import styled from "@emotion/styled";
3
+ import { useRef } from "react";
4
+ import { Heading } from "react-aria-components";
5
+ import Ellipsis from "../Ellipsis.js";
6
+ import getIcon from "../helpers/getIcon.js";
7
+ import isPropAllowed from "../helpers/isPropAllowed.js";
8
+ import { paddingProps } from "../helpers/styledProps.js";
9
+ import Icon from "../Icon/index.js";
10
+ import AriaButton from "../Inputs/helpers/AriaButton.js";
11
+ const Header_Header = ({ children, triggerIconPosition = 'right', background, title, iconLeft, iconRight, ...props })=>{
12
+ const triggerRef = useRef(null);
13
+ return /*#__PURE__*/ jsxs(HeaderContainer, {
14
+ onClick: ()=>triggerRef.current?.click(),
15
+ background: background,
16
+ ...props,
17
+ children: [
18
+ 'left' === triggerIconPosition && /*#__PURE__*/ jsx(Icon, {
19
+ name: "chevron-left",
20
+ className: "trigger-icon left"
21
+ }),
22
+ iconLeft && getIcon(iconLeft),
23
+ /*#__PURE__*/ jsx(Title, {
24
+ children: /*#__PURE__*/ jsx(AriaButton, {
25
+ slot: "trigger",
26
+ ref: triggerRef,
27
+ width: "100%",
28
+ children: /*#__PURE__*/ jsx(Ellipsis, {
29
+ children: title
30
+ })
31
+ })
32
+ }),
33
+ /*#__PURE__*/ jsx(Content, {
34
+ children: children
35
+ }),
36
+ iconRight && getIcon(iconRight),
37
+ 'right' === triggerIconPosition && /*#__PURE__*/ jsx(Icon, {
38
+ name: "chevron-right",
39
+ className: "trigger-icon right"
40
+ })
41
+ ]
42
+ });
43
+ };
44
+ const HeaderContainer = styled.div(({ theme, background, height })=>({
45
+ margin: 0,
46
+ display: 'flex',
47
+ gap: 8,
48
+ padding: 8,
49
+ height,
50
+ backgroundColor: background || theme.scale0,
51
+ alignItems: 'center',
52
+ fontSize: '1rem',
53
+ fontWeight: 'normal',
54
+ color: 'inherit',
55
+ borderRadius: 4,
56
+ cursor: 'pointer',
57
+ '& > .trigger-icon': {
58
+ transition: 'transform 300ms'
59
+ }
60
+ }), paddingProps);
61
+ const Title = styled(Heading, {
62
+ shouldForwardProp: (prop)=>isPropAllowed(prop, [
63
+ 'reverse',
64
+ 'spaced'
65
+ ])
66
+ })(({ theme, reverse })=>({
67
+ backgroundColor: 'transparent',
68
+ color: theme.scale10,
69
+ border: 'none',
70
+ display: 'flex',
71
+ flexDirection: reverse ? 'row-reverse' : 'row',
72
+ justifyContent: 'space-between',
73
+ alignItems: 'center',
74
+ fontSize: theme.font.size.md,
75
+ margin: 0,
76
+ textAlign: 'left',
77
+ overflow: 'hidden'
78
+ }));
79
+ const Content = styled.div({
80
+ display: 'flex',
81
+ alignItems: 'center',
82
+ flexGrow: 1
83
+ });
84
+ Header_Header.displayName = 'Accordion.Header';
85
+ const Header = Header_Header;
86
+ export { Header as default };
@@ -0,0 +1,25 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import styled from "@emotion/styled";
3
+ import { Disclosure } from "react-aria-components";
4
+ const Item = ({ children, ...props })=>/*#__PURE__*/ jsx(ItemContainer, {
5
+ ...props,
6
+ children: children
7
+ });
8
+ const ItemContainer = styled(Disclosure)(({ theme })=>({
9
+ '&[data-expanded="true"]': {
10
+ '& > div:first-of-type': {
11
+ borderBottomLeftRadius: 0,
12
+ borderBottomRightRadius: 0,
13
+ backgroundColor: theme.scale1,
14
+ '& > .trigger-icon.left': {
15
+ transform: 'rotate(-90deg)'
16
+ },
17
+ '& > .trigger-icon.right': {
18
+ transform: 'rotate(90deg)'
19
+ }
20
+ }
21
+ }
22
+ }));
23
+ Item.displayName = 'Accordion.Item';
24
+ const Accordion_Item = Item;
25
+ export { Accordion_Item as default };
@@ -0,0 +1,64 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import styled from "@emotion/styled";
3
+ import { useRef, useState } from "react";
4
+ import { DisclosurePanel } from "react-aria-components";
5
+ import { useElementObserver } from "../../hooks/index.js";
6
+ import isPropAllowed from "../helpers/isPropAllowed.js";
7
+ const Panel = ({ children, maxHeight, ...props })=>{
8
+ const contentRef = useRef(null);
9
+ const [calculatedMaxHeight, setCalculatedMaxHeight] = useState();
10
+ const setHeight = (node)=>{
11
+ const open = 'false' === node.getAttribute('aria-hidden');
12
+ if (!open) return;
13
+ const item = node.parentElement;
14
+ const accordion = item?.parentElement;
15
+ const accMaxHeight = accordion?.style.maxHeight;
16
+ const containerMaxHeight = accMaxHeight ? accMaxHeight.match(/^[0-9]+/g)?.pop() : void 0;
17
+ if (!containerMaxHeight || !accordion) return void node.scrollTo(0, 0);
18
+ const allItems = [
19
+ ...accordion.childNodes
20
+ ];
21
+ const index = allItems.indexOf(item) + 1;
22
+ const siblings = allItems.slice(index);
23
+ const siblingHeights = siblings.length > 0 ? siblings.reduce((acc, child)=>acc + child.clientHeight, 0) : 0;
24
+ const { offsetTop } = node;
25
+ const spacedMargin = (allItems.length - 1) * 8;
26
+ const containerHeight = containerMaxHeight || 0;
27
+ const height = containerHeight - offsetTop - siblingHeights - spacedMargin;
28
+ if (height !== calculatedMaxHeight) setCalculatedMaxHeight(height);
29
+ node.scrollTo(0, 0);
30
+ };
31
+ useElementObserver(contentRef, setHeight);
32
+ return /*#__PURE__*/ jsx(PanelContainer, {
33
+ ref: contentRef,
34
+ maxHeight: maxHeight || calculatedMaxHeight,
35
+ defaultPadding: 'string' == typeof children,
36
+ ...props,
37
+ children: children
38
+ });
39
+ };
40
+ const PanelContainer = styled(DisclosurePanel, {
41
+ shouldForwardProp: (prop)=>isPropAllowed(prop, [
42
+ 'defaultPadding',
43
+ 'maxHeight'
44
+ ])
45
+ })(({ theme, maxHeight, defaultPadding, background })=>({
46
+ backgroundColor: background || theme.scale0,
47
+ color: theme.scale10,
48
+ fontSize: theme.font.size.md,
49
+ overflow: 'auto',
50
+ maxHeight,
51
+ borderBottomLeftRadius: 4,
52
+ borderBottomRightRadius: 4,
53
+ height: 'var(--disclosure-panel-height)',
54
+ transition: 'height 250ms',
55
+ '&[aria-hidden="true"]': {
56
+ opacity: 0
57
+ },
58
+ '&[aria-hidden="false"]': {
59
+ padding: defaultPadding ? '4px 16px' : void 0
60
+ }
61
+ }));
62
+ Panel.displayName = 'Accordion.Panel';
63
+ const Accordion_Panel = Panel;
64
+ export { Accordion_Panel as default };
@@ -0,0 +1,2 @@
1
+ import Accordion from "./Accordion.js";
2
+ export { Accordion as default };
@@ -0,0 +1,248 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import styled from "@emotion/styled";
3
+ import { useEffect, useImperativeHandle, useRef, useState } from "react";
4
+ import Button from "./Button/index.js";
5
+ import { marginProps } from "./helpers/styledProps.js";
6
+ import Slider from "./Slider.js";
7
+ import Waveform from "./Waveform.js";
8
+ const Audio_Audio = ({ src, title, width, infoPosition, centerAlignContent, small, tiny, iconOnly, buttonProps, collapsed, hideSliderOnStop, hideTimeOnStop, hideCurrentTime, fontSizeTitle, fontSizeTime, fallbackDuration, waveform, onPlay, onPause, onStop, ref, ...rest })=>{
9
+ const [isPlaying, setIsPlaying] = useState(false);
10
+ const [isCleared, setIsCleared] = useState(true);
11
+ const [progress, setProgress] = useState(0);
12
+ const [totalDuration, setTotalDuration] = useState(0);
13
+ const [displayCurrent, setDisplayCurrent] = useState('');
14
+ const [displayDuration, setDisplayDuration] = useState('0:00');
15
+ const audioRef = useRef(null);
16
+ const { height = 30, showHoverTime = false, playedColor, unplayedColor } = 'object' == typeof waveform ? waveform : {};
17
+ const play = ()=>{
18
+ const { current: audio } = audioRef;
19
+ if (audio) audio.play().catch(()=>{
20
+ throw Error('Video failed to play');
21
+ });
22
+ };
23
+ const pause = ()=>{
24
+ const { current: audio } = audioRef;
25
+ if (audio) audio.pause();
26
+ };
27
+ const stop = ()=>{
28
+ const { current: audio } = audioRef;
29
+ if (audio) audio.load();
30
+ };
31
+ const checkIsPlaying = ()=>{
32
+ const { current: audio } = audioRef;
33
+ return audio ? !audio.paused : false;
34
+ };
35
+ const togglePlayPause = ()=>{
36
+ if (isPlaying) pause();
37
+ else play();
38
+ };
39
+ useImperativeHandle(ref, ()=>({
40
+ play,
41
+ pause,
42
+ stop
43
+ }), [
44
+ audioRef,
45
+ isPlaying
46
+ ]);
47
+ const handleAudioPlay = (event)=>{
48
+ setIsPlaying(true);
49
+ setIsCleared(false);
50
+ if (onPlay) onPlay(event);
51
+ };
52
+ const handleAudioPause = (event)=>{
53
+ setIsPlaying(false);
54
+ if (onPause) onPause(event);
55
+ };
56
+ const handleAudioStop = (event)=>{
57
+ setIsPlaying(false);
58
+ setIsCleared(true);
59
+ if (onStop) onStop(event);
60
+ };
61
+ const handleAudioError = ()=>{
62
+ const { current: audio } = audioRef;
63
+ if (audio) setTimeout(()=>{
64
+ audio.load();
65
+ }, 500);
66
+ };
67
+ useEffect(()=>{
68
+ checkIsPlaying();
69
+ }, [
70
+ isPlaying
71
+ ]);
72
+ useEffect(()=>{
73
+ const { current: audio } = audioRef;
74
+ if (audio && src) {
75
+ audio.load();
76
+ const checkDuration = setTimeout(()=>{
77
+ if (audio.duration && Number.isFinite(audio.duration) && audio.duration > 0 && audio.duration !== 1 / 0) {
78
+ setTotalDuration(audio.duration);
79
+ setDisplayDuration(formatTime(audio.duration));
80
+ } else if (fallbackDuration && Number.isFinite(fallbackDuration) && fallbackDuration > 0) {
81
+ setTotalDuration(fallbackDuration);
82
+ setDisplayDuration(formatTime(fallbackDuration));
83
+ }
84
+ }, 500);
85
+ return ()=>clearTimeout(checkDuration);
86
+ }
87
+ }, [
88
+ src,
89
+ fallbackDuration
90
+ ]);
91
+ const formatTime = (time)=>{
92
+ if (!Number.isFinite(time) || time < 0) return '0:00';
93
+ const mins = Math.floor(time / 60);
94
+ const secs = Math.floor(time % 60);
95
+ return `${mins}:${secs.toString().padStart(2, '0')}`;
96
+ };
97
+ const updateProgress = ()=>{
98
+ const { current: audio } = audioRef;
99
+ if (audio) {
100
+ const { currentTime } = audio;
101
+ if (Number.isFinite(currentTime) && currentTime >= 0) {
102
+ const current = formatTime(currentTime);
103
+ setProgress(currentTime);
104
+ setDisplayCurrent(current);
105
+ }
106
+ }
107
+ };
108
+ const handleLoad = ()=>{
109
+ const { current: audio } = audioRef;
110
+ if (audio) {
111
+ const { duration, readyState } = audio;
112
+ if (Number.isFinite(duration) && duration > 0 && duration !== 1 / 0) {
113
+ const audioLength = formatTime(duration);
114
+ setTotalDuration(duration);
115
+ setDisplayDuration(audioLength);
116
+ } else if (fallbackDuration && Number.isFinite(fallbackDuration) && fallbackDuration > 0) {
117
+ const audioLength = formatTime(fallbackDuration);
118
+ setTotalDuration(fallbackDuration);
119
+ setDisplayDuration(audioLength);
120
+ } else if (readyState >= 1) setTimeout(()=>{
121
+ if (audio.duration && Number.isFinite(audio.duration) && audio.duration > 0 && audio.duration !== 1 / 0) {
122
+ setTotalDuration(audio.duration);
123
+ setDisplayDuration(formatTime(audio.duration));
124
+ } else if (fallbackDuration && Number.isFinite(fallbackDuration) && fallbackDuration > 0) {
125
+ setTotalDuration(fallbackDuration);
126
+ setDisplayDuration(formatTime(fallbackDuration));
127
+ }
128
+ }, 100);
129
+ }
130
+ };
131
+ const handleControlGrab = (value)=>{
132
+ const sliderPosition = Array.isArray(value) ? value[0] : value;
133
+ if (audioRef?.current && Number.isFinite(sliderPosition) && Number.isFinite(totalDuration) && totalDuration > 0) audioRef.current.currentTime = Math.max(0, Math.min(sliderPosition, totalDuration));
134
+ };
135
+ const hideSlider = isCleared && hideSliderOnStop;
136
+ const hideTime = isCleared && hideTimeOnStop;
137
+ const icon = iconOnly ? isPlaying ? 'pause-circle' : 'play-circle' : isPlaying ? 'pause' : 'play';
138
+ const timeData = /*#__PURE__*/ jsxs(Data, {
139
+ secondary: true,
140
+ fontSize: fontSizeTime,
141
+ marginLeft: 'center' === infoPosition && waveform ? -4 : void 0,
142
+ children: [
143
+ hideCurrentTime || !displayCurrent || isCleared ? '' : `${displayCurrent} / `,
144
+ displayDuration
145
+ ]
146
+ });
147
+ return /*#__PURE__*/ jsxs(AudioContainer, {
148
+ width: collapsed ? void 0 : width || 250,
149
+ ...rest,
150
+ children: [
151
+ /*#__PURE__*/ jsx(Button, {
152
+ link: iconOnly,
153
+ secondary: true,
154
+ ...buttonProps,
155
+ small: small,
156
+ tiny: tiny,
157
+ icon: icon,
158
+ onClick: togglePlayPause
159
+ }),
160
+ !collapsed && /*#__PURE__*/ jsxs(ProgressContainer, {
161
+ alignData: infoPosition,
162
+ children: [
163
+ !hideSlider && (waveform ? /*#__PURE__*/ jsx(Waveform, {
164
+ src: src,
165
+ value: progress,
166
+ maxValue: totalDuration,
167
+ onChange: handleControlGrab,
168
+ showHoverTime: showHoverTime,
169
+ playedColor: playedColor,
170
+ unplayedColor: unplayedColor,
171
+ height: height
172
+ }) : /*#__PURE__*/ jsx(Slider, {
173
+ value: progress,
174
+ max: totalDuration,
175
+ step: 0.1,
176
+ onChange: handleControlGrab
177
+ })),
178
+ 'center' !== infoPosition && /*#__PURE__*/ jsxs(DataContainer, {
179
+ alignTop: 'top' === infoPosition,
180
+ noSlider: hideSlider,
181
+ relative: centerAlignContent || hideSlider,
182
+ waveformHeight: waveform ? height : void 0,
183
+ children: [
184
+ title ? /*#__PURE__*/ jsx(Data, {
185
+ fontSize: fontSizeTitle,
186
+ children: title
187
+ }) : /*#__PURE__*/ jsx("div", {}),
188
+ !hideTime && timeData
189
+ ]
190
+ })
191
+ ]
192
+ }),
193
+ 'center' === infoPosition && timeData,
194
+ /*#__PURE__*/ jsx("audio", {
195
+ ref: audioRef,
196
+ src: src,
197
+ onPlay: handleAudioPlay,
198
+ onPause: handleAudioPause,
199
+ onEmptied: handleAudioStop,
200
+ onEnded: handleAudioStop,
201
+ onTimeUpdate: updateProgress,
202
+ onDurationChange: handleLoad,
203
+ onLoadedMetadata: handleLoad,
204
+ onLoadedData: handleLoad,
205
+ onCanPlay: handleLoad,
206
+ onError: handleAudioError,
207
+ preload: "auto",
208
+ children: /*#__PURE__*/ jsx("track", {
209
+ kind: "captions"
210
+ })
211
+ })
212
+ ]
213
+ });
214
+ };
215
+ const AudioContainer = styled.div(({ width })=>({
216
+ display: 'flex',
217
+ alignItems: 'center',
218
+ gap: 8,
219
+ width
220
+ }), marginProps);
221
+ const ProgressContainer = styled.div(({ alignData })=>({
222
+ display: 'flex',
223
+ flexDirection: 'top' === alignData ? 'column-reverse' : 'column',
224
+ position: 'relative',
225
+ flex: 1,
226
+ minWidth: 0
227
+ }));
228
+ const DataContainer = styled.div(({ alignTop, noSlider, relative, waveformHeight })=>{
229
+ const top = waveformHeight ?? 6;
230
+ return {
231
+ position: relative ? 'relative' : 'absolute',
232
+ top: alignTop || noSlider ? void 0 : top,
233
+ bottom: alignTop && !noSlider ? top : void 0,
234
+ display: 'flex',
235
+ justifyContent: 'space-between',
236
+ alignItems: 'flex-end',
237
+ width: '100%'
238
+ };
239
+ });
240
+ const Data = styled.div(({ theme, secondary, fontSize })=>({
241
+ display: 'flex',
242
+ alignItems: 'center',
243
+ whiteSpace: 'nowrap',
244
+ color: secondary ? theme.scale6 : theme.scale10,
245
+ fontSize: fontSize || 10
246
+ }), marginProps);
247
+ const Audio = Audio_Audio;
248
+ export { Audio as default };
@@ -0,0 +1,123 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useTheme } from "@emotion/react";
3
+ import styled from "@emotion/styled";
4
+ import millify from "millify";
5
+ import { Bar, BarChart, CartesianGrid, Legend, ResponsiveContainer, XAxis, YAxis } from "recharts";
6
+ import { ChartContainer, ChartStyles, LegendContent, Tooltip } from "./ChartHelpers.js";
7
+ const BarChart_BarChart = ({ data, legend, keys, stacked, barGap, barCategoryGap, barSize = 16, maxBarSize, vertical = false, hideYLabels, hideXLabels, diagonalXLabels, maxXLabelLength = 10, xAxisHeight = 22, yAxisWidth = 45, axisColor, tooltipLegendPostfix, ...rest })=>{
8
+ const { scale2 } = useTheme();
9
+ const xAxisTick = diagonalXLabels ? (args)=>DiagonalAxisTick({
10
+ ...args,
11
+ maxXLabelLength,
12
+ axisColor
13
+ }) : {};
14
+ return /*#__PURE__*/ jsxs(ChartContainer, {
15
+ ...rest,
16
+ children: [
17
+ /*#__PURE__*/ jsx(ChartStyles, {}),
18
+ /*#__PURE__*/ jsx(ResponsiveContainer, {
19
+ width: "100%",
20
+ height: "100%",
21
+ children: /*#__PURE__*/ jsxs(BarChart, {
22
+ margin: {
23
+ top: 0,
24
+ left: 0,
25
+ right: 0,
26
+ bottom: 0
27
+ },
28
+ data: data,
29
+ layout: vertical ? 'vertical' : 'horizontal',
30
+ barSize: barSize,
31
+ maxBarSize: maxBarSize,
32
+ barGap: barGap,
33
+ barCategoryGap: barCategoryGap,
34
+ children: [
35
+ /*#__PURE__*/ jsx(CartesianGrid, {
36
+ stroke: axisColor || scale2,
37
+ strokeDasharray: "3 5",
38
+ vertical: vertical,
39
+ horizontal: !vertical
40
+ }),
41
+ /*#__PURE__*/ jsx(XAxis, {
42
+ stroke: axisColor || scale2,
43
+ tickMargin: 4,
44
+ tickFormatter: (value)=>vertical ? millify(value) : value,
45
+ tick: hideXLabels ? false : xAxisTick,
46
+ height: hideXLabels ? 12 : xAxisHeight,
47
+ interval: diagonalXLabels ? 0 : void 0,
48
+ dataKey: vertical ? void 0 : 'name',
49
+ type: vertical ? 'number' : 'category'
50
+ }),
51
+ /*#__PURE__*/ jsx(YAxis, {
52
+ stroke: axisColor || scale2,
53
+ tickMargin: 4,
54
+ tickFormatter: (value)=>vertical ? value : millify(value),
55
+ tick: hideYLabels ? false : {},
56
+ width: hideYLabels ? 5 : yAxisWidth,
57
+ dataKey: vertical ? 'name' : void 0,
58
+ type: vertical ? 'category' : 'number'
59
+ }),
60
+ Tooltip({
61
+ legendPostfix: tooltipLegendPostfix
62
+ }),
63
+ legend && /*#__PURE__*/ jsx(Legend, {
64
+ content: /*#__PURE__*/ jsx(LegendContent, {})
65
+ }),
66
+ keys.map(({ key, color }, i)=>{
67
+ const rVal = 2;
68
+ let radius = vertical ? [
69
+ 0,
70
+ rVal,
71
+ rVal,
72
+ 0
73
+ ] : [
74
+ rVal,
75
+ rVal,
76
+ 0,
77
+ 0
78
+ ];
79
+ if (stacked && i !== keys.length - 1) radius = [
80
+ 0,
81
+ 0,
82
+ 0,
83
+ 0
84
+ ];
85
+ return /*#__PURE__*/ jsx(Bar, {
86
+ dataKey: key,
87
+ fill: color,
88
+ stackId: stacked ? 'stack' : void 0,
89
+ radius: radius
90
+ }, `bar-${i + 1}`);
91
+ })
92
+ ]
93
+ })
94
+ })
95
+ ]
96
+ });
97
+ };
98
+ const DiagonalAxisTick = ({ x, y, payload, maxXLabelLength, axisColor })=>{
99
+ const text = payload.value;
100
+ const displayText = text.length > maxXLabelLength ? `${text.slice(0, maxXLabelLength)}...` : text;
101
+ return /*#__PURE__*/ jsx("g", {
102
+ transform: `translate(${x},${y})`,
103
+ children: /*#__PURE__*/ jsxs(DiagonalText, {
104
+ x: 0,
105
+ y: 0,
106
+ dy: 8,
107
+ textAnchor: "end",
108
+ transform: "rotate(-45)",
109
+ color: axisColor,
110
+ children: [
111
+ /*#__PURE__*/ jsx("title", {
112
+ children: text
113
+ }),
114
+ displayText
115
+ ]
116
+ })
117
+ });
118
+ };
119
+ const DiagonalText = styled.text(({ theme, color })=>({
120
+ fill: color || theme.scale2
121
+ }));
122
+ const components_BarChart = BarChart_BarChart;
123
+ export { DiagonalAxisTick, components_BarChart as default };