@ostack.tech/ui-kform 0.15.5 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/chunks/{en-CaLvO1z0.js → en-CKrk2smU.js} +14 -5
  2. package/dist/chunks/en-CKrk2smU.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 +21 -12
  6. package/dist/locales/fr-FR.js.map +1 -1
  7. package/dist/locales/pt-PT.js +13 -4
  8. package/dist/locales/pt-PT.js.map +1 -1
  9. package/dist/ostack-ui-kform.css +13 -0
  10. package/dist/ostack-ui-kform.js +1806 -709
  11. package/dist/ostack-ui-kform.js.map +1 -1
  12. package/package.json +6 -5
  13. package/scss/_utils.scss +1 -0
  14. package/scss/components/FormPages/_FormPages.scss +8 -0
  15. package/scss/components/SubmitAction/_SubmitAction-variables.scss +3 -0
  16. package/scss/components/SubmitAction/_SubmitAction.scss +13 -0
  17. package/scss/index.scss +1 -0
  18. package/types/components/Annexes/Annex.d.ts +71 -7
  19. package/types/components/Annexes/Annexes.d.ts +49 -65
  20. package/types/components/Annexes/AnnexesContext.d.ts +2 -1
  21. package/types/components/Annexes/AnnexesManager.d.ts +15 -10
  22. package/types/components/Annexes/AnnexesMenu.d.ts +5 -6
  23. package/types/components/Annexes/AnnexesTabList.d.ts +3 -4
  24. package/types/components/CheckboxControl/CheckboxControl.d.ts +38 -9
  25. package/types/components/CheckboxGroupControl/CheckboxGroupControl.d.ts +64 -22
  26. package/types/components/CheckboxGroupControl/CheckboxGroupControlItem.d.ts +26 -0
  27. package/types/components/CheckboxGroupControl/index.d.ts +1 -0
  28. package/types/components/ControlField/ControlField.d.ts +3 -4
  29. package/types/components/DateControl/DateControl.d.ts +38 -8
  30. package/types/components/DateRangeControl/DateRangeControl.d.ts +56 -24
  31. package/types/components/DebugInfo/DebugInfo.d.ts +26 -0
  32. package/types/components/DebugInfo/DebugInfoControlAddonTrigger.d.ts +9 -0
  33. package/types/components/DebugInfo/index.d.ts +2 -0
  34. package/types/components/FileControl/FileControl.d.ts +37 -8
  35. package/types/components/FileControl/FileControlDownloadAddon.d.ts +8 -0
  36. package/types/components/FileControl/FileControlViewAddon.d.ts +10 -0
  37. package/types/components/FormApp/FormApp.d.ts +60 -139
  38. package/types/components/FormApp/FormAppContext.d.ts +13 -3
  39. package/types/components/FormApp/FormAppElement.d.ts +3 -3
  40. package/types/components/FormApp/index.d.ts +1 -1
  41. package/types/components/FormPages/FormPage.d.ts +38 -20
  42. package/types/components/FormPages/FormPageHeader.d.ts +3 -3
  43. package/types/components/FormPages/FormPages.d.ts +45 -24
  44. package/types/components/FormPages/FormPagesContext.d.ts +2 -1
  45. package/types/components/FormPages/FormPagesNavigation.d.ts +11 -8
  46. package/types/components/FormPages/FormPagesSelect.d.ts +1 -1
  47. package/types/components/FormPages/FormPagesSidebar.d.ts +3 -3
  48. package/types/components/FormStepper/FormStep.d.ts +23 -7
  49. package/types/components/FormStepper/FormStepList.d.ts +3 -4
  50. package/types/components/FormStepper/FormStepper.d.ts +52 -21
  51. package/types/components/FormStepper/FormStepperContext.d.ts +2 -1
  52. package/types/components/FormStepper/FormStepperFinishTrigger.d.ts +4 -1
  53. package/types/components/FormStepper/FormStepperNextTrigger.d.ts +4 -1
  54. package/types/components/FormStepper/FormStepperPreviousTrigger.d.ts +4 -1
  55. package/types/components/FormStepper/FormStepperState.d.ts +3 -1
  56. package/types/components/IssueMessage/IssueMessage.d.ts +2 -2
  57. package/types/components/IssueMessages/IssueMessages.d.ts +4 -4
  58. package/types/components/IssuesAlert/IssuesAlert.d.ts +4 -5
  59. package/types/components/IssuesPanel/IssuesPanel.d.ts +18 -18
  60. package/types/components/IssuesPanel/IssuesPanelMessagesCard.d.ts +4 -4
  61. package/types/components/IssuesPanel/IssuesPanelSummaryCard.d.ts +4 -4
  62. package/types/components/IssuesPopover/IssuesPopover.d.ts +3 -4
  63. package/types/components/LoadAction/LoadAction.d.ts +34 -4
  64. package/types/components/NumericControl/NumericControl.d.ts +56 -8
  65. package/types/components/PathLink/PathLink.d.ts +2 -2
  66. package/types/components/PrintAction/PrintAction.d.ts +41 -16
  67. package/types/components/RadioGroupControl/RadioGroupControl.d.ts +54 -19
  68. package/types/components/RadioGroupControl/RadioGroupControlItem.d.ts +25 -0
  69. package/types/components/RadioGroupControl/index.d.ts +1 -0
  70. package/types/components/SaveAction/SaveAction.d.ts +45 -7
  71. package/types/components/SelectControl/SelectControl.d.ts +55 -10
  72. package/types/components/SelectControl/SelectControlItem.d.ts +23 -0
  73. package/types/components/SelectControl/SelectControlItemGroup.d.ts +23 -0
  74. package/types/components/SelectControl/index.d.ts +2 -0
  75. package/types/components/SelectMultipleControl/SelectMultipleControl.d.ts +71 -14
  76. package/types/components/SelectMultipleControl/SelectMultipleControlItem.d.ts +13 -0
  77. package/types/components/SelectMultipleControl/SelectMultipleControlItemGroup.d.ts +13 -0
  78. package/types/components/SelectMultipleControl/index.d.ts +2 -0
  79. package/types/components/SubmitAction/SubmitAction.d.ts +50 -14
  80. package/types/components/TableControl/TableControl.d.ts +108 -13
  81. package/types/components/TableControl/TableControlActionsColumn.d.ts +21 -0
  82. package/types/components/TableControl/TableControlActionsColumnLabel.d.ts +2 -0
  83. package/types/components/TableControl/TableControlAddRowTrigger.d.ts +12 -5
  84. package/types/components/TableControl/TableControlCell.d.ts +3 -4
  85. package/types/components/TableControl/TableControlColumn.d.ts +24 -56
  86. package/types/components/TableControl/TableControlColumnFns.d.ts +113 -0
  87. package/types/components/TableControl/TableControlColumnGroup.d.ts +25 -0
  88. package/types/components/TableControl/TableControlColumns.d.ts +14 -0
  89. package/types/components/TableControl/TableControlContent.d.ts +3 -4
  90. package/types/components/TableControl/TableControlContext.d.ts +2 -1
  91. package/types/components/TableControl/TableControlIndexColumn.d.ts +10 -0
  92. package/types/components/TableControl/TableControlIndexColumnLabel.d.ts +2 -0
  93. package/types/components/TableControl/TableControlPagination.d.ts +4 -1
  94. package/types/components/TableControl/TableControlRemoveRowTrigger.d.ts +5 -5
  95. package/types/components/TableControl/TableControlRow.d.ts +11 -4
  96. package/types/components/TableControl/TableControlRowsPerPage.d.ts +4 -1
  97. package/types/components/TableControl/index.d.ts +6 -0
  98. package/types/components/TextControl/TextControl.d.ts +47 -21
  99. package/types/components/TopBar/TopBar.d.ts +3 -3
  100. package/types/components/TopBar/TopBarActions.d.ts +3 -4
  101. package/types/components/ValidateAction/ValidateAction.d.ts +24 -2
  102. package/types/index.d.ts +1 -0
  103. package/types/providers/LocalizationProvider/LocalizationObject.d.ts +5 -1
  104. package/types/utils/__tests__/pathSpecificity.test.d.ts +1 -0
  105. package/types/utils/options.d.ts +13 -18
  106. package/types/utils/promiseUtils.d.ts +7 -0
  107. package/types/utils/selectionTransformations.d.ts +9 -9
  108. package/types/utils/useControlIssues.d.ts +21 -19
  109. package/types/utils/useFormLoader.d.ts +7 -1
  110. package/types/utils/useFormSaver.d.ts +3 -3
  111. package/dist/chunks/en-CaLvO1z0.js.map +0 -1
