@stll/ui 0.79.0 → 0.81.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/calendar/day-calendar.d.ts +6 -1
  2. package/dist/calendar/day-calendar.js +77 -20
  3. package/dist/components/animated-count.js +5 -5
  4. package/dist/components/button.d.ts +7 -3
  5. package/dist/components/button.js +58 -9
  6. package/dist/components/destructive-confirm-dialog.js +1 -0
  7. package/dist/components/document-mark.shared.d.ts +14 -125
  8. package/dist/components/document-mark.shared.js +222 -37
  9. package/dist/components/file-input.d.ts +2 -1
  10. package/dist/components/file-input.js +2 -1
  11. package/dist/components/hex-color-picker.js +10 -11
  12. package/dist/components/search-field.d.ts +2 -1
  13. package/dist/components/search-field.js +2 -1
  14. package/dist/components/secret-input.d.ts +2 -1
  15. package/dist/components/secret-input.js +2 -1
  16. package/dist/components/split-button.d.ts +1 -1
  17. package/dist/components/split-button.js +6 -2
  18. package/dist/components/swap-text.js +9 -7
  19. package/dist/components/tooltip-trigger-helper.d.ts +3 -1
  20. package/dist/components/tooltip-trigger-helper.js +10 -3
  21. package/dist/components/tooltip.d.ts +3 -1
  22. package/dist/components/tooltip.js +25 -20
  23. package/dist/hooks/use-inline-overflow.d.ts +47 -0
  24. package/dist/hooks/use-inline-overflow.js +93 -0
  25. package/dist/icons.d.ts +2 -2
  26. package/dist/icons.js +2 -2
  27. package/dist/inspector/facet-bar.d.ts +1 -1
  28. package/dist/inspector/facet-bar.js +18 -53
  29. package/dist/lib/inline-overflow.d.ts +62 -0
  30. package/dist/lib/inline-overflow.js +79 -0
  31. package/dist/lib/matter-colors.d.ts +2 -2
  32. package/dist/lib/matter-colors.js +0 -1
  33. package/dist/review/review-decision-actions.d.ts +9 -4
  34. package/dist/review/review-decision-actions.js +24 -23
  35. package/dist/review/review-out-of-date-notice.d.ts +2 -4
  36. package/dist/review/review-out-of-date-notice.js +3 -3
  37. package/package.json +9 -1
  38. package/dist/inspector/facet-bar.logic.d.ts +0 -48
  39. package/dist/inspector/facet-bar.logic.js +0 -52
@@ -336,45 +336,230 @@ const openDocumentMark = ({ badge, letter, arrows, layers }) => {
336
336
  ]
337
337
  };
338
338
  };
