@wonderflow/react-components 3.0.0-next.4 → 3.0.0-next.5

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.
package/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export { UIDReset as IdProvider } from 'react-uid';
2
- export { AnimatePresence as Presence } from 'framer-motion';
3
2
  export * as Polymorphic from './polymorphic';
4
3
  export { Avatar, AvatarProps } from './avatar';
5
4
  export { Button, ButtonsGroup, ButtonProps, ButtonsGroupProps } from './button';
@@ -19,8 +18,9 @@ export { InfoState, InfoStateProps } from './info-state';
19
18
  export { InputGroup, InputGroupProps } from './input-group';
20
19
  export { List, ListProps } from './list';
21
20
  export { SplitButton, SplitButtonProps } from './split-button';
22
- export { Modal, ModalProps, useModalContext } from './modal';
21
+ export { Modal, ModalProps, useModalContext, ModalProvider } from './modal';
23
22
  export { LinearProgress, LinearProgressProps } from './linear-progress';
23
+ export { OverlayContainer, OverlayContainerProps } from './overlay-container';
24
24
  export { Prose, ProseProps } from './prose';
25
25
  export { Pagination, PaginationProps } from './pagination';
26
26
  export { Select, SelectProps } from './select';
package/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  export { UIDReset as IdProvider } from 'react-uid';
2
- export { AnimatePresence as Presence } from 'framer-motion';
3
2
  export * as Polymorphic from './polymorphic';
4
3
  export { Avatar } from './avatar';
5
4
  export { Button, ButtonsGroup } from './button';
@@ -19,8 +18,9 @@ export { InfoState } from './info-state';
19
18
  export { InputGroup } from './input-group';
20
19
  export { List } from './list';
21
20
  export { SplitButton } from './split-button';
22
- export { Modal, useModalContext } from './modal';
21
+ export { Modal, useModalContext, ModalProvider } from './modal';
23
22
  export { LinearProgress } from './linear-progress';
23
+ export { OverlayContainer } from './overlay-container';
24
24
  export { Prose } from './prose';
25
25
  export { Pagination } from './pagination';
26
26
  export { Select } from './select';
@@ -1,13 +1,13 @@
1
1
  import clsx from 'clsx';
2
2
  import React, { forwardRef } from 'react';
3
3
  import { Content, Header, CloseButton } from './modal-content.module.css';
