@wonderflow/react-components 3.0.0-next.9 → 3.0.0

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 (170) 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/button/button.d.ts +35 -0
  11. package/button/button.js +7 -10
  12. package/button/button.module.css +1 -1
  13. package/card/card.d.ts +24 -0
  14. package/card/card.js +3 -6
  15. package/card/card.module.css +1 -1
  16. package/chip/chip.d.ts +28 -4
  17. package/chip/chip.js +3 -5
  18. package/circular-progress/circular-progress.d.ts +33 -3
  19. package/circular-progress/circular-progress.js +3 -2
  20. package/clamp-text/clamp-text.d.ts +6 -0
  21. package/clamp-text/clamp-text.js +3 -2
  22. package/container/container.d.ts +6 -0
  23. package/container/container.js +3 -2
  24. package/core/typography.css +1 -1
  25. package/core/utils/media.css +19 -1
  26. package/core/utils/vibrancy.css +0 -24
  27. package/core.css +1 -1
  28. package/datetime/datetime.d.ts +7 -0
  29. package/datetime/datetime.js +16 -0
  30. package/datetime/index.d.ts +2 -0
  31. package/datetime/index.js +1 -0
  32. package/disclosure/disclosure.d.ts +55 -3
  33. package/disclosure/disclosure.js +4 -7
  34. package/drawer/drawer.d.ts +85 -0
  35. package/drawer/drawer.js +34 -0
  36. package/drawer/drawer.module.css +1 -0
  37. package/drawer/index.d.ts +2 -0
  38. package/drawer/index.js +1 -0
  39. package/dropdown/dropdown.d.ts +43 -10
  40. package/dropdown/dropdown.js +45 -34
  41. package/dropdown/dropdown.module.css +1 -1
  42. package/dropdown/index.d.ts +0 -1
  43. package/elevator/elevator.d.ts +11 -0
  44. package/elevator/elevator.js +6 -5
  45. package/grid/grid.d.ts +32 -2
  46. package/grid/grid.js +4 -3
  47. package/grid/grid.module.css +1 -1
  48. package/grid/index.d.ts +1 -1
  49. package/grid/item/grid-item.d.ts +41 -0
  50. package/grid/item/grid-item.js +12 -0
  51. package/grid/item/grid-item.module.css +1 -0
  52. package/icon/icon.d.ts +30 -4
  53. package/icon/icon.js +3 -3
  54. package/icon-button/icon-button.js +3 -2
  55. package/index.d.ts +86 -40
  56. package/index.js +6 -3
  57. package/info-state/info-state.d.ts +50 -6
  58. package/info-state/info-state.js +3 -9
  59. package/input-group/input-group.d.ts +33 -3
  60. package/input-group/input-group.js +11 -15
  61. package/linear-progress/linear-progress.d.ts +33 -3
  62. package/linear-progress/linear-progress.js +6 -7
  63. package/list/list.d.ts +13 -0
  64. package/list/list.js +4 -5
  65. package/list/list.module.css +1 -1
  66. package/masonry/masonry.d.ts +22 -0
  67. package/masonry/masonry.js +5 -4
  68. package/menu/index.d.ts +6 -0
  69. package/menu/index.js +3 -0
  70. package/menu/menu-item/menu-item-checkbox.d.ts +11 -0
  71. package/menu/menu-item/menu-item-checkbox.js +5 -0
  72. package/menu/menu-item/menu-item.d.ts +60 -0
  73. package/menu/menu-item/menu-item.js +23 -0
  74. package/menu/menu-item/menu-item.module.css +1 -0
  75. package/menu/menu.d.ts +16 -0
  76. package/menu/menu.js +15 -0
  77. package/menu/menu.module.css +1 -0
  78. package/modal/content/modal-content.d.ts +19 -3
  79. package/modal/content/modal-content.js +6 -9
  80. package/modal/content/modal-content.module.css +1 -1
  81. package/modal/index.d.ts +0 -1
  82. package/modal/index.js +0 -1
  83. package/modal/modal.d.ts +6 -3
  84. package/modal/modal.js +25 -11
  85. package/modal/modal.module.css +1 -1
  86. package/overlay-container/index.d.ts +1 -0
  87. package/overlay-container/index.js +1 -0
  88. package/overlay-container/overlay-container.d.ts +27 -1
  89. package/overlay-container/overlay-container.js +9 -5
  90. package/overlay-container/overlay-container.module.css +1 -0
  91. package/overlay-container/overlay-context.d.ts +9 -0
  92. package/overlay-container/overlay-context.js +23 -0
  93. package/package.json +74 -30
  94. package/pagination/pagination.d.ts +26 -2
  95. package/pagination/pagination.js +5 -4
  96. package/polymorphic/polymorphic.d.ts +26 -1
  97. package/prose/prose.js +3 -2
  98. package/select/select.d.ts +45 -3
  99. package/select/select.js +4 -7
  100. package/select/select.module.css +1 -1
  101. package/selection-controls/checkbox.d.ts +31 -3
  102. package/selection-controls/checkbox.js +3 -2
  103. package/selection-controls/radio.d.ts +23 -3
  104. package/selection-controls/radio.js +3 -2
  105. package/selection-controls/selection-controls.module.css +1 -1
  106. package/selection-controls/toggle.d.ts +23 -3
  107. package/selection-controls/toggle.js +3 -2
  108. package/separator/separator.d.ts +2 -2
  109. package/separator/separator.js +3 -2
  110. package/skeleton-block/skeleton-block.d.ts +4 -0
  111. package/skeleton-block/skeleton-block.js +2 -2
  112. package/slider/slider.d.ts +65 -3
  113. package/slider/slider.js +3 -7
  114. package/snackbar/snackbar.d.ts +28 -2
  115. package/snackbar/snackbar.js +4 -11
  116. package/snackbar/snackbar.module.css +1 -1
  117. package/spinner/spinner.d.ts +15 -3
  118. package/spinner/spinner.js +4 -7
  119. package/split-button/split-button.d.ts +4 -2
  120. package/split-button/split-button.js +4 -5
  121. package/split-button/split-button.module.css +1 -1
  122. package/stack/stack.d.ts +35 -1
  123. package/stack/stack.js +3 -2
  124. package/stack/stack.module.css +1 -1
  125. package/star-meter/star-meter.d.ts +25 -0
  126. package/star-meter/star-meter.js +9 -16
  127. package/tab/primitive-tab.d.ts +1 -1
  128. package/tab/primitive-tab.js +3 -3
  129. package/tab/tab-item.d.ts +17 -3
  130. package/tab/tab-item.js +3 -4
  131. package/tab/tab-list.d.ts +6 -2
  132. package/tab/tab-list.js +3 -3
  133. package/tab/tab-panel.d.ts +25 -3
  134. package/tab/tab-panel.js +3 -2
  135. package/tab/tab.d.ts +18 -1
  136. package/tab/tab.js +6 -8
  137. package/table/table.d.ts +13 -0
  138. package/table/table.js +7 -9
  139. package/text/text.d.ts +31 -0
  140. package/text/text.js +4 -3
  141. package/text/text.module.css +1 -1
  142. package/textfield/base-field/base-field.d.ts +10 -1
  143. package/textfield/base-field/base-field.js +3 -2
  144. package/textfield/base-field/base-field.module.css +1 -1
  145. package/textfield/textfield.d.ts +76 -6
  146. package/textfield/textfield.js +10 -13
  147. package/themes/dark.css +1 -1
  148. package/themes/light.css +1 -1
  149. package/title/title.d.ts +20 -0
  150. package/title/title.js +3 -2
  151. package/title/title.module.css +1 -1
  152. package/toggle-button/toggle-button.d.ts +10 -0
  153. package/toggle-button/toggle-button.js +6 -5
  154. package/tooltip/tooltip.d.ts +33 -1
  155. package/tooltip/tooltip.js +24 -27
  156. package/tooltip/tooltip.module.css +1 -1
  157. package/dropdown/dropdown-item.d.ts +0 -21
  158. package/dropdown/dropdown-item.js +0 -26
  159. package/dropdown/dropdown-item.module.css +0 -1
  160. package/dropdown/dropdown-menu.d.ts +0 -7
  161. package/dropdown/dropdown-menu.js +0 -17
  162. package/dropdown/dropdown-menu.module.css +0 -1
  163. package/grid/grid-item.d.ts +0 -11
  164. package/grid/grid-item.js +0 -11
  165. package/modal/modal-context.d.ts +0 -9
  166. package/modal/modal-context.js +0 -22
  167. package/theme-switch/index.d.ts +0 -2
  168. package/theme-switch/index.js +0 -1
  169. package/theme-switch/theme-switch.d.ts +0 -9
  170. package/theme-switch/theme-switch.js +0 -14
