@wonderflow/react-components 3.0.0-beta.7 → 3.0.0-beta.8

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.
@@ -27,4 +27,22 @@
27
27
 
28
28
  /* Motion Media Queries */
29
29
 
30
- @custom-media --allow-motion (prefers-reduced-motion: no-preference);
30
+ @custom-media --motion (prefers-reduced-motion: no-preference);
31
+ @custom-media --reduced-motion (prefers-reduced-motion: reduce);
32
+
33
+ /* Opacity Media Queries */
34
+
35
+ @custom-media --opacity (prefers-reduced-transparency: no-preference);
36
+ @custom-media --reduce-opacity (prefers-reduced-transparency: reduce);
37
+
38
+ /* Contrast Media Queries */
39
+
40
+ @custom-media --high-contrast (prefers-contrast: high);
41
+ @custom-media --low-contrast (prefers-contrast: low);
42
+
43
+ /* Pointer Media Queries */
44
+
45
+ @custom-media --touch (hover: none) and (pointer: coarse);
46
+ @custom-media --stylus (hover: none) and (pointer: fine);
47
+ @custom-media --pointer (hover) and (pointer: coarse);
48
+ @custom-media --mouse (hover) and (pointer: fine);
@@ -0,0 +1,65 @@
1
+ import { PropsWithChildren, ReactNode } from 'react';
2
+ export declare type DrawerProps = PropsWithChildren<PropsWithClass> & {
3
+ /**
4
+ * This enable the drawer to be closed by clicking on the overlay.
5
+ * Even if this can be set to `false` we strongly recommend to leave
6
+ * it to `true` as it ensures the accessibility of the drawer.
7
+ */
8
+ closeOnClickOutside?: boolean;
9
+ /**
10
+ * Set the accessible title of the drawer. This is used by screen readers to
11
+ * announce the title of the drawer when opened.
12
+ */
13
+ title?: ReactNode;
14
+ /**
15
+ * Hide or show the drawer header which includes the title and the close button.
16
+ */
17
+ showHeader?: boolean;
18
+ /**
19
+ * Set the maximum width of the drawer, on mobile the drawer will be
20
+ * automatically collapsed when the width is reached.
21
+ */
22
+ maxWidth?: string;
23
+ /**
24
+ * Set the theme of the content card. To ensure contrast with the default overlay color (dark),
25
+ * this is set to `light` by default.
26
+ */
27
+ theme?: 'dark' | 'light' | 'auto';
28
+ /**
29
+ * Set the side on which the drawer will be positioned.
30
+ */
31
+ side?: 'left' | 'right';
32
+ };
33
+ export declare const Drawer: import("react").ForwardRefExoticComponent<PropsWithClass & {
34
+ children?: ReactNode;
35
+ } & {
36
+ /**
37
+ * This enable the drawer to be closed by clicking on the overlay.
38
+ * Even if this can be set to `false` we strongly recommend to leave
39
+ * it to `true` as it ensures the accessibility of the drawer.
40
+ */
41
+ closeOnClickOutside?: boolean | undefined;
42
+ /**
43
+ * Set the accessible title of the drawer. This is used by screen readers to
44
+ * announce the title of the drawer when opened.
45
+ */
46
+ title?: ReactNode;
47
+ /**
48
+ * Hide or show the drawer header which includes the title and the close button.
49
+ */
50
+ showHeader?: boolean | undefined;
51
+ /**
52
+ * Set the maximum width of the drawer, on mobile the drawer will be
53
+ * automatically collapsed when the width is reached.
54
+ */
55
+ maxWidth?: string | undefined;
56
+ /**
57
+ * Set the theme of the content card. To ensure contrast with the default overlay color (dark),
58
+ * this is set to `light` by default.
59
+ */
60
+ theme?: "auto" | "light" | "dark" | undefined;
61
+ /**
62
+ * Set the side on which the drawer will be positioned.
63
+ */
64
+ side?: "left" | "right" | undefined;
65
+ } & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
3
+ import { motion } from 'framer-motion';
4
+ import clsx from 'clsx';
5
+ import { FocusOn } from 'react-focus-on';
6
+ import { Drawer as DrawerClass, Container, Content, Header, CloseButton } from './drawer.module.css';
7
+ import { useOverlayContext } from '../overlay-container';
8
+ import { Elevator, IconButton, Stack, Title } from '../';
9
+ export const Drawer = forwardRef(({ children, className, closeOnClickOutside = true, showHeader = true, maxWidth = '400px', side = 'right', theme = 'light', title, ...otherProps }, forwardedRef) => {
10
+ const { titleId, onClose } = useOverlayContext();
11
+ const dynamicStyle = {
12
+ '--max-w': maxWidth
13
+ };
14
+ const DrawerAnimation = {
15
+ visible: {
16
+ x: 0,
17
+ transition: {
18
+ ease: [0, 0, 0.34, 1],
19
+ duration: 0.35
20
+ }
21
+ },
22
+ hidden: {
23
+ x: side === 'right' ? '100%' : '-100%',
24
+ transition: {
25
+ ease: [0.3, 0.07, 1, 1],
26
+ duration: 0.2
27
+ }
28
+ }
29
+ };
30
+ return (_jsx("div", { role: "dialog", "aria-modal": "true", "data-theme": theme, "aria-labelledby": titleId, className: clsx(DrawerClass, className), ref: forwardedRef, ...otherProps, children: _jsx(FocusOn, { onClickOutside: onClose, onEscapeKey: onClose, children: _jsx(motion.div, { variants: DrawerAnimation, initial: "hidden", animate: "visible", exit: "hidden", className: Container, "data-drawer-side": side, children: _jsx(Elevator, { resting: 4, children: _jsxs("div", { className: Content, style: dynamicStyle, ref: forwardedRef, ...otherProps, children: [(showHeader && title) && (_jsxs(Stack, { verticalAlign: "center", fill: false, horizontalAlign: "space-between", direction: "row", className: Header, children: [_jsx(Title, { responsive: false, level: "6", id: titleId, children: title }, void 0), onClose && _jsx(IconButton, { dimension: "small", onClick: onClose, className: CloseButton, icon: "xmark", kind: "flat" }, void 0)] }, void 0)), children] }, void 0) }, void 0) }, void 0) }, void 0) }, void 0));
31
+ });
32
+ Drawer.displayName = 'Drawer';
@@ -0,0 +1 @@
1
+ .Drawer{display:contents}.Container{align-items:stretch;bottom:0;display:grid;left:0;pointer-events:none;position:absolute;right:0;top:0}.Container[data-drawer-side=right]{justify-content:flex-end}.Container[data-drawer-side=left]{justify-content:flex-start}@media (min-width:30em){.Container{overflow:auto}}.Container>*{pointer-events:auto}.Content{-webkit-overflow-scrolling:touch;background-color:var(--global-background);inline-size:100%;max-inline-size:var(--max-w);overflow:auto;overscroll-behavior:contain}.Header{background-color:inherit;border-bottom:1px solid var(--dimmed-1);padding:.89rem 4.44rem .89rem 1.33rem;position:sticky;top:0}.CloseButton.CloseButton{position:absolute;right:.44rem;top:50%;transform:translateY(-50%)}
@@ -0,0 +1,2 @@
1
+ export { Drawer } from './drawer';
2
+ export type { DrawerProps } from './drawer';
@@ -0,0 +1 @@
1
+ export { Drawer } from './drawer';
package/index.d.ts CHANGED
@@ -16,6 +16,8 @@ export { ClampText } from './clamp-text';
16
16
  export type { ClampTextProps } from './clamp-text';
