@tensor_1/react 2.22.0 → 2.24.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 +20 -0
- package/dist/components/DiffViewer.d.ts +15 -1
- package/dist/components/DiffViewer.js +11 -6
- package/dist/components/EditorIcons.d.ts +2 -0
- package/dist/components/EditorIcons.js +3 -1
- package/dist/components/TableControls.d.ts +77 -10
- package/dist/components/TableControls.js +397 -20
- package/dist/emoji.cjs +3 -1
- package/dist/index.cjs +978 -545
- package/dist/index.d.cts +92 -11
- package/dist/index.d.ts +1 -1
- package/dist/rich-text.cjs +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -205,4 +205,24 @@ Radial mode still shortens long labels to fit its ring, but every node carries i
|
|
|
205
205
|
<CopyButton value={email} label={t('copyEmail')} copiedLabel={t('copied')} failedLabel={t('copyFailed')} />
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
+
### DiffViewer words and control size
|
|
209
|
+
|
|
210
|
+
- **Every word is a label.** `labels` (a `Partial<DiffViewerLabels>`, English defaults in `DEFAULT_DIFF_VIEWER_LABELS`) covers the version names, group titles, the summary, the live progress text, and the action buttons.
|
|
211
|
+
- **Each action is named for its entry.** The visible words come from `acceptIncoming` / `keepCurrent` / `markPending`. The accessible names come from `acceptIncomingFor` / `keepCurrentFor` / `markPendingFor`, e.g. "Accept incoming for $.limit". Each entry's three buttons sit in a group named by `resolve`. When you translate a name, keep the visible word inside it, so people using speech input can say what they see (WCAG 2.5.3).
|
|
212
|
+
- **`controlSize`** sets the height of the action buttons and the entry rows. `sm` (the default) is the compact 28px kit size. `md` follows `--uix-control-h`, so a theme with 60px controls gets 60px actions. `lg` is 44px.
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
<DiffViewer
|
|
216
|
+
base={published} current={draft} incoming={remote}
|
|
217
|
+
controlSize="md"
|
|
218
|
+
labels={{
|
|
219
|
+
acceptIncoming: t('acceptIncoming'), acceptIncomingFor: t('acceptIncomingFor'), // 'Prihvati dolazno za {path}'
|
|
220
|
+
keepCurrent: t('keepCurrent'), keepCurrentFor: t('keepCurrentFor'),
|
|
221
|
+
markPending: t('markPending'), markPendingFor: t('markPendingFor'),
|
|
222
|
+
resolve: t('resolve'), /* …the rest of DiffViewerLabels */
|
|
223
|
+
}}
|
|
224
|
+
onResolutionChange={record}
|
|
225
|
+
/>
|
|
226
|
+
```
|
|
227
|
+
|
|
208
228
|
Ships **ESM + CJS + types**, with per-file `"use client"` so it's safe under React Server Components. Part of the **[UIx v2 styleguide](https://github.com/COx-ORG-H/UIx)**.
|
|
@@ -6,6 +6,11 @@ import { DiffEntry, DiffResolution } from '../diff-model.js';
|
|
|
6
6
|
* Every word the diff viewer renders (TENSOR RX-125, UIX-12). `base` / `current` /
|
|
7
7
|
* `incoming` keep their meaning from before; `{path}`, `{version}`, `{resolved}` and
|
|
8
8
|
* `{total}` are placeholders.
|
|
9
|
+
*
|
|
10
|
+
* `acceptIncomingFor` / `keepCurrentFor` / `markPendingFor` are the accessible names of
|
|
11
|
+
* the three action buttons, so a screen reader hears which entry each one resolves. Keep
|
|
12
|
+
* the visible word inside the translated name (WCAG 2.5.3 Label in Name): speech-input
|
|
13
|
+
* users say what they see.
|
|
9
14
|
*/
|
|
10
15
|
interface DiffViewerLabels {
|
|
11
16
|
base: string;
|
|
@@ -26,6 +31,9 @@ interface DiffViewerLabels {
|
|
|
26
31
|
acceptIncoming: string;
|
|
27
32
|
keepCurrent: string;
|
|
28
33
|
markPending: string;
|
|
34
|
+
acceptIncomingFor: string;
|
|
35
|
+
keepCurrentFor: string;
|
|
36
|
+
markPendingFor: string;
|
|
29
37
|
resolutionAccept: string;
|
|
30
38
|
resolutionSkip: string;
|
|
31
39
|
resolutionPending: string;
|
|
@@ -41,9 +49,15 @@ interface DiffViewerProps {
|
|
|
41
49
|
resolutions?: Record<string, DiffResolution>;
|
|
42
50
|
onResolutionChange?: (path: string, resolution: DiffResolution) => void;
|
|
43
51
|
labels?: Partial<DiffViewerLabels>;
|
|
52
|
+
/**
|
|
53
|
+
* Height of the resolution buttons and the entry disclosure rows. `sm` (the default) is
|
|
54
|
+
* the compact 28px kit size; `md` follows `--uix-control-h`, so a theme that sets its
|
|
55
|
+
* own control height (for example 60px touch targets) gets it here too; `lg` is 44px.
|
|
56
|
+
*/
|
|
57
|
+
controlSize?: 'sm' | 'md' | 'lg';
|
|
44
58
|
className?: string;
|
|
45
59
|
}
|
|
46
60
|
/** Three-way configuration diff with per-entry keyboard-operable resolution. */
|
|
47
|
-
declare function DiffViewer({ base, current, incoming, entries: providedEntries, resolutions: controlledResolutions, onResolutionChange, labels: labelOverrides, className, }: DiffViewerProps): react.JSX.Element;
|
|
61
|
+
declare function DiffViewer({ base, current, incoming, entries: providedEntries, resolutions: controlledResolutions, onResolutionChange, labels: labelOverrides, controlSize, className, }: DiffViewerProps): react.JSX.Element;
|
|
48
62
|
|
|
49
63
|
export { DEFAULT_DIFF_VIEWER_LABELS, DiffViewer, type DiffViewerLabels, type DiffViewerProps };
|
|
@@ -24,6 +24,9 @@ const DEFAULT_DIFF_VIEWER_LABELS = {
|
|
|
24
24
|
acceptIncoming: "Accept incoming",
|
|
25
25
|
keepCurrent: "Keep current",
|
|
26
26
|
markPending: "Mark pending",
|
|
27
|
+
acceptIncomingFor: "Accept incoming for {path}",
|
|
28
|
+
keepCurrentFor: "Keep current for {path}",
|
|
29
|
+
markPendingFor: "Mark pending for {path}",
|
|
27
30
|
resolutionAccept: "accepted",
|
|
28
31
|
resolutionSkip: "kept",
|
|
29
32
|
resolutionPending: "pending",
|
|
@@ -40,10 +43,12 @@ function DiffViewer({
|
|
|
40
43
|
resolutions: controlledResolutions,
|
|
41
44
|
onResolutionChange,
|
|
42
45
|
labels: labelOverrides,
|
|
46
|
+
controlSize = "sm",
|
|
43
47
|
className
|
|
44
48
|
}) {
|
|
45
49
|
const labels = { ...DEFAULT_DIFF_VIEWER_LABELS, ...labelOverrides };
|
|
46
50
|
const resolutionLabel = { accept: labels.resolutionAccept, skip: labels.resolutionSkip, pending: labels.resolutionPending };
|
|
51
|
+
const buttonSize = controlSize === "md" ? void 0 : `uix-btn--${controlSize}`;
|
|
47
52
|
const id = useId();
|
|
48
53
|
const entries = useMemo(() => providedEntries ?? buildThreeWayDiff(base, current, incoming), [providedEntries, base, current, incoming]);
|
|
49
54
|
const [internalResolutions, setInternalResolutions] = useState({});
|
|
@@ -57,8 +62,8 @@ function DiffViewer({
|
|
|
57
62
|
/* @__PURE__ */ jsx("h3", { children: labels.noDifferences }),
|
|
58
63
|
/* @__PURE__ */ jsx("p", { children: labels.noDifferencesDetail })
|
|
59
64
|
] });
|
|
60
|
-
return /* @__PURE__ */ jsxs("section", { className: cx("uix-diff-viewer", className), "aria-label": labels.region, children: [
|
|
61
|
-
/* @__PURE__ */ jsxs("div", { className: "uix-diff-viewer__summary", "aria-label": labels.summary, children: [
|
|
65
|
+
return /* @__PURE__ */ jsxs("section", { className: cx("uix-diff-viewer", className), "aria-label": labels.region, "data-control-size": controlSize, children: [
|
|
66
|
+
/* @__PURE__ */ jsxs("div", { className: "uix-diff-viewer__summary", role: "group", "aria-label": labels.summary, children: [
|
|
62
67
|
GROUPS.map((kind) => /* @__PURE__ */ jsxs("span", { children: [
|
|
63
68
|
/* @__PURE__ */ jsx("b", { children: summary[kind] }),
|
|
64
69
|
" ",
|
|
@@ -95,10 +100,10 @@ function DiffViewer({
|
|
|
95
100
|
/* @__PURE__ */ jsx("strong", { children: labels[version] }),
|
|
96
101
|
/* @__PURE__ */ jsx("pre", { children: renderValue(entry[version], labels.notPresent) })
|
|
97
102
|
] }, version)) }),
|
|
98
|
-
/* @__PURE__ */ jsxs("div", { className: "uix-diff-viewer__actions", "aria-label": fillLabel(labels.resolve, { path: entry.path }), children: [
|
|
99
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "uix-btn uix-btn--primary
|
|
100
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "uix-btn uix-btn--secondary
|
|
101
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "uix-btn uix-btn--ghost
|
|
103
|
+
/* @__PURE__ */ jsxs("div", { className: "uix-diff-viewer__actions", role: "group", "aria-label": fillLabel(labels.resolve, { path: entry.path }), children: [
|
|
104
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: cx("uix-btn uix-btn--primary", buttonSize), "aria-label": fillLabel(labels.acceptIncomingFor, { path: entry.path }), "aria-pressed": resolution === "accept", onClick: () => resolve(entry.path, "accept"), children: labels.acceptIncoming }),
|
|
105
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: cx("uix-btn uix-btn--secondary", buttonSize), "aria-label": fillLabel(labels.keepCurrentFor, { path: entry.path }), "aria-pressed": resolution === "skip", onClick: () => resolve(entry.path, "skip"), children: labels.keepCurrent }),
|
|
106
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: cx("uix-btn uix-btn--ghost", buttonSize), "aria-label": fillLabel(labels.markPendingFor, { path: entry.path }), "aria-pressed": resolution === "pending", onClick: () => resolve(entry.path, "pending"), children: labels.markPending })
|
|
102
107
|
] })
|
|
103
108
|
] }, entry.path);
|
|
104
109
|
})
|
|
@@ -30,6 +30,8 @@ declare const PATHS: {
|
|
|
30
30
|
readonly sourceMode: "M10 12.5 8 15l2 2.5M14 12.5l2 2.5-2 2.5M14 2v4a2 2 0 0 0 2 2h4M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z";
|
|
31
31
|
readonly richMode: "M14 2v4a2 2 0 0 0 2 2h4M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7ZM8 13h8M8 17h5";
|
|
32
32
|
readonly clock: "M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20ZM12 6v6l4 2";
|
|
33
|
+
readonly grip: "M9 5h.01M9 12h.01M9 19h.01M15 5h.01M15 12h.01M15 19h.01";
|
|
34
|
+
readonly more: "M5 12h.01M12 12h.01M19 12h.01";
|
|
33
35
|
};
|
|
34
36
|
type EditorIconName = keyof typeof PATHS;
|
|
35
37
|
declare function EditorIcon({ name, ...props }: {
|
|
@@ -27,7 +27,9 @@ const PATHS = {
|
|
|
27
27
|
redo: "m15 14 5-5-5-5M20 9H9.5a5.5 5.5 0 0 0 0 11H13",
|
|
28
28
|
sourceMode: "M10 12.5 8 15l2 2.5M14 12.5l2 2.5-2 2.5M14 2v4a2 2 0 0 0 2 2h4M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",
|
|
29
29
|
richMode: "M14 2v4a2 2 0 0 0 2 2h4M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7ZM8 13h8M8 17h5",
|
|
30
|
-
clock: "M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20ZM12 6v6l4 2"
|
|
30
|
+
clock: "M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20ZM12 6v6l4 2",
|
|
31
|
+
grip: "M9 5h.01M9 12h.01M9 19h.01M15 5h.01M15 12h.01M15 19h.01",
|
|
32
|
+
more: "M5 12h.01M12 12h.01M19 12h.01"
|
|
31
33
|
};
|
|
32
34
|
function EditorIcon({ name, ...props }) {
|
|
33
35
|
return /* @__PURE__ */ jsx(
|
|
@@ -6,15 +6,40 @@ interface ViewMenuColumn {
|
|
|
6
6
|
label: ReactNode;
|
|
7
7
|
visible: boolean;
|
|
8
8
|
disabled?: boolean;
|
|
9
|
+
/** Always shown (e.g. the record id): the row has no checkbox and no Hide / Show, its name sits in the checkbox's slot. */
|
|
10
|
+
required?: boolean;
|
|
11
|
+
/** Plain-text name for the `{label}` templates in `columnLabels` when `label` is not a string. */
|
|
12
|
+
textLabel?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Words for the column rows. `{label}` is replaced by the column name; `moved` also gets
|
|
16
|
+
* `{position}` and `{count}`. Every key has an English default.
|
|
17
|
+
*/
|
|
18
|
+
interface ViewMenuColumnLabels {
|
|
19
|
+
/** Name of a row's ⋯ menu button and of the menu. Default `Column actions: {label}`. */
|
|
20
|
+
rowActions: string;
|
|
21
|
+
/** Name of a row's drag grip. Default `Drag to reorder: {label}`. */
|
|
22
|
+
reorder: string;
|
|
23
|
+
moveUp: string;
|
|
24
|
+
moveDown: string;
|
|
25
|
+
hide: string;
|
|
26
|
+
show: string;
|
|
27
|
+
/** Tooltip on a required column's name. Default `Always shown`. */
|
|
28
|
+
required: string;
|
|
29
|
+
/** Polite announcement after a move. Default `{label} moved to position {position} of {count}`. */
|
|
30
|
+
moved: string;
|
|
9
31
|
}
|
|
10
32
|
interface ViewMenuProps {
|
|
11
|
-
density
|
|
12
|
-
|
|
13
|
-
|
|
33
|
+
/** The density section renders when `densityOptions` and `onDensityChange` are given. */
|
|
34
|
+
density?: string;
|
|
35
|
+
densityLabel?: ReactNode;
|
|
36
|
+
densityOptions?: readonly {
|
|
14
37
|
value: string;
|
|
15
38
|
label: ReactNode;
|
|
16
39
|
}[];
|
|
17
|
-
onDensityChange
|
|
40
|
+
onDensityChange?: (value: string) => void;
|
|
41
|
+
/** Optional title over the zebra / freeze switches. */
|
|
42
|
+
displayLabel?: ReactNode;
|
|
18
43
|
zebra?: {
|
|
19
44
|
checked: boolean;
|
|
20
45
|
label: ReactNode;
|
|
@@ -28,9 +53,23 @@ interface ViewMenuProps {
|
|
|
28
53
|
columns?: readonly ViewMenuColumn[];
|
|
29
54
|
columnsLabel?: ReactNode;
|
|
30
55
|
onColumnVisibilityChange?: (id: string, visible: boolean) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Turns on reordering: every column row gets a drag grip (pointer; ArrowUp / ArrowDown once
|
|
58
|
+
* focused) and a ⋯ menu with Move up · Move down · Hide / Show, which is the keyboard path.
|
|
59
|
+
* Receives every column id, first to last. The order is the application's to persist.
|
|
60
|
+
*/
|
|
61
|
+
onReorder?: (orderedIds: string[]) => void;
|
|
62
|
+
columnLabels?: Partial<ViewMenuColumnLabels>;
|
|
63
|
+
/** Pinned under the columns, e.g. a Reset sort `.uix-menu__item` button. */
|
|
64
|
+
footer?: ReactNode;
|
|
65
|
+
className?: string;
|
|
31
66
|
}
|
|
32
|
-
/**
|
|
33
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Controlled table presentation panel with its own surface: density, zebra / freeze and a column
|
|
69
|
+
* list under sticky section titles. A column row is grip · checkbox · name · ⋯ (grip and ⋯ with
|
|
70
|
+
* `onReorder`). Usable inside a Popover or any overlay shell, including one that adds no chrome.
|
|
71
|
+
*/
|
|
72
|
+
declare function ViewMenu({ density, densityLabel, densityOptions, onDensityChange, displayLabel, zebra, freeze, columns, columnsLabel, onColumnVisibilityChange, onReorder, columnLabels, footer, className, }: ViewMenuProps): react.JSX.Element;
|
|
34
73
|
interface FilterOption {
|
|
35
74
|
value: string;
|
|
36
75
|
label: string;
|
|
@@ -55,14 +94,26 @@ interface SavedViewItem {
|
|
|
55
94
|
active?: boolean;
|
|
56
95
|
pinned?: boolean;
|
|
57
96
|
}
|
|
58
|
-
|
|
97
|
+
/** A titled group of saved views, e.g. the user's custom views above the built-in presets. */
|
|
98
|
+
interface SavedViewSection {
|
|
99
|
+
id: string;
|
|
100
|
+
label: ReactNode;
|
|
59
101
|
items: readonly SavedViewItem[];
|
|
102
|
+
}
|
|
103
|
+
interface SavedViewMenuBaseProps {
|
|
60
104
|
onSelect: (id: string) => void;
|
|
61
105
|
emptyLabel?: ReactNode;
|
|
106
|
+
/** The row's overflow slot (e.g. a ⋯ menu trigger). It stays quiet until the row is hovered or focused, or its menu is open. */
|
|
62
107
|
actions?: (item: SavedViewItem) => ReactNode;
|
|
63
108
|
footer?: ReactNode;
|
|
64
109
|
}
|
|
65
110
|
type SavedViewMenuProps = SavedViewMenuBaseProps & ({
|
|
111
|
+
items: readonly SavedViewItem[];
|
|
112
|
+
sections?: never;
|
|
113
|
+
} | {
|
|
114
|
+
sections: readonly SavedViewSection[];
|
|
115
|
+
items?: never;
|
|
116
|
+
}) & ({
|
|
66
117
|
onPinChange: (id: string, pinned: boolean) => void;
|
|
67
118
|
pinLabel: string;
|
|
68
119
|
unpinLabel: string;
|
|
@@ -70,8 +121,24 @@ type SavedViewMenuProps = SavedViewMenuBaseProps & ({
|
|
|
70
121
|
onPinChange?: undefined;
|
|
71
122
|
pinLabel?: never;
|
|
72
123
|
unpinLabel?: never;
|
|
124
|
+
}) & ({
|
|
125
|
+
/**
|
|
126
|
+
* Adds a drag grip to every row. Rows move only within their own section; the
|
|
127
|
+
* callback receives that section's full id order (and its id when `sections` is used).
|
|
128
|
+
* The grip also moves its row with ArrowUp / ArrowDown.
|
|
129
|
+
*/
|
|
130
|
+
onReorder: (orderedIds: string[], sectionId: string | undefined) => void;
|
|
131
|
+
/** Accessible name of the grip; the row's name is attached as its description. */
|
|
132
|
+
reorderLabel: string;
|
|
133
|
+
} | {
|
|
134
|
+
onReorder?: undefined;
|
|
135
|
+
reorderLabel?: never;
|
|
73
136
|
});
|
|
74
|
-
/**
|
|
75
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Generic saved-view selector: optional titled sections inside one `.uix-menu`, rows of
|
|
139
|
+
* grip · name · overflow. The selected row is tinted as a whole (no check glyph). Persistence,
|
|
140
|
+
* ownership, permissions and labels remain application concerns.
|
|
141
|
+
*/
|
|
142
|
+
declare function SavedViewMenu({ items, sections, onSelect, onPinChange, pinLabel, unpinLabel, onReorder, reorderLabel, emptyLabel, actions, footer }: SavedViewMenuProps): react.JSX.Element;
|
|
76
143
|
|
|
77
|
-
export { type FilterOption, FilterPopover, type FilterPopoverProps, type SavedViewItem, SavedViewMenu, type SavedViewMenuProps, ViewMenu, type ViewMenuColumn, type ViewMenuProps };
|
|
144
|
+
export { type FilterOption, FilterPopover, type FilterPopoverProps, type SavedViewItem, SavedViewMenu, type SavedViewMenuProps, type SavedViewSection, ViewMenu, type ViewMenuColumn, type ViewMenuColumnLabels, type ViewMenuProps };
|