@algorithm-shift/design-system 1.2.43 → 1.2.45
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/chunk-QZ2QO7MJ.mjs +24 -0
- package/dist/chunk-QZ2QO7MJ.mjs.map +1 -0
- package/dist/client.d.mts +39 -0
- package/dist/client.d.ts +39 -0
- package/dist/client.js +344 -0
- package/dist/client.js.map +1 -0
- package/dist/client.mjs +298 -0
- package/dist/client.mjs.map +1 -0
- package/dist/index.d.mts +1 -36
- package/dist/index.d.ts +1 -36
- package/dist/index.js +6 -302
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -312
- package/dist/index.mjs.map +1 -1
- package/package.json +19 -1
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import {
|
|
3
|
+
cn,
|
|
4
|
+
getInitials
|
|
5
|
+
} from "./chunk-QZ2QO7MJ.mjs";
|
|
6
|
+
|
|
1
7
|
// src/components/Layout/Modal.tsx
|
|
2
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
9
|
var Modal = ({
|
|
@@ -64,25 +70,6 @@ var Container_default = Container;
|
|
|
64
70
|
// src/components/ui/button.tsx
|
|
65
71
|
import { Slot } from "@radix-ui/react-slot";
|
|
66
72
|
import { cva } from "class-variance-authority";
|
|
67
|
-
|
|
68
|
-
// src/lib/utils.ts
|
|
69
|
-
import { clsx } from "clsx";
|
|
70
|
-
import { twMerge } from "tailwind-merge";
|
|
71
|
-
function cn(...inputs) {
|
|
72
|
-
return twMerge(clsx(inputs));
|
|
73
|
-
}
|
|
74
|
-
function getInitials(name) {
|
|
75
|
-
const words = name.split(" ");
|
|
76
|
-
if (words.length === 0) {
|
|
77
|
-
return "";
|
|
78
|
-
}
|
|
79
|
-
if (words.length === 1) {
|
|
80
|
-
return words[0].charAt(0);
|
|
81
|
-
}
|
|
82
|
-
return words[0].charAt(0) + words[1].charAt(0);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// src/components/ui/button.tsx
|
|
86
73
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
87
74
|
var buttonVariants = cva(
|
|
88
75
|
"inline-flex items-center 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",
|
|
@@ -2768,293 +2755,6 @@ function showSonnerToast({
|
|
|
2768
2755
|
toast(title, options);
|
|
2769
2756
|
}
|
|
2770
2757
|
}
|
|
2771
|
-
|
|
2772
|
-
// src/components/StateManagment/StateContext.tsx
|
|
2773
|
-
import { createContext, useContext, useReducer } from "react";
|
|
2774
|
-
|
|
2775
|
-
// src/components/StateManagment/stateReducer.ts
|
|
2776
|
-
function stateReducer(state, action) {
|
|
2777
|
-
switch (action.type) {
|
|
2778
|
-
case "SET_STATE":
|
|
2779
|
-
return { ...state, [action.key]: action.value };
|
|
2780
|
-
default:
|
|
2781
|
-
return state;
|
|
2782
|
-
}
|
|
2783
|
-
}
|
|
2784
|
-
|
|
2785
|
-
// src/components/StateManagment/StateContext.tsx
|
|
2786
|
-
import { jsx as jsx56 } from "react/jsx-runtime";
|
|
2787
|
-
var StateContext = createContext(null);
|
|
2788
|
-
function StateProvider({ children }) {
|
|
2789
|
-
const [state, dispatch] = useReducer(stateReducer, {});
|
|
2790
|
-
return /* @__PURE__ */ jsx56(StateContext.Provider, { value: { state, dispatch }, children });
|
|
2791
|
-
}
|
|
2792
|
-
function useAppState() {
|
|
2793
|
-
return useContext(StateContext);
|
|
2794
|
-
}
|
|
2795
|
-
|
|
2796
|
-
// src/components/Form/Form.tsx
|
|
2797
|
-
import React7, { useMemo as useMemo2 } from "react";
|
|
2798
|
-
import { zodResolver } from "@hookform/resolvers/zod";
|
|
2799
|
-
import { useForm, Controller } from "react-hook-form";
|
|
2800
|
-
import { z } from "zod";
|
|
2801
|
-
import { jsx as jsx57 } from "react/jsx-runtime";
|
|
2802
|
-
function generateZodSchema(data) {
|
|
2803
|
-
const fields = data.reduce((acc, f) => {
|
|
2804
|
-
const name = f.name || "unnamed";
|
|
2805
|
-
const message = f.message || `${name} is invalid`;
|
|
2806
|
-
const passwordLen = f.passwordLength;
|
|
2807
|
-
let fieldSchema = z.string({ message });
|
|
2808
|
-
switch (f.type) {
|
|
2809
|
-
case "Text":
|
|
2810
|
-
case "Search":
|
|
2811
|
-
fieldSchema = z.string({ message });
|
|
2812
|
-
if (f?.min && f?.min !== "") fieldSchema = fieldSchema.min(f.min);
|
|
2813
|
-
else if (f.isRequired) fieldSchema = fieldSchema.min(1, { message: `${message}. Cannot be empty` });
|
|
2814
|
-
if (f?.max && f?.max !== "") fieldSchema = fieldSchema.max(f.max);
|
|
2815
|
-
if (f?.email) fieldSchema = fieldSchema.email();
|
|
2816
|
-
if (f?.url) fieldSchema = fieldSchema.url();
|
|
2817
|
-
if (f?.regex) fieldSchema = fieldSchema.regex(new RegExp(f.regex));
|
|
2818
|
-
break;
|
|
2819
|
-
case "Email":
|
|
2820
|
-
fieldSchema = z.email({ message });
|
|
2821
|
-
break;
|
|
2822
|
-
case "Password":
|
|
2823
|
-
fieldSchema = z.string({ message }).min(passwordLen, { message: `Password must be at least ${passwordLen} characters long` });
|
|
2824
|
-
break;
|
|
2825
|
-
case "Phone":
|
|
2826
|
-
fieldSchema = z.string().transform((val) => val.replace(/\D/g, "")).transform((val) => val.slice(-10)).refine((val) => {
|
|
2827
|
-
return val.length === 10;
|
|
2828
|
-
}, {
|
|
2829
|
-
message: "Phone number must be 10 digits long"
|
|
2830
|
-
});
|
|
2831
|
-
break;
|
|
2832
|
-
case "DatePicker":
|
|
2833
|
-
fieldSchema = z.iso.date({ message });
|
|
2834
|
-
break;
|
|
2835
|
-
case "FileInput":
|
|
2836
|
-
fieldSchema = z.instanceof(File, { message: "Please select a file" });
|
|
2837
|
-
if (f?.maxSize) {
|
|
2838
|
-
fieldSchema = fieldSchema.refine(
|
|
2839
|
-
(file) => file.size <= f.maxSize,
|
|
2840
|
-
{ message: `File size must be less than ${f.maxSize / 1024 / 1024}MB` }
|
|
2841
|
-
);
|
|
2842
|
-
}
|
|
2843
|
-
if (f?.acceptedTypes) {
|
|
2844
|
-
fieldSchema = fieldSchema.refine(
|
|
2845
|
-
(file) => f.acceptedTypes.includes(file.type),
|
|
2846
|
-
{ message: `File type must be one of: ${f.acceptedTypes.join(", ")}` }
|
|
2847
|
-
);
|
|
2848
|
-
}
|
|
2849
|
-
break;
|
|
2850
|
-
case "Checkbox":
|
|
2851
|
-
fieldSchema = z.boolean({ message });
|
|
2852
|
-
break;
|
|
2853
|
-
case "Dropdown":
|
|
2854
|
-
fieldSchema = z.string({ message });
|
|
2855
|
-
break;
|
|
2856
|
-
case "NumberInput":
|
|
2857
|
-
fieldSchema = z.number({ message });
|
|
2858
|
-
if (f?.min !== void 0) fieldSchema = fieldSchema.min(f.min);
|
|
2859
|
-
if (f?.max !== void 0) fieldSchema = fieldSchema.max(f.max);
|
|
2860
|
-
break;
|
|
2861
|
-
default:
|
|
2862
|
-
fieldSchema = z.any();
|
|
2863
|
-
}
|
|
2864
|
-
if (!f.isRequired) fieldSchema = fieldSchema.optional();
|
|
2865
|
-
acc[name] = fieldSchema;
|
|
2866
|
-
return acc;
|
|
2867
|
-
}, {});
|
|
2868
|
-
return z.object(fields);
|
|
2869
|
-
}
|
|
2870
|
-
var Form = ({
|
|
2871
|
-
validation,
|
|
2872
|
-
defaultValues,
|
|
2873
|
-
children,
|
|
2874
|
-
onSubmit,
|
|
2875
|
-
onReset
|
|
2876
|
-
}) => {
|
|
2877
|
-
const schema = useMemo2(() => {
|
|
2878
|
-
if (!validation || validation.length === 0) return null;
|
|
2879
|
-
return generateZodSchema(validation);
|
|
2880
|
-
}, [validation]);
|
|
2881
|
-
const {
|
|
2882
|
-
handleSubmit,
|
|
2883
|
-
control,
|
|
2884
|
-
formState: { errors },
|
|
2885
|
-
reset
|
|
2886
|
-
} = useForm({
|
|
2887
|
-
resolver: schema ? zodResolver(schema) : void 0,
|
|
2888
|
-
defaultValues
|
|
2889
|
-
});
|
|
2890
|
-
const formSubmit = (data) => {
|
|
2891
|
-
if (onSubmit) onSubmit(data);
|
|
2892
|
-
};
|
|
2893
|
-
const handleReset = () => {
|
|
2894
|
-
reset();
|
|
2895
|
-
if (onReset) onReset();
|
|
2896
|
-
};
|
|
2897
|
-
return /* @__PURE__ */ jsx57(
|
|
2898
|
-
"form",
|
|
2899
|
-
{
|
|
2900
|
-
onSubmit: handleSubmit(formSubmit),
|
|
2901
|
-
onReset: handleReset,
|
|
2902
|
-
className: cn(
|
|
2903
|
-
"space-y-4 min-h-[100px] h-auto flex justify-between flex-col"
|
|
2904
|
-
),
|
|
2905
|
-
children: /* @__PURE__ */ jsx57("div", { className: "min-h-[50px]", children: React7.Children.map(children, (child) => {
|
|
2906
|
-
const processChild = (child2) => {
|
|
2907
|
-
if (React7.isValidElement(child2)) {
|
|
2908
|
-
const node = child2.props?.node;
|
|
2909
|
-
if (node?.category === "Form Controls") {
|
|
2910
|
-
const name = node.properties?.name || "unnamed";
|
|
2911
|
-
return /* @__PURE__ */ jsx57("div", { className: "flex flex-col", children: /* @__PURE__ */ jsx57(
|
|
2912
|
-
Controller,
|
|
2913
|
-
{
|
|
2914
|
-
name,
|
|
2915
|
-
control,
|
|
2916
|
-
render: ({ field: controllerField }) => {
|
|
2917
|
-
const childElement = child2;
|
|
2918
|
-
return React7.cloneElement(childElement, {
|
|
2919
|
-
input: {
|
|
2920
|
-
...controllerField,
|
|
2921
|
-
value: controllerField.value || "",
|
|
2922
|
-
hasFormContainer: true,
|
|
2923
|
-
validateOnMount: true,
|
|
2924
|
-
errorMessage: errors[name]?.message || null
|
|
2925
|
-
},
|
|
2926
|
-
children: void 0
|
|
2927
|
-
});
|
|
2928
|
-
}
|
|
2929
|
-
}
|
|
2930
|
-
) }, node.id);
|
|
2931
|
-
}
|
|
2932
|
-
if (child2.props?.children) {
|
|
2933
|
-
const childElement = child2;
|
|
2934
|
-
return React7.cloneElement(childElement, {
|
|
2935
|
-
children: React7.Children.map(childElement.props.children, processChild)
|
|
2936
|
-
});
|
|
2937
|
-
}
|
|
2938
|
-
return React7.cloneElement(child2);
|
|
2939
|
-
}
|
|
2940
|
-
return child2;
|
|
2941
|
-
};
|
|
2942
|
-
return processChild(child);
|
|
2943
|
-
}) })
|
|
2944
|
-
}
|
|
2945
|
-
);
|
|
2946
|
-
};
|
|
2947
|
-
var Form_default = Form;
|
|
2948
|
-
|
|
2949
|
-
// src/components/Form/Wrapper.tsx
|
|
2950
|
-
import { useMemo as useMemo3 } from "react";
|
|
2951
|
-
import { zodResolver as zodResolver2 } from "@hookform/resolvers/zod";
|
|
2952
|
-
import { useForm as useForm2 } from "react-hook-form";
|
|
2953
|
-
import { z as z2 } from "zod";
|
|
2954
|
-
import { jsx as jsx58 } from "react/jsx-runtime";
|
|
2955
|
-
function generateZodSchema2(data) {
|
|
2956
|
-
const fields = data.reduce((acc, f) => {
|
|
2957
|
-
const name = f.name || "unnamed";
|
|
2958
|
-
const message = f.message || `${name} is invalid`;
|
|
2959
|
-
const passwordLen = f.passwordLength;
|
|
2960
|
-
let fieldSchema = z2.string({ message });
|
|
2961
|
-
switch (f.type) {
|
|
2962
|
-
case "Text":
|
|
2963
|
-
case "Search":
|
|
2964
|
-
fieldSchema = z2.string({ message });
|
|
2965
|
-
if (f?.min && f?.min !== "") fieldSchema = fieldSchema.min(f.min);
|
|
2966
|
-
else if (f.isRequired) fieldSchema = fieldSchema.min(1, { message: `${message}. Cannot be empty` });
|
|
2967
|
-
if (f?.max && f?.max !== "") fieldSchema = fieldSchema.max(f.max);
|
|
2968
|
-
if (f?.email) fieldSchema = fieldSchema.email();
|
|
2969
|
-
if (f?.url) fieldSchema = fieldSchema.url();
|
|
2970
|
-
if (f?.regex) fieldSchema = fieldSchema.regex(new RegExp(f.regex));
|
|
2971
|
-
break;
|
|
2972
|
-
case "Email":
|
|
2973
|
-
fieldSchema = z2.email({ message });
|
|
2974
|
-
break;
|
|
2975
|
-
case "Password":
|
|
2976
|
-
fieldSchema = z2.string({ message }).min(passwordLen, { message: `Password must be at least ${passwordLen} characters long` });
|
|
2977
|
-
break;
|
|
2978
|
-
case "Phone":
|
|
2979
|
-
fieldSchema = z2.string().transform((val) => val.replace(/\D/g, "")).transform((val) => val.slice(-10)).refine((val) => {
|
|
2980
|
-
return val.length === 10;
|
|
2981
|
-
}, {
|
|
2982
|
-
message: "Phone number must be 10 digits long"
|
|
2983
|
-
});
|
|
2984
|
-
break;
|
|
2985
|
-
case "DatePicker":
|
|
2986
|
-
fieldSchema = z2.iso.date({ message });
|
|
2987
|
-
break;
|
|
2988
|
-
case "FileInput":
|
|
2989
|
-
fieldSchema = z2.instanceof(File, { message: "Please select a file" });
|
|
2990
|
-
if (f?.maxSize) {
|
|
2991
|
-
fieldSchema = fieldSchema.refine(
|
|
2992
|
-
(file) => file.size <= f.maxSize,
|
|
2993
|
-
{ message: `File size must be less than ${f.maxSize / 1024 / 1024}MB` }
|
|
2994
|
-
);
|
|
2995
|
-
}
|
|
2996
|
-
if (f?.acceptedTypes) {
|
|
2997
|
-
fieldSchema = fieldSchema.refine(
|
|
2998
|
-
(file) => f.acceptedTypes.includes(file.type),
|
|
2999
|
-
{ message: `File type must be one of: ${f.acceptedTypes.join(", ")}` }
|
|
3000
|
-
);
|
|
3001
|
-
}
|
|
3002
|
-
break;
|
|
3003
|
-
case "Checkbox":
|
|
3004
|
-
fieldSchema = z2.boolean({ message });
|
|
3005
|
-
break;
|
|
3006
|
-
case "Dropdown":
|
|
3007
|
-
fieldSchema = z2.string({ message });
|
|
3008
|
-
break;
|
|
3009
|
-
case "NumberInput":
|
|
3010
|
-
fieldSchema = z2.number({ message });
|
|
3011
|
-
if (f?.min !== void 0) fieldSchema = fieldSchema.min(f.min);
|
|
3012
|
-
if (f?.max !== void 0) fieldSchema = fieldSchema.max(f.max);
|
|
3013
|
-
break;
|
|
3014
|
-
default:
|
|
3015
|
-
fieldSchema = z2.any();
|
|
3016
|
-
}
|
|
3017
|
-
if (!f.isRequired) fieldSchema = fieldSchema.optional();
|
|
3018
|
-
acc[name] = fieldSchema;
|
|
3019
|
-
return acc;
|
|
3020
|
-
}, {});
|
|
3021
|
-
return z2.object(fields);
|
|
3022
|
-
}
|
|
3023
|
-
var FormWrapper = ({
|
|
3024
|
-
validation,
|
|
3025
|
-
defaultValues,
|
|
3026
|
-
children,
|
|
3027
|
-
onSubmit,
|
|
3028
|
-
onReset
|
|
3029
|
-
}) => {
|
|
3030
|
-
const schema = useMemo3(() => {
|
|
3031
|
-
if (!validation || validation.length === 0) return null;
|
|
3032
|
-
return generateZodSchema2(validation);
|
|
3033
|
-
}, [validation]);
|
|
3034
|
-
const form = useForm2({
|
|
3035
|
-
resolver: schema ? zodResolver2(schema) : void 0,
|
|
3036
|
-
defaultValues
|
|
3037
|
-
});
|
|
3038
|
-
const formSubmit = (data) => {
|
|
3039
|
-
if (onSubmit) onSubmit(data);
|
|
3040
|
-
};
|
|
3041
|
-
const handleReset = () => {
|
|
3042
|
-
form.reset();
|
|
3043
|
-
if (onReset) onReset();
|
|
3044
|
-
};
|
|
3045
|
-
return /* @__PURE__ */ jsx58(
|
|
3046
|
-
"form",
|
|
3047
|
-
{
|
|
3048
|
-
onSubmit: form.handleSubmit(formSubmit),
|
|
3049
|
-
onReset: handleReset,
|
|
3050
|
-
className: cn(
|
|
3051
|
-
"space-y-4 min-h-[100px] h-auto flex justify-between flex-col"
|
|
3052
|
-
),
|
|
3053
|
-
children: /* @__PURE__ */ jsx58("div", { className: "min-h-[50px]", children: typeof children === "function" ? children(form) : children })
|
|
3054
|
-
}
|
|
3055
|
-
);
|
|
3056
|
-
};
|
|
3057
|
-
var Wrapper_default = FormWrapper;
|
|
3058
2758
|
export {
|
|
3059
2759
|
BarChart_default as BarChart,
|
|
3060
2760
|
Breadcrumb_default as Breadcrumb,
|
|
@@ -3069,8 +2769,6 @@ export {
|
|
|
3069
2769
|
EmailComposer,
|
|
3070
2770
|
FileInput_default as FileInput,
|
|
3071
2771
|
Flex_default as FlexLayout,
|
|
3072
|
-
Form_default as Form,
|
|
3073
|
-
Wrapper_default as FormWrapper,
|
|
3074
2772
|
Grid_default as GridLayout,
|
|
3075
2773
|
Image_default as Image,
|
|
3076
2774
|
Modal_default as Modal,
|
|
@@ -3087,7 +2785,6 @@ export {
|
|
|
3087
2785
|
Shape_default as Shape,
|
|
3088
2786
|
Spacer_default as Spacer,
|
|
3089
2787
|
Stages_default as Stages,
|
|
3090
|
-
StateProvider,
|
|
3091
2788
|
SwitchToggle_default as SwitchToggle,
|
|
3092
2789
|
Table_default as Table,
|
|
3093
2790
|
Tabs_default as Tabs,
|
|
@@ -3098,9 +2795,7 @@ export {
|
|
|
3098
2795
|
UrlInput_default as URL,
|
|
3099
2796
|
cn,
|
|
3100
2797
|
getInitials,
|
|
3101
|
-
showSonnerToast
|
|
3102
|
-
stateReducer,
|
|
3103
|
-
useAppState
|
|
2798
|
+
showSonnerToast
|
|
3104
2799
|
};
|
|
3105
2800
|
/*! Bundled license information:
|
|
3106
2801
|
|