17
17
  export { Container } from './container';
18
18
  export type { ContainerProps } from './container';
19
+ export { Drawer } from './drawer';
20
+ export type { DrawerProps } from './drawer';
19
21
  export { Table } from './table';
20
22
  export type { TableProps } from './table';
21
23
  export { Disclosure } from './disclosure';
package/index.js CHANGED
@@ -8,6 +8,7 @@ export { Chip } from './chip';
8
8
  export { CircularProgress } from './circular-progress';
9
9
  export { ClampText } from './clamp-text';
10
10
  export { Container } from './container';
11
+ export { Drawer } from './drawer';
11
12
  export { Table } from './table';
12
13
  export { Disclosure } from './disclosure';
13
14
  export { Dropdown } from './dropdown';
@@ -6,6 +6,6 @@ import { Title, Elevator, IconButton, Stack } from '../../';
6
6
  import { useOverlayContext } from '../../overlay-container';
7
7
  export const ModalContent = forwardRef(({ children, className, title, theme = 'light', ...otherProps }, forwardedRef) => {
8
8
  const { onClose, titleId } = useOverlayContext();
9
- return (_jsx(Elevator, { resting: 4, children: _jsxs("div", { className: clsx(Content, className), ref: forwardedRef, "data-theme": theme, ...otherProps, children: [_jsxs(Stack, { verticalAlign: "center", fill: false, horizontalAlign: "space-between", direction: "row", className: Header, children: [_jsx(Title, { level: "5", id: titleId, children: title }, void 0), onClose && _jsx(IconButton, { onClick: onClose, className: CloseButton, icon: "xmark", kind: "flat" }, void 0)] }, void 0), children] }, void 0) }, void 0));
9
+ return (_jsx(Elevator, { resting: 4, children: _jsxs("div", { className: clsx(Content, className), ref: forwardedRef, "data-theme": theme, ...otherProps, children: [_jsxs(Stack, { verticalAlign: "center", fill: false, horizontalAlign: "space-between", direction: "row", className: Header, children: [_jsx(Title, { responsive: false, level: "5", id: titleId, children: title }, void 0), onClose && _jsx(IconButton, { onClick: onClose, className: CloseButton, icon: "xmark", kind: "flat" }, void 0)] }, void 0), children] }, void 0) }, void 0));
10
10
  });
