@wiltech-labs/ngx-forms 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from "@angular/core";
2
- import { InputSignal, WritableSignal } from "@angular/core";
2
+ import { InjectionToken, InputSignal, WritableSignal } from "@angular/core";
3
3
  import { FieldTree, Schema } from "@angular/forms/signals";
4
4
  export declare enum FormFieldType {
5
5
  TEXT = "text",
@@ -67,16 +67,24 @@ interface SchemaConfig<T extends BaseSchema> {
67
67
  fields: FieldDef[];
68
68
  initialValue: T;
69
69
  }
70
- /** Renders one Material field component per FieldDef, plus Save and Clear buttons. */
70
+ /**
71
+ * Renders one Material field component per FieldDef, then right-aligned actions: a text
72
+ * secondary action ("Clear" by default — label it "Cancel" when it leaves the form) and the filled
73
+ * primary one ("Save"). Name both after what they do.
74
+ */
71
75
  export declare class DynamicForm<T extends BaseSchema = BaseSchema> {
72
76
  metaInfo: InputSignal<FieldDef[]>;
73
77
  dynamicForm: InputSignal<FieldTree<T>>;
78
+ /** Filled primary action. */
79
+ readonly submitLabel: InputSignal<string>;
80
+ /** Text secondary action; emits `onFormClear`. */
81
+ readonly clearLabel: InputSignal<string>;
74
82
  onFormSubmit: import("@angular/core").OutputEmitterRef<void>;
75
83
  onFormClear: import("@angular/core").OutputEmitterRef<void>;
76
84
  protected handleSubmit(): void;
77
85
  protected clearForm(): void;
78
86
  static ɵfac: i0.ɵɵFactoryDeclaration<DynamicForm<any>, never>;
79
- static ɵcmp: i0.ɵɵComponentDeclaration<DynamicForm<any>, "app-dynamic-form", never, {
87
+ static ɵcmp: i0.ɵɵComponentDeclaration<DynamicForm<any>, "ngx-dynamic-form", never, {
80
88
  "metaInfo": {
81
89
  "alias": "metaInfo";
82
90
  "required": true;
@@ -87,6 +95,16 @@ export declare class DynamicForm<T extends BaseSchema = BaseSchema> {
87
95
  "required": true;
88
96
  "isSignal": true;
89
97
  };
98
+ "submitLabel": {
99
+ "alias": "submitLabel";
100
+ "required": false;
101
+ "isSignal": true;
102
+ };
103
+ "clearLabel": {
104
+ "alias": "clearLabel";
105
+ "required": false;
106
+ "isSignal": true;
107
+ };
90
108
  }, {
91
109
  "onFormSubmit": "onFormSubmit";
92
110
  "onFormClear": "onFormClear";
@@ -102,7 +120,7 @@ export declare class TextField {
102
120
  readonly field: import("@angular/core").InputSignal<FieldTree<string> | FieldTree<number>>;
103
121
  protected readonly formField: import("@angular/core").Signal<FieldTree<string>>;
104
122
  static ɵfac: i0.ɵɵFactoryDeclaration<TextField, never>;
105
- static ɵcmp: i0.ɵɵComponentDeclaration<TextField, "app-text-field", never, {
123
+ static ɵcmp: i0.ɵɵComponentDeclaration<TextField, "ngx-text-field", never, {
106
124
  "fieldDef": {
107
125
  "alias": "fieldDef";
108
126
  "required": true;
@@ -125,7 +143,7 @@ export declare class TextareaField {
125
143
  protected readonly isCode: import("@angular/core").Signal<boolean>;
126
144
  protected onKeydown(event: KeyboardEvent): void;
127
145
  static ɵfac: i0.ɵɵFactoryDeclaration<TextareaField, never>;
128
- static ɵcmp: i0.ɵɵComponentDeclaration<TextareaField, "app-textarea-field", never, {
146
+ static ɵcmp: i0.ɵɵComponentDeclaration<TextareaField, "ngx-textarea-field", never, {
129
147
  "fieldDef": {
130
148
  "alias": "fieldDef";
131
149
  "required": true;
@@ -143,7 +161,7 @@ export declare class CheckboxField {
143
161
  readonly fieldDef: import("@angular/core").InputSignal<FieldDef>;
144
162
  readonly field: import("@angular/core").InputSignal<FieldTree<boolean>>;
145
163
  static ɵfac: i0.ɵɵFactoryDeclaration<CheckboxField, never>;
146
- static ɵcmp: i0.ɵɵComponentDeclaration<CheckboxField, "app-checkbox-field", never, {
164
+ static ɵcmp: i0.ɵɵComponentDeclaration<CheckboxField, "ngx-checkbox-field", never, {
147
165
  "fieldDef": {
148
166
  "alias": "fieldDef";
149
167
  "required": true;
@@ -162,7 +180,7 @@ export declare class RadioField {
162
180
  readonly field: import("@angular/core").InputSignal<FieldTree<string | number | boolean>>;
163
181
  protected readonly labelId: string;
164
182
  static ɵfac: i0.ɵɵFactoryDeclaration<RadioField, never>;
165
- static ɵcmp: i0.ɵɵComponentDeclaration<RadioField, "app-radio-field", never, {
183
+ static ɵcmp: i0.ɵɵComponentDeclaration<RadioField, "ngx-radio-field", never, {
166
184
  "fieldDef": {
167
185
  "alias": "fieldDef";
168
186
  "required": true;
@@ -180,7 +198,7 @@ export declare class SelectField {
180
198
  readonly fieldDef: import("@angular/core").InputSignal<FieldDef>;
181
199
  readonly field: import("@angular/core").InputSignal<FieldTree<string | number | boolean>>;
182
200
  static ɵfac: i0.ɵɵFactoryDeclaration<SelectField, never>;
183
- static ɵcmp: i0.ɵɵComponentDeclaration<SelectField, "app-select-field", never, {
201
+ static ɵcmp: i0.ɵɵComponentDeclaration<SelectField, "ngx-select-field", never, {
184
202
  "fieldDef": {
185
203
  "alias": "fieldDef";
186
204
  "required": true;
@@ -199,7 +217,7 @@ export declare class SliderField {
199
217
  readonly field: import("@angular/core").InputSignal<FieldTree<number>>;
200
218
  protected readonly labelId: string;
201
219
  static ɵfac: i0.ɵɵFactoryDeclaration<SliderField, never>;
202
- static ɵcmp: i0.ɵɵComponentDeclaration<SliderField, "app-slider-field", never, {
220
+ static ɵcmp: i0.ɵɵComponentDeclaration<SliderField, "ngx-slider-field", never, {
203
221
  "fieldDef": {
204
222
  "alias": "fieldDef";
205
223
  "required": true;
@@ -220,6 +238,7 @@ export declare class BusinessDateField {
220
238
  readonly fieldDef: import("@angular/core").InputSignal<FieldDef>;
221
239
  readonly field: import("@angular/core").InputSignal<FieldTree<string | null>>;
222
240
  private readonly dateAdapter;
241
+ private readonly resolveLocale;
223
242
  protected readonly state: import("@angular/core").Signal<import("@angular/forms/signals").FieldState<string | null, string | number>>;
224
243
  protected readonly date: import("@angular/core").Signal<Date | null>;
225
244
  protected readonly minDate: import("@angular/core").Signal<Date | null>;
@@ -228,7 +247,7 @@ export declare class BusinessDateField {
228
247
  constructor();
229
248
  protected onDateChange(date: Date | null): void;
230
249
  static ɵfac: i0.ɵɵFactoryDeclaration<BusinessDateField, never>;
231
- static ɵcmp: i0.ɵɵComponentDeclaration<BusinessDateField, "app-business-date-field", never, {
250
+ static ɵcmp: i0.ɵɵComponentDeclaration<BusinessDateField, "ngx-business-date-field", never, {
232
251
  "fieldDef": {
233
252
  "alias": "fieldDef";
234
253
  "required": true;
@@ -249,6 +268,7 @@ export declare class BusinessTimeField {
249
268
  readonly fieldDef: import("@angular/core").InputSignal<FieldDef>;
250
269
  readonly field: import("@angular/core").InputSignal<FieldTree<string | null>>;
251
270
  private readonly dateAdapter;
271
+ private readonly resolveLocale;
252
272
  protected readonly state: import("@angular/core").Signal<import("@angular/forms/signals").FieldState<string | null, string | number>>;
253
273
  protected readonly time: import("@angular/core").Signal<Date | null>;
254
274
  protected readonly minTime: import("@angular/core").Signal<Date | null>;
@@ -257,7 +277,7 @@ export declare class BusinessTimeField {
257
277
  constructor();
258
278
  protected onTimeChange(time: Date | null): void;
259
279
  static ɵfac: i0.ɵɵFactoryDeclaration<BusinessTimeField, never>;
260
- static ɵcmp: i0.ɵɵComponentDeclaration<BusinessTimeField, "app-business-time-field", never, {
280
+ static ɵcmp: i0.ɵɵComponentDeclaration<BusinessTimeField, "ngx-business-time-field", never, {
261
281
  "fieldDef": {
262
282
  "alias": "fieldDef";
263
283
  "required": true;
@@ -280,6 +300,7 @@ export declare class InstantDateTimeField {
280
300
  readonly field: import("@angular/core").InputSignal<FieldTree<string | null>>;
281
301
  private readonly zonedDateTime;
282
302
  private readonly dateAdapter;
303
+ private readonly resolveLocale;
283
304
  /** Explains how a DST gap or overlap was resolved for the last value picked by the user. */
284
305
  protected readonly notice: WritableSignal<string | null>;
285
306
  protected readonly state: import("@angular/core").Signal<import("@angular/forms/signals").FieldState<string | null, string | number>>;
@@ -297,7 +318,7 @@ export declare class InstantDateTimeField {
297
318
  protected onTimeChange(time: Date | null): void;
298
319
  private commit;
299
320
  static ɵfac: i0.ɵɵFactoryDeclaration<InstantDateTimeField, never>;
300
- static ɵcmp: i0.ɵɵComponentDeclaration<InstantDateTimeField, "app-instant-date-time-field", never, {
321
+ static ɵcmp: i0.ɵɵComponentDeclaration<InstantDateTimeField, "ngx-instant-date-time-field", never, {
301
322
  "fieldDef": {
302
323
  "alias": "fieldDef";
303
324
  "required": true;
@@ -362,6 +383,25 @@ export declare class FormConfigBuilder<T extends BaseSchema> {
362
383
  }
363
384
  /** Starts a FormConfigBuilder for schema `T`. */
364
385
  export declare function formConfig<T extends BaseSchema>(schemaType: T['schemaType']): FormConfigBuilder<T>;
386
+ /** A plain function the app supplies, read fresh on every call — see `NGX_FORMS_LOCALE`. */
387
+ type FormsLocaleResolver = () => string;
388
+ /**
389
+ * Which locale a date/time field's picker displays and parses in, when its own `FieldDef`
390
+ * doesn't set `dateTimeConfig.locale` — an explicit per-field `locale` always wins over this.
391
+ * Defaults to `DEFAULT_DATE_TIME_LOCALE` ('en-GB'), same as before this token existed, not the
392
+ * browser's own language: unlike `ngx-dates`' `NGX_DATES_LOCALE` (read-only display text), this
393
+ * locale also decides which *typed* day/month order `LocaleDateAdapter.parse()` accepts, so
394
+ * switching it changes user input behaviour, not just wording — an app opts in deliberately:
395
+ *
396
+ * ```ts
397
+ * { provide: NGX_FORMS_LOCALE, useFactory: () => { const translations = inject(TranslationsService); return () => translations.locale(); } }
398
+ * ```
399
+ *
400
+ * A plain function rather than a direct import of `ngx-translations`' `TranslationsService`, so this package
401
+ * stays buildable and publishable on its own — same reasoning as `ngx-dates`' `NGX_DATES_LOCALE`
402
+ * (see root `CLAUDE.md`'s "Inter-package deps").
403
+ */
404
+ export declare const NGX_FORMS_LOCALE: InjectionToken<FormsLocaleResolver>;
365
405
  interface ZonedInstantResult {
366
406
  instant: string;
367
407
  notice: string | null;
@@ -387,4 +427,4 @@ export declare function defineSchema<T extends BaseSchema>(config: SchemaConfig<
387
427
  export declare function createEmptyEntity<T extends BaseSchema>(schemaType: T['schemaType'], defaults: Omit<T, 'id' | 'schemaType'>): T;
388
428
  /** Turns field definitions into Signals Forms rules. The model can be any object, not just a BaseSchema. */
389
429
  export declare function toSchema<T>(meta: FieldDef[]): Schema<T>;
390
- export type { BaseSchema, DateTimeConfig, DateTimeDisambiguation, DateTimeFieldOptions, FieldDef, FieldName, FieldOption, FieldOptions, SchemaConfig, ZonedInstantResult };
430
+ export type { BaseSchema, DateTimeConfig, DateTimeDisambiguation, DateTimeFieldOptions, FieldDef, FieldName, FieldOption, FieldOptions, FormsLocaleResolver, SchemaConfig, ZonedInstantResult };