@@ -1,15 +1,16 @@
1
1
  import type { Path } from "@ostack.tech/kform";
2
2
  import { type InputController, type InputOptions } from "@ostack.tech/kform-react";
3
- import { Select } from "@ostack.tech/ui";
4
- import { type ComponentPropsWithoutRef, type ComponentPropsWithRef, type ComponentRef, type ReactNode, type Ref } from "react";
5
- import type { OptionObject, OptionsGroupObject } from "../../utils/options.ts";
6
- import type { IssueMessages, IssueMessagesByCode } from "../IssueMessages";
3
+ import { Select, type SelectProps } from "@ostack.tech/ui";
4
+ import { type ComponentRef, type ReactNode, type Ref } from "react";
5
+ import type { IssueMessagesByCode, IssueMessagesProps } from "../IssueMessages";
6
+ import { type SelectControlItemObject } from "./SelectControlItem.tsx";
7
+ import { type SelectControlItemGroupObject } from "./SelectControlItemGroup.tsx";
7
8
  /** Properties of the select control component. */
8
- export interface SelectControlProps<T = unknown> extends Omit<InputOptions<T, T, ComponentRef<typeof Select>>, "enabled" | "format" | "parse">, Omit<ComponentPropsWithoutRef<typeof Select>, "multiple" | "defaultValue" | "value" | "onValueChange" | "children" | "status" | "validate" | "validationMode"> {
9
+ export interface SelectControlProps<T = unknown> extends Omit<InputOptions<T, T, ComponentRef<typeof Select>>, "enabled" | "format" | "parse">, Omit<SelectProps, "multiple" | "defaultValue" | "value" | "onValueChange" | "maxSelected" | "children" | "status" | "validate" | "validationMode"> {
9
10
  /** Path to the value. */
10
11
  path?: string | Path;
11
12
  /** Select control options. */
12
- options: (OptionsGroupObject<T> | OptionObject<T>)[];
13
+ options?: (SelectControlItemGroupObject<T> | SelectControlItemObject<T>)[];
13
14
  /**
14
15
  * Issue messages of this control.
15
16
  *
@@ -20,7 +21,7 @@ export interface SelectControlProps<T = unknown> extends Omit<InputOptions<T, T,
20
21
  * Label to use in the issues panel when displaying issues associated with
21
22
  * this field.
22
23
  *
23
- * This label has priority over the field's `ControlLabel`.
24
+ * This label has priority over the field's `Label`.
24
25
  */
25
26
  issuesPanelLabel?: ReactNode;
26
27
  /**
@@ -41,10 +42,54 @@ export interface SelectControlProps<T = unknown> extends Omit<InputOptions<T, T,
41
42
  * @default false
42
43
  */
43
44
  preventAutoFocus?: boolean;
45
+ /** Select control children. */
46
+ children?: ReactNode;
47
+ /**
48
+ * Whether to show debug information. This property has no effect in
49
+ * production builds.
50
+ */
51
+ debug?: boolean;
44
52
  /** Reference to the control's API. */
45
53
  apiRef?: Ref<InputController<T, string, ComponentRef<typeof Select>> | undefined>;
46
54
  /** Properties to pass to the `IssueMessages` component. */
47
- issueMessagesProps?: Omit<ComponentPropsWithRef<typeof IssueMessages>, "path" | "issues" | "messages" | "unwrapped">;
55
+ issueMessagesProps?: Omit<IssueMessagesProps, "path" | "issues" | "messages" | "unwrapped">;
48
56
  }
49
- /** Select control component supporting schemas of any type. */
50
- export declare const SelectControl: import("react").ForwardRefExoticComponent<SelectControlProps<unknown> & import("react").RefAttributes<HTMLButtonElement>>;
57
+ /**
58
+ * The select control component is a KForm form control for values with any type
59
+ * of (typically
60
+ * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))
61
+ * schema. It is built on top of the
62
+ * [`Select`](/docs/ostack-ui-forms-select--docs) component.
63
+ *
64
+ * It composes the following subcomponents:
65
+ *
66
+ * - `SelectControlItem`: Component used to define an item of the select control.
67
+ * - `SelectControlItemGroup`: Component used to define a group of items of the
68
+ * select control.
69
+ *
70
+ * The following built-in KForm validation affects this control:
71
+ *
72
+ * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):
73
+ * Sets the `required` property.
74
+ *
75
+ * Example usage:
76
+ *
77
+ * ```tsx
78
+ * import { SelectControl, SelectControlItem } from "@ostack.tech/ui-kform";
79
+ *
80
+ * function ShirtSizeControl() {
81
+ * return (
82
+ * <SelectControl
83
+ * path="/shirtSize"
84
+ * placeholder="Select your shirt size…"
85
+ * >
86
+ * <SelectControlItem value="sm">Small</SelectControlItem>
87
+ * <SelectControlItem value="md">Medium</SelectControlItem>
88
+ * <SelectControlItem value="lg">Large</SelectControlItem>
89
+ * <SelectControlItem value="xl">X-Large</SelectControlItem>
90
+ * </SelectControl>
91
+ * );
92
+ * }
93
+ * ```
94
+ */
95
+ export declare function SelectControl<T = unknown>({ path, options: groupedOptions, issueMessages, issuesPanelLabel, displayIssues, unknownValueLabel, preventAutoFocus, apiRef, issueMessagesProps, formManager, onInitialized, onFormManagerEvent, onValueChange, onValidationStatusChange, onDisplayStatusChange, onDirtyStatusChange, onTouchedStatusChange, required, loading, showSpinner, disabled, readOnly, showClearButton, endAdornment, onFocus, onBlurToOutside, children, debug, ref, ...otherProps }: SelectControlProps<T>): import("react").JSX.Element;
@@ -0,0 +1,23 @@
1
+ import type { OptionProps } from "@ostack.tech/ui";
2
+ import type { Key, ReactNode } from "react";
3
+ /** Select control item in object notation. */
4
+ export interface SelectControlItemObject<T = unknown> extends Omit<OptionProps, "value" | "children"> {
5
+ /** Item value. */
6
+ value: T;
7
+ /** Item's rendered text. */
8
+ text?: ReactNode;
9
+ /** Item's unique key. */
10
+ key?: Key;
11
+ }
12
+ /** Properties of the select control item component. */
13
+ export interface SelectControlItemProps<T = unknown> extends Omit<SelectControlItemObject<T>, "text"> {
14
+ /** Item's rendered text. */
15
+ children?: ReactNode;
16
+ }
17
+ /**
18
+ * Definition of a select control item.
19
+ *
20
+ * This component doesn't actually render anything by itself; it is used by the
21
+ * `SelectControl` component to automatically create the `options` array.
22
+ */
23
+ export declare function SelectControlItem(_props: SelectControlItemProps): null;
@@ -0,0 +1,23 @@
1
+ import type { OptionProps } from "@ostack.tech/ui";
2
+ import type { Key, ReactNode } from "react";
3
+ import type { SelectControlItemObject } from "./SelectControlItem.tsx";
4
+ /** Select control item group in object notation. */
5
+ export interface SelectControlItemGroupObject<T = unknown> extends Omit<OptionProps, "value" | "children"> {
6
+ /** Group's options. */
7
+ options: SelectControlItemObject<T>[];
8
+ /** Group's unique key. */
9
+ key?: Key;
10
+ }
11
+ /** Properties of the select control item group component. */
12
+ export interface SelectControlItemGroupProps<T = unknown> extends Omit<SelectControlItemGroupObject<T>, "options"> {
13
+ /** Group's children. */
14
+ children?: ReactNode;
15
+ }
16
+ /**
17
+ * Definition of a select control item group.
18
+ *
19
+ * This component doesn't actually render anything by itself; it is used by the
20
+ * `SelectControl` component to automatically create groups of items in the
21
+ * `options` array.
22
+ */
23
+ export declare function SelectControlItemGroup(_props: SelectControlItemGroupProps): null;
@@ -1 +1,3 @@
1
1
  export * from "./SelectControl.tsx";
2
+ export * from "./SelectControlItem.tsx";
3
+ export * from "./SelectControlItemGroup.tsx";
@@ -1,15 +1,16 @@
1
1
  import type { Path } from "@ostack.tech/kform";
2
2
  import { type Listable, type ListableInputController, type ListableInputOptions } from "@ostack.tech/kform-react";
3
- import { Select } from "@ostack.tech/ui";
4
- import { type ComponentPropsWithoutRef, type ComponentPropsWithRef, type ComponentRef, type ReactNode, type Ref } from "react";
5
- import type { OptionObject, OptionsGroupObject } from "../../utils/options.ts";
6
- import type { IssueMessages, IssueMessagesByCode } from "../IssueMessages";
3
+ import { Select, type SelectProps } from "@ostack.tech/ui";
4
+ import { type ComponentRef, type ReactNode, type Ref } from "react";
5
+ import type { IssueMessagesByCode, IssueMessagesProps } from "../IssueMessages";
6
+ import { type SelectMultipleControlItemObject } from "./SelectMultipleControlItem.tsx";
7
+ import { type SelectMultipleControlItemGroupObject } from "./SelectMultipleControlItemGroup.tsx";
7
8
  /** 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, T[] | null, ComponentRef<typeof Select>>, "enabled" | "formatFromArray" | "parseToArray">, Omit<ComponentPropsWithoutRef<typeof Select>, "multiple" | "defaultValue" | "value" | "onValueChange" | "children" | "status" | "validate" | "validationMode"> {
9
+ export interface SelectMultipleControlProps<T = unknown, TListable extends Listable<T> | null = Listable<T> | null> extends Omit<ListableInputOptions<T, TListable, readonly T[] | null, ComponentRef<typeof Select>>, "enabled" | "formatFromArray" | "parseToArray">, Omit<SelectProps, "multiple" | "defaultValue" | "value" | "onValueChange" | "children" | "status" | "validate" | "validationMode"> {
9
10
  /** Path to the value. */
10
11
  path?: string | Path;
11
12
  /** Select multiple control options. */
12
- options: (OptionsGroupObject<T> | OptionObject<T>)[];
13
+ options?: (SelectMultipleControlItemGroupObject<T> | SelectMultipleControlItemObject<T>)[];
13
14
  /**
14
15
  * Issue messages of this control.
15
16
  *
@@ -20,7 +21,7 @@ export interface SelectMultipleControlProps<T = unknown, TListable extends Lista
20
21
  * Label to use in the issues panel when displaying issues associated with
21
22
  * this field.
22
23
  *
23
- * This label has priority over the field's `ControlLabel`.
24
+ * This label has priority over the field's `Label`.
24
25
  */
25
26
  issuesPanelLabel?: ReactNode;
26
27
  /**
@@ -41,17 +42,73 @@ export interface SelectMultipleControlProps<T = unknown, TListable extends Lista
41
42
  * @default false
42
43
  */
43
44
  preventAutoFocus?: boolean;
45
+ /** Select multiple control children. */
46
+ children?: ReactNode;
47
+ /**
48
+ * Whether to show debug information. This property has no effect in
49
+ * production builds.
50
+ */
51
+ debug?: boolean;
44
52
  /** Reference to the control's API. */
45
53
  apiRef?: Ref<ListableInputController<T, TListable, string[], ComponentRef<typeof Select>> | undefined>;
46
54
  /** Properties to pass to the `IssueMessages` component. */
47
- issueMessagesProps?: Omit<ComponentPropsWithRef<typeof IssueMessages>, "path" | "issues" | "messages" | "unwrapped">;
55
+ issueMessagesProps?: Omit<IssueMessagesProps, "path" | "issues" | "messages" | "unwrapped">;
48
56
  }
