@sankhyalabs/ezui 5.21.0-dev.3 → 5.21.0-dev.31

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 (188) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/ICustomRender-6fafffce.js +13 -0
  3. package/dist/cjs/ez-actions-button.cjs.entry.js +1 -0
  4. package/dist/cjs/ez-alert-list.cjs.entry.js +6 -4
  5. package/dist/cjs/ez-button.cjs.entry.js +2 -2
  6. package/dist/cjs/ez-chart.cjs.entry.js +433 -0
  7. package/dist/cjs/ez-collapsible-box.cjs.entry.js +1 -0
  8. package/dist/cjs/ez-combo-box.cjs.entry.js +1 -0
  9. package/dist/cjs/{ez-text-edit.cjs.entry.js → ez-custom-form-input_2.cjs.entry.js} +94 -0
  10. package/dist/cjs/ez-form-view.cjs.entry.js +33 -3
  11. package/dist/cjs/ez-form.cjs.entry.js +77 -2
  12. package/dist/cjs/ez-grid.cjs.entry.js +360 -34
  13. package/dist/cjs/ez-list.cjs.entry.js +11 -3
  14. package/dist/cjs/ez-modal-container.cjs.entry.js +2 -2
  15. package/dist/cjs/ez-number-input.cjs.entry.js +37 -31
  16. package/dist/cjs/ez-search.cjs.entry.js +27 -5
  17. package/dist/cjs/ez-split-item.cjs.entry.js +1 -0
  18. package/dist/cjs/ez-split-panel.cjs.entry.js +1 -1
  19. package/dist/cjs/ez-tabselector.cjs.entry.js +34 -29
  20. package/dist/cjs/ezui.cjs.js +1 -1
  21. package/dist/cjs/index-a7b0c73d.js +8 -4
  22. package/dist/cjs/loader.cjs.js +1 -1
  23. package/dist/collection/collection-manifest.json +2 -0
  24. package/dist/collection/components/ez-alert-list/ez-alert-list.js +6 -4
  25. package/dist/collection/components/ez-button/ez-button.css +7 -0
  26. package/dist/collection/components/ez-button/ez-button.js +1 -1
  27. package/dist/collection/components/ez-chart/components/BarChart.js +27 -0
  28. package/dist/collection/components/ez-chart/components/ColumnChart.js +27 -0
  29. package/dist/collection/components/ez-chart/components/DonutChart.js +42 -0
  30. package/dist/collection/components/ez-chart/components/LineChart.js +27 -0
  31. package/dist/collection/components/ez-chart/components/PieChart.js +45 -0
  32. package/dist/collection/components/ez-chart/components/index.js +5 -0
  33. package/dist/collection/components/ez-chart/ez-chart.css +5 -0
  34. package/dist/collection/components/ez-chart/ez-chart.js +284 -0
  35. package/dist/collection/components/ez-chart/interfaces/ChartAxis.js +1 -0
  36. package/dist/collection/components/ez-chart/interfaces/ChartContext.js +14 -0
  37. package/dist/collection/components/ez-chart/interfaces/ChartOptions.js +1 -0
  38. package/dist/collection/components/ez-chart/interfaces/ChartSerie.js +1 -0
  39. package/dist/collection/components/ez-chart/interfaces/ChartStrategies.js +1 -0
  40. package/dist/collection/components/ez-chart/interfaces/ChartType.js +8 -0
  41. package/dist/collection/components/ez-chart/interfaces/index.js +5 -0
  42. package/dist/collection/components/ez-chart/test/mock-chart.js +137 -0
  43. package/dist/collection/components/ez-chart/types/BaseHighChartsRender.js +146 -0
  44. package/dist/collection/components/ez-form/ez-form.js +130 -4
  45. package/dist/collection/components/ez-form-view/custom-input/ez-custom-form-input.js +253 -0
  46. package/dist/collection/components/ez-form-view/ez-form-view.js +89 -1
  47. package/dist/collection/components/ez-form-view/fieldbuilder/templates/NumberInput.tpl.js +3 -2
  48. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +62 -5
  49. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +9 -0
  50. package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +35 -1
  51. package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.js +58 -0
  52. package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellRender.js +40 -0
  53. package/dist/collection/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellEditorConstants.js +11 -0
  54. package/dist/collection/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellRenderConstants.js +11 -0
  55. package/dist/collection/components/ez-grid/controller/ag-grid/editor/EzCellEditor.js +6 -3
  56. package/dist/collection/components/ez-grid/controller/ag-grid/editor/EzCellRender.js +40 -0
  57. package/dist/collection/components/ez-grid/controller/ag-grid/editor/IUICellRender.js +1 -0
  58. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js +3 -2
  59. package/dist/collection/components/ez-grid/ez-grid.css +1 -0
  60. package/dist/collection/components/ez-grid/ez-grid.js +265 -13
  61. package/dist/collection/components/ez-grid/interfaces/ICustomFormatter.js +1 -0
  62. package/dist/collection/components/ez-grid/interfaces/index.js +1 -0
  63. package/dist/collection/components/ez-grid/subcomponents/selection-counter.js +3 -11
  64. package/dist/collection/components/ez-grid/subcomponents/utils/selectionCounterUtils.js +22 -0
  65. package/dist/collection/components/ez-grid/test/resources/gridDataUnit.js +19 -0
  66. package/dist/collection/components/ez-list/ez-list.css +6 -2
  67. package/dist/collection/components/ez-list/ez-list.js +28 -2
  68. package/dist/collection/components/ez-modal-container/ez-modal-container.css +4 -0
  69. package/dist/collection/components/ez-modal-container/ez-modal-container.js +1 -1
  70. package/dist/collection/components/ez-number-input/ez-number-input.js +46 -31
  71. package/dist/collection/components/ez-search/ez-search.js +26 -5
  72. package/dist/collection/components/ez-split-panel/ez-split-panel.css +1 -0
  73. package/dist/collection/components/ez-tabselector/ez-tabselector.js +34 -29
  74. package/dist/collection/utils/customEditor/interfaces/ICustomEditor.js +5 -0
  75. package/dist/collection/utils/customEditor/interfaces/ICustomEditorInfo.js +1 -0
  76. package/dist/collection/utils/customRender/interfaces/ICustomRender.js +5 -0
  77. package/dist/collection/utils/customRender/interfaces/ICustomRenderInfo.js +1 -0
  78. package/dist/collection/utils/form/DataBinder.js +26 -0
  79. package/dist/collection/utils/form/test/DataBinder.test.js +41 -4
  80. package/dist/collection/utils/form/test/resources/metadataTest.js +15 -0
  81. package/dist/collection/utils/index.js +2 -0
  82. package/dist/custom-elements/index.d.ts +12 -0
  83. package/dist/custom-elements/index.js +1131 -122
  84. package/dist/esm/ICustomRender-875b5a40.js +13 -0
  85. package/dist/esm/ez-actions-button.entry.js +1 -0
  86. package/dist/esm/ez-alert-list.entry.js +6 -4
  87. package/dist/esm/ez-button.entry.js +2 -2
  88. package/dist/esm/ez-chart.entry.js +429 -0
  89. package/dist/esm/ez-collapsible-box.entry.js +1 -0
  90. package/dist/esm/ez-combo-box.entry.js +1 -0
  91. package/dist/esm/{ez-text-edit.entry.js → ez-custom-form-input_2.entry.js} +96 -3
  92. package/dist/esm/ez-form-view.entry.js +33 -3
  93. package/dist/esm/ez-form.entry.js +78 -3
  94. package/dist/esm/ez-grid.entry.js +360 -34
  95. package/dist/esm/ez-list.entry.js +11 -3
  96. package/dist/esm/ez-modal-container.entry.js +2 -2
  97. package/dist/esm/ez-number-input.entry.js +38 -32
  98. package/dist/esm/ez-search.entry.js +27 -5
  99. package/dist/esm/ez-split-item.entry.js +1 -0
  100. package/dist/esm/ez-split-panel.entry.js +1 -1
  101. package/dist/esm/ez-tabselector.entry.js +34 -29
  102. package/dist/esm/ezui.js +1 -1
  103. package/dist/esm/index-baa5e267.js +8 -4
  104. package/dist/esm/loader.js +1 -1
  105. package/dist/ezui/ezui.esm.js +1 -1
  106. package/dist/ezui/p-09de35a2.entry.js +1 -0
  107. package/dist/ezui/{p-af2ecb1b.entry.js → p-1285c902.entry.js} +1 -1
  108. package/dist/ezui/p-13d2fe2d.entry.js +1 -0
  109. package/dist/ezui/p-1a35324b.entry.js +1 -0
  110. package/dist/ezui/p-1ee2479b.entry.js +1 -0
  111. package/dist/ezui/p-2097d0cf.entry.js +1 -0
  112. package/dist/ezui/p-2dcb50d4.entry.js +1 -0
  113. package/dist/ezui/p-30775e7f.entry.js +1 -0
  114. package/dist/ezui/p-3b4eeeb6.entry.js +1 -0
  115. package/dist/ezui/p-3b56d2ef.entry.js +1 -0
  116. package/dist/ezui/p-42566f9e.entry.js +1 -0
  117. package/dist/ezui/p-4607fb89.js +1 -0
  118. package/dist/ezui/p-7922142b.entry.js +1 -0
  119. package/dist/ezui/p-84e439b9.entry.js +1 -0
  120. package/dist/ezui/p-922ac38b.entry.js +1 -0
  121. package/dist/ezui/{p-b44741b0.entry.js → p-97db197f.entry.js} +2 -2
  122. package/dist/ezui/p-bcb53f27.entry.js +1 -0
  123. package/dist/ezui/p-ffef392d.entry.js +1 -0
  124. package/dist/types/components/ez-alert-list/ez-alert-list.d.ts +2 -2
  125. package/dist/types/components/ez-chart/components/BarChart.d.ts +9 -0
  126. package/dist/types/components/ez-chart/components/ColumnChart.d.ts +9 -0
  127. package/dist/types/components/ez-chart/components/DonutChart.d.ts +9 -0
  128. package/dist/types/components/ez-chart/components/LineChart.d.ts +9 -0
  129. package/dist/types/components/ez-chart/components/PieChart.d.ts +9 -0
  130. package/dist/types/components/ez-chart/components/index.d.ts +5 -0
  131. package/dist/types/components/ez-chart/ez-chart.d.ts +58 -0
  132. package/dist/types/components/ez-chart/interfaces/ChartAxis.d.ts +7 -0
  133. package/dist/types/components/ez-chart/interfaces/ChartContext.d.ts +11 -0
  134. package/dist/types/components/ez-chart/interfaces/ChartOptions.d.ts +10 -0
  135. package/dist/types/components/ez-chart/interfaces/ChartSerie.d.ts +20 -0
  136. package/dist/types/components/ez-chart/interfaces/ChartStrategies.d.ts +7 -0
  137. package/dist/types/components/ez-chart/interfaces/ChartType.d.ts +7 -0
  138. package/dist/types/components/ez-chart/interfaces/index.d.ts +5 -0
  139. package/dist/types/components/ez-chart/types/BaseHighChartsRender.d.ts +15 -0
  140. package/dist/types/components/ez-form/ez-form.d.ts +20 -1
  141. package/dist/types/components/ez-form-view/custom-input/ez-custom-form-input.d.ts +43 -0
  142. package/dist/types/components/ez-form-view/ez-form-view.d.ts +11 -0
  143. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +42 -0
  144. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +15 -0
  145. package/dist/types/components/ez-grid/controller/ag-grid/DataSource.d.ts +2 -0
  146. package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +7 -1
  147. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.d.ts +19 -0
  148. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellRender.d.ts +14 -0
  149. package/dist/types/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellEditorConstants.d.ts +11 -0
  150. package/dist/types/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellRenderConstants.d.ts +11 -0
  151. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellEditor.d.ts +3 -0
  152. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellRender.d.ts +15 -0
  153. package/dist/types/components/ez-grid/controller/ag-grid/editor/IUICellRender.d.ts +10 -0
  154. package/dist/types/components/ez-grid/ez-grid.d.ts +39 -1
  155. package/dist/types/components/ez-grid/interfaces/ICustomFormatter.d.ts +5 -0
  156. package/dist/types/components/ez-grid/interfaces/index.d.ts +1 -0
  157. package/dist/types/components/ez-grid/subcomponents/utils/selectionCounterUtils.d.ts +4 -0
  158. package/dist/types/components/ez-grid/test/resources/gridDataUnit.d.ts +2 -0
  159. package/dist/types/components/ez-list/ez-list.d.ts +5 -0
  160. package/dist/types/components/ez-number-input/ez-number-input.d.ts +3 -0
  161. package/dist/types/components/ez-search/ez-search.d.ts +3 -1
  162. package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +3 -2
  163. package/dist/types/components.d.ts +231 -4
  164. package/dist/types/utils/customEditor/interfaces/ICustomEditor.d.ts +29 -0
  165. package/dist/types/utils/customEditor/interfaces/ICustomEditorInfo.d.ts +5 -0
  166. package/dist/types/utils/customRender/interfaces/ICustomRender.d.ts +29 -0
  167. package/dist/types/utils/customRender/interfaces/ICustomRenderInfo.d.ts +5 -0
  168. package/dist/types/utils/form/DataBinder.d.ts +3 -0
  169. package/dist/types/utils/form/test/resources/metadataTest.d.ts +2 -0
  170. package/dist/types/utils/index.d.ts +2 -0
  171. package/package.json +2 -1
  172. package/react/components.d.ts +2 -0
  173. package/react/components.js +2 -0
  174. package/react/components.js.map +1 -1
  175. package/dist/ezui/p-0447d17c.entry.js +0 -1
  176. package/dist/ezui/p-20ec22c0.entry.js +0 -1
  177. package/dist/ezui/p-2a1a0e04.entry.js +0 -1
  178. package/dist/ezui/p-44c5b6a5.entry.js +0 -1
  179. package/dist/ezui/p-5ef056ce.entry.js +0 -1
  180. package/dist/ezui/p-637f69f2.entry.js +0 -1
  181. package/dist/ezui/p-8defa6d3.entry.js +0 -1
  182. package/dist/ezui/p-99ead599.entry.js +0 -1
  183. package/dist/ezui/p-9aefaa52.entry.js +0 -1
  184. package/dist/ezui/p-b041333c.entry.js +0 -1
  185. package/dist/ezui/p-b567fa8c.entry.js +0 -1
  186. package/dist/ezui/p-bae3d0aa.entry.js +0 -1
  187. package/dist/ezui/p-cc2dc4f4.entry.js +0 -1
  188. package/dist/ezui/p-db77a984.entry.js +0 -1
