@easydata/crud 1.4.13 → 1.4.18

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 (61) hide show
  1. package/dist/browser/easydata.css +2184 -2181
  2. package/dist/browser/easydata.css.map +1 -1
  3. package/dist/browser/easydata.js +10890 -11626
  4. package/dist/browser/easydata.js.map +1 -1
  5. package/dist/browser/easydata.min.css +3 -1
  6. package/dist/browser/easydata.min.js +1 -1
  7. package/dist/browser/easydata.min.js.map +1 -1
  8. package/dist/bundles/easydata.crud.js +8442 -8439
  9. package/dist/bundles/easydata.crud.js.map +1 -1
  10. package/dist/bundles/easydata.crud.min.js +1 -1
  11. package/dist/bundles/easydata.crud.min.js.map +1 -1
  12. package/dist/lib/filter/data_filter.d.ts +6 -6
  13. package/dist/lib/filter/data_filter.js +1 -0
  14. package/dist/lib/filter/text_data_filter.d.ts +16 -16
  15. package/dist/lib/filter/text_data_filter.js +122 -122
  16. package/dist/lib/form/entity_edit_form.d.ts +20 -20
  17. package/dist/lib/form/entity_edit_form.js +133 -133
  18. package/dist/lib/form/entity_edit_form.js.map +1 -1
  19. package/dist/lib/form/entity_form_builder.d.ts +27 -27
  20. package/dist/lib/form/entity_form_builder.js +440 -440
  21. package/dist/lib/form/entity_form_builder.js.map +1 -1
  22. package/dist/lib/i18n/text_resources.d.ts +1 -1
  23. package/dist/lib/i18n/text_resources.js +31 -31
  24. package/dist/lib/main/data_context.d.ts +45 -45
  25. package/dist/lib/main/data_context.js +167 -167
  26. package/dist/lib/main/data_context.js.map +1 -1
  27. package/dist/lib/main/easy_data_server_loader.d.ts +11 -11
  28. package/dist/lib/main/easy_data_server_loader.js +43 -43
  29. package/dist/lib/public_api.d.ts +16 -16
  30. package/dist/lib/public_api.js +16 -14
  31. package/dist/lib/public_api.js.map +1 -1
  32. package/dist/lib/utils/utils.d.ts +4 -4
  33. package/dist/lib/utils/utils.js +24 -24
  34. package/dist/lib/utils/utils.js.map +1 -1
  35. package/dist/lib/validators/datetime_validator.d.ts +6 -6
  36. package/dist/lib/validators/datetime_validator.js +45 -43
  37. package/dist/lib/validators/datetime_validator.js.map +1 -1
  38. package/dist/lib/validators/required_validator.d.ts +6 -6
  39. package/dist/lib/validators/required_validator.js +36 -34
  40. package/dist/lib/validators/required_validator.js.map +1 -1
  41. package/dist/lib/validators/type_validator.d.ts +6 -6
  42. package/dist/lib/validators/type_validator.js +46 -44
  43. package/dist/lib/validators/type_validator.js.map +1 -1
  44. package/dist/lib/validators/validator.d.ts +9 -9
  45. package/dist/lib/validators/validator.js +6 -6
  46. package/dist/lib/views/easy_data_view_dispatcher.d.ts +18 -18
  47. package/dist/lib/views/easy_data_view_dispatcher.js +113 -113
  48. package/dist/lib/views/entity_data_view.d.ts +23 -23
  49. package/dist/lib/views/entity_data_view.js +224 -224
  50. package/dist/lib/views/entity_data_view.js.map +1 -1
  51. package/dist/lib/views/options.d.ts +14 -14
  52. package/dist/lib/views/options.js +1 -0
  53. package/dist/lib/views/root_data_view.d.ts +9 -9
  54. package/dist/lib/views/root_data_view.js +48 -48
  55. package/dist/lib/views/root_data_view.js.map +1 -1
  56. package/dist/lib/widgets/progress_bar.d.ts +6 -6
  57. package/dist/lib/widgets/progress_bar.js +15 -15
  58. package/dist/lib/widgets/text_filter_widget.d.ts +24 -24
  59. package/dist/lib/widgets/text_filter_widget.js +213 -213
  60. package/package.json +28 -27
  61. package/webpack.config.js +12 -9
