@scbt-ecom/ui 0.59.0 → 0.59.2

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.
@@ -1,21 +1,21 @@
1
- import { useState as m, useEffect as u } from "react";
2
- import { f as b } from "./useDebounce-CK7Ghu8F.js";
1
+ import { useState as u, useEffect as m } from "react";
2
+ import { u as b } from "./useDebounce-QgEEiWs9.js";
3
3
  const g = (c) => {
4
4
  var r;
5
5
  return (r = Object.values(c)) == null ? void 0 : r.reduce((o, e) => o + (e == null ? void 0 : e.progress), 0);
6
- }, S = ({
6
+ }, f = ({
7
7
  control: c,
8
8
  schema: r,
9
9
  fields: o
10
10
  }) => {
11
- const [e, a] = m(o), t = b({ control: c });
12
- return u(() => {
11
+ const [e, a] = u(o), t = b({ control: c });
12
+ return m(() => {
13
13
  a(
14
14
  (n) => n == null ? void 0 : n.map((s) => r.shape[s.name].safeParse(t[s.name]).success && t[s.name] && t[s.name] !== "" ? { ...s, progress: s.maxPercent } : { ...s, progress: 0 })
15
15
  );
16
16
  }, [t]), g(e);
17
17
  };
18
18
  export {
19
- S as u
19
+ f as u
20
20
  };
21
- //# sourceMappingURL=useFieldsProgress-BeFcsVuB.js.map
21
+ //# sourceMappingURL=useFieldsProgress-BXzIWmGP.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFieldsProgress-BeFcsVuB.js","sources":["../lib/shared/hooks/useFieldsProgress.ts"],"sourcesContent":["'use client'\n\nimport { useEffect, useState } from 'react'\nimport { type Control, type FieldValues, type Path, useWatch } from 'react-hook-form'\nimport { type ZodObject, type ZodRawShape } from 'zod'\n\nexport interface ISubscribedField<T extends FieldValues> {\n name: Path<T>\n progress: number\n maxPercent: number\n}\n\ntype TUseFieldsProgress<T extends FieldValues, S extends ZodRawShape> = {\n control: Control<T>\n schema: ZodObject<S>\n fields: ISubscribedField<T>[]\n}\n\nconst formatProgress = <T extends FieldValues>(subscribeFields: ISubscribedField<T>[]) => {\n return Object.values(subscribeFields)?.reduce((acc, value) => {\n return acc + value?.progress\n }, 0)\n}\n\nexport const useFieldsProgress = <T extends FieldValues, S extends ZodRawShape>({\n control,\n schema,\n fields\n}: TUseFieldsProgress<T, S>): number => {\n const [subscribeFields, setSubscribeFields] = useState<ISubscribedField<T>[]>(fields)\n const watchedFields = useWatch({ control })\n\n useEffect(() => {\n setSubscribeFields((prevFields) =>\n prevFields?.map((field) => {\n const fieldSchema = schema.shape[field.name]\n const result = fieldSchema.safeParse(watchedFields[field.name])\n if (result.success && watchedFields[field.name] && watchedFields[field.name] !== '') {\n return { ...field, progress: field.maxPercent }\n } else {\n return { ...field, progress: 0 }\n }\n })\n )\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [watchedFields])\n\n return formatProgress(subscribeFields)\n}\n"],"names":["formatProgress","subscribeFields","_a","acc","value","useFieldsProgress","control","schema","fields","setSubscribeFields","useState","watchedFields","useWatch","useEffect","prevFields","field"],"mappings":";;AAkBA,MAAMA,IAAiB,CAAwBC,MAA2C;;AACxF,UAAOC,IAAA,OAAO,OAAOD,CAAe,MAA7B,gBAAAC,EAAgC,OAAO,CAACC,GAAKC,MAC3CD,KAAMC,KAAA,gBAAAA,EAAO,WACnB;AACL,GAEaC,IAAoB,CAA+C;AAAA,EAC9E,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,QAAAC;AACF,MAAwC;AACtC,QAAM,CAACP,GAAiBQ,CAAkB,IAAIC,EAAgCF,CAAM,GAC9EG,IAAgBC,EAAS,EAAE,SAAAN,GAAS;AAE1C,SAAAO,EAAU,MAAM;AACd,IAAAJ;AAAA,MAAmB,CAACK,MAClBA,KAAA,gBAAAA,EAAY,IAAI,CAACC,MACKR,EAAO,MAAMQ,EAAM,IAAI,EAChB,UAAUJ,EAAcI,EAAM,IAAI,CAAC,EACnD,WAAWJ,EAAcI,EAAM,IAAI,KAAKJ,EAAcI,EAAM,IAAI,MAAM,KACxE,EAAE,GAAGA,GAAO,UAAUA,EAAM,WAAW,IAEvC,EAAE,GAAGA,GAAO,UAAU,EAAE;AAAA,IAGrC;AAAA,EAAA,GAEC,CAACJ,CAAa,CAAC,GAEXX,EAAeC,CAAe;AACvC;"}
1
+ {"version":3,"file":"useFieldsProgress-BXzIWmGP.js","sources":["../lib/shared/hooks/useFieldsProgress.ts"],"sourcesContent":["'use client'\n\nimport { useEffect, useState } from 'react'\nimport { type Control, type FieldValues, type Path, useWatch } from 'react-hook-form'\nimport { type ZodObject, type ZodRawShape } from 'zod'\n\nexport interface ISubscribedField<T extends FieldValues> {\n name: Path<T>\n progress: number\n maxPercent: number\n}\n\ntype TUseFieldsProgress<T extends FieldValues, S extends ZodRawShape> = {\n control: Control<T>\n schema: ZodObject<S>\n fields: ISubscribedField<T>[]\n}\n\nconst formatProgress = <T extends FieldValues>(subscribeFields: ISubscribedField<T>[]) => {\n return Object.values(subscribeFields)?.reduce((acc, value) => {\n return acc + value?.progress\n }, 0)\n}\n\nexport const useFieldsProgress = <T extends FieldValues, S extends ZodRawShape>({\n control,\n schema,\n fields\n}: TUseFieldsProgress<T, S>): number => {\n const [subscribeFields, setSubscribeFields] = useState<ISubscribedField<T>[]>(fields)\n const watchedFields = useWatch({ control })\n\n useEffect(() => {\n setSubscribeFields((prevFields) =>\n prevFields?.map((field) => {\n const fieldSchema = schema.shape[field.name]\n const result = fieldSchema.safeParse(watchedFields[field.name])\n if (result.success && watchedFields[field.name] && watchedFields[field.name] !== '') {\n return { ...field, progress: field.maxPercent }\n } else {\n return { ...field, progress: 0 }\n }\n })\n )\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [watchedFields])\n\n return formatProgress(subscribeFields)\n}\n"],"names":["formatProgress","subscribeFields","_a","acc","value","useFieldsProgress","control","schema","fields","setSubscribeFields","useState","watchedFields","useWatch","useEffect","prevFields","field"],"mappings":";;AAkBA,MAAMA,IAAiB,CAAwBC,MAA2C;;AACxF,UAAOC,IAAA,OAAO,OAAOD,CAAe,MAA7B,gBAAAC,EAAgC,OAAO,CAACC,GAAKC,MAC3CD,KAAMC,KAAA,gBAAAA,EAAO,WACnB;AACL,GAEaC,IAAoB,CAA+C;AAAA,EAC9E,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,QAAAC;AACF,MAAwC;AACtC,QAAM,CAACP,GAAiBQ,CAAkB,IAAIC,EAAgCF,CAAM,GAC9EG,IAAgBC,EAAS,EAAE,SAAAN,GAAS;AAE1C,SAAAO,EAAU,MAAM;AACd,IAAAJ;AAAA,MAAmB,CAACK,MAClBA,KAAA,gBAAAA,EAAY,IAAI,CAACC,MACKR,EAAO,MAAMQ,EAAM,IAAI,EAChB,UAAUJ,EAAcI,EAAM,IAAI,CAAC,EACnD,WAAWJ,EAAcI,EAAM,IAAI,KAAKJ,EAAcI,EAAM,IAAI,MAAM,KACxE,EAAE,GAAGA,GAAO,UAAUA,EAAM,WAAW,IAEvC,EAAE,GAAGA,GAAO,UAAU,EAAE;AAAA,IAGrC;AAAA,EAAA,GAEC,CAACJ,CAAa,CAAC,GAEXX,EAAeC,CAAe;AACvC;"}
package/dist/utils.js CHANGED
@@ -1,16 +1,15 @@
1
- import { c as a, g as p, s as c } from "./uuid-DQgafI7K.js";
2
- import { T as m, c as l } from "./typeGuards-Bhdr9KYW.js";
1
+ import { a as r, c as s, g as o, s as t } from "./uuid-2wKG15vy.js";
2
+ import { T as c, c as i } from "./typeGuards-Bhdr9KYW.js";
3
3
  import { i as f } from "./isClient-C9aZtt2Q.js";
4
- import { m as u } from "./mergeRefs-qDToYXtM.js";
5
- const s = (r) => r.split("-").map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join("-");
4
+ import { m as n } from "./mergeRefs-qDToYXtM.js";
6
5
  export {
7
- m as TypeGuards,
8
- s as capitalize,
9
- l as cn,
10
- a as createPhoneNumber,
11
- p as getUuid,
6
+ c as TypeGuards,
7
+ r as capitalize,
8
+ i as cn,
9
+ s as createPhoneNumber,
10
+ o as getUuid,
12
11
  f as isClient,
13
- u as mergeRefs,
14
- c as scrollToElement
12
+ n as mergeRefs,
13
+ t as scrollToElement
15
14
  };
16
15
  //# sourceMappingURL=utils.js.map
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../lib/shared/utils/capitalize.ts"],"sourcesContent":["export const capitalize = (str: string) => {\n return str\n .split('-')\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join('-')\n}\n"],"names":["capitalize","str","word"],"mappings":";;;;AAAa,MAAAA,IAAa,CAACC,MAClBA,EACJ,MAAM,GAAG,EACT,IAAI,CAACC,MAASA,EAAK,OAAO,CAAC,EAAE,YAAY,IAAIA,EAAK,MAAM,CAAC,EAAE,YAAa,CAAA,EACxE,KAAK,GAAG;"}
1
+ {"version":3,"file":"utils.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -0,0 +1,25 @@
1
+ import { v4 as n } from "uuid";
2
+ function a(e, o = "x xxx xxx-xx-xx") {
3
+ let t = o;
4
+ for (let r = 0; r < e.length; r++)
5
+ t = t.replace("x", e[r]);
6
+ return t;
7
+ }
8
+ const s = {
9
+ behavior: "smooth",
10
+ block: "center"
11
+ }, x = ({ widgetId: e, config: o = {} }) => {
12
+ const { behavior: t, block: r } = { ...s, ...o }, c = document.getElementById(e);
13
+ if (!c) {
14
+ console.error("Такого элемента в DOM не существует", e);
15
+ return;
16
+ }
17
+ c.scrollIntoView({ behavior: t, block: r });
18
+ }, i = (e) => e.split("-").map((o) => o.charAt(0).toUpperCase() + o.slice(1).toLowerCase()).join("-"), m = () => n();
19
+ export {
20
+ i as a,
21
+ a as c,
22
+ m as g,
23
+ x as s
24
+ };
25
+ //# sourceMappingURL=uuid-2wKG15vy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid-2wKG15vy.js","sources":["../lib/shared/utils/createPhoneNumber.ts","../lib/shared/utils/scrollToElement.ts","../lib/shared/utils/capitalize.ts","../lib/shared/utils/uuid.ts"],"sourcesContent":["export function createPhoneNumber(numbers: string, phoneMask: string = 'x xxx xxx-xx-xx'): string {\n let mask = phoneMask\n\n for (let i = 0; i < numbers.length; i++) {\n mask = mask.replace('x', numbers[i])\n }\n\n return mask\n}\n","import type { AllowedWidgets } from '$/widgets'\n\ntype ScrollConfig = {\n behavior?: ScrollBehavior\n block?: ScrollLogicalPosition\n}\n\ntype ScrollElement = {\n widgetId: AllowedWidgets\n config?: ScrollConfig\n}\n\nconst DEFAULT_SCROLL_CONFIG: Required<ScrollConfig> = {\n behavior: 'smooth',\n block: 'center'\n}\n\nexport const scrollToElement = ({ widgetId, config = {} }: ScrollElement) => {\n const { behavior, block } = { ...DEFAULT_SCROLL_CONFIG, ...config }\n\n const element = document.getElementById(widgetId)\n if (!element) {\n console.error('Такого элемента в DOM не существует', widgetId)\n return\n }\n\n element.scrollIntoView({ behavior, block })\n}\n","export const capitalize = (str: string) => {\n return str\n .split('-')\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join('-')\n}\n","import { v4 as uuid } from 'uuid'\n\nexport const getUuid = () => uuid()\n"],"names":["createPhoneNumber","numbers","phoneMask","mask","i","DEFAULT_SCROLL_CONFIG","scrollToElement","widgetId","config","behavior","block","element","capitalize","str","word","getUuid","uuid"],"mappings":";AAAgB,SAAAA,EAAkBC,GAAiBC,IAAoB,mBAA2B;AAChG,MAAIC,IAAOD;AAEX,WAASE,IAAI,GAAGA,IAAIH,EAAQ,QAAQG;AAClC,IAAAD,IAAOA,EAAK,QAAQ,KAAKF,EAAQG,CAAC,CAAC;AAG9B,SAAAD;AACT;ACIA,MAAME,IAAgD;AAAA,EACpD,UAAU;AAAA,EACV,OAAO;AACT,GAEaC,IAAkB,CAAC,EAAE,UAAAC,GAAU,QAAAC,IAAS,SAAwB;AACrE,QAAA,EAAE,UAAAC,GAAU,OAAAC,EAAM,IAAI,EAAE,GAAGL,GAAuB,GAAGG,EAAO,GAE5DG,IAAU,SAAS,eAAeJ,CAAQ;AAChD,MAAI,CAACI,GAAS;AACJ,YAAA,MAAM,uCAAuCJ,CAAQ;AAC7D;AAAA,EAAA;AAGF,EAAAI,EAAQ,eAAe,EAAE,UAAAF,GAAU,OAAAC,EAAA,CAAO;AAC5C,GC3BaE,IAAa,CAACC,MAClBA,EACJ,MAAM,GAAG,EACT,IAAI,CAACC,MAASA,EAAK,OAAO,CAAC,EAAE,YAAY,IAAIA,EAAK,MAAM,CAAC,EAAE,YAAa,CAAA,EACxE,KAAK,GAAG,GCFAC,IAAU,MAAMC,EAAK;"}