@wonderflow/react-components 10.20.0 → 11.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/core/basic.css +1 -1
  2. package/core.css +1 -1
  3. package/dist/components/accordion/accordion.test.js +0 -15
  4. package/dist/components/aspect-ratio/aspect-ratio.test.js +0 -15
  5. package/dist/components/autocomplete/autocomplete.d.ts +4 -0
  6. package/dist/components/autocomplete/autocomplete.d.ts.map +1 -1
  7. package/dist/components/autocomplete/autocomplete.js +2 -4
  8. package/dist/components/autocomplete/autocomplete.module.css +1 -1
  9. package/dist/components/autocomplete/autocomplete.test.js +0 -15
  10. package/dist/components/avatar/avatar.module.css +1 -1
  11. package/dist/components/avatar/avatar.test.js +0 -15
  12. package/dist/components/button/button.d.ts +1 -2
  13. package/dist/components/button/button.d.ts.map +1 -1
  14. package/dist/components/button/button.module.css +1 -1
  15. package/dist/components/button/button.stories.d.ts +4 -4
  16. package/dist/components/button/button.stories.d.ts.map +1 -1
  17. package/dist/components/button/button.test.js +0 -15
  18. package/dist/components/card/card.d.ts.map +1 -1
  19. package/dist/components/card/card.js +1 -1
  20. package/dist/components/card/card.module.css +1 -1
  21. package/dist/components/card/card.test.js +0 -15
  22. package/dist/components/chip/chip.module.css +1 -1
  23. package/dist/components/chip/chip.test.js +0 -15
  24. package/dist/components/circular-progress/circular-progress.test.js +0 -15
  25. package/dist/components/clamp-text/clamp-text.test.js +0 -15
  26. package/dist/components/container/container.d.ts +1 -1
  27. package/dist/components/container/container.d.ts.map +1 -1
  28. package/dist/components/container/container.module.css +1 -1
  29. package/dist/components/container/container.stories.d.ts +4 -5
  30. package/dist/components/container/container.stories.d.ts.map +1 -1
  31. package/dist/components/container/container.stories.js +11 -14
  32. package/dist/components/container/container.test.js +0 -15
  33. package/dist/components/datetime/datetime.test.js +0 -15
  34. package/dist/components/disclosure/disclosure.module.css +1 -1
  35. package/dist/components/disclosure/disclosure.test.d.ts.map +1 -1
  36. package/dist/components/disclosure/disclosure.test.js +0 -15
  37. package/dist/components/elevator/elevator.test.js +0 -15
  38. package/dist/components/expander/expander.test.js +0 -15
  39. package/dist/components/grid/grid.test.js +0 -15
  40. package/dist/components/info-state/info-state.d.ts.map +1 -1
  41. package/dist/components/info-state/info-state.js +1 -9
  42. package/dist/components/info-state/info-state.module.css +1 -1
  43. package/dist/components/info-state/info-state.stories.d.ts +31 -31
  44. package/dist/components/info-state/info-state.stories.d.ts.map +1 -1
  45. package/dist/components/info-state/info-state.stories.js +5 -5
  46. package/dist/components/info-state/info-state.test.js +0 -15
  47. package/dist/components/input-group/input-group.test.js +0 -15
  48. package/dist/components/linear-progress/linear-progress.module.css +1 -1
  49. package/dist/components/linear-progress/linear-progress.test.js +0 -15
  50. package/dist/components/list/list.module.css +1 -1
  51. package/dist/components/list/list.test.js +0 -15
  52. package/dist/components/masonry/masonry.test.js +0 -15
  53. package/dist/components/menu/menu-item/menu-item.d.ts.map +1 -1
  54. package/dist/components/menu/menu-item/menu-item.js +3 -1
  55. package/dist/components/menu/menu-item/menu-item.module.css +1 -1
  56. package/dist/components/menu/menu-item/menu-item.stories.d.ts.map +1 -1
  57. package/dist/components/menu/menu-item/menu-item.stories.js +1 -0
  58. package/dist/components/menu/menu.test.js +0 -15
  59. package/dist/components/modal/content/modal-content.d.ts +7 -8
  60. package/dist/components/modal/content/modal-content.d.ts.map +1 -1
  61. package/dist/components/modal/content/modal-content.js +3 -7
  62. package/dist/components/modal/content/modal-content.module.css +1 -1
  63. package/dist/components/modal/footer/modal-footer.d.ts +32 -0
  64. package/dist/components/modal/footer/modal-footer.d.ts.map +1 -0
  65. package/dist/components/modal/footer/modal-footer.js +22 -0
  66. package/dist/components/modal/footer/modal-footer.module.css +1 -0
  67. package/dist/components/modal/header/modal-header.d.ts +20 -0
  68. package/dist/components/modal/header/modal-header.d.ts.map +1 -0
  69. package/dist/components/modal/header/modal-header.js +26 -0
  70. package/dist/components/modal/header/modal-header.module.css +1 -0
  71. package/dist/components/modal/modal.d.ts +79 -7
  72. package/dist/components/modal/modal.d.ts.map +1 -1
  73. package/dist/components/modal/modal.js +16 -6
  74. package/dist/components/modal/modal.module.css +1 -1
  75. package/dist/components/modal/modal.stories.d.ts +69 -5
  76. package/dist/components/modal/modal.stories.d.ts.map +1 -1
  77. package/dist/components/modal/modal.stories.js +145 -10
  78. package/dist/components/modal/modal.test.d.ts +2 -0
  79. package/dist/components/modal/modal.test.d.ts.map +1 -0
  80. package/dist/components/modal/modal.test.js +60 -0
  81. package/dist/components/overlay-container/overlay-container.test.d.ts +2 -0
  82. package/dist/components/overlay-container/overlay-container.test.d.ts.map +1 -0
  83. package/dist/components/overlay-container/overlay-container.test.js +19 -0
  84. package/dist/components/pagination/pagination.test.js +0 -15
  85. package/dist/components/popover/popover.d.ts +4 -0
  86. package/dist/components/popover/popover.d.ts.map +1 -1
  87. package/dist/components/popover/popover.js +6 -8
  88. package/dist/components/popover/popover.module.css +1 -1
  89. package/dist/components/popover/popover.stories.d.ts +13 -9
  90. package/dist/components/popover/popover.stories.d.ts.map +1 -1
  91. package/dist/components/popover/popover.stories.js +8 -2
  92. package/dist/components/popover/popover.test.js +0 -15
  93. package/dist/components/prose/prose.test.js +0 -15
  94. package/dist/components/select/select.js +1 -1
  95. package/dist/components/select/select.module.css +1 -1
  96. package/dist/components/select/select.test.js +0 -15
  97. package/dist/components/selection-controls/selection-controls.test.js +0 -15
  98. package/dist/components/separator/separator.test.js +0 -15
  99. package/dist/components/skeleton/skeleton.test.js +0 -15
  100. package/dist/components/slider/slider.test.js +0 -15
  101. package/dist/components/snackbar/snackbar.test.js +0 -15
  102. package/dist/components/spinner/spinner.test.js +0 -15
  103. package/dist/components/split-button/split-button.test.js +0 -15
  104. package/dist/components/stack/stack.test.js +0 -15
  105. package/dist/components/star-meter/star-meter.module.css +1 -1
  106. package/dist/components/star-meter/star-meter.test.js +0 -15
  107. package/dist/components/symbol/symbol.test.js +0 -15
  108. package/dist/components/tab/tab.js +1 -1
  109. package/dist/components/tab/tab.module.css +1 -1
  110. package/dist/components/tab/tab.stories.d.ts +1 -0
  111. package/dist/components/tab/tab.stories.d.ts.map +1 -1
  112. package/dist/components/tab/tab.stories.js +4 -17
  113. package/dist/components/tab/tab.test.js +0 -15
  114. package/dist/components/table/table-cell/table-cell.test.js +0 -15
  115. package/dist/components/table/table-checkbox/table-checkbox.test.js +0 -15
  116. package/dist/components/table/table-controls/table-controls.test.js +0 -15
  117. package/dist/components/table/table-header/table-header.test.js +0 -15
  118. package/dist/components/table/table-pagination/table-pagination.test.js +0 -15
  119. package/dist/components/table/table-row/table-row.test.js +0 -15
  120. package/dist/components/table/table.module.css +1 -1
  121. package/dist/components/table/table.stories.d.ts.map +1 -1
  122. package/dist/components/table/table.stories.js +1 -0
  123. package/dist/components/table/table.test.js +0 -15
  124. package/dist/components/text/text.module.css +1 -1
  125. package/dist/components/text/text.test.js +0 -15
  126. package/dist/components/textfield/textfield.module.css +1 -1
  127. package/dist/components/textfield/textfield.test.js +0 -15
  128. package/dist/components/title/title.module.css +1 -1
  129. package/dist/components/title/title.test.js +0 -15
  130. package/dist/components/toggle-button/toggle-button.test.js +0 -15
  131. package/dist/components/tooltip/tooltip.d.ts +4 -0
  132. package/dist/components/tooltip/tooltip.d.ts.map +1 -1
  133. package/dist/components/tooltip/tooltip.js +2 -4
  134. package/dist/components/tooltip/tooltip.module.css +1 -1
  135. package/dist/components/tooltip/tooltip.stories.d.ts +1 -1
  136. package/dist/components/tooltip/tooltip.stories.d.ts.map +1 -1
  137. package/dist/components/tooltip/tooltip.stories.js +4 -3
  138. package/dist/components/tooltip/tooltip.test.js +0 -15
  139. package/dist/hooks/index.d.ts +3 -1
  140. package/dist/hooks/index.d.ts.map +1 -1
  141. package/dist/hooks/index.js +3 -1
  142. package/dist/hooks/useBreakpoints.d.ts +11 -0
  143. package/dist/hooks/useBreakpoints.d.ts.map +1 -0
  144. package/dist/hooks/useBreakpoints.js +84 -0
  145. package/dist/hooks/useBreakpoints.test.d.ts +2 -0
  146. package/dist/hooks/useBreakpoints.test.d.ts.map +1 -0
  147. package/dist/hooks/useBreakpoints.test.js +35 -0
  148. package/dist/hooks/useBreakpointsConfig.d.ts +12 -0
  149. package/dist/hooks/useBreakpointsConfig.d.ts.map +1 -0
  150. package/dist/hooks/useBreakpointsConfig.js +31 -0
  151. package/dist/hooks/useBreakpointsConfig.test.d.ts +2 -0
  152. package/dist/hooks/useBreakpointsConfig.test.d.ts.map +1 -0
  153. package/dist/hooks/useBreakpointsConfig.test.js +16 -0
  154. package/dist/hooks/useSSR.d.ts +5 -0
  155. package/dist/hooks/useSSR.d.ts.map +1 -0
  156. package/dist/hooks/useSSR.js +24 -0
  157. package/dist/hooks/useSSR.test.d.ts +2 -0
  158. package/dist/hooks/useSSR.test.d.ts.map +1 -0
  159. package/dist/hooks/useSSR.test.js +11 -0
  160. package/dist/providers/providers.test.js +11 -17
  161. package/package.json +5 -4
  162. package/dist/hooks/usePopupWrapper.d.ts +0 -4
  163. package/dist/hooks/usePopupWrapper.d.ts.map +0 -1
  164. package/dist/hooks/usePopupWrapper.js +0 -42
