@jumoo/usync 17.6.1-prerelease.19 → 17.6.1-prerelease.21

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.
@@ -0,0 +1,16 @@
1
+ import type { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
2
+ import type { uSyncPreviewLabels } from '../preview/types.js';
3
+ export type PreviewSide = 'current' | 'incoming';
4
+ /** the headline over one side of a preview. */
5
+ export declare function renderPreviewHeadline(host: UmbLitElement, side: PreviewSide, labels?: uSyncPreviewLabels): import("lit-html").TemplateResult<1>;
6
+ /**
7
+ * styles shared by the sides of a preview (each side is `.side.current` or `.side.incoming`).
8
+ *
9
+ * the incoming side (the source) is always on the left, and the current side (the
10
+ * target, which the import changes) on the right.
11
+ *
12
+ * what differs is red on the current side (what goes) and green on the incoming
13
+ * side (what comes in), so you can see which way the change runs whichever way
14
+ * round the sites are. elements colour their changes with `--usync-preview-change`.
15
+ */
16
+ export declare const previewSideStyles: import("lit").CSSResult;
@@ -0,0 +1,38 @@
1
+ import { css, html } from '@umbraco-cms/backoffice/external/lit';
2
+ /** the headline over one side of a preview. */
3
+ export function renderPreviewHeadline(host, side, labels) {
4
+ const headline = side === 'current'
5
+ ? (labels?.current ??
6
+ host.localize.termOrDefault('uSync_previewCurrent', 'Current (this site)'))
7
+ : (labels?.incoming ??
8
+ host.localize.termOrDefault('uSync_previewIncoming', 'Incoming (uSync files)'));
9
+ return html `<h4 class="side-headline">${headline}</h4>`;
10
+ }
11
+ /**
12
+ * styles shared by the sides of a preview (each side is `.side.current` or `.side.incoming`).
13
+ *
14
+ * the incoming side (the source) is always on the left, and the current side (the
15
+ * target, which the import changes) on the right.
16
+ *
17
+ * what differs is red on the current side (what goes) and green on the incoming
18
+ * side (what comes in), so you can see which way the change runs whichever way
19
+ * round the sites are. elements colour their changes with `--usync-preview-change`.
20
+ */
21
+ export const previewSideStyles = css `
22
+ .side.current {
23
+ --usync-preview-change: var(--uui-color-danger);
24
+ }
25
+
26
+ .side.incoming {
27
+ --usync-preview-change: var(--uui-color-positive);
28
+ }
29
+
30
+ .side-headline {
31
+ align-self: center;
32
+ margin: 0;
33
+ font-size: var(--uui-type-small-size);
34
+ text-transform: uppercase;
35
+ letter-spacing: 0.04em;
36
+ color: var(--uui-color-text-alt);
37
+ }
38
+ `;
@@ -2,6 +2,7 @@ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
2
2
  import { type PropertyValues, nothing } from '@umbraco-cms/backoffice/external/lit';
3
3
  import '@umbraco-cms/backoffice/components';
4
4
  import type { SyncItemPreviewResponse } from '../api';
5
+ import { type uSyncPreviewLabels } from '../preview/types.js';
5
6
  /**
6
7
  * Shows the current and incoming versions of a content or media item side by
7
8
  * side, laid out the way the backoffice editor shows them, with every value
@@ -10,6 +11,7 @@ import type { SyncItemPreviewResponse } from '../api';
10
11
  export declare class uSyncContentPreviewElement extends UmbLitElement {
11
12
  #private;
12
13
  preview?: SyncItemPreviewResponse;
14
+ labels?: uSyncPreviewLabels;
13
15
  /** the tab shown on both sides (by name) */
14
16
  private _activeTab?;
15
17
  /** the culture shown on both sides (undefined for invariant items) */
@@ -17,7 +19,7 @@ export declare class uSyncContentPreviewElement extends UmbLitElement {
17
19
  private _onlyChanges;
18
20
  protected willUpdate(changed: PropertyValues<this>): void;
19
21
  render(): typeof nothing | import("lit-html").TemplateResult<1>;
20
- static styles: import("lit").CSSResult;
22
+ static styles: import("lit").CSSResult[];
21
23
  }
22
24
  export default uSyncContentPreviewElement;
23
25
  declare global {
@@ -19,6 +19,7 @@ var _uSyncContentPreviewElement_instances, _uSyncContentPreviewElement_current,
19
19
  import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
20
20
  import { classMap, css, customElement, html, nothing, property, repeat, state, } from '@umbraco-cms/backoffice/external/lit';
21
21
  import '@umbraco-cms/backoffice/components';
22
+ import { previewSideStyles, renderPreviewHeadline, } from './preview-side.js';
22
23
  import { getPreviewModel, } from '../preview/types.js';
23
24
  import { buildContentTypeLayout, } from '../utils/preview/content-type-layout.js';
24
25
  import { deepEqual } from '../utils/diff/deep-equal.js';
@@ -71,8 +72,8 @@ let uSyncContentPreviewElement = class uSyncContentPreviewElement extends UmbLit
71
72
  return html `
72
73
  <div class="sides">
73
74
  ${__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
75
  ${__classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_renderSide).call(this, 'incoming', __classPrivateFieldGet(this, _uSyncContentPreviewElement_incoming, "f"), tabs, active)}
76
+ ${__classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_renderSide).call(this, 'current', __classPrivateFieldGet(this, _uSyncContentPreviewElement_current, "f"), tabs, active)}
76
77
  </div>
77
78
  `;
78
79
  }
@@ -109,18 +110,15 @@ _uSyncContentPreviewElement_renderToolbar = function _uSyncContentPreviewElement
109
110
  </div>`;
110
111
  };
111
112
  _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
113
  if (!data.item) {
116
114
  return html `<div class="side ${side}">
117
- <h4 class="side-headline">${headline}</h4>
115
+ ${renderPreviewHeadline(this, side, this.labels)}
118
116
  <uui-box class="info"><p class="empty">${__classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_missingMessage).call(this, side)}</p></uui-box>
