@sankhyalabs/sankhyablocks 1.1.24 → 1.1.25

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 (180) hide show
  1. package/dist/cjs/ApplicationUtils-05b74ee9.js +39 -0
  2. package/dist/cjs/AssetsUtils-7e3c38f9.js +24 -0
  3. package/dist/cjs/CSSVarsUtils-75ca9c64.js +19 -0
  4. package/dist/cjs/ez-action-chip.cjs.entry.js +27 -0
  5. package/dist/cjs/ez-application.cjs.entry.js +26 -0
  6. package/dist/cjs/ez-button_4.cjs.entry.js +660 -0
  7. package/dist/cjs/ez-calendar.cjs.entry.js +223 -0
  8. package/dist/cjs/ez-collapsible-box.cjs.entry.js +47 -0
  9. package/dist/cjs/ez-combo-box.cjs.entry.js +278 -0
  10. package/dist/cjs/ez-date-input.cjs.entry.js +102 -0
  11. package/dist/cjs/ez-date-time-input.cjs.entry.js +145 -0
  12. package/dist/cjs/ez-dialog.cjs.entry.js +89 -0
  13. package/dist/cjs/ez-form.cjs.entry.js +463 -0
  14. package/dist/cjs/ez-grid.cjs.entry.js +647 -0
  15. package/dist/cjs/ez-icon.cjs.entry.js +41 -0
  16. package/dist/cjs/ez-label-chip.cjs.entry.js +104 -0
  17. package/dist/cjs/ez-modal_2.cjs.entry.js +316 -0
  18. package/dist/cjs/ez-number-input.cjs.entry.js +86 -0
  19. package/dist/cjs/ez-popover.cjs.entry.js +120 -0
  20. package/dist/cjs/ez-popup.cjs.entry.js +48 -0
  21. package/dist/cjs/ez-search.cjs.entry.js +64 -0
  22. package/dist/cjs/ez-tabselector.cjs.entry.js +198 -0
  23. package/dist/cjs/ez-text-area.cjs.entry.js +114 -0
  24. package/dist/cjs/ez-text-input.cjs.entry.js +201 -0
  25. package/dist/cjs/ez-time-input.cjs.entry.js +118 -0
  26. package/dist/cjs/ez-toast.cjs.entry.js +44 -0
  27. package/dist/cjs/ez-upload.cjs.entry.js +356 -0
  28. package/dist/cjs/index-682c98b2.js +1771 -0
  29. package/dist/cjs/loader.cjs.js +2 -2
  30. package/dist/cjs/sankhyablocks.cjs.js +2 -2
  31. package/dist/cjs/snk-application.cjs.entry.js +6 -41
  32. package/dist/cjs/test-du.cjs.entry.js +76 -0
  33. package/dist/collection/collection-manifest.json +36 -1
  34. package/dist/collection/components/snk-application/snk-application.js +2 -1
  35. package/dist/{collection/temp → components}/ApplicationUtils.js +37 -36
  36. package/dist/components/AssetsUtils.js +22 -0
  37. package/dist/components/CSSVarsUtils.js +17 -0
  38. package/dist/components/ez-action-chip.js +44 -0
  39. package/dist/components/ez-application.js +39 -0
  40. package/dist/components/ez-button.js +6 -0
  41. package/dist/components/ez-button2.js +105 -0
  42. package/dist/components/ez-calendar.js +6 -0
  43. package/dist/components/ez-calendar2.js +242 -0
  44. package/dist/components/ez-check.js +6 -0
  45. package/dist/components/ez-check2.js +94 -0
  46. package/dist/components/ez-collapsible-box.js +67 -0
  47. package/dist/components/ez-combo-box.js +6 -0
  48. package/dist/components/ez-combo-box2.js +311 -0
  49. package/dist/components/ez-date-input.js +135 -0
  50. package/dist/components/ez-date-time-input.js +179 -0
  51. package/dist/components/ez-dialog.js +124 -0
  52. package/dist/components/ez-form.js +6 -0
  53. package/dist/components/ez-form2.js +485 -0
  54. package/dist/components/ez-grid.js +738 -0
  55. package/dist/components/ez-icon.js +6 -0
  56. package/dist/components/ez-icon2.js +56 -0
  57. package/dist/components/ez-label-chip.js +125 -0
  58. package/dist/components/ez-list.js +6 -0
  59. package/dist/components/ez-list2.js +523 -0
  60. package/dist/components/ez-modal.js +6 -0
  61. package/dist/components/ez-modal2.js +82 -0
  62. package/dist/components/ez-number-input.js +115 -0
  63. package/dist/components/ez-popover.js +145 -0
  64. package/dist/components/ez-popup.js +67 -0
  65. package/dist/components/ez-search.js +100 -0
  66. package/dist/components/ez-tabselector.js +6 -0
  67. package/dist/components/ez-tabselector2.js +213 -0
  68. package/dist/components/ez-text-area.js +137 -0
  69. package/dist/components/ez-text-input.js +6 -0
  70. package/dist/components/ez-text-input2.js +223 -0
  71. package/dist/components/ez-time-input.js +153 -0
  72. package/dist/components/ez-toast.js +64 -0
  73. package/dist/components/ez-upload.js +382 -0
  74. package/dist/components/grid-config.js +6 -0
  75. package/dist/components/grid-config2.js +318 -0
  76. package/dist/components/select-box.js +6 -0
  77. package/dist/components/select-box2.js +47 -0
  78. package/dist/components/snk-application.js +1 -36
  79. package/dist/components/test-du.js +101 -0
  80. package/dist/esm/ApplicationUtils-e0b6d857.js +37 -0
  81. package/dist/esm/AssetsUtils-6e6624dc.js +22 -0
  82. package/dist/esm/CSSVarsUtils-0787c3f3.js +17 -0
  83. package/dist/esm/ez-action-chip.entry.js +23 -0
  84. package/dist/esm/ez-application.entry.js +22 -0
  85. package/dist/esm/ez-button_4.entry.js +653 -0
  86. package/dist/esm/ez-calendar.entry.js +219 -0
  87. package/dist/esm/ez-collapsible-box.entry.js +43 -0
  88. package/dist/esm/ez-combo-box.entry.js +274 -0
  89. package/dist/esm/ez-date-input.entry.js +98 -0
  90. package/dist/esm/ez-date-time-input.entry.js +141 -0
  91. package/dist/esm/ez-dialog.entry.js +85 -0
  92. package/dist/esm/ez-form.entry.js +459 -0
  93. package/dist/esm/ez-grid.entry.js +643 -0
  94. package/dist/esm/ez-icon.entry.js +37 -0
  95. package/dist/esm/ez-label-chip.entry.js +100 -0
  96. package/dist/esm/ez-modal_2.entry.js +311 -0
  97. package/dist/esm/ez-number-input.entry.js +82 -0
  98. package/dist/esm/ez-popover.entry.js +116 -0
  99. package/dist/esm/ez-popup.entry.js +44 -0
  100. package/dist/esm/ez-search.entry.js +60 -0
  101. package/dist/esm/ez-tabselector.entry.js +194 -0
  102. package/dist/esm/ez-text-area.entry.js +110 -0
  103. package/dist/esm/ez-text-input.entry.js +197 -0
  104. package/dist/esm/ez-time-input.entry.js +114 -0
  105. package/dist/esm/ez-toast.entry.js +40 -0
  106. package/dist/esm/ez-upload.entry.js +352 -0
  107. package/dist/esm/index-35088a3f.js +1740 -0
  108. package/dist/esm/loader.js +2 -2
  109. package/dist/esm/sankhyablocks.js +2 -2
  110. package/dist/esm/snk-application.entry.js +2 -37
  111. package/dist/esm/test-du.entry.js +72 -0
  112. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-action-chip/ez-action-chip.css +67 -0
  113. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-application/ez-application.css +3 -0
  114. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-button/ez-button.css +180 -0
  115. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-calendar/ez-calendar.css +319 -0
  116. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-check/ez-check.css +327 -0
  117. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-collapsible-box/ez-collapsible-box.css +162 -0
  118. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-combo-box/ez-combo-box.css +217 -0
  119. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-date-input/ez-date-input.css +49 -0
  120. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-date-time-input/ez-date-time-input.css +44 -0
  121. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-dialog/ez-dialog.css +527 -0
  122. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-form/ez-form.css +5 -0
  123. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/ez-grid.css +31 -0
  124. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/subcomponents/gridconfig/grid-config.css +129 -0
  125. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/subcomponents/select-box/select-box.css +10 -0
  126. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-icon/ez-icon.css +176 -0
  127. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-label-chip/ez-label-chip.css +139 -0
  128. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-list/ez-list.css +335 -0
  129. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-modal/ez-modal.css +358 -0
  130. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-number-input/ez-number-input.css +4 -0
  131. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-popover/ez-popover.css +44 -0
  132. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-popup/ez-popup.css +405 -0
  133. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-search/ez-search.css +3 -0
  134. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-tabselector/ez-tabselector.css +138 -0
  135. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-text-area/ez-text-area.css +165 -0
  136. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-text-input/ez-text-input.css +196 -0
  137. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-time-input/ez-time-input.css +10 -0
  138. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-toast/ez-toast.css +127 -0
  139. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-upload/ez-upload.css +568 -0
  140. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/test-du/test-du.css +3 -0
  141. package/dist/sankhyablocks/p-0183d259.entry.js +1 -0
  142. package/dist/sankhyablocks/p-01f23a70.entry.js +1 -0
  143. package/dist/sankhyablocks/p-07c32f68.entry.js +1 -0
  144. package/dist/sankhyablocks/p-0f90499d.entry.js +1 -0
  145. package/dist/sankhyablocks/p-105724a3.entry.js +1 -0
  146. package/dist/sankhyablocks/p-2ac02d48.entry.js +1 -0
  147. package/dist/sankhyablocks/p-35364a97.entry.js +1 -0
  148. package/dist/sankhyablocks/p-3f6aa9a7.entry.js +1 -0
  149. package/dist/sankhyablocks/p-5f9af495.entry.js +1 -0
  150. package/dist/sankhyablocks/p-60967cf0.js +1 -0
  151. package/dist/sankhyablocks/p-6ce33b60.entry.js +57 -0
  152. package/dist/sankhyablocks/p-70ad6c16.entry.js +1 -0
  153. package/dist/sankhyablocks/p-710bfffe.entry.js +1 -0
  154. package/dist/sankhyablocks/p-735440c1.entry.js +1 -0
  155. package/dist/sankhyablocks/p-811b4b9d.js +1 -0
  156. package/dist/sankhyablocks/p-813fe4f7.js +1 -0
  157. package/dist/sankhyablocks/p-85a9446b.js +2 -0
  158. package/dist/sankhyablocks/p-89a1100f.entry.js +1 -0
  159. package/dist/sankhyablocks/p-8b543003.entry.js +1 -0
  160. package/dist/sankhyablocks/p-9750632b.entry.js +1 -0
  161. package/dist/sankhyablocks/p-a96272f7.entry.js +1 -0
  162. package/dist/sankhyablocks/p-ac8842e5.entry.js +1 -0
  163. package/dist/sankhyablocks/p-ba64cc41.entry.js +1 -0
  164. package/dist/sankhyablocks/p-c1ede043.entry.js +1 -0
  165. package/dist/sankhyablocks/p-d90ebb85.entry.js +1 -0
  166. package/dist/sankhyablocks/p-e17dfaae.entry.js +1 -0
  167. package/dist/sankhyablocks/p-e5355a29.entry.js +1 -0
  168. package/dist/sankhyablocks/p-ef04b633.entry.js +1 -0
  169. package/dist/sankhyablocks/p-f6db07fb.entry.js +1 -0
  170. package/dist/sankhyablocks/p-fcd9bd92.entry.js +1 -0
  171. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  172. package/package.json +1 -1
  173. package/react/components.d.ts +29 -0
  174. package/react/components.js +29 -0
  175. package/react/components.js.map +1 -1
  176. package/dist/cjs/index-4720dab8.js +0 -735
  177. package/dist/esm/index-72d4e2e0.js +0 -709
  178. package/dist/sankhyablocks/p-45635e4f.entry.js +0 -57
  179. package/dist/sankhyablocks/p-a33afc3b.js +0 -2
  180. package/dist/types/temp/ApplicationUtils.d.ts +0 -11
