@ostack.tech/ui-kform 1.2.0-beta.0 → 1.2.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.
Files changed (97) hide show
  1. package/dist/chunks/{en-D4xMcf6Q.js → en-BHlLXSzh.js} +4 -16
  2. package/dist/chunks/en-BHlLXSzh.js.map +1 -0
  3. package/dist/locales/en-GB.js +1 -1
  4. package/dist/locales/en-US.js +1 -1
  5. package/dist/locales/fr-FR.js +5 -17
  6. package/dist/locales/fr-FR.js.map +1 -1
  7. package/dist/locales/pt-PT.js +3 -15
  8. package/dist/locales/pt-PT.js.map +1 -1
  9. package/dist/ostack-ui-kform.js +15299 -4434
  10. package/dist/ostack-ui-kform.js.map +1 -1
  11. package/package.json +16 -14
  12. package/scss/components/Annexes/_Annexes-variables.scss +4 -9
  13. package/scss/components/Annexes/_Annexes.scss +9 -15
  14. package/scss/components/FormApp/_FormApp.scss +1 -4
  15. package/scss/components/FormPages/_FormPages-variables.scss +8 -27
  16. package/scss/components/FormPages/_FormPages.scss +11 -33
  17. package/scss/components/IssuesPanel/_IssuesPanel-variables.scss +3 -8
  18. package/scss/components/IssuesPanel/_IssuesPanel.scss +3 -8
  19. package/types/components/Annexes/Annex.d.ts +26 -37
  20. package/types/components/Annexes/Annexes.d.ts +8 -10
  21. package/types/components/Annexes/AnnexesContext.d.ts +1 -1
  22. package/types/components/Annexes/AnnexesManager.d.ts +8 -12
  23. package/types/components/CheckboxControl/CheckboxControl.d.ts +9 -19
  24. package/types/components/CheckboxGroupControl/CheckboxGroupControl.d.ts +14 -31
  25. package/types/components/CheckboxGroupControl/CheckboxGroupControlItem.d.ts +1 -2
  26. package/types/components/ControlField/ControlField.d.ts +6 -6
  27. package/types/components/DateControl/DateControl.d.ts +13 -18
  28. package/types/components/DateRangeControl/DateRangeControl.d.ts +16 -22
  29. package/types/components/DebugInfo/DebugInfo.d.ts +3 -4
  30. package/types/components/DebugInfo/DebugInfoControlAddonTrigger.d.ts +1 -1
  31. package/types/components/FileControl/FileControl.d.ts +16 -22
  32. package/types/components/FileControl/FileControlDownloadAddon.d.ts +2 -2
  33. package/types/components/FileControl/FileControlViewAddon.d.ts +1 -1
  34. package/types/components/FormApp/FormApp.d.ts +25 -34
  35. package/types/components/FormApp/FormAppContext.d.ts +20 -44
  36. package/types/components/FormApp/FormAppIssueMessages.d.ts +6 -8
  37. package/types/components/FormApp/FormAppStatus.d.ts +1 -1
  38. package/types/components/FormPages/FormPage.d.ts +12 -20
  39. package/types/components/FormPages/FormPages.d.ts +8 -17
  40. package/types/components/FormPages/FormPagesContext.d.ts +1 -1
  41. package/types/components/FormPages/FormPagesNavigation.d.ts +3 -3
  42. package/types/components/FormStepper/FormStep.d.ts +8 -9
  43. package/types/components/FormStepper/FormStepper.d.ts +14 -18
  44. package/types/components/FormStepper/FormStepperContext.d.ts +1 -1
  45. package/types/components/IssueMessage/IssueMessage.d.ts +1 -1
  46. package/types/components/IssueMessages/IssueMessages.d.ts +17 -25
  47. package/types/components/IssuesPanel/IssuesPanel.d.ts +11 -15
  48. package/types/components/IssuesPanel/IssuesPanelControls.d.ts +1 -1
  49. package/types/components/IssuesPopover/IssuesPopover.d.ts +4 -4
  50. package/types/components/LoadAction/LoadAction.d.ts +7 -10
  51. package/types/components/NumericControl/NumericControl.d.ts +15 -21
  52. package/types/components/PathLink/PathLink.d.ts +4 -5
  53. package/types/components/PrintAction/PrintAction.d.ts +7 -11
  54. package/types/components/RadioGroupControl/RadioGroupControl.d.ts +12 -21
  55. package/types/components/RadioGroupControl/RadioGroupControlItem.d.ts +2 -2
  56. package/types/components/ResetOnChange/ResetOnChange.d.ts +6 -14
  57. package/types/components/ResetOnChange/index.d.ts +1 -1
  58. package/types/components/ResetOnChange/useResetOnChange.d.ts +22 -32
  59. package/types/components/SaveAction/SaveAction.d.ts +22 -30
  60. package/types/components/SelectControl/SelectControl.d.ts +11 -21
  61. package/types/components/SelectControl/SelectControlItem.d.ts +2 -2
  62. package/types/components/SelectControl/SelectControlItemGroup.d.ts +2 -3
  63. package/types/components/SelectMultipleControl/SelectMultipleControl.d.ts +17 -35
  64. package/types/components/SelectMultipleControl/SelectMultipleControlItem.d.ts +1 -2
  65. package/types/components/SelectMultipleControl/SelectMultipleControlItemGroup.d.ts +2 -2
  66. package/types/components/SubmitAction/SubmitAction.d.ts +19 -33
  67. package/types/components/TableControl/TableControl.d.ts +27 -41
  68. package/types/components/TableControl/TableControlActionsColumn.d.ts +3 -5
  69. package/types/components/TableControl/TableControlAddRowTrigger.d.ts +7 -13
  70. package/types/components/TableControl/TableControlApi.d.ts +4 -4
  71. package/types/components/TableControl/TableControlColumn.d.ts +5 -8
  72. package/types/components/TableControl/TableControlColumnFns.d.ts +21 -31
  73. package/types/components/TableControl/TableControlColumnGroup.d.ts +3 -6
  74. package/types/components/TableControl/TableControlColumns.d.ts +4 -4
  75. package/types/components/TableControl/TableControlContent.d.ts +1 -1
  76. package/types/components/TableControl/TableControlIndexColumn.d.ts +2 -2
  77. package/types/components/TableControl/TableControlRemoveRowTrigger.d.ts +9 -16
  78. package/types/components/TextControl/TextControl.d.ts +7 -13
  79. package/types/components/UnknownValue/UnknownValue.d.ts +1 -1
  80. package/types/components/ValidateAction/ValidateAction.d.ts +7 -10
  81. package/types/providers/ActivePathProvider/ActivePathProvider.d.ts +4 -7
  82. package/types/providers/LocalizationProvider/LocalizationProvider.d.ts +1 -4
  83. package/types/providers/LocalizationProvider/useLocale.d.ts +1 -4
  84. package/types/providers/PrefixSuffixProvider/PrefixSuffixProvider.d.ts +1 -1
  85. package/types/providers/PrefixSuffixProvider/defaultPrefixSuffix.d.ts +3 -3
  86. package/types/providers/PrefixSuffixProvider/usePrefix.d.ts +1 -4
  87. package/types/utils/mostSpecificPath.d.ts +4 -6
  88. package/types/utils/pathSpecificity.d.ts +7 -8
  89. package/types/utils/selectionTransformations.d.ts +2 -8
  90. package/types/utils/useControlAutofocus.d.ts +6 -8
  91. package/types/utils/useControlIssues.d.ts +4 -4
  92. package/types/utils/useFormLoader.d.ts +24 -31
  93. package/types/utils/useFormSaver.d.ts +29 -34
  94. package/types/utils/useFormValidator.d.ts +13 -20
  95. package/types/utils/useRegisterControl.d.ts +1 -1
  96. package/types/utils/useTemporalStringTransformer.d.ts +4 -10
  97. package/dist/chunks/en-D4xMcf6Q.js.map +0 -1
