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