@ostack.tech/ui-kform 0.16.3 → 1.0.0-rc.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 (37) hide show
  1. package/dist/chunks/{en-CKrk2smU.js → en-CBhjKaFE.js} +2 -1
  2. package/dist/chunks/{en-CKrk2smU.js.map → en-CBhjKaFE.js.map} +1 -1
  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 +1 -0
  6. package/dist/locales/fr-FR.js.map +1 -1
  7. package/dist/locales/pt-PT.js +1 -0
  8. package/dist/locales/pt-PT.js.map +1 -1
  9. package/dist/ostack-ui-kform.css +17 -1
  10. package/dist/ostack-ui-kform.js +349 -185
  11. package/dist/ostack-ui-kform.js.map +1 -1
  12. package/package.json +2 -2
  13. package/scss/components/Annexes/_Annexes.scss +6 -0
  14. package/scss/components/TopBar/_TopBar.scss +13 -1
  15. package/types/components/FileControl/FileControl.d.ts +1 -1
  16. package/types/components/LoadAction/LoadAction.d.ts +2 -5
  17. package/types/components/PathLink/PathLink.d.ts +22 -1
  18. package/types/components/PrintAction/PrintAction.d.ts +2 -5
  19. package/types/components/ResetOnChange/ResetOnChange.d.ts +40 -0
  20. package/types/components/ResetOnChange/ResetOnChangeContext.d.ts +7 -0
  21. package/types/components/ResetOnChange/index.d.ts +3 -0
  22. package/types/components/ResetOnChange/useResetOnChange.d.ts +96 -0
  23. package/types/components/SaveAction/SaveAction.d.ts +8 -10
  24. package/types/components/SubmitAction/SubmitAction.d.ts +2 -4
  25. package/types/components/TableControl/TableControl.d.ts +4 -1
  26. package/types/components/TableControl/TableControlAddRowTrigger.d.ts +2 -4
  27. package/types/components/TableControl/TableControlColumnFns.d.ts +8 -28
  28. package/types/components/TableControl/TableControlContent.d.ts +1 -1
  29. package/types/components/TableControl/TableControlRemoveRowTrigger.d.ts +11 -21
  30. package/types/components/TopBar/TopBarActions.d.ts +4 -4
  31. package/types/components/TopBar/TopBarActionsSecondary.d.ts +6 -0
  32. package/types/components/TopBar/index.d.ts +1 -0
  33. package/types/components/ValidateAction/ValidateAction.d.ts +2 -5
  34. package/types/index.d.ts +1 -1
  35. package/types/providers/LocalizationProvider/LocalizationObject.d.ts +2 -1
  36. package/types/utils/extractConfirmDialogOptions.d.ts +13 -0
  37. package/types/utils/useResetOnChange.d.ts +0 -98
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.16.3",
4
+ "version": "1.0.0-rc.0",
5
5
  "homepage": "https://ui.ostack.tech/",
6
6
  "author": {
7
7
  "name": "Opensoft",
@@ -51,7 +51,7 @@
51
51
  "@fortawesome/free-solid-svg-icons": "^6.2.0 || ^7.0.0",
52
52
  "@ostack.tech/kform": "~1.0.0-rc.1",
53
53
  "@ostack.tech/kform-react": "~1.0.0-rc.1",
54
- "@ostack.tech/ui": "~0.16.3",
54
+ "@ostack.tech/ui": "~1.0.0-rc.0",
55
55
  "@types/react": "^19.0.0",
56
56
  "@types/react-dom": "^19.0.0",
57
57
  "date-fns": "^4.1.0",
@@ -21,6 +21,12 @@
21
21
  }
22
22
  }
23
23
  }
24
+ @include o-ui.media-breakpoint-down(sm) {
25
+ &__manager {
26
+ min-width: 0;
27
+ flex: 1 0 auto;
28
+ }
29
+ }
24
30
 
25
31
  &__menu-container {
26
32
  margin-bottom: o-ui.$tabs-tab-list-annexes-margin-bottom;
@@ -42,7 +42,19 @@
42
42
  }
43
43
  }
44
44
 
45
- &__actions {
45
+ &__actions-container {
46
+ align-self: stretch;
46
47
  margin: $top-bar-actions-margin;
47
48
  }
49
+
50
+ &__actions {
51
+ height: 100%;
52
+ margin-left: auto;
53
+ }
54
+
55
+ @include o-ui.media-breakpoint-up(sm) {
56
+ &__actions-container {
57
+ flex: 1 0 auto;
58
+ }
59
+ }
48
60
  }
@@ -57,7 +57,7 @@ export interface FileControlProps<T extends KFormFile | null = KFormFile | null>
57
57
  /**
58
58
  * Type of interaction with the selected file.
59
59
  *
60
- * @default view
60
+ * @default "view"
61
61
  */
62
62
  fileInteraction?: FileControlFileInteraction;
63
63
  /** Label of the button used to open the file viewer. */