49
57
  /**
50
- * Select multiple control component supporting (possibly nullable) listable
51
- * schemas with elements of any type.
58
+ * The select multiple control component is a KForm form control for values with
59
+ * (possibly
60
+ * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))
61
+ * schemas of type
62
+ * [`ListSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-list-schema/index.html)
63
+ * or
64
+ * [`TableSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-table-schema/index.html)
65
+ * and items of any type. It is built on top of the
66
+ * [`Select`](/docs/ostack-ui-forms-select--docs) component with the `multiple`
67
+ * property set.
68
+ *
69
+ * It composes the following subcomponents:
70
+ *
71
+ * - `SelectMultipleControlItem`: Component used to define an item of the select
72
+ * multiple control.
73
+ * - `SelectMultipleControlItemGroup`: Component used to define a group of items
74
+ * of the select multiple control.
75
+ *
76
+ * The following built-in KForm validations affect this control:
77
+ *
78
+ * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):
79
+ * Sets the `required` property.
80
+ * - [`Size`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-size/index.html)/[`MaxSize`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-size/index.html):
81
+ * Sets the `maxSelected` property.
82
+ *
83
+ * Example usage:
84
+ *
85
+ * ```tsx
86
+ * import {
87
+ * SelectMultipleControl,
88
+ * SelectMultipleControlItem,
89
+ * } from "@ostack.tech/ui-kform";
52
90
  *
53
- * If the schema is nullable, this component sets the form value to `null` when
54
- * the control contains no elements. Note, however, that the form may still hold
55
- * an empty listable as value if set programmatically.
91
+ * function SpokenLanguagesControl() {
92
+ * return (
93
+ * <SelectMultipleControl
94
+ * path="/spokenLanguages"
95
+ * placeholder="Select your spoken languages…"
96
+ * >
97
+ * <SelectMultipleControlItem value="en">
98
+ * English
99
+ * </SelectMultipleControlItem>
100
+ * <SelectMultipleControlItem value="fr">
101
+ * French
102
+ * </SelectMultipleControlItem>
103
+ * <SelectMultipleControlItem value="pt">
104
+ * Portuguese
105
+ * </SelectMultipleControlItem>
106
+ * <SelectMultipleControlItem value="es">
107
+ * Spanish
108
+ * </SelectMultipleControlItem>
109
+ * </SelectMultipleControl>
110
+ * );
111
+ * }
112
+ * ```
56
113
  */
