@parhelia/localization 0.1.12902 → 0.1.12904

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.
Files changed (73) hide show
  1. package/dist/LocalizeItemCommand.d.ts.map +1 -1
  2. package/dist/LocalizeItemCommand.js +2 -4
  3. package/dist/LocalizeItemDialog.d.ts.map +1 -1
  4. package/dist/LocalizeItemDialog.js +35 -97
  5. package/dist/LocalizeItemUtils.d.ts +2 -1
  6. package/dist/LocalizeItemUtils.d.ts.map +1 -1
  7. package/dist/LocalizeItemUtils.js +36 -78
  8. package/dist/api/discovery.d.ts +0 -25
  9. package/dist/api/discovery.d.ts.map +1 -1
  10. package/dist/api/discovery.js +2 -106
  11. package/dist/constants.d.ts +15 -0
  12. package/dist/constants.d.ts.map +1 -0
  13. package/dist/constants.js +21 -0
  14. package/dist/hooks/useTranslationWizard.d.ts.map +1 -1
  15. package/dist/hooks/useTranslationWizard.js +3 -3
  16. package/dist/index.d.ts +11 -10
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +32 -36
  19. package/dist/services/translationService.d.ts +10 -41
  20. package/dist/services/translationService.d.ts.map +1 -1
  21. package/dist/services/translationService.js +6 -48
  22. package/dist/settings/TranslationServicesPanel.d.ts.map +1 -1
  23. package/dist/settings/TranslationServicesPanel.js +36 -21
  24. package/dist/setup/LocalizationSetupStep.d.ts.map +1 -1
  25. package/dist/setup/LocalizationSetupStep.js +18 -29
  26. package/dist/sidebar/TranslationSidebar.d.ts.map +1 -1
  27. package/dist/sidebar/TranslationSidebar.js +10 -20
  28. package/dist/steps/MetadataInputStep.d.ts +4 -0
  29. package/dist/steps/MetadataInputStep.d.ts.map +1 -0
  30. package/dist/steps/MetadataInputStep.js +41 -0
  31. package/dist/steps/PromptCustomizationStep.d.ts +1 -1
  32. package/dist/steps/PromptCustomizationStep.d.ts.map +1 -1
  33. package/dist/steps/PromptCustomizationStep.js +56 -159
  34. package/dist/steps/ServiceLanguageSelectionStep.d.ts +1 -6
  35. package/dist/steps/ServiceLanguageSelectionStep.d.ts.map +1 -1
  36. package/dist/steps/ServiceLanguageSelectionStep.js +163 -56
  37. package/dist/steps/SubitemDiscoveryStep.d.ts +3 -0
  38. package/dist/steps/SubitemDiscoveryStep.d.ts.map +1 -0
  39. package/dist/steps/SubitemDiscoveryStep.js +313 -0
  40. package/dist/steps/index.d.ts +5 -0
  41. package/dist/steps/index.d.ts.map +1 -0
  42. package/dist/steps/index.js +4 -0
  43. package/dist/steps/types.d.ts +1 -17
  44. package/dist/steps/types.d.ts.map +1 -1
  45. package/dist/translation-center/BatchTranslationView.d.ts +8 -0
  46. package/dist/translation-center/BatchTranslationView.d.ts.map +1 -0
  47. package/dist/translation-center/BatchTranslationView.js +870 -0
  48. package/dist/translation-center/RecentTranslations.d.ts +2 -0
  49. package/dist/translation-center/RecentTranslations.d.ts.map +1 -0
  50. package/dist/translation-center/RecentTranslations.js +309 -0
  51. package/dist/translation-center/TranslationManagement.d.ts.map +1 -1
  52. package/dist/translation-center/TranslationManagement.js +15 -25
  53. package/dist/types.d.ts +0 -1
  54. package/dist/types.d.ts.map +1 -1
  55. package/dist/utils/createVersions.d.ts +14 -0
  56. package/dist/utils/createVersions.d.ts.map +1 -0
  57. package/dist/utils/createVersions.js +26 -0
  58. package/package.json +1 -1
  59. package/dist/steps/ItemSelectionStep.d.ts +0 -3
  60. package/dist/steps/ItemSelectionStep.d.ts.map +0 -1
  61. package/dist/steps/ItemSelectionStep.js +0 -24
  62. package/dist/steps/ItemSelectionTree.d.ts +0 -13
  63. package/dist/steps/ItemSelectionTree.d.ts.map +0 -1
  64. package/dist/steps/ItemSelectionTree.js +0 -327
  65. package/dist/steps/WizardStepShell.d.ts +0 -17
  66. package/dist/steps/WizardStepShell.d.ts.map +0 -1
  67. package/dist/steps/WizardStepShell.js +0 -11
  68. package/dist/translation-center/TranslationBatches.d.ts +0 -2
  69. package/dist/translation-center/TranslationBatches.d.ts.map +0 -1
  70. package/dist/translation-center/TranslationBatches.js +0 -1160
  71. package/dist/translation-center/TranslationsTitlebar.d.ts +0 -6
  72. package/dist/translation-center/TranslationsTitlebar.d.ts.map +0 -1
  73. package/dist/translation-center/TranslationsTitlebar.js +0 -16
