@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/README.md +3 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +199 -1
- package/dist/react.js +260 -10
- package/dist/react.js.map +1 -1
- package/dist/styles.css +106 -0
- package/dist/ui.d.ts +199 -1
- package/package.json +5 -5
package/dist/react.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/dist/react.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { a as uiMessages, i as warnInDevelopment, n as cssWriterOf, o as UiError, t as isThemePair } from "./shared/pair-DLVFV6vU.js";
|
|
3
3
|
import { createMessages, platformOf, sdkCoreMessages } from "@hussmartinez/sdk-core";
|
|
4
|
-
import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
4
|
+
import { cloneElement, createContext, forwardRef, isValidElement, useCallback, useContext, useEffect, useId, useMemo, useRef, useState, useSyncExternalStore, version } from "react";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { flushSync } from "react-dom";
|
|
7
7
|
// src/internal/single-copy.ts
|
|
@@ -9,7 +9,7 @@ var REGISTRY = /* @__PURE__ */ Symbol.for("@hussmartinez/ui");
|
|
|
9
9
|
var THIS_COPY = {};
|
|
10
10
|
var checked = false;
|
|
11
11
|
function ownVersion() {
|
|
12
|
-
return "0.
|
|
12
|
+
return "0.8.0";
|
|
13
13
|
}
|
|
14
14
|
function checkSingleCopy() {
|
|
15
15
|
if (checked || !(typeof process !== "undefined" && process.env.NODE_ENV !== "production")) return;
|
|
@@ -800,6 +800,27 @@ var Spinner = /* @__PURE__ */ forwardRef(function Spinner({ label, className, cl
|
|
|
800
800
|
"data-hm-unstyled": unstyledAttribute(unstyled)
|
|
801
801
|
});
|
|
802
802
|
});
|
|
803
|
+
// src/components/text-field/TextField.tsx
|
|
804
|
+
var TextField = /* @__PURE__ */ forwardRef(function TextField({ type = "text", onValueChange, onChange, label, className, classNames, unstyled, ...props }, ref) {
|
|
805
|
+
const fieldProps = useFieldProps(props, label);
|
|
806
|
+
if (label === void 0 && !props["aria-label"] && !props["aria-labelledby"] && fieldProps.id === void 0) {
|
|
807
|
+
if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") warnInDevelopment("TextField needs an accessible name: pass label, or put it in a Field. Use text from your message catalogue.");
|
|
808
|
+
}
|
|
809
|
+
const handleChange = (event) => {
|
|
810
|
+
onChange?.(event);
|
|
811
|
+
onValueChange?.(event.currentTarget.value);
|
|
812
|
+
};
|
|
813
|
+
return /* @__PURE__ */ jsx("input", {
|
|
814
|
+
...props,
|
|
815
|
+
...fieldProps,
|
|
816
|
+
ref,
|
|
817
|
+
type,
|
|
818
|
+
"aria-label": label ?? props["aria-label"],
|
|
819
|
+
className: cx("hm-text-field", classNames?.root, className),
|
|
820
|
+
"data-hm-unstyled": unstyledAttribute(unstyled),
|
|
821
|
+
onChange: handleChange
|
|
822
|
+
});
|
|
823
|
+
});
|
|
803
824
|
// src/components/toggle-button/ToggleButton.tsx
|
|
804
825
|
var ToggleButton = /* @__PURE__ */ forwardRef(function ToggleButton({ pressed: controlled, defaultPressed = false, onPressedChange, onClick, icon, label, className, ...props }, ref) {
|
|
805
826
|
const [uncontrolled, setUncontrolled] = useState(defaultPressed);
|
|
@@ -950,6 +971,155 @@ var ToolbarSeparator = /* @__PURE__ */ forwardRef(function ToolbarSeparator({ cl
|
|
|
950
971
|
className: cx("hm-toolbar-separator", className)
|
|
951
972
|
});
|
|
952
973
|
});
|
|
974
|
+
// src/react/use-platform.ts
|
|
975
|
+
var subscribe = () => () => void 0;
|
|
976
|
+
var onClient = () => platformOf(globalThis.navigator);
|
|
977
|
+
var onServer = () => "other";
|
|
978
|
+
function usePlatform() {
|
|
979
|
+
return useSyncExternalStore(subscribe, onClient, onServer);
|
|
980
|
+
}
|
|
981
|
+
// src/components/tooltip/Tooltip.tsx
|
|
982
|
+
var GRACE = 100;
|
|
983
|
+
var ariaKey = (part) => part.value === " " ? "Space" : part.value;
|
|
984
|
+
function place(trigger, tooltip, preferred) {
|
|
985
|
+
const anchor = trigger.getBoundingClientRect();
|
|
986
|
+
const box = tooltip.getBoundingClientRect();
|
|
987
|
+
const viewport = document.documentElement;
|
|
988
|
+
const above = anchor.top;
|
|
989
|
+
const below = viewport.clientHeight - anchor.bottom;
|
|
990
|
+
const fits = (side) => (side === "top" ? above : below) >= box.height;
|
|
991
|
+
const other = preferred === "top" ? "bottom" : "top";
|
|
992
|
+
const side = fits(preferred) || !fits(other) ? preferred : other;
|
|
993
|
+
const left = Math.min(Math.max(anchor.left + anchor.width / 2 - box.width / 2, 0), Math.max(viewport.clientWidth - box.width, 0));
|
|
994
|
+
tooltip.style.left = `${left}px`;
|
|
995
|
+
tooltip.style.top = `${side === "top" ? anchor.top - box.height : anchor.bottom}px`;
|
|
996
|
+
tooltip.dataset["hmPlacement"] = side;
|
|
997
|
+
}
|
|
998
|
+
function refOf(element) {
|
|
999
|
+
if (version.startsWith("18")) return element.ref;
|
|
1000
|
+
return element.props.ref;
|
|
1001
|
+
}
|
|
1002
|
+
function setRef(ref, value) {
|
|
1003
|
+
if (typeof ref === "function") ref(value);
|
|
1004
|
+
else if (ref) ref.current = value;
|
|
1005
|
+
}
|
|
1006
|
+
var Tooltip = /* @__PURE__ */ forwardRef(function Tooltip({ content, type = "description", shortcut, placement = "top", delay = 500, className, classNames, unstyled, children }, ref) {
|
|
1007
|
+
const id = useId();
|
|
1008
|
+
const contentId = `${id}-content`;
|
|
1009
|
+
const platform = usePlatform();
|
|
1010
|
+
const messages = useUiMessages();
|
|
1011
|
+
const [open, setOpen] = useState(false);
|
|
1012
|
+
const trigger = useRef(null);
|
|
1013
|
+
const tooltip = useRef(null);
|
|
1014
|
+
const timer = useRef(void 0);
|
|
1015
|
+
const dismissed = useRef(false);
|
|
1016
|
+
const clear = () => {
|
|
1017
|
+
clearTimeout(timer.current);
|
|
1018
|
+
timer.current = void 0;
|
|
1019
|
+
};
|
|
1020
|
+
const show = useCallback((after) => {
|
|
1021
|
+
clearTimeout(timer.current);
|
|
1022
|
+
if (dismissed.current) return;
|
|
1023
|
+
timer.current = setTimeout(() => setOpen(true), after);
|
|
1024
|
+
}, []);
|
|
1025
|
+
const hide = useCallback((after) => {
|
|
1026
|
+
clearTimeout(timer.current);
|
|
1027
|
+
timer.current = setTimeout(() => setOpen(false), after);
|
|
1028
|
+
}, []);
|
|
1029
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
1030
|
+
useEffect(() => {
|
|
1031
|
+
const element = tooltip.current;
|
|
1032
|
+
if (!element || typeof element.showPopover !== "function") return;
|
|
1033
|
+
if (!open) {
|
|
1034
|
+
if (element.matches(":popover-open")) element.hidePopover();
|
|
1035
|
+
return;
|
|
1036
|
+
}
|
|
1037
|
+
element.showPopover();
|
|
1038
|
+
if (trigger.current) place(trigger.current, element, placement);
|
|
1039
|
+
const close = () => setOpen(false);
|
|
1040
|
+
const onKeyDown = (event) => {
|
|
1041
|
+
if (event.key === "Escape") {
|
|
1042
|
+
event.preventDefault();
|
|
1043
|
+
dismissed.current = true;
|
|
1044
|
+
close();
|
|
1045
|
+
}
|
|
1046
|
+
};
|
|
1047
|
+
document.addEventListener("keydown", onKeyDown, true);
|
|
1048
|
+
window.addEventListener("scroll", close, true);
|
|
1049
|
+
window.addEventListener("resize", close);
|
|
1050
|
+
return () => {
|
|
1051
|
+
document.removeEventListener("keydown", onKeyDown, true);
|
|
1052
|
+
window.removeEventListener("scroll", close, true);
|
|
1053
|
+
window.removeEventListener("resize", close);
|
|
1054
|
+
};
|
|
1055
|
+
}, [open, placement]);
|
|
1056
|
+
if (!isValidElement(children)) {
|
|
1057
|
+
if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") warnInDevelopment("Tooltip needs one element as its child, such as an IconButton.");
|
|
1058
|
+
return children;
|
|
1059
|
+
}
|
|
1060
|
+
const child = children;
|
|
1061
|
+
const own = child.props;
|
|
1062
|
+
const childRef = refOf(child);
|
|
1063
|
+
const keyshortcuts = shortcut && shortcut.length > 0 ? shortcut.map(ariaKey).join("+") : own["aria-keyshortcuts"];
|
|
1064
|
+
const text = messages.t;
|
|
1065
|
+
const triggerProps = {
|
|
1066
|
+
ref: (node) => {
|
|
1067
|
+
trigger.current = node;
|
|
1068
|
+
setRef(childRef, node);
|
|
1069
|
+
},
|
|
1070
|
+
...type === "label" ? { "aria-labelledby": joinIds(contentId, own["aria-labelledby"]) } : { "aria-describedby": joinIds(own["aria-describedby"], contentId) },
|
|
1071
|
+
"aria-keyshortcuts": keyshortcuts,
|
|
1072
|
+
onPointerEnter: (event) => {
|
|
1073
|
+
own.onPointerEnter?.(event);
|
|
1074
|
+
if (event.pointerType !== "touch") show(open ? 0 : delay);
|
|
1075
|
+
},
|
|
1076
|
+
onPointerLeave: (event) => {
|
|
1077
|
+
own.onPointerLeave?.(event);
|
|
1078
|
+
dismissed.current = false;
|
|
1079
|
+
hide(GRACE);
|
|
1080
|
+
},
|
|
1081
|
+
onPointerDown: (event) => {
|
|
1082
|
+
own.onPointerDown?.(event);
|
|
1083
|
+
clear();
|
|
1084
|
+
setOpen(false);
|
|
1085
|
+
},
|
|
1086
|
+
onFocus: (event) => {
|
|
1087
|
+
own.onFocus?.(event);
|
|
1088
|
+
if (event.currentTarget.matches(":focus-visible") && !dismissed.current) {
|
|
1089
|
+
clear();
|
|
1090
|
+
setOpen(true);
|
|
1091
|
+
}
|
|
1092
|
+
},
|
|
1093
|
+
onBlur: (event) => {
|
|
1094
|
+
own.onBlur?.(event);
|
|
1095
|
+
dismissed.current = false;
|
|
1096
|
+
clear();
|
|
1097
|
+
setOpen(false);
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [cloneElement(child, triggerProps), /* @__PURE__ */ jsxs("div", {
|
|
1101
|
+
ref: (node) => {
|
|
1102
|
+
tooltip.current = node;
|
|
1103
|
+
setRef(ref, node);
|
|
1104
|
+
},
|
|
1105
|
+
id,
|
|
1106
|
+
role: "tooltip",
|
|
1107
|
+
popover: "manual",
|
|
1108
|
+
className: cx("hm-tooltip", classNames?.root, className),
|
|
1109
|
+
"data-hm-unstyled": unstyledAttribute(unstyled),
|
|
1110
|
+
onPointerEnter: () => clear(),
|
|
1111
|
+
onPointerLeave: () => hide(GRACE),
|
|
1112
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1113
|
+
id: contentId,
|
|
1114
|
+
className: cx("hm-tooltip-content", classNames?.content),
|
|
1115
|
+
children: content
|
|
1116
|
+
}), shortcut && shortcut.length > 0 ? /* @__PURE__ */ jsx("span", {
|
|
1117
|
+
className: cx("hm-tooltip-shortcut", classNames?.shortcut),
|
|
1118
|
+
"aria-hidden": "true",
|
|
1119
|
+
children: shortcut.map((part, index) => /* @__PURE__ */ jsxs("span", { children: [index > 0 && platform === "other" ? "+" : null, /* @__PURE__ */ jsx("kbd", { children: part.message ? text(part.message) : part.value })] }, index))
|
|
1120
|
+
}) : null]
|
|
1121
|
+
})] });
|
|
1122
|
+
});
|
|
953
1123
|
// src/components/visually-hidden/VisuallyHidden.tsx
|
|
954
1124
|
var VisuallyHidden = /* @__PURE__ */ forwardRef(function VisuallyHidden({ as: Element = "span", className, ...props }, ref) {
|
|
955
1125
|
return /* @__PURE__ */ jsx(Element, {
|
|
@@ -984,6 +1154,9 @@ function renderIcon(name, nodes, mirror, { label, className, ...props }) {
|
|
|
984
1154
|
function AddIcon(props) {
|
|
985
1155
|
return renderIcon("add", [["path", { d: "M5 12h14" }], ["path", { d: "M12 5v14" }]], false, props);
|
|
986
1156
|
}
|
|
1157
|
+
function ArrowIcon(props) {
|
|
1158
|
+
return renderIcon("arrow", [["path", { d: "M13 5H19V11" }], ["path", { d: "M19 5L5 19" }]], false, props);
|
|
1159
|
+
}
|
|
987
1160
|
function CheckIcon(props) {
|
|
988
1161
|
return renderIcon("check", [["path", { d: "M20 6 9 17l-5-5" }]], false, props);
|
|
989
1162
|
}
|
|
@@ -1018,6 +1191,24 @@ function DownloadIcon(props) {
|
|
|
1018
1191
|
["path", { d: "m7 10 5 5 5-5" }]
|
|
1019
1192
|
], false, props);
|
|
1020
1193
|
}
|
|
1194
|
+
function DuplicateIcon(props) {
|
|
1195
|
+
return renderIcon("duplicate", [["rect", {
|
|
1196
|
+
width: "14",
|
|
1197
|
+
height: "14",
|
|
1198
|
+
x: "8",
|
|
1199
|
+
y: "8",
|
|
1200
|
+
rx: "2",
|
|
1201
|
+
ry: "2"
|
|
1202
|
+
}], ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" }]], false, props);
|
|
1203
|
+
}
|
|
1204
|
+
function EllipseIcon(props) {
|
|
1205
|
+
return renderIcon("ellipse", [["ellipse", {
|
|
1206
|
+
cx: "12",
|
|
1207
|
+
cy: "12",
|
|
1208
|
+
rx: "10",
|
|
1209
|
+
ry: "6"
|
|
1210
|
+
}]], false, props);
|
|
1211
|
+
}
|
|
1021
1212
|
function FadeInIcon(props) {
|
|
1022
1213
|
return renderIcon("fade-in", [
|
|
1023
1214
|
["path", { d: "M5 21v-6" }],
|
|
@@ -1060,6 +1251,14 @@ function FlipVerticalIcon(props) {
|
|
|
1060
1251
|
["path", { d: "M7.298 3.712A1 1 0 018 2h8a1 1 0 01.703 1.712l-3.991 3.99a1 1 0 01-1.424.001z" }]
|
|
1061
1252
|
], false, props);
|
|
1062
1253
|
}
|
|
1254
|
+
function HiddenIcon(props) {
|
|
1255
|
+
return renderIcon("hidden", [
|
|
1256
|
+
["path", { d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49" }],
|
|
1257
|
+
["path", { d: "M14.084 14.158a3 3 0 0 1-4.242-4.242" }],
|
|
1258
|
+
["path", { d: "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143" }],
|
|
1259
|
+
["path", { d: "m2 2 20 20" }]
|
|
1260
|
+
], false, props);
|
|
1261
|
+
}
|
|
1063
1262
|
function HighlighterIcon(props) {
|
|
1064
1263
|
return renderIcon("highlighter", [["path", { d: "m9 11-6 6v3h9l3-3" }], ["path", { d: "m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4" }]], false, props);
|
|
1065
1264
|
}
|
|
@@ -1074,6 +1273,13 @@ function InfoIcon(props) {
|
|
|
1074
1273
|
["path", { d: "M12 8h.01" }]
|
|
1075
1274
|
], false, props);
|
|
1076
1275
|
}
|
|
1276
|
+
function LayersIcon(props) {
|
|
1277
|
+
return renderIcon("layers", [
|
|
1278
|
+
["path", { d: "M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" }],
|
|
1279
|
+
["path", { d: "M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" }],
|
|
1280
|
+
["path", { d: "M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" }]
|
|
1281
|
+
], false, props);
|
|
1282
|
+
}
|
|
1077
1283
|
function LoopIcon(props) {
|
|
1078
1284
|
return renderIcon("loop", [
|
|
1079
1285
|
["path", { d: "m17 2 4 4-4 4" }],
|
|
@@ -1108,6 +1314,12 @@ function MoreIcon(props) {
|
|
|
1108
1314
|
}]
|
|
1109
1315
|
], false, props);
|
|
1110
1316
|
}
|
|
1317
|
+
function MoveDownIcon(props) {
|
|
1318
|
+
return renderIcon("move-down", [["path", { d: "M12 5v14" }], ["path", { d: "m19 12-7 7-7-7" }]], false, props);
|
|
1319
|
+
}
|
|
1320
|
+
function MoveUpIcon(props) {
|
|
1321
|
+
return renderIcon("move-up", [["path", { d: "m5 12 7-7 7 7" }], ["path", { d: "M12 19V5" }]], false, props);
|
|
1322
|
+
}
|
|
1111
1323
|
function MutedIcon(props) {
|
|
1112
1324
|
return renderIcon("muted", [
|
|
1113
1325
|
["path", { d: "M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z" }],
|
|
@@ -1118,6 +1330,14 @@ function MutedIcon(props) {
|
|
|
1118
1330
|
function OpenIcon(props) {
|
|
1119
1331
|
return renderIcon("open", [["path", { d: "m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2" }]], false, props);
|
|
1120
1332
|
}
|
|
1333
|
+
function PageAddIcon(props) {
|
|
1334
|
+
return renderIcon("page-add", [
|
|
1335
|
+
["path", { d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" }],
|
|
1336
|
+
["path", { d: "M14 2v5a1 1 0 0 0 1 1h5" }],
|
|
1337
|
+
["path", { d: "M9 15h6" }],
|
|
1338
|
+
["path", { d: "M12 18v-6" }]
|
|
1339
|
+
], false, props);
|
|
1340
|
+
}
|
|
1121
1341
|
function PageGridIcon(props) {
|
|
1122
1342
|
return renderIcon("page-grid", [
|
|
1123
1343
|
["path", { d: "M12 3v18" }],
|
|
@@ -1163,6 +1383,29 @@ function PenIcon(props) {
|
|
|
1163
1383
|
function PlayIcon(props) {
|
|
1164
1384
|
return renderIcon("play", [["path", { d: "M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z" }]], false, props);
|
|
1165
1385
|
}
|
|
1386
|
+
function RectangleIcon(props) {
|
|
1387
|
+
return renderIcon("rectangle", [["rect", {
|
|
1388
|
+
width: "20",
|
|
1389
|
+
height: "12",
|
|
1390
|
+
x: "2",
|
|
1391
|
+
y: "6",
|
|
1392
|
+
rx: "2"
|
|
1393
|
+
}]], false, props);
|
|
1394
|
+
}
|
|
1395
|
+
function RedactIcon(props) {
|
|
1396
|
+
return renderIcon("redact", [
|
|
1397
|
+
["rect", {
|
|
1398
|
+
width: "20",
|
|
1399
|
+
height: "12",
|
|
1400
|
+
x: "2",
|
|
1401
|
+
y: "6",
|
|
1402
|
+
rx: "2"
|
|
1403
|
+
}],
|
|
1404
|
+
["path", { d: "M12 12h.01" }],
|
|
1405
|
+
["path", { d: "M17 12h.01" }],
|
|
1406
|
+
["path", { d: "M7 12h.01" }]
|
|
1407
|
+
], false, props);
|
|
1408
|
+
}
|
|
1166
1409
|
function RedoIcon(props) {
|
|
1167
1410
|
return renderIcon("redo", [["path", { d: "m15 14 5-5-5-5" }], ["path", { d: "M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" }]], true, props);
|
|
1168
1411
|
}
|
|
@@ -1224,6 +1467,13 @@ function StopIcon(props) {
|
|
|
1224
1467
|
rx: "2"
|
|
1225
1468
|
}]], false, props);
|
|
1226
1469
|
}
|
|
1470
|
+
function TextIcon(props) {
|
|
1471
|
+
return renderIcon("text", [
|
|
1472
|
+
["path", { d: "M12 4v16" }],
|
|
1473
|
+
["path", { d: "M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2" }],
|
|
1474
|
+
["path", { d: "M9 20h6" }]
|
|
1475
|
+
], false, props);
|
|
1476
|
+
}
|
|
1227
1477
|
function TrimEndIcon(props) {
|
|
1228
1478
|
return renderIcon("trim-end", [
|
|
1229
1479
|
["path", { d: "m9 6-6 6 6 6" }],
|
|
@@ -1248,6 +1498,13 @@ function UploadIcon(props) {
|
|
|
1248
1498
|
["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }]
|
|
1249
1499
|
], false, props);
|
|
1250
1500
|
}
|
|
1501
|
+
function VisibleIcon(props) {
|
|
1502
|
+
return renderIcon("visible", [["path", { d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" }], ["circle", {
|
|
1503
|
+
cx: "12",
|
|
1504
|
+
cy: "12",
|
|
1505
|
+
r: "3"
|
|
1506
|
+
}]], false, props);
|
|
1507
|
+
}
|
|
1251
1508
|
function VolumeIcon(props) {
|
|
1252
1509
|
return renderIcon("volume", [
|
|
1253
1510
|
["path", { d: "M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z" }],
|
|
@@ -1348,13 +1605,6 @@ function ThemeProvider(props) {
|
|
|
1348
1605
|
}), children]
|
|
1349
1606
|
});
|
|
1350
1607
|
}
|
|
1351
|
-
|
|
1352
|
-
var subscribe = () => () => void 0;
|
|
1353
|
-
var onClient = () => platformOf(globalThis.navigator);
|
|
1354
|
-
var onServer = () => "other";
|
|
1355
|
-
function usePlatform() {
|
|
1356
|
-
return useSyncExternalStore(subscribe, onClient, onServer);
|
|
1357
|
-
}
|
|
1358
|
-
export { AddIcon, AnnouncerProvider, Button, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CloseIcon, CropIcon, DeleteIcon, Dialog, DownloadIcon, FadeInIcon, FadeOutIcon, Field, FileDropZone, FitIcon, FlipHorizontalIcon, FlipVerticalIcon, HighlighterIcon, IconButton, InfoIcon, LoopIcon, MenuIcon, MoreIcon, MutedIcon, NumberField, OpenIcon, PageGridIcon, PageSingleIcon, PanIcon, PauseIcon, PenIcon, PlayIcon, ProgressBar, RedoIcon, RemoveIcon, RotateLeftIcon, RotateRightIcon, SearchIcon, SegmentedControl, SelectIcon, SkipBackIcon, SkipForwardIcon, Slider, SnapIcon, Spinner, SplitIcon, StopIcon, ThemeProvider, ToggleButton, Toolbar, ToolbarGroup, ToolbarSeparator, TrimEndIcon, TrimStartIcon, UiMessagesProvider, UndoIcon, UploadIcon, VisuallyHidden, VolumeIcon, WarningIcon, ZoomInIcon, ZoomOutIcon, uiMessages, useAnnounce, usePlatform, useUiMessages };
|
|
1608
|
+
export { AddIcon, AnnouncerProvider, ArrowIcon, Button, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CloseIcon, CropIcon, DeleteIcon, Dialog, DownloadIcon, DuplicateIcon, EllipseIcon, FadeInIcon, FadeOutIcon, Field, FileDropZone, FitIcon, FlipHorizontalIcon, FlipVerticalIcon, HiddenIcon, HighlighterIcon, IconButton, InfoIcon, LayersIcon, LoopIcon, MenuIcon, MoreIcon, MoveDownIcon, MoveUpIcon, MutedIcon, NumberField, OpenIcon, PageAddIcon, PageGridIcon, PageSingleIcon, PanIcon, PauseIcon, PenIcon, PlayIcon, ProgressBar, RectangleIcon, RedactIcon, RedoIcon, RemoveIcon, RotateLeftIcon, RotateRightIcon, SearchIcon, SegmentedControl, SelectIcon, SkipBackIcon, SkipForwardIcon, Slider, SnapIcon, Spinner, SplitIcon, StopIcon, TextField, TextIcon, ThemeProvider, ToggleButton, Toolbar, ToolbarGroup, ToolbarSeparator, Tooltip, TrimEndIcon, TrimStartIcon, UiMessagesProvider, UndoIcon, UploadIcon, VisibleIcon, VisuallyHidden, VolumeIcon, WarningIcon, ZoomInIcon, ZoomOutIcon, uiMessages, useAnnounce, usePlatform, useUiMessages };
|
|
1359
1609
|
|
|
1360
1610
|
//# sourceMappingURL=react.js.map
|