@sankhyalabs/ezui 5.21.4 → 5.22.0-dev.10

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 (201) hide show
  1. package/dist/cjs/ICustomRender-6fafffce.js +13 -0
  2. package/dist/cjs/ez-actions-button.cjs.entry.js +1 -0
  3. package/dist/cjs/ez-chart.cjs.entry.js +435 -0
  4. package/dist/cjs/ez-collapsible-box.cjs.entry.js +1 -0
  5. package/dist/cjs/ez-combo-box.cjs.entry.js +1 -0
  6. package/dist/cjs/{ez-text-edit.cjs.entry.js → ez-custom-form-input_2.cjs.entry.js} +99 -0
  7. package/dist/cjs/ez-form-view.cjs.entry.js +37 -5
  8. package/dist/cjs/ez-form.cjs.entry.js +81 -2
  9. package/dist/cjs/ez-grid.cjs.entry.js +312 -40
  10. package/dist/cjs/ez-list.cjs.entry.js +10 -2
  11. package/dist/cjs/ez-modal-container.cjs.entry.js +2 -1
  12. package/dist/cjs/ez-modal.cjs.entry.js +7 -1
  13. package/dist/cjs/ez-number-input.cjs.entry.js +37 -31
  14. package/dist/cjs/ez-scroller_2.cjs.entry.js +222 -0
  15. package/dist/cjs/ez-search.cjs.entry.js +40 -33
  16. package/dist/cjs/ez-sidebar-navigator.cjs.entry.js +92 -0
  17. package/dist/cjs/ez-split-item.cjs.entry.js +1 -0
  18. package/dist/cjs/ez-tabselector.cjs.entry.js +8 -2
  19. package/dist/cjs/{ez-scroller_3.cjs.entry.js → ez-tree.cjs.entry.js} +0 -215
  20. package/dist/cjs/ezui.cjs.js +1 -1
  21. package/dist/cjs/index-a7b0c73d.js +16 -4
  22. package/dist/cjs/loader.cjs.js +1 -1
  23. package/dist/collection/collection-manifest.json +3 -0
  24. package/dist/collection/components/ez-chart/components/BarChart.js +27 -0
  25. package/dist/collection/components/ez-chart/components/ColumnChart.js +27 -0
  26. package/dist/collection/components/ez-chart/components/DonutChart.js +42 -0
  27. package/dist/collection/components/ez-chart/components/LineChart.js +27 -0
  28. package/dist/collection/components/ez-chart/components/PieChart.js +45 -0
  29. package/dist/collection/components/ez-chart/components/index.js +5 -0
  30. package/dist/collection/components/ez-chart/ez-chart.css +5 -0
  31. package/dist/collection/components/ez-chart/ez-chart.js +286 -0
  32. package/dist/collection/components/ez-chart/interfaces/ChartAxis.js +1 -0
  33. package/dist/collection/components/ez-chart/interfaces/ChartContext.js +14 -0
  34. package/dist/collection/components/ez-chart/interfaces/ChartOptions.js +1 -0
  35. package/dist/collection/components/ez-chart/interfaces/ChartSerie.js +1 -0
  36. package/dist/collection/components/ez-chart/interfaces/ChartStrategies.js +1 -0
  37. package/dist/collection/components/ez-chart/interfaces/ChartType.js +8 -0
  38. package/dist/collection/components/ez-chart/interfaces/index.js +5 -0
  39. package/dist/collection/components/ez-chart/test/mock-chart.js +137 -0
  40. package/dist/collection/components/ez-chart/types/BaseHighChartsRender.js +146 -0
  41. package/dist/collection/components/ez-form/ez-form.js +130 -4
  42. package/dist/collection/components/ez-form-view/custom-input/ez-custom-form-input.js +278 -0
  43. package/dist/collection/components/ez-form-view/ez-form-view.js +110 -1
  44. package/dist/collection/components/ez-form-view/fieldbuilder/templates/NumberInput.tpl.js +3 -2
  45. package/dist/collection/components/ez-form-view/fieldbuilder/templates/SearchInput.tpl.js +3 -2
  46. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +51 -22
  47. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +6 -1
  48. package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +36 -2
  49. package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.js +59 -0
  50. package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellRender.js +40 -0
  51. package/dist/collection/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellEditorConstants.js +11 -0
  52. package/dist/collection/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellRenderConstants.js +11 -0
  53. package/dist/collection/components/ez-grid/controller/ag-grid/editor/EzCellEditor.js +10 -3
  54. package/dist/collection/components/ez-grid/controller/ag-grid/editor/EzCellRender.js +40 -0
  55. package/dist/collection/components/ez-grid/controller/ag-grid/editor/IUICellRender.js +1 -0
  56. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js +3 -2
  57. package/dist/collection/components/ez-grid/controller/ag-grid/test/constants/GridEditionMock.js +40 -0
  58. package/dist/collection/components/ez-grid/ez-grid.js +235 -12
  59. package/dist/collection/components/ez-grid/interfaces/ICustomFormatter.js +1 -0
  60. package/dist/collection/components/ez-grid/interfaces/index.js +1 -0
  61. package/dist/collection/components/ez-grid/test/resources/gridDataUnit.js +19 -0
  62. package/dist/collection/components/ez-list/ez-list.js +28 -2
  63. package/dist/collection/components/ez-modal/ez-modal.js +25 -1
  64. package/dist/collection/components/ez-modal-container/ez-modal-container.js +20 -1
  65. package/dist/collection/components/ez-number-input/ez-number-input.js +46 -31
  66. package/dist/collection/components/ez-search/ez-search.js +39 -33
  67. package/dist/collection/components/ez-sidebar-button/ez-sidebar-button.css +6 -2
  68. package/dist/collection/components/ez-sidebar-button/ez-sidebar-button.js +1 -1
  69. package/dist/collection/components/ez-sidebar-navigator/ez-sidebar-navigator.css +180 -0
  70. package/dist/collection/components/ez-sidebar-navigator/ez-sidebar-navigator.js +293 -0
  71. package/dist/collection/components/ez-sidebar-navigator/interfaces/ModeMenuEnum.js +5 -0
  72. package/dist/collection/components/ez-sidebar-navigator/interfaces/SizeMenuEnum.js +6 -0
  73. package/dist/collection/components/ez-sidebar-navigator/interfaces/TypeMenuEnum.js +6 -0
  74. package/dist/collection/components/ez-sidebar-navigator/interfaces/index.js +3 -0
  75. package/dist/collection/components/ez-sidebar-navigator/messages/constants.js +5 -0
  76. package/dist/collection/components/ez-tabselector/ez-tabselector.js +34 -2
  77. package/dist/collection/utils/customEditor/interfaces/ICustomEditor.js +5 -0
  78. package/dist/collection/utils/customEditor/interfaces/ICustomEditorInfo.js +1 -0
  79. package/dist/collection/utils/customRender/interfaces/ICustomRender.js +5 -0
  80. package/dist/collection/utils/customRender/interfaces/ICustomRenderInfo.js +1 -0
  81. package/dist/collection/utils/form/DataBinder.js +31 -1
  82. package/dist/collection/utils/form/test/DataBinder.test.js +41 -4
  83. package/dist/collection/utils/form/test/resources/metadataTest.js +15 -0
  84. package/dist/collection/utils/index.js +2 -0
  85. package/dist/custom-elements/index.d.ts +18 -0
  86. package/dist/custom-elements/index.js +1173 -127
  87. package/dist/esm/ICustomRender-875b5a40.js +13 -0
  88. package/dist/esm/ez-actions-button.entry.js +1 -0
  89. package/dist/esm/ez-chart.entry.js +431 -0
  90. package/dist/esm/ez-collapsible-box.entry.js +1 -0
  91. package/dist/esm/ez-combo-box.entry.js +1 -0
  92. package/dist/esm/{ez-text-edit.entry.js → ez-custom-form-input_2.entry.js} +101 -3
  93. package/dist/esm/ez-form-view.entry.js +37 -5
  94. package/dist/esm/ez-form.entry.js +82 -3
  95. package/dist/esm/ez-grid.entry.js +312 -40
  96. package/dist/esm/ez-list.entry.js +10 -2
  97. package/dist/esm/ez-modal-container.entry.js +2 -1
  98. package/dist/esm/ez-modal.entry.js +7 -1
  99. package/dist/esm/ez-number-input.entry.js +38 -32
  100. package/dist/esm/ez-scroller_2.entry.js +217 -0
  101. package/dist/esm/ez-search.entry.js +40 -33
  102. package/dist/esm/ez-sidebar-navigator.entry.js +88 -0
  103. package/dist/esm/ez-split-item.entry.js +1 -0
  104. package/dist/esm/ez-tabselector.entry.js +8 -2
  105. package/dist/esm/{ez-scroller_3.entry.js → ez-tree.entry.js} +3 -216
  106. package/dist/esm/ezui.js +1 -1
  107. package/dist/esm/index-baa5e267.js +16 -4
  108. package/dist/esm/loader.js +1 -1
  109. package/dist/ezui/ezui.esm.js +1 -1
  110. package/dist/ezui/p-2097d0cf.entry.js +1 -0
  111. package/dist/ezui/{p-9fbb0f01.entry.js → p-32e553e5.entry.js} +2 -2
  112. package/dist/ezui/p-34b6916c.entry.js +1 -0
  113. package/dist/ezui/p-3b4eeeb6.entry.js +1 -0
  114. package/dist/ezui/p-42533ea4.entry.js +1 -0
  115. package/dist/ezui/p-4607fb89.js +1 -0
  116. package/dist/ezui/p-4d5235f1.entry.js +1 -0
  117. package/dist/ezui/p-5b205c80.entry.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-8888d9ed.entry.js +1 -0
  121. package/dist/ezui/p-922ac38b.entry.js +1 -0
  122. package/dist/ezui/p-a31b9c90.entry.js +1 -0
  123. package/dist/ezui/p-aba3da00.entry.js +1 -0
  124. package/dist/ezui/p-bcb53f27.entry.js +1 -0
  125. package/dist/ezui/p-c0d9c4f8.entry.js +1 -0
  126. package/dist/ezui/p-cdc472cc.entry.js +1 -0
  127. package/dist/ezui/p-ecc2c1ec.entry.js +1 -0
  128. package/dist/ezui/p-fcf0acce.entry.js +1 -0
  129. package/dist/types/components/ez-chart/components/BarChart.d.ts +9 -0
  130. package/dist/types/components/ez-chart/components/ColumnChart.d.ts +9 -0
  131. package/dist/types/components/ez-chart/components/DonutChart.d.ts +9 -0
  132. package/dist/types/components/ez-chart/components/LineChart.d.ts +9 -0
  133. package/dist/types/components/ez-chart/components/PieChart.d.ts +9 -0
  134. package/dist/types/components/ez-chart/components/index.d.ts +5 -0
  135. package/dist/types/components/ez-chart/ez-chart.d.ts +58 -0
  136. package/dist/types/components/ez-chart/interfaces/ChartAxis.d.ts +7 -0
  137. package/dist/types/components/ez-chart/interfaces/ChartContext.d.ts +11 -0
  138. package/dist/types/components/ez-chart/interfaces/ChartOptions.d.ts +10 -0
  139. package/dist/types/components/ez-chart/interfaces/ChartSerie.d.ts +20 -0
  140. package/dist/types/components/ez-chart/interfaces/ChartStrategies.d.ts +7 -0
  141. package/dist/types/components/ez-chart/interfaces/ChartType.d.ts +7 -0
  142. package/dist/types/components/ez-chart/interfaces/index.d.ts +5 -0
  143. package/dist/types/components/ez-chart/types/BaseHighChartsRender.d.ts +15 -0
  144. package/dist/types/components/ez-form/ez-form.d.ts +20 -1
  145. package/dist/types/components/ez-form-view/custom-input/ez-custom-form-input.d.ts +48 -0
  146. package/dist/types/components/ez-form-view/ez-form-view.d.ts +16 -1
  147. package/dist/types/components/ez-form-view/fieldbuilder/templates/SearchInput.tpl.d.ts +1 -1
  148. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +37 -0
  149. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +13 -4
  150. package/dist/types/components/ez-grid/controller/ag-grid/DataSource.d.ts +1 -0
  151. package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +7 -1
  152. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.d.ts +19 -0
  153. package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellRender.d.ts +14 -0
  154. package/dist/types/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellEditorConstants.d.ts +11 -0
  155. package/dist/types/components/ez-grid/controller/ag-grid/components/test/constants/EzGridCustomCellRenderConstants.d.ts +11 -0
  156. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellEditor.d.ts +6 -0
  157. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellRender.d.ts +15 -0
  158. package/dist/types/components/ez-grid/controller/ag-grid/editor/IUICellRender.d.ts +10 -0
  159. package/dist/types/components/ez-grid/controller/ag-grid/test/constants/GridEditionMock.d.ts +6 -0
  160. package/dist/types/components/ez-grid/ez-grid.d.ts +34 -1
  161. package/dist/types/components/ez-grid/interfaces/ICustomFormatter.d.ts +5 -0
  162. package/dist/types/components/ez-grid/interfaces/index.d.ts +1 -0
  163. package/dist/types/components/ez-grid/test/resources/gridDataUnit.d.ts +2 -0
  164. package/dist/types/components/ez-list/ez-list.d.ts +5 -0
  165. package/dist/types/components/ez-modal/ez-modal.d.ts +5 -0
  166. package/dist/types/components/ez-modal-container/ez-modal-container.d.ts +4 -0
  167. package/dist/types/components/ez-number-input/ez-number-input.d.ts +3 -0
  168. package/dist/types/components/ez-search/ez-search.d.ts +4 -2
  169. package/dist/types/components/ez-sidebar-navigator/ez-sidebar-navigator.d.ts +57 -0
  170. package/dist/types/components/ez-sidebar-navigator/interfaces/ModeMenuEnum.d.ts +4 -0
  171. package/dist/types/components/ez-sidebar-navigator/interfaces/SizeMenuEnum.d.ts +5 -0
  172. package/dist/types/components/ez-sidebar-navigator/interfaces/TypeMenuEnum.d.ts +5 -0
  173. package/dist/types/components/ez-sidebar-navigator/interfaces/index.d.ts +3 -0
  174. package/dist/types/components/ez-sidebar-navigator/messages/constants.d.ts +5 -0
  175. package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +2 -1
  176. package/dist/types/components.d.ts +351 -5
  177. package/dist/types/utils/customEditor/interfaces/ICustomEditor.d.ts +31 -0
  178. package/dist/types/utils/customEditor/interfaces/ICustomEditorInfo.d.ts +5 -0
  179. package/dist/types/utils/customRender/interfaces/ICustomRender.d.ts +29 -0
  180. package/dist/types/utils/customRender/interfaces/ICustomRenderInfo.d.ts +5 -0
  181. package/dist/types/utils/form/DataBinder.d.ts +5 -0
  182. package/dist/types/utils/form/test/resources/metadataTest.d.ts +2 -0
  183. package/dist/types/utils/index.d.ts +2 -0
  184. package/package.json +2 -1
  185. package/react/components.d.ts +3 -0
  186. package/react/components.js +3 -0
  187. package/react/components.js.map +1 -1
  188. package/dist/ezui/p-0447d17c.entry.js +0 -1
  189. package/dist/ezui/p-20ec22c0.entry.js +0 -1
  190. package/dist/ezui/p-2a1a0e04.entry.js +0 -1
  191. package/dist/ezui/p-2dcb50d4.entry.js +0 -1
  192. package/dist/ezui/p-30775e7f.entry.js +0 -1
  193. package/dist/ezui/p-41ac6cd9.entry.js +0 -1
  194. package/dist/ezui/p-637f69f2.entry.js +0 -1
  195. package/dist/ezui/p-786559c5.entry.js +0 -1
  196. package/dist/ezui/p-91f626d3.entry.js +0 -1
  197. package/dist/ezui/p-99ead599.entry.js +0 -1
  198. package/dist/ezui/p-b567fa8c.entry.js +0 -1
  199. package/dist/ezui/p-bae3d0aa.entry.js +0 -1
  200. package/dist/ezui/p-db77a984.entry.js +0 -1
  201. package/dist/ezui/p-f3c526cc.entry.js +0 -1
