@wonderflow/react-components 3.0.0-beta.1 → 3.0.0-beta.13

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 (57) hide show
  1. package/button/button.module.css +1 -1
  2. package/card/card.module.css +1 -1
  3. package/core/utils/media.css +19 -1
  4. package/core/utils/vibrancy.css +0 -24
  5. package/datetime/datetime.d.ts +7 -0
  6. package/datetime/datetime.js +13 -0
  7. package/datetime/index.d.ts +2 -0
  8. package/datetime/index.js +1 -0
  9. package/drawer/drawer.d.ts +85 -0
  10. package/drawer/drawer.js +34 -0
  11. package/drawer/drawer.module.css +1 -0
  12. package/drawer/index.d.ts +2 -0
  13. package/drawer/index.js +1 -0
  14. package/dropdown/dropdown.js +25 -12
  15. package/index.d.ts +6 -2
  16. package/index.js +4 -2
  17. package/input-group/input-group.js +3 -3
  18. package/list/list.js +1 -1
  19. package/list/list.module.css +1 -1
  20. package/modal/content/modal-content.js +4 -3
  21. package/modal/content/modal-content.module.css +1 -1
  22. package/modal/index.d.ts +0 -1
  23. package/modal/index.js +0 -1
  24. package/modal/modal.d.ts +0 -10
  25. package/modal/modal.js +24 -7
  26. package/modal/modal.module.css +1 -1
  27. package/overlay-container/index.d.ts +1 -0
  28. package/overlay-container/index.js +1 -0
  29. package/overlay-container/overlay-container.d.ts +14 -0
  30. package/overlay-container/overlay-container.js +8 -4
  31. package/overlay-container/overlay-container.module.css +1 -0
  32. package/overlay-container/overlay-context.d.ts +9 -0
  33. package/overlay-container/overlay-context.js +23 -0
  34. package/package.json +64 -21
  35. package/select/select.js +2 -2
  36. package/select/select.module.css +1 -1
  37. package/selection-controls/selection-controls.module.css +1 -1
  38. package/snackbar/snackbar.d.ts +1 -1
  39. package/snackbar/snackbar.js +2 -2
  40. package/snackbar/snackbar.module.css +1 -1
  41. package/spinner/spinner.d.ts +12 -0
  42. package/split-button/split-button.module.css +1 -1
  43. package/stack/stack.module.css +1 -1
  44. package/star-meter/star-meter.d.ts +4 -0
  45. package/star-meter/star-meter.js +4 -4
  46. package/text/text.js +1 -1
  47. package/textfield/base-field/base-field.module.css +1 -1
  48. package/textfield/textfield.js +4 -4
  49. package/themes/dark.css +1 -1
  50. package/themes/light.css +1 -1
  51. package/title/title.d.ts +20 -0
  52. package/title/title.module.css +1 -1
  53. package/toggle-button/toggle-button.d.ts +10 -0
  54. package/tooltip/tooltip.d.ts +32 -1
  55. package/tooltip/tooltip.js +11 -12
  56. package/modal/modal-context.d.ts +0 -9
  57. package/modal/modal-context.js +0 -23
