@wonderflow/react-components 2.38.0 → 3.0.0-next.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.
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": "2.38.0",
4
+ "version": "3.0.0-next.1",
5
5
  "author": "Wonderflow",
6
6
  "license": "MIT",
7
7
  "main": "index.js",
package/tab/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { Tab } from './tab';
2
- export type { TabProps, TabPanelProps } from './tab';
1
+ export { TabRoot as Tab } from './tab';
2
+ export type { TabProps } from './tab';
package/tab/index.js CHANGED
@@ -1 +1 @@
1
- export { Tab } from './tab';
1
+ export { TabRoot as Tab } from './tab';
@@ -0,0 +1,6 @@
1
+ import React, { ButtonHTMLAttributes } from 'react';
2
+ import { IconNames } from '../icons/types';
3
+ export declare type TabItemProps = ButtonHTMLAttributes<HTMLButtonElement> & {
4
+ icon?: IconNames;
5
+ };
6
+ export declare const TabItem: React.FC<TabItemProps>;
@@ -0,0 +1,20 @@
1
+ import React, { useCallback, useRef } from 'react';
2
+ import { useRovingTabIndex, useFocusEffect } from 'react-roving-tabindex';
3
+ import clsx from 'clsx';
4
+ import { Stack, Icon } from '../';
5
+ import { useTabState } from './primitive-tab';
6
+ import { TabItem as TabItemClass } from './tab.module.css';
7
+ export const TabItem = ({ children, className, icon, ...props }) => {
8
+ const { onClick, isActive } = useTabState(children);
9
+ const internalRef = useRef(null);
10
+ const [, focused, handleKeyDown, handleClick] = useRovingTabIndex(internalRef, false);
11
+ useFocusEffect(focused, internalRef);
12
+ const fireClick = useCallback(() => {
13
+ onClick();
14
+ handleClick();
15
+ }, [handleClick, onClick]);
16
+ return (React.createElement(Stack, { as: "button", direction: "row", verticalAlign: "center", horizontalAlign: "start", fill: false, columnGap: 8, role: "tab", ref: internalRef, className: clsx(TabItemClass, className), "aria-selected": isActive, onClick: fireClick, onKeyDown: handleKeyDown, onFocus: fireClick, type: "button", tabIndex: isActive ? 0 : -1, ...props },
17
+ icon && React.createElement(Icon, { name: icon, dimension: 16 }),
18
+ children));
19
+ };
20
+ TabItem.displayName = 'Tab.Item';
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const TabList: React.FC<PropsWithClass>;
@@ -0,0 +1,6 @@
1
+ import React, { forwardRef } from 'react';
2
+ import { RovingTabIndexProvider } from 'react-roving-tabindex';
3
+ import clsx from 'clsx';
4
+ import { TabList as TabListClass } from './tab.module.css';
5
+ export const TabList = forwardRef(({ children, className, ...props }, forwardedRef) => (React.createElement("div", { ref: forwardedRef, role: "tablist", tabIndex: -1, className: clsx(TabListClass, className), ...props },
6
+ React.createElement(RovingTabIndexProvider, null, children))));
@@ -0,0 +1,7 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { IconNames } from '../icons/types';
3
+ export declare type TabPanelProps = PropsWithClass & {
4
+ label: ReactNode;
5
+ icon?: IconNames;
6
+ };
7
+ export declare const TabPanel: React.FC<TabPanelProps>;
@@ -0,0 +1,10 @@
1
+ import React, { forwardRef } from 'react';
2
+ import clsx from 'clsx';
3
+ import { usePanelState } from './primitive-tab';
4
+ import { TabPanel as TabPanelClass } from './tab.module.css';
5
+ export const TabPanel = forwardRef(({ children, className, ...props }, forwardedRef) => {
6
+ const isActive = usePanelState(children);
7
+ return isActive
8
+ ? (React.createElement("div", { ref: forwardedRef, tabIndex: 0, className: clsx(TabPanelClass, className), ...props }, children))
9
+ : null;
10
+ });
package/tab/tab.d.ts CHANGED
@@ -1,20 +1,15 @@
1
- import React, { ReactNode, ButtonHTMLAttributes } from 'react';
2
- import { IconNames } from '../icons/types';
1
+ import React, { ReactNode } from 'react';
3
2
  export declare type TabProps = PropsWithClass & {
4
3
  children: ReactNode;
5
4
  state?: [number, React.Dispatch<React.SetStateAction<number>>];
6
5
  onChange?(index: number): void;
7
6
  };
