@bsol-oss/react-datatable5 13.0.1-beta.26 → 13.0.1-beta.27
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.
- package/dist/index.d.ts +7 -12
- package/dist/index.js +13 -223
- package/dist/index.mjs +14 -224
- package/dist/types/components/Form/components/core/FormRoot.d.ts +1 -1
- package/dist/types/components/Form/components/types/CustomJSONSchema7.d.ts +1 -1
- package/dist/types/components/Form/useForm.d.ts +4 -9
- package/package.json +4 -1
package/dist/index.d.ts
CHANGED
|
@@ -614,7 +614,7 @@ interface CustomJSONSchema7 extends Omit<JSONSchema7, 'items' | 'additionalItems
|
|
|
614
614
|
showLabel?: boolean;
|
|
615
615
|
formatOptions?: Intl.NumberFormatOptions;
|
|
616
616
|
numberStorageType?: 'string' | 'number';
|
|
617
|
-
|
|
617
|
+
errorMessage?: Record<Partial<ValidationErrorType> | string, string | Record<string, string>>;
|
|
618
618
|
filePicker?: FilePickerProps;
|
|
619
619
|
tagPicker?: {
|
|
620
620
|
queryFn?: (params: {
|
|
@@ -719,7 +719,7 @@ interface FormRootProps<TData extends FieldValues> {
|
|
|
719
719
|
requestUrl?: string;
|
|
720
720
|
idMap: Record<string, object>;
|
|
721
721
|
setIdMap: Dispatch<SetStateAction<Record<string, object>>>;
|
|
722
|
-
form: UseFormReturn
|
|
722
|
+
form: UseFormReturn<TData, any, TData>;
|
|
723
723
|
children: ReactNode;
|
|
724
724
|
order?: string[];
|
|
725
725
|
ignore?: string[];
|
|
@@ -783,17 +783,12 @@ type MediaLibraryBrowserPropsMultiple = MediaLibraryBrowserPropsBase & {
|
|
|
783
783
|
type MediaLibraryBrowserProps = MediaLibraryBrowserPropsSingle | MediaLibraryBrowserPropsMultiple;
|
|
784
784
|
declare const MediaLibraryBrowser: ({ onFetchFiles, filterImageOnly, labels, enabled, multiple, onFileSelect, selectedFile: controlledSelectedFile, onSelectedFileChange, }: MediaLibraryBrowserProps) => react_jsx_runtime.JSX.Element | null;
|
|
785
785
|
|
|
786
|
-
interface
|
|
787
|
-
|
|
788
|
-
i18n?: any;
|
|
789
|
-
ready?: boolean;
|
|
790
|
-
}
|
|
791
|
-
interface UseFormProps {
|
|
792
|
-
preLoadedValues?: FieldValues | undefined;
|
|
786
|
+
interface UseFormProps<T> {
|
|
787
|
+
preLoadedValues?: T | undefined;
|
|
793
788
|
schema?: CustomJSONSchema7;
|
|
794
789
|
}
|
|
795
|
-
declare
|
|
796
|
-
form: react_hook_form.UseFormReturn<
|
|
790
|
+
declare function useForm<T extends FieldValues = any>({ preLoadedValues, schema, }: UseFormProps<T>): {
|
|
791
|
+
form: react_hook_form.UseFormReturn<T, any, T>;
|
|
797
792
|
idMap: Record<string, object>;
|
|
798
793
|
setIdMap: React$1.Dispatch<React$1.SetStateAction<Record<string, object>>>;
|
|
799
794
|
};
|
|
@@ -1259,4 +1254,4 @@ declare module '@tanstack/react-table' {
|
|
|
1259
1254
|
}
|
|
1260
1255
|
}
|
|
1261
1256
|
|
|
1262
|
-
export { CalendarDisplay, type CalendarDisplayProps, type CalendarEvent, type CalendarProps, CardHeader, type CardHeaderProps, type CustomJSONSchema7, type CustomJSONSchema7Definition, DataDisplay, type DataDisplayProps, type DataResponse, DataTable, type DataTableDefaultState, type DataTableProps, DataTableServer, type DataTableServerProps, DatePickerContext, DatePickerInput, type DatePickerInputProps, type DatePickerLabels, type DatePickerProps, type DateTimePickerLabels, DefaultCardTitle, DefaultForm, type DefaultFormProps, DefaultTable, type DefaultTableProps, DefaultTableServer, type DefaultTableServerProps, DensityToggleButton, type DensityToggleButtonProps, type EditFilterButtonProps, EditSortingButton, type EditSortingButtonProps, type EditViewButtonProps, EmptyState, type EmptyStateProps, type EnumPickerLabels, ErrorAlert, type ErrorAlertProps, type FilePickerLabels, type FilePickerMediaFile, type FilePickerProps, FilterDialog, FormBody, type FormButtonLabels, FormRoot, type FormRootProps, FormTitle, type GetDateColorProps, type GetMultiDatesProps, type GetRangeDatesProps, type GetStyleProps, type GetVariantProps, GlobalFilter, type IdPickerLabels, type LoadInitialValuesParams, type LoadInitialValuesResult, MediaLibraryBrowser, type MediaLibraryBrowserProps, PageSizeControl, type PageSizeControlProps, Pagination, type QueryParams, type RangeCalendarProps, type RangeDatePickerLabels, type RangeDatePickerProps, RecordDisplay, type RecordDisplayProps, ReloadButton, type ReloadButtonProps, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, type Result, RowCountText, SelectAllRowsToggle, type SelectAllRowsToggleProps, Table, TableBody, type TableBodyProps, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableComponent, TableControls, type TableControlsProps, TableDataDisplay, type TableDataDisplayProps, TableFilter, TableFilterTags, type TableFilterTagsProps, TableFooter, type TableFooterProps, TableHeader, type TableHeaderProps, type TableHeaderTexts, TableLoadingComponent, type TableLoadingComponentProps, type TableProps, type TableRendererProps, type TableRowSelectorProps, TableSelector, TableSorter, TableViewer, type TagPickerProps, TextCell, type TextCellProps, type TimePickerLabels, type
|
|
1257
|
+
export { CalendarDisplay, type CalendarDisplayProps, type CalendarEvent, type CalendarProps, CardHeader, type CardHeaderProps, type CustomJSONSchema7, type CustomJSONSchema7Definition, DataDisplay, type DataDisplayProps, type DataResponse, DataTable, type DataTableDefaultState, type DataTableProps, DataTableServer, type DataTableServerProps, DatePickerContext, DatePickerInput, type DatePickerInputProps, type DatePickerLabels, type DatePickerProps, type DateTimePickerLabels, DefaultCardTitle, DefaultForm, type DefaultFormProps, DefaultTable, type DefaultTableProps, DefaultTableServer, type DefaultTableServerProps, DensityToggleButton, type DensityToggleButtonProps, type EditFilterButtonProps, EditSortingButton, type EditSortingButtonProps, type EditViewButtonProps, EmptyState, type EmptyStateProps, type EnumPickerLabels, ErrorAlert, type ErrorAlertProps, type FilePickerLabels, type FilePickerMediaFile, type FilePickerProps, FilterDialog, FormBody, type FormButtonLabels, FormRoot, type FormRootProps, FormTitle, type GetDateColorProps, type GetMultiDatesProps, type GetRangeDatesProps, type GetStyleProps, type GetVariantProps, GlobalFilter, type IdPickerLabels, type LoadInitialValuesParams, type LoadInitialValuesResult, MediaLibraryBrowser, type MediaLibraryBrowserProps, PageSizeControl, type PageSizeControlProps, Pagination, type QueryParams, type RangeCalendarProps, type RangeDatePickerLabels, type RangeDatePickerProps, RecordDisplay, type RecordDisplayProps, ReloadButton, type ReloadButtonProps, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, type Result, RowCountText, SelectAllRowsToggle, type SelectAllRowsToggleProps, Table, TableBody, type TableBodyProps, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableComponent, TableControls, type TableControlsProps, TableDataDisplay, type TableDataDisplayProps, TableFilter, TableFilterTags, type TableFilterTagsProps, TableFooter, type TableFooterProps, TableHeader, type TableHeaderProps, type TableHeaderTexts, TableLoadingComponent, type TableLoadingComponentProps, type TableProps, type TableRendererProps, type TableRowSelectorProps, TableSelector, TableSorter, TableViewer, type TagPickerProps, TextCell, type TextCellProps, type TimePickerLabels, type UseDataTableProps, type UseDataTableReturn, type UseDataTableServerProps, type UseDataTableServerReturn, type UseFormProps, type ValidationErrorType, ViewDialog, defaultRenderDisplay, getMultiDates, getRangeDates, useDataTable, useDataTableContext, useDataTableServer, useForm };
|
package/dist/index.js
CHANGED
|
@@ -31,9 +31,7 @@ var customParseFormat = require('dayjs/plugin/customParseFormat');
|
|
|
31
31
|
var timezone = require('dayjs/plugin/timezone');
|
|
32
32
|
var utc = require('dayjs/plugin/utc');
|
|
33
33
|
var ti = require('react-icons/ti');
|
|
34
|
-
var
|
|
35
|
-
var addFormats = require('ajv-formats');
|
|
36
|
-
var AjvErrors = require('ajv-errors');
|
|
34
|
+
var ajv = require('@hookform/resolvers/ajv');
|
|
37
35
|
var matchSorterUtils = require('@tanstack/match-sorter-utils');
|
|
38
36
|
|
|
39
37
|
function _interopNamespaceDefault(e) {
|
|
@@ -1153,7 +1151,7 @@ function getElementFromPointWithoutHoneypot(client) {
|
|
|
1153
1151
|
var maxZIndex = 2147483647;
|
|
1154
1152
|
|
|
1155
1153
|
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1156
|
-
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t),
|
|
1154
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1157
1155
|
var honeyPotSize = 2;
|
|
1158
1156
|
var halfHoneyPotSize = honeyPotSize / 2;
|
|
1159
1157
|
|
|
@@ -2258,8 +2256,8 @@ function addAttribute(element, _ref) {
|
|
|
2258
2256
|
}
|
|
2259
2257
|
|
|
2260
2258
|
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2261
|
-
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t),
|
|
2262
|
-
function _createForOfIteratorHelper$1(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(r)) || e
|
|
2259
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2260
|
+
function _createForOfIteratorHelper$1(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
2263
2261
|
function _unsupportedIterableToArray$1(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$1(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0; } }
|
|
2264
2262
|
function _arrayLikeToArray$1(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
2265
2263
|
function copyReverse(array) {
|
|
@@ -2563,11 +2561,11 @@ function makeDropTarget(_ref) {
|
|
|
2563
2561
|
};
|
|
2564
2562
|
}
|
|
2565
2563
|
|
|
2566
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e
|
|
2564
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
2567
2565
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
2568
2566
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
2569
2567
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2570
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t),
|
|
2568
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2571
2569
|
function makeMonitor() {
|
|
2572
2570
|
var registry = new Set();
|
|
2573
2571
|
var dragging = null;
|
|
@@ -8192,223 +8190,15 @@ const DefaultForm = ({ formConfig, }) => {
|
|
|
8192
8190
|
return (jsxRuntime.jsx(FormRoot, { ...formConfig, children: jsxRuntime.jsxs(react.Grid, { gap: "2", children: [showTitle && jsxRuntime.jsx(FormTitle, {}), jsxRuntime.jsx(FormBody, {})] }) }));
|
|
8193
8191
|
};
|
|
8194
8192
|
|
|
8195
|
-
|
|
8196
|
-
const ajv = new Ajv({
|
|
8197
|
-
strict: false,
|
|
8198
|
-
allErrors: true,
|
|
8199
|
-
});
|
|
8200
|
-
addFormats(ajv);
|
|
8201
|
-
AjvErrors(ajv); // Load ajv-errors plugin to process errorMessage format
|
|
8202
|
-
const validate = ajv.compile(schema);
|
|
8203
|
-
const validationResult = validate(data);
|
|
8204
|
-
const errors = validate.errors;
|
|
8205
|
-
return {
|
|
8206
|
-
isValid: validationResult,
|
|
8207
|
-
validate,
|
|
8208
|
-
errors,
|
|
8209
|
-
};
|
|
8210
|
-
};
|
|
8211
|
-
|
|
8212
|
-
/**
|
|
8213
|
-
* Gets the schema node for a given field path
|
|
8214
|
-
*/
|
|
8215
|
-
const getSchemaNodeForField = (schema, fieldPath) => {
|
|
8216
|
-
if (!fieldPath || fieldPath === '') {
|
|
8217
|
-
return schema;
|
|
8218
|
-
}
|
|
8219
|
-
const pathParts = fieldPath.split('.');
|
|
8220
|
-
let currentSchema = schema;
|
|
8221
|
-
for (const part of pathParts) {
|
|
8222
|
-
if (currentSchema &&
|
|
8223
|
-
currentSchema.properties &&
|
|
8224
|
-
currentSchema.properties[part] &&
|
|
8225
|
-
typeof currentSchema.properties[part] === 'object' &&
|
|
8226
|
-
currentSchema.properties[part] !== null) {
|
|
8227
|
-
currentSchema = currentSchema.properties[part];
|
|
8228
|
-
}
|
|
8229
|
-
else {
|
|
8230
|
-
return undefined;
|
|
8231
|
-
}
|
|
8232
|
-
}
|
|
8233
|
-
return currentSchema;
|
|
8234
|
-
};
|
|
8235
|
-
/**
|
|
8236
|
-
* Strips null, undefined, and empty string values from an object
|
|
8237
|
-
*/
|
|
8238
|
-
const stripEmptyValues = (obj) => {
|
|
8239
|
-
if (obj === null || obj === undefined) {
|
|
8240
|
-
return undefined;
|
|
8241
|
-
}
|
|
8242
|
-
if (typeof obj === 'string' && obj.trim() === '') {
|
|
8243
|
-
return undefined;
|
|
8244
|
-
}
|
|
8245
|
-
if (Array.isArray(obj)) {
|
|
8246
|
-
const filtered = obj
|
|
8247
|
-
.map(stripEmptyValues)
|
|
8248
|
-
.filter((item) => item !== undefined);
|
|
8249
|
-
return filtered.length > 0 ? filtered : undefined;
|
|
8250
|
-
}
|
|
8251
|
-
if (typeof obj === 'object' && obj !== null) {
|
|
8252
|
-
const result = {};
|
|
8253
|
-
let hasValues = false;
|
|
8254
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
8255
|
-
const cleanedValue = stripEmptyValues(value);
|
|
8256
|
-
if (cleanedValue !== undefined) {
|
|
8257
|
-
result[key] = cleanedValue;
|
|
8258
|
-
hasValues = true;
|
|
8259
|
-
}
|
|
8260
|
-
}
|
|
8261
|
-
return hasValues ? result : undefined;
|
|
8262
|
-
}
|
|
8263
|
-
return obj;
|
|
8264
|
-
};
|
|
8265
|
-
/**
|
|
8266
|
-
* Converts AJV error objects to react-hook-form field errors format
|
|
8267
|
-
*/
|
|
8268
|
-
const convertAjvErrorsToFieldErrors = (errors, schema) => {
|
|
8269
|
-
if (!errors || errors.length === 0) {
|
|
8270
|
-
return {};
|
|
8271
|
-
}
|
|
8272
|
-
const fieldErrors = {};
|
|
8273
|
-
errors.forEach((error) => {
|
|
8274
|
-
let fieldName = '';
|
|
8275
|
-
// Special handling for required keyword: map to the specific missing property
|
|
8276
|
-
if (error.keyword === 'required') {
|
|
8277
|
-
const basePath = (error.instancePath || '')
|
|
8278
|
-
.replace(/^\//, '')
|
|
8279
|
-
.replace(/\//g, '.');
|
|
8280
|
-
const missingProperty = error.params && error.params.missingProperty;
|
|
8281
|
-
if (missingProperty) {
|
|
8282
|
-
fieldName = basePath
|
|
8283
|
-
? `${basePath}.${missingProperty}`
|
|
8284
|
-
: missingProperty;
|
|
8285
|
-
}
|
|
8286
|
-
else {
|
|
8287
|
-
// Fallback to schemaPath conversion if missingProperty is unavailable
|
|
8288
|
-
fieldName = (error.schemaPath || '')
|
|
8289
|
-
.replace(/^#\//, '#.')
|
|
8290
|
-
.replace(/\//g, '.');
|
|
8291
|
-
}
|
|
8292
|
-
}
|
|
8293
|
-
else {
|
|
8294
|
-
const fieldPath = error.instancePath || error.schemaPath;
|
|
8295
|
-
if (fieldPath) {
|
|
8296
|
-
fieldName = fieldPath.replace(/^\//, '').replace(/\//g, '.');
|
|
8297
|
-
}
|
|
8298
|
-
}
|
|
8299
|
-
if (fieldName) {
|
|
8300
|
-
// Get the schema node for this field to check for custom error messages
|
|
8301
|
-
const fieldSchema = getSchemaNodeForField(schema, fieldName);
|
|
8302
|
-
const customMessage = fieldSchema?.errorMessages?.[error.keyword];
|
|
8303
|
-
// Debug log when error message is missing
|
|
8304
|
-
if (!customMessage) {
|
|
8305
|
-
console.debug(`[Form Validation] Missing error message for field '${fieldName}' with keyword '${error.keyword}'. Add errorMessages.${error.keyword} to schema for field '${fieldName}'`, {
|
|
8306
|
-
fieldName,
|
|
8307
|
-
keyword: error.keyword,
|
|
8308
|
-
instancePath: error.instancePath,
|
|
8309
|
-
schemaPath: error.schemaPath,
|
|
8310
|
-
params: error.params,
|
|
8311
|
-
fieldSchema: fieldSchema
|
|
8312
|
-
? {
|
|
8313
|
-
type: fieldSchema.type,
|
|
8314
|
-
errorMessages: fieldSchema
|
|
8315
|
-
.errorMessages,
|
|
8316
|
-
}
|
|
8317
|
-
: undefined,
|
|
8318
|
-
});
|
|
8319
|
-
}
|
|
8320
|
-
// Provide helpful fallback message if no custom message is provided
|
|
8321
|
-
const fallbackMessage = customMessage ||
|
|
8322
|
-
`Missing error message for ${error.keyword}. Add errorMessages.${error.keyword} to schema for field '${fieldName}'`;
|
|
8323
|
-
if (error.keyword === 'required') {
|
|
8324
|
-
// Required errors override any existing non-required errors for this field
|
|
8325
|
-
fieldErrors[fieldName] = {
|
|
8326
|
-
type: 'required',
|
|
8327
|
-
keyword: error.keyword,
|
|
8328
|
-
params: error.params,
|
|
8329
|
-
message: fallbackMessage,
|
|
8330
|
-
};
|
|
8331
|
-
}
|
|
8332
|
-
else {
|
|
8333
|
-
const existing = fieldErrors[fieldName];
|
|
8334
|
-
if (existing) {
|
|
8335
|
-
// Do not override required errors
|
|
8336
|
-
if (existing.type === 'required') {
|
|
8337
|
-
return;
|
|
8338
|
-
}
|
|
8339
|
-
// Combine messages if multiple errors for same field
|
|
8340
|
-
existing.message = existing.message
|
|
8341
|
-
? `${existing.message}; ${fallbackMessage}`
|
|
8342
|
-
: fallbackMessage;
|
|
8343
|
-
}
|
|
8344
|
-
else {
|
|
8345
|
-
fieldErrors[fieldName] = {
|
|
8346
|
-
type: error.keyword,
|
|
8347
|
-
keyword: error.keyword,
|
|
8348
|
-
params: error.params,
|
|
8349
|
-
message: fallbackMessage,
|
|
8350
|
-
};
|
|
8351
|
-
}
|
|
8352
|
-
}
|
|
8353
|
-
}
|
|
8354
|
-
});
|
|
8355
|
-
return fieldErrors;
|
|
8356
|
-
};
|
|
8357
|
-
/**
|
|
8358
|
-
* AJV resolver for react-hook-form
|
|
8359
|
-
* Integrates AJV validation with react-hook-form's validation system
|
|
8360
|
-
*/
|
|
8361
|
-
const ajvResolver = (schema) => {
|
|
8362
|
-
return async (values) => {
|
|
8363
|
-
try {
|
|
8364
|
-
// Strip empty values before validation
|
|
8365
|
-
const cleanedValues = stripEmptyValues(values);
|
|
8366
|
-
// Use empty object for validation if all values were stripped
|
|
8367
|
-
const valuesToValidate = cleanedValues === undefined ? {} : cleanedValues;
|
|
8368
|
-
const { isValid, errors } = validateData(valuesToValidate, schema);
|
|
8369
|
-
console.debug('AJV Validation Result:', {
|
|
8370
|
-
isValid,
|
|
8371
|
-
errors,
|
|
8372
|
-
cleanedValues,
|
|
8373
|
-
valuesToValidate,
|
|
8374
|
-
});
|
|
8375
|
-
if (isValid) {
|
|
8376
|
-
return {
|
|
8377
|
-
values: (cleanedValues || {}),
|
|
8378
|
-
errors: {},
|
|
8379
|
-
};
|
|
8380
|
-
}
|
|
8381
|
-
const fieldErrors = convertAjvErrorsToFieldErrors(errors, schema);
|
|
8382
|
-
console.debug('AJV Validation Failed:', {
|
|
8383
|
-
errors,
|
|
8384
|
-
fieldErrors,
|
|
8385
|
-
cleanedValues,
|
|
8386
|
-
valuesToValidate,
|
|
8387
|
-
});
|
|
8388
|
-
return {
|
|
8389
|
-
values: {},
|
|
8390
|
-
errors: fieldErrors,
|
|
8391
|
-
};
|
|
8392
|
-
}
|
|
8393
|
-
catch (error) {
|
|
8394
|
-
return {
|
|
8395
|
-
values: {},
|
|
8396
|
-
errors: {
|
|
8397
|
-
root: {
|
|
8398
|
-
type: 'validation',
|
|
8399
|
-
message: error instanceof Error ? error.message : 'Validation failed',
|
|
8400
|
-
},
|
|
8401
|
-
},
|
|
8402
|
-
};
|
|
8403
|
-
}
|
|
8404
|
-
};
|
|
8405
|
-
};
|
|
8406
|
-
|
|
8407
|
-
const useForm = ({ preLoadedValues, schema }) => {
|
|
8193
|
+
function useForm({ preLoadedValues, schema, }) {
|
|
8408
8194
|
const form = reactHookForm.useForm({
|
|
8409
8195
|
values: preLoadedValues,
|
|
8410
8196
|
mode: 'onSubmit',
|
|
8411
|
-
resolver: schema
|
|
8197
|
+
resolver: schema
|
|
8198
|
+
? ajv.ajvResolver(schema, {
|
|
8199
|
+
strict: false,
|
|
8200
|
+
})
|
|
8201
|
+
: undefined,
|
|
8412
8202
|
reValidateMode: 'onChange',
|
|
8413
8203
|
});
|
|
8414
8204
|
const [idMap, setIdMap] = React.useState({});
|
|
@@ -8417,7 +8207,7 @@ const useForm = ({ preLoadedValues, schema }) => {
|
|
|
8417
8207
|
idMap,
|
|
8418
8208
|
setIdMap,
|
|
8419
8209
|
};
|
|
8420
|
-
}
|
|
8210
|
+
}
|
|
8421
8211
|
|
|
8422
8212
|
const getMultiDates = ({ selected, selectedDate, selectedDates, selectable, }) => {
|
|
8423
8213
|
if (!selectable) {
|
package/dist/index.mjs
CHANGED
|
@@ -21,7 +21,7 @@ import { IoReload } from 'react-icons/io5';
|
|
|
21
21
|
import { useDebounce } from '@uidotdev/usehooks';
|
|
22
22
|
import { BsExclamationCircleFill, BsClock } from 'react-icons/bs';
|
|
23
23
|
import { HiColorSwatch } from 'react-icons/hi';
|
|
24
|
-
import { flexRender, makeStateUpdater, functionalUpdate, useReactTable,
|
|
24
|
+
import { flexRender, makeStateUpdater, functionalUpdate, useReactTable, getPaginationRowModel, getSortedRowModel, getFilteredRowModel, getCoreRowModel } from '@tanstack/react-table';
|
|
25
25
|
import { GrAscend, GrDescend } from 'react-icons/gr';
|
|
26
26
|
import axios from 'axios';
|
|
27
27
|
import { useFormContext, FormProvider, useForm as useForm$1 } from 'react-hook-form';
|
|
@@ -30,9 +30,7 @@ import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
|
30
30
|
import timezone from 'dayjs/plugin/timezone';
|
|
31
31
|
import utc from 'dayjs/plugin/utc';
|
|
32
32
|
import { TiDeleteOutline } from 'react-icons/ti';
|
|
33
|
-
import
|
|
34
|
-
import addFormats from 'ajv-formats';
|
|
35
|
-
import AjvErrors from 'ajv-errors';
|
|
33
|
+
import { ajvResolver } from '@hookform/resolvers/ajv';
|
|
36
34
|
import { rankItem } from '@tanstack/match-sorter-utils';
|
|
37
35
|
|
|
38
36
|
const DataTableContext = createContext({
|
|
@@ -1133,7 +1131,7 @@ function getElementFromPointWithoutHoneypot(client) {
|
|
|
1133
1131
|
var maxZIndex = 2147483647;
|
|
1134
1132
|
|
|
1135
1133
|
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1136
|
-
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t),
|
|
1134
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1137
1135
|
var honeyPotSize = 2;
|
|
1138
1136
|
var halfHoneyPotSize = honeyPotSize / 2;
|
|
1139
1137
|
|
|
@@ -2238,8 +2236,8 @@ function addAttribute(element, _ref) {
|
|
|
2238
2236
|
}
|
|
2239
2237
|
|
|
2240
2238
|
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2241
|
-
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t),
|
|
2242
|
-
function _createForOfIteratorHelper$1(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(r)) || e
|
|
2239
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2240
|
+
function _createForOfIteratorHelper$1(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
2243
2241
|
function _unsupportedIterableToArray$1(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$1(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0; } }
|
|
2244
2242
|
function _arrayLikeToArray$1(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
2245
2243
|
function copyReverse(array) {
|
|
@@ -2543,11 +2541,11 @@ function makeDropTarget(_ref) {
|
|
|
2543
2541
|
};
|
|
2544
2542
|
}
|
|
2545
2543
|
|
|
2546
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e
|
|
2544
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
2547
2545
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
2548
2546
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
2549
2547
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2550
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t),
|
|
2548
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2551
2549
|
function makeMonitor() {
|
|
2552
2550
|
var registry = new Set();
|
|
2553
2551
|
var dragging = null;
|
|
@@ -8172,223 +8170,15 @@ const DefaultForm = ({ formConfig, }) => {
|
|
|
8172
8170
|
return (jsx(FormRoot, { ...formConfig, children: jsxs(Grid, { gap: "2", children: [showTitle && jsx(FormTitle, {}), jsx(FormBody, {})] }) }));
|
|
8173
8171
|
};
|
|
8174
8172
|
|
|
8175
|
-
|
|
8176
|
-
const ajv = new Ajv({
|
|
8177
|
-
strict: false,
|
|
8178
|
-
allErrors: true,
|
|
8179
|
-
});
|
|
8180
|
-
addFormats(ajv);
|
|
8181
|
-
AjvErrors(ajv); // Load ajv-errors plugin to process errorMessage format
|
|
8182
|
-
const validate = ajv.compile(schema);
|
|
8183
|
-
const validationResult = validate(data);
|
|
8184
|
-
const errors = validate.errors;
|
|
8185
|
-
return {
|
|
8186
|
-
isValid: validationResult,
|
|
8187
|
-
validate,
|
|
8188
|
-
errors,
|
|
8189
|
-
};
|
|
8190
|
-
};
|
|
8191
|
-
|
|
8192
|
-
/**
|
|
8193
|
-
* Gets the schema node for a given field path
|
|
8194
|
-
*/
|
|
8195
|
-
const getSchemaNodeForField = (schema, fieldPath) => {
|
|
8196
|
-
if (!fieldPath || fieldPath === '') {
|
|
8197
|
-
return schema;
|
|
8198
|
-
}
|
|
8199
|
-
const pathParts = fieldPath.split('.');
|
|
8200
|
-
let currentSchema = schema;
|
|
8201
|
-
for (const part of pathParts) {
|
|
8202
|
-
if (currentSchema &&
|
|
8203
|
-
currentSchema.properties &&
|
|
8204
|
-
currentSchema.properties[part] &&
|
|
8205
|
-
typeof currentSchema.properties[part] === 'object' &&
|
|
8206
|
-
currentSchema.properties[part] !== null) {
|
|
8207
|
-
currentSchema = currentSchema.properties[part];
|
|
8208
|
-
}
|
|
8209
|
-
else {
|
|
8210
|
-
return undefined;
|
|
8211
|
-
}
|
|
8212
|
-
}
|
|
8213
|
-
return currentSchema;
|
|
8214
|
-
};
|
|
8215
|
-
/**
|
|
8216
|
-
* Strips null, undefined, and empty string values from an object
|
|
8217
|
-
*/
|
|
8218
|
-
const stripEmptyValues = (obj) => {
|
|
8219
|
-
if (obj === null || obj === undefined) {
|
|
8220
|
-
return undefined;
|
|
8221
|
-
}
|
|
8222
|
-
if (typeof obj === 'string' && obj.trim() === '') {
|
|
8223
|
-
return undefined;
|
|
8224
|
-
}
|
|
8225
|
-
if (Array.isArray(obj)) {
|
|
8226
|
-
const filtered = obj
|
|
8227
|
-
.map(stripEmptyValues)
|
|
8228
|
-
.filter((item) => item !== undefined);
|
|
8229
|
-
return filtered.length > 0 ? filtered : undefined;
|
|
8230
|
-
}
|
|
8231
|
-
if (typeof obj === 'object' && obj !== null) {
|
|
8232
|
-
const result = {};
|
|
8233
|
-
let hasValues = false;
|
|
8234
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
8235
|
-
const cleanedValue = stripEmptyValues(value);
|
|
8236
|
-
if (cleanedValue !== undefined) {
|
|
8237
|
-
result[key] = cleanedValue;
|
|
8238
|
-
hasValues = true;
|
|
8239
|
-
}
|
|
8240
|
-
}
|
|
8241
|
-
return hasValues ? result : undefined;
|
|
8242
|
-
}
|
|
8243
|
-
return obj;
|
|
8244
|
-
};
|
|
8245
|
-
/**
|
|
8246
|
-
* Converts AJV error objects to react-hook-form field errors format
|
|
8247
|
-
*/
|
|
8248
|
-
const convertAjvErrorsToFieldErrors = (errors, schema) => {
|
|
8249
|
-
if (!errors || errors.length === 0) {
|
|
8250
|
-
return {};
|
|
8251
|
-
}
|
|
8252
|
-
const fieldErrors = {};
|
|
8253
|
-
errors.forEach((error) => {
|
|
8254
|
-
let fieldName = '';
|
|
8255
|
-
// Special handling for required keyword: map to the specific missing property
|
|
8256
|
-
if (error.keyword === 'required') {
|
|
8257
|
-
const basePath = (error.instancePath || '')
|
|
8258
|
-
.replace(/^\//, '')
|
|
8259
|
-
.replace(/\//g, '.');
|
|
8260
|
-
const missingProperty = error.params && error.params.missingProperty;
|
|
8261
|
-
if (missingProperty) {
|
|
8262
|
-
fieldName = basePath
|
|
8263
|
-
? `${basePath}.${missingProperty}`
|
|
8264
|
-
: missingProperty;
|
|
8265
|
-
}
|
|
8266
|
-
else {
|
|
8267
|
-
// Fallback to schemaPath conversion if missingProperty is unavailable
|
|
8268
|
-
fieldName = (error.schemaPath || '')
|
|
8269
|
-
.replace(/^#\//, '#.')
|
|
8270
|
-
.replace(/\//g, '.');
|
|
8271
|
-
}
|
|
8272
|
-
}
|
|
8273
|
-
else {
|
|
8274
|
-
const fieldPath = error.instancePath || error.schemaPath;
|
|
8275
|
-
if (fieldPath) {
|
|
8276
|
-
fieldName = fieldPath.replace(/^\//, '').replace(/\//g, '.');
|
|
8277
|
-
}
|
|
8278
|
-
}
|
|
8279
|
-
if (fieldName) {
|
|
8280
|
-
// Get the schema node for this field to check for custom error messages
|
|
8281
|
-
const fieldSchema = getSchemaNodeForField(schema, fieldName);
|
|
8282
|
-
const customMessage = fieldSchema?.errorMessages?.[error.keyword];
|
|
8283
|
-
// Debug log when error message is missing
|
|
8284
|
-
if (!customMessage) {
|
|
8285
|
-
console.debug(`[Form Validation] Missing error message for field '${fieldName}' with keyword '${error.keyword}'. Add errorMessages.${error.keyword} to schema for field '${fieldName}'`, {
|
|
8286
|
-
fieldName,
|
|
8287
|
-
keyword: error.keyword,
|
|
8288
|
-
instancePath: error.instancePath,
|
|
8289
|
-
schemaPath: error.schemaPath,
|
|
8290
|
-
params: error.params,
|
|
8291
|
-
fieldSchema: fieldSchema
|
|
8292
|
-
? {
|
|
8293
|
-
type: fieldSchema.type,
|
|
8294
|
-
errorMessages: fieldSchema
|
|
8295
|
-
.errorMessages,
|
|
8296
|
-
}
|
|
8297
|
-
: undefined,
|
|
8298
|
-
});
|
|
8299
|
-
}
|
|
8300
|
-
// Provide helpful fallback message if no custom message is provided
|
|
8301
|
-
const fallbackMessage = customMessage ||
|
|
8302
|
-
`Missing error message for ${error.keyword}. Add errorMessages.${error.keyword} to schema for field '${fieldName}'`;
|
|
8303
|
-
if (error.keyword === 'required') {
|
|
8304
|
-
// Required errors override any existing non-required errors for this field
|
|
8305
|
-
fieldErrors[fieldName] = {
|
|
8306
|
-
type: 'required',
|
|
8307
|
-
keyword: error.keyword,
|
|
8308
|
-
params: error.params,
|
|
8309
|
-
message: fallbackMessage,
|
|
8310
|
-
};
|
|
8311
|
-
}
|
|
8312
|
-
else {
|
|
8313
|
-
const existing = fieldErrors[fieldName];
|
|
8314
|
-
if (existing) {
|
|
8315
|
-
// Do not override required errors
|
|
8316
|
-
if (existing.type === 'required') {
|
|
8317
|
-
return;
|
|
8318
|
-
}
|
|
8319
|
-
// Combine messages if multiple errors for same field
|
|
8320
|
-
existing.message = existing.message
|
|
8321
|
-
? `${existing.message}; ${fallbackMessage}`
|
|
8322
|
-
: fallbackMessage;
|
|
8323
|
-
}
|
|
8324
|
-
else {
|
|
8325
|
-
fieldErrors[fieldName] = {
|
|
8326
|
-
type: error.keyword,
|
|
8327
|
-
keyword: error.keyword,
|
|
8328
|
-
params: error.params,
|
|
8329
|
-
message: fallbackMessage,
|
|
8330
|
-
};
|
|
8331
|
-
}
|
|
8332
|
-
}
|
|
8333
|
-
}
|
|
8334
|
-
});
|
|
8335
|
-
return fieldErrors;
|
|
8336
|
-
};
|
|
8337
|
-
/**
|
|
8338
|
-
* AJV resolver for react-hook-form
|
|
8339
|
-
* Integrates AJV validation with react-hook-form's validation system
|
|
8340
|
-
*/
|
|
8341
|
-
const ajvResolver = (schema) => {
|
|
8342
|
-
return async (values) => {
|
|
8343
|
-
try {
|
|
8344
|
-
// Strip empty values before validation
|
|
8345
|
-
const cleanedValues = stripEmptyValues(values);
|
|
8346
|
-
// Use empty object for validation if all values were stripped
|
|
8347
|
-
const valuesToValidate = cleanedValues === undefined ? {} : cleanedValues;
|
|
8348
|
-
const { isValid, errors } = validateData(valuesToValidate, schema);
|
|
8349
|
-
console.debug('AJV Validation Result:', {
|
|
8350
|
-
isValid,
|
|
8351
|
-
errors,
|
|
8352
|
-
cleanedValues,
|
|
8353
|
-
valuesToValidate,
|
|
8354
|
-
});
|
|
8355
|
-
if (isValid) {
|
|
8356
|
-
return {
|
|
8357
|
-
values: (cleanedValues || {}),
|
|
8358
|
-
errors: {},
|
|
8359
|
-
};
|
|
8360
|
-
}
|
|
8361
|
-
const fieldErrors = convertAjvErrorsToFieldErrors(errors, schema);
|
|
8362
|
-
console.debug('AJV Validation Failed:', {
|
|
8363
|
-
errors,
|
|
8364
|
-
fieldErrors,
|
|
8365
|
-
cleanedValues,
|
|
8366
|
-
valuesToValidate,
|
|
8367
|
-
});
|
|
8368
|
-
return {
|
|
8369
|
-
values: {},
|
|
8370
|
-
errors: fieldErrors,
|
|
8371
|
-
};
|
|
8372
|
-
}
|
|
8373
|
-
catch (error) {
|
|
8374
|
-
return {
|
|
8375
|
-
values: {},
|
|
8376
|
-
errors: {
|
|
8377
|
-
root: {
|
|
8378
|
-
type: 'validation',
|
|
8379
|
-
message: error instanceof Error ? error.message : 'Validation failed',
|
|
8380
|
-
},
|
|
8381
|
-
},
|
|
8382
|
-
};
|
|
8383
|
-
}
|
|
8384
|
-
};
|
|
8385
|
-
};
|
|
8386
|
-
|
|
8387
|
-
const useForm = ({ preLoadedValues, schema }) => {
|
|
8173
|
+
function useForm({ preLoadedValues, schema, }) {
|
|
8388
8174
|
const form = useForm$1({
|
|
8389
8175
|
values: preLoadedValues,
|
|
8390
8176
|
mode: 'onSubmit',
|
|
8391
|
-
resolver: schema
|
|
8177
|
+
resolver: schema
|
|
8178
|
+
? ajvResolver(schema, {
|
|
8179
|
+
strict: false,
|
|
8180
|
+
})
|
|
8181
|
+
: undefined,
|
|
8392
8182
|
reValidateMode: 'onChange',
|
|
8393
8183
|
});
|
|
8394
8184
|
const [idMap, setIdMap] = useState({});
|
|
@@ -8397,7 +8187,7 @@ const useForm = ({ preLoadedValues, schema }) => {
|
|
|
8397
8187
|
idMap,
|
|
8398
8188
|
setIdMap,
|
|
8399
8189
|
};
|
|
8400
|
-
}
|
|
8190
|
+
}
|
|
8401
8191
|
|
|
8402
8192
|
const getMultiDates = ({ selected, selectedDate, selectedDates, selectable, }) => {
|
|
8403
8193
|
if (!selectable) {
|
|
@@ -33,7 +33,7 @@ export interface FormRootProps<TData extends FieldValues> {
|
|
|
33
33
|
requestUrl?: string;
|
|
34
34
|
idMap: Record<string, object>;
|
|
35
35
|
setIdMap: Dispatch<SetStateAction<Record<string, object>>>;
|
|
36
|
-
form: UseFormReturn
|
|
36
|
+
form: UseFormReturn<TData, any, TData>;
|
|
37
37
|
children: ReactNode;
|
|
38
38
|
order?: string[];
|
|
39
39
|
ignore?: string[];
|
|
@@ -108,7 +108,7 @@ export interface CustomJSONSchema7 extends Omit<JSONSchema7, 'items' | 'addition
|
|
|
108
108
|
showLabel?: boolean;
|
|
109
109
|
formatOptions?: Intl.NumberFormatOptions;
|
|
110
110
|
numberStorageType?: 'string' | 'number';
|
|
111
|
-
|
|
111
|
+
errorMessage?: Record<Partial<ValidationErrorType> | string, string | Record<string, string>>;
|
|
112
112
|
filePicker?: FilePickerProps;
|
|
113
113
|
tagPicker?: {
|
|
114
114
|
queryFn?: (params: {
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { FieldValues } from 'react-hook-form';
|
|
3
3
|
import { CustomJSONSchema7 } from './components/types/CustomJSONSchema7';
|
|
4
|
-
export interface
|
|
5
|
-
|
|
6
|
-
i18n?: any;
|
|
7
|
-
ready?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface UseFormProps {
|
|
10
|
-
preLoadedValues?: FieldValues | undefined;
|
|
4
|
+
export interface UseFormProps<T> {
|
|
5
|
+
preLoadedValues?: T | undefined;
|
|
11
6
|
schema?: CustomJSONSchema7;
|
|
12
7
|
}
|
|
13
|
-
export declare
|
|
14
|
-
form: import("react-hook-form").UseFormReturn<
|
|
8
|
+
export declare function useForm<T extends FieldValues = any>({ preLoadedValues, schema, }: UseFormProps<T>): {
|
|
9
|
+
form: import("react-hook-form").UseFormReturn<T, any, T>;
|
|
15
10
|
idMap: Record<string, object>;
|
|
16
11
|
setIdMap: import("react").Dispatch<import("react").SetStateAction<Record<string, object>>>;
|
|
17
12
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsol-oss/react-datatable5",
|
|
3
|
-
"version": "13.0.1-beta.
|
|
3
|
+
"version": "13.0.1-beta.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -91,5 +91,8 @@
|
|
|
91
91
|
"*.{ts,js,json,md,tsx}": [
|
|
92
92
|
"prettier --config ./.prettierrc --write"
|
|
93
93
|
]
|
|
94
|
+
},
|
|
95
|
+
"dependencies": {
|
|
96
|
+
"@hookform/resolvers": "^5.2.2"
|
|
94
97
|
}
|
|
95
98
|
}
|