@ostack.tech/ui-kform 0.15.5 → 0.16.1
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/chunks/{en-CaLvO1z0.js → en-CKrk2smU.js} +14 -5
- package/dist/chunks/en-CKrk2smU.js.map +1 -0
- package/dist/locales/en-GB.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/fr-FR.js +21 -12
- package/dist/locales/fr-FR.js.map +1 -1
- package/dist/locales/pt-PT.js +13 -4
- package/dist/locales/pt-PT.js.map +1 -1
- package/dist/ostack-ui-kform.css +13 -0
- package/dist/ostack-ui-kform.js +1806 -709
- package/dist/ostack-ui-kform.js.map +1 -1
- package/package.json +6 -5
- package/scss/_utils.scss +1 -0
- package/scss/components/FormPages/_FormPages.scss +8 -0
- package/scss/components/SubmitAction/_SubmitAction-variables.scss +3 -0
- package/scss/components/SubmitAction/_SubmitAction.scss +13 -0
- package/scss/index.scss +1 -0
- package/types/components/Annexes/Annex.d.ts +71 -7
- package/types/components/Annexes/Annexes.d.ts +49 -65
- package/types/components/Annexes/AnnexesContext.d.ts +2 -1
- package/types/components/Annexes/AnnexesManager.d.ts +15 -10
- package/types/components/Annexes/AnnexesMenu.d.ts +5 -6
- package/types/components/Annexes/AnnexesTabList.d.ts +3 -4
- package/types/components/CheckboxControl/CheckboxControl.d.ts +38 -9
- package/types/components/CheckboxGroupControl/CheckboxGroupControl.d.ts +64 -22
- package/types/components/CheckboxGroupControl/CheckboxGroupControlItem.d.ts +26 -0
- package/types/components/CheckboxGroupControl/index.d.ts +1 -0
- package/types/components/ControlField/ControlField.d.ts +3 -4
- package/types/components/DateControl/DateControl.d.ts +38 -8
- package/types/components/DateRangeControl/DateRangeControl.d.ts +56 -24
- package/types/components/DebugInfo/DebugInfo.d.ts +26 -0
- package/types/components/DebugInfo/DebugInfoControlAddonTrigger.d.ts +9 -0
- package/types/components/DebugInfo/index.d.ts +2 -0
- package/types/components/FileControl/FileControl.d.ts +37 -8
- package/types/components/FileControl/FileControlDownloadAddon.d.ts +8 -0
- package/types/components/FileControl/FileControlViewAddon.d.ts +10 -0
- package/types/components/FormApp/FormApp.d.ts +60 -139
- package/types/components/FormApp/FormAppContext.d.ts +13 -3
- package/types/components/FormApp/FormAppElement.d.ts +3 -3
- package/types/components/FormApp/index.d.ts +1 -1
- package/types/components/FormPages/FormPage.d.ts +38 -20
- package/types/components/FormPages/FormPageHeader.d.ts +3 -3
- package/types/components/FormPages/FormPages.d.ts +45 -24
- package/types/components/FormPages/FormPagesContext.d.ts +2 -1
- package/types/components/FormPages/FormPagesNavigation.d.ts +11 -8
- package/types/components/FormPages/FormPagesSelect.d.ts +1 -1
- package/types/components/FormPages/FormPagesSidebar.d.ts +3 -3
- package/types/components/FormStepper/FormStep.d.ts +23 -7
- package/types/components/FormStepper/FormStepList.d.ts +3 -4
- package/types/components/FormStepper/FormStepper.d.ts +52 -21
- package/types/components/FormStepper/FormStepperContext.d.ts +2 -1
- package/types/components/FormStepper/FormStepperFinishTrigger.d.ts +4 -1
- package/types/components/FormStepper/FormStepperNextTrigger.d.ts +4 -1
- package/types/components/FormStepper/FormStepperPreviousTrigger.d.ts +4 -1
- package/types/components/FormStepper/FormStepperState.d.ts +3 -1
- package/types/components/IssueMessage/IssueMessage.d.ts +2 -2
- package/types/components/IssueMessages/IssueMessages.d.ts +4 -4
- package/types/components/IssuesAlert/IssuesAlert.d.ts +4 -5
- package/types/components/IssuesPanel/IssuesPanel.d.ts +18 -18
- package/types/components/IssuesPanel/IssuesPanelMessagesCard.d.ts +4 -4
- package/types/components/IssuesPanel/IssuesPanelSummaryCard.d.ts +4 -4
- package/types/components/IssuesPopover/IssuesPopover.d.ts +3 -4
- package/types/components/LoadAction/LoadAction.d.ts +34 -4
- package/types/components/NumericControl/NumericControl.d.ts +56 -8
- package/types/components/PathLink/PathLink.d.ts +2 -2
- package/types/components/PrintAction/PrintAction.d.ts +41 -16
- package/types/components/RadioGroupControl/RadioGroupControl.d.ts +54 -19
- package/types/components/RadioGroupControl/RadioGroupControlItem.d.ts +25 -0
- package/types/components/RadioGroupControl/index.d.ts +1 -0
- package/types/components/SaveAction/SaveAction.d.ts +45 -7
- package/types/components/SelectControl/SelectControl.d.ts +55 -10
- package/types/components/SelectControl/SelectControlItem.d.ts +23 -0
- package/types/components/SelectControl/SelectControlItemGroup.d.ts +23 -0
- package/types/components/SelectControl/index.d.ts +2 -0
- package/types/components/SelectMultipleControl/SelectMultipleControl.d.ts +71 -14
- package/types/components/SelectMultipleControl/SelectMultipleControlItem.d.ts +13 -0
- package/types/components/SelectMultipleControl/SelectMultipleControlItemGroup.d.ts +13 -0
- package/types/components/SelectMultipleControl/index.d.ts +2 -0
- package/types/components/SubmitAction/SubmitAction.d.ts +50 -14
- package/types/components/TableControl/TableControl.d.ts +108 -13
- package/types/components/TableControl/TableControlActionsColumn.d.ts +21 -0
- package/types/components/TableControl/TableControlActionsColumnLabel.d.ts +2 -0
- package/types/components/TableControl/TableControlAddRowTrigger.d.ts +12 -5
- package/types/components/TableControl/TableControlCell.d.ts +3 -4
- package/types/components/TableControl/TableControlColumn.d.ts +24 -56
- package/types/components/TableControl/TableControlColumnFns.d.ts +113 -0
- package/types/components/TableControl/TableControlColumnGroup.d.ts +25 -0
- package/types/components/TableControl/TableControlColumns.d.ts +14 -0
- package/types/components/TableControl/TableControlContent.d.ts +3 -4
- package/types/components/TableControl/TableControlContext.d.ts +2 -1
- package/types/components/TableControl/TableControlIndexColumn.d.ts +10 -0
- package/types/components/TableControl/TableControlIndexColumnLabel.d.ts +2 -0
- package/types/components/TableControl/TableControlPagination.d.ts +4 -1
- package/types/components/TableControl/TableControlRemoveRowTrigger.d.ts +5 -5
- package/types/components/TableControl/TableControlRow.d.ts +11 -4
- package/types/components/TableControl/TableControlRowsPerPage.d.ts +4 -1
- package/types/components/TableControl/index.d.ts +6 -0
- package/types/components/TextControl/TextControl.d.ts +47 -21
- package/types/components/TopBar/TopBar.d.ts +3 -3
- package/types/components/TopBar/TopBarActions.d.ts +3 -4
- package/types/components/ValidateAction/ValidateAction.d.ts +24 -2
- package/types/index.d.ts +1 -0
- package/types/providers/LocalizationProvider/LocalizationObject.d.ts +5 -1
- package/types/utils/__tests__/pathSpecificity.test.d.ts +1 -0
- package/types/utils/options.d.ts +13 -18
- package/types/utils/promiseUtils.d.ts +7 -0
- package/types/utils/selectionTransformations.d.ts +9 -9
- package/types/utils/useControlIssues.d.ts +21 -19
- package/types/utils/useFormLoader.d.ts +7 -1
- package/types/utils/useFormSaver.d.ts +3 -3
- package/dist/chunks/en-CaLvO1z0.js.map +0 -1
|
@@ -13,6 +13,7 @@ export interface FormAppContextValue<T = unknown> {
|
|
|
13
13
|
issueMessagesDataKey: string;
|
|
14
14
|
formAppElement: HTMLFormElement | null;
|
|
15
15
|
store: FormAppStore<T>;
|
|
16
|
+
debug: boolean;
|
|
16
17
|
}
|
|
17
18
|
/** State of the form app. */
|
|
18
19
|
export interface FormAppState<T> {
|
|
@@ -73,7 +74,7 @@ export interface UseCreateFormAppContextOptions<T> extends Omit<FormAppContextVa
|
|
|
73
74
|
onPathFocus?: (path: AbsolutePath) => void;
|
|
74
75
|
}
|
|
75
76
|
/** Hook which creates the form app context. */
|
|
76
|
-
export declare function useCreateFormAppContext<T>({ formTitle, controller, disabled, readOnly, issuesDisplayMode, displayIssueCodes, issueMessagesDataKey, formAppElement, onPathFocus, }: UseCreateFormAppContextOptions<T>): {
|
|
77
|
+
export declare function useCreateFormAppContext<T>({ formTitle, controller, disabled, readOnly, issuesDisplayMode, displayIssueCodes, issueMessagesDataKey, formAppElement, onPathFocus, debug, }: UseCreateFormAppContextOptions<T>): {
|
|
77
78
|
formTitle: string | undefined;
|
|
78
79
|
disabled: boolean;
|
|
79
80
|
readOnly: boolean;
|
|
@@ -81,6 +82,7 @@ export declare function useCreateFormAppContext<T>({ formTitle, controller, disa
|
|
|
81
82
|
displayIssueCodes: boolean;
|
|
82
83
|
issueMessagesDataKey: string;
|
|
83
84
|
formAppElement: HTMLFormElement | null;
|
|
85
|
+
debug: boolean;
|
|
84
86
|
store: Omit<import("zustand").StoreApi<FormAppState<T>>, "subscribe"> & {
|
|
85
87
|
subscribe: {
|
|
86
88
|
(listener: (selectedState: FormAppState<T>, previousSelectedState: FormAppState<T>) => void): () => void;
|
|
@@ -108,6 +110,8 @@ export declare function useIssuesDisplayMode(): IssuesDisplayMode;
|
|
|
108
110
|
export declare function useDisplayIssueCodesInIssueMessages(): boolean;
|
|
109
111
|
/** Hook providing access to the form app's HTML form element. */
|
|
110
112
|
export declare function useFormAppElement(): HTMLFormElement;
|
|
113
|
+
/** Returns whether the form is in debug mode. */
|
|
114
|
+
export declare function useFormInDebugMode(): boolean;
|
|
111
115
|
/**
|
|
112
116
|
* Hook exposing a function that can be used to specify the height of the form
|
|
113
117
|
* app's top bar.
|
|
@@ -164,6 +168,12 @@ export declare function useActiveIssuesPanelBreadcrumb(): BreadcrumbItem[] | nul
|
|
|
164
168
|
export declare function useStartIssuesNavigation(): FormAppActions["startIssuesNavigation"];
|
|
165
169
|
/** Options available to the {@link useOnPathFocus} hook. */
|
|
166
170
|
export interface UseOnFocusedPathChangeOptions {
|
|
171
|
+
/**
|
|
172
|
+
* Whether to enable the hook.
|
|
173
|
+
*
|
|
174
|
+
* @default true
|
|
175
|
+
*/
|
|
176
|
+
enabled?: boolean;
|
|
167
177
|
/**
|
|
168
178
|
* Whether to run the callback immediately with the current focused path.
|
|
169
179
|
*
|
|
@@ -176,10 +186,10 @@ export interface UseOnFocusedPathChangeOptions {
|
|
|
176
186
|
* changes.
|
|
177
187
|
*
|
|
178
188
|
* @param cb Function to run when the focused path changes. This function should
|
|
179
|
-
* hopefully not change on every render (i.e
|
|
189
|
+
* hopefully not change on every render (i.e. it should be memoised via
|
|
180
190
|
* `useCallback` or be defined externally).
|
|
181
191
|
* @param options Hook options.
|
|
182
192
|
*/
|
|
183
|
-
export declare function useOnPathFocus(cb: (focusedPath: AbsolutePath) => void, { fireImmediately }?: UseOnFocusedPathChangeOptions): void;
|
|
193
|
+
export declare function useOnPathFocus(cb: (focusedPath: AbsolutePath) => void, { enabled, fireImmediately, }?: UseOnFocusedPathChangeOptions): void;
|
|
184
194
|
/** Hook used to set the function which starts issue navigation. */
|
|
185
195
|
export declare function useSetStartIssuesNavigation(fn: () => void): void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ComponentProps, type Dispatch, type SetStateAction } from "react";
|
|
2
2
|
import type { FormAppProps } from "./FormApp.tsx";
|
|
3
3
|
/** Properties of the form application element component. */
|
|
4
|
-
export interface FormAppElementProps extends Omit<
|
|
4
|
+
export interface FormAppElementProps extends Omit<ComponentProps<"form">, "onSubmit" | "onReset">, Pick<FormAppProps, "minHeight"> {
|
|
5
5
|
formAppElement: HTMLFormElement | null;
|
|
6
6
|
setFormAppElement: Dispatch<SetStateAction<HTMLFormElement | null>>;
|
|
7
7
|
}
|
|
8
8
|
/** Form application element. */
|
|
9
|
-
export declare
|
|
9
|
+
export declare function FormAppElement({ formAppElement, setFormAppElement, minHeight, className, style, children, ref, ...otherProps }: FormAppElementProps): import("react").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from "./FormApp.tsx";
|
|
2
|
-
export { useActiveIssuesPanelBreadcrumb, useDisplayIssueCodesInIssueMessages, useFocus, useFormAppElement, useFormIsDisabled, useFormIsReadOnly, useFormTitle, useIsRegistered, useIssuesDisplayMode, useOnPathFocus, useRegisterController, useRegisteredIssueMessage, useRegisterIssueMessages, useRegisterLabel, useSetBottomPanelHeight, useSetLeftSidebarWidth, useSetTopBarHeight, useStartIssuesNavigation, } from "./FormAppContext.ts";
|
|
2
|
+
export { useActiveIssuesPanelBreadcrumb, useDisplayIssueCodesInIssueMessages, useFocus, useFormAppElement, useFormInDebugMode, useFormIsDisabled, useFormIsReadOnly, useFormTitle, useIsRegistered, useIssuesDisplayMode, useOnPathFocus, useRegisterController, useRegisteredIssueMessage, useRegisterIssueMessages, useRegisterLabel, useResetFocus, useSetBottomPanelHeight, useSetLeftSidebarWidth, useSetTopBarHeight, useStartIssuesNavigation, } from "./FormAppContext.ts";
|
|
3
3
|
export * from "./FormAppIssueMessages.tsx";
|
|
4
4
|
export * from "./FormAppStatus.tsx";
|
|
@@ -1,10 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { type
|
|
3
|
-
import type
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
1
|
+
import type { Path } from "@ostack.tech/kform";
|
|
2
|
+
import { type ContainerProps, type ErrorBoundaryProps, type IconButtonProps, type PopoverContentProps, type PopoverProps, type StackProps } from "@ostack.tech/ui";
|
|
3
|
+
import { type ComponentProps, type ReactNode } from "react";
|
|
4
|
+
import type { IssueMessagesByCode, IssueMessagesProps } from "../IssueMessages";
|
|
5
|
+
import type { IssuesPopoverProps } from "../IssuesPopover";
|
|
6
|
+
/** Object representation of a form page. */
|
|
7
|
+
export interface FormPageObject<T = any> {
|
|
8
|
+
/** Form page path. */
|
|
9
|
+
path?: string | Path;
|
|
10
|
+
/** Form page's title */
|
|
11
|
+
title?: ReactNode | ((value: T) => ReactNode);
|
|
12
|
+
/**
|
|
13
|
+
* Title of the form page as a string to display in the document's title.
|
|
14
|
+
*
|
|
15
|
+
* Defaults to `title` when it is a string. A warning is printed if `title` is
|
|
16
|
+
* not a string and `documentTitle` is not provided.
|
|
17
|
+
*/
|
|
18
|
+
documentTitle?: string | null | ((value: T) => string | null);
|
|
19
|
+
/** Form page's code. */
|
|
20
|
+
code?: ReactNode;
|
|
21
|
+
/** Form page's label in the issues panel. The `title` is used by default. */
|
|
22
|
+
issuesPanelLabel?: ReactNode | ((value: T) => ReactNode);
|
|
23
|
+
}
|
|
6
24
|
/** Properties of the form page component. */
|
|
7
|
-
export interface FormPageProps extends FormPageObject, Omit<
|
|
25
|
+
export interface FormPageProps extends FormPageObject, Omit<ComponentProps<"section">, "title" | "children"> {
|
|
8
26
|
/** Sets the form page as disabled. */
|
|
9
27
|
disabled?: boolean;
|
|
10
28
|
/** Sets the form page as read-only. */
|
|
@@ -47,7 +65,7 @@ export interface FormPageProps extends FormPageObject, Omit<ComponentPropsWithou
|
|
|
47
65
|
*/
|
|
48
66
|
ownIssueMessages?: IssueMessagesByCode;
|
|
49
67
|
/** Properties to pass to the header element. */
|
|
50
|
-
headerProps?:
|
|
68
|
+
headerProps?: ComponentProps<"div">;
|
|
51
69
|
/** Label of the helper button announced to assistive technologies. */
|
|
52
70
|
helperButtonLabel?: string;
|
|
53
71
|
/**
|
|
@@ -56,31 +74,31 @@ export interface FormPageProps extends FormPageObject, Omit<ComponentPropsWithou
|
|
|
56
74
|
*/
|
|
57
75
|
visuallyHiddenCodePrefix?: ReactNode;
|
|
58
76
|
/** Properties to pass to the code element. */
|
|
59
|
-
codeProps?:
|
|
77
|
+
codeProps?: ComponentProps<"div">;
|
|
60
78
|
/** Properties to pass to the title element. */
|
|
61
|
-
titleProps?:
|
|
79
|
+
titleProps?: ComponentProps<"h2">;
|
|
62
80
|
/**
|
|
63
81
|
* Properties to pass to the element containing the popover components in the
|
|
64
82
|
* header.
|
|
65
83
|
*/
|
|
66
|
-
headerPopoverContainerProps?:
|
|
84
|
+
headerPopoverContainerProps?: StackProps;
|
|
67
85
|
/** Properties to pass to the form page's issues popover component. */
|
|
68
|
-
issuesPopoverProps?:
|
|
86
|
+
issuesPopoverProps?: IssuesPopoverProps;
|
|
69
87
|
/** Properties to pass to the form page's issue messages component. */
|
|
70
|
-
issueMessagesProps?: Omit<
|
|
88
|
+
issueMessagesProps?: Omit<IssueMessagesProps, "messages">;
|
|
71
89
|
/** Properties to pass to the content element. */
|
|
72
|
-
contentProps?:
|
|
90
|
+
contentProps?: ComponentProps<"div">;
|
|
73
91
|
/** Properties to pass to the container component. */
|
|
74
|
-
containerProps?:
|
|
92
|
+
containerProps?: ContainerProps;
|
|
75
93
|
/** Properties to pass to the `ErrorBoundary` component. */
|
|
76
|
-
errorBoundaryProps?:
|
|
94
|
+
errorBoundaryProps?: ErrorBoundaryProps;
|
|
77
95
|
/** Properties to pass to the helper button component. */
|
|
78
|
-
helperButtonProps?: Omit<
|
|
96
|
+
helperButtonProps?: Omit<IconButtonProps, "icon">;
|
|
79
97
|
/** Properties to pass to the helper popover component. */
|
|
80
|
-
helperPopoverProps?:
|
|
98
|
+
helperPopoverProps?: PopoverProps;
|
|
81
99
|
/** Properties to pass to the helper popover content component. */
|
|
82
|
-
helperPopoverContentProps?:
|
|
100
|
+
helperPopoverContentProps?: PopoverContentProps;
|
|
83
101
|
children?: ReactNode;
|
|
84
102
|
}
|
|
85
|
-
/**
|
|
86
|
-
export declare
|
|
103
|
+
/** Component representing a single form page. */
|
|
104
|
+
export declare function FormPage({ path, title: _title, documentTitle: _documentTitle, code: _code, issuesPanelLabel: _issuesPanelLabel, disabled, readOnly, className, helperText, helperButtonLabel, visuallyHiddenCodePrefix: _visuallyHiddenCodePrefix, issueMessages, ownIssueMessages, headerProps, codeProps, titleProps, headerPopoverContainerProps, issuesPopoverProps, issueMessagesProps, contentProps, containerProps, errorBoundaryProps, helperButtonProps, helperPopoverProps, helperPopoverContentProps, children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...otherProps }: FormPageProps): import("react").JSX.Element | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
2
|
import type { FormPageProps } from "./FormPage.tsx";
|
|
3
3
|
/** Properties of the form page header. */
|
|
4
|
-
export interface FormPageHeaderProps extends
|
|
4
|
+
export interface FormPageHeaderProps extends ComponentProps<"div">, Pick<FormPageProps, "helperText" | "helperButtonLabel" | "ownIssueMessages" | "codeProps" | "titleProps" | "headerPopoverContainerProps" | "issuesPopoverProps" | "issueMessagesProps" | "helperButtonProps" | "helperPopoverProps" | "helperPopoverContentProps"> {
|
|
5
5
|
}
|
|
6
6
|
/** Form page header. */
|
|
7
|
-
export declare
|
|
7
|
+
export declare function FormPageHeader({ helperText, helperButtonLabel, ownIssueMessages, codeProps, titleProps, headerPopoverContainerProps, issuesPopoverProps, issueMessagesProps, helperButtonProps, helperPopoverProps, helperPopoverContentProps, className, ...otherProps }: FormPageHeaderProps): import("react").JSX.Element;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type AbsolutePath, Path } from "@ostack.tech/kform";
|
|
2
|
-
import { type
|
|
2
|
+
import { type ComponentProps, type ReactNode } from "react";
|
|
3
|
+
import { type FormPageObject } from "./FormPage.tsx";
|
|
3
4
|
/** Properties of the form page component. */
|
|
4
|
-
export interface FormPagesProps extends
|
|
5
|
+
export interface FormPagesProps extends ComponentProps<"div"> {
|
|
5
6
|
/** Base path for all declared form pages. */
|
|
6
7
|
path?: string | Path;
|
|
7
8
|
/**
|
|
@@ -9,9 +10,9 @@ export interface FormPagesProps extends ComponentPropsWithoutRef<"div"> {
|
|
|
9
10
|
* from the direct children `FormPage` components.
|
|
10
11
|
*/
|
|
11
12
|
pages?: FormPageObject[];
|
|
12
|
-
/** Default active form page. */
|
|
13
|
+
/** Default path of the active form page. */
|
|
13
14
|
defaultActivePage?: string | Path;
|
|
14
|
-
/** Controlled active form page. */
|
|
15
|
+
/** Controlled path of the active form page. */
|
|
15
16
|
activePage?: string | Path;
|
|
16
17
|
/**
|
|
17
18
|
* Function called whenever the active form page changes.
|
|
@@ -21,23 +22,43 @@ export interface FormPagesProps extends ComponentPropsWithoutRef<"div"> {
|
|
|
21
22
|
onActivePageChange?: (activePagePath: AbsolutePath | null) => void;
|
|
22
23
|
children?: ReactNode;
|
|
23
24
|
}
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The form pages component can be used to split parts of a form into separate
|
|
27
|
+
* pages, while providing means of navigating between them. Although not
|
|
28
|
+
* strictly mandatory, each page is typically represented by its own class, with
|
|
29
|
+
* its own schema and distinct path.
|
|
30
|
+
*
|
|
31
|
+
* It composes the following subcomponents:
|
|
32
|
+
*
|
|
33
|
+
* - `FormPagesNavigation`: Component used to navigate between form pages.
|
|
34
|
+
* - `FormPage`: The content of a single page of the form.
|
|
35
|
+
*
|
|
36
|
+
* Example usage:
|
|
37
|
+
*
|
|
38
|
+
* ```tsx
|
|
39
|
+
* import {
|
|
40
|
+
* FormPage,
|
|
41
|
+
* FormPages,
|
|
42
|
+
* FormPagesNavigation,
|
|
43
|
+
* } from "@ostack.tech/ui-kform";
|
|
44
|
+
*
|
|
45
|
+
* function TaxWithholdingPages() {
|
|
46
|
+
* return (
|
|
47
|
+
* <FormPages>
|
|
48
|
+
* <FormPagesNavigation />
|
|
49
|
+
* <FormPage path="/fillingInfo" title="Filing information" code="0">
|
|
50
|
+
* Filing information page…
|
|
51
|
+
* </FormPage>
|
|
52
|
+
* <FormPage
|
|
53
|
+
* path="/exemptions"
|
|
54
|
+
* title="Exemptions & declarations"
|
|
55
|
+
* code="1"
|
|
56
|
+
* >
|
|
57
|
+
* Exemptions & declarations page…
|
|
58
|
+
* </FormPage>
|
|
59
|
+
* </FormPages>
|
|
60
|
+
* );
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function FormPages({ path, pages, defaultActivePage, activePage, onActivePageChange, className, children, ref, ...otherProps }: FormPagesProps): import("react").JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AbsolutePath, type DisplayStatus, type Path, type SealedValidationIssue } from "@ostack.tech/kform";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
|
-
import type { FormPageObject
|
|
3
|
+
import type { FormPageObject } from "./FormPage.tsx";
|
|
4
|
+
import type { FormPagesProps } from "./FormPages.tsx";
|
|
4
5
|
/** Value of the form pages context. */
|
|
5
6
|
export type FormPagesContextValue = FormPagesStore;
|
|
6
7
|
/** Resolved form page object. */
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
import { type FormPagesSelectProps } from "./FormPagesSelect.tsx";
|
|
3
|
+
import { type FormPagesSidebarProps } from "./FormPagesSidebar.tsx";
|
|
4
4
|
/** Properties of the form pages navigation component. */
|
|
5
|
-
export interface FormPagesNavigationProps extends
|
|
5
|
+
export interface FormPagesNavigationProps extends ComponentProps<"nav"> {
|
|
6
6
|
/** Properties to pass to the sidebar component. */
|
|
7
|
-
sidebarProps?:
|
|
7
|
+
sidebarProps?: FormPagesSidebarProps;
|
|
8
8
|
/** Properties to pass to the select component. */
|
|
9
|
-
selectProps?:
|
|
9
|
+
selectProps?: FormPagesSelectProps;
|
|
10
10
|
}
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Component allowing navigation between form pages. Renders as a sidebar in
|
|
13
|
+
* large screens and as a select for smaller ones.
|
|
14
|
+
*/
|
|
15
|
+
export declare function FormPagesNavigation({ sidebarProps, selectProps, className, "aria-label": ariaLabel, ...otherProps }: FormPagesNavigationProps): import("react").JSX.Element;
|
|
@@ -3,4 +3,4 @@ import { type SelectSingleProps } from "@ostack.tech/ui";
|
|
|
3
3
|
export interface FormPagesSelectProps extends Omit<SelectSingleProps, "defaultValue" | "value" | "onValueChange" | "showClearButton"> {
|
|
4
4
|
}
|
|
5
5
|
/** Select component allowing the navigation between form pages. */
|
|
6
|
-
export declare
|
|
6
|
+
export declare function FormPagesSelect({ rootProps, containerProps, valueProps, arrowProps, popoverProps, commandMenuProps, className, ...otherProps }: FormPagesSelectProps): import("react").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ComponentProps } from "react";
|
|
2
2
|
/** Properties of the form pages sidebar component. */
|
|
3
|
-
export interface FormPagesSidebarProps extends
|
|
3
|
+
export interface FormPagesSidebarProps extends ComponentProps<"div"> {
|
|
4
4
|
}
|
|
5
5
|
/** Sidebar component allowing the navigation between form pages. */
|
|
6
|
-
export declare
|
|
6
|
+
export declare function FormPagesSidebar({ className, ref, ...otherProps }: FormPagesSidebarProps): import("react").JSX.Element;
|
|
@@ -1,9 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type
|
|
1
|
+
import type { Path } from "@ostack.tech/kform";
|
|
2
|
+
import { type ErrorBoundaryProps, type StepContentProps } from "@ostack.tech/ui";
|
|
3
|
+
import { type ReactNode } from "react";
|
|
3
4
|
import type { IssueMessagesByCode } from "../IssueMessages";
|
|
4
|
-
|
|
5
|
+
/** Object representation of a form step. */
|
|
6
|
+
export interface FormStepObject<T = any> {
|
|
7
|
+
/** Form step path. */
|
|
8
|
+
path?: string | Path;
|
|
9
|
+
/** Form step's title. */
|
|
10
|
+
title: ReactNode | ((value: T) => ReactNode);
|
|
11
|
+
/**
|
|
12
|
+
* Title of the form step as a string to display in the document's title.
|
|
13
|
+
*
|
|
14
|
+
* Defaults to `title` when it is a string. A warning is printed if `title` is
|
|
15
|
+
* not a string and `documentTitle` is not provided.
|
|
16
|
+
*/
|
|
17
|
+
documentTitle?: string | null | ((value: T) => string | null);
|
|
18
|
+
/** Label of the form step in the issues panel. Uses the `title` by default. */
|
|
19
|
+
issuesPanelLabel?: ReactNode | ((value: T) => ReactNode);
|
|
20
|
+
}
|
|
5
21
|
/** Properties of the form step component. */
|
|
6
|
-
export interface FormStepProps extends FormStepObject, Omit<
|
|
22
|
+
export interface FormStepProps extends FormStepObject, Omit<StepContentProps, "index" | "title"> {
|
|
7
23
|
/** Sets the step as disabled. */
|
|
8
24
|
disabled?: boolean;
|
|
9
25
|
/** Sets the step as read-only. */
|
|
@@ -37,9 +53,9 @@ export interface FormStepProps extends FormStepObject, Omit<ComponentPropsWithou
|
|
|
37
53
|
*/
|
|
38
54
|
issueMessages?: Record<string, IssueMessagesByCode>;
|
|
39
55
|
/** Properties to pass to the `ErrorBoundary` component. */
|
|
40
|
-
errorBoundaryProps?:
|
|
56
|
+
errorBoundaryProps?: ErrorBoundaryProps;
|
|
41
57
|
}
|
|
42
58
|
/** Single form step. */
|
|
43
|
-
export declare
|
|
59
|
+
export declare function FormStep({ path, title: _title, documentTitle: _documentTitle, issuesPanelLabel: _issuesPanelLabel, disabled, readOnly, issueMessages, errorBoundaryProps, className, children, ...otherProps }: FormStepProps): false | import("react").JSX.Element;
|
|
44
60
|
/** @deprecated Use `FormStep` instead. */
|
|
45
|
-
export declare const FormStepContent:
|
|
61
|
+
export declare const FormStepContent: typeof FormStep;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type ComponentPropsWithoutRef } from "react";
|
|
1
|
+
import { type StepListProps } from "@ostack.tech/ui";
|
|
3
2
|
/** Properties of the form steps sidebar component. */
|
|
4
|
-
export interface FormStepListProps extends
|
|
3
|
+
export interface FormStepListProps extends StepListProps {
|
|
5
4
|
}
|
|
6
5
|
/** Component displaying all form steps in a list. */
|
|
7
|
-
export declare
|
|
6
|
+
export declare function FormStepList({ className, ...otherProps }: FormStepListProps): import("react").JSX.Element;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type AbsolutePath, Path, type SealedLocatedValidationIssue } from "@ostack.tech/kform";
|
|
2
|
-
import {
|
|
3
|
-
import { type
|
|
2
|
+
import { type StepperProps } from "@ostack.tech/ui";
|
|
3
|
+
import { type FormStepObject } from "./FormStep.tsx";
|
|
4
4
|
/** Properties of the form stepper component. */
|
|
5
|
-
export interface FormStepperProps extends Omit<
|
|
5
|
+
export interface FormStepperProps extends Omit<StepperProps, "defaultActiveStep" | "activeStep" | "onActiveStepChange"> {
|
|
6
6
|
/** Base path for all declared form steps. */
|
|
7
7
|
path?: string | Path;
|
|
8
8
|
/** List of all form steps. */
|
|
@@ -51,21 +51,52 @@ export interface FormStepperProps extends Omit<ComponentPropsWithoutRef<typeof S
|
|
|
51
51
|
*/
|
|
52
52
|
preventFocusOnError?: boolean;
|
|
53
53
|
}
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
54
|
+
/**
|
|
55
|
+
* The form stepper component can be used to split parts of a form into separate
|
|
56
|
+
* steps. It is built on top of the
|
|
57
|
+
* [`Stepper`](/docs/ostack-ui-disclosure-stepper--docs) component. Although not
|
|
58
|
+
* strictly mandatory, each page is typically represented by its own class, with
|
|
59
|
+
* its own schema and distinct path.
|
|
60
|
+
*
|
|
61
|
+
* It composes the following subcomponents:
|
|
62
|
+
*
|
|
63
|
+
* - `FormStepList`: Component used to navigate between form pages.
|
|
64
|
+
* - `FormStep`: The content of a single step of the form.
|
|
65
|
+
* - `FormStepperPreviousTrigger`: Trigger to navigate to the previous step.
|
|
66
|
+
* - `FormStepperNextTrigger`: Trigger to navigate to the next step.
|
|
67
|
+
* - `FormStepperFinishTrigger`: Trigger to finish the form stepper.
|
|
68
|
+
*
|
|
69
|
+
* Example usage:
|
|
70
|
+
*
|
|
71
|
+
* ```tsx
|
|
72
|
+
* import {
|
|
73
|
+
* FormStep,
|
|
74
|
+
* FormStepList,
|
|
75
|
+
* FormStepper,
|
|
76
|
+
* FormStepperFinishTrigger,
|
|
77
|
+
* FormStepperNextTrigger,
|
|
78
|
+
* FormStepperPreviousTrigger,
|
|
79
|
+
* } from "@ostack.tech/ui-kform";
|
|
80
|
+
*
|
|
81
|
+
* function AccountSetupStepper() {
|
|
82
|
+
* return (
|
|
83
|
+
* <FormStepper>
|
|
84
|
+
* <FormStepList />
|
|
85
|
+
* <FormStep path="/profile" title="Personal profile">
|
|
86
|
+
* Provide identification…
|
|
87
|
+
* </FormStep>
|
|
88
|
+
* <FormStep path="/preferences" title="Preferences">
|
|
89
|
+
* Select preferences…
|
|
90
|
+
* </FormStep>
|
|
91
|
+
* <FormStep path="/terms" title="Terms & authorization">
|
|
92
|
+
* Accept terms…
|
|
93
|
+
* </FormStep>
|
|
94
|
+
* <FormStepperPreviousTrigger />
|
|
95
|
+
* <FormStepperNextTrigger />
|
|
96
|
+
* <FormStepperFinishTrigger />
|
|
97
|
+
* </FormStepper>
|
|
98
|
+
* );
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare function FormStepper({ path, steps, defaultActiveStep, activeStep, onActiveStepChange, onStepValidation, skipStepValidationOnForwardNavigation, allowForwardNavigationOnError, preventFocusOnError, className, children, ...otherProps }: FormStepperProps): import("react").JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type AbsolutePath, type DisplayStatus, type FormManager } from "@ostack.tech/kform";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
|
-
import type { FormStepObject
|
|
3
|
+
import type { FormStepObject } from "./FormStep.tsx";
|
|
4
|
+
import type { FormStepperProps } from "./FormStepper.tsx";
|
|
4
5
|
/** Value of the form stepper context. */
|
|
5
6
|
export type FormStepperContextValue = FormStepperStore;
|
|
6
7
|
/** Resolved form step object. */
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { StepperFinishTrigger, type StepperFinishTriggerProps } from "@ostack.tech/ui";
|
|
2
|
+
/** Properties of the form stepper finish trigger component. */
|
|
3
|
+
export type FormStepperFinishTriggerProps = StepperFinishTriggerProps;
|
|
1
4
|
/** Trigger used to conclude the form stepper. */
|
|
2
|
-
export declare const FormStepperFinishTrigger:
|
|
5
|
+
export declare const FormStepperFinishTrigger: typeof StepperFinishTrigger;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { StepperNextTrigger, type StepperNextTriggerProps } from "@ostack.tech/ui";
|
|
2
|
+
/** Properties of the form stepper next trigger component. */
|
|
3
|
+
export type FormStepperNextTriggerProps = StepperNextTriggerProps;
|
|
1
4
|
/** Trigger used to go to the next step of the form stepper. */
|
|
2
|
-
export declare const FormStepperNextTrigger:
|
|
5
|
+
export declare const FormStepperNextTrigger: typeof StepperNextTrigger;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { StepperPreviousTrigger, type StepperPreviousTriggerProps } from "@ostack.tech/ui";
|
|
2
|
+
/** Properties of the form stepper previous trigger component. */
|
|
3
|
+
export type FormStepperPreviousTriggerProps = StepperPreviousTriggerProps;
|
|
1
4
|
/** Trigger used to go to the previous step of the form stepper. */
|
|
2
|
-
export declare const FormStepperPreviousTrigger:
|
|
5
|
+
export declare const FormStepperPreviousTrigger: typeof StepperPreviousTrigger;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import { StepperState } from "@ostack.tech/ui";
|
|
1
|
+
import { StepperState, type StepperStateProps } from "@ostack.tech/ui";
|
|
2
|
+
/** Properties of the form stepper state component. */
|
|
3
|
+
export type FormStepperStateProps = StepperStateProps;
|
|
2
4
|
/** Component used to access the state of the form stepper and act on its API. */
|
|
3
5
|
export declare const FormStepperState: typeof StepperState;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AbsolutePath, Schema, SealedValidationIssue } from "@ostack.tech/kform";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ComponentProps } from "react";
|
|
3
3
|
import type { IssueMessagesProps } from "../IssueMessages";
|
|
4
4
|
/** Default data key where to check for an issue message. */
|
|
5
5
|
export declare const DEFAULT_ISSUE_MESSAGE_DATA_KEY = "message";
|
|
@@ -10,7 +10,7 @@ export interface IssueMessageProps extends Pick<IssueMessagesProps, "visuallyHid
|
|
|
10
10
|
path: AbsolutePath;
|
|
11
11
|
issue: SealedValidationIssue;
|
|
12
12
|
schema: Schema;
|
|
13
|
-
issueCodeProps?:
|
|
13
|
+
issueCodeProps?: ComponentProps<"span">;
|
|
14
14
|
}
|
|
15
15
|
/** Single issue message within the issue messages or issues panel components. */
|
|
16
16
|
export declare function IssueMessage({ path, issue, schema, displayIssueCode, messageDataKey, visuallyHiddenErrorCodePrefix, visuallyHiddenWarningCodePrefix, unknownErrorMessage, unknownWarningMessage, issueCodeProps, }: IssueMessageProps): import("react").JSX.Element;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { AbsolutePath, Path, Schema, SealedValidationIssue, ValidationIssueData } from "@ostack.tech/kform";
|
|
2
|
-
import {
|
|
3
|
-
import { type
|
|
2
|
+
import { type FeedbackListProps } from "@ostack.tech/ui";
|
|
3
|
+
import { type ReactNode } from "react";
|
|
4
4
|
/** Value of an issue message. */
|
|
5
5
|
export type IssueMessageValue = ReactNode | ((issueData: ValidationIssueData, schema: Schema, path: AbsolutePath) => ReactNode);
|
|
6
6
|
/** Mapping of issue message codes to their respective message. */
|
|
7
7
|
export type IssueMessagesByCode = Record<string, IssueMessageValue>;
|
|
8
8
|
/** Properties of the issue messages component. */
|
|
9
|
-
export interface IssueMessagesProps extends
|
|
9
|
+
export interface IssueMessagesProps extends FeedbackListProps {
|
|
10
10
|
/** Path of the value for which to show issues. */
|
|
11
11
|
path?: string | Path;
|
|
12
12
|
/**
|
|
@@ -79,4 +79,4 @@ export interface IssueMessagesProps extends ComponentPropsWithoutRef<typeof Feed
|
|
|
79
79
|
* If `path` contains an issue without an associated issue message, a generic
|
|
80
80
|
* message is displayed together with a console warning.
|
|
81
81
|
*/
|
|
82
|
-
export declare
|
|
82
|
+
export declare function IssueMessages({ path, issues, messages, displayIssueCodes, messagesDataKey, visuallyHiddenErrorCodePrefix, visuallyHiddenWarningCodePrefix, unknownErrorMessage, unknownWarningMessage, unwrapped, ...otherProps }: IssueMessagesProps): import("react").JSX.Element;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { IssueMessages } from "../IssueMessages";
|
|
1
|
+
import { type AlertProps } from "@ostack.tech/ui";
|
|
2
|
+
import type { IssueMessagesProps } from "../IssueMessages";
|
|
4
3
|
/** Properties of the issues alert component. */
|
|
5
|
-
export interface IssuesAlertProps extends Omit<
|
|
4
|
+
export interface IssuesAlertProps extends Omit<AlertProps, "open" | "defaultOpen" | "severity" | "children">, Pick<IssueMessagesProps, "path" | "issues" | "messages" | "displayIssueCodes" | "messagesDataKey" | "visuallyHiddenErrorCodePrefix" | "visuallyHiddenWarningCodePrefix" | "unknownErrorMessage" | "unknownWarningMessage"> {
|
|
6
5
|
}
|
|
7
6
|
/** Component used to display an issue alert. */
|
|
8
|
-
export declare
|
|
7
|
+
export declare function IssuesAlert({ variant, path, issues, messages, displayIssueCodes, messagesDataKey, visuallyHiddenErrorCodePrefix, visuallyHiddenWarningCodePrefix, unknownErrorMessage, unknownWarningMessage, className, ...otherProps }: IssuesAlertProps): import("react").JSX.Element;
|