@ng-forge/dynamic-forms-ionic 1.2.0-next.6 → 1.2.0-next.7
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/ng-forge-dynamic-forms-ionic-lazy-addon-button.mjs +75 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-addon-button.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-addon-icon.mjs +36 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-addon-icon.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-button.mjs +70 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-button.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-checkbox.mjs +67 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-checkbox.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-datepicker.mjs +195 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-datepicker.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-input.mjs +211 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-input.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-multi-checkbox.mjs +139 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-multi-checkbox.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-radio.mjs +98 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-radio.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-select.mjs +92 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-select.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-slider.mjs +76 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-slider.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-textarea.mjs +96 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-textarea.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-toggle.mjs +146 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-lazy-toggle.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-shared.mjs +83 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic-shared.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-ionic.mjs +37 -157
- package/fesm2022/ng-forge-dynamic-forms-ionic.mjs.map +1 -1
- package/package.json +55 -3
- package/types/ng-forge-dynamic-forms-ionic-lazy-addon-button.d.ts +29 -0
- package/types/ng-forge-dynamic-forms-ionic-lazy-addon-icon.d.ts +18 -0
- package/types/ng-forge-dynamic-forms-ionic-lazy-button.d.ts +119 -0
- package/types/ng-forge-dynamic-forms-ionic-lazy-checkbox.d.ts +23 -0
- package/types/ng-forge-dynamic-forms-ionic-lazy-datepicker.d.ts +39 -0
- package/types/ng-forge-dynamic-forms-ionic-lazy-input.d.ts +70 -0
- package/types/ng-forge-dynamic-forms-ionic-lazy-multi-checkbox.d.ts +28 -0
- package/types/ng-forge-dynamic-forms-ionic-lazy-radio.d.ts +25 -0
- package/types/ng-forge-dynamic-forms-ionic-lazy-select.d.ts +31 -0
- package/types/ng-forge-dynamic-forms-ionic-lazy-slider.d.ts +43 -0
- package/types/ng-forge-dynamic-forms-ionic-lazy-textarea.d.ts +28 -0
- package/types/ng-forge-dynamic-forms-ionic-lazy-toggle.d.ts +66 -0
- package/types/ng-forge-dynamic-forms-ionic-shared.d.ts +116 -0
- package/types/ng-forge-dynamic-forms-ionic.d.ts +8 -162
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { AsyncPipe } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { inject, ElementRef, input, computed, DestroyRef, signal, forwardRef, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
|
+
import { FormField } from '@angular/forms/signals';
|
|
5
|
+
import { IonInput, IonNote } from '@ionic/angular/standalone';
|
|
6
|
+
import { DynamicFormLogger } from '@ng-forge/dynamic-forms';
|
|
7
|
+
import * as i1 from '@ng-forge/dynamic-forms/integration';
|
|
8
|
+
import { injectNgForgeField, injectNgForgeAddons, NgForgeControl, DfAddonSlot, DynamicTextPipe, ADDON_PRESET_HANDLER, FIELD_SIGNAL_CONTEXT, NgForgeFieldHost, NgForgeAddons } from '@ng-forge/dynamic-forms/integration';
|
|
9
|
+
import { explicitEffect } from 'ngxtension/explicit-effect';
|
|
10
|
+
import { IONIC_CONFIG, IONIC_INPUT_TYPE_OVERRIDE, IonicInlineButtonAddonComponent, runIonicPresetAction } from '@ng-forge/dynamic-forms-ionic/shared';
|
|
11
|
+
|
|
12
|
+
class IonicInputFieldComponent {
|
|
13
|
+
elementRef = inject((ElementRef));
|
|
14
|
+
ionicConfig = inject(IONIC_CONFIG, { optional: true });
|
|
15
|
+
ngf = injectNgForgeField();
|
|
16
|
+
ngfa = injectNgForgeAddons();
|
|
17
|
+
props = input(/* @ts-ignore */
|
|
18
|
+
...(ngDevMode ? [undefined, { debugName: "props" }] : /* istanbul ignore next */ []));
|
|
19
|
+
fieldInputs = input(/* @ts-ignore */
|
|
20
|
+
...(ngDevMode ? [undefined, { debugName: "fieldInputs" }] : /* istanbul ignore next */ []));
|
|
21
|
+
typeOverride = inject(IONIC_INPUT_TYPE_OVERRIDE);
|
|
22
|
+
fill = computed(() => this.props()?.fill ?? this.ionicConfig?.fill ?? 'solid', /* @ts-ignore */
|
|
23
|
+
...(ngDevMode ? [{ debugName: "fill" }] : /* istanbul ignore next */ []));
|
|
24
|
+
shape = computed(() => this.props()?.shape ?? this.ionicConfig?.shape, /* @ts-ignore */
|
|
25
|
+
...(ngDevMode ? [{ debugName: "shape" }] : /* istanbul ignore next */ []));
|
|
26
|
+
labelPlacement = computed(() => this.props()?.labelPlacement ?? this.ionicConfig?.labelPlacement ?? 'stacked', /* @ts-ignore */
|
|
27
|
+
...(ngDevMode ? [{ debugName: "labelPlacement" }] : /* istanbul ignore next */ []));
|
|
28
|
+
color = computed(() => this.props()?.color ?? this.ionicConfig?.color, /* @ts-ignore */
|
|
29
|
+
...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
|
|
30
|
+
type = computed(() => this.typeOverride() ?? this.props()?.type ?? 'text', /* @ts-ignore */
|
|
31
|
+
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
32
|
+
buttonPrefixAddons = computed(() => this.ngfa.prefixAddons().filter((a) => a.type === 'ion-button'), /* @ts-ignore */
|
|
33
|
+
...(ngDevMode ? [{ debugName: "buttonPrefixAddons" }] : /* istanbul ignore next */ []));
|
|
34
|
+
buttonSuffixAddons = computed(() => this.ngfa.suffixAddons().filter((a) => a.type === 'ion-button'), /* @ts-ignore */
|
|
35
|
+
...(ngDevMode ? [{ debugName: "buttonSuffixAddons" }] : /* istanbul ignore next */ []));
|
|
36
|
+
decorativePrefixAddons = computed(() => this.ngfa.prefixAddons().filter((a) => a.type !== 'ion-button'), /* @ts-ignore */
|
|
37
|
+
...(ngDevMode ? [{ debugName: "decorativePrefixAddons" }] : /* istanbul ignore next */ []));
|
|
38
|
+
decorativeSuffixAddons = computed(() => this.ngfa.suffixAddons().filter((a) => a.type !== 'ion-button'), /* @ts-ignore */
|
|
39
|
+
...(ngDevMode ? [{ debugName: "decorativeSuffixAddons" }] : /* istanbul ignore next */ []));
|
|
40
|
+
destroyed = false;
|
|
41
|
+
constructor() {
|
|
42
|
+
inject(DestroyRef).onDestroy(() => (this.destroyed = true));
|
|
43
|
+
explicitEffect([this.ngf.ariaDescribedBy], ([describedBy]) => {
|
|
44
|
+
queueMicrotask(() => {
|
|
45
|
+
if (this.destroyed)
|
|
46
|
+
return;
|
|
47
|
+
const ionInput = this.elementRef.nativeElement.querySelector('ion-input');
|
|
48
|
+
if (ionInput?.getInputElement) {
|
|
49
|
+
ionInput.getInputElement().then((inputEl) => {
|
|
50
|
+
if (this.destroyed || !inputEl)
|
|
51
|
+
return;
|
|
52
|
+
if (describedBy) {
|
|
53
|
+
inputEl.setAttribute('aria-describedby', describedBy);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
inputEl.removeAttribute('aria-describedby');
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: IonicInputFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
64
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.1", type: IonicInputFieldComponent, isStandalone: true, selector: "df-ion-input", inputs: { props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null }, fieldInputs: { classPropertyName: "fieldInputs", publicName: "fieldInputs", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
|
|
65
|
+
{
|
|
66
|
+
provide: IONIC_INPUT_TYPE_OVERRIDE,
|
|
67
|
+
useFactory: () => signal(undefined),
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
provide: ADDON_PRESET_HANDLER,
|
|
71
|
+
useFactory: () => {
|
|
72
|
+
const typeOverride = inject(IONIC_INPUT_TYPE_OVERRIDE);
|
|
73
|
+
const fsc = inject(FIELD_SIGNAL_CONTEXT, { optional: true });
|
|
74
|
+
const logger = inject(DynamicFormLogger);
|
|
75
|
+
const host = inject(forwardRef(() => IonicInputFieldComponent));
|
|
76
|
+
return {
|
|
77
|
+
run: (preset, ctx) => {
|
|
78
|
+
const fieldKey = ctx.field.key;
|
|
79
|
+
return runIonicPresetAction(preset, ctx, {
|
|
80
|
+
typeOverride,
|
|
81
|
+
fieldValueSetter: ctx.setValue,
|
|
82
|
+
fieldDefaultValueGetter: fsc && fieldKey ? () => fsc.defaultValues()?.[fieldKey] : undefined,
|
|
83
|
+
baselineType: () => host.props()?.type,
|
|
84
|
+
logger,
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
], hostDirectives: [{ directive: i1.NgForgeFieldHost }, { directive: i1.NgForgeAddons }], ngImport: i0, template: `
|
|
91
|
+
@let f = ngf.field();
|
|
92
|
+
@let inputId = ngf.key() + '-input';
|
|
93
|
+
|
|
94
|
+
<ion-input
|
|
95
|
+
ngForgeControl
|
|
96
|
+
[id]="inputId"
|
|
97
|
+
[type]="type()"
|
|
98
|
+
[formField]="f"
|
|
99
|
+
[label]="(ngf.label() | dynamicText | async) ?? undefined"
|
|
100
|
+
[labelPlacement]="labelPlacement()"
|
|
101
|
+
[placeholder]="(ngf.placeholder() | dynamicText | async) ?? ''"
|
|
102
|
+
[clearInput]="props()?.clearInput ?? false"
|
|
103
|
+
[counter]="props()?.counter ?? false"
|
|
104
|
+
[minlength]="f().minLength?.()"
|
|
105
|
+
[maxlength]="f().maxLength?.()"
|
|
106
|
+
[color]="color()"
|
|
107
|
+
[fill]="fill()"
|
|
108
|
+
[shape]="shape()"
|
|
109
|
+
[readonly]="f().readonly()"
|
|
110
|
+
[helperText]="ngf.errorsToDisplay().length === 0 ? ((props()?.hint | dynamicText | async) ?? undefined) : undefined"
|
|
111
|
+
[attr.tabindex]="ngf.tabIndex()"
|
|
112
|
+
>
|
|
113
|
+
@for (a of decorativePrefixAddons(); track $index) {
|
|
114
|
+
<span slot="start">
|
|
115
|
+
<df-addon-slot [addon]="a" [fieldInputs]="fieldInputs()" [hidden]="ngfa.hiddenSignalCache().get(a)" />
|
|
116
|
+
</span>
|
|
117
|
+
}
|
|
118
|
+
@for (a of buttonPrefixAddons(); track $index) {
|
|
119
|
+
<ion-button df-ion-button-addon slot="start" [addon]="a" [fieldInputs]="fieldInputs()"></ion-button>
|
|
120
|
+
}
|
|
121
|
+
@for (a of buttonSuffixAddons(); track $index) {
|
|
122
|
+
<ion-button df-ion-button-addon slot="end" [addon]="a" [fieldInputs]="fieldInputs()"></ion-button>
|
|
123
|
+
}
|
|
124
|
+
@for (a of decorativeSuffixAddons(); track $index) {
|
|
125
|
+
<span slot="end">
|
|
126
|
+
<df-addon-slot [addon]="a" [fieldInputs]="fieldInputs()" [hidden]="ngfa.hiddenSignalCache().get(a)" />
|
|
127
|
+
</span>
|
|
128
|
+
}
|
|
129
|
+
</ion-input>
|
|
130
|
+
@if (ngf.errorsToDisplay()[0]; as error) {
|
|
131
|
+
<ion-note color="danger" class="df-ion-error" [id]="ngf.errorId()" role="alert">{{ error.message }}</ion-note>
|
|
132
|
+
}
|
|
133
|
+
`, isInline: true, styles: [".df-ion-field{display:flex;flex-direction:column;gap:var(--df-field-gap, .5rem);width:100%}.df-ion-label{font-weight:var(--df-label-font-weight, 500);color:var(--df-label-color, inherit)}.df-ion-hint{display:block;color:var(--df-hint-color, var(--ion-color-medium, #92949c));font-size:var(--df-hint-font-size, .875rem)}.df-ion-error{display:block;color:var(--df-error-color, var(--ion-color-danger, #eb445a));font-size:var(--df-error-font-size, .875rem)}:host([hidden]){display:none!important}\n", ":host([hidden]){display:none!important}:host{--df-ion-addon-prefix-outer-padding: 0;--df-ion-addon-prefix-inner-padding: .5rem;--df-ion-addon-suffix-inner-padding: .5rem;--df-ion-addon-suffix-outer-padding: 0}:host ::ng-deep ion-input [slot=start],:host ::ng-deep ion-input [slot=end]{display:inline-flex;align-items:center;align-self:center;line-height:1}:host ::ng-deep ion-input [slot=start] df-addon-slot,:host ::ng-deep ion-input [slot=end] df-addon-slot,:host ::ng-deep ion-input [slot=start] df-ion-icon-addon,:host ::ng-deep ion-input [slot=end] df-ion-icon-addon{display:inline-flex;align-items:center;line-height:1}:host ::ng-deep ion-input [slot=start]{padding-inline-start:var(--df-ion-addon-prefix-outer-padding);padding-inline-end:var(--df-ion-addon-prefix-inner-padding)}:host ::ng-deep ion-input [slot=end]{padding-inline-start:var(--df-ion-addon-suffix-inner-padding);padding-inline-end:var(--df-ion-addon-suffix-outer-padding)}:host ::ng-deep ion-input ion-icon{color:inherit}\n"], dependencies: [{ kind: "component", type: IonInput, selector: "ion-input", inputs: ["accept", "autocapitalize", "autocomplete", "autocorrect", "autofocus", "clearInput", "clearOnEdit", "color", "counter", "counterFormatter", "debounce", "disabled", "enterkeyhint", "errorText", "fill", "helperText", "inputmode", "label", "labelPlacement", "max", "maxlength", "min", "minlength", "mode", "multiple", "name", "pattern", "placeholder", "readonly", "required", "shape", "size", "spellcheck", "step", "type", "value"] }, { kind: "component", type: IonNote, selector: "ion-note", inputs: ["color", "mode"] }, { kind: "directive", type: FormField, selector: "[formField]", inputs: ["formField"], exportAs: ["formField"] }, { kind: "directive", type: NgForgeControl, selector: "[ngForgeControl]", inputs: ["ngForgeControl"] }, { kind: "component", type: DfAddonSlot, selector: "df-addon-slot", inputs: ["addon", "fieldInputs", "hidden"] }, { kind: "component", type: IonicInlineButtonAddonComponent, selector: "ion-button[df-ion-button-addon]" }, { kind: "pipe", type: DynamicTextPipe, name: "dynamicText" }, { kind: "pipe", type: AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
134
|
+
}
|
|
135
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: IonicInputFieldComponent, decorators: [{
|
|
136
|
+
type: Component,
|
|
137
|
+
args: [{ selector: 'df-ion-input', imports: [IonInput, IonNote, FormField, DynamicTextPipe, AsyncPipe, NgForgeControl, DfAddonSlot, IonicInlineButtonAddonComponent], hostDirectives: [NgForgeFieldHost, NgForgeAddons], template: `
|
|
138
|
+
@let f = ngf.field();
|
|
139
|
+
@let inputId = ngf.key() + '-input';
|
|
140
|
+
|
|
141
|
+
<ion-input
|
|
142
|
+
ngForgeControl
|
|
143
|
+
[id]="inputId"
|
|
144
|
+
[type]="type()"
|
|
145
|
+
[formField]="f"
|
|
146
|
+
[label]="(ngf.label() | dynamicText | async) ?? undefined"
|
|
147
|
+
[labelPlacement]="labelPlacement()"
|
|
148
|
+
[placeholder]="(ngf.placeholder() | dynamicText | async) ?? ''"
|
|
149
|
+
[clearInput]="props()?.clearInput ?? false"
|
|
150
|
+
[counter]="props()?.counter ?? false"
|
|
151
|
+
[minlength]="f().minLength?.()"
|
|
152
|
+
[maxlength]="f().maxLength?.()"
|
|
153
|
+
[color]="color()"
|
|
154
|
+
[fill]="fill()"
|
|
155
|
+
[shape]="shape()"
|
|
156
|
+
[readonly]="f().readonly()"
|
|
157
|
+
[helperText]="ngf.errorsToDisplay().length === 0 ? ((props()?.hint | dynamicText | async) ?? undefined) : undefined"
|
|
158
|
+
[attr.tabindex]="ngf.tabIndex()"
|
|
159
|
+
>
|
|
160
|
+
@for (a of decorativePrefixAddons(); track $index) {
|
|
161
|
+
<span slot="start">
|
|
162
|
+
<df-addon-slot [addon]="a" [fieldInputs]="fieldInputs()" [hidden]="ngfa.hiddenSignalCache().get(a)" />
|
|
163
|
+
</span>
|
|
164
|
+
}
|
|
165
|
+
@for (a of buttonPrefixAddons(); track $index) {
|
|
166
|
+
<ion-button df-ion-button-addon slot="start" [addon]="a" [fieldInputs]="fieldInputs()"></ion-button>
|
|
167
|
+
}
|
|
168
|
+
@for (a of buttonSuffixAddons(); track $index) {
|
|
169
|
+
<ion-button df-ion-button-addon slot="end" [addon]="a" [fieldInputs]="fieldInputs()"></ion-button>
|
|
170
|
+
}
|
|
171
|
+
@for (a of decorativeSuffixAddons(); track $index) {
|
|
172
|
+
<span slot="end">
|
|
173
|
+
<df-addon-slot [addon]="a" [fieldInputs]="fieldInputs()" [hidden]="ngfa.hiddenSignalCache().get(a)" />
|
|
174
|
+
</span>
|
|
175
|
+
}
|
|
176
|
+
</ion-input>
|
|
177
|
+
@if (ngf.errorsToDisplay()[0]; as error) {
|
|
178
|
+
<ion-note color="danger" class="df-ion-error" [id]="ngf.errorId()" role="alert">{{ error.message }}</ion-note>
|
|
179
|
+
}
|
|
180
|
+
`, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
181
|
+
{
|
|
182
|
+
provide: IONIC_INPUT_TYPE_OVERRIDE,
|
|
183
|
+
useFactory: () => signal(undefined),
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
provide: ADDON_PRESET_HANDLER,
|
|
187
|
+
useFactory: () => {
|
|
188
|
+
const typeOverride = inject(IONIC_INPUT_TYPE_OVERRIDE);
|
|
189
|
+
const fsc = inject(FIELD_SIGNAL_CONTEXT, { optional: true });
|
|
190
|
+
const logger = inject(DynamicFormLogger);
|
|
191
|
+
const host = inject(forwardRef(() => IonicInputFieldComponent));
|
|
192
|
+
return {
|
|
193
|
+
run: (preset, ctx) => {
|
|
194
|
+
const fieldKey = ctx.field.key;
|
|
195
|
+
return runIonicPresetAction(preset, ctx, {
|
|
196
|
+
typeOverride,
|
|
197
|
+
fieldValueSetter: ctx.setValue,
|
|
198
|
+
fieldDefaultValueGetter: fsc && fieldKey ? () => fsc.defaultValues()?.[fieldKey] : undefined,
|
|
199
|
+
baselineType: () => host.props()?.type,
|
|
200
|
+
logger,
|
|
201
|
+
});
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
], styles: [".df-ion-field{display:flex;flex-direction:column;gap:var(--df-field-gap, .5rem);width:100%}.df-ion-label{font-weight:var(--df-label-font-weight, 500);color:var(--df-label-color, inherit)}.df-ion-hint{display:block;color:var(--df-hint-color, var(--ion-color-medium, #92949c));font-size:var(--df-hint-font-size, .875rem)}.df-ion-error{display:block;color:var(--df-error-color, var(--ion-color-danger, #eb445a));font-size:var(--df-error-font-size, .875rem)}:host([hidden]){display:none!important}\n", ":host([hidden]){display:none!important}:host{--df-ion-addon-prefix-outer-padding: 0;--df-ion-addon-prefix-inner-padding: .5rem;--df-ion-addon-suffix-inner-padding: .5rem;--df-ion-addon-suffix-outer-padding: 0}:host ::ng-deep ion-input [slot=start],:host ::ng-deep ion-input [slot=end]{display:inline-flex;align-items:center;align-self:center;line-height:1}:host ::ng-deep ion-input [slot=start] df-addon-slot,:host ::ng-deep ion-input [slot=end] df-addon-slot,:host ::ng-deep ion-input [slot=start] df-ion-icon-addon,:host ::ng-deep ion-input [slot=end] df-ion-icon-addon{display:inline-flex;align-items:center;line-height:1}:host ::ng-deep ion-input [slot=start]{padding-inline-start:var(--df-ion-addon-prefix-outer-padding);padding-inline-end:var(--df-ion-addon-prefix-inner-padding)}:host ::ng-deep ion-input [slot=end]{padding-inline-start:var(--df-ion-addon-suffix-inner-padding);padding-inline-end:var(--df-ion-addon-suffix-outer-padding)}:host ::ng-deep ion-input ion-icon{color:inherit}\n"] }]
|
|
207
|
+
}], ctorParameters: () => [], propDecorators: { props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }], fieldInputs: [{ type: i0.Input, args: [{ isSignal: true, alias: "fieldInputs", required: false }] }] } });
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
export { IonicInputFieldComponent };
|
|
211
|
+
//# sourceMappingURL=ng-forge-dynamic-forms-ionic-lazy-input.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-forge-dynamic-forms-ionic-lazy-input.mjs","mappings":";;;;;;;;;;;AAgKc;AACK;;;;AAMR;;AAET,IAKS;;IAGQ;AAEE;;AACA;;IAEA;;AACA;;IAGA;;AAEnB;;;;;;;;;AAaA;AACE;wBAIA;;;;AAGI;AACA;;AAEI;;;AAEE;;;AAEA;;AAEJ;;AAEJ;AACF;;;AA7DiB;AA7EjB;AACE;AACA;AACD;AACD;gFAME;;AAEE;AACA;AACA;oBAEA;;AAEE;AACE;AACA;;;;;;AAOC;;;;AAIR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAnCF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIC;AACE;AACA;AACD;AACD;4IAME;;AAEE;AACA;AACA;;;AAIE;AACE;AACA;;;;;;AAOC;;;;AAIR;AACF","names":[],"ignoreList":[],"sources":["../../../../packages/dynamic-forms-ionic/src/lib/fields/input/ionic-input.component.ts"],"sourcesContent":["import { AsyncPipe } from '@angular/common';\nimport { ChangeDetectionStrategy, Component, computed, DestroyRef, ElementRef, forwardRef, inject, input, signal } from '@angular/core';\nimport { FormField } from '@angular/forms/signals';\nimport { IonInput, IonNote } from '@ionic/angular/standalone';\nimport { AddonActionContext, AddonActionPreset, DynamicFormLogger } from '@ng-forge/dynamic-forms';\nimport { DfAddonSlot } from '@ng-forge/dynamic-forms/integration';\nimport { WrapperFieldInputs } from '@ng-forge/dynamic-forms/integration';\nimport { DynamicTextPipe, FIELD_SIGNAL_CONTEXT } from '@ng-forge/dynamic-forms/integration';\nimport {\n ADDON_PRESET_HANDLER,\n AddonPresetHandler,\n injectNgForgeAddons,\n injectNgForgeField,\n NgForgeAddons,\n NgForgeControl,\n NgForgeFieldHost,\n} from '@ng-forge/dynamic-forms/integration';\nimport { explicitEffect } from 'ngxtension/explicit-effect';\nimport {\n IONIC_CONFIG,\n IONIC_INPUT_TYPE_OVERRIDE,\n IonicInlineButtonAddonComponent,\n runIonicPresetAction,\n} from '@ng-forge/dynamic-forms-ionic/shared';\nimport { IonicInputAddon, IonicInputProps } from './ionic-input.type';\n\n// minlength/maxlength bindings: Signal Forms auto-syncs these on NATIVE\n// inputs; <ion-input> is a Stencil web component so we bind directly from\n// FieldState (`f().maxLength?.()` — the signal itself is missing when no\n// validator is configured).\n@Component({\n selector: 'df-ion-input',\n // IonButton intentionally NOT imported — it would collide with\n // IonicInlineButtonAddonComponent on `<ion-button>` (NG0300).\n imports: [IonInput, IonNote, FormField, DynamicTextPipe, AsyncPipe, NgForgeControl, DfAddonSlot, IonicInlineButtonAddonComponent],\n hostDirectives: [NgForgeFieldHost, NgForgeAddons],\n template: `\n @let f = ngf.field();\n @let inputId = ngf.key() + '-input';\n\n <ion-input\n ngForgeControl\n [id]=\"inputId\"\n [type]=\"type()\"\n [formField]=\"f\"\n [label]=\"(ngf.label() | dynamicText | async) ?? undefined\"\n [labelPlacement]=\"labelPlacement()\"\n [placeholder]=\"(ngf.placeholder() | dynamicText | async) ?? ''\"\n [clearInput]=\"props()?.clearInput ?? false\"\n [counter]=\"props()?.counter ?? false\"\n [minlength]=\"f().minLength?.()\"\n [maxlength]=\"f().maxLength?.()\"\n [color]=\"color()\"\n [fill]=\"fill()\"\n [shape]=\"shape()\"\n [readonly]=\"f().readonly()\"\n [helperText]=\"ngf.errorsToDisplay().length === 0 ? ((props()?.hint | dynamicText | async) ?? undefined) : undefined\"\n [attr.tabindex]=\"ngf.tabIndex()\"\n >\n @for (a of decorativePrefixAddons(); track $index) {\n <span slot=\"start\">\n <df-addon-slot [addon]=\"a\" [fieldInputs]=\"fieldInputs()\" [hidden]=\"ngfa.hiddenSignalCache().get(a)\" />\n </span>\n }\n @for (a of buttonPrefixAddons(); track $index) {\n <ion-button df-ion-button-addon slot=\"start\" [addon]=\"a\" [fieldInputs]=\"fieldInputs()\"></ion-button>\n }\n @for (a of buttonSuffixAddons(); track $index) {\n <ion-button df-ion-button-addon slot=\"end\" [addon]=\"a\" [fieldInputs]=\"fieldInputs()\"></ion-button>\n }\n @for (a of decorativeSuffixAddons(); track $index) {\n <span slot=\"end\">\n <df-addon-slot [addon]=\"a\" [fieldInputs]=\"fieldInputs()\" [hidden]=\"ngfa.hiddenSignalCache().get(a)\" />\n </span>\n }\n </ion-input>\n @if (ngf.errorsToDisplay()[0]; as error) {\n <ion-note color=\"danger\" class=\"df-ion-error\" [id]=\"ngf.errorId()\" role=\"alert\">{{ error.message }}</ion-note>\n }\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n styleUrl: '../../styles/_form-field.scss',\n providers: [\n {\n provide: IONIC_INPUT_TYPE_OVERRIDE,\n useFactory: () => signal<string | undefined>(undefined),\n },\n {\n // Adapter-specific preset semantics for `ion-button` addons (clear /\n // reset / paste / copy / toggle-password-visibility). The directive\n // (`NgForgeAddonAction`) delegates here when an addon configures a\n // `preset`. Per-ion-input-instance so the `typeOverride` signal is\n // scoped to one field.\n provide: ADDON_PRESET_HANDLER,\n useFactory: (): AddonPresetHandler => {\n const typeOverride = inject(IONIC_INPUT_TYPE_OVERRIDE);\n const fsc = inject(FIELD_SIGNAL_CONTEXT, { optional: true });\n const logger = inject(DynamicFormLogger);\n // forwardRef for baselineType only — host.props()?.type gates toggle-password-visibility.\n const host = inject(forwardRef(() => IonicInputFieldComponent));\n return {\n run: (preset: string, ctx: AddonActionContext) => {\n const fieldKey = ctx.field.key;\n return runIonicPresetAction(preset as AddonActionPreset, ctx, {\n typeOverride,\n fieldValueSetter: ctx.setValue,\n fieldDefaultValueGetter:\n fsc && fieldKey ? () => (fsc.defaultValues() as Record<string, unknown> | undefined)?.[fieldKey] : undefined,\n baselineType: () => host.props()?.type,\n logger,\n });\n },\n };\n },\n },\n ],\n styles: [\n `\n :host([hidden]) {\n display: none !important;\n }\n /* Per-side padding knobs on each slot wrapper (independent prefix/suffix). */\n :host {\n --df-ion-addon-prefix-outer-padding: 0;\n --df-ion-addon-prefix-inner-padding: 0.5rem;\n --df-ion-addon-suffix-inner-padding: 0.5rem;\n --df-ion-addon-suffix-outer-padding: 0;\n }\n /* inline-flex on slot wrappers prevents baseline-pinning of decorative addon glyphs. */\n :host ::ng-deep ion-input [slot='start'],\n :host ::ng-deep ion-input [slot='end'] {\n display: inline-flex;\n align-items: center;\n align-self: center;\n line-height: 1;\n }\n :host ::ng-deep ion-input [slot='start'] df-addon-slot,\n :host ::ng-deep ion-input [slot='end'] df-addon-slot,\n :host ::ng-deep ion-input [slot='start'] df-ion-icon-addon,\n :host ::ng-deep ion-input [slot='end'] df-ion-icon-addon {\n display: inline-flex;\n align-items: center;\n line-height: 1;\n }\n :host ::ng-deep ion-input [slot='start'] {\n padding-inline-start: var(--df-ion-addon-prefix-outer-padding);\n padding-inline-end: var(--df-ion-addon-prefix-inner-padding);\n }\n :host ::ng-deep ion-input [slot='end'] {\n padding-inline-start: var(--df-ion-addon-suffix-inner-padding);\n padding-inline-end: var(--df-ion-addon-suffix-outer-padding);\n }\n /* Inherit input text color so icons stay readable on dark themes\n (Ionic's default \"medium\" greys out and fails WCAG on dark inputs). */\n :host ::ng-deep ion-input ion-icon {\n color: inherit;\n }\n `,\n ],\n})\nexport default class IonicInputFieldComponent {\n private readonly elementRef = inject(ElementRef<HTMLElement>);\n private ionicConfig = inject(IONIC_CONFIG, { optional: true });\n\n protected readonly ngf = injectNgForgeField<string>();\n protected readonly ngfa = injectNgForgeAddons<IonicInputAddon>();\n\n readonly props = input<IonicInputProps>();\n\n /**\n * Wrapper-style host bag pushed by `DfFieldOutlet`. Declared at the\n * component level so `setInputIfDeclared` (which uses\n * `reflectComponentType`) can write it.\n */\n readonly fieldInputs = input<WrapperFieldInputs | undefined>();\n\n /** Per-instance type override populated by `toggle-password-visibility` preset. */\n private readonly typeOverride = inject(IONIC_INPUT_TYPE_OVERRIDE);\n\n protected readonly fill = computed(() => this.props()?.fill ?? this.ionicConfig?.fill ?? 'solid');\n protected readonly shape = computed(() => this.props()?.shape ?? this.ionicConfig?.shape);\n /** Bootstrap / PrimeNG. Consumers can opt into Ionic's native inline 'start' */\n protected readonly labelPlacement = computed(() => this.props()?.labelPlacement ?? this.ionicConfig?.labelPlacement ?? 'stacked');\n protected readonly color = computed(() => this.props()?.color ?? this.ionicConfig?.color);\n\n /** Override (set by `toggle-password-visibility` preset) wins over `props().type`. */\n protected readonly type = computed(() => this.typeOverride() ?? this.props()?.type ?? 'text');\n\n /** Per-type split: ion-button addons render inline via the attribute-\n * selector inline component (so the slotted element is a native\n * <ion-button> Ionic can style); everything else (icon/text/template/\n * component types) goes through the universal <df-addon-slot> dispatcher\n * wrapped in <span slot=\"start|end\"> for safe shadow-DOM projection. */\n protected readonly buttonPrefixAddons = computed(() => this.ngfa.prefixAddons().filter((a) => a.type === 'ion-button'));\n protected readonly buttonSuffixAddons = computed(() => this.ngfa.suffixAddons().filter((a) => a.type === 'ion-button'));\n protected readonly decorativePrefixAddons = computed(() => this.ngfa.prefixAddons().filter((a) => a.type !== 'ion-button'));\n protected readonly decorativeSuffixAddons = computed(() => this.ngfa.suffixAddons().filter((a) => a.type !== 'ion-button'));\n\n /** Set when the component is destroyed — guards async aria-describedby sync against teardown. */\n private destroyed = false;\n\n constructor() {\n inject(DestroyRef).onDestroy(() => (this.destroyed = true));\n // ion-input encapsulates a native <input> in shadow DOM and does not automatically\n // propagate aria-describedby to it. This effect imperatively syncs the attribute\n // after a microtask to ensure Ionic has resolved the internal element.\n explicitEffect([this.ngf.ariaDescribedBy], ([describedBy]) => {\n queueMicrotask(() => {\n if (this.destroyed) return;\n const ionInput = this.elementRef.nativeElement.querySelector('ion-input') as HTMLIonInputElement | null;\n if (ionInput?.getInputElement) {\n ionInput.getInputElement().then((inputEl) => {\n if (this.destroyed || !inputEl) return;\n if (describedBy) {\n inputEl.setAttribute('aria-describedby', describedBy);\n } else {\n inputEl.removeAttribute('aria-describedby');\n }\n });\n }\n });\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, linkedSignal, computed, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { IonCheckbox, IonItem, IonNote } from '@ionic/angular/standalone';
|
|
4
|
+
import * as i1 from '@ng-forge/dynamic-forms/integration';
|
|
5
|
+
import { injectNgForgeField, isEqual, NgForgeControl, DynamicTextPipe, NgForgeFieldHost } from '@ng-forge/dynamic-forms/integration';
|
|
6
|
+
import { explicitEffect } from 'ngxtension/explicit-effect';
|
|
7
|
+
import { AsyncPipe } from '@angular/common';
|
|
8
|
+
|
|
9
|
+
class IonicMultiCheckboxFieldComponent {
|
|
10
|
+
ngf = injectNgForgeField();
|
|
11
|
+
options = input([], /* @ts-ignore */
|
|
12
|
+
...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
|
|
13
|
+
props = input(/* @ts-ignore */
|
|
14
|
+
...(ngDevMode ? [undefined, { debugName: "props" }] : /* istanbul ignore next */ []));
|
|
15
|
+
valueViewModel = linkedSignal(() => {
|
|
16
|
+
const currentValues = this.ngf.field()().value();
|
|
17
|
+
return this.options().filter((option) => currentValues.includes(option.value));
|
|
18
|
+
}, { ...(ngDevMode ? { debugName: "valueViewModel" } : /* istanbul ignore next */ {}), equal: isEqual });
|
|
19
|
+
checkedValuesMap = computed(() => {
|
|
20
|
+
const map = {};
|
|
21
|
+
for (const opt of this.valueViewModel()) {
|
|
22
|
+
map[String(opt.value)] = true;
|
|
23
|
+
}
|
|
24
|
+
return map;
|
|
25
|
+
}, /* @ts-ignore */
|
|
26
|
+
...(ngDevMode ? [{ debugName: "checkedValuesMap" }] : /* istanbul ignore next */ []));
|
|
27
|
+
constructor() {
|
|
28
|
+
explicitEffect([this.valueViewModel], ([selectedOptions]) => {
|
|
29
|
+
const selectedValues = selectedOptions.map((option) => option.value);
|
|
30
|
+
if (!isEqual(selectedValues, this.ngf.field()().value())) {
|
|
31
|
+
this.ngf.field()().value.set(selectedValues);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
explicitEffect([this.options], ([options]) => {
|
|
35
|
+
const values = options.map((option) => option.value);
|
|
36
|
+
const uniqueValues = new Set(values);
|
|
37
|
+
if (values.length !== uniqueValues.size) {
|
|
38
|
+
const duplicates = values.filter((value, index) => values.indexOf(value) !== index);
|
|
39
|
+
throw new Error(`Duplicate option values detected in ionic-multi-checkbox: ${duplicates.join(', ')}`);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
onCheckboxChange(option, checked) {
|
|
44
|
+
this.valueViewModel.update((currentOptions) => {
|
|
45
|
+
if (checked) {
|
|
46
|
+
return currentOptions.some((opt) => opt.value === option.value) ? currentOptions : [...currentOptions, option];
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return currentOptions.filter((opt) => opt.value !== option.value);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: IonicMultiCheckboxFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
54
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.1", type: IonicMultiCheckboxFieldComponent, isStandalone: true, selector: "df-ion-multi-checkbox", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null } }, hostDirectives: [{ directive: i1.NgForgeFieldHost }], ngImport: i0, template: `
|
|
55
|
+
@let f = ngf.field();
|
|
56
|
+
@let checked = checkedValuesMap();
|
|
57
|
+
@if (ngf.label(); as label) {
|
|
58
|
+
<div class="checkbox-group-label">{{ label | dynamicText | async }}</div>
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
<div
|
|
62
|
+
class="checkbox-group"
|
|
63
|
+
role="group"
|
|
64
|
+
[attr.aria-invalid]="ngf.ariaInvalid()"
|
|
65
|
+
[attr.aria-required]="ngf.ariaRequired()"
|
|
66
|
+
[attr.aria-describedby]="ngf.ariaDescribedBy()"
|
|
67
|
+
[class.ion-invalid]="ngf.showErrors()"
|
|
68
|
+
[class.ion-touched]="f().touched()"
|
|
69
|
+
>
|
|
70
|
+
@for (option of options(); track option.value) {
|
|
71
|
+
<ion-item lines="none">
|
|
72
|
+
<ion-checkbox
|
|
73
|
+
ngForgeControl
|
|
74
|
+
[checked]="checked['' + option.value]"
|
|
75
|
+
[disabled]="f().disabled() || option.disabled"
|
|
76
|
+
[labelPlacement]="props()?.labelPlacement ?? 'end'"
|
|
77
|
+
[justify]="props()?.justify ?? 'start'"
|
|
78
|
+
[color]="props()?.color ?? 'primary'"
|
|
79
|
+
(ionChange)="onCheckboxChange(option, $event.detail.checked)"
|
|
80
|
+
>
|
|
81
|
+
{{ option.label | dynamicText | async }}
|
|
82
|
+
</ion-checkbox>
|
|
83
|
+
</ion-item>
|
|
84
|
+
}
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
@if (ngf.errorsToDisplay()[0]; as error) {
|
|
88
|
+
<ion-note color="danger" class="df-ion-error" [id]="ngf.errorId()" role="alert">{{ error.message }}</ion-note>
|
|
89
|
+
} @else if (props()?.hint; as hint) {
|
|
90
|
+
<ion-note class="df-ion-hint" [id]="ngf.hintId()">{{ hint | dynamicText | async }}</ion-note>
|
|
91
|
+
}
|
|
92
|
+
`, isInline: true, styles: [".df-ion-field{display:flex;flex-direction:column;gap:var(--df-field-gap, .5rem);width:100%}.df-ion-label{font-weight:var(--df-label-font-weight, 500);color:var(--df-label-color, inherit)}.df-ion-hint{display:block;color:var(--df-hint-color, var(--ion-color-medium, #92949c));font-size:var(--df-hint-font-size, .875rem)}.df-ion-error{display:block;color:var(--df-error-color, var(--ion-color-danger, #eb445a));font-size:var(--df-error-font-size, .875rem)}:host([hidden]){display:none!important}\n", ":host{display:block}:host([hidden]){display:none!important}.checkbox-group-label{margin-bottom:8px;font-weight:500}.checkbox-group{display:flex;flex-direction:column;gap:4px}ion-item{--padding-start: 0;--inner-padding-end: 0}\n"], dependencies: [{ kind: "component", type: IonCheckbox, selector: "ion-checkbox", inputs: ["checked", "color", "disabled", "errorText", "helperText", "indeterminate", "justify", "labelPlacement", "mode", "name", "value"] }, { kind: "component", type: IonItem, selector: "ion-item", inputs: ["button", "color", "detail", "detailIcon", "disabled", "download", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "target", "type"] }, { kind: "component", type: IonNote, selector: "ion-note", inputs: ["color", "mode"] }, { kind: "directive", type: NgForgeControl, selector: "[ngForgeControl]", inputs: ["ngForgeControl"] }, { kind: "pipe", type: DynamicTextPipe, name: "dynamicText" }, { kind: "pipe", type: AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
93
|
+
}
|
|
94
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: IonicMultiCheckboxFieldComponent, decorators: [{
|
|
95
|
+
type: Component,
|
|
96
|
+
args: [{ selector: 'df-ion-multi-checkbox', imports: [IonCheckbox, IonItem, IonNote, DynamicTextPipe, AsyncPipe, NgForgeControl], hostDirectives: [NgForgeFieldHost], template: `
|
|
97
|
+
@let f = ngf.field();
|
|
98
|
+
@let checked = checkedValuesMap();
|
|
99
|
+
@if (ngf.label(); as label) {
|
|
100
|
+
<div class="checkbox-group-label">{{ label | dynamicText | async }}</div>
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
<div
|
|
104
|
+
class="checkbox-group"
|
|
105
|
+
role="group"
|
|
106
|
+
[attr.aria-invalid]="ngf.ariaInvalid()"
|
|
107
|
+
[attr.aria-required]="ngf.ariaRequired()"
|
|
108
|
+
[attr.aria-describedby]="ngf.ariaDescribedBy()"
|
|
109
|
+
[class.ion-invalid]="ngf.showErrors()"
|
|
110
|
+
[class.ion-touched]="f().touched()"
|
|
111
|
+
>
|
|
112
|
+
@for (option of options(); track option.value) {
|
|
113
|
+
<ion-item lines="none">
|
|
114
|
+
<ion-checkbox
|
|
115
|
+
ngForgeControl
|
|
116
|
+
[checked]="checked['' + option.value]"
|
|
117
|
+
[disabled]="f().disabled() || option.disabled"
|
|
118
|
+
[labelPlacement]="props()?.labelPlacement ?? 'end'"
|
|
119
|
+
[justify]="props()?.justify ?? 'start'"
|
|
120
|
+
[color]="props()?.color ?? 'primary'"
|
|
121
|
+
(ionChange)="onCheckboxChange(option, $event.detail.checked)"
|
|
122
|
+
>
|
|
123
|
+
{{ option.label | dynamicText | async }}
|
|
124
|
+
</ion-checkbox>
|
|
125
|
+
</ion-item>
|
|
126
|
+
}
|
|
127
|
+
</div>
|
|
128
|
+
|
|
129
|
+
@if (ngf.errorsToDisplay()[0]; as error) {
|
|
130
|
+
<ion-note color="danger" class="df-ion-error" [id]="ngf.errorId()" role="alert">{{ error.message }}</ion-note>
|
|
131
|
+
} @else if (props()?.hint; as hint) {
|
|
132
|
+
<ion-note class="df-ion-hint" [id]="ngf.hintId()">{{ hint | dynamicText | async }}</ion-note>
|
|
133
|
+
}
|
|
134
|
+
`, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".df-ion-field{display:flex;flex-direction:column;gap:var(--df-field-gap, .5rem);width:100%}.df-ion-label{font-weight:var(--df-label-font-weight, 500);color:var(--df-label-color, inherit)}.df-ion-hint{display:block;color:var(--df-hint-color, var(--ion-color-medium, #92949c));font-size:var(--df-hint-font-size, .875rem)}.df-ion-error{display:block;color:var(--df-error-color, var(--ion-color-danger, #eb445a));font-size:var(--df-error-font-size, .875rem)}:host([hidden]){display:none!important}\n", ":host{display:block}:host([hidden]){display:none!important}.checkbox-group-label{margin-bottom:8px;font-weight:500}.checkbox-group{display:flex;flex-direction:column;gap:4px}ion-item{--padding-start: 0;--inner-padding-end: 0}\n"] }]
|
|
135
|
+
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }] } });
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
export { IonicMultiCheckboxFieldComponent };
|
|
139
|
+
//# sourceMappingURL=ng-forge-dynamic-forms-ionic-lazy-multi-checkbox.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-forge-dynamic-forms-ionic-lazy-multi-checkbox.mjs","mappings":";;;;;;;;AAkFc;;;;AAIH;;AAET;AAEI;;AAEF;IAKO;;;;;AAKP;;;AAGF;AACE;AACE;AAEA;AACE;;AAEJ;AAEA;AACE;AACA;;;AAIE;;AAEJ;;;;;AAMI;;;AAEA;;AAEJ;;;AAlDiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAxET","names":[],"ignoreList":[],"sources":["../../../../packages/dynamic-forms-ionic/src/lib/fields/multi-checkbox/ionic-multi-checkbox.component.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, computed, input, linkedSignal } from '@angular/core';\nimport { IonCheckbox, IonItem, IonNote } from '@ionic/angular/standalone';\nimport { FieldOption, ValueType } from '@ng-forge/dynamic-forms';\nimport { DynamicTextPipe } from '@ng-forge/dynamic-forms/integration';\nimport { injectNgForgeField, NgForgeFieldHost, isEqual, NgForgeControl } from '@ng-forge/dynamic-forms/integration';\nimport { explicitEffect } from 'ngxtension/explicit-effect';\nimport { IonicMultiCheckboxProps } from './ionic-multi-checkbox.type';\nimport { AsyncPipe } from '@angular/common';\n\n@Component({\n selector: 'df-ion-multi-checkbox',\n imports: [IonCheckbox, IonItem, IonNote, DynamicTextPipe, AsyncPipe, NgForgeControl],\n hostDirectives: [NgForgeFieldHost],\n template: `\n @let f = ngf.field();\n @let checked = checkedValuesMap();\n @if (ngf.label(); as label) {\n <div class=\"checkbox-group-label\">{{ label | dynamicText | async }}</div>\n }\n\n <div\n class=\"checkbox-group\"\n role=\"group\"\n [attr.aria-invalid]=\"ngf.ariaInvalid()\"\n [attr.aria-required]=\"ngf.ariaRequired()\"\n [attr.aria-describedby]=\"ngf.ariaDescribedBy()\"\n [class.ion-invalid]=\"ngf.showErrors()\"\n [class.ion-touched]=\"f().touched()\"\n >\n @for (option of options(); track option.value) {\n <ion-item lines=\"none\">\n <ion-checkbox\n ngForgeControl\n [checked]=\"checked['' + option.value]\"\n [disabled]=\"f().disabled() || option.disabled\"\n [labelPlacement]=\"props()?.labelPlacement ?? 'end'\"\n [justify]=\"props()?.justify ?? 'start'\"\n [color]=\"props()?.color ?? 'primary'\"\n (ionChange)=\"onCheckboxChange(option, $event.detail.checked)\"\n >\n {{ option.label | dynamicText | async }}\n </ion-checkbox>\n </ion-item>\n }\n </div>\n\n @if (ngf.errorsToDisplay()[0]; as error) {\n <ion-note color=\"danger\" class=\"df-ion-error\" [id]=\"ngf.errorId()\" role=\"alert\">{{ error.message }}</ion-note>\n } @else if (props()?.hint; as hint) {\n <ion-note class=\"df-ion-hint\" [id]=\"ngf.hintId()\">{{ hint | dynamicText | async }}</ion-note>\n }\n `,\n styleUrl: '../../styles/_form-field.scss',\n styles: [\n `\n :host {\n display: block;\n }\n\n :host([hidden]) {\n display: none !important;\n }\n\n .checkbox-group-label {\n margin-bottom: 8px;\n font-weight: 500;\n }\n\n .checkbox-group {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n ion-item {\n --padding-start: 0;\n --inner-padding-end: 0;\n }\n `,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport default class IonicMultiCheckboxFieldComponent {\n protected readonly ngf = injectNgForgeField<ValueType[]>();\n\n readonly options = input<FieldOption<ValueType>[]>([]);\n readonly props = input<IonicMultiCheckboxProps>();\n\n valueViewModel = linkedSignal<FieldOption<ValueType>[]>(\n () => {\n const currentValues = this.ngf.field()().value();\n return this.options().filter((option) => currentValues.includes(option.value));\n },\n { equal: isEqual },\n );\n\n /** Computed map of checked option values for O(1) lookup in template */\n readonly checkedValuesMap = computed(() => {\n const map: Record<string, boolean> = {};\n for (const opt of this.valueViewModel()) {\n map[String(opt.value)] = true;\n }\n return map;\n });\n\n constructor() {\n explicitEffect([this.valueViewModel], ([selectedOptions]) => {\n const selectedValues = selectedOptions.map((option) => option.value);\n\n if (!isEqual(selectedValues, this.ngf.field()().value())) {\n this.ngf.field()().value.set(selectedValues);\n }\n });\n\n explicitEffect([this.options], ([options]) => {\n const values = options.map((option) => option.value);\n const uniqueValues = new Set(values);\n\n if (values.length !== uniqueValues.size) {\n const duplicates = values.filter((value, index) => values.indexOf(value) !== index);\n throw new Error(`Duplicate option values detected in ionic-multi-checkbox: ${duplicates.join(', ')}`);\n }\n });\n }\n\n onCheckboxChange(option: FieldOption<ValueType>, checked: boolean): void {\n this.valueViewModel.update((currentOptions) => {\n if (checked) {\n return currentOptions.some((opt) => opt.value === option.value) ? currentOptions : [...currentOptions, option];\n } else {\n return currentOptions.filter((opt) => opt.value !== option.value);\n }\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { FormField } from '@angular/forms/signals';
|
|
4
|
+
import { IonRadioGroup, IonRadio, IonItem, IonNote } from '@ionic/angular/standalone';
|
|
5
|
+
import * as i1 from '@ng-forge/dynamic-forms/integration';
|
|
6
|
+
import { injectNgForgeField, NgForgeControl, DynamicTextPipe, NgForgeFieldHost } from '@ng-forge/dynamic-forms/integration';
|
|
7
|
+
import { AsyncPipe } from '@angular/common';
|
|
8
|
+
|
|
9
|
+
class IonicRadioFieldComponent {
|
|
10
|
+
ngf = injectNgForgeField();
|
|
11
|
+
options = input([], /* @ts-ignore */
|
|
12
|
+
...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
|
|
13
|
+
props = input(/* @ts-ignore */
|
|
14
|
+
...(ngDevMode ? [undefined, { debugName: "props" }] : /* istanbul ignore next */ []));
|
|
15
|
+
defaultCompare = Object.is;
|
|
16
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: IonicRadioFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
17
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.1", type: IonicRadioFieldComponent, isStandalone: true, selector: "df-ion-radio", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null } }, hostDirectives: [{ directive: i1.NgForgeFieldHost }], ngImport: i0, template: `
|
|
18
|
+
@let f = ngf.field();
|
|
19
|
+
@let radioGroupId = ngf.key() + '-radio-group';
|
|
20
|
+
@if (ngf.label(); as label) {
|
|
21
|
+
<div class="radio-label">{{ label | dynamicText | async }}</div>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
<ion-radio-group
|
|
25
|
+
[id]="radioGroupId"
|
|
26
|
+
[formField]="f"
|
|
27
|
+
[compareWith]="props()?.compareWith || defaultCompare"
|
|
28
|
+
[attr.aria-invalid]="ngf.ariaInvalid()"
|
|
29
|
+
[attr.aria-required]="ngf.ariaRequired()"
|
|
30
|
+
[attr.aria-describedby]="ngf.ariaDescribedBy()"
|
|
31
|
+
>
|
|
32
|
+
@for (option of options(); track option.value) {
|
|
33
|
+
<ion-item [lines]="'none'">
|
|
34
|
+
<ion-radio
|
|
35
|
+
ngForgeControl
|
|
36
|
+
[value]="option.value"
|
|
37
|
+
[disabled]="option.disabled || false"
|
|
38
|
+
[labelPlacement]="props()?.labelPlacement ?? 'end'"
|
|
39
|
+
[justify]="props()?.justify"
|
|
40
|
+
[color]="props()?.color ?? 'primary'"
|
|
41
|
+
>
|
|
42
|
+
{{ option.label | dynamicText | async }}
|
|
43
|
+
</ion-radio>
|
|
44
|
+
</ion-item>
|
|
45
|
+
}
|
|
46
|
+
</ion-radio-group>
|
|
47
|
+
|
|
48
|
+
@if (ngf.errorsToDisplay()[0]; as error) {
|
|
49
|
+
<ion-note color="danger" class="df-ion-error" [id]="ngf.errorId()" role="alert">{{ error.message }}</ion-note>
|
|
50
|
+
} @else if (props()?.hint; as hint) {
|
|
51
|
+
<ion-note class="df-ion-hint" [id]="ngf.hintId()">{{ hint | dynamicText | async }}</ion-note>
|
|
52
|
+
}
|
|
53
|
+
`, isInline: true, styles: [".df-ion-field{display:flex;flex-direction:column;gap:var(--df-field-gap, .5rem);width:100%}.df-ion-label{font-weight:var(--df-label-font-weight, 500);color:var(--df-label-color, inherit)}.df-ion-hint{display:block;color:var(--df-hint-color, var(--ion-color-medium, #92949c));font-size:var(--df-hint-font-size, .875rem)}.df-ion-error{display:block;color:var(--df-error-color, var(--ion-color-danger, #eb445a));font-size:var(--df-error-font-size, .875rem)}:host([hidden]){display:none!important}\n", ":host{display:block}:host([hidden]){display:none!important}.radio-label{font-size:.875rem;font-weight:500;margin-bottom:.5rem;color:var(--ion-text-color)}\n"], dependencies: [{ kind: "component", type: IonRadioGroup, selector: "ion-radio-group", inputs: ["allowEmptySelection", "compareWith", "errorText", "helperText", "name", "value"] }, { kind: "component", type: IonRadio, selector: "ion-radio", inputs: ["alignment", "color", "disabled", "justify", "labelPlacement", "mode", "name", "value"] }, { kind: "component", type: IonItem, selector: "ion-item", inputs: ["button", "color", "detail", "detailIcon", "disabled", "download", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "target", "type"] }, { kind: "component", type: IonNote, selector: "ion-note", inputs: ["color", "mode"] }, { kind: "directive", type: FormField, selector: "[formField]", inputs: ["formField"], exportAs: ["formField"] }, { kind: "directive", type: NgForgeControl, selector: "[ngForgeControl]", inputs: ["ngForgeControl"] }, { kind: "pipe", type: DynamicTextPipe, name: "dynamicText" }, { kind: "pipe", type: AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
54
|
+
}
|
|
55
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: IonicRadioFieldComponent, decorators: [{
|
|
56
|
+
type: Component,
|
|
57
|
+
args: [{ selector: 'df-ion-radio', imports: [IonRadioGroup, IonRadio, IonItem, IonNote, FormField, DynamicTextPipe, AsyncPipe, NgForgeControl], hostDirectives: [NgForgeFieldHost], template: `
|
|
58
|
+
@let f = ngf.field();
|
|
59
|
+
@let radioGroupId = ngf.key() + '-radio-group';
|
|
60
|
+
@if (ngf.label(); as label) {
|
|
61
|
+
<div class="radio-label">{{ label | dynamicText | async }}</div>
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
<ion-radio-group
|
|
65
|
+
[id]="radioGroupId"
|
|
66
|
+
[formField]="f"
|
|
67
|
+
[compareWith]="props()?.compareWith || defaultCompare"
|
|
68
|
+
[attr.aria-invalid]="ngf.ariaInvalid()"
|
|
69
|
+
[attr.aria-required]="ngf.ariaRequired()"
|
|
70
|
+
[attr.aria-describedby]="ngf.ariaDescribedBy()"
|
|
71
|
+
>
|
|
72
|
+
@for (option of options(); track option.value) {
|
|
73
|
+
<ion-item [lines]="'none'">
|
|
74
|
+
<ion-radio
|
|
75
|
+
ngForgeControl
|
|
76
|
+
[value]="option.value"
|
|
77
|
+
[disabled]="option.disabled || false"
|
|
78
|
+
[labelPlacement]="props()?.labelPlacement ?? 'end'"
|
|
79
|
+
[justify]="props()?.justify"
|
|
80
|
+
[color]="props()?.color ?? 'primary'"
|
|
81
|
+
>
|
|
82
|
+
{{ option.label | dynamicText | async }}
|
|
83
|
+
</ion-radio>
|
|
84
|
+
</ion-item>
|
|
85
|
+
}
|
|
86
|
+
</ion-radio-group>
|
|
87
|
+
|
|
88
|
+
@if (ngf.errorsToDisplay()[0]; as error) {
|
|
89
|
+
<ion-note color="danger" class="df-ion-error" [id]="ngf.errorId()" role="alert">{{ error.message }}</ion-note>
|
|
90
|
+
} @else if (props()?.hint; as hint) {
|
|
91
|
+
<ion-note class="df-ion-hint" [id]="ngf.hintId()">{{ hint | dynamicText | async }}</ion-note>
|
|
92
|
+
}
|
|
93
|
+
`, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".df-ion-field{display:flex;flex-direction:column;gap:var(--df-field-gap, .5rem);width:100%}.df-ion-label{font-weight:var(--df-label-font-weight, 500);color:var(--df-label-color, inherit)}.df-ion-hint{display:block;color:var(--df-hint-color, var(--ion-color-medium, #92949c));font-size:var(--df-hint-font-size, .875rem)}.df-ion-error{display:block;color:var(--df-error-color, var(--ion-color-danger, #eb445a));font-size:var(--df-error-font-size, .875rem)}:host([hidden]){display:none!important}\n", ":host{display:block}:host([hidden]){display:none!important}.radio-label{font-size:.875rem;font-weight:500;margin-bottom:.5rem;color:var(--ion-text-color)}\n"] }]
|
|
94
|
+
}], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }] } });
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
export { IonicRadioFieldComponent };
|
|
98
|
+
//# sourceMappingURL=ng-forge-dynamic-forms-ionic-lazy-radio.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-forge-dynamic-forms-ionic-lazy-radio.mjs","mappings":";;;;;;;;AAuEc;;;;AAIH;;AAET;;AANmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAtBlB","names":[],"ignoreList":[],"sources":["../../../../packages/dynamic-forms-ionic/src/lib/fields/radio/ionic-radio.component.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, input } from '@angular/core';\nimport { FormField } from '@angular/forms/signals';\nimport { IonItem, IonNote, IonRadio, IonRadioGroup } from '@ionic/angular/standalone';\nimport { FieldOption, ValueType } from '@ng-forge/dynamic-forms';\nimport { DynamicTextPipe } from '@ng-forge/dynamic-forms/integration';\nimport { NgForgeControl, injectNgForgeField, NgForgeFieldHost } from '@ng-forge/dynamic-forms/integration';\nimport { IonicRadioProps } from './ionic-radio.type';\nimport { AsyncPipe } from '@angular/common';\n\n@Component({\n selector: 'df-ion-radio',\n imports: [IonRadioGroup, IonRadio, IonItem, IonNote, FormField, DynamicTextPipe, AsyncPipe, NgForgeControl],\n hostDirectives: [NgForgeFieldHost],\n template: `\n @let f = ngf.field();\n @let radioGroupId = ngf.key() + '-radio-group';\n @if (ngf.label(); as label) {\n <div class=\"radio-label\">{{ label | dynamicText | async }}</div>\n }\n\n <ion-radio-group\n [id]=\"radioGroupId\"\n [formField]=\"f\"\n [compareWith]=\"props()?.compareWith || defaultCompare\"\n [attr.aria-invalid]=\"ngf.ariaInvalid()\"\n [attr.aria-required]=\"ngf.ariaRequired()\"\n [attr.aria-describedby]=\"ngf.ariaDescribedBy()\"\n >\n @for (option of options(); track option.value) {\n <ion-item [lines]=\"'none'\">\n <ion-radio\n ngForgeControl\n [value]=\"option.value\"\n [disabled]=\"option.disabled || false\"\n [labelPlacement]=\"props()?.labelPlacement ?? 'end'\"\n [justify]=\"props()?.justify\"\n [color]=\"props()?.color ?? 'primary'\"\n >\n {{ option.label | dynamicText | async }}\n </ion-radio>\n </ion-item>\n }\n </ion-radio-group>\n\n @if (ngf.errorsToDisplay()[0]; as error) {\n <ion-note color=\"danger\" class=\"df-ion-error\" [id]=\"ngf.errorId()\" role=\"alert\">{{ error.message }}</ion-note>\n } @else if (props()?.hint; as hint) {\n <ion-note class=\"df-ion-hint\" [id]=\"ngf.hintId()\">{{ hint | dynamicText | async }}</ion-note>\n }\n `,\n styleUrl: '../../styles/_form-field.scss',\n styles: [\n `\n :host {\n display: block;\n }\n\n :host([hidden]) {\n display: none !important;\n }\n\n .radio-label {\n font-size: 0.875rem;\n font-weight: 500;\n margin-bottom: 0.5rem;\n color: var(--ion-text-color);\n }\n `,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport default class IonicRadioFieldComponent {\n protected readonly ngf = injectNgForgeField<ValueType>();\n\n readonly options = input<FieldOption<ValueType>[]>([]);\n readonly props = input<IonicRadioProps>();\n\n defaultCompare = Object.is;\n}\n"]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { FormField } from '@angular/forms/signals';
|
|
4
|
+
import { IonSelect, IonSelectOption, IonNote } from '@ionic/angular/standalone';
|
|
5
|
+
import * as i1 from '@ng-forge/dynamic-forms/integration';
|
|
6
|
+
import { injectNgForgeField, NgForgeControl, DynamicTextPipe, NgForgeFieldHost } from '@ng-forge/dynamic-forms/integration';
|
|
7
|
+
import { AsyncPipe } from '@angular/common';
|
|
8
|
+
|
|
9
|
+
class IonicSelectFieldComponent {
|
|
10
|
+
ngf = injectNgForgeField();
|
|
11
|
+
options = input([], /* @ts-ignore */
|
|
12
|
+
...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
|
|
13
|
+
props = input(/* @ts-ignore */
|
|
14
|
+
...(ngDevMode ? [undefined, { debugName: "props" }] : /* istanbul ignore next */ []));
|
|
15
|
+
defaultCompare = Object.is;
|
|
16
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: IonicSelectFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
17
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.1", type: IonicSelectFieldComponent, isStandalone: true, selector: "df-ion-select", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null } }, hostDirectives: [{ directive: i1.NgForgeFieldHost }], ngImport: i0, template: `
|
|
18
|
+
@let f = ngf.field();
|
|
19
|
+
@let selectId = ngf.key() + '-select';
|
|
20
|
+
|
|
21
|
+
<ion-select
|
|
22
|
+
ngForgeControl
|
|
23
|
+
[id]="selectId"
|
|
24
|
+
[formField]="f"
|
|
25
|
+
[label]="(ngf.label() | dynamicText | async) ?? undefined"
|
|
26
|
+
[labelPlacement]="props()?.labelPlacement ?? 'stacked'"
|
|
27
|
+
[placeholder]="(ngf.placeholder() | dynamicText | async) ?? ''"
|
|
28
|
+
[multiple]="props()?.multiple ?? false"
|
|
29
|
+
[compareWith]="props()?.compareWith ?? defaultCompare"
|
|
30
|
+
[interface]="props()?.interface ?? 'alert'"
|
|
31
|
+
[interfaceOptions]="props()?.interfaceOptions ?? {}"
|
|
32
|
+
[cancelText]="props()?.cancelText ?? 'Cancel'"
|
|
33
|
+
[okText]="props()?.okText ?? 'OK'"
|
|
34
|
+
[color]="props()?.color"
|
|
35
|
+
[fill]="props()?.fill ?? 'outline'"
|
|
36
|
+
[shape]="props()?.shape"
|
|
37
|
+
[attr.tabindex]="ngf.tabIndex()"
|
|
38
|
+
>
|
|
39
|
+
@for (option of options(); track option.value) {
|
|
40
|
+
<ion-select-option [value]="option.value" [disabled]="option.disabled || false">
|
|
41
|
+
{{ option.label | dynamicText | async }}
|
|
42
|
+
</ion-select-option>
|
|
43
|
+
}
|
|
44
|
+
</ion-select>
|
|
45
|
+
@if (ngf.errorsToDisplay()[0]; as error) {
|
|
46
|
+
<ion-note color="danger" class="df-ion-error" [id]="ngf.errorId()" role="alert">{{ error.message }}</ion-note>
|
|
47
|
+
} @else if (props()?.hint; as hint) {
|
|
48
|
+
<ion-note class="df-ion-hint" [id]="ngf.hintId()">{{ hint | dynamicText | async }}</ion-note>
|
|
49
|
+
}
|
|
50
|
+
`, isInline: true, styles: [".df-ion-field{display:flex;flex-direction:column;gap:var(--df-field-gap, .5rem);width:100%}.df-ion-label{font-weight:var(--df-label-font-weight, 500);color:var(--df-label-color, inherit)}.df-ion-hint{display:block;color:var(--df-hint-color, var(--ion-color-medium, #92949c));font-size:var(--df-hint-font-size, .875rem)}.df-ion-error{display:block;color:var(--df-error-color, var(--ion-color-danger, #eb445a));font-size:var(--df-error-font-size, .875rem)}:host([hidden]){display:none!important}\n", ":host([hidden]){display:none!important}\n"], dependencies: [{ kind: "component", type: IonSelect, selector: "ion-select", inputs: ["cancelText", "color", "compareWith", "disabled", "errorText", "expandedIcon", "fill", "helperText", "interface", "interfaceOptions", "justify", "label", "labelPlacement", "mode", "multiple", "name", "okText", "placeholder", "selectedText", "shape", "toggleIcon", "value"] }, { kind: "component", type: IonSelectOption, selector: "ion-select-option", inputs: ["disabled", "value"] }, { kind: "component", type: IonNote, selector: "ion-note", inputs: ["color", "mode"] }, { kind: "directive", type: FormField, selector: "[formField]", inputs: ["formField"], exportAs: ["formField"] }, { kind: "directive", type: NgForgeControl, selector: "[ngForgeControl]", inputs: ["ngForgeControl"] }, { kind: "pipe", type: DynamicTextPipe, name: "dynamicText" }, { kind: "pipe", type: AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
51
|
+
}
|
|
52
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: IonicSelectFieldComponent, decorators: [{
|
|
53
|
+
type: Component,
|
|
54
|
+
args: [{ selector: 'df-ion-select', imports: [IonSelect, IonSelectOption, IonNote, FormField, DynamicTextPipe, AsyncPipe, NgForgeControl], hostDirectives: [NgForgeFieldHost], template: `
|
|
55
|
+
@let f = ngf.field();
|
|
56
|
+
@let selectId = ngf.key() + '-select';
|
|
57
|
+
|
|
58
|
+
<ion-select
|
|
59
|
+
ngForgeControl
|
|
60
|
+
[id]="selectId"
|
|
61
|
+
[formField]="f"
|
|
62
|
+
[label]="(ngf.label() | dynamicText | async) ?? undefined"
|
|
63
|
+
[labelPlacement]="props()?.labelPlacement ?? 'stacked'"
|
|
64
|
+
[placeholder]="(ngf.placeholder() | dynamicText | async) ?? ''"
|
|
65
|
+
[multiple]="props()?.multiple ?? false"
|
|
66
|
+
[compareWith]="props()?.compareWith ?? defaultCompare"
|
|
67
|
+
[interface]="props()?.interface ?? 'alert'"
|
|
68
|
+
[interfaceOptions]="props()?.interfaceOptions ?? {}"
|
|
69
|
+
[cancelText]="props()?.cancelText ?? 'Cancel'"
|
|
70
|
+
[okText]="props()?.okText ?? 'OK'"
|
|
71
|
+
[color]="props()?.color"
|
|
72
|
+
[fill]="props()?.fill ?? 'outline'"
|
|
73
|
+
[shape]="props()?.shape"
|
|
74
|
+
[attr.tabindex]="ngf.tabIndex()"
|
|
75
|
+
>
|
|
76
|
+
@for (option of options(); track option.value) {
|
|
77
|
+
<ion-select-option [value]="option.value" [disabled]="option.disabled || false">
|
|
78
|
+
{{ option.label | dynamicText | async }}
|
|
79
|
+
</ion-select-option>
|
|
80
|
+
}
|
|
81
|
+
</ion-select>
|
|
82
|
+
@if (ngf.errorsToDisplay()[0]; as error) {
|
|
83
|
+
<ion-note color="danger" class="df-ion-error" [id]="ngf.errorId()" role="alert">{{ error.message }}</ion-note>
|
|
84
|
+
} @else if (props()?.hint; as hint) {
|
|
85
|
+
<ion-note class="df-ion-hint" [id]="ngf.hintId()">{{ hint | dynamicText | async }}</ion-note>
|
|
86
|
+
}
|
|
87
|
+
`, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".df-ion-field{display:flex;flex-direction:column;gap:var(--df-field-gap, .5rem);width:100%}.df-ion-label{font-weight:var(--df-label-font-weight, 500);color:var(--df-label-color, inherit)}.df-ion-hint{display:block;color:var(--df-hint-color, var(--ion-color-medium, #92949c));font-size:var(--df-hint-font-size, .875rem)}.df-ion-error{display:block;color:var(--df-error-color, var(--ion-color-danger, #eb445a));font-size:var(--df-error-font-size, .875rem)}:host([hidden]){display:none!important}\n", ":host([hidden]){display:none!important}\n"] }]
|
|
88
|
+
}], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }] } });
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
export { IonicSelectFieldComponent };
|
|
92
|
+
//# sourceMappingURL=ng-forge-dynamic-forms-ionic-lazy-select.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-forge-dynamic-forms-ionic-lazy-select.mjs","mappings":";;;;;;;;AAyDc;;;;AAIH;;AAET;;AANmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAXlB","names":[],"ignoreList":[],"sources":["../../../../packages/dynamic-forms-ionic/src/lib/fields/select/ionic-select.component.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, input } from '@angular/core';\nimport { FormField } from '@angular/forms/signals';\nimport { IonNote, IonSelect, IonSelectOption } from '@ionic/angular/standalone';\nimport { FieldOption, ValueType } from '@ng-forge/dynamic-forms';\nimport { DynamicTextPipe } from '@ng-forge/dynamic-forms/integration';\nimport { NgForgeControl, injectNgForgeField, NgForgeFieldHost } from '@ng-forge/dynamic-forms/integration';\nimport { IonicSelectProps } from './ionic-select.type';\nimport { AsyncPipe } from '@angular/common';\n\n@Component({\n selector: 'df-ion-select',\n imports: [IonSelect, IonSelectOption, IonNote, FormField, DynamicTextPipe, AsyncPipe, NgForgeControl],\n hostDirectives: [NgForgeFieldHost],\n template: `\n @let f = ngf.field();\n @let selectId = ngf.key() + '-select';\n\n <ion-select\n ngForgeControl\n [id]=\"selectId\"\n [formField]=\"f\"\n [label]=\"(ngf.label() | dynamicText | async) ?? undefined\"\n [labelPlacement]=\"props()?.labelPlacement ?? 'stacked'\"\n [placeholder]=\"(ngf.placeholder() | dynamicText | async) ?? ''\"\n [multiple]=\"props()?.multiple ?? false\"\n [compareWith]=\"props()?.compareWith ?? defaultCompare\"\n [interface]=\"props()?.interface ?? 'alert'\"\n [interfaceOptions]=\"props()?.interfaceOptions ?? {}\"\n [cancelText]=\"props()?.cancelText ?? 'Cancel'\"\n [okText]=\"props()?.okText ?? 'OK'\"\n [color]=\"props()?.color\"\n [fill]=\"props()?.fill ?? 'outline'\"\n [shape]=\"props()?.shape\"\n [attr.tabindex]=\"ngf.tabIndex()\"\n >\n @for (option of options(); track option.value) {\n <ion-select-option [value]=\"option.value\" [disabled]=\"option.disabled || false\">\n {{ option.label | dynamicText | async }}\n </ion-select-option>\n }\n </ion-select>\n @if (ngf.errorsToDisplay()[0]; as error) {\n <ion-note color=\"danger\" class=\"df-ion-error\" [id]=\"ngf.errorId()\" role=\"alert\">{{ error.message }}</ion-note>\n } @else if (props()?.hint; as hint) {\n <ion-note class=\"df-ion-hint\" [id]=\"ngf.hintId()\">{{ hint | dynamicText | async }}</ion-note>\n }\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n styleUrl: '../../styles/_form-field.scss',\n styles: [\n `\n :host([hidden]) {\n display: none !important;\n }\n `,\n ],\n})\nexport default class IonicSelectFieldComponent {\n protected readonly ngf = injectNgForgeField<ValueType>();\n\n readonly options = input<FieldOption<ValueType>[]>([]);\n readonly props = input<IonicSelectProps>();\n\n defaultCompare = Object.is;\n}\n"]}
|