@@ -1,15 +1,87 @@
1
1
  import { PropsWithChildren } from 'react';
2
- import { ModalContentProps } from './content/modal-content';
2
+ import { OverlayContainerProps } from '../..';
3
+ import { Button } from '../button/button';
4
+ import { ModalContentComponent } from './content/modal-content';
5
+ import { ModalFooterComponent } from './footer/modal-footer';
6
+ import { ModalHeaderComponent } from './header/modal-header';
3
7
  export declare type ModalProps = PropsWithChildren<PropsWithClass<{
4
8
  /**
5
- * This enable the modal to be closed by clicking on the overlay.
6
- * Even if this can be set to `false` we strongly recommend to leave
7
- * it to `true` as it ensures the accessibility of the modal.
9
+ * Display the Modal
8
10
  */
9
- closeOnClickOutside?: boolean;
10
- }>>;
11
+ isVisible: boolean;
12
+ /**
13
+ * Callback function to be called when the Modal is closed.
14
+ */
15
+ onCloseModal: () => void;
16
+ /**
17
+ * Set the Modal Header title.
18
+ */
19
+ title?: React.ReactNode;
20
+ /**
21
+ * Set the Modal Header subtitle. This value depends on the presence of the title.
22
+ */
23
+ subtitle?: React.ReactNode;
24
+ /**
25
+ * Hide the Close icon Button.
26
+ */
27
+ hideCloseButton?: boolean;
28
+ /**
29
+ * Hide the border at the bottom of the header. This will be automatically dismissed
30
+ * if no content is provided inside the Modal Header.
31
+ */
32
+ hideHeaderBorder?: boolean;
33
+ /**
34
+ * Hide the border at the top of the footer. This will be automatically dismissed
35
+ * if no actions are provided inside the Modal Footer.
36
+ */
37
+ hideFooterBorder?: boolean;
38
+ /**
39
+ * Set the Modal body content.
40
+ */
41
+ content?: React.ReactNode;
42
+ /**
43
+ * Set the Primary Button with a constrain in kind and size.
44
+ */
45
+ primaryAction?: React.ComponentPropsWithRef<typeof Button>;
46
+ /**
47
+ * Set the Secondary Button with a constrain in kind and size.
48
+ */
49
+ secondaryAction?: React.ComponentPropsWithRef<typeof Button>;
50
+ /**
51
+ * Set a Custom Modal Action element.
52
+ */
53
+ tertiaryAction?: React.ReactNode;
54
+ /**
55
+ * Set Modal action buttons in the center on a desktop screen. On Mobile
56
+ * they will always be stacked vertically in a column.
57
+ */
58
+ alignActionCenter?: boolean;
59
+ /**
60
+ * Set Modal content vertically in the center on a mobile screen.
61
+ */
62
+ alignContentCenter?: boolean;
63
+ /**
64
+ * Set the loading state by displaying a spinner while true.
65
+ */
66
+ isLoading?: boolean;
67
+ /**
68
+ * Set the theme of the content card. To ensure contrast with the default overlay color (dark),
69
+ * this is set to `light` by default.
70
+ */
71
+ theme?: 'dark' | 'light' | 'auto';
72
+ /**
73
+ * Set the Modal size.
74
+ */
75
+ size?: 'small' | 'medium' | 'large';
76
+ /**
77
+ * This prevent the modal to be closed by clicking on the overlay.
78
+ */
79
+ preventCloseOnClickOutside?: boolean;
80
+ }>> & Pick<OverlayContainerProps, 'obfuscate' | 'overlayColor' | 'index' | 'root'>;
11
81
  declare type ModalComponent = React.ForwardRefExoticComponent<ModalProps> & {
12
- Content: React.ForwardRefExoticComponent<ModalContentProps>;
82
+ Header: ModalHeaderComponent;
83
+ Content: ModalContentComponent;
84
+ Footer: ModalFooterComponent;
13
85
  };
