@jumoo/usync 18.2.1 → 18.3.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.
Files changed (45) hide show
  1. package/dist/api/index.d.ts +2 -2
  2. package/dist/api/index.js +1 -1
  3. package/dist/api/sdk.gen.d.ts +2 -1
  4. package/dist/api/sdk.gen.js +5 -0
  5. package/dist/api/types.gen.d.ts +37 -0
  6. package/dist/components/usync-content-preview.d.ts +27 -0
  7. package/dist/components/usync-content-preview.js +532 -0
  8. package/dist/components/usync-content-type-preview.d.ts +25 -0
  9. package/dist/components/usync-content-type-preview.js +530 -0
  10. package/dist/components/usync-data-type-preview.d.ts +21 -0
  11. package/dist/components/usync-data-type-preview.js +295 -0
  12. package/dist/components/usync-results-view.js +13 -5
  13. package/dist/dialogs/details-modal-element.d.ts +15 -0
  14. package/dist/dialogs/details-modal-element.js +217 -7
  15. package/dist/dialogs/details-modal-token.d.ts +10 -1
  16. package/dist/exports.d.ts +1 -0
  17. package/dist/exports.js +1 -0
  18. package/dist/lang/files/da-dk.d.ts +37 -0
  19. package/dist/lang/files/da-dk.js +37 -0
  20. package/dist/lang/files/de-de.d.ts +37 -0
  21. package/dist/lang/files/de-de.js +37 -0
  22. package/dist/lang/files/en-us.d.ts +50 -0
  23. package/dist/lang/files/en-us.js +50 -0
  24. package/dist/lang/files/es-es.d.ts +37 -0
  25. package/dist/lang/files/es-es.js +37 -0
  26. package/dist/lang/files/fr-fr.d.ts +37 -0
  27. package/dist/lang/files/fr-fr.js +37 -0
  28. package/dist/lang/files/nl-nl.d.ts +37 -0
  29. package/dist/lang/files/nl-nl.js +37 -0
  30. package/dist/manifests.js +2 -0
  31. package/dist/preview/index.d.ts +1 -0
  32. package/dist/preview/index.js +1 -0
  33. package/dist/preview/manifest.d.ts +2 -0
  34. package/dist/preview/manifest.js +22 -0
  35. package/dist/preview/types.d.ts +72 -0
  36. package/dist/preview/types.js +2 -0
  37. package/dist/repository/SyncAction.respositoy.d.ts +13 -0
  38. package/dist/repository/SyncAction.respositoy.js +6 -0
  39. package/dist/repository/sources/SyncAction.source.d.ts +10 -0
  40. package/dist/repository/sources/SyncAction.source.js +6 -1
  41. package/dist/utils/preview/content-type-diff.d.ts +18 -0
  42. package/dist/utils/preview/content-type-diff.js +72 -0
  43. package/dist/utils/preview/content-type-layout.d.ts +39 -0
  44. package/dist/utils/preview/content-type-layout.js +100 -0
  45. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- export { getActionsBySet, getAddOns, getAddOnSplash, getCheckLegacy, getHandlerSettings, getRunning, getSets, getSettings, getStatus, getSyncFileInfo, type Options, postCopyLegacy, postDownload, postIgnoreLegacy, postImport, postMergeExport, postPerform, postProcessUpload } from './sdk.gen';