@@ -1 +1 @@
1
- {"version":3,"file":"root_data_view.js","sourceRoot":"","sources":["../../../src/views/root_data_view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAY,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C;IAGI,sBACY,IAAiB,EACjB,OAAoB,EACpB,QAAgB;QAFhB,SAAI,GAAJ,IAAI,CAAa;QACjB,YAAO,G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AG,CAAC,WAAW,CAAE,CAAC,CAAC;4BACnC,CAAC,CAAC,CAAC;yBACN;oBACL,CAAC,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,EA3BgB,CA2BhB,CACL,CAAC;SACL;IACL,CAAC;IACL,mBAAC;AAAD,CAAC,AAjDD,IAiDC"}
@@ -1,6 +1,6 @@
1
- export declare class ProgressBar {
2
- private slot;
3
- constructor(slot: HTMLElement);
4
- show(): void;
5
- hide(): void;
6
- }
1
+ export declare class ProgressBar {
2
+ private slot;
3
+ constructor(slot: HTMLElement);
4
+ show(): void;
5
+ hide(): void;
6
+ }
@@ -1,16 +1,16 @@
1
- var ProgressBar = /** @class */ (function () {
2
- function ProgressBar(slot) {
3
- this.slot = slot;
4
- this.hide();
5
- this.slot.classList.add('ed-progress-bar');
6
- }
7
- ProgressBar.prototype.show = function () {
8
- this.slot.style.removeProperty('display');
9
- };
10
- ProgressBar.prototype.hide = function () {
11
- this.slot.style.display = 'none';
12
- };
13
- return ProgressBar;
14
- }());
15
- export { ProgressBar };
1
+ var ProgressBar = /** @class */ (function () {
2
+ function ProgressBar(slot) {
3
+ this.slot = slot;
4
+ this.hide();
5
+ this.slot.classList.add('ed-progress-bar');
6
+ }
7
+ ProgressBar.prototype.show = function () {
8
+ this.slot.style.removeProperty('display');
9
+ };
10
+ ProgressBar.prototype.hide = function () {
11
+ this.slot.style.display = 'none';
12
+ };
13
+ return ProgressBar;
14
+ }());
15
+ export { ProgressBar };
16
16
  //# sourceMappingURL=progress_bar.js.map
@@ -1,24 +1,24 @@
1
- import { EasyGrid } from '@easydata/ui';
2
- import { DataFilter } from '../filter/data_filter';
3
- export interface TextFilterWidgetOptions {
4
- focus?: boolean;
5
- instantMode?: boolean;
6
- instantTimeout?: number;
7
- }
8
- export declare class TextFilterWidget {
9
- private slot;
10
- private grid;
11
- private filter;
12
- private options;
13
- constructor(slot: HTMLElement, grid: EasyGrid, filter: DataFilter, options?: TextFilterWidgetOptions);
14
- private filterInput;
15
- private render;
16
- private applyFilterTimeout;
17
- private inputKeydownHandler;
18
- private inputKeyupHandler;
19
- private clearButtonClickHander;
20
- private searchButtonClickHandler;
21
- applyFilter(checkChange: boolean): boolean;
22
- private highlightCellRenderer;
23
- private highlightText;
24
- }
1
+ import { EasyGrid } from '@easydata/ui';
2
+ import { DataFilter } from '../filter/data_filter';
3
+ export interface TextFilterWidgetOptions {
4
+ focus?: boolean;
5
+ instantMode?: boolean;
6
+ instantTimeout?: number;
7
+ }
8
+ export declare class TextFilterWidget {
9
+ private slot;
10
+ private grid;
11
+ private filter;
12
+ private options;
13
+ constructor(slot: HTMLElement, grid: EasyGrid, filter: DataFilter, options?: TextFilterWidgetOptions);
14
+ private filterInput;
15
+ private render;
16
+ private applyFilterTimeout;
17
+ private inputKeydownHandler;
18
+ private inputKeyupHandler;
19
+ private clearButtonClickHander;
20
+ private searchButtonClickHandler;
21
+ applyFilter(checkChange: boolean): boolean;
22
+ private highlightCellRenderer;
23
+ private highlightText;
24
+ }
@@ -1,214 +1,214 @@
1
- import { i18n, utils as dataUtils } from '@easydata/core';
2
- import { browserUtils, CellRendererType, domel, DFMT_REGEX } from '@easydata/ui';
3
- var TextFilterWidget = /** @class */ (function () {
4
- function TextFilterWidget(slot, grid, filter, options) {
5
- var _this = this;
6
- this.slot = slot;
7
- this.grid = grid;
8
- this.filter = filter;
9
- this.options = {
10
- focus: false,
11
- instantMode: false,
12
- instantTimeout: 1000
13
- };
14
- this.options = dataUtils.assignDeep(this.options, options || {});
15
- var stringDefRenderer = this.grid.cellRendererStore
16
- .getDefaultRendererByType(CellRendererType.STRING);
17
- this.grid.cellRendererStore
18
- .setDefaultRenderer(CellRendererType.STRING, function (value, column, cellElement, rowElement) {
19
- return _this.highlightCellRenderer(stringDefRenderer, value, column, cellElement, rowElement);
20
- });
21
- var numDefRenderer = this.grid.cellRendererStore
22
- .getDefaultRendererByType(CellRendererType.NUMBER);
23
- this.grid.cellRendererStore
24
- .setDefaultRenderer(CellRendererType.NUMBER, function (value, column, cellElement, rowElement) {
25
- return _this.highlightCellRenderer(numDefRenderer, value, column, cellElement, rowElement);
26
- });
27
- this.render();
28
- }
29
- TextFilterWidget.prototype.render = function () {
30
- var _this = this;
31
- var horizClass = browserUtils.IsIE()
32
- ? 'kfrm-fields-ie is-horizontal'
33
- : 'kfrm-fields is-horizontal';
34
- var isEdgeOrIE = browserUtils.IsIE() || browserUtils.IsEdge();
35
- domel(this.slot)
36
- .addClass(horizClass)
37
- .addChild('div', function (b) {
38
- b
39
- .addClass('control')
40
- .addChild('input', function (b) {
41
- _this.filterInput = b.toDOM();
42
- b
43
- .attr('placeholder', i18n.getText('SearchInputPlaceholder'))
44
- .type('text');
45
- b.on('keydown', _this.inputKeydownHandler.bind(_this));
46
- if (_this.options.instantMode) {
47
- b.on('keyup', _this.inputKeyupHandler.bind(_this));
48
- }
49
- });
50
- if (!isEdgeOrIE) {
51
- b
52
- .addClass('has-icons-right')
53
- .addChild('span', function (b) {
54
- b
55
- .addClass('icon')
56
- .addClass('is-right')
57
- .addClass('is-clickable')
58
- .html('🗙')
59
- .on('click', _this.clearButtonClickHander.bind(_this));
60
- });
61
- }
62
- });
63
- if (!this.options.instantMode) {
64
- domel(this.slot)
65
- .addChild('button', function (b) { return b
66
- .addClass('kfrm-button')
67
- .addText(i18n.getText('SearchBtn'))
68
- .on('click', _this.searchButtonClickHandler.bind(_this)); });
69
- }
70
- if (this.options.focus) {
71
- this.filterInput.focus();
72
- }
73
- };
74
- TextFilterWidget.prototype.inputKeydownHandler = function (ev) {
75
- if (ev.keyCode == 13) {
76
- this.applyFilter(true);
77
- }
78
- };
79
- TextFilterWidget.prototype.inputKeyupHandler = function () {
80
- var _this = this;
81
- if (this.applyFilterTimeout) {
82
- clearTimeout(this.applyFilterTimeout);
83
- }
84
- this.applyFilterTimeout = setTimeout(function () {
85
- _this.applyFilter(true);
86
- }, this.options.instantTimeout);
87
- };
88
- TextFilterWidget.prototype.clearButtonClickHander = function () {
89
- this.filterInput.value = '';
90
- this.filterInput.focus();
91
- this.applyFilter(true);
92
- };
93
- TextFilterWidget.prototype.searchButtonClickHandler = function () {
94
- this.applyFilter(true);
95
- };
96
- TextFilterWidget.prototype.applyFilter = function (checkChange) {
97
- var _this = this;
98
- if (this.applyFilterTimeout) {
99
- clearTimeout(this.applyFilterTimeout);
100
- }
101
- var filterValue = this.filter.getValue();
102
- if (!checkChange || filterValue != this.filterInput.value) {
103
- this.filter.apply(this.filterInput.value)
104
- .then(function (data) {
105
- _this.grid.setData(data);
106
- });
107
- return true;
108
- }
109
- return false;
110
- };
111
- TextFilterWidget.prototype.highlightCellRenderer = function (defaultRenderer, value, column, cellElement, rowElement) {
112
- if (dataUtils.isNumericType(column.type)
113
- || dataUtils.getStringDataTypes().indexOf(column.type) >= 0) {
114
- if (value) {
115
- if (column.dataColumn && column.dataColumn.displayFormat
116
- && DFMT_REGEX.test(column.dataColumn.displayFormat)) {
117
- value = column.dataColumn.displayFormat.replace(DFMT_REGEX, function (_, $1) {
118
- return i18n.numberToStr(value, $1);
119
- });
120
- }
121
- else {
122
- value = value.toLocaleString();
123
- }
124
- var result = this.highlightText(value.toString());
125
- if (result instanceof HTMLElement) {
126
- cellElement.title = value;
127
- cellElement.appendChild(result);
128
- return;
129
- }
130
- }
131
- }
132
- defaultRenderer(value, column, cellElement, rowElement);
133
- };
134
- TextFilterWidget.prototype.highlightText = function (content) {
135
- var normalizedContent = content.toLowerCase();
136
- var filterValue = this.filter.getValue().toString();
137
- if (filterValue && filterValue.length > 0 && content && content.length > 0) {
138
- var indexInMas = [];
139
- var words = filterValue.split('||').map(function (w) { return w.trim().toLowerCase(); });
140
- for (var i = 0; i < words.length; i++) {
141
- var pos = 0;
142
- var lowerWord = words[i];
143
- if (!lowerWord.length)
144
- continue;
145
- if (lowerWord === normalizedContent) {
146
- var highlightSpan = document.createElement('span');
147
- highlightSpan.style.backgroundColor = 'yellow';
148
- highlightSpan.innerText = content;
149
- return highlightSpan;
150
- }
151
- while (pos < content.length - 1) {
152
- var index = normalizedContent.indexOf(lowerWord, pos);
153
- if (index >= 0) {
154
- indexInMas.push({ index: index, length: words[i].length });
155
- pos = index + lowerWord.length;
156
- }
157
- else {
158
- pos++;
159
- }
160
- }
161
- }
162
- if (indexInMas.length > 0) {
163
- //sort array item by index
164
- indexInMas.sort(function (item1, item2) {
165
- if (item1.index > item2.index) {
166
- return 1;
167
- }
168
- else if (item1.index == item2.index2) {
169
- return 0;
170
- }
171
- else {
172
- return -1;
173
- }
174
- });
175
- //remove intersecting gaps
176
- for (var i = 0; i < indexInMas.length - 1;) {
177
- var delta = indexInMas[i + 1].index - (indexInMas[i].index + indexInMas[i].length);
178
- if (delta < 0) {
179
- var addDelta = indexInMas[i + 1].length + delta;
180
- if (addDelta > 0) {
181
- indexInMas[i].length += addDelta;
182
- }
183
- indexInMas.splice(i + 1, 1);
184
- }
185
- else {
186
- i++;
187
- }
188
- }
189
- var div = document.createElement('div');
190
- for (var i = 0; i < indexInMas.length; i++) {
191
- if (i === 0) {
192
- var text_1 = document.createTextNode(content.substring(0, indexInMas[i].index));
193
- div.appendChild(text_1);
194
- }
195
- var highlightSpan = document.createElement('span');
196
- highlightSpan.style.backgroundColor = 'yellow';
197
- highlightSpan.innerText = content.substring(indexInMas[i].index, indexInMas[i].index + indexInMas[i].length);
198
- div.appendChild(highlightSpan);
199
- var text = (i < indexInMas.length - 1)
200
- ? document.createTextNode(content.substring(indexInMas[i].index
201
- + indexInMas[i].length, indexInMas[i + 1].index))
202
- : document.createTextNode(content.substring(indexInMas[i].index
203
- + indexInMas[i].length));
204
- div.appendChild(text);
205
- }
206
- return div;
207
- }
208
- }
209
- return content;
210
- };
211
- return TextFilterWidget;
212
- }());
213
- export { TextFilterWidget };
1
+ import { i18n, utils as dataUtils } from '@easydata/core';
2
+ import { browserUtils, CellRendererType, domel, DFMT_REGEX } from '@easydata/ui';
3
+ var TextFilterWidget = /** @class */ (function () {
4
+ function TextFilterWidget(slot, grid, filter, options) {
5
+ var _this = this;
6
+ this.slot = slot;
7
+ this.grid = grid;
8
+ this.filter = filter;
9
+ this.options = {
10
+ focus: false,
11
+ instantMode: false,
12
+ instantTimeout: 1000
13
+ };
14
+ this.options = dataUtils.assignDeep(this.options, options || {});
15
+ var stringDefRenderer = this.grid.cellRendererStore
16
+ .getDefaultRendererByType(CellRendererType.STRING);
17
+ this.grid.cellRendererStore
18
+ .setDefaultRenderer(CellRendererType.STRING, function (value, column, cellElement, rowElement) {
19
+ return _this.highlightCellRenderer(stringDefRenderer, value, column, cellElement, rowElement);
20
+ });
21
+ var numDefRenderer = this.grid.cellRendererStore
22
+ .getDefaultRendererByType(CellRendererType.NUMBER);
23
+ this.grid.cellRendererStore
24
+ .setDefaultRenderer(CellRendererType.NUMBER, function (value, column, cellElement, rowElement) {
25
+ return _this.highlightCellRenderer(numDefRenderer, value, column, cellElement, rowElement);
26
+ });
27
+ this.render();
28
+ }
29
+ TextFilterWidget.prototype.render = function () {
30
+ var _this = this;
31
+ var horizClass = browserUtils.IsIE()
32
+ ? 'kfrm-fields-ie is-horizontal'
33
+ : 'kfrm-fields is-horizontal';
34
+ var isEdgeOrIE = browserUtils.IsIE() || browserUtils.IsEdge();
35
+ domel(this.slot)
36
+ .addClass(horizClass)
37
+ .addChild('div', function (b) {
38
+ b
39
+ .addClass('control')
40
+ .addChild('input', function (b) {
41
+ _this.filterInput = b.toDOM();
42
+ b
43
+ .attr('placeholder', i18n.getText('SearchInputPlaceholder'))
44
+ .type('text');
45
+ b.on('keydown', _this.inputKeydownHandler.bind(_this));
46
+ if (_this.options.instantMode) {
47
+ b.on('keyup', _this.inputKeyupHandler.bind(_this));
48
+ }
49
+ });
50
+ if (!isEdgeOrIE) {
51
+ b
52
+ .addClass('has-icons-right')
53
+ .addChild('span', function (b) {
54
+ b
55
+ .addClass('icon')
56
+ .addClass('is-right')
57
+ .addClass('is-clickable')
58
+ .html('&#x1F5D9;')
59
+ .on('click', _this.clearButtonClickHander.bind(_this));
60
+ });
61
+ }
62
+ });
63
+ if (!this.options.instantMode) {
64
+ domel(this.slot)
65
+ .addChild('button', function (b) { return b
66
+ .addClass('kfrm-button')
67
+ .addText(i18n.getText('SearchBtn'))
68
+ .on('click', _this.searchButtonClickHandler.bind(_this)); });
69
+ }
70
+ if (this.options.focus) {
71
+ this.filterInput.focus();
72
+ }
73
+ };
74
+ TextFilterWidget.prototype.inputKeydownHandler = function (ev) {
75
+ if (ev.keyCode == 13) {
76
+ this.applyFilter(true);
77
+ }
78
+ };
79
+ TextFilterWidget.prototype.inputKeyupHandler = function () {
80
+ var _this = this;
81
+ if (this.applyFilterTimeout) {
82
+ clearTimeout(this.applyFilterTimeout);
83
+ }
84
+ this.applyFilterTimeout = setTimeout(function () {
85
+ _this.applyFilter(true);
86
+ }, this.options.instantTimeout);
87
+ };
88
+ TextFilterWidget.prototype.clearButtonClickHander = function () {
89
+ this.filterInput.value = '';
90
+ this.filterInput.focus();
91
+ this.applyFilter(true);
92
+ };
93
+ TextFilterWidget.prototype.searchButtonClickHandler = function () {
94
+ this.applyFilter(true);
95
+ };
96
+ TextFilterWidget.prototype.applyFilter = function (checkChange) {
97
+ var _this = this;
98
+ if (this.applyFilterTimeout) {
99
+ clearTimeout(this.applyFilterTimeout);
100
+ }
101
+ var filterValue = this.filter.getValue();
102
+ if (!checkChange || filterValue != this.filterInput.value) {
103
+ this.filter.apply(this.filterInput.value)
104
+ .then(function (data) {
105
+ _this.grid.setData(data);
106
+ });
107
+ return true;
108
+ }
109
+ return false;
110
+ };
111
+ TextFilterWidget.prototype.highlightCellRenderer = function (defaultRenderer, value, column, cellElement, rowElement) {
112
+ if (dataUtils.isNumericType(column.type)
113
+ || dataUtils.getStringDataTypes().indexOf(column.type) >= 0) {
114
+ if (value) {
115
+ if (column.dataColumn && column.dataColumn.displayFormat
116
+ && DFMT_REGEX.test(column.dataColumn.displayFormat)) {
117
+ value = column.dataColumn.displayFormat.replace(DFMT_REGEX, function (_, $1) {
118
+ return i18n.numberToStr(value, $1);
119
+ });
120
+ }
121
+ else {
122
+ value = value.toLocaleString();
123
+ }
124
+ var result = this.highlightText(value.toString());
125
+ if (result instanceof HTMLElement) {
126
+ cellElement.title = value;
127
+ cellElement.appendChild(result);
128
+ return;
129
+ }
130
+ }
131
+ }
132
+ defaultRenderer(value, column, cellElement, rowElement);
133
+ };
134
+ TextFilterWidget.prototype.highlightText = function (content) {
135
+ var normalizedContent = content.toLowerCase();
136
+ var filterValue = this.filter.getValue().toString();
137
+ if (filterValue && filterValue.length > 0 && content && content.length > 0) {
138
+ var indexInMas = [];
139
+ var words = filterValue.split('||').map(function (w) { return w.trim().toLowerCase(); });
140
+ for (var i = 0; i < words.length; i++) {
141
+ var pos = 0;
142
+ var lowerWord = words[i];
143
+ if (!lowerWord.length)
144
+ continue;
145
+ if (lowerWord === normalizedContent) {
146
+ var highlightSpan = document.createElement('span');
147
+ highlightSpan.style.backgroundColor = 'yellow';
148
+ highlightSpan.innerText = content;
149
+ return highlightSpan;
150
+ }
151
+ while (pos < content.length - 1) {
152
+ var index = normalizedContent.indexOf(lowerWord, pos);
153
+ if (index >= 0) {
154
+ indexInMas.push({ index: index, length: words[i].length });
155
+ pos = index + lowerWord.length;
156
+ }
157
+ else {
158
+ pos++;
159
+ }
160
+ }
161
+ }
162
+ if (indexInMas.length > 0) {
163
+ //sort array item by index
164
+ indexInMas.sort(function (item1, item2) {
165
+ if (item1.index > item2.index) {
166
+ return 1;
167
+ }
168
+ else if (item1.index == item2.index2) {
169
+ return 0;
170
+ }
171
+ else {
172
+ return -1;
173
+ }
174
+ });
175
+ //remove intersecting gaps
176
+ for (var i = 0; i < indexInMas.length - 1;) {
177
+ var delta = indexInMas[i + 1].index - (indexInMas[i].index + indexInMas[i].length);
178
+ if (delta < 0) {
179
+ var addDelta = indexInMas[i + 1].length + delta;
180
+ if (addDelta > 0) {
181
+ indexInMas[i].length += addDelta;
182
+ }
183
+ indexInMas.splice(i + 1, 1);
184
+ }
185
+ else {
186
+ i++;
187
+ }
188
+ }
189
+ var div = document.createElement('div');
190
+ for (var i = 0; i < indexInMas.length; i++) {
191
+ if (i === 0) {
192
+ var text_1 = document.createTextNode(content.substring(0, indexInMas[i].index));
193
+ div.appendChild(text_1);
194
+ }
195
+ var highlightSpan = document.createElement('span');
196
+ highlightSpan.style.backgroundColor = 'yellow';
197
+ highlightSpan.innerText = content.substring(indexInMas[i].index, indexInMas[i].index + indexInMas[i].length);
198
+ div.appendChild(highlightSpan);
199
+ var text = (i < indexInMas.length - 1)
200
+ ? document.createTextNode(content.substring(indexInMas[i].index
201
+ + indexInMas[i].length, indexInMas[i + 1].index))
202
+ : document.createTextNode(content.substring(indexInMas[i].index
203
+ + indexInMas[i].length));
204
+ div.appendChild(text);
205
+ }
206
+ return div;
207
+ }
208
+ }
209
+ return content;
210
+ };
211
+ return TextFilterWidget;
212
+ }());
213
+ export { TextFilterWidget };
214
214
  //# sourceMappingURL=text_filter_widget.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easydata/crud",
3
- "version": "1.4.13",
3
+ "version": "1.4.18",
4
4
  "description": "EasyData.JS UI widgets and view for CRUD manipulations",
5
5
  "types": "./dist/lib/public_api.d.ts",
6
6
  "main": "./dist/bundles/easydata.crud.js",
@@ -29,39 +29,39 @@
29
29
  "bugs": "https://github.com/KorzhCom/EasyData/issues",
30
30
  "license": "MIT",
31
31
  "peerDependencies": {
32
- "@easydata/core": "^1.4.13",
33
- "@easydata/ui": "^1.4.13"
32
+ "@easydata/core": "^1.4.18",
33
+ "@easydata/ui": "^1.4.18"
34
34
  },
35
35
  "devDependencies": {
36
- "@types/node": "12.7.8",
37
- "@types/jasmine": "^3.3.12",
38
- "@types/jsdom": "12.2.4",
39
- "autoprefixer": "^9.7.2",
40
- "css-loader": "^2.1.0",
36
+ "@types/jasmine": "^4.3.2",
37
+ "@types/jsdom": "21.1.1",
38
+ "@types/node": "20.2.5",
39
+ "autoprefixer": "^10.4.14",
40
+ "css-loader": "^6.7.4",
41
41
  "es6-promise": "^4.2.8",
42
42
  "extract-text-webpack-plugin": "^4.0.0-beta.0",
43
- "filemanager-webpack-plugin": "^3.0.0-alpha.7",
44
- "jasmine": "^3.4.0",
43
+ "filemanager-webpack-plugin": "^8.0.0",
44
+ "jasmine": "^5.0.0",
45
45
  "jasmine-ts-console-reporter": "^3.1.1",
46
- "jsdom": "^15.1.1",
47
- "mini-css-extract-plugin": "0.5.0",
48
- "nodemon": "1.18.10",
49
- "optimize-css-assets-webpack-plugin": "5.0.1",
50
- "postcss-loader": "^3.0.0",
51
- "rimraf": "2.6.3",
52
- "style-loader": "^0.23.1",
53
- "ts-loader": "^5.3.3",
54
- "ts-node": "^8.0.2",
55
- "typedoc": "^0.15.0",
56
- "typedoc-webpack-plugin": "^1.1.4",
57
- "typescript": "3.7.*",
46
+ "jsdom": "^22.1.0",
47
+ "mini-css-extract-plugin": "2.7.6",
48
+ "nodemon": "2.0.22",
49
+ "optimize-css-assets-webpack-plugin": "6.0.1",
50
+ "postcss-loader": "^7.3.1",
51
+ "rimraf": "5.0.1",
52
+ "style-loader": "^3.3.3",
53
+ "terser-webpack-plugin": "^5.3.9",
54
+ "ts-loader": "^9.4.3",
55
+ "ts-node": "^10.9.1",
56
+ "typedoc": "^0.24.7",
57
+ "typescript": "5.0.*",
58
58
  "typings-for-css-modules-loader": "1.7.0",
59
- "terser-webpack-plugin": "^4.2.3",
60
- "webpack": "^4.36.1",
61
- "webpack-cli": "^3.3.6"
59
+ "webpack": "^5.84.1",
60
+ "webpack-cli": "^5.1.1",
61
+ "@olton/typedoc-webpack-plugin": "^0.1.0"
62
62
  },
63
63
  "browserslist": [
64
- "defaults"
64
+ "defaults and supports es6-module"
65
65
  ],
66
66
  "nodemonConfig": {
67
67
  "watch": [
@@ -70,5 +70,6 @@
70
70
  "delay": "1000",
71
71
  "ext": "ts,js",
72
72
  "exec": "tsc"
73
- }
73
+ },
74
+ "dependencies": {}
74
75
  }