@wonderflow/react-components 3.0.0-beta.5 → 3.0.0-beta.9

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.
@@ -1 +1 @@
1
- :where(.Card){background:var(--global-background);border-radius:var(--radius);padding:var(--padding);position:relative}[data-card-dimmed="1"]:where(.Card){background:var(--dimmed-0)}[data-card-dimmed="2"]:where(.Card){background:var(--dimmed-1)}[data-card-dimmed="3"]:where(.Card){background:var(--dimmed-2)}[data-card-vibrant=true]:where(.Card){background-color:var(--global-vibrancy-background)}[data-card-highlight-hover=true][data-card-vibrant=true]:where(.Card).focus-visible,[data-card-highlight-hover=true][data-card-vibrant=true]:where(.Card):hover{background-color:var(--global-vibrancy-background-hover)}[data-card-highlight-hover=true][data-card-vibrant=true]:where(.Card):focus-visible,[data-card-highlight-hover=true][data-card-vibrant=true]:where(.Card):hover{background-color:var(--global-vibrancy-background-hover)}[data-card-bordered=true]:where(.Card){border:1px solid var(--dimmed-1)}[data-card-vibrant=true][data-card-bordered=true]:where(.Card){border:1px solid var(--dimmed-2)}.Left{flex-shrink:0}.Content{flex-grow:1}.Right{flex-shrink:0}
1
+ :where(.Card){background:var(--global-background);border-radius:var(--radius);padding:var(--padding);position:relative}[data-card-dimmed="1"]:where(.Card){background:var(--dimmed-0)}[data-card-dimmed="2"]:where(.Card){background:var(--dimmed-1)}[data-card-dimmed="3"]:where(.Card){background:var(--dimmed-2)}[data-card-vibrant=true]:where(.Card){-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background-color:var(--global-vibrancy-background)}[data-card-highlight-hover=true][data-card-vibrant=true]:where(.Card).focus-visible,[data-card-highlight-hover=true][data-card-vibrant=true]:where(.Card):hover{background-color:var(--global-vibrancy-background-hover)}[data-card-highlight-hover=true][data-card-vibrant=true]:where(.Card):focus-visible,[data-card-highlight-hover=true][data-card-vibrant=true]:where(.Card):hover{background-color:var(--global-vibrancy-background-hover)}[data-card-bordered=true]:where(.Card){border:1px solid var(--dimmed-1)}[data-card-vibrant=true][data-card-bordered=true]:where(.Card){border:1px solid var(--dimmed-2)}.Left{flex-shrink:0}.Content{flex-grow:1}.Right{flex-shrink:0}
@@ -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: closeOnClickOutside ? onClose : undefined, 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';
@@ -1,10 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import clsx from 'clsx';
3
3
  import { useState, Children, cloneElement, useRef, forwardRef } from 'react';
4
- import { useKeyPress, useClickAway } from 'ahooks';
4
+ import { useKeyPress, useClickAway, useFocusWithin } from 'ahooks';
5
5
  import { Dropdown as DropdownClass, PopUp } from './dropdown.module.css';
6
6
  import { useUIDSeed } from 'react-uid';
7
- import { useFocusWithin } from '../hooks';
8
7
  import { DropdownMenu } from './menu/dropdown-menu';
9
8
  import { DropdownItem } from './item/dropdown-item';
10
9
  import { DropdownItemCheckbox } from './item-checkbox/dropdown-item-checkbox';