11
11
  ModalContent.displayName = 'Modal.Content';
@@ -1 +1 @@
1
- .Content{-webkit-overflow-scrolling:touch;align-self:end;background-color:var(--global-background);border-radius:.89rem .89rem 0 0;color:var(--global-foreground);inline-size:100%;justify-self:center;max-block-size:95vh;overflow:auto;overscroll-behavior:contain}@media (min-width:30em){.Content{align-self:center;border-radius:.44rem;justify-self:center;max-block-size:80vh;max-inline-size:600px}}.Header{background-color:inherit;border-bottom:1px solid var(--dimmed-1);padding:.89rem 4.44rem .89rem 1.33rem;position:sticky;top:0}.CloseButton.CloseButton{position:absolute;right:.44rem;top:.44rem}
1
+ .Content{-webkit-overflow-scrolling:touch;align-self:end;background-color:var(--global-background);border-radius:.89rem .89rem 0 0;inline-size:100%;justify-self:center;max-block-size:95vh;overflow:auto;overscroll-behavior:contain}@media (min-width:30em){.Content{align-self:center;border-radius:.44rem;justify-self:center;max-block-size:80vh;max-inline-size:600px}}.Header{background-color:inherit;border-bottom:1px solid var(--dimmed-1);padding:.89rem 4.44rem .89rem 1.33rem;position:sticky;top:0}.CloseButton.CloseButton{position:absolute;right:.44rem;top:.44rem}
package/modal/modal.js CHANGED
@@ -6,9 +6,27 @@ import { FocusOn } from 'react-focus-on';
6
6
  import { ModalContent } from './content/modal-content';
7
7
  import { Modal as ModalClass, Container } from './modal.module.css';
8
8
  import { useOverlayContext } from '../overlay-container';
