@sankhyalabs/ezui 1.1.142 → 1.1.145

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 (52) hide show
  1. package/dist/cjs/ez-button.cjs.entry.js +1 -1
  2. package/dist/cjs/ez-card-item.cjs.entry.js +44 -0
  3. package/dist/cjs/ez-collapsible-box.cjs.entry.js +3 -2
  4. package/dist/cjs/ez-combo-box.cjs.entry.js +41 -20
  5. package/dist/cjs/ez-form.cjs.entry.js +21 -13
  6. package/dist/cjs/ez-grid.cjs.entry.js +2 -0
  7. package/dist/cjs/ez-upload.cjs.entry.js +3 -3
  8. package/dist/cjs/ezui.cjs.js +1 -1
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/collection/collection-manifest.json +1 -0
  11. package/dist/collection/components/ez-button/ez-button.css +6 -0
  12. package/dist/collection/components/ez-card-item/ez-card-item.css +115 -0
  13. package/dist/collection/components/ez-card-item/ez-card-item.js +86 -0
  14. package/dist/collection/components/ez-collapsible-box/ez-collapsible-box.css +4 -0
  15. package/dist/collection/components/ez-collapsible-box/ez-collapsible-box.js +2 -1
  16. package/dist/collection/components/ez-combo-box/ez-combo-box.js +43 -21
  17. package/dist/collection/components/ez-form/ez-form.js +14 -6
  18. package/dist/collection/components/ez-form/structure/FormSheetMetadata.js +7 -7
  19. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +2 -0
  20. package/dist/collection/components/ez-upload/ez-upload.js +3 -3
  21. package/dist/custom-elements/index.d.ts +6 -0
  22. package/dist/custom-elements/index.js +114 -41
  23. package/dist/esm/ez-button.entry.js +1 -1
  24. package/dist/esm/ez-card-item.entry.js +40 -0
  25. package/dist/esm/ez-collapsible-box.entry.js +3 -2
  26. package/dist/esm/ez-combo-box.entry.js +41 -20
  27. package/dist/esm/ez-form.entry.js +21 -13
  28. package/dist/esm/ez-grid.entry.js +2 -0
  29. package/dist/esm/ez-upload.entry.js +3 -3
  30. package/dist/esm/ezui.js +1 -1
  31. package/dist/esm/loader.js +1 -1
  32. package/dist/ezui/ezui.esm.js +1 -1
  33. package/dist/ezui/p-024df41e.entry.js +1 -0
  34. package/dist/ezui/p-23369322.entry.js +1 -0
  35. package/dist/ezui/p-5a05f1ea.entry.js +1 -0
  36. package/dist/ezui/p-6395ed55.entry.js +1 -0
  37. package/dist/ezui/{p-1b2bf15d.entry.js → p-6816c9ee.entry.js} +1 -1
  38. package/dist/ezui/{p-8cb2c629.entry.js → p-c15d4d6f.entry.js} +1 -1
  39. package/dist/ezui/p-c77c0022.entry.js +1 -0
  40. package/dist/types/components/ez-card-item/ez-card-item.d.ts +23 -0
  41. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +5 -1
  42. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +1 -0
  43. package/dist/types/components/ez-upload/ez-upload.d.ts +1 -1
  44. package/dist/types/components.d.ts +17 -0
  45. package/package.json +2 -2
  46. package/react/components.d.ts +1 -0
  47. package/react/components.js +1 -0
  48. package/react/components.js.map +1 -1
  49. package/dist/ezui/p-7746460e.entry.js +0 -1
  50. package/dist/ezui/p-87808290.entry.js +0 -1
  51. package/dist/ezui/p-cabe3671.entry.js +0 -1
  52. package/dist/ezui/p-dd6f4872.entry.js +0 -1
