@ostack.tech/ui-kform 0.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.
Files changed (144) hide show
  1. package/README.md +3 -0
  2. package/dist/ostack-ui-kform.cjs +7534 -0
  3. package/dist/ostack-ui-kform.cjs.map +1 -0
  4. package/dist/ostack-ui-kform.css +858 -0
  5. package/dist/ostack-ui-kform.css.map +1 -0
  6. package/dist/ostack-ui-kform.js +7518 -0
  7. package/dist/ostack-ui-kform.js.map +1 -0
  8. package/dist/types/components/Annexes/Annex.d.ts +46 -0
  9. package/dist/types/components/Annexes/AnnexTab.d.ts +5 -0
  10. package/dist/types/components/Annexes/Annexes.d.ts +95 -0
  11. package/dist/types/components/Annexes/AnnexesContext.d.ts +87 -0
  12. package/dist/types/components/Annexes/AnnexesManager.d.ts +47 -0
  13. package/dist/types/components/Annexes/AnnexesMenu.d.ts +10 -0
  14. package/dist/types/components/Annexes/AnnexesTabList.d.ts +8 -0
  15. package/dist/types/components/Annexes/index.d.ts +3 -0
  16. package/dist/types/components/CheckboxControl/CheckboxControl.d.ts +48 -0
  17. package/dist/types/components/CheckboxControl/index.d.ts +1 -0
  18. package/dist/types/components/CheckboxGroupControl/CheckboxGroupControl.d.ts +63 -0
  19. package/dist/types/components/CheckboxGroupControl/index.d.ts +1 -0
  20. package/dist/types/components/ControlField/ControlField.d.ts +50 -0
  21. package/dist/types/components/ControlField/ControlFieldContext.d.ts +33 -0
  22. package/dist/types/components/ControlField/index.d.ts +2 -0
  23. package/dist/types/components/DateControl/DateControl.d.ts +45 -0
  24. package/dist/types/components/DateControl/index.d.ts +1 -0
  25. package/dist/types/components/DateRangeControl/DateRangeControl.d.ts +79 -0
  26. package/dist/types/components/DateRangeControl/index.d.ts +1 -0
  27. package/dist/types/components/FileControl/FileControl.d.ts +68 -0
  28. package/dist/types/components/FileControl/index.d.ts +1 -0
  29. package/dist/types/components/FormApp/FormApp.d.ts +210 -0
  30. package/dist/types/components/FormApp/FormAppContext.d.ts +181 -0
  31. package/dist/types/components/FormApp/FormAppIssueMessages.d.ts +45 -0
  32. package/dist/types/components/FormApp/FormAppStatus.d.ts +23 -0
  33. package/dist/types/components/FormApp/index.d.ts +4 -0
  34. package/dist/types/components/FormPages/FormPage.d.ts +86 -0
  35. package/dist/types/components/FormPages/FormPageHeader.d.ts +7 -0
  36. package/dist/types/components/FormPages/FormPageSidebarItem.d.ts +6 -0
  37. package/dist/types/components/FormPages/FormPages.d.ts +40 -0
  38. package/dist/types/components/FormPages/FormPagesContext.d.ts +67 -0
  39. package/dist/types/components/FormPages/FormPagesNavigation.d.ts +12 -0
  40. package/dist/types/components/FormPages/FormPagesSelect.d.ts +7 -0
  41. package/dist/types/components/FormPages/FormPagesSelectOption.d.ts +6 -0
  42. package/dist/types/components/FormPages/FormPagesSidebar.d.ts +6 -0
  43. package/dist/types/components/FormPages/index.d.ts +3 -0
  44. package/dist/types/components/FormStepper/FormStep.d.ts +8 -0
  45. package/dist/types/components/FormStepper/FormStepContent.d.ts +20 -0
  46. package/dist/types/components/FormStepper/FormStepList.d.ts +7 -0
  47. package/dist/types/components/FormStepper/FormStepper.d.ts +71 -0
  48. package/dist/types/components/FormStepper/FormStepperContext.d.ts +65 -0
  49. package/dist/types/components/FormStepper/index.d.ts +3 -0
  50. package/dist/types/components/IssueAlert/IssueAlert.d.ts +13 -0
  51. package/dist/types/components/IssueAlert/index.d.ts +1 -0
  52. package/dist/types/components/IssueMessage/IssueMessage.d.ts +14 -0
  53. package/dist/types/components/IssueMessage/index.d.ts +1 -0
  54. package/dist/types/components/IssueMessages/IssueMessages.d.ts +70 -0
  55. package/dist/types/components/IssueMessages/index.d.ts +1 -0
  56. package/dist/types/components/IssuesPanel/IssuesPanel.d.ts +106 -0
  57. package/dist/types/components/IssuesPanel/IssuesPanelControls.d.ts +19 -0
  58. package/dist/types/components/IssuesPanel/IssuesPanelMessagesCard.d.ts +13 -0
  59. package/dist/types/components/IssuesPanel/IssuesPanelSummaryCard.d.ts +9 -0
  60. package/dist/types/components/IssuesPanel/index.d.ts +1 -0
  61. package/dist/types/components/IssuesPopover/IssuesPopover.d.ts +15 -0
  62. package/dist/types/components/IssuesPopover/index.d.ts +1 -0
  63. package/dist/types/components/LoadAction/LoadAction.d.ts +22 -0
  64. package/dist/types/components/LoadAction/index.d.ts +1 -0
  65. package/dist/types/components/NumericControl/NumericControl.d.ts +45 -0
  66. package/dist/types/components/NumericControl/index.d.ts +1 -0
  67. package/dist/types/components/PathLink/PathLink.d.ts +16 -0
  68. package/dist/types/components/PathLink/index.d.ts +1 -0
  69. package/dist/types/components/RadioGroupControl/RadioGroupControl.d.ts +56 -0
  70. package/dist/types/components/RadioGroupControl/index.d.ts +1 -0
  71. package/dist/types/components/SaveAction/SaveAction.d.ts +51 -0
  72. package/dist/types/components/SaveAction/index.d.ts +1 -0
  73. package/dist/types/components/SelectControl/SelectControl.d.ts +48 -0
  74. package/dist/types/components/SelectControl/index.d.ts +1 -0
  75. package/dist/types/components/SelectMultipleControl/SelectMultipleControl.d.ts +55 -0
  76. package/dist/types/components/SelectMultipleControl/index.d.ts +1 -0
  77. package/dist/types/components/SubmitAction/SubmitAction.d.ts +94 -0
  78. package/dist/types/components/SubmitAction/index.d.ts +1 -0
  79. package/dist/types/components/TableControl/TableControl.d.ts +64 -0
  80. package/dist/types/components/TableControl/TableControlAddRowTrigger.d.ts +25 -0
  81. package/dist/types/components/TableControl/TableControlApi.d.ts +25 -0
  82. package/dist/types/components/TableControl/TableControlCell.d.ts +7 -0
  83. package/dist/types/components/TableControl/TableControlColumn.d.ts +58 -0
  84. package/dist/types/components/TableControl/TableControlContent.d.ts +7 -0
  85. package/dist/types/components/TableControl/TableControlContext.d.ts +26 -0
  86. package/dist/types/components/TableControl/TableControlPagination.d.ts +2 -0
  87. package/dist/types/components/TableControl/TableControlRemoveRowTrigger.d.ts +61 -0
  88. package/dist/types/components/TableControl/TableControlRow.d.ts +7 -0
  89. package/dist/types/components/TableControl/TableControlRowsPerPage.d.ts +2 -0
  90. package/dist/types/components/TableControl/index.d.ts +8 -0
  91. package/dist/types/components/TextControl/TextControl.d.ts +66 -0
  92. package/dist/types/components/TextControl/index.d.ts +1 -0
  93. package/dist/types/components/TopBar/TopBar.d.ts +6 -0
  94. package/dist/types/components/TopBar/TopBarActions.d.ts +7 -0
  95. package/dist/types/components/TopBar/index.d.ts +2 -0
  96. package/dist/types/components/ValidateAction/ValidateAction.d.ts +21 -0
  97. package/dist/types/components/ValidateAction/index.d.ts +1 -0
  98. package/dist/types/index.d.ts +36 -0
  99. package/dist/types/locale/LocalizationObject.d.ts +34 -0
  100. package/dist/types/locale/defaultLocale.d.ts +3 -0
  101. package/dist/types/locale/en-GB.d.ts +3 -0
  102. package/dist/types/locale/en-US.d.ts +3 -0
  103. package/dist/types/locale/en.d.ts +3 -0
  104. package/dist/types/locale/fr-FR.d.ts +3 -0
  105. package/dist/types/locale/index.d.ts +6 -0
  106. package/dist/types/locale/pt-PT.d.ts +3 -0
  107. package/dist/types/providers/LocalizationProvider/LocalizationContext.d.ts +6 -0
  108. package/dist/types/providers/LocalizationProvider/LocalizationProvider.d.ts +10 -0
  109. package/dist/types/providers/LocalizationProvider/index.d.ts +3 -0
  110. package/dist/types/providers/LocalizationProvider/useLocale.d.ts +3 -0
  111. package/dist/types/providers/PrefixSuffixProvider/PrefixSuffixContext.d.ts +5 -0
  112. package/dist/types/providers/PrefixSuffixProvider/PrefixSuffixProvider.d.ts +9 -0
  113. package/dist/types/providers/PrefixSuffixProvider/index.d.ts +3 -0
  114. package/dist/types/providers/PrefixSuffixProvider/usePrefix.d.ts +6 -0
  115. package/dist/types/utils/dateRestrictions.d.ts +6 -0
  116. package/dist/types/utils/displayStatusConversions.d.ts +6 -0
  117. package/dist/types/utils/mostSpecificPath.d.ts +13 -0
  118. package/dist/types/utils/options.d.ts +18 -0
  119. package/dist/types/utils/pathSpecificity.d.ts +18 -0
  120. package/dist/types/utils/selectionTransformations.d.ts +32 -0
  121. package/dist/types/utils/useControlAutofocus.d.ts +32 -0
  122. package/dist/types/utils/useControlIssues.d.ts +27 -0
  123. package/dist/types/utils/useEqualityFn.d.ts +1 -0
  124. package/dist/types/utils/useFormLoader.d.ts +83 -0
  125. package/dist/types/utils/useFormSaver.d.ts +96 -0
  126. package/dist/types/utils/useFormValidator.d.ts +28 -0
  127. package/dist/types/utils/useRegisterControl.d.ts +24 -0
  128. package/dist/types/utils/useReportValidationFailures.d.ts +5 -0
  129. package/dist/types/utils/useTemporalStringTransformer.d.ts +21 -0
  130. package/package.json +70 -0
  131. package/scss/_utils.scss +6 -0
  132. package/scss/components/Annexes/_Annexes-variables.scss +17 -0
  133. package/scss/components/Annexes/_Annexes.scss +234 -0
  134. package/scss/components/FileControl/_FileControl.scss +52 -0
  135. package/scss/components/FormApp/_FormApp.scss +67 -0
  136. package/scss/components/FormPages/_FormPages-variables.scss +62 -0
  137. package/scss/components/FormPages/_FormPages.scss +288 -0
  138. package/scss/components/IssueMessages/_IssueMessages.scss +13 -0
  139. package/scss/components/IssuesPanel/_IssuesPanel-variables.scss +82 -0
  140. package/scss/components/IssuesPanel/_IssuesPanel.scss +196 -0
  141. package/scss/components/TableControl/_TableControl.scss +21 -0
  142. package/scss/components/TopBar/_TopBar.scss +52 -0
  143. package/scss/index.scss +11 -0
  144. package/scss/scss/_base-variables.scss +5 -0