9
+ const ModalAnimation = {
10
+ visible: {
11
+ scale: 1,
12
+ opacity: 1,
13
+ transition: {
14
+ ease: [0, 0, 0.34, 1],
15
+ duration: 0.35
16
+ }
17
+ },
18
+ hidden: {
19
+ scale: 0.98,
20
+ opacity: 0,
21
+ transition: {
22
+ ease: [0.3, 0.07, 1, 1],
23
+ duration: 0.2
24
+ }
25
+ }
26
+ };
9
27
  export const Modal = forwardRef(({ children, className, closeOnClickOutside = true, ...otherProps }, forwardedRef) => {
10
28
  const { titleId, onClose } = useOverlayContext();
11
- return (_jsx("div", { role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, className: clsx(ModalClass, className), ref: forwardedRef, ...otherProps, children: _jsx(FocusOn, { onClickOutside: onClose, onEscapeKey: onClose, children: _jsx(motion.div, { initial: { scale: 0.98, opacity: 0 }, animate: { scale: 1, opacity: 1 }, transition: { ease: 'easeOut', duration: 0.1 }, exit: { scale: 0.98, opacity: 0 }, className: Container, children: children }, void 0) }, void 0) }, void 0));
29
+ return (_jsx("div", { role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, className: clsx(ModalClass, className), ref: forwardedRef, ...otherProps, children: _jsx(FocusOn, { onClickOutside: onClose, onEscapeKey: onClose, children: _jsx(motion.div, { variants: ModalAnimation, initial: "hidden", animate: "visible", exit: "hidden", className: Container, children: children }, void 0) }, void 0) }, void 0));
12
30
  });
13
31
  Modal.displayName = 'Modal';
14
32
  Modal.Content = ModalContent;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wonderflow/react-components",
3
3
  "description": "UI components from Wonderflow's Wanda design system",
4
- "version": "3.0.0-beta.7",
4
+ "version": "3.0.0-beta.8",
5
5
  "author": "Wonderflow",
6
6
  "license": "MIT",
7
7
  "main": "index.js",
@@ -36,6 +36,6 @@ export declare type SnackbarProps = {
36
36
  */
37
37
  onDismiss?(): void;
38
38
  };
39
- declare type PolymorphicSnackbar = Polymorphic.ForwardRefComponent<'div', SnackbarProps>;
39
+ declare type PolymorphicSnackbar = Polymorphic.ForwardRefComponent<'output', SnackbarProps>;
40
40
  export declare const Snackbar: PolymorphicSnackbar;
41
41
  export {};
@@ -3,7 +3,7 @@ import { forwardRef } from 'react';
3
3
  import { Snackbar as SnackbarClass, Icon as IconClass, Action } from './snackbar.module.css';
4
4
  import clsx from 'clsx';
5
5
  import { Title, Stack, Icon, Button } from '../';
