@addev-be/ui 2.4.2 → 2.4.3
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/components/data/DataGrid/helpers/columns.d.ts +2 -2
- package/dist/components/data/DataGrid/helpers/columns.js +17 -9
- package/dist/components/search/QuickSearchBar.js +3 -1
- package/package.json +2 -2
- package/src/components/data/DataGrid/helpers/columns.tsx +31 -27
- package/src/components/search/QuickSearchBar.tsx +3 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataGridCheckboxColumn, DataGridColorColumn, DataGridColumn, DataGridDateColumn, DataGridNumberColumn, DataGridSelectColumn, DataGridSettings, DataGridTextColumn } from '../types';
|
|
2
|
+
import { SqlRequestDataGridCheckboxColumn, SqlRequestDataGridTextColumn } from '../../SqlRequestDataGrid/types';
|
|
2
3
|
import { DeepPartial } from '../../../../types';
|
|
3
|
-
import { SqlRequestDataGridTextColumn } from '../../SqlRequestDataGrid/types';
|
|
4
4
|
export declare const isColumnVisible: <R>(obj: DataGridColumn<R> | DataGridSettings) => boolean;
|
|
5
5
|
export declare const buildExcelFormat: (decimals?: number, suffix?: string) => string;
|
|
6
6
|
export declare const textColumn: <R extends Record<string, any>>(key: string, title: string, options?: DeepPartial<SqlRequestDataGridTextColumn<R>>, otherOptions?: Partial<DataGridTextColumn<R>>) => DataGridTextColumn<R>;
|
|
@@ -12,6 +12,6 @@ export declare const monthColumn: <R extends Record<string, any>>(key: string, t
|
|
|
12
12
|
export declare const numberColumn: <R extends Record<string, any>>(key: string, title: string, decimals?: number, options?: DeepPartial<SqlRequestDataGridTextColumn<R>>, otherOptions?: Partial<DataGridNumberColumn<R>>) => DataGridNumberColumn<R>;
|
|
13
13
|
export declare const moneyColumn: <R extends Record<string, any>>(key: string, title: string, decimals?: number, currency?: string | ((row: R) => string), options?: DeepPartial<SqlRequestDataGridTextColumn<R>>, otherOptions?: Partial<DataGridNumberColumn<R>>) => DataGridNumberColumn<R>;
|
|
14
14
|
export declare const percentageColumn: <R extends Record<string, any>>(key: string, title: string, decimals?: number, options?: DeepPartial<SqlRequestDataGridTextColumn<R>>, otherOptions?: Partial<DataGridNumberColumn<R>>) => DataGridNumberColumn<R>;
|
|
15
|
-
export declare const checkboxColumn: <R extends Record<string, any>>(key: string, title: string,
|
|
15
|
+
export declare const checkboxColumn: <R extends Record<string, any>>(key: string, title: string, options?: DeepPartial<DataGridCheckboxColumn<R>>) => SqlRequestDataGridCheckboxColumn<R>;
|
|
16
16
|
export declare const selectColumn: <R extends Record<string, any>, T>(key: string, title: string, items: T[], itemKey: (item: T | null) => string, itemLabel: (item: T | null) => string, otherOptions?: Partial<DataGridSelectColumn<R, T>>) => DataGridSelectColumn<R, T>;
|
|
17
17
|
export declare const colorColumn: <R extends Record<string, any>>(key: string, title: string, otherOptions?: Partial<DataGridColorColumn<R>>) => DataGridColorColumn<R>;
|
|
@@ -30,6 +30,7 @@ var jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
30
30
|
var filters_1 = require("./filters");
|
|
31
31
|
var dates_1 = require("../../../../helpers/dates");
|
|
32
32
|
var numbers_1 = require("../../../../helpers/numbers");
|
|
33
|
+
var lodash_1 = require("lodash");
|
|
33
34
|
var CheckboxEditableCell_1 = require("../DataGridEditableCell/CheckboxEditableCell");
|
|
34
35
|
var DateEditableCell_1 = require("../DataGridEditableCell/DateEditableCell");
|
|
35
36
|
var NumberEditableCell_1 = require("../DataGridEditableCell/NumberEditableCell");
|
|
@@ -37,7 +38,6 @@ var Select_1 = require("../../../forms/Form/Select");
|
|
|
37
38
|
var typography_1 = require("../../../../helpers/styled/typography");
|
|
38
39
|
var TextEditableCell_1 = require("../DataGridEditableCell/TextEditableCell");
|
|
39
40
|
var moment_1 = __importDefault(require("moment"));
|
|
40
|
-
var lodash_1 = require("lodash");
|
|
41
41
|
var components_1 = require("../../../../helpers/components");
|
|
42
42
|
var isColumnVisible = function (obj) { return (obj === null || obj === void 0 ? void 0 : obj.order) !== -1; };
|
|
43
43
|
exports.isColumnVisible = isColumnVisible;
|
|
@@ -143,15 +143,23 @@ var percentageColumn = function (key, title, decimals, options, otherOptions) {
|
|
|
143
143
|
return column;
|
|
144
144
|
};
|
|
145
145
|
exports.percentageColumn = percentageColumn;
|
|
146
|
-
var checkboxColumn = function (key, title,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
146
|
+
var checkboxColumn = function (key, title, options) {
|
|
147
|
+
return (0, lodash_1.merge)({
|
|
148
|
+
key: key,
|
|
149
|
+
name: title,
|
|
150
|
+
type: 'checkbox',
|
|
151
|
+
render: function (_row) {
|
|
152
|
+
var normalized = typeof _row === 'string' ? _row : String(_row);
|
|
153
|
+
var isChecked = normalized === 'true' || normalized === '1';
|
|
154
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", checked: isChecked, readOnly: true }), (0, jsx_runtime_1.jsx)("span", { children: isChecked ? ' Oui' : ' Non' })] }));
|
|
150
155
|
},
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
},
|
|
154
|
-
|
|
156
|
+
getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; },
|
|
157
|
+
sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; },
|
|
158
|
+
filter: __assign(__assign({}, (0, filters_1.numberFilter)(key)), { getter: function (row) { var _a; return +((_a = row[key]) !== null && _a !== void 0 ? _a : 0); } }),
|
|
159
|
+
footer: function (rows) { return "".concat(rows[0][key], " \u00E9l\u00E9ments"); },
|
|
160
|
+
editComponent: CheckboxEditableCell_1.CheckboxEditableCell,
|
|
161
|
+
}, options);
|
|
162
|
+
};
|
|
155
163
|
exports.checkboxColumn = checkboxColumn;
|
|
156
164
|
var selectColumn = function (key, title, items, itemKey, itemLabel, otherOptions) { return (__assign({ key: key, type: 'select', name: title, render: function (value, row) { var _a; return (_a = itemLabel(row[key])) !== null && _a !== void 0 ? _a : ''; }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : null; }, sortGetter: function (row) { var _a; return (_a = itemLabel(row[key])) !== null && _a !== void 0 ? _a : ''; }, footer: function (_, filteredRows) { return "".concat(filteredRows.length, " \u00E9l\u00E9ments"); }, filter: __assign(__assign({}, (0, filters_1.textFilter)(key)), { renderer: function (value) { var _a; return (_a = itemLabel(value)) !== null && _a !== void 0 ? _a : ''; } }), items: items, itemKey: itemKey, itemLabel: itemLabel, editComponent: (0, components_1.withDisplayName)(function (_a) {
|
|
157
165
|
var value = _a.value, onChange = _a.onChange, onClose = _a.onClose, ref = _a.ref;
|
|
@@ -73,6 +73,8 @@ var QuickSearchBar = function (_a) {
|
|
|
73
73
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
74
74
|
});
|
|
75
75
|
}, []);
|
|
76
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(InputComponent, { type: "text", ref: fakeInputRef, value: term, onFocus: onFocus, placeholder: placeholder }), dropdownVisible && rect && ((0, jsx_runtime_1.jsx)(Dropdown_1.Dropdown, { "$sourceRect": destRect, onClose: function () { return setDropdownVisible(false); }, "$width": rect.width, "$height": [results ? 250 : rect.height, 400], "$autoPositionY": false, children: (0, jsx_runtime_1.jsxs)(styles.QuickSearchDropdownContainer, { children: [(0, jsx_runtime_1.jsx)(InputComponent, { type: "text", ref: inputRef, value: term, placeholder: placeholder, onChange: function (e) { return setTerm(e.target.value); }, onClick: function (e) { return e.stopPropagation(); }
|
|
76
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(InputComponent, { type: "text", ref: fakeInputRef, value: term, onFocus: onFocus, placeholder: placeholder }), dropdownVisible && rect && ((0, jsx_runtime_1.jsx)(Dropdown_1.Dropdown, { "$sourceRect": destRect, onClose: function () { return setDropdownVisible(false); }, "$width": rect.width, "$height": [results ? 250 : rect.height, 400], "$autoPositionY": false, children: (0, jsx_runtime_1.jsxs)(styles.QuickSearchDropdownContainer, { children: [(0, jsx_runtime_1.jsx)(InputComponent, { type: "text", ref: inputRef, value: term, placeholder: placeholder, onChange: function (e) { return setTerm(e.target.value); }, onClick: function (e) { return e.stopPropagation(); }, onPaste: function (e) {
|
|
77
|
+
e.clipboardData.getData('text');
|
|
78
|
+
} }), results && ((0, jsx_runtime_1.jsx)(QuickSearchResults_1.QuickSearchResults, { results: results, definitions: types, term: debouncedTerm }))] }) }))] }));
|
|
77
79
|
};
|
|
78
80
|
exports.QuickSearchBar = QuickSearchBar;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@addev-be/ui",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"watch": "tsc -b --watch",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"update-version": "../../node/update-version.mjs"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@addev-be/framework-utils": "^2.4.
|
|
23
|
+
"@addev-be/framework-utils": "^2.4.3",
|
|
24
24
|
"@types/lodash": "^4.17.20",
|
|
25
25
|
"@types/react": "^19.1.13",
|
|
26
26
|
"@types/react-dom": "^19.1.9",
|
|
@@ -10,6 +10,10 @@ import {
|
|
|
10
10
|
DataGridSettings,
|
|
11
11
|
DataGridTextColumn,
|
|
12
12
|
} from '../types';
|
|
13
|
+
import {
|
|
14
|
+
SqlRequestDataGridCheckboxColumn,
|
|
15
|
+
SqlRequestDataGridTextColumn,
|
|
16
|
+
} from '../../SqlRequestDataGrid/types';
|
|
13
17
|
import { dateFilter, numberFilter, textFilter } from './filters';
|
|
14
18
|
import { formatDate, formatDateTime } from '../../../../helpers/dates';
|
|
15
19
|
import {
|
|
@@ -18,17 +22,17 @@ import {
|
|
|
18
22
|
formatNumberInvariant,
|
|
19
23
|
formatPercentage,
|
|
20
24
|
} from '../../../../helpers/numbers';
|
|
25
|
+
import { merge, repeat } from 'lodash';
|
|
21
26
|
|
|
22
27
|
import { CheckboxEditableCell } from '../DataGridEditableCell/CheckboxEditableCell';
|
|
23
28
|
import { DateEditableCell } from '../DataGridEditableCell/DateEditableCell';
|
|
24
29
|
import { DeepPartial } from '../../../../types';
|
|
25
30
|
import { NumberEditableCell } from '../DataGridEditableCell/NumberEditableCell';
|
|
26
31
|
import { Select } from '../../../forms/Form/Select';
|
|
27
|
-
import {
|
|
32
|
+
import { SqlRequestGridCheckboxColumn } from '../../SqlRequestGrid/types';
|
|
28
33
|
import { StyledTypography } from '../../../../helpers/styled/typography';
|
|
29
34
|
import { TextEditableCell } from '../DataGridEditableCell/TextEditableCell';
|
|
30
35
|
import moment from 'moment';
|
|
31
|
-
import { repeat } from 'lodash';
|
|
32
36
|
import { withDisplayName } from '../../../../helpers/components';
|
|
33
37
|
|
|
34
38
|
export const isColumnVisible = <R,>(
|
|
@@ -365,34 +369,34 @@ export const percentageColumn = <R extends Record<string, any>>(
|
|
|
365
369
|
};
|
|
366
370
|
return column;
|
|
367
371
|
};
|
|
368
|
-
|
|
369
372
|
export const checkboxColumn = <R extends Record<string, any>>(
|
|
370
373
|
key: string,
|
|
371
374
|
title: string,
|
|
372
|
-
|
|
373
|
-
):
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
375
|
+
options?: DeepPartial<DataGridCheckboxColumn<R>>
|
|
376
|
+
): SqlRequestDataGridCheckboxColumn<R> =>
|
|
377
|
+
merge(
|
|
378
|
+
{
|
|
379
|
+
key,
|
|
380
|
+
name: title,
|
|
381
|
+
type: 'checkbox',
|
|
382
|
+
render: (_row) => {
|
|
383
|
+
const normalized = typeof _row === 'string' ? _row : String(_row);
|
|
384
|
+
const isChecked = normalized === 'true' || normalized === '1';
|
|
385
|
+
return (
|
|
386
|
+
<>
|
|
387
|
+
<input type="checkbox" checked={isChecked} readOnly />
|
|
388
|
+
<span>{isChecked ? ' Oui' : ' Non'}</span>
|
|
389
|
+
</>
|
|
390
|
+
);
|
|
391
|
+
},
|
|
392
|
+
getter: (row) => row[key] ?? '',
|
|
393
|
+
sortGetter: (row) => row[key] ?? '',
|
|
394
|
+
filter: { ...numberFilter(key), getter: (row) => +(row[key] ?? 0) },
|
|
395
|
+
footer: (rows) => `${rows[0][key]} éléments`,
|
|
396
|
+
editComponent: CheckboxEditableCell,
|
|
397
|
+
} as SqlRequestGridCheckboxColumn<R>,
|
|
398
|
+
options
|
|
399
|
+
);
|
|
396
400
|
|
|
397
401
|
export const selectColumn = <R extends Record<string, any>, T>(
|
|
398
402
|
key: string,
|
|
@@ -83,6 +83,9 @@ export const QuickSearchBar = <R,>({
|
|
|
83
83
|
placeholder={placeholder}
|
|
84
84
|
onChange={(e) => setTerm(e.target.value)}
|
|
85
85
|
onClick={(e) => e.stopPropagation()}
|
|
86
|
+
onPaste={(e) => {
|
|
87
|
+
e.clipboardData.getData('text');
|
|
88
|
+
}}
|
|
86
89
|
/>
|
|
87
90
|
{results && (
|
|
88
91
|
<QuickSearchResults
|