@wonderflow/react-components 3.0.0-next.7 → 3.0.1-beta.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 (195) hide show
  1. package/autocomplete/autocomplete-option.d.ts +39 -0
  2. package/autocomplete/autocomplete-option.js +11 -0
  3. package/autocomplete/autocomplete.d.ts +24 -0
  4. package/autocomplete/autocomplete.js +82 -0
  5. package/autocomplete/autocomplete.module.css +1 -0
  6. package/autocomplete/index.d.ts +2 -0
  7. package/autocomplete/index.js +1 -0
  8. package/avatar/avatar.d.ts +15 -3
  9. package/avatar/avatar.js +3 -6
  10. package/avatar/avatar.module.css +1 -31
  11. package/button/button.d.ts +35 -0
  12. package/button/button.js +7 -10
  13. package/button/button.module.css +1 -154
  14. package/card/card.d.ts +24 -0
  15. package/card/card.js +3 -6
  16. package/card/card.module.css +1 -51
  17. package/chip/chip.d.ts +28 -4
  18. package/chip/chip.js +3 -5
  19. package/chip/chip.module.css +1 -60
  20. package/circular-progress/circular-progress.d.ts +33 -3
  21. package/circular-progress/circular-progress.js +3 -2
  22. package/circular-progress/circular-progress.module.css +1 -55
  23. package/clamp-text/clamp-text.d.ts +6 -0
  24. package/clamp-text/clamp-text.js +3 -2
  25. package/clamp-text/clamp-text.module.css +1 -7
  26. package/container/container.d.ts +6 -0
  27. package/container/container.js +3 -2
  28. package/container/container.module.css +1 -35
  29. package/core/basic.css +1 -49
  30. package/core/elevations.css +1 -56
  31. package/core/typography.css +1 -117
  32. package/core/{media.css → utils/media.css} +19 -1
  33. package/core/utils/vibrancy.css +3 -0
  34. package/core.css +1 -5
  35. package/datetime/datetime.d.ts +7 -0
  36. package/datetime/datetime.js +16 -0
  37. package/datetime/index.d.ts +2 -0
  38. package/datetime/index.js +1 -0
  39. package/disclosure/disclosure.d.ts +55 -3
  40. package/disclosure/disclosure.js +4 -7
  41. package/disclosure/disclosure.module.css +1 -93
  42. package/drawer/drawer.d.ts +85 -0
  43. package/drawer/drawer.js +34 -0
  44. package/drawer/drawer.module.css +1 -0
  45. package/drawer/index.d.ts +2 -0
  46. package/drawer/index.js +1 -0
  47. package/dropdown/dropdown.d.ts +43 -10
  48. package/dropdown/dropdown.js +45 -34
  49. package/dropdown/dropdown.module.css +1 -9
  50. package/dropdown/index.d.ts +0 -1
  51. package/elevator/elevator.d.ts +11 -0
  52. package/elevator/elevator.js +6 -5
  53. package/grid/grid.d.ts +32 -2
  54. package/grid/grid.js +4 -3
  55. package/grid/grid.module.css +1 -29
  56. package/grid/index.d.ts +1 -1
  57. package/grid/item/grid-item.d.ts +41 -0
  58. package/grid/item/grid-item.js +12 -0
  59. package/grid/item/grid-item.module.css +1 -0
  60. package/icon/icon.d.ts +30 -4
  61. package/icon/icon.js +3 -3
  62. package/icon-button/icon-button.js +3 -2
  63. package/icon-button/icon-button.module.css +1 -22
  64. package/index.d.ts +86 -40
  65. package/index.js +6 -3
  66. package/info-state/info-state.d.ts +50 -6
  67. package/info-state/info-state.js +3 -9
  68. package/info-state/info-state.module.css +1 -77
  69. package/input-group/input-group.d.ts +33 -3
  70. package/input-group/input-group.js +11 -15
  71. package/input-group/input-group.module.css +1 -33
  72. package/linear-progress/linear-progress.d.ts +33 -3
  73. package/linear-progress/linear-progress.js +6 -7
  74. package/linear-progress/linear-progress.module.css +1 -81
  75. package/list/list.d.ts +13 -0
  76. package/list/list.js +4 -5
  77. package/list/list.module.css +1 -55
  78. package/masonry/masonry.d.ts +22 -0
  79. package/masonry/masonry.js +5 -4
  80. package/masonry/masonry.module.css +1 -14
  81. package/menu/index.d.ts +6 -0
  82. package/menu/index.js +3 -0
  83. package/menu/menu-item/menu-item-checkbox.d.ts +11 -0
  84. package/menu/menu-item/menu-item-checkbox.js +5 -0
  85. package/menu/menu-item/menu-item.d.ts +60 -0
  86. package/menu/menu-item/menu-item.js +23 -0
  87. package/menu/menu-item/menu-item.module.css +1 -0
  88. package/menu/menu.d.ts +16 -0
  89. package/menu/menu.js +15 -0
  90. package/menu/menu.module.css +1 -0
  91. package/modal/content/modal-content.d.ts +19 -3
  92. package/modal/content/modal-content.js +6 -9
  93. package/modal/content/modal-content.module.css +1 -40
  94. package/modal/index.d.ts +0 -1
  95. package/modal/index.js +0 -1
  96. package/modal/modal.d.ts +6 -3
  97. package/modal/modal.js +25 -11
  98. package/modal/modal.module.css +1 -48
  99. package/overlay-container/index.d.ts +1 -0
  100. package/overlay-container/index.js +1 -0
  101. package/overlay-container/overlay-container.d.ts +28 -1
  102. package/overlay-container/overlay-container.js +9 -5
  103. package/overlay-container/overlay-container.module.css +1 -0
  104. package/overlay-container/overlay-context.d.ts +9 -0
  105. package/overlay-container/overlay-context.js +23 -0
  106. package/package.json +88 -38
  107. package/pagination/pagination.d.ts +26 -2
  108. package/pagination/pagination.js +5 -4
  109. package/pagination/pagination.module.css +1 -31
  110. package/polymorphic/polymorphic.d.ts +26 -1
  111. package/prose/prose.js +3 -2
  112. package/prose/prose.module.css +1 -23
  113. package/select/select.d.ts +45 -3
  114. package/select/select.js +4 -7
  115. package/select/select.module.css +1 -108
  116. package/selection-controls/checkbox.d.ts +31 -3
  117. package/selection-controls/checkbox.js +3 -2
  118. package/selection-controls/radio.d.ts +23 -3
  119. package/selection-controls/radio.js +3 -2
  120. package/selection-controls/selection-controls.module.css +1 -119
  121. package/selection-controls/toggle.d.ts +23 -3
  122. package/selection-controls/toggle.js +3 -2
  123. package/separator/separator.d.ts +2 -2
  124. package/separator/separator.js +3 -2
  125. package/separator/separator.module.css +1 -6
  126. package/skeleton-block/skeleton-block.d.ts +4 -0
  127. package/skeleton-block/skeleton-block.js +2 -2
  128. package/slider/slider.d.ts +65 -3
  129. package/slider/slider.js +3 -7
  130. package/slider/slider.module.css +1 -101
  131. package/snackbar/snackbar.d.ts +28 -2
  132. package/snackbar/snackbar.js +4 -11
  133. package/snackbar/snackbar.module.css +1 -46
  134. package/spinner/spinner.d.ts +15 -3
  135. package/spinner/spinner.js +4 -7
  136. package/split-button/split-button.d.ts +4 -2
  137. package/split-button/split-button.js +4 -5
  138. package/split-button/split-button.module.css +1 -28
  139. package/stack/stack.d.ts +35 -1
  140. package/stack/stack.js +3 -2
  141. package/stack/stack.module.css +1 -27
  142. package/star-meter/star-meter.d.ts +25 -0
  143. package/star-meter/star-meter.js +9 -16
  144. package/star-meter/star-meter.module.css +1 -30
  145. package/tab/primitive-tab.d.ts +1 -1
  146. package/tab/primitive-tab.js +3 -3
  147. package/tab/tab-item.d.ts +17 -3
  148. package/tab/tab-item.js +3 -4
  149. package/tab/tab-list.d.ts +6 -2
  150. package/tab/tab-list.js +3 -3
  151. package/tab/tab-panel.d.ts +25 -3
  152. package/tab/tab-panel.js +3 -2
  153. package/tab/tab.d.ts +18 -1
  154. package/tab/tab.js +6 -8
  155. package/tab/tab.module.css +1 -103
  156. package/table/index.d.ts +1 -0
  157. package/table/table.d.ts +14 -1
  158. package/table/table.js +7 -9
  159. package/table/table.module.css +1 -28
  160. package/text/text.d.ts +31 -0
  161. package/text/text.js +4 -3
  162. package/text/text.module.css +1 -87
  163. package/textfield/base-field/base-field.d.ts +10 -1
  164. package/textfield/base-field/base-field.js +3 -2
  165. package/textfield/base-field/base-field.module.css +1 -119
  166. package/textfield/textfield.d.ts +76 -6
  167. package/textfield/textfield.js +10 -13
  168. package/textfield/textfield.module.css +1 -103
  169. package/themes/dark.css +1 -1
  170. package/themes/light.css +1 -1
  171. package/themes.css +1 -143
  172. package/title/title.d.ts +20 -0
  173. package/title/title.js +3 -2
  174. package/title/title.module.css +1 -110
  175. package/toggle-button/toggle-button.d.ts +10 -0
  176. package/toggle-button/toggle-button.js +6 -5
  177. package/toggle-button/toggle-button.module.css +1 -51
  178. package/tooltip/tooltip.d.ts +33 -1
  179. package/tooltip/tooltip.js +24 -27
  180. package/tooltip/tooltip.module.css +1 -72
  181. package/core/vibrancy.css +0 -27
  182. package/dropdown/dropdown-item.d.ts +0 -21
  183. package/dropdown/dropdown-item.js +0 -26
  184. package/dropdown/dropdown-item.module.css +0 -63
  185. package/dropdown/dropdown-menu.d.ts +0 -7
  186. package/dropdown/dropdown-menu.js +0 -17
  187. package/dropdown/dropdown-menu.module.css +0 -13
  188. package/grid/grid-item.d.ts +0 -11
  189. package/grid/grid-item.js +0 -11
  190. package/modal/modal-context.d.ts +0 -9
  191. package/modal/modal-context.js +0 -22
  192. package/theme-switch/index.d.ts +0 -2
  193. package/theme-switch/index.js +0 -1
  194. package/theme-switch/theme-switch.d.ts +0 -9
  195. package/theme-switch/theme-switch.js +0 -14
