@addev-be/ui 2.4.1 → 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.
Files changed (27) hide show
  1. package/assets/icons/table.svg +1 -1
  2. package/dist/components/data/DataGrid/helpers/columns.d.ts +2 -2
  3. package/dist/components/data/DataGrid/helpers/columns.js +17 -9
  4. package/dist/components/data/SqlRequestDataGrid/helpers/columns.js +3 -1
  5. package/dist/components/search/QuickSearchBar.js +3 -1
  6. package/package.json +2 -2
  7. package/src/components/data/DataGrid/DataGridFilterMenu/helpers.ts +23 -23
  8. package/src/components/data/DataGrid/helpers/columns.tsx +31 -27
  9. package/src/components/data/SqlRequestDataGrid/helpers/columns.tsx +4 -2
  10. package/src/components/search/QuickSearchBar.tsx +3 -0
  11. package/src/components/ui/Avatar/styles.ts +61 -61
  12. package/src/components/ui/TabsView/index.ts +3 -3
  13. package/src/providers/TrackingProvider/hooks.ts +14 -14
  14. package/dist/components/data/AdvancedRequestDataGrid/helpers/advancedRequests.d.ts +0 -14
  15. package/dist/components/data/AdvancedRequestDataGrid/helpers/advancedRequests.js +0 -76
  16. package/dist/components/data/AdvancedRequestDataGrid/helpers/columns.d.ts +0 -22
  17. package/dist/components/data/AdvancedRequestDataGrid/helpers/columns.js +0 -156
  18. package/dist/components/data/AdvancedRequestDataGrid/helpers/index.d.ts +0 -2
  19. package/dist/components/data/AdvancedRequestDataGrid/helpers/index.js +0 -18
  20. package/dist/components/data/AdvancedRequestDataGrid/index.d.ts +0 -2
  21. package/dist/components/data/AdvancedRequestDataGrid/index.js +0 -215
  22. package/dist/components/data/AdvancedRequestDataGrid/types.d.ts +0 -21
  23. package/dist/components/data/AdvancedRequestDataGrid/types.js +0 -2
  24. package/dist/components/data/DataGrid/DataGridEditableCell.d.ts +0 -2
  25. package/dist/components/data/DataGrid/DataGridEditableCell.js +0 -27
  26. package/dist/helpers/styled/index.d.ts +0 -1
  27. package/dist/helpers/styled/index.js +0 -17
@@ -1 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M48 264V160H232V264H48zm0 48H232V432H64c-8.8 0-16-7.2-16-16V312zM280 432V312H464V416c0 8.8-7.2 16-16 16H280zM464 264H280V160H464V264zM64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64z"/></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M48 264V160H232V264H48zm0 48H232V432H64c-8.8 0-16-7.2-16-16V312zM280 432V312H464V416c0 8.8-7.2 16-16 16H280zM464 264H280V160H464V264zM64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64z"/></svg>
@@ -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, otherOptions?: Partial<DataGridCheckboxColumn<R>>) => DataGridCheckboxColumn<R>;
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, otherOptions) { return (__assign({ key: key, type: 'checkbox', name: title, render: function (value, row) { return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", checked: row[key], readOnly: true }), (0, jsx_runtime_1.jsx)("span", { children: row[key] ? ' Oui' : ' Non' })] })); }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: (0, filters_1.numberFilter)(key), footer: {
147
- count: function (_, filteredRows) { return "".concat(filteredRows.length, " \u00E9l\u00E9ments"); },
148
- checked: function (_, filteredRows) {
149
- return "".concat(filteredRows.filter(function (row) { return !!row[key]; }).length, " coch\u00E9s");
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
- unchecked: function (_, filteredRows) {
152
- return "".concat(filteredRows.filter(function (row) { return !row[key]; }).length, " d\u00E9coch\u00E9s");
153
- },
154
- }, editComponent: CheckboxEditableCell_1.CheckboxEditableCell }, otherOptions)); };
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;
@@ -240,7 +240,9 @@ var sqlCheckboxColumn = function (key, title, options) {
240
240
  name: title,
241
241
  type: 'checkbox',
242
242
  render: function (value) {
243
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", checked: value, readOnly: true }), (0, jsx_runtime_1.jsx)("span", { children: value ? ' Oui' : ' Non' })] }));
243
+ var normalized = typeof value === 'string' ? value : String(value);
244
+ var isChecked = normalized === 'true' || normalized === '1';
245
+ 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' })] }));
244
246
  },
245
247
  getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; },
246
248
  sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; },
