@hussmartinez/ui 0.7.0 → 0.9.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.
@@ -5,6 +5,7 @@ var UiError = class extends SdkError {
5
5
  };
6
6
  // src/messages/en.ts
7
7
  var uiMessages = /* @__PURE__ */ defineMessages({
8
+ "colorField.swatches": "swatches",
8
9
  "dialog.close": "Close",
9
10
  "fileDropZone.choose": "Choose a file",
10
11
  "fileDropZone.chooseMultiple": "Choose files",
@@ -40,4 +41,4 @@ function isThemePair(value) {
40
41
  }
41
42
  export { uiMessages as a, warnInDevelopment as i, cssWriterOf as n, UiError as o, registerTheme as r, isThemePair as t };
42
43
 
43
- //# sourceMappingURL=pair-DLVFV6vU.js.map
44
+ //# sourceMappingURL=pair-pt-vUVwu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pair-pt-vUVwu.js","names":[],"sources":["../../src/errors/ui-error.ts","../../src/messages/en.ts","../../src/internal/development.ts","../../src/theme/registry.ts","../../src/theme/pair.ts"],"sourcesContent":["import { SdkError } from \"@hussmartinez/sdk-core\";\n\n/**\n * Error codes of `@hussmartinez/ui`. They never change once released.\n *\n * - `INVALID_THEME_TOKEN`: a theme token has an unknown name, or a value that\n * isn't allowed for its type. `details` has `token`, `value` and `reason`.\n * - `INVALID_THEME_SELECTOR`: the selector passed to `themeToCss` isn't a\n * plain CSS selector. `details` has `selector` and `reason`.\n *\n * @public\n */\nexport type UiErrorCode = \"INVALID_THEME_TOKEN\" | \"INVALID_THEME_SELECTOR\";\n\n/**\n * The error `@hussmartinez/ui` throws, with a stable `code` and structured\n * `details`. Show users the text for its code from {@link uiMessages}, never\n * its `message`.\n *\n * @example\n * ```ts\n * try {\n * createTheme({ extends: \"light\", tokens: { \"color-accent\": brandColour } });\n * } catch (error) {\n * if (isSdkError(error, \"INVALID_THEME_TOKEN\")) {\n * // Ask for another colour.\n * }\n * }\n * ```\n *\n * @public\n */\nexport class UiError extends SdkError<UiErrorCode> {\n override readonly name = \"UiError\";\n}\n","import { defineMessages } from \"@hussmartinez/sdk-core\";\n\n/**\n * English text for `@hussmartinez/ui`'s error codes. Applications and SDKs\n * spread it into their catalogue, next to `sdkCoreMessages`, so\n * `messages.error()` can describe a `UiError`. Components add their\n * text here as they arrive.\n *\n * @example\n * ```ts\n * export const en = defineMessages({ ...sdkCoreMessages, ...uiMessages });\n * ```\n *\n * @public\n */\nexport const uiMessages = /* @__PURE__ */ defineMessages({\n \"colorField.swatches\": \"swatches\",\n \"dialog.close\": \"Close\",\n \"fileDropZone.choose\": \"Choose a file\",\n \"fileDropZone.chooseMultiple\": \"Choose files\",\n \"fileDropZone.hint\": \"or drop it here\",\n \"fileDropZone.hintMultiple\": \"or drop them here\",\n \"progress.label\": \"Progress\",\n \"spinner.label\": \"Loading\",\n \"errors.INVALID_THEME_TOKEN\": \"The theme setting {token} has a value that can't be used.\",\n \"errors.INVALID_THEME_SELECTOR\": \"The theme can't be applied to the selector {selector}.\",\n});\n","declare const process: { readonly env: { readonly NODE_ENV?: string } };\n\n/**\n * Whether development-only checks and warnings are on, as a runtime check.\n * The same pattern as sdk-core's.\n *\n * It keeps a forgotten guard from warning in production, but it can't make a\n * bundle smaller: a bundler can't see through a function call, so the\n * message passed to {@link warnInDevelopment} would still ship. Every call\n * site therefore also guards itself inline, with exactly this expression,\n * which bundlers fold away when they replace `process.env.NODE_ENV`:\n *\n * ```ts\n * if (typeof process !== \"undefined\" && process.env.NODE_ENV !== \"production\") {\n * warnInDevelopment(`…`);\n * }\n * ```\n *\n * `development.test.ts` checks every call site, and `build.test.ts` checks\n * that a production bundle drops the messages. Where nothing defines\n * `process`, such as a page loading the module directly, warnings are off.\n */\nexport function isDevelopment(): boolean {\n try {\n return process.env.NODE_ENV !== \"production\";\n } catch {\n return false;\n }\n}\n\n/**\n * Logs a development-only warning. Call it only inside the inline guard\n * shown on {@link isDevelopment}.\n *\n * @param message - What's wrong and how to fix it.\n */\nexport function warnInDevelopment(message: string): void {\n if (isDevelopment()) {\n // biome-ignore lint/suspicious/noConsole: development-only diagnostics are the purpose of this helper.\n console.warn(`[@hussmartinez/ui] ${message}`);\n }\n}\n","import type { Theme } from \"./types.js\";\n\n/** Writes validated themes as CSS. Lives in css-writer.ts. */\nexport type CssWriter = (light: Theme, dark: Theme | undefined, selector: string) => string;\n\n/**\n * Themes from `createTheme`, with the function that writes them as CSS.\n *\n * Kept apart from `createTheme` so `ThemeProvider` can apply themes without\n * importing the validator, the colour parser or the token data: an\n * application that only uses the built-in themes doesn't ship them.\n */\nconst writers = /* @__PURE__ */ new WeakMap<Theme, CssWriter>();\n\n/** Records a validated theme, and how to write it as CSS. */\nexport function registerTheme(theme: Theme, writer: CssWriter): void {\n writers.set(theme, writer);\n}\n\n/**\n * The CSS writer of a theme from `createTheme`, or `undefined` for anything\n * else, such as a theme parsed from JSON.\n */\nexport function cssWriterOf(theme: unknown): CssWriter | undefined {\n return typeof theme === \"object\" && theme !== null ? writers.get(theme as Theme) : undefined;\n}\n","import type { Theme, ThemePair } from \"./types.js\";\n\n/** Whether a value is a light and dark pair rather than a single theme. */\nexport function isThemePair(value: Theme | ThemePair): value is ThemePair {\n return typeof value === \"object\" && value !== null && \"light\" in value && \"dark\" in value;\n}\n"],"mappings":";;AAgCA,IAAa,UAAb,cAA6B,SAAsB;CACjD,OAAyB;AAC3B;;ACnBA,IAAa,aAA6B,+BAAe;CACvD,uBAAuB;CACvB,gBAAgB;CAChB,uBAAuB;CACvB,+BAA+B;CAC/B,qBAAqB;CACrB,6BAA6B;CAC7B,kBAAkB;CAClB,iBAAiB;CACjB,8BAA8B;CAC9B,iCAAiC;AACnC,CAAC;;ACJD,SAAgB,gBAAyB;CACvC,IAAI;EACF,OAAA,QAAA,IAAA,aAAgC;CAClC,QAAQ;EACN,OAAO;CACT;AACF;AAQA,SAAgB,kBAAkB,SAAuB;CACvD,IAAI,cAAc,GAEhB,QAAQ,KAAK,sBAAsB,SAAS;AAEhD;;AC7BA,IAAM,0BAA0B,IAAI,QAA0B;AAG9D,SAAgB,cAAc,OAAc,QAAyB;CACnE,QAAQ,IAAI,OAAO,MAAM;AAC3B;AAMA,SAAgB,YAAY,OAAuC;CACjE,OAAO,OAAO,UAAU,YAAY,UAAU,OAAO,QAAQ,IAAI,KAAc,IAAI,KAAA;AACrF;;ACtBA,SAAgB,YAAY,OAA8C;CACxE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,WAAW,SAAS,UAAU;AACtF"}
package/dist/styles.css CHANGED
@@ -1219,6 +1219,118 @@
1219
1219
  }
1220
1220
  }