@@ -0,0 +1,146 @@
1
+ export class BaseHighChartsRender {
2
+ parseSerie(series) {
3
+ if (Array.isArray(series)) {
4
+ const seriesOptions = series.map(serie => this.chartSerieToSeriesOptions(serie));
5
+ return seriesOptions;
6
+ }
7
+ const seriesOptions = this.chartSerieToSeriesOptions(series);
8
+ return [seriesOptions];
9
+ }
10
+ parseAxis(axis) {
11
+ if (Array.isArray(axis)) {
12
+ const axisOptions = axis.map(value => this.chartAxisToAxisOptions(value));
13
+ return axisOptions;
14
+ }
15
+ const axisOptions = this.chartAxisToAxisOptions(axis);
16
+ return axisOptions;
17
+ }
18
+ parseTitle(title) {
19
+ return {
20
+ text: title,
21
+ };
22
+ }
23
+ parseSubTitle(subTtile) {
24
+ return {
25
+ text: subTtile,
26
+ };
27
+ }
28
+ buildFormatterTooltip(series) {
29
+ const seriesArray = Array.isArray(series) ? series : [series];
30
+ return {
31
+ formatter: function (tooltip) {
32
+ const indexSerie = seriesArray.findIndex(serie => serie.name === this.series.name && serie.toolTipFormatter);
33
+ if (indexSerie !== -1) {
34
+ return seriesArray[indexSerie].toolTipFormatter(this.series.name, this.x, this.y, this.point.name, this.point.percentage);
35
+ }
36
+ return tooltip.defaultFormatter.call(this, tooltip);
37
+ }
38
+ };
39
+ }
40
+ buildOnClickCallBack(evt) {
41
+ return function (_e) {
42
+ evt.emit({
43
+ name: this.series.name,
44
+ data: this.series.data,
45
+ type: this.series.type,
46
+ yAxis: this.x,
47
+ });
48
+ };
49
+ }
50
+ buildResposiveConfig() {
51
+ return {
52
+ rules: [
53
+ {
54
+ condition: {
55
+ maxWidth: 500
56
+ },
57
+ chartOptions: {
58
+ legend: {
59
+ enabled: false
60
+ },
61
+ xAxis: {
62
+ labels: {
63
+ enabled: false
64
+ },
65
+ gridLineWidth: 0
66
+ },
67
+ yAxis: {
68
+ labels: {
69
+ enabled: false
70
+ },
71
+ gridLineWidth: 0
72
+ }
73
+ }
74
+ },
75
+ {
76
+ condition: {
77
+ maxWidth: 600
78
+ },
79
+ chartOptions: {
80
+ xAxis: {
81
+ labels: {
82
+ style: {
83
+ fontSize: '10px'
84
+ }
85
+ }
86
+ },
87
+ yAxis: {
88
+ labels: {
89
+ style: {
90
+ fontSize: '10px'
91
+ },
92
+ }
93
+ },
94
+ title: {
95
+ style: {
96
+ fontSize: '14px'
97
+ }
98
+ },
99
+ subtitle: {
100
+ style: {
101
+ fontSize: '12px'
102
+ }
103
+ }
104
+ }
105
+ },
106
+ {
107
+ condition: {
108
+ maxWidth: 400
109
+ },
110
+ chartOptions: {
111
+ chart: {
112
+ margin: [10, 10, 15, 10],
113
+ },
114
+ subtitle: {
115
+ text: null
116
+ },
117
+ title: {
118
+ text: null
119
+ }
120
+ }
121
+ }
122
+ ]
123
+ };
124
+ }
125
+ buildDefaultChartOptions() {
126
+ return {
127
+ credits: {
128
+ enabled: false
129
+ }
130
+ };
131
+ }
132
+ chartSerieToSeriesOptions(serie) {
133
+ const { name, data, color, showDataLabel, type, yAxis } = serie;
134
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (name && { name })), (type && { type })), (data && { data })), (color && { color })), (showDataLabel && { dataLabels: { enabled: showDataLabel } })), (yAxis !== undefined && { yAxis }));
135
+ }
136
+ chartAxisToAxisOptions(axis) {
137
+ const { categories, color, text, invertedPosition, formatter } = axis;
138
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, (categories && { categories })), (text && {
139
+ title: Object.assign({ text }, (color && { style: { color } }))
140
+ })), (formatter && {
141
+ labels: {
142
+ formatter: function () { return formatter(this.value); },
143
+ }
144
+ })), (invertedPosition && { opposite: invertedPosition }));
145
+ }
146
+ }
@@ -1,20 +1,23 @@
1
1
  import { Action, DataUnit, ElementIDUtils, StringUtils } from "@sankhyalabs/core";