@@ -1 +1 @@
1
- .Button{-webkit-touch-callout:none;grid-gap:.44rem;align-items:center;-webkit-appearance:none;appearance:none;background:none;border:0;border-radius:.22rem;box-sizing:border-box;cursor:pointer;display:inline-flex;font-family:inherit;font-weight:600;justify-content:center;margin:0;min-inline-size:min-content;overflow:hidden;position:relative;text-decoration:none;-webkit-user-select:none;user-select:none;white-space:nowrap}.Button[data-button-dimension=big]{block-size:2.67rem;font-size:1rem;padding:.55rem 1.33rem .66rem}.Button[data-button-dimension=regular]{block-size:2.22rem;font-size:.89rem;padding:.33rem .89rem .44rem}.Button[data-button-dimension=small]{grid-gap:.22rem;block-size:1.33rem;font-size:.78rem;padding:0 .22rem .11rem}.Button[data-button-kind=primary]{background:var(--cta-default);color:var(--cta-foreground)}.Button[data-button-kind=primary]:not([aria-pressed=true],[aria-disabled=true]):is(:active){background:var(--cta-dark)}.Button[data-button-kind=primary]:where([aria-pressed=true]),.Button[data-button-kind=primary]:where([aria-pressed=true]:active){background:#9e0018;color:#fff}.Button[data-button-kind=secondary]{-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background:linear-gradient(to bottom,var(--global-vibrancy-background),var(--global-vibrancy-background));color:var(--global-vibrancy-foreground)}.Button[data-button-kind=secondary]:not([aria-pressed=true],[aria-disabled=true]):is(:active){background:linear-gradient(to bottom,var(--global-vibrancy-background-hover),var(--global-vibrancy-background-hover));color:var(--global-vibrancy-foreground)}.Button[data-button-kind=secondary]:where([aria-pressed=true]),.Button[data-button-kind=secondary]:where([aria-pressed=true]:active){background:var(--dimmed-7);color:var(--dimmed-0)}.Button[data-button-kind=flat]{color:var(--global-vibrancy-foreground)}.Button[data-button-kind=flat]:not([aria-pressed=true],[aria-disabled=true]):is(:active){background:linear-gradient(to bottom,var(--global-vibrancy-background-hover),var(--global-vibrancy-background-hover))}.Button[data-button-kind=flat]:is(:hover,:focus){-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background:linear-gradient(to bottom,var(--global-vibrancy-background),var(--global-vibrancy-background));color:var(--global-vibrancy-foreground)}.Button[data-button-kind=flat]:where([aria-pressed=true]),.Button[data-button-kind=flat]:where([aria-pressed=true]:is(:active,:focus)){background:var(--dimmed-7);color:var(--dimmed-0)}.Button[data-button-fullwidth=true]{inline-size:100%}.Button[data-button-icon-position=right]{flex-direction:row-reverse}.Button[aria-disabled=true],.Button[aria-disabled=true]:is(:hover,:focus,:active){-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background:linear-gradient(to bottom,var(--global-disabled-background),var(--global-disabled-background));color:var(--global-disabled-foreground);cursor:not-allowed}.Button[aria-busy=true]>:not(.SpinnerIndicator){visibility:hidden}.SpinnerIndicator{align-content:center;bottom:0;display:grid;justify-content:center;left:0;place-content:center;position:absolute;right:0;top:0}.ButtonsGroup{display:inline-flex}.ButtonsGroup>:not(:first-child,:last-child,:only-of-type){border-radius:0}.ButtonsGroup>:first-child:not(:only-of-type){border-bottom-right-radius:0;border-top-right-radius:0;box-shadow:inset -1px 0 0 #6666661a}.ButtonsGroup>:last-child:not(:only-of-type){border-bottom-left-radius:0;border-top-left-radius:0;box-shadow:inset 1px 0 0 #6666661a}
1
+ .Button{-webkit-touch-callout:none;grid-gap:.44rem;align-items:center;-webkit-appearance:none;appearance:none;background:none;border:0;border-radius:.22rem;box-sizing:border-box;cursor:pointer;display:inline-flex;font-family:inherit;font-weight:600;justify-content:center;margin:0;min-inline-size:min-content;overflow:hidden;position:relative;text-decoration:none;-webkit-user-select:none;user-select:none;white-space:nowrap}.Button[data-button-dimension=big]{block-size:2.67rem;font-size:1rem;padding:.55rem 1.33rem .66rem}.Button[data-button-dimension=regular]{block-size:2.22rem;font-size:.89rem;padding:.33rem .89rem .44rem}.Button[data-button-dimension=small]{grid-gap:.22rem;block-size:1.33rem;font-size:.78rem;padding:0 .22rem .11rem}.Button[data-button-kind=primary]{background:var(--cta-default);color:var(--cta-foreground)}.Button[data-button-kind=primary]:not([aria-pressed=true],[aria-disabled=true]):is(:active){background:var(--cta-dark)}.Button[data-button-kind=primary]:where([aria-pressed=true]),.Button[data-button-kind=primary]:where([aria-pressed=true]:active){background:#9e0018;color:#fff}.Button[data-button-kind=secondary]{-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background-color:var(--global-vibrancy-background);color:var(--global-vibrancy-foreground)}.Button[data-button-kind=secondary]:not([aria-pressed=true],[aria-disabled=true]):is(:active){background-color:var(--global-vibrancy-background-hover);color:var(--global-vibrancy-foreground)}.Button[data-button-kind=secondary]:where([aria-pressed=true]),.Button[data-button-kind=secondary]:where([aria-pressed=true]:active){background:var(--dimmed-7);color:var(--dimmed-0)}.Button[data-button-kind=flat]{color:var(--global-vibrancy-foreground)}.Button[data-button-kind=flat]:not([aria-pressed=true],[aria-disabled=true]):is(:active){background-color:var(--global-vibrancy-background-hover)}.Button[data-button-kind=flat]:is(:hover,:focus){-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background-color:var(--global-vibrancy-background);color:var(--global-vibrancy-foreground)}.Button[data-button-kind=flat]:where([aria-pressed=true]),.Button[data-button-kind=flat]:where([aria-pressed=true]:is(:active,:focus)){background:var(--dimmed-7);color:var(--dimmed-0)}.Button[data-button-fullwidth=true]{inline-size:100%}.Button[data-button-icon-position=right]{flex-direction:row-reverse}.Button[aria-disabled=true],.Button[aria-disabled=true]:is(:hover,:focus,:active){background-color:var(--global-global-disabled-background);color:var(--global-disabled-foreground);cursor:not-allowed}.Button[aria-busy=true]>:not(.SpinnerIndicator){visibility:hidden}.SpinnerIndicator{align-content:center;bottom:0;display:grid;justify-content:center;left:0;place-content:center;position:absolute;right:0;top:0}.ButtonsGroup{display:inline-flex}.ButtonsGroup>:not(:first-child,:last-child,:only-of-type){border-radius:0}.ButtonsGroup>:first-child:not(:only-of-type){border-bottom-right-radius:0;border-top-right-radius:0;box-shadow:inset -1px 0 0 #6666661a}.ButtonsGroup>:last-child:not(:only-of-type){border-bottom-left-radius:0;border-top-left-radius:0;box-shadow:inset 1px 0 0 #6666661a}
@@ -1 +1 @@
1
- :where(.Card){background:var(--global-background);border-radius:var(--radius);padding:var(--padding);position:relative}:where(.Card)[data-card-dimmed="1"]{background:var(--dimmed-0)}:where(.Card)[data-card-dimmed="2"]{background:var(--dimmed-1)}:where(.Card)[data-card-dimmed="3"]{background:var(--dimmed-2)}:where(.Card)[data-card-vibrant=true]{-webkit-backdrop-filter:saturate(180%) blur(62px);backdrop-filter:saturate(180%) blur(62px);background:linear-gradient(to bottom,var(--global-vibrancy-background),var(--global-vibrancy-background))}:where(.Card)[data-card-highlight-hover=true][data-card-vibrant=true].focus-visible,:where(.Card)[data-card-highlight-hover=true][data-card-vibrant=true]:hover{background:linear-gradient(to bottom,var(--global-vibrancy-background-hover),var(--global-vibrancy-background-hover))}:where(.Card)[data-card-highlight-hover=true][data-card-vibrant=true]:focus-visible,:where(.Card)[data-card-highlight-hover=true][data-card-vibrant=true]:hover{background:linear-gradient(to bottom,var(--global-vibrancy-background-hover),var(--global-vibrancy-background-hover))}:where(.Card)[data-card-bordered=true]{border:1px solid var(--dimmed-1)}:where(.Card)[data-card-vibrant=true][data-card-bordered=true]{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);
@@ -1,27 +1,3 @@
1
1
  @define-mixin vibrancy {
2
2
  backdrop-filter: saturate(180%) blur(62px);
3
- background:
4
- linear-gradient(
5
- to bottom,
6
- var(--global-vibrancy-background),
7
- var(--global-vibrancy-background)
8
- );
9
- }
10
- @define-mixin vibrancy-hover {
11
- background:
12
- linear-gradient(
13
- to bottom,
14
- var(--global-vibrancy-background-hover),
15
- var(--global-vibrancy-background-hover)
16
- );
17
- }
18
- @define-mixin vibrancy-disabled {
19
- color: var(--global-disabled-foreground);
20
- backdrop-filter: saturate(180%) blur(62px);
21
- background:
22
- linear-gradient(
23
- to bottom,
24
- var(--global-disabled-background),
25
- var(--global-disabled-background)
26
- );
27
3
  }
@@ -0,0 +1,7 @@
1
+ import { HTMLAttributes } from 'react';
2
+ export declare type DatetimeProps = HTMLAttributes<HTMLTimeElement> & {
3
+ date: string;
4
+ locale?: string;
5
+ options?: Intl.DateTimeFormatOptions;
6
+ };
7
+ export declare const Datetime: ({ date, locale, options }: DatetimeProps) => JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ export const Datetime = ({ date, locale = 'en-US', options }) => {
4
+ const [datetime, setDateTime] = useState('');
5
+ useEffect(() => {
6
+ const timeDate = new Date(date);
7
+ const humanDate = new Intl.DateTimeFormat(locale, {
8
+ ...options
9
+ }).format(timeDate);
10
+ setDateTime(humanDate);
11
+ }, [date, locale, options]);
12
+ return (_jsx("time", { dateTime: date, children: datetime }, void 0));
13
+ };
@@ -0,0 +1,2 @@
1
+ export { Datetime } from './datetime';
2
+ export type { DatetimeProps } from './datetime';
@@ -0,0 +1 @@
1
+ export { Datetime } from './datetime';
@@ -0,0 +1,85 @@
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
+ * @important This property is considered only when `isModal` is `true`.
9
+ */
10
+ closeOnClickOutside?: boolean;
11
+ /**
12
+ * Set the accessible title of the drawer. This is used by screen readers to
13
+ * announce the title of the drawer when opened.
14
+ */
15
+ title?: ReactNode;
16
+ /**
17
+ * Hide or show the drawer header which includes the title and the close button.
18
+ * If you hide the title, make sure to add yuor own title element in order
19
+ * to provide an accessible label to the drawer.
20
+ */
21
+ showHeader?: boolean;
22
+ /**
23
+ * Set the maximum width of the drawer, on mobile the drawer will be
24
+ * automatically collapsed when the width is reached.
25
+ */
26
+ maxWidth?: string;
27
+ /**
28
+ * Set the theme of the content card. To ensure contrast with the default overlay color (dark),
29
+ * this is set to `light` by default.
30
+ */
31
+ theme?: 'dark' | 'light' | 'auto';
32
+ /**
33
+ * Set the side on which the drawer will be positioned.
34
+ */
35
+ side?: 'left' | 'right';
36
+ /**
37
+ * Disable the modal behavior of the drawer.
38
+ * If `false`, disable the prop `closeOnClickOutside` and
39
+ * the page is not blocked when the drawer is open.
40
+ */
41
+ isModal?: boolean;
42
+ };
43
+ export declare const Drawer: import("react").ForwardRefExoticComponent<PropsWithClass & {
44
+ children?: ReactNode;
45
+ } & {
46
+ /**
47
+ * This enable the drawer to be closed by clicking on the overlay.
48
+ * Even if this can be set to `false` we strongly recommend to leave
49
+ * it to `true` as it ensures the accessibility of the drawer.
50
+ *
51
+ * @important This property is considered only when `isModal` is `true`.
52
+ */
53
+ closeOnClickOutside?: boolean | undefined;
54
+ /**
55
+ * Set the accessible title of the drawer. This is used by screen readers to
56
+ * announce the title of the drawer when opened.
57
+ */
58
+ title?: ReactNode;
59
+ /**
60
+ * Hide or show the drawer header which includes the title and the close button.
61
+ * If you hide the title, make sure to add yuor own title element in order
62
+ * to provide an accessible label to the drawer.
63
+ */
64
+ showHeader?: boolean | undefined;
65
+ /**
66
+ * Set the maximum width of the drawer, on mobile the drawer will be
67
+ * automatically collapsed when the width is reached.
68
+ */
69
+ maxWidth?: string | undefined;
70
+ /**
71
+ * Set the theme of the content card. To ensure contrast with the default overlay color (dark),
72
+ * this is set to `light` by default.
73
+ */
74
+ theme?: "auto" | "light" | "dark" | undefined;
75
+ /**
76
+ * Set the side on which the drawer will be positioned.
77
+ */
78
+ side?: "left" | "right" | undefined;
79
+ /**
80
+ * Disable the modal behavior of the drawer.
81
+ * If `false`, disable the prop `closeOnClickOutside` and
82
+ * the page is not blocked when the drawer is open.
83
+ */
84
+ isModal?: boolean | undefined;
85
+ } & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,34 @@
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, AutoFocusInside } from 'react-focus-on';
6
+ import { useKeyPress } from 'ahooks';
7
+ import { Drawer as DrawerClass, Container, Content, Header, CloseButton } from './drawer.module.css';
8
+ import { useOverlayContext } from '../overlay-container';
9
+ import { Elevator, IconButton, Stack, Title } from '../';
10
+ export const Drawer = forwardRef(({ children, className, closeOnClickOutside = true, showHeader = true, maxWidth = '400px', side = 'right', theme = 'light', isModal = true, title, ...otherProps }, forwardedRef) => {
11
+ const { titleId, onClose } = useOverlayContext();
12
+ useKeyPress('esc', () => (!isModal && onClose) && onClose());
13
+ const dynamicStyle = {
14
+ '--max-w': maxWidth
15
+ };
16
+ const DrawerAnimation = {
17
+ visible: {
18
+ x: 0,
19
+ transition: {
20
+ ease: [0, 0, 0.34, 1],
21
+ duration: 0.35
22
+ }
23
+ },
24
+ hidden: {
25
+ x: side === 'right' ? '100%' : '-100%',
26
+ transition: {
27
+ ease: [0.3, 0.07, 1, 1],
28
+ duration: 0.2
29
+ }
30
+ }
31
+ };
32
+ return (_jsx("div", { role: "dialog", "aria-modal": isModal, "data-theme": theme, "aria-labelledby": titleId, className: clsx(DrawerClass, className), ref: forwardedRef, ...otherProps, children: _jsx(FocusOn, { enabled: isModal, 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)), _jsx(AutoFocusInside, { children: children }, void 0)] }, void 0) }, void 0) }, void 0) }, void 0) }, void 0));
33
+ });
34
+ 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,15 +1,32 @@
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 { useKey, useClickAway } from 'react-use';
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 '@react-aria/interactions';
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';
11
10
  import { usePopperTooltip } from 'react-popper-tooltip';
