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

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.js CHANGED
@@ -6059,21 +6059,25 @@ const FormBody = () => {
6059
6059
  // Enhanced validation function using AJV with i18n support
6060
6060
  const validateFormData = (data) => {
6061
6061
  try {
6062
- const validationResult = validateData(data, schema, { locale: validationLocale });
6062
+ const validationResult = validateData(data, schema, {
6063
+ locale: validationLocale,
6064
+ });
6063
6065
  return validationResult;
6064
6066
  }
6065
6067
  catch (error) {
6066
- const errorMessage = validationLocale === 'zh-HK' || validationLocale === 'zh-TW'
6067
- ? `驗證錯誤: ${error instanceof Error ? error.message : '未知驗證錯誤'}`
6068
- : validationLocale === 'zh-CN' || validationLocale === 'zh'
6069
- ? `验证错误: ${error instanceof Error ? error.message : '未知验证错误'}`
6070
- : `Validation error: ${error instanceof Error ? error.message : 'Unknown validation error'}`;
6068
+ const errorMessage = validationLocale === "zh-HK" || validationLocale === "zh-TW"
6069
+ ? `驗證錯誤: ${error instanceof Error ? error.message : "未知驗證錯誤"}`
6070
+ : validationLocale === "zh-CN" || validationLocale === "zh"
6071
+ ? `验证错误: ${error instanceof Error ? error.message : "未知验证错误"}`
6072
+ : `Validation error: ${error instanceof Error ? error.message : "Unknown validation error"}`;
6071
6073
  return {
6072
6074
  isValid: false,
6073
- errors: [{
6074
- field: 'validation',
6075
- message: errorMessage
6076
- }]
6075
+ errors: [
6076
+ {
6077
+ field: "validation",
6078
+ message: errorMessage,
6079
+ },
6080
+ ],
6077
6081
  };
6078
6082
  }
6079
6083
  };
@@ -6106,13 +6110,13 @@ const FormBody = () => {
6106
6110
  if (!validationResult.isValid) {
6107
6111
  // Set validation errors
6108
6112
  const validationErrorMessage = {
6109
- type: 'validation',
6113
+ type: "validation",
6110
6114
  errors: validationResult.errors,
6111
- message: validationLocale === 'zh-HK' || validationLocale === 'zh-TW'
6112
- ? '表單驗證失敗'
6113
- : validationLocale === 'zh-CN' || validationLocale === 'zh'
6114
- ? '表单验证失败'
6115
- : 'Form validation failed'
6115
+ message: validationLocale === "zh-HK" || validationLocale === "zh-TW"
6116
+ ? "表單驗證失敗"
6117
+ : validationLocale === "zh-CN" || validationLocale === "zh"
6118
+ ? "表单验证失败"
6119
+ : "Form validation failed",
6116
6120
  };
6117
6121
  onSubmitError(validationErrorMessage);
6118
6122
  return;
@@ -6125,22 +6129,22 @@ const FormBody = () => {
6125
6129
  };
6126
6130
  // Custom error renderer for validation errors with i18n support
6127
6131
  const renderValidationErrors = (validationErrors) => {
6128
- const title = validationLocale === 'zh-HK' || validationLocale === 'zh-TW'
6129
- ? `表單驗證失敗 (${validationErrors.length} 個錯誤${validationErrors.length > 1 ? '' : ''})`
6130
- : validationLocale === 'zh-CN' || validationLocale === 'zh'
6131
- ? `表单验证失败 (${validationErrors.length} 个错误${validationErrors.length > 1 ? '' : ''})`
6132
- : `Form Validation Failed (${validationErrors.length} error${validationErrors.length > 1 ? 's' : ''})`;
6133
- const formLabel = validationLocale === 'zh-HK' || validationLocale === 'zh-TW'
6134
- ? '表單'
6135
- : validationLocale === 'zh-CN' || validationLocale === 'zh'
6136
- ? '表单'
6137
- : 'Form';
6138
- const currentValueLabel = validationLocale === 'zh-HK' || validationLocale === 'zh-TW'
6139
- ? '目前值:'
6140
- : validationLocale === 'zh-CN' || validationLocale === 'zh'
6141
- ? '当前值:'
6142
- : 'Current value:';
6143
- return (jsxRuntime.jsxs(react.Alert.Root, { status: "error", children: [jsxRuntime.jsx(react.Alert.Indicator, {}), jsxRuntime.jsx(react.Alert.Title, { children: jsxRuntime.jsx(AccordionRoot, { collapsible: true, defaultValue: [], children: jsxRuntime.jsxs(AccordionItem, { value: "validation-errors", children: [jsxRuntime.jsx(AccordionItemTrigger, { children: title }), jsxRuntime.jsx(AccordionItemContent, { children: jsxRuntime.jsx(react.Box, { mt: 2, children: validationErrors.map((err, index) => (jsxRuntime.jsxs(react.Box, { mb: 2, p: 2, bg: "red.50", borderLeft: "4px solid", borderColor: "red.500", children: [jsxRuntime.jsxs(react.Text, { fontWeight: "bold", color: "red.700", children: [err.field === 'root' ? formLabel : err.field, ":"] }), jsxRuntime.jsx(react.Text, { color: "red.600", children: err.message }), err.value !== undefined && (jsxRuntime.jsxs(react.Text, { fontSize: "sm", color: "red.500", mt: 1, children: [currentValueLabel, " ", JSON.stringify(err.value)] }))] }, index))) }) })] }) }) })] }));
6132
+ const title = validationLocale === "zh-HK" || validationLocale === "zh-TW"
6133
+ ? `表單驗證失敗 (${validationErrors.length} 個錯誤${validationErrors.length > 1 ? "" : ""})`
6134
+ : validationLocale === "zh-CN" || validationLocale === "zh"
6135
+ ? `表单验证失败 (${validationErrors.length} 个错误${validationErrors.length > 1 ? "" : ""})`
6136
+ : `Form Validation Failed (${validationErrors.length} error${validationErrors.length > 1 ? "s" : ""})`;
6137
+ const formLabel = validationLocale === "zh-HK" || validationLocale === "zh-TW"
6138
+ ? "表單"
6139
+ : validationLocale === "zh-CN" || validationLocale === "zh"
6140
+ ? "表单"
6141
+ : "Form";
6142
+ const currentValueLabel = validationLocale === "zh-HK" || validationLocale === "zh-TW"
6143
+ ? "目前值:"
6144
+ : validationLocale === "zh-CN" || validationLocale === "zh"
6145
+ ? "当前值:"
6146
+ : "Current value:";
6147
+ return (jsxRuntime.jsx(AccordionRoot, { collapsible: true, defaultValue: [], children: jsxRuntime.jsxs(AccordionItem, { value: "validation-errors", children: [jsxRuntime.jsx(AccordionItemTrigger, { children: title }), jsxRuntime.jsx(AccordionItemContent, { children: validationErrors.map((err, index) => (jsxRuntime.jsxs(react.Box, { mb: 2, p: 2, bg: "red.50", borderLeft: "4px solid", borderColor: "red.500", children: [jsxRuntime.jsxs(react.Text, { fontWeight: "bold", color: "red.700", children: [err.field === "root" ? formLabel : err.field, ":"] }), jsxRuntime.jsx(react.Text, { color: "red.600", children: err.message }), err.value !== undefined && (jsxRuntime.jsxs(react.Text, { fontSize: "sm", color: "red.500", mt: 1, whiteSpace: "pre-wrap", wordBreak: "break-all", children: [currentValueLabel, " ", JSON.stringify(err.value, null, 2)] }))] }, index))) })] }) }));
6144
6148
  };
6145
6149
  const renderColumns = ({ order, keys, ignore, include, }) => {
6146
6150
  const included = include.length > 0 ? include : keys;
@@ -6177,7 +6181,8 @@ const FormBody = () => {
6177
6181
  setIsConfirming(false);
6178
6182
  }, variant: "subtle", children: translate.t("cancel") }), jsxRuntime.jsx(react.Button, { onClick: () => {
6179
6183
  onFormSubmit(validatedData);
6180
- }, children: translate.t("confirm") })] }), isSubmiting && (jsxRuntime.jsx(react.Box, { pos: "absolute", inset: "0", bg: "bg/80", children: jsxRuntime.jsx(react.Center, { h: "full", children: jsxRuntime.jsx(react.Spinner, { color: "teal.500" }) }) })), isError && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: customErrorRenderer ? (customErrorRenderer(error)) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: error?.type === 'validation' && error?.errors ? (renderValidationErrors(error.errors)) : (jsxRuntime.jsx(react.Alert.Root, { status: "error", children: jsxRuntime.jsx(react.Alert.Title, { children: jsxRuntime.jsx(AccordionRoot, { collapsible: true, defaultValue: [], children: jsxRuntime.jsxs(AccordionItem, { value: "b", children: [jsxRuntime.jsxs(AccordionItemTrigger, { children: [jsxRuntime.jsx(react.Alert.Indicator, {}), `${error}`] }), jsxRuntime.jsx(AccordionItemContent, { children: `${JSON.stringify(error)}` })] }) }) }) })) })) }))] }));
6184
+ }, children: translate.t("confirm") })] }), isSubmiting && (jsxRuntime.jsx(react.Box, { pos: "absolute", inset: "0", bg: "bg/80", children: jsxRuntime.jsx(react.Center, { h: "full", children: jsxRuntime.jsx(react.Spinner, { color: "teal.500" }) }) })), isError && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: customErrorRenderer ? (customErrorRenderer(error)) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: error?.type === "validation" &&
6185
+ error?.errors ? (renderValidationErrors(error.errors)) : (jsxRuntime.jsx(react.Alert.Root, { status: "error", children: jsxRuntime.jsx(react.Alert.Title, { children: jsxRuntime.jsx(AccordionRoot, { collapsible: true, defaultValue: [], children: jsxRuntime.jsxs(AccordionItem, { value: "b", children: [jsxRuntime.jsxs(AccordionItemTrigger, { children: [jsxRuntime.jsx(react.Alert.Indicator, {}), `${error}`] }), jsxRuntime.jsx(AccordionItemContent, { children: `${JSON.stringify(error)}` })] }) }) }) })) })) }))] }));
6181
6186
  }
