reshaped 3.7.3 → 3.8.0-canary.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 (94) hide show
  1. package/CHANGELOG-extra.md +3 -0
  2. package/CHANGELOG.md +40 -55
  3. package/LICENSE.md +1 -1
  4. package/README.md +24 -0
  5. package/dist/bundle.css +1 -1
  6. package/dist/bundle.js +10 -10
  7. package/dist/cjs/themes/index.d.ts +1 -0
  8. package/dist/cjs/themes/index.js +3 -1
  9. package/dist/components/Accordion/Accordion.types.d.ts +13 -2
  10. package/dist/components/ActionBar/ActionBar.types.d.ts +10 -0
  11. package/dist/components/Actionable/Actionable.types.d.ts +14 -0
  12. package/dist/components/Alert/Alert.types.d.ts +11 -0
  13. package/dist/components/Autocomplete/Autocomplete.js +2 -0
  14. package/dist/components/Autocomplete/Autocomplete.types.d.ts +7 -0
  15. package/dist/components/Autocomplete/tests/Autocomplete.stories.js +5 -1
  16. package/dist/components/Avatar/Avatar.types.d.ts +18 -0
  17. package/dist/components/Avatar/tests/Avatar.stories.js +1 -1
  18. package/dist/components/Badge/Badge.types.d.ts +25 -1
  19. package/dist/components/Badge/tests/Badge.test.stories.js +3 -1
  20. package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +11 -0
  21. package/dist/components/Button/Button.types.d.ts +20 -0
  22. package/dist/components/Calendar/Calendar.types.d.ts +31 -0
  23. package/dist/components/Calendar/tests/Calendar.stories.js +1 -1
  24. package/dist/components/Card/Card.types.d.ts +12 -0
  25. package/dist/components/Carousel/Carousel.types.d.ts +13 -0
  26. package/dist/components/Checkbox/Checkbox.types.d.ts +19 -0
  27. package/dist/components/Checkbox/tests/Checkbox.stories.js +1 -1
  28. package/dist/components/CheckboxGroup/CheckboxGroup.types.d.ts +10 -0
  29. package/dist/components/Container/Container.types.d.ts +11 -1
  30. package/dist/components/Dismissible/Dismissible.types.d.ts +10 -0
  31. package/dist/components/Divider/Divider.types.d.ts +6 -0
  32. package/dist/components/DropdownMenu/DropdownMenu.types.d.ts +3 -0
  33. package/dist/components/FileUpload/FileUpload.types.d.ts +10 -0
  34. package/dist/components/Flyout/Flyout.types.d.ts +38 -0
  35. package/dist/components/Flyout/FlyoutContent.js +1 -1
  36. package/dist/components/FormControl/FormControl.types.d.ts +9 -0
  37. package/dist/components/Grid/Grid.js +3 -1
  38. package/dist/components/Grid/Grid.module.css +1 -1
  39. package/dist/components/Grid/Grid.types.d.ts +31 -0
  40. package/dist/components/Grid/tests/Grid.stories.d.ts +3 -0
  41. package/dist/components/Grid/tests/Grid.stories.js +39 -1
  42. package/dist/components/Hidden/Hidden.types.d.ts +4 -0
  43. package/dist/components/HiddenVisually/HiddenVisually.types.d.ts +1 -0
  44. package/dist/components/Hotkey/Hotkey.types.d.ts +4 -0
  45. package/dist/components/Icon/Icon.types.d.ts +6 -0
  46. package/dist/components/Image/Image.types.d.ts +15 -0
  47. package/dist/components/Link/Link.types.d.ts +7 -0
  48. package/dist/components/Loader/Loader.types.d.ts +5 -0
  49. package/dist/components/MenuItem/MenuItem.types.d.ts +13 -1
  50. package/dist/components/Modal/Modal.types.d.ts +19 -0
  51. package/dist/components/NumberField/NumberField.types.d.ts +10 -0
  52. package/dist/components/Overlay/Overlay.types.d.ts +13 -0
  53. package/dist/components/Pagination/Pagination.types.d.ts +11 -29
  54. package/dist/components/PinField/PinField.types.d.ts +13 -0
  55. package/dist/components/Popover/Popover.types.d.ts +3 -0
  56. package/dist/components/Progress/Progress.types.d.ts +9 -0
  57. package/dist/components/ProgressIndicator/ProgressIndicator.js +13 -84
  58. package/dist/components/ProgressIndicator/ProgressIndicator.module.css +1 -1
  59. package/dist/components/ProgressIndicator/ProgressIndicator.types.d.ts +8 -0
  60. package/dist/components/ProgressIndicator/tests/ProgressIndicator.stories.js +8 -1
  61. package/dist/components/Radio/Radio.types.d.ts +12 -0
  62. package/dist/components/RadioGroup/RadioGroup.types.d.ts +14 -0
  63. package/dist/components/Reshaped/Reshaped.types.d.ts +12 -0
  64. package/dist/components/Resizable/Resizable.types.d.ts +7 -0
  65. package/dist/components/Scrim/Scrim.types.d.ts +6 -1
  66. package/dist/components/ScrollArea/ScrollArea.types.d.ts +7 -0
  67. package/dist/components/Select/Select.types.d.ts +27 -0
  68. package/dist/components/Skeleton/Skeleton.types.d.ts +2 -0
  69. package/dist/components/Slider/Slider.types.d.ts +56 -0
  70. package/dist/components/Stepper/Stepper.types.d.ts +13 -0
  71. package/dist/components/Switch/Switch.types.d.ts +16 -0
  72. package/dist/components/Table/Table.types.d.ts +29 -0
  73. package/dist/components/Tabs/Tabs.module.css +1 -1
  74. package/dist/components/Tabs/Tabs.types.d.ts +24 -0
  75. package/dist/components/Tabs/TabsItem.js +2 -2
  76. package/dist/components/Tabs/tests/Tabs.stories.js +6 -6
  77. package/dist/components/Text/Text.types.d.ts +12 -0
  78. package/dist/components/TextArea/TextArea.types.d.ts +17 -0
  79. package/dist/components/TextField/TextField.types.d.ts +29 -0
  80. package/dist/components/Theme/Theme.js +4 -1
  81. package/dist/components/Theme/Theme.types.d.ts +5 -0
  82. package/dist/components/Timeline/Timeline.types.d.ts +7 -0
  83. package/dist/components/Toast/Toast.types.d.ts +18 -0
  84. package/dist/components/ToggleButton/ToggleButton.types.d.ts +9 -0
  85. package/dist/components/ToggleButtonGroup/ToggleButtonGroup.types.d.ts +8 -0
  86. package/dist/components/Tooltip/Tooltip.types.d.ts +5 -0
  87. package/dist/components/View/View.types.d.ts +56 -1
  88. package/dist/components/_private/Aligner/Aligner.types.d.ts +6 -0
  89. package/dist/themes/index.d.ts +1 -0
  90. package/dist/themes/index.js +1 -0
  91. package/package.json +21 -17
  92. package/LICENSE-SOURCE.md +0 -40
  93. package/dist/components/Grid/tests/Grid.test.stories.d.ts +0 -23
  94. package/dist/components/Grid/tests/Grid.test.stories.js +0 -42