339
- const legalDocumentMark = (details) => ({
340
- viewBox: "0 0 24 24",
341
- gradients: [],
342
- shapes: [
343
- {
344
- tag: "path",
345
- attrs: {
346
- d: "M5 1h9l5 5v15a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2z",
347
- fill: "#566275"
348
- }
349
- },
350
- {
351
- tag: "path",
352
- attrs: {
353
- d: "M14 1v5h5",
354
- fill: "#c2c9d2"
355
- }
356
- },
357
- {
358
- tag: "path",
359
- attrs: {
360
- d: details,
361
- fill: "none",
362
- stroke: "#fff",
363
- strokeWidth: "1.4",
364
- strokeLinecap: "round",
365
- strokeLinejoin: "round"
339
+ /**
340
+ * The letters a tag is drawn with, as strokes in a box three wide and four
341
+ * tall (the data-box mark's letters): points "x y" joined by commas, strokes
342
+ * by "|". A stroke that ends where it starts is closed.
343
+ */
344
+ const MARK_GLYPHS = {
345
+ A: "0 4,0 1.5,1.5 0,3 1.5,3 4|0 2.5,3 2.5",
346
+ B: "0 2,2.2 2,3 1.3,3 0.7,2.2 0,0 0,0 4,2.2 4,3 3.3,3 2.7,2.2 2",
347
+ C: "3 0,0 0,0 4,3 4",
348
+ D: "0 0,2 0,3 1,3 3,2 4,0 4,0 0",
349
+ E: "3 0,0 0,0 4,3 4|0 2,2.2 2",
350
+ F: "3 0,0 0,0 4|0 2,2.2 2",
351
+ I: "0.5 0,2.5 0|1.5 0,1.5 4|0.5 4,2.5 4",
352
+ L: "0 0,0 4,3 4",
353
+ M: "0 4,0 0,1.5 2,3 0,3 4",
354
+ O: "0 0,3 0,3 4,0 4,0 0",
355
+ P: "0 4,0 0,3 0,3 2,0 2",
356
+ S: "3 0,0 0,0 2,3 2,3 4,0 4",
357
+ T: "0 0,3 0|1.5 0,1.5 4",
358
+ U: "0 0,0 4,3 4,3 0",
359
+ X: "0 0,3 4|3 0,0 4",
360
+ Z: "0 0,3 0,0 4,3 4",
361
+ "3": "0 0,3 0,1.5 2,3 2,3 4,0 4",
362
+ "7": "0 0,3 0,1 4"
363
+ };
364
+ const GLYPH_WIDTH = 3;
365
+ const GLYPH_HEIGHT = 4;
366
+ const GLYPH_GAP = 2;
367
+ /** The page's room for its widest line, clear of the page's edges. */
368
+ const TAG_MAX_WIDTH = 14;
369
+ const TAG_MAX_SCALE = 1.15;
370
+ const TAG_LINE_GAP = 2;
371
+ const TAG_CENTER_X = 11;
372
+ /** The middle of the page below its fold. */
373
+ const TAG_CENTER_Y = 15;
374
+ const TAG_STROKE_WIDTH = 1.2;
375
+ const coordinate = (value) => String(Math.round(value * 100) / 100);
376
+ const lineWidth = (line) => line.length * GLYPH_WIDTH + (line.length - 1) * GLYPH_GAP;
377
+ const glyphStrokes = (glyph) => MARK_GLYPHS[glyph].split("|").map((stroke) => stroke.split(",").map((point) => {
378
+ const [x = 0, y = 0] = point.split(" ").map(Number);
379
+ return {
380
+ x,
381
+ y
382
+ };
383
+ }));
384
+ /** One stroke path for every letter of the tag, centred on the page. */
385
+ const tagPath = (lines) => {
386
+ const scale = Math.min(TAG_MAX_SCALE, TAG_MAX_WIDTH / Math.max(...lines.map(lineWidth)));
387
+ const lineHeight = GLYPH_HEIGHT * scale;
388
+ const blockHeight = lines.length * lineHeight + (lines.length - 1) * TAG_LINE_GAP;
389
+ const top = TAG_CENTER_Y - blockHeight / 2;
390
+ return {
391
+ d: lines.flatMap((line, lineIndex) => {
392
+ const left = TAG_CENTER_X - lineWidth(line) * scale / 2;
393
+ const y0 = top + lineIndex * (lineHeight + TAG_LINE_GAP);
394
+ return line.flatMap((glyph, glyphIndex) => {
395
+ const x0 = left + glyphIndex * 5 * scale;
396
+ return glyphStrokes(glyph).map((points) => {
397
+ const first = points.at(0);
398
+ const last = points.at(-1);
399
+ const closed = points.length > 2 && first?.x === last?.x && first?.y === last?.y;
400
+ return `M${(closed ? points.slice(0, -1) : points).map(({ x, y }) => `${coordinate(x0 + x * scale)} ${coordinate(y0 + y * scale)}`).join("L")}${closed ? "Z" : ""}`;
401
+ });
402
+ });
403
+ }).join(""),
404
+ strokeWidth: coordinate(TAG_STROKE_WIDTH * Math.min(1, scale))
405
+ };
406
+ };
407
+ const legalFormatMark = ({ color, lines }) => {
408
+ const tag = tagPath(lines);
409
+ return {
410
+ viewBox: "0 0 24 24",
411
+ gradients: [],
412
+ shapes: [
413
+ {
414
+ tag: "path",
415
+ attrs: {
416
+ d: "M5 1h9l5 5v15a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2z",
417
+ fill: color
418
+ }
419
+ },
420
+ {
421
+ tag: "path",
422
+ attrs: {
423
+ d: "M14 1v5h5",
424
+ fill: "#fff",
425
+ fillOpacity: "0.5"
426
+ }
427
+ },
428
+ {
429
+ tag: "path",
430
+ attrs: {
431
+ d: tag.d,
432
+ fill: "none",
433
+ stroke: "#fff",
434
+ strokeLinecap: "round",
435
+ strokeLinejoin: "round",
436
+ strokeWidth: tag.strokeWidth
437
+ }
366
438
  }
367
- }
368
- ]
369
- });
370
- const signedDocumentMark = legalDocumentMark("M7 11h8m-8 3h5m1 4 2 2 4-5");
371
- const structuredDocumentMark = legalDocumentMark("M7 11h8m-8 4h8m-8 4h5");
439
+ ]
440
+ };
441
+ };
372
442
  const DOCUMENT_MARKS = {
373
- ofd: structuredDocumentMark,
374
- uyap: structuredDocumentMark,
375
- asicE: signedDocumentMark,
376
- asicS: signedDocumentMark,
377
- cades: signedDocumentMark,
443
+ ofd: legalFormatMark({
444
+ color: "#9a5b00",
445
+ lines: [[
446
+ "O",
447
+ "F",
448
+ "D"
449
+ ]]
450
+ }),
451
+ uyap: legalFormatMark({
452
+ color: "#b3261e",
453
+ lines: [[
454
+ "U",
455
+ "D",
456
+ "F"
457
+ ]]
458
+ }),
459
+ asicE: legalFormatMark({
460
+ color: "#2e6b4f",
461
+ lines: [[
462
+ "A",
463
+ "S",
464
+ "I",
465
+ "C"
466
+ ], ["E"]]
467
+ }),
468
+ asicS: legalFormatMark({
469
+ color: "#4f7a2e",
470
+ lines: [[
471
+ "A",
472
+ "S",
473
+ "I",
474
+ "C"
475
+ ], ["S"]]
476
+ }),
477
+ bdoc: legalFormatMark({
478
+ color: "#0f6e7a",
479
+ lines: [[
480
+ "B",
481
+ "D",
482
+ "O",
483
+ "C"
484
+ ]]
485
+ }),
486
+ cades: legalFormatMark({
487
+ color: "#6b4c9a",
488
+ lines: [[
489
+ "P",
490
+ "7",
491
+ "M"
492
+ ]]
493
+ }),
494
+ fatturaPA: legalFormatMark({
495
+ color: "#1d6f42",
496
+ lines: [[
497
+ "F",
498
+ "P",
499
+ "A"
500
+ ]]
501
+ }),
502
+ isdoc: legalFormatMark({
503
+ color: "#1f5fa8",
504
+ lines: [[
505
+ "I",
506
+ "S",
507
+ "D",
508
+ "O",
509
+ "C"
510
+ ]]
511
+ }),
512
+ isdocx: legalFormatMark({
513
+ color: "#2a4f8f",
514
+ lines: [[
515
+ "I",
516
+ "S",
517
+ "D",
518
+ "O",
519
+ "C"
520
+ ], ["X"]]
521
+ }),
522
+ xml: legalFormatMark({
523
+ color: "#5c6470",
524
+ lines: [[
525
+ "X",
526
+ "M",
527
+ "L"
528
+ ]]
529
+ }),
530
+ eAkta: legalFormatMark({
531
+ color: "#8c2f5d",
532
+ lines: [[
533
+ "E",
534
+ "S",
535
+ "3"
536
+ ]]
537
+ }),
538
+ et3: legalFormatMark({
539
+ color: "#a2481f",
540
+ lines: [[
541
+ "E",
542
+ "T",
543
+ "3"
544
+ ]]
545
+ }),
546
+ zep: legalFormatMark({
547
+ color: "#24529c",
548
+ lines: [[
549
+ "Z",
550
+ "E",
551
+ "P"
552
+ ]]
553
+ }),
554
+ xadesZep: legalFormatMark({
555
+ color: "#3d4f8f",
556
+ lines: [[
557
+ "X",
558
+ "Z",
559
+ "E",
560
+ "P"
561
+ ]]
562
+ }),
378
563
  dataBox: {
379
564
  viewBox: "0 0 24 24",
380
565
  gradients: [],
@@ -3,10 +3,11 @@ type FileInputProps = {
3
3
  "aria-labelledby"?: string | undefined;
4
4
  className?: string | undefined;
5
5
  disabled?: boolean | undefined;
6
+ disabledReason?: string | undefined;
6
7
  file: File | null;
7
8
  onFileChange: (file: File) => void;
8
9
  chooseLabel: string;
9
10
  emptyLabel: string;
10
11
  };
11
- declare const FileInput: ({ accept, "aria-labelledby": labelledBy, className, disabled, file, onFileChange, chooseLabel, emptyLabel }: FileInputProps) => import("react").JSX.Element;
12
+ declare const FileInput: ({ accept, "aria-labelledby": labelledBy, className, disabled, disabledReason, file, onFileChange, chooseLabel, emptyLabel }: FileInputProps) => import("react").JSX.Element;
12
13
  export { FileInput, type FileInputProps };
@@ -7,7 +7,7 @@ import { TruncatedText } from "./truncated-text.js";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
8
  import { useId } from "react";
9
9
  // src/components/file-input.tsx
10
- const FileInput = ({ accept, "aria-labelledby": labelledBy, className, disabled, file, onFileChange, chooseLabel, emptyLabel }) => {
10
+ const FileInput = ({ accept, "aria-labelledby": labelledBy, className, disabled, disabledReason, file, onFileChange, chooseLabel, emptyLabel }) => {
11
11
  const triggerId = useId();
12
12
  return /* @__PURE__ */ jsxs("span", {
13
13
  className: cn("flex min-w-0 items-center gap-3", className),
@@ -16,6 +16,7 @@ const FileInput = ({ accept, "aria-labelledby": labelledBy, className, disabled,
16
16
  "aria-labelledby": labelledBy ? `${labelledBy} ${triggerId}` : void 0,
17
17
  "data-slot": "file-input-trigger",
18
18
  disabled,
19
+ disabledReason,
19
20
  id: triggerId,
20
21
  onClick: () => openFilePicker({
21
22
  accept,
@@ -143,23 +143,22 @@ const useEventCallback = (handler) => {
143
143
  };
144
144
  const useColorManipulation = (color, onChange) => {
145
145
  const onChangeCallback = useEventCallback(onChange);
146
- const [hsva, setHsva] = useState(() => hexToHsva(color));
147
- const [committedColor, setCommittedColor] = useState(color);
148
- if (!equalHex(color, committedColor)) {
149
- setCommittedColor(color);
150
- setHsva(hexToHsva(color));
151
- }
146
+ const [local, setLocal] = useState(() => ({
147
+ color,
148
+ hsva: hexToHsva(color)
149
+ }));
150
+ const hsva = equalHex(color, local.color) ? local.hsva : hexToHsva(color);
152
151
  const handleChange = (params) => {
153
152
  const next = {
154
153
  ...hsva,
155
154
  ...params
156
155
  };
157
- setHsva(next);
158
156
  const hex = hsvaToHex(next);
159
- if (!equalHex(hex, committedColor)) {
160
- setCommittedColor(hex);
161
- onChangeCallback(hex);
162
- }
157
+ setLocal({
158
+ color: hex,
159
+ hsva: next
160
+ });
161
+ if (!equalHex(hex, color)) onChangeCallback(hex);
163
162
  };
164
163
  return [hsva, handleChange];
165
164
  };
@@ -5,6 +5,7 @@ type SearchFieldProps = Omit<React.ComponentProps<typeof InputGroupInput>, "onCh
5
5
  onValueChange: (value: string) => void;
6
6
  /** Accessible name of the clear button; the package ships no copy. */
7
7
  clearLabel: string;
8
+ disabledReason?: string | undefined;
8
9
  /** Class for the outer group (width, margins). */
9
10
  groupClassName?: string;
10
11
  };
@@ -14,5 +15,5 @@ type SearchFieldProps = Omit<React.ComponentProps<typeof InputGroupInput>, "onCh
14
15
  * and the matching; keep matching local and instant for lists under a few
15
16
  * hundred rows.
16
17
  */
17
- declare const SearchField: ({ value, onValueChange, clearLabel, groupClassName, className, onKeyDown, ...props }: SearchFieldProps) => React.JSX.Element;
18
+ declare const SearchField: ({ value, onValueChange, clearLabel, disabledReason, groupClassName, className, onKeyDown, ...props }: SearchFieldProps) => React.JSX.Element;
18
19
  export { SearchField, type SearchFieldProps };
@@ -11,7 +11,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
11
11
  * and the matching; keep matching local and instant for lists under a few
12
12
  * hundred rows.
13
13
  */
14
- const SearchField = ({ value, onValueChange, clearLabel, groupClassName, className, onKeyDown, ...props }) => /* @__PURE__ */ jsxs(InputGroup, {
14
+ const SearchField = ({ value, onValueChange, clearLabel, disabledReason, groupClassName, className, onKeyDown, ...props }) => /* @__PURE__ */ jsxs(InputGroup, {
15
15
  className: cn("min-h-11 sm:min-h-0", groupClassName),
16
16
  children: [/* @__PURE__ */ jsx(InputGroupInput, {
17
17
  autoComplete: "off",
@@ -36,6 +36,7 @@ const SearchField = ({ value, onValueChange, clearLabel, groupClassName, classNa
36
36
  children: /* @__PURE__ */ jsx(Button, {
37
37
  "aria-label": clearLabel,
38
38
  disabled: props.disabled,
39
+ disabledReason,
39
40
  onClick: () => {
40
41
  onValueChange("");
41
42
  },
@@ -1,7 +1,8 @@
1
1
  import { InputProps } from "./input.js";
2
2
  type SecretInputProps = Omit<InputProps, "type"> & {
3
3
  hideValueLabel: string;
4
+ disabledReason?: string | undefined;
4
5
  showValueLabel: string;
5
6
  };
6
- declare const SecretInput: ({ className, dir, disabled, hideValueLabel, showValueLabel, ...props }: SecretInputProps) => import("react").JSX.Element;
7
+ declare const SecretInput: ({ className, dir, disabled, hideValueLabel, disabledReason, showValueLabel, ...props }: SecretInputProps) => import("react").JSX.Element;
7
8
  export { SecretInput, type SecretInputProps };
@@ -6,7 +6,7 @@ import { Input } from "./input.js";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
7
  import { useState } from "react";
8
8
  // src/components/secret-input.tsx
9
- const SecretInput = ({ className, dir, disabled, hideValueLabel, showValueLabel, ...props }) => {
9
+ const SecretInput = ({ className, dir, disabled, hideValueLabel, disabledReason, showValueLabel, ...props }) => {
10
10
  const [visibility, setVisibility] = useState("concealed");
11
11
  const isRevealed = visibility === "revealed";
12
12
  const label = isRevealed ? hideValueLabel : showValueLabel;
@@ -26,6 +26,7 @@ const SecretInput = ({ className, dir, disabled, hideValueLabel, showValueLabel,
26
26
  className: "text-muted-foreground hover:text-foreground absolute end-1 top-1/2 z-1 -translate-y-1/2",
27
27
  "data-slot": "secret-input-visibility-toggle",
28
28
  disabled,
29
+ disabledReason,
29
30
  onClick: () => setVisibility(isRevealed ? "concealed" : "revealed"),
30
31
  size: "icon-xs",
31
32
  type: "button",
@@ -9,7 +9,7 @@ type SplitButtonSharedProps = {
9
9
  menuDescriptionId?: string;
10
10
  onPrimaryClick: NonNullable<ComponentProps<typeof Button>["onClick"]>;
11
11
  menu: ReactNode;
12
- primaryDisabled?: boolean;
12
+ primaryDisabledReason?: string | undefined;
13
13
  menuDisabled?: boolean;
14
14
  size?: SplitButtonSize;
15
15
  className?: string;
@@ -13,7 +13,11 @@ import { jsx, jsxs } from "react/jsx-runtime";
13
13
  * never reads as disabled beside its neighbours.
14
14
  */
15
15
  const SplitButton = (props) => {
16
- const { primaryLabel, menuLabel, primaryDescriptionId, menuDescriptionId, onPrimaryClick, children, menu, primaryDisabled, menuDisabled, size = "md", className } = props;
16
+ const { primaryLabel, menuLabel, primaryDescriptionId, menuDescriptionId, onPrimaryClick, children, menu, primaryDisabledReason, menuDisabled, size = "md", className } = props;
17
+ const primaryState = Object.hasOwn(props, "primaryDisabledReason") ? {
18
+ disabled: primaryDisabledReason !== void 0,
19
+ disabledReason: primaryDisabledReason
20
+ } : {};
17
21
  const triggerButton = /* @__PURE__ */ jsx(Button, {
18
22
  className: SPLIT_BUTTON_TRIGGER_CLASS[size],
19
23
  size: "sm",
@@ -28,7 +32,7 @@ const SplitButton = (props) => {
28
32
  "aria-describedby": primaryDescriptionId,
29
33
  "aria-label": primaryLabel,
30
34
  className: SPLIT_BUTTON_PRIMARY_CLASS[size],
31
- disabled: primaryDisabled,
35
+ ...primaryState,
32
36
  onClick: onPrimaryClick,
33
37
  size: "sm",
34
38
  tooltip: props.primaryContent === BUTTON_CONTENT.icon ? primaryLabel : void 0,
@@ -11,16 +11,18 @@ import { useState } from "react";
11
11
  * under reduced motion the label simply changes.
12
12
  */
13
13
  const SwapText = ({ className, text }) => {
14
+ const [prevText, setPrevText] = useState(text);
14
15
  const [state, setState] = useState({
15
- current: text,
16
16
  generation: 0,
17
17
  previous: null
18
18
  });
19
- if (state.current !== text) setState({
20
- current: text,
21
- generation: state.generation + 1,
22
- previous: state.current
23
- });
19
+ if (prevText !== text) {
20
+ setPrevText(text);
21
+ setState({
22
+ generation: state.generation + 1,
23
+ previous: prevText
24
+ });
25
+ }
24
26
  const hasSwapped = state.generation > 0;
25
27
  return /* @__PURE__ */ jsxs("span", {
26
28
  className: "inline-grid",
@@ -43,7 +45,7 @@ const SwapText = ({ className, text }) => {
43
45
  className: cn("col-start-1 row-start-1", hasSwapped && "motion-safe:animate-swap-in"),
44
46
  children: /* @__PURE__ */ jsx("span", {
45
47
  className,
46
- children: state.current
48
+ children: text
47
49
  })
48
50
  }, `in-${state.generation}`)]
49
51
  });
@@ -2,11 +2,13 @@ import * as React from "react";
2
2
  type TooltipTriggerOptions = {
3
3
  trigger: React.ReactElement;
4
4
  tooltip: React.ReactNode;
5
+ keepTriggerMounted?: boolean;
6
+ popupDescriptionId?: string | undefined;
5
7
  };
6
8
  /**
7
9
  * Overlay triggers pass only an explicit `tooltip`. They cannot tell whether
8
10
  * their content is a label or a glyph; a trigger rendered as `Button` hands its
9
11
  * `aria-label` to that Button, whose size decides (see `BUTTON_SIZE_CONTENT`).
10
12
  */
11
- declare const renderTooltipTrigger: ({ trigger, tooltip }: TooltipTriggerOptions) => React.JSX.Element;
13
+ declare const renderTooltipTrigger: ({ trigger, tooltip, keepTriggerMounted, popupDescriptionId }: TooltipTriggerOptions) => React.JSX.Element;
12
14
  export { renderTooltipTrigger };
@@ -8,8 +8,15 @@ import { jsx, jsxs } from "react/jsx-runtime";
8
8
  * their content is a label or a glyph; a trigger rendered as `Button` hands its
9
9
  * `aria-label` to that Button, whose size decides (see `BUTTON_SIZE_CONTENT`).
10
10
  */
11
- const renderTooltipTrigger = ({ trigger, tooltip }) => {
12
- if (!hasTooltipContent(tooltip)) return trigger;
13
- return /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, { render: trigger }), /* @__PURE__ */ jsx(TooltipPopup, { children: tooltip })] });
11
+ const renderTooltipTrigger = ({ trigger, tooltip, keepTriggerMounted = false, popupDescriptionId }) => {
12
+ const hasContent = hasTooltipContent(tooltip);
13
+ if (!hasContent && !keepTriggerMounted) return trigger;
14
+ return /* @__PURE__ */ jsxs(Tooltip, {
15
+ disabled: !hasContent,
16
+ children: [/* @__PURE__ */ jsx(TooltipTrigger, { render: trigger }), hasContent && /* @__PURE__ */ jsx(TooltipPopup, {
17
+ descriptionId: popupDescriptionId,
18
+ children: tooltip
19
+ })]
20
+ });
14
21
  };
15
22
  export { renderTooltipTrigger };
@@ -27,12 +27,14 @@ declare const TooltipTrigger: (props: Tooltip$1.Trigger.Props) => import("react"
27
27
  declare const TooltipFactTrigger: ({ children }: {
28
28
  children: ReactNode;
29
29
  }) => import("react").JSX.Element;
30
- declare const TooltipPopup: ({ anchor, className, align, sideOffset, side, children, shortcut, ...props }: Tooltip$1.Popup.Props & {
30
+ declare const TooltipPopup: ({ anchor, className, align, sideOffset, side, children, shortcut, descriptionId, ...props }: Tooltip$1.Popup.Props & {
31
31
  /**
32
32
  * The keys that do the same as the trigger, shown after the label and
33
33
  * spelled for the reader's platform (`["mod", "K"]`).
34
34
  */
35
35
  shortcut?: KbdKeys | undefined;
36
+ /** Keep the popup as a single accessible description target when closed. */
37
+ descriptionId?: string | undefined;
36
38
  /**
37
39
  * The element the popup sits beside, when that is a part of the trigger
38
40
  * rather than all of it (a wide row whose tooltip explains one detail).
@@ -41,27 +41,32 @@ const TooltipFactTrigger = ({ children }) => /* @__PURE__ */ jsx(Tooltip$1.Trigg
41
41
  type: "button",
42
42
  children
43
43
  });
44
- const TooltipPopup = ({ anchor, className, align = "center", sideOffset = 4, side = "top", children, shortcut, ...props }) => /* @__PURE__ */ jsx(Tooltip$1.Portal, { children: /* @__PURE__ */ jsx(Tooltip$1.Positioner, {
45
- ...anchor === void 0 ? {} : { anchor },
46
- align,
47
- className: cn(CONTENT_SIZED_POSITIONER_CLASS_NAME, "transition-[top,left,right,bottom,transform] data-instant:transition-none", OVERLAY_LAYER_CLASS_NAMES.popup),
48
- collisionPadding: 8,
49
- "data-slot": "tooltip-positioner",
50
- side,
51
- sideOffset,
52
- children: /* @__PURE__ */ jsx(Tooltip$1.Popup, {
53
- className: cn(IN_FLOW_POPUP_CLASS_NAME, "bg-popover text-popover-foreground flex h-(--popup-height,auto) w-(--popup-width,auto) origin-(--transform-origin) rounded-md border text-xs text-balance shadow-md/5 transition-[width,height,scale,opacity] not-dark:bg-clip-padding before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-md)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-ending-style:scale-98 data-ending-style:opacity-0 data-instant:duration-0 data-starting-style:scale-98 data-starting-style:opacity-0 dark:before:shadow-[0_-1px_--theme(--color-white/6%)]", className),
54
- "data-slot": "tooltip-popup",
55
- ...props,
56
- children: /* @__PURE__ */ jsx(Tooltip$1.Viewport, {
57
- className: "relative size-full overflow-clip px-(--viewport-inline-padding) py-1 [--viewport-inline-padding:--spacing(2)] **:data-current:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-current:opacity-100 **:data-current:transition-opacity **:data-current:data-ending-style:opacity-0 data-instant:transition-none **:data-previous:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-previous:truncate **:data-previous:opacity-100 **:data-previous:transition-opacity **:data-previous:data-ending-style:opacity-0 **:data-current:data-starting-style:opacity-0 **:data-previous:data-starting-style:opacity-0",
58
- "data-slot": "tooltip-viewport",
59
- children: shortcut === void 0 ? children : /* @__PURE__ */ jsxs("span", {
60
- className: "flex flex-wrap items-center gap-x-2 gap-y-1",
61
- "data-slot": "tooltip-shortcut-row",
62
- children: [children, /* @__PURE__ */ jsx(Kbd, { keys: shortcut })]
44
+ const TooltipPopup = ({ anchor, className, align = "center", sideOffset = 4, side = "top", children, shortcut, descriptionId, ...props }) => /* @__PURE__ */ jsx(Tooltip$1.Portal, {
45
+ keepMounted: descriptionId !== void 0,
46
+ children: /* @__PURE__ */ jsx(Tooltip$1.Positioner, {
47
+ id: descriptionId,
48
+ ...anchor === void 0 ? {} : { anchor },
49
+ align,
50
+ className: cn(CONTENT_SIZED_POSITIONER_CLASS_NAME, "transition-[top,left,right,bottom,transform] data-instant:transition-none", OVERLAY_LAYER_CLASS_NAMES.popup),
51
+ collisionPadding: 8,
52
+ "data-slot": "tooltip-positioner",
53
+ side,
54
+ sideOffset,
55
+ children: /* @__PURE__ */ jsx(Tooltip$1.Popup, {
56
+ className: cn(IN_FLOW_POPUP_CLASS_NAME, "bg-popover text-popover-foreground flex h-(--popup-height,auto) w-(--popup-width,auto) origin-(--transform-origin) rounded-md border text-xs text-balance shadow-md/5 transition-[width,height,scale,opacity] not-dark:bg-clip-padding before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-md)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-ending-style:scale-98 data-ending-style:opacity-0 data-instant:duration-0 data-starting-style:scale-98 data-starting-style:opacity-0 dark:before:shadow-[0_-1px_--theme(--color-white/6%)]", className),
57
+ "data-slot": "tooltip-popup",
58
+ role: descriptionId === void 0 ? void 0 : "tooltip",
59
+ ...props,
60
+ children: /* @__PURE__ */ jsx(Tooltip$1.Viewport, {
61
+ className: "relative size-full overflow-clip px-(--viewport-inline-padding) py-1 [--viewport-inline-padding:--spacing(2)] **:data-current:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-current:opacity-100 **:data-current:transition-opacity **:data-current:data-ending-style:opacity-0 data-instant:transition-none **:data-previous:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-previous:truncate **:data-previous:opacity-100 **:data-previous:transition-opacity **:data-previous:data-ending-style:opacity-0 **:data-current:data-starting-style:opacity-0 **:data-previous:data-starting-style:opacity-0",
62
+ "data-slot": "tooltip-viewport",
63
+ children: shortcut === void 0 ? children : /* @__PURE__ */ jsxs("span", {
64
+ className: "flex flex-wrap items-center gap-x-2 gap-y-1",
65
+ "data-slot": "tooltip-shortcut-row",
66
+ children: [children, /* @__PURE__ */ jsx(Kbd, { keys: shortcut })]
67
+ })
63
68
  })
64
69
  })
65
70
  })
66
- }) });
71
+ });
67
72
  export { TOOLTIP_OPEN_DELAY_MS, Tooltip, TooltipPopup as TooltipContent, TooltipPopup, TooltipCreateHandle, TooltipFactTrigger, TooltipProvider, TooltipTrigger };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Marks one item's natural-width copy inside the measuring row; its value is
3
+ * the item's key.
4
+ */
5
+ export declare const INLINE_OVERFLOW_ITEM_ATTRIBUTE = "data-inline-overflow-item";
6
+ /** Marks the overflow trigger's copy inside the measuring row. */
7
+ export declare const INLINE_OVERFLOW_TRIGGER_ATTRIBUTE = "data-inline-overflow-trigger";
8
+ type UseInlineOverflowOptions = {
9
+ /** The active item's index; the policy keeps it on screen. */
10
+ activeIndex: number;
11
+ /**
12
+ * Each item's key, in display order; the measuring copy of an item carries
13
+ * its key in `INLINE_OVERFLOW_ITEM_ATTRIBUTE`.
14
+ */
15
+ itemKeys: readonly string[];
16
+ };
17
+ /**
18
+ * Measures a single-line row and decides how many of its items fit, by
19
+ * `resolveInlineOverflow`. The caller renders two things:
20
+ *
21
+ * - the row (`containerRef`), whose content box is the room the items and
22
+ * the overflow trigger share, independent of how many items it shows;
23
+ * - an invisible, inert copy of every item at its natural width plus the
24
+ * trigger (`measureRef`), each marked with `INLINE_OVERFLOW_ITEM_ATTRIBUTE`
25
+ * (set to the item's key) or `INLINE_OVERFLOW_TRIGGER_ATTRIBUTE`, inside
26
+ * one flex row whose gap is the gap between items.
27
+ *
28
+ * Measuring the copy keeps the widths stable however many items the row is
29
+ * currently showing, so collapsing an item never changes the measurement
30
+ * that collapsed it. Widths are read by key in the order `itemKeys` gives,
31
+ * and the count is recomputed whenever either element resizes (a docked
32
+ * pane narrows the row, an added view or a rename widens the copy), the
33
+ * active item changes, or the items change order: swapping two items keeps
34
+ * the measuring row's size, which no observer reports. The first count
35
+ * arrives with the observer's first report, before the row paints; until
36
+ * then every item shows.
37
+ */
38
+ export declare const useInlineOverflow: ({ activeIndex, itemKeys }: UseInlineOverflowOptions) => {
39
+ /** The measured row, once mounted. */
40
+ container: HTMLElement | null;
41
+ containerRef: import("react").Dispatch<import("react").SetStateAction<HTMLElement | null>>;
42
+ /** Whether the row has been measured; until then every item shows. */
43
+ measured: boolean;
44
+ measureRef: import("react").Dispatch<import("react").SetStateAction<HTMLElement | null>>;
45
+ visibleCount: number;
46
+ };
47
+ export {};