fynixui 1.0.10
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/LICENSE +21 -0
- package/dist/context/context.d.ts +19 -0
- package/dist/context/context.d.ts.map +1 -0
- package/dist/context/context.js +4 -0
- package/dist/context/context.js.map +7 -0
- package/dist/custom/button.d.ts +2 -0
- package/dist/custom/button.d.ts.map +1 -0
- package/dist/custom/button.js +4 -0
- package/dist/custom/button.js.map +7 -0
- package/dist/custom/index.d.ts +3 -0
- package/dist/custom/index.d.ts.map +1 -0
- package/dist/custom/index.js +2 -0
- package/dist/custom/index.js.map +7 -0
- package/dist/custom/path.d.ts +14 -0
- package/dist/custom/path.d.ts.map +1 -0
- package/dist/custom/path.js +20 -0
- package/dist/custom/path.js.map +7 -0
- package/dist/error/errorOverlay.d.ts +3 -0
- package/dist/error/errorOverlay.d.ts.map +1 -0
- package/dist/error/errorOverlay.js +84 -0
- package/dist/error/errorOverlay.js.map +7 -0
- package/dist/fynix/index.d.ts +6 -0
- package/dist/fynix/index.d.ts.map +1 -0
- package/dist/fynix/index.js +5 -0
- package/dist/fynix/index.js.map +7 -0
- package/dist/hooks/nixAsync.d.ts +20 -0
- package/dist/hooks/nixAsync.d.ts.map +1 -0
- package/dist/hooks/nixAsync.js +114 -0
- package/dist/hooks/nixAsync.js.map +7 -0
- package/dist/hooks/nixAsyncCache.d.ts +19 -0
- package/dist/hooks/nixAsyncCache.d.ts.map +1 -0
- package/dist/hooks/nixAsyncCache.js +137 -0
- package/dist/hooks/nixAsyncCache.js.map +7 -0
- package/dist/hooks/nixAsyncDebounce.d.ts +22 -0
- package/dist/hooks/nixAsyncDebounce.d.ts.map +1 -0
- package/dist/hooks/nixAsyncDebounce.js +77 -0
- package/dist/hooks/nixAsyncDebounce.js.map +7 -0
- package/dist/hooks/nixAsyncQuery.d.ts +16 -0
- package/dist/hooks/nixAsyncQuery.d.ts.map +1 -0
- package/dist/hooks/nixAsyncQuery.js +87 -0
- package/dist/hooks/nixAsyncQuery.js.map +7 -0
- package/dist/hooks/nixCallback.d.ts +2 -0
- package/dist/hooks/nixCallback.d.ts.map +1 -0
- package/dist/hooks/nixCallback.js +34 -0
- package/dist/hooks/nixCallback.js.map +7 -0
- package/dist/hooks/nixComputed.d.ts +16 -0
- package/dist/hooks/nixComputed.d.ts.map +1 -0
- package/dist/hooks/nixComputed.js +175 -0
- package/dist/hooks/nixComputed.js.map +7 -0
- package/dist/hooks/nixDebounce.d.ts +11 -0
- package/dist/hooks/nixDebounce.d.ts.map +1 -0
- package/dist/hooks/nixDebounce.js +55 -0
- package/dist/hooks/nixDebounce.js.map +7 -0
- package/dist/hooks/nixEffect.d.ts +4 -0
- package/dist/hooks/nixEffect.d.ts.map +1 -0
- package/dist/hooks/nixEffect.js +75 -0
- package/dist/hooks/nixEffect.js.map +7 -0
- package/dist/hooks/nixFor.d.ts +13 -0
- package/dist/hooks/nixFor.d.ts.map +1 -0
- package/dist/hooks/nixFor.js +43 -0
- package/dist/hooks/nixFor.js.map +7 -0
- package/dist/hooks/nixForm.d.ts +33 -0
- package/dist/hooks/nixForm.d.ts.map +1 -0
- package/dist/hooks/nixForm.js +123 -0
- package/dist/hooks/nixForm.js.map +7 -0
- package/dist/hooks/nixFormAsync.d.ts +42 -0
- package/dist/hooks/nixFormAsync.d.ts.map +1 -0
- package/dist/hooks/nixFormAsync.js +169 -0
- package/dist/hooks/nixFormAsync.js.map +7 -0
- package/dist/hooks/nixInterval.d.ts +2 -0
- package/dist/hooks/nixInterval.d.ts.map +1 -0
- package/dist/hooks/nixInterval.js +23 -0
- package/dist/hooks/nixInterval.js.map +7 -0
- package/dist/hooks/nixLazy.d.ts +8 -0
- package/dist/hooks/nixLazy.d.ts.map +1 -0
- package/dist/hooks/nixLazy.js +58 -0
- package/dist/hooks/nixLazy.js.map +7 -0
- package/dist/hooks/nixLazyAsync.d.ts +10 -0
- package/dist/hooks/nixLazyAsync.d.ts.map +1 -0
- package/dist/hooks/nixLazyAsync.js +71 -0
- package/dist/hooks/nixLazyAsync.js.map +7 -0
- package/dist/hooks/nixLazyFormAsync.d.ts +50 -0
- package/dist/hooks/nixLazyFormAsync.d.ts.map +1 -0
- package/dist/hooks/nixLazyFormAsync.js +221 -0
- package/dist/hooks/nixLazyFormAsync.js.map +7 -0
- package/dist/hooks/nixLocalStorage.d.ts +8 -0
- package/dist/hooks/nixLocalStorage.d.ts.map +1 -0
- package/dist/hooks/nixLocalStorage.js +136 -0
- package/dist/hooks/nixLocalStorage.js.map +7 -0
- package/dist/hooks/nixMemo.d.ts +2 -0
- package/dist/hooks/nixMemo.d.ts.map +1 -0
- package/dist/hooks/nixMemo.js +30 -0
- package/dist/hooks/nixMemo.js.map +7 -0
- package/dist/hooks/nixPrevious.d.ts +2 -0
- package/dist/hooks/nixPrevious.d.ts.map +1 -0
- package/dist/hooks/nixPrevious.js +15 -0
- package/dist/hooks/nixPrevious.js.map +7 -0
- package/dist/hooks/nixRef.d.ts +4 -0
- package/dist/hooks/nixRef.d.ts.map +1 -0
- package/dist/hooks/nixRef.js +17 -0
- package/dist/hooks/nixRef.js.map +7 -0
- package/dist/hooks/nixState.d.ts +15 -0
- package/dist/hooks/nixState.d.ts.map +1 -0
- package/dist/hooks/nixState.js +127 -0
- package/dist/hooks/nixState.js.map +7 -0
- package/dist/hooks/nixStore.d.ts +10 -0
- package/dist/hooks/nixStore.d.ts.map +1 -0
- package/dist/hooks/nixStore.js +103 -0
- package/dist/hooks/nixStore.js.map +7 -0
- package/dist/package.json +221 -0
- package/dist/plugins/vite-plugin-res.d.ts +38 -0
- package/dist/plugins/vite-plugin-res.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-res.js +106 -0
- package/dist/plugins/vite-plugin-res.js.map +7 -0
- package/dist/router/router.d.ts +48 -0
- package/dist/router/router.d.ts.map +1 -0
- package/dist/router/router.js +872 -0
- package/dist/router/router.js.map +7 -0
- package/dist/runtime.d.ts +124 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1361 -0
- package/dist/runtime.js.map +7 -0
- package/package.json +254 -0
- package/types/fnx.d.ts +34 -0
- package/types/fynix-ui.d.ts +323 -0
- package/types/global.d.ts +279 -0
- package/types/index.d.ts +37 -0
- package/types/jsx.d.ts +993 -0
- package/types/vite-env.d.ts +545 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../hooks/nixForm.ts"],
|
|
4
|
+
"sourcesContent": ["/* MIT License\r\n\r\n* Copyright (c) 2026 Resty Gonzales\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n* SOFTWARE.\r\n */\r\n// core/hooks/nixForm.js - Form handling utilities with memory-safe async support\r\nimport { nixComputed } from \"./nixComputed.js\";\r\nimport { nixState } from \"./nixState.js\";\r\n\r\ntype ValidationRule<T> = {\r\n required?: boolean;\r\n minLength?: number;\r\n maxLength?: number;\r\n pattern?: RegExp;\r\n custom?: (value: any, values: T) => boolean;\r\n message?: string;\r\n};\r\n\r\ntype ValidationRules<T> = {\r\n [K in keyof T]?: ValidationRule<T>;\r\n};\r\n\r\ntype FormState<T> = {\r\n values: ReturnType<typeof nixState<T>>;\r\n errors: ReturnType<typeof nixState<Partial<Record<keyof T, string>>>>;\r\n touched: ReturnType<typeof nixState<Partial<Record<keyof T, boolean>>>>;\r\n isSubmitting: ReturnType<typeof nixState<boolean>>;\r\n isValid: ReturnType<typeof nixComputed<boolean>>;\r\n handleChange: (fieldName: keyof T, value: any) => void;\r\n handleBlur: (fieldName: keyof T) => void;\r\n handleSubmit: (\r\n onSubmit: (values: T, signal: AbortSignal) => Promise<void>\r\n ) => Promise<void>;\r\n cancelSubmit: () => void;\r\n reset: () => void;\r\n getFieldProps: (fieldName: keyof T) => {\r\n value: any;\r\n \"r-input\": (e: any) => void;\r\n \"r-blur\": () => void;\r\n };\r\n};\r\n\r\n/**\r\n * Reactive form handler with validation, reactive state, and safe async submit.\r\n *\r\n * @param {Object} [initialValues={}] - Initial values for form fields.\r\n * @param {Object} [validationRules={}] - Validation rules for fields.\r\n * @returns {Object} Form utilities: values, errors, touched, isSubmitting, isValid,\r\n * handleChange, handleBlur, handleSubmit, reset, getFieldProps, cancelSubmit\r\n *\r\n * @example\r\n * const form = nixForm({ email: \"\" }, {\r\n * email: { required: true, pattern: /^\\S+@\\S+$/, message: \"Invalid email\" }\r\n * });\r\n * form.handleSubmit(async (values) => { await api.submit(values); });\r\n */\r\nexport function nixForm<T extends Record<string, any> = Record<string, any>>(\r\n initialValues: T = {} as T,\r\n validationRules: ValidationRules<T> = {} as ValidationRules<T>\r\n): FormState<T> {\r\n const values = nixState<T>({ ...initialValues });\r\n const errors = nixState<Partial<Record<keyof T, string>>>({});\r\n const touched = nixState<Partial<Record<keyof T, boolean>>>({});\r\n const isSubmitting = nixState<boolean>(false);\r\n\r\n const isValid = nixComputed<boolean>(\r\n () => Object.keys(errors.value).length === 0\r\n );\r\n\r\n let abortController: AbortController | null = null;\r\n\r\n function validate(fieldName: keyof T, value: any): string | null {\r\n const rules = validationRules[fieldName];\r\n if (!rules) return null;\r\n\r\n if (rules.required && !value) {\r\n return rules.message || `${String(fieldName)} is required`;\r\n }\r\n if (rules.minLength && value.length < rules.minLength) {\r\n return (\r\n rules.message ||\r\n `${String(fieldName)} must be at least ${rules.minLength} characters`\r\n );\r\n }\r\n if (rules.maxLength && value.length > rules.maxLength) {\r\n return (\r\n rules.message ||\r\n `${String(fieldName)} must be at most ${rules.maxLength} characters`\r\n );\r\n }\r\n if (rules.pattern && !rules.pattern.test(value)) {\r\n return rules.message || `${String(fieldName)} is invalid`;\r\n }\r\n if (rules.custom && !rules.custom(value, values.value)) {\r\n return rules.message || `${String(fieldName)} is invalid`;\r\n }\r\n return null;\r\n }\r\n\r\n function handleChange(fieldName: keyof T, value: any): void {\r\n values.value = { ...values.value, [fieldName]: value };\r\n\r\n if (touched.value[fieldName]) {\r\n const error = validate(fieldName, value);\r\n if (error) {\r\n errors.value = { ...errors.value, [fieldName]: error };\r\n } else {\r\n const newErrors = { ...errors.value };\r\n delete newErrors[fieldName];\r\n errors.value = newErrors;\r\n }\r\n }\r\n }\r\n\r\n function handleBlur(fieldName: keyof T): void {\r\n touched.value = { ...touched.value, [fieldName]: true };\r\n const error = validate(fieldName, values.value[fieldName]);\r\n if (error) {\r\n errors.value = { ...errors.value, [fieldName]: error };\r\n }\r\n }\r\n\r\n function validateAll(): boolean {\r\n const newErrors: Partial<Record<keyof T, string>> = {};\r\n (Object.keys(validationRules) as Array<keyof T>).forEach((fieldName) => {\r\n const error = validate(fieldName, values.value[fieldName]);\r\n if (error) newErrors[fieldName] = error;\r\n });\r\n errors.value = newErrors;\r\n return Object.keys(newErrors).length === 0;\r\n }\r\n\r\n async function handleSubmit(\r\n onSubmit: (values: T, signal: AbortSignal) => Promise<void>\r\n ): Promise<void> {\r\n const allTouched = (Object.keys(validationRules) as Array<keyof T>).reduce(\r\n (acc, key) => {\r\n acc[key] = true;\r\n return acc;\r\n },\r\n {} as Partial<Record<keyof T, boolean>>\r\n );\r\n touched.value = allTouched;\r\n\r\n if (!validateAll()) return;\r\n\r\n if (abortController) abortController.abort();\r\n abortController = new AbortController();\r\n const signal = abortController.signal;\r\n\r\n isSubmitting.value = true;\r\n try {\r\n await onSubmit(values.value, signal);\r\n } catch (err: any) {\r\n if (err.name !== \"AbortError\") {\r\n console.error(\"[nixForm] Submission error:\", err);\r\n }\r\n } finally {\r\n if (!signal.aborted) isSubmitting.value = false;\r\n }\r\n }\r\n\r\n function cancelSubmit(): void {\r\n if (abortController) {\r\n abortController.abort();\r\n abortController = null;\r\n }\r\n }\r\n\r\n function reset(): void {\r\n values.value = { ...initialValues };\r\n errors.value = {};\r\n touched.value = {};\r\n isSubmitting.value = false;\r\n cancelSubmit();\r\n }\r\n\r\n function getFieldProps(fieldName: keyof T) {\r\n return {\r\n value: values.value[fieldName] || \"\",\r\n \"r-input\": (e: any) => handleChange(fieldName, e.target.value),\r\n \"r-blur\": () => handleBlur(fieldName),\r\n };\r\n }\r\n\r\n return {\r\n values,\r\n errors,\r\n touched,\r\n isSubmitting,\r\n isValid,\r\n handleChange,\r\n handleBlur,\r\n handleSubmit,\r\n cancelSubmit,\r\n reset,\r\n getFieldProps,\r\n };\r\n}\r\n"],
|
|
5
|
+
"mappings": ";;AAuBA,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AAiDlB,SAAS,QACd,gBAAmB,CAAC,GACpB,kBAAsC,CAAC,GACzB;AACd,QAAM,SAAS,SAAY,EAAE,GAAG,cAAc,CAAC;AAC/C,QAAM,SAAS,SAA2C,CAAC,CAAC;AAC5D,QAAM,UAAU,SAA4C,CAAC,CAAC;AAC9D,QAAM,eAAe,SAAkB,KAAK;AAE5C,QAAM,UAAU;AAAA,IACd,MAAM,OAAO,KAAK,OAAO,KAAK,EAAE,WAAW;AAAA,EAC7C;AAEA,MAAI,kBAA0C;AAE9C,WAAS,SAAS,WAAoB,OAA2B;AAC/D,U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;AAAA,EACf;AANS;AAQT,WAAS,cAAc,WAAoB;AACzC,WAAO;AAAA,MACL,OAAO,OAAO,MAAM,SAAS,KAAK;AAAA,MAClC,WAAW,wBAAC,MAAW,aAAa,WAAW,EAAE,OAAO,KAAK,GAAlD;AAAA,MACX,UAAU,6BAAM,WAAW,SAAS,GAA1B;AAAA,IACZ;AAAA,EACF;AANS;AAQT,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AA9IgB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { nixComputed } from "./nixComputed.js";
|
|
2
|
+
import { nixState } from "./nixState.js";
|
|
3
|
+
type ValidationRule<T> = {
|
|
4
|
+
required?: boolean;
|
|
5
|
+
minLength?: number;
|
|
6
|
+
maxLength?: number;
|
|
7
|
+
pattern?: RegExp;
|
|
8
|
+
custom?: (value: any, values: T) => boolean;
|
|
9
|
+
message?: string;
|
|
10
|
+
};
|
|
11
|
+
type ValidationRules<T> = {
|
|
12
|
+
[K in keyof T]?: ValidationRule<T>;
|
|
13
|
+
};
|
|
14
|
+
type FormAsyncState<T, D = any, E = any> = {
|
|
15
|
+
values: ReturnType<typeof nixState<T>>;
|
|
16
|
+
errors: ReturnType<typeof nixState<Partial<Record<keyof T, string>>>>;
|
|
17
|
+
touched: ReturnType<typeof nixState<Partial<Record<keyof T, boolean>>>>;
|
|
18
|
+
isSubmitting: ReturnType<typeof nixState<boolean>>;
|
|
19
|
+
isValid: ReturnType<typeof nixComputed<boolean>>;
|
|
20
|
+
data: ReturnType<typeof nixState<D | null>>;
|
|
21
|
+
error: ReturnType<typeof nixState<E | null>>;
|
|
22
|
+
loading: ReturnType<typeof nixState<boolean>>;
|
|
23
|
+
handleChange: (fieldName: keyof T, value: any) => void;
|
|
24
|
+
handleBlur: (fieldName: keyof T) => void;
|
|
25
|
+
handleSubmit: (onSubmit: (values: T, signal: AbortSignal) => Promise<D>) => void;
|
|
26
|
+
cancelSubmit: () => void;
|
|
27
|
+
reset: () => void;
|
|
28
|
+
getFieldProps: (fieldName: keyof T) => {
|
|
29
|
+
value: any;
|
|
30
|
+
"r-input": (e: any) => void;
|
|
31
|
+
"r-blur": () => void;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export declare function nixFormAsync<T extends Record<string, any> = Record<string, any>, D = any, E = any>(initialValues?: T, validationRules?: ValidationRules<T>, options?: {
|
|
35
|
+
delay?: number;
|
|
36
|
+
leading?: boolean;
|
|
37
|
+
trailing?: boolean;
|
|
38
|
+
maxWait?: number;
|
|
39
|
+
cache?: boolean;
|
|
40
|
+
}): FormAsyncState<T, D, E>;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=nixFormAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nixFormAsync.d.ts","sourceRoot":"","sources":["../../hooks/nixFormAsync.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,KAAK,cAAc,CAAC,CAAC,IAAI;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,eAAe,CAAC,CAAC,IAAI;KACvB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC;CACnC,CAAC;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,EAAE,GAAG,CAAC;QACX,SAAS,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;QAC5B,QAAQ,EAAE,MAAM,IAAI,CAAC;KACtB,CAAC;CACH,CAAC;AAeF,wBAAgB,YAAY,CAC1B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACnD,CAAC,GAAG,GAAG,EACP,CAAC,GAAG,GAAG,EAEP,aAAa,GAAE,CAAW,EAC1B,eAAe,GAAE,eAAe,CAAC,CAAC,CAA4B,EAC9D,OAAO,GAAE;IACP,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACZ,GACL,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CA6LzB"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { nixComputed } from "./nixComputed.js";
|
|
2
|
+
import { nixState } from "./nixState.js";
|
|
3
|
+
export function nixFormAsync(initialValues = {}, validationRules = {}, options = {}) {
|
|
4
|
+
const values = nixState({ ...initialValues });
|
|
5
|
+
const errors = nixState({});
|
|
6
|
+
const touched = nixState({});
|
|
7
|
+
const isSubmitting = nixState(false);
|
|
8
|
+
const isValid = nixComputed(() => Object.keys(errors.value).length === 0);
|
|
9
|
+
const { delay = 300, leading = false, trailing = true, maxWait, cache = true, } = options;
|
|
10
|
+
const data = nixState(null);
|
|
11
|
+
const error = nixState(null);
|
|
12
|
+
const loading = nixState(false);
|
|
13
|
+
let abortController = null;
|
|
14
|
+
let timerId = null;
|
|
15
|
+
let lastInvokeTime = 0;
|
|
16
|
+
let lastResult = null;
|
|
17
|
+
let lastError = null;
|
|
18
|
+
let pendingPromise = null;
|
|
19
|
+
function validate(fieldName, value) {
|
|
20
|
+
const rules = validationRules[fieldName];
|
|
21
|
+
if (!rules)
|
|
22
|
+
return null;
|
|
23
|
+
if (rules.required && !value)
|
|
24
|
+
return rules.message || `${String(fieldName)} is required`;
|
|
25
|
+
if (rules.minLength && value.length < rules.minLength)
|
|
26
|
+
return (rules.message ||
|
|
27
|
+
`${String(fieldName)} must be at least ${rules.minLength} characters`);
|
|
28
|
+
if (rules.maxLength && value.length > rules.maxLength)
|
|
29
|
+
return (rules.message ||
|
|
30
|
+
`${String(fieldName)} must be at most ${rules.maxLength} characters`);
|
|
31
|
+
if (rules.pattern && !rules.pattern.test(value))
|
|
32
|
+
return rules.message || `${String(fieldName)} is invalid`;
|
|
33
|
+
if (rules.custom && !rules.custom(value, values.value))
|
|
34
|
+
return rules.message || `${String(fieldName)} is invalid`;
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
function handleChange(fieldName, value) {
|
|
38
|
+
values.value = { ...values.value, [fieldName]: value };
|
|
39
|
+
if (touched.value[fieldName]) {
|
|
40
|
+
const err = validate(fieldName, value);
|
|
41
|
+
if (err)
|
|
42
|
+
errors.value = { ...errors.value, [fieldName]: err };
|
|
43
|
+
else {
|
|
44
|
+
const newErrors = { ...errors.value };
|
|
45
|
+
delete newErrors[fieldName];
|
|
46
|
+
errors.value = newErrors;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function handleBlur(fieldName) {
|
|
51
|
+
touched.value = { ...touched.value, [fieldName]: true };
|
|
52
|
+
const err = validate(fieldName, values.value[fieldName]);
|
|
53
|
+
if (err)
|
|
54
|
+
errors.value = { ...errors.value, [fieldName]: err };
|
|
55
|
+
}
|
|
56
|
+
function validateAll() {
|
|
57
|
+
const newErrors = {};
|
|
58
|
+
Object.keys(validationRules).forEach((fieldName) => {
|
|
59
|
+
const err = validate(fieldName, values.value[fieldName]);
|
|
60
|
+
if (err)
|
|
61
|
+
newErrors[fieldName] = err;
|
|
62
|
+
});
|
|
63
|
+
errors.value = newErrors;
|
|
64
|
+
return Object.keys(newErrors).length === 0;
|
|
65
|
+
}
|
|
66
|
+
async function invokeAsync(onSubmit) {
|
|
67
|
+
if (cache && lastResult !== null) {
|
|
68
|
+
data.value = lastResult;
|
|
69
|
+
error.value = lastError;
|
|
70
|
+
loading.value = false;
|
|
71
|
+
return lastResult;
|
|
72
|
+
}
|
|
73
|
+
if (abortController)
|
|
74
|
+
abortController.abort();
|
|
75
|
+
abortController = new AbortController();
|
|
76
|
+
const signal = abortController.signal;
|
|
77
|
+
loading.value = true;
|
|
78
|
+
error.value = null;
|
|
79
|
+
pendingPromise = onSubmit(values.value, signal);
|
|
80
|
+
try {
|
|
81
|
+
const result = await pendingPromise;
|
|
82
|
+
lastResult = result;
|
|
83
|
+
data.value = result;
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
if (err.name !== "AbortError") {
|
|
88
|
+
lastError = err;
|
|
89
|
+
error.value = err;
|
|
90
|
+
console.error("[nixFormAsync] submit error:", err);
|
|
91
|
+
}
|
|
92
|
+
throw err;
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
loading.value = false;
|
|
96
|
+
pendingPromise = null;
|
|
97
|
+
lastInvokeTime = Date.now();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function handleSubmit(onSubmit) {
|
|
101
|
+
if (!validateAll())
|
|
102
|
+
return;
|
|
103
|
+
const now = Date.now();
|
|
104
|
+
const timeSinceLastInvoke = now - lastInvokeTime;
|
|
105
|
+
const remainingTime = delay - timeSinceLastInvoke;
|
|
106
|
+
const shouldInvokeLeading = leading && !timerId;
|
|
107
|
+
if (maxWait !== undefined && timeSinceLastInvoke >= maxWait) {
|
|
108
|
+
if (timerId)
|
|
109
|
+
clearTimeout(timerId);
|
|
110
|
+
timerId = null;
|
|
111
|
+
void invokeAsync(onSubmit);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (timerId)
|
|
115
|
+
clearTimeout(timerId);
|
|
116
|
+
if (shouldInvokeLeading) {
|
|
117
|
+
void invokeAsync(onSubmit);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (trailing) {
|
|
121
|
+
timerId = setTimeout(() => {
|
|
122
|
+
timerId = null;
|
|
123
|
+
void invokeAsync(onSubmit);
|
|
124
|
+
}, remainingTime > 0 ? remainingTime : delay);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function cancelSubmit() {
|
|
128
|
+
if (abortController) {
|
|
129
|
+
abortController.abort();
|
|
130
|
+
abortController = null;
|
|
131
|
+
}
|
|
132
|
+
if (timerId)
|
|
133
|
+
clearTimeout(timerId);
|
|
134
|
+
timerId = null;
|
|
135
|
+
}
|
|
136
|
+
function reset() {
|
|
137
|
+
values.value = { ...initialValues };
|
|
138
|
+
errors.value = {};
|
|
139
|
+
touched.value = {};
|
|
140
|
+
isSubmitting.value = false;
|
|
141
|
+
cancelSubmit();
|
|
142
|
+
data.value = null;
|
|
143
|
+
error.value = null;
|
|
144
|
+
loading.value = false;
|
|
145
|
+
}
|
|
146
|
+
function getFieldProps(fieldName) {
|
|
147
|
+
return {
|
|
148
|
+
value: values.value[fieldName] || "",
|
|
149
|
+
"r-input": (e) => handleChange(fieldName, e.target.value),
|
|
150
|
+
"r-blur": () => handleBlur(fieldName),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
values,
|
|
155
|
+
errors,
|
|
156
|
+
touched,
|
|
157
|
+
isSubmitting,
|
|
158
|
+
isValid,
|
|
159
|
+
data,
|
|
160
|
+
error,
|
|
161
|
+
loading,
|
|
162
|
+
handleChange,
|
|
163
|
+
handleBlur,
|
|
164
|
+
handleSubmit,
|
|
165
|
+
cancelSubmit,
|
|
166
|
+
reset,
|
|
167
|
+
getFieldProps,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../hooks/nixFormAsync.ts"],
|
|
4
|
+
"sourcesContent": ["/* MIT License\r\n\r\n* Copyright (c) 2026 Resty Gonzales\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n* SOFTWARE.\r\n */\r\n// core/hooks/nixFormAsync.js\r\n\r\nimport { nixComputed } from \"./nixComputed.js\";\r\nimport { nixState } from \"./nixState.js\";\r\n\r\ntype ValidationRule<T> = {\r\n required?: boolean;\r\n minLength?: number;\r\n maxLength?: number;\r\n pattern?: RegExp;\r\n custom?: (value: any, values: T) => boolean;\r\n message?: string;\r\n};\r\n\r\ntype ValidationRules<T> = {\r\n [K in keyof T]?: ValidationRule<T>;\r\n};\r\n\r\ntype FormAsyncState<T, D = any, E = any> = {\r\n values: ReturnType<typeof nixState<T>>;\r\n errors: ReturnType<typeof nixState<Partial<Record<keyof T, string>>>>;\r\n touched: ReturnType<typeof nixState<Partial<Record<keyof T, boolean>>>>;\r\n isSubmitting: ReturnType<typeof nixState<boolean>>;\r\n isValid: ReturnType<typeof nixComputed<boolean>>;\r\n data: ReturnType<typeof nixState<D | null>>;\r\n error: ReturnType<typeof nixState<E | null>>;\r\n loading: ReturnType<typeof nixState<boolean>>;\r\n handleChange: (fieldName: keyof T, value: any) => void;\r\n handleBlur: (fieldName: keyof T) => void;\r\n handleSubmit: (\r\n onSubmit: (values: T, signal: AbortSignal) => Promise<D>\r\n ) => void;\r\n cancelSubmit: () => void;\r\n reset: () => void;\r\n getFieldProps: (fieldName: keyof T) => {\r\n value: any;\r\n \"r-input\": (e: any) => void;\r\n \"r-blur\": () => void;\r\n };\r\n};\r\n\r\n/**\r\n * Full-featured reactive form with debounced async API submission.\r\n *\r\n * @param {Object} [initialValues={}] - Initial field values.\r\n * @param {Object} [validationRules={}] - Validation rules for each field.\r\n * @param {Object} [options={}] - Async submit options.\r\n * @param {number} [options.delay=300] - Debounce delay in ms.\r\n * @param {boolean} [options.leading=false] - Invoke submit on leading edge.\r\n * @param {boolean} [options.trailing=true] - Invoke submit on trailing edge.\r\n * @param {number} [options.maxWait] - Maximum wait time before forced invocation.\r\n * @param {boolean} [options.cache=true] - Cache last submission result.\r\n * @returns {Object} Form API with state, validation, and debounced async submission.\r\n */\r\nexport function nixFormAsync<\r\n T extends Record<string, any> = Record<string, any>,\r\n D = any,\r\n E = any,\r\n>(\r\n initialValues: T = {} as T,\r\n validationRules: ValidationRules<T> = {} as ValidationRules<T>,\r\n options: {\r\n delay?: number;\r\n leading?: boolean;\r\n trailing?: boolean;\r\n maxWait?: number;\r\n cache?: boolean;\r\n } = {}\r\n): FormAsyncState<T, D, E> {\r\n const values = nixState<T>({ ...initialValues });\r\n const errors = nixState<Partial<Record<keyof T, string>>>({});\r\n const touched = nixState<Partial<Record<keyof T, boolean>>>({});\r\n const isSubmitting = nixState<boolean>(false);\r\n const isValid = nixComputed<boolean>(\r\n () => Object.keys(errors.value).length === 0\r\n );\r\n\r\n const {\r\n delay = 300,\r\n leading = false,\r\n trailing = true,\r\n maxWait,\r\n cache = true,\r\n } = options;\r\n const data = nixState<D | null>(null);\r\n const error = nixState<E | null>(null);\r\n const loading = nixState<boolean>(false);\r\n\r\n let abortController: AbortController | null = null;\r\n let timerId: ReturnType<typeof setTimeout> | null = null;\r\n let lastInvokeTime = 0;\r\n let lastResult: D | null = null;\r\n let lastError: E | null = null;\r\n let pendingPromise: Promise<D> | null = null;\r\n\r\n function validate(fieldName: keyof T, value: any): string | null {\r\n const rules = validationRules[fieldName];\r\n if (!rules) return null;\r\n\r\n if (rules.required && !value)\r\n return rules.message || `${String(fieldName)} is required`;\r\n if (rules.minLength && value.length < rules.minLength)\r\n return (\r\n rules.message ||\r\n `${String(fieldName)} must be at least ${rules.minLength} characters`\r\n );\r\n if (rules.maxLength && value.length > rules.maxLength)\r\n return (\r\n rules.message ||\r\n `${String(fieldName)} must be at most ${rules.maxLength} characters`\r\n );\r\n if (rules.pattern && !rules.pattern.test(value))\r\n return rules.message || `${String(fieldName)} is invalid`;\r\n if (rules.custom && !rules.custom(value, values.value))\r\n return rules.message || `${String(fieldName)} is invalid`;\r\n\r\n return null;\r\n }\r\n\r\n function handleChange(fieldName: keyof T, value: any): void {\r\n values.value = { ...values.value, [fieldName]: value };\r\n\r\n if (touched.value[fieldName]) {\r\n const err = validate(fieldName, value);\r\n if (err) errors.value = { ...errors.value, [fieldName]: err };\r\n else {\r\n const newErrors = { ...errors.value };\r\n delete newErrors[fieldName];\r\n errors.value = newErrors;\r\n }\r\n }\r\n }\r\n\r\n function handleBlur(fieldName: keyof T): void {\r\n touched.value = { ...touched.value, [fieldName]: true };\r\n const err = validate(fieldName, values.value[fieldName]);\r\n if (err) errors.value = { ...errors.value, [fieldName]: err };\r\n }\r\n\r\n function validateAll(): boolean {\r\n const newErrors: Partial<Record<keyof T, string>> = {};\r\n (Object.keys(validationRules) as Array<keyof T>).forEach((fieldName) => {\r\n const err = validate(fieldName, values.value[fieldName]);\r\n if (err) newErrors[fieldName] = err;\r\n });\r\n errors.value = newErrors;\r\n return Object.keys(newErrors).length === 0;\r\n }\r\n\r\n async function invokeAsync(\r\n onSubmit: (values: T, signal: AbortSignal) => Promise<D>\r\n ): Promise<D | undefined> {\r\n if (cache && lastResult !== null) {\r\n data.value = lastResult;\r\n error.value = lastError;\r\n loading.value = false;\r\n return lastResult;\r\n }\r\n if (abortController) abortController.abort();\r\n abortController = new AbortController();\r\n const signal = abortController.signal;\r\n loading.value = true;\r\n error.value = null;\r\n pendingPromise = onSubmit(values.value, signal);\r\n try {\r\n const result = await pendingPromise;\r\n lastResult = result;\r\n data.value = result;\r\n return result;\r\n } catch (err: any) {\r\n if (err.name !== \"AbortError\") {\r\n lastError = err;\r\n error.value = err;\r\n console.error(\"[nixFormAsync] submit error:\", err);\r\n }\r\n throw err;\r\n } finally {\r\n loading.value = false;\r\n pendingPromise = null;\r\n lastInvokeTime = Date.now();\r\n }\r\n }\r\n\r\n function handleSubmit(\r\n onSubmit: (values: T, signal: AbortSignal) => Promise<D>\r\n ): void {\r\n if (!validateAll()) return;\r\n const now = Date.now();\r\n const timeSinceLastInvoke = now - lastInvokeTime;\r\n const remainingTime = delay - timeSinceLastInvoke;\r\n const shouldInvokeLeading = leading && !timerId;\r\n if (maxWait !== undefined && timeSinceLastInvoke >= maxWait) {\r\n if (timerId) clearTimeout(timerId);\r\n timerId = null;\r\n void invokeAsync(onSubmit);\r\n return;\r\n }\r\n if (timerId) clearTimeout(timerId);\r\n if (shouldInvokeLeading) {\r\n void invokeAsync(onSubmit);\r\n return;\r\n }\r\n if (trailing) {\r\n timerId = setTimeout(\r\n () => {\r\n timerId = null;\r\n void invokeAsync(onSubmit);\r\n },\r\n remainingTime > 0 ? remainingTime : delay\r\n );\r\n }\r\n }\r\n\r\n function cancelSubmit(): void {\r\n if (abortController) {\r\n abortController.abort();\r\n abortController = null;\r\n }\r\n if (timerId) clearTimeout(timerId);\r\n timerId = null;\r\n }\r\n\r\n function reset(): void {\r\n values.value = { ...initialValues };\r\n errors.value = {};\r\n touched.value = {};\r\n isSubmitting.value = false;\r\n cancelSubmit();\r\n data.value = null;\r\n error.value = null;\r\n loading.value = false;\r\n }\r\n\r\n function getFieldProps(fieldName: keyof T) {\r\n return {\r\n value: values.value[fieldName] || \"\",\r\n \"r-input\": (e: any) => handleChange(fieldName, e.target.value),\r\n \"r-blur\": () => handleBlur(fieldName),\r\n };\r\n }\r\n\r\n return {\r\n values,\r\n errors,\r\n touched,\r\n isSubmitting,\r\n isValid,\r\n data,\r\n error,\r\n loading,\r\n handleChange,\r\n handleBlur,\r\n handleSubmit,\r\n cancelSubmit,\r\n reset,\r\n getFieldProps,\r\n };\r\n}\r\n"],
|
|
5
|
+
"mappings": ";;AAwBA,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AAmDlB,SAAS,aAKd,gBAAmB,CAAC,GACpB,kBAAsC,CAAC,GACvC,UAMI,CAAC,GACoB;AACzB,QAAM,SAAS,SAAY,EAAE,GAAG,cAAc,CAAC;AAC/C,QAAM,SAAS,SAA2C,CAAC,CAAC;AAC5D,QAAM,UAAU,SAA4C,CAAC,CAAC;AAC9D,QAAM,eAAe,SAAkB,KAAK;AAC5C,QAAM,UAAU;AAAA,IACd,MAAM,OAAO,KAAK,OAAO,KAAK,EAAE,WAAW;AAAA,EAC7C;AAEA,QAAM;AAAA,IACJ,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,WAAW;AAAA,IACX;AAAA,IACA,QAAQ;AAAA,EACV,IAAI;AACJ,QAAM,OAAO,SAAmB,IAAI;AACpC,QAAM,QAAQ,SAAmB,IAAI;AACrC,QAAM,UAAU,SAAkB,KAAK;AAEvC,MAAI,kBAA0C;AAC9C,MAAI,UAAgD;AACpD,MAAI,iBAAiB;AACrB,MAAI,aAAuB;AAC3B,MAAI,YAAsB;AAC1B,MAAI,iBAAoC;AAExC,WAAS,SAAS,WAAoB,OAA2B;AAC/D,UAAM,QAAQ,gBAAgB,SAAS;AACvC,QAAI,CAAC,MAAO,QAAO;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YAAY,QAAQ;AACzB;AAAA,IACF;AACA,QAAI,UAAU;AACZ,gBAAU;AAAA,QACR,MAAM;AACJ,oBAAU;AACV,eAAK,YAAY,QAAQ;AAAA,QAC3B;AAAA,QACA,gBAAgB,IAAI,gBAAgB;AAAA,MACtC;AAAA,IACF;AAAA,EACF;AA5BS;AA8BT,WAAS,eAAqB;AAC5B,QAAI,iBAAiB;AACnB,sBAAgB,MAAM;AACtB,wBAAkB;AAAA,IACpB;AACA,QAAI,QAAS,cAAa,OAAO;AACjC,cAAU;AAAA,EACZ;AAPS;AAST,WAAS,QAAc;AACrB,WAAO,QAAQ,EAAE,GAAG,cAAc;AAClC,WAAO,QAAQ,CAAC;AAChB,YAAQ,QAAQ,CAAC;AACjB,iBAAa,QAAQ;AACrB,iBAAa;AACb,SAAK,QAAQ;AACb,UAAM,QAAQ;AACd,YAAQ,QAAQ;AAAA,EAClB;AATS;AAWT,WAAS,cAAc,WAAoB;AACzC,WAAO;AAAA,MACL,OAAO,OAAO,MAAM,SAAS,KAAK;AAAA,MAClC,WAAW,wBAAC,MAAW,aAAa,WAAW,EAAE,OAAO,KAAK,GAAlD;AAAA,MACX,UAAU,6BAAM,WAAW,SAAS,GAA1B;AAAA,IACZ;AAAA,EACF;AANS;AAQT,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AA3MgB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nixInterval.d.ts","sourceRoot":"","sources":["../../hooks/nixInterval.ts"],"names":[],"mappings":"AAgDA,wBAAgB,WAAW,CACzB,EAAE,EAAE,MAAM,IAAI,EACd,EAAE,EAAE,MAAM,EACV,MAAM,CAAC,EAAE,WAAW,GACnB,MAAM,IAAI,CA2BZ"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function nixInterval(fn, ms, signal) {
|
|
2
|
+
if (typeof fn !== "function") {
|
|
3
|
+
throw new TypeError("nixInterval: first argument must be a function");
|
|
4
|
+
}
|
|
5
|
+
if (typeof ms !== "number" || ms < 0) {
|
|
6
|
+
throw new TypeError("nixInterval: second argument must be a non-negative number");
|
|
7
|
+
}
|
|
8
|
+
const id = setInterval(fn, ms);
|
|
9
|
+
const cancel = () => clearInterval(id);
|
|
10
|
+
if (signal) {
|
|
11
|
+
if (signal.aborted) {
|
|
12
|
+
cancel();
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
const listener = () => {
|
|
16
|
+
cancel();
|
|
17
|
+
signal.removeEventListener("abort", listener);
|
|
18
|
+
};
|
|
19
|
+
signal.addEventListener("abort", listener);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return cancel;
|
|
23
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../hooks/nixInterval.ts"],
|
|
4
|
+
"sourcesContent": ["/* MIT License\r\n\r\n* Copyright (c) 2026 Resty Gonzales\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n* SOFTWARE.\r\n */\r\n/**\r\n * @fileoverview Safe interval utility with automatic cleanup support.\r\n * Provides AbortController integration for cancellable intervals.\r\n */\r\n\r\n/**\r\n * Safe interval with automatic cleanup support and optional AbortController.\r\n * Must be called within a component and cleaned up on unmount.\r\n *\r\n * @param {() => void} fn - Function to run at each interval\r\n * @param {number} ms - Interval duration in milliseconds\r\n * @param {AbortSignal} [signal] - Optional AbortSignal to cancel the interval\r\n * @returns {() => void} Cleanup function to stop the interval\r\n *\r\n * @example\r\n * const cancel = nixInterval(() => console.log('tick'), 1000);\r\n * // stop interval\r\n * cancel();\r\n *\r\n * @example\r\n * const controller = new AbortController();\r\n * nixInterval(() => console.log('tick'), 1000, controller.signal);\r\n * controller.abort(); // automatically clears interval\r\n *\r\n * @throws {TypeError} If fn is not a function or ms is not a non-negative number\r\n */\r\nexport function nixInterval(\r\n fn: () => void,\r\n ms: number,\r\n signal?: AbortSignal\r\n): () => void {\r\n if (typeof fn !== \"function\") {\r\n throw new TypeError(\"nixInterval: first argument must be a function\");\r\n }\r\n if (typeof ms !== \"number\" || ms < 0) {\r\n throw new TypeError(\r\n \"nixInterval: second argument must be a non-negative number\"\r\n );\r\n }\r\n\r\n const id = setInterval(fn, ms);\r\n\r\n const cancel = () => clearInterval(id);\r\n\r\n if (signal) {\r\n if (signal.aborted) {\r\n cancel();\r\n } else {\r\n const listener = () => {\r\n cancel();\r\n signal.removeEventListener(\"abort\", listener);\r\n };\r\n signal.addEventListener(\"abort\", listener);\r\n }\r\n }\r\n\r\n return cancel;\r\n}\r\n"],
|
|
5
|
+
"mappings": ";;AAgDO,SAAS,YACd,IACA,IACA,QACY;AACZ,MAAI,OAAO,OAAO,YAAY;AAC5B,UAAM,IAAI,UAAU,gDAAgD;AAAA,EACtE;AACA,MAAI,OAAO,OAAO,YAAY,KAAK,GAAG;AACpC,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,KAAK,YAAY,IAAI,EAAE;AAE7B,QAAM,SAAS,6BAAM,cAAc,EAAE,GAAtB;AAEf,MAAI,QAAQ;AACV,QAAI,OAAO,SAAS;AAClB,aAAO;AAAA,IACT,OAAO;AACL,YAAM,WAAW,6BAAM;AACrB,eAAO;AACP,eAAO,oBAAoB,SAAS,QAAQ;AAAA,MAC9C,GAHiB;AAIjB,aAAO,iBAAiB,SAAS,QAAQ;AAAA,IAC3C;AAAA,EACF;AAEA,SAAO;AACT;AA/BgB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function nixLazy<TProps = any>(importFn: () => Promise<{
|
|
2
|
+
default?: (props: TProps) => any;
|
|
3
|
+
} | ((props: TProps) => any)>): (props: TProps) => any;
|
|
4
|
+
export declare function Suspense<T = any>({ fallback, children, }: {
|
|
5
|
+
fallback: any;
|
|
6
|
+
children: () => T;
|
|
7
|
+
}): T | any;
|
|
8
|
+
//# sourceMappingURL=nixLazy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nixLazy.d.ts","sourceRoot":"","sources":["../../hooks/nixLazy.ts"],"names":[],"mappings":"AAgCA,wBAAgB,OAAO,CAAC,MAAM,GAAG,GAAG,EAClC,QAAQ,EAAE,MAAM,OAAO,CACrB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,GAAG,CAAA;CAAE,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,GAAG,CAAC,CAChE,GACA,CAAC,KAAK,EAAE,MAAM,KAAK,GAAG,CA4CxB;AAUD,wBAAgB,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,EAChC,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,GAAG,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC,CAAC;CACnB,GAAG,CAAC,GAAG,GAAG,CAqBV"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { activeContext } from "../context/context.js";
|
|
2
|
+
import { nixState } from "./nixState.js";
|
|
3
|
+
export function nixLazy(importFn) {
|
|
4
|
+
const cache = {
|
|
5
|
+
status: "pending",
|
|
6
|
+
component: null,
|
|
7
|
+
error: null,
|
|
8
|
+
promise: null,
|
|
9
|
+
};
|
|
10
|
+
let canceled = false;
|
|
11
|
+
cache.promise = importFn()
|
|
12
|
+
.then((module) => {
|
|
13
|
+
if (!canceled) {
|
|
14
|
+
cache.status = "success";
|
|
15
|
+
cache.component = module.default || module;
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
.catch((err) => {
|
|
19
|
+
if (!canceled) {
|
|
20
|
+
cache.status = "error";
|
|
21
|
+
cache.error = err;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return function LazyWrapper(props) {
|
|
25
|
+
const ctx = activeContext;
|
|
26
|
+
if (!ctx)
|
|
27
|
+
throw new Error("nixLazy() called outside component");
|
|
28
|
+
if (cache.status === "pending") {
|
|
29
|
+
throw cache.promise;
|
|
30
|
+
}
|
|
31
|
+
if (cache.status === "error") {
|
|
32
|
+
throw cache.error;
|
|
33
|
+
}
|
|
34
|
+
return cache.component(props);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function Suspense({ fallback, children, }) {
|
|
38
|
+
const loading = nixState(false);
|
|
39
|
+
const error = nixState(null);
|
|
40
|
+
try {
|
|
41
|
+
return children();
|
|
42
|
+
}
|
|
43
|
+
catch (promise) {
|
|
44
|
+
if (promise instanceof Promise) {
|
|
45
|
+
loading.value = true;
|
|
46
|
+
promise
|
|
47
|
+
.then(() => {
|
|
48
|
+
loading.value = false;
|
|
49
|
+
})
|
|
50
|
+
.catch((err) => {
|
|
51
|
+
error.value = err;
|
|
52
|
+
loading.value = false;
|
|
53
|
+
});
|
|
54
|
+
return fallback;
|
|
55
|
+
}
|
|
56
|
+
throw promise;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../hooks/nixLazy.ts"],
|
|
4
|
+
"sourcesContent": ["/* MIT License\r\n\r\n* Copyright (c) 2026 Resty Gonzales\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n* SOFTWARE.\r\n */\r\n// core/hooks/nixLazy.js\r\nimport { activeContext } from \"../context/context.js\";\r\nimport { nixState } from \"./nixState.js\";\r\n\r\n/**\r\n * Lazy-load a module/component with caching.\r\n *\r\n * @param {() => Promise<any>} importFn - Function that returns a dynamic import.\r\n * @returns {Function} Component wrapper for lazy-loaded module.\r\n */\r\nexport function nixLazy<TProps = any>(\r\n importFn: () => Promise<\r\n { default?: (props: TProps) => any } | ((props: TProps) => any)\r\n >\r\n): (props: TProps) => any {\r\n type Cache = {\r\n status: \"pending\" | \"success\" | \"error\";\r\n component: ((props: TProps) => any) | null;\r\n error: any;\r\n promise: Promise<any> | null;\r\n };\r\n const cache: Cache = {\r\n status: \"pending\",\r\n component: null,\r\n error: null,\r\n promise: null,\r\n };\r\n\r\n let canceled = false;\r\n\r\n cache.promise = importFn()\r\n .then((module) => {\r\n if (!canceled) {\r\n cache.status = \"success\";\r\n cache.component = (module as any).default || module;\r\n }\r\n })\r\n .catch((err) => {\r\n if (!canceled) {\r\n cache.status = \"error\";\r\n cache.error = err;\r\n }\r\n });\r\n\r\n return function LazyWrapper(props: TProps): any {\r\n const ctx = activeContext;\r\n if (!ctx) throw new Error(\"nixLazy() called outside component\");\r\n\r\n if (cache.status === \"pending\") {\r\n throw cache.promise; // Suspense-like behavior\r\n }\r\n\r\n if (cache.status === \"error\") {\r\n throw cache.error;\r\n }\r\n\r\n return cache.component!(props);\r\n };\r\n}\r\n\r\n/**\r\n * Suspense-like wrapper for lazy components.\r\n *\r\n * @param {Object} props\r\n * @param {any} props.fallback - Element to render while loading.\r\n * @param {Function} props.children - Function returning child component.\r\n * @returns {any} Rendered fallback or child.\r\n */\r\nexport function Suspense<T = any>({\r\n fallback,\r\n children,\r\n}: {\r\n fallback: any;\r\n children: () => T;\r\n}): T | any {\r\n const loading = nixState<boolean>(false);\r\n const error = nixState<any>(null);\r\n\r\n try {\r\n return children();\r\n } catch (promise) {\r\n if (promise instanceof Promise) {\r\n loading.value = true;\r\n promise\r\n .then(() => {\r\n loading.value = false;\r\n })\r\n .catch((err) => {\r\n error.value = err;\r\n loading.value = false;\r\n });\r\n return fallback;\r\n }\r\n throw promise;\r\n }\r\n}\r\n"],
|
|
5
|
+
"mappings": ";;AAuBA,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AAQlB,SAAS,QACd,UAGwB;AAOxB,QAAM,QAAe;AAAA,IACnB,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,OAAO;AAAA,IACP,SAAS;AAAA,EACX;AAEA,MAAI,WAAW;AAEf,QAAM,UAAU,SAAS,EACtB,KAAK,CAAC,WAAW;AAChB,QAAI,CAAC,UAAU;AACb,YAAM,SAAS;AACf,YAAM,YAAa,OAAe,WAAW;AAAA,IAC/C;AAAA,EACF,CAAC,EACA,MAAM,CAAC,QAAQ;AACd,QAAI,CAAC,UAAU;AACb,YAAM,SAAS;AACf,YAAM,QAAQ;AAAA,IAChB;AAAA,EACF,CAAC;AAEH,SAAO,gCAAS,YAAY,OAAoB;AAC9C,UAAM,MAAM;AACZ,QAAI,CAAC,IAAK,OAAM,IAAI,MAAM,oCAAoC;AAE9D,QAAI,MAAM,WAAW,WAAW;AAC9B,YAAM,MAAM;AAAA,IACd;AAEA,QAAI,MAAM,WAAW,SAAS;AAC5B,YAAM,MAAM;AAAA,IACd;AAEA,WAAO,MAAM,UAAW,KAAK;AAAA,EAC/B,GAbO;AAcT;AAhDgB;AA0DT,SAAS,SAAkB;AAAA,EAChC;AAAA,EACA;AACF,GAGY;AACV,QAAM,UAAU,SAAkB,KAAK;AACvC,QAAM,QAAQ,SAAc,IAAI;AAEhC,MAAI;AACF,WAAO,SAAS;AAAA,EAClB,SAAS,SAAS;AAChB,QAAI,mBAAmB,SAAS;AAC9B,cAAQ,QAAQ;AAChB,cACG,KAAK,MAAM;AACV,gBAAQ,QAAQ;AAAA,MAClB,CAAC,EACA,MAAM,CAAC,QAAQ;AACd,cAAM,QAAQ;AACd,gBAAQ,QAAQ;AAAA,MAClB,CAAC;AACH,aAAO;AAAA,IACT;AACA,UAAM;AAAA,EACR;AACF;AA3BgB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function nixLazyAsync<TProps = any>(importFn: () => Promise<{
|
|
2
|
+
default?: (props: TProps) => any;
|
|
3
|
+
} | ((props: TProps) => any)>, options?: {
|
|
4
|
+
retry?: number;
|
|
5
|
+
}): (props: TProps) => any;
|
|
6
|
+
export declare function Suspense<T = any>({ fallback, children, }: {
|
|
7
|
+
fallback: any;
|
|
8
|
+
children: () => T;
|
|
9
|
+
}): T | any;
|
|
10
|
+
//# sourceMappingURL=nixLazyAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nixLazyAsync.d.ts","sourceRoot":"","sources":["../../hooks/nixLazyAsync.ts"],"names":[],"mappings":"AAqCA,wBAAgB,YAAY,CAAC,MAAM,GAAG,GAAG,EACvC,QAAQ,EAAE,MAAM,OAAO,CACrB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,GAAG,CAAA;CAAE,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,GAAG,CAAC,CAChE,EACD,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/B,CAAC,KAAK,EAAE,MAAM,KAAK,GAAG,CAgExB;AAUD,wBAAgB,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,EAChC,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,GAAG,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC,CAAC;CACnB,GAAG,CAAC,GAAG,GAAG,CAmBV"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { activeContext } from "../context/context.js";
|
|
2
|
+
import { nixState } from "./nixState.js";
|
|
3
|
+
export function nixLazyAsync(importFn, options = {}) {
|
|
4
|
+
const { retry = 0 } = options;
|
|
5
|
+
const cache = {
|
|
6
|
+
status: "pending",
|
|
7
|
+
component: null,
|
|
8
|
+
error: null,
|
|
9
|
+
promise: null,
|
|
10
|
+
retriesLeft: retry,
|
|
11
|
+
};
|
|
12
|
+
let canceled = false;
|
|
13
|
+
const loadModule = () => {
|
|
14
|
+
cache.promise = importFn()
|
|
15
|
+
.then((module) => {
|
|
16
|
+
if (!canceled) {
|
|
17
|
+
cache.status = "success";
|
|
18
|
+
cache.component = module.default || module;
|
|
19
|
+
}
|
|
20
|
+
return cache.component;
|
|
21
|
+
})
|
|
22
|
+
.catch((err) => {
|
|
23
|
+
if (!canceled) {
|
|
24
|
+
if (cache.retriesLeft > 0) {
|
|
25
|
+
cache.retriesLeft--;
|
|
26
|
+
return loadModule();
|
|
27
|
+
}
|
|
28
|
+
cache.status = "error";
|
|
29
|
+
cache.error = err;
|
|
30
|
+
}
|
|
31
|
+
return Promise.reject(cache.error);
|
|
32
|
+
});
|
|
33
|
+
return cache.promise;
|
|
34
|
+
};
|
|
35
|
+
loadModule();
|
|
36
|
+
return function LazyWrapper(props) {
|
|
37
|
+
const ctx = activeContext;
|
|
38
|
+
if (!ctx)
|
|
39
|
+
throw new Error("nixLazyAsync() called outside component");
|
|
40
|
+
if (cache.status === "pending") {
|
|
41
|
+
throw cache.promise;
|
|
42
|
+
}
|
|
43
|
+
if (cache.status === "error") {
|
|
44
|
+
throw cache.error;
|
|
45
|
+
}
|
|
46
|
+
if (!cache.component) {
|
|
47
|
+
throw new Error("nixLazyAsync: component not loaded");
|
|
48
|
+
}
|
|
49
|
+
return cache.component(props);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export function Suspense({ fallback, children, }) {
|
|
53
|
+
const loading = nixState(false);
|
|
54
|
+
const error = nixState(null);
|
|
55
|
+
try {
|
|
56
|
+
return children();
|
|
57
|
+
}
|
|
58
|
+
catch (promise) {
|
|
59
|
+
if (promise instanceof Promise) {
|
|
60
|
+
loading.value = true;
|
|
61
|
+
promise
|
|
62
|
+
.then(() => (loading.value = false))
|
|
63
|
+
.catch((err) => {
|
|
64
|
+
error.value = err;
|
|
65
|
+
loading.value = false;
|
|
66
|
+
});
|
|
67
|
+
return fallback;
|
|
68
|
+
}
|
|
69
|
+
throw promise;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../hooks/nixLazyAsync.ts"],
|
|
4
|
+
"sourcesContent": ["/* MIT License\r\n\r\n* Copyright (c) 2026 Resty Gonzales\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n* SOFTWARE.\r\n */\r\n// core/hooks/nixLazyAsync.js\r\nimport { activeContext } from \"../context/context.js\";\r\nimport { nixState } from \"./nixState.js\";\r\n\r\n/**\r\n * Lazy-load a module/component with caching, retry, and abort support.\r\n *\r\n * @param {() => Promise<any>} importFn - Function returning a dynamic import.\r\n * @param {Object} [options={}] - Options for lazy loading.\r\n * @param {number} [options.retry=0] - Number of retry attempts on failure.\r\n * @returns {Function} Component wrapper for lazy-loaded module.\r\n *\r\n * @example\r\n * const LazyComp = nixLazyAsync(() => import(\"./MyComponent\"), { retry: 2 });\r\n */\r\nexport function nixLazyAsync<TProps = any>(\r\n importFn: () => Promise<\r\n { default?: (props: TProps) => any } | ((props: TProps) => any)\r\n >,\r\n options: { retry?: number } = {}\r\n): (props: TProps) => any {\r\n const { retry = 0 } = options;\r\n\r\n type Cache = {\r\n status: \"pending\" | \"success\" | \"error\";\r\n component: ((props: TProps) => any) | null;\r\n error: any;\r\n promise: Promise<any> | null;\r\n retriesLeft: number;\r\n };\r\n const cache: Cache = {\r\n status: \"pending\",\r\n component: null,\r\n error: null,\r\n promise: null,\r\n retriesLeft: retry,\r\n };\r\n\r\n let canceled = false;\r\n\r\n const loadModule = (): Promise<any> => {\r\n cache.promise = importFn()\r\n .then((module) => {\r\n if (!canceled) {\r\n cache.status = \"success\";\r\n cache.component = (module as any).default || module;\r\n }\r\n return cache.component;\r\n })\r\n .catch((err) => {\r\n if (!canceled) {\r\n if (cache.retriesLeft > 0) {\r\n cache.retriesLeft--;\r\n return loadModule();\r\n }\r\n cache.status = \"error\";\r\n cache.error = err;\r\n }\r\n return Promise.reject(cache.error);\r\n });\r\n return cache.promise;\r\n };\r\n\r\n loadModule();\r\n\r\n // Removed unused 'cancel' function\r\n\r\n return function LazyWrapper(props: TProps): any {\r\n const ctx = activeContext;\r\n if (!ctx) throw new Error(\"nixLazyAsync() called outside component\");\r\n\r\n if (cache.status === \"pending\") {\r\n throw cache.promise; // Suspense fallback\r\n }\r\n\r\n if (cache.status === \"error\") {\r\n throw cache.error;\r\n }\r\n\r\n if (!cache.component) {\r\n throw new Error(\"nixLazyAsync: component not loaded\");\r\n }\r\n return cache.component(props);\r\n };\r\n}\r\n\r\n/**\r\n * Suspense wrapper to catch pending promises and render fallback.\r\n *\r\n * @param {Object} props\r\n * @param {any} props.fallback - Element to render while loading.\r\n * @param {Function} props.children - Function returning child component.\r\n * @returns {any} Rendered fallback or child component.\r\n */\r\nexport function Suspense<T = any>({\r\n fallback,\r\n children,\r\n}: {\r\n fallback: any;\r\n children: () => T;\r\n}): T | any {\r\n const loading = nixState<boolean>(false);\r\n const error = nixState<any>(null);\r\n\r\n try {\r\n return children();\r\n } catch (promise) {\r\n if (promise instanceof Promise) {\r\n loading.value = true;\r\n promise\r\n .then(() => (loading.value = false))\r\n .catch((err) => {\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AACV,QAAM,UAAU,SAAkB,KAAK;AACvC,QAAM,QAAQ,SAAc,IAAI;AAEhC,MAAI;AACF,WAAO,SAAS;AAAA,EAClB,SAAS,SAAS;AAChB,QAAI,mBAAmB,SAAS;AAC9B,cAAQ,QAAQ;AAChB,cACG,KAAK,MAAO,QAAQ,QAAQ,KAAM,EAClC,MAAM,CAAC,QAAQ;AACd,cAAM,QAAQ;AACd,gBAAQ,QAAQ;AAAA,MAClB,CAAC;AACH,aAAO;AAAA,IACT;AACA,UAAM;AAAA,EACR;AACF;AAzBgB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { nixComputed } from "./nixComputed.js";
|
|
2
|
+
import { nixState } from "./nixState.js";
|
|
3
|
+
type ValidationRule<T> = {
|
|
4
|
+
required?: boolean;
|
|
5
|
+
minLength?: number;
|
|
6
|
+
maxLength?: number;
|
|
7
|
+
pattern?: RegExp;
|
|
8
|
+
custom?: (value: any, values: T) => boolean;
|
|
9
|
+
message?: string;
|
|
10
|
+
};
|
|
11
|
+
type ValidationRules<T> = {
|
|
12
|
+
[K in keyof T]?: ValidationRule<T>;
|
|
13
|
+
};
|
|
14
|
+
type LazyFormAsyncReturn<T, D = any, E = any, P = any> = {
|
|
15
|
+
LazyComponentWrapper: (props: P) => any;
|
|
16
|
+
values: ReturnType<typeof nixState<T>>;
|
|
17
|
+
errors: ReturnType<typeof nixState<Partial<Record<keyof T, string>>>>;
|
|
18
|
+
touched: ReturnType<typeof nixState<Partial<Record<keyof T, boolean>>>>;
|
|
19
|
+
isSubmitting: ReturnType<typeof nixState<boolean>>;
|
|
20
|
+
isValid: ReturnType<typeof nixComputed<boolean>>;
|
|
21
|
+
data: ReturnType<typeof nixState<D | null>>;
|
|
22
|
+
error: ReturnType<typeof nixState<E | null>>;
|
|
23
|
+
loading: ReturnType<typeof nixState<boolean>>;
|
|
24
|
+
handleChange: (fieldName: keyof T, value: any) => void;
|
|
25
|
+
handleBlur: (fieldName: keyof T) => void;
|
|
26
|
+
handleSubmit: (onSubmit: (values: T, signal: AbortSignal) => Promise<D>) => void;
|
|
27
|
+
cancelSubmit: () => void;
|
|
28
|
+
reset: () => void;
|
|
29
|
+
getFieldProps: (fieldName: keyof T) => {
|
|
30
|
+
value: any;
|
|
31
|
+
"r-input": (e: any) => void;
|
|
32
|
+
"r-blur": () => void;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export declare function nixLazyFormAsync<T extends Record<string, any> = Record<string, any>, D = any, E = any, P = any>(importFn: () => Promise<{
|
|
36
|
+
default?: (props: P) => any;
|
|
37
|
+
} | ((props: P) => any)>, formOptions?: {
|
|
38
|
+
initialValues?: T;
|
|
39
|
+
validationRules?: ValidationRules<T>;
|
|
40
|
+
}, submitOptions?: {
|
|
41
|
+
delay?: number;
|
|
42
|
+
leading?: boolean;
|
|
43
|
+
trailing?: boolean;
|
|
44
|
+
maxWait?: number;
|
|
45
|
+
cache?: boolean;
|
|
46
|
+
}, lazyOptions?: {
|
|
47
|
+
retry?: number;
|
|
48
|
+
}): LazyFormAsyncReturn<T, D, E, P>;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=nixLazyFormAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nixLazyFormAsync.d.ts","sourceRoot":"","sources":["../../hooks/nixLazyFormAsync.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAmBzC,KAAK,cAAc,CAAC,CAAC,IAAI;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,MAA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