119
117
  </div>`;
120
118
  }
121
119
  return html `
122
120
  <div class="side ${side}">
123
- <h4 class="side-headline">${headline}</h4>
121
+ ${renderPreviewHeadline(this, side, this.labels)}
124
122
  ${__classPrivateFieldGet(this, _uSyncContentPreviewElement_instances, "m", _uSyncContentPreviewElement_renderInfo).call(this, data)}
125
123
  ${tabs.length > 1 || (tabs.length === 1 && tabs[0].name)
126
124
  ? html `<uui-tab-group>
@@ -304,208 +302,198 @@ _uSyncContentPreviewElement_valueStatus = function _uSyncContentPreviewElement_v
304
302
  return 'removed';
305
303
  return 'changed';
306
304
  };
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
- }
305
+ uSyncContentPreviewElement.styles = [
306
+ previewSideStyles,
307
+ css `
308
+ :host {
309
+ display: block;
310
+ container-type: inline-size;
311
+ }
342
312
 
343
- .side.current {
344
- grid-column: 1;
345
- grid-row: 1 / span 4;
346
- }
313
+ /* the toolbar shares the headline row with the current 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
+ }
347
325
 
348
- .side.incoming {
349
- grid-column: 2;
350
- grid-row: 1 / span 4;
351
- }
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
+ }
352
334
 
353
- .side > .info:not(:last-child) {
354
- align-self: stretch;
355
- }
335
+ .side {
336
+ display: grid;
337
+ grid-row: span 4;
338
+ grid-template-rows: subgrid;
339
+ align-items: start;
340
+ min-width: 0;
341
+ }
356
342
 
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);
343
+ .side.current {
344
+ grid-column: 2;
345
+ grid-row: 1 / span 4;
362
346
  }
363
347
 
364
- .side,
365
- .side.current,
366
- .side.incoming,
367
- .toolbar {
348
+ .side.incoming {
368
349
  grid-column: 1;
369
- grid-row: auto;
350
+ grid-row: 1 / span 4;
370
351
  }
371
352
 
372
- .side {
373
- display: flex;
374
- flex-direction: column;
375
- align-items: stretch;
376
- gap: var(--uui-size-space-4);
353
+ .side > .info:not(:last-child) {
354
+ align-self: stretch;
377
355
  }
378
356
 
379
- .side > .side-headline {
380
- align-self: auto;
381
- }
382
- }
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
+ }
383
363
 
384
- umb-property-dataset {
385
- display: flex;
386
- flex-direction: column;
387
- gap: var(--uui-size-space-4);
388
- min-width: 0;
389
- }
364
+ .side,
365
+ .side.current,
366
+ .side.incoming,
367
+ .toolbar {
368
+ grid-column: 1;
369
+ grid-row: auto;
370
+ }
390
371
 
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
- }
372
+ .side {
373
+ display: flex;
374
+ flex-direction: column;
375
+ align-items: stretch;
376
+ gap: var(--uui-size-space-4);
377
+ }
399
378
 
400
- .headline {
401
- display: flex;
402
- align-items: center;
403
- gap: var(--uui-size-space-3);
404
- }
379
+ .side > .side-headline {
380
+ align-self: auto;
381
+ }
382
+ }
405
383
 
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
- }
384
+ umb-property-dataset {
385
+ display: flex;
386
+ flex-direction: column;
387
+ gap: var(--uui-size-space-4);
388
+ min-width: 0;
389
+ }
413
390
 
414
- .meta dt {
415
- font-weight: 700;
416
- }
391
+ .headline {
392
+ display: flex;
393
+ align-items: center;
394
+ gap: var(--uui-size-space-3);
395
+ }
417
396
 
418
- .tags {
419
- display: inline-flex;
420
- flex-wrap: wrap;
421
- gap: var(--uui-size-space-2);
422
- }
397
+ .meta {
398
+ display: grid;
399
+ grid-template-columns: max-content 1fr;
400
+ align-items: center;
401
+ gap: var(--uui-size-space-2) var(--uui-size-space-5);
402
+ margin: 0 0 var(--uui-size-space-2);
403
+ }
423
404
 
424
- .meta dd {
425
- display: flex;
426
- flex-wrap: wrap;
427
- gap: var(--uui-size-space-2);
428
- margin: 0;
429
- }
405
+ .meta dt {
406
+ font-weight: 700;
407
+ }
430
408
 
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
- }
409
+ .tags {
410
+ display: inline-flex;
411
+ flex-wrap: wrap;
412
+ gap: var(--uui-size-space-2);
413
+ }
438
414
 
439
- uui-tab-group {
440
- --uui-tab-divider: var(--uui-color-border);
441
- border-bottom: 1px solid var(--uui-color-border);
442
- }
415
+ .meta dd {
416
+ display: flex;
417
+ flex-wrap: wrap;
418
+ gap: var(--uui-size-space-2);
419
+ margin: 0;
420
+ }
443
421
 
444
- .tab-label {
445
- display: inline-flex;
446
- align-items: center;
447
- gap: var(--uui-size-space-2);
448
- white-space: nowrap;
449
- }
422
+ /* a changed field gets a soft highlight, spread with a shadow so the text doesn't move. */
423
+ .changed:not(.property):not(.dot) {
424
+ background: color-mix(in srgb, var(--usync-preview-change) 35%, transparent);
425
+ border-radius: var(--uui-border-radius);
426
+ box-shadow: 0 0 0 var(--uui-size-space-1)
427
+ color-mix(in srgb, var(--usync-preview-change) 35%, transparent);
428
+ }
450
429
 
451
- .dot {
452
- display: inline-block;
453
- width: 8px;
454
- height: 8px;
455
- border-radius: 50%;
456
- }
430
+ uui-tab-group {
431
+ --uui-tab-divider: var(--uui-color-border);
432
+ border-bottom: 1px solid var(--uui-color-border);
433
+ }
457
434
 
458
- .dot.changed {
459
- background: var(--uui-color-warning);
460
- }
435
+ .tab-label {
436
+ display: inline-flex;
437
+ align-items: center;
438
+ gap: var(--uui-size-space-2);
439
+ white-space: nowrap;
440
+ }
461
441
 
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
- }
442
+ .dot {
443
+ display: inline-block;
444
+ width: 8px;
445
+ height: 8px;
446
+ border-radius: 50%;
447
+ }
467
448
 
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
- }
449
+ .dot.changed {
450
+ background: var(--uui-color-warning);
451
+ }
472
452
 
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
- }
453
+ /* marked with an inset bar rather than a border, so the content doesn't shift.
454
+ the colour is the side's (red going, green coming in), whatever the change. */
455
+ .property.added,
456
+ .property.removed,
457
+ .property.changed {
458
+ box-shadow: inset 3px 0 0 var(--usync-preview-change);
459
+ background: color-mix(in srgb, var(--usync-preview-change) 10%, transparent);
460
+ }
477
461
 
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
- }
462
+ /* properties run edge to edge in their box, like the backoffice editor. */
463
+ .property {
464
+ padding: 0 var(--uui-size-space-5);
465
+ margin: 0 calc(-1 * var(--uui-size-space-5));
466
+ }
483
467
 
