@open-condo/ui 2.43.1 → 2.44.0

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/events.js CHANGED
@@ -1862,6 +1862,7 @@ const html5Email = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]
1862
1862
  const rfc5322Email = /^(([^<>()\[\]\\.,;:\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,}))$/;
1863
1863
  /** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
1864
1864
  const unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
1865
+ const idnEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
1865
1866
  const browserEmail = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
1866
1867
  // from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
1867
1868
  const _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
@@ -1876,9 +1877,8 @@ const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?:
1876
1877
  const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
1877
1878
  const base64url = /^[A-Za-z0-9_-]*$/;
1878
1879
  // based on https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address
1879
- // export const hostname: RegExp =
1880
- // /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)+([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/;
1881
- const hostname = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
1880
+ // export const hostname: RegExp = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
1881
+ const hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
1882
1882
  const domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
1883
1883
  // https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
1884
1884
  const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
@@ -1905,8 +1905,9 @@ function datetime(args) {
1905
1905
  const opts = ["Z"];
1906
1906
  if (args.local)
1907
1907
  opts.push("");
1908
+ // if (args.offset) opts.push(`([+-]\\d{2}:\\d{2})`);
1908
1909
  if (args.offset)
1909
- opts.push(`([+-]\\d{2}:\\d{2})`);
1910
+ opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
1910
1911
  const timeRegex = `${time}(?:${opts.join("|")})`;
1911
1912
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
1912
1913
  }
@@ -1978,22 +1979,33 @@ function cleanRegex(source) {
1978
1979
  }
1979
1980
  function floatSafeRemainder(val, step) {
1980
1981
  const valDecCount = (val.toString().split(".")[1] || "").length;
1981
- const stepDecCount = (step.toString().split(".")[1] || "").length;
1982
+ const stepString = step.toString();
1983
+ let stepDecCount = (stepString.split(".")[1] || "").length;
1984
+ if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
1985
+ const match = stepString.match(/\d?e-(\d?)/);
1986
+ if (match?.[1]) {
1987
+ stepDecCount = Number.parseInt(match[1]);
1988
+ }
1989
+ }
1982
1990
  const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
1983
1991
  const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
1984
1992
  const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
1985
1993
  return (valInt % stepInt) / 10 ** decCount;
1986
1994
  }
1995
+ const EVALUATING = Symbol("evaluating");
1987
1996
  function defineLazy(object, key, getter) {
1988
- const set = false;
1997
+ let value = undefined;
1989
1998
  Object.defineProperty(object, key, {
1990
1999
  get() {
1991
- if (!set) {
1992
- const value = getter();
1993
- object[key] = value;
1994
- return value;
2000
+ if (value === EVALUATING) {
2001
+ // Circular reference detected, return undefined to break the cycle
2002
+ return undefined;
1995
2003
  }
1996
- throw new Error("cached value already set");
2004
+ if (value === undefined) {
2005
+ value = EVALUATING;
2006
+ value = getter();
2007
+ }
2008
+ return value;
1997
2009
  },
1998
2010
  set(v) {
1999
2011
  Object.defineProperty(object, key, {
@@ -2005,6 +2017,9 @@ function defineLazy(object, key, getter) {
2005
2017
  configurable: true,
2006
2018
  });
2007
2019
  }
2020
+ function objectClone(obj) {
2021
+ return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
2022
+ }
2008
2023
  function assignProp(target, prop, value) {
2009
2024
  Object.defineProperty(target, prop, {
2010
2025
  value,
@@ -2366,6 +2381,7 @@ function required(Class, schema, mask) {
2366
2381
  });
2367
2382
  return clone(schema, def);
2368
2383
  }
2384
+ // invalid_type | too_big | too_small | invalid_format | not_multiple_of | unrecognized_keys | invalid_union | invalid_key | invalid_element | invalid_value | custom
2369
2385
  function aborted(x, startIndex = 0) {
2370
2386
  for (let i = startIndex; i < x.issues.length; i++) {
2371
2387
  if (x.issues[i]?.continue !== true) {
@@ -2574,6 +2590,7 @@ const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat"
2574
2590
  expected: origin,
2575
2591
  format: def.format,
2576
2592
  code: "invalid_type",
2593
+ continue: false,
2577
2594
  input,
2578
2595
  inst,
2579
2596
  });
@@ -3003,6 +3020,7 @@ const $ZodCheckMimeType = /*@__PURE__*/ (/* unused pure expression or super */ n
3003
3020
  values: def.mime,
3004
3021
  input: payload.value.type,
3005
3022
  inst,
3023
+ continue: !def.abort,
3006
3024
  });
3007
3025
  };
3008
3026
  })));
@@ -3305,7 +3323,7 @@ const safeParseAsync = /* @__PURE__*/ _safeParseAsync($ZodRealError);
3305
3323
  const versions_version = {
3306
3324
  major: 4,
3307
3325
  minor: 0,
3308
- patch: 10,
3326
+ patch: 15,
3309
3327
  };
3310
3328
 