57
- export declare const SelectMultipleControl: import("react").ForwardRefExoticComponent<SelectMultipleControlProps<unknown, Listable<unknown> | null> & import("react").RefAttributes<HTMLButtonElement>>;
114
+ export declare function SelectMultipleControl<T = unknown, TListable extends Listable<T> | null = Listable<T> | null>({ path, options: groupedOptions, issueMessages, issuesPanelLabel, displayIssues, unknownValueLabel, preventAutoFocus, apiRef, issueMessagesProps, formManager, onInitialized, onFormManagerEvent, onValueChange, onValidationStatusChange, onDisplayStatusChange, onDirtyStatusChange, onTouchedStatusChange, required, maxSelected, loading, showSpinner, disabled, readOnly, endAdornment, onFocus, onBlurToOutside, children, debug, ref, ...otherProps }: SelectMultipleControlProps<T, TListable>): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import type { SelectControlItemObject, SelectControlItemProps } from "../SelectControl";
2
+ /** Select multiple control item in object notation. */
3
+ export type SelectMultipleControlItemObject<T = unknown> = SelectControlItemObject<T>;
4
+ /** Properties of the select multiple control item component. */
5
+ export type SelectMultipleControlItemProps<T = unknown> = SelectControlItemProps<T>;
6
+ /**
7
+ * Definition of a select multiple control item.
8
+ *
9
+ * This component doesn't actually render anything by itself; it is used by the
10
+ * `SelectMultipleControl` component to automatically create the `options`
11
+ * array.
12
+ */
13
+ export declare function SelectMultipleControlItem(_props: SelectMultipleControlItemProps): null;
@@ -0,0 +1,13 @@
1
+ import type { SelectControlItemGroupObject, SelectControlItemGroupProps } from "../SelectControl";
2
+ /** Select multiple control item group in object notation. */
3
+ export type SelectMultipleControlItemGroupObject<T = unknown> = SelectControlItemGroupObject<T>;
4
+ /** Properties of the select multiple control item group component. */
5
+ export type SelectMultipleControlItemGroupProps<T = unknown> = SelectControlItemGroupProps<T>;
6
+ /**
7
+ * Definition of a select multiple control item group.
8
+ *
9
+ * This component doesn't actually render anything by itself; it is used by the
10
+ * `SelectMultipleControl` component to automatically create groups of items in
11
+ * the `options` array.
12
+ */
13
+ export declare function SelectMultipleControlItemGroup(_props: SelectMultipleControlItemGroupProps): null;
@@ -1 +1,3 @@
1
1
  export * from "./SelectMultipleControl.tsx";