@@ -1,19 +1,71 @@
1
- import React, { DetailsHTMLAttributes, ReactNode } from 'react';
1
+ import { DetailsHTMLAttributes, ReactNode } from 'react';
2
2
  export declare type DisclosureProps = DetailsHTMLAttributes<HTMLDetailsElement> & {
3
+ /**
4
+ * Set the initial state of the disclosure.
5
+ */
3
6
  open?: boolean;
7
+ /**
8
+ * Define the text to be displayed as the summary of the disclosure.
9
+ * This should generally be a short sentenc and related to the content
10
+ */
4
11
  summary: ReactNode;
12
+ /**
13
+ * Remove or add a padding to align the content with the icon indicator.
14
+ * This is useful when the content inside starts with text and you want to align it
15
+ * summary to improve readability.
16
+ */
5
17
  padding?: boolean;
18
+ /**
19
+ * Set the max height of the content after which the scrollbar will appear.
20
+ */
6
21
  contentMaxHeight?: string;
22
+ /**
23
+ * Set the dimension of the summary toggle
24
+ */
7
25
  dimension?: 'small' | 'regular' | 'big';
26
+ /**
27
+ * Set the position of the icon indicator. The content padding is automatically
28
+ * applied based on the icon position.
29
+ */
8
30
  iconPosition?: 'left' | 'right';
31
+ /**
32
+ * Set or disable the interactivity of the summary toggle.
33
+ * Eg. If `open` is set to `true` the content can't be toggled.
34
+ */
9
35
  expandable?: boolean;
10
36
  };