3311
3329
  ;// CONCATENATED MODULE: ../../node_modules/zod/v4/core/schemas.js
@@ -4172,7 +4190,12 @@ const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
4172
4190
  }
4173
4191
  return undefined;
4174
4192
  });
4193
+ const single = def.options.length === 1;
4194
+ const first = def.options[0]._zod.run;
4175
4195
  inst._zod.parse = (payload, ctx) => {
4196
+ if (single) {
4197
+ return first(payload, ctx);
4198
+ }
4176
4199
  let async = false;
4177
4200
  const results = [];
4178
4201
  for (const option of def.options) {
@@ -4364,10 +4387,10 @@ const $ZodTuple = /*@__PURE__*/ (/* unused pure expression or super */ null && (
4364
4387
  const tooSmall = input.length < optStart - 1;
4365
4388
  if (tooBig || tooSmall) {
4366
4389
  payload.issues.push({
4390
+ ...(tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length }),
4367
4391
  input,
4368
4392
  inst,
4369
4393
  origin: "array",
4370
- ...(tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length }),
4371
4394
  });
4372
4395
  return payload;
4373
4396
  }
@@ -4479,8 +4502,8 @@ const $ZodRecord = /*@__PURE__*/ (/* unused pure expression or super */ null &&
4479
4502
  }
4480
4503
  if (keyResult.issues.length) {
4481
4504
  payload.issues.push({
4482
- origin: "record",
4483
4505
  code: "invalid_key",
4506
+ origin: "record",
4484
4507
  issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
4485
4508
  input: key,
4486
4509
  path: [key],
@@ -4551,8 +4574,8 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
4551
4574
  }
4552
4575
  else {
4553
4576
  final.issues.push({
4554
- origin: "map",
4555
4577
  code: "invalid_key",
4578
+ origin: "map",
4556
4579
  input,
4557
4580
  inst,
4558
4581
  issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
@@ -4690,6 +4713,12 @@ const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) =>
4690
4713
  return payload;
4691
4714
  };
4692
4715
  });
4716
+ function handleOptionalResult(result, input) {
4717
+ if (result.issues.length && input === undefined) {
4718
+ return { issues: [], value: undefined };
4719
+ }
4720
+ return result;
4721
+ }
4693
4722
  const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
4694
4723
  $ZodType.init(inst, def);
4695
4724
  inst._zod.optin = "optional";
@@ -4703,7 +4732,10 @@ const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
4703
4732
  });
4704
4733
  inst._zod.parse = (payload, ctx) => {
4705
4734
  if (def.innerType._zod.optin === "optional") {
4706
- return def.innerType._zod.run(payload, ctx);
4735
+ const result = def.innerType._zod.run(payload, ctx);
4736
+ if (result instanceof Promise)
4737
+ return result.then((r) => handleOptionalResult(r, payload.value));
4738
+ return handleOptionalResult(result, payload.value);
4707
4739
  }
4708
4740
  if (payload.value === undefined) {
4709
4741
  return payload;
@@ -4950,11 +4982,18 @@ const $ZodPromise = /*@__PURE__*/ (/* unused pure expression or super */ null &&
4950
4982
  })));
