@azrico/reactgrid 1.2.33 → 1.2.35

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.
@@ -1,85 +1,82 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.fix_parent_child_relations = fix_parent_child_relations;
7
- exports.func_selection = void 0;
8
1
  function get_parentId(obj) {
9
- return obj.__parent__table_id || obj.parent;
2
+ return obj.__parent__table_id || obj.parent;
10
3
  }
11
4
  function get_selfId(obj) {
12
- return obj.__table_id;
5
+ return obj.__table_id;
13
6
  }
14
7
  //given an array of rows, fixes parent,child relations
15
- function fix_parent_child_relations(rows) {
16
- if (!Array.isArray(rows)) rows = [];
17
- const anyparentid = rows.find(r => get_parentId(r));
18
- const anyselfid = rows.find(r => get_selfId(r));
19
- if (!anyparentid || !anyselfid) return rows;
20
- const converted_rows = rows.filter(r => r != null).map(r => {
21
- return {
22
- parent: get_parentId(r),
23
- self: get_selfId(r),
24
- data: r
25
- };
26
- });
27
- const top_level_rows = converted_rows.filter(r => !r.parent);
28
- const any_child = converted_rows.find(r => Boolean(r.parent));
29
- if (any_child) {
30
- //find children of top-level parents:
31
- for (let index = 0; index < top_level_rows.length; index++) {
32
- const mrow = top_level_rows[index];
33
- assign_children(mrow, converted_rows);
8
+ export function fix_parent_child_relations(rows) {
9
+ if (!Array.isArray(rows))
10
+ rows = [];
11
+ const anyparentid = rows.find((r) => get_parentId(r));
12
+ const anyselfid = rows.find((r) => get_selfId(r));
13
+ if (!anyparentid || !anyselfid)
14
+ return rows;
15
+ const converted_rows = rows
16
+ .filter((r) => r != null)
17
+ .map((r) => {
18
+ return { parent: get_parentId(r), self: get_selfId(r), data: r };
19
+ });
20
+ const top_level_rows = converted_rows.filter((r) => !r.parent);
21
+ const any_child = converted_rows.find((r) => Boolean(r.parent));
22
+ if (any_child) {
23
+ //find children of top-level parents:
24
+ for (let index = 0; index < top_level_rows.length; index++) {
25
+ const mrow = top_level_rows[index];
26
+ assign_children(mrow, converted_rows);
27
+ }
34
28
  }
35
- }
36
- return top_level_rows.map(r => r.data);
29
+ return top_level_rows.map((r) => r.data);
37
30
  }
38
31
  function assign_children(row, all_rows) {
39
- const my_children = all_rows.filter(s => row.self == s.parent);
40
- if (my_children.length > 0) {
41
- //find children of my children:
42
- for (let index = 0; index < my_children.length; index++) {
43
- const child = my_children[index];
44
- assign_children(child, all_rows);
32
+ const my_children = all_rows.filter((s) => row.self == s.parent);
33
+ if (my_children.length > 0) {
34
+ //find children of my children:
35
+ for (let index = 0; index < my_children.length; index++) {
36
+ const child = my_children[index];
37
+ assign_children(child, all_rows);
38
+ }
39
+ row.data.__children = my_children.map((r) => r.data);
45
40
  }
46
- row.data.__children = my_children.map(r => r.data);
47
- } else if (!Array.isArray(row.data.__children) || row.data.__children.length == 0) row.data.__children = undefined;
41
+ else if (!Array.isArray(row.data.__children) || row.data.__children.length == 0)
42
+ row.data.__children = undefined;
48
43
  }
49
- class func_selection {
50
- static getVirtualElement(x = 0, y = 0) {
51
- const boundsRect = func_selection.generateGetBoundingClientRect(x, y);
52
- return {
53
- getBoundingClientRect: boundsRect
54
- };
55
- }
56
- static generateGetBoundingClientRect(x = 0, y = 0) {
57
- return () => ({
58
- width: 0,
59
- height: 0,
60
- top: y,
61
- right: x,
62
- bottom: y,
63
- left: x
64
- });
65
- }
66
- static get_selectedText() {
67
- var text = '';
68
- if (window.getSelection) {
69
- var _window$getSelection;
70
- text = (_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 ? void 0 : _window$getSelection.toString();
71
- } else if (document.selection && document.selection.type != 'Control') {
72
- var _document$selection$c;
73
- text = (_document$selection$c = document.selection.createRange()) === null || _document$selection$c === void 0 ? void 0 : _document$selection$c.text;
44
+ export class func_selection {
45
+ static getVirtualElement(x = 0, y = 0) {
46
+ const boundsRect = func_selection.generateGetBoundingClientRect(x, y);
47
+ return {
48
+ getBoundingClientRect: boundsRect,
49
+ };
50
+ }
51
+ static generateGetBoundingClientRect(x = 0, y = 0) {
52
+ return () => ({
53
+ width: 0,
54
+ height: 0,
55
+ top: y,
56
+ right: x,
57
+ bottom: y,
58
+ left: x,
59
+ });
60
+ }
61
+ static get_selectedText() {
62
+ var text = '';
63
+ if (window.getSelection) {
64
+ text = window.getSelection()?.toString();
65
+ }
66
+ else if (document.selection &&
67
+ document.selection.type != 'Control') {
68
+ text = document.selection.createRange()?.text;
69
+ }
70
+ return text || '';
71
+ }
72
+ static has_selection() {
73
+ const slct = window.getSelection();
74
+ if (slct == null)
75
+ return false;
76
+ if (slct.type == null)
77
+ return func_selection.get_selectedText().length !== 0;
78
+ if (slct.type === 'Range')
79
+ return true;
80
+ return false;
74
81
  }
75
- return text || '';
76
- }
77
- static has_selection() {
78
- const slct = window.getSelection();
79
- if (slct == null) return false;
80
- if (slct.type == null) return func_selection.get_selectedText().length !== 0;
81
- if (slct.type === 'Range') return true;
82
- return false;
83
- }
84
82
  }
85
- exports.func_selection = func_selection;
@@ -1,39 +1,39 @@
1
- import { ColumnDefinition } from '../views/DataGrid';
2
- export type MakeWriteable<Type> = {
3
- -readonly [Key in keyof Type]: Type[Key];
4
- };
5
- export type ModifyFields<T, R> = Omit<T, keyof R> & R;
6
- export declare function ApplyDataSource(datasource: any, props: any): Promise<any>;
7
- /**
8
- * merges together all different props for columns
9
- * to build a single final column data array
10
- * @param column_data
11
- * @returns
12
- */
13
- export declare function ApplyColumnData(column_data: any): ColumnDefinition[];
14
- export declare function to_datasource(arr: any[], idProperty: string, valueAsID?: boolean): any[];
15
- /**
16
- * Gets name of a column from its column object
17
- * @param obj
18
- * @returns
19
- */
20
- export declare function get_col_name(obj: any): string;
21
- /**
22
- * Gets header of a column
23
- * @param obj
24
- * @returns
25
- */
26
- export declare function get_col_header(obj: any): string;
27
- /**
28
- * Gets name of a column from its column object
29
- * @param obj
30
- * @returns
31
- */
32
- export declare function get_row_id(obj: any): any;
33
- export declare function set_row_id(obj: any, val: undefined | string): any;
34
- /**
35
- * Gets default activation key for grid plugin
36
- * @returns
37
- */
38
- export declare function get_default_key(): string;
39
- export declare function validateCache(current: any, old: any, looseCheck?: boolean): boolean;
1
+ import { ColumnDefinition } from '../views/DataGrid';
2
+ export type MakeWriteable<Type> = {
3
+ -readonly [Key in keyof Type]: Type[Key];
4
+ };
5
+ export type ModifyFields<T, R> = Omit<T, keyof R> & R;
6
+ export declare function ApplyDataSource(datasource: any, props: any): Promise<any>;
7
+ /**
8
+ * merges together all different props for columns
9
+ * to build a single final column data array
10
+ * @param column_data
11
+ * @returns
12
+ */
13
+ export declare function ApplyColumnData(column_data: any): ColumnDefinition[];
14
+ export declare function to_datasource(arr: any[], idProperty: string, valueAsID?: boolean): any[];
15
+ /**
16
+ * Gets name of a column from its column object
17
+ * @param obj
18
+ * @returns
19
+ */
20
+ export declare function get_col_name(obj: any): string;
21
+ /**
22
+ * Gets header of a column
23
+ * @param obj
24
+ * @returns
25
+ */
26
+ export declare function get_col_header(obj: any): string;
27
+ /**
28
+ * Gets name of a column from its column object
29
+ * @param obj
30
+ * @returns
31
+ */
32
+ export declare function get_row_id(obj: any): any;
33
+ export declare function set_row_id(obj: any, val: undefined | string): any;
34
+ /**
35
+ * Gets default activation key for grid plugin
36
+ * @returns
37
+ */
38
+ export declare function get_default_key(): string;
39
+ export declare function validateCache(current: any, old: any, looseCheck?: boolean): boolean;