11
- export declare const Disclosure: React.ForwardRefExoticComponent<React.DetailsHTMLAttributes<HTMLDetailsElement> & {
37
+ export declare const Disclosure: import("react").ForwardRefExoticComponent<DetailsHTMLAttributes<HTMLDetailsElement> & {
38
+ /**
39
+ * Set the initial state of the disclosure.
40
+ */
12
41
  open?: boolean | undefined;
42
+ /**
43
+ * Define the text to be displayed as the summary of the disclosure.
44
+ * This should generally be a short sentenc and related to the content
45
+ */
13
46
  summary: ReactNode;
47
+ /**
48
+ * Remove or add a padding to align the content with the icon indicator.
49
+ * This is useful when the content inside starts with text and you want to align it
50
+ * summary to improve readability.
51
+ */
14
52
  padding?: boolean | undefined;
53
+ /**
54
+ * Set the max height of the content after which the scrollbar will appear.
55
+ */
15
56
  contentMaxHeight?: string | undefined;
57
+ /**
58
+ * Set the dimension of the summary toggle
59
+ */
16
60
  dimension?: "big" | "small" | "regular" | undefined;
61
+ /**
62
+ * Set the position of the icon indicator. The content padding is automatically
63
+ * applied based on the icon position.
64
+ */
17
65
  iconPosition?: "left" | "right" | undefined;
66
+ /**
67
+ * Set or disable the interactivity of the summary toggle.
68
+ * Eg. If `open` is set to `true` the content can't be toggled.
69
+ */
18
70
  expandable?: boolean | undefined;
19
- } & React.RefAttributes<HTMLDetailsElement>>;
71
+ } & import("react").RefAttributes<HTMLDetailsElement>>;
@@ -1,4 +1,5 @@
1
- import React, { forwardRef, useCallback, useState } from 'react';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useCallback, useState } from 'react';
2
3
  import clsx from 'clsx';
3
4
  import { Disclosure as DisclosureClass, Summary, ExpandIcon, Content } from './disclosure.module.css';
