ngx-core-components 0.3.31 → 0.3.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +988 -601
- package/barcodes/barcode/barcode-encoding.d.ts +1 -0
- package/barcodes/barcode/barcode.component.d.ts +4 -4
- package/barcodes/public-api.d.ts +1 -0
- package/charts/bar-chart/bar-chart.component.d.ts +5 -1
- package/charts/box-plot-chart/box-plot-chart.component.d.ts +6 -0
- package/charts/bubble-chart/bubble-chart.component.d.ts +4 -0
- package/charts/bullet-chart/bullet-chart.component.d.ts +3 -0
- package/charts/column-range-chart/column-range-chart.component.d.ts +5 -1
- package/charts/dumbbell-chart/dumbbell-chart.component.d.ts +5 -1
- package/charts/funnel-chart/funnel-chart.component.d.ts +4 -0
- package/charts/heatmap-chart/heatmap-chart.component.d.ts +4 -0
- package/charts/line-chart/line-chart.component.d.ts +2 -0
- package/charts/lollipop-chart/lollipop-chart.component.d.ts +5 -1
- package/charts/marimekko-chart/marimekko-chart.component.d.ts +25 -1
- package/charts/pie-chart/pie-chart.component.d.ts +9 -0
- package/charts/pyramid-chart/pyramid-chart.component.d.ts +5 -0
- package/charts/radial-bar-chart/radial-bar-chart.component.d.ts +4 -0
- package/charts/range-bar-chart/range-bar-chart.component.d.ts +4 -0
- package/charts/scatter-plot/scatter-plot.component.d.ts +4 -0
- package/charts/shared/chart-accessible-mark.directive.d.ts +9 -0
- package/charts/shared/chart-export-menu.component.d.ts +7 -0
- package/charts/shared/chart-skeleton.component.d.ts +1 -1
- package/charts/sunburst-chart/sunburst-chart.component.d.ts +6 -3
- package/charts/treemap-chart/treemap-chart.component.d.ts +6 -4
- package/charts/waterfall-chart/waterfall-chart.component.d.ts +8 -0
- package/fesm2022/ngx-core-components-barcodes.mjs +196 -42
- package/fesm2022/ngx-core-components-barcodes.mjs.map +1 -1
- package/fesm2022/ngx-core-components-charts.mjs +1399 -875
- package/fesm2022/ngx-core-components-charts.mjs.map +1 -1
- package/fesm2022/ngx-core-components-grid.mjs +2075 -545
- package/fesm2022/ngx-core-components-grid.mjs.map +1 -1
- package/fesm2022/ngx-core-components-i18n.mjs +129 -35
- package/fesm2022/ngx-core-components-i18n.mjs.map +1 -1
- package/fesm2022/ngx-core-components-inputs.mjs +297 -39
- package/fesm2022/ngx-core-components-inputs.mjs.map +1 -1
- package/fesm2022/ngx-core-components-layout.mjs +71 -53
- package/fesm2022/ngx-core-components-layout.mjs.map +1 -1
- package/fesm2022/ngx-core-components-testing.mjs +30 -0
- package/fesm2022/ngx-core-components-testing.mjs.map +1 -0
- package/fesm2022/ngx-core-components-views.mjs +69 -29
- package/fesm2022/ngx-core-components-views.mjs.map +1 -1
- package/fesm2022/ngx-core-components.mjs +2 -2
- package/fesm2022/ngx-core-components.mjs.map +1 -1
- package/grid/data-grid/components/grid-filter-builder/grid-filter-builder.component.d.ts +6 -1
- package/grid/data-grid/data-grid.component.d.ts +19 -1
- package/grid/data-grid/grid-data-source.d.ts +22 -0
- package/grid/data-grid/services/grid-state.service.d.ts +7 -0
- package/grid/public-api.d.ts +6 -3
- package/i18n/ngx-core-i18n.d.ts +94 -1
- package/i18n/public-api.d.ts +1 -1
- package/inputs/form-builder/form-builder.component.d.ts +17 -1
- package/package.json +6 -2
- package/public-api.d.ts +8 -7
- package/testing/component-test-harness.d.ts +10 -0
- package/testing/index.d.ts +5 -0
- package/testing/public-api.d.ts +1 -0
- package/views/kanban/kanban.component.d.ts +1 -0
|
@@ -2882,7 +2882,20 @@ class DateRangePickerComponent {
|
|
|
2882
2882
|
viewYear = signal(new Date().getFullYear());
|
|
2883
2883
|
rangeChange = output();
|
|
2884
2884
|
openChange = output();
|
|
2885
|
-
monthNames = [
|
|
2885
|
+
monthNames = [
|
|
2886
|
+
'January',
|
|
2887
|
+
'February',
|
|
2888
|
+
'March',
|
|
2889
|
+
'April',
|
|
2890
|
+
'May',
|
|
2891
|
+
'June',
|
|
2892
|
+
'July',
|
|
2893
|
+
'August',
|
|
2894
|
+
'September',
|
|
2895
|
+
'October',
|
|
2896
|
+
'November',
|
|
2897
|
+
'December',
|
|
2898
|
+
];
|
|
2886
2899
|
baseWeekDays = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
2887
2900
|
syncInputs = effect(() => {
|
|
2888
2901
|
const start = this.toDateString(this.start());
|
|
@@ -2997,9 +3010,12 @@ class DateRangePickerComponent {
|
|
|
2997
3010
|
this.openChange.emit(false);
|
|
2998
3011
|
}
|
|
2999
3012
|
onDayKeydown(event, date) {
|
|
3013
|
+
const currentTarget = event.currentTarget;
|
|
3014
|
+
const isRtl = currentTarget instanceof HTMLElement && currentTarget.closest('[dir="rtl"]') !== null;
|
|
3015
|
+
const horizontalDirection = isRtl ? -1 : 1;
|
|
3000
3016
|
const deltas = {
|
|
3001
|
-
ArrowLeft: -
|
|
3002
|
-
ArrowRight:
|
|
3017
|
+
ArrowLeft: -horizontalDirection,
|
|
3018
|
+
ArrowRight: horizontalDirection,
|
|
3003
3019
|
ArrowUp: -7,
|
|
3004
3020
|
ArrowDown: 7,
|
|
3005
3021
|
};
|
|
@@ -3028,7 +3044,9 @@ class DateRangePickerComponent {
|
|
|
3028
3044
|
const min = this.parseLocalDate(this.toDateString(this.min()));
|
|
3029
3045
|
const max = this.parseLocalDate(this.toDateString(this.max()));
|
|
3030
3046
|
const key = this.formatLocalDate(date);
|
|
3031
|
-
const disabledSet = new Set(this.disabledDates()
|
|
3047
|
+
const disabledSet = new Set(this.disabledDates()
|
|
3048
|
+
.map(item => this.toDateString(item))
|
|
3049
|
+
.filter(Boolean));
|
|
3032
3050
|
return !!((min && date < min) || (max && date > max) || disabledSet.has(key));
|
|
3033
3051
|
}
|
|
3034
3052
|
parseLocalDate(value) {
|
|
@@ -3075,7 +3093,9 @@ class DateRangePickerComponent {
|
|
|
3075
3093
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: DateRangePickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3076
3094
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: DateRangePickerComponent, isStandalone: true, selector: "ngx-date-range-picker", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, start: { classPropertyName: "start", publicName: "start", isSignal: true, isRequired: false, transformFunction: null }, end: { classPropertyName: "end", publicName: "end", 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 }, disabledDates: { classPropertyName: "disabledDates", publicName: "disabledDates", isSignal: true, isRequired: false, transformFunction: null }, presets: { classPropertyName: "presets", publicName: "presets", isSignal: true, isRequired: false, transformFunction: null }, weekStartsOn: { classPropertyName: "weekStartsOn", publicName: "weekStartsOn", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { rangeChange: "rangeChange", openChange: "openChange" }, ngImport: i0, template: `
|
|
3077
3095
|
<div class="ngx-date-range-picker">
|
|
3078
|
-
@if (label()) {
|
|
3096
|
+
@if (label()) {
|
|
3097
|
+
<label class="drp-label">{{ label() }}</label>
|
|
3098
|
+
}
|
|
3079
3099
|
<div
|
|
3080
3100
|
class="drp-inputs"
|
|
3081
3101
|
[class.disabled]="disabled()"
|
|
@@ -3087,9 +3107,23 @@ class DateRangePickerComponent {
|
|
|
3087
3107
|
(keydown.space)="toggleOpen(); $event.preventDefault()"
|
|
3088
3108
|
(keydown.escape)="open.set(false)"
|
|
3089
3109
|
>
|
|
3090
|
-
<input
|
|
3110
|
+
<input
|
|
3111
|
+
class="drp-input"
|
|
3112
|
+
type="text"
|
|
3113
|
+
readonly
|
|
3114
|
+
[value]="startDate()"
|
|
3115
|
+
placeholder="Start date"
|
|
3116
|
+
[disabled]="disabled()"
|
|
3117
|
+
/>
|
|
3091
3118
|
<span class="drp-sep">→</span>
|
|
3092
|
-
<input
|
|
3119
|
+
<input
|
|
3120
|
+
class="drp-input"
|
|
3121
|
+
type="text"
|
|
3122
|
+
readonly
|
|
3123
|
+
[value]="endDate()"
|
|
3124
|
+
placeholder="End date"
|
|
3125
|
+
[disabled]="disabled()"
|
|
3126
|
+
/>
|
|
3093
3127
|
<span class="drp-icon">📅</span>
|
|
3094
3128
|
</div>
|
|
3095
3129
|
@if (open()) {
|
|
@@ -3106,12 +3140,16 @@ class DateRangePickerComponent {
|
|
|
3106
3140
|
|
|
3107
3141
|
<div class="drp-calendar">
|
|
3108
3142
|
<div class="cal-header">
|
|
3109
|
-
<button class="cal-nav" type="button" (click)="prevMonth($event)" aria-label="Previous month"
|
|
3143
|
+
<button class="cal-nav" type="button" (click)="prevMonth($event)" aria-label="Previous month">
|
|
3144
|
+
‹
|
|
3145
|
+
</button>
|
|
3110
3146
|
<span class="cal-title">{{ monthName(viewMonth()) }} {{ viewYear() }}</span>
|
|
3111
3147
|
<button class="cal-nav" type="button" (click)="nextMonth($event)" aria-label="Next month">›</button>
|
|
3112
3148
|
</div>
|
|
3113
3149
|
<div class="cal-grid" role="grid">
|
|
3114
|
-
@for (day of weekDays(); track day) {
|
|
3150
|
+
@for (day of weekDays(); track day) {
|
|
3151
|
+
<div class="cal-weekday">{{ day }}</div>
|
|
3152
|
+
}
|
|
3115
3153
|
@for (cell of calendarDays(); track cell.key) {
|
|
3116
3154
|
<button
|
|
3117
3155
|
type="button"
|
|
@@ -3128,20 +3166,24 @@ class DateRangePickerComponent {
|
|
|
3128
3166
|
[disabled]="cell.disabled"
|
|
3129
3167
|
(click)="selectDay(cell.date, $event)"
|
|
3130
3168
|
(keydown)="onDayKeydown($event, cell.date)"
|
|
3131
|
-
>
|
|
3169
|
+
>
|
|
3170
|
+
{{ cell.date.getDate() }}
|
|
3171
|
+
</button>
|
|
3132
3172
|
}
|
|
3133
3173
|
</div>
|
|
3134
3174
|
</div>
|
|
3135
3175
|
</div>
|
|
3136
3176
|
}
|
|
3137
3177
|
</div>
|
|
3138
|
-
`, isInline: true, styles: [":host{display:block;position:relative}.drp-label{display:block;font-size:12px;font-weight:600;color:var(--ngx-input-label, #475569);margin-bottom:6px}.drp-inputs{display:flex;align-items:center;gap:8px;padding:9px 12px;border:1px solid var(--ngx-input-border, #cbd5e1);border-radius:var(--ngx-input-radius, 8px);cursor:pointer;background:var(--ngx-input-bg, #fff);transition:all .2s}.drp-inputs:hover,.drp-inputs:focus-visible{border-color:var(--primary-color, #4f46e5);outline:none;box-shadow:0 0 0 3px var(--primary-glow, rgba(79, 70, 229, .12))}.drp-inputs.disabled{cursor:not-allowed;opacity:.6;background:var(--ngx-input-disabled-bg, #f8fafc)}.drp-input{border:none;background:transparent;font-size:13px;color:var(--ngx-input-text, #0f172a);outline:none;cursor:pointer;width:85px;font-family:inherit}.drp-input:disabled{cursor:not-allowed;color:var(--text-secondary, #64748b)}.drp-sep{color:#94a3b8;font-weight:650}.drp-icon{font-size:14px;color:#64748b;margin-left:auto}.drp-calendar-wrap{position:absolute;top:calc(100% + 6px);left:0;display:flex;gap:12px;background:var(--bg-secondary, #fff);border:1px solid var(--border-color, #e2e8f0);border-radius:var(--ngx-input-radius, 12px);box-shadow:var(--shadow-lg, 0 10px 25px rgba(0,0,0
|
|
3178
|
+
`, isInline: true, styles: [":host{display:block;position:relative}.drp-label{display:block;font-size:12px;font-weight:600;color:var(--ngx-input-label, #475569);margin-bottom:6px}.drp-inputs{display:flex;align-items:center;gap:8px;padding:9px 12px;border:1px solid var(--ngx-input-border, #cbd5e1);border-radius:var(--ngx-input-radius, 8px);cursor:pointer;background:var(--ngx-input-bg, #fff);transition:all .2s}.drp-inputs:hover,.drp-inputs:focus-visible{border-color:var(--primary-color, #4f46e5);outline:none;box-shadow:0 0 0 3px var(--primary-glow, rgba(79, 70, 229, .12))}.drp-inputs.disabled{cursor:not-allowed;opacity:.6;background:var(--ngx-input-disabled-bg, #f8fafc)}.drp-input{border:none;background:transparent;font-size:13px;color:var(--ngx-input-text, #0f172a);outline:none;cursor:pointer;width:85px;font-family:inherit}.drp-input:disabled{cursor:not-allowed;color:var(--text-secondary, #64748b)}.drp-sep{color:#94a3b8;font-weight:650}.drp-icon{font-size:14px;color:#64748b;margin-left:auto}.drp-calendar-wrap{position:absolute;top:calc(100% + 6px);left:0;display:flex;gap:12px;background:var(--bg-secondary, #fff);border:1px solid var(--border-color, #e2e8f0);border-radius:var(--ngx-input-radius, 12px);box-shadow:var(--shadow-lg, 0 10px 25px rgba(0, 0, 0, .08));z-index:1000;padding:14px}.drp-presets{display:flex;flex-direction:column;gap:6px;min-width:112px;padding-right:12px;border-right:1px solid var(--border-color, #e2e8f0)}.preset-btn{border:1px solid transparent;border-radius:6px;background:transparent;color:var(--text-secondary, #64748b);cursor:pointer;font:inherit;font-size:12px;font-weight:650;padding:7px 9px;text-align:left}.preset-btn:hover,.preset-btn:focus-visible{background:var(--border-light, #f1f5f9);color:var(--text-primary, #0f172a);outline:none}.cal-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.cal-nav{background:none;border:1px solid var(--border-color, #e2e8f0);border-radius:6px;cursor:pointer;padding:3px 8px;font-size:14px;color:#64748b;transition:all .15s}.cal-nav:hover,.cal-nav:focus-visible{background:var(--border-light, #f1f5f9);color:var(--text-primary, #0f172a);outline:none}.cal-title{font-weight:750;font-size:13px;color:var(--text-primary, #0f172a);font-family:var(--ngx-heading-font-family, inherit)}.cal-grid{display:grid;grid-template-columns:repeat(7,34px);gap:3px}.cal-weekday{text-align:center;font-size:10px;font-weight:700;color:#94a3b8;padding:4px 0;text-transform:uppercase;letter-spacing:.5px}.cal-day{width:34px;height:34px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:550;border-radius:6px;cursor:pointer;transition:all .15s;color:var(--text-primary, #0f172a);border:0;background:transparent;font-family:inherit}.cal-day:hover:not(.range-start):not(.range-end):not(.disabled),.cal-day:focus-visible:not(.range-start):not(.range-end):not(.disabled){background:var(--border-light, #f1f5f9);outline:none}.cal-day.other-month{color:#cbd5e1}.cal-day.disabled{color:#cbd5e1;cursor:not-allowed;text-decoration:line-through}.cal-day.in-range{background:var(--primary-glow, rgba(79, 70, 229, .08));color:var(--primary-color, #4f46e5);border-radius:0}.cal-day.range-start,.cal-day.range-end{background:var(--primary-gradient, linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%));color:#fff;font-weight:700;border-radius:50%;box-shadow:0 2px 6px #4f46e559}.cal-day.today:not(.range-start):not(.range-end){font-weight:700;border:1.5px solid var(--primary-color, #4f46e5);color:var(--primary-color, #4f46e5)}@media (max-width: 520px){.drp-calendar-wrap{flex-direction:column;width:max-content;max-width:calc(100vw - 32px)}.drp-presets{flex-direction:row;flex-wrap:wrap;min-width:0;padding:0 0 10px;border-right:0;border-bottom:1px solid var(--border-color, #e2e8f0)}}\n"] });
|
|
3139
3179
|
}
|
|
3140
3180
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: DateRangePickerComponent, decorators: [{
|
|
3141
3181
|
type: Component,
|
|
3142
3182
|
args: [{ selector: 'ngx-date-range-picker', standalone: true, template: `
|
|
3143
3183
|
<div class="ngx-date-range-picker">
|
|
3144
|
-
@if (label()) {
|
|
3184
|
+
@if (label()) {
|
|
3185
|
+
<label class="drp-label">{{ label() }}</label>
|
|
3186
|
+
}
|
|
3145
3187
|
<div
|
|
3146
3188
|
class="drp-inputs"
|
|
3147
3189
|
[class.disabled]="disabled()"
|
|
@@ -3153,9 +3195,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
|
|
|
3153
3195
|
(keydown.space)="toggleOpen(); $event.preventDefault()"
|
|
3154
3196
|
(keydown.escape)="open.set(false)"
|
|
3155
3197
|
>
|
|
3156
|
-
<input
|
|
3198
|
+
<input
|
|
3199
|
+
class="drp-input"
|
|
3200
|
+
type="text"
|
|
3201
|
+
readonly
|
|
3202
|
+
[value]="startDate()"
|
|
3203
|
+
placeholder="Start date"
|
|
3204
|
+
[disabled]="disabled()"
|
|
3205
|
+
/>
|
|
3157
3206
|
<span class="drp-sep">→</span>
|
|
3158
|
-
<input
|
|
3207
|
+
<input
|
|
3208
|
+
class="drp-input"
|
|
3209
|
+
type="text"
|
|
3210
|
+
readonly
|
|
3211
|
+
[value]="endDate()"
|
|
3212
|
+
placeholder="End date"
|
|
3213
|
+
[disabled]="disabled()"
|
|
3214
|
+
/>
|
|
3159
3215
|
<span class="drp-icon">📅</span>
|
|
3160
3216
|
</div>
|
|
3161
3217
|
@if (open()) {
|
|
@@ -3172,12 +3228,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
|
|
|
3172
3228
|
|
|
3173
3229
|
<div class="drp-calendar">
|
|
3174
3230
|
<div class="cal-header">
|
|
3175
|
-
<button class="cal-nav" type="button" (click)="prevMonth($event)" aria-label="Previous month"
|
|
3231
|
+
<button class="cal-nav" type="button" (click)="prevMonth($event)" aria-label="Previous month">
|
|
3232
|
+
‹
|
|
3233
|
+
</button>
|
|
3176
3234
|
<span class="cal-title">{{ monthName(viewMonth()) }} {{ viewYear() }}</span>
|
|
3177
3235
|
<button class="cal-nav" type="button" (click)="nextMonth($event)" aria-label="Next month">›</button>
|
|
3178
3236
|
</div>
|
|
3179
3237
|
<div class="cal-grid" role="grid">
|
|
3180
|
-
@for (day of weekDays(); track day) {
|
|
3238
|
+
@for (day of weekDays(); track day) {
|
|
3239
|
+
<div class="cal-weekday">{{ day }}</div>
|
|
3240
|
+
}
|
|
3181
3241
|
@for (cell of calendarDays(); track cell.key) {
|
|
3182
3242
|
<button
|
|
3183
3243
|
type="button"
|
|
@@ -3194,14 +3254,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
|
|
|
3194
3254
|
[disabled]="cell.disabled"
|
|
3195
3255
|
(click)="selectDay(cell.date, $event)"
|
|
3196
3256
|
(keydown)="onDayKeydown($event, cell.date)"
|
|
3197
|
-
>
|
|
3257
|
+
>
|
|
3258
|
+
{{ cell.date.getDate() }}
|
|
3259
|
+
</button>
|
|
3198
3260
|
}
|
|
3199
3261
|
</div>
|
|
3200
3262
|
</div>
|
|
3201
3263
|
</div>
|
|
3202
3264
|
}
|
|
3203
3265
|
</div>
|
|
3204
|
-
`, styles: [":host{display:block;position:relative}.drp-label{display:block;font-size:12px;font-weight:600;color:var(--ngx-input-label, #475569);margin-bottom:6px}.drp-inputs{display:flex;align-items:center;gap:8px;padding:9px 12px;border:1px solid var(--ngx-input-border, #cbd5e1);border-radius:var(--ngx-input-radius, 8px);cursor:pointer;background:var(--ngx-input-bg, #fff);transition:all .2s}.drp-inputs:hover,.drp-inputs:focus-visible{border-color:var(--primary-color, #4f46e5);outline:none;box-shadow:0 0 0 3px var(--primary-glow, rgba(79, 70, 229, .12))}.drp-inputs.disabled{cursor:not-allowed;opacity:.6;background:var(--ngx-input-disabled-bg, #f8fafc)}.drp-input{border:none;background:transparent;font-size:13px;color:var(--ngx-input-text, #0f172a);outline:none;cursor:pointer;width:85px;font-family:inherit}.drp-input:disabled{cursor:not-allowed;color:var(--text-secondary, #64748b)}.drp-sep{color:#94a3b8;font-weight:650}.drp-icon{font-size:14px;color:#64748b;margin-left:auto}.drp-calendar-wrap{position:absolute;top:calc(100% + 6px);left:0;display:flex;gap:12px;background:var(--bg-secondary, #fff);border:1px solid var(--border-color, #e2e8f0);border-radius:var(--ngx-input-radius, 12px);box-shadow:var(--shadow-lg, 0 10px 25px rgba(0,0,0
|
|
3266
|
+
`, styles: [":host{display:block;position:relative}.drp-label{display:block;font-size:12px;font-weight:600;color:var(--ngx-input-label, #475569);margin-bottom:6px}.drp-inputs{display:flex;align-items:center;gap:8px;padding:9px 12px;border:1px solid var(--ngx-input-border, #cbd5e1);border-radius:var(--ngx-input-radius, 8px);cursor:pointer;background:var(--ngx-input-bg, #fff);transition:all .2s}.drp-inputs:hover,.drp-inputs:focus-visible{border-color:var(--primary-color, #4f46e5);outline:none;box-shadow:0 0 0 3px var(--primary-glow, rgba(79, 70, 229, .12))}.drp-inputs.disabled{cursor:not-allowed;opacity:.6;background:var(--ngx-input-disabled-bg, #f8fafc)}.drp-input{border:none;background:transparent;font-size:13px;color:var(--ngx-input-text, #0f172a);outline:none;cursor:pointer;width:85px;font-family:inherit}.drp-input:disabled{cursor:not-allowed;color:var(--text-secondary, #64748b)}.drp-sep{color:#94a3b8;font-weight:650}.drp-icon{font-size:14px;color:#64748b;margin-left:auto}.drp-calendar-wrap{position:absolute;top:calc(100% + 6px);left:0;display:flex;gap:12px;background:var(--bg-secondary, #fff);border:1px solid var(--border-color, #e2e8f0);border-radius:var(--ngx-input-radius, 12px);box-shadow:var(--shadow-lg, 0 10px 25px rgba(0, 0, 0, .08));z-index:1000;padding:14px}.drp-presets{display:flex;flex-direction:column;gap:6px;min-width:112px;padding-right:12px;border-right:1px solid var(--border-color, #e2e8f0)}.preset-btn{border:1px solid transparent;border-radius:6px;background:transparent;color:var(--text-secondary, #64748b);cursor:pointer;font:inherit;font-size:12px;font-weight:650;padding:7px 9px;text-align:left}.preset-btn:hover,.preset-btn:focus-visible{background:var(--border-light, #f1f5f9);color:var(--text-primary, #0f172a);outline:none}.cal-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.cal-nav{background:none;border:1px solid var(--border-color, #e2e8f0);border-radius:6px;cursor:pointer;padding:3px 8px;font-size:14px;color:#64748b;transition:all .15s}.cal-nav:hover,.cal-nav:focus-visible{background:var(--border-light, #f1f5f9);color:var(--text-primary, #0f172a);outline:none}.cal-title{font-weight:750;font-size:13px;color:var(--text-primary, #0f172a);font-family:var(--ngx-heading-font-family, inherit)}.cal-grid{display:grid;grid-template-columns:repeat(7,34px);gap:3px}.cal-weekday{text-align:center;font-size:10px;font-weight:700;color:#94a3b8;padding:4px 0;text-transform:uppercase;letter-spacing:.5px}.cal-day{width:34px;height:34px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:550;border-radius:6px;cursor:pointer;transition:all .15s;color:var(--text-primary, #0f172a);border:0;background:transparent;font-family:inherit}.cal-day:hover:not(.range-start):not(.range-end):not(.disabled),.cal-day:focus-visible:not(.range-start):not(.range-end):not(.disabled){background:var(--border-light, #f1f5f9);outline:none}.cal-day.other-month{color:#cbd5e1}.cal-day.disabled{color:#cbd5e1;cursor:not-allowed;text-decoration:line-through}.cal-day.in-range{background:var(--primary-glow, rgba(79, 70, 229, .08));color:var(--primary-color, #4f46e5);border-radius:0}.cal-day.range-start,.cal-day.range-end{background:var(--primary-gradient, linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%));color:#fff;font-weight:700;border-radius:50%;box-shadow:0 2px 6px #4f46e559}.cal-day.today:not(.range-start):not(.range-end){font-weight:700;border:1.5px solid var(--primary-color, #4f46e5);color:var(--primary-color, #4f46e5)}@media (max-width: 520px){.drp-calendar-wrap{flex-direction:column;width:max-content;max-width:calc(100vw - 32px)}.drp-presets{flex-direction:row;flex-wrap:wrap;min-width:0;padding:0 0 10px;border-right:0;border-bottom:1px solid var(--border-color, #e2e8f0)}}\n"] }]
|
|
3205
3267
|
}] });
|
|
3206
3268
|
|
|
3207
3269
|
class FileUploadComponent {
|
|
@@ -4296,7 +4358,56 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
|
|
|
4296
4358
|
args: ['window:resize']
|
|
4297
4359
|
}] } });
|
|
4298
4360
|
|
|
4361
|
+
function findSchemaErrors(fields, translations) {
|
|
4362
|
+
const fieldKeys = new Set();
|
|
4363
|
+
const errors = [];
|
|
4364
|
+
for (const field of fields) {
|
|
4365
|
+
if (fieldKeys.has(field.key)) {
|
|
4366
|
+
errors.push(translations.duplicateFieldKey(field.key));
|
|
4367
|
+
}
|
|
4368
|
+
fieldKeys.add(field.key);
|
|
4369
|
+
}
|
|
4370
|
+
const dependencies = new Map();
|
|
4371
|
+
for (const field of fields) {
|
|
4372
|
+
if (!dependencies.has(field.key))
|
|
4373
|
+
dependencies.set(field.key, []);
|
|
4374
|
+
for (const condition of field.conditions ?? []) {
|
|
4375
|
+
if (!fieldKeys.has(condition.field)) {
|
|
4376
|
+
errors.push(translations.missingConditionField(field.key, condition.field));
|
|
4377
|
+
}
|
|
4378
|
+
else {
|
|
4379
|
+
dependencies.get(field.key)?.push(condition.field);
|
|
4380
|
+
}
|
|
4381
|
+
}
|
|
4382
|
+
}
|
|
4383
|
+
const visited = new Set();
|
|
4384
|
+
const activePath = [];
|
|
4385
|
+
const cycleFields = new Set();
|
|
4386
|
+
const visit = (key) => {
|
|
4387
|
+
if (visited.has(key))
|
|
4388
|
+
return;
|
|
4389
|
+
activePath.push(key);
|
|
4390
|
+
for (const dependency of dependencies.get(key) ?? []) {
|
|
4391
|
+
const cycleStart = activePath.indexOf(dependency);
|
|
4392
|
+
if (cycleStart !== -1) {
|
|
4393
|
+
activePath.slice(cycleStart).forEach(cycleKey => cycleFields.add(cycleKey));
|
|
4394
|
+
}
|
|
4395
|
+
else {
|
|
4396
|
+
visit(dependency);
|
|
4397
|
+
}
|
|
4398
|
+
}
|
|
4399
|
+
activePath.pop();
|
|
4400
|
+
visited.add(key);
|
|
4401
|
+
};
|
|
4402
|
+
for (const key of dependencies.keys())
|
|
4403
|
+
visit(key);
|
|
4404
|
+
if (cycleFields.size > 0) {
|
|
4405
|
+
errors.push(translations.conditionCycle([...cycleFields].join(', ')));
|
|
4406
|
+
}
|
|
4407
|
+
return errors;
|
|
4408
|
+
}
|
|
4299
4409
|
class FormBuilderComponent {
|
|
4410
|
+
i18n = inject(NGX_CORE_I18N);
|
|
4300
4411
|
fields = input([]);
|
|
4301
4412
|
value = input({});
|
|
4302
4413
|
submitLabel = input('Submit');
|
|
@@ -4304,6 +4415,11 @@ class FormBuilderComponent {
|
|
|
4304
4415
|
formSubmit = output();
|
|
4305
4416
|
formChange = output();
|
|
4306
4417
|
formState = signal({});
|
|
4418
|
+
validationErrors = signal({});
|
|
4419
|
+
pending = signal(false);
|
|
4420
|
+
stepIndex = signal(0);
|
|
4421
|
+
schemaErrors = computed(() => findSchemaErrors(this.fields(), this.i18n.formBuilder));
|
|
4422
|
+
validationRun = 0;
|
|
4307
4423
|
visibleFields = computed(() => {
|
|
4308
4424
|
const allFields = this.fields();
|
|
4309
4425
|
const state = this.formState();
|
|
@@ -4321,6 +4437,10 @@ class FormBuilderComponent {
|
|
|
4321
4437
|
return true;
|
|
4322
4438
|
});
|
|
4323
4439
|
});
|
|
4440
|
+
steps = computed(() => [...new Set(this.visibleFields().map(field => field.formStep ?? 0))].sort((a, b) => a - b));
|
|
4441
|
+
currentStep = computed(() => this.steps()[this.stepIndex()] ?? 0);
|
|
4442
|
+
currentStepFields = computed(() => this.visibleFields().filter(field => (field.formStep ?? 0) === this.currentStep()));
|
|
4443
|
+
isLastStep = computed(() => this.steps().length === 0 || this.stepIndex() >= this.steps().length - 1);
|
|
4324
4444
|
constructor() {
|
|
4325
4445
|
effect(() => {
|
|
4326
4446
|
const initial = this.value() || {};
|
|
@@ -4355,13 +4475,65 @@ class FormBuilderComponent {
|
|
|
4355
4475
|
return false;
|
|
4356
4476
|
}
|
|
4357
4477
|
updateValue(key, val) {
|
|
4478
|
+
this.validationRun++;
|
|
4479
|
+
this.pending.set(false);
|
|
4480
|
+
const errors = { ...this.validationErrors() };
|
|
4481
|
+
delete errors[key];
|
|
4482
|
+
this.validationErrors.set(errors);
|
|
4358
4483
|
const updated = { ...this.formState(), [key]: val };
|
|
4359
4484
|
this.formState.set(updated);
|
|
4360
4485
|
this.formChange.emit(updated);
|
|
4361
4486
|
}
|
|
4362
|
-
|
|
4487
|
+
async nextStep() {
|
|
4488
|
+
if (this.schemaErrors().length > 0 || this.isLastStep() || !(await this.validateFields(this.currentStepFields())))
|
|
4489
|
+
return;
|
|
4490
|
+
this.stepIndex.update(index => Math.min(index + 1, this.steps().length - 1));
|
|
4491
|
+
}
|
|
4492
|
+
previousStep() {
|
|
4493
|
+
this.stepIndex.update(index => Math.max(0, index - 1));
|
|
4494
|
+
}
|
|
4495
|
+
async submit(event) {
|
|
4363
4496
|
event.preventDefault();
|
|
4364
|
-
|
|
4497
|
+
if (this.schemaErrors().length > 0)
|
|
4498
|
+
return;
|
|
4499
|
+
if (await this.validateFields(this.visibleFields())) {
|
|
4500
|
+
this.formSubmit.emit(this.formState());
|
|
4501
|
+
}
|
|
4502
|
+
}
|
|
4503
|
+
async validateFields(fields) {
|
|
4504
|
+
const run = ++this.validationRun;
|
|
4505
|
+
const state = this.formState();
|
|
4506
|
+
const errors = {};
|
|
4507
|
+
const enabledFields = fields.filter(field => !this.isFieldDisabled(field));
|
|
4508
|
+
this.pending.set(true);
|
|
4509
|
+
for (const field of enabledFields) {
|
|
4510
|
+
const value = state[field.key];
|
|
4511
|
+
const missing = value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0);
|
|
4512
|
+
if (field.required && missing)
|
|
4513
|
+
errors[field.key] = this.i18n.formBuilder.required;
|
|
4514
|
+
}
|
|
4515
|
+
await Promise.all(enabledFields
|
|
4516
|
+
.filter(field => field.asyncValidator)
|
|
4517
|
+
.map(async (field) => {
|
|
4518
|
+
try {
|
|
4519
|
+
const message = await field.asyncValidator(state[field.key], state);
|
|
4520
|
+
if (message)
|
|
4521
|
+
errors[field.key] = message;
|
|
4522
|
+
}
|
|
4523
|
+
catch (error) {
|
|
4524
|
+
errors[field.key] =
|
|
4525
|
+
error instanceof Error && error.message ? error.message : this.i18n.formBuilder.validationFailed;
|
|
4526
|
+
}
|
|
4527
|
+
}));
|
|
4528
|
+
if (run !== this.validationRun)
|
|
4529
|
+
return false;
|
|
4530
|
+
const nextErrors = { ...this.validationErrors() };
|
|
4531
|
+
for (const field of fields)
|
|
4532
|
+
delete nextErrors[field.key];
|
|
4533
|
+
Object.assign(nextErrors, errors);
|
|
4534
|
+
this.validationErrors.set(nextErrors);
|
|
4535
|
+
this.pending.set(false);
|
|
4536
|
+
return Object.keys(errors).length === 0;
|
|
4365
4537
|
}
|
|
4366
4538
|
coerceInputValue(field, val) {
|
|
4367
4539
|
if (field.type === 'number') {
|
|
@@ -4383,7 +4555,9 @@ class FormBuilderComponent {
|
|
|
4383
4555
|
case 'neq':
|
|
4384
4556
|
return String(actualVal) !== String(cond.value);
|
|
4385
4557
|
case 'contains':
|
|
4386
|
-
return String(actualVal || '')
|
|
4558
|
+
return String(actualVal || '')
|
|
4559
|
+
.toLowerCase()
|
|
4560
|
+
.includes(String(cond.value || '').toLowerCase());
|
|
4387
4561
|
case 'gt':
|
|
4388
4562
|
return Number(actualVal) > Number(cond.value);
|
|
4389
4563
|
case 'lt':
|
|
@@ -4399,8 +4573,15 @@ class FormBuilderComponent {
|
|
|
4399
4573
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: FormBuilderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4400
4574
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: FormBuilderComponent, isStandalone: true, selector: "ngx-form-builder", inputs: { fields: { classPropertyName: "fields", publicName: "fields", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, submitLabel: { classPropertyName: "submitLabel", publicName: "submitLabel", isSignal: true, isRequired: false, transformFunction: null }, showSubmit: { classPropertyName: "showSubmit", publicName: "showSubmit", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { formSubmit: "formSubmit", formChange: "formChange" }, ngImport: i0, template: `
|
|
4401
4575
|
<form class="ngx-form-builder" (submit)="submit($event)">
|
|
4576
|
+
@if (schemaErrors().length > 0) {
|
|
4577
|
+
<ul class="form-schema-errors" role="alert">
|
|
4578
|
+
@for (error of schemaErrors(); track error) {
|
|
4579
|
+
<li>{{ error }}</li>
|
|
4580
|
+
}
|
|
4581
|
+
</ul>
|
|
4582
|
+
}
|
|
4402
4583
|
<div class="form-grid">
|
|
4403
|
-
@for (field of
|
|
4584
|
+
@for (field of currentStepFields(); track field.key) {
|
|
4404
4585
|
<div
|
|
4405
4586
|
class="form-field-wrap"
|
|
4406
4587
|
[style.grid-column]="'span ' + (field.colSpan || 12)"
|
|
@@ -4408,7 +4589,10 @@ class FormBuilderComponent {
|
|
|
4408
4589
|
>
|
|
4409
4590
|
@if (field.type !== 'checkbox') {
|
|
4410
4591
|
<label class="field-label" [attr.for]="field.key">
|
|
4411
|
-
{{ field.label }}
|
|
4592
|
+
{{ field.label }}
|
|
4593
|
+
@if (field.required) {
|
|
4594
|
+
<strong class="req-star">*</strong>
|
|
4595
|
+
}
|
|
4412
4596
|
</label>
|
|
4413
4597
|
}
|
|
4414
4598
|
|
|
@@ -4431,7 +4615,7 @@ class FormBuilderComponent {
|
|
|
4431
4615
|
[value]="valueFor(field.key)"
|
|
4432
4616
|
(change)="updateValue(field.key, readOptionValue(field, $any($event.target).value))"
|
|
4433
4617
|
>
|
|
4434
|
-
<option value="">
|
|
4618
|
+
<option value="">{{ i18n.dropdown.selectPlaceholder }}</option>
|
|
4435
4619
|
@for (option of field.options || []; track option.value) {
|
|
4436
4620
|
<option [value]="option.value">{{ option.label }}</option>
|
|
4437
4621
|
}
|
|
@@ -4447,7 +4631,12 @@ class FormBuilderComponent {
|
|
|
4447
4631
|
[disabled]="isFieldDisabled(field)"
|
|
4448
4632
|
(change)="updateValue(field.key, $any($event.target).checked)"
|
|
4449
4633
|
/>
|
|
4450
|
-
<span class="field-label"
|
|
4634
|
+
<span class="field-label"
|
|
4635
|
+
>{{ field.label }}
|
|
4636
|
+
@if (field.required) {
|
|
4637
|
+
<strong class="req-star">*</strong>
|
|
4638
|
+
}
|
|
4639
|
+
</span>
|
|
4451
4640
|
</label>
|
|
4452
4641
|
}
|
|
4453
4642
|
@case ('switch') {
|
|
@@ -4463,8 +4652,7 @@ class FormBuilderComponent {
|
|
|
4463
4652
|
<span class="field-label">{{ field.label }}</span>
|
|
4464
4653
|
</label>
|
|
4465
4654
|
}
|
|
4466
|
-
@case ('range') {
|
|
4467
|
-
}
|
|
4655
|
+
@case ('range') {}
|
|
4468
4656
|
@case ('color-picker') {
|
|
4469
4657
|
<input
|
|
4470
4658
|
type="color"
|
|
@@ -4493,24 +4681,59 @@ class FormBuilderComponent {
|
|
|
4493
4681
|
@if (field.hint) {
|
|
4494
4682
|
<div class="field-hint">{{ field.hint }}</div>
|
|
4495
4683
|
}
|
|
4684
|
+
@if (validationErrors()[field.key]; as validationError) {
|
|
4685
|
+
<div class="field-error" role="alert">{{ validationError }}</div>
|
|
4686
|
+
}
|
|
4496
4687
|
</div>
|
|
4497
4688
|
}
|
|
4498
4689
|
</div>
|
|
4499
4690
|
|
|
4500
|
-
@if (
|
|
4691
|
+
@if (steps().length > 1) {
|
|
4692
|
+
<nav class="form-step-actions" [attr.aria-label]="i18n.formBuilder.steps">
|
|
4693
|
+
<button type="button" (click)="previousStep()" [disabled]="stepIndex() === 0 || pending()">
|
|
4694
|
+
{{ i18n.formBuilder.previousStep }}
|
|
4695
|
+
</button>
|
|
4696
|
+
<span aria-live="polite">{{ i18n.formBuilder.stepProgress(stepIndex() + 1, steps().length) }}</span>
|
|
4697
|
+
@if (!isLastStep()) {
|
|
4698
|
+
<button type="button" (click)="nextStep()" [disabled]="pending() || schemaErrors().length > 0">
|
|
4699
|
+
{{ i18n.formBuilder.nextStep }}
|
|
4700
|
+
</button>
|
|
4701
|
+
}
|
|
4702
|
+
</nav>
|
|
4703
|
+
}
|
|
4704
|
+
@if (showSubmit() && isLastStep()) {
|
|
4501
4705
|
<div class="form-actions">
|
|
4502
|
-
<button
|
|
4706
|
+
<button
|
|
4707
|
+
type="submit"
|
|
4708
|
+
class="submit-btn"
|
|
4709
|
+
[disabled]="pending() || schemaErrors().length > 0"
|
|
4710
|
+
[attr.aria-busy]="pending()"
|
|
4711
|
+
>
|
|
4712
|
+
{{ submitLabel() }}
|
|
4713
|
+
</button>
|
|
4503
4714
|
</div>
|
|
4504
4715
|
}
|
|
4716
|
+
<div class="form-status" aria-live="polite">
|
|
4717
|
+
@if (pending()) {
|
|
4718
|
+
{{ i18n.formBuilder.validating }}
|
|
4719
|
+
}
|
|
4720
|
+
</div>
|
|
4505
4721
|
</form>
|
|
4506
|
-
`, isInline: true, styles: [":host{display:block}.ngx-form-builder{font-family:var(--ngx-font-family, inherit);color:var(--text-primary, #0f172a)}.form-grid{display:grid;grid-template-columns:repeat(12,1fr);gap:14px}.form-field-wrap{display:flex;flex-direction:column;gap:6px}.field-label{font-size:12px;font-weight:700;color:var(--ngx-input-label, #475569)}.req-star{color:var(--ngx-input-error, #dc2626);margin-left:2px}.checkbox-label{display:flex;align-items:center;gap:8px;cursor:pointer}.field-hint{font-size:11px;color:#64748b}input:not([type=checkbox]):not([type=color]),textarea,select{width:100%;border:1px solid var(--ngx-input-border, #cbd5e1);border-radius:var(--ngx-input-radius, 8px);background:var(--ngx-input-bg, #ffffff);color:var(--ngx-input-text, #0f172a);font:inherit;font-size:13px;padding:9px 11px;outline:none;transition:all .15s}input:focus,textarea:focus,select:focus{border-color:var(--ngx-input-focus, #4f46e5);box-shadow:0 0 0 3px #4f46e51f}textarea{min-height:80px;resize:vertical}.form-actions{margin-top:18px;display:flex;justify-content:flex-end}.submit-btn{padding:9px 20px;font-size:13px;font-weight:700;border-radius:8px;border:none;background:var(--ngx-btn-primary-bg, #4f46e5);color:#fff;cursor:pointer;transition:all .2s}.submit-btn:hover{background:var(--ngx-btn-primary-hover, #4338ca)}.switch-wrap{display:flex;align-items:center;gap:10px;cursor:pointer}.switch-wrap input{display:none}.switch-slider{width:36px;height:20px;background:#cbd5e1;border-radius:20px;position:relative;transition:background .2s}.switch-slider:before{content:\"\";position:absolute;top:2px;left:2px;width:16px;height:16px;background:#fff;border-radius:50%;transition:transform .2s}.switch-wrap input:checked+.switch-slider{background:#4f46e5}.switch-wrap input:checked+.switch-slider:before{transform:translate(16px)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }] });
|
|
4722
|
+
`, isInline: true, styles: [":host{display:block}.ngx-form-builder{font-family:var(--ngx-font-family, inherit);color:var(--text-primary, #0f172a)}.form-grid{display:grid;grid-template-columns:repeat(12,1fr);gap:14px}.form-schema-errors{color:var(--ngx-input-error, #b91c1c)}.form-field-wrap{display:flex;flex-direction:column;gap:6px}.field-label{font-size:12px;font-weight:700;color:var(--ngx-input-label, #475569)}.req-star{color:var(--ngx-input-error, #dc2626);margin-left:2px}.checkbox-label{display:flex;align-items:center;gap:8px;cursor:pointer}.field-hint{font-size:11px;color:#64748b}.field-error{font-size:12px;color:var(--ngx-input-error, #b91c1c)}.form-step-actions{margin-top:18px;display:flex;align-items:center;gap:12px}.form-step-actions button{min-height:36px;padding:6px 12px;border:1px solid var(--ngx-input-border, #cbd5e1);border-radius:6px;background:var(--ngx-input-bg, #fff);color:inherit;cursor:pointer}.form-step-actions button:disabled,.submit-btn:disabled{cursor:not-allowed;opacity:.6}.form-step-actions button:last-child{margin-left:auto}input:not([type=checkbox]):not([type=color]),textarea,select{width:100%;border:1px solid var(--ngx-input-border, #cbd5e1);border-radius:var(--ngx-input-radius, 8px);background:var(--ngx-input-bg, #ffffff);color:var(--ngx-input-text, #0f172a);font:inherit;font-size:13px;padding:9px 11px;outline:none;transition:all .15s}input:focus,textarea:focus,select:focus{border-color:var(--ngx-input-focus, #4f46e5);box-shadow:0 0 0 3px #4f46e51f}textarea{min-height:80px;resize:vertical}.form-actions{margin-top:18px;display:flex;justify-content:flex-end}.submit-btn{padding:9px 20px;font-size:13px;font-weight:700;border-radius:8px;border:none;background:var(--ngx-btn-primary-bg, #4f46e5);color:#fff;cursor:pointer;transition:all .2s}.submit-btn:hover{background:var(--ngx-btn-primary-hover, #4338ca)}.switch-wrap{display:flex;align-items:center;gap:10px;cursor:pointer}.switch-wrap input{display:none}.switch-slider{width:36px;height:20px;background:#cbd5e1;border-radius:20px;position:relative;transition:background .2s}.switch-slider:before{content:\"\";position:absolute;top:2px;left:2px;width:16px;height:16px;background:#fff;border-radius:50%;transition:transform .2s}.switch-wrap input:checked+.switch-slider{background:#4f46e5}.switch-wrap input:checked+.switch-slider:before{transform:translate(16px)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }] });
|
|
4507
4723
|
}
|
|
4508
4724
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: FormBuilderComponent, decorators: [{
|
|
4509
4725
|
type: Component,
|
|
4510
4726
|
args: [{ selector: 'ngx-form-builder', standalone: true, imports: [CommonModule], template: `
|
|
4511
4727
|
<form class="ngx-form-builder" (submit)="submit($event)">
|
|
4728
|
+
@if (schemaErrors().length > 0) {
|
|
4729
|
+
<ul class="form-schema-errors" role="alert">
|
|
4730
|
+
@for (error of schemaErrors(); track error) {
|
|
4731
|
+
<li>{{ error }}</li>
|
|
4732
|
+
}
|
|
4733
|
+
</ul>
|
|
4734
|
+
}
|
|
4512
4735
|
<div class="form-grid">
|
|
4513
|
-
@for (field of
|
|
4736
|
+
@for (field of currentStepFields(); track field.key) {
|
|
4514
4737
|
<div
|
|
4515
4738
|
class="form-field-wrap"
|
|
4516
4739
|
[style.grid-column]="'span ' + (field.colSpan || 12)"
|
|
@@ -4518,7 +4741,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
|
|
|
4518
4741
|
>
|
|
4519
4742
|
@if (field.type !== 'checkbox') {
|
|
4520
4743
|
<label class="field-label" [attr.for]="field.key">
|
|
4521
|
-
{{ field.label }}
|
|
4744
|
+
{{ field.label }}
|
|
4745
|
+
@if (field.required) {
|
|
4746
|
+
<strong class="req-star">*</strong>
|
|
4747
|
+
}
|
|
4522
4748
|
</label>
|
|
4523
4749
|
}
|
|
4524
4750
|
|
|
@@ -4541,7 +4767,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
|
|
|
4541
4767
|
[value]="valueFor(field.key)"
|
|
4542
4768
|
(change)="updateValue(field.key, readOptionValue(field, $any($event.target).value))"
|
|
4543
4769
|
>
|
|
4544
|
-
<option value="">
|
|
4770
|
+
<option value="">{{ i18n.dropdown.selectPlaceholder }}</option>
|
|
4545
4771
|
@for (option of field.options || []; track option.value) {
|
|
4546
4772
|
<option [value]="option.value">{{ option.label }}</option>
|
|
4547
4773
|
}
|
|
@@ -4557,7 +4783,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
|
|
|
4557
4783
|
[disabled]="isFieldDisabled(field)"
|
|
4558
4784
|
(change)="updateValue(field.key, $any($event.target).checked)"
|
|
4559
4785
|
/>
|
|
4560
|
-
<span class="field-label"
|
|
4786
|
+
<span class="field-label"
|
|
4787
|
+
>{{ field.label }}
|
|
4788
|
+
@if (field.required) {
|
|
4789
|
+
<strong class="req-star">*</strong>
|
|
4790
|
+
}
|
|
4791
|
+
</span>
|
|
4561
4792
|
</label>
|
|
4562
4793
|
}
|
|
4563
4794
|
@case ('switch') {
|
|
@@ -4573,8 +4804,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
|
|
|
4573
4804
|
<span class="field-label">{{ field.label }}</span>
|
|
4574
4805
|
</label>
|
|
4575
4806
|
}
|
|
4576
|
-
@case ('range') {
|
|
4577
|
-
}
|
|
4807
|
+
@case ('range') {}
|
|
4578
4808
|
@case ('color-picker') {
|
|
4579
4809
|
<input
|
|
4580
4810
|
type="color"
|
|
@@ -4603,17 +4833,45 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
|
|
|
4603
4833
|
@if (field.hint) {
|
|
4604
4834
|
<div class="field-hint">{{ field.hint }}</div>
|
|
4605
4835
|
}
|
|
4836
|
+
@if (validationErrors()[field.key]; as validationError) {
|
|
4837
|
+
<div class="field-error" role="alert">{{ validationError }}</div>
|
|
4838
|
+
}
|
|
4606
4839
|
</div>
|
|
4607
4840
|
}
|
|
4608
4841
|
</div>
|
|
4609
4842
|
|
|
4610
|
-
@if (
|
|
4843
|
+
@if (steps().length > 1) {
|
|
4844
|
+
<nav class="form-step-actions" [attr.aria-label]="i18n.formBuilder.steps">
|
|
4845
|
+
<button type="button" (click)="previousStep()" [disabled]="stepIndex() === 0 || pending()">
|
|
4846
|
+
{{ i18n.formBuilder.previousStep }}
|
|
4847
|
+
</button>
|
|
4848
|
+
<span aria-live="polite">{{ i18n.formBuilder.stepProgress(stepIndex() + 1, steps().length) }}</span>
|
|
4849
|
+
@if (!isLastStep()) {
|
|
4850
|
+
<button type="button" (click)="nextStep()" [disabled]="pending() || schemaErrors().length > 0">
|
|
4851
|
+
{{ i18n.formBuilder.nextStep }}
|
|
4852
|
+
</button>
|
|
4853
|
+
}
|
|
4854
|
+
</nav>
|
|
4855
|
+
}
|
|
4856
|
+
@if (showSubmit() && isLastStep()) {
|
|
4611
4857
|
<div class="form-actions">
|
|
4612
|
-
<button
|
|
4858
|
+
<button
|
|
4859
|
+
type="submit"
|
|
4860
|
+
class="submit-btn"
|
|
4861
|
+
[disabled]="pending() || schemaErrors().length > 0"
|
|
4862
|
+
[attr.aria-busy]="pending()"
|
|
4863
|
+
>
|
|
4864
|
+
{{ submitLabel() }}
|
|
4865
|
+
</button>
|
|
4613
4866
|
</div>
|
|
4614
4867
|
}
|
|
4868
|
+
<div class="form-status" aria-live="polite">
|
|
4869
|
+
@if (pending()) {
|
|
4870
|
+
{{ i18n.formBuilder.validating }}
|
|
4871
|
+
}
|
|
4872
|
+
</div>
|
|
4615
4873
|
</form>
|
|
4616
|
-
`, styles: [":host{display:block}.ngx-form-builder{font-family:var(--ngx-font-family, inherit);color:var(--text-primary, #0f172a)}.form-grid{display:grid;grid-template-columns:repeat(12,1fr);gap:14px}.form-field-wrap{display:flex;flex-direction:column;gap:6px}.field-label{font-size:12px;font-weight:700;color:var(--ngx-input-label, #475569)}.req-star{color:var(--ngx-input-error, #dc2626);margin-left:2px}.checkbox-label{display:flex;align-items:center;gap:8px;cursor:pointer}.field-hint{font-size:11px;color:#64748b}input:not([type=checkbox]):not([type=color]),textarea,select{width:100%;border:1px solid var(--ngx-input-border, #cbd5e1);border-radius:var(--ngx-input-radius, 8px);background:var(--ngx-input-bg, #ffffff);color:var(--ngx-input-text, #0f172a);font:inherit;font-size:13px;padding:9px 11px;outline:none;transition:all .15s}input:focus,textarea:focus,select:focus{border-color:var(--ngx-input-focus, #4f46e5);box-shadow:0 0 0 3px #4f46e51f}textarea{min-height:80px;resize:vertical}.form-actions{margin-top:18px;display:flex;justify-content:flex-end}.submit-btn{padding:9px 20px;font-size:13px;font-weight:700;border-radius:8px;border:none;background:var(--ngx-btn-primary-bg, #4f46e5);color:#fff;cursor:pointer;transition:all .2s}.submit-btn:hover{background:var(--ngx-btn-primary-hover, #4338ca)}.switch-wrap{display:flex;align-items:center;gap:10px;cursor:pointer}.switch-wrap input{display:none}.switch-slider{width:36px;height:20px;background:#cbd5e1;border-radius:20px;position:relative;transition:background .2s}.switch-slider:before{content:\"\";position:absolute;top:2px;left:2px;width:16px;height:16px;background:#fff;border-radius:50%;transition:transform .2s}.switch-wrap input:checked+.switch-slider{background:#4f46e5}.switch-wrap input:checked+.switch-slider:before{transform:translate(16px)}\n"] }]
|
|
4874
|
+
`, styles: [":host{display:block}.ngx-form-builder{font-family:var(--ngx-font-family, inherit);color:var(--text-primary, #0f172a)}.form-grid{display:grid;grid-template-columns:repeat(12,1fr);gap:14px}.form-schema-errors{color:var(--ngx-input-error, #b91c1c)}.form-field-wrap{display:flex;flex-direction:column;gap:6px}.field-label{font-size:12px;font-weight:700;color:var(--ngx-input-label, #475569)}.req-star{color:var(--ngx-input-error, #dc2626);margin-left:2px}.checkbox-label{display:flex;align-items:center;gap:8px;cursor:pointer}.field-hint{font-size:11px;color:#64748b}.field-error{font-size:12px;color:var(--ngx-input-error, #b91c1c)}.form-step-actions{margin-top:18px;display:flex;align-items:center;gap:12px}.form-step-actions button{min-height:36px;padding:6px 12px;border:1px solid var(--ngx-input-border, #cbd5e1);border-radius:6px;background:var(--ngx-input-bg, #fff);color:inherit;cursor:pointer}.form-step-actions button:disabled,.submit-btn:disabled{cursor:not-allowed;opacity:.6}.form-step-actions button:last-child{margin-left:auto}input:not([type=checkbox]):not([type=color]),textarea,select{width:100%;border:1px solid var(--ngx-input-border, #cbd5e1);border-radius:var(--ngx-input-radius, 8px);background:var(--ngx-input-bg, #ffffff);color:var(--ngx-input-text, #0f172a);font:inherit;font-size:13px;padding:9px 11px;outline:none;transition:all .15s}input:focus,textarea:focus,select:focus{border-color:var(--ngx-input-focus, #4f46e5);box-shadow:0 0 0 3px #4f46e51f}textarea{min-height:80px;resize:vertical}.form-actions{margin-top:18px;display:flex;justify-content:flex-end}.submit-btn{padding:9px 20px;font-size:13px;font-weight:700;border-radius:8px;border:none;background:var(--ngx-btn-primary-bg, #4f46e5);color:#fff;cursor:pointer;transition:all .2s}.submit-btn:hover{background:var(--ngx-btn-primary-hover, #4338ca)}.switch-wrap{display:flex;align-items:center;gap:10px;cursor:pointer}.switch-wrap input{display:none}.switch-slider{width:36px;height:20px;background:#cbd5e1;border-radius:20px;position:relative;transition:background .2s}.switch-slider:before{content:\"\";position:absolute;top:2px;left:2px;width:16px;height:16px;background:#fff;border-radius:50%;transition:transform .2s}.switch-wrap input:checked+.switch-slider{background:#4f46e5}.switch-wrap input:checked+.switch-slider:before{transform:translate(16px)}\n"] }]
|
|
4617
4875
|
}], ctorParameters: () => [] });
|
|
4618
4876
|
|
|
4619
4877
|
class FormDesignerComponent {
|