@abgov/ui-components-common 1.3.0 → 1.4.0-alpha.1

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/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var M=Object.defineProperty;var y=r=>{throw TypeError(r)};var S=(r,t,e)=>t in r?M(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var l=(r,t,e)=>S(r,typeof t!="symbol"?t+"":t,e),N=(r,t,e)=>t.has(r)||y("Cannot "+e);var g=(r,t,e)=>t.has(r)?y("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e);var V=(r,t,e)=>(N(r,t,"access private method"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class E{constructor(t){l(this,"validators");this.validators=t||{}}add(t,...e){this.validators[t]=e}validate(t){const e={};return Object.entries(this.validators).forEach(([a,i])=>{const n=i.map(s=>s(t[a])).find(s=>!!s);n&&(e[a]=n)}),e}}function w(){return[c("Day is required"),m({min:1,max:31,minMsg:"Day must be between 1 and 31",maxMsg:"Day must be between 1 and 31"})]}function _(){return[c("Month is required"),m({min:0,max:11,minMsg:"Month must be between Jan and Dec",maxMsg:"Month must be between Jan and Dec"})]}function D(){const r=new Date().getFullYear();return[c("Year is required"),m({min:1900,max:r,minMsg:"Year must be greater than 1900",maxMsg:`Year must be less than ${r}`})]}function c(r){return t=>(r=r||"Required",typeof t=="number"&&!isNaN(t)||t?"":r)}function R(r){const t=new RegExp(/^\+?[\d-() ]{10,18}$/);return h(t,r||"Invalid phone number")}function $(r){const t=new RegExp(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);return h(t,r||"Invalid email address")}function x(){return r=>{if(!r)return"";const t="121212121".split("").map(i=>parseInt(i)),e=r.replace(/\D/g,"");return e.length!==9?"SIN must contain 9 numbers":e.split("").map(i=>parseInt(i)).map((i,n)=>{const s=i*t[n];return s<10?s:`${s}`.split("").map(o=>parseInt(o)).reduce((o,u)=>o+u,0)}).reduce((i,n)=>i+n,0)%10===0?"":"Invalid SIN"}}function I(){return h(/^[ABCEGHJ-NPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ -]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,"Invalid postal code")}function h(r,t){return e=>!e||e.match(r)?"":t}function C({invalidMsg:r,minMsg:t,maxMsg:e,min:a,max:i}={}){return n=>{let s=new Date(-1);return`${n||""}`.length===0?"":(typeof n=="string"&&(s=new Date(n)),typeof n=="number"&&(s=new Date(n)),n.toDateString&&(s=n),s.getDate()===-1?r||"Invalid date":a&&s<a?t||`Must be after ${a}`:i&&s>i?e||`Must be before ${i}`:"")}}function m({invalidTypeMsg:r,minMsg:t,maxMsg:e,min:a=-Number.MAX_VALUE,max:i=Number.MAX_VALUE}={}){return n=>{let s=Number.MAX_VALUE;return`${n??""}`.length===0?"":(typeof n=="string"&&(s=parseFloat(n)),typeof n=="number"&&(s=n),isNaN(s)?r||"Must be a numeric value":s>i?e||`Must be less than or equal to ${i}`:s<a?t||`Must be greater than or equal to ${a}`:"")}}function L({invalidTypeMsg:r,minMsg:t,maxMsg:e,min:a=-Number.MAX_VALUE,max:i=Number.MAX_VALUE}){return n=>`${n||""}`.length===0?"":typeof n!="string"?r||"Invalid type":n.length>i?e||`Must be less than ${i} characters`:n.length<a?t||`Must be greater than ${a} characters`:""}var f,T,A;class q{constructor(t){g(this,f);l(this,"state");l(this,"_formData");l(this,"_formRef");this.type=t}init(t){if(this._formRef){console.warn("init: form element has already been set");return}this._formRef=t.detail.el,this.state={uuid:crypto.randomUUID(),form:{},history:[],editting:"",status:"not-started"}}initList(t){this._formRef=t.detail.el,this.state=[]}initState(t,e){d(this._formRef,"external::init:state",t),typeof t=="string"?this.state=JSON.parse(t):Array.isArray(t)||(this.state=t),e&&setTimeout(e,200)}updateListState(t){const e=t.detail;Array.isArray(e.data)&&(this.state=e.data)}updateObjectState(t){var a,i;if(Array.isArray(this.state))return;const e=t.detail;e.type==="list"?this.state={...this.state,form:{...((a=this.state)==null?void 0:a.form)||{},[e.id]:e.data}}:this.state={...this.state,...e.data,form:{...((i=this.state)==null?void 0:i.form)||{},...e.data.form},history:e.data.history}}getStateList(){return this.state?Array.isArray(this.state)?this.state.length===0?[]:this.state.map(t=>Object.values(t.form).filter(e=>{var a;return((a=e==null?void 0:e.data)==null?void 0:a.type)==="details"}).map(e=>{var a;return e.data.type==="details"&&((a=e.data)==null?void 0:a.fieldsets)||{}}).reduce((e,a)=>{for(const[i,n]of Object.entries(a))e[i]=n.value;return e},{})):(console.warn("Utils:getStateList: unable to update the state of a non-multi form type",this.state),[]):[]}getStateValue(t,e){if(Array.isArray(this.state))return console.error("getStateValue: unable to update the state of a multi form type"),"";if(!this.state)return console.error("getStateValue: state has not yet been set"),"";const a=this.state.form[t].data;return a.type!=="details"?"":a.fieldsets[e].value}continueTo(t){if(!t){console.error("continueTo [name] is undefined");return}d(this._formRef,"external::continue",{next:t})}validate(t,e,a,i){var b;const{el:n,state:s,cancelled:o}=t.detail,u=(b=s==null?void 0:s[e])==null?void 0:b.value;if(window.scrollTo({top:0,behavior:"smooth"}),o)return[!0,u];for(const v of a){const p=v(u);if(V(this,f,A).call(this,n,e,p,i),p)return[!1,""]}return[!0,u]}validateGroup(t,e,a){let i=0;const n={};for(const s of e){const[o]=this.validate(t,s,a,{grouped:!0});o&&(n[s]=!0,i++)}return[i,n]}edit(t){d(this._formRef,"external::alter:state",{index:t,operation:"edit"})}remove(t){d(this._formRef,"external::alter:state",{index:t,operation:"remove"})}clean(t){return t.history.reduce((e,a)=>(e[a]=t.form[a],e),{})}}f=new WeakSet,T=function(t){var e;Array.isArray(t.data)&&(Array.isArray(this.state)||(this.state={...this.state,form:{...((e=this.state)==null?void 0:e.form)||{},[t.id]:t.data}}))},A=function(t,e,a,i){t.dispatchEvent(new CustomEvent("msg",{composed:!0,detail:{action:"external::set:error",data:{name:e,msg:a,grouped:i==null?void 0:i.grouped}}}))};function U(r,t,e,a){if(!r){console.error("dispatch element is null");return}r.dispatchEvent(new CustomEvent(t,{composed:!0,bubbles:a==null?void 0:a.bubbles,detail:e}))}function d(r,t,e,a){if(!r){console.error("dispatch element is null");return}r.dispatchEvent(new CustomEvent("msg",{composed:!0,bubbles:a==null?void 0:a.bubbles,detail:{action:t,data:e}}))}exports.FormValidator=E;exports.PublicFormController=q;exports.SINValidator=x;exports.birthDayValidator=w;exports.birthMonthValidator=_;exports.birthYearValidator=D;exports.dateValidator=C;exports.dispatch=U;exports.emailValidator=$;exports.lengthValidator=L;exports.numericValidator=m;exports.phoneNumberValidator=R;exports.postalCodeValidator=I;exports.regexValidator=h;exports.relay=d;exports.requiredValidator=c;
1
+ "use strict";var M=Object.defineProperty;var y=r=>{throw TypeError(r)};var S=(r,t,e)=>t in r?M(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var l=(r,t,e)=>S(r,typeof t!="symbol"?t+"":t,e),N=(r,t,e)=>t.has(r)||y("Cannot "+e);var g=(r,t,e)=>t.has(r)?y("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e);var V=(r,t,e)=>(N(r,t,"access private method"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class E{constructor(t){l(this,"validators");this.validators=t||{}}add(t,...e){this.validators[t]=e}validate(t){const e={};return Object.entries(this.validators).forEach(([a,i])=>{const n=i.map(s=>s(t[a])).find(s=>!!s);n&&(e[a]=n)}),e}}function w(){return[c("Day is required"),m({min:1,max:31,minMsg:"Day must be between 1 and 31",maxMsg:"Day must be between 1 and 31"})]}function _(){return[c("Month is required"),m({min:0,max:11,minMsg:"Month must be between Jan and Dec",maxMsg:"Month must be between Jan and Dec"})]}function D(){const r=new Date().getFullYear();return[c("Year is required"),m({min:1900,max:r,minMsg:"Year must be greater than 1900",maxMsg:`Year must be less than ${r}`})]}function c(r){return t=>(r=r||"Required",typeof t=="number"&&!isNaN(t)||t?"":r)}function R(r){const t=new RegExp(/^\+?[\d-() ]{10,18}$/);return h(t,r||"Invalid phone number")}function $(r){const t=new RegExp(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);return h(t,r||"Invalid email address")}function x(){return r=>{if(!r)return"";const t="121212121".split("").map(i=>parseInt(i)),e=r.replace(/\D/g,"");return e.length!==9?"SIN must contain 9 numbers":e.split("").map(i=>parseInt(i)).map((i,n)=>{const s=i*t[n];return s<10?s:`${s}`.split("").map(o=>parseInt(o)).reduce((o,u)=>o+u,0)}).reduce((i,n)=>i+n,0)%10===0?"":"Invalid SIN"}}function I(){return h(/^[ABCEGHJ-NPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ -]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,"Invalid postal code")}function h(r,t){return e=>!e||e.match(r)?"":t}function C({invalidMsg:r,minMsg:t,maxMsg:e,min:a,max:i}={}){return n=>{let s=new Date(-1);return`${n||""}`.length===0?"":(typeof n=="string"&&(s=new Date(n)),typeof n=="number"&&(s=new Date(n)),n.toDateString&&(s=n),s.getDate()===-1?r||"Invalid date":a&&s<a?t||`Must be after ${a}`:i&&s>i?e||`Must be before ${i}`:"")}}function m({invalidTypeMsg:r,minMsg:t,maxMsg:e,min:a=-Number.MAX_VALUE,max:i=Number.MAX_VALUE}={}){return n=>{let s=Number.MAX_VALUE;return`${n??""}`.length===0?"":(typeof n=="string"&&(s=parseFloat(n)),typeof n=="number"&&(s=n),isNaN(s)?r||"Must be a numeric value":s>i?e||`Must be less than or equal to ${i}`:s<a?t||`Must be greater than or equal to ${a}`:"")}}function L({invalidTypeMsg:r,minMsg:t,maxMsg:e,min:a=-Number.MAX_VALUE,max:i=Number.MAX_VALUE}){return n=>`${n||""}`.length===0?"":typeof n!="string"?r||"Invalid type":n.length>i?e||`Must be less than ${i} characters`:n.length<a?t||`Must be greater than ${a} characters`:""}var f,T,A;class q{constructor(t){g(this,f);l(this,"state");l(this,"_formData");l(this,"_formRef");this.type=t}init(t){if(this._formRef){console.warn("init: form element has already been set");return}this._formRef=t.el,this.state={uuid:crypto.randomUUID(),form:{},history:[],editting:"",status:"not-started"}}initList(t){this._formRef=t.detail.el,this.state=[]}initState(t,e){d(this._formRef,"external::init:state",t),typeof t=="string"?this.state=JSON.parse(t):Array.isArray(t)||(this.state=t),e&&setTimeout(e,200)}updateListState(t){const e=t.detail;Array.isArray(e.data)&&(this.state=e.data)}updateObjectState(t){var a,i;if(Array.isArray(this.state))return;const e=t.detail;e.type==="list"?this.state={...this.state,form:{...((a=this.state)==null?void 0:a.form)||{},[e.id]:e.data}}:this.state={...this.state,...e.data,form:{...((i=this.state)==null?void 0:i.form)||{},...e.data.form},history:e.data.history}}getStateList(){return this.state?Array.isArray(this.state)?this.state.length===0?[]:this.state.map(t=>Object.values(t.form).filter(e=>{var a;return((a=e==null?void 0:e.data)==null?void 0:a.type)==="details"}).map(e=>{var a;return e.data.type==="details"&&((a=e.data)==null?void 0:a.fieldsets)||{}}).reduce((e,a)=>{for(const[i,n]of Object.entries(a))e[i]=n.value;return e},{})):(console.warn("Utils:getStateList: unable to update the state of a non-multi form type",this.state),[]):[]}getStateValue(t,e){if(Array.isArray(this.state))return console.error("getStateValue: unable to update the state of a multi form type"),"";if(!this.state)return console.error("getStateValue: state has not yet been set"),"";const a=this.state.form[t].data;return a.type!=="details"?"":a.fieldsets[e].value}continueTo(t){if(!t){console.error("continueTo [name] is undefined");return}d(this._formRef,"external::continue",{next:t})}validate(t,e,a,i){var b;const{el:n,state:s,cancelled:o}=t,u=(b=s==null?void 0:s[e])==null?void 0:b.value;if(window.scrollTo({top:0,behavior:"smooth"}),o)return[!0,u];for(const v of a){const p=v(u);if(V(this,f,A).call(this,n,e,p,i),p)return[!1,""]}return[!0,u]}validateGroup(t,e,a){let i=0;const n={};for(const s of e){const[o]=this.validate(t,s,a,{grouped:!0});o&&(n[s]=!0,i++)}return[i,n]}edit(t){d(this._formRef,"external::alter:state",{index:t,operation:"edit"})}remove(t){d(this._formRef,"external::alter:state",{index:t,operation:"remove"})}clean(t){return t.history.reduce((e,a)=>(e[a]=t.form[a],e),{})}}f=new WeakSet,T=function(t){var e;Array.isArray(t.data)&&(Array.isArray(this.state)||(this.state={...this.state,form:{...((e=this.state)==null?void 0:e.form)||{},[t.id]:t.data}}))},A=function(t,e,a,i){t.dispatchEvent(new CustomEvent("msg",{composed:!0,detail:{action:"external::set:error",data:{name:e,msg:a,grouped:i==null?void 0:i.grouped}}}))};function U(r,t,e,a){if(!r){console.error("dispatch element is null");return}r.dispatchEvent(new CustomEvent(t,{composed:!0,bubbles:a==null?void 0:a.bubbles,detail:e}))}function d(r,t,e,a){if(!r){console.error("dispatch element is null");return}r.dispatchEvent(new CustomEvent("msg",{composed:!0,bubbles:a==null?void 0:a.bubbles,detail:{action:t,data:e}}))}exports.FormValidator=E;exports.PublicFormController=q;exports.SINValidator=x;exports.birthDayValidator=w;exports.birthMonthValidator=_;exports.birthYearValidator=D;exports.dateValidator=C;exports.dispatch=U;exports.emailValidator=$;exports.lengthValidator=L;exports.numericValidator=m;exports.phoneNumberValidator=R;exports.postalCodeValidator=I;exports.regexValidator=h;exports.relay=d;exports.requiredValidator=c;
package/index.js CHANGED
@@ -3,12 +3,12 @@ var y = (r) => {
3
3
  throw TypeError(r);
4
4
  };
5
5
  var S = (r, t, e) => t in r ? M(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
6
- var l = (r, t, e) => S(r, typeof t != "symbol" ? t + "" : t, e), E = (r, t, e) => t.has(r) || y("Cannot " + e);
6
+ var f = (r, t, e) => S(r, typeof t != "symbol" ? t + "" : t, e), E = (r, t, e) => t.has(r) || y("Cannot " + e);
7
7
  var g = (r, t, e) => t.has(r) ? y("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e);
8
8
  var A = (r, t, e) => (E(r, t, "access private method"), e);
9
9
  class _ {
10
10
  constructor(t) {
11
- l(this, "validators");
11
+ f(this, "validators");
12
12
  this.validators = t || {};
13
13
  }
14
14
  add(t, ...e) {
@@ -121,13 +121,13 @@ function q({
121
121
  }) {
122
122
  return (i) => `${i || ""}`.length === 0 ? "" : typeof i != "string" ? r || "Invalid type" : i.length > n ? e || `Must be less than ${n} characters` : i.length < a ? t || `Must be greater than ${a} characters` : "";
123
123
  }
124
- var f, w, v;
124
+ var l, w, v;
125
125
  class T {
126
126
  constructor(t) {
127
- g(this, f);
128
- l(this, "state");
129
- l(this, "_formData");
130
- l(this, "_formRef");
127
+ g(this, l);
128
+ f(this, "state");
129
+ f(this, "_formData");
130
+ f(this, "_formRef");
131
131
  this.type = t;
132
132
  }
133
133
  // Obtain reference to the form element
@@ -136,7 +136,7 @@ class T {
136
136
  console.warn("init: form element has already been set");
137
137
  return;
138
138
  }
139
- this._formRef = t.detail.el, this.state = {
139
+ this._formRef = t.el, this.state = {
140
140
  uuid: crypto.randomUUID(),
141
141
  form: {},
142
142
  history: [],
@@ -228,12 +228,12 @@ class T {
228
228
  // Public method to perform validation and send the appropriate messages to the form elements
229
229
  validate(t, e, a, n) {
230
230
  var b;
231
- const { el: i, state: s, cancelled: o } = t.detail, u = (b = s == null ? void 0 : s[e]) == null ? void 0 : b.value;
231
+ const { el: i, state: s, cancelled: o } = t, u = (b = s == null ? void 0 : s[e]) == null ? void 0 : b.value;
232
232
  if (window.scrollTo({ top: 0, behavior: "smooth" }), o)
233
233
  return [!0, u];
234
234
  for (const V of a) {
235
235
  const p = V(u);
236
- if (A(this, f, v).call(this, i, e, p, n), p)
236
+ if (A(this, l, v).call(this, i, e, p, n), p)
237
237
  return [!1, ""];
238
238
  }
239
239
  return [!0, u];
@@ -270,7 +270,7 @@ class T {
270
270
  return t.history.reduce((e, a) => (e[a] = t.form[a], e), {});
271
271
  }
272
272
  }
273
- f = new WeakSet(), w = function(t) {
273
+ l = new WeakSet(), w = function(t) {
274
274
  var e;
275
275
  Array.isArray(t.data) && (Array.isArray(this.state) || (this.state = {
276
276
  ...this.state,
package/lib/common.d.ts CHANGED
@@ -244,20 +244,10 @@ export type GoabTextHeadingSize = "heading-xl" | "heading-l" | "heading-m" | "he
244
244
  export type GoabTextBodySize = "body-l" | "body-m" | "body-s" | "body-xs";
245
245
  export type GoabTextSize = GoabTextHeadingSize | GoabTextBodySize;
246
246
  export type GoabTextColor = "primary" | "secondary";
247
- export type GoabFielsetOnContinueDetail = {
248
- el: HTMLElement;
249
- state: Record<string, string>;
250
- };
251
247
  export type GoabFormField = {
252
248
  label: string;
253
249
  value: string;
254
250
  };
255
- export type GoabFormState = {
256
- form: Record<string, Record<string, GoabFormField>>;
257
- history: string[];
258
- editting: string;
259
- lastModified?: Date;
260
- };
261
251
  export type GoabFormStorageType = "none" | "local" | "session";
262
252
  export type GoabFormOnMountDetail = {
263
253
  fn: (next: string) => void;
@@ -266,6 +256,70 @@ export type GoabFormOnStateChange = {
266
256
  id: string;
267
257
  state: Record<string, Record<string, GoabFormField>>;
268
258
  };
259
+ export type GoabFormStatus = "not-started" | "cannot-start-yet" | "in-progress" | "submitted" | "update-needed" | "complete";
260
+ export type GoabFormState = {
261
+ uuid: string;
262
+ form: Record<string, GoabFieldsetSchema>;
263
+ history: string[];
264
+ editting: string;
265
+ lastModified?: Date;
266
+ status: GoabFormStatus;
267
+ };
268
+ export type GoabFormDispatchOn = "change" | "continue";
269
+ export type GoabFieldsetItemValue = string | number | Date;
270
+ export type GoabFieldsetItemState = {
271
+ name: string;
272
+ label: string;
273
+ value: GoabFieldsetItemValue;
274
+ order: number;
275
+ };
276
+ export type GoabFieldsetData = {
277
+ type: "details";
278
+ fieldsets: Record<string, GoabFieldsetItemState>;
279
+ } | {
280
+ type: "list";
281
+ items: GoabFormState[];
282
+ };
283
+ export type GoabFieldsetSchema = {
284
+ heading?: string;
285
+ data?: GoabFieldsetData;
286
+ };
287
+ export interface GoabFieldsetOnChangeDetail {
288
+ id: string;
289
+ state: {
290
+ data: Record<string, GoabFieldsetItemState>;
291
+ };
292
+ dispatchOn: GoabFormDispatchOn;
293
+ }
294
+ export interface GoabFieldsetOnContinueDetail {
295
+ el: HTMLElement;
296
+ state: Record<string, GoabFieldsetItemState>;
297
+ cancelled: boolean;
298
+ }
299
+ export type GoabPublicFormStatus = "initializing" | "complete";
300
+ export type GoabPublicFormOnInitDetail = {
301
+ el: HTMLFormElement;
302
+ };
303
+ export type GoabPublicFormPageStep = "step" | "summary" | "multistep";
304
+ export type GoabPublicFormPageButtonVisibility = "visible" | "hidden";
305
+ export type GoabPublicFormPageOnContinueDetail = {
306
+ el: HTMLElement;
307
+ state: Record<string, GoabFieldsetItemState>;
308
+ cancelled: boolean;
309
+ };
310
+ export type GoabPublicFormPageOnFieldsetChangeDetail = {
311
+ id: string;
312
+ state: {
313
+ heading?: string;
314
+ data: Record<string, GoabFieldsetItemState>;
315
+ };
316
+ dispatchOn: GoabFormDispatchOn;
317
+ };
318
+ export type GoabPublicFormPageOnCompleteDetail = {
319
+ el: HTMLElement;
320
+ state: Record<string, GoabFieldsetItemState>;
321
+ cancelled: boolean;
322
+ };
269
323
  export type GoabDrawerPosition = "bottom" | "left" | "right" | undefined;
270
324
  export type GoabDrawerSizeUnit = "px" | "rem" | "ch" | "vh" | "vw";
271
325
  export type GoabDrawerSize = `${number}${GoabDrawerSizeUnit}` | undefined;
@@ -1,3 +1,4 @@
1
+ import { GoabFieldsetItemValue, GoabFormDispatchOn, GoabPublicFormOnInitDetail, GoabPublicFormPageOnContinueDetail } from './common';
1
2
  import { FieldsetItemState, FieldValidator } from './validators';
2
3
 
3
4
  export type FormStatus = "not-started" | "incomplete" | "complete";
@@ -10,7 +11,7 @@ export type AppState<T> = {
10
11
  status: FormStatus;
11
12
  currentFieldset?: {
12
13
  id: T;
13
- dispatchType: "change" | "continue";
14
+ dispatchType: GoabFormDispatchOn;
14
15
  };
15
16
  };
16
17
  export type Fieldset<T> = {
@@ -30,7 +31,7 @@ export declare class PublicFormController<T> {
30
31
  _formData?: Record<string, string>;
31
32
  _formRef?: HTMLElement;
32
33
  constructor(type: "details" | "list");
33
- init(e: Event): void;
34
+ init(e: GoabPublicFormOnInitDetail): void;
34
35
  initList(e: Event): void;
35
36
  initState(state?: string | AppState<T> | AppState<T>[], callback?: () => void): void;
36
37
  updateListState(e: Event): void;
@@ -38,9 +39,9 @@ export declare class PublicFormController<T> {
38
39
  getStateList(): Record<string, string>[];
39
40
  getStateValue(group: string, key: string): string;
40
41
  continueTo(next: T | undefined): void;
41
- validate(e: Event, field: string, validators: FieldValidator[], options?: {
42
+ validate(e: GoabPublicFormPageOnContinueDetail, field: string, validators: FieldValidator[], options?: {
42
43
  grouped: boolean;
43
- }): [boolean, string];
44
+ }): [boolean, GoabFieldsetItemValue];
44
45
  /**
45
46
  * Validates a group of fields ensuring that at least `minPassCount` of the items within the group
46
47
  * passes. This is useful in the scenario when n number fields are required out of n+m number of fields.
@@ -50,7 +51,7 @@ export declare class PublicFormController<T> {
50
51
  * @param {FieldValidator[]} validators - An array of validator functions to apply to the fields.
51
52
  * @return {[number, Record<string, boolean>]} - Returns back the number of fields that passed and a record of the fields and their pass status.
52
53
  */
53
- validateGroup(e: Event, fields: string[], validators: FieldValidator[]): [number, Record<string, boolean>];
54
+ validateGroup(e: GoabPublicFormPageOnContinueDetail, fields: string[], validators: FieldValidator[]): [number, Record<string, boolean>];
54
55
  edit(index: number): void;
55
56
  remove(index: number): void;
56
57
  clean(data: AppState<T>): Record<string, unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/ui-components-common",
3
- "version": "1.3.0",
3
+ "version": "1.4.0-alpha.1",
4
4
  "bugs": {
5
5
  "url": "https://github.com/GovAlta/ui-components/issues"
6
6
  },