484
- .property:first-child {
485
- margin-top: calc(-1 * var(--uui-size-space-5));
486
- }
468
+ .property:first-child {
469
+ margin-top: calc(-1 * var(--uui-size-space-5));
470
+ }
487
471
 
488
- .property:last-child {
489
- margin-bottom: calc(-1 * var(--uui-size-space-5));
490
- }
472
+ .property:last-child {
473
+ margin-bottom: calc(-1 * var(--uui-size-space-5));
474
+ }
491
475
 
492
- .property + .property {
493
- border-top: 1px solid var(--uui-color-divider);
494
- }
476
+ .property + .property {
477
+ border-top: 1px solid var(--uui-color-divider);
478
+ }
495
479
 
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
- }
480
+ /* umb-property pads itself for a full workspace, tighten it up here. */
481
+ umb-property {
482
+ --uui-size-layout-1: var(--uui-size-space-4);
483
+ }
500
484
 
501
- .empty {
502
- margin: 0;
503
- color: var(--uui-color-text-alt);
504
- }
505
- `;
485
+ .empty {
486
+ margin: 0;
487
+ color: var(--uui-color-text-alt);
488
+ }
489
+ `,
490
+ ];
506
491
  __decorate([
507
492
  property({ type: Object })
508
493
  ], uSyncContentPreviewElement.prototype, "preview", void 0);
