@wonderflow/react-components 3.0.0-next.2 → 3.0.0-next.3

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 (95) hide show
  1. package/avatar/avatar.js +2 -2
  2. package/button/button.d.ts +4 -4
  3. package/button/button.js +4 -5
  4. package/button/button.module.css +22 -19
  5. package/card/card.d.ts +1 -1
  6. package/card/card.js +2 -2
  7. package/chip/chip.d.ts +10 -3
  8. package/chip/chip.js +2 -2
  9. package/circular-progress/circular-progress.js +2 -2
  10. package/clamp-text/clamp-text.d.ts +1 -1
  11. package/clamp-text/clamp-text.js +2 -3
  12. package/container/container.js +2 -3
  13. package/core/typography.css +1 -6
  14. package/core.css +5 -1
  15. package/disclosure/disclosure.js +3 -3
  16. package/dropdown/dropdown-item.d.ts +1 -1
  17. package/dropdown/dropdown-item.js +2 -2
  18. package/dropdown/dropdown-menu.d.ts +3 -3
  19. package/dropdown/dropdown-menu.js +11 -5
  20. package/dropdown/dropdown.d.ts +9 -19
  21. package/dropdown/dropdown.js +7 -5
  22. package/elevator/elevator.d.ts +2 -2
  23. package/grid/grid-item.d.ts +5 -1
  24. package/grid/grid-item.js +5 -4
  25. package/grid/grid.d.ts +5 -21
  26. package/grid/grid.js +3 -3
  27. package/grid/index.d.ts +1 -1
  28. package/grid/index.js +1 -1
  29. package/icon/icon.js +2 -2
  30. package/icon-button/icon-button.d.ts +1 -1
  31. package/icon-button/icon-button.js +1 -2
  32. package/icons/all.svg +15 -7
  33. package/icons/structure.json +2 -0
  34. package/icons/types.d.ts +4 -0
  35. package/index.d.ts +1 -1
  36. package/info-state/info-state.d.ts +12 -3
  37. package/info-state/info-state.js +2 -2
  38. package/input-group/input-group.js +3 -3
  39. package/input-group/input-group.module.css +0 -3
  40. package/linear-progress/linear-progress.d.ts +4 -4
  41. package/linear-progress/linear-progress.js +3 -3
  42. package/list/list.d.ts +2 -1
  43. package/list/list.js +2 -3
  44. package/list/list.module.css +7 -0
  45. package/masonry/masonry.d.ts +2 -2
  46. package/masonry/masonry.js +2 -2
  47. package/modal/modal-content.js +2 -2
  48. package/modal/modal.d.ts +5 -7
  49. package/modal/modal.js +11 -14
  50. package/package.json +30 -30
  51. package/pagination/pagination.d.ts +2 -4
  52. package/pagination/pagination.js +2 -2
  53. package/prose/prose.js +2 -3
  54. package/select/select.js +2 -2
  55. package/selection-controls/checkbox.js +2 -2
  56. package/selection-controls/radio.js +2 -2
  57. package/selection-controls/toggle.js +2 -2
  58. package/separator/index.d.ts +1 -0
  59. package/separator/separator.d.ts +3 -2
  60. package/separator/separator.js +2 -2
  61. package/skeleton-block/skeleton-block.d.ts +1 -1
  62. package/skeleton-block/skeleton-block.js +2 -2
  63. package/slider/slider.js +2 -2
  64. package/snackbar/snackbar.js +2 -3
  65. package/spinner/spinner.d.ts +5 -2
  66. package/spinner/spinner.js +5 -4
  67. package/split-button/split-button.js +2 -3
  68. package/stack/stack.js +2 -3
  69. package/star-meter/star-meter.d.ts +1 -1
  70. package/star-meter/star-meter.js +2 -3
  71. package/tab/tab-item.js +2 -2
  72. package/tab/tab-list.js +1 -1
  73. package/tab/tab-panel.js +3 -2
  74. package/tab/tab.d.ts +4 -4
  75. package/tab/tab.js +3 -2
  76. package/table/table.d.ts +3 -3
  77. package/table/table.js +8 -9
  78. package/table/table.module.css +0 -4
  79. package/text/text.d.ts +1 -1
  80. package/text/text.js +2 -3
  81. package/text/text.module.css +25 -24
  82. package/textfield/base-field/base-field.d.ts +1 -0
  83. package/textfield/base-field/base-field.js +2 -2
  84. package/textfield/base-field/index.d.ts +1 -1
  85. package/textfield/textfield.d.ts +4 -4
  86. package/textfield/textfield.js +3 -3
  87. package/themes/dark.css +1 -1
  88. package/themes/light.css +1 -1
  89. package/themes.css +3 -3
  90. package/title/title.d.ts +1 -1
  91. package/title/title.js +2 -3
  92. package/title/title.module.css +35 -34
  93. package/toggle-button/toggle-button.js +2 -3
  94. package/toggle-button/toggle-button.module.css +16 -2
  95. package/tooltip/tooltip.d.ts +2 -2
package/avatar/avatar.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import clsx from 'clsx';
2
2
  import React, { forwardRef } from 'react';
3
3
  import { Avatar as AvatarClass, Placeholder } from './avatar.module.css';
