@gnwebsoft/ui 2.17.3 → 2.17.5

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.
@@ -135,6 +135,33 @@ function getTimezone(adapter, value) {
135
135
  return value == null || !adapter.utils.isValid(value) ? null : adapter.utils.getTimezone(value);
136
136
  }
137
137
 
138
+ // src/utils/handleServerErrors.ts
139
+ var handleServerErrors = function handleServerErrors2(args) {
140
+ const { errors, setError } = args;
141
+ for (const key in errors) {
142
+ const isKeyInVariables = Object.keys(flattenObjectKeys(errors)).includes(
143
+ key
144
+ );
145
+ if (!isKeyInVariables) {
146
+ continue;
147
+ }
148
+ const fieldError = errors[key];
149
+ let errorMessage = "";
150
+ if (Array.isArray(fieldError)) {
151
+ errorMessage = fieldError.join(" ");
152
+ }
153
+ if (typeof fieldError === "string") {
154
+ errorMessage = fieldError;
155
+ }
156
+ if (typeof fieldError === "boolean" && fieldError) {
157
+ errorMessage = "Field is not valid.";
158
+ }
159
+ setError(key, {
160
+ message: errorMessage
161
+ });
162
+ }
163
+ };
164
+
138
165
  // src/utils/propertyExists.ts
139
166
  function propertyExists(obj, prop) {
140
167
  return typeof obj === "object" && obj !== null && Object.prototype.hasOwnProperty.call(obj, prop);
@@ -156,11 +183,25 @@ var removeLeadingTrailingSlashes = (route) => {
156
183
  return route.replace(/^\/|\/$/g, "");
157
184
  };
158
185
 
186
+ // src/utils/schemaTools.ts
187
+ import dayjs from "dayjs";
188
+ import { z } from "zod";
189
+ var schemaTools = {
190
+ date: () => z.coerce.string().transform((c) => c === "null" || c === "undefined" ? null : c).refine((c) => !!c, { message: "required" }).refine((c) => !!c ? dayjs(c).isValid() : true, {
191
+ message: "Invalid date"
192
+ }),
193
+ nullableDate: () => z.coerce.string().transform((c) => c === "null" ? null : c).transform((c) => c === "undefined" ? null : c).refine((c) => !c && c != null ? dayjs(c).isValid() : true, {
194
+ message: "Invalid date"
195
+ })
196
+ };
197
+
159
198
  export {
160
199
  api,
161
200
  flattenObjectKeys,
162
201
  getTimezone,
202
+ handleServerErrors,
163
203
  propertyExists,
164
204
  readValueAsDate,
165
- removeLeadingTrailingSlashes
205
+ removeLeadingTrailingSlashes,
206
+ schemaTools
166
207
  };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-GFSTK7KN.mjs";
4
4
  import {
5
5
  readValueAsDate
6
- } from "./chunk-DMQDQUAE.mjs";
6
+ } from "./chunk-44LP4RZD.mjs";
7
7
 
8
8
  // src/wrappers/DatePickerElement/DatePickerElement.tsx