2
- export { ChangeDetailType, ChangeType, type ClientOptions, type EntityTagHeaderValue, type FileContentResult, type GetActionsBySetData, type GetActionsBySetErrors, type GetActionsBySetResponse, type GetActionsBySetResponses, type GetAddOnsData, type GetAddOnsErrors, type GetAddOnSplashData, type GetAddOnSplashErrors, type GetAddOnSplashResponse, type GetAddOnSplashResponses, type GetAddOnsResponse, type GetAddOnsResponses, type GetCheckLegacyData, type GetCheckLegacyErrors, type GetCheckLegacyResponse, type GetCheckLegacyResponses, type GetHandlerSettingsData, type GetHandlerSettingsErrors, type GetHandlerSettingsResponse, type GetHandlerSettingsResponses, type GetRunningData, type GetRunningErrors, type GetRunningResponse, type GetRunningResponses, type GetSetsData, type GetSetsErrors, type GetSetsResponse, type GetSetsResponses, type GetSettingsData, type GetSettingsErrors, type GetSettingsResponse, type GetSettingsResponses, type GetStatusData, type GetStatusErrors, type GetStatusResponse, type GetStatusResponses, type GetSyncFileInfoData, type GetSyncFileInfoErrors, type GetSyncFileInfoResponse, type GetSyncFileInfoResponses, type HandlerSettings, HandlerStatus, type PerformActionRequest, type PerformActionResponse, type PostCopyLegacyData, type PostCopyLegacyErrors, type PostCopyLegacyResponse, type PostCopyLegacyResponses, type PostDownloadData, type PostDownloadErrors, type PostDownloadResponse, type PostDownloadResponses, type PostIgnoreLegacyData, type PostIgnoreLegacyErrors, type PostIgnoreLegacyResponse, type PostIgnoreLegacyResponses, type PostImportData, type PostImportErrors, type PostImportResponse, type PostImportResponses, type PostMergeExportData, type PostMergeExportErrors, type PostMergeExportResponse, type PostMergeExportResponses, type PostPerformData, type PostPerformErrors, type PostPerformResponse, type PostPerformResponses, type PostProcessUploadData, type PostProcessUploadErrors, type PostProcessUploadResponse, type PostProcessUploadResponses, type StringSegment, type SyncActionButton, type SyncActionGroup, type SyncFileVersionCheckResult, SyncFolderMode, type SyncHandlerSummary, type SyncLegacyCheckResponse, type SyncOperationStatusResponse, SyncProcessingMode, type SyncRunningOperationResponse, type SyncSelectableSet, type UploadImportResult, type USyncActionView, type USyncAddonInfo, type USyncAddonSplash, type USyncChange, type USyncHandlerSetSettings, type USyncOptions, type USyncSettings } from './types.gen';
1
+ export { getActionsBySet, getAddOns, getAddOnSplash, getCheckLegacy, getHandlerSettings, getPreview, getRunning, getSets, getSettings, getStatus, getSyncFileInfo, type Options, postCopyLegacy, postDownload, postIgnoreLegacy, postImport, postMergeExport, postPerform, postProcessUpload } from './sdk.gen';
2
+ export { ChangeDetailType, ChangeType, type ClientOptions, type EntityTagHeaderValue, type FileContentResult, type GetActionsBySetData, type GetActionsBySetErrors, type GetActionsBySetResponse, type GetActionsBySetResponses, type GetAddOnsData, type GetAddOnsErrors, type GetAddOnSplashData, type GetAddOnSplashErrors, type GetAddOnSplashResponse, type GetAddOnSplashResponses, type GetAddOnsResponse, type GetAddOnsResponses, type GetCheckLegacyData, type GetCheckLegacyErrors, type GetCheckLegacyResponse, type GetCheckLegacyResponses, type GetHandlerSettingsData, type GetHandlerSettingsErrors, type GetHandlerSettingsResponse, type GetHandlerSettingsResponses, type GetPreviewData, type GetPreviewErrors, type GetPreviewResponse, type GetPreviewResponses, type GetRunningData, type GetRunningErrors, type GetRunningResponse, type GetRunningResponses, type GetSetsData, type GetSetsErrors, type GetSetsResponse, type GetSetsResponses, type GetSettingsData, type GetSettingsErrors, type GetSettingsResponse, type GetSettingsResponses, type GetStatusData, type GetStatusErrors, type GetStatusResponse, type GetStatusResponses, type GetSyncFileInfoData, type GetSyncFileInfoErrors, type GetSyncFileInfoResponse, type GetSyncFileInfoResponses, type HandlerSettings, HandlerStatus, type PerformActionRequest, type PerformActionResponse, type PostCopyLegacyData, type PostCopyLegacyErrors, type PostCopyLegacyResponse, type PostCopyLegacyResponses, type PostDownloadData, type PostDownloadErrors, type PostDownloadResponse, type PostDownloadResponses, type PostIgnoreLegacyData, type PostIgnoreLegacyErrors, type PostIgnoreLegacyResponse, type PostIgnoreLegacyResponses, type PostImportData, type PostImportErrors, type PostImportResponse, type PostImportResponses, type PostMergeExportData, type PostMergeExportErrors, type PostMergeExportResponse, type PostMergeExportResponses, type PostPerformData, type PostPerformErrors, type PostPerformResponse, type PostPerformResponses, type PostProcessUploadData, type PostProcessUploadErrors, type PostProcessUploadResponse, type PostProcessUploadResponses, type StringSegment, type SyncActionButton, type SyncActionGroup, type SyncFileVersionCheckResult, SyncFolderMode, type SyncHandlerSummary, type SyncItemPreviewResponse, type SyncLegacyCheckResponse, type SyncOperationStatusResponse, SyncProcessingMode, type SyncRunningOperationResponse, type SyncSelectableSet, type UploadImportResult, type USyncActionView, type USyncAddonInfo, type USyncAddonSplash, type USyncChange, type USyncHandlerSetSettings, type USyncOptions, type USyncSettings } from './types.gen';
package/dist/api/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is auto-generated by @hey-api/openapi-ts
2
- export { getActionsBySet, getAddOns, getAddOnSplash, getCheckLegacy, getHandlerSettings, getRunning, getSets, getSettings, getStatus, getSyncFileInfo, postCopyLegacy, postDownload, postIgnoreLegacy, postImport, postMergeExport, postPerform, postProcessUpload } from './sdk.gen';
2
+ export { getActionsBySet, getAddOns, getAddOnSplash, getCheckLegacy, getHandlerSettings, getPreview, getRunning, getSets, getSettings, getStatus, getSyncFileInfo, postCopyLegacy, postDownload, postIgnoreLegacy, postImport, postMergeExport, postPerform, postProcessUpload } from './sdk.gen';
3
3
  export { ChangeDetailType, ChangeType, HandlerStatus, SyncFolderMode, SyncProcessingMode } from './types.gen';
@@ -1,5 +1,5 @@
1
1
  import type { Client, ClientMeta, Options as Options2, RequestResult, TDataShape } from './client';