8
- export declare type TabPanelProps = PropsWithClass & {
9
- label: ReactNode;
10
- icon?: IconNames;
11
- };
12
- export declare type TabItemProps = ButtonHTMLAttributes<HTMLButtonElement> & {
13
- icon?: IconNames;
14
- };
15
- export declare const Tab: {
16
- Root: React.FC<TabProps>;
7
+ export declare const TabRoot: React.ForwardRefExoticComponent<PropsWithClass & {
8
+ children: ReactNode;
9
+ state?: [number, React.Dispatch<React.SetStateAction<number>>] | undefined;
10
+ onChange?(index: number): void;
11
+ } & React.RefAttributes<HTMLDivElement>> & {
12
+ Item: React.FC<import("./tab-item").TabItemProps>;
17
13
  List: React.FC<PropsWithClass>;
18
- Item: React.FC<TabItemProps>;
19
- Panel: React.FC<TabPanelProps>;
14
+ Panel: React.FC<import("./tab-panel").TabPanelProps>;
20
15
  };
package/tab/tab.js CHANGED
@@ -1,11 +1,12 @@
1
- import React, { useCallback, useEffect, useState, forwardRef, useRef, Children, cloneElement } from 'react';
2
- import { useRovingTabIndex, useFocusEffect, RovingTabIndexProvider } from 'react-roving-tabindex';
1
+ import React, { useEffect, useState, forwardRef, Children, cloneElement } from 'react';
3
2
  import clsx from 'clsx';
4
3
  import { useUIDSeed } from 'react-uid';
5
- import { Stack, Icon } from '../';
6
- import { Tabs as TabsWrapper, useTabState, usePanelState } from './primitive-tab';
7
- import { Tab as TabClass, TabList as TabListClass, TabItem as TabItemClass, TabPanel as TabPanelClass } from './tab.module.css';
8
- const TabRoot = forwardRef(({ children, className, state, onChange, ...props }, forwardedRef) => {
4
+ import { TabItem } from './tab-item';
5
+ import { TabList } from './tab-list';
6
+ import { TabPanel } from './tab-panel';
7
+ import { Tabs as TabsWrapper } from './primitive-tab';
8
+ import { Tab as TabClass } from './tab.module.css';
9
+ const Tab = forwardRef(({ children, className, state, onChange, ...props }, forwardedRef) => {
9
10
  const renderedChildren = Children.toArray(children).filter(Boolean);
10
11
  const innerState = useState(0);
11
12
  const tabState = state || innerState;
@@ -18,40 +19,14 @@ const TabRoot = forwardRef(({ children, className, state, onChange, ...props },
18
19
  }, [currentTab, onChange]);
19
20
  return (React.createElement("div", { ref: forwardedRef, className: clsx(TabClass, className), ...props },
20
21
  React.createElement(TabsWrapper, { state: tabState },
21
- React.createElement(TabList, null, Children.map(renderedChildren, (child, index) => (React.createElement(Tab.Item, { id: seedID(`tab-item-${index}`), "aria-controls": seedID(`tab-panel-${index}`), icon: child.props.icon }, child.props.label)))),
22
+ React.createElement(TabList, null, Children.map(renderedChildren, (child, index) => (React.createElement(TabItem, { id: seedID(`tab-item-${index}`), "aria-controls": seedID(`tab-panel-${index}`), icon: child.props.icon }, child.props.label)))),
22
23
  Children.map(renderedChildren, (child, index) => cloneElement(child, {
23
24
  id: seedID(`tab-panel-${index}`),
24
25
  'aria-labelledby': seedID(`tab-item-${index}`)
25
26
  })))));
26
27
  });
27
- const TabList = forwardRef(({ children, className, ...props }, forwardedRef) => (React.createElement("div", { ref: forwardedRef, role: "tablist", tabIndex: -1, className: clsx(TabListClass, className), ...props },
28
- React.createElement(RovingTabIndexProvider, null, children))));
29
- const TabPanel = forwardRef(({ children, className, ...props }, forwardedRef) => {
30
- const isActive = usePanelState(children);
31
- return isActive
32
- ? (React.createElement("div", { ref: forwardedRef, tabIndex: 0, className: clsx(TabPanelClass, className), ...props }, children))
33
- : null;
34
- });
35
- const TabItem = ({ children, className, icon, ...props }) => {
36
- const { onClick, isActive } = useTabState(children);
37
- const internalRef = useRef(null);
38
- const [, focused, handleKeyDown, handleClick] = useRovingTabIndex(internalRef, false);
39
- useFocusEffect(focused, internalRef);
40
- const fireClick = useCallback(() => {
41
- onClick();
42
- handleClick();
43
- }, [handleClick, onClick]);
44
- return (React.createElement(Stack, { as: "button", direction: "row", verticalAlign: "center", horizontalAlign: "start", fill: false, columnGap: 8, role: "tab", ref: internalRef, className: clsx(TabItemClass, className), "aria-selected": isActive, onClick: fireClick, onKeyDown: handleKeyDown, onFocus: fireClick, type: "button", tabIndex: isActive ? 0 : -1, ...props },
45
- icon && React.createElement(Icon, { name: icon, dimension: 16 }),
46
- children));
47
- };
48
- export const Tab = {
49
- Root: TabRoot,
50
- List: TabList,
28
+ export const TabRoot = Object.assign(Tab, {
51
29
  Item: TabItem,
30
+ List: TabList,
52
31
  Panel: TabPanel
53
- };
54
- Tab.Root.displayName = 'Tab.Root';
55
- Tab.List.displayName = 'Tab.List';
56
- Tab.Panel.displayName = 'Tab.Panel';
57
- Tab.Item.displayName = 'Tab.Item';
32
+ });
package/themes/dark.css CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 29 Nov 2021 08:43:32 GMT
3
+ * Generated on Mon, 29 Nov 2021 10:40:48 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 Mon, 29 Nov 2021 08:43:32 GMT
3
+ * Generated on Mon, 29 Nov 2021 10:40:48 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 Mon, 29 Nov 2021 08:43:32 GMT
7
+ * Generated on Mon, 29 Nov 2021 10:40:48 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 Mon, 29 Nov 2021 08:43:32 GMT
54
+ * Generated on Mon, 29 Nov 2021 10:40:48 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 Mon, 29 Nov 2021 08:43:32 GMT
102
+ * Generated on Mon, 29 Nov 2021 10:40:48 GMT
103
103
  */
104
104
 
105
105