@tensor_1/react 2.53.0 → 2.54.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 +47 -1
- package/dist/components/MatrixHeatmap.d.ts +63 -0
- package/dist/components/MatrixHeatmap.js +67 -0
- package/dist/components/MatrixInput.d.ts +83 -0
- package/dist/components/MatrixInput.js +162 -0
- package/dist/components/MatrixParts.d.ts +39 -0
- package/dist/components/MatrixParts.js +54 -0
- package/dist/hooks/useMatrixGrid.d.ts +17 -0
- package/dist/hooks/useMatrixGrid.js +49 -0
- package/dist/index.cjs +519 -169
- package/dist/index.d.cts +147 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/matrix-model.d.ts +21 -0
- package/dist/matrix-model.js +28 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -177,6 +177,8 @@ __export(src_exports, {
|
|
|
177
177
|
LocaleSwitcher: () => LocaleSwitcher,
|
|
178
178
|
Mark: () => Mark,
|
|
179
179
|
MatchReview: () => MatchReview,
|
|
180
|
+
MatrixHeatmap: () => MatrixHeatmap,
|
|
181
|
+
MatrixInput: () => MatrixInput,
|
|
180
182
|
Menu: () => Menu,
|
|
181
183
|
MenuGroup: () => MenuGroup,
|
|
182
184
|
MenuItem: () => MenuItem,
|
|
@@ -23539,9 +23541,355 @@ function AdoptCandidate({ candidate, incoming, fields, labels, heading, provenan
|
|
|
23539
23541
|
] });
|
|
23540
23542
|
}
|
|
23541
23543
|
|
|
23542
|
-
// src/components/
|
|
23544
|
+
// src/components/MatrixInput.tsx
|
|
23545
|
+
var import_react110 = require("react");
|
|
23546
|
+
|
|
23547
|
+
// src/hooks/useMatrixGrid.ts
|
|
23543
23548
|
var import_react109 = require("react");
|
|
23544
23549
|
|
|
23550
|
+
// src/matrix-model.ts
|
|
23551
|
+
function matrixStep(from, size, key, options = {}) {
|
|
23552
|
+
const { corner = false, rtl = false } = options;
|
|
23553
|
+
const lastRow = size.rows - 1;
|
|
23554
|
+
const lastColumn = size.columns - 1;
|
|
23555
|
+
const clamp3 = (row, column) => ({
|
|
23556
|
+
row: Math.max(0, Math.min(lastRow, row)),
|
|
23557
|
+
column: Math.max(0, Math.min(lastColumn, column))
|
|
23558
|
+
});
|
|
23559
|
+
switch (key) {
|
|
23560
|
+
case "ArrowUp":
|
|
23561
|
+
return clamp3(from.row - 1, from.column);
|
|
23562
|
+
case "ArrowDown":
|
|
23563
|
+
return clamp3(from.row + 1, from.column);
|
|
23564
|
+
case "ArrowLeft":
|
|
23565
|
+
return clamp3(from.row, from.column + (rtl ? 1 : -1));
|
|
23566
|
+
case "ArrowRight":
|
|
23567
|
+
return clamp3(from.row, from.column + (rtl ? -1 : 1));
|
|
23568
|
+
case "Home":
|
|
23569
|
+
return corner ? clamp3(0, 0) : clamp3(from.row, 0);
|
|
23570
|
+
case "End":
|
|
23571
|
+
return corner ? clamp3(lastRow, lastColumn) : clamp3(from.row, lastColumn);
|
|
23572
|
+
default:
|
|
23573
|
+
return null;
|
|
23574
|
+
}
|
|
23575
|
+
}
|
|
23576
|
+
|
|
23577
|
+
// src/hooks/useMatrixGrid.ts
|
|
23578
|
+
var useIsomorphicLayoutEffect26 = typeof document !== "undefined" ? import_react109.useLayoutEffect : import_react109.useEffect;
|
|
23579
|
+
var CELL = "[data-uix-matrix-cell]";
|
|
23580
|
+
function useMatrixGrid(rows, columns) {
|
|
23581
|
+
const gridRef = (0, import_react109.useRef)(null);
|
|
23582
|
+
const stop2 = (0, import_react109.useRef)({ node: null, index: 0 });
|
|
23583
|
+
const size = (0, import_react109.useRef)({ rows, columns });
|
|
23584
|
+
size.current = { rows, columns };
|
|
23585
|
+
const cells = () => Array.from(gridRef.current?.querySelectorAll(CELL) ?? []);
|
|
23586
|
+
useIsomorphicLayoutEffect26(() => {
|
|
23587
|
+
stop2.current = syncRovingStop(cells(), stop2.current);
|
|
23588
|
+
});
|
|
23589
|
+
const onGridFocus = (0, import_react109.useCallback)((event) => {
|
|
23590
|
+
const cell = event.target.closest(CELL);
|
|
23591
|
+
if (cell) stop2.current = syncRovingStop(cells(), stop2.current, cell);
|
|
23592
|
+
}, []);
|
|
23593
|
+
const onCellKeyDown = (0, import_react109.useCallback)((event) => {
|
|
23594
|
+
const cell = event.currentTarget;
|
|
23595
|
+
if (cell.getAttribute("aria-expanded") === "true") return;
|
|
23596
|
+
const { key, altKey, shiftKey } = event;
|
|
23597
|
+
const corner = event.ctrlKey || event.metaKey;
|
|
23598
|
+
if (altKey || shiftKey || corner && key !== "Home" && key !== "End") return;
|
|
23599
|
+
const to = matrixStep(
|
|
23600
|
+
{ row: Number(cell.dataset.row), column: Number(cell.dataset.column) },
|
|
23601
|
+
size.current,
|
|
23602
|
+
key,
|
|
23603
|
+
{ corner, rtl: getComputedStyle(cell).direction === "rtl" }
|
|
23604
|
+
);
|
|
23605
|
+
if (!to) return;
|
|
23606
|
+
event.preventDefault();
|
|
23607
|
+
const next = gridRef.current?.querySelector(`${CELL}[data-row="${to.row}"][data-column="${to.column}"]`);
|
|
23608
|
+
if (!next || next === cell) return;
|
|
23609
|
+
next.focus({ preventScroll: true });
|
|
23610
|
+
next.scrollIntoView?.({ block: "nearest", inline: "nearest" });
|
|
23611
|
+
const grid = gridRef.current;
|
|
23612
|
+
const header = grid?.tHead?.rows[0]?.cells[0];
|
|
23613
|
+
const scroller = grid?.parentElement;
|
|
23614
|
+
if (!header || !scroller) return;
|
|
23615
|
+
const under = header.getBoundingClientRect().bottom - next.getBoundingClientRect().top;
|
|
23616
|
+
if (under > 0) scroller.scrollTop -= under;
|
|
23617
|
+
}, []);
|
|
23618
|
+
return { gridRef, onCellKeyDown, onGridFocus };
|
|
23619
|
+
}
|
|
23620
|
+
|
|
23621
|
+
// src/components/MatrixParts.tsx
|
|
23622
|
+
var import_jsx_runtime124 = require("react/jsx-runtime");
|
|
23623
|
+
function MatrixFrame({
|
|
23624
|
+
gridRef,
|
|
23625
|
+
rows,
|
|
23626
|
+
columns,
|
|
23627
|
+
rowAxisLabel,
|
|
23628
|
+
columnAxisLabel,
|
|
23629
|
+
ariaLabel,
|
|
23630
|
+
ariaLabelledBy,
|
|
23631
|
+
readOnly,
|
|
23632
|
+
onFocus,
|
|
23633
|
+
gridProps,
|
|
23634
|
+
renderCell
|
|
23635
|
+
}) {
|
|
23636
|
+
return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("div", { className: "uix-matrix__scroll", children: /* @__PURE__ */ (0, import_jsx_runtime124.jsxs)(
|
|
23637
|
+
"table",
|
|
23638
|
+
{
|
|
23639
|
+
...gridProps,
|
|
23640
|
+
ref: gridRef,
|
|
23641
|
+
role: "grid",
|
|
23642
|
+
className: "uix-matrix__grid",
|
|
23643
|
+
style: { "--uix-matrix-columns": columns.length },
|
|
23644
|
+
"aria-label": ariaLabel,
|
|
23645
|
+
"aria-labelledby": ariaLabelledBy,
|
|
23646
|
+
"aria-readonly": readOnly || void 0,
|
|
23647
|
+
onFocus,
|
|
23648
|
+
children: [
|
|
23649
|
+
/* @__PURE__ */ (0, import_jsx_runtime124.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime124.jsxs)("tr", { children: [
|
|
23650
|
+
/* @__PURE__ */ (0, import_jsx_runtime124.jsxs)("th", { scope: "col", className: "uix-matrix__corner", children: [
|
|
23651
|
+
columnAxisLabel && /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("span", { className: "uix-matrix__axis uix-matrix__axis--column", children: columnAxisLabel }),
|
|
23652
|
+
/* @__PURE__ */ (0, import_jsx_runtime124.jsx)("span", { className: "uix-matrix__axis", children: rowAxisLabel })
|
|
23653
|
+
] }),
|
|
23654
|
+
columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime124.jsxs)("th", { scope: "col", className: "uix-matrix__column", children: [
|
|
23655
|
+
column.label,
|
|
23656
|
+
column.description != null && /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("span", { className: "uix-matrix__note", children: column.description })
|
|
23657
|
+
] }, column.id))
|
|
23658
|
+
] }) }),
|
|
23659
|
+
/* @__PURE__ */ (0, import_jsx_runtime124.jsx)("tbody", { children: rows.map((row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime124.jsxs)("tr", { children: [
|
|
23660
|
+
/* @__PURE__ */ (0, import_jsx_runtime124.jsxs)("th", { scope: "row", className: "uix-matrix__row", children: [
|
|
23661
|
+
row.label,
|
|
23662
|
+
row.description != null && /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("span", { className: "uix-matrix__note", children: row.description })
|
|
23663
|
+
] }),
|
|
23664
|
+
columns.map((column, columnIndex) => renderCell(row, column, rowIndex, columnIndex))
|
|
23665
|
+
] }, row.id)) })
|
|
23666
|
+
]
|
|
23667
|
+
}
|
|
23668
|
+
) });
|
|
23669
|
+
}
|
|
23670
|
+
var matrixClass = (className, modifier) => cx("uix-matrix", modifier && `uix-matrix--${modifier}`, className);
|
|
23671
|
+
|
|
23672
|
+
// src/components/MatrixInput.tsx
|
|
23673
|
+
var import_jsx_runtime125 = require("react/jsx-runtime");
|
|
23674
|
+
var Cell = (0, import_react110.memo)(function Cell2({
|
|
23675
|
+
rowId,
|
|
23676
|
+
columnId,
|
|
23677
|
+
rowIndex,
|
|
23678
|
+
columnIndex,
|
|
23679
|
+
name,
|
|
23680
|
+
value,
|
|
23681
|
+
options,
|
|
23682
|
+
option,
|
|
23683
|
+
empty,
|
|
23684
|
+
help,
|
|
23685
|
+
error,
|
|
23686
|
+
disabled,
|
|
23687
|
+
readOnly,
|
|
23688
|
+
id,
|
|
23689
|
+
onKeyDown,
|
|
23690
|
+
onPick
|
|
23691
|
+
}) {
|
|
23692
|
+
const locked = disabled || readOnly;
|
|
23693
|
+
const helpId = help ? `${id}-help` : void 0;
|
|
23694
|
+
const errorId = error ? `${id}-error` : void 0;
|
|
23695
|
+
const describedBy = [errorId, helpId].filter(Boolean).join(" ") || void 0;
|
|
23696
|
+
return /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)("td", { role: "gridcell", className: "uix-matrix__cell", "aria-readonly": locked || void 0, "aria-invalid": error ? true : void 0, children: [
|
|
23697
|
+
/* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
|
|
23698
|
+
Select,
|
|
23699
|
+
{
|
|
23700
|
+
size: "sm",
|
|
23701
|
+
"aria-label": name,
|
|
23702
|
+
"aria-describedby": describedBy,
|
|
23703
|
+
"aria-disabled": disabled || void 0,
|
|
23704
|
+
tabIndex: rowIndex === 0 && columnIndex === 0 ? 0 : -1,
|
|
23705
|
+
options,
|
|
23706
|
+
value,
|
|
23707
|
+
placeholder: empty,
|
|
23708
|
+
readOnly: locked,
|
|
23709
|
+
invalid: !!error,
|
|
23710
|
+
"data-uix-matrix-cell": "",
|
|
23711
|
+
"data-row": rowIndex,
|
|
23712
|
+
"data-column": columnIndex,
|
|
23713
|
+
"data-tone": option?.tone,
|
|
23714
|
+
"data-unrated": option?.unrated || void 0,
|
|
23715
|
+
"data-locked": disabled || void 0,
|
|
23716
|
+
"data-help": help,
|
|
23717
|
+
onKeyDown,
|
|
23718
|
+
onValueChange: (next) => onPick(rowId, columnId, next)
|
|
23719
|
+
}
|
|
23720
|
+
),
|
|
23721
|
+
help && /* @__PURE__ */ (0, import_jsx_runtime125.jsx)("span", { id: helpId, className: "uix-visually-hidden", children: help }),
|
|
23722
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime125.jsx)("span", { id: errorId, className: "uix-matrix__error", children: error })
|
|
23723
|
+
] });
|
|
23724
|
+
});
|
|
23725
|
+
function MatrixInput({
|
|
23726
|
+
"aria-label": ariaLabel,
|
|
23727
|
+
"aria-labelledby": ariaLabelledBy,
|
|
23728
|
+
rows,
|
|
23729
|
+
columns,
|
|
23730
|
+
options,
|
|
23731
|
+
value,
|
|
23732
|
+
onChange,
|
|
23733
|
+
rowAxisLabel,
|
|
23734
|
+
columnAxisLabel,
|
|
23735
|
+
labels,
|
|
23736
|
+
getCell,
|
|
23737
|
+
disabled = false,
|
|
23738
|
+
readOnly = false,
|
|
23739
|
+
className,
|
|
23740
|
+
...props
|
|
23741
|
+
}) {
|
|
23742
|
+
const uid = (0, import_react110.useId)();
|
|
23743
|
+
const { gridRef, onCellKeyDown, onGridFocus } = useMatrixGrid(rows.length, columns.length);
|
|
23744
|
+
const helpRef = (0, import_react110.useRef)(null);
|
|
23745
|
+
const latest = (0, import_react110.useRef)({ value, onChange });
|
|
23746
|
+
latest.current = { value, onChange };
|
|
23747
|
+
const onPick = (0, import_react110.useCallback)((rowId, columnId, next) => {
|
|
23748
|
+
const current = latest.current;
|
|
23749
|
+
current.onChange(
|
|
23750
|
+
{ ...current.value, [rowId]: { ...current.value[rowId], [columnId]: next } },
|
|
23751
|
+
{ rowId, columnId, value: next }
|
|
23752
|
+
);
|
|
23753
|
+
}, []);
|
|
23754
|
+
const choices = (0, import_react110.useMemo)(() => options.map(({ value: v, label, description, disabled: off }) => ({
|
|
23755
|
+
value: v,
|
|
23756
|
+
label,
|
|
23757
|
+
...description ? { description } : {},
|
|
23758
|
+
...off ? { disabled: true } : {}
|
|
23759
|
+
})), [options]);
|
|
23760
|
+
const byValue = (0, import_react110.useMemo)(() => new Map(options.map((o) => [o.value, o])), [options]);
|
|
23761
|
+
const showHelp = (cell) => {
|
|
23762
|
+
if (helpRef.current) helpRef.current.textContent = cell?.getAttribute("data-help") ?? "";
|
|
23763
|
+
};
|
|
23764
|
+
const cellOf = (target) => target?.closest?.("[data-uix-matrix-cell]") ?? null;
|
|
23765
|
+
const onFocus = (event) => {
|
|
23766
|
+
onGridFocus(event);
|
|
23767
|
+
showHelp(cellOf(event.target));
|
|
23768
|
+
};
|
|
23769
|
+
const onPointerOver = (event) => {
|
|
23770
|
+
const cell = cellOf(event.target);
|
|
23771
|
+
if (cell && event.pointerType === "mouse") showHelp(cell);
|
|
23772
|
+
};
|
|
23773
|
+
const onPointerLeave = () => showHelp(cellOf(document.activeElement));
|
|
23774
|
+
const onBlur = (event) => {
|
|
23775
|
+
if (!event.currentTarget.contains(event.relatedTarget)) showHelp(null);
|
|
23776
|
+
};
|
|
23777
|
+
(0, import_react110.useEffect)(() => {
|
|
23778
|
+
const focused = cellOf(document.activeElement);
|
|
23779
|
+
if (focused && gridRef.current?.contains(focused)) showHelp(focused);
|
|
23780
|
+
});
|
|
23781
|
+
const anyHelp = !!getCell && rows.some((row) => columns.some((column) => getCell(row.id, column.id)?.help));
|
|
23782
|
+
return /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)("div", { ...props, className: matrixClass(className, "input"), children: [
|
|
23783
|
+
/* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
|
|
23784
|
+
MatrixFrame,
|
|
23785
|
+
{
|
|
23786
|
+
gridRef,
|
|
23787
|
+
rows,
|
|
23788
|
+
columns,
|
|
23789
|
+
rowAxisLabel,
|
|
23790
|
+
columnAxisLabel,
|
|
23791
|
+
ariaLabel,
|
|
23792
|
+
ariaLabelledBy,
|
|
23793
|
+
readOnly,
|
|
23794
|
+
onFocus,
|
|
23795
|
+
gridProps: { onPointerOver, onPointerLeave, onBlur },
|
|
23796
|
+
renderCell: (row, column, rowIndex, columnIndex) => {
|
|
23797
|
+
const state = getCell?.(row.id, column.id);
|
|
23798
|
+
const current = value[row.id]?.[column.id] ?? "";
|
|
23799
|
+
return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
|
|
23800
|
+
Cell,
|
|
23801
|
+
{
|
|
23802
|
+
rowId: row.id,
|
|
23803
|
+
columnId: column.id,
|
|
23804
|
+
rowIndex,
|
|
23805
|
+
columnIndex,
|
|
23806
|
+
name: `${row.label}, ${column.label}`,
|
|
23807
|
+
value: current,
|
|
23808
|
+
options: choices,
|
|
23809
|
+
option: byValue.get(current),
|
|
23810
|
+
empty: labels.empty,
|
|
23811
|
+
help: state?.help,
|
|
23812
|
+
error: state?.error,
|
|
23813
|
+
disabled: disabled || !!state?.disabled,
|
|
23814
|
+
readOnly: readOnly || !!state?.readOnly,
|
|
23815
|
+
id: `${uid}-${rowIndex}-${columnIndex}`,
|
|
23816
|
+
onKeyDown: onCellKeyDown,
|
|
23817
|
+
onPick
|
|
23818
|
+
},
|
|
23819
|
+
column.id
|
|
23820
|
+
);
|
|
23821
|
+
}
|
|
23822
|
+
}
|
|
23823
|
+
),
|
|
23824
|
+
anyHelp && /* @__PURE__ */ (0, import_jsx_runtime125.jsx)("p", { ref: helpRef, className: "uix-matrix__help", "aria-hidden": "true" })
|
|
23825
|
+
] });
|
|
23826
|
+
}
|
|
23827
|
+
|
|
23828
|
+
// src/components/MatrixHeatmap.tsx
|
|
23829
|
+
var import_react111 = require("react");
|
|
23830
|
+
var import_jsx_runtime126 = require("react/jsx-runtime");
|
|
23831
|
+
var cellKey = (rowId, columnId) => JSON.stringify([rowId, columnId]);
|
|
23832
|
+
function MatrixHeatmap({
|
|
23833
|
+
"aria-label": ariaLabel,
|
|
23834
|
+
"aria-labelledby": ariaLabelledBy,
|
|
23835
|
+
rows,
|
|
23836
|
+
columns,
|
|
23837
|
+
cells,
|
|
23838
|
+
onOpenCell,
|
|
23839
|
+
renderLink,
|
|
23840
|
+
rowAxisLabel,
|
|
23841
|
+
columnAxisLabel,
|
|
23842
|
+
labels,
|
|
23843
|
+
className,
|
|
23844
|
+
...props
|
|
23845
|
+
}) {
|
|
23846
|
+
const { gridRef, onCellKeyDown, onGridFocus } = useMatrixGrid(rows.length, columns.length);
|
|
23847
|
+
const byCell = (0, import_react111.useMemo)(() => new Map(cells.map((cell) => [cellKey(cell.rowId, cell.columnId), cell])), [cells]);
|
|
23848
|
+
return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)("div", { ...props, className: matrixClass(className, "heatmap"), children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
|
|
23849
|
+
MatrixFrame,
|
|
23850
|
+
{
|
|
23851
|
+
gridRef,
|
|
23852
|
+
rows,
|
|
23853
|
+
columns,
|
|
23854
|
+
rowAxisLabel,
|
|
23855
|
+
columnAxisLabel,
|
|
23856
|
+
ariaLabel,
|
|
23857
|
+
ariaLabelledBy,
|
|
23858
|
+
readOnly: true,
|
|
23859
|
+
onFocus: onGridFocus,
|
|
23860
|
+
renderCell: (row, column, rowIndex, columnIndex) => {
|
|
23861
|
+
const cell = byCell.get(cellKey(row.id, column.id));
|
|
23862
|
+
const figure = cell && !cell.hideCount && cell.count != null ? String(cell.count) : null;
|
|
23863
|
+
const empty = figure == null && !cell?.band;
|
|
23864
|
+
const detail = empty ? labels.empty : [cell?.band?.label, figure].filter(Boolean).join(", ");
|
|
23865
|
+
const name = `${row.label}, ${column.label}${detail ? `: ${detail}` : ""}`;
|
|
23866
|
+
const opened = cell ?? { rowId: row.id, columnId: column.id };
|
|
23867
|
+
const control = {
|
|
23868
|
+
className: "uix-matrix__tile",
|
|
23869
|
+
"aria-label": name,
|
|
23870
|
+
tabIndex: rowIndex === 0 && columnIndex === 0 ? 0 : -1,
|
|
23871
|
+
"data-uix-matrix-cell": "",
|
|
23872
|
+
"data-row": rowIndex,
|
|
23873
|
+
"data-column": columnIndex,
|
|
23874
|
+
"data-tone": cell?.band?.tone,
|
|
23875
|
+
"data-empty": empty || void 0,
|
|
23876
|
+
"aria-disabled": cell?.href == null && !onOpenCell || void 0,
|
|
23877
|
+
onKeyDown: onCellKeyDown,
|
|
23878
|
+
onClick: cell?.href != null ? void 0 : () => onOpenCell?.(opened)
|
|
23879
|
+
};
|
|
23880
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(import_jsx_runtime126.Fragment, { children: [
|
|
23881
|
+
figure != null && /* @__PURE__ */ (0, import_jsx_runtime126.jsx)("span", { className: "uix-matrix__count", children: figure }),
|
|
23882
|
+
/* @__PURE__ */ (0, import_jsx_runtime126.jsx)("span", { className: "uix-matrix__band", children: empty ? labels.empty : cell?.band?.label })
|
|
23883
|
+
] });
|
|
23884
|
+
return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)("td", { role: "gridcell", className: "uix-matrix__cell", children: cell?.href != null ? renderUixLink(renderLink, { ...control, href: cell.href, children: content }) : /* @__PURE__ */ (0, import_jsx_runtime126.jsx)("button", { type: "button", ...control, children: content }) }, column.id);
|
|
23885
|
+
}
|
|
23886
|
+
}
|
|
23887
|
+
) });
|
|
23888
|
+
}
|
|
23889
|
+
|
|
23890
|
+
// src/components/MetricInput.tsx
|
|
23891
|
+
var import_react112 = require("react");
|
|
23892
|
+
|
|
23545
23893
|
// src/metric-model.ts
|
|
23546
23894
|
function decimals(value) {
|
|
23547
23895
|
const text = String(value).toLowerCase();
|
|
@@ -23565,7 +23913,7 @@ function parseMetricValue(value) {
|
|
|
23565
23913
|
}
|
|
23566
23914
|
|
|
23567
23915
|
// src/components/MetricInput.tsx
|
|
23568
|
-
var
|
|
23916
|
+
var import_jsx_runtime127 = require("react/jsx-runtime");
|
|
23569
23917
|
var defaultMetricFormat = (input) => input == null ? "" : String(input);
|
|
23570
23918
|
function MetricInput({
|
|
23571
23919
|
value,
|
|
@@ -23586,14 +23934,14 @@ function MetricInput({
|
|
|
23586
23934
|
className,
|
|
23587
23935
|
id: providedId
|
|
23588
23936
|
}) {
|
|
23589
|
-
const generatedId = (0,
|
|
23937
|
+
const generatedId = (0, import_react112.useId)();
|
|
23590
23938
|
const id = providedId ?? generatedId;
|
|
23591
23939
|
const errorId = `${id}-error`;
|
|
23592
23940
|
const hintId = `${id}-hint`;
|
|
23593
23941
|
const showError = Boolean(invalid && errorMessage);
|
|
23594
23942
|
const describedBy = [hint ? hintId : null, showError ? errorId : null].filter(Boolean).join(" ") || void 0;
|
|
23595
|
-
const [text, setText] = (0,
|
|
23596
|
-
(0,
|
|
23943
|
+
const [text, setText] = (0, import_react112.useState)(() => format(value));
|
|
23944
|
+
(0, import_react112.useEffect)(() => setText(format(value)), [value, format]);
|
|
23597
23945
|
const commit = (input) => {
|
|
23598
23946
|
const parsed = parse(input);
|
|
23599
23947
|
if (input.trim() === "" || parsed !== null) {
|
|
@@ -23619,10 +23967,10 @@ function MetricInput({
|
|
|
23619
23967
|
const parsed = parse(event.currentTarget.value);
|
|
23620
23968
|
setText(parsed === null && event.currentTarget.value.trim() !== "" ? format(value) : format(parsed));
|
|
23621
23969
|
};
|
|
23622
|
-
return /* @__PURE__ */ (0,
|
|
23623
|
-
/* @__PURE__ */ (0,
|
|
23624
|
-
/* @__PURE__ */ (0,
|
|
23625
|
-
/* @__PURE__ */ (0,
|
|
23970
|
+
return /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)("div", { className: cx("uix-metric-input", invalid && "uix-metric-input--invalid", className), children: [
|
|
23971
|
+
/* @__PURE__ */ (0, import_jsx_runtime127.jsx)("label", { className: "uix-field__label", htmlFor: id, "data-required": required || void 0, children: label }),
|
|
23972
|
+
/* @__PURE__ */ (0, import_jsx_runtime127.jsxs)("div", { className: "uix-metric-input__control", children: [
|
|
23973
|
+
/* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
|
|
23626
23974
|
Input,
|
|
23627
23975
|
{
|
|
23628
23976
|
id,
|
|
@@ -23643,23 +23991,23 @@ function MetricInput({
|
|
|
23643
23991
|
readOnly
|
|
23644
23992
|
}
|
|
23645
23993
|
),
|
|
23646
|
-
unit && /* @__PURE__ */ (0,
|
|
23647
|
-
/* @__PURE__ */ (0,
|
|
23648
|
-
/* @__PURE__ */ (0,
|
|
23649
|
-
/* @__PURE__ */ (0,
|
|
23994
|
+
unit && /* @__PURE__ */ (0, import_jsx_runtime127.jsx)("span", { className: "uix-metric-input__unit", "aria-hidden": "true", children: unit }),
|
|
23995
|
+
/* @__PURE__ */ (0, import_jsx_runtime127.jsxs)("span", { className: "uix-metric-input__steps", children: [
|
|
23996
|
+
/* @__PURE__ */ (0, import_jsx_runtime127.jsx)("button", { type: "button", className: "uix-metric-input__step", onClick: () => stepBy(1), disabled: disabled || readOnly, "aria-label": `Increase ${label}`, children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(PlusIcon, {}) }),
|
|
23997
|
+
/* @__PURE__ */ (0, import_jsx_runtime127.jsx)("button", { type: "button", className: "uix-metric-input__step", onClick: () => stepBy(-1), disabled: disabled || readOnly, "aria-label": `Decrease ${label}`, children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(MinusIcon, {}) })
|
|
23650
23998
|
] })
|
|
23651
23999
|
] }),
|
|
23652
|
-
unit && /* @__PURE__ */ (0,
|
|
24000
|
+
unit && /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)("span", { className: "uix-visually-hidden", children: [
|
|
23653
24001
|
"Unit: ",
|
|
23654
24002
|
unit
|
|
23655
24003
|
] }),
|
|
23656
|
-
hint && /* @__PURE__ */ (0,
|
|
23657
|
-
showError && /* @__PURE__ */ (0,
|
|
24004
|
+
hint && /* @__PURE__ */ (0, import_jsx_runtime127.jsx)("span", { id: hintId, className: "uix-field__hint", children: hint }),
|
|
24005
|
+
showError && /* @__PURE__ */ (0, import_jsx_runtime127.jsx)("span", { id: errorId, className: "uix-field__error", children: errorMessage })
|
|
23658
24006
|
] });
|
|
23659
24007
|
}
|
|
23660
24008
|
|
|
23661
24009
|
// src/components/LicensePositionBar.tsx
|
|
23662
|
-
var
|
|
24010
|
+
var import_jsx_runtime128 = require("react/jsx-runtime");
|
|
23663
24011
|
var defaultCapacityFormat = (value) => new Intl.NumberFormat().format(value);
|
|
23664
24012
|
function LicensePositionBar({
|
|
23665
24013
|
consumed,
|
|
@@ -23680,18 +24028,18 @@ function LicensePositionBar({
|
|
|
23680
24028
|
const percent = safeEntitled === 0 ? safeConsumed > 0 ? 100 : 0 : safeConsumed / safeEntitled * 100;
|
|
23681
24029
|
const format = (value) => `${formatValue(value)}${unit ? ` ${unit}` : ""}`;
|
|
23682
24030
|
const summary = `${consumedLabel}: ${format(safeConsumed)}. ${entitledLabel}: ${format(safeEntitled)}. ${over > 0 ? `${format(over)} ${overLabel}` : `${format(available)} ${availableLabel}`}.`;
|
|
23683
|
-
return /* @__PURE__ */ (0,
|
|
23684
|
-
/* @__PURE__ */ (0,
|
|
23685
|
-
/* @__PURE__ */ (0,
|
|
24031
|
+
return /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)("div", { className: cx("uix-license-position", over > 0 && "uix-license-position--over", className), ...props, children: [
|
|
24032
|
+
/* @__PURE__ */ (0, import_jsx_runtime128.jsxs)("div", { className: "uix-license-position__header", children: [
|
|
24033
|
+
/* @__PURE__ */ (0, import_jsx_runtime128.jsxs)("span", { className: "uix-license-position__value", children: [
|
|
23686
24034
|
format(safeConsumed),
|
|
23687
24035
|
" / ",
|
|
23688
24036
|
format(safeEntitled)
|
|
23689
24037
|
] }),
|
|
23690
|
-
/* @__PURE__ */ (0,
|
|
24038
|
+
/* @__PURE__ */ (0, import_jsx_runtime128.jsx)(StatusPill, { tone: over > 0 ? "danger" : percent >= 80 ? "warning" : "success", children: over > 0 ? `${format(over)} ${overLabel}` : `${format(available)} ${availableLabel}` })
|
|
23691
24039
|
] }),
|
|
23692
|
-
/* @__PURE__ */ (0,
|
|
23693
|
-
/* @__PURE__ */ (0,
|
|
23694
|
-
over > 0 && /* @__PURE__ */ (0,
|
|
24040
|
+
/* @__PURE__ */ (0, import_jsx_runtime128.jsxs)("div", { className: "uix-license-position__track", children: [
|
|
24041
|
+
/* @__PURE__ */ (0, import_jsx_runtime128.jsx)(Meter, { value: Math.min(100, percent), tone: over > 0 ? "danger" : percent >= 80 ? "warning" : "success", "aria-label": summary, "aria-valuetext": summary }),
|
|
24042
|
+
over > 0 && /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
|
|
23695
24043
|
"span",
|
|
23696
24044
|
{
|
|
23697
24045
|
className: "uix-license-position__overflow",
|
|
@@ -23700,12 +24048,12 @@ function LicensePositionBar({
|
|
|
23700
24048
|
}
|
|
23701
24049
|
)
|
|
23702
24050
|
] }),
|
|
23703
|
-
/* @__PURE__ */ (0,
|
|
24051
|
+
/* @__PURE__ */ (0, import_jsx_runtime128.jsx)("span", { className: "uix-visually-hidden", children: summary })
|
|
23704
24052
|
] });
|
|
23705
24053
|
}
|
|
23706
24054
|
|
|
23707
24055
|
// src/components/BrandProfiles.tsx
|
|
23708
|
-
var
|
|
24056
|
+
var import_react114 = require("react");
|
|
23709
24057
|
|
|
23710
24058
|
// src/color-model.ts
|
|
23711
24059
|
var clamp2 = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
@@ -23774,8 +24122,8 @@ function meetsContrast(background, foreground, minimum = 4.5) {
|
|
|
23774
24122
|
}
|
|
23775
24123
|
|
|
23776
24124
|
// src/components/ColorPicker.tsx
|
|
23777
|
-
var
|
|
23778
|
-
var
|
|
24125
|
+
var import_react113 = require("react");
|
|
24126
|
+
var import_jsx_runtime129 = require("react/jsx-runtime");
|
|
23779
24127
|
var DEFAULT_COLOR_PICKER_LABELS = {
|
|
23780
24128
|
trigger: "{label}: {color}",
|
|
23781
24129
|
sample: "Aa",
|
|
@@ -23806,17 +24154,17 @@ function ColorPicker({
|
|
|
23806
24154
|
labels: labelOverrides
|
|
23807
24155
|
}) {
|
|
23808
24156
|
const labels = { ...DEFAULT_COLOR_PICKER_LABELS, ...labelOverrides };
|
|
23809
|
-
const id = (0,
|
|
23810
|
-
const triggerRef = (0,
|
|
23811
|
-
const dialogRef = (0,
|
|
23812
|
-
const [open, setOpen] = (0,
|
|
24157
|
+
const id = (0, import_react113.useId)();
|
|
24158
|
+
const triggerRef = (0, import_react113.useRef)(null);
|
|
24159
|
+
const dialogRef = (0, import_react113.useRef)(null);
|
|
24160
|
+
const [open, setOpen] = (0, import_react113.useState)(false);
|
|
23813
24161
|
const normalized = normalizeHex(value) ?? "#000000";
|
|
23814
|
-
const [hexText, setHexText] = (0,
|
|
23815
|
-
const hsv = (0,
|
|
24162
|
+
const [hexText, setHexText] = (0, import_react113.useState)(normalized);
|
|
24163
|
+
const hsv = (0, import_react113.useMemo)(() => rgbToHsv(hexToRgb(normalized)), [normalized]);
|
|
23816
24164
|
const ratio = contrastRatio(normalized, foreground) ?? 0;
|
|
23817
24165
|
const passes = ratio >= minimumContrast;
|
|
23818
|
-
(0,
|
|
23819
|
-
(0,
|
|
24166
|
+
(0, import_react113.useEffect)(() => setHexText(normalized), [normalized]);
|
|
24167
|
+
(0, import_react113.useEffect)(() => {
|
|
23820
24168
|
if (!open) return;
|
|
23821
24169
|
const dialog = dialogRef.current;
|
|
23822
24170
|
dialog?.querySelector("input,button")?.focus();
|
|
@@ -23859,8 +24207,8 @@ function ColorPicker({
|
|
|
23859
24207
|
if (next) onChange(next);
|
|
23860
24208
|
};
|
|
23861
24209
|
const sampleStyle = { backgroundColor: normalized };
|
|
23862
|
-
return /* @__PURE__ */ (0,
|
|
23863
|
-
/* @__PURE__ */ (0,
|
|
24210
|
+
return /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("div", { className: cx("uix-color-picker", className), children: [
|
|
24211
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(
|
|
23864
24212
|
"button",
|
|
23865
24213
|
{
|
|
23866
24214
|
ref: triggerRef,
|
|
@@ -23872,12 +24220,12 @@ function ColorPicker({
|
|
|
23872
24220
|
onClick: () => setOpen((current) => !current),
|
|
23873
24221
|
disabled,
|
|
23874
24222
|
children: [
|
|
23875
|
-
/* @__PURE__ */ (0,
|
|
23876
|
-
/* @__PURE__ */ (0,
|
|
24223
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsx)("span", { className: "uix-color-picker__swatch", style: sampleStyle, "aria-hidden": "true" }),
|
|
24224
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsx)("span", { children: normalized })
|
|
23877
24225
|
]
|
|
23878
24226
|
}
|
|
23879
24227
|
),
|
|
23880
|
-
open && /* @__PURE__ */ (0,
|
|
24228
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(
|
|
23881
24229
|
"div",
|
|
23882
24230
|
{
|
|
23883
24231
|
ref: dialogRef,
|
|
@@ -23888,55 +24236,55 @@ function ColorPicker({
|
|
|
23888
24236
|
className: "uix-color-picker__popover",
|
|
23889
24237
|
onKeyDown: onDialogKeyDown,
|
|
23890
24238
|
children: [
|
|
23891
|
-
/* @__PURE__ */ (0,
|
|
23892
|
-
/* @__PURE__ */ (0,
|
|
24239
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsx)("div", { className: "uix-color-picker__preview", style: sampleStyle, children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("span", { style: { color: foreground }, children: labels.sample }) }),
|
|
24240
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("label", { className: "uix-color-picker__range", children: [
|
|
23893
24241
|
labels.hue,
|
|
23894
24242
|
" ",
|
|
23895
|
-
/* @__PURE__ */ (0,
|
|
24243
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("span", { children: [
|
|
23896
24244
|
Math.round(hsv.h),
|
|
23897
24245
|
"\xB0"
|
|
23898
24246
|
] }),
|
|
23899
|
-
/* @__PURE__ */ (0,
|
|
24247
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsx)("input", { type: "range", min: "0", max: "359", value: Math.round(hsv.h), onChange: (event) => updateHsv({ h: Number(event.currentTarget.value) }) })
|
|
23900
24248
|
] }),
|
|
23901
|
-
/* @__PURE__ */ (0,
|
|
24249
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("label", { className: "uix-color-picker__range", children: [
|
|
23902
24250
|
labels.saturation,
|
|
23903
24251
|
" ",
|
|
23904
|
-
/* @__PURE__ */ (0,
|
|
24252
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("span", { children: [
|
|
23905
24253
|
Math.round(hsv.s * 100),
|
|
23906
24254
|
"%"
|
|
23907
24255
|
] }),
|
|
23908
|
-
/* @__PURE__ */ (0,
|
|
24256
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsx)("input", { type: "range", min: "0", max: "100", value: Math.round(hsv.s * 100), onChange: (event) => updateHsv({ s: Number(event.currentTarget.value) / 100 }) })
|
|
23909
24257
|
] }),
|
|
23910
|
-
/* @__PURE__ */ (0,
|
|
24258
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("label", { className: "uix-color-picker__range", children: [
|
|
23911
24259
|
labels.brightness,
|
|
23912
24260
|
" ",
|
|
23913
|
-
/* @__PURE__ */ (0,
|
|
24261
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("span", { children: [
|
|
23914
24262
|
Math.round(hsv.v * 100),
|
|
23915
24263
|
"%"
|
|
23916
24264
|
] }),
|
|
23917
|
-
/* @__PURE__ */ (0,
|
|
24265
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsx)("input", { type: "range", min: "0", max: "100", value: Math.round(hsv.v * 100), onChange: (event) => updateHsv({ v: Number(event.currentTarget.value) / 100 }) })
|
|
23918
24266
|
] }),
|
|
23919
|
-
/* @__PURE__ */ (0,
|
|
24267
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("label", { className: "uix-color-picker__hex", children: [
|
|
23920
24268
|
labels.hex,
|
|
23921
|
-
/* @__PURE__ */ (0,
|
|
23922
|
-
/* @__PURE__ */ (0,
|
|
24269
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("span", { className: "uix-color-picker__hex-row", children: [
|
|
24270
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsx)("input", { className: "uix-input", value: hexText, onChange: (event) => setHexText(event.currentTarget.value), onBlur: commitHex, onKeyDown: (event) => {
|
|
23923
24271
|
if (event.key === "Enter") commitHex();
|
|
23924
24272
|
}, "aria-invalid": !normalizeHex(hexText) }),
|
|
23925
|
-
/* @__PURE__ */ (0,
|
|
24273
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsx)("button", { type: "button", className: "uix-btn uix-btn--secondary uix-btn--sm", onClick: commitHex, disabled: !normalizeHex(hexText), children: labels.set })
|
|
23926
24274
|
] })
|
|
23927
24275
|
] }),
|
|
23928
|
-
(presets.length > 0 || recent.length > 0) && /* @__PURE__ */ (0,
|
|
23929
|
-
presets.length > 0 && /* @__PURE__ */ (0,
|
|
23930
|
-
/* @__PURE__ */ (0,
|
|
23931
|
-
/* @__PURE__ */ (0,
|
|
24276
|
+
(presets.length > 0 || recent.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("div", { className: "uix-color-picker__palettes", children: [
|
|
24277
|
+
presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("fieldset", { children: [
|
|
24278
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsx)("legend", { children: labels.presets }),
|
|
24279
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsx)("div", { children: presets.map((color) => /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("button", { type: "button", className: "uix-color-picker__preset", style: { backgroundColor: normalizeHex(color) ?? color }, onClick: () => choose(color), "aria-label": fillLabel(labels.usePreset, { color }) }, color)) })
|
|
23932
24280
|
] }),
|
|
23933
|
-
recent.length > 0 && /* @__PURE__ */ (0,
|
|
23934
|
-
/* @__PURE__ */ (0,
|
|
23935
|
-
/* @__PURE__ */ (0,
|
|
24281
|
+
recent.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("fieldset", { children: [
|
|
24282
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsx)("legend", { children: labels.recent }),
|
|
24283
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsx)("div", { children: recent.map((color) => /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("button", { type: "button", className: "uix-color-picker__preset", style: { backgroundColor: normalizeHex(color) ?? color }, onClick: () => choose(color), "aria-label": fillLabel(labels.useRecent, { color }) }, color)) })
|
|
23936
24284
|
] })
|
|
23937
24285
|
] }),
|
|
23938
|
-
/* @__PURE__ */ (0,
|
|
23939
|
-
/* @__PURE__ */ (0,
|
|
24286
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsx)("p", { className: cx("uix-color-picker__contrast", passes ? "uix-color-picker__contrast--pass" : "uix-color-picker__contrast--fail"), role: "status", "aria-live": "polite", children: fillLabel(passes ? labels.contrastPasses : labels.contrastFails, { ratio: ratio.toFixed(2), minimum: minimumContrast }) }),
|
|
24287
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsx)("button", { type: "button", className: "uix-btn uix-btn--primary uix-btn--sm", onClick: close, children: labels.done })
|
|
23940
24288
|
]
|
|
23941
24289
|
}
|
|
23942
24290
|
)
|
|
@@ -23944,7 +24292,7 @@ function ColorPicker({
|
|
|
23944
24292
|
}
|
|
23945
24293
|
|
|
23946
24294
|
// src/components/BrandProfiles.tsx
|
|
23947
|
-
var
|
|
24295
|
+
var import_jsx_runtime130 = require("react/jsx-runtime");
|
|
23948
24296
|
var PROFILE_PROPERTIES = {
|
|
23949
24297
|
brand: "--uix-brand",
|
|
23950
24298
|
brandForeground: "--uix-brand-fg",
|
|
@@ -24036,7 +24384,7 @@ function BrandProfileEditor({
|
|
|
24036
24384
|
labels: labelOverrides
|
|
24037
24385
|
}) {
|
|
24038
24386
|
const labels = { ...DEFAULT_BRAND_PROFILE_EDITOR_LABELS, ...labelOverrides };
|
|
24039
|
-
const [announcement, setAnnouncement] = (0,
|
|
24387
|
+
const [announcement, setAnnouncement] = (0, import_react114.useState)("");
|
|
24040
24388
|
const update = (patch) => onChange({ ...value, ...patch });
|
|
24041
24389
|
const apply = () => {
|
|
24042
24390
|
if (applyTarget !== null) applyBrandProfile(value, applyTarget);
|
|
@@ -24053,54 +24401,54 @@ function BrandProfileEditor({
|
|
|
24053
24401
|
...value.typography?.sans ? { "--uix-font-sans": value.typography.sans } : {},
|
|
24054
24402
|
...value.typography?.heading ? { "--uix-font-heading": value.typography.heading } : {}
|
|
24055
24403
|
};
|
|
24056
|
-
return /* @__PURE__ */ (0,
|
|
24057
|
-
/* @__PURE__ */ (0,
|
|
24058
|
-
profiles.length > 0 && /* @__PURE__ */ (0,
|
|
24404
|
+
return /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("section", { className: cx("uix-brand-profiles", className), "aria-label": labels.region, children: [
|
|
24405
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("div", { className: "uix-brand-profiles__form", children: [
|
|
24406
|
+
profiles.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("label", { className: "uix-field__label", children: [
|
|
24059
24407
|
labels.profile,
|
|
24060
|
-
/* @__PURE__ */ (0,
|
|
24408
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsx)(Select, { value: value.id, options: profiles.map((profile) => ({ value: profile.id, label: profile.name })), onValueChange: (next) => {
|
|
24061
24409
|
const selected = profiles.find((profile) => profile.id === next);
|
|
24062
24410
|
if (selected) onSelectProfile?.(selected);
|
|
24063
24411
|
} })
|
|
24064
24412
|
] }),
|
|
24065
|
-
/* @__PURE__ */ (0,
|
|
24413
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("label", { className: "uix-field__label", children: [
|
|
24066
24414
|
labels.name,
|
|
24067
|
-
/* @__PURE__ */ (0,
|
|
24415
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsx)("input", { className: "uix-input", value: value.name, onChange: (event) => update({ name: event.currentTarget.value }) })
|
|
24068
24416
|
] }),
|
|
24069
|
-
/* @__PURE__ */ (0,
|
|
24070
|
-
/* @__PURE__ */ (0,
|
|
24417
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("div", { className: "uix-brand-profiles__colors", children: [
|
|
24418
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("label", { children: [
|
|
24071
24419
|
labels.brand,
|
|
24072
|
-
/* @__PURE__ */ (0,
|
|
24420
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsx)(ColorPicker, { label: labels.brandColor, value: value.brand, foreground: value.brandForeground, presets: colorPresets, onChange: (brand) => update({ brand }) })
|
|
24073
24421
|
] }),
|
|
24074
|
-
/* @__PURE__ */ (0,
|
|
24422
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("label", { children: [
|
|
24075
24423
|
labels.onBrand,
|
|
24076
|
-
/* @__PURE__ */ (0,
|
|
24424
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsx)(ColorPicker, { label: labels.onBrandColor, value: value.brandForeground, foreground: value.brand, presets: colorPresets, onChange: (brandForeground) => update({ brandForeground }) })
|
|
24077
24425
|
] })
|
|
24078
24426
|
] }),
|
|
24079
|
-
/* @__PURE__ */ (0,
|
|
24427
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("label", { className: "uix-field__label", children: [
|
|
24080
24428
|
labels.bodyFont,
|
|
24081
|
-
/* @__PURE__ */ (0,
|
|
24429
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsx)("input", { className: "uix-input", value: value.typography?.sans ?? "", onChange: (event) => update({ typography: { ...value.typography, sans: event.currentTarget.value || void 0 } }) })
|
|
24082
24430
|
] }),
|
|
24083
|
-
/* @__PURE__ */ (0,
|
|
24431
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("label", { className: "uix-field__label", children: [
|
|
24084
24432
|
labels.headingFont,
|
|
24085
|
-
/* @__PURE__ */ (0,
|
|
24433
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsx)("input", { className: "uix-input", value: value.typography?.heading ?? "", onChange: (event) => update({ typography: { ...value.typography, heading: event.currentTarget.value || void 0 } }) })
|
|
24086
24434
|
] }),
|
|
24087
|
-
/* @__PURE__ */ (0,
|
|
24435
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("label", { className: "uix-file-upload uix-brand-profiles__upload", children: [
|
|
24088
24436
|
labels.logoFile,
|
|
24089
|
-
/* @__PURE__ */ (0,
|
|
24437
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsx)("input", { type: "file", accept: "image/*", onChange: onFile })
|
|
24090
24438
|
] }),
|
|
24091
|
-
/* @__PURE__ */ (0,
|
|
24092
|
-
/* @__PURE__ */ (0,
|
|
24439
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsx)("button", { type: "button", className: "uix-btn uix-btn--primary", onClick: apply, children: labels.apply }),
|
|
24440
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsx)("span", { className: "uix-visually-hidden", "aria-live": "polite", children: announcement })
|
|
24093
24441
|
] }),
|
|
24094
|
-
/* @__PURE__ */ (0,
|
|
24095
|
-
/* @__PURE__ */ (0,
|
|
24096
|
-
value.logo ? /* @__PURE__ */ (0,
|
|
24097
|
-
/* @__PURE__ */ (0,
|
|
24442
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("div", { className: "uix-brand-profiles__preview", style: previewStyle, "aria-label": fillLabel(labels.preview, { name: value.name }), children: [
|
|
24443
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("div", { className: "uix-brand-profiles__preview-header", children: [
|
|
24444
|
+
value.logo ? /* @__PURE__ */ (0, import_jsx_runtime130.jsx)("img", { src: value.logo.src, alt: value.logo.alt }) : /* @__PURE__ */ (0, import_jsx_runtime130.jsx)("span", { className: "uix-brand-profiles__logo-placeholder", children: labels.logoPlaceholder }),
|
|
24445
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsx)("strong", { children: value.name || labels.previewTitleFallback })
|
|
24098
24446
|
] }),
|
|
24099
|
-
/* @__PURE__ */ (0,
|
|
24100
|
-
/* @__PURE__ */ (0,
|
|
24101
|
-
/* @__PURE__ */ (0,
|
|
24102
|
-
/* @__PURE__ */ (0,
|
|
24103
|
-
/* @__PURE__ */ (0,
|
|
24447
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("div", { className: "uix-brand-profiles__preview-body", children: [
|
|
24448
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsx)("h3", { children: labels.previewHeading }),
|
|
24449
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsx)("p", { children: labels.previewBody }),
|
|
24450
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsx)("button", { type: "button", className: "uix-btn uix-btn--primary", children: labels.previewPrimary }),
|
|
24451
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsx)("a", { href: "#brand-profile-preview", children: labels.previewLink })
|
|
24104
24452
|
] })
|
|
24105
24453
|
] })
|
|
24106
24454
|
] });
|
|
@@ -24108,7 +24456,7 @@ function BrandProfileEditor({
|
|
|
24108
24456
|
var BrandProfiles = BrandProfileEditor;
|
|
24109
24457
|
|
|
24110
24458
|
// src/components/DiffViewer.tsx
|
|
24111
|
-
var
|
|
24459
|
+
var import_react115 = require("react");
|
|
24112
24460
|
|
|
24113
24461
|
// src/diff-model.ts
|
|
24114
24462
|
function isJsonObject(value) {
|
|
@@ -24159,7 +24507,7 @@ function summarizeDiff(entries, resolutions = {}) {
|
|
|
24159
24507
|
}
|
|
24160
24508
|
|
|
24161
24509
|
// src/components/DiffViewer.tsx
|
|
24162
|
-
var
|
|
24510
|
+
var import_jsx_runtime131 = require("react/jsx-runtime");
|
|
24163
24511
|
var DEFAULT_DIFF_VIEWER_LABELS = {
|
|
24164
24512
|
base: "Base",
|
|
24165
24513
|
current: "Current",
|
|
@@ -24207,38 +24555,38 @@ function DiffViewer({
|
|
|
24207
24555
|
const labels = { ...DEFAULT_DIFF_VIEWER_LABELS, ...useUixLabels().diffViewer, ...labelOverrides };
|
|
24208
24556
|
const nameOf = (path) => {
|
|
24209
24557
|
const node = labelFor?.(path);
|
|
24210
|
-
if (node == null || node === false) return { node: /* @__PURE__ */ (0,
|
|
24558
|
+
if (node == null || node === false) return { node: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("code", { children: path }), text: path };
|
|
24211
24559
|
return { node, text: typeof node === "string" || typeof node === "number" ? String(node) : path };
|
|
24212
24560
|
};
|
|
24213
24561
|
const resolutionLabel = { accept: labels.resolutionAccept, skip: labels.resolutionSkip, pending: labels.resolutionPending };
|
|
24214
24562
|
const buttonSize = controlSize === "md" ? void 0 : `uix-btn--${controlSize}`;
|
|
24215
|
-
const id = (0,
|
|
24216
|
-
const entries = (0,
|
|
24217
|
-
const [internalResolutions, setInternalResolutions] = (0,
|
|
24563
|
+
const id = (0, import_react115.useId)();
|
|
24564
|
+
const entries = (0, import_react115.useMemo)(() => providedEntries ?? buildThreeWayDiff(base, current, incoming), [providedEntries, base, current, incoming]);
|
|
24565
|
+
const [internalResolutions, setInternalResolutions] = (0, import_react115.useState)({});
|
|
24218
24566
|
const resolutions = controlledResolutions ?? internalResolutions;
|
|
24219
24567
|
const summary = summarizeDiff(entries, resolutions);
|
|
24220
24568
|
const resolve = (path, resolution) => {
|
|
24221
24569
|
if (controlledResolutions === void 0) setInternalResolutions((currentState) => ({ ...currentState, [path]: resolution }));
|
|
24222
24570
|
onResolutionChange?.(path, resolution);
|
|
24223
24571
|
};
|
|
24224
|
-
if (entries.length === 0) return /* @__PURE__ */ (0,
|
|
24225
|
-
/* @__PURE__ */ (0,
|
|
24226
|
-
/* @__PURE__ */ (0,
|
|
24572
|
+
if (entries.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("section", { className: cx("uix-diff-viewer uix-diff-viewer--empty", className), "aria-label": labels.region, children: [
|
|
24573
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsx)("h3", { children: labels.noDifferences }),
|
|
24574
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsx)("p", { children: labels.noDifferencesDetail })
|
|
24227
24575
|
] });
|
|
24228
|
-
return /* @__PURE__ */ (0,
|
|
24229
|
-
/* @__PURE__ */ (0,
|
|
24230
|
-
GROUPS.map((kind) => /* @__PURE__ */ (0,
|
|
24231
|
-
/* @__PURE__ */ (0,
|
|
24576
|
+
return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("section", { className: cx("uix-diff-viewer", className), "aria-label": labels.region, "data-control-size": controlSize, children: [
|
|
24577
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("div", { className: "uix-diff-viewer__summary", role: "group", "aria-label": labels.summary, children: [
|
|
24578
|
+
GROUPS.map((kind) => /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("span", { children: [
|
|
24579
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsx)("b", { children: summary[kind] }),
|
|
24232
24580
|
" ",
|
|
24233
24581
|
labels[kind].toLowerCase()
|
|
24234
24582
|
] }, kind)),
|
|
24235
|
-
/* @__PURE__ */ (0,
|
|
24236
|
-
/* @__PURE__ */ (0,
|
|
24583
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("span", { children: [
|
|
24584
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsx)("b", { children: summary.resolved }),
|
|
24237
24585
|
" ",
|
|
24238
24586
|
labels.resolved
|
|
24239
24587
|
] }),
|
|
24240
|
-
/* @__PURE__ */ (0,
|
|
24241
|
-
/* @__PURE__ */ (0,
|
|
24588
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("span", { children: [
|
|
24589
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsx)("b", { children: summary.pending }),
|
|
24242
24590
|
" ",
|
|
24243
24591
|
labels.pending
|
|
24244
24592
|
] })
|
|
@@ -24246,43 +24594,43 @@ function DiffViewer({
|
|
|
24246
24594
|
GROUPS.map((kind) => {
|
|
24247
24595
|
const grouped = entries.filter((entry) => entry.kind === kind);
|
|
24248
24596
|
if (!grouped.length) return null;
|
|
24249
|
-
return /* @__PURE__ */ (0,
|
|
24250
|
-
/* @__PURE__ */ (0,
|
|
24597
|
+
return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("section", { className: "uix-diff-viewer__group", "aria-labelledby": `${id}-${kind}`, children: [
|
|
24598
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("h3", { id: `${id}-${kind}`, children: [
|
|
24251
24599
|
labels[kind],
|
|
24252
24600
|
" ",
|
|
24253
|
-
/* @__PURE__ */ (0,
|
|
24601
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsx)("span", { children: grouped.length })
|
|
24254
24602
|
] }),
|
|
24255
24603
|
grouped.map((entry) => {
|
|
24256
24604
|
const resolution = resolutions[entry.path] ?? "pending";
|
|
24257
24605
|
const name = nameOf(entry.path);
|
|
24258
|
-
return /* @__PURE__ */ (0,
|
|
24259
|
-
/* @__PURE__ */ (0,
|
|
24260
|
-
/* @__PURE__ */ (0,
|
|
24261
|
-
/* @__PURE__ */ (0,
|
|
24606
|
+
return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("details", { className: "uix-diff-viewer__entry", "data-kind": entry.kind, open: entry.kind === "conflicted", children: [
|
|
24607
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("summary", { children: [
|
|
24608
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsx)("span", { className: "uix-diff-viewer__name", children: name.node }),
|
|
24609
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsx)(StatusPill, { tone: resolution === "pending" ? "warning" : "success", children: resolutionLabel[resolution] })
|
|
24262
24610
|
] }),
|
|
24263
|
-
/* @__PURE__ */ (0,
|
|
24611
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsx)("div", { className: "uix-diff-viewer__versions", children: ["base", "current", "incoming"].map((version) => {
|
|
24264
24612
|
const origin = provenance?.(entry.path, version);
|
|
24265
|
-
return /* @__PURE__ */ (0,
|
|
24266
|
-
/* @__PURE__ */ (0,
|
|
24267
|
-
renderValue ? /* @__PURE__ */ (0,
|
|
24268
|
-
origin != null && origin !== false && /* @__PURE__ */ (0,
|
|
24613
|
+
return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("div", { role: "region", "aria-label": fillLabel(labels.valueFor, { version: labels[version], path: name.text }), children: [
|
|
24614
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsx)("strong", { children: labels[version] }),
|
|
24615
|
+
renderValue ? /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("div", { className: "uix-diff-viewer__value", children: renderValue(entry[version], entry.path, version) ?? labels.notPresent }) : /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("pre", { children: jsonText(entry[version], labels.notPresent) }),
|
|
24616
|
+
origin != null && origin !== false && /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("div", { className: "uix-diff-viewer__provenance", children: origin })
|
|
24269
24617
|
] }, version);
|
|
24270
24618
|
}) }),
|
|
24271
|
-
/* @__PURE__ */ (0,
|
|
24272
|
-
/* @__PURE__ */ (0,
|
|
24273
|
-
/* @__PURE__ */ (0,
|
|
24274
|
-
/* @__PURE__ */ (0,
|
|
24619
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("div", { className: "uix-diff-viewer__actions", role: "group", "aria-label": fillLabel(labels.resolve, { path: name.text }), children: [
|
|
24620
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsx)("button", { type: "button", className: cx("uix-btn uix-btn--primary", buttonSize), "aria-label": fillLabel(labels.acceptIncomingFor, { path: name.text }), "aria-pressed": resolution === "accept", onClick: () => resolve(entry.path, "accept"), children: labels.acceptIncoming }),
|
|
24621
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsx)("button", { type: "button", className: cx("uix-btn uix-btn--secondary", buttonSize), "aria-label": fillLabel(labels.keepCurrentFor, { path: name.text }), "aria-pressed": resolution === "skip", onClick: () => resolve(entry.path, "skip"), children: labels.keepCurrent }),
|
|
24622
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsx)("button", { type: "button", className: cx("uix-btn uix-btn--ghost", buttonSize), "aria-label": fillLabel(labels.markPendingFor, { path: name.text }), "aria-pressed": resolution === "pending", onClick: () => resolve(entry.path, "pending"), children: labels.markPending })
|
|
24275
24623
|
] })
|
|
24276
24624
|
] }, entry.path);
|
|
24277
24625
|
})
|
|
24278
24626
|
] }, kind);
|
|
24279
24627
|
}),
|
|
24280
|
-
/* @__PURE__ */ (0,
|
|
24628
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsx)("p", { className: "uix-visually-hidden", "aria-live": "polite", children: fillLabel(labels.progress, { resolved: summary.resolved, total: entries.length }) })
|
|
24281
24629
|
] });
|
|
24282
24630
|
}
|
|
24283
24631
|
|
|
24284
24632
|
// src/components/TextDiff.tsx
|
|
24285
|
-
var
|
|
24633
|
+
var import_react116 = require("react");
|
|
24286
24634
|
|
|
24287
24635
|
// src/text-diff-model.ts
|
|
24288
24636
|
var WORD_TOKENS = /\s+|[\p{L}\p{M}\p{N}_]+|[^\s\p{L}\p{M}\p{N}_]/gu;
|
|
@@ -24542,7 +24890,7 @@ function textDiffRows(result, { context } = {}) {
|
|
|
24542
24890
|
}
|
|
24543
24891
|
|
|
24544
24892
|
// src/components/TextDiff.tsx
|
|
24545
|
-
var
|
|
24893
|
+
var import_jsx_runtime132 = require("react/jsx-runtime");
|
|
24546
24894
|
var DEFAULT_TEXT_DIFF_LABELS = {
|
|
24547
24895
|
before: "Before",
|
|
24548
24896
|
after: "After",
|
|
@@ -24555,47 +24903,47 @@ var DEFAULT_TEXT_DIFF_LABELS = {
|
|
|
24555
24903
|
};
|
|
24556
24904
|
function Marked({ segments, side, labels, whole: whole2 }) {
|
|
24557
24905
|
const Tag = side === "before" ? "del" : "ins";
|
|
24558
|
-
return /* @__PURE__ */ (0,
|
|
24559
|
-
/* @__PURE__ */ (0,
|
|
24906
|
+
return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_jsx_runtime132.Fragment, { children: segments.map((segment, i) => segment.changed ? /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(Tag, { "data-whole": whole2 || void 0, children: [
|
|
24907
|
+
/* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("span", { className: "uix-visually-hidden", children: [
|
|
24560
24908
|
side === "before" ? labels.removed : labels.added,
|
|
24561
24909
|
": "
|
|
24562
24910
|
] }),
|
|
24563
24911
|
segment.text
|
|
24564
|
-
] }, i) : /* @__PURE__ */ (0,
|
|
24912
|
+
] }, i) : /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_react116.Fragment, { children: segment.text }, i)) });
|
|
24565
24913
|
}
|
|
24566
|
-
function
|
|
24567
|
-
if (!line) return /* @__PURE__ */ (0,
|
|
24914
|
+
function Cell3({ line, side, kind, labels }) {
|
|
24915
|
+
if (!line) return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { className: "uix-text-diff__cell", "data-side": side, "data-empty": "", "aria-hidden": "true" });
|
|
24568
24916
|
const changed = kind !== "equal";
|
|
24569
|
-
return /* @__PURE__ */ (0,
|
|
24570
|
-
/* @__PURE__ */ (0,
|
|
24571
|
-
/* @__PURE__ */ (0,
|
|
24572
|
-
/* @__PURE__ */ (0,
|
|
24917
|
+
return /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("div", { className: "uix-text-diff__cell", "data-side": side, "data-kind": changed ? side === "before" ? "delete" : "insert" : "equal", children: [
|
|
24918
|
+
/* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { className: "uix-text-diff__num", "aria-hidden": "true", children: line.number }),
|
|
24919
|
+
/* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { className: "uix-text-diff__sign", "aria-hidden": "true", children: changed ? side === "before" ? "\u2212" : "+" : "" }),
|
|
24920
|
+
/* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { className: "uix-text-diff__text", children: line.segments.length === 1 && line.segments[0].text === "" ? "\u200B" : /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Marked, { segments: line.segments, side, labels, whole: line.segments.length === 1 }) })
|
|
24573
24921
|
] });
|
|
24574
24922
|
}
|
|
24575
24923
|
function Rows({ rows, view, labels, focusFirst }) {
|
|
24576
|
-
const [open, setOpen] = (0,
|
|
24577
|
-
const first = (0,
|
|
24578
|
-
(0,
|
|
24924
|
+
const [open, setOpen] = (0, import_react116.useState)(() => /* @__PURE__ */ new Set());
|
|
24925
|
+
const first = (0, import_react116.useRef)(null);
|
|
24926
|
+
(0, import_react116.useEffect)(() => {
|
|
24579
24927
|
if (focusFirst) first.current?.focus();
|
|
24580
24928
|
}, [focusFirst]);
|
|
24581
24929
|
const firstProps = (index) => focusFirst && index === 0 ? { ref: first, tabIndex: -1 } : {};
|
|
24582
|
-
return /* @__PURE__ */ (0,
|
|
24930
|
+
return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_jsx_runtime132.Fragment, { children: rows.map((row, index) => {
|
|
24583
24931
|
if (row.kind === "fold") {
|
|
24584
|
-
if (open.has(index)) return /* @__PURE__ */ (0,
|
|
24585
|
-
return /* @__PURE__ */ (0,
|
|
24932
|
+
if (open.has(index)) return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Rows, { rows: row.rows, view, labels, focusFirst: true }, index);
|
|
24933
|
+
return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { className: "uix-text-diff__row", "data-kind": "fold", children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("button", { type: "button", className: "uix-text-diff__fold", onClick: () => setOpen((s) => new Set(s).add(index)), children: fillLabel(labels.showUnchanged, { count: row.count }) }) }, index);
|
|
24586
24934
|
}
|
|
24587
24935
|
const before = row.kind === "insert" ? void 0 : row.before;
|
|
24588
24936
|
const after = row.kind === "delete" ? void 0 : row.after;
|
|
24589
24937
|
if (view === "unified") {
|
|
24590
|
-
if (row.kind === "equal") return /* @__PURE__ */ (0,
|
|
24591
|
-
return /* @__PURE__ */ (0,
|
|
24592
|
-
before && /* @__PURE__ */ (0,
|
|
24593
|
-
after && /* @__PURE__ */ (0,
|
|
24938
|
+
if (row.kind === "equal") return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { className: "uix-text-diff__row", "data-kind": "equal", ...firstProps(index), children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Cell3, { line: after, side: "after", kind: "equal", labels }) }, index);
|
|
24939
|
+
return /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(import_react116.Fragment, { children: [
|
|
24940
|
+
before && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { className: "uix-text-diff__row", "data-kind": "delete", children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Cell3, { line: before, side: "before", kind: row.kind, labels }) }),
|
|
24941
|
+
after && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { className: "uix-text-diff__row", "data-kind": "insert", children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Cell3, { line: after, side: "after", kind: row.kind, labels }) })
|
|
24594
24942
|
] }, index);
|
|
24595
24943
|
}
|
|
24596
|
-
return /* @__PURE__ */ (0,
|
|
24597
|
-
/* @__PURE__ */ (0,
|
|
24598
|
-
/* @__PURE__ */ (0,
|
|
24944
|
+
return /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("div", { className: "uix-text-diff__row", "data-kind": row.kind, ...firstProps(index), children: [
|
|
24945
|
+
/* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Cell3, { line: before, side: "before", kind: row.kind, labels }),
|
|
24946
|
+
/* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Cell3, { line: after, side: "after", kind: row.kind, labels })
|
|
24599
24947
|
] }, index);
|
|
24600
24948
|
}) });
|
|
24601
24949
|
}
|
|
@@ -24617,41 +24965,41 @@ function TextDiff({
|
|
|
24617
24965
|
}) {
|
|
24618
24966
|
const uixLabels = useUixLabels();
|
|
24619
24967
|
const labels = { ...DEFAULT_TEXT_DIFF_LABELS, ...uixLabels.textDiff, ...labelOverrides };
|
|
24620
|
-
const result = (0,
|
|
24621
|
-
const rows = (0,
|
|
24622
|
-
const heads = /* @__PURE__ */ (0,
|
|
24623
|
-
/* @__PURE__ */ (0,
|
|
24624
|
-
view === "unified" && /* @__PURE__ */ (0,
|
|
24968
|
+
const result = (0, import_react116.useMemo)(() => diffText(before, after, { granularity, maxTokens, maxEdits }), [before, after, granularity, maxTokens, maxEdits]);
|
|
24969
|
+
const rows = (0, import_react116.useMemo)(() => granularity === "line" && result.status === "ok" ? textDiffRows(result, { context }) : [], [result, granularity, context]);
|
|
24970
|
+
const heads = /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("div", { className: "uix-text-diff__heads", "aria-hidden": view === "unified" || void 0, children: [
|
|
24971
|
+
/* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("span", { className: "uix-text-diff__head", "data-side": "before", children: [
|
|
24972
|
+
view === "unified" && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { "aria-hidden": "true", children: "\u2212 " }),
|
|
24625
24973
|
beforeLabel ?? labels.before
|
|
24626
24974
|
] }),
|
|
24627
|
-
/* @__PURE__ */ (0,
|
|
24628
|
-
view === "unified" && /* @__PURE__ */ (0,
|
|
24975
|
+
/* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("span", { className: "uix-text-diff__head", "data-side": "after", children: [
|
|
24976
|
+
view === "unified" && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { "aria-hidden": "true", children: "+ " }),
|
|
24629
24977
|
afterLabel ?? labels.after
|
|
24630
24978
|
] })
|
|
24631
24979
|
] });
|
|
24632
24980
|
const unchanged = result.status === "ok" && result.added === 0 && result.removed === 0 && result.ops.every((op) => op.type === "equal");
|
|
24633
24981
|
let body;
|
|
24634
|
-
if (result.status === "too-large") body = /* @__PURE__ */ (0,
|
|
24635
|
-
else if (granularity === "line") body = /* @__PURE__ */ (0,
|
|
24982
|
+
if (result.status === "too-large") body = /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { className: "uix-text-diff__note", children: labels.tooLarge });
|
|
24983
|
+
else if (granularity === "line") body = /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { className: "uix-text-diff__body", children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Rows, { rows, view, labels }) });
|
|
24636
24984
|
else {
|
|
24637
|
-
const prose = (side2) => /* @__PURE__ */ (0,
|
|
24985
|
+
const prose = (side2) => /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { className: "uix-text-diff__prose", "data-side": side2, children: result.ops.map((op, i) => {
|
|
24638
24986
|
const text = op.tokens.join("");
|
|
24639
|
-
if (op.type === "equal") return /* @__PURE__ */ (0,
|
|
24987
|
+
if (op.type === "equal") return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_react116.Fragment, { children: text }, i);
|
|
24640
24988
|
if (op.type === "delete" && side2 === "after") return null;
|
|
24641
24989
|
if (op.type === "insert" && side2 === "before") return null;
|
|
24642
|
-
return /* @__PURE__ */ (0,
|
|
24990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Marked, { segments: [{ text, changed: true }], side: op.type === "delete" ? "before" : "after", labels }, i);
|
|
24643
24991
|
}) });
|
|
24644
|
-
const side = (which) => /* @__PURE__ */ (0,
|
|
24645
|
-
/* @__PURE__ */ (0,
|
|
24992
|
+
const side = (which) => /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("div", { className: "uix-text-diff__side", children: [
|
|
24993
|
+
/* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { className: "uix-text-diff__head", children: which === "before" ? beforeLabel ?? labels.before : afterLabel ?? labels.after }),
|
|
24646
24994
|
prose(which)
|
|
24647
24995
|
] });
|
|
24648
|
-
body = /* @__PURE__ */ (0,
|
|
24996
|
+
body = /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { className: "uix-text-diff__body", children: view === "unified" ? prose("both") : /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("div", { className: "uix-text-diff__row", "data-kind": "prose", children: [
|
|
24649
24997
|
side("before"),
|
|
24650
24998
|
side("after")
|
|
24651
24999
|
] }) });
|
|
24652
25000
|
}
|
|
24653
|
-
return /* @__PURE__ */ (0,
|
|
24654
|
-
!hideSummary && result.status === "ok" && /* @__PURE__ */ (0,
|
|
25001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("div", { role: "group", "aria-label": label, className: cx("uix-text-diff", className), "data-view": view, "data-granularity": granularity, ...props, children: [
|
|
25002
|
+
!hideSummary && result.status === "ok" && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { className: "uix-text-diff__summary", children: unchanged ? labels.noChanges : fillLabel(labels.summary, { added: result.added, removed: result.removed }) }),
|
|
24655
25003
|
!(granularity === "word" && view === "split" && result.status === "ok") && heads,
|
|
24656
25004
|
body
|
|
24657
25005
|
] });
|
|
@@ -24815,6 +25163,8 @@ function TextDiff({
|
|
|
24815
25163
|
LocaleSwitcher,
|
|
24816
25164
|
Mark,
|
|
24817
25165
|
MatchReview,
|
|
25166
|
+
MatrixHeatmap,
|
|
25167
|
+
MatrixInput,
|
|
24818
25168
|
Menu,
|
|
24819
25169
|
MenuGroup,
|
|
24820
25170
|
MenuItem,
|