@@ -0,0 +1,86 @@
1
+ import { Component, Event, h, Host, Prop } from '@stencil/core';
2
+ export class EzCardItem {
3
+ componentWillRender() {
4
+ this.createDetailList();
5
+ }
6
+ createDetailList() {
7
+ var _a, _b, _c;
8
+ this._details = { detailsLeft: [], detailsRight: [] };
9
+ let cont = 0;
10
+ if ((_a = this.item) === null || _a === void 0 ? void 0 : _a.details) {
11
+ for (const attribute in this.item.details) {
12
+ cont < 3 ?
13
+ this._details.detailsLeft.push({ label: attribute, value: (_b = this.item.details[attribute]) === null || _b === void 0 ? void 0 : _b.toString() }) :
14
+ this._details.detailsRight.push({ label: attribute, value: (_c = this.item.details[attribute]) === null || _c === void 0 ? void 0 : _c.toString() });
15
+ cont++;
16
+ }
17
+ }
18
+ }
19
+ buildDetailContent(detail) {
20
+ return h("div", { class: "card-item__detail" },
21
+ h("label", { class: "card-item__detail-label" }, detail.label),
22
+ ": ",
23
+ h("label", { class: "card-item__detail-value", innerHTML: detail.value }));
24
+ }
25
+ render() {
26
+ return (h(Host, null, this.item &&
27
+ h("div", { class: "card-item", onClick: () => { this.ezClick.emit(this.item); } },
28
+ h("label", { class: "card-item__title", innerHTML: this.item.key + ' - ' + this.item.title }),
29
+ h("div", { class: "card-item__details" },
30
+ h("div", { class: "card-item__details-left" }, this._details.detailsLeft.map(detail => {
31
+ return this.buildDetailContent(detail);
32
+ })),
33
+ h("div", { class: "card-item__details-right" }, this._details.detailsRight.map(detail => {
34
+ return this.buildDetailContent(detail);
35
+ }))))));
36
+ }
37
+ static get is() { return "ez-card-item"; }
38
+ static get encapsulation() { return "shadow"; }
39
+ static get originalStyleUrls() { return {
40
+ "$": ["ez-card-item.css"]
41
+ }; }
42
+ static get styleUrls() { return {
43
+ "$": ["ez-card-item.css"]
44
+ }; }
45
+ static get properties() { return {
46
+ "item": {
47
+ "type": "unknown",
48
+ "mutable": false,
49
+ "complexType": {
50
+ "original": "CardItem",
51
+ "resolved": "CardItem",
52
+ "references": {
53
+ "CardItem": {
54
+ "location": "local"
55
+ }
56
+ }
57
+ },
58
+ "required": false,
59
+ "optional": false,
60
+ "docs": {
61
+ "tags": [],
62
+ "text": ""
63
+ }
64
+ }
65
+ }; }
66
+ static get events() { return [{
67
+ "method": "ezClick",
68
+ "name": "ezClick",
69
+ "bubbles": true,
70
+ "cancelable": true,
71
+ "composed": true,
72
+ "docs": {
73
+ "tags": [],
74
+ "text": ""
75
+ },
76
+ "complexType": {
77
+ "original": "CardItem",
78
+ "resolved": "CardItem",
79
+ "references": {
80
+ "CardItem": {
81
+ "location": "local"
82
+ }
83
+ }
84
+ }
85
+ }]; }
86
+ }
@@ -132,6 +132,10 @@ ez-icon {
132
132
  justify-content: space-between;
133
133
  }
134
134
 
