@lt-ui/table 0.0.0-stage → 0.0.2
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/cells/cells.module.css +481 -0
- package/cells/field-cells.d.ts +118 -0
- package/cells/field-cells.js +48 -0
- package/cells/index.d.ts +29 -0
- package/cells/index.js +15 -0
- package/cells/square-select.d.ts +19 -0
- package/cells/square-select.js +37 -0
- package/cells/square.d.ts +16 -0
- package/cells/square.js +78 -0
- package/cells/table-cell-actions.d.ts +32 -0
- package/cells/table-cell-actions.js +36 -0
- package/cells/table-cell-checkbox.d.ts +13 -0
- package/cells/table-cell-checkbox.js +13 -0
- package/cells/table-cell-copy.d.ts +18 -0
- package/cells/table-cell-copy.js +32 -0
- package/cells/table-cell-date.d.ts +20 -0
- package/cells/table-cell-date.js +15 -0
- package/cells/table-cell-expand.d.ts +18 -0
- package/cells/table-cell-expand.js +17 -0
- package/cells/table-cell-file-upload.d.ts +27 -0
- package/cells/table-cell-file-upload.js +22 -0
- package/cells/table-cell-file.d.ts +27 -0
- package/cells/table-cell-file.js +29 -0
- package/cells/table-cell-image.d.ts +22 -0
- package/cells/table-cell-image.js +12 -0
- package/cells/table-cell-input.d.ts +22 -0
- package/cells/table-cell-input.js +22 -0
- package/cells/table-cell-link.d.ts +14 -0
- package/cells/table-cell-link.js +28 -0
- package/cells/table-cell-select.d.ts +44 -0
- package/cells/table-cell-select.js +30 -0
- package/cells/table-cell-switch.d.ts +8 -0
- package/cells/table-cell-switch.js +5 -0
- package/cells/table-cell-textarea.d.ts +22 -0
- package/cells/table-cell-textarea.js +68 -0
- package/cjs/cells/cells.module.css +481 -0
- package/cjs/cells/field-cells.js +87 -0
- package/cjs/cells/index.js +36 -0
- package/cjs/cells/square-select.js +77 -0
- package/cjs/cells/square.js +117 -0
- package/cjs/cells/table-cell-actions.js +75 -0
- package/cjs/cells/table-cell-checkbox.js +19 -0
- package/cjs/cells/table-cell-copy.js +71 -0
- package/cjs/cells/table-cell-date.js +22 -0
- package/cjs/cells/table-cell-expand.js +23 -0
- package/cjs/cells/table-cell-file-upload.js +61 -0
- package/cjs/cells/table-cell-file.js +38 -0
- package/cjs/cells/table-cell-image.js +18 -0
- package/cjs/cells/table-cell-input.js +61 -0
- package/cjs/cells/table-cell-link.js +34 -0
- package/cjs/cells/table-cell-select.js +36 -0
- package/cjs/cells/table-cell-switch.js +12 -0
- package/cjs/cells/table-cell-textarea.js +107 -0
- package/cjs/column-settings.js +128 -0
- package/cjs/columns.js +67 -0
- package/cjs/context.js +14 -0
- package/cjs/corner-settings.js +24 -0
- package/cjs/empty-function.js +8 -0
- package/cjs/features.js +40 -0
- package/cjs/header-filter.js +93 -0
- package/cjs/index.js +44 -0
- package/cjs/layout.js +34 -0
- package/cjs/locale/index.js +8 -0
- package/cjs/locale/messages.js +63 -0
- package/cjs/locale/use-locale.js +10 -0
- package/cjs/row-loading-border.js +79 -0
- package/cjs/selection.js +34 -0
- package/cjs/sort-icon.js +18 -0
- package/cjs/styles.module.css +678 -0
- package/cjs/table-head.js +45 -0
- package/cjs/table-pagination.js +25 -0
- package/cjs/table-row.js +62 -0
- package/cjs/table-search.js +74 -0
- package/cjs/table-toolbar.js +22 -0
- package/cjs/table.js +95 -0
- package/cjs/tanstack.js +2 -0
- package/cjs/types.js +2 -0
- package/cjs/use-pointer-sort.js +116 -0
- package/cjs/use-table.js +23 -0
- package/column-settings.d.ts +59 -0
- package/column-settings.js +88 -0
- package/columns.d.ts +18 -0
- package/columns.js +59 -0
- package/context.d.ts +7 -0
- package/context.js +10 -0
- package/corner-settings.d.ts +11 -0
- package/corner-settings.js +16 -0
- package/empty-function.d.ts +1 -0
- package/empty-function.js +4 -0
- package/features.d.ts +38 -0
- package/features.js +37 -0
- package/header-filter.d.ts +29 -0
- package/header-filter.js +54 -0
- package/index.d.ts +22 -0
- package/index.js +12 -0
- package/layout.d.ts +5 -0
- package/layout.js +27 -0
- package/locale/index.d.ts +3 -0
- package/locale/index.js +2 -0
- package/locale/messages.d.ts +40 -0
- package/locale/messages.js +60 -0
- package/locale/use-locale.d.ts +9 -0
- package/locale/use-locale.js +7 -0
- package/package.json +33 -4
- package/row-loading-border.d.ts +7 -0
- package/row-loading-border.js +40 -0
- package/selection.d.ts +8 -0
- package/selection.js +31 -0
- package/sort-icon.d.ts +8 -0
- package/sort-icon.js +10 -0
- package/styles.module.css +678 -0
- package/table-head.d.ts +6 -0
- package/table-head.js +39 -0
- package/table-pagination.d.ts +16 -0
- package/table-pagination.js +19 -0
- package/table-row.d.ts +21 -0
- package/table-row.js +56 -0
- package/table-search.d.ts +28 -0
- package/table-search.js +38 -0
- package/table-toolbar.d.ts +18 -0
- package/table-toolbar.js +16 -0
- package/table.d.ts +15 -0
- package/table.js +56 -0
- package/tanstack.d.ts +9 -0
- package/tanstack.js +1 -0
- package/types.d.ts +161 -0
- package/types.js +1 -0
- package/use-pointer-sort.d.ts +32 -0
- package/use-pointer-sort.js +113 -0
- package/use-table.d.ts +46 -0
- package/use-table.js +19 -0
- package/README.md +0 -3
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.TableCellMaskedInput = exports.TableCellNumberInput = exports.TableCellTimePicker = exports.TableCellDatePicker = void 0;
|
|
41
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
42
|
+
const react_1 = __importStar(require("react"));
|
|
43
|
+
const uikit_1 = require("@lt-ui/uikit");
|
|
44
|
+
const context_1 = require("../context");
|
|
45
|
+
const square_1 = require("./square");
|
|
46
|
+
const cells_module_scss_1 = __importDefault(require("./cells.module.css"));
|
|
47
|
+
/**
|
|
48
|
+
* Превращает поле uikit в ячейку таблицы. В таблице `cells` поле «плоское» и занимает всю ячейку (рамку рисует ячейка:
|
|
49
|
+
* фокус внутри, ошибка красным с уголком), в остальных видах это обычное поле размера `s` во всю ширину колонки.
|
|
50
|
+
* Все пропсы исходного поля (формат, маска, границы, `onUpdate`...) работают как обычно.
|
|
51
|
+
*/
|
|
52
|
+
function FieldCellBody({ Field, withRef, fieldRef, error, ...props }) {
|
|
53
|
+
const variant = (0, context_1.useTableVariant)();
|
|
54
|
+
// В «квадратной» ячейке текст ошибки лежит в подсказке рамки, в остальных видах — подпись под полем
|
|
55
|
+
const caption = variant !== 'cells' && typeof error === 'string' ? error : undefined;
|
|
56
|
+
const field = ((0, jsx_runtime_1.jsx)(Field, { ...{
|
|
57
|
+
...props,
|
|
58
|
+
...(withRef ? { ref: fieldRef } : {}),
|
|
59
|
+
size: 's',
|
|
60
|
+
fullWidth: true,
|
|
61
|
+
status: error ? 'error' : undefined,
|
|
62
|
+
caption,
|
|
63
|
+
} }));
|
|
64
|
+
if (variant === 'cells') {
|
|
65
|
+
return ((0, jsx_runtime_1.jsx)(square_1.SquareFrame, { error: error, className: cells_module_scss_1.default.squareFlat, children: field }));
|
|
66
|
+
}
|
|
67
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: cells_module_scss_1.default.field, "data-table-ignore": true, children: field }));
|
|
68
|
+
}
|
|
69
|
+
function createFieldCell(Field, name, withRef = false) {
|
|
70
|
+
// `ref` — на поле ввода: нужен для фокуса на первую ошибку формы. Остальные ячейки `ref` не принимают
|
|
71
|
+
if (withRef) {
|
|
72
|
+
const Cell = (0, react_1.forwardRef)((props, ref) => ((0, jsx_runtime_1.jsx)(FieldCellBody, { ...props, Field: Field, withRef: true, fieldRef: ref })));
|
|
73
|
+
Cell.displayName = name;
|
|
74
|
+
return Cell;
|
|
75
|
+
}
|
|
76
|
+
const Cell = (props) => (0, jsx_runtime_1.jsx)(FieldCellBody, { ...props, Field: Field, withRef: false });
|
|
77
|
+
Cell.displayName = name;
|
|
78
|
+
return Cell;
|
|
79
|
+
}
|
|
80
|
+
/** Дата: `DatePicker` в ячейке (формат, границы дат, недоступные дни, `time` — как у обычного; диапазон не поддерживается) */
|
|
81
|
+
exports.TableCellDatePicker = createFieldCell(uikit_1.DatePicker, 'TableCellDatePicker', true);
|
|
82
|
+
/** Время: `TimePicker` в ячейке */
|
|
83
|
+
exports.TableCellTimePicker = createFieldCell(uikit_1.TimePicker, 'TableCellTimePicker');
|
|
84
|
+
/** Число с форматированием: `NumberInput` в ячейке (`preset`, `min`, `max`, `decimalPrecision`) */
|
|
85
|
+
exports.TableCellNumberInput = createFieldCell(uikit_1.NumberInput, 'TableCellNumberInput', true);
|
|
86
|
+
/** Поле с маской: `MaskedInput` в ячейке (телефон, номер, дата по маске) */
|
|
87
|
+
exports.TableCellMaskedInput = createFieldCell(uikit_1.MaskedInput, 'TableCellMaskedInput', true);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SquareFrame = exports.TableCellFileUpload = exports.TableCellImage = exports.TableCellFile = exports.TableCellCheckbox = exports.TableCellTextarea = exports.TableCellMaskedInput = exports.TableCellNumberInput = exports.TableCellTimePicker = exports.TableCellDatePicker = exports.TableCellDate = exports.TableCellExpand = exports.TableCellCopy = exports.TableCellSwitch = exports.TableCellSelect = exports.TableCellInput = exports.TableCellActions = exports.TableCellLink = void 0;
|
|
4
|
+
var table_cell_link_1 = require("./table-cell-link");
|
|
5
|
+
Object.defineProperty(exports, "TableCellLink", { enumerable: true, get: function () { return table_cell_link_1.TableCellLink; } });
|
|
6
|
+
var table_cell_actions_1 = require("./table-cell-actions");
|
|
7
|
+
Object.defineProperty(exports, "TableCellActions", { enumerable: true, get: function () { return table_cell_actions_1.TableCellActions; } });
|
|
8
|
+
var table_cell_input_1 = require("./table-cell-input");
|
|
9
|
+
Object.defineProperty(exports, "TableCellInput", { enumerable: true, get: function () { return table_cell_input_1.TableCellInput; } });
|
|
10
|
+
var table_cell_select_1 = require("./table-cell-select");
|
|
11
|
+
Object.defineProperty(exports, "TableCellSelect", { enumerable: true, get: function () { return table_cell_select_1.TableCellSelect; } });
|
|
12
|
+
var table_cell_switch_1 = require("./table-cell-switch");
|
|
13
|
+
Object.defineProperty(exports, "TableCellSwitch", { enumerable: true, get: function () { return table_cell_switch_1.TableCellSwitch; } });
|
|
14
|
+
var table_cell_copy_1 = require("./table-cell-copy");
|
|
15
|
+
Object.defineProperty(exports, "TableCellCopy", { enumerable: true, get: function () { return table_cell_copy_1.TableCellCopy; } });
|
|
16
|
+
var table_cell_expand_1 = require("./table-cell-expand");
|
|
17
|
+
Object.defineProperty(exports, "TableCellExpand", { enumerable: true, get: function () { return table_cell_expand_1.TableCellExpand; } });
|
|
18
|
+
var table_cell_date_1 = require("./table-cell-date");
|
|
19
|
+
Object.defineProperty(exports, "TableCellDate", { enumerable: true, get: function () { return table_cell_date_1.TableCellDate; } });
|
|
20
|
+
var field_cells_1 = require("./field-cells");
|
|
21
|
+
Object.defineProperty(exports, "TableCellDatePicker", { enumerable: true, get: function () { return field_cells_1.TableCellDatePicker; } });
|
|
22
|
+
Object.defineProperty(exports, "TableCellTimePicker", { enumerable: true, get: function () { return field_cells_1.TableCellTimePicker; } });
|
|
23
|
+
Object.defineProperty(exports, "TableCellNumberInput", { enumerable: true, get: function () { return field_cells_1.TableCellNumberInput; } });
|
|
24
|
+
Object.defineProperty(exports, "TableCellMaskedInput", { enumerable: true, get: function () { return field_cells_1.TableCellMaskedInput; } });
|
|
25
|
+
var table_cell_textarea_1 = require("./table-cell-textarea");
|
|
26
|
+
Object.defineProperty(exports, "TableCellTextarea", { enumerable: true, get: function () { return table_cell_textarea_1.TableCellTextarea; } });
|
|
27
|
+
var table_cell_checkbox_1 = require("./table-cell-checkbox");
|
|
28
|
+
Object.defineProperty(exports, "TableCellCheckbox", { enumerable: true, get: function () { return table_cell_checkbox_1.TableCellCheckbox; } });
|
|
29
|
+
var table_cell_file_1 = require("./table-cell-file");
|
|
30
|
+
Object.defineProperty(exports, "TableCellFile", { enumerable: true, get: function () { return table_cell_file_1.TableCellFile; } });
|
|
31
|
+
var table_cell_image_1 = require("./table-cell-image");
|
|
32
|
+
Object.defineProperty(exports, "TableCellImage", { enumerable: true, get: function () { return table_cell_image_1.TableCellImage; } });
|
|
33
|
+
var table_cell_file_upload_1 = require("./table-cell-file-upload");
|
|
34
|
+
Object.defineProperty(exports, "TableCellFileUpload", { enumerable: true, get: function () { return table_cell_file_upload_1.TableCellFileUpload; } });
|
|
35
|
+
var square_1 = require("./square");
|
|
36
|
+
Object.defineProperty(exports, "SquareFrame", { enumerable: true, get: function () { return square_1.SquareFrame; } });
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.KIND_CONFIG = void 0;
|
|
41
|
+
exports.SquareSelect = SquareSelect;
|
|
42
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
43
|
+
const react_1 = __importStar(require("react"));
|
|
44
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
45
|
+
const uikit_1 = require("@lt-ui/uikit");
|
|
46
|
+
const cells_module_scss_1 = __importDefault(require("./cells.module.css"));
|
|
47
|
+
const locale_1 = require("../locale");
|
|
48
|
+
exports.KIND_CONFIG = {
|
|
49
|
+
select: { mode: 'single' },
|
|
50
|
+
multiselect: { mode: 'multiple' },
|
|
51
|
+
autocomplete: { mode: 'single', showSearch: true, strict: false },
|
|
52
|
+
};
|
|
53
|
+
/** «Квадратная» ячейка выбора: поле без рамки на всю ячейку на `useSelect`, список открывается под ячейкой */
|
|
54
|
+
function SquareSelect({ options, value, onUpdate, placeholder: placeholderProp, disabled, selectProps, kind = 'select', 'aria-label': ariaLabel, }) {
|
|
55
|
+
const { t } = (0, locale_1.useLocale)();
|
|
56
|
+
const placeholder = placeholderProp !== null && placeholderProp !== void 0 ? placeholderProp : t('table.cell.select');
|
|
57
|
+
const select = (0, uikit_1.useSelect)({
|
|
58
|
+
...selectProps,
|
|
59
|
+
...exports.KIND_CONFIG[kind],
|
|
60
|
+
options,
|
|
61
|
+
value,
|
|
62
|
+
onUpdate,
|
|
63
|
+
placeholder,
|
|
64
|
+
disabled,
|
|
65
|
+
});
|
|
66
|
+
const { inputProps, listboxProps, activatorRef, popupRef } = (0, uikit_1.useSelectInputBindings)(select);
|
|
67
|
+
const wasOpen = (0, react_1.useRef)(false);
|
|
68
|
+
// В мультиселекте выбранное видно в поле сразу, пока список открыт (иначе поле показывало бы заглушку)
|
|
69
|
+
const display = kind === 'multiselect' && !select.searchValue && select.multiselectDisplayLabels.length
|
|
70
|
+
? select.multiselectDisplayLabels.join(', ')
|
|
71
|
+
: inputProps.value;
|
|
72
|
+
return ((0, jsx_runtime_1.jsx)(uikit_1.Popover, { open: select.open, onOpenChange: next => !next && select.close(), trigger: "manual", layer: false, returnFocus: false, arrow: false, matchWidth: true, offset: 2, placement: "bottom-start", anchor: (0, jsx_runtime_1.jsxs)("div", { ref: activatorRef, className: cells_module_scss_1.default.squareSelectRow, children: [(0, jsx_runtime_1.jsx)("input", { ...inputProps, value: display, type: "text", className: (0, clsx_1.default)(cells_module_scss_1.default.squareInput, cells_module_scss_1.default.squareSelectInput), "aria-label": ariaLabel, onChange: event => inputProps.onChange(event, event.target.value),
|
|
73
|
+
// Повторный клик по полю закрывает открытый список (с поиском клик ставит курсор, список остаётся)
|
|
74
|
+
onMouseDown: () => {
|
|
75
|
+
wasOpen.current = select.open;
|
|
76
|
+
}, onClick: event => wasOpen.current && !select.showSearch ? select.close() : inputProps.onClick(event), "data-table-ignore": true }), (0, jsx_runtime_1.jsx)("span", { className: cells_module_scss_1.default.squareArrow, "aria-hidden": true, onMouseDown: event => event.preventDefault(), onClick: select.toggleOpen })] }), children: (0, jsx_runtime_1.jsx)("div", { ref: popupRef, children: (0, jsx_runtime_1.jsx)(uikit_1.SelectListbox, { ...listboxProps, open: select.open }) }) }));
|
|
77
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.SquareFrame = SquareFrame;
|
|
41
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
42
|
+
const react_1 = __importStar(require("react"));
|
|
43
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
44
|
+
const uikit_1 = require("@lt-ui/uikit");
|
|
45
|
+
const cells_module_scss_1 = __importDefault(require("./cells.module.css"));
|
|
46
|
+
const NARROW_QUERY = '(max-width: 767px)';
|
|
47
|
+
const subscribeNarrow = (notify) => {
|
|
48
|
+
var _a;
|
|
49
|
+
const query = (_a = globalThis.matchMedia) === null || _a === void 0 ? void 0 : _a.call(globalThis, NARROW_QUERY);
|
|
50
|
+
query === null || query === void 0 ? void 0 : query.addEventListener('change', notify);
|
|
51
|
+
return () => query === null || query === void 0 ? void 0 : query.removeEventListener('change', notify);
|
|
52
|
+
};
|
|
53
|
+
const getNarrow = () => { var _a, _b; return (_b = (_a = globalThis.matchMedia) === null || _a === void 0 ? void 0 : _a.call(globalThis, NARROW_QUERY).matches) !== null && _b !== void 0 ? _b : false; };
|
|
54
|
+
/** Узкий экран (телефон, маленький планшет): ошибка ячейки показывается под ней, а не справа */
|
|
55
|
+
function useNarrowScreen() {
|
|
56
|
+
return (0, react_1.useSyncExternalStore)(subscribeNarrow, getNarrow, () => false);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Рамка «квадратной» ячейки: заполняет ячейку таблицы целиком, фокус рисуется рамкой внутри ячейки, ошибка — красной
|
|
60
|
+
* рамкой и треугольником в углу, как в электронных таблицах. Текст ошибки не занимает места в таблице: красная
|
|
61
|
+
* подсказка открывается справа от угла (если места нет — по обычным правилам подсказок на другой стороне).
|
|
62
|
+
* На узком экране ячейка при фокусе поднимается к верхнему краю, ошибка пишется под ней на всю ширину ячейки
|
|
63
|
+
* и нужной высоты, а ниже открывается клавиатура.
|
|
64
|
+
*/
|
|
65
|
+
function SquareFrame({ children, error, className }) {
|
|
66
|
+
const [hovered, setHovered] = (0, react_1.useState)(false);
|
|
67
|
+
const [focused, setFocused] = (0, react_1.useState)(false);
|
|
68
|
+
const blurTimer = (0, react_1.useRef)(undefined);
|
|
69
|
+
const root = (0, react_1.useRef)(null);
|
|
70
|
+
const narrow = useNarrowScreen();
|
|
71
|
+
const hasText = typeof error === 'string' && error !== '';
|
|
72
|
+
(0, react_1.useEffect)(() => () => clearTimeout(blurTimer.current), []);
|
|
73
|
+
// Клавиатура на телефоне закрывает нижнюю часть экрана: ячейку с ошибкой поднимаем наверх, ошибка и клавиатура — под ней
|
|
74
|
+
(0, react_1.useEffect)(() => {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
if (narrow && focused && hasText)
|
|
77
|
+
(_b = (_a = root.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a, { block: 'start', inline: 'nearest', behavior: 'smooth' });
|
|
78
|
+
}, [narrow, focused, hasText]);
|
|
79
|
+
// Если элемент под курсором или в фокусе исчез (закрылось окно поверх ячейки), `mouseleave` и `blur` не придут:
|
|
80
|
+
// клик или фокус вне ячейки и вне её окон (порталов) сбрасывают наведение и фокус
|
|
81
|
+
(0, react_1.useEffect)(() => {
|
|
82
|
+
if (!hovered && !focused)
|
|
83
|
+
return undefined;
|
|
84
|
+
const outside = (event) => {
|
|
85
|
+
var _a;
|
|
86
|
+
return event.target instanceof Element &&
|
|
87
|
+
!((_a = root.current) === null || _a === void 0 ? void 0 : _a.contains(event.target)) &&
|
|
88
|
+
!event.target.closest('[data-lt-ui-portal]');
|
|
89
|
+
};
|
|
90
|
+
const reset = (event) => {
|
|
91
|
+
if (!outside(event))
|
|
92
|
+
return;
|
|
93
|
+
setHovered(false);
|
|
94
|
+
setFocused(false);
|
|
95
|
+
};
|
|
96
|
+
globalThis.document.addEventListener('pointerdown', reset, true);
|
|
97
|
+
globalThis.document.addEventListener('focusin', reset, true);
|
|
98
|
+
return () => {
|
|
99
|
+
globalThis.document.removeEventListener('pointerdown', reset, true);
|
|
100
|
+
globalThis.document.removeEventListener('focusin', reset, true);
|
|
101
|
+
};
|
|
102
|
+
}, [hovered, focused]);
|
|
103
|
+
const frame = ((0, jsx_runtime_1.jsx)("div", { ref: root, className: (0, clsx_1.default)(cells_module_scss_1.default.square, className), "data-error": error ? '' : undefined, "data-table-square": "", onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false),
|
|
104
|
+
// События фокуса из порталов (календарь, список) всплывают по дереву React: уход фокуса в них не скрывает ошибку
|
|
105
|
+
onFocus: () => {
|
|
106
|
+
clearTimeout(blurTimer.current);
|
|
107
|
+
setFocused(true);
|
|
108
|
+
}, onBlur: () => {
|
|
109
|
+
clearTimeout(blurTimer.current);
|
|
110
|
+
blurTimer.current = setTimeout(() => setFocused(false), 0);
|
|
111
|
+
}, children: children }));
|
|
112
|
+
if (typeof error !== 'string' || !error)
|
|
113
|
+
return frame;
|
|
114
|
+
return ((0, jsx_runtime_1.jsx)(uikit_1.Popover, { anchor: frame,
|
|
115
|
+
// Ошибка видна, пока ячейка в фокусе или под курсором, и пока приложение её передаёт
|
|
116
|
+
open: narrow ? focused : focused || hovered, trigger: "manual", placement: narrow ? 'bottom-start' : 'right-start', matchWidth: narrow, flip: !narrow, arrow: false, offset: 2, layer: "tooltip", role: "tooltip", returnFocus: false, closeOnOutsideClick: false, className: (0, clsx_1.default)(cells_module_scss_1.default.errorTip, narrow && cells_module_scss_1.default.errorTipNarrow), children: (0, jsx_runtime_1.jsx)("span", { className: cells_module_scss_1.default.errorTipText, children: error }) }));
|
|
117
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.TableCellActions = TableCellActions;
|
|
41
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
42
|
+
const react_1 = __importStar(require("react"));
|
|
43
|
+
const uikit_1 = require("@lt-ui/uikit");
|
|
44
|
+
const cells_module_scss_1 = __importDefault(require("./cells.module.css"));
|
|
45
|
+
const locale_1 = require("../locale");
|
|
46
|
+
const BUTTON = 32;
|
|
47
|
+
const GAP = 4;
|
|
48
|
+
const DotsIcon = () => ((0, jsx_runtime_1.jsxs)("svg", { viewBox: "0 0 24 24", width: "20", height: "20", fill: "currentColor", "aria-hidden": true, children: [(0, jsx_runtime_1.jsx)("circle", { cx: "5.5", cy: "12", r: "1.75" }), (0, jsx_runtime_1.jsx)("circle", { cx: "12", cy: "12", r: "1.75" }), (0, jsx_runtime_1.jsx)("circle", { cx: "18.5", cy: "12", r: "1.75" })] }));
|
|
49
|
+
/**
|
|
50
|
+
* Действия строки двумя способами. Кнопки в ряд через небольшой отступ (квадратные, со скруглением, с подсказками —
|
|
51
|
+
* например, корзина и карандаш) либо одна квадратная кнопка «⋯» со списком внутри. В режиме `auto` кнопки сворачиваются
|
|
52
|
+
* в меню, когда не помещаются в ячейку (ширина колонки — `size`) или задан `collapsed`.
|
|
53
|
+
*/
|
|
54
|
+
function TableCellActions({ actions, mode = 'auto', collapsed, label: labelProp, }) {
|
|
55
|
+
const { t } = (0, locale_1.useLocale)();
|
|
56
|
+
const label = labelProp !== null && labelProp !== void 0 ? labelProp : t('table.cell.actions');
|
|
57
|
+
const root = (0, react_1.useRef)(null);
|
|
58
|
+
const [fits, setFits] = (0, react_1.useState)(false);
|
|
59
|
+
const needed = actions.length * BUTTON + (actions.length - 1) * GAP;
|
|
60
|
+
const iconic = actions.every(action => action.icon);
|
|
61
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
62
|
+
const element = root.current;
|
|
63
|
+
if (mode !== 'auto' || !element)
|
|
64
|
+
return undefined;
|
|
65
|
+
const measure = () => setFits(element.clientWidth >= needed);
|
|
66
|
+
measure();
|
|
67
|
+
if (typeof ResizeObserver === 'undefined')
|
|
68
|
+
return undefined;
|
|
69
|
+
const observer = new ResizeObserver(measure);
|
|
70
|
+
observer.observe(element);
|
|
71
|
+
return () => observer.disconnect();
|
|
72
|
+
}, [mode, needed]);
|
|
73
|
+
const inline = iconic && !collapsed && (mode === 'inline' || (mode === 'auto' && fits));
|
|
74
|
+
return ((0, jsx_runtime_1.jsx)("span", { ref: root, className: cells_module_scss_1.default.actions, children: inline ? (actions.map(action => ((0, jsx_runtime_1.jsx)(uikit_1.Tooltip, { title: action.label, children: (0, jsx_runtime_1.jsx)(uikit_1.Button, { iconOnly: true, size: "s", variant: "outline", className: cells_module_scss_1.default.actionButton, "aria-label": action.label, disabled: action.disabled, onClick: action.onSelect, children: action.icon }) }, action.id)))) : ((0, jsx_runtime_1.jsx)(uikit_1.DropdownMenu, { "aria-label": label, closeOnSelect: true, placement: "bottom-end", onClick: value => { var _a; return (_a = actions.find(action => action.id === value)) === null || _a === void 0 ? void 0 : _a.onSelect(); }, button: (0, jsx_runtime_1.jsx)(uikit_1.DropdownMenuButton, { iconOnly: true, size: "s", variant: "outline", className: cells_module_scss_1.default.actionButton, iconRight: (0, jsx_runtime_1.jsx)("span", { hidden: true }), "aria-label": label, children: (0, jsx_runtime_1.jsx)(DotsIcon, {}) }), children: actions.map(action => ((0, jsx_runtime_1.jsx)(uikit_1.ListItem, { value: action.id, text: action.label, iconLeft: action.icon, disabled: action.disabled }, action.id))) })) }));
|
|
75
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.TableCellCheckbox = TableCellCheckbox;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const react_1 = __importDefault(require("react"));
|
|
10
|
+
const uikit_1 = require("@lt-ui/uikit");
|
|
11
|
+
const context_1 = require("../context");
|
|
12
|
+
const square_1 = require("./square");
|
|
13
|
+
const cells_module_scss_1 = __importDefault(require("./cells.module.css"));
|
|
14
|
+
/** Флажок в ячейке по центру (в таблице `cells` — во всю ячейку, клик в любом месте ячейки не нужен: целится сам флажок) */
|
|
15
|
+
function TableCellCheckbox({ error, ...props }) {
|
|
16
|
+
const variant = (0, context_1.useTableVariant)();
|
|
17
|
+
const box = ((0, jsx_runtime_1.jsx)("span", { className: cells_module_scss_1.default.checkboxCell, "data-table-ignore": true, children: (0, jsx_runtime_1.jsx)(uikit_1.Checkbox, { ...props, animated: false, status: error ? 'error' : undefined }) }));
|
|
18
|
+
return variant === 'cells' ? (0, jsx_runtime_1.jsx)(square_1.SquareFrame, { error: error, children: box }) : box;
|
|
19
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.TableCellCopy = TableCellCopy;
|
|
41
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
42
|
+
const react_1 = __importStar(require("react"));
|
|
43
|
+
const cells_module_scss_1 = __importDefault(require("./cells.module.css"));
|
|
44
|
+
const locale_1 = require("../locale");
|
|
45
|
+
const CopyIcon = () => ((0, jsx_runtime_1.jsxs)("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", "aria-hidden": true, children: [(0, jsx_runtime_1.jsx)("rect", { x: "8.5", y: "8.5", width: "11", height: "11", rx: "2", stroke: "currentColor", strokeWidth: "1.5" }), (0, jsx_runtime_1.jsx)("path", { d: "M15.5 8.5V6.5a2 2 0 0 0-2-2h-7a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h2", stroke: "currentColor", strokeWidth: "1.5" })] }));
|
|
46
|
+
const CheckIcon = () => ((0, jsx_runtime_1.jsx)("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", "aria-hidden": true, children: (0, jsx_runtime_1.jsx)("path", { d: "m5.5 12.5 4.5 4.5 8.5-9", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
47
|
+
/**
|
|
48
|
+
* Значение с копированием: текст обрезается многоточием, а справа при наведении (и при фокусе) плавно выезжает
|
|
49
|
+
* кнопка «скопировать»; после копирования на секунду показывает галочку.
|
|
50
|
+
*/
|
|
51
|
+
function TableCellCopy({ value, children, label }) {
|
|
52
|
+
const { t } = (0, locale_1.useLocale)();
|
|
53
|
+
const [copied, setCopied] = (0, react_1.useState)(false);
|
|
54
|
+
(0, react_1.useEffect)(() => {
|
|
55
|
+
if (!copied)
|
|
56
|
+
return undefined;
|
|
57
|
+
const timer = setTimeout(() => setCopied(false), 1400);
|
|
58
|
+
return () => clearTimeout(timer);
|
|
59
|
+
}, [copied]);
|
|
60
|
+
const copy = async () => {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
try {
|
|
63
|
+
await ((_b = (_a = globalThis.navigator) === null || _a === void 0 ? void 0 : _a.clipboard) === null || _b === void 0 ? void 0 : _b.writeText(value));
|
|
64
|
+
setCopied(true);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// Буфер недоступен (небезопасный контекст): ничего не показываем
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
return ((0, jsx_runtime_1.jsxs)("span", { className: cells_module_scss_1.default.copyCell, children: [(0, jsx_runtime_1.jsx)("span", { className: cells_module_scss_1.default.copyText, title: value, children: children !== null && children !== void 0 ? children : value }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: cells_module_scss_1.default.copyButton, "aria-label": copied ? t('table.cell.copied') : (label !== null && label !== void 0 ? label : t('table.cell.copy')), "data-copied": copied || undefined, "data-table-ignore": true, onClick: copy, children: copied ? (0, jsx_runtime_1.jsx)(CheckIcon, {}) : (0, jsx_runtime_1.jsx)(CopyIcon, {}) })] }));
|
|
71
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TableCellDate = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const PRESETS = {
|
|
10
|
+
date: { day: '2-digit', month: '2-digit', year: 'numeric' },
|
|
11
|
+
datetime: { day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit' },
|
|
12
|
+
time: { hour: '2-digit', minute: '2-digit' },
|
|
13
|
+
};
|
|
14
|
+
/** Дата в ячейке: форматируется через `Intl`, в `<time>` лежит ISO-значение для скринридеров и поиска */
|
|
15
|
+
const TableCellDate = ({ value, format = 'date', locale, placeholder = '—' }) => {
|
|
16
|
+
const date = value === null || value === undefined || value === '' ? null : new Date(value);
|
|
17
|
+
if (!date || Number.isNaN(date.getTime()))
|
|
18
|
+
return (0, jsx_runtime_1.jsx)("span", { children: placeholder });
|
|
19
|
+
const options = typeof format === 'string' ? PRESETS[format] : format;
|
|
20
|
+
return (0, jsx_runtime_1.jsx)("time", { dateTime: date.toISOString(), children: new Intl.DateTimeFormat(locale, options).format(date) });
|
|
21
|
+
};
|
|
22
|
+
exports.TableCellDate = TableCellDate;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.TableCellExpand = TableCellExpand;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const react_1 = __importDefault(require("react"));
|
|
10
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
11
|
+
const sort_icon_1 = require("../sort-icon");
|
|
12
|
+
const cells_module_scss_1 = __importDefault(require("./cells.module.css"));
|
|
13
|
+
const locale_1 = require("../locale");
|
|
14
|
+
/**
|
|
15
|
+
* Первая ячейка дерева: отступ по уровню (`row.depth`) и стрелка раскрытия дочерних строк. Нужны `getSubRows`
|
|
16
|
+
* в опциях таблицы; раскрытие и сворачивание — состояние `expanded` TanStack Table.
|
|
17
|
+
*/
|
|
18
|
+
function TableCellExpand({ row, children, indent = 20, }) {
|
|
19
|
+
const { t } = (0, locale_1.useLocale)();
|
|
20
|
+
const canExpand = row.getCanExpand();
|
|
21
|
+
const expanded = row.getIsExpanded();
|
|
22
|
+
return ((0, jsx_runtime_1.jsxs)("span", { className: cells_module_scss_1.default.expandCell, style: { paddingInlineStart: row.depth * indent }, children: [canExpand ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: (0, clsx_1.default)(cells_module_scss_1.default.expandButton, expanded && cells_module_scss_1.default.expandButtonOpen), "aria-expanded": expanded, "aria-label": expanded ? t('table.cell.collapse') : t('table.cell.expand'), onClick: row.getToggleExpandedHandler(), children: (0, jsx_runtime_1.jsx)(sort_icon_1.ChevronIcon, {}) })) : ((0, jsx_runtime_1.jsx)("span", { className: cells_module_scss_1.default.expandSpacer, "aria-hidden": true })), (0, jsx_runtime_1.jsx)("span", { className: cells_module_scss_1.default.expandLabel, children: children })] }));
|
|
23
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.TableCellFileUpload = TableCellFileUpload;
|
|
41
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
42
|
+
const react_1 = __importStar(require("react"));
|
|
43
|
+
const uikit_1 = require("@lt-ui/uikit");
|
|
44
|
+
const table_cell_file_1 = require("./table-cell-file");
|
|
45
|
+
const cells_module_scss_1 = __importDefault(require("./cells.module.css"));
|
|
46
|
+
const locale_1 = require("../locale");
|
|
47
|
+
const UploadIcon = () => ((0, jsx_runtime_1.jsx)("svg", { viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", "aria-hidden": true, children: (0, jsx_runtime_1.jsx)("path", { d: "M12 15V4m0 0L8 8m4-4 4 4M5 19.5h14", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
48
|
+
/**
|
|
49
|
+
* Загрузка файла в ячейке: квадратная кнопка открывает системный выбор, выбранные файлы — иконками по расширению.
|
|
50
|
+
* Клик по иконке открывает окно с именем, размером и кнопкой «Удалить».
|
|
51
|
+
*/
|
|
52
|
+
function TableCellFileUpload({ files = [], onSelect, onRemove, accept, multiple, disabled, removeLabel: removeLabelProp, 'aria-label': ariaLabel, }) {
|
|
53
|
+
const { t } = (0, locale_1.useLocale)();
|
|
54
|
+
const removeLabel = removeLabelProp !== null && removeLabelProp !== void 0 ? removeLabelProp : t('table.cell.remove');
|
|
55
|
+
const input = (0, react_1.useRef)(null);
|
|
56
|
+
return ((0, jsx_runtime_1.jsxs)("span", { className: cells_module_scss_1.default.upload, "data-table-ignore": true, children: [(0, jsx_runtime_1.jsx)("input", { ref: input, type: "file", hidden: true, accept: accept, multiple: multiple, onChange: event => {
|
|
57
|
+
var _a;
|
|
58
|
+
onSelect(Array.from((_a = event.target.files) !== null && _a !== void 0 ? _a : []));
|
|
59
|
+
event.target.value = '';
|
|
60
|
+
} }), (0, jsx_runtime_1.jsx)(uikit_1.Button, { iconOnly: true, size: "s", variant: "outline", className: cells_module_scss_1.default.actionButton, disabled: disabled, "aria-label": ariaLabel, onClick: () => { var _a; return (_a = input.current) === null || _a === void 0 ? void 0 : _a.click(); }, children: (0, jsx_runtime_1.jsx)(UploadIcon, {}) }), files.map((file, index) => ((0, jsx_runtime_1.jsx)(uikit_1.Popover, { placement: "bottom-start", arrow: false, offset: 4, anchor: (0, jsx_runtime_1.jsx)("button", { type: "button", className: cells_module_scss_1.default.uploadFile, "aria-label": file.name, title: file.name, children: (0, jsx_runtime_1.jsx)("span", { className: cells_module_scss_1.default.fileIcon, children: (0, uikit_1.getDefaultFileIconByExtension)((0, uikit_1.splitFileName)(file.name).ext) }) }), children: (0, jsx_runtime_1.jsxs)("div", { className: cells_module_scss_1.default.uploadPanel, children: [(0, jsx_runtime_1.jsx)("div", { className: cells_module_scss_1.default.uploadPanelName, children: file.name }), file.size !== undefined && ((0, jsx_runtime_1.jsx)("div", { className: cells_module_scss_1.default.fileSize, children: (0, table_cell_file_1.formatFileSize)(file.size, t) })), onRemove && ((0, jsx_runtime_1.jsx)(uikit_1.Button, { size: "s", variant: "outline", onClick: () => onRemove(index), children: removeLabel }))] }) }, `${file.name}-${index}`)))] }));
|
|
61
|
+
}
|