4
- import { Title, Elevator, IconButton, Stack } from '../';
5
- import { useModalContext } from './modal-context';
4
+ import { Title, Elevator, IconButton, Stack } from '../../';
5
+ import { useModalContext } from '../modal-context';
6
6
  export const ModalContent = forwardRef(({ children, className, title, ...otherProps }, forwardedRef) => {
7
7
  const { onClose, titleId } = useModalContext();
8
8
  return (React.createElement(Elevator, { resting: 4 },
9
9
  React.createElement("div", { className: clsx(Content, className), ref: forwardedRef, "data-theme": "light", ...otherProps },
10
- React.createElement(Stack, { as: "header", verticalAlign: "center", fill: false, horizontalAlign: "space-between", direction: "row", className: Header },
10
+ React.createElement(Stack, { verticalAlign: "center", fill: false, horizontalAlign: "space-between", direction: "row", className: Header },
11
11
  React.createElement(Title, { level: "5", id: titleId }, title),
12
12
  onClose && React.createElement(IconButton, { onClick: onClose, className: CloseButton, icon: "xmark", kind: "flat" })),
13
13
  children)));
@@ -1,4 +1,4 @@
1
- @import '../core/media.css';
1
+ @import '../../core/media.css';
2
2
 
3
3
  .Content {
4
4
  background-color: var(--global-background);
package/modal/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { Modal } from './modal';
2
- export { useModalContext } from './modal-context';
2
+ export { useModalContext, ModalProvider } from './modal-context';
3
3
  export type { ModalProps } from './modal';
package/modal/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export { Modal } from './modal';
2
- export { useModalContext } from './modal-context';
2
+ export { useModalContext, ModalProvider } from './modal-context';
@@ -1,9 +1,9 @@
1
- /// <reference types="react" />
1
+ import React, { PropsWithChildren } from 'react';
2
2
  import { ModalProps } from '../modal';
3
- declare type ModalContextProps = Pick<ModalProps, 'onClose' | 'visible'> & {
4
- titleId: string;
5
- setTitleId?(): void;
3
+ declare type ModalContextProps = Partial<ModalProps> & {
4
+ titleId?: string;
6
5
  };
7
- export declare const ModalContext: import("react").Context<ModalContextProps>;
6
+ export declare const ModalContext: React.Context<ModalContextProps>;
7
+ export declare const ModalProvider: (props: PropsWithChildren<ModalContextProps>) => JSX.Element;
8
8
  export declare const useModalContext: () => ModalContextProps;
9
9
  export {};
@@ -1,9 +1,18 @@
1
- import { createContext, useContext } from 'react';
1
+ import React, { createContext, useContext } from 'react';
2
+ import { useUIDSeed } from 'react-uid';
2
3
  export const ModalContext = createContext({
3
4
  titleId: '',
4
5
  onClose: () => { }
5
6
  });
6
7
  ModalContext.displayName = 'ModalContext';
8
+ export const ModalProvider = (props) => {
9
+ const seedID = useUIDSeed();
10
+ const { children, titleId = seedID('modal-title'), onClose } = props;
11
+ return (React.createElement(ModalContext.Provider, { value: {
12
+ titleId,
13
+ onClose
14
+ } }, children));
15
+ };
7
16
  export const useModalContext = () => {
8
17
  const context = useContext(ModalContext);
9
18
  if (!context) {
package/modal/modal.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import React, { PropsWithChildren } from 'react';
2
- import { ModalContentProps } from './modal-content';
2
+ import { ModalContentProps } from './content/modal-content';
3
3
  export declare type ModalProps = PropsWithChildren<PropsWithClass> & {
4
- visible?: boolean;
5
4
  overlayColor?: 'light' | 'dark' | 'auto';
6
5
  closeOnClickOutside?: boolean;
7
6
  onClose(): void;
package/modal/modal.js CHANGED
@@ -3,27 +3,16 @@ import { useUIDSeed } from 'react-uid';
3
3
  import { motion } from 'framer-motion';
4
4
  import clsx from 'clsx';
5
5
  import { FocusOn } from 'react-focus-on';
6
- import { ModalContent } from './modal-content';
6
+ import { ModalContent } from './content/modal-content';
7
7
  import { Modal as ModalClass, Backdrop, Container } from './modal.module.css';
8
- import { ModalContext } from './modal-context';
9
- import { Presence } from '../';
10
- const ModalElement = forwardRef(({ children, className, overlayColor = 'dark', closeOnClickOutside = true, onClose, visible, ...otherProps }, forwardedRef) => {
8
+ import { ModalContext, ModalProvider } from './modal-context';
9
+ export const Modal = forwardRef(({ children, className, overlayColor = 'dark', closeOnClickOutside = true, onClose, ...otherProps }, forwardedRef) => {
11
10
  const seedID = useUIDSeed();
12
- return (React.createElement(ModalContext.Provider, { value: {
13
- onClose,
14
- visible,
15
- titleId: seedID('modal-title')
16
- } },
11
+ return (React.createElement(ModalProvider, { onClose: onClose },
17
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 },
18
13
  React.createElement(motion.span, { key: seedID('modal-backdrop'), className: Backdrop, "data-overlay-color": overlayColor, initial: { opacity: 0 }, animate: { opacity: 0.95 }, exit: { opacity: 0 }, transition: { duration: 0.2 } }),
19
- React.createElement(FocusOn, { onClickOutside: () => ctx.onClose(), onEscapeKey: ctx.onClose },
14
+ React.createElement(FocusOn, { onClickOutside: ctx.onClose, onEscapeKey: ctx.onClose },
20
15
  React.createElement(motion.div, { key: seedID('modal-container'), className: Container, initial: { scale: 0.98, opacity: 0 }, animate: { scale: 1, opacity: 1 }, exit: { scale: 0.98, opacity: 0 }, transition: { ease: 'easeOut', duration: 0.1 } }, children)))))));
21
16
  });
22
- export const Modal = forwardRef(({ visible, ...otherProps }, forwardedRef) => {
23
- if (typeof visible === 'boolean') {
24
- return (React.createElement(Presence, { exitBeforeEnter: true }, visible ? React.createElement(ModalElement, { ref: forwardedRef, ...otherProps }) : null));
25
- }
26
- return (React.createElement(ModalElement, { ref: forwardedRef, ...otherProps }));
27
- });
28
17
  Modal.displayName = 'Modal';
29
18
  Modal.Content = ModalContent;
@@ -0,0 +1,2 @@
1
+ export { OverlayContainer } from './overlay-container';
2
+ export type { OverlayContainerProps } from './overlay-container';
@@ -0,0 +1 @@
1
+ export { OverlayContainer } from './overlay-container';
@@ -0,0 +1,6 @@
1
+ import React, { ReactNode } from 'react';
2
+ export declare type OverlayContainerProps = {
3
+ children: ReactNode;
4
+ root?: HTMLElement;
5
+ };
6
+ export declare const OverlayContainer: React.FC<OverlayContainerProps>;
@@ -0,0 +1,15 @@
1
+ import { AnimatePresence } from 'framer-motion';
2
+ import React, { useEffect } from 'react';
3
+ import { ModalProvider } from '../modal';
4
+ import { createPortal } from 'react-dom';
5
+ export const OverlayContainer = ({ children, root = document.body }) => {
6
+ useEffect(() => {
7
+ if (root.closest('[data-overlay-container]')) {
8
+ throw new Error('An OverlayContainer must not be inside another container. Please change the root prop.');
9
+ }
10
+ }, [root]);
11
+ const content = (React.createElement(ModalProvider, null,
12
+ React.createElement("div", { "data-overlay-container": true },
13
+ React.createElement(AnimatePresence, null, children))));
14
+ return createPortal(content, root);
15
+ };
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.4",
4
+ "version": "3.0.0-next.5",
5
5
  "author": "Wonderflow",
6
6
  "license": "MIT",
7
7
  "main": "index.js",
package/themes/dark.css CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Wed, 15 Dec 2021 11:09:41 GMT
3
+ * Generated on Wed, 15 Dec 2021 18:33:15 GMT
4
4
  */
5
5
 
6
6
  :root {
package/themes/light.css CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Wed, 15 Dec 2021 11:09:41 GMT
3
+ * Generated on Wed, 15 Dec 2021 18:33:15 GMT
4
4
  */
5
5
 
6
6
  :root {
package/themes.css CHANGED
@@ -4,7 +4,7 @@
4
4
  color: var(--global-foreground);
5
5
  /**
6
6
  * Do not edit directly
7
- * Generated on Wed, 15 Dec 2021 11:09:41 GMT
7
+ * Generated on Wed, 15 Dec 2021 18:33:15 GMT
8
8
  */
9
9
 
10
10
 
@@ -51,7 +51,7 @@
51
51
  color: var(--global-foreground);
52
52
  /**
53
53
  * Do not edit directly
54
- * Generated on Wed, 15 Dec 2021 11:09:41 GMT
54
+ * Generated on Wed, 15 Dec 2021 18:33:15 GMT
55
55
  */
56
56
 
57
57
 
@@ -99,7 +99,7 @@
99
99
  color: var(--global-foreground);
100
100
  /**
101
101
  * Do not edit directly
102
- * Generated on Wed, 15 Dec 2021 11:09:41 GMT
102
+ * Generated on Wed, 15 Dec 2021 18:33:15 GMT
103
103
  */
104
104
 
105
105
 
@@ -17,14 +17,6 @@
17
17
  &[data-title-line-height='small'] {
18
18
  --lh: 1.33;
19
19
  }
20
-
21
- &::before {
22
- content: '';
23
- display: block;
24
- height: 0;
25
- width: 0;
26
- margin-top: calc((1 - var(--lh)) * 0.6em);
27
- }
28
20
  }
29
21
 
30
22
  &:is(.H6) {
@@ -53,6 +45,14 @@
53
45
  --fs-max: 2.37rem;
54
46
 
55
47
  font-weight: 800;
48
+
49
+ &::before {
50
+ content: '';
51
+ display: block;
52
+ height: 0;
53
+ width: 0;
54
+ margin-top: calc((1 - var(--lh)) * 0.6em);
55
+ }
56
56
  }
57
57
 
58
58
  &:is(.H2) {
@@ -60,6 +60,14 @@
60
60
  --fs-max: 3.16rem;
61
61
 
62
62
  font-weight: 800;
63
+
64
+ &::before {
65
+ content: '';
66
+ display: block;
67
+ height: 0;
68
+ width: 0;
69
+ margin-top: calc((1 - var(--lh)) * 0.6em);
70
+ }
63
71
  }
64
72
 
65
73
  &:is(.H1) {
@@ -67,6 +75,14 @@
67
75
  --fs-max: 4.2rem;
68
76
 
69
77
  font-weight: 800;
78
+
79
+ &::before {
80
+ content: '';
81
+ display: block;
82
+ height: 0;
83
+ width: 0;
84
+ margin-top: calc((1 - var(--lh)) * 0.6em);
85
+ }
70
86
  }
71
87
 
72
88
  &.Display {
@@ -74,6 +90,14 @@
74
90
  --fs-max: 5.6rem;
75
91
 
76
92
  font-weight: 800;
93
+
94
+ &::before {
95
+ content: '';
96
+ display: block;
97
+ height: 0;
98
+ width: 0;
99
+ margin-top: calc((1 - var(--lh)) * 0.6em);
100
+ }
77
101
  }
78
102
 
79
103
  &[data-title-responsive='true'] {