ywana-core8 0.1.76 → 0.1.78
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.cjs +2781 -142
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1772 -72
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +2775 -143
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +2781 -142
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/index.js +3 -0
- package/src/html/tab.css +4 -3
- package/src/html/table2.example.js +1 -1
- package/src/html/table2.js +1 -1
- package/src/html/textfield2.css +3 -4
- package/src/html/textfield2.example.js +1013 -142
- package/src/html/textfield2.js +22 -9
- package/src/html/tree.css +18 -16
- package/src/html/tree.js +6 -4
package/dist/index.cjs
CHANGED
@@ -1357,7 +1357,7 @@ var PropTypes = propTypes;
|
|
1357
1357
|
*/
|
1358
1358
|
var SiteContext = React__default["default"].createContext({});
|
1359
1359
|
|
1360
|
-
var _excluded$
|
1360
|
+
var _excluded$h = ["format", "children", "className", "size", "weight", "color", "align", "transform", "decoration", "truncate", "maxLength", "locale", "currency", "minimumFractionDigits", "maximumFractionDigits", "dateStyle", "timeStyle", "fallback", "loading", "skeleton", "copyable", "selectable", "as", "style", "onClick"];
|
1361
1361
|
function _catch$c(body, recover) {
|
1362
1362
|
try {
|
1363
1363
|
var result = body();
|
@@ -1428,7 +1428,7 @@ var Text = function Text(props) {
|
|
1428
1428
|
as = _props$as === void 0 ? 'span' : _props$as,
|
1429
1429
|
style = props.style,
|
1430
1430
|
onClick = props.onClick,
|
1431
|
-
restProps = _objectWithoutPropertiesLoose(props, _excluded$
|
1431
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded$h);
|
1432
1432
|
var site = React.useContext(SiteContext);
|
1433
1433
|
|
1434
1434
|
// Memoize formatted value for performance
|
@@ -1796,8 +1796,8 @@ Icon.defaultProps = {
|
|
1796
1796
|
className: ''
|
1797
1797
|
};
|
1798
1798
|
|
1799
|
-
var _excluded$
|
1800
|
-
_excluded2$
|
1799
|
+
var _excluded$g = ["className", "sections", "disabled", "allowMultiple", "animated", "onCheck", "onToggle", "onSectionChange", "ariaLabel"],
|
1800
|
+
_excluded2$9 = ["checked", "icon", "title", "subtitle", "open", "disabled", "animated", "sectionIndex", "onToggle", "onCheck", "toolbar", "info", "children", "ariaLabel"];
|
1801
1801
|
|
1802
1802
|
/**
|
1803
1803
|
* Enhanced Accordion component with improved accessibility and robustness
|
@@ -1816,7 +1816,7 @@ var Accordion = function Accordion(props) {
|
|
1816
1816
|
onToggle = props.onToggle,
|
1817
1817
|
onSectionChange = props.onSectionChange,
|
1818
1818
|
ariaLabel = props.ariaLabel,
|
1819
|
-
restProps = _objectWithoutPropertiesLoose(props, _excluded$
|
1819
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded$g);
|
1820
1820
|
var _useState = React.useState([]),
|
1821
1821
|
openSections = _useState[0],
|
1822
1822
|
setOpenSections = _useState[1];
|
@@ -1933,7 +1933,7 @@ var AccordionSection = function AccordionSection(props) {
|
|
1933
1933
|
info = props.info,
|
1934
1934
|
children = props.children,
|
1935
1935
|
ariaLabel = props.ariaLabel,
|
1936
|
-
restProps = _objectWithoutPropertiesLoose(props, _excluded2$
|
1936
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded2$9);
|
1937
1937
|
var togglerIcon = open ? "expand_less" : "expand_more";
|
1938
1938
|
var checkedIcon = checked === undefined || checked === null ? null : checked === false ? "check_box_outline_blank" : "check_box";
|
1939
1939
|
|
@@ -2062,8 +2062,8 @@ Accordion.defaultProps = {
|
|
2062
2062
|
animated: true
|
2063
2063
|
};
|
2064
2064
|
|
2065
|
-
var _excluded$
|
2066
|
-
_excluded2$
|
2065
|
+
var _excluded$f = ["id", "label", "icon", "action", "disabled", "loading", "outlined", "raised", "size", "type", "className", "ariaLabel", "tooltip", "form", "onClick", "onFocus", "onBlur", "onKeyDown"],
|
2066
|
+
_excluded2$8 = ["states", "state", "className", "disabled", "onStateChange"];
|
2067
2067
|
function _catch$b(body, recover) {
|
2068
2068
|
try {
|
2069
2069
|
var result = body();
|
@@ -2118,7 +2118,7 @@ var Button = function Button(props) {
|
|
2118
2118
|
onFocus = props.onFocus,
|
2119
2119
|
onBlur = props.onBlur,
|
2120
2120
|
onKeyDown = props.onKeyDown,
|
2121
|
-
restProps = _objectWithoutPropertiesLoose(props, _excluded$
|
2121
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded$f);
|
2122
2122
|
|
2123
2123
|
// Validate required props
|
2124
2124
|
if (!label && !icon && !ariaLabel) {
|
@@ -2231,7 +2231,7 @@ var ActionButton = function ActionButton(props) {
|
|
2231
2231
|
_props$disabled2 = props.disabled,
|
2232
2232
|
disabled = _props$disabled2 === void 0 ? false : _props$disabled2,
|
2233
2233
|
onStateChange = props.onStateChange,
|
2234
|
-
restProps = _objectWithoutPropertiesLoose(props, _excluded2$
|
2234
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded2$8);
|
2235
2235
|
var _useState = React.useState(state),
|
2236
2236
|
currentState = _useState[0],
|
2237
2237
|
setCurrentState = _useState[1];
|
@@ -2482,8 +2482,8 @@ CheckBox.defaultProps = {
|
|
2482
2482
|
className: ''
|
2483
2483
|
};
|
2484
2484
|
|
2485
|
-
var _excluded$
|
2486
|
-
_excluded2$
|
2485
|
+
var _excluded$e = ["id", "icon", "label", "tooltip", "action", "outlined", "selected", "disabled", "deletable", "size", "variant", "className", "ariaLabel", "onSelect", "onDelete", "onClick", "onKeyDown"],
|
2486
|
+
_excluded2$7 = ["children", "items", "selected", "disabled", "deletable", "multiSelect", "size", "variant", "className", "onSelect", "onDelete", "onChange"];
|
2487
2487
|
|
2488
2488
|
/**
|
2489
2489
|
* Chip component with enhanced features and accessibility
|
@@ -2512,7 +2512,7 @@ var Chip = function Chip(props) {
|
|
2512
2512
|
onDelete = props.onDelete,
|
2513
2513
|
onClick = props.onClick,
|
2514
2514
|
onKeyDown = props.onKeyDown,
|
2515
|
-
restProps = _objectWithoutPropertiesLoose(props, _excluded$
|
2515
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded$e);
|
2516
2516
|
|
2517
2517
|
// Validate required props
|
2518
2518
|
if (!label && !icon && !ariaLabel) {
|
@@ -2614,7 +2614,7 @@ var Chips = function Chips(props) {
|
|
2614
2614
|
onSelect = props.onSelect,
|
2615
2615
|
onDelete = props.onDelete,
|
2616
2616
|
onChange = props.onChange,
|
2617
|
-
restProps = _objectWithoutPropertiesLoose(props, _excluded2$
|
2617
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded2$7);
|
2618
2618
|
var _useState = React.useState(selected),
|
2619
2619
|
selectedItems = _useState[0],
|
2620
2620
|
setSelectedItems = _useState[1];
|
@@ -2779,7 +2779,7 @@ Chips.defaultProps = {
|
|
2779
2779
|
className: ''
|
2780
2780
|
};
|
2781
2781
|
|
2782
|
-
var _excluded$
|
2782
|
+
var _excluded$d = ["id", "title", "columns", "children", "outlined", "disabled", "loading", "autoComplete", "noValidate", "className", "onChange", "onSubmit", "onReset", "onValidationChange"];
|
2783
2783
|
function _catch$a(body, recover) {
|
2784
2784
|
try {
|
2785
2785
|
var result = body();
|
@@ -2830,7 +2830,7 @@ var Form = function Form(props) {
|
|
2830
2830
|
onSubmit = props.onSubmit,
|
2831
2831
|
onReset = props.onReset,
|
2832
2832
|
onValidationChange = props.onValidationChange,
|
2833
|
-
restProps = _objectWithoutPropertiesLoose(props, _excluded$
|
2833
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded$d);
|
2834
2834
|
var _useState = React.useState([]),
|
2835
2835
|
fields = _useState[0],
|
2836
2836
|
setFields = _useState[1];
|
@@ -3121,8 +3121,186 @@ var Header = function Header(props) {
|
|
3121
3121
|
}, props.children));
|
3122
3122
|
};
|
3123
3123
|
|
3124
|
-
var _excluded$
|
3125
|
-
|
3124
|
+
var _excluded$c = ["title", "icon", "iconSrc", "img", "caption", "prominent", "dense", "primary", "secondary", "clickable", "disabled", "loading", "className", "children", "action", "ariaLabel", "role", "onClick", "onIconClick"];
|
3125
|
+
|
3126
|
+
/**
|
3127
|
+
* Enhanced Header component with improved accessibility and robustness
|
3128
|
+
* Maintains 100% visual compatibility with original Header
|
3129
|
+
*/
|
3130
|
+
var Header2 = function Header2(props) {
|
3131
|
+
var title = props.title,
|
3132
|
+
icon = props.icon,
|
3133
|
+
iconSrc = props.iconSrc,
|
3134
|
+
img = props.img,
|
3135
|
+
_props$caption = props.caption,
|
3136
|
+
caption = _props$caption === void 0 ? false : _props$caption,
|
3137
|
+
_props$prominent = props.prominent,
|
3138
|
+
prominent = _props$prominent === void 0 ? false : _props$prominent,
|
3139
|
+
_props$dense = props.dense,
|
3140
|
+
dense = _props$dense === void 0 ? false : _props$dense,
|
3141
|
+
_props$primary = props.primary,
|
3142
|
+
primary = _props$primary === void 0 ? false : _props$primary,
|
3143
|
+
_props$secondary = props.secondary,
|
3144
|
+
secondary = _props$secondary === void 0 ? false : _props$secondary,
|
3145
|
+
_props$clickable = props.clickable,
|
3146
|
+
clickable = _props$clickable === void 0 ? false : _props$clickable,
|
3147
|
+
_props$disabled = props.disabled,
|
3148
|
+
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
3149
|
+
_props$loading = props.loading,
|
3150
|
+
loading = _props$loading === void 0 ? false : _props$loading,
|
3151
|
+
className = props.className,
|
3152
|
+
children = props.children,
|
3153
|
+
action = props.action,
|
3154
|
+
ariaLabel = props.ariaLabel,
|
3155
|
+
_props$role = props.role,
|
3156
|
+
role = _props$role === void 0 ? 'banner' : _props$role,
|
3157
|
+
onClick = props.onClick,
|
3158
|
+
onIconClick = props.onIconClick,
|
3159
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded$c);
|
3160
|
+
|
3161
|
+
// Validate props
|
3162
|
+
if (!title && !icon && !iconSrc && !ariaLabel) {
|
3163
|
+
console.warn('Header2 component: title, icon, iconSrc, or ariaLabel should be provided for accessibility');
|
3164
|
+
}
|
3165
|
+
|
3166
|
+
// Handle icon click
|
3167
|
+
var handleIconClick = React.useCallback(function (event) {
|
3168
|
+
if (disabled || loading) return;
|
3169
|
+
if (onIconClick) {
|
3170
|
+
onIconClick(event);
|
3171
|
+
} else if (action) {
|
3172
|
+
action(event);
|
3173
|
+
}
|
3174
|
+
}, [disabled, loading, onIconClick, action]);
|
3175
|
+
|
3176
|
+
// Handle header click
|
3177
|
+
var handleClick = React.useCallback(function (event) {
|
3178
|
+
if (disabled || loading) return;
|
3179
|
+
if (onClick) {
|
3180
|
+
onClick(event);
|
3181
|
+
}
|
3182
|
+
}, [disabled, loading, onClick]);
|
3183
|
+
|
3184
|
+
// Generate CSS classes (maintaining exact same logic as original)
|
3185
|
+
var captionClass = caption ? 'caption' : '';
|
3186
|
+
var prominentClass = prominent ? 'prominent' : '';
|
3187
|
+
var denseClass = dense ? 'dense' : '';
|
3188
|
+
var themeClass = primary ? 'primary' : '';
|
3189
|
+
themeClass = secondary ? 'secondary' : themeClass;
|
3190
|
+
var safeClassName = className || '';
|
3191
|
+
var cssClasses = ['header2', captionClass, prominentClass, denseClass, themeClass, disabled && 'disabled', loading && 'loading', safeClassName].filter(Boolean).join(' ');
|
3192
|
+
|
3193
|
+
// Generate icon element (maintaining exact same logic as original)
|
3194
|
+
var iconElement = null;
|
3195
|
+
if (icon) {
|
3196
|
+
iconElement = /*#__PURE__*/React__default["default"].createElement(Icon, {
|
3197
|
+
icon: icon,
|
3198
|
+
clickable: clickable && !disabled && !loading,
|
3199
|
+
action: handleIconClick,
|
3200
|
+
disabled: disabled,
|
3201
|
+
ariaLabel: icon + " icon"
|
3202
|
+
});
|
3203
|
+
} else if (iconSrc) {
|
3204
|
+
iconElement = /*#__PURE__*/React__default["default"].createElement("img", {
|
3205
|
+
className: "header2-icon",
|
3206
|
+
src: iconSrc,
|
3207
|
+
alt: ariaLabel || title || 'Header icon',
|
3208
|
+
onClick: clickable && !disabled && !loading ? handleIconClick : undefined,
|
3209
|
+
style: {
|
3210
|
+
cursor: clickable && !disabled && !loading ? 'pointer' : 'default',
|
3211
|
+
opacity: disabled ? 0.6 : 1
|
3212
|
+
}
|
3213
|
+
});
|
3214
|
+
}
|
3215
|
+
|
3216
|
+
// Generate background style (maintaining exact same logic as original)
|
3217
|
+
var backgroundStyle = img ? {
|
3218
|
+
backgroundImage: "url(" + img + ")"
|
3219
|
+
} : {};
|
3220
|
+
|
3221
|
+
// Generate title element (maintaining exact same logic as original)
|
3222
|
+
var titleElement = title ? /*#__PURE__*/React__default["default"].createElement("label", {
|
3223
|
+
className: "header2-title"
|
3224
|
+
}, /*#__PURE__*/React__default["default"].createElement(Text, null, title)) : null;
|
3225
|
+
|
3226
|
+
// Accessibility attributes
|
3227
|
+
var ariaAttributes = {
|
3228
|
+
'aria-label': ariaLabel || (typeof title === 'string' ? title : 'Header'),
|
3229
|
+
'aria-disabled': disabled,
|
3230
|
+
'aria-busy': loading,
|
3231
|
+
role: role
|
3232
|
+
};
|
3233
|
+
return /*#__PURE__*/React__default["default"].createElement("header", _extends({
|
3234
|
+
className: cssClasses,
|
3235
|
+
style: backgroundStyle,
|
3236
|
+
onClick: onClick ? handleClick : undefined
|
3237
|
+
}, ariaAttributes, restProps), iconElement, titleElement, /*#__PURE__*/React__default["default"].createElement("span", {
|
3238
|
+
className: "header2-actions",
|
3239
|
+
role: "toolbar",
|
3240
|
+
"aria-label": "Header actions"
|
3241
|
+
}, loading && /*#__PURE__*/React__default["default"].createElement(Icon, {
|
3242
|
+
icon: "hourglass_empty",
|
3243
|
+
className: "header2-loading",
|
3244
|
+
ariaLabel: "Loading"
|
3245
|
+
}), children));
|
3246
|
+
};
|
3247
|
+
|
3248
|
+
// PropTypes for Header2
|
3249
|
+
Header2.propTypes = {
|
3250
|
+
/** Header title text */
|
3251
|
+
title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
3252
|
+
/** Material icon name */
|
3253
|
+
icon: PropTypes.string,
|
3254
|
+
/** Icon image source URL */
|
3255
|
+
iconSrc: PropTypes.string,
|
3256
|
+
/** Background image URL */
|
3257
|
+
img: PropTypes.string,
|
3258
|
+
/** Whether header has caption style (4rem height) */
|
3259
|
+
caption: PropTypes.bool,
|
3260
|
+
/** Whether header has prominent style (12.8rem height) */
|
3261
|
+
prominent: PropTypes.bool,
|
3262
|
+
/** Whether header has dense style (2.4rem height) */
|
3263
|
+
dense: PropTypes.bool,
|
3264
|
+
/** Whether header has primary theme */
|
3265
|
+
primary: PropTypes.bool,
|
3266
|
+
/** Whether header has secondary theme */
|
3267
|
+
secondary: PropTypes.bool,
|
3268
|
+
/** Whether icon is clickable */
|
3269
|
+
clickable: PropTypes.bool,
|
3270
|
+
/** Whether header is disabled */
|
3271
|
+
disabled: PropTypes.bool,
|
3272
|
+
/** Whether header is in loading state */
|
3273
|
+
loading: PropTypes.bool,
|
3274
|
+
/** Additional CSS classes */
|
3275
|
+
className: PropTypes.string,
|
3276
|
+
/** Action elements (buttons, etc.) */
|
3277
|
+
children: PropTypes.node,
|
3278
|
+
/** Icon click handler (legacy support) */
|
3279
|
+
action: PropTypes.func,
|
3280
|
+
/** ARIA label for accessibility */
|
3281
|
+
ariaLabel: PropTypes.string,
|
3282
|
+
/** ARIA role */
|
3283
|
+
role: PropTypes.string,
|
3284
|
+
/** Header click handler */
|
3285
|
+
onClick: PropTypes.func,
|
3286
|
+
/** Icon click handler */
|
3287
|
+
onIconClick: PropTypes.func
|
3288
|
+
};
|
3289
|
+
Header2.defaultProps = {
|
3290
|
+
caption: false,
|
3291
|
+
prominent: false,
|
3292
|
+
dense: false,
|
3293
|
+
primary: false,
|
3294
|
+
secondary: false,
|
3295
|
+
clickable: false,
|
3296
|
+
disabled: false,
|
3297
|
+
loading: false,
|
3298
|
+
role: 'banner',
|
3299
|
+
className: ''
|
3300
|
+
};
|
3301
|
+
|
3302
|
+
var _excluded$b = ["value", "max", "size", "thickness", "variant", "color", "showValue", "showLabel", "label", "icon", "animated", "disabled", "className", "style", "children", "onComplete", "formatValue", "ariaLabel"],
|
3303
|
+
_excluded2$6 = ["value", "max", "variant", "color", "size", "showValue", "showLabel", "label", "buffer", "animated", "striped", "disabled", "rounded", "className", "style", "onComplete", "formatValue", "ariaLabel", "estimatedTime", "speed"];
|
3126
3304
|
|
3127
3305
|
/**
|
3128
3306
|
* Enhanced Circular Progress component with professional features
|
@@ -3156,7 +3334,7 @@ var CircularProgress = function CircularProgress(props) {
|
|
3156
3334
|
onComplete = props.onComplete,
|
3157
3335
|
formatValue = props.formatValue,
|
3158
3336
|
ariaLabel = props.ariaLabel,
|
3159
|
-
restProps = _objectWithoutPropertiesLoose(props, _excluded$
|
3337
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded$b);
|
3160
3338
|
var _useState = React.useState(0),
|
3161
3339
|
animatedValue = _useState[0],
|
3162
3340
|
setAnimatedValue = _useState[1];
|
@@ -3318,7 +3496,7 @@ var LinearProgress = function LinearProgress(props) {
|
|
3318
3496
|
ariaLabel = props.ariaLabel,
|
3319
3497
|
estimatedTime = props.estimatedTime,
|
3320
3498
|
speed = props.speed,
|
3321
|
-
restProps = _objectWithoutPropertiesLoose(props, _excluded2$
|
3499
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded2$6);
|
3322
3500
|
var _useState3 = React.useState(0),
|
3323
3501
|
animatedValue = _useState3[0],
|
3324
3502
|
setAnimatedValue = _useState3[1];
|
@@ -4011,9 +4189,9 @@ var PasswordField = function PasswordField(props) {
|
|
4011
4189
|
}));
|
4012
4190
|
};
|
4013
4191
|
|
4014
|
-
var _excluded$
|
4015
|
-
_excluded2$
|
4016
|
-
_excluded3$
|
4192
|
+
var _excluded$a = ["items", "children", "selected", "onSelect", "groupBy", "groupRenderer", "loading", "empty", "emptyMessage", "emptyIcon", "searchable", "searchPlaceholder", "searchBy", "sortable", "sortBy", "sortDirection", "onSort", "multiSelect", "onMultiSelect", "dense", "disabled", "animated", "virtualized", "itemHeight", "maxHeight", "className", "style", "ariaLabel", "role"],
|
4193
|
+
_excluded2$5 = ["items", "children", "selected", "onSelect", "groupBy", "groupRenderer", "searchTerm", "onSearch", "searchable", "searchPlaceholder", "multiSelect", "dense", "disabled", "animated", "cssClasses", "ariaAttributes", "style"],
|
4194
|
+
_excluded3$2 = ["id", "icon", "iconTooltip", "line1", "line2", "meta", "avatar", "badge", "actions", "disabled"];
|
4017
4195
|
|
4018
4196
|
/**
|
4019
4197
|
* Enhanced List component with improved functionality while maintaining 100% compatibility
|
@@ -4060,7 +4238,7 @@ var List = function List(props) {
|
|
4060
4238
|
ariaLabel = props.ariaLabel,
|
4061
4239
|
_props$role = props.role,
|
4062
4240
|
role = _props$role === void 0 ? 'list' : _props$role,
|
4063
|
-
restProps = _objectWithoutPropertiesLoose(props, _excluded$
|
4241
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded$a);
|
4064
4242
|
var _useState = React.useState(''),
|
4065
4243
|
searchTerm = _useState[0],
|
4066
4244
|
setSearchTerm = _useState[1];
|
@@ -4269,7 +4447,7 @@ var GroupedList = function GroupedList(props) {
|
|
4269
4447
|
cssClasses = props.cssClasses,
|
4270
4448
|
ariaAttributes = props.ariaAttributes,
|
4271
4449
|
style = props.style,
|
4272
|
-
restProps = _objectWithoutPropertiesLoose(props, _excluded2$
|
4450
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded2$5);
|
4273
4451
|
var _useState3 = React.useState(new Set()),
|
4274
4452
|
collapsedGroups = _useState3[0],
|
4275
4453
|
setCollapsedGroups = _useState3[1];
|
@@ -4389,7 +4567,7 @@ var ListItem = function ListItem(_ref) {
|
|
4389
4567
|
actions = item.actions,
|
4390
4568
|
_item$disabled = item.disabled,
|
4391
4569
|
itemDisabled = _item$disabled === void 0 ? false : _item$disabled,
|
4392
|
-
itemProps = _objectWithoutPropertiesLoose(item, _excluded3$
|
4570
|
+
itemProps = _objectWithoutPropertiesLoose(item, _excluded3$2);
|
4393
4571
|
var isItemDisabled = disabled || itemDisabled;
|
4394
4572
|
var isSelected = Array.isArray(selected) ? selected.includes(id) : selected === id;
|
4395
4573
|
|
@@ -4653,7 +4831,7 @@ var MenuSeparator = function MenuSeparator(props) {
|
|
4653
4831
|
});
|
4654
4832
|
};
|
4655
4833
|
|
4656
|
-
var _excluded$
|
4834
|
+
var _excluded$9 = ["id", "className", "label", "name", "initial", "value", "editable", "onChange", "options", "type", "disabled", "required", "placeholder", "multiline", "rows", "maxLength", "minLength", "pattern", "validateValue", "size", "variant", "layout", "nameWidth", "copyable", "error", "helperText", "onFocus", "onBlur", "onValidationError", "clearable", "readOnly", "loading", "skeleton", "style"];
|
4657
4835
|
function _catch$9(body, recover) {
|
4658
4836
|
try {
|
4659
4837
|
var result = body();
|
@@ -4719,7 +4897,7 @@ var Property = function Property(props) {
|
|
4719
4897
|
_props$skeleton = props.skeleton,
|
4720
4898
|
skeleton = _props$skeleton === void 0 ? false : _props$skeleton,
|
4721
4899
|
style = props.style,
|
4722
|
-
restProps = _objectWithoutPropertiesLoose(props, _excluded$
|
4900
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded$9);
|
4723
4901
|
var _useState = React.useState(false),
|
4724
4902
|
isFocused = _useState[0],
|
4725
4903
|
setIsFocused = _useState[1];
|
@@ -5351,8 +5529,8 @@ Section.defaultProps = {
|
|
5351
5529
|
className: ''
|
5352
5530
|
};
|
5353
5531
|
|
5354
|
-
var _excluded$
|
5355
|
-
_excluded2$
|
5532
|
+
var _excluded$8 = ["children", "selected", "onChange", "fillLeft", "fillRight", "orientation", "variant", "scrollable", "centered", "disabled", "animated", "persistent", "persistKey", "beforeChange", "className", "style", "ariaLabel"],
|
5533
|
+
_excluded2$4 = ["id", "icon", "label", "selected", "actions", "onSelect", "disabled", "closeable", "onClose", "badge", "tooltip", "orientation", "variant", "animated", "tabIndex", "totalTabs", "className", "style"];
|
5356
5534
|
function _catch$8(body, recover) {
|
5357
5535
|
try {
|
5358
5536
|
var result = body();
|
@@ -5395,7 +5573,7 @@ var Tabs = function Tabs(props) {
|
|
5395
5573
|
className = props.className,
|
5396
5574
|
style = props.style,
|
5397
5575
|
ariaLabel = props.ariaLabel,
|
5398
|
-
restProps = _objectWithoutPropertiesLoose(props, _excluded$
|
5576
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded$8);
|
5399
5577
|
var tabsRef = React.useRef(null);
|
5400
5578
|
|
5401
5579
|
// Validate props
|
@@ -5557,7 +5735,7 @@ var Tab = function Tab(props) {
|
|
5557
5735
|
tabIndex = props.tabIndex,
|
5558
5736
|
className = props.className,
|
5559
5737
|
style = props.style,
|
5560
|
-
restProps = _objectWithoutPropertiesLoose(props, _excluded2$
|
5738
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded2$4);
|
5561
5739
|
var tabRef = React.useRef(null);
|
5562
5740
|
|
5563
5741
|
// Handle selection (maintaining original behavior)
|
@@ -6226,7 +6404,7 @@ var Uploader = function Uploader(_ref) {
|
|
6226
6404
|
}));
|
6227
6405
|
};
|
6228
6406
|
|
6229
|
-
var isFunction$
|
6407
|
+
var isFunction$2 = function isFunction(value) {
|
6230
6408
|
return value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
|
6231
6409
|
};
|
6232
6410
|
|
@@ -6498,7 +6676,7 @@ var DataTableRow = function DataTableRow(props) {
|
|
6498
6676
|
className: "table-row-info"
|
6499
6677
|
}, /*#__PURE__*/React__default["default"].createElement("td", {
|
6500
6678
|
colSpan: columns.length + 1
|
6501
|
-
}, isFunction$
|
6679
|
+
}, isFunction$2(row.info) ? row.info() : row.info)) : null);
|
6502
6680
|
};
|
6503
6681
|
|
6504
6682
|
/**
|
@@ -6990,140 +7168,2592 @@ var SortIcon = function SortIcon(props) {
|
|
6990
7168
|
});
|
6991
7169
|
};
|
6992
7170
|
|
6993
|
-
var _excluded$
|
6994
|
-
_excluded2$
|
7171
|
+
var _excluded$7 = ["id", "type", "className", "label", "labelPosition", "placeholder", "value", "outlined", "readOnly", "disabled", "required", "canClear", "showPasswordToggle", "autoComplete", "error", "helperText", "maxLength", "minLength", "pattern", "step", "min", "max", "rows", "validation", "debounceMs", "ariaLabel", "ariaDescribedBy", "onChange", "onEnter", "onClick", "onFocus", "onBlur", "onValidation"],
|
7172
|
+
_excluded2$3 = ["id", "options", "value", "placeholder", "label", "outlined", "disabled", "readOnly", "required", "searchable", "clearable", "multiple", "groupBy", "filterFunction", "renderOption", "renderValue", "position", "maxHeight", "error", "helperText", "className", "ariaLabel", "onChange", "onOpen", "onClose", "onSearch"],
|
7173
|
+
_excluded3$1 = ["id", "label", "value", "outlined", "disabled", "readOnly", "required", "minDate", "maxDate", "error", "helperText", "className", "ariaLabel", "onChange", "onValidation"];
|
6995
7174
|
|
6996
7175
|
/**
|
6997
|
-
* Enhanced
|
7176
|
+
* Enhanced TextField component with improved validation and accessibility
|
6998
7177
|
*/
|
6999
|
-
var
|
7178
|
+
var TextField2 = function TextField2(props) {
|
7000
7179
|
var id = props.id,
|
7180
|
+
_props$type = props.type,
|
7181
|
+
type = _props$type === void 0 ? 'text' : _props$type,
|
7182
|
+
className = props.className,
|
7001
7183
|
label = props.label,
|
7002
|
-
_props$
|
7003
|
-
|
7004
|
-
|
7005
|
-
|
7006
|
-
_props$
|
7007
|
-
|
7008
|
-
|
7184
|
+
_props$labelPosition = props.labelPosition,
|
7185
|
+
labelPosition = _props$labelPosition === void 0 ? 'top' : _props$labelPosition,
|
7186
|
+
placeholder = props.placeholder,
|
7187
|
+
value = props.value,
|
7188
|
+
_props$outlined = props.outlined,
|
7189
|
+
outlined = _props$outlined === void 0 ? false : _props$outlined,
|
7190
|
+
_props$readOnly = props.readOnly,
|
7191
|
+
readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
|
7009
7192
|
_props$disabled = props.disabled,
|
7010
7193
|
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
7011
7194
|
_props$required = props.required,
|
7012
7195
|
required = _props$required === void 0 ? false : _props$required,
|
7013
|
-
_props$
|
7014
|
-
|
7015
|
-
|
7016
|
-
_props$
|
7017
|
-
|
7018
|
-
_props$
|
7019
|
-
allowDuplicates = _props$allowDuplicate === void 0 ? true : _props$allowDuplicate,
|
7020
|
-
validateToken = props.validateToken,
|
7021
|
-
_props$tokenSeparator = props.tokenSeparators,
|
7022
|
-
tokenSeparators = _props$tokenSeparator === void 0 ? [',', ';', '\n'] : _props$tokenSeparator,
|
7023
|
-
_props$size = props.size,
|
7024
|
-
size = _props$size === void 0 ? 'medium' : _props$size,
|
7025
|
-
_props$variant = props.variant,
|
7026
|
-
variant = _props$variant === void 0 ? 'default' : _props$variant,
|
7196
|
+
_props$canClear = props.canClear,
|
7197
|
+
canClear = _props$canClear === void 0 ? true : _props$canClear,
|
7198
|
+
_props$showPasswordTo = props.showPasswordToggle,
|
7199
|
+
showPasswordToggle = _props$showPasswordTo === void 0 ? true : _props$showPasswordTo,
|
7200
|
+
_props$autoComplete = props.autoComplete,
|
7201
|
+
autoComplete = _props$autoComplete === void 0 ? 'off' : _props$autoComplete,
|
7027
7202
|
error = props.error,
|
7028
7203
|
helperText = props.helperText,
|
7204
|
+
maxLength = props.maxLength,
|
7205
|
+
minLength = props.minLength,
|
7206
|
+
pattern = props.pattern,
|
7207
|
+
step = props.step,
|
7208
|
+
min = props.min,
|
7209
|
+
max = props.max,
|
7210
|
+
_props$rows = props.rows,
|
7211
|
+
rows = _props$rows === void 0 ? 3 : _props$rows,
|
7212
|
+
validation = props.validation,
|
7213
|
+
_props$debounceMs = props.debounceMs,
|
7214
|
+
debounceMs = _props$debounceMs === void 0 ? 0 : _props$debounceMs,
|
7215
|
+
ariaLabel = props.ariaLabel,
|
7216
|
+
ariaDescribedBy = props.ariaDescribedBy,
|
7217
|
+
onChange = props.onChange,
|
7218
|
+
onEnter = props.onEnter,
|
7219
|
+
onClick = props.onClick,
|
7029
7220
|
onFocus = props.onFocus,
|
7030
7221
|
onBlur = props.onBlur,
|
7031
|
-
|
7032
|
-
|
7033
|
-
|
7034
|
-
|
7035
|
-
|
7036
|
-
|
7037
|
-
_props$searchable = props.searchable,
|
7038
|
-
searchable = _props$searchable === void 0 ? false : _props$searchable,
|
7039
|
-
_props$sortable = props.sortable,
|
7040
|
-
sortable = _props$sortable === void 0 ? false : _props$sortable,
|
7041
|
-
className = props.className,
|
7042
|
-
style = props.style,
|
7043
|
-
restProps = _objectWithoutPropertiesLoose(props, _excluded$5);
|
7044
|
-
var _useState = React.useState(''),
|
7045
|
-
value = _useState[0],
|
7046
|
-
setValue = _useState[1];
|
7222
|
+
onValidation = props.onValidation,
|
7223
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded$7);
|
7224
|
+
var site = React.useContext(SiteContext);
|
7225
|
+
var _useState = React.useState(false),
|
7226
|
+
isPasswordVisible = _useState[0],
|
7227
|
+
setIsPasswordVisible = _useState[1];
|
7047
7228
|
var _useState2 = React.useState(false),
|
7048
7229
|
isFocused = _useState2[0],
|
7049
7230
|
setIsFocused = _useState2[1];
|
7050
|
-
var _useState3 = React.useState(
|
7051
|
-
|
7052
|
-
|
7231
|
+
var _useState3 = React.useState(''),
|
7232
|
+
internalError = _useState3[0],
|
7233
|
+
setInternalError = _useState3[1];
|
7234
|
+
var _useState4 = React.useState(true),
|
7235
|
+
isValid = _useState4[0],
|
7236
|
+
setIsValid = _useState4[1];
|
7053
7237
|
var inputRef = React.useRef(null);
|
7054
|
-
var
|
7238
|
+
var debounceRef = React.useRef(null);
|
7055
7239
|
|
7056
|
-
// Validate props
|
7057
|
-
|
7058
|
-
|
7059
|
-
|
7060
|
-
}
|
7061
|
-
if (maxTokens && tokens.length > maxTokens) {
|
7062
|
-
console.warn("TokenField: tokens count (" + tokens.length + ") exceeds maxTokens (" + maxTokens + ")");
|
7063
|
-
}
|
7064
|
-
if (minTokens && tokens.length < minTokens) {
|
7065
|
-
console.warn("TokenField: tokens count (" + tokens.length + ") is below minTokens (" + minTokens + ")");
|
7066
|
-
}
|
7067
|
-
}, [tokens, maxTokens, minTokens]);
|
7068
|
-
|
7069
|
-
// Enhanced remove function (maintaining original behavior)
|
7070
|
-
var remove = React.useCallback(function (index) {
|
7071
|
-
if (disabled || readOnly) return;
|
7072
|
-
var next = tokens.slice();
|
7073
|
-
var removedToken = next.splice(index, 1)[0];
|
7240
|
+
// Validate required props
|
7241
|
+
if (!id) {
|
7242
|
+
console.warn('TextField2 component: id prop is required');
|
7243
|
+
}
|
7074
7244
|
|
7075
|
-
|
7076
|
-
|
7077
|
-
|
7078
|
-
|
7245
|
+
// Validate value and set error states
|
7246
|
+
React.useEffect(function () {
|
7247
|
+
if (validation && value !== undefined) {
|
7248
|
+
var validationResult = validation(value);
|
7249
|
+
var valid = typeof validationResult === 'boolean' ? validationResult : validationResult.valid;
|
7250
|
+
var errorMessage = typeof validationResult === 'object' ? validationResult.message : '';
|
7251
|
+
setIsValid(valid);
|
7252
|
+
setInternalError(valid ? '' : errorMessage || (required && !value ? 'This field is required' : 'Invalid value'));
|
7253
|
+
if (onValidation) {
|
7254
|
+
onValidation(id, valid, errorMessage);
|
7255
|
+
}
|
7256
|
+
} else if (required && !value) {
|
7257
|
+
setIsValid(false);
|
7258
|
+
setInternalError('This field is required');
|
7259
|
+
} else {
|
7260
|
+
setIsValid(true);
|
7261
|
+
setInternalError('');
|
7079
7262
|
}
|
7080
|
-
|
7081
|
-
if (onTokenRemove) onTokenRemove(removedToken, index);
|
7082
|
-
}, [disabled, readOnly, tokens, minTokens, id, onChange, onTokenRemove]);
|
7263
|
+
}, [value, required, id]); // Removed validation and onValidation from dependencies to prevent infinite loops
|
7083
7264
|
|
7084
|
-
//
|
7085
|
-
var
|
7265
|
+
// Handle input changes with debouncing
|
7266
|
+
var handleChange = React.useCallback(function (event) {
|
7086
7267
|
if (disabled || readOnly) return;
|
7268
|
+
event.stopPropagation();
|
7087
7269
|
var newValue = event.target.value;
|
7088
|
-
setValue(newValue);
|
7089
|
-
}, [disabled, readOnly]);
|
7090
7270
|
|
7091
|
-
|
7092
|
-
|
7093
|
-
|
7094
|
-
return {
|
7095
|
-
isValid: false,
|
7096
|
-
error: 'Token cannot be empty'
|
7097
|
-
};
|
7271
|
+
// Clear previous debounce
|
7272
|
+
if (debounceRef.current) {
|
7273
|
+
clearTimeout(debounceRef.current);
|
7098
7274
|
}
|
7099
|
-
|
7100
|
-
|
7101
|
-
|
7102
|
-
|
7103
|
-
|
7104
|
-
|
7105
|
-
};
|
7275
|
+
if (debounceMs > 0) {
|
7276
|
+
debounceRef.current = setTimeout(function () {
|
7277
|
+
if (onChange) onChange(id, newValue, event);
|
7278
|
+
}, debounceMs);
|
7279
|
+
} else {
|
7280
|
+
if (onChange) onChange(id, newValue, event);
|
7106
7281
|
}
|
7282
|
+
}, [disabled, readOnly, id, onChange, debounceMs]);
|
7107
7283
|
|
7108
|
-
|
7109
|
-
|
7110
|
-
|
7111
|
-
|
7112
|
-
|
7113
|
-
|
7284
|
+
// Handle key press events
|
7285
|
+
var handleKeyPress = React.useCallback(function (event) {
|
7286
|
+
if (disabled) return;
|
7287
|
+
var key = event.charCode || event.keyCode || 0;
|
7288
|
+
if (key === 13 && onEnter) {
|
7289
|
+
event.preventDefault();
|
7290
|
+
onEnter(event);
|
7114
7291
|
}
|
7292
|
+
}, [disabled, onEnter]);
|
7115
7293
|
|
7116
|
-
|
7117
|
-
|
7118
|
-
|
7119
|
-
|
7120
|
-
|
7121
|
-
|
7294
|
+
// Handle focus events
|
7295
|
+
var handleFocus = React.useCallback(function (event) {
|
7296
|
+
if (disabled) return;
|
7297
|
+
setIsFocused(true);
|
7298
|
+
if (onFocus) onFocus(event);
|
7299
|
+
|
7300
|
+
// Site context focus management
|
7301
|
+
if (site && site.changeFocus) {
|
7302
|
+
site.changeFocus({
|
7303
|
+
lose: function lose() {
|
7304
|
+
return setIsFocused(false);
|
7305
|
+
}
|
7306
|
+
});
|
7122
7307
|
}
|
7123
|
-
|
7124
|
-
|
7125
|
-
|
7126
|
-
|
7308
|
+
}, [disabled, onFocus, site]);
|
7309
|
+
|
7310
|
+
// Handle blur events
|
7311
|
+
var handleBlur = React.useCallback(function (event) {
|
7312
|
+
if (disabled) return;
|
7313
|
+
setIsFocused(false);
|
7314
|
+
if (onBlur) onBlur(event);
|
7315
|
+
}, [disabled, onBlur]);
|
7316
|
+
|
7317
|
+
// Handle clear action
|
7318
|
+
var handleClear = React.useCallback(function () {
|
7319
|
+
if (disabled || readOnly) return;
|
7320
|
+
if (onChange) onChange(id, '', {
|
7321
|
+
target: {
|
7322
|
+
value: ''
|
7323
|
+
}
|
7324
|
+
});
|
7325
|
+
if (inputRef.current) {
|
7326
|
+
inputRef.current.focus();
|
7327
|
+
}
|
7328
|
+
}, [disabled, readOnly, id, onChange]);
|
7329
|
+
|
7330
|
+
// Handle password visibility toggle
|
7331
|
+
var handlePasswordToggle = React.useCallback(function () {
|
7332
|
+
if (disabled) return;
|
7333
|
+
setIsPasswordVisible(!isPasswordVisible);
|
7334
|
+
}, [disabled, isPasswordVisible]);
|
7335
|
+
|
7336
|
+
// Generate CSS classes
|
7337
|
+
var borderStyle = outlined ? 'textfield2-outlined' : 'textfield2';
|
7338
|
+
var labelStyle = label ? '' : 'no-label';
|
7339
|
+
var labelPositionStyle = labelPosition === 'left' ? 'label-left' : 'label-top';
|
7340
|
+
var safeClassName = className || '';
|
7341
|
+
var cssClasses = ['textfield2', borderStyle, labelStyle, labelPositionStyle, "textfield2-" + type, isFocused && 'focused', disabled && 'disabled', readOnly && 'readonly', error || internalError ? 'error' : '', !isValid && 'invalid', placeholder && 'has-placeholder', safeClassName, id].filter(Boolean).join(' ');
|
7342
|
+
|
7343
|
+
// Accessibility attributes
|
7344
|
+
var ariaAttributes = {
|
7345
|
+
'aria-label': ariaLabel || label,
|
7346
|
+
'aria-describedby': ariaDescribedBy || (error || internalError || helperText ? id + "-helper" : undefined),
|
7347
|
+
'aria-invalid': !isValid || !!(error || internalError),
|
7348
|
+
'aria-required': required,
|
7349
|
+
'aria-disabled': disabled,
|
7350
|
+
'aria-readonly': readOnly
|
7351
|
+
};
|
7352
|
+
|
7353
|
+
// Input attributes
|
7354
|
+
var inputAttributes = _extends({
|
7355
|
+
id: id,
|
7356
|
+
type: type === 'password' && isPasswordVisible ? 'text' : type,
|
7357
|
+
placeholder: site != null && site.translate ? site.translate(placeholder) : placeholder,
|
7358
|
+
value: value || '',
|
7359
|
+
required: required,
|
7360
|
+
disabled: disabled,
|
7361
|
+
readOnly: readOnly,
|
7362
|
+
maxLength: maxLength,
|
7363
|
+
minLength: minLength,
|
7364
|
+
pattern: pattern,
|
7365
|
+
step: step,
|
7366
|
+
min: min,
|
7367
|
+
max: max,
|
7368
|
+
autoComplete: autoComplete
|
7369
|
+
}, ariaAttributes, restProps);
|
7370
|
+
|
7371
|
+
// Label text
|
7372
|
+
var labelTxt = label ? /*#__PURE__*/React__default["default"].createElement(Text, null, label) : null;
|
7373
|
+
var placeholderTxt = site != null && site.translate ? site.translate(placeholder) : placeholder;
|
7374
|
+
|
7375
|
+
// Error/helper text
|
7376
|
+
var displayError = error || internalError;
|
7377
|
+
var displayHelperText = helperText && !displayError;
|
7378
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
7379
|
+
className: cssClasses,
|
7380
|
+
onClick: onClick
|
7381
|
+
}, type === 'textarea' ? /*#__PURE__*/React__default["default"].createElement("textarea", _extends({
|
7382
|
+
ref: inputRef,
|
7383
|
+
rows: rows,
|
7384
|
+
placeholder: placeholderTxt,
|
7385
|
+
onChange: handleChange,
|
7386
|
+
onKeyDown: handleKeyPress,
|
7387
|
+
onFocus: handleFocus,
|
7388
|
+
onBlur: handleBlur
|
7389
|
+
}, inputAttributes)) : /*#__PURE__*/React__default["default"].createElement("input", _extends({
|
7390
|
+
ref: inputRef,
|
7391
|
+
onChange: handleChange,
|
7392
|
+
onKeyDown: handleKeyPress,
|
7393
|
+
onFocus: handleFocus,
|
7394
|
+
onBlur: handleBlur
|
7395
|
+
}, inputAttributes)), !readOnly && !disabled && canClear && value && value.length > 0 && /*#__PURE__*/React__default["default"].createElement(Icon, {
|
7396
|
+
icon: "close",
|
7397
|
+
clickable: true,
|
7398
|
+
size: "small",
|
7399
|
+
action: handleClear,
|
7400
|
+
className: "textfield2-clear",
|
7401
|
+
ariaLabel: "Clear field"
|
7402
|
+
}), type === 'password' && showPasswordToggle && !disabled && /*#__PURE__*/React__default["default"].createElement(Icon, {
|
7403
|
+
icon: isPasswordVisible ? 'visibility' : 'visibility_off',
|
7404
|
+
clickable: true,
|
7405
|
+
size: "small",
|
7406
|
+
action: handlePasswordToggle,
|
7407
|
+
className: "textfield2-password-toggle",
|
7408
|
+
ariaLabel: isPasswordVisible ? 'Hide password' : 'Show password'
|
7409
|
+
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
7410
|
+
className: "textfield2-bar"
|
7411
|
+
}), label && /*#__PURE__*/React__default["default"].createElement("label", {
|
7412
|
+
htmlFor: id
|
7413
|
+
}, labelTxt), (displayError || displayHelperText) && /*#__PURE__*/React__default["default"].createElement("div", {
|
7414
|
+
id: id + "-helper",
|
7415
|
+
className: "textfield2-helper " + (displayError ? 'error' : 'helper'),
|
7416
|
+
role: displayError ? 'alert' : 'status',
|
7417
|
+
"aria-live": displayError ? 'assertive' : 'polite'
|
7418
|
+
}, displayError && /*#__PURE__*/React__default["default"].createElement(Icon, {
|
7419
|
+
icon: "error",
|
7420
|
+
size: "small"
|
7421
|
+
}), /*#__PURE__*/React__default["default"].createElement(Text, null, displayError || helperText)));
|
7422
|
+
};
|
7423
|
+
|
7424
|
+
/**
|
7425
|
+
* Enhanced TextArea component
|
7426
|
+
*/
|
7427
|
+
var TextArea2 = function TextArea2(props) {
|
7428
|
+
return /*#__PURE__*/React__default["default"].createElement(TextField2, _extends({}, props, {
|
7429
|
+
type: "textarea"
|
7430
|
+
}));
|
7431
|
+
};
|
7432
|
+
|
7433
|
+
/**
|
7434
|
+
* Enhanced PasswordField component
|
7435
|
+
*/
|
7436
|
+
var PasswordField2 = function PasswordField2(props) {
|
7437
|
+
return /*#__PURE__*/React__default["default"].createElement(TextField2, _extends({}, props, {
|
7438
|
+
type: "password"
|
7439
|
+
}));
|
7440
|
+
};
|
7441
|
+
|
7442
|
+
// PropTypes for TextField2
|
7443
|
+
TextField2.propTypes = {
|
7444
|
+
/** Unique identifier for the field */
|
7445
|
+
id: PropTypes.string.isRequired,
|
7446
|
+
/** Input type */
|
7447
|
+
type: PropTypes.oneOf(['text', 'email', 'password', 'number', 'tel', 'url', 'search', 'date', 'time', 'datetime-local', 'month', 'week', 'textarea']),
|
7448
|
+
/** Additional CSS classes */
|
7449
|
+
className: PropTypes.string,
|
7450
|
+
/** Field label */
|
7451
|
+
label: PropTypes.string,
|
7452
|
+
/** Label position */
|
7453
|
+
labelPosition: PropTypes.oneOf(['top', 'left']),
|
7454
|
+
/** Placeholder text */
|
7455
|
+
placeholder: PropTypes.string,
|
7456
|
+
/** Field value */
|
7457
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
7458
|
+
/** Whether field has outlined style */
|
7459
|
+
outlined: PropTypes.bool,
|
7460
|
+
/** Whether field is read-only */
|
7461
|
+
readOnly: PropTypes.bool,
|
7462
|
+
/** Whether field is disabled */
|
7463
|
+
disabled: PropTypes.bool,
|
7464
|
+
/** Whether field is required */
|
7465
|
+
required: PropTypes.bool,
|
7466
|
+
/** Whether to show clear button */
|
7467
|
+
canClear: PropTypes.bool,
|
7468
|
+
/** Whether to show password toggle for password fields */
|
7469
|
+
showPasswordToggle: PropTypes.bool,
|
7470
|
+
/** HTML autocomplete attribute */
|
7471
|
+
autoComplete: PropTypes.string,
|
7472
|
+
/** Error message to display */
|
7473
|
+
error: PropTypes.string,
|
7474
|
+
/** Helper text to display */
|
7475
|
+
helperText: PropTypes.string,
|
7476
|
+
/** Maximum length */
|
7477
|
+
maxLength: PropTypes.number,
|
7478
|
+
/** Minimum length */
|
7479
|
+
minLength: PropTypes.number,
|
7480
|
+
/** Input pattern */
|
7481
|
+
pattern: PropTypes.string,
|
7482
|
+
/** Step for number inputs */
|
7483
|
+
step: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
7484
|
+
/** Minimum value for number inputs */
|
7485
|
+
min: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
7486
|
+
/** Maximum value for number inputs */
|
7487
|
+
max: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
7488
|
+
/** Number of rows for textarea */
|
7489
|
+
rows: PropTypes.number,
|
7490
|
+
/** Validation function */
|
7491
|
+
validation: PropTypes.func,
|
7492
|
+
/** Debounce delay in milliseconds */
|
7493
|
+
debounceMs: PropTypes.number,
|
7494
|
+
/** ARIA label */
|
7495
|
+
ariaLabel: PropTypes.string,
|
7496
|
+
/** ARIA described by */
|
7497
|
+
ariaDescribedBy: PropTypes.string,
|
7498
|
+
/** Change handler */
|
7499
|
+
onChange: PropTypes.func,
|
7500
|
+
/** Enter key handler */
|
7501
|
+
onEnter: PropTypes.func,
|
7502
|
+
/** Click handler */
|
7503
|
+
onClick: PropTypes.func,
|
7504
|
+
/** Focus handler */
|
7505
|
+
onFocus: PropTypes.func,
|
7506
|
+
/** Blur handler */
|
7507
|
+
onBlur: PropTypes.func,
|
7508
|
+
/** Validation handler */
|
7509
|
+
onValidation: PropTypes.func
|
7510
|
+
};
|
7511
|
+
TextField2.defaultProps = {
|
7512
|
+
type: 'text',
|
7513
|
+
labelPosition: 'top',
|
7514
|
+
outlined: false,
|
7515
|
+
readOnly: false,
|
7516
|
+
disabled: false,
|
7517
|
+
required: false,
|
7518
|
+
canClear: true,
|
7519
|
+
showPasswordToggle: true,
|
7520
|
+
autoComplete: 'off',
|
7521
|
+
rows: 3,
|
7522
|
+
debounceMs: 0,
|
7523
|
+
className: ''
|
7524
|
+
};
|
7525
|
+
|
7526
|
+
// PropTypes for TextArea2
|
7527
|
+
TextArea2.propTypes = _extends({}, TextField2.propTypes);
|
7528
|
+
TextArea2.defaultProps = _extends({}, TextField2.defaultProps, {
|
7529
|
+
type: 'textarea'
|
7530
|
+
});
|
7531
|
+
|
7532
|
+
// PropTypes for PasswordField2
|
7533
|
+
PasswordField2.propTypes = _extends({}, TextField2.propTypes);
|
7534
|
+
PasswordField2.defaultProps = _extends({}, TextField2.defaultProps, {
|
7535
|
+
type: 'password'
|
7536
|
+
});
|
7537
|
+
|
7538
|
+
/**
|
7539
|
+
* Enhanced DropDown component with improved accessibility and functionality
|
7540
|
+
*/
|
7541
|
+
var DropDown2 = function DropDown2(props) {
|
7542
|
+
var id = props.id,
|
7543
|
+
_props$options = props.options,
|
7544
|
+
options = _props$options === void 0 ? [] : _props$options,
|
7545
|
+
value = props.value,
|
7546
|
+
placeholder = props.placeholder,
|
7547
|
+
label = props.label,
|
7548
|
+
_props$outlined2 = props.outlined,
|
7549
|
+
outlined = _props$outlined2 === void 0 ? false : _props$outlined2,
|
7550
|
+
_props$disabled2 = props.disabled,
|
7551
|
+
disabled = _props$disabled2 === void 0 ? false : _props$disabled2,
|
7552
|
+
_props$readOnly2 = props.readOnly,
|
7553
|
+
readOnly = _props$readOnly2 === void 0 ? false : _props$readOnly2,
|
7554
|
+
_props$required2 = props.required,
|
7555
|
+
required = _props$required2 === void 0 ? false : _props$required2,
|
7556
|
+
_props$searchable = props.searchable,
|
7557
|
+
searchable = _props$searchable === void 0 ? false : _props$searchable,
|
7558
|
+
_props$clearable = props.clearable,
|
7559
|
+
clearable = _props$clearable === void 0 ? false : _props$clearable,
|
7560
|
+
_props$multiple = props.multiple,
|
7561
|
+
multiple = _props$multiple === void 0 ? false : _props$multiple,
|
7562
|
+
groupBy = props.groupBy,
|
7563
|
+
filterFunction = props.filterFunction,
|
7564
|
+
renderOption = props.renderOption,
|
7565
|
+
renderValue = props.renderValue,
|
7566
|
+
_props$position = props.position,
|
7567
|
+
position = _props$position === void 0 ? 'bottom' : _props$position,
|
7568
|
+
_props$maxHeight = props.maxHeight,
|
7569
|
+
maxHeight = _props$maxHeight === void 0 ? '200px' : _props$maxHeight,
|
7570
|
+
error = props.error,
|
7571
|
+
helperText = props.helperText,
|
7572
|
+
className = props.className,
|
7573
|
+
ariaLabel = props.ariaLabel,
|
7574
|
+
onChange = props.onChange,
|
7575
|
+
onOpen = props.onOpen,
|
7576
|
+
onClose = props.onClose,
|
7577
|
+
onSearch = props.onSearch,
|
7578
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded2$3);
|
7579
|
+
React.useContext(SiteContext);
|
7580
|
+
var _useState5 = React.useState(false),
|
7581
|
+
isOpen = _useState5[0],
|
7582
|
+
setIsOpen = _useState5[1];
|
7583
|
+
var _useState6 = React.useState(''),
|
7584
|
+
searchTerm = _useState6[0],
|
7585
|
+
setSearchTerm = _useState6[1];
|
7586
|
+
var _useState7 = React.useState(-1),
|
7587
|
+
focusedIndex = _useState7[0],
|
7588
|
+
setFocusedIndex = _useState7[1];
|
7589
|
+
var _useState8 = React.useState(''),
|
7590
|
+
internalError = _useState8[0],
|
7591
|
+
setInternalError = _useState8[1];
|
7592
|
+
var dropdownRef = React.useRef(null);
|
7593
|
+
var inputRef = React.useRef(null);
|
7594
|
+
var listRef = React.useRef(null);
|
7595
|
+
|
7596
|
+
// Validate required props
|
7597
|
+
if (!id) {
|
7598
|
+
console.warn('DropDown2 component: id prop is required');
|
7599
|
+
}
|
7600
|
+
if (!Array.isArray(options)) {
|
7601
|
+
console.warn('DropDown2 component: options must be an array');
|
7602
|
+
}
|
7603
|
+
|
7604
|
+
// Validate required field
|
7605
|
+
React.useEffect(function () {
|
7606
|
+
if (required && (!value || Array.isArray(value) && value.length === 0)) {
|
7607
|
+
setInternalError('This field is required');
|
7608
|
+
} else {
|
7609
|
+
setInternalError('');
|
7610
|
+
}
|
7611
|
+
}, [value, required]);
|
7612
|
+
|
7613
|
+
// Get display value
|
7614
|
+
var getDisplayValue = React.useCallback(function () {
|
7615
|
+
if (!value) return '';
|
7616
|
+
if (multiple && Array.isArray(value)) {
|
7617
|
+
if (value.length === 0) return '';
|
7618
|
+
if (value.length === 1) {
|
7619
|
+
var _option = options.find(function (opt) {
|
7620
|
+
return opt.value === value[0];
|
7621
|
+
});
|
7622
|
+
return _option ? _option.label : value[0];
|
7623
|
+
}
|
7624
|
+
return value.length + " items selected";
|
7625
|
+
}
|
7626
|
+
var option = options.find(function (opt) {
|
7627
|
+
return opt.value === value;
|
7628
|
+
});
|
7629
|
+
if (renderValue && option) {
|
7630
|
+
return renderValue(option);
|
7631
|
+
}
|
7632
|
+
return option ? option.label : value;
|
7633
|
+
}, [value, options, multiple, renderValue]);
|
7634
|
+
|
7635
|
+
// Filter options based on search term
|
7636
|
+
var filteredOptions = React.useMemo(function () {
|
7637
|
+
if (!searchTerm || !searchable) return options;
|
7638
|
+
if (filterFunction) {
|
7639
|
+
return options.filter(function (option) {
|
7640
|
+
return filterFunction(option, searchTerm);
|
7641
|
+
});
|
7642
|
+
}
|
7643
|
+
return options.filter(function (option) {
|
7644
|
+
return option.label.toLowerCase().includes(searchTerm.toLowerCase());
|
7645
|
+
});
|
7646
|
+
}, [options, searchTerm, searchable, filterFunction]);
|
7647
|
+
|
7648
|
+
// Group options if groupBy is provided
|
7649
|
+
var groupedOptions = React.useMemo(function () {
|
7650
|
+
if (!groupBy) return [{
|
7651
|
+
options: filteredOptions
|
7652
|
+
}];
|
7653
|
+
var groups = filteredOptions.reduce(function (acc, option) {
|
7654
|
+
var groupKey = typeof groupBy === 'function' ? groupBy(option) : option[groupBy];
|
7655
|
+
if (!acc[groupKey]) {
|
7656
|
+
acc[groupKey] = [];
|
7657
|
+
}
|
7658
|
+
acc[groupKey].push(option);
|
7659
|
+
return acc;
|
7660
|
+
}, {});
|
7661
|
+
return Object.entries(groups).map(function (_ref) {
|
7662
|
+
var label = _ref[0],
|
7663
|
+
options = _ref[1];
|
7664
|
+
return {
|
7665
|
+
label: label,
|
7666
|
+
options: options
|
7667
|
+
};
|
7668
|
+
});
|
7669
|
+
}, [filteredOptions, groupBy]);
|
7670
|
+
|
7671
|
+
// Handle option selection
|
7672
|
+
var handleSelect = React.useCallback(function (selectedValue, option) {
|
7673
|
+
if (disabled || readOnly) return;
|
7674
|
+
var newValue;
|
7675
|
+
if (multiple) {
|
7676
|
+
var currentValues = Array.isArray(value) ? value : [];
|
7677
|
+
if (currentValues.includes(selectedValue)) {
|
7678
|
+
newValue = currentValues.filter(function (v) {
|
7679
|
+
return v !== selectedValue;
|
7680
|
+
});
|
7681
|
+
} else {
|
7682
|
+
newValue = [].concat(currentValues, [selectedValue]);
|
7683
|
+
}
|
7684
|
+
} else {
|
7685
|
+
newValue = selectedValue;
|
7686
|
+
setIsOpen(false);
|
7687
|
+
}
|
7688
|
+
if (onChange) {
|
7689
|
+
onChange(id, newValue, option);
|
7690
|
+
}
|
7691
|
+
if (!multiple) {
|
7692
|
+
setSearchTerm('');
|
7693
|
+
setFocusedIndex(-1);
|
7694
|
+
}
|
7695
|
+
}, [disabled, readOnly, multiple, value, id, onChange]);
|
7696
|
+
|
7697
|
+
// Handle dropdown open/close
|
7698
|
+
var handleToggle = React.useCallback(function () {
|
7699
|
+
if (disabled || readOnly) return;
|
7700
|
+
var newOpen = !isOpen;
|
7701
|
+
setIsOpen(newOpen);
|
7702
|
+
if (newOpen) {
|
7703
|
+
setFocusedIndex(-1);
|
7704
|
+
if (onOpen) onOpen();
|
7705
|
+
} else {
|
7706
|
+
setSearchTerm('');
|
7707
|
+
setFocusedIndex(-1);
|
7708
|
+
if (onClose) onClose();
|
7709
|
+
}
|
7710
|
+
}, [disabled, readOnly, isOpen, onOpen, onClose]);
|
7711
|
+
|
7712
|
+
// Handle search input
|
7713
|
+
var handleSearch = React.useCallback(function (event) {
|
7714
|
+
if (!searchable) return;
|
7715
|
+
var term = event.target.value;
|
7716
|
+
setSearchTerm(term);
|
7717
|
+
setFocusedIndex(-1);
|
7718
|
+
if (!isOpen) {
|
7719
|
+
setIsOpen(true);
|
7720
|
+
}
|
7721
|
+
if (onSearch) {
|
7722
|
+
onSearch(term);
|
7723
|
+
}
|
7724
|
+
}, [searchable, isOpen, onSearch]);
|
7725
|
+
|
7726
|
+
// Handle clear
|
7727
|
+
var handleClear = React.useCallback(function (event) {
|
7728
|
+
event.stopPropagation();
|
7729
|
+
if (disabled || readOnly) return;
|
7730
|
+
var newValue = multiple ? [] : '';
|
7731
|
+
if (onChange) {
|
7732
|
+
onChange(id, newValue);
|
7733
|
+
}
|
7734
|
+
setSearchTerm('');
|
7735
|
+
}, [disabled, readOnly, multiple, id, onChange]);
|
7736
|
+
|
7737
|
+
// Keyboard navigation
|
7738
|
+
var handleKeyDown = React.useCallback(function (event) {
|
7739
|
+
if (disabled) return;
|
7740
|
+
var flatOptions = groupedOptions.flatMap(function (group) {
|
7741
|
+
return group.options;
|
7742
|
+
});
|
7743
|
+
switch (event.key) {
|
7744
|
+
case 'ArrowDown':
|
7745
|
+
event.preventDefault();
|
7746
|
+
if (!isOpen) {
|
7747
|
+
setIsOpen(true);
|
7748
|
+
} else {
|
7749
|
+
setFocusedIndex(function (prev) {
|
7750
|
+
return prev < flatOptions.length - 1 ? prev + 1 : 0;
|
7751
|
+
});
|
7752
|
+
}
|
7753
|
+
break;
|
7754
|
+
case 'ArrowUp':
|
7755
|
+
event.preventDefault();
|
7756
|
+
if (isOpen) {
|
7757
|
+
setFocusedIndex(function (prev) {
|
7758
|
+
return prev > 0 ? prev - 1 : flatOptions.length - 1;
|
7759
|
+
});
|
7760
|
+
}
|
7761
|
+
break;
|
7762
|
+
case 'Enter':
|
7763
|
+
event.preventDefault();
|
7764
|
+
if (isOpen && focusedIndex >= 0) {
|
7765
|
+
var option = flatOptions[focusedIndex];
|
7766
|
+
if (option) {
|
7767
|
+
handleSelect(option.value, option);
|
7768
|
+
}
|
7769
|
+
} else {
|
7770
|
+
handleToggle();
|
7771
|
+
}
|
7772
|
+
break;
|
7773
|
+
case 'Escape':
|
7774
|
+
if (isOpen) {
|
7775
|
+
event.preventDefault();
|
7776
|
+
setIsOpen(false);
|
7777
|
+
setSearchTerm('');
|
7778
|
+
setFocusedIndex(-1);
|
7779
|
+
}
|
7780
|
+
break;
|
7781
|
+
case 'Tab':
|
7782
|
+
if (isOpen) {
|
7783
|
+
setIsOpen(false);
|
7784
|
+
setSearchTerm('');
|
7785
|
+
setFocusedIndex(-1);
|
7786
|
+
}
|
7787
|
+
break;
|
7788
|
+
}
|
7789
|
+
}, [disabled, isOpen, focusedIndex, groupedOptions, handleSelect, handleToggle]);
|
7790
|
+
|
7791
|
+
// Click outside to close
|
7792
|
+
React.useEffect(function () {
|
7793
|
+
var handleClickOutside = function handleClickOutside(event) {
|
7794
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
7795
|
+
setIsOpen(false);
|
7796
|
+
setSearchTerm('');
|
7797
|
+
setFocusedIndex(-1);
|
7798
|
+
}
|
7799
|
+
};
|
7800
|
+
if (isOpen) {
|
7801
|
+
document.addEventListener('mousedown', handleClickOutside);
|
7802
|
+
return function () {
|
7803
|
+
return document.removeEventListener('mousedown', handleClickOutside);
|
7804
|
+
};
|
7805
|
+
}
|
7806
|
+
}, [isOpen]);
|
7807
|
+
|
7808
|
+
// Generate CSS classes
|
7809
|
+
var safeClassName = className || '';
|
7810
|
+
var cssClasses = ['dropdown2', outlined && 'outlined', disabled && 'disabled', readOnly && 'readonly', isOpen && 'open', error || internalError ? 'error' : '', multiple && 'multiple', safeClassName].filter(Boolean).join(' ');
|
7811
|
+
|
7812
|
+
// Accessibility attributes
|
7813
|
+
var ariaAttributes = {
|
7814
|
+
'aria-label': ariaLabel || label,
|
7815
|
+
'aria-expanded': isOpen,
|
7816
|
+
'aria-haspopup': 'listbox',
|
7817
|
+
'aria-disabled': disabled,
|
7818
|
+
'aria-readonly': readOnly,
|
7819
|
+
'aria-required': required,
|
7820
|
+
'aria-invalid': !!(error || internalError),
|
7821
|
+
'aria-describedby': error || internalError || helperText ? id + "-helper" : undefined
|
7822
|
+
};
|
7823
|
+
var displayValue = getDisplayValue();
|
7824
|
+
var displayError = error || internalError;
|
7825
|
+
var displayHelperText = helperText && !displayError;
|
7826
|
+
var showClear = clearable && displayValue && !disabled && !readOnly;
|
7827
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _extends({
|
7828
|
+
ref: dropdownRef,
|
7829
|
+
className: cssClasses
|
7830
|
+
}, restProps), /*#__PURE__*/React__default["default"].createElement("div", _extends({
|
7831
|
+
className: "dropdown2-control",
|
7832
|
+
onClick: handleToggle,
|
7833
|
+
onKeyDown: handleKeyDown,
|
7834
|
+
tabIndex: disabled ? -1 : 0
|
7835
|
+
}, ariaAttributes), searchable && isOpen ? /*#__PURE__*/React__default["default"].createElement("input", {
|
7836
|
+
ref: inputRef,
|
7837
|
+
type: "text",
|
7838
|
+
value: searchTerm,
|
7839
|
+
placeholder: placeholder || 'Search...',
|
7840
|
+
onChange: handleSearch,
|
7841
|
+
onKeyDown: handleKeyDown,
|
7842
|
+
className: "dropdown2-search",
|
7843
|
+
disabled: disabled,
|
7844
|
+
autoFocus: true
|
7845
|
+
}) : /*#__PURE__*/React__default["default"].createElement("span", {
|
7846
|
+
className: "dropdown2-value " + (!displayValue ? 'placeholder' : '')
|
7847
|
+
}, displayValue || placeholder || 'Select...'), /*#__PURE__*/React__default["default"].createElement("div", {
|
7848
|
+
className: "dropdown2-indicators"
|
7849
|
+
}, showClear && /*#__PURE__*/React__default["default"].createElement(Icon, {
|
7850
|
+
icon: "close",
|
7851
|
+
size: "small",
|
7852
|
+
clickable: true,
|
7853
|
+
action: handleClear,
|
7854
|
+
className: "dropdown2-clear",
|
7855
|
+
ariaLabel: "Clear selection"
|
7856
|
+
}), /*#__PURE__*/React__default["default"].createElement(Icon, {
|
7857
|
+
icon: isOpen ? 'expand_less' : 'expand_more',
|
7858
|
+
size: "small",
|
7859
|
+
className: "dropdown2-arrow"
|
7860
|
+
}))), label && /*#__PURE__*/React__default["default"].createElement("label", {
|
7861
|
+
htmlFor: id,
|
7862
|
+
className: "dropdown2-label " + (isOpen || displayValue ? 'active' : '')
|
7863
|
+
}, /*#__PURE__*/React__default["default"].createElement(Text, null, label)), isOpen && /*#__PURE__*/React__default["default"].createElement("div", {
|
7864
|
+
className: "dropdown2-menu " + position,
|
7865
|
+
style: {
|
7866
|
+
maxHeight: maxHeight
|
7867
|
+
},
|
7868
|
+
role: "listbox",
|
7869
|
+
"aria-multiselectable": multiple
|
7870
|
+
}, /*#__PURE__*/React__default["default"].createElement("ul", {
|
7871
|
+
ref: listRef
|
7872
|
+
}, groupedOptions.map(function (group, groupIndex) {
|
7873
|
+
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, {
|
7874
|
+
key: groupIndex
|
7875
|
+
}, group.label && /*#__PURE__*/React__default["default"].createElement("li", {
|
7876
|
+
className: "dropdown2-group-label",
|
7877
|
+
role: "group"
|
7878
|
+
}, /*#__PURE__*/React__default["default"].createElement(Text, null, group.label)), group.options.map(function (option, optionIndex) {
|
7879
|
+
var flatIndex = groupedOptions.slice(0, groupIndex).reduce(function (acc, g) {
|
7880
|
+
return acc + g.options.length;
|
7881
|
+
}, 0) + optionIndex;
|
7882
|
+
var isSelected = multiple ? Array.isArray(value) && value.includes(option.value) : value === option.value;
|
7883
|
+
var isFocused = flatIndex === focusedIndex;
|
7884
|
+
return /*#__PURE__*/React__default["default"].createElement("li", {
|
7885
|
+
key: option.value,
|
7886
|
+
className: "dropdown2-option " + (isSelected ? 'selected' : '') + " " + (isFocused ? 'focused' : ''),
|
7887
|
+
onClick: function onClick() {
|
7888
|
+
return handleSelect(option.value, option);
|
7889
|
+
},
|
7890
|
+
role: "option",
|
7891
|
+
"aria-selected": isSelected
|
7892
|
+
}, multiple && /*#__PURE__*/React__default["default"].createElement(Icon, {
|
7893
|
+
icon: isSelected ? 'check_box' : 'check_box_outline_blank',
|
7894
|
+
size: "small",
|
7895
|
+
className: "dropdown2-checkbox"
|
7896
|
+
}), option.icon && /*#__PURE__*/React__default["default"].createElement(Icon, {
|
7897
|
+
icon: option.icon,
|
7898
|
+
size: "small",
|
7899
|
+
className: "dropdown2-option-icon"
|
7900
|
+
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
7901
|
+
className: "dropdown2-option-text"
|
7902
|
+
}, renderOption ? renderOption(option) : /*#__PURE__*/React__default["default"].createElement(Text, null, option.label)), isSelected && !multiple && /*#__PURE__*/React__default["default"].createElement(Icon, {
|
7903
|
+
icon: "check",
|
7904
|
+
size: "small",
|
7905
|
+
className: "dropdown2-check"
|
7906
|
+
}));
|
7907
|
+
}));
|
7908
|
+
}), filteredOptions.length === 0 && /*#__PURE__*/React__default["default"].createElement("li", {
|
7909
|
+
className: "dropdown2-no-options"
|
7910
|
+
}, /*#__PURE__*/React__default["default"].createElement(Text, null, "No options found")))), (displayError || displayHelperText) && /*#__PURE__*/React__default["default"].createElement("div", {
|
7911
|
+
id: id + "-helper",
|
7912
|
+
className: "dropdown2-helper " + (displayError ? 'error' : 'helper'),
|
7913
|
+
role: displayError ? 'alert' : 'status',
|
7914
|
+
"aria-live": displayError ? 'assertive' : 'polite'
|
7915
|
+
}, displayError && /*#__PURE__*/React__default["default"].createElement(Icon, {
|
7916
|
+
icon: "error",
|
7917
|
+
size: "small"
|
7918
|
+
}), /*#__PURE__*/React__default["default"].createElement(Text, null, displayError || helperText)));
|
7919
|
+
};
|
7920
|
+
|
7921
|
+
// PropTypes for DropDown2
|
7922
|
+
DropDown2.propTypes = {
|
7923
|
+
/** Unique identifier for the dropdown */
|
7924
|
+
id: PropTypes.string.isRequired,
|
7925
|
+
/** Array of option objects */
|
7926
|
+
options: PropTypes.arrayOf(PropTypes.shape({
|
7927
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
7928
|
+
label: PropTypes.string.isRequired,
|
7929
|
+
icon: PropTypes.string,
|
7930
|
+
disabled: PropTypes.bool
|
7931
|
+
})).isRequired,
|
7932
|
+
/** Selected value(s) */
|
7933
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))]),
|
7934
|
+
/** Placeholder text */
|
7935
|
+
placeholder: PropTypes.string,
|
7936
|
+
/** Field label */
|
7937
|
+
label: PropTypes.string,
|
7938
|
+
/** Whether dropdown has outlined style */
|
7939
|
+
outlined: PropTypes.bool,
|
7940
|
+
/** Whether dropdown is disabled */
|
7941
|
+
disabled: PropTypes.bool,
|
7942
|
+
/** Whether dropdown is read-only */
|
7943
|
+
readOnly: PropTypes.bool,
|
7944
|
+
/** Whether dropdown is required */
|
7945
|
+
required: PropTypes.bool,
|
7946
|
+
/** Whether dropdown is searchable */
|
7947
|
+
searchable: PropTypes.bool,
|
7948
|
+
/** Whether dropdown is clearable */
|
7949
|
+
clearable: PropTypes.bool,
|
7950
|
+
/** Whether multiple selection is allowed */
|
7951
|
+
multiple: PropTypes.bool,
|
7952
|
+
/** Function or property name to group options by */
|
7953
|
+
groupBy: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
7954
|
+
/** Custom filter function */
|
7955
|
+
filterFunction: PropTypes.func,
|
7956
|
+
/** Custom option renderer */
|
7957
|
+
renderOption: PropTypes.func,
|
7958
|
+
/** Custom value renderer */
|
7959
|
+
renderValue: PropTypes.func,
|
7960
|
+
/** Dropdown position */
|
7961
|
+
position: PropTypes.oneOf(['top', 'bottom']),
|
7962
|
+
/** Maximum height of dropdown menu */
|
7963
|
+
maxHeight: PropTypes.string,
|
7964
|
+
/** Error message */
|
7965
|
+
error: PropTypes.string,
|
7966
|
+
/** Helper text */
|
7967
|
+
helperText: PropTypes.string,
|
7968
|
+
/** Additional CSS classes */
|
7969
|
+
className: PropTypes.string,
|
7970
|
+
/** ARIA label */
|
7971
|
+
ariaLabel: PropTypes.string,
|
7972
|
+
/** Change handler */
|
7973
|
+
onChange: PropTypes.func,
|
7974
|
+
/** Open handler */
|
7975
|
+
onOpen: PropTypes.func,
|
7976
|
+
/** Close handler */
|
7977
|
+
onClose: PropTypes.func,
|
7978
|
+
/** Search handler */
|
7979
|
+
onSearch: PropTypes.func
|
7980
|
+
};
|
7981
|
+
DropDown2.defaultProps = {
|
7982
|
+
options: [],
|
7983
|
+
outlined: false,
|
7984
|
+
disabled: false,
|
7985
|
+
readOnly: false,
|
7986
|
+
required: false,
|
7987
|
+
searchable: false,
|
7988
|
+
clearable: false,
|
7989
|
+
multiple: false,
|
7990
|
+
position: 'bottom',
|
7991
|
+
maxHeight: '200px',
|
7992
|
+
className: ''
|
7993
|
+
};
|
7994
|
+
|
7995
|
+
/**
|
7996
|
+
* Enhanced DateRange component with improved validation and accessibility
|
7997
|
+
*/
|
7998
|
+
var DateRange2 = function DateRange2(props) {
|
7999
|
+
var id = props.id,
|
8000
|
+
label = props.label,
|
8001
|
+
value = props.value,
|
8002
|
+
_props$outlined3 = props.outlined,
|
8003
|
+
outlined = _props$outlined3 === void 0 ? false : _props$outlined3,
|
8004
|
+
_props$disabled3 = props.disabled,
|
8005
|
+
disabled = _props$disabled3 === void 0 ? false : _props$disabled3,
|
8006
|
+
_props$readOnly3 = props.readOnly,
|
8007
|
+
readOnly = _props$readOnly3 === void 0 ? false : _props$readOnly3,
|
8008
|
+
_props$required3 = props.required,
|
8009
|
+
required = _props$required3 === void 0 ? false : _props$required3,
|
8010
|
+
minDate = props.minDate,
|
8011
|
+
maxDate = props.maxDate,
|
8012
|
+
error = props.error,
|
8013
|
+
helperText = props.helperText,
|
8014
|
+
className = props.className,
|
8015
|
+
ariaLabel = props.ariaLabel,
|
8016
|
+
onChange = props.onChange,
|
8017
|
+
onValidation = props.onValidation,
|
8018
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded3$1);
|
8019
|
+
var _useState9 = React.useState({
|
8020
|
+
from: '',
|
8021
|
+
to: ''
|
8022
|
+
}),
|
8023
|
+
form = _useState9[0],
|
8024
|
+
setForm = _useState9[1];
|
8025
|
+
var _useState0 = React.useState(''),
|
8026
|
+
internalError = _useState0[0],
|
8027
|
+
setInternalError = _useState0[1];
|
8028
|
+
var _useState1 = React.useState(true),
|
8029
|
+
isValid = _useState1[0],
|
8030
|
+
setIsValid = _useState1[1];
|
8031
|
+
|
8032
|
+
// Validate required props
|
8033
|
+
if (!id) {
|
8034
|
+
console.warn('DateRange2 component: id prop is required');
|
8035
|
+
}
|
8036
|
+
|
8037
|
+
// Initialize form from value
|
8038
|
+
React.useEffect(function () {
|
8039
|
+
if (value && typeof value === 'object') {
|
8040
|
+
setForm(function (prevForm) {
|
8041
|
+
// Only update if values are actually different
|
8042
|
+
if (prevForm.from !== (value.from || '') || prevForm.to !== (value.to || '')) {
|
8043
|
+
return {
|
8044
|
+
from: value.from || '',
|
8045
|
+
to: value.to || ''
|
8046
|
+
};
|
8047
|
+
}
|
8048
|
+
return prevForm;
|
8049
|
+
});
|
8050
|
+
}
|
8051
|
+
}, [value]);
|
8052
|
+
|
8053
|
+
// Validate date range
|
8054
|
+
React.useEffect(function () {
|
8055
|
+
var valid = true;
|
8056
|
+
var errorMessage = '';
|
8057
|
+
if (required && (!form.from || !form.to)) {
|
8058
|
+
valid = false;
|
8059
|
+
errorMessage = 'Both dates are required';
|
8060
|
+
} else if (form.from && form.to) {
|
8061
|
+
var fromDate = new Date(form.from);
|
8062
|
+
var toDate = new Date(form.to);
|
8063
|
+
if (fromDate > toDate) {
|
8064
|
+
valid = false;
|
8065
|
+
errorMessage = 'From date must be before To date';
|
8066
|
+
} else if (minDate && fromDate < new Date(minDate)) {
|
8067
|
+
valid = false;
|
8068
|
+
errorMessage = "From date must be after " + minDate;
|
8069
|
+
} else if (maxDate && toDate > new Date(maxDate)) {
|
8070
|
+
valid = false;
|
8071
|
+
errorMessage = "To date must be before " + maxDate;
|
8072
|
+
}
|
8073
|
+
}
|
8074
|
+
setIsValid(valid);
|
8075
|
+
setInternalError(valid ? '' : errorMessage);
|
8076
|
+
if (onValidation) {
|
8077
|
+
onValidation(id, valid, errorMessage);
|
8078
|
+
}
|
8079
|
+
}, [form, required, minDate, maxDate, id]); // Removed onValidation to prevent infinite loops
|
8080
|
+
|
8081
|
+
// Handle form changes
|
8082
|
+
React.useEffect(function () {
|
8083
|
+
if (form.from && form.to && onChange) {
|
8084
|
+
// Only call onChange if the form values are different from the current value
|
8085
|
+
var hasChanged = !value || value.from !== form.from || value.to !== form.to;
|
8086
|
+
if (hasChanged) {
|
8087
|
+
onChange(id, form);
|
8088
|
+
}
|
8089
|
+
}
|
8090
|
+
}, [form, id, value]); // Added value to check for changes
|
8091
|
+
|
8092
|
+
// Handle field changes
|
8093
|
+
var handleChange = React.useCallback(function (fieldId, fieldValue) {
|
8094
|
+
if (disabled || readOnly) return;
|
8095
|
+
setForm(function (prevForm) {
|
8096
|
+
var _extends2;
|
8097
|
+
return _extends({}, prevForm, (_extends2 = {}, _extends2[fieldId] = fieldValue, _extends2));
|
8098
|
+
});
|
8099
|
+
}, [disabled, readOnly]);
|
8100
|
+
|
8101
|
+
// Generate CSS classes
|
8102
|
+
var safeClassName = className || '';
|
8103
|
+
var cssClasses = ['date-range2', outlined && 'outlined', disabled && 'disabled', readOnly && 'readonly', error || internalError ? 'error' : '', !isValid && 'invalid', safeClassName].filter(Boolean).join(' ');
|
8104
|
+
|
8105
|
+
// Accessibility attributes
|
8106
|
+
var ariaAttributes = {
|
8107
|
+
'aria-label': ariaLabel || label,
|
8108
|
+
'aria-invalid': !isValid || !!(error || internalError),
|
8109
|
+
'aria-required': required,
|
8110
|
+
'aria-disabled': disabled,
|
8111
|
+
'aria-readonly': readOnly,
|
8112
|
+
'aria-describedby': error || internalError || helperText ? id + "-helper" : undefined
|
8113
|
+
};
|
8114
|
+
var displayError = error || internalError;
|
8115
|
+
var displayHelperText = helperText && !displayError;
|
8116
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _extends({
|
8117
|
+
className: cssClasses
|
8118
|
+
}, ariaAttributes, restProps), label && /*#__PURE__*/React__default["default"].createElement("label", {
|
8119
|
+
className: "date-range2-label"
|
8120
|
+
}, /*#__PURE__*/React__default["default"].createElement(Text, null, label)), /*#__PURE__*/React__default["default"].createElement("div", {
|
8121
|
+
className: "date-range2-fields"
|
8122
|
+
}, /*#__PURE__*/React__default["default"].createElement(TextField2, {
|
8123
|
+
id: id + "-from",
|
8124
|
+
type: "date",
|
8125
|
+
label: "From",
|
8126
|
+
value: form.from,
|
8127
|
+
outlined: outlined,
|
8128
|
+
disabled: disabled,
|
8129
|
+
readOnly: readOnly,
|
8130
|
+
required: required,
|
8131
|
+
min: minDate,
|
8132
|
+
max: form.to || maxDate,
|
8133
|
+
onChange: handleChange,
|
8134
|
+
className: "date-range2-from"
|
8135
|
+
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
8136
|
+
className: "date-range2-separator"
|
8137
|
+
}, /*#__PURE__*/React__default["default"].createElement(Text, null, "to")), /*#__PURE__*/React__default["default"].createElement(TextField2, {
|
8138
|
+
id: id + "-to",
|
8139
|
+
type: "date",
|
8140
|
+
label: "To",
|
8141
|
+
value: form.to,
|
8142
|
+
outlined: outlined,
|
8143
|
+
disabled: disabled,
|
8144
|
+
readOnly: readOnly,
|
8145
|
+
required: required,
|
8146
|
+
min: form.from || minDate,
|
8147
|
+
max: maxDate,
|
8148
|
+
onChange: handleChange,
|
8149
|
+
className: "date-range2-to"
|
8150
|
+
})), (displayError || displayHelperText) && /*#__PURE__*/React__default["default"].createElement("div", {
|
8151
|
+
id: id + "-helper",
|
8152
|
+
className: "date-range2-helper " + (displayError ? 'error' : 'helper'),
|
8153
|
+
role: displayError ? 'alert' : 'status',
|
8154
|
+
"aria-live": displayError ? 'assertive' : 'polite'
|
8155
|
+
}, displayError && /*#__PURE__*/React__default["default"].createElement(Icon, {
|
8156
|
+
icon: "error",
|
8157
|
+
size: "small"
|
8158
|
+
}), /*#__PURE__*/React__default["default"].createElement(Text, null, displayError || helperText)));
|
8159
|
+
};
|
8160
|
+
|
8161
|
+
// PropTypes for DateRange2
|
8162
|
+
DateRange2.propTypes = {
|
8163
|
+
/** Unique identifier for the date range */
|
8164
|
+
id: PropTypes.string.isRequired,
|
8165
|
+
/** Field label */
|
8166
|
+
label: PropTypes.string,
|
8167
|
+
/** Date range value object with from and to properties */
|
8168
|
+
value: PropTypes.shape({
|
8169
|
+
from: PropTypes.string,
|
8170
|
+
to: PropTypes.string
|
8171
|
+
}),
|
8172
|
+
/** Whether fields have outlined style */
|
8173
|
+
outlined: PropTypes.bool,
|
8174
|
+
/** Whether fields are disabled */
|
8175
|
+
disabled: PropTypes.bool,
|
8176
|
+
/** Whether fields are read-only */
|
8177
|
+
readOnly: PropTypes.bool,
|
8178
|
+
/** Whether date range is required */
|
8179
|
+
required: PropTypes.bool,
|
8180
|
+
/** Minimum allowed date */
|
8181
|
+
minDate: PropTypes.string,
|
8182
|
+
/** Maximum allowed date */
|
8183
|
+
maxDate: PropTypes.string,
|
8184
|
+
/** Error message */
|
8185
|
+
error: PropTypes.string,
|
8186
|
+
/** Helper text */
|
8187
|
+
helperText: PropTypes.string,
|
8188
|
+
/** Additional CSS classes */
|
8189
|
+
className: PropTypes.string,
|
8190
|
+
/** ARIA label */
|
8191
|
+
ariaLabel: PropTypes.string,
|
8192
|
+
/** Change handler */
|
8193
|
+
onChange: PropTypes.func,
|
8194
|
+
/** Validation handler */
|
8195
|
+
onValidation: PropTypes.func
|
8196
|
+
};
|
8197
|
+
DateRange2.defaultProps = {
|
8198
|
+
outlined: false,
|
8199
|
+
disabled: false,
|
8200
|
+
readOnly: false,
|
8201
|
+
required: false,
|
8202
|
+
className: ''
|
8203
|
+
};
|
8204
|
+
|
8205
|
+
var _excluded$6 = ["columns", "rows", "onRowSelection", "onSort", "onCheckAll", "editable", "outlined", "expanded", "className", "emptyMessage", "emptyIcon", "multisort", "filterable", "onClearFilters", "loading", "skeleton", "striped", "hover", "compact", "bordered", "responsive", "stickyHeader", "virtualScrolling", "pageSize", "selectionMode", "sortMode", "resizable", "reorderable", "exportable", "searchable", "searchPlaceholder", "onSearch", "onExport", "onColumnResize", "onColumnReorder", "customEmptyState", "rowHeight", "density", "theme", "accessibility", "onRowClick", "onRowDoubleClick", "onRowContextMenu", "onCellClick", "onCellDoubleClick", "onCellEdit", "rowClassName", "cellClassName", "headerClassName", "footerContent", "showRowNumbers", "showSelectAll", "persistState", "stateKey", "onStateChange"];
|
8206
|
+
var isFunction$1 = function isFunction(value) {
|
8207
|
+
return value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
|
8208
|
+
};
|
8209
|
+
|
8210
|
+
/**
|
8211
|
+
* Enhanced DataTable v2 - 100% Compatible with original DataTable
|
8212
|
+
*
|
8213
|
+
* This is a completely rewritten version of DataTable that maintains 100% API compatibility
|
8214
|
+
* while adding significant performance improvements, accessibility, and new features.
|
8215
|
+
*/
|
8216
|
+
var DataTable2 = function DataTable2(props) {
|
8217
|
+
var _props$columns = props.columns,
|
8218
|
+
columns = _props$columns === void 0 ? [] : _props$columns,
|
8219
|
+
_props$rows = props.rows,
|
8220
|
+
rows = _props$rows === void 0 ? [] : _props$rows,
|
8221
|
+
onRowSelection = props.onRowSelection,
|
8222
|
+
onSort = props.onSort,
|
8223
|
+
onCheckAll = props.onCheckAll,
|
8224
|
+
editable = props.editable,
|
8225
|
+
outlined = props.outlined,
|
8226
|
+
_props$expanded = props.expanded,
|
8227
|
+
expanded = _props$expanded === void 0 ? false : _props$expanded,
|
8228
|
+
className = props.className,
|
8229
|
+
_props$emptyMessage = props.emptyMessage,
|
8230
|
+
emptyMessage = _props$emptyMessage === void 0 ? "No Results Found" : _props$emptyMessage,
|
8231
|
+
_props$emptyIcon = props.emptyIcon,
|
8232
|
+
emptyIcon = _props$emptyIcon === void 0 ? "search_off" : _props$emptyIcon,
|
8233
|
+
_props$multisort = props.multisort,
|
8234
|
+
multisort = _props$multisort === void 0 ? false : _props$multisort,
|
8235
|
+
_props$filterable = props.filterable,
|
8236
|
+
filterable = _props$filterable === void 0 ? false : _props$filterable,
|
8237
|
+
onClearFilters = props.onClearFilters,
|
8238
|
+
_props$loading = props.loading,
|
8239
|
+
loading = _props$loading === void 0 ? false : _props$loading,
|
8240
|
+
_props$skeleton = props.skeleton,
|
8241
|
+
skeleton = _props$skeleton === void 0 ? false : _props$skeleton,
|
8242
|
+
_props$striped = props.striped,
|
8243
|
+
striped = _props$striped === void 0 ? false : _props$striped,
|
8244
|
+
_props$hover = props.hover,
|
8245
|
+
hover = _props$hover === void 0 ? true : _props$hover,
|
8246
|
+
_props$compact = props.compact,
|
8247
|
+
compact = _props$compact === void 0 ? false : _props$compact,
|
8248
|
+
_props$bordered = props.bordered,
|
8249
|
+
bordered = _props$bordered === void 0 ? false : _props$bordered,
|
8250
|
+
_props$responsive = props.responsive,
|
8251
|
+
responsive = _props$responsive === void 0 ? true : _props$responsive,
|
8252
|
+
_props$stickyHeader = props.stickyHeader,
|
8253
|
+
stickyHeader = _props$stickyHeader === void 0 ? true : _props$stickyHeader,
|
8254
|
+
_props$virtualScrolli = props.virtualScrolling,
|
8255
|
+
virtualScrolling = _props$virtualScrolli === void 0 ? false : _props$virtualScrolli,
|
8256
|
+
_props$pageSize = props.pageSize,
|
8257
|
+
pageSize = _props$pageSize === void 0 ? 50 : _props$pageSize,
|
8258
|
+
_props$selectionMode = props.selectionMode,
|
8259
|
+
selectionMode = _props$selectionMode === void 0 ? 'single' : _props$selectionMode,
|
8260
|
+
_props$sortMode = props.sortMode,
|
8261
|
+
sortMode = _props$sortMode === void 0 ? 'single' : _props$sortMode,
|
8262
|
+
_props$resizable = props.resizable,
|
8263
|
+
resizable = _props$resizable === void 0 ? false : _props$resizable,
|
8264
|
+
_props$exportable = props.exportable,
|
8265
|
+
exportable = _props$exportable === void 0 ? false : _props$exportable,
|
8266
|
+
_props$searchable = props.searchable,
|
8267
|
+
searchable = _props$searchable === void 0 ? false : _props$searchable,
|
8268
|
+
_props$searchPlacehol = props.searchPlaceholder,
|
8269
|
+
searchPlaceholder = _props$searchPlacehol === void 0 ? "Search..." : _props$searchPlacehol,
|
8270
|
+
onSearch = props.onSearch,
|
8271
|
+
onExport = props.onExport,
|
8272
|
+
onColumnResize = props.onColumnResize,
|
8273
|
+
customEmptyState = props.customEmptyState,
|
8274
|
+
_props$rowHeight = props.rowHeight,
|
8275
|
+
rowHeight = _props$rowHeight === void 0 ? 'medium' : _props$rowHeight,
|
8276
|
+
_props$density = props.density,
|
8277
|
+
density = _props$density === void 0 ? 'normal' : _props$density,
|
8278
|
+
_props$theme = props.theme,
|
8279
|
+
theme = _props$theme === void 0 ? 'default' : _props$theme,
|
8280
|
+
_props$accessibility = props.accessibility,
|
8281
|
+
accessibility = _props$accessibility === void 0 ? true : _props$accessibility,
|
8282
|
+
onRowClick = props.onRowClick,
|
8283
|
+
onRowDoubleClick = props.onRowDoubleClick,
|
8284
|
+
onRowContextMenu = props.onRowContextMenu,
|
8285
|
+
onCellClick = props.onCellClick,
|
8286
|
+
onCellDoubleClick = props.onCellDoubleClick,
|
8287
|
+
onCellEdit = props.onCellEdit,
|
8288
|
+
rowClassName = props.rowClassName,
|
8289
|
+
cellClassName = props.cellClassName,
|
8290
|
+
headerClassName = props.headerClassName,
|
8291
|
+
footerContent = props.footerContent,
|
8292
|
+
_props$showRowNumbers = props.showRowNumbers,
|
8293
|
+
showRowNumbers = _props$showRowNumbers === void 0 ? false : _props$showRowNumbers,
|
8294
|
+
_props$showSelectAll = props.showSelectAll,
|
8295
|
+
showSelectAll = _props$showSelectAll === void 0 ? true : _props$showSelectAll,
|
8296
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded$6);
|
8297
|
+
|
8298
|
+
// State management
|
8299
|
+
var _useState = React.useState({}),
|
8300
|
+
sortDir = _useState[0],
|
8301
|
+
setSortDir = _useState[1];
|
8302
|
+
var _useState2 = React.useState(false),
|
8303
|
+
allChecked = _useState2[0],
|
8304
|
+
setAllChecked = _useState2[1];
|
8305
|
+
var _useState3 = React.useState(''),
|
8306
|
+
searchTerm = _useState3[0],
|
8307
|
+
setSearchTerm = _useState3[1];
|
8308
|
+
var _useState4 = React.useState(new Set()),
|
8309
|
+
selectedRows = _useState4[0],
|
8310
|
+
setSelectedRows = _useState4[1];
|
8311
|
+
var _useState5 = React.useState(loading),
|
8312
|
+
isLoading = _useState5[0],
|
8313
|
+
setIsLoading = _useState5[1];
|
8314
|
+
var _useState6 = React.useState(0),
|
8315
|
+
currentPage = _useState6[0],
|
8316
|
+
setCurrentPage = _useState6[1];
|
8317
|
+
|
8318
|
+
// Refs
|
8319
|
+
var tableRef = React.useRef(null);
|
8320
|
+
|
8321
|
+
// Validate props
|
8322
|
+
React.useEffect(function () {
|
8323
|
+
if (!Array.isArray(columns)) {
|
8324
|
+
console.warn('DataTable2: columns prop must be an array');
|
8325
|
+
}
|
8326
|
+
if (!Array.isArray(rows)) {
|
8327
|
+
console.warn('DataTable2: rows prop must be an array');
|
8328
|
+
}
|
8329
|
+
if (virtualScrolling && !pageSize) {
|
8330
|
+
console.warn('DataTable2: pageSize is required when virtualScrolling is enabled');
|
8331
|
+
}
|
8332
|
+
}, [columns, rows, virtualScrolling, pageSize]);
|
8333
|
+
|
8334
|
+
// Sync loading state
|
8335
|
+
React.useEffect(function () {
|
8336
|
+
setIsLoading(loading);
|
8337
|
+
}, [loading]);
|
8338
|
+
|
8339
|
+
// Enhanced sort function (maintaining original behavior)
|
8340
|
+
var changeSort = React.useCallback(function (id) {
|
8341
|
+
if (sortMode === 'none') return;
|
8342
|
+
if (sortMode === 'multiple' || multisort) {
|
8343
|
+
var _Object$assign;
|
8344
|
+
var nextDir = sortDir[id] ? sortDir[id] * -1 : 1;
|
8345
|
+
var next = Object.assign({}, sortDir, (_Object$assign = {}, _Object$assign[id] = nextDir, _Object$assign));
|
8346
|
+
setSortDir(next);
|
8347
|
+
} else {
|
8348
|
+
var _setSortDir;
|
8349
|
+
var _nextDir = sortDir[id] ? sortDir[id] * -1 : 1;
|
8350
|
+
setSortDir((_setSortDir = {}, _setSortDir[id] = _nextDir, _setSortDir));
|
8351
|
+
}
|
8352
|
+
}, [sortDir, sortMode, multisort]);
|
8353
|
+
|
8354
|
+
// Enhanced multiSort function (maintaining original logic)
|
8355
|
+
var multiSort = React.useCallback(function (array, sortObject) {
|
8356
|
+
if (sortObject === void 0) {
|
8357
|
+
sortObject = {};
|
8358
|
+
}
|
8359
|
+
var sortKeys = Object.keys(sortObject);
|
8360
|
+
if (!sortKeys.length) {
|
8361
|
+
return array;
|
8362
|
+
}
|
8363
|
+
var keySort = function keySort(a, b, direction) {
|
8364
|
+
direction = direction !== null ? direction : 1;
|
8365
|
+
|
8366
|
+
// check if a and b are numbers and compare as numbers
|
8367
|
+
if (!isNaN(a) && !isNaN(b)) {
|
8368
|
+
a = Number(a);
|
8369
|
+
b = Number(b);
|
8370
|
+
}
|
8371
|
+
|
8372
|
+
// If b > a, multiply by -1 to get the reverse direction.
|
8373
|
+
return a > b ? direction : -1 * direction;
|
8374
|
+
};
|
8375
|
+
return array.sort(function (a, b) {
|
8376
|
+
var sorted = 0;
|
8377
|
+
var index = 0;
|
8378
|
+
|
8379
|
+
// Loop until sorted (-1 or 1) or until the sort keys have been processed.
|
8380
|
+
while (sorted === 0 && index < sortKeys.length) {
|
8381
|
+
var key = sortKeys[index];
|
8382
|
+
if (key) {
|
8383
|
+
var direction = sortObject[key];
|
8384
|
+
sorted = keySort(a[key], b[key], direction);
|
8385
|
+
index++;
|
8386
|
+
}
|
8387
|
+
}
|
8388
|
+
return sorted;
|
8389
|
+
});
|
8390
|
+
}, []);
|
8391
|
+
|
8392
|
+
// Enhanced row selection (maintaining original behavior)
|
8393
|
+
var select = React.useCallback(function (row, event) {
|
8394
|
+
if (event.target.id !== "checked") {
|
8395
|
+
// Enhanced selection logic
|
8396
|
+
if (selectionMode === 'multiple') {
|
8397
|
+
var newSelected = new Set(selectedRows);
|
8398
|
+
if (newSelected.has(row.id)) {
|
8399
|
+
newSelected["delete"](row.id);
|
8400
|
+
} else {
|
8401
|
+
newSelected.add(row.id);
|
8402
|
+
}
|
8403
|
+
setSelectedRows(newSelected);
|
8404
|
+
} else if (selectionMode === 'single') {
|
8405
|
+
setSelectedRows(new Set([row.id]));
|
8406
|
+
}
|
8407
|
+
|
8408
|
+
// Call original callback
|
8409
|
+
if (onRowSelection) onRowSelection(row, event);
|
8410
|
+
if (onRowClick) onRowClick(row, event);
|
8411
|
+
}
|
8412
|
+
}, [selectedRows, selectionMode, onRowSelection, onRowClick]);
|
8413
|
+
|
8414
|
+
// Enhanced move row function (maintaining original behavior)
|
8415
|
+
var moveRow = React.useCallback(function (dragged, dropped) {
|
8416
|
+
if (onSort) onSort(dragged, dropped);
|
8417
|
+
}, [onSort]);
|
8418
|
+
|
8419
|
+
// Enhanced check all function (maintaining original behavior)
|
8420
|
+
var checkAll = React.useCallback(function (_, value) {
|
8421
|
+
var ids = rows.map(function (row) {
|
8422
|
+
return row.id;
|
8423
|
+
});
|
8424
|
+
setAllChecked(value);
|
8425
|
+
if (selectionMode === 'multiple') {
|
8426
|
+
if (value) {
|
8427
|
+
setSelectedRows(new Set(ids));
|
8428
|
+
} else {
|
8429
|
+
setSelectedRows(new Set());
|
8430
|
+
}
|
8431
|
+
}
|
8432
|
+
if (onCheckAll) onCheckAll(ids, value);
|
8433
|
+
}, [rows, selectionMode, onCheckAll]);
|
8434
|
+
|
8435
|
+
// Search functionality
|
8436
|
+
var filteredRows = React.useMemo(function () {
|
8437
|
+
if (!searchTerm || !searchable) return rows;
|
8438
|
+
return rows.filter(function (row) {
|
8439
|
+
return columns.some(function (column) {
|
8440
|
+
var value = row[column.id];
|
8441
|
+
if (value == null) return false;
|
8442
|
+
return String(value).toLowerCase().includes(searchTerm.toLowerCase());
|
8443
|
+
});
|
8444
|
+
});
|
8445
|
+
}, [rows, searchTerm, searchable, columns]);
|
8446
|
+
|
8447
|
+
// Pagination for virtual scrolling
|
8448
|
+
var paginatedRows = React.useMemo(function () {
|
8449
|
+
if (!virtualScrolling) return filteredRows;
|
8450
|
+
var start = currentPage * pageSize;
|
8451
|
+
var end = start + pageSize;
|
8452
|
+
return filteredRows.slice(start, end);
|
8453
|
+
}, [filteredRows, virtualScrolling, currentPage, pageSize]);
|
8454
|
+
|
8455
|
+
// Final processed rows
|
8456
|
+
var processedRows = React.useMemo(function () {
|
8457
|
+
var rowsToProcess = virtualScrolling ? paginatedRows : filteredRows;
|
8458
|
+
return multiSort(rowsToProcess, sortDir);
|
8459
|
+
}, [virtualScrolling, paginatedRows, filteredRows, multiSort, sortDir]);
|
8460
|
+
|
8461
|
+
// Handle search
|
8462
|
+
var handleSearch = React.useCallback(function (term) {
|
8463
|
+
setSearchTerm(term);
|
8464
|
+
setCurrentPage(0); // Reset to first page
|
8465
|
+
if (onSearch) onSearch(term);
|
8466
|
+
}, [onSearch]);
|
8467
|
+
|
8468
|
+
// Handle export
|
8469
|
+
var handleExport = React.useCallback(function () {
|
8470
|
+
if (onExport) {
|
8471
|
+
onExport(processedRows, columns);
|
8472
|
+
} else {
|
8473
|
+
// Default CSV export
|
8474
|
+
var csvContent = [columns.map(function (col) {
|
8475
|
+
return col.label || col.id;
|
8476
|
+
}).join(',')].concat(processedRows.map(function (row) {
|
8477
|
+
return columns.map(function (col) {
|
8478
|
+
var value = row[col.id];
|
8479
|
+
return typeof value === 'string' ? "\"" + value + "\"" : value;
|
8480
|
+
}).join(',');
|
8481
|
+
})).join('\n');
|
8482
|
+
var blob = new Blob([csvContent], {
|
8483
|
+
type: 'text/csv'
|
8484
|
+
});
|
8485
|
+
var url = URL.createObjectURL(blob);
|
8486
|
+
var a = document.createElement('a');
|
8487
|
+
a.href = url;
|
8488
|
+
a.download = 'table-export.csv';
|
8489
|
+
a.click();
|
8490
|
+
URL.revokeObjectURL(url);
|
8491
|
+
}
|
8492
|
+
}, [processedRows, columns, onExport]);
|
8493
|
+
|
8494
|
+
// Generate CSS classes
|
8495
|
+
var cssClasses = ['datatable8',
|
8496
|
+
// Maintain original class for compatibility
|
8497
|
+
'datatable2',
|
8498
|
+
// New class for v2 features
|
8499
|
+
outlined && 'outlined', striped && 'datatable2--striped', compact && 'datatable2--compact', bordered && 'datatable2--bordered', !hover && 'datatable2--no-hover', "datatable2--" + rowHeight, "datatable2--" + density, "datatable2--" + theme, responsive && 'datatable2--responsive', isLoading && 'datatable2--loading', skeleton && 'datatable2--skeleton', className].filter(Boolean).join(' ');
|
8500
|
+
|
8501
|
+
// Accessibility attributes
|
8502
|
+
var ariaAttributes = accessibility ? {
|
8503
|
+
role: 'table',
|
8504
|
+
'aria-label': 'Data table',
|
8505
|
+
'aria-rowcount': processedRows.length,
|
8506
|
+
'aria-colcount': columns.length,
|
8507
|
+
'aria-multiselectable': selectionMode === 'multiple',
|
8508
|
+
'aria-busy': isLoading
|
8509
|
+
} : {};
|
8510
|
+
|
8511
|
+
// Render loading/skeleton state
|
8512
|
+
if (isLoading && skeleton) {
|
8513
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _extends({
|
8514
|
+
className: cssClasses
|
8515
|
+
}, ariaAttributes, restProps), /*#__PURE__*/React__default["default"].createElement(SkeletonTable, {
|
8516
|
+
columns: columns,
|
8517
|
+
rows: 5
|
8518
|
+
}));
|
8519
|
+
}
|
8520
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _extends({
|
8521
|
+
className: cssClasses,
|
8522
|
+
ref: tableRef
|
8523
|
+
}, ariaAttributes, restProps), searchable && /*#__PURE__*/React__default["default"].createElement("div", {
|
8524
|
+
className: "datatable2__search"
|
8525
|
+
}, /*#__PURE__*/React__default["default"].createElement(TextField2, {
|
8526
|
+
placeholder: searchPlaceholder,
|
8527
|
+
value: searchTerm,
|
8528
|
+
onChange: function onChange(_, value) {
|
8529
|
+
return handleSearch(value);
|
8530
|
+
},
|
8531
|
+
icon: "search"
|
8532
|
+
})), exportable && /*#__PURE__*/React__default["default"].createElement("div", {
|
8533
|
+
className: "datatable2__toolbar"
|
8534
|
+
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
8535
|
+
className: "datatable2__export-btn",
|
8536
|
+
onClick: handleExport,
|
8537
|
+
disabled: isLoading
|
8538
|
+
}, /*#__PURE__*/React__default["default"].createElement(Icon, {
|
8539
|
+
icon: "download",
|
8540
|
+
size: "small"
|
8541
|
+
}), "Export")), /*#__PURE__*/React__default["default"].createElement("table", null, /*#__PURE__*/React__default["default"].createElement(DataTable2Header, {
|
8542
|
+
columns: columns,
|
8543
|
+
sortDir: sortDir,
|
8544
|
+
onSort: changeSort,
|
8545
|
+
allChecked: allChecked,
|
8546
|
+
onCheckAll: checkAll,
|
8547
|
+
showSelectAll: showSelectAll,
|
8548
|
+
showRowNumbers: showRowNumbers,
|
8549
|
+
resizable: resizable,
|
8550
|
+
onColumnResize: onColumnResize,
|
8551
|
+
accessibility: accessibility,
|
8552
|
+
headerClassName: headerClassName,
|
8553
|
+
stickyHeader: stickyHeader
|
8554
|
+
}), /*#__PURE__*/React__default["default"].createElement(DataTable2Body, {
|
8555
|
+
columns: columns,
|
8556
|
+
rows: processedRows,
|
8557
|
+
onSelect: select,
|
8558
|
+
onDrop: moveRow,
|
8559
|
+
editable: editable,
|
8560
|
+
expanded: expanded,
|
8561
|
+
filterable: filterable,
|
8562
|
+
onClearFilters: onClearFilters,
|
8563
|
+
selectedRows: selectedRows,
|
8564
|
+
showRowNumbers: showRowNumbers,
|
8565
|
+
onRowDoubleClick: onRowDoubleClick,
|
8566
|
+
onRowContextMenu: onRowContextMenu,
|
8567
|
+
onCellClick: onCellClick,
|
8568
|
+
onCellDoubleClick: onCellDoubleClick,
|
8569
|
+
onCellEdit: onCellEdit,
|
8570
|
+
rowClassName: rowClassName,
|
8571
|
+
cellClassName: cellClassName,
|
8572
|
+
accessibility: accessibility,
|
8573
|
+
emptyMessage: emptyMessage,
|
8574
|
+
emptyIcon: emptyIcon,
|
8575
|
+
customEmptyState: customEmptyState,
|
8576
|
+
isLoading: isLoading
|
8577
|
+
})), footerContent && /*#__PURE__*/React__default["default"].createElement("div", {
|
8578
|
+
className: "datatable2__footer"
|
8579
|
+
}, footerContent), virtualScrolling && filteredRows.length > pageSize && /*#__PURE__*/React__default["default"].createElement("div", {
|
8580
|
+
className: "datatable2__pagination"
|
8581
|
+
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
8582
|
+
onClick: function onClick() {
|
8583
|
+
return setCurrentPage(Math.max(0, currentPage - 1));
|
8584
|
+
},
|
8585
|
+
disabled: currentPage === 0
|
8586
|
+
}, "Previous"), /*#__PURE__*/React__default["default"].createElement("span", null, "Page ", currentPage + 1, " of ", Math.ceil(filteredRows.length / pageSize)), /*#__PURE__*/React__default["default"].createElement("button", {
|
8587
|
+
onClick: function onClick() {
|
8588
|
+
return setCurrentPage(Math.min(Math.ceil(filteredRows.length / pageSize) - 1, currentPage + 1));
|
8589
|
+
},
|
8590
|
+
disabled: currentPage >= Math.ceil(filteredRows.length / pageSize) - 1
|
8591
|
+
}, "Next")));
|
8592
|
+
};
|
8593
|
+
|
8594
|
+
/**
|
8595
|
+
* Enhanced DataTable Header - maintains original structure
|
8596
|
+
*/
|
8597
|
+
var DataTable2Header = function DataTable2Header(_ref) {
|
8598
|
+
var columns = _ref.columns,
|
8599
|
+
sortDir = _ref.sortDir,
|
8600
|
+
onSort = _ref.onSort,
|
8601
|
+
allChecked = _ref.allChecked,
|
8602
|
+
onCheckAll = _ref.onCheckAll,
|
8603
|
+
showSelectAll = _ref.showSelectAll,
|
8604
|
+
showRowNumbers = _ref.showRowNumbers,
|
8605
|
+
resizable = _ref.resizable,
|
8606
|
+
onColumnResize = _ref.onColumnResize,
|
8607
|
+
accessibility = _ref.accessibility,
|
8608
|
+
headerClassName = _ref.headerClassName,
|
8609
|
+
stickyHeader = _ref.stickyHeader;
|
8610
|
+
var headerClasses = ['datatable2__header', stickyHeader && 'datatable2__header--sticky', headerClassName].filter(Boolean).join(' ');
|
8611
|
+
return /*#__PURE__*/React__default["default"].createElement("thead", {
|
8612
|
+
className: headerClasses
|
8613
|
+
}, /*#__PURE__*/React__default["default"].createElement("tr", null, showRowNumbers && /*#__PURE__*/React__default["default"].createElement("th", {
|
8614
|
+
className: "datatable2__row-number-header"
|
8615
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", null, "#")), columns.map(function (_ref2) {
|
8616
|
+
var id = _ref2.id,
|
8617
|
+
label = _ref2.label,
|
8618
|
+
type = _ref2.type,
|
8619
|
+
item = _ref2.item,
|
8620
|
+
sortable = _ref2.sortable,
|
8621
|
+
_ref2$resizable = _ref2.resizable,
|
8622
|
+
colResizable = _ref2$resizable === void 0 ? false : _ref2$resizable;
|
8623
|
+
var isResizable = resizable || colResizable;
|
8624
|
+
var resizableStyle = isResizable ? "resizable-column" : "";
|
8625
|
+
var sort = sortDir[id] ? sortDir[id] : null;
|
8626
|
+
var _ref3 = type === TYPES$1.ENTITY ? [1, Object.values(item).filter(function (v) {
|
8627
|
+
return v.column === true;
|
8628
|
+
}).length] : [2, 1],
|
8629
|
+
rowspan = _ref3[0],
|
8630
|
+
colspan = _ref3[1];
|
8631
|
+
var thProps = accessibility ? {
|
8632
|
+
role: 'columnheader',
|
8633
|
+
'aria-sort': sort > 0 ? 'ascending' : sort < 0 ? 'descending' : 'none',
|
8634
|
+
tabIndex: sortable ? 0 : -1
|
8635
|
+
} : {};
|
8636
|
+
return /*#__PURE__*/React__default["default"].createElement("th", _extends({
|
8637
|
+
key: id,
|
8638
|
+
className: resizableStyle,
|
8639
|
+
rowSpan: rowspan,
|
8640
|
+
colSpan: colspan,
|
8641
|
+
style: {
|
8642
|
+
minWidth: '80px'
|
8643
|
+
}
|
8644
|
+
}, thProps), /*#__PURE__*/React__default["default"].createElement("div", {
|
8645
|
+
style: {
|
8646
|
+
display: 'flex',
|
8647
|
+
alignItems: 'center',
|
8648
|
+
justifyContent: 'space-between'
|
8649
|
+
}
|
8650
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
8651
|
+
style: {
|
8652
|
+
display: 'flex',
|
8653
|
+
alignItems: 'center',
|
8654
|
+
gap: '0.5rem'
|
8655
|
+
}
|
8656
|
+
}, id === "checked" && onCheckAll && showSelectAll ? /*#__PURE__*/React__default["default"].createElement(CheckBox, {
|
8657
|
+
onChange: onCheckAll,
|
8658
|
+
value: allChecked
|
8659
|
+
}) : /*#__PURE__*/React__default["default"].createElement(Text, {
|
8660
|
+
key: "th_" + id
|
8661
|
+
}, label), sortable ? /*#__PURE__*/React__default["default"].createElement(SortIcon2, {
|
8662
|
+
sortDir: sortDir[id],
|
8663
|
+
onChange: function onChange() {
|
8664
|
+
return onSort(id);
|
8665
|
+
}
|
8666
|
+
}) : null)), isResizable && /*#__PURE__*/React__default["default"].createElement("div", {
|
8667
|
+
className: "column-resizer",
|
8668
|
+
onMouseDown: function onMouseDown(e) {
|
8669
|
+
return handleColumnResize(e, id, onColumnResize);
|
8670
|
+
},
|
8671
|
+
title: "Drag to resize column"
|
8672
|
+
}));
|
8673
|
+
}), /*#__PURE__*/React__default["default"].createElement("th", {
|
8674
|
+
rowSpan: 2,
|
8675
|
+
colSpan: 1
|
8676
|
+
})), /*#__PURE__*/React__default["default"].createElement("tr", null, showRowNumbers && /*#__PURE__*/React__default["default"].createElement("th", null), columns.filter(function (_ref4) {
|
8677
|
+
var type = _ref4.type;
|
8678
|
+
return type === TYPES$1.ENTITY;
|
8679
|
+
}).map(function (column) {
|
8680
|
+
var item = column.item;
|
8681
|
+
var fields = item ? Object.values(item) : [];
|
8682
|
+
return fields.filter(function (field) {
|
8683
|
+
return field.column === true;
|
8684
|
+
}).map(function (field) {
|
8685
|
+
return /*#__PURE__*/React__default["default"].createElement("th", {
|
8686
|
+
key: field.id
|
8687
|
+
}, field.label);
|
8688
|
+
});
|
8689
|
+
})));
|
8690
|
+
};
|
8691
|
+
|
8692
|
+
/**
|
8693
|
+
* Enhanced DataTable Body - maintains original structure
|
8694
|
+
*/
|
8695
|
+
var DataTable2Body = function DataTable2Body(_ref5) {
|
8696
|
+
var columns = _ref5.columns,
|
8697
|
+
rows = _ref5.rows,
|
8698
|
+
onSelect = _ref5.onSelect,
|
8699
|
+
onDrop = _ref5.onDrop,
|
8700
|
+
editable = _ref5.editable,
|
8701
|
+
expanded = _ref5.expanded,
|
8702
|
+
filterable = _ref5.filterable,
|
8703
|
+
onClearFilters = _ref5.onClearFilters,
|
8704
|
+
selectedRows = _ref5.selectedRows,
|
8705
|
+
showRowNumbers = _ref5.showRowNumbers,
|
8706
|
+
onRowDoubleClick = _ref5.onRowDoubleClick,
|
8707
|
+
onRowContextMenu = _ref5.onRowContextMenu,
|
8708
|
+
onCellClick = _ref5.onCellClick,
|
8709
|
+
onCellDoubleClick = _ref5.onCellDoubleClick,
|
8710
|
+
onCellEdit = _ref5.onCellEdit,
|
8711
|
+
rowClassName = _ref5.rowClassName,
|
8712
|
+
cellClassName = _ref5.cellClassName,
|
8713
|
+
accessibility = _ref5.accessibility,
|
8714
|
+
emptyMessage = _ref5.emptyMessage,
|
8715
|
+
emptyIcon = _ref5.emptyIcon,
|
8716
|
+
customEmptyState = _ref5.customEmptyState;
|
8717
|
+
return /*#__PURE__*/React__default["default"].createElement("tbody", null, filterable ? /*#__PURE__*/React__default["default"].createElement(DataTableFiltersRow2, {
|
8718
|
+
columns: columns,
|
8719
|
+
onClear: onClearFilters,
|
8720
|
+
showRowNumbers: showRowNumbers
|
8721
|
+
}) : null, rows.length > 0 ? rows.map(function (row, index) {
|
8722
|
+
return /*#__PURE__*/React__default["default"].createElement(DataTableRow2, {
|
8723
|
+
key: row.id,
|
8724
|
+
index: index,
|
8725
|
+
row: row,
|
8726
|
+
columns: columns,
|
8727
|
+
onSelect: onSelect,
|
8728
|
+
onDrop: onDrop,
|
8729
|
+
editable: editable,
|
8730
|
+
expanded: expanded,
|
8731
|
+
selected: selectedRows.has(row.id),
|
8732
|
+
showRowNumbers: showRowNumbers,
|
8733
|
+
onRowDoubleClick: onRowDoubleClick,
|
8734
|
+
onRowContextMenu: onRowContextMenu,
|
8735
|
+
onCellClick: onCellClick,
|
8736
|
+
onCellDoubleClick: onCellDoubleClick,
|
8737
|
+
onCellEdit: onCellEdit,
|
8738
|
+
rowClassName: rowClassName,
|
8739
|
+
cellClassName: cellClassName,
|
8740
|
+
accessibility: accessibility
|
8741
|
+
});
|
8742
|
+
}) : /*#__PURE__*/React__default["default"].createElement("tr", null, /*#__PURE__*/React__default["default"].createElement("td", {
|
8743
|
+
colSpan: columns.length + (showRowNumbers ? 1 : 0) + 1
|
8744
|
+
}, customEmptyState || /*#__PURE__*/React__default["default"].createElement(EmptyMessage, {
|
8745
|
+
icon: emptyIcon ? emptyIcon : "search_off",
|
8746
|
+
text: emptyMessage,
|
8747
|
+
className: "empty-message"
|
8748
|
+
}))));
|
8749
|
+
};
|
8750
|
+
|
8751
|
+
/**
|
8752
|
+
* Enhanced DataTableFiltersRow - maintains original structure
|
8753
|
+
*/
|
8754
|
+
var DataTableFiltersRow2 = function DataTableFiltersRow2(_ref6) {
|
8755
|
+
var columns = _ref6.columns,
|
8756
|
+
onClear = _ref6.onClear,
|
8757
|
+
showRowNumbers = _ref6.showRowNumbers;
|
8758
|
+
var _useState7 = React.useState({}),
|
8759
|
+
form = _useState7[0],
|
8760
|
+
setForm = _useState7[1];
|
8761
|
+
function changeFilter(id, value, onFilter) {
|
8762
|
+
var _extends2;
|
8763
|
+
setForm(_extends({}, form, (_extends2 = {}, _extends2[id] = value, _extends2)));
|
8764
|
+
if (onFilter) onFilter(id, value);
|
8765
|
+
}
|
8766
|
+
function clear() {
|
8767
|
+
setForm({});
|
8768
|
+
if (onClear) onClear();
|
8769
|
+
}
|
8770
|
+
var dirty = Object.keys(form).length > 0;
|
8771
|
+
return /*#__PURE__*/React__default["default"].createElement("tr", {
|
8772
|
+
className: "filters-row"
|
8773
|
+
}, showRowNumbers && /*#__PURE__*/React__default["default"].createElement("td", {
|
8774
|
+
className: "filter-cell"
|
8775
|
+
}), columns.map(function (_ref7) {
|
8776
|
+
var id = _ref7.id,
|
8777
|
+
filterable = _ref7.filterable,
|
8778
|
+
onFilter = _ref7.onFilter,
|
8779
|
+
_ref7$predictive = _ref7.predictive,
|
8780
|
+
predictive = _ref7$predictive === void 0 ? false : _ref7$predictive,
|
8781
|
+
options = _ref7.options;
|
8782
|
+
var value = form[id] ? form[id] : '';
|
8783
|
+
var field = options ? /*#__PURE__*/React__default["default"].createElement(DropDown2, {
|
8784
|
+
id: id,
|
8785
|
+
value: value,
|
8786
|
+
options: options,
|
8787
|
+
predictive: predictive,
|
8788
|
+
onChange: function onChange(id, value) {
|
8789
|
+
return changeFilter(id, value, onFilter);
|
8790
|
+
},
|
8791
|
+
outlined: true
|
8792
|
+
}) : /*#__PURE__*/React__default["default"].createElement(TextField2, {
|
8793
|
+
id: id,
|
8794
|
+
value: value,
|
8795
|
+
onChange: function onChange(id, value) {
|
8796
|
+
return changeFilter(id, value, onFilter);
|
8797
|
+
},
|
8798
|
+
outlined: true
|
8799
|
+
});
|
8800
|
+
return /*#__PURE__*/React__default["default"].createElement("td", {
|
8801
|
+
key: id,
|
8802
|
+
className: "filter-cell"
|
8803
|
+
}, filterable ? field : null);
|
8804
|
+
}), /*#__PURE__*/React__default["default"].createElement("td", null, /*#__PURE__*/React__default["default"].createElement(Icon, {
|
8805
|
+
icon: "close",
|
8806
|
+
size: "small",
|
8807
|
+
clickable: true,
|
8808
|
+
action: clear,
|
8809
|
+
disabled: !dirty
|
8810
|
+
})));
|
8811
|
+
};
|
8812
|
+
|
8813
|
+
/**
|
8814
|
+
* Enhanced DataTable Row - maintains original structure
|
8815
|
+
*/
|
8816
|
+
var DataTableRow2 = function DataTableRow2(props) {
|
8817
|
+
var index = props.index,
|
8818
|
+
row = props.row,
|
8819
|
+
_props$columns2 = props.columns,
|
8820
|
+
columns = _props$columns2 === void 0 ? [] : _props$columns2,
|
8821
|
+
onSelect = props.onSelect,
|
8822
|
+
editable = props.editable,
|
8823
|
+
_props$expanded2 = props.expanded,
|
8824
|
+
expanded = _props$expanded2 === void 0 ? false : _props$expanded2,
|
8825
|
+
_props$selected = props.selected,
|
8826
|
+
selected = _props$selected === void 0 ? false : _props$selected,
|
8827
|
+
showRowNumbers = props.showRowNumbers,
|
8828
|
+
onRowDoubleClick = props.onRowDoubleClick,
|
8829
|
+
onRowContextMenu = props.onRowContextMenu,
|
8830
|
+
onCellClick = props.onCellClick,
|
8831
|
+
onCellDoubleClick = props.onCellDoubleClick,
|
8832
|
+
onCellEdit = props.onCellEdit,
|
8833
|
+
rowClassName = props.rowClassName,
|
8834
|
+
cellClassName = props.cellClassName,
|
8835
|
+
accessibility = props.accessibility;
|
8836
|
+
var rowClass = row.className;
|
8837
|
+
var _useState8 = React.useState(expanded),
|
8838
|
+
isInfoOpen = _useState8[0],
|
8839
|
+
toggleInfo = _useState8[1];
|
8840
|
+
var infoIcon = isInfoOpen ? 'expand_less' : 'expand_more';
|
8841
|
+
var style = isInfoOpen ? "expanded" : "";
|
8842
|
+
if (selected) style += " selected";
|
8843
|
+
var finalRowClassName = [style, rowClass, typeof rowClassName === 'function' ? rowClassName(row, index) : rowClassName].filter(Boolean).join(' ');
|
8844
|
+
var rowProps = accessibility ? {
|
8845
|
+
role: 'row',
|
8846
|
+
'aria-selected': selected,
|
8847
|
+
'aria-rowindex': index + 1,
|
8848
|
+
tabIndex: 0
|
8849
|
+
} : {};
|
8850
|
+
var handleRowClick = React.useCallback(function (ev) {
|
8851
|
+
onSelect(row, ev);
|
8852
|
+
}, [onSelect, row]);
|
8853
|
+
var handleRowDoubleClick = React.useCallback(function (ev) {
|
8854
|
+
if (onRowDoubleClick) onRowDoubleClick(row, ev);
|
8855
|
+
}, [onRowDoubleClick, row]);
|
8856
|
+
var handleRowContextMenu = React.useCallback(function (ev) {
|
8857
|
+
if (onRowContextMenu) onRowContextMenu(row, ev);
|
8858
|
+
}, [onRowContextMenu, row]);
|
8859
|
+
return /*#__PURE__*/React__default["default"].createElement(React.Fragment, null, /*#__PURE__*/React__default["default"].createElement("tr", _extends({
|
8860
|
+
className: finalRowClassName,
|
8861
|
+
onClick: handleRowClick,
|
8862
|
+
onDoubleClick: handleRowDoubleClick,
|
8863
|
+
onContextMenu: handleRowContextMenu
|
8864
|
+
}, rowProps), showRowNumbers && /*#__PURE__*/React__default["default"].createElement("td", {
|
8865
|
+
className: "datatable2__row-number"
|
8866
|
+
}, index + 1), columns.map(function (column, cindex) {
|
8867
|
+
return /*#__PURE__*/React__default["default"].createElement(DataTableCell2, {
|
8868
|
+
key: column.id + "_" + cindex,
|
8869
|
+
index: index,
|
8870
|
+
row: row,
|
8871
|
+
column: column,
|
8872
|
+
cell: row[column.id],
|
8873
|
+
editable: editable || column.editable,
|
8874
|
+
onCellClick: onCellClick,
|
8875
|
+
onCellDoubleClick: onCellDoubleClick,
|
8876
|
+
onCellEdit: onCellEdit,
|
8877
|
+
cellClassName: cellClassName,
|
8878
|
+
accessibility: accessibility
|
8879
|
+
});
|
8880
|
+
}), row.info ? /*#__PURE__*/React__default["default"].createElement("td", null, /*#__PURE__*/React__default["default"].createElement(Icon, {
|
8881
|
+
icon: infoIcon,
|
8882
|
+
clickable: true,
|
8883
|
+
action: function action() {
|
8884
|
+
return toggleInfo(!isInfoOpen);
|
8885
|
+
}
|
8886
|
+
})) : /*#__PURE__*/React__default["default"].createElement("td", null)), row.info && isInfoOpen ? /*#__PURE__*/React__default["default"].createElement("tr", {
|
8887
|
+
className: "table-row-info"
|
8888
|
+
}, /*#__PURE__*/React__default["default"].createElement("td", {
|
8889
|
+
colSpan: columns.length + (showRowNumbers ? 1 : 0) + 1
|
8890
|
+
}, isFunction$1(row.info) ? row.info() : row.info)) : null);
|
8891
|
+
};
|
8892
|
+
|
8893
|
+
/**
|
8894
|
+
* Enhanced Sort Icon - maintains original behavior
|
8895
|
+
*/
|
8896
|
+
var SortIcon2 = function SortIcon2(props) {
|
8897
|
+
var sortDir = props.sortDir,
|
8898
|
+
onChange = props.onChange;
|
8899
|
+
var icon = sortDir ? sortDir > 0 ? "arrow_upward" : "arrow_downward" : "swap_vert";
|
8900
|
+
return /*#__PURE__*/React__default["default"].createElement(Icon, {
|
8901
|
+
icon: icon,
|
8902
|
+
size: "small",
|
8903
|
+
clickable: true,
|
8904
|
+
action: onChange
|
8905
|
+
});
|
8906
|
+
};
|
8907
|
+
|
8908
|
+
/**
|
8909
|
+
* Enhanced column resize handler
|
8910
|
+
*/
|
8911
|
+
var handleColumnResize = function handleColumnResize(e, columnId, onColumnResize) {
|
8912
|
+
e.preventDefault();
|
8913
|
+
e.stopPropagation();
|
8914
|
+
var startX = e.clientX;
|
8915
|
+
var th = e.target.parentElement;
|
8916
|
+
var startWidth = th.offsetWidth;
|
8917
|
+
var handleMouseMove = function handleMouseMove(e) {
|
8918
|
+
var newWidth = Math.max(80, startWidth + (e.clientX - startX));
|
8919
|
+
|
8920
|
+
// Apply width directly to the element for immediate feedback
|
8921
|
+
th.style.width = newWidth + "px";
|
8922
|
+
|
8923
|
+
// Call external callback if provided
|
8924
|
+
if (onColumnResize) {
|
8925
|
+
onColumnResize(columnId, newWidth);
|
8926
|
+
}
|
8927
|
+
};
|
8928
|
+
var _handleMouseUp = function handleMouseUp() {
|
8929
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
8930
|
+
document.removeEventListener('mouseup', _handleMouseUp);
|
8931
|
+
document.body.style.cursor = 'default';
|
8932
|
+
document.body.style.userSelect = 'auto';
|
8933
|
+
};
|
8934
|
+
|
8935
|
+
// Prevent text selection during resize
|
8936
|
+
document.body.style.cursor = 'col-resize';
|
8937
|
+
document.body.style.userSelect = 'none';
|
8938
|
+
document.addEventListener('mousemove', handleMouseMove);
|
8939
|
+
document.addEventListener('mouseup', _handleMouseUp);
|
8940
|
+
};
|
8941
|
+
|
8942
|
+
/**
|
8943
|
+
* Enhanced DataTable Cell - maintains original structure and logic
|
8944
|
+
*/
|
8945
|
+
var DataTableCell2 = function DataTableCell2(_ref8) {
|
8946
|
+
var index = _ref8.index,
|
8947
|
+
row = _ref8.row,
|
8948
|
+
column = _ref8.column,
|
8949
|
+
cell = _ref8.cell,
|
8950
|
+
editable = _ref8.editable,
|
8951
|
+
onCellClick = _ref8.onCellClick,
|
8952
|
+
onCellDoubleClick = _ref8.onCellDoubleClick,
|
8953
|
+
cellClassName = _ref8.cellClassName,
|
8954
|
+
accessibility = _ref8.accessibility;
|
8955
|
+
var handleCellClick = React.useCallback(function (e) {
|
8956
|
+
if (onCellClick) onCellClick(row, column, cell, e);
|
8957
|
+
}, [onCellClick, row, column, cell]);
|
8958
|
+
var handleCellDoubleClick = React.useCallback(function (e) {
|
8959
|
+
if (onCellDoubleClick) onCellDoubleClick(row, column, cell, e);
|
8960
|
+
}, [onCellDoubleClick, row, column, cell]);
|
8961
|
+
var render = function render(type) {
|
8962
|
+
var id = column.id,
|
8963
|
+
_column$disabled = column.disabled,
|
8964
|
+
disabled = _column$disabled === void 0 ? false : _column$disabled,
|
8965
|
+
min = column.min,
|
8966
|
+
max = column.max,
|
8967
|
+
_onChange = column.onChange,
|
8968
|
+
format = column.format,
|
8969
|
+
options = column.options,
|
8970
|
+
action = column.action,
|
8971
|
+
maxDecimals = column.maxDecimals;
|
8972
|
+
if (id === "checked") {
|
8973
|
+
return row.checkDisabled ? null : /*#__PURE__*/React__default["default"].createElement(CheckBox, {
|
8974
|
+
id: id,
|
8975
|
+
value: cell,
|
8976
|
+
onChange: function onChange(id, value) {
|
8977
|
+
return _onChange(row.id, id, value);
|
8978
|
+
}
|
8979
|
+
});
|
8980
|
+
} else if (editable && _onChange) {
|
8981
|
+
switch (type) {
|
8982
|
+
case "ICON":
|
8983
|
+
return /*#__PURE__*/React__default["default"].createElement(Icon, {
|
8984
|
+
icon: cell
|
8985
|
+
});
|
8986
|
+
case "BOOLEAN":
|
8987
|
+
return /*#__PURE__*/React__default["default"].createElement(CheckBox, {
|
8988
|
+
id: id,
|
8989
|
+
value: cell,
|
8990
|
+
onChange: function onChange(id, value) {
|
8991
|
+
return _onChange(row.id, id, value);
|
8992
|
+
},
|
8993
|
+
disabled: disabled
|
8994
|
+
});
|
8995
|
+
case "Boolean":
|
8996
|
+
return /*#__PURE__*/React__default["default"].createElement(CheckBox, {
|
8997
|
+
id: id,
|
8998
|
+
value: cell,
|
8999
|
+
onChange: function onChange(id, value) {
|
9000
|
+
return _onChange(row.id, id, value);
|
9001
|
+
},
|
9002
|
+
disabled: disabled
|
9003
|
+
});
|
9004
|
+
case "SELECTION":
|
9005
|
+
return /*#__PURE__*/React__default["default"].createElement(DropDown2, {
|
9006
|
+
id: id,
|
9007
|
+
value: cell,
|
9008
|
+
placeholder: "--Select--",
|
9009
|
+
options: options,
|
9010
|
+
onChange: function onChange(id, value) {
|
9011
|
+
return _onChange(row.id, id, value);
|
9012
|
+
}
|
9013
|
+
});
|
9014
|
+
case "CHECK":
|
9015
|
+
return /*#__PURE__*/React__default["default"].createElement(CheckBox, {
|
9016
|
+
id: id,
|
9017
|
+
value: cell,
|
9018
|
+
onChange: function onChange(id, value) {
|
9019
|
+
return _onChange(row.id, id, value);
|
9020
|
+
},
|
9021
|
+
disabled: row.disabled
|
9022
|
+
});
|
9023
|
+
case "CHECKABLE":
|
9024
|
+
return cell && cell.value ? /*#__PURE__*/React__default["default"].createElement(CheckBox, {
|
9025
|
+
id: id,
|
9026
|
+
value: cell.checked || false,
|
9027
|
+
label: cell.value,
|
9028
|
+
onChange: function onChange(id, checked) {
|
9029
|
+
return _onChange(row.id, id, cell.value, checked, cell);
|
9030
|
+
}
|
9031
|
+
}) : '';
|
9032
|
+
case "TEXTFIELD":
|
9033
|
+
return /*#__PURE__*/React__default["default"].createElement(TextField2, {
|
9034
|
+
id: id,
|
9035
|
+
value: cell,
|
9036
|
+
onChange: function onChange(id, value) {
|
9037
|
+
return _onChange(row.id, id, value);
|
9038
|
+
}
|
9039
|
+
});
|
9040
|
+
case "String":
|
9041
|
+
return /*#__PURE__*/React__default["default"].createElement(StringCellEditor2, {
|
9042
|
+
id: id,
|
9043
|
+
value: cell,
|
9044
|
+
options: options,
|
9045
|
+
onChange: function onChange(id, value) {
|
9046
|
+
return _onChange(row.id, id, value);
|
9047
|
+
}
|
9048
|
+
});
|
9049
|
+
case "Number":
|
9050
|
+
return /*#__PURE__*/React__default["default"].createElement(TextField2, {
|
9051
|
+
id: id,
|
9052
|
+
type: "number",
|
9053
|
+
value: cell,
|
9054
|
+
min: min,
|
9055
|
+
max: max,
|
9056
|
+
maxDecimals: column.maxDecimals,
|
9057
|
+
onChange: function onChange(id, value) {
|
9058
|
+
return _onChange(row.id, id, value);
|
9059
|
+
}
|
9060
|
+
});
|
9061
|
+
case "Image":
|
9062
|
+
return /*#__PURE__*/React__default["default"].createElement(ImageCellViewer2, {
|
9063
|
+
id: row.id,
|
9064
|
+
value: cell,
|
9065
|
+
uploadURL: column.uploadURL,
|
9066
|
+
onChange: column.onChange
|
9067
|
+
});
|
9068
|
+
default:
|
9069
|
+
return cell;
|
9070
|
+
}
|
9071
|
+
} else {
|
9072
|
+
switch (type) {
|
9073
|
+
case "INDEX":
|
9074
|
+
return /*#__PURE__*/React__default["default"].createElement("span", null, index);
|
9075
|
+
case "ICON":
|
9076
|
+
return /*#__PURE__*/React__default["default"].createElement(Icon, {
|
9077
|
+
icon: cell
|
9078
|
+
});
|
9079
|
+
case "Boolean":
|
9080
|
+
return /*#__PURE__*/React__default["default"].createElement(BooleanCellViewer2, {
|
9081
|
+
id: id,
|
9082
|
+
value: cell
|
9083
|
+
});
|
9084
|
+
case "String":
|
9085
|
+
return /*#__PURE__*/React__default["default"].createElement(StringCellViewer2, {
|
9086
|
+
id: id,
|
9087
|
+
value: cell,
|
9088
|
+
format: format,
|
9089
|
+
options: options,
|
9090
|
+
action: action
|
9091
|
+
});
|
9092
|
+
case "Number":
|
9093
|
+
return /*#__PURE__*/React__default["default"].createElement(NumberCellViewer2, {
|
9094
|
+
id: id,
|
9095
|
+
value: cell,
|
9096
|
+
format: format,
|
9097
|
+
maxDecimals: maxDecimals
|
9098
|
+
});
|
9099
|
+
case "Image":
|
9100
|
+
return /*#__PURE__*/React__default["default"].createElement("img", {
|
9101
|
+
src: cell,
|
9102
|
+
alt: ""
|
9103
|
+
});
|
9104
|
+
case "DATETIME":
|
9105
|
+
var locale = window.navigator.userLanguage || window.navigator.language;
|
9106
|
+
var date = new Date(cell);
|
9107
|
+
date.setMinutes(date.getMinutes() + date.getTimezoneOffset() + 1);
|
9108
|
+
return /*#__PURE__*/React__default["default"].createElement("span", null, date.toLocaleString(locale, {
|
9109
|
+
year: 'numeric',
|
9110
|
+
month: 'numeric',
|
9111
|
+
day: 'numeric',
|
9112
|
+
hour: 'numeric',
|
9113
|
+
minute: 'numeric',
|
9114
|
+
second: 'numeric'
|
9115
|
+
}));
|
9116
|
+
default:
|
9117
|
+
return cell;
|
9118
|
+
}
|
9119
|
+
}
|
9120
|
+
};
|
9121
|
+
var finalCellClassName = [column.id, typeof cellClassName === 'function' ? cellClassName(row, column, cell) : cellClassName].filter(Boolean).join(' ');
|
9122
|
+
var cellProps = accessibility ? {
|
9123
|
+
role: 'cell',
|
9124
|
+
'aria-describedby': column.label ? column.id + "-header" : undefined,
|
9125
|
+
tabIndex: editable ? 0 : -1
|
9126
|
+
} : {};
|
9127
|
+
return column.type === TYPES$1.ENTITY ? /*#__PURE__*/React__default["default"].createElement(EntityCellViewer2, {
|
9128
|
+
id: column.id,
|
9129
|
+
item: column.item,
|
9130
|
+
value: cell
|
9131
|
+
}) : /*#__PURE__*/React__default["default"].createElement("td", _extends({
|
9132
|
+
key: column.id,
|
9133
|
+
className: finalCellClassName,
|
9134
|
+
onClick: handleCellClick,
|
9135
|
+
onDoubleClick: handleCellDoubleClick
|
9136
|
+
}, cellProps), render(column.type));
|
9137
|
+
};
|
9138
|
+
|
9139
|
+
// Import and re-export original cell viewers with enhanced versions
|
9140
|
+
// These maintain 100% compatibility while adding new features
|
9141
|
+
|
9142
|
+
/**
|
9143
|
+
* Enhanced Image Cell Viewer
|
9144
|
+
*/
|
9145
|
+
var ImageCellViewer2 = function ImageCellViewer2(_ref9) {
|
9146
|
+
var id = _ref9.id,
|
9147
|
+
value = _ref9.value,
|
9148
|
+
uploadURL = _ref9.uploadURL,
|
9149
|
+
onChange = _ref9.onChange;
|
9150
|
+
function success(file, message) {
|
9151
|
+
if (onChange) onChange(id, file, message);
|
9152
|
+
}
|
9153
|
+
function error(file, message) {
|
9154
|
+
if (onChange) onChange(id, file, message);
|
9155
|
+
console.error(message);
|
9156
|
+
}
|
9157
|
+
return uploadURL ? /*#__PURE__*/React__default["default"].createElement("div", {
|
9158
|
+
className: "image-cell"
|
9159
|
+
}, value ? /*#__PURE__*/React__default["default"].createElement("img", {
|
9160
|
+
src: value,
|
9161
|
+
alt: ""
|
9162
|
+
}) : /*#__PURE__*/React__default["default"].createElement(Icon, {
|
9163
|
+
icon: "person"
|
9164
|
+
}), /*#__PURE__*/React__default["default"].createElement(Uploader, {
|
9165
|
+
view: "icon",
|
9166
|
+
icon: "cloud_upload",
|
9167
|
+
target: uploadURL,
|
9168
|
+
onSuccess: success,
|
9169
|
+
onError: error
|
9170
|
+
})) : /*#__PURE__*/React__default["default"].createElement("div", {
|
9171
|
+
className: "image-cell"
|
9172
|
+
}, value ? /*#__PURE__*/React__default["default"].createElement("img", {
|
9173
|
+
src: value,
|
9174
|
+
alt: ""
|
9175
|
+
}) : /*#__PURE__*/React__default["default"].createElement(Icon, {
|
9176
|
+
icon: "person"
|
9177
|
+
}));
|
9178
|
+
};
|
9179
|
+
|
9180
|
+
/**
|
9181
|
+
* Enhanced Entity Cell Viewer
|
9182
|
+
*/
|
9183
|
+
var EntityCellViewer2 = function EntityCellViewer2(_ref0) {
|
9184
|
+
var item = _ref0.item,
|
9185
|
+
value = _ref0.value;
|
9186
|
+
var fields = Object.values(item).filter(function (field) {
|
9187
|
+
return field.column === true;
|
9188
|
+
});
|
9189
|
+
var locale = window.navigator.userLanguage || window.navigator.language;
|
9190
|
+
return fields.map(function (field) {
|
9191
|
+
var text = value[field.id];
|
9192
|
+
if (field.format) {
|
9193
|
+
switch (field.format) {
|
9194
|
+
case FORMATS$1.COLOR:
|
9195
|
+
text = /*#__PURE__*/React__default["default"].createElement("input", {
|
9196
|
+
type: "color",
|
9197
|
+
value: text,
|
9198
|
+
disabled: true
|
9199
|
+
});
|
9200
|
+
break;
|
9201
|
+
case FORMATS$1.URL:
|
9202
|
+
text = /*#__PURE__*/React__default["default"].createElement("a", {
|
9203
|
+
href: text,
|
9204
|
+
target: "download",
|
9205
|
+
download: true
|
9206
|
+
}, text);
|
9207
|
+
break;
|
9208
|
+
case FORMATS$1.IMG:
|
9209
|
+
text = /*#__PURE__*/React__default["default"].createElement("img", {
|
9210
|
+
src: text,
|
9211
|
+
alt: ""
|
9212
|
+
});
|
9213
|
+
break;
|
9214
|
+
case FORMATS$1.DATE:
|
9215
|
+
var fecha = new Date(text);
|
9216
|
+
fecha.setMinutes(fecha.getMinutes() + fecha.getTimezoneOffset() + 1);
|
9217
|
+
text = fecha.toLocaleString(locale, {
|
9218
|
+
day: 'numeric',
|
9219
|
+
month: 'numeric',
|
9220
|
+
year: 'numeric'
|
9221
|
+
});
|
9222
|
+
break;
|
9223
|
+
case FORMATS$1.TIME:
|
9224
|
+
text = new Date(text).toLocaleString(locale, {
|
9225
|
+
hour: 'numeric',
|
9226
|
+
minute: 'numeric',
|
9227
|
+
second: 'numeric'
|
9228
|
+
});
|
9229
|
+
break;
|
9230
|
+
case FORMATS$1.DATETIME:
|
9231
|
+
text = new Date(text).toLocaleString(locale, {
|
9232
|
+
year: 'numeric',
|
9233
|
+
month: 'numeric',
|
9234
|
+
day: 'numeric',
|
9235
|
+
hour: 'numeric',
|
9236
|
+
minute: 'numeric',
|
9237
|
+
second: 'numeric'
|
9238
|
+
});
|
9239
|
+
break;
|
9240
|
+
}
|
9241
|
+
}
|
9242
|
+
return /*#__PURE__*/React__default["default"].createElement("td", {
|
9243
|
+
key: field.id,
|
9244
|
+
className: "entity-cell " + field.id
|
9245
|
+
}, text);
|
9246
|
+
});
|
9247
|
+
};
|
9248
|
+
|
9249
|
+
/**
|
9250
|
+
* Enhanced Boolean Cell Viewer
|
9251
|
+
*/
|
9252
|
+
var BooleanCellViewer2 = function BooleanCellViewer2(_ref1) {
|
9253
|
+
var _ref1$value = _ref1.value,
|
9254
|
+
value = _ref1$value === void 0 ? false : _ref1$value;
|
9255
|
+
var icon = value === true ? "check_box" : "check_box_outline_blank";
|
9256
|
+
return /*#__PURE__*/React__default["default"].createElement(Icon, {
|
9257
|
+
icon: icon
|
9258
|
+
});
|
9259
|
+
};
|
9260
|
+
|
9261
|
+
/**
|
9262
|
+
* Enhanced Number Cell Viewer
|
9263
|
+
*/
|
9264
|
+
var NumberCellViewer2 = function NumberCellViewer2(_ref10) {
|
9265
|
+
var value = _ref10.value,
|
9266
|
+
format = _ref10.format,
|
9267
|
+
maxDecimals = _ref10.maxDecimals;
|
9268
|
+
function formatNumber(number, maxDecimals) {
|
9269
|
+
if (maxDecimals === void 0) {
|
9270
|
+
maxDecimals = 0;
|
9271
|
+
}
|
9272
|
+
if (number === null) return "null";
|
9273
|
+
var result = number.toLocaleString('es-ES', {
|
9274
|
+
minimumFractionDigits: 2,
|
9275
|
+
maximumFractionDigits: 2
|
9276
|
+
});
|
9277
|
+
var parts = result.toString().split(",");
|
9278
|
+
var numberPart = parts[0];
|
9279
|
+
var decimalPart = parts[1];
|
9280
|
+
var thousands = /\B(?=(\d{3})+(?!\d))/g;
|
9281
|
+
var decimal = decimalPart ? decimalPart.substring(0, maxDecimals) : null;
|
9282
|
+
return numberPart.replace(thousands, ".") + (decimal ? "," + decimal : "");
|
9283
|
+
}
|
9284
|
+
if (format) {
|
9285
|
+
switch (format) {
|
9286
|
+
case FORMATS$1.CURRENCY:
|
9287
|
+
return /*#__PURE__*/React__default["default"].createElement("span", null, value.toLocaleString('es-ES', {
|
9288
|
+
style: 'currency',
|
9289
|
+
currency: 'EUR'
|
9290
|
+
}));
|
9291
|
+
case FORMATS$1.PERCENT:
|
9292
|
+
return /*#__PURE__*/React__default["default"].createElement("span", null, value.toLocaleString('es-ES', {
|
9293
|
+
style: 'percent',
|
9294
|
+
minimumFractionDigits: 2
|
9295
|
+
}));
|
9296
|
+
case "ES_es":
|
9297
|
+
var number = Number(value);
|
9298
|
+
if (isNaN(number)) return value;
|
9299
|
+
return /*#__PURE__*/React__default["default"].createElement("span", null, formatNumber(number, maxDecimals));
|
9300
|
+
default:
|
9301
|
+
return /*#__PURE__*/React__default["default"].createElement("span", null, value);
|
9302
|
+
}
|
9303
|
+
} else {
|
9304
|
+
var decimals = maxDecimals ? maxDecimals : 2;
|
9305
|
+
if (typeof value === "string") {
|
9306
|
+
value = parseFloat(value);
|
9307
|
+
}
|
9308
|
+
return value && !isNaN(value) ? /*#__PURE__*/React__default["default"].createElement("span", null, value.toFixed(decimals)) : "";
|
9309
|
+
}
|
9310
|
+
};
|
9311
|
+
|
9312
|
+
/**
|
9313
|
+
* Enhanced String Cell Viewer
|
9314
|
+
*/
|
9315
|
+
var StringCellViewer2 = function StringCellViewer2(_ref11) {
|
9316
|
+
var id = _ref11.id,
|
9317
|
+
value = _ref11.value,
|
9318
|
+
format = _ref11.format,
|
9319
|
+
options = _ref11.options,
|
9320
|
+
action = _ref11.action;
|
9321
|
+
function buildOptions() {
|
9322
|
+
var opts = typeof options === 'function' ? options() : options;
|
9323
|
+
return opts;
|
9324
|
+
}
|
9325
|
+
function onClick() {
|
9326
|
+
if (action) action(id, value, format, options);
|
9327
|
+
}
|
9328
|
+
var option = options ? buildOptions().find(function (o) {
|
9329
|
+
return o.value === value;
|
9330
|
+
}) : null;
|
9331
|
+
var text = option ? option.label : value;
|
9332
|
+
var className = option ? option.className : '';
|
9333
|
+
var locale = window.navigator.userLanguage || window.navigator.language;
|
9334
|
+
switch (format) {
|
9335
|
+
case FORMATS$1.TOKENS:
|
9336
|
+
text = value && Array.isArray(value) ? value.join(", ") : value;
|
9337
|
+
break;
|
9338
|
+
case FORMATS$1.COLOR:
|
9339
|
+
text = /*#__PURE__*/React__default["default"].createElement("input", {
|
9340
|
+
type: "color",
|
9341
|
+
value: text,
|
9342
|
+
disabled: true
|
9343
|
+
});
|
9344
|
+
break;
|
9345
|
+
case FORMATS$1.URL:
|
9346
|
+
text = /*#__PURE__*/React__default["default"].createElement("a", {
|
9347
|
+
href: text,
|
9348
|
+
target: "download",
|
9349
|
+
download: true
|
9350
|
+
}, text);
|
9351
|
+
break;
|
9352
|
+
case FORMATS$1.IMG:
|
9353
|
+
text = /*#__PURE__*/React__default["default"].createElement("img", {
|
9354
|
+
src: text,
|
9355
|
+
onClick: onClick,
|
9356
|
+
alt: ""
|
9357
|
+
});
|
9358
|
+
break;
|
9359
|
+
case FORMATS$1.DATE:
|
9360
|
+
var fecha = new Date(text);
|
9361
|
+
fecha.setMinutes(fecha.getMinutes() + fecha.getTimezoneOffset() + 1);
|
9362
|
+
text = fecha.toLocaleString(locale, {
|
9363
|
+
day: 'numeric',
|
9364
|
+
month: 'numeric',
|
9365
|
+
year: 'numeric'
|
9366
|
+
});
|
9367
|
+
break;
|
9368
|
+
case FORMATS$1.TIME:
|
9369
|
+
text = new Date(text).toLocaleString(locale, {
|
9370
|
+
hour: 'numeric',
|
9371
|
+
minute: 'numeric',
|
9372
|
+
second: 'numeric'
|
9373
|
+
});
|
9374
|
+
break;
|
9375
|
+
case FORMATS$1.DATETIME:
|
9376
|
+
text = new Date(text).toLocaleString(locale, {
|
9377
|
+
year: 'numeric',
|
9378
|
+
month: 'numeric',
|
9379
|
+
day: 'numeric',
|
9380
|
+
hour: 'numeric',
|
9381
|
+
minute: 'numeric',
|
9382
|
+
second: 'numeric'
|
9383
|
+
});
|
9384
|
+
break;
|
9385
|
+
}
|
9386
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
9387
|
+
className: "field-editor string-viewer " + className,
|
9388
|
+
title: text
|
9389
|
+
}, text);
|
9390
|
+
};
|
9391
|
+
|
9392
|
+
/**
|
9393
|
+
* Enhanced String Cell Editor
|
9394
|
+
*/
|
9395
|
+
var StringCellEditor2 = function StringCellEditor2(_ref12) {
|
9396
|
+
var id = _ref12.id,
|
9397
|
+
_ref12$value = _ref12.value,
|
9398
|
+
value = _ref12$value === void 0 ? '' : _ref12$value,
|
9399
|
+
options = _ref12.options,
|
9400
|
+
onChange = _ref12.onChange;
|
9401
|
+
function change(id, value) {
|
9402
|
+
if (onChange) onChange(id, value);
|
9403
|
+
}
|
9404
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
9405
|
+
className: "field-editor string-editor"
|
9406
|
+
}, options ? /*#__PURE__*/React__default["default"].createElement(DropDown2, {
|
9407
|
+
outlined: true,
|
9408
|
+
id: id,
|
9409
|
+
value: value,
|
9410
|
+
onChange: change,
|
9411
|
+
options: options
|
9412
|
+
}) : /*#__PURE__*/React__default["default"].createElement(TextField2, {
|
9413
|
+
outlined: true,
|
9414
|
+
id: id,
|
9415
|
+
value: value,
|
9416
|
+
onChange: change
|
9417
|
+
}));
|
9418
|
+
};
|
9419
|
+
|
9420
|
+
/**
|
9421
|
+
* Skeleton loading table
|
9422
|
+
*/
|
9423
|
+
var SkeletonTable = function SkeletonTable(_ref13) {
|
9424
|
+
var columns = _ref13.columns,
|
9425
|
+
rows = _ref13.rows;
|
9426
|
+
return /*#__PURE__*/React__default["default"].createElement("table", null, /*#__PURE__*/React__default["default"].createElement("thead", null, /*#__PURE__*/React__default["default"].createElement("tr", null, columns.map(function (col) {
|
9427
|
+
return /*#__PURE__*/React__default["default"].createElement("th", {
|
9428
|
+
key: col.id
|
9429
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
9430
|
+
className: "skeleton-text skeleton-text--header"
|
9431
|
+
}));
|
9432
|
+
}))), /*#__PURE__*/React__default["default"].createElement("tbody", null, Array.from({
|
9433
|
+
length: rows
|
9434
|
+
}, function (_, i) {
|
9435
|
+
return /*#__PURE__*/React__default["default"].createElement("tr", {
|
9436
|
+
key: i
|
9437
|
+
}, columns.map(function (col) {
|
9438
|
+
return /*#__PURE__*/React__default["default"].createElement("td", {
|
9439
|
+
key: col.id
|
9440
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
9441
|
+
className: "skeleton-text"
|
9442
|
+
}));
|
9443
|
+
}));
|
9444
|
+
})));
|
9445
|
+
};
|
9446
|
+
|
9447
|
+
// PropTypes for DataTable2
|
9448
|
+
DataTable2.propTypes = {
|
9449
|
+
// Original props (100% compatible)
|
9450
|
+
/** Array of column definitions */
|
9451
|
+
columns: PropTypes.arrayOf(PropTypes.shape({
|
9452
|
+
id: PropTypes.string.isRequired,
|
9453
|
+
label: PropTypes.string,
|
9454
|
+
type: PropTypes.string,
|
9455
|
+
sortable: PropTypes.bool,
|
9456
|
+
filterable: PropTypes.bool,
|
9457
|
+
resizable: PropTypes.bool,
|
9458
|
+
editable: PropTypes.bool,
|
9459
|
+
format: PropTypes.string,
|
9460
|
+
options: PropTypes.array,
|
9461
|
+
onChange: PropTypes.func,
|
9462
|
+
onFilter: PropTypes.func,
|
9463
|
+
action: PropTypes.func,
|
9464
|
+
disabled: PropTypes.bool,
|
9465
|
+
min: PropTypes.number,
|
9466
|
+
max: PropTypes.number,
|
9467
|
+
maxDecimals: PropTypes.number,
|
9468
|
+
predictive: PropTypes.bool,
|
9469
|
+
item: PropTypes.object,
|
9470
|
+
uploadURL: PropTypes.string
|
9471
|
+
})),
|
9472
|
+
/** Array of row data */
|
9473
|
+
rows: PropTypes.arrayOf(PropTypes.shape({
|
9474
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
9475
|
+
selected: PropTypes.bool,
|
9476
|
+
className: PropTypes.string,
|
9477
|
+
checkDisabled: PropTypes.bool,
|
9478
|
+
disabled: PropTypes.bool,
|
9479
|
+
info: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
|
9480
|
+
})),
|
9481
|
+
/** Row selection callback */
|
9482
|
+
onRowSelection: PropTypes.func,
|
9483
|
+
/** Sort callback */
|
9484
|
+
onSort: PropTypes.func,
|
9485
|
+
/** Check all callback */
|
9486
|
+
onCheckAll: PropTypes.func,
|
9487
|
+
/** Enable editing */
|
9488
|
+
editable: PropTypes.bool,
|
9489
|
+
/** Outlined style */
|
9490
|
+
outlined: PropTypes.bool,
|
9491
|
+
/** Expand rows by default */
|
9492
|
+
expanded: PropTypes.bool,
|
9493
|
+
/** Additional CSS classes */
|
9494
|
+
className: PropTypes.string,
|
9495
|
+
/** Empty state message */
|
9496
|
+
emptyMessage: PropTypes.string,
|
9497
|
+
/** Empty state icon */
|
9498
|
+
emptyIcon: PropTypes.string,
|
9499
|
+
/** Enable multi-sort */
|
9500
|
+
multisort: PropTypes.bool,
|
9501
|
+
/** Enable filtering */
|
9502
|
+
filterable: PropTypes.bool,
|
9503
|
+
/** Clear filters callback */
|
9504
|
+
onClearFilters: PropTypes.func,
|
9505
|
+
// New enhanced props (all optional for compatibility)
|
9506
|
+
/** Loading state */
|
9507
|
+
loading: PropTypes.bool,
|
9508
|
+
/** Skeleton placeholder */
|
9509
|
+
skeleton: PropTypes.bool,
|
9510
|
+
/** Striped rows */
|
9511
|
+
striped: PropTypes.bool,
|
9512
|
+
/** Hover effects */
|
9513
|
+
hover: PropTypes.bool,
|
9514
|
+
/** Compact layout */
|
9515
|
+
compact: PropTypes.bool,
|
9516
|
+
/** Bordered table */
|
9517
|
+
bordered: PropTypes.bool,
|
9518
|
+
/** Responsive design */
|
9519
|
+
responsive: PropTypes.bool,
|
9520
|
+
/** Sticky header */
|
9521
|
+
stickyHeader: PropTypes.bool,
|
9522
|
+
/** Virtual scrolling */
|
9523
|
+
virtualScrolling: PropTypes.bool,
|
9524
|
+
/** Page size for virtual scrolling */
|
9525
|
+
pageSize: PropTypes.number,
|
9526
|
+
/** Selection mode */
|
9527
|
+
selectionMode: PropTypes.oneOf(['single', 'multiple', 'none']),
|
9528
|
+
/** Sort mode */
|
9529
|
+
sortMode: PropTypes.oneOf(['single', 'multiple', 'none']),
|
9530
|
+
/** Resizable columns */
|
9531
|
+
resizable: PropTypes.bool,
|
9532
|
+
/** Reorderable columns */
|
9533
|
+
reorderable: PropTypes.bool,
|
9534
|
+
/** Export functionality */
|
9535
|
+
exportable: PropTypes.bool,
|
9536
|
+
/** Search functionality */
|
9537
|
+
searchable: PropTypes.bool,
|
9538
|
+
/** Search placeholder */
|
9539
|
+
searchPlaceholder: PropTypes.string,
|
9540
|
+
/** Search callback */
|
9541
|
+
onSearch: PropTypes.func,
|
9542
|
+
/** Export callback */
|
9543
|
+
onExport: PropTypes.func,
|
9544
|
+
/** Column resize callback */
|
9545
|
+
onColumnResize: PropTypes.func,
|
9546
|
+
/** Column reorder callback */
|
9547
|
+
onColumnReorder: PropTypes.func,
|
9548
|
+
/** Custom empty state */
|
9549
|
+
customEmptyState: PropTypes.node,
|
9550
|
+
/** Row height */
|
9551
|
+
rowHeight: PropTypes.oneOf(['small', 'medium', 'large']),
|
9552
|
+
/** Table density */
|
9553
|
+
density: PropTypes.oneOf(['compact', 'normal', 'comfortable']),
|
9554
|
+
/** Theme */
|
9555
|
+
theme: PropTypes.oneOf(['default', 'dark', 'minimal']),
|
9556
|
+
/** Accessibility features */
|
9557
|
+
accessibility: PropTypes.bool,
|
9558
|
+
/** Row click callback */
|
9559
|
+
onRowClick: PropTypes.func,
|
9560
|
+
/** Row double click callback */
|
9561
|
+
onRowDoubleClick: PropTypes.func,
|
9562
|
+
/** Row context menu callback */
|
9563
|
+
onRowContextMenu: PropTypes.func,
|
9564
|
+
/** Cell click callback */
|
9565
|
+
onCellClick: PropTypes.func,
|
9566
|
+
/** Cell double click callback */
|
9567
|
+
onCellDoubleClick: PropTypes.func,
|
9568
|
+
/** Cell edit callback */
|
9569
|
+
onCellEdit: PropTypes.func,
|
9570
|
+
/** Row class name function */
|
9571
|
+
rowClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
9572
|
+
/** Cell class name function */
|
9573
|
+
cellClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
9574
|
+
/** Header class name */
|
9575
|
+
headerClassName: PropTypes.string,
|
9576
|
+
/** Footer content */
|
9577
|
+
footerContent: PropTypes.node,
|
9578
|
+
/** Show row numbers */
|
9579
|
+
showRowNumbers: PropTypes.bool,
|
9580
|
+
/** Show select all checkbox */
|
9581
|
+
showSelectAll: PropTypes.bool,
|
9582
|
+
/** Persist table state */
|
9583
|
+
persistState: PropTypes.bool,
|
9584
|
+
/** State key for persistence */
|
9585
|
+
stateKey: PropTypes.string,
|
9586
|
+
/** State change callback */
|
9587
|
+
onStateChange: PropTypes.func
|
9588
|
+
};
|
9589
|
+
DataTable2.defaultProps = {
|
9590
|
+
columns: [],
|
9591
|
+
rows: [],
|
9592
|
+
expanded: false,
|
9593
|
+
emptyMessage: "No Results Found",
|
9594
|
+
emptyIcon: "search_off",
|
9595
|
+
multisort: false,
|
9596
|
+
filterable: false,
|
9597
|
+
loading: false,
|
9598
|
+
skeleton: false,
|
9599
|
+
striped: false,
|
9600
|
+
hover: true,
|
9601
|
+
compact: false,
|
9602
|
+
bordered: false,
|
9603
|
+
responsive: true,
|
9604
|
+
stickyHeader: true,
|
9605
|
+
virtualScrolling: false,
|
9606
|
+
pageSize: 50,
|
9607
|
+
selectionMode: 'single',
|
9608
|
+
sortMode: 'single',
|
9609
|
+
resizable: false,
|
9610
|
+
reorderable: false,
|
9611
|
+
exportable: false,
|
9612
|
+
searchable: false,
|
9613
|
+
searchPlaceholder: "Search...",
|
9614
|
+
rowHeight: 'medium',
|
9615
|
+
density: 'normal',
|
9616
|
+
theme: 'default',
|
9617
|
+
accessibility: true,
|
9618
|
+
showRowNumbers: false,
|
9619
|
+
showSelectAll: true,
|
9620
|
+
persistState: false
|
9621
|
+
};
|
9622
|
+
|
9623
|
+
var _excluded$5 = ["id", "label", "tokens", "readOnly", "options", "predictive", "onChange", "disabled", "required", "placeholder", "maxTokens", "minTokens", "allowDuplicates", "validateToken", "tokenSeparators", "size", "variant", "error", "helperText", "onFocus", "onBlur", "onTokenAdd", "onTokenRemove", "onValidationError", "clearable", "onClear", "searchable", "sortable", "className", "style"],
|
9624
|
+
_excluded2$2 = ["text", "onDelete", "disabled", "error", "size", "variant", "icon", "className", "style"];
|
9625
|
+
|
9626
|
+
/**
|
9627
|
+
* Enhanced Token Field component with improved functionality while maintaining 100% compatibility
|
9628
|
+
*/
|
9629
|
+
var TokenField = function TokenField(props) {
|
9630
|
+
var id = props.id,
|
9631
|
+
label = props.label,
|
9632
|
+
_props$tokens = props.tokens,
|
9633
|
+
tokens = _props$tokens === void 0 ? [] : _props$tokens,
|
9634
|
+
readOnly = props.readOnly,
|
9635
|
+
options = props.options,
|
9636
|
+
_props$predictive = props.predictive,
|
9637
|
+
predictive = _props$predictive === void 0 ? true : _props$predictive,
|
9638
|
+
onChange = props.onChange,
|
9639
|
+
_props$disabled = props.disabled,
|
9640
|
+
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
9641
|
+
_props$required = props.required,
|
9642
|
+
required = _props$required === void 0 ? false : _props$required,
|
9643
|
+
_props$placeholder = props.placeholder,
|
9644
|
+
placeholder = _props$placeholder === void 0 ? "Add token..." : _props$placeholder,
|
9645
|
+
maxTokens = props.maxTokens,
|
9646
|
+
_props$minTokens = props.minTokens,
|
9647
|
+
minTokens = _props$minTokens === void 0 ? 0 : _props$minTokens,
|
9648
|
+
_props$allowDuplicate = props.allowDuplicates,
|
9649
|
+
allowDuplicates = _props$allowDuplicate === void 0 ? true : _props$allowDuplicate,
|
9650
|
+
validateToken = props.validateToken,
|
9651
|
+
_props$tokenSeparator = props.tokenSeparators,
|
9652
|
+
tokenSeparators = _props$tokenSeparator === void 0 ? [',', ';', '\n'] : _props$tokenSeparator,
|
9653
|
+
_props$size = props.size,
|
9654
|
+
size = _props$size === void 0 ? 'medium' : _props$size,
|
9655
|
+
_props$variant = props.variant,
|
9656
|
+
variant = _props$variant === void 0 ? 'default' : _props$variant,
|
9657
|
+
error = props.error,
|
9658
|
+
helperText = props.helperText,
|
9659
|
+
onFocus = props.onFocus,
|
9660
|
+
onBlur = props.onBlur,
|
9661
|
+
onTokenAdd = props.onTokenAdd,
|
9662
|
+
onTokenRemove = props.onTokenRemove,
|
9663
|
+
onValidationError = props.onValidationError,
|
9664
|
+
_props$clearable = props.clearable,
|
9665
|
+
clearable = _props$clearable === void 0 ? false : _props$clearable,
|
9666
|
+
onClear = props.onClear,
|
9667
|
+
_props$searchable = props.searchable,
|
9668
|
+
searchable = _props$searchable === void 0 ? false : _props$searchable,
|
9669
|
+
_props$sortable = props.sortable,
|
9670
|
+
sortable = _props$sortable === void 0 ? false : _props$sortable,
|
9671
|
+
className = props.className,
|
9672
|
+
style = props.style,
|
9673
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded$5);
|
9674
|
+
var _useState = React.useState(''),
|
9675
|
+
value = _useState[0],
|
9676
|
+
setValue = _useState[1];
|
9677
|
+
var _useState2 = React.useState(false),
|
9678
|
+
isFocused = _useState2[0],
|
9679
|
+
setIsFocused = _useState2[1];
|
9680
|
+
var _useState3 = React.useState({}),
|
9681
|
+
validationErrors = _useState3[0],
|
9682
|
+
setValidationErrors = _useState3[1];
|
9683
|
+
var inputRef = React.useRef(null);
|
9684
|
+
var containerRef = React.useRef(null);
|
9685
|
+
|
9686
|
+
// Validate props
|
9687
|
+
React.useEffect(function () {
|
9688
|
+
if (!Array.isArray(tokens)) {
|
9689
|
+
console.warn('TokenField: tokens prop must be an array');
|
9690
|
+
}
|
9691
|
+
if (maxTokens && tokens.length > maxTokens) {
|
9692
|
+
console.warn("TokenField: tokens count (" + tokens.length + ") exceeds maxTokens (" + maxTokens + ")");
|
9693
|
+
}
|
9694
|
+
if (minTokens && tokens.length < minTokens) {
|
9695
|
+
console.warn("TokenField: tokens count (" + tokens.length + ") is below minTokens (" + minTokens + ")");
|
9696
|
+
}
|
9697
|
+
}, [tokens, maxTokens, minTokens]);
|
9698
|
+
|
9699
|
+
// Enhanced remove function (maintaining original behavior)
|
9700
|
+
var remove = React.useCallback(function (index) {
|
9701
|
+
if (disabled || readOnly) return;
|
9702
|
+
var next = tokens.slice();
|
9703
|
+
var removedToken = next.splice(index, 1)[0];
|
9704
|
+
|
9705
|
+
// Check minimum tokens
|
9706
|
+
if (minTokens && next.length < minTokens) {
|
9707
|
+
console.warn("TokenField: Cannot remove token. Minimum " + minTokens + " tokens required.");
|
9708
|
+
return;
|
9709
|
+
}
|
9710
|
+
if (onChange) onChange(id, next);
|
9711
|
+
if (onTokenRemove) onTokenRemove(removedToken, index);
|
9712
|
+
}, [disabled, readOnly, tokens, minTokens, id, onChange, onTokenRemove]);
|
9713
|
+
|
9714
|
+
// Enhanced change function (maintaining original behavior)
|
9715
|
+
var change = React.useCallback(function (event) {
|
9716
|
+
if (disabled || readOnly) return;
|
9717
|
+
var newValue = event.target.value;
|
9718
|
+
setValue(newValue);
|
9719
|
+
}, [disabled, readOnly]);
|
9720
|
+
|
9721
|
+
// Validate token
|
9722
|
+
var validateTokenValue = React.useCallback(function (tokenValue) {
|
9723
|
+
if (!tokenValue || typeof tokenValue === 'string' && tokenValue.trim() === '') {
|
9724
|
+
return {
|
9725
|
+
isValid: false,
|
9726
|
+
error: 'Token cannot be empty'
|
9727
|
+
};
|
9728
|
+
}
|
9729
|
+
|
9730
|
+
// Check duplicates
|
9731
|
+
if (!allowDuplicates && tokens.includes(tokenValue)) {
|
9732
|
+
return {
|
9733
|
+
isValid: false,
|
9734
|
+
error: 'Duplicate token not allowed'
|
9735
|
+
};
|
9736
|
+
}
|
9737
|
+
|
9738
|
+
// Check max tokens
|
9739
|
+
if (maxTokens && tokens.length >= maxTokens) {
|
9740
|
+
return {
|
9741
|
+
isValid: false,
|
9742
|
+
error: "Maximum " + maxTokens + " tokens allowed"
|
9743
|
+
};
|
9744
|
+
}
|
9745
|
+
|
9746
|
+
// Custom validation
|
9747
|
+
if (validateToken) {
|
9748
|
+
var customValidation = validateToken(tokenValue, tokens);
|
9749
|
+
if (customValidation && !customValidation.isValid) {
|
9750
|
+
return customValidation;
|
9751
|
+
}
|
9752
|
+
}
|
9753
|
+
return {
|
9754
|
+
isValid: true
|
9755
|
+
};
|
9756
|
+
}, [allowDuplicates, tokens, maxTokens, validateToken]);
|
7127
9757
|
|
7128
9758
|
// Add token helper
|
7129
9759
|
var addToken = React.useCallback(function (tokenValue) {
|
@@ -7639,7 +10269,7 @@ var Tree = function Tree(props) {
|
|
7639
10269
|
className: "tree__loading"
|
7640
10270
|
}, /*#__PURE__*/React__default["default"].createElement(Icon, {
|
7641
10271
|
icon: "hourglass_empty",
|
7642
|
-
size: "
|
10272
|
+
size: "normal"
|
7643
10273
|
}), /*#__PURE__*/React__default["default"].createElement(Text, null, "Loading...")));
|
7644
10274
|
}
|
7645
10275
|
|
@@ -7689,7 +10319,7 @@ var Tree = function Tree(props) {
|
|
7689
10319
|
icon: "unfold_more",
|
7690
10320
|
size: "small"
|
7691
10321
|
}), /*#__PURE__*/React__default["default"].createElement(Text, {
|
7692
|
-
size: "
|
10322
|
+
size: "sm"
|
7693
10323
|
}, "Expand All")), collapseAll && /*#__PURE__*/React__default["default"].createElement("button", {
|
7694
10324
|
className: "tree__control-button",
|
7695
10325
|
onClick: handleCollapseAll,
|
@@ -7698,7 +10328,7 @@ var Tree = function Tree(props) {
|
|
7698
10328
|
icon: "unfold_less",
|
7699
10329
|
size: "small"
|
7700
10330
|
}), /*#__PURE__*/React__default["default"].createElement(Text, {
|
7701
|
-
size: "
|
10331
|
+
size: "sm"
|
7702
10332
|
}, "Collapse All"))), /*#__PURE__*/React__default["default"].createElement("div", {
|
7703
10333
|
className: "tree__content"
|
7704
10334
|
}, nodes, children));
|
@@ -7868,7 +10498,9 @@ var TreeNode = function TreeNode(props) {
|
|
7868
10498
|
})), /*#__PURE__*/React__default["default"].createElement("div", {
|
7869
10499
|
className: "label " + clickable,
|
7870
10500
|
onClick: handleSelect
|
7871
|
-
},
|
10501
|
+
}, /*#__PURE__*/React__default["default"].createElement("span", {
|
10502
|
+
className: "tree-node__label-text"
|
10503
|
+
}, labelTxt), badge && /*#__PURE__*/React__default["default"].createElement("span", {
|
7872
10504
|
className: "tree-node__badge"
|
7873
10505
|
}, typeof badge === 'number' && badge > 99 ? '99+' : badge)), actions && /*#__PURE__*/React__default["default"].createElement("div", {
|
7874
10506
|
className: "actions"
|
@@ -19202,9 +21834,12 @@ exports.ContentForm = ContentForm;
|
|
19202
21834
|
exports.ContentViewer = ContentViewer;
|
19203
21835
|
exports.CreateContentDialog = CreateContentDialog;
|
19204
21836
|
exports.DataTable = DataTable;
|
21837
|
+
exports.DataTable2 = DataTable2;
|
19205
21838
|
exports.DateRange = DateRange;
|
21839
|
+
exports.DateRange2 = DateRange2;
|
19206
21840
|
exports.Dialog = Dialog;
|
19207
21841
|
exports.DropDown = DropDown;
|
21842
|
+
exports.DropDown2 = DropDown2;
|
19208
21843
|
exports.DynamicForm = DynamicForm;
|
19209
21844
|
exports.EditContentDialog = EditContentDialog;
|
19210
21845
|
exports.EmptyMessage = EmptyMessage;
|
@@ -19221,6 +21856,7 @@ exports.ForgetUserPasswordAction = ForgetUserPasswordAction;
|
|
19221
21856
|
exports.Form = Form;
|
19222
21857
|
exports.HTTPClient = HTTPClient;
|
19223
21858
|
exports.Header = Header;
|
21859
|
+
exports.Header2 = Header2;
|
19224
21860
|
exports.Icon = Icon;
|
19225
21861
|
exports.ImageViewer = ImageViewer;
|
19226
21862
|
exports.Kanban = Kanban;
|
@@ -19247,6 +21883,7 @@ exports.PageLink = PageLink;
|
|
19247
21883
|
exports.PageProvider = PageProvider;
|
19248
21884
|
exports.PasswordEditor = PasswordEditor;
|
19249
21885
|
exports.PasswordField = PasswordField;
|
21886
|
+
exports.PasswordField2 = PasswordField2;
|
19250
21887
|
exports.Planner = Planner;
|
19251
21888
|
exports.Planner2 = Planner2;
|
19252
21889
|
exports.Property = Property;
|
@@ -19278,7 +21915,9 @@ exports.TaskMonitor = TaskMonitor;
|
|
19278
21915
|
exports.TaskProgress = TaskProgress;
|
19279
21916
|
exports.Text = Text;
|
19280
21917
|
exports.TextArea = TextArea;
|
21918
|
+
exports.TextArea2 = TextArea2;
|
19281
21919
|
exports.TextField = TextField;
|
21920
|
+
exports.TextField2 = TextField2;
|
19282
21921
|
exports.Thumbnail = Thumbnail;
|
19283
21922
|
exports.ToggleButton = ToggleButton;
|
19284
21923
|
exports.TokenField = TokenField;
|