@arsedizioni/ars-utils 22.1.5 → 22.5.2

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 (78) hide show
  1. package/README.md +158 -10
  2. package/clipper.ui/clipper.scss +564 -0
  3. package/fesm2022/arsedizioni-ars-utils-clipper.common.mjs +1 -1
  4. package/fesm2022/arsedizioni-ars-utils-clipper.common.mjs.map +1 -1
  5. package/fesm2022/arsedizioni-ars-utils-clipper.ui.mjs +11 -7
  6. package/fesm2022/arsedizioni-ars-utils-clipper.ui.mjs.map +1 -1
  7. package/fesm2022/arsedizioni-ars-utils-core.date.mjs +609 -0
  8. package/fesm2022/arsedizioni-ars-utils-core.date.mjs.map +1 -0
  9. package/fesm2022/arsedizioni-ars-utils-core.markdown.mjs +591 -0
  10. package/fesm2022/arsedizioni-ars-utils-core.markdown.mjs.map +1 -0
  11. package/fesm2022/arsedizioni-ars-utils-core.mjs +270 -1449
  12. package/fesm2022/arsedizioni-ars-utils-core.mjs.map +1 -1
  13. package/fesm2022/arsedizioni-ars-utils-evolution.common.mjs +1 -1
  14. package/fesm2022/arsedizioni-ars-utils-evolution.common.mjs.map +1 -1
  15. package/fesm2022/arsedizioni-ars-utils-support.common.mjs +1 -1
  16. package/fesm2022/arsedizioni-ars-utils-support.common.mjs.map +1 -1
  17. package/fesm2022/arsedizioni-ars-utils-ui.application.mjs +14 -4108
  18. package/fesm2022/arsedizioni-ars-utils-ui.application.mjs.map +1 -1
  19. package/fesm2022/arsedizioni-ars-utils-ui.controls.mjs +962 -0
  20. package/fesm2022/arsedizioni-ars-utils-ui.controls.mjs.map +1 -0
  21. package/fesm2022/arsedizioni-ars-utils-ui.dialogs.auth.mjs +506 -0
  22. package/fesm2022/arsedizioni-ars-utils-ui.dialogs.auth.mjs.map +1 -0
  23. package/fesm2022/arsedizioni-ars-utils-ui.dialogs.mjs +450 -0
  24. package/fesm2022/arsedizioni-ars-utils-ui.dialogs.mjs.map +1 -0
  25. package/fesm2022/arsedizioni-ars-utils-ui.dialogs.prompt.mjs +184 -0
  26. package/fesm2022/arsedizioni-ars-utils-ui.dialogs.prompt.mjs.map +1 -0
  27. package/fesm2022/arsedizioni-ars-utils-ui.dialogs.select.mjs +825 -0
  28. package/fesm2022/arsedizioni-ars-utils-ui.dialogs.select.mjs.map +1 -0
  29. package/fesm2022/arsedizioni-ars-utils-ui.files.mjs +708 -0
  30. package/fesm2022/arsedizioni-ars-utils-ui.files.mjs.map +1 -0
  31. package/fesm2022/arsedizioni-ars-utils-ui.filters.mjs +426 -0
  32. package/fesm2022/arsedizioni-ars-utils-ui.filters.mjs.map +1 -0
  33. package/fesm2022/arsedizioni-ars-utils-ui.help.mjs +531 -0
  34. package/fesm2022/arsedizioni-ars-utils-ui.help.mjs.map +1 -0
  35. package/fesm2022/arsedizioni-ars-utils-ui.mjs +54 -1227
  36. package/fesm2022/arsedizioni-ars-utils-ui.mjs.map +1 -1
  37. package/fesm2022/arsedizioni-ars-utils-ui.navigation.mjs +1049 -0
  38. package/fesm2022/arsedizioni-ars-utils-ui.navigation.mjs.map +1 -0
  39. package/fesm2022/arsedizioni-ars-utils-ui.notifications.mjs +263 -0
  40. package/fesm2022/arsedizioni-ars-utils-ui.notifications.mjs.map +1 -0
  41. package/fesm2022/arsedizioni-ars-utils-ui.oauth.mjs +4 -3
  42. package/fesm2022/arsedizioni-ars-utils-ui.oauth.mjs.map +1 -1
  43. package/fesm2022/arsedizioni-ars-utils-ui.paginator.mjs +53 -0
  44. package/fesm2022/arsedizioni-ars-utils-ui.paginator.mjs.map +1 -0
  45. package/fesm2022/arsedizioni-ars-utils-ui.shell.mjs +517 -0
  46. package/fesm2022/arsedizioni-ars-utils-ui.shell.mjs.map +1 -0
  47. package/fesm2022/arsedizioni-ars-utils-ui.tinymce.mjs +246 -0
  48. package/fesm2022/arsedizioni-ars-utils-ui.tinymce.mjs.map +1 -0
  49. package/fesm2022/arsedizioni-ars-utils.mjs +13 -12
  50. package/fesm2022/arsedizioni-ars-utils.mjs.map +1 -1
  51. package/help/package.json +4 -0
  52. package/package.json +80 -14
  53. package/styles/ui.colors.scss +23 -0
  54. package/support.ui/package.json +4 -0
  55. package/tinymce/package.json +4 -0
  56. package/types/arsedizioni-ars-utils-clipper.common.d.ts +1 -2
  57. package/types/arsedizioni-ars-utils-clipper.ui.d.ts +4 -1
  58. package/types/arsedizioni-ars-utils-core.d.ts +684 -1004
  59. package/types/arsedizioni-ars-utils-core.date.d.ts +304 -0
  60. package/types/arsedizioni-ars-utils-core.markdown.d.ts +159 -0
  61. package/types/arsedizioni-ars-utils-ui.application.d.ts +10 -2022
  62. package/types/arsedizioni-ars-utils-ui.controls.d.ts +413 -0
  63. package/types/arsedizioni-ars-utils-ui.d.ts +183 -566
  64. package/types/arsedizioni-ars-utils-ui.dialogs.auth.d.ts +224 -0
  65. package/types/arsedizioni-ars-utils-ui.dialogs.d.ts +228 -0
  66. package/types/arsedizioni-ars-utils-ui.dialogs.prompt.d.ts +47 -0
  67. package/types/arsedizioni-ars-utils-ui.dialogs.select.d.ts +309 -0
  68. package/types/arsedizioni-ars-utils-ui.files.d.ts +271 -0
  69. package/types/arsedizioni-ars-utils-ui.filters.d.ts +163 -0
  70. package/types/arsedizioni-ars-utils-ui.help.d.ts +220 -0
  71. package/types/arsedizioni-ars-utils-ui.navigation.d.ts +650 -0
  72. package/types/arsedizioni-ars-utils-ui.notifications.d.ts +73 -0
  73. package/types/arsedizioni-ars-utils-ui.paginator.d.ts +23 -0
  74. package/types/arsedizioni-ars-utils-ui.shell.d.ts +345 -0
  75. package/types/arsedizioni-ars-utils-ui.tinymce.d.ts +63 -0
  76. package/types/arsedizioni-ars-utils.d.ts +4 -10
  77. package/ui.tinymce/README.md +12 -0
  78. package/ui.tinymce/langs/it.js +466 -0
