@hussmartinez/ui 0.6.0 → 0.8.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.
package/dist/styles.css CHANGED
@@ -721,6 +721,54 @@
721
721
  border-radius: var(--hm-toolbar-radius, var(--hm-radius-surface));
722
722
  }
723
723
  }
724
+ @layer hm.components {
725
+ /*
726
+ * A tooltip in the top layer (popover="manual"). It's placed with
727
+ * position: fixed, and Tooltip.tsx sets top and left; the offset from the
728
+ * trigger is a translation, so it never changes the measured box.
729
+ */
730
+ .hm-tooltip {
731
+ box-sizing: border-box;
732
+ inset: auto;
733
+ margin: 0;
734
+ max-inline-size: var(--hm-tooltip-max-width, var(--hm-surface-width-small));
735
+ overflow: visible;
736
+ padding: var(--hm-tooltip-padding, var(--hm-inset-tight));
737
+ position: fixed;
738
+ }
739
+
740
+ .hm-tooltip[data-hm-placement="top"] {
741
+ translate: 0 calc(var(--hm-tooltip-offset, var(--hm-gap-tight)) * -1);
742
+ }
743
+
744
+ .hm-tooltip[data-hm-placement="bottom"] {
745
+ translate: 0 var(--hm-tooltip-offset, var(--hm-gap-tight));
746
+ }
747
+
748
+ .hm-tooltip-shortcut {
749
+ margin-inline-start: var(--hm-tooltip-padding, var(--hm-inset-tight));
750
+ white-space: nowrap;
751
+ }
752
+
753
+ /*
754
+ * Visual styles, dropped with unstyled. The border is transparent, so
755
+ * forced-colours mode draws it.
756
+ */
757
+ .hm-tooltip:not([data-hm-unstyled]) {
758
+ background: var(--hm-tooltip-bg, var(--hm-color-text));
759
+ border: var(--hm-border-width) solid transparent;
760
+ border-radius: var(--hm-tooltip-radius, var(--hm-radius-control));
761
+ box-shadow: var(--hm-tooltip-shadow, var(--hm-shadow-raised));
762
+ color: var(--hm-tooltip-fg, var(--hm-color-bg));
763
+ font-family: var(--hm-font-family);
764
+ font-size: var(--hm-tooltip-font-size, var(--hm-font-size-small));
765
+ line-height: var(--hm-line-height-tight);
766
+ }
767
+
768
+ .hm-tooltip:not([data-hm-unstyled]) kbd {
769
+ font-family: inherit;
770
+ }
771
+ }
724
772
  @layer hm.components {
725
773
  .hm-segmented-control {
726
774
  box-sizing: border-box;
@@ -1113,6 +1161,64 @@
1113
1161
  }
1114
1162
  }
1115
1163
  }
