@wonderflow/react-components 2.25.0-beta.7 → 2.25.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.
@@ -1,8 +1,7 @@
1
- import React, { MouseEvent } from 'react';
1
+ import { MouseEvent } from 'react';
2
2
  import { IconNames } from '../icons/types';
3
- import { Primitive, ComponentPropsWithoutRef } from '../';
4
- declare type PrimitiveButtonProps = ComponentPropsWithoutRef<typeof Primitive.button>;
5
- export declare type ButtonProps = PrimitiveButtonProps & {
3
+ import { Polymorphic } from '../';
4
+ export declare type ButtonProps = PropsWithClass & {
6
5
  kind?: 'primary' | 'secondary' | 'flat';
7
6
  dimension?: 'regular' | 'small' | 'big';
8
7
  fullWidth?: boolean;
@@ -12,18 +11,6 @@ export declare type ButtonProps = PrimitiveButtonProps & {
12
11
  type?: 'submit' | 'reset' | 'button';
13
12
  onClick?(event: MouseEvent<HTMLButtonElement | HTMLAnchorElement>): void;
14
13
  };
15
- export declare const Button: React.ForwardRefExoticComponent<Pick<Pick<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "key" | keyof React.ButtonHTMLAttributes<HTMLButtonElement>> & {
16
- ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
17
- } & {
18
- as?: keyof JSX.IntrinsicElements | undefined;
19
- }, "as" | "key" | keyof React.ButtonHTMLAttributes<HTMLButtonElement>> & {
20
- kind?: "primary" | "secondary" | "flat" | undefined;
21
- dimension?: "big" | "small" | "regular" | undefined;
22
- fullWidth?: boolean | undefined;
23
- icon?: IconNames | undefined;
24
- iconPosition?: "left" | "right" | undefined;
25
- disabled?: boolean | undefined;
26
- type?: "button" | "submit" | "reset" | undefined;
27
- onClick?(event: MouseEvent<HTMLButtonElement | HTMLAnchorElement>): void;
28
- } & React.RefAttributes<HTMLButtonElement>>;
14
+ declare type PolymorphicButton = Polymorphic.ForwardRefComponent<'button', ButtonProps>;
15
+ export declare const Button: PolymorphicButton;
29
16
  export {};
package/button/button.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import clsx from 'clsx';
2
2
  import React, { forwardRef, useCallback } from 'react';
3
- import { Icon, Primitive } from '../';
3
+ import { Icon } from '../';
4
4
  import { Button as ButtonClass } from './button.module.css';
5
- export const Button = forwardRef(({ kind = 'primary', dimension = 'regular', className, children, fullWidth, icon, disabled, iconPosition = 'left', type = 'button', onClick, as = 'button', ...props }, forwardedRef) => {
5
+ export const Button = forwardRef(({ kind = 'primary', dimension = 'regular', className, children, fullWidth, icon, disabled, iconPosition = 'left', type = 'button', onClick, as: Wrapper = 'button', ...props }, forwardedRef) => {
6
6
  const handleClick = useCallback(() => (event) => {
7
7
  if (!disabled && onClick)
8
8
  onClick(event);
@@ -14,7 +14,7 @@ export const Button = forwardRef(({ kind = 'primary', dimension = 'regular', cla
14
14
  regular: 16,
15
15
  small: 16
16
16
  };
17
- return (React.createElement(Primitive.button, { as: as, ref: forwardedRef, type: as === 'button' ? type : undefined, className: clsx(ButtonClass, className), "data-button-icon-position": iconPosition, "data-button-dimension": dimension, "data-button-kind": kind, "data-button-fullwidth": fullWidth, "data-button-disabled": disabled, "aria-disabled": disabled, onClick: handleClick(), ...props },
17
+ return (React.createElement(Wrapper, { ref: forwardedRef, type: Wrapper === 'button' ? type : undefined, className: clsx(ButtonClass, className), "data-button-icon-position": iconPosition, "data-button-dimension": dimension, "data-button-kind": kind, "data-button-fullwidth": fullWidth, "data-button-disabled": disabled, "aria-disabled": disabled, onClick: handleClick(), ...props },
18
18
  icon && React.createElement(Icon, { name: icon, dimension: iconSize[dimension] }),
19
19
  children));
20
20
  });
package/card/card.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import type * as Polymorphic from '../polymorphic';
3
- import { StackProps } from '../';
2
+ import { StackProps, Polymorphic } from '../';
4
3
  import { TokensTypes } from '@wonderflow/tokens/platforms/web/types';
5
4
  export declare type CardProps = PropsWithClass & Pick<StackProps, 'wrap' | 'columnGap' | 'rowGap' | 'verticalAlign' | 'horizontalAlign'> & {
6
5
  padding?: false | TokensTypes['space'];
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import type * as Polymorphic from '../polymorphic';
2
+ import { Polymorphic } from '../';
3
3
  export declare type ClampTextProps = PropsWithClass & {
4
4
  children: ReactNode;
5
5
  rows?: number;
@@ -1,4 +1,4 @@
1
- import type * as Polymorphic from '../polymorphic';
1
+ import { Polymorphic } from '../';
2
2
  export declare type ContainerProps = {
3
3
  dimension?: 'full' | 'medium' | 'large';
4
4
  padding?: boolean;
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
- import type * as Polymorphic from '../polymorphic';
3
2
  import { IconNames } from '../icons/types';
3
+ import { Polymorphic } from '../';
4
4
  export declare type DropdownItemProps = PropsWithClass & {
5
5
  children: ReactNode;
6
6
  icon?: IconNames;
@@ -1,9 +1,7 @@
1
1
  import React, { useCallback, forwardRef, useRef, useMemo } from 'react';
2
- import { Icon } from '../icon';
3
- import { Stack } from '../stack';
4
2
  import { useRovingTabIndex, useFocusEffect } from 'react-roving-tabindex';
5
3
  import { DropdownItem as DropdownItemClass, Icon as IconClass } from './dropdown-item.module.css';
6
- import { Tooltip } from '../';
4
+ import { Tooltip, Stack, Icon } from '../';
7
5
  import clsx from 'clsx';
8
6
  export const DropdownItem = forwardRef(({ className, children, onClick, icon, dimension = 'regular', as: Wrapper = 'button', iconPosition = 'left', description, ...props }, forwardedRef) => {
9
7
  const itemRef = useRef(forwardedRef);
@@ -1,19 +1,5 @@
1
- import React from 'react';
2
- import { Button, ButtonProps, ComponentPropsWithoutRef } from '../';
3
- declare type PrimitiveIconButtonProps = ComponentPropsWithoutRef<typeof Button>;
4
- export declare type IconButtonProps = PrimitiveIconButtonProps & Pick<ButtonProps, 'kind' | 'dimension' | 'icon' | 'disabled' | 'onClick'>;
5
- export declare const IconButton: React.ForwardRefExoticComponent<Pick<Pick<Pick<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "key" | keyof React.ButtonHTMLAttributes<HTMLButtonElement>> & {
6
- ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
7
- } & {
8
- as?: keyof JSX.IntrinsicElements | undefined;
9
- }, "as" | "key" | keyof React.ButtonHTMLAttributes<HTMLButtonElement>> & {
10
- kind?: "primary" | "secondary" | "flat" | undefined;
11
- dimension?: "big" | "small" | "regular" | undefined;
12
- fullWidth?: boolean | undefined;
13
- icon?: import("../icons/types").IconNames | undefined;
14
- iconPosition?: "left" | "right" | undefined;
15
- disabled?: boolean | undefined;
16
- type?: "button" | "submit" | "reset" | undefined;
17
- onClick?(event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement, MouseEvent>): void;
18
- } & React.RefAttributes<HTMLButtonElement>, "as" | "key" | keyof React.ButtonHTMLAttributes<HTMLButtonElement> | "kind" | "dimension" | "fullWidth" | "icon" | "iconPosition"> & Pick<ButtonProps, "onClick" | "disabled" | "kind" | "dimension" | "icon"> & React.RefAttributes<HTMLButtonElement>>;
1
+ import { Button, ButtonProps, Polymorphic } from '../';
2
+ export declare type IconButtonProps = PropsWithClass & Pick<ButtonProps, 'kind' | 'dimension' | 'icon' | 'disabled' | 'onClick'>;
3
+ declare type PolymorphicIconButton = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof Button>, Polymorphic.OwnProps<typeof Button> & IconButtonProps>;
4
+ export declare const IconButton: PolymorphicIconButton;
19
5
  export {};
@@ -5,18 +5,18 @@
5
5
  &[data-button-dimension='small'] {
6
6
  inline-size: env(--space-24);
7
7
  min-inline-size: env(--space-24);
8
- padding: inherit;
8
+ padding: 0;
9
9
  }
10
10
 
11
11
  &[data-button-dimension='regular'] {
12
12
  inline-size: env(--space-40);
13
13
  min-inline-size: env(--space-40);
14
- padding: inherit;
14
+ padding: 0;
15
15
  }
16
16
 
17
17
  &[data-button-dimension='big'] {
18
18
  inline-size: env(--space-48);
19
19
  min-inline-size: env(--space-48);
20
- padding: inherit;
20
+ padding: 0;
21
21
  }
22
22
  }
package/index.d.ts CHANGED
@@ -15,7 +15,6 @@ export { IconButton, IconButtonProps } from './icon-button';
15
15
  export { List, ListProps } from './list';
16
16
  export { Modal, ModalProps, useModalContext } from './modal';
17
17
  export { Prose, ProseProps } from './prose';
18
- export { Primitive, ComponentPropsWithoutRef, PrimitivePropsWithRef } from './primitive';
19
18
  export { Select, SelectProps } from './select';
20
19
  export { Separator } from './separator';
21
20
  export { Snackbar, SnackbarProps } from './snackbar';
package/index.js CHANGED
@@ -15,7 +15,6 @@ export { IconButton } from './icon-button';
15
15
  export { List } from './list';
16
16
  export { Modal, useModalContext } from './modal';
17
17
  export { Prose } from './prose';
18
- export { Primitive } from './primitive';
19
18
  export { Select } from './select';
20
19
  export { Separator } from './separator';
21
20
  export { Snackbar } from './snackbar';
package/list/list.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type * as Polymorphic from '../polymorphic';
2
1
  import { IconNames } from '../icons/types';
2
+ import { Polymorphic } from '../';
3
3
  export declare type ListProps = PropsWithClass & {
4
4
  dimension?: 'small' | 'regular' | 'big';
5
5
  marker?: IconNames;
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.25.0-beta.7",
4
+ "version": "2.25.1",
5
5
  "author": "Wonderflow",
6
6
  "license": "MIT",
7
7
  "main": "index.js",
package/prose/prose.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type * as Polymorphic from '../polymorphic';
1
+ import { Polymorphic } from '../';
2
2
  export declare type ProseProps = {};
3
3
  declare type PolymorphicProse = Polymorphic.ForwardRefComponent<'div', ProseProps>;
4
4
  export declare const Prose: PolymorphicProse;
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
- import type * as Polymorphic from '../polymorphic';
3
2
  import { IconNames } from '../icons/types';
3
+ import { Polymorphic } from '../';
4
4
  export declare type SnackbarProps = {
5
5
  icon?: IconNames;
6
6
  title?: string;
package/stack/stack.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type * as Polymorphic from '../polymorphic';
1
+ import { Polymorphic } from '../';
2
2
  import { TokensTypes } from '@wonderflow/tokens/platforms/web/types';
3
3
  export declare type StackProps = {
4
4
  rowGap?: 0 | TokensTypes['space'];
@@ -1,6 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import type * as Polymorphic from '../polymorphic';
3
- import { Stack } from '../';
2
+ import { Stack, Polymorphic } from '../';
4
3
  export declare type StarMeterProps = PropsWithClass & {
5
4
  value: number;
6
5
  starCount?: number;
package/text/text.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type * as Polymorphic from '../polymorphic';
1
+ import { Polymorphic } from '../';
2
2
  import { TokensTypes } from '@wonderflow/tokens/platforms/web/types';
3
3
  export declare type TextProps = {
4
4
  size?: TokensTypes['font']['size'];
@@ -1,5 +1,5 @@
1
1
  import { InputHTMLAttributes } from 'react';
2
- import type * as Polymorphic from '../../polymorphic';
2
+ import { Polymorphic } from '../../';
3
3
  export declare type BaseFieldProps = InputHTMLAttributes<HTMLInputElement> & InputHTMLAttributes<HTMLTextAreaElement> & {
4
4
  invalid?: boolean;
5
5
  };
package/themes/dark.css CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 04 Oct 2021 15:02:03 GMT
3
+ * Generated on Mon, 04 Oct 2021 16:41:59 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, 04 Oct 2021 15:02:03 GMT
3
+ * Generated on Mon, 04 Oct 2021 16:41:59 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, 04 Oct 2021 15:02:03 GMT
7
+ * Generated on Mon, 04 Oct 2021 16:41:59 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, 04 Oct 2021 15:02:03 GMT
54
+ * Generated on Mon, 04 Oct 2021 16:41:59 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, 04 Oct 2021 15:02:03 GMT
102
+ * Generated on Mon, 04 Oct 2021 16:41:59 GMT
103
103
  */
104
104
 
105
105
 
package/title/title.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type * as Polymorphic from '../polymorphic';
1
+ import { Polymorphic } from '../';
2
2
  export declare type TitleProps = {
3
3
  level?: '1' | '2' | '3' | '4' | '5' | '6' | 'display';
4
4
  lineHeignt?: 'none' | 'small' | 'large';
@@ -1,2 +0,0 @@
1
- export { Primitive } from './primitive';
2
- export type { ComponentPropsWithoutRef, PrimitivePropsWithRef } from './primitive';
@@ -1 +0,0 @@
1
- export { Primitive } from './primitive';
@@ -1,14 +0,0 @@
1
- import * as React from 'react';
2
- declare const NODES: readonly ["a", "button", "div", "h2", "h3", "img", "li", "nav", "p", "span", "svg", "ul"];
3
- declare type PropsWithoutRef<P> = P extends any ? ('ref' extends keyof P ? Pick<P, Exclude<keyof P, 'ref'>> : P) : P;
4
- export declare type ComponentPropsWithoutRef<T extends React.ElementType> = PropsWithoutRef<React.ComponentProps<T>>;
5
- declare type Primitives = {
6
- [E in typeof NODES[number]]: PrimitiveForwardRefComponent<E>;
7
- };
8
- export declare type PrimitivePropsWithRef<E extends React.ElementType> = React.ComponentPropsWithRef<E> & {
9
- as?: keyof JSX.IntrinsicElements;
10
- };
11
- interface PrimitiveForwardRefComponent<E extends React.ElementType> extends React.ForwardRefExoticComponent<PrimitivePropsWithRef<E>> {
12
- }
13
- export declare const Primitive: Primitives;
14
- export {};
@@ -1,23 +0,0 @@
1
- import * as React from 'react';
2
- const NODES = [
3
- 'a',
4
- 'button',
5
- 'div',
6
- 'h2',
7
- 'h3',
8
- 'img',
9
- 'li',
10
- 'nav',
11
- 'p',
12
- 'span',
13
- 'svg',
14
- 'ul'
15
- ];
16
- export const Primitive = NODES.reduce((primitive, node) => ({
17
- ...primitive,
18
- [node]: React.forwardRef((props, forwardedRef) => {
19
- const { as, ...primitiveProps } = props;
20
- const Comp = as || node;
21
- return React.createElement(Comp, { ...primitiveProps, ref: forwardedRef });
22
- })
23
- }), {});