@@ -1,12 +1,9 @@
1
- import { type ButtonProps } from "@ostack.tech/ui";
2
- import type { ReactNode } from "react";
1
+ import { type ActionButtonProps } from "@ostack.tech/ui";
3
2
  import { type FormLoaderOptions } from "../../utils/useFormLoader.tsx";
4
3
  /** Default “load” keybinds. */
5
4
  export declare const DEFAULT_LOAD_KEYBINDS = "$mod+O";
6
5
  /** Properties of the load action. */
7
- export interface LoadActionProps<T = unknown> extends Omit<ButtonProps, "children">, Omit<FormLoaderOptions<T>, "id"> {
8
- /** Action's label. */
9
- label?: ReactNode;
6
+ export interface LoadActionProps<T = unknown> extends Partial<ActionButtonProps>, Omit<FormLoaderOptions<T>, "id"> {
10
7
  /**
11
8
  * Keybinds for triggering the action. Set to `null` to disable the keyboard
12
9
  * shortcut.
@@ -9,5 +9,26 @@ export interface PathLinkOwnProps extends LinkOwnProps {
9
9
  /** KForm path to link to. */
10
10
  to: string | Path;
11
11
  }
12
- /** Link to a KForm path. */
12
+ /**
13
+ * The path link component creates a link (although typically rendered as a
14
+ * `<button>`) to a part of the form identified by the provided path. It is
15
+ * built on top of the [`Link`
16
+ * component](/docs/ostack-ui-typography-link--docs).
17
+ *
18
+ * Example usage:
19
+ *
20
+ * ```tsx
21
+ * import { Alert } from "@ostack.tech/ui";
22
+ * import { PathLink } from "@ostack.tech/ui-kform";
23
+ *
24
+ * function ProfileNotice() {
25
+ * return (
26
+ * <Alert>
27
+ * Your profile URL will be generated using your handle. To change it,
28
+ * update your <PathLink to="/username">username</PathLink>.
29
+ * </Alert>
30
+ * );
31
+ * }
32
+ * ```
33
+ */
13
34
  export declare function PathLink<TAs extends PathLinkAs = "button">({ as, to, onClick, ...otherProps }: PathLinkProps<TAs>): import("react").JSX.Element;
@@ -1,11 +1,8 @@
1
- import { type ButtonProps } from "@ostack.tech/ui";
2
- import type { ReactNode } from "react";
1
+ import { type ActionButtonProps } from "@ostack.tech/ui";
3
2
  /** Default “print” keybinds. */
4
3
  export declare const DEFAULT_PRINT_KEYBINDS = "$mod+P";
5
4
  /** Properties of the print action. */
6
- export interface PrintActionProps extends Omit<ButtonProps, "children"> {
7
- /** Action's label. */
8
- label?: ReactNode;
5
+ export interface PrintActionProps extends Partial<ActionButtonProps> {
9
6
  /**
10
7
  * Keybinds for triggering the action. Set to `null` to disable the keyboard
11
8
  * shortcut.
@@ -0,0 +1,40 @@
1
+ import type { Path } from "@ostack.tech/kform";
2
+ import type { ReactNode } from "react";
3
+ import { type UseResetOnChangeOptions } from "./useResetOnChange.tsx";
4
+ /** Properties of the reset on change component. */
5
+ export interface ResetOnChangeProps extends UseResetOnChangeOptions {
6
+ /** Paths to reset. */
7
+ reset: string | Path | (string | Path)[];
8
+ children?: ReactNode;
9
+ }
10
+ /**
11
+ * Component used to reset path(s) to their initial value when the value of
12
+ * controls within it change (according to the `when` function). Built on top of
13
+ * the `useResetOnChange` hook.
14
+ *
15
+ * Optionally requests user-confirmation via alert dialog if `showConfirmation`
16
+ * is provided.
17
+ *
18
+ * When using wildcards in `reset`, certain fields may be excluded via
19
+ * `exclude`.
20
+ *
21
+ * Example usage:
22
+ *
23
+ * ```tsx
24
+ * import { CheckboxControl, ResetOnChange } from "@ostack.tech/ui-kform";
25
+ *
26
+ * function SameAddressControl() {
27
+ * return (
28
+ * <ResetOnChange
29
+ * reset="/mailingAddress"
30
+ * when={({ value }) => Boolean(value)}
31
+ * >
32
+ * <CheckboxControl path="/sameAddress">
33
+ * Same as residential address
34
+ * </CheckboxControl>
35
+ * </ResetOnChange>
36
+ * );
37
+ * }
38
+ * ```
39
+ */
40
+ export declare function ResetOnChange({ reset, children, ...otherProps }: ResetOnChangeProps): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import type { UseResetOnChangeResult } from "./useResetOnChange.tsx";
2
+ /** Value of the reset on change context. */
3
+ export type ResetOnChangeContextValue = UseResetOnChangeResult;
4
+ /** Reset on change context. */
5
+ export declare const ResetOnChangeContext: import("react").Context<UseResetOnChangeResult | undefined>;
6
+ /** Function providing access to the reset on change context value. */
7
+ export declare function useResetOnChangeContext(): ResetOnChangeContextValue | undefined;
@@ -0,0 +1,3 @@
1
+ export * from "./ResetOnChange.tsx";
2
+ export { type ResetOnChangeContextValue, useResetOnChangeContext, } from "./ResetOnChangeContext.ts";
3
+ export * from "./useResetOnChange.tsx";
@@ -0,0 +1,96 @@
1
+ import { type FormManager, type Path, type SealedValueEvent } from "@ostack.tech/kform";
2
+ import { type PrefixedConfirmDialogOptions } from "../../utils/extractConfirmDialogOptions.ts";
3
+ /** Options of the `useResetOnChange` hook. */
4
+ export interface UseResetOnChangeOptions<T = unknown> extends PrefixedConfirmDialogOptions {
5
+ /**
6
+ * Function which determines whether to reset the fields when the value
7
+ * changes. By default, fields are reset whenever the value changes.
8
+ *
9
+ * @param event Value event.
10
+ */
11
+ when?: (event: SealedValueEvent<T>) => boolean;
12
+ /**
13
+ * Fields in `toReset` that should be excluded from being reset (relative to
14
+ * the current path). This is useful when using wildcards in `toReset` and you
15
+ * want to exclude some of the fields that match the wildcard.
16
+ *
17
+ * E.g. `{ toReset: ["/a/*"], excludeFromReset: ["/a/b"] }` will reset all
18
+ * children of `/a` except `/a/b`.
19
+ */
20
+ exclude?: string | Path | (string | Path)[];
21
+ /**
22
+ * Whether to show a confirmation message before performing the reset.
23
+ *
24
+ * If the confirmation is cancelled, the event which caused the reset in the
25
+ * first place is undone.
26
+ *
27
+ * This property is `false` by default, but is automatically set to `true` if
28
+ * a `confirmDialogMessage` is provided.
29
+ */
30
+ showConfirmation?: boolean;
31
+ /**
32
+ * Whether to set the fields as untouched when resetting.
33
+ *
34
+ * @default true
35
+ */
36
+ setUntouched?: boolean;
37
+ /**
38
+ * Whether to set the fields as pristine when resetting.
39
+ *
40
+ * @default true
41
+ */
42
+ setPristine?: boolean;
43
+ /** Function used to undo the change when the user cancels the confirmation. */
44
+ undo?: (formManager: FormManager, event: SealedValueEvent<T>) => PromiseLike<void>;
45
+ }
46
+ /** Event handler returned by the `useResetOnChange` hook. */
47
+ export type UseResetOnChangeResult = (event: SealedValueEvent<any>) => void;
48
+ /**
49
+ * Hook which returns an `onValueChange` event handler which resets the fields
50
+ * at the provided `reset` path(s) to their initial value when a value changes
51
+ * (according to the `when` function).
52
+ *
53
+ * Optionally requests user-confirmation via alert dialog if `showConfirmation`
54
+ * is provided.
55
+ *
56
+ * When using wildcards in `reset`, certain fields may be excluded via
57
+ * `exclude`.
58
+ *
59
+ * Example usage:
60
+ *
61
+ * ```tsx
62
+ * import {
63
+ * CheckboxControl,
64
+ * useResetOnChange,
65
+ * } from "@ostack.tech/ui-kform";
66
+ *
67
+ * function NoTransactionsControl() {
68
+ * const handleOnChange = useResetOnChange("/transactions", {
69
+ * when: ({ value }) => Boolean(value),
70
+ * confirmDialogTitle: "Confirm no transactions",
71
+ * confirmDialogMessage: (
72
+ * <>
73
+ * By checking this box, the “Itemised transactions” table will be
74
+ * cleared. Are you sure you want to continue?
75
+ * </>
76
+ * ),
77
+ * confirmDialogOkText: "Confirm",
78
+ * });
79
+ *
80
+ * return (
81
+ * <CheckboxControl
82
+ * path="/noTransactions"
83
+ * onValueChange={handleOnChange}
84
+ * >
85
+ * I declare that no taxable transactions were performed during this
86
+ * filing period.
87
+ * </CheckboxControl>
88
+ * );
89
+ * }
90
+ * ```
91
+ *
92
+ * @param reset Path(s) to reset when the value changes (relative to the current
93
+ * path). Wildcards in paths (`*` or `**`) are supported.
94
+ * @param options Hook options. See {@link UseResetOnChangeOptions}.
95
+ */
96
+ export declare function useResetOnChange<T = unknown>(reset: string | Path | (string | Path)[], { when, exclude, confirmDialogMessage, showConfirmation, setUntouched, setPristine, undo, ...confirmDialogOptions }?: UseResetOnChangeOptions<T>): UseResetOnChangeResult;
@@ -1,4 +1,4 @@
1
- import { type ButtonProps, type DropdownMenuContentProps, type IconButtonProps } from "@ostack.tech/ui";
1
+ import { type ActionButtonProps, type ActionSplitProps } from "@ostack.tech/ui";
2
2
  import type { ReactNode } from "react";
3
3
  import { type FormSaverOptions } from "../../utils/useFormSaver.tsx";
4
4
  /** Default “save” keybinds. */
@@ -6,9 +6,7 @@ export declare const DEFAULT_SAVE_KEYBINDS = "$mod+S";
6
6
  /** Default “save as” keybinds. */
7
7
  export declare const DEFAULT_SAVE_AS_KEYBINDS = "$mod+Shift+S";
8
8
  /** Properties of the save action. */
9
- export interface SaveActionProps<T = unknown> extends Omit<ButtonProps, "children">, Omit<FormSaverOptions<T>, "id" | "overwrite"> {
10
- /** Action's label. */
11
- label?: ReactNode;
9
+ export interface SaveActionProps<T = unknown> extends Partial<ActionButtonProps>, Pick<ActionSplitProps, "groupCollapsed" | "buttonGroupProps" | "dropdownMenuGroupProps" | "defaultOpen" | "open" | "onOpenChange" | "modal" | "dropdownMenuContentProps" | "groupLabel">, Omit<FormSaverOptions<T>, "id" | "overwrite"> {
12
10
  /**
13
11
  * Keybinds for triggering the action. Set to `null` to disable the keyboard
14
12
  * shortcut.
@@ -44,10 +42,12 @@ export interface SaveActionProps<T = unknown> extends Omit<ButtonProps, "childre
44
42
  * Defaults to `true` when the form is read-only and `false` otherwise.
45
43
  */
46
44
  disableOverwrite?: boolean;
47
- /** Label of the save options button. */
48
- saveOptionsLabel?: ReactNode;
49
45
  /** Label of the action's "save as" sub-action. */
50
46
  saveAsLabel?: ReactNode;
47
+ /** Label of the save options button. */
48
+ saveOptionsLabel?: ReactNode;
49
+ /** Placement of the save options button. */
50
+ saveOptionsPlacement?: ActionSplitProps["splitPlacement"];
51
51
  /**
52
52
  * Keybinds for triggering the "save as" sub-action. Set to `null` to disable
53
53
  * the keyboard shortcut.
@@ -62,9 +62,7 @@ export interface SaveActionProps<T = unknown> extends Omit<ButtonProps, "childre
62
62
  */
63
63
  saveAsKeybinds?: string | string[] | null;
64
64
  /** Properties to pass to the save options button component. */
65
- saveOptionsProps?: Omit<Partial<IconButtonProps>, "label">;
66
- /** Properties to pass to the save options dropdown menu component. */
67
- dropdownMenuProps?: DropdownMenuContentProps;
65
+ saveOptionsProps?: Omit<ActionButtonProps, "label">;
68
66
  }
69
67
  /**
70
68
  * Form action used to save the form to a file, supporting both overwriting and
@@ -92,4 +90,4 @@ export interface SaveActionProps<T = unknown> extends Omit<ButtonProps, "childre
92
90
  * }
93
91
  * ```
94
92
  */
95
- export declare function SaveAction<T = unknown>({ label, keybinds, showWhenReadOnly, fileSystemId, disableOverwrite, saveOptionsLabel, saveAsLabel, saveAsKeybinds, loading, disabled, onClick, variant, color, path, encode, fileName, extensions, description, mimeTypes, startIn, excludeAcceptAllOption, successMessage, errorMessage, saveOptionsProps, dropdownMenuProps, ...otherProps }: SaveActionProps<T>): false | import("react").JSX.Element;
93
+ export declare function SaveAction<T = unknown>({ label, keybinds, showWhenReadOnly, fileSystemId, disableOverwrite, saveOptionsLabel, saveAsLabel, saveAsKeybinds, loading, disabled, onClick, variant, color, path, encode, fileName, extensions, description, mimeTypes, startIn, excludeAcceptAllOption, successMessage, errorMessage, groupCollapsed, defaultOpen, open, onOpenChange, modal, groupLabel, saveOptionsPlacement, buttonGroupProps, saveOptionsProps, dropdownMenuGroupProps, dropdownMenuContentProps, ...otherProps }: SaveActionProps<T>): false | import("react").JSX.Element;
@@ -1,13 +1,11 @@
1
1
  import { type LocatedValidationWarning } from "@ostack.tech/kform";
2
2
  import { type SubmitOptions } from "@ostack.tech/kform-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";
3
+ import { type ActionButtonProps, type AlertDialogBodyProps, type AlertDialogContentProps, type AlertDialogDescriptionProps, type AlertDialogFooterProps, type AlertDialogHeaderProps, type AlertDialogTitleProps, type AlertProps, type ButtonProps, type CheckboxProps } from "@ostack.tech/ui";
4
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. */
8
- export interface SubmitActionProps<T = unknown, TSubmitResult = unknown> extends Omit<ButtonProps, "children" | "onSubmit">, Pick<Required<SubmitOptions<T, TSubmitResult>>, "onSubmit">, Omit<SubmitOptions<T, TSubmitResult>, "onSubmit"> {
9
- /** Action's label. */
10
- label?: ReactNode;
8
+ export interface SubmitActionProps<T = unknown, TSubmitResult = unknown> extends Omit<Partial<ActionButtonProps>, "onSubmit">, Pick<Required<SubmitOptions<T, TSubmitResult>>, "onSubmit">, Omit<SubmitOptions<T, TSubmitResult>, "onSubmit"> {
11
9
  /**
12
10
  * Keybinds for triggering the action. Set to `null` to disable the keyboard
13
11
  * shortcut.
@@ -144,7 +144,10 @@ export interface TableControlProps<T = unknown, TTable extends Table<T> | null =
144
144
  * <TableControlActionsColumn removeRowLabel="Remove item" />
145
145
  * </TableControlColumns>
146
146
  * <TableControlAddRowTrigger label="Add item" />
147
- * <TableControlContent caption="Inventory" />
147
+ * <TableControlContent
148
+ * caption="Inventory"
149
+ * emptyMessage="No items added."
150
+ * />
148
151
  * </TableControl>
149
152
  * );
150
153
  * }
@@ -1,4 +1,4 @@
1
- import { type ButtonProps } from "@ostack.tech/ui";
1
+ import { type ActionButtonProps } from "@ostack.tech/ui";
2
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;
@@ -37,9 +37,7 @@ export interface TableControlAddRowTriggerPropsBase {
37
37
  * Properties of the table control add row trigger component when rendered
38
38
  * without children.
39
39
  */
40
- export interface TableControlAddRowTriggerChildlessProps extends TableControlAddRowTriggerPropsBase, Omit<ButtonProps, "asChild" | "children"> {
41
- /** Label displayed on the button. */
42
- label?: ReactNode;
40
+ export interface TableControlAddRowTriggerChildlessProps extends TableControlAddRowTriggerPropsBase, Omit<Partial<ActionButtonProps>, "asChild" | "children"> {
43
41
  /**
44
42
  * Label displayed on the button.
45
43
  *
@@ -1,6 +1,8 @@
1
+ import { type ActionsProps } from "@ostack.tech/ui";
1
2
  import type { ReactNode } from "react";
3
+ import { type PrefixedConfirmDialogOptions } from "../../utils/extractConfirmDialogOptions.ts";
2
4
  import type { TableControlColumnObject } from "./TableControlColumn.tsx";
3
- import { type TableControlRemoveRowTriggerProps } from "./TableControlRemoveRowTrigger.tsx";
5
+ import { type TableControlRemoveRowTriggerProps, type TableControlRemoveRowTriggerPropsBase } from "./TableControlRemoveRowTrigger.tsx";
4
6
  /** Properties used to configure the `tableControlIndexColumn` function. */
5
7
  export interface TableControlIndexColumnFnProps<T = unknown, TValue = any> extends TableControlColumnObject<T, TValue> {
6
8
  }
@@ -13,7 +15,7 @@ export interface TableControlIndexColumnFnProps<T = unknown, TValue = any> exten
13
15
  */
14
16
  export declare function tableControlIndexColumn<T = unknown, TValue = any>({ render, ...otherProps }?: TableControlIndexColumnFnProps<T, TValue>): TableControlColumnObject<T, TValue>;
15
17
  /** Properties used to configure the `tableControlActionsColumn` function. */
16
- export interface TableControlActionsColumnFnProps<T = unknown, TValue = any> extends TableControlColumnObject<T, TValue> {
18
+ export interface TableControlActionsColumnFnProps<T = unknown, TValue = any> extends TableControlColumnObject<T, TValue>, Omit<PrefixedConfirmDialogOptions<"confirmRowRemovalDialog">, "confirmRowRemovalDialogMessage"> {
17
19
  /**
18
20
  * Set the `label` property of the `TableControlRemoveRowTrigger` component
19
21
  * rendered by default.
@@ -46,14 +48,6 @@ export interface TableControlActionsColumnFnProps<T = unknown, TValue = any> ext
46
48
  * overridden.
47
49
  */
48
50
  onRowRemoved?: () => void;
49
- /**
50
- * Sets the `confirmDialogTitle` property of the
51
- * `TableControlRemoveRowTrigger` component rendered by default.
52
- *
53
- * **Note:** This property has no effect if the column's `render` function is
54
- * overridden.
55
- */
56
- confirmRowRemovalDialogTitle?: ReactNode;
57
51
  /**
58
52
  * Sets the `confirmDialogMessage` property of the
59
53
  * `TableControlRemoveRowTrigger` component rendered by default.
@@ -61,23 +55,7 @@ export interface TableControlActionsColumnFnProps<T = unknown, TValue = any> ext
61
55
  * **Note:** This property has no effect if the column's `render` function is
62
56
  * overridden.
63
57
  */
64
- confirmRowRemovalDialogMessage?: (index: number) => ReactNode;
65
- /**
66
- * Sets the `confirmDialogOkText` property of the
67
- * `TableControlRemoveRowTrigger` component rendered by default.
68
- *
69
- * **Note:** This property has no effect if the column's `render` function is
70
- * overridden.
71
- */
72
- confirmRowRemovalDialogOkText?: ReactNode;
73
- /**
74
- * Sets the `confirmDialogCancelText` property of the
75
- * `TableControlRemoveRowTrigger` component rendered by default.
76
- *
77
- * **Note:** This property has no effect if the column's `render` function is
78
- * overridden.
79
- */
80
- confirmRowRemovalDialogCancelText?: ReactNode;
58
+ confirmRowRemovalDialogMessage?: TableControlRemoveRowTriggerPropsBase["confirmDialogMessage"];
81
59
  /**
82
60
  * Properties to pass to the `TableControlRemoveRowTrigger` component rendered
83
61
  * by default.
@@ -86,6 +64,8 @@ export interface TableControlActionsColumnFnProps<T = unknown, TValue = any> ext
86
64
  * overridden.
87
65
  */
88
66
  removeRowProps?: TableControlRemoveRowTriggerProps;
67
+ /** Properties to pass to the `Actions` component. */
68
+ actionsProps?: ActionsProps;
89
69
  }
90
70
  /**
91
71
  * Pre-configured column used to display row actions. By default, it sticks to
@@ -110,4 +90,4 @@ export interface TableControlActionsColumnFnProps<T = unknown, TValue = any> ext
110
90
  * @param overrides Column properties used to display the actions of each row.
111
91
  * @returns Table control column used to display the actions of each row.
112
92
  */
113
- export declare function tableControlActionsColumn<T = unknown, TValue = any>({ removeRowLabel, showRowRemovalConfirmation, onConfirmRowRemoval, onRowRemoved, confirmRowRemovalDialogTitle, confirmRowRemovalDialogMessage, confirmRowRemovalDialogOkText, confirmRowRemovalDialogCancelText, removeRowProps, render, ...otherProps }?: TableControlActionsColumnFnProps<T, TValue>): TableControlColumnObject<T, TValue>;
93
+ export declare function tableControlActionsColumn<T = unknown, TValue = any>({ removeRowLabel, showRowRemovalConfirmation, onConfirmRowRemoval, onRowRemoved, confirmRowRemovalDialogMessage, removeRowProps, render, actionsProps, ...otherProps }?: TableControlActionsColumnFnProps<T, TValue>): TableControlColumnObject<T, TValue>;
@@ -3,4 +3,4 @@ import { type DataTableContentProps } from "@ostack.tech/ui";
3
3
  export interface TableControlContentProps extends Omit<DataTableContentProps, "status"> {
4
4
  }
5
5
  /** Component containing the content of the table control. */
6
- export declare function TableControlContent({ scrollableProps, ...otherProps }: TableControlContentProps): import("react").JSX.Element;
6
+ export declare function TableControlContent({ emptyMessage, scrollableProps, ...otherProps }: TableControlContentProps): import("react").JSX.Element;
@@ -1,40 +1,30 @@
1
- import { type IconButtonProps } from "@ostack.tech/ui";
1
+ import { type ActionButtonProps } from "@ostack.tech/ui";
2
2
  import { type ComponentProps, type ReactNode } from "react";
3
+ import { type PrefixedConfirmDialogOptions } from "../../utils/extractConfirmDialogOptions.ts";
3
4
  /** Properties of the table control remove row trigger component. */
4
5
  export type TableControlRemoveRowTriggerProps = TableControlRemoveRowTriggerChildlessProps | TableControlRemoveRowTriggerChildrenProps;
5
6
  /** Base properties of the table control remove row trigger component. */
6
- export interface TableControlRemoveRowTriggerChildlessPropsBase {
7
+ export interface TableControlRemoveRowTriggerPropsBase extends Omit<PrefixedConfirmDialogOptions, "confirmDialogMessage"> {
7
8
  /**
8
9
  * Whether to show a confirmation message when removing a row.
9
10
  *
10
- * @default false
11
+ * Defaults to `false` unless `confirmDialogMessage` is set, in which case
12
+ * defaults to `true`.
11
13
  */
12
14
  showConfirmation?: boolean;
13
15
  /**
14
16
  * Function called after confirmation that the row is to be removed (this
15
- * function is called even if `showConfirmation` is not set).
17
+ * function is called even if `showConfirmation` is `false`).
16
18
  */
17
19
  onConfirmRowRemoval?: () => void;
18
20
  /** Function called after the row has been removed. */
19
21
  onRowRemoved?: () => void;
20
- /** Title of the confirmation dialog when `showConfirmation` is `true`. */
21
- confirmDialogTitle?: ReactNode;
22
22
  /**
23
- * Message of the confirmation dialog when `showConfirmation` is `true`.
23
+ * Message of the confirmation dialog.
24
24
  *
25
25
  * @param index Index of the row being removed.
26
26
  */
27
- confirmDialogMessage?: (index: number) => ReactNode;
28
- /**
29
- * Ok button text of the confirmation dialog when `showConfirmation` is
30
- * `true`.
31
- */
32
- confirmDialogOkText?: ReactNode;
33
- /**
34
- * Cancel button text of the confirmation dialog when `showConfirmation` is
35
- * `true`.
36
- */
37
- confirmDialogCancelText?: ReactNode;
27
+ confirmDialogMessage?: ReactNode | ((index: number) => ReactNode);
38
28
  /**
39
29
  * Whether to show the trigger when the table is read-only.
40
30
  *
@@ -46,7 +36,7 @@ export interface TableControlRemoveRowTriggerChildlessPropsBase {
46
36
  * Base properties of the table control remove row trigger component when
47
37
  * rendered without children.
48
38
  */
49
- export interface TableControlRemoveRowTriggerChildlessProps extends TableControlRemoveRowTriggerChildlessPropsBase, Omit<Partial<IconButtonProps>, "asChild" | "children"> {
39
+ export interface TableControlRemoveRowTriggerChildlessProps extends TableControlRemoveRowTriggerPropsBase, Omit<Partial<ActionButtonProps>, "asChild" | "children"> {
50
40
  /**
51
41
  * Label of the icon button.
52
42
  *
@@ -59,7 +49,7 @@ export interface TableControlRemoveRowTriggerChildlessProps extends TableControl
59
49
  * Base properties of the table control remove row trigger component when
60
50
  * rendered with children.
61
51
  */
62
- export interface TableControlRemoveRowTriggerChildrenProps extends TableControlRemoveRowTriggerChildlessPropsBase, Partial<ComponentProps<"button">> {
52
+ export interface TableControlRemoveRowTriggerChildrenProps extends TableControlRemoveRowTriggerPropsBase, Partial<ComponentProps<"button">> {
63
53
  children: ReactNode;
64
54
  }
65
55
  /**
@@ -68,4 +58,4 @@ export interface TableControlRemoveRowTriggerChildrenProps extends TableControlR
68
58
  * By default, it renders an icon button with label `defaultButtonLabel`,
69
59
  * however, this can be overriden by providing `children`.
70
60
  */
71
- export declare function TableControlRemoveRowTrigger({ showConfirmation, onConfirmRowRemoval, onRowRemoved, confirmDialogTitle, confirmDialogMessage, confirmDialogOkText, confirmDialogCancelText, showWhenReadOnly, disabled, onClick, children, ...otherProps }: TableControlRemoveRowTriggerProps): import("react").JSX.Element | null;
61
+ export declare function TableControlRemoveRowTrigger({ onConfirmRowRemoval, onRowRemoved, confirmDialogMessage, confirmDialogTitle, confirmDialogOkText, confirmDialogCancelText, showConfirmation, showWhenReadOnly, disabled, onClick, children, ...otherProps }: TableControlRemoveRowTriggerProps): import("react").JSX.Element | null;
@@ -1,6 +1,6 @@
1
- import { type StackProps } from "@ostack.tech/ui";
1
+ import { type ActionsProps } from "@ostack.tech/ui";
2
2
  /** Properties of the top bar actions component. */
3
- export interface TopBarActionsProps extends StackProps {
3
+ export interface TopBarActionsProps extends ActionsProps {
4
4
  }
5
- /** Container used to display actions within the top bar. */
6
- export declare function TopBarActions({ className, children, ...otherProps }: TopBarActionsProps): import("react").JSX.Element;
5
+ /** Container of the top bar actions. */
6
+ export declare function TopBarActions({ className, containerProps, children, ...otherProps }: TopBarActionsProps): import("react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { type ActionsSecondaryProps } from "@ostack.tech/ui";
2
+ /** Properties of the top bar secondary actions component. */
3
+ export interface TopBarActionsSecondaryProps extends ActionsSecondaryProps {
4
+ }
5
+ /** Container of the secondary top bar actions. */
6
+ export declare function TopBarActionsSecondary(props: TopBarActionsSecondaryProps): import("react").JSX.Element;
@@ -1,3 +1,4 @@
1
1
  export * from "./TopBar.tsx";
2
2
  export * from "./TopBarActions.tsx";
3
+ export * from "./TopBarActionsSecondary.tsx";
3
4
  export { useTopBarElement } from "./TopBarContext.tsx";
@@ -1,11 +1,8 @@
1
- import { type ButtonProps } from "@ostack.tech/ui";
2
- import { type ReactNode } from "react";
1
+ import { type ActionButtonProps } from "@ostack.tech/ui";
3
2
  /** Default “validate” keybinds. */
4
3
  export declare const DEFAULT_VALIDATE_KEYBINDS = "Alt+Shift+V";
5
4
  /** Properties of the validate action. */
6
- export interface ValidateActionProps extends Omit<ButtonProps, "children"> {
7
- /** Action's label. */
8
- label?: ReactNode;
5
+ export interface ValidateActionProps extends Partial<ActionButtonProps> {
9
6
  /**
10
7
  * Keybinds for triggering the action. Set to `null` to disable the keyboard
11
8
  * shortcut.
package/types/index.d.ts CHANGED
@@ -19,6 +19,7 @@ export * from "./components/NumericControl";
19
19
  export * from "./components/PathLink";
20
20
  export * from "./components/PrintAction";
21
21
  export * from "./components/RadioGroupControl";
22
+ export * from "./components/ResetOnChange";
22
23
  export * from "./components/SaveAction";
23
24
  export * from "./components/SelectControl";
24
25
  export * from "./components/SelectMultipleControl";
@@ -37,4 +38,3 @@ export * from "./utils/useFormLoader.tsx";
37
38
  export * from "./utils/useFormSaver.tsx";
38
39
  export * from "./utils/useFormValidator.ts";
39
40
  export * from "./utils/useRegisterControl.tsx";
40
- export * from "./utils/useResetOnChange.tsx";
@@ -16,7 +16,7 @@ import type { SaveActionProps } from "../../components/SaveAction";
16
16
  import type { SelectControlProps } from "../../components/SelectControl";
17
17
  import type { SelectMultipleControlProps } from "../../components/SelectMultipleControl";
18
18
  import type { SubmitActionProps } from "../../components/SubmitAction";
19
- import type { TableControlAddRowTriggerChildlessProps, TableControlIndexColumnProps, TableControlRemoveRowTriggerChildlessProps } from "../../components/TableControl";
19
+ import type { TableControlAddRowTriggerChildlessProps, TableControlContentProps, TableControlIndexColumnProps, TableControlRemoveRowTriggerChildlessProps } from "../../components/TableControl";
20
20
  import type { UnknownValueProps } from "../../components/UnknownValue";
21
21
  import type { ValidateActionProps } from "../../components/ValidateAction";
22
22
  /** Localization object representation. */
@@ -42,6 +42,7 @@ export interface LocalizationObject {
42
42
  SubmitAction: Pick<SubmitActionProps, "label" | "keybinds" | "dialogTitle" | "dialogDescription" | "dialogBody" | "dialogOkText" | "dialogCancelText" | "confirmWarningsCheckboxLabel" | "successMessage" | "errorMessage">;
43
43
  TableControlActionsColumn: Pick<TableControlIndexColumnProps, "label">;
44
44
  TableControlAddRowTrigger: Pick<TableControlAddRowTriggerChildlessProps, "label">;
45
+ TableControlContent: Pick<TableControlContentProps, "emptyMessage">;
45
46
  TableControlIndexColumn: Pick<TableControlIndexColumnProps, "label">;
46
47
  TableControlRemoveRowTrigger: Pick<TableControlRemoveRowTriggerChildlessProps, "label" | "confirmDialogTitle" | "confirmDialogMessage" | "confirmDialogOkText" | "confirmDialogCancelText">;
47
48
  UnknownValue: Pick<UnknownValueProps, "label">;
@@ -0,0 +1,13 @@
1
+ import type { ConfirmDialogOptions } from "@ostack.tech/ui";
2
+ import type { ReactNode } from "react";
3
+ /** Confirm dialog options with a prefix. */
4
+ export type PrefixedConfirmDialogOptions<TPrefix extends string = "confirmDialog"> = {
5
+ [K in keyof ConfirmDialogOptions as `${TPrefix}${Capitalize<string & K>}`]: ConfirmDialogOptions[K];
6
+ } & Partial<Record<`${TPrefix}Message`, ReactNode>>;
7
+ /** Result of the {@link extractConfirmDialogOptions} function. */
8
+ export type ExtractConfirmDialogOptionsResult<TOptions extends PrefixedConfirmDialogOptions<TPrefix>, TPrefix extends string = "confirmDialog", TNewPrefix extends string = ""> = [
9
+ TNewPrefix extends "" ? ConfirmDialogOptions : PrefixedConfirmDialogOptions<TNewPrefix>,
10
+ Omit<TOptions, keyof PrefixedConfirmDialogOptions<TPrefix>>
11
+ ];
12
+ /** Function used to extract confirm dialog options with a given prefix. */
13
+ export declare function extractConfirmDialogOptions<TOptions extends PrefixedConfirmDialogOptions<TPrefix>, TPrefix extends string = "confirmDialog", TNewPrefix extends string = "">(options: TOptions, prefix?: TPrefix, newPrefix?: TNewPrefix): ExtractConfirmDialogOptionsResult<TOptions, TPrefix, TNewPrefix>;