@bsol-oss/react-datatable5 12.0.0-beta.61 → 12.0.0-beta.63
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 +114 -8
- package/dist/index.mjs +116 -10
- package/dist/types/components/TextArea/TextArea.d.ts +22 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4076,14 +4076,14 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, showTotalAndLi
|
|
|
4076
4076
|
if (!!item === false) {
|
|
4077
4077
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
4078
4078
|
}
|
|
4079
|
-
return (jsxRuntime.jsx(Tag, { closable: true, onClick: () => {
|
|
4079
|
+
return (jsxRuntime.jsx(Tag, { size: "lg", closable: true, onClick: () => {
|
|
4080
4080
|
setValue(column, watchEnums.filter((id) => id != item));
|
|
4081
4081
|
}, children: !!renderDisplay === true
|
|
4082
4082
|
? renderDisplay(item)
|
|
4083
|
-
: translate.t(removeIndex(`${colLabel}.${item}`)) }));
|
|
4084
|
-
}), jsxRuntime.jsx(Tag, { cursor: "pointer", onClick: () => {
|
|
4083
|
+
: translate.t(removeIndex(`${colLabel}.${item}`)) }, item));
|
|
4084
|
+
}), jsxRuntime.jsx(Tag, { size: "lg", cursor: "pointer", onClick: () => {
|
|
4085
4085
|
setOpenSearchResult(true);
|
|
4086
|
-
}, children: translate.t(removeIndex(`${colLabel}.add_more`)) })] })), !isMultiple && (jsxRuntime.jsx(Button, { variant: "outline", onClick: () => {
|
|
4086
|
+
}, children: translate.t(removeIndex(`${colLabel}.add_more`)) }, `${colLabel}-add-more-tag`)] })), !isMultiple && (jsxRuntime.jsx(Button, { variant: "outline", onClick: () => {
|
|
4087
4087
|
setOpenSearchResult(true);
|
|
4088
4088
|
}, justifyContent: "start", children: !!watchEnum === false
|
|
4089
4089
|
? ""
|
|
@@ -4904,13 +4904,101 @@ const TagPicker = ({ column, schema, prefix }) => {
|
|
|
4904
4904
|
}), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: (errors[`${column}`]?.message ?? "No error message") }))] }));
|
|
4905
4905
|
};
|
|
4906
4906
|
|
|
4907
|
+
const Textarea = React.forwardRef(({ value, defaultValue, placeholder, onChange, onFocus, onBlur, disabled = false, readOnly = false, className, rows = 4, maxLength, autoFocus = false, invalid = false, required = false, label, helperText, errorText, ...props }, ref) => {
|
|
4908
|
+
const contentEditableRef = React.useRef(null);
|
|
4909
|
+
const isControlled = value !== undefined;
|
|
4910
|
+
// Handle input changes
|
|
4911
|
+
const handleInput = (e) => {
|
|
4912
|
+
const text = e.currentTarget.textContent || "";
|
|
4913
|
+
// Check maxLength if specified
|
|
4914
|
+
if (maxLength && text.length > maxLength) {
|
|
4915
|
+
e.currentTarget.textContent = text.slice(0, maxLength);
|
|
4916
|
+
// Move cursor to end
|
|
4917
|
+
const selection = window.getSelection();
|
|
4918
|
+
if (selection) {
|
|
4919
|
+
selection.selectAllChildren(e.currentTarget);
|
|
4920
|
+
selection.collapseToEnd();
|
|
4921
|
+
}
|
|
4922
|
+
return;
|
|
4923
|
+
}
|
|
4924
|
+
onChange?.(text);
|
|
4925
|
+
};
|
|
4926
|
+
// Handle paste events to strip formatting and respect maxLength
|
|
4927
|
+
const handlePaste = (e) => {
|
|
4928
|
+
e.preventDefault();
|
|
4929
|
+
const text = e.clipboardData.getData('text/plain');
|
|
4930
|
+
const currentText = e.currentTarget.textContent || "";
|
|
4931
|
+
let pasteText = text;
|
|
4932
|
+
if (maxLength) {
|
|
4933
|
+
const remainingLength = maxLength - currentText.length;
|
|
4934
|
+
pasteText = text.slice(0, remainingLength);
|
|
4935
|
+
}
|
|
4936
|
+
document.execCommand('insertText', false, pasteText);
|
|
4937
|
+
};
|
|
4938
|
+
// Set initial content
|
|
4939
|
+
React.useEffect(() => {
|
|
4940
|
+
if (contentEditableRef.current && !isControlled) {
|
|
4941
|
+
const initialValue = defaultValue || "";
|
|
4942
|
+
if (contentEditableRef.current.textContent !== initialValue) {
|
|
4943
|
+
contentEditableRef.current.textContent = initialValue;
|
|
4944
|
+
}
|
|
4945
|
+
}
|
|
4946
|
+
}, [defaultValue, isControlled]);
|
|
4947
|
+
// Update content when value changes (controlled mode)
|
|
4948
|
+
React.useEffect(() => {
|
|
4949
|
+
if (contentEditableRef.current && isControlled && value !== undefined) {
|
|
4950
|
+
if (contentEditableRef.current.textContent !== value) {
|
|
4951
|
+
contentEditableRef.current.textContent = value;
|
|
4952
|
+
}
|
|
4953
|
+
}
|
|
4954
|
+
}, [value, isControlled]);
|
|
4955
|
+
// Auto focus
|
|
4956
|
+
React.useEffect(() => {
|
|
4957
|
+
if (autoFocus && contentEditableRef.current) {
|
|
4958
|
+
contentEditableRef.current.focus();
|
|
4959
|
+
}
|
|
4960
|
+
}, [autoFocus]);
|
|
4961
|
+
// Forward ref
|
|
4962
|
+
React.useEffect(() => {
|
|
4963
|
+
if (typeof ref === 'function') {
|
|
4964
|
+
ref(contentEditableRef.current);
|
|
4965
|
+
}
|
|
4966
|
+
else if (ref) {
|
|
4967
|
+
ref.current = contentEditableRef.current;
|
|
4968
|
+
}
|
|
4969
|
+
}, [ref]);
|
|
4970
|
+
const textareaElement = (jsxRuntime.jsx(react.Box, { ref: contentEditableRef, contentEditable: !disabled && !readOnly, onInput: handleInput, onPaste: handlePaste, onFocus: onFocus, onBlur: onBlur, className: className, minHeight: `${rows * 1.5}em`, padding: "2", border: "1px solid", borderColor: invalid ? "red.500" : "gray.200", borderRadius: "md", outline: "none", _focus: {
|
|
4971
|
+
borderColor: invalid ? "red.500" : "blue.500",
|
|
4972
|
+
boxShadow: `0 0 0 1px ${invalid ? "red.500" : "blue.500"}`,
|
|
4973
|
+
}, _disabled: {
|
|
4974
|
+
opacity: 0.6,
|
|
4975
|
+
cursor: "not-allowed",
|
|
4976
|
+
bg: "gray.50",
|
|
4977
|
+
}, _empty: {
|
|
4978
|
+
_before: {
|
|
4979
|
+
content: placeholder ? `"${placeholder}"` : undefined,
|
|
4980
|
+
color: "gray.400",
|
|
4981
|
+
pointerEvents: "none",
|
|
4982
|
+
}
|
|
4983
|
+
}, whiteSpace: "pre-wrap", overflowWrap: "break-word", overflow: "auto", maxHeight: `${rows * 4}em`, suppressContentEditableWarning: true, ...props }));
|
|
4984
|
+
// If we have additional field props, wrap in Field component
|
|
4985
|
+
if (label || helperText || errorText || required) {
|
|
4986
|
+
return (jsxRuntime.jsxs(react.Field.Root, { invalid: invalid, required: required, children: [label && (jsxRuntime.jsxs(react.Field.Label, { children: [label, required && jsxRuntime.jsx(react.Field.RequiredIndicator, {})] })), textareaElement, helperText && jsxRuntime.jsx(react.Field.HelperText, { children: helperText }), errorText && jsxRuntime.jsx(react.Field.ErrorText, { children: errorText })] }));
|
|
4987
|
+
}
|
|
4988
|
+
return textareaElement;
|
|
4989
|
+
});
|
|
4990
|
+
Textarea.displayName = "Textarea";
|
|
4991
|
+
|
|
4907
4992
|
const TextAreaInput = ({ column, schema, prefix, }) => {
|
|
4908
4993
|
const { register, formState: { errors }, } = reactHookForm.useFormContext();
|
|
4909
4994
|
const { translate } = useSchemaContext();
|
|
4910
4995
|
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
4911
4996
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4912
4997
|
const colLabel = `${prefix}${column}`;
|
|
4913
|
-
|
|
4998
|
+
const form = reactHookForm.useFormContext();
|
|
4999
|
+
const { setValue, watch } = form;
|
|
5000
|
+
const watchValue = watch(colLabel);
|
|
5001
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, gridColumn: gridColumn ?? "span 4", gridRow: gridRow ?? "span 1", display: "grid", children: [jsxRuntime.jsx(Textarea, { value: watchValue, onChange: (value) => setValue(colLabel, value) }), errors[colLabel] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }) }));
|
|
4914
5002
|
};
|
|
4915
5003
|
|
|
4916
5004
|
function TimePicker$1({ hour, setHour, minute, setMinute, meridiem, setMeridiem, meridiemLabel = {
|
|
@@ -5402,6 +5490,15 @@ const SchemaRenderer = ({ schema, prefix, column, }) => {
|
|
|
5402
5490
|
if (variant === "file-picker") {
|
|
5403
5491
|
return jsxRuntime.jsx(FilePicker, { schema: colSchema, prefix, column });
|
|
5404
5492
|
}
|
|
5493
|
+
if (variant === "enum-picker") {
|
|
5494
|
+
const { items } = colSchema;
|
|
5495
|
+
const { enum: enumItems } = items;
|
|
5496
|
+
const enumSchema = {
|
|
5497
|
+
type: "string",
|
|
5498
|
+
enum: enumItems,
|
|
5499
|
+
};
|
|
5500
|
+
return (jsxRuntime.jsx(EnumPicker, { isMultiple: true, schema: enumSchema, prefix, column }));
|
|
5501
|
+
}
|
|
5405
5502
|
if (items) {
|
|
5406
5503
|
return jsxRuntime.jsx(ArrayRenderer, { schema: colSchema, prefix, column });
|
|
5407
5504
|
}
|
|
@@ -5493,9 +5590,9 @@ const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
5493
5590
|
if (item === undefined) {
|
|
5494
5591
|
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: "undefined" });
|
|
5495
5592
|
}
|
|
5496
|
-
return (jsxRuntime.jsx(Tag, { children: !!renderDisplay === true
|
|
5593
|
+
return (jsxRuntime.jsx(Tag, { size: "lg", children: !!renderDisplay === true
|
|
5497
5594
|
? renderDisplay(item)
|
|
5498
|
-
: customTranslate(item) }));
|
|
5595
|
+
: customTranslate(item) }, item));
|
|
5499
5596
|
}) })), !isMultiple && jsxRuntime.jsx(react.Text, { children: customTranslate(watchEnum) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: customTranslate(`field_required`) }))] }));
|
|
5500
5597
|
};
|
|
5501
5598
|
|
|
@@ -5809,6 +5906,15 @@ const SchemaViewer = ({ schema, prefix, column, }) => {
|
|
|
5809
5906
|
if (variant === "file-picker") {
|
|
5810
5907
|
return jsxRuntime.jsx(FileViewer, { schema: colSchema, prefix, column });
|
|
5811
5908
|
}
|
|
5909
|
+
if (variant === "enum-picker") {
|
|
5910
|
+
const { items } = schema;
|
|
5911
|
+
const { enum: enumItems } = items;
|
|
5912
|
+
const enumSchema = {
|
|
5913
|
+
type: "string",
|
|
5914
|
+
enum: enumItems,
|
|
5915
|
+
};
|
|
5916
|
+
return (jsxRuntime.jsx(EnumViewer, { isMultiple: true, schema: enumSchema, prefix, column }));
|
|
5917
|
+
}
|
|
5812
5918
|
if (items) {
|
|
5813
5919
|
return jsxRuntime.jsx(ArrayViewer, { schema: colSchema, prefix, column });
|
|
5814
5920
|
}
|
|
@@ -5956,7 +6062,7 @@ const FormBody = () => {
|
|
|
5956
6062
|
return (jsxRuntime.jsx(AccordionRoot, { backgroundColor: {
|
|
5957
6063
|
base: "red.50",
|
|
5958
6064
|
_dark: "red.950",
|
|
5959
|
-
}, p: "4", colorPalette: "red", collapsible: true, defaultValue: [], children: jsxRuntime.jsxs(AccordionItem, { value: "validation-errors", children: [jsxRuntime.jsx(AccordionItemTrigger, { children: translate.t("validation_error") }), jsxRuntime.jsx(AccordionItemContent, { display: "flex", flexFlow: "column", gap: "2", children: validationErrors.map((err, index) => (jsxRuntime.jsxs(react.AlertRoot, { status: "error", display: "flex", alignItems: "center", children: [jsxRuntime.jsx(react.AlertIndicator, {}), jsxRuntime.
|
|
6065
|
+
}, p: "4", colorPalette: "red", collapsible: true, defaultValue: [], children: jsxRuntime.jsxs(AccordionItem, { value: "validation-errors", children: [jsxRuntime.jsx(AccordionItemTrigger, { children: translate.t("validation_error") }), jsxRuntime.jsx(AccordionItemContent, { display: "flex", flexFlow: "column", gap: "2", children: validationErrors.map((err, index) => (jsxRuntime.jsxs(react.AlertRoot, { status: "error", display: "flex", alignItems: "center", children: [jsxRuntime.jsx(react.AlertIndicator, {}), jsxRuntime.jsx(react.AlertContent, { children: jsxRuntime.jsx(react.AlertDescription, { children: err.message }) })] }))) })] }) }));
|
|
5960
6066
|
};
|
|
5961
6067
|
const renderColumns = ({ order, keys, ignore, include, }) => {
|
|
5962
6068
|
const included = include.length > 0 ? include : keys;
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { Button as Button$1, AbsoluteCenter, Spinner, Span, IconButton, Portal, Dialog, Flex, Text, useDisclosure, DialogBackdrop, RadioGroup as RadioGroup$1, Grid, Box, Slider as Slider$1, HStack, For, Tag as Tag$1, Input, Menu, createRecipeContext, createContext as createContext$1, Pagination as Pagination$1, usePaginationContext, CheckboxCard as CheckboxCard$1, Image, EmptyState as EmptyState$2, VStack, Alert, Card, Group, InputElement, Tooltip as Tooltip$1, Icon, List, Table as Table$1, Checkbox as Checkbox$1, MenuRoot as MenuRoot$1, MenuTrigger as MenuTrigger$1, Accordion, Field as Field$1, Popover, NumberInput, Show, RadioCard, CheckboxGroup,
|
|
2
|
+
import { Button as Button$1, AbsoluteCenter, Spinner, Span, IconButton, Portal, Dialog, Flex, Text, useDisclosure, DialogBackdrop, RadioGroup as RadioGroup$1, Grid, Box, Slider as Slider$1, HStack, For, Tag as Tag$1, Input, Menu, createRecipeContext, createContext as createContext$1, Pagination as Pagination$1, usePaginationContext, CheckboxCard as CheckboxCard$1, Image, EmptyState as EmptyState$2, VStack, Alert, Card, Group, InputElement, Tooltip as Tooltip$1, Icon, List, Table as Table$1, Checkbox as Checkbox$1, MenuRoot as MenuRoot$1, MenuTrigger as MenuTrigger$1, Accordion, Field as Field$1, Popover, NumberInput, Show, RadioCard, CheckboxGroup, Center, AlertRoot, AlertIndicator, AlertContent, AlertDescription, Heading } from '@chakra-ui/react';
|
|
3
3
|
import { AiOutlineColumnWidth } from 'react-icons/ai';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import React__default, { createContext, useContext, useState, useEffect, useRef } from 'react';
|
|
5
|
+
import React__default, { createContext, useContext, useState, useEffect, useRef, forwardRef } from 'react';
|
|
6
6
|
import { LuX, LuCheck, LuChevronRight, LuChevronDown } from 'react-icons/lu';
|
|
7
7
|
import { MdOutlineSort, MdFilterAlt, MdSearch, MdOutlineViewColumn, MdFilterListAlt, MdPushPin, MdCancel, MdClear, MdOutlineChecklist, MdDateRange } from 'react-icons/md';
|
|
8
8
|
import { FaUpDown, FaGripLinesVertical, FaTrash } from 'react-icons/fa6';
|
|
@@ -4056,14 +4056,14 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, showTotalAndLi
|
|
|
4056
4056
|
if (!!item === false) {
|
|
4057
4057
|
return jsx(Fragment, {});
|
|
4058
4058
|
}
|
|
4059
|
-
return (jsx(Tag, { closable: true, onClick: () => {
|
|
4059
|
+
return (jsx(Tag, { size: "lg", closable: true, onClick: () => {
|
|
4060
4060
|
setValue(column, watchEnums.filter((id) => id != item));
|
|
4061
4061
|
}, children: !!renderDisplay === true
|
|
4062
4062
|
? renderDisplay(item)
|
|
4063
|
-
: translate.t(removeIndex(`${colLabel}.${item}`)) }));
|
|
4064
|
-
}), jsx(Tag, { cursor: "pointer", onClick: () => {
|
|
4063
|
+
: translate.t(removeIndex(`${colLabel}.${item}`)) }, item));
|
|
4064
|
+
}), jsx(Tag, { size: "lg", cursor: "pointer", onClick: () => {
|
|
4065
4065
|
setOpenSearchResult(true);
|
|
4066
|
-
}, children: translate.t(removeIndex(`${colLabel}.add_more`)) })] })), !isMultiple && (jsx(Button, { variant: "outline", onClick: () => {
|
|
4066
|
+
}, children: translate.t(removeIndex(`${colLabel}.add_more`)) }, `${colLabel}-add-more-tag`)] })), !isMultiple && (jsx(Button, { variant: "outline", onClick: () => {
|
|
4067
4067
|
setOpenSearchResult(true);
|
|
4068
4068
|
}, justifyContent: "start", children: !!watchEnum === false
|
|
4069
4069
|
? ""
|
|
@@ -4884,13 +4884,101 @@ const TagPicker = ({ column, schema, prefix }) => {
|
|
|
4884
4884
|
}), errors[`${column}`] && (jsx(Text, { color: "red.400", children: (errors[`${column}`]?.message ?? "No error message") }))] }));
|
|
4885
4885
|
};
|
|
4886
4886
|
|
|
4887
|
+
const Textarea = forwardRef(({ value, defaultValue, placeholder, onChange, onFocus, onBlur, disabled = false, readOnly = false, className, rows = 4, maxLength, autoFocus = false, invalid = false, required = false, label, helperText, errorText, ...props }, ref) => {
|
|
4888
|
+
const contentEditableRef = useRef(null);
|
|
4889
|
+
const isControlled = value !== undefined;
|
|
4890
|
+
// Handle input changes
|
|
4891
|
+
const handleInput = (e) => {
|
|
4892
|
+
const text = e.currentTarget.textContent || "";
|
|
4893
|
+
// Check maxLength if specified
|
|
4894
|
+
if (maxLength && text.length > maxLength) {
|
|
4895
|
+
e.currentTarget.textContent = text.slice(0, maxLength);
|
|
4896
|
+
// Move cursor to end
|
|
4897
|
+
const selection = window.getSelection();
|
|
4898
|
+
if (selection) {
|
|
4899
|
+
selection.selectAllChildren(e.currentTarget);
|
|
4900
|
+
selection.collapseToEnd();
|
|
4901
|
+
}
|
|
4902
|
+
return;
|
|
4903
|
+
}
|
|
4904
|
+
onChange?.(text);
|
|
4905
|
+
};
|
|
4906
|
+
// Handle paste events to strip formatting and respect maxLength
|
|
4907
|
+
const handlePaste = (e) => {
|
|
4908
|
+
e.preventDefault();
|
|
4909
|
+
const text = e.clipboardData.getData('text/plain');
|
|
4910
|
+
const currentText = e.currentTarget.textContent || "";
|
|
4911
|
+
let pasteText = text;
|
|
4912
|
+
if (maxLength) {
|
|
4913
|
+
const remainingLength = maxLength - currentText.length;
|
|
4914
|
+
pasteText = text.slice(0, remainingLength);
|
|
4915
|
+
}
|
|
4916
|
+
document.execCommand('insertText', false, pasteText);
|
|
4917
|
+
};
|
|
4918
|
+
// Set initial content
|
|
4919
|
+
useEffect(() => {
|
|
4920
|
+
if (contentEditableRef.current && !isControlled) {
|
|
4921
|
+
const initialValue = defaultValue || "";
|
|
4922
|
+
if (contentEditableRef.current.textContent !== initialValue) {
|
|
4923
|
+
contentEditableRef.current.textContent = initialValue;
|
|
4924
|
+
}
|
|
4925
|
+
}
|
|
4926
|
+
}, [defaultValue, isControlled]);
|
|
4927
|
+
// Update content when value changes (controlled mode)
|
|
4928
|
+
useEffect(() => {
|
|
4929
|
+
if (contentEditableRef.current && isControlled && value !== undefined) {
|
|
4930
|
+
if (contentEditableRef.current.textContent !== value) {
|
|
4931
|
+
contentEditableRef.current.textContent = value;
|
|
4932
|
+
}
|
|
4933
|
+
}
|
|
4934
|
+
}, [value, isControlled]);
|
|
4935
|
+
// Auto focus
|
|
4936
|
+
useEffect(() => {
|
|
4937
|
+
if (autoFocus && contentEditableRef.current) {
|
|
4938
|
+
contentEditableRef.current.focus();
|
|
4939
|
+
}
|
|
4940
|
+
}, [autoFocus]);
|
|
4941
|
+
// Forward ref
|
|
4942
|
+
useEffect(() => {
|
|
4943
|
+
if (typeof ref === 'function') {
|
|
4944
|
+
ref(contentEditableRef.current);
|
|
4945
|
+
}
|
|
4946
|
+
else if (ref) {
|
|
4947
|
+
ref.current = contentEditableRef.current;
|
|
4948
|
+
}
|
|
4949
|
+
}, [ref]);
|
|
4950
|
+
const textareaElement = (jsx(Box, { ref: contentEditableRef, contentEditable: !disabled && !readOnly, onInput: handleInput, onPaste: handlePaste, onFocus: onFocus, onBlur: onBlur, className: className, minHeight: `${rows * 1.5}em`, padding: "2", border: "1px solid", borderColor: invalid ? "red.500" : "gray.200", borderRadius: "md", outline: "none", _focus: {
|
|
4951
|
+
borderColor: invalid ? "red.500" : "blue.500",
|
|
4952
|
+
boxShadow: `0 0 0 1px ${invalid ? "red.500" : "blue.500"}`,
|
|
4953
|
+
}, _disabled: {
|
|
4954
|
+
opacity: 0.6,
|
|
4955
|
+
cursor: "not-allowed",
|
|
4956
|
+
bg: "gray.50",
|
|
4957
|
+
}, _empty: {
|
|
4958
|
+
_before: {
|
|
4959
|
+
content: placeholder ? `"${placeholder}"` : undefined,
|
|
4960
|
+
color: "gray.400",
|
|
4961
|
+
pointerEvents: "none",
|
|
4962
|
+
}
|
|
4963
|
+
}, whiteSpace: "pre-wrap", overflowWrap: "break-word", overflow: "auto", maxHeight: `${rows * 4}em`, suppressContentEditableWarning: true, ...props }));
|
|
4964
|
+
// If we have additional field props, wrap in Field component
|
|
4965
|
+
if (label || helperText || errorText || required) {
|
|
4966
|
+
return (jsxs(Field$1.Root, { invalid: invalid, required: required, children: [label && (jsxs(Field$1.Label, { children: [label, required && jsx(Field$1.RequiredIndicator, {})] })), textareaElement, helperText && jsx(Field$1.HelperText, { children: helperText }), errorText && jsx(Field$1.ErrorText, { children: errorText })] }));
|
|
4967
|
+
}
|
|
4968
|
+
return textareaElement;
|
|
4969
|
+
});
|
|
4970
|
+
Textarea.displayName = "Textarea";
|
|
4971
|
+
|
|
4887
4972
|
const TextAreaInput = ({ column, schema, prefix, }) => {
|
|
4888
4973
|
const { register, formState: { errors }, } = useFormContext();
|
|
4889
4974
|
const { translate } = useSchemaContext();
|
|
4890
4975
|
const { required, gridColumn = "span 4", gridRow = "span 1" } = schema;
|
|
4891
4976
|
const isRequired = required?.some((columnId) => columnId === column);
|
|
4892
4977
|
const colLabel = `${prefix}${column}`;
|
|
4893
|
-
|
|
4978
|
+
const form = useFormContext();
|
|
4979
|
+
const { setValue, watch } = form;
|
|
4980
|
+
const watchValue = watch(colLabel);
|
|
4981
|
+
return (jsx(Fragment, { children: jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, gridColumn: gridColumn ?? "span 4", gridRow: gridRow ?? "span 1", display: "grid", children: [jsx(Textarea, { value: watchValue, onChange: (value) => setValue(colLabel, value) }), errors[colLabel] && (jsx(Text, { color: "red.400", children: translate.t(removeIndex(`${colLabel}.field_required`)) }))] }) }));
|
|
4894
4982
|
};
|
|
4895
4983
|
|
|
4896
4984
|
function TimePicker$1({ hour, setHour, minute, setMinute, meridiem, setMeridiem, meridiemLabel = {
|
|
@@ -5382,6 +5470,15 @@ const SchemaRenderer = ({ schema, prefix, column, }) => {
|
|
|
5382
5470
|
if (variant === "file-picker") {
|
|
5383
5471
|
return jsx(FilePicker, { schema: colSchema, prefix, column });
|
|
5384
5472
|
}
|
|
5473
|
+
if (variant === "enum-picker") {
|
|
5474
|
+
const { items } = colSchema;
|
|
5475
|
+
const { enum: enumItems } = items;
|
|
5476
|
+
const enumSchema = {
|
|
5477
|
+
type: "string",
|
|
5478
|
+
enum: enumItems,
|
|
5479
|
+
};
|
|
5480
|
+
return (jsx(EnumPicker, { isMultiple: true, schema: enumSchema, prefix, column }));
|
|
5481
|
+
}
|
|
5385
5482
|
if (items) {
|
|
5386
5483
|
return jsx(ArrayRenderer, { schema: colSchema, prefix, column });
|
|
5387
5484
|
}
|
|
@@ -5473,9 +5570,9 @@ const EnumViewer = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
5473
5570
|
if (item === undefined) {
|
|
5474
5571
|
return jsx(Fragment, { children: "undefined" });
|
|
5475
5572
|
}
|
|
5476
|
-
return (jsx(Tag, { children: !!renderDisplay === true
|
|
5573
|
+
return (jsx(Tag, { size: "lg", children: !!renderDisplay === true
|
|
5477
5574
|
? renderDisplay(item)
|
|
5478
|
-
: customTranslate(item) }));
|
|
5575
|
+
: customTranslate(item) }, item));
|
|
5479
5576
|
}) })), !isMultiple && jsx(Text, { children: customTranslate(watchEnum) }), errors[`${column}`] && (jsx(Text, { color: "red.400", children: customTranslate(`field_required`) }))] }));
|
|
5480
5577
|
};
|
|
5481
5578
|
|
|
@@ -5789,6 +5886,15 @@ const SchemaViewer = ({ schema, prefix, column, }) => {
|
|
|
5789
5886
|
if (variant === "file-picker") {
|
|
5790
5887
|
return jsx(FileViewer, { schema: colSchema, prefix, column });
|
|
5791
5888
|
}
|
|
5889
|
+
if (variant === "enum-picker") {
|
|
5890
|
+
const { items } = schema;
|
|
5891
|
+
const { enum: enumItems } = items;
|
|
5892
|
+
const enumSchema = {
|
|
5893
|
+
type: "string",
|
|
5894
|
+
enum: enumItems,
|
|
5895
|
+
};
|
|
5896
|
+
return (jsx(EnumViewer, { isMultiple: true, schema: enumSchema, prefix, column }));
|
|
5897
|
+
}
|
|
5792
5898
|
if (items) {
|
|
5793
5899
|
return jsx(ArrayViewer, { schema: colSchema, prefix, column });
|
|
5794
5900
|
}
|
|
@@ -5936,7 +6042,7 @@ const FormBody = () => {
|
|
|
5936
6042
|
return (jsx(AccordionRoot, { backgroundColor: {
|
|
5937
6043
|
base: "red.50",
|
|
5938
6044
|
_dark: "red.950",
|
|
5939
|
-
}, p: "4", colorPalette: "red", collapsible: true, defaultValue: [], children: jsxs(AccordionItem, { value: "validation-errors", children: [jsx(AccordionItemTrigger, { children: translate.t("validation_error") }), jsx(AccordionItemContent, { display: "flex", flexFlow: "column", gap: "2", children: validationErrors.map((err, index) => (jsxs(AlertRoot, { status: "error", display: "flex", alignItems: "center", children: [jsx(AlertIndicator, {}),
|
|
6045
|
+
}, p: "4", colorPalette: "red", collapsible: true, defaultValue: [], children: jsxs(AccordionItem, { value: "validation-errors", children: [jsx(AccordionItemTrigger, { children: translate.t("validation_error") }), jsx(AccordionItemContent, { display: "flex", flexFlow: "column", gap: "2", children: validationErrors.map((err, index) => (jsxs(AlertRoot, { status: "error", display: "flex", alignItems: "center", children: [jsx(AlertIndicator, {}), jsx(AlertContent, { children: jsx(AlertDescription, { children: err.message }) })] }))) })] }) }));
|
|
5940
6046
|
};
|
|
5941
6047
|
const renderColumns = ({ order, keys, ignore, include, }) => {
|
|
5942
6048
|
const included = include.length > 0 ? include : keys;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
interface CustomTextareaProps {
|
|
3
|
+
value?: string;
|
|
4
|
+
defaultValue?: string;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
onChange?: (value: string) => void;
|
|
7
|
+
onFocus?: () => void;
|
|
8
|
+
onBlur?: () => void;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
readOnly?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
rows?: number;
|
|
13
|
+
maxLength?: number;
|
|
14
|
+
autoFocus?: boolean;
|
|
15
|
+
invalid?: boolean;
|
|
16
|
+
required?: boolean;
|
|
17
|
+
label?: string;
|
|
18
|
+
helperText?: string;
|
|
19
|
+
errorText?: string;
|
|
20
|
+
}
|
|
21
|
+
declare const Textarea: React.ForwardRefExoticComponent<CustomTextareaProps & React.RefAttributes<HTMLDivElement>>;
|
|
22
|
+
export { Textarea };
|