2
- import type { GetActionsBySetData, GetActionsBySetErrors, GetActionsBySetResponses, GetAddOnsData, GetAddOnsErrors, GetAddOnSplashData, GetAddOnSplashErrors, GetAddOnSplashResponses, GetAddOnsResponses, GetCheckLegacyData, GetCheckLegacyErrors, GetCheckLegacyResponses, GetHandlerSettingsData, GetHandlerSettingsErrors, GetHandlerSettingsResponses, GetRunningData, GetRunningErrors, GetRunningResponses, GetSetsData, GetSetsErrors, GetSetsResponses, GetSettingsData, GetSettingsErrors, GetSettingsResponses, GetStatusData, GetStatusErrors, GetStatusResponses, GetSyncFileInfoData, GetSyncFileInfoErrors, GetSyncFileInfoResponses, PostCopyLegacyData, PostCopyLegacyErrors, PostCopyLegacyResponses, PostDownloadData, PostDownloadErrors, PostDownloadResponses, PostIgnoreLegacyData, PostIgnoreLegacyErrors, PostIgnoreLegacyResponses, PostImportData, PostImportErrors, PostImportResponses, PostMergeExportData, PostMergeExportErrors, PostMergeExportResponses, PostPerformData, PostPerformErrors, PostPerformResponses, PostProcessUploadData, PostProcessUploadErrors, PostProcessUploadResponses } from './types.gen';
2
+ import type { GetActionsBySetData, GetActionsBySetErrors, GetActionsBySetResponses, GetAddOnsData, GetAddOnsErrors, GetAddOnSplashData, GetAddOnSplashErrors, GetAddOnSplashResponses, GetAddOnsResponses, GetCheckLegacyData, GetCheckLegacyErrors, GetCheckLegacyResponses, GetHandlerSettingsData, GetHandlerSettingsErrors, GetHandlerSettingsResponses, GetPreviewData, GetPreviewErrors, GetPreviewResponses, GetRunningData, GetRunningErrors, GetRunningResponses, GetSetsData, GetSetsErrors, GetSetsResponses, GetSettingsData, GetSettingsErrors, GetSettingsResponses, GetStatusData, GetStatusErrors, GetStatusResponses, GetSyncFileInfoData, GetSyncFileInfoErrors, GetSyncFileInfoResponses, PostCopyLegacyData, PostCopyLegacyErrors, PostCopyLegacyResponses, PostDownloadData, PostDownloadErrors, PostDownloadResponses, PostIgnoreLegacyData, PostIgnoreLegacyErrors, PostIgnoreLegacyResponses, PostImportData, PostImportErrors, PostImportResponses, PostMergeExportData, PostMergeExportErrors, PostMergeExportResponses, PostPerformData, PostPerformErrors, PostPerformResponses, PostProcessUploadData, PostProcessUploadErrors, PostProcessUploadResponses } from './types.gen';
3
3
  export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