1221
1221
  }
1222
+ @layer hm.components {
1223
+ /*
1224
+ * A text field with several lines: text-field.css gives it the field's
1225
+ * size floor, focus ring, colours, border and states, and this adds what
1226
+ * lines of text need. Kept with unstyled.
1227
+ */
1228
+ .hm-text-area {
1229
+ max-inline-size: 100%;
1230
+ padding-block: var(--hm-text-area-padding-y, var(--hm-inset-tight));
1231
+ /* Taller only: a wider area would break the layout around it. */
1232
+ resize: vertical;
1233
+ /* An inline box would leave room for descenders under it. */
1234
+ vertical-align: top;
1235
+ }
1236
+
1237
+ /* Visual styles, dropped with unstyled. */
1238
+ .hm-text-area:not([data-hm-unstyled]) {
1239
+ line-height: var(--hm-line-height-body);
1240
+ }
1241
+ }
1242
+ @layer hm.components {
1243
+ /*
1244
+ * Layout, focus and target size: kept with unstyled, so the field stays
1245
+ * usable and accessible. The input is a text field, with its class and
1246
+ * tokens.
1247
+ */
1248
+ .hm-color-field {
1249
+ box-sizing: border-box;
1250
+ display: inline-grid;
1251
+ gap: var(--hm-color-field-gap, var(--hm-gap-tight));
1252
+ grid-template-columns: minmax(0, 1fr);
1253
+ }
1254
+
1255
+ .hm-color-field-control {
1256
+ display: flex;
1257
+ gap: var(--hm-color-field-gap, var(--hm-gap-tight));
1258
+ }
1259
+
1260
+ /* As wide as the input is tall, and stretched to its height. */
1261
+ .hm-color-field-preview {
1262
+ box-sizing: border-box;
1263
+ flex: none;
1264
+ inline-size: max(var(--hm-text-field-height, var(--hm-control-height)), var(--hm-target-size));
1265
+ }
1266
+
1267
+ .hm-color-field-input {
1268
+ flex: 1;
1269
+ }
1270
+
1271
+ .hm-color-field-swatches {
1272
+ display: flex;
1273
+ flex-wrap: wrap;
1274
+ gap: var(--hm-color-field-gap, var(--hm-gap-tight));
1275
+ }
1276
+
1277
+ /* The padding keeps the checked ring apart from the colour. */
1278
+ .hm-color-field-swatch {
1279
+ block-size: max(
1280
+ var(--hm-color-field-swatch-size, var(--hm-control-height-small)),
1281
+ var(--hm-target-size)
1282
+ );
1283
+ box-sizing: border-box;
1284
+ cursor: pointer;
1285
+ display: inline-flex;
1286
+ inline-size: max(
1287
+ var(--hm-color-field-swatch-size, var(--hm-control-height-small)),
1288
+ var(--hm-target-size)
1289
+ );
1290
+ padding: var(--hm-focus-ring-offset);
1291
+ }
1292
+
1293
+ .hm-color-field-swatch:focus-visible {
1294
+ outline: var(--hm-focus-ring);
1295
+ outline-offset: var(--hm-focus-ring-offset);
1296
+ }
1297
+
1298
+ .hm-color-field-swatch:disabled {
1299
+ cursor: not-allowed;
1300
+ }
1301
+
1302
+ .hm-color-field-swatch-fill {
1303
+ block-size: 100%;
1304
+ box-sizing: border-box;
1305
+ inline-size: 100%;
1306
+ }
1307
+
1308
+ /*
1309
+ * Visual styles, dropped with unstyled. Every colour has a border, so one
1310
+ * close to the surface's still shows its edge (WCAG 1.4.11).
1311
+ */
1312
+ .hm-color-field:not([data-hm-unstyled]) .hm-color-field-preview,
1313
+ .hm-color-field:not([data-hm-unstyled]) .hm-color-field-swatch-fill {
1314
+ border: var(--hm-border-width) solid
1315
+ var(--hm-color-field-swatch-border-color, var(--hm-color-border-strong));
1316
+ border-radius: var(--hm-color-field-swatch-radius, var(--hm-radius-control));
1317
+ }
1318
+
1319
+ .hm-color-field:not([data-hm-unstyled]) .hm-color-field-swatch {
1320
+ background: transparent;
1321
+ border: var(--hm-focus-ring-width) solid transparent;
1322
+ border-radius: var(--hm-color-field-swatch-radius, var(--hm-radius-control));
1323
+ }
1324
+
1325
+ /* The checked swatch has a ring, whatever its colour. */
1326
+ .hm-color-field:not([data-hm-unstyled]) .hm-color-field-swatch[aria-checked="true"] {
1327
+ border-color: var(--hm-color-field-swatch-checked-border-color, var(--hm-color-text));
1328
+ }
1329
+
1330
+ .hm-color-field:not([data-hm-unstyled]) .hm-color-field-swatch:disabled {
1331
+ opacity: var(--hm-opacity-disabled);
1332
+ }
1333
+ }
1222
1334
  @layer hm.components {
1223
1335
  .hm-spinner {
1224
1336
  block-size: var(--hm-spinner-size, var(--hm-icon-size));
package/dist/ui.d.ts CHANGED
@@ -24,6 +24,7 @@ import { RefAttributes } from 'react';
24
24
  import { RefObject } from 'react';
25
25
  import type { ShortcutPart } from '@hussmartinez/sdk-core';
26
26
  import type { SVGProps } from 'react';
27
+ import { TextareaHTMLAttributes } from 'react';
27
28
 
28
29
  /**
29
30
  * The `add` icon: Lucide's `plus`.
@@ -62,6 +63,13 @@ export declare interface AnnouncerProviderProps {
62
63
  readonly children?: ReactNode;
63
64
  }
64
65
 
66
+ /**
67
+ * The `arrow` icon: Lucide's `move-up-right`.
68
+ *
69
+ * @public
70
+ */
71
+ export declare function ArrowIcon(props: IconProps): ReactElement;
72
+
65
73
  /**
66
74
  * A button: a native `<button>`, `type="button"` unless you say otherwise.
67
75
  *
@@ -168,6 +176,68 @@ export declare type ClassNames<Part extends string> = {
168
176
  */
169
177
  export declare function CloseIcon(props: IconProps): ReactElement;
170
178
 
179
+ /**
180
+ * A colour input: a hex field with a preview of the colour, and optional
181
+ * swatches to pick from. It works with the keyboard alone and doesn't use
182
+ * the browser's own colour picker, which differs between browsers and can't
183
+ * be themed or translated.
184
+ *
185
+ * - **The input** takes `#rrggbb`, `#rgb` or either without the `#`. Typing
186
+ * doesn't change the value: the text is committed on blur or Enter. Text
187
+ * that isn't a colour goes back to the last value, and Escape throws the
188
+ * typing away.
189
+ * - **The swatches** are a radio group: one Tab stop, and the arrow keys move
190
+ * and select. A swatch is checked while the value is its colour.
191
+ * - **The value** is always lowercase `#rrggbb`. With `name`, forms receive it.
192
+ *
193
+ * @example
194
+ * ```tsx
195
+ * <Field label={t("shape.fill")}>
196
+ * <ColorField
197
+ * value={fill}
198
+ * onValueChange={setFill}
199
+ * swatches={[
200
+ * { value: "#d92d20", label: t("colors.red") },
201
+ * { value: "#1570ef", label: t("colors.blue") },
202
+ * ]}
203
+ * />
204
+ * </Field>
205
+ * ```
206
+ *
207
+ * @public
208
+ */
209
+ export declare const ColorField: ForwardRefExoticComponent<ColorFieldProps & RefAttributes<HTMLDivElement>>;
210
+
211
+ /**
212
+ * The parts of a colour field that `classNames` can target.
213
+ *
214
+ * @public
215
+ */
216
+ export declare type ColorFieldPart = "root" | "control" | "preview" | "input" | "swatches" | "swatch";
217
+
218
+ /**
219
+ * Props of {@link ColorField}. Other props go to the hex input.
220
+ *
221
+ * @public
222
+ */
223
+ export declare interface ColorFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "className" | "type" | "value" | "defaultValue" | "onChange">, StyleProps<ColorFieldPart> {
224
+ /** The colour, as `#rrggbb`. With it, the field is controlled. */
225
+ readonly value?: string | undefined;
226
+ /** The first colour of an uncontrolled field. Defaults to `#000000`. */
227
+ readonly defaultValue?: string | undefined;
228
+ /** Called with the new colour, always as lowercase `#rrggbb`. */
229
+ readonly onValueChange?: ((value: string) => void) | undefined;
230
+ /** Colours to pick from, shown under the input. Leave it out for the input alone. */
231
+ readonly swatches?: readonly ColorSwatch[] | undefined;
232
+ /**
233
+ * The accessible name, such as "Fill". Leave it out inside a `Field`, or
234
+ * when a visible `<label>` points at the field's `id`.
235
+ */
236
+ readonly label?: string | undefined;
237
+ /** The word that follows the label in the swatch group's name. Defaults to "swatches". */
238
+ readonly swatchesLabel?: string | undefined;
239
+ }
240
+
171
241
  /**
172
242
  * How a subtree picks between light and dark: one of them, or whichever the
173
243
  * operating system prefers (`prefers-color-scheme`).
@@ -176,6 +246,18 @@ export declare function CloseIcon(props: IconProps): ReactElement;
176
246
  */
177
247
  export declare type ColorMode = "light" | "dark" | "system";
178
248
 
249
+ /**
250
+ * A colour a {@link ColorField} offers as a swatch.
251
+ *
252
+ * @public
253
+ */
254
+ export declare interface ColorSwatch {
255
+ /** The colour, as `#rrggbb` or `#rgb`. */
256
+ readonly value: string;
257
+ /** The swatch's accessible name, such as "Red". Use text from your message catalogue. */
258
+ readonly label: string;
259
+ }
260
+
179
261
  /**
180
262
  * The `crop` icon: Lucide's `crop`.
181
263
  *
@@ -269,6 +351,20 @@ export declare interface DialogProps extends Omit<DialogHTMLAttributes<HTMLDialo
269
351
  */
270
352
  export declare function DownloadIcon(props: IconProps): ReactElement;
271
353
 
354
+ /**
355
+ * The `duplicate` icon: Lucide's `copy`.
356
+ *
357
+ * @public
358
+ */
359
+ export declare function DuplicateIcon(props: IconProps): ReactElement;
360
+
361
+ /**
362
+ * The `ellipse` icon: Lucide's `ellipse`.
363
+ *
364
+ * @public
365
+ */
366
+ export declare function EllipseIcon(props: IconProps): ReactElement;
367
+
272
368
  /**
273
369
  * The `fade-in` icon: Lucide's `chart-no-axes-column-increasing`.
274
370
  *
@@ -475,6 +571,13 @@ export declare function FlipHorizontalIcon(props: IconProps): ReactElement;
475
571
  */
476
572
  export declare function FlipVerticalIcon(props: IconProps): ReactElement;
477
573
 
574
+ /**
575
+ * The `hidden` icon: Lucide's `eye-off`.
576
+ *
577
+ * @public
578
+ */
579
+ export declare function HiddenIcon(props: IconProps): ReactElement;
580
+
478
581
  /**
479
582
  * The `highlighter` icon: Lucide's `highlighter`.
480
583
  *
@@ -523,7 +626,7 @@ export declare type IconComponent = (props: IconProps) => ReactElement;
523
626
  *
524
627
  * @public
525
628
  */
526
- export declare type IconName = "add" | "check" | "chevron-down" | "chevron-left" | "chevron-right" | "close" | "crop" | "delete" | "download" | "fade-in" | "fade-out" | "fit" | "flip-horizontal" | "flip-vertical" | "highlighter" | "info" | "loop" | "menu" | "more" | "muted" | "open" | "page-grid" | "page-single" | "pan" | "pause" | "pen" | "play" | "redo" | "remove" | "rotate-left" | "rotate-right" | "search" | "select" | "skip-back" | "skip-forward" | "snap" | "split" | "stop" | "trim-end" | "trim-start" | "undo" | "upload" | "volume" | "warning" | "zoom-in" | "zoom-out";
629
+ export declare type IconName = "add" | "arrow" | "check" | "chevron-down" | "chevron-left" | "chevron-right" | "close" | "crop" | "delete" | "download" | "duplicate" | "ellipse" | "fade-in" | "fade-out" | "fit" | "flip-horizontal" | "flip-vertical" | "hidden" | "highlighter" | "info" | "layers" | "loop" | "menu" | "more" | "move-down" | "move-up" | "muted" | "open" | "page-add" | "page-grid" | "page-single" | "pan" | "pause" | "pen" | "play" | "rectangle" | "redact" | "redo" | "remove" | "rotate-left" | "rotate-right" | "search" | "select" | "skip-back" | "skip-forward" | "snap" | "split" | "stop" | "text" | "trim-end" | "trim-start" | "undo" | "upload" | "visible" | "volume" | "warning" | "zoom-in" | "zoom-out";
527
630
 
528
631
  /**
529
632
  * Props of every icon. SVG attributes are passed through.
@@ -546,6 +649,13 @@ export declare interface IconProps extends Omit<SVGProps<SVGSVGElement>, "childr
546
649
  */
547
650
  export declare function InfoIcon(props: IconProps): ReactElement;
548
651
 
652
+ /**
653
+ * The `layers` icon: Lucide's `layers`.
654
+ *
655
+ * @public
656
+ */
657
+ export declare function LayersIcon(props: IconProps): ReactElement;
658
+
549
659
  /**
550
660
  * The `loop` icon: Lucide's `repeat`.
551
661
  *
@@ -567,6 +677,20 @@ export declare function MenuIcon(props: IconProps): ReactElement;
567
677
  */
568
678
  export declare function MoreIcon(props: IconProps): ReactElement;
569
679
 
680
+ /**
681
+ * The `move-down` icon: Lucide's `arrow-down`.
682
+ *
683
+ * @public
684
+ */
685
+ export declare function MoveDownIcon(props: IconProps): ReactElement;
686
+
687
+ /**
688
+ * The `move-up` icon: Lucide's `arrow-up`.
689
+ *
690
+ * @public
691
+ */
692
+ export declare function MoveUpIcon(props: IconProps): ReactElement;
693
+
570
694
  /**
571
695
  * The `muted` icon: Lucide's `volume-x`.
572
696
  *
@@ -661,6 +785,13 @@ export declare interface NumberFieldProps extends Omit<InputHTMLAttributes<HTMLI
661
785
  */
662
786
  export declare function OpenIcon(props: IconProps): ReactElement;
663
787
 
788
+ /**
789
+ * The `page-add` icon: Lucide's `file-plus`.
790
+ *
791
+ * @public
792
+ */
793
+ export declare function PageAddIcon(props: IconProps): ReactElement;
794
+
664
795
  /**
665
796
  * The `page-grid` icon: Lucide's `grid-2x2`.
666
797
  *
@@ -743,6 +874,20 @@ export declare interface ProgressBarProps extends Omit<ProgressHTMLAttributes<HT
743
874
  readonly valueText?: string | undefined;
744
875
  }
745
876
 
877
+ /**
878
+ * The `rectangle` icon: Lucide's `rectangle-horizontal`.
879
+ *
880
+ * @public
881
+ */
882
+ export declare function RectangleIcon(props: IconProps): ReactElement;
883
+
884
+ /**
885
+ * The `redact` icon: Lucide's `rectangle-ellipsis`.
886
+ *
887
+ * @public
888
+ */
889
+ export declare function RedactIcon(props: IconProps): ReactElement;
890
+
746
891
  /**
747
892
  * The `redo` icon: Lucide's `redo-2`, mirrored in right-to-left text.
748
893
  *
@@ -994,6 +1139,43 @@ export declare interface StyleProps<Part extends string> {
994
1139
  readonly unstyled?: boolean | undefined;
995
1140
  }
996
1141
 
1142
+ /**
1143
+ * A multi-line text input, styled like `TextField`, with its tokens. `rows`
1144
+ * sets its height, three by default, and the user can drag it taller. Inside
1145
+ * a `Field`, it takes the field's label, description and error.
1146
+ *
1147
+ * Enter adds a line, so it doesn't submit a form. Its value separates lines
1148
+ * with `\n`, whatever was pasted.
1149
+ *
1150
+ * @example
1151
+ * ```tsx
1152
+ * <Field label={t("text.content")}>
1153
+ * <TextArea value={text} onValueChange={setText} rows={4} />
1154
+ * </Field>
1155
+ * ```
1156
+ *
1157
+ * @public
1158
+ */
1159
+ export declare const TextArea: ForwardRefExoticComponent<TextAreaProps & RefAttributes<HTMLTextAreaElement>>;
1160
+
1161
+ /**
1162
+ * Props of {@link TextArea}. Native textarea props are passed through, so it
1163
+ * works controlled with `value` and `onChange`, or uncontrolled with
1164
+ * `defaultValue`.
1165
+ *
1166
+ * @public
1167
+ */
1168
+ export declare interface TextAreaProps extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "className">, StyleProps<"root"> {
1169
+ /** Called with the new text as it changes, as well as `onChange`. */
1170
+ readonly onValueChange?: ((value: string) => void) | undefined;
1171
+ /**
1172
+ * The accessible name, such as "Caption". Leave it out inside a `Field`,
1173
+ * or when a visible `<label>` points at the field's `id`, or
1174
+ * `aria-labelledby` names it.
1175
+ */
1176
+ readonly label?: string | undefined;
1177
+ }
1178
+
997
1179
  /**
998
1180
  * A single-line text input, styled like the family's other fields. Inside a
999
1181
  * `Field`, it takes the field's label, description and error.
@@ -1036,6 +1218,13 @@ export declare interface TextFieldProps extends Omit<InputHTMLAttributes<HTMLInp
1036
1218
  */
1037
1219
  export declare type TextFieldType = "text" | "search" | "email" | "url" | "tel" | "password";
1038
1220
 
1221
+ /**
1222
+ * The `text` icon: Lucide's `type`.
1223
+ *
1224
+ * @public
1225
+ */
1226
+ export declare function TextIcon(props: IconProps): ReactElement;
1227
+
1039
1228
  /**
1040
1229
  * A validated theme. Create it with `createTheme`; its values are
1041
1230
  * frozen and safe to write into CSS.
@@ -1403,6 +1592,7 @@ export declare type UiMessages = Messages<typeof uiMessages>;
1403
1592
  * @public
1404
1593
  */
1405
1594
  export declare const uiMessages: {
1595
+ readonly "colorField.swatches": "swatches";
1406
1596
  readonly "dialog.close": "Close";
1407
1597
  readonly "fileDropZone.choose": "Choose a file";
1408
1598
  readonly "fileDropZone.chooseMultiple": "Choose files";
@@ -1496,6 +1686,13 @@ export declare function usePlatform(): Platform;
1496
1686
  */
1497
1687
  export declare function useUiMessages(): UiMessages;
1498
1688
 
1689
+ /**
1690
+ * The `visible` icon: Lucide's `eye`.
1691
+ *
1692
+ * @public
1693
+ */
1694
+ export declare function VisibleIcon(props: IconProps): ReactElement;
1695
+
1499
1696
  /**
1500
1697
  * Content for assistive technology only: hidden on screen, but read out and
1501
1698
  * part of the accessible name of its parent. It has no `unstyled` prop,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hussmartinez/ui",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Design system of the @hussmartinez SDK family: tokens, themes, base styles and accessible React components.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "@arethetypeswrong/cli": "^0.18.5",
52
- "@hussmartinez/sdk-config": "^0.5.0",
52
+ "@hussmartinez/sdk-config": "^0.9.0",
53
53
  "@microsoft/api-extractor": "^7.60.1",
54
54
  "@size-limit/file": "^14.3.0",
55
55
  "@types/node": "^24.19.2",
@@ -58,7 +58,7 @@
58
58
  "@vitest/browser-playwright": "5.1.0",
59
59
  "esbuild": "^0.28.2",
60
60
  "lucide-static": "1.72.0",
61
- "playwright": "^1.64.1",
61
+ "playwright": "1.65.1",
62
62
  "publint": "^0.3.25",
63
63
  "react": "^19.3.0",
64
64
  "react-dom": "^19.3.0",
@@ -71,8 +71,8 @@
71
71
  "typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.test.json",
72
72
  "build": "vite build && pnpm check:api",
73
73
  "test": "vitest run --project unit",
74
- "test:browser": "vitest run --project browser",
75
- "test:browser:all": "vitest run --project browser --mode all-browsers",
74
+ "test:browser": "hm-in-image vitest run --project browser",
75
+ "test:browser:all": "hm-in-image vitest run --project browser --mode all-browsers",
76
76
  "check:size": "size-limit",
77
77
  "check:api": "tsc -p tsconfig.build.json && api-extractor run && api-extractor run -c api-extractor.react.json && hm-check-api-reports --main api/ui.api.md --types dist/index.d.ts api/ui-react.api.md",
78
78
  "check:package": "publint run --pack pnpm --strict && attw --pack . --profile esm-only --exclude-entrypoints ./styles.css",
@@ -1 +0,0 @@
1
- {"version":3,"file":"pair-DLVFV6vU.js","names":[],"sources":["../../src/errors/ui-error.ts","../../src/messages/en.ts","../../src/internal/development.ts","../../src/theme/registry.ts","../../src/theme/pair.ts"],"sourcesContent":["import { SdkError } from \"@hussmartinez/sdk-core\";\n\n/**\n * Error codes of `@hussmartinez/ui`. They never change once released.\n *\n * - `INVALID_THEME_TOKEN`: a theme token has an unknown name, or a value that\n * isn't allowed for its type. `details` has `token`, `value` and `reason`.\n * - `INVALID_THEME_SELECTOR`: the selector passed to `themeToCss` isn't a\n * plain CSS selector. `details` has `selector` and `reason`.\n *\n * @public\n */\nexport type UiErrorCode = \"INVALID_THEME_TOKEN\" | \"INVALID_THEME_SELECTOR\";\n\n/**\n * The error `@hussmartinez/ui` throws, with a stable `code` and structured\n * `details`. Show users the text for its code from {@link uiMessages}, never\n * its `message`.\n *\n * @example\n * ```ts\n * try {\n * createTheme({ extends: \"light\", tokens: { \"color-accent\": brandColour } });\n * } catch (error) {\n * if (isSdkError(error, \"INVALID_THEME_TOKEN\")) {\n * // Ask for another colour.\n * }\n * }\n * ```\n *\n * @public\n */\nexport class UiError extends SdkError<UiErrorCode> {\n override readonly name = \"UiError\";\n}\n","import { defineMessages } from \"@hussmartinez/sdk-core\";\n\n/**\n * English text for `@hussmartinez/ui`'s error codes. Applications and SDKs\n * spread it into their catalogue, next to `sdkCoreMessages`, so\n * `messages.error()` can describe a `UiError`. Components add their\n * text here as they arrive.\n *\n * @example\n * ```ts\n * export const en = defineMessages({ ...sdkCoreMessages, ...uiMessages });\n * ```\n *\n * @public\n */\nexport const uiMessages = /* @__PURE__ */ defineMessages({\n \"dialog.close\": \"Close\",\n \"fileDropZone.choose\": \"Choose a file\",\n \"fileDropZone.chooseMultiple\": \"Choose files\",\n \"fileDropZone.hint\": \"or drop it here\",\n \"fileDropZone.hintMultiple\": \"or drop them here\",\n \"progress.label\": \"Progress\",\n \"spinner.label\": \"Loading\",\n \"errors.INVALID_THEME_TOKEN\": \"The theme setting {token} has a value that can't be used.\",\n \"errors.INVALID_THEME_SELECTOR\": \"The theme can't be applied to the selector {selector}.\",\n});\n","declare const process: { readonly env: { readonly NODE_ENV?: string } };\n\n/**\n * Whether development-only checks and warnings are on, as a runtime check.\n * The same pattern as sdk-core's.\n *\n * It keeps a forgotten guard from warning in production, but it can't make a\n * bundle smaller: a bundler can't see through a function call, so the\n * message passed to {@link warnInDevelopment} would still ship. Every call\n * site therefore also guards itself inline, with exactly this expression,\n * which bundlers fold away when they replace `process.env.NODE_ENV`:\n *\n * ```ts\n * if (typeof process !== \"undefined\" && process.env.NODE_ENV !== \"production\") {\n * warnInDevelopment(`…`);\n * }\n * ```\n *\n * `development.test.ts` checks every call site, and `build.test.ts` checks\n * that a production bundle drops the messages. Where nothing defines\n * `process`, such as a page loading the module directly, warnings are off.\n */\nexport function isDevelopment(): boolean {\n try {\n return process.env.NODE_ENV !== \"production\";\n } catch {\n return false;\n }\n}\n\n/**\n * Logs a development-only warning. Call it only inside the inline guard\n * shown on {@link isDevelopment}.\n *\n * @param message - What's wrong and how to fix it.\n */\nexport function warnInDevelopment(message: string): void {\n if (isDevelopment()) {\n // biome-ignore lint/suspicious/noConsole: development-only diagnostics are the purpose of this helper.\n console.warn(`[@hussmartinez/ui] ${message}`);\n }\n}\n","import type { Theme } from \"./types.js\";\n\n/** Writes validated themes as CSS. Lives in css-writer.ts. */\nexport type CssWriter = (light: Theme, dark: Theme | undefined, selector: string) => string;\n\n/**\n * Themes from `createTheme`, with the function that writes them as CSS.\n *\n * Kept apart from `createTheme` so `ThemeProvider` can apply themes without\n * importing the validator, the colour parser or the token data: an\n * application that only uses the built-in themes doesn't ship them.\n */\nconst writers = /* @__PURE__ */ new WeakMap<Theme, CssWriter>();\n\n/** Records a validated theme, and how to write it as CSS. */\nexport function registerTheme(theme: Theme, writer: CssWriter): void {\n writers.set(theme, writer);\n}\n\n/**\n * The CSS writer of a theme from `createTheme`, or `undefined` for anything\n * else, such as a theme parsed from JSON.\n */\nexport function cssWriterOf(theme: unknown): CssWriter | undefined {\n return typeof theme === \"object\" && theme !== null ? writers.get(theme as Theme) : undefined;\n}\n","import type { Theme, ThemePair } from \"./types.js\";\n\n/** Whether a value is a light and dark pair rather than a single theme. */\nexport function isThemePair(value: Theme | ThemePair): value is ThemePair {\n return typeof value === \"object\" && value !== null && \"light\" in value && \"dark\" in value;\n}\n"],"mappings":";;AAgCA,IAAa,UAAb,cAA6B,SAAsB;CACjD,OAAyB;AAC3B;;ACnBA,IAAa,aAA6B,+BAAe;CACvD,gBAAgB;CAChB,uBAAuB;CACvB,+BAA+B;CAC/B,qBAAqB;CACrB,6BAA6B;CAC7B,kBAAkB;CAClB,iBAAiB;CACjB,8BAA8B;CAC9B,iCAAiC;AACnC,CAAC;;ACHD,SAAgB,gBAAyB;CACvC,IAAI;EACF,OAAA,QAAA,IAAA,aAAgC;CAClC,QAAQ;EACN,OAAO;CACT;AACF;AAQA,SAAgB,kBAAkB,SAAuB;CACvD,IAAI,cAAc,GAEhB,QAAQ,KAAK,sBAAsB,SAAS;AAEhD;;AC7BA,IAAM,0BAA0B,IAAI,QAA0B;AAG9D,SAAgB,cAAc,OAAc,QAAyB;CACnE,QAAQ,IAAI,OAAO,MAAM;AAC3B;AAMA,SAAgB,YAAY,OAAuC;CACjE,OAAO,OAAO,UAAU,YAAY,UAAU,OAAO,QAAQ,IAAI,KAAc,IAAI,KAAA;AACrF;;ACtBA,SAAgB,YAAY,OAA8C;CACxE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,WAAW,SAAS,UAAU;AACtF"}