6182
6187
  return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "2", children: [jsxRuntime.jsx(react.Grid, { gap: "4", gridTemplateColumns: "repeat(12, 1fr)", autoFlow: "row", children: ordered.map((column) => {
6183
6188
  return (jsxRuntime.jsx(ColumnRenderer
@@ -6187,7 +6192,8 @@ const FormBody = () => {
6187
6192
  properties: properties, prefix: ``, column }, `form-input-${column}`));
6188
6193
  }) }), jsxRuntime.jsxs(react.Flex, { justifyContent: "end", gap: "2", children: [jsxRuntime.jsx(react.Button, { onClick: () => {
6189
6194
  methods.reset();
6190
- }, variant: "subtle", children: translate.t("reset") }), jsxRuntime.jsx(SubmitButton, {})] }), isError && error?.type === 'validation' && (jsxRuntime.jsx(react.Box, { mt: 4, children: error?.errors && renderValidationErrors(error.errors) }))] }));
6195
+ }, variant: "subtle", children: translate.t("reset") }), jsxRuntime.jsx(SubmitButton, {})] }), isError && error?.type === "validation" && (jsxRuntime.jsx(react.Box, { mt: 4, children: error?.errors &&
6196
+ renderValidationErrors(error.errors) }))] }));
6191
6197
  };