4
4
  /**
5
5
  * You can provide a client instance returned by `createClient()` instead of
@@ -17,6 +17,7 @@ export declare const getActionsBySet: <ThrowOnError extends boolean = false>(opt
17
17
  export declare const postDownload: <ThrowOnError extends boolean = false>(options?: Options<PostDownloadData, ThrowOnError>) => RequestResult<PostDownloadResponses, PostDownloadErrors, ThrowOnError>;
18
18
  export declare const postImport: <ThrowOnError extends boolean = false>(options: Options<PostImportData, ThrowOnError>) => RequestResult<PostImportResponses, PostImportErrors, ThrowOnError>;
19
19
  export declare const postPerform: <ThrowOnError extends boolean = false>(options: Options<PostPerformData, ThrowOnError>) => RequestResult<PostPerformResponses, PostPerformErrors, ThrowOnError>;
20
+ export declare const getPreview: <ThrowOnError extends boolean = false>(options?: Options<GetPreviewData, ThrowOnError>) => RequestResult<GetPreviewResponses, GetPreviewErrors, ThrowOnError>;
20
21
  export declare const postProcessUpload: <ThrowOnError extends boolean = false>(options?: Options<PostProcessUploadData, ThrowOnError>) => RequestResult<PostProcessUploadResponses, PostProcessUploadErrors, ThrowOnError>;
21
22
  export declare const getRunning: <ThrowOnError extends boolean = false>(options?: Options<GetRunningData, ThrowOnError>) => RequestResult<GetRunningResponses, GetRunningErrors, ThrowOnError>;
22
23
  export declare const getStatus: <ThrowOnError extends boolean = false>(options?: Options<GetStatusData, ThrowOnError>) => RequestResult<GetStatusResponses, GetStatusErrors, ThrowOnError>;
@@ -28,6 +28,11 @@ export const postPerform = (options) => (options.client ?? client).post({
28
28
  ...options.headers
29
29
  }
30
30
  });
31
+ export const getPreview = (options) => (options?.client ?? client).get({
32
+ security: [{ scheme: 'bearer', type: 'http' }],
33
+ url: '/umbraco/usync/api/v1/Preview',
34
+ ...options
35
+ });
31
36
  export const postProcessUpload = (options) => (options?.client ?? client).post({
32
37
  security: [{ scheme: 'bearer', type: 'http' }],
33
38
  url: '/umbraco/usync/api/v1/ProcessUpload',
@@ -115,6 +115,17 @@ export type SyncHandlerSummary = {
115
115
  changes: number | string;
116
116
  inError: boolean;
117
117
  };
118
+ export type SyncItemPreviewResponse = {
119
+ key: string;
120
+ handler: string;
121
+ itemType: string;
122
+ entityType: string;
123
+ isDelete: boolean;
124
+ success: boolean;
125
+ message?: null | string;
126
+ preview?: unknown;
127
+ details: Array<USyncChange>;
128
+ };
118
129
  export type SyncLegacyCheckResponse = {
119
130
  hasLegacy: boolean;
120
131
  legacyFolder?: null | string;
@@ -310,6 +321,32 @@ export type PostPerformResponses = {
310
321
  200: PerformActionResponse;
311
322
  };
312
323
  export type PostPerformResponse = PostPerformResponses[keyof PostPerformResponses];
324
+ export type GetPreviewData = {
325
+ body?: never;
326
+ path?: never;
327
+ query?: {
328
+ handler?: string;
329
+ key?: string;
330
+ };
331
+ url: '/umbraco/usync/api/v1/Preview';
332
+ };
333
+ export type GetPreviewErrors = {
334
+ /**
335
+ * The resource is protected and requires an authentication token
336
+ */
337
+ 401: unknown;
338
+ /**
339
+ * Not Found
340
+ */
341
+ 404: unknown;
342
+ };
343
+ export type GetPreviewResponses = {
344
+ /**
345
+ * OK
346
+ */
347
+ 200: SyncItemPreviewResponse;
348
+ };
349
+ export type GetPreviewResponse = GetPreviewResponses[keyof GetPreviewResponses];
313
350
  export type PostProcessUploadData = {
314
351
  body?: never;
315
352
  path?: never;
@@ -0,0 +1,27 @@
1
+ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
2
+ import { type PropertyValues, nothing } from '@umbraco-cms/backoffice/external/lit';
3
+ import '@umbraco-cms/backoffice/components';
4
+ import type { SyncItemPreviewResponse } from '../api';
5
+ /**
6
+ * Shows the current and incoming versions of a content or media item side by
7
+ * side, laid out the way the backoffice editor shows them, with every value
8
+ * rendered by its real property editor. Values that change are highlighted.
9
+ */
10
+ export declare class uSyncContentPreviewElement extends UmbLitElement {
11
+ #private;
12
+ preview?: SyncItemPreviewResponse;
13
+ /** the tab shown on both sides (by name) */
14
+ private _activeTab?;
15
+ /** the culture shown on both sides (undefined for invariant items) */
16
+ private _culture?;
17
+ private _onlyChanges;
18
+ protected willUpdate(changed: PropertyValues<this>): void;
19
+ render(): typeof nothing | import("lit-html").TemplateResult<1>;
20
+ static styles: import("lit").CSSResult;
21
+ }
22
+ export default uSyncContentPreviewElement;
23
+ declare global {
24
+ interface HTMLElementTagNameMap {
25
+ 'usync-content-preview': uSyncContentPreviewElement;
26
+ }
27
+ }
@@ -0,0 +1,532 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8
+ if (kind === "m") throw new TypeError("Private method is not writable");
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
11
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
+ };
13
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
14
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
15
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
16
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
17
+ };
18
+ var _uSyncContentPreviewElement_instances, _uSyncContentPreviewElement_current, _uSyncContentPreviewElement_incoming, _uSyncContentPreviewElement_type, _uSyncContentPreviewElement_compositions, _uSyncContentPreviewElement_dataTypes, _uSyncContentPreviewElement_cultures, _uSyncContentPreviewElement_renderToolbar, _uSyncContentPreviewElement_renderSide, _uSyncContentPreviewElement_missingMessage, _uSyncContentPreviewElement_renderInfo, _uSyncContentPreviewElement_renderPublished, _uSyncContentPreviewElement_name, _uSyncContentPreviewElement_renderTabButton, _uSyncContentPreviewElement_renderTab, _uSyncContentPreviewElement_renderProperties, _uSyncContentPreviewElement_visibleTabs, _uSyncContentPreviewElement_tabProperties, _uSyncContentPreviewElement_datasetValue, _uSyncContentPreviewElement_value, _uSyncContentPreviewElement_valueStatus;
19
+ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
20
+ import { classMap, css, customElement, html, nothing, property, repeat, state, } from '@umbraco-cms/backoffice/external/lit';
21
+ import '@umbraco-cms/backoffice/components';
22
+ import { getPreviewModel, } from '../preview/types.js';
23
+ import { buildContentTypeLayout, } from '../utils/preview/content-type-layout.js';
24
+ import { deepEqual } from '../utils/diff/deep-equal.js';
25
+ /**
26
+ * Shows the current and incoming versions of a content or media item side by
27
+ * side, laid out the way the backoffice editor shows them, with every value
28
+ * rendered by its real property editor. Values that change are highlighted.
29
+ */
30
+ let uSyncContentPreviewElement = class uSyncContentPreviewElement extends UmbLitElement {
31
+ constructor() {
32
+ super(...arguments);
33
+ _uSyncContentPreviewElement_instances.add(this);
34
+ this._onlyChanges = false;
35
+ _uSyncContentPreviewElement_current.set(this, {});
36
+ _uSyncContentPreviewElement_incoming.set(this, {});
37
+ _uSyncContentPreviewElement_type.set(this, void 0);
38
+ _uSyncContentPreviewElement_compositions.set(this, new Map());
39
+ _uSyncContentPreviewElement_dataTypes.set(this, new Map());
40
+ _uSyncContentPreviewElement_cultures.set(this, []);
41
+ }
42
+ willUpdate(changed) {
43
+ if (!changed.has('preview') || !this.preview)
44
+ return;
45
+ const model = getPreviewModel(this.preview);
46
+ __classPrivateFieldSet(this, _uSyncContentPreviewElement_current, { item: model?.current ?? undefined, info: model?.currentInfo }, "f");
47
+ __classPrivateFieldSet(this, _uSyncContentPreviewElement_incoming, { item: model?.incoming ?? undefined, info: model?.incomingInfo }, "f");
48
+ __classPrivateFieldSet(this, _uSyncContentPreviewElement_type, model?.contentType ?? undefined, "f");
49
+ const compositions = model?.compositions ?? [];
50
+ __classPrivateFieldSet(this, _uSyncContentPreviewElement_compositions, new Map(compositions.map((c) => [c.id, c])), "f");
51
+ __classPrivateFieldSet(this, _uSyncContentPreviewElement_dataTypes, new Map((model?.dataTypes ?? []).map((d) => [d.id, d])), "f");
52
+ __classPrivateFieldSet(this, _uSyncContentPreviewElement_cultures, [
53
+ ...new Set([__classPrivateFieldGet(this, _uSyncContentPreviewElement_current, "f").item, __classPrivateFieldGet(this, _uSyncContentPreviewElement_incoming, "f").item]
54
+ .flatMap((item) => item?.variants ?? [])
55
+ .map((v) => v.culture)
56
+ .filter((c) => !!c)),
57
+ ].sort(), "f");
58
+ this._culture = __classPrivateFieldGet(this, _uSyncContentPreviewElement_cultures, "f")[0];
59
+ this._activeTab = undefined;
60
+ }
61
+ render() {
62
+ if (!this.preview)
63
+ return nothing;
64
+ const tabs = __classPrivateFieldGet(this, _uSyncContentPreviewElement_type, "f")
65
+ ? __classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_visibleTabs).call(this, buildContentTypeLayout(__classPrivateFieldGet(this, _uSyncContentPreviewElement_type, "f"), __classPrivateFieldGet(this, _uSyncContentPreviewElement_compositions, "f")))
66
+ : [];
67
+ // until a tab is picked, open on the first one with changes.
68
+ const active = tabs.find((t) => t.name === this._activeTab) ??
69
+ tabs.find((t) => __classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_tabProperties).call(this, t).some((p) => __classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_valueStatus).call(this, p.property))) ??
70
+ tabs[0];
71
+ return html `
72
+ <div class="sides">
73
+ ${__classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_renderToolbar).call(this)}
74
+ ${__classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_renderSide).call(this, 'current', __classPrivateFieldGet(this, _uSyncContentPreviewElement_current, "f"), tabs, active)}
75
+ ${__classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_renderSide).call(this, 'incoming', __classPrivateFieldGet(this, _uSyncContentPreviewElement_incoming, "f"), tabs, active)}
76
+ </div>
77
+ `;
78
+ }
79
+ };
80
+ _uSyncContentPreviewElement_current = new WeakMap();
81
+ _uSyncContentPreviewElement_incoming = new WeakMap();
82
+ _uSyncContentPreviewElement_type = new WeakMap();
83
+ _uSyncContentPreviewElement_compositions = new WeakMap();
84
+ _uSyncContentPreviewElement_dataTypes = new WeakMap();
85
+ _uSyncContentPreviewElement_cultures = new WeakMap();
86
+ _uSyncContentPreviewElement_instances = new WeakSet();
87
+ _uSyncContentPreviewElement_renderToolbar = function _uSyncContentPreviewElement_renderToolbar() {
88
+ if (__classPrivateFieldGet(this, _uSyncContentPreviewElement_cultures, "f").length < 2 && !(__classPrivateFieldGet(this, _uSyncContentPreviewElement_current, "f").item && __classPrivateFieldGet(this, _uSyncContentPreviewElement_incoming, "f").item))
89
+ return nothing;
90
+ return html `<div class="toolbar">
91
+ ${__classPrivateFieldGet(this, _uSyncContentPreviewElement_cultures, "f").length > 1
92
+ ? html `<uui-button-group
93
+ aria-label=${this.localize.termOrDefault('uSync_previewCulture', 'Language')}>
94
+ ${__classPrivateFieldGet(this, _uSyncContentPreviewElement_cultures, "f").map((culture) => html `<uui-button
95
+ look=${culture === this._culture ? 'primary' : 'secondary'}
96
+ compact
97
+ label=${culture}
98
+ @click=${() => (this._culture = culture)}></uui-button>`)}
99
+ </uui-button-group>`
100
+ : nothing}
101
+ ${
102
+ // there is only something to compare when the item is on both sides.
103
+ __classPrivateFieldGet(this, _uSyncContentPreviewElement_current, "f").item && __classPrivateFieldGet(this, _uSyncContentPreviewElement_incoming, "f").item
104
+ ? html `<uui-toggle
105
+ label=${this.localize.termOrDefault('uSync_previewOnlyChanges', 'Only show changes')}
106
+ ?checked=${this._onlyChanges}
107
+ @change=${(e) => (this._onlyChanges = e.target.checked)}></uui-toggle>`
108
+ : nothing}
109
+ </div>`;
110
+ };
111
+ _uSyncContentPreviewElement_renderSide = function _uSyncContentPreviewElement_renderSide(side, data, tabs, active) {
112
+ const headline = side === 'current'
113
+ ? this.localize.termOrDefault('uSync_previewCurrent', 'Current (this site)')
114
+ : this.localize.termOrDefault('uSync_previewIncoming', 'Incoming (uSync files)');
115
+ if (!data.item) {
116
+ return html `<div class="side ${side}">
117
+ <h4 class="side-headline">${headline}</h4>
118
+ <uui-box class="info"><p class="empty">${__classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_missingMessage).call(this, side)}</p></uui-box>
119
+ </div>`;
120
+ }
121
+ return html `
122
+ <div class="side ${side}">
123
+ <h4 class="side-headline">${headline}</h4>
124
+ ${__classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_renderInfo).call(this, data)}
125
+ ${tabs.length > 1 || (tabs.length === 1 && tabs[0].name)
126
+ ? html `<uui-tab-group>
127
+ ${tabs.map((tab) => __classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_renderTabButton).call(this, tab, tab === active))}
128
+ </uui-tab-group>`
129
+ : html `<div></div>`}
130
+ ${active
131
+ ? __classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_renderTab).call(this, data.item, active)
132
+ : html `<uui-box>
133
+ <p class="empty">
134
+ ${this._onlyChanges
135
+ ? this.localize.termOrDefault('uSync_previewNoValueChanges', 'No values change')
136
+ : this.localize.termOrDefault('uSync_previewNoProperties', 'No properties')}
137
+ </p>
138
+ </uui-box>`}
139
+ </div>
140
+ `;
141
+ };
142
+ _uSyncContentPreviewElement_missingMessage = function _uSyncContentPreviewElement_missingMessage(side) {
143
+ if (side === 'current') {
144
+ return this.localize.termOrDefault('uSync_previewNotInSite', 'This item does not exist in the site yet');
145
+ }
146
+ return this.preview?.isDelete
147
+ ? this.localize.termOrDefault('uSync_previewDeleted', 'This item will be deleted or renamed by the import')
148
+ : this.localize.termOrDefault('uSync_previewFailed', 'The incoming item could not be built for the preview');
149
+ };
150
+ _uSyncContentPreviewElement_renderInfo = function _uSyncContentPreviewElement_renderInfo(data) {
151
+ const item = data.item;
152
+ const info = data.info;
153
+ const other = data === __classPrivateFieldGet(this, _uSyncContentPreviewElement_current, "f") ? __classPrivateFieldGet(this, _uSyncContentPreviewElement_incoming, "f") : __classPrivateFieldGet(this, _uSyncContentPreviewElement_current, "f");
154
+ const both = !!other.item;
155
+ const changed = (field) => {
156
+ if (!both)
157
+ return { changed: false };
158
+ const mine = field === 'name' ? __classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_name).call(this, item) : info?.[field];
159
+ const theirs = field === 'name' ? __classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_name).call(this, other.item) : other.info?.[field];
160
+ return { changed: !deepEqual(mine, theirs) };
161
+ };
162
+ const icon = 'documentType' in item ? item.documentType.icon : item.mediaType.icon;
163
+ return html `
164
+ <uui-box class="info">
165
+ <div slot="headline" class="headline">
166
+ <umb-icon name=${icon}></umb-icon>
167
+ <span class=${classMap(changed('name'))}>${__classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_name).call(this, item)}</span>
168
+ </div>
169
+ <dl class="meta">
170
+ <dt>${this.localize.termOrDefault('uSync_previewParent', 'Parent')}</dt>
171
+ <dd>
172
+ <span class=${classMap(changed('parent'))}
173
+ >${info?.parent ?? this.localize.termOrDefault('uSync_previewRoot', '(root)')}</span
174
+ >
175
+ </dd>
176
+ ${info?.template !== undefined && this.preview?.entityType === 'document'
177
+ ? html `<dt>
178
+ ${this.localize.termOrDefault('uSync_previewTemplate', 'Template')}
179
+ </dt>
180
+ <dd>
181
+ <span class=${classMap(changed('template'))}
182
+ >${info?.template ?? '-'}</span
183
+ >
184
+ </dd>`
185
+ : nothing}
186
+ <dt>${this.localize.termOrDefault('uSync_previewSortOrder', 'Sort order')}</dt>
187
+ <dd>
188
+ <span class=${classMap(changed('sortOrder'))}>${info?.sortOrder ?? '-'}</span>
189
+ </dd>
190
+ ${info?.published.length
191
+ ? html `<dt>
192
+ ${this.localize.termOrDefault('uSync_previewPublished', 'Published')}
193
+ </dt>
194
+ <dd>
195
+ <span class=${classMap({ tags: true, ...changed('published') })}>
196
+ ${info.published.map((p) => __classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_renderPublished).call(this, p.culture, p.published))}
197
+ </span>
198
+ </dd>`
199
+ : nothing}
200
+ </dl>
201
+ ${info?.trashed
202
+ ? html `<uui-tag color="danger" look="secondary"
203
+ >${this.localize.termOrDefault('uSync_previewTrashed', 'In the recycle bin')}</uui-tag
204
+ >`
205
+ : nothing}
206
+ </uui-box>
207
+ `;
208
+ };
209
+ _uSyncContentPreviewElement_renderPublished = function _uSyncContentPreviewElement_renderPublished(culture, published) {
210
+ const label = published
211
+ ? this.localize.termOrDefault('uSync_previewPublished', 'Published')
212
+ : this.localize.termOrDefault('uSync_previewNotPublished', 'Not published');
213
+ return html `<uui-tag
214
+ size="s"
215
+ look=${published ? 'primary' : 'secondary'}
216
+ color=${published ? 'positive' : 'default'}
217
+ >${culture ? `${culture}: ` : ''}${label}</uui-tag
218
+ >`;
219
+ };
220
+ _uSyncContentPreviewElement_name = function _uSyncContentPreviewElement_name(item) {
221
+ const variant = item.variants.find((v) => (v.culture ?? undefined) === this._culture) ??
222
+ item.variants[0];
223
+ return variant?.name ?? '';
224
+ };
225
+ _uSyncContentPreviewElement_renderTabButton = function _uSyncContentPreviewElement_renderTabButton(tab, active) {
226
+ const changed = __classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_tabProperties).call(this, tab).some((p) => __classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_valueStatus).call(this, p.property));
227
+ const label = tab.name || this.localize.termOrDefault('uSync_previewGenericTab', 'Generic');
228
+ return html `<uui-tab
229
+ label=${label}
230
+ ?active=${active}
231
+ @click=${() => (this._activeTab = tab.name)}>
232
+ <span class="tab-label">
233
+ ${label} ${changed ? html `<span class="dot changed"></span>` : nothing}
234
+ </span>
235
+ </uui-tab>`;
236
+ };
237
+ _uSyncContentPreviewElement_renderTab = function _uSyncContentPreviewElement_renderTab(item, tab) {
238
+ // inert rather than readonly: editors are shown as an editor would see them,
239
+ // but nothing in the preview can be changed.
240
+ return html `
241
+ <umb-property-dataset .value=${__classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_datasetValue).call(this, item)} inert>
242
+ ${tab.properties.length ? html `<uui-box>${__classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_renderProperties).call(this, tab.properties)}</uui-box>` : nothing}
243
+ ${repeat(tab.groups, (group) => group.name, (group) => html `<uui-box headline=${group.name}
244
+ >${__classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_renderProperties).call(this, group.properties)}</uui-box
245
+ >`)}
246
+ </umb-property-dataset>
247
+ `;
248
+ };
249
+ _uSyncContentPreviewElement_renderProperties = function _uSyncContentPreviewElement_renderProperties(properties) {
250
+ return repeat(properties, (entry) => entry.property.id, ({ property: p }) => {
251
+ const dataType = __classPrivateFieldGet(this, _uSyncContentPreviewElement_dataTypes, "f").get(p.dataType.id);
252
+ const status = __classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_valueStatus).call(this, p);
253
+ return html `<div class="property ${status ?? ''}">
254
+ ${dataType
255
+ ? html `<umb-property
256
+ .alias=${p.alias}
257
+ .label=${p.name}
258
+ .description=${p.description ?? ''}
259
+ .propertyEditorUiAlias=${dataType.editorUiAlias}
260
+ .config=${dataType.values}
261
+ .appearance=${p.appearance}></umb-property>`
262
+ : html `<p class="empty">${p.name}</p>`}
263
+ </div>`;
264
+ });
265
+ };
266
+ _uSyncContentPreviewElement_visibleTabs = function _uSyncContentPreviewElement_visibleTabs(tabs) {
267
+ if (!this._onlyChanges)
268
+ return tabs;
269
+ const keep = (properties) => properties.filter((p) => __classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_valueStatus).call(this, p.property));
270
+ return tabs
271
+ .map((tab) => ({
272
+ ...tab,
273
+ properties: keep(tab.properties),
274
+ groups: tab.groups
275
+ .map((group) => ({ ...group, properties: keep(group.properties) }))
276
+ .filter((group) => group.properties.length > 0),
277
+ }))
278
+ .filter((tab) => tab.properties.length > 0 || tab.groups.length > 0);
279
+ };
280
+ _uSyncContentPreviewElement_tabProperties = function _uSyncContentPreviewElement_tabProperties(tab) {
281
+ return [...tab.properties, ...tab.groups.flatMap((g) => g.properties)];
282
+ };
283
+ _uSyncContentPreviewElement_datasetValue = function _uSyncContentPreviewElement_datasetValue(item) {
284
+ return item.values
285
+ .filter((v) => !v.segment && (!v.culture || v.culture === this._culture))
286
+ .map((v) => ({ alias: v.alias, value: v.value }));
287
+ };
288
+ _uSyncContentPreviewElement_value = function _uSyncContentPreviewElement_value(item, p) {
289
+ const culture = p.variesByCulture ? this._culture : undefined;
290
+ return item?.values.find((v) => v.alias === p.alias && !v.segment && (v.culture ?? undefined) === culture)?.value;
291
+ };
292
+ _uSyncContentPreviewElement_valueStatus = function _uSyncContentPreviewElement_valueStatus(p) {
293
+ const current = __classPrivateFieldGet(this, _uSyncContentPreviewElement_current, "f").item;
294
+ const incoming = __classPrivateFieldGet(this, _uSyncContentPreviewElement_incoming, "f").item;
295
+ if (!current || !incoming)
296
+ return undefined;
297
+ const before = __classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_value).call(this, current, p);
298
+ const after = __classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_value).call(this, incoming, p);
299
+ if (deepEqual(normalise(before), normalise(after)))
300
+ return undefined;
301
+ if (isEmpty(before))
302
+ return 'added';
303
+ if (isEmpty(after))
304
+ return 'removed';
305
+ return 'changed';
306
+ };
307
+ uSyncContentPreviewElement.styles = css `
308
+ :host {
309
+ display: block;
310
+ container-type: inline-size;
311
+ }
312
+
313
+ /* the toolbar shares the headline row with the incoming side, on the right. */
314
+ .toolbar {
315
+ grid-column: 2;
316
+ grid-row: 1;
317
+ justify-self: end;
318
+ align-self: center;
319
+ z-index: 1;
320
+ display: flex;
321
+ flex-wrap: wrap;
322
+ align-items: center;
323
+ gap: var(--uui-size-space-4);
324
+ }
325
+
326
+ /* the two sides share rows (headline, info, tabs, content), so the
327
+ tab bars and properties line up even when the info boxes differ. */
328
+ .sides {
329
+ display: grid;
330
+ grid-template-columns: 1fr 1fr;
331
+ grid-template-rows: auto auto auto 1fr;
332
+ gap: var(--uui-size-space-4) var(--uui-size-space-5);
333
+ }
334
+
335
+ .side {
336
+ display: grid;
337
+ grid-row: span 4;
338
+ grid-template-rows: subgrid;
339
+ align-items: start;
340
+ min-width: 0;
341
+ }
342
+
343
+ .side.current {
344
+ grid-column: 1;
345
+ grid-row: 1 / span 4;
346
+ }
347
+
348
+ .side.incoming {
349
+ grid-column: 2;
350
+ grid-row: 1 / span 4;
351
+ }
352
+
353
+ .side > .info:not(:last-child) {
354
+ align-self: stretch;
355
+ }
356
+
357
+ @container (max-width: 760px) {
358
+ .sides {
359
+ grid-template-columns: 1fr;
360
+ grid-template-rows: none;
361
+ row-gap: var(--uui-size-layout-1);
362
+ }
363
+
364
+ .side,
365
+ .side.current,
366
+ .side.incoming,
367
+ .toolbar {
368
+ grid-column: 1;
369
+ grid-row: auto;
370
+ }
371
+
372
+ .side {
373
+ display: flex;
374
+ flex-direction: column;
375
+ align-items: stretch;
376
+ gap: var(--uui-size-space-4);
377
+ }
378
+
379
+ .side > .side-headline {
380
+ align-self: auto;
381
+ }
382
+ }
383
+
384
+ umb-property-dataset {
385
+ display: flex;
386
+ flex-direction: column;
387
+ gap: var(--uui-size-space-4);
388
+ min-width: 0;
389
+ }
390
+
391
+ .side-headline {
392
+ align-self: center;
393
+ margin: 0;
394
+ font-size: var(--uui-type-small-size);
395
+ text-transform: uppercase;
396
+ letter-spacing: 0.04em;
397
+ color: var(--uui-color-text-alt);
398
+ }
399
+
400
+ .headline {
401
+ display: flex;
402
+ align-items: center;
403
+ gap: var(--uui-size-space-3);
404
+ }
405
+
406
+ .meta {
407
+ display: grid;
408
+ grid-template-columns: max-content 1fr;
409
+ align-items: center;
410
+ gap: var(--uui-size-space-2) var(--uui-size-space-5);
411
+ margin: 0 0 var(--uui-size-space-2);
412
+ }
413
+
414
+ .meta dt {
415
+ font-weight: 700;
416
+ }
417
+
418
+ .tags {
419
+ display: inline-flex;
420
+ flex-wrap: wrap;
421
+ gap: var(--uui-size-space-2);
422
+ }
423
+
424
+ .meta dd {
425
+ display: flex;
426
+ flex-wrap: wrap;
427
+ gap: var(--uui-size-space-2);
428
+ margin: 0;
429
+ }
430
+
431
+ /* a changed field gets a soft highlight, spread with a shadow so the text doesn't move. */
432
+ .changed:not(.property):not(.dot) {
433
+ background: color-mix(in srgb, var(--uui-color-warning) 35%, transparent);
434
+ border-radius: var(--uui-border-radius);
435
+ box-shadow: 0 0 0 var(--uui-size-space-1)
436
+ color-mix(in srgb, var(--uui-color-warning) 35%, transparent);
437
+ }
438
+
439
+ uui-tab-group {
440
+ --uui-tab-divider: var(--uui-color-border);
441
+ border-bottom: 1px solid var(--uui-color-border);
442
+ }
443
+
444
+ .tab-label {
445
+ display: inline-flex;
446
+ align-items: center;
447
+ gap: var(--uui-size-space-2);
448
+ white-space: nowrap;
449
+ }
450
+
451
+ .dot {
452
+ display: inline-block;
453
+ width: 8px;
454
+ height: 8px;
455
+ border-radius: 50%;
456
+ }
457
+
458
+ .dot.changed {
459
+ background: var(--uui-color-warning);
460
+ }
461
+
462
+ /* marked with an inset bar rather than a border, so the content doesn't shift. */
463
+ .property.added {
464
+ box-shadow: inset 3px 0 0 var(--uui-color-positive);
465
+ background: color-mix(in srgb, var(--uui-color-positive) 6%, transparent);
466
+ }
467
+
468
+ .property.removed {
469
+ box-shadow: inset 3px 0 0 var(--uui-color-danger);
470
+ background: color-mix(in srgb, var(--uui-color-danger) 6%, transparent);
471
+ }
472
+
473
+ .property.changed {
474
+ box-shadow: inset 3px 0 0 var(--uui-color-warning);
475
+ background: color-mix(in srgb, var(--uui-color-warning) 10%, transparent);
476
+ }
477
+
478
+ /* properties run edge to edge in their box, like the backoffice editor. */
479
+ .property {
480
+ padding: 0 var(--uui-size-space-5);
481
+ margin: 0 calc(-1 * var(--uui-size-space-5));
482
+ }
483
+
484
+ .property:first-child {
485
+ margin-top: calc(-1 * var(--uui-size-space-5));
486
+ }
487
+
488
+ .property:last-child {
489
+ margin-bottom: calc(-1 * var(--uui-size-space-5));
490
+ }
491
+
492
+ .property + .property {
493
+ border-top: 1px solid var(--uui-color-divider);
494
+ }
495
+
496
+ /* umb-property pads itself for a full workspace, tighten it up here. */
497
+ umb-property {
498
+ --uui-size-layout-1: var(--uui-size-space-4);
499
+ }
500
+
501
+ .empty {
502
+ margin: 0;
503
+ color: var(--uui-color-text-alt);
504
+ }
505
+ `;
506
+ __decorate([
507
+ property({ type: Object })
508
+ ], uSyncContentPreviewElement.prototype, "preview", void 0);
509
+ __decorate([
510
+ state()
511
+ ], uSyncContentPreviewElement.prototype, "_activeTab", void 0);
512
+ __decorate([
513
+ state()
514
+ ], uSyncContentPreviewElement.prototype, "_culture", void 0);
515
+ __decorate([
516
+ state()
517
+ ], uSyncContentPreviewElement.prototype, "_onlyChanges", void 0);
518
+ uSyncContentPreviewElement = __decorate([
519
+ customElement('usync-content-preview')
520
+ ], uSyncContentPreviewElement);
521
+ export { uSyncContentPreviewElement };
522
+ /** values that mean "nothing set" compare as equal */
523
+ function normalise(value) {
524
+ return isEmpty(value) ? undefined : value;
525
+ }
526
+ function isEmpty(value) {
527
+ return (value === undefined ||
528
+ value === null ||
529
+ value === '' ||
530
+ (Array.isArray(value) && value.length === 0));
531
+ }
532
+ export default uSyncContentPreviewElement;