4951
4983
  const $ZodLazy = /*@__PURE__*/ (/* unused pure expression or super */ null && (core.$constructor("$ZodLazy", (inst, def) => {
4952
4984
  $ZodType.init(inst, def);
4985
+ // let _innerType!: any;
4986
+ // util.defineLazy(def, "getter", () => {
4987
+ // if (!_innerType) {
4988
+ // _innerType = def.getter();
4989
+ // }
4990
+ // return () => _innerType;
4991
+ // });
4953
4992
  util.defineLazy(inst._zod, "innerType", () => def.getter());
4954
4993
  util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType._zod.pattern);
4955
4994
  util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType._zod.propValues);
4956
- util.defineLazy(inst._zod, "optin", () => inst._zod.innerType._zod.optin);
4957
- util.defineLazy(inst._zod, "optout", () => inst._zod.innerType._zod.optout);
4995
+ util.defineLazy(inst._zod, "optin", () => inst._zod.innerType._zod.optin ?? undefined);
4996
+ util.defineLazy(inst._zod, "optout", () => inst._zod.innerType._zod.optout ?? undefined);
4958
4997
  inst._zod.parse = (payload, ctx) => {
4959
4998
  const inner = inst._zod.innerType;
4960
4999
  return inner._zod.run(payload, ctx);
@@ -5859,13 +5898,6 @@ function _custom(Class, fn, _params) {
5859
5898
  });
5860
5899
  return schema;
5861
5900
  }
5862
- // export function _refine<T>(
5863
- // Class: util.SchemaClass<schemas.$ZodCustom>,
5864
- // fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>,
5865
- // _params: string | $ZodCustomParams = {}
5866
- // ): checks.$ZodCheck<T> {
5867
- // return _custom(Class, fn, _params);
5868
- // }
5869
5901
  // same as _custom but defaults to abort:false
5870
5902
  function _refine(Class, fn, _params) {
5871
5903
  const schema = new Class({
@@ -5876,6 +5908,36 @@ function _refine(Class, fn, _params) {
5876
5908
  });
5877
5909
  return schema;
5878
5910
  }
5911
+ function _superRefine(fn) {
5912
+ const ch = _check((payload) => {
5913
+ payload.addIssue = (issue) => {
5914
+ if (typeof issue === "string") {
5915
+ payload.issues.push(util_issue(issue, payload.value, ch._zod.def));
5916
+ }
5917
+ else {
5918
+ // for Zod 3 backwards compatibility
5919
+ const _issue = issue;
5920
+ if (_issue.fatal)
5921
+ _issue.continue = false;
5922
+ _issue.code ?? (_issue.code = "custom");
5923
+ _issue.input ?? (_issue.input = payload.value);
5924
+ _issue.inst ?? (_issue.inst = ch);
5925
+ _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
5926
+ payload.issues.push(util_issue(_issue));
5927
+ }
5928
+ };
5929
+ return fn(payload.value, payload);
5930
+ });
5931
+ return ch;
5932
+ }
5933
+ function _check(fn, params) {
5934
+ const ch = new $ZodCheck({
5935
+ check: "custom",
5936
+ ...normalizeParams(params),
5937
+ });
5938
+ ch._zod.check = fn;
5939
+ return ch;
5940
+ }
5879
5941
  function _stringbool(Classes, _params) {
5880
5942
  const params = util.normalizeParams(_params);
5881
5943
  let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
@@ -5909,6 +5971,7 @@ function _stringbool(Classes, _params) {
5909
5971
  values: [...truthySet, ...falsySet],
5910
5972
  input: payload.value,
5911
5973
  inst: tx,
5974
+ continue: false,
5912
5975
  });
5913
5976
  return {};
5914
5977
  }
@@ -6351,6 +6414,9 @@ const ZodCustomStringFormat = /*@__PURE__*/ (/* unused pure expression or super
6351
6414
  function stringFormat(format, fnOrRegex, _params = {}) {
6352
6415
  return core._stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
6353
6416
  }
6417
+ function schemas_hostname(_params) {
6418
+ return core._stringFormat(ZodCustomStringFormat, "hostname", core.regexes.hostname, _params);
6419
+ }
6354
6420
  const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
6355
6421
  $ZodNumber.init(inst, def);
6356
6422
  ZodType.init(inst, def);
@@ -6549,7 +6615,7 @@ function object(shape, params) {
6549
6615
  const def = {
6550
6616
  type: "object",
6551
6617
  get shape() {
6552
- assignProp(this, "shape", { ...shape });
6618
+ assignProp(this, "shape", shape ? objectClone(shape) : {});
6553
6619
  return this.shape;
6554
6620
  },
6555
6621
  ...normalizeParams(params),
@@ -6561,7 +6627,7 @@ function strictObject(shape, params) {
6561
6627
  return new ZodObject({
6562
6628
  type: "object",
6563
6629
  get shape() {
6564
- assignProp(this, "shape", { ...shape });
6630
+ assignProp(this, "shape", objectClone(shape));
6565
6631
  return this.shape;
6566
6632
  },
6567
6633
  catchall: never(),
@@ -6573,7 +6639,7 @@ function looseObject(shape, params) {
6573
6639
  return new ZodObject({
6574
6640
  type: "object",
6575
6641
  get shape() {
6576
- util.assignProp(this, "shape", { ...shape });
6642
+ util.assignProp(this, "shape", util.objectClone(shape));
6577
6643
  return this.shape;
6578
6644
  },
6579
6645
  catchall: unknown(),
@@ -6981,7 +7047,7 @@ const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
6981
7047
  });
6982
7048
  // custom checks
6983
7049
  function check(fn) {
6984
- const ch = new $ZodCheck({
7050
+ const ch = new core.$ZodCheck({
6985
7051
  check: "custom",
6986
7052
  // ...util.normalizeParams(params),
6987
7053
  });
@@ -6996,26 +7062,7 @@ function refine(fn, _params = {}) {
6996
7062
  }
6997
7063
  // superRefine
6998
7064
  function superRefine(fn) {
6999
- const ch = check((payload) => {
7000
- payload.addIssue = (issue) => {
7001
- if (typeof issue === "string") {
7002
- payload.issues.push(util_issue(issue, payload.value, ch._zod.def));
7003
- }
7004
- else {
7005
- // for Zod 3 backwards compatibility
7006
- const _issue = issue;
7007
- if (_issue.fatal)
7008
- _issue.continue = false;
7009
- _issue.code ?? (_issue.code = "custom");
7010
- _issue.input ?? (_issue.input = payload.value);
7011
- _issue.inst ?? (_issue.inst = ch);
7012
- _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
7013
- payload.issues.push(util_issue(_issue));
7014
- }
7015
- };
7016
- return fn(payload.value, payload);
7017
- });
7018
- return ch;
7065
+ return _superRefine(fn);
7019
7066
  }
7020
7067
  function _instanceof(cls, params = {
7021
7068
  error: `Input not instance of ${cls.name}`,