1164
+ @layer hm.components {
1165
+ /*
1166
+ * Layout, focus and target size: kept with unstyled, so the field stays
1167
+ * usable and accessible.
1168
+ */
1169
+ .hm-text-field {
1170
+ box-sizing: border-box;
1171
+ min-block-size: max(
1172
+ var(--hm-text-field-height, var(--hm-control-height)),
1173
+ var(--hm-target-size)
1174
+ );
1175
+ min-inline-size: var(--hm-target-size);
1176
+ padding-block: 0;
1177
+ padding-inline: var(--hm-text-field-padding-x, var(--hm-control-padding-x));
1178
+ }
1179
+
1180
+ .hm-text-field:focus-visible {
1181
+ outline: var(--hm-focus-ring);
1182
+ outline-offset: var(--hm-focus-ring-offset);
1183
+ }
1184
+
1185
+ .hm-text-field:disabled {
1186
+ cursor: not-allowed;
1187
+ }
1188
+
1189
+ /* Visual styles, dropped with unstyled. */
1190
+ .hm-text-field:not([data-hm-unstyled]) {
1191
+ background: var(--hm-text-field-bg, var(--hm-color-surface));
1192
+ border: var(--hm-border-width) solid
1193
+ var(--hm-text-field-border-color, var(--hm-color-border-strong));
1194
+ border-radius: var(--hm-text-field-radius, var(--hm-radius-control));
1195
+ color: var(--hm-text-field-fg, var(--hm-color-text));
1196
+ font-family: var(--hm-font-family);
1197
+ font-size: var(--hm-font-size-body);
1198
+ letter-spacing: var(--hm-letter-spacing);
1199
+ line-height: var(--hm-line-height-tight);
1200
+ transition: border-color var(--hm-motion-duration-feedback) var(--hm-motion-easing-standard);
1201
+ }
1202
+
1203
+ .hm-text-field:not([data-hm-unstyled])::placeholder {
1204
+ color: var(--hm-text-field-placeholder-fg, var(--hm-color-text-muted));
1205
+ opacity: 1;
1206
+ }
1207
+
1208
+ .hm-text-field[aria-invalid="true"]:not([data-hm-unstyled]) {
1209
+ border-color: var(--hm-text-field-invalid-border-color, var(--hm-color-danger-text));
1210
+ }
1211
+
1212
+ .hm-text-field:not([data-hm-unstyled]):disabled {
1213
+ opacity: var(--hm-opacity-disabled);
1214
+ }
1215
+
1216
+ @media (prefers-reduced-motion: reduce) {
1217
+ .hm-text-field:not([data-hm-unstyled]) {
1218
+ transition-duration: 0s;
1219
+ }
1220
+ }
1221
+ }
1116
1222
  @layer hm.components {
1117
1223
  .hm-spinner {
1118
1224
  block-size: var(--hm-spinner-size, var(--hm-icon-size));
package/dist/ui.d.ts CHANGED
@@ -22,6 +22,7 @@ import { ReactNode } from 'react';
22
22
  import { Ref } from 'react';
23
23
  import { RefAttributes } from 'react';
24
24
  import { RefObject } from 'react';
25
+ import type { ShortcutPart } from '@hussmartinez/sdk-core';
25
26
  import type { SVGProps } from 'react';
26
27
 
27
28
  /**
@@ -61,6 +62,13 @@ export declare interface AnnouncerProviderProps {
61
62
  readonly children?: ReactNode;
62
63
  }
63
64
 
65
+ /**
66
+ * The `arrow` icon: Lucide's `move-up-right`.
67
+ *
68
+ * @public
69
+ */
70
+ export declare function ArrowIcon(props: IconProps): ReactElement;
71
+
64
72
  /**
65
73
  * A button: a native `<button>`, `type="button"` unless you say otherwise.
66
74
  *
@@ -268,6 +276,20 @@ export declare interface DialogProps extends Omit<DialogHTMLAttributes<HTMLDialo
268
276
  */
269
277
  export declare function DownloadIcon(props: IconProps): ReactElement;
270
278
 
279
+ /**
280
+ * The `duplicate` icon: Lucide's `copy`.
281
+ *
282
+ * @public
283
+ */
284
+ export declare function DuplicateIcon(props: IconProps): ReactElement;
285
+
286
+ /**
287
+ * The `ellipse` icon: Lucide's `ellipse`.
288
+ *
289
+ * @public
290
+ */
291
+ export declare function EllipseIcon(props: IconProps): ReactElement;
292
+
271
293
  /**
272
294
  * The `fade-in` icon: Lucide's `chart-no-axes-column-increasing`.
273
295
  *
@@ -474,6 +496,13 @@ export declare function FlipHorizontalIcon(props: IconProps): ReactElement;
474
496
  */
475
497
  export declare function FlipVerticalIcon(props: IconProps): ReactElement;
476
498
 
499
+ /**
500
+ * The `hidden` icon: Lucide's `eye-off`.
501
+ *
502
+ * @public
503
+ */
504
+ export declare function HiddenIcon(props: IconProps): ReactElement;
505
+
477
506
  /**
478
507
  * The `highlighter` icon: Lucide's `highlighter`.
479
508
  *
@@ -522,7 +551,7 @@ export declare type IconComponent = (props: IconProps) => ReactElement;
522
551
  *
523
552
  * @public
524
553
  */
525
- 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";
554
+ 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";
526
555
 
527
556
  /**
528
557
  * Props of every icon. SVG attributes are passed through.
@@ -545,6 +574,13 @@ export declare interface IconProps extends Omit<SVGProps<SVGSVGElement>, "childr
545
574
  */
546
575
  export declare function InfoIcon(props: IconProps): ReactElement;
547
576
 
577
+ /**
578
+ * The `layers` icon: Lucide's `layers`.
579
+ *
580
+ * @public
581
+ */
582
+ export declare function LayersIcon(props: IconProps): ReactElement;
583
+
548
584
  /**
549
585
  * The `loop` icon: Lucide's `repeat`.
550
586
  *
@@ -566,6 +602,20 @@ export declare function MenuIcon(props: IconProps): ReactElement;
566
602
  */
567
603
  export declare function MoreIcon(props: IconProps): ReactElement;
568
604
 
605
+ /**
606
+ * The `move-down` icon: Lucide's `arrow-down`.
607
+ *
608
+ * @public
609
+ */
610
+ export declare function MoveDownIcon(props: IconProps): ReactElement;
611
+
612
+ /**
613
+ * The `move-up` icon: Lucide's `arrow-up`.
614
+ *
615
+ * @public
616
+ */
617
+ export declare function MoveUpIcon(props: IconProps): ReactElement;
618
+
569
619
  /**
570
620
  * The `muted` icon: Lucide's `volume-x`.
571
621
  *
@@ -660,6 +710,13 @@ export declare interface NumberFieldProps extends Omit<InputHTMLAttributes<HTMLI
660
710
  */
661
711
  export declare function OpenIcon(props: IconProps): ReactElement;
662
712
 
713
+ /**
714
+ * The `page-add` icon: Lucide's `file-plus`.
715
+ *
716
+ * @public
717
+ */
718
+ export declare function PageAddIcon(props: IconProps): ReactElement;
719
+
663
720
  /**
664
721
  * The `page-grid` icon: Lucide's `grid-2x2`.
665
722
  *
@@ -742,6 +799,20 @@ export declare interface ProgressBarProps extends Omit<ProgressHTMLAttributes<HT
742
799
  readonly valueText?: string | undefined;
743
800
  }
744
801
 
802
+ /**
803
+ * The `rectangle` icon: Lucide's `rectangle-horizontal`.
804
+ *
805
+ * @public
806
+ */
807
+ export declare function RectangleIcon(props: IconProps): ReactElement;
808
+
809
+ /**
810
+ * The `redact` icon: Lucide's `rectangle-ellipsis`.
811
+ *
812
+ * @public
813
+ */
814
+ export declare function RedactIcon(props: IconProps): ReactElement;
815
+
745
816
  /**
746
817
  * The `redo` icon: Lucide's `redo-2`, mirrored in right-to-left text.
747
818
  *
@@ -993,6 +1064,55 @@ export declare interface StyleProps<Part extends string> {
993
1064
  readonly unstyled?: boolean | undefined;
994
1065
  }
995
1066
 
1067
+ /**
1068
+ * A single-line text input, styled like the family's other fields. Inside a
1069
+ * `Field`, it takes the field's label, description and error.
1070
+ *
1071
+ * @example
1072
+ * ```tsx
1073
+ * <Field label={t("export.fileName")} error={nameError}>
1074
+ * <TextField value={name} onValueChange={setName} autoComplete="off" />
1075
+ * </Field>
1076
+ * ```
1077
+ *
1078
+ * @public
1079
+ */
1080
+ export declare const TextField: ForwardRefExoticComponent<TextFieldProps & RefAttributes<HTMLInputElement>>;
1081
+
1082
+ /**
1083
+ * Props of {@link TextField}. Native input props are passed through, so it
1084
+ * works controlled with `value` and `onChange`, or uncontrolled with
1085
+ * `defaultValue`.
1086
+ *
1087
+ * @public
1088
+ */
1089
+ export declare interface TextFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "className" | "type">, StyleProps<"root"> {
1090
+ /** Defaults to `text`. */
1091
+ readonly type?: TextFieldType | undefined;
1092
+ /** Called with the new text as it changes, as well as `onChange`. */
1093
+ readonly onValueChange?: ((value: string) => void) | undefined;
1094
+ /**
1095
+ * The accessible name, such as "File name". Leave it out inside a
1096
+ * `Field`, or when a visible `<label>` points at the field's `id`, or
1097
+ * `aria-labelledby` names it.
1098
+ */
1099
+ readonly label?: string | undefined;
1100
+ }
1101
+
1102
+ /**
1103
+ * The kinds of single-line text a {@link TextField} takes.
1104
+ *
1105
+ * @public
1106
+ */
1107
+ export declare type TextFieldType = "text" | "search" | "email" | "url" | "tel" | "password";
1108
+
1109
+ /**
1110
+ * The `text` icon: Lucide's `type`.
1111
+ *
1112
+ * @public
1113
+ */
1114
+ export declare function TextIcon(props: IconProps): ReactElement;
1115
+
996
1116
  /**
997
1117
  * A validated theme. Create it with `createTheme`; its values are
998
1118
  * frozen and safe to write into CSS.
@@ -1253,6 +1373,77 @@ export declare const ToolbarSeparator: ForwardRefExoticComponent<ToolbarSeparato
1253
1373
  */
1254
1374
  export declare type ToolbarSeparatorProps = Omit<HTMLAttributes<HTMLHRElement>, "children">;
1255
1375
 
1376
+ /**
1377
+ * A tooltip: short text about a control, shown while the pointer rests on it
1378
+ * or while it has keyboard focus (WAI-ARIA tooltip pattern, WCAG 1.4.13).
1379
+ *
1380
+ * - It shows after `delay` on hover, and at once on keyboard focus, never
1381
+ * on a mouse click's focus or on touch.
1382
+ * - The pointer can move onto it without it closing, and it stays until the
1383
+ * pointer and focus leave. Escape closes it without moving focus, and
1384
+ * doesn't close a surrounding dialog.
1385
+ * - **While it's open, the first Escape belongs to the tooltip.** It calls
1386
+ * `preventDefault()`, so an editor's own Escape action, such as cancelling
1387
+ * a crop, runs on the second press. sdk-core's shortcut registry already
1388
+ * skips handled events; a handler of your own should check
1389
+ * `event.defaultPrevented` too.
1390
+ * - It's in the top layer, through the Popover API, so no stacking context
1391
+ * can hide it, and it's placed above the trigger, or below when there's no
1392
+ * room, without a positioning library (docs/adr/0006).
1393
+ *
1394
+ * @example
1395
+ * ```tsx
1396
+ * <Tooltip type="label" content={t("toolbar.undo")} shortcut={shortcuts.describe("pdf.undo")[0]}>
1397
+ * <IconButton label={t("toolbar.undo")} icon={<UndoIcon />} onClick={undo} />
1398
+ * </Tooltip>
1399
+ * ```
1400
+ *
1401
+ * @public
1402
+ */
1403
+ export declare const Tooltip: ForwardRefExoticComponent<TooltipProps & RefAttributes<HTMLDivElement>>;
1404
+
1405
+ /**
1406
+ * The parts of a tooltip that `classNames` can target.
1407
+ *
1408
+ * @public
1409
+ */
1410
+ export declare type TooltipPart = "root" | "content" | "shortcut";
1411
+
1412
+ /**
1413
+ * Props of {@link Tooltip}.
1414
+ *
1415
+ * @public
1416
+ */
1417
+ export declare interface TooltipProps extends StyleProps<TooltipPart> {
1418
+ /** The text. Use text from your message catalogue. */
1419
+ readonly content: ReactNode;
1420
+ /**
1421
+ * How the text reaches assistive technology. `description`, the default,
1422
+ * describes the trigger (`aria-describedby`). `label` names it
1423
+ * (`aria-labelledby`): use it for an icon-only button whose tooltip says
1424
+ * what its label would, so screen readers don't hear it twice.
1425
+ */
1426
+ readonly type?: "description" | "label" | undefined;
1427
+ /**
1428
+ * The trigger's keyboard shortcut, as sdk-core's shortcut registry
1429
+ * describes it: `registry.describe(toolId)[0]`. The tooltip shows it in the
1430
+ * platform's notation, such as ⌘⇧Z or Ctrl+Shift+Z, and the trigger gets
1431
+ * `aria-keyshortcuts`.
1432
+ */
1433
+ readonly shortcut?: readonly ShortcutPart[] | undefined;
1434
+ /** Where it shows, when there's room: `top` (the default) or `bottom`. */
1435
+ readonly placement?: "top" | "bottom" | undefined;
1436
+ /** How long the pointer rests on the trigger before it shows, in milliseconds. Defaults to 500. */
1437
+ readonly delay?: number | undefined;
1438
+ /**
1439
+ * The trigger: one element that forwards its ref, such as `IconButton`.
1440
+ * A disabled trigger should use `focusableWhenDisabled`: a natively
1441
+ * disabled button gets neither focus nor pointer events, so its tooltip
1442
+ * can't show.
1443
+ */
1444
+ readonly children: ReactElement;
1445
+ }
1446
+
1256
1447
  /**
1257
1448
  * The `trim-end` icon: Lucide's `arrow-left-from-line`.
1258
1449
  *
@@ -1382,6 +1573,13 @@ export declare function usePlatform(): Platform;
1382
1573
  */
1383
1574
  export declare function useUiMessages(): UiMessages;
1384
1575
 
1576
+ /**
1577
+ * The `visible` icon: Lucide's `eye`.
1578
+ *
1579
+ * @public
1580
+ */
1581
+ export declare function VisibleIcon(props: IconProps): ReactElement;
1582
+
1385
1583
  /**
1386
1584
  * Content for assistive technology only: hidden on screen, but read out and
1387
1585
  * 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.6.0",
3
+ "version": "0.8.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.3.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",