@@ -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(); } }), results && ((0, jsx_runtime_1.jsx)(QuickSearchResults_1.QuickSearchResults, { results: results, definitions: types, term: debouncedTerm }))] }) }))] }));
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.1",
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.1",
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",
@@ -1,23 +1,23 @@
1
- import { DataGridColumn, DataGridFilterValue } from '../types';
2
-
3
- import { uniq } from 'lodash';
4
-
5
- export const sortAvailableValues = <R>(
6
- values: unknown[],
7
- column: DataGridColumn<R>
8
- ): DataGridFilterValue[] => {
9
- switch (column?.type) {
10
- case 'number':
11
- return uniq(values).sort(
12
- (a, b) => (a as number) - (b as number)
13
- ) as number[];
14
- case 'select':
15
- return uniq(values).sort((a, b) =>
16
- column.itemLabel(a).localeCompare(column.itemLabel(b))
17
- ) as string[];
18
- default:
19
- return uniq(values).sort((a, b) =>
20
- (a as string).localeCompare(b as string)
21
- ) as string[];
22
- }
23
- };
1
+ import { DataGridColumn, DataGridFilterValue } from '../types';
2
+
3
+ import { uniq } from 'lodash';
4
+
5
+ export const sortAvailableValues = <R>(
6
+ values: unknown[],
7
+ column: DataGridColumn<R>
8
+ ): DataGridFilterValue[] => {
9
+ switch (column?.type) {
10
+ case 'number':
11
+ return uniq(values).sort(
12
+ (a, b) => (a as number) - (b as number)
13
+ ) as number[];
14
+ case 'select':
15
+ return uniq(values).sort((a, b) =>
16
+ column.itemLabel(a).localeCompare(column.itemLabel(b))
17
+ ) as string[];
18
+ default:
19
+ return uniq(values).sort((a, b) =>
20
+ (a as string).localeCompare(b as string)
21
+ ) as string[];
22
+ }
23
+ };
@@ -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 { SqlRequestDataGridTextColumn } from '../../SqlRequestDataGrid/types';
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
- otherOptions?: Partial<DataGridCheckboxColumn<R>>
373
- ): DataGridCheckboxColumn<R> => ({
374
- key,
375
- type: 'checkbox',
376
- name: title,
377
- render: (value, row) => (
378
- <>
379
- <input type="checkbox" checked={row[key]} readOnly />
380
- <span>{row[key] ? ' Oui' : ' Non'}</span>
381
- </>
382
- ),
383
- getter: (row) => row[key] ?? '',
384
- sortGetter: (row) => row[key] ?? '',
385
- filter: numberFilter(key),
386
- footer: {
387
- count: (_, filteredRows) => `${filteredRows.length} éléments`,
388
- checked: (_, filteredRows) =>
389
- `${filteredRows.filter((row) => !!row[key]).length} cochés`,
390
- unchecked: (_, filteredRows) =>
391
- `${filteredRows.filter((row) => !row[key]).length} décochés`,
392
- },
393
- editComponent: CheckboxEditableCell,
394
- ...otherOptions,
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,
@@ -382,10 +382,12 @@ export const sqlCheckboxColumn = <R extends Record<string, any>>(
382
382
  name: title,
383
383
  type: 'checkbox',
384
384
  render: (value) => {
385
+ const normalized = typeof value === 'string' ? value : String(value);
386
+ const isChecked = normalized === 'true' || normalized === '1';
385
387
  return (
386
388
  <>
387
- <input type="checkbox" checked={value} readOnly />
388
- <span>{value ? ' Oui' : ' Non'}</span>
389
+ <input type="checkbox" checked={isChecked} readOnly />
390
+ <span>{isChecked ? ' Oui' : ' Non'}</span>
389
391
  </>
390
392
  );
391
393
  },
@@ -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
@@ -1,61 +1,61 @@
1
- import styled, { css } from 'styled-components';
2
-
3
- export type AvatarContainerProps = {
4
- size: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
5
- };
6
-
7
- const stylesMap: Record<
8
- AvatarContainerProps['size'],
9
- ReturnType<typeof css>
10
- > = {
11
- xs: css`
12
- width: var(--size-6);
13
- height: var(--size-6);
14
- min-width: var(--size-6);
15
- min-height: var(--size-6);
16
- font-size: var(--text-xs);
17
- line-height: var(--text-xs);
18
- `,
19
- sm: css`
20
- width: var(--size-8);
21
- height: var(--size-8);
22
- min-width: var(--size-8);
23
- min-height: var(--size-8);
24
- font-size: var(--text-sm);
25
- line-height: var(--text-sm);
26
- `,
27
- md: css`
28
- width: var(--size-10);
29
- height: var(--size-10);
30
- min-width: var(--size-10);
31
- min-height: var(--size-10);
32
- font-size: var(--text-md);
33
- line-height: var(--text-md);
34
- `,
35
- lg: css`
36
- width: var(--size-12);
37
- height: var(--size-12);
38
- min-width: var(--size-12);
39
- min-height: var(--size-12);
40
- font-size: var(--text-lg);
41
- line-height: var(--text-lg);
42
- `,
43
- xl: css`
44
- width: var(--size-14);
45
- height: var(--size-14);
46
- min-width: var(--size-14);
47
- min-height: var(--size-14);
48
- font-size: var(--text-2xl);
49
- line-height: var(--text-2xl);
50
- `,
51
- };
52
-
53
- export const AvatarContainer = styled.div<AvatarContainerProps>`
54
- display: inline-flex;
55
- align-items: center;
56
- justify-content: center;
57
- border-radius: var(--rounded-full);
58
- user-select: none;
59
-
60
- ${({ size }) => stylesMap[size]}
61
- `;
1
+ import styled, { css } from 'styled-components';
2
+
3
+ export type AvatarContainerProps = {
4
+ size: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
5
+ };
6
+
7
+ const stylesMap: Record<
8
+ AvatarContainerProps['size'],
9
+ ReturnType<typeof css>
10
+ > = {
11
+ xs: css`
12
+ width: var(--size-6);
13
+ height: var(--size-6);
14
+ min-width: var(--size-6);
15
+ min-height: var(--size-6);
16
+ font-size: var(--text-xs);
17
+ line-height: var(--text-xs);
18
+ `,
19
+ sm: css`
20
+ width: var(--size-8);
21
+ height: var(--size-8);
22
+ min-width: var(--size-8);
23
+ min-height: var(--size-8);
24
+ font-size: var(--text-sm);
25
+ line-height: var(--text-sm);
26
+ `,
27
+ md: css`
28
+ width: var(--size-10);
29
+ height: var(--size-10);
30
+ min-width: var(--size-10);
31
+ min-height: var(--size-10);
32
+ font-size: var(--text-md);
33
+ line-height: var(--text-md);
34
+ `,
35
+ lg: css`
36
+ width: var(--size-12);
37
+ height: var(--size-12);
38
+ min-width: var(--size-12);
39
+ min-height: var(--size-12);
40
+ font-size: var(--text-lg);
41
+ line-height: var(--text-lg);
42
+ `,
43
+ xl: css`
44
+ width: var(--size-14);
45
+ height: var(--size-14);
46
+ min-width: var(--size-14);
47
+ min-height: var(--size-14);
48
+ font-size: var(--text-2xl);
49
+ line-height: var(--text-2xl);
50
+ `,
51
+ };
52
+
53
+ export const AvatarContainer = styled.div<AvatarContainerProps>`
54
+ display: inline-flex;
55
+ align-items: center;
56
+ justify-content: center;
57
+ border-radius: var(--rounded-full);
58
+ user-select: none;
59
+
60
+ ${({ size }) => stylesMap[size]}
61
+ `;
@@ -1,3 +1,3 @@
1
- export * from './types';
2
- export * from './TabsView';
3
- export * from './TabsList';
1
+ export * from './types';
2
+ export * from './TabsView';
3
+ export * from './TabsList';
@@ -1,14 +1,14 @@
1
- import { useContext, useEffect } from 'react';
2
-
3
- import { TrackingContext } from '.';
4
- import { useLocation } from 'react-router-dom';
5
-
6
- export const useLocationTracking = () => {
7
- const { sendEvent } = useContext(TrackingContext);
8
- const { pathname, search } = useLocation();
9
- const pathWithSearch = `${pathname}${search}`;
10
-
11
- useEffect(() => {
12
- sendEvent('PageView', { path: pathWithSearch });
13
- }, [pathWithSearch, sendEvent]);
14
- };
1
+ import { useContext, useEffect } from 'react';
2
+
3
+ import { TrackingContext } from '.';
4
+ import { useLocation } from 'react-router-dom';
5
+
6
+ export const useLocationTracking = () => {
7
+ const { sendEvent } = useContext(TrackingContext);
8
+ const { pathname, search } = useLocation();
9
+ const pathWithSearch = `${pathname}${search}`;
10
+
11
+ useEffect(() => {
12
+ sendEvent('PageView', { path: pathWithSearch });
13
+ }, [pathWithSearch, sendEvent]);
14
+ };
@@ -1,14 +0,0 @@
1
- import { AdvancedRequestDTO, ConditionDTO, FieldDTO, OrderByDTO } from '../../../../services/advancedRequests';
2
- import { AdvancedRequestDataGridColumns, AdvancedRequestDataGridFilters } from '../types';
3
- export declare const getAdvancedRequestDto: <R>({ type, columns, conditions, orderBy, start, length, getTotal, idField, }: {
4
- type: string;
5
- columns: AdvancedRequestDataGridColumns<R>;
6
- conditions?: ConditionDTO[];
7
- orderBy?: OrderByDTO[];
8
- start?: number;
9
- length?: number;
10
- getTotal?: boolean;
11
- idField?: FieldDTO | null;
12
- }) => AdvancedRequestDTO;
13
- export declare const convertFiltersToConditions: <R>(filters: AdvancedRequestDataGridFilters, columns: AdvancedRequestDataGridColumns<R>) => Record<string, ConditionDTO>;
14
- export declare const parseJsonObjectFields: <R>(rows: any[], columns: AdvancedRequestDataGridColumns<R>, parser?: (row: any) => R) => R[];
@@ -1,76 +0,0 @@
1
- "use strict";
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
- var __assign = (this && this.__assign) || function () {
4
- __assign = Object.assign || function(t) {
5
- for (var s, i = 1, n = arguments.length; i < n; i++) {
6
- s = arguments[i];
7
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
8
- t[p] = s[p];
9
- }
10
- return t;
11
- };
12
- return __assign.apply(this, arguments);
13
- };
14
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
15
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
16
- if (ar || !(i in from)) {
17
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
18
- ar[i] = from[i];
19
- }
20
- }
21
- return to.concat(ar || Array.prototype.slice.call(from));
22
- };
23
- var __importDefault = (this && this.__importDefault) || function (mod) {
24
- return (mod && mod.__esModule) ? mod : { "default": mod };
25
- };
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.parseJsonObjectFields = exports.convertFiltersToConditions = exports.getAdvancedRequestDto = void 0;
28
- var lodash_1 = __importDefault(require("lodash"));
29
- var getAdvancedRequestDto = function (_a) {
30
- var type = _a.type, columns = _a.columns, _b = _a.conditions, conditions = _b === void 0 ? [] : _b, _c = _a.orderBy, orderBy = _c === void 0 ? [] : _c, _d = _a.start, start = _d === void 0 ? 0 : _d, _e = _a.length, length = _e === void 0 ? 100 : _e, _f = _a.getTotal, getTotal = _f === void 0 ? false : _f, _g = _a.idField, idField = _g === void 0 ? { fieldName: 'Id' } : _g;
31
- return ({
32
- fields: __spreadArray(__spreadArray([], (idField === null ? [] : [idField]), true), Object.keys(columns).map(function (key) {
33
- var _a, _b;
34
- return columns[key].field
35
- ? __assign(__assign({}, columns[key].field), { fieldName: (_b = (_a = columns[key].field) === null || _a === void 0 ? void 0 : _a.fieldName) !== null && _b !== void 0 ? _b : key, fieldAlias: key }) : {
36
- fieldName: key,
37
- fieldAlias: key,
38
- };
39
- }), true),
40
- conditions: conditions,
41
- orderBy: orderBy,
42
- type: type,
43
- start: start,
44
- length: length,
45
- getTotal: getTotal,
46
- });
47
- };
48
- exports.getAdvancedRequestDto = getAdvancedRequestDto;
49
- var convertFiltersToConditions = function (filters, columns) {
50
- return lodash_1.default.mapValues(filters, function (filter, columnKey) {
51
- var _a, _b, _c, _d, _e;
52
- return ({
53
- field: (_e = (_c = (_a = columns[columnKey].filterField) !== null && _a !== void 0 ? _a : (_b = columns[columnKey].field) === null || _b === void 0 ? void 0 : _b.fieldAlias) !== null && _c !== void 0 ? _c : (_d = columns[columnKey].field) === null || _d === void 0 ? void 0 : _d.fieldName) !== null && _e !== void 0 ? _e : columnKey,
54
- operator: filter.operator,
55
- value: ['inArray', 'inRange'].includes(filter.operator)
56
- ? filter.values
57
- : lodash_1.default.castArray(filter.values)[0],
58
- });
59
- });
60
- };
61
- exports.convertFiltersToConditions = convertFiltersToConditions;
62
- var parseJsonObjectFields = function (rows, columns, parser) {
63
- var jsonColumns = Object.keys(columns).filter(function (key) { var _a; return ((_a = columns[key].field) === null || _a === void 0 ? void 0 : _a.operator) === 'jsonObject'; });
64
- var parsedRows = jsonColumns.length === 0
65
- ? rows
66
- : rows.map(function (row) {
67
- var parsedRow = __assign({}, row);
68
- jsonColumns.forEach(function (key) {
69
- var _a;
70
- parsedRow[key] = JSON.parse((_a = parsedRow[key]) !== null && _a !== void 0 ? _a : '{}');
71
- });
72
- return parsedRow;
73
- });
74
- return parser ? parsedRows.map(parser) : parsedRows;
75
- };
76
- exports.parseJsonObjectFields = parseJsonObjectFields;
@@ -1,22 +0,0 @@
1
- import { AdvancedRequestDataGridColumn, AdvancedRequestDataGridColumns } from '../types';
2
- import { FieldDTO } from '../../../../services/advancedRequests';
3
- export declare const withGroupBy: <R extends Record<string, any>>(columns: AdvancedRequestDataGridColumns<R>) => AdvancedRequestDataGridColumns<R>;
4
- export declare const advancedTextColumn: <R extends Record<string, any>>(key: string, title: string, options?: Partial<AdvancedRequestDataGridColumn<R>>) => AdvancedRequestDataGridColumns<R>;
5
- /**
6
- * Creates a column with a composed value from multiple fields,
7
- * and filtered by a text filter on the first field
8
- */
9
- export declare const advancedComposedColumn: <R extends Record<string, any>>(key: string, title: string, fields: string[], options?: Partial<AdvancedRequestDataGridColumn<R>>) => AdvancedRequestDataGridColumns<R>;
10
- export declare const advancedMailColumn: <R extends Record<string, any>>(key: string, title: string, options?: Partial<AdvancedRequestDataGridColumn<R>>) => AdvancedRequestDataGridColumns<R>;
11
- export declare const advancedPhoneColumn: <R extends Record<string, any>>(key: string, title: string, options?: Partial<AdvancedRequestDataGridColumn<R>>) => AdvancedRequestDataGridColumns<R>;
12
- export declare const advancedDateColumn: <R extends Record<string, any>>(key: string, title: string, options?: Partial<AdvancedRequestDataGridColumn<R>>) => AdvancedRequestDataGridColumns<R>;
13
- export declare const advancedMonthColumn: <R extends Record<string, any>>(key: string, title: string, options?: Partial<AdvancedRequestDataGridColumn<R>>) => AdvancedRequestDataGridColumns<R>;
14
- export declare const advancedNumberColumn: <R extends Record<string, any>>(key: string, title: string, decimals?: number, options?: Partial<AdvancedRequestDataGridColumn<R>>) => AdvancedRequestDataGridColumns<R>;
15
- export declare const advancedMoneyColumn: <R extends Record<string, any>>(key: string, title: string, decimals?: number, options?: Partial<AdvancedRequestDataGridColumn<R>>) => AdvancedRequestDataGridColumns<R>;
16
- export declare const advancedPercentageColumn: <R extends Record<string, any>>(key: string, title: string, options?: Partial<AdvancedRequestDataGridColumn<R>>) => AdvancedRequestDataGridColumns<R>;
17
- export declare const advancedCheckboxColumn: <R extends Record<string, any>>(key: string, title: string, options?: Partial<AdvancedRequestDataGridColumn<R>>) => AdvancedRequestDataGridColumns<R>;
18
- export declare const advancedColorColumn: <R extends Record<string, any>>(key: string, title: string, options?: Partial<AdvancedRequestDataGridColumn<R>>) => AdvancedRequestDataGridColumns<R>;
19
- export declare const getColumnField: <R>(columns: AdvancedRequestDataGridColumns<R>, columnKey: string) => FieldDTO;
20
- export declare const getColumnSortField: <R>(columns: AdvancedRequestDataGridColumns<R>, columnKey: string) => FieldDTO;
21
- export declare const getFirstColumnField: <R>(columns: AdvancedRequestDataGridColumns<R>) => FieldDTO;
22
- export declare const getFirstColumnSortField: <R>(columns: AdvancedRequestDataGridColumns<R>) => FieldDTO;
@@ -1,156 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.getFirstColumnSortField = exports.getFirstColumnField = exports.getColumnSortField = exports.getColumnField = exports.advancedColorColumn = exports.advancedCheckboxColumn = exports.advancedPercentageColumn = exports.advancedMoneyColumn = exports.advancedNumberColumn = exports.advancedMonthColumn = exports.advancedDateColumn = exports.advancedPhoneColumn = exports.advancedMailColumn = exports.advancedComposedColumn = exports.advancedTextColumn = exports.withGroupBy = void 0;
18
- var jsx_runtime_1 = require("react/jsx-runtime");
19
- var numbers_1 = require("../../../../helpers/numbers");
20
- var helpers_1 = require("../../DataGrid/helpers");
21
- var lodash_1 = __importDefault(require("lodash"));
22
- var moment_1 = __importDefault(require("moment"));
23
- var withGroupBy = function (columns) {
24
- return lodash_1.default.mapValues(columns, function (column, key) {
25
- var _a;
26
- return (__assign(__assign({}, column), { field: __assign(__assign({}, ((_a = column.field) !== null && _a !== void 0 ? _a : { fieldName: key })), { groupBy: true }) }));
27
- });
28
- };
29
- exports.withGroupBy = withGroupBy;
30
- var advancedTextColumn = function (key, title, options) {
31
- var _a;
32
- return (_a = {},
33
- _a[key] = __assign({ name: title, render: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.textFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : ''; } }) }, options),
34
- _a);
35
- };
36
- exports.advancedTextColumn = advancedTextColumn;
37
- /**
38
- * Creates a column with a composed value from multiple fields,
39
- * and filtered by a text filter on the first field
40
- */
41
- var advancedComposedColumn = function (key, title, fields, options) {
42
- var _a;
43
- return (_a = {},
44
- _a[key] = __assign({ field: {
45
- fieldAlias: key,
46
- operator: 'jsonObject',
47
- operands: fields.flatMap(function (field) { return [
48
- { constantValue: field },
49
- { fieldName: field },
50
- ]; }),
51
- }, name: title, render: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.textFilter)(fields[0])), { getter: function (value) { var _a; return (_a = value[fields[0]]) !== null && _a !== void 0 ? _a : 0; } }), filterField: fields[0], sortField: fields[0] }, options),
52
- _a);
53
- };
54
- exports.advancedComposedColumn = advancedComposedColumn;
55
- var advancedMailColumn = function (key, title, options) {
56
- var _a;
57
- return (_a = {},
58
- _a[key] = __assign({ name: title, render: function (row) { var _a; return (0, jsx_runtime_1.jsx)("a", { href: "mailto:".concat(row[key]), children: (_a = row[key]) !== null && _a !== void 0 ? _a : '' }); }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.textFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : ''; } }) }, options),
59
- _a);
60
- };
61
- exports.advancedMailColumn = advancedMailColumn;
62
- var advancedPhoneColumn = function (key, title, options) {
63
- var _a;
64
- return (_a = {},
65
- _a[key] = __assign({ name: title, render: function (row) { var _a; return (0, jsx_runtime_1.jsx)("a", { href: "tel:".concat(row[key]), children: (_a = row[key]) !== null && _a !== void 0 ? _a : '' }); }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.textFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : ''; } }) }, options),
66
- _a);
67
- };
68
- exports.advancedPhoneColumn = advancedPhoneColumn;
69
- var advancedDateColumn = function (key, title, options) {
70
- var _a;
71
- return (_a = {},
72
- _a[key] = __assign({ name: title, render: function (row) { var _a; return (_a = (0, moment_1.default)(row[key]).format('DD/MM/YYYY')) !== null && _a !== void 0 ? _a : ''; }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.textFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : ''; } }) }, options),
73
- _a);
74
- };
75
- exports.advancedDateColumn = advancedDateColumn;
76
- var advancedMonthColumn = function (key, title, options) {
77
- var _a;
78
- return (_a = {},
79
- _a[key] = __assign({ name: title, render: function (row) { return (row[key] ? "".concat(row[key], " mois ") : ''); }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.textFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : ''; } }) }, options),
80
- _a);
81
- };
82
- exports.advancedMonthColumn = advancedMonthColumn;
83
- var advancedNumberColumn = function (key, title, decimals, options) {
84
- var _a;
85
- if (decimals === void 0) { decimals = 2; }
86
- return (_a = {},
87
- _a[key] = __assign({ name: title, render: function (row) { var _a; return (_a = (0, numbers_1.formatNumber)(row[key], decimals)) !== null && _a !== void 0 ? _a : ''; }, excelFormatter: function () { return '#'; }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.numberFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : 0; } }) }, options),
88
- _a);
89
- };
90
- exports.advancedNumberColumn = advancedNumberColumn;
91
- var advancedMoneyColumn = function (key, title, decimals, options) {
92
- var _a;
93
- if (decimals === void 0) { decimals = 2; }
94
- return (_a = {},
95
- _a[key] = __assign({ name: title, render: function (row) { var _a; return (_a = (0, numbers_1.formatMoney)(row[key], decimals)) !== null && _a !== void 0 ? _a : ''; }, excelFormatter: function () { return '#0.00'; }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.numberFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : 0; } }) }, options),
96
- _a);
97
- };
98
- exports.advancedMoneyColumn = advancedMoneyColumn;
99
- var advancedPercentageColumn = function (key, title, options) {
100
- var _a;
101
- return (_a = {},
102
- _a[key] = __assign({ name: title, render: function (row) { var _a; return (_a = (0, numbers_1.formatPercentage)(row[key])) !== null && _a !== void 0 ? _a : ''; }, excelFormatter: function () { return '#0.00'; }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.numberFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : 0; } }) }, options),
103
- _a);
104
- };
105
- exports.advancedPercentageColumn = advancedPercentageColumn;
106
- var advancedCheckboxColumn = function (key, title, options) {
107
- var _a;
108
- return (_a = {},
109
- _a[key] = __assign({ name: title, render: function (row) { return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", checked: row[key], readOnly: true }), (0, jsx_runtime_1.jsx)("span", { children: row[key] ? ' Oui' : ' Non' })] })); }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.numberFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : 0; } }) }, options),
110
- _a);
111
- };
112
- exports.advancedCheckboxColumn = advancedCheckboxColumn;
113
- var advancedColorColumn = function (key, title, options) {
114
- var _a;
115
- return (_a = {},
116
- _a[key] = __assign({ name: title, render: function (row) {
117
- var _a;
118
- return ((0, jsx_runtime_1.jsx)("div", { style: { backgroundColor: row[key] }, children: (_a = row[key]) !== null && _a !== void 0 ? _a : '' }));
119
- }, getter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, sortGetter: function (row) { var _a; return (_a = row[key]) !== null && _a !== void 0 ? _a : ''; }, filter: __assign(__assign({}, (0, helpers_1.textFilter)(key)), { getter: function (value) { var _a; return (_a = value[key]) !== null && _a !== void 0 ? _a : ''; } }) }, options),
120
- _a);
121
- };
122
- exports.advancedColorColumn = advancedColorColumn;
123
- var getColumnField = function (columns, columnKey) {
124
- var _a, _b;
125
- return columns[columnKey].field
126
- ? {
127
- fieldName: (_b = (_a = columns[columnKey].field) === null || _a === void 0 ? void 0 : _a.fieldName) !== null && _b !== void 0 ? _b : columnKey,
128
- fieldAlias: columnKey,
129
- }
130
- : {
131
- fieldName: columnKey,
132
- fieldAlias: columnKey,
133
- };
134
- };
135
- exports.getColumnField = getColumnField;
136
- var getColumnSortField = function (columns, columnKey) {
137
- var _a;
138
- return columns[columnKey].sortField
139
- ? {
140
- fieldName: (_a = columns[columnKey].sortField) !== null && _a !== void 0 ? _a : columnKey,
141
- fieldAlias: columnKey,
142
- }
143
- : {
144
- fieldName: columnKey,
145
- fieldAlias: columnKey,
146
- };
147
- };
148
- exports.getColumnSortField = getColumnSortField;
149
- var getFirstColumnField = function (columns) {
150
- return (0, exports.getColumnField)(columns, Object.keys(columns)[0]);
151
- };
152
- exports.getFirstColumnField = getFirstColumnField;
153
- var getFirstColumnSortField = function (columns) {
154
- return (0, exports.getColumnSortField)(columns, Object.keys(columns)[0]);
155
- };
156
- exports.getFirstColumnSortField = getFirstColumnSortField;
@@ -1,2 +0,0 @@
1
- export * from './advancedRequests';
2
- export * from './columns';
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./advancedRequests"), exports);
18
- __exportStar(require("./columns"), exports);
@@ -1,2 +0,0 @@
1
- import { AdvancedRequestDataGridProps } from './types';
2
- export declare const AdvancedRequestDataGrid: <R>({ onSelectionChange: onSelectionChangeFromProps, idField, ...props }: AdvancedRequestDataGridProps<R>) => import("react/jsx-runtime").JSX.Element;
@@ -1,215 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- var desc = Object.getOwnPropertyDescriptor(m, k);
16
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
- desc = { enumerable: true, get: function() { return m[k]; } };
18
- }
19
- Object.defineProperty(o, k2, desc);
20
- }) : (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- o[k2] = m[k];
23
- }));
24
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
- Object.defineProperty(o, "default", { enumerable: true, value: v });
26
- }) : function(o, v) {
27
- o["default"] = v;
28
- });
29
- var __importStar = (this && this.__importStar) || function (mod) {
30
- if (mod && mod.__esModule) return mod;
31
- var result = {};
32
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
- __setModuleDefault(result, mod);
34
- return result;
35
- };
36
- var __rest = (this && this.__rest) || function (s, e) {
37
- var t = {};
38
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
39
- t[p] = s[p];
40
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
41
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
42
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
43
- t[p[i]] = s[p[i]];
44
- }
45
- return t;
46
- };
47
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
48
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
49
- if (ar || !(i in from)) {
50
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
51
- ar[i] = from[i];
52
- }
53
- }
54
- return to.concat(ar || Array.prototype.slice.call(from));
55
- };
56
- Object.defineProperty(exports, "__esModule", { value: true });
57
- exports.AdvancedRequestDataGrid = void 0;
58
- var jsx_runtime_1 = require("react/jsx-runtime");
59
- var advancedRequests_1 = require("../../../services/advancedRequests");
60
- var lodash_1 = __importStar(require("lodash"));
61
- var helpers_1 = require("./helpers");
62
- var react_1 = require("react");
63
- var DataGrid_1 = require("../DataGrid");
64
- var AdvancedRequestDataGrid = function (_a) {
65
- var onSelectionChangeFromProps = _a.onSelectionChange, idField = _a.idField, props = __rest(_a, ["onSelectionChange", "idField"]);
66
- var currentRows = (0, react_1.useRef)([]);
67
- var _b = (0, react_1.useState)([]), rows = _b[0], setRows = _b[1];
68
- var _c = (0, react_1.useState)(0), start = _c[0], setStart = _c[1];
69
- var _d = (0, react_1.useState)(50), length = _d[0], setLength = _d[1];
70
- var _e = (0, react_1.useState)(-1), total = _e[0], setTotal = _e[1];
71
- var advancedRequest = (0, advancedRequests_1.useAdvancedRequestHandler)();
72
- var idAdvancedRequest = (0, advancedRequests_1.useAdvancedRequestHandler)();
73
- var _f = (0, react_1.useState)({}), conditions = _f[0], setConditions = _f[1];
74
- var _g = (0, react_1.useState)([]), orderBy = _g[0], setOrderBy = _g[1];
75
- var refresh = (0, react_1.useCallback)(function () {
76
- setRows([]);
77
- setStart(0);
78
- setLength(50);
79
- setTotal(-1);
80
- }, []);
81
- var onFiltersChanged = (0, react_1.useCallback)(function (filters) {
82
- var newConditions = (0, helpers_1.convertFiltersToConditions)(filters, props.columns);
83
- setTotal(-1);
84
- setConditions(newConditions);
85
- }, [props.columns]);
86
- var onSortsChanged = (0, react_1.useCallback)(function (sorts) {
87
- refresh();
88
- setOrderBy(Object.entries(sorts).map(function (_a) {
89
- var columnKey = _a[0], direction = _a[1];
90
- return ({
91
- field: (0, helpers_1.getColumnSortField)(props.columns, columnKey),
92
- direction: direction.toUpperCase(),
93
- });
94
- }));
95
- }, [props.columns, refresh]);
96
- var loadRows = (0, react_1.useRef)((0, lodash_1.debounce)(function (columns, conditions, orderBy, start, length, idField, getTotal) {
97
- if (getTotal === void 0) { getTotal = false; }
98
- advancedRequest((0, helpers_1.getAdvancedRequestDto)({
99
- type: props.type,
100
- columns: columns,
101
- conditions: conditions,
102
- orderBy: orderBy,
103
- start: start,
104
- length: length,
105
- getTotal: getTotal,
106
- idField: idField,
107
- })).then(function (response) {
108
- var _a;
109
- var _b;
110
- if (getTotal) {
111
- currentRows.current = Array(response.count).fill(null);
112
- if (getTotal)
113
- setTotal((_b = response.count) !== null && _b !== void 0 ? _b : 0);
114
- }
115
- var parsedRows = (0, helpers_1.parseJsonObjectFields)(response.data, columns, props.parser);
116
- (_a = currentRows.current).splice.apply(_a, __spreadArray([start, length], parsedRows, false));
117
- setRows(__spreadArray([], currentRows.current, true));
118
- });
119
- }, 100));
120
- var loadFilterValues = (0, react_1.useCallback)(function (columnKey) {
121
- var _a, _b, _c, _d, _e, _f, _g;
122
- return advancedRequest({
123
- fields: [
124
- (_a = props.columns[columnKey].field) !== null && _a !== void 0 ? _a : {
125
- fieldName: columnKey,
126
- },
127
- ],
128
- conditions: __spreadArray(__spreadArray([], ((_b = props.conditions) !== null && _b !== void 0 ? _b : []), true), Object.values(lodash_1.default.pickBy(conditions, function (_, key) { return key !== columnKey; })), true).filter(function (condition) { return condition.field !== columnKey; }),
129
- orderBy: [
130
- {
131
- field: (_g = (_e = (_c = props.columns[columnKey].filterField) !== null && _c !== void 0 ? _c : (_d = props.columns[columnKey].field) === null || _d === void 0 ? void 0 : _d.fieldAlias) !== null && _e !== void 0 ? _e : (_f = props.columns[columnKey].field) === null || _f === void 0 ? void 0 : _f.fieldName) !== null && _g !== void 0 ? _g : columnKey,
132
- direction: 'ASC',
133
- },
134
- ],
135
- type: props.type,
136
- getTotal: false,
137
- unique: true,
138
- }).then(function (response) {
139
- return response.data.map(function (row) { var _a, _b, _c; return (_c = (_b = (_a = props.columns[columnKey].filter) === null || _a === void 0 ? void 0 : _a.getter) === null || _b === void 0 ? void 0 : _b.call(_a, row)) !== null && _c !== void 0 ? _c : null; });
140
- });
141
- }, [advancedRequest, conditions, props.columns, props.conditions, props.type]);
142
- (0, react_1.useEffect)(function () {
143
- var _a, _b;
144
- return loadRows.current(props.columns, __spreadArray(__spreadArray([], ((_a = props.conditions) !== null && _a !== void 0 ? _a : []), true), ((_b = Object.values(conditions)) !== null && _b !== void 0 ? _b : []), true), orderBy, start, length, idField, total < 0);
145
- }, [
146
- props.columns,
147
- conditions,
148
- orderBy,
149
- start,
150
- length,
151
- total,
152
- props.conditions,
153
- idField,
154
- ]);
155
- var loadCopyRows = (0, react_1.useCallback)(function () {
156
- var _a, _b;
157
- return advancedRequest((0, helpers_1.getAdvancedRequestDto)({
158
- type: props.type,
159
- columns: props.columns,
160
- conditions: __spreadArray(__spreadArray([], ((_a = props.conditions) !== null && _a !== void 0 ? _a : []), true), ((_b = Object.values(conditions)) !== null && _b !== void 0 ? _b : []), true),
161
- orderBy: orderBy,
162
- start: 0,
163
- length: total,
164
- idField: idField,
165
- })).then(function (response) {
166
- return (0, helpers_1.parseJsonObjectFields)(response.data, props.columns, props.parser);
167
- });
168
- }, [
169
- advancedRequest,
170
- conditions,
171
- idField,
172
- orderBy,
173
- props.columns,
174
- props.conditions,
175
- props.parser,
176
- props.type,
177
- total,
178
- ]);
179
- var loadAllIds = (0, react_1.useCallback)(function () {
180
- var _a, _b;
181
- return idAdvancedRequest((0, helpers_1.getAdvancedRequestDto)({
182
- type: props.type,
183
- columns: {
184
- Id: {
185
- name: 'Id',
186
- field: idField !== null && idField !== void 0 ? idField : { fieldName: 'Id' },
187
- },
188
- },
189
- conditions: __spreadArray(__spreadArray([], ((_a = props.conditions) !== null && _a !== void 0 ? _a : []), true), ((_b = Object.values(conditions)) !== null && _b !== void 0 ? _b : []), true),
190
- orderBy: orderBy,
191
- start: 0,
192
- length: total,
193
- idField: null,
194
- })).then(function (response) { return response.data.map(function (row) { return row['Id']; }); });
195
- }, [
196
- conditions,
197
- idAdvancedRequest,
198
- idField,
199
- orderBy,
200
- props.conditions,
201
- props.type,
202
- total,
203
- ]);
204
- var onVisibleRowsChanged = (0, react_1.useCallback)(function (newStart, newLength) {
205
- if (newStart !== start || newLength !== length) {
206
- setStart(newStart);
207
- setLength(newLength);
208
- }
209
- }, [length, start]);
210
- var onSelectionChange = (0, react_1.useCallback)(function (selectedKeys) {
211
- onSelectionChangeFromProps === null || onSelectionChangeFromProps === void 0 ? void 0 : onSelectionChangeFromProps(selectedKeys);
212
- }, [onSelectionChangeFromProps]);
213
- return ((0, jsx_runtime_1.jsx)(DataGrid_1.DataGrid, __assign({ onVisibleRowsChange: onVisibleRowsChanged, filter: false, sort: false, onFiltersChanged: onFiltersChanged, onSortsChanged: onSortsChanged, filterValuesLoader: loadFilterValues, rows: rows, loadCopyRows: loadCopyRows, refresh: refresh, onSelectionChange: onSelectionChange, getAllIds: loadAllIds }, props)));
214
- };
215
- exports.AdvancedRequestDataGrid = AdvancedRequestDataGrid;
@@ -1,21 +0,0 @@
1
- import { AdvancedRequestRow, ConditionDTO, FieldDTO, OrderByDTO } from '../../../services/advancedRequests';
2
- import { DataGridColumn, DataGridFilter, DataGridFilterType, DataGridProps } from '../DataGrid/types';
3
- export type AdvancedRequestDataGridFilter<T extends DataGridFilterType = DataGridFilterType> = DataGridFilter<T> & {
4
- field?: FieldDTO;
5
- };
6
- export type AdvancedRequestDataGridFilters = Record<string, AdvancedRequestDataGridFilter>;
7
- export type AdvancedRequestDataGridColumn<R> = DataGridColumn<R> & {
8
- filter?: AdvancedRequestDataGridFilter;
9
- field?: FieldDTO;
10
- filterField?: string;
11
- sortField?: string;
12
- };
13
- export type AdvancedRequestDataGridColumns<R> = Record<string, AdvancedRequestDataGridColumn<R>>;
14
- export type AdvancedRequestDataGridProps<R> = Omit<DataGridProps<R>, 'rows' | 'columns'> & {
15
- columns: AdvancedRequestDataGridColumns<R>;
16
- type: string;
17
- orderBy?: OrderByDTO[];
18
- conditions?: ConditionDTO[];
19
- idField?: FieldDTO | null;
20
- parser?: (row: AdvancedRequestRow<R>) => R;
21
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- import { DataGridCellProps } from './types';
2
- export declare const DataGridEditableCell: <R>({ row, columnKey, column, context, }: DataGridCellProps<R>) => import("react/jsx-runtime").JSX.Element;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DataGridEditableCell = void 0;
4
- var jsx_runtime_1 = require("react/jsx-runtime");
5
- /* eslint-disable @typescript-eslint/no-explicit-any */
6
- /* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
7
- var react_1 = require("react");
8
- var hooks_1 = require("./hooks");
9
- var DataGridEditableCell = function (_a) {
10
- var row = _a.row, columnKey = _a.columnKey, column = _a.column, context = _a.context;
11
- var _b = (0, hooks_1.useDataGridContext)(context), onCellEdited = _b.onCellEdited, setEditingCell = _b.setEditingCell;
12
- var _c = (0, react_1.useState)(column.getter
13
- ? column.getter(row)
14
- : column.propertyName
15
- ? String(row[column.propertyName])
16
- : ''), value = _c[0], setValue = _c[1];
17
- var onClose = (0, react_1.useCallback)(function () {
18
- onCellEdited === null || onCellEdited === void 0 ? void 0 : onCellEdited(row, columnKey, value);
19
- setEditingCell([-1, -1]);
20
- }, [columnKey, onCellEdited, row, setEditingCell, value]);
21
- return ((0, jsx_runtime_1.jsxs)("td", { children: [(0, jsx_runtime_1.jsx)("input", { type: "text",
22
- // className="relative z-10 block text-normal w-full border-0 py-1.5 text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-sky-600 sm:text-sm sm:leading-6"
23
- value: String(value), onChange: function (e) { return setValue(e.target.value); } }), (0, jsx_runtime_1.jsx)("div", {
24
- // className="fixed inset-0 bg-black bg-opacity-10"
25
- onClick: onClose })] }, columnKey));
26
- };
27
- exports.DataGridEditableCell = DataGridEditableCell;
@@ -1 +0,0 @@
1
- export * from './space';
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./space"), exports);