14
86
  export declare const Modal: ModalComponent;
15
87
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/modal/modal.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAc,iBAAiB,EAAW,MAAM,OAAO,CAAC;AAK/D,OAAO,EAAgB,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG1E,oBAAY,UAAU,GAAG,iBAAiB,CAAC,cAAc,CAAC;IACxD;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC,CAAC,CAAA;AAEH,aAAK,cAAc,GAAG,KAAK,CAAC,yBAAyB,CAAC,UAAU,CAAC,GAAG;IAClE,OAAO,EAAE,KAAK,CAAC,yBAAyB,CAAC,iBAAiB,CAAC,CAAC;CAC7D,CAAA;AAOD,eAAO,MAAM,KAAK,gBAyDE,CAAC"}
1
+ {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/modal/modal.tsx"],"names":[],"mappings":"AAmBA,OAAO,EACqC,iBAAiB,EAC5D,MAAM,OAAO,CAAC;AAGf,OAAO,EACuB,qBAAqB,EAClD,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAgB,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAe,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAe,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAG1E,oBAAY,UAAU,GAAG,iBAAiB,CAAC,cAAc,CAAC;IACxD;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC,qBAAqB,CAAC,OAAO,MAAM,CAAC,CAAC;IAC3D;;OAEG;IACH,eAAe,CAAC,EAAE,KAAK,CAAC,qBAAqB,CAAC,OAAO,MAAM,CAAC,CAAC;IAC7D;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACjC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IAClC;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC;;OAEG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC,CAAC,CAAC,GAAG,IAAI,CAAC,qBAAqB,EAAE,WAAW,GAAG,cAAc,GAAG,OAAO,GAAG,MAAM,CAAC,CAAA;AAElF,aAAK,cAAc,GAAG,KAAK,CAAC,yBAAyB,CAAC,UAAU,CAAC,GAAG;IAClE,MAAM,EAAE,oBAAoB,CAAC;IAC7B,OAAO,EAAE,qBAAqB,CAAC;IAC/B,MAAM,EAAE,oBAAoB,CAAC;CAC9B,CAAA;AAOD,eAAO,MAAM,KAAK,gBA0JE,CAAC"}
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  /*
3
3
  * Copyright 2022-2023 Wonderflow Design Team
4
4
  *
@@ -17,18 +17,20 @@ import { jsx as _jsx } from "react/jsx-runtime";
17
17
  import tkns from '@wonderflow/tokens/platforms/web/tokens.json';
18
18
  import clsx from 'clsx';
19
19
  import { domMax, LazyMotion, m } from 'framer-motion';
20
- import { forwardRef, useMemo } from 'react';
20
+ import { cloneElement, forwardRef, isValidElement, useMemo, } from 'react';
21
21
  import { FocusOn } from 'react-focus-on';
22
- import { useOverlayContext, useResponsiveContext } from '../..';
22
+ import { Elevator, OverlayContainer, Spinner, Stack, Text, Title, useResponsiveContext, } from '../..';
23
23
  import { ModalContent } from './content/modal-content';
24
+ import { ModalFooter } from './footer/modal-footer';
25
+ import { ModalHeader } from './header/modal-header';
24
26
  import * as styles from './modal.module.css';
25
27
  const cssEasingToArray = (cssEasing) => {
26
28
  const [x1, y1, x2, y2] = cssEasing.replace(/[^0-9.,]+/g, '').split(',').map(i => parseFloat(i));
27
29
  return [x1, y1, x2, y2];
28
30
  };
29
- export const Modal = forwardRef(({ children, className, closeOnClickOutside = true, ...otherProps }, forwardedRef) => {
30
- const { titleId, onClose } = useOverlayContext();
31
+ export const Modal = forwardRef(({ children, className, size = 'medium', theme = 'light', title, subtitle, hideCloseButton, hideHeaderBorder, hideFooterBorder, content, primaryAction, secondaryAction, tertiaryAction, alignActionCenter, alignContentCenter, isVisible, preventCloseOnClickOutside, isLoading, onCloseModal, ...otherProps }, forwardedRef) => {
31
32
  const { matches } = useResponsiveContext();
33
+ const hasActions = tertiaryAction ?? secondaryAction ?? primaryAction;
32
34
  const ModalAnimation = useMemo(() => ({
33
35
  visible: {
34
36
  scale: 1,
@@ -49,7 +51,15 @@ export const Modal = forwardRef(({ children, className, closeOnClickOutside = tr
49
51
  },
50
52
  },
51
53
  }), [matches]);
52
- return (_jsx("div", { role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, className: clsx(styles.Modal, className), ref: forwardedRef, ...otherProps, children: _jsx(FocusOn, { onClickOutside: closeOnClickOutside ? onClose : undefined, onEscapeKey: onClose, children: _jsx(LazyMotion, { features: domMax, children: _jsx(m.div, { variants: ModalAnimation, initial: "hidden", animate: "visible", exit: "hidden", className: styles.Container, children: children }) }) }) }));
54
+ return (_jsx(_Fragment, { children: isVisible && (_jsx(OverlayContainer, { onClose: onCloseModal, overlayColor: otherProps.overlayColor, root: otherProps.root, index: otherProps.index, obfuscate: otherProps.obfuscate, children: _jsx("div", { "aria-modal": "true", "aria-labelledby": (typeof title === 'string') ? title : 'modal-label', className: clsx(styles.Modal, className), ref: forwardedRef, ...otherProps, children: _jsx(FocusOn, { onClickOutside: preventCloseOnClickOutside ? undefined : onCloseModal, onEscapeKey: onCloseModal, children: _jsx(LazyMotion, { features: domMax, children: _jsx(m.div, { role: "dialog", variants: ModalAnimation, initial: "hidden", animate: "visible", exit: "hidden", className: styles.Container, children: _jsx(Elevator, { resting: 4, children: _jsx("div", { className: clsx(styles.Main, className), ref: forwardedRef, "data-theme": theme, "data-size": size, ...otherProps, children: children ?? (_jsxs(_Fragment, { children: [_jsxs(Modal.Header, { hideCloseButton: hideCloseButton, theme: theme, hideBorder: (!title ?? !subtitle) || hideHeaderBorder, children: [title && _jsx(Title, { level: "5", children: title }), (title && subtitle) && _jsx(Text, { size: 14, children: subtitle })] }), content && (_jsx(Modal.Content, { theme: theme, alignContentCenter: isLoading ?? alignContentCenter, children: isLoading
55
+ ? (_jsx(Stack, { fill: true, hAlign: "center", vPadding: 64, children: _jsxs(Stack, { hAlign: "center", vAlign: "center", rowGap: 16, children: [_jsx(Spinner, { dimension: "big" }), _jsx(Text, { size: "16", dimmed: 5, children: "Loading..." })] }) }))
56
+ : content })), hasActions && (_jsx(Modal.Footer, { theme: theme, hideBorder: hideFooterBorder, children: _jsxs(Stack, { direction: matches.small ? 'row' : 'column-reverse', rowGap: matches.small ? undefined : '16', fill: false, hAlign: (alignActionCenter && matches.small) ? 'center' : 'space-between', vAlign: "center", columnGap: 16, children: [_jsx(Stack, { direction: "row", fill: true, children: tertiaryAction }), _jsxs(Stack, { direction: matches.small ? 'row' : 'column-reverse', rowGap: matches.small ? undefined : '16', columnGap: 16, children: [secondaryAction
57
+ && isValidElement(secondaryAction)
58
+ && cloneElement(secondaryAction, { ...secondaryAction.props, kind: 'secondary', dimension: 'regular' }), primaryAction
59
+ && isValidElement(primaryAction)
60
+ && cloneElement(primaryAction, { ...primaryAction.props, kind: 'primary', dimension: 'regular' })] })] }) }))] })) }) }) }) }) }) }) })) }));
53
61
  });
54
62
  Modal.displayName = 'Modal';
63
+ Modal.Header = ModalHeader;
55
64
  Modal.Content = ModalContent;
65
+ Modal.Footer = ModalFooter;
@@ -1 +1 @@
1
- @layer components{.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:48em){.Container{overflow:auto;padding:0 1.5rem}}.Container>*{pointer-events:auto}}
1
+ @layer components{.Modal{align-items:center;display:flex;height:100vh;justify-content:center;left:0;position:fixed;top:0;width:100vw}.Main{-webkit-overflow-scrolling:touch;background-color:var(--global-background);border-radius:0;display:grid;grid-template-columns:100%;grid-template-rows:auto 1fr auto;inline-size:100vw;max-block-size:95vh;min-height:100vh;overflow:hidden}@media (min-width:48em){.Main{border-radius:.5rem;max-height:90vh;min-height:auto}.Main[data-size=small]{inline-size:480px}.Main[data-size=medium]{inline-size:600px}.Main[data-size=large]{inline-size:720px}}.Container{z-index:1}.Container>*{pointer-events:auto}}@layer overrides{.CloseButton{position:absolute;right:.5rem;top:.5rem}}
@@ -1,12 +1,76 @@
1
+ /// <reference types="react" />
1
2
  import { ComponentMeta, ComponentStory } from '@storybook/react';
2
- import React from 'react';
3
3
  import { Modal } from './modal';
4
4
  declare const story: ComponentMeta<typeof Modal>;
5
5
  export default story;
6
- export declare const Default: ComponentStory<React.ForwardRefExoticComponent<import("./modal").ModalProps> & {
7
- Content: React.ForwardRefExoticComponent<import("./content/modal-content").ModalContentProps>;
6
+ export declare const Default: ComponentStory<import("react").ForwardRefExoticComponent<import("./modal").ModalProps> & {
7
+ Header: import("./header/modal-header").ModalHeaderComponent;
8
+ Content: import("./content/modal-content").ModalContentComponent;
9
+ Footer: import("./footer/modal-footer").ModalFooterComponent;
8
10
  }>;
9
- export declare const Custom: ComponentStory<React.ForwardRefExoticComponent<import("./modal").ModalProps> & {
10
- Content: React.ForwardRefExoticComponent<import("./content/modal-content").ModalContentProps>;
11
+ export declare const Inverse: ComponentStory<import("react").ForwardRefExoticComponent<import("./modal").ModalProps> & {
12
+ Header: import("./header/modal-header").ModalHeaderComponent;
13
+ Content: import("./content/modal-content").ModalContentComponent;
14
+ Footer: import("./footer/modal-footer").ModalFooterComponent;
15
+ }>;
16
+ export declare const LoadingContent: ComponentStory<import("react").ForwardRefExoticComponent<import("./modal").ModalProps> & {
17
+ Header: import("./header/modal-header").ModalHeaderComponent;
18
+ Content: import("./content/modal-content").ModalContentComponent;
19
+ Footer: import("./footer/modal-footer").ModalFooterComponent;
20
+ }>;
21
+ export declare const Confirmation: ComponentStory<import("react").ForwardRefExoticComponent<import("./modal").ModalProps> & {
22
+ Header: import("./header/modal-header").ModalHeaderComponent;
23
+ Content: import("./content/modal-content").ModalContentComponent;
24
+ Footer: import("./footer/modal-footer").ModalFooterComponent;
25
+ }>;
26
+ export declare const WithSimpleForm: ComponentStory<import("react").ForwardRefExoticComponent<import("./modal").ModalProps> & {
27
+ Header: import("./header/modal-header").ModalHeaderComponent;
28
+ Content: import("./content/modal-content").ModalContentComponent;
29
+ Footer: import("./footer/modal-footer").ModalFooterComponent;
30
+ }>;
31
+ export declare const WithComplexForm: ComponentStory<import("react").ForwardRefExoticComponent<import("./modal").ModalProps> & {
32
+ Header: import("./header/modal-header").ModalHeaderComponent;
33
+ Content: import("./content/modal-content").ModalContentComponent;
34
+ Footer: import("./footer/modal-footer").ModalFooterComponent;
35
+ }>;
36
+ export declare const WithThirdAction: ComponentStory<import("react").ForwardRefExoticComponent<import("./modal").ModalProps> & {
37
+ Header: import("./header/modal-header").ModalHeaderComponent;
38
+ Content: import("./content/modal-content").ModalContentComponent;
39
+ Footer: import("./footer/modal-footer").ModalFooterComponent;
40
+ }>;
41
+ export declare const WithAList: ComponentStory<import("react").ForwardRefExoticComponent<import("./modal").ModalProps> & {
42
+ Header: import("./header/modal-header").ModalHeaderComponent;
43
+ Content: import("./content/modal-content").ModalContentComponent;
44
+ Footer: import("./footer/modal-footer").ModalFooterComponent;
45
+ }>;
46
+ export declare const WithImage: ComponentStory<import("react").ForwardRefExoticComponent<import("./modal").ModalProps> & {
47
+ Header: import("./header/modal-header").ModalHeaderComponent;
48
+ Content: import("./content/modal-content").ModalContentComponent;
49
+ Footer: import("./footer/modal-footer").ModalFooterComponent;
50
+ }>;
51
+ export declare const WithTabs: ComponentStory<import("react").ForwardRefExoticComponent<import("./modal").ModalProps> & {
52
+ Header: import("./header/modal-header").ModalHeaderComponent;
53
+ Content: import("./content/modal-content").ModalContentComponent;
54
+ Footer: import("./footer/modal-footer").ModalFooterComponent;
55
+ }>;
56
+ export declare const withNestedElements: ComponentStory<import("react").ForwardRefExoticComponent<import("./modal").ModalProps> & {
57
+ Header: import("./header/modal-header").ModalHeaderComponent;
58
+ Content: import("./content/modal-content").ModalContentComponent;
59
+ Footer: import("./footer/modal-footer").ModalFooterComponent;
60
+ }>;
61
+ export declare const withDisclosure: ComponentStory<import("react").ForwardRefExoticComponent<import("./modal").ModalProps> & {
62
+ Header: import("./header/modal-header").ModalHeaderComponent;
63
+ Content: import("./content/modal-content").ModalContentComponent;
64
+ Footer: import("./footer/modal-footer").ModalFooterComponent;
65
+ }>;
66
+ export declare const withHeroIcon: ComponentStory<import("react").ForwardRefExoticComponent<import("./modal").ModalProps> & {
67
+ Header: import("./header/modal-header").ModalHeaderComponent;
68
+ Content: import("./content/modal-content").ModalContentComponent;
69
+ Footer: import("./footer/modal-footer").ModalFooterComponent;
70
+ }>;
71
+ export declare const Custom: ComponentStory<import("react").ForwardRefExoticComponent<import("./modal").ModalProps> & {
72
+ Header: import("./header/modal-header").ModalHeaderComponent;
73
+ Content: import("./content/modal-content").ModalContentComponent;
74
+ Footer: import("./footer/modal-footer").ModalFooterComponent;
11
75
  }>;
12
76
  //# sourceMappingURL=modal.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"modal.stories.d.ts","sourceRoot":"","sources":["../../../src/components/modal/modal.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAmB,MAAM,OAAO,CAAC;AAMxC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,KAAK,CAOtC,CAAC;AAEF,eAAe,KAAK,CAAC;AAsCrB,eAAO,MAAM,OAAO;;EAA2B,CAAC;AAuBhD,eAAO,MAAM,MAAM;;EAA0B,CAAC"}
1
+ {"version":3,"file":"modal.stories.d.ts","sourceRoot":"","sources":["../../../src/components/modal/modal.stories.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQjE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAQhC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,KAAK,CAmCtC,CAAC;AAEF,eAAe,KAAK,CAAC;AAkBrB,eAAO,MAAM,OAAO;;;;EAA2B,CAAC;AAEhD,eAAO,MAAM,OAAO;;;;EAA2B,CAAC;AAMhD,eAAO,MAAM,cAAc;;;;EAA2B,CAAC;AAOvD,eAAO,MAAM,YAAY;;;;EAA2B,CAAC;AAWrD,eAAO,MAAM,cAAc;;;;EAA2B,CAAC;AAevD,eAAO,MAAM,eAAe;;;;EAA2B,CAAC;AA8BxD,eAAO,MAAM,eAAe;;;;EAA2B,CAAC;AAgBxD,eAAO,MAAM,SAAS;;;;EAA2B,CAAC;AA+BlD,eAAO,MAAM,SAAS;;;;EAA2B,CAAC;AA0ClD,eAAO,MAAM,QAAQ;;;;EAA2B,CAAC;AA4DjD,eAAO,MAAM,kBAAkB;;;;EAA2B,CAAC;AAS3D,eAAO,MAAM,cAAc;;;;EAA2B,CAAC;AAqBvD,eAAO,MAAM,YAAY;;;;EAA2B,CAAC;AA+CrD,eAAO,MAAM,MAAM;;;;EAA0B,CAAC"}
@@ -1,23 +1,158 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
- import { Button, IconButton, OverlayContainer, ResponsiveProvider, Stack, Title, useOverlayContext, } from '../..';
3
+ import { AutoFocusInside } from 'react-focus-on';
4
+ import { Button, Card, Checkbox, Disclosure, Elevator, InfoState, Popover, ResponsiveProvider, Select, Stack, Tab, Text, Textfield, Title, } from '../..';
4
5
  import { Modal } from './modal';
6
+ const longText = (_jsx(Text, { size: 16, children: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore cumque voluptate in ut iste reiciendis ipsa nihil accusantium illum ea ullam quasi voluptatibus, reprehenderit maxime placeat laborum, quam debitis, perferendis nemo cum cupiditate dolorem esse. Distinctio excepturi pariatur doloribus, nostrum nesciunt provident. Placeat debitis a odit nesciunt perspiciatis? Nihil aliquam obcaecati ab, quas magni aut suscipit et similique alias nulla repudiandae beatae, aliquid, saepe porro libero officiis ullam cumque quidem eius odio voluptatibus. Reiciendis, vel asperiores? Facilis, provident inventore iure ea a odit suscipit! Aspernatur quae odio neque labore? Quidem esse earum hic excepturi amet sequi porro aperiam eos iste mollitia aut a omnis praesentium sit, asperiores consequatur harum itaque in quam. Quisquam dolores sint eaque dicta quia velit repellat suscipit provident facere repellendus molestias accusantium obcaecati ratione distinctio qui nesciunt totam quas, a ipsum. Possimus exercitationem, velit quibusdam dicta, et quidem dolorum provident voluptatibus facilis quasi nisi incidunt magni quis officia obcaecati laborum perferendis aliquid consequatur itaque corrupti similique ex reprehenderit expedita suscipit. Ipsum quidem possimus doloribus ut, id debitis, officiis, totam assumenda dolore recusandae impedit in tempore neque unde? Repellat necessitatibus in tempora ipsam officiis quam cumque alias. Sed saepe iure ullam, pariatur quo incidunt vero sapiente exercitationem numquam obcaecati suscipit mollitia aspernatur iste esse quia facere magni praesentium! Alias corrupti vitae odit animi magnam ut ad, voluptates hic consequatur dolorum aliquam suscipit quidem assumenda omnis velit, modi commodi exercitationem rerum! Inventore officia, nobis sunt enim quisquam explicabo molestias suscipit esse eaque cumque fugit autem perspiciatis temporibus nisi non. Quae aut nam aliquam accusamus officiis impedit suscipit deleniti ipsa saepe, est facere iusto quam molestias in voluptate error qui porro, veritatis labore iste commodi deserunt ipsum sed? Corrupti unde animi esse deleniti eligendi distinctio, recusandae ratione earum libero sunt nisi impedit repellat aspernatur, quisquam eius iste reiciendis maxime." }));
5
7
  const story = {
6
8
  title: 'Dialogs/Modal',
7
9
  component: Modal,
8
- argTypes: {},
9
- args: {},
10
+ argTypes: {
11
+ theme: {
12
+ options: ['light', 'dark', 'auto'],
13
+ control: { type: 'select' },
14
+ },
15
+ overlayColor: {
16
+ options: ['light', 'dark', 'auto'],
17
+ control: { type: 'select' },
18
+ },
19
+ size: {
20
+ options: ['small', 'medium', 'large'],
21
+ control: { type: 'select' },
22
+ },
23
+ },
24
+ args: {
25
+ title: 'Modal Title',
26
+ subtitle: 'Subtitle',
27
+ overlayColor: 'dark',
28
+ hideCloseButton: false,
29
+ hideHeaderBorder: false,
30
+ hideFooterBorder: false,
31
+ alignActionCenter: false,
32
+ alignContentCenter: false,
33
+ size: 'medium',
34
+ theme: 'auto',
35
+ isLoading: false,
36
+ preventCloseOnClickOutside: false,
37
+ content: longText,
38
+ primaryAction: _jsx(Button, { onClick: () => alert('Primary Action'), children: "Action 1" }),
39
+ secondaryAction: _jsx(Button, { onClick: () => alert('Secondary Action'), children: "Action 2" }),
40
+ tertiaryAction: undefined,
41
+ },
10
42
  };
11
43
  export default story;
12
- const ModalShell = ({ children, ...otherProps }) => {
44
+ const DefaultTemplate = (args) => {
13
45
  const [isVisible, setIsVisible] = useState(false);
14
- return (_jsxs(ResponsiveProvider, { children: [_jsx(Button, { onClick: () => setIsVisible(true), children: "Show Modal" }), _jsx(OverlayContainer, { onClose: () => setIsVisible(false), children: isVisible && (_jsx(Modal, { ...otherProps, children: children }, "dynamic-modal")) })] }));
46
+ return (_jsxs(ResponsiveProvider, { children: [_jsx(Button, { onClick: () => setIsVisible(true), children: "Show Modal" }), _jsx(Modal, { ...args, isVisible: isVisible, onCloseModal: () => setIsVisible(false) })] }));
15
47
  };
16
- const DefaultTemplate = args => (_jsx(ModalShell, { ...args, children: _jsxs(Modal.Content, { title: "Modal title", theme: "auto", children: ["Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus et magnam distinctio qui quod ducimus libero magni earum perspiciatis.", _jsx("img", { width: "100%", height: "400", alt: "", src: "https://images.unsplash.com/photo-1579332649290-10b7da0cd111?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=cover&w=1600&q=80" }), _jsx("button", { type: "button", children: "click" })] }) }));
17
48
  export const Default = DefaultTemplate.bind({});
18
- const CustomContentModal = () => {
19
- const { onClose, titleId } = useOverlayContext();
20
- return (_jsxs(Stack, { vAlign: "center", children: [_jsxs(Stack, { direction: "row", fill: false, vAlign: "center", hAlign: "space-between", children: [_jsx(Title, { level: "5", id: titleId, children: titleId }), _jsx(IconButton, { onClick: () => onClose?.(), icon: "xmark", kind: "flat", "aria-label": "Close modal" })] }), "Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus et magnam distinctio qui quod ducimus libero magni earum perspiciatis.", _jsx("img", { width: "100%", height: "auto", alt: "", src: "https://images.unsplash.com/photo-1579332649290-10b7da0cd111?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=cover&w=1600&q=80" })] }));
49
+ export const Inverse = DefaultTemplate.bind({});
50
+ Inverse.args = {
51
+ theme: 'dark',
52
+ overlayColor: 'light',
53
+ };
54
+ export const LoadingContent = DefaultTemplate.bind({});
55
+ LoadingContent.args = {
56
+ isLoading: true,
57
+ primaryAction: _jsx(Button, { onClick: () => alert('Primary Action'), disabled: true, children: "Action 1" }),
58
+ secondaryAction: _jsx(Button, { onClick: () => alert('Secondary Action'), disabled: true, children: "Action 2" }),
59
+ };
60
+ export const Confirmation = DefaultTemplate.bind({});
61
+ Confirmation.args = {
62
+ title: 'Delete account?',
63
+ subtitle: undefined,
64
+ hideHeaderBorder: true,
65
+ content: _jsx(Text, { size: 16, children: "Are you sure you want to delete your account? This action cannot be undone." }),
66
+ hideFooterBorder: true,
67
+ primaryAction: _jsx(Button, { children: "Delete" }),
68
+ secondaryAction: _jsx(Button, { children: "Cancel" }),
69
+ };
70
+ export const WithSimpleForm = DefaultTemplate.bind({});
71
+ WithSimpleForm.args = {
72
+ title: 'Enter your details',
73
+ subtitle: undefined,
74
+ content: (_jsxs(Stack, { rowGap: 16, children: [_jsx(Textfield, { label: "First name" }), _jsx(Textfield, { label: "Last name" })] })),
75
+ hideFooterBorder: true,
76
+ primaryAction: _jsx(Button, { children: "Submit" }),
77
+ secondaryAction: _jsx(Button, { children: "Cancel" }),
78
+ };
79
+ export const WithComplexForm = DefaultTemplate.bind({});
80
+ WithComplexForm.args = {
81
+ title: 'Tell us more about yourself',
82
+ subtitle: 'You may add a description here',
83
+ content: (_jsxs(Stack, { rowGap: 16, children: [_jsx(Textfield, { label: "Enter your full name", messag: "Sample hint text" }), _jsxs(Select, { placeholder: "Select", label: "How would you describe the interface?", children: [_jsxs("optgroup", { label: "Option Group", children: [_jsx("option", { children: "Option 1" }), _jsx("option", { children: "Option 2" }), _jsx("option", { children: "Option 3" })] }), _jsxs("optgroup", { label: "Option Group 2", children: [_jsx("option", { children: "Option 4" }), _jsx("option", { children: "Option 5" }), _jsx("option", { children: "Option 6" })] })] }), _jsx(Textfield, { textarea: true, label: "Is there anything you'd like to add?", value: "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nesciunt, earum." })] })),
84
+ primaryAction: _jsx(Button, { children: "Submit" }),
85
+ secondaryAction: _jsx(Button, { children: "Cancel" }),
86
+ };
87
+ export const WithThirdAction = DefaultTemplate.bind({});
88
+ WithThirdAction.args = {
89
+ title: 'Enter your details',
90
+ subtitle: undefined,
91
+ content: (_jsxs(Stack, { rowGap: 16, children: [_jsx(Textfield, { label: "First name" }), _jsx(Textfield, { label: "Last name" })] })),
92
+ hideFooterBorder: true,
93
+ primaryAction: _jsx(Button, { children: "Submit" }),
94
+ secondaryAction: _jsx(Button, { children: "Cancel" }),
95
+ tertiaryAction: _jsx(Checkbox, { label: "Remember me", defaultChecked: true, dimension: "small" }),
96
+ };
97
+ export const WithAList = DefaultTemplate.bind({});
98
+ WithAList.args = {
99
+ title: 'Modal with a list',
100
+ subtitle: undefined,
101
+ content: (_jsxs(Stack, { rowGap: 16, children: [_jsx(Text, { size: 16, children: "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nesciunt, earum." }), _jsxs("ul", { children: [_jsx("li", { children: _jsx(Text, { size: 16, children: "List item content" }) }), _jsx("li", { children: _jsx(Text, { size: 16, children: "List item content" }) }), _jsx("li", { children: _jsx(Text, { size: 16, children: "List item content" }) })] })] })),
102
+ primaryAction: _jsx(Button, { children: "Primary" }),
103
+ secondaryAction: _jsx(Button, { children: "Secondary" }),
104
+ };
105
+ const withImageContent = (_jsxs(Stack, { hAlign: "center", vAlign: "center", vPadding: 16, children: [_jsx("img", { src: "https://wonderimages.gumlet.io/placeholders/illustration.png?format=webp&q=100", alt: "modal illustartion", width: "400px", height: "auto" }), _jsx(Title, { level: "5", children: "Title goes here" }), _jsx(Text, { size: 14, children: "Subtitle goes here" })] }));
106
+ export const WithImage = DefaultTemplate.bind({});
107
+ WithImage.args = {
108
+ title: undefined,
109
+ subtitle: undefined,
110
+ content: withImageContent,
111
+ hideFooterBorder: true,
112
+ alignContentCenter: true,
113
+ alignActionCenter: true,
114
+ primaryAction: _jsx(Button, { children: "Primary" }),
115
+ secondaryAction: _jsx(Button, { children: "Secondary" }),
116
+ };
117
+ const formWithin = (_jsxs(Stack, { rowGap: 24, children: [_jsxs(Stack, { direction: "row", columnGap: 24, children: [_jsx(Textfield, { label: "Label", placeHolder: "Sample value" }), _jsx(Textfield, { label: "Label", placeHolder: "Sample value" })] }), _jsx(Textfield, { label: "Label", placeHolder: "Sample value" })] }));
118
+ const withTabsContent = (_jsxs(Tab, { defaultValue: "1", dimension: "regular", children: [_jsx(Tab.Panel, { value: "1", label: "Tab 1", children: _jsx(Card, { children: formWithin }) }), _jsx(Tab.Panel, { value: "2", label: "Tab 2", children: _jsx(Card, { children: formWithin }) }), _jsx(Tab.Panel, { value: "3", label: "Tab 3", children: _jsx(Card, { children: formWithin }) })] }));
119
+ export const WithTabs = DefaultTemplate.bind({});
120
+ WithTabs.args = {
121
+ title: 'Modal title',
122
+ subtitle: 'Subtitle',
123
+ content: withTabsContent,
124
+ primaryAction: _jsx(Button, { children: "Confirm" }),
125
+ secondaryAction: _jsx(Button, { children: "Cancel" }),
126
+ };
127
+ const complexNesting = (_jsx(Stack, { vPadding: 8, children: _jsx(Popover, { placement: "bottom-start", trigger: (_jsx(Textfield, { type: "text", label: "Topic", placeholder: "Select a Topic" })), children: _jsx(Elevator, { resting: 1, children: _jsx(Card, { children: _jsx(AutoFocusInside, { children: _jsxs(Tab, { defaultValue: "1", dimension: "regular", children: [_jsx(Tab.Panel, { value: "1", label: "Tab 1", children: _jsx(Card, { children: _jsx(Stack, { children: _jsx(Disclosure, { summary: "Disclosure 1", children: "Content Tab 1" }) }) }) }), _jsx(Tab.Panel, { value: "2", label: "Tab 2", children: _jsx(Card, { children: _jsx(Stack, { children: _jsx(Disclosure, { summary: "Disclosure 2", children: "Content Tab 2" }) }) }) }), _jsx(Tab.Panel, { value: "3", label: "Tab 3", children: _jsx(Card, { children: _jsx(Stack, { children: _jsx(Disclosure, { summary: "Disclosure 3", children: "Content Tab 3" }) }) }) })] }) }) }) }) }) }));
128
+ export const withNestedElements = DefaultTemplate.bind({});
129
+ withNestedElements.args = {
130
+ title: 'With Nested Elements',
131
+ subtitle: undefined,
132
+ content: complexNesting,
133
+ primaryAction: _jsx(Button, { children: "Confirm" }),
134
+ secondaryAction: _jsx(Button, { children: "Cancel" }),
135
+ };
136
+ export const withDisclosure = DefaultTemplate.bind({});
137
+ withDisclosure.args = {
138
+ title: 'With Disclosed Content',
139
+ content: (_jsxs(Stack, { rowGap: 16, children: [_jsx(Text, { children: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Ea facilis similique ab?" }), _jsx(Disclosure, { dimension: "small", summary: "Lorem 12", iconPosition: "right", children: _jsx(Text, { children: "Lorem ipsum dolor, sit amet consectetur adipisicing elit. Ullam sequi laudantium quibusdam?" }) }), _jsx(Disclosure, { dimension: "small", summary: "Lorem 16", iconPosition: "right", children: _jsx(Text, { children: "Lorem, ipsum dolor sit amet consectetur adipisicing elit. Quod incidunt temporibus tempora laborum quisquam, fugiat voluptas?" }) }), _jsx(Disclosure, { dimension: "small", summary: "Lorem 24", iconPosition: "right", children: _jsx(Text, { children: "Lorem, ipsum dolor sit amet consectetur adipisicing elit. Neque repellat dicta molestias facere, vero possimus reiciendis odio delectus tenetur voluptatum quis. Quam, eaque quo?" }) })] })),
140
+ alignActionCenter: true,
141
+ primaryAction: _jsx(Button, { children: "OK" }),
142
+ secondaryAction: undefined,
143
+ };
144
+ export const withHeroIcon = DefaultTemplate.bind({});
145
+ withHeroIcon.args = {
146
+ title: undefined,
147
+ subtitle: undefined,
148
+ content: (_jsx(InfoState, { title: "Delete user?", direction: "column", icon: "trash-can", iconColor: "red", children: _jsxs(Stack, { hAlign: "center", children: [_jsx(Text, { size: 16, children: "Are you sure you want to delete this user?" }), _jsx(Text, { size: 16, children: "This action cannot be undone." })] }) })),
149
+ hideFooterBorder: true,
150
+ primaryAction: _jsx(Button, { children: "Delete" }),
151
+ secondaryAction: _jsx(Button, { children: "Cancel" }),
152
+ alignContentCenter: true,
153
+ };
154
+ const CustomTemplate = (args) => {
155
+ const [isVisible, setIsVisible] = useState(false);
156
+ return (_jsxs(ResponsiveProvider, { children: [_jsx(Button, { onClick: () => setIsVisible(true), children: "Show Modal" }), _jsxs(Modal, { ...args, isVisible: isVisible, onCloseModal: () => setIsVisible(false), children: [_jsxs(Modal.Header, { children: [_jsx("p", { children: "custom header content here" }), _jsx("p", { children: "custom header content here" }), _jsx("p", { children: "custom header content here" })] }), _jsx(Modal.Content, { children: longText }), _jsxs(Modal.Footer, { children: [_jsx("p", { children: "custom footer content here" }), _jsx("p", { children: "custom footer content here" }), _jsx("p", { children: "custom footer content here" })] })] })] }));
21
157
  };
22
- const CustomTemplate = args => (_jsx(ModalShell, { ...args, children: _jsx(CustomContentModal, {}) }));
23
158
  export const Custom = CustomTemplate.bind({});
@@ -0,0 +1,2 @@
1
+ import '@testing-library/jest-dom';
2
+ //# sourceMappingURL=modal.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modal.test.d.ts","sourceRoot":"","sources":["../../../src/components/modal/modal.test.tsx"],"names":[],"mappings":"AACA,OAAO,2BAA2B,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /* eslint-disable @typescript-eslint/no-unused-vars */
3
+ import '@testing-library/jest-dom';
4
+ import { render, screen } from '@testing-library/react';
5
+ import { useState } from 'react';
6
+ import { Button } from '../..';
7
+ import { ResponsiveProvider } from '../../providers';
8
+ import { ModalContent } from './content/modal-content';
9
+ import { ModalFooter } from './footer/modal-footer';
10
+ import { Modal } from './modal';
11
+ const ModalTemplate = () => {
12
+ const [isVisible, setIsVisible] = useState(true);
13
+ return (_jsxs(ResponsiveProvider, { children: [_jsx(Button, { onClick: () => setIsVisible(true), children: "Show Modal" }), _jsx(Modal, { isVisible: isVisible, onCloseModal: () => setIsVisible(false), content: _jsx("p", { children: "Modal content" }), primaryAction: _jsx(Button, { onClick: () => setIsVisible(false), children: "OK" }) })] }));
14
+ };
15
+ // describe('<Modal>', () => {
16
+ // test('it should render properly', () => {
17
+ // const { result } = renderHook(() => useResponsiveContext());
18
+ // const { container } = render(<ModalTemplate />);
19
+ // expect(result).toBeDefined();
20
+ // expect(container).toBeDefined();
21
+ // });
22
+ // test('it should render properly with children', () => {
23
+ // const { container } = render(
24
+ // <Modal
25
+ // isVisible
26
+ // onCloseModal={() => ({})}
27
+ // >
28
+ // <ModalHeader>test</ModalHeader>
29
+ // <ModalContent>test</ModalContent>
30
+ // <ModalFooter>test</ModalFooter>
31
+ // </Modal>,
32
+ // );
33
+ // expect(container).toBeDefined();
34
+ // });
35
+ // });
36
+ describe('<Modal.Header>', () => {
37
+ test.todo('it should render properly');
38
+ // ,() => {
39
+ // const { container } = render(<ModalHeader>test</ModalHeader>);
40
+ // const t = screen.getByText(/test/i);
41
+ // expect(t).toHaveTextContent('test');
42
+ // expect(container).toBeDefined();
43
+ // }
44
+ });
45
+ describe('<Modal.Content>', () => {
46
+ test('it should render properly', () => {
47
+ const { container } = render(_jsx(ModalContent, { children: "test" }));
48
+ const t = screen.getByText(/test/i);
49
+ expect(t).toHaveTextContent('test');
50
+ expect(container).toBeDefined();
51
+ });
52
+ });
53
+ describe('<Modal.Footer>', () => {
54
+ test('it should render properly', () => {
55
+ const { container } = render(_jsx(ModalFooter, { children: "test" }));
56
+ const t = screen.getByText(/test/i);
57
+ expect(t).toHaveTextContent('test');
58
+ expect(container).toBeDefined();
59
+ });
60
+ });
@@ -0,0 +1,2 @@
1
+ import '@testing-library/jest-dom';
2
+ //# sourceMappingURL=overlay-container.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlay-container.test.d.ts","sourceRoot":"","sources":["../../../src/components/overlay-container/overlay-container.test.tsx"],"names":[],"mappings":"AACA,OAAO,2BAA2B,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /* eslint-disable no-console */
3
+ import '@testing-library/jest-dom';
4
+ import { render, screen, waitFor } from '@testing-library/react';
5
+ import { OverlayContainer } from './overlay-container';
6
+ describe('<OverlayContainer>', () => {
7
+ test('it should be defined', () => expect(OverlayContainer).toBeDefined());
8
+ test('it should render children properly', async () => {
9
+ try {
10
+ await waitFor(() => expect(_jsx(OverlayContainer, { children: "test" })).toBeDefined());
11
+ await screen.findByText('test');
12
+ const { baseElement } = render(_jsx(OverlayContainer, { children: "test" }));
13
+ await waitFor(() => expect(baseElement).toMatchSnapshot());
14
+ }
15
+ catch (error) {
16
+ console.error(error);
17
+ }
18
+ });
19
+ });
@@ -1,19 +1,4 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- /*
3
- * Copyright 2023 Wonderflow Design Team
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
2
  import { fireEvent, render } from '@testing-library/react';
18
3
  import { Pagination } from './pagination';
19
4
  describe('<Pagination>', () => {
@@ -46,6 +46,10 @@ export declare type PopoverProps = {
46
46
  * Set the popover element the same with of the trigger element.
47
47
  */
48
48
  matchTriggerWidth?: boolean;
49
+ /**
50
+ * Set the root element to render the Popover into.
51
+ */
52
+ root?: HTMLElement;
49
53
  };