2
+ export * from "./SelectMultipleControlItem.tsx";
3
+ export * from "./SelectMultipleControlItemGroup.tsx";
@@ -1,7 +1,7 @@
1
1
  import { type LocatedValidationWarning } from "@ostack.tech/kform";
2
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 { type ComponentPropsWithRef, type ReactNode } from "react";
3
+ import { type AlertDialogBodyProps, type AlertDialogContentProps, type AlertDialogDescriptionProps, type AlertDialogFooterProps, type AlertDialogHeaderProps, type AlertDialogTitleProps, type AlertProps, type ButtonProps, type CheckboxProps } from "@ostack.tech/ui";
4
+ import { type ReactNode } from "react";
5
5
  /** Default “submit” keybinds. */
6
6
  export declare const DEFAULT_SUBMIT_KEYBINDS = "$mod+Enter";
7
7
  /** Properties of the submit action. */
@@ -21,6 +21,12 @@ export interface SubmitActionProps<T = unknown, TSubmitResult = unknown> extends
21
21
  * `DEFAULT_SUBMIT_KEYBINDS`.
22
22
  */
23
23
  keybinds?: string | string[] | null;
24
+ /**
25
+ * Whether to show the submit action when the form is read-only.
26
+ *
27
+ * @default false
28
+ */
29
+ showWhenReadOnly?: boolean;
24
30
  /**
25
31
  * Whether users should confirm (by ticking a checkbox) that the submission
26
32
  * should proceed whenever the form contains warnings.
@@ -75,25 +81,55 @@ export interface SubmitActionProps<T = unknown, TSubmitResult = unknown> extends
75
81
  */
76
82
  errorMessage?: ReactNode | ((error: unknown) => ReactNode);
77
83
  /** Properties to pass to the confirmation dialog content component. */
78
- dialogContentProps?: Omit<ComponentPropsWithRef<typeof AlertDialogContent>, "children">;
84
+ dialogContentProps?: Omit<AlertDialogContentProps, "children">;
79
85
  /** Properties to pass to the confirmation dialog header component. */
80
- dialogHeaderProps?: Omit<ComponentPropsWithRef<typeof AlertDialogHeader>, "children">;
86
+ dialogHeaderProps?: Omit<AlertDialogHeaderProps, "children">;
81
87
  /** Properties to pass to the confirmation dialog title component. */
82
- dialogTitleProps?: Omit<ComponentPropsWithRef<typeof AlertDialogTitle>, "children">;
88
+ dialogTitleProps?: Omit<AlertDialogTitleProps, "children">;
83
89
  /** Properties to pass to the confirmation dialog body component. */
84
- dialogBodyProps?: Omit<ComponentPropsWithRef<typeof AlertDialogBody>, "children">;
90
+ dialogBodyProps?: Omit<AlertDialogBodyProps, "children">;
85
91
  /** Properties to pass to the confirmation dialog description component. */
86
- dialogDescriptionProps?: Omit<ComponentPropsWithRef<typeof AlertDialogDescription>, "children">;
92
+ dialogDescriptionProps?: Omit<AlertDialogDescriptionProps, "children">;
87
93
  /** Properties to pass to the confirmation dialog footer component. */
88
- dialogFooterProps?: Omit<ComponentPropsWithRef<typeof AlertDialogFooter>, "children">;
94
+ dialogFooterProps?: Omit<AlertDialogFooterProps, "children">;
89
95
  /** Properties to pass to the confirmation dialog OK button component. */
90
- dialogOkButtonProps?: Omit<ComponentPropsWithRef<typeof Button<"button">>, "children">;
96
+ dialogOkButtonProps?: Omit<ButtonProps, "children">;
91
97
  /** Properties to pass to the confirmation dialog cancel button component. */
92
- dialogCancelButtonProps?: Omit<ComponentPropsWithRef<typeof Button<"button">>, "children">;
98
+ dialogCancelButtonProps?: Omit<ButtonProps, "children">;
93
99
  /** Properties to pass to the alert used to confirm warnings. */