@@ -0,0 +1,60 @@
1
+ import { Polymorphic } from '../..';
2
+ import { ReactNode } from 'react';
3
+ import { IconNames } from '../../icons/types';
4
+ export declare type MenuItemProps = {
5
+ /**
6
+ * Content to display in the menu item.
7
+ */
8
+ children: ReactNode;
9
+ /**
10
+ * Whether the menu item should have an icon
11
+ */
12
+ icon?: IconNames;
13
+ /**
14
+ * Set the position of the icon. Used only when icon is defined.
15
+ */
16
+ iconPosition?: 'left' | 'right';
17
+ /**
18
+ * Set the size of the menu item.
19
+ * Font size and icon style will be adjusted to match the size.
20
+ */
21
+ dimension?: 'small' | 'regular';
22
+ /**
23
+ * Callback function to be called when the menu item is pressed.
24
+ */
25
+ onClick?(event?: Event): void;
26
+ /**
27
+ * Add an extra description to the menu item.
28
+ * This uses the `<Tooltip>` component internally.
29
+ */
30
+ description?: ReactNode;
31
+ /**
32
+ * Set disabled state. The item is not interactive and grayed out.
33
+ */
34
+ disabled?: boolean;
35
+ /**
36
+ * Add or remove the padding from the menu item.
37
+ * This space is used to keep the content aligned across items with or without icons.
38
+ * We suggest to not remove the padding if you have items with icons in the same menu to
39
+ * keep a good readability.
40
+ *
41
+ * Read more: https://design.wonderflow.ai/design/recipes/menu/#items-with-icons
42
+ */
43
+ padding?: boolean;
44
+ /**
45
+ * Set item to gain focus automatically when the menu is opened.
46
+ * This property is commonly used on the first item in the menu.
47
+ */
48
+ autoFocus?: boolean;
49
+ /**
50
+ * Add an element to decorate the menu item. This is useful for adding extra elements
51
+ * and informations to the menu item.
52
+ *
53
+ * @note Don't use interactive elements (link, buttons, etc..) as decoration
54
+ * if `Menu.Item` is rendered as ´<button>´ (default).
55
+ */
56
+ decoration?: ReactNode;
57
+ };
58
+ declare type PolymorphicMenuItem = Polymorphic.ForwardRefComponent<'button', MenuItemProps>;
59
+ export declare const MenuItem: PolymorphicMenuItem;
60
+ export {};
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Icon, Stack, Tooltip } from '../..';
3
+ import { Icon as IconClass, ItemContent, MenuItem as MenuItemClass } from './menu-item.module.css';
4
+ import { forwardRef, useCallback, useMemo, useRef } from 'react';
5
+ import { useFocusEffect, useRovingTabIndex } from 'react-roving-tabindex';
6
+ import clsx from 'clsx';
7
+ export const MenuItem = forwardRef(({ className, children, onClick, icon, dimension = 'regular', as: Wrapper = 'button', iconPosition = 'left', description, padding = true, disabled = false, autoFocus, decoration, ...otherProps }, forwardedRef) => {
8
+ const itemRef = useRef(forwardedRef);
9
+ const [tabIndex, focused, handleKeyDown, handleClick] = useRovingTabIndex(itemRef, disabled);
10
+ const isIconRight = iconPosition === 'right';
11
+ useFocusEffect(focused, itemRef);
12
+ const triggerClick = useCallback((e) => {
13
+ if (onClick) {
14
+ handleClick();
15
+ onClick(e);
16
+ }
17
+ }, [handleClick, onClick]);
18
+ const InnerContent = useMemo(() => (_jsxs(Stack, { direction: isIconRight ? 'row-reverse' : 'row', as: "span", className: ItemContent, horizontalAlign: isIconRight ? 'space-between' : 'start', verticalAlign: "center", columnGap: 8, horizontalPadding: 16, verticalPadding: 8, "data-menu-item-icon-right": isIconRight, "data-menu-item-has-icon": Boolean(icon), "data-menu-item-padding": padding, style: { inlineSize: '100%' }, children: [icon && (_jsx(Icon, { className: IconClass, name: icon, dimension: dimension === 'small' ? 14 : 16 }, void 0)), _jsxs(Stack, { columnGap: 16, fill: false, direction: "row", horizontalAlign: "space-between", children: [children, decoration] }, void 0)] }, void 0)), [children, dimension, icon, isIconRight, decoration, padding]);
19
+ return (_jsx(Wrapper, { autoFocus: autoFocus, ref: itemRef, role: "menuitem", className: clsx(MenuItemClass, className), onClick: disabled ? undefined : triggerClick, onKeyDown: disabled ? undefined : handleKeyDown, tabIndex: tabIndex, "aria-disabled": disabled, type: Wrapper === 'button' ? 'button' : undefined, "data-menu-item-dimension": dimension, ...otherProps, children: description
20
+ ? (_jsx(Tooltip, { fill: true, open: focused, placement: "right-start", interactive: true, trigger: InnerContent, children: description }, void 0))
21
+ : InnerContent }, void 0));
22
+ });
23
+ MenuItem.displayName = 'Menu.Item';
@@ -0,0 +1 @@
1
+ .MenuItem{background:none;border:0;box-sizing:border-box;color:var(--dimmed-6);cursor:pointer;font:inherit;font-size:.89rem;font-weight:600;inline-size:100%;padding:0;position:relative;text-align:start}.MenuItem:hover{color:var(--global-foreground)}.MenuItem[aria-checked=true]{color:var(--global-interactive-text)}.MenuItem:before{border-radius:.22rem;bottom:0;content:"";left:.44rem;opacity:60%;position:absolute;right:.44rem;top:0;z-index:0}.MenuItem:is(:hover,.focus-visible,[aria-pressed=true]):not([aria-disabled=true]){outline:none}.MenuItem:is(:hover,:focus-visible,[aria-pressed=true]):not([aria-disabled=true]){outline:none}.MenuItem:is(:hover,.focus-visible,[aria-pressed=true]):not([aria-disabled=true]):before{background-color:var(--dimmed-1)}.MenuItem:is(:hover,:focus-visible,[aria-pressed=true]):not([aria-disabled=true]):before{background-color:var(--dimmed-1)}.MenuItem[data-menu-item-dimension=small]{font-size:.78rem}.MenuItem>*{position:relative}.MenuItem[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}.MenuItem [data-menu-item-padding=true][data-menu-item-has-icon=false][data-menu-item-icon-right=false]{padding-left:2.22rem}.MenuItem [data-menu-item-padding=true][data-menu-item-has-icon=false][data-menu-item-icon-right=true]{padding-right:2.22rem}.ItemContent{position:relative}.Icon{align-self:flex-start;flex-grow:0;flex-shrink:0;margin-top:4px}
package/menu/menu.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { ReactNode, HTMLAttributes, ForwardRefExoticComponent } from 'react';
2
+ import { MenuItem, MenuItemProps } from './menu-item/menu-item';
3
+ import { MenuItemCheckbox, MenuItemCheckboxProps } from './menu-item/menu-item-checkbox';
4
+ import { Polymorphic } from '..';
5
+ export declare type MenuProps = HTMLAttributes<HTMLUListElement> & {
6
+ /**
7
+ * The items of the dropdown menu.
8
+ */
9
+ children: ReactNode;
10
+ };
11
+ declare type MenuComponent = ForwardRefExoticComponent<MenuProps> & {
12
+ Item: Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof MenuItem>, Polymorphic.OwnProps<typeof MenuItem> & MenuItemProps>;
13
+ ItemCheckbox: Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof MenuItemCheckbox>, Polymorphic.OwnProps<typeof MenuItemCheckbox> & MenuItemCheckboxProps>;
14
+ };
15
+ export declare const Menu: MenuComponent;
16
+ export {};
package/menu/menu.js ADDED
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Children, forwardRef } from 'react';
3
+ import { RovingTabIndexProvider } from 'react-roving-tabindex';
4
+ import { MenuItem } from './menu-item/menu-item';
5
+ import { MenuItemCheckbox } from './menu-item/menu-item-checkbox';
6
+ import { Stack, Elevator } from '..';
7
+ import { Menu as MenuClass } from './menu.module.css';
8
+ import clsx from 'clsx';
9
+ export const Menu = forwardRef(({ className, children, ...otherProps }, forwardedRef) => {
10
+ const renderedChildren = Children.toArray(children).filter(Boolean);
11
+ return (_jsx(Elevator, { resting: 2, children: _jsx(Stack, { as: "ul", ref: forwardedRef, className: clsx(MenuClass, className), role: "menu", ...otherProps, children: _jsx(RovingTabIndexProvider, { options: { direction: 'vertical', loopAround: true }, children: Children.map(renderedChildren, (child) => (_jsx(Stack, { as: "li", role: "none", verticalPadding: child.type?.displayName === 'Separator' ? 8 : undefined, children: child }, void 0))) }, void 0) }, void 0) }, void 0));
12
+ });
13
+ Menu.displayName = 'Menu';
14
+ Menu.Item = MenuItem;
15
+ Menu.ItemCheckbox = MenuItemCheckbox;
@@ -0,0 +1 @@
1
+ .Menu{background-color:var(--global-background);border:1px solid var(--dimmed-1);border-radius:.44rem;list-style-type:none;overflow:hidden;padding:.44rem 0;position:relative}.Menu hr{margin:0 .44rem}
@@ -1,9 +1,25 @@
1
- import React, { ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  export declare type ModalContentProps = PropsWithClass & {
3
+ /**
4
+ * Set the accessible title of the modal. This is used by screen readers to
5
+ * announce the title of the modal when opened.
6
+ */
3
7
  title: ReactNode;
8
+ /**
9
+ * Set the theme of the content card. To ensure contrast with the default overlay color (dark),
10
+ * this is set to `light` by default.
11
+ */
4
12
  theme?: 'dark' | 'light' | 'auto';
5
13
  };
6
- export declare const ModalContent: React.ForwardRefExoticComponent<PropsWithClass & {
14
+ export declare const ModalContent: import("react").ForwardRefExoticComponent<PropsWithClass & {
15
+ /**
16
+ * Set the accessible title of the modal. This is used by screen readers to
17
+ * announce the title of the modal when opened.
18
+ */
7
19
  title: ReactNode;
20
+ /**
21
+ * Set the theme of the content card. To ensure contrast with the default overlay color (dark),
22
+ * this is set to `light` by default.
23
+ */
8
24
  theme?: "auto" | "light" | "dark" | undefined;
9
- } & React.RefAttributes<HTMLDivElement>>;
25
+ } & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,15 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
2
  import clsx from 'clsx';
2
- import React, { forwardRef } from 'react';
3
+ import { forwardRef } from 'react';
4
+ import { AutoFocusInside } from 'react-focus-on';
3
5
  import { Content, Header, CloseButton } from './modal-content.module.css';
4
6
  import { Title, Elevator, IconButton, Stack } from '../../';
5
- import { useModalContext } from '../modal-context';
7
+ import { useOverlayContext } from '../../overlay-container';
6
8
  export const ModalContent = forwardRef(({ children, className, title, theme = 'light', ...otherProps }, forwardedRef) => {
7
- const { onClose, titleId } = useModalContext();
8
- return (React.createElement(Elevator, { resting: 4 },
9
- React.createElement("div", { className: clsx(Content, className), ref: forwardedRef, "data-theme": theme, ...otherProps },
10
- React.createElement(Stack, { verticalAlign: "center", fill: false, horizontalAlign: "space-between", direction: "row", className: Header },
11
- React.createElement(Title, { level: "5", id: titleId }, title),
12
- onClose && React.createElement(IconButton, { onClick: onClose, className: CloseButton, icon: "xmark", kind: "flat" })),
13
- children)));
9
+ const { onClose, titleId } = useOverlayContext();
10
+ return (_jsx(Elevator, { resting: 4, children: _jsxs("div", { className: clsx(Content, className), ref: forwardedRef, "data-theme": theme, ...otherProps, children: [_jsxs(Stack, { verticalAlign: "center", fill: false, horizontalAlign: "space-between", direction: "row", className: Header, children: [_jsx(Title, { responsive: false, level: "5", id: titleId, children: title }, void 0), onClose && _jsx(IconButton, { onClick: onClose, className: CloseButton, icon: "xmark", kind: "flat" }, void 0)] }, void 0), _jsx(AutoFocusInside, { children: children }, void 0)] }, void 0) }, void 0));
14
11
  });
15
12
  ModalContent.displayName = 'Modal.Content';
@@ -1 +1 @@
1
- .Content{-webkit-overflow-scrolling:touch;align-self:end;background-color:var(--global-background);border-radius:.89rem .89rem 0 0;color:var(--global-foreground);inline-size:100%;justify-self:center;max-block-size:95vh;overflow:auto;overscroll-behavior:contain}@media (min-width:30em){.Content{align-self:center;border-radius:.44rem;justify-self:center;max-block-size:80vh;max-inline-size:600px}}.Header{background-color:inherit;border-bottom:1px solid var(--dimmed-1);padding:.89rem 4.44rem .89rem 1.33rem;position:sticky;top:0}.CloseButton.CloseButton{position:absolute;right:.44rem;top:.44rem}
1
+ .Content{-webkit-overflow-scrolling:touch;align-self:end;background-color:var(--global-background);border-radius:.89rem .89rem 0 0;inline-size:100%;justify-self:center;max-block-size:95vh;overflow:auto;overscroll-behavior:contain}@media (min-width:30em){.Content{align-self:center;border-radius:.44rem;justify-self:center;max-block-size:80vh;max-inline-size:600px}}.Header{background-color:inherit;border-bottom:1px solid var(--dimmed-1);padding:.89rem 4.44rem .89rem 1.33rem;position:sticky;top:0}.CloseButton.CloseButton{position:absolute;right:.44rem;top:.44rem}
package/modal/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export { Modal } from './modal';
2
- export { useModalContext, ModalProvider } from './modal-context';
3
2
  export type { ModalProps } from './modal';
package/modal/index.js CHANGED
@@ -1,2 +1 @@
1
1
  export { Modal } from './modal';
2
- export { useModalContext, ModalProvider } from './modal-context';
package/modal/modal.d.ts CHANGED
@@ -1,9 +1,12 @@
1
- import React, { PropsWithChildren } from 'react';
1
+ import { PropsWithChildren } from 'react';
2
2
  import { ModalContentProps } from './content/modal-content';
3
3
  export declare type ModalProps = PropsWithChildren<PropsWithClass> & {
4
- overlayColor?: 'light' | 'dark' | 'auto';
4
+ /**
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.
8
+ */
5
9
  closeOnClickOutside?: boolean;
6
- onClose(): void;
7
10
  };
8
11
  declare type ModalComponent = React.ForwardRefExoticComponent<ModalProps> & {
9
12
  Content: React.ForwardRefExoticComponent<ModalContentProps>;
package/modal/modal.js CHANGED
@@ -1,18 +1,32 @@
1
- import React, { forwardRef } from 'react';
2
- import { useUIDSeed } from 'react-uid';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
3
3
  import { motion } from 'framer-motion';
4
4
  import clsx from 'clsx';
5
5
  import { FocusOn } from 'react-focus-on';
6
6
  import { ModalContent } from './content/modal-content';
7
- import { Modal as ModalClass, Backdrop, Container } from './modal.module.css';
8
- import { ModalContext, ModalProvider } from './modal-context';
9
- export const Modal = forwardRef(({ children, className, overlayColor = 'dark', closeOnClickOutside = true, onClose, ...otherProps }, forwardedRef) => {
10
- const seedID = useUIDSeed();
11
- return (React.createElement(ModalProvider, { onClose: onClose },
12
- React.createElement(ModalContext.Consumer, null, (ctx) => (React.createElement("div", { role: "dialog", "aria-modal": "true", "aria-labelledby": ctx.titleId, className: clsx(ModalClass, className), ref: forwardedRef, ...otherProps },
13
- React.createElement(motion.span, { key: seedID('modal-backdrop'), className: Backdrop, "data-overlay-color": overlayColor, initial: { opacity: 0 }, animate: { opacity: 0.95 }, transition: { duration: 0.2 } }),
14
- React.createElement(FocusOn, { onClickOutside: ctx.onClose, onEscapeKey: ctx.onClose },
15
- React.createElement(motion.div, { key: seedID('modal-container'), className: Container, initial: { y: 20, scale: 0.98, opacity: 0 }, animate: { y: 0, scale: 1, opacity: 1 }, transition: { ease: 'easeOut', duration: 0.1 } }, children)))))));
7
+ import { Modal as ModalClass, Container } from './modal.module.css';
8
+ import { useOverlayContext } from '../overlay-container';
9
+ const ModalAnimation = {
10
+ visible: {
11
+ scale: 1,
12
+ opacity: 1,
13
+ transition: {
14
+ ease: [0, 0, 0.34, 1],
15
+ duration: 0.35
16
+ }
17
+ },
18
+ hidden: {
19
+ scale: 0.98,
20
+ opacity: 0,
21
+ transition: {
22
+ ease: [0.3, 0.07, 1, 1],
23
+ duration: 0.2
24
+ }
25
+ }
26
+ };
27
+ export const Modal = forwardRef(({ children, className, closeOnClickOutside = true, ...otherProps }, forwardedRef) => {
28
+ const { titleId, onClose } = useOverlayContext();
29
+ return (_jsx("div", { role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, className: clsx(ModalClass, className), ref: forwardedRef, ...otherProps, children: _jsx(FocusOn, { onClickOutside: closeOnClickOutside ? onClose : undefined, onEscapeKey: onClose, children: _jsx(motion.div, { variants: ModalAnimation, initial: "hidden", animate: "visible", exit: "hidden", className: Container, children: children }, void 0) }, void 0) }, void 0));
16
30
  });
17
31
  Modal.displayName = 'Modal';
18
32
  Modal.Content = ModalContent;
@@ -1 +1 @@
1
- .Modal{position:fixed;z-index:20}.Backdrop,.Modal{bottom:0;left:0;right:0;top:0}.Backdrop{background-color:var(--dimmed-0);display:block;position:absolute;z-index:1}.Backdrop[data-overlay-color=light]{background-color:#f9fafb}.Backdrop[data-overlay-color=dark]{background-color:#202328}.Container{align-items:center;bottom:0;display:grid;justify-content:center;left:0;pointer-events:none;position:absolute;right:0;top:0;z-index:1}@media (min-width:30em){.Container{overflow:auto;padding:0 1.33rem}}.Container>*{pointer-events:auto}
1
+ .Modal{display:contents}.Container{align-items:center;bottom:0;display:grid;justify-content:center;left:0;pointer-events:none;position:absolute;right:0;top:0;z-index:1}@media (min-width:30em){.Container{overflow:auto;padding:0 1.33rem}}.Container>*{pointer-events:auto}
@@ -1,2 +1,3 @@
1
1
  export { OverlayContainer } from './overlay-container';
2
+ export { useOverlayContext, OverlayProvider, OverlayContext } from './overlay-context';
2
3
  export type { OverlayContainerProps } from './overlay-container';
@@ -1 +1,2 @@
1
1
  export { OverlayContainer } from './overlay-container';
2
+ export { useOverlayContext, OverlayProvider, OverlayContext } from './overlay-context';
@@ -1,7 +1,33 @@
1
- import React, { ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  export declare type OverlayContainerProps = {
3
+ /**
4
+ * The children to render inside the overlay container. This content
5
+ * will be rendered in a React `portal`, which means that it will be
6
+ * rendered outside of the DOM hierarchy of the parent component.
7
+ */
3
8
  children: ReactNode;
9
+ /**
10
+ * Set the root element to render the overlay container into.
11
+ */
4
12
  root?: HTMLElement;
13
+ /**
14
+ * Set the css `z-index` of the overlay container. This must be used only
15
+ * if necessary.
16
+ */
5
17
  index?: number;
18
+ /**
19
+ * Set the overlay style. This is used to obscure the content
20
+ * behind the overlay if `obfuscate` is `true`. If set to `auto`, the overlay
21
+ * color is determined by the global active theme (light or dark).
22
+ */
23
+ overlayColor?: 'light' | 'dark' | 'auto';
24
+ /**
25
+ * The callback function that is called when the overlay is closed.
26
+ */
27
+ onClose?(): void;
28
+ /**
29
+ * Set the overlay to be obscuring the page content behind it.
30
+ */
31
+ obfuscate?: boolean;
6
32
  };
7
33
  export declare const OverlayContainer: React.FC<OverlayContainerProps>;
@@ -1,13 +1,17 @@
1
- import React, { useEffect } from 'react';
2
- import { ModalProvider } from '../modal';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { AnimatePresence, motion } from 'framer-motion';
3
+ import { useEffect } from 'react';
3
4
  import { createPortal } from 'react-dom';
4
- export const OverlayContainer = ({ children, root = document.body, index = 4 }) => {
5
+ import { useUIDSeed } from 'react-uid';
6
+ import { OverlayProvider } from './overlay-context';
7
+ import { OverlayContainer as OverlayContainerClass, Backdrop } from './overlay-container.module.css';
8
+ export const OverlayContainer = ({ children, root = document.body, overlayColor = 'dark', index = 4, obfuscate = true, onClose }) => {
9
+ const seedID = useUIDSeed();
5
10
  useEffect(() => {
6
11
  if (root.closest('[data-overlay-container]')) {
7
12
  throw new Error('An OverlayContainer must not be inside another container. Please change the root prop.');
8
13
  }
9
14
  }, [root]);
10
- const content = (React.createElement(ModalProvider, null,
11
- React.createElement("div", { "data-overlay-container": true, style: { position: 'relative', zIndex: index } }, children)));
15
+ const content = (_jsx(OverlayProvider, { onClose: onClose, children: _jsx(AnimatePresence, { exitBeforeEnter: true, children: children && (_jsxs("div", { "data-overlay-container": true, "data-overlay-container-obfuscate": obfuscate, className: OverlayContainerClass, style: { zIndex: index }, children: [obfuscate && (_jsx(motion.span, { className: Backdrop, "data-overlay-color": overlayColor, initial: { opacity: 0 }, animate: { opacity: 0.95 }, transition: { duration: 0.2 }, exit: { opacity: 0 } }, seedID('modal-backdrop'))), children] }, void 0)) }, void 0) }, void 0));
12
16
  return createPortal(content, root);
13
17
  };
@@ -0,0 +1 @@
1
+ .OverlayContainer{bottom:0;display:block;left:0;position:fixed;right:0;top:0}.OverlayContainer[data-overlay-container-obfuscate=false]{pointer-events:none}.Backdrop{background-color:var(--dimmed-0);bottom:0;left:0;position:fixed;right:0;top:0;z-index:-1}.Backdrop[data-overlay-color=light]{background-color:#f9fafb}.Backdrop[data-overlay-color=dark]{background-color:#202328}
@@ -0,0 +1,9 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { OverlayContainerProps } from './overlay-container';
3
+ declare type OverlayContextProps = Partial<OverlayContainerProps> & {
4
+ titleId?: string;
5
+ };
6
+ export declare const OverlayContext: import("react").Context<OverlayContextProps>;
7
+ export declare const OverlayProvider: (props: PropsWithChildren<OverlayContextProps>) => JSX.Element;
8
+ export declare const useOverlayContext: () => OverlayContextProps;
9
+ export {};
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext } from 'react';
3
+ import { useUIDSeed } from 'react-uid';
4
+ export const OverlayContext = createContext({
5
+ titleId: '',
6
+ onClose: () => { }
7
+ });
8
+ OverlayContext.displayName = 'OverlayContext';
9
+ export const OverlayProvider = (props) => {
10
+ const seedID = useUIDSeed();
11
+ const { children, titleId = seedID('overlay-title'), onClose } = props;
12
+ return (_jsx(OverlayContext.Provider, { value: {
13
+ titleId,
14
+ onClose
15
+ }, children: children }, void 0));
16
+ };
17
+ export const useOverlayContext = () => {
18
+ const context = useContext(OverlayContext);
19
+ if (!context) {
20
+ throw new Error('OverlayContainer component must be used inside OverlayContext to access context data.');
21
+ }
22
+ return context;
23
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wonderflow/react-components",
3
3
  "description": "UI components from Wonderflow's Wanda design system",
4
- "version": "3.0.0-next.9",
4
+ "version": "3.0.0",
5
5
  "author": "Wonderflow",
6
6
  "license": "MIT",
7
7
  "main": "index.js",
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "engines": {
12
12
  "node": ">=14.x",
13
- "npm": ">=8.x.x"
13
+ "npm": ">=8.x"
14
14
  },
15
15
  "repository": {
16
16
  "type": "git",
@@ -25,7 +25,7 @@
25
25
  "bugs": {
26
26
  "url": "https://github.com/wonderflow-bv/react-components/issues"
27
27
  },
28
- "homepage": "https://github.com/wonderflow-bv/react-components#readme",
28
+ "homepage": "https://design.wonderflow.ai/",
29
29
  "browserslist": [
30
30
  "last 2 Chrome versions",
31
31
  "last 2 Firefox versions",
@@ -33,8 +33,9 @@
33
33
  "last 2 Edge versions"
34
34
  ],
35
35
  "scripts": {
36
- "start": "run-s build storybook",
36
+ "start": "run-s build:themes build:icons storybook",
37
37
  "storybook": "start-storybook --quiet -p 6006",
38
+ "commit": "cz",
38
39
  "lint": "run-s lint:scripts && run-s lint:styles",
39
40
  "lint:scripts": "eslint \"src/**/*.{tsx,ts}\"",
40
41
  "lint:styles": "stylelint src/**/*.css",
@@ -51,6 +52,7 @@
51
52
  "prepare:themes": "node src/themes/combine.js",
52
53
  "prepare:package": "copyfiles package.json dist",
53
54
  "build:components": "tsc",
55
+ "build:components:nocomments": "tsc -p ./tsconfig.nocomments.json",
54
56
  "build:css:core": "postcss dist/core/*.css dist/*.css --replace",
55
57
  "build:css:components": "postcss dist/**/*.module.css dist/**/**/*.module.css --replace",
56
58
  "build:css": "run-s build:csscore build:csscomponents",
@@ -58,30 +60,26 @@
58
60
  "build:light": "node src/themes/index.js --name light",
59
61
  "build:dark": "node src/themes/index.js --name dark",
60
62
  "build:icons": "run-s copy:icons optimize:svg generate:sprites",
61
- "build": "run-s build:icons build:components copy:css build:themes build:css:components build:css:core",
63
+ "build": "run-s build:icons build:components build:components:nocomments copy:css build:themes build:css:components build:css:core",
62
64
  "postbuild": "run-s prepare:package"
63
65
  },
64
66
  "dependencies": {
65
- "@react-aria/interactions": "3.7.0",
66
- "@wonderflow/eslint-config": "1.1.7",
67
- "@wonderflow/stylelint-config": "1.1.3",
68
67
  "@wonderflow/tokens": "1.3.7",
68
+ "ahooks": "3.1.3",
69
69
  "clsx": "1.1.1",
70
- "framer-motion": "4.1.17",
70
+ "framer-motion": "5.5.5",
71
71
  "postcss": "^8.4.5",
72
72
  "react": "^17.0",
73
- "react-data-table-component": "7.4.5",
73
+ "react-data-table-component": "7.4.6",
74
74
  "react-dom": "^17.0",
75
75
  "react-focus-on": "3.5.4",
76
- "react-loading-skeleton": "3.0.1",
76
+ "react-loading-skeleton": "3.0.2",
77
77
  "react-masonry-css": "1.0.16",
78
78
  "react-paginate": "8.1.0",
79
79
  "react-popper-tooltip": "4.3.1",
80
80
  "react-roving-tabindex": "3.1.1",
81
81
  "react-uid": "2.3.1",
82
- "react-use": "17.3.1",
83
82
  "storybook-addon-turbo-build": "1.0.1",
84
- "style-dictionary": "3.0.3",
85
83
  "type-fest": "2.8.0"
86
84
  },
87
85
  "peerDependencies": {
@@ -90,53 +88,99 @@
90
88
  "react-dom": "^17.0"
91
89
  },
92
90
  "devDependencies": {
93
- "@babel/core": "7.16.5",
94
- "@commitlint/cli": "15.0.0",
95
- "@commitlint/config-conventional": "15.0.0",
96
- "@semantic-release/commit-analyzer": "9.0.2",
91
+ "@babel/core": "7.16.7",
92
+ "@commitlint/cli": "16.0.1",
93
+ "@commitlint/config-conventional": "16.0.0",
97
94
  "@semantic-release/exec": "6.0.3",
98
95
  "@semantic-release/git": "10.0.1",
99
96
  "@semantic-release/github": "8.0.2",
100
97
  "@semantic-release/npm": "8.0.3",
101
98
  "@semantic-release/release-notes-generator": "10.0.3",
102
- "@storybook/addon-actions": "6.4.9",
103
- "@storybook/addon-essentials": "6.4.9",
104
- "@storybook/addon-links": "6.4.9",
99
+ "@storybook/addon-actions": "6.5.0-alpha.4",
100
+ "@storybook/addon-essentials": "6.5.0-alpha.4",
101
+ "@storybook/addon-links": "6.5.0-alpha.4",
105
102
  "@storybook/addon-postcss": "2.0.0",
106
- "@storybook/addons": "6.4.9",
107
- "@storybook/react": "6.4.9",
108
- "@storybook/theming": "6.4.9",
103
+ "@storybook/addons": "6.5.0-alpha.4",
104
+ "@storybook/builder-webpack5": "6.5.0-alpha.4",
105
+ "@storybook/manager-webpack5": "6.5.0-alpha.4",
106
+ "@storybook/react": "6.5.0-alpha.4",
107
+ "@storybook/theming": "6.5.0-alpha.4",
109
108
  "@types/react-dom": "17.0.11",
110
- "@typescript-eslint/eslint-plugin": "5.7.0",
111
- "@typescript-eslint/parser": "5.7.0",
112
- "@wonderflow/config": "3.0.2",
109
+ "@typescript-eslint/eslint-plugin": "5.8.1",
110
+ "@typescript-eslint/parser": "5.8.1",
111
+ "@wonderflow/config": "3.0.3",
112
+ "@wonderflow/eslint-config": "1.1.8",
113
+ "@wonderflow/stylelint-config": "1.1.3",
113
114
  "babel-loader": "8.2.3",
115
+ "commit-analyzer-fail-on-no-release": "1.0.1",
114
116
  "commitizen": "4.2.4",
115
117
  "copyfiles": "2.4.1",
116
118
  "cz-conventional-changelog": "3.3.0",
117
119
  "directory-tree": "3.0.1",
118
120
  "eslint": "7.32.0",
119
- "eslint-plugin-react": "7.27.1",
121
+ "eslint-plugin-react": "7.28.0",
122
+ "eslint-plugin-storybook": "0.5.5",
120
123
  "fs-extra": "10.0.0",
121
124
  "husky": "7.0.4",
122
125
  "is-ci": "3.0.1",
123
126
  "nanospinner": "0.6.0",
124
127
  "npm-run-all": "4.1.5",
125
128
  "picocolors": "1.0.0",
126
- "postcss-cli": "9.0.2",
129
+ "postcss-cli": "9.1.0",
127
130
  "postcss-mixins": "9.0.1",
128
131
  "rimraf": "3.0.2",
129
132
  "semantic-release": "18.0.1",
130
133
  "storybook-addon-themes": "6.1.0",
131
134
  "storybook-css-modules-preset": "1.1.1",
132
- "stylelint": "14.1.0",
135
+ "style-dictionary": "3.1.1",
136
+ "styled-components": "5.3.3",
137
+ "stylelint": "14.2.0",
133
138
  "svgo": "2.8.0",
134
139
  "svgstore": "3.0.1",
135
140
  "typescript": "4.5.4",
136
141
  "typescript-plugin-css-modules": "3.4.0",
137
- "yargs": "17.3.0"
142
+ "webpack": "5.65.0",
143
+ "yargs": "17.3.1"
138
144
  },
139
145
  "resolutions": {
140
146
  "rc": "1.2.8"
147
+ },
148
+ "config": {
149
+ "commitizen": {
150
+ "path": "cz-conventional-changelog"
151
+ }
152
+ },
153
+ "release": {
154
+ "branches": [
155
+ "main",
156
+ {
157
+ "name": "beta",
158
+ "channel": "beta",
159
+ "prerelease": true
160
+ }
161
+ ],
162
+ "plugins": [
163
+ "commit-analyzer-fail-on-no-release",
164
+ "@semantic-release/release-notes-generator",
165
+ [
166
+ "@semantic-release/github",
167
+ {
168
+ "addReleases": true
169
+ }
170
+ ],
171
+ [
172
+ "@semantic-release/npm",
173
+ {
174
+ "pkgRoot": "dist"
175
+ }
176
+ ],
177
+ [
178
+ "@semantic-release/exec",
179
+ {
180
+ "prepareCmd": "npx replace-json-property package.json version ${nextRelease.version}"
181
+ }
182
+ ],
183
+ "@semantic-release/git"
184
+ ]
141
185
  }
142
186
  }
@@ -1,10 +1,34 @@
1
1
  /// <reference types="react" />
2
2
  import { ReactPaginateProps } from 'react-paginate';
3
- export declare type PaginationProps = ReactPaginateProps & {
3
+ import { Except } from 'type-fest';
4
+ export declare type PaginationProps = Except<ReactPaginateProps, 'pageCount'> & {
5
+ /**
6
+ * Set the total number of items to paginate through.
7
+ */
4
8
  itemsCount: number;
9
+ /**
10
+ * Set the number of items to display per page.
11
+ */
5
12
  itemsPerPage?: number;
6
- onPageClick?(offset: Record<string, number>): void;
13
+ /**
14
+ * Set the number of pages to display. If missing this is computed by
15
+ * the `itemsCount` divided by `itemsPerPage`.
16
+ */
17
+ pageCount?: number;
18
+ /**
19
+ * Callback function to be called when the page is changed. A an `object`
20
+ * is passed with the following properties:
21
+ * - `selected`: The index of the selected page.
22
+ * - `offset`: The offset of the selected page.
23
+ */
24
+ onPageClick?(data: Record<string, number>): void;
25
+ /**
26
+ * Set how many pages to show in the visible page range (between the "..." break)
27
+ */
7
28
  pageRangeDisplayed?: ReactPaginateProps['pageRangeDisplayed'];
29
+ /**
30
+ * The number of visible pages to display on the sides.
31
+ */
8
32
  marginPagesDisplayed?: ReactPaginateProps['marginPagesDisplayed'];
9
33
  };
10
34
  export declare const Pagination: ({ className, itemsCount, itemsPerPage, onPageClick, pageCount, pageRangeDisplayed, marginPagesDisplayed, ...otherProps }: PaginationProps) => JSX.Element;
@@ -1,5 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import clsx from 'clsx';
2
- import React, { useCallback, useEffect, useState } from 'react';
3
+ import { useEffect, useState } from 'react';
3
4
  import ReactPaginate from 'react-paginate';
4
5
  import { Icon } from '../';
5
6
  import { Pagination as PaginationClass } from './pagination.module.css';
@@ -8,9 +9,9 @@ export const Pagination = ({ className, itemsCount, itemsPerPage = 10, onPageCli
8
9
  useEffect(() => {
9
10
  itemsCount && setComputedPageCount(Math.ceil(itemsCount / itemsPerPage));
10
11
  }, [itemsCount, itemsPerPage]);
11
- const handlePageClick = useCallback((event) => {
12
+ const handlePageClick = (event) => {
12
13
  const newOffset = (event.selected * itemsPerPage) % itemsCount;
13
14
  onPageClick && onPageClick({ ...event, offset: newOffset });
14
- }, [itemsPerPage, onPageClick, itemsCount]);
15
- return (React.createElement(ReactPaginate, { containerClassName: clsx(PaginationClass, className), breakLabel: "...", nextLabel: React.createElement(Icon, { dimension: 16, name: "chevron-right" }), previousLabel: React.createElement(Icon, { dimension: 16, name: "chevron-left" }), onPageChange: handlePageClick, pageRangeDisplayed: pageRangeDisplayed, pageCount: pageCount || computedPageCount, marginPagesDisplayed: marginPagesDisplayed, ...otherProps }));
15
+ };
16
+ return (_jsx(ReactPaginate, { containerClassName: clsx(PaginationClass, className), breakLabel: "...", nextLabel: _jsx(Icon, { dimension: 16, name: "chevron-right" }, void 0), previousLabel: _jsx(Icon, { dimension: 16, name: "chevron-left" }, void 0), onPageChange: handlePageClick, pageRangeDisplayed: pageRangeDisplayed, pageCount: pageCount || computedPageCount, marginPagesDisplayed: marginPagesDisplayed, ...otherProps }, void 0));
16
17
  };