@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
@@ -1,27 +1,97 @@
1
- import React, { ChangeEvent } from 'react';
2
- import { IconNames } from '../icons/types';
3
1
  import { BaseFieldProps, PrimitiveInputType } from './base-field';
2
+ import { ChangeEvent } from 'react';
3
+ import { IconNames } from '../icons/types';
4
4
  export declare type TextfieldProps = BaseFieldProps & {
5
+ /**
6
+ * Set the icon to show on the left or right side of the input.
7
+ */
5
8
  icon?: IconNames;
9
+ /**
10
+ * Set in which side of the field the icon should be displayed.
11
+ */
12
+ iconPosition?: 'left' | 'right';
13
+ /**
14
+ * Define the accessible label of the input. While this is not
15
+ * mandatory, an input should always have a label. If not using this property
16
+ * you can bind a custom label to the input by using an id.
17
+ */
6
18
  label?: string;
19
+ /**
20
+ * Set the input type. The value can be anything that
21
+ * is supported by the HTML input element.
22
+ *
23
+ * Read more: https://developer.mozilla.org/en-US/docs/Learn/Forms/HTML5_input_types
24
+ */
7
25
  type?: string;
26
+ /**
27
+ * Set the input to be a textarea instead of a single line field.
28
+ * This property completely changes the rendered element from an input to a textarea.
29
+ */
8
30
  textarea?: boolean;
31
+ /**
32
+ * Set the size of the field
33
+ */
9
34
  dimension?: 'regular' | 'small' | 'big';
35
+ /**
36
+ * Set the field into a readonly state. When readonly, the field value
37
+ * cannot be edited but it can still be selected and copied.
38
+ */
10
39
  readOnly?: boolean;
11
- iconPosition?: 'left' | 'right';
40
+ /**
41
+ * Set the field into a disabled state. When disabled, the field value cannot be
42
+ * edited, selected or copied, but it can still be focused and navigated by AT.
43
+ */
12
44
  disabled?: boolean;
45
+ /**
46
+ * The callback function that is called when the input value changes.
47
+ */
13
48
  onChange?: (event: ChangeEvent<PrimitiveInputType>) => void;
14
49
  };
15
- export declare const Textfield: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & React.InputHTMLAttributes<HTMLTextAreaElement> & {
50
+ export declare const Textfield: import("react").ForwardRefExoticComponent<import("react").InputHTMLAttributes<PrimitiveInputType> & {
16
51
  invalid?: boolean | undefined;
17
52
  } & {
53
+ /**
54
+ * Set the icon to show on the left or right side of the input.
55
+ */
18
56
  icon?: IconNames | undefined;
57
+ /**
58
+ * Set in which side of the field the icon should be displayed.
59
+ */
60
+ iconPosition?: "left" | "right" | undefined;
61
+ /**
62
+ * Define the accessible label of the input. While this is not
63
+ * mandatory, an input should always have a label. If not using this property
64
+ * you can bind a custom label to the input by using an id.
65
+ */
19
66
  label?: string | undefined;
67
+ /**
68
+ * Set the input type. The value can be anything that
69
+ * is supported by the HTML input element.
70
+ *
71
+ * Read more: https://developer.mozilla.org/en-US/docs/Learn/Forms/HTML5_input_types
72
+ */
20
73
  type?: string | undefined;
74
+ /**
75
+ * Set the input to be a textarea instead of a single line field.
76
+ * This property completely changes the rendered element from an input to a textarea.
77
+ */
21
78
  textarea?: boolean | undefined;
79
+ /**
80
+ * Set the size of the field
81
+ */
22
82
  dimension?: "big" | "small" | "regular" | undefined;
83
+ /**
84
+ * Set the field into a readonly state. When readonly, the field value
85
+ * cannot be edited but it can still be selected and copied.
86
+ */
23
87
  readOnly?: boolean | undefined;
24
- iconPosition?: "left" | "right" | undefined;
88
+ /**
89
+ * Set the field into a disabled state. When disabled, the field value cannot be
90
+ * edited, selected or copied, but it can still be focused and navigated by AT.
91
+ */
25
92
  disabled?: boolean | undefined;
93
+ /**
94
+ * The callback function that is called when the input value changes.
95
+ */
26
96
  onChange?: ((event: ChangeEvent<PrimitiveInputType>) => void) | undefined;
27
- } & React.RefAttributes<PrimitiveInputType>>;
97
+ } & import("react").RefAttributes<PrimitiveInputType>>;
@@ -1,13 +1,15 @@
1
- import React, { forwardRef, useCallback, useState } from 'react';
2
- import { Text, Stack, Icon, IconButton } from '../';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
2
  import { BaseField } from './base-field';
