@openwarelabs/ui 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +5 -1
  2. package/dist/components/Avatar/Avatar.d.cts +2 -13
  3. package/dist/components/Avatar/Avatar.d.ts +2 -13
  4. package/dist/components/Avatar/Avatar.types.d.cts +13 -0
  5. package/dist/components/Avatar/Avatar.types.d.ts +13 -0
  6. package/dist/components/Calendar/DatePicker.d.cts +2 -19
  7. package/dist/components/Calendar/DatePicker.d.ts +2 -19
  8. package/dist/components/Calendar/DatePicker.types.d.cts +19 -0
  9. package/dist/components/Calendar/DatePicker.types.d.ts +19 -0
  10. package/dist/components/Calendar/DateRangePicker.d.cts +2 -34
  11. package/dist/components/Calendar/DateRangePicker.d.ts +2 -34
  12. package/dist/components/Calendar/DateRangePicker.types.d.cts +34 -0
  13. package/dist/components/Calendar/DateRangePicker.types.d.ts +34 -0
  14. package/dist/components/ColorPicker/ColorPicker.d.cts +2 -55
  15. package/dist/components/ColorPicker/ColorPicker.d.ts +2 -55
  16. package/dist/components/ColorPicker/ColorPicker.types.d.cts +54 -0
  17. package/dist/components/ColorPicker/ColorPicker.types.d.ts +54 -0
  18. package/dist/components/ListBox/ListBox.d.cts +3 -61
  19. package/dist/components/ListBox/ListBox.d.ts +3 -61
  20. package/dist/components/ListBox/ListBox.types.d.cts +61 -0
  21. package/dist/components/ListBox/ListBox.types.d.ts +61 -0
  22. package/dist/components/Prose/Prose.d.cts +2 -16
  23. package/dist/components/Prose/Prose.d.ts +2 -16
  24. package/dist/components/Prose/Prose.types.d.cts +16 -0
  25. package/dist/components/Prose/Prose.types.d.ts +16 -0
  26. package/dist/components.css +16 -0
  27. package/dist/index.cjs +34 -13
  28. package/dist/index.cjs.map +2 -2
  29. package/dist/index.js +103 -82
  30. package/dist/index.js.map +3 -3
  31. package/dist/openware-ui.iife.js +6 -6
  32. package/dist/styles.css +16 -0
  33. package/package.json +4 -4
package/README.md CHANGED
@@ -2,8 +2,12 @@
2
2
 
3
3
  React components and design tokens with a quiet, tactile look: a midnight brand colour, a brass accent kept small, cool slate surfaces, buttons that press in, and Inter. Light and dark themes, and a brand colour you can swap.
4
4
 
