@wavv/ui 2.4.3 → 2.4.4-alpha.1

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.
@@ -0,0 +1,50 @@
1
+ import type { CSSProperties, ReactNode, RefObject } from 'react';
2
+ import type { Attributes } from './typeDefs/elementTypes';
3
+ import type { MaxWidthHeight, MinWidthHeight, Padding, PositionType, WidthHeight } from './types';
4
+ type DivAttributes = Attributes<HTMLDivElement>;
5
+ type DialogProps = {
6
+ /** The header content displayed at the top of the dialog */
7
+ header: ReactNode;
8
+ /** The main text content displayed in the dialog body */
9
+ text?: ReactNode;
10
+ /** Additional children content */
11
+ children?: ReactNode;
12
+ /** The text of the cancel button */
13
+ cancelText?: string;
14
+ /** The text of the confirm button */
15
+ confirmText?: string;
16
+ /** The confirm button will be negative (red) */
17
+ negative?: boolean;
18
+ /** The function called when the confirm button is clicked */
19
+ onConfirm?: () => void;
20
+ /** Controls whether or not the Dialog is open */
21
+ visible: boolean;
22
+ /** The function called when the Dialog is closed */
23
+ onClose: () => void;
24
+ /** Displays a close icon in the top right of the Dialog */
25
+ closeIcon?: boolean;
26
+ /** Prevents the Dialog from closing if the overlay outside the dialog is clicked */
27
+ preventOverlayClose?: boolean;
28
+ /** Adjust or disable the blur effect of the dialog overlay */
29
+ overlayBlur?: boolean | number;
30
+ /** Sets the color of the dialog overlay */
31
+ overlayColor?: string;
32
+ /** Overrides the backgroundColor of the dialog container */
33
+ backgroundColor?: string;
34
+ /** Overrides the borderRadius of the dialog container */
35
+ borderRadius?: number | string;
36
+ /** Overrides the overflow of the dialog container */
37
+ overflow?: CSSProperties['overflow'];
38
+ /** Prevents the dialog from being interacted with */
39
+ inert?: boolean;
40
+ /** Renders the Dialog scoped inside a container */
41
+ scopeRef?: RefObject<HTMLElement | null>;
42
+ /** Sets the position of the dialog container */
43
+ position?: PositionType;
44
+ /** Sets the zIndex of the dialog container */
45
+ zIndex?: number;
46
+ /** The `aria-label` of the dialog */
47
+ 'aria-label'?: string;
48
+ } & WidthHeight & MaxWidthHeight & MinWidthHeight & Padding & DivAttributes;
49
+ declare const Dialog: ({ header, text, children, cancelText, confirmText, negative, onConfirm, visible, width, height, onClose, closeIcon, preventOverlayClose, overlayBlur, overlayColor, backgroundColor, inert, scopeRef, position, zIndex, ...props }: DialogProps) => import("react/jsx-runtime").JSX.Element;
50
+ export default Dialog;
@@ -0,0 +1,150 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import styled from "@emotion/styled";
3
+ import { Dialog, Modal, ModalOverlay } from "react-aria-components";
4
+ import Button from "./Button/index.js";
5
+ import { maxWidthHeightProps, minWidthHeightProps, paddingProps } from "./helpers/styledProps.js";
6
+ import Icon from "./Icon/index.js";
7
+ import PortalScope from "./PortalScope.js";
8
+ const Dialog_Dialog = ({ header, text, children, cancelText = 'Cancel', confirmText = 'Okay', negative, onConfirm, visible, width, height, onClose, closeIcon, preventOverlayClose, overlayBlur = true, overlayColor, backgroundColor, inert, scopeRef, position, zIndex, ...props })=>{
9
+ const { 'aria-label': ariaLabel, ...rest } = props;
10
+ const handleOpenChange = (open)=>{
11
+ if (!open) onClose();
12
+ };
13
+ const hasFooter = !!onConfirm;
14
+ const dialog = /*#__PURE__*/ jsx(Overlay, {
15
+ isDismissable: !preventOverlayClose,
16
+ isOpen: visible,
17
+ onOpenChange: handleOpenChange,
18
+ color: overlayColor,
19
+ position: scopeRef ? 'absolute' : position,
20
+ width: scopeRef ? '100%' : void 0,
21
+ height: scopeRef ? '100%' : void 0,
22
+ zIndex: zIndex,
23
+ blur: overlayBlur,
24
+ ref: (node)=>{
25
+ if (!node) return;
26
+ if (inert) node.setAttribute('inert', '');
27
+ else node.removeAttribute('inert');
28
+ },
29
+ children: /*#__PURE__*/ jsx(StyledModal, {
30
+ children: /*#__PURE__*/ jsx(StyledDialog, {
31
+ "aria-label": ariaLabel,
32
+ children: /*#__PURE__*/ jsxs(DialogContainer, {
33
+ width: width,
34
+ height: height,
35
+ backgroundColor: backgroundColor,
36
+ ...rest,
37
+ children: [
38
+ /*#__PURE__*/ jsxs(DialogHeader, {
39
+ children: [
40
+ header,
41
+ closeIcon && /*#__PURE__*/ jsx(CloseInHeader, {
42
+ children: /*#__PURE__*/ jsx(Icon, {
43
+ name: "close",
44
+ size: "small",
45
+ onClick: onClose
46
+ })
47
+ })
48
+ ]
49
+ }),
50
+ (text || children) && /*#__PURE__*/ jsxs(DialogContent, {
51
+ hasFooter: hasFooter,
52
+ children: [
53
+ text,
54
+ children
55
+ ]
56
+ }),
57
+ hasFooter && /*#__PURE__*/ jsxs(DialogFooter, {
58
+ children: [
59
+ /*#__PURE__*/ jsx(Button, {
60
+ secondary: true,
61
+ onClick: onClose,
62
+ children: cancelText
63
+ }),
64
+ /*#__PURE__*/ jsx(Button, {
65
+ negative: negative,
66
+ onClick: onConfirm,
67
+ children: confirmText
68
+ })
69
+ ]
70
+ })
71
+ ]
72
+ })
73
+ })
74
+ })
75
+ });
76
+ return scopeRef ? /*#__PURE__*/ jsx(PortalScope, {
77
+ containerRef: scopeRef,
78
+ children: dialog
79
+ }) : dialog;
80
+ };
81
+ const DialogHeader = styled.div(({ theme })=>({
82
+ display: 'flex',
83
+ alignItems: 'center',
84
+ justifyContent: 'space-between',
85
+ color: theme.modal.color.header,
86
+ fontWeight: theme.font.weight.default,
87
+ fontSize: theme.font.size.xl,
88
+ margin: 0,
89
+ padding: 16,
90
+ borderBottom: `1px solid ${theme.scale1}`,
91
+ position: 'relative',
92
+ width: '100%',
93
+ boxSizing: 'border-box'
94
+ }));
95
+ const DialogContent = styled.div(({ theme, hasFooter })=>({
96
+ color: theme.modal.color.body,
97
+ fontSize: theme.font.size.lg,
98
+ padding: hasFooter ? '16px 16px 8px' : 16,
99
+ boxSizing: 'border-box'
100
+ }));
101
+ const DialogFooter = styled.div({
102
+ display: 'flex',
103
+ alignItems: 'center',
104
+ justifyContent: 'flex-end',
105
+ padding: 16,
106
+ gap: 8,
107
+ boxSizing: 'border-box'
108
+ });
109
+ const DialogContainer = styled.div(({ theme, width, height, backgroundColor, borderRadius, overflow })=>({
110
+ display: 'flex',
111
+ flexDirection: 'column',
112
+ backgroundColor: backgroundColor || theme.modal.background,
113
+ color: theme.scale10,
114
+ boxShadow: theme.elevation3,
115
+ width: width || 'max-content',
116
+ height: height || 'max-content',
117
+ borderRadius: borderRadius || theme.size.sm,
118
+ overflow: overflow || 'hidden'
119
+ }), {
120
+ position: 'absolute',
121
+ top: '50%',
122
+ left: '50%',
123
+ transform: 'translate(-50%,-50%)'
124
+ }, paddingProps, minWidthHeightProps, maxWidthHeightProps);
125
+ const CloseInHeader = styled.div(({ theme })=>({
126
+ display: 'flex',
127
+ justifyContent: 'center',
128
+ alignItems: 'center',
129
+ marginLeft: 'auto',
130
+ cursor: 'pointer',
131
+ color: theme.scale10
132
+ }));
133
+ const Overlay = styled(ModalOverlay)(({ color, blur, position, zIndex, width, height })=>({
134
+ position: position || 'fixed',
135
+ top: 0,
136
+ left: 0,
137
+ width: width || '100vw',
138
+ height: height || 'var(--visual-viewport-height)',
139
+ zIndex: zIndex || 100,
140
+ backgroundColor: color || 'rgba(0, 0, 0, 0.2)',
141
+ backdropFilter: blur ? `blur(${'number' == typeof blur ? blur : 4}px)` : 'none'
142
+ }));
143
+ const StyledModal = styled(Modal)({
144
+ outline: 'none'
145
+ });
146
+ const StyledDialog = styled(Dialog)({
147
+ outline: 'none'
148
+ });
149
+ const components_Dialog = Dialog_Dialog;
150
+ export { components_Dialog as default };
package/build/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export { default as Checkbox } from './components/Checkbox';
8
8
  export { default as Code } from './components/Code';