6192
6198
 
6193
6199
  const FormTitle = () => {
package/dist/index.mjs CHANGED
@@ -6039,21 +6039,25 @@ const FormBody = () => {
6039
6039
  // Enhanced validation function using AJV with i18n support
6040
6040
  const validateFormData = (data) => {
6041
6041
  try {
6042
- const validationResult = validateData(data, schema, { locale: validationLocale });
6042
+ const validationResult = validateData(data, schema, {
6043
+ locale: validationLocale,
6044
+ });
6043
6045
  return validationResult;
6044
6046
  }
6045
6047
  catch (error) {
6046
- const errorMessage = validationLocale === 'zh-HK' || validationLocale === 'zh-TW'
6047
- ? `驗證錯誤: ${error instanceof Error ? error.message : '未知驗證錯誤'}`
6048
- : validationLocale === 'zh-CN' || validationLocale === 'zh'
6049
- ? `验证错误: ${error instanceof Error ? error.message : '未知验证错误'}`
6050
- : `Validation error: ${error instanceof Error ? error.message : 'Unknown validation error'}`;
6048
+ const errorMessage = validationLocale === "zh-HK" || validationLocale === "zh-TW"
6049
+ ? `驗證錯誤: ${error instanceof Error ? error.message : "未知驗證錯誤"}`
6050
+ : validationLocale === "zh-CN" || validationLocale === "zh"
6051
+ ? `验证错误: ${error instanceof Error ? error.message : "未知验证错误"}`
6052
+ : `Validation error: ${error instanceof Error ? error.message : "Unknown validation error"}`;
6051
6053
  return {
6052
6054
  isValid: false,
6053
- errors: [{
6054
- field: 'validation',
6055
- message: errorMessage
6056
- }]
6055
+ errors: [
6056
+ {
6057
+ field: "validation",
6058
+ message: errorMessage,
6059
+ },
6060
+ ],
6057
6061
  };
6058
6062
  }
6059
6063
  };
@@ -6086,13 +6090,13 @@ const FormBody = () => {
6086
6090
  if (!validationResult.isValid) {
6087
6091
  // Set validation errors
6088
6092
  const validationErrorMessage = {
6089
- type: 'validation',
6093
+ type: "validation",
6090
6094
  errors: validationResult.errors,
6091
- message: validationLocale === 'zh-HK' || validationLocale === 'zh-TW'
6092
- ? '表單驗證失敗'
6093
- : validationLocale === 'zh-CN' || validationLocale === 'zh'
6094
- ? '表单验证失败'
6095
- : 'Form validation failed'
6095
+ message: validationLocale === "zh-HK" || validationLocale === "zh-TW"
6096
+ ? "表單驗證失敗"
6097
+ : validationLocale === "zh-CN" || validationLocale === "zh"
6098
+ ? "表单验证失败"
6099
+ : "Form validation failed",
6096
6100
  };
6097
6101
  onSubmitError(validationErrorMessage);
6098
6102
  return;
@@ -6105,22 +6109,22 @@ const FormBody = () => {
6105
6109
  };
6106
6110
  // Custom error renderer for validation errors with i18n support
6107
6111
  const renderValidationErrors = (validationErrors) => {
6108
- const title = validationLocale === 'zh-HK' || validationLocale === 'zh-TW'
6109
- ? `表單驗證失敗 (${validationErrors.length} 個錯誤${validationErrors.length > 1 ? '' : ''})`
6110
- : validationLocale === 'zh-CN' || validationLocale === 'zh'
6111
- ? `表单验证失败 (${validationErrors.length} 个错误${validationErrors.length > 1 ? '' : ''})`
6112
- : `Form Validation Failed (${validationErrors.length} error${validationErrors.length > 1 ? 's' : ''})`;
6113
- const formLabel = validationLocale === 'zh-HK' || validationLocale === 'zh-TW'
6114
- ? '表單'
6115
- : validationLocale === 'zh-CN' || validationLocale === 'zh'
6116
- ? '表单'
6117
- : 'Form';
6118
- const currentValueLabel = validationLocale === 'zh-HK' || validationLocale === 'zh-TW'
6119
- ? '目前值:'
6120
- : validationLocale === 'zh-CN' || validationLocale === 'zh'
6121
- ? '当前值:'
6122
- : 'Current value:';
6123
- return (jsxs(Alert.Root, { status: "error", children: [jsx(Alert.Indicator, {}), jsx(Alert.Title, { children: jsx(AccordionRoot, { collapsible: true, defaultValue: [], children: jsxs(AccordionItem, { value: "validation-errors", children: [jsx(AccordionItemTrigger, { children: title }), jsx(AccordionItemContent, { children: jsx(Box, { mt: 2, children: validationErrors.map((err, index) => (jsxs(Box, { mb: 2, p: 2, bg: "red.50", borderLeft: "4px solid", borderColor: "red.500", children: [jsxs(Text, { fontWeight: "bold", color: "red.700", children: [err.field === 'root' ? formLabel : err.field, ":"] }), jsx(Text, { color: "red.600", children: err.message }), err.value !== undefined && (jsxs(Text, { fontSize: "sm", color: "red.500", mt: 1, children: [currentValueLabel, " ", JSON.stringify(err.value)] }))] }, index))) }) })] }) }) })] }));
6112
+ const title = validationLocale === "zh-HK" || validationLocale === "zh-TW"
6113
+ ? `表單驗證失敗 (${validationErrors.length} 個錯誤${validationErrors.length > 1 ? "" : ""})`
6114
+ : validationLocale === "zh-CN" || validationLocale === "zh"
6115
+ ? `表单验证失败 (${validationErrors.length} 个错误${validationErrors.length > 1 ? "" : ""})`
6116
+ : `Form Validation Failed (${validationErrors.length} error${validationErrors.length > 1 ? "s" : ""})`;
6117
+ const formLabel = validationLocale === "zh-HK" || validationLocale === "zh-TW"
6118
+ ? "表單"
6119
+ : validationLocale === "zh-CN" || validationLocale === "zh"
6120
+ ? "表单"
6121
+ : "Form";
6122
+ const currentValueLabel = validationLocale === "zh-HK" || validationLocale === "zh-TW"
6123
+ ? "目前值:"
6124
+ : validationLocale === "zh-CN" || validationLocale === "zh"
6125
+ ? "当前值:"
6126
+ : "Current value:";
6127
+ return (jsx(AccordionRoot, { collapsible: true, defaultValue: [], children: jsxs(AccordionItem, { value: "validation-errors", children: [jsx(AccordionItemTrigger, { children: title }), jsx(AccordionItemContent, { children: validationErrors.map((err, index) => (jsxs(Box, { mb: 2, p: 2, bg: "red.50", borderLeft: "4px solid", borderColor: "red.500", children: [jsxs(Text, { fontWeight: "bold", color: "red.700", children: [err.field === "root" ? formLabel : err.field, ":"] }), jsx(Text, { color: "red.600", children: err.message }), err.value !== undefined && (jsxs(Text, { fontSize: "sm", color: "red.500", mt: 1, whiteSpace: "pre-wrap", wordBreak: "break-all", children: [currentValueLabel, " ", JSON.stringify(err.value, null, 2)] }))] }, index))) })] }) }));
6124
6128
  };
6125
6129
  const renderColumns = ({ order, keys, ignore, include, }) => {
6126
6130
  const included = include.length > 0 ? include : keys;
@@ -6157,7 +6161,8 @@ const FormBody = () => {
6157
6161
  setIsConfirming(false);
6158
6162
  }, variant: "subtle", children: translate.t("cancel") }), jsx(Button$1, { onClick: () => {
6159
6163
  onFormSubmit(validatedData);
6160
- }, children: translate.t("confirm") })] }), isSubmiting && (jsx(Box, { pos: "absolute", inset: "0", bg: "bg/80", children: jsx(Center, { h: "full", children: jsx(Spinner, { color: "teal.500" }) }) })), isError && (jsx(Fragment, { children: customErrorRenderer ? (customErrorRenderer(error)) : (jsx(Fragment, { children: error?.type === 'validation' && error?.errors ? (renderValidationErrors(error.errors)) : (jsx(Alert.Root, { status: "error", children: jsx(Alert.Title, { children: jsx(AccordionRoot, { collapsible: true, defaultValue: [], children: jsxs(AccordionItem, { value: "b", children: [jsxs(AccordionItemTrigger, { children: [jsx(Alert.Indicator, {}), `${error}`] }), jsx(AccordionItemContent, { children: `${JSON.stringify(error)}` })] }) }) }) })) })) }))] }));
6164
+ }, children: translate.t("confirm") })] }), isSubmiting && (jsx(Box, { pos: "absolute", inset: "0", bg: "bg/80", children: jsx(Center, { h: "full", children: jsx(Spinner, { color: "teal.500" }) }) })), isError && (jsx(Fragment, { children: customErrorRenderer ? (customErrorRenderer(error)) : (jsx(Fragment, { children: error?.type === "validation" &&
6165
+ error?.errors ? (renderValidationErrors(error.errors)) : (jsx(Alert.Root, { status: "error", children: jsx(Alert.Title, { children: jsx(AccordionRoot, { collapsible: true, defaultValue: [], children: jsxs(AccordionItem, { value: "b", children: [jsxs(AccordionItemTrigger, { children: [jsx(Alert.Indicator, {}), `${error}`] }), jsx(AccordionItemContent, { children: `${JSON.stringify(error)}` })] }) }) }) })) })) }))] }));
6161
6166
  }