494
+ __decorate([
495
+ property({ type: Object })
496
+ ], uSyncContentPreviewElement.prototype, "labels", void 0);
509
497
  __decorate([
510
498
  state()
511
499
  ], uSyncContentPreviewElement.prototype, "_activeTab", void 0);
@@ -2,6 +2,7 @@ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
2
2
  import { type PropertyValues, nothing } from '@umbraco-cms/backoffice/external/lit';
3
3
  import '@umbraco-cms/backoffice/components';
4
4
  import type { SyncItemPreviewResponse } from '../api';
5
+ import { type uSyncPreviewLabels } from '../preview/types.js';
5
6
  /**
6
7
  * Shows the current and incoming versions of a document, media or member
7
8
  * type side by side, laid out the way the backoffice editor shows them, with
@@ -11,11 +12,12 @@ import type { SyncItemPreviewResponse } from '../api';
11
12
  export declare class uSyncContentTypePreviewElement extends UmbLitElement {
12
13
  #private;
13
14
  preview?: SyncItemPreviewResponse;
15
+ labels?: uSyncPreviewLabels;
14
16
  /** the tab shown on both sides (by name, so it lines up when ids differ) */
15
17
  private _activeTab?;
16
18
  protected willUpdate(changed: PropertyValues<this>): void;
17
19
  render(): typeof nothing | import("lit-html").TemplateResult<1>;
18
- static styles: import("lit").CSSResult;
20
+ static styles: import("lit").CSSResult[];
19
21
  }
20
22
  export default uSyncContentTypePreviewElement;
21
23
  declare global {