135
+ .collapsible-box__title--no-margin {
136
+ margin-bottom: 0;
137
+ }
138
+
135
139
  .collapsible-box__content {
136
140
  /*private*/
137
141
  display: flex;
@@ -42,7 +42,8 @@ export class EzCollapsibleBox {
42
42
  h("div", { class: "collapsible-box__header" },
43
43
  h("button", { onClick: () => this.showHide(), class: "collapsible-box__title" +
44
44
  (this.iconPlacement === "right" ? " collapsible-box__title--icon-right" : "") +
45
- (this.stretchTitle ? " collapsible-box__title--stretched" : "") },
45
+ (this.stretchTitle ? " collapsible-box__title--stretched" : "") +
46
+ (this.value ? " collapsible-box__title--no-margin" : "") },
46
47
  h("ez-icon", { slot: "icon", "icon-name": "chevron-right", size: this.getHeaderSize(), class: "collapsible-box__icon collapsible-box__icon--" + this.getHeaderSize() + (this.value ? " collapsible-box__icon--collapsed" : "") }),
47
48
  h("label", { class: "collapsible-box__label font--" + this.getHeaderSize(), title: this.label }, this.label))),
48
49
  h("div", { class: "collapsible-box__content" + (this.value ? "" : " collapsible-box__content--show") },
@@ -3,6 +3,9 @@ import { Component, h, Host, Prop, State, Event, Element, Watch, Method } from "
3
3
  import CSSVarsUtils from "../../utils/CSSVarsUtils";
4
4
  export class EzComboBox {
5
5
  constructor() {
6
+ this._limitCharsToSearch = 3;
7
+ this._deboucingTime = 300;
8
+ this._startLoading = false;
6
9
  /**
7
10
  * Deixa o campo disponível ou não para interação com usuário.
8
11
  */
@@ -141,19 +144,8 @@ export class EzComboBox {
141
144
  this._preSelection = undefined;
142
145
  }
143
146
  }
144
- selectOption(opt) {
145
- const currentOpt = this.getSelectedOption();
146
- if (currentOpt !== opt) {
147
- const adjustedOpt = !(opt === null || opt === void 0 ? void 0 : opt.value) ? undefined : opt;
148
- this.value = adjustedOpt;
149
- this.errorMessage = "";
150
- this.ezChange.emit(adjustedOpt);
151
- }
152
- else {
153
- this.observeValue();
154
- }
155
- }
156
147
  updateSource(source) {
148
+ this._startLoading = false;
157
149
  if (source instanceof Promise) {
158
150
  source.then(result => this.updateSource(result));
159
151
  this.updateVisibleOptions();
@@ -164,12 +156,26 @@ export class EzComboBox {
164
156
  this.updateVisibleOptions();
165
157
  }
166
158
  else {
167
- this.value = source;
159
+ this.selectOption(source);
168
160
  }
169
161
  }
170
162
  }
163
+ selectOption(newOption) {
164
+ var _a, _b;
165
+ const currentOpt = this.getSelectedOption();
166
+ if (((_a = currentOpt === null || currentOpt === void 0 ? void 0 : currentOpt.value) === null || _a === void 0 ? void 0 : _a.toString()) !== ((_b = newOption === null || newOption === void 0 ? void 0 : newOption.value) === null || _b === void 0 ? void 0 : _b.toString())) {
167
+ const adjustedOpt = !(newOption === null || newOption === void 0 ? void 0 : newOption.value) ? undefined : newOption;
168
+ this.value = adjustedOpt;
169
+ this.errorMessage = "";
170
+ this.ezChange.emit(this.value);
171
+ }
172
+ else {
173
+ this.observeValue();
174
+ }
175
+ }
171
176
  loadOptions(mode, argument = "") {
172
177
  this._criteria = argument;
178
+ this._startLoading = true;
173
179
  if (this.optionLoader) {
174
180
  this.updateSource(this.optionLoader({ mode, argument }));
175
181
  }
@@ -226,25 +232,40 @@ export class EzComboBox {
226
232
  this.searchMode ? this.loadOptions("ADVANCED") : this.showOptions();
227
233
  }
228
234
  onTextInputChangeHandler(event) {
235
+ var _a;
236
+ this.clearDeboucingTimeout();
237
+ if (this._startLoading) {
238
+ this._changeDeboucingTimeout = window.setTimeout(() => {
239
+ this.onTextInputChangeHandler(event);
240
+ }, this._deboucingTime);
241
+ return;
242
+ }
229
243
  if (!this._criteria) {
230
244
  this._inputElement.value = event.data;
231
245
  }
232
- const argument = event.target.value;
246
+ const argument = (_a = event.target.value) === null || _a === void 0 ? void 0 : _a.trim();
247
+ const argumentNumber = Number(argument || undefined);
233
248
  this._criteria = argument;
234
- if (this._criteria) {
249
+ if (argument && (!isNaN(argumentNumber) || argument.length >= this._limitCharsToSearch)) {
235
250
  if (this.searchMode) {
236
- if (this._changeDeboucingTimeout) {
237
- window.clearTimeout(this._changeDeboucingTimeout);
238
- }
239
251
  this._changeDeboucingTimeout = window.setTimeout(() => {
240
- this.loadOptions("PREDICTIVE", argument);
241
- }, 200);
252
+ this.loadOptions("PREDICTIVE", isNaN(argumentNumber) ? argument : argumentNumber.toString());
253
+ }, this._deboucingTime);
242
254
  }
243
255
  else {
244
256
  this.updateVisibleOptions();
245
257
  }
246
258
  this.showOptions();
247
259
  }
260
+ else {
261
+ this.hideOptions();
262
+ }
263
+ }
264
+ clearDeboucingTimeout() {
265
+ if (this._changeDeboucingTimeout) {
266
+ window.clearTimeout(this._changeDeboucingTimeout);
267
+ this._changeDeboucingTimeout = undefined;
268
+ }
248
269
  }
249
270
  onTextInputClickHandler() {
250
271
  if (!this.searchMode) {
@@ -530,7 +551,8 @@ export class EzComboBox {
530
551
  }; }
531
552
  static get states() { return {
532
553
  "_preSelection": {},
533
- "_visibleOptions": {}
554
+ "_visibleOptions": {},
555
+ "_startLoading": {}
534
556
  }; }
535
557
  static get events() { return [{
536
558
  "method": "ezChange",
@@ -45,12 +45,20 @@ export class EzForm {
45
45
  requiredFields.forEach(field => {
46
46
  const value = record[field];
47
47
  const fieldElem = this._element.querySelector(`[data-field-name=${field}]`);
48
- if (value === null || value === undefined || value === "") {
49
- invalidFields.push(field);
50
- fieldElem["errorMessage"] = "Essa informação é obrigatória";
51
- }
52
- else {
53
- fieldElem["errorMessage"] = "";
48
+ /**
49
+ * TODO: fieldElem vai ser vazio quando o campo está em uma aba que
50
+ * está escondida.
51
+ * Temos que tratar esse caso para apresentar a mensagem de erro
52
+ * na aba, isso será tratado no card: https://sankhya.atlassian.net/browse/SKA-44182
53
+ */
54
+ if (fieldElem) {
55
+ if (value === null || value === undefined || value === "") {
56
+ invalidFields.push(field);
57
+ fieldElem["errorMessage"] = "Essa informação é obrigatória";
58
+ }
59
+ else {
60
+ fieldElem["errorMessage"] = "";
61
+ }
54
62
  }
55
63
  });
56
64
  const isValid = invalidFields.length === 0;
@@ -45,7 +45,7 @@ export const buildFromDataUnit = (dataUnit) => {
45
45
  .filter(descriptor => descriptor.required)
46
46
  .map(descriptor => descriptor.name),
47
47
  cleanOnCopyFields: visibleFields
48
- .filter(descriptor => { var _a; return (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy; })
48
+ .filter(descriptor => { var _a, _b; return ((_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy) || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum); })
49
49
  .map(descriptor => descriptor.name),
50
50
  defaultValues
51
51
  });
@@ -57,7 +57,7 @@ function getTabConfig(tab, sheets) {
57
57
  return tabConfig || { label: tab, visible: true };
58
58
  }
59
59
  function sortTabs(a, b) {
60
- return a[0].label == 'Geral' ? -1 : (a[0].order || 10000) - (b[0].order || 10000);
60
+ return a[0].label == '__main' ? -1 : (a[0].order || 10000) - (b[0].order || 10000);
61
61
  }
62
62
  export const buildFromConfig = (fields, dataUnit) => {
63
63
  const sheets = new Map();
@@ -65,9 +65,9 @@ export const buildFromConfig = (fields, dataUnit) => {
65
65
  const cleanOnCopyFields = [];
66
66
  const defaultValues = {};
67
67
  fields.forEach(config => {
68
- var _a, _b;
68
+ var _a, _b, _c;
69
69
  if (config.visible !== false) {
70
- const tabConfig = getTabConfig(config.tab || "Geral", sheets);
70
+ const tabConfig = getTabConfig(config.tab || "__main", sheets);
71
71
  const descriptor = dataUnit.getField(config.name);
72
72
  if (descriptor && tabConfig.visible) {
73
73
  if (!sheets.has(tabConfig)) {
@@ -78,11 +78,11 @@ export const buildFromConfig = (fields, dataUnit) => {
78
78
  if (isRequired) {
79
79
  requiredFields.push(config.name);
80
80
  }
81
- const clearOnCopy = config.cleanOnCopy === undefined ? (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy : config.cleanOnCopy;
81
+ const clearOnCopy = config.cleanOnCopy === undefined ? (((_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy) || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum)) : config.cleanOnCopy;
82
82
  if (clearOnCopy) {
83
83
  cleanOnCopyFields.push(config.name);
84
84
  }
85
- const defaultValue = config.defaultValue === undefined ? (_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.defaultValue : config.defaultValue;
85
+ const defaultValue = config.defaultValue === undefined ? (_c = descriptor.properties) === null || _c === void 0 ? void 0 : _c.defaultValue : config.defaultValue;
86
86
  if (defaultValue) {
87
87
  defaultValues[config.name] = config.defaultValue;
88
88
  }
@@ -108,7 +108,7 @@ export const buildFromConfig = (fields, dataUnit) => {
108
108
  .sort(sortTabs)
109
109
  .forEach(([key, value]) => {
110
110
  metadata.addSheet({
111
- label: key.label,
111
+ label: (key.label === "__main") ? "Principal" : key.label,
112
112
  name: key.label,
113
113
  items: Array.from(value.values()),
114
114
  requiredFields,
@@ -11,6 +11,7 @@ export default class AgGridController {
11
11
  this.DEFAULT_ROW_HEIGHT = 25;
12
12
  this.CHECK_BOX_COL_ID = "checkBoxColumn";
13
13
  this.RECORD_ARCHIVE_COL_ID = "__RECORD_ARCHIVE__";
14
+ this.BLOCK_LOAD_DEBOUNCE = 400;
14
15
  this._menuItems = [];
15
16
  this._idAttribName = "__record__id__";
16
17
  this._isFirstRecordOfPage = true;
@@ -54,6 +55,7 @@ export default class AgGridController {
54
55
  rowSelection: this._multipleSelection ? "multiple" : "single",
55
56
  serverSideDatasource: this._dataSource,
56
57
  sortingOrder: ['desc', 'asc', null],
58
+ blockLoadDebounceMillis: this.BLOCK_LOAD_DEBOUNCE,
57
59
  getRowNodeId: this._dataUnit ? (params) => typeof params === "string" ? params : params[this._idAttribName] : undefined,
58
60
  getMainMenuItems: (params) => {
59
61
  const column = params.column;
@@ -101,7 +101,7 @@ export class EzUpload {
101
101
  }
102
102
  this._filePointers.set(file.name, uploadingFile);
103
103
  uploadingFile.upload(this.urlUpload, this._requestHeaders, (file) => this.updateFeedback(file))
104
- .then((files) => files.forEach(ezFile => this.finishUpload(ezFile)))
104
+ .then((files) => files.forEach(ezFile => this.finishUpload(uploadingFile.name, ezFile)))
105
105
  .catch(msg => {
106
106
  this.ezCancelWaitingChange.emit();
107
107
  this.showError(msg);
@@ -114,8 +114,8 @@ export class EzUpload {
114
114
  throw error;
115
115
  }
116
116
  }
117
- finishUpload(ezFile) {
118
- this._filePointers.set(ezFile.name, ezFile);
117
+ finishUpload(key, ezFile) {
118
+ this._filePointers.set(key, ezFile);
119
119
  this.updateValue();
120
120
  }
121
121
  updateValue() {
@@ -20,6 +20,12 @@ export const EzCalendar: {
20
20
  new (): EzCalendar;
21
21
  };
22
22
 
23
+ interface EzCardItem extends Components.EzCardItem, HTMLElement {}
24
+ export const EzCardItem: {
25
+ prototype: EzCardItem;
26
+ new (): EzCardItem;
27
+ };
28
+
23
29
  interface EzCheck extends Components.EzCheck, HTMLElement {}
24
30
  export const EzCheck: {
25
31
  prototype: EzCheck;