6162
6167
  return (jsxs(Flex, { flexFlow: "column", gap: "2", children: [jsx(Grid, { gap: "4", gridTemplateColumns: "repeat(12, 1fr)", autoFlow: "row", children: ordered.map((column) => {
6163
6168
  return (jsx(ColumnRenderer
@@ -6167,7 +6172,8 @@ const FormBody = () => {
6167
6172
  properties: properties, prefix: ``, column }, `form-input-${column}`));
6168
6173
  }) }), jsxs(Flex, { justifyContent: "end", gap: "2", children: [jsx(Button$1, { onClick: () => {
6169
6174
  methods.reset();
6170
- }, variant: "subtle", children: translate.t("reset") }), jsx(SubmitButton, {})] }), isError && error?.type === 'validation' && (jsx(Box, { mt: 4, children: error?.errors && renderValidationErrors(error.errors) }))] }));
6175
+ }, variant: "subtle", children: translate.t("reset") }), jsx(SubmitButton, {})] }), isError && error?.type === "validation" && (jsx(Box, { mt: 4, children: error?.errors &&
6176
+ renderValidationErrors(error.errors) }))] }));
6171
6177
  };
6172
6178
 
6173
6179
  const FormTitle = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsol-oss/react-datatable5",
3
- "version": "12.0.0-beta.58",
3
+ "version": "12.0.0-beta.59",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",