4
5
  import { Text, Icon } from '../';
@@ -23,11 +24,7 @@ export const Disclosure = forwardRef(({ children, open = false, padding = true,
23
24
  summary: 22
24
25
  }
25
26
  };
26
- const renderContent = useCallback(() => (React.createElement(motion.div, { className: Content, "data-disclosure-padding": padding, "data-disclosure-height": Boolean(contentMaxHeight), animate: isOpen ? { y: 5, opacity: 1 } : { y: 0, opacity: 0 }, transition: { ease: 'easeOut', duration: 0.1 }, initial: false }, children)), [children, contentMaxHeight, isOpen, padding]);
27
- return (React.createElement("details", { style: { ...dynamicStyle, ...style }, className: clsx(DisclosureClass, className), "data-disclosure-icon-position": iconPosition, "data-disclosure-dimension": dimension, "data-disclosure-expandable": expandable, "aria-expanded": isOpen ? 'true' : 'false', open: isOpen, ref: forwardedRef, ...otherProps },
28
- React.createElement(Text, { as: "summary", onClick: handleOpen(), className: Summary, "aria-expanded": isOpen, tabIndex: !expandable ? -1 : 0, size: dimension ? sizes[dimension].summary : undefined, weight: "bold" },
29
- summary,
30
- expandable && (React.createElement(Icon, { className: ExpandIcon, name: "chevron-right", dimension: dimension !== 'big' ? 16 : 24 }))),
31
- renderContent()));
27
+ const renderContent = useCallback(() => (_jsx(motion.div, { className: Content, "data-disclosure-padding": padding, "data-disclosure-height": Boolean(contentMaxHeight), animate: isOpen ? { y: 5, opacity: 1 } : { y: 0, opacity: 0 }, transition: { ease: 'easeOut', duration: 0.1 }, initial: false, children: children }, void 0)), [children, contentMaxHeight, isOpen, padding]);
28
+ return (_jsxs("details", { style: { ...dynamicStyle, ...style }, className: clsx(DisclosureClass, className), "data-disclosure-icon-position": iconPosition, "data-disclosure-dimension": dimension, "data-disclosure-expandable": expandable, "aria-expanded": isOpen ? 'true' : 'false', open: isOpen, ref: forwardedRef, ...otherProps, children: [_jsxs(Text, { as: "summary", onClick: handleOpen(), responsive: false, className: Summary, "aria-expanded": isOpen, tabIndex: !expandable ? -1 : 0, size: dimension ? sizes[dimension].summary : undefined, weight: "bold", children: [summary, expandable && (_jsx(Icon, { className: ExpandIcon, name: "chevron-right", dimension: dimension !== 'big' ? 16 : 24 }, void 0))] }, void 0), renderContent()] }, void 0));
32
29
  });
33
30
  Disclosure.displayName = 'Disclosure';
