@ostack.tech/ui-kform 0.12.5 → 0.13.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.
@@ -86,6 +86,14 @@ export type FormAppProps<T = any> = Pick<ComponentPropsWithoutRef<typeof Root>,
86
86
  * @default false
87
87
  */
88
88
  displayIssueCodes?: boolean;
89
+ /**
90
+ * Name of the key in the data object of validation issues that possibly
91
+ * contains the issue message to display. This message is only used if no
92
+ * matching message is otherwise found.
93
+ *
94
+ * @default "message"
95
+ */
96
+ issueMessagesDataKey?: string;
89
97
  /** Uncontrolled default active path to use. */
90
98
  defaultActivePath?: string | Path;
91
99
  /** Controlled active path to use. */
@@ -218,6 +226,14 @@ export declare const FormApp: import('react').ForwardRefExoticComponent<Pick<Omi
218
226
  * @default false
219
227
  */
220
228
  displayIssueCodes?: boolean;
229
+ /**
230
+ * Name of the key in the data object of validation issues that possibly
231
+ * contains the issue message to display. This message is only used if no
232
+ * matching message is otherwise found.
233
+ *
234
+ * @default "message"
235
+ */
236
+ issueMessagesDataKey?: string;
221
237
  /** Uncontrolled default active path to use. */
222
238
  defaultActivePath?: string | Path;
223
239
  /** Controlled active path to use. */
@@ -10,6 +10,7 @@ export interface FormAppContextValue<T = unknown> {
10
10
  readOnly: boolean;
11
11
  issuesDisplayMode: IssuesDisplayMode;
12
12
  displayIssueCodes: boolean;
13
+ issueMessagesDataKey: string;
13
14
  formAppElement: HTMLFormElement | null;
14
15
  store: FormAppStore<T>;
15
16
  }
@@ -53,7 +54,7 @@ export interface FormAppActions {
53
54
  isRegistered: (path: AbsolutePath) => boolean;
54
55
  setLatestInteraction: (path: AbsolutePath) => void;
55
56
  registerIssueMessages: (basePath: AbsolutePath, issueMessages?: Record<string, IssueMessagesByCode>, priority?: number) => (() => void) | void;
56
- getRegisteredIssueMessage: (path: AbsolutePath, code: string) => IssueMessageValue | null;
57
+ getRegisteredIssueMessage: (path: AbsolutePath, code: string) => IssueMessageValue;
57
58
  registerLabel: (path: AbsolutePath, label: ReactNode, priority?: number) => (() => void) | void;
58
59
  getRegisteredLabel: (path: AbsolutePath) => ReactNode;
59
60
  getActiveIssuesPanelBreadcrumb: () => BreadcrumbItem[] | null;
@@ -72,12 +73,13 @@ export interface UseCreateFormAppContextOptions<T> extends Omit<FormAppContextVa
72
73
  onPathFocus?: (path: AbsolutePath) => void;
73
74
  }
74
75
  /** Hook which creates the form app context. */