@@ -0,0 +1,61 @@
1
+ import { IconButton } from "@ostack.tech/ui";
2
+ import * as React from "react";
3
+ /** Properties of the table control remove row trigger component. */
4
+ export interface TableControlRemoveRowTriggerProps extends Omit<Partial<React.ComponentPropsWithoutRef<typeof IconButton>>, "children"> {
5
+ /**
6
+ * Whether to show a confirmation message when removing a row.
7
+ *
8
+ * @default false
9
+ */
10
+ showConfirmation?: boolean;
11
+ /**
12
+ * Function called after confirmation that the row is to be removed (this
13
+ * function is called even if `showConfirmation` is not set).
14
+ */
15
+ onConfirmRowRemoval?: () => void;
16
+ /** Function called after the row has been removed. */
17
+ onRowRemoved?: () => void;
18
+ /**
19
+ * Label displayed on the icon button rendered by default when no `children`
20
+ * are provided. If `children` are provided, this property has no effect.
21
+ */
22
+ defaultButtonLabel?: React.ReactNode;
23
+ /** Title of the confirmation dialog when `showConfirmation` is `true`. */
24
+ confirmDialogTitle?: React.ReactNode;
25
+ /**
26
+ * Message of the confirmation dialog when `showConfirmation` is `true`.
27
+ *
28
+ * @param index Index of the row being removed.
29
+ */
30
+ confirmDialogMessage?: (index: number) => React.ReactNode;
31
+ /**
32
+ * Ok button text of the confirmation dialog when `showConfirmation` is
33
+ * `true`.
34
+ */
35
+ confirmDialogOkText?: React.ReactNode;
36
+ /**
37
+ * Cancel button text of the confirmation dialog when `showConfirmation` is
38
+ * `true`.
39
+ */
40
+ confirmDialogCancelText?: React.ReactNode;
41
+ /**
42
+ * Whether to show the trigger when the table is read-only.
43
+ *
44
+ * @default false
45
+ */
46
+ showWhenReadOnly?: boolean;
47
+ /**
48
+ * Children of the remove row trigger component. By default, it is an
49
+ * `IconButton` with label `defaultButtonLabel`. A function can be optionally
50
+ * passed as children which will receive an argument with whether the row is
51
+ * currently being removed.
52
+ */
53
+ children?: React.ReactNode;
54
+ }
55
+ /**
56
+ * Trigger used to remove a row of a table controlled by a table control.
57
+ *
58
+ * By default, it renders an icon button with label `defaultButtonLabel`,
59
+ * however, this can be overriden by providing `children`.
60
+ */
61
+ export declare const TableControlRemoveRowTrigger: React.ForwardRefExoticComponent<TableControlRemoveRowTriggerProps & React.RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,7 @@
1
+ import { DataTableRow } from "@ostack.tech/ui";
2
+ import * as React from "react";
3
+ /** Properties of the table control row. */
4
+ export interface TableControlRowProps extends React.ComponentPropsWithoutRef<typeof DataTableRow> {
5
+ }
6
+ /** Row of a table control. */
7
+ export declare const TableControlRow: React.NamedExoticComponent<TableControlRowProps & React.RefAttributes<HTMLTableRowElement>>;
@@ -0,0 +1,2 @@
1
+ /** Table control rows per page. */
2
+ export declare const TableControlRowsPerPage: import("react").ForwardRefExoticComponent<import("@ostack.tech/ui").DataTableRowsPerPageProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,8 @@
1
+ export * from "./TableControl.tsx";
2
+ export * from "./TableControlAddRowTrigger.tsx";
3
+ export * from "./TableControlApi.ts";
4
+ export * from "./TableControlColumn.tsx";
5
+ export * from "./TableControlContent.tsx";
6
+ export * from "./TableControlPagination.tsx";
7
+ export * from "./TableControlRemoveRowTrigger.tsx";
8
+ export * from "./TableControlRowsPerPage.tsx";
@@ -0,0 +1,66 @@
1
+ import { type Path } from "@ostack.tech/kform";
2
+ import { type InputController, type InputOptions } from "@ostack.tech/kform-react";
3
+ import { Input, TextArea } from "@ostack.tech/ui";
4
+ import * as React from "react";
5
+ import { type IssueMessages, type IssueMessagesByCode } from "../IssueMessages";
6
+ /** Properties of the text control component. */
7
+ export type TextControlProps<T extends string | null = string | null> = TextControlPropsSingleline<T> | TextControlPropsMultiline<T>;
8
+ export type TextControlPropsSingleline<T extends string | null = string | null> = Omit<React.ComponentPropsWithoutRef<typeof Input>, "defaultValue" | "value" | "status"> & TextControlPropsBase<T> & {
9
+ multiline?: false;
10
+ };
11
+ export type TextControlPropsMultiline<T extends string | null = string | null> = Omit<React.ComponentPropsWithoutRef<typeof TextArea>, "defaultValue" | "value" | "status"> & TextControlPropsBase<T> & {
12
+ multiline: true;
13
+ pattern?: never;
14
+ };
15
+ export type TextControlPropsBase<T extends string | null = string | null> = Omit<InputOptions<T, string, React.ComponentRef<typeof Input | typeof TextArea>>, "enabled" | "format" | "parse"> & {
16
+ /** Path to the value. */
17
+ path?: string | Path;
18
+ /**
19
+ * Issue messages of this control.
20
+ *
21
+ * Mapping from an issue's code to its message.
22
+ */
23
+ issueMessages?: IssueMessagesByCode;
24
+ /**
25
+ * Label to use in the issues panel when displaying issues associated with
26
+ * this field.
27
+ *
28
+ * This label has priority over the field's `ControlLabel`.
29
+ */
30
+ issuesPanelLabel?: React.ReactNode;
31
+ /**
32
+ * Whether to display the issues associated with this control.
33
+ *
34
+ * @default true
35
+ */
36
+ displayIssues?: boolean;
37
+ /**
38
+ * Whether to prevent the auto-focusing behaviour that causes this control
39
+ * to be focused when the form app's `focus` is called with this control's
40
+ * path.
41
+ *
42
+ * Preventing this behaviour is useful when multiple controls for the same
43
+ * path are rendered at once, and only one of them should be focused.
44
+ *
45
+ * @default false
46
+ */
47
+ preventAutoFocus?: boolean;
48
+ /** Whether to render a multiline text control. */
49
+ multiline?: boolean;
50
+ /** Reference to the control's API. */
51
+ apiRef?: React.Ref<InputController<T, string, React.ComponentRef<typeof Input | typeof TextArea>> | undefined>;
52
+ /** Properties to pass to the `IssueMessages` component. */
53
+ issueMessagesProps?: Omit<React.ComponentPropsWithRef<typeof IssueMessages>, "path" | "issues" | "messages">;
54
+ };
55
+ /**
56
+ * Text control component supporting (possibly nullable) schemas of type
57
+ * "String".
58
+ *
59
+ * If the schema is nullable, this component sets the form value to `null` when
60
+ * the control is empty. Note, however, that the form may still hold an empty
61
+ * string as value if set programmatically.
62
+ *
63
+ * The component further supports either single or multiple lines via the
64
+ * `multiline` prop.
65
+ */
66
+ export declare const TextControl: React.ForwardRefExoticComponent<TextControlProps<string | null> & React.RefAttributes<HTMLInputElement | HTMLTextAreaElement>>;
@@ -0,0 +1 @@
1
+ export * from "./TextControl.tsx";
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ /** Properties of the top bar component. */
3
+ export interface TopBarProps extends React.ComponentPropsWithoutRef<"div"> {
4
+ }
5
+ /** Top bar component. */
6
+ export declare const TopBar: React.ForwardRefExoticComponent<TopBarProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,7 @@
1
+ import { Stack } from "@ostack.tech/ui";
2
+ import * as React from "react";
3
+ /** Properties of the top bar actions component. */
4
+ export interface TopBarActionsProps extends React.ComponentPropsWithoutRef<typeof Stack> {
5
+ }
6
+ /** Container used to display actions within the top bar. */
7
+ export declare const TopBarActions: React.ForwardRefExoticComponent<TopBarActionsProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,2 @@
1
+ export * from "./TopBar.tsx";
2
+ export * from "./TopBarActions.tsx";
@@ -0,0 +1,21 @@
1
+ import { type ButtonProps } from "@ostack.tech/ui";
2
+ import * as React from "react";
3
+ /** Properties of the validate action. */
4
+ export interface ValidateActionProps extends Omit<ButtonProps, "children"> {
5
+ /** Action's label. */
6
+ label?: React.ReactNode;
7
+ /**
8
+ * Keybinds for triggering the action. Set to `null` to disable the keyboard
9
+ * shortcut.
10
+ *
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`
14
+ * documentation](https://github.com/jamiebuilds/tinykeys).
15
+ *
16
+ * Defaults to the keybinds defined by the current locale.
17
+ */
18
+ keybinds?: string | string[] | null;
19
+ }
20
+ /** Action used to validate the form. */
21
+ export declare function ValidateAction({ label, keybinds, loading, disabled, onClick, ...otherProps }: ValidateActionProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./ValidateAction.tsx";
@@ -0,0 +1,36 @@
1
+ export * from "./locale";
2
+ export * from "./components/Annexes";
3
+ export * from "./components/CheckboxControl";
4
+ export * from "./components/CheckboxGroupControl";
5
+ export * from "./components/ControlField";
6
+ export * from "./components/DateControl";
7
+ export * from "./components/DateRangeControl";
8
+ export * from "./components/FileControl";
9
+ export * from "./components/FormApp";
10
+ export * from "./components/FormPages";
11
+ export * from "./components/FormStepper";
12
+ export * from "./components/IssueAlert";
13
+ export * from "./components/IssueMessages";
14
+ export * from "./components/IssuesPanel";
15
+ export * from "./components/IssuesPopover";
16
+ export * from "./components/LoadAction";
17
+ export * from "./components/NumericControl";
18
+ export * from "./components/PathLink";
19
+ export * from "./components/RadioGroupControl";
20
+ export * from "./components/SaveAction";
21
+ export * from "./components/SelectControl";
22
+ export * from "./components/SelectMultipleControl";
23
+ export * from "./components/SubmitAction";
24
+ export * from "./components/TableControl";
25
+ export * from "./components/TextControl";
26
+ export * from "./components/TopBar";
27
+ export * from "./components/ValidateAction";
28
+ export * from "./providers/LocalizationProvider";
29
+ export * from "./providers/PrefixSuffixProvider";
30
+ export * from "./utils/displayStatusConversions.ts";
31
+ export * from "./utils/options.ts";
32
+ export * from "./utils/useControlIssues.tsx";
33
+ export * from "./utils/useFormLoader.tsx";
34
+ export * from "./utils/useFormSaver.tsx";
35
+ export * from "./utils/useFormValidator.ts";
36
+ export * from "./utils/useRegisterControl.tsx";
@@ -0,0 +1,34 @@
1
+ import { type LocalizationObject as UiLocalizationObject } from "@ostack.tech/ui";
2
+ import { type AnnexesManagerProps } from "../components/Annexes";
3
+ import { type DateRangeControlProps } from "../components/DateRangeControl";
4
+ import { type FileControlProps } from "../components/FileControl";
5
+ import { type FormAppProps } from "../components/FormApp";
6
+ import { type FormPageProps, type FormPagesNavigationProps } from "../components/FormPages";
7
+ import { type IssueMessagesProps } from "../components/IssueMessages";
8
+ import { type IssuesPanelProps } from "../components/IssuesPanel";
9
+ import { type IssuesPopoverProps } from "../components/IssuesPopover";
10
+ import { type LoadActionProps } from "../components/LoadAction";
11
+ import { type SaveActionProps } from "../components/SaveAction";
12
+ import { type SubmitActionProps } from "../components/SubmitAction";
13
+ import { type TableControlAddRowTriggerProps, type TableControlRemoveRowTriggerProps } from "../components/TableControl";
14
+ import { type ValidateActionProps } from "../components/ValidateAction";
15
+ /** Localization object representation. */
16
+ export interface LocalizationObject {
17
+ languageTag: string;
18
+ uiLocale: UiLocalizationObject;
19
+ AnnexesManager: Pick<AnnexesManagerProps, "aria-label" | "menuButtonText" | "addAnnexText" | "removeAnnexButtonLabel" | "removeAnnexKeyboardHint" | "removeAnnexConfirmDialogTitle" | "removeAnnexConfirmDialogMessage" | "removeAnnexConfirmDialogOkText" | "removeAnnexConfirmDialogCancelText">;
20
+ DateRangeControl: Pick<DateRangeControlProps, "issuesPanelStartLabelSuffix" | "issuesPanelEndLabelSuffix">;
21
+ FileControl: Pick<FileControlProps, "viewFileButtonLabel" | "downloadFileButtonLabel" | "fallbackText">;
22
+ FormApp: Pick<FormAppProps, "issuesPanelLabel" | "issueMessages" | "confirmUnloadMessage">;
23
+ FormPage: Pick<FormPageProps, "helperButtonLabel">;
24
+ FormPagesNavigation: Pick<FormPagesNavigationProps, "aria-label">;
25
+ IssueMessages: Pick<IssueMessagesProps, "unknownErrorMessage" | "unknownWarningMessage">;
26
+ IssuesPanel: Pick<IssuesPanelProps, "errorsLabel" | "warningsLabel" | "focusButtonLabel" | "previousIssueButtonLabel" | "nextIssueButtonLabel" | "firstIssueButtonLabel" | "lastIssueButtonLabel" | "paginationLabel" | "noIssuesMessage" | "resolvedTitle" | "resolvedMessage">;
27
+ IssuesPopover: Pick<IssuesPopoverProps, "label">;
28
+ LoadAction: Pick<LoadActionProps, "label" | "keybinds" | "successMessage" | "errorMessage">;
29
+ SaveAction: Pick<SaveActionProps, "label" | "keybinds" | "saveOptionsLabel" | "saveAsLabel" | "saveAsKeybinds" | "successMessage" | "errorMessage">;
30
+ SubmitAction: Pick<SubmitActionProps, "label" | "keybinds" | "dialogTitle" | "dialogDescription" | "dialogBody" | "dialogOkText" | "dialogCancelText" | "confirmWarningsCheckboxLabel" | "successMessage" | "errorMessage">;
31
+ TableControlAddRowTrigger: Pick<TableControlAddRowTriggerProps, "defaultButtonText">;
32
+ TableControlRemoveRowTrigger: Pick<TableControlRemoveRowTriggerProps, "defaultButtonLabel" | "confirmDialogTitle" | "confirmDialogMessage" | "confirmDialogOkText" | "confirmDialogCancelText">;
33
+ ValidateAction: Pick<ValidateActionProps, "label" | "keybinds">;
34
+ }
@@ -0,0 +1,3 @@
1
+ import { type LocalizationObject } from "./LocalizationObject.ts";
2
+ /** Default locale. */
3
+ export declare const defaultLocale: LocalizationObject;
@@ -0,0 +1,3 @@
1
+ import { type LocalizationObject } from "./LocalizationObject.ts";
2
+ /** `en-GB` locale. */
3
+ export declare const enGB: LocalizationObject;
@@ -0,0 +1,3 @@
1
+ import { type LocalizationObject } from "./LocalizationObject.ts";
2
+ /** `en-US` locale. */
3
+ export declare const enUS: LocalizationObject;
@@ -0,0 +1,3 @@
1
+ import { type LocalizationObject } from "./LocalizationObject.ts";
2
+ /** `en` locale (partial). */
3
+ export declare const en: Omit<LocalizationObject, "languageTag" | "uiLocale">;
@@ -0,0 +1,3 @@
1
+ import { type LocalizationObject } from "./LocalizationObject.ts";
2
+ /** `fr-FR` locale. */
3
+ export declare const frFR: LocalizationObject;
@@ -0,0 +1,6 @@
1
+ export * from "./LocalizationObject.ts";
2
+ export * from "./defaultLocale.ts";
3
+ export * from "./en-GB.ts";
4
+ export * from "./en-US.ts";
5
+ export * from "./fr-FR.tsx";
6
+ export * from "./pt-PT.tsx";
@@ -0,0 +1,3 @@
1
+ import { type LocalizationObject } from "./LocalizationObject.ts";
2
+ /** `pt-PT` locale. */
3
+ export declare const ptPT: LocalizationObject;
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ import { type LocalizationObject } from "../../locale/LocalizationObject.ts";
3
+ /** Value of the localisation context. */
4
+ export type LocalizationContextValue = LocalizationObject;
5
+ /** Localisation context. */
6
+ export declare const LocalizationContext: React.Context<LocalizationObject>;
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ import { type LocalizationObject } from "../../locale/LocalizationObject.ts";
3
+ /** Properties of the localisation provider. */
4
+ export interface LocalizationProviderProps {
5
+ /** Locale to use for the components. */
6
+ locale?: LocalizationObject;
7
+ children: React.ReactNode;
8
+ }
9
+ /** Localisation provider. */
10
+ export declare function LocalizationProvider({ locale, children, }: LocalizationProviderProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
@@ -0,0 +1,3 @@
1
+ export * from "./LocalizationContext.ts";
2
+ export * from "./LocalizationProvider.tsx";
3
+ export * from "./useLocale.ts";
@@ -0,0 +1,3 @@
1
+ import { type LocalizationObject } from "../../locale/LocalizationObject.ts";
2
+ /** Hook used to get the current locale. */
3
+ export declare function useLocale(): LocalizationObject;
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ /** Default library prefix-suffix. */
3
+ export declare const DEFAULT_PREFIX_SUFFIX = "kform-";
4
+ /** Prefix-suffix context. */
5
+ export declare const PrefixSuffixContext: React.Context<string>;
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ /** Properties of the prefix-suffix provider. */
3
+ export interface PrefixSuffixProviderProps {
4
+ /** Suffix to add to ostack/UI's prefix. */
5
+ prefixSuffix?: string;
6
+ children: React.ReactNode;
7
+ }
8
+ /** Prefix-suffix provider. */
9
+ export declare function PrefixSuffixProvider({ prefixSuffix, children, }: PrefixSuffixProviderProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
@@ -0,0 +1,3 @@
1
+ export * from "./PrefixSuffixContext.ts";
2
+ export * from "./PrefixSuffixProvider.tsx";
3
+ export * from "./usePrefix.ts";
@@ -0,0 +1,6 @@
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
+ */
6
+ export declare function usePrefix(): PrefixFn;
@@ -0,0 +1,6 @@
1
+ import { type Schema } from "@ostack.tech/kform";
2
+ import { type Temporal } from "@ostack.tech/kform-react";
3
+ /** Returns the minimum date allowed based on a temporal schema's restrictions. */
4
+ export declare function minDateRestriction<T extends Temporal | null>(schema: Schema<T>): Date | undefined;
5
+ /** Returns the maximum date allowed based on a temporal schema's restrictions. */
6
+ export declare function maxDateRestriction<T extends Temporal | null>(schema: Schema<T>): Date | undefined;
@@ -0,0 +1,6 @@
1
+ import { type DisplayStatus } from "@ostack.tech/kform";
2
+ import { type ControlStatus } from "@ostack.tech/ui";
3
+ /** Transforms ostack/KForm's display status into ostack/UI's control status. */
4
+ export declare function displayStatusToControlStatus(displayStatus: DisplayStatus | undefined): ControlStatus | undefined;
5
+ /** Transforms ostack/KForm's display status into a "danger" or "warning" colour. */
6
+ export declare function displayStatusToColor(displayStatus: DisplayStatus | undefined): "danger" | "warning" | undefined;
@@ -0,0 +1,13 @@
1
+ import { AbsolutePath } from "@ostack.tech/kform";
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.
6
+ *
7
+ * The list of paths may contain paths with a single trailing wildcard.
8
+ *
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.
12
+ */
13
+ export declare function mostSpecificPath(toMatch: AbsolutePath | null, paths: AbsolutePath[], currentActivePath: AbsolutePath | null): AbsolutePath | null;
@@ -0,0 +1,18 @@
1
+ import { type OptionProps, type OptionsGroupProps } from "@ostack.tech/ui";
2
+ import type * as React from "react";
3
+ /** Object representation of an options group. */
4
+ export type OptionsGroupObject<T = unknown> = Omit<OptionsGroupProps, "children"> & {
5
+ /** Group's options. */
6
+ options: OptionObject<T>[];
7
+ /** Group's unique key. */
8
+ key?: React.Key;
9
+ };
10
+ /** Object representation of an option. */
11
+ export type OptionObject<T = unknown> = Omit<OptionProps, "value" | "children"> & {
12
+ /** Option value. */
13
+ value: T;
14
+ /** Option's rendered text. */
15
+ text?: React.ReactNode;
16
+ /** Option's unique key. */
17
+ key?: React.Key;
18
+ };
@@ -0,0 +1,18 @@
1
+ import { type AbsolutePath } from "@ostack.tech/kform";
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.
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.
10
+ *
11
+ * Both `/a` and `/a/b/c` have the same specificity since both paths uniquely
12
+ * identify a resource.
13
+ *
14
+ * @param path1 First path to compare.
15
+ * @param path2 Second path to compare.
16
+ * @returns Number representing which path is more specific.
17
+ */
18
+ export declare function comparePathsBySpecificity(path1: AbsolutePath, path2: AbsolutePath): number;
@@ -0,0 +1,32 @@
1
+ import { type Schema } from "@ostack.tech/kform";
2
+ import { type Listable } from "@ostack.tech/kform-react";
3
+ import { type OptionObject, type OptionsGroupObject } from "./options.ts";
4
+ /**
5
+ * Parses a selection value from the (string) index of an option (or empty
6
+ * string).
7
+ */
8
+ export declare function parseSelectionValueFromOptionIndex<T>(formattedValue: string, schema: Schema<T>, options: {
9
+ value: T;
10
+ }[]): T;
11
+ /**
12
+ * Formats a selection value as the (string) index of an option (or empty
13
+ * string).
14
+ */
15
+ export declare function formatSelectionValueAsOptionIndex<T>(value: T | undefined, options: {
16
+ value: T;
17
+ }[]): string;
18
+ /** Parses an array of selection values from an array of (string) option indices. */
19
+ export declare function parseSelectionValuesFromOptionIndices<T, TListable extends Listable<T> | null>(formattedValue: string[], schema: Schema<TListable>, options: {
20
+ value: T;
21
+ }[]): T[] | null;
22
+ /** Formats an array of selection values as an array of (string) option indices. */
23
+ export declare function formatSelectionValuesAsOptionIndices<T>(arrayValue: T[] | null | undefined, options: {
24
+ value: T;
25
+ }[]): string[];
26
+ /**
27
+ * Transforms option objects into React nodes.
28
+ *
29
+ * @param options Option objects.
30
+ * @returns React nodes representing the objects.
31
+ */
32
+ export declare function optionObjectsToNodes<T>(options: (OptionsGroupObject<T> | OptionObject<T>)[]): React.JSX.Element[];
@@ -0,0 +1,32 @@
1
+ import { type Controller } from "@ostack.tech/kform-react";
2
+ import * as React from "react";
3
+ /**
4
+ * Function used to scroll an element into view.
5
+ *
6
+ * @param el Element to scroll into view.
7
+ * @param options Scroll into view options.
8
+ */
9
+ export type ScrollIntoViewFn = (el: HTMLElement, options?: ScrollIntoViewOptions) => void;
10
+ /**
11
+ * Hook used to autofocus a control when the active path changes, given the
12
+ * control's path.
13
+ *
14
+ * @param controller Control's controller.
15
+ * @param enabled Whether to enable the auto-focus behaviour.
16
+ * @returns Reference that should be set on the focusable element of the
17
+ * control.
18
+ */
19
+ export declare function useControlAutofocus<T = unknown, TElem extends HTMLElement = HTMLElement>({ usePath, useExists }: Controller<T>, enabled?: boolean): React.MutableRefObject<TElem | null>;
20
+ /**
21
+ * Visibly focuses the provided element.
22
+ *
23
+ * @param el Element to visibly focus.
24
+ * @param options Focus options.
25
+ */
26
+ export declare function visiblyFocus(el: HTMLElement, options?: FocusOptions): void;
27
+ /**
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.
31
+ */
32
+ export declare function useScrollIntoView(): ScrollIntoViewFn;
@@ -0,0 +1,27 @@
1
+ import { type SealedValidationIssue } from "@ostack.tech/kform";
2
+ import * as React from "react";
3
+ import { IssueMessages, type IssueMessagesByCode } from "../components/IssueMessages";
4
+ /** Options of the `useControlIssues` hook. */
5
+ export interface UseControlIssuesOptions {
6
+ /** Mapping from path to issues to display. */
7
+ issuesToDisplay: Record<string, SealedValidationIssue[]>;
8
+ /** Mapping from path to issue messages by code. */
9
+ issueMessages?: Record<string, IssueMessagesByCode | undefined>;
10
+ /** Whether issues should be displayed. */
11
+ displayIssues?: boolean;
12
+ /** Properties to pass to the `IssueMessages` component. */
13
+ issueMessagesProps?: Omit<React.ComponentPropsWithRef<typeof IssueMessages>, "path" | "issues" | "messages" | "unwrapped">;
14
+ }
15
+ /**
16
+ * Hook which helps a control component render its issues.
17
+ *
18
+ * This hook returns a pair containing two React nodes:
19
+ *
20
+ * - The first element of the pair contains the node that should be rendered when
21
+ * the issues are to appear inline. This will be `null` if the issues should
22
+ * not appear inline.
23
+ * - The second element of the pair contains the node that should be rendered when
24
+ * the issues are to appear within a popover. This will be `null` if the
25
+ * issues should not appear in a popover.
26
+ */
27
+ export declare function useControlIssues({ issuesToDisplay, issueMessages, displayIssues, issueMessagesProps, }: UseControlIssuesOptions): [React.ReactNode, React.ReactNode];
@@ -0,0 +1 @@
1
+ export declare function useEqualityFn<TState, TResult>(selector: (state: TState) => TResult, equalityFn?: (v1: TResult, v2: TResult) => boolean): (state: TState) => TResult;
@@ -0,0 +1,83 @@
1
+ import { AbsolutePath } from "@ostack.tech/kform";
2
+ import { type FileSystemHandle, type FileWithHandle, type WellKnownDirectory } from "browser-fs-access";
3
+ import * as React from "react";
4
+ /**
5
+ * Options that can be passed to the {@link useFormLoader} hook, or to its
6
+ * resulting `load` function.
7
+ */
8
+ export interface FormLoaderOptions<T = unknown> {
9
+ /**
10
+ * Function used to decode the form, given its file.
11
+ *
12
+ * If decoding a text-based format, one may use `await file.text()` to get the
13
+ * content of the file as a string.
14
+ *
15
+ * @param file File containing the form to decode.
16
+ * @returns Decoded form value.
17
+ */
18
+ decode?: (file: FileWithHandle) => PromiseLike<T>;
19
+ /**
20
+ * Path of the value being loaded.
21
+ *
22
+ * @default AbsolutePath.ROOT
23
+ */
24
+ path?: string | AbsolutePath;
25
+ /** Acceptable file extensions. */
26
+ extensions?: string[];
27
+ /** Acceptable MIME types. */
28
+ mimeTypes?: string[];
29
+ /** Suggested file description. */
30
+ description?: string;
31
+ /** Directory to present when starting to load. */
32
+ startIn?: WellKnownDirectory | FileSystemHandle;
33
+ /**
34
+ * By specifying an ID, the user agent can remember different directories for
35
+ * different IDs.
36
+ */
37
+ id?: string;
38
+ /**
39
+ * Whether to set the form as pristine when it is loaded.
40
+ *
41
+ * @default true
42
+ */
43
+ setPristineOnLoad?: boolean;
44
+ /**
45
+ * Whether to validate the form (and show the issues panel) when it is loaded.
46
+ *
47
+ * @default true
48
+ */
49
+ validateOnLoad?: boolean;
50
+ /**
51
+ * Message to show in a toast when successfully loading a form from a file.
52
+ *
53
+ * @param file Loaded file.
54
+ * @returns Message to show in a toast.
55
+ */
56
+ successMessage?: (file: FileWithHandle) => React.ReactNode;
57
+ /**
58
+ * Message to show in a toast when an error occurs while loading the form from
59
+ * a file.
60
+ *
61
+ * @param file File from which the load was attempted (or `null` if the file
62
+ * could not be accessed).
63
+ * @param error Error that occurred.
64
+ * @returns Message to show in a toast.
65
+ */
66
+ errorMessage?: (file: FileWithHandle | null, error: unknown) => React.ReactNode;
67
+ }
68
+ /** Result of the {@link useFormLoader} hook. */
69
+ export interface FormLoaderResult<T> {
70
+ /**
71
+ * Function used to load the form.
72
+ *
73
+ * @param options Options used for loading the form.
74
+ * @returns Promise which resolves once the form has been loaded.
75
+ */
76
+ load: (options?: FormLoaderOptions<T>) => Promise<void>;
77
+ /** Whether the browser supports modern file system APIs used for loading. */
78
+ supportsFileSystemAPIs: boolean;
79
+ }
80
+ /** Hook exposing a function used to load the form from a file. */
81
+ export declare function useFormLoader<T = unknown>({ decode, path, extensions, mimeTypes, description, startIn, id, setPristineOnLoad, validateOnLoad, successMessage, errorMessage, }?: FormLoaderOptions<T>): FormLoaderResult<T>;
82
+ /** Hook exposing whether the form is currently being loaded. */
83
+ export declare function useFormIsLoading(): any;