@ostack.tech/ui-kform 1.0.0-rc.2 → 1.1.0
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/ostack-ui-kform.js +78 -18
- package/dist/ostack-ui-kform.js.map +1 -1
- package/package.json +4 -4
- package/types/components/LoadAction/LoadAction.d.ts +1 -1
- package/types/components/ResetOnChange/useResetOnChange.d.ts +5 -5
- package/types/components/SaveAction/SaveAction.d.ts +1 -1
- package/types/components/SubmitAction/SubmitAction.d.ts +1 -1
- package/types/components/ValidateAction/ValidateAction.d.ts +3 -2
- package/types/utils/useFormLoader.d.ts +27 -1
- package/types/utils/useFormSaver.d.ts +22 -1
- package/types/utils/useFormValidator.d.ts +26 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ostack.tech/ui-kform",
|
|
3
3
|
"description": "Integration of ostack/UI with ostack/KForm.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"homepage": "https://ui.ostack.tech/",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Opensoft",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"@fortawesome/fontawesome-svg-core": "^6.2.0 || ^7.0.0",
|
|
54
54
|
"@fortawesome/free-regular-svg-icons": "^6.2.0 || ^7.0.0",
|
|
55
55
|
"@fortawesome/free-solid-svg-icons": "^6.2.0 || ^7.0.0",
|
|
56
|
-
"@ostack.tech/kform": "
|
|
57
|
-
"@ostack.tech/kform-react": "
|
|
58
|
-
"@ostack.tech/ui": "~1.
|
|
56
|
+
"@ostack.tech/kform": "^1.1.0",
|
|
57
|
+
"@ostack.tech/kform-react": "^1.1.0",
|
|
58
|
+
"@ostack.tech/ui": "~1.1.0",
|
|
59
59
|
"@types/react": "^19.0.0",
|
|
60
60
|
"@types/react-dom": "^19.0.0",
|
|
61
61
|
"date-fns": "^4.1.0",
|
|
@@ -49,4 +49,4 @@ export interface LoadActionProps<T = unknown> extends Partial<ActionButtonProps>
|
|
|
49
49
|
* }
|
|
50
50
|
* ```
|
|
51
51
|
*/
|
|
52
|
-
export declare function LoadAction<T = unknown>({ label, keybinds, showWhenReadOnly, fileSystemId, loading, disabled, onClick, decode, path, extensions, mimeTypes, description, startIn, setPristineOnLoad, validateOnLoad, successMessage, errorMessage, ...otherProps }: LoadActionProps<T>): false | import("react").JSX.Element | undefined;
|
|
52
|
+
export declare function LoadAction<T = unknown>({ label, keybinds, showWhenReadOnly, fileSystemId, loading, disabled, onClick, decode, path, extensions, mimeTypes, description, startIn, onBeforeLoad, onAfterLoad, setPristineOnLoad, setTouchedOnLoad, validateOnLoad, successMessage, errorMessage, ...otherProps }: LoadActionProps<T>): false | import("react").JSX.Element | undefined;
|
|
@@ -10,12 +10,12 @@ export interface UseResetOnChangeOptions<T = unknown> extends PrefixedConfirmDia
|
|
|
10
10
|
*/
|
|
11
11
|
when?: (event: SealedValueEvent<T>) => boolean;
|
|
12
12
|
/**
|
|
13
|
-
* Fields in `
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Fields in `reset` that should be excluded from being reset (relative to the
|
|
14
|
+
* current path). This is useful when using wildcards in `reset` and you want
|
|
15
|
+
* to exclude some of the fields that match the wildcard.
|
|
16
16
|
*
|
|
17
|
-
* E.g.
|
|
18
|
-
* children of `/a` except `/a/b`.
|
|
17
|
+
* E.g. if the path being reset is `/a/*`, setting `exclude` to `/a/b` will
|
|
18
|
+
* reset all children of `/a` except `/a/b`.
|
|
19
19
|
*/
|
|
20
20
|
exclude?: string | Path | (string | Path)[];
|
|
21
21
|
/**
|
|
@@ -90,4 +90,4 @@ export interface SaveActionProps<T = unknown> extends Partial<ActionButtonProps>
|
|
|
90
90
|
* }
|
|
91
91
|
* ```
|
|
92
92
|
*/
|
|
93
|
-
export declare function SaveAction<T = unknown>({ label, keybinds, showWhenReadOnly, fileSystemId, disableOverwrite, saveOptionsLabel, saveAsLabel, saveAsKeybinds, loading, disabled, onClick, variant, color, path, encode, fileName, extensions, description, mimeTypes, startIn, excludeAcceptAllOption, successMessage, errorMessage, groupCollapsed, defaultOpen, open, onOpenChange, modal, groupLabel, saveOptionsPlacement, buttonGroupProps, saveOptionsProps, dropdownMenuGroupProps, dropdownMenuContentProps, ...otherProps }: SaveActionProps<T>): false | import("react").JSX.Element;
|
|
93
|
+
export declare function SaveAction<T = unknown>({ label, keybinds, showWhenReadOnly, fileSystemId, disableOverwrite, saveOptionsLabel, saveAsLabel, saveAsKeybinds, loading, disabled, onClick, variant, color, path, encode, fileName, extensions, description, mimeTypes, startIn, excludeAcceptAllOption, onBeforeSave, onAfterSave, setPristineOnSave, successMessage, errorMessage, groupCollapsed, defaultOpen, open, onOpenChange, modal, groupLabel, saveOptionsPlacement, buttonGroupProps, saveOptionsProps, dropdownMenuGroupProps, dropdownMenuContentProps, ...otherProps }: SaveActionProps<T>): false | import("react").JSX.Element;
|
|
@@ -130,4 +130,4 @@ export interface SubmitActionProps<T = unknown, TSubmitResult = unknown> extends
|
|
|
130
130
|
* }
|
|
131
131
|
* ```
|
|
132
132
|
*/
|
|
133
|
-
export declare function SubmitAction<T = unknown, TSubmitResult = unknown>({ onSubmit, onInvalidSubmit, onSuccessfulSubmit, onFailedSubmit, setTouchedOnSubmit, validateOnSubmit, setPristineOnSuccessfulSubmit, convertExternalIssuesTableRowIndicesToIds, label, keybinds, showWhenReadOnly, confirmWarnings, loading, disabled, onClick, dialogTitle, dialogDescription, dialogBody, confirmWarningsCheckboxLabel, dialogOkText, dialogCancelText, successMessage: successMessageProp, errorMessage: errorMessageProp, dialogContentProps, dialogHeaderProps, dialogTitleProps, dialogBodyProps, dialogDescriptionProps, dialogFooterProps, dialogOkButtonProps, dialogCancelButtonProps, confirmWarningsAlertProps, confirmWarningsCheckboxProps, ...otherProps }: SubmitActionProps<T, TSubmitResult>): false | import("react").JSX.Element | undefined;
|
|
133
|
+
export declare function SubmitAction<T = unknown, TSubmitResult = unknown>({ onBeforeSubmit, onSubmit, onInvalidSubmit, onSuccessfulSubmit, onFailedSubmit, onAfterSubmit, setTouchedOnSubmit, validateOnSubmit, setPristineOnSuccessfulSubmit, convertExternalIssuesTableRowIndicesToIds, label, keybinds, showWhenReadOnly, confirmWarnings, loading, disabled, onClick, dialogTitle, dialogDescription, dialogBody, confirmWarningsCheckboxLabel, dialogOkText, dialogCancelText, successMessage: successMessageProp, errorMessage: errorMessageProp, dialogContentProps, dialogHeaderProps, dialogTitleProps, dialogBodyProps, dialogDescriptionProps, dialogFooterProps, dialogOkButtonProps, dialogCancelButtonProps, confirmWarningsAlertProps, confirmWarningsCheckboxProps, ...otherProps }: SubmitActionProps<T, TSubmitResult>): false | import("react").JSX.Element | undefined;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type ActionButtonProps } from "@ostack.tech/ui";
|
|
2
|
+
import { type UseFormValidatorOptions } from "../../utils/useFormValidator.ts";
|
|
2
3
|
/** Default “validate” keybinds. */
|
|
3
4
|
export declare const DEFAULT_VALIDATE_KEYBINDS = "Alt+Shift+V";
|
|
4
5
|
/** Properties of the validate action. */
|
|
5
|
-
export interface ValidateActionProps extends Partial<ActionButtonProps> {
|
|
6
|
+
export interface ValidateActionProps extends UseFormValidatorOptions, Partial<ActionButtonProps> {
|
|
6
7
|
/**
|
|
7
8
|
* Keybinds for triggering the action. Set to `null` to disable the keyboard
|
|
8
9
|
* shortcut.
|
|
@@ -40,4 +41,4 @@ export interface ValidateActionProps extends Partial<ActionButtonProps> {
|
|
|
40
41
|
* }
|
|
41
42
|
* ```
|
|
42
43
|
*/
|
|
43
|
-
export declare function ValidateAction({ label, keybinds, showWhenReadOnly, loading, disabled, onClick, ...otherProps }: ValidateActionProps): false | import("react").JSX.Element | undefined;
|
|
44
|
+
export declare function ValidateAction({ onBeforeValidate, onAfterValidate, label, keybinds, showWhenReadOnly, loading, disabled, onClick, ...otherProps }: ValidateActionProps): false | import("react").JSX.Element | undefined;
|
|
@@ -35,6 +35,27 @@ export interface FormLoaderOptions<T = unknown> {
|
|
|
35
35
|
* different IDs.
|
|
36
36
|
*/
|
|
37
37
|
id?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Function called before loading. The form will still be marked as "loading"
|
|
40
|
+
* while this function is running.
|
|
41
|
+
*
|
|
42
|
+
* If `false` is returned, then the load action will be cancelled. If loading
|
|
43
|
+
* was cancelled, `onAfterLoad` will **not** run.
|
|
44
|
+
*
|
|
45
|
+
* @returns Boolean indicating whether loading should proceed. If nothing
|
|
46
|
+
* (`undefined`) is returned, then loading will proceed as normal. A promise
|
|
47
|
+
* resolving to one of the previously mentioned values may also be
|
|
48
|
+
* returned.
|
|
49
|
+
*/
|
|
50
|
+
onBeforeLoad?: () => boolean | void | PromiseLike<boolean | void>;
|
|
51
|
+
/**
|
|
52
|
+
* Function called after loading independently of success or failure. The form
|
|
53
|
+
* will still be marked as "loading" while this function is running.
|
|
54
|
+
*
|
|
55
|
+
* This function does **not** run if loading was cancelled due to `false`
|
|
56
|
+
* being returned from `onBeforeLoad`.
|
|
57
|
+
*/
|
|
58
|
+
onAfterLoad?: () => void | PromiseLike<void>;
|
|
38
59
|
/**
|
|
39
60
|
* Whether to set the form as pristine when it is loaded.
|
|
40
61
|
*
|
|
@@ -85,6 +106,11 @@ export interface FormLoaderResult<T> {
|
|
|
85
106
|
supportsFileSystemAPIs: boolean;
|
|
86
107
|
}
|
|
87
108
|
/** Hook exposing a function used to load the form from a file. */
|
|
88
|
-
export declare function useFormLoader<T = unknown>({ decode, path, extensions, mimeTypes, description, startIn, id, setPristineOnLoad, setTouchedOnLoad, validateOnLoad, successMessage, errorMessage, }?: FormLoaderOptions<T>): FormLoaderResult<T>;
|
|
109
|
+
export declare function useFormLoader<T = unknown>({ decode, path, extensions, mimeTypes, description, startIn, id, onBeforeLoad, onAfterLoad, setPristineOnLoad, setTouchedOnLoad, validateOnLoad, successMessage, errorMessage, }?: FormLoaderOptions<T>): FormLoaderResult<T>;
|
|
110
|
+
/**
|
|
111
|
+
* Hook exposing whether the form is currently preparing the load (running
|
|
112
|
+
* `onBeforeLoad` or selecting the file to load).
|
|
113
|
+
*/
|
|
114
|
+
export declare function useFormIsPreparingLoad(): any;
|
|
89
115
|
/** Hook exposing whether the form is currently being loaded. */
|
|
90
116
|
export declare function useFormIsLoading(): any;
|
|
@@ -70,6 +70,27 @@ export interface FormSaverOptions<T = unknown> {
|
|
|
70
70
|
* different IDs.
|
|
71
71
|
*/
|
|
72
72
|
id?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Function called before saving. The form will still be marked as "saving"
|
|
75
|
+
* while this function is running.
|
|
76
|
+
*
|
|
77
|
+
* If `false` is returned, then the save action will be cancelled. If saving
|
|
78
|
+
* was cancelled, `onAfterSave` will **not** run.
|
|
79
|
+
*
|
|
80
|
+
* @returns Boolean indicating whether saving should proceed. If nothing
|
|
81
|
+
* (`undefined`) is returned, then saving will proceed as normal. A promise
|
|
82
|
+
* resolving to one of the previously mentioned values may also be
|
|
83
|
+
* returned.
|
|
84
|
+
*/
|
|
85
|
+
onBeforeSave?: () => boolean | void | PromiseLike<boolean | void>;
|
|
86
|
+
/**
|
|
87
|
+
* Function called after saving independently of success or failure. The form
|
|
88
|
+
* will still be marked as "saving" while this function is running.
|
|
89
|
+
*
|
|
90
|
+
* This function does **not** run if saving was cancelled due to `false` being
|
|
91
|
+
* returned from `onBeforeSave`.
|
|
92
|
+
*/
|
|
93
|
+
onAfterSave?: () => void | PromiseLike<void>;
|
|
73
94
|
/**
|
|
74
95
|
* Whether to set the form as pristine when saving.
|
|
75
96
|
*
|
|
@@ -108,6 +129,6 @@ export interface FormSaverResult<T> {
|
|
|
108
129
|
supportsFileSystemAPIs: boolean;
|
|
109
130
|
}
|
|
110
131
|
/** Hook exposing functions used to save the form to a file. */
|
|
111
|
-
export declare function useFormSaver<T = unknown>({ overwrite, path, encode, fileName, extensions, description, mimeTypes, startIn, excludeAcceptAllOption, id, setPristineOnSave, successMessage, errorMessage, }?: FormSaverOptions<T>): FormSaverResult<T>;
|
|
132
|
+
export declare function useFormSaver<T = unknown>({ overwrite, path, encode, fileName, extensions, description, mimeTypes, startIn, excludeAcceptAllOption, id, onBeforeSave, onAfterSave, setPristineOnSave, successMessage, errorMessage, }?: FormSaverOptions<T>): FormSaverResult<T>;
|
|
112
133
|
/** Hook exposing whether the form is currently being saved. */
|
|
113
134
|
export declare function useFormIsSaving(): any;
|
|
@@ -1,5 +1,29 @@
|
|
|
1
|
+
/** Options of the {@link useFormValidator} hook. */
|
|
2
|
+
export interface UseFormValidatorOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Function called before validating. The form will still be marked as
|
|
5
|
+
* "validating" while this function is running.
|
|
6
|
+
*
|
|
7
|
+
* If `false` is returned, then the validate action will be cancelled. If
|
|
8
|
+
* validating was cancelled, `onAfterValidate` will **not** run.
|
|
9
|
+
*
|
|
10
|
+
* @returns Boolean indicating whether validating should proceed. If nothing
|
|
11
|
+
* (`undefined`) is returned, then validating will proceed as normal. A
|
|
12
|
+
* promise resolving to one of the previously mentioned values may also be
|
|
13
|
+
* returned.
|
|
14
|
+
*/
|
|
15
|
+
onBeforeValidate?: () => boolean | void | PromiseLike<boolean | void>;
|
|
16
|
+
/**
|
|
17
|
+
* Function called after validating independently of success or failure. The
|
|
18
|
+
* form will still be marked as "validating" while this function is running.
|
|
19
|
+
*
|
|
20
|
+
* This function does **not** run if validating was cancelled due to `false`
|
|
21
|
+
* being returned from `onBeforeValidate`.
|
|
22
|
+
*/
|
|
23
|
+
onAfterValidate?: () => void | PromiseLike<void>;
|
|
24
|
+
}
|
|
1
25
|
/** Result of the {@link useFormValidator} hook. */
|
|
2
|
-
export interface
|
|
26
|
+
export interface UseFormValidatorResult {
|
|
3
27
|
/**
|
|
4
28
|
* Function used to validate the form.
|
|
5
29
|
*
|
|
@@ -8,7 +32,7 @@ export interface FormValidatorResult {
|
|
|
8
32
|
validate: () => Promise<void>;
|
|
9
33
|
}
|
|
10
34
|
/** Hook exposing a function used to validate the form. */
|
|
11
|
-
export declare function useFormValidator():
|
|
35
|
+
export declare function useFormValidator({ onBeforeValidate, onAfterValidate, }?: UseFormValidatorOptions): UseFormValidatorResult;
|
|
12
36
|
/** Result of the {@link useFormIsValidating} hook. */
|
|
13
37
|
export interface FormIsValidatingResult {
|
|
14
38
|
/**
|