@@ -1,93 +1 @@
1
- .Disclosure {
2
- --icon-size: 1.11rem;
3
- --icon-padding: env(--space-8);
4
- --padding: calc(var(--icon-size) + var(--icon-padding) + (var(--icon-size) / 2));
5
-
6
- display: block;
7
- position: relative;
8
- transform: translateZ(0);
9
- z-index: 0;
10
-
11
- & * {
12
- box-sizing: border-box;
13
- }
14
-
15
- &[data-disclosure-dimension='small'] {
16
- --icon-size: env(--space-16);
17
- }
18
-
19
- &[data-disclosure-dimension='regular'] {
20
- --icon-size: 1.11rem;
21
- }
22
-
23
- &[data-disclosure-dimension='big'] {
24
- --icon-size: env(--space-24);
25
- --icon-padding: env(--space-16);
26
- }
27
- }
28
-
29
- .Summary {
30
- display: list-item;
31
- touch-action: manipulation;
32
- position: relative;
33
- padding: env(--space-2) 0;
34
- outline-offset: -2px;
35
- user-select: none;
36
-
37
- @nest .Disclosure[data-disclosure-icon-position='right'][data-disclosure-expandable='true'] & {
38
- padding-inline-end: var(--padding);
39
- }
40
- @nest .Disclosure[data-disclosure-icon-position='left'][data-disclosure-expandable='true'] & {
41
- padding-inline-start: var(--padding);
42
- }
43
- @nest .Disclosure[data-disclosure-expandable='true'] & {
44
- cursor: pointer;
45
- }
46
-
47
- &::marker {
48
- content: '';
49
- }
50
-
51
- &::-webkit-details-marker {
52
- display: none;
53
- }
54
- }
55
-
56
- .ExpandIcon {
57
- content: '';
58
- transform-box: fill-box;
59
- position: absolute;
60
- top: calc(var(--icon-size) / 4);
61
- right: calc(var(--icon-size) / 2);
62
- inline-size: var(--icon-size);
63
- block-size: var(--icon-size);
64
- transition: transform env(--duration-100) env(--easing-standard);
65
- transform-origin: 50% center;
66
-
67
- @nest .Disclosure[data-disclosure-icon-position='left'] & {
68
- left: calc(var(--icon-size) / 2);
69
- right: auto;
70
- }
71
- @nest .Disclosure[open] & {
72
- transform: rotate(90deg);
73
- }
74
- }
75
-
76
-
77
- .Content {
78
- box-sizing: border-box;
79
-
80
- @nest .Disclosure[data-disclosure-icon-position='left'] &[data-disclosure-padding='true'] {
81
- padding-inline-start: var(--padding);
82
- }
83
- @nest .Disclosure[data-disclosure-icon-position='right'] &[data-disclosure-padding='true'] {
84
- padding-right: var(--padding);
85
- }
86
-
87
- &[data-disclosure-height='true'] {
88
- -webkit-overflow-scrolling: touch;
89
- overscroll-behavior: contain;
90
- max-block-size: var(--maxHeight);
91
- overflow: auto;
92
- }
93
- }
1
+ .Disclosure{--icon-size:1.11rem;--icon-padding:0.44rem;--padding:calc(var(--icon-size) + var(--icon-padding) + var(--icon-size)/2);display:block;position:relative;transform:translateZ(0);z-index:0}.Disclosure *{box-sizing:border-box}.Disclosure[data-disclosure-dimension=small]{--icon-size:0.89rem}.Disclosure[data-disclosure-dimension=regular]{--icon-size:1.11rem}.Disclosure[data-disclosure-dimension=big]{--icon-size:1.33rem;--icon-padding:0.89rem}.Summary{display:list-item;outline-offset:-2px;padding:.11rem 0;position:relative;touch-action:manipulation;-webkit-user-select:none;user-select:none}.Disclosure[data-disclosure-icon-position=right][data-disclosure-expandable=true] .Summary{padding-inline-end:var(--padding)}.Disclosure[data-disclosure-icon-position=left][data-disclosure-expandable=true] .Summary{padding-inline-start:var(--padding)}.Disclosure[data-disclosure-expandable=true] .Summary{cursor:pointer}.Summary::marker{content:""}.Summary::-webkit-details-marker{display:none}.ExpandIcon{block-size:var(--icon-size);content:"";inline-size:var(--icon-size);position:absolute;right:calc(var(--icon-size)/2);top:calc(var(--icon-size)/4);transform-box:fill-box;transform-origin:50% center;transition:transform .1s cubic-bezier(.3,.07,.34,1)}.Disclosure[data-disclosure-icon-position=left] .ExpandIcon{left:calc(var(--icon-size)/2);right:auto}.Disclosure[open] .ExpandIcon{transform:rotate(90deg)}.Content{box-sizing:border-box}.Disclosure[data-disclosure-icon-position=left] .Content[data-disclosure-padding=true]{padding-inline-start:var(--padding)}.Disclosure[data-disclosure-icon-position=right] .Content[data-disclosure-padding=true]{padding-right:var(--padding)}.Content[data-disclosure-height=true]{-webkit-overflow-scrolling:touch;max-block-size:var(--maxHeight);overflow:auto;overscroll-behavior:contain}
@@ -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,17 +1,50 @@
1
- import { ReactNode, ForwardRefExoticComponent } from 'react';
2
- import { DropdownMenuProps } from './dropdown-menu';
3
- import { DropdownItemProps, DropdownItemCheckboxProps } from './dropdown-item';
1
+ import { ReactNode } from 'react';
4
2
  import { AutoPlacement, BasePlacement, VariationPlacement } from '@popperjs/core';
5
3
  export declare type DropdownProps = PropsWithClass & {
4
+ /**
5
+ * The content of the dropdown to display when the dropdown is open.
6
+ */
6
7
  children: ReactNode;
8
+ /**
9
+ * The element to use as the trigger for the dropdown.
10
+ */
7
11
  trigger: ReactNode;
12
+ /**
13
+ * The distance from the trigger to the dropdown.
14
+ */
8
15
  offset?: number;
16
+ /**
17
+ * The placement of the dropdown. This is automatically handled based on
18
+ * scroll and viewport edges. By default the dropdown is anchored at
19
+ * the beginning of the trigger.
20
+ *
21
+ * The first key refers to the X axis, the second key refers to the Y axis.
22
+ * Eg: `auto-start` means the dropdown will be placed automatically on left or right
23
+ * based on the available space, and anchored at the top (start) of the trigger.
24
+ */
9
25
  placement?: AutoPlacement | BasePlacement | VariationPlacement;
10
26
  };