75
- export declare function useCreateFormAppContext<T>({ formTitle, controller, disabled, readOnly, issuesDisplayMode, displayIssueCodes, formAppElement, onPathFocus, }: UseCreateFormAppContextOptions<T>): {
76
+ export declare function useCreateFormAppContext<T>({ formTitle, controller, disabled, readOnly, issuesDisplayMode, displayIssueCodes, issueMessagesDataKey, formAppElement, onPathFocus, }: UseCreateFormAppContextOptions<T>): {
76
77
  formTitle: string | undefined;
77
78
  disabled: boolean;
78
79
  readOnly: boolean;
79
80
  issuesDisplayMode: IssuesDisplayMode;
80
81
  displayIssueCodes: boolean;
82
+ issueMessagesDataKey: string;
81
83
  formAppElement: HTMLFormElement | null;
82
84
  store: Omit<import('zustand').StoreApi<FormAppState<T>>, "subscribe"> & {
83
85
  subscribe: {
@@ -147,7 +149,7 @@ export declare function useSetLatestInteraction(): FormAppActions["setLatestInte
147
149
  /** Hook used to register issue messages within the form app. */
148
150
  export declare function useRegisterIssueMessages(path: AbsolutePath | null | undefined, issueMessages?: Record<string, IssueMessagesByCode>, priority?: number): void;
149
151
  /** Hook used to get the issue message value for the provided path and code. */
150
- export declare function useRegisteredIssueMessage(path: AbsolutePath | null | undefined, code: string): IssueMessageValue | null;
152
+ export declare function useRegisteredIssueMessage(path: AbsolutePath | null | undefined, code: string): IssueMessageValue;
151
153
  /** Hook used to register a label within the form app. */
152
154
  export declare function useRegisterLabel(path: AbsolutePath | null | undefined, label: ReactNode, priority?: number): void;
153
155
  /**
@@ -1,16 +1,16 @@
1
1
  import { AbsolutePath, Schema, SealedValidationIssue } from '@ostack.tech/kform';
2
- import { ComponentPropsWithRef, ReactNode } from 'react';
2
+ import { ComponentPropsWithRef } from 'react';
3
+ import { IssueMessagesProps } from '../IssueMessages';
4
+ /** Default data key where to check for an issue message. */
5
+ export declare const DEFAULT_ISSUE_MESSAGE_DATA_KEY = "message";
3
6
  /** Properties of the issue message component. */
4
- export interface IssueMessageProps {
7
+ export interface IssueMessageProps extends Pick<IssueMessagesProps, "visuallyHiddenErrorCodePrefix" | "visuallyHiddenWarningCodePrefix" | "unknownErrorMessage" | "unknownWarningMessage"> {
5
8
  displayIssueCode?: boolean;
6
- visuallyHiddenErrorCodePrefix?: ReactNode;
7
- visuallyHiddenWarningCodePrefix?: ReactNode;
8
- unknownErrorMessage?: ReactNode;
9
- unknownWarningMessage?: ReactNode;
9
+ messageDataKey?: string;
10
10
  path: AbsolutePath;
11
11
  issue: SealedValidationIssue;
12
12
  schema: Schema;
13
13
  issueCodeProps?: ComponentPropsWithRef<"span">;
14
14
  }
15
15
  /** Single issue message within the issue messages or issues panel components. */
16
- export declare function IssueMessage({ path, issue, schema, displayIssueCode, visuallyHiddenErrorCodePrefix, visuallyHiddenWarningCodePrefix, unknownErrorMessage, unknownWarningMessage, issueCodeProps, }: IssueMessageProps): import("react/jsx-runtime").JSX.Element;
16
+ export declare function IssueMessage({ path, issue, schema, displayIssueCode, messageDataKey, visuallyHiddenErrorCodePrefix, visuallyHiddenWarningCodePrefix, unknownErrorMessage, unknownWarningMessage, issueCodeProps, }: IssueMessageProps): import("react/jsx-runtime").JSX.Element;
@@ -23,6 +23,14 @@ export interface IssueMessagesProps extends ComponentPropsWithoutRef<typeof Feed
23
23
  * of the `FormApp`.
24
24
  */
25
25
  displayIssueCodes?: boolean;
26
+ /**
27
+ * Name of the key in a validation issue's data object that possibly contains
28
+ * the issue message. This message is only used if no matching message is
29
+ * otherwise found.
30
+ *
31
+ * @default "message"
32
+ */
33
+ messagesDataKey?: string;
26
34
  /** Accessible prefix for error codes when `displayIssueCodes` is set. */
27
35
  visuallyHiddenErrorCodePrefix?: ReactNode;
28
36
  /** Accessible prefix for warning codes when `displayIssueCodes` is set. */
@@ -0,0 +1,8 @@
1
+ import { Alert } from '@ostack.tech/ui';
2
+ import { ComponentPropsWithoutRef } from 'react';
3
+ import { IssueMessages } from '../IssueMessages';
4
+ /** Properties of the issues alert component. */
5
+ export interface IssuesAlertProps extends Omit<ComponentPropsWithoutRef<typeof Alert>, "open" | "defaultOpen" | "severity" | "children">, Pick<ComponentPropsWithoutRef<typeof IssueMessages>, "path" | "issues" | "messages" | "displayIssueCodes" | "messagesDataKey" | "visuallyHiddenErrorCodePrefix" | "visuallyHiddenWarningCodePrefix" | "unknownErrorMessage" | "unknownWarningMessage"> {
6
+ }
7
+ /** Component used to display an issue alert. */
8
+ export declare const IssuesAlert: import('react').ForwardRefExoticComponent<IssuesAlertProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -0,0 +1 @@
1
+ export * from './IssuesAlert.tsx';
@@ -9,8 +9,8 @@ export * from './components/FileControl';
9
9
  export * from './components/FormApp';
10
10
  export * from './components/FormPages';
11
11
  export * from './components/FormStepper';
12
- export * from './components/IssueAlert';
13
12
  export * from './components/IssueMessages';
13
+ export * from './components/IssuesAlert';
14
14
  export * from './components/IssuesPanel';
15
15
  export * from './components/IssuesPopover';
16
16
  export * from './components/LoadAction';
@@ -52,7 +52,7 @@ export interface UseResetOnChangeOptions<T = unknown> {
52
52
  setPristine?: boolean;
53
53
  }
54
54
  /** Event handler returned by the `useResetOnChange` hook. */
55
- export type UseResetOnChangeResult = (event: SealedValueEvent<any>) => Promise<void>;
55
+ export type UseResetOnChangeResult = (event: SealedValueEvent<any>) => void;
56
56
  /**
57
57
  * Hook which returns an `onValueChange` event handler which resets the fields
58
58
  * at the provided `toReset` paths to their initial value when the value changes
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.12.5",
4
+ "version": "0.13.1",
5
5
  "homepage": "https://ui.ostack.tech/",
6
6
  "author": {
7
7
  "name": "Opensoft",
@@ -50,7 +50,7 @@
50
50
  "@fortawesome/free-solid-svg-icons": "^6.2.0 || ^7.0.0",
51
51
  "@ostack.tech/kform": "~0.32.0",
52
52
  "@ostack.tech/kform-react": "~0.32.0",
53
- "@ostack.tech/ui": "~0.12.5",
53
+ "@ostack.tech/ui": "~0.13.1",
54
54
  "@types/react": "^18.0.0 || ^19.0.0",
55
55
  "@types/react-dom": "^18.0.0 || ^19.0.0",
56
56
  "date-fns": "^4.1.0",
@@ -0,0 +1,10 @@
1
+ @use "@ostack.tech/ui/scss/utils" as o-ui;
2
+ @use "../../scss/base-variables" as *;
3
+
4
+ .#{$prefix}issues-alert {
5
+ .#{o-ui.$prefix}feedback {
6
+ color: inherit;
7
+ font-size: inherit;
8
+ line-height: inherit;
9
+ }
10
+ }
package/scss/index.scss CHANGED
@@ -6,5 +6,6 @@
6
6
  @forward "components/FormApp/FormApp";
7
7
  @forward "components/FormPages/FormPages";
8
8
  @forward "components/IssueMessages/IssueMessages";
9
+ @forward "components/IssuesAlert/IssuesAlert";
9
10
  @forward "components/IssuesPanel/IssuesPanel";
10
11
  @forward "components/TopBar/TopBar";
@@ -1,13 +0,0 @@
1
- import { Path, ValidationIssueData } from '@ostack.tech/kform';
2
- import { Alert } from '@ostack.tech/ui';
3
- import { ComponentPropsWithoutRef, ReactNode } from 'react';
4
- /** Properties of the issue alert component. */
5
- export interface IssueAlertProps extends Omit<ComponentPropsWithoutRef<typeof Alert>, "severity" | "children"> {
6
- /** Path of the value with the issue in question. */
7
- path?: string | Path;
8
- /** Code of the issue in question. */
9
- code: string;
10
- children?: ReactNode | ((issueData: ValidationIssueData) => ReactNode);
11
- }
12
- /** Component used to display an issue alert. */
13
- export declare const IssueAlert: import('react').ForwardRefExoticComponent<IssueAlertProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -1 +0,0 @@
1
- export * from './IssueAlert.tsx';