9
9
  import {
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/api.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/utils/api.ts
2
2
  var makeRequest = async (url, options = {}) => {
3
3
  const response = await fetch(url, options);
4
4
  if (response.ok) {
@@ -135,6 +135,33 @@ function getTimezone(adapter, value) {
135
135
  return value == null || !adapter.utils.isValid(value) ? null : adapter.utils.getTimezone(value);
136
136
  }
137
137
 
138
+ // src/utils/handleServerErrors.ts
139
+ var handleServerErrors = function handleServerErrors2(args) {
140
+ const { errors, setError } = args;
141
+ for (const key in errors) {
142
+ const isKeyInVariables = Object.keys(flattenObjectKeys(errors)).includes(
143
+ key
144
+ );
145
+ if (!isKeyInVariables) {
146
+ continue;
147
+ }
148
+ const fieldError = errors[key];
149
+ let errorMessage = "";
150
+ if (Array.isArray(fieldError)) {
151
+ errorMessage = fieldError.join(" ");
152
+ }
153
+ if (typeof fieldError === "string") {
154
+ errorMessage = fieldError;
155
+ }
156
+ if (typeof fieldError === "boolean" && fieldError) {
157
+ errorMessage = "Field is not valid.";
158
+ }
159
+ setError(key, {
160
+ message: errorMessage
161
+ });
162
+ }
163
+ };
164
+
138
165
  // src/utils/propertyExists.ts
139
166
  function propertyExists(obj, prop) {
140
167
  return typeof obj === "object" && obj !== null && Object.prototype.hasOwnProperty.call(obj, prop);
@@ -156,6 +183,20 @@ var removeLeadingTrailingSlashes = (route) => {
156
183
  return route.replace(/^\/|\/$/g, "");
157
184
  };
158
185
 
186
+ // src/utils/schemaTools.ts
187
+ var _dayjs = require('dayjs'); var _dayjs2 = _interopRequireDefault(_dayjs);
188
+ var _zod = require('zod');
189
+ var schemaTools = {
190
+ date: () => _zod.z.coerce.string().transform((c) => c === "null" || c === "undefined" ? null : c).refine((c) => !!c, { message: "required" }).refine((c) => !!c ? _dayjs2.default.call(void 0, c).isValid() : true, {
191
+ message: "Invalid date"
192
+ }),
193
+ nullableDate: () => _zod.z.coerce.string().transform((c) => c === "null" ? null : c).transform((c) => c === "undefined" ? null : c).refine((c) => !c && c != null ? _dayjs2.default.call(void 0, c).isValid() : true, {
194
+ message: "Invalid date"
195
+ })
196
+ };
197
+
198
+
199
+
159
200
 
160
201
 
161
202
 
@@ -163,4 +204,4 @@ var removeLeadingTrailingSlashes = (route) => {
163
204
 
164
205
 
165
206
 
166
- exports.api = api; exports.flattenObjectKeys = flattenObjectKeys; exports.getTimezone = getTimezone; exports.propertyExists = propertyExists; exports.readValueAsDate = readValueAsDate; exports.removeLeadingTrailingSlashes = removeLeadingTrailingSlashes;
207
+ exports.api = api; exports.flattenObjectKeys = flattenObjectKeys; exports.getTimezone = getTimezone; exports.handleServerErrors = handleServerErrors; exports.propertyExists = propertyExists; exports.readValueAsDate = readValueAsDate; exports.removeLeadingTrailingSlashes = removeLeadingTrailingSlashes; exports.schemaTools = schemaTools;
@@ -2,7 +2,7 @@
2
2
  var _material = require('@mui/material');
3
3
  var _jsxruntime = require('react/jsx-runtime');
4
4
  var ClearButton = ({ isSubmitting, handleClear }) => {
5
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Button, { variant: "outlined", onClick: handleClear, children: "Clear" });
5
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Button, { variant: "outlined", onClick: handleClear, disabled: isSubmitting, children: "Clear" });
6
6
  };
7
7
  var ClearButton_default = ClearButton;
8
8
 
@@ -3,7 +3,7 @@
3
3
  var _chunk6JZ35VQJjs = require('./chunk-6JZ35VQJ.js');
4
4
 
5
5
 
6
- var _chunkYAGXZLL6js = require('./chunk-YAGXZLL6.js');
6
+ var _chunkBSA6BJG2js = require('./chunk-BSA6BJG2.js');
7
7
 
8
8
  // src/wrappers/DatePickerElement/DatePickerElement.tsx
9
9
 
@@ -45,7 +45,7 @@ var Component = function DatePickerElement(props) {
45
45
  value: field.value,
46
46
  onChange: field.onChange,
47
47
  transform: {
48
- input: typeof _optionalChain([transform, 'optionalAccess', _3 => _3.input]) === "function" ? transform.input : (newValue) => _chunkYAGXZLL6js.readValueAsDate.call(void 0, adapter, newValue),
48
+ input: typeof _optionalChain([transform, 'optionalAccess', _3 => _3.input]) === "function" ? transform.input : (newValue) => _chunkBSA6BJG2js.readValueAsDate.call(void 0, adapter, newValue),
49
49
  output: typeof _optionalChain([transform, 'optionalAccess', _4 => _4.output]) === "function" ? transform.output : (newValue) => newValue
50
50
  }
51
51
  });
@@ -476,7 +476,7 @@ var Component5 = function TimePickerElement(props) {
476
476
  value: field.value,
477
477
  onChange: field.onChange,
478
478
  transform: {
479
- input: typeof _optionalChain([transform, 'optionalAccess', _15 => _15.input]) === "function" ? transform.input : (newValue) => _chunkYAGXZLL6js.readValueAsDate.call(void 0, adapter, newValue),
479
+ input: typeof _optionalChain([transform, 'optionalAccess', _15 => _15.input]) === "function" ? transform.input : (newValue) => _chunkBSA6BJG2js.readValueAsDate.call(void 0, adapter, newValue),
480
480
  output: typeof _optionalChain([transform, 'optionalAccess', _16 => _16.output]) === "function" ? transform.output : (newValue) => newValue
481
481
  }
482
482
  });
@@ -2,7 +2,7 @@
2
2
  import { Button } from "@mui/material";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  var ClearButton = ({ isSubmitting, handleClear }) => {
5
- return /* @__PURE__ */ jsx(Button, { variant: "outlined", onClick: handleClear, children: "Clear" });
5
+ return /* @__PURE__ */ jsx(Button, { variant: "outlined", onClick: handleClear, disabled: isSubmitting, children: "Clear" });
6
6
  };
7
7
  var ClearButton_default = ClearButton;
8
8
 
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkDK74BFWAjs = require('../chunk-DK74BFWA.js');
8
+ var _chunkMXOTA42Jjs = require('../chunk-MXOTA42J.js');
9
9
 
10
10
 
11
11
 
@@ -13,4 +13,4 @@ var _chunkDK74BFWAjs = require('../chunk-DK74BFWA.js');
13
13
 
14
14
 
15
15
 
16
- exports.ClearButton = _chunkDK74BFWAjs.ClearButton_default; exports.FilterButton = _chunkDK74BFWAjs.FilterButton_default; exports.FormWrapper = _chunkDK74BFWAjs.FormWrapper_default; exports.LabelText = _chunkDK74BFWAjs.LabelText_default; exports.ListWrapper = _chunkDK74BFWAjs.ListWrapper_default; exports.SimpleToolbar = _chunkDK74BFWAjs.SimpleToolbar_default;
16
+ exports.ClearButton = _chunkMXOTA42Jjs.ClearButton_default; exports.FilterButton = _chunkMXOTA42Jjs.FilterButton_default; exports.FormWrapper = _chunkMXOTA42Jjs.FormWrapper_default; exports.LabelText = _chunkMXOTA42Jjs.LabelText_default; exports.ListWrapper = _chunkMXOTA42Jjs.ListWrapper_default; exports.SimpleToolbar = _chunkMXOTA42Jjs.SimpleToolbar_default;
@@ -5,7 +5,7 @@ import {
5
5
  LabelText_default,
6
6
  ListWrapper_default,
7
7
  SimpleToolbar_default
8
- } from "../chunk-BWAFZ6F6.mjs";
8
+ } from "../chunk-WE5MOMEE.mjs";
9
9
  export {
10
10
  ClearButton_default as ClearButton,
11
11
  FilterButton_default as FilterButton,
package/dist/index.d.mts CHANGED
@@ -1,14 +1,15 @@
1
1
  export { ClearButton, FilterButton, FormWrapper, LabelText, ListWrapper, SimpleToolbar } from './components/index.mjs';
2
2
  export { UseTransformOptions, UseTransformReturn, useTransform } from './hooks/index.mjs';
3
+ export { AsyncMultiSelectPayload, ListResponse, OptionItem, OptionItem2, PostModel, ValueLabel } from './types/index.mjs';
4
+ export { api, flattenObjectKeys, getTimezone, handleServerErrors, propertyExists, readValueAsDate, removeLeadingTrailingSlashes, schemaTools } from './utils/index.mjs';
5
+ export { Field } from './wrappers/index.mjs';
3
6
  export { A as ApiResponse, V as ValidationErrors } from './ApiResponse-DWjEML13.mjs';
4
7
  export { A as AsyncSelectPayload } from './AsyncSelectPayload-DHN-R3gc.mjs';
5
- export { AsyncMultiSelectPayload, OptionItem, OptionItem2 } from './types/index.mjs';
6
- export { api, flattenObjectKeys, getTimezone, propertyExists, readValueAsDate, removeLeadingTrailingSlashes } from './utils/index.mjs';
7
- export { Field } from './wrappers/index.mjs';
8
8
  import 'react/jsx-runtime';
9
9
  import 'react';
10
10
  import 'react-hook-form';
11
11
  import '@mui/x-date-pickers';
12
12
  import '@mui/x-date-pickers/internals';
13
+ import 'zod';
13
14
  import '@mui/material';
14
15
  import '@mui/x-date-pickers/models';
package/dist/index.d.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  export { ClearButton, FilterButton, FormWrapper, LabelText, ListWrapper, SimpleToolbar } from './components/index.js';
2
2
  export { UseTransformOptions, UseTransformReturn, useTransform } from './hooks/index.js';
3
+ export { AsyncMultiSelectPayload, ListResponse, OptionItem, OptionItem2, PostModel, ValueLabel } from './types/index.js';
4
+ export { api, flattenObjectKeys, getTimezone, handleServerErrors, propertyExists, readValueAsDate, removeLeadingTrailingSlashes, schemaTools } from './utils/index.js';
5
+ export { Field } from './wrappers/index.js';
3
6
  export { A as ApiResponse, V as ValidationErrors } from './ApiResponse-DWjEML13.js';
4
7
  export { A as AsyncSelectPayload } from './AsyncSelectPayload-DHN-R3gc.js';
5
- export { AsyncMultiSelectPayload, OptionItem, OptionItem2 } from './types/index.js';
6
- export { api, flattenObjectKeys, getTimezone, propertyExists, readValueAsDate, removeLeadingTrailingSlashes } from './utils/index.js';
7
- export { Field } from './wrappers/index.js';
8
8
  import 'react/jsx-runtime';
9
9
  import 'react';
10
10
  import 'react-hook-form';
11
11
  import '@mui/x-date-pickers';
12
12
  import '@mui/x-date-pickers/internals';
13
+ import 'zod';
13
14
  import '@mui/material';
14
15
  import '@mui/x-date-pickers/models';
package/dist/index.js CHANGED
@@ -5,12 +5,12 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkDK74BFWAjs = require('./chunk-DK74BFWA.js');
8
+ var _chunkMXOTA42Jjs = require('./chunk-MXOTA42J.js');
9
9
  require('./chunk-7M2VOCYN.js');
10
10
  require('./chunk-TLJXC46A.js');
11
11
 
12
12
 
13
- var _chunkNLI47OFIjs = require('./chunk-NLI47OFI.js');
13
+ var _chunkTP5OSIU5js = require('./chunk-TP5OSIU5.js');
14
14
 
15
15
 
16
16
  var _chunk6JZ35VQJjs = require('./chunk-6JZ35VQJ.js');
@@ -21,9 +21,9 @@ var _chunk6JZ35VQJjs = require('./chunk-6JZ35VQJ.js');
21
21
 
22
22
 
23
23
 
24
- var _chunkYAGXZLL6js = require('./chunk-YAGXZLL6.js');
25
24
 
26
25
 
26
+ var _chunkBSA6BJG2js = require('./chunk-BSA6BJG2.js');
27
27
 
28
28
 
29
29
 
@@ -37,4 +37,8 @@ var _chunkYAGXZLL6js = require('./chunk-YAGXZLL6.js');
37
37
 
38
38
 
39
39
 
40
- exports.ClearButton = _chunkDK74BFWAjs.ClearButton_default; exports.Field = _chunkNLI47OFIjs.Field_default; exports.FilterButton = _chunkDK74BFWAjs.FilterButton_default; exports.FormWrapper = _chunkDK74BFWAjs.FormWrapper_default; exports.LabelText = _chunkDK74BFWAjs.LabelText_default; exports.ListWrapper = _chunkDK74BFWAjs.ListWrapper_default; exports.SimpleToolbar = _chunkDK74BFWAjs.SimpleToolbar_default; exports.api = _chunkYAGXZLL6js.api; exports.flattenObjectKeys = _chunkYAGXZLL6js.flattenObjectKeys; exports.getTimezone = _chunkYAGXZLL6js.getTimezone; exports.propertyExists = _chunkYAGXZLL6js.propertyExists; exports.readValueAsDate = _chunkYAGXZLL6js.readValueAsDate; exports.removeLeadingTrailingSlashes = _chunkYAGXZLL6js.removeLeadingTrailingSlashes; exports.useTransform = _chunk6JZ35VQJjs.useTransform;
40
+
41
+
42
+
43
+
44
+ exports.ClearButton = _chunkMXOTA42Jjs.ClearButton_default; exports.Field = _chunkTP5OSIU5js.Field_default; exports.FilterButton = _chunkMXOTA42Jjs.FilterButton_default; exports.FormWrapper = _chunkMXOTA42Jjs.FormWrapper_default; exports.LabelText = _chunkMXOTA42Jjs.LabelText_default; exports.ListWrapper = _chunkMXOTA42Jjs.ListWrapper_default; exports.SimpleToolbar = _chunkMXOTA42Jjs.SimpleToolbar_default; exports.api = _chunkBSA6BJG2js.api; exports.flattenObjectKeys = _chunkBSA6BJG2js.flattenObjectKeys; exports.getTimezone = _chunkBSA6BJG2js.getTimezone; exports.handleServerErrors = _chunkBSA6BJG2js.handleServerErrors; exports.propertyExists = _chunkBSA6BJG2js.propertyExists; exports.readValueAsDate = _chunkBSA6BJG2js.readValueAsDate; exports.removeLeadingTrailingSlashes = _chunkBSA6BJG2js.removeLeadingTrailingSlashes; exports.schemaTools = _chunkBSA6BJG2js.schemaTools; exports.useTransform = _chunk6JZ35VQJjs.useTransform;
package/dist/index.mjs CHANGED
@@ -5,12 +5,12 @@ import {
5
5
  LabelText_default,
6
6
  ListWrapper_default,
7
7
  SimpleToolbar_default
8
- } from "./chunk-BWAFZ6F6.mjs";
8
+ } from "./chunk-WE5MOMEE.mjs";
9
9
  import "./chunk-2JFL7TS5.mjs";