@@ -19,4 +19,5 @@ export type { Name as ViewportTokenName } from "./_generator/tokens/viewport/vie
19
19
  */
20
20
  export { default as baseThemeDefinition } from "./_generator/definitions/reshaped";
21
21
  export { default as generateThemeColors } from "./_generator/tokens/color/utilities/generateColors";
22
+ export { default as transform } from "./_generator/transform";
22
23
  export declare const getThemeCSS: (name: string, definition: PassedThemeDefinition, options?: T.PublicOptions["themeOptions"]) => string;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getThemeCSS = exports.generateThemeColors = exports.baseThemeDefinition = void 0;
6
+ exports.getThemeCSS = exports.transform = exports.generateThemeColors = exports.baseThemeDefinition = void 0;
7
7
  const transform_1 = __importDefault(require("./_generator/transform"));
8
8
  /**
9
9
  * Exported runtime code
@@ -12,6 +12,8 @@ var reshaped_1 = require("./_generator/definitions/reshaped");
12
12
  Object.defineProperty(exports, "baseThemeDefinition", { enumerable: true, get: function () { return __importDefault(reshaped_1).default; } });
13
13
  var generateColors_1 = require("./_generator/tokens/color/utilities/generateColors");
14
14
  Object.defineProperty(exports, "generateThemeColors", { enumerable: true, get: function () { return __importDefault(generateColors_1).default; } });
15
+ var transform_2 = require("./_generator/transform");
16
+ Object.defineProperty(exports, "transform", { enumerable: true, get: function () { return __importDefault(transform_2).default; } });
15
17
  const getThemeCSS = (name, definition, options) => {
16
18
  const code = (0, transform_1.default)(name, definition, { themeOptions: options, isFragment: true });
17
19
  return code.variables;
@@ -1,18 +1,24 @@
1
1
  import type React from "react";
2
2
  import type { IconProps } from "../Icon";
3
3
  import type * as G from "../../types/global";
4
- import type * as S from "../../styles/types";
5
4
  export type BaseProps = {
5
+ /** Expand / collapse icon size in units */
6
6
  iconSize?: IconProps["size"];
7
+ /** Position of the expand / collapse icon */
7
8
  iconPosition?: "start" | "end";