@@ -0,0 +1,40 @@
1
+ import EzCellRender from "../editor/EzCellRender";
2
+ import { HTMLBuilder } from "@sankhyalabs/core";
3
+ import { CustomRenderSource } from "../../../../../utils/customRender/interfaces/ICustomRender";
4
+ export default class EzGridCustomCellRender extends EzCellRender {
5
+ init(params) {
6
+ var _a, _b;
7
+ this._fieldName = params.column.getColId();
8
+ this._customRenderInstance = params.customRendersInfo.customRender;
9
+ super.init(params);
10
+ const fieldMetadata = super.getFieldMetadata();
11
+ this._params = {
12
+ value: params.value,
13
+ charPress: '',
14
+ currentRender: super.getGui(),
15
+ name: this._fieldName,
16
+ source: CustomRenderSource.GRID,
17
+ getValue: () => params.getValue(),
18
+ detailContext: params.customRendersInfo.detailContext,
19
+ renderMetadata: {
20
+ hidden: ((_a = fieldMetadata.props) === null || _a === void 0 ? void 0 : _a.visible) === false,
21
+ label: fieldMetadata.label,
22
+ userInterface: fieldMetadata.userInterface,
23
+ props: fieldMetadata.props,
24
+ optionLoader: fieldMetadata.optionLoader,
25
+ options: ((_b = fieldMetadata.props) === null || _b === void 0 ? void 0 : _b.options) || {},
26
+ }
27
+ };
28
+ }
29
+ getGui() {
30
+ const editorElement = this._customRenderInstance.getRenderElement(this._params);
31
+ if (!editorElement) {
32
+ return super.getGui();
33
+ }
34
+ if (typeof editorElement === 'string') {
35
+ const element = HTMLBuilder.parseElement(editorElement);
36
+ return element;
37
+ }
38
+ return editorElement;
39
+ }
40
+ }
@@ -0,0 +1,11 @@
1
+ import { DataType, UserInterface } from "@sankhyalabs/core";
2
+ export const metadata = {
3
+ name: 'metadatada',
4
+ label: 'metadatada',
5
+ fields: [{
6
+ name: 'FIELDNAME',
7
+ label: 'Test',
8
+ dataType: DataType.TEXT,
9
+ userInterface: UserInterface.SHORTTEXT,
10
+ }],
11
+ };
@@ -0,0 +1,11 @@
1
+ import { DataType, UserInterface } from "@sankhyalabs/core";
2
+ export const metadata = {
3
+ name: 'metadatada',
4
+ label: 'metadatada',
5
+ fields: [{
6
+ name: 'FIELDNAME',
7
+ label: 'Test',
8
+ dataType: DataType.TEXT,
9
+ userInterface: UserInterface.SHORTTEXT,
10
+ }],
11
+ };
@@ -20,9 +20,9 @@ export default class EzCellEditor {
20
20
  init(params) {
21
21
  const fieldName = params.column.getColId();
22
22
  const dataUnit = params.context.dataUnit;
23
- const fieldMetadata = buildEditorMetadata(dataUnit.getField(fieldName), params.eGridCell, dataUnit, params.context.editionManager);
24
- const builder = uiBuilders.get(fieldMetadata.userInterface) || buildTextInput;
25
- this._gui = builder(fieldMetadata);
23
+ this._fieldMetadata = buildEditorMetadata(dataUnit.getField(fieldName), params.eGridCell, dataUnit, params.context.editionManager);
24
+ const builder = uiBuilders.get(this._fieldMetadata.userInterface) || buildTextInput;
25
+ this._gui = builder(this._fieldMetadata);
26
26
  if (this._gui.valueSetter != undefined) {
27
27
  this._gui.valueSetter(params.value);
28
28
  }
@@ -46,4 +46,7 @@ export default class EzCellEditor {
46
46
  isPopup() {
47
47
  return this._gui.isPopUp;
48
48
  }
49
+ getFieldMetadata() {
50
+ return this._fieldMetadata;
51
+ }
49
52
  }
@@ -0,0 +1,40 @@
1
+ import { buildEditorMetadata } from "./IEditorMetadata";
2
+ export default class EzCellRender {
3
+ init(params) {
4
+ const span = document.createElement('span');
5
+ this._currentParams = params;
6
+ span.textContent = params.value;
7
+ const fieldName = params.column.getColId();
8
+ const dataUnit = params.context.dataUnit;
9
+ this._fieldMetadata = buildEditorMetadata(dataUnit.getField(fieldName), params.eGridCell, dataUnit, params.context.editionManager);
10
+ this._gui = span;
11
+ }
12
+ refresh() {
13
+ try {
14
+ this._currentParams.refreshCell();
15
+ return true;
16
+ }
17
+ catch (_a) {
18
+ return false;
19
+ }
20
+ }
21
+ getGui() {
22
+ return this._gui;
23
+ }
24
+ afterGuiAttached() {
25
+ this.focusIn();
26
+ }
27
+ focusIn() {
28
+ this._gui.focus();
29
+ this._gui.setFocus({ selectText: true });
30
+ }
31
+ getValue() {
32
+ return this._currentParams.getValue();
33
+ }
34
+ isPopup() {
35
+ return this._gui.isPopUp;
36
+ }
37
+ getFieldMetadata() {
38
+ return this._fieldMetadata;
39
+ }
40
+ }
@@ -1,7 +1,8 @@
1
1
  import { HTMLBuilder } from "@sankhyalabs/core";
2
2
  export const buildDecimal = ({ readOnly, props }) => {
3
- const precision = Number((props === null || props === void 0 ? void 0 : props.precision) || 2);
4
- const prettyPrecision = Number((props === null || props === void 0 ? void 0 : props.prettyPrecision) || precision);
3
+ var _a, _b;
4
+ const precision = Number((_a = props === null || props === void 0 ? void 0 : props.precision) !== null && _a !== void 0 ? _a : 2);
5
+ const prettyPrecision = Number((_b = props === null || props === void 0 ? void 0 : props.prettyPrecision) !== null && _b !== void 0 ? _b : precision);
5
6
  return buildNumeric(readOnly, precision, prettyPrecision);
6
7
  };
7
8
  export const buildInteger = ({ readOnly }) => {
@@ -31,6 +31,7 @@
31
31
  /*private*/
32
32
  padding-top: 15px;
33
33
  margin-top: -12px;
34
+ outline: none;
34
35
 
35
36
  /*public*/
36
37
  box-shadow: var(--ez-grid__container--shadow);
@@ -15,6 +15,8 @@ export class EzGrid {
15
15
  constructor() {
16
16
  this._gridController = new AgGridController(false);
17
17
  this._messageFilterAppliedSuccess = 'Filtro de coluna aplicado com sucesso!';
18
+ this._customEditor = new Map();
19
+ this._customRenders = new Map();
18
20
  this._paginationInfo = undefined;
19
21
  this._paginationChangedByKeyboard = true;
20
22
  this._showSelectionCounter = false;
@@ -22,6 +24,7 @@ export class EzGrid {
22
24
  this._currentPageSelected = undefined;
23
25
  this._selectionCount = undefined;
24
26
  this._hasLeftButtons = false;
27
+ this._customFormatters = new Map();
25
28
  this.multipleSelection = undefined;
26
29
  this.config = undefined;
27
30
  this.selectionToastConfig = undefined;
@@ -32,6 +35,7 @@ export class EzGrid {
32
35
  this.useEnterLikeTab = false;
33
36
  this.recordsValidator = undefined;
34
37
  this.canEdit = true;
38
+ this.autoFocus = true;
35
39
  }
36
40
  /**
37
41
  * Aplica a definição de colunas.
@@ -93,6 +97,69 @@ export class EzGrid {
93
97
  async filterColumns(search) {
94
98
  return Promise.resolve(this._gridController.getColumnsState().filter(col => matches(col.label, search)));
95
99
  }
100
+ /**
101
+ * Registra um editor customizado para campos da grade e formulário.
102
+ */
103
+ async addCustomEditor(fieldName, customEditor, detailContext) {
104
+ const newCustomEditor = new Map(this._customEditor);
105
+ newCustomEditor.set(fieldName, {
106
+ customEditor,
107
+ detailContext,
108
+ });
109
+ this._customEditor = newCustomEditor;
110
+ this._gridController.setCellEditors(newCustomEditor);
111
+ }
112
+ /**
113
+ * Registra um render customizado para colunas da grid.
114
+ */
115
+ async addGridCustomRender(fieldName, customRender, detailContext) {
116
+ const newCustomRenders = new Map(this._customRenders);
117
+ newCustomRenders.set(fieldName, { customRender, detailContext });
118
+ this._customRenders = newCustomRenders;
119
+ this._gridController.setCellRenders(newCustomRenders);
120
+ }
121
+ /**
122
+ * Registra um formatador de valores para uma coluna da grid.
123
+ */
124
+ async addCustomValueFormatter(columnName, customFormatter) {
125
+ if (!columnName || !customFormatter) {
126
+ return;
127
+ }
128
+ const newCustomFormatters = new Map(this._customFormatters);
129
+ newCustomFormatters.set(columnName, customFormatter);
130
+ this._customFormatters = newCustomFormatters;
131
+ this._gridController.setCustomFormatters(newCustomFormatters);
132
+ }
133
+ /**
134
+ * Remove o formatador de valores de uma coluna da grid.
135
+ */
136
+ async removeCustomValueFormatter(columnName) {
137
+ if (!columnName) {
138
+ return;
139
+ }
140
+ const newCustomFormatters = new Map(this._customFormatters);
141
+ newCustomFormatters.delete(columnName);
142
+ this._customFormatters = newCustomFormatters;
143
+ this._gridController.setCustomFormatters(newCustomFormatters);
144
+ }
145
+ /**
146
+ * Atualiza linhas da grade.
147
+ */
148
+ async refreshSelectedRows() {
149
+ this._gridController.refreshSelectedRows();
150
+ }
151
+ /**
152
+ * Retorna o formatador customizado da coluna caso exista.
153
+ */
154
+ async getCustomValueFormatter(columnName) {
155
+ return this._customFormatters.get(columnName);
156
+ }
157
+ /**
158
+ * Atribui o foco para a grade.
159
+ */
160
+ async setFocus() {
161
+ this._gridController.setFocus();
162
+ }
96
163
  observeConfig(config) {
97
164
  this._gridController.setColumnsState(config === null || config === void 0 ? void 0 : config.columns);
98
165
  }
@@ -246,7 +313,9 @@ export class EzGrid {
246
313
  const dataInfo = { dataUnit: this.dataUnit };
247
314
  ElementIDUtils.addIDInfo(this._element, null, dataInfo);
248
315
  const dtInfo = { id: 'ezGrid' };
249
- ElementIDUtils.addIDInfo(this._refPaginationControl, 'pagination', dtInfo);
316
+ if (this._refPaginationControl) {
317
+ ElementIDUtils.addIDInfo(this._refPaginationControl, 'pagination', dtInfo);
318
+ }
250
319
  }
251
320
  previousPage() {
252
321
  if (this.dataUnit) {
@@ -266,14 +335,10 @@ export class EzGrid {
266
335
  (_a = this._gridApi) === null || _a === void 0 ? void 0 : _a.clearRangeSelection();
267
336
  }
268
337
  getPaginationControl() {
269
- if (this._paginationInfo) {
270
- const { currentPage, hasMore } = this._paginationInfo;
271
- return [
272
- h("div", { class: "ez-text ez-text--primary ez-text--medium ez-margin-right--medium", ref: (element) => (this._refPaginationLabel = element) }, h("span", { class: "grid-header__pagination-label" }, h("strong", { class: "ez-text ez-text--primary ez-text--medium" }, this._getActualPageLabel()), this._getRemainingPageLabel())),
273
- h("div", { id: "grid-pagination-tooltip", ref: (element) => (this._refPaginationLabelTooltip = element), class: "ez-flex ez-margin-right--medium" }, h("ez-button", { size: "small", class: "ez-margin-right--medium", iconName: "chevron-left", mode: "icon", enabled: currentPage > 0, onClick: () => this.previousPage(), label: "P\u00E1gina anterior" }), h("ez-button", { size: "small", iconName: "chevron-right", mode: "icon", enabled: hasMore, onClick: () => this.nextPage(), label: "Pr\u00F3xima P\u00E1gina" })),
274
- ];
275
- }
276
- return null;
338
+ if (!this._paginationInfo)
339
+ return null;
340
+ const { currentPage, hasMore } = this._paginationInfo;
341
+ return (h("div", { class: "grid-header__container grid-header__pagination", ref: ref => (this._refPaginationControl = ref) }, h("div", { class: "ez-text ez-text--primary ez-text--medium ez-margin-right--medium", ref: (element) => (this._refPaginationLabel = element) }, h("span", { class: "grid-header__pagination-label" }, h("strong", { class: "ez-text ez-text--primary ez-text--medium" }, this._getActualPageLabel()), this._getRemainingPageLabel())), h("div", { id: "grid-pagination-tooltip", ref: (element) => (this._refPaginationLabelTooltip = element), class: "ez-flex ez-margin-right--medium" }, h("ez-button", { size: "small", class: "ez-margin-right--medium", iconName: "chevron-left", mode: "icon", enabled: currentPage > 0, onClick: () => this.previousPage(), label: "P\u00E1gina anterior" }), h("ez-button", { size: "small", iconName: "chevron-right", mode: "icon", enabled: hasMore, onClick: () => this.nextPage(), label: "Pr\u00F3xima P\u00E1gina" }))));
277
342
  }
278
343
  componentDidLoad() {
279
344
  this._gridController.initDatagrid(this._container, {
@@ -294,7 +359,14 @@ export class EzGrid {
294
359
  statusResolver: this.statusResolver,
295
360
  useEnterLikeTab: this.useEnterLikeTab,
296
361
  recordsValidator: this.recordsValidator,
297
- editionIsDisabled: () => !this.canEdit
362
+ editionIsDisabled: () => !this.canEdit,
363
+ customFormatters: this._customFormatters,
364
+ autoFocus: this.autoFocus,
365
+ onRefresh: () => {
366
+ if (this.dataUnit) {
367
+ this.setSelection(this.dataUnit.getSelectionInfo());
368
+ }
369
+ }
298
370
  });
299
371
  if (this.config) {
300
372
  this.observeConfig(this.config);
@@ -310,7 +382,7 @@ export class EzGrid {
310
382
  }
311
383
  handlePaginationChange(selectFirstRecord, paginationInfo) {
312
384
  var _a;
313
- if (selectFirstRecord !== false) {
385
+ if (selectFirstRecord !== false && this.autoFocus) {
314
386
  if (((_a = this._paginationInfo) === null || _a === void 0 ? void 0 : _a.currentPage) > (paginationInfo === null || paginationInfo === void 0 ? void 0 : paginationInfo.currentPage) && this._paginationChangedByKeyboard) {
315
387
  this._gridController.setFocusLastRow();
316
388
  }
@@ -380,6 +452,9 @@ export class EzGrid {
380
452
  if (!this.dataUnit.name.includes("InMemoryDataUnit"))
381
453
  return;
382
454
  }
455
+ componentDidUpdate() {
456
+ this._gridController.setAutoFocus(this.autoFocus);
457
+ }
383
458
  getDataSource() {
384
459
  var _a;
385
460
  return (_a = this.columnfilterDataSource) !== null && _a !== void 0 ? _a : new InMemoryFilterColumnDataSource(this.dataUnit);
@@ -389,7 +464,7 @@ export class EzGrid {
389
464
  }
390
465
  render() {
391
466
  var _a;
392
- return (h(Host, { "no-header": this.hideHeader() }, h("div", { class: "grid__container ez-grid", ref: elem => (this._container = elem) }), h("div", { class: "ez-box ez-box--shadow ez-padding--medium grid-header" }, h("filter-column", { class: "grid-header__popover", noHeaderTaskBar: !this._hasLeftButtons, dataSource: this.getDataSource(), dataUnit: this.dataUnit, gridHeaderHidden: this.hideHeader(), ref: (element) => (this._filterColumn = element) }), h("div", { class: "grid-header__position" }, h("div", { class: "grid-header__container grid-header__left-container" }, h("slot", { name: "leftButtons" })), h("div", { class: "grid-header__container grid-header__pagination", ref: ref => (this._refPaginationControl = ref) }, this.getPaginationControl()))), h("div", { ref: (ref) => (this._gridSelectionCounter = ref), class: `grid__selection-counter ez-elevation--4
467
+ return (h(Host, { "no-header": this.hideHeader() }, h("div", { class: "grid__container ez-grid", ref: elem => (this._container = elem) }), h("div", { class: "ez-box ez-box--shadow ez-padding--medium grid-header" }, h("filter-column", { class: "grid-header__popover", noHeaderTaskBar: !this._hasLeftButtons, dataSource: this.getDataSource(), dataUnit: this.dataUnit, gridHeaderHidden: this.hideHeader(), ref: (element) => (this._filterColumn = element) }), h("div", { class: "grid-header__position" }, h("div", { class: "grid-header__container grid-header__left-container" }, h("slot", { name: "leftButtons" })), this.getPaginationControl())), h("div", { ref: (ref) => (this._gridSelectionCounter = ref), class: `grid__selection-counter ez-elevation--4
393
468
  ${this._showSelectionCounter ? 'grid__selection-counter--opened' : ''}
394
469
  ` }, h(SelectionCounter, { selectionCount: this._selectionCount, currentPageSelected: this._currentPageSelected, paginationInfo: this._paginationInfo, canSelectAll: (_a = this.selectionToastConfig) === null || _a === void 0 ? void 0 : _a.canSelectAll, allRecordSelected: this._isAllSelection, onSelectAll: () => this.onSelectAllRecords(), onSelectPage: () => this.onSelectPageRecords(), onClearAll: () => this.onClearSelectedRecords(), onClose: () => (this._showSelectionCounter = false) })), h("div", { class: "grid__footer" }, h("slot", { name: "footer" }))));
395
470
  }
@@ -601,6 +676,24 @@ export class EzGrid {
601
676
  "attribute": "can-edit",
602
677
  "reflect": false,
603
678
  "defaultValue": "true"
679
+ },
680
+ "autoFocus": {
681
+ "type": "boolean",
682
+ "mutable": false,
683
+ "complexType": {
684
+ "original": "boolean",
685
+ "resolved": "boolean",
686
+ "references": {}
687
+ },
688
+ "required": false,
689
+ "optional": true,
690
+ "docs": {
691
+ "tags": [],
692
+ "text": "Define se a grid ser\u00E1 focada ao ser carregada."
693
+ },
694
+ "attribute": "auto-focus",
695
+ "reflect": false,
696
+ "defaultValue": "true"
604
697
  }
605
698
  };
606
699
  }
@@ -612,7 +705,8 @@ export class EzGrid {
612
705
  "_isAllSelection": {},
613
706
  "_currentPageSelected": {},
614
707
  "_selectionCount": {},
615
- "_hasLeftButtons": {}
708
+ "_hasLeftButtons": {},
709
+ "_customFormatters": {}
616
710
  };
617
711
  }
618
712
  static get events() {
@@ -946,6 +1040,164 @@ export class EzGrid {
946
1040
  "text": "Usa um argumento para filtrar as colunas po label",
947
1041
  "tags": []
948
1042
  }
1043
+ },
1044
+ "addCustomEditor": {
1045
+ "complexType": {
1046
+ "signature": "(fieldName: string, customEditor: ICustomEditor, detailContext?: string) => Promise<void>",
1047
+ "parameters": [{
1048
+ "tags": [],
1049
+ "text": ""
1050
+ }, {
1051
+ "tags": [],
1052
+ "text": ""
1053
+ }, {
1054
+ "tags": [],
1055
+ "text": ""
1056
+ }],
1057
+ "references": {
1058
+ "Promise": {
1059
+ "location": "global"
1060
+ },
1061
+ "ICustomEditor": {
1062
+ "location": "import",
1063
+ "path": "../../utils/customEditor/interfaces/ICustomEditor"
1064
+ }
1065
+ },
1066
+ "return": "Promise<void>"
1067
+ },
1068
+ "docs": {
1069
+ "text": "Registra um editor customizado para campos da grade e formul\u00E1rio.",
1070
+ "tags": []
1071
+ }
1072
+ },
1073
+ "addGridCustomRender": {
1074
+ "complexType": {
1075
+ "signature": "(fieldName: string, customRender: ICustomRender, detailContext?: string) => Promise<void>",
1076
+ "parameters": [{
1077
+ "tags": [],
1078
+ "text": ""
1079
+ }, {
1080
+ "tags": [],
1081
+ "text": ""
1082
+ }, {
1083
+ "tags": [],
1084
+ "text": ""
1085
+ }],
1086
+ "references": {
1087
+ "Promise": {
1088
+ "location": "global"
1089
+ },
1090
+ "ICustomRender": {
1091
+ "location": "import",
1092
+ "path": "../../utils/customRender/interfaces/ICustomRender"
1093
+ }
1094
+ },
1095
+ "return": "Promise<void>"
1096
+ },
1097
+ "docs": {
1098
+ "text": "Registra um render customizado para colunas da grid.",
1099
+ "tags": []
1100
+ }
1101
+ },
1102
+ "addCustomValueFormatter": {
1103
+ "complexType": {
1104
+ "signature": "(columnName: string, customFormatter: ICustomFormatter) => Promise<void>",
1105
+ "parameters": [{
1106
+ "tags": [],
1107
+ "text": ""
1108
+ }, {
1109
+ "tags": [],
1110
+ "text": ""
1111
+ }],
1112
+ "references": {
1113
+ "Promise": {
1114
+ "location": "global"
1115
+ },
1116
+ "ICustomFormatter": {
1117
+ "location": "import",
1118
+ "path": "./interfaces"
1119
+ }
1120
+ },
1121
+ "return": "Promise<void>"
1122
+ },
1123
+ "docs": {
1124
+ "text": "Registra um formatador de valores para uma coluna da grid.",
1125
+ "tags": []
1126
+ }
1127
+ },
1128
+ "removeCustomValueFormatter": {
1129
+ "complexType": {
1130
+ "signature": "(columnName: string) => Promise<void>",
1131
+ "parameters": [{
1132
+ "tags": [],
1133
+ "text": ""
1134
+ }],
1135
+ "references": {
1136
+ "Promise": {
1137
+ "location": "global"
1138
+ }
1139
+ },
1140
+ "return": "Promise<void>"
1141
+ },
1142
+ "docs": {
1143
+ "text": "Remove o formatador de valores de uma coluna da grid.",
1144
+ "tags": []
1145
+ }
1146
+ },
1147
+ "refreshSelectedRows": {
1148
+ "complexType": {
1149
+ "signature": "() => Promise<void>",
1150
+ "parameters": [],
1151
+ "references": {
1152
+ "Promise": {
1153
+ "location": "global"
1154
+ }
1155
+ },
1156
+ "return": "Promise<void>"
1157
+ },
1158
+ "docs": {
1159
+ "text": "Atualiza linhas da grade.",
1160
+ "tags": []
1161
+ }
1162
+ },
1163
+ "getCustomValueFormatter": {
1164
+ "complexType": {
1165
+ "signature": "(columnName: string) => Promise<ICustomFormatter | undefined>",
1166
+ "parameters": [{
1167
+ "tags": [],
1168
+ "text": ""
1169
+ }],
1170
+ "references": {
1171
+ "Promise": {
1172
+ "location": "global"
1173
+ },
1174
+ "ICustomFormatter": {
1175
+ "location": "import",
1176
+ "path": "./interfaces"
1177
+ }
1178
+ },
1179
+ "return": "Promise<ICustomFormatter>"
1180
+ },
1181
+ "docs": {
1182
+ "text": "Retorna o formatador customizado da coluna caso exista.",
1183
+ "tags": []
1184
+ }
1185
+ },
1186
+ "setFocus": {
1187
+ "complexType": {
1188
+ "signature": "() => Promise<void>",
1189
+ "parameters": [],
1190
+ "references": {
1191
+ "Promise": {
1192
+ "location": "global"
1193
+ }
1194
+ },
1195
+ "return": "Promise<void>"
1196
+ },
1197
+ "docs": {
1198
+ "text": "Atribui o foco para a grade.",
1199
+ "tags": []
1200
+ }
949
1201
  }
950
1202
  };
951
1203
  }
@@ -1,3 +1,4 @@
1
1
  export * from './ISelection';
2
2
  export * from './ISelectionToastConfig';
3
3
  export * from './IColumnFilter';
4
+ export * from './ICustomFormatter';
@@ -1,8 +1,9 @@
1
1
  import { ElementIDUtils } from "@sankhyalabs/core";
2
2
  import { h } from "@stencil/core";
3
+ import { buildSelectAllLabel, buildSelectAllTitle, enableSelectAll, getText } from './utils/selectionCounterUtils';
3
4
  export const SelectionCounter = (props) => {
4
5
  const { selectionCount, currentPageSelected, allRecordSelected, paginationInfo, canSelectAll, onSelectAll, onSelectPage, onClearAll, onClose } = props;
5
- const { total, hasMore } = paginationInfo || {};
6
+ const { total, hasMore, count } = paginationInfo || {};
6
7
  const shouldRenderSelectionButton = () => {
7
8
  if ((!allRecordSelected && selectionCount === total) || (allRecordSelected && !hasMore))
8
9
  return false;
@@ -11,17 +12,8 @@ export const SelectionCounter = (props) => {
11
12
  return !!paginationInfo && (currentPageSelected || allRecordSelected);
12
13
  };
13
14
  return (h("div", Object.assign({ class: "ez-box ez-box--shadow-small" }, getElementID("ezGridSelectionCounter")), h("div", { class: "ez-flex ez-flex--align-items-center ez-size-width--full ez-padding-horizontal--medium" }, h("div", { class: "ez-flex ez-flex--wrap ez-flex--align-items-baseline ez-flex--justify-center" }, h("label", Object.assign({ innerHTML: getText(selectionCount, allRecordSelected), class: "ez-text ez-text--primary ez-text--medium ez-margin-right--medium ez-margin-top--medium" }, getElementID("ezGridSelectionCounter_label"))), h("div", { class: "ez-flex ez-margin-right--medium" }, shouldRenderSelectionButton() &&
14
- h("ez-button", Object.assign({ class: "ez-margin-right--medium", label: `Selecionar ${allRecordSelected ? "apenas a página atual" : `todos os ${total} registros`}`, mode: "link", onClick: allRecordSelected ? onSelectPage : onSelectAll }, getElementID(`ezGridSelectionCounter_select${allRecordSelected ? "Page" : "All"}`))), h("ez-button", Object.assign({ class: "grid__btn-clear", label: "Limpar", mode: "link", onClick: onClearAll }, getElementID("ezGridSelectionCounter_clearAll"))))), h("button", Object.assign({ class: "grid__btn-close", title: "Fechar", onClick: onClose }, getElementID("ezGridSelectionCounter_close")), h("ez-icon", { iconName: "close" })))));
15
+ h("ez-button", Object.assign({ title: buildSelectAllTitle(total), enabled: enableSelectAll(total), class: "ez-margin-right--medium", label: buildSelectAllLabel(allRecordSelected, count, total), mode: "link", onClick: allRecordSelected ? onSelectPage : onSelectAll }, getElementID(`ezGridSelectionCounter_select${allRecordSelected ? "Page" : "All"}`))), h("ez-button", Object.assign({ class: "grid__btn-clear", label: "Limpar Sele\u00E7\u00E3o", mode: "link", onClick: onClearAll }, getElementID("ezGridSelectionCounter_clearAll"))))), h("button", Object.assign({ class: "grid__btn-close", title: "Fechar", onClick: onClose }, getElementID("ezGridSelectionCounter_close")), h("ez-icon", { iconName: "close" })))));
15
16
  };
16
- function getText(selectionCount, allSelectedRecords) {
17
- if (allSelectedRecords) {
18
- return `Todos os <strong>${selectionCount} registros</strong> da grade estão selecionados.`;
19
- }
20
- else {
21
- const pluralChar = selectionCount > 1 ? "s" : "";
22
- return `Há <strong>${selectionCount} registro${pluralChar}</strong> selecionado${pluralChar}.`;
23
- }
24
- }
25
17
  function getElementID(sufix) {
26
18
  return {
27
19
  [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: ElementIDUtils.getInternalIDInfo(sufix)
@@ -0,0 +1,22 @@
1
+ export function enableSelectAll(total) {
2
+ return total !== undefined;
3
+ }
4
+ export function buildSelectAllLabel(allRecordSelected, count, total) {
5
+ if (allRecordSelected)
6
+ return 'Selecionar apenas a página atual';
7
+ if (total === undefined)
8
+ return `Carregando todos os ${count} registros`;
9
+ return `Selecionar todos os ${total} registros`;
10
+ }
11
+ export function buildSelectAllTitle(total) {
12
+ if (enableSelectAll(total))
13
+ return '';
14
+ return 'Aguarde o carregamento para selecionar o registro de todas as páginas';
15
+ }
16
+ export function getText(selectionCount, allSelectedRecords) {
17
+ if (allSelectedRecords) {
18
+ return `Todos os <strong>${selectionCount} registros</strong> da grade estão selecionados.`;
19
+ }
20
+ const pluralCharacter = selectionCount > 1 ? "s" : "";
21
+ return `Há <strong>${selectionCount} registro${pluralCharacter}</strong> selecionado${pluralCharacter} na grade.`;
22
+ }
@@ -0,0 +1,19 @@
1
+ import { DataType, DataUnit, StringUtils } from "@sankhyalabs/core";
2
+ export function getDataUnit() {
3
+ const dataUnit = new DataUnit('EzGridDU');
4
+ dataUnit.pageSize = 3;
5
+ dataUnit.metadata = {
6
+ name: "exemplo.datagrid",
7
+ label: "Exemplo data grid",
8
+ fields: [
9
+ { name: "PRODUTO", label: "Produto", dataType: DataType.TEXT },
10
+ { name: "QUANTIDADE", label: "Quantidade", dataType: DataType.NUMBER }
11
+ ]
12
+ };
13
+ dataUnit.records = [
14
+ { __record__id__: StringUtils.generateUUID(), "PRODUTO": "Mamão", "QUANTIDADE": 1 },
15
+ { __record__id__: StringUtils.generateUUID(), "PRODUTO": "Mexerica", "QUANTIDADE": 2 }
16
+ ];
17
+ dataUnit.selectFirst();
18
+ return dataUnit;
19
+ }
@@ -168,14 +168,18 @@ p {
168
168
  display: flex;
169
169
 
170
170
  /*public*/
171
- padding: var(--space--2xs, 8px) var(--space--3xs, 4px);
172
- margin: var(--ez-list__item--margin);
173
171
  font-family: var(--ez-list__item--font-family);
174
172
  font-size: var(--ez-list__item--font-size);
175
173
  color: var(--ez-list__item--color);
176
174
  border-bottom: var(--ez-list__item--border-bottom, none) var(--ez-list__item--border-bottom-color);
177
175
  }
178
176
 
177
+ .draggable-list li > div {
178
+ /*public*/
179
+ padding: var(--space--2xs, 8px) var(--space--3xs, 4px);
180
+ margin: var(--ez-list__item--margin);
181
+ }
182
+
179
183
  .over {
180
184
  /*public*/
181
185
  border-top: 1px dashed var(--ez-list__over--border--color);