9
9
  export { default as ComboBox } from './components/ComboBox';
10
10
  export { default as CommandMenu } from './components/CommandMenu';
11
+ export { default as Dialog } from './components/Dialog';
11
12
  export { default as DocTable } from './components/DocTable';
12
13
  export { default as Dot } from './components/Dot';
13
14
  export { default as DraftEditor } from './components/DraftEditor';
package/build/index.js CHANGED
@@ -8,6 +8,7 @@ import Checkbox from "./components/Checkbox.js";
8
8
  import Code from "./components/Code/index.js";
9
9
  import ComboBox from "./components/ComboBox.js";
10
10
  import CommandMenu from "./components/CommandMenu/index.js";
11
+ import Dialog from "./components/Dialog.js";
11
12
  import DocTable from "./components/DocTable.js";
12
13
  import Dot from "./components/Dot.js";
13
14
  import DraftEditor from "./components/DraftEditor.js";
@@ -82,4 +83,4 @@ import formatDate from "./utils/formatDate.js";
82
83
  import formatNumber from "./utils/formatNumber.js";
83
84
  import numberWithCommas from "./utils/numberWithCommas.js";
84
85
  import matchesFileTypes from "./utils/matchesFileTypes.js";
85
- export { Accordion, Audio, Avatar, BarChart, Button, Calendar, Checkbox, Code, ComboBox, CommandMenu, DatePicker, DateRangePicker, DateRangeSelect, DocTable, Dot, DraftEditor, DropZone, Dropdown, DropdownMenu, DropdownSelect, Editor, Ellipsis, FileTrigger, Form, Grid, Icon, ImageViewer, InlineCode, InlineInput, InputHelpers as InputUtils, Label, LineChart, Menu, Message, MessageHr, Modal, MultiSelect, NumberInput, Pagination, PaymentLogo, PhoneInput, PieChart, Popover, PortalScope, Progress, Radio, RangeCalendar, ResetStyles, ScrollbarStyles, SearchInput, Select, Slider, Spinner, Table, Tabs, Tag, TextArea, TextInput, TimeInput, ToastStyles, Toggle, ToggleButton, ToggleButtonGroup, Tooltip, TransferList, Tree, UnstyledButton, colors, copyToClipboard, createEditorContent, darkScale, editorContentToText, formatDate, formatNumber, lightScale, marginProps, matchesFileTypes, numberWithCommas, paddingProps, positionProps, theme, themeClasses, themeOptions, useConfirm, useCopy, useElementObserver, useEventListener, useOnClickOutside, usePrevious, useSelectAll, useWindowSize, widthHeightProps };
86
+ export { Accordion, Audio, Avatar, BarChart, Button, Calendar, Checkbox, Code, ComboBox, CommandMenu, DatePicker, DateRangePicker, DateRangeSelect, Dialog, DocTable, Dot, DraftEditor, DropZone, Dropdown, DropdownMenu, DropdownSelect, Editor, Ellipsis, FileTrigger, Form, Grid, Icon, ImageViewer, InlineCode, InlineInput, InputHelpers as InputUtils, Label, LineChart, Menu, Message, MessageHr, Modal, MultiSelect, NumberInput, Pagination, PaymentLogo, PhoneInput, PieChart, Popover, PortalScope, Progress, Radio, RangeCalendar, ResetStyles, ScrollbarStyles, SearchInput, Select, Slider, Spinner, Table, Tabs, Tag, TextArea, TextInput, TimeInput, ToastStyles, Toggle, ToggleButton, ToggleButtonGroup, Tooltip, TransferList, Tree, UnstyledButton, colors, copyToClipboard, createEditorContent, darkScale, editorContentToText, formatDate, formatNumber, lightScale, marginProps, matchesFileTypes, numberWithCommas, paddingProps, positionProps, theme, themeClasses, themeOptions, useConfirm, useCopy, useElementObserver, useEventListener, useOnClickOutside, usePrevious, useSelectAll, useWindowSize, widthHeightProps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wavv/ui",
3
- "version": "2.4.3",
3
+ "version": "2.4.4-alpha.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {