@openwarelabs/ui 0.12.2 → 0.14.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 (79) hide show
  1. package/README.md +7 -7
  2. package/dist/components/AspectRatio/AspectRatio.d.cts +7 -0
  3. package/dist/components/AspectRatio/AspectRatio.d.ts +7 -0
  4. package/dist/components/AspectRatio/AspectRatio.types.d.cts +7 -0
  5. package/dist/components/AspectRatio/AspectRatio.types.d.ts +7 -0
  6. package/dist/components/Banner/Banner.d.cts +7 -0
  7. package/dist/components/Banner/Banner.d.ts +7 -0
  8. package/dist/components/Banner/Banner.types.d.cts +44 -0
  9. package/dist/components/Banner/Banner.types.d.ts +44 -0
  10. package/dist/components/Carousel/Carousel.d.cts +9 -0
  11. package/dist/components/Carousel/Carousel.d.ts +9 -0
  12. package/dist/components/Carousel/Carousel.types.d.cts +63 -0
  13. package/dist/components/Carousel/Carousel.types.d.ts +63 -0
  14. package/dist/components/ContextMenu/ContextMenu.d.cts +7 -0
  15. package/dist/components/ContextMenu/ContextMenu.d.ts +7 -0
  16. package/dist/components/ContextMenu/ContextMenu.types.d.cts +32 -0
  17. package/dist/components/ContextMenu/ContextMenu.types.d.ts +32 -0
  18. package/dist/components/DescriptionList/DescriptionList.d.cts +9 -0
  19. package/dist/components/DescriptionList/DescriptionList.d.ts +9 -0
  20. package/dist/components/DescriptionList/DescriptionList.types.d.cts +32 -0
  21. package/dist/components/DescriptionList/DescriptionList.types.d.ts +32 -0
  22. package/dist/components/HoverCard/HoverCard.d.cts +8 -0
  23. package/dist/components/HoverCard/HoverCard.d.ts +8 -0
  24. package/dist/components/HoverCard/HoverCard.types.d.cts +28 -0
  25. package/dist/components/HoverCard/HoverCard.types.d.ts +28 -0
  26. package/dist/components/Image/Image.d.cts +7 -0
  27. package/dist/components/Image/Image.d.ts +7 -0
  28. package/dist/components/Image/Image.types.d.cts +28 -0
  29. package/dist/components/Image/Image.types.d.ts +28 -0
  30. package/dist/components/Menu/Menu.context.d.cts +3 -0
  31. package/dist/components/Menu/Menu.context.d.ts +3 -0
  32. package/dist/components/Menu/Menu.d.cts +4 -34
  33. package/dist/components/Menu/Menu.d.ts +4 -34
  34. package/dist/components/Menu/Menu.types.d.cts +39 -0
  35. package/dist/components/Menu/Menu.types.d.ts +39 -0
  36. package/dist/components/PasswordInput/PasswordInput.d.cts +9 -0
  37. package/dist/components/PasswordInput/PasswordInput.d.ts +9 -0
  38. package/dist/components/PasswordInput/PasswordInput.types.d.cts +47 -0
  39. package/dist/components/PasswordInput/PasswordInput.types.d.ts +47 -0
  40. package/dist/components/PasswordInput/passwordStrength.d.cts +9 -0
  41. package/dist/components/PasswordInput/passwordStrength.d.ts +9 -0
  42. package/dist/components/Rating/Rating.d.cts +8 -0
  43. package/dist/components/Rating/Rating.d.ts +8 -0
  44. package/dist/components/Rating/Rating.types.d.cts +59 -0
  45. package/dist/components/Rating/Rating.types.d.ts +59 -0
  46. package/dist/components/Splitter/Splitter.d.cts +14 -0
  47. package/dist/components/Splitter/Splitter.d.ts +14 -0
  48. package/dist/components/Splitter/Splitter.layout.d.cts +12 -0
  49. package/dist/components/Splitter/Splitter.layout.d.ts +12 -0
  50. package/dist/components/Splitter/Splitter.types.d.cts +69 -0
  51. package/dist/components/Splitter/Splitter.types.d.ts +69 -0
  52. package/dist/components/Table/Table.d.cts +4 -60
  53. package/dist/components/Table/Table.d.ts +4 -60
  54. package/dist/components/Table/Table.types.d.cts +64 -0
  55. package/dist/components/Table/Table.types.d.ts +64 -0
  56. package/dist/components/TagInput/TagInput.d.cts +7 -0
  57. package/dist/components/TagInput/TagInput.d.ts +7 -0
  58. package/dist/components/TagInput/TagInput.types.d.cts +78 -0
  59. package/dist/components/TagInput/TagInput.types.d.ts +78 -0
  60. package/dist/components/Timeline/Timeline.d.cts +6 -0
  61. package/dist/components/Timeline/Timeline.d.ts +6 -0
  62. package/dist/components/Timeline/Timeline.types.d.cts +42 -0
  63. package/dist/components/Timeline/Timeline.types.d.ts +42 -0
  64. package/dist/components/Tour/Tour.d.cts +9 -0
  65. package/dist/components/Tour/Tour.d.ts +9 -0
  66. package/dist/components/Tour/Tour.types.d.cts +119 -0
  67. package/dist/components/Tour/Tour.types.d.ts +119 -0
  68. package/dist/components.css +1630 -124
  69. package/dist/icons.d.cts +6 -0
  70. package/dist/icons.d.ts +6 -0
  71. package/dist/index.cjs +3501 -1357
  72. package/dist/index.cjs.map +4 -4
  73. package/dist/index.d.cts +26 -0
  74. package/dist/index.d.ts +26 -0
  75. package/dist/index.js +3518 -1355
  76. package/dist/index.js.map +4 -4
  77. package/dist/openware-ui.iife.js +9 -8
  78. package/dist/styles.css +1630 -124
  79. package/package.json +1 -1
@@ -0,0 +1,28 @@
1
+ import type { CSSProperties, ImgHTMLAttributes, ReactNode } from "react";
2
+ export type ImageFit = "cover" | "contain";
3
+ export type ImageRadius = "none" | "control" | "container";
4
+ export interface ImageProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, "alt"> {
5
+ /**
6
+ * What the image shows, for screen readers and when it can't load. Required: pass `alt=""` for a decorative image
7
+ * that adds nothing to the text around it.
8
+ */
9
+ alt: string;
10
+ /** Width over height, such as `16 / 9` or `1`: the image fills a box of that shape as wide as its container. Leave it out to keep the image's own size. */
11
+ ratio?: number;
12
+ /** `cover` fills the box and crops what's over; `contain` shows the whole image, with space around it if the shapes differ. @default "cover" */
13
+ fit?: ImageFit;
14
+ /** The corners: `control` matches inputs and buttons (8px), `container` matches cards (12px). @default "none" */
15
+ radius?: ImageRadius;
16
+ /** Shown instead when the image fails to load or there's no `src`. @default an image icon on a muted ground */
17
+ fallback?: ReactNode;
18
+ /** A line under the image. With it, the image and the caption come in a `<figure>`. */
19
+ caption?: ReactNode;
20
+ /** Lazy loads the image only as it nears the screen; pass `"eager"` for one at the top of the page. @default "lazy" */
21
+ loading?: "lazy" | "eager";
22
+ /** @default "async" */
23
+ decoding?: "async" | "sync" | "auto";
24
+ /** Goes on the outer box (or the figure), not the `<img>`, so you can size and place it. */
25
+ className?: string;
26
+ /** Goes on the outer box (or the figure), not the `<img>`, so you can size and place it. */
27
+ style?: CSSProperties;
28
+ }
@@ -0,0 +1,3 @@
1
+ import type { MenuContextValue } from "./Menu.types.cjs";
2
+ /** Lets a MenuItem close the menu around it. Menu and ContextMenu both provide it. */
3
+ export declare const MenuContext: import("react").Context<MenuContextValue | null>;
@@ -0,0 +1,3 @@
1
+ import type { MenuContextValue } from "./Menu.types.js";
2
+ /** Lets a MenuItem close the menu around it. Menu and ContextMenu both provide it. */
3
+ export declare const MenuContext: import("react").Context<MenuContextValue | null>;
@@ -1,43 +1,13 @@
1
- import { type ButtonHTMLAttributes, type ReactElement, type ReactNode } from "react";
2
- export interface MenuProps {
3
- /** The button that opens it, usually a Button. Menu adds the click handler and the aria attributes. */
4
- trigger: ReactElement;
5
- /** MenuItem, MenuLabel and MenuSeparator. */
6
- children: ReactNode;
7
- /** Names the menu for screen readers. */
8
- label: string;
9
- /** Which edge of the trigger it lines up with.
10
- * @default "start" */
11
- align?: "start" | "end";
12
- /** Prefers opening upward. Either way it flips when there's no room.
13
- * @default false */
14
- above?: boolean;
15
- /** CSS width; default fits the items, at least 200px. */
16
- width?: number | string;
17
- /** Starts open, for documentation and tests. */
18
- defaultOpen?: boolean;
19
- className?: string;
20
- }
1
+ import type { MenuItemProps, MenuLabelProps, MenuProps } from "./Menu.types.cjs";
2
+ export type { MenuContextValue, MenuItemProps, MenuLabelProps, MenuProps } from "./Menu.types.cjs";
21
3
  /**
22
4
  * A dropdown menu of actions under a button. Opening it focuses the first item; the arrow keys, Home and End
23
5
  * move; Escape closes it and returns focus to the button; a click outside or Tab closes it.
24
6
  */
25
7
  export declare function Menu({ trigger, children, label, align, above, width, defaultOpen, className }: MenuProps): import("react").JSX.Element;
26
- export interface MenuItemProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onSelect"> {
27
- /** A 15px lucide-react icon before the label. */
28
- icon?: ReactNode;
29
- /** Runs the action; the menu then closes. */
30
- onSelect?(): void;
31
- /** Red, for actions that delete or can't be undone. */
32
- destructive?: boolean;
33
- /** Shown on the right, e.g. "⌘,". Only a shortcut that actually works. */
34
- shortcut?: string;
35
- }
36
- /** One action in a Menu. */
8
+ /** One action in a Menu or a ContextMenu. */
37
9
  export declare const MenuItem: import("react").ForwardRefExoticComponent<MenuItemProps & import("react").RefAttributes<HTMLButtonElement>>;
38
10
  /** A small uppercase heading for a group of items. */
39
- export declare function MenuLabel({ children }: {
40
- children: ReactNode;
41
- }): import("react").JSX.Element;
11
+ export declare function MenuLabel({ children }: MenuLabelProps): import("react").JSX.Element;
42
12
  /** A hairline between groups of items. */
43
13
  export declare function MenuSeparator(): import("react").JSX.Element;
@@ -1,43 +1,13 @@
1
- import { type ButtonHTMLAttributes, type ReactElement, type ReactNode } from "react";
2
- export interface MenuProps {
3
- /** The button that opens it, usually a Button. Menu adds the click handler and the aria attributes. */
4
- trigger: ReactElement;
5
- /** MenuItem, MenuLabel and MenuSeparator. */
6
- children: ReactNode;
7
- /** Names the menu for screen readers. */
8
- label: string;
9
- /** Which edge of the trigger it lines up with.
10
- * @default "start" */
11
- align?: "start" | "end";
12
- /** Prefers opening upward. Either way it flips when there's no room.
13
- * @default false */
14
- above?: boolean;
15
- /** CSS width; default fits the items, at least 200px. */
16
- width?: number | string;
17
- /** Starts open, for documentation and tests. */
18
- defaultOpen?: boolean;
19
- className?: string;
20
- }
1
+ import type { MenuItemProps, MenuLabelProps, MenuProps } from "./Menu.types.js";
2
+ export type { MenuContextValue, MenuItemProps, MenuLabelProps, MenuProps } from "./Menu.types.js";
21
3
  /**
22
4
  * A dropdown menu of actions under a button. Opening it focuses the first item; the arrow keys, Home and End
23
5
  * move; Escape closes it and returns focus to the button; a click outside or Tab closes it.
24
6
  */
25
7
  export declare function Menu({ trigger, children, label, align, above, width, defaultOpen, className }: MenuProps): import("react").JSX.Element;
26
- export interface MenuItemProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onSelect"> {
27
- /** A 15px lucide-react icon before the label. */
28
- icon?: ReactNode;
29
- /** Runs the action; the menu then closes. */
30
- onSelect?(): void;
31
- /** Red, for actions that delete or can't be undone. */
32
- destructive?: boolean;
33
- /** Shown on the right, e.g. "⌘,". Only a shortcut that actually works. */
34
- shortcut?: string;
35
- }
36
- /** One action in a Menu. */
8
+ /** One action in a Menu or a ContextMenu. */
37
9
  export declare const MenuItem: import("react").ForwardRefExoticComponent<MenuItemProps & import("react").RefAttributes<HTMLButtonElement>>;
38
10
  /** A small uppercase heading for a group of items. */
39
- export declare function MenuLabel({ children }: {
40
- children: ReactNode;
41
- }): import("react").JSX.Element;
11
+ export declare function MenuLabel({ children }: MenuLabelProps): import("react").JSX.Element;
42
12
  /** A hairline between groups of items. */
43
13
  export declare function MenuSeparator(): import("react").JSX.Element;