10
10
  import "./chunk-5VR5QVUV.mjs";
11
11
  import {
12
12
  Field_default
13
- } from "./chunk-2VRWJP7M.mjs";
13
+ } from "./chunk-B3F2F3PI.mjs";
14
14
  import {
15
15
  useTransform
16
16
  } from "./chunk-GFSTK7KN.mjs";
@@ -18,10 +18,12 @@ import {
18
18
  api,
19
19
  flattenObjectKeys,
20
20
  getTimezone,
21
+ handleServerErrors,
21
22
  propertyExists,
22
23
  readValueAsDate,
23
- removeLeadingTrailingSlashes
24
- } from "./chunk-DMQDQUAE.mjs";
24
+ removeLeadingTrailingSlashes,
25
+ schemaTools
26
+ } from "./chunk-44LP4RZD.mjs";
25
27
  export {
26
28
  ClearButton_default as ClearButton,
27
29
  Field_default as Field,
@@ -33,8 +35,10 @@ export {
33
35
  api,
34
36
  flattenObjectKeys,
35
37
  getTimezone,
38
+ handleServerErrors,
36
39
  propertyExists,
37
40
  readValueAsDate,
38
41
  removeLeadingTrailingSlashes,
42
+ schemaTools,
39
43
  useTransform
40
44
  };
@@ -14,4 +14,24 @@ type OptionItem2 = {
14
14
  value: number;
15
15
  };
16
16
 
17
- export type { AsyncMultiSelectPayload, OptionItem, OptionItem2 };
17
+ type PostModel<TFilterModel> = {
18
+ filterModel?: TFilterModel;
19
+ pageOffset: number;
20
+ pageSize: number;
21
+ sortField: string | null;
22
+ sortOrder: "asc" | "desc" | null | undefined;
23
+ sortModel?: {
24
+ sortField: string | null;
25
+ sortDirection: string | null;
26
+ };
27
+ };
28
+ type ListResponse<TGridModel> = {
29
+ data: TGridModel[];
30
+ total: number;
31
+ };
32
+ type ValueLabel = {
33
+ value: number;
34
+ label: number;
35
+ };
36
+
37
+ export type { AsyncMultiSelectPayload, ListResponse, OptionItem, OptionItem2, PostModel, ValueLabel };
@@ -14,4 +14,24 @@ type OptionItem2 = {
14
14
  value: number;
15
15
  };
16
16
 
17
- export type { AsyncMultiSelectPayload, OptionItem, OptionItem2 };
17
+ type PostModel<TFilterModel> = {
18
+ filterModel?: TFilterModel;
19
+ pageOffset: number;
20
+ pageSize: number;
21
+ sortField: string | null;
22
+ sortOrder: "asc" | "desc" | null | undefined;
23
+ sortModel?: {
24
+ sortField: string | null;
25
+ sortDirection: string | null;
26
+ };
27
+ };
28
+ type ListResponse<TGridModel> = {
29
+ data: TGridModel[];
30
+ total: number;
31
+ };
32
+ type ValueLabel = {
33
+ value: number;
34
+ label: number;
35
+ };
36
+
37
+ export type { AsyncMultiSelectPayload, ListResponse, OptionItem, OptionItem2, PostModel, ValueLabel };
@@ -1,6 +1,8 @@
1
1
  import { A as ApiResponse } from '../ApiResponse-DWjEML13.mjs';
2
2
  import { PickerValidDate } from '@mui/x-date-pickers';
3
3
  import { useLocalizationContext } from '@mui/x-date-pickers/internals';
4
+ import { FieldValues, UseFormSetError } from 'react-hook-form';
5
+ import { z } from 'zod';
4
6
 
5
7
  declare class api {
6
8
  static post<T>(url: string, body?: any): Promise<ApiResponse<T>>;
@@ -18,10 +20,21 @@ declare const flattenObjectKeys: (obj: any, prefix?: string) => {
18
20
 
19
21
  declare function getTimezone<TDate extends PickerValidDate>(adapter: ReturnType<typeof useLocalizationContext>, value: TDate): string | null;
20
22
 
23
+ type HandleServerErrorsType<TFieldValues extends FieldValues = FieldValues> = {
24
+ errors: Record<string, string[]>;
25
+ setError: UseFormSetError<TFieldValues>;
26
+ };
27
+ declare const handleServerErrors: <TFieldValues extends FieldValues = FieldValues>(args: HandleServerErrorsType<TFieldValues>) => void;
28
+
21
29
  declare function propertyExists<X, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown>;
22
30
 
23
31
  declare function readValueAsDate<TDate extends PickerValidDate>(adapter: ReturnType<typeof useLocalizationContext>, value: string | null | TDate): TDate | null;
24
32
 
25
33
  declare const removeLeadingTrailingSlashes: (route: string) => string;
26
34
 
27
- export { api, flattenObjectKeys, getTimezone, propertyExists, readValueAsDate, removeLeadingTrailingSlashes };
35
+ declare const schemaTools: {
36
+ date: () => z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string | null, string>, string | null, string>, string | null, string>;
37
+ nullableDate: () => z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string | null, string>, string | null, string>, string | null, string>;
38
+ };
39
+
40
+ export { api, flattenObjectKeys, getTimezone, handleServerErrors, propertyExists, readValueAsDate, removeLeadingTrailingSlashes, schemaTools };
@@ -1,6 +1,8 @@
1
1
  import { A as ApiResponse } from '../ApiResponse-DWjEML13.js';
2
2
  import { PickerValidDate } from '@mui/x-date-pickers';
3
3
  import { useLocalizationContext } from '@mui/x-date-pickers/internals';
4
+ import { FieldValues, UseFormSetError } from 'react-hook-form';
5
+ import { z } from 'zod';
4
6
 
5
7
  declare class api {
6
8
  static post<T>(url: string, body?: any): Promise<ApiResponse<T>>;
@@ -18,10 +20,21 @@ declare const flattenObjectKeys: (obj: any, prefix?: string) => {
18
20
 
19
21
  declare function getTimezone<TDate extends PickerValidDate>(adapter: ReturnType<typeof useLocalizationContext>, value: TDate): string | null;
20
22
 
23
+ type HandleServerErrorsType<TFieldValues extends FieldValues = FieldValues> = {
24
+ errors: Record<string, string[]>;
25
+ setError: UseFormSetError<TFieldValues>;
26
+ };
27
+ declare const handleServerErrors: <TFieldValues extends FieldValues = FieldValues>(args: HandleServerErrorsType<TFieldValues>) => void;
28
+
21
29
  declare function propertyExists<X, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown>;
22
30
 
23
31
  declare function readValueAsDate<TDate extends PickerValidDate>(adapter: ReturnType<typeof useLocalizationContext>, value: string | null | TDate): TDate | null;
24
32
 
25
33
  declare const removeLeadingTrailingSlashes: (route: string) => string;
26
34
 
27
- export { api, flattenObjectKeys, getTimezone, propertyExists, readValueAsDate, removeLeadingTrailingSlashes };
35
+ declare const schemaTools: {
36
+ date: () => z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string | null, string>, string | null, string>, string | null, string>;
37
+ nullableDate: () => z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string | null, string>, string | null, string>, string | null, string>;
38
+ };
39
+
40
+ export { api, flattenObjectKeys, getTimezone, handleServerErrors, propertyExists, readValueAsDate, removeLeadingTrailingSlashes, schemaTools };
@@ -5,12 +5,16 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkYAGXZLL6js = require('../chunk-YAGXZLL6.js');
9
8
 
10
9
 
10
+ var _chunkBSA6BJG2js = require('../chunk-BSA6BJG2.js');
11
11
 
12
12
 
13
13
 
14
14
 
15
15
 
16
- exports.api = _chunkYAGXZLL6js.api; exports.flattenObjectKeys = _chunkYAGXZLL6js.flattenObjectKeys; exports.getTimezone = _chunkYAGXZLL6js.getTimezone; exports.propertyExists = _chunkYAGXZLL6js.propertyExists; exports.readValueAsDate = _chunkYAGXZLL6js.readValueAsDate; exports.removeLeadingTrailingSlashes = _chunkYAGXZLL6js.removeLeadingTrailingSlashes;
16
+
17
+
18
+
19
+
20
+ exports.api = _chunkBSA6BJG2js.api; exports.flattenObjectKeys = _chunkBSA6BJG2js.flattenObjectKeys; exports.getTimezone = _chunkBSA6BJG2js.getTimezone; exports.handleServerErrors = _chunkBSA6BJG2js.handleServerErrors; exports.propertyExists = _chunkBSA6BJG2js.propertyExists; exports.readValueAsDate = _chunkBSA6BJG2js.readValueAsDate; exports.removeLeadingTrailingSlashes = _chunkBSA6BJG2js.removeLeadingTrailingSlashes; exports.schemaTools = _chunkBSA6BJG2js.schemaTools;
@@ -2,15 +2,19 @@ import {
2
2
  api,
3
3
  flattenObjectKeys,
4
4
  getTimezone,
5
+ handleServerErrors,
5
6
  propertyExists,
6
7
  readValueAsDate,
7
- removeLeadingTrailingSlashes
8
- } from "../chunk-DMQDQUAE.mjs";
8
+ removeLeadingTrailingSlashes,
9
+ schemaTools
10
+ } from "../chunk-44LP4RZD.mjs";
9
11
  export {
10
12
  api,
11
13
  flattenObjectKeys,
12
14
  getTimezone,
15
+ handleServerErrors,
13
16
  propertyExists,
14
17
  readValueAsDate,
15
- removeLeadingTrailingSlashes
18
+ removeLeadingTrailingSlashes,
19
+ schemaTools
16
20
  };
@@ -1,8 +1,8 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkNLI47OFIjs = require('../chunk-NLI47OFI.js');
3
+ var _chunkTP5OSIU5js = require('../chunk-TP5OSIU5.js');
4
4
  require('../chunk-6JZ35VQJ.js');
5
- require('../chunk-YAGXZLL6.js');
5
+ require('../chunk-BSA6BJG2.js');
6
6
 
7
7
 
8
- exports.Field = _chunkNLI47OFIjs.Field_default;
8
+ exports.Field = _chunkTP5OSIU5js.Field_default;
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  Field_default
3
- } from "../chunk-2VRWJP7M.mjs";
3
+ } from "../chunk-B3F2F3PI.mjs";
4
4
  import "../chunk-GFSTK7KN.mjs";
5
- import "../chunk-DMQDQUAE.mjs";
5
+ import "../chunk-44LP4RZD.mjs";
6
6
  export {
7
7
  Field_default as Field
8
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gnwebsoft/ui",
3
- "version": "2.17.3",
3
+ "version": "2.17.5",
4
4
  "description": "A set of reusable wrappers for MUI v6",
5
5
  "author": "GNWebsoft Private Limited",
6
6
  "license": "",