11
- declare type DropdownComponent = ForwardRefExoticComponent<DropdownProps> & {
12
- Menu: ForwardRefExoticComponent<DropdownMenuProps>;
13
- Item: ForwardRefExoticComponent<DropdownItemProps>;
14
- ItemCheckbox: ForwardRefExoticComponent<DropdownItemCheckboxProps>;
15
- };
16
- export declare const Dropdown: DropdownComponent;
17
- export {};
27
+ export declare const Dropdown: import("react").ForwardRefExoticComponent<PropsWithClass & {
28
+ /**
29
+ * The content of the dropdown to display when the dropdown is open.
30
+ */
31
+ children: ReactNode;
32
+ /**
33
+ * The element to use as the trigger for the dropdown.
34
+ */
35
+ trigger: ReactNode;
36
+ /**
37
+ * The distance from the trigger to the dropdown.
38
+ */
39
+ offset?: number | undefined;
40
+ /**
41
+ * The placement of the dropdown. This is automatically handled based on
42
+ * scroll and viewport edges. By default the dropdown is anchored at
43
+ * the beginning of the trigger.
44
+ *
45
+ * The first key refers to the X axis, the second key refers to the Y axis.
46
+ * Eg: `auto-start` means the dropdown will be placed automatically on left or right
47
+ * based on the available space, and anchored at the top (start) of the trigger.
48
+ */
49
+ placement?: AutoPlacement | BasePlacement | VariationPlacement | undefined;
50
+ } & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,53 +1,64 @@
1
- import clsx from 'clsx';
2
- import React, { useState, Children, cloneElement, useRef, forwardRef } from 'react';
3
- import { useKey, useClickAway } from 'react-use';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState, Children, cloneElement, useRef, forwardRef } from 'react';
3
+ import { useKeyPress, useFocusWithin } from 'ahooks';
4
4
  import { Dropdown as DropdownClass, PopUp } from './dropdown.module.css';
5
5
  import { useUIDSeed } from 'react-uid';
6
- import { useFocusWithin } from '@react-aria/interactions';
7
- import { DropdownMenu } from './dropdown-menu';
8
- import { DropdownItem, DropdownItemCheckbox } from './dropdown-item';
9
6
  import { usePopperTooltip } from 'react-popper-tooltip';
10
7
  import { AnimatePresence, motion } from 'framer-motion';
