prom-pal-ui 1.2.4 → 1.2.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.
@@ -23637,101 +23637,6 @@ const r=(t,r,o)=>{if(t&&"reportValidity"in t){const s=reactHookForm.get(o,r);t.s
23637
23637
 
23638
23638
  function t(r,e){try{var o=r();}catch(r){return e(r)}return o&&o.then?o.then(void 0,e):o}function s(r,e){for(var n={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(".");if(!n[a])if("unionErrors"in t){var u=t.unionErrors[0].errors[0];n[a]={message:u.message,type:u.code};}else n[a]={message:i,type:s};if("unionErrors"in t&&t.unionErrors.forEach(function(e){return e.errors.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[t.code];n[a]=reactHookForm.appendErrors(a,e,n,s,f?[].concat(f,t.message):t.message);}r.shift();}return n}function i(r,e){for(var n={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(".");if(!n[a])if("invalid_union"===t.code&&t.errors.length>0){var u=t.errors[0][0];n[a]={message:u.message,type:u.code};}else n[a]={message:i,type:s};if("invalid_union"===t.code&&t.errors.forEach(function(e){return e.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[t.code];n[a]=reactHookForm.appendErrors(a,e,n,s,f?[].concat(f,t.message):t.message);}r.shift();}return n}function a(o$1,a,u){if(void 0===u&&(u={}),function(r){return "_def"in r&&"object"==typeof r._def&&"typeName"in r._def}(o$1))return function(n,i,c){try{return Promise.resolve(t(function(){return Promise.resolve(o$1["sync"===u.mode?"parse":"parseAsync"](n,a)).then(function(e){return c.shouldUseNativeValidation&&o({},c),{errors:{},values:u.raw?Object.assign({},n):e}})},function(r){if(function(r){return Array.isArray(null==r?void 0:r.issues)}(r))return {values:{},errors:s$1(s(r.errors,!c.shouldUseNativeValidation&&"all"===c.criteriaMode),c)};throw r}))}catch(r){return Promise.reject(r)}};if(function(r){return "_zod"in r&&"object"==typeof r._zod}(o$1))return function(s,c,f){try{return Promise.resolve(t(function(){return Promise.resolve(("sync"===u.mode?parse$2:parseAsync$1)(o$1,s,a)).then(function(e){return f.shouldUseNativeValidation&&o({},f),{errors:{},values:u.raw?Object.assign({},s):e}})},function(r){if(function(r){return r instanceof $ZodError}(r))return {values:{},errors:s$1(i(r.issues,!f.shouldUseNativeValidation&&"all"===f.criteriaMode),f)};throw r}))}catch(r){return Promise.reject(r)}};throw new Error("Invalid input: not a Zod schema")}
23639
23639
 
23640
- // "use client";
23641
- // import { ReactNode, useState } from "react";
23642
- // import {
23643
- // useForm,
23644
- // Controller,
23645
- // FormProvider,
23646
- // useFormState,
23647
- // useFormContext,
23648
- // type ControllerProps,
23649
- // type FieldPath,
23650
- // type FieldValues,
23651
- // UseFormReturn,
23652
- // } from "react-hook-form";
23653
- // import { zodResolver } from "@hookform/resolvers/zod";
23654
- // import { z } from "zod";
23655
- // import { CommonPromComponentProps } from "../types";
23656
- // type PromFormRenderProps = {
23657
- // isValid: boolean;
23658
- // serverError?: any;
23659
- // isSubmitting: boolean;
23660
- // errors: Record<string, any>;
23661
- // form: UseFormReturn<z.infer<any>>;
23662
- // };
23663
- // interface PromFromProps extends CommonPromComponentProps {
23664
- // children?: ReactNode;
23665
- // schema?: z.ZodObject<any>;
23666
- // defaultValues?: z.infer<any>;
23667
- // form?: UseFormReturn<z.infer<any>>;
23668
- // onSubmit?: (data: z.infer<any>) => Promise<void>;
23669
- // render?: (props: PromFormRenderProps) => ReactNode;
23670
- // }
23671
- // const PromFrom = ({
23672
- // schema,
23673
- // render,
23674
- // children,
23675
- // onSubmit,
23676
- // defaultValues = {},
23677
- // form: externalForm,
23678
- // }: PromFromProps) => {
23679
- // type FormData = z.infer<typeof schema>;
23680
- // const internalForm = useForm<FormData>({
23681
- // resolver: schema ? zodResolver(schema) : undefined,
23682
- // defaultValues: defaultValues,
23683
- // });
23684
- // const form = externalForm || internalForm;
23685
- // const { errors, isSubmitting, isValid } = form.formState;
23686
- // const [serverError, setServerError] = useState<string>("");
23687
- // const handleOnSubmit = async (data: FormData) => {
23688
- // try {
23689
- // await onSubmit(data);
23690
- // } catch (error) {
23691
- // let errorMessage = "Произошла ошибка при отправке формы";
23692
- // setServerError(error || errorMessage);
23693
- // throw error;
23694
- // }
23695
- // };
23696
- // const handleSubmit = handleOnSubmit
23697
- // ? form.handleSubmit(handleOnSubmit)
23698
- // : undefined;
23699
- // return (
23700
- // <FormProvider {...form}>
23701
- // <form
23702
- // onSubmit={handleSubmit}
23703
- // className="space-y-4"
23704
- // onKeyDown={(e) => {
23705
- // if (e.key === "Enter" && !onSubmit) {
23706
- // e.preventDefault();
23707
- // }
23708
- // }}
23709
- // >
23710
- // {render
23711
- // ? render({ form, errors, isSubmitting, isValid, serverError })
23712
- // : children}
23713
- // </form>
23714
- // </FormProvider>
23715
- // );
23716
- // };
23717
- // const usePromForm = <T extends FieldValues>() => {
23718
- // const form = useFormContext<T>();
23719
- // const { errors, isSubmitting, isValid } = form.formState;
23720
- // return {
23721
- // form,
23722
- // errors,
23723
- // isValid,
23724
- // isSubmitting,
23725
- // reset: form.reset,
23726
- // watch: form.watch,
23727
- // control: form.control,
23728
- // trigger: form.trigger,
23729
- // register: form.register,
23730
- // setValue: form.setValue,
23731
- // getValues: form.getValues,
23732
- // handleSubmit: form.handleSubmit,
23733
- // };
23734
- // };
23735
23640
  var PromFrom = function (_a) {
23736
23641
  var schema = _a.schema, render = _a.render, children = _a.children, onSubmit = _a.onSubmit, _b = _a.defaultValues, defaultValues = _b === void 0 ? {} : _b, externalForm = _a.form;
23737
23642
  var internalForm = reactHookForm.useForm({
@@ -23806,43 +23711,6 @@ var usePromForm = function () {
23806
23711
  handleSubmit: form.handleSubmit,
23807
23712
  };
23808
23713
  };
23809
- // const PromFormFiled = <
23810
- // TFieldValues extends FieldValues = FieldValues,
23811
- // TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
23812
- // >({
23813
- // ...props
23814
- // }: PromFormFiledProps<TFieldValues, TName>) => {
23815
- // return <Controller {...props} />;
23816
- // };
23817
- // const PromMessage = () => {
23818
- // const { control } = useFormContext();
23819
- // const { errors } = useFormState({ control });
23820
- // if (Object.keys(errors).length > 0) {
23821
- // console.log(errors);
23822
- // return <p>Ошибка</p>;
23823
- // }
23824
- // };
23825
- // const useCreatePromForm = ({
23826
- // schema,
23827
- // defaultValues,
23828
- // }: {
23829
- // schema: z.ZodObject<any>;
23830
- // defaultValues?: z.infer<any>;
23831
- // }) => {
23832
- // return useForm({
23833
- // resolver: schema ? zodResolver(schema) : undefined,
23834
- // defaultValues,
23835
- // });
23836
- // };
23837
- // export {
23838
- // PromFrom,
23839
- // usePromForm,
23840
- // PromMessage,
23841
- // PromFormFiled,
23842
- // useCreatePromForm,
23843
- // type PromFromProps,
23844
- // type PromFormRenderProps,
23845
- // };
23846
23714
  var PromFormFiled = function (_a) {
23847
23715
  var props = tslib.__rest(_a, []);
23848
23716
  return jsxRuntimeExports.jsx(reactHookForm.Controller, tslib.__assign({}, props));
@@ -23617,101 +23617,6 @@ const r=(t,r,o)=>{if(t&&"reportValidity"in t){const s=get(o,r);t.setCustomValidi
23617
23617
 
23618
23618
  function t(r,e){try{var o=r();}catch(r){return e(r)}return o&&o.then?o.then(void 0,e):o}function s(r,e){for(var n={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(".");if(!n[a])if("unionErrors"in t){var u=t.unionErrors[0].errors[0];n[a]={message:u.message,type:u.code};}else n[a]={message:i,type:s};if("unionErrors"in t&&t.unionErrors.forEach(function(e){return e.errors.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[t.code];n[a]=appendErrors(a,e,n,s,f?[].concat(f,t.message):t.message);}r.shift();}return n}function i(r,e){for(var n={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(".");if(!n[a])if("invalid_union"===t.code&&t.errors.length>0){var u=t.errors[0][0];n[a]={message:u.message,type:u.code};}else n[a]={message:i,type:s};if("invalid_union"===t.code&&t.errors.forEach(function(e){return e.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[t.code];n[a]=appendErrors(a,e,n,s,f?[].concat(f,t.message):t.message);}r.shift();}return n}function a(o$1,a,u){if(void 0===u&&(u={}),function(r){return "_def"in r&&"object"==typeof r._def&&"typeName"in r._def}(o$1))return function(n,i,c){try{return Promise.resolve(t(function(){return Promise.resolve(o$1["sync"===u.mode?"parse":"parseAsync"](n,a)).then(function(e){return c.shouldUseNativeValidation&&o({},c),{errors:{},values:u.raw?Object.assign({},n):e}})},function(r){if(function(r){return Array.isArray(null==r?void 0:r.issues)}(r))return {values:{},errors:s$1(s(r.errors,!c.shouldUseNativeValidation&&"all"===c.criteriaMode),c)};throw r}))}catch(r){return Promise.reject(r)}};if(function(r){return "_zod"in r&&"object"==typeof r._zod}(o$1))return function(s,c,f){try{return Promise.resolve(t(function(){return Promise.resolve(("sync"===u.mode?parse$2:parseAsync$1)(o$1,s,a)).then(function(e){return f.shouldUseNativeValidation&&o({},f),{errors:{},values:u.raw?Object.assign({},s):e}})},function(r){if(function(r){return r instanceof $ZodError}(r))return {values:{},errors:s$1(i(r.issues,!f.shouldUseNativeValidation&&"all"===f.criteriaMode),f)};throw r}))}catch(r){return Promise.reject(r)}};throw new Error("Invalid input: not a Zod schema")}
23619
23619
 
23620
- // "use client";
23621
- // import { ReactNode, useState } from "react";
23622
- // import {
23623
- // useForm,
23624
- // Controller,
23625
- // FormProvider,
23626
- // useFormState,
23627
- // useFormContext,
23628
- // type ControllerProps,
23629
- // type FieldPath,
23630
- // type FieldValues,
23631
- // UseFormReturn,
23632
- // } from "react-hook-form";
23633
- // import { zodResolver } from "@hookform/resolvers/zod";
23634
- // import { z } from "zod";
23635
- // import { CommonPromComponentProps } from "../types";
23636
- // type PromFormRenderProps = {
23637
- // isValid: boolean;
23638
- // serverError?: any;
23639
- // isSubmitting: boolean;
23640
- // errors: Record<string, any>;
23641
- // form: UseFormReturn<z.infer<any>>;
23642
- // };
23643
- // interface PromFromProps extends CommonPromComponentProps {
23644
- // children?: ReactNode;
23645
- // schema?: z.ZodObject<any>;
23646
- // defaultValues?: z.infer<any>;
23647
- // form?: UseFormReturn<z.infer<any>>;
23648
- // onSubmit?: (data: z.infer<any>) => Promise<void>;
23649
- // render?: (props: PromFormRenderProps) => ReactNode;
23650
- // }
23651
- // const PromFrom = ({
23652
- // schema,
23653
- // render,
23654
- // children,
23655
- // onSubmit,
23656
- // defaultValues = {},
23657
- // form: externalForm,
23658
- // }: PromFromProps) => {
23659
- // type FormData = z.infer<typeof schema>;
23660
- // const internalForm = useForm<FormData>({
23661
- // resolver: schema ? zodResolver(schema) : undefined,
23662
- // defaultValues: defaultValues,
23663
- // });
23664
- // const form = externalForm || internalForm;
23665
- // const { errors, isSubmitting, isValid } = form.formState;
23666
- // const [serverError, setServerError] = useState<string>("");
23667
- // const handleOnSubmit = async (data: FormData) => {
23668
- // try {
23669
- // await onSubmit(data);
23670
- // } catch (error) {
23671
- // let errorMessage = "Произошла ошибка при отправке формы";
23672
- // setServerError(error || errorMessage);
23673
- // throw error;
23674
- // }
23675
- // };
23676
- // const handleSubmit = handleOnSubmit
23677
- // ? form.handleSubmit(handleOnSubmit)
23678
- // : undefined;
23679
- // return (
23680
- // <FormProvider {...form}>
23681
- // <form
23682
- // onSubmit={handleSubmit}
23683
- // className="space-y-4"
23684
- // onKeyDown={(e) => {
23685
- // if (e.key === "Enter" && !onSubmit) {
23686
- // e.preventDefault();
23687
- // }
23688
- // }}
23689
- // >
23690
- // {render
23691
- // ? render({ form, errors, isSubmitting, isValid, serverError })
23692
- // : children}
23693
- // </form>
23694
- // </FormProvider>
23695
- // );
23696
- // };
23697
- // const usePromForm = <T extends FieldValues>() => {
23698
- // const form = useFormContext<T>();
23699
- // const { errors, isSubmitting, isValid } = form.formState;
23700
- // return {
23701
- // form,
23702
- // errors,
23703
- // isValid,
23704
- // isSubmitting,
23705
- // reset: form.reset,
23706
- // watch: form.watch,
23707
- // control: form.control,
23708
- // trigger: form.trigger,
23709
- // register: form.register,
23710
- // setValue: form.setValue,
23711
- // getValues: form.getValues,
23712
- // handleSubmit: form.handleSubmit,
23713
- // };
23714
- // };
23715
23620
  var PromFrom = function (_a) {
23716
23621
  var schema = _a.schema, render = _a.render, children = _a.children, onSubmit = _a.onSubmit, _b = _a.defaultValues, defaultValues = _b === void 0 ? {} : _b, externalForm = _a.form;
23717
23622
  var internalForm = useForm({
@@ -23786,43 +23691,6 @@ var usePromForm = function () {
23786
23691
  handleSubmit: form.handleSubmit,
23787
23692
  };
23788
23693
  };
23789
- // const PromFormFiled = <
23790
- // TFieldValues extends FieldValues = FieldValues,
23791
- // TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
23792
- // >({
23793
- // ...props
23794
- // }: PromFormFiledProps<TFieldValues, TName>) => {
23795
- // return <Controller {...props} />;
23796
- // };
23797
- // const PromMessage = () => {
23798
- // const { control } = useFormContext();
23799
- // const { errors } = useFormState({ control });
23800
- // if (Object.keys(errors).length > 0) {
23801
- // console.log(errors);
23802
- // return <p>Ошибка</p>;
23803
- // }
23804
- // };
23805
- // const useCreatePromForm = ({
23806
- // schema,
23807
- // defaultValues,
23808
- // }: {
23809
- // schema: z.ZodObject<any>;
23810
- // defaultValues?: z.infer<any>;
23811
- // }) => {
23812
- // return useForm({
23813
- // resolver: schema ? zodResolver(schema) : undefined,
23814
- // defaultValues,
23815
- // });
23816
- // };
23817
- // export {
23818
- // PromFrom,
23819
- // usePromForm,
23820
- // PromMessage,
23821
- // PromFormFiled,
23822
- // useCreatePromForm,
23823
- // type PromFromProps,
23824
- // type PromFormRenderProps,
23825
- // };
23826
23694
  var PromFormFiled = function (_a) {
23827
23695
  var props = __rest(_a, []);
23828
23696
  return jsxRuntimeExports.jsx(Controller, __assign({}, props));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prom-pal-ui",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "type": "module",
5
5
  "main": "build/cjs/index.js",
6
6
  "module": "build/esm/index.js",
@@ -12,12 +12,12 @@
12
12
  ".": {
13
13
  "import": "./build/ui/esm/index.js",
14
14
  "require": "./build/ui/cjs/index.js",
15
- "types": "./build/ui/types/index.d.ts"
15
+ "types": "./build/types/index.d.ts"
16
16
  },
17
17
  "./function": {
18
- "import": "./build/ui/esm/index.js",
19
- "require": "./build/ui/cjs/index.js",
20
- "types": "./build/ui/types/index.d.ts"
18
+ "import": "./build/function/esm/index.js",
19
+ "require": "./build/function/cjs/index.js",
20
+ "types": "./build/types/index.d.ts"
21
21
  }
22
22
  },
23
23
  "publishConfig": {