@@ -0,0 +1,39 @@
1
+ import type { ButtonHTMLAttributes, ReactElement, ReactNode } from "react";
2
+ export interface MenuProps {
3
+ /** The button that opens it, usually a Button. Menu adds the click handler and the aria attributes. */
4
+ trigger: ReactElement;
5
+ /** MenuItem, MenuLabel and MenuSeparator. */
6
+ children: ReactNode;
7
+ /** Names the menu for screen readers. */
8
+ label: string;
9
+ /** Which edge of the trigger it lines up with.
10
+ * @default "start" */
11
+ align?: "start" | "end";
12
+ /** Prefers opening upward. Either way it flips when there's no room.
13
+ * @default false */
14
+ above?: boolean;
15
+ /** CSS width; default fits the items, at least 200px. */
16
+ width?: number | string;
17
+ /** Starts open, for documentation and tests. */
18
+ defaultOpen?: boolean;
19
+ className?: string;
20
+ }
21
+ export interface MenuItemProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onSelect"> {
22
+ /** A 15px lucide-react icon before the label. */
23
+ icon?: ReactNode;
24
+ /** Runs the action; the menu then closes. */
25
+ onSelect?(): void;
26
+ /** Red, for actions that delete or can't be undone. */
27
+ destructive?: boolean;
28
+ /** Shown on the right, e.g. "⌘,". Only a shortcut that actually works. */
29
+ shortcut?: string;
30
+ }
31
+ export interface MenuLabelProps {
32
+ /** The heading's text. */
33
+ children: ReactNode;
34
+ }
35
+ /** What a MenuItem reaches for to close the menu it's in (a Menu or a ContextMenu). */
36
+ export interface MenuContextValue {
37
+ /** Closes the menu and puts focus back where it was before it opened. */
38
+ close(): void;
39
+ }
@@ -0,0 +1,39 @@
1
+ import type { ButtonHTMLAttributes, ReactElement, ReactNode } from "react";
2
+ export interface MenuProps {
3
+ /** The button that opens it, usually a Button. Menu adds the click handler and the aria attributes. */
4
+ trigger: ReactElement;
5
+ /** MenuItem, MenuLabel and MenuSeparator. */
6
+ children: ReactNode;
7
+ /** Names the menu for screen readers. */
8
+ label: string;
9
+ /** Which edge of the trigger it lines up with.
10
+ * @default "start" */
11
+ align?: "start" | "end";
12
+ /** Prefers opening upward. Either way it flips when there's no room.
13
+ * @default false */
14
+ above?: boolean;
15
+ /** CSS width; default fits the items, at least 200px. */
16
+ width?: number | string;
17
+ /** Starts open, for documentation and tests. */
18
+ defaultOpen?: boolean;
19
+ className?: string;
20
+ }
21
+ export interface MenuItemProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onSelect"> {
22
+ /** A 15px lucide-react icon before the label. */
23
+ icon?: ReactNode;
24
+ /** Runs the action; the menu then closes. */
25
+ onSelect?(): void;
26
+ /** Red, for actions that delete or can't be undone. */
27
+ destructive?: boolean;
28
+ /** Shown on the right, e.g. "⌘,". Only a shortcut that actually works. */
29
+ shortcut?: string;
30
+ }
31
+ export interface MenuLabelProps {
32
+ /** The heading's text. */
33
+ children: ReactNode;
34
+ }
35
+ /** What a MenuItem reaches for to close the menu it's in (a Menu or a ContextMenu). */
36
+ export interface MenuContextValue {
37
+ /** Closes the menu and puts focus back where it was before it opened. */
38
+ close(): void;
39
+ }
@@ -0,0 +1,9 @@
1
+ import type { PasswordInputProps } from "./PasswordInput.types.cjs";
2
+ export { passwordStrength } from "./passwordStrength.cjs";
3
+ export type { PasswordInputProps, PasswordRequirement, PasswordStrength, PasswordStrengthScorer } from "./PasswordInput.types.cjs";
4
+ /**
5
+ * A password field with a button that shows and hides what's typed. It can also show how strong the password is, and a
6
+ * checklist of rules that tick as they're met. Every Input prop passes through, and the ref is the input's; `className`
7
+ * goes on the wrapper around the field and what's under it.
8
+ */
9
+ export declare const PasswordInput: import("react").ForwardRefExoticComponent<PasswordInputProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,9 @@
1
+ import type { PasswordInputProps } from "./PasswordInput.types.js";
2
+ export { passwordStrength } from "./passwordStrength.js";
3
+ export type { PasswordInputProps, PasswordRequirement, PasswordStrength, PasswordStrengthScorer } from "./PasswordInput.types.js";
4
+ /**
5
+ * A password field with a button that shows and hides what's typed. It can also show how strong the password is, and a
6
+ * checklist of rules that tick as they're met. Every Input prop passes through, and the ref is the input's; `className`
7
+ * goes on the wrapper around the field and what's under it.
8
+ */
9
+ export declare const PasswordInput: import("react").ForwardRefExoticComponent<PasswordInputProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,47 @@
1
+ import type { ReactNode } from "react";
2
+ import type { InputProps } from "../Input/Input.cjs";
3
+ /** How strong a password is: a score from 0 (very weak) to 4 (strong), and the word shown for it. */
4
+ export interface PasswordStrength {
5
+ /** 0 very weak, 1 weak, 2 fair, 3 good, 4 strong. */
6
+ score: 0 | 1 | 2 | 3 | 4;
7
+ /** The word shown and read out, such as "Good". Defaults to the score's: Very weak, Weak, Fair, Good, Strong. */
8
+ label?: string;
9
+ }
10
+ /** Scores a password, such as a wrapper around zxcvbn or your server's own rules. */
11
+ export type PasswordStrengthScorer = (value: string) => PasswordStrength;
12
+ /** One rule in the checklist under the field. */
13
+ export interface PasswordRequirement {
14
+ /** What the rule asks for, such as "At least 12 characters". */
15
+ label: ReactNode;
16
+ /** Whether the password meets it. */
17
+ test(value: string): boolean;
18
+ }
19
+ export interface PasswordInputProps extends Omit<InputProps, "type" | "endContent"> {
20
+ /**
21
+ * Shows a strength meter under the field: `true` scores it with the built-in `passwordStrength`, or pass your own
22
+ * function from the value to `{ score, label }`. The word is announced politely as it changes.
23
+ * @default false
24
+ */
25
+ strength?: boolean | PasswordStrengthScorer;
26
+ /** Names the strength meter, and starts the line under it.
27
+ * @default "Password strength" */
28
+ strengthLabel?: string;
29
+ /** Rules shown as a checklist under the field, each ticked once the password meets it. */
30
+ requirements?: PasswordRequirement[];
31
+ /** Shows the password as text, when you control it. */
32
+ visible?: boolean;
33
+ /** Shows the password as text at first, when it controls itself.
34
+ * @default false */
35
+ defaultVisible?: boolean;
36
+ /** Called when the person shows or hides the password. */
37
+ onVisibleChange?(visible: boolean): void;
38
+ /** Names the show and hide button for screen readers. It stays the same either way; aria-pressed says which.
39
+ * @default "Show password" */
40
+ toggleLabel?: string;
41
+ /**
42
+ * What browsers and password managers fill in: `current-password` to sign in, `new-password` to sign up or change
43
+ * a password (so they offer a strong one).
44
+ * @default "current-password"
45
+ */
46
+ autoComplete?: string;
47
+ }
@@ -0,0 +1,47 @@
1
+ import type { ReactNode } from "react";
2
+ import type { InputProps } from "../Input/Input.js";
3
+ /** How strong a password is: a score from 0 (very weak) to 4 (strong), and the word shown for it. */
4
+ export interface PasswordStrength {
5
+ /** 0 very weak, 1 weak, 2 fair, 3 good, 4 strong. */
6
+ score: 0 | 1 | 2 | 3 | 4;
7
+ /** The word shown and read out, such as "Good". Defaults to the score's: Very weak, Weak, Fair, Good, Strong. */
8
+ label?: string;
9
+ }
10
+ /** Scores a password, such as a wrapper around zxcvbn or your server's own rules. */
11
+ export type PasswordStrengthScorer = (value: string) => PasswordStrength;
12
+ /** One rule in the checklist under the field. */
13
+ export interface PasswordRequirement {
14
+ /** What the rule asks for, such as "At least 12 characters". */
15
+ label: ReactNode;
16
+ /** Whether the password meets it. */
17
+ test(value: string): boolean;
18
+ }
19
+ export interface PasswordInputProps extends Omit<InputProps, "type" | "endContent"> {
20
+ /**
21
+ * Shows a strength meter under the field: `true` scores it with the built-in `passwordStrength`, or pass your own
22
+ * function from the value to `{ score, label }`. The word is announced politely as it changes.
23
+ * @default false
24
+ */
25
+ strength?: boolean | PasswordStrengthScorer;
26
+ /** Names the strength meter, and starts the line under it.
27
+ * @default "Password strength" */
28
+ strengthLabel?: string;
29
+ /** Rules shown as a checklist under the field, each ticked once the password meets it. */
30
+ requirements?: PasswordRequirement[];
31
+ /** Shows the password as text, when you control it. */
32
+ visible?: boolean;
33
+ /** Shows the password as text at first, when it controls itself.
34
+ * @default false */
35
+ defaultVisible?: boolean;
36
+ /** Called when the person shows or hides the password. */
37
+ onVisibleChange?(visible: boolean): void;
38
+ /** Names the show and hide button for screen readers. It stays the same either way; aria-pressed says which.
39
+ * @default "Show password" */
40
+ toggleLabel?: string;
41
+ /**
42
+ * What browsers and password managers fill in: `current-password` to sign in, `new-password` to sign up or change
43
+ * a password (so they offer a strong one).
44
+ * @default "current-password"
45
+ */
46
+ autoComplete?: string;
47
+ }
@@ -0,0 +1,9 @@
1
+ import type { PasswordStrength } from "./PasswordInput.types.cjs";
2
+ /** The word for each score, from 0 to 4. */
3
+ export declare const strengthLabels: readonly ["Very weak", "Weak", "Fair", "Good", "Strong"];
4
+ /**
5
+ * A small, quick estimate of a password's strength, from 0 (very weak) to 4 (strong): points for length and for mixing
6
+ * lower case, upper case, digits and symbols, less for common passwords, repeats, runs like "1234" and years. It runs
7
+ * in the browser and sends nothing anywhere. It's a nudge, not a guarantee: check passwords against leaks on the server.
8
+ */
9
+ export declare function passwordStrength(value: string): Required<PasswordStrength>;
@@ -0,0 +1,9 @@
1
+ import type { PasswordStrength } from "./PasswordInput.types.js";
2
+ /** The word for each score, from 0 to 4. */
3
+ export declare const strengthLabels: readonly ["Very weak", "Weak", "Fair", "Good", "Strong"];
4
+ /**
5
+ * A small, quick estimate of a password's strength, from 0 (very weak) to 4 (strong): points for length and for mixing
6
+ * lower case, upper case, digits and symbols, less for common passwords, repeats, runs like "1234" and years. It runs
7
+ * in the browser and sends nothing anywhere. It's a nudge, not a guarantee: check passwords against leaks on the server.
8
+ */
9
+ export declare function passwordStrength(value: string): Required<PasswordStrength>;
@@ -0,0 +1,8 @@
1
+ import type { RatingProps } from "./Rating.types.cjs";
2
+ export type { RatingLabels, RatingProps } from "./Rating.types.cjs";
3
+ /**
4
+ * Stars to pick a score, or to show one. Picking, it's a group of radios: the arrow keys change the rating,
5
+ * the pointer previews it, and it's sent with a form under its `name`. With `readOnly`, it shows a rating
6
+ * to any fraction, read as "4.5 out of 5 stars", with an optional count of reviews.
7
+ */
8
+ export declare function Rating({ value, defaultValue, onChange, max, allowHalf, clearable, size, readOnly, disabled, showValue, count, name, required, isInvalid, labels: labelsProp, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, id, className, }: RatingProps): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import type { RatingProps } from "./Rating.types.js";
2
+ export type { RatingLabels, RatingProps } from "./Rating.types.js";
3
+ /**
4
+ * Stars to pick a score, or to show one. Picking, it's a group of radios: the arrow keys change the rating,
5
+ * the pointer previews it, and it's sent with a form under its `name`. With `readOnly`, it shows a rating
6
+ * to any fraction, read as "4.5 out of 5 stars", with an optional count of reviews.
7
+ */
8
+ export declare function Rating({ value, defaultValue, onChange, max, allowHalf, clearable, size, readOnly, disabled, showValue, count, name, required, isInvalid, labels: labelsProp, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, id, className, }: RatingProps): import("react").JSX.Element;
@@ -0,0 +1,59 @@
1
+ export interface RatingLabels {
2
+ /** Names one star's radio for screen readers.
3
+ * @default (value) => value === 1 ? "1 star" : `${value} stars` */
4
+ star?(value: number): string;
5
+ /** Reads out a rating that's shown, not picked.
6
+ * @default (value, max) => `${value} out of ${max} stars` */
7
+ summary?(value: number, max: number): string;
8
+ /** The text after the stars when there's a `count`.
9
+ * @default (count) => `${count} reviews`, with thousands separated */
10
+ count?(count: number): string;
11
+ }
12
+ export interface RatingProps {
13
+ /** The rating, when you control it. 0 is no rating yet. Read-only, it can be any fraction, like 4.6. */
14
+ value?: number;
15
+ /** The starting rating when uncontrolled.
16
+ * @default 0 */
17
+ defaultValue?: number;
18
+ /** Called with the new rating; 0 when it's cleared. */
19
+ onChange?(value: number): void;
20
+ /** How many stars.
21
+ * @default 5 */
22
+ max?: number;
23
+ /** Lets people pick half stars: the left half of a star is half a point.
24
+ * @default false */
25
+ allowHalf?: boolean;
26
+ /** Choosing the current rating again clears it, back to 0.
27
+ * @default false */
28
+ clearable?: boolean;
29
+ /** sm 16px, md 20px, lg 24px stars.
30
+ * @default "md" */
31
+ size?: "sm" | "md" | "lg";
32
+ /** Shows a rating rather than asking for one: an image read as "4.5 out of 5 stars", filled to any fraction.
33
+ * @default false */
34
+ readOnly?: boolean;
35
+ /** @default false */
36
+ disabled?: boolean;
37
+ /** Shows the number after the stars, like 4.6.
38
+ * @default false */
39
+ showValue?: boolean;
40
+ /** How many ratings it's from, shown after the stars as "1,203 reviews". */
41
+ count?: number;
42
+ /** The form field name: the rating is sent under it (nothing when it's 0). Generated when left out. */
43
+ name?: string;
44
+ /** Asks for a rating before the form can be sent. */
45
+ required?: boolean;
46
+ /** Marks it invalid, with an error colour; Field sets this. */
47
+ isInvalid?: boolean;
48
+ /** The words it uses, for other languages. */
49
+ labels?: RatingLabels;
50
+ /** Names the rating for screen readers when there's no Field label: "Rate this recipe". */
51
+ "aria-label"?: string;
52
+ /** Names the rating by another element's id, such as a Field's label; Field sets this. */
53
+ "aria-labelledby"?: string;
54
+ /** Ids of the hint or error that describe it; Field sets this. */
55
+ "aria-describedby"?: string;
56
+ /** The id of the stars, so a Field's label points at them; Field sets this. */
57
+ id?: string;
58
+ className?: string;
59
+ }
@@ -0,0 +1,59 @@
1
+ export interface RatingLabels {
2
+ /** Names one star's radio for screen readers.
3
+ * @default (value) => value === 1 ? "1 star" : `${value} stars` */
4
+ star?(value: number): string;
5
+ /** Reads out a rating that's shown, not picked.
6
+ * @default (value, max) => `${value} out of ${max} stars` */
7
+ summary?(value: number, max: number): string;
8
+ /** The text after the stars when there's a `count`.
9
+ * @default (count) => `${count} reviews`, with thousands separated */
10
+ count?(count: number): string;
11
+ }
12
+ export interface RatingProps {
13
+ /** The rating, when you control it. 0 is no rating yet. Read-only, it can be any fraction, like 4.6. */
14
+ value?: number;
15
+ /** The starting rating when uncontrolled.
16
+ * @default 0 */
17
+ defaultValue?: number;
18
+ /** Called with the new rating; 0 when it's cleared. */
19
+ onChange?(value: number): void;
20
+ /** How many stars.
21
+ * @default 5 */
22
+ max?: number;
23
+ /** Lets people pick half stars: the left half of a star is half a point.
24
+ * @default false */
25
+ allowHalf?: boolean;
26
+ /** Choosing the current rating again clears it, back to 0.
27
+ * @default false */
28
+ clearable?: boolean;
29
+ /** sm 16px, md 20px, lg 24px stars.
30
+ * @default "md" */
31
+ size?: "sm" | "md" | "lg";
32
+ /** Shows a rating rather than asking for one: an image read as "4.5 out of 5 stars", filled to any fraction.
33
+ * @default false */
34
+ readOnly?: boolean;
35
+ /** @default false */
36
+ disabled?: boolean;
37
+ /** Shows the number after the stars, like 4.6.
38
+ * @default false */
39
+ showValue?: boolean;
40
+ /** How many ratings it's from, shown after the stars as "1,203 reviews". */
41
+ count?: number;
42
+ /** The form field name: the rating is sent under it (nothing when it's 0). Generated when left out. */
43
+ name?: string;
44
+ /** Asks for a rating before the form can be sent. */
45
+ required?: boolean;
46
+ /** Marks it invalid, with an error colour; Field sets this. */
47
+ isInvalid?: boolean;
48
+ /** The words it uses, for other languages. */
49
+ labels?: RatingLabels;
50
+ /** Names the rating for screen readers when there's no Field label: "Rate this recipe". */
51
+ "aria-label"?: string;
52
+ /** Names the rating by another element's id, such as a Field's label; Field sets this. */
53
+ "aria-labelledby"?: string;
54
+ /** Ids of the hint or error that describe it; Field sets this. */
55
+ "aria-describedby"?: string;
56
+ /** The id of the stars, so a Field's label points at them; Field sets this. */
57
+ id?: string;
58
+ className?: string;
59
+ }
@@ -0,0 +1,14 @@
1
+ import type { SplitterHandleProps, SplitterPanelProps, SplitterProps } from "./Splitter.types.cjs";
2
+ export type { SplitterDirection, SplitterHandleProps, SplitterPanelProps, SplitterProps } from "./Splitter.types.cjs";
3
+ /**
4
+ * Lays panels side by side, or stacked, with a handle between each pair to drag them bigger or smaller. Sizes are
5
+ * percentages. Handles move with the arrow keys too, and a collapsible panel folds away with Enter or a double-click.
6
+ */
7
+ export declare function Splitter({ children, direction, sizes, defaultSizes, onSizesChange, autoSaveId, className, ...props }: SplitterProps): import("react").JSX.Element;
8
+ /** One of a Splitter's panels. Give it a `defaultSize`, and limits with `minSize` and `maxSize`. */
9
+ export declare function SplitterPanel({ defaultSize: _defaultSize, minSize: _minSize, maxSize: _maxSize, collapsible: _collapsible, collapsedSize: _collapsedSize, onResize: _onResize, onCollapsedChange: _onCollapsedChange, className, style, ...props }: SplitterPanelProps): import("react").JSX.Element;
10
+ /**
11
+ * The line between two panels. Drag it, or focus it and use the arrow keys (Shift for bigger steps), Home and End.
12
+ * Enter or a double-click collapses a collapsible panel beside it, and expands it again.
13
+ */
14
+ export declare function SplitterHandle({ "aria-label": ariaLabel, grip, disabled, className, onPointerDown, onKeyDown, onDoubleClick, ...props }: SplitterHandleProps): import("react").JSX.Element | null;
@@ -0,0 +1,14 @@
1
+ import type { SplitterHandleProps, SplitterPanelProps, SplitterProps } from "./Splitter.types.js";
2
+ export type { SplitterDirection, SplitterHandleProps, SplitterPanelProps, SplitterProps } from "./Splitter.types.js";
3
+ /**
4
+ * Lays panels side by side, or stacked, with a handle between each pair to drag them bigger or smaller. Sizes are
5
+ * percentages. Handles move with the arrow keys too, and a collapsible panel folds away with Enter or a double-click.
6
+ */
7
+ export declare function Splitter({ children, direction, sizes, defaultSizes, onSizesChange, autoSaveId, className, ...props }: SplitterProps): import("react").JSX.Element;
8
+ /** One of a Splitter's panels. Give it a `defaultSize`, and limits with `minSize` and `maxSize`. */
9
+ export declare function SplitterPanel({ defaultSize: _defaultSize, minSize: _minSize, maxSize: _maxSize, collapsible: _collapsible, collapsedSize: _collapsedSize, onResize: _onResize, onCollapsedChange: _onCollapsedChange, className, style, ...props }: SplitterPanelProps): import("react").JSX.Element;
10
+ /**
11
+ * The line between two panels. Drag it, or focus it and use the arrow keys (Shift for bigger steps), Home and End.
12
+ * Enter or a double-click collapses a collapsible panel beside it, and expands it again.
13
+ */
14
+ export declare function SplitterHandle({ "aria-label": ariaLabel, grip, disabled, className, onPointerDown, onKeyDown, onDoubleClick, ...props }: SplitterHandleProps): import("react").JSX.Element | null;
@@ -0,0 +1,12 @@
1
+ import type { SplitterPanelLimits } from "./Splitter.types.cjs";
2
+ export declare const isCollapsed: (limits: SplitterPanelLimits, size: number) => boolean;
3
+ /** Panels with a default size keep it; the rest share what's left. Then everything is scaled to add up to 100. */
4
+ export declare function initialSizes(defaults: Array<number | undefined>): number[];
5
+ export declare function normalise(sizes: number[]): number[];
6
+ /**
7
+ * Moves the handle after panel `handle` by `delta` percent: the panel on the side it moves away from grows (up to its
8
+ * maximum), and the panels on the other side shrink in turn, nearest first, down to their minimums. With `snap`, a
9
+ * collapsible panel collapses once it's dragged more than halfway from its minimum to its collapsed size, and
10
+ * expands again past the same point.
11
+ */
12
+ export declare function moveHandle(sizes: number[], limits: SplitterPanelLimits[], handle: number, delta: number, snap: boolean): number[];
@@ -0,0 +1,12 @@
1
+ import type { SplitterPanelLimits } from "./Splitter.types.js";
2
+ export declare const isCollapsed: (limits: SplitterPanelLimits, size: number) => boolean;
3
+ /** Panels with a default size keep it; the rest share what's left. Then everything is scaled to add up to 100. */
4
+ export declare function initialSizes(defaults: Array<number | undefined>): number[];
5
+ export declare function normalise(sizes: number[]): number[];
6
+ /**
7
+ * Moves the handle after panel `handle` by `delta` percent: the panel on the side it moves away from grows (up to its
8
+ * maximum), and the panels on the other side shrink in turn, nearest first, down to their minimums. With `snap`, a
9
+ * collapsible panel collapses once it's dragged more than halfway from its minimum to its collapsed size, and
10
+ * expands again past the same point.
11
+ */
12
+ export declare function moveHandle(sizes: number[], limits: SplitterPanelLimits[], handle: number, delta: number, snap: boolean): number[];
@@ -0,0 +1,69 @@
1
+ import type { HTMLAttributes, ReactNode } from "react";
2
+ export type SplitterDirection = "horizontal" | "vertical";
3
+ export interface SplitterProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
4
+ /** SplitterPanels with a SplitterHandle between each pair, straight inside (fragments are fine). */
5
+ children: ReactNode;
6
+ /** `horizontal` puts the panels side by side, `vertical` stacks them.
7
+ * @default "horizontal" */
8
+ direction?: SplitterDirection;
9
+ /** Each panel's size in percent, in order, adding up to 100, when you control it. */
10
+ sizes?: number[];
11
+ /** The sizes at first, when it controls itself. Without it, each panel's `defaultSize` is used, and panels without
12
+ * one share what's left. */
13
+ defaultSizes?: number[];
14
+ /** Called with every panel's size, in percent, as they change: while dragging, on each key press, on collapsing. */
15
+ onSizesChange?(sizes: number[]): void;
16
+ /** Remembers the sizes in localStorage under this name and puts them back next time. Give each splitter its own. */
17
+ autoSaveId?: string;
18
+ }
19
+ export interface SplitterPanelProps extends Omit<HTMLAttributes<HTMLDivElement>, "onResize"> {
20
+ children?: ReactNode;
21
+ /** Its size at first, in percent of the splitter. Panels without one share what the others leave. */
22
+ defaultSize?: number;
23
+ /** The smallest it can be dragged, in percent. @default 0 */
24
+ minSize?: number;
25
+ /** The largest it can be dragged, in percent. @default 100 */
26
+ maxSize?: number;
27
+ /** Lets it fold away: dragging well past `minSize`, double-clicking its handle, or Enter on the handle collapses it
28
+ * to `collapsedSize`, and the same expands it again. @default false */
29
+ collapsible?: boolean;
30
+ /** Its size when collapsed, in percent: 0 hides it, more leaves a strip such as a rail of icons. @default 0 */
31
+ collapsedSize?: number;
32
+ /** Called with its new size, in percent, when it changes. */
33
+ onResize?(size: number): void;
34
+ /** Called when it collapses or expands. */
35
+ onCollapsedChange?(collapsed: boolean): void;
36
+ }
37
+ export interface SplitterHandleProps extends Omit<HTMLAttributes<HTMLDivElement>, "children" | "role"> {
38
+ /** Names the handle for screen readers: say which panel it resizes, such as "Resize sidebar".
39
+ * @default "Resize panels" */
40
+ "aria-label"?: string;
41
+ /** Shows a small grip on the line, so it's easier to see and to catch on a touch screen. @default false */
42
+ grip?: boolean;
43
+ /** Keeps the panels at their sizes: the handle can't be dragged or focused. @default false */
44
+ disabled?: boolean;
45
+ }
46
+ /** A panel's limits, in percent, as the layout maths reads them. Internal. */
47
+ export interface SplitterPanelLimits {
48
+ minSize: number;
49
+ maxSize: number;
50
+ collapsible: boolean;
51
+ collapsedSize: number;
52
+ }
53
+ /** What a Splitter shares with its panels and handles. Internal. */
54
+ export interface SplitterState {
55
+ direction: SplitterDirection;
56
+ sizes: number[];
57
+ limits: SplitterPanelLimits[];
58
+ /** Each panel's element id, for the handles' aria-controls. */
59
+ panelIds: string[];
60
+ /** Moves handle `handle` by `delta` percent; `snap` lets a collapsible panel fold or unfold on the way. */
61
+ move(handle: number, delta: number, snap: boolean, from?: number[]): void;
62
+ /** Collapses or expands the collapsible panel beside the handle. */
63
+ toggle(handle: number): void;
64
+ /** The panels' length along the direction, in pixels, and whether a horizontal splitter runs right to left. */
65
+ measure(): {
66
+ length: number;
67
+ reversed: boolean;
68
+ };
69
+ }