50
54
  export declare const Popover: import("react").ForwardRefExoticComponent<{
51
55
  style?: Record<string, any> | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../../src/components/popover/popover.tsx"],"names":[],"mappings":"AAgBA,OAAO,EACL,aAAa,EAAE,aAAa,EAAY,kBAAkB,EAC3D,MAAM,gBAAgB,CAAC;AAOxB,OAAO,EAML,SAAS,EAKV,MAAM,OAAO,CAAC;AASf,oBAAY,YAAY,GAAG;IACzB;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,aAAa,GAAG,aAAa,GAAG,kBAAkB,CAAC;IAC/D;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAA;AA0BD,eAAO,MAAM,OAAO;;;iEA+HlB,CAAC"}
1
+ {"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../../src/components/popover/popover.tsx"],"names":[],"mappings":"AAgBA,OAAO,EACL,aAAa,EAAE,aAAa,EAAY,kBAAkB,EAC3D,MAAM,gBAAgB,CAAC;AAOxB,OAAO,EAML,SAAS,EAKV,MAAM,OAAO,CAAC;AAQf,oBAAY,YAAY,GAAG;IACzB;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,aAAa,GAAG,aAAa,GAAG,kBAAkB,CAAC;IAC/D;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB,CAAA;AA0BD,eAAO,MAAM,OAAO;;;iEAgIlB,CAAC"}
@@ -8,7 +8,6 @@ import { createPortal } from 'react-dom';
8
8
  import { mergeRefs } from 'react-merge-refs';