@@ -0,0 +1,118 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-682c98b2.js');
6
+ const core = require('@sankhyalabs/core');
7
+ const CSSVarsUtils = require('./CSSVarsUtils-75ca9c64.js');
8
+ const AssetsUtils = require('./AssetsUtils-7e3c38f9.js');
9
+
10
+ const ezTimeInputCss = ":host{display:flex;flex-wrap:wrap;position:relative;width:100%}";
11
+
12
+ const EzTimeInput = class {
13
+ constructor(hostRef) {
14
+ index.registerInstance(this, hostRef);
15
+ /**
16
+ * Deixa o campo disponível ou não para digitação.
17
+ */
18
+ this.enabled = true;
19
+ /**
20
+ * Define se o componente irá ou não considerar os segundos
21
+ */
22
+ this.showSeconds = false;
23
+ }
24
+ prepareMask() {
25
+ if (this.showSeconds) {
26
+ if (this._maskFormatter == undefined) {
27
+ this._maskFormatter = new core.MaskFormatter("##:##:##");
28
+ }
29
+ else {
30
+ this._maskFormatter.mask = "##:##:##";
31
+ }
32
+ }
33
+ else {
34
+ if (this._maskFormatter == undefined) {
35
+ this._maskFormatter = new core.MaskFormatter("##:##");
36
+ }
37
+ else {
38
+ this._maskFormatter.mask = "##:##";
39
+ }
40
+ }
41
+ }
42
+ onValueChanged() {
43
+ if (this.value === NaN) {
44
+ this.value = undefined;
45
+ this.handleFocusout();
46
+ }
47
+ }
48
+ //---------------------------------------------
49
+ // Public methods
50
+ //---------------------------------------------
51
+ /**
52
+ * Faz o foco no componente de input
53
+ */
54
+ async setFocus() {
55
+ this._inputElem.focus();
56
+ }
57
+ /**
58
+ * Remove o foco no componente de input
59
+ */
60
+ async setBlur() {
61
+ this._inputElem.blur();
62
+ }
63
+ //---------------------------------------------
64
+ // Event handlers
65
+ //---------------------------------------------
66
+ handleFocusout() {
67
+ this.errorMessage = "";
68
+ this.prepareValue(this.viewValue);
69
+ if (!core.TimeFormatter.validateTime(this.viewValue, this.showSeconds)) {
70
+ this.clearField();
71
+ this.errorMessage = "Favor inserir um horário válido.";
72
+ }
73
+ }
74
+ prepareValue(value) {
75
+ try {
76
+ this.viewValue = core.TimeFormatter.prepareValue(value, this.showSeconds);
77
+ }
78
+ catch (e) {
79
+ this.clearField();
80
+ this.errorMessage = e.message;
81
+ }
82
+ }
83
+ clearField() {
84
+ this.viewValue = this.value = undefined;
85
+ }
86
+ handleChange() {
87
+ this.viewValue = this._inputElem.value;
88
+ this.value = core.NumberUtils.stringToNumber(this.viewValue.replace(/\D/g, ""));
89
+ }
90
+ //---------------------------------------------
91
+ // Lifecycle web component
92
+ //---------------------------------------------
93
+ componentDidLoad() {
94
+ this.onValueChanged();
95
+ CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._inputElem);
96
+ }
97
+ componentWillLoad() {
98
+ this.prepareMask();
99
+ if (this.value) {
100
+ this.prepareValue(this.value.toString());
101
+ }
102
+ else if (this.viewValue) {
103
+ this.prepareValue(this.viewValue);
104
+ }
105
+ }
106
+ render() {
107
+ return (index.h(index.Host, null, index.h("ez-text-input", { ref: (el) => this._inputElem = el, value: this.viewValue, enabled: this.enabled, label: this.label, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); }, errorMessage: this.errorMessage }, index.h("ez-icon", { slot: "leftIcon", href: AssetsUtils.getSpritePath("timer-outline") }))));
108
+ }
109
+ static get assetsDirs() { return ["../assets"]; }
110
+ get _elem() { return index.getElement(this); }
111
+ static get watchers() { return {
112
+ "showSeconds": ["prepareMask"],
113
+ "value": ["onValueChanged"]
114
+ }; }
115
+ };
116
+ EzTimeInput.style = ezTimeInputCss;
117
+
118
+ exports.ez_time_input = EzTimeInput;
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-682c98b2.js');
6
+
7
+ const ezToastCss = ":host{--ez-toast__btn__close__image:url('data:image/svg+xml;utf8,<svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" xmlns=\"http://www.w3.org/2000/svg%22%3E<path d=\"M 7.0060773,5.995511 11.461972,1.5397722 c 0.132856,-0.1328413 0.207547,-0.3130253 0.207547,-0.5009046 0,-0.18786999 -0.07469,-0.3680541 -0.207547,-0.5009048 -0.132857,-0.13284126 -0.31302,-0.20748126 -0.500927,-0.20748126 -0.187812,0 -0.36807,0.07464 -0.500926,0.20748126 L 6.0042244,4.9937015 1.5482921,0.5379628 C 1.4154357,0.40512154 1.2352533,0.33048154 1.0473657,0.33048154 c -0.18787813,0 -0.36807,0.07464 -0.50092647,0.20748126 -0.13285646,0.1328507 -0.20749026,0.31303481 -0.20749026,0.5009048 0,0.1878793 0.0746338,0.3680633 0.20749026,0.5009046 L 5.0023715,5.995511 0.54643923,10.452213 c -0.0676086,0.06534 -0.12151598,0.14352 -0.15859681,0.229916 -0.0370714,0.08639 -0.0565645,0.1794 -0.0573369,0.27335 -7.724e-4,0.09404 0.0171873,0.187331 0.0528423,0.274293 0.0356455,0.08705 0.0882688,0.166087 0.15479148,0.23256 0.0665321,0.06648 0.14562277,0.11897 0.2326735,0.154567 0.0870507,0.0356 0.18031463,0.05344 0.2743433,0.05259 0.094029,-8.5e-4 0.1869528,-0.02049 0.2733331,-0.0576 0.08639,-0.0372 0.1645078,-0.09121 0.2298029,-0.158817 L 6.0042244,6.9973204 10.460119,11.453078 c 0.132856,0.132851 0.313114,0.207444 0.500926,0.207444 0.187907,0 0.36807,-0.07459 0.500927,-0.207444 0.132856,-0.13285 0.207547,-0.313006 0.207547,-0.500904 0,-0.187898 -0.07469,-0.368054 -0.207547,-0.500905 z\"/></svg>');--ez-toast__container-z-index:var(--more-visible, 2);--ez-toast__container--background-color:var(--color--secondary, #383c45);--ez-toast__icon--padding-left:var(--space--small, 6px)}.toast__container{position:fixed;display:flex;bottom:100px;z-index:var(--ez-toast__container-z-index);left:100px;width:280px;box-sizing:border-box;background-color:var(--ez-toast__container--background-color);border-radius:6px;align-items:center;padding:12px;visibility:hidden}.message__container{font-family:\"Sora\", \"Algerian\";text-shadow:0 0 0 #353535, 0 0 1px transparent;color:#FFFFFF;font-size:14px;width:90%;overflow:hidden;word-break:break-all;height:auto;-webkit-box-orient:vertical;-webkit-line-clamp:4;display:-webkit-box;text-overflow:ellipsis}.message__conteiner--icon{padding-left:var(--ez-toast__icon--padding-left);width:80%}.btn-close{margin-top:3px;display:flex;justify-content:flex-end;align-self:flex-start;padding:0;outline:none;width:10%;border:none;background-color:unset;cursor:pointer}.btn-close::after{content:'';display:flex;background-color:#FFFFFF;width:12px;height:12px;-webkit-mask-image:var(--ez-toast__btn__close__image);mask-image:var(--ez-toast__btn__close__image)}.toast__container--oppened{animation:fadein 0.5s, fadeout 0.5s 3s;visibility:visible}@-webkit-keyframes fadein{from{left:-100px;opacity:0}to{left:100px;opacity:1}}@keyframes fadein{from{left:-100px;opacity:0}to{left:100px;opacity:1}}@-webkit-keyframes fadeout{from{left:100px;opacity:1}to{bottom:0;opacity:0}}@keyframes fadeout{from{left:100px;opacity:1}to{bottom:0;opacity:0}}";
8
+
9
+ const EzToast = class {
10
+ constructor(hostRef) {
11
+ index.registerInstance(this, hostRef);
12
+ /**
13
+ * Controla o tempo de exibição do componente em milissegundos.
14
+ */
15
+ this.fadeTime = 5000;
16
+ /**
17
+ * Adiciona ícone de check no componente.
18
+ */
19
+ this.useIcon = false;
20
+ /**
21
+ * Controla o uso do icone de fechar o toast.
22
+ */
23
+ this.canClose = true;
24
+ }
25
+ /**
26
+ * Exibe o componente na tela.
27
+ */
28
+ async show() {
29
+ this.container.classList.add("toast__container--oppened");
30
+ this.container.style.animation = `fadein 0.5s, fadeout 0.5s ${this.fadeTime / 1000}s`;
31
+ setTimeout(() => {
32
+ this.container.classList.remove("toast__container--oppened");
33
+ this.container.style.animation = `none`;
34
+ }, this.fadeTime + 400);
35
+ }
36
+ render() {
37
+ return (index.h("div", { ref: (el) => this.container = el, class: "toast__container" }, this.useIcon &&
38
+ index.h("slot", { name: "icon" }), index.h("div", { class: this.useIcon ? "message__container message__conteiner--icon" : "message__container", title: this.message, innerHTML: this.message }), this.canClose &&
39
+ index.h("button", { class: "btn-close", onClick: () => { this.container.classList.remove("toast__container--oppened"); this.container.style.animation = `none`; } })));
40
+ }
41
+ };
42
+ EzToast.style = ezToastCss;
43
+
44
+ exports.ez_toast = EzToast;
@@ -0,0 +1,356 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-682c98b2.js');
6
+ const ApplicationUtils = require('./ApplicationUtils-05b74ee9.js');
7
+
8
+ class RemoteFile {
9
+ constructor(file) {
10
+ this.file = file;
11
+ this.size = file.size;
12
+ this.name = file.name;
13
+ }
14
+ abortUpload() {
15
+ if (this._uploadingXhr) {
16
+ this._aborted = true;
17
+ this._uploadingXhr.abort();
18
+ this._uploadingXhr = undefined;
19
+ }
20
+ }
21
+ isUploading() {
22
+ return this._uploadingXhr !== undefined;
23
+ }
24
+ async upload(server, headers, updateCallBack) {
25
+ return new Promise((resolve, reject) => {
26
+ const xhr = new XMLHttpRequest();
27
+ this._uploadingXhr = xhr;
28
+ this._aborted = false;
29
+ this.progress = 0;
30
+ xhr.upload.onprogress = (e) => {
31
+ const loaded = e.loaded;
32
+ const total = e.total;
33
+ this.progress = ~~((loaded / total) * 100);
34
+ updateCallBack(this, loaded, total);
35
+ };
36
+ xhr.onreadystatechange = () => {
37
+ if (xhr.readyState == 4) {
38
+ this._uploadingXhr = undefined;
39
+ const status = xhr.status;
40
+ if (!this._aborted) {
41
+ if (status === 0) {
42
+ reject("Servidor indisponível");
43
+ }
44
+ else if (status >= 500) {
45
+ reject("Erro inesperado no servidor");
46
+ }
47
+ else if (status >= 400) {
48
+ reject("Operação não permitida");
49
+ }
50
+ }
51
+ const response = xhr.response;
52
+ if (response) {
53
+ resolve(JSON.parse(response));
54
+ }
55
+ }
56
+ };
57
+ xhr.ontimeout = () => {
58
+ reject("Tempo limite de transferência atingido.");
59
+ };
60
+ const formData = new FormData();
61
+ formData.append("ARQUIVO", this.file, this.file.name);
62
+ xhr.open("POST", server, true);
63
+ if (headers) {
64
+ headers.forEach((value, key) => xhr.setRequestHeader(key, value));
65
+ }
66
+ xhr.send(formData);
67
+ });
68
+ }
69
+ async delete(item, server, headers) {
70
+ return new Promise((resolve, reject) => {
71
+ const xhr = new XMLHttpRequest();
72
+ xhr.onreadystatechange = () => {
73
+ if (xhr.readyState == 4) {
74
+ if (xhr.status === 0) {
75
+ reject("Servidor indisponível");
76
+ }
77
+ else if (xhr.status >= 500) {
78
+ reject("Erro inesperado no servidor");
79
+ }
80
+ else if (xhr.status >= 400) {
81
+ reject("Operação não permitida");
82
+ }
83
+ resolve(true);
84
+ }
85
+ };
86
+ xhr.ontimeout = () => {
87
+ reject("Tempo limite de remoção atingido.");
88
+ };
89
+ xhr.open("DELETE", server, true);
90
+ if (headers) {
91
+ headers.forEach((value, key) => xhr.setRequestHeader(key, value));
92
+ }
93
+ xhr.send(JSON.stringify(item));
94
+ });
95
+ }
96
+ }
97
+
98
+ 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}.appearanceNone{width:0px;height:0px}.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%}}";
99
+
100
+ const EzUpload = class {
101
+ constructor(hostRef) {
102
+ index.registerInstance(this, hostRef);
103
+ this.ezChange = index.createEvent(this, "ezChange", 7);
104
+ this._filePointers = new Map();
105
+ /**
106
+ * Deixa o campo disponível ou não para digitação.
107
+ */
108
+ this.enabled = true;
109
+ }
110
+ changeValue(newValue) {
111
+ if (newValue !== this._updatingValue) {
112
+ this._filePointers.forEach(f => {
113
+ if (this.isRemoteFile(f)) {
114
+ f.abortUpload();
115
+ }
116
+ });
117
+ this._filePointers = new Map();
118
+ this.updateFilePointers();
119
+ }
120
+ this._updatingValue = undefined;
121
+ }
122
+ updateFilePointers() {
123
+ if (this.value) {
124
+ this.value.forEach(ezFile => this._filePointers.set(ezFile.name, ezFile));
125
+ }
126
+ }
127
+ normalizeRequestHeaders() {
128
+ this._requestHeaders = new Map();
129
+ if (typeof this.requestHeaders == "string") {
130
+ try {
131
+ this.requestHeaders = JSON.parse(this.requestHeaders);
132
+ }
133
+ catch (e) {
134
+ this.requestHeaders = undefined;
135
+ }
136
+ }
137
+ for (var key in this.requestHeaders) {
138
+ this._requestHeaders.set(key, this.requestHeaders[key]);
139
+ }
140
+ }
141
+ /**
142
+ * Método responsável por adicionar um ou mais arquivos ao componente.
143
+ */
144
+ async addFiles(files) {
145
+ if (this.maxFiles > 0) {
146
+ let countDistinctFiles = this._filePointers.size;
147
+ files.forEach(file => {
148
+ if (!this._filePointers.has(file.name)) {
149
+ countDistinctFiles++;
150
+ }
151
+ });
152
+ if (countDistinctFiles > this.maxFiles) {
153
+ this.showError(`A quantidade máxima de arquivos é ${this.maxFiles}.`);
154
+ return;
155
+ }
156
+ }
157
+ Array.prototype.forEach.call(files, this.addFile.bind(this));
158
+ }
159
+ /**
160
+ * Realiza o foco no componente de upload
161
+ */
162
+ async setFocus() {
163
+ this._fileInput.focus();
164
+ }
165
+ /**
166
+ * Remove o foco no componente de upload
167
+ */
168
+ async setBlur() {
169
+ this._fileInput.blur();
170
+ }
171
+ async addFile(file) {
172
+ const oldFile = this._filePointers.get(file.name);
173
+ if (oldFile) {
174
+ ApplicationUtils.ApplicationUtils.confirm("Substituir arquivo", `Já existe um arquivo chamado "${file.name}". Deseja substituí-lo?`)
175
+ .then(ok => {
176
+ if (ok) {
177
+ if (this.isRemoteFile(oldFile)) {
178
+ oldFile.abortUpload();
179
+ }
180
+ this.doAddFile(file);
181
+ }
182
+ });
183
+ }
184
+ else {
185
+ this.doAddFile(file);
186
+ }
187
+ }
188
+ async doAddFile(file) {
189
+ if (this.validateFile(file)) {
190
+ const uploadingFile = new RemoteFile(file);
191
+ this._filePointers.set(file.name, uploadingFile);
192
+ uploadingFile.upload(this.urlUpload, this._requestHeaders, (file) => this.updateFeedback(file))
193
+ .then((files) => files.forEach(ezFile => this.finishUpload(ezFile)))
194
+ .catch(msg => this.showError(msg));
195
+ index.forceUpdate(this);
196
+ }
197
+ }
198
+ finishUpload(ezFile) {
199
+ this._filePointers.set(ezFile.name, ezFile);
200
+ this.updateValue();
201
+ }
202
+ updateValue() {
203
+ this._updatingValue = [];
204
+ this._filePointers.forEach(f => {
205
+ if (!this.isRemoteFile(f)) {
206
+ this._updatingValue.push(f);
207
+ }
208
+ });
209
+ this.value = this._updatingValue;
210
+ this.ezChange.emit(this.value);
211
+ }
212
+ buildProgressId(uploading) {
213
+ let sanitizedName = uploading.name.replace(/[^a-z0-9_]/gi, "_");
214
+ return `PROGRESS_${sanitizedName}_${uploading.file.lastModified}`;
215
+ }
216
+ updateFeedback(uf) {
217
+ window.requestAnimationFrame(() => {
218
+ if (this._host) {
219
+ const progress = this._host.shadowRoot.querySelector("#" + this.buildProgressId(uf));
220
+ if (progress) {
221
+ progress.value = uf.progress;
222
+ }
223
+ }
224
+ });
225
+ }
226
+ validateFile(file) {
227
+ if (!this._filePointers.has(file.name) && this.maxFiles > 0 && this._filePointers.size >= this.maxFiles) {
228
+ this.showError(`A quantidade máxima de arquivos é ${this.maxFiles}.`);
229
+ return false;
230
+ }
231
+ if (file.size === 0) {
232
+ this.showError(`Erro de permissão: O arquivo "${file.name}" não pode ser enviado.`);
233
+ return false;
234
+ }
235
+ if (!this.urlUpload) {
236
+ this.showError("Endereço de upload não informado");
237
+ return false;
238
+ }
239
+ if (this.maxFileSize >= 0 && file.size > this.maxFileSize) {
240
+ this.showError("O tamanho máximo dos arquivos é de " + this.formatBytes(this.maxFileSize));
241
+ return false;
242
+ }
243
+ return true;
244
+ }
245
+ showError(message) {
246
+ ApplicationUtils.ApplicationUtils.alert("Enviando arquivo", message);
247
+ }
248
+ formatBytes(bytes, decimals = 1) {
249
+ if (bytes === 0)
250
+ return "0 Bytes";
251
+ const k = 1024;
252
+ const dm = decimals < 0 ? 0 : decimals;
253
+ const sizes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
254
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
255
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
256
+ }
257
+ onFileInputChange(event) {
258
+ const input = event.target;
259
+ this.addFiles(Array.from(input.files));
260
+ this._fileInput.value = "";
261
+ }
262
+ isRemoteFile(item) {
263
+ return "file" in item;
264
+ }
265
+ removeFromList(name) {
266
+ this._filePointers.delete(name);
267
+ this.updateValue();
268
+ }
269
+ removeFile(name) {
270
+ const item = this._filePointers.get(name);
271
+ if (this.isRemoteFile(item)) {
272
+ item.abortUpload();
273
+ this.removeFromList(name);
274
+ }
275
+ else {
276
+ if (this.urlDelete) {
277
+ const uploadingFile = new RemoteFile(null);
278
+ this._filePointers.set(item.name, uploadingFile);
279
+ uploadingFile.delete(item, this.urlDelete, null)
280
+ .then(_ok => this.removeFromList(name))
281
+ .catch(msg => this.showError(msg));
282
+ }
283
+ else {
284
+ this.removeFromList(name);
285
+ }
286
+ }
287
+ }
288
+ openFilesDialog() {
289
+ if (this.enabled) {
290
+ this._fileInput.click();
291
+ }
292
+ }
293
+ componentDidLoad() {
294
+ if (this.enabled && this._dropZone && window.FileList && window.File) {
295
+ this._dropZone.addEventListener("dragover", event => {
296
+ event.stopPropagation();
297
+ event.preventDefault();
298
+ event.dataTransfer.dropEffect = "copy";
299
+ this._dropZone.style.background = "#c2dbff";
300
+ });
301
+ this._dropZone.addEventListener("drop", event => {
302
+ event.stopPropagation();
303
+ event.preventDefault();
304
+ this.addFiles(Array.from(event.dataTransfer.files));
305
+ this._dropZone.style.background = "";
306
+ });
307
+ this._dropZone.addEventListener("dragleave", _event => {
308
+ this._dropZone.style.background = "";
309
+ });
310
+ }
311
+ }
312
+ componentWillRender() {
313
+ if (this.value) {
314
+ if (this._filePointers.size < this.value.length) {
315
+ this.updateFilePointers();
316
+ }
317
+ }
318
+ }
319
+ render() {
320
+ 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, class: "appearanceNone" })));
321
+ }
322
+ buildFooter() {
323
+ if (this._filePointers.size === 0) {
324
+ return null;
325
+ }
326
+ const items = [];
327
+ this._filePointers.forEach(item => items.push(this.buildFileItem(item)));
328
+ return (index.h("div", { class: "iu__footer" }, items));
329
+ }
330
+ buildFileItem(item) {
331
+ const fileName = item.name;
332
+ const progress = Number(item["progress"]);
333
+ const downloadURL = item["downloadURL"];
334
+ const label = `${fileName} (${this.formatBytes(item.size)})`;
335
+ 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)
336
+ ?
337
+ null
338
+ :
339
+ 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
340
+ ?
341
+ index.h("div", { class: "col col--stretch align--middle" }, index.h("button", { class: "btn-cancel ", onClick: () => this.removeFile(fileName) }))
342
+ :
343
+ null));
344
+ }
345
+ evalDisabledClass(regularClasses, disabledClass) {
346
+ return this.enabled ? regularClasses : `${regularClasses} ${disabledClass}`;
347
+ }
348
+ get _host() { return index.getElement(this); }
349
+ static get watchers() { return {
350
+ "value": ["changeValue"],
351
+ "requestHeaders": ["normalizeRequestHeaders"]
352
+ }; }
353
+ };
354
+ EzUpload.style = ezUploadCss;
355
+
356
+ exports.ez_upload = EzUpload;