5
+ **Docs: [openwarelabs.github.io/ui](https://openwarelabs.github.io/ui/)**: every component with live examples and props, every block, the tokens and the guides. It's published from each release, so it matches the packages on npm.
6
+
5
7
  ## Docs
6
8
 
9
+ To run them from the repository:
10
+
7
11
  ```sh
8
12
  npm install # installs and builds dist/
9
13
  npm run dev # the docs site: http://localhost:5173
@@ -133,7 +137,7 @@ Five checks have to pass to merge:
133
137
  - **Visual**: every block (desktop and phone width) and every component example, in light and dark, rendered from the PR and from `main` and compared pixel by pixel. If something looks different, the run's summary lists it and the `visual-report` artifact shows each one before, after and with the changed pixels marked. When the change is meant, add the **visual change** label and the check passes. `npm run visual` runs the same comparison locally against `main` (`-- --filter Hero` for a few).
134
138
  - **Accessibility**: axe over every block (desktop and phone width) and every component example, in light and dark, against WCAG 2.2 A and AA. The run's summary lists each problem with the element and how to fix it. `a11y-known.json` lists the problems there already were, which don't fail it; fixing one means lowering its count. `npm run a11y` runs it locally (`-- --filter Hero` for a few).
135
139
 
136
- Dependabot opens a pull request each Monday with the week's npm and GitHub Actions updates, minor and patch ones grouped; every check above runs on it.
140
+ Dependabot opens a pull request each Monday with the week's npm and GitHub Actions updates, minor and patch ones grouped, and React with React DOM in one. Only Checks runs on those (types, builds, size and the package smoke test): PR title, Cleaner, Visual and Accessibility are for changes people make, and skipped jobs count as passing.
137
141
 
138
142
  `scripts/setup-github.sh` sets this up on GitHub (squash merges only, the PR title as the commit, the ruleset for `main`, the visual change label). Repository admins can bypass the ruleset, which `npm run release` uses to push its version commit and tag.
139
143
 
@@ -1,17 +1,6 @@
1
1
  import { type CSSProperties } from "react";
2
- export interface AvatarProps {
3
- /** The person's name; its initials show when there's no image. */
4
- name: string;
5
- /** A photo URL. If it fails to load, the initials show instead. */
6
- src?: string;
7
- /** sm 24px, md 28px, lg 36px, xl 48px, or any size in pixels, such as 96 for a team page. The initials scale with it.
8
- * @default "md" */
9
- size?: AvatarSize;
10
- /** Give it when the avatar stands alone; beside the name, leave it out and it's hidden from screen readers. */
11
- label?: string;
12
- className?: string;
13
- }
14
- export type AvatarSize = "sm" | "md" | "lg" | "xl" | number;
2
+ import type { AvatarProps, AvatarSize } from "./Avatar.types.cjs";
3
+ export type { AvatarProps, AvatarSize } from "./Avatar.types.cjs";
15
4
  /**
16
5
  * The class and style that size an avatar: a named size's class, or a pixel size through --ow-avatar-size.
17
6
  * @internal
@@ -1,17 +1,6 @@
1
1
  import { type CSSProperties } from "react";
2
- export interface AvatarProps {
3
- /** The person's name; its initials show when there's no image. */
4
- name: string;
5
- /** A photo URL. If it fails to load, the initials show instead. */
6
- src?: string;
7
- /** sm 24px, md 28px, lg 36px, xl 48px, or any size in pixels, such as 96 for a team page. The initials scale with it.
8
- * @default "md" */
9
- size?: AvatarSize;
10
- /** Give it when the avatar stands alone; beside the name, leave it out and it's hidden from screen readers. */
11
- label?: string;
12
- className?: string;
13
- }
14
- export type AvatarSize = "sm" | "md" | "lg" | "xl" | number;
2
+ import type { AvatarProps, AvatarSize } from "./Avatar.types.js";
3
+ export type { AvatarProps, AvatarSize } from "./Avatar.types.js";
15
4
  /**
16
5
  * The class and style that size an avatar: a named size's class, or a pixel size through --ow-avatar-size.
17
6
  * @internal
@@ -0,0 +1,13 @@
1
+ export interface AvatarProps {
2
+ /** The person's name; its initials show when there's no image. */
3
+ name: string;
4
+ /** A photo URL. If it fails to load, the initials show instead. */
5
+ src?: string;
6
+ /** sm 24px, md 28px, lg 36px, xl 48px, or any size in pixels, such as 96 for a team page. The initials scale with it.
7
+ * @default "md" */
8
+ size?: AvatarSize;
9
+ /** Give it when the avatar stands alone; beside the name, leave it out and it's hidden from screen readers. */
10
+ label?: string;
11
+ className?: string;
12
+ }
13
+ export type AvatarSize = "sm" | "md" | "lg" | "xl" | number;
@@ -0,0 +1,13 @@
1
+ export interface AvatarProps {
2
+ /** The person's name; its initials show when there's no image. */
3
+ name: string;
4
+ /** A photo URL. If it fails to load, the initials show instead. */
5
+ src?: string;
6
+ /** sm 24px, md 28px, lg 36px, xl 48px, or any size in pixels, such as 96 for a team page. The initials scale with it.
7
+ * @default "md" */
8
+ size?: AvatarSize;
9
+ /** Give it when the avatar stands alone; beside the name, leave it out and it's hidden from screen readers. */
10
+ label?: string;
11
+ className?: string;
12
+ }
13
+ export type AvatarSize = "sm" | "md" | "lg" | "xl" | number;
@@ -1,21 +1,4 @@
1
- import { type CalendarProps } from "./Calendar.cjs";
2
- export interface DatePickerProps extends Omit<CalendarProps, "autoFocus" | "className"> {
3
- /** Shown when no date is chosen.
4
- * @default "Pick a date" */
5
- placeholder?: string;
6
- /** How the chosen date is written in the field.
7
- * @default { dateStyle: "medium" } */
8
- formatOptions?: Intl.DateTimeFormatOptions;
9
- /** @default "md" */
10
- size?: "sm" | "md";
11
- /** @default false */
12
- isInvalid?: boolean;
13
- disabled?: boolean;
14
- id?: string;
15
- "aria-label"?: string;
16
- "aria-labelledby"?: string;
17
- "aria-describedby"?: string;
18
- className?: string;
19
- }
1
+ import type { DatePickerProps } from "./DatePicker.types.cjs";
2
+ export type { DatePickerProps } from "./DatePicker.types.cjs";
20
3
  /** A field that opens a Calendar. Choosing a date closes it; Escape closes it without changing anything. */
21
4
  export declare const DatePicker: import("react").ForwardRefExoticComponent<DatePickerProps & import("react").RefAttributes<HTMLButtonElement>>;
@@ -1,21 +1,4 @@
1
- import { type CalendarProps } from "./Calendar.js";
2
- export interface DatePickerProps extends Omit<CalendarProps, "autoFocus" | "className"> {
3
- /** Shown when no date is chosen.
4
- * @default "Pick a date" */
5
- placeholder?: string;
6
- /** How the chosen date is written in the field.
7
- * @default { dateStyle: "medium" } */
8
- formatOptions?: Intl.DateTimeFormatOptions;
9
- /** @default "md" */
10
- size?: "sm" | "md";
11
- /** @default false */
12
- isInvalid?: boolean;
13
- disabled?: boolean;
14
- id?: string;
15
- "aria-label"?: string;
16
- "aria-labelledby"?: string;
17
- "aria-describedby"?: string;
18
- className?: string;
19
- }
1
+ import type { DatePickerProps } from "./DatePicker.types.js";
2
+ export type { DatePickerProps } from "./DatePicker.types.js";
20
3
  /** A field that opens a Calendar. Choosing a date closes it; Escape closes it without changing anything. */
21
4
  export declare const DatePicker: import("react").ForwardRefExoticComponent<DatePickerProps & import("react").RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,19 @@
1
+ import type { CalendarProps } from "./Calendar.cjs";
2
+ export interface DatePickerProps extends Omit<CalendarProps, "autoFocus" | "className"> {
3
+ /** Shown when no date is chosen.
4
+ * @default "Pick a date" */
5
+ placeholder?: string;
6
+ /** How the chosen date is written in the field.
7
+ * @default { dateStyle: "medium" } */
8
+ formatOptions?: Intl.DateTimeFormatOptions;
9
+ /** @default "md" */
10
+ size?: "sm" | "md";
11
+ /** @default false */
12
+ isInvalid?: boolean;
13
+ disabled?: boolean;
14
+ id?: string;
15
+ "aria-label"?: string;
16
+ "aria-labelledby"?: string;
17
+ "aria-describedby"?: string;
18
+ className?: string;
19
+ }
@@ -0,0 +1,19 @@
1
+ import type { CalendarProps } from "./Calendar.js";
2
+ export interface DatePickerProps extends Omit<CalendarProps, "autoFocus" | "className"> {
3
+ /** Shown when no date is chosen.
4
+ * @default "Pick a date" */
5
+ placeholder?: string;
6
+ /** How the chosen date is written in the field.
7
+ * @default { dateStyle: "medium" } */
8
+ formatOptions?: Intl.DateTimeFormatOptions;
9
+ /** @default "md" */
10
+ size?: "sm" | "md";
11
+ /** @default false */
12
+ isInvalid?: boolean;
13
+ disabled?: boolean;
14
+ id?: string;
15
+ "aria-label"?: string;
16
+ "aria-labelledby"?: string;
17
+ "aria-describedby"?: string;
18
+ className?: string;
19
+ }
@@ -1,37 +1,5 @@
1
- import { type DateRange, type RangeCalendarProps } from "./RangeCalendar.cjs";
2
- /** A named range to pick in one go, such as "Last 7 days". */
3
- export interface DateRangePreset {
4
- /** What the list shows, in sentence case. */
5
- label: string;
6
- range: DateRange;
7
- }
8
- export interface DateRangePickerProps extends Omit<RangeCalendarProps, "autoFocus" | "className" | "visibleMonths"> {
9
- /** Ranges to pick in one go, listed beside the calendar: "Last 7 days", "This month". */
10
- presets?: DateRangePreset[];
11
- /** How many months the calendar shows side by side. Phones always get one.
12
- * @default 2 */
13
- visibleMonths?: 1 | 2;
14
- /** Shown when no range is chosen.
15
- * @default "Pick dates" */
16
- placeholder?: string;
17
- /** How each date is written in the field; dates the two ends share are written once, as in "3 – 9 Oct 2026".
18
- * @default { dateStyle: "medium" } */
19
- formatOptions?: Intl.DateTimeFormatOptions;
20
- /** md is 40px tall, sm 32px.
21
- * @default "md" */
22
- size?: "sm" | "md";
23
- /** @default false */
24
- isInvalid?: boolean;
25
- /** @default false */
26
- disabled?: boolean;
27
- /** For the field's button, so a label can point at it. */
28
- id?: string;
29
- "aria-label"?: string;
30
- "aria-labelledby"?: string;
31
- "aria-describedby"?: string;
32
- /** Classes for the field, e.g. a width. */
33
- className?: string;
34
- }
1
+ import type { DateRangePickerProps } from "./DateRangePicker.types.cjs";
2
+ export type { DateRangePickerProps, DateRangePreset } from "./DateRangePicker.types.cjs";
35
3
  /**
36
4
  * A field that opens a two-month RangeCalendar, with optional presets beside it. Picking the second day, or a preset,
37
5
  * closes it; Escape closes it without changing anything. Once there's a range, a clear button empties it.
@@ -1,37 +1,5 @@
1
- import { type DateRange, type RangeCalendarProps } from "./RangeCalendar.js";
2
- /** A named range to pick in one go, such as "Last 7 days". */
3
- export interface DateRangePreset {
4
- /** What the list shows, in sentence case. */
5
- label: string;
6
- range: DateRange;
7
- }
8
- export interface DateRangePickerProps extends Omit<RangeCalendarProps, "autoFocus" | "className" | "visibleMonths"> {
9
- /** Ranges to pick in one go, listed beside the calendar: "Last 7 days", "This month". */
10
- presets?: DateRangePreset[];
11
- /** How many months the calendar shows side by side. Phones always get one.
12
- * @default 2 */
13
- visibleMonths?: 1 | 2;
14
- /** Shown when no range is chosen.
15
- * @default "Pick dates" */
16
- placeholder?: string;
17
- /** How each date is written in the field; dates the two ends share are written once, as in "3 – 9 Oct 2026".
18
- * @default { dateStyle: "medium" } */
19
- formatOptions?: Intl.DateTimeFormatOptions;
20
- /** md is 40px tall, sm 32px.
21
- * @default "md" */
22
- size?: "sm" | "md";
23
- /** @default false */
24
- isInvalid?: boolean;
25
- /** @default false */
26
- disabled?: boolean;
27
- /** For the field's button, so a label can point at it. */
28
- id?: string;
29
- "aria-label"?: string;
30
- "aria-labelledby"?: string;
31
- "aria-describedby"?: string;
32
- /** Classes for the field, e.g. a width. */
33
- className?: string;
34
- }
1
+ import type { DateRangePickerProps } from "./DateRangePicker.types.js";
2
+ export type { DateRangePickerProps, DateRangePreset } from "./DateRangePicker.types.js";
35
3
  /**
36
4
  * A field that opens a two-month RangeCalendar, with optional presets beside it. Picking the second day, or a preset,
37
5
  * closes it; Escape closes it without changing anything. Once there's a range, a clear button empties it.
@@ -0,0 +1,34 @@
1
+ import type { DateRange, RangeCalendarProps } from "./RangeCalendar.cjs";
2
+ /** A named range to pick in one go, such as "Last 7 days". */
3
+ export interface DateRangePreset {
4
+ /** What the list shows, in sentence case. */
5
+ label: string;
6
+ range: DateRange;
7
+ }
8
+ export interface DateRangePickerProps extends Omit<RangeCalendarProps, "autoFocus" | "className" | "visibleMonths"> {
9
+ /** Ranges to pick in one go, listed beside the calendar: "Last 7 days", "This month". */
10
+ presets?: DateRangePreset[];
11
+ /** How many months the calendar shows side by side. Phones always get one.
12
+ * @default 2 */
13
+ visibleMonths?: 1 | 2;
14
+ /** Shown when no range is chosen.
15
+ * @default "Pick dates" */
16
+ placeholder?: string;
17
+ /** How each date is written in the field; dates the two ends share are written once, as in "3 – 9 Oct 2026".
18
+ * @default { dateStyle: "medium" } */
19
+ formatOptions?: Intl.DateTimeFormatOptions;
20
+ /** md is 40px tall, sm 32px.
21
+ * @default "md" */
22
+ size?: "sm" | "md";
23
+ /** @default false */
24
+ isInvalid?: boolean;
25
+ /** @default false */
26
+ disabled?: boolean;
27
+ /** For the field's button, so a label can point at it. */
28
+ id?: string;
29
+ "aria-label"?: string;
30
+ "aria-labelledby"?: string;
31
+ "aria-describedby"?: string;
32
+ /** Classes for the field, e.g. a width. */
33
+ className?: string;
34
+ }
@@ -0,0 +1,34 @@
1
+ import type { DateRange, RangeCalendarProps } from "./RangeCalendar.js";
2
+ /** A named range to pick in one go, such as "Last 7 days". */
3
+ export interface DateRangePreset {
4
+ /** What the list shows, in sentence case. */
5
+ label: string;
6
+ range: DateRange;
7
+ }
8
+ export interface DateRangePickerProps extends Omit<RangeCalendarProps, "autoFocus" | "className" | "visibleMonths"> {
9
+ /** Ranges to pick in one go, listed beside the calendar: "Last 7 days", "This month". */
10
+ presets?: DateRangePreset[];
11
+ /** How many months the calendar shows side by side. Phones always get one.
12
+ * @default 2 */
13
+ visibleMonths?: 1 | 2;
14
+ /** Shown when no range is chosen.
15
+ * @default "Pick dates" */
16
+ placeholder?: string;
17
+ /** How each date is written in the field; dates the two ends share are written once, as in "3 – 9 Oct 2026".
18
+ * @default { dateStyle: "medium" } */
19
+ formatOptions?: Intl.DateTimeFormatOptions;
20
+ /** md is 40px tall, sm 32px.
21
+ * @default "md" */
22
+ size?: "sm" | "md";
23
+ /** @default false */
24
+ isInvalid?: boolean;
25
+ /** @default false */
26
+ disabled?: boolean;
27
+ /** For the field's button, so a label can point at it. */
28
+ id?: string;
29
+ "aria-label"?: string;
30
+ "aria-labelledby"?: string;
31
+ "aria-describedby"?: string;
32
+ /** Classes for the field, e.g. a width. */
33
+ className?: string;
34
+ }
@@ -1,62 +1,9 @@
1
- import { type Placement } from "../../hooks/useFloating.cjs";
2
- /** What a swatch is: a colour, or a colour with a name to read out. */
3
- export type ColorSwatchOption = string | {
4
- color: string;
5
- name: string;
6
- };
7
- export interface ColorPickerProps {
8
- /** A hex colour: "#0d9488", or "#0d9488cc" with alpha. */
9
- value?: string;
10
- /** @default "#312c7e" */
11
- defaultValue?: string;
12
- /** Called with a lowercase hex colour as the person drags, types or picks. */
13
- onChange?(color: string): void;
14
- /** Adds an opacity slider; colours come back as #rrggbbaa.
15
- * @default false */
16
- alpha?: boolean;
17
- /** Ready-made colours as swatches under the picker. */
18
- swatches?: ColorSwatchOption[];
19
- /** The hex field under the picker.
20
- * @default true */
21
- showInput?: boolean;
22
- /** A button that picks a colour from anywhere on the screen, where the browser can (Chrome and Edge).
23
- * @default true */
24
- eyeDropper?: boolean;
25
- /** Names the picker for screen readers.
26
- * @default "Colour" */
27
- "aria-label"?: string;
28
- className?: string;
29
- }
30
- interface EyeDropperResult {
31
- sRGBHex: string;
32
- }
33
- declare global {
34
- interface Window {
35
- EyeDropper?: new () => {
36
- open(): Promise<EyeDropperResult>;
37
- };
38
- }
39
- }
1
+ import type { ColorFieldProps, ColorPickerProps } from "./ColorPicker.types.cjs";
2
+ export type { ColorFieldProps, ColorPickerProps, ColorSwatchOption } from "./ColorPicker.types.cjs";
40
3
  /**
41
4
  * Picks a colour: a saturation area and a hue slider (react-colorful, dressed in Openware's look), a hex field,
42
5
  * an eyedropper where the browser has one, and optional swatches. The area and sliders work with the arrow keys.
43
6
  */
44
7
  export declare function ColorPicker({ value, defaultValue, onChange, alpha, swatches, showInput, eyeDropper, "aria-label": ariaLabel, className, }: ColorPickerProps): import("react").JSX.Element;
45
- export interface ColorFieldProps extends Omit<ColorPickerProps, "className" | "aria-label"> {
46
- /** @default "md" */
47
- size?: "sm" | "md";
48
- /** @default false */
49
- isInvalid?: boolean;
50
- disabled?: boolean;
51
- /** Where the picker opens; it flips when there's no room.
52
- * @default "bottom-start" */
53
- placement?: Placement;
54
- id?: string;
55
- "aria-label"?: string;
56
- "aria-labelledby"?: string;
57
- "aria-describedby"?: string;
58
- className?: string;
59
- }
60
8
  /** A field that shows a colour and its hex, and opens a ColorPicker below. Escape or a click outside closes it. */
61
9
  export declare const ColorField: import("react").ForwardRefExoticComponent<ColorFieldProps & import("react").RefAttributes<HTMLButtonElement>>;
62
- export {};
@@ -1,62 +1,9 @@
1
- import { type Placement } from "../../hooks/useFloating.js";
2
- /** What a swatch is: a colour, or a colour with a name to read out. */
3
- export type ColorSwatchOption = string | {
4
- color: string;
5
- name: string;
6
- };
7
- export interface ColorPickerProps {
8
- /** A hex colour: "#0d9488", or "#0d9488cc" with alpha. */
9
- value?: string;
10
- /** @default "#312c7e" */
11
- defaultValue?: string;
12
- /** Called with a lowercase hex colour as the person drags, types or picks. */
13
- onChange?(color: string): void;
14
- /** Adds an opacity slider; colours come back as #rrggbbaa.
15
- * @default false */
16
- alpha?: boolean;
17
- /** Ready-made colours as swatches under the picker. */
18
- swatches?: ColorSwatchOption[];
19
- /** The hex field under the picker.
20
- * @default true */
21
- showInput?: boolean;
22
- /** A button that picks a colour from anywhere on the screen, where the browser can (Chrome and Edge).
23
- * @default true */
24
- eyeDropper?: boolean;
25
- /** Names the picker for screen readers.
26
- * @default "Colour" */
27
- "aria-label"?: string;
28
- className?: string;
29
- }
30
- interface EyeDropperResult {
31
- sRGBHex: string;
32
- }
33
- declare global {
34
- interface Window {
35
- EyeDropper?: new () => {
36
- open(): Promise<EyeDropperResult>;
37
- };
38
- }
39
- }
1
+ import type { ColorFieldProps, ColorPickerProps } from "./ColorPicker.types.js";
2
+ export type { ColorFieldProps, ColorPickerProps, ColorSwatchOption } from "./ColorPicker.types.js";
40
3
  /**
41
4
  * Picks a colour: a saturation area and a hue slider (react-colorful, dressed in Openware's look), a hex field,
42
5
  * an eyedropper where the browser has one, and optional swatches. The area and sliders work with the arrow keys.
43
6
  */
44
7
  export declare function ColorPicker({ value, defaultValue, onChange, alpha, swatches, showInput, eyeDropper, "aria-label": ariaLabel, className, }: ColorPickerProps): import("react").JSX.Element;
45
- export interface ColorFieldProps extends Omit<ColorPickerProps, "className" | "aria-label"> {
46
- /** @default "md" */
47
- size?: "sm" | "md";
48
- /** @default false */
49
- isInvalid?: boolean;
50
- disabled?: boolean;
51
- /** Where the picker opens; it flips when there's no room.
52
- * @default "bottom-start" */
53
- placement?: Placement;
54
- id?: string;
55
- "aria-label"?: string;
56
- "aria-labelledby"?: string;
57
- "aria-describedby"?: string;
58
- className?: string;
59
- }
60
8
  /** A field that shows a colour and its hex, and opens a ColorPicker below. Escape or a click outside closes it. */
61
9
  export declare const ColorField: import("react").ForwardRefExoticComponent<ColorFieldProps & import("react").RefAttributes<HTMLButtonElement>>;
62
- export {};
@@ -0,0 +1,54 @@
1
+ import type { Placement } from "../../hooks/useFloating.cjs";
2
+ /** What a swatch is: a colour, or a colour with a name to read out. */
3
+ export type ColorSwatchOption = string | {
4
+ color: string;
5
+ name: string;
6
+ };
7
+ export interface ColorPickerProps {
8
+ /** A hex colour: "#0d9488", or "#0d9488cc" with alpha. */
9
+ value?: string;
10
+ /** @default "#312c7e" */
11
+ defaultValue?: string;
12
+ /** Called with a lowercase hex colour as the person drags, types or picks. */
13
+ onChange?(color: string): void;
14
+ /** Adds an opacity slider; colours come back as #rrggbbaa.
15
+ * @default false */
16
+ alpha?: boolean;
17
+ /** Ready-made colours as swatches under the picker. */
18
+ swatches?: ColorSwatchOption[];
19
+ /** The hex field under the picker.
20
+ * @default true */
21
+ showInput?: boolean;
22
+ /** A button that picks a colour from anywhere on the screen, where the browser can (Chrome and Edge).
23
+ * @default true */
24
+ eyeDropper?: boolean;
25
+ /** Names the picker for screen readers.
26
+ * @default "Colour" */
27
+ "aria-label"?: string;
28
+ className?: string;
29
+ }
30
+ export interface EyeDropperResult {
31
+ sRGBHex: string;
32
+ }
33
+ declare global {
34
+ interface Window {
35
+ EyeDropper?: new () => {
36
+ open(): Promise<EyeDropperResult>;
37
+ };
38
+ }
39
+ }
40
+ export interface ColorFieldProps extends Omit<ColorPickerProps, "className" | "aria-label"> {
41
+ /** @default "md" */
42
+ size?: "sm" | "md";
43
+ /** @default false */
44
+ isInvalid?: boolean;
45
+ disabled?: boolean;
46
+ /** Where the picker opens; it flips when there's no room.
47
+ * @default "bottom-start" */
48
+ placement?: Placement;
49
+ id?: string;
50
+ "aria-label"?: string;
51
+ "aria-labelledby"?: string;
52
+ "aria-describedby"?: string;
53
+ className?: string;
54
+ }
@@ -0,0 +1,54 @@
1
+ import type { Placement } from "../../hooks/useFloating.js";
2
+ /** What a swatch is: a colour, or a colour with a name to read out. */
3
+ export type ColorSwatchOption = string | {
4
+ color: string;
5
+ name: string;
6
+ };
7
+ export interface ColorPickerProps {
8
+ /** A hex colour: "#0d9488", or "#0d9488cc" with alpha. */
9
+ value?: string;
10
+ /** @default "#312c7e" */
11
+ defaultValue?: string;
12
+ /** Called with a lowercase hex colour as the person drags, types or picks. */
13
+ onChange?(color: string): void;
14
+ /** Adds an opacity slider; colours come back as #rrggbbaa.
15
+ * @default false */
16
+ alpha?: boolean;
17
+ /** Ready-made colours as swatches under the picker. */
18
+ swatches?: ColorSwatchOption[];
19
+ /** The hex field under the picker.
20
+ * @default true */
21
+ showInput?: boolean;
22
+ /** A button that picks a colour from anywhere on the screen, where the browser can (Chrome and Edge).
23
+ * @default true */
24
+ eyeDropper?: boolean;
25
+ /** Names the picker for screen readers.
26
+ * @default "Colour" */
27
+ "aria-label"?: string;
28
+ className?: string;
29
+ }
30
+ export interface EyeDropperResult {
31
+ sRGBHex: string;
32
+ }
33
+ declare global {
34
+ interface Window {
35
+ EyeDropper?: new () => {
36
+ open(): Promise<EyeDropperResult>;
37
+ };
38
+ }
39
+ }
40
+ export interface ColorFieldProps extends Omit<ColorPickerProps, "className" | "aria-label"> {
41
+ /** @default "md" */
42
+ size?: "sm" | "md";
43
+ /** @default false */
44
+ isInvalid?: boolean;
45
+ disabled?: boolean;
46
+ /** Where the picker opens; it flips when there's no room.
47
+ * @default "bottom-start" */
48
+ placement?: Placement;
49
+ id?: string;
50
+ "aria-label"?: string;
51
+ "aria-labelledby"?: string;
52
+ "aria-describedby"?: string;
53
+ className?: string;
54
+ }
@@ -1,64 +1,6 @@
1
- import { type ReactElement, type ReactNode, type RefAttributes } from "react";
2
- import type { SelectOption } from "../Select/Select.cjs";
3
- /** An option, shaped like Select's, with an optional icon. */
4
- export interface ListBoxOption extends SelectOption {
5
- /** A 16px icon between the checkmark and the label. */
6
- icon?: ReactNode;
7
- /** Plain text for type-to-find, when `label` isn't a string. */
8
- textValue?: string;
9
- }
10
- /** Options under a heading, like a Select's groups. */
11
- export interface ListBoxGroup {
12
- /** The heading, shown in uppercase above the options and read out as the group's name. */
13
- label: string;
14
- options: ListBoxOption[];
15
- }
16
- export type ListBoxItem = ListBoxOption | ListBoxGroup;
17
- export type ListBoxSelectionMode = "single" | "multiple";
18
- /** ListBox's props for one selection mode: `value` is a string in single mode and an array in multiple mode. */
19
- export interface ListBoxModeProps<Mode extends ListBoxSelectionMode> {
20
- /** The options, and groups of options under a heading. */
21
- options: ListBoxItem[];
22
- /** `single` chooses one option; `multiple` any number.
23
- * @default "single" */
24
- selectionMode?: Mode;
25
- /** The selected option's value in single mode ("" for none), or the selected values in multiple mode. */
26
- value?: Mode extends "multiple" ? string[] : string;
27
- /** The starting value when uncontrolled.
28
- * @default "" or [] */
29
- defaultValue?: Mode extends "multiple" ? string[] : string;
30
- /** Called with the new value: a string in single mode, the selected values in the options' order in multiple mode. */
31
- onChange?(value: Mode extends "multiple" ? string[] : string): void;
32
- /** Keeps at least one option selected: choosing the selected option again doesn't clear it.
33
- * @default false */
34
- disallowEmptySelection?: boolean;
35
- /** Shown in the list when there are no options.
36
- * @default "No options" */
37
- emptyMessage?: ReactNode;
38
- /** Scrolls the options past this height, e.g. 240 or "40vh". */
39
- maxHeight?: number | string;
40
- /** md rows are 36px; sm rows are 32px with 12px text, like a small Select's list.
41
- * @default "md" */
42
- size?: "sm" | "md";
43
- /** Shows the list as wrong: a red border, and a red halo when focused. Also sets aria-invalid. Field passes it.
44
- * @default false */
45
- isInvalid?: boolean;
46
- /** The options can be moved through and read, but the selection can't change.
47
- * @default false */
48
- isReadOnly?: boolean;
49
- /** Fades the list and takes it out of the tab order.
50
- * @default false */
51
- disabled?: boolean;
52
- id?: string;
53
- /** Names the list for screen readers when it isn't in a Field. */
54
- "aria-label"?: string;
55
- "aria-labelledby"?: string;
56
- "aria-describedby"?: string;
57
- className?: string;
58
- }
59
- /** ListBox's props. `value`, `defaultValue` and `onChange` take a string in single mode and an array in multiple mode. */
60
- export interface ListBoxProps extends ListBoxModeProps<ListBoxSelectionMode> {
61
- }
1
+ import { type ReactElement, type RefAttributes } from "react";
2
+ import type { ListBoxModeProps, ListBoxSelectionMode } from "./ListBox.types.cjs";
3
+ export type { ListBoxGroup, ListBoxItem, ListBoxModeProps, ListBoxOption, ListBoxProps, ListBoxSelectionMode } from "./ListBox.types.cjs";
62
4
  /**
63
5
  * Select's list of options on its own: a choice that stays on the page. `selectionMode="multiple"` makes `value` an array.
64
6
  */