@bsol-oss/react-datatable5 12.0.0-beta.56 → 12.0.0-beta.58

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.
@@ -14,6 +14,29 @@ export interface GetVariantProps {
14
14
  selectable: boolean;
15
15
  }
16
16
  export interface DatePickerProps extends Props {
17
+ onDateSelected?: (obj: {
18
+ date: Date;
19
+ }) => void;
20
+ selected: Date | Date[];
21
+ firstDayOfWeek?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
22
+ showOutsideDays?: boolean;
23
+ date?: Date;
24
+ minDate?: Date;
25
+ maxDate?: Date;
26
+ monthsToDisplay?: number;
27
+ labels?: {
28
+ monthNamesShort: string[];
29
+ weekdayNamesShort: string[];
30
+ backButtonLabel?: string;
31
+ forwardButtonLabel?: string;
32
+ };
33
+ render?: (dayzedData: any) => React.ReactNode;
34
+ }
35
+ export interface DatePickerLabels {
36
+ monthNamesShort: string[];
37
+ weekdayNamesShort: string[];
38
+ backButtonLabel?: string;
39
+ forwardButtonLabel?: string;
17
40
  }
18
41
  declare class DatePicker extends React.Component<DatePickerProps> {
19
42
  render(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { DatePickerLabels } from "./DatePicker";
2
+ interface DateTimePickerProps {
3
+ value?: string;
4
+ onChange?: (date?: string) => void;
5
+ format?: "date-time" | "iso-date-time";
6
+ showSeconds?: boolean;
7
+ labels?: DatePickerLabels;
8
+ timezone?: string;
9
+ }
10
+ export declare function DateTimePicker({ value, onChange, format, showSeconds, labels, timezone, }: DateTimePickerProps): import("react/jsx-runtime").JSX.Element;
11
+ export {};
@@ -0,0 +1,12 @@
1
+ interface DurationPickerProps {
2
+ value?: string | null;
3
+ onChange?: (duration: string | null) => void;
4
+ showYears?: boolean;
5
+ showMonths?: boolean;
6
+ showDays?: boolean;
7
+ showHours?: boolean;
8
+ showMinutes?: boolean;
9
+ showSeconds?: boolean;
10
+ }
11
+ export declare function DurationPicker({ value, onChange, showYears, showMonths, showDays, showHours, showMinutes, showSeconds, }: DurationPickerProps): import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -0,0 +1,16 @@
1
+ import { Dispatch, SetStateAction } from "react";
2
+ interface IsoTimePickerProps {
3
+ hour: number | null;
4
+ setHour: Dispatch<SetStateAction<number | null>>;
5
+ minute: number | null;
6
+ setMinute: Dispatch<SetStateAction<number | null>>;
7
+ second: number | null;
8
+ setSecond: Dispatch<SetStateAction<number | null>>;
9
+ onChange?: (newValue: {
10
+ hour: number | null;
11
+ minute: number | null;
12
+ second: number | null;
13
+ }) => void;
14
+ }
15
+ export declare function IsoTimePicker({ hour, setHour, minute, setMinute, second, setSecond, onChange, }: IsoTimePickerProps): import("react/jsx-runtime").JSX.Element;
16
+ export {};
@@ -0,0 +1 @@
1
+ export declare function PickerDemo(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ type FormatType = "date" | "time" | "date-time" | "iso-time" | "iso-date-time" | "duration";
2
+ interface UniversalPickerProps {
3
+ format: FormatType;
4
+ value?: string | null;
5
+ onChange?: (value: string | null) => void;
6
+ placeholder?: string;
7
+ }
8
+ export declare function UniversalPicker({ format, value, onChange, placeholder, }: UniversalPickerProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,7 @@
1
+ export { default as DatePicker } from './DatePicker';
2
+ export { TimePicker } from '../TimePicker/TimePicker';
3
+ export { IsoTimePicker } from './IsoTimePicker';
4
+ export { DateTimePicker } from './DateTimePicker';
5
+ export { DurationPicker } from './DurationPicker';
6
+ export { UniversalPicker } from './UniversalPicker';
7
+ export type { DatePickerProps, CalendarProps, GetDateColorProps, GetVariantProps } from './DatePicker';
@@ -3,6 +3,7 @@ import { JSONSchema7 } from "json-schema";
3
3
  import { Dispatch, ReactNode, SetStateAction } from "react";
4
4
  import { FieldValues } from "react-hook-form";
5
5
  import { UseTranslationResponse } from "react-i18next";
6
+ import { SupportedLocale } from "./utils/validation";
6
7
  export interface SchemaFormContext<TData extends FieldValues> {
7
8
  schema: JSONSchema7;
8
9
  serverUrl: string;
@@ -30,5 +31,7 @@ export interface SchemaFormContext<TData extends FieldValues> {
30
31
  setError: Dispatch<SetStateAction<unknown>>;
31
32
  getUpdatedData: () => TData | Promise<TData>;
32
33
  customErrorRenderer?: (error: unknown) => ReactNode;
34
+ validationLocale?: SupportedLocale;
35
+ timezone?: string;
33
36
  }
34
37
  export declare const SchemaFormContext: import("react").Context<SchemaFormContext<unknown>>;
@@ -1,4 +1,5 @@
1
1
  import { ForeignKeyProps } from "@/components/Form/components/fields/StringInputField";
2
+ import { SupportedLocale } from "@/components/Form/utils/validation";
2
3
  import { AxiosRequestConfig } from "axios";
3
4
  import { JSONSchema7 } from "json-schema";
4
5
  import { Dispatch, ReactNode, SetStateAction } from "react";
@@ -22,6 +23,7 @@ export interface FormRootProps<TData extends FieldValues> {
22
23
  requestOptions?: AxiosRequestConfig;
23
24
  getUpdatedData?: () => TData | Promise<TData> | void;
24
25
  customErrorRenderer?: (error: unknown) => ReactNode;
26
+ validationLocale?: SupportedLocale;
25
27
  }
26
28
  export interface CustomJSONSchema7Definition extends JSONSchema7 {
27
29
  variant: string;
@@ -38,4 +40,4 @@ export declare const idPickerSanityCheck: (column: string, foreign_key?: {
38
40
  column?: string | undefined;
39
41
  display_column?: string | undefined;
40
42
  } | undefined) => void;
41
- export declare const FormRoot: <TData extends FieldValues>({ schema, idMap, setIdMap, form, serverUrl, translate, children, order, ignore, include, onSubmit, rowNumber, requestOptions, getUpdatedData, customErrorRenderer, }: FormRootProps<TData>) => import("react/jsx-runtime").JSX.Element;
43
+ export declare const FormRoot: <TData extends FieldValues>({ schema, idMap, setIdMap, form, serverUrl, translate, children, order, ignore, include, onSubmit, rowNumber, requestOptions, getUpdatedData, customErrorRenderer, validationLocale, }: FormRootProps<TData>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { InputDefaultProps } from "./types";
2
+ export declare const DateTimePicker: ({ column, schema, prefix, }: InputDefaultProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { CustomJSONSchema7 } from "../types/CustomJSONSchema7";
2
+ export interface DateViewerProps {
3
+ column: string;
4
+ schema: CustomJSONSchema7;
5
+ prefix: string;
6
+ }
7
+ export declare const DateTimeViewer: ({ column, schema, prefix }: DateViewerProps) => import("react/jsx-runtime").JSX.Element;
@@ -4,4 +4,4 @@ export interface TimeViewerProps {
4
4
  schema: CustomJSONSchema7;
5
5
  prefix: string;
6
6
  }
7
- export declare const TimeViewer: ({ column, schema, prefix, }: TimeViewerProps) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const TimeViewer: ({ column, schema, prefix }: TimeViewerProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,49 @@
1
+ import { JSONSchema7 } from "json-schema";
2
+ declare const localize: {
3
+ en: () => void;
4
+ 'zh-HK': import("ajv-i18n/localize/types").Localize;
5
+ 'zh-TW': import("ajv-i18n/localize/types").Localize;
6
+ 'zh-CN': import("ajv-i18n/localize/types").Localize;
7
+ zh: import("ajv-i18n/localize/types").Localize;
8
+ };
9
+ export type SupportedLocale = keyof typeof localize;
10
+ export interface ValidationError {
11
+ field: string;
12
+ message: string;
13
+ value?: unknown;
14
+ schemaPath?: string;
15
+ }
16
+ export interface ValidationResult {
17
+ isValid: boolean;
18
+ errors: ValidationError[];
19
+ }
20
+ export interface ValidationOptions {
21
+ locale?: SupportedLocale;
22
+ }
23
+ /**
24
+ * Validates data against a JSON Schema using AJV with i18n support
25
+ * @param data - The data to validate
26
+ * @param schema - The JSON Schema to validate against
27
+ * @param options - Validation options including locale
28
+ * @returns ValidationResult containing validation status and errors
29
+ */
30
+ export declare const validateData: (data: unknown, schema: JSONSchema7, options?: ValidationOptions) => ValidationResult;
31
+ /**
32
+ * Creates a reusable validator function for a specific schema with i18n support
33
+ * @param schema - The JSON Schema to create validator for
34
+ * @param locale - The locale to use for error messages
35
+ * @returns A function that validates data against the schema
36
+ */
37
+ export declare const createSchemaValidator: (schema: JSONSchema7, locale?: SupportedLocale) => (data: unknown) => ValidationResult;
38
+ /**
39
+ * Get available locales for validation error messages
40
+ * @returns Array of supported locale codes
41
+ */
42
+ export declare const getSupportedLocales: () => SupportedLocale[];
43
+ /**
44
+ * Check if a locale is supported
45
+ * @param locale - The locale to check
46
+ * @returns Boolean indicating if the locale is supported
47
+ */
48
+ export declare const isLocaleSupported: (locale: string) => locale is "en" | "zh-HK" | "zh-TW" | "zh-CN" | "zh";
49
+ export {};
@@ -121,3 +121,5 @@ export * from "./components/DatePicker/getMultiDates";
121
121
  export * from "./components/DatePicker/getRangeDates";
122
122
  export * from "./components/DatePicker/RangeDatePicker";
123
123
  export * from "./components/DataTable/display/RecordDisplay";
124
+ export * from "./components/Form/utils/validation";
125
+ export type { SupportedLocale, ValidationOptions } from "./components/Form/utils/validation";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsol-oss/react-datatable5",
3
- "version": "12.0.0-beta.56",
3
+ "version": "12.0.0-beta.58",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -43,6 +43,9 @@
43
43
  "@tanstack/react-query": "^5.66.9",
44
44
  "@tanstack/react-table": "^8.21.2",
45
45
  "@uidotdev/usehooks": "^2.4.1",
46
+ "ajv": "^8.12.0",
47
+ "ajv-formats": "^3.0.1",
48
+ "ajv-i18n": "^4.2.0",
46
49
  "axios": "^1.7.9",
47
50
  "dayjs": "^1.11.13",
48
51
  "next-themes": "^0.4.4",
@@ -70,6 +73,9 @@
70
73
  "@typescript-eslint/eslint-plugin": "^7.2.0",
71
74
  "@typescript-eslint/parser": "^7.2.0",
72
75
  "@vitejs/plugin-react": "^4.2.1",
76
+ "ajv": "^8.12.0",
77
+ "ajv-formats": "^3.0.1",
78
+ "ajv-i18n": "^4.2.0",
73
79
  "eslint": "^8.57.0",
74
80
  "eslint-plugin-react-hooks": "^4.6.0",
75
81
  "eslint-plugin-react-refresh": "^0.4.6",