@molecule/app-ui-angular 1.0.5 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11742 -1145
- package/dist/components/accordion.component.d.ts +114 -0
- package/dist/components/accordion.component.d.ts.map +1 -0
- package/dist/components/accordion.component.js +286 -0
- package/dist/components/accordion.component.js.map +1 -0
- package/dist/components/alert.component.d.ts +81 -37
- package/dist/components/alert.component.d.ts.map +1 -1
- package/dist/components/alert.component.js +232 -146
- package/dist/components/alert.component.js.map +1 -1
- package/dist/components/auth-guard.component.d.ts +94 -0
- package/dist/components/auth-guard.component.d.ts.map +1 -0
- package/dist/components/auth-guard.component.js +212 -0
- package/dist/components/auth-guard.component.js.map +1 -0
- package/dist/components/avatar.component.d.ts +97 -0
- package/dist/components/avatar.component.d.ts.map +1 -0
- package/dist/components/avatar.component.js +216 -0
- package/dist/components/avatar.component.js.map +1 -0
- package/dist/components/badge.component.d.ts +27 -12
- package/dist/components/badge.component.d.ts.map +1 -1
- package/dist/components/badge.component.js +47 -47
- package/dist/components/badge.component.js.map +1 -1
- package/dist/components/button.component.d.ts +96 -14
- package/dist/components/button.component.d.ts.map +1 -1
- package/dist/components/button.component.js +232 -87
- package/dist/components/button.component.js.map +1 -1
- package/dist/components/card.component.d.ts +135 -0
- package/dist/components/card.component.d.ts.map +1 -0
- package/dist/components/card.component.js +291 -0
- package/dist/components/card.component.js.map +1 -0
- package/dist/components/checkbox.component.d.ts +102 -29
- package/dist/components/checkbox.component.d.ts.map +1 -1
- package/dist/components/checkbox.component.js +222 -113
- package/dist/components/checkbox.component.js.map +1 -1
- package/dist/components/confirm-button.component.d.ts +130 -0
- package/dist/components/confirm-button.component.d.ts.map +1 -0
- package/dist/components/confirm-button.component.js +322 -0
- package/dist/components/confirm-button.component.js.map +1 -0
- package/dist/components/confirm-dialog.component.d.ts +60 -0
- package/dist/components/confirm-dialog.component.d.ts.map +1 -0
- package/dist/components/confirm-dialog.component.js +152 -0
- package/dist/components/confirm-dialog.component.js.map +1 -0
- package/dist/components/dropdown.component.d.ts +313 -0
- package/dist/components/dropdown.component.d.ts.map +1 -0
- package/dist/components/dropdown.component.js +919 -0
- package/dist/components/dropdown.component.js.map +1 -0
- package/dist/components/empty-state.component.d.ts +73 -0
- package/dist/components/empty-state.component.d.ts.map +1 -0
- package/dist/components/empty-state.component.js +180 -0
- package/dist/components/empty-state.component.js.map +1 -0
- package/dist/components/floating-input.component.d.ts +86 -0
- package/dist/components/floating-input.component.d.ts.map +1 -0
- package/dist/components/floating-input.component.js +167 -0
- package/dist/components/floating-input.component.js.map +1 -0
- package/dist/components/form-field.component.d.ts +111 -0
- package/dist/components/form-field.component.d.ts.map +1 -0
- package/dist/components/form-field.component.js +300 -0
- package/dist/components/form-field.component.js.map +1 -0
- package/dist/components/form.component.d.ts +77 -0
- package/dist/components/form.component.d.ts.map +1 -0
- package/dist/components/form.component.js +222 -0
- package/dist/components/form.component.js.map +1 -0
- package/dist/components/icon.component.d.ts +85 -0
- package/dist/components/icon.component.d.ts.map +1 -0
- package/dist/components/icon.component.js +187 -0
- package/dist/components/icon.component.js.map +1 -0
- package/dist/components/index.d.ts +49 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +49 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/input.component.d.ts +157 -54
- package/dist/components/input.component.d.ts.map +1 -1
- package/dist/components/input.component.js +437 -222
- package/dist/components/input.component.js.map +1 -1
- package/dist/components/label.component.d.ts +29 -0
- package/dist/components/label.component.d.ts.map +1 -0
- package/dist/components/label.component.js +60 -0
- package/dist/components/label.component.js.map +1 -0
- package/dist/components/language-picker.component.d.ts +124 -0
- package/dist/components/language-picker.component.d.ts.map +1 -0
- package/dist/components/language-picker.component.js +305 -0
- package/dist/components/language-picker.component.js.map +1 -0
- package/dist/components/layout.component.d.ts +167 -0
- package/dist/components/layout.component.d.ts.map +1 -0
- package/dist/components/layout.component.js +364 -0
- package/dist/components/layout.component.js.map +1 -0
- package/dist/components/load-error-banner.component.d.ts +103 -0
- package/dist/components/load-error-banner.component.d.ts.map +1 -0
- package/dist/components/load-error-banner.component.js +263 -0
- package/dist/components/load-error-banner.component.js.map +1 -0
- package/dist/components/modal.component.d.ts +125 -95
- package/dist/components/modal.component.d.ts.map +1 -1
- package/dist/components/modal.component.js +458 -271
- package/dist/components/modal.component.js.map +1 -1
- package/dist/components/molecule/alert.component.d.ts +77 -0
- package/dist/components/molecule/alert.component.d.ts.map +1 -0
- package/dist/components/molecule/alert.component.js +229 -0
- package/dist/components/molecule/alert.component.js.map +1 -0
- package/dist/components/molecule/badge.component.d.ts +27 -0
- package/dist/components/molecule/badge.component.d.ts.map +1 -0
- package/dist/components/molecule/badge.component.js +79 -0
- package/dist/components/molecule/badge.component.js.map +1 -0
- package/dist/components/molecule/button.component.d.ts +38 -0
- package/dist/components/molecule/button.component.d.ts.map +1 -0
- package/dist/components/molecule/button.component.js +137 -0
- package/dist/components/molecule/button.component.js.map +1 -0
- package/dist/components/molecule/checkbox.component.d.ts +53 -0
- package/dist/components/molecule/checkbox.component.d.ts.map +1 -0
- package/dist/components/molecule/checkbox.component.js +166 -0
- package/dist/components/molecule/checkbox.component.js.map +1 -0
- package/dist/components/molecule/index.d.ts +18 -0
- package/dist/components/molecule/index.d.ts.map +1 -0
- package/dist/components/molecule/index.js +18 -0
- package/dist/components/molecule/index.js.map +1 -0
- package/dist/components/molecule/input.component.d.ts +93 -0
- package/dist/components/molecule/input.component.d.ts.map +1 -0
- package/dist/components/molecule/input.component.js +314 -0
- package/dist/components/molecule/input.component.js.map +1 -0
- package/dist/components/molecule/modal.component.d.ts +148 -0
- package/dist/components/molecule/modal.component.d.ts.map +1 -0
- package/dist/components/molecule/modal.component.js +382 -0
- package/dist/components/molecule/modal.component.js.map +1 -0
- package/dist/components/molecule/radio-group.component.d.ts +63 -0
- package/dist/components/molecule/radio-group.component.d.ts.map +1 -0
- package/dist/components/molecule/radio-group.component.js +208 -0
- package/dist/components/molecule/radio-group.component.js.map +1 -0
- package/dist/components/molecule/select.component.d.ts +72 -0
- package/dist/components/molecule/select.component.d.ts.map +1 -0
- package/dist/components/molecule/select.component.js +274 -0
- package/dist/components/molecule/select.component.js.map +1 -0
- package/dist/components/molecule/spinner.component.d.ts +42 -0
- package/dist/components/molecule/spinner.component.d.ts.map +1 -0
- package/dist/components/molecule/spinner.component.js +122 -0
- package/dist/components/molecule/spinner.component.js.map +1 -0
- package/dist/components/molecule/switch.component.d.ts +54 -0
- package/dist/components/molecule/switch.component.d.ts.map +1 -0
- package/dist/components/molecule/switch.component.js +148 -0
- package/dist/components/molecule/switch.component.js.map +1 -0
- package/dist/components/molecule/toast.component.d.ts +98 -0
- package/dist/components/molecule/toast.component.d.ts.map +1 -0
- package/dist/components/molecule/toast.component.js +305 -0
- package/dist/components/molecule/toast.component.js.map +1 -0
- package/dist/components/molecule/tooltip.component.d.ts +77 -0
- package/dist/components/molecule/tooltip.component.d.ts.map +1 -0
- package/dist/components/molecule/tooltip.component.js +316 -0
- package/dist/components/molecule/tooltip.component.js.map +1 -0
- package/dist/components/optimistic-toggle-button.component.d.ts +125 -0
- package/dist/components/optimistic-toggle-button.component.d.ts.map +1 -0
- package/dist/components/optimistic-toggle-button.component.js +296 -0
- package/dist/components/optimistic-toggle-button.component.js.map +1 -0
- package/dist/components/page-header.component.d.ts +77 -0
- package/dist/components/page-header.component.d.ts.map +1 -0
- package/dist/components/page-header.component.js +225 -0
- package/dist/components/page-header.component.js.map +1 -0
- package/dist/components/page-shell.component.d.ts +101 -0
- package/dist/components/page-shell.component.d.ts.map +1 -0
- package/dist/components/page-shell.component.js +221 -0
- package/dist/components/page-shell.component.js.map +1 -0
- package/dist/components/pagination.component.d.ts +137 -0
- package/dist/components/pagination.component.d.ts.map +1 -0
- package/dist/components/pagination.component.js +419 -0
- package/dist/components/pagination.component.js.map +1 -0
- package/dist/components/panel-close.component.d.ts +43 -0
- package/dist/components/panel-close.component.d.ts.map +1 -0
- package/dist/components/panel-close.component.js +75 -0
- package/dist/components/panel-close.component.js.map +1 -0
- package/dist/components/progress.component.d.ts +84 -0
- package/dist/components/progress.component.d.ts.map +1 -0
- package/dist/components/progress.component.js +219 -0
- package/dist/components/progress.component.js.map +1 -0
- package/dist/components/prompt-dialog.component.d.ts +121 -0
- package/dist/components/prompt-dialog.component.d.ts.map +1 -0
- package/dist/components/prompt-dialog.component.js +332 -0
- package/dist/components/prompt-dialog.component.js.map +1 -0
- package/dist/components/radio-group.component.d.ts +66 -34
- package/dist/components/radio-group.component.d.ts.map +1 -1
- package/dist/components/radio-group.component.js +146 -125
- package/dist/components/radio-group.component.js.map +1 -1
- package/dist/components/responsive-app-shell.component.d.ts +408 -0
- package/dist/components/responsive-app-shell.component.d.ts.map +1 -0
- package/dist/components/responsive-app-shell.component.js +1144 -0
- package/dist/components/responsive-app-shell.component.js.map +1 -0
- package/dist/components/select.component.d.ts +135 -38
- package/dist/components/select.component.d.ts.map +1 -1
- package/dist/components/select.component.js +373 -181
- package/dist/components/select.component.js.map +1 -1
- package/dist/components/separator.component.d.ts +39 -0
- package/dist/components/separator.component.d.ts.map +1 -0
- package/dist/components/separator.component.js +73 -0
- package/dist/components/separator.component.js.map +1 -0
- package/dist/components/sidebar-user-card.component.d.ts +106 -0
- package/dist/components/sidebar-user-card.component.d.ts.map +1 -0
- package/dist/components/sidebar-user-card.component.js +277 -0
- package/dist/components/sidebar-user-card.component.js.map +1 -0
- package/dist/components/skeleton.component.d.ts +100 -0
- package/dist/components/skeleton.component.d.ts.map +1 -0
- package/dist/components/skeleton.component.js +214 -0
- package/dist/components/skeleton.component.js.map +1 -0
- package/dist/components/spinner.component.d.ts +36 -19
- package/dist/components/spinner.component.d.ts.map +1 -1
- package/dist/components/spinner.component.js +69 -71
- package/dist/components/spinner.component.js.map +1 -1
- package/dist/components/switch.component.d.ts +72 -29
- package/dist/components/switch.component.d.ts.map +1 -1
- package/dist/components/switch.component.js +163 -91
- package/dist/components/switch.component.js.map +1 -1
- package/dist/components/table.component.d.ts +193 -0
- package/dist/components/table.component.d.ts.map +1 -0
- package/dist/components/table.component.js +550 -0
- package/dist/components/table.component.js.map +1 -0
- package/dist/components/tabs.component.d.ts +140 -0
- package/dist/components/tabs.component.d.ts.map +1 -0
- package/dist/components/tabs.component.js +390 -0
- package/dist/components/tabs.component.js.map +1 -0
- package/dist/components/template-outlet.directive.d.ts +50 -0
- package/dist/components/template-outlet.directive.d.ts.map +1 -0
- package/dist/components/template-outlet.directive.js +81 -0
- package/dist/components/template-outlet.directive.js.map +1 -0
- package/dist/components/textarea.component.d.ts +151 -0
- package/dist/components/textarea.component.d.ts.map +1 -0
- package/dist/components/textarea.component.js +340 -0
- package/dist/components/textarea.component.js.map +1 -0
- package/dist/components/theme-toggle.component.d.ts +58 -0
- package/dist/components/theme-toggle.component.d.ts.map +1 -0
- package/dist/components/theme-toggle.component.js +124 -0
- package/dist/components/theme-toggle.component.js.map +1 -0
- package/dist/components/toast.component.d.ts +237 -49
- package/dist/components/toast.component.d.ts.map +1 -1
- package/dist/components/toast.component.js +636 -201
- package/dist/components/toast.component.js.map +1 -1
- package/dist/components/tooltip.component.d.ts +95 -45
- package/dist/components/tooltip.component.d.ts.map +1 -1
- package/dist/components/tooltip.component.js +372 -221
- package/dist/components/tooltip.component.js.map +1 -1
- package/dist/components/user-menu-popover.component.d.ts +283 -0
- package/dist/components/user-menu-popover.component.d.ts.map +1 -0
- package/dist/components/user-menu-popover.component.js +646 -0
- package/dist/components/user-menu-popover.component.js.map +1 -0
- package/dist/components/user-menu.component.d.ts +95 -0
- package/dist/components/user-menu.component.d.ts.map +1 -0
- package/dist/components/user-menu.component.js +218 -0
- package/dist/components/user-menu.component.js.map +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/use-is-desktop.d.ts +22 -0
- package/dist/hooks/use-is-desktop.d.ts.map +1 -0
- package/dist/hooks/use-is-desktop.js +37 -0
- package/dist/hooks/use-is-desktop.js.map +1 -0
- package/dist/index.d.ts +32 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -17
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utilities/dom-context.d.ts +42 -0
- package/dist/utilities/dom-context.d.ts.map +1 -0
- package/dist/utilities/dom-context.js +66 -0
- package/dist/utilities/dom-context.js.map +1 -0
- package/dist/utilities/focus.d.ts +32 -0
- package/dist/utilities/focus.d.ts.map +1 -0
- package/dist/utilities/focus.js +47 -0
- package/dist/utilities/focus.js.map +1 -0
- package/dist/utilities/form-field-context.d.ts +34 -0
- package/dist/utilities/form-field-context.d.ts.map +1 -0
- package/dist/utilities/form-field-context.js +28 -0
- package/dist/utilities/form-field-context.js.map +1 -0
- package/dist/utilities/form-submit-error.d.ts +17 -0
- package/dist/utilities/form-submit-error.d.ts.map +1 -0
- package/dist/utilities/form-submit-error.js +42 -0
- package/dist/utilities/form-submit-error.js.map +1 -0
- package/dist/utilities/icon-markup.d.ts +17 -0
- package/dist/utilities/icon-markup.d.ts.map +1 -0
- package/dist/utilities/icon-markup.js +46 -0
- package/dist/utilities/icon-markup.js.map +1 -0
- package/dist/utilities/ids.d.ts +15 -0
- package/dist/utilities/ids.d.ts.map +1 -0
- package/dist/utilities/ids.js +19 -0
- package/dist/utilities/ids.js.map +1 -0
- package/dist/utilities/index.d.ts +11 -0
- package/dist/utilities/index.d.ts.map +1 -1
- package/dist/utilities/index.js +11 -0
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/initials.d.ts +13 -0
- package/dist/utilities/initials.d.ts.map +1 -0
- package/dist/utilities/initials.js +23 -0
- package/dist/utilities/initials.js.map +1 -0
- package/dist/utilities/node-value.d.ts +31 -0
- package/dist/utilities/node-value.d.ts.map +1 -0
- package/dist/utilities/node-value.js +37 -0
- package/dist/utilities/node-value.js.map +1 -0
- package/dist/utilities/optimistic-value.d.ts +81 -0
- package/dist/utilities/optimistic-value.d.ts.map +1 -0
- package/dist/utilities/optimistic-value.js +154 -0
- package/dist/utilities/optimistic-value.js.map +1 -0
- package/dist/utilities/render-icon.d.ts +77 -7
- package/dist/utilities/render-icon.d.ts.map +1 -1
- package/dist/utilities/render-icon.js +123 -33
- package/dist/utilities/render-icon.js.map +1 -1
- package/dist/utilities/rest-attrs.d.ts +21 -0
- package/dist/utilities/rest-attrs.d.ts.map +1 -0
- package/dist/utilities/rest-attrs.js +37 -0
- package/dist/utilities/rest-attrs.js.map +1 -0
- package/dist/utilities/style.d.ts +23 -0
- package/dist/utilities/style.d.ts.map +1 -0
- package/dist/utilities/style.js +86 -0
- package/dist/utilities/style.js.map +1 -0
- package/package.json +10 -5
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Progress component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { Component } from '@angular/core';
|
|
7
|
+
import { useTranslation } from '@molecule/app-angular';
|
|
8
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
9
|
+
import { styleText } from '../utilities/style.js';
|
|
10
|
+
import * as i0 from "@angular/core";
|
|
11
|
+
function Progress_Conditional_0_Conditional_1_Template(rf, ctx) { if (rf & 1) {
|
|
12
|
+
i0.ɵɵdomElementStart(0, "span");
|
|
13
|
+
i0.ɵɵtext(1);
|
|
14
|
+
i0.ɵɵdomElementEnd();
|
|
15
|
+
} if (rf & 2) {
|
|
16
|
+
const ctx_r0 = i0.ɵɵnextContext(2);
|
|
17
|
+
i0.ɵɵclassMap(ctx_r0.cm().progressLabelText);
|
|
18
|
+
i0.ɵɵadvance();
|
|
19
|
+
i0.ɵɵtextInterpolate(ctx_r0.label);
|
|
20
|
+
} }
|
|
21
|
+
function Progress_Conditional_0_Conditional_2_Template(rf, ctx) { if (rf & 1) {
|
|
22
|
+
i0.ɵɵdomElementStart(0, "span");
|
|
23
|
+
i0.ɵɵdomElementContainerStart(1);
|
|
24
|
+
i0.ɵɵtext(2);
|
|
25
|
+
i0.ɵɵdomElementContainerEnd();
|
|
26
|
+
i0.ɵɵdomElementContainerStart(3);
|
|
27
|
+
i0.ɵɵtext(4);
|
|
28
|
+
i0.ɵɵdomElementContainerEnd();
|
|
29
|
+
i0.ɵɵdomElementEnd();
|
|
30
|
+
} if (rf & 2) {
|
|
31
|
+
const ctx_r0 = i0.ɵɵnextContext(2);
|
|
32
|
+
i0.ɵɵclassMap(ctx_r0.cm().progressLabelText);
|
|
33
|
+
i0.ɵɵadvance(2);
|
|
34
|
+
i0.ɵɵtextInterpolate(ctx_r0.rounded);
|
|
35
|
+
i0.ɵɵadvance(2);
|
|
36
|
+
i0.ɵɵtextInterpolate("%");
|
|
37
|
+
} }
|
|
38
|
+
function Progress_Conditional_0_Template(rf, ctx) { if (rf & 1) {
|
|
39
|
+
i0.ɵɵdomElementStart(0, "div");
|
|
40
|
+
i0.ɵɵconditionalCreate(1, Progress_Conditional_0_Conditional_1_Template, 2, 3, "span", 0);
|
|
41
|
+
i0.ɵɵconditionalCreate(2, Progress_Conditional_0_Conditional_2_Template, 5, 4, "span", 0);
|
|
42
|
+
i0.ɵɵdomElementEnd();
|
|
43
|
+
} if (rf & 2) {
|
|
44
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
45
|
+
i0.ɵɵclassMap(ctx_r0.cm().progressLabelContainer);
|
|
46
|
+
i0.ɵɵadvance();
|
|
47
|
+
i0.ɵɵconditional(ctx_r0.label ? 1 : -1);
|
|
48
|
+
i0.ɵɵadvance();
|
|
49
|
+
i0.ɵɵconditional(ctx_r0.showValue ? 2 : -1);
|
|
50
|
+
} }
|
|
51
|
+
/**
|
|
52
|
+
* Progress component.
|
|
53
|
+
*
|
|
54
|
+
* The host is the wrapper div React renders; `aria-valuenow` is clamped into
|
|
55
|
+
* `[0, max]` to match the clamped visual bar.
|
|
56
|
+
*/
|
|
57
|
+
export class Progress {
|
|
58
|
+
/** Progress value (0–max). */
|
|
59
|
+
value = 0;
|
|
60
|
+
/** Maximum value. */
|
|
61
|
+
max = 100;
|
|
62
|
+
/** Progress size. */
|
|
63
|
+
size;
|
|
64
|
+
/** Progress color. */
|
|
65
|
+
color;
|
|
66
|
+
/** Whether the numeric value label renders. */
|
|
67
|
+
showValue;
|
|
68
|
+
/** Accessible label. */
|
|
69
|
+
label;
|
|
70
|
+
/** Whether the progress is indeterminate. */
|
|
71
|
+
indeterminate;
|
|
72
|
+
/** Extra classes joined onto the wrapper classes. */
|
|
73
|
+
className;
|
|
74
|
+
/** Inline style object (React camelCase). */
|
|
75
|
+
style;
|
|
76
|
+
/** `data-testid`. */
|
|
77
|
+
testId;
|
|
78
|
+
/**
|
|
79
|
+
* Reactive translation, read in the injection context. Its `t` reads the
|
|
80
|
+
* locale, so the view re-renders the text on a locale switch (the static `t`
|
|
81
|
+
* does not).
|
|
82
|
+
*/
|
|
83
|
+
i18n = useTranslation();
|
|
84
|
+
/**
|
|
85
|
+
* The current class map.
|
|
86
|
+
* @returns The UIClassMap.
|
|
87
|
+
*/
|
|
88
|
+
cm() {
|
|
89
|
+
return getClassMap();
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The percentage, clamped to [0, 100].
|
|
93
|
+
* @returns The percentage.
|
|
94
|
+
*/
|
|
95
|
+
get percent() {
|
|
96
|
+
const max = this.max ?? 100;
|
|
97
|
+
return Math.min(Math.max((this.value / max) * 100, 0), 100);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The rounded percentage shown in the value label.
|
|
101
|
+
* @returns The whole percentage.
|
|
102
|
+
*/
|
|
103
|
+
get rounded() {
|
|
104
|
+
return Math.round(this.percent);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The clamped aria-valuenow.
|
|
108
|
+
* @returns The clamped value.
|
|
109
|
+
*/
|
|
110
|
+
get clamped() {
|
|
111
|
+
const max = this.max ?? 100;
|
|
112
|
+
return Math.min(Math.max(this.value, 0), max);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The accessible label with the localized default.
|
|
116
|
+
* @returns The label text.
|
|
117
|
+
*/
|
|
118
|
+
progressLabel() {
|
|
119
|
+
return this.i18n.t('ui.progress.label', undefined, { defaultValue: 'Progress' });
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Computes the wrapper class list.
|
|
123
|
+
* @returns The class string.
|
|
124
|
+
*/
|
|
125
|
+
classes() {
|
|
126
|
+
return this.cm().cn(this.cm().progressWrapper, this.className);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Computes the bar class list.
|
|
130
|
+
* @returns The class string.
|
|
131
|
+
*/
|
|
132
|
+
barClasses() {
|
|
133
|
+
return this.cm().cn(this.cm().progressBar(), this.cm().progressColor(this.color ?? 'primary'), this.indeterminate && this.cm().progressIndeterminate);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Serializes the bar's inline style (the translateX fill, unless indeterminate).
|
|
137
|
+
* @returns The style attribute text.
|
|
138
|
+
*/
|
|
139
|
+
barStyle() {
|
|
140
|
+
if (this.indeterminate)
|
|
141
|
+
return null;
|
|
142
|
+
return styleText({ transform: `translateX(-${100 - this.percent}%)` });
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Serializes the inline style.
|
|
146
|
+
* @returns The style attribute text.
|
|
147
|
+
*/
|
|
148
|
+
hostStyle() {
|
|
149
|
+
return styleText(this.style);
|
|
150
|
+
}
|
|
151
|
+
static ɵfac = function Progress_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Progress)(); };
|
|
152
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: Progress, selectors: [["div", "mol-progress", ""]], hostVars: 5, hostBindings: function Progress_HostBindings(rf, ctx) { if (rf & 2) {
|
|
153
|
+
i0.ɵɵattribute("data-testid", ctx.testId);
|
|
154
|
+
i0.ɵɵstyleMap(ctx.hostStyle());
|
|
155
|
+
i0.ɵɵclassMap(ctx.classes());
|
|
156
|
+
} }, inputs: { value: "value", max: "max", size: "size", color: "color", showValue: "showValue", label: "label", indeterminate: "indeterminate", className: "className", style: "style", testId: "testId" }, decls: 3, vars: 9, consts: [[3, "class"], ["role", "progressbar", "aria-valuemin", "0"]], template: function Progress_Template(rf, ctx) { if (rf & 1) {
|
|
157
|
+
i0.ɵɵconditionalCreate(0, Progress_Conditional_0_Template, 3, 4, "div", 0);
|
|
158
|
+
i0.ɵɵdomElementStart(1, "div", 1);
|
|
159
|
+
i0.ɵɵdomElement(2, "div");
|
|
160
|
+
i0.ɵɵdomElementEnd();
|
|
161
|
+
} if (rf & 2) {
|
|
162
|
+
i0.ɵɵconditional(ctx.label || ctx.showValue ? 0 : -1);
|
|
163
|
+
i0.ɵɵadvance();
|
|
164
|
+
i0.ɵɵclassMap(ctx.cm().cn(ctx.cm().progress(), ctx.cm().progressHeight(ctx.size ?? "md")));
|
|
165
|
+
i0.ɵɵattribute("aria-valuenow", ctx.indeterminate ? null : ctx.clamped)("aria-valuemax", ctx.max)("aria-label", ctx.label ?? ctx.progressLabel());
|
|
166
|
+
i0.ɵɵadvance();
|
|
167
|
+
i0.ɵɵclassMap(ctx.barClasses());
|
|
168
|
+
i0.ɵɵattribute("style", ctx.barStyle(), i0.ɵɵsanitizeStyle);
|
|
169
|
+
} }, encapsulation: 2 });
|
|
170
|
+
}
|
|
171
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(Progress, [{
|
|
172
|
+
type: Component,
|
|
173
|
+
args: [{
|
|
174
|
+
selector: 'div[mol-progress]',
|
|
175
|
+
standalone: true,
|
|
176
|
+
inputs: [
|
|
177
|
+
'value',
|
|
178
|
+
'max',
|
|
179
|
+
'size',
|
|
180
|
+
'color',
|
|
181
|
+
'showValue',
|
|
182
|
+
'label',
|
|
183
|
+
'indeterminate',
|
|
184
|
+
'className',
|
|
185
|
+
'style',
|
|
186
|
+
'testId',
|
|
187
|
+
],
|
|
188
|
+
host: {
|
|
189
|
+
'[class]': 'classes()',
|
|
190
|
+
'[style]': 'hostStyle()',
|
|
191
|
+
'[attr.data-testid]': 'testId',
|
|
192
|
+
},
|
|
193
|
+
template: `@if (label || showValue) {
|
|
194
|
+
<div [class]="cm().progressLabelContainer">
|
|
195
|
+
@if (label) {
|
|
196
|
+
<span [class]="cm().progressLabelText">{{ label }}</span>
|
|
197
|
+
}
|
|
198
|
+
@if (showValue) {
|
|
199
|
+
<span [class]="cm().progressLabelText"
|
|
200
|
+
><ng-container>{{ rounded }}</ng-container
|
|
201
|
+
><ng-container>{{ '%' }}</ng-container></span
|
|
202
|
+
>
|
|
203
|
+
}
|
|
204
|
+
</div>
|
|
205
|
+
}
|
|
206
|
+
<div
|
|
207
|
+
[class]="cm().cn(cm().progress(), cm().progressHeight(size ?? 'md'))"
|
|
208
|
+
role="progressbar"
|
|
209
|
+
[attr.aria-valuenow]="indeterminate ? null : clamped"
|
|
210
|
+
aria-valuemin="0"
|
|
211
|
+
[attr.aria-valuemax]="max"
|
|
212
|
+
[attr.aria-label]="label ?? progressLabel()"
|
|
213
|
+
>
|
|
214
|
+
<div [class]="barClasses()" [attr.style]="barStyle()"></div>
|
|
215
|
+
</div>`,
|
|
216
|
+
}]
|
|
217
|
+
}], null, null); })();
|
|
218
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(Progress, { className: "Progress", filePath: "components/progress.component.ts", lineNumber: 65 }); })();
|
|
219
|
+
//# sourceMappingURL=progress.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.component.js","sourceRoot":"","sources":["../../src/components/progress.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAA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,QAAQ;;YAAR,cAAA,eACb,CADqB;YAAR,cAAA,aAAS,CAAD;;YAxBR,0EAA0B;YAanC,iCAOC;YACC,yBAA4D;YAC9D,oBAAM;;YAtBG,qDAYR;YAEC,cAAqE;YAArE,0FAAqE;;YAOhE,cAAsB;YAAtB,+BAAsB;;;;iFAGpB,QAAQ;cA5CpB,SAAS;eAAC;gBACT,QAAQ,EAAE,mBAAmB;gBAC7B,UAAU,EAAE,IAAI;gBAChB,MAAM,EAAE;oBACN,OAAO;oBACP,KAAK;oBACL,MAAM;oBACN,OAAO;oBACP,WAAW;oBACX,OAAO;oBACP,eAAe;oBACf,WAAW;oBACX,OAAO;oBACP,QAAQ;iBACT;gBACD,IAAI,EAAE;oBACJ,SAAS,EAAE,WAAW;oBACtB,SAAS,EAAE,aAAa;oBACxB,oBAAoB,EAAE,QAAQ;iBAC/B;gBACD,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;WAsBD;aACV;;kFACY,QAAQ"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PromptDialog component (React parity): the shared "ask for a short string"
|
|
3
|
+
* modal.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { type AfterViewInit, type DoCheck, type ElementRef, EventEmitter } from '@angular/core';
|
|
8
|
+
import type { UIClassMap } from '@molecule/app-ui';
|
|
9
|
+
import { Input } from './input.component.js';
|
|
10
|
+
import * as i0 from "@angular/core";
|
|
11
|
+
/**
|
|
12
|
+
* PromptDialog component.
|
|
13
|
+
*
|
|
14
|
+
* Composed from `Modal`, `Input` and `Button` exactly as React composes
|
|
15
|
+
* them. Resolving `onSubmit` closes the dialog and resets it; a rejection
|
|
16
|
+
* keeps it open with the value intact. The host is unwrapped
|
|
17
|
+
* (`data-parity-unwrap`, React's `Modal` root is a fragment/portal).
|
|
18
|
+
*/
|
|
19
|
+
export declare class PromptDialog implements AfterViewInit, DoCheck {
|
|
20
|
+
/** Whether the dialog is open. */
|
|
21
|
+
open: boolean;
|
|
22
|
+
/** Dialog heading (node-valued prop). */
|
|
23
|
+
title?: unknown;
|
|
24
|
+
/** Explanatory line under the title. */
|
|
25
|
+
description?: string;
|
|
26
|
+
/** Input placeholder. */
|
|
27
|
+
placeholder?: string;
|
|
28
|
+
/** Value the input starts from every time the dialog opens. */
|
|
29
|
+
initialValue: string;
|
|
30
|
+
/**
|
|
31
|
+
* Called with the entered value on confirm. Resolve to close the dialog;
|
|
32
|
+
* reject or throw to keep it open.
|
|
33
|
+
*/
|
|
34
|
+
onSubmit?: (value: string) => void | Promise<void>;
|
|
35
|
+
/** Confirm-button label. */
|
|
36
|
+
confirmLabel?: string;
|
|
37
|
+
/** Cancel-button label. */
|
|
38
|
+
cancelLabel?: string;
|
|
39
|
+
/** Renders the confirm button in the error color. */
|
|
40
|
+
destructive: boolean;
|
|
41
|
+
/** `data-mol-id` for the text input. */
|
|
42
|
+
inputMolId?: string;
|
|
43
|
+
/** `data-mol-id` for the confirm button. */
|
|
44
|
+
confirmMolId?: string;
|
|
45
|
+
/** `data-mol-id` for the cancel button. */
|
|
46
|
+
cancelMolId?: string;
|
|
47
|
+
/** Fires when the dialog should close (escape, backdrop, cancel, a fulfilled submit). */
|
|
48
|
+
readonly close: EventEmitter<unknown>;
|
|
49
|
+
/** The dialog heading element (its text seeds the input's aria-label). */
|
|
50
|
+
titleSlot?: ElementRef<HTMLHeadingElement>;
|
|
51
|
+
/** The composed input (its native element receives React's aria-label). */
|
|
52
|
+
inputComponent?: Input;
|
|
53
|
+
/** The current input value. */
|
|
54
|
+
readonly value: import("@angular/core").WritableSignal<string>;
|
|
55
|
+
/** Whether a submit is in flight. */
|
|
56
|
+
readonly pending: import("@angular/core").WritableSignal<boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* Reactive translation, read in the injection context. Its `t` reads the
|
|
59
|
+
* locale, so the view re-renders the text on a locale switch (the static `t`
|
|
60
|
+
* does not).
|
|
61
|
+
*/
|
|
62
|
+
private readonly i18n;
|
|
63
|
+
private lastOpen;
|
|
64
|
+
private lastInitial;
|
|
65
|
+
/**
|
|
66
|
+
* The current class map.
|
|
67
|
+
* @returns The UIClassMap.
|
|
68
|
+
*/
|
|
69
|
+
cm(): UIClassMap;
|
|
70
|
+
/**
|
|
71
|
+
* The cancel button's label.
|
|
72
|
+
* @returns The label text.
|
|
73
|
+
*/
|
|
74
|
+
cancelText(): string;
|
|
75
|
+
/**
|
|
76
|
+
* The confirm button's label.
|
|
77
|
+
* @returns The label text.
|
|
78
|
+
*/
|
|
79
|
+
confirmText(): string;
|
|
80
|
+
/**
|
|
81
|
+
* The input's accessible label: React uses the title when it is a plain
|
|
82
|
+
* string, otherwise the placeholder.
|
|
83
|
+
* @returns The label, or null when React would render none.
|
|
84
|
+
*/
|
|
85
|
+
inputLabel(): string | null;
|
|
86
|
+
/**
|
|
87
|
+
* Seeds the value when the dialog opens (React's `[open, initialValue]`
|
|
88
|
+
* effect).
|
|
89
|
+
*/
|
|
90
|
+
ngAfterViewInit(): void;
|
|
91
|
+
/**
|
|
92
|
+
* Re-seeds the value on a later open transition (React's effect).
|
|
93
|
+
*/
|
|
94
|
+
ngDoCheck(): void;
|
|
95
|
+
/**
|
|
96
|
+
* Applies React's `aria-label` to the inner input (it is a rest prop there,
|
|
97
|
+
* and the view queries it needs resolve only after view init).
|
|
98
|
+
*/
|
|
99
|
+
private applyInputLabel;
|
|
100
|
+
/**
|
|
101
|
+
* Tracks the typed value (React's controlled `onChange`).
|
|
102
|
+
*
|
|
103
|
+
* @param event - The native input event.
|
|
104
|
+
*/
|
|
105
|
+
onInput(event: Event): void;
|
|
106
|
+
/**
|
|
107
|
+
* Modal's close request: ignored while a submit is pending (React passes a
|
|
108
|
+
* no-op `onClose` while pending).
|
|
109
|
+
*/
|
|
110
|
+
onModalClose(): void;
|
|
111
|
+
/**
|
|
112
|
+
* Submits the entered value: resolve closes and resets; reject keeps the
|
|
113
|
+
* dialog open (React's `handleSubmit`).
|
|
114
|
+
*
|
|
115
|
+
* @param event - The form submit event.
|
|
116
|
+
*/
|
|
117
|
+
handleSubmit(event: Event): void;
|
|
118
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PromptDialog, never>;
|
|
119
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<PromptDialog, "mol-prompt-dialog", never, { "open": { "alias": "open"; "required": false; }; "title": { "alias": "title"; "required": false; }; "description": { "alias": "description"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "initialValue": { "alias": "initialValue"; "required": false; }; "onSubmit": { "alias": "onSubmit"; "required": false; }; "confirmLabel": { "alias": "confirmLabel"; "required": false; }; "cancelLabel": { "alias": "cancelLabel"; "required": false; }; "destructive": { "alias": "destructive"; "required": false; }; "inputMolId": { "alias": "inputMolId"; "required": false; }; "confirmMolId": { "alias": "confirmMolId"; "required": false; }; "cancelMolId": { "alias": "cancelMolId"; "required": false; }; }, { "close": "close"; }, never, ["[slot=title]", "*"], true, never>;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=prompt-dialog.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-dialog.component.d.ts","sourceRoot":"","sources":["../../src/components/prompt-dialog.component.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,YAAY,EAIb,MAAM,eAAe,CAAA;AAGtB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAIlD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;;AAG5C;;;;;;;GAOG;AACH,qBAkEa,YAAa,YAAW,aAAa,EAAE,OAAO;IACzD,kCAAkC;IAClC,IAAI,UAAQ;IACZ,yCAAyC;IACzC,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,yBAAyB;IACz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AAI,IAAI;IAKpB;;;;;OAKG;IACH,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;yCA7JrB,YAAY;2CAAZ,YAAY;CA4KxB"}
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PromptDialog component (React parity): the shared "ask for a short string"
|
|
3
|
+
* modal.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { Component, EventEmitter, Output, signal, ViewChild, } from '@angular/core';
|
|
8
|
+
import { useTranslation } from '@molecule/app-angular';
|
|
9
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
10
|
+
import { Button } from './button.component.js';
|
|
11
|
+
import { Input } from './input.component.js';
|
|
12
|
+
import { Modal } from './modal.component.js';
|
|
13
|
+
import * as i0 from "@angular/core";
|
|
14
|
+
const _c0 = ["titleSlot"];
|
|
15
|
+
const _c1 = [[["", "slot", "title"]], "*"];
|
|
16
|
+
const _c2 = ["[slot=title]", "*"];
|
|
17
|
+
const _c3 = () => ({ justify: "end", gap: "sm" });
|
|
18
|
+
function PromptDialog_Conditional_6_Template(rf, ctx) { if (rf & 1) {
|
|
19
|
+
i0.ɵɵelementStart(0, "p");
|
|
20
|
+
i0.ɵɵtext(1);
|
|
21
|
+
i0.ɵɵelementEnd();
|
|
22
|
+
} if (rf & 2) {
|
|
23
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
24
|
+
i0.ɵɵclassMap(ctx_r0.cm().textSize("sm"));
|
|
25
|
+
i0.ɵɵadvance();
|
|
26
|
+
i0.ɵɵtextInterpolate(ctx_r0.description);
|
|
27
|
+
} }
|
|
28
|
+
/**
|
|
29
|
+
* PromptDialog component.
|
|
30
|
+
*
|
|
31
|
+
* Composed from `Modal`, `Input` and `Button` exactly as React composes
|
|
32
|
+
* them. Resolving `onSubmit` closes the dialog and resets it; a rejection
|
|
33
|
+
* keeps it open with the value intact. The host is unwrapped
|
|
34
|
+
* (`data-parity-unwrap`, React's `Modal` root is a fragment/portal).
|
|
35
|
+
*/
|
|
36
|
+
export class PromptDialog {
|
|
37
|
+
/** Whether the dialog is open. */
|
|
38
|
+
open = false;
|
|
39
|
+
/** Dialog heading (node-valued prop). */
|
|
40
|
+
title;
|
|
41
|
+
/** Explanatory line under the title. */
|
|
42
|
+
description;
|
|
43
|
+
/** Input placeholder. */
|
|
44
|
+
placeholder;
|
|
45
|
+
/** Value the input starts from every time the dialog opens. */
|
|
46
|
+
initialValue = '';
|
|
47
|
+
/**
|
|
48
|
+
* Called with the entered value on confirm. Resolve to close the dialog;
|
|
49
|
+
* reject or throw to keep it open.
|
|
50
|
+
*/
|
|
51
|
+
onSubmit;
|
|
52
|
+
/** Confirm-button label. */
|
|
53
|
+
confirmLabel;
|
|
54
|
+
/** Cancel-button label. */
|
|
55
|
+
cancelLabel;
|
|
56
|
+
/** Renders the confirm button in the error color. */
|
|
57
|
+
destructive = false;
|
|
58
|
+
/** `data-mol-id` for the text input. */
|
|
59
|
+
inputMolId;
|
|
60
|
+
/** `data-mol-id` for the confirm button. */
|
|
61
|
+
confirmMolId;
|
|
62
|
+
/** `data-mol-id` for the cancel button. */
|
|
63
|
+
cancelMolId;
|
|
64
|
+
/** Fires when the dialog should close (escape, backdrop, cancel, a fulfilled submit). */
|
|
65
|
+
close = new EventEmitter();
|
|
66
|
+
/** The dialog heading element (its text seeds the input's aria-label). */
|
|
67
|
+
titleSlot;
|
|
68
|
+
/** The composed input (its native element receives React's aria-label). */
|
|
69
|
+
inputComponent;
|
|
70
|
+
/** The current input value. */
|
|
71
|
+
value = signal('', /* @ts-ignore */
|
|
72
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
73
|
+
/** Whether a submit is in flight. */
|
|
74
|
+
pending = signal(false, /* @ts-ignore */
|
|
75
|
+
...(ngDevMode ? [{ debugName: "pending" }] : /* istanbul ignore next */ []));
|
|
76
|
+
/**
|
|
77
|
+
* Reactive translation, read in the injection context. Its `t` reads the
|
|
78
|
+
* locale, so the view re-renders the text on a locale switch (the static `t`
|
|
79
|
+
* does not).
|
|
80
|
+
*/
|
|
81
|
+
i18n = useTranslation();
|
|
82
|
+
lastOpen = false;
|
|
83
|
+
lastInitial = '';
|
|
84
|
+
/**
|
|
85
|
+
* The current class map.
|
|
86
|
+
* @returns The UIClassMap.
|
|
87
|
+
*/
|
|
88
|
+
cm() {
|
|
89
|
+
return getClassMap();
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The cancel button's label.
|
|
93
|
+
* @returns The label text.
|
|
94
|
+
*/
|
|
95
|
+
cancelText() {
|
|
96
|
+
return this.cancelLabel ?? this.i18n.t('prompt.cancel', {}, { defaultValue: 'Cancel' });
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The confirm button's label.
|
|
100
|
+
* @returns The label text.
|
|
101
|
+
*/
|
|
102
|
+
confirmText() {
|
|
103
|
+
return this.confirmLabel ?? this.i18n.t('prompt.confirm', {}, { defaultValue: 'Confirm' });
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The input's accessible label: React uses the title when it is a plain
|
|
107
|
+
* string, otherwise the placeholder.
|
|
108
|
+
* @returns The label, or null when React would render none.
|
|
109
|
+
*/
|
|
110
|
+
inputLabel() {
|
|
111
|
+
const title = this.titleSlot?.nativeElement;
|
|
112
|
+
if (title) {
|
|
113
|
+
const hasElement = Array.from(title.childNodes).some((node) => node.nodeType === 1);
|
|
114
|
+
const text = (title.textContent ?? '').trim();
|
|
115
|
+
if (!hasElement && text)
|
|
116
|
+
return text;
|
|
117
|
+
}
|
|
118
|
+
return this.placeholder ?? null;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Seeds the value when the dialog opens (React's `[open, initialValue]`
|
|
122
|
+
* effect).
|
|
123
|
+
*/
|
|
124
|
+
ngAfterViewInit() {
|
|
125
|
+
this.applyInputLabel();
|
|
126
|
+
this.lastOpen = !!this.open;
|
|
127
|
+
this.lastInitial = this.initialValue;
|
|
128
|
+
if (this.open) {
|
|
129
|
+
this.value.set(this.initialValue);
|
|
130
|
+
this.pending.set(false);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Re-seeds the value on a later open transition (React's effect).
|
|
135
|
+
*/
|
|
136
|
+
ngDoCheck() {
|
|
137
|
+
const open = !!this.open;
|
|
138
|
+
this.applyInputLabel();
|
|
139
|
+
if (open !== this.lastOpen || (open && this.initialValue !== this.lastInitial)) {
|
|
140
|
+
this.lastOpen = open;
|
|
141
|
+
this.lastInitial = this.initialValue;
|
|
142
|
+
if (open) {
|
|
143
|
+
this.value.set(this.initialValue);
|
|
144
|
+
this.pending.set(false);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Applies React's `aria-label` to the inner input (it is a rest prop there,
|
|
150
|
+
* and the view queries it needs resolve only after view init).
|
|
151
|
+
*/
|
|
152
|
+
applyInputLabel() {
|
|
153
|
+
const input = this.inputComponent?.inputEl?.nativeElement;
|
|
154
|
+
if (!input)
|
|
155
|
+
return;
|
|
156
|
+
const label = this.inputLabel();
|
|
157
|
+
if (label === null)
|
|
158
|
+
input.removeAttribute('aria-label');
|
|
159
|
+
else
|
|
160
|
+
input.setAttribute('aria-label', label);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Tracks the typed value (React's controlled `onChange`).
|
|
164
|
+
*
|
|
165
|
+
* @param event - The native input event.
|
|
166
|
+
*/
|
|
167
|
+
onInput(event) {
|
|
168
|
+
this.value.set(event.target.value);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Modal's close request: ignored while a submit is pending (React passes a
|
|
172
|
+
* no-op `onClose` while pending).
|
|
173
|
+
*/
|
|
174
|
+
onModalClose() {
|
|
175
|
+
if (this.pending())
|
|
176
|
+
return;
|
|
177
|
+
this.close.emit();
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Submits the entered value: resolve closes and resets; reject keeps the
|
|
181
|
+
* dialog open (React's `handleSubmit`).
|
|
182
|
+
*
|
|
183
|
+
* @param event - The form submit event.
|
|
184
|
+
*/
|
|
185
|
+
handleSubmit(event) {
|
|
186
|
+
event.preventDefault();
|
|
187
|
+
if (this.pending())
|
|
188
|
+
return;
|
|
189
|
+
this.pending.set(true);
|
|
190
|
+
void Promise.resolve(this.onSubmit?.(this.value()))
|
|
191
|
+
.then(() => {
|
|
192
|
+
this.pending.set(false);
|
|
193
|
+
this.close.emit();
|
|
194
|
+
})
|
|
195
|
+
.catch((_error) => {
|
|
196
|
+
// Deliberate: a rejection keeps the dialog open and the caller owns
|
|
197
|
+
// the error, rendering it through `children`.
|
|
198
|
+
this.pending.set(false);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
static ɵfac = function PromptDialog_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PromptDialog)(); };
|
|
202
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PromptDialog, selectors: [["mol-prompt-dialog"]], viewQuery: function PromptDialog_Query(rf, ctx) { if (rf & 1) {
|
|
203
|
+
i0.ɵɵviewQuery(_c0, 5)(Input, 5);
|
|
204
|
+
} if (rf & 2) {
|
|
205
|
+
let _t;
|
|
206
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.titleSlot = _t.first);
|
|
207
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.inputComponent = _t.first);
|
|
208
|
+
} }, hostAttrs: ["data-parity-unwrap", "", 2, "display", "contents"], inputs: { open: "open", title: "title", description: "description", placeholder: "placeholder", initialValue: "initialValue", onSubmit: "onSubmit", confirmLabel: "confirmLabel", cancelLabel: "cancelLabel", destructive: "destructive", inputMolId: "inputMolId", confirmMolId: "confirmMolId", cancelMolId: "cancelMolId" }, outputs: { close: "close" }, ngContentSelectors: _c2, decls: 14, vars: 24, consts: [["titleSlot", ""], [3, "close", "open"], [3, "submit"], [3, "class"], ["mol-input", "", 3, "change", "value", "placeholder", "disabled"], ["mol-button", "", 3, "click", "type", "variant", "disabled"], ["mol-button", "", 3, "type", "variant", "color", "disabled"]], template: function PromptDialog_Template(rf, ctx) { if (rf & 1) {
|
|
209
|
+
i0.ɵɵprojectionDef(_c1);
|
|
210
|
+
i0.ɵɵelementStart(0, "mol-modal", 1);
|
|
211
|
+
i0.ɵɵlistener("close", function PromptDialog_Template_mol_modal_close_0_listener() { return ctx.onModalClose(); });
|
|
212
|
+
i0.ɵɵelementStart(1, "form", 2);
|
|
213
|
+
i0.ɵɵlistener("submit", function PromptDialog_Template_form_submit_1_listener($event) { return ctx.handleSubmit($event); });
|
|
214
|
+
i0.ɵɵelementStart(2, "div")(3, "h2", null, 0);
|
|
215
|
+
i0.ɵɵprojection(5);
|
|
216
|
+
i0.ɵɵelementEnd();
|
|
217
|
+
i0.ɵɵconditionalCreate(6, PromptDialog_Conditional_6_Template, 2, 3, "p", 3);
|
|
218
|
+
i0.ɵɵelementStart(7, "div", 4);
|
|
219
|
+
i0.ɵɵlistener("change", function PromptDialog_Template_div_change_7_listener($event) { return ctx.onInput($event); });
|
|
220
|
+
i0.ɵɵelementEnd();
|
|
221
|
+
i0.ɵɵprojection(8, 1);
|
|
222
|
+
i0.ɵɵelementStart(9, "div")(10, "button", 5);
|
|
223
|
+
i0.ɵɵlistener("click", function PromptDialog_Template_button_click_10_listener($event) { return ctx.close.emit($event); });
|
|
224
|
+
i0.ɵɵtext(11);
|
|
225
|
+
i0.ɵɵelementEnd();
|
|
226
|
+
i0.ɵɵelementStart(12, "button", 6);
|
|
227
|
+
i0.ɵɵtext(13);
|
|
228
|
+
i0.ɵɵelementEnd()()()()();
|
|
229
|
+
} if (rf & 2) {
|
|
230
|
+
i0.ɵɵproperty("open", ctx.open);
|
|
231
|
+
i0.ɵɵadvance(2);
|
|
232
|
+
i0.ɵɵclassMap(ctx.cm().stack(3));
|
|
233
|
+
i0.ɵɵadvance();
|
|
234
|
+
i0.ɵɵclassMap(ctx.cm().cn(ctx.cm().textSize("lg"), ctx.cm().fontWeight("bold")));
|
|
235
|
+
i0.ɵɵadvance(3);
|
|
236
|
+
i0.ɵɵconditional(ctx.description ? 6 : -1);
|
|
237
|
+
i0.ɵɵadvance();
|
|
238
|
+
i0.ɵɵproperty("value", ctx.value())("placeholder", ctx.placeholder)("disabled", ctx.pending());
|
|
239
|
+
i0.ɵɵattribute("data-mol-id", ctx.inputMolId);
|
|
240
|
+
i0.ɵɵadvance(2);
|
|
241
|
+
i0.ɵɵclassMap(ctx.cm().flex(i0.ɵɵpureFunction0(23, _c3)));
|
|
242
|
+
i0.ɵɵadvance();
|
|
243
|
+
i0.ɵɵproperty("type", "button")("variant", "ghost")("disabled", ctx.pending());
|
|
244
|
+
i0.ɵɵattribute("data-mol-id", ctx.cancelMolId);
|
|
245
|
+
i0.ɵɵadvance();
|
|
246
|
+
i0.ɵɵtextInterpolate1(" ", ctx.cancelText());
|
|
247
|
+
i0.ɵɵadvance();
|
|
248
|
+
i0.ɵɵproperty("type", "submit")("variant", "solid")("color", ctx.destructive ? "error" : "primary")("disabled", ctx.pending());
|
|
249
|
+
i0.ɵɵattribute("data-mol-id", ctx.confirmMolId);
|
|
250
|
+
i0.ɵɵadvance();
|
|
251
|
+
i0.ɵɵtextInterpolate1(" ", ctx.confirmText(), " ");
|
|
252
|
+
} }, dependencies: [Button, Input, Modal], encapsulation: 2 });
|
|
253
|
+
}
|
|
254
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PromptDialog, [{
|
|
255
|
+
type: Component,
|
|
256
|
+
args: [{
|
|
257
|
+
selector: 'mol-prompt-dialog',
|
|
258
|
+
standalone: true,
|
|
259
|
+
imports: [Button, Input, Modal],
|
|
260
|
+
inputs: [
|
|
261
|
+
'open',
|
|
262
|
+
'title',
|
|
263
|
+
'description',
|
|
264
|
+
'placeholder',
|
|
265
|
+
'initialValue',
|
|
266
|
+
'onSubmit',
|
|
267
|
+
'confirmLabel',
|
|
268
|
+
'cancelLabel',
|
|
269
|
+
'destructive',
|
|
270
|
+
'inputMolId',
|
|
271
|
+
'confirmMolId',
|
|
272
|
+
'cancelMolId',
|
|
273
|
+
],
|
|
274
|
+
outputs: ['close'],
|
|
275
|
+
host: {
|
|
276
|
+
'data-parity-unwrap': '',
|
|
277
|
+
style: 'display: contents',
|
|
278
|
+
},
|
|
279
|
+
template: `<mol-modal [open]="open" (close)="onModalClose()"
|
|
280
|
+
><form (submit)="handleSubmit($event)">
|
|
281
|
+
<div [class]="cm().stack(3)">
|
|
282
|
+
<h2 #titleSlot [class]="cm().cn(cm().textSize('lg'), cm().fontWeight('bold'))">
|
|
283
|
+
<ng-content select="[slot=title]"></ng-content>
|
|
284
|
+
</h2>
|
|
285
|
+
@if (description) {
|
|
286
|
+
<p [class]="cm().textSize('sm')">{{ description }}</p>
|
|
287
|
+
}
|
|
288
|
+
<div
|
|
289
|
+
mol-input
|
|
290
|
+
[value]="value()"
|
|
291
|
+
[placeholder]="placeholder"
|
|
292
|
+
[disabled]="pending()"
|
|
293
|
+
[attr.data-mol-id]="inputMolId"
|
|
294
|
+
(change)="onInput($event)"
|
|
295
|
+
></div>
|
|
296
|
+
<ng-content></ng-content>
|
|
297
|
+
<div [class]="cm().flex({ justify: 'end', gap: 'sm' })">
|
|
298
|
+
<button
|
|
299
|
+
mol-button
|
|
300
|
+
[type]="'button'"
|
|
301
|
+
[variant]="'ghost'"
|
|
302
|
+
[disabled]="pending()"
|
|
303
|
+
(click)="close.emit($event)"
|
|
304
|
+
[attr.data-mol-id]="cancelMolId"
|
|
305
|
+
>
|
|
306
|
+
{{ cancelText() }}</button
|
|
307
|
+
><button
|
|
308
|
+
mol-button
|
|
309
|
+
[type]="'submit'"
|
|
310
|
+
[variant]="'solid'"
|
|
311
|
+
[color]="destructive ? 'error' : 'primary'"
|
|
312
|
+
[disabled]="pending()"
|
|
313
|
+
[attr.data-mol-id]="confirmMolId"
|
|
314
|
+
>
|
|
315
|
+
{{ confirmText() }}
|
|
316
|
+
</button>
|
|
317
|
+
</div>
|
|
318
|
+
</div>
|
|
319
|
+
</form></mol-modal
|
|
320
|
+
>`,
|
|
321
|
+
}]
|
|
322
|
+
}], null, { close: [{
|
|
323
|
+
type: Output
|
|
324
|
+
}], titleSlot: [{
|
|
325
|
+
type: ViewChild,
|
|
326
|
+
args: ['titleSlot']
|
|
327
|
+
}], inputComponent: [{
|
|
328
|
+
type: ViewChild,
|
|
329
|
+
args: [Input]
|
|
330
|
+
}] }); })();
|
|
331
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PromptDialog, { className: "PromptDialog", filePath: "components/prompt-dialog.component.ts", lineNumber: 101 }); })();
|
|
332
|
+
//# sourceMappingURL=prompt-dialog.component.js.map
|