6
- export const Snackbar = forwardRef(({ children, className, title, icon, kind = 'neutral', as: Wrapper = 'div', dismissable, dismissLabel = 'Dismiss', onDismiss, ...otherProps }, forwardedRef) => {
6
+ export const Snackbar = forwardRef(({ children, className, title, icon, kind = 'neutral', as: Wrapper = 'output', dismissable, dismissLabel = 'Dismiss', onDismiss, ...otherProps }, forwardedRef) => {
7
7
  const defaultIcons = {
8
8
  info: 'circle-info',
9
9
  warning: 'triangle-exclamation',
@@ -11,5 +11,5 @@ export const Snackbar = forwardRef(({ children, className, title, icon, kind = '
11
11
  positive: 'check',
12
12
  danger: 'circle-x'
13
13
  };
14
- return (_jsx(Wrapper, { ref: forwardedRef, className: clsx(SnackbarClass, className), "data-snackbar-kind": kind, role: "alert", ...otherProps, children: _jsxs(Stack, { verticalAlign: "start", horizontalAlign: "start", direction: "row", columnGap: 16, fill: false, children: [_jsx(Icon, { className: IconClass, name: icon || defaultIcons[kind], dimension: 24 }, void 0), _jsxs(Stack, { rowGap: 16, children: [_jsxs(Stack, { rowGap: 8, children: [title && _jsx(Title, { level: "5", children: title }, void 0), _jsx("p", { children: children }, void 0)] }, void 0), dismissable && (_jsx(Stack, { horizontalAlign: "end", children: _jsx(Button, { onClick: onDismiss, className: Action, children: dismissLabel }, void 0) }, void 0))] }, void 0)] }, void 0) }, void 0));
14
+ return (_jsx(Wrapper, { ref: forwardedRef, className: clsx(SnackbarClass, className), "data-snackbar-kind": kind, role: "status", ...otherProps, children: _jsxs(Stack, { verticalAlign: "start", horizontalAlign: "start", direction: "row", columnGap: 16, fill: false, children: [_jsx(Icon, { className: IconClass, name: icon || defaultIcons[kind], dimension: 24 }, void 0), _jsxs(Stack, { rowGap: 16, children: [_jsxs(Stack, { rowGap: 8, children: [title && _jsx(Title, { level: "5", children: title }, void 0), _jsx("p", { children: children }, void 0)] }, void 0), dismissable && (_jsx(Stack, { horizontalAlign: "end", children: _jsx(Button, { onClick: onDismiss, className: Action, children: dismissLabel }, void 0) }, void 0))] }, void 0)] }, void 0) }, void 0));
15
15
  });
@@ -1 +1 @@
1
- .Snackbar{background:linear-gradient(to right,var(--snackbar-fg) 4px,var(--snackbar-bg) 4px);border-radius:.22rem;color:var(--snackbar-fg);overflow:hidden;padding:.89rem 1.33rem}.Snackbar p{font-size:.89rem}.Snackbar[data-snackbar-kind=neutral]{--snackbar-bg:var(--highlight-gray-background);--snackbar-fg:var(--highlight-gray-foreground)}.Snackbar[data-snackbar-kind=positive]{--snackbar-bg:var(--highlight-green-background);--snackbar-fg:var(--highlight-green-foreground)}.Snackbar[data-snackbar-kind=warning]{--snackbar-bg:var(--highlight-yellow-background);--snackbar-fg:var(--highlight-yellow-foreground)}.Snackbar[data-snackbar-kind=info]{--snackbar-bg:var(--highlight-blue-background);--snackbar-fg:var(--highlight-blue-foreground)}.Snackbar[data-snackbar-kind=danger]{--snackbar-bg:var(--highlight-red-background);--snackbar-fg:var(--highlight-red-foreground)}.Icon{flex-shrink:0}.Action:is(.Action.Action){background-color:var(--snackbar-fg);color:var(--snackbar-bg)}
1
+ .Snackbar{background:linear-gradient(to right,var(--snackbar-fg) 4px,var(--snackbar-bg) 4px);border-radius:.22rem;color:var(--snackbar-fg);display:block;overflow:hidden;padding:.89rem 1.33rem}.Snackbar p{font-size:.89rem}.Snackbar[data-snackbar-kind=neutral]{--snackbar-bg:var(--highlight-gray-background);--snackbar-fg:var(--highlight-gray-foreground)}.Snackbar[data-snackbar-kind=positive]{--snackbar-bg:var(--highlight-green-background);--snackbar-fg:var(--highlight-green-foreground)}.Snackbar[data-snackbar-kind=warning]{--snackbar-bg:var(--highlight-yellow-background);--snackbar-fg:var(--highlight-yellow-foreground)}.Snackbar[data-snackbar-kind=info]{--snackbar-bg:var(--highlight-blue-background);--snackbar-fg:var(--highlight-blue-foreground)}.Snackbar[data-snackbar-kind=danger]{--snackbar-bg:var(--highlight-red-background);--snackbar-fg:var(--highlight-red-foreground)}.Icon{flex-shrink:0}.Action:is(.Action.Action){background-color:var(--snackbar-fg);color:var(--snackbar-bg)}
package/themes/dark.css CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Thu, 23 Dec 2021 10:40:26 GMT
3
+ * Generated on Thu, 23 Dec 2021 15:52:14 GMT
4
4
  */
5
5
 
6
6
  :root {
package/themes/light.css CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Thu, 23 Dec 2021 10:40:26 GMT
3
+ * Generated on Thu, 23 Dec 2021 15:52:14 GMT
4
4
  */
5
5
 
6
6
  :root {