12
11
  import { AnimatePresence, motion } from 'framer-motion';
12
+ const DropdownAnimation = {
13
+ visible: {
14
+ y: 0,
15
+ opacity: 1,
16
+ transition: {
17
+ ease: [0, 0, 0.34, 1],
18
+ duration: 0.1
19
+ }
20
+ },
21
+ hidden: {
22
+ y: -5,
23
+ opacity: 0,
24
+ transition: {
25
+ ease: [0.3, 0.07, 1, 1],
26
+ duration: 0.1
27
+ }
28
+ }
29
+ };
13
30
  export const Dropdown = forwardRef(({ className, children, trigger, offset = 8, placement = 'auto-start' }, forwardedRef) => {
14
31
  const renderedChildren = Children.toArray(children).filter(Boolean);
15
32
  const seedID = useUIDSeed();
@@ -26,22 +43,18 @@ export const Dropdown = forwardRef(({ className, children, trigger, offset = 8,
26
43
  offset: [0, offset],
27
44
  closeOnOutsideClick: false
28
45
  });
29
- useClickAway(popupRef, () => {
46
+ const isFocusWithin = useFocusWithin(popupRef);
47
+ useClickAway(() => {
30
48
  setIsOpen(false);
31
- });
32
- const { focusWithinProps } = useFocusWithin({
33
- onFocusWithin: () => null,
34
- onBlurWithin: (e) => e.relatedTarget && setIsOpen(false),
35
- onFocusWithinChange: () => null
36
- });
37
- useKey('Escape', () => setIsOpen(false));
38
- return (_jsxs("div", { ref: popupRef, className: clsx(DropdownClass, className), ...focusWithinProps, children: [Children.map(trigger, (child) => cloneElement(child, {
49
+ }, popupRef);
50
+ useKeyPress('esc', () => setIsOpen(false));
51
+ return (_jsxs("div", { ref: popupRef, "data-dropdown-has-focus-within": isFocusWithin, className: clsx(DropdownClass, className), children: [Children.map(trigger, (child) => cloneElement(child, {
39
52
  ref: setTriggerRef,
40
53
  id: seedID('dropdown-trigger'),
41
54
  'aria-haspopup': 'true',
42
55
  'aria-controls': seedID('dropdown-menu'),
43
56
  'aria-expanded': isOpen
44
- })), _jsx(AnimatePresence, { children: visible && (_jsx("div", { ref: setTooltipRef, role: "tooltip", id: seedID('tooltip-content'), className: PopUp, ...getTooltipProps({ className: PopUp }), children: _jsx(motion.div, { style: { y: -5 }, animate: visible ? { y: 0, opacity: 1 } : { opacity: 0 }, transition: { ease: 'easeOut', duration: 0.1 }, children: Children.map(renderedChildren, (child) => cloneElement(child, {
57
+ })), _jsx(AnimatePresence, { children: visible && (_jsx("div", { ref: setTooltipRef, role: "tooltip", id: seedID('tooltip-content'), className: PopUp, ...getTooltipProps({ className: PopUp }), children: _jsx(motion.div, { variants: DropdownAnimation, initial: "hidden", animate: "visible", exit: "hidden", children: Children.map(renderedChildren, (child) => cloneElement(child, {
45
58
  id: seedID('dropdown-menu'),
46
59
  'aria-labelledby': seedID('dropdown-trigger')
47
60
  })) }, void 0) }, void 0)) }, void 0)] }, void 0));
package/index.d.ts CHANGED
@@ -16,6 +16,10 @@ 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 { Datetime } from './datetime';
20
+ export type { DatetimeProps } from './datetime';
21
+ export { Drawer } from './drawer';
22
+ export type { DrawerProps } from './drawer';
19
23
  export { Table } from './table';
20
24
  export type { TableProps } from './table';
21
25
  export { Disclosure } from './disclosure';
@@ -36,11 +40,11 @@ export { List } from './list';
36
40
  export type { ListProps } from './list';
37
41
  export { SplitButton } from './split-button';
38
42
  export type { SplitButtonProps } from './split-button';
39
- export { Modal, useModalContext, ModalProvider } from './modal';
43
+ export { Modal } from './modal';
40
44
  export type { ModalProps } from './modal';
41
45
  export { LinearProgress } from './linear-progress';
42
46
  export type { LinearProgressProps } from './linear-progress';
43
- export { OverlayContainer } from './overlay-container';
47
+ export { OverlayContainer, useOverlayContext, OverlayProvider } from './overlay-container';
44
48
  export type { OverlayContainerProps } from './overlay-container';
45
49
  export { Prose } from './prose';
46
50
  export type { ProseProps } from './prose';
package/index.js CHANGED
@@ -8,6 +8,8 @@ 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 { Datetime } from './datetime';
12
+ export { Drawer } from './drawer';
11
13
  export { Table } from './table';
12
14
  export { Disclosure } from './disclosure';
13
15
  export { Dropdown } from './dropdown';
@@ -18,9 +20,9 @@ export { InfoState } from './info-state';
18
20
  export { InputGroup } from './input-group';
19
21
  export { List } from './list';
20
22
  export { SplitButton } from './split-button';
21
- export { Modal, useModalContext, ModalProvider } from './modal';
23
+ export { Modal } from './modal';
22
24
  export { LinearProgress } from './linear-progress';
23
- export { OverlayContainer } from './overlay-container';
25
+ export { OverlayContainer, useOverlayContext, OverlayProvider } from './overlay-container';
24
26
  export { Prose } from './prose';
25
27
  export { Pagination } from './pagination';
26
28
  export { Select } from './select';
@@ -5,11 +5,11 @@ import { Stack, Text } from '../';
5
5
  import { useUIDSeed } from 'react-uid';
6
6
  import { End, InputField, Start, InputGroup as InputGroupClass } from './input-group.module.css';
7
7
  export const InputGroup = forwardRef(({ className, input, end, start, label, dimension = 'regular', ...otherProps }, forwardedRef) => {
8
- const uid = useUIDSeed();
9
- return (_jsxs(Stack, { rowGap: 4, horizontalAlign: "stretch", verticalAlign: "start", fill: false, children: [label && _jsx(Text, { as: "label", size: dimension === 'small' ? 14 : 16, htmlFor: uid('field'), children: label }, void 0), _jsxs(Stack, { as: "fieldset", direction: "row", verticalAlign: "start", horizontalAlign: "start", fill: false, inline: true, ref: forwardedRef, className: clsx(InputGroupClass, className), "data-input-group-has-end": Boolean(end), "data-input-group-has-start": !!start, ...otherProps, children: [_jsx("div", { className: Start, children: Children.map(start, (child) => cloneElement(child, {
8
+ const seedID = useUIDSeed();
9
+ return (_jsxs(Stack, { rowGap: 4, horizontalAlign: "stretch", verticalAlign: "start", fill: false, children: [label && _jsx(Text, { as: "label", size: dimension === 'small' ? 14 : 16, htmlFor: seedID('field'), children: label }, void 0), _jsxs(Stack, { as: "fieldset", direction: "row", verticalAlign: "start", horizontalAlign: "start", fill: false, inline: true, ref: forwardedRef, className: clsx(InputGroupClass, className), "data-input-group-has-end": Boolean(end), "data-input-group-has-start": !!start, ...otherProps, children: [_jsx("div", { className: Start, children: Children.map(start, (child) => cloneElement(child, {
10
10
  dimension
11
11
  })) }, void 0), _jsx("div", { className: InputField, children: Children.map(input, (child) => cloneElement(child, {
12
- id: uid('field'),
12
+ id: seedID('field'),
13
13
  dimension
14
14
  })) }, void 0), _jsx("div", { className: End, children: Children.map(end, (child) => cloneElement(child, {
15
15
  dimension
package/list/list.js CHANGED
@@ -19,5 +19,5 @@ export const List = forwardRef(({ as: Wrapper = 'ul', children, marker = 'circle
19
19
  }
20
20
  };
21
21
  const isUnordered = useMemo(() => Wrapper === 'ul', [Wrapper]);
22
- return (_jsx(Wrapper, { ref: forwardedRef, className: clsx(ListClass, className), "data-list-size": dimension, "data-list-ordered": !isUnordered, "data-list-no-marker": hideMarker, ...otherProps, children: Children.map(children, (child) => (_jsxs(Text, { as: "li", size: sizes[dimension].text, children: [isUnordered && (_jsx(Icon, { name: marker, className: Marker, fill: markerColor, dimension: marker !== 'circle' ? sizes[dimension].icon : 16 }, void 0)), child.props.children] }, void 0))) }, void 0));
22
+ return (_jsx(Wrapper, { ref: forwardedRef, className: clsx(ListClass, className), "data-list-size": dimension, "data-list-ordered": !isUnordered, "data-list-no-marker": hideMarker, ...otherProps, children: Children.map(children, (child) => (_jsxs(Text, { as: "li", size: sizes[dimension].text, children: [(isUnordered && !hideMarker) && (_jsx(Icon, { name: marker, className: Marker, fill: markerColor, "data-list-default-marker": marker === 'circle', dimension: marker !== 'circle' ? sizes[dimension].icon : 16 }, void 0)), child.props.children] }, void 0))) }, void 0));
23
23
  });
@@ -1 +1 @@
1
- .List{--marker-size:0.89rem;--marker-gap:0.44rem}.List[data-list-no-marker=true]{--marker-size:0;--marker-gap:0;list-style:none;padding:0}.List[data-list-ordered=false]{list-style:none;padding:0}.List[data-list-ordered=false] li{padding-inline-start:calc(var(--marker-size) + var(--marker-gap));position:relative}.List[data-list-ordered=true] li{padding-inline-start:var(--marker-gap)}.List[data-list-ordered=true] li::marker{color:var(--dimmed-5)}.List[data-list-size=small]{--marker-size:0.77rem;--marker-gap:0.44rem}.List[data-list-size=big]{--marker-size:1.11rem;--marker-gap:0.89rem}.Marker{block-size:var(--marker-size);inline-size:var(--marker-size);left:0;position:absolute;top:calc(var(--marker-size)/2.4)}.List[data-list-size=small] .Marker{top:3px}.List[data-list-size=big] .Marker{top:calc(var(--marker-size)/3)}
1
+ .List{--marker-size:0.89rem;--marker-gap:0.44rem}.List[data-list-ordered=false]{list-style:none;padding:0}.List[data-list-ordered=false] li{padding-inline-start:calc(var(--marker-size) + var(--marker-gap));position:relative}.List[data-list-ordered=true] li{padding-inline-start:var(--marker-gap)}.List[data-list-ordered=true] li::marker{color:var(--dimmed-5)}.List[data-list-size=small]{--marker-size:0.77rem;--marker-gap:0.44rem}.List[data-list-size=big]{--marker-size:1.11rem;--marker-gap:0.89rem}.List[data-list-no-marker=true]{--marker-size:0;--marker-gap:0;list-style:none;padding:0}.Marker{block-size:var(--marker-size);inline-size:var(--marker-size);left:0;position:absolute;top:calc(var(--marker-size)/2.4)}.Marker[data-list-default-marker=true]{transform:scale(.7)}.List[data-list-size=small] .Marker{top:3px}.List[data-list-size=big] .Marker{top:calc(var(--marker-size)/3)}
@@ -1,11 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import clsx from 'clsx';
3
3
  import { forwardRef } from 'react';
4
+ import { AutoFocusInside } from 'react-focus-on';
4
5
  import { Content, Header, CloseButton } from './modal-content.module.css';
5
6
  import { Title, Elevator, IconButton, Stack } from '../../';
6
- import { useModalContext } from '../modal-context';
7
+ import { useOverlayContext } from '../../overlay-container';
7
8
  export const ModalContent = forwardRef(({ children, className, title, theme = 'light', ...otherProps }, forwardedRef) => {
8
- const { onClose, titleId } = useModalContext();
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
+ const { onClose, titleId } = useOverlayContext();
10
+ 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), _jsx(AutoFocusInside, { children: children }, void 0)] }, void 0) }, void 0));
10
11
  });
11
12
  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/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export { Modal } from './modal';
2
- export { useModalContext, ModalProvider } from './modal-context';
3
2
  export type { ModalProps } from './modal';
package/modal/index.js CHANGED
@@ -1,2 +1 @@
1
1
  export { Modal } from './modal';
2
- export { useModalContext, ModalProvider } from './modal-context';
package/modal/modal.d.ts CHANGED
@@ -1,22 +1,12 @@
1
1
  import { PropsWithChildren } from 'react';
2
2
  import { ModalContentProps } from './content/modal-content';
3
3
  export declare type ModalProps = PropsWithChildren<PropsWithClass> & {
4
- /**
5
- * Set the overlay style. This is used to obscure the page content
6
- * behind the modal while it is open. If set to `auto`, the overlay
7
- * color is determined by the global active theme (light or dark).
8
- */
9
- overlayColor?: 'light' | 'dark' | 'auto';
10
4
  /**
11
5
  * This enable the modal to be closed by clicking on the overlay.
12
6
  * Even if this can be set to `false` we strongly recommend to leave
13
7
  * it to `true` as it ensures the accessibility of the modal.
14
8
  */
15
9
  closeOnClickOutside?: boolean;
16
- /**
17
- * The callback function that is called when the modal is closed.
18
- */
19
- onClose(): void;
20
10
  };
21
11
  declare type ModalComponent = React.ForwardRefExoticComponent<ModalProps> & {
22
12
  Content: React.ForwardRefExoticComponent<ModalContentProps>;
package/modal/modal.js CHANGED
@@ -1,15 +1,32 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from 'react';
3
- import { useUIDSeed } from 'react-uid';
4
3
  import { motion } from 'framer-motion';
5
4
  import clsx from 'clsx';
6
5
  import { FocusOn } from 'react-focus-on';
7
6
  import { ModalContent } from './content/modal-content';
8
- import { Modal as ModalClass, Backdrop, Container } from './modal.module.css';
9
- import { ModalContext, ModalProvider } from './modal-context';
10
- export const Modal = forwardRef(({ children, className, overlayColor = 'dark', closeOnClickOutside = true, onClose, ...otherProps }, forwardedRef) => {
11
- const seedID = useUIDSeed();
12
- return (_jsx(ModalProvider, { onClose: onClose, children: _jsx(ModalContext.Consumer, { children: (ctx) => (_jsxs("div", { role: "dialog", "aria-modal": "true", "aria-labelledby": ctx.titleId, className: clsx(ModalClass, className), ref: forwardedRef, ...otherProps, children: [_jsx(motion.span, { className: Backdrop, "data-overlay-color": overlayColor, initial: { opacity: 0 }, animate: { opacity: 0.95 }, transition: { duration: 0.2 } }, seedID('modal-backdrop')), _jsx(FocusOn, { onClickOutside: ctx.onClose, onEscapeKey: ctx.onClose, children: _jsx(motion.div, { className: Container, initial: { y: 20, scale: 0.98, opacity: 0 }, animate: { y: 0, scale: 1, opacity: 1 }, transition: { ease: 'easeOut', duration: 0.1 }, children: children }, seedID('modal-container')) }, void 0)] }, void 0)) }, void 0) }, void 0));
7
+ import { Modal as ModalClass, Container } from './modal.module.css';
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
+ };
27
+ export const Modal = forwardRef(({ children, className, closeOnClickOutside = true, ...otherProps }, forwardedRef) => {
28
+ const { titleId, onClose } = useOverlayContext();
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));
13
30
  });
14
31
  Modal.displayName = 'Modal';
15
32
  Modal.Content = ModalContent;
@@ -1 +1 @@
1
- .Modal{position:fixed;z-index:20}.Backdrop,.Modal{bottom:0;left:0;right:0;top:0}.Backdrop{background-color:var(--dimmed-0);display:block;position:absolute;z-index:1}.Backdrop[data-overlay-color=light]{background-color:#f9fafb}.Backdrop[data-overlay-color=dark]{background-color:#202328}.Container{align-items:center;bottom:0;display:grid;justify-content:center;left:0;pointer-events:none;position:absolute;right:0;top:0;z-index:1}@media (min-width:30em){.Container{overflow:auto;padding:0 1.33rem}}.Container>*{pointer-events:auto}
1
+ .Modal{display:contents}.Container{align-items:center;bottom:0;display:grid;justify-content:center;left:0;pointer-events:none;position:absolute;right:0;top:0;z-index:1}@media (min-width:30em){.Container{overflow:auto;padding:0 1.33rem}}.Container>*{pointer-events:auto}
@@ -1,2 +1,3 @@
1
1
  export { OverlayContainer } from './overlay-container';
2
+ export { useOverlayContext, OverlayProvider, OverlayContext } from './overlay-context';
2
3
  export type { OverlayContainerProps } from './overlay-container';
@@ -1 +1,2 @@
1
1
  export { OverlayContainer } from './overlay-container';
2
+ export { useOverlayContext, OverlayProvider, OverlayContext } from './overlay-context';
@@ -15,5 +15,19 @@ export declare type OverlayContainerProps = {
15
15
  * if necessary.
16
16
  */
17
17
  index?: number;
18
+ /**
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
+ * color is determined by the global active theme (light or dark).
22
+ */
23
+ overlayColor?: 'light' | 'dark' | 'auto';
24
+ /**
25
+ * The callback function that is called when the overlay is closed.
26
+ */
27
+ onClose?(): void;
28
+ /**
29
+ * Set the overlay to be obscuring the page content behind it.
30
+ */
31
+ obfuscate?: boolean;
18
32
  };
19
33
  export declare const OverlayContainer: React.FC<OverlayContainerProps>;
@@ -1,13 +1,17 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { AnimatePresence, motion } from 'framer-motion';
2
3
  import { useEffect } from 'react';
3
- import { ModalProvider } from '../modal';
4
4
  import { createPortal } from 'react-dom';
5
- export const OverlayContainer = ({ children, root = document.body, index = 4 }) => {
5
+ import { useUIDSeed } from 'react-uid';
6
+ import { OverlayProvider } from './overlay-context';
7
+ import { OverlayContainer as OverlayContainerClass, Backdrop } from './overlay-container.module.css';
8
+ export const OverlayContainer = ({ children, root = document.body, overlayColor = 'dark', index = 4, obfuscate = true, onClose }) => {
9
+ const seedID = useUIDSeed();
6
10
  useEffect(() => {
7
11
  if (root.closest('[data-overlay-container]')) {
8
12
  throw new Error('An OverlayContainer must not be inside another container. Please change the root prop.');
9
13
  }
10
14
  }, [root]);
11
- const content = (_jsx(ModalProvider, { children: _jsx("div", { "data-overlay-container": true, style: { position: 'relative', zIndex: index }, children: children }, void 0) }, void 0));
15
+ const content = (_jsx(OverlayProvider, { onClose: onClose, children: _jsx(AnimatePresence, { exitBeforeEnter: true, children: children && (_jsxs("div", { "data-overlay-container": true, "data-overlay-container-obfuscate": obfuscate, className: OverlayContainerClass, style: { zIndex: index }, children: [obfuscate && (_jsx(motion.span, { className: Backdrop, "data-overlay-color": overlayColor, initial: { opacity: 0 }, animate: { opacity: 0.95 }, transition: { duration: 0.2 }, exit: { opacity: 0 } }, seedID('modal-backdrop'))), children] }, void 0)) }, void 0) }, void 0));
12
16
  return createPortal(content, root);
13
17
  };
@@ -0,0 +1 @@
1
+ .OverlayContainer{bottom:0;display:block;left:0;position:fixed;right:0;top:0}.OverlayContainer[data-overlay-container-obfuscate=false]{pointer-events:none}.Backdrop{background-color:var(--dimmed-0);bottom:0;left:0;position:fixed;right:0;top:0;z-index:-1}.Backdrop[data-overlay-color=light]{background-color:#f9fafb}.Backdrop[data-overlay-color=dark]{background-color:#202328}
@@ -0,0 +1,9 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { OverlayContainerProps } from './overlay-container';
3
+ declare type OverlayContextProps = Partial<OverlayContainerProps> & {
4
+ titleId?: string;
5
+ };
6
+ export declare const OverlayContext: import("react").Context<OverlayContextProps>;
7
+ export declare const OverlayProvider: (props: PropsWithChildren<OverlayContextProps>) => JSX.Element;
8
+ export declare const useOverlayContext: () => OverlayContextProps;
9
+ export {};
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext } from 'react';
3
+ import { useUIDSeed } from 'react-uid';
4
+ export const OverlayContext = createContext({
5
+ titleId: '',
6
+ onClose: () => { }
7
+ });
8
+ OverlayContext.displayName = 'OverlayContext';
9
+ export const OverlayProvider = (props) => {
10
+ const seedID = useUIDSeed();
11
+ const { children, titleId = seedID('overlay-title'), onClose } = props;
12
+ return (_jsx(OverlayContext.Provider, { value: {
13
+ titleId,
14
+ onClose
15
+ }, children: children }, void 0));
16
+ };
17
+ export const useOverlayContext = () => {
18
+ const context = useContext(OverlayContext);
19
+ if (!context) {
20
+ throw new Error('OverlayContainer component must be used inside OverlayContext to access context data.');
21
+ }
22
+ return context;
23
+ };