2
2
  import { Host, forceUpdate, h } from "@stencil/core";
3
3
  import { createStore } from "redux";
4
- import { changeTab, formReducer, loadMetadata, selectCurrentSheet, selectFormMetadata } from "./store/form.slice";
5
- import { buildFormMetadata } from "../../utils/form/FormMetadata";
6
4
  import DataBinder from "../../utils/form/DataBinder";
5
+ import { buildFormMetadata } from "../../utils/form/FormMetadata";
6
+ import { changeTab, formReducer, loadMetadata, selectCurrentSheet, selectFormMetadata } from "./store/form.slice";
7
7
  export class EzForm {
8
8
  constructor() {
9
+ this._customEditors = new Map();
9
10
  this.onDataUnitAction = (action) => {
10
11
  if (action.type === Action.METADATA_LOADED) {
11
12
  this.processMetadata();
12
13
  }
13
14
  };
15
+ this._fieldsProps = new Map();
14
16
  this.dataUnit = undefined;
15
17
  this.config = undefined;
16
18
  this.recordsValidator = undefined;
17
19
  this.fieldToFocus = undefined;
20
+ this.onlyStaticFields = false;
18
21
  }
19
22
  /**
20
23
  * Realiza validação no conteúdo de todos os campos.
@@ -22,9 +25,30 @@ export class EzForm {
22
25
  validate() {
23
26
  return this._dataBinder.validate();
24
27
  }
28
+ /**
29
+ * Registra um editor customizado para campos da grade e formulário.
30
+ */
31
+ async addCustomEditor(fieldName, customEditor, detailContext) {
32
+ if (this._formView) {
33
+ this._formView.addCustomEditor(fieldName, customEditor, detailContext);
34
+ return;
35
+ }
36
+ const newCustomEditors = new Map(this._customEditors);
37
+ newCustomEditors.set(fieldName, { customEditor, detailContext });
38
+ this._customEditors = newCustomEditors;
39
+ }
25
40
  observeConfig() {
26
41
  this.processMetadata();
27
42
  }
43
+ /**
44
+ * Altera/adiciona uma propriedade nos metadados do campo.
45
+ */
46
+ async setFieldProp(fieldName, propName, value) {
47
+ const newCustomFieldProps = new Map(this._fieldsProps);
48
+ const currentProps = this._fieldsProps.get(fieldName);
49
+ newCustomFieldProps.set(fieldName, Object.assign(Object.assign({}, currentProps), { [propName]: value }));
50
+ this._fieldsProps = newCustomFieldProps;
51
+ }
28
52
  getDynamicContent() {
29
53
  var _a;
30
54
  const formMD = selectFormMetadata(this._store.getState());
@@ -51,10 +75,10 @@ export class EzForm {
51
75
  }
52
76
  this.ezFormSetFields.emit(fields);
53
77
  const idFormSheet = `${StringUtils.replaceAccentuatedChars(StringUtils.toCamelCase(currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.label), false)}_selectorContainer`;
54
- return (h("div", { class: "dynamic-content", "data-element-id": idFormSheet }, h("ez-form-view", { class: "ez-row ez-padding-vertical--small", fields: fields })));
78
+ return (h("div", { class: "dynamic-content", "data-element-id": idFormSheet }, h("ez-form-view", { ref: (element) => (this._formView = element), class: "ez-row ez-padding-vertical--small", fields: fields, selectedRecord: this.dataUnit.getSelectedRecord() })));
55
79
  }
56
80
  processMetadata() {
57
- if (!this.isStatic() && this.dataUnit && this._store) {
81
+ if (this.bindFields() && this.dataUnit && this._store) {
58
82
  const metadata = buildFormMetadata(this.config, this.dataUnit);
59
83
  this._store.dispatch(loadMetadata(metadata));
60
84
  }
@@ -63,6 +87,9 @@ export class EzForm {
63
87
  var _a;
64
88
  return ((_a = this._staticFields) === null || _a === void 0 ? void 0 : _a.length) > 0;
65
89
  }
90
+ bindFields() {
91
+ return !this.isStatic() || this.onlyStaticFields === false;
92
+ }
66
93
  componentWillLoad() {
67
94
  if (this.dataUnit === undefined) {
68
95
  this.dataUnit = new DataUnit("ez-form");
@@ -82,6 +109,17 @@ export class EzForm {
82
109
  this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]")), this.dataUnit.dataUnitId, metadata, this.recordsValidator);
83
110
  this.ezReady.emit();
84
111
  this.handleFieldToFocus();
112
+ this.setCustomEditors();
113
+ this.setFieldsProps();
114
+ }
115
+ setCustomEditors() {
116
+ if (!this._formView) {
117
+ return;
118
+ }
119
+ for (const [fieldName, customEditorProps] of this._customEditors) {
120
+ this._formView.addCustomEditor(fieldName, customEditorProps.customEditor, customEditorProps.detailContext);
121
+ this._customEditors.delete(fieldName);
122
+ }
85
123
  }
86
124
  handleFieldToFocus() {
87
125
  var _a;
@@ -98,6 +136,17 @@ export class EzForm {
98
136
  this.ezFormRequestClearFieldToFocus.emit();
99
137
  });
100
138
  }
139
+ setFieldsProps() {
140
+ if (!this._formView) {
141
+ return;
142
+ }
143
+ for (const [fieldName, props] of this._fieldsProps) {
144
+ for (const prop in props) {
145
+ this._formView.setFieldProp(fieldName, prop, props[prop]);
146
+ }
147
+ this._fieldsProps.delete(fieldName);
148
+ }
149
+ }
101
150
  disconnectedCallback() {
102
151
  this.dataUnit.unsubscribe(this.onDataUnitAction);
103
152
  this._dataBinder.onDisconnectedCallback();
@@ -201,9 +250,32 @@ export class EzForm {
201
250
  },
202
251
  "attribute": "field-to-focus",
203
252
  "reflect": false
253
+ },
254
+ "onlyStaticFields": {
255
+ "type": "boolean",
256
+ "mutable": false,
257
+ "complexType": {
258
+ "original": "boolean",
259
+ "resolved": "boolean",
260
+ "references": {}
261
+ },
262
+ "required": false,
263
+ "optional": false,
264
+ "docs": {
265
+ "tags": [],
266
+ "text": "Define se os campos que ser\u00E3o apresentados s\u00E3o todos est\u00E1ticos. Quando verdadeira, ocorrer\u00E1 no DataBinder o bind dos campos com o DataUnit."
267
+ },
268
+ "attribute": "only-static-fields",
269
+ "reflect": false,
270
+ "defaultValue": "false"
204
271
  }
205
272
  };
206
273
  }
274
+ static get states() {
275
+ return {
276
+ "_fieldsProps": {}
277
+ };
278
+ }
207
279
  static get events() {
208
280
  return [{
209
281
  "method": "ezFormRequestClearFieldToFocus",
@@ -297,6 +369,60 @@ export class EzForm {
297
369
  "text": "Realiza valida\u00E7\u00E3o no conte\u00FAdo de todos os campos.",
298
370
  "tags": []
299
371
  }
372
+ },
373
+ "addCustomEditor": {
374
+ "complexType": {
375
+ "signature": "(fieldName: string, customEditor: ICustomEditor, detailContext?: string) => Promise<void>",
376
+ "parameters": [{
377
+ "tags": [],
378
+ "text": ""
379
+ }, {
380
+ "tags": [],
381
+ "text": ""
382
+ }, {
383
+ "tags": [],
384
+ "text": ""
385
+ }],
386
+ "references": {
387
+ "Promise": {
388
+ "location": "global"
389
+ },
390
+ "ICustomEditor": {
391
+ "location": "import",
392
+ "path": "../../utils/customEditor/interfaces/ICustomEditor"
393
+ }
394
+ },
395
+ "return": "Promise<void>"
396
+ },
397
+ "docs": {
398
+ "text": "Registra um editor customizado para campos da grade e formul\u00E1rio.",
399
+ "tags": []
400
+ }
401
+ },
402
+ "setFieldProp": {
403
+ "complexType": {
404
+ "signature": "(fieldName: string, propName: string, value: any) => Promise<void>",
405
+ "parameters": [{
406
+ "tags": [],
407
+ "text": ""
408
+ }, {
409
+ "tags": [],
410
+ "text": ""
411
+ }, {
412
+ "tags": [],
413
+ "text": ""
414
+ }],
415
+ "references": {
416
+ "Promise": {
417
+ "location": "global"
418
+ }
419
+ },
420
+ "return": "Promise<void>"
421
+ },
422
+ "docs": {
423
+ "text": "Altera/adiciona uma propriedade nos metadados do campo.",
424
+ "tags": []
425
+ }
300
426
  }
301
427
  };
302
428
  }
@@ -0,0 +1,278 @@
1
+ import { h, Host } from '@stencil/core';
2
+ import { CustomEditorSource } from '../../../utils/customEditor/interfaces/ICustomEditor';
3
+ import { HTMLBuilder, StringUtils } from '@sankhyalabs/core';
4
+ export class EzCustomFormInput {
5
+ constructor() {
6
+ this.gui = undefined;
7
+ this.customEditor = undefined;
8
+ this.formViewField = undefined;
9
+ this.value = undefined;
10
+ this.detailContext = undefined;
11
+ this.builderFallback = undefined;
12
+ this.selectedRecord = undefined;
13
+ }
14
+ /**
15
+ * Aplica foco no campo.
16
+ */
17
+ async setFocus() {
18
+ var _a, _b;
19
+ (_b = (_a = this.gui) === null || _a === void 0 ? void 0 : _a["setFocus"]) === null || _b === void 0 ? void 0 : _b.call(_a);
20
+ }
21
+ /**
22
+ * Remove o foco do campo.
23
+ */
24
+ async setBlur() {
25
+ var _a, _b;
26
+ (_b = (_a = this.gui) === null || _a === void 0 ? void 0 : _a["setBlur"]) === null || _b === void 0 ? void 0 : _b.call(_a);
27
+ }
28
+ /**
29
+ * Retorna se o conteúdo é inválido.
30
+ */
31
+ async isInvalid() {
32
+ var _a, _b;
33
+ return ((_b = (_a = this.gui) === null || _a === void 0 ? void 0 : _a["isInvalid"]) === null || _b === void 0 ? void 0 : _b.call(_a)) || false;
34
+ }
35
+ getContent() {
36
+ var _a, _b;
37
+ const fieldProps = new Map();
38
+ for (const prop in this.formViewField.props) {
39
+ fieldProps.set(prop, this.formViewField.props[prop]);
40
+ }
41
+ const params = {
42
+ value: this.value,
43
+ name: this.formViewField.name,
44
+ currentEditor: this.builderFallback(this.formViewField),
45
+ setValue: (value) => this.setValue(value),
46
+ getValue: this.getValue,
47
+ record: this.selectedRecord,
48
+ editorMetadata: {
49
+ label: this.formViewField.label,
50
+ hidden: ((_a = this.formViewField.props) === null || _a === void 0 ? void 0 : _a.visible) === false,
51
+ userInterface: this.formViewField.userInterface,
52
+ options: (_b = this.formViewField.props) === null || _b === void 0 ? void 0 : _b.options,
53
+ props: this.formViewField.props ? fieldProps : undefined,
54
+ optionLoader: this.formViewField.optionLoader
55
+ },
56
+ source: CustomEditorSource.FORM,
57
+ detailContext: this.detailContext
58
+ };
59
+ let gui = this.customEditor.getEditorElement(params);
60
+ if (!gui) {
61
+ gui = this.builderFallback(this.formViewField);
62
+ this.handleValue(gui);
63
+ this.gui = gui;
64
+ return;
65
+ }
66
+ if (!(gui instanceof HTMLElement) && typeof gui !== 'string') {
67
+ this.handleValue(gui);
68
+ this.gui = gui;
69
+ return;
70
+ }
71
+ if (typeof gui === 'string') {
72
+ gui = HTMLBuilder.parseElement(gui);
73
+ }
74
+ if (this.value) {
75
+ gui.setAttribute('value', typeof this.value === 'object' ? this.value.value : this.value);
76
+ }
77
+ this.gui = h("div", { key: StringUtils.generateUUID(), ref: el => el && el.appendChild(gui) });
78
+ }
79
+ setValue(value) {
80
+ this.value = value;
81
+ }
82
+ getValue() {
83
+ return this.value;
84
+ }
85
+ handleValue(gui) {
86
+ var _a;
87
+ //@ts-ignore
88
+ (_a = gui.$children$) === null || _a === void 0 ? void 0 : _a.forEach((child) => {
89
+ child.$attrs$.value = this.value;
90
+ });
91
+ }
92
+ componentWillRender() {
93
+ this.getContent();
94
+ }
95
+ render() {
96
+ return (h(Host, null, this.gui));
97
+ }
98
+ static get is() { return "ez-custom-form-input"; }
99
+ static get encapsulation() { return "scoped"; }
100
+ static get properties() {
101
+ return {
102
+ "customEditor": {
103
+ "type": "unknown",
104
+ "mutable": false,
105
+ "complexType": {
106
+ "original": "ICustomEditor",
107
+ "resolved": "ICustomEditor",
108
+ "references": {
109
+ "ICustomEditor": {
110
+ "location": "import",
111
+ "path": "../../../utils/customEditor/interfaces/ICustomEditor"
112
+ }
113
+ }
114
+ },
115
+ "required": false,
116
+ "optional": false,
117
+ "docs": {
118
+ "tags": [],
119
+ "text": "Inst\u00E2ncia do editor customizado."
120
+ }
121
+ },
122
+ "formViewField": {
123
+ "type": "unknown",
124
+ "mutable": false,
125
+ "complexType": {
126
+ "original": "IFormViewField",
127
+ "resolved": "IFormViewField",
128
+ "references": {
129
+ "IFormViewField": {
130
+ "location": "import",
131
+ "path": "../interfaces"
132
+ }
133
+ }
134
+ },
135
+ "required": false,
136
+ "optional": false,
137
+ "docs": {
138
+ "tags": [],
139
+ "text": "Campo que o elemento customizado representa."
140
+ }
141
+ },
142
+ "value": {
143
+ "type": "any",
144
+ "mutable": true,
145
+ "complexType": {
146
+ "original": "any",
147
+ "resolved": "any",
148
+ "references": {}
149
+ },
150
+ "required": false,
151
+ "optional": false,
152
+ "docs": {
153
+ "tags": [],
154
+ "text": "Valores dos campos do formul\u00E1rio."
155
+ },
156
+ "attribute": "value",
157
+ "reflect": false
158
+ },
159
+ "detailContext": {
160
+ "type": "string",
161
+ "mutable": false,
162
+ "complexType": {
163
+ "original": "string",
164
+ "resolved": "string",
165
+ "references": {}
166
+ },
167
+ "required": false,
168
+ "optional": false,
169
+ "docs": {
170
+ "tags": [],
171
+ "text": "Define de qual contexto o editor est\u00E1 sendo acionado."
172
+ },
173
+ "attribute": "detail-context",
174
+ "reflect": false
175
+ },
176
+ "builderFallback": {
177
+ "type": "unknown",
178
+ "mutable": false,
179
+ "complexType": {
180
+ "original": "(field: IFormViewField) => HTMLElement",
181
+ "resolved": "(field: IFormViewField) => HTMLElement",
182
+ "references": {
183
+ "IFormViewField": {
184
+ "location": "import",
185
+ "path": "../interfaces"
186
+ },
187
+ "HTMLElement": {
188
+ "location": "global"
189
+ }
190
+ }
191
+ },
192
+ "required": false,
193
+ "optional": false,
194
+ "docs": {
195
+ "tags": [],
196
+ "text": "Builder original do FormView que ser\u00E1 chamado caso o custom n\u00E3o retorne nenhum valor."
197
+ }
198
+ },
199
+ "selectedRecord": {
200
+ "type": "unknown",
201
+ "mutable": false,
202
+ "complexType": {
203
+ "original": "Record",
204
+ "resolved": "Record",
205
+ "references": {
206
+ "Record": {
207
+ "location": "import",
208
+ "path": "@sankhyalabs/core"
209
+ }
210
+ }
211
+ },
212
+ "required": false,
213
+ "optional": false,
214
+ "docs": {
215
+ "tags": [],
216
+ "text": "Define os registros da linha selecionada."
217
+ }
218
+ }
219
+ };
220
+ }
221
+ static get states() {
222
+ return {
223
+ "gui": {}
224
+ };
225
+ }
226
+ static get methods() {
227
+ return {
228
+ "setFocus": {
229
+ "complexType": {
230
+ "signature": "() => Promise<void>",
231
+ "parameters": [],
232
+ "references": {
233
+ "Promise": {
234
+ "location": "global"
235
+ }
236
+ },
237
+ "return": "Promise<void>"
238
+ },
239
+ "docs": {
240
+ "text": "Aplica foco no campo.",
241
+ "tags": []
242
+ }
243
+ },
244
+ "setBlur": {
245
+ "complexType": {
246
+ "signature": "() => Promise<void>",
247
+ "parameters": [],
248
+ "references": {
249
+ "Promise": {
250
+ "location": "global"
251
+ }
252
+ },
253
+ "return": "Promise<void>"
254
+ },
255
+ "docs": {
256
+ "text": "Remove o foco do campo.",
257
+ "tags": []
258
+ }
259
+ },
260
+ "isInvalid": {
261
+ "complexType": {
262
+ "signature": "() => Promise<boolean>",
263
+ "parameters": [],
264
+ "references": {
265
+ "Promise": {
266
+ "location": "global"
267
+ }
268
+ },
269
+ "return": "Promise<boolean>"
270
+ },
271
+ "docs": {
272
+ "text": "Retorna se o conte\u00FAdo \u00E9 inv\u00E1lido.",
273
+ "tags": []
274
+ }
275
+ }
276
+ };
277
+ }
278
+ }