@tensor_1/react 2.52.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/Card.d.ts +7 -1
- package/dist/components/Card.js +9 -3
- 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 +526 -171
- package/dist/index.d.cts +154 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/link.d.ts +1 -1
- 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,
|
|
@@ -7195,9 +7197,10 @@ function Card({ title, titleAs: TitleTag = "div", titleId, subtitle, help, helpL
|
|
|
7195
7197
|
footer != null && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "uix-card__footer", children: footer })
|
|
7196
7198
|
] });
|
|
7197
7199
|
}
|
|
7198
|
-
function CardLink({ title, subtitle, headerAction, footer, children, className, ...props }) {
|
|
7200
|
+
function CardLink({ title, subtitle, headerAction, footer, children, className, href, renderLink, ...props }) {
|
|
7199
7201
|
const hasHeader = title != null || subtitle != null || headerAction != null;
|
|
7200
|
-
|
|
7202
|
+
const classes = cx("uix-card", "uix-card--interactive", className);
|
|
7203
|
+
const body = /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
7201
7204
|
hasHeader && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "uix-card__header", children: [
|
|
7202
7205
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { style: { flex: 1 }, children: [
|
|
7203
7206
|
title != null && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "uix-card__title", children: title }),
|
|
@@ -7208,6 +7211,10 @@ function CardLink({ title, subtitle, headerAction, footer, children, className,
|
|
|
7208
7211
|
children != null && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "uix-card__body", children }),
|
|
7209
7212
|
footer != null && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "uix-card__footer", children: footer })
|
|
7210
7213
|
] });
|
|
7214
|
+
if (renderLink && href !== void 0) {
|
|
7215
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children: renderUixLink(renderLink, { ...props, href, className: classes, children: body }) });
|
|
7216
|
+
}
|
|
7217
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("a", { className: classes, href, ...props, children: body });
|
|
7211
7218
|
}
|
|
7212
7219
|
function Inset({ padding = "md", tone = "sunken", children, className, ...props }) {
|
|
7213
7220
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: cx("uix-inset", padding === "sm" && "uix-inset--sm", tone === "surface" && "uix-inset--surface", className), ...props, children });
|
|
@@ -23534,9 +23541,355 @@ function AdoptCandidate({ candidate, incoming, fields, labels, heading, provenan
|
|
|
23534
23541
|
] });
|
|
23535
23542
|
}
|
|
23536
23543
|
|
|
23537
|
-
// src/components/
|
|
23544
|
+
// src/components/MatrixInput.tsx
|
|
23545
|
+
var import_react110 = require("react");
|
|
23546
|
+
|
|
23547
|
+
// src/hooks/useMatrixGrid.ts
|
|
23538
23548
|
var import_react109 = require("react");
|
|
23539
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
|
+
|
|
23540
23893
|
// src/metric-model.ts
|
|
23541
23894
|
function decimals(value) {
|
|
23542
23895
|
const text = String(value).toLowerCase();
|
|
@@ -23560,7 +23913,7 @@ function parseMetricValue(value) {
|
|
|
23560
23913
|
}
|
|
23561
23914
|
|
|
23562
23915
|
// src/components/MetricInput.tsx
|
|
23563
|
-
var
|
|
23916
|
+
var import_jsx_runtime127 = require("react/jsx-runtime");
|
|
23564
23917
|
var defaultMetricFormat = (input) => input == null ? "" : String(input);
|
|
23565
23918
|
function MetricInput({
|
|
23566
23919
|
value,
|
|
@@ -23581,14 +23934,14 @@ function MetricInput({
|
|
|
23581
23934
|
className,
|
|
23582
23935
|
id: providedId
|
|
23583
23936
|
}) {
|
|
23584
|
-
const generatedId = (0,
|
|
23937
|
+
const generatedId = (0, import_react112.useId)();
|
|
23585
23938
|
const id = providedId ?? generatedId;
|
|
23586
23939
|
const errorId = `${id}-error`;
|
|
23587
23940
|
const hintId = `${id}-hint`;
|
|
23588
23941
|
const showError = Boolean(invalid && errorMessage);
|
|
23589
23942
|
const describedBy = [hint ? hintId : null, showError ? errorId : null].filter(Boolean).join(" ") || void 0;
|
|
23590
|
-
const [text, setText] = (0,
|
|
23591
|
-
(0,
|
|
23943
|
+
const [text, setText] = (0, import_react112.useState)(() => format(value));
|
|
23944
|
+
(0, import_react112.useEffect)(() => setText(format(value)), [value, format]);
|
|
23592
23945
|
const commit = (input) => {
|
|
23593
23946
|
const parsed = parse(input);
|
|
23594
23947
|
if (input.trim() === "" || parsed !== null) {
|
|
@@ -23614,10 +23967,10 @@ function MetricInput({
|
|
|
23614
23967
|
const parsed = parse(event.currentTarget.value);
|
|
23615
23968
|
setText(parsed === null && event.currentTarget.value.trim() !== "" ? format(value) : format(parsed));
|
|
23616
23969
|
};
|
|
23617
|
-
return /* @__PURE__ */ (0,
|
|
23618
|
-
/* @__PURE__ */ (0,
|
|
23619
|
-
/* @__PURE__ */ (0,
|
|
23620
|
-
/* @__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)(
|
|
23621
23974
|
Input,
|
|
23622
23975
|
{
|
|
23623
23976
|
id,
|
|
@@ -23638,23 +23991,23 @@ function MetricInput({
|
|
|
23638
23991
|
readOnly
|
|
23639
23992
|
}
|
|
23640
23993
|
),
|
|
23641
|
-
unit && /* @__PURE__ */ (0,
|
|
23642
|
-
/* @__PURE__ */ (0,
|
|
23643
|
-
/* @__PURE__ */ (0,
|
|
23644
|
-
/* @__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, {}) })
|
|
23645
23998
|
] })
|
|
23646
23999
|
] }),
|
|
23647
|
-
unit && /* @__PURE__ */ (0,
|
|
24000
|
+
unit && /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)("span", { className: "uix-visually-hidden", children: [
|
|
23648
24001
|
"Unit: ",
|
|
23649
24002
|
unit
|
|
23650
24003
|
] }),
|
|
23651
|
-
hint && /* @__PURE__ */ (0,
|
|
23652
|
-
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 })
|
|
23653
24006
|
] });
|
|
23654
24007
|
}
|
|
23655
24008
|
|
|
23656
24009
|
// src/components/LicensePositionBar.tsx
|
|
23657
|
-
var
|
|
24010
|
+
var import_jsx_runtime128 = require("react/jsx-runtime");
|
|
23658
24011
|
var defaultCapacityFormat = (value) => new Intl.NumberFormat().format(value);
|
|
23659
24012
|
function LicensePositionBar({
|
|
23660
24013
|
consumed,
|
|
@@ -23675,18 +24028,18 @@ function LicensePositionBar({
|
|
|
23675
24028
|
const percent = safeEntitled === 0 ? safeConsumed > 0 ? 100 : 0 : safeConsumed / safeEntitled * 100;
|
|
23676
24029
|
const format = (value) => `${formatValue(value)}${unit ? ` ${unit}` : ""}`;
|
|
23677
24030
|
const summary = `${consumedLabel}: ${format(safeConsumed)}. ${entitledLabel}: ${format(safeEntitled)}. ${over > 0 ? `${format(over)} ${overLabel}` : `${format(available)} ${availableLabel}`}.`;
|
|
23678
|
-
return /* @__PURE__ */ (0,
|
|
23679
|
-
/* @__PURE__ */ (0,
|
|
23680
|
-
/* @__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: [
|
|
23681
24034
|
format(safeConsumed),
|
|
23682
24035
|
" / ",
|
|
23683
24036
|
format(safeEntitled)
|
|
23684
24037
|
] }),
|
|
23685
|
-
/* @__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}` })
|
|
23686
24039
|
] }),
|
|
23687
|
-
/* @__PURE__ */ (0,
|
|
23688
|
-
/* @__PURE__ */ (0,
|
|
23689
|
-
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)(
|
|
23690
24043
|
"span",
|
|
23691
24044
|
{
|
|
23692
24045
|
className: "uix-license-position__overflow",
|
|
@@ -23695,12 +24048,12 @@ function LicensePositionBar({
|
|
|
23695
24048
|
}
|
|
23696
24049
|
)
|
|
23697
24050
|
] }),
|
|
23698
|
-
/* @__PURE__ */ (0,
|
|
24051
|
+
/* @__PURE__ */ (0, import_jsx_runtime128.jsx)("span", { className: "uix-visually-hidden", children: summary })
|
|
23699
24052
|
] });
|
|
23700
24053
|
}
|
|
23701
24054
|
|
|
23702
24055
|
// src/components/BrandProfiles.tsx
|
|
23703
|
-
var
|
|
24056
|
+
var import_react114 = require("react");
|
|
23704
24057
|
|
|
23705
24058
|
// src/color-model.ts
|
|
23706
24059
|
var clamp2 = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
@@ -23769,8 +24122,8 @@ function meetsContrast(background, foreground, minimum = 4.5) {
|
|
|
23769
24122
|
}
|
|
23770
24123
|
|
|
23771
24124
|
// src/components/ColorPicker.tsx
|
|
23772
|
-
var
|
|
23773
|
-
var
|
|
24125
|
+
var import_react113 = require("react");
|
|
24126
|
+
var import_jsx_runtime129 = require("react/jsx-runtime");
|
|
23774
24127
|
var DEFAULT_COLOR_PICKER_LABELS = {
|
|
23775
24128
|
trigger: "{label}: {color}",
|
|
23776
24129
|
sample: "Aa",
|
|
@@ -23801,17 +24154,17 @@ function ColorPicker({
|
|
|
23801
24154
|
labels: labelOverrides
|
|
23802
24155
|
}) {
|
|
23803
24156
|
const labels = { ...DEFAULT_COLOR_PICKER_LABELS, ...labelOverrides };
|
|
23804
|
-
const id = (0,
|
|
23805
|
-
const triggerRef = (0,
|
|
23806
|
-
const dialogRef = (0,
|
|
23807
|
-
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);
|
|
23808
24161
|
const normalized = normalizeHex(value) ?? "#000000";
|
|
23809
|
-
const [hexText, setHexText] = (0,
|
|
23810
|
-
const hsv = (0,
|
|
24162
|
+
const [hexText, setHexText] = (0, import_react113.useState)(normalized);
|
|
24163
|
+
const hsv = (0, import_react113.useMemo)(() => rgbToHsv(hexToRgb(normalized)), [normalized]);
|
|
23811
24164
|
const ratio = contrastRatio(normalized, foreground) ?? 0;
|
|
23812
24165
|
const passes = ratio >= minimumContrast;
|
|
23813
|
-
(0,
|
|
23814
|
-
(0,
|
|
24166
|
+
(0, import_react113.useEffect)(() => setHexText(normalized), [normalized]);
|
|
24167
|
+
(0, import_react113.useEffect)(() => {
|
|
23815
24168
|
if (!open) return;
|
|
23816
24169
|
const dialog = dialogRef.current;
|
|
23817
24170
|
dialog?.querySelector("input,button")?.focus();
|
|
@@ -23854,8 +24207,8 @@ function ColorPicker({
|
|
|
23854
24207
|
if (next) onChange(next);
|
|
23855
24208
|
};
|
|
23856
24209
|
const sampleStyle = { backgroundColor: normalized };
|
|
23857
|
-
return /* @__PURE__ */ (0,
|
|
23858
|
-
/* @__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)(
|
|
23859
24212
|
"button",
|
|
23860
24213
|
{
|
|
23861
24214
|
ref: triggerRef,
|
|
@@ -23867,12 +24220,12 @@ function ColorPicker({
|
|
|
23867
24220
|
onClick: () => setOpen((current) => !current),
|
|
23868
24221
|
disabled,
|
|
23869
24222
|
children: [
|
|
23870
|
-
/* @__PURE__ */ (0,
|
|
23871
|
-
/* @__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 })
|
|
23872
24225
|
]
|
|
23873
24226
|
}
|
|
23874
24227
|
),
|
|
23875
|
-
open && /* @__PURE__ */ (0,
|
|
24228
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(
|
|
23876
24229
|
"div",
|
|
23877
24230
|
{
|
|
23878
24231
|
ref: dialogRef,
|
|
@@ -23883,55 +24236,55 @@ function ColorPicker({
|
|
|
23883
24236
|
className: "uix-color-picker__popover",
|
|
23884
24237
|
onKeyDown: onDialogKeyDown,
|
|
23885
24238
|
children: [
|
|
23886
|
-
/* @__PURE__ */ (0,
|
|
23887
|
-
/* @__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: [
|
|
23888
24241
|
labels.hue,
|
|
23889
24242
|
" ",
|
|
23890
|
-
/* @__PURE__ */ (0,
|
|
24243
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("span", { children: [
|
|
23891
24244
|
Math.round(hsv.h),
|
|
23892
24245
|
"\xB0"
|
|
23893
24246
|
] }),
|
|
23894
|
-
/* @__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) }) })
|
|
23895
24248
|
] }),
|
|
23896
|
-
/* @__PURE__ */ (0,
|
|
24249
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("label", { className: "uix-color-picker__range", children: [
|
|
23897
24250
|
labels.saturation,
|
|
23898
24251
|
" ",
|
|
23899
|
-
/* @__PURE__ */ (0,
|
|
24252
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("span", { children: [
|
|
23900
24253
|
Math.round(hsv.s * 100),
|
|
23901
24254
|
"%"
|
|
23902
24255
|
] }),
|
|
23903
|
-
/* @__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 }) })
|
|
23904
24257
|
] }),
|
|
23905
|
-
/* @__PURE__ */ (0,
|
|
24258
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("label", { className: "uix-color-picker__range", children: [
|
|
23906
24259
|
labels.brightness,
|
|
23907
24260
|
" ",
|
|
23908
|
-
/* @__PURE__ */ (0,
|
|
24261
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("span", { children: [
|
|
23909
24262
|
Math.round(hsv.v * 100),
|
|
23910
24263
|
"%"
|
|
23911
24264
|
] }),
|
|
23912
|
-
/* @__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 }) })
|
|
23913
24266
|
] }),
|
|
23914
|
-
/* @__PURE__ */ (0,
|
|
24267
|
+
/* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("label", { className: "uix-color-picker__hex", children: [
|
|
23915
24268
|
labels.hex,
|
|
23916
|
-
/* @__PURE__ */ (0,
|
|
23917
|
-
/* @__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) => {
|
|
23918
24271
|
if (event.key === "Enter") commitHex();
|
|
23919
24272
|
}, "aria-invalid": !normalizeHex(hexText) }),
|
|
23920
|
-
/* @__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 })
|
|
23921
24274
|
] })
|
|
23922
24275
|
] }),
|
|
23923
|
-
(presets.length > 0 || recent.length > 0) && /* @__PURE__ */ (0,
|
|
23924
|
-
presets.length > 0 && /* @__PURE__ */ (0,
|
|
23925
|
-
/* @__PURE__ */ (0,
|
|
23926
|
-
/* @__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)) })
|
|
23927
24280
|
] }),
|
|
23928
|
-
recent.length > 0 && /* @__PURE__ */ (0,
|
|
23929
|
-
/* @__PURE__ */ (0,
|
|
23930
|
-
/* @__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)) })
|
|
23931
24284
|
] })
|
|
23932
24285
|
] }),
|
|
23933
|
-
/* @__PURE__ */ (0,
|
|
23934
|
-
/* @__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 })
|
|
23935
24288
|
]
|
|
23936
24289
|
}
|
|
23937
24290
|
)
|
|
@@ -23939,7 +24292,7 @@ function ColorPicker({
|
|
|
23939
24292
|
}
|
|
23940
24293
|
|
|
23941
24294
|
// src/components/BrandProfiles.tsx
|
|
23942
|
-
var
|
|
24295
|
+
var import_jsx_runtime130 = require("react/jsx-runtime");
|
|
23943
24296
|
var PROFILE_PROPERTIES = {
|
|
23944
24297
|
brand: "--uix-brand",
|
|
23945
24298
|
brandForeground: "--uix-brand-fg",
|
|
@@ -24031,7 +24384,7 @@ function BrandProfileEditor({
|
|
|
24031
24384
|
labels: labelOverrides
|
|
24032
24385
|
}) {
|
|
24033
24386
|
const labels = { ...DEFAULT_BRAND_PROFILE_EDITOR_LABELS, ...labelOverrides };
|
|
24034
|
-
const [announcement, setAnnouncement] = (0,
|
|
24387
|
+
const [announcement, setAnnouncement] = (0, import_react114.useState)("");
|
|
24035
24388
|
const update = (patch) => onChange({ ...value, ...patch });
|
|
24036
24389
|
const apply = () => {
|
|
24037
24390
|
if (applyTarget !== null) applyBrandProfile(value, applyTarget);
|
|
@@ -24048,54 +24401,54 @@ function BrandProfileEditor({
|
|
|
24048
24401
|
...value.typography?.sans ? { "--uix-font-sans": value.typography.sans } : {},
|
|
24049
24402
|
...value.typography?.heading ? { "--uix-font-heading": value.typography.heading } : {}
|
|
24050
24403
|
};
|
|
24051
|
-
return /* @__PURE__ */ (0,
|
|
24052
|
-
/* @__PURE__ */ (0,
|
|
24053
|
-
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: [
|
|
24054
24407
|
labels.profile,
|
|
24055
|
-
/* @__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) => {
|
|
24056
24409
|
const selected = profiles.find((profile) => profile.id === next);
|
|
24057
24410
|
if (selected) onSelectProfile?.(selected);
|
|
24058
24411
|
} })
|
|
24059
24412
|
] }),
|
|
24060
|
-
/* @__PURE__ */ (0,
|
|
24413
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("label", { className: "uix-field__label", children: [
|
|
24061
24414
|
labels.name,
|
|
24062
|
-
/* @__PURE__ */ (0,
|
|
24415
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsx)("input", { className: "uix-input", value: value.name, onChange: (event) => update({ name: event.currentTarget.value }) })
|
|
24063
24416
|
] }),
|
|
24064
|
-
/* @__PURE__ */ (0,
|
|
24065
|
-
/* @__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: [
|
|
24066
24419
|
labels.brand,
|
|
24067
|
-
/* @__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 }) })
|
|
24068
24421
|
] }),
|
|
24069
|
-
/* @__PURE__ */ (0,
|
|
24422
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("label", { children: [
|
|
24070
24423
|
labels.onBrand,
|
|
24071
|
-
/* @__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 }) })
|
|
24072
24425
|
] })
|
|
24073
24426
|
] }),
|
|
24074
|
-
/* @__PURE__ */ (0,
|
|
24427
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("label", { className: "uix-field__label", children: [
|
|
24075
24428
|
labels.bodyFont,
|
|
24076
|
-
/* @__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 } }) })
|
|
24077
24430
|
] }),
|
|
24078
|
-
/* @__PURE__ */ (0,
|
|
24431
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("label", { className: "uix-field__label", children: [
|
|
24079
24432
|
labels.headingFont,
|
|
24080
|
-
/* @__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 } }) })
|
|
24081
24434
|
] }),
|
|
24082
|
-
/* @__PURE__ */ (0,
|
|
24435
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("label", { className: "uix-file-upload uix-brand-profiles__upload", children: [
|
|
24083
24436
|
labels.logoFile,
|
|
24084
|
-
/* @__PURE__ */ (0,
|
|
24437
|
+
/* @__PURE__ */ (0, import_jsx_runtime130.jsx)("input", { type: "file", accept: "image/*", onChange: onFile })
|
|
24085
24438
|
] }),
|
|
24086
|
-
/* @__PURE__ */ (0,
|
|
24087
|
-
/* @__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 })
|
|
24088
24441
|
] }),
|
|
24089
|
-
/* @__PURE__ */ (0,
|
|
24090
|
-
/* @__PURE__ */ (0,
|
|
24091
|
-
value.logo ? /* @__PURE__ */ (0,
|
|
24092
|
-
/* @__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 })
|
|
24093
24446
|
] }),
|
|
24094
|
-
/* @__PURE__ */ (0,
|
|
24095
|
-
/* @__PURE__ */ (0,
|
|
24096
|
-
/* @__PURE__ */ (0,
|
|
24097
|
-
/* @__PURE__ */ (0,
|
|
24098
|
-
/* @__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 })
|
|
24099
24452
|
] })
|
|
24100
24453
|
] })
|
|
24101
24454
|
] });
|
|
@@ -24103,7 +24456,7 @@ function BrandProfileEditor({
|
|
|
24103
24456
|
var BrandProfiles = BrandProfileEditor;
|
|
24104
24457
|
|
|
24105
24458
|
// src/components/DiffViewer.tsx
|
|
24106
|
-
var
|
|
24459
|
+
var import_react115 = require("react");
|
|
24107
24460
|
|
|
24108
24461
|
// src/diff-model.ts
|
|
24109
24462
|
function isJsonObject(value) {
|
|
@@ -24154,7 +24507,7 @@ function summarizeDiff(entries, resolutions = {}) {
|
|
|
24154
24507
|
}
|
|
24155
24508
|
|
|
24156
24509
|
// src/components/DiffViewer.tsx
|
|
24157
|
-
var
|
|
24510
|
+
var import_jsx_runtime131 = require("react/jsx-runtime");
|
|
24158
24511
|
var DEFAULT_DIFF_VIEWER_LABELS = {
|
|
24159
24512
|
base: "Base",
|
|
24160
24513
|
current: "Current",
|
|
@@ -24202,38 +24555,38 @@ function DiffViewer({
|
|
|
24202
24555
|
const labels = { ...DEFAULT_DIFF_VIEWER_LABELS, ...useUixLabels().diffViewer, ...labelOverrides };
|
|
24203
24556
|
const nameOf = (path) => {
|
|
24204
24557
|
const node = labelFor?.(path);
|
|
24205
|
-
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 };
|
|
24206
24559
|
return { node, text: typeof node === "string" || typeof node === "number" ? String(node) : path };
|
|
24207
24560
|
};
|
|
24208
24561
|
const resolutionLabel = { accept: labels.resolutionAccept, skip: labels.resolutionSkip, pending: labels.resolutionPending };
|
|
24209
24562
|
const buttonSize = controlSize === "md" ? void 0 : `uix-btn--${controlSize}`;
|
|
24210
|
-
const id = (0,
|
|
24211
|
-
const entries = (0,
|
|
24212
|
-
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)({});
|
|
24213
24566
|
const resolutions = controlledResolutions ?? internalResolutions;
|
|
24214
24567
|
const summary = summarizeDiff(entries, resolutions);
|
|
24215
24568
|
const resolve = (path, resolution) => {
|
|
24216
24569
|
if (controlledResolutions === void 0) setInternalResolutions((currentState) => ({ ...currentState, [path]: resolution }));
|
|
24217
24570
|
onResolutionChange?.(path, resolution);
|
|
24218
24571
|
};
|
|
24219
|
-
if (entries.length === 0) return /* @__PURE__ */ (0,
|
|
24220
|
-
/* @__PURE__ */ (0,
|
|
24221
|
-
/* @__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 })
|
|
24222
24575
|
] });
|
|
24223
|
-
return /* @__PURE__ */ (0,
|
|
24224
|
-
/* @__PURE__ */ (0,
|
|
24225
|
-
GROUPS.map((kind) => /* @__PURE__ */ (0,
|
|
24226
|
-
/* @__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] }),
|
|
24227
24580
|
" ",
|
|
24228
24581
|
labels[kind].toLowerCase()
|
|
24229
24582
|
] }, kind)),
|
|
24230
|
-
/* @__PURE__ */ (0,
|
|
24231
|
-
/* @__PURE__ */ (0,
|
|
24583
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("span", { children: [
|
|
24584
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsx)("b", { children: summary.resolved }),
|
|
24232
24585
|
" ",
|
|
24233
24586
|
labels.resolved
|
|
24234
24587
|
] }),
|
|
24235
|
-
/* @__PURE__ */ (0,
|
|
24236
|
-
/* @__PURE__ */ (0,
|
|
24588
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("span", { children: [
|
|
24589
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsx)("b", { children: summary.pending }),
|
|
24237
24590
|
" ",
|
|
24238
24591
|
labels.pending
|
|
24239
24592
|
] })
|
|
@@ -24241,43 +24594,43 @@ function DiffViewer({
|
|
|
24241
24594
|
GROUPS.map((kind) => {
|
|
24242
24595
|
const grouped = entries.filter((entry) => entry.kind === kind);
|
|
24243
24596
|
if (!grouped.length) return null;
|
|
24244
|
-
return /* @__PURE__ */ (0,
|
|
24245
|
-
/* @__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: [
|
|
24246
24599
|
labels[kind],
|
|
24247
24600
|
" ",
|
|
24248
|
-
/* @__PURE__ */ (0,
|
|
24601
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsx)("span", { children: grouped.length })
|
|
24249
24602
|
] }),
|
|
24250
24603
|
grouped.map((entry) => {
|
|
24251
24604
|
const resolution = resolutions[entry.path] ?? "pending";
|
|
24252
24605
|
const name = nameOf(entry.path);
|
|
24253
|
-
return /* @__PURE__ */ (0,
|
|
24254
|
-
/* @__PURE__ */ (0,
|
|
24255
|
-
/* @__PURE__ */ (0,
|
|
24256
|
-
/* @__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] })
|
|
24257
24610
|
] }),
|
|
24258
|
-
/* @__PURE__ */ (0,
|
|
24611
|
+
/* @__PURE__ */ (0, import_jsx_runtime131.jsx)("div", { className: "uix-diff-viewer__versions", children: ["base", "current", "incoming"].map((version) => {
|
|
24259
24612
|
const origin = provenance?.(entry.path, version);
|
|
24260
|
-
return /* @__PURE__ */ (0,
|
|
24261
|
-
/* @__PURE__ */ (0,
|
|
24262
|
-
renderValue ? /* @__PURE__ */ (0,
|
|
24263
|
-
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 })
|
|
24264
24617
|
] }, version);
|
|
24265
24618
|
}) }),
|
|
24266
|
-
/* @__PURE__ */ (0,
|
|
24267
|
-
/* @__PURE__ */ (0,
|
|
24268
|
-
/* @__PURE__ */ (0,
|
|
24269
|
-
/* @__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 })
|
|
24270
24623
|
] })
|
|
24271
24624
|
] }, entry.path);
|
|
24272
24625
|
})
|
|
24273
24626
|
] }, kind);
|
|
24274
24627
|
}),
|
|
24275
|
-
/* @__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 }) })
|
|
24276
24629
|
] });
|
|
24277
24630
|
}
|
|
24278
24631
|
|
|
24279
24632
|
// src/components/TextDiff.tsx
|
|
24280
|
-
var
|
|
24633
|
+
var import_react116 = require("react");
|
|
24281
24634
|
|
|
24282
24635
|
// src/text-diff-model.ts
|
|
24283
24636
|
var WORD_TOKENS = /\s+|[\p{L}\p{M}\p{N}_]+|[^\s\p{L}\p{M}\p{N}_]/gu;
|
|
@@ -24537,7 +24890,7 @@ function textDiffRows(result, { context } = {}) {
|
|
|
24537
24890
|
}
|
|
24538
24891
|
|
|
24539
24892
|
// src/components/TextDiff.tsx
|
|
24540
|
-
var
|
|
24893
|
+
var import_jsx_runtime132 = require("react/jsx-runtime");
|
|
24541
24894
|
var DEFAULT_TEXT_DIFF_LABELS = {
|
|
24542
24895
|
before: "Before",
|
|
24543
24896
|
after: "After",
|
|
@@ -24550,47 +24903,47 @@ var DEFAULT_TEXT_DIFF_LABELS = {
|
|
|
24550
24903
|
};
|
|
24551
24904
|
function Marked({ segments, side, labels, whole: whole2 }) {
|
|
24552
24905
|
const Tag = side === "before" ? "del" : "ins";
|
|
24553
|
-
return /* @__PURE__ */ (0,
|
|
24554
|
-
/* @__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: [
|
|
24555
24908
|
side === "before" ? labels.removed : labels.added,
|
|
24556
24909
|
": "
|
|
24557
24910
|
] }),
|
|
24558
24911
|
segment.text
|
|
24559
|
-
] }, i) : /* @__PURE__ */ (0,
|
|
24912
|
+
] }, i) : /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_react116.Fragment, { children: segment.text }, i)) });
|
|
24560
24913
|
}
|
|
24561
|
-
function
|
|
24562
|
-
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" });
|
|
24563
24916
|
const changed = kind !== "equal";
|
|
24564
|
-
return /* @__PURE__ */ (0,
|
|
24565
|
-
/* @__PURE__ */ (0,
|
|
24566
|
-
/* @__PURE__ */ (0,
|
|
24567
|
-
/* @__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 }) })
|
|
24568
24921
|
] });
|
|
24569
24922
|
}
|
|
24570
24923
|
function Rows({ rows, view, labels, focusFirst }) {
|
|
24571
|
-
const [open, setOpen] = (0,
|
|
24572
|
-
const first = (0,
|
|
24573
|
-
(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)(() => {
|
|
24574
24927
|
if (focusFirst) first.current?.focus();
|
|
24575
24928
|
}, [focusFirst]);
|
|
24576
24929
|
const firstProps = (index) => focusFirst && index === 0 ? { ref: first, tabIndex: -1 } : {};
|
|
24577
|
-
return /* @__PURE__ */ (0,
|
|
24930
|
+
return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_jsx_runtime132.Fragment, { children: rows.map((row, index) => {
|
|
24578
24931
|
if (row.kind === "fold") {
|
|
24579
|
-
if (open.has(index)) return /* @__PURE__ */ (0,
|
|
24580
|
-
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);
|
|
24581
24934
|
}
|
|
24582
24935
|
const before = row.kind === "insert" ? void 0 : row.before;
|
|
24583
24936
|
const after = row.kind === "delete" ? void 0 : row.after;
|
|
24584
24937
|
if (view === "unified") {
|
|
24585
|
-
if (row.kind === "equal") return /* @__PURE__ */ (0,
|
|
24586
|
-
return /* @__PURE__ */ (0,
|
|
24587
|
-
before && /* @__PURE__ */ (0,
|
|
24588
|
-
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 }) })
|
|
24589
24942
|
] }, index);
|
|
24590
24943
|
}
|
|
24591
|
-
return /* @__PURE__ */ (0,
|
|
24592
|
-
/* @__PURE__ */ (0,
|
|
24593
|
-
/* @__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 })
|
|
24594
24947
|
] }, index);
|
|
24595
24948
|
}) });
|
|
24596
24949
|
}
|
|
@@ -24612,41 +24965,41 @@ function TextDiff({
|
|
|
24612
24965
|
}) {
|
|
24613
24966
|
const uixLabels = useUixLabels();
|
|
24614
24967
|
const labels = { ...DEFAULT_TEXT_DIFF_LABELS, ...uixLabels.textDiff, ...labelOverrides };
|
|
24615
|
-
const result = (0,
|
|
24616
|
-
const rows = (0,
|
|
24617
|
-
const heads = /* @__PURE__ */ (0,
|
|
24618
|
-
/* @__PURE__ */ (0,
|
|
24619
|
-
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 " }),
|
|
24620
24973
|
beforeLabel ?? labels.before
|
|
24621
24974
|
] }),
|
|
24622
|
-
/* @__PURE__ */ (0,
|
|
24623
|
-
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: "+ " }),
|
|
24624
24977
|
afterLabel ?? labels.after
|
|
24625
24978
|
] })
|
|
24626
24979
|
] });
|
|
24627
24980
|
const unchanged = result.status === "ok" && result.added === 0 && result.removed === 0 && result.ops.every((op) => op.type === "equal");
|
|
24628
24981
|
let body;
|
|
24629
|
-
if (result.status === "too-large") body = /* @__PURE__ */ (0,
|
|
24630
|
-
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 }) });
|
|
24631
24984
|
else {
|
|
24632
|
-
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) => {
|
|
24633
24986
|
const text = op.tokens.join("");
|
|
24634
|
-
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);
|
|
24635
24988
|
if (op.type === "delete" && side2 === "after") return null;
|
|
24636
24989
|
if (op.type === "insert" && side2 === "before") return null;
|
|
24637
|
-
return /* @__PURE__ */ (0,
|
|
24990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Marked, { segments: [{ text, changed: true }], side: op.type === "delete" ? "before" : "after", labels }, i);
|
|
24638
24991
|
}) });
|
|
24639
|
-
const side = (which) => /* @__PURE__ */ (0,
|
|
24640
|
-
/* @__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 }),
|
|
24641
24994
|
prose(which)
|
|
24642
24995
|
] });
|
|
24643
|
-
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: [
|
|
24644
24997
|
side("before"),
|
|
24645
24998
|
side("after")
|
|
24646
24999
|
] }) });
|
|
24647
25000
|
}
|
|
24648
|
-
return /* @__PURE__ */ (0,
|
|
24649
|
-
!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 }) }),
|
|
24650
25003
|
!(granularity === "word" && view === "split" && result.status === "ok") && heads,
|
|
24651
25004
|
body
|
|
24652
25005
|
] });
|
|
@@ -24810,6 +25163,8 @@ function TextDiff({
|
|
|
24810
25163
|
LocaleSwitcher,
|
|
24811
25164
|
Mark,
|
|
24812
25165
|
MatchReview,
|
|
25166
|
+
MatrixHeatmap,
|
|
25167
|
+
MatrixInput,
|
|
24813
25168
|
Menu,
|
|
24814
25169
|
MenuGroup,
|
|
24815
25170
|
MenuItem,
|