@@ -1,327 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
- import { ItemCollectionEditor, } from "@parhelia/core";
4
- import { streamSubitemCount } from "../api/discovery";
5
- const SITECORE_ROOT = "11111111-1111-1111-1111-111111111111";
6
- function fullItemFromDescriptor(descriptor) {
7
- return {
8
- id: descriptor.id,
9
- language: descriptor.language,
10
- version: descriptor.version,
11
- descriptor: {
12
- id: descriptor.id,
13
- language: descriptor.language,
14
- version: descriptor.version,
15
- name: descriptor.name,
16
- displayName: descriptor.displayName,
17
- path: descriptor.path,
18
- },
19
- name: descriptor.name ?? "",
20
- templateId: descriptor.templateId ?? "",
21
- templateName: "",
22
- icon: descriptor.icon ?? "",
23
- largeIcon: descriptor.icon ?? "",
24
- thumbnail: "",
25
- path: descriptor.path ?? "",
26
- fields: [],
27
- canWriteItem: false,
28
- canWriteLanguage: false,
29
- canWriteWorkflow: false,
30
- canRename: false,
31
- canDelete: false,
32
- canCreate: false,
33
- workflowState: "",
34
- hasLock: false,
35
- hasLayout: true,
36
- idPath: descriptor.idPath ?? "",
37
- canLock: false,
38
- lockedBy: "",
39
- isInheritedFromMasterLanguage: false,
40
- hasChildren: descriptor.hasChildren ?? false,
41
- };
42
- }
43
- function fullItemToWithSubtree(item, includeSubitems) {
44
- return {
45
- descriptor: {
46
- id: item.descriptor?.id ?? item.id,
47
- language: item.descriptor?.language ?? item.language,
48
- version: item.descriptor?.version ?? item.version,
49
- name: item.descriptor?.name ?? item.name,
50
- displayName: item.descriptor?.displayName ?? item.displayName,
51
- path: item.descriptor?.path ?? item.path,
52
- },
53
- includeSubitems,
54
- };
55
- }
56
- export function ItemSelectionTree({ data, setData, editContext, isActive = true, onSelectionValidChange, height = 360, }) {
57
- const language = useMemo(() => editContext?.item?.language ??
58
- editContext?.currentItemDescriptor?.language ??
59
- "en", [editContext?.item?.language, editContext?.currentItemDescriptor?.language]);
60
- // Seed selection: prefer previously saved tree items, then discoveredItems,
61
- // then the wizard's initial `items`. Default includeSubitems = legacy flag.
62
- const initialItems = useMemo(() => {
63
- if (data.selectionTreeItems && data.selectionTreeItems.length > 0) {
64
- return data.selectionTreeItems;
65
- }
66
- const seed = data.discoveredItems && data.discoveredItems.length > 0
67
- ? data.discoveredItems
68
- : data.items;
69
- return seed.map((item) => fullItemToWithSubtree(item, !!data.includeSubitems));
70
- // First mount only — once the user edits, wizard data is downstream.
71
- // eslint-disable-next-line react-hooks/exhaustive-deps
72
- }, []);
73
- const [items, setItems] = useState(initialItems);
74
- const [selectedInTree, setSelectedInTree] = useState([]);
75
- const [selectedFromList, setSelectedFromList] = useState([]);
76
- // Async subitem counts keyed by item id. Filtered server-side via
77
- // IItemExportFilter (see TranslationController.DiscoverItemsTree). The
78
- // running count climbs as chunks arrive; `complete` flips true on the
79
- // final chunk so consumers know when to drop the "still counting" hint.
80
- const [subitemCounts, setSubitemCounts] = useState(() => data.subitemCounts ?? {});
81
- // Mirror local subitemCounts into wizardData so later steps (e.g. the
82
- // Start Translation button) can show a live total.
83
- const dataRef = useRef(data);
84
- dataRef.current = data;
85
- useEffect(() => {
86
- setData({ ...dataRef.current, subitemCounts });
87
- }, [subitemCounts, setData]);
88
- // Keep a cache of the richest FullItem we've ever seen for each id so we
89
- // can rebuild discoveredItems without re-fetching.
90
- const itemCacheRef = useRef(new Map());
91
- if (itemCacheRef.current.size === 0) {
92
- for (const it of data.items)
93
- itemCacheRef.current.set(it.id, it);
94
- for (const it of data.discoveredItems || [])
95
- itemCacheRef.current.set(it.id, it);
96
- }
97
- // Build a combined idPath that expands every parent of the current
98
- // selection (but not the items themselves). ContentTree's parser
99
- // extracts each {guid} segment, so concatenating multiple paths works.
100
- const expandIdPath = useMemo(() => {
101
- const segments = [];
102
- for (const entry of items) {
103
- const cached = itemCacheRef.current.get(entry.descriptor.id);
104
- const idPath = cached?.idPath;
105
- if (!idPath)
106
- continue;
107
- const parts = idPath.split("/").filter((s) => s.length > 0);
108
- // Drop the last segment (the item itself) — we only want parents.
109
- parts.pop();
110
- for (const part of parts)
111
- segments.push(part);
112
- }
113
- if (segments.length === 0)
114
- return undefined;
115
- return "/" + segments.join("/");
116
- }, [items]);
117
- const commitToWizard = useCallback((nextItems) => {
118
- const cache = itemCacheRef.current;
119
- const discovered = nextItems.map((entry) => cache.get(entry.descriptor.id) ??
120
- fullItemFromDescriptor(entry.descriptor));
121
- setData({
122
- ...data,
123
- selectionTreeItems: nextItems,
124
- discoveredItems: discovered,
125
- includeSubitems: nextItems.some((i) => i.includeSubitems),
126
- });
127
- }, [data, setData]);
128
- // Commit current state on first mount so wizard data reflects the seed.
129
- const didInitialCommitRef = useRef(false);
130
- useEffect(() => {
131
- if (didInitialCommitRef.current)
132
- return;
133
- didInitialCommitRef.current = true;
134
- commitToWizard(items);
135
- // eslint-disable-next-line react-hooks/exhaustive-deps
136
- }, []);
137
- useEffect(() => {
138
- if (isActive)
139
- onSelectionValidChange?.(items.length > 0);
140
- }, [isActive, onSelectionValidChange, items.length]);
141
- // Stream subitem counts in the background for items whose
142
- // includeSubitems flag is on. Filtering happens server-side (see
143
- // TranslationController.DiscoverSubitemCountStream). The count grows in
144
- // real time as the backend walks the subtree. Cached results survive
145
- // toggle-off/on; in-flight requests are aborted if the user turns the
146
- // flag back off.
147
- const sessionId = editContext?.sessionId;
148
- const inFlightRef = useRef(new Map());
149
- useEffect(() => {
150
- const inFlight = inFlightRef.current;
151
- const enabledIds = new Set(items.filter((it) => it.includeSubitems).map((it) => it.descriptor.id));
152
- // Cancel any streams whose items no longer have the flag on.
153
- for (const [id, ctrl] of inFlight) {
154
- if (!enabledIds.has(id)) {
155
- ctrl.abort();
156
- inFlight.delete(id);
157
- }
158
- }
159
- // Start a stream for every newly-enabled item that doesn't already
160
- // have a count or an active stream. Cached complete results survive;
161
- // a partial (non-complete) object means a previous stream was aborted
162
- // mid-flight — restart it.
163
- const toStart = items
164
- .filter((it) => it.includeSubitems)
165
- .map((it) => it.descriptor)
166
- .filter((d) => {
167
- if (inFlight.has(d.id))
168
- return false;
169
- const c = subitemCounts[d.id];
170
- if (c === undefined || c === "error")
171
- return true;
172
- if (c === "loading")
173
- return false;
174
- return !c.complete;
175
- });
176
- if (toStart.length === 0)
177
- return;
178
- setSubitemCounts((prev) => {
179
- const next = { ...prev };
180
- for (const d of toStart)
181
- next[d.id] = "loading";
182
- return next;
183
- });
184
- for (const descriptor of toStart) {
185
- const controller = new AbortController();
186
- inFlight.set(descriptor.id, controller);
187
- void (async () => {
188
- try {
189
- const finalCount = await streamSubitemCount({ itemId: descriptor.id, language: descriptor.language }, ({ count, complete }) => {
190
- setSubitemCounts((prev) => ({
191
- ...prev,
192
- [descriptor.id]: { count, complete },
193
- }));
194
- }, { sessionId, signal: controller.signal });
195
- // Backend may close the stream without explicitly sending
196
- // complete=true on the last line — mark complete on a clean exit.
197
- setSubitemCounts((prev) => {
198
- const existing = prev[descriptor.id];
199
- const count = existing && typeof existing === "object"
200
- ? existing.count
201
- : finalCount;
202
- return {
203
- ...prev,
204
- [descriptor.id]: { count, complete: true },
205
- };
206
- });
207
- }
208
- catch (err) {
209
- if (err?.name === "AbortError")
210
- return;
211
- setSubitemCounts((prev) => {
212
- // Don't overwrite a partial count with "error" — keep what we have.
213
- const existing = prev[descriptor.id];
214
- if (existing && typeof existing === "object")
215
- return prev;
216
- return { ...prev, [descriptor.id]: "error" };
217
- });
218
- }
219
- finally {
220
- if (inFlight.get(descriptor.id) === controller) {
221
- inFlight.delete(descriptor.id);
222
- }
223
- }
224
- })();
225
- }
226
- }, [items, subitemCounts, sessionId]);
227
- // Abort any in-flight streams on unmount.
228
- useEffect(() => {
229
- const inFlight = inFlightRef.current;
230
- return () => {
231
- for (const ctrl of inFlight.values())
232
- ctrl.abort();
233
- inFlight.clear();
234
- };
235
- }, []);
236
- const cacheTreeNode = useCallback((node) => {
237
- const id = node.id;
238
- if (!id)
239
- return;
240
- const cache = itemCacheRef.current;
241
- if (cache.has(id))
242
- return;
243
- const anyNode = node;
244
- cache.set(id, fullItemFromDescriptor({
245
- id,
246
- language: node.language ?? language,
247
- version: node.version ?? 1,
248
- name: node.name,
249
- displayName: node.displayName,
250
- path: node.path,
251
- idPath: anyNode.idPath,
252
- icon: anyNode.icon,
253
- templateId: anyNode.templateId,
254
- hasChildren: anyNode.hasChildren,
255
- }));
256
- }, [language]);
257
- const handleAddToList = useCallback(async (itemsToAdd) => {
258
- const source = itemsToAdd ?? selectedInTree;
259
- if (!source || source.length === 0)
260
- return;
261
- const existing = new Set(items.map((i) => i.descriptor.id));
262
- const next = [...items];
263
- for (const node of source) {
264
- if (!node.id || existing.has(node.id))
265
- continue;
266
- cacheTreeNode(node);
267
- next.push({
268
- descriptor: {
269
- id: node.id,
270
- language: node.language ?? language,
271
- version: node.version ?? 1,
272
- name: node.name,
273
- displayName: node.displayName,
274
- path: node.path,
275
- },
276
- includeSubitems: false,
277
- });
278
- existing.add(node.id);
279
- }
280
- setItems(next);
281
- commitToWizard(next);
282
- setSelectedInTree([]);
283
- setSelectedFromList([]);
284
- }, [items, selectedInTree, language, cacheTreeNode, commitToWizard]);
285
- const handleAddItem = useCallback(async (item) => {
286
- const id = item.id;
287
- if (!id || items.some((i) => i.descriptor.id === id))
288
- return;
289
- cacheTreeNode(item);
290
- const next = [
291
- ...items,
292
- {
293
- descriptor: {
294
- id,
295
- language: item.language ?? language,
296
- version: item.version ?? 1,
297
- name: item.name,
298
- displayName: item.displayName,
299
- path: item.path,
300
- },
301
- includeSubitems: false,
302
- },
303
- ];
304
- setItems(next);
305
- commitToWizard(next);
306
- setSelectedFromList([]);
307
- }, [items, language, cacheTreeNode, commitToWizard]);
308
- const handleRemoveFromList = useCallback(() => {
309
- const ids = new Set(selectedFromList.map((i) => i.descriptor.id));
310
- const next = items.filter((i) => !ids.has(i.descriptor.id));
311
- setItems(next);
312
- commitToWizard(next);
313
- setSelectedFromList([]);
314
- }, [items, selectedFromList, commitToWizard]);
315
- const handleRemoveItem = useCallback((index) => {
316
- const next = items.filter((_, i) => i !== index);
317
- setItems(next);
318
- commitToWizard(next);
319
- setSelectedFromList([]);
320
- }, [items, commitToWizard]);
321
- const handleToggleSubitems = useCallback((index) => {
322
- const next = items.map((it, i) => i === index ? { ...it, includeSubitems: !it.includeSubitems } : it);
323
- setItems(next);
324
- commitToWizard(next);
325
- }, [items, commitToWizard]);
326
- return (_jsx(ItemCollectionEditor, { items: items, selectedInTree: selectedInTree, onSelectedInTreeChange: setSelectedInTree, selectedFromList: selectedFromList, onSelectedFromListChange: setSelectedFromList, onAddToList: handleAddToList, onRemoveFromList: handleRemoveFromList, onAddItem: handleAddItem, onRemoveItem: handleRemoveItem, onToggleSubitems: handleToggleSubitems, language: language, rootItemIds: [SITECORE_ROOT], selectedItemsLabel: "Items to Translate", emptyMessage: "No items selected", emptyHint: "Browse or search to add items", height: height, subitemCounts: subitemCounts, expandIdPath: expandIdPath, localStorageKey: "translation-wizard.itemCollectionSplitter" }));
327
- }
@@ -1,17 +0,0 @@
1
- import { ReactNode } from "react";
2
- type WizardStepShellProps = {
3
- /** Right-aligned content above the body (badges, counts, actions). */
4
- meta?: ReactNode;
5
- /** When true, the body section flex-grows and content can overflow internally. */
6
- fillHeight?: boolean;
7
- testId?: string;
8
- children: ReactNode;
9
- };
10
- /**
11
- * Body-only scaffold for translation-wizard steps. Step title/description
12
- * live in the wizard's stepper bar, so this just gives a consistent
13
- * padding + optional meta row + flex/scroll behavior for the content.
14
- */
15
- export declare function WizardStepShell({ meta, fillHeight, testId, children, }: WizardStepShellProps): import("react/jsx-runtime").JSX.Element;
16
- export {};
17
- //# sourceMappingURL=WizardStepShell.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WizardStepShell.d.ts","sourceRoot":"","sources":["../../src/steps/WizardStepShell.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,KAAK,oBAAoB,GAAG;IAC1B,sEAAsE;IACtE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,kFAAkF;IAClF,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,UAAkB,EAClB,MAAM,EACN,QAAQ,GACT,EAAE,oBAAoB,2CAiBtB"}
@@ -1,11 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /**
3
- * Body-only scaffold for translation-wizard steps. Step title/description
4
- * live in the wizard's stepper bar, so this just gives a consistent
5
- * padding + optional meta row + flex/scroll behavior for the content.
6
- */
7
- export function WizardStepShell({ meta, fillHeight = false, testId, children, }) {
8
- return (_jsxs("div", { className: "flex h-full flex-col gap-4 p-6", "data-testid": testId, children: [meta && (_jsx("div", { className: "flex items-center justify-end gap-2", children: meta })), _jsx("div", { className: fillHeight
9
- ? "flex min-h-0 flex-1 flex-col gap-4"
10
- : "flex flex-col gap-5", children: children })] }));
11
- }
@@ -1,2 +0,0 @@
1
- export declare function TranslationBatches(): import("react/jsx-runtime").JSX.Element;
2
- //# sourceMappingURL=TranslationBatches.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TranslationBatches.d.ts","sourceRoot":"","sources":["../../src/translation-center/TranslationBatches.tsx"],"names":[],"mappings":"AAmPA,wBAAgB,kBAAkB,4CAgtCjC"}