9
+ /** Gap between the trigger and the content */
8
10
  gap?: G.Responsive<number>;
11
+ /** Node for inserting the trigger and the content */
9
12
  children?: React.ReactNode;
13
+ /** Callback when the accordion is expanded or collapsed */
10
14
  onToggle?: (active: boolean) => void;
11
- mixin?: Pick<S.Mixin, "margin">;
15
+ /** Additional classname for the root element */
12
16
  className?: G.ClassName;
17
+ /** Additional attributes for the root element */
13
18
  attributes?: G.Attributes<"div">;
14
19
  };
15
20
  export type TriggerProps = {
21
+ /** Node or render function for inserting the trigger */
16
22
  children?: ((attributes: {
17
23
  "aria-expanded": boolean;
18
24
  "aria-controls": string;
@@ -23,14 +29,19 @@ export type TriggerProps = {
23
29
  }) => React.ReactNode) | React.ReactNode;
24
30
  };
25
31
  export type ContentProps = {
32
+ /** Node for inserting the expandable content */
26
33
  children?: React.ReactNode;
27
34
  };
28
35
  export type ControlledProps = BaseProps & {
36
+ /** Control whether the accordion is expanded or collapsed, enables controlled mode */
29
37
  active: boolean;
38
+ /** Control whether the accordion is expanded or collapsed by default, enables uncontrolled mode */
30
39
  defaultActive?: never;
31
40
  };
32
41
  export type UncontrolledProps = BaseProps & {
42
+ /** Control whether the accordion is expanded or collapsed, enables controlled mode */
33
43
  active?: never;
44
+ /** Control whether the accordion is expanded or collapsed by default, enables uncontrolled mode */
34
45
  defaultActive?: boolean;
35
46
  };
36
47
  export type Props = ControlledProps | UncontrolledProps;
@@ -2,12 +2,22 @@ import type React from "react";
2
2
  import type { ViewProps } from "../View";
3
3
  import type * as G from "../../types/global";
4
4
  export type Props = Pick<ViewProps, "paddingBlock" | "paddingInline" | "padding"> & {
5
+ /** Show or hide the component */
5
6
  active?: boolean;
7
+ /** Offset from the container bounds */
6
8
  offset?: G.Responsive<number>;
9
+ /** Position based on the container bounds
10
+ * @default "bottom"
11
+ */
7
12
  position?: "top" | "top-end" | "top-start" | "bottom" | "bottom-start" | "bottom-end";
13
+ /** CSS position style */
8
14
  positionType?: G.Responsive<"relative" | "absolute" | "fixed">;
15
+ /** Display above the content with elevated shadow and background */
9
16
  elevated?: boolean;
17
+ /** Node for inserting the content */
10
18
  children?: React.ReactNode;
19
+ /** Additional classname for the root element */
11
20
  className?: G.ClassName;
21
+ /** Additional attributes for the root element */
12
22
  attributes?: G.Attributes<"div">;
13
23
  };
@@ -1,19 +1,33 @@
1
1
  import type React from "react";
2
2
  import type * as G from "../../types/global";
3
3
  export type Props = {
4
+ /** Node for inserting the content */
4
5
  children?: React.ReactNode;
6
+ /** Callback when clicked, renders it as a button tag if href is not provided */
5
7
  onClick?: (e: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void;
8
+ /** URL, renders it as an anchor tag */
6
9
  href?: string;
10
+ /** Type attribute, renders it as a button tag */
7
11
  type?: React.ButtonHTMLAttributes<HTMLButtonElement>["type"];
12
+ /** Disable from user interaction */
8
13
  disabled?: boolean;
14
+ /** Enable a minimum required touch hitbox */
9
15
  touchHitbox?: boolean;
16
+ /** Take up the full width of its parent */
10
17
  fullWidth?: boolean;
18
+ /** Enable a focus ring inside the element bounds */
11
19
  insetFocus?: boolean;
20
+ /** Don't show a focus ring on focus, can be used when it is within a container with a focus ring */
12
21
  disableFocusRing?: boolean;
22
+ /** Apply the focus ring to the child and rely on its border radius */
13
23
  borderRadius?: "inherit";
24
+ /** Prevent the event from bubbling up to the parent */
14
25
  stopPropagation?: boolean;
26
+ /** Render as a different element */
15
27
  as?: keyof React.JSX.IntrinsicElements;
28
+ /** Additional classname for the root element */
16
29
  className?: G.ClassName;
30
+ /** Additional attributes for the root element */
17
31
  attributes?: G.Attributes<"button"> & Omit<React.JSX.IntrinsicElements["a"], keyof G.Attributes<"button">> & {
18
32
  ref?: React.RefObject<HTMLButtonElement | HTMLAnchorElement | null>;
19
33
  };
@@ -2,13 +2,24 @@ import type React from "react";
2
2
  import type { IconProps } from "../Icon";
3
3
  import type * as G from "../../types/global";
4
4
  export type Props = {
5
+ /** SVG component for the icon */
5
6
  icon?: IconProps["svg"];
7
+ /** Title slot */
6
8
  title?: React.ReactNode;
9
+ /** Slot for rendering the main content */
7
10
  children?: React.ReactNode;
11
+ /** Actions slot, usually used for Buttons and Links, automatically adds a gap between the actions */
8
12
  actionsSlot?: React.ReactNode;
13
+ /** Color scheme of the alert elements
14
+ * @default "neutral"
15
+ */
9
16
  color?: "neutral" | "critical" | "warning" | "positive" | "primary";
17
+ /** Display action to the right of the content */
10
18
  inline?: boolean;
19
+ /** Apply negative margin and remove side borders, base unit token number multiplier */
11
20
  bleed?: G.Responsive<number>;
21
+ /** Additional classname for the root element */
12
22
  className?: G.ClassName;
23
+ /** Additional attributes for the root element */
13
24
  attributes?: G.Attributes<"div">;
14
25
  };
@@ -85,6 +85,8 @@ const Autocomplete = (props) => {
85
85
  [keys.BACKSPACE]: () => {
86
86
  onBackspaceRef.current?.();
87
87
  },
88
+ }, [getOptionElements, onEnterRef, onBackspaceRef, highlightedId], { ref: inputRef });
89
+ useHotkeys({
88
90
  [keys.UP]: () => {
89
91
  const options = getOptionElements();
90
92
  if (options.length) {
@@ -2,14 +2,21 @@ import type { TextFieldProps } from "../TextField";
2
2
  import type { MenuItemProps } from "../MenuItem";
3
3
  import type { DropdownMenuProps, DropdownMenuInstance } from "../DropdownMenu";
4
4
  type SelectArgs = {
5
+ /** Value that will be passed to the input on selection */
5
6
  value: string;
7
+ /** Additional data that will be passed to the onItemSelect callback */
6
8
  data?: unknown;
7
9
  };
8
10
  export type Props = TextFieldProps & Pick<DropdownMenuProps, "containerRef" | "instanceRef" | "active" | "onOpen" | "onClose"> & {
11
+ /** Callback for when value changes from user input */
9
12
  onInput?: TextFieldProps["onChange"];
13
+ /** Callback for when an item is selected in the dropdown */
10
14
  onItemSelect?: (args: SelectArgs) => void;
15
+ /** Callback for when the backspace key is pressed while the input is focused */
11
16
  onBackspace?: () => void;
17
+ /** Callback for when the enter key is pressed while the input is focused */
12
18
  onEnter?: () => void;
19
+ /** Slot for rendering the Autocomplete.Item components */
13
20
  children: React.ReactNode;
14
21
  };
15
22
  export type ItemProps = MenuItemProps & SelectArgs;
@@ -223,7 +223,11 @@ export const multiselect = {
223
223
  </Badge>));
224
224
  return (<FormControl>
225
225
  <FormControl.Label>Food</FormControl.Label>
226
- <Autocomplete name="fruit" value={query} placeholder="Pick your food" startSlot={valuesNode} multiline inputAttributes={{ ref: inputRef }} onChange={(args) => setQuery(args.value)} onItemSelect={(args) => {
226
+ <Autocomplete name="fruit" value={query} placeholder="Pick your food" startSlot={valuesNode} multiline inputAttributes={{ ref: inputRef }} onChange={(args) => setQuery(args.value)} onBackspace={() => {
227
+ if (query.length === 0) {
228
+ setValues((prev) => prev.slice(0, -1));
229
+ }
230
+ }} onItemSelect={(args) => {
227
231
  setQuery("");
228
232
  setValues((prev) => [...prev, args.value]);
229
233
  }}>
@@ -1,19 +1,37 @@
1
1
  import type { IconProps } from "../Icon";
2
2
  import type * as G from "../../types/global";
3
3
  export type Props = {
4
+ /** Image URL */
4
5
  src?: string;
6
+ /** Image alt text */
5
7
  alt?: string;
8
+ /** Additional attributes for the image element */
6
9
  imageAttributes?: G.Attributes<"img">;
10
+ /** Render prop for the image element, useful for integrating with the Image component from third party frameworks */
7
11
  renderImage?: (attributes: Omit<G.Attributes<"img">, "src" | "alt"> & {
8
12
  src: string;
9
13
  alt: string;
10
14
  }) => React.ReactNode;
15
+ /** Initials to display if no image is provided */
11
16
  initials?: string;
17
+ /** SVG component for the icon, used when no image is provided */
12
18
  icon?: IconProps["svg"];
19
+ /** Change the shape to rounded square */
13
20
  squared?: boolean;
21
+ /** Component render variant
22
+ * @default "solid"
23
+ */
14
24
  variant?: "solid" | "faded";
25
+ /** Component color scheme
26
+ * @default "neutral"
27
+ */
15
28
  color?: "neutral" | "critical" | "warning" | "positive" | "primary";
29
+ /** Size of the component, base unit token number multiplier
30
+ * @default 12
31
+ */
16
32
  size?: G.Responsive<number>;
33
+ /** Additional classname for the root element */
17
34
  className?: G.ClassName;
35
+ /** Additional attributes for the root element */
18
36
  attributes?: G.Attributes<"div">;
19
37
  };
@@ -17,7 +17,7 @@ export const src = {
17
17
  name: "src, alt",
18
18
  render: () => (<Example>
19
19
  <Example.Item title="src, alt">
20
- <Avatar src="https://images.unsplash.com/photo-1536880756060-98a6a140f0a7?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1600&q=80" alt="Amsterdam canal"/>
20
+ <Avatar src="https://images.unsplash.com/photo-1536880756060-98a6a140f0a7?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1600&q=80" alt="Amsterdam canal" size={12}/>
21
21
  </Example.Item>
22
22
 
23
23
  <Example.Item title="src">
@@ -3,17 +3,32 @@ import type { ActionableProps, ActionableRef } from "../Actionable";
3
3
  import type { IconProps } from "../Icon";
4
4
  import type * as G from "../../types/global";
5
5
  type BaseProps = {
6
+ /** Component color scheme
7
+ * @default "neutral"
8
+ */
6
9
  color?: "neutral" | "critical" | "warning" | "positive" | "primary";
10
+ /** Component size
11
+ * @default "medium"
12
+ */
7
13
  size?: "small" | "medium" | "large";
14
+ /** SVG component for the end position icon */
8
15
  endIcon?: IconProps["svg"];
16
+ /** Change border radius to fully rounded corners */
9
17
  rounded?: boolean;
18
+ /** Transition the component to hidden state */
10
19
  hidden?: boolean;
20
+ /** Additional classname for the root element */
11
21
  className?: G.ClassName;
12
22
  } & Pick<ActionableProps, "href" | "onClick" | "attributes">;
13
23
  type WithChildren = BaseProps & {
24
+ /** Node for inserting text or other content */
14
25
  children?: React.ReactNode;
26
+ /** SVG component for the icon */
15
27
  icon?: IconProps["svg"];
16
- variant?: "faded" | "outline";
28
+ /** Component render variant
29
+ * @default "solid"
30
+ */
31
+ variant?: "solid" | "faded" | "outline";
17
32
  };
18
33
  type WithEmpty = BaseProps & {
19
34
  children?: never;
@@ -21,7 +36,9 @@ type WithEmpty = BaseProps & {
21
36
  variant?: never;
22
37
  };
23
38
  type WithDismissible = {
39
+ /** Callback triggered when the dismiss button is pressed */
24
40
  onDismiss: () => void;
41
+ /** Aria label for the dismiss button */
25
42
  dismissAriaLabel: string;
26
43
  };
27
44
  type WithoutDismissible = {
@@ -30,10 +47,17 @@ type WithoutDismissible = {
30
47
  };
31
48
  export type Props = (WithChildren | WithEmpty) & (WithDismissible | WithoutDismissible);
32
49
  export type ContainerProps = {
50
+ /** Position of the container relative to the parent element
51
+ * @default "top-end"
52
+ */
33
53
  position?: "top-end" | "bottom-end";
54
+ /** Move the badge closer to center to overlap with the child component, could be used to overlap with rounded shapes */
34
55
  overlap?: boolean;
56
+ /** Node for inserting children to position the badge against */
35
57
  children: React.ReactNode;
58
+ /** Additional classname for the root element */
36
59
  className?: G.ClassName;
60
+ /** Additional attributes for the root element */
37
61
  attributes?: G.Attributes<"div">;
38
62
  };
39
63
  export type Export = React.ForwardRefExoticComponent<Props & {
@@ -12,7 +12,9 @@ export default {
12
12
  };
13
13
  export const href = {
14
14
  name: "href",
15
- render: () => <Badge href="https://reshaped.so">Badge</Badge>,
15
+ render: () => (<Badge href="https://reshaped.so" dismissAriaLabel="Dismiss">
16
+ Badge
17
+ </Badge>),
16
18
  play: async ({ canvas }) => {
17
19
  const link = canvas.getByRole("link");
18
20
  expect(link).toHaveAttribute("href", "https://reshaped.so");
@@ -2,14 +2,25 @@ import type React from "react";
2
2
  import type { LinkProps } from "../Link";
3
3
  import type * as G from "../../types/global";
4
4
  export type Props = {
5
+ /** Node for inserting children to position items */
5
6
  children: React.ReactElement | React.ReactElement[];
7
+ /** Node for defining custom separator between items */
6
8
  separator?: React.ReactNode;
9
+ /** Component color scheme
10
+ * @default "neutral"
11
+ */
7
12
  color?: "neutral" | "primary";
13
+ /** Number of items to show by default, others will be hidden and can be expanded */
8
14
  defaultVisibleItems?: number;
15
+ /** Aria label for the expand button */
9
16
  expandAriaLabel?: string;
17
+ /** Turn expand button into static text and disable the expand functionality */
10
18
  disableExpand?: boolean;
19
+ /** aria-label attribute for the component */
11
20
  ariaLabel?: string;
21
+ /** Additional classname for the root element */
12
22
  className?: G.ClassName;
23
+ /** Additional attributes for the root element */
13
24
  attributes?: G.Attributes<"nav">;
14
25
  };
15
26
  export type ItemProps = Pick<LinkProps, "icon" | "href" | "onClick" | "disabled" | "children">;
@@ -5,21 +5,41 @@ import type { AlignerProps as BaseAlignerProps } from "../_private/Aligner";
5
5
  import type * as G from "../../types/global";
6
6
  export type Size = "xlarge" | "large" | "medium" | "small";
7
7
  export type Props = Pick<ActionableProps, "attributes" | "className" | "disabled" | "children" | "href" | "onClick" | "type" | "as" | "stopPropagation"> & {
8
+ /** Component color scheme
9
+ * @default "neutral"
10
+ */
8
11
  color?: "primary" | "critical" | "positive" | "neutral" | "media" | "inherit";
12
+ /** Component render variant
13
+ * @default "solid"
14
+ */
9
15
  variant?: "solid" | "outline" | "ghost" | "faded";
16
+ /** SVG component for the icon */
10
17
  icon?: IconProps["svg"];
18
+ /** SVG component for the end position icon */
11
19
  endIcon?: IconProps["svg"];
20
+ /** Component size
21
+ * @default "medium"
22
+ */
12
23
  size?: G.Responsive<Size>;
24
+ /** Change border radius to fully rounded corners */
13
25
  rounded?: boolean;
26
+ /** Show loading state */
14
27
  loading?: boolean;
28
+ /** aria-label attribute for the loading indicator */
15
29
  loadingAriaLabel?: string;
30
+ /** Apply elevated styles to the component */
16
31
  elevated?: boolean;
32
+ /** Make the component take the full width of the parent element */
17
33
  fullWidth?: G.Responsive<boolean>;
34
+ /** Highlight the component when component is used for an active state */
18
35
  highlighted?: boolean;
19
36
  };
20
37
  export type GroupProps = {
38
+ /** Node for inserting child Button components */
21
39
  children: React.ReactNode;
40
+ /** Additional classname for the root element */
22
41
  className?: G.ClassName;
42
+ /** Additional attributes for the root element */
23
43
  attributes?: G.Attributes<"div">;
24
44
  };
25
45
  export type AlignerProps = BaseAlignerProps & {
@@ -1,29 +1,47 @@
1
1
  export type SelectionMode = "date" | "month";
2
2
  export type BaseProps = {
3
+ /** Default month to display
4
+ * @default Date.now()
5
+ */
3
6
  defaultMonth?: Date;
7
+ /** Minimum date that can be selected */
4
8
  min?: Date;
9
+ /** Maximum date that can be selected */
5
10
  max?: Date;
11
+ /** First day of the week
12
+ * @default 1, Monday
13
+ */
6
14
  firstWeekDay?: number;
15
+ /** Dates that are selected */
7
16
  selectedDates?: Date[];
17
+ /** Render a custom weekday label, can be used for localization */
8
18
  renderWeekDay?: (args: {
9
19
  weekDay: number;
10
20
  date: Date;
11
21
  }) => string;
22
+ /** Render a custom month label, can be used for localization */
12
23
  renderSelectedMonthLabel?: (args: {
13
24
  date: Date;
14
25
  }) => string;
26
+ /** Render a custom month label, can be used for localization */
15
27
  renderMonthLabel?: (args: {
16
28
  month: number;
17
29
  date: Date;
18
30
  }) => string;
31
+ /** Aria label for the previous month button */
19
32
  previousMonthAriaLabel?: string;
20
33
  nextMonthAriaLabel?: string;
34
+ /** Aria label for the previous year button */
21
35
  previousYearAriaLabel?: string;
36
+ /** Aria label for the next year button */
22
37
  nextYearAriaLabel?: string;
38
+ /** Aria label for the month selection button */
23
39
  monthSelectionAriaLabel?: string;
40
+ /** Dynamic aria label applied to each date cell based on the arguments */
24
41
  renderDateAriaLabel?: (args: {
25
42
  date: Date;
26
43
  }) => string;
44
+ /** Dynamic aria label applied to each month element based on the arguments */
27
45
  renderMonthAriaLabel?: (args: {
28
46
  month: number;
29
47
  }) => string;
@@ -34,33 +52,46 @@ export type RangeValue = {
34
52
  end: Date | null;
35
53
  };
36
54
  export type ControlledSingleProps = {
55
+ /** Disable range selection */
37
56
  range?: false;
57
+ /** Current selected date value, enables controlled mode */
38
58
  value: SingleValue | null;
59
+ /** Default selected date value, enables uncontrolled mode */
39
60
  defaultValue?: never;
61
+ /** Callback when date selection changes */
40
62
  onChange?: (args: {
41
63
  value: SingleValue;
42
64
  }) => void;
43
65
  };
44
66
  export type UncontrolledSingleProps = {
67
+ /** Disable range selection */
45
68
  range?: false;
46
69
  value?: never;
70
+ /** Default selected date value, enables uncontrolled mode */
47
71
  defaultValue?: SingleValue;
72
+ /** Callback when date selection changes */
48
73
  onChange?: (args: {
49
74
  value: SingleValue;
50
75
  }) => void;
51
76
  };
52
77
  export type ControlledRangeProps = {
78
+ /** Enable range selection */
53
79
  range: true;
80
+ /** Current selected range value, enables controlled mode */
54
81
  value: RangeValue;
55
82
  defaultValue?: never;
83
+ /** Callback when range selection changes */
56
84
  onChange?: (args: {
57
85
  value: RangeValue;
58
86
  }) => void;
59
87
  };
60
88
  export type UncontrolledRangeProps = {
89
+ /** Enable range selection */
61
90
  range: true;
62
91
  value?: never;
92
+ /** Default selected range value, enables uncontrolled mode */
63
93
  defaultValue?: RangeValue;
94
+ /** Callback when range selection changes */
64
95
  onChange?: (args: {
65
96
  value: RangeValue;
66
97
  }) => void;
@@ -14,7 +14,7 @@ export const defaultMonth = {
14
14
  name: "defaultMonth",
15
15
  render: () => (<Example>
16
16
  <Example.Item title="defaultMonth: 2020 January">
17
- <Calendar defaultMonth={new Date(2020, 0)}/>
17
+ <Calendar defaultMonth={new Date(2020, 0)} range/>
18
18
  </Example.Item>
19
19
  </Example>),
20
20
  play: ({ canvas }) => {
@@ -3,14 +3,26 @@ import type { ActionableProps } from "../Actionable";
3
3
  import type { ViewProps } from "../View";
4
4
  import type * as G from "../../types/global";
5
5
  export type Props<TagName extends keyof React.JSX.IntrinsicElements = "div"> = {
6
+ /** Component padding, base unit multiplier */
6
7
  padding?: G.Responsive<number>;
8
+ /** Remove side borders and apply negative margins, base unit multiplier */
7
9
  bleed?: G.Responsive<number>;
10
+ /** Highlight the component when component is used for an active state */
8
11
  selected?: boolean;
12
+ /** Apply elevated styles to the component */
9
13
  elevated?: boolean;
14
+ /** Node for inserting children */
10
15
  children?: React.ReactNode;
16
+ /** Callback when the component is clicked, turns component into a button */
11
17
  onClick?: ActionableProps["onClick"];
18
+ /** URL to navigate to when the component is clicked, turns component into a link */
12
19
  href?: string;
20
+ /** Custom component tag name
21
+ * @default "div"
22
+ */
13
23
  as?: TagName;
24
+ /** Additional classname for the root element */
14
25
  className?: G.ClassName;
26
+ /** Additional attributes for the root element */
15
27
  attributes?: G.Attributes<TagName> & ActionableProps["attributes"];
16
28
  } & Pick<ViewProps, "height">;
@@ -1,8 +1,11 @@
1
1
  import type React from "react";
2
2
  import type * as G from "../../types/global";
3
3
  export type Instance = {
4
+ /** Scroll to the previous item */
4
5
  navigateBack: () => void;
6
+ /** Scroll to the next item */
5
7
  navigateForward: () => void;
8
+ /** Scroll to the item at the given index */
6
9
  navigateTo: (index: number) => void;
7
10
  } | undefined;
8
11
  export type ControlProps = {
@@ -15,16 +18,26 @@ export type ControlProps = {
15
18
  mounted: boolean;
16
19
  };
17
20
  export type Props = {
21
+ /** Node for inserting children, each child is rendered as a carousel item */
18
22
  children?: React.ReactNode;
23
+ /** Number of items visible at once in the container*/
19
24
  visibleItems?: G.Responsive<number>;
25
+ /** Gap between items in the container, base unit multiplier */
20
26
  gap?: G.Responsive<number>;
27
+ /** Apply negative margins, base unit multiplier, can be used to make sure the items don't get clipped when scrolling */
21
28
  bleed?: G.Responsive<number>;
29
+ /** Hide navigation controls */
22
30
  navigationDisplay?: "hidden";
31
+ /** Ref accessor for the carousel methods */
23
32
  instanceRef?: React.Ref<Instance>;
33
+ /** Callback when the first visible carousel index changes */
24
34
  onChange?: (args: {
25
35
  index: number;
26
36
  }) => void;
37
+ /** Callback when the carousel scrolls */
27
38
  onScroll?: (e: React.UIEvent<HTMLUListElement>) => void;
39
+ /** Additional classname for the root element */
28
40
  className?: G.ClassName;
41
+ /** Additional attributes for the root element */
29
42
  attributes?: G.Attributes<"div">;
30
43
  };
@@ -1,26 +1,45 @@
1
1
  import type React from "react";
2
2
  import type * as G from "../../types/global";
3
3
  type BaseProps = {
4
+ /** Node for inserting the label */
4
5
  children?: React.ReactNode;
6
+ /** Component name attribute */
5
7
  name?: string;
8
+ /** Disable the component */
6
9
  disabled?: boolean;
10
+ /** Show an error state, automatically inherited when component is used inside FormControl */
7
11
  hasError?: boolean;
12
+ /** Component value used for form submission */
8
13
  value?: string;
14
+ /** Show a indeterminate state, used for "select all" checkboxes with some of the individual checkboxes selected */
9
15
  indeterminate?: boolean;
16
+ /** Component size
17
+ * @default "medium"
18
+ */
10
19
  size?: G.Responsive<"small" | "medium" | "large">;
20
+ /** Callback when the component selection changes */
11
21
  onChange?: G.ChangeHandler<boolean>;
22
+ /** Callback when the component is focused */
12
23
  onFocus?: (e: React.FocusEvent) => void;
24
+ /** Callback when the component is blurred */
13
25
  onBlur?: (e: React.FocusEvent) => void;
26
+ /** Additional classname for the root element */
14
27
  className?: G.ClassName;
28
+ /** Additional attributes for the root element */
15
29
  attributes?: G.Attributes<"label">;
30
+ /** Additional attributes for the input element */
16
31
  inputAttributes?: G.Attributes<"input">;
17
32
  };
18
33
  export type ControlledProps = BaseProps & {
34
+ /** Component checked state, enables controlled mode */
19
35
  checked: boolean;
36
+ /** Default checked state, enables uncontrolled mode */
20
37
  defaultChecked?: never;
21
38
  };
22
39
  export type UncontrolledProps = BaseProps & {
40
+ /** Component checked state, enables controlled mode */
23
41
  checked?: never;
42
+ /** Default checked state, enables uncontrolled mode */
24
43
  defaultChecked?: boolean;
25
44
  };
26
45
  export type Props = ControlledProps | UncontrolledProps;
@@ -18,7 +18,7 @@ export const selection = () => (<Example>
18
18
  </Example.Item>
19
19
 
20
20
  <Example.Item title="checked, uncontrolled">
21
- <Checkbox name="animal" value="dog" defaultChecked>
21
+ <Checkbox name="animal" value="dog">
22
22
  Checkbox
23
23
  </Checkbox>
24
24
  </Example.Item>
@@ -2,19 +2,29 @@ import type React from "react";
2
2
  import type * as G from "../../types/global";
3
3
  import type { CheckboxProps } from "../Checkbox";
4
4
  type BaseProps = {
5
+ /** Component id attribute */
5
6
  id?: string;
7
+ /** Node for inserting checkboxes or custom layout components */
6
8
  children?: React.ReactNode;
9
+ /** Show an error state, automatically inherited when component is used inside FormControl */
7
10
  hasError?: boolean;
11
+ /** Disable the component from form submission */
8
12
  disabled?: boolean;
13
+ /** Component name attribute */
9
14
  name: string;
15
+ /** Callback when the component selection changes */
10
16
  onChange?: G.ChangeHandler<string[]>;
11
17
  };
12
18
  export type ControlledProps = BaseProps & {
19
+ /** Component value, enables controlled mode */
13
20
  value: string[];
21
+ /** Default value, enables uncontrolled mode */
14
22
  defaultValue?: never;
15
23
  };
16
24
  export type UncontrolledProps = BaseProps & {
25
+ /** Component value, enables uncontrolled mode */
17
26
  value?: never;
27
+ /** Default value, enables uncontrolled mode */
18
28
  defaultValue?: string[];
19
29
  };
20
30
  export type Props = ControlledProps | UncontrolledProps;