@daffodil/storefront 0.94.1-rc.0 → 0.95.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,460 +1,746 @@
1
- import * as i0 from '@angular/core';
2
- import { output, model, input, ViewChild, Optional, ChangeDetectionStrategy, Component, computed, effect, signal, viewChild, booleanAttribute, Input, Self } from '@angular/core';
3
- import * as i1 from '@angular/forms';
4
- import { UntypedFormControl, ReactiveFormsModule, Validators } from '@angular/forms';
5
- import { Subject, merge, of, map, tap } from 'rxjs';
6
- import { takeUntil } from 'rxjs/operators';
7
- import * as i2 from '@daffodil/design/form-field';
8
- import { DaffFormFieldControl } from '@daffodil/design/form-field';
9
- import { DaffInputComponent } from '@daffodil/design/input';
10
- import { coerceNumberProperty } from '@angular/cdk/coercion';
11
- import { DaffNativeSelectComponent } from '@daffodil/design/native-select';
12
-
13
- class DaffSfQuantityInputComponent {
14
- /**
15
- * @docs-private
16
- */
17
- get focused() {
18
- return this.input.focused;
19
- }
20
- get value() {
21
- return this.ngControl?.control.value || this.quantity();
22
- }
23
- set value(value) {
24
- if (value === 0 || Number.isNaN(value)) {
25
- value = this.value;
26
- }
27
- const val = Math.max(Math.min(Math.round(value), this.max()), this.min());
28
- this.ngControl?.control.patchValue(val);
29
- this._inputControl.patchValue(val);
30
- this.quantity.set(val);
31
- this.changeDetectorRef.markForCheck();
32
- }
33
- constructor(ngControl, changeDetectorRef) {
34
- this.ngControl = ngControl;
35
- this.changeDetectorRef = changeDetectorRef;
36
- /**
37
- * Event emitted when the quantity input gains focus
38
- */
39
- this.focusChange = output();
40
- /**
41
- * Event emitted when the quantity input loses focus
42
- */
43
- this.blurChange = output();
44
- /**
45
- * Event emitted when the quantity input's value changes
46
- */
47
- this.valueChange = output();
48
- this.quantity = model(...(ngDevMode ? [undefined, { debugName: "quantity" }] : /* istanbul ignore next */ []));
49
- /**
50
- * The minimum number for the quantity input field
51
- */
52
- this.min = input(1, ...(ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []));
53
- /**
54
- * The maximum number for the quantity input field
55
- */
56
- this.max = input(10, ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
57
- /**
58
- * A new control for the nested native input.
59
- * We don't bind the native input directly to the inherited form control
60
- * to avoid triggering updates on the input event.
61
- * Instead, we listen for the change event and manually patch form control values.
62
- */
63
- this._inputControl = new UntypedFormControl();
64
- this._destroyed = new Subject();
65
- }
66
- /**
67
- * @docs-private
68
- */
69
- ngOnInit() {
70
- this._inputControl.patchValue(this.ngControl?.control.value ?? this.quantity());
71
- this.setInputDisabled();
72
- this.ngControl?.statusChanges.pipe(takeUntil(this._destroyed)).subscribe((s) => {
73
- this.setInputDisabled();
74
- });
75
- }
76
- ngOnDestroy() {
77
- this._destroyed.next(true);
78
- }
79
- focus() {
80
- this.input.focus();
81
- }
82
- /**
83
- * Callback function fired when the value changes.
84
- * Used to pass the value back up to the ngControl.
85
- */
86
- onValueChange(event) {
87
- if (event.target instanceof HTMLInputElement) {
88
- this.value = event.target.valueAsNumber;
89
- }
90
- this.valueChange.emit(this.value);
91
- }
92
- setInputDisabled() {
93
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
94
- this.ngControl?.disabled
95
- ? this._inputControl.disable()
96
- : this._inputControl.enable();
97
- }
98
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffSfQuantityInputComponent, deps: [{ token: i1.NgControl, optional: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
99
- /** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.9", type: DaffSfQuantityInputComponent, isStandalone: true, selector: "daff-sf-quantity-input", inputs: { quantity: { classPropertyName: "quantity", publicName: "quantity", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { focusChange: "focusChange", blurChange: "blurChange", valueChange: "valueChange", quantity: "quantityChange" }, viewQueries: [{ propertyName: "input", first: true, predicate: DaffInputComponent, descendants: true }], ngImport: i0, template: "<input daff-input\n type=\"number\"\n [attr.max]=\"max()\"\n [attr.min]=\"min()\"\n [attr.step]=\"1\"\n (change)=\"onValueChange($event)\"\n (focus)=\"focusChange.emit()\" \n (blur)=\"blurChange.emit()\"\n [formControl]=\"_inputControl\"\n>\n", dependencies: [{ kind: "component", type: DaffInputComponent, selector: "input[daff-input]", inputs: ["disabled", "required"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
100
- }
101
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffSfQuantityInputComponent, decorators: [{
102
- type: Component,
103
- args: [{ selector: 'daff-sf-quantity-input', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
104
- DaffInputComponent,
105
- ReactiveFormsModule,
106
- ], template: "<input daff-input\n type=\"number\"\n [attr.max]=\"max()\"\n [attr.min]=\"min()\"\n [attr.step]=\"1\"\n (change)=\"onValueChange($event)\"\n (focus)=\"focusChange.emit()\" \n (blur)=\"blurChange.emit()\"\n [formControl]=\"_inputControl\"\n>\n" }]
107
- }], ctorParameters: () => [{ type: i1.NgControl, decorators: [{
108
- type: Optional
109
- }] }, { type: i0.ChangeDetectorRef }], propDecorators: { input: [{
110
- type: ViewChild,
111
- args: [DaffInputComponent]
112
- }], focusChange: [{ type: i0.Output, args: ["focusChange"] }], blurChange: [{ type: i0.Output, args: ["blurChange"] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }], quantity: [{ type: i0.Input, args: [{ isSignal: true, alias: "quantity", required: false }] }, { type: i0.Output, args: ["quantityChange"] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }] } });
113
-
114
- /**
115
- * @docs-private
116
- *
117
- * Create an array of numbers from min to max, not including max.
118
- */
119
- const makeValueArray = (min, max, increment) => Array(max - min).fill(0).map((x, i) => (i * increment) + min);
120
- class DaffSfQuantitySelectComponent {
121
- constructor() {
122
- /**
123
- * A new control for the nested native select.
124
- * We don't bind the native select directly to the inherited form control
125
- * to avoid triggering updates on the input event.
126
- * Instead, we listen for the change event and manually patch form control values.
127
- */
128
- this._selectControl = new UntypedFormControl();
129
- /**
130
- * The minimum number selectable. Defaults to 1.
131
- */
132
- this.min = input(1, ...(ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []));
133
- /**
134
- * The maximum number selectable. Defaults to 10.
135
- */
136
- this.max = input(10, ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
137
- /**
138
- * Property used to determine whether or not the select is
139
- * used in a situation where the `max` isn't a true max.
140
- */
141
- this.extendable = input(true, ...(ngDevMode ? [{ debugName: "extendable" }] : /* istanbul ignore next */ []));
142
- /**
143
- * Event emitted when the quantity select gains focus
144
- */
145
- this.focusChange = output();
146
- /**
147
- * Event emitted when the quantity select loses focus
148
- */
149
- this.blurChange = output();
150
- /**
151
- * Event emitted when the quantiy select's value changes
152
- */
153
- this.valueChange = output();
154
- this.quantity = input(...(ngDevMode ? [undefined, { debugName: "quantity" }] : /* istanbul ignore next */ []));
155
- this.disabled = input(...(ngDevMode ? [undefined, { debugName: "disabled" }] : /* istanbul ignore next */ []));
156
- /**
157
- * An input for easily making options for the `select`.
158
- */
159
- this.valueArray = computed(() => makeValueArray(this.min(), this.max(), 1), ...(ngDevMode ? [{ debugName: "valueArray" }] : /* istanbul ignore next */ []));
160
- effect(() => {
161
- const value = this.quantity();
162
- this._selectControl.patchValue(value);
163
- });
164
- effect(() => {
165
- if (this.disabled()) {
166
- this._selectControl.disable();
167
- }
168
- else {
169
- this._selectControl.enable();
170
- }
171
- });
172
- }
173
- get focused() {
174
- return this.select?.focused;
175
- }
176
- focus() {
177
- this.select?.focus();
178
- }
179
- /**
180
- * @docs-private
181
- *
182
- * Callback function fired when the value changes.
183
- * Used to pass the value back up to the ngControl.
184
- */
185
- onValueChange(event) {
186
- const val = coerceNumberProperty(event.target.value);
187
- this.valueChange.emit(val);
188
- }
189
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffSfQuantitySelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
190
- /** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.9", type: DaffSfQuantitySelectComponent, isStandalone: true, selector: "daff-sf-quantity-select", inputs: { min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, extendable: { classPropertyName: "extendable", publicName: "extendable", isSignal: true, isRequired: false, transformFunction: null }, quantity: { classPropertyName: "quantity", publicName: "quantity", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { focusChange: "focusChange", blurChange: "blurChange", valueChange: "valueChange" }, viewQueries: [{ propertyName: "select", first: true, predicate: DaffNativeSelectComponent, descendants: true }], ngImport: i0, template: "<select daff-native-select\n [formControl]=\"_selectControl\"\n (focus)=\"focusChange.emit()\" \n (blur)=\"blurChange.emit()\"\n (change)=\"onValueChange($event)\"\n>\n @for (item of valueArray(); track item) {\n <option [value]=\"item\">{{ item }}</option>\n }\n @if (extendable()) {\n <option [value]=\"max()\">{{ max() }}+</option>\n } @else {\n <option [value]=\"max()\">{{ max() }}</option>\n }\n</select>\n", dependencies: [{ kind: "component", type: DaffNativeSelectComponent, selector: "select[daff-native-select]", inputs: ["disabled", "required"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
191
- }
192
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffSfQuantitySelectComponent, decorators: [{
193
- type: Component,
194
- args: [{ selector: 'daff-sf-quantity-select', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
195
- DaffNativeSelectComponent,
196
- ReactiveFormsModule,
197
- ], template: "<select daff-native-select\n [formControl]=\"_selectControl\"\n (focus)=\"focusChange.emit()\" \n (blur)=\"blurChange.emit()\"\n (change)=\"onValueChange($event)\"\n>\n @for (item of valueArray(); track item) {\n <option [value]=\"item\">{{ item }}</option>\n }\n @if (extendable()) {\n <option [value]=\"max()\">{{ max() }}+</option>\n } @else {\n <option [value]=\"max()\">{{ max() }}</option>\n }\n</select>\n" }]
198
- }], ctorParameters: () => [], propDecorators: { select: [{
199
- type: ViewChild,
200
- args: [DaffNativeSelectComponent]
201
- }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], extendable: [{ type: i0.Input, args: [{ isSignal: true, alias: "extendable", required: false }] }], focusChange: [{ type: i0.Output, args: ["focusChange"] }], blurChange: [{ type: i0.Output, args: ["blurChange"] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }], quantity: [{ type: i0.Input, args: [{ isSignal: true, alias: "quantity", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }] } });
202
-
203
- class DaffSfQuantityFieldComponent extends DaffFormFieldControl {
204
- /** @docs-private */
205
- get controlType() {
206
- return this._showInputField() ? 'native-input' : 'native-select';
207
- }
208
- /**
209
- * @docs-private
210
- *
211
- * Implemented as part of DaffFormFieldControl.
212
- */
213
- get focused() {
214
- return this.select()?.focused || this.input()?.focused;
215
- }
216
- ;
217
- /**
218
- * @docs-private
219
- *
220
- * Implemented as part of DaffFormFieldControl.
221
- */
222
- get disabled() {
223
- return this.ngControl?.disabled ?? this._disabled;
224
- }
225
- set disabled(value) {
226
- this._disabled = value;
227
- }
228
- /**
229
- * @docs-private
230
- *
231
- * Implemented as part of DaffFormFieldControl.
232
- */
233
- get required() {
234
- return this.ngControl?.control?.hasValidator(Validators.required) ?? this._required;
235
- }
236
- set required(value) {
237
- this._required = value;
238
- }
239
- /**
240
- * @docs-private
241
- *
242
- * Returns the lesser of max and selectMax.
243
- */
244
- get _maxFloor() {
245
- return Math.min(this.max(), this.selectMax());
246
- }
247
- constructor(ngControl, cd, formField) {
248
- super(ngControl);
249
- this.ngControl = ngControl;
250
- this.cd = cd;
251
- this.formField = formField;
252
- /**
253
- * @docs-private
254
- */
255
- this.quantity = signal(1, ...(ngDevMode ? [{ debugName: "quantity" }] : /* istanbul ignore next */ []));
256
- /**
257
- * @docs-private
258
- */
259
- this._inputHasBeenShown = signal(false, ...(ngDevMode ? [{ debugName: "_inputHasBeenShown" }] : /* istanbul ignore next */ []));
260
- /**
261
- * @docs-private
262
- */
263
- this._showInputField = computed(() => {
264
- this.quantity();
265
- return this._inputHasBeenShown() || this.quantity() >= this.selectMax();
266
- }, ...(ngDevMode ? [{ debugName: "_showInputField" }] : /* istanbul ignore next */ []));
267
- /**
268
- * @docs-private
269
- */
270
- this._showSelectField = computed(() => !this._showInputField(), ...(ngDevMode ? [{ debugName: "_showSelectField" }] : /* istanbul ignore next */ []));
271
- /**
272
- * @docs-private
273
- */
274
- this.input = viewChild(DaffSfQuantityInputComponent, ...(ngDevMode ? [{ debugName: "input" }] : /* istanbul ignore next */ []));
275
- /**
276
- * @docs-private
277
- */
278
- this.select = viewChild(DaffSfQuantitySelectComponent, ...(ngDevMode ? [{ debugName: "select" }] : /* istanbul ignore next */ []));
279
- /**
280
- * The minimum valid value of the quantity field.
281
- * Must be greater than or equal to 1.
282
- */
283
- this.min = input(1, ...(ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []));
284
- /**
285
- * The maximum valid value of the quantity field.
286
- * Must be greater than `min`.
287
- */
288
- this.max = input(500, ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
289
- /**
290
- * The maximum number allowed before the field switches from a dropdown to an input.
291
- * When the value reaches this number, an input field is shown instead of a select.
292
- * Default is 10.
293
- */
294
- this.selectMax = input(10, ...(ngDevMode ? [{ debugName: "selectMax" }] : /* istanbul ignore next */ []));
295
- this._disabled = false;
296
- this._required = false;
297
- this._destroyed = new Subject();
298
- this._focusSetWhenSwitching = false;
299
- if (this.ngControl != null) {
300
- this.ngControl.valueAccessor = this;
301
- }
302
- if (!this.formField) {
303
- throw new Error('DaffSfQuantityFieldComponent needs to be used with the DaffFormFieldComponent.');
304
- }
305
- effect(() => {
306
- if (this.quantity() >= this.selectMax()) {
307
- this._inputHasBeenShown.set(true);
308
- }
309
- });
310
- effect(() => {
311
- if (this._inputHasBeenShown() && this.select()?.focused) {
312
- this._focusSetWhenSwitching = true;
313
- }
314
- if (this._focusSetWhenSwitching && this.input()) {
315
- this.input().focus();
316
- this._focusSetWhenSwitching = false;
317
- }
318
- });
319
- }
320
- /**
321
- * @docs-private
322
- */
323
- ngOnInit() {
324
- this.stateChanges = merge(this._stateChanges.asObservable(), this.ngControl ? this.ngControl.statusChanges : of(undefined)).pipe(map(() => this.state), tap((state) => this.disabled = state.disabled));
325
- if (this.ngControl?.statusChanges) {
326
- this.ngControl.statusChanges.pipe(takeUntil(this._destroyed)).subscribe(() => {
327
- this.emitState();
328
- });
329
- }
330
- if (this.ngControl?.valueChanges) {
331
- this.ngControl.valueChanges.pipe(takeUntil(this._destroyed)).subscribe((value) => {
332
- this.quantity.set(value);
333
- this.cd.markForCheck();
334
- });
335
- }
336
- }
337
- onChange(quantity) { }
338
- ;
339
- onTouched(quantity) { }
340
- ;
341
- /**
342
- * @docs-private
343
- */
344
- writeValue(quantity) {
345
- this.quantity.set(quantity);
346
- this.cd.markForCheck();
347
- }
348
- /**
349
- * @docs-private
350
- */
351
- registerOnChange(fn) {
352
- this.onChange = fn;
353
- }
354
- /**
355
- * @docs-private
356
- */
357
- registerOnTouched(fn) {
358
- this.onTouched = fn;
359
- }
360
- /**
361
- * @docs-private
362
- */
363
- setDisabledState(isDisabled) {
364
- this.disabled = isDisabled;
365
- this.cd.markForCheck();
366
- }
367
- /**
368
- * @docs-private
369
- *
370
- * Implemented as part of DaffFormFieldControl.
371
- */
372
- focus() {
373
- if (this.select()) {
374
- this.select().focus();
375
- }
376
- if (this.input()) {
377
- this.input().focus();
378
- }
379
- this.emitState();
380
- }
381
- /**
382
- * @docs-private
383
- *
384
- * Called when child components gain focus
385
- */
386
- _onChildFocus() {
387
- this.onTouched(this.value);
388
- this.emitState();
389
- }
390
- /**
391
- * @docs-private
392
- *
393
- * Called when child components lose focus
394
- */
395
- _onChildBlur() {
396
- this.onTouched(this.value);
397
- this.emitState(true);
398
- }
399
- /**
400
- * @docs-private
401
- *
402
- * Called when child components change value
403
- */
404
- _onChildValueChange(value) {
405
- this.quantity.set(value);
406
- this.onChange(value);
407
- this.cd.markForCheck();
408
- }
409
- /**
410
- * Implemented as part of DaffFormFieldControl.
411
- */
412
- get value() {
413
- return this.quantity();
414
- }
415
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffSfQuantityFieldComponent, deps: [{ token: i1.NgControl, optional: true, self: true }, { token: i0.ChangeDetectorRef }, { token: i2.DaffFormFieldComponent, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
416
- /** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.9", type: DaffSfQuantityFieldComponent, isStandalone: true, selector: "daff-sf-quantity-field", inputs: { min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, selectMax: { classPropertyName: "selectMax", publicName: "selectMax", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, required: { classPropertyName: "required", publicName: "required", isSignal: false, isRequired: false, transformFunction: booleanAttribute } }, providers: [
417
- {
418
- provide: DaffFormFieldControl,
419
- useExisting: DaffSfQuantityFieldComponent,
420
- },
421
- ], viewQueries: [{ propertyName: "input", first: true, predicate: DaffSfQuantityInputComponent, descendants: true, isSignal: true }, { propertyName: "select", first: true, predicate: DaffSfQuantitySelectComponent, descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "@if (_showSelectField()) {\n <daff-sf-quantity-select\n [min]=\"min()\"\n [max]=\"_maxFloor\"\n [quantity]=\"quantity()\"\n [disabled]=\"disabled\"\n [extendable]=\"max() > selectMax()\"\n (focusChange)=\"_onChildFocus()\"\n (blurChange)=\"_onChildBlur()\"\n (valueChange)=\"_onChildValueChange($event)\">\n </daff-sf-quantity-select>\n}\n@if (_showInputField()) {\n <daff-sf-quantity-input\n [min]=\"min()\"\n [max]=\"max()\"\n [quantity]=\"quantity()\"\n (focusChange)=\"_onChildFocus()\"\n (blurChange)=\"_onChildBlur()\"\n (valueChange)=\"_onChildValueChange($event)\">\n </daff-sf-quantity-input>\n}\n", dependencies: [{ kind: "component", type: DaffSfQuantityInputComponent, selector: "daff-sf-quantity-input", inputs: ["quantity", "min", "max"], outputs: ["focusChange", "blurChange", "valueChange", "quantityChange"] }, { kind: "component", type: DaffSfQuantitySelectComponent, selector: "daff-sf-quantity-select", inputs: ["min", "max", "extendable", "quantity", "disabled"], outputs: ["focusChange", "blurChange", "valueChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
422
- }
423
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffSfQuantityFieldComponent, decorators: [{
424
- type: Component,
425
- args: [{ selector: 'daff-sf-quantity-field', providers: [
426
- {
427
- provide: DaffFormFieldControl,
428
- useExisting: DaffSfQuantityFieldComponent,
429
- },
430
- ], changeDetection: ChangeDetectionStrategy.OnPush, imports: [
431
- DaffSfQuantityInputComponent,
432
- DaffSfQuantitySelectComponent,
433
- ], template: "@if (_showSelectField()) {\n <daff-sf-quantity-select\n [min]=\"min()\"\n [max]=\"_maxFloor\"\n [quantity]=\"quantity()\"\n [disabled]=\"disabled\"\n [extendable]=\"max() > selectMax()\"\n (focusChange)=\"_onChildFocus()\"\n (blurChange)=\"_onChildBlur()\"\n (valueChange)=\"_onChildValueChange($event)\">\n </daff-sf-quantity-select>\n}\n@if (_showInputField()) {\n <daff-sf-quantity-input\n [min]=\"min()\"\n [max]=\"max()\"\n [quantity]=\"quantity()\"\n (focusChange)=\"_onChildFocus()\"\n (blurChange)=\"_onChildBlur()\"\n (valueChange)=\"_onChildValueChange($event)\">\n </daff-sf-quantity-input>\n}\n" }]
434
- }], ctorParameters: () => [{ type: i1.NgControl, decorators: [{
435
- type: Optional
436
- }, {
437
- type: Self
438
- }] }, { type: i0.ChangeDetectorRef }, { type: i2.DaffFormFieldComponent, decorators: [{
439
- type: Optional
440
- }] }], propDecorators: { input: [{ type: i0.ViewChild, args: [i0.forwardRef(() => DaffSfQuantityInputComponent), { isSignal: true }] }], select: [{ type: i0.ViewChild, args: [i0.forwardRef(() => DaffSfQuantitySelectComponent), { isSignal: true }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], selectMax: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectMax", required: false }] }], disabled: [{
441
- type: Input,
442
- args: [{ transform: booleanAttribute }]
443
- }], required: [{
444
- type: Input,
445
- args: [{ transform: booleanAttribute }]
446
- }] } });
447
-
448
- /**
449
- * @docs-private
450
- */
451
- const DAFF_SF_QUANTITY_FIELD_COMPONENTS = [
452
- DaffSfQuantityFieldComponent,
453
- ];
454
-
455
- /**
456
- * Generated bundle index. Do not edit.
457
- */
458
-
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, Input, Optional, Self, ViewChild, booleanAttribute, computed, effect, input, model, output, signal, viewChild } from "@angular/core";
3
+ import * as i1 from "@angular/forms";
4
+ import { ReactiveFormsModule, UntypedFormControl, Validators } from "@angular/forms";
5
+ import { Subject, map, merge, of, tap } from "rxjs";
6
+ import { takeUntil } from "rxjs/operators";
7
+ import * as i2 from "@daffodil/design/form-field";
8
+ import { DaffFormFieldControl, DaffFormFieldControlTypesEnum } from "@daffodil/design/form-field";
9
+ import { DaffInputComponent } from "@daffodil/design/input";
10
+ import { coerceNumberProperty } from "@angular/cdk/coercion";
11
+ import { DaffNativeSelectComponent } from "@daffodil/design/native-select";
12
+ var DaffSfQuantityInputComponent = class DaffSfQuantityInputComponent {
13
+ get focused() {
14
+ return this.input.focused;
15
+ }
16
+ get value() {
17
+ return this.ngControl?.control.value || this.quantity();
18
+ }
19
+ set value(value) {
20
+ if (value === 0 || Number.isNaN(value)) value = this.value;
21
+ const val = Math.max(Math.min(Math.round(value), this.max()), this.min());
22
+ this.ngControl?.control.patchValue(val);
23
+ this._inputControl.patchValue(val);
24
+ this.quantity.set(val);
25
+ this.changeDetectorRef.markForCheck();
26
+ }
27
+ constructor(ngControl, changeDetectorRef) {
28
+ this.ngControl = ngControl;
29
+ this.changeDetectorRef = changeDetectorRef;
30
+ this.focusChange = output();
31
+ this.blurChange = output();
32
+ this.valueChange = output();
33
+ this.quantity = model(...ngDevMode ? [void 0, { debugName: "quantity" }] : /* istanbul ignore next */ []);
34
+ this.min = input(1, ...ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []);
35
+ this.max = input(10, ...ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []);
36
+ this._inputControl = new UntypedFormControl();
37
+ this._destroyed = new Subject();
38
+ }
39
+ ngOnInit() {
40
+ this._inputControl.patchValue(this.ngControl?.control.value ?? this.quantity());
41
+ this.setInputDisabled();
42
+ this.ngControl?.statusChanges.pipe(takeUntil(this._destroyed)).subscribe((s) => {
43
+ this.setInputDisabled();
44
+ });
45
+ }
46
+ ngOnDestroy() {
47
+ this._destroyed.next(true);
48
+ }
49
+ focus() {
50
+ this.input.focus();
51
+ }
52
+ onValueChange(event) {
53
+ if (event.target instanceof HTMLInputElement) this.value = event.target.valueAsNumber;
54
+ this.valueChange.emit(this.value);
55
+ }
56
+ setInputDisabled() {
57
+ this.ngControl?.disabled ? this._inputControl.disable() : this._inputControl.enable();
58
+ }
59
+ static {
60
+ this.ɵfac = i0.ɵɵngDeclareFactory({
61
+ minVersion: "12.0.0",
62
+ version: "22.2.4",
63
+ ngImport: i0,
64
+ type: DaffSfQuantityInputComponent,
65
+ deps: [{
66
+ token: i1.NgControl,
67
+ optional: true
68
+ }, { token: i0.ChangeDetectorRef }],
69
+ target: i0.ɵɵFactoryTarget.Component
70
+ });
71
+ }
72
+ static {
73
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
74
+ minVersion: "17.1.0",
75
+ version: "22.2.4",
76
+ type: DaffSfQuantityInputComponent,
77
+ isStandalone: true,
78
+ selector: "daff-sf-quantity-input",
79
+ inputs: {
80
+ quantity: {
81
+ classPropertyName: "quantity",
82
+ publicName: "quantity",
83
+ isSignal: true,
84
+ isRequired: false,
85
+ transformFunction: null
86
+ },
87
+ min: {
88
+ classPropertyName: "min",
89
+ publicName: "min",
90
+ isSignal: true,
91
+ isRequired: false,
92
+ transformFunction: null
93
+ },
94
+ max: {
95
+ classPropertyName: "max",
96
+ publicName: "max",
97
+ isSignal: true,
98
+ isRequired: false,
99
+ transformFunction: null
100
+ }
101
+ },
102
+ outputs: {
103
+ focusChange: "focusChange",
104
+ blurChange: "blurChange",
105
+ valueChange: "valueChange",
106
+ quantity: "quantityChange"
107
+ },
108
+ viewQueries: [{
109
+ propertyName: "input",
110
+ first: true,
111
+ predicate: DaffInputComponent,
112
+ descendants: true
113
+ }],
114
+ ngImport: i0,
115
+ template: "<input daff-input\n type=\"number\"\n [attr.max]=\"max()\"\n [attr.min]=\"min()\"\n [attr.step]=\"1\"\n (change)=\"onValueChange($event)\"\n (focus)=\"focusChange.emit()\" \n (blur)=\"blurChange.emit()\"\n [formControl]=\"_inputControl\"\n>\n",
116
+ dependencies: [
117
+ {
118
+ kind: "component",
119
+ type: DaffInputComponent,
120
+ selector: "input[daff-input]",
121
+ inputs: ["disabled", "required"]
122
+ },
123
+ {
124
+ kind: "ngmodule",
125
+ type: ReactiveFormsModule
126
+ },
127
+ {
128
+ kind: "directive",
129
+ type: i1.DefaultValueAccessor,
130
+ selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]"
131
+ },
132
+ {
133
+ kind: "directive",
134
+ type: i1.NumberValueAccessor,
135
+ selector: "input[type=number]:not([ngNoCva])[formControlName],input[type=number]:not([ngNoCva])[formControl],input[type=number]:not([ngNoCva])[ngModel]"
136
+ },
137
+ {
138
+ kind: "directive",
139
+ type: i1.NgControlStatus,
140
+ selector: "[formControlName],[ngModel],[formControl]"
141
+ },
142
+ {
143
+ kind: "directive",
144
+ type: i1.FormControlDirective,
145
+ selector: "[formControl]",
146
+ inputs: [
147
+ "formControl",
148
+ "disabled",
149
+ "ngModel"
150
+ ],
151
+ outputs: ["ngModelChange"],
152
+ exportAs: ["ngForm"]
153
+ }
154
+ ],
155
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
156
+ });
157
+ }
158
+ };
159
+ i0.ɵɵngDeclareClassMetadata({
160
+ minVersion: "12.0.0",
161
+ version: "22.2.4",
162
+ ngImport: i0,
163
+ type: DaffSfQuantityInputComponent,
164
+ decorators: [{
165
+ type: Component,
166
+ args: [{
167
+ selector: "daff-sf-quantity-input",
168
+ changeDetection: ChangeDetectionStrategy.OnPush,
169
+ imports: [DaffInputComponent, ReactiveFormsModule],
170
+ template: "<input daff-input\n type=\"number\"\n [attr.max]=\"max()\"\n [attr.min]=\"min()\"\n [attr.step]=\"1\"\n (change)=\"onValueChange($event)\"\n (focus)=\"focusChange.emit()\" \n (blur)=\"blurChange.emit()\"\n [formControl]=\"_inputControl\"\n>\n"
171
+ }]
172
+ }],
173
+ ctorParameters: () => [{
174
+ type: i1.NgControl,
175
+ decorators: [{ type: Optional }]
176
+ }, { type: i0.ChangeDetectorRef }],
177
+ propDecorators: {
178
+ input: [{
179
+ type: ViewChild,
180
+ args: [DaffInputComponent]
181
+ }],
182
+ focusChange: [{
183
+ type: i0.Output,
184
+ args: ["focusChange"]
185
+ }],
186
+ blurChange: [{
187
+ type: i0.Output,
188
+ args: ["blurChange"]
189
+ }],
190
+ valueChange: [{
191
+ type: i0.Output,
192
+ args: ["valueChange"]
193
+ }],
194
+ quantity: [{
195
+ type: i0.Input,
196
+ args: [{
197
+ isSignal: true,
198
+ alias: "quantity",
199
+ required: false
200
+ }]
201
+ }, {
202
+ type: i0.Output,
203
+ args: ["quantityChange"]
204
+ }],
205
+ min: [{
206
+ type: i0.Input,
207
+ args: [{
208
+ isSignal: true,
209
+ alias: "min",
210
+ required: false
211
+ }]
212
+ }],
213
+ max: [{
214
+ type: i0.Input,
215
+ args: [{
216
+ isSignal: true,
217
+ alias: "max",
218
+ required: false
219
+ }]
220
+ }]
221
+ }
222
+ });
223
+ const makeValueArray = (min, max, increment) => Array(max - min).fill(0).map((x, i) => i * increment + min);
224
+ var DaffSfQuantitySelectComponent = class DaffSfQuantitySelectComponent {
225
+ constructor() {
226
+ this._selectControl = new UntypedFormControl();
227
+ this.min = input(1, ...ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []);
228
+ this.max = input(10, ...ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []);
229
+ this.extendable = input(true, ...ngDevMode ? [{ debugName: "extendable" }] : /* istanbul ignore next */ []);
230
+ this.focusChange = output();
231
+ this.blurChange = output();
232
+ this.valueChange = output();
233
+ this.quantity = input(...ngDevMode ? [void 0, { debugName: "quantity" }] : /* istanbul ignore next */ []);
234
+ this.disabled = input(...ngDevMode ? [void 0, { debugName: "disabled" }] : /* istanbul ignore next */ []);
235
+ this.valueArray = computed(() => makeValueArray(this.min(), this.max(), 1), ...ngDevMode ? [{ debugName: "valueArray" }] : /* istanbul ignore next */ []);
236
+ effect(() => {
237
+ const value = this.quantity();
238
+ this._selectControl.patchValue(value);
239
+ });
240
+ effect(() => {
241
+ if (this.disabled()) this._selectControl.disable();
242
+ else this._selectControl.enable();
243
+ });
244
+ }
245
+ get focused() {
246
+ return this.select?.focused;
247
+ }
248
+ focus() {
249
+ this.select?.focus();
250
+ }
251
+ onValueChange(event) {
252
+ const val = coerceNumberProperty(event.target.value);
253
+ this.valueChange.emit(val);
254
+ }
255
+ static {
256
+ this.ɵfac = i0.ɵɵngDeclareFactory({
257
+ minVersion: "12.0.0",
258
+ version: "22.2.4",
259
+ ngImport: i0,
260
+ type: DaffSfQuantitySelectComponent,
261
+ deps: [],
262
+ target: i0.ɵɵFactoryTarget.Component
263
+ });
264
+ }
265
+ static {
266
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
267
+ minVersion: "17.0.0",
268
+ version: "22.2.4",
269
+ type: DaffSfQuantitySelectComponent,
270
+ isStandalone: true,
271
+ selector: "daff-sf-quantity-select",
272
+ inputs: {
273
+ min: {
274
+ classPropertyName: "min",
275
+ publicName: "min",
276
+ isSignal: true,
277
+ isRequired: false,
278
+ transformFunction: null
279
+ },
280
+ max: {
281
+ classPropertyName: "max",
282
+ publicName: "max",
283
+ isSignal: true,
284
+ isRequired: false,
285
+ transformFunction: null
286
+ },
287
+ extendable: {
288
+ classPropertyName: "extendable",
289
+ publicName: "extendable",
290
+ isSignal: true,
291
+ isRequired: false,
292
+ transformFunction: null
293
+ },
294
+ quantity: {
295
+ classPropertyName: "quantity",
296
+ publicName: "quantity",
297
+ isSignal: true,
298
+ isRequired: false,
299
+ transformFunction: null
300
+ },
301
+ disabled: {
302
+ classPropertyName: "disabled",
303
+ publicName: "disabled",
304
+ isSignal: true,
305
+ isRequired: false,
306
+ transformFunction: null
307
+ }
308
+ },
309
+ outputs: {
310
+ focusChange: "focusChange",
311
+ blurChange: "blurChange",
312
+ valueChange: "valueChange"
313
+ },
314
+ viewQueries: [{
315
+ propertyName: "select",
316
+ first: true,
317
+ predicate: DaffNativeSelectComponent,
318
+ descendants: true
319
+ }],
320
+ ngImport: i0,
321
+ template: "<select daff-native-select\n [formControl]=\"_selectControl\"\n (focus)=\"focusChange.emit()\" \n (blur)=\"blurChange.emit()\"\n (change)=\"onValueChange($event)\"\n>\n @for (item of valueArray(); track item) {\n <option [value]=\"item\">{{ item }}</option>\n }\n @if (extendable()) {\n <option [value]=\"max()\">{{ max() }}+</option>\n } @else {\n <option [value]=\"max()\">{{ max() }}</option>\n }\n</select>\n",
322
+ dependencies: [
323
+ {
324
+ kind: "component",
325
+ type: DaffNativeSelectComponent,
326
+ selector: "select[daff-native-select]",
327
+ inputs: ["disabled", "required"]
328
+ },
329
+ {
330
+ kind: "ngmodule",
331
+ type: ReactiveFormsModule
332
+ },
333
+ {
334
+ kind: "directive",
335
+ type: i1.NgSelectOption,
336
+ selector: "option",
337
+ inputs: ["ngValue", "value"]
338
+ },
339
+ {
340
+ kind: "directive",
341
+ type: i1.ɵNgSelectMultipleOption,
342
+ selector: "option",
343
+ inputs: ["ngValue", "value"]
344
+ },
345
+ {
346
+ kind: "directive",
347
+ type: i1.SelectControlValueAccessor,
348
+ selector: "select:not([multiple]):not([ngNoCva])[formControlName],select:not([multiple]):not([ngNoCva])[formControl],select:not([multiple]):not([ngNoCva])[ngModel]",
349
+ inputs: ["compareWith"]
350
+ },
351
+ {
352
+ kind: "directive",
353
+ type: i1.NgControlStatus,
354
+ selector: "[formControlName],[ngModel],[formControl]"
355
+ },
356
+ {
357
+ kind: "directive",
358
+ type: i1.FormControlDirective,
359
+ selector: "[formControl]",
360
+ inputs: [
361
+ "formControl",
362
+ "disabled",
363
+ "ngModel"
364
+ ],
365
+ outputs: ["ngModelChange"],
366
+ exportAs: ["ngForm"]
367
+ }
368
+ ],
369
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
370
+ });
371
+ }
372
+ };
373
+ i0.ɵɵngDeclareClassMetadata({
374
+ minVersion: "12.0.0",
375
+ version: "22.2.4",
376
+ ngImport: i0,
377
+ type: DaffSfQuantitySelectComponent,
378
+ decorators: [{
379
+ type: Component,
380
+ args: [{
381
+ selector: "daff-sf-quantity-select",
382
+ changeDetection: ChangeDetectionStrategy.OnPush,
383
+ imports: [DaffNativeSelectComponent, ReactiveFormsModule],
384
+ template: "<select daff-native-select\n [formControl]=\"_selectControl\"\n (focus)=\"focusChange.emit()\" \n (blur)=\"blurChange.emit()\"\n (change)=\"onValueChange($event)\"\n>\n @for (item of valueArray(); track item) {\n <option [value]=\"item\">{{ item }}</option>\n }\n @if (extendable()) {\n <option [value]=\"max()\">{{ max() }}+</option>\n } @else {\n <option [value]=\"max()\">{{ max() }}</option>\n }\n</select>\n"
385
+ }]
386
+ }],
387
+ ctorParameters: () => [],
388
+ propDecorators: {
389
+ select: [{
390
+ type: ViewChild,
391
+ args: [DaffNativeSelectComponent]
392
+ }],
393
+ min: [{
394
+ type: i0.Input,
395
+ args: [{
396
+ isSignal: true,
397
+ alias: "min",
398
+ required: false
399
+ }]
400
+ }],
401
+ max: [{
402
+ type: i0.Input,
403
+ args: [{
404
+ isSignal: true,
405
+ alias: "max",
406
+ required: false
407
+ }]
408
+ }],
409
+ extendable: [{
410
+ type: i0.Input,
411
+ args: [{
412
+ isSignal: true,
413
+ alias: "extendable",
414
+ required: false
415
+ }]
416
+ }],
417
+ focusChange: [{
418
+ type: i0.Output,
419
+ args: ["focusChange"]
420
+ }],
421
+ blurChange: [{
422
+ type: i0.Output,
423
+ args: ["blurChange"]
424
+ }],
425
+ valueChange: [{
426
+ type: i0.Output,
427
+ args: ["valueChange"]
428
+ }],
429
+ quantity: [{
430
+ type: i0.Input,
431
+ args: [{
432
+ isSignal: true,
433
+ alias: "quantity",
434
+ required: false
435
+ }]
436
+ }],
437
+ disabled: [{
438
+ type: i0.Input,
439
+ args: [{
440
+ isSignal: true,
441
+ alias: "disabled",
442
+ required: false
443
+ }]
444
+ }]
445
+ }
446
+ });
447
+ var DaffSfQuantityFieldComponent = class DaffSfQuantityFieldComponent extends DaffFormFieldControl {
448
+ get controlType() {
449
+ return this._showInputField() ? DaffFormFieldControlTypesEnum.Input : DaffFormFieldControlTypesEnum.Dropdown;
450
+ }
451
+ get focused() {
452
+ return this.select()?.focused || this.input()?.focused;
453
+ }
454
+ get disabled() {
455
+ return this.ngControl?.disabled ?? this._disabled;
456
+ }
457
+ set disabled(value) {
458
+ this._disabled = value;
459
+ }
460
+ get required() {
461
+ return this.ngControl?.control?.hasValidator(Validators.required) ?? this._required;
462
+ }
463
+ set required(value) {
464
+ this._required = value;
465
+ }
466
+ get _maxFloor() {
467
+ return Math.min(this.max(), this.selectMax());
468
+ }
469
+ constructor(ngControl, cd, formField) {
470
+ super(ngControl);
471
+ this.ngControl = ngControl;
472
+ this.cd = cd;
473
+ this.formField = formField;
474
+ this.quantity = signal(1, ...ngDevMode ? [{ debugName: "quantity" }] : /* istanbul ignore next */ []);
475
+ this._inputHasBeenShown = signal(false, ...ngDevMode ? [{ debugName: "_inputHasBeenShown" }] : /* istanbul ignore next */ []);
476
+ this._showInputField = computed(() => {
477
+ this.quantity();
478
+ return this._inputHasBeenShown() || this.quantity() >= this.selectMax();
479
+ }, ...ngDevMode ? [{ debugName: "_showInputField" }] : /* istanbul ignore next */ []);
480
+ this._showSelectField = computed(() => !this._showInputField(), ...ngDevMode ? [{ debugName: "_showSelectField" }] : /* istanbul ignore next */ []);
481
+ this.input = viewChild(DaffSfQuantityInputComponent, ...ngDevMode ? [{ debugName: "input" }] : /* istanbul ignore next */ []);
482
+ this.select = viewChild(DaffSfQuantitySelectComponent, ...ngDevMode ? [{ debugName: "select" }] : /* istanbul ignore next */ []);
483
+ this.min = input(1, ...ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []);
484
+ this.max = input(500, ...ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []);
485
+ this.selectMax = input(10, ...ngDevMode ? [{ debugName: "selectMax" }] : /* istanbul ignore next */ []);
486
+ this._disabled = false;
487
+ this._required = false;
488
+ this._destroyed = new Subject();
489
+ this._focusSetWhenSwitching = false;
490
+ if (this.ngControl != null) this.ngControl.valueAccessor = this;
491
+ if (!this.formField) throw new Error("DaffSfQuantityFieldComponent needs to be used with the DaffFormFieldComponent.");
492
+ effect(() => {
493
+ if (this.quantity() >= this.selectMax()) this._inputHasBeenShown.set(true);
494
+ });
495
+ effect(() => {
496
+ if (this._inputHasBeenShown() && this.select()?.focused) this._focusSetWhenSwitching = true;
497
+ if (this._focusSetWhenSwitching && this.input()) {
498
+ this.input().focus();
499
+ this._focusSetWhenSwitching = false;
500
+ }
501
+ });
502
+ }
503
+ ngOnInit() {
504
+ this.stateChanges = merge(this._stateChanges.asObservable(), this.ngControl ? this.ngControl.statusChanges : of(void 0)).pipe(map(() => this.state), tap((state) => this.disabled = state.disabled));
505
+ if (this.ngControl?.statusChanges) this.ngControl.statusChanges.pipe(takeUntil(this._destroyed)).subscribe(() => {
506
+ this.emitState();
507
+ });
508
+ if (this.ngControl?.valueChanges) this.ngControl.valueChanges.pipe(takeUntil(this._destroyed)).subscribe((value) => {
509
+ this.quantity.set(value);
510
+ this.cd.markForCheck();
511
+ });
512
+ }
513
+ onChange(quantity) {}
514
+ onTouched(quantity) {}
515
+ writeValue(quantity) {
516
+ this.quantity.set(quantity);
517
+ this.cd.markForCheck();
518
+ }
519
+ registerOnChange(fn) {
520
+ this.onChange = fn;
521
+ }
522
+ registerOnTouched(fn) {
523
+ this.onTouched = fn;
524
+ }
525
+ setDisabledState(isDisabled) {
526
+ this.disabled = isDisabled;
527
+ this.cd.markForCheck();
528
+ }
529
+ focus() {
530
+ if (this.select()) this.select().focus();
531
+ if (this.input()) this.input().focus();
532
+ this.emitState();
533
+ }
534
+ _onChildFocus() {
535
+ this.onTouched(this.value);
536
+ this.emitState();
537
+ }
538
+ _onChildBlur() {
539
+ this.onTouched(this.value);
540
+ this.emitState(true);
541
+ }
542
+ _onChildValueChange(value) {
543
+ this.quantity.set(value);
544
+ this.onChange(value);
545
+ this.cd.markForCheck();
546
+ }
547
+ get value() {
548
+ return this.quantity();
549
+ }
550
+ static {
551
+ this.ɵfac = i0.ɵɵngDeclareFactory({
552
+ minVersion: "12.0.0",
553
+ version: "22.2.4",
554
+ ngImport: i0,
555
+ type: DaffSfQuantityFieldComponent,
556
+ deps: [
557
+ {
558
+ token: i1.NgControl,
559
+ optional: true,
560
+ self: true
561
+ },
562
+ { token: i0.ChangeDetectorRef },
563
+ {
564
+ token: i2.DaffFormFieldComponent,
565
+ optional: true
566
+ }
567
+ ],
568
+ target: i0.ɵɵFactoryTarget.Component
569
+ });
570
+ }
571
+ static {
572
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
573
+ minVersion: "17.0.0",
574
+ version: "22.2.4",
575
+ type: DaffSfQuantityFieldComponent,
576
+ isStandalone: true,
577
+ selector: "daff-sf-quantity-field",
578
+ inputs: {
579
+ min: {
580
+ classPropertyName: "min",
581
+ publicName: "min",
582
+ isSignal: true,
583
+ isRequired: false,
584
+ transformFunction: null
585
+ },
586
+ max: {
587
+ classPropertyName: "max",
588
+ publicName: "max",
589
+ isSignal: true,
590
+ isRequired: false,
591
+ transformFunction: null
592
+ },
593
+ selectMax: {
594
+ classPropertyName: "selectMax",
595
+ publicName: "selectMax",
596
+ isSignal: true,
597
+ isRequired: false,
598
+ transformFunction: null
599
+ },
600
+ disabled: {
601
+ classPropertyName: "disabled",
602
+ publicName: "disabled",
603
+ isSignal: false,
604
+ isRequired: false,
605
+ transformFunction: booleanAttribute
606
+ },
607
+ required: {
608
+ classPropertyName: "required",
609
+ publicName: "required",
610
+ isSignal: false,
611
+ isRequired: false,
612
+ transformFunction: booleanAttribute
613
+ }
614
+ },
615
+ providers: [{
616
+ provide: DaffFormFieldControl,
617
+ useExisting: DaffSfQuantityFieldComponent
618
+ }],
619
+ viewQueries: [{
620
+ propertyName: "input",
621
+ first: true,
622
+ predicate: DaffSfQuantityInputComponent,
623
+ descendants: true,
624
+ isSignal: true
625
+ }, {
626
+ propertyName: "select",
627
+ first: true,
628
+ predicate: DaffSfQuantitySelectComponent,
629
+ descendants: true,
630
+ isSignal: true
631
+ }],
632
+ usesInheritance: true,
633
+ ngImport: i0,
634
+ template: "@if (_showSelectField()) {\n <daff-sf-quantity-select\n [min]=\"min()\"\n [max]=\"_maxFloor\"\n [quantity]=\"quantity()\"\n [disabled]=\"disabled\"\n [extendable]=\"max() > selectMax()\"\n (focusChange)=\"_onChildFocus()\"\n (blurChange)=\"_onChildBlur()\"\n (valueChange)=\"_onChildValueChange($event)\">\n </daff-sf-quantity-select>\n}\n@if (_showInputField()) {\n <daff-sf-quantity-input\n [min]=\"min()\"\n [max]=\"max()\"\n [quantity]=\"quantity()\"\n (focusChange)=\"_onChildFocus()\"\n (blurChange)=\"_onChildBlur()\"\n (valueChange)=\"_onChildValueChange($event)\">\n </daff-sf-quantity-input>\n}\n",
635
+ dependencies: [{
636
+ kind: "component",
637
+ type: DaffSfQuantityInputComponent,
638
+ selector: "daff-sf-quantity-input",
639
+ inputs: [
640
+ "quantity",
641
+ "min",
642
+ "max"
643
+ ],
644
+ outputs: [
645
+ "focusChange",
646
+ "blurChange",
647
+ "valueChange",
648
+ "quantityChange"
649
+ ]
650
+ }, {
651
+ kind: "component",
652
+ type: DaffSfQuantitySelectComponent,
653
+ selector: "daff-sf-quantity-select",
654
+ inputs: [
655
+ "min",
656
+ "max",
657
+ "extendable",
658
+ "quantity",
659
+ "disabled"
660
+ ],
661
+ outputs: [
662
+ "focusChange",
663
+ "blurChange",
664
+ "valueChange"
665
+ ]
666
+ }],
667
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
668
+ });
669
+ }
670
+ };
671
+ i0.ɵɵngDeclareClassMetadata({
672
+ minVersion: "12.0.0",
673
+ version: "22.2.4",
674
+ ngImport: i0,
675
+ type: DaffSfQuantityFieldComponent,
676
+ decorators: [{
677
+ type: Component,
678
+ args: [{
679
+ selector: "daff-sf-quantity-field",
680
+ providers: [{
681
+ provide: DaffFormFieldControl,
682
+ useExisting: DaffSfQuantityFieldComponent
683
+ }],
684
+ changeDetection: ChangeDetectionStrategy.OnPush,
685
+ imports: [DaffSfQuantityInputComponent, DaffSfQuantitySelectComponent],
686
+ template: "@if (_showSelectField()) {\n <daff-sf-quantity-select\n [min]=\"min()\"\n [max]=\"_maxFloor\"\n [quantity]=\"quantity()\"\n [disabled]=\"disabled\"\n [extendable]=\"max() > selectMax()\"\n (focusChange)=\"_onChildFocus()\"\n (blurChange)=\"_onChildBlur()\"\n (valueChange)=\"_onChildValueChange($event)\">\n </daff-sf-quantity-select>\n}\n@if (_showInputField()) {\n <daff-sf-quantity-input\n [min]=\"min()\"\n [max]=\"max()\"\n [quantity]=\"quantity()\"\n (focusChange)=\"_onChildFocus()\"\n (blurChange)=\"_onChildBlur()\"\n (valueChange)=\"_onChildValueChange($event)\">\n </daff-sf-quantity-input>\n}\n"
687
+ }]
688
+ }],
689
+ ctorParameters: () => [
690
+ {
691
+ type: i1.NgControl,
692
+ decorators: [{ type: Optional }, { type: Self }]
693
+ },
694
+ { type: i0.ChangeDetectorRef },
695
+ {
696
+ type: i2.DaffFormFieldComponent,
697
+ decorators: [{ type: Optional }]
698
+ }
699
+ ],
700
+ propDecorators: {
701
+ input: [{
702
+ type: i0.ViewChild,
703
+ args: [i0.forwardRef(() => DaffSfQuantityInputComponent), { isSignal: true }]
704
+ }],
705
+ select: [{
706
+ type: i0.ViewChild,
707
+ args: [i0.forwardRef(() => DaffSfQuantitySelectComponent), { isSignal: true }]
708
+ }],
709
+ min: [{
710
+ type: i0.Input,
711
+ args: [{
712
+ isSignal: true,
713
+ alias: "min",
714
+ required: false
715
+ }]
716
+ }],
717
+ max: [{
718
+ type: i0.Input,
719
+ args: [{
720
+ isSignal: true,
721
+ alias: "max",
722
+ required: false
723
+ }]
724
+ }],
725
+ selectMax: [{
726
+ type: i0.Input,
727
+ args: [{
728
+ isSignal: true,
729
+ alias: "selectMax",
730
+ required: false
731
+ }]
732
+ }],
733
+ disabled: [{
734
+ type: Input,
735
+ args: [{ transform: booleanAttribute }]
736
+ }],
737
+ required: [{
738
+ type: Input,
739
+ args: [{ transform: booleanAttribute }]
740
+ }]
741
+ }
742
+ });
743
+ const DAFF_SF_QUANTITY_FIELD_COMPONENTS = [DaffSfQuantityFieldComponent];
459
744
  export { DAFF_SF_QUANTITY_FIELD_COMPONENTS, DaffSfQuantityFieldComponent };
460
- //# sourceMappingURL=daffodil-storefront-quantity-field.mjs.map
745
+
746
+ //# sourceMappingURL=daffodil-storefront-quantity-field.mjs.map