@abgov/ui-components-common 1.1.0 → 1.2.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 A=Object.defineProperty;var p=r=>{throw TypeError(r)};var M=(r,t,e)=>t in r?A(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var u=(r,t,e)=>M(r,typeof t!="symbol"?t+"":t,e),v=(r,t,e)=>t.has(r)||p("Cannot "+e);var y=(r,t,e)=>t.has(r)?p("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e);var g=(r,t,e)=>(v(r,t,"access private method"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class S{constructor(t){u(this,"validators");this.validators=t||{}}add(t,...e){this.validators[t]=e}validate(t){const e={};return Object.entries(this.validators).forEach(([a,n])=>{const s=n.map(i=>i(t[a])).find(i=>!!i);s&&(e[a]=s)}),e}}function E(){return[f("Day is required"),h({min:1,max:31,minMsg:"Day must be between 1 and 31",maxMsg:"Day must be between 1 and 31"})]}function N(){return[f("Month is required"),h({min:0,max:11,minMsg:"Month must be between Jan and Dec",maxMsg:"Month must be between Jan and Dec"})]}function _(){const r=new Date().getFullYear();return[f("Year is required"),h({min:1900,max:r,minMsg:"Year must be greater than 1900",maxMsg:`Year must be less than ${r}`})]}function f(r){return t=>(r=r||"Required",typeof t=="number"&&!isNaN(t)||t?"":r)}function R(r){const t=new RegExp(/^\+?[\d-() ]{10,18}$/);return c(t,r||"Invalid phone number")}function D(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 c(t,r||"Invalid email address")}function w(){return r=>{if(!r)return"";const t="121212121".split("").map(n=>parseInt(n)),e=r.replace(/\D/g,"");return e.length!==9?"SIN must contain 9 numbers":e.split("").map(n=>parseInt(n)).map((n,s)=>{const i=n*t[s];return i<10?i:`${i}`.split("").map(o=>parseInt(o)).reduce((o,m)=>o+m,0)}).reduce((n,s)=>n+s,0)%10===0?"":"Invalid SIN"}}function I(){return c(/^[ABCEGHJ-NPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ -]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,"Invalid postal code")}function c(r,t){return e=>!e||e.match(r)?"":t}function x({invalidMsg:r,minMsg:t,maxMsg:e,min:a,max:n}){return s=>{let i=new Date(0);return typeof s=="string"&&(i=new Date(s)),s.toDateString&&(i=s),i.toString()==="Invalid Date"||i.getTime()===0?r||"Invalid date":i&&a&&i<a?t||`Must be after ${a}`:i&&n&&i>n?e||`Must be before ${n}`:""}}function h({invalidTypeMsg:r,minMsg:t,maxMsg:e,min:a=-Number.MAX_VALUE,max:n=Number.MAX_VALUE}){return s=>{let i=Number.MAX_VALUE;return typeof s=="string"&&(i=parseFloat(s)),typeof s=="number"&&(i=s),isNaN(i)?r||"Must be a numeric value":i>n?e||`Must be less than or equal to ${n}`:i<a?t||`Must be greater than or equal to ${a}`:""}}function $({invalidTypeMsg:r,minMsg:t,maxMsg:e,min:a=-Number.MAX_VALUE,max:n=Number.MAX_VALUE,optional:s}){return i=>s&&`${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`:""}var d,L,V;class C{constructor(t){y(this,d);u(this,"state");u(this,"_formData");u(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){l(this._formRef,"external::init:state",t),e&&setTimeout(e,200)}updateListState(t){const e=t.detail;Array.isArray(e.data)&&(this.state=e.data)}updateObjectState(t){var a,n;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,form:{...((n=this.state)==null?void 0:n.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[n,s]of Object.entries(a))e[n]=s.value;return e},{})):(console.warn("Utils:getStateList: unable to update the state of a non-multi form type",this.state),[]):[]}continueTo(t){if(!t){console.error("continueTo [name] is undefined");return}console.log("continueTo: TYPE",{type:this.type,state:this.state,formRef:this._formRef,next:t}),l(this._formRef,"external::continue",{next:t})}validate(t,e,a){var o;const{el:n,state:s}=e.detail,i=(o=s==null?void 0:s[t])==null?void 0:o.value;for(const m of a){const b=m(i);if(g(this,d,V).call(this,n,t,b),b)return[!1,""]}return[!0,i]}edit(t){l(this._formRef,"external::alter:state",{index:t,operation:"edit"})}remove(t){l(this._formRef,"external::alter:state",{index:t,operation:"remove"})}clean(){var e;if(Array.isArray(this.state))return;const t=this.state;return(e=this.state)==null?void 0:e.history.reduce((a,n)=>(a[n]=t==null?void 0:t.form[n],a),{})}}d=new WeakSet,L=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}}))},V=function(t,e,a){t.dispatchEvent(new CustomEvent("msg",{composed:!0,detail:{action:"external::set:error",data:{name:e,msg:a}}}))};function T(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 l(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=S;exports.PublicFormController=C;exports.SINValidator=w;exports.birthDayValidator=E;exports.birthMonthValidator=N;exports.birthYearValidator=_;exports.dateValidator=x;exports.dispatch=T;exports.emailValidator=D;exports.lengthValidator=$;exports.numericValidator=h;exports.phoneNumberValidator=R;exports.postalCodeValidator=I;exports.regexValidator=c;exports.relay=l;exports.requiredValidator=f;
1
+ "use strict";var A=Object.defineProperty;var p=r=>{throw TypeError(r)};var M=(r,t,e)=>t in r?A(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var u=(r,t,e)=>M(r,typeof t!="symbol"?t+"":t,e),v=(r,t,e)=>t.has(r)||p("Cannot "+e);var y=(r,t,e)=>t.has(r)?p("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e);var g=(r,t,e)=>(v(r,t,"access private method"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class E{constructor(t){u(this,"validators");this.validators=t||{}}add(t,...e){this.validators[t]=e}validate(t){const e={};return Object.entries(this.validators).forEach(([a,n])=>{const i=n.map(s=>s(t[a])).find(s=>!!s);i&&(e[a]=i)}),e}}function S(){return[f("Day is required"),h({min:1,max:31,minMsg:"Day must be between 1 and 31",maxMsg:"Day must be between 1 and 31"})]}function N(){return[f("Month is required"),h({min:0,max:11,minMsg:"Month must be between Jan and Dec",maxMsg:"Month must be between Jan and Dec"})]}function _(){const r=new Date().getFullYear();return[f("Year is required"),h({min:1900,max:r,minMsg:"Year must be greater than 1900",maxMsg:`Year must be less than ${r}`})]}function f(r){return t=>(r=r||"Required",typeof t=="number"&&!isNaN(t)||t?"":r)}function D(r){const t=new RegExp(/^\+?[\d-() ]{10,18}$/);return c(t,r||"Invalid phone number")}function R(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 c(t,r||"Invalid email address")}function w(){return r=>{if(!r)return"";const t="121212121".split("").map(n=>parseInt(n)),e=r.replace(/\D/g,"");return e.length!==9?"SIN must contain 9 numbers":e.split("").map(n=>parseInt(n)).map((n,i)=>{const s=n*t[i];return s<10?s:`${s}`.split("").map(o=>parseInt(o)).reduce((o,m)=>o+m,0)}).reduce((n,i)=>n+i,0)%10===0?"":"Invalid SIN"}}function $(){return c(/^[ABCEGHJ-NPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ -]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,"Invalid postal code")}function c(r,t){return e=>!e||e.match(r)?"":t}function I({invalidMsg:r,minMsg:t,maxMsg:e,min:a,max:n}={}){return i=>{let s=new Date(-1);return`${i||""}`.length===0?"":(typeof i=="string"&&(s=new Date(i)),typeof i=="number"&&(s=new Date(i)),i.toDateString&&(s=i),s.getDate()===-1?r||"Invalid date":a&&s<a?t||`Must be after ${a}`:n&&s>n?e||`Must be before ${n}`:"")}}function h({invalidTypeMsg:r,minMsg:t,maxMsg:e,min:a=-Number.MAX_VALUE,max:n=Number.MAX_VALUE}={}){return i=>{let s=Number.MAX_VALUE;return`${i??""}`.length===0?"":(typeof i=="string"&&(s=parseFloat(i)),typeof i=="number"&&(s=i),isNaN(s)?r||"Must be a numeric value":s>n?e||`Must be less than or equal to ${n}`:s<a?t||`Must be greater than or equal to ${a}`:"")}}function x({invalidTypeMsg:r,minMsg:t,maxMsg:e,min:a=-Number.MAX_VALUE,max:n=Number.MAX_VALUE}){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`:""}var d,L,V;class C{constructor(t){y(this,d);u(this,"state");u(this,"_formData");u(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){l(this._formRef,"external::init:state",t),e&&setTimeout(e,200)}updateListState(t){const e=t.detail;Array.isArray(e.data)&&(this.state=e.data)}updateObjectState(t){var a,n;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,form:{...((n=this.state)==null?void 0:n.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[n,i]of Object.entries(a))e[n]=i.value;return e},{})):(console.warn("Utils:getStateList: unable to update the state of a non-multi form type",this.state),[]):[]}continueTo(t){if(!t){console.error("continueTo [name] is undefined");return}console.log("continueTo: TYPE",{type:this.type,state:this.state,formRef:this._formRef,next:t}),l(this._formRef,"external::continue",{next:t})}validate(t,e,a){var o;const{el:n,state:i}=e.detail,s=(o=i==null?void 0:i[t])==null?void 0:o.value;for(const m of a){const b=m(s);if(g(this,d,V).call(this,n,t,b),b)return[!1,""]}return[!0,s]}edit(t){l(this._formRef,"external::alter:state",{index:t,operation:"edit"})}remove(t){l(this._formRef,"external::alter:state",{index:t,operation:"remove"})}clean(){var e;if(Array.isArray(this.state))return;const t=this.state;return(e=this.state)==null?void 0:e.history.reduce((a,n)=>(a[n]=t==null?void 0:t.form[n],a),{})}}d=new WeakSet,L=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}}))},V=function(t,e,a){t.dispatchEvent(new CustomEvent("msg",{composed:!0,detail:{action:"external::set:error",data:{name:e,msg:a}}}))};function T(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 l(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=C;exports.SINValidator=w;exports.birthDayValidator=S;exports.birthMonthValidator=N;exports.birthYearValidator=_;exports.dateValidator=I;exports.dispatch=T;exports.emailValidator=R;exports.lengthValidator=x;exports.numericValidator=h;exports.phoneNumberValidator=D;exports.postalCodeValidator=$;exports.regexValidator=c;exports.relay=l;exports.requiredValidator=f;
package/index.js CHANGED
@@ -2,11 +2,11 @@ var M = Object.defineProperty;
2
2
  var p = (r) => {
3
3
  throw TypeError(r);
4
4
  };
5
- var v = (r, t, e) => t in r ? M(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
6
- var u = (r, t, e) => v(r, typeof t != "symbol" ? t + "" : t, e), V = (r, t, e) => t.has(r) || p("Cannot " + e);
5
+ var V = (r, t, e) => t in r ? M(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
6
+ var u = (r, t, e) => V(r, typeof t != "symbol" ? t + "" : t, e), v = (r, t, e) => t.has(r) || p("Cannot " + e);
7
7
  var y = (r, t, e) => t.has(r) ? p("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e);
8
- var g = (r, t, e) => (V(r, t, "access private method"), e);
9
- class _ {
8
+ var g = (r, t, e) => (v(r, t, "access private method"), e);
9
+ class N {
10
10
  constructor(t) {
11
11
  u(this, "validators");
12
12
  this.validators = t || {};
@@ -16,13 +16,13 @@ class _ {
16
16
  }
17
17
  validate(t) {
18
18
  const e = {};
19
- return Object.entries(this.validators).forEach(([a, i]) => {
20
- const s = i.map((n) => n(t[a])).find((n) => !!n);
21
- s && (e[a] = s);
19
+ return Object.entries(this.validators).forEach(([n, i]) => {
20
+ const a = i.map((s) => s(t[n])).find((s) => !!s);
21
+ a && (e[n] = a);
22
22
  }), e;
23
23
  }
24
24
  }
25
- function N() {
25
+ function R() {
26
26
  return [
27
27
  c("Day is required"),
28
28
  m({
@@ -33,7 +33,7 @@ function N() {
33
33
  })
34
34
  ];
35
35
  }
36
- function R() {
36
+ function S() {
37
37
  return [
38
38
  c("Month is required"),
39
39
  m({
@@ -63,7 +63,7 @@ function D(r) {
63
63
  const t = new RegExp(/^\+?[\d-() ]{10,18}$/);
64
64
  return h(t, r || "Invalid phone number");
65
65
  }
66
- function I(r) {
66
+ function $(r) {
67
67
  const t = new RegExp(
68
68
  /^(([^<>()[\]\\.,;:\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,}))$/
69
69
  );
@@ -73,13 +73,13 @@ function x() {
73
73
  return (r) => {
74
74
  if (!r) return "";
75
75
  const t = "121212121".split("").map((i) => parseInt(i)), e = r.replace(/\D/g, "");
76
- return e.length !== 9 ? "SIN must contain 9 numbers" : e.split("").map((i) => parseInt(i)).map((i, s) => {
77
- const n = i * t[s];
78
- return n < 10 ? n : `${n}`.split("").map((o) => parseInt(o)).reduce((o, d) => o + d, 0);
79
- }).reduce((i, s) => i + s, 0) % 10 === 0 ? "" : "Invalid SIN";
76
+ return e.length !== 9 ? "SIN must contain 9 numbers" : e.split("").map((i) => parseInt(i)).map((i, a) => {
77
+ const s = i * t[a];
78
+ return s < 10 ? s : `${s}`.split("").map((o) => parseInt(o)).reduce((o, d) => o + d, 0);
79
+ }).reduce((i, a) => i + a, 0) % 10 === 0 ? "" : "Invalid SIN";
80
80
  };
81
81
  }
82
- function $() {
82
+ function I() {
83
83
  return h(
84
84
  /^[ABCEGHJ-NPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ -]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,
85
85
  "Invalid postal code"
@@ -92,38 +92,37 @@ function L({
92
92
  invalidMsg: r,
93
93
  minMsg: t,
94
94
  maxMsg: e,
95
- min: a,
95
+ min: n,
96
96
  max: i
97
- }) {
98
- return (s) => {
99
- let n = /* @__PURE__ */ new Date(0);
100
- return typeof s == "string" && (n = new Date(s)), s.toDateString && (n = s), n.toString() === "Invalid Date" || n.getTime() === 0 ? r || "Invalid date" : n && a && n < a ? t || `Must be after ${a}` : n && i && n > i ? e || `Must be before ${i}` : "";
97
+ } = {}) {
98
+ return (a) => {
99
+ let s = /* @__PURE__ */ new Date(-1);
100
+ return `${a || ""}`.length === 0 ? "" : (typeof a == "string" && (s = new Date(a)), typeof a == "number" && (s = new Date(a)), a.toDateString && (s = a), s.getDate() === -1 ? r || "Invalid date" : n && s < n ? t || `Must be after ${n}` : i && s > i ? e || `Must be before ${i}` : "");
101
101
  };
102
102
  }
103
103
  function m({
104
104
  invalidTypeMsg: r,
105
105
  minMsg: t,
106
106
  maxMsg: e,
107
- min: a = -Number.MAX_VALUE,
107
+ min: n = -Number.MAX_VALUE,
108
108
  max: i = Number.MAX_VALUE
109
- }) {
110
- return (s) => {
111
- let n = Number.MAX_VALUE;
112
- return typeof s == "string" && (n = parseFloat(s)), typeof s == "number" && (n = s), isNaN(n) ? r || "Must be a numeric value" : n > i ? e || `Must be less than or equal to ${i}` : n < a ? t || `Must be greater than or equal to ${a}` : "";
109
+ } = {}) {
110
+ return (a) => {
111
+ let s = Number.MAX_VALUE;
112
+ return `${a ?? ""}`.length === 0 ? "" : (typeof a == "string" && (s = parseFloat(a)), typeof a == "number" && (s = a), isNaN(s) ? r || "Must be a numeric value" : s > i ? e || `Must be less than or equal to ${i}` : s < n ? t || `Must be greater than or equal to ${n}` : "");
113
113
  };
114
114
  }
115
- function T({
115
+ function C({
116
116
  invalidTypeMsg: r,
117
117
  minMsg: t,
118
118
  maxMsg: e,
119
- min: a = -Number.MAX_VALUE,
120
- max: i = Number.MAX_VALUE,
121
- optional: s
119
+ min: n = -Number.MAX_VALUE,
120
+ max: i = Number.MAX_VALUE
122
121
  }) {
123
- return (n) => s && `${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` : "";
122
+ return (a) => `${a || ""}`.length === 0 ? "" : typeof a != "string" ? r || "Invalid type" : a.length > i ? e || `Must be less than ${i} characters` : a.length < n ? t || `Must be greater than ${n} characters` : "";
124
123
  }
125
124
  var f, E, A;
126
- class C {
125
+ class T {
127
126
  constructor(t) {
128
127
  y(this, f);
129
128
  u(this, "state");
@@ -157,13 +156,13 @@ class C {
157
156
  Array.isArray(e.data) && (this.state = e.data);
158
157
  }
159
158
  updateObjectState(t) {
160
- var a, i;
159
+ var n, i;
161
160
  if (Array.isArray(this.state))
162
161
  return;
163
162
  const e = t.detail;
164
163
  e.type === "list" ? this.state = {
165
164
  ...this.state,
166
- form: { ...((a = this.state) == null ? void 0 : a.form) || {}, [e.id]: e.data }
165
+ form: { ...((n = this.state) == null ? void 0 : n.form) || {}, [e.id]: e.data }
167
166
  // currentFieldset: newState.currentFieldset,
168
167
  // history: detail.data.,
169
168
  } : this.state = {
@@ -175,15 +174,15 @@ class C {
175
174
  }
176
175
  getStateList() {
177
176
  return this.state ? Array.isArray(this.state) ? this.state.length === 0 ? [] : this.state.map((t) => Object.values(t.form).filter((e) => {
178
- var a;
179
- return ((a = e == null ? void 0 : e.data) == null ? void 0 : a.type) === "details";
177
+ var n;
178
+ return ((n = e == null ? void 0 : e.data) == null ? void 0 : n.type) === "details";
180
179
  }).map((e) => {
181
- var a;
182
- return e.data.type === "details" && ((a = e.data) == null ? void 0 : a.fieldsets) || {};
180
+ var n;
181
+ return e.data.type === "details" && ((n = e.data) == null ? void 0 : n.fieldsets) || {};
183
182
  }).reduce(
184
- (e, a) => {
185
- for (const [i, s] of Object.entries(a))
186
- e[i] = s.value;
183
+ (e, n) => {
184
+ for (const [i, a] of Object.entries(n))
185
+ e[i] = a.value;
187
186
  return e;
188
187
  },
189
188
  {}
@@ -234,15 +233,15 @@ class C {
234
233
  }), l(this._formRef, "external::continue", { next: t });
235
234
  }
236
235
  // Public method to perform validation and send the appropriate messages to the form elements
237
- validate(t, e, a) {
236
+ validate(t, e, n) {
238
237
  var o;
239
- const { el: i, state: s } = e.detail, n = (o = s == null ? void 0 : s[t]) == null ? void 0 : o.value;
240
- for (const d of a) {
241
- const b = d(n);
238
+ const { el: i, state: a } = e.detail, s = (o = a == null ? void 0 : a[t]) == null ? void 0 : o.value;
239
+ for (const d of n) {
240
+ const b = d(s);
242
241
  if (g(this, f, A).call(this, i, t, b), b)
243
242
  return [!1, ""];
244
243
  }
245
- return [!0, n];
244
+ return [!0, s];
246
245
  }
247
246
  edit(t) {
248
247
  l(this._formRef, "external::alter:state", { index: t, operation: "edit" });
@@ -256,7 +255,7 @@ class C {
256
255
  if (Array.isArray(this.state))
257
256
  return;
258
257
  const t = this.state;
259
- return (e = this.state) == null ? void 0 : e.history.reduce((a, i) => (a[i] = t == null ? void 0 : t.form[i], a), {});
258
+ return (e = this.state) == null ? void 0 : e.history.reduce((n, i) => (n[i] = t == null ? void 0 : t.form[i], n), {});
260
259
  }
261
260
  }
262
261
  f = new WeakSet(), E = function(t) {
@@ -269,7 +268,7 @@ f = new WeakSet(), E = function(t) {
269
268
  }
270
269
  }));
271
270
  }, // Private method to dispatch the error message to the form element
272
- A = function(t, e, a) {
271
+ A = function(t, e, n) {
273
272
  t.dispatchEvent(
274
273
  new CustomEvent("msg", {
275
274
  composed: !0,
@@ -277,13 +276,13 @@ A = function(t, e, a) {
277
276
  action: "external::set:error",
278
277
  data: {
279
278
  name: e,
280
- msg: a
279
+ msg: n
281
280
  }
282
281
  }
283
282
  })
284
283
  );
285
284
  };
286
- function U(r, t, e, a) {
285
+ function U(r, t, e, n) {
287
286
  if (!r) {
288
287
  console.error("dispatch element is null");
289
288
  return;
@@ -291,12 +290,12 @@ function U(r, t, e, a) {
291
290
  r.dispatchEvent(
292
291
  new CustomEvent(t, {
293
292
  composed: !0,
294
- bubbles: a == null ? void 0 : a.bubbles,
293
+ bubbles: n == null ? void 0 : n.bubbles,
295
294
  detail: e
296
295
  })
297
296
  );
298
297
  }
299
- function l(r, t, e, a) {
298
+ function l(r, t, e, n) {
300
299
  if (!r) {
301
300
  console.error("dispatch element is null");
302
301
  return;
@@ -304,7 +303,7 @@ function l(r, t, e, a) {
304
303
  r.dispatchEvent(
305
304
  new CustomEvent("msg", {
306
305
  composed: !0,
307
- bubbles: a == null ? void 0 : a.bubbles,
306
+ bubbles: n == null ? void 0 : n.bubbles,
308
307
  detail: {
309
308
  action: t,
310
309
  data: e
@@ -313,19 +312,19 @@ function l(r, t, e, a) {
313
312
  );
314
313
  }
315
314
  export {
316
- _ as FormValidator,
317
- C as PublicFormController,
315
+ N as FormValidator,
316
+ T as PublicFormController,
318
317
  x as SINValidator,
319
- N as birthDayValidator,
320
- R as birthMonthValidator,
318
+ R as birthDayValidator,
319
+ S as birthMonthValidator,
321
320
  w as birthYearValidator,
322
321
  L as dateValidator,
323
322
  U as dispatch,
324
- I as emailValidator,
325
- T as lengthValidator,
323
+ $ as emailValidator,
324
+ C as lengthValidator,
326
325
  m as numericValidator,
327
326
  D as phoneNumberValidator,
328
- $ as postalCodeValidator,
327
+ I as postalCodeValidator,
329
328
  h as regexValidator,
330
329
  l as relay,
331
330
  c as requiredValidator
package/lib/common.d.ts CHANGED
@@ -71,7 +71,7 @@ export type GoabCalloutAriaLive = "off" | "polite" | "assertive";
71
71
  export type GoabCalloutIconTheme = "outline" | "filled";
72
72
  export type GoabButtonType = "primary" | "submit" | "secondary" | "tertiary" | "start";
73
73
  export type GoabButtonSize = "compact" | "normal";
74
- export type GoabButtonVariant = "normal" | "destructive";
74
+ export type GoabButtonVariant = "normal" | "destructive" | "inverse";
75
75
  export type GoabButtonGroupAlignment = "start" | "end" | "center";
76
76
  export type GoabButtonGroupGap = "relaxed" | "compact";
77
77
  export type GoabAccordionHeadingSize = "small" | "medium";
@@ -218,9 +218,9 @@ interface BaseProps extends Margins {
218
218
  }
219
219
  export type GoabIconFilledType = `${GoabIconType}-${GoabIconTheme}`;
220
220
  export type GoabIconType = "accessibility" | "add-circle" | "add" | "airplane" | "alarm" | "albums" | "alert-circle" | "alert" | "american-football" | "analytics" | "aperture" | "apps" | "archive" | "arrow-back-circle" | "arrow-back" | "arrow-down-circle" | "arrow-down" | "arrow-forward-circle" | "arrow-forward" | "arrow-redo-circle" | "arrow-redo" | "arrow-undo-circle" | "arrow-undo" | "arrow-up-circle" | "arrow-up" | "at-circle" | "at" | "attach" | "backspace" | "bag-add" | "bag-check" | "bag-handle" | "bag" | "bag-remove" | "balloon" | "ban" | "bandage" | "bar-chart" | "barbell" | "barcode" | "baseball" | "basket" | "basketball" | "battery-charging" | "battery-dead" | "battery-full" | "battery-half" | "beaker" | "bed" | "beer" | "bicycle" | "bluetooth" | "boat" | "body" | "bonfire" | "book" | "bookmark" | "bookmarks" | "bowling-ball" | "briefcase" | "browsers" | "brush" | "bug" | "build" | "bulb" | "bus" | "business" | "cafe" | "calculator" | "calendar-clear" | "calendar-number" | "calendar" | "call" | "camera" | "camera-reverse" | "car" | "car-sport" | "card" | "caret-back-circle" | "caret-back" | "caret-down-circle" | "caret-down" | "caret-forward-circle" | "caret-forward" | "caret-up-circle" | "caret-up" | "cart" | "cash" | "cellular" | "chatbox-ellipses" | "chatbox" | "chatbubble-ellipses" | "chatbubble" | "chatbubbles" | "checkbox" | "checkmark-circle" | "checkmark-done-circle" | "checkmark-done" | "checkmark" | "chevron-back-circle" | "chevron-back" | "chevron-down-circle" | "chevron-down" | "chevron-forward-circle" | "chevron-forward" | "chevron-up-circle" | "chevron-up" | "clipboard" | "close-circle" | "close" | "cloud-circle" | "cloud-done" | "cloud-download" | "cloud-offline" | "cloud" | "cloud-upload" | "cloudy-night" | "cloudy" | "code-download" | "code" | "code-slash" | "code-working" | "cog" | "color-fill" | "color-filter" | "color-palette" | "color-wand" | "compass" | "construct" | "contract" | "contrast" | "copy" | "create" | "crop" | "cube" | "cut" | "desktop" | "diamond" | "dice" | "disc" | "document-attach" | "document-lock" | "document" | "document-text" | "documents" | "download" | "duplicate" | "ear" | "earth" | "easel" | "egg" | "ellipse" | "ellipsis-horizontal-circle" | "ellipsis-horizontal" | "ellipsis-vertical-circle" | "ellipsis-vertical" | "enter" | "exit" | "expand" | "extension-puzzle" | "eye-off" | "eye" | "eyedrop" | "fast-food" | "female" | "file-tray-full" | "file-tray" | "file-tray-stacked" | "filenames.ps1" | "film" | "filter-circle" | "filter" | "finger-print" | "fish" | "fitness" | "flag" | "flame" | "flash-off" | "flash" | "flashlight" | "flask" | "flower" | "folder-open" | "folder" | "football" | "footsteps" | "funnel" | "game-controller" | "gift" | "git-branch" | "git-commit" | "git-compare" | "git-merge" | "git-network" | "git-pull-request" | "glasses" | "globe" | "golf" | "grid" | "hammer" | "hand-left" | "hand-right" | "happy" | "hardware-chip" | "headset" | "heart-circle" | "heart-dislike-circle" | "heart-dislike" | "heart-half" | "heart" | "help-buoy" | "help-circle" | "help" | "home" | "hourglass" | "ice-cream" | "id-card" | "image" | "images" | "infinite" | "information-circle" | "information" | "invert-mode" | "journal" | "key" | "keypad" | "language" | "laptop" | "layers" | "leaf" | "library" | "link" | "list-circle" | "list" | "locate" | "location" | "lock-closed" | "lock-open" | "log-in" | "log-out" | "magnet" | "mail-open" | "mail" | "mail-unread" | "male-female" | "male" | "man" | "map" | "medal" | "medical" | "medkit" | "megaphone" | "menu" | "mic-circle" | "mic-off-circle" | "mic-off" | "mic" | "moon" | "move" | "musical-note" | "musical-notes" | "navigate-circle" | "navigate" | "newspaper" | "notifications-circle" | "notifications-off-circle" | "notifications-off" | "notifications" | "nuclear" | "nutrition" | "open" | "options" | "paper-plane" | "partly-sunny" | "pause-circle" | "pause" | "paw" | "pencil" | "people-circle" | "people" | "person-add" | "person-circle" | "person" | "person-remove" | "phone-landscape" | "phone-portrait" | "pie-chart" | "pin" | "pint" | "pizza" | "planet" | "play-back-circle" | "play-back" | "play-circle" | "play-forward-circle" | "play-forward" | "play" | "play-skip-back-circle" | "play-skip-back" | "play-skip-forward-circle" | "play-skip-forward" | "podium" | "power" | "pricetag" | "pricetags" | "print" | "prism" | "pulse" | "push" | "qr-code" | "radio-button-off" | "radio-button-on" | "radio" | "rainy" | "reader" | "receipt" | "recording" | "refresh-circle" | "refresh" | "reload-circle" | "reload" | "remove-circle" | "remove" | "reorder-four" | "reorder-three" | "reorder-two" | "repeat" | "resize" | "restaurant" | "return-down-back" | "return-down-forward" | "return-up-back" | "return-up-forward" | "ribbon" | "rocket" | "rose" | "sad" | "save" | "scale" | "scan-circle" | "scan" | "school" | "search-circle" | "search" | "send" | "server" | "settings" | "shapes" | "share" | "share-social" | "shield-checkmark" | "shield-half" | "shield" | "shirt" | "shuffle" | "skull" | "snow" | "sparkles" | "speedometer" | "square" | "star-half" | "star" | "stats-chart" | "stop-circle" | "stop" | "stopwatch" | "storefront" | "subway" | "sunny" | "swap-horizontal" | "swap-vertical" | "sync-circle" | "sync" | "tablet-landscape" | "tablet-portrait" | "telescope" | "tennisball" | "terminal" | "text" | "thermometer" | "thumbs-down" | "thumbs-up" | "thunderstorm" | "ticket" | "time" | "timer" | "today" | "toggle" | "trail-sign" | "train" | "transgender" | "trash-bin" | "trash" | "trending-down" | "trending-up" | "triangle" | "trophy" | "tv" | "umbrella" | "unlink" | "videocam-off" | "videocam" | "volume-high" | "volume-low" | "volume-medium" | "volume-mute" | "volume-off" | "walk" | "wallet" | "warning" | "watch" | "water" | "wifi" | "wine" | "woman" | "logo-alipay" | "logo-amazon" | "logo-amplify" | "logo-android" | "logo-angular" | "logo-apple" | "logo-apple-appstore" | "logo-apple-ar" | "logo-behance" | "logo-bitbucket" | "logo-bitcoin" | "logo-buffer" | "logo-capacitor" | "logo-chrome" | "logo-closed-captioning" | "logo-codepen" | "logo-css3" | "logo-designernews" | "logo-deviantart" | "logo-discord" | "logo-docker" | "logo-dribbble" | "logo-dropbox" | "logo-edge" | "logo-electron" | "logo-euro" | "logo-facebook" | "logo-figma" | "logo-firebase" | "logo-firefox" | "logo-flickr" | "logo-foursquare" | "logo-github" | "logo-gitlab" | "logo-google" | "logo-google-playstore" | "logo-hackernews" | "logo-html5" | "logo-instagram" | "logo-ionic" | "logo-ionitron" | "logo-javascript" | "logo-laravel" | "logo-linkedin" | "logo-markdown" | "logo-mastodon" | "logo-medium" | "logo-microsoft" | "logo-no-smoking" | "logo-nodejs" | "logo-npm" | "logo-octocat" | "logo-paypal" | "logo-pinterest" | "logo-playstation" | "logo-pwa" | "logo-python" | "logo-react" | "logo-reddit" | "logo-rss" | "logo-sass" | "logo-skype" | "logo-slack" | "logo-snapchat" | "logo-soundcloud" | "logo-stackoverflow" | "logo-steam" | "logo-stencil" | "logo-tableau" | "logo-tiktok" | "logo-tumblr" | "logo-tux" | "logo-twitch" | "logo-twitter" | "logo-usd" | "logo-venmo" | "logo-vercel" | "logo-vimeo" | "logo-vk" | "logo-vue" | "logo-web-component" | "logo-wechat" | "logo-whatsapp" | "logo-windows" | "logo-wordpress" | "logo-xbox" | "logo-xing" | "logo-yahoo" | "logo-yen" | "logo-youtube";
221
- export type GoabIconSize = "small" | "medium" | "large" | "xlarge";
221
+ export type GoabIconSize = "1" | "2" | "3" | "4" | "5" | "6" | "2xsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge";
222
222
  export type GoabIconTheme = "outline" | "filled";
223
- export type GoabIconButtonVariant = "color" | "nocolor" | "dark" | "destructive";
223
+ export type GoabIconButtonVariant = "color" | "nocolor" | "dark" | "light" | "destructive";
224
224
  export type GoabIconVariant = "primary" | "secondary" | "tertiary";
225
225
  export type NumericSpacing = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10";
226
226
  export type TShirtSpacing = "none" | "3xs" | "2xs" | "xs" | "s" | "m" | "l" | "xl" | "2xl" | "3xl" | "4xl";
@@ -1,10 +1,10 @@
1
+ export type FieldValidator = (value: unknown) => string;
2
+ export type FieldsetState = Record<string, FieldsetItemState>;
1
3
  export type FieldsetItemState = {
2
4
  name: string;
3
5
  label: string;
4
6
  value: string;
5
7
  };
6
- export type FieldValidator = (value: unknown) => string;
7
- export type FieldsetState = Record<string, FieldsetItemState>;
8
8
  export declare class FormValidator {
9
9
  private readonly validators;
10
10
  constructor(validators?: Record<string, FieldValidator[]>);
@@ -27,7 +27,7 @@ interface DateValidatorOptions {
27
27
  min?: Date;
28
28
  max?: Date;
29
29
  }
30
- export declare function dateValidator({ invalidMsg, minMsg, maxMsg, min, max, }: DateValidatorOptions): FieldValidator;
30
+ export declare function dateValidator({ invalidMsg, minMsg, maxMsg, min, max, }?: DateValidatorOptions): FieldValidator;
31
31
  interface NumericValidatorOptions {
32
32
  invalidTypeMsg?: string;
33
33
  minMsg?: string;
@@ -35,14 +35,13 @@ interface NumericValidatorOptions {
35
35
  min?: number;
36
36
  max?: number;
37
37
  }
38
- export declare function numericValidator({ invalidTypeMsg, minMsg, maxMsg, min, max, }: NumericValidatorOptions): FieldValidator;
38
+ export declare function numericValidator({ invalidTypeMsg, minMsg, maxMsg, min, max, }?: NumericValidatorOptions): FieldValidator;
39
39
  interface LengthValidatorOptions {
40
40
  invalidTypeMsg?: string;
41
41
  minMsg?: string;
42
42
  maxMsg?: string;
43
43
  max?: number;
44
44
  min?: number;
45
- optional?: boolean;
46
45
  }
47
- export declare function lengthValidator({ invalidTypeMsg, minMsg, maxMsg, min, max, optional, }: LengthValidatorOptions): FieldValidator;
46
+ export declare function lengthValidator({ invalidTypeMsg, minMsg, maxMsg, min, max, }: LengthValidatorOptions): FieldValidator;
48
47
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/ui-components-common",
3
- "version": "1.1.0",
3
+ "version": "1.2.0-alpha.1",
4
4
  "bugs": {
5
5
  "url": "https://github.com/GovAlta/ui-components/issues"
6
6
  },