@sankhyalabs/ezui 1.1.94 → 1.1.97

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 (93) hide show
  1. package/dist/cjs/{CSSVarsUtils-66e86394.js → CSSVarsUtils-8fbdf2e0.js} +1 -0
  2. package/dist/cjs/StringUtils-0ba09df4.js +57 -0
  3. package/dist/cjs/UnitMetadata-2e11c5d3.js +1310 -0
  4. package/dist/cjs/ez-button_3.cjs.entry.js +578 -0
  5. package/dist/cjs/ez-calendar_14.cjs.entry.js +2657 -0
  6. package/dist/cjs/{ez-button_11.cjs.entry.js → ez-grid.cjs.entry.js} +27 -1501
  7. package/dist/cjs/ez-icon.cjs.entry.js +42 -0
  8. package/dist/cjs/ez-modal_2.cjs.entry.js +317 -0
  9. package/dist/cjs/ez-popover.cjs.entry.js +1 -1
  10. package/dist/cjs/ez-time-input.cjs.entry.js +7 -7
  11. package/dist/cjs/ezui.cjs.js +1 -1
  12. package/dist/cjs/loader.cjs.js +1 -1
  13. package/dist/collection/components/ez-check/ez-check.css +4 -3
  14. package/dist/collection/components/ez-combo-box/ez-combo-box.js +52 -3
  15. package/dist/collection/components/ez-form/DataBinder.js +13 -0
  16. package/dist/collection/components/ez-form/fieldbuilder/FieldBuilder.js +4 -1
  17. package/dist/collection/components/ez-form/fieldbuilder/tpl/CheckBox.tpl.js +4 -4
  18. package/dist/collection/components/ez-form/fieldbuilder/tpl/ComboBox.tpl.js +2 -2
  19. package/dist/collection/components/ez-form/fieldbuilder/tpl/DateInput.tpl.js +2 -2
  20. package/dist/collection/components/ez-form/fieldbuilder/tpl/FileInput.tpl.js +2 -2
  21. package/dist/collection/components/ez-form/fieldbuilder/tpl/NumberInput.tpl.js +6 -6
  22. package/dist/collection/components/ez-form/fieldbuilder/tpl/SearchInput.tpl.js +2 -2
  23. package/dist/collection/components/ez-form/fieldbuilder/tpl/TextArea.tpl.js +2 -2
  24. package/dist/collection/components/ez-form/structure/FormSheetMetadata.js +14 -8
  25. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +3 -2
  26. package/dist/collection/components/ez-grid/ez-grid.css +8 -0
  27. package/dist/collection/components/ez-grid/ez-grid.js +3 -3
  28. package/dist/collection/components/ez-grid/subcomponents/gridconfig/grid-config.css +28 -4
  29. package/dist/collection/components/ez-grid/subcomponents/gridconfig/grid-config.js +6 -5
  30. package/dist/collection/components/ez-grid/subcomponents/select-box/select-box.css +10 -7
  31. package/dist/collection/components/ez-grid/subcomponents/select-box/select-box.js +12 -17
  32. package/dist/collection/components/ez-icon/ez-icon.css +5 -0
  33. package/dist/collection/components/ez-list/ez-list.js +2 -2
  34. package/dist/collection/components/ez-text-input/ez-text-input.css +2 -2
  35. package/dist/collection/components/ez-text-input/ez-text-input.js +24 -1
  36. package/dist/collection/components/test-du/test-du.js +1 -1
  37. package/dist/collection/utils/CSSVarsUtils.js +1 -0
  38. package/dist/custom-elements/index.js +290 -6376
  39. package/dist/esm/{CSSVarsUtils-aeee9825.js → CSSVarsUtils-667e0016.js} +1 -0
  40. package/dist/esm/StringUtils-cbf10229.js +55 -0
  41. package/dist/esm/UnitMetadata-8b1bbaa2.js +1304 -0
  42. package/dist/esm/ez-button_3.entry.js +572 -0
  43. package/dist/esm/ez-calendar_14.entry.js +2640 -0
  44. package/dist/esm/{ez-button_11.entry.js → ez-grid.entry.js} +23 -1487
  45. package/dist/esm/ez-icon.entry.js +38 -0
  46. package/dist/esm/ez-modal_2.entry.js +312 -0
  47. package/dist/esm/ez-popover.entry.js +1 -1
  48. package/dist/esm/ez-time-input.entry.js +2 -2
  49. package/dist/esm/ezui.js +1 -1
  50. package/dist/esm/loader.js +1 -1
  51. package/dist/ezui/ezui.esm.js +1 -1
  52. package/dist/ezui/p-07b60fe9.js +1 -0
  53. package/dist/ezui/p-2336c9ce.entry.js +1 -0
  54. package/dist/ezui/p-2f84ba72.js +1 -0
  55. package/dist/ezui/{p-4b5c4408.entry.js → p-45a25c30.entry.js} +1 -1
  56. package/dist/ezui/{p-ca42d682.entry.js → p-532b5b24.entry.js} +46 -46
  57. package/dist/ezui/p-614fbb4e.entry.js +1 -0
  58. package/dist/ezui/p-7165ac4f.entry.js +1 -0
  59. package/dist/ezui/p-90f6d8a0.entry.js +1 -0
  60. package/dist/ezui/{p-7e1d9c29.entry.js → p-d3f87e18.entry.js} +1 -1
  61. package/dist/ezui/p-d54c157f.js +1 -0
  62. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +8 -0
  63. package/dist/types/components/ez-form/DataBinder.d.ts +1 -0
  64. package/dist/types/components/ez-form/ez-form.d.ts +6 -1
  65. package/dist/types/components/ez-form/fieldbuilder/tpl/ComboBox.tpl.d.ts +2 -1
  66. package/dist/types/components/ez-form/fieldbuilder/tpl/DateInput.tpl.d.ts +2 -1
  67. package/dist/types/components/ez-form/fieldbuilder/tpl/FileInput.tpl.d.ts +2 -1
  68. package/dist/types/components/ez-form/fieldbuilder/tpl/NumberInput.tpl.d.ts +4 -2
  69. package/dist/types/components/ez-form/fieldbuilder/tpl/SearchInput.tpl.d.ts +2 -1
  70. package/dist/types/components/ez-form/fieldbuilder/tpl/TextArea.tpl.d.ts +2 -1
  71. package/dist/types/components/ez-grid/subcomponents/select-box/select-box.d.ts +6 -4
  72. package/dist/types/components/ez-text-input/ez-text-input.d.ts +4 -0
  73. package/dist/types/components.d.ts +26 -2
  74. package/package.json +2 -2
  75. package/dist/cjs/ApplicationUtils-d1c1db56.js +0 -35
  76. package/dist/cjs/ez-calendar.cjs.entry.js +0 -224
  77. package/dist/cjs/ez-collapsible-box_7.cjs.entry.js +0 -853
  78. package/dist/cjs/ez-combo-box.cjs.entry.js +0 -254
  79. package/dist/cjs/ez-form.cjs.entry.js +0 -753
  80. package/dist/cjs/index-5c8eb919.js +0 -7460
  81. package/dist/esm/ApplicationUtils-01280a9d.js +0 -33
  82. package/dist/esm/ez-calendar.entry.js +0 -220
  83. package/dist/esm/ez-collapsible-box_7.entry.js +0 -843
  84. package/dist/esm/ez-combo-box.entry.js +0 -250
  85. package/dist/esm/ez-form.entry.js +0 -749
  86. package/dist/esm/index-4688c617.js +0 -7452
  87. package/dist/ezui/p-278ce681.entry.js +0 -1
  88. package/dist/ezui/p-33d1247f.entry.js +0 -1
  89. package/dist/ezui/p-5793a2e1.entry.js +0 -1
  90. package/dist/ezui/p-68f6b75e.entry.js +0 -1
  91. package/dist/ezui/p-7107d7ef.js +0 -1
  92. package/dist/ezui/p-7ff8b7f7.js +0 -1
  93. package/dist/ezui/p-8b099482.js +0 -1
