xmlui 0.10.18 → 0.10.19
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/lib/{index-Cy6Emsex.mjs → index-cuh97e2e.mjs} +286 -140
- package/dist/lib/index.css +1 -1
- package/dist/lib/{initMock-B-rmnC-t.mjs → initMock-BMxsanHc.mjs} +1 -1
- package/dist/lib/xmlui.mjs +1 -1
- package/dist/metadata/{collectedComponentMetadata-CB63ngkU.mjs → collectedComponentMetadata-Cp-9lpnG.mjs} +286 -140
- package/dist/metadata/{initMock-D0wDKF_I.mjs → initMock-C-cnv--V.mjs} +1 -1
- package/dist/metadata/style.css +1 -1
- package/dist/metadata/xmlui-metadata.mjs +1 -1
- package/dist/metadata/xmlui-metadata.umd.js +3 -3
- package/dist/scripts/package.json +1 -1
- package/dist/scripts/src/components/AutoComplete/AutoComplete.spec.js +25 -4
- package/dist/scripts/src/components/Checkbox/Checkbox.spec.js +5 -0
- package/dist/scripts/src/components/DateInput/DateInput.spec.js +22 -17
- package/dist/scripts/src/components/DatePicker/DatePicker.js +14 -9
- package/dist/scripts/src/components/DatePicker/DatePicker.spec.js +21 -18
- package/dist/scripts/src/components/DatePicker/DatePickerNative.js +24 -21
- package/dist/scripts/src/components/FileInput/FileInput.spec.js +7 -0
- package/dist/scripts/src/components/Icon/Icon.js +1 -1
- package/dist/scripts/src/components/NumberBox/NumberBox.spec.js +5 -0
- package/dist/scripts/src/components/RadioGroup/RadioGroup.spec.js +9 -0
- package/dist/scripts/src/components/Select/Select.spec.js +286 -217
- package/dist/scripts/src/components/Slider/Slider.spec.js +7 -0
- package/dist/scripts/src/components/Switch/Switch.spec.js +24 -17
- package/dist/scripts/src/components/Table/Table.js +11 -1
- package/dist/scripts/src/components/Table/Table.spec.js +272 -0
- package/dist/scripts/src/components/Table/TableNative.js +162 -5
- package/dist/scripts/src/components/TextArea/TextArea.spec.js +51 -0
- package/dist/scripts/src/components/TextBox/TextBox.spec.js +7 -0
- package/dist/scripts/src/components/TimeInput/TimeInput.spec.js +44 -37
- package/dist/scripts/src/components/TimeInput/TimeInputNative.js +6 -20
- package/dist/scripts/src/components/Toggle/Toggle.js +3 -1
- package/dist/standalone/xmlui-standalone.umd.js +33 -33
- package/package.json +1 -1
|
@@ -23,7 +23,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.defaultProps = exports.Table = exports.TablePaginationControlsLocationValues = void 0;
|
|
26
|
+
exports.defaultProps = exports.Table = exports.CheckboxToleranceValues = exports.TablePaginationControlsLocationValues = void 0;
|
|
27
27
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
28
|
const react_1 = require("react");
|
|
29
29
|
const react_dom_1 = require("react-dom");
|
|
@@ -45,11 +45,53 @@ const IconNative_1 = require("../Icon/IconNative");
|
|
|
45
45
|
const useRowSelection_1 = __importDefault(require("./useRowSelection"));
|
|
46
46
|
const PaginationNative_1 = require("../Pagination/PaginationNative");
|
|
47
47
|
exports.TablePaginationControlsLocationValues = ["top", "bottom", "both"];
|
|
48
|
+
exports.CheckboxToleranceValues = ["none", "compact", "comfortable", "spacious"];
|
|
48
49
|
function defaultIsRowDisabled(_) {
|
|
49
50
|
return false;
|
|
50
51
|
}
|
|
51
52
|
const SELECT_COLUMN_WIDTH = 42;
|
|
52
53
|
const DEFAULT_PAGE_SIZES = [10];
|
|
54
|
+
/**
|
|
55
|
+
* Maps checkbox tolerance values to pixel values
|
|
56
|
+
* @param tolerance - The tolerance level
|
|
57
|
+
* @returns The number of pixels for the tolerance
|
|
58
|
+
*/
|
|
59
|
+
const getCheckboxTolerancePixels = (tolerance) => {
|
|
60
|
+
switch (tolerance) {
|
|
61
|
+
case "none":
|
|
62
|
+
return 0;
|
|
63
|
+
case "compact":
|
|
64
|
+
return 8;
|
|
65
|
+
case "comfortable":
|
|
66
|
+
return 12;
|
|
67
|
+
case "spacious":
|
|
68
|
+
return 16;
|
|
69
|
+
default:
|
|
70
|
+
return 8; // fallback to compact
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Helper function to check if a point is within the checkbox boundary
|
|
75
|
+
* @param pointX - X coordinate of the point to check
|
|
76
|
+
* @param pointY - Y coordinate of the point to check
|
|
77
|
+
* @param checkboxRect - Bounding rectangle of the checkbox
|
|
78
|
+
* @param tolerancePixels - Number of pixels to extend the boundary
|
|
79
|
+
* @returns true if the point is within the checkbox or within tolerancePixels of its boundary
|
|
80
|
+
*/
|
|
81
|
+
const isWithinCheckboxBoundary = (pointX, pointY, checkboxRect, tolerancePixels) => {
|
|
82
|
+
// Calculate distance from point to checkbox boundaries
|
|
83
|
+
const distanceToLeft = Math.abs(pointX - checkboxRect.left);
|
|
84
|
+
const distanceToRight = Math.abs(pointX - checkboxRect.right);
|
|
85
|
+
const distanceToTop = Math.abs(pointY - checkboxRect.top);
|
|
86
|
+
const distanceToBottom = Math.abs(pointY - checkboxRect.bottom);
|
|
87
|
+
// Check if point is within the checkbox bounds or within boundary pixels of any edge
|
|
88
|
+
const withinHorizontalBounds = pointX >= checkboxRect.left && pointX <= checkboxRect.right;
|
|
89
|
+
const withinVerticalBounds = pointY >= checkboxRect.top && pointY <= checkboxRect.bottom;
|
|
90
|
+
const withinCheckbox = withinHorizontalBounds && withinVerticalBounds;
|
|
91
|
+
const nearHorizontalBoundary = (withinVerticalBounds && (distanceToLeft <= tolerancePixels || distanceToRight <= tolerancePixels));
|
|
92
|
+
const nearVerticalBoundary = (withinHorizontalBounds && (distanceToTop <= tolerancePixels || distanceToBottom <= tolerancePixels));
|
|
93
|
+
return withinCheckbox || nearHorizontalBoundary || nearVerticalBoundary;
|
|
94
|
+
};
|
|
53
95
|
//These are the important styles to make sticky column pinning work!
|
|
54
96
|
//Apply styles like this using your CSS strategy of choice with this kind of logic to head cells, data cells, footer cells, etc.
|
|
55
97
|
//View the index.css file for more needed styles such as border-collapse: separate
|
|
@@ -74,7 +116,7 @@ const getCommonPinningStyles = (column) => {
|
|
|
74
116
|
// eslint-disable-next-line react/display-name
|
|
75
117
|
exports.Table = (0, react_1.forwardRef)((_a, forwardedRef) => {
|
|
76
118
|
var _b, _c, _d, _e, _f;
|
|
77
|
-
var { data = exports.defaultProps.data, columns = exports.defaultProps.columns, isPaginated = exports.defaultProps.isPaginated, loading = exports.defaultProps.loading, headerHeight, rowsSelectable = exports.defaultProps.rowsSelectable, enableMultiRowSelection = exports.defaultProps.enableMultiRowSelection, initiallySelected = exports.defaultProps.initiallySelected, syncWithAppState, pageSizeOptions = exports.defaultProps.pageSizeOptions, pageSize = (pageSizeOptions === null || pageSizeOptions === void 0 ? void 0 : pageSizeOptions[0]) || DEFAULT_PAGE_SIZES[0], currentPageIndex = 0, rowDisabledPredicate = defaultIsRowDisabled, sortBy, sortingDirection = exports.defaultProps.sortingDirection, iconSortAsc, iconSortDesc, iconNoSort, sortingDidChange, willSort, style, className, noDataRenderer, autoFocus = exports.defaultProps.autoFocus, hideHeader = exports.defaultProps.hideHeader, hideNoDataView = exports.defaultProps.hideNoDataView, alwaysShowSelectionHeader = exports.defaultProps.alwaysShowSelectionHeader, registerComponentApi, onSelectionDidChange, noBottomBorder = exports.defaultProps.noBottomBorder, paginationControlsLocation = exports.defaultProps.paginationControlsLocation, cellVerticalAlign = exports.defaultProps.cellVerticalAlign, buttonRowPosition = exports.defaultProps.buttonRowPosition, pageSizeSelectorPosition = exports.defaultProps.pageSizeSelectorPosition, pageInfoPosition = exports.defaultProps.pageInfoPosition, showCurrentPage = exports.defaultProps.showCurrentPage, showPageInfo = exports.defaultProps.showPageInfo, showPageSizeSelector = exports.defaultProps.showPageSizeSelector } = _a, rest = __rest(_a, ["data", "columns", "isPaginated", "loading", "headerHeight", "rowsSelectable", "enableMultiRowSelection", "initiallySelected", "syncWithAppState", "pageSizeOptions", "pageSize", "currentPageIndex", "rowDisabledPredicate", "sortBy", "sortingDirection", "iconSortAsc", "iconSortDesc", "iconNoSort", "sortingDidChange", "willSort", "style", "className", "noDataRenderer", "autoFocus", "hideHeader", "hideNoDataView", "alwaysShowSelectionHeader", "registerComponentApi", "onSelectionDidChange", "noBottomBorder", "paginationControlsLocation", "cellVerticalAlign", "buttonRowPosition", "pageSizeSelectorPosition", "pageInfoPosition", "showCurrentPage", "showPageInfo", "showPageSizeSelector"])
|
|
119
|
+
var { data = exports.defaultProps.data, columns = exports.defaultProps.columns, isPaginated = exports.defaultProps.isPaginated, loading = exports.defaultProps.loading, headerHeight, rowsSelectable = exports.defaultProps.rowsSelectable, enableMultiRowSelection = exports.defaultProps.enableMultiRowSelection, initiallySelected = exports.defaultProps.initiallySelected, syncWithAppState, pageSizeOptions = exports.defaultProps.pageSizeOptions, pageSize = (pageSizeOptions === null || pageSizeOptions === void 0 ? void 0 : pageSizeOptions[0]) || DEFAULT_PAGE_SIZES[0], currentPageIndex = 0, rowDisabledPredicate = defaultIsRowDisabled, sortBy, sortingDirection = exports.defaultProps.sortingDirection, iconSortAsc, iconSortDesc, iconNoSort, sortingDidChange, willSort, style, className, noDataRenderer, autoFocus = exports.defaultProps.autoFocus, hideHeader = exports.defaultProps.hideHeader, hideNoDataView = exports.defaultProps.hideNoDataView, alwaysShowSelectionHeader = exports.defaultProps.alwaysShowSelectionHeader, registerComponentApi, onSelectionDidChange, noBottomBorder = exports.defaultProps.noBottomBorder, paginationControlsLocation = exports.defaultProps.paginationControlsLocation, cellVerticalAlign = exports.defaultProps.cellVerticalAlign, buttonRowPosition = exports.defaultProps.buttonRowPosition, pageSizeSelectorPosition = exports.defaultProps.pageSizeSelectorPosition, pageInfoPosition = exports.defaultProps.pageInfoPosition, showCurrentPage = exports.defaultProps.showCurrentPage, showPageInfo = exports.defaultProps.showPageInfo, showPageSizeSelector = exports.defaultProps.showPageSizeSelector, checkboxTolerance = exports.defaultProps.checkboxTolerance } = _a, rest = __rest(_a, ["data", "columns", "isPaginated", "loading", "headerHeight", "rowsSelectable", "enableMultiRowSelection", "initiallySelected", "syncWithAppState", "pageSizeOptions", "pageSize", "currentPageIndex", "rowDisabledPredicate", "sortBy", "sortingDirection", "iconSortAsc", "iconSortDesc", "iconNoSort", "sortingDidChange", "willSort", "style", "className", "noDataRenderer", "autoFocus", "hideHeader", "hideNoDataView", "alwaysShowSelectionHeader", "registerComponentApi", "onSelectionDidChange", "noBottomBorder", "paginationControlsLocation", "cellVerticalAlign", "buttonRowPosition", "pageSizeSelectorPosition", "pageInfoPosition", "showCurrentPage", "showPageInfo", "showPageSizeSelector", "checkboxTolerance"])
|
|
78
120
|
// cols
|
|
79
121
|
;
|
|
80
122
|
const { getThemeVar } = (0, ThemeContext_1.useTheme)();
|
|
@@ -99,6 +141,12 @@ exports.Table = (0, react_1.forwardRef)((_a, forwardedRef) => {
|
|
|
99
141
|
}, [autoFocus]);
|
|
100
142
|
// --- Keep track of visible table rows
|
|
101
143
|
const [visibleItems, setVisibleItems] = (0, react_1.useState)(constants_1.EMPTY_ARRAY);
|
|
144
|
+
// --- Track which row should show forced hover for checkbox
|
|
145
|
+
const [hoveredRowId, setHoveredRowId] = (0, react_1.useState)(null);
|
|
146
|
+
// --- Track if the header checkbox should show forced hover
|
|
147
|
+
const [headerCheckboxHovered, setHeaderCheckboxHovered] = (0, react_1.useState)(false);
|
|
148
|
+
// --- Calculate tolerance pixels from the prop
|
|
149
|
+
const tolerancePixels = getCheckboxTolerancePixels(checkboxTolerance);
|
|
102
150
|
// --- Get the operations to manage selected rows in a table
|
|
103
151
|
const { toggleRow, checkAllRows, focusedIndex, onKeyDown, selectedRowIdMap, idKey, selectionApi, } = (0, useRowSelection_1.default)({
|
|
104
152
|
items: safeData,
|
|
@@ -221,18 +269,23 @@ exports.Table = (0, react_1.forwardRef)((_a, forwardedRef) => {
|
|
|
221
269
|
},
|
|
222
270
|
header: ({ table }) => enableMultiRowSelection ? ((0, jsx_runtime_1.jsx)(Toggle_1.Toggle, { className: (0, classnames_1.default)(Table_module_scss_1.default.checkBoxWrapper, {
|
|
223
271
|
[Table_module_scss_1.default.showInHeader]: alwaysShowSelectionHeader,
|
|
272
|
+
[Table_module_scss_1.default.forceHoverWrapper]: headerCheckboxHovered,
|
|
224
273
|
}),
|
|
225
274
|
value: table.getIsAllRowsSelected(),
|
|
226
275
|
indeterminate: table.getIsSomeRowsSelected(),
|
|
276
|
+
forceHover: headerCheckboxHovered,
|
|
227
277
|
onDidChange: () => {
|
|
228
278
|
const allSelected = table
|
|
229
279
|
.getRowModel()
|
|
230
280
|
.rows.every((row) => rowDisabledPredicate(row.original) || row.getIsSelected());
|
|
231
281
|
checkAllRows(!allSelected);
|
|
232
282
|
} })) : null,
|
|
233
|
-
cell: ({ row }) => ((0, jsx_runtime_1.jsx)(Toggle_1.Toggle, { className: Table_module_scss_1.default.checkBoxWrapper,
|
|
283
|
+
cell: ({ row }) => ((0, jsx_runtime_1.jsx)(Toggle_1.Toggle, { className: (0, classnames_1.default)(Table_module_scss_1.default.checkBoxWrapper, {
|
|
284
|
+
[Table_module_scss_1.default.forceHoverWrapper]: hoveredRowId === row.id,
|
|
285
|
+
}),
|
|
234
286
|
value: row.getIsSelected(),
|
|
235
287
|
indeterminate: row.getIsSomeSelected(),
|
|
288
|
+
forceHover: hoveredRowId === row.id,
|
|
236
289
|
onDidChange: () => {
|
|
237
290
|
toggleRow(row.original, { metaKey: true });
|
|
238
291
|
} })),
|
|
@@ -246,6 +299,8 @@ exports.Table = (0, react_1.forwardRef)((_a, forwardedRef) => {
|
|
|
246
299
|
checkAllRows,
|
|
247
300
|
toggleRow,
|
|
248
301
|
rowDisabledPredicate,
|
|
302
|
+
hoveredRowId,
|
|
303
|
+
headerCheckboxHovered,
|
|
249
304
|
]);
|
|
250
305
|
// --- Set up page information (using the first page size option)
|
|
251
306
|
// const [pagination, setPagination] = useState<PaginationState>();
|
|
@@ -396,7 +451,71 @@ exports.Table = (0, react_1.forwardRef)((_a, forwardedRef) => {
|
|
|
396
451
|
(paginationControlsLocation === "top" || paginationControlsLocation === "both") &&
|
|
397
452
|
paginationControls, (0, jsx_runtime_1.jsxs)("table", { className: Table_module_scss_1.default.table, ref: tableRef, children: [!hideHeader && ((0, jsx_runtime_1.jsx)("thead", { style: { height: headerHeight }, className: Table_module_scss_1.default.headerWrapper, children: table.getHeaderGroups().map((headerGroup, headerGroupIndex) => ((0, jsx_runtime_1.jsx)("tr", { className: (0, classnames_1.default)(Table_module_scss_1.default.headerRow, {
|
|
398
453
|
[Table_module_scss_1.default.allSelected]: table.getIsAllRowsSelected(),
|
|
399
|
-
}),
|
|
454
|
+
}), onClick: (event) => {
|
|
455
|
+
const target = event.target;
|
|
456
|
+
const headerCell = target.closest('th');
|
|
457
|
+
// Only handle clicks for the select column header
|
|
458
|
+
if (headerCell && rowsSelectable && enableMultiRowSelection) {
|
|
459
|
+
const header = headerGroup.headers.find(h => {
|
|
460
|
+
const headerElement = headerCell;
|
|
461
|
+
return (headerElement === null || headerElement === void 0 ? void 0 : headerElement.getAttribute('data-column-id')) === h.id || h.id === 'select';
|
|
462
|
+
});
|
|
463
|
+
if (header && header.id === 'select') {
|
|
464
|
+
const clickX = event.clientX;
|
|
465
|
+
const clickY = event.clientY;
|
|
466
|
+
const checkbox = headerCell.querySelector('input[type=\"checkbox\"]');
|
|
467
|
+
if (checkbox) {
|
|
468
|
+
const checkboxRect = checkbox.getBoundingClientRect();
|
|
469
|
+
if (isWithinCheckboxBoundary(clickX, clickY, checkboxRect, tolerancePixels)) {
|
|
470
|
+
// Prevent the default click and manually trigger the checkbox
|
|
471
|
+
event.preventDefault();
|
|
472
|
+
event.stopPropagation();
|
|
473
|
+
const allSelected = table
|
|
474
|
+
.getRowModel()
|
|
475
|
+
.rows.every((row) => rowDisabledPredicate(row.original) || row.getIsSelected());
|
|
476
|
+
checkAllRows(!allSelected);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}, onMouseMove: (event) => {
|
|
482
|
+
if (rowsSelectable && enableMultiRowSelection) {
|
|
483
|
+
const target = event.target;
|
|
484
|
+
const headerCell = target.closest('th');
|
|
485
|
+
if (headerCell) {
|
|
486
|
+
const header = headerGroup.headers.find(h => {
|
|
487
|
+
const headerElement = headerCell;
|
|
488
|
+
return (headerElement === null || headerElement === void 0 ? void 0 : headerElement.getAttribute('data-column-id')) === h.id || h.id === 'select';
|
|
489
|
+
});
|
|
490
|
+
if (header && header.id === 'select') {
|
|
491
|
+
const mouseX = event.clientX;
|
|
492
|
+
const mouseY = event.clientY;
|
|
493
|
+
const checkbox = headerCell.querySelector('input[type=\"checkbox\"]');
|
|
494
|
+
if (checkbox) {
|
|
495
|
+
const checkboxRect = checkbox.getBoundingClientRect();
|
|
496
|
+
const shouldShowHover = isWithinCheckboxBoundary(mouseX, mouseY, checkboxRect, tolerancePixels);
|
|
497
|
+
if (shouldShowHover && !headerCheckboxHovered) {
|
|
498
|
+
setHeaderCheckboxHovered(true);
|
|
499
|
+
event.currentTarget.style.cursor = 'pointer';
|
|
500
|
+
}
|
|
501
|
+
else if (!shouldShowHover && headerCheckboxHovered) {
|
|
502
|
+
setHeaderCheckboxHovered(false);
|
|
503
|
+
event.currentTarget.style.cursor = '';
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
else if (headerCheckboxHovered) {
|
|
508
|
+
setHeaderCheckboxHovered(false);
|
|
509
|
+
event.currentTarget.style.cursor = '';
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}, onMouseLeave: (event) => {
|
|
514
|
+
if (headerCheckboxHovered) {
|
|
515
|
+
setHeaderCheckboxHovered(false);
|
|
516
|
+
event.currentTarget.style.cursor = '';
|
|
517
|
+
}
|
|
518
|
+
}, children: headerGroup.headers.map((header, headerIndex) => {
|
|
400
519
|
var _a, _b, _c;
|
|
401
520
|
const _d = ((_a = header.column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.style) || {}, { width } = _d, style = __rest(_d, ["width"]);
|
|
402
521
|
const size = header.getSize();
|
|
@@ -405,7 +524,7 @@ exports.Table = (0, react_1.forwardRef)((_a, forwardedRef) => {
|
|
|
405
524
|
: cellVerticalAlign === "bottom"
|
|
406
525
|
? Table_module_scss_1.default.alignBottom
|
|
407
526
|
: Table_module_scss_1.default.alignCenter;
|
|
408
|
-
return ((0, jsx_runtime_1.jsxs)("th", { className: (0, classnames_1.default)(Table_module_scss_1.default.columnCell, alignmentClass), colSpan: header.colSpan, style: Object.assign({ position: "relative", width: size }, getCommonPinningStyles(header.column)), children: [(0, jsx_runtime_1.jsx)(ClickableHeader, { hasSorting: header.column.columnDef.enableSorting &&
|
|
527
|
+
return ((0, jsx_runtime_1.jsxs)("th", { "data-column-id": header.id, className: (0, classnames_1.default)(Table_module_scss_1.default.columnCell, alignmentClass), colSpan: header.colSpan, style: Object.assign({ position: "relative", width: size }, getCommonPinningStyles(header.column)), children: [(0, jsx_runtime_1.jsx)(ClickableHeader, { hasSorting: header.column.columnDef.enableSorting &&
|
|
409
528
|
!!((_b = header.column.columnDef.meta) === null || _b === void 0 ? void 0 : _b.accessorKey), updateSorting: () => { var _a; return _updateSorting((_a = header.column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.accessorKey); }, children: (0, jsx_runtime_1.jsxs)("div", { className: Table_module_scss_1.default.headerContent, style: style, children: [(0, react_table_1.flexRender)(header.column.columnDef.header, header.getContext()), header.column.columnDef.enableSorting && ((0, jsx_runtime_1.jsx)("span", { style: { display: "inline-flex", maxWidth: 16 }, children: (0, jsx_runtime_1.jsx)(ColumnOrderingIndicator, { iconSortAsc: iconSortAsc, iconSortDesc: iconSortDesc, iconNoSort: iconNoSort, direction: ((_c = header.column.columnDef.meta) === null || _c === void 0 ? void 0 : _c.accessorKey) === _sortBy
|
|
410
529
|
? _sortingDirection
|
|
411
530
|
: undefined }) }))] }) }), header.column.getCanResize() && ((0, jsx_runtime_1.jsx)("div", { onDoubleClick: () => {
|
|
@@ -449,7 +568,44 @@ exports.Table = (0, react_1.forwardRef)((_a, forwardedRef) => {
|
|
|
449
568
|
if (target.tagName.toLowerCase() === "input") {
|
|
450
569
|
return;
|
|
451
570
|
}
|
|
571
|
+
// Check if click is within checkbox boundary
|
|
572
|
+
const currentRow = event.currentTarget;
|
|
573
|
+
const checkbox = currentRow.querySelector('input[type="checkbox"]');
|
|
574
|
+
if (checkbox) {
|
|
575
|
+
const checkboxRect = checkbox.getBoundingClientRect();
|
|
576
|
+
const clickX = event.clientX;
|
|
577
|
+
const clickY = event.clientY;
|
|
578
|
+
if (isWithinCheckboxBoundary(clickX, clickY, checkboxRect, tolerancePixels)) {
|
|
579
|
+
// Toggle the checkbox when clicking within the boundary
|
|
580
|
+
toggleRow(row.original, { metaKey: true });
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
452
584
|
toggleRow(row.original, event);
|
|
585
|
+
}, onMouseMove: (event) => {
|
|
586
|
+
// Change cursor and hover state when within checkbox boundary
|
|
587
|
+
const currentRow = event.currentTarget;
|
|
588
|
+
const checkbox = currentRow.querySelector('input[type="checkbox"]');
|
|
589
|
+
if (checkbox) {
|
|
590
|
+
const checkboxRect = checkbox.getBoundingClientRect();
|
|
591
|
+
const mouseX = event.clientX;
|
|
592
|
+
const mouseY = event.clientY;
|
|
593
|
+
const shouldShowHover = isWithinCheckboxBoundary(mouseX, mouseY, checkboxRect, tolerancePixels);
|
|
594
|
+
// Update hover state and cursor based on proximity to checkbox
|
|
595
|
+
if (shouldShowHover) {
|
|
596
|
+
setHoveredRowId(row.id);
|
|
597
|
+
currentRow.style.cursor = 'pointer';
|
|
598
|
+
}
|
|
599
|
+
else {
|
|
600
|
+
setHoveredRowId(null);
|
|
601
|
+
currentRow.style.cursor = '';
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}, onMouseLeave: (event) => {
|
|
605
|
+
// Reset cursor and hover state when leaving the row
|
|
606
|
+
const currentRow = event.currentTarget;
|
|
607
|
+
currentRow.style.cursor = '';
|
|
608
|
+
setHoveredRowId(null);
|
|
453
609
|
}, children: row.getVisibleCells().map((cell, i) => {
|
|
454
610
|
var _a, _b;
|
|
455
611
|
const cellRenderer = (_b = (_a = cell.column.columnDef) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.cellRenderer;
|
|
@@ -510,4 +666,5 @@ exports.defaultProps = {
|
|
|
510
666
|
buttonRowPosition: "center",
|
|
511
667
|
pageSizeSelectorPosition: "start",
|
|
512
668
|
pageInfoPosition: "end",
|
|
669
|
+
checkboxTolerance: "compact",
|
|
513
670
|
};
|
|
@@ -327,6 +327,57 @@ fixtures_1.test.describe("Accessibility", () => {
|
|
|
327
327
|
}));
|
|
328
328
|
});
|
|
329
329
|
// =============================================================================
|
|
330
|
+
// EVENT HANDLING TESTS
|
|
331
|
+
// =============================================================================
|
|
332
|
+
fixtures_1.test.describe("Event Handling", () => {
|
|
333
|
+
(0, fixtures_1.test)("didChange event fires on input change", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
334
|
+
const { testStateDriver } = yield initTestBed(`
|
|
335
|
+
<TextArea onDidChange="testState = 'changed'" />
|
|
336
|
+
`);
|
|
337
|
+
yield page.getByRole("textbox").fill("test");
|
|
338
|
+
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual("changed");
|
|
339
|
+
}));
|
|
340
|
+
(0, fixtures_1.test)("didChange event passes new value", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
341
|
+
const { testStateDriver } = yield initTestBed(`
|
|
342
|
+
<TextArea onDidChange="arg => testState = arg" />
|
|
343
|
+
`);
|
|
344
|
+
yield page.getByRole("textbox").fill("test value");
|
|
345
|
+
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual("test value");
|
|
346
|
+
}));
|
|
347
|
+
(0, fixtures_1.test)("gotFocus event fires on focus", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
348
|
+
const { testStateDriver } = yield initTestBed(`
|
|
349
|
+
<TextArea onGotFocus="testState = 'focused'" />
|
|
350
|
+
`);
|
|
351
|
+
yield page.getByRole("textbox").focus();
|
|
352
|
+
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual("focused");
|
|
353
|
+
}));
|
|
354
|
+
(0, fixtures_1.test)("gotFocus event fires on label click", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
355
|
+
const { testStateDriver } = yield initTestBed(`
|
|
356
|
+
<TextArea label="Comments" onGotFocus="testState = 'focused'" />
|
|
357
|
+
`);
|
|
358
|
+
yield page.getByText("Comments").click();
|
|
359
|
+
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual("focused");
|
|
360
|
+
}));
|
|
361
|
+
(0, fixtures_1.test)("lostFocus event fires on blur", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
362
|
+
const { testStateDriver } = yield initTestBed(`
|
|
363
|
+
<TextArea onLostFocus="testState = 'blurred'" />
|
|
364
|
+
`);
|
|
365
|
+
const textarea = page.getByRole("textbox");
|
|
366
|
+
yield textarea.focus();
|
|
367
|
+
yield textarea.blur();
|
|
368
|
+
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual("blurred");
|
|
369
|
+
}));
|
|
370
|
+
(0, fixtures_1.test)("events do not fire when component is disabled", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
371
|
+
const { testStateDriver } = yield initTestBed(`
|
|
372
|
+
<TextArea enabled="false" onDidChange="testState = 'changed'" onGotFocus="testState = 'focused'" />
|
|
373
|
+
`);
|
|
374
|
+
const textarea = page.getByRole("textbox");
|
|
375
|
+
yield textarea.focus();
|
|
376
|
+
yield textarea.fill("test", { force: true });
|
|
377
|
+
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual(null);
|
|
378
|
+
}));
|
|
379
|
+
});
|
|
380
|
+
// =============================================================================
|
|
330
381
|
// VISUAL STATE TESTS
|
|
331
382
|
// =============================================================================
|
|
332
383
|
fixtures_1.test.describe("Visual States", () => {
|
|
@@ -257,6 +257,13 @@ fixtures_1.test.describe("Event Handling", () => {
|
|
|
257
257
|
yield driver.input.focus();
|
|
258
258
|
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual("focused");
|
|
259
259
|
}));
|
|
260
|
+
(0, fixtures_1.test)("gotFocus event fires on label click", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
261
|
+
const { testStateDriver } = yield initTestBed(`
|
|
262
|
+
<TextBox label="Username" onGotFocus="testState = 'focused'" />
|
|
263
|
+
`);
|
|
264
|
+
yield page.getByText("Username").click();
|
|
265
|
+
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual("focused");
|
|
266
|
+
}));
|
|
260
267
|
(0, fixtures_1.test)("component lostFocus event fires on blur", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createTextBoxDriver }) {
|
|
261
268
|
const { testStateDriver } = yield initTestBed(`
|
|
262
269
|
<TextBox testId="test" onLostFocus="testState = 'blurred'" />
|