9
9
  import { usePopperTooltip } from 'react-popper-tooltip';
10
10
  import { useUIDSeed } from 'react-uid';
11
- import { usePopUpWrapper } from '../../hooks';
12
11
  import * as styles from './popover.module.css';
13
12
  const cssEasingToArray = (cssEasing) => {
14
13
  const [x1, y1, x2, y2] = cssEasing.replace(/[^0-9.,]+/g, '').split(',').map(i => parseFloat(i));
@@ -32,11 +31,10 @@ const PopoverAnimation = {
32
31
  },
33
32
  },
34
33
  };
35
- export const Popover = forwardRef(({ children, trigger, offset = 8, placement = 'auto-start', open, disabled, closeOnOutsideClick = true, className, matchTriggerWidth, onOpenChange, ...otherProps }, forwardedRef) => {
34
+ export const Popover = forwardRef(({ children, trigger, offset = 8, placement = 'auto-start', open, disabled, closeOnOutsideClick = true, className, matchTriggerWidth, onOpenChange, root, ...otherProps }, forwardedRef) => {
36
35
  const seedID = useUIDSeed();
37
36
  const [isOpen, setIsOpen] = useState(false);
38
37
  const popoverContainerRef = useRef(null);
39
- const { wrapper } = usePopUpWrapper('popover-popup-root');
40
38
  const sameWidth = useMemo(() => ({
41
39
  name: 'sameWidth',
42
40
  enabled: true,
@@ -54,7 +52,7 @@ export const Popover = forwardRef(({ children, trigger, offset = 8, placement =
54
52
  s.elements.popper.style.width = `${referenceElement.offsetWidth ?? 0}px`;
55
53
  },
56
54
  }), [matchTriggerWidth]);
57
- const { getTooltipProps, setTooltipRef, setTriggerRef,
55
+ const { getTooltipProps, setTooltipRef, setTriggerRef, tooltipRef,
58
56
  // eslint-disable-next-line @typescript-eslint/naming-convention
59
57
  visible, } = usePopperTooltip({
60
58
  delayShow: 0,
@@ -79,10 +77,10 @@ export const Popover = forwardRef(({ children, trigger, offset = 8, placement =
79
77
  },
80
78
  ],
81
79
  });
82
- const isFocusWithin = useFocusWithin(document.getElementById(seedID('tooltip-content')), {
83
- onBlur: (e) => {
80
+ const isFocusWithin = useFocusWithin(tooltipRef, {
81
+ onFocus: (e) => {
84
82
  if (e.relatedTarget && visible) {
85
- setIsOpen(false);
83
+ setIsOpen(true);
86
84
  }
87
85
  },
88
86
  });
@@ -102,6 +100,6 @@ export const Popover = forwardRef(({ children, trigger, offset = 8, placement =
102
100
  }), visible && createPortal(_jsx(AnimatePresence, { children: _jsx("div", { ref: setTooltipRef, role: "tooltip", id: seedID('tooltip-content'), ...getTooltipProps({ className: styles.PopUp }), children: _jsx(LazyMotion, { features: domMax, children: _jsx(m.div, { variants: PopoverAnimation, initial: "hidden", animate: "visible", exit: "hidden", children: Children.map(children, child => isValidElement(child) && cloneElement(child, {
103
101
  id: seedID('popover-dialog'),
104
102
  'aria-labelledby': seedID('popover-trigger'),
105
- })) }) }) }, seedID('tooltip-content')) }), wrapper)] }));
103
+ })) }) }) }, seedID('tooltip-content')) }), root ?? document.body)] }));
106
104
  });
107
105
  Popover.displayName = 'Popover';
@@ -1 +1 @@
1
- @layer components{.Popover{display:contents}.PopUp{inline-size:max-content;z-index:2}}
1
+ @layer components{.Popover{display:contents}.PopUp{inline-size:max-content;z-index:5}}