4
- export const Avatar = forwardRef(({ className, src, dimension = 'regular', ...props }, forwardedRef) => {
4
+ export const Avatar = forwardRef(({ className, src, dimension = 'regular', ...otherProps }, forwardedRef) => {
5
5
  return (React.createElement("picture", { className: clsx(AvatarClass, className), "data-avatar-dimension": dimension },
6
6
  React.createElement("svg", { "aria-hidden": "true", className: Placeholder, height: 18, viewBox: "0 0 12 18", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
7
7
  React.createElement("path", { opacity: 0.7, d: "M6 0C3.795 0 2 1.794 2 4s1.795 4 4 4 4-1.794 4-4-1.795-4-4-4z", fill: "var(--highlight-blue-foreground)" }),
8
8
  React.createElement("path", { d: "M8.4 9H3.6C1.612 9 0 10.575 0 12.531v5.126C1.814 18.517 3.85 19 6 19s4.186-.483 6-1.343v-5.126C12 10.581 10.394 9 8.4 9z", fill: "var(--highlight-blue-foreground)" })),
9
- src && (React.createElement("img", { ref: forwardedRef, alt: "", src: src, ...props }))));
9
+ src && (React.createElement("img", { ref: forwardedRef, alt: "", src: src, ...otherProps }))));
10
10
  });
11
11
  Avatar.displayName = 'Avatar';
@@ -1,7 +1,7 @@
1
- import React, { MouseEvent } from 'react';
1
+ import { FC, MouseEvent } from 'react';
2
2
  import { IconNames } from '../icons/types';
3
3
  import { Polymorphic } from '../';
4
- export declare type ButtonProps = PropsWithClass & {
4
+ export declare type ButtonProps = {
5
5
  kind?: 'primary' | 'secondary' | 'flat';
6
6
  dimension?: 'regular' | 'small' | 'big';
7
7
  fullWidth?: boolean;
@@ -10,12 +10,12 @@ export declare type ButtonProps = PropsWithClass & {
10
10
  iconColor?: string;
11
11
  disabled?: boolean;
12
12
  type?: 'submit' | 'reset' | 'button';
13
- loading?: boolean;
13
+ busy?: boolean;
14
14
  pressed?: boolean;
15
15
  onClick?(event: MouseEvent<HTMLButtonElement | HTMLAnchorElement>): void;
16
16
  };
17
17
  declare type PolymorphicButton = Polymorphic.ForwardRefComponent<'button', ButtonProps>;
18
18
  export declare const Button: PolymorphicButton;
19
19
  export declare type ButtonsGroupProps = PropsWithClass & Pick<ButtonProps, 'dimension' | 'kind'>;
20
- export declare const ButtonsGroup: React.FC<ButtonsGroupProps>;
20
+ export declare const ButtonsGroup: FC<ButtonsGroupProps>;
21
21
  export {};
package/button/button.js CHANGED
@@ -2,7 +2,7 @@ import clsx from 'clsx';
2
2
  import React, { Children, cloneElement, forwardRef, useCallback } from 'react';
3
3
  import { Icon, Spinner } from '../';
4
4
  import { Button as ButtonClass, SpinnerIndicator, ButtonsGroup as ButtonsGroupClass } from './button.module.css';
5
- export const Button = forwardRef(({ kind = 'primary', dimension = 'regular', className, children, fullWidth, icon, disabled, iconPosition = 'left', iconColor, type = 'button', pressed, onClick, loading, as: Wrapper = 'button', ...props }, forwardedRef) => {
5
+ export const Button = forwardRef(({ kind = 'primary', dimension = 'regular', className, children, fullWidth, icon, disabled, iconPosition = 'left', iconColor, type = 'button', pressed, onClick, busy, as: Wrapper = 'button', ...otherProps }, forwardedRef) => {
6
6
  const handleClick = useCallback(() => (event) => {
7
7
  if (!disabled && onClick)
8
8
  onClick(event);
@@ -14,14 +14,13 @@ export const Button = forwardRef(({ kind = 'primary', dimension = 'regular', cla
14
14
  regular: 16,
15
15
  small: 16
16
16
  };
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, "data-button-is-loading": loading, "aria-disabled": disabled, "aria-busy": loading, "aria-pressed": Wrapper === 'button' ? pressed : undefined, "aria-live": loading ? 'polite' : undefined, 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, "aria-disabled": disabled, "aria-busy": busy, "aria-pressed": Wrapper === 'button' ? pressed : undefined, "aria-live": busy ? 'polite' : undefined, onClick: handleClick(), ...otherProps },
18
18
  icon && (React.createElement(Icon, { name: icon, fill: iconColor, dimension: iconSize[dimension] })),
19
- children && React.createElement("span", null, children),
20
- loading && (React.createElement("span", { className: SpinnerIndicator },
19
+ (children && busy) ? React.createElement("span", null, children) : children,
20
+ busy && (React.createElement("span", { className: SpinnerIndicator },
21
21
  React.createElement(Spinner, { dimension: dimension })))));
22
22
  });
23
23
  export const ButtonsGroup = ({ children, className, kind, dimension = 'regular' }) => (React.createElement("div", { className: clsx(ButtonsGroupClass, className) }, Children.map(children, (child) => cloneElement(child, {
24
24
  kind,
25
25
  dimension
26
26
  }))));
27
- Button.displayName = 'Button';
@@ -46,16 +46,16 @@
46
46
  /* Types */
47
47
 
48
48
  &[data-button-kind='primary'] {
49
- background-color: var(--cta-default);
49
+ background: var(--cta-default);
50
50
  color: var(--cta-foreground);
51
51
 
52
- &:is(:active) {
53
- background-color: var(--cta-dark);
52
+ &:not([aria-pressed='true'], [aria-disabled='true']):is(:active) {
53
+ background: var(--cta-dark);
54
54
  }
55
55
 
56
- &[aria-pressed='true'],
57
- &[aria-pressed='true']:active {
58
- background-color: hsl(env(--color-red-50));
56
+ &:where([aria-pressed='true']),
57
+ &:where([aria-pressed='true']:active) {
58
+ background: hsl(env(--color-red-50));
59
59
  color: hsl(env(--color-support-white));
60
60
  }
61
61
  }
@@ -66,36 +66,39 @@
66
66
 
67
67
  color: var(--global-vibrancy-foreground);
68
68
 
69
- &:is(:active) {
69
+ &:not([aria-pressed='true'], [aria-disabled='true']):is(:active) {
70
70
 
71
71
  @mixin vibrancy-hover;
72
+
73
+ color: var(--global-vibrancy-foreground);
72
74
  }
73
75
 
74
- &[aria-pressed='true'],
75
- &[aria-pressed='true']:active {
76
- background-color: var(--dimmed-7);
76
+ &:where([aria-pressed='true']),
77
+ &:where([aria-pressed='true']:active) {
77
78
  color: var(--dimmed-0);
79
+ background: var(--dimmed-7);
78
80
  }
79
81
  }
80
82
 
81
83
  &[data-button-kind='flat'] {
82
- color: var(--global-foreground);
84
+ color: var(--global-vibrancy-foreground);
83
85
 
84
- &:is(:active) {
86
+ &:not([aria-pressed='true'], [aria-disabled='true']):is(:active) {
85
87
 
86
88
  @mixin vibrancy-hover;
87
89
  }
88
90
 
89
- &:is(:hover, :focus):not(:active) {
91
+ &:is(:hover, :focus) {
90
92
 
91
93
  @mixin vibrancy;
92
94
 
93
95
  color: var(--global-vibrancy-foreground);
94
96
  }
95
97
 
96
- &[aria-pressed='true'],
97
- &[aria-pressed='true']:active {
98
- background-color: var(--global-vibrancy-background-hover);
98
+ &:where([aria-pressed='true']),
99
+ &:where([aria-pressed='true']:is(:active, :focus)) {
100
+ color: var(--dimmed-0);
101
+ background: var(--dimmed-7);
99
102
  }
100
103
  }
101
104
 
@@ -109,15 +112,15 @@
109
112
  flex-direction: row-reverse;
110
113
  }
111
114
 
112
- &[data-button-disabled='true'],
113
- &[data-button-disabled='true']:is(:hover, :focus) {
115
+ &[aria-disabled='true'],
116
+ &[aria-disabled='true']:is(:hover, :focus, :active) {
114
117
 
115
118
  @mixin vibrancy-disabled;
116
119
 
117
120
  cursor: not-allowed;
118
121
  }
119
122
 
120
- &[data-button-is-loading='true'] > :not(.SpinnerIndicator) {
123
+ &[aria-busy='true'] > :not(.SpinnerIndicator) {
121
124
  visibility: hidden;
122
125
  }
123
126
  }
package/card/card.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { StackProps, Polymorphic } from '../';
3
3
  import { TokensTypes } from '@wonderflow/tokens/platforms/web/types';
4
- export declare type CardProps = PropsWithClass & Pick<StackProps, 'wrap' | 'columnGap' | 'rowGap' | 'verticalAlign' | 'horizontalAlign'> & {
4
+ export declare type CardProps = Pick<StackProps, 'wrap' | 'columnGap' | 'rowGap' | 'verticalAlign' | 'horizontalAlign'> & {
5
5
  padding?: false | TokensTypes['space'];
6
6
  left?: ReactNode;
7
7
  right?: ReactNode;
package/card/card.js CHANGED
@@ -3,12 +3,12 @@ import tkns from '@wonderflow/tokens/platforms/web/tokens.json';
3
3
  import { Stack } from '../';
4
4
  import clsx from 'clsx';
5
5
  import { Card as CardClass, Left, Content, Right } from './card.module.css';
6
- export const Card = forwardRef(({ as: Wrapper = 'div', children, className, padding = 24, radius = 8, left, right, dimmed, bordered, columnGap = 24, rowGap = 24, verticalAlign = 'start', horizontalAlign = 'space-between', vibrant = false, highlightOnHover = false, wrap, style, ...props }, forwardedRef) => {
6
+ export const Card = forwardRef(({ as: Wrapper = 'div', children, className, padding = 24, radius = 8, left, right, dimmed, bordered, columnGap = 24, rowGap = 24, verticalAlign = 'start', horizontalAlign = 'space-between', vibrant = false, highlightOnHover = false, wrap, style, ...otherProps }, forwardedRef) => {
7
7
  const dynamicStyle = {
8
8
  '--padding': padding && tkns.space[padding],
9
9
  '--radius': radius && tkns.radius[radius]
10
10
  };
11
- return (React.createElement(Wrapper, { ref: forwardedRef, className: clsx(CardClass, className), style: { ...dynamicStyle, ...style }, "data-card-dimmed": dimmed, "data-card-bordered": bordered, "data-card-vibrant": vibrant, "data-card-highlight-hover": highlightOnHover, ...props },
11
+ return (React.createElement(Wrapper, { ref: forwardedRef, className: clsx(CardClass, className), style: { ...dynamicStyle, ...style }, "data-card-dimmed": dimmed, "data-card-bordered": bordered, "data-card-vibrant": vibrant, "data-card-highlight-hover": highlightOnHover, ...otherProps },
12
12
  React.createElement(Stack, { direction: "row", fill: false, verticalAlign: verticalAlign, horizontalAlign: horizontalAlign, columnGap: columnGap, rowGap: rowGap, wrap: wrap },
13
13
  left && React.createElement("div", { className: Left }, left),
14
14
  children && (React.createElement("div", { className: Content }, children)),
package/chip/chip.d.ts CHANGED
@@ -1,8 +1,15 @@
1
- import React from 'react';
2
- export declare type ChipProps = PropsWithClass & {
1
+ import React, { PropsWithChildren } from 'react';
2
+ export declare type ChipProps = PropsWithChildren<PropsWithClass> & {
3
3
  dimension?: 'small' | 'regular' | 'big';
4
4
  color?: 'gray' | 'cyan' | 'green' | 'purple' | 'yellow' | 'red' | 'blue';
5
5
  interactive?: boolean;
6
6
  onDismissClick?(): void;
7
7
  };
8
- export declare const Chip: React.FC<ChipProps>;
8
+ export declare const Chip: React.ForwardRefExoticComponent<PropsWithClass & {
9
+ children?: React.ReactNode;
10
+ } & {
11
+ dimension?: "big" | "small" | "regular" | undefined;
12
+ color?: "gray" | "cyan" | "green" | "purple" | "yellow" | "red" | "blue" | undefined;
13
+ interactive?: boolean | undefined;
14
+ onDismissClick?(): void;
15
+ } & React.RefAttributes<HTMLSpanElement>>;
package/chip/chip.js CHANGED
@@ -2,7 +2,7 @@ import clsx from 'clsx';
2
2
  import React, { forwardRef } from 'react';
3
3
  import { Icon, Stack } from '../';
4
4
  import { Chip as ChipClass, Action } from './chip.module.css';
5
- export const Chip = forwardRef(({ children, className, dimension = 'regular', color = 'gray', interactive, onDismissClick, ...props }, forwardedRef) => {
5
+ export const Chip = forwardRef(({ children, className, dimension = 'regular', color = 'gray', interactive, onDismissClick, ...otherProps }, forwardedRef) => {
6
6
  const properties = {
7
7
  small: {
8
8
  iconSize: 14
@@ -14,7 +14,7 @@ export const Chip = forwardRef(({ children, className, dimension = 'regular', co
14
14
  iconSize: 16
15
15
  }
16
16
  };
17
- return (React.createElement(Stack, { as: "span", direction: "row", columnGap: 8, inline: true, "data-chip-color": color, "data-chip-dimension": dimension, className: clsx(ChipClass, className), verticalAlign: "center", ref: forwardedRef, ...props },
17
+ return (React.createElement(Stack, { as: "span", direction: "row", columnGap: 8, inline: true, "data-chip-color": color, "data-chip-dimension": dimension, className: clsx(ChipClass, className), verticalAlign: "center", ref: forwardedRef, ...otherProps },
18
18
  React.createElement("b", null, children),
19
19
  interactive && (React.createElement("button", { onClick: interactive && onDismissClick, className: Action, type: "button" },
20
20
  React.createElement(Icon, { name: "xmark", dimension: properties[dimension].iconSize })))));
@@ -1,12 +1,12 @@
1
1
  import React, { forwardRef, useCallback } from 'react';
2
2
  import clsx from 'clsx';
3
3
  import { CircularProgress as CircularProgressClass } from './circular-progress.module.css';
4
- export const CircularProgress = forwardRef(({ className, value, max = 100, dimension = 'regular', showProgress, style, ...props }, forwardedRef) => {
4
+ export const CircularProgress = forwardRef(({ className, value, max = 100, dimension = 'regular', showProgress, style, ...otherProps }, forwardedRef) => {
5
5
  const getPercentage = useCallback(() => value ? Math.round((100 * value) / max) : 0, [max, value]);
6
6
  const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
7
7
  const dynamicStyle = {
8
8
  '--progress': `${getPercentage()}%`
9
9
  };
10
- return (React.createElement("div", { ref: forwardedRef, role: "progressbar", "aria-valuenow": value, "aria-valuemin": 0, "aria-valuemax": max, className: clsx(CircularProgressClass, className), "data-circular-progress": clamp(getPercentage(), 0, 100), "data-circular-progress-dimension": dimension, "data-circular-progress-show-progress": showProgress, style: { ...dynamicStyle, ...style }, ...props }));
10
+ return (React.createElement("div", { ref: forwardedRef, role: "progressbar", "aria-valuenow": value, "aria-valuemin": 0, "aria-valuemax": max, className: clsx(CircularProgressClass, className), "data-circular-progress": clamp(getPercentage(), 0, 100), "data-circular-progress-dimension": dimension, "data-circular-progress-show-progress": showProgress, style: { ...dynamicStyle, ...style }, ...otherProps }));
11
11
  });
12
12
  CircularProgress.displayName = 'CircularProgress';
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { Polymorphic } from '../';
3
- export declare type ClampTextProps = PropsWithClass & {
3
+ export declare type ClampTextProps = {
4
4
  children: ReactNode;
5
5
  rows?: number;
6
6
  };
@@ -1,10 +1,9 @@
1
1
  import React, { forwardRef } from 'react';
2
2
  import clsx from 'clsx';
3
3
  import { ClampText as ClampTextClass } from './clamp-text.module.css';
4
- export const ClampText = forwardRef(({ className, children, rows = 1, style, as: Wrapper = 'span', ...props }, forwardedRef) => {
4
+ export const ClampText = forwardRef(({ className, children, rows = 1, style, as: Wrapper = 'span', ...otherProps }, forwardedRef) => {
5
5
  const dynamicStyle = {
6
6
  '--r': rows
7
7
  };
8
- return (React.createElement(Wrapper, { ref: forwardedRef, style: { ...dynamicStyle, ...style }, className: clsx(ClampTextClass, className), ...props }, children));
8
+ return (React.createElement(Wrapper, { ref: forwardedRef, style: { ...dynamicStyle, ...style }, className: clsx(ClampTextClass, className), ...otherProps }, children));
9
9
  });
10
- ClampText.displayName = 'ClampText';
@@ -1,7 +1,6 @@
1
1
  import React, { forwardRef } from 'react';
2
2
  import { Container as ContainerClass } from './container.module.css';
3
3
  import clsx from 'clsx';
4
- export const Container = forwardRef(({ children, className, dimension = 'full', padding = true, as: Wrapper = 'div', ...props }, forwardedRef) => {
5
- return (React.createElement(Wrapper, { ref: forwardedRef, className: clsx(ContainerClass, className), "data-container-dimension": dimension, "data-container-padding": padding, ...props }, children));
4
+ export const Container = forwardRef(({ children, className, dimension = 'full', padding = true, as: Wrapper = 'div', ...otherProps }, forwardedRef) => {
5
+ return (React.createElement(Wrapper, { ref: forwardedRef, className: clsx(ContainerClass, className), "data-container-dimension": dimension, "data-container-padding": padding, ...otherProps }, children));
6
6
  });
7
- Container.displayName = 'Container';
@@ -1,12 +1,7 @@
1
1
  :where(p) {
2
2
  line-height: 1.5;
3
3
  min-block-size: 0.01vh;
4
- font-size:
5
- clamp(
6
- var(--fluid-type-min, env(--font-size-16)),
7
- calc(0.6rem + 0.92vw),
8
- var(--fluid-type-max, 1rem)
9
- );
4
+ font-size: 1rem;
10
5
  }
11
6
 
12
7
  small {
package/core.css CHANGED
@@ -1 +1,5 @@
1
- @import './core/*.css';
1
+ @import './core/basic.css';
2
+ @import './core/elevations.css';
3
+ @import './core/media.css';
4
+ @import './core/typography.css';
5
+ @import './core/vibrancy.css';
@@ -3,7 +3,7 @@ import clsx from 'clsx';
3
3
  import { Disclosure as DisclosureClass, Summary, ExpandIcon, Content } from './disclosure.module.css';
4
4
  import { Text, Icon } from '../';
5
5
  import { motion } from 'framer-motion';
6
- export const Disclosure = forwardRef(({ children, open = false, padding = true, className, summary, contentMaxHeight, dimension = 'regular', iconPosition = 'left', expandable = true, style, ...props }, forwardedRef) => {
6
+ export const Disclosure = forwardRef(({ children, open = false, padding = true, className, summary, contentMaxHeight, dimension = 'regular', iconPosition = 'left', expandable = true, style, ...otherProps }, forwardedRef) => {
7
7
  const [isOpen, setIsOpen] = useState(open);
8
8
  const handleOpen = useCallback(() => (event) => {
9
9
  event.preventDefault();
@@ -24,8 +24,8 @@ export const Disclosure = forwardRef(({ children, open = false, padding = true,
24
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, ...props },
28
- React.createElement(Text, { as: "summary", onClick: handleOpen(), className: Summary, fluid: false, "aria-expanded": isOpen, tabIndex: !expandable ? -1 : 0, size: dimension ? sizes[dimension].summary : undefined, weight: "bold" },
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
29
  summary,
30
30
  expandable && (React.createElement(Icon, { className: ExpandIcon, name: "chevron-right", dimension: dimension !== 'big' ? 16 : 24 }))),
31
31
  renderContent()));
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { IconNames } from '../icons/types';
3
3
  import { Polymorphic } from '../';
4
- export declare type DropdownItemProps = PropsWithClass & {
4
+ export declare type DropdownItemProps = {
5
5
  children: ReactNode;
6
6
  icon?: IconNames;
7
7
  dimension?: 'small' | 'regular';
@@ -21,6 +21,6 @@ export const DropdownItem = forwardRef(({ className, children, onClick, icon, di
21
21
  ? (React.createElement(Tooltip, { fill: true, show: focused, placement: "right-start", trigger: InnerContent }, description))
22
22
  : InnerContent));
23
23
  });
24
- export const DropdownItemCheckbox = forwardRef(({ children, checked, ...props }, forwardedRef) => React.createElement(DropdownItem, { role: "menuitemcheckbox", "aria-checked": checked, ref: forwardedRef, ...props }, children));
25
24
  DropdownItem.displayName = 'Dropdown.Item';
26
- DropdownItemCheckbox.displayName = 'Dropdown.ItemChecbox';
25
+ export const DropdownItemCheckbox = forwardRef(({ children, checked, ...props }, forwardedRef) => React.createElement(DropdownItem, { role: "menuitemcheckbox", "aria-checked": checked, ref: forwardedRef, ...props }, children));
26
+ DropdownItemCheckbox.displayName = 'Dropdown.ItemCheckbox';
@@ -1,7 +1,7 @@
1
- import React, { ReactNode } from 'react';
2
- export declare type DropdownMenuProps = PropsWithClass & {
1
+ import React, { ReactNode, HTMLAttributes } from 'react';
2
+ export declare type DropdownMenuProps = HTMLAttributes<HTMLUListElement> & {
3
3
  children: ReactNode;
4
4
  };
5
- export declare const DropdownMenu: React.ForwardRefExoticComponent<PropsWithClass & {
5
+ export declare const DropdownMenu: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLUListElement> & {
6
6
  children: ReactNode;
7
7
  } & React.RefAttributes<HTMLUListElement>>;
@@ -3,9 +3,15 @@ import { RovingTabIndexProvider } from 'react-roving-tabindex';
3
3
  import { Stack, Elevator } from '../';
4
4
  import clsx from 'clsx';
5
5
  import { DropdownMenu as DropdownMenuClass } from './dropdown-menu.module.css';
6
- export const DropdownMenu = forwardRef(({ className, children, ...props }, forwardedRef) => (React.createElement(Elevator, { resting: 2 },
7
- React.createElement(Stack, { as: "ul", ref: forwardedRef, rowGap: 8, className: clsx(DropdownMenuClass, className), role: "menu", ...props },
8
- React.createElement(RovingTabIndexProvider, { options: { direction: 'vertical', loopAround: true } }, Children.map(children, (child, index) => (React.createElement("li", { role: "none" }, cloneElement(child, {
9
- autoFocus: index === 0 && true
10
- })))))))));
6
+ export const DropdownMenu = forwardRef(({ className, children, ...otherProps }, forwardedRef) => {
7
+ const renderedChildren = Children.toArray(children).filter(Boolean);
8
+ return (React.createElement(Elevator, { resting: 2 },
9
+ React.createElement(Stack, { as: "ul", ref: forwardedRef, className: clsx(DropdownMenuClass, className), role: "menu", ...otherProps },
10
+ React.createElement(RovingTabIndexProvider, { options: { direction: 'vertical', loopAround: true } }, Children.map(renderedChildren, (child, index) => {
11
+ var _a;
12
+ return (React.createElement(Stack, { as: "li", role: "none", verticalPadding: ((_a = child.type) === null || _a === void 0 ? void 0 : _a.displayName) === 'Separator' ? 8 : undefined }, cloneElement(child, {
13
+ autoFocus: index === 0 && true
14
+ })));
15
+ })))));
16
+ });
11
17
  DropdownMenu.displayName = 'Dropdown.Menu';
@@ -1,4 +1,6 @@
1
- import React, { ReactNode } from 'react';
1
+ import { ReactNode, ForwardRefExoticComponent } from 'react';
2
+ import { DropdownMenuProps } from './dropdown-menu';
3
+ import { DropdownItemProps, DropdownItemCheckboxProps } from './dropdown-item';
2
4
  import { AutoPlacement, BasePlacement, VariationPlacement } from '@popperjs/core';
3
5
  export declare type DropdownProps = PropsWithClass & {
4
6
  children: ReactNode;
@@ -6,22 +8,10 @@ export declare type DropdownProps = PropsWithClass & {
6
8
  offset?: number;
7
9
  placement?: AutoPlacement | BasePlacement | VariationPlacement;
8
10
  };
9
- export declare const Dropdown: {
10
- ({ className, children, trigger, offset, placement }: DropdownProps): JSX.Element;
11
- Menu: React.ForwardRefExoticComponent<PropsWithClass & {
12
- children: React.ReactNode;
13
- } & React.RefAttributes<HTMLUListElement>>;
14
- Item: import("../polymorphic/polymorphic").ForwardRefComponent<"button", import("./dropdown-item").DropdownItemProps>;
15
- ItemCheckbox: import("../polymorphic/polymorphic").ForwardRefComponent<"button", PropsWithClass & {
16
- children: React.ReactNode;
17
- icon?: import("../icons/types").IconNames | undefined;
18
- dimension?: "small" | "regular" | undefined;
19
- onClick?(): void;
20
- iconPosition?: "left" | "right" | undefined;
21
- description?: React.ReactNode;
22
- disabled?: boolean | undefined;
23
- padding?: boolean | undefined;
24
- } & {
25
- checked?: boolean | undefined;
26
- }>;
11
+ declare type DropdownComponent = ForwardRefExoticComponent<DropdownProps> & {
12
+ Menu: ForwardRefExoticComponent<DropdownMenuProps>;
13
+ Item: ForwardRefExoticComponent<DropdownItemProps>;
14
+ ItemCheckbox: ForwardRefExoticComponent<DropdownItemCheckboxProps>;
27
15
  };
16
+ export declare const Dropdown: DropdownComponent;
17
+ export {};
@@ -1,5 +1,5 @@
1
1
  import clsx from 'clsx';
2
- import React, { useState, Children, cloneElement, useRef } from 'react';
2
+ import React, { useState, Children, cloneElement, useRef, forwardRef } from 'react';
3
3
  import { useKey, useClickAway } from 'react-use';
4
4
  import { Dropdown as DropdownClass, PopUp } from './dropdown.module.css';
5
5
  import { useUIDSeed } from 'react-uid';
@@ -8,9 +8,10 @@ import { DropdownMenu } from './dropdown-menu';
8
8
  import { DropdownItem, DropdownItemCheckbox } from './dropdown-item';
9
9
  import { usePopperTooltip } from 'react-popper-tooltip';
10
10
  import { AnimatePresence, motion } from 'framer-motion';
11
- export const Dropdown = ({ className, children, trigger, offset = 8, placement = 'auto-start' }) => {
11
+ export const Dropdown = forwardRef(({ className, children, trigger, offset = 8, placement = 'auto-start' }, forwardedRef) => {
12
+ const renderedChildren = Children.toArray(children).filter(Boolean);
12
13
  const seedID = useUIDSeed();
13
- const popupRef = useRef(null);
14
+ const popupRef = useRef(forwardedRef);
14
15
  const [isOpen, setIsOpen] = useState(false);
15
16
  const { getTooltipProps, setTooltipRef, setTriggerRef, visible } = usePopperTooltip({
16
17
  delayShow: 0,
@@ -41,11 +42,12 @@ export const Dropdown = ({ className, children, trigger, offset = 8, placement =
41
42
  'aria-expanded': isOpen
42
43
  })),
43
44
  React.createElement(AnimatePresence, null, visible && (React.createElement("div", { ref: setTooltipRef, role: "tooltip", id: seedID('tooltip-content'), className: PopUp, ...getTooltipProps({ className: PopUp }) },
44
- React.createElement(motion.div, { animate: visible ? { y: 5, opacity: 1 } : { y: 0, opacity: 0 }, transition: { ease: 'easeOut', duration: 0.1 } }, Children.map(children, (child) => cloneElement(child, {
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, {
45
46
  id: seedID('dropdown-menu'),
46
47
  'aria-labelledby': seedID('dropdown-trigger')
47
48
  }))))))));
48
- };
49
+ });
50
+ Dropdown.displayName = 'Dropdown';
49
51
  Dropdown.Menu = DropdownMenu;
50
52
  Dropdown.Item = DropdownItem;
51
53
  Dropdown.ItemCheckbox = DropdownItemCheckbox;
@@ -1,7 +1,7 @@
1
- import React, { ReactElement } from 'react';
1
+ import { FC, ReactElement } from 'react';
2
2
  export declare type ElevatorProps = {
3
3
  resting: 0 | 1 | 2 | 3 | 4;
4
4
  hover?: 0 | 1 | 2 | 3 | 4;
5
5
  children: ReactElement;
6
6
  };
7
- export declare const Elevator: React.FC<ElevatorProps>;
7
+ export declare const Elevator: FC<ElevatorProps>;
@@ -4,4 +4,8 @@ export declare type GridItemProps = PropsWithClass & {
4
4
  column?: string;
5
5
  row?: string;
6
6
  };
7
- export declare const GridItem: React.FC<GridItemProps>;
7
+ export declare const GridItem: React.ForwardRefExoticComponent<PropsWithClass & {
8
+ fullWidth?: boolean | undefined;
9
+ column?: string | undefined;
10
+ row?: string | undefined;
11
+ } & React.RefAttributes<HTMLLIElement>>;
package/grid/grid-item.js CHANGED
@@ -1,10 +1,11 @@
1
- import React from 'react';
1
+ import React, { forwardRef } from 'react';
2
2
  import clsx from 'clsx';
3
3
  import { GridItem as GridItemClass } from './grid.module.css';
4
- export const GridItem = ({ children, style, className, fullWidth = false, column, row, ...props }) => {
4
+ export const GridItem = forwardRef(({ children, style, className, fullWidth = false, column, row, ...otherProps }, forwardedRef) => {
5
5
  const dynamicStyle = {
6
6
  '--column': column,
7
7
  '--row': row
8
8
  };
9
- return (React.createElement("li", { className: clsx(GridItemClass, className), style: { ...dynamicStyle, ...style }, "data-grid-item-fullwidth": fullWidth, ...props }, children));
10
- };
9
+ return (React.createElement("li", { ref: forwardedRef, className: clsx(GridItemClass, className), style: { ...dynamicStyle, ...style }, "data-grid-item-fullwidth": fullWidth, ...otherProps }, children));
10
+ });
11
+ GridItem.displayName = 'Grid.Item';
package/grid/grid.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  import { TokensTypes } from '@wonderflow/tokens/platforms/web/types';
3
+ import { GridItemProps } from './grid-item';
3
4
  export declare type GridProps = PropsWithClass & {
4
5
  children: ReactNode;
5
6
  columns?: number;
@@ -10,25 +11,8 @@ export declare type GridProps = PropsWithClass & {
10
11
  colMinWidth?: string;
11
12
  rowMinHeight?: string;
12
13
  };
13
- export declare const Grid: React.ForwardRefExoticComponent<PropsWithClass & {
14
- children: ReactNode;
15
- columns?: number | undefined;
16
- rows?: number | undefined;
17
- rowGap?: 0 | 24 | 16 | 32 | 40 | 48 | 56 | 2 | 4 | 8 | 64 | 72 | 80 | 88 | 96 | 104 | 112 | 120 | 128 | 136 | 144 | 152 | 160 | 168 | 176 | 184 | 192 | 200 | undefined;
18
- columnGap?: 0 | 24 | 16 | 32 | 40 | 48 | 56 | 2 | 4 | 8 | 64 | 72 | 80 | 88 | 96 | 104 | 112 | 120 | 128 | 136 | 144 | 152 | 160 | 168 | 176 | 184 | 192 | 200 | undefined;
19
- filling?: false | "fill" | "fit" | undefined;
20
- colMinWidth?: string | undefined;
21
- rowMinHeight?: string | undefined;
22
- } & React.RefAttributes<HTMLUListElement>>;
23
- export declare const GridRoot: React.ForwardRefExoticComponent<PropsWithClass & {
24
- children: ReactNode;
25
- columns?: number | undefined;
26
- rows?: number | undefined;
27
- rowGap?: 0 | 24 | 16 | 32 | 40 | 48 | 56 | 2 | 4 | 8 | 64 | 72 | 80 | 88 | 96 | 104 | 112 | 120 | 128 | 136 | 144 | 152 | 160 | 168 | 176 | 184 | 192 | 200 | undefined;
28
- columnGap?: 0 | 24 | 16 | 32 | 40 | 48 | 56 | 2 | 4 | 8 | 64 | 72 | 80 | 88 | 96 | 104 | 112 | 120 | 128 | 136 | 144 | 152 | 160 | 168 | 176 | 184 | 192 | 200 | undefined;
29
- filling?: false | "fill" | "fit" | undefined;
30
- colMinWidth?: string | undefined;
31
- rowMinHeight?: string | undefined;
32
- } & React.RefAttributes<HTMLUListElement>> & {
33
- Item: React.FC<import("./grid-item").GridItemProps>;
14
+ declare type GridComponent = React.ForwardRefExoticComponent<GridProps> & {
15
+ Item: React.ForwardRefExoticComponent<GridItemProps>;
34
16
  };
17
+ export declare const Grid: GridComponent;
18
+ export {};
package/grid/grid.js CHANGED
@@ -3,7 +3,7 @@ import clsx from 'clsx';
3
3
  import tksn from '@wonderflow/tokens/platforms/web/tokens.json';
4
4
  import { GridItem } from './grid-item';
5
5
  import { Grid as GridClass } from './grid.module.css';
6
- export const Grid = forwardRef(({ className, children, columns, rows, rowGap = 8, columnGap = 8, style, filling = 'fill', colMinWidth = '10rem', rowMinHeight = '1fr', ...props }, forwardedRef) => {
6
+ export const Grid = forwardRef(({ className, children, columns, rows, rowGap = 8, columnGap = 8, style, filling = 'fill', colMinWidth = '10rem', rowMinHeight = '1fr', ...otherProps }, forwardedRef) => {
7
7
  const computedStyle = {
8
8
  '--rGap': rowGap && tksn.space[rowGap],
9
9
  '--cGap': columnGap && tksn.space[columnGap],
@@ -12,7 +12,7 @@ export const Grid = forwardRef(({ className, children, columns, rows, rowGap = 8
12
12
  '--rows': rows,
13
13
  '--row-min-h': rowMinHeight
14
14
  };
15
- return (React.createElement("ul", { className: clsx(GridClass, className), style: { ...computedStyle, ...style }, "data-grid-filling-type": filling, ref: forwardedRef, ...props }, children));
15
+ return (React.createElement("ul", { className: clsx(GridClass, className), style: { ...computedStyle, ...style }, "data-grid-filling-type": filling, ref: forwardedRef, ...otherProps }, children));
16
16
  });
17
17
  Grid.displayName = 'Grid';
18
- export const GridRoot = Object.assign(Grid, { Item: GridItem });
18
+ Grid.Item = GridItem;
package/grid/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { GridRoot as Grid } from './grid';
1
+ export { Grid } from './grid';
2
2
  export type { GridProps } from './grid';
3
3
  export type { GridItemProps } from './grid-item';
package/grid/index.js CHANGED
@@ -1 +1 @@
1
- export { GridRoot as Grid } from './grid';
1
+ export { Grid } from './grid';
package/icon/icon.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import React, { forwardRef } from 'react';
2
2
  import sprite from '../icons/all.svg';
3
- export const Icon = forwardRef(({ className, name, dimension = 16, fill, ...props }, forwardedRef) => {
3
+ export const Icon = forwardRef(({ className, name, dimension = 16, fill, ...otherProps }, forwardedRef) => {
4
4
  const computedSize = dimension < 24 ? 16 : 24;
5
- return (React.createElement("svg", { "aria-hidden": "true", width: dimension, height: dimension, fill: fill, className: className, ref: forwardedRef, ...props },
5
+ return (React.createElement("svg", { "aria-hidden": "true", width: dimension, height: dimension, fill: fill, className: className, ref: forwardedRef, ...otherProps },
6
6
  React.createElement("use", { href: `${sprite}#${computedSize}/${name}` })));
7
7
  });
8
8
  Icon.displayName = 'Icon';
@@ -1,5 +1,5 @@
1
1
  import { Button, ButtonProps, Polymorphic } from '../';
2
- export declare type IconButtonProps = PropsWithClass & Pick<ButtonProps, 'kind' | 'dimension' | 'icon' | 'disabled' | 'onClick' | 'loading'>;
2
+ export declare type IconButtonProps = Pick<ButtonProps, 'kind' | 'dimension' | 'icon' | 'disabled' | 'onClick' | 'busy'>;
3
3
  declare type PolymorphicIconButton = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof Button>, Polymorphic.OwnProps<typeof Button> & IconButtonProps>;
4
4
  export declare const IconButton: PolymorphicIconButton;
5
5
  export {};
@@ -2,5 +2,4 @@ import React, { forwardRef } from 'react';
2
2
  import { IconButton as IconButtonClass } from './icon-button.module.css';
3
3
  import { Button } from '../';
4
4
  import clsx from 'clsx';
5
- export const IconButton = forwardRef(({ className, icon, dimension, kind, disabled, loading, ...props }, forwardedRef) => (React.createElement(Button, { ref: forwardedRef, icon: icon, dimension: dimension, kind: kind, disabled: disabled, loading: loading, className: clsx(IconButtonClass, className), ...props })));
6
- IconButton.displayName = 'IconButton';
5
+ export const IconButton = forwardRef(({ className, icon, dimension, kind, disabled, busy, ...otherProps }, forwardedRef) => (React.createElement(Button, { ref: forwardedRef, icon: icon, dimension: dimension, kind: kind, disabled: disabled, busy: busy, className: clsx(IconButtonClass, className), ...otherProps })));