@@ -8,13 +8,12 @@ export interface TableControlRemoveRowTriggerPropsBase extends Omit<PrefixedConf
8
8
  /**
9
9
  * Whether to show a confirmation message when removing a row.
10
10
  *
11
- * Defaults to `false` unless `confirmDialogMessage` is set, in which case
12
- * defaults to `true`.
11
+ * Defaults to `false` unless `confirmDialogMessage` is set, in which case defaults to `true`.
13
12
  */
14
13
  showConfirmation?: boolean;
15
14
  /**
16
- * Function called after confirmation that the row is to be removed (this
17
- * function is called even if `showConfirmation` is `false`).
15
+ * Function called after confirmation that the row is to be removed (this function is called even
16
+ * if `showConfirmation` is `false`).
18
17
  */
19
18
  onConfirmRowRemoval?: () => void;
20
19
  /** Function called after the row has been removed. */
@@ -32,11 +31,8 @@ export interface TableControlRemoveRowTriggerPropsBase extends Omit<PrefixedConf
32
31
  */
33
32
  showWhenReadOnly?: boolean;
34
33
  }
35
- /**
36
- * Base properties of the table control remove row trigger component when
37
- * rendered without children.
38
- */
39
- export interface TableControlRemoveRowTriggerChildlessProps extends TableControlRemoveRowTriggerPropsBase, Omit<Partial<ActionButtonProps>, "asChild" | "children"> {
34
+ /** Base properties of the table control remove row trigger component when rendered without children. */
35
+ export interface TableControlRemoveRowTriggerChildlessProps extends TableControlRemoveRowTriggerPropsBase, Omit<Partial<ActionButtonProps>, "asLink" | "asChild" | "children"> {
40
36
  /**
41
37
  * Label of the icon button.
42
38
  *
@@ -45,17 +41,14 @@ export interface TableControlRemoveRowTriggerChildlessProps extends TableControl
45
41
  defaultButtonLabel?: ReactNode;
46
42
  children?: never;
47
43
  }
48
- /**
49
- * Base properties of the table control remove row trigger component when
50
- * rendered with children.
51
- */
44
+ /** Base properties of the table control remove row trigger component when rendered with children. */
52
45
  export interface TableControlRemoveRowTriggerChildrenProps extends TableControlRemoveRowTriggerPropsBase, Partial<ComponentProps<"button">> {
53
46
  children: ReactNode;
54
47
  }
55
48
  /**
56
49
  * Trigger used to remove a row of a table controlled by a table control.
57
50
  *
58
- * By default, it renders an icon button with label `defaultButtonLabel`,
59
- * however, this can be overriden by providing `children`.
51
+ * By default, it renders an icon button with label `defaultButtonLabel`, however, this can be
52
+ * overriden by providing `children`.
60
53
  */
61
- export declare function TableControlRemoveRowTrigger({ onConfirmRowRemoval, onRowRemoved, confirmDialogMessage, confirmDialogTitle, confirmDialogOkText, confirmDialogCancelText, showConfirmation, showWhenReadOnly, disabled, onClick, children, ...otherProps }: TableControlRemoveRowTriggerProps): import("react").JSX.Element | null;
54
+ export declare function TableControlRemoveRowTrigger({ onConfirmRowRemoval, onRowRemoved, confirmDialogMessage: confirmDialogMessageProp, confirmDialogTitle: confirmDialogTitleProp, confirmDialogOkText: confirmDialogOkTextProp, confirmDialogCancelText: confirmDialogCancelTextProp, showConfirmation: showConfirmationProp, showWhenReadOnly, disabled, onClick, children, ...otherProps }: TableControlRemoveRowTriggerProps): import("react").JSX.Element | null;
@@ -16,8 +16,7 @@ export type TextControlPropsBase<T extends string | null = string | null> = Omit
16
16
  */
17
17
  issueMessages?: IssueMessagesByCode;
18
18
  /**
19
- * Label to use in the issues panel when displaying issues associated with
20
- * this field.
19
+ * Label to use in the issues panel when displaying issues associated with this field.
21
20
  *
22
21
  * This label has priority over the field's `Label`.
23
22
  */
@@ -29,22 +28,18 @@ export type TextControlPropsBase<T extends string | null = string | null> = Omit
29
28
  */
30
29
  displayIssues?: boolean;
31
30
  /**
32
- * Whether to prevent the auto-focusing behaviour that causes this control
33
- * to be focused when the form app's `focus` is called with this control's
34
- * path.
31
+ * Whether to prevent the auto-focusing behaviour that causes this control to be focused when the
32
+ * form app's `focus` is called with this control's path.
35
33
  *
36
- * Preventing this behaviour is useful when multiple controls for the same
37
- * path are rendered at once, and only one of them should be focused.
34
+ * Preventing this behaviour is useful when multiple controls for the same path are rendered at
35
+ * once, and only one of them should be focused.
38
36
  *
39
37
  * @default false
40
38
  */
41
39
  preventAutoFocus?: boolean;
42
40
  /** Whether to render a multiline text control. */
43
41
  multiline?: boolean;
44
- /**
45
- * Whether to show debug information. This property has no effect in
46
- * production builds.
47
- */
42
+ /** Whether to show debug information. This property has no effect in production builds. */
48
43
  debug?: boolean;
49
44
  /** Reference to the control's API. */
50
45
  apiRef?: Ref<InputController<T, string, ComponentRef<typeof Input | typeof TextArea>> | undefined>;
@@ -67,8 +62,7 @@ export type TextControlTextAreaProps<T extends string | null = string | null> =
67
62
  * [`StringSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-string-schema/index.html).
68
63
  * It supports both single and multiline text editing, being built on top of the
69
64
  * [`Input`](/docs/ostack-ui-forms-input--docs) (for single-line) or
70
- * [`TextArea`](/docs/ostack-ui-forms-text-area--docs) (for multiline)
71
- * components.
65
+ * [`TextArea`](/docs/ostack-ui-forms-text-area--docs) (for multiline) components.
72
66
  *
73
67
  * The following built-in KForm validations affect this control:
74
68
  *
@@ -6,4 +6,4 @@ export interface UnknownValueProps<T = unknown> {
6
6
  label?: ReactNode;
7
7
  }
8
8
  /** Representation of an unknown value. */
9
- export declare function UnknownValue<T = unknown>({ value, label, }: UnknownValueProps<T>): import("react").JSX.Element;
9
+ export declare function UnknownValue<T = unknown>({ value, label: labelProp }: UnknownValueProps<T>): import("react").JSX.Element;
@@ -5,16 +5,13 @@ export declare const DEFAULT_VALIDATE_KEYBINDS = "Alt+Shift+V";
5
5
  /** Properties of the validate action. */
6
6
  export interface ValidateActionProps extends UseFormValidatorOptions, Partial<ActionButtonProps> {
7
7
  /**
8
- * Keybinds for triggering the action. Set to `null` to disable the keyboard
9
- * shortcut.
8
+ * Keybinds for triggering the action. Set to `null` to disable the keyboard shortcut.
10
9
  *
11
- * Keyboard handling is built on top of the
12
- * [`tinykeys`](https://jamiebuilds.github.io/tinykeys) library. For
13
- * information on keybinding syntax, read the [`tinykeys`
10
+ * Keyboard handling is built on top of the [`tinykeys`](https://jamiebuilds.github.io/tinykeys)
11
+ * library. For information on keybinding syntax, read the [`tinykeys`
14
12
  * documentation](https://github.com/jamiebuilds/tinykeys).
15
13
  *
16
- * Defaults to the keybinds defined by the current locale or to
17
- * `DEFAULT_VALIDATE_KEYBINDS`.
14
+ * Defaults to the keybinds defined by the current locale or to `DEFAULT_VALIDATE_KEYBINDS`.
18
15
  */
19
16
  keybinds?: string | string[] | null;
20
17
  /**
@@ -28,8 +25,8 @@ export interface ValidateActionProps extends UseFormValidatorOptions, Partial<Ac
28
25
  * Form action used to validate the form. Built on top of the [`Button`
29
26
  * component](/docs/ostack-ui-forms-button--docs) and `useFormValidator` hook.
30
27
  *
31
- * If the form contains an `IssuesPanel` component, it is shown as a result of
32
- * triggering the action.
28
+ * If the form contains an `IssuesPanel` component, it is shown as a result of triggering the
29
+ * action.
33
30
  *
34
31
  * Example usage:
35
32
  *
@@ -41,4 +38,4 @@ export interface ValidateActionProps extends UseFormValidatorOptions, Partial<Ac
41
38
  * }
42
39
  * ```
43
40
  */
44
- export declare function ValidateAction({ onBeforeValidate, onAfterValidate, label, keybinds, showWhenReadOnly, loading, disabled, onClick, ...otherProps }: ValidateActionProps): false | import("react").JSX.Element | undefined;
41
+ export declare function ValidateAction({ onBeforeValidate, onAfterValidate, label: labelProp, keybinds: keybindsProp, showWhenReadOnly, loading, disabled, onClick, ...otherProps }: ValidateActionProps): false | import("react").JSX.Element | undefined;
@@ -1,9 +1,6 @@
1
1
  import { AbsolutePath, type Path } from "@ostack.tech/kform";
2
- import { type ReactNode } from "react";
3
- /**
4
- * Navigation options to use when controlling the active path via the browser's
5
- * URL.
6
- */
2
+ import type { ReactNode } from "react";
3
+ /** Navigation options to use when controlling the active path via the browser's URL. */
7
4
  export interface OnActivePathChangeNavigationOptions {
8
5
  /** Whether to replace the current history entry. */
9
6
  replace: boolean;
@@ -18,8 +15,8 @@ export interface ActivePathProviderProps {
18
15
  * Callback called whenever the active path is changed.
19
16
  *
20
17
  * @param activePath New active path.
21
- * @param options Navigation options to use when controlling the active path
22
- * via the browser's URL.
18
+ * @param options Navigation options to use when controlling the active path via the browser's
19
+ * URL.
23
20
  */
24
21
  onActivePathChange?: (activePath: AbsolutePath, options: OnActivePathChangeNavigationOptions) => void;
25
22
  children?: ReactNode;
@@ -14,8 +14,5 @@ export interface LocalizationProviderProps {
14
14
  onLocaleChange?: (locale: LocalizationObject) => void;
15
15
  children: ReactNode;
16
16
  }
17
- /**
18
- * Localisation provider (also sets the `@ostack.tech/ui` localisation
19
- * provider).
20
- */
17
+ /** Localisation provider (also sets the `@ostack.tech/ui` localisation provider). */
21
18
  export declare function LocalizationProvider({ defaultLocale, locale: controlledLocale, onLocaleChange, children, }: LocalizationProviderProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
@@ -1,6 +1,3 @@
1
1
  import type { LocalizationObject } from "./LocalizationObject.ts";
2
2
  /** Hook used to get and set the current locale. */
3
- export declare function useLocale(): [
4
- LocalizationObject,
5
- (locale: LocalizationObject) => void
6
- ];
3
+ export declare function useLocale(): [LocalizationObject, (locale: LocalizationObject) => void];
@@ -6,4 +6,4 @@ export interface PrefixSuffixProviderProps {
6
6
  children: ReactNode;
7
7
  }
8
8
  /** Prefix-suffix provider. */
9
- export declare function PrefixSuffixProvider({ prefixSuffix, children, }: PrefixSuffixProviderProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
9
+ export declare function PrefixSuffixProvider({ prefixSuffix, children }: PrefixSuffixProviderProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
@@ -3,9 +3,9 @@ export declare const defaultPrefixSuffixStore: import("zustand").StoreApi<{
3
3
  defaultPrefixSuffix: string;
4
4
  }>;
5
5
  /**
6
- * Function used to set the default library's prefix-suffix. The default library
7
- * prefix-suffix can be overridden by providing a `prefixSuffix` property to the
8
- * `PrefixSuffixProvider` or `FormApp` components.
6
+ * Function used to set the default library's prefix-suffix. The default library prefix-suffix can
7
+ * be overridden by providing a `prefixSuffix` property to the `PrefixSuffixProvider` or `FormApp`
8
+ * components.
9
9
  *
10
10
  * @param defaultPrefixSuffix Prefix-suffix to set as the library's default.
11
11
  */
@@ -1,6 +1,3 @@
1
1
  import { type PrefixFn } from "@ostack.tech/ui";
2
- /**
3
- * Hook which returns a function which can be used to prefix a string with the
4
- * current prefix.
5
- */
2
+ /** Hook which returns a function which can be used to prefix a string with the current prefix. */
6
3
  export declare function usePrefix(): PrefixFn;
@@ -1,13 +1,11 @@
1
1
  import { AbsolutePath } from "@ostack.tech/kform";
2
2
  /**
3
- * Function which selects the most "specific" path from a list of paths, given a
4
- * path to match. `currentActivePath` contains the path that is currently
5
- * active.
3
+ * Function which selects the most "specific" path from a list of paths, given a path to match.
4
+ * `currentActivePath` contains the path that is currently active.
6
5
  *
7
6
  * The list of paths may contain paths with a single trailing wildcard.
8
7
  *
9
- * This function is used by the `Annexes`, `FormPages`, and `FormStepper`
10
- * components to select the next path that should be focused when the focused
11
- * path changes.
8
+ * This function is used by the `Annexes`, `FormPages`, and `FormStepper` components to select the
9
+ * next path that should be focused when the focused path changes.
12
10
  */
13
11
  export declare function mostSpecificPath(toMatch: AbsolutePath | null, paths: AbsolutePath[], currentActivePath: AbsolutePath | null): AbsolutePath | null;
@@ -1,15 +1,14 @@
1
1
  import { type AbsolutePath } from "@ostack.tech/kform";
2
2
  /**
3
- * Given two paths, returns a number > 0 if the first path is more specific than
4
- * the second, a number < 0 if the first path is less specific than the second,
5
- * or 0 if both paths have the same specificity.
3
+ * Given two paths, returns a number > 0 if the first path is more specific than the second, a
4
+ * number < 0 if the first path is less specific than the second, or 0 if both paths have the same
5
+ * specificity.
6
6
  *
7
- * Specificity is not incredibly well specified (and may change over time if a
8
- * need arises), but the idea is that wildcards make paths less specific, so
9
- * `/a/∗` is less specific than `/a/b`, and `/∗∗` is the least specific path.
7
+ * Specificity is not incredibly well specified (and may change over time if a need arises), but the
8
+ * idea is that wildcards make paths less specific, so `/a/∗` is less specific than `/a/b`, and
9
+ * `/∗∗` is the least specific path.
10
10
  *
11
- * Both `/a` and `/a/b/c` have the same specificity since both paths uniquely
12
- * identify a resource.
11
+ * Both `/a` and `/a/b/c` have the same specificity since both paths uniquely identify a resource.
13
12
  *
14
13
  * @param path1 First path to compare.
15
14
  * @param path2 Second path to compare.
@@ -6,17 +6,11 @@ import type { SelectControlItemGroupObject, SelectControlItemObject } from "../c
6
6
  export declare function isUnknownValue<T>(value: T | null | undefined, options: {
7
7
  value: T;
8
8
  }[]): boolean;
9
- /**
10
- * Parses a selection value from the (string) index of an option (or empty
11
- * string).
12
- */
9
+ /** Parses a selection value from the (string) index of an option (or empty string). */
13
10
  export declare function parseSelectionValueFromOptionIndex<T>(formattedValue: string, schema: Schema<T>, options: {
14
11
  value: T;
15
12
  }[], unknownValues: readonly T[]): T;
16
- /**
17
- * Formats a selection value as the (string) index of an option (or empty
18
- * string).
19
- */
13
+ /** Formats a selection value as the (string) index of an option (or empty string). */
20
14
  export declare function formatSelectionValueAsOptionIndex<T>(value: T | undefined, options: {
21
15
  value: T;
22
16
  }[]): string;
@@ -1,4 +1,4 @@
1
- import type { Controller } from "@ostack.tech/kform-react";
1
+ import { type Controller } from "@ostack.tech/kform-react";
2
2
  import { type RefObject } from "react";
3
3
  /**
4
4
  * Function used to scroll an element into view.
@@ -8,15 +8,14 @@ import { type RefObject } from "react";
8
8
  */
9
9
  export type ScrollIntoViewFn = (el: HTMLElement, options?: ScrollIntoViewOptions) => void;
10
10
  /**
11
- * Hook used to autofocus a control when the active path changes, given the
12
- * control's path.
11
+ * Hook used to autofocus a control when the active path changes, given the control's path.
13
12
  *
14
13
  * @param controller Control's controller.
15
14
  * @param enabled Whether to enable the auto-focus behaviour.
16
15
  * @returns Reference that should be set on the focusable element of the
17
- * control.
16
+ * control.
18
17
  */
19
- export declare function useControlAutofocus<T = unknown, TElem extends HTMLElement = HTMLElement>({ usePath, useExists }: Controller<T>, enabled?: boolean): RefObject<TElem | null>;
18
+ export declare function useControlAutofocus<T = unknown, TElem extends HTMLElement = HTMLElement>(controller: Controller<T>, enabled?: boolean): RefObject<TElem | null>;
20
19
  /**
21
20
  * Visibly focuses the provided element.
22
21
  *
@@ -25,8 +24,7 @@ export declare function useControlAutofocus<T = unknown, TElem extends HTMLEleme
25
24
  */
26
25
  export declare function visiblyFocus(el: HTMLElement, options?: FocusOptions): void;
27
26
  /**
28
- * Returns a function used the scroll an element into view, taking into account
29
- * the form app's sticky elements, so that elements don't end up hidden behind
30
- * them.
27
+ * Returns a function used the scroll an element into view, taking into account the form app's
28
+ * sticky elements, so that elements don't end up hidden behind them.
31
29
  */
32
30
  export declare function useScrollIntoView(): ScrollIntoViewFn;
@@ -20,13 +20,13 @@ export interface UseControlIssuesOptions {
20
20
  /** Result of the `useControlIssues` hook. */
21
21
  export interface UseControlIssuesResult {
22
22
  /**
23
- * Node that should be rendered when the issues are to appear inline. This
24
- * will be `null` if the issues should not appear inline.
23
+ * Node that should be rendered when the issues are to appear inline. This will be `null` if the
24
+ * issues should not appear inline.
25
25
  */
26
26
  inlineIssues: ReactNode;
27
27
  /**
28
- * Node that should be rendered when the issues are to appear within a
29
- * popover. This will be `null` if the issues should not appear in a popover.
28
+ * Node that should be rendered when the issues are to appear within a popover. This will be
29
+ * `null` if the issues should not appear in a popover.
30
30
  */
31
31
  popoverIssues: ReactNode;
32
32
  }
@@ -1,16 +1,13 @@
1
1
  import { AbsolutePath } from "@ostack.tech/kform";
2
2
  import { type FileSystemHandle, type FileWithHandle, type WellKnownDirectory } from "browser-fs-access";
3
- import { type ReactNode } from "react";
4
- /**
5
- * Options that can be passed to the {@link useFormLoader} hook, or to its
6
- * resulting `load` function.
7
- */
3
+ import type { ReactNode } from "react";
4
+ /** Options that can be passed to the {@link useFormLoader} hook, or to its resulting `load` function. */
8
5
  export interface FormLoaderOptions<T = unknown> {
9
6
  /**
10
7
  * Function used to decode the form, given its file.
11
8
  *
12
- * If decoding a text-based format, one may use `await file.text()` to get the
13
- * content of the file as a string.
9
+ * If decoding a text-based format, one may use `await file.text()` to get the content of the file
10
+ * as a string.
14
11
  *
15
12
  * @param file File containing the form to decode.
16
13
  * @returns Decoded form value.
@@ -30,30 +27,26 @@ export interface FormLoaderOptions<T = unknown> {
30
27
  description?: string;
31
28
  /** Directory to present when starting to load. */
32
29
  startIn?: WellKnownDirectory | FileSystemHandle;
33
- /**
34
- * By specifying an ID, the user agent can remember different directories for
35
- * different IDs.
36
- */
30
+ /** By specifying an ID, the user agent can remember different directories for different IDs. */
37
31
  id?: string;
38
32
  /**
39
- * Function called before loading. The form will still be marked as "loading"
40
- * while this function is running.
33
+ * Function called before loading. The form will still be marked as "loading" while this function
34
+ * is running.
41
35
  *
42
- * If `false` is returned, then the load action will be cancelled. If loading
43
- * was cancelled, `onAfterLoad` will **not** run.
36
+ * If `false` is returned, then the load action will be cancelled. If loading was cancelled,
37
+ * `onAfterLoad` will **not** run.
44
38
  *
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.
39
+ * @returns Boolean indicating whether loading should proceed. If nothing (`undefined`) is
40
+ * returned, then loading will proceed as normal. A promise resolving to one of the previously
41
+ * mentioned values may also be returned.
49
42
  */
50
43
  onBeforeLoad?: () => boolean | void | PromiseLike<boolean | void>;
51
44
  /**
52
- * Function called after loading independently of success or failure. The form
53
- * will still be marked as "loading" while this function is running.
45
+ * Function called after loading independently of success or failure. The form will still be
46
+ * marked as "loading" while this function is running.
54
47
  *
55
- * This function does **not** run if loading was cancelled due to `false`
56
- * being returned from `onBeforeLoad`.
48
+ * This function does **not** run if loading was cancelled due to `false` being returned from
49
+ * `onBeforeLoad`.
57
50
  */
58
51
  onAfterLoad?: () => void | PromiseLike<void>;
59
52
  /**
@@ -75,19 +68,19 @@ export interface FormLoaderOptions<T = unknown> {
75
68
  */
76
69
  validateOnLoad?: boolean;
77
70
  /**
78
- * Message to show in a toast when successfully loading a form from a file.
79
- * Can be set to `null` to not show any message.
71
+ * Message to show in a toast when successfully loading a form from a file. Can be set to `null`
72
+ * to not show any message.
80
73
  *
81
74
  * @param file Loaded file.
82
75
  * @returns Message to show in a toast.
83
76
  */
84
77
  successMessage?: ReactNode | ((file: FileWithHandle) => ReactNode);
85
78
  /**
86
- * Message to show in a toast when an error occurs while loading the form from
87
- * a file. Can be set to `null` to not show any message.
79
+ * Message to show in a toast when an error occurs while loading the form from a file. Can be set
80
+ * to `null` to not show any message.
88
81
  *
89
- * @param file File from which the load was attempted (or `null` if the file
90
- * could not be accessed).
82
+ * @param file File from which the load was attempted (or `null` if the file could not be
83
+ * accessed).
91
84
  * @param error Error that occurred.
92
85
  * @returns Message to show in a toast.
93
86
  */
@@ -108,8 +101,8 @@ export interface FormLoaderResult<T> {
108
101
  /** Hook exposing a function used to load the form from a file. */
109
102
  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
103
  /**
111
- * Hook exposing whether the form is currently preparing the load (running
112
- * `onBeforeLoad` or selecting the file to load).
104
+ * Hook exposing whether the form is currently preparing the load (running `onBeforeLoad` or
105
+ * selecting the file to load).
113
106
  */
114
107
  export declare function useFormIsPreparingLoad(): any;
115
108
  /** Hook exposing whether the form is currently being loaded. */
@@ -1,15 +1,14 @@
1
1
  import { AbsolutePath } from "@ostack.tech/kform";
2
2
  import { type FileSystemHandle, type WellKnownDirectory } from "browser-fs-access";
3
- import { type ReactNode } from "react";
3
+ import type { ReactNode } from "react";
4
4
  /**
5
- * Options that can be passed to the {@link useFormSaver} hook, or to its
6
- * resulting `save`/`saveAs` functions.
5
+ * Options that can be passed to the {@link useFormSaver} hook, or to its resulting `save`/`saveAs`
6
+ * functions.
7
7
  */
8
8
  export interface FormSaverOptions<T = unknown> {
9
9
  /**
10
- * When set, if modern file system APIs are available and the form has been
11
- * previously loaded or saved, then the file will be written over the
12
- * previously saved/loaded file.
10
+ * When set, if modern file system APIs are available and the form has been previously loaded or
11
+ * saved, then the file will be written over the previously saved/loaded file.
13
12
  *
14
13
  * @default false
15
14
  */
@@ -17,13 +16,13 @@ export interface FormSaverOptions<T = unknown> {
17
16
  /**
18
17
  * Function used to encode the form, given its value.
19
18
  *
20
- * Note that when returning a string, the string is converted into a `Blob`
21
- * using the first provided mime type in `mimeTypes` as its type, i.e. it is
22
- * converted as `new Blob([encodedValue], { type: mimeTypes?.[0] })`.
19
+ * Note that when returning a string, the string is converted into a `Blob` using the first
20
+ * provided mime type in `mimeTypes` as its type, i.e. it is converted as `new
21
+ * Blob([encodedValue], { type: mimeTypes?.[0] })`.
23
22
  *
24
23
  * @param formValue Value of the form.
25
24
  * @returns Encoded form value as a string, blob, response, or a promise to
26
- * either type.
25
+ * either type.
27
26
  */
28
27
  encode?: (formValue: T) => string | Blob | Response | PromiseLike<string | Blob | Response>;
29
28
  /**
@@ -35,8 +34,8 @@ export interface FormSaverOptions<T = unknown> {
35
34
  /**
36
35
  * Suggested file name.
37
36
  *
38
- * A function may be provided which will be called with the form value right
39
- * before invoking the save.
37
+ * A function may be provided which will be called with the form value right before invoking the
38
+ * save.
40
39
  */
41
40
  fileName?: string | ((formValue: T) => string | PromiseLike<string>);
42
41
  /**
@@ -65,30 +64,26 @@ export interface FormSaverOptions<T = unknown> {
65
64
  startIn?: WellKnownDirectory | FileSystemHandle;
66
65
  /** Excludes the "accept all" option. */
67
66
  excludeAcceptAllOption?: boolean;
68
- /**
69
- * By specifying an ID, the user agent can remember different directories for
70
- * different IDs.
71
- */
67
+ /** By specifying an ID, the user agent can remember different directories for different IDs. */
72
68
  id?: string;
73
69
  /**
74
- * Function called before saving. The form will still be marked as "saving"
75
- * while this function is running.
70
+ * Function called before saving. The form will still be marked as "saving" while this function is
71
+ * running.
76
72
  *
77
- * If `false` is returned, then the save action will be cancelled. If saving
78
- * was cancelled, `onAfterSave` will **not** run.
73
+ * If `false` is returned, then the save action will be cancelled. If saving was cancelled,
74
+ * `onAfterSave` will **not** run.
79
75
  *
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.
76
+ * @returns Boolean indicating whether saving should proceed. If nothing (`undefined`) is
77
+ * returned, then saving will proceed as normal. A promise resolving to one of the previously
78
+ * mentioned values may also be returned.
84
79
  */
85
80
  onBeforeSave?: () => boolean | void | PromiseLike<boolean | void>;
86
81
  /**
87
- * Function called after saving independently of success or failure. The form
88
- * will still be marked as "saving" while this function is running.
82
+ * Function called after saving independently of success or failure. The form will still be marked
83
+ * as "saving" while this function is running.
89
84
  *
90
- * This function does **not** run if saving was cancelled due to `false` being
91
- * returned from `onBeforeSave`.
85
+ * This function does **not** run if saving was cancelled due to `false` being returned from
86
+ * `onBeforeSave`.
92
87
  */
93
88
  onAfterSave?: () => void | PromiseLike<void>;
94
89
  /**
@@ -98,19 +93,19 @@ export interface FormSaverOptions<T = unknown> {
98
93
  */
99
94
  setPristineOnSave?: boolean;
100
95
  /**
101
- * Message to show in a toast when successfully saving the form to a file. Can
102
- * be set to `null` to not show any message.
96
+ * Message to show in a toast when successfully saving the form to a file. Can be set to `null` to
97
+ * not show any message.
103
98
  *
104
99
  * @param fileHandle Handle to the saved file.
105
100
  * @returns Message to show in a toast.
106
101
  */
107
102
  successMessage?: ReactNode | ((fileHandle: FileSystemFileHandle) => ReactNode);
108
103
  /**
109
- * Message to show in a toast when an error occurs while saving the form to a
110
- * file. Can be set to `null` to not show any message.
104
+ * Message to show in a toast when an error occurs while saving the form to a file. Can be set to
105
+ * `null` to not show any message.
111
106
  *
112
- * @param fileHandle Handle of the file over which the save was attempted, or
113
- * `null` if no such file exists.
107
+ * @param fileHandle Handle of the file over which the save was attempted, or `null` if no such
108
+ * file exists.
114
109
  * @param error Error that occurred.
115
110
  * @returns Message to show in a toast.
116
111
  */
@@ -1,24 +1,23 @@
1
1
  /** Options of the {@link useFormValidator} hook. */
2
2
  export interface UseFormValidatorOptions {
3
3
  /**
4
- * Function called before validating. The form will still be marked as
5
- * "validating" while this function is running.
4
+ * Function called before validating. The form will still be marked as "validating" while this
5
+ * function is running.
6
6
  *
7
- * If `false` is returned, then the validate action will be cancelled. If
8
- * validating was cancelled, `onAfterValidate` will **not** run.
7
+ * If `false` is returned, then the validate action will be cancelled. If validating was
8
+ * cancelled, `onAfterValidate` will **not** run.
9
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.
10
+ * @returns Boolean indicating whether validating should proceed. If nothing (`undefined`) is
11
+ * returned, then validating will proceed as normal. A promise resolving to one of the
12
+ * previously mentioned values may also be returned.
14
13
  */
15
14
  onBeforeValidate?: () => boolean | void | PromiseLike<boolean | void>;
16
15
  /**
17
- * Function called after validating independently of success or failure. The
18
- * form will still be marked as "validating" while this function is running.
16
+ * Function called after validating independently of success or failure. The form will still be
17
+ * marked as "validating" while this function is running.
19
18
  *
20
- * This function does **not** run if validating was cancelled due to `false`
21
- * being returned from `onBeforeValidate`.
19
+ * This function does **not** run if validating was cancelled due to `false` being returned from
20
+ * `onBeforeValidate`.
22
21
  */
23
22
  onAfterValidate?: () => void | PromiseLike<void>;
24
23
  }
@@ -35,15 +34,9 @@ export interface UseFormValidatorResult {
35
34
  export declare function useFormValidator({ onBeforeValidate, onAfterValidate, }?: UseFormValidatorOptions): UseFormValidatorResult;
36
35
  /** Result of the {@link useFormIsValidating} hook. */
37
36
  export interface FormIsValidatingResult {
38
- /**
39
- * Whether form is being validated automatically (due to validating mode being
40
- * set to `"auto"`).
41
- */
37
+ /** Whether form is being validated automatically (due to validating mode being set to `"auto"`). */
42
38
  validatingAutomatically: boolean;
43
- /**
44
- * Whether form is being validated manually (due to an explicit `validate`
45
- * call).
46
- */
39
+ /** Whether form is being validated manually (due to an explicit `validate` call). */
47
40
  validatingManually: boolean;
48
41
  /** Whether form is being validated (either automatically or manually). */
49
42
  validating: boolean;
@@ -1,5 +1,5 @@
1
1
  import type { DisplayStatus, SealedValidationIssue } from "@ostack.tech/kform";
2
- import type { Controller } from "@ostack.tech/kform-react";
2
+ import { type Controller } from "@ostack.tech/kform-react";
3
3
  import { type FocusEvent, type ReactNode, type Ref, type RefObject } from "react";
4
4
  /** Options when registering the control. */
5
5
  export interface UseRegisterControlOptions<T> {