@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
@@ -1,98 +0,0 @@
1
- import type { Path, SealedValueEvent } from "@ostack.tech/kform";
2
- import { type AlertDialogContentColor, type ConfirmDialogOptions } from "@ostack.tech/ui";
3
- import { type ReactNode } from "react";
4
- /** Options of the reset confirmation dialog. */
5
- export interface ResetConfirmDialogOption extends ConfirmDialogOptions {
6
- /** Message of the confirmation dialog. */
7
- message: ReactNode;
8
- /**
9
- * Confirmation dialog content color.
10
- *
11
- * @default "warning"
12
- */
13
- color?: AlertDialogContentColor;
14
- }
15
- /** Options of the `useResetOnChange` hook. */
16
- export interface UseResetOnChangeOptions<T = unknown> {
17
- /**
18
- * Function which determines whether to reset the fields when the value
19
- * changes. By default, fields are reset whenever the value changes.
20
- *
21
- * @param event Value event.
22
- */
23
- when?: (event: SealedValueEvent<T>) => boolean;
24
- /**
25
- * Fields in `toReset` that should be excluded from being reset (relative to
26
- * the current path). This is useful when using wildcards in `toReset` and you
27
- * want to exclude some of the fields that match the wildcard.
28
- *
29
- * E.g. `{ toReset: ["/a/*"], excludeFromReset: ["/a/b"] }` will reset all
30
- * children of `/a` except `/a/b`.
31
- */
32
- exclude?: string | Path | (string | Path)[];
33
- /**
34
- * Confirmation dialog options. When provided, a confirmation dialog will be
35
- * presented to the user before resetting the fields.
36
- *
37
- * If this option is **not** provided, the fields will be reset without
38
- * confirmation.
39
- */
40
- confirmation?: ResetConfirmDialogOption;
41
- /**
42
- * Whether to set the fields as untouched when resetting.
43
- *
44
- * @default true
45
- */
46
- setUntouched?: boolean;
47
- /**
48
- * Whether to set the fields as pristine when resetting.
49
- *
50
- * @default true
51
- */
52
- setPristine?: boolean;
53
- }
54
- /** Event handler returned by the `useResetOnChange` hook. */
55
- export type UseResetOnChangeResult = (event: SealedValueEvent<any>) => void;
56
- /**
57
- * Hook which returns an `onValueChange` event handler which resets the fields
58
- * at the provided `toReset` paths to their initial value when the value changes
59
- * (according to the `when` function).
60
- *
61
- * Optionally requests user-confirmation via dialog if `confirmation` is
62
- * provided.
63
- *
64
- * When using wildcards in `toReset`, certain fields may be excluded via
65
- * `exclude`.
66
- *
67
- * Example usage:
68
- *
69
- * ```tsx
70
- * function NoTransactionsControl() {
71
- * const handleOnChange = useResetOnChange("/transactions/*", {
72
- * when: ({ value }) => value,
73
- * confirmation: {
74
- * title: "Confirm no transactions",
75
- * message: (
76
- * <>
77
- * By checking this box, all fields in section “Transactions” will
78
- * be cleared. Are you sure you want to continue?
79
- * </>
80
- * ),
81
- * okText: "Confirm",
82
- * },
83
- * });
84
- *
85
- * return (
86
- * <CheckboxControl
87
- * path="noTransactions"
88
- * onValueChange={handleOnChange}
89
- * />
90
- * );
91
- * }
92
- * ```
93
- *
94
- * @param toReset Paths to reset up when the value changes (relative to the
95
- * current path). Wildcards in paths (`*` or `**`) are supported.
96
- * @param options Hook options. See {@link UseResetOnChangeOptions}.
97
- */
98
- export declare function useResetOnChange<T = unknown>(toReset: string | Path | (string | Path)[], { when, exclude, confirmation, setUntouched, setPristine, }?: UseResetOnChangeOptions<T>): UseResetOnChangeResult;