@openwarelabs/ui 0.9.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.
- package/README.md +12 -4
- package/dist/components/Avatar/Avatar.d.cts +2 -13
- package/dist/components/Avatar/Avatar.d.ts +2 -13
- package/dist/components/Avatar/Avatar.types.d.cts +13 -0
- package/dist/components/Avatar/Avatar.types.d.ts +13 -0
- package/dist/components/Calendar/DatePicker.d.cts +2 -19
- package/dist/components/Calendar/DatePicker.d.ts +2 -19
- package/dist/components/Calendar/DatePicker.types.d.cts +19 -0
- package/dist/components/Calendar/DatePicker.types.d.ts +19 -0
- package/dist/components/Calendar/DateRangePicker.d.cts +2 -34
- package/dist/components/Calendar/DateRangePicker.d.ts +2 -34
- package/dist/components/Calendar/DateRangePicker.types.d.cts +34 -0
- package/dist/components/Calendar/DateRangePicker.types.d.ts +34 -0
- package/dist/components/ColorPicker/ColorPicker.d.cts +2 -55
- package/dist/components/ColorPicker/ColorPicker.d.ts +2 -55
- package/dist/components/ColorPicker/ColorPicker.types.d.cts +54 -0
- package/dist/components/ColorPicker/ColorPicker.types.d.ts +54 -0
- package/dist/components/ListBox/ListBox.d.cts +3 -61
- package/dist/components/ListBox/ListBox.d.ts +3 -61
- package/dist/components/ListBox/ListBox.types.d.cts +61 -0
- package/dist/components/ListBox/ListBox.types.d.ts +61 -0
- package/dist/components/Prose/Prose.d.cts +2 -16
- package/dist/components/Prose/Prose.d.ts +2 -16
- package/dist/components/Prose/Prose.types.d.cts +16 -0
- package/dist/components/Prose/Prose.types.d.ts +16 -0
- package/dist/components.css +16 -0
- package/dist/index.cjs +110 -98
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +179 -167
- package/dist/index.js.map +3 -3
- package/dist/openware-ui.iife.js +6 -6
- package/dist/styles.css +16 -0
- package/package.json +19 -5
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
|
|
@@ -71,7 +75,7 @@ Hooks for your own components: `useControllableState`, `useFloating` (top-layer
|
|
|
71
75
|
|
|
72
76
|
## Blocks as components
|
|
73
77
|
|
|
74
|
-
|
|
78
|
+
Every block is also a component in its own package, `@openwarelabs/blocks`, that takes its content as props, so you don't copy its code: all 95, from `Header01` and `Hero01` to `Settings03` and `Chat03` ([the list](blocks/README.md#blocks)).
|
|
75
79
|
|
|
76
80
|
```sh
|
|
77
81
|
npm install @openwarelabs/blocks
|
|
@@ -125,13 +129,17 @@ The docs' header has a colour picker that does this live, and the Theming page s
|
|
|
125
129
|
|
|
126
130
|
`main` takes changes only through pull requests, squash-merged, so each one lands as a single commit named after the PR. The PR title follows [Conventional Commits](https://www.conventionalcommits.org) because `npm run release` reads it: `feat: add a date range picker`, `fix(Menu): close on Escape`, `feat!: rename Stack's gap sizes`. Put `BREAKING CHANGE: …` in the PR description for a breaking change.
|
|
127
131
|
|
|
128
|
-
|
|
132
|
+
Five checks have to pass to merge:
|
|
129
133
|
|
|
130
|
-
- **Checks**: types, contrast, blocks, the library, the MCP server and the docs.
|
|
134
|
+
- **Checks**: types, contrast, blocks, the library, the MCP server and the docs, and the bundle size: what an app pays, minified and gzipped, for each package and for one piece of it imported alone, against the limits in `size-limits.json` (`npm run size` after a build). Raise a limit in the PR that needs it, so the growth is seen in review. It also lints for React's hooks rules (`npm run lint`; `eslint-suppressions.json` lists the problems there already were), and packs both packages as `npm publish` would, installs them in a new app and imports, requires, bundles and type-checks them there (`npm run smoke`).
|
|
131
135
|
- **PR title**: the title follows the convention (`npm run commits:check -- --title "feat: …"` locally).
|
|
132
136
|
- **Cleaner**: [openwarelabs/cleaner](https://github.com/openwarelabs/cleaner) on the `.ts` and `.tsx` files the PR changes. Types go in a `<name>.types.ts` beside the component, and imports from another folder use the aliases instead of `../`: `@/…` for `src/` (in the library and the docs), `@docs/…` for `docs/` (`?highlight` imports too) and `@build/…` in `mcp/`. Files that haven't been touched yet don't follow it; they catch up as they change.
|
|
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).
|
|
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).
|
|
139
|
+
|
|
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.
|
|
133
141
|
|
|
134
|
-
`scripts/setup-github.sh` sets this up on GitHub (squash merges only, the PR title as the commit, the ruleset for `main
|
|
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.
|
|
135
143
|
|
|
136
144
|
## Releasing
|
|
137
145
|
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { type CSSProperties } from "react";
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
3
|
-
|
|
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 {
|
|
2
|
-
export
|
|
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 {
|
|
2
|
-
export
|
|
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
|
|
2
|
-
|
|
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
|
|
2
|
-
|
|
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 {
|
|
2
|
-
|
|
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 {
|
|
2
|
-
|
|
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
|
+
}
|