@ahrowe/ui 0.1.4 → 0.1.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/dist/index.mjs CHANGED
@@ -3931,23 +3931,30 @@ var ur = {
3931
3931
  })
3932
3932
  });
3933
3933
  }
3934
- };
3934
+ }, fr = null;
3935
+ function pr(e, t) {
3936
+ if (!fr) {
3937
+ console.error("[Toast] No ToastProvider found. Wrap your app with <ToastProvider>.");
3938
+ return;
3939
+ }
3940
+ fr(e, t);
3941
+ }
3935
3942
  //#endregion
3936
3943
  //#region package/services/formValidation/formValidatorGroup.ts
3937
- function fr(e) {
3944
+ function mr(e) {
3938
3945
  let t = e;
3939
3946
  return t?.errors && Array.isArray(t.errors) ? t.errors.flatMap((e) => Object.entries(e).map(([e, t]) => ({
3940
3947
  id: e,
3941
3948
  message: t
3942
3949
  }))) : [];
3943
3950
  }
3944
- var pr = class {
3951
+ var hr = class {
3945
3952
  #e;
3946
3953
  #t;
3947
3954
  #n;
3948
3955
  #r;
3949
3956
  #i;
3950
- constructor(e, t = null, { initialValues: n, onSubmit: r = () => void 0, onValidate: i = () => void 0, errorParser: a = fr } = {}) {
3957
+ constructor(e, t = null, { initialValues: n, onSubmit: r = () => void 0, onValidate: i = () => void 0, errorParser: a = mr, onSubmitError: o = () => void 0 } = {}) {
3951
3958
  this.#t = !1, this.#i = [], this.getFormError = () => {
3952
3959
  let e = Object.keys(this.group);
3953
3960
  for (let t = 0; t < e.length; t += 1) {
@@ -3966,12 +3973,16 @@ var pr = class {
3966
3973
  this.group[e].dirty = !1, this.group[e].touched = !1;
3967
3974
  });
3968
3975
  }, this.parseError = (e, t = !1) => {
3969
- this.errorParser(e).forEach(({ id: e, message: t }) => {
3976
+ let n = this.errorParser(e);
3977
+ n.length > 0 ? (n.forEach(({ id: e, message: t }) => {
3970
3978
  this.group[e] && this.group[e].addError({
3971
3979
  id: e,
3972
3980
  message: t
3973
3981
  });
3974
- });
3982
+ }), t && this.onSubmitError(n)) : this.onSubmitError([{
3983
+ id: "generic",
3984
+ message: "An error occurred"
3985
+ }]);
3975
3986
  }, this.#a = () => {
3976
3987
  this.component && this.component.forceUpdate(), this.#i.forEach((e) => e());
3977
3988
  }, this.registerOnUpdateListener = (e) => {
@@ -3983,8 +3994,10 @@ var pr = class {
3983
3994
  }, this.submit = async (e) => {
3984
3995
  e && (e.preventDefault && e.preventDefault(), e.stopPropagation && e.stopPropagation()), this.setSubmitting(!0);
3985
3996
  let t = null;
3986
- if (this.submitCount === 0 ? t = await Promise.resolve(this.validate()) : this.onValidateCallback && (t = await Promise.resolve(this.onValidateCallback(this))), this.getFormError() || t) {
3987
- this.setSubmitting(!1), this.submitCount, this.submitCount += 1, this.#a();
3997
+ this.submitCount === 0 ? t = await Promise.resolve(this.validate()) : this.onValidateCallback && (t = await Promise.resolve(this.onValidateCallback(this)));
3998
+ let n = this.getFormError() || t;
3999
+ if (n) {
4000
+ this.setSubmitting(!1), this.submitCount > -1 && this.onSubmitError([n]), this.submitCount += 1, this.#a();
3988
4001
  return;
3989
4002
  }
3990
4003
  try {
@@ -4010,7 +4023,7 @@ var pr = class {
4010
4023
  n[e] !== void 0 && t.set(n[e]), this.#r[e] = t.value, this.group[e].registerOnUpdateListener(() => {
4011
4024
  this.#a(), this.submitCount = 0, this.#n && clearTimeout(this.#n), this.#n = setTimeout(() => this.onDebounce(this.getValues()), 500);
4012
4025
  });
4013
- }), this.component = t, this.onSubmitCallback = r, this.onValidateCallback = i, this.errorParser = a, this.setSubmitting(!1);
4026
+ }), this.component = t, this.onSubmitCallback = r, this.onValidateCallback = i, this.errorParser = a, this.onSubmitError = o, this.setSubmitting(!1);
4014
4027
  }
4015
4028
  get isSubmitting() {
4016
4029
  return this.#t;
@@ -4031,7 +4044,7 @@ var pr = class {
4031
4044
  };
4032
4045
  //#endregion
4033
4046
  //#region package/services/formValidation/FormValidatorGroupForm.tsx
4034
- function mr(e) {
4047
+ function gr(e) {
4035
4048
  return function({ children: t, ...n }) {
4036
4049
  return /* @__PURE__ */ M("form", {
4037
4050
  onSubmit: e.submit,
@@ -4043,11 +4056,16 @@ function mr(e) {
4043
4056
  }
4044
4057
  //#endregion
4045
4058
  //#region package/services/formValidation/FormValidatorGroupWithForm.tsx
4046
- var hr = class extends pr {
4059
+ var _r = (e) => {
4060
+ pr(e[0].message, { type: "error" });
4061
+ }, vr = class extends hr {
4047
4062
  constructor(e, t = null, n) {
4048
- super(e, t, n), this.Form = mr(this);
4063
+ super(e, t, {
4064
+ ...n,
4065
+ onSubmitError: n?.onSubmitError ?? _r
4066
+ }), this.Form = gr(this);
4049
4067
  }
4050
- }, gr = class {
4068
+ }, yr = class {
4051
4069
  #e;
4052
4070
  #t;
4053
4071
  #n;
@@ -4101,40 +4119,40 @@ var hr = class extends pr {
4101
4119
  return this.#r;
4102
4120
  }
4103
4121
  };
4104
- gr.prototype.toString = function() {
4122
+ yr.prototype.toString = function() {
4105
4123
  return `${this.value}`;
4106
4124
  };
4107
4125
  //#endregion
4108
4126
  //#region package/services/regexp.ts
4109
- function _r(e) {
4127
+ function br(e) {
4110
4128
  return /^[0-9]+$/.test(e);
4111
4129
  }
4112
- function vr(e) {
4130
+ function xr(e) {
4113
4131
  return /^[0-9]{2}.[0-9]{2}.[0-9]{4}$/.test(e);
4114
4132
  }
4115
- function yr(e) {
4133
+ function Sr(e) {
4116
4134
  return /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}Z$/.test(e);
4117
4135
  }
4118
- function br(e) {
4136
+ function Cr(e) {
4119
4137
  return /^(([^<>()[\]\\.,;:\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,}))$/.test(e);
4120
4138
  }
4121
- function xr(e) {
4139
+ function wr(e) {
4122
4140
  return /^[A-Z]{6}[A-Z\d]{2}([A-Z\d]{3})?$/.test(e);
4123
4141
  }
4124
- function Sr(e) {
4142
+ function Tr(e) {
4125
4143
  return /[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,63}(\/[-a-zA-Z0-9@:%_+.~#?&//=]*)?$/.test(e);
4126
4144
  }
4127
- function Cr(e) {
4145
+ function Er(e) {
4128
4146
  return /^[\w!@#$%^&*?±§~`'"/\\[\]{}\-,.();:><+=|öäüÖÄÜß €μ]{8,}$/.test(e);
4129
4147
  }
4130
- function wr(e) {
4148
+ function Dr(e) {
4131
4149
  return /^(?=.*[a-zöäüA-ZÖÄÜß])/.test(e);
4132
4150
  }
4133
- function Tr(e) {
4151
+ function Or(e) {
4134
4152
  return /^(?=.*\d)/.test(e);
4135
4153
  }
4136
- function Er(e) {
4137
- return Cr(e) && wr(e) && Tr(e);
4154
+ function kr(e) {
4155
+ return Er(e) && Dr(e) && Or(e);
4138
4156
  }
4139
4157
  //#endregion
4140
4158
  //#region package/services/formValidation/validators.ts
@@ -4153,7 +4171,7 @@ var $ = { t: (e, t) => ({
4153
4171
  "garages.errors.bic": "Must be a valid BIC",
4154
4172
  "formValidators.minLetters": `Must contain at least ${t?.smart_count} letters`,
4155
4173
  "formValidators.minDigits": `Must contain at least ${t?.smart_count} digits`
4156
- })[e] || e }, Dr = class e {
4174
+ })[e] || e }, Ar = class e {
4157
4175
  static {
4158
4176
  this.minLength = (e, t) => (n) => !n || n.length < e ? {
4159
4177
  id: "minLength",
@@ -4167,7 +4185,7 @@ var $ = { t: (e, t) => ({
4167
4185
  } : null;
4168
4186
  }
4169
4187
  static {
4170
- this.email = (e) => (t) => t && !br(t) ? {
4188
+ this.email = (e) => (t) => t && !Cr(t) ? {
4171
4189
  id: "email",
4172
4190
  message: e || $.t("formValidators.email")
4173
4191
  } : null;
@@ -4210,7 +4228,7 @@ var $ = { t: (e, t) => ({
4210
4228
  this.multiEmail = (e) => (t) => {
4211
4229
  if (t) {
4212
4230
  let n = t.replace(/ /g, "").replace(/,/g, ";").split(";");
4213
- for (let t = 0; t < n.length; t += 1) if (!br(n[t])) return {
4231
+ for (let t = 0; t < n.length; t += 1) if (!Cr(n[t])) return {
4214
4232
  id: "multiEmail",
4215
4233
  message: e || $.t("formValidators.multiEmail")
4216
4234
  };
@@ -4219,7 +4237,7 @@ var $ = { t: (e, t) => ({
4219
4237
  };
4220
4238
  }
4221
4239
  static {
4222
- this.date = (e) => (t) => t && !vr(t) && !yr(t) ? {
4240
+ this.date = (e) => (t) => t && !xr(t) && !Sr(t) ? {
4223
4241
  id: "date",
4224
4242
  message: e || $.t("formValidators.date")
4225
4243
  } : null;
@@ -4231,13 +4249,13 @@ var $ = { t: (e, t) => ({
4231
4249
  } : null;
4232
4250
  }
4233
4251
  static {
4234
- this.website = (e) => (t) => t && !Sr(t) ? {
4252
+ this.website = (e) => (t) => t && !Tr(t) ? {
4235
4253
  id: "website",
4236
4254
  message: e || $.t("garages.errors.website")
4237
4255
  } : null;
4238
4256
  }
4239
4257
  static {
4240
- this.bic = (e) => (t) => t && !xr(t) ? {
4258
+ this.bic = (e) => (t) => t && !wr(t) ? {
4241
4259
  id: "bic",
4242
4260
  message: e || $.t("garages.errors.bic")
4243
4261
  } : null;
@@ -4263,7 +4281,7 @@ var $ = { t: (e, t) => ({
4263
4281
  } : r : null;
4264
4282
  };
4265
4283
  }
4266
- }, Or = class extends n {
4284
+ }, jr = class extends n {
4267
4285
  static {
4268
4286
  this.defaultProps = {
4269
4287
  formValidator: null,
@@ -4343,7 +4361,7 @@ var $ = { t: (e, t) => ({
4343
4361
  };
4344
4362
  //#endregion
4345
4363
  //#region package/services/formValidation/useFormValidator.ts
4346
- function kr(e) {
4364
+ function Mr(e) {
4347
4365
  let [, t] = l((e) => e + 1, 0);
4348
4366
  return a(() => {
4349
4367
  if (e) return e.registerOnUpdateListener(t), () => e.removeOnUpdateListener(t);
@@ -4351,16 +4369,17 @@ function kr(e) {
4351
4369
  }
4352
4370
  //#endregion
4353
4371
  //#region package/services/formValidation/useFormValidatorGroup.ts
4354
- function Ar(e, { initialValues: t, onSubmit: n, onValidate: r, errorParser: i } = {}) {
4355
- let [, o] = l((e) => e + 1, 0), s = u(null);
4356
- s.current ||= new hr(e, null, {
4372
+ function Nr(e, { initialValues: t, onSubmit: n, onValidate: r, errorParser: i, onSubmitError: o } = {}) {
4373
+ let [, s] = l((e) => e + 1, 0), c = u(null);
4374
+ c.current ||= new vr(e, null, {
4357
4375
  initialValues: t,
4358
- errorParser: i
4376
+ errorParser: i,
4377
+ onSubmitError: o
4359
4378
  });
4360
- let c = s.current, d = u(n), f = u(r);
4361
- return d.current = n, f.current = r, a(() => (n !== void 0 && (c.onSubmitCallback = (...e) => d.current?.(...e)), r !== void 0 && (c.onValidateCallback = (...e) => f.current?.(...e)), c.registerOnUpdateListener(o), () => c.removeOnUpdateListener(o)), []), c;
4379
+ let d = c.current, f = u(n), p = u(r);
4380
+ return f.current = n, p.current = r, a(() => (n !== void 0 && (d.onSubmitCallback = (...e) => f.current?.(...e)), r !== void 0 && (d.onValidateCallback = (...e) => p.current?.(...e)), d.registerOnUpdateListener(s), () => d.removeOnUpdateListener(s)), []), d;
4362
4381
  }
4363
4382
  //#endregion
4364
- export { be as Accordion, B as AccordionStyleType, Ae as ActionButtons, Fe as ActionIcon, Je as Align, Ie as BodyEnd, W as Button, we as ButtonSize, U as ButtonStyleType, Te as ButtonType, Le as Card, Ve as CardActions, Be as CardContent, Re as CardHeader, ze as CardMedia, Ue as Checkbox, Ge as Chip, Ke as ChipContainer, ut as ColorPicker, pt as ConfirmModal, Bt as DatePicker, Rt as Dropdown, Ht as EmptyState, Kt as Fab, Xe as FloatingMenu, gr as FormValidator, hr as FormValidatorGroup, Yt as Icon, an as IconLoading, Zt as IdleManager, Lt as InfiniteBlock, $e as Input, q as InputType, Ne as InteractableDiv, tn as KanbanBoard, en as KanbanColumn, ft as Modal, cn as NumberInput, un as OptionPicker, mn as Overscroll, _n as ProgressBar, De as Ripple, Wn as RoomDrawer, qn as ScrollbarProvider, Yn as SearchInput, H as SpinnerLoading, Xn as Stepper, ir as TenorPicker, ar as Textarea, cr as ThemeProvider, Qe as Tooltip, Or as ValidatableComponent, Dr as Validators, dr as Wizard, bt as getLocale, Cr as hasEightPasswordChars, Tr as hasOnePasswordDigit, wr as hasOnePasswordLetter, xr as isBic, vr as isDate, br as isEmail, yr as isISODate, _r as isNumber, Er as isPassword, Sr as isURL, _t as mapLocale, yt as setLocale, kr as useFormValidator, Ar as useFormValidatorGroup, lr as useTheme };
4383
+ export { be as Accordion, B as AccordionStyleType, Ae as ActionButtons, Fe as ActionIcon, Je as Align, Ie as BodyEnd, W as Button, we as ButtonSize, U as ButtonStyleType, Te as ButtonType, Le as Card, Ve as CardActions, Be as CardContent, Re as CardHeader, ze as CardMedia, Ue as Checkbox, Ge as Chip, Ke as ChipContainer, ut as ColorPicker, pt as ConfirmModal, Bt as DatePicker, Rt as Dropdown, Ht as EmptyState, Kt as Fab, Xe as FloatingMenu, yr as FormValidator, vr as FormValidatorGroup, Yt as Icon, an as IconLoading, Zt as IdleManager, Lt as InfiniteBlock, $e as Input, q as InputType, Ne as InteractableDiv, tn as KanbanBoard, en as KanbanColumn, ft as Modal, cn as NumberInput, un as OptionPicker, mn as Overscroll, _n as ProgressBar, De as Ripple, Wn as RoomDrawer, qn as ScrollbarProvider, Yn as SearchInput, H as SpinnerLoading, Xn as Stepper, ir as TenorPicker, ar as Textarea, cr as ThemeProvider, Qe as Tooltip, jr as ValidatableComponent, Ar as Validators, dr as Wizard, bt as getLocale, Er as hasEightPasswordChars, Or as hasOnePasswordDigit, Dr as hasOnePasswordLetter, wr as isBic, xr as isDate, Cr as isEmail, Sr as isISODate, br as isNumber, kr as isPassword, Tr as isURL, _t as mapLocale, yt as setLocale, Mr as useFormValidator, Nr as useFormValidatorGroup, lr as useTheme };
4365
4384
 
4366
4385
  //# sourceMappingURL=index.mjs.map