@@ -0,0 +1,517 @@
1
+ import { timer } from 'rxjs';
2
+ import { tap, first } from 'rxjs/operators';
3
+ import * as i0 from '@angular/core';
4
+ import { signal, computed, ChangeDetectionStrategy, Component, output, viewChild, afterNextRender, inject, DestroyRef, HostListener, ApplicationRef, EnvironmentInjector, createComponent, Service } from '@angular/core';
5
+ import { SafeHtmlPipe, SystemUtils } from '@arsedizioni/ars-utils/core';
6
+
7
+ /**
8
+ * Shows the busy overlay only if the operation is still running after a debounce delay, so that
9
+ * an operation that answers in 30 ms never makes the screen flash.
10
+ *
11
+ * Whoever creates one owns it: {@link clear} must be called when the operation ends, otherwise
12
+ * the overlay appears after the fact and stays.
13
+ */
14
+ class BusyTimer {
15
+ /**
16
+ * Arms the timer.
17
+ * @param shellService - The service that owns the overlay. A `DialogService` is accepted too,
18
+ * since it extends `ShellService`.
19
+ * @param due - Delay in milliseconds before the overlay appears. Defaults to `100`.
20
+ * @param message - Text to display. Defaults to `'Operazione in corso...'`.
21
+ */
22
+ constructor(shellService, due = 100, message = 'Operazione in corso...') {
23
+ this.shellService = shellService;
24
+ this.subscription = timer(due).pipe(tap(() => this.shellService.busy(message))).subscribe();
25
+ }
26
+ /**
27
+ * Disarms the timer and takes the overlay away.
28
+ * @returns void
29
+ */
30
+ clear() {
31
+ this.subscription.unsubscribe();
32
+ this.shellService.clearBusy();
33
+ }
34
+ }
35
+
36
+ /** Circumference of the spinner circle, in user units. Kept here so the template stays arithmetic-free. */
37
+ const SPINNER_CIRCUMFERENCE = 2 * Math.PI * 31.5;
38
+ /**
39
+ * Overlay that blocks interaction while an operation is running, in the four styles the
40
+ * applications use: progress bar, spinner, hourglass and bare wait.
41
+ *
42
+ * Reproduces `mat-progress-bar` and `mat-progress-spinner` in CSS and SVG rather than importing
43
+ * them, because this overlay is shown from the boot path — an HTTP interceptor calls it before
44
+ * any route exists — and `ui.shell` exists precisely so that path costs no Material.
45
+ *
46
+ * The instance is created once by {@link ShellService} and then reused: showing and hiding is a
47
+ * class on the host, never a `createComponent`, so the 40-odd calls a screen costs nothing.
48
+ */
49
+ class ShellBusyComponent {
50
+ constructor() {
51
+ /** Whether the overlay is on screen. Hidden with `display: none`, so it costs no layout. */
52
+ this.visible = signal(false, /* @ts-ignore */
53
+ ...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
54
+ /** Visual style of the indicator. */
55
+ this.type = signal('bar', /* @ts-ignore */
56
+ ...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
57
+ /** Current progress value (0-100), used when {@link progressMode} is `'determinate'`. */
58
+ this.progress = signal(0, /* @ts-ignore */
59
+ ...(ngDevMode ? [{ debugName: "progress" }] : /* istanbul ignore next */ []));
60
+ /** Progress mode of the bar and of the spinner. */
61
+ this.progressMode = signal('indeterminate', /* @ts-ignore */
62
+ ...(ngDevMode ? [{ debugName: "progressMode" }] : /* istanbul ignore next */ []));
63
+ /** Message displayed above the indicator. */
64
+ this.message = signal('', /* @ts-ignore */
65
+ ...(ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []));
66
+ /** Circumference of the spinner circle, bound to `stroke-dasharray`. */
67
+ this.circumference = SPINNER_CIRCUMFERENCE;
68
+ /** Length of the spinner arc still to be drawn, derived from {@link progress}. */
69
+ this.dashOffset = computed(() => SPINNER_CIRCUMFERENCE * (1 - Math.min(Math.max(this.progress(), 0), 100) / 100), /* @ts-ignore */
70
+ ...(ngDevMode ? [{ debugName: "dashOffset" }] : /* istanbul ignore next */ []));
71
+ }
72
+ /**
73
+ * Updates the overlay state.
74
+ *
75
+ * Same contract as the `BusyDialogComponent` it replaces, down to the two implicit rules that
76
+ * callers rely on: an empty message keeps the previous text (so `wait()` does not wipe it), and
77
+ * a progress above zero forces `'determinate'` whatever the caller passed.
78
+ * @param message - New message to display. An empty string preserves the current one.
79
+ * @param progress - Current progress value (0-100). Above zero it forces determinate mode.
80
+ * @param progressMode - Progress mode to use. Defaults to `'indeterminate'`.
81
+ * @param type - Visual style to use. Defaults to `'bar'`.
82
+ * @returns void
83
+ */
84
+ set(message, progress, progressMode = 'indeterminate', type = 'bar') {
85
+ if (message)
86
+ this.message.set(message);
87
+ if (type)
88
+ this.type.set(type);
89
+ this.progress.set(progress);
90
+ this.progressMode.set(progress > 0 ? 'determinate' : progressMode);
91
+ }
92
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: ShellBusyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
93
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: ShellBusyComponent, isStandalone: true, selector: "ars-shell-busy", host: { properties: { "class.ars-hidden": "!visible()" } }, ngImport: i0, template: "<div class=\"scrim\"></div>\n\n@if (type() === 'hourglass' || type() === 'wait') {\n<div class=\"bare\">\n <svg class=\"hourglass\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path d=\"M6 2h12v6l-4 4 4 4v6H6v-6l4-4-4-4zm2 2v3.2l4 4 4-4V4zm0 16h8v-3.2l-4-4-4 4z\" />\n </svg>\n @if (type() === 'hourglass' && message()) {\n <div class=\"message\" [innerHTML]=\"message() | safeHtml\"></div>\n }\n</div>\n} @else {\n<div class=\"panel\" role=\"status\" aria-live=\"polite\">\n @if (message()) {\n <div class=\"message\" [innerHTML]=\"message() | safeHtml\"></div>\n }\n\n @if (type() === 'bar') {\n <div class=\"bar\" [class.indeterminate]=\"progressMode() === 'indeterminate'\">\n <div class=\"bar-fill\" [style.width.%]=\"progressMode() === 'determinate' ? progress() : null\"></div>\n </div>\n } @else if (type() === 'spinner') {\n <svg class=\"spinner\" [class.indeterminate]=\"progressMode() === 'indeterminate'\" viewBox=\"0 0 70 70\"\n aria-hidden=\"true\">\n <circle class=\"track\" cx=\"35\" cy=\"35\" r=\"31.5\"></circle>\n <circle class=\"arc\" cx=\"35\" cy=\"35\" r=\"31.5\" [style.stroke-dasharray]=\"circumference\"\n [style.stroke-dashoffset]=\"progressMode() === 'determinate' ? dashOffset() : null\"></circle>\n </svg>\n }\n\n @if (progress() > 0) {\n <div class=\"percent\"><b>{{ progress() }}%</b></div>\n }\n</div>\n}\n", styles: [":host{position:fixed;inset:0;z-index:var(--ars-busy-z-index, 1090);display:flex;align-items:center;justify-content:center;font-family:var(--mat-sys-body-medium-font, Roboto, sans-serif);color:var(--ars-color-text, var(--mat-sys-on-surface, #191c1b))}:host(.ars-hidden){display:none}.scrim{position:absolute;inset:0;background:var(--ars-busy-scrim-color, rgba(0, 0, 0, .42));-webkit-backdrop-filter:blur(1px);backdrop-filter:blur(1px)}.panel{position:relative;min-width:250px;max-width:calc(100% - 24px);margin:12px;padding:24px;border-radius:var(--ars-dialog-radius, 24px);background:var(--ars-dialog-background-color, var(--mat-sys-surface-container-high, #e6eae8));box-shadow:var(--ars-dialog-elevation, 0 4px 8px 0 rgba(0, 0, 0, .2), 0 6px 20px 0 rgba(0, 0, 0, .19));text-align:center}.bare{position:relative;display:flex;flex-direction:column;align-items:center;color:var(--ars-busy-bare-color, #ffffff)}.message{font-size:larger;font-weight:600;padding-bottom:15px;text-align:center}.bare .message{padding-top:15px;padding-bottom:0}.percent{padding-top:8px;font-size:smaller}.bar{position:relative;max-width:350px;height:4px;margin:15px auto 0;overflow:hidden;border-radius:2px;background:var(--ars-progress-track-color, var(--mat-sys-surface-container-highest, #d5dbd8))}.bar-fill{position:absolute;inset:0 auto 0 0;width:0;border-radius:inherit;background:var(--ars-color-primary, var(--mat-sys-primary, #00a293));transition:width .12s linear}.bar.indeterminate .bar-fill{width:40%;transition:none;animation:ars-busy-bar 1.6s cubic-bezier(.65,.02,.35,1) infinite}@keyframes ars-busy-bar{0%{left:-40%}to{left:100%}}.spinner{display:block;width:70px;height:70px;margin:15px auto 0;transform:rotate(-90deg)}.spinner circle{fill:none;stroke-width:7;stroke-linecap:round}.spinner .track{stroke:var(--ars-progress-track-color, var(--mat-sys-surface-container-highest, #d5dbd8))}.spinner .arc{stroke:var(--ars-color-primary, var(--mat-sys-primary, #00a293));transition:stroke-dashoffset .12s linear}.spinner.indeterminate{animation:ars-busy-rotate 1.4s linear infinite}.spinner.indeterminate .arc{transition:none;stroke-dashoffset:0;animation:ars-busy-dash 1.4s ease-in-out infinite}@keyframes ars-busy-rotate{0%{transform:rotate(-90deg)}to{transform:rotate(270deg)}}@keyframes ars-busy-dash{0%{stroke-dasharray:15 183}50%{stroke-dasharray:145 53}to{stroke-dasharray:15 183}}.hourglass{width:80px;height:80px;fill:currentColor;animation:ars-busy-hourglass 3s linear infinite}@keyframes ars-busy-hourglass{0%{transform:rotate(360deg)}to{transform:rotate(0)}}@media(prefers-reduced-motion:reduce){.bar.indeterminate .bar-fill,.spinner.indeterminate,.spinner.indeterminate .arc,.hourglass{animation-duration:4s}}\n"], dependencies: [{ kind: "pipe", type: SafeHtmlPipe, name: "safeHtml" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
94
+ }
95
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: ShellBusyComponent, decorators: [{
96
+ type: Component,
97
+ args: [{ selector: 'ars-shell-busy', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [SafeHtmlPipe], host: { '[class.ars-hidden]': '!visible()' }, template: "<div class=\"scrim\"></div>\n\n@if (type() === 'hourglass' || type() === 'wait') {\n<div class=\"bare\">\n <svg class=\"hourglass\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path d=\"M6 2h12v6l-4 4 4 4v6H6v-6l4-4-4-4zm2 2v3.2l4 4 4-4V4zm0 16h8v-3.2l-4-4-4 4z\" />\n </svg>\n @if (type() === 'hourglass' && message()) {\n <div class=\"message\" [innerHTML]=\"message() | safeHtml\"></div>\n }\n</div>\n} @else {\n<div class=\"panel\" role=\"status\" aria-live=\"polite\">\n @if (message()) {\n <div class=\"message\" [innerHTML]=\"message() | safeHtml\"></div>\n }\n\n @if (type() === 'bar') {\n <div class=\"bar\" [class.indeterminate]=\"progressMode() === 'indeterminate'\">\n <div class=\"bar-fill\" [style.width.%]=\"progressMode() === 'determinate' ? progress() : null\"></div>\n </div>\n } @else if (type() === 'spinner') {\n <svg class=\"spinner\" [class.indeterminate]=\"progressMode() === 'indeterminate'\" viewBox=\"0 0 70 70\"\n aria-hidden=\"true\">\n <circle class=\"track\" cx=\"35\" cy=\"35\" r=\"31.5\"></circle>\n <circle class=\"arc\" cx=\"35\" cy=\"35\" r=\"31.5\" [style.stroke-dasharray]=\"circumference\"\n [style.stroke-dashoffset]=\"progressMode() === 'determinate' ? dashOffset() : null\"></circle>\n </svg>\n }\n\n @if (progress() > 0) {\n <div class=\"percent\"><b>{{ progress() }}%</b></div>\n }\n</div>\n}\n", styles: [":host{position:fixed;inset:0;z-index:var(--ars-busy-z-index, 1090);display:flex;align-items:center;justify-content:center;font-family:var(--mat-sys-body-medium-font, Roboto, sans-serif);color:var(--ars-color-text, var(--mat-sys-on-surface, #191c1b))}:host(.ars-hidden){display:none}.scrim{position:absolute;inset:0;background:var(--ars-busy-scrim-color, rgba(0, 0, 0, .42));-webkit-backdrop-filter:blur(1px);backdrop-filter:blur(1px)}.panel{position:relative;min-width:250px;max-width:calc(100% - 24px);margin:12px;padding:24px;border-radius:var(--ars-dialog-radius, 24px);background:var(--ars-dialog-background-color, var(--mat-sys-surface-container-high, #e6eae8));box-shadow:var(--ars-dialog-elevation, 0 4px 8px 0 rgba(0, 0, 0, .2), 0 6px 20px 0 rgba(0, 0, 0, .19));text-align:center}.bare{position:relative;display:flex;flex-direction:column;align-items:center;color:var(--ars-busy-bare-color, #ffffff)}.message{font-size:larger;font-weight:600;padding-bottom:15px;text-align:center}.bare .message{padding-top:15px;padding-bottom:0}.percent{padding-top:8px;font-size:smaller}.bar{position:relative;max-width:350px;height:4px;margin:15px auto 0;overflow:hidden;border-radius:2px;background:var(--ars-progress-track-color, var(--mat-sys-surface-container-highest, #d5dbd8))}.bar-fill{position:absolute;inset:0 auto 0 0;width:0;border-radius:inherit;background:var(--ars-color-primary, var(--mat-sys-primary, #00a293));transition:width .12s linear}.bar.indeterminate .bar-fill{width:40%;transition:none;animation:ars-busy-bar 1.6s cubic-bezier(.65,.02,.35,1) infinite}@keyframes ars-busy-bar{0%{left:-40%}to{left:100%}}.spinner{display:block;width:70px;height:70px;margin:15px auto 0;transform:rotate(-90deg)}.spinner circle{fill:none;stroke-width:7;stroke-linecap:round}.spinner .track{stroke:var(--ars-progress-track-color, var(--mat-sys-surface-container-highest, #d5dbd8))}.spinner .arc{stroke:var(--ars-color-primary, var(--mat-sys-primary, #00a293));transition:stroke-dashoffset .12s linear}.spinner.indeterminate{animation:ars-busy-rotate 1.4s linear infinite}.spinner.indeterminate .arc{transition:none;stroke-dashoffset:0;animation:ars-busy-dash 1.4s ease-in-out infinite}@keyframes ars-busy-rotate{0%{transform:rotate(-90deg)}to{transform:rotate(270deg)}}@keyframes ars-busy-dash{0%{stroke-dasharray:15 183}50%{stroke-dasharray:145 53}to{stroke-dasharray:15 183}}.hourglass{width:80px;height:80px;fill:currentColor;animation:ars-busy-hourglass 3s linear infinite}@keyframes ars-busy-hourglass{0%{transform:rotate(360deg)}to{transform:rotate(0)}}@media(prefers-reduced-motion:reduce){.bar.indeterminate .bar-fill,.spinner.indeterminate,.spinner.indeterminate .arc,.hourglass{animation-duration:4s}}\n"] }]
98
+ }] });
99
+
100
+ /**
101
+ * The shell's message panel: a modal that looks like a Material dialog and owes nothing to
102
+ * Material.
103
+ *
104
+ * It exists because shell, interceptors, guards and app initializers must be able to say
105
+ * "the session is gone" before a single route has been loaded, and paying for `mat-dialog`,
106
+ * `cdk/overlay` and the rest of that stack on the boot path costs the initial bundle more
107
+ * than every route of the application put together. The look is matched through CSS custom
108
+ * properties (`--ars-*` first, Material's `--mat-sys-*` next, a literal last), so an
109
+ * application that themes Material gets the same surface here for free.
110
+ *
111
+ * Instantiated imperatively by {@link ShellService}, never declared in a template: that is
112
+ * what lets an interceptor open it.
113
+ */
114
+ class ShellMessageComponent {
115
+ constructor() {
116
+ /** Emitted when the user dismisses the message, whichever way they did it. */
117
+ this.closed = output();
118
+ this.panel = viewChild.required('panel', /* @ts-ignore */
119
+ ...(ngDevMode ? [{ debugName: "panel" }] : /* istanbul ignore next */ []));
120
+ this.okButton = viewChild.required('ok', /* @ts-ignore */
121
+ ...(ngDevMode ? [{ debugName: "okButton" }] : /* istanbul ignore next */ []));
122
+ /** Unique id tying the panel to its heading for assistive technology. */
123
+ this.titleId = `ars-shell-message-title-${Math.random().toString(36).slice(2, 10)}`;
124
+ /** Current content, with the defaults the shell relies on already applied. */
125
+ this.data = signal({ message: '', title: 'Informazioni', okCaption: 'Ok', width: 500 }, /* @ts-ignore */
126
+ ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
127
+ /** True for a moment after a successful copy, so the button can acknowledge it. */
128
+ this.copied = signal(false, /* @ts-ignore */
129
+ ...(ngDevMode ? [{ debugName: "copied" }] : /* istanbul ignore next */ []));
130
+ this.closing = false;
131
+ afterNextRender(() => this.okButton().nativeElement.focus());
132
+ inject(DestroyRef).onDestroy(() => {
133
+ clearTimeout(this.dismissTimer);
134
+ clearTimeout(this.copiedTimer);
135
+ });
136
+ }
137
+ /**
138
+ * Replaces the content shown by the panel and restarts the auto-dismiss timer.
139
+ *
140
+ * Called on an already open panel by `ShellService.error()` so that a burst of failures
141
+ * updates one message instead of stacking modals nobody can dismiss.
142
+ * @param data - The new content to display.
143
+ * @returns void
144
+ */
145
+ setData(data) {
146
+ this.data.set({ title: 'Informazioni', okCaption: 'Ok', width: 500, ...data });
147
+ this.scheduleDismiss(this.data().dismissAfter);
148
+ }
149
+ /**
150
+ * Dismisses the panel. Safe to call more than once: only the first call is announced.
151
+ * @returns void
152
+ */
153
+ close() {
154
+ if (this.closing)
155
+ return;
156
+ this.closing = true;
157
+ clearTimeout(this.dismissTimer);
158
+ this.closed.emit();
159
+ }
160
+ /**
161
+ * Closes the panel on Escape, mirroring a Material dialog opened with the default config.
162
+ * @param e - The keyboard event captured at document level.
163
+ * @returns void
164
+ */
165
+ onKeydown(e) {
166
+ if (e.key === 'Escape') {
167
+ e.preventDefault();
168
+ this.close();
169
+ return;
170
+ }
171
+ if (e.key === 'Tab')
172
+ this.trapFocus(e);
173
+ }
174
+ /**
175
+ * Keeps Tab inside the panel while the message is up.
176
+ *
177
+ * A hand-rolled two-element version of what `cdk/a11y` does, which is all this panel needs:
178
+ * it never holds more than the copy button and the dismiss button.
179
+ * @param e - The Tab keydown event.
180
+ * @returns void
181
+ */
182
+ trapFocus(e) {
183
+ const focusable = Array.from(this.panel().nativeElement.querySelectorAll('button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'));
184
+ if (!focusable.length)
185
+ return;
186
+ const first = focusable[0];
187
+ const last = focusable[focusable.length - 1];
188
+ const active = document.activeElement;
189
+ if (e.shiftKey && (active === first || !this.panel().nativeElement.contains(active))) {
190
+ e.preventDefault();
191
+ last.focus();
192
+ }
193
+ else if (!e.shiftKey && active === last) {
194
+ e.preventDefault();
195
+ first.focus();
196
+ }
197
+ }
198
+ /**
199
+ * (Re)schedules the auto-dismiss timer, cancelling any pending one so a timer armed for an
200
+ * earlier message can never close a newer one.
201
+ * @param dismissAfter - Delay in milliseconds; no-op when falsy.
202
+ * @returns void
203
+ */
204
+ scheduleDismiss(dismissAfter) {
205
+ clearTimeout(this.dismissTimer);
206
+ this.dismissTimer = undefined;
207
+ if (dismissAfter)
208
+ this.dismissTimer = setTimeout(() => this.close(), dismissAfter);
209
+ }
210
+ /**
211
+ * Copies the message and its details to the clipboard, as both HTML and plain text.
212
+ *
213
+ * Unlike `InfoDialogComponent` there is no toast to report the outcome — the shell has no
214
+ * toast — so the button itself acknowledges it for a moment.
215
+ * @returns A promise that resolves once the copy has been attempted.
216
+ */
217
+ async copy() {
218
+ const content = this.panel().nativeElement.querySelector('.content');
219
+ if (!content)
220
+ return;
221
+ try {
222
+ await navigator.clipboard.write([
223
+ new ClipboardItem({
224
+ 'text/html': new Blob([content.innerHTML], { type: 'text/html' }),
225
+ 'text/plain': new Blob([content.innerText], { type: 'text/plain' })
226
+ })
227
+ ]);
228
+ this.copied.set(true);
229
+ clearTimeout(this.copiedTimer);
230
+ this.copiedTimer = setTimeout(() => this.copied.set(false), 1500);
231
+ }
232
+ catch {
233
+ // Clipboard permission denied or the document is not focused: nothing worth interrupting
234
+ // the user for, and the text is on screen anyway.
235
+ }
236
+ }
237
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: ShellMessageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
238
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: ShellMessageComponent, isStandalone: true, selector: "ars-shell-message", outputs: { closed: "closed" }, host: { listeners: { "document:keydown": "onKeydown($event)" } }, viewQueries: [{ propertyName: "panel", first: true, predicate: ["panel"], descendants: true, isSignal: true }, { propertyName: "okButton", first: true, predicate: ["ok"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"scrim\" (click)=\"close()\"></div>\n\n<div #panel class=\"panel\" role=\"alertdialog\" aria-modal=\"true\" [attr.aria-labelledby]=\"titleId\"\n [style.max-width.px]=\"data().width\">\n\n <h2 class=\"title\" [id]=\"titleId\" [innerHTML]=\"data().title | safeHtml\"></h2>\n\n <div class=\"content\">\n @if (data().message) {\n <div class=\"message\" [innerHTML]=\"data().message | safeHtml\"></div>\n }\n @if (data().details) {\n <div class=\"details-box\">\n <div class=\"details-separator\"></div>\n <p class=\"details-label\">Dettaglio:</p>\n <div class=\"details\">\n <div [innerHTML]=\"data().details | safeHtml\"></div>\n </div>\n </div>\n }\n </div>\n\n <div class=\"actions\">\n <button type=\"button\" class=\"icon-button\" (click)=\"copy()\"\n [title]=\"copied() ? 'Copiato negli appunti' : 'Copia negli appunti'\" aria-label=\"Copia negli appunti\">\n @if (copied()) {\n <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z\" /></svg>\n } @else {\n <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path\n d=\"M16 1H4a2 2 0 0 0-2 2v14h2V3h12zm3 4H8a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2m0 16H8V7h11z\" /></svg>\n }\n </button>\n <button #ok type=\"button\" class=\"flat-button\" (click)=\"close()\">{{ data().okCaption }}</button>\n </div>\n</div>\n", styles: [":host{position:fixed;inset:0;z-index:var(--ars-shell-z-index, 1100);display:flex;align-items:center;justify-content:center;box-sizing:border-box}.scrim{position:absolute;inset:0;background:var(--ars-scrim-color, rgba(0, 0, 0, .32));-webkit-backdrop-filter:blur(1px);backdrop-filter:blur(1px);animation:ars-shell-fade .15s cubic-bezier(0,0,.2,1)}.panel{position:relative;display:flex;flex-direction:column;width:100%;min-width:0;margin:12px;max-height:calc(100% - 24px);box-sizing:border-box;border-radius:var(--ars-dialog-radius, 28px);background:var(--ars-dialog-background-color, var(--mat-sys-surface-container-high, #e6eae8));color:var(--ars-color-text, var(--mat-sys-on-surface, #191c1b));box-shadow:var(--ars-dialog-elevation, 0 4px 8px 3px rgba(0, 0, 0, .15), 0 1px 3px 0 rgba(0, 0, 0, .3));font-family:var(--mat-sys-body-medium-font, Roboto, sans-serif);text-align:left;animation:ars-shell-enter .15s cubic-bezier(0,0,.2,1)}.title{margin:0;padding:24px 24px 16px;font:var(--mat-sys-headline-small, 400 24px/32px Roboto, sans-serif);color:inherit}.content{display:flex;flex-direction:column;flex:1 1 auto;min-height:0;padding:0;font:var(--mat-sys-body-medium, 400 14px/20px Roboto, sans-serif)}.message{flex:0 1 auto;min-height:0;padding:0 24px 24px;overflow-y:auto;overscroll-behavior:contain}.details-box{display:contents}.details-separator{flex:0 0 auto;height:1px;margin:0 24px 8px;background:var(--ars-color-divider, #757d87)}.details-label{flex:0 0 auto;margin:0 0 4px;padding:0 24px;font-size:.75em;text-transform:uppercase;color:var(--ars-color-secondary, var(--mat-sys-on-surface-variant, #4a635f))}.details{flex:1 1000 auto;min-height:64px;max-height:350px;padding:4px 24px 8px;overflow-y:auto;overscroll-behavior:contain;background:transparent;font-size:.85em}.actions{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:16px 24px 24px}button{font-family:inherit;cursor:pointer;border:none}button:focus-visible{outline:3px solid var(--ars-color-primary, var(--mat-sys-primary, #00a293));outline-offset:2px}.icon-button{display:inline-flex;align-items:center;justify-content:center;width:40px;height:40px;padding:0;border-radius:50%;background:transparent;color:inherit}.icon-button svg{width:24px;height:24px;fill:currentColor}.icon-button:hover{background:var(--ars-item-hover-background-color, rgba(0, 0, 0, .08))}.flat-button{height:40px;padding:0 24px;border-radius:20px;background:var(--ars-color-primary, var(--mat-sys-primary, #00a293));color:var(--ars-color-on-primary, var(--mat-sys-on-primary, #ffffff));font:var(--mat-sys-label-large, 500 14px/20px Roboto, sans-serif)}.flat-button:hover{filter:brightness(1.08)}@keyframes ars-shell-fade{0%{opacity:0}to{opacity:1}}@keyframes ars-shell-enter{0%{opacity:0;transform:scale(.7)}to{opacity:1;transform:none}}@media(prefers-reduced-motion:reduce){.scrim,.panel{animation:none}}\n"], dependencies: [{ kind: "pipe", type: SafeHtmlPipe, name: "safeHtml" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
239
+ }
240
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: ShellMessageComponent, decorators: [{
241
+ type: Component,
242
+ args: [{ selector: 'ars-shell-message', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [SafeHtmlPipe], template: "<div class=\"scrim\" (click)=\"close()\"></div>\n\n<div #panel class=\"panel\" role=\"alertdialog\" aria-modal=\"true\" [attr.aria-labelledby]=\"titleId\"\n [style.max-width.px]=\"data().width\">\n\n <h2 class=\"title\" [id]=\"titleId\" [innerHTML]=\"data().title | safeHtml\"></h2>\n\n <div class=\"content\">\n @if (data().message) {\n <div class=\"message\" [innerHTML]=\"data().message | safeHtml\"></div>\n }\n @if (data().details) {\n <div class=\"details-box\">\n <div class=\"details-separator\"></div>\n <p class=\"details-label\">Dettaglio:</p>\n <div class=\"details\">\n <div [innerHTML]=\"data().details | safeHtml\"></div>\n </div>\n </div>\n }\n </div>\n\n <div class=\"actions\">\n <button type=\"button\" class=\"icon-button\" (click)=\"copy()\"\n [title]=\"copied() ? 'Copiato negli appunti' : 'Copia negli appunti'\" aria-label=\"Copia negli appunti\">\n @if (copied()) {\n <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z\" /></svg>\n } @else {\n <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path\n d=\"M16 1H4a2 2 0 0 0-2 2v14h2V3h12zm3 4H8a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2m0 16H8V7h11z\" /></svg>\n }\n </button>\n <button #ok type=\"button\" class=\"flat-button\" (click)=\"close()\">{{ data().okCaption }}</button>\n </div>\n</div>\n", styles: [":host{position:fixed;inset:0;z-index:var(--ars-shell-z-index, 1100);display:flex;align-items:center;justify-content:center;box-sizing:border-box}.scrim{position:absolute;inset:0;background:var(--ars-scrim-color, rgba(0, 0, 0, .32));-webkit-backdrop-filter:blur(1px);backdrop-filter:blur(1px);animation:ars-shell-fade .15s cubic-bezier(0,0,.2,1)}.panel{position:relative;display:flex;flex-direction:column;width:100%;min-width:0;margin:12px;max-height:calc(100% - 24px);box-sizing:border-box;border-radius:var(--ars-dialog-radius, 28px);background:var(--ars-dialog-background-color, var(--mat-sys-surface-container-high, #e6eae8));color:var(--ars-color-text, var(--mat-sys-on-surface, #191c1b));box-shadow:var(--ars-dialog-elevation, 0 4px 8px 3px rgba(0, 0, 0, .15), 0 1px 3px 0 rgba(0, 0, 0, .3));font-family:var(--mat-sys-body-medium-font, Roboto, sans-serif);text-align:left;animation:ars-shell-enter .15s cubic-bezier(0,0,.2,1)}.title{margin:0;padding:24px 24px 16px;font:var(--mat-sys-headline-small, 400 24px/32px Roboto, sans-serif);color:inherit}.content{display:flex;flex-direction:column;flex:1 1 auto;min-height:0;padding:0;font:var(--mat-sys-body-medium, 400 14px/20px Roboto, sans-serif)}.message{flex:0 1 auto;min-height:0;padding:0 24px 24px;overflow-y:auto;overscroll-behavior:contain}.details-box{display:contents}.details-separator{flex:0 0 auto;height:1px;margin:0 24px 8px;background:var(--ars-color-divider, #757d87)}.details-label{flex:0 0 auto;margin:0 0 4px;padding:0 24px;font-size:.75em;text-transform:uppercase;color:var(--ars-color-secondary, var(--mat-sys-on-surface-variant, #4a635f))}.details{flex:1 1000 auto;min-height:64px;max-height:350px;padding:4px 24px 8px;overflow-y:auto;overscroll-behavior:contain;background:transparent;font-size:.85em}.actions{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:16px 24px 24px}button{font-family:inherit;cursor:pointer;border:none}button:focus-visible{outline:3px solid var(--ars-color-primary, var(--mat-sys-primary, #00a293));outline-offset:2px}.icon-button{display:inline-flex;align-items:center;justify-content:center;width:40px;height:40px;padding:0;border-radius:50%;background:transparent;color:inherit}.icon-button svg{width:24px;height:24px;fill:currentColor}.icon-button:hover{background:var(--ars-item-hover-background-color, rgba(0, 0, 0, .08))}.flat-button{height:40px;padding:0 24px;border-radius:20px;background:var(--ars-color-primary, var(--mat-sys-primary, #00a293));color:var(--ars-color-on-primary, var(--mat-sys-on-primary, #ffffff));font:var(--mat-sys-label-large, 500 14px/20px Roboto, sans-serif)}.flat-button:hover{filter:brightness(1.08)}@keyframes ars-shell-fade{0%{opacity:0}to{opacity:1}}@keyframes ars-shell-enter{0%{opacity:0;transform:scale(.7)}to{opacity:1;transform:none}}@media(prefers-reduced-motion:reduce){.scrim,.panel{animation:none}}\n"] }]
243
+ }], ctorParameters: () => [], propDecorators: { closed: [{ type: i0.Output, args: ["closed"] }], panel: [{ type: i0.ViewChild, args: ['panel', { isSignal: true }] }], okButton: [{ type: i0.ViewChild, args: ['ok', { isSignal: true }] }], onKeydown: [{
244
+ type: HostListener,
245
+ args: ['document:keydown', ['$event']]
246
+ }] } });
247
+
248
+ /** Grace period before the busy overlay is actually taken away, in milliseconds. */
249
+ const CLEAR_BUSY_GRACE = 500;
250
+ /**
251
+ * Everything the application can say to the user without asking anything back: a message, an
252
+ * error, and the wait overlay. No Angular Material behind any of it.
253
+ *
254
+ * `DialogService` extends this class, so a route component injects `DialogService` and has both
255
+ * halves; shell, HTTP interceptors, route guards and app initializers inject `ShellService` and
256
+ * pay for neither `mat-dialog` nor `cdk/overlay` on the boot path — measured at 445 KB of the
257
+ * 905 KB initial bundle on myARS, more than every route of the application put together.
258
+ *
259
+ * The methods keep the parameter order of the `DialogService` ones they came from, so no call
260
+ * site changed when they moved here.
261
+ *
262
+ * ## Stacking
263
+ *
264
+ * Outside the CDK overlay stack the order is a fixed z-index: the busy overlay sits at 1090 and
265
+ * the message at 1100, both above the `cdk-overlay-container` (1000). So an error raised while a
266
+ * Material dialog is open lands on top of it, which is what an error should do, and the busy
267
+ * overlay covers the dialog it belongs to. The one case a fixed number cannot express is a dialog
268
+ * opened while the overlay is still up — `DialogService.open()` takes the busy away immediately
269
+ * rather than with the grace period, precisely so that case cannot happen.
270
+ */
271
+ class ShellService {
272
+ constructor() {
273
+ this.appRef = inject(ApplicationRef);
274
+ this.environmentInjector = inject(EnvironmentInjector);
275
+ this.busyVisible = false;
276
+ }
277
+ // ---------------------------------------------------------------------------
278
+ // Messages
279
+ // ---------------------------------------------------------------------------
280
+ /**
281
+ * Shows an informational message.
282
+ * @param message - HTML message to display.
283
+ * @param title - Heading. Defaults to `'Informazioni'`.
284
+ * @param okCaption - Dismiss button label. Defaults to `'Ok'`.
285
+ * @param width - Maximum panel width in pixels. Defaults to `500`.
286
+ * @param dismissAfter - Auto-close delay in milliseconds (optional).
287
+ * @param details - Optional secondary details text.
288
+ * @returns A handle over the open message, or `null` outside the browser.
289
+ */
290
+ info(message, title = 'Informazioni', okCaption = 'Ok', width = 500, dismissAfter, details) {
291
+ this.clearBusy();
292
+ return this.showMessage('info', { message, title, okCaption, width, dismissAfter, details });
293
+ }
294
+ /**
295
+ * Shows an error message. When one is already on screen its content is replaced in place: a
296
+ * failing API answers many requests at once, and each of them must not add a panel of its own.
297
+ * @param message - HTML error message to display.
298
+ * @param log - Optional technical log or stack trace shown in the details panel.
299
+ * @param title - Heading. Defaults to `'Errore'`.
300
+ * @param okCaption - Dismiss button label. Defaults to `'Ok'`.
301
+ * @param width - Maximum panel width in pixels. Defaults to `500`.
302
+ * @param dismissAfter - Auto-close delay in milliseconds (optional).
303
+ * @returns A handle over the open message, or `null` outside the browser.
304
+ */
305
+ error(message, log, title = 'Errore', okCaption = 'Ok', width = 500, dismissAfter) {
306
+ this.clearBusy();
307
+ return this.showMessage('error', { message, title, okCaption, width, dismissAfter, details: log });
308
+ }
309
+ /**
310
+ * Closes the message currently on screen, if any. Does not touch the busy overlay.
311
+ * @returns void
312
+ */
313
+ closeMessage() {
314
+ if (!this.messageRef)
315
+ return;
316
+ const ref = this.messageRef;
317
+ this.messageRef = undefined;
318
+ this.messageKind = undefined;
319
+ this.appRef.detachView(ref.hostView);
320
+ ref.destroy();
321
+ if (this.previousOverflow !== undefined) {
322
+ document.body.style.overflow = this.previousOverflow;
323
+ this.previousOverflow = undefined;
324
+ }
325
+ this.previouslyFocused?.focus();
326
+ this.previouslyFocused = undefined;
327
+ this.resolveClosed?.();
328
+ this.resolveClosed = undefined;
329
+ }
330
+ /**
331
+ * Opens the message panel, or updates the one already open when it is showing the same kind of
332
+ * message.
333
+ * @param kind - Whether this is an informational or an error message.
334
+ * @param data - The content to display.
335
+ * @returns A handle over the open message, or `null` outside the browser.
336
+ */
337
+ showMessage(kind, data) {
338
+ if (!SystemUtils.isBrowser())
339
+ return null;
340
+ if (this.messageRef && this.messageKind === kind) {
341
+ this.messageRef.instance.setData(data);
342
+ this.messageRef.changeDetectorRef.detectChanges();
343
+ return this.messageHandle();
344
+ }
345
+ // A message of a different kind replaces the one on screen rather than stacking on it.
346
+ this.closeMessage();
347
+ const ref = createComponent(ShellMessageComponent, { environmentInjector: this.environmentInjector });
348
+ ref.instance.setData(data);
349
+ ref.instance.closed.subscribe(() => this.closeMessage());
350
+ this.previouslyFocused = document.activeElement instanceof HTMLElement ? document.activeElement : undefined;
351
+ this.previousOverflow = document.body.style.overflow;
352
+ document.body.style.overflow = 'hidden';
353
+ this.appRef.attachView(ref.hostView);
354
+ document.body.appendChild(ref.location.nativeElement);
355
+ this.messageRef = ref;
356
+ this.messageKind = kind;
357
+ return this.messageHandle();
358
+ }
359
+ /**
360
+ * Builds the handle returned to callers, wiring its `closed` promise to the current message.
361
+ * @returns The handle over the message currently on screen.
362
+ */
363
+ messageHandle() {
364
+ const closed = new Promise(resolve => { this.resolveClosed = resolve; });
365
+ return { close: () => this.closeMessage(), closed };
366
+ }
367
+ // ---------------------------------------------------------------------------
368
+ // Busy overlay
369
+ // ---------------------------------------------------------------------------
370
+ /**
371
+ * Shows or updates the busy overlay.
372
+ *
373
+ * Called dozens of times per screen, so it creates nothing after the first time: the component
374
+ * is built once and then kept, and showing it again is a class on the host element. The state
375
+ * is written to signals and checked synchronously before returning, so the message on screen is
376
+ * always the last one asked for — a second `busy()` in the same task never leaves the previous
377
+ * text behind.
378
+ * @param message - Text to display. An empty string keeps the current one.
379
+ * @param progress - Progress value (`-1` = indeterminate). Defaults to `-1`.
380
+ * @param progressMode - Progress mode. Defaults to `'indeterminate'`.
381
+ * @param type - Visual style of the overlay. Defaults to `'bar'`.
382
+ * @param action - Optional observable; the overlay is dismissed when it first emits. It
383
+ * replaces the one passed to a previous call, which is unsubscribed.
384
+ * @returns `true` if the overlay was brought up by this call, `false` if it was already up.
385
+ */
386
+ setBusy(message, progress = -1, progressMode = 'indeterminate', type = 'bar', action) {
387
+ if (!SystemUtils.isBrowser())
388
+ return false;
389
+ // Cancel any pending clearBusy(): it must never take away an overlay just asked for.
390
+ clearTimeout(this.clearBusyTimer);
391
+ this.clearBusyTimer = undefined;
392
+ const created = !this.busyVisible;
393
+ const ref = this.ensureBusy();
394
+ ref.instance.set(message, progress, progressMode, type);
395
+ ref.instance.visible.set(true);
396
+ this.busyVisible = true;
397
+ ref.changeDetectorRef.detectChanges();
398
+ // The action always replaces the previous one. Keeping the first, as the previous
399
+ // implementation did, meant the overlay outlived the operation that was actually running.
400
+ this.busyActionSubscription?.unsubscribe();
401
+ this.busyActionSubscription = action?.pipe(first()).subscribe(() => this.clearBusy());
402
+ return created;
403
+ }
404
+ /**
405
+ * Shows or updates the busy overlay using the progress-bar style.
406
+ * @param message - Text to display inside the overlay.
407
+ * @param progress - Progress value (`-1` = indeterminate). Defaults to `-1`.
408
+ * @param progressMode - Progress mode. Defaults to `'indeterminate'`.
409
+ * @param action - Optional observable; the overlay is dismissed when it emits.
410
+ * @returns `true` if the overlay was brought up by this call.
411
+ */
412
+ busy(message, progress = -1, progressMode = 'indeterminate', action) {
413
+ return this.setBusy(message, progress, progressMode, 'bar', action);
414
+ }
415
+ /**
416
+ * Shows or updates the busy overlay using the spinner style.
417
+ * @param message - Text to display inside the overlay.
418
+ * @param progress - Progress value (`-1` = indeterminate). Defaults to `-1`.
419
+ * @param progressMode - Progress mode. Defaults to `'indeterminate'`.
420
+ * @param action - Optional observable; the overlay is dismissed when it emits.
421
+ * @returns `true` if the overlay was brought up by this call.
422
+ */
423
+ busySpinner(message, progress = -1, progressMode = 'indeterminate', action) {
424
+ return this.setBusy(message, progress, progressMode, 'spinner', action);
425
+ }
426
+ /**
427
+ * Shows or updates the busy overlay using the hourglass style.
428
+ * @param message - Text to display inside the overlay.
429
+ * @param action - Optional observable; the overlay is dismissed when it emits.
430
+ * @returns `true` if the overlay was brought up by this call.
431
+ */
432
+ busyHourglass(message, action) {
433
+ return this.setBusy(message, -1, 'indeterminate', 'hourglass', action);
434
+ }
435
+ /**
436
+ * Shows a bare wait indicator, with no panel and no message.
437
+ * @param action - Optional observable; the overlay is dismissed when it emits.
438
+ * @returns `true` if the overlay was brought up by this call.
439
+ */
440
+ wait(action) {
441
+ return this.setBusy('', -1, 'indeterminate', 'wait', action);
442
+ }
443
+ /**
444
+ * Returns a {@link BusyTimer} that brings the overlay up only if the operation is still running
445
+ * after a debounce delay.
446
+ * @param message - Text to display. Defaults to `'Operazione in corso...'`.
447
+ * @param due - Delay in milliseconds before the overlay appears. Defaults to `100`.
448
+ * @returns A timer that must be disposed with `clear()` when the operation ends.
449
+ */
450
+ busyTimer(message = 'Operazione in corso...', due = 100) {
451
+ return new BusyTimer(this, due, message);
452
+ }
453
+ /**
454
+ * Takes the busy overlay away.
455
+ *
456
+ * By default it waits a short grace period, so that a chain of quick operations does not make
457
+ * the overlay blink between one and the next; any `setBusy()` in the meantime cancels the
458
+ * pending removal. Pass `true` when something is about to be drawn underneath it and the wait
459
+ * would be visible — that is what `DialogService.open()` does.
460
+ * @param immediate - When `true`, removes the overlay without waiting for the grace period.
461
+ * @returns void
462
+ */
463
+ clearBusy(immediate = false) {
464
+ clearTimeout(this.clearBusyTimer);
465
+ this.clearBusyTimer = undefined;
466
+ if (immediate) {
467
+ this.hideBusy();
468
+ return;
469
+ }
470
+ this.clearBusyTimer = setTimeout(() => {
471
+ this.clearBusyTimer = undefined;
472
+ this.hideBusy();
473
+ }, CLEAR_BUSY_GRACE);
474
+ }
475
+ /**
476
+ * Hides the busy overlay without destroying it, so the next call can reuse the instance.
477
+ * @returns void
478
+ */
479
+ hideBusy() {
480
+ this.busyActionSubscription?.unsubscribe();
481
+ this.busyActionSubscription = undefined;
482
+ if (!this.busyVisible)
483
+ return;
484
+ this.busyVisible = false;
485
+ this.busyRef?.instance.visible.set(false);
486
+ this.busyRef?.changeDetectorRef.detectChanges();
487
+ }
488
+ /**
489
+ * Returns the busy component, creating and attaching it the first time it is needed.
490
+ * @returns The reused busy component reference.
491
+ */
492
+ ensureBusy() {
493
+ if (this.busyRef)
494
+ return this.busyRef;
495
+ const ref = createComponent(ShellBusyComponent, { environmentInjector: this.environmentInjector });
496
+ this.appRef.attachView(ref.hostView);
497
+ document.body.appendChild(ref.location.nativeElement);
498
+ this.busyRef = ref;
499
+ return ref;
500
+ }
501
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: ShellService, deps: [], target: i0.ɵɵFactoryTarget.Service }); }
502
+ static { this.ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.1.3", ngImport: i0, type: ShellService }); }
503
+ }
504
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: ShellService, decorators: [{
505
+ type: Service
506
+ }] });
507
+
508
+ /*
509
+ * Public API Surface of @arsedizioni/ars-utils/ui.shell
510
+ */
511
+
512
+ /**
513
+ * Generated bundle index. Do not edit.
514
+ */
515
+
516
+ export { BusyTimer, ShellBusyComponent, ShellMessageComponent, ShellService };
517
+ //# sourceMappingURL=arsedizioni-ars-utils-ui.shell.mjs.map