@abgov/ui-components-common 1.6.0-alpha.3 → 1.6.0-alpha.5

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 d=(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 w{constructor(t){d(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 D(){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 E(){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 _(){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 I(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 $(){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(u=>parseInt(u)).reduce((u,l)=>u+l,0)}).reduce((i,n)=>i+n,0)%10===0?"":"Invalid SIN"}}function x(){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 T({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`:""}function L(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 o(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}}))}var f,q,A;class U{constructor(t){g(this,f);d(this,"state");d(this,"_formData");d(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){o(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}o(this._formRef,"external::continue",{next:t})}validate(t,e,a,i){var b;const{el:n,state:s,cancelled:u}=t.detail,l=(b=s==null?void 0:s[e])==null?void 0:b.value;if(window.scrollTo({top:0,behavior:"smooth"}),u)return[!0,l];for(const v of a){const p=v(l);if(V(this,f,A).call(this,n,e,p,i),p)return[!1,""]}return[!0,l]}validateGroup(t,e,a){let i=0;const n={};for(const s of e){const[u]=this.validate(t,s,a,{grouped:!0});u&&(n[s]=!0,i++)}return[i,n]}edit(t){o(this._formRef,"external::alter:state",{index:t,operation:"edit"})}remove(t){o(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,q=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}}}))};const Y=["basic","success","failure"];function O(r,t){const e=crypto.randomUUID();return t={uuid:e,type:"basic",...t||{}},!t.duration&&t.type&&Y.includes(t.type)&&(t.duration="short"),o(document.body,"goa:temp-notification",{message:r,...t},{bubbles:!0}),e}function P(r){o(document.body,"goa:temp-notification:dismiss",r,{bubbles:!0})}function j(r,t){o(document.body,"goa:temp-notification:progress",{uuid:r,progress:t},{bubbles:!0})}const F={show:O,dismiss:P,setProgress:j};exports.FormValidator=w;exports.PublicFormController=U;exports.SINValidator=$;exports.TemporaryNotification=F;exports.birthDayValidator=D;exports.birthMonthValidator=E;exports.birthYearValidator=_;exports.dateValidator=C;exports.dispatch=L;exports.emailValidator=I;exports.lengthValidator=T;exports.numericValidator=m;exports.phoneNumberValidator=R;exports.postalCodeValidator=x;exports.regexValidator=h;exports.relay=o;exports.requiredValidator=c;
package/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export * from './lib/common';
2
2
  export * from './lib/validators';
3
3
  export * from './lib/public-form-controller';
4
+ export * from './lib/temporary-notification-controller/temporary-notification-controller';
5
+ export * from './lib/messaging/messaging';
package/index.js CHANGED
@@ -3,10 +3,10 @@ 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 l = (r, t, e) => S(r, typeof t != "symbol" ? t + "" : t, e), w = (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
- var A = (r, t, e) => (E(r, t, "access private method"), e);
9
- class _ {
8
+ var A = (r, t, e) => (w(r, t, "access private method"), e);
9
+ class x {
10
10
  constructor(t) {
11
11
  l(this, "validators");
12
12
  this.validators = t || {};
@@ -22,7 +22,7 @@ class _ {
22
22
  }), e;
23
23
  }
24
24
  }
25
- function D() {
25
+ function I() {
26
26
  return [
27
27
  c("Day is required"),
28
28
  m({
@@ -33,7 +33,7 @@ function D() {
33
33
  })
34
34
  ];
35
35
  }
36
- function R() {
36
+ function L() {
37
37
  return [
38
38
  c("Month is required"),
39
39
  m({
@@ -44,7 +44,7 @@ function R() {
44
44
  })
45
45
  ];
46
46
  }
47
- function $() {
47
+ function U() {
48
48
  const r = (/* @__PURE__ */ new Date()).getFullYear();
49
49
  return [
50
50
  c("Year is required"),
@@ -59,27 +59,27 @@ function $() {
59
59
  function c(r) {
60
60
  return (t) => (r = r || "Required", typeof t == "number" && !isNaN(t) || t ? "" : r);
61
61
  }
62
- function x(r) {
62
+ function C(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 T(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
  );
70
70
  return h(t, r || "Invalid email address");
71
71
  }
72
- function L() {
72
+ function q() {
73
73
  return (r) => {
74
74
  if (!r) return "";
75
75
  const t = "121212121".split("").map((n) => parseInt(n)), e = r.replace(/\D/g, "");
76
76
  return e.length !== 9 ? "SIN must contain 9 numbers" : e.split("").map((n) => parseInt(n)).map((n, i) => {
77
77
  const s = n * t[i];
78
- return s < 10 ? s : `${s}`.split("").map((o) => parseInt(o)).reduce((o, u) => o + u, 0);
78
+ return s < 10 ? s : `${s}`.split("").map((o) => parseInt(o)).reduce((o, f) => o + f, 0);
79
79
  }).reduce((n, i) => n + i, 0) % 10 === 0 ? "" : "Invalid SIN";
80
80
  };
81
81
  }
82
- function C() {
82
+ function Y() {
83
83
  return h(
84
84
  /^[ABCEGHJ-NPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ -]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,
85
85
  "Invalid postal code"
@@ -88,7 +88,7 @@ function C() {
88
88
  function h(r, t) {
89
89
  return (e) => !e || e.match(r) ? "" : t;
90
90
  }
91
- function U({
91
+ function J({
92
92
  invalidMsg: r,
93
93
  minMsg: t,
94
94
  maxMsg: e,
@@ -112,7 +112,7 @@ function m({
112
112
  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}` : "");
113
113
  };
114
114
  }
115
- function q({
115
+ function O({
116
116
  invalidTypeMsg: r,
117
117
  minMsg: t,
118
118
  maxMsg: e,
@@ -121,10 +121,39 @@ 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;
125
- class T {
124
+ function X(r, t, e, a) {
125
+ if (!r) {
126
+ console.error("dispatch element is null");
127
+ return;
128
+ }
129
+ r.dispatchEvent(
130
+ new CustomEvent(t, {
131
+ composed: !0,
132
+ bubbles: a == null ? void 0 : a.bubbles,
133
+ detail: e
134
+ })
135
+ );
136
+ }
137
+ function u(r, t, e, a) {
138
+ if (!r) {
139
+ console.error("dispatch element is null");
140
+ return;
141
+ }
142
+ r.dispatchEvent(
143
+ new CustomEvent("msg", {
144
+ composed: !0,
145
+ bubbles: a == null ? void 0 : a.bubbles,
146
+ detail: {
147
+ action: t,
148
+ data: e
149
+ }
150
+ })
151
+ );
152
+ }
153
+ var d, E, v;
154
+ class j {
126
155
  constructor(t) {
127
- g(this, f);
156
+ g(this, d);
128
157
  l(this, "state");
129
158
  l(this, "_formData");
130
159
  l(this, "_formRef");
@@ -149,7 +178,7 @@ class T {
149
178
  }
150
179
  // Public method to allow for the initialization of the state
151
180
  initState(t, e) {
152
- 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);
181
+ u(this._formRef, "external::init:state", t), typeof t == "string" ? this.state = JSON.parse(t) : Array.isArray(t) || (this.state = t), e && setTimeout(e, 200);
153
182
  }
154
183
  updateListState(t) {
155
184
  const e = t.detail;
@@ -223,20 +252,20 @@ class T {
223
252
  console.error("continueTo [name] is undefined");
224
253
  return;
225
254
  }
226
- d(this._formRef, "external::continue", { next: t });
255
+ u(this._formRef, "external::continue", { next: t });
227
256
  }
228
257
  // Public method to perform validation and send the appropriate messages to the form elements
229
258
  validate(t, e, a, n) {
230
259
  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;
260
+ const { el: i, state: s, cancelled: o } = t.detail, f = (b = s == null ? void 0 : s[e]) == null ? void 0 : b.value;
232
261
  if (window.scrollTo({ top: 0, behavior: "smooth" }), o)
233
- return [!0, u];
262
+ return [!0, f];
234
263
  for (const V of a) {
235
- const p = V(u);
236
- if (A(this, f, v).call(this, i, e, p, n), p)
264
+ const p = V(f);
265
+ if (A(this, d, v).call(this, i, e, p, n), p)
237
266
  return [!1, ""];
238
267
  }
239
- return [!0, u];
268
+ return [!0, f];
240
269
  }
241
270
  /**
242
271
  * Validates a group of fields ensuring that at least `minPassCount` of the items within the group
@@ -257,10 +286,10 @@ class T {
257
286
  return [n, i];
258
287
  }
259
288
  edit(t) {
260
- d(this._formRef, "external::alter:state", { index: t, operation: "edit" });
289
+ u(this._formRef, "external::alter:state", { index: t, operation: "edit" });
261
290
  }
262
291
  remove(t) {
263
- d(this._formRef, "external::alter:state", {
292
+ u(this._formRef, "external::alter:state", {
264
293
  index: t,
265
294
  operation: "remove"
266
295
  });
@@ -270,7 +299,7 @@ class T {
270
299
  return t.history.reduce((e, a) => (e[a] = t.form[a], e), {});
271
300
  }
272
301
  }
273
- f = new WeakSet(), w = function(t) {
302
+ d = new WeakSet(), E = function(t) {
274
303
  var e;
275
304
  Array.isArray(t.data) && (Array.isArray(this.state) || (this.state = {
276
305
  ...this.state,
@@ -295,50 +324,53 @@ v = function(t, e, a, n) {
295
324
  })
296
325
  );
297
326
  };
298
- function Y(r, t, e, a) {
299
- if (!r) {
300
- console.error("dispatch element is null");
301
- return;
302
- }
303
- r.dispatchEvent(
304
- new CustomEvent(t, {
305
- composed: !0,
306
- bubbles: a == null ? void 0 : a.bubbles,
307
- detail: e
308
- })
327
+ const N = ["basic", "success", "failure"];
328
+ function D(r, t) {
329
+ const e = crypto.randomUUID();
330
+ return t = { uuid: e, type: "basic", ...t || {} }, !t.duration && t.type && N.includes(t.type) && (t.duration = "short"), u(
331
+ document.body,
332
+ "goa:temp-notification",
333
+ { message: r, ...t },
334
+ { bubbles: !0 }
335
+ ), e;
336
+ }
337
+ function _(r) {
338
+ u(
339
+ document.body,
340
+ "goa:temp-notification:dismiss",
341
+ r,
342
+ { bubbles: !0 }
309
343
  );
310
344
  }
311
- function d(r, t, e, a) {
312
- if (!r) {
313
- console.error("dispatch element is null");
314
- return;
315
- }
316
- r.dispatchEvent(
317
- new CustomEvent("msg", {
318
- composed: !0,
319
- bubbles: a == null ? void 0 : a.bubbles,
320
- detail: {
321
- action: t,
322
- data: e
323
- }
324
- })
345
+ function R(r, t) {
346
+ u(
347
+ document.body,
348
+ "goa:temp-notification:progress",
349
+ { uuid: r, progress: t },
350
+ { bubbles: !0 }
325
351
  );
326
352
  }
353
+ const G = {
354
+ show: D,
355
+ dismiss: _,
356
+ setProgress: R
357
+ };
327
358
  export {
328
- _ as FormValidator,
329
- T as PublicFormController,
330
- L as SINValidator,
331
- D as birthDayValidator,
332
- R as birthMonthValidator,
333
- $ as birthYearValidator,
334
- U as dateValidator,
335
- Y as dispatch,
336
- I as emailValidator,
337
- q as lengthValidator,
359
+ x as FormValidator,
360
+ j as PublicFormController,
361
+ q as SINValidator,
362
+ G as TemporaryNotification,
363
+ I as birthDayValidator,
364
+ L as birthMonthValidator,
365
+ U as birthYearValidator,
366
+ J as dateValidator,
367
+ X as dispatch,
368
+ T as emailValidator,
369
+ O as lengthValidator,
338
370
  m as numericValidator,
339
- x as phoneNumberValidator,
340
- C as postalCodeValidator,
371
+ C as phoneNumberValidator,
372
+ Y as postalCodeValidator,
341
373
  h as regexValidator,
342
- d as relay,
374
+ u as relay,
343
375
  c as requiredValidator
344
376
  };
package/lib/common.d.ts CHANGED
@@ -242,6 +242,7 @@ export interface Margins {
242
242
  }
243
243
  export type GoabBlockDirection = "row" | "column";
244
244
  export type GoabBlockAlignment = "center" | "start" | "end";
245
+ export type GoabPageBlockSize = "full" | string;
245
246
  export type GoabLinkButtonType = "start" | "primary" | "secondary" | "tertiary";
246
247
  export type GoabTextMaxWidth = string | "none";
247
248
  export type GoabTextHeadingElement = "h1" | "h2" | "h3" | "h4" | "h5";
@@ -291,13 +292,6 @@ export type GoabFieldsetSchema = {
291
292
  heading?: string;
292
293
  data?: GoabFieldsetData;
293
294
  };
294
- export interface GoabFieldsetOnChangeDetail {
295
- id: string;
296
- state: {
297
- data: Record<string, GoabFieldsetItemState>;
298
- };
299
- dispatchOn: GoabFormDispatchOn;
300
- }
301
295
  export interface GoabFieldsetOnContinueDetail {
302
296
  el: HTMLElement;
303
297
  state: Record<string, GoabFieldsetItemState>;
@@ -306,19 +300,6 @@ export interface GoabFieldsetOnContinueDetail {
306
300
  export type GoabPublicFormStatus = "initializing" | "complete";
307
301
  export type GoabPublicFormPageStep = "step" | "summary" | "multistep";
308
302
  export type GoabPublicFormPageButtonVisibility = "visible" | "hidden";
309
- export type GoabPublicFormPageOnFieldsetChangeDetail = {
310
- id: string;
311
- state: {
312
- heading?: string;
313
- data: Record<string, GoabFieldsetItemState>;
314
- };
315
- dispatchOn: GoabFormDispatchOn;
316
- };
317
- export type GoabPublicFormPageOnCompleteDetail = {
318
- el: HTMLElement;
319
- state: Record<string, GoabFieldsetItemState>;
320
- cancelled: boolean;
321
- };
322
303
  export type GoabPublicFormTaskStatus = "completed" | "not-started" | "cannot-start";
323
304
  export type GoabDrawerPosition = "bottom" | "left" | "right" | undefined;
324
305
  export type GoabDrawerSizeUnit = "px" | "rem" | "ch" | "vh" | "vw";
@@ -0,0 +1,6 @@
1
+ export declare function dispatch<T>(el: HTMLElement | Element | null | undefined, eventName: string, detail?: T, opts?: {
2
+ bubbles?: boolean;
3
+ }): void;
4
+ export declare function relay<T>(el: HTMLElement | Element | null | undefined, eventName: string, data?: T, opts?: {
5
+ bubbles?: boolean;
6
+ }): void;
@@ -55,9 +55,3 @@ export declare class PublicFormController<T> {
55
55
  remove(index: number): void;
56
56
  clean(data: AppState<T>): Record<string, unknown>;
57
57
  }
58
- export declare function dispatch<T>(el: HTMLElement | Element | null | undefined, eventName: string, detail?: T, opts?: {
59
- bubbles?: boolean;
60
- }): void;
61
- export declare function relay<T>(el: HTMLElement | Element | null | undefined, eventName: string, data?: T, opts?: {
62
- bubbles?: boolean;
63
- }): void;
@@ -0,0 +1,19 @@
1
+ export type GoabTemporaryNotificationType = "basic" | "success" | "failure" | "indeterminate" | "progress";
2
+ export type GoabNotificationOptions = {
3
+ type: GoabTemporaryNotificationType;
4
+ uuid: string;
5
+ cancelUUID?: string;
6
+ duration?: "long" | "medium" | "short" | number;
7
+ actionText?: string;
8
+ action?: () => void;
9
+ visible: boolean;
10
+ };
11
+ declare function show(message: string, opts?: Partial<GoabNotificationOptions>): string;
12
+ declare function dismiss(uuid: string): void;
13
+ declare function setProgress(uuid: string, progress: number): void;
14
+ export declare const TemporaryNotification: {
15
+ show: typeof show;
16
+ dismiss: typeof dismiss;
17
+ setProgress: typeof setProgress;
18
+ };
19
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/ui-components-common",
3
- "version": "1.6.0-alpha.3",
3
+ "version": "1.6.0-alpha.5",
4
4
  "bugs": {
5
5
  "url": "https://github.com/GovAlta/ui-components/issues"
6
6
  },