@abgov/ui-components-common 1.4.0 → 1.5.0-alpha.2

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/lib/common.d.ts CHANGED
@@ -297,16 +297,8 @@ export interface GoabFieldsetOnContinueDetail {
297
297
  cancelled: boolean;
298
298
  }
299
299
  export type GoabPublicFormStatus = "initializing" | "complete";
300
- export type GoabPublicFormOnInitDetail = {
301
- el: HTMLFormElement;
302
- };
303
300
  export type GoabPublicFormPageStep = "step" | "summary" | "multistep";
304
301
  export type GoabPublicFormPageButtonVisibility = "visible" | "hidden";
305
- export type GoabPublicFormPageOnContinueDetail = {
306
- el: HTMLElement;
307
- state: Record<string, GoabFieldsetItemState>;
308
- cancelled: boolean;
309
- };
310
302
  export type GoabPublicFormPageOnFieldsetChangeDetail = {
311
303
  id: string;
312
304
  state: {
@@ -1,6 +1,5 @@
1
- import { GoabFieldsetItemValue, GoabFormDispatchOn, GoabPublicFormOnInitDetail, GoabPublicFormPageOnContinueDetail } from './common';
2
1
  import { FieldsetItemState, FieldValidator } from './validators';
3
-
2
+ import { GoabFieldsetItemValue, GoabFormDispatchOn } from './common';
4
3
  export type FormStatus = "not-started" | "incomplete" | "complete";
5
4
  export type AppState<T> = {
6
5
  uuid: string;
@@ -31,7 +30,7 @@ export declare class PublicFormController<T> {
31
30
  _formData?: Record<string, string>;
32
31
  _formRef?: HTMLElement;
33
32
  constructor(type: "details" | "list");
34
- init(e: GoabPublicFormOnInitDetail): void;
33
+ init(e: Event): void;
35
34
  initList(e: Event): void;
36
35
  initState(state?: string | AppState<T> | AppState<T>[], callback?: () => void): void;
37
36
  updateListState(e: Event): void;
@@ -39,7 +38,7 @@ export declare class PublicFormController<T> {
39
38
  getStateList(): Record<string, string>[];
40
39
  getStateValue(group: string, key: string): string;
41
40
  continueTo(next: T | undefined): void;
42
- validate(e: GoabPublicFormPageOnContinueDetail, field: string, validators: FieldValidator[], options?: {
41
+ validate(e: Event, field: string, validators: FieldValidator[], options?: {
43
42
  grouped: boolean;
44
43
  }): [boolean, GoabFieldsetItemValue];
45
44
  /**
@@ -51,7 +50,7 @@ export declare class PublicFormController<T> {
51
50
  * @param {FieldValidator[]} validators - An array of validator functions to apply to the fields.
52
51
  * @return {[number, Record<string, boolean>]} - Returns back the number of fields that passed and a record of the fields and their pass status.
53
52
  */
54
- validateGroup(e: GoabPublicFormPageOnContinueDetail, fields: string[], validators: FieldValidator[]): [number, Record<string, boolean>];
53
+ validateGroup(e: Event, fields: string[], validators: FieldValidator[]): [number, Record<string, boolean>];
55
54
  edit(index: number): void;
56
55
  remove(index: number): void;
57
56
  clean(data: AppState<T>): Record<string, unknown>;
@@ -0,0 +1,14 @@
1
+ import { PublicFormController, AppState } from './public-form-controller';
2
+ import { GoabFieldsetItemValue } from './common';
3
+ import { FieldValidator } from './validators';
4
+ export declare function usePublicFormController<T>(type?: "details" | "list"): {
5
+ state: AppState<T> | AppState<T>[] | undefined;
6
+ init: (e: Event) => void;
7
+ initList: (e: Event) => void;
8
+ initState: (state?: string | AppState<T> | AppState<T>[], callback?: () => void) => void;
9
+ continueTo: (next: T | undefined) => void;
10
+ validate: (e: Event, field: string, validators: FieldValidator[]) => [boolean, GoabFieldsetItemValue];
11
+ getStateValue: (group: string, key: string) => string;
12
+ getStateList: () => Record<string, string>[];
13
+ controller: PublicFormController<T>;
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/ui-components-common",
3
- "version": "1.4.0",
3
+ "version": "1.5.0-alpha.2",
4
4
  "bugs": {
5
5
  "url": "https://github.com/GovAlta/ui-components/issues"
6
6
  },