@hussmartinez/ui 0.9.0 → 0.10.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 +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +134 -1
- package/dist/react.js +292 -62
- package/dist/react.js.map +1 -1
- package/dist/shared/{pair-pt-vUVwu.js → pair-MeX064R6.js} +2 -1
- package/dist/shared/pair-MeX064R6.js.map +1 -0
- package/dist/styles.css +73 -0
- package/dist/ui.d.ts +134 -1
- package/package.json +1 -1
- package/dist/shared/pair-pt-vUVwu.js.map +0 -1
package/dist/react.d.ts
CHANGED
|
@@ -626,7 +626,7 @@ export declare type IconComponent = (props: IconProps) => ReactElement;
|
|
|
626
626
|
*
|
|
627
627
|
* @public
|
|
628
628
|
*/
|
|
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";
|
|
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" | "image" | "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";
|
|
630
630
|
|
|
631
631
|
/**
|
|
632
632
|
* Props of every icon. SVG attributes are passed through.
|
|
@@ -642,6 +642,13 @@ export declare interface IconProps extends Omit<SVGProps<SVGSVGElement>, "childr
|
|
|
642
642
|
readonly label?: string | undefined;
|
|
643
643
|
}
|
|
644
644
|
|
|
645
|
+
/**
|
|
646
|
+
* The `image` icon: Lucide's `image`.
|
|
647
|
+
*
|
|
648
|
+
* @public
|
|
649
|
+
*/
|
|
650
|
+
export declare function ImageIcon(props: IconProps): ReactElement;
|
|
651
|
+
|
|
645
652
|
/**
|
|
646
653
|
* The `info` icon: Lucide's `info`.
|
|
647
654
|
*
|
|
@@ -902,6 +909,131 @@ export declare function RedoIcon(props: IconProps): ReactElement;
|
|
|
902
909
|
*/
|
|
903
910
|
export declare function RemoveIcon(props: IconProps): ReactElement;
|
|
904
911
|
|
|
912
|
+
/**
|
|
913
|
+
* A list whose items the user selects, reorders and removes, with one Tab
|
|
914
|
+
* stop and room for controls in each row (docs/adr/0009). It's a WAI-ARIA
|
|
915
|
+
* grid with one column of rows.
|
|
916
|
+
*
|
|
917
|
+
* - **↑ and ↓** move between rows and select; with Ctrl or ⌘, they move
|
|
918
|
+
* without selecting. **← and →**, Home and End move between a row's
|
|
919
|
+
* cells. Ctrl or ⌘ with Home or End goes to the first or last row.
|
|
920
|
+
* Space or Enter on an item selects it.
|
|
921
|
+
* - **Alt+↑ and Alt+↓** (Option on macOS) move the focused item, through
|
|
922
|
+
* `onMove`. **Delete and Backspace** remove it, through `onRemove`.
|
|
923
|
+
* - **You own the order.** The list calls `onMove` and `onRemove`, and you
|
|
924
|
+
* render the result. Focus stays with a moved item, and goes to the next
|
|
925
|
+
* one after a removal.
|
|
926
|
+
* - **Offer buttons too.** The keys are an addition: also render buttons
|
|
927
|
+
* that move the selected item, for touch and for people who don't know
|
|
928
|
+
* the keys, and name the keys on them with `aria-keyshortcuts`.
|
|
929
|
+
*
|
|
930
|
+
* @example
|
|
931
|
+
* ```tsx
|
|
932
|
+
* <ReorderableList
|
|
933
|
+
* label={t("layers.label")}
|
|
934
|
+
* selectedId={selected}
|
|
935
|
+
* onSelectedChange={setSelected}
|
|
936
|
+
* onMove={(id, toIndex) => session.moveLayer(id, toIndex)}
|
|
937
|
+
* onRemove={(id) => session.deleteLayer(id)}
|
|
938
|
+
* >
|
|
939
|
+
* {layers.map((layer) => (
|
|
940
|
+
* <ReorderableListItem
|
|
941
|
+
* key={layer.id}
|
|
942
|
+
* id={layer.id}
|
|
943
|
+
* label={layer.name}
|
|
944
|
+
* controls={[
|
|
945
|
+
* <ToggleButton
|
|
946
|
+
* key="visible"
|
|
947
|
+
* variant="quiet"
|
|
948
|
+
* label={t("layers.visible")}
|
|
949
|
+
* icon={<VisibleIcon />}
|
|
950
|
+
* pressed={layer.visible}
|
|
951
|
+
* onPressedChange={(visible) => session.showLayer(layer.id, visible)}
|
|
952
|
+
* />,
|
|
953
|
+
* ]}
|
|
954
|
+
* >
|
|
955
|
+
* {layer.name}
|
|
956
|
+
* </ReorderableListItem>
|
|
957
|
+
* ))}
|
|
958
|
+
* </ReorderableList>
|
|
959
|
+
* ```
|
|
960
|
+
*
|
|
961
|
+
* @public
|
|
962
|
+
*/
|
|
963
|
+
export declare const ReorderableList: ForwardRefExoticComponent<ReorderableListProps & RefAttributes<HTMLDivElement>>;
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* An item of a {@link ReorderableList}: a row with the item's content, and a
|
|
967
|
+
* cell for each of its `controls`.
|
|
968
|
+
*
|
|
969
|
+
* @public
|
|
970
|
+
*/
|
|
971
|
+
export declare const ReorderableListItem: ForwardRefExoticComponent<ReorderableListItemProps & RefAttributes<HTMLDivElement>>;
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* The parts of a reorderable list's item that `classNames` can target.
|
|
975
|
+
*
|
|
976
|
+
* @public
|
|
977
|
+
*/
|
|
978
|
+
export declare type ReorderableListItemPart = "root" | "item" | "control";
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* Props of {@link ReorderableListItem}.
|
|
982
|
+
*
|
|
983
|
+
* @public
|
|
984
|
+
*/
|
|
985
|
+
export declare interface ReorderableListItemProps extends Omit<HTMLAttributes<HTMLDivElement>, "className" | "role" | "id">, StyleProps<ReorderableListItemPart> {
|
|
986
|
+
/** Identifies the item in `selectedId`, `onMove` and `onRemove`. Unique in the list. */
|
|
987
|
+
readonly id: string;
|
|
988
|
+
/**
|
|
989
|
+
* The item's accessible name, such as a layer's name. Start it with the
|
|
990
|
+
* text the item shows, if it shows any.
|
|
991
|
+
*/
|
|
992
|
+
readonly label: string;
|
|
993
|
+
/**
|
|
994
|
+
* The item's controls, such as a visibility toggle: one focusable control
|
|
995
|
+
* each, in its own cell. A control that can't act should stay focusable,
|
|
996
|
+
* as `focusableWhenDisabled` makes a button.
|
|
997
|
+
*/
|
|
998
|
+
readonly controls?: readonly ReactNode[] | undefined;
|
|
999
|
+
/** What the item shows. */
|
|
1000
|
+
readonly children?: ReactNode;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* Props of {@link ReorderableList}.
|
|
1005
|
+
*
|
|
1006
|
+
* @public
|
|
1007
|
+
*/
|
|
1008
|
+
export declare interface ReorderableListProps extends Omit<HTMLAttributes<HTMLDivElement>, "className" | "role">, StyleProps<"root"> {
|
|
1009
|
+
/** The list's accessible name, such as "Layers". Required. */
|
|
1010
|
+
readonly label: string;
|
|
1011
|
+
/** The selected item's `id`, or `null` for none. */
|
|
1012
|
+
readonly selectedId?: string | null | undefined;
|
|
1013
|
+
/** Called with an item's `id` when the user selects it. */
|
|
1014
|
+
readonly onSelectedChange?: ((id: string) => void) | undefined;
|
|
1015
|
+
/**
|
|
1016
|
+
* Called when the user moves an item with Alt+↑ or Alt+↓ (Option on
|
|
1017
|
+
* macOS), with its `id` and the position it should have, counted from 0.
|
|
1018
|
+
* Render the items in the new order, or leave them when the move isn't
|
|
1019
|
+
* allowed. Without it, the list doesn't reorder.
|
|
1020
|
+
*/
|
|
1021
|
+
readonly onMove?: ((id: string, toIndex: number) => void) | undefined;
|
|
1022
|
+
/**
|
|
1023
|
+
* Called when the user presses Delete or Backspace on an item, with its
|
|
1024
|
+
* `id`. Render the items without it. Without it, the keys do nothing.
|
|
1025
|
+
*/
|
|
1026
|
+
readonly onRemove?: ((id: string) => void) | undefined;
|
|
1027
|
+
/**
|
|
1028
|
+
* Whether the list announces a move to screen readers, through the
|
|
1029
|
+
* closest `AnnouncerProvider`. Defaults to `true`; pass `false` when you
|
|
1030
|
+
* announce it in your own words.
|
|
1031
|
+
*/
|
|
1032
|
+
readonly announceMoves?: boolean | undefined;
|
|
1033
|
+
/** The items: {@link ReorderableListItem} elements, in the order shown. */
|
|
1034
|
+
readonly children?: ReactNode;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
905
1037
|
/**
|
|
906
1038
|
* The `rotate-left` icon: Lucide's `rotate-ccw`.
|
|
907
1039
|
*
|
|
@@ -1599,6 +1731,7 @@ export declare const uiMessages: {
|
|
|
1599
1731
|
readonly "fileDropZone.hint": "or drop it here";
|
|
1600
1732
|
readonly "fileDropZone.hintMultiple": "or drop them here";
|
|
1601
1733
|
readonly "progress.label": "Progress";
|
|
1734
|
+
readonly "reorderableList.moved": "{label} moved to position {position} of {count}";
|
|
1602
1735
|
readonly "spinner.label": "Loading";
|
|
1603
1736
|
readonly "errors.INVALID_THEME_TOKEN": "The theme setting {token} has a value that can't be used.";
|
|
1604
1737
|
readonly "errors.INVALID_THEME_SELECTOR": "The theme can't be applied to the selector {selector}.";
|
package/dist/react.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { a as uiMessages, i as warnInDevelopment, n as cssWriterOf, o as UiError, t as isThemePair } from "./shared/pair-
|
|
2
|
+
import { a as uiMessages, i as warnInDevelopment, n as cssWriterOf, o as UiError, t as isThemePair } from "./shared/pair-MeX064R6.js";
|
|
3
3
|
import { createMessages, platformOf, sdkCoreMessages } from "@hussmartinez/sdk-core";
|
|
4
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";
|
|
@@ -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.10.0";
|
|
13
13
|
}
|
|
14
14
|
function checkSingleCopy() {
|
|
15
15
|
if (checked || !(typeof process !== "undefined" && process.env.NODE_ENV !== "production")) return;
|
|
@@ -838,6 +838,274 @@ var ProgressBar = /* @__PURE__ */ forwardRef(function ProgressBar({ value, max =
|
|
|
838
838
|
"data-hm-unstyled": unstyledAttribute(unstyled)
|
|
839
839
|
});
|
|
840
840
|
});
|
|
841
|
+
// src/components/toolbar/roving-focus.ts
|
|
842
|
+
var FOCUSABLE = "button:not(:disabled), a[href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex^=\"-\"]):not(button, a, input, select, textarea), [data-hm-roving]:not(:disabled)";
|
|
843
|
+
function items(toolbar) {
|
|
844
|
+
return [...toolbar.querySelectorAll(FOCUSABLE)].filter((element) => !element.closest("[hidden], [inert]") && element.getClientRects().length > 0);
|
|
845
|
+
}
|
|
846
|
+
function syncTabStop$1(toolbar, active) {
|
|
847
|
+
const list = items(toolbar);
|
|
848
|
+
const current = list.find((item) => item === active) ?? list.find((item) => item.tabIndex === 0 && item.dataset["hmTabStop"] !== void 0) ?? list[0];
|
|
849
|
+
for (const item of list) {
|
|
850
|
+
const isStop = item === current;
|
|
851
|
+
item.dataset["hmRoving"] = "";
|
|
852
|
+
item.tabIndex = isStop ? 0 : -1;
|
|
853
|
+
if (isStop) item.dataset["hmTabStop"] = "";
|
|
854
|
+
else delete item.dataset["hmTabStop"];
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
function editsText$1(target) {
|
|
858
|
+
if (!(target instanceof HTMLElement)) return false;
|
|
859
|
+
return target.isContentEditable || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement || target instanceof HTMLInputElement && ![
|
|
860
|
+
"button",
|
|
861
|
+
"checkbox",
|
|
862
|
+
"radio",
|
|
863
|
+
"reset",
|
|
864
|
+
"submit"
|
|
865
|
+
].includes(target.type);
|
|
866
|
+
}
|
|
867
|
+
function moveFocus(toolbar, event, orientation) {
|
|
868
|
+
if (editsText$1(event.target)) return false;
|
|
869
|
+
const rtl = getComputedStyle(toolbar).direction === "rtl";
|
|
870
|
+
const next = orientation === "vertical" ? "ArrowDown" : rtl ? "ArrowLeft" : "ArrowRight";
|
|
871
|
+
const previous = orientation === "vertical" ? "ArrowUp" : rtl ? "ArrowRight" : "ArrowLeft";
|
|
872
|
+
const list = items(toolbar);
|
|
873
|
+
if (list.length === 0) return false;
|
|
874
|
+
const index = list.indexOf(event.target);
|
|
875
|
+
let target;
|
|
876
|
+
switch (event.key) {
|
|
877
|
+
case next:
|
|
878
|
+
target = list[(index + 1) % list.length];
|
|
879
|
+
break;
|
|
880
|
+
case previous:
|
|
881
|
+
target = list[(index - 1 + list.length) % list.length];
|
|
882
|
+
break;
|
|
883
|
+
case "Home":
|
|
884
|
+
target = list[0];
|
|
885
|
+
break;
|
|
886
|
+
case "End":
|
|
887
|
+
target = list[list.length - 1];
|
|
888
|
+
break;
|
|
889
|
+
default: return false;
|
|
890
|
+
}
|
|
891
|
+
if (target) {
|
|
892
|
+
syncTabStop$1(toolbar, target);
|
|
893
|
+
target.focus();
|
|
894
|
+
}
|
|
895
|
+
return true;
|
|
896
|
+
}
|
|
897
|
+
// src/components/reorderable-list/ReorderableList.tsx
|
|
898
|
+
var ReorderableListContext = /* @__PURE__ */ createContext(void 0);
|
|
899
|
+
function editsText(target) {
|
|
900
|
+
return target instanceof HTMLElement && (target.isContentEditable || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement || target instanceof HTMLInputElement && ![
|
|
901
|
+
"button",
|
|
902
|
+
"checkbox",
|
|
903
|
+
"radio",
|
|
904
|
+
"reset",
|
|
905
|
+
"submit"
|
|
906
|
+
].includes(target.type));
|
|
907
|
+
}
|
|
908
|
+
function rowsOf(list) {
|
|
909
|
+
return [...list.children].filter((child) => child instanceof HTMLElement && child.getAttribute("role") === "row");
|
|
910
|
+
}
|
|
911
|
+
function cellsOf(row) {
|
|
912
|
+
const targets = [];
|
|
913
|
+
for (const cell of row.children) {
|
|
914
|
+
if (!(cell instanceof HTMLElement)) continue;
|
|
915
|
+
if (cell.dataset["hmCell"] === "item") targets.push(cell);
|
|
916
|
+
else {
|
|
917
|
+
const control = items(cell)[0];
|
|
918
|
+
if (control) targets.push(control);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
return targets;
|
|
922
|
+
}
|
|
923
|
+
var idOf = (row) => row?.dataset["hmId"] ?? "";
|
|
924
|
+
var orderOf = (rows) => JSON.stringify(rows.map(idOf));
|
|
925
|
+
var selectedRow = (rows) => rows.find((row) => row.getAttribute("aria-selected") === "true");
|
|
926
|
+
function syncTabStop(list, active) {
|
|
927
|
+
const rows = rowsOf(list);
|
|
928
|
+
const all = rows.flatMap(cellsOf);
|
|
929
|
+
const current = all.find((cell) => cell === active) ?? all.find((cell) => cell.dataset["hmTabStop"] !== void 0) ?? cellsOf(selectedRow(rows) ?? rows[0] ?? list)[0];
|
|
930
|
+
for (const cell of all) {
|
|
931
|
+
const isStop = cell === current;
|
|
932
|
+
cell.dataset["hmRoving"] = "";
|
|
933
|
+
cell.tabIndex = isStop ? 0 : -1;
|
|
934
|
+
if (isStop) cell.dataset["hmTabStop"] = "";
|
|
935
|
+
else delete cell.dataset["hmTabStop"];
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
var ReorderableList = /* @__PURE__ */ forwardRef(function ReorderableList({ label, selectedId, onSelectedChange, onMove, onRemove, announceMoves = true, className, classNames, unstyled, onKeyDown, onClick, onFocus, onBlur, children, ...props }, ref) {
|
|
939
|
+
const list = useRef(null);
|
|
940
|
+
const pending = useRef(void 0);
|
|
941
|
+
const lastSelected = useRef(selectedId);
|
|
942
|
+
const announce = useAnnounce();
|
|
943
|
+
const messages = useUiMessages();
|
|
944
|
+
useEffect(() => {
|
|
945
|
+
const element = list.current;
|
|
946
|
+
if (!element) return;
|
|
947
|
+
const change = pending.current;
|
|
948
|
+
const rows = rowsOf(element);
|
|
949
|
+
if (change && orderOf(rows) !== change.order) {
|
|
950
|
+
pending.current = void 0;
|
|
951
|
+
const index = change.kind === "move" ? rows.findIndex((row) => idOf(row) === change.id) : Math.min(change.index, rows.length - 1);
|
|
952
|
+
const row = rows[index];
|
|
953
|
+
const active = document.activeElement;
|
|
954
|
+
const free = !active || active === document.body || element.contains(active);
|
|
955
|
+
if (row && free) {
|
|
956
|
+
const cells = cellsOf(row);
|
|
957
|
+
const target = cells[change.cell] ?? cells[0];
|
|
958
|
+
syncTabStop(element, target);
|
|
959
|
+
target?.focus();
|
|
960
|
+
}
|
|
961
|
+
if (row && change.kind === "move" && announceMoves) announce(messages.t("reorderableList.moved", {
|
|
962
|
+
label: cellsOf(row)[0]?.getAttribute("aria-label") ?? "",
|
|
963
|
+
position: index + 1,
|
|
964
|
+
count: rows.length
|
|
965
|
+
}));
|
|
966
|
+
}
|
|
967
|
+
const inside = element.contains(document.activeElement);
|
|
968
|
+
const reselected = lastSelected.current !== selectedId;
|
|
969
|
+
lastSelected.current = selectedId;
|
|
970
|
+
syncTabStop(element, inside ? document.activeElement : reselected ? cellsOf(selectedRow(rowsOf(element)) ?? element)[0] : null);
|
|
971
|
+
});
|
|
972
|
+
const select = (id) => {
|
|
973
|
+
if (id !== "" && id !== selectedId) onSelectedChange?.(id);
|
|
974
|
+
};
|
|
975
|
+
const focusCell = (row, cell) => {
|
|
976
|
+
if (!row || !list.current) return;
|
|
977
|
+
const cells = cellsOf(row);
|
|
978
|
+
const target = cells[cell] ?? cells[0];
|
|
979
|
+
syncTabStop(list.current, target);
|
|
980
|
+
target?.focus();
|
|
981
|
+
};
|
|
982
|
+
const handleKeyDown = (event) => {
|
|
983
|
+
onKeyDown?.(event);
|
|
984
|
+
pending.current = void 0;
|
|
985
|
+
if (event.defaultPrevented || event.nativeEvent.isComposing || event.shiftKey || editsText(event.target)) return;
|
|
986
|
+
const element = event.currentTarget;
|
|
987
|
+
const rows = rowsOf(element);
|
|
988
|
+
const index = rows.findIndex((row) => row.contains(event.target));
|
|
989
|
+
const row = rows[index];
|
|
990
|
+
if (!row) return;
|
|
991
|
+
const cells = cellsOf(row);
|
|
992
|
+
const cell = cells.indexOf(event.target);
|
|
993
|
+
if (cell === -1) return;
|
|
994
|
+
const quiet = event.ctrlKey || event.metaKey;
|
|
995
|
+
const vertical = event.key === "ArrowUp" ? -1 : event.key === "ArrowDown" ? 1 : 0;
|
|
996
|
+
if (event.altKey) {
|
|
997
|
+
if (vertical !== 0 && !quiet && onMove) {
|
|
998
|
+
event.preventDefault();
|
|
999
|
+
const toIndex = index + vertical;
|
|
1000
|
+
if (toIndex >= 0 && toIndex < rows.length) {
|
|
1001
|
+
pending.current = {
|
|
1002
|
+
kind: "move",
|
|
1003
|
+
id: idOf(row),
|
|
1004
|
+
index,
|
|
1005
|
+
cell,
|
|
1006
|
+
order: orderOf(rows)
|
|
1007
|
+
};
|
|
1008
|
+
onMove(idOf(row), toIndex);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
1013
|
+
if (vertical !== 0) {
|
|
1014
|
+
event.preventDefault();
|
|
1015
|
+
const next = rows[index + vertical];
|
|
1016
|
+
if (next) {
|
|
1017
|
+
focusCell(next, cell);
|
|
1018
|
+
if (!quiet) select(idOf(next));
|
|
1019
|
+
}
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
if (event.key === "Home" || event.key === "End") {
|
|
1023
|
+
event.preventDefault();
|
|
1024
|
+
if (quiet) focusCell(event.key === "Home" ? rows[0] : rows[rows.length - 1], cell);
|
|
1025
|
+
else focusCell(row, event.key === "Home" ? 0 : cells.length - 1);
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
if (quiet) return;
|
|
1029
|
+
if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
|
|
1030
|
+
event.preventDefault();
|
|
1031
|
+
const rtl = getComputedStyle(element).direction === "rtl";
|
|
1032
|
+
const step = event.key === "ArrowRight" === rtl ? -1 : 1;
|
|
1033
|
+
if (cells[cell + step]) focusCell(row, cell + step);
|
|
1034
|
+
} else if ((event.key === "Delete" || event.key === "Backspace") && onRemove) {
|
|
1035
|
+
event.preventDefault();
|
|
1036
|
+
pending.current = {
|
|
1037
|
+
kind: "remove",
|
|
1038
|
+
id: idOf(row),
|
|
1039
|
+
index,
|
|
1040
|
+
cell,
|
|
1041
|
+
order: orderOf(rows)
|
|
1042
|
+
};
|
|
1043
|
+
onRemove(idOf(row));
|
|
1044
|
+
} else if ((event.key === " " || event.key === "Enter") && cell === 0) {
|
|
1045
|
+
event.preventDefault();
|
|
1046
|
+
select(idOf(row));
|
|
1047
|
+
}
|
|
1048
|
+
};
|
|
1049
|
+
const handleClick = (event) => {
|
|
1050
|
+
onClick?.(event);
|
|
1051
|
+
const target = event.target;
|
|
1052
|
+
const row = rowsOf(event.currentTarget).find((candidate) => candidate.contains(target));
|
|
1053
|
+
if (row && !event.defaultPrevented && target.closest("[data-hm-cell=\"control\"]") === null) select(idOf(row));
|
|
1054
|
+
};
|
|
1055
|
+
const handleFocus = (event) => {
|
|
1056
|
+
onFocus?.(event);
|
|
1057
|
+
syncTabStop(event.currentTarget, event.target);
|
|
1058
|
+
};
|
|
1059
|
+
const handleBlur = (event) => {
|
|
1060
|
+
onBlur?.(event);
|
|
1061
|
+
if (event.relatedTarget && !event.currentTarget.contains(event.relatedTarget)) pending.current = void 0;
|
|
1062
|
+
};
|
|
1063
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1064
|
+
...props,
|
|
1065
|
+
ref: (node) => {
|
|
1066
|
+
list.current = node;
|
|
1067
|
+
if (typeof ref === "function") ref(node);
|
|
1068
|
+
else if (ref) ref.current = node;
|
|
1069
|
+
},
|
|
1070
|
+
role: "grid",
|
|
1071
|
+
"aria-label": label,
|
|
1072
|
+
className: cx("hm-reorderable-list", classNames?.root, className),
|
|
1073
|
+
"data-hm-unstyled": unstyledAttribute(unstyled),
|
|
1074
|
+
onKeyDown: handleKeyDown,
|
|
1075
|
+
onClick: handleClick,
|
|
1076
|
+
onFocus: handleFocus,
|
|
1077
|
+
onBlur: handleBlur,
|
|
1078
|
+
children: /* @__PURE__ */ jsx(ReorderableListContext.Provider, {
|
|
1079
|
+
value: { selectedId },
|
|
1080
|
+
children
|
|
1081
|
+
})
|
|
1082
|
+
});
|
|
1083
|
+
});
|
|
1084
|
+
var ReorderableListItem = /* @__PURE__ */ forwardRef(function ReorderableListItem({ id, label, controls, className, classNames, unstyled, children, ...props }, ref) {
|
|
1085
|
+
const selected = useContext(ReorderableListContext)?.selectedId === id;
|
|
1086
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1087
|
+
...props,
|
|
1088
|
+
ref,
|
|
1089
|
+
role: "row",
|
|
1090
|
+
"aria-selected": selected,
|
|
1091
|
+
"data-hm-id": id,
|
|
1092
|
+
className: cx("hm-reorderable-list-row", classNames?.root, className),
|
|
1093
|
+
"data-hm-unstyled": unstyledAttribute(unstyled),
|
|
1094
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1095
|
+
role: "gridcell",
|
|
1096
|
+
"aria-label": label,
|
|
1097
|
+
tabIndex: selected ? 0 : -1,
|
|
1098
|
+
"data-hm-cell": "item",
|
|
1099
|
+
className: cx("hm-reorderable-list-item", classNames?.item),
|
|
1100
|
+
children
|
|
1101
|
+
}), controls?.map((control, index) => /* @__PURE__ */ jsx("div", {
|
|
1102
|
+
role: "gridcell",
|
|
1103
|
+
"data-hm-cell": "control",
|
|
1104
|
+
className: cx("hm-reorderable-list-control", classNames?.control),
|
|
1105
|
+
children: control
|
|
1106
|
+
}, index))]
|
|
1107
|
+
});
|
|
1108
|
+
});
|
|
841
1109
|
// src/components/toolbar/toolbar-context.ts
|
|
842
1110
|
var ToolbarContext = /* @__PURE__ */ createContext(void 0);
|
|
843
1111
|
function useToolbar() {
|
|
@@ -1041,62 +1309,6 @@ var ToggleButton = /* @__PURE__ */ forwardRef(function ToggleButton({ pressed: c
|
|
|
1041
1309
|
onClick: handleClick
|
|
1042
1310
|
});
|
|
1043
1311
|
});
|
|
1044
|
-
// src/components/toolbar/roving-focus.ts
|
|
1045
|
-
var FOCUSABLE = "button:not(:disabled), a[href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex^=\"-\"]):not(button, a, input, select, textarea), [data-hm-roving]:not(:disabled)";
|
|
1046
|
-
function items(toolbar) {
|
|
1047
|
-
return [...toolbar.querySelectorAll(FOCUSABLE)].filter((element) => !element.closest("[hidden], [inert]") && element.getClientRects().length > 0);
|
|
1048
|
-
}
|
|
1049
|
-
function syncTabStop(toolbar, active) {
|
|
1050
|
-
const list = items(toolbar);
|
|
1051
|
-
const current = list.find((item) => item === active) ?? list.find((item) => item.tabIndex === 0 && item.dataset["hmTabStop"] !== void 0) ?? list[0];
|
|
1052
|
-
for (const item of list) {
|
|
1053
|
-
const isStop = item === current;
|
|
1054
|
-
item.dataset["hmRoving"] = "";
|
|
1055
|
-
item.tabIndex = isStop ? 0 : -1;
|
|
1056
|
-
if (isStop) item.dataset["hmTabStop"] = "";
|
|
1057
|
-
else delete item.dataset["hmTabStop"];
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
function editsText(target) {
|
|
1061
|
-
if (!(target instanceof HTMLElement)) return false;
|
|
1062
|
-
return target.isContentEditable || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement || target instanceof HTMLInputElement && ![
|
|
1063
|
-
"button",
|
|
1064
|
-
"checkbox",
|
|
1065
|
-
"radio",
|
|
1066
|
-
"reset",
|
|
1067
|
-
"submit"
|
|
1068
|
-
].includes(target.type);
|
|
1069
|
-
}
|
|
1070
|
-
function moveFocus(toolbar, event, orientation) {
|
|
1071
|
-
if (editsText(event.target)) return false;
|
|
1072
|
-
const rtl = getComputedStyle(toolbar).direction === "rtl";
|
|
1073
|
-
const next = orientation === "vertical" ? "ArrowDown" : rtl ? "ArrowLeft" : "ArrowRight";
|
|
1074
|
-
const previous = orientation === "vertical" ? "ArrowUp" : rtl ? "ArrowRight" : "ArrowLeft";
|
|
1075
|
-
const list = items(toolbar);
|
|
1076
|
-
if (list.length === 0) return false;
|
|
1077
|
-
const index = list.indexOf(event.target);
|
|
1078
|
-
let target;
|
|
1079
|
-
switch (event.key) {
|
|
1080
|
-
case next:
|
|
1081
|
-
target = list[(index + 1) % list.length];
|
|
1082
|
-
break;
|
|
1083
|
-
case previous:
|
|
1084
|
-
target = list[(index - 1 + list.length) % list.length];
|
|
1085
|
-
break;
|
|
1086
|
-
case "Home":
|
|
1087
|
-
target = list[0];
|
|
1088
|
-
break;
|
|
1089
|
-
case "End":
|
|
1090
|
-
target = list[list.length - 1];
|
|
1091
|
-
break;
|
|
1092
|
-
default: return false;
|
|
1093
|
-
}
|
|
1094
|
-
if (target) {
|
|
1095
|
-
syncTabStop(toolbar, target);
|
|
1096
|
-
target.focus();
|
|
1097
|
-
}
|
|
1098
|
-
return true;
|
|
1099
|
-
}
|
|
1100
1312
|
// src/components/toolbar/Toolbar.tsx
|
|
1101
1313
|
function useMergedRef(forwarded) {
|
|
1102
1314
|
const local = useRef(null);
|
|
@@ -1111,8 +1323,8 @@ var Toolbar = /* @__PURE__ */ forwardRef(function Toolbar({ label, orientation =
|
|
|
1111
1323
|
useEffect(() => {
|
|
1112
1324
|
const toolbar = ref.current;
|
|
1113
1325
|
if (!toolbar) return;
|
|
1114
|
-
syncTabStop(toolbar);
|
|
1115
|
-
const observer = new MutationObserver(() => syncTabStop(toolbar, document.activeElement));
|
|
1326
|
+
syncTabStop$1(toolbar);
|
|
1327
|
+
const observer = new MutationObserver(() => syncTabStop$1(toolbar, document.activeElement));
|
|
1116
1328
|
observer.observe(toolbar, {
|
|
1117
1329
|
childList: true,
|
|
1118
1330
|
subtree: true,
|
|
@@ -1127,7 +1339,7 @@ var Toolbar = /* @__PURE__ */ forwardRef(function Toolbar({ label, orientation =
|
|
|
1127
1339
|
};
|
|
1128
1340
|
const handleFocus = (event) => {
|
|
1129
1341
|
onFocus?.(event);
|
|
1130
|
-
if (ref.current && event.target !== ref.current) syncTabStop(ref.current, event.target);
|
|
1342
|
+
if (ref.current && event.target !== ref.current) syncTabStop$1(ref.current, event.target);
|
|
1131
1343
|
};
|
|
1132
1344
|
return /* @__PURE__ */ jsx(ToolbarContext.Provider, {
|
|
1133
1345
|
value: { orientation },
|
|
@@ -1456,6 +1668,24 @@ function HiddenIcon(props) {
|
|
|
1456
1668
|
function HighlighterIcon(props) {
|
|
1457
1669
|
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);
|
|
1458
1670
|
}
|
|
1671
|
+
function ImageIcon(props) {
|
|
1672
|
+
return renderIcon("image", [
|
|
1673
|
+
["rect", {
|
|
1674
|
+
width: "18",
|
|
1675
|
+
height: "18",
|
|
1676
|
+
x: "3",
|
|
1677
|
+
y: "3",
|
|
1678
|
+
rx: "2",
|
|
1679
|
+
ry: "2"
|
|
1680
|
+
}],
|
|
1681
|
+
["circle", {
|
|
1682
|
+
cx: "9",
|
|
1683
|
+
cy: "9",
|
|
1684
|
+
r: "2"
|
|
1685
|
+
}],
|
|
1686
|
+
["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" }]
|
|
1687
|
+
], false, props);
|
|
1688
|
+
}
|
|
1459
1689
|
function InfoIcon(props) {
|
|
1460
1690
|
return renderIcon("info", [
|
|
1461
1691
|
["circle", {
|
|
@@ -1799,6 +2029,6 @@ function ThemeProvider(props) {
|
|
|
1799
2029
|
}), children]
|
|
1800
2030
|
});
|
|
1801
2031
|
}
|
|
1802
|
-
export { AddIcon, AnnouncerProvider, ArrowIcon, Button, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CloseIcon, ColorField, 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, TextArea, TextField, TextIcon, ThemeProvider, ToggleButton, Toolbar, ToolbarGroup, ToolbarSeparator, Tooltip, TrimEndIcon, TrimStartIcon, UiMessagesProvider, UndoIcon, UploadIcon, VisibleIcon, VisuallyHidden, VolumeIcon, WarningIcon, ZoomInIcon, ZoomOutIcon, uiMessages, useAnnounce, usePlatform, useUiMessages };
|
|
2032
|
+
export { AddIcon, AnnouncerProvider, ArrowIcon, Button, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CloseIcon, ColorField, CropIcon, DeleteIcon, Dialog, DownloadIcon, DuplicateIcon, EllipseIcon, FadeInIcon, FadeOutIcon, Field, FileDropZone, FitIcon, FlipHorizontalIcon, FlipVerticalIcon, HiddenIcon, HighlighterIcon, IconButton, ImageIcon, InfoIcon, LayersIcon, LoopIcon, MenuIcon, MoreIcon, MoveDownIcon, MoveUpIcon, MutedIcon, NumberField, OpenIcon, PageAddIcon, PageGridIcon, PageSingleIcon, PanIcon, PauseIcon, PenIcon, PlayIcon, ProgressBar, RectangleIcon, RedactIcon, RedoIcon, RemoveIcon, ReorderableList, ReorderableListItem, RotateLeftIcon, RotateRightIcon, SearchIcon, SegmentedControl, SelectIcon, SkipBackIcon, SkipForwardIcon, Slider, SnapIcon, Spinner, SplitIcon, StopIcon, TextArea, TextField, TextIcon, ThemeProvider, ToggleButton, Toolbar, ToolbarGroup, ToolbarSeparator, Tooltip, TrimEndIcon, TrimStartIcon, UiMessagesProvider, UndoIcon, UploadIcon, VisibleIcon, VisuallyHidden, VolumeIcon, WarningIcon, ZoomInIcon, ZoomOutIcon, uiMessages, useAnnounce, usePlatform, useUiMessages };
|
|
1803
2033
|
|
|
1804
2034
|
//# sourceMappingURL=react.js.map
|