@@ -1,853 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index = require('./index-88286449.js');
6
- const index$1 = require('./index-5c8eb919.js');
7
- const CSSVarsUtils = require('./CSSVarsUtils-66e86394.js');
8
- const ApplicationUtils = require('./ApplicationUtils-d1c1db56.js');
9
-
10
- class DateUtils {
11
- static clearTime(date, adjustDayLightSavingTime = true) {
12
- const newDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0, 0);
13
- return adjustDayLightSavingTime ? DateUtils.adjustDLST(newDate) : newDate;
14
- }
15
- static strToDate(strValue, adjustDayLightSavingTime = true, monthYearMode = false) {
16
- /** monthYearMode é um booleano para usar o formato MM/YYYY.
17
- * Quando ativado, é retornado o primeiro dia do mês apenas para construir a data.
18
- * Não há necessidade de verificar o horário de verão quando utilizado esse modo. */
19
- let parts;
20
- if (monthYearMode) {
21
- parts = /^(1[0-2]|0[1-9]|[1-9])[^\d]?(\d{2}|\d{4})(?:\s(\d{1,2}):(\d{1,2}):?(\d{0,2}))?$/.exec(strValue);
22
- }
23
- else {
24
- parts = /^(3[01]|[1-2]\d|0[1-9]|[1-9])[^\d]?(1[0-2]|0[1-9]|[1-9])[^\d]?(\d{2}|\d{4})(?:\s(\d{1,2}):(\d{1,2}):?(\d{0,2}))?$/.exec(strValue);
25
- }
26
- if (!parts) {
27
- return undefined;
28
- }
29
- var day = monthYearMode ? 1 : Number(parts[1]);
30
- var month = Number(parts[(monthYearMode ? 1 : 2)]);
31
- var year = Number(parts[(monthYearMode ? 2 : 3)]);
32
- var hour = Number(parts[(monthYearMode ? 3 : 4)] || 0);
33
- var min = Number(parts[(monthYearMode ? 4 : 5)] || 0);
34
- var sec = Number(parts[(monthYearMode ? 5 : 6)] || 0);
35
- if (year < 100) {
36
- year += year < 30 ? 2000 : 1900;
37
- }
38
- let date = new Date(year, month - 1, day, hour, min, sec, 0);
39
- if (adjustDayLightSavingTime === true && !monthYearMode && hour == 0) {
40
- date = DateUtils.adjustDLST(date);
41
- }
42
- return date;
43
- }
44
- static adjustDLST(date) {
45
- //Work around para corrigir o Bug do horário de verão.
46
- if (date.getHours() == 23) {
47
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1, 1, 0, 0, 0);
48
- }
49
- return date;
50
- }
51
- }
52
-
53
- const ezCollapsibleBoxCss = ":host{--ez-collapsible-box--height:42px;--ez-collapsible-box--font-size:var(--title--medium, 14px);--ez-collapsible-box--font-family:var(--font-pattern, Arial);--ez-collapsible-box--font-weight:var(--text-weight--large, 600);--ez-collapsible-box--color:var(--title--primary);--ez-collapsible-box__btn--image--xsmall:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"12px\" width=\"7.5px\"><path d=\"M 0,10.56 4.5967752,6.0000006 0,1.3800006 1.4516132,0 7.5,6.0000006 1.4516132,12 Z\"/></svg>');--ez-collapsible-box__btn--image--small:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"14px\" width=\"8.68px\"><path d=\"M 0,12.32 5.3200012,7.0000007 0,1.6100007 1.6800004,0 8.68,7.0000007 1.6800004,14 Z\"/></svg>');--ez-collapsible-box__btn--image--medium:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"16px\" width=\"10px\"><path d=\"M 0.21915251,13.860393 6.0795475,8.0000007 0.21915251,2.0624968 2.0698036,0.28895588 9.7808475,8.0000007 2.0698036,15.711044 Z\"/></svg>');--ez-collapsible-box__btn--image--large:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"18px\" width=\"11.25px\"><path d=\"M 0,15.84 6.8951628,9.0000009 0,2.0700009 2.1774198,0 11.25,9.0000009 2.1774198,18 Z\"/></svg>');--ez-collapsible-box__btn--image--xlarge:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"20px\" width=\"12.5px\"><path d=\"M 0,17.6 7.661292,10.000001 0,2.300001 2.4193553,0 12.5,10.000001 2.4193553,20 Z\"/></svg>');--ez-collapsible-box__btn--fill:var(--ez-collapsible-box--color);--ez-collapsible-box__btn--width:10px;--ez-collapsible-box__btn--height:16px;display:flex;flex-wrap:wrap;width:100%}.collapsible-box__title{width:100%;align-self:center;display:flex;box-sizing:border-box}.collapsible-box__label{white-space:nowrap;overflow:hidden;cursor:pointer;text-overflow:ellipsis;width:100%;font-family:var(--ez-collapsible-box--font-family);font-size:var(--ez-collapsible-box--font-size);font-weight:var(--ez-collapsible-box--font-weight);color:var(--ez-collapsible-box--color)}.collapsible-box__label--icon-right{white-space:nowrap;overflow:hidden;cursor:pointer;text-overflow:ellipsis;font-family:var(--ez-collapsible-box--font-family);font-size:var(--ez-collapsible-box--font-size);font-weight:var(--ez-collapsible-box--font-weight);color:var(--ez-collapsible-box--color)}.collapsible-box__btn{outline:none;border:none;background-color:unset;cursor:pointer;padding:1px 6px}.collapsible-box__btn::after{content:'';display:flex;background-color:var(--ez-collapsible-box__btn--fill);width:var(--ez-collapsible-box__btn--width);height:var(--ez-collapsible-box__btn--height);transition:transform var(--transition);transform:rotate(90deg)}.collapsible-box__btn--xsmall::after{width:7.5px;height:12px;-webkit-mask-image:var(--ez-collapsible-box__btn--image--xsmall);mask-image:var(--ez-collapsible-box__btn--image--xsmall)}.collapsible-box__btn--small::after{width:8.68px;height:14px;-webkit-mask-image:var(--ez-collapsible-box__btn--image--small);mask-image:var(--ez-collapsible-box__btn--image--small)}.collapsible-box__btn--medium::after{width:10px;height:16px;-webkit-mask-image:var(--ez-collapsible-box__btn--image--medium);mask-image:var(--ez-collapsible-box__btn--image--medium)}.collapsible-box__btn--large::after{width:11.25px;height:18px;-webkit-mask-image:var(--ez-collapsible-box__btn--image--large);mask-image:var(--ez-collapsible-box__btn--image--large)}.collapsible-box__btn--xlarge::after{width:12.5px;height:20px;-webkit-mask-image:var(--ez-collapsible-box__btn--image--xlarge);mask-image:var(--ez-collapsible-box__btn--image--xlarge)}.collapsible-box__btn--collapsed::after{transform:rotate(0deg)}.font--xsmall{font-size:10px}.font--small{font-size:12px}.font--medium{font-size:14px}.font--large{font-size:16px}.font--xlarge{font-size:20px}";
54
-
55
- let EzCollapsibleBox = class {
56
- constructor(hostRef) {
57
- index.registerInstance(this, hostRef);
58
- this.ezChange = index.createEvent(this, "ezChange", 7);
59
- /**
60
- * Valor externalizado que garante a exibição ou não do componente
61
- */
62
- this.value = false;
63
- /**
64
- * Define o tamanho do texto e do ícone do componente.
65
- */
66
- this.headerSize = "small";
67
- /**
68
- * Define o local onde o ícone será renderizado.
69
- */
70
- this.iconPlacement = "left";
71
- }
72
- observeValue() {
73
- this.ezChange.emit();
74
- }
75
- /**
76
- * Esconde ou revela o conteúdo do componente
77
- */
78
- async showHide() {
79
- this.value = !this.value;
80
- }
81
- render() {
82
- return (index.h(index.Host, null, this.iconPlacement == "right" ?
83
- index.h("div", { class: "collapsible-box__title" }, index.h("label", { class: (this.iconPlacement == "right" ? "collapsible-box__label--icon-right " : "collapsible-box__label ") + (this.headerSize ? "font--" + this.headerSize : ""), onClick: () => this.showHide(), title: this.label }, this.label), index.h("button", { class: this.value ? "collapsible-box__btn collapsible-box__btn--collapsed " + "collapsible-box__btn--" + this.headerSize : "collapsible-box__btn " + "collapsible-box__btn--" + this.headerSize, onClick: () => this.showHide() }))
84
- :
85
- index.h("div", { class: "collapsible-box__title" }, index.h("button", { class: this.value ? "collapsible-box__btn collapsible-box__btn--collapsed " + "collapsible-box__btn--" + this.headerSize : "collapsible-box__btn " + "collapsible-box__btn--" + this.headerSize, onClick: () => this.showHide() }), index.h("label", { class: (this.iconPlacement == "right" ? "collapsible-box__label--icon-right " : "collapsible-box__label ") + (this.headerSize ? "font--" + this.headerSize : ""), onClick: () => this.showHide(), title: this.label }, this.label)), !this.value ? index.h("slot", null) : null));
86
- }
87
- static get watchers() { return {
88
- "value": ["observeValue"]
89
- }; }
90
- };
91
- EzCollapsibleBox.style = ezCollapsibleBoxCss;
92
-
93
- const ezDateInputCss = ":host{display:block;width:100%;--ez-date-input__input--background-color:var(--background--medium, #e0e0e0);--ez-date-input__input--border-color:var(--ez-date-input__input--background-color);--ez-date-input__calendar-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"16px\" width=\"15px\"><path d=\"M 3.171875,5.25 C 2.6485088,5.25 2.21875,5.6797588 2.21875,6.203125 2.21875,6.7264912 2.6485088,7.15625 3.171875,7.15625 3.6952412,7.15625 4.125,6.7264912 4.125,6.203125 4.125,5.6797588 3.6952412,5.25 3.171875,5.25 Z m 2.875,0 C 5.5235088,5.25 5.09375,5.6797588 5.09375,6.203125 5.09375,6.7264912 5.5235088,7.15625 6.046875,7.15625 6.5702412,7.15625 7,6.7264912 7,6.203125 7,5.6797588 6.5702412,5.25 6.046875,5.25 Z m 2.875,0 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.953125 0.953125,0.953125 0.5233662,0 0.9511719,-0.4297588 0.9511719,-0.953125 C 9.8730469,5.6797588 9.4452412,5.25 8.921875,5.25 Z m 2.873047,0 c -0.523366,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.429759,0.953125 0.953125,0.953125 0.523366,0 0.953125,-0.4297588 0.953125,-0.953125 C 12.748047,5.6797588 12.318288,5.25 11.794922,5.25 Z M 3.171875,8.1230469 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.9531251 0.953125,0.9531251 0.5233662,0 0.953125,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.875,0 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.9531251 0.953125,0.9531251 C 6.5702412,10.029297 7,9.5995381 7,9.0761719 7,8.5528057 6.5702412,8.1230469 6.046875,8.1230469 Z m 2.8554688,0 c -0.5233663,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297587,0.9531251 0.953125,0.9531251 0.5233661,0 0.9531249,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.9003902,0 c -0.523366,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.429759,0.9531251 0.953125,0.9531251 0.523367,0 0.953125,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.429758,-0.953125 -0.953125,-0.953125 z M 3.171875,10.998047 c -0.5233662,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297588,0.953125 0.953125,0.953125 0.5233662,0 0.953125,-0.429759 0.953125,-0.953125 0,-0.523366 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.875,0 c -0.5233662,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297588,0.953125 0.953125,0.953125 C 6.5702412,12.904297 7,12.474538 7,11.951172 7,11.427806 6.5702412,10.998047 6.046875,10.998047 Z m 2.8554688,0 c -0.5233663,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297587,0.953125 0.953125,0.953125 0.5233661,0 0.9531249,-0.429759 0.953125,-0.953125 0,-0.523366 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.9003902,0 c -0.523366,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.429759,0.953125 0.953125,0.953125 0.523367,0 0.953125,-0.429759 0.953125,-0.953125 0,-0.523366 -0.429758,-0.953125 -0.953125,-0.953125 z M 3.5,0 c -0.554,0 -1,0.446 -1,1 v 0.050781 C 1.0853217,1.2909766 0,2.5186658 0,4 v 9 c 0,1.652487 1.3475134,3 3,3 h 9 c 1.652487,0 3,-1.347513 3,-3 V 4 C 15,2.5186658 13.914678,1.2909766 12.5,1.0507812 V 1 c 0,-0.554 -0.446,-1 -1,-1 -0.554,0 -1,0.446 -1,1 h -2 c 0,-0.554 -0.446,-1 -1,-1 -0.554,0 -1,0.446 -1,1 h -2 C 4.5,0.446 4.054,0 3.5,0 Z m 1,2.0996094 h 2 v 0.640625 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 v -0.640625 h 2 v 0.640625 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 V 2.1738281 C 13.311725,2.3905225 13.900391,3.11278 13.900391,4 v 9 c 0,1.062113 -0.838278,1.900391 -1.900391,1.900391 H 3 C 1.9378864,14.900391 1.0996094,14.062113 1.0996094,13 V 4 C 1.0996094,3.11278 1.6882747,2.3905225 2.5,2.1738281 v 0.5664063 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 z\"/></svg>')}.btn-open-cal{outline:none;border:none;background-color:unset;cursor:pointer}.btn-open-cal:disabled{cursor:unset}.btn-open-cal::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:15px;height:16px;-webkit-mask-image:var(--ez-date-input__calendar-image);mask-image:var(--ez-date-input__calendar-image)}.btn-open-cal:disabled:after{background-color:var(--text--disable, #AFB6C0)}.btn-open-cal:enabled:hover::after{background-color:var(--color--primary, #4e4e4e)}ez-text-input{--text-input__input--background-color:var(--ez-date-input__input--background-color, #FFFFFF);--text-input__input--border-color:var(--ez-date-input__input--border-color, #DCE0E8)}";
94
-
95
- let EzDateInput = class {
96
- constructor(hostRef) {
97
- index.registerInstance(this, hostRef);
98
- this.ezChange = index.createEvent(this, "ezChange", 7);
99
- /**
100
- * Deixa o campo disponível ou não para uso.
101
- */
102
- this.enabled = true;
103
- }
104
- setLabel() {
105
- this._textInput.label = this.label;
106
- }
107
- setErrorMessage() {
108
- this._textInput.errorMessage = this.errorMessage;
109
- }
110
- applyValueToInput() {
111
- if (this._textInput) {
112
- this._textInput.value = this.getTextValue(this.value);
113
- }
114
- }
115
- changeValue(newValue) {
116
- newValue = newValue == null ? null : DateUtils.clearTime(newValue);
117
- this._textInput.errorMessage = "";
118
- if (newValue !== this.value) {
119
- this.value = newValue;
120
- this.ezChange.emit();
121
- }
122
- }
123
- showCalendar() {
124
- this.parseDate();
125
- this._calendar.value = this.value;
126
- //FIXME: Provavelmente isso fará com que o popup abra em uma
127
- //posição errada no futuro. Preferi fazer simples no começo,
128
- //porque não quis onerar o text input com essa funcionalidade...
129
- const top = this._textInput.errorMessage ? 0 : -17;
130
- this._calendar.fitVertical(top, this._elem.clientHeight);
131
- }
132
- hideCalendar() {
133
- this.changeValue(this._calendar.value);
134
- this._calendar.hide();
135
- }
136
- parseDate() {
137
- const strValue = this._textInput.value;
138
- const parsedDate = DateUtils.strToDate(strValue);
139
- if (parsedDate || !strValue) {
140
- if (this.value === parsedDate) {
141
- this.changeValue(this.value);
142
- }
143
- else {
144
- this.changeValue(parsedDate);
145
- }
146
- }
147
- else {
148
- this._textInput.errorMessage = "O valor digitado não é uma data válida";
149
- }
150
- }
151
- getTextValue(d) {
152
- return d ? new Intl.DateTimeFormat("pt-BR").format(d) : null;
153
- }
154
- componentDidLoad() {
155
- CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
156
- }
157
- render() {
158
- return (index.h(index.Host, null, index.h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => {
159
- if (event.key === "H" || event.key === "h")
160
- this.changeValue(new Date());
161
- }, label: this.label, onEzChange: event => event.stopPropagation(), value: this.getTextValue(this.value), restrict: "0123456789/", enabled: this.enabled, errorMessage: this.errorMessage }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), index.h("ez-calendar", { onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem })));
162
- }
163
- get _elem() { return index.getElement(this); }
164
- static get watchers() { return {
165
- "label": ["setLabel"],
166
- "errorMessage": ["setErrorMessage"],
167
- "value": ["applyValueToInput"]
168
- }; }
169
- };
170
- EzDateInput.style = ezDateInputCss;
171
-
172
- const ezDateTimeInputCss = ":host{display:block;width:100%;--ez-date-input__input--background-color:var(--background--medium, #e0e0e0);--ez-date-input__input--border-color:var(--ez-date-input__input--background-color);--ez-date-input__calendar-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"16px\" width=\"15px\"><path d=\"M 3.171875,5.25 C 2.6485088,5.25 2.21875,5.6797588 2.21875,6.203125 2.21875,6.7264912 2.6485088,7.15625 3.171875,7.15625 3.6952412,7.15625 4.125,6.7264912 4.125,6.203125 4.125,5.6797588 3.6952412,5.25 3.171875,5.25 Z m 2.875,0 C 5.5235088,5.25 5.09375,5.6797588 5.09375,6.203125 5.09375,6.7264912 5.5235088,7.15625 6.046875,7.15625 6.5702412,7.15625 7,6.7264912 7,6.203125 7,5.6797588 6.5702412,5.25 6.046875,5.25 Z m 2.875,0 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.953125 0.953125,0.953125 0.5233662,0 0.9511719,-0.4297588 0.9511719,-0.953125 C 9.8730469,5.6797588 9.4452412,5.25 8.921875,5.25 Z m 2.873047,0 c -0.523366,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.429759,0.953125 0.953125,0.953125 0.523366,0 0.953125,-0.4297588 0.953125,-0.953125 C 12.748047,5.6797588 12.318288,5.25 11.794922,5.25 Z M 3.171875,8.1230469 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.9531251 0.953125,0.9531251 0.5233662,0 0.953125,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.875,0 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.9531251 0.953125,0.9531251 C 6.5702412,10.029297 7,9.5995381 7,9.0761719 7,8.5528057 6.5702412,8.1230469 6.046875,8.1230469 Z m 2.8554688,0 c -0.5233663,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297587,0.9531251 0.953125,0.9531251 0.5233661,0 0.9531249,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.9003902,0 c -0.523366,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.429759,0.9531251 0.953125,0.9531251 0.523367,0 0.953125,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.429758,-0.953125 -0.953125,-0.953125 z M 3.171875,10.998047 c -0.5233662,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297588,0.953125 0.953125,0.953125 0.5233662,0 0.953125,-0.429759 0.953125,-0.953125 0,-0.523366 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.875,0 c -0.5233662,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297588,0.953125 0.953125,0.953125 C 6.5702412,12.904297 7,12.474538 7,11.951172 7,11.427806 6.5702412,10.998047 6.046875,10.998047 Z m 2.8554688,0 c -0.5233663,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297587,0.953125 0.953125,0.953125 0.5233661,0 0.9531249,-0.429759 0.953125,-0.953125 0,-0.523366 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.9003902,0 c -0.523366,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.429759,0.953125 0.953125,0.953125 0.523367,0 0.953125,-0.429759 0.953125,-0.953125 0,-0.523366 -0.429758,-0.953125 -0.953125,-0.953125 z M 3.5,0 c -0.554,0 -1,0.446 -1,1 v 0.050781 C 1.0853217,1.2909766 0,2.5186658 0,4 v 9 c 0,1.652487 1.3475134,3 3,3 h 9 c 1.652487,0 3,-1.347513 3,-3 V 4 C 15,2.5186658 13.914678,1.2909766 12.5,1.0507812 V 1 c 0,-0.554 -0.446,-1 -1,-1 -0.554,0 -1,0.446 -1,1 h -2 c 0,-0.554 -0.446,-1 -1,-1 -0.554,0 -1,0.446 -1,1 h -2 C 4.5,0.446 4.054,0 3.5,0 Z m 1,2.0996094 h 2 v 0.640625 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 v -0.640625 h 2 v 0.640625 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 V 2.1738281 C 13.311725,2.3905225 13.900391,3.11278 13.900391,4 v 9 c 0,1.062113 -0.838278,1.900391 -1.900391,1.900391 H 3 C 1.9378864,14.900391 1.0996094,14.062113 1.0996094,13 V 4 C 1.0996094,3.11278 1.6882747,2.3905225 2.5,2.1738281 v 0.5664063 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 z\"/></svg>')}.btn-open-cal{outline:none;border:none;background-color:unset;cursor:pointer}.btn-open-cal:disabled{cursor:unset}.btn-open-cal::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:15px;height:16px;-webkit-mask-image:var(--ez-date-input__calendar-image);mask-image:var(--ez-date-input__calendar-image)}.btn-open-cal:disabled:after{background-color:var(--text--disable, #AFB6C0)}.btn-open-cal:enabled:hover::after{background-color:var(--color--primary, #4e4e4e)}ez-text-input{--text-input__input--background-color:var(--ez-date-input__input--background-color, #FFFFFF);--text-input__input--border-color:var(--ez-date-input__input--border-color, #DCE0E8)}";
173
-
174
- let EzDateTimeInput = class {
175
- constructor(hostRef) {
176
- index.registerInstance(this, hostRef);
177
- this.ezChange = index.createEvent(this, "ezChange", 7);
178
- /**
179
- * Deixa o campo disponível ou não para uso.
180
- */
181
- this.enabled = true;
182
- /**
183
- * Exibe ou não os segundos no input
184
- */
185
- this.showSeconds = false;
186
- }
187
- setLabel() {
188
- this._textInput.label = this.label;
189
- }
190
- setErrorMessage() {
191
- this._textInput.errorMessage = this.errorMessage;
192
- }
193
- applyValueToInput() {
194
- if (this._textInput) {
195
- this._textInput.value = this.getTextValue(this.value);
196
- }
197
- }
198
- onChangeKeyDown(ev) {
199
- const input = this._textInput.shadowRoot.querySelector('input');
200
- if (ev.key === "H" || ev.key === "h") {
201
- this.changeValue(new Date());
202
- }
203
- else if (ev.shiftKey && ev.key === "Tab") {
204
- if (input.selectionStart > 0) {
205
- let selectIni = input.value.lastIndexOf(" ", input.selectionStart);
206
- if (selectIni !== -1) {
207
- input.setSelectionRange(0, selectIni);
208
- ev.preventDefault();
209
- }
210
- }
211
- }
212
- else if (ev.key === "Tab") {
213
- if (input.value.length !== input.selectionEnd) {
214
- let selectIni = input.value.indexOf(" ", input.selectionEnd);
215
- selectIni = selectIni === -1 ? input.selectionEnd : selectIni + 1;
216
- input.setSelectionRange(selectIni, input.value.length);
217
- ev.preventDefault();
218
- }
219
- }
220
- }
221
- onFocused() {
222
- const input = this._textInput.shadowRoot.querySelector('input');
223
- if (input.selectionStart !== input.selectionEnd) {
224
- let selectIni = input.value.indexOf(" ", input.selectionStart);
225
- selectIni = selectIni === -1 ? input.value.length : selectIni;
226
- input.setSelectionRange(0, selectIni);
227
- }
228
- }
229
- onClicked() {
230
- const input = this._textInput.shadowRoot.querySelector('input');
231
- let selectIni = input.value.lastIndexOf(" ", input.selectionEnd);
232
- selectIni = selectIni === -1 ? 0 : selectIni + 1;
233
- selectIni = selectIni > input.selectionEnd ? 0 : selectIni;
234
- let selectFin = selectIni === 0 ? input.value.indexOf(" ") : input.value.length;
235
- input.setSelectionRange(selectIni, selectFin);
236
- }
237
- changeValue(newValue) {
238
- this._textInput.errorMessage = "";
239
- if (newValue !== this.value) {
240
- this.value = newValue;
241
- this.ezChange.emit();
242
- }
243
- }
244
- showCalendar() {
245
- const top = this._textInput.errorMessage ? 0 : -17;
246
- this._calendar.fitVertical(top, this._elem.clientHeight);
247
- this._calendar.style.visibility = 'inherit';
248
- }
249
- parseDate() {
250
- const strValue = this._textInput.value;
251
- const partsDateTime = (strValue && strValue.length > 0) ? strValue.split(" ") : [];
252
- const onlyDate = partsDateTime.length > 0 ? partsDateTime[0] : strValue;
253
- const onlyTime = partsDateTime[1] ? partsDateTime[1] : "";
254
- const parsedTime = index$1.TimeFormatter.prepareValue(onlyTime, this.showSeconds);
255
- const strDateTime = onlyDate + (parsedTime && " " + parsedTime);
256
- const parsedDate = DateUtils.strToDate(strDateTime);
257
- if (parsedDate || !strValue) {
258
- if (this.value === parsedDate) {
259
- this.changeValue(this.value);
260
- }
261
- else {
262
- this.changeValue(parsedDate);
263
- }
264
- }
265
- else {
266
- this._textInput.errorMessage = "O valor digitado não é uma data válida";
267
- }
268
- }
269
- getTextValue(d) {
270
- const options = {
271
- year: 'numeric', month: 'numeric', day: 'numeric',
272
- hour: 'numeric', minute: 'numeric'
273
- };
274
- const optionsSecond = {
275
- year: 'numeric', month: 'numeric', day: 'numeric',
276
- hour: 'numeric', minute: 'numeric', second: 'numeric'
277
- };
278
- return d ? (new Intl.DateTimeFormat('pt-BR', this.showSeconds ? optionsSecond : options).format(d)) : null;
279
- }
280
- componentDidLoad() {
281
- CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
282
- }
283
- render() {
284
- return (index.h(index.Host, null, index.h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => { this.onChangeKeyDown(event); }, label: this.label, onEzChange: event => event.stopPropagation(), value: this.getTextValue(this.value), restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, onFocus: () => this.onFocused(), onClick: () => this.onClicked() }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), index.h("ez-calendar", { onEzChange: (event) => { this.changeValue(this._calendar.value); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem, time: true, showSeconds: this.showSeconds })));
285
- }
286
- get _elem() { return index.getElement(this); }
287
- static get watchers() { return {
288
- "label": ["setLabel"],
289
- "errorMessage": ["setErrorMessage"],
290
- "value": ["applyValueToInput"]
291
- }; }
292
- };
293
- EzDateTimeInput.style = ezDateTimeInputCss;
294
-
295
- const ezNumberInputCss = ":host{display:block;width:100%}";
296
-
297
- let EzNumberInput = class {
298
- constructor(hostRef) {
299
- index.registerInstance(this, hostRef);
300
- this.ezChange = index.createEvent(this, "ezChange", 7);
301
- /**
302
- * Deixa o campo disponível ou não para uso.
303
- */
304
- this.enabled = true;
305
- }
306
- setLabel() {
307
- this._textInput.label = this.label;
308
- }
309
- setErrorMessage() {
310
- this._textInput.errorMessage = this.errorMessage;
311
- }
312
- applyValueToInput() {
313
- if (this._textInput) {
314
- this._textInput.value = this.getTextValue(this.value);
315
- }
316
- }
317
- changeValue(newValue) {
318
- this.errorMessage = "";
319
- if (newValue && newValue !== this.value) {
320
- this.value = newValue;
321
- this.ezChange.emit(this.value);
322
- }
323
- }
324
- parseNumber() {
325
- const parsedNumber = this._textInput.value ? index$1.NumberUtils.stringToNumber(this._textInput.value) : null;
326
- if (parsedNumber != null && isNaN(parsedNumber)) {
327
- this.errorMessage = "O valor digitado não é um número válido";
328
- }
329
- else {
330
- try {
331
- this.changeValue(parsedNumber);
332
- }
333
- catch (e) {
334
- this.errorMessage = e.message;
335
- return;
336
- }
337
- }
338
- }
339
- getTextValue(value) {
340
- if (value) {
341
- return this.precision > 0 ? index$1.NumberUtils.format(value.toString(), Number(this.precision), Number(this.prettyPrecision)) : value.toString();
342
- }
343
- return null;
344
- }
345
- componentDidLoad() {
346
- CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
347
- }
348
- render() {
349
- return (index.h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseNumber(), label: this.label, onEzChange: event => event.stopPropagation(), value: this.getTextValue(this.value), restrict: this.precision > 0 ? "0123456789-,." : "0123456789-", enabled: this.enabled, errorMessage: this.errorMessage }));
350
- }
351
- get _elem() { return index.getElement(this); }
352
- static get watchers() { return {
353
- "label": ["setLabel"],
354
- "errorMessage": ["setErrorMessage"],
355
- "value": ["applyValueToInput"]
356
- }; }
357
- };
358
- EzNumberInput.style = ezNumberInputCss;
359
-
360
- const ezSearchCss = ":host{width:100%}";
361
-
362
- let EzSearch = class {
363
- constructor(hostRef) {
364
- index.registerInstance(this, hostRef);
365
- this.ezChange = index.createEvent(this, "ezChange", 7);
366
- this.showPopup = index.createEvent(this, "showPopup", 7);
367
- /**
368
- * Deixa o campo disponível ou não.
369
- */
370
- this.enabled = true;
371
- /**
372
- * Ajusta a opção de mostrar o "value" ao selecionar uma opção.
373
- */
374
- this.showSelectedValue = true;
375
- /**
376
- * Ajusta a opção de mostrar o "value" para cada opção.
377
- */
378
- this.showOptionValue = true;
379
- }
380
- updateValue() {
381
- if (this._comboElement) {
382
- this._comboElement.value = this.value;
383
- }
384
- }
385
- onComboChange(evt) {
386
- evt.stopPropagation();
387
- this.value = evt.detail;
388
- this.ezChange.emit(evt.detail);
389
- }
390
- componentDidLoad() {
391
- CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._comboElement);
392
- }
393
- render() {
394
- return (index.h("ez-combo-box", { ref: elem => this._comboElement = elem, value: this.value, label: this.label, enabled: this.enabled, errorMessage: this.errorMessage, optionLoader: this.optionLoader, searchMode: true, onEzChange: evt => this.onComboChange(evt), showSelectedValue: this.showSelectedValue, showOptionValue: this.showOptionValue }));
395
- }
396
- ;
397
- get _elem() { return index.getElement(this); }
398
- static get watchers() { return {
399
- "value": ["updateValue"]
400
- }; }
401
- };
402
- EzSearch.style = ezSearchCss;
403
-
404
- const ezTextAreaCss = ":host{--text-area--width:100%;--text-area--border-radius:var(--border--radius-medium, 12px);--text-area--font-size:var(--text--medium, 14px);--text-area--font-family:var(--font-pattern, Arial);--text-area--font-weight:var(--text-weight--large, 500);--text-area--color:var(--title--primary, #000);--text-area__input--background-color:var(--background--medium, #e0e0e0);--text-area__input--border:var(--border--medium, 2px solid);--text-area__input--border-color:var(--text-area__input--background-color);--text-area__input--focus--border-color:var(--color--primary, #008561);--text-area__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--text-area__input--disabled--color:var(--text--disable, #AFB6C0);--text-area__input--error--border-color:#CC2936;--text-area__message_box--font-size:var(--text--small, 12px);--text-area__message_box--info--color:var(--color--success, #22085d);--text-area__message_box--error--color:var(--color--error, #FF0000);--text-area__label--floating--top:6px;--text-area__label--padding-top:12px;--text-area__label--padding-left:14px;--text-area__label--padding-right:12px;display:flex;flex-wrap:wrap;position:relative;width:var(--text-area--width)}textarea{box-sizing:border-box;border:none;resize:none;margin-top:calc(var(--space--medium, 12px) + 4px);width:100%;font-weight:var(--text-weight--large, 600);font-family:var(--text-area--font-family);font-size:var(--text-area--font-size);color:var(--text-area--color);padding:0;background:none}textarea:focus{outline:none}textarea:disabled{background-color:transparent;color:var(--text-area__input--disabled--color)}.textarea{width:100%;box-sizing:border-box;padding-left:var(--space--medium);padding-right:var(--space--extra-small);border-radius:var(--text-area--border-radius);border:var(--text-area__input--border);border-color:var(--text-area__input--border-color);background-color:var(--text-area__input--background-color)}.textarea--focus{border-color:var(--text-area__input--focus--border-color)}.textarea.hasError{color:var(--text-area--color);border-color:var(--text-area__input--error--border-color)}.message-box{min-height:16px;min-width:100%;margin-top:2px;line-height:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--text-area--font-family);font-size:var(--text-area__message_box--font-size);color:var(--text-area__message_box--info--color)}.hasError{color:var(--text-area__message_box--error--color)}.textarea__label{box-sizing:border-box;position:absolute;z-index:var(--visible);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;-webkit-transition:font-size .05s, top .05s;transition:font-size .05s, top .05s;width:calc(100% - var(--text-area__label--padding-right));left:var(--text-area--space--medium);font-family:var(--text-area--font-family);font-size:var(--text-area--font-size);font-weight:var(--text-area--font-weight);color:var(--text-area--color);top:var(--text-area__label--padding-top);left:var(--text-area__label--padding-left);padding-right:var(--text-area__label--padding-right)}.textarea__label--floated{font-family:var(--text-area--font-family);font-size:var(--text--extra-small);color:var(--text--primary);top:var(--text-area__label--floating--top)}.textarea__label--disabled{color:var(--text-area__input--disabled--color)}";
405
-
406
- let EzTextArea = class {
407
- constructor(hostRef) {
408
- index.registerInstance(this, hostRef);
409
- this.ezChange = index.createEvent(this, "ezChange", 7);
410
- /**
411
- * Deixa o campo disponível ou não para digitação.
412
- */
413
- this.enabled = true;
414
- /**
415
- * Ajusta o número de linhas e consequentemente o height do textarea. Valor default: 4
416
- */
417
- this.rows = 4;
418
- }
419
- showError() {
420
- const hasError = typeof this.errorMessage === 'string' && this.errorMessage !== '';
421
- if (hasError) {
422
- this._container.classList.add('hasError');
423
- this._messageBoxElem.classList.add('hasError');
424
- }
425
- else {
426
- this._container.classList.remove('hasError');
427
- this._messageBoxElem.classList.remove('hasError');
428
- }
429
- }
430
- updateInputValue() {
431
- this._inputElem.value = this.value;
432
- this.handleChange();
433
- this.adjustFloatingLabel();
434
- this.ezChange.emit(this.value);
435
- }
436
- adjustFloatingLabel() {
437
- if (this.label) {
438
- const hasValue = this.value && this.value.toString().length > 0;
439
- const containsFloatedClass = this._labelElem.classList.contains("textarea__label--floated");
440
- if (hasValue || this.isFocused()) {
441
- if (!containsFloatedClass) {
442
- this._labelElem.classList.add("textarea__label--floated");
443
- }
444
- }
445
- else {
446
- if (containsFloatedClass) {
447
- this._labelElem.classList.remove("textarea__label--floated");
448
- }
449
- }
450
- }
451
- }
452
- isFocused() {
453
- return this._hostElement.shadowRoot.activeElement !== null;
454
- }
455
- //---------------------------------------------
456
- // Public methods
457
- //---------------------------------------------
458
- /**
459
- * Faz o foco no componente de input
460
- */
461
- async setFocus() {
462
- this._inputElem.focus();
463
- }
464
- /**
465
- * Remove o foco no componente de input
466
- */
467
- async setBlur() {
468
- this._inputElem.blur();
469
- }
470
- //---------------------------------------------
471
- // Event handlers
472
- //---------------------------------------------
473
- handleFocusout() {
474
- this.adjustFloatingLabel();
475
- if (this._container && this._container.classList.contains("textarea--focus")) {
476
- this._container.classList.remove("textarea--focus");
477
- }
478
- }
479
- handleChange() {
480
- this.errorMessage = "";
481
- this.value = this._inputElem.value;
482
- }
483
- handleFocus() {
484
- if (this.label && this._labelElem && !this._labelElem.classList.contains("textarea__label--floated")) {
485
- this._labelElem.classList.add("textarea__label--floated");
486
- }
487
- if (this._container && !this._container.classList.contains("textarea--focus")) {
488
- this._container.classList.add("textarea--focus");
489
- }
490
- }
491
- //---------------------------------------------
492
- // Lifecycle web component
493
- //---------------------------------------------
494
- componentDidLoad() {
495
- this.showError();
496
- this.adjustFloatingLabel();
497
- }
498
- render() {
499
- return (index.h(index.Host, null, index.h("div", { class: "textarea", ref: (el) => this._container = el }, this.label ?
500
- index.h("label", { ref: (el) => this._labelElem = el, class: this.enabled ? "textarea__label" : "textarea__label textarea__label--disabled", onClick: () => this._inputElem.focus(), title: this.label }, this.label)
501
- : null, index.h("textarea", { onFocus: () => this.handleFocus(), ref: (el) => this._inputElem = el, value: this.value, disabled: !this.enabled, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); }, onKeyDown: event => event.stopPropagation(), rows: this.rows })), index.h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errorMessage }, this.errorMessage)));
502
- }
503
- get _hostElement() { return index.getElement(this); }
504
- static get watchers() { return {
505
- "errorMessage": ["showError"],
506
- "value": ["updateInputValue"]
507
- }; }
508
- };
509
- EzTextArea.style = ezTextAreaCss;
510
-
511
- class RemoteFile {
512
- constructor(file) {
513
- this.file = file;
514
- this.size = file.size;
515
- this.name = file.name;
516
- }
517
- abortUpload() {
518
- if (this._uploadingXhr) {
519
- this._aborted = true;
520
- this._uploadingXhr.abort();
521
- this._uploadingXhr = undefined;
522
- }
523
- }
524
- isUploading() {
525
- return this._uploadingXhr !== undefined;
526
- }
527
- async upload(server, headers, updateCallBack) {
528
- return new Promise((resolve, reject) => {
529
- const xhr = new XMLHttpRequest();
530
- this._uploadingXhr = xhr;
531
- this._aborted = false;
532
- this.progress = 0;
533
- xhr.upload.onprogress = (e) => {
534
- const loaded = e.loaded;
535
- const total = e.total;
536
- this.progress = ~~((loaded / total) * 100);
537
- updateCallBack(this, loaded, total);
538
- };
539
- xhr.onreadystatechange = () => {
540
- if (xhr.readyState == 4) {
541
- this._uploadingXhr = undefined;
542
- const status = xhr.status;
543
- if (!this._aborted) {
544
- if (status === 0) {
545
- reject("Servidor indisponível");
546
- }
547
- else if (status >= 500) {
548
- reject("Erro inesperado no servidor");
549
- }
550
- else if (status >= 400) {
551
- reject("Operação não permitida");
552
- }
553
- }
554
- const response = xhr.response;
555
- if (response) {
556
- resolve(JSON.parse(response));
557
- }
558
- }
559
- };
560
- xhr.ontimeout = () => {
561
- reject("Tempo limite de transferência atingido.");
562
- };
563
- const formData = new FormData();
564
- formData.append("ARQUIVO", this.file, this.file.name);
565
- xhr.open("POST", server, true);
566
- if (headers) {
567
- headers.forEach((value, key) => xhr.setRequestHeader(key, value));
568
- }
569
- xhr.send(formData);
570
- });
571
- }
572
- async delete(item, server, headers) {
573
- return new Promise((resolve, reject) => {
574
- const xhr = new XMLHttpRequest();
575
- xhr.onreadystatechange = () => {
576
- if (xhr.readyState == 4) {
577
- if (xhr.status === 0) {
578
- reject("Servidor indisponível");
579
- }
580
- else if (xhr.status >= 500) {
581
- reject("Erro inesperado no servidor");
582
- }
583
- else if (xhr.status >= 400) {
584
- reject("Operação não permitida");
585
- }
586
- resolve(true);
587
- }
588
- };
589
- xhr.ontimeout = () => {
590
- reject("Tempo limite de remoção atingido.");
591
- };
592
- xhr.open("DELETE", server, true);
593
- if (headers) {
594
- headers.forEach((value, key) => xhr.setRequestHeader(key, value));
595
- }
596
- xhr.send(JSON.stringify(item));
597
- });
598
- }
599
- }
600
-
601
- const ezUploadCss = ":host{--ez-upload--height:42px;--ez-upload--width:100%;--ez-upload__icon--width:48px;--ez-upload__container--background-color:var(--background--medium, #d2dce9);--ez-upload__color--primary:var(--color--primary, #008561);--ez-upload--padding--extra-small:var(--space--extra-small, 3px);--ez-upload--padding--small:var(--space--small, 6px);--ez-upload--padding--medium:var(--space--medium, 12px);--ez-upload--padding--large:var(--space--large, 24px);--ez-upload__border--color:var(--color-strokes, #DCE0E8);--ez-upload--text-shadow:var(--text-shadow, 0 0 0 #353535, 0 0 1px transparent);--ez-upload--text--primary:var(--text-primary, #626e82);--ez-upload--font-size:var(--text--medium, 14px);--ez-upload--font-family:var(--font-pattern, Arial);--ez-upload--font-weight:var(--text-weight--large, 500);--ez-upload__btn__cancel-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"8x\" width=\"8px\"><path d=\"M 8,0.8 7.2,0 4,3.2 0.8,0 0,0.8 3.2,4 0,7.2 0.8,8 4,4.8 7.2,8 8,7.2 4.8,4 Z\"/></svg>');--ez-upload__file-icon-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"11x\" width=\"9px\"><path d=\"M 1.2272719,8.4999999 V 2.75 c 0,-1.1045695 1.4652499,-2 3.2727273,-2 1.8074777,0 3.2727281,0.8954305 3.2727281,2 V 8.9999999 C 7.7727273,9.690356 6.8569456,10.25 5.7272719,10.25 4.5975985,10.25 3.6818174,9.690356 3.6818174,8.9999999 V 3.75 c 0,-0.2761425 0.3663125,-0.5 0.8181818,-0.5 0.4518694,0 0.8181818,0.2238575 0.8181818,0.5 V 8.4999999 H 6.5454537 V 3.75 C 6.5454537,3.059644 5.6296725,2.5 4.4999992,2.5 3.3703258,2.5 2.4545446,3.059644 2.4545446,3.75 V 8.9999999 C 2.4545446,10.10457 3.9197945,11 5.7272719,11 7.5347496,11 9,10.10457 9,8.9999999 V 2.75 C 9,1.231217 6.9852809,0 4.4999992,0 2.0147181,5e-7 0,1.231217 0,2.75 v 5.7499999 z\"/></svg>');display:flex;flex-wrap:wrap;position:relative;font-family:var(--ez-upload--font-family);font-size:var(--ez-upload--font-size);width:var(--ez-upload--width);font-weight:var(--ez-upload--font-weight)}.iu{display:flex;flex-wrap:wrap;background-color:var(--ez-upload__container--background-color);padding:var(--ez-upload--padding--small);width:100%;border-radius:12px;box-sizing:border-box}.iu__container{width:100%;display:flex;flex-wrap:wrap;justify-content:center;align-items:center;border:2px dashed var(--ez-upload__border--color);border-radius:6px;box-sizing:border-box}.iu__footer{display:flex;flex-wrap:wrap;justify-content:flex-start;width:100%;padding:0 var(--ez-upload--padding--medium) var(--ez-upload--padding--medium) var(--ez-upload--padding--medium);box-sizing:border-box}.iu__item{display:flex;width:100%;justify-content:flex-start;align-items:center;align-self:center;padding-bottom:var(--ez-upload--padding--extra-small);box-sizing:border-box;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.iu__item-label{display:flex;max-width:80%;align-self:stretch;align-items:center}.file__name{font-weight:200}.box__content{width:100%;justify-content:center;align-items:center;height:100%;border:1px dashed var(--ez-upload__border--color);border-radius:6px;box-sizing:border-box}.box__container{display:flex;flex-wrap:wrap;background-color:var(--ez-upload__container--background-color);padding:6px;width:100%;border-radius:12px}a:-webkit-any-link{color:#008561;fill:#008561;cursor:pointer;text-decoration:none}progress[value]{display:flex;width:100%;appearance:none;border:1px solid var(--ez-upload__border--color);height:12px;justify-content:flex-start;align-items:center;border-radius:3px;position:relative}progress[value]::-webkit-progress-bar{display:flex;-webkit-appearance:none;width:100%;background-color:rgb(255, 255, 255);border-radius:2px;padding:2px}progress[value]::-webkit-progress-value{display:flex;width:100%;background-color:var(--ez-upload__color--primary)}.text--center{text-align:center}.align--middle{align-self:center;align-items:center}.text{font-family:\"Sora\", \"Algerian\";text-shadow:0 0 0 #353535, 0 0 1px transparent}.text--primary{color:var(--ez-upload--text--primary);text-shadow:var(--ez-upload--text-shadow)}.text--ellipsis{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.text--medium{font-size:14px}.text--small{font-size:12px}.btn-cancel{outline:none;border:none;background-color:unset;cursor:pointer}.btn-cancel::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:8px;height:8px;-webkit-mask-image:var(--ez-upload__btn__cancel-image);mask-image:var(--ez-upload__btn__cancel-image)}.iu_header{display:flex;flex-direction:column;width:100%}.iu__label{padding:var(--space--small);box-sizing:border-box;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--ez-upload--font-family);font-size:var(--text--extra-small);font-weight:var(--ez-upload--font-weight);color:var(--ez-upload--text--primary);text-shadow:var(--ez-upload--text-shadow)}.iu__file-icon{outline:none;border:none;background-color:unset;cursor:pointer}.iu__file-icon:disabled{cursor:unset}.iu__file-icon::after{content:'';display:flex;background-color:var(--text--primary, #626e82);width:9px;height:11px;-webkit-mask-image:var(--ez-upload__file-icon-image);mask-image:var(--ez-upload__file-icon-image)}.iu__file-icon:disabled::after{background-color:var(--text--disable, #AFB6C0)}.iu__icon-label{justify-content:center;display:flex;cursor:pointer;padding:var(--ez-upload--padding--large) 0px;box-sizing:border-box}.background--disabled{background-color:var(--color--disable-secondary, #F2F5F8)}.text--disabled{color:var(--text--disable, #AFB6C0)}.mouse-pointer--disabled{cursor:unset}.row{width:100%;display:flex;flex-wrap:wrap}.col{display:flex;flex-wrap:wrap;align-self:flex-start;box-sizing:border-box}.col--stretch{align-self:stretch}.col--undefined{width:unset}.col--nowrap{flex-wrap:nowrap}@media screen and (min-width: 320px){.col--sd-1{width:8.33333%}.col--sd-2{width:16.66667%}.col--sd-3{width:25%}.col--sd-4{width:33.33333%}.col--sd-5{width:41.66667%}.col--sd-6{width:50%}.col--sd-7{width:58.33333%}.col--sd-8{width:66.66667%}.col--sd-9{width:75%}.col--sd-10{width:83.33333%}.col--sd-11{width:91.66667%}.col--sd-12{width:100%}}@media screen and (min-width: 480px){.col--pn-1{width:8.33333%}.col--pn-2{width:16.66667%}.col--pn-3{width:25%}.col--pn-4{width:33.33333%}.col--pn-5{width:41.66667%}.col--pn-6{width:50%}.col--pn-7{width:58.33333%}.col--pn-8{width:66.66667%}.col--pn-9{width:75%}.col--pn-10{width:83.33333%}.col--pn-11{width:91.66667%}.col--pn-12{width:100%}}@media screen and (min-width: 768px){.col--tb-1{width:8.33333%}.col--tb-2{width:16.66667%}.col--tb-3{width:25%}.col--tb-4{width:33.33333%}.col--tb-5{width:41.66667%}.col--tb-6{width:50%}.col--tb-7{width:58.33333%}.col--tb-8{width:66.66667%}.col--tb-9{width:75%}.col--tb-10{width:83.33333%}.col--tb-11{width:91.66667%}.col--tb-12{width:100%}}@media screen and (min-width: 992px){.col--md-1{width:8.33333%}.col--md-2{width:16.66667%}.col--md-3{width:25%}.col--md-4{width:33.33333%}.col--md-5{width:41.66667%}.col--md-6{width:50%}.col--md-7{width:58.33333%}.col--md-8{width:66.66667%}.col--md-9{width:75%}.col--md-10{width:83.33333%}.col--md-11{width:91.66667%}.col--md-12{width:100%}}@media screen and (min-width: 1200px){.col--ld-1{width:8.33333%}.col--ld-2{width:16.66667%}.col--ld-3{width:25%}.col--ld-4{width:33.33333%}.col--ld-5{width:41.66667%}.col--ld-6{width:50%}.col--ld-7{width:58.33333%}.col--ld-8{width:66.66667%}.col--ld-9{width:75%}.col--ld-10{width:83.33333%}.col--ld-11{width:91.66667%}.col--ld-12{width:100%}}";
602
-
603
- let EzUpload = class {
604
- constructor(hostRef) {
605
- index.registerInstance(this, hostRef);
606
- this.ezChange = index.createEvent(this, "ezChange", 7);
607
- this._filePointers = new Map();
608
- /**
609
- * Deixa o campo disponível ou não para digitação.
610
- */
611
- this.enabled = true;
612
- }
613
- changeValue(newValue) {
614
- if (newValue !== this._updatingValue) {
615
- this._filePointers.forEach(f => {
616
- if (this.isRemoteFile(f)) {
617
- f.abortUpload();
618
- }
619
- });
620
- this._filePointers = new Map();
621
- this.updateFilePointers();
622
- }
623
- this._updatingValue = undefined;
624
- }
625
- updateFilePointers() {
626
- if (this.value) {
627
- this.value.forEach(ezFile => this._filePointers.set(ezFile.name, ezFile));
628
- }
629
- }
630
- normalizeRequestHeaders() {
631
- this._requestHeaders = new Map();
632
- if (typeof this.requestHeaders == "string") {
633
- try {
634
- this.requestHeaders = JSON.parse(this.requestHeaders);
635
- }
636
- catch (e) {
637
- this.requestHeaders = undefined;
638
- }
639
- }
640
- for (var key in this.requestHeaders) {
641
- this._requestHeaders.set(key, this.requestHeaders[key]);
642
- }
643
- }
644
- /**
645
- * Método responsável por adicionar um ou mais arquivos ao componente.
646
- */
647
- async addFiles(files) {
648
- if (this.maxFiles > 0) {
649
- let countDistinctFiles = this._filePointers.size;
650
- files.forEach(file => {
651
- if (!this._filePointers.has(file.name)) {
652
- countDistinctFiles++;
653
- }
654
- });
655
- if (countDistinctFiles > this.maxFiles) {
656
- this.showError(`A quantidade máxima de arquivos é ${this.maxFiles}.`);
657
- return;
658
- }
659
- }
660
- Array.prototype.forEach.call(files, this.addFile.bind(this));
661
- }
662
- async addFile(file) {
663
- const oldFile = this._filePointers.get(file.name);
664
- if (oldFile) {
665
- ApplicationUtils.ApplicationUtils.confirm("Substituir arquivo", `Já existe um arquivo chamado "${file.name}". Deseja substituí-lo?`)
666
- .then(ok => {
667
- if (ok) {
668
- if (this.isRemoteFile(oldFile)) {
669
- oldFile.abortUpload();
670
- }
671
- this.doAddFile(file);
672
- }
673
- });
674
- }
675
- else {
676
- this.doAddFile(file);
677
- }
678
- }
679
- async doAddFile(file) {
680
- if (this.validateFile(file)) {
681
- const uploadingFile = new RemoteFile(file);
682
- this._filePointers.set(file.name, uploadingFile);
683
- uploadingFile.upload(this.urlUpload, this._requestHeaders, (file) => this.updateFeedback(file))
684
- .then((files) => files.forEach(ezFile => this.finishUpload(ezFile)))
685
- .catch(msg => this.showError(msg));
686
- index.forceUpdate(this);
687
- }
688
- }
689
- finishUpload(ezFile) {
690
- this._filePointers.set(ezFile.name, ezFile);
691
- this.updateValue();
692
- }
693
- updateValue() {
694
- this._updatingValue = [];
695
- this._filePointers.forEach(f => {
696
- if (!this.isRemoteFile(f)) {
697
- this._updatingValue.push(f);
698
- }
699
- });
700
- this.value = this._updatingValue;
701
- this.ezChange.emit(this.value);
702
- }
703
- buildProgressId(uploading) {
704
- let sanitizedName = uploading.name.replace(/[^a-z0-9_]/gi, "_");
705
- return `PROGRESS_${sanitizedName}_${uploading.file.lastModified}`;
706
- }
707
- updateFeedback(uf) {
708
- window.requestAnimationFrame(() => {
709
- if (this._host) {
710
- const progress = this._host.shadowRoot.querySelector("#" + this.buildProgressId(uf));
711
- if (progress) {
712
- progress.value = uf.progress;
713
- }
714
- }
715
- });
716
- }
717
- validateFile(file) {
718
- if (!this._filePointers.has(file.name) && this.maxFiles > 0 && this._filePointers.size >= this.maxFiles) {
719
- this.showError(`A quantidade máxima de arquivos é ${this.maxFiles}.`);
720
- return false;
721
- }
722
- if (file.size === 0) {
723
- this.showError(`Erro de permissão: O arquivo "${file.name}" não pode ser enviado.`);
724
- return false;
725
- }
726
- if (!this.urlUpload) {
727
- this.showError("Endereço de upload não informado");
728
- return false;
729
- }
730
- if (this.maxFileSize >= 0 && file.size > this.maxFileSize) {
731
- this.showError("O tamanho máximo dos arquivos é de " + this.formatBytes(this.maxFileSize));
732
- return false;
733
- }
734
- return true;
735
- }
736
- showError(message) {
737
- ApplicationUtils.ApplicationUtils.alert("Enviando arquivo", message);
738
- }
739
- formatBytes(bytes, decimals = 1) {
740
- if (bytes === 0)
741
- return "0 Bytes";
742
- const k = 1024;
743
- const dm = decimals < 0 ? 0 : decimals;
744
- const sizes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
745
- const i = Math.floor(Math.log(bytes) / Math.log(k));
746
- return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
747
- }
748
- onFileInputChange(event) {
749
- const input = event.target;
750
- this.addFiles(Array.from(input.files));
751
- this._fileInput.value = "";
752
- }
753
- isRemoteFile(item) {
754
- return "file" in item;
755
- }
756
- removeFromList(name) {
757
- this._filePointers.delete(name);
758
- this.updateValue();
759
- }
760
- removeFile(name) {
761
- const item = this._filePointers.get(name);
762
- if (this.isRemoteFile(item)) {
763
- item.abortUpload();
764
- this.removeFromList(name);
765
- }
766
- else {
767
- if (this.urlDelete) {
768
- const uploadingFile = new RemoteFile(null);
769
- this._filePointers.set(item.name, uploadingFile);
770
- uploadingFile.delete(item, this.urlDelete, null)
771
- .then(_ok => this.removeFromList(name))
772
- .catch(msg => this.showError(msg));
773
- }
774
- else {
775
- this.removeFromList(name);
776
- }
777
- }
778
- }
779
- openFilesDialog() {
780
- if (this.enabled) {
781
- this._fileInput.click();
782
- }
783
- }
784
- componentDidLoad() {
785
- if (this.enabled && this._dropZone && window.FileList && window.File) {
786
- this._dropZone.addEventListener("dragover", event => {
787
- event.stopPropagation();
788
- event.preventDefault();
789
- event.dataTransfer.dropEffect = "copy";
790
- this._dropZone.style.background = "#c2dbff";
791
- });
792
- this._dropZone.addEventListener("drop", event => {
793
- event.stopPropagation();
794
- event.preventDefault();
795
- this.addFiles(Array.from(event.dataTransfer.files));
796
- this._dropZone.style.background = "";
797
- });
798
- this._dropZone.addEventListener("dragleave", _event => {
799
- this._dropZone.style.background = "";
800
- });
801
- }
802
- }
803
- componentWillRender() {
804
- if (this.value) {
805
- if (this._filePointers.size < this.value.length) {
806
- this.updateFilePointers();
807
- }
808
- }
809
- }
810
- render() {
811
- return (index.h("div", { ref: (el) => this._dropZone = el, class: this.evalDisabledClass("iu", "background--disabled") }, index.h("div", { class: "iu__container", onClick: () => this.openFilesDialog() }, index.h("div", { class: "iu_header" }, this.label ? index.h("label", { class: this.evalDisabledClass("iu__label", "text--disabled"), title: this.label }, this.label) : null, index.h("div", { class: this.evalDisabledClass("iu__icon-label", "mouse-pointer--disabled") }, index.h("button", { class: "iu__file-icon", disabled: !this.enabled }), index.h("div", { class: this.evalDisabledClass("text text--center text--medium text--primary", "text--disabled") }, this.enabled ? "Arraste e solte ou clique para adicionar arquivos" : "Somente leitura"))), this.buildFooter()), index.h("input", { ref: (el) => this._fileInput = el, onChange: (ev) => this.onFileInputChange(ev), type: "file", multiple: true, hidden: true })));
812
- }
813
- buildFooter() {
814
- if (this._filePointers.size === 0) {
815
- return null;
816
- }
817
- const items = [];
818
- this._filePointers.forEach(item => items.push(this.buildFileItem(item)));
819
- return (index.h("div", { class: "iu__footer" }, items));
820
- }
821
- buildFileItem(item) {
822
- const fileName = item.name;
823
- const progress = Number(item["progress"]);
824
- const downloadURL = item["downloadURL"];
825
- const label = `${fileName} (${this.formatBytes(item.size)})`;
826
- return (index.h("div", { class: "iu__item", key: fileName, onClick: evt => evt.stopPropagation() }, index.h("div", { class: "iu__item-label modificador" }, index.h("div", { title: label, class: "col--stretch align--middle file__name text text--primary text--small text--ellipsis align--middle" }, downloadURL ? index.h("a", { href: downloadURL, download: true }, label) : label)), isNaN(progress)
827
- ?
828
- null
829
- :
830
- index.h("div", { class: "col col--sd-4 col--stretch align--middle" }, index.h("progress", { id: this.buildProgressId(item), value: progress, max: "100" })), this.enabled
831
- ?
832
- index.h("div", { class: "col col--stretch align--middle" }, index.h("button", { class: "btn-cancel ", onClick: () => this.removeFile(fileName) }))
833
- :
834
- null));
835
- }
836
- evalDisabledClass(regularClasses, disabledClass) {
837
- return this.enabled ? regularClasses : `${regularClasses} ${disabledClass}`;
838
- }
839
- get _host() { return index.getElement(this); }
840
- static get watchers() { return {
841
- "value": ["changeValue"],
842
- "requestHeaders": ["normalizeRequestHeaders"]
843
- }; }
844
- };
845
- EzUpload.style = ezUploadCss;
846
-
847
- exports.ez_collapsible_box = EzCollapsibleBox;
848
- exports.ez_date_input = EzDateInput;
849
- exports.ez_date_time_input = EzDateTimeInput;
850
- exports.ez_number_input = EzNumberInput;
851
- exports.ez_search = EzSearch;
852
- exports.ez_text_area = EzTextArea;
853
- exports.ez_upload = EzUpload;