94
- confirmWarningsAlertProps?: Omit<ComponentPropsWithRef<typeof Alert>, "children">;
100
+ confirmWarningsAlertProps?: Omit<AlertProps, "children">;
95
101
  /** Properties to pass to the checkbox used to confirm warnings. */
96
- confirmWarningsCheckboxProps?: Omit<ComponentPropsWithRef<typeof Checkbox>, "checked" | "onCheckedChange" | "children">;
102
+ confirmWarningsCheckboxProps?: Omit<CheckboxProps, "checked" | "onCheckedChange" | "children">;
97
103
  }
98
- /** Action used to submit the form. */
99
- 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.Element;
104
+ /**
105
+ * Form action used to submit a form, supporting all submission-related
106
+ * properties available in a
107
+ * [`FormApp`](/docs/ostack-ui-kform-layout-form-app--docs). Built on top of the
108
+ * [Button](/docs/ostack-ui-forms-button--docs) and
109
+ * [AlertDialog](/docs/ostack-ui-overlay-alert-dialog--docs) components.
110
+ *
111
+ * Example usage:
112
+ *
113
+ * ```tsx
114
+ * import { SubmitAction } from "@ostack.tech/ui-kform";
115
+ *
116
+ * function SubmitForm() {
117
+ * return (
118
+ * <SubmitAction
119
+ * onSubmit={async (formValue, warnings) => {
120
+ * const response = await submitForm(formValue, warnings);
121
+ * if (response instanceof FormSubmitSuccess) {
122
+ * return response.redirectTo;
123
+ * } else if (response instanceof FormSubmitValidationError) {
124
+ * return response.issues;
125
+ * } else {
126
+ * throw new Error(response.errorMessage);
127
+ * }
128
+ * }}
129
+ * onSuccessfulSubmit={(redirectTo) => navigate(redirectTo)}
130
+ * />
131
+ * );
132
+ * }
133
+ * ```
134
+ */
135
+ export declare function SubmitAction<T = unknown, TSubmitResult = unknown>({ onSubmit, onInvalidSubmit, onSuccessfulSubmit, onFailedSubmit, setTouchedOnSubmit, validateOnSubmit, setPristineOnSuccessfulSubmit, convertExternalIssuesTableRowIndicesToIds, label, keybinds, showWhenReadOnly, confirmWarnings, loading, disabled, onClick, dialogTitle, dialogDescription, dialogBody, confirmWarningsCheckboxLabel, dialogOkText, dialogCancelText, successMessage: successMessageProp, errorMessage: errorMessageProp, dialogContentProps, dialogHeaderProps, dialogTitleProps, dialogBodyProps, dialogDescriptionProps, dialogFooterProps, dialogOkButtonProps, dialogCancelButtonProps, confirmWarningsAlertProps, confirmWarningsCheckboxProps, ...otherProps }: SubmitActionProps<T, TSubmitResult>): false | import("react").JSX.Element | undefined;
@@ -1,14 +1,20 @@
1
1
  import { type Path, type Table } from "@ostack.tech/kform";
2
2
  import { type ControllerOptions } from "@ostack.tech/kform-react";
3
- import { DataTable } from "@ostack.tech/ui";
4
- import { type ComponentPropsWithoutRef, type ComponentPropsWithRef, type ReactNode, type Ref } from "react";
5
- import type { IssueMessages, IssueMessagesByCode } from "../IssueMessages";
3
+ import { type DataTableProps } from "@ostack.tech/ui";
4
+ import { type ReactNode, type Ref } from "react";
5
+ import type { IssueMessagesByCode, IssueMessagesProps } from "../IssueMessages";
6
6
  import type { TableControlApi } from "./TableControlApi.ts";
7
- import type { TableControlColumn, TableControlColumns } from "./TableControlColumn.tsx";
7
+ import { type TableControlColumnObject } from "./TableControlColumn.tsx";
8
+ import { type TableControlColumnGroupObject } from "./TableControlColumnGroup.tsx";
9
+ import { type TableControlRowController } from "./TableControlRow.tsx";
10
+ /** Array of table control columns. */
11
+ export type TableControlColumnObjects<T = unknown> = (TableControlColumnObject<T> | TableControlColumnGroupObject<T>)[];
8
12
  /** Properties of the table control component. */