@@ -26,16 +25,17 @@ export const Dropdown = forwardRef(({ className, children, trigger, offset = 8,
26
25
  offset: [0, offset],
27
26
  closeOnOutsideClick: false
28
27
  });
28
+ const isFocusWithin = useFocusWithin(popupRef, {
29
+ onBlur: (e) => e.relatedTarget && setIsOpen(false),
30
+ onChange: (isFocusWithin) => {
31
+ !isFocusWithin && setIsOpen(false);
32
+ }
33
+ });
29
34
  useClickAway(() => {
30
35
  setIsOpen(false);
31
36
  }, popupRef);
32
- const { focusWithinProps } = useFocusWithin({
33
- onFocusWithin: () => null,
34
- onBlurWithin: (e) => e.relatedTarget && setIsOpen(false),
35
- onFocusWithinChange: () => null
36
- });
37
37
  useKeyPress('esc', () => setIsOpen(false));
38
- return (_jsxs("div", { ref: popupRef, className: clsx(DropdownClass, className), ...focusWithinProps, children: [Children.map(trigger, (child) => cloneElement(child, {
38
+ return (_jsxs("div", { ref: popupRef, "data-dropdown-has-focus-within": isFocusWithin, className: clsx(DropdownClass, className), children: [Children.map(trigger, (child) => cloneElement(child, {
39
39
  ref: setTriggerRef,
40
40
  id: seedID('dropdown-trigger'),
41
41
  'aria-haspopup': 'true',
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: closeOnClickOutside ? onClose : undefined, 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;
@@ -16,8 +16,8 @@ export declare type OverlayContainerProps = {
16
16
  */
17
17
  index?: number;
18
18
  /**
19
- * Set the overlay style. This is used to obscure the page content
20
- * behind the content of the overlay, while it is open. If set to `auto`, the overlay
19
+ * Set the overlay style. This is used to obscure the content
20
+ * behind the overlay if `obfuscate` is `true`. If set to `auto`, the overlay
21
21
  * color is determined by the global active theme (light or dark).
22
22
  */
23
23
  overlayColor?: 'light' | 'dark' | 'auto';
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.5",
4
+ "version": "3.0.0-beta.9",
5
5
  "author": "Wonderflow",
6
6
  "license": "MIT",
7
7
  "main": "index.js",
@@ -64,14 +64,13 @@
64
64
  "postbuild": "run-s prepare:package"
65
65
  },
66
66
  "dependencies": {
67
- "@react-aria/interactions": "3.7.0",
68
67
  "@wonderflow/tokens": "1.3.7",
69
- "ahooks": "3.0.8",
68
+ "ahooks": "3.1.1",
70
69
  "clsx": "1.1.1",
71
70
  "framer-motion": "4.1.17",
72
71
  "postcss": "^8.4.5",
73
72
  "react": "^17.0",
74
- "react-data-table-component": "7.4.5",
73
+ "react-data-table-component": "7.4.6",
75
74
  "react-dom": "^17.0",
76
75
  "react-focus-on": "3.5.4",
77
76
  "react-loading-skeleton": "3.0.1",
@@ -107,8 +106,8 @@
107
106
  "@storybook/react": "6.5.0-alpha.4",
108
107
  "@storybook/theming": "6.5.0-alpha.4",
109
108
  "@types/react-dom": "17.0.11",
110
- "@typescript-eslint/eslint-plugin": "5.7.0",
111
- "@typescript-eslint/parser": "5.7.0",
109
+ "@typescript-eslint/eslint-plugin": "5.8.0",
110
+ "@typescript-eslint/parser": "5.8.0",
112
111
  "@wonderflow/config": "3.0.3",
113
112
  "@wonderflow/eslint-config": "1.1.8",
114
113
  "@wonderflow/stylelint-config": "1.1.3",
@@ -119,7 +118,7 @@
119
118
  "cz-conventional-changelog": "3.3.0",
120
119
  "directory-tree": "3.0.1",
121
120
  "eslint": "7.32.0",
122
- "eslint-plugin-react": "7.27.1",
121
+ "eslint-plugin-react": "7.28.0",
123
122
  "eslint-plugin-storybook": "0.5.5",
124
123
  "fs-extra": "10.0.0",
125
124
  "husky": "7.0.4",
@@ -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 Wed, 22 Dec 2021 14:08:07 GMT
3
+ * Generated on Fri, 24 Dec 2021 12:01:48 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 Wed, 22 Dec 2021 14:08:07 GMT
3
+ * Generated on Fri, 24 Dec 2021 12:01:48 GMT
4
4
  */
5
5
 
6
6
  :root {
@@ -1,19 +1,19 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Children, cloneElement, useState } from 'react';
2
+ import { Children, cloneElement, useState, useRef } from 'react';
3
3
  import { useUIDSeed } from 'react-uid';
4
- import { useKeyPress } from 'ahooks';
4
+ import { useKeyPress, useFocusWithin } from 'ahooks';
5
5
  import { Elevator } from '../';
6
- import { useFocusWithin } from '../hooks';
7
6
  import { Tooltip as TooltipClass, Arrow, Trigger } from './tooltip.module.css';
8
7
  import { usePopperTooltip } from 'react-popper-tooltip';
9
8
  export const Tooltip = ({ children, trigger, placement = 'bottom-start', show, style, maxWidth = '40ch', fill = false, interactive = false, delay = 500 }) => {
10
9
  const seedID = useUIDSeed();
11
10
  const [controlledVisible, setControlledVisible] = useState(false);
11
+ const tooltipContainerRef = useRef(null);
12
12
  useKeyPress('esc', () => setControlledVisible(false));
13
13
  const { getArrowProps, getTooltipProps, setTooltipRef, setTriggerRef, visible } = usePopperTooltip({
14
14
  delayShow: delay,
15
15
  delayHide: 300,
16
- trigger: ['hover', 'focus'],
16
+ trigger: ['hover'],
17
17
  visible: show || controlledVisible,
18
18
  closeOnTriggerHidden: true,
19
19
  interactive: interactive,
@@ -23,19 +23,18 @@ export const Tooltip = ({ children, trigger, placement = 'bottom-start', show, s
23
23
  }, {
24
24
  strategy: 'fixed'
25
25
  });
26
- const { focusWithinProps } = useFocusWithin({
27
- onFocusWithin: () => {
26
+ const isFocusWithin = useFocusWithin(tooltipContainerRef, {
27
+ onFocus: () => {
28
28
  setControlledVisible(true);
29
29
  },
30
- onBlurWithin: () => {
31
- setControlledVisible(false);
32
- },
33
- onFocusWithinChange: () => null
30
+ onBlur: (e) => {
31
+ (e.target?.parentElement !== tooltipContainerRef.current) && setControlledVisible(false);
32
+ }
34
33
  });
35
34
  const dynamycStyle = {
36
35
  '--maxW': maxWidth
37
36
  };
38
- return (_jsxs("div", { "data-tooltip-fill": fill, className: Trigger, ...focusWithinProps, style: { ...style }, children: [Children.map(trigger, (child) => cloneElement(child, {
37
+ return (_jsxs("div", { "data-tooltip-fill": fill, className: Trigger, ref: tooltipContainerRef, "data-tooltip-has-focus-within": isFocusWithin, style: { ...style }, children: [Children.map(trigger, (child) => cloneElement(child, {
39
38
  ref: setTriggerRef,
40
39
  'aria-describedby': seedID('tooltip-content')
41
40
  })), visible && (_jsx(Elevator, { resting: 2, children: _jsxs("div", { ref: setTooltipRef, role: "tooltip", id: seedID('tooltip-content'), "data-theme": "dark", ...getTooltipProps({ className: TooltipClass, style: dynamycStyle }), children: [children, _jsx("div", { ...getArrowProps({ className: Arrow }) }, void 0)] }, void 0) }, void 0))] }, void 0));
package/hooks/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export { useFocusWithin } from './useFocusWithin';
package/hooks/index.js DELETED
@@ -1 +0,0 @@
1
- export { useFocusWithin } from './useFocusWithin';
@@ -1,20 +0,0 @@
1
- import { FocusEvent, HTMLAttributes } from 'react';
2
- interface FocusWithinProps {
3
- /** Whether the focus within events should be disabled. */
4
- isDisabled?: boolean;
5
- /** Handler that is called when the target element or a descendant receives focus. */
6
- onFocusWithin?: (e: FocusEvent) => void;
7
- /** Handler that is called when the target element and all descendants lose focus. */
8
- onBlurWithin?: (e: FocusEvent) => void;
9
- /** Handler that is called when the the focus within state changes. */
10
- onFocusWithinChange?: (isFocusWithin: boolean) => void;
11
- }
12
- interface FocusWithinResult {
13
- /** Props to spread onto the target element. */
14
- focusWithinProps: HTMLAttributes<HTMLElement>;
15
- }
16
- /**
17
- * Handles focus events for the target and its descendants.
18
- */
19
- export declare function useFocusWithin(props: FocusWithinProps): FocusWithinResult;
20
- export {};
@@ -1,37 +0,0 @@
1
- import { useRef } from 'react';
2
- export function useFocusWithin(props) {
3
- const state = useRef({
4
- isFocusWithin: false
5
- }).current;
6
- if (props.isDisabled) {
7
- return { focusWithinProps: {} };
8
- }
9
- const onFocus = (e) => {
10
- if (!state.isFocusWithin) {
11
- if (props.onFocusWithin) {
12
- props.onFocusWithin(e);
13
- }
14
- if (props.onFocusWithinChange) {
15
- props.onFocusWithinChange(true);
16
- }
17
- state.isFocusWithin = true;
18
- }
19
- };
20
- const onBlur = (e) => {
21
- if (state.isFocusWithin && !e.currentTarget.contains(e.relatedTarget)) {
22
- if (props.onBlurWithin) {
23
- props.onBlurWithin(e);
24
- }
25
- if (props.onFocusWithinChange) {
26
- props.onFocusWithinChange(false);
27
- }
28
- state.isFocusWithin = false;
29
- }
30
- };
31
- return {
32
- focusWithinProps: {
33
- onFocus: onFocus,
34
- onBlur: onBlur
35
- }
36
- };
37
- }