@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 @@
1
+ export * from "./LoadAction.tsx";
@@ -0,0 +1,45 @@
1
+ import { type Path } from "@ostack.tech/kform";
2
+ import { type Numeric, type NumericInputController, type NumericInputOptions } from "@ostack.tech/kform-react";
3
+ import { NumericInput } from "@ostack.tech/ui";
4
+ import * as React from "react";
5
+ import { type IssueMessages, type IssueMessagesByCode } from "../IssueMessages";
6
+ /** Properties of the numeric control component. */
7
+ export interface NumericControlProps<T extends Numeric | null = Numeric | null> extends Omit<NumericInputOptions<T, string, React.ComponentRef<typeof NumericInput>>, "enabled" | "formatFromString" | "parseToString">, Omit<React.ComponentPropsWithoutRef<typeof NumericInput>, "defaultValue" | "value" | "onValueChange" | "valueIsUnformattedString" | "status"> {
8
+ /** Path to the value. */
9
+ path?: string | Path;
10
+ /**
11
+ * Issue messages of this control.
12
+ *
13
+ * Mapping from an issue's code to its message.
14
+ */
15
+ issueMessages?: IssueMessagesByCode;
16
+ /**
17
+ * Label to use in the issues panel when displaying issues associated with
18
+ * this field.
19
+ *
20
+ * This label has priority over the field's `ControlLabel`.
21
+ */
22
+ issuesPanelLabel?: React.ReactNode;
23
+ /**
24
+ * Whether to display the issues associated with this control.
25
+ *
26
+ * @default true
27
+ */
28
+ displayIssues?: boolean;
29
+ /**
30
+ * Whether to prevent the auto-focusing behaviour that causes this control to
31
+ * be focused when the form app's `focus` is called with this control's path.
32
+ *
33
+ * Preventing this behaviour is useful when multiple controls for the same
34
+ * path are rendered at once, and only one of them should be focused.
35
+ *
36
+ * @default false
37
+ */
38
+ preventAutoFocus?: boolean;
39
+ /** Reference to the control's API. */
40
+ apiRef?: React.Ref<NumericInputController<T, string, React.ComponentRef<typeof NumericInput>> | undefined>;
41
+ /** Properties to pass to the `IssueMessages` component. */
42
+ issueMessagesProps?: Omit<React.ComponentPropsWithRef<typeof IssueMessages>, "path" | "issues" | "messages" | "unwrapped">;
43
+ }
44
+ /** Numeric control component supporting (possibly nullable) numeric schemas. */
45
+ export declare const NumericControl: React.ForwardRefExoticComponent<NumericControlProps<Numeric | null> & React.RefAttributes<HTMLInputElement>>;
@@ -0,0 +1 @@
1
+ export * from "./NumericControl.tsx";
@@ -0,0 +1,16 @@
1
+ import { type AbsolutePath, type Path } from "@ostack.tech/kform";
2
+ import { Link } from "@ostack.tech/ui";
3
+ import React from "react";
4
+ /** Properties of the path link component. */
5
+ export interface PathLinkProps extends Omit<React.ComponentPropsWithoutRef<typeof Link>, "href"> {
6
+ /** KForm path to link to. */
7
+ to: string | Path;
8
+ /**
9
+ * Function used to build the link's `href` from the path.
10
+ *
11
+ * @default (path) => path.toString()
12
+ */
13
+ buildHref?: (path: AbsolutePath) => string;
14
+ }
15
+ /** Link to a KForm path. */
16
+ export declare function PathLink({ to, buildHref, onClick, ...otherProps }: PathLinkProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./PathLink.tsx";
@@ -0,0 +1,56 @@
1
+ import { type Path } from "@ostack.tech/kform";
2
+ import { type InputController, type InputOptions } from "@ostack.tech/kform-react";
3
+ import { Radio, RadioGroup } from "@ostack.tech/ui";
4
+ import * as React from "react";
5
+ import { type IssueMessages, type IssueMessagesByCode } from "../IssueMessages";
6
+ /** Radio in object notation. */
7
+ export type RadioObject<T = unknown> = Omit<React.ComponentPropsWithRef<typeof Radio>, "value" | "children"> & {
8
+ /** Option value. */
9
+ value: T;
10
+ /** Option's rendered text. */
11
+ text?: React.ReactNode;
12
+ /** Option's unique key. */
13
+ key?: React.Key;
14
+ };
15
+ /** Properties of the radio group control component. */
16
+ export interface RadioGroupControlProps<T = unknown> extends Omit<InputOptions<T, string, React.ComponentRef<typeof RadioGroup>>, "enabled" | "format" | "parse">, Omit<React.ComponentPropsWithoutRef<typeof RadioGroup>, "defaultValue" | "value" | "onValueChange" | "children" | "status"> {
17
+ /** Path to the value. */
18
+ path?: string | Path;
19
+ /** RadioGroup control options. */
20
+ options: RadioObject<T>[];
21
+ /**
22
+ * Issue messages of this control.
23
+ *
24
+ * Mapping from an issue's code to its message.
25
+ */
26
+ issueMessages?: IssueMessagesByCode;
27
+ /**
28
+ * Label to use in the issues panel when displaying issues associated with
29
+ * this field.
30
+ *
31
+ * This label has priority over the field's `ControlLabel`.
32
+ */
33
+ issuesPanelLabel?: React.ReactNode;
34
+ /**
35
+ * Whether to display the issues associated with this control.
36
+ *
37
+ * @default true
38
+ */
39
+ displayIssues?: boolean;
40
+ /**
41
+ * Whether to prevent the auto-focusing behaviour that causes this control to
42
+ * be focused when the form app's `focus` is called with this control's path.
43
+ *
44
+ * Preventing this behaviour is useful when multiple controls for the same
45
+ * path are rendered at once, and only one of them should be focused.
46
+ *
47
+ * @default false
48
+ */
49
+ preventAutoFocus?: boolean;
50
+ /** Reference to the control's API. */
51
+ apiRef?: React.Ref<InputController<T, string, React.ComponentRef<typeof RadioGroup>> | undefined>;
52
+ /** Properties to pass to the `IssueMessages` component. */
53
+ issueMessagesProps?: Omit<React.ComponentPropsWithRef<typeof IssueMessages>, "path" | "issues" | "messages" | "unwrapped">;
54
+ }
55
+ /** Radio group control component supporting schemas of any type. */
56
+ export declare const RadioGroupControl: React.ForwardRefExoticComponent<RadioGroupControlProps<unknown> & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1 @@
1
+ export * from "./RadioGroupControl.tsx";
@@ -0,0 +1,51 @@
1
+ import { type ButtonProps, DropdownMenuContent, IconButton } from "@ostack.tech/ui";
2
+ import * as React from "react";
3
+ import { type FormSaverOptions } from "../../utils/useFormSaver.tsx";
4
+ /** Properties of the save action. */
5
+ export interface SaveActionProps<T = unknown> extends Omit<ButtonProps, "children">, Omit<FormSaverOptions<T>, "overwrite"> {
6
+ /** Action's label. */
7
+ label?: React.ReactNode;
8
+ /**
9
+ * Keybinds for triggering the action. Set to `null` to disable the keyboard
10
+ * shortcut.
11
+ *
12
+ * Keyboard handling is built on top of the
13
+ * [`tinykeys`](https://jamiebuilds.github.io/tinykeys) library. For
14
+ * information on keybinding syntax, read the [`tinykeys`
15
+ * documentation](https://github.com/jamiebuilds/tinykeys).
16
+ *
17
+ * Defaults to the keybinds defined by the current locale.
18
+ */
19
+ keybinds?: string | string[] | null;
20
+ /**
21
+ * Whether to disable the overwriting behaviour of the “save” button. When
22
+ * set, the “save” button will function as the “save as” button and the “save
23
+ * as” button will not be rendered.
24
+ *
25
+ * This property only affects browsers that support modern file system APIs,
26
+ * since other browsers already function in the above-mentioned way.
27
+ */
28
+ disableOverwrite?: boolean;
29
+ /** Label of the save options button. */
30
+ saveOptionsLabel?: React.ReactNode;
31
+ /** Label of the action's "save as" sub-action. */
32
+ saveAsLabel?: React.ReactNode;
33
+ /**
34
+ * Keybinds for triggering the "save as" sub-action. Set to `null` to disable
35
+ * the keyboard shortcut.
36
+ *
37
+ * Keyboard handling is built on top of the
38
+ * [`tinykeys`](https://jamiebuilds.github.io/tinykeys) library. For
39
+ * information on keybinding syntax, read the [`tinykeys`
40
+ * documentation](https://github.com/jamiebuilds/tinykeys).
41
+ *
42
+ * Defaults to the keybinds defined by the current locale.
43
+ */
44
+ saveAsKeybinds?: string | string[] | null;
45
+ /** Properties to pass to the save options button component. */
46
+ saveOptionsProps?: Omit<Partial<React.ComponentPropsWithRef<typeof IconButton>>, "label">;
47
+ /** Properties to pass to the save options dropdown menu component. */
48
+ dropdownMenuProps?: React.ComponentPropsWithRef<typeof DropdownMenuContent>;
49
+ }
50
+ /** Action used to save the form to a file. */
51
+ export declare function SaveAction<T = unknown>({ label, keybinds, disableOverwrite, saveOptionsLabel, saveAsLabel, saveAsKeybinds, loading, disabled, onClick, variant, color, path, encode, fileName, extensions, description, mimeTypes, startIn, excludeAcceptAllOption, id, successMessage, errorMessage, saveOptionsProps, dropdownMenuProps, ...otherProps }: SaveActionProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./SaveAction.tsx";
@@ -0,0 +1,48 @@
1
+ import { type Path } from "@ostack.tech/kform";
2
+ import { type InputController, type InputOptions } from "@ostack.tech/kform-react";
3
+ import { Select } from "@ostack.tech/ui";
4
+ import * as React from "react";
5
+ import { type OptionObject, type OptionsGroupObject } from "../../utils/options.ts";
6
+ import { type IssueMessages, type IssueMessagesByCode } from "../IssueMessages";
7
+ /** Properties of the select control component. */
8
+ export interface SelectControlProps<T = unknown> extends Omit<InputOptions<T, string, React.ComponentRef<typeof Select>>, "enabled" | "format" | "parse">, Omit<React.ComponentPropsWithoutRef<typeof Select>, "multiple" | "defaultValue" | "value" | "onValueChange" | "children" | "status"> {
9
+ /** Path to the value. */
10
+ path?: string | Path;
11
+ /** Select control options. */
12
+ options: (OptionsGroupObject<T> | OptionObject<T>)[];
13
+ /**
14
+ * Issue messages of this control.
15
+ *
16
+ * Mapping from an issue's code to its message.
17
+ */
18
+ issueMessages?: IssueMessagesByCode;
19
+ /**
20
+ * Label to use in the issues panel when displaying issues associated with
21
+ * this field.
22
+ *
23
+ * This label has priority over the field's `ControlLabel`.
24
+ */
25
+ issuesPanelLabel?: React.ReactNode;
26
+ /**
27
+ * Whether to display the issues associated with this control.
28
+ *
29
+ * @default true
30
+ */
31
+ displayIssues?: boolean;
32
+ /**
33
+ * Whether to prevent the auto-focusing behaviour that causes this control to
34
+ * be focused when the form app's `focus` is called with this control's path.
35
+ *
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.
38
+ *
39
+ * @default false
40
+ */
41
+ preventAutoFocus?: boolean;
42
+ /** Reference to the control's API. */
43
+ apiRef?: React.Ref<InputController<T, string, React.ComponentRef<typeof Select>> | undefined>;
44
+ /** Properties to pass to the `IssueMessages` component. */
45
+ issueMessagesProps?: Omit<React.ComponentPropsWithRef<typeof IssueMessages>, "path" | "issues" | "messages" | "unwrapped">;
46
+ }
47
+ /** Select control component supporting schemas of any type. */
48
+ export declare const SelectControl: React.ForwardRefExoticComponent<SelectControlProps<unknown> & React.RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1 @@
1
+ export * from "./SelectControl.tsx";
@@ -0,0 +1,55 @@
1
+ import { type Path } from "@ostack.tech/kform";
2
+ import { type Listable, type ListableInputController, type ListableInputOptions } from "@ostack.tech/kform-react";
3
+ import { Select } from "@ostack.tech/ui";
4
+ import * as React from "react";
5
+ import { type OptionObject, type OptionsGroupObject } from "../../utils/options.ts";
6
+ import { type IssueMessages, type IssueMessagesByCode } from "../IssueMessages";
7
+ /** Properties of the select multiple control component. */
8
+ export interface SelectMultipleControlProps<T = unknown, TListable extends Listable<T> | null = Listable<T> | null> extends Omit<ListableInputOptions<T, TListable, string[], React.ComponentRef<typeof Select>>, "enabled" | "formatFromArray" | "parseToArray">, Omit<React.ComponentPropsWithoutRef<typeof Select>, "multiple" | "defaultValue" | "value" | "onValueChange" | "children" | "status"> {
9
+ /** Path to the value. */
10
+ path?: string | Path;
11
+ /**
12
+ * Issue messages of this control.
13
+ *
14
+ * Mapping from an issue's code to its message.
15
+ */
16
+ issueMessages?: IssueMessagesByCode;
17
+ /**
18
+ * Label to use in the issues panel when displaying issues associated with
19
+ * this field.
20
+ *
21
+ * This label has priority over the field's `ControlLabel`.
22
+ */
23
+ issuesPanelLabel?: React.ReactNode;
24
+ /**
25
+ * Whether to display the issues associated with this control.
26
+ *
27
+ * @default true
28
+ */
29
+ displayIssues?: boolean;
30
+ /** Select multiple control options. */
31
+ options: (OptionsGroupObject<T> | OptionObject<T>)[];
32
+ /**
33
+ * Whether to prevent the auto-focusing behaviour that causes this control to
34
+ * be focused when the form app's `focus` is called with this control's path.
35
+ *
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.
38
+ *
39
+ * @default false
40
+ */
41
+ preventAutoFocus?: boolean;
42
+ /** Reference to the control's API. */
43
+ apiRef?: React.Ref<ListableInputController<T, TListable, string[], React.ComponentRef<typeof Select>> | undefined>;
44
+ /** Properties to pass to the `IssueMessages` component. */
45
+ issueMessagesProps?: Omit<React.ComponentPropsWithRef<typeof IssueMessages>, "path" | "issues" | "messages" | "unwrapped">;
46
+ }
47
+ /**
48
+ * Select multiple control component supporting (possibly nullable) listable
49
+ * schemas with elements of any type.
50
+ *
51
+ * If the schema is nullable, this component sets the form value to `null` when
52
+ * the control contains no elements. Note, however, that the form may still hold
53
+ * an empty listable as value if set programmatically.
54
+ */
55
+ export declare const SelectMultipleControl: React.ForwardRefExoticComponent<SelectMultipleControlProps<unknown, Listable<unknown> | null> & React.RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1 @@
1
+ export * from "./SelectMultipleControl.tsx";
@@ -0,0 +1,94 @@
1
+ import { type LocatedValidationWarning } from "@ostack.tech/kform";
2
+ import { type SubmitOptions } from "@ostack.tech/kform-react";
3
+ import { Alert, AlertDialogBody, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, Button, type ButtonProps, Checkbox } from "@ostack.tech/ui";
4
+ import * as React from "react";
5
+ /** Properties of the submit action. */
6
+ export interface SubmitActionProps<T = unknown, TSubmitResult = unknown> extends Omit<ButtonProps, "children" | "onSubmit">, Pick<Required<SubmitOptions<T, TSubmitResult>>, "onSubmit">, Omit<SubmitOptions<T, TSubmitResult>, "onSubmit"> {
7
+ /** Action's label. */
8
+ label?: React.ReactNode;
9
+ /**
10
+ * Keybinds for triggering the action. Set to `null` to disable the keyboard
11
+ * shortcut.
12
+ *
13
+ * Keyboard handling is built on top of the
14
+ * [`tinykeys`](https://jamiebuilds.github.io/tinykeys) library. For
15
+ * information on keybinding syntax, read the [`tinykeys`
16
+ * documentation](https://github.com/jamiebuilds/tinykeys).
17
+ *
18
+ * Defaults to the keybinds defined by the current locale.
19
+ */
20
+ keybinds?: string | string[] | null;
21
+ /**
22
+ * Whether users should confirm (by ticking a checkbox) that the submission
23
+ * should proceed whenever the form contains warnings.
24
+ *
25
+ * @default true
26
+ */
27
+ confirmWarnings?: boolean;
28
+ /** Title of the confirmation dialog which appears when submitting the form. */
29
+ dialogTitle?: React.ReactNode | ((formValue: T, warnings?: LocatedValidationWarning[]) => React.ReactNode);
30
+ /**
31
+ * Description of the confirmation dialog which appears when submitting the
32
+ * form.
33
+ */
34
+ dialogDescription?: React.ReactNode | ((formValue: T, warnings?: LocatedValidationWarning[]) => React.ReactNode);
35
+ /**
36
+ * Body of the confirmation dialog which appears when submitting the form.
37
+ *
38
+ * This property can be used to display a summary of the data being submitted
39
+ * and will be displayed between the description and the “confirm warnings
40
+ * alert”, when it exists.
41
+ */
42
+ dialogBody?: React.ReactNode | ((formValue: T, warnings?: LocatedValidationWarning[]) => React.ReactNode);
43
+ /**
44
+ * Label of the checkbox which prompts users to confirm that they intend to
45
+ * proceed with submission in the event of warnings in the form.
46
+ */
47
+ confirmWarningsCheckboxLabel?: React.ReactNode;
48
+ /**
49
+ * Text of the OK button in the confirmation dialog which appears when
50
+ * submitting the form.
51
+ */
52
+ dialogOkText?: React.ReactNode;
53
+ /**
54
+ * Text of the cancel button in the confirmation dialog which appears when
55
+ * submitting the form.
56
+ */
57
+ dialogCancelText?: React.ReactNode;
58
+ /**
59
+ * Message to show in a toast after a successful submission.
60
+ *
61
+ * @param submitResult Result of `onSubmit`.
62
+ * @returns Message to show in a toast.
63
+ */
64
+ successMessage?: (submitResult: TSubmitResult) => React.ReactNode;
65
+ /**
66
+ * Message to show in a toast when an error occurs while submitting the form.
67
+ *
68
+ * @param error Error that occurred.
69
+ * @returns Message to show in a toast.
70
+ */
71
+ errorMessage?: (error: unknown) => React.ReactNode;
72
+ /** Properties to pass to the confirmation dialog content component. */
73
+ dialogContentProps?: Omit<React.ComponentPropsWithRef<typeof AlertDialogContent>, "children">;
74
+ /** Properties to pass to the confirmation dialog header component. */
75
+ dialogHeaderProps?: Omit<React.ComponentPropsWithRef<typeof AlertDialogHeader>, "children">;
76
+ /** Properties to pass to the confirmation dialog title component. */
77
+ dialogTitleProps?: Omit<React.ComponentPropsWithRef<typeof AlertDialogTitle>, "children">;
78
+ /** Properties to pass to the confirmation dialog body component. */
79
+ dialogBodyProps?: Omit<React.ComponentPropsWithRef<typeof AlertDialogBody>, "children">;
80
+ /** Properties to pass to the confirmation dialog description component. */
81
+ dialogDescriptionProps?: Omit<React.ComponentPropsWithRef<typeof AlertDialogDescription>, "children">;
82
+ /** Properties to pass to the confirmation dialog footer component. */
83
+ dialogFooterProps?: Omit<React.ComponentPropsWithRef<typeof AlertDialogFooter>, "children">;
84
+ /** Properties to pass to the confirmation dialog OK button component. */
85
+ dialogOkButtonProps?: Omit<React.ComponentPropsWithRef<typeof Button>, "children">;
86
+ /** Properties to pass to the confirmation dialog cancel button component. */
87
+ dialogCancelButtonProps?: Omit<React.ComponentPropsWithRef<typeof Button>, "children">;
88
+ /** Properties to pass to the alert used to confirm warnings. */
89
+ confirmWarningsAlertProps?: Omit<React.ComponentPropsWithRef<typeof Alert>, "children">;
90
+ /** Properties to pass to the checkbox used to confirm warnings. */
91
+ confirmWarningsCheckboxProps?: Omit<React.ComponentPropsWithRef<typeof Checkbox>, "checked" | "onCheckedChange" | "children">;
92
+ }
93
+ /** Action used to submit the form. */
94
+ export declare function SubmitAction<T = unknown, TSubmitResult = unknown>({ onSubmit, onInvalidSubmit, onSuccessfulSubmit, onFailedSubmit, setTouchedOnSubmit, validateOnSubmit, setPristineOnSuccessfulSubmit, convertExternalIssuesTableRowIndicesToIds, label, keybinds, confirmWarnings, loading, disabled, onClick, dialogTitle, dialogDescription, dialogBody, confirmWarningsCheckboxLabel, dialogOkText, dialogCancelText, successMessage, errorMessage, dialogContentProps, dialogHeaderProps, dialogTitleProps, dialogBodyProps, dialogDescriptionProps, dialogFooterProps, dialogOkButtonProps, dialogCancelButtonProps, confirmWarningsAlertProps, confirmWarningsCheckboxProps, ...otherProps }: SubmitActionProps<T, TSubmitResult>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./SubmitAction.tsx";
@@ -0,0 +1,64 @@
1
+ import { type Path, type Table } from "@ostack.tech/kform";
2
+ import { type ControllerOptions } from "@ostack.tech/kform-react";
3
+ import { DataTable } from "@ostack.tech/ui";
4
+ import * as React from "react";
5
+ import { type IssueMessages, type IssueMessagesByCode } from "../IssueMessages";
6
+ import { type TableControlApi } from "./TableControlApi.ts";
7
+ import { type TableControlColumn, type TableControlColumns } from "./TableControlColumn.tsx";
8
+ /** Properties of the table control component. */
9
+ export interface TableControlProps<T = unknown, TTable extends Table<T> | null = Table<T> | null> extends Omit<React.ComponentPropsWithoutRef<typeof DataTable>, "columns" | "rows" | "getRows" | "rowKey" | "loading" | "defaultFilter" | "filter" | "onFilterChange" | "defaultSortBy" | "sortBy" | "defaultSortDirection" | "sortDirection" | "onSort" | "showSelectionColumn" | "defaultSelectedRows" | "selectedRows" | "onSelectedRowsChange" | "apiRef">, Omit<ControllerOptions<TTable>, "enabled"> {
10
+ /** Control's path. */
11
+ path?: string | Path;
12
+ /**
13
+ * Issue messages of this control.
14
+ *
15
+ * Mapping from an issue's code to its message.
16
+ */
17
+ issueMessages?: IssueMessagesByCode;
18
+ /**
19
+ * Label to use in the issues panel when displaying issues associated with
20
+ * this table.
21
+ *
22
+ * This label has priority over the table's `ControlLabel`.
23
+ */
24
+ issuesPanelLabel?: React.ReactNode;
25
+ /**
26
+ * Whether to display the issues associated with this control.
27
+ *
28
+ * @default true
29
+ */
30
+ displayIssues?: boolean;
31
+ /** Table control columns. */
32
+ columns: TableControlColumns<T>;
33
+ /**
34
+ * Sets the maximum number of rows that the table can have. By default, if the
35
+ * table's schema has a `MaxSize` validation, then its value is used.
36
+ */
37
+ maxRows?: number;
38
+ /** Sets the table control as disabled. */
39
+ disabled?: boolean;
40
+ /** Sets the table control as read-only. */
41
+ readOnly?: boolean;
42
+ /**
43
+ * Whether to prevent the auto-focusing behaviour that causes this control to
44
+ * be focused when the form app's `focus` is called with this control's path.
45
+ *
46
+ * Preventing this behaviour is useful when multiple controls for the same
47
+ * path are rendered at once, and only one of them should be focused.
48
+ *
49
+ * @default false
50
+ */
51
+ preventAutoFocus?: boolean;
52
+ /** Reference to the control's API. */
53
+ apiRef?: React.Ref<TableControlApi<T, TTable> | undefined>;
54
+ /** Properties to pass to the `IssueMessages` component. */
55
+ issueMessagesProps?: Omit<React.ComponentPropsWithRef<typeof IssueMessages>, "path" | "issues" | "messages" | "unwrapped">;
56
+ }
57
+ /** Table control component supporting (possibly nullable) collection schemas. */
58
+ export declare const TableControl: React.ForwardRefExoticComponent<TableControlProps<unknown, Table<unknown> | null> & React.RefAttributes<HTMLTableElement>>;
59
+ /** Properties of the table control cell renderer. */
60
+ export interface TableControlCellRendererProps<T = unknown> {
61
+ render: NonNullable<TableControlColumn<T>["render"]>;
62
+ }
63
+ /** Renderer of a table control cell. */
64
+ export declare function TableControlCellRenderer<T = unknown>({ render, }: TableControlCellRendererProps<T>): React.ReactNode;
@@ -0,0 +1,25 @@
1
+ import { Button } from "@ostack.tech/ui";
2
+ import * as React from "react";
3
+ /** Properties of the table control add row trigger component. */
4
+ export interface TableControlAddRowTriggerProps extends React.ComponentPropsWithoutRef<typeof Button> {
5
+ /**
6
+ * Text displayed on the button rendered by default when no `children` are
7
+ * provided. If `children` are provided, this property has no effect.
8
+ */
9
+ defaultButtonText?: React.ReactNode;
10
+ /** Function called after the row has been added. */
11
+ onRowAdded?: () => void;
12
+ /**
13
+ * Whether to show the trigger when the table is read-only.
14
+ *
15
+ * @default false
16
+ */
17
+ showWhenReadOnly?: boolean;
18
+ }
19
+ /**
20
+ * Trigger used to add a new row to a table control.
21
+ *
22
+ * By default, it renders a button with text `defaultButtonText`, however, this
23
+ * can be overriden by providing `children`.
24
+ */
25
+ export declare const TableControlAddRowTrigger: React.ForwardRefExoticComponent<TableControlAddRowTriggerProps & React.RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,25 @@
1
+ import { type Table, type TableRowId } from "@ostack.tech/kform";
2
+ import { type Controller } from "@ostack.tech/kform-react";
3
+ import { type DataTableScrollToOptions } from "@ostack.tech/ui";
4
+ import * as React from "react";
5
+ /** Imperative table control API. */
6
+ export type TableControlApi<T = unknown, TTable extends Table<T> | null = Table<T> | null> = Controller<TTable> & {
7
+ /**
8
+ * Navigates to the row with the provided index.
9
+ *
10
+ * @param index Index of row to navigate to.
11
+ * @param scrollOptions Options used to configure to scrolling to the row
12
+ * (only relevant in scrolled display mode).
13
+ */
14
+ goToIndex: (index: number, scrollOptions?: DataTableScrollToOptions) => void;
15
+ /**
16
+ * Navigates to the row with the provided id.
17
+ *
18
+ * @param id Id of row to navigate to.
19
+ * @param scrollOptions Options used to configure to scrolling to the row
20
+ * (only relevant in scrolled display mode).
21
+ */
22
+ goToId: (id: TableRowId, scrollOptions?: DataTableScrollToOptions) => void;
23
+ };
24
+ /** Hook used to access the table control API. */
25
+ export declare function useTableControlApiRef<T = unknown, TTable extends Table<T> | null = Table<T> | null>(): React.RefObject<TableControlApi<T, TTable> | null>;
@@ -0,0 +1,7 @@
1
+ import { DataTableCell } from "@ostack.tech/ui";
2
+ import * as React from "react";
3
+ /** Properties of the table control cell. */
4
+ export interface TableControlCellProps extends React.ComponentPropsWithoutRef<typeof DataTableCell> {
5
+ }
6
+ /** Cell of the table control. */
7
+ export declare const TableControlCell: React.ForwardRefExoticComponent<TableControlCellProps & React.RefAttributes<HTMLTableDataCellElement>>;
@@ -0,0 +1,58 @@
1
+ import { type Controller } from "@ostack.tech/kform-react";
2
+ import { type DataTableColumn } from "@ostack.tech/ui";
3
+ import * as React from "react";
4
+ import { TableControlRemoveRowTrigger } from "./TableControlRemoveRowTrigger.tsx";
5
+ /** Array of table control columns. */
6
+ export type TableControlColumns<T = unknown> = (TableControlColumn<T> | ((tableControlStatus: TableControlStatus) => TableControlColumn<T> | false | null | undefined) | false | null | undefined)[];
7
+ /** Status of the table control. */
8
+ export interface TableControlStatus {
9
+ /** Whether the table control is disabled. */
10
+ disabled: boolean;
11
+ /** Whether the table control is read-only. */
12
+ readOnly: boolean;
13
+ }
14
+ /** Controller of a table row. */
15
+ export type TableControlRowController<T = unknown> = Controller<T> & {
16
+ /** Row index. */
17
+ index: number;
18
+ };
19
+ /** Column of a table control. */
20
+ export interface TableControlColumn<T = unknown, TValue = any> extends Omit<DataTableColumn<T, TValue>, "subColumns" | "getValue" | "format" | "render" | "compare" | "filterable" | "sortable"> {
21
+ /** Sub columns of this column. */
22
+ subColumns?: TableControlColumns<T>;
23
+ /** Function used to render the cell's content. */
24
+ render?: (rowController: TableControlRowController<T>) => React.ReactNode;
25
+ }
26
+ /**
27
+ * Pre-configured column used to display the index of each row. By default, it
28
+ * sticks to left of the table.
29
+ *
30
+ * @param overrides Column properties to override the defaults.
31
+ * @returns Table control column used to display the index of each row.
32
+ */
33
+ export declare function tableControlIndexColumn<T = unknown, TValue = any>(overrides?: TableControlColumn<T, TValue>): TableControlColumn<T, TValue>;
34
+ /**
35
+ * Pre-configured column used to display row actions. By default, it sticks to
36
+ * the right of the table and renders the `TableControlRemoveRow` component.
37
+ *
38
+ * Its configuration can be overriden to show other actions, for example, an
39
+ * edit button:
40
+ *
41
+ * ```typescript
42
+ * tableControlActionsColumn({
43
+ * width: 100,
44
+ * render: () => (
45
+ * <>
46
+ * <IconButton label="Edit row" icon={faPencil} />
47
+ * <TableControlRemoveRow />
48
+ * </>
49
+ * ),
50
+ * });
51
+ * ```
52
+ *
53
+ * @param overrides Column properties used to display the actions of each row.
54
+ * @returns Table control column used to display the actions of each row.
55
+ */
56
+ export declare function tableControlActionsColumn<T = unknown, TValue = any>({ removeRowProps, ...columnOverrides }?: TableControlColumn<T, TValue> & {
57
+ removeRowProps?: React.ComponentPropsWithRef<typeof TableControlRemoveRowTrigger>;
58
+ }): (tableControlStatus: TableControlStatus) => TableControlColumn<T, TValue> | false;
@@ -0,0 +1,7 @@
1
+ import { DataTableContent } from "@ostack.tech/ui";
2
+ import * as React from "react";
3
+ /** Properties of the table control content component. */
4
+ export interface TableControlContentProps extends Omit<React.ComponentPropsWithoutRef<typeof DataTableContent>, "status"> {
5
+ }
6
+ /** Component containing the content of the table control. */
7
+ export declare const TableControlContent: React.ForwardRefExoticComponent<TableControlContentProps & React.RefAttributes<HTMLTableElement>>;
@@ -0,0 +1,26 @@
1
+ import { type AbsolutePath, type Table, type TableRowId } from "@ostack.tech/kform";
2
+ import { type FormatterController } from "@ostack.tech/kform-react";
3
+ import * as React from "react";
4
+ import { type UseRegisterControlResult } from "../../utils/useRegisterControl.tsx";
5
+ import { type TableControlRowController } from "./TableControlColumn.tsx";
6
+ /** Value of the table control context. */
7
+ export interface TableControlContextValue<T = any, TTable extends Table<T> | null = Table<T> | null> {
8
+ controller: TableControlController<T, TTable>;
9
+ autofocusRef: React.Ref<HTMLDivElement>;
10
+ handleFocus: UseRegisterControlResult<HTMLDivElement>["handleFocus"];
11
+ size?: number;
12
+ maxRows?: number;
13
+ }
14
+ /** Controller of the table control. */
15
+ export type TableControlController<T = any, TTable extends Table<T> | null = Table<T> | null> = FormatterController<TTable, TableRowId[]> & {
16
+ addRow: () => PromiseLike<void> | void;
17
+ removeRow: (path: AbsolutePath) => PromiseLike<void> | void;
18
+ };
19
+ /** Table control context. */
20
+ export declare const TableControlContext: React.Context<TableControlContextValue<any, Table<any> | null> | null>;
21
+ /** Hook providing access to the table control context. */
22
+ export declare function useTableControlContext<T = unknown, TTable extends Table<T> | null = Table<T> | null>(): TableControlContextValue<T, TTable>;
23
+ /** Table control row context. */
24
+ export declare const TableControlRowContext: React.Context<TableControlRowController | null>;
25
+ /** Hook providing access to the table control row context. */
26
+ export declare function useTableControlRowContext<T>(): TableControlRowController<T>;
@@ -0,0 +1,2 @@
1
+ /** Table control pagination. */
2
+ export declare const TableControlPagination: import("react").ForwardRefExoticComponent<import("@ostack.tech/ui").DataTablePaginationProps & import("react").RefAttributes<HTMLDivElement>>;