mn-angular-lib 2.0.33 → 2.0.35
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/fesm2022/mn-angular-lib-alert.mjs +515 -527
- package/fesm2022/mn-angular-lib-alert.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-bottom-sheet.mjs +264 -357
- package/fesm2022/mn-angular-lib-bottom-sheet.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-button.mjs +819 -382
- package/fesm2022/mn-angular-lib-button.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-calendar-core.mjs +240 -365
- package/fesm2022/mn-angular-lib-calendar-core.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-calendar.mjs +1691 -1545
- package/fesm2022/mn-angular-lib-calendar.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-collection.mjs +2367 -2796
- package/fesm2022/mn-angular-lib-collection.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-core.mjs +693 -1241
- package/fesm2022/mn-angular-lib-core.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-display.mjs +679 -712
- package/fesm2022/mn-angular-lib-display.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-forms.mjs +3671 -4647
- package/fesm2022/mn-angular-lib-forms.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-keyboard.mjs +221 -190
- package/fesm2022/mn-angular-lib-keyboard.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-modal-core.mjs +711 -896
- package/fesm2022/mn-angular-lib-modal-core.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-modal-ui.mjs +2089 -2035
- package/fesm2022/mn-angular-lib-modal-ui.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-modal.mjs +76 -121
- package/fesm2022/mn-angular-lib-modal.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-rich-text-editor.mjs +289 -277
- package/fesm2022/mn-angular-lib-rich-text-editor.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-segmented.mjs +189 -241
- package/fesm2022/mn-angular-lib-segmented.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-tab.mjs +409 -642
- package/fesm2022/mn-angular-lib-tab.mjs.map +1 -1
- package/fesm2022/mn-angular-lib.mjs +16 -29
- package/package.json +1 -1
- package/types/mn-angular-lib-alert.d.ts +239 -241
- package/types/mn-angular-lib-bottom-sheet.d.ts +190 -150
- package/types/mn-angular-lib-button.d.ts +319 -317
- package/types/mn-angular-lib-calendar-core.d.ts +199 -209
- package/types/mn-angular-lib-calendar.d.ts +656 -511
- package/types/mn-angular-lib-collection.d.ts +1649 -1585
- package/types/mn-angular-lib-core.d.ts +524 -535
- package/types/mn-angular-lib-display.d.ts +946 -886
- package/types/mn-angular-lib-forms.d.ts +3012 -3013
- package/types/mn-angular-lib-keyboard.d.ts +125 -85
- package/types/mn-angular-lib-modal-core.d.ts +978 -994
- package/types/mn-angular-lib-modal-ui.d.ts +541 -493
- package/types/mn-angular-lib-modal.d.ts +24 -27
- package/types/mn-angular-lib-rich-text-editor.d.ts +131 -98
- package/types/mn-angular-lib-segmented.d.ts +354 -341
- package/types/mn-angular-lib-tab.d.ts +345 -336
- package/types/mn-angular-lib.d.ts +16 -16
- package/fesm2022/mn-angular-lib.mjs.map +0 -1
|
@@ -1,945 +1,760 @@
|
|
|
1
|
-
import { InjectionToken } from
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { Subject } from 'rxjs';
|
|
7
|
-
|
|
8
|
-
// =========================
|
|
9
|
-
// Enums / Value Types
|
|
10
|
-
// =========================
|
|
1
|
+
import { InjectionToken, TemplateRef, Type } from "@angular/core";
|
|
2
|
+
import * as lucide from "lucide";
|
|
3
|
+
import { lucideIcons } from "mn-angular-lib/core";
|
|
4
|
+
import { Validators } from "@angular/forms";
|
|
5
|
+
import { Subject } from "rxjs";
|
|
11
6
|
var ModalKind;
|
|
12
|
-
(function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
(function(ModalKind) {
|
|
8
|
+
ModalKind["WIZARD"] = "wizard";
|
|
9
|
+
ModalKind["FORM"] = "form";
|
|
10
|
+
ModalKind["CONFIRMATION"] = "confirmation";
|
|
11
|
+
ModalKind["CUSTOM"] = "custom";
|
|
17
12
|
})(ModalKind || (ModalKind = {}));
|
|
18
13
|
var ModalSize;
|
|
19
|
-
(function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
(function(ModalSize) {
|
|
15
|
+
ModalSize["SM"] = "sm";
|
|
16
|
+
ModalSize["MD"] = "md";
|
|
17
|
+
ModalSize["LG"] = "lg";
|
|
18
|
+
ModalSize["XL"] = "xl";
|
|
19
|
+
ModalSize["FULL"] = "full";
|
|
25
20
|
})(ModalSize || (ModalSize = {}));
|
|
26
21
|
var CloseMode;
|
|
27
|
-
(function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
(function(CloseMode) {
|
|
23
|
+
CloseMode["ALLOWED"] = "allowed";
|
|
24
|
+
CloseMode["GUARDED"] = "guarded";
|
|
25
|
+
CloseMode["DISABLED"] = "disabled";
|
|
31
26
|
})(CloseMode || (CloseMode = {}));
|
|
32
27
|
var BackdropMode;
|
|
33
|
-
(function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
(function(BackdropMode) {
|
|
29
|
+
BackdropMode["HIDE"] = "hide";
|
|
30
|
+
BackdropMode["STATIC"] = "static";
|
|
31
|
+
BackdropMode["CLOSABLE"] = "closable";
|
|
37
32
|
})(BackdropMode || (BackdropMode = {}));
|
|
38
33
|
var KeyboardMode;
|
|
39
|
-
(function
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
(function(KeyboardMode) {
|
|
35
|
+
KeyboardMode["ENABLED"] = "enabled";
|
|
36
|
+
KeyboardMode["DISABLED"] = "disabled";
|
|
42
37
|
})(KeyboardMode || (KeyboardMode = {}));
|
|
43
38
|
var ModalIntent;
|
|
44
|
-
(function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
(function(ModalIntent) {
|
|
40
|
+
ModalIntent["NEUTRAL"] = "neutral";
|
|
41
|
+
ModalIntent["INFO"] = "info";
|
|
42
|
+
ModalIntent["SUCCESS"] = "success";
|
|
43
|
+
ModalIntent["WARNING"] = "warning";
|
|
44
|
+
ModalIntent["DANGER"] = "danger";
|
|
50
45
|
})(ModalIntent || (ModalIntent = {}));
|
|
51
46
|
var WizardFlowMode;
|
|
52
|
-
(function
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
(function(WizardFlowMode) {
|
|
48
|
+
WizardFlowMode["LINEAR"] = "linear";
|
|
49
|
+
WizardFlowMode["FREE"] = "free";
|
|
55
50
|
})(WizardFlowMode || (WizardFlowMode = {}));
|
|
56
51
|
var FormLayoutMode;
|
|
57
|
-
(function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
(function(FormLayoutMode) {
|
|
53
|
+
FormLayoutMode["SINGLE_COLUMN"] = "single-column";
|
|
54
|
+
FormLayoutMode["TWO_COLUMN"] = "two-column";
|
|
55
|
+
FormLayoutMode["INLINE"] = "inline";
|
|
61
56
|
})(FormLayoutMode || (FormLayoutMode = {}));
|
|
62
57
|
var SubmitMode;
|
|
63
|
-
(function
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
(function(SubmitMode) {
|
|
59
|
+
SubmitMode["ONCE"] = "once";
|
|
60
|
+
SubmitMode["RETRYABLE"] = "retryable";
|
|
66
61
|
})(SubmitMode || (SubmitMode = {}));
|
|
67
62
|
var ConfirmationTone;
|
|
68
|
-
(function
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
(function(ConfirmationTone) {
|
|
64
|
+
ConfirmationTone["DEFAULT"] = "default";
|
|
65
|
+
ConfirmationTone["WARNING"] = "warning";
|
|
66
|
+
ConfirmationTone["DANGER"] = "danger";
|
|
72
67
|
})(ConfirmationTone || (ConfirmationTone = {}));
|
|
73
68
|
var FieldKind;
|
|
74
|
-
(function
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
69
|
+
(function(FieldKind) {
|
|
70
|
+
FieldKind["TEXT"] = "text";
|
|
71
|
+
FieldKind["NUMBER"] = "number";
|
|
72
|
+
FieldKind["SELECT"] = "select";
|
|
73
|
+
FieldKind["CHECKBOX"] = "checkbox";
|
|
74
|
+
FieldKind["DATE"] = "date";
|
|
75
|
+
FieldKind["TEXTAREA"] = "textarea";
|
|
76
|
+
FieldKind["DATETIME"] = "datetime";
|
|
77
|
+
FieldKind["MULTI_SELECT"] = "multi-select";
|
|
78
|
+
FieldKind["MULTI_SELECT_TABLE"] = "multi-select-table";
|
|
79
|
+
FieldKind["SINGLE_SELECT_TABLE"] = "single-select-table";
|
|
80
|
+
FieldKind["PASSWORD"] = "password";
|
|
81
|
+
FieldKind["FILE"] = "file";
|
|
82
|
+
FieldKind["COLOR"] = "color";
|
|
83
|
+
FieldKind["RATING"] = "rating";
|
|
84
|
+
FieldKind["SLIDER"] = "slider";
|
|
85
|
+
FieldKind["CUSTOM"] = "custom";
|
|
91
86
|
})(FieldKind || (FieldKind = {}));
|
|
92
87
|
var FieldAppearance;
|
|
93
|
-
(function
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
88
|
+
(function(FieldAppearance) {
|
|
89
|
+
FieldAppearance["OUTLINE"] = "outline";
|
|
90
|
+
FieldAppearance["FILLED"] = "filled";
|
|
91
|
+
FieldAppearance["GHOST"] = "ghost";
|
|
97
92
|
})(FieldAppearance || (FieldAppearance = {}));
|
|
98
93
|
var SelectionMode;
|
|
99
|
-
(function
|
|
100
|
-
|
|
101
|
-
|
|
94
|
+
(function(SelectionMode) {
|
|
95
|
+
SelectionMode["SINGLE"] = "single";
|
|
96
|
+
SelectionMode["MULTIPLE"] = "multiple";
|
|
102
97
|
})(SelectionMode || (SelectionMode = {}));
|
|
103
98
|
var OptionState;
|
|
104
|
-
(function
|
|
105
|
-
|
|
106
|
-
|
|
99
|
+
(function(OptionState) {
|
|
100
|
+
OptionState["ENABLED"] = "enabled";
|
|
101
|
+
OptionState["DISABLED"] = "disabled";
|
|
107
102
|
})(OptionState || (OptionState = {}));
|
|
108
103
|
var ActionStyle;
|
|
109
|
-
(function
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
104
|
+
(function(ActionStyle) {
|
|
105
|
+
ActionStyle["PRIMARY"] = "primary";
|
|
106
|
+
ActionStyle["SECONDARY"] = "secondary";
|
|
107
|
+
ActionStyle["DANGER"] = "danger";
|
|
108
|
+
ActionStyle["GHOST"] = "ghost";
|
|
114
109
|
})(ActionStyle || (ActionStyle = {}));
|
|
115
110
|
var StepState;
|
|
116
|
-
(function
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
111
|
+
(function(StepState) {
|
|
112
|
+
StepState["PENDING"] = "pending";
|
|
113
|
+
StepState["ACTIVE"] = "active";
|
|
114
|
+
StepState["COMPLETE"] = "complete";
|
|
115
|
+
StepState["DISABLED"] = "disabled";
|
|
116
|
+
StepState["HIDDEN"] = "hidden";
|
|
122
117
|
})(StepState || (StepState = {}));
|
|
123
118
|
var NavigationDirection;
|
|
124
|
-
(function
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
119
|
+
(function(NavigationDirection) {
|
|
120
|
+
NavigationDirection["FORWARD"] = "forward";
|
|
121
|
+
NavigationDirection["BACKWARD"] = "backward";
|
|
122
|
+
NavigationDirection["DIRECT"] = "direct";
|
|
128
123
|
})(NavigationDirection || (NavigationDirection = {}));
|
|
129
124
|
var ModalCloseReason;
|
|
130
|
-
(function
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
125
|
+
(function(ModalCloseReason) {
|
|
126
|
+
ModalCloseReason["COMPLETED"] = "completed";
|
|
127
|
+
ModalCloseReason["CANCELLED"] = "cancelled";
|
|
128
|
+
ModalCloseReason["DISMISSED"] = "dismissed";
|
|
129
|
+
ModalCloseReason["BACKDROP"] = "backdrop";
|
|
130
|
+
ModalCloseReason["ESCAPE"] = "escape";
|
|
131
|
+
ModalCloseReason["PROGRAMMATIC"] = "programmatic";
|
|
132
|
+
ModalCloseReason["GUARD_REJECTED"] = "guard_rejected";
|
|
138
133
|
})(ModalCloseReason || (ModalCloseReason = {}));
|
|
139
134
|
var ValidationStatus;
|
|
140
|
-
(function
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
135
|
+
(function(ValidationStatus) {
|
|
136
|
+
ValidationStatus["VALID"] = "valid";
|
|
137
|
+
ValidationStatus["INVALID"] = "invalid";
|
|
138
|
+
ValidationStatus["PENDING"] = "pending";
|
|
144
139
|
})(ValidationStatus || (ValidationStatus = {}));
|
|
145
140
|
var ValidationCode;
|
|
146
|
-
(function
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
141
|
+
(function(ValidationCode) {
|
|
142
|
+
ValidationCode["REQUIRED"] = "required";
|
|
143
|
+
ValidationCode["MIN"] = "min";
|
|
144
|
+
ValidationCode["MAX"] = "max";
|
|
145
|
+
ValidationCode["PATTERN"] = "pattern";
|
|
146
|
+
ValidationCode["CUSTOM"] = "custom";
|
|
152
147
|
})(ValidationCode || (ValidationCode = {}));
|
|
153
|
-
|
|
154
|
-
/** Lucide icons this file renders. */
|
|
155
148
|
const ICONS = lucideIcons({
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
149
|
+
ArrowLeft: lucide.ArrowLeft,
|
|
150
|
+
ArrowRight: lucide.ArrowRight,
|
|
151
|
+
Check: lucide.Check,
|
|
152
|
+
Trash2: lucide.Trash2,
|
|
153
|
+
X: lucide.X
|
|
161
154
|
});
|
|
162
|
-
/**
|
|
163
|
-
* Default leading-icon size (px) for modal action buttons, matching the standard
|
|
164
|
-
* (`md`) button. Small (`sm`) buttons use {@link MODAL_ACTION_ICON_SIZE_SM}.
|
|
165
|
-
*/
|
|
166
155
|
const MODAL_ACTION_ICON_SIZE = 18;
|
|
167
|
-
/** Leading-icon size (px) for `sm`-sized modal action buttons. */
|
|
168
156
|
const MODAL_ACTION_ICON_SIZE_SM = 16;
|
|
169
|
-
/**
|
|
170
|
-
* The canonical Lucide icon data used as defaults across all modal action buttons.
|
|
171
|
-
* Each value is a Lucide icon's static `.icon` data, rendered via the dynamic
|
|
172
|
-
* `svg[lucideIcon]` directive so no icon has to be registered in `MN_ICON_MAP`.
|
|
173
|
-
*/
|
|
174
157
|
const MN_MODAL_ACTION_ICONS = {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
cancel: ICONS.X,
|
|
181
|
-
/** Wizard forward navigation (rendered trailing). */
|
|
182
|
-
next: ICONS.ArrowRight,
|
|
183
|
-
/** Wizard backward navigation. */
|
|
184
|
-
back: ICONS.ArrowLeft,
|
|
158
|
+
confirm: ICONS.Check,
|
|
159
|
+
danger: ICONS.Trash2,
|
|
160
|
+
cancel: ICONS.X,
|
|
161
|
+
next: ICONS.ArrowRight,
|
|
162
|
+
back: ICONS.ArrowLeft
|
|
185
163
|
};
|
|
186
|
-
/**
|
|
187
|
-
* Resolves the default action-button icon from its {@link ActionStyle}. Used by
|
|
188
|
-
* generic footer actions and any confirm button that has no explicit icon:
|
|
189
|
-
* `DANGER` → trash, `PRIMARY` → check, everything else (`GHOST`/`SECONDARY`) → cross.
|
|
190
|
-
* @param style The action's style, if any.
|
|
191
|
-
* @returns The Lucide icon data to render.
|
|
192
|
-
*/
|
|
193
164
|
function defaultIconForStyle(style) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
default:
|
|
200
|
-
return MN_MODAL_ACTION_ICONS.cancel;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Optional DI token used by the bottom sheet to emit haptic feedback on native
|
|
206
|
-
* platforms (sheet open, swipe-dismiss, and snap-back). Provide a {@link MnHapticsHandler}
|
|
207
|
-
* at the application root to enable it; leave unprovided on the web (the modal injects it
|
|
208
|
-
* with `{ optional: true }` and no-ops when absent).
|
|
209
|
-
*/
|
|
210
|
-
const MN_HAPTICS = new InjectionToken('MN_HAPTICS');
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* A builder class that provides form layout capabilities (fields, rows, groups).
|
|
214
|
-
* This can be used as a delegate to avoid code duplication between FormModalBuilder and StepBuilder.
|
|
215
|
-
*/
|
|
216
|
-
class FormLayoutBuilder {
|
|
217
|
-
config;
|
|
218
|
-
parent;
|
|
219
|
-
currentRow = [];
|
|
220
|
-
currentRowColumns = 1;
|
|
221
|
-
constructor(config, parent) {
|
|
222
|
-
this.config = config;
|
|
223
|
-
this.parent = parent;
|
|
224
|
-
this.config.fields = this.config.fields || [];
|
|
225
|
-
this.config.rows = this.config.rows || [];
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Add a custom body/content to the form/step.
|
|
229
|
-
*/
|
|
230
|
-
body(body) {
|
|
231
|
-
this.config.body = body;
|
|
232
|
-
return this.parent;
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Add a field as a full-width row (single column).
|
|
236
|
-
*/
|
|
237
|
-
field(field) {
|
|
238
|
-
this.flushCurrentRow();
|
|
239
|
-
this.config.fields = this.config.fields || [];
|
|
240
|
-
this.config.fields.push(field);
|
|
241
|
-
this.config.rows = this.config.rows || [];
|
|
242
|
-
this.config.rows.push({
|
|
243
|
-
columns: 1,
|
|
244
|
-
fields: [{ field, span: 1 }],
|
|
245
|
-
});
|
|
246
|
-
return this.parent;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Start a new row with the specified number of columns.
|
|
250
|
-
* All subsequent `addToRow()` calls will add fields to this row.
|
|
251
|
-
*/
|
|
252
|
-
row(columns = 2) {
|
|
253
|
-
this.flushCurrentRow();
|
|
254
|
-
this.currentRowColumns = columns;
|
|
255
|
-
return this.parent;
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Add a field to the current row started by `row()`.
|
|
259
|
-
* @param field - The field configuration
|
|
260
|
-
* @param span - How many columns this field should span (default: 1)
|
|
261
|
-
*/
|
|
262
|
-
addToRow(field, span = 1) {
|
|
263
|
-
this.config.fields = this.config.fields || [];
|
|
264
|
-
this.config.fields.push(field);
|
|
265
|
-
this.currentRow.push({ field, span });
|
|
266
|
-
return this.parent;
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Declarative way to add a row.
|
|
270
|
-
* @example
|
|
271
|
-
* .addRow(2, row => {
|
|
272
|
-
* row.add({ kind: FieldKind.TEXT, key: 'first', ... });
|
|
273
|
-
* row.add({ kind: FieldKind.TEXT, key: 'last', ... });
|
|
274
|
-
* })
|
|
275
|
-
*/
|
|
276
|
-
addRow(columns, buildFn) {
|
|
277
|
-
this.flushCurrentRow();
|
|
278
|
-
const rowFields = [];
|
|
279
|
-
buildFn({
|
|
280
|
-
add: (field, span = 1) => {
|
|
281
|
-
this.config.fields = this.config.fields || [];
|
|
282
|
-
this.config.fields.push(field);
|
|
283
|
-
rowFields.push({ field, span });
|
|
284
|
-
},
|
|
285
|
-
});
|
|
286
|
-
if (rowFields.length > 0) {
|
|
287
|
-
this.config.rows = this.config.rows || [];
|
|
288
|
-
this.config.rows.push({
|
|
289
|
-
columns,
|
|
290
|
-
fields: rowFields,
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
return this.parent;
|
|
294
|
-
}
|
|
295
|
-
fieldGroup(arg1, arg2, arg3) {
|
|
296
|
-
this.flushCurrentRow();
|
|
297
|
-
if (typeof arg1 !== 'string') {
|
|
298
|
-
const group = arg1;
|
|
299
|
-
this.processFieldGroup(group);
|
|
300
|
-
return this.parent;
|
|
301
|
-
}
|
|
302
|
-
const title = arg1;
|
|
303
|
-
let description;
|
|
304
|
-
let buildFn;
|
|
305
|
-
if (typeof arg2 === 'string') {
|
|
306
|
-
description = arg2;
|
|
307
|
-
buildFn = arg3;
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
buildFn = arg2;
|
|
311
|
-
}
|
|
312
|
-
const groupConfig = {
|
|
313
|
-
fields: [],
|
|
314
|
-
rows: [],
|
|
315
|
-
};
|
|
316
|
-
const groupBuilder = new FormLayoutBuilder(groupConfig, null);
|
|
317
|
-
groupBuilder.parent = groupBuilder;
|
|
318
|
-
buildFn(groupBuilder);
|
|
319
|
-
groupBuilder.flushCurrentRow();
|
|
320
|
-
const group = {
|
|
321
|
-
title,
|
|
322
|
-
description,
|
|
323
|
-
fields: groupConfig.fields || [],
|
|
324
|
-
rows: groupConfig.rows || [],
|
|
325
|
-
};
|
|
326
|
-
this.processFieldGroup(group);
|
|
327
|
-
return this.parent;
|
|
328
|
-
}
|
|
329
|
-
processFieldGroup(group) {
|
|
330
|
-
if (!this.config.fieldGroups) {
|
|
331
|
-
this.config.fieldGroups = [];
|
|
332
|
-
}
|
|
333
|
-
// Also add group fields to the flat fields array for form control creation
|
|
334
|
-
this.config.fields = this.config.fields || [];
|
|
335
|
-
const fields = this.config.fields;
|
|
336
|
-
group.fields.forEach((f) => fields.push(f));
|
|
337
|
-
// Build rows for the group if not provided
|
|
338
|
-
if (!group.rows || group.rows.length === 0) {
|
|
339
|
-
group.rows = group.fields.map((f) => ({
|
|
340
|
-
columns: 1,
|
|
341
|
-
fields: [{ field: f, span: 1 }],
|
|
342
|
-
}));
|
|
343
|
-
}
|
|
344
|
-
this.config.fieldGroups.push(group);
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Add form-level validators for cross-field validation.
|
|
348
|
-
*/
|
|
349
|
-
formValidators(validators) {
|
|
350
|
-
this.config.formValidators = validators;
|
|
351
|
-
return this.parent;
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Add Angular FormGroup-level validators.
|
|
355
|
-
*/
|
|
356
|
-
groupValidators(validators) {
|
|
357
|
-
this.config.groupValidators = validators;
|
|
358
|
-
return this.parent;
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Set initial value for fields.
|
|
362
|
-
*/
|
|
363
|
-
initialValue(value) {
|
|
364
|
-
this.config.initialValue = value;
|
|
365
|
-
return this.parent;
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* Set the field to be focused when the form initializes.
|
|
369
|
-
*/
|
|
370
|
-
focus(key) {
|
|
371
|
-
this.config.fields?.forEach(f => {
|
|
372
|
-
f.autoFocus = false;
|
|
373
|
-
});
|
|
374
|
-
this.config.fieldGroups?.forEach(g => {
|
|
375
|
-
g.fields.forEach(f => {
|
|
376
|
-
f.autoFocus = false;
|
|
377
|
-
});
|
|
378
|
-
});
|
|
379
|
-
const field = this.config.fields?.find(f => f.key === key);
|
|
380
|
-
if (field) {
|
|
381
|
-
field.autoFocus = true;
|
|
382
|
-
}
|
|
383
|
-
return this.parent;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Wraps a field with a fluent API for validation.
|
|
387
|
-
*/
|
|
388
|
-
fieldWithValidators(field) {
|
|
389
|
-
const fieldWithV = field;
|
|
390
|
-
fieldWithV.validators = fieldWithV.validators || [];
|
|
391
|
-
this.field(field);
|
|
392
|
-
return new FieldValidatorBuilder(field, this.parent);
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* Flushes any pending fields in the current row to the configuration.
|
|
396
|
-
*/
|
|
397
|
-
flushCurrentRow() {
|
|
398
|
-
if (this.currentRow.length > 0) {
|
|
399
|
-
this.config.rows.push({
|
|
400
|
-
columns: this.currentRowColumns,
|
|
401
|
-
fields: [...this.currentRow],
|
|
402
|
-
});
|
|
403
|
-
this.currentRow = [];
|
|
404
|
-
this.currentRowColumns = 1;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* A builder for adding validation rules to a field fluently.
|
|
410
|
-
*/
|
|
411
|
-
class FieldValidatorBuilder {
|
|
412
|
-
field;
|
|
413
|
-
parent;
|
|
414
|
-
constructor(field, parent) {
|
|
415
|
-
this.field = field;
|
|
416
|
-
this.parent = parent;
|
|
417
|
-
this.field.validators = this.field.validators || [];
|
|
418
|
-
}
|
|
419
|
-
required(_message) {
|
|
420
|
-
this.field.validators.push(Validators.required);
|
|
421
|
-
return this;
|
|
422
|
-
}
|
|
423
|
-
minLength(length) {
|
|
424
|
-
this.field.validators.push(Validators.minLength(length));
|
|
425
|
-
return this;
|
|
426
|
-
}
|
|
427
|
-
maxLength(length) {
|
|
428
|
-
this.field.validators.push(Validators.maxLength(length));
|
|
429
|
-
return this;
|
|
430
|
-
}
|
|
431
|
-
pattern(pattern) {
|
|
432
|
-
this.field.validators.push(Validators.pattern(pattern));
|
|
433
|
-
return this;
|
|
434
|
-
}
|
|
435
|
-
email() {
|
|
436
|
-
this.field.validators.push(Validators.email);
|
|
437
|
-
return this;
|
|
438
|
-
}
|
|
439
|
-
min(value) {
|
|
440
|
-
this.field.validators.push(Validators.min(value));
|
|
441
|
-
return this;
|
|
442
|
-
}
|
|
443
|
-
max(value) {
|
|
444
|
-
this.field.validators.push(Validators.max(value));
|
|
445
|
-
return this;
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* Add a custom validator.
|
|
449
|
-
*/
|
|
450
|
-
custom(validator) {
|
|
451
|
-
this.field.validators.push(validator);
|
|
452
|
-
return this;
|
|
453
|
-
}
|
|
454
|
-
/**
|
|
455
|
-
* Return to the parent builder.
|
|
456
|
-
*/
|
|
457
|
-
done() {
|
|
458
|
-
return this.parent;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
class StepBuilder {
|
|
463
|
-
config;
|
|
464
|
-
layoutBuilder;
|
|
465
|
-
constructor(id, title) {
|
|
466
|
-
this.config = {
|
|
467
|
-
id,
|
|
468
|
-
title,
|
|
469
|
-
fields: [],
|
|
470
|
-
state: StepState.PENDING,
|
|
471
|
-
};
|
|
472
|
-
this.layoutBuilder = new FormLayoutBuilder(this.config, this);
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* Set the step body. Accepts plain text, a component, or a template.
|
|
476
|
-
* @param body The step body content (string, component `Type`, or `TemplateRef`).
|
|
477
|
-
* @param inputs Optional inputs for a component/template body (ignored for text).
|
|
478
|
-
*/
|
|
479
|
-
body(body, inputs) {
|
|
480
|
-
this.config.body = body;
|
|
481
|
-
if (inputs !== undefined) {
|
|
482
|
-
this.config.bodyInputs = inputs;
|
|
483
|
-
}
|
|
484
|
-
return this;
|
|
485
|
-
}
|
|
486
|
-
state(state) {
|
|
487
|
-
this.config.state = state;
|
|
488
|
-
return this;
|
|
489
|
-
}
|
|
490
|
-
guard(guard) {
|
|
491
|
-
this.config.guard = guard;
|
|
492
|
-
return this;
|
|
493
|
-
}
|
|
494
|
-
validators(validators) {
|
|
495
|
-
this.config.validators = validators;
|
|
496
|
-
return this;
|
|
497
|
-
}
|
|
498
|
-
field(field) {
|
|
499
|
-
return this.layoutBuilder.field(field);
|
|
500
|
-
}
|
|
501
|
-
row(columns = 2) {
|
|
502
|
-
return this.layoutBuilder.row(columns);
|
|
503
|
-
}
|
|
504
|
-
addToRow(field, span = 1) {
|
|
505
|
-
return this.layoutBuilder.addToRow(field, span);
|
|
506
|
-
}
|
|
507
|
-
addRow(columns, buildFn) {
|
|
508
|
-
return this.layoutBuilder.addRow(columns, buildFn);
|
|
509
|
-
}
|
|
510
|
-
fieldGroup(arg1, arg2, arg3) {
|
|
511
|
-
if (typeof arg1 !== 'string') {
|
|
512
|
-
return this.layoutBuilder.fieldGroup(arg1);
|
|
513
|
-
}
|
|
514
|
-
if (typeof arg2 === 'string') {
|
|
515
|
-
return this.layoutBuilder.fieldGroup(arg1, arg2, arg3);
|
|
516
|
-
}
|
|
517
|
-
return this.layoutBuilder.fieldGroup(arg1, arg2);
|
|
518
|
-
}
|
|
519
|
-
formValidators(validators) {
|
|
520
|
-
return this.layoutBuilder.formValidators(validators);
|
|
521
|
-
}
|
|
522
|
-
groupValidators(validators) {
|
|
523
|
-
return this.layoutBuilder.groupValidators(validators);
|
|
524
|
-
}
|
|
525
|
-
initialValue(value) {
|
|
526
|
-
return this.layoutBuilder.initialValue(value);
|
|
527
|
-
}
|
|
528
|
-
visible(condition) {
|
|
529
|
-
this.config.visible = condition;
|
|
530
|
-
return this;
|
|
531
|
-
}
|
|
532
|
-
nextLabel(label) {
|
|
533
|
-
this.config.nextLabel = label;
|
|
534
|
-
return this;
|
|
535
|
-
}
|
|
536
|
-
backLabel(label) {
|
|
537
|
-
this.config.backLabel = label;
|
|
538
|
-
return this;
|
|
539
|
-
}
|
|
540
|
-
hideBack(hide = true) {
|
|
541
|
-
this.config.hideBack = hide;
|
|
542
|
-
return this;
|
|
543
|
-
}
|
|
544
|
-
build() {
|
|
545
|
-
this.layoutBuilder.flushCurrentRow();
|
|
546
|
-
return this.config;
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
class BaseModalBuilder {
|
|
551
|
-
config;
|
|
552
|
-
layoutBuilder;
|
|
553
|
-
constructor(initialConfig) {
|
|
554
|
-
this.config = initialConfig;
|
|
555
|
-
this.layoutBuilder = new FormLayoutBuilder(this.config, this);
|
|
556
|
-
}
|
|
557
|
-
title(title) {
|
|
558
|
-
this.config.title = title;
|
|
559
|
-
return this;
|
|
560
|
-
}
|
|
561
|
-
subtitle(subtitle) {
|
|
562
|
-
this.config.subtitle = subtitle;
|
|
563
|
-
return this;
|
|
564
|
-
}
|
|
565
|
-
description(description) {
|
|
566
|
-
this.config.description = description;
|
|
567
|
-
return this;
|
|
568
|
-
}
|
|
569
|
-
closeGuard(guard) {
|
|
570
|
-
this.config.closeGuard = guard;
|
|
571
|
-
return this;
|
|
572
|
-
}
|
|
573
|
-
/** Set the width of the modal */
|
|
574
|
-
sizeWidth(size) {
|
|
575
|
-
this.config.sizeWidth = size;
|
|
576
|
-
return this;
|
|
577
|
-
}
|
|
578
|
-
/** Set the height of the modal */
|
|
579
|
-
sizeHeight(size) {
|
|
580
|
-
this.config.sizeHeight = size;
|
|
581
|
-
return this;
|
|
582
|
-
}
|
|
583
|
-
closeMode(mode) {
|
|
584
|
-
this.config.closeMode = mode;
|
|
585
|
-
return this;
|
|
586
|
-
}
|
|
587
|
-
backdrop(mode) {
|
|
588
|
-
this.config.backdrop = mode;
|
|
589
|
-
return this;
|
|
590
|
-
}
|
|
591
|
-
keyboard(mode) {
|
|
592
|
-
this.config.keyboard = mode;
|
|
593
|
-
return this;
|
|
594
|
-
}
|
|
595
|
-
intent(intent) {
|
|
596
|
-
this.config.intent = intent;
|
|
597
|
-
return this;
|
|
598
|
-
}
|
|
599
|
-
readOnly(readOnly = true) {
|
|
600
|
-
this.config.readOnly = readOnly;
|
|
601
|
-
return this;
|
|
602
|
-
}
|
|
603
|
-
disabled(disabled = true) {
|
|
604
|
-
this.config.disabled = disabled;
|
|
605
|
-
return this;
|
|
606
|
-
}
|
|
607
|
-
footerActions(actions) {
|
|
608
|
-
this.config.footerActions = actions;
|
|
609
|
-
return this;
|
|
610
|
-
}
|
|
611
|
-
polling(config) {
|
|
612
|
-
this.config.polling = config;
|
|
613
|
-
return this;
|
|
614
|
-
}
|
|
615
|
-
onCancel(handler) {
|
|
616
|
-
this.config.onCancel = handler;
|
|
617
|
-
return this;
|
|
618
|
-
}
|
|
619
|
-
i18n(labels) {
|
|
620
|
-
this.config.i18n = labels;
|
|
621
|
-
return this;
|
|
622
|
-
}
|
|
623
|
-
component(component) {
|
|
624
|
-
this.config.component = component;
|
|
625
|
-
return this;
|
|
626
|
-
}
|
|
627
|
-
template(template) {
|
|
628
|
-
this.config.template = template;
|
|
629
|
-
return this;
|
|
630
|
-
}
|
|
631
|
-
inputs(inputs) {
|
|
632
|
-
this.config.inputs = inputs;
|
|
633
|
-
return this;
|
|
634
|
-
}
|
|
635
|
-
animation(animation) {
|
|
636
|
-
this.config.animation = animation;
|
|
637
|
-
return this;
|
|
638
|
-
}
|
|
639
|
-
/**
|
|
640
|
-
* Control whether the modal renders as a bottom sheet on small screens (< 640px).
|
|
641
|
-
* Enabled by default; pass `false` to keep a centered dialog on mobile.
|
|
642
|
-
*/
|
|
643
|
-
mobileBottomSheet(enabled = true) {
|
|
644
|
-
this.config.mobileBottomSheet = enabled;
|
|
645
|
-
return this;
|
|
646
|
-
}
|
|
647
|
-
/**
|
|
648
|
-
* Add a custom body/content to the modal.
|
|
649
|
-
*/
|
|
650
|
-
body(body) {
|
|
651
|
-
return this.layoutBuilder.body(body);
|
|
652
|
-
}
|
|
653
|
-
/**
|
|
654
|
-
* Add a field.
|
|
655
|
-
*/
|
|
656
|
-
field(field) {
|
|
657
|
-
return this.layoutBuilder.field(field);
|
|
658
|
-
}
|
|
659
|
-
/**
|
|
660
|
-
* Add a field with a fluent validation builder.
|
|
661
|
-
*/
|
|
662
|
-
fieldWithValidators(field) {
|
|
663
|
-
return this.layoutBuilder.fieldWithValidators(field);
|
|
664
|
-
}
|
|
665
|
-
/**
|
|
666
|
-
* Start a new row.
|
|
667
|
-
*/
|
|
668
|
-
row(columns = 2) {
|
|
669
|
-
return this.layoutBuilder.row(columns);
|
|
670
|
-
}
|
|
671
|
-
/**
|
|
672
|
-
* Add a field to the current row.
|
|
673
|
-
*/
|
|
674
|
-
addToRow(field, span = 1) {
|
|
675
|
-
return this.layoutBuilder.addToRow(field, span);
|
|
676
|
-
}
|
|
677
|
-
/**
|
|
678
|
-
* Declarative way to add a row.
|
|
679
|
-
*/
|
|
680
|
-
addRow(columns, buildFn) {
|
|
681
|
-
return this.layoutBuilder.addRow(columns, buildFn);
|
|
682
|
-
}
|
|
683
|
-
fieldGroup(arg1, arg2, arg3) {
|
|
684
|
-
if (typeof arg1 !== 'string') {
|
|
685
|
-
return this.layoutBuilder.fieldGroup(arg1);
|
|
686
|
-
}
|
|
687
|
-
if (typeof arg2 === 'string') {
|
|
688
|
-
return this.layoutBuilder.fieldGroup(arg1, arg2, arg3);
|
|
689
|
-
}
|
|
690
|
-
return this.layoutBuilder.fieldGroup(arg1, arg2);
|
|
691
|
-
}
|
|
692
|
-
groupValidators(validators) {
|
|
693
|
-
return this.layoutBuilder.groupValidators(validators);
|
|
694
|
-
}
|
|
695
|
-
build() {
|
|
696
|
-
this.layoutBuilder.flushCurrentRow();
|
|
697
|
-
return Object.freeze({ ...this.config });
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
class WizardModalBuilder extends BaseModalBuilder {
|
|
702
|
-
constructor() {
|
|
703
|
-
super({
|
|
704
|
-
kind: ModalKind.WIZARD,
|
|
705
|
-
steps: [],
|
|
706
|
-
});
|
|
707
|
-
}
|
|
708
|
-
/**
|
|
709
|
-
* Set initial values for the entire wizard.
|
|
710
|
-
* Note: This will be merged with individual step initial values.
|
|
711
|
-
*/
|
|
712
|
-
initialValue(value) {
|
|
713
|
-
this.config.initialValue = value;
|
|
714
|
-
return this;
|
|
715
|
-
}
|
|
716
|
-
/**
|
|
717
|
-
* Description is not supported for wizard modals.
|
|
718
|
-
* Use step-level body text instead.
|
|
719
|
-
*/
|
|
720
|
-
description(_description) {
|
|
721
|
-
return this;
|
|
722
|
-
}
|
|
723
|
-
step(step) {
|
|
724
|
-
if (typeof step === 'function') {
|
|
725
|
-
const builder = new StepBuilder('', '');
|
|
726
|
-
step(builder);
|
|
727
|
-
const builtStep = builder.build();
|
|
728
|
-
this.config.steps.push(builtStep);
|
|
729
|
-
}
|
|
730
|
-
else {
|
|
731
|
-
this.config.steps.push(step);
|
|
732
|
-
}
|
|
733
|
-
return this;
|
|
734
|
-
}
|
|
735
|
-
addStep(title, buildFn, id) {
|
|
736
|
-
const stepId = id || `step-${this.config.steps.length}`;
|
|
737
|
-
const builder = new StepBuilder(stepId, title);
|
|
738
|
-
buildFn(builder);
|
|
739
|
-
const builtStep = builder.build();
|
|
740
|
-
this.config.steps.push(builtStep);
|
|
741
|
-
return this;
|
|
742
|
-
}
|
|
743
|
-
startAt(stepId) {
|
|
744
|
-
this.config.startStepId = stepId;
|
|
745
|
-
return this;
|
|
746
|
-
}
|
|
747
|
-
flow(mode) {
|
|
748
|
-
this.config.flow = mode;
|
|
749
|
-
return this;
|
|
750
|
-
}
|
|
751
|
-
onStepChange(handler) {
|
|
752
|
-
this.config.onStepChange = handler;
|
|
753
|
-
return this;
|
|
754
|
-
}
|
|
755
|
-
onComplete(handler) {
|
|
756
|
-
this.config.onComplete = handler;
|
|
757
|
-
return this;
|
|
758
|
-
}
|
|
759
|
-
onBeforeComplete(validators) {
|
|
760
|
-
this.config.onBeforeComplete = validators;
|
|
761
|
-
return this;
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
class FormModalBuilder extends BaseModalBuilder {
|
|
766
|
-
constructor() {
|
|
767
|
-
super({
|
|
768
|
-
kind: ModalKind.FORM,
|
|
769
|
-
fields: [],
|
|
770
|
-
rows: [],
|
|
771
|
-
});
|
|
772
|
-
}
|
|
773
|
-
field(field) {
|
|
774
|
-
return super.field(field);
|
|
775
|
-
}
|
|
776
|
-
layout(mode) {
|
|
777
|
-
this.config.layout = mode;
|
|
778
|
-
return this;
|
|
779
|
-
}
|
|
780
|
-
initialValue(value) {
|
|
781
|
-
return this.layoutBuilder.initialValue(value);
|
|
782
|
-
}
|
|
783
|
-
submitMode(mode) {
|
|
784
|
-
this.config.submitMode = mode;
|
|
785
|
-
return this;
|
|
786
|
-
}
|
|
787
|
-
onComplete(handler) {
|
|
788
|
-
this.config.onComplete = handler;
|
|
789
|
-
return this;
|
|
790
|
-
}
|
|
791
|
-
formValidators(validators) {
|
|
792
|
-
return this.layoutBuilder.formValidators(validators);
|
|
793
|
-
}
|
|
794
|
-
groupValidators(validators) {
|
|
795
|
-
return this.layoutBuilder.groupValidators(validators);
|
|
796
|
-
}
|
|
797
|
-
build() {
|
|
798
|
-
return super.build();
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
class ConfirmationModalBuilder extends BaseModalBuilder {
|
|
803
|
-
constructor() {
|
|
804
|
-
super({
|
|
805
|
-
kind: ModalKind.CONFIRMATION,
|
|
806
|
-
message: '',
|
|
807
|
-
fields: [],
|
|
808
|
-
rows: [],
|
|
809
|
-
});
|
|
810
|
-
}
|
|
811
|
-
message(text) {
|
|
812
|
-
this.config.message = text;
|
|
813
|
-
return this;
|
|
814
|
-
}
|
|
815
|
-
tone(tone) {
|
|
816
|
-
this.config.tone = tone;
|
|
817
|
-
return this;
|
|
818
|
-
}
|
|
819
|
-
confirmAction(action) {
|
|
820
|
-
this.config.confirm = action;
|
|
821
|
-
return this;
|
|
822
|
-
}
|
|
823
|
-
cancelAction(action) {
|
|
824
|
-
this.config.cancel = action;
|
|
825
|
-
return this;
|
|
826
|
-
}
|
|
827
|
-
initialValue(value) {
|
|
828
|
-
return this.layoutBuilder.initialValue(value);
|
|
829
|
-
}
|
|
830
|
-
formValidators(validators) {
|
|
831
|
-
return this.layoutBuilder.formValidators(validators);
|
|
832
|
-
}
|
|
833
|
-
groupValidators(validators) {
|
|
834
|
-
return this.layoutBuilder.groupValidators(validators);
|
|
835
|
-
}
|
|
836
|
-
build() {
|
|
837
|
-
return super.build();
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
class CustomModalBuilder extends BaseModalBuilder {
|
|
842
|
-
constructor() {
|
|
843
|
-
super({
|
|
844
|
-
kind: ModalKind.CUSTOM,
|
|
845
|
-
});
|
|
846
|
-
}
|
|
847
|
-
onComplete(handler) {
|
|
848
|
-
this.config.onComplete = handler;
|
|
849
|
-
return this;
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
class ModalBuilder {
|
|
854
|
-
static wizard() {
|
|
855
|
-
return new WizardModalBuilder();
|
|
856
|
-
}
|
|
857
|
-
static form() {
|
|
858
|
-
return new FormModalBuilder();
|
|
859
|
-
}
|
|
860
|
-
static confirmation() {
|
|
861
|
-
return new ConfirmationModalBuilder();
|
|
862
|
-
}
|
|
863
|
-
static custom() {
|
|
864
|
-
return new CustomModalBuilder();
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
class MnModalRef {
|
|
869
|
-
componentRef;
|
|
870
|
-
config;
|
|
871
|
-
closeSubject = new Subject();
|
|
872
|
-
afterClosed$ = this.closeSubject.asObservable();
|
|
873
|
-
/** Whether close() or dismiss() has run, so a shell that finishes loading afterwards is never shown. */
|
|
874
|
-
closeRequested = false;
|
|
875
|
-
/**
|
|
876
|
-
* @param componentRef The rendered modal shell, or null while `MnModalService` is still
|
|
877
|
-
* loading the modal components (`mn-angular-lib/modal-ui`); it is attached with {@link attach}.
|
|
878
|
-
* @param config The modal's mutable working config, shared with the shell.
|
|
879
|
-
*/
|
|
880
|
-
constructor(componentRef, config) {
|
|
881
|
-
this.componentRef = componentRef;
|
|
882
|
-
this.config = config;
|
|
883
|
-
}
|
|
884
|
-
close(result) {
|
|
885
|
-
const event = {
|
|
886
|
-
reason: ModalCloseReason.COMPLETED,
|
|
887
|
-
result,
|
|
888
|
-
};
|
|
889
|
-
this.animateAndDestroy(event);
|
|
890
|
-
}
|
|
891
|
-
dismiss(reason) {
|
|
892
|
-
const event = {
|
|
893
|
-
reason,
|
|
894
|
-
};
|
|
895
|
-
this.animateAndDestroy(event);
|
|
896
|
-
}
|
|
897
|
-
async animateAndDestroy(event) {
|
|
898
|
-
this.closeRequested = true;
|
|
899
|
-
const shell = this.componentRef?.instance;
|
|
900
|
-
if (shell && typeof shell.startClosing === 'function') {
|
|
901
|
-
await shell.startClosing();
|
|
902
|
-
}
|
|
903
|
-
this.closeSubject.next(event);
|
|
904
|
-
this.closeSubject.complete();
|
|
905
|
-
this.destroy();
|
|
906
|
-
}
|
|
907
|
-
update(config) {
|
|
908
|
-
Object.assign(this.config, config);
|
|
909
|
-
// Trigger change detection on the shell component, once it is rendered
|
|
910
|
-
this.componentRef?.changeDetectorRef.detectChanges();
|
|
911
|
-
}
|
|
912
|
-
/** The rendered shell component, or undefined while the modal components are still loading. */
|
|
913
|
-
get component() {
|
|
914
|
-
return this.componentRef?.instance;
|
|
915
|
-
}
|
|
916
|
-
/** Whether close() or dismiss() has been called. */
|
|
917
|
-
get isCloseRequested() {
|
|
918
|
-
return this.closeRequested;
|
|
919
|
-
}
|
|
920
|
-
/**
|
|
921
|
-
* Attaches the rendered shell once `MnModalService` has loaded the modal components.
|
|
922
|
-
* @param componentRef The created shell.
|
|
923
|
-
*/
|
|
924
|
-
attach(componentRef) {
|
|
925
|
-
this.componentRef = componentRef;
|
|
926
|
-
}
|
|
927
|
-
destroy() {
|
|
928
|
-
this.componentRef?.destroy();
|
|
929
|
-
}
|
|
165
|
+
switch (style) {
|
|
166
|
+
case ActionStyle.DANGER: return MN_MODAL_ACTION_ICONS.danger;
|
|
167
|
+
case ActionStyle.PRIMARY: return MN_MODAL_ACTION_ICONS.confirm;
|
|
168
|
+
default: return MN_MODAL_ACTION_ICONS.cancel;
|
|
169
|
+
}
|
|
930
170
|
}
|
|
171
|
+
const MN_HAPTICS = new InjectionToken("MN_HAPTICS");
|
|
172
|
+
var FormLayoutBuilder = class FormLayoutBuilder {
|
|
173
|
+
config;
|
|
174
|
+
parent;
|
|
175
|
+
currentRow = [];
|
|
176
|
+
currentRowColumns = 1;
|
|
177
|
+
constructor(config, parent) {
|
|
178
|
+
this.config = config;
|
|
179
|
+
this.parent = parent;
|
|
180
|
+
this.config.fields = this.config.fields || [];
|
|
181
|
+
this.config.rows = this.config.rows || [];
|
|
182
|
+
}
|
|
183
|
+
body(body) {
|
|
184
|
+
this.config.body = body;
|
|
185
|
+
return this.parent;
|
|
186
|
+
}
|
|
187
|
+
field(field) {
|
|
188
|
+
this.flushCurrentRow();
|
|
189
|
+
this.config.fields = this.config.fields || [];
|
|
190
|
+
this.config.fields.push(field);
|
|
191
|
+
this.config.rows = this.config.rows || [];
|
|
192
|
+
this.config.rows.push({
|
|
193
|
+
columns: 1,
|
|
194
|
+
fields: [{
|
|
195
|
+
field,
|
|
196
|
+
span: 1
|
|
197
|
+
}]
|
|
198
|
+
});
|
|
199
|
+
return this.parent;
|
|
200
|
+
}
|
|
201
|
+
row(columns = 2) {
|
|
202
|
+
this.flushCurrentRow();
|
|
203
|
+
this.currentRowColumns = columns;
|
|
204
|
+
return this.parent;
|
|
205
|
+
}
|
|
206
|
+
addToRow(field, span = 1) {
|
|
207
|
+
this.config.fields = this.config.fields || [];
|
|
208
|
+
this.config.fields.push(field);
|
|
209
|
+
this.currentRow.push({
|
|
210
|
+
field,
|
|
211
|
+
span
|
|
212
|
+
});
|
|
213
|
+
return this.parent;
|
|
214
|
+
}
|
|
215
|
+
addRow(columns, buildFn) {
|
|
216
|
+
this.flushCurrentRow();
|
|
217
|
+
const rowFields = [];
|
|
218
|
+
buildFn({ add: (field, span = 1) => {
|
|
219
|
+
this.config.fields = this.config.fields || [];
|
|
220
|
+
this.config.fields.push(field);
|
|
221
|
+
rowFields.push({
|
|
222
|
+
field,
|
|
223
|
+
span
|
|
224
|
+
});
|
|
225
|
+
} });
|
|
226
|
+
if (rowFields.length > 0) {
|
|
227
|
+
this.config.rows = this.config.rows || [];
|
|
228
|
+
this.config.rows.push({
|
|
229
|
+
columns,
|
|
230
|
+
fields: rowFields
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return this.parent;
|
|
234
|
+
}
|
|
235
|
+
fieldGroup(arg1, arg2, arg3) {
|
|
236
|
+
this.flushCurrentRow();
|
|
237
|
+
if (typeof arg1 !== "string") {
|
|
238
|
+
const group = arg1;
|
|
239
|
+
this.processFieldGroup(group);
|
|
240
|
+
return this.parent;
|
|
241
|
+
}
|
|
242
|
+
const title = arg1;
|
|
243
|
+
let description;
|
|
244
|
+
let buildFn;
|
|
245
|
+
if (typeof arg2 === "string") {
|
|
246
|
+
description = arg2;
|
|
247
|
+
buildFn = arg3;
|
|
248
|
+
} else buildFn = arg2;
|
|
249
|
+
const groupConfig = {
|
|
250
|
+
fields: [],
|
|
251
|
+
rows: []
|
|
252
|
+
};
|
|
253
|
+
const groupBuilder = new FormLayoutBuilder(groupConfig, null);
|
|
254
|
+
groupBuilder.parent = groupBuilder;
|
|
255
|
+
buildFn(groupBuilder);
|
|
256
|
+
groupBuilder.flushCurrentRow();
|
|
257
|
+
const group = {
|
|
258
|
+
title,
|
|
259
|
+
description,
|
|
260
|
+
fields: groupConfig.fields || [],
|
|
261
|
+
rows: groupConfig.rows || []
|
|
262
|
+
};
|
|
263
|
+
this.processFieldGroup(group);
|
|
264
|
+
return this.parent;
|
|
265
|
+
}
|
|
266
|
+
processFieldGroup(group) {
|
|
267
|
+
if (!this.config.fieldGroups) this.config.fieldGroups = [];
|
|
268
|
+
this.config.fields = this.config.fields || [];
|
|
269
|
+
const fields = this.config.fields;
|
|
270
|
+
group.fields.forEach((f) => fields.push(f));
|
|
271
|
+
if (!group.rows || group.rows.length === 0) group.rows = group.fields.map((f) => ({
|
|
272
|
+
columns: 1,
|
|
273
|
+
fields: [{
|
|
274
|
+
field: f,
|
|
275
|
+
span: 1
|
|
276
|
+
}]
|
|
277
|
+
}));
|
|
278
|
+
this.config.fieldGroups.push(group);
|
|
279
|
+
}
|
|
280
|
+
formValidators(validators) {
|
|
281
|
+
this.config.formValidators = validators;
|
|
282
|
+
return this.parent;
|
|
283
|
+
}
|
|
284
|
+
groupValidators(validators) {
|
|
285
|
+
this.config.groupValidators = validators;
|
|
286
|
+
return this.parent;
|
|
287
|
+
}
|
|
288
|
+
initialValue(value) {
|
|
289
|
+
this.config.initialValue = value;
|
|
290
|
+
return this.parent;
|
|
291
|
+
}
|
|
292
|
+
focus(key) {
|
|
293
|
+
this.config.fields?.forEach((f) => {
|
|
294
|
+
f.autoFocus = false;
|
|
295
|
+
});
|
|
296
|
+
this.config.fieldGroups?.forEach((g) => {
|
|
297
|
+
g.fields.forEach((f) => {
|
|
298
|
+
f.autoFocus = false;
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
const field = this.config.fields?.find((f) => f.key === key);
|
|
302
|
+
if (field) field.autoFocus = true;
|
|
303
|
+
return this.parent;
|
|
304
|
+
}
|
|
305
|
+
fieldWithValidators(field) {
|
|
306
|
+
const fieldWithV = field;
|
|
307
|
+
fieldWithV.validators = fieldWithV.validators || [];
|
|
308
|
+
this.field(field);
|
|
309
|
+
return new FieldValidatorBuilder(field, this.parent);
|
|
310
|
+
}
|
|
311
|
+
flushCurrentRow() {
|
|
312
|
+
if (this.currentRow.length > 0) {
|
|
313
|
+
this.config.rows.push({
|
|
314
|
+
columns: this.currentRowColumns,
|
|
315
|
+
fields: [...this.currentRow]
|
|
316
|
+
});
|
|
317
|
+
this.currentRow = [];
|
|
318
|
+
this.currentRowColumns = 1;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
var FieldValidatorBuilder = class {
|
|
323
|
+
field;
|
|
324
|
+
parent;
|
|
325
|
+
constructor(field, parent) {
|
|
326
|
+
this.field = field;
|
|
327
|
+
this.parent = parent;
|
|
328
|
+
this.field.validators = this.field.validators || [];
|
|
329
|
+
}
|
|
330
|
+
required(_message) {
|
|
331
|
+
this.field.validators.push(Validators.required);
|
|
332
|
+
return this;
|
|
333
|
+
}
|
|
334
|
+
minLength(length) {
|
|
335
|
+
this.field.validators.push(Validators.minLength(length));
|
|
336
|
+
return this;
|
|
337
|
+
}
|
|
338
|
+
maxLength(length) {
|
|
339
|
+
this.field.validators.push(Validators.maxLength(length));
|
|
340
|
+
return this;
|
|
341
|
+
}
|
|
342
|
+
pattern(pattern) {
|
|
343
|
+
this.field.validators.push(Validators.pattern(pattern));
|
|
344
|
+
return this;
|
|
345
|
+
}
|
|
346
|
+
email() {
|
|
347
|
+
this.field.validators.push(Validators.email);
|
|
348
|
+
return this;
|
|
349
|
+
}
|
|
350
|
+
min(value) {
|
|
351
|
+
this.field.validators.push(Validators.min(value));
|
|
352
|
+
return this;
|
|
353
|
+
}
|
|
354
|
+
max(value) {
|
|
355
|
+
this.field.validators.push(Validators.max(value));
|
|
356
|
+
return this;
|
|
357
|
+
}
|
|
358
|
+
custom(validator) {
|
|
359
|
+
this.field.validators.push(validator);
|
|
360
|
+
return this;
|
|
361
|
+
}
|
|
362
|
+
done() {
|
|
363
|
+
return this.parent;
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
var StepBuilder = class {
|
|
367
|
+
config;
|
|
368
|
+
layoutBuilder;
|
|
369
|
+
constructor(id, title) {
|
|
370
|
+
this.config = {
|
|
371
|
+
id,
|
|
372
|
+
title,
|
|
373
|
+
fields: [],
|
|
374
|
+
state: StepState.PENDING
|
|
375
|
+
};
|
|
376
|
+
this.layoutBuilder = new FormLayoutBuilder(this.config, this);
|
|
377
|
+
}
|
|
378
|
+
body(body, inputs) {
|
|
379
|
+
this.config.body = body;
|
|
380
|
+
if (inputs !== void 0) this.config.bodyInputs = inputs;
|
|
381
|
+
return this;
|
|
382
|
+
}
|
|
383
|
+
state(state) {
|
|
384
|
+
this.config.state = state;
|
|
385
|
+
return this;
|
|
386
|
+
}
|
|
387
|
+
guard(guard) {
|
|
388
|
+
this.config.guard = guard;
|
|
389
|
+
return this;
|
|
390
|
+
}
|
|
391
|
+
validators(validators) {
|
|
392
|
+
this.config.validators = validators;
|
|
393
|
+
return this;
|
|
394
|
+
}
|
|
395
|
+
field(field) {
|
|
396
|
+
return this.layoutBuilder.field(field);
|
|
397
|
+
}
|
|
398
|
+
row(columns = 2) {
|
|
399
|
+
return this.layoutBuilder.row(columns);
|
|
400
|
+
}
|
|
401
|
+
addToRow(field, span = 1) {
|
|
402
|
+
return this.layoutBuilder.addToRow(field, span);
|
|
403
|
+
}
|
|
404
|
+
addRow(columns, buildFn) {
|
|
405
|
+
return this.layoutBuilder.addRow(columns, buildFn);
|
|
406
|
+
}
|
|
407
|
+
fieldGroup(arg1, arg2, arg3) {
|
|
408
|
+
if (typeof arg1 !== "string") return this.layoutBuilder.fieldGroup(arg1);
|
|
409
|
+
if (typeof arg2 === "string") return this.layoutBuilder.fieldGroup(arg1, arg2, arg3);
|
|
410
|
+
return this.layoutBuilder.fieldGroup(arg1, arg2);
|
|
411
|
+
}
|
|
412
|
+
formValidators(validators) {
|
|
413
|
+
return this.layoutBuilder.formValidators(validators);
|
|
414
|
+
}
|
|
415
|
+
groupValidators(validators) {
|
|
416
|
+
return this.layoutBuilder.groupValidators(validators);
|
|
417
|
+
}
|
|
418
|
+
initialValue(value) {
|
|
419
|
+
return this.layoutBuilder.initialValue(value);
|
|
420
|
+
}
|
|
421
|
+
visible(condition) {
|
|
422
|
+
this.config.visible = condition;
|
|
423
|
+
return this;
|
|
424
|
+
}
|
|
425
|
+
nextLabel(label) {
|
|
426
|
+
this.config.nextLabel = label;
|
|
427
|
+
return this;
|
|
428
|
+
}
|
|
429
|
+
backLabel(label) {
|
|
430
|
+
this.config.backLabel = label;
|
|
431
|
+
return this;
|
|
432
|
+
}
|
|
433
|
+
hideBack(hide = true) {
|
|
434
|
+
this.config.hideBack = hide;
|
|
435
|
+
return this;
|
|
436
|
+
}
|
|
437
|
+
build() {
|
|
438
|
+
this.layoutBuilder.flushCurrentRow();
|
|
439
|
+
return this.config;
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
var BaseModalBuilder = class {
|
|
443
|
+
config;
|
|
444
|
+
layoutBuilder;
|
|
445
|
+
constructor(initialConfig) {
|
|
446
|
+
this.config = initialConfig;
|
|
447
|
+
this.layoutBuilder = new FormLayoutBuilder(this.config, this);
|
|
448
|
+
}
|
|
449
|
+
title(title) {
|
|
450
|
+
this.config.title = title;
|
|
451
|
+
return this;
|
|
452
|
+
}
|
|
453
|
+
subtitle(subtitle) {
|
|
454
|
+
this.config.subtitle = subtitle;
|
|
455
|
+
return this;
|
|
456
|
+
}
|
|
457
|
+
description(description) {
|
|
458
|
+
this.config.description = description;
|
|
459
|
+
return this;
|
|
460
|
+
}
|
|
461
|
+
closeGuard(guard) {
|
|
462
|
+
this.config.closeGuard = guard;
|
|
463
|
+
return this;
|
|
464
|
+
}
|
|
465
|
+
sizeWidth(size) {
|
|
466
|
+
this.config.sizeWidth = size;
|
|
467
|
+
return this;
|
|
468
|
+
}
|
|
469
|
+
sizeHeight(size) {
|
|
470
|
+
this.config.sizeHeight = size;
|
|
471
|
+
return this;
|
|
472
|
+
}
|
|
473
|
+
closeMode(mode) {
|
|
474
|
+
this.config.closeMode = mode;
|
|
475
|
+
return this;
|
|
476
|
+
}
|
|
477
|
+
backdrop(mode) {
|
|
478
|
+
this.config.backdrop = mode;
|
|
479
|
+
return this;
|
|
480
|
+
}
|
|
481
|
+
keyboard(mode) {
|
|
482
|
+
this.config.keyboard = mode;
|
|
483
|
+
return this;
|
|
484
|
+
}
|
|
485
|
+
intent(intent) {
|
|
486
|
+
this.config.intent = intent;
|
|
487
|
+
return this;
|
|
488
|
+
}
|
|
489
|
+
readOnly(readOnly = true) {
|
|
490
|
+
this.config.readOnly = readOnly;
|
|
491
|
+
return this;
|
|
492
|
+
}
|
|
493
|
+
disabled(disabled = true) {
|
|
494
|
+
this.config.disabled = disabled;
|
|
495
|
+
return this;
|
|
496
|
+
}
|
|
497
|
+
footerActions(actions) {
|
|
498
|
+
this.config.footerActions = actions;
|
|
499
|
+
return this;
|
|
500
|
+
}
|
|
501
|
+
polling(config) {
|
|
502
|
+
this.config.polling = config;
|
|
503
|
+
return this;
|
|
504
|
+
}
|
|
505
|
+
onCancel(handler) {
|
|
506
|
+
this.config.onCancel = handler;
|
|
507
|
+
return this;
|
|
508
|
+
}
|
|
509
|
+
i18n(labels) {
|
|
510
|
+
this.config.i18n = labels;
|
|
511
|
+
return this;
|
|
512
|
+
}
|
|
513
|
+
component(component) {
|
|
514
|
+
this.config.component = component;
|
|
515
|
+
return this;
|
|
516
|
+
}
|
|
517
|
+
template(template) {
|
|
518
|
+
this.config.template = template;
|
|
519
|
+
return this;
|
|
520
|
+
}
|
|
521
|
+
inputs(inputs) {
|
|
522
|
+
this.config.inputs = inputs;
|
|
523
|
+
return this;
|
|
524
|
+
}
|
|
525
|
+
animation(animation) {
|
|
526
|
+
this.config.animation = animation;
|
|
527
|
+
return this;
|
|
528
|
+
}
|
|
529
|
+
mobileBottomSheet(enabled = true) {
|
|
530
|
+
this.config.mobileBottomSheet = enabled;
|
|
531
|
+
return this;
|
|
532
|
+
}
|
|
533
|
+
body(body) {
|
|
534
|
+
return this.layoutBuilder.body(body);
|
|
535
|
+
}
|
|
536
|
+
field(field) {
|
|
537
|
+
return this.layoutBuilder.field(field);
|
|
538
|
+
}
|
|
539
|
+
fieldWithValidators(field) {
|
|
540
|
+
return this.layoutBuilder.fieldWithValidators(field);
|
|
541
|
+
}
|
|
542
|
+
row(columns = 2) {
|
|
543
|
+
return this.layoutBuilder.row(columns);
|
|
544
|
+
}
|
|
545
|
+
addToRow(field, span = 1) {
|
|
546
|
+
return this.layoutBuilder.addToRow(field, span);
|
|
547
|
+
}
|
|
548
|
+
addRow(columns, buildFn) {
|
|
549
|
+
return this.layoutBuilder.addRow(columns, buildFn);
|
|
550
|
+
}
|
|
551
|
+
fieldGroup(arg1, arg2, arg3) {
|
|
552
|
+
if (typeof arg1 !== "string") return this.layoutBuilder.fieldGroup(arg1);
|
|
553
|
+
if (typeof arg2 === "string") return this.layoutBuilder.fieldGroup(arg1, arg2, arg3);
|
|
554
|
+
return this.layoutBuilder.fieldGroup(arg1, arg2);
|
|
555
|
+
}
|
|
556
|
+
groupValidators(validators) {
|
|
557
|
+
return this.layoutBuilder.groupValidators(validators);
|
|
558
|
+
}
|
|
559
|
+
build() {
|
|
560
|
+
this.layoutBuilder.flushCurrentRow();
|
|
561
|
+
return Object.freeze({ ...this.config });
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
var WizardModalBuilder = class extends BaseModalBuilder {
|
|
565
|
+
constructor() {
|
|
566
|
+
super({
|
|
567
|
+
kind: ModalKind.WIZARD,
|
|
568
|
+
steps: []
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
initialValue(value) {
|
|
572
|
+
this.config.initialValue = value;
|
|
573
|
+
return this;
|
|
574
|
+
}
|
|
575
|
+
description(_description) {
|
|
576
|
+
return this;
|
|
577
|
+
}
|
|
578
|
+
step(step) {
|
|
579
|
+
if (typeof step === "function") {
|
|
580
|
+
const builder = new StepBuilder("", "");
|
|
581
|
+
step(builder);
|
|
582
|
+
const builtStep = builder.build();
|
|
583
|
+
this.config.steps.push(builtStep);
|
|
584
|
+
} else this.config.steps.push(step);
|
|
585
|
+
return this;
|
|
586
|
+
}
|
|
587
|
+
addStep(title, buildFn, id) {
|
|
588
|
+
const builder = new StepBuilder(id || `step-${this.config.steps.length}`, title);
|
|
589
|
+
buildFn(builder);
|
|
590
|
+
const builtStep = builder.build();
|
|
591
|
+
this.config.steps.push(builtStep);
|
|
592
|
+
return this;
|
|
593
|
+
}
|
|
594
|
+
startAt(stepId) {
|
|
595
|
+
this.config.startStepId = stepId;
|
|
596
|
+
return this;
|
|
597
|
+
}
|
|
598
|
+
flow(mode) {
|
|
599
|
+
this.config.flow = mode;
|
|
600
|
+
return this;
|
|
601
|
+
}
|
|
602
|
+
onStepChange(handler) {
|
|
603
|
+
this.config.onStepChange = handler;
|
|
604
|
+
return this;
|
|
605
|
+
}
|
|
606
|
+
onComplete(handler) {
|
|
607
|
+
this.config.onComplete = handler;
|
|
608
|
+
return this;
|
|
609
|
+
}
|
|
610
|
+
onBeforeComplete(validators) {
|
|
611
|
+
this.config.onBeforeComplete = validators;
|
|
612
|
+
return this;
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
var FormModalBuilder = class extends BaseModalBuilder {
|
|
616
|
+
constructor() {
|
|
617
|
+
super({
|
|
618
|
+
kind: ModalKind.FORM,
|
|
619
|
+
fields: [],
|
|
620
|
+
rows: []
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
field(field) {
|
|
624
|
+
return super.field(field);
|
|
625
|
+
}
|
|
626
|
+
layout(mode) {
|
|
627
|
+
this.config.layout = mode;
|
|
628
|
+
return this;
|
|
629
|
+
}
|
|
630
|
+
initialValue(value) {
|
|
631
|
+
return this.layoutBuilder.initialValue(value);
|
|
632
|
+
}
|
|
633
|
+
submitMode(mode) {
|
|
634
|
+
this.config.submitMode = mode;
|
|
635
|
+
return this;
|
|
636
|
+
}
|
|
637
|
+
onComplete(handler) {
|
|
638
|
+
this.config.onComplete = handler;
|
|
639
|
+
return this;
|
|
640
|
+
}
|
|
641
|
+
formValidators(validators) {
|
|
642
|
+
return this.layoutBuilder.formValidators(validators);
|
|
643
|
+
}
|
|
644
|
+
groupValidators(validators) {
|
|
645
|
+
return this.layoutBuilder.groupValidators(validators);
|
|
646
|
+
}
|
|
647
|
+
build() {
|
|
648
|
+
return super.build();
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
var ConfirmationModalBuilder = class extends BaseModalBuilder {
|
|
652
|
+
constructor() {
|
|
653
|
+
super({
|
|
654
|
+
kind: ModalKind.CONFIRMATION,
|
|
655
|
+
message: "",
|
|
656
|
+
fields: [],
|
|
657
|
+
rows: []
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
message(text) {
|
|
661
|
+
this.config.message = text;
|
|
662
|
+
return this;
|
|
663
|
+
}
|
|
664
|
+
tone(tone) {
|
|
665
|
+
this.config.tone = tone;
|
|
666
|
+
return this;
|
|
667
|
+
}
|
|
668
|
+
confirmAction(action) {
|
|
669
|
+
this.config.confirm = action;
|
|
670
|
+
return this;
|
|
671
|
+
}
|
|
672
|
+
cancelAction(action) {
|
|
673
|
+
this.config.cancel = action;
|
|
674
|
+
return this;
|
|
675
|
+
}
|
|
676
|
+
initialValue(value) {
|
|
677
|
+
return this.layoutBuilder.initialValue(value);
|
|
678
|
+
}
|
|
679
|
+
formValidators(validators) {
|
|
680
|
+
return this.layoutBuilder.formValidators(validators);
|
|
681
|
+
}
|
|
682
|
+
groupValidators(validators) {
|
|
683
|
+
return this.layoutBuilder.groupValidators(validators);
|
|
684
|
+
}
|
|
685
|
+
build() {
|
|
686
|
+
return super.build();
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
var CustomModalBuilder = class extends BaseModalBuilder {
|
|
690
|
+
constructor() {
|
|
691
|
+
super({ kind: ModalKind.CUSTOM });
|
|
692
|
+
}
|
|
693
|
+
onComplete(handler) {
|
|
694
|
+
this.config.onComplete = handler;
|
|
695
|
+
return this;
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
var ModalBuilder = class {
|
|
699
|
+
static wizard() {
|
|
700
|
+
return new WizardModalBuilder();
|
|
701
|
+
}
|
|
702
|
+
static form() {
|
|
703
|
+
return new FormModalBuilder();
|
|
704
|
+
}
|
|
705
|
+
static confirmation() {
|
|
706
|
+
return new ConfirmationModalBuilder();
|
|
707
|
+
}
|
|
708
|
+
static custom() {
|
|
709
|
+
return new CustomModalBuilder();
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
var MnModalRef = class {
|
|
713
|
+
componentRef;
|
|
714
|
+
config;
|
|
715
|
+
closeSubject = new Subject();
|
|
716
|
+
afterClosed$ = this.closeSubject.asObservable();
|
|
717
|
+
closeRequested = false;
|
|
718
|
+
constructor(componentRef, config) {
|
|
719
|
+
this.componentRef = componentRef;
|
|
720
|
+
this.config = config;
|
|
721
|
+
}
|
|
722
|
+
close(result) {
|
|
723
|
+
const event = {
|
|
724
|
+
reason: ModalCloseReason.COMPLETED,
|
|
725
|
+
result
|
|
726
|
+
};
|
|
727
|
+
this.animateAndDestroy(event);
|
|
728
|
+
}
|
|
729
|
+
dismiss(reason) {
|
|
730
|
+
const event = { reason };
|
|
731
|
+
this.animateAndDestroy(event);
|
|
732
|
+
}
|
|
733
|
+
async animateAndDestroy(event) {
|
|
734
|
+
this.closeRequested = true;
|
|
735
|
+
const shell = this.componentRef?.instance;
|
|
736
|
+
if (shell && typeof shell.startClosing === "function") await shell.startClosing();
|
|
737
|
+
this.closeSubject.next(event);
|
|
738
|
+
this.closeSubject.complete();
|
|
739
|
+
this.destroy();
|
|
740
|
+
}
|
|
741
|
+
update(config) {
|
|
742
|
+
Object.assign(this.config, config);
|
|
743
|
+
this.componentRef?.changeDetectorRef.detectChanges();
|
|
744
|
+
}
|
|
745
|
+
get component() {
|
|
746
|
+
return this.componentRef?.instance;
|
|
747
|
+
}
|
|
748
|
+
get isCloseRequested() {
|
|
749
|
+
return this.closeRequested;
|
|
750
|
+
}
|
|
751
|
+
attach(componentRef) {
|
|
752
|
+
this.componentRef = componentRef;
|
|
753
|
+
}
|
|
754
|
+
destroy() {
|
|
755
|
+
this.componentRef?.destroy();
|
|
756
|
+
}
|
|
757
|
+
};
|
|
758
|
+
export { ActionStyle, BackdropMode, BaseModalBuilder, CloseMode, ConfirmationModalBuilder, ConfirmationTone, CustomModalBuilder, FieldAppearance, FieldKind, FormLayoutMode, FormModalBuilder, KeyboardMode, MN_HAPTICS, MN_MODAL_ACTION_ICONS, MODAL_ACTION_ICON_SIZE, MODAL_ACTION_ICON_SIZE_SM, MnModalRef, ModalBuilder, ModalCloseReason, ModalIntent, ModalKind, ModalSize, NavigationDirection, OptionState, SelectionMode, StepBuilder, StepState, SubmitMode, TemplateRef, Type, ValidationCode, ValidationStatus, WizardFlowMode, WizardModalBuilder, defaultIconForStyle };
|
|
931
759
|
|
|
932
|
-
|
|
933
|
-
* Public API of the `mn-angular-lib/modal-core` entry point: modal types, builders, the modal ref and action icons, without any component.
|
|
934
|
-
*
|
|
935
|
-
* Each entry point is its own module in the published package, so a consumer's bundler
|
|
936
|
-
* splits it into the chunk that uses it instead of loading the whole library at startup.
|
|
937
|
-
* The root `mn-angular-lib` entry re-exports every entry point.
|
|
938
|
-
*/
|
|
939
|
-
|
|
940
|
-
/**
|
|
941
|
-
* Generated bundle index. Do not edit.
|
|
942
|
-
*/
|
|
943
|
-
|
|
944
|
-
export { ActionStyle, BackdropMode, BaseModalBuilder, CloseMode, ConfirmationModalBuilder, ConfirmationTone, CustomModalBuilder, FieldAppearance, FieldKind, FormLayoutMode, FormModalBuilder, KeyboardMode, MN_HAPTICS, MN_MODAL_ACTION_ICONS, MODAL_ACTION_ICON_SIZE, MODAL_ACTION_ICON_SIZE_SM, MnModalRef, ModalBuilder, ModalCloseReason, ModalIntent, ModalKind, ModalSize, NavigationDirection, OptionState, SelectionMode, StepBuilder, StepState, SubmitMode, ValidationCode, ValidationStatus, WizardFlowMode, WizardModalBuilder, defaultIconForStyle };
|
|
945
|
-
//# sourceMappingURL=mn-angular-lib-modal-core.mjs.map
|
|
760
|
+
//# sourceMappingURL=mn-angular-lib-modal-core.mjs.map
|