11
- export const Dropdown = forwardRef(({ className, children, trigger, offset = 8, placement = 'auto-start' }, forwardedRef) => {
8
+ import clsx from 'clsx';
9
+ const DropdownAnimation = {
10
+ visible: {
11
+ y: 0,
12
+ opacity: 1,
13
+ transition: {
14
+ ease: [0, 0, 0.34, 1],
15
+ duration: 0.1
16
+ }
17
+ },
18
+ hidden: {
19
+ y: -5,
20
+ opacity: 0,
21
+ transition: {
22
+ ease: [0.3, 0.07, 1, 1],
23
+ duration: 0.1
24
+ }
25
+ }
26
+ };
27
+ export const Dropdown = forwardRef(({ children, trigger, offset = 8, placement = 'auto-start', className, ...otherProps }, forwardedRef) => {
12
28
  const renderedChildren = Children.toArray(children).filter(Boolean);
13
29
  const seedID = useUIDSeed();
14
- const popupRef = useRef(forwardedRef);
30
+ const dropdownRef = useRef(forwardedRef);
15
31
  const [isOpen, setIsOpen] = useState(false);
16
32
  const { getTooltipProps, setTooltipRef, setTriggerRef, visible } = usePopperTooltip({
17
33
  delayShow: 0,
18
- delayHide: 200,
34
+ delayHide: 0,
19
35
  trigger: ['click'],
20
36
  visible: isOpen,
21
37
  closeOnTriggerHidden: true,
22
38
  onVisibleChange: setIsOpen,
23
39
  placement: placement,
24
40
  offset: [0, offset],
25
- closeOnOutsideClick: false
26
- });
27
- useClickAway(popupRef, () => {
28
- setIsOpen(false);
41
+ closeOnOutsideClick: true
29
42
  });
30
- const { focusWithinProps } = useFocusWithin({
31
- onFocusWithin: () => null,
32
- onBlurWithin: (e) => e.relatedTarget && setIsOpen(false),
33
- onFocusWithinChange: () => null
43
+ const isFocusWithin = useFocusWithin(dropdownRef, {
44
+ onBlur: (e) => {
45
+ if (e.relatedTarget && visible) {
46
+ setIsOpen(false);
47
+ }
48
+ }
34
49
  });
35
- useKey('Escape', () => setIsOpen(false));
36
- return (React.createElement("div", { ref: popupRef, className: clsx(DropdownClass, className), ...focusWithinProps },
37
- Children.map(trigger, (child) => cloneElement(child, {
38
- ref: setTriggerRef,
39
- id: seedID('dropdown-trigger'),
40
- 'aria-haspopup': 'true',
41
- 'aria-controls': seedID('dropdown-menu'),
42
- 'aria-expanded': isOpen
43
- })),
44
- React.createElement(AnimatePresence, null, visible && (React.createElement("div", { ref: setTooltipRef, role: "tooltip", id: seedID('tooltip-content'), className: PopUp, ...getTooltipProps({ className: PopUp }) },
45
- React.createElement(motion.div, { animate: visible ? { y: 5, opacity: 1 } : { y: 0, opacity: 0 }, transition: { ease: 'easeOut', duration: 0.1 } }, Children.map(renderedChildren, (child) => cloneElement(child, {
46
- id: seedID('dropdown-menu'),
47
- 'aria-labelledby': seedID('dropdown-trigger')
48
- }))))))));
50
+ useKeyPress('esc', () => setIsOpen(false));
51
+ return (_jsxs("div", { ref: dropdownRef, className: clsx(DropdownClass, className), "data-dropdown-has-focus": isFocusWithin, children: [Children.map(trigger, (child) => cloneElement(child, {
52
+ ref: setTriggerRef,
53
+ id: seedID('dropdown-trigger'),
54
+ key: seedID('dropdown-trigger'),
55
+ 'aria-haspopup': 'true',
56
+ 'aria-controls': seedID('dropdown-menu'),
57
+ 'aria-expanded': isOpen,
58
+ ...otherProps
59
+ })), _jsx(AnimatePresence, { children: visible && (_jsx("div", { ref: setTooltipRef, role: "tooltip", id: seedID('tooltip-content'), ...getTooltipProps({ className: PopUp }), children: _jsx(motion.div, { variants: DropdownAnimation, initial: "hidden", animate: "visible", exit: "hidden", children: Children.map(renderedChildren, (child) => cloneElement(child, {
60
+ id: seedID('dropdown-menu'),
61
+ 'aria-labelledby': seedID('dropdown-trigger')
62
+ })) }, void 0) }, seedID('tooltip-content'))) }, void 0)] }, void 0));
49
63
  });
50
64
  Dropdown.displayName = 'Dropdown';
51
- Dropdown.Menu = DropdownMenu;
52
- Dropdown.Item = DropdownItem;
53
- Dropdown.ItemCheckbox = DropdownItemCheckbox;
@@ -1,9 +1 @@
1
- .Dropdown {
2
- position: relative;
3
- display: inline-flex;
4
- }
5
-
6
- .PopUp {
7
- inline-size: max-content;
8
- z-index: 2;
9
- }
1
+ .Dropdown{display:contents}.PopUp{inline-size:max-content;z-index:2}
@@ -1,3 +1,2 @@
1
1
  export { Dropdown } from './dropdown';
2
2
  export type { DropdownProps } from './dropdown';
3
- export type { DropdownItemProps } from './dropdown-item';
@@ -1,7 +1,18 @@
1
1
  import { FC, ReactElement } from 'react';
2
2
  export declare type ElevatorProps = {
3
+ /**
4
+ * Set the elevation of the component when is resting.
5
+ */
3
6
  resting: 0 | 1 | 2 | 3 | 4;
7
+ /**
8
+ * Set the elevation of the component when is hovered.
9
+ */
4
10
  hover?: 0 | 1 | 2 | 3 | 4;
11
+ /**
12
+ * The content to be elevated.
13
+ * This component doesn't generate any wrapper.
14
+ * It just applies the elevation by adding the respective attribvtes to the children.
15
+ */
5
16
  children: ReactElement;
6
17
  };
7
18
  export declare const Elevator: FC<ElevatorProps>;
@@ -1,7 +1,8 @@
1
- import React, { Fragment, Children, cloneElement } from 'react';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Fragment, Children, cloneElement } from 'react';
2
3
  export const Elevator = ({ children, resting, hover }) => {
3
- return (React.createElement(Fragment, null, Children.map(children, (child) => cloneElement(child, {
4
- 'data-elevation': resting,
5
- 'data-elevation-hover': hover
6
- }))));
4
+ return (_jsx(Fragment, { children: Children.map(children, (child) => cloneElement(child, {
5
+ 'data-elevation': resting,
6
+ 'data-elevation-hover': hover
7
+ })) }, void 0));
7
8
  };
package/grid/grid.d.ts CHANGED
@@ -1,14 +1,44 @@
1
- import React, { ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { TokensTypes } from '@wonderflow/tokens/platforms/web/types';
3
- import { GridItemProps } from './grid-item';
3
+ import { GridItemProps } from './item/grid-item';
4
4
  export declare type GridProps = PropsWithClass & {
5
+ /**
6
+ * The children to be rendered in the grid.
7
+ * Even though this component doesn't block you to use any elements as children,
8
+ * it's recommended to use only `<Grid.Item>` component to generate the grid items.
9
+ */
5
10
  children: ReactNode;
11
+ /**
12
+ * Specify how many columns the grid should have.
13
+ */
6
14
  columns?: number;
15
+ /**
16
+ * Specify how many rows the grid should have.
17
+ */
7
18
  rows?: number;
19
+ /**
20
+ * Add a gap between rows.
21
+ */
8
22
  rowGap?: 0 | TokensTypes['space'];
23
+ /**
24
+ * Add a gap between columns.
25
+ */
9
26
  columnGap?: 0 | TokensTypes['space'];
27
+ /**
28
+ * Set the columns repeating behaviour.
29
+ * This refers to the CSS function `repeat()`, which can use both `auto-fit`
30
+ * and `auto-fill` parameters.
31
+ *
32
+ * Read more: https://developer.mozilla.org/en-US/docs/Web/CSS/repeat
33
+ */
10
34
  filling?: 'fit' | 'fill' | false;
35
+ /**
36
+ * Set the minimum columns width
37
+ */
11
38
  colMinWidth?: string;
39
+ /**
40
+ * Set the minimum rows height
41
+ */
12
42
  rowMinHeight?: string;
13
43
  };
14
44
  declare type GridComponent = React.ForwardRefExoticComponent<GridProps> & {
package/grid/grid.js CHANGED
@@ -1,7 +1,8 @@
1
- import React, { forwardRef } from 'react';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
2
3
  import clsx from 'clsx';
3
4
  import tksn from '@wonderflow/tokens/platforms/web/tokens.json';
4
- import { GridItem } from './grid-item';
5
+ import { GridItem } from './item/grid-item';
5
6
  import { Grid as GridClass } from './grid.module.css';
6
7
  export const Grid = forwardRef(({ className, children, columns, rows, rowGap = 8, columnGap = 8, style, filling = 'fill', colMinWidth = '10rem', rowMinHeight = '1fr', ...otherProps }, forwardedRef) => {
7
8
  const computedStyle = {
@@ -12,7 +13,7 @@ export const Grid = forwardRef(({ className, children, columns, rows, rowGap = 8
12
13
  '--rows': rows,
13
14
  '--row-min-h': rowMinHeight
14
15
  };
15
- return (React.createElement("ul", { className: clsx(GridClass, className), style: { ...computedStyle, ...style }, "data-grid-filling-type": filling, ref: forwardedRef, ...otherProps }, children));
16
+ return (_jsx("ul", { className: clsx(GridClass, className), style: { ...computedStyle, ...style }, "data-grid-filling-type": filling, ref: forwardedRef, ...otherProps, children: children }, void 0));
16
17
  });
17
18
  Grid.displayName = 'Grid';
18
19
  Grid.Item = GridItem;
@@ -1,29 +1 @@
1
- .Grid {
2
- --column-size: minmax(min(var(--column-min-w), 100%), 1fr);
3
-
4
- display: grid;
5
- list-style: none;
6
- margin: 0;
7
- padding: 0;
8
- grid-template-columns: repeat(var(--columns), var(--column-size));
9
- grid-template-rows: repeat(var(--rows), var(--row-min-h));
10
- grid-gap: var(--rGap, env(--space-8)) var(--cGap, env(--space-8));
11
-
12
- &[data-grid-filling-type='fill'] {
13
- grid-template-columns: repeat(auto-fill, var(--column-size));
14
- }
15
-
16
- &[data-grid-filling-type='fit'] {
17
- grid-template-columns: repeat(auto-fit, var(--column-size));
18
- }
19
- }
20
-
21
- .GridItem {
22
- grid-column: var(--column);
23
- grid-row: var(--row);
24
- display: block;
25
-
26
- &[data-grid-item-fullwidth='true'] {
27
- grid-column: 1 / -1;
28
- }
29
- }
1
+ .Grid{--column-size:minmax(min(var(--column-min-w),100%),1fr);grid-gap:var(--rGap,.44rem) var(--cGap,.44rem);display:grid;grid-template-columns:repeat(var(--columns),var(--column-size));grid-template-rows:repeat(var(--rows),var(--row-min-h));list-style:none;margin:0;padding:0}.Grid[data-grid-filling-type=fill]{grid-template-columns:repeat(auto-fill,var(--column-size))}.Grid[data-grid-filling-type=fit]{grid-template-columns:repeat(auto-fit,var(--column-size))}
package/grid/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { Grid } from './grid';
2
2
  export type { GridProps } from './grid';
3
- export type { GridItemProps } from './grid-item';
3
+ export type { GridItemProps } from './item/grid-item';