3
+ import { forwardRef, useCallback, useState, useMemo } from 'react';
4
+ import { FieldContainer, IconButton as IconButtonClass, Icon as IconClass, InputField, Textfield as TextfieldClass } from './textfield.module.css';
5
+ import { Icon, IconButton, Stack, Text } from '../';
4
6
  import clsx from 'clsx';
5
7
  import { useUIDSeed } from 'react-uid';
6
- import { Textfield as TextfieldClass, FieldContainer, InputField, Icon as IconClass, IconButton as IconButtonClass } from './textfield.module.css';
7
- export const Textfield = forwardRef(({ children, className, disabled = false, icon, label, textarea, readOnly, invalid, iconPosition = 'right', dimension = 'regular', type, onChange, ...otherProps }, forwardedRef) => {
8
+ export const Textfield = forwardRef(({ children, className, disabled = false, icon, label, textarea, readOnly, invalid, id, iconPosition = 'right', dimension = 'regular', type, style, onChange, ...otherProps }, forwardedRef) => {
8
9
  const [passwordVisible, setPasswordVisible] = useState(false);
9
- const uid = useUIDSeed();
10
+ const seedID = useUIDSeed();
10
11
  const isPassword = type === 'password';
12
+ const fieldID = useMemo(() => id || seedID('field'), [id, seedID]);
11
13
  const handlePasswordVisibility = useCallback(() => {
12
14
  setPasswordVisible(visibility => !visibility);
13
15
  }, []);
@@ -27,13 +29,8 @@ export const Textfield = forwardRef(({ children, className, disabled = false, ic
27
29
  disabled,
28
30
  onChange
29
31
  };
30
- return (React.createElement(Stack, { as: "fieldset", rowGap: 4, className: clsx(TextfieldClass, className), "data-textfield-has-icon": isPassword || Boolean(icon), "data-textfield-icon-position": iconPosition, "data-textfield-dimension": dimension, "data-textfield-invalid": invalid, "aria-disabled": disabled, horizontalAlign: "stretch", verticalAlign: "start", tabIndex: disabled ? 0 : undefined },
31
- label && React.createElement(Text, { as: "label", size: dimension === 'small' ? 14 : 16, htmlFor: uid('field') }, label),
32
- React.createElement("div", { className: FieldContainer },
33
- textarea
34
- ? (React.createElement(BaseField, { ref: forwardedRef, as: "textarea", id: uid('field'), ...commonProps, ...otherProps }))
35
- : (React.createElement(BaseField, { className: InputField, id: uid('field'), ref: forwardedRef, type: passwordVisible ? 'text' : type, ...commonProps, ...otherProps })),
36
- isPassword && (React.createElement(IconButton, { className: IconButtonClass, dimension: actionSizes[dimension], onClick: handlePasswordVisibility, kind: "flat", "aria-label": "Reveal password", icon: passwordVisible ? 'eye-slash' : 'eye' })),
37
- !textarea && icon && type !== 'password' && (React.createElement(Icon, { className: IconClass, name: icon, dimension: iconSizes[dimension] })))));
32
+ return (_jsxs(Stack, { as: "fieldset", rowGap: 4, className: clsx(TextfieldClass, className), "data-textfield-has-icon": isPassword || Boolean(icon), "data-textfield-icon-position": iconPosition, "data-textfield-dimension": dimension, "data-textfield-invalid": invalid, "aria-disabled": disabled, horizontalAlign: "stretch", verticalAlign: "start", tabIndex: disabled ? 0 : undefined, style: style, children: [label && _jsx(Text, { as: "label", size: dimension === 'small' ? 14 : 16, htmlFor: fieldID, children: label }, void 0), _jsxs("div", { className: FieldContainer, children: [textarea
33
+ ? (_jsx(BaseField, { ref: forwardedRef, as: "textarea", id: fieldID, ...commonProps, ...otherProps }, void 0))
34
+ : (_jsx(BaseField, { className: InputField, id: fieldID, ref: forwardedRef, type: passwordVisible ? 'text' : type, ...commonProps, ...otherProps }, void 0)), isPassword && (_jsx(IconButton, { className: IconButtonClass, dimension: actionSizes[dimension], onClick: handlePasswordVisibility, kind: "flat", "aria-label": "Reveal password", icon: passwordVisible ? 'eye-slash' : 'eye' }, void 0)), !textarea && icon && !isPassword && (_jsx(Icon, { className: IconClass, name: icon, dimension: iconSizes[dimension] }, void 0))] }, void 0)] }, void 0));
38
35
  });
39
36
  Textfield.displayName = 'Textfield';
package/themes/dark.css CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Thu, 16 Dec 2021 17:07:15 GMT
3
+ * Generated on Wed, 05 Jan 2022 13:47:46 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 Thu, 16 Dec 2021 17:07:15 GMT
3
+ * Generated on Wed, 05 Jan 2022 13:47:46 GMT
4
4
  */
5
5
 
6
6
  :root {
package/title/title.d.ts CHANGED
@@ -1,9 +1,29 @@
1
1
  import { Polymorphic } from '../';
2
2
  export declare type TitleProps = {
3
+ /**
4
+ * Set the level of the title. This property only
5
+ * affects the visual appearance of the title and not the
6
+ * semantic meaning of the title, which you can define
7
+ * by using the `as` property.
8
+ */
3
9
  level?: '1' | '2' | '3' | '4' | '5' | '6' | 'display';
10
+ /**
11
+ * Set the text line-height of the title. This uses
12
+ * the predefined tokens from the typography system.
13
+ */
4
14
  lineHeight?: 'none' | 'small' | 'large';
15
+ /**
16
+ * Set the text alignment of the title based on the text direction.
17
+ */
5
18
  textAlign?: 'start' | 'center' | 'end';
19
+ /**
20
+ * Set the maximum width of the text after which it will wrap.
21
+ */
6
22
  maxWidth?: string;
23
+ /**
24
+ * Enable or disable the responsiveness of the text. If disabled,
25
+ * the text will be always the same size across all breakpoints.
26
+ */
7
27
  responsive?: boolean;
8
28
  };
9
29
  declare type PolymorphicTitle = Polymorphic.ForwardRefComponent<'span', TitleProps>;
package/title/title.js CHANGED
@@ -1,5 +1,6 @@
1
- import React, { forwardRef } from 'react';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as styles from './title.module.css';
3
+ import { forwardRef } from 'react';
3
4
  import clsx from 'clsx';
4
5
  export const Title = forwardRef(({ children, className, as: Wrapper = 'span', lineHeight = 'small', level = '1', textAlign = 'start', maxWidth, responsive = true, style, ...otherProps }, forwardedRef) => {
5
6
  const computedLevel = level.match(/\d/g) ? `H${level}` : level.charAt(0).toUpperCase() + level.slice(1);
@@ -7,5 +8,5 @@ export const Title = forwardRef(({ children, className, as: Wrapper = 'span', li
7
8
  '--maxW': maxWidth,
8
9
  '--tAlign': textAlign
9
10
  };
10
- return (React.createElement(Wrapper, { ref: forwardedRef, "data-title-line-height": lineHeight, "data-title-responsive": responsive, className: clsx(styles.Title, styles[computedLevel], className), style: { ...dynamicStyle, ...style }, ...otherProps }, children));
11
+ return (_jsx(Wrapper, { ref: forwardedRef, "data-title-line-height": lineHeight, "data-title-responsive": responsive, className: clsx(styles.Title, styles[computedLevel], className), style: { ...dynamicStyle, ...style }, ...otherProps, children: children }, void 0));
11
12
  });
@@ -1 +1 @@
1
- .Title:is(.H1,.H2,.H3,.H4,.H5,.H6,.Display){--lh:0.3;color:var(--heading-foreground);display:block;font-size:var(--fs-max);line-height:1.2;max-inline-size:var(--maxW,initial);min-block-size:.01vh;overflow-wrap:break-word;text-align:var(--tAlign)}.Title:is(.H1,.H2,.H3,.H4,.H5,.H6,.Display)[data-title-line-height=small]{--lh:1.33}.Title:is(.H6){--fs-min:0.78rem;--fs-max:1.00rem;font-weight:700}.Title:is(.H5){--fs-min:1rem;--fs-max:1.33rem;font-weight:700}.Title:is(.H4){--fs-min:1.33rem;--fs-max:1.77rem;font-weight:700}.Title:is(.H3){--fs-min:1.77rem;--fs-max:2.37rem;font-weight:800}.Title:is(.H3):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title:is(.H2){--fs-min:2.37rem;--fs-max:3.16rem;font-weight:800}.Title:is(.H2):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title:is(.H1){--fs-min:3.16rem;--fs-max:4.2rem;font-weight:800}.Title:is(.H1):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title.Display{--fs-min:4.2rem;--fs-max:5.6rem;font-weight:800}.Title.Display:before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title[data-title-responsive=true]{font-size:var(--fs-min)}@media (min-width:48em){.Title[data-title-responsive=true]{font-size:var(--fs-max)}}
1
+ .Title:is(.H1,.H2,.H3,.H4,.H5,.H6,.Display){--lh:1.5;color:var(--heading-foreground);display:block;font-size:var(--fs-max);line-height:1.2;max-inline-size:var(--maxW,initial);min-block-size:.01vh;overflow-wrap:break-word;text-align:var(--tAlign)}.Title[data-title-line-height=small]:is(.H1,.H2,.H3,.H4,.H5,.H6,.Display){--lh:1.2}.Title[data-title-line-height=large]:is(.H1,.H2,.H3,.H4,.H5,.H6,.Display){line-height:1.5}.Title:is(.H6){--fs-min:0.78rem;--fs-max:1.00rem;font-weight:700}.Title:is(.H5){--fs-min:1rem;--fs-max:1.33rem;font-weight:700}.Title:is(.H5):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title:is(.H4){--fs-min:1.33rem;--fs-max:1.77rem;font-weight:700}.Title:is(.H4):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title:is(.H3){--fs-min:1.77rem;--fs-max:2.37rem;font-weight:800}.Title:is(.H3):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title:is(.H2){--fs-min:2.37rem;--fs-max:3.16rem;font-weight:800}.Title:is(.H2):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title:is(.H1){--fs-min:3.16rem;--fs-max:4.2rem;font-weight:800}.Title:is(.H1):before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title.Display{--fs-min:4.2rem;--fs-max:5.6rem;font-weight:800}.Title.Display:before{content:"";display:block;height:0;margin-top:calc((1 - var(--lh))*.6em);width:0}.Title[data-title-responsive=true]{font-size:var(--fs-min)}@media (min-width:48em){.Title[data-title-responsive=true]{font-size:var(--fs-max)}}
@@ -1,8 +1,18 @@
1
1
  import { IconButton, IconButtonProps, Polymorphic } from '../';
2
2
  import { Except } from 'type-fest';
3
3
  export declare type ToggleButtonProps = Except<IconButtonProps, 'icon'> & {
4
+ /**
5
+ * Set the icon to show when the button is resting.
6
+ */
4
7
  restingIcon: IconButtonProps['icon'];
8
+ /**
9
+ * Set the icon to show when the button is pressed/active.
10
+ */
5
11
  pressedIcon?: IconButtonProps['icon'];
12
+ /**
13
+ * Set the pressed state of the button. If `pressedIcon` is set,
14
+ * the icon will be shown instead of the resting icon.
15
+ */
6
16
  pressed?: boolean;
7
17
  };
8
18
  declare type PolymorphicToggleButton = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof IconButton>, Polymorphic.OwnProps<typeof IconButton> & ToggleButtonProps>;
@@ -1,4 +1,5 @@
1
- import React, { forwardRef, useCallback, useEffect, useState } from 'react';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useCallback, useEffect, useState } from 'react';
2
3
  import { ToggleButton as ToggleButtonClass } from './toggle-button.module.css';
3
4
  import { IconButton, Icon } from '../';
4
5
  import clsx from 'clsx';
@@ -37,9 +38,9 @@ export const ToggleButton = forwardRef(({ className, restingIcon, pressedIcon, d
37
38
  regular: 16,
38
39
  small: 16
39
40
  };
40
- return (React.createElement(Icon, { name: icon, dimension: iconSize[dimension] }));
41
+ return (_jsx(Icon, { name: icon, dimension: iconSize[dimension] }, void 0));
41
42
  }, []);
42
- return (React.createElement(IconButton, { as: "button", ref: forwardedRef, dimension: dimension, "aria-pressed": isPressed, kind: kind, disabled: disabled, onClick: handleClick, className: clsx(ToggleButtonClass, className), ...otherProps }, isPressed && pressedIcon
43
- ? (React.createElement(motion.span, { key: "pressedIcon", variants: scaleAnimation, initial: firstRender && isPressed ? false : 'scaleOut', animate: "scaleIn" }, renderIcon(pressedIcon, dimension)))
44
- : restingIcon && (React.createElement(motion.span, { key: "restingIcon", variants: scaleAnimation, initial: firstRender && !isPressed ? false : 'scaleOut', animate: "scaleIn" }, renderIcon(restingIcon, dimension)))));
43
+ return (_jsx(IconButton, { as: "button", ref: forwardedRef, dimension: dimension, "aria-pressed": isPressed, kind: kind, disabled: disabled, onClick: handleClick, className: clsx(ToggleButtonClass, className), ...otherProps, children: isPressed && pressedIcon
44
+ ? (_jsx(motion.span, { variants: scaleAnimation, initial: firstRender && isPressed ? false : 'scaleOut', animate: "scaleIn", children: renderIcon(pressedIcon, dimension) }, "pressedIcon"))
45
+ : restingIcon && (_jsx(motion.span, { variants: scaleAnimation, initial: firstRender && !isPressed ? false : 'scaleOut', animate: "scaleIn", children: renderIcon(restingIcon, dimension) }, "restingIcon")) }, void 0));
45
46
  });
@@ -1,12 +1,44 @@
1
1
  import { FC, ReactNode } from 'react';
2
2
  import { AutoPlacement, BasePlacement, VariationPlacement } from '@popperjs/core/lib';
3
3
  export declare type TooltipProps = PropsWithClass & {
4
+ /**
5
+ * Pass the content of the tooltip. It can be any valid React node.
6
+ */
4
7
  children: ReactNode;
8
+ /**
9
+ * Set the element that will be used as the trigger of the tooltip.
10
+ */
5
11
  trigger: ReactNode;
12
+ /**
13
+ * The placement of the tooltip. This is automatically handled based on
14
+ * scroll and viewport edges.
15
+ *
16
+ * The first key refers to the X axis, the second key refers to the Y axis.
17
+ * Eg: `auto-start` means the dropdown will be placed automatically on left or right
18
+ * based on the available space, and anchored at the top (start) of the trigger.
19
+ */
6
20
  placement?: AutoPlacement | BasePlacement | VariationPlacement;
7
- show?: boolean;
21
+ /**
22
+ * Set if the tooltip should be shown or hidden.
23
+ */
24
+ open?: boolean;
25
+ /**
26
+ * Define a delay time before the tooltip is shown.
27
+ */
8
28
  delay?: number;
29
+ /**
30
+ * Set the max width of the tooltip. This prevents the tooltip content
31
+ * from filling the whole screen.
32
+ */
9
33
  maxWidth?: string;
34
+ /**
35
+ * Make the tooltip interactive.
36
+ * This will allow the user to interact with the tooltip content.
37
+ */
38
+ interactive?: boolean;
39
+ /**
40
+ * Set the trigger container to behave like inline or block element
41
+ */
10
42
  fill?: boolean;
11
43
  };
12
44
  export declare const Tooltip: FC<TooltipProps>;
@@ -1,45 +1,42 @@
1
- import React, { Children, cloneElement, useState } from 'react';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Children, cloneElement, useState, useRef } from 'react';
2
3
  import { useUIDSeed } from 'react-uid';
3
- import { useKey } from 'react-use';
4
+ import { useKeyPress, useFocusWithin } from 'ahooks';
4
5
  import { Elevator } from '../';
5
- import { useFocusWithin } from '@react-aria/interactions';
6
- import { Tooltip as TooltipClass, Arrow, Trigger } from './tooltip.module.css';
6
+ import { Tooltip as TooltipClass, Balloon, Arrow } from './tooltip.module.css';
7
7
  import { usePopperTooltip } from 'react-popper-tooltip';
8
- export const Tooltip = ({ children, trigger, placement = 'bottom-start', show, style, maxWidth = '40ch', fill = false, delay = 500 }) => {
8
+ export const Tooltip = ({ children, trigger, placement = 'bottom-start', open, style, maxWidth = '40ch', fill = false, interactive = false, delay = 500 }) => {
9
9
  const seedID = useUIDSeed();
10
- const [controlledVisible, setControlledVisible] = useState(false);
11
- useKey('Escape', () => setControlledVisible(false));
10
+ const [isOpen, setIsOpen] = useState(false);
11
+ const tooltipContainerRef = useRef(null);
12
+ useKeyPress('esc', () => setIsOpen(false));
12
13
  const { getArrowProps, getTooltipProps, setTooltipRef, setTriggerRef, visible } = usePopperTooltip({
13
14
  delayShow: delay,
14
- delayHide: 200,
15
- trigger: ['hover', 'focus'],
16
- visible: show || controlledVisible,
15
+ delayHide: 300,
16
+ trigger: ['hover'],
17
+ visible: open || isOpen,
17
18
  closeOnTriggerHidden: true,
18
- onVisibleChange: setControlledVisible,
19
+ interactive: interactive,
20
+ onVisibleChange: setIsOpen,
19
21
  placement: placement,
20
22
  offset: [0, 16]
21
23
  }, {
22
24
  strategy: 'fixed'
23
25
  });
24
- const { focusWithinProps } = useFocusWithin({
25
- onFocusWithin: () => {
26
- setControlledVisible(true);
26
+ const isFocusWithin = useFocusWithin(tooltipContainerRef, {
27
+ onFocus: () => {
28
+ setIsOpen(true);
27
29
  },
28
- onBlurWithin: () => {
29
- setControlledVisible(false);
30
- },
31
- onFocusWithinChange: () => null
30
+ onBlur: (e) => {
31
+ (e.target?.parentElement !== tooltipContainerRef.current) && setIsOpen(false);
32
+ }
32
33
  });
33
34
  const dynamycStyle = {
34
35
  '--maxW': maxWidth
35
36
  };
36
- return (React.createElement("div", { "data-tooltip-fill": fill, className: Trigger, ...focusWithinProps, style: { ...style } },
37
- Children.map(trigger, (child) => cloneElement(child, {
38
- ref: setTriggerRef,
39
- 'aria-describedby': seedID('tooltip-content')
40
- })),
41
- visible && (React.createElement(Elevator, { resting: 2 },
42
- React.createElement("div", { ref: setTooltipRef, role: "tooltip", id: seedID('tooltip-content'), "data-theme": "dark", ...getTooltipProps({ className: TooltipClass, style: dynamycStyle }) },
43
- children,
44
- React.createElement("div", { ...getArrowProps({ className: Arrow }) }))))));
37
+ return (_jsxs("div", { "data-tooltip-fill": fill, className: TooltipClass, ref: tooltipContainerRef, "data-tooltip-has-focus-within": isFocusWithin, style: { ...style }, children: [Children.map(trigger, (child) => cloneElement(child, {
38
+ ref: setTriggerRef,
39
+ tabIndex: 0,
40
+ 'aria-describedby': seedID('tooltip-content')
41
+ })), visible && (_jsx(Elevator, { resting: 1, children: _jsxs("div", { ref: setTooltipRef, role: "tooltip", id: seedID('tooltip-content'), "data-theme": "dark", ...getTooltipProps({ className: Balloon, style: dynamycStyle }), children: [children, _jsx("div", { ...getArrowProps({ className: Arrow }) }, void 0)] }, void 0) }, void 0))] }, void 0));
45
42
  };
@@ -1 +1 @@
1
- .Tooltip{word-wrap:break-word;background-color:#31363f;border-radius:.22rem;font-size:.89rem;max-inline-size:var(--maxW);padding:.44rem .89rem;position:relative;z-index:2}.Tooltip[data-popper-reference-hidden=true]{pointer-events:none;visibility:hidden}.Trigger{display:inline-flex}.Trigger[data-tooltip-fill=true]{display:flex}.Arrow:before{background-color:#31363f;block-size:12px;content:"";inline-size:12px;position:absolute;transform:rotate(45deg);visibility:visible}.Tooltip[data-popper-reference-hidden=true] .Arrow{pointer-events:none;visibility:hidden}.Tooltip[data-popper-placement^=top] .Arrow{bottom:6px}.Tooltip[data-popper-placement^=top] .Arrow:before{transform:translateX(-50%) rotate(45deg)}.Tooltip[data-popper-placement^=left] .Arrow{right:6px}.Tooltip[data-popper-placement^=left] .Arrow:before{transform:translateY(-50%) rotate(45deg)}.Tooltip[data-popper-placement^=bottom] .Arrow{top:-6px}.Tooltip[data-popper-placement^=bottom] .Arrow:before{transform:translateX(-50%) rotate(45deg)}.Tooltip[data-popper-placement^=right] .Arrow{left:-6px}.Tooltip[data-popper-placement^=right] .Arrow:before{transform:translateY(-50%) rotate(45deg)}
1
+ .Tooltip{display:contents}.Balloon{word-wrap:break-word;background-color:#31363f;border-radius:.22rem;font-size:.89rem;max-inline-size:var(--maxW);padding:.44rem .89rem;position:relative;z-index:2}.Balloon[data-popper-reference-hidden=true]{pointer-events:none;visibility:hidden}.Arrow:before{background-color:#31363f;block-size:12px;content:"";inline-size:12px;position:absolute;transform:rotate(45deg);visibility:visible}.Balloon[data-popper-reference-hidden=true] .Arrow{pointer-events:none;visibility:hidden}.Balloon[data-popper-placement^=top] .Arrow{bottom:6px}.Balloon[data-popper-placement^=top] .Arrow:before{transform:translateX(-50%) rotate(45deg)}.Balloon[data-popper-placement^=left] .Arrow{right:6px}.Balloon[data-popper-placement^=left] .Arrow:before{transform:translateY(-50%) rotate(45deg)}.Balloon[data-popper-placement^=bottom] .Arrow{top:-6px}.Balloon[data-popper-placement^=bottom] .Arrow:before{transform:translateX(-50%) rotate(45deg)}.Balloon[data-popper-placement^=right] .Arrow{left:-6px}.Balloon[data-popper-placement^=right] .Arrow:before{transform:translateY(-50%) rotate(45deg)}
@@ -1,21 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { IconNames } from '../icons/types';
3
- import { Polymorphic } from '../';
4
- export declare type DropdownItemProps = {
5
- children: ReactNode;
6
- icon?: IconNames;
7
- dimension?: 'small' | 'regular';
8
- onClick?(): void;
9
- iconPosition?: 'left' | 'right';
10
- description?: ReactNode;
11
- disabled?: boolean;
12
- padding?: boolean;
13
- };
14
- declare type PolymorphicDropdownItem = Polymorphic.ForwardRefComponent<'button', DropdownItemProps>;
15
- export declare const DropdownItem: PolymorphicDropdownItem;
16
- export declare type DropdownItemCheckboxProps = DropdownItemProps & {
17
- checked?: boolean;
18
- };
19
- declare type PolymorphicDropdownItemCheckbox = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof DropdownItem>, Polymorphic.OwnProps<typeof DropdownItem> & DropdownItemCheckboxProps>;
20
- export declare const DropdownItemCheckbox: PolymorphicDropdownItemCheckbox;
21
- export {};
@@ -1,26 +0,0 @@
1
- import React, { useCallback, forwardRef, useRef, useMemo } from 'react';
2
- import { useRovingTabIndex, useFocusEffect } from 'react-roving-tabindex';
3
- import { DropdownItem as DropdownItemClass, Icon as IconClass } from './dropdown-item.module.css';
4
- import { Tooltip, Stack, Icon } from '../';
5
- import clsx from 'clsx';
6
- export const DropdownItem = forwardRef(({ className, children, onClick, icon, dimension = 'regular', as: Wrapper = 'button', iconPosition = 'left', description, padding = true, disabled = false, ...props }, forwardedRef) => {
7
- const itemRef = useRef(forwardedRef);
8
- const [tabIndex, focused, handleKeyDown, handleClick] = useRovingTabIndex(itemRef, disabled);
9
- const isIconRight = iconPosition === 'right';
10
- useFocusEffect(focused, itemRef);
11
- const triggerClick = useCallback(() => {
12
- if (onClick) {
13
- handleClick();
14
- onClick();
15
- }
16
- }, [handleClick, onClick]);
17
- const InnerContent = useMemo(() => (React.createElement(Stack, { direction: "row", as: "span", fill: false, horizontalAlign: isIconRight ? 'space-between' : 'start', verticalAlign: "center", columnGap: 8, horizontalPadding: 16, verticalPadding: 8, "data-dropdown-icon-right": isIconRight, "data-dropdown-has-icon": Boolean(icon), "data-dropdown-padding": padding, style: { inlineSize: '100%' } },
18
- icon && (React.createElement(Icon, { className: IconClass, name: icon, dimension: dimension === 'small' ? 14 : 16 })),
19
- children)), [children, dimension, icon, isIconRight, padding]);
20
- return (React.createElement(Wrapper, { ref: itemRef, role: "menuitem", className: clsx(DropdownItemClass, className), onClick: disabled ? undefined : triggerClick, onKeyDown: disabled ? undefined : handleKeyDown, tabIndex: tabIndex, "aria-disabled": disabled, type: Wrapper === 'button' ? 'button' : undefined, "data-dropdown-item-dimension": dimension, ...props }, description
21
- ? (React.createElement(Tooltip, { fill: true, show: focused, placement: "right-start", trigger: InnerContent }, description))
22
- : InnerContent));
23
- });
24
- DropdownItem.displayName = 'Dropdown.Item';
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 +0,0 @@
1
- .DropdownItem{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%;line-height:1.2;position:relative;text-align:start}.DropdownItem[aria-checked=true]{color:var(--global-interactive-text)}.DropdownItem:before{border-radius:.22rem;bottom:0;content:"";left:.44rem;opacity:60%;position:absolute;right:.44rem;top:0}.DropdownItem:is(:hover,.focus-visible,[aria-pressed=true]):not([aria-disabled=true]){outline:none}.DropdownItem:is(:hover,:focus-visible,[aria-pressed=true]):not([aria-disabled=true]){outline:none}.DropdownItem:is(:hover,.focus-visible,[aria-pressed=true]):not([aria-disabled=true]):before{background-color:var(--dimmed-1)}.DropdownItem:is(:hover,:focus-visible,[aria-pressed=true]):not([aria-disabled=true]):before{background-color:var(--dimmed-1)}.DropdownItem[data-dropdown-item-dimension=small]{font-size:.78rem}.DropdownItem>*{position:relative}.DropdownItem[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}.DropdownItem [data-dropdown-padding=true][data-dropdown-has-icon=false][data-dropdown-icon-right=false]{padding-left:2.22rem}.DropdownItem [data-dropdown-padding=true][data-dropdown-has-icon=false][data-dropdown-icon-right=true]{padding-right:2.22rem}[data-dropdown-icon-right=true] .Icon{order:2}
@@ -1,7 +0,0 @@
1
- import React, { ReactNode, HTMLAttributes } from 'react';
2
- export declare type DropdownMenuProps = HTMLAttributes<HTMLUListElement> & {
3
- children: ReactNode;
4
- };
5
- export declare const DropdownMenu: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLUListElement> & {
6
- children: ReactNode;
7
- } & React.RefAttributes<HTMLUListElement>>;
@@ -1,17 +0,0 @@
1
- import React, { Children, cloneElement, forwardRef } from 'react';
2
- import { RovingTabIndexProvider } from 'react-roving-tabindex';
3
- import { Stack, Elevator } from '../';
4
- import clsx from 'clsx';
5
- import { DropdownMenu as DropdownMenuClass } from './dropdown-menu.module.css';
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
- });
17
- DropdownMenu.displayName = 'Dropdown.Menu';
@@ -1 +0,0 @@
1
- .DropdownMenu{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}.DropdownMenu hr{margin:0 .44rem}
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- export declare type GridItemProps = PropsWithClass & {
3
- fullWidth?: boolean;
4
- column?: string;
5
- row?: string;
6
- };
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 DELETED
@@ -1,11 +0,0 @@
1
- import React, { forwardRef } from 'react';
2
- import clsx from 'clsx';
3
- import { GridItem as GridItemClass } from './grid.module.css';
4
- export const GridItem = forwardRef(({ children, style, className, fullWidth = false, column, row, ...otherProps }, forwardedRef) => {
5
- const dynamicStyle = {
6
- '--column': column,
7
- '--row': row
8
- };
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';
@@ -1,9 +0,0 @@
1
- import React, { PropsWithChildren } from 'react';
2
- import { ModalProps } from '../modal';
3
- declare type ModalContextProps = Partial<ModalProps> & {
4
- titleId?: string;
5
- };
6
- export declare const ModalContext: React.Context<ModalContextProps>;
7
- export declare const ModalProvider: (props: PropsWithChildren<ModalContextProps>) => JSX.Element;
8
- export declare const useModalContext: () => ModalContextProps;
9
- export {};
@@ -1,22 +0,0 @@
1
- import React, { createContext, useContext } from 'react';
2
- import { useUIDSeed } from 'react-uid';
3
- export const ModalContext = createContext({
4
- titleId: '',
5
- onClose: () => { }
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
- };
16
- export const useModalContext = () => {
17
- const context = useContext(ModalContext);
18
- if (!context) {
19
- throw new Error('Modal component must be used inside ModalContext to access context data.');
20
- }
21
- return context;
22
- };
@@ -1,2 +0,0 @@
1
- export { ThemeSwitch } from './theme-switch';
2
- export type { ThemeSwitchProps } from './theme-switch';
@@ -1 +0,0 @@
1
- export { ThemeSwitch } from './theme-switch';
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import { SelectProps } from '../';
3
- import { Except } from 'type-fest';
4
- export declare type ThemeSwitchProps = Except<SelectProps, 'children'> & {
5
- currentTheme?: string;
6
- onChange: SelectProps['onChange'];
7
- dimension?: SelectProps['dimension'];
8
- };
9
- export declare const ThemeSwitch: ({ className, currentTheme, onChange, dimension }: ThemeSwitchProps) => JSX.Element;
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- import { Select } from '../';
3
- import clsx from 'clsx';
4
- export const ThemeSwitch = ({ className, currentTheme = 'system', onChange, dimension }) => {
5
- const icon = {
6
- light: 'sun-bright',
7
- system: 'pc',
8
- dark: 'moon'
9
- };
10
- return (React.createElement(Select, { dimension: dimension, onChange: onChange, icon: currentTheme === 'system' ? icon.system : icon[currentTheme], defaultValue: currentTheme, className: clsx(className), "aria-label": "Change color scheme" },
11
- React.createElement("option", { value: "light" }, "Light"),
12
- React.createElement("option", { value: "system" }, "System"),
13
- React.createElement("option", { value: "dark" }, "Dark")));
14
- };