@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
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ostack.tech/ui-kform",
3
3
  "description": "Integration of ostack/UI with ostack/KForm.",
4
- "version": "0.15.5",
4
+ "version": "0.16.1",
5
5
  "homepage": "https://ui.ostack.tech/",
6
6
  "author": {
7
7
  "name": "Opensoft",
@@ -42,15 +42,16 @@
42
42
  "copy:scss": "cpy 'src/**/*.scss' '!src/**/*.stories.scss' scss/"
43
43
  },
44
44
  "dependencies": {
45
- "browser-fs-access": "^0.38.0"
45
+ "browser-fs-access": "^0.38.0",
46
+ "esm-env": "^1.2.2"
46
47
  },
47
48
  "peerDependencies": {
48
49
  "@fortawesome/fontawesome-svg-core": "^6.2.0 || ^7.0.0",
49
50
  "@fortawesome/free-regular-svg-icons": "^6.2.0 || ^7.0.0",
50
51
  "@fortawesome/free-solid-svg-icons": "^6.2.0 || ^7.0.0",
51
- "@ostack.tech/kform": "~0.36.0",
52
- "@ostack.tech/kform-react": "~0.36.0",
53
- "@ostack.tech/ui": "~0.15.5",
52
+ "@ostack.tech/kform": "~1.0.0-rc.1",
53
+ "@ostack.tech/kform-react": "~1.0.0-rc.1",
54
+ "@ostack.tech/ui": "~0.16.1",
54
55
  "@types/react": "^19.0.0",
55
56
  "@types/react-dom": "^19.0.0",
56
57
  "date-fns": "^4.1.0",
package/scss/_utils.scss CHANGED
@@ -5,5 +5,6 @@
5
5
  @forward "components/FormApp/FormApp-variables";
6
6
  @forward "components/FormPages/FormPages-variables";
7
7
  @forward "components/IssuesPanel/IssuesPanel-variables";
8
+ @forward "components/SubmitAction/SubmitAction-variables";
8
9
  @forward "components/TopBar/TopBar-variables";
9
10
  @forward "components/UnknownValue/UnknownValue-variables";
@@ -158,6 +158,10 @@
158
158
  background-color: var(--#{o-ui.$prefix}accent-9);
159
159
  color: var(--#{o-ui.$prefix}accent-contrast);
160
160
  }
161
+
162
+ &:empty::after {
163
+ content: "\00a0";
164
+ }
161
165
  }
162
166
 
163
167
  &__select-arrow {
@@ -246,6 +250,10 @@
246
250
  background-color: var(--#{o-ui.$prefix}accent-9);
247
251
  color: var(--#{o-ui.$prefix}accent-contrast);
248
252
  }
253
+
254
+ &:empty::after {
255
+ content: "\00a0";
256
+ }
249
257
  }
250
258
 
251
259
  &__page-title {
@@ -0,0 +1,3 @@
1
+ @use "@ostack.tech/ui/scss/utils" as o-ui;
2
+
3
+ $submit-action-dialog-body-gap-y: o-ui.$card-padding-y !default;
@@ -0,0 +1,13 @@
1
+ @use "@ostack.tech/ui/scss/utils" as o-ui;
2
+ @use "SubmitAction-variables" as *;
3
+ @use "../../scss/base-variables" as *;
4
+
5
+ .#{$prefix}submit-action {
6
+ &__dialog-description:not(:last-child) {
7
+ margin-bottom: $submit-action-dialog-body-gap-y;
8
+ }
9
+
10
+ &__confirm-warnings-alert-container:not(:first-child) {
11
+ margin-top: $submit-action-dialog-body-gap-y;
12
+ }
13
+ }
package/scss/index.scss CHANGED
@@ -8,5 +8,6 @@
8
8
  @forward "components/IssueMessages/IssueMessages";
9
9
  @forward "components/IssuesAlert/IssuesAlert";
10
10
  @forward "components/IssuesPanel/IssuesPanel";
11
+ @forward "components/SubmitAction/SubmitAction";
11
12
  @forward "components/TopBar/TopBar";
12
13
  @forward "components/UnknownValue/UnknownValue";
@@ -1,9 +1,73 @@
1
- import { ErrorBoundary, TabContent } from "@ostack.tech/ui";
2
- import { type ComponentPropsWithoutRef, type ComponentPropsWithRef, type ReactNode } from "react";
1
+ import type { Path } from "@ostack.tech/kform";
2
+ import { type ErrorBoundaryProps, type TabContentProps } from "@ostack.tech/ui";
3
+ import { type ComponentProps, type ReactNode } from "react";
3
4
  import type { IssueMessagesByCode } from "../IssueMessages";
4
- import type { AnnexObject } from "./Annexes.tsx";
5
+ /** Object representation of an annex. */
6
+ export interface AnnexObject<T = any> {
7
+ /**
8
+ * Annex path. This path may contain a single wildcard (`*`) at the end, when
9
+ * the elements of a collection should be counted as annexes. Otherwise, the
10
+ * path may contain no other wildcards.
11
+ */
12
+ path?: string | Path;
13
+ /** Annex's title. */
14
+ title?: ReactNode | ((value: T) => ReactNode);
15
+ /** Annex's subtitle. */
16
+ subtitle?: ReactNode | ((value: T, index?: number) => ReactNode);
17
+ /** Annex's description. */
18
+ description?: ReactNode;
19
+ /**
20
+ * Annex's label in the issues panel. The `title` and `subtitle` are used by
21
+ * default.
22
+ */
23
+ issuesPanelLabel?: ReactNode | ((value: T) => ReactNode);
24
+ /**
25
+ * Title of an annex within a collection of annexes. The `title` is used by
26
+ * default.
27
+ */
28
+ itemTitle?: ReactNode | ((value: T, index: number) => ReactNode);
29
+ /**
30
+ * Issues panel label for each annex of a collection of annexes. The
31
+ * `subtitle` and index of the item are used by default.
32
+ */
33
+ itemIssuesPanelLabel?: ReactNode | ((value: T, index: number) => ReactNode);
34
+ /**
35
+ * Title of the annex as a string to display in the document's title.
36
+ *
37
+ * Defaults to the `title` together with the `subtitle` (if it exists) when
38
+ * they are strings.
39
+ *
40
+ * A warning is printed if either the title or the subtitle are defined but
41
+ * aren't strings and `documentTitle` is not provided.
42
+ */
43
+ documentTitle?: string | null | ((value: T, index?: number) => string | null);
44
+ /**
45
+ * Maximum number of annexes matching this path that can be added, when
46
+ * counting collection elements as annexes. By default, if the collection has
47
+ * a `MaxSize` validation, then its value is used.
48
+ */
49
+ maxAnnexes?: number;
50
+ /**
51
+ * Function called when an annex matching this path is being added to choose
52
+ * the value that should be added.
53
+ *
54
+ * The default value being added is provided as an argument and may be edited
55
+ * if required.
56
+ *
57
+ * The value to be added should be returned, or a promise that resolves with
58
+ * said value.
59
+ *
60
+ * To prevent an annex from being added, return `undefined`/`null` (or a
61
+ * promise which resolves with `undefined`/`null`).
62
+ *
63
+ * @param value - Value being added, can be edited.
64
+ * @returns Value to be added, `undefined`/`null` if the annex shouldn't be
65
+ * added (or a promise that resolves with said values).
66
+ */
67
+ getValue?: (value: T) => T | null | undefined | PromiseLike<T | null | undefined>;
68
+ }
5
69
  /** Properties of the annex component. */
6
- export interface AnnexProps extends AnnexObject, Omit<ComponentPropsWithoutRef<typeof TabContent>, "value" | "title" | "children"> {
70
+ export interface AnnexProps extends AnnexObject, Omit<TabContentProps, "value" | "title" | "children"> {
7
71
  /** Sets the annex as disabled. */
8
72
  disabled?: boolean;
9
73
  /** Sets the annex as read-only. */
@@ -37,10 +101,10 @@ export interface AnnexProps extends AnnexObject, Omit<ComponentPropsWithoutRef<t
37
101
  */
38
102
  issueMessages?: Record<string, IssueMessagesByCode>;
39
103
  /** Properties to pass to the container element. */
40
- containerProps?: ComponentPropsWithRef<"div">;
104
+ containerProps?: ComponentProps<"div">;
41
105
  /** Properties to pass to the `ErrorBoundary` component. */
42
- errorBoundaryProps?: ComponentPropsWithRef<typeof ErrorBoundary>;
106
+ errorBoundaryProps?: ErrorBoundaryProps;
43
107
  children?: ReactNode;
44
108
  }
45
109
  /** Component containing the content of an annex. */
46
- export declare const Annex: import("react").ForwardRefExoticComponent<AnnexProps & import("react").RefAttributes<HTMLDivElement>>;
110
+ export declare function Annex({ path, title: _title, subtitle: _subtitle, description: _description, issuesPanelLabel: _issuesPanelLabel, itemTitle: _itemTitle, itemIssuesPanelLabel: _itemIssuesPanelLabel, documentTitle: _documentTitle, maxAnnexes: _maxAnnexes, getValue: _getValue, ref, ...otherProps }: AnnexProps): import("react").JSX.Element[];
@@ -1,8 +1,9 @@
1
1
  import { type AbsolutePath, Path } from "@ostack.tech/kform";
2
- import { Tabs } from "@ostack.tech/ui";
3
- import { type ComponentPropsWithoutRef, type ReactNode } from "react";
2
+ import { type TabsProps } from "@ostack.tech/ui";
3
+ import { type ReactNode } from "react";
4
+ import { type AnnexObject } from "./Annex.tsx";
4
5
  /** Properties of the annexes component. */
5
- export interface AnnexesProps extends Omit<ComponentPropsWithoutRef<typeof Tabs>, "defaultValue" | "value" | "onValueChange" | "showAllTabsWhilePrinting"> {
6
+ export interface AnnexesProps extends Omit<TabsProps, "defaultValue" | "value" | "onValueChange" | "showAllTabsWhilePrinting"> {
6
7
  /** Base path for all declared annexes. */
7
8
  path?: string | Path;
8
9
  /**
@@ -34,65 +35,48 @@ export interface AnnexesProps extends Omit<ComponentPropsWithoutRef<typeof Tabs>
34
35
  onAnnexRemove?: (removedAnnexPath: AbsolutePath) => void;
35
36
  children?: ReactNode;
36
37
  }
37
- /** Object representation of an annex. */
38
- export interface AnnexObject<T = any> {
39
- /**
40
- * Annex path. This path may contain a single wildcard (`*`) at the end, when
41
- * the elements of a collection should be counted as annexes. Otherwise, the
42
- * path may contain no other wildcards.
43
- */
44
- path?: string | Path;
45
- /** Annex's title. */
46
- title?: ReactNode | ((value: T) => ReactNode);
47
- /** Annex's subtitle. */
48
- subtitle?: ReactNode | ((value: T, index?: number) => ReactNode);
49
- /** Annex's description. */
50
- description?: ReactNode;
51
- /**
52
- * Annex's label in the issues panel. The `title` and `subtitle` are used by
53
- * default.
54
- */
55
- issuesPanelLabel?: ReactNode | ((value: T) => ReactNode);
56
- itemTitle?: ReactNode | ((value: T, index: number) => ReactNode);
57
- /**
58
- * Issues panel label for each annex of a collection of annexes. The
59
- * `subtitle` and index of the item are used by default.
60
- */
61
- itemIssuesPanelLabel?: ReactNode | ((value: T, index: number) => ReactNode);
62
- /**
63
- * Title of the annex as a string to display in the document's title.
64
- *
65
- * Defaults to the `title` together with the `subtitle` (if it exists) when
66
- * they are strings.
67
- *
68
- * A warning is printed if either the title or the subtitle are defined but
69
- * aren't strings and `documentTitle` is not provided.
70
- */
71
- documentTitle?: string | null | ((value: T, index?: number) => string | null);
72
- /**
73
- * Maximum number of annexes matching this path that can be added, when
74
- * counting collection elements as annexes. By default, if the collection has
75
- * a `MaxSize` validation, then its value is used.
76
- */
77
- maxAnnexes?: number;
78
- /**
79
- * Function called when an annex matching this path is being added to choose
80
- * the value that should be added.
81
- *
82
- * The default value being added is provided as an argument and may be edited
83
- * if required.
84
- *
85
- * The value to be added should be returned, or a promise that resolves with
86
- * said value.
87
- *
88
- * To prevent an annex from being added, return `undefined`/`null` (or a
89
- * promise which resolves with `undefined`/`null`).
90
- *
91
- * @param value - Value being added, can be edited.
92
- * @returns Value to be added, `undefined`/`null` if the annex shouldn't be
93
- * added (or a promise that resolves with said values).
94
- */
95
- getValue?: (value: T) => T | null | undefined | Promise<T | null | undefined>;
96
- }
97
- /** Root component used to render form annexes. */
98
- export declare const Annexes: import("react").ForwardRefExoticComponent<AnnexesProps & import("react").RefAttributes<HTMLDivElement>>;
38
+ /**
39
+ * The annexes component can be used to split parts of a form into separate
40
+ * annexes (tabs), while providing means of managing and navigating between
41
+ * them. Although not strictly mandatory, each annex (tab) is typically
42
+ * represented by its own class, with its own schema and distinct path.
43
+ *
44
+ * It further supports optional annexes (via
45
+ * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html)
46
+ * schemas), as well as repetitive ones (via schemas of type
47
+ * [`ListSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-list-schema/index.html)
48
+ * or
49
+ * [`TableSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-table-schema/index.html)).
50
+ *
51
+ * The following built-in KForm validations affect annexes:
52
+ *
53
+ * - [`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):
54
+ * Sets the `maxAnnexes` property of repetitive annexes.
55
+ *
56
+ * It composes the following subcomponents:
57
+ *
58
+ * - `AnnexesManager`: Component used to manage and navigate between annexes
59
+ * (tabs).
60
+ * - `Annex`: Content of a single annex (tab) of the form.
61
+ *
62
+ * Example usage:
63
+ *
64
+ * ```tsx
65
+ * import { Annex, Annexes, AnnexesManager } from "@ostack.tech/ui-kform";
66
+ *
67
+ * function TaxDeclarationsAnnexes() {
68
+ * return (
69
+ * <Annexes>
70
+ * <AnnexesManager />
71
+ * <Annex path="/cover" title="Cover" subtitle="Income sources">
72
+ * Cover content…
73
+ * </Annex>
74
+ * <Annex path="/annexA" title="Annex A" subtitle="Foreign assets">
75
+ * Annex A content…
76
+ * </Annex>
77
+ * </Annexes>
78
+ * );
79
+ * }
80
+ * ```
81
+ */
82
+ export declare function Annexes({ path, annexes, defaultActiveAnnex, activeAnnex, onActiveAnnexChange, onAnnexAdd, onAnnexRemove, variant, className, children, ...otherProps }: AnnexesProps): import("react").JSX.Element;
@@ -1,6 +1,7 @@
1
1
  import { AbsolutePath, type DisplayStatus, type FormManager, type Path, type Schema, type SealedValidationIssue, type TableRowId } from "@ostack.tech/kform";
2
2
  import { type ReactNode } from "react";
3
- import type { AnnexesProps, AnnexObject } from "./Annexes.tsx";
3
+ import type { AnnexObject } from "./Annex.tsx";
4
+ import type { AnnexesProps } from "./Annexes.tsx";
4
5
  /** Value of the annexes' context. */
5
6
  export type AnnexesContextValue = AnnexesStore;
6
7
  /** Resolved annex object. */
@@ -1,7 +1,12 @@
1
- import { type Button, type DropdownMenu, type DropdownMenuContent, type TabList } from "@ostack.tech/ui";
2
- import { type ComponentPropsWithoutRef, type ComponentPropsWithRef, type ReactNode } from "react";
1
+ import { type ButtonProps, type DropdownMenuContentProps, type DropdownMenuProps, type TabListProps } from "@ostack.tech/ui";
2
+ import { type ComponentProps, type ReactNode } from "react";
3
3
  /** Properties of the annexes' manager component. */
4
- export interface AnnexesManagerProps extends ComponentPropsWithoutRef<"nav"> {
4
+ export interface AnnexesManagerProps extends ComponentProps<"nav"> {
5
+ /**
6
+ * Whether to show the annexes manager menu. This defaults to `true` if there
7
+ * is at least one optional or repetitive annex, and `false` otherwise.
8
+ */
9
+ showMenu?: boolean;
5
10
  /** Text of the menu button. */
6
11
  menuButtonText?: ReactNode;
7
12
  /** Accessible label of the menu button. */
@@ -31,21 +36,21 @@ export interface AnnexesManagerProps extends ComponentPropsWithoutRef<"nav"> {
31
36
  /** Text of the "remove annex" confirm dialog cancel button. */
32
37
  removeAnnexConfirmDialogCancelText?: ReactNode;
33
38
  /** Properties to pass to the menu container element. */
34
- menuContainerProps?: ComponentPropsWithRef<"div">;
39
+ menuContainerProps?: ComponentProps<"div">;
35
40
  /** Properties to pass to the menu trigger component. */
36
- menuTriggerProps?: Omit<ComponentPropsWithRef<typeof Button<"button">>, "icon">;
41
+ menuTriggerProps?: Omit<ButtonProps, "icon">;
37
42
  /** Properties to pass to the menu content component. */
38
- menuContentProps?: ComponentPropsWithRef<typeof DropdownMenuContent>;
43
+ menuContentProps?: DropdownMenuContentProps;
39
44
  /** Properties to pass to the menu component. */
40
- menuProps?: ComponentPropsWithRef<typeof DropdownMenu>;
45
+ menuProps?: DropdownMenuProps;
41
46
  /** Properties to pass to the tab-list container element. */
42
- tabListContainerProps?: ComponentPropsWithRef<"div">;
47
+ tabListContainerProps?: ComponentProps<"div">;
43
48
  /** Properties to pass to the tab-list component. */
44
- tabListProps?: ComponentPropsWithRef<typeof TabList>;
49
+ tabListProps?: TabListProps;
45
50
  }
46
51
  /**
47
52
  * Component used to manage the form's annexes. Provides a menu that allows
48
53
  * changing, adding, and removing annexes, as well as a list of tabs for each
49
54
  * existing annex.
50
55
  */
51
- export declare const AnnexesManager: import("react").ForwardRefExoticComponent<AnnexesManagerProps & import("react").RefAttributes<HTMLElement>>;
56
+ export declare function AnnexesManager({ showMenu, menuButtonText, menuButtonLabel, addAnnexText, removeAnnexButtonLabel, removeAnnexKeyboardHint, removeAnnexConfirmDialogTitle, removeAnnexConfirmDialogMessage, removeAnnexConfirmDialogOkText, removeAnnexConfirmDialogCancelText, className, "aria-label": ariaLabel, menuContainerProps, menuTriggerProps, menuContentProps, menuProps, tabListContainerProps, tabListProps, ref, ...otherProps }: AnnexesManagerProps): import("react").JSX.Element;
@@ -1,10 +1,9 @@
1
- import { Button, DropdownMenu, DropdownMenuContent } from "@ostack.tech/ui";
2
- import { type ComponentPropsWithoutRef, type ComponentPropsWithRef } from "react";
3
- import type { AnnexesManager } from "./AnnexesManager.tsx";
1
+ import { type ButtonProps, type DropdownMenuContentProps, type DropdownMenuProps } from "@ostack.tech/ui";
2
+ import type { AnnexesManagerProps } from "./AnnexesManager.tsx";
4
3
  /** Properties of the annexes' menu. */
5
- export interface AnnexesMenuProps extends Pick<ComponentPropsWithoutRef<typeof AnnexesManager>, "menuButtonText" | "menuButtonLabel" | "addAnnexText" | "removeAnnexButtonLabel" | "removeAnnexKeyboardHint" | "removeAnnexConfirmDialogTitle" | "removeAnnexConfirmDialogMessage" | "removeAnnexConfirmDialogOkText" | "removeAnnexConfirmDialogCancelText">, ComponentPropsWithoutRef<typeof DropdownMenu> {
6
- menuTriggerProps?: Omit<ComponentPropsWithRef<typeof Button<"button">>, "icon">;
7
- menuContentProps?: ComponentPropsWithRef<typeof DropdownMenuContent>;
4
+ export interface AnnexesMenuProps extends Pick<AnnexesManagerProps, "menuButtonText" | "menuButtonLabel" | "addAnnexText" | "removeAnnexButtonLabel" | "removeAnnexKeyboardHint" | "removeAnnexConfirmDialogTitle" | "removeAnnexConfirmDialogMessage" | "removeAnnexConfirmDialogOkText" | "removeAnnexConfirmDialogCancelText">, DropdownMenuProps {
5
+ menuTriggerProps?: Omit<ButtonProps, "icon">;
6
+ menuContentProps?: DropdownMenuContentProps;
8
7
  }
9
8
  /** Component that allows to navigate between, add, and remove annexes. */
10
9
  export declare function AnnexesMenu({ menuButtonText, menuButtonLabel, addAnnexText, removeAnnexButtonLabel, removeAnnexKeyboardHint, removeAnnexConfirmDialogTitle, removeAnnexConfirmDialogMessage, removeAnnexConfirmDialogOkText, removeAnnexConfirmDialogCancelText, defaultOpen, open: controlledOpen, onOpenChange, menuTriggerProps, menuContentProps, ...otherProps }: AnnexesMenuProps): import("react").JSX.Element;
@@ -1,8 +1,7 @@
1
- import { TabList } from "@ostack.tech/ui";
2
- import { type ComponentPropsWithoutRef } from "react";
1
+ import { type TabListProps } from "@ostack.tech/ui";
3
2
  /** Properties of the annex tab list component. */
4
- export interface AnnexTabListProps extends ComponentPropsWithoutRef<typeof TabList> {
3
+ export interface AnnexTabListProps extends TabListProps {
5
4
  hideNonActiveOnSmallScreens: boolean;
6
5
  }
7
6
  /** List of annex tabs. */
8
- export declare const AnnexesTabList: import("react").ForwardRefExoticComponent<AnnexTabListProps & import("react").RefAttributes<HTMLDivElement>>;
7
+ export declare function AnnexesTabList({ hideNonActiveOnSmallScreens, rootProps, className, ...otherProps }: AnnexTabListProps): import("react").JSX.Element;
@@ -1,10 +1,10 @@
1
1
  import type { Path } from "@ostack.tech/kform";
2
2
  import { type InputController, type InputOptions } from "@ostack.tech/kform-react";
3
- import { Checkbox, type CheckboxChecked } from "@ostack.tech/ui";
4
- import { type ComponentPropsWithoutRef, type ComponentPropsWithRef, type ComponentRef, type ReactNode, type Ref } from "react";
5
- import type { IssueMessages, IssueMessagesByCode } from "../IssueMessages";
3
+ import { Checkbox, type CheckboxChecked, type CheckboxProps } from "@ostack.tech/ui";
4
+ import { type ComponentRef, type ReactNode, type Ref } from "react";
5
+ import type { IssueMessagesByCode, IssueMessagesProps } from "../IssueMessages";
6
6
  /** Properties of the checkbox control component. */
7
- export interface CheckboxControlProps<T extends boolean | null = boolean | null> extends Omit<InputOptions<T, CheckboxChecked, ComponentRef<typeof Checkbox>>, "enabled" | "format" | "parse">, Omit<ComponentPropsWithoutRef<typeof Checkbox>, "defaultChecked" | "checked" | "status" | "validate" | "validationMode"> {
7
+ export interface CheckboxControlProps<T extends boolean | null = boolean | null> extends Omit<InputOptions<T, CheckboxChecked, ComponentRef<typeof Checkbox>>, "enabled" | "format" | "parse">, Omit<CheckboxProps, "defaultChecked" | "checked" | "status" | "validate" | "validationMode"> {
8
8
  /** Path to the value. */
9
9
  path?: string | Path;
10
10
  /**
@@ -17,7 +17,7 @@ export interface CheckboxControlProps<T extends boolean | null = boolean | null>
17
17
  * Label to use in the issues panel when displaying issues associated with
18
18
  * this field.
19
19
  *
20
- * This label has priority over the field's `ControlLabel`.
20
+ * This label has priority over the field's `Label`.
21
21
  */
22
22
  issuesPanelLabel?: ReactNode;
23
23
  /**
@@ -36,13 +36,42 @@ export interface CheckboxControlProps<T extends boolean | null = boolean | null>
36
36
  * @default false
37
37
  */
38
38
  preventAutoFocus?: boolean;
39
+ /**
40
+ * Whether to show debug information. This property has no effect in
41
+ * production builds.
42
+ */
43
+ debug?: boolean;
39
44
  /** Reference to the control's API. */
40
45
  apiRef?: Ref<InputController<T, CheckboxChecked, ComponentRef<typeof Checkbox>> | undefined>;
41
46
  /** Properties to pass to the `IssueMessages` component. */
42
- issueMessagesProps?: Omit<ComponentPropsWithRef<typeof IssueMessages>, "path" | "issues" | "messages" | "unwrapped">;
47
+ issueMessagesProps?: Omit<IssueMessagesProps, "path" | "issues" | "messages" | "unwrapped">;
43
48
  }
44
49
  /**
45
- * Checkbox control component supporting (possibly nullable) schemas of type
46
- * "Boolean". `null` values are represented as an "indeterminate" checkbox.
50
+ * The checkbox control component is a KForm form control for values with
51
+ * (possibly
52
+ * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))
53
+ * schemas of type
54
+ * [`BooleanSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-boolean-schema/index.html).
55
+ * It is built on top of the [`Checkbox`](/docs/ostack-ui-forms-checkbox--docs)
56
+ * component.
57
+ *
58
+ * The following built-in KForm validation affects this control:
59
+ *
60
+ * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):
61
+ * Sets the `required` property.
62
+ *
63
+ * Example usage:
64
+ *
65
+ * ```tsx
66
+ * import { CheckboxControl } from "@ostack.tech/ui-kform";
67
+ *
68
+ * function TermsControl() {
69
+ * return (
70
+ * <CheckboxControl path="/terms">
71
+ * Accept terms and conditions
72
+ * </CheckboxControl>
73
+ * );
74
+ * }
75
+ * ```
47
76
  */
48
- export declare const CheckboxControl: import("react").ForwardRefExoticComponent<CheckboxControlProps<boolean | null> & import("react").RefAttributes<HTMLButtonElement>>;
77
+ export declare function CheckboxControl<T extends boolean | null = boolean | null>({ path, issueMessages, issuesPanelLabel, displayIssues, preventAutoFocus, apiRef, issueMessagesProps, formManager, onInitialized, onFormManagerEvent, onValueChange, onValidationStatusChange, onDisplayStatusChange, onDirtyStatusChange, onTouchedStatusChange, required, loading, showSpinner, disabled, readOnly, endAdornment, onFocus, onCheckedChange, onBlurToOutside, debug, ref, ...otherProps }: CheckboxControlProps<T>): import("react").JSX.Element;
@@ -1,23 +1,15 @@
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 { Checkbox, CheckboxGroup } from "@ostack.tech/ui";
4
- import { type ComponentPropsWithoutRef, type ComponentPropsWithRef, type ComponentRef, type Key, type ReactNode, type Ref } from "react";
5
- import type { IssueMessages, IssueMessagesByCode } from "../IssueMessages";
6
- /** Checkbox in object notation. */
7
- export type CheckboxObject<T = unknown> = Omit<ComponentPropsWithRef<typeof Checkbox>, "defaultChecked" | "checked" | "value" | "children"> & {
8
- /** Option value. */
9
- value: T;
10
- /** Option's rendered text. */
11
- text?: ReactNode;
12
- /** Option's unique key. */
13
- key?: Key;
14
- };
3
+ import { CheckboxGroup, type CheckboxGroupProps } from "@ostack.tech/ui";
4
+ import { type ComponentRef, type ReactNode, type Ref } from "react";
5
+ import type { IssueMessagesByCode, IssueMessagesProps } from "../IssueMessages";
6
+ import { type CheckboxGroupControlItemObject } from "./CheckboxGroupControlItem.tsx";
15
7
  /** Properties of the checkbox group control component. */
16
- export interface CheckboxGroupControlProps<T = unknown, TListable extends Listable<T> | null = Listable<T> | null> extends Omit<ListableInputOptions<T, TListable, T[] | null, ComponentRef<typeof CheckboxGroup>>, "enabled" | "formatFromArray" | "parseToArray">, Omit<ComponentPropsWithoutRef<typeof CheckboxGroup>, "defaultValue" | "value" | "onValueChange" | "children" | "status" | "validate" | "validationMode"> {
8
+ export interface CheckboxGroupControlProps<T = unknown, TListable extends Listable<T> | null = Listable<T> | null> extends Omit<ListableInputOptions<T, TListable, readonly T[] | null, ComponentRef<typeof CheckboxGroup>>, "enabled" | "formatFromArray" | "parseToArray">, Omit<CheckboxGroupProps, "defaultValue" | "value" | "onValueChange" | "children" | "status" | "validate" | "validationMode"> {
17
9
  /** Path to the value. */
18
10
  path?: string | Path;
19
11
  /** Checkbox group control options. */
20
- options: CheckboxObject<T>[];
12
+ options?: CheckboxGroupControlItemObject<T>[];
21
13
  /**
22
14
  * Issue messages of this control.
23
15
  *
@@ -28,7 +20,7 @@ export interface CheckboxGroupControlProps<T = unknown, TListable extends Listab
28
20
  * Label to use in the issues panel when displaying issues associated with
29
21
  * this field.
30
22
  *
31
- * This label has priority over the field's `ControlLabel`.
23
+ * This label has priority over the field's `Label`.
32
24
  */
33
25
  issuesPanelLabel?: ReactNode;
34
26
  /**
@@ -49,17 +41,67 @@ export interface CheckboxGroupControlProps<T = unknown, TListable extends Listab
49
41
  * @default false
50
42
  */
51
43
  preventAutoFocus?: boolean;
44
+ /** Checkbox group control children. */
45
+ children?: ReactNode;
46
+ /**
47
+ * Whether to show debug information. This property has no effect in
48
+ * production builds.
49
+ */
50
+ debug?: boolean;
52
51
  /** Reference to the control's API. */
53
52
  apiRef?: Ref<ListableInputController<T, TListable, string[], ComponentRef<typeof CheckboxGroup>> | undefined>;
54
53
  /** Properties to pass to the `IssueMessages` component. */
55
- issueMessagesProps?: Omit<ComponentPropsWithRef<typeof IssueMessages>, "path" | "issues" | "messages" | "unwrapped">;
54
+ issueMessagesProps?: Omit<IssueMessagesProps, "path" | "issues" | "messages" | "unwrapped">;
56
55
  }
57
56
  /**
58
- * Checkbox group control component supporting (possibly nullable) listable
59
- * schemas with elements of any type.
57
+ * The checkbox group control component is a KForm form control for values with
58
+ * (possibly
59
+ * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))
60
+ * schemas of type
61
+ * [`ListSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-list-schema/index.html)
62
+ * or
63
+ * [`TableSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-table-schema/index.html)
64
+ * and items of any type. It is built on top of the
65
+ * [`CheckboxGroup`](/docs/ostack-ui-forms-checkbox-group--docs) component.
66
+ *
67
+ * It composes the following subcomponent:
68
+ *
69
+ * - `CheckboxGroupControlItem`: Component used to define an item of the checkbox
70
+ * group control.
71
+ *
72
+ * The following built-in KForm validations affect this control:
73
+ *
74
+ * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):
75
+ * Sets the `required` property.
76
+ * - [`Size`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-size/index.html)/[`MinSize`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-min-size/index.html)/[`MaxSize`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-size/index.html):
77
+ * Sets the `minChecked` and/or `maxChecked` properties.
78
+ *
79
+ * Example usage:
80
+ *
81
+ * ```tsx
82
+ * import {
83
+ * CheckboxGroupControl,
84
+ * CheckboxGroupControlItem,
85
+ * } from "@ostack.tech/ui-kform";
60
86
  *
61
- * If the schema is nullable, this component sets the form value to `null` when
62
- * the control contains no elements. Note, however, that the form may still hold
63
- * an empty listable as value if set programmatically.
87
+ * function SpokenLanguagesControl() {
88
+ * return (
89
+ * <CheckboxGroupControl path="/spokenLanguages">
90
+ * <CheckboxGroupControlItem value="en">
91
+ * English
92
+ * </CheckboxGroupControlItem>
93
+ * <CheckboxGroupControlItem value="fr">
94
+ * French
95
+ * </CheckboxGroupControlItem>
96
+ * <CheckboxGroupControlItem value="pt">
97
+ * Portuguese
98
+ * </CheckboxGroupControlItem>
99
+ * <CheckboxGroupControlItem value="es">
100
+ * Spanish
101
+ * </CheckboxGroupControlItem>
102
+ * </CheckboxGroupControl>
103
+ * );
104
+ * }
105
+ * ```
64
106
  */
65
- export declare const CheckboxGroupControl: import("react").ForwardRefExoticComponent<CheckboxGroupControlProps<unknown, Listable<unknown> | null> & import("react").RefAttributes<HTMLDivElement>>;
107
+ export declare function CheckboxGroupControl<T = unknown, TListable extends Listable<T> | null = Listable<T> | null>({ path, options, issueMessages, issuesPanelLabel, displayIssues, unknownValueLabel, preventAutoFocus, apiRef, issueMessagesProps, formManager, onInitialized, onFormManagerEvent, onValueChange, onValidationStatusChange, onDisplayStatusChange, onDirtyStatusChange, onTouchedStatusChange, required, minChecked, maxChecked, loading, showSpinner, disabled, readOnly, endAdornment, onFocus, onBlurToOutside, children, debug, ref, ...otherProps }: CheckboxGroupControlProps<T, TListable>): import("react").JSX.Element;
@@ -0,0 +1,26 @@
1
+ import type { CheckboxProps } from "@ostack.tech/ui";
2
+ import type { Key, ReactNode } from "react";
3
+ /** @deprecated Use {@link CheckboxGroupControlItemObject} instead. */
4
+ export type CheckboxObject<T = unknown> = CheckboxGroupControlItemObject<T>;
5
+ /** Checkbox group control item in object notation. */
6
+ export interface CheckboxGroupControlItemObject<T = unknown> extends Omit<CheckboxProps, "defaultChecked" | "checked" | "value" | "children"> {
7
+ /** Item value. */
8
+ value: T;
9
+ /** Item's rendered text. */
10
+ text?: ReactNode;
11
+ /** Item's unique key. */
12
+ key?: Key;
13
+ }
14
+ /** Properties of the checkbox group control item component. */
15
+ export interface CheckboxGroupControlItemProps<T = unknown> extends Omit<CheckboxGroupControlItemObject<T>, "text"> {
16
+ /** Item's rendered text. */
17
+ children?: ReactNode;
18
+ }
19
+ /**
20
+ * Definition of a checkbox group control item.
21
+ *
22
+ * This component doesn't actually render anything by itself; it is used by the
23
+ * `CheckboxGroupControl` component to automatically create the `options`
24
+ * array.
25
+ */
26
+ export declare function CheckboxGroupControlItem(_props: CheckboxGroupControlItemProps): null;
@@ -1 +1,2 @@
1
1
  export * from "./CheckboxGroupControl.tsx";
2
+ export * from "./CheckboxGroupControlItem.tsx";