prom-pal-ui 1.2.4 → 1.2.6

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 +1,2 @@
1
1
  export { usePromPromiseQuery } from "./api";
2
+ export * from "./lib";
@@ -0,0 +1,2 @@
1
+ export * from "./schema";
2
+ export * from "./schema-msg";
@@ -0,0 +1,5 @@
1
+ declare const PROM_MSG_ERROR: {
2
+ EMPTY: string;
3
+ INVALID_VALUES: string;
4
+ };
5
+ export { PROM_MSG_ERROR };
@@ -0,0 +1,3 @@
1
+ import z from "zod";
2
+ declare const promSchemaPhone: z.ZodString;
3
+ export { promSchemaPhone };
@@ -0,0 +1,2 @@
1
+ export { cn } from "./utils";
2
+ export * from "./form/rules";
@@ -0,0 +1,2 @@
1
+ import { type ClassValue } from "clsx";
2
+ export declare function cn(...inputs: ClassValue[]): string;
@@ -3,5 +3,4 @@ export * from "./ui/select";
3
3
  export * from "./fields";
4
4
  export * from "./ui/skeleton";
5
5
  import "./styles/tailwind.css";
6
- export * from "./lib/index";
7
6
  export * from "./ui/test";
@@ -18185,15 +18185,10 @@ var z = /*#__PURE__*/Object.freeze({
18185
18185
  xor: xor
18186
18186
  });
18187
18187
 
18188
- var promSchemaPhone = z.string().regex(/^\+7\d{10}$/, {
18188
+ z.string().regex(/^\+7\d{10}$/, {
18189
18189
  message: "Номер должен быть в формате +7XXXXXXXXXX (11 цифр)",
18190
18190
  });
18191
18191
 
18192
- var PROM_MSG_ERROR = {
18193
- EMPTY: "Поле обязательно для заполнения",
18194
- INVALID_VALUES: "Недопустимые значения",
18195
- };
18196
-
18197
18192
  var buttonVariants = cva("inline-flex items-center cursor-pointer justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", {
18198
18193
  variants: {
18199
18194
  variant: {
@@ -23637,101 +23632,6 @@ const r=(t,r,o)=>{if(t&&"reportValidity"in t){const s=reactHookForm.get(o,r);t.s
23637
23632
 
23638
23633
  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
23634
 
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
23635
  var PromFrom = function (_a) {
23736
23636
  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
23637
  var internalForm = reactHookForm.useForm({
@@ -23806,43 +23706,6 @@ var usePromForm = function () {
23806
23706
  handleSubmit: form.handleSubmit,
23807
23707
  };
23808
23708
  };
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
23709
  var PromFormFiled = function (_a) {
23847
23710
  var props = tslib.__rest(_a, []);
23848
23711
  return jsxRuntimeExports.jsx(reactHookForm.Controller, tslib.__assign({}, props));
@@ -24161,7 +24024,6 @@ function PromTest() {
24161
24024
  return (jsxRuntimeExports.jsx("div", { className: "text-primary test-text text-lg font-medium p-4 bg-gray-100 rounded-lg", children: "test \u0446\u0432\u0435\u0442\u0430 \u043E\u0430\u043B\u0434\u044B\u0432\u043E\u0430\u043B\u043E\u0432\u0430\u043B" }));
24162
24025
  }
24163
24026
 
24164
- exports.PROM_MSG_ERROR = PROM_MSG_ERROR;
24165
24027
  exports.PromButton = PromButton;
24166
24028
  exports.PromFormFiled = PromFormFiled;
24167
24029
  exports.PromFrom = PromFrom;
@@ -24184,8 +24046,6 @@ exports.PromSwitchField = PromSwitchField;
24184
24046
  exports.PromTest = PromTest;
24185
24047
  exports.PromTextarea = PromTextarea;
24186
24048
  exports.buttonVariants = buttonVariants;
24187
- exports.cn = cn;
24188
- exports.promSchemaPhone = promSchemaPhone;
24189
24049
  exports.promSelectFilterOptions = promSelectFilterOptions;
24190
24050
  exports.skeletonVariants = skeletonVariants;
24191
24051
  exports.useCreatePromForm = useCreatePromForm;
@@ -18165,15 +18165,10 @@ var z = /*#__PURE__*/Object.freeze({
18165
18165
  xor: xor
18166
18166
  });
18167
18167
 
18168
- var promSchemaPhone = z.string().regex(/^\+7\d{10}$/, {
18168
+ z.string().regex(/^\+7\d{10}$/, {
18169
18169
  message: "Номер должен быть в формате +7XXXXXXXXXX (11 цифр)",
18170
18170
  });
18171
18171
 
18172
- var PROM_MSG_ERROR = {
18173
- EMPTY: "Поле обязательно для заполнения",
18174
- INVALID_VALUES: "Недопустимые значения",
18175
- };
18176
-
18177
18172
  var buttonVariants = cva("inline-flex items-center cursor-pointer justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", {
18178
18173
  variants: {
18179
18174
  variant: {
@@ -23617,101 +23612,6 @@ const r=(t,r,o)=>{if(t&&"reportValidity"in t){const s=get(o,r);t.setCustomValidi
23617
23612
 
23618
23613
  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
23614
 
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
23615
  var PromFrom = function (_a) {
23716
23616
  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
23617
  var internalForm = useForm({
@@ -23786,43 +23686,6 @@ var usePromForm = function () {
23786
23686
  handleSubmit: form.handleSubmit,
23787
23687
  };
23788
23688
  };
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
23689
  var PromFormFiled = function (_a) {
23827
23690
  var props = __rest(_a, []);
23828
23691
  return jsxRuntimeExports.jsx(Controller, __assign({}, props));
@@ -24141,4 +24004,4 @@ function PromTest() {
24141
24004
  return (jsxRuntimeExports.jsx("div", { className: "text-primary test-text text-lg font-medium p-4 bg-gray-100 rounded-lg", children: "test \u0446\u0432\u0435\u0442\u0430 \u043E\u0430\u043B\u0434\u044B\u0432\u043E\u0430\u043B\u043E\u0432\u0430\u043B" }));
24142
24005
  }
24143
24006
 
24144
- export { PROM_MSG_ERROR, PromButton, PromFormFiled, PromFrom, PromInput, PromLabel, PromMessage, PromSelect, PromSelectContent, PromSelectField, PromSelectGroup, PromSelectItem, PromSelectLabel, PromSelectScrollDownButton, PromSelectScrollUpButton, PromSelectSeparator, PromSelectTrigger, PromSelectValue, PromSkeleton, PromSwitchField, PromTest, PromTextarea, buttonVariants, cn, promSchemaPhone, promSelectFilterOptions, skeletonVariants, useCreatePromForm, usePromForm };
24007
+ export { PromButton, PromFormFiled, PromFrom, PromInput, PromLabel, PromMessage, PromSelect, PromSelectContent, PromSelectField, PromSelectGroup, PromSelectItem, PromSelectLabel, PromSelectScrollDownButton, PromSelectScrollUpButton, PromSelectSeparator, PromSelectTrigger, PromSelectValue, PromSkeleton, PromSwitchField, PromTest, PromTextarea, buttonVariants, promSelectFilterOptions, skeletonVariants, useCreatePromForm, usePromForm };
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.6",
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": {