9
- export interface TableControlProps<T = unknown, TTable extends Table<T> | null = Table<T> | null> extends Omit<ComponentPropsWithoutRef<typeof DataTable>, "columns" | "rows" | "onVisibleRowsChange" | "onProcessedRowsChange" | "getRows" | "rowKey" | "loading" | "defaultFilter" | "filter" | "onFilterChange" | "defaultSortBy" | "sortBy" | "defaultSortDirection" | "sortDirection" | "onSort" | "showSelectionColumn" | "selectionMode" | "defaultSelectedRows" | "selectedRows" | "onSelectedRowsChange" | "selectAllChecked" | "onSelectAll" | "showAllRowsWhilePrinting" | "apiRef">, Omit<ControllerOptions<TTable>, "enabled"> {
13
+ export interface TableControlProps<T = unknown, TTable extends Table<T> | null = Table<T> | null> extends Omit<DataTableProps, "columns" | "rows" | "onVisibleRowsChange" | "onProcessedRowsChange" | "getRows" | "rowKey" | "loading" | "defaultFilter" | "filter" | "onFilterChange" | "defaultSortBy" | "sortBy" | "defaultSortDirection" | "sortDirection" | "onSort" | "showSelectionColumn" | "selectionMode" | "defaultSelectedRows" | "selectedRows" | "onSelectedRowsChange" | "selectAllChecked" | "onSelectAll" | "showAllRowsWhilePrinting" | "apiRef">, Omit<ControllerOptions<TTable>, "enabled"> {
10
14
  /** Control's path. */
11
15
  path?: string | Path;
16
+ /** Table control columns in object notation. */
17
+ columns?: TableControlColumnObjects<T>;
12
18
  /**
13
19
  * Issue messages of this control.
14
20
  *
@@ -19,7 +25,7 @@ export interface TableControlProps<T = unknown, TTable extends Table<T> | null =
19
25
  * Label to use in the issues panel when displaying issues associated with
20
26
  * this table.
21
27
  *
22
- * This label has priority over the table's `ControlLabel`.
28
+ * This label has priority over the table's `Label`.
23
29
  */
24
30
  issuesPanelLabel?: ReactNode;
25
31
  /**
@@ -28,13 +34,30 @@ export interface TableControlProps<T = unknown, TTable extends Table<T> | null =
28
34
  * @default true
29
35
  */
30
36
  displayIssues?: boolean;
31
- /** Table control columns. */
32
- columns: TableControlColumns<T>;
33
37
  /**
34
38
  * 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.
39
+ * table's schema has a `Size` or `MaxSize` validation, then its value is
40
+ * used.
36
41
  */
37
42
  maxRows?: number;
43
+ /**
44
+ * Function called when a row is being added to choose the value that should
45
+ * be added.
46
+ *
47
+ * The default value being added is provided as an argument and may be edited
48
+ * if required.
49
+ *
50
+ * The value to be added should be returned, or a promise that resolves with
51
+ * said value.
52
+ *
53
+ * To prevent a row from being added, return `undefined`/`null` (or a promise
54
+ * which resolves with `undefined`/`null`).
55
+ *
56
+ * @param value - Value being added, can be edited.
57
+ * @returns Value to be added, `undefined`/`null` if the row shouldn't be
58
+ * added (or a promise that resolves with said values).
59
+ */
60
+ getRowValue?: (value: T) => T | null | undefined | PromiseLike<T | null | undefined>;
38
61
  /** Sets the table control as disabled. */
39
62
  disabled?: boolean;
40
63
  /** Sets the table control as read-only. */
@@ -49,16 +72,88 @@ export interface TableControlProps<T = unknown, TTable extends Table<T> | null =
49
72
  * @default false
50
73
  */
51
74
  preventAutoFocus?: boolean;
75
+ /**
76
+ * Whether to show debug information. This property has no effect in
77
+ * production builds.
78
+ */
79
+ debug?: boolean;
52
80
  /** Reference to the control's API. */
53
81
  apiRef?: Ref<TableControlApi<T, TTable> | undefined>;
54
82
  /** Properties to pass to the `IssueMessages` component. */
55
- issueMessagesProps?: Omit<ComponentPropsWithRef<typeof IssueMessages>, "path" | "issues" | "messages" | "unwrapped">;
83
+ issueMessagesProps?: Omit<IssueMessagesProps, "path" | "issues" | "messages" | "unwrapped">;
56
84
  }
57
- /** Table control component supporting (possibly nullable) collection schemas. */
58
- export declare const TableControl: import("react").ForwardRefExoticComponent<TableControlProps<unknown, Table<unknown> | null> & import("react").RefAttributes<HTMLTableElement>>;
85
+ /**
86
+ * The table control component is a KForm form control for values with (possibly
87
+ * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))
88
+ * schemas of type
89
+ * [`TableSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-table-schema/index.html)
90
+ * and items of any type. It is built on top of the
91
+ * [`DataTable`](/docs/ostack-ui-data-display-data-table--docs) component.
92
+ *
93
+ * It composes the following subcomponents:
94
+ *
95
+ * - `TableControlColumns`: Container for the definition of all table control
96
+ * columns and their groups.
97
+ * - `TableControlColumn`: Component used to define a column of the table control.
98
+ * - `TableControlColumnGroup`: Component used to define a column group of the
99
+ * table control.
100
+ * - `TableControlContent`: Main content of the table control, containing the
101
+ * table itself.
102
+ * - `TableControlAddRowTrigger`: Trigger used to add a new row to the table.
103
+ * - `TableControlRemoveRowTrigger`: Trigger used to remove a row from the table.
104
+ * - `DataTablePagination`: Optional pagination component of the table control,
105
+ * showing the current scroll progress in the default `scrolled` mode and
106
+ * allowing the selection of the current page in `paged` mode.
107
+ * - `TableControlRowsPerPage`: Optional component allowing the selection of the
108
+ * number of rows to display per page.
109
+ * - `TableControlIndexColumn`: Built-in column displaying the number of each row.
110
+ * - `TableControlActionsColumn`: Built-in column displaying actions that can be
111
+ * performed on each row; displays a `TableControlRemoveRowTrigger` by
112
+ * default.
113
+ *
114
+ * The following built-in KForm validations affect this control:
115
+ *
116
+ * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):
117
+ * Sets the `required` property.
118
+ * - [`Size`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-size/index.html)/[`MaxSize`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-size/index.html):
119
+ * Sets the `maxRows` properties.
120
+ *
121
+ * Example usage:
122
+ *
123
+ * ```tsx
124
+ * import {
125
+ * NumericControl,
126
+ * TableControl,
127
+ * TableControlActionsColumn,
128
+ * TableControlAddRowTrigger,
129
+ * TableControlColumn,
130
+ * TableControlContent,
131
+ * TextControl,
132
+ * } from "@ostack.tech/ui-kform";
133
+ *
134
+ * function InventoryControl() {
135
+ * return (
136
+ * <TableControl path="/inventory">
137
+ * <TableControlColumns>
138
+ * <TableControlColumn label="Description">
139
+ * <TextControl path="description" />
140
+ * </TableControlColumn>
141
+ * <TableControlColumn label="Quantity">
142
+ * <NumericControl path="quantity" />
143
+ * </TableControlColumn>
144
+ * <TableControlActionsColumn removeRowLabel="Remove item" />
145
+ * </TableControlColumns>
146
+ * <TableControlAddRowTrigger label="Add item" />
147
+ * <TableControlContent caption="Inventory" />
148
+ * </TableControl>
149
+ * );
150
+ * }
151
+ * ```
152
+ */
153
+ export declare function TableControl<T = unknown, TTable extends Table<T> | null = Table<T> | null>({ path, issueMessages, issuesPanelLabel, displayIssues, preventAutoFocus, apiRef, issueMessagesProps, onInitialized, onFormManagerEvent, onValueChange, onValidationStatusChange, onDisplayStatusChange, onDirtyStatusChange, onTouchedStatusChange, columns: columnsProp, required, maxRows, getRowValue, disabled, readOnly, className, debug, children, ...otherProps }: TableControlProps<T, TTable>): import("react").JSX.Element;
59
154
  /** Properties of the table control cell renderer. */
60
155
  export interface TableControlCellRendererProps<T = unknown> {
61
- render: NonNullable<TableControlColumn<T>["render"]>;
156
+ render: (rowController: TableControlRowController<T>) => ReactNode;
62
157
  }
63
158
  /** Renderer of a table control cell. */
64
159
  export declare function TableControlCellRenderer<T = unknown>({ render, }: TableControlCellRendererProps<T>): ReactNode;
@@ -0,0 +1,21 @@
1
+ import { type TableControlColumnObject, type TableControlColumnProps } from "./TableControlColumn.tsx";
2
+ import { type TableControlActionsColumnFnProps } from "./TableControlColumnFns.tsx";
3
+ /** Properties of the table control actions column. */
4
+ export interface TableControlActionsColumnProps extends TableControlColumnProps, Omit<TableControlActionsColumnFnProps, keyof TableControlColumnObject> {
5
+ }
6
+ /**
7
+ * Pre-configured column used to display row actions. By default, it sticks to
8
+ * the right of the table and renders the `TableControlRemoveRowTrigger`
9
+ * component.
10
+ *
11
+ * Its configuration can be overridden to show other actions, e.g. an edit
12
+ * button:
13
+ *
14
+ * ```tsx
15
+ * <TableControlActionsColumn width={100}>
16
+ * <IconButton label="Edit item" icon={faPencil} />
17
+ * <TableControlRemoveRowTrigger label="Remove item" />
18
+ * </TableControlActionsColumn>;
19
+ * ```
20
+ */
21
+ export declare function TableControlActionsColumn({ render, children, ...otherProps }: TableControlActionsColumnProps): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ /** Default label of the table control's actions column. */
2
+ export declare function TableControlActionsColumnLabel(): import("react").ReactNode;
@@ -1,9 +1,16 @@
1
- import { Button } from "@ostack.tech/ui";
2
- import { type ComponentPropsWithoutRef, type ReactNode } from "react";
1
+ import { type ButtonProps } from "@ostack.tech/ui";
2
+ import { type ComponentProps, type ReactNode } from "react";
3
3
  /** Properties of the table control add row trigger component. */
4
4
  export type TableControlAddRowTriggerProps = TableControlAddRowTriggerChildlessProps | TableControlAddRowTriggerChildrenProps;
5
5
  /** Base properties of the table control add row trigger component. */
6
6
  export interface TableControlAddRowTriggerPropsBase {
7
+ /**
8
+ * Whether to disable the trigger (and show a loading button by default) while
9
+ * a row is being added.
10
+ *
11
+ * @default false
12
+ */
13
+ disableWhileAdding?: boolean;
7
14
  /** Function called after the row has been added. */
8
15
  onRowAdded?: () => void;
9
16
  /**
@@ -30,7 +37,7 @@ export interface TableControlAddRowTriggerPropsBase {
30
37
  * Properties of the table control add row trigger component when rendered
31
38
  * without children.
32
39
  */
33
- export interface TableControlAddRowTriggerChildlessProps extends TableControlAddRowTriggerPropsBase, Omit<ComponentPropsWithoutRef<typeof Button<"button">>, "asChild" | "children"> {
40
+ export interface TableControlAddRowTriggerChildlessProps extends TableControlAddRowTriggerPropsBase, Omit<ButtonProps, "asChild" | "children"> {
34
41
  /** Label displayed on the button. */
35
42
  label?: ReactNode;
36
43
  /**
@@ -45,8 +52,8 @@ export interface TableControlAddRowTriggerChildlessProps extends TableControlAdd
45
52
  * Properties of the table control add row trigger component when rendered with
46
53
  * children.
47
54
  */
48
- export interface TableControlAddRowTriggerChildrenProps extends TableControlAddRowTriggerPropsBase, ComponentPropsWithoutRef<"button"> {
55
+ export interface TableControlAddRowTriggerChildrenProps extends TableControlAddRowTriggerPropsBase, ComponentProps<"button"> {
49
56
  children: ReactNode;
50
57
  }
51
58
  /** Trigger used to add a new row to a table control. */
52
- export declare const TableControlAddRowTrigger: import("react").ForwardRefExoticComponent<TableControlAddRowTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
59
+ export declare function TableControlAddRowTrigger({ disableWhileAdding, onRowAdded, preferRightAlignment, showWhenReadOnly, showWhilePrinting, disabled, onClick, className, children, ...otherProps }: TableControlAddRowTriggerProps): import("react").JSX.Element | null;
@@ -1,7 +1,6 @@
1
- import { DataTableCell } from "@ostack.tech/ui";
2
- import { type ComponentPropsWithoutRef } from "react";
1
+ import { type DataTableCellProps } from "@ostack.tech/ui";
3
2
  /** Properties of the table control cell. */
4
- export interface TableControlCellProps extends ComponentPropsWithoutRef<typeof DataTableCell> {
3
+ export interface TableControlCellProps extends DataTableCellProps {
5
4
  }
6
5
  /** Cell of the table control. */
7
- export declare const TableControlCell: import("react").ForwardRefExoticComponent<TableControlCellProps & import("react").RefAttributes<HTMLTableDataCellElement>>;
6
+ export declare function TableControlCell({ variant, ...otherProps }: TableControlCellProps): import("react").JSX.Element;