@sankhyalabs/ezui 1.1.76 → 1.1.77

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 (164) hide show
  1. package/dist/cjs/ApplicationUtils-d1c1db56.js +35 -0
  2. package/dist/cjs/AssetsUtils-dd585fba.js +24 -0
  3. package/dist/cjs/DataUnit-fdd7c70e.js +474 -0
  4. package/dist/cjs/DateUtils-716769e0.js +46 -0
  5. package/dist/cjs/ez-action-chip.cjs.entry.js +1 -1
  6. package/dist/cjs/ez-application.cjs.entry.js +28 -0
  7. package/dist/cjs/ez-button_11.cjs.entry.js +111771 -0
  8. package/dist/cjs/ez-calendar.cjs.entry.js +212 -0
  9. package/dist/cjs/ez-collapsible-box_6.cjs.entry.js +630 -0
  10. package/dist/cjs/ez-combo-box.cjs.entry.js +250 -0
  11. package/dist/cjs/ez-date-time-input.cjs.entry.js +144 -0
  12. package/dist/cjs/ez-dialog.cjs.entry.js +1 -1
  13. package/dist/cjs/ez-form.cjs.entry.js +1838 -0
  14. package/dist/cjs/ez-label-chip.cjs.entry.js +1 -1
  15. package/dist/cjs/ez-number-input.cjs.entry.js +61 -190
  16. package/dist/cjs/ez-popover.cjs.entry.js +3 -3
  17. package/dist/cjs/ez-popup.cjs.entry.js +2 -2
  18. package/dist/cjs/ez-time-input.cjs.entry.js +9 -27
  19. package/dist/cjs/ez-toast.cjs.entry.js +1 -1
  20. package/dist/cjs/ezui.cjs.js +3 -3
  21. package/dist/cjs/form-metadata.cjs.entry.js +129 -0
  22. package/dist/cjs/index-262d703b.js +7442 -0
  23. package/dist/cjs/{index-9431aeeb.js → index-4e4bae01.js} +1 -5
  24. package/dist/cjs/loader.cjs.js +3 -3
  25. package/dist/collection/collection-manifest.json +8 -3
  26. package/dist/collection/components/ez-application/ez-application.css +3 -0
  27. package/dist/collection/components/ez-application/ez-application.js +37 -0
  28. package/dist/collection/components/ez-button/ez-button.css +16 -1
  29. package/dist/collection/components/ez-button/ez-button.js +27 -2
  30. package/dist/collection/components/ez-calendar/ez-calendar.css +70 -3
  31. package/dist/collection/components/ez-calendar/ez-calendar.js +168 -24
  32. package/dist/collection/components/ez-check/ez-check.css +78 -78
  33. package/dist/collection/components/ez-check/ez-check.js +3 -3
  34. package/dist/collection/components/ez-combo-box/ez-combo-box.css +67 -51
  35. package/dist/collection/components/ez-combo-box/ez-combo-box.js +1 -0
  36. package/dist/collection/components/ez-date-time-input/ez-date-time-input.css +49 -0
  37. package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +254 -0
  38. package/dist/collection/components/ez-form/subcomponents/DataUnit.js +4 -4
  39. package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +1 -1
  40. package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +2 -2
  41. package/dist/collection/components/ez-grid/controller/DataUnitBridge.js +21 -0
  42. package/dist/collection/components/ez-grid/controller/EzGridController.js +1 -0
  43. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +203 -0
  44. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +41 -0
  45. package/dist/collection/components/ez-grid/controller/ag-grid/i18n/pt-BR.js +75 -0
  46. package/dist/collection/components/ez-grid/controller/ag-grid/mock/Server.js +69 -0
  47. package/dist/collection/components/ez-grid/controller/ag-grid/template/HeaderColumnTemplate.js +12 -0
  48. package/dist/collection/components/ez-grid/ez-grid.css +15 -0
  49. package/dist/collection/components/ez-grid/ez-grid.js +414 -0
  50. package/dist/collection/components/ez-grid/subcomponents/gridconfig/grid-config.css +105 -0
  51. package/dist/collection/components/ez-grid/subcomponents/gridconfig/grid-config.js +354 -0
  52. package/dist/collection/components/ez-grid/subcomponents/select-box/select-box.css +7 -0
  53. package/dist/collection/components/ez-grid/subcomponents/select-box/select-box.js +66 -0
  54. package/dist/collection/components/ez-icon/ez-icon.css +1 -1
  55. package/dist/collection/components/ez-list/ez-list.css +227 -44
  56. package/dist/collection/components/ez-list/ez-list.js +529 -149
  57. package/dist/collection/components/ez-modal/ez-modal.css +4 -4
  58. package/dist/collection/components/ez-modal/ez-modal.js +1 -1
  59. package/dist/collection/components/ez-number-input/ez-number-input.css +7 -162
  60. package/dist/collection/components/ez-number-input/ez-number-input.js +90 -281
  61. package/dist/collection/components/ez-popover/ez-popover.css +10 -6
  62. package/dist/collection/components/ez-popup/ez-popup.css +25 -27
  63. package/dist/collection/components/ez-tabselector/ez-tabselector.css +0 -1
  64. package/dist/collection/components/ez-tabselector/ez-tabselector.js +3 -3
  65. package/dist/collection/components/ez-text-area/ez-text-area.js +1 -0
  66. package/dist/collection/components/ez-text-input/ez-text-input.js +1 -0
  67. package/dist/collection/components/ez-upload/ez-upload.js +3 -3
  68. package/dist/collection/components/test-du/test-du.css +3 -0
  69. package/dist/collection/components/test-du/test-du.js +45 -0
  70. package/dist/collection/servidor.js +94 -94
  71. package/dist/collection/utils/{Application.js → ApplicationUtils.js} +4 -4
  72. package/dist/custom-elements/index.d.ts +36 -6
  73. package/dist/custom-elements/index.js +120975 -3013
  74. package/dist/esm/ApplicationUtils-01280a9d.js +33 -0
  75. package/dist/esm/AssetsUtils-3803e935.js +22 -0
  76. package/dist/esm/DataUnit-1cd45202.js +464 -0
  77. package/dist/esm/DateUtils-0a1bbd7a.js +44 -0
  78. package/dist/esm/ez-action-chip.entry.js +1 -1
  79. package/dist/esm/ez-application.entry.js +24 -0
  80. package/dist/esm/ez-button_11.entry.js +111757 -0
  81. package/dist/esm/ez-calendar.entry.js +208 -0
  82. package/dist/esm/ez-collapsible-box_6.entry.js +621 -0
  83. package/dist/esm/ez-combo-box.entry.js +246 -0
  84. package/dist/esm/ez-date-time-input.entry.js +140 -0
  85. package/dist/esm/ez-dialog.entry.js +1 -1
  86. package/dist/esm/ez-form.entry.js +1834 -0
  87. package/dist/esm/ez-label-chip.entry.js +1 -1
  88. package/dist/esm/ez-number-input.entry.js +61 -190
  89. package/dist/esm/ez-popover.entry.js +3 -3
  90. package/dist/esm/ez-popup.entry.js +2 -2
  91. package/dist/esm/ez-time-input.entry.js +3 -21
  92. package/dist/esm/ez-toast.entry.js +1 -1
  93. package/dist/esm/ezui.js +3 -3
  94. package/dist/esm/form-metadata.entry.js +125 -0
  95. package/dist/esm/{index-fd3c8023.js → index-1dacecd3.js} +1 -5
  96. package/dist/esm/index-cfd5e193.js +7433 -0
  97. package/dist/esm/loader.js +3 -3
  98. package/dist/ezui/ezui.esm.js +1 -1
  99. package/dist/ezui/p-1ea8187e.entry.js +369 -0
  100. package/dist/ezui/p-37a611ea.js +1 -0
  101. package/dist/ezui/p-45689464.entry.js +1 -0
  102. package/dist/ezui/{p-a0b6eee2.entry.js → p-516d0e0f.entry.js} +1 -1
  103. package/dist/ezui/p-57291f97.entry.js +1 -0
  104. package/dist/ezui/{p-66954a04.entry.js → p-5a86e18a.entry.js} +1 -1
  105. package/dist/ezui/{p-823ff0a0.entry.js → p-5da66d3e.entry.js} +1 -1
  106. package/dist/ezui/p-69416bec.entry.js +1 -0
  107. package/dist/ezui/p-7107d7ef.js +1 -0
  108. package/dist/ezui/p-7ef97c5f.entry.js +1 -0
  109. package/dist/ezui/p-88f45a83.entry.js +1 -0
  110. package/dist/ezui/p-8c51a6aa.entry.js +1 -0
  111. package/dist/ezui/{p-e0ab3746.js → p-8f4851a6.js} +1 -1
  112. package/dist/ezui/p-9dfd537e.js +1 -0
  113. package/dist/ezui/{p-d443f020.entry.js → p-a18a2d7b.entry.js} +1 -1
  114. package/dist/ezui/p-a223eed8.entry.js +1 -0
  115. package/dist/ezui/p-b36308e7.js +1 -0
  116. package/dist/ezui/p-c0af195b.entry.js +1 -0
  117. package/dist/ezui/p-c6d469fc.entry.js +1 -0
  118. package/dist/ezui/p-c89629eb.js +1 -0
  119. package/dist/ezui/p-e7ee2836.entry.js +1 -0
  120. package/dist/ezui/p-f7b835cf.entry.js +1 -0
  121. package/dist/types/components/ez-application/ez-application.d.ts +12 -0
  122. package/dist/types/components/ez-button/ez-button.d.ts +5 -0
  123. package/dist/types/components/ez-calendar/ez-calendar.d.ts +21 -0
  124. package/dist/types/components/ez-check/ez-check.d.ts +1 -1
  125. package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +42 -0
  126. package/dist/types/components/ez-grid/controller/DataUnitBridge.d.ts +8 -0
  127. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +195 -0
  128. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +34 -0
  129. package/dist/types/components/ez-grid/controller/ag-grid/DataSource.d.ts +11 -0
  130. package/dist/types/components/ez-grid/controller/ag-grid/i18n/pt-BR.d.ts +2 -0
  131. package/dist/types/components/ez-grid/controller/ag-grid/mock/Server.d.ts +8 -0
  132. package/dist/types/components/ez-grid/ez-grid.d.ts +78 -0
  133. package/dist/types/components/ez-grid/subcomponents/gridconfig/grid-config.d.ts +30 -0
  134. package/dist/types/components/ez-grid/subcomponents/select-box/select-box.d.ts +9 -0
  135. package/dist/types/components/ez-list/ez-list.d.ts +70 -17
  136. package/dist/types/components/ez-number-input/ez-number-input.d.ts +33 -50
  137. package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +1 -1
  138. package/dist/types/components/test-du/test-du.d.ts +6 -0
  139. package/dist/types/components.d.ts +283 -117
  140. package/dist/types/stencil-public-runtime.d.ts +6 -4
  141. package/dist/types/utils/{Application.d.ts → ApplicationUtils.d.ts} +1 -1
  142. package/package.json +10 -8
  143. package/react/components.d.ts +6 -1
  144. package/react/components.js +6 -1
  145. package/react/components.js.map +1 -1
  146. package/dist/cjs/RequestMetadata-2cd01e8a.js +0 -531
  147. package/dist/cjs/ez-button_16.cjs.entry.js +0 -4079
  148. package/dist/cjs/ez-list.cjs.entry.js +0 -174
  149. package/dist/cjs/ez-modal.cjs.entry.js +0 -65
  150. package/dist/collection/components/ez-numeric-input/ez-numeric-input.css +0 -13
  151. package/dist/collection/components/ez-numeric-input/ez-numeric-input.js +0 -185
  152. package/dist/esm/RequestMetadata-c265c9d5.js +0 -527
  153. package/dist/esm/ez-button_16.entry.js +0 -4060
  154. package/dist/esm/ez-list.entry.js +0 -170
  155. package/dist/esm/ez-modal.entry.js +0 -61
  156. package/dist/ezui/p-11ae4ae7.entry.js +0 -1
  157. package/dist/ezui/p-47fa3d6c.entry.js +0 -1
  158. package/dist/ezui/p-8ab6168f.entry.js +0 -1
  159. package/dist/ezui/p-9c1fb51c.entry.js +0 -1
  160. package/dist/ezui/p-9d85125b.entry.js +0 -1
  161. package/dist/ezui/p-9dfccb16.js +0 -1
  162. package/dist/ezui/p-a7b546b2.entry.js +0 -1
  163. package/dist/ezui/p-c833c94f.entry.js +0 -1
  164. package/dist/types/components/ez-numeric-input/ez-numeric-input.d.ts +0 -45
@@ -1,4060 +0,0 @@
1
- import { r as registerInstance, h, c as createEvent, f as forceUpdate, H as Host, g as getElement } from './index-fd3c8023.js';
2
- import { N as NumberUtils, M as MaskFormatter } from './RequestMetadata-c265c9d5.js';
3
- import { F as FloatingManager } from './FloatingManager-bb90ef41.js';
4
- import { C as CSSVarsUtils } from './CSSVarsUtils-e0128b01.js';
5
-
6
- const ezButtonCss = ":host{--ez-button--min-width:100px;--ez-button--height:42px;--ez-button__icon--width:18px;--ez-button__inline__icon--padding:12px;--ez-button--padding-top:var(--space--medium, 12px);--ez-button--padding-bottom:var(--space--medium, 12px);--ez-button--padding-right:var(--space--large, 24px);--ez-button--padding-left:var(--space--large, 24px);--ez-button--color:var(--text--primary, #FFF);--ez-button--font-size:var(--text--medium, 14px);--ez-button--font-family:var(--font-pattern, Arial);--ez-button--font-weight:var(--text-weight--large);--ez-button--background-color:var(--background--medium, #c0c0c0);--ez-button--border-radius:var(--border--radius-large, 12px);--ez-button--border:none;--ez-button--hover--background-color:var(--background--strong, var(--ez-button--background-color));--ez-button--disabled-color:var(--text--disable);--ez-button--disabled--background-color:var(--color--disable-secondary);--ez-button--focus--border:var(--ez-button--border);--ez-button--focus--box-shadow:none;--ez-button--link-color:var(--title--primary, '#C0C0C0')}ez-icon{--ez-icon--color:inherit}button{display:flex;align-items:center;justify-content:center;margin:0;cursor:pointer;transition:background-color 0.2s linear;min-width:var(--ez-button--min-width);height:var(--ez-button--height);font-family:var(--ez-button--font-family);font-size:var(--ez-button--font-size);font-weight:var(--ez-button--font-weight);padding:var(--ez-button--padding-top) var(--ez-button--padding-right) var(--ez-button--padding-bottom) var(--ez-button--padding-left);border-radius:var(--ez-button--border-radius);background-color:var(--ez-button--background-color);color:var(--ez-button--color);fill:var(--ez-button--color);border:var(--ez-button--border)}button:hover{background-color:var(--ez-button--hover--background-color)}button:focus{outline:none;border:var(--ez-button--focus--border);box-shadow:var(--ez-button--focus--box-shadow)}button:disabled{background-color:var(--ez-button--disabled--background-color);color:var(--ez-button--disabled-color);fill:var(--ez-button--disabled-color);border:none;cursor:no-drop}button.icon{width:42px;min-width:42px;height:42px;padding:0px}.label-icon{display:flex;flex-direction:column;align-items:center;color:var(--ez-button--color)}.label-icon label{max-width:150px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer;font-family:var(--ez-button--font-family);font-size:var(--ez-button--font-size);font-weight:var(--ez-button--font-weight)}a{font-family:var(--ez-button--font-family);font-size:var(--ez-button--font-size);font-weight:var(--ez-button--font-weight);color:var(--ez-button--link-color);cursor:pointer;display:flex;align-items:center;justify-content:center;}";
7
-
8
- let EzButton = class {
9
- constructor(hostRef) {
10
- registerInstance(this, hostRef);
11
- /**
12
- * Deixa o botão disponível ou não para interação com o usuário.
13
- */
14
- this.enabled = true;
15
- /**
16
- * Define o modo de uso do botão; opções: icon, link e regular
17
- */
18
- this.mode = "regular";
19
- }
20
- handleSlotChange(ev) {
21
- const slot = ev.target;
22
- const content = slot.assignedElements()[0];
23
- if (this.mode == "link") {
24
- content.style.display = "inline";
25
- if (slot.name == "leftIcon") {
26
- content.style.paddingRight = "var(--ez-button__inline__icon--padding)";
27
- }
28
- else if (slot.name == "rightIcon") {
29
- content.style.paddingLeft = "var(--ez-button__inline__icon--padding)";
30
- }
31
- }
32
- else {
33
- content.style.setProperty('--ez-icon--color', 'var(--ez-icon--color)');
34
- }
35
- }
36
- render() {
37
- if (this.mode == "icon") {
38
- return (h("button", { class: "icon", type: "button", disabled: !this.enabled }, h("ez-icon", { class: "icon", href: this.image, size: "large", onClick: evt => {
39
- if (!this.enabled)
40
- evt.stopPropagation();
41
- } })));
42
- }
43
- else if (this.mode == "label-icon") {
44
- return (h("div", { class: "label-icon" }, h("button", { class: "icon", type: "button", disabled: !this.enabled }, h("ez-icon", { class: "icon", href: this.image, size: "large", onClick: evt => {
45
- if (!this.enabled)
46
- evt.stopPropagation();
47
- } })), h("label", { title: this.label }, this.label)));
48
- }
49
- else if (this.mode == "link") {
50
- return (h("a", null, h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label, h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } })));
51
- }
52
- else {
53
- return (h("button", { type: "button", disabled: !this.enabled }, h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label, h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } })));
54
- }
55
- }
56
- };
57
- EzButton.style = ezButtonCss;
58
-
59
- class DateUtils {
60
- static clearTime(date, adjustDayLightSavingTime = true) {
61
- const newDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0, 0);
62
- return adjustDayLightSavingTime ? DateUtils.adjustDLST(newDate) : newDate;
63
- }
64
- static strToDate(strValue, adjustDayLightSavingTime = true, monthYearMode = false) {
65
- /** monthYearMode é um booleano para usar o formato MM/YYYY.
66
- * Quando ativado, é retornado o primeiro dia do mês apenas para construir a data.
67
- * Não há necessidade de verificar o horário de verão quando utilizado esse modo. */
68
- let parts;
69
- if (monthYearMode) {
70
- 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);
71
- }
72
- else {
73
- 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);
74
- }
75
- if (!parts) {
76
- return undefined;
77
- }
78
- var day = monthYearMode ? 1 : Number(parts[1]);
79
- var month = Number(parts[(monthYearMode ? 1 : 2)]);
80
- var year = Number(parts[(monthYearMode ? 2 : 3)]);
81
- var hour = Number(parts[(monthYearMode ? 3 : 4)] || 0);
82
- var min = Number(parts[(monthYearMode ? 4 : 5)] || 0);
83
- var sec = Number(parts[(monthYearMode ? 5 : 6)] || 0);
84
- if (year < 100) {
85
- year += year < 30 ? 2000 : 1900;
86
- }
87
- let date = new Date(year, month - 1, day, hour, min, sec, 0);
88
- if (adjustDayLightSavingTime === true && !monthYearMode && hour == 0) {
89
- date = DateUtils.adjustDLST(date);
90
- }
91
- return date;
92
- }
93
- static adjustDLST(date) {
94
- //Work around para corrigir o Bug do horário de verão.
95
- if (date.getHours() == 23) {
96
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1, 1, 0, 0, 0);
97
- }
98
- return date;
99
- }
100
- }
101
-
102
- const ezCalendarCss = ":host{--ez-calendar--font-family:var(--font-pattern, Arial);--ez-calendar--color:var(--title--primary, #626e82);--ez-calendar--text-shadow:var(--text-shadow, 0 0 0 #353535, 0 0 1px transparent);--ez-calendar__body--background-color:var(--background--xlight, #FFF);--ez-calendar__body--padding:var(--space--medium, 12px);--ez-calendar__body--border-radius:var(--border--radius-medium, 12px);--ez-calendar__body--shadow:var(--shadow, 0px 0px 16px 0px #000);--ez-calendar__header-line--stroke:2px;--ez-calendar__header-line--color:var(--color--strokes, #C0C0C0);--ez-calendar__nav-btn--fill:var(--text--primary, #008561);--ez-calendar__nav-btn--hover--fill:var(--color--primary, #350404);--ez-calendar__nav-btn--width:10px;--ez-calendar__nav-btn--height:16px;--ez-calendar__nav-btn--previous-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"16px\" width=\"10px\"><path d=\"M 9.7808475,13.860393 3.9204526,8.0000004 9.7808475,2.0624965 7.9301965,0.28895552 0.21915255,8.0000004 7.9301965,15.711044 Z\"/></svg>');--ez-calendar__nav-btn--next-image: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-calendar__cell--margin:0px var(--space--small, 12px);--ez-calendar__cell--width:var(--space--large, 24px);--ez-calendar__cell--padding:var(--space--extra-small, 3px) 0px;--ez-calendar__cell--border-radius:var(--border--radius-small, 6px);--ez-calendar__cell--over--background-color:var(--color--strokes, #C0C0C0);--ez-calendar__cell--outset--color:var(--color--strokes, #C0C0C0);--ez-calendar__cell--selected--background-color:var(--color--primary, #008561);--ez-calendar__cell--selected--color:var(--color--inverted, #FFF);--ez-calendar__btn-today--color:var(--color--primary);--ez-calendar__btn-today--hover--background-color:var(--color--strokes, #C0C0C0);--ez-calendar__btn-today--border-radius:var(--border--radius-small, 6px);position:relative;display:flex;user-select:none}.calendar{z-index:var(--more-visible, 2);display:flex;flex-direction:column;background-color:var(--ez-calendar__body--background-color);padding:var(--ez-calendar__body--padding);border-radius:var(--ez-calendar__body--border-radius);box-shadow:var(--ez-calendar__body--shadow)}.calendar__header{display:flex;justify-content:space-between;padding-bottom:var(--space--medium, 12px);margin:var(--space--small, 6px) var(--space--, 12px);font-family:var(--ez-calendar--font-family);color:var(--ez-calendar--color);text-shadow:var(--ez-calendar--text-shadow);border-bottom:solid var(--ez-calendar__header-line--stroke) var(--ez-calendar__header-line--color)}.calendar__btn-next,.calendar__btn-previous{outline:none;border:none;background-color:unset;cursor:pointer;padding:0px}.calendar__btn-next::after,.calendar__btn-previous::after{content:'';display:flex;background-color:var(--ez-calendar__nav-btn--fill);width:var(--ez-calendar__nav-btn--width);height:var(--ez-calendar__nav-btn--height)}.calendar__btn-previous::after{-webkit-mask-image:var(--ez-calendar__nav-btn--previous-image);mask-image:var(--ez-calendar__nav-btn--previous-image)}.calendar__btn-next::after{-webkit-mask-image:var(--ez-calendar__nav-btn--next-image);mask-image:var(--ez-calendar__nav-btn--next-image)}.calendar__btn-next:hover::after,.calendar__btn-previous:hover::after{background-color:var(--ez-calendar__nav-btn--hover--fill)}.calendar__lbl-month{font-weight:var(--text-weight--large, 600);font-size:var(--title--medium, 16px);font-family:var(--ez-calendar--font-family);color:var(--ez-calendar--color);text-shadow:var(--ez-calendar--text-shadow)}.calendar__line{display:flex;padding:0px;margin:0px}.calendar__cell{display:flex;justify-content:center;align-content:center;cursor:pointer;font-size:var(--text--small, 12px);font-family:var(--ez-calendar--font-family);color:var(--ez-calendar--color);text-shadow:var(--ez-calendar--text-shadow);padding:var(--ez-calendar__cell--padding);margin:var(--ez-calendar__cell--margin);min-width:var(--ez-calendar__cell--width);border-radius:var(--ez-calendar__cell--border-radius)}.calendar__cell:hover{background-color:var(--ez-calendar__cell--over--background-color)}.calendar__cell--secondary{color:var(--ez-calendar__cell--outset--color)}.calendar__cell--unselectable:hover{background-color:unset;border-radius:unset;cursor:unset}.calendar__cell--unselectable{font-weight:var(--text-weight--large, 600);font-family:var(--ez-calendar--font-family);color:var(--ez-calendar--color);text-shadow:var(--ez-calendar--text-shadow)}.calendar__cell--selected,.calendar__cell--selected:hover{background-color:var(--ez-calendar__cell--selected--background-color);color:var(--ez-calendar__cell--selected--color)}.calendar__body{padding:var(--space--small, 6px) 0px}.calendar__footer{display:flex;flex-direction:column}.calendar__btn-today{border:none;background-color:unset;cursor:pointer;font-weight:var(--text-weight--large, 600);font-size:var(--title--small);padding:var(--space--extra-small, 6px);font-family:var(--ez-calendar--font-family);text-shadow:var(--ez-calendar--text-shadow);color:var(--ez-calendar__btn-today--color);border-radius:var(--ez-calendar__btn-today--border-radius)}.calendar__btn-today:hover{background-color:var(--ez-calendar__btn-today--hover--background-color)}";
103
-
104
- let EzCalendar = class {
105
- constructor(hostRef) {
106
- registerInstance(this, hostRef);
107
- this.ezChange = createEvent(this, "ezChange", 7);
108
- this._firstRender = true;
109
- this._todayLabel = "Hoje";
110
- this._weekDayLabels = ["D", "S", "T", "Q", "Q", "S", "S"];
111
- this._monthLabels = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
112
- /**
113
- * A data selecionada no calendário
114
- */
115
- this.value = new Date();
116
- /**
117
- * No modo floating o calendário só se tornará visível
118
- * quando o método show() for acionado.
119
- */
120
- this.floating = false;
121
- }
122
- /**
123
- * Usado no modo floating. Faz com que o componente seja exibido.
124
- * É possível determinar ajustes de posicionamento através dos parâmetros
125
- * top, left, bottom e right. Esses parâmetros devem ser informados como
126
- * strings no formato css.
127
- */
128
- async show(top, left, bottom, right) {
129
- if (this.floating) {
130
- this._floatingID = FloatingManager.float(this._box, this._container, { autoClose: true, top, left, bottom, right });
131
- window.requestAnimationFrame(() => {
132
- this._box.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
133
- });
134
- }
135
- }
136
- /**
137
- * Método necessário para ajustar o posicionamento do calendar acima ou abaixo do ez-date-input conforme a disponibilidade de espaço.
138
- */
139
- async fitVertical(topOffset, bottomOffset) {
140
- const neededHeight = this._container.getBoundingClientRect().bottom + this._calendarHeight;
141
- const availableBottom = (window.innerHeight || document.documentElement.clientHeight) > neededHeight;
142
- if (availableBottom) {
143
- this.show(topOffset + "px", undefined, "unset");
144
- }
145
- else {
146
- this.show("unset", undefined, bottomOffset + "px");
147
- }
148
- }
149
- /**
150
- * Usado no modo floating. Faz com que o componente seja ocultado.
151
- */
152
- async hide() {
153
- if (this._floatingID !== undefined) {
154
- FloatingManager.close(this._floatingID);
155
- this._floatingID = undefined;
156
- }
157
- }
158
- valueChanged() {
159
- if (this.value) {
160
- this._currentPosition.setTime(this.value.getTime());
161
- this._currentPosition.setDate(1);
162
- }
163
- }
164
- getMonthLabel() {
165
- return this._monthLabels[this._currentPosition.getMonth()] + " " + this._currentPosition.getFullYear();
166
- }
167
- isSelectedDate(d) {
168
- if (this.value) {
169
- return this.value.getDate() == d.getDate() && this.value.getMonth() == d.getMonth() && this.value.getFullYear() == d.getFullYear();
170
- }
171
- return false;
172
- }
173
- changeMonth(offset) {
174
- this._currentPosition.setMonth(this._currentPosition.getMonth() + offset);
175
- forceUpdate(this);
176
- }
177
- selectDate(d) {
178
- this.value = d;
179
- this.ezChange.emit();
180
- }
181
- componentDidRender() {
182
- if (this.floating && this._firstRender) {
183
- this._calendarHeight = this._box.clientHeight;
184
- this._box.remove();
185
- this._firstRender = false;
186
- }
187
- }
188
- render() {
189
- if (this._currentPosition == null) {
190
- this._currentPosition = new Date();
191
- this._currentPosition.setTime(this.value.getTime());
192
- this._currentPosition.setDate(1);
193
- }
194
- const firstDate = new Date();
195
- firstDate.setTime(this._currentPosition.getTime());
196
- firstDate.setDate(1 - firstDate.getDay());
197
- return (h("section", { ref: elem => this._container = elem }, h("div", { class: "calendar", ref: elem => this._box = elem }, h("div", { class: "calendar__header" }, h("button", { class: "calendar__btn-previous", onClick: () => this.changeMonth(-1) }), h("label", { class: "calendar__lbl-month" }, this.getMonthLabel()), h("button", { class: "calendar__btn-next", onClick: () => this.changeMonth(1) })), h("div", { class: "calendar__body" }, h("div", { class: "calendar__line" }, this._weekDayLabels.map(day => h("div", { class: "calendar__cell calendar__cell--unselectable" }, day))), [0, 7, 14, 21, 28, 35].map(offset => h("div", { class: "calendar__line" }, [0, 1, 2, 3, 4, 5, 6].map(index => {
198
- const date = new Date();
199
- date.setTime(firstDate.getTime());
200
- date.setDate(date.getDate() + offset + index);
201
- let classNames = "calendar__cell";
202
- if (this._currentPosition.getMonth() != date.getMonth()) {
203
- classNames += " calendar__cell--secondary";
204
- }
205
- else if (this.isSelectedDate(date)) {
206
- classNames += " calendar__cell--selected";
207
- }
208
- return h("div", { class: classNames, onClick: () => this.selectDate(date) }, date.getDate());
209
- })))), h("div", { class: "calendar__footer" }, h("button", { class: "calendar__btn-today", onClick: () => this.selectDate(new Date()) }, this._todayLabel)))));
210
- }
211
- static get watchers() { return {
212
- "value": ["valueChanged"]
213
- }; }
214
- };
215
- EzCalendar.style = ezCalendarCss;
216
-
217
- const ezCheckCss = ":host{--check--box--width:18px;--check--box--height:18px;--check--width:calc(var(--check--box--width) + 14px);--check--height:calc(var(--check--box--width) + 14px);--check--border-radius:var(--border--radius-small);--check--checked--background-color:var(--color--primary-200);--check--focus--background-color:var(--color--strokes, #FFFFFF);--check--hover--background-color:var(--background--medium);--check--checked--disabled--background-color:var(--color--disable-secondary);--check--border:var(--border--medium) var(--title--primary);--check--disabled--border:var(--border--medium) var(--color--strokes);--check--checked--border:var(--border--medium) var(--color--primary);--check--checked--hover--background-color:var(--color--primary-200);--check--checked--focus--background-color:var(--color--primary-300, #FFFFFF);--check--check--image:url('data:image/svg+xml;utf8,<svg width=\"8\" height=\"7\" viewBox=\"0 0 8 7\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M7.70002 0.398999L7.48502 0.207997C7.31524 0.0598858 7.09376 -0.0150438 6.86894 -0.000430025C6.64411 0.0141838 6.43419 0.117153 6.28502 0.285997L2.70002 4.332L1.61802 3.384C1.44837 3.23576 1.22697 3.16067 1.00214 3.17509C0.77732 3.18952 0.567332 3.2923 0.418019 3.461L0.229019 3.674C0.0752361 3.84797 -0.00437434 4.07521 0.00721192 4.30713C0.0187982 4.53904 0.120661 4.75722 0.291019 4.915L2.27402 6.762C2.35832 6.8432 2.45842 6.90618 2.56811 6.94702C2.67779 6.98787 2.79471 7.00571 2.91159 6.99942C3.02846 6.99314 3.14279 6.96287 3.24747 6.91049C3.35214 6.85812 3.44492 6.78477 3.52002 6.695L7.79102 1.638C7.94063 1.46048 8.01486 1.23149 7.99786 0.999963C7.98085 0.768436 7.87396 0.552749 7.70002 0.398999Z\"/></svg>');--check--check--background-color:var(--color--primary);--check--check--disabled--background-color:var(--color--strokes);--switch--slider--width:34px;--switch--slider--height:14px;--switch--pin--width:20px;--switch--pin--height:20px;--switch--focus--width:32px;--switch--focus--height:32px;--switch--background-color:var(--color--strokes);--switch--disabled--background-color:var(--color--disable-secondary);--switch--checked--background-color:var(--color--primary-300);--switch--pin--background-color:var(--background--xlight);--switch--pin--disabled--background-color:var(--color--disable-secondary);--switch--pin--checked--background-color:var(--color--primary);--switch--pin--checked--disabled--background-color:#E8F7F4;--switch--pin--focus--background-color:var(--text--disable);--switch--pin--checked--focus--background-color:var(--color--primary);--check--label--font-size:var(--text--medium, 14px);--check--label--font-family:var(--font-pattern, Arial);--check--label--color:var(--title--primary, #000);--check--label--disabled--color:var(--text--disable, #AFB6C0);display:flex;width:100%;align-items:center;margin:0}input.regularMode{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;box-sizing:border-box;-webkit-appearance:none;appearance:none;cursor:pointer;border-radius:50%;position:relative;width:var(--check--width);height:var(--check--height)}input.regularMode:enabled:hover{background-color:var(--check--hover--background-color)}input.regularMode:enabled:focus{outline:none;background-color:var(--check--focus--background-color)}input.regularMode:disabled{cursor:auto;background:none}input.regularMode::before{box-sizing:border-box;content:\"\";display:block;width:var(--check--box--width);height:var(--check--box--height);border-radius:var(--check--border-radius);border:var(--check--border)}input.regularMode:disabled::before{border:var(--check--disabled--border)}input.regularMode:checked:enabled:hover{background-color:var(--check--checked--hover--background-color)}input.regularMode:checked:enabled:focus{background-color:var(--check--checked--focus--background-color)}input.regularMode:checked::before{border:var(--check--checked--border);background-color:var(--check--checked--background-color)}input.regularMode:checked:disabled:before{border:var(--check--disabled--border);background-color:var(--check--checked--disabled--background-color)}input.regularMode:checked::after{display:flex;position:absolute;content:\"\";background-color:var(--check--check--background-color);width:8px;height:7px;-webkit-mask-image:var(--check--check--image);mask-image:var(--check--check--image)}input.regularMode:checked:disabled::after{background-color:var(--check--check--disabled--background-color)}input.switchMode{flex-shrink:0;-webkit-appearance:none;appearance:none;position:relative;outline:none;cursor:pointer;border-radius:20px;border:none;transition:background-color var(--transition);width:var(--switch--slider--width);height:var(--switch--slider--height);background-color:var(--switch--background-color)}input.switchMode:disabled{background-color:var(--switch--disabled--background-color)}input.switchMode::after{content:\"\";display:block;position:absolute;box-shadow:var(--shadow);transition:transform var(--transition);transition:background-color var(--transition);transform:translateY(-3px);border-radius:50%;width:var(--switch--pin--width);height:var(--switch--pin--height);background-color:var(--switch--pin--background-color)}input.switchMode:disabled::after{background-color:var(--switch--pin--disabled--background-color)}input.switchMode:checked{transition:background-color var(--transition);background-color:var(--switch--checked--background-color)}input.switchMode::before{display:block;content:\"\";display:block;position:absolute;border-radius:50%;opacity:0;width:var(--switch--focus--width);height:var(--switch--focus--height);top:calc((var(--switch--slider--height) - var(--switch--focus--height)) / 2);left:calc((var(--switch--pin--width) - var(--switch--focus--width))/2);background-color:var(--switch--pin--focus--background-color)}input.switchMode:focus::before{opacity:0.24;transition:opacity var(--transition)}input.switchMode:checked:focus::before{background-color:var(--switch--pin--checked--focus--background-color);transform:translateX(calc(var(--switch--slider--width) - var(--switch--pin--width)))}input.switchMode:checked::after{transition:transform var(--transition);transition:background-color var(--transition);transform:translateX(calc(var(--switch--slider--width) - var(--switch--pin--width))) translateY(-3px);box-shadow:var(--shadow);background-color:var(--switch--pin--checked--background-color)}input.switchMode:checked:disabled::after{background-color:var(--switch--pin--checked--disabled--background-color)}.label{flex-shrink:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--check--label--color);text-shadow:var(--text-shadow);font-size:var(--check--label--font-size);font-family:var(--check--label--font-family);cursor:default;padding-left:var(--space--small)}.label--disabled{color:var(--check--label--disabled--color)}";
218
-
219
- let EzCheck = class {
220
- constructor(hostRef) {
221
- registerInstance(this, hostRef);
222
- this.ezChange = createEvent(this, "ezChange", 7);
223
- /**
224
- * Deixa o campo disponível ou não para interação com o usuário.
225
- */
226
- this.enabled = true;
227
- /**
228
- * Existem dois modos de visualização: regular e switch.
229
- * Se esta propriedade for omitida, o componete assume o formato "regular".
230
- * No modo "regular" a visualização é a tradicional de uma caixinha marcada/desmarcada.
231
- * No modo "switch" o campo tem uma interface em formato de um pino liga/desliga.
232
- */
233
- this.mode = "regular";
234
- }
235
- adjustMode() {
236
- if (this.mode === "switch") {
237
- this._inputElem.classList.remove("regularMode");
238
- this._inputElem.classList.add("switchMode");
239
- }
240
- else {
241
- this._inputElem.classList.remove("switchMode");
242
- this._inputElem.classList.add("regularMode");
243
- }
244
- }
245
- //---------------------------------------------
246
- // Public methods
247
- //---------------------------------------------
248
- /**
249
- * Devolve o modo escolhido para o componente
250
- */
251
- async getMode() {
252
- return this.mode;
253
- }
254
- /**
255
- * Faz o foco no componente de input
256
- */
257
- async setFocus() {
258
- this._inputElem.focus();
259
- }
260
- componentDidLoad() {
261
- this.adjustMode();
262
- }
263
- changeValue() {
264
- this.value = !this.value;
265
- this.ezChange.emit();
266
- }
267
- getLabelClasses() {
268
- let classes = "label";
269
- if (!this.enabled) {
270
- classes += " label--disabled";
271
- }
272
- return classes;
273
- }
274
- render() {
275
- return (h(Host, null, h("input", { type: "checkbox", class: "regularMode", checked: this.value === true, onChange: () => { this.changeValue(); }, disabled: !this.enabled, ref: (el) => this._inputElem = el }), this.label ? h("label", { class: this.getLabelClasses(), onClick: () => { this.changeValue(); }, title: this.label }, this.label) : undefined));
276
- }
277
- static get watchers() { return {
278
- "mode": ["adjustMode"]
279
- }; }
280
- };
281
- EzCheck.style = ezCheckCss;
282
-
283
- 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}";
284
-
285
- let EzCollapsibleBox = class {
286
- constructor(hostRef) {
287
- registerInstance(this, hostRef);
288
- this.ezChange = createEvent(this, "ezChange", 7);
289
- /**
290
- * Valor externalizado que garante a exibição ou não do componente
291
- */
292
- this.value = false;
293
- /**
294
- * Define o tamanho do texto e do ícone do componente.
295
- */
296
- this.headerSize = "small";
297
- /**
298
- * Define o local onde o ícone será renderizado.
299
- */
300
- this.iconPlacement = "left";
301
- }
302
- observeValue() {
303
- this.ezChange.emit();
304
- }
305
- /**
306
- * Esconde ou revela o conteúdo do componente
307
- */
308
- async showHide() {
309
- this.value = !this.value;
310
- }
311
- render() {
312
- return (h(Host, null, this.iconPlacement == "right" ?
313
- h("div", { class: "collapsible-box__title" }, 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), 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() }))
314
- :
315
- h("div", { class: "collapsible-box__title" }, 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() }), 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 ? h("slot", null) : null));
316
- }
317
- static get watchers() { return {
318
- "value": ["observeValue"]
319
- }; }
320
- };
321
- EzCollapsibleBox.style = ezCollapsibleBoxCss;
322
-
323
- const ezComboBoxCss = ":host{--combo-box--height:42px;--combo-box--width:100%;--combo-box__icon--width:48px;--combo-box--border-radius:var(--border--radius-medium, 12px);--combo-box--border-radius-small:var(--border--radius-small, 6px);--combo-box--font-size:var(--text--medium, 14px);--combo-box--font-family:var(--font-pattern, Arial);--combo-box--font-weight--large:var(--text-weight--large, 500);--combo-box--font-weight--medium:var(--text-weight--medium, 400);--combo-box--background-color--xlight:var(--background--xlight, #fff);--combo-box__input--background-color:var(--background--medium, #e0e0e0);--combo-box__input--border:var(--border--medium, 2px solid);--combo-box__input--border-color:var(--combo-box__input--background-color);--combo-box__input--focus--border-color:var(--color--primary, #008561);--combo-box__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--combo-box__input--disabled--color:var(--text--disable, #AFB6C0);--combo-box__input--error--border-color:#CC2936;--combo-box__label--color:var(--title--primary, #919191);--combo-box__list-text--primary:var(--text--primary, #626e82);--combo-box__list-height:calc(var(--combo-box--font-size) + var(--combo-box--space--medium));--combo-box--drop-down__image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"16px\" width=\"16px\"><path d=\"M 1.8585859,3.0707069 7.9999998,9.2121212 14.141414,3.0707069 16,5.0101006 7.9999998,12.929293 0,4.9292932 Z\"/></svg>');--combo-box--search__image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"22px\" width=\"22px\"><path d=\"m 9.4,2.3 c 4.1,0 7.4,3.2 7.4,7.2 0,1.8 -0.7,3.4 -1.8,4.7 l 0.3,0.3 h 0.9 l 5.7,5.6 -1.7,1.7 -5.7,-5.6 V 15.3 L 14.3,15 C 13,16.1 11.3,16.7 9.5,16.7 5.3,16.7 2,13.5 2,9.5 2,5.5 5.3,2.3 9.4,2.3 m 0,2.2 c -2.9,0 -5.1,2.2 -5.1,5 0,2.8 2.3,5 5.1,5 2.8,0 5.1,-2.2 5.1,-5 0,-2.8 -2.2,-5 -5.1,-5 z\"/></svg>');--combo-box--space--medium:var(--space--medium, 12px);--combo-box--space--small:var(--space--small, 6px);display:flex;flex-wrap:wrap;position:relative;width:var(--combo-box--width)}ez-text-input{--ez-text-input__input--background-color:var(--combo-box__input--background-color, #FFFFFF);--ez-text-input__input--border-color:var(--combo-box__input--border-color, #DCE0E8)}.list-container{position:relative;width:100%}.options-list{box-sizing:border-box;width:100%;z-index:var(--more-visible, 2);display:flex;flex-direction:column;background-color:var(--combo-box--background-color--xlight);padding:var(--combo-box--space--small);border-radius:var(--combo-box--border-radius);box-shadow:var(--shadow, 0px 0px 16px 0px #000);scroll-behavior:smooth;max-height:calc(4*var(--combo-box__list-height) + 2*var(--combo-box--space--small));overflow:auto}.item{text-align:left;display:flex;justify-content:space-between;align-items:center;border-radius:var(--combo-box--border-radius-small);padding:0 var(--combo-box--space--small);list-style-type:none;min-height:var(--combo-box__list-height)}.item--label{text-align:left;flex-basis:85%;flex-grow:1;color:var(--combo-box__list-text--primary);font-weight:var(--combo-box--font-weight--large);font-family:var(--combo-box--font-family);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.item--value{text-align:right;flex-basis:15%;flex-grow:0;color:var(--combo-box__list-text--primary);font-weight:var(--combo-box--font-weight--large);font-family:var(--combo-box--font-family);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}li:hover{background-color:var(--background--medium)}.preselected{background-color:var(--background--medium)}.btn-open-options{outline:none;border:none;background-color:unset;cursor:pointer}.btn-open-options:disabled{cursor:unset}.btn-open-options::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:16px;height:16px;-webkit-mask-image:var(--combo-box--drop-down__image);mask-image:var(--combo-box--drop-down__image)}.btn-open-options:disabled:after{background-color:var(--text--disable, #AFB6C0)}.btn-open-options:enabled:hover::after{background-color:var(--color--primary, #4e4e4e)}.btn-open-search{outline:none;border:none;background-color:unset;cursor:pointer}.btn-open-search:disabled{cursor:unset}.btn-open-search::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:22px;height:22px;-webkit-mask-image:var(--combo-box--search__image);mask-image:var(--combo-box--search__image)}.btn-open-search:disabled:after{background-color:var(--text--disable, #AFB6C0)}.btn-open-search:enabled:hover::after{background-color:var(--color--primary, #4e4e4e)}";
324
-
325
- let EzComboBox = class {
326
- constructor(hostRef) {
327
- registerInstance(this, hostRef);
328
- this.ezChange = createEvent(this, "ezChange", 7);
329
- /**
330
- * Deixa o campo disponível ou não para interação com usuário.
331
- */
332
- this.enabled = true;
333
- /**
334
- * Ajusta a opção de mostrar o "value" ao selecionar uma opção. Por padrão não mostra.
335
- */
336
- this.showSelectedValue = false;
337
- /**
338
- * Ajusta a opção de mostrar o "value" para cada opção. Por padrão não mostra
339
- */
340
- this.showOptionValue = false;
341
- }
342
- internalUpdate() {
343
- if (this._inputElement) {
344
- this._inputElement.value = this.getText();
345
- }
346
- this.hideOptions();
347
- this._criteria = undefined;
348
- this._preSelection = undefined;
349
- this.updateVisibleOptions();
350
- }
351
- getText() {
352
- let text = "";
353
- const selected = this.getSelectedOption();
354
- if (selected) {
355
- text = this.showSelectedValue ? `${selected.value} - ${selected.label}` : selected.label;
356
- }
357
- return text;
358
- }
359
- getSelectedOption() {
360
- if (typeof this.value === "string" || this.value instanceof String) {
361
- return this._visibleOptions.find(o => o.value === this.value);
362
- }
363
- return this.value;
364
- }
365
- updateVisibleOptions() {
366
- let opts = this._source || [];
367
- if (!this.searchMode && this._criteria) {
368
- const upperCriteria = this._criteria.toUpperCase();
369
- opts = opts.filter(opt => opt.label.toLocaleUpperCase().indexOf(upperCriteria) > -1);
370
- }
371
- this._visibleOptions = [{ value: undefined, label: "" }].concat(opts);
372
- }
373
- buildItem(opt, index) {
374
- return h("li", { class: index === this._preSelection ? "item preselected" : "item", id: `item_${opt.value}`, onMouseDown: () => this.selectOption(opt), onMouseOver: () => this._preSelection = undefined }, h("span", { class: "item--label", title: opt.label }, opt.label), this.showOptionValue ? h("span", { class: "item--value", title: opt.value }, opt.value) : undefined);
375
- }
376
- showOptions() {
377
- if (!this.enabled) {
378
- return;
379
- }
380
- //FIXME: Provavelmente isso fará com que o popup abra em uma
381
- //posição errada no futuro. Preferi fazer simples no começo,
382
- //porque não quis onerar o text input com essa funcionalidade...
383
- const top = this.errorMessage ? "0px" : "-17px";
384
- this._floatingID = FloatingManager.float(this._optionsList, this._listContainer, { autoClose: true, top });
385
- window.requestAnimationFrame(() => {
386
- this._optionsList.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
387
- });
388
- }
389
- hideOptions() {
390
- if (this._floatingID !== undefined) {
391
- FloatingManager.close(this._floatingID);
392
- }
393
- this._floatingID = undefined;
394
- }
395
- isOptionsVisible() {
396
- return this._floatingID !== undefined && FloatingManager.isFloating(this._floatingID);
397
- }
398
- nextOption() {
399
- if (this.searchMode && !this.isOptionsVisible()) {
400
- return;
401
- }
402
- this.showOptions();
403
- this._preSelection = this._preSelection === undefined ? 0 : Math.min(this._preSelection + 1, this._visibleOptions.length - 1);
404
- this.scrollToOption(this._visibleOptions[this._preSelection], true);
405
- }
406
- previousOption() {
407
- this._preSelection = this._preSelection === undefined ? 0 : Math.max(this._preSelection - 1, 0);
408
- this.scrollToOption(this._visibleOptions[this._preSelection], false);
409
- }
410
- scrollToOption(opt, down) {
411
- window.requestAnimationFrame(() => {
412
- const liElem = this._optionsList.querySelector(`li#item_${opt.value}`);
413
- if (liElem) {
414
- const parent = liElem.parentElement;
415
- const parentRect = parent.getBoundingClientRect();
416
- const itemRect = liElem.getBoundingClientRect();
417
- if (down && itemRect.bottom > parentRect.bottom) {
418
- parent.scrollTop = itemRect.top;
419
- }
420
- else if (!down && itemRect.top < parentRect.top) {
421
- parent.scrollTop = 0;
422
- }
423
- }
424
- });
425
- }
426
- selectCurrentOption() {
427
- if (this._preSelection !== undefined) {
428
- this.selectOption(this._visibleOptions[this._preSelection]);
429
- this._preSelection = undefined;
430
- }
431
- }
432
- selectOption(opt) {
433
- const currentOpt = this.getSelectedOption();
434
- if (currentOpt !== opt) {
435
- const adjustedOpt = !(opt === null || opt === void 0 ? void 0 : opt.value) ? undefined : opt;
436
- this.value = adjustedOpt;
437
- this.ezChange.emit(adjustedOpt);
438
- }
439
- else {
440
- this.internalUpdate();
441
- }
442
- }
443
- updateSource(source) {
444
- if (source instanceof Promise) {
445
- source.then(result => this.updateSource(result));
446
- this.updateVisibleOptions();
447
- }
448
- else {
449
- this._source = source;
450
- this.updateVisibleOptions();
451
- }
452
- }
453
- loadOptions(mode, argument = "") {
454
- this._criteria = argument;
455
- if (this.optionLoader) {
456
- this.updateSource(this.optionLoader({ mode, argument }));
457
- }
458
- else {
459
- this.updateSource(this.options);
460
- }
461
- }
462
- cancelPreselection() {
463
- if (!this._inputElement.value && this.value) {
464
- this.selectOption(undefined);
465
- }
466
- else {
467
- this.internalUpdate();
468
- }
469
- }
470
- //---------------------------------------------
471
- // Lifecycle web component
472
- //---------------------------------------------
473
- componentWillLoad() {
474
- if (this.options === undefined) {
475
- this.options = [];
476
- const optionsTags = this.el.querySelectorAll("option");
477
- if (optionsTags) {
478
- optionsTags.forEach(e => {
479
- let label = e.innerText;
480
- let value = e.getAttribute("value");
481
- if (!value) {
482
- value = label;
483
- }
484
- this.options.push({ label, value });
485
- e.hidden = true;
486
- });
487
- }
488
- }
489
- if (this.searchMode) {
490
- this.updateSource([]);
491
- }
492
- else {
493
- this.loadOptions("PRELOAD");
494
- }
495
- }
496
- componentDidRender() {
497
- if (this._floatingID === undefined) {
498
- this._optionsList.remove();
499
- }
500
- }
501
- //---------------------------------------------
502
- // Event handlers
503
- //---------------------------------------------
504
- onTextInputChangeHandler(event) {
505
- if (!this._criteria) {
506
- this._inputElement.value = event.data;
507
- }
508
- const argument = event.target.value;
509
- this._criteria = argument;
510
- if (this._criteria) {
511
- if (this.searchMode) {
512
- if (this._changeDeboucingTimeout) {
513
- window.clearTimeout(this._changeDeboucingTimeout);
514
- }
515
- this._changeDeboucingTimeout = window.setTimeout(() => {
516
- this.loadOptions("PREDICTIVE", argument);
517
- }, 200);
518
- }
519
- else {
520
- this.updateVisibleOptions();
521
- }
522
- this.showOptions();
523
- }
524
- }
525
- onTextInputClickHandler() {
526
- if (!this.searchMode) {
527
- this.showOptions();
528
- }
529
- }
530
- keyDownHandler(event) {
531
- switch (event.key) {
532
- case "ArrowDown":
533
- this.nextOption();
534
- break;
535
- case "ArrowUp":
536
- this.previousOption();
537
- break;
538
- case "Enter":
539
- this.selectCurrentOption();
540
- break;
541
- case "Escape":
542
- this.cancelPreselection();
543
- break;
544
- }
545
- event.stopPropagation();
546
- }
547
- onTextInputFocusOutHandler() {
548
- this.cancelPreselection();
549
- }
550
- render() {
551
- return (h(Host, null, h("ez-text-input", { ref: elem => this._inputElement = elem, enabled: this.enabled, onInput: evt => this.onTextInputChangeHandler(evt), onClick: () => this.onTextInputClickHandler(), onFocusout: () => this.onTextInputFocusOutHandler(), onEzChange: event => event.stopPropagation(), onKeyDown: event => this.keyDownHandler(event), label: this.label, value: this.getText(), errorMessage: this.errorMessage }, this.searchMode ?
552
- h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-search", onClick: () => { this.loadOptions("ADVANCED"); }, slot: "leftIcon" })
553
- :
554
- h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-options", slot: "rightIcon", onClick: () => this.showOptions() })), h("section", { class: "list-container", ref: elem => this._listContainer = elem }, h("div", { class: "options-list", ref: elem => this._optionsList = elem }, this._visibleOptions.map((opt, index) => this.buildItem(opt, index))))));
555
- }
556
- get el() { return getElement(this); }
557
- static get watchers() { return {
558
- "value": ["internalUpdate"]
559
- }; }
560
- };
561
- EzComboBox.style = ezComboBoxCss;
562
-
563
- 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>')}.text-input{--ez-text-input__input--background-color:inherit;--ez-text-input__input--border-color:inherit}.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)}";
564
-
565
- let EzDateInput = class {
566
- constructor(hostRef) {
567
- registerInstance(this, hostRef);
568
- this.ezChange = createEvent(this, "ezChange", 7);
569
- /**
570
- * Deixa o campo disponível ou não para uso.
571
- */
572
- this.enabled = true;
573
- }
574
- setLabel() {
575
- this._textInput.label = this.label;
576
- }
577
- setErrorMessage() {
578
- this._textInput.errorMessage = this.errorMessage;
579
- }
580
- applyValueToInput() {
581
- if (this._textInput) {
582
- this._textInput.value = this.getTextValue(this.value);
583
- }
584
- }
585
- changeValue(newValue) {
586
- newValue = newValue == null ? null : DateUtils.clearTime(newValue);
587
- this._textInput.errorMessage = "";
588
- if (this.getTextValue(newValue) !== this.getTextValue(this.value)) {
589
- this.value = newValue;
590
- this.ezChange.emit();
591
- }
592
- }
593
- showCalendar() {
594
- this.parseDate();
595
- this._calendar.value = this.value;
596
- //FIXME: Provavelmente isso fará com que o popup abra em uma
597
- //posição errada no futuro. Preferi fazer simples no começo,
598
- //porque não quis onerar o text input com essa funcionalidade...
599
- const top = this._textInput.errorMessage ? 0 : -17;
600
- this._calendar.fitVertical(top, this._elem.clientHeight);
601
- }
602
- hideCalendar() {
603
- this.changeValue(this._calendar.value);
604
- this._calendar.hide();
605
- }
606
- parseDate() {
607
- const strValue = this._textInput.value;
608
- const parsedDate = DateUtils.strToDate(strValue);
609
- if (parsedDate || !strValue) {
610
- if (this.value === parsedDate) {
611
- this.changeValue(this.value);
612
- }
613
- else {
614
- this.changeValue(parsedDate);
615
- }
616
- }
617
- else {
618
- this._textInput.errorMessage = "O valor digitado não é uma data válida";
619
- }
620
- }
621
- getTextValue(d) {
622
- return d ? new Intl.DateTimeFormat("pt-BR").format(d) : null;
623
- }
624
- componentDidLoad() {
625
- CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
626
- }
627
- render() {
628
- return (h(Host, null, h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => {
629
- if (event.key === "H" || event.key === "h")
630
- this.changeValue(new Date());
631
- }, label: this.label, onEzChange: event => event.stopPropagation(), value: this.getTextValue(this.value), restrict: "0123456789/", enabled: this.enabled, errorMessage: this.errorMessage }, h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), h("ez-calendar", { onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem })));
632
- }
633
- get _elem() { return getElement(this); }
634
- static get watchers() { return {
635
- "label": ["setLabel"],
636
- "errorMessage": ["setErrorMessage"],
637
- "value": ["applyValueToInput"]
638
- }; }
639
- };
640
- EzDateInput.style = ezDateInputCss;
641
-
642
- function _defineProperty(obj, key, value) {
643
- if (key in obj) {
644
- Object.defineProperty(obj, key, {
645
- value: value,
646
- enumerable: true,
647
- configurable: true,
648
- writable: true
649
- });
650
- } else {
651
- obj[key] = value;
652
- }
653
-
654
- return obj;
655
- }
656
-
657
- function ownKeys(object, enumerableOnly) {
658
- var keys = Object.keys(object);
659
-
660
- if (Object.getOwnPropertySymbols) {
661
- var symbols = Object.getOwnPropertySymbols(object);
662
-
663
- if (enumerableOnly) {
664
- symbols = symbols.filter(function (sym) {
665
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
666
- });
667
- }
668
-
669
- keys.push.apply(keys, symbols);
670
- }
671
-
672
- return keys;
673
- }
674
-
675
- function _objectSpread2(target) {
676
- for (var i = 1; i < arguments.length; i++) {
677
- var source = arguments[i] != null ? arguments[i] : {};
678
-
679
- if (i % 2) {
680
- ownKeys(Object(source), true).forEach(function (key) {
681
- _defineProperty(target, key, source[key]);
682
- });
683
- } else if (Object.getOwnPropertyDescriptors) {
684
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
685
- } else {
686
- ownKeys(Object(source)).forEach(function (key) {
687
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
688
- });
689
- }
690
- }
691
-
692
- return target;
693
- }
694
-
695
- /**
696
- * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
697
- *
698
- * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
699
- * during build.
700
- * @param {number} code
701
- */
702
- function formatProdErrorMessage(code) {
703
- return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. ';
704
- }
705
-
706
- // Inlined version of the `symbol-observable` polyfill
707
- var $$observable = (function () {
708
- return typeof Symbol === 'function' && Symbol.observable || '@@observable';
709
- })();
710
-
711
- /**
712
- * These are private action types reserved by Redux.
713
- * For any unknown actions, you must return the current state.
714
- * If the current state is undefined, you must return the initial state.
715
- * Do not reference these action types directly in your code.
716
- */
717
- var randomString = function randomString() {
718
- return Math.random().toString(36).substring(7).split('').join('.');
719
- };
720
-
721
- var ActionTypes = {
722
- INIT: "@@redux/INIT" + randomString(),
723
- REPLACE: "@@redux/REPLACE" + randomString(),
724
- PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
725
- return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
726
- }
727
- };
728
-
729
- /**
730
- * @param {any} obj The object to inspect.
731
- * @returns {boolean} True if the argument appears to be a plain object.
732
- */
733
- function isPlainObject(obj) {
734
- if (typeof obj !== 'object' || obj === null) return false;
735
- var proto = obj;
736
-
737
- while (Object.getPrototypeOf(proto) !== null) {
738
- proto = Object.getPrototypeOf(proto);
739
- }
740
-
741
- return Object.getPrototypeOf(obj) === proto;
742
- }
743
-
744
- /**
745
- * Creates a Redux store that holds the state tree.
746
- * The only way to change the data in the store is to call `dispatch()` on it.
747
- *
748
- * There should only be a single store in your app. To specify how different
749
- * parts of the state tree respond to actions, you may combine several reducers
750
- * into a single reducer function by using `combineReducers`.
751
- *
752
- * @param {Function} reducer A function that returns the next state tree, given
753
- * the current state tree and the action to handle.
754
- *
755
- * @param {any} [preloadedState] The initial state. You may optionally specify it
756
- * to hydrate the state from the server in universal apps, or to restore a
757
- * previously serialized user session.
758
- * If you use `combineReducers` to produce the root reducer function, this must be
759
- * an object with the same shape as `combineReducers` keys.
760
- *
761
- * @param {Function} [enhancer] The store enhancer. You may optionally specify it
762
- * to enhance the store with third-party capabilities such as middleware,
763
- * time travel, persistence, etc. The only store enhancer that ships with Redux
764
- * is `applyMiddleware()`.
765
- *
766
- * @returns {Store} A Redux store that lets you read the state, dispatch actions
767
- * and subscribe to changes.
768
- */
769
-
770
- function createStore(reducer, preloadedState, enhancer) {
771
- var _ref2;
772
-
773
- if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
774
- throw new Error(formatProdErrorMessage(0) );
775
- }
776
-
777
- if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
778
- enhancer = preloadedState;
779
- preloadedState = undefined;
780
- }
781
-
782
- if (typeof enhancer !== 'undefined') {
783
- if (typeof enhancer !== 'function') {
784
- throw new Error(formatProdErrorMessage(1) );
785
- }
786
-
787
- return enhancer(createStore)(reducer, preloadedState);
788
- }
789
-
790
- if (typeof reducer !== 'function') {
791
- throw new Error(formatProdErrorMessage(2) );
792
- }
793
-
794
- var currentReducer = reducer;
795
- var currentState = preloadedState;
796
- var currentListeners = [];
797
- var nextListeners = currentListeners;
798
- var isDispatching = false;
799
- /**
800
- * This makes a shallow copy of currentListeners so we can use
801
- * nextListeners as a temporary list while dispatching.
802
- *
803
- * This prevents any bugs around consumers calling
804
- * subscribe/unsubscribe in the middle of a dispatch.
805
- */
806
-
807
- function ensureCanMutateNextListeners() {
808
- if (nextListeners === currentListeners) {
809
- nextListeners = currentListeners.slice();
810
- }
811
- }
812
- /**
813
- * Reads the state tree managed by the store.
814
- *
815
- * @returns {any} The current state tree of your application.
816
- */
817
-
818
-
819
- function getState() {
820
- if (isDispatching) {
821
- throw new Error(formatProdErrorMessage(3) );
822
- }
823
-
824
- return currentState;
825
- }
826
- /**
827
- * Adds a change listener. It will be called any time an action is dispatched,
828
- * and some part of the state tree may potentially have changed. You may then
829
- * call `getState()` to read the current state tree inside the callback.
830
- *
831
- * You may call `dispatch()` from a change listener, with the following
832
- * caveats:
833
- *
834
- * 1. The subscriptions are snapshotted just before every `dispatch()` call.
835
- * If you subscribe or unsubscribe while the listeners are being invoked, this
836
- * will not have any effect on the `dispatch()` that is currently in progress.
837
- * However, the next `dispatch()` call, whether nested or not, will use a more
838
- * recent snapshot of the subscription list.
839
- *
840
- * 2. The listener should not expect to see all state changes, as the state
841
- * might have been updated multiple times during a nested `dispatch()` before
842
- * the listener is called. It is, however, guaranteed that all subscribers
843
- * registered before the `dispatch()` started will be called with the latest
844
- * state by the time it exits.
845
- *
846
- * @param {Function} listener A callback to be invoked on every dispatch.
847
- * @returns {Function} A function to remove this change listener.
848
- */
849
-
850
-
851
- function subscribe(listener) {
852
- if (typeof listener !== 'function') {
853
- throw new Error(formatProdErrorMessage(4) );
854
- }
855
-
856
- if (isDispatching) {
857
- throw new Error(formatProdErrorMessage(5) );
858
- }
859
-
860
- var isSubscribed = true;
861
- ensureCanMutateNextListeners();
862
- nextListeners.push(listener);
863
- return function unsubscribe() {
864
- if (!isSubscribed) {
865
- return;
866
- }
867
-
868
- if (isDispatching) {
869
- throw new Error(formatProdErrorMessage(6) );
870
- }
871
-
872
- isSubscribed = false;
873
- ensureCanMutateNextListeners();
874
- var index = nextListeners.indexOf(listener);
875
- nextListeners.splice(index, 1);
876
- currentListeners = null;
877
- };
878
- }
879
- /**
880
- * Dispatches an action. It is the only way to trigger a state change.
881
- *
882
- * The `reducer` function, used to create the store, will be called with the
883
- * current state tree and the given `action`. Its return value will
884
- * be considered the **next** state of the tree, and the change listeners
885
- * will be notified.
886
- *
887
- * The base implementation only supports plain object actions. If you want to
888
- * dispatch a Promise, an Observable, a thunk, or something else, you need to
889
- * wrap your store creating function into the corresponding middleware. For
890
- * example, see the documentation for the `redux-thunk` package. Even the
891
- * middleware will eventually dispatch plain object actions using this method.
892
- *
893
- * @param {Object} action A plain object representing “what changed”. It is
894
- * a good idea to keep actions serializable so you can record and replay user
895
- * sessions, or use the time travelling `redux-devtools`. An action must have
896
- * a `type` property which may not be `undefined`. It is a good idea to use
897
- * string constants for action types.
898
- *
899
- * @returns {Object} For convenience, the same action object you dispatched.
900
- *
901
- * Note that, if you use a custom middleware, it may wrap `dispatch()` to
902
- * return something else (for example, a Promise you can await).
903
- */
904
-
905
-
906
- function dispatch(action) {
907
- if (!isPlainObject(action)) {
908
- throw new Error(formatProdErrorMessage(7) );
909
- }
910
-
911
- if (typeof action.type === 'undefined') {
912
- throw new Error(formatProdErrorMessage(8) );
913
- }
914
-
915
- if (isDispatching) {
916
- throw new Error(formatProdErrorMessage(9) );
917
- }
918
-
919
- try {
920
- isDispatching = true;
921
- currentState = currentReducer(currentState, action);
922
- } finally {
923
- isDispatching = false;
924
- }
925
-
926
- var listeners = currentListeners = nextListeners;
927
-
928
- for (var i = 0; i < listeners.length; i++) {
929
- var listener = listeners[i];
930
- listener();
931
- }
932
-
933
- return action;
934
- }
935
- /**
936
- * Replaces the reducer currently used by the store to calculate the state.
937
- *
938
- * You might need this if your app implements code splitting and you want to
939
- * load some of the reducers dynamically. You might also need this if you
940
- * implement a hot reloading mechanism for Redux.
941
- *
942
- * @param {Function} nextReducer The reducer for the store to use instead.
943
- * @returns {void}
944
- */
945
-
946
-
947
- function replaceReducer(nextReducer) {
948
- if (typeof nextReducer !== 'function') {
949
- throw new Error(formatProdErrorMessage(10) );
950
- }
951
-
952
- currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
953
- // Any reducers that existed in both the new and old rootReducer
954
- // will receive the previous state. This effectively populates
955
- // the new state tree with any relevant data from the old one.
956
-
957
- dispatch({
958
- type: ActionTypes.REPLACE
959
- });
960
- }
961
- /**
962
- * Interoperability point for observable/reactive libraries.
963
- * @returns {observable} A minimal observable of state changes.
964
- * For more information, see the observable proposal:
965
- * https://github.com/tc39/proposal-observable
966
- */
967
-
968
-
969
- function observable() {
970
- var _ref;
971
-
972
- var outerSubscribe = subscribe;
973
- return _ref = {
974
- /**
975
- * The minimal observable subscription method.
976
- * @param {Object} observer Any object that can be used as an observer.
977
- * The observer object should have a `next` method.
978
- * @returns {subscription} An object with an `unsubscribe` method that can
979
- * be used to unsubscribe the observable from the store, and prevent further
980
- * emission of values from the observable.
981
- */
982
- subscribe: function subscribe(observer) {
983
- if (typeof observer !== 'object' || observer === null) {
984
- throw new Error(formatProdErrorMessage(11) );
985
- }
986
-
987
- function observeState() {
988
- if (observer.next) {
989
- observer.next(getState());
990
- }
991
- }
992
-
993
- observeState();
994
- var unsubscribe = outerSubscribe(observeState);
995
- return {
996
- unsubscribe: unsubscribe
997
- };
998
- }
999
- }, _ref[$$observable] = function () {
1000
- return this;
1001
- }, _ref;
1002
- } // When a store is created, an "INIT" action is dispatched so that every
1003
- // reducer returns their initial state. This effectively populates
1004
- // the initial state tree.
1005
-
1006
-
1007
- dispatch({
1008
- type: ActionTypes.INIT
1009
- });
1010
- return _ref2 = {
1011
- dispatch: dispatch,
1012
- subscribe: subscribe,
1013
- getState: getState,
1014
- replaceReducer: replaceReducer
1015
- }, _ref2[$$observable] = observable, _ref2;
1016
- }
1017
-
1018
- function assertReducerShape(reducers) {
1019
- Object.keys(reducers).forEach(function (key) {
1020
- var reducer = reducers[key];
1021
- var initialState = reducer(undefined, {
1022
- type: ActionTypes.INIT
1023
- });
1024
-
1025
- if (typeof initialState === 'undefined') {
1026
- throw new Error(formatProdErrorMessage(12) );
1027
- }
1028
-
1029
- if (typeof reducer(undefined, {
1030
- type: ActionTypes.PROBE_UNKNOWN_ACTION()
1031
- }) === 'undefined') {
1032
- throw new Error(formatProdErrorMessage(13) );
1033
- }
1034
- });
1035
- }
1036
- /**
1037
- * Turns an object whose values are different reducer functions, into a single
1038
- * reducer function. It will call every child reducer, and gather their results
1039
- * into a single state object, whose keys correspond to the keys of the passed
1040
- * reducer functions.
1041
- *
1042
- * @param {Object} reducers An object whose values correspond to different
1043
- * reducer functions that need to be combined into one. One handy way to obtain
1044
- * it is to use ES6 `import * as reducers` syntax. The reducers may never return
1045
- * undefined for any action. Instead, they should return their initial state
1046
- * if the state passed to them was undefined, and the current state for any
1047
- * unrecognized action.
1048
- *
1049
- * @returns {Function} A reducer function that invokes every reducer inside the
1050
- * passed object, and builds a state object with the same shape.
1051
- */
1052
-
1053
-
1054
- function combineReducers(reducers) {
1055
- var reducerKeys = Object.keys(reducers);
1056
- var finalReducers = {};
1057
-
1058
- for (var i = 0; i < reducerKeys.length; i++) {
1059
- var key = reducerKeys[i];
1060
-
1061
- if (typeof reducers[key] === 'function') {
1062
- finalReducers[key] = reducers[key];
1063
- }
1064
- }
1065
-
1066
- var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
1067
-
1068
- var shapeAssertionError;
1069
-
1070
- try {
1071
- assertReducerShape(finalReducers);
1072
- } catch (e) {
1073
- shapeAssertionError = e;
1074
- }
1075
-
1076
- return function combination(state, action) {
1077
- if (state === void 0) {
1078
- state = {};
1079
- }
1080
-
1081
- if (shapeAssertionError) {
1082
- throw shapeAssertionError;
1083
- }
1084
-
1085
- var hasChanged = false;
1086
- var nextState = {};
1087
-
1088
- for (var _i = 0; _i < finalReducerKeys.length; _i++) {
1089
- var _key = finalReducerKeys[_i];
1090
- var reducer = finalReducers[_key];
1091
- var previousStateForKey = state[_key];
1092
- var nextStateForKey = reducer(previousStateForKey, action);
1093
-
1094
- if (typeof nextStateForKey === 'undefined') {
1095
- throw new Error(formatProdErrorMessage(14) );
1096
- }
1097
-
1098
- nextState[_key] = nextStateForKey;
1099
- hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
1100
- }
1101
-
1102
- hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
1103
- return hasChanged ? nextState : state;
1104
- };
1105
- }
1106
-
1107
- /**
1108
- * Composes single-argument functions from right to left. The rightmost
1109
- * function can take multiple arguments as it provides the signature for
1110
- * the resulting composite function.
1111
- *
1112
- * @param {...Function} funcs The functions to compose.
1113
- * @returns {Function} A function obtained by composing the argument functions
1114
- * from right to left. For example, compose(f, g, h) is identical to doing
1115
- * (...args) => f(g(h(...args))).
1116
- */
1117
- function compose() {
1118
- for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
1119
- funcs[_key] = arguments[_key];
1120
- }
1121
-
1122
- if (funcs.length === 0) {
1123
- return function (arg) {
1124
- return arg;
1125
- };
1126
- }
1127
-
1128
- if (funcs.length === 1) {
1129
- return funcs[0];
1130
- }
1131
-
1132
- return funcs.reduce(function (a, b) {
1133
- return function () {
1134
- return a(b.apply(void 0, arguments));
1135
- };
1136
- });
1137
- }
1138
-
1139
- /**
1140
- * Creates a store enhancer that applies middleware to the dispatch method
1141
- * of the Redux store. This is handy for a variety of tasks, such as expressing
1142
- * asynchronous actions in a concise manner, or logging every action payload.
1143
- *
1144
- * See `redux-thunk` package as an example of the Redux middleware.
1145
- *
1146
- * Because middleware is potentially asynchronous, this should be the first
1147
- * store enhancer in the composition chain.
1148
- *
1149
- * Note that each middleware will be given the `dispatch` and `getState` functions
1150
- * as named arguments.
1151
- *
1152
- * @param {...Function} middlewares The middleware chain to be applied.
1153
- * @returns {Function} A store enhancer applying the middleware.
1154
- */
1155
-
1156
- function applyMiddleware() {
1157
- for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
1158
- middlewares[_key] = arguments[_key];
1159
- }
1160
-
1161
- return function (createStore) {
1162
- return function () {
1163
- var store = createStore.apply(void 0, arguments);
1164
-
1165
- var _dispatch = function dispatch() {
1166
- throw new Error(formatProdErrorMessage(15) );
1167
- };
1168
-
1169
- var middlewareAPI = {
1170
- getState: store.getState,
1171
- dispatch: function dispatch() {
1172
- return _dispatch.apply(void 0, arguments);
1173
- }
1174
- };
1175
- var chain = middlewares.map(function (middleware) {
1176
- return middleware(middlewareAPI);
1177
- });
1178
- _dispatch = compose.apply(void 0, chain)(store.dispatch);
1179
- return _objectSpread2(_objectSpread2({}, store), {}, {
1180
- dispatch: _dispatch
1181
- });
1182
- };
1183
- };
1184
- }
1185
-
1186
- /** A function that accepts a potential "extra argument" value to be injected later,
1187
- * and returns an instance of the thunk middleware that uses that value
1188
- */
1189
- function createThunkMiddleware(extraArgument) {
1190
- // Standard Redux middleware definition pattern:
1191
- // See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
1192
- var middleware = function middleware(_ref) {
1193
- var dispatch = _ref.dispatch,
1194
- getState = _ref.getState;
1195
- return function (next) {
1196
- return function (action) {
1197
- // The thunk middleware looks for any functions that were passed to `store.dispatch`.
1198
- // If this "action" is really a function, call it and return the result.
1199
- if (typeof action === 'function') {
1200
- // Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
1201
- return action(dispatch, getState, extraArgument);
1202
- } // Otherwise, pass the action down the middleware chain as usual
1203
-
1204
-
1205
- return next(action);
1206
- };
1207
- };
1208
- };
1209
-
1210
- return middleware;
1211
- }
1212
-
1213
- var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
1214
- // with whatever "extra arg" they want to inject into their thunks
1215
-
1216
- thunk.withExtraArgument = createThunkMiddleware;
1217
-
1218
- function changeFieldValue$1(dataUnit, recordId, fieldName, value) {
1219
- return {
1220
- type: "FORM/CHANGEFIELD",
1221
- payload: { dataUnit, recordId, fieldName, value }
1222
- };
1223
- }
1224
- function changeTab$1(formId, index) {
1225
- return {
1226
- type: "FORM/CHANGETAB",
1227
- payload: { formId, index }
1228
- };
1229
- }
1230
- function clearEdition$1(dataUnit, recordsLimit) {
1231
- return {
1232
- type: "FORM/CLEAREDITION",
1233
- payload: {
1234
- dataUnit,
1235
- recordsLimit
1236
- }
1237
- };
1238
- }
1239
- function collapseExpandGroup(collapseId, collapsed) {
1240
- return {
1241
- type: "FORM/COLLAPSEGROUP",
1242
- payload: { collapseId, collapsed }
1243
- };
1244
- }
1245
- function previousRecord(dataUnit) {
1246
- return {
1247
- type: "FORM/NAVIGATE",
1248
- payload: {
1249
- dataUnit,
1250
- limit: 0,
1251
- backward: true
1252
- }
1253
- };
1254
- }
1255
- function nextRecord(dataUnit, limit) {
1256
- return {
1257
- type: "FORM/NAVIGATE",
1258
- payload: {
1259
- dataUnit,
1260
- limit,
1261
- backward: false
1262
- }
1263
- };
1264
- }
1265
- function insertRecord$1(dataUnit, insertionIndex) {
1266
- return {
1267
- type: "FORM/INSERT",
1268
- payload: {
1269
- dataUnit,
1270
- insertionIndex
1271
- }
1272
- };
1273
- }
1274
- function formLoad() {
1275
- return {
1276
- type: "FORM/LOAD"
1277
- };
1278
- }
1279
- function dataLoading$1(dataUnit) {
1280
- return {
1281
- type: "FORM/DATALOADING",
1282
- payload: {
1283
- dataUnit
1284
- }
1285
- };
1286
- }
1287
- function savingChanges$1(dataUnit) {
1288
- return {
1289
- type: "FORM/SAVINGCHANGES",
1290
- payload: {
1291
- dataUnit
1292
- }
1293
- };
1294
- }
1295
- function dataLoaded$1(dataUnit) {
1296
- return {
1297
- type: "FORM/DATALOADED",
1298
- payload: {
1299
- dataUnit
1300
- }
1301
- };
1302
- }
1303
- function changesSaved$1(dataUnit) {
1304
- return {
1305
- type: "FORM/CHANGESSAVED",
1306
- payload: {
1307
- dataUnit
1308
- }
1309
- };
1310
- }
1311
- function removingRecord$1(dataUnit) {
1312
- return {
1313
- type: "FORM/REMOVINGRECORD",
1314
- payload: {
1315
- dataUnit
1316
- }
1317
- };
1318
- }
1319
- function recordRemoved$1(dataUnit) {
1320
- return {
1321
- type: "FORM/RECORDREMOVED",
1322
- payload: {
1323
- dataUnit
1324
- }
1325
- };
1326
- }
1327
- function invalidField$1(tabController, tabIndex, dataUnit, recordIndex, recordId, fieldName, errorMessage) {
1328
- return {
1329
- type: "FORM/INVALIDFIELD",
1330
- payload: {
1331
- tabController,
1332
- tabIndex,
1333
- dataUnit,
1334
- recordId,
1335
- recordIndex,
1336
- fieldName,
1337
- errorMessage
1338
- }
1339
- };
1340
- }
1341
- function showHideNavigationButtons(buttonName, status) {
1342
- return {
1343
- type: "FORM/SHOWHIDENAVBTN",
1344
- payload: {
1345
- buttonName,
1346
- status
1347
- }
1348
- };
1349
- }
1350
-
1351
- function getDefaultExportFromCjs (x) {
1352
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
1353
- }
1354
-
1355
- function createCommonjsModule(fn, basedir, module) {
1356
- return module = {
1357
- path: basedir,
1358
- exports: {},
1359
- require: function (path, base) {
1360
- return commonjsRequire();
1361
- }
1362
- }, fn(module, module.exports), module.exports;
1363
- }
1364
-
1365
- function commonjsRequire () {
1366
- throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
1367
- }
1368
-
1369
- var actions = createCommonjsModule(function (module, exports) {
1370
-
1371
- Object.defineProperty(exports, "__esModule", {
1372
- value: true
1373
- });
1374
- exports.ActionCreators = exports.ActionTypes = void 0;
1375
- var ActionTypes = {
1376
- UNDO: '@@redux-undo/UNDO',
1377
- REDO: '@@redux-undo/REDO',
1378
- JUMP_TO_FUTURE: '@@redux-undo/JUMP_TO_FUTURE',
1379
- JUMP_TO_PAST: '@@redux-undo/JUMP_TO_PAST',
1380
- JUMP: '@@redux-undo/JUMP',
1381
- CLEAR_HISTORY: '@@redux-undo/CLEAR_HISTORY'
1382
- };
1383
- exports.ActionTypes = ActionTypes;
1384
- var ActionCreators = {
1385
- undo: function undo() {
1386
- return {
1387
- type: ActionTypes.UNDO
1388
- };
1389
- },
1390
- redo: function redo() {
1391
- return {
1392
- type: ActionTypes.REDO
1393
- };
1394
- },
1395
- jumpToFuture: function jumpToFuture(index) {
1396
- return {
1397
- type: ActionTypes.JUMP_TO_FUTURE,
1398
- index: index
1399
- };
1400
- },
1401
- jumpToPast: function jumpToPast(index) {
1402
- return {
1403
- type: ActionTypes.JUMP_TO_PAST,
1404
- index: index
1405
- };
1406
- },
1407
- jump: function jump(index) {
1408
- return {
1409
- type: ActionTypes.JUMP,
1410
- index: index
1411
- };
1412
- },
1413
- clearHistory: function clearHistory() {
1414
- return {
1415
- type: ActionTypes.CLEAR_HISTORY
1416
- };
1417
- }
1418
- };
1419
- exports.ActionCreators = ActionCreators;
1420
- });
1421
-
1422
- var helpers = createCommonjsModule(function (module, exports) {
1423
-
1424
- Object.defineProperty(exports, "__esModule", {
1425
- value: true
1426
- });
1427
- exports.parseActions = parseActions;
1428
- exports.isHistory = isHistory;
1429
- exports.includeAction = includeAction;
1430
- exports.excludeAction = excludeAction;
1431
- exports.combineFilters = combineFilters;
1432
- exports.groupByActionTypes = groupByActionTypes;
1433
- exports.newHistory = newHistory;
1434
-
1435
- // parseActions helper: takes a string (or array)
1436
- // and makes it an array if it isn't yet
1437
- function parseActions(rawActions) {
1438
- var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
1439
-
1440
- if (Array.isArray(rawActions)) {
1441
- return rawActions;
1442
- } else if (typeof rawActions === 'string') {
1443
- return [rawActions];
1444
- }
1445
-
1446
- return defaultValue;
1447
- } // isHistory helper: check for a valid history object
1448
-
1449
-
1450
- function isHistory(history) {
1451
- return typeof history.present !== 'undefined' && typeof history.future !== 'undefined' && typeof history.past !== 'undefined' && Array.isArray(history.future) && Array.isArray(history.past);
1452
- } // includeAction helper: whitelist actions to be added to the history
1453
-
1454
-
1455
- function includeAction(rawActions) {
1456
- var actions = parseActions(rawActions);
1457
- return function (action) {
1458
- return actions.indexOf(action.type) >= 0;
1459
- };
1460
- } // excludeAction helper: blacklist actions from being added to the history
1461
-
1462
-
1463
- function excludeAction(rawActions) {
1464
- var actions = parseActions(rawActions);
1465
- return function (action) {
1466
- return actions.indexOf(action.type) < 0;
1467
- };
1468
- } // combineFilters helper: combine multiple filters to one
1469
-
1470
-
1471
- function combineFilters() {
1472
- for (var _len = arguments.length, filters = new Array(_len), _key = 0; _key < _len; _key++) {
1473
- filters[_key] = arguments[_key];
1474
- }
1475
-
1476
- return filters.reduce(function (prev, curr) {
1477
- return function (action, currentState, previousHistory) {
1478
- return prev(action, currentState, previousHistory) && curr(action, currentState, previousHistory);
1479
- };
1480
- }, function () {
1481
- return true;
1482
- });
1483
- }
1484
-
1485
- function groupByActionTypes(rawActions) {
1486
- var actions = parseActions(rawActions);
1487
- return function (action) {
1488
- return actions.indexOf(action.type) >= 0 ? action.type : null;
1489
- };
1490
- }
1491
-
1492
- function newHistory(past, present, future) {
1493
- var group = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
1494
- return {
1495
- past: past,
1496
- present: present,
1497
- future: future,
1498
- group: group,
1499
- _latestUnfiltered: present,
1500
- index: past.length,
1501
- limit: past.length + future.length + 1
1502
- };
1503
- }
1504
- });
1505
-
1506
- var debug = createCommonjsModule(function (module, exports) {
1507
-
1508
- Object.defineProperty(exports, "__esModule", {
1509
- value: true
1510
- });
1511
- exports.set = set;
1512
- exports.start = start;
1513
- exports.end = end;
1514
- exports.log = log;
1515
-
1516
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
1517
-
1518
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
1519
-
1520
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
1521
-
1522
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
1523
-
1524
- var __DEBUG__;
1525
-
1526
- var displayBuffer;
1527
- var colors = {
1528
- prevState: '#9E9E9E',
1529
- action: '#03A9F4',
1530
- nextState: '#4CAF50'
1531
- };
1532
- /* istanbul ignore next: debug messaging is not tested */
1533
-
1534
- function initBuffer() {
1535
- displayBuffer = {
1536
- header: [],
1537
- prev: [],
1538
- action: [],
1539
- next: [],
1540
- msgs: []
1541
- };
1542
- }
1543
- /* istanbul ignore next: debug messaging is not tested */
1544
-
1545
-
1546
- function printBuffer() {
1547
- var _displayBuffer = displayBuffer,
1548
- header = _displayBuffer.header,
1549
- prev = _displayBuffer.prev,
1550
- next = _displayBuffer.next,
1551
- action = _displayBuffer.action,
1552
- msgs = _displayBuffer.msgs;
1553
-
1554
- if (console.group) {
1555
- var _console, _console2, _console3, _console4, _console5;
1556
-
1557
- (_console = console).groupCollapsed.apply(_console, _toConsumableArray(header));
1558
-
1559
- (_console2 = console).log.apply(_console2, _toConsumableArray(prev));
1560
-
1561
- (_console3 = console).log.apply(_console3, _toConsumableArray(action));
1562
-
1563
- (_console4 = console).log.apply(_console4, _toConsumableArray(next));
1564
-
1565
- (_console5 = console).log.apply(_console5, _toConsumableArray(msgs));
1566
-
1567
- console.groupEnd();
1568
- } else {
1569
- var _console6, _console7, _console8, _console9, _console10;
1570
-
1571
- (_console6 = console).log.apply(_console6, _toConsumableArray(header));
1572
-
1573
- (_console7 = console).log.apply(_console7, _toConsumableArray(prev));
1574
-
1575
- (_console8 = console).log.apply(_console8, _toConsumableArray(action));
1576
-
1577
- (_console9 = console).log.apply(_console9, _toConsumableArray(next));
1578
-
1579
- (_console10 = console).log.apply(_console10, _toConsumableArray(msgs));
1580
- }
1581
- }
1582
- /* istanbul ignore next: debug messaging is not tested */
1583
-
1584
-
1585
- function colorFormat(text, color, obj) {
1586
- return ["%c".concat(text), "color: ".concat(color, "; font-weight: bold"), obj];
1587
- }
1588
- /* istanbul ignore next: debug messaging is not tested */
1589
-
1590
-
1591
- function start(action, state) {
1592
- initBuffer();
1593
-
1594
- if (__DEBUG__) {
1595
- if (console.group) {
1596
- displayBuffer.header = ['%credux-undo', 'font-style: italic', 'action', action.type];
1597
- displayBuffer.action = colorFormat('action', colors.action, action);
1598
- displayBuffer.prev = colorFormat('prev history', colors.prevState, state);
1599
- } else {
1600
- displayBuffer.header = ['redux-undo action', action.type];
1601
- displayBuffer.action = ['action', action];
1602
- displayBuffer.prev = ['prev history', state];
1603
- }
1604
- }
1605
- }
1606
- /* istanbul ignore next: debug messaging is not tested */
1607
-
1608
-
1609
- function end(nextState) {
1610
- if (__DEBUG__) {
1611
- if (console.group) {
1612
- displayBuffer.next = colorFormat('next history', colors.nextState, nextState);
1613
- } else {
1614
- displayBuffer.next = ['next history', nextState];
1615
- }
1616
-
1617
- printBuffer();
1618
- }
1619
- }
1620
- /* istanbul ignore next: debug messaging is not tested */
1621
-
1622
-
1623
- function log() {
1624
- if (__DEBUG__) {
1625
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1626
- args[_key] = arguments[_key];
1627
- }
1628
-
1629
- displayBuffer.msgs = displayBuffer.msgs.concat([].concat(args, ['\n']));
1630
- }
1631
- }
1632
- /* istanbul ignore next: debug messaging is not tested */
1633
-
1634
-
1635
- function set(debug) {
1636
- __DEBUG__ = debug;
1637
- }
1638
- });
1639
-
1640
- var reducer = createCommonjsModule(function (module, exports) {
1641
-
1642
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
1643
-
1644
- Object.defineProperty(exports, "__esModule", {
1645
- value: true
1646
- });
1647
- exports["default"] = undoable;
1648
-
1649
- var debug$1 = _interopRequireWildcard(debug);
1650
-
1651
-
1652
-
1653
-
1654
-
1655
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
1656
-
1657
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
1658
-
1659
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
1660
-
1661
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
1662
-
1663
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1664
-
1665
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
1666
-
1667
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
1668
-
1669
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
1670
-
1671
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
1672
-
1673
- function createHistory(state, ignoreInitialState) {
1674
- // ignoreInitialState essentially prevents the user from undoing to the
1675
- // beginning, in the case that the undoable reducer handles initialization
1676
- // in a way that can't be redone simply
1677
- var history = (0, helpers.newHistory)([], state, []);
1678
-
1679
- if (ignoreInitialState) {
1680
- history._latestUnfiltered = null;
1681
- }
1682
-
1683
- return history;
1684
- } // insert: insert `state` into history, which means adding the current state
1685
- // into `past`, setting the new `state` as `present` and erasing
1686
- // the `future`.
1687
-
1688
-
1689
- function insert(history, state, limit, group) {
1690
- var lengthWithoutFuture = history.past.length + 1;
1691
- debug$1.log('inserting', state);
1692
- debug$1.log('new free: ', limit - lengthWithoutFuture);
1693
- var past = history.past,
1694
- _latestUnfiltered = history._latestUnfiltered;
1695
- var isHistoryOverflow = limit && limit <= lengthWithoutFuture;
1696
- var pastSliced = past.slice(isHistoryOverflow ? 1 : 0);
1697
- var newPast = _latestUnfiltered != null ? [].concat(_toConsumableArray(pastSliced), [_latestUnfiltered]) : pastSliced;
1698
- return (0, helpers.newHistory)(newPast, state, [], group);
1699
- } // jumpToFuture: jump to requested index in future history
1700
-
1701
-
1702
- function jumpToFuture(history, index) {
1703
- if (index < 0 || index >= history.future.length) return history;
1704
- var past = history.past,
1705
- future = history.future,
1706
- _latestUnfiltered = history._latestUnfiltered;
1707
- var newPast = [].concat(_toConsumableArray(past), [_latestUnfiltered], _toConsumableArray(future.slice(0, index)));
1708
- var newPresent = future[index];
1709
- var newFuture = future.slice(index + 1);
1710
- return (0, helpers.newHistory)(newPast, newPresent, newFuture);
1711
- } // jumpToPast: jump to requested index in past history
1712
-
1713
-
1714
- function jumpToPast(history, index) {
1715
- if (index < 0 || index >= history.past.length) return history;
1716
- var past = history.past,
1717
- future = history.future,
1718
- _latestUnfiltered = history._latestUnfiltered;
1719
- var newPast = past.slice(0, index);
1720
- var newFuture = [].concat(_toConsumableArray(past.slice(index + 1)), [_latestUnfiltered], _toConsumableArray(future));
1721
- var newPresent = past[index];
1722
- return (0, helpers.newHistory)(newPast, newPresent, newFuture);
1723
- } // jump: jump n steps in the past or forward
1724
-
1725
-
1726
- function jump(history, n) {
1727
- if (n > 0) return jumpToFuture(history, n - 1);
1728
- if (n < 0) return jumpToPast(history, history.past.length + n);
1729
- return history;
1730
- } // helper to dynamically match in the reducer's switch-case
1731
-
1732
-
1733
- function actionTypeAmongClearHistoryType(actionType, clearHistoryType) {
1734
- return clearHistoryType.indexOf(actionType) > -1 ? actionType : !actionType;
1735
- } // redux-undo higher order reducer
1736
-
1737
-
1738
- function undoable(reducer) {
1739
- var rawConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1740
- debug$1.set(rawConfig.debug);
1741
-
1742
- var config = _objectSpread({
1743
- limit: undefined,
1744
- filter: function filter() {
1745
- return true;
1746
- },
1747
- groupBy: function groupBy() {
1748
- return null;
1749
- },
1750
- undoType: actions.ActionTypes.UNDO,
1751
- redoType: actions.ActionTypes.REDO,
1752
- jumpToPastType: actions.ActionTypes.JUMP_TO_PAST,
1753
- jumpToFutureType: actions.ActionTypes.JUMP_TO_FUTURE,
1754
- jumpType: actions.ActionTypes.JUMP,
1755
- neverSkipReducer: false,
1756
- ignoreInitialState: false,
1757
- syncFilter: false
1758
- }, rawConfig, {
1759
- initTypes: (0, helpers.parseActions)(rawConfig.initTypes, ['@@redux-undo/INIT']),
1760
- clearHistoryType: (0, helpers.parseActions)(rawConfig.clearHistoryType, [actions.ActionTypes.CLEAR_HISTORY])
1761
- }); // Allows the user to call the reducer with redux-undo specific actions
1762
-
1763
-
1764
- var skipReducer = config.neverSkipReducer ? function (res, action) {
1765
- for (var _len = arguments.length, slices = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
1766
- slices[_key - 2] = arguments[_key];
1767
- }
1768
-
1769
- return _objectSpread({}, res, {
1770
- present: reducer.apply(void 0, [res.present, action].concat(slices))
1771
- });
1772
- } : function (res) {
1773
- return res;
1774
- };
1775
- var initialState;
1776
- return function () {
1777
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
1778
- var action = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1779
- debug$1.start(action, state);
1780
- var history = state;
1781
-
1782
- for (var _len2 = arguments.length, slices = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
1783
- slices[_key2 - 2] = arguments[_key2];
1784
- }
1785
-
1786
- if (!initialState) {
1787
- debug$1.log('history is uninitialized');
1788
-
1789
- if (state === undefined) {
1790
- var createHistoryAction = {
1791
- type: '@@redux-undo/CREATE_HISTORY'
1792
- };
1793
- var start = reducer.apply(void 0, [state, createHistoryAction].concat(slices));
1794
- history = createHistory(start, config.ignoreInitialState);
1795
- debug$1.log('do not set initialState on probe actions');
1796
- debug$1.end(history);
1797
- return history;
1798
- } else if ((0, helpers.isHistory)(state)) {
1799
- history = initialState = config.ignoreInitialState ? state : (0, helpers.newHistory)(state.past, state.present, state.future);
1800
- debug$1.log('initialHistory initialized: initialState is a history', initialState);
1801
- } else {
1802
- history = initialState = createHistory(state, config.ignoreInitialState);
1803
- debug$1.log('initialHistory initialized: initialState is not a history', initialState);
1804
- }
1805
- }
1806
-
1807
- var res;
1808
-
1809
- switch (action.type) {
1810
- case undefined:
1811
- return history;
1812
-
1813
- case config.undoType:
1814
- res = jump(history, -1);
1815
- debug$1.log('perform undo');
1816
- debug$1.end(res);
1817
- return skipReducer.apply(void 0, [res, action].concat(slices));
1818
-
1819
- case config.redoType:
1820
- res = jump(history, 1);
1821
- debug$1.log('perform redo');
1822
- debug$1.end(res);
1823
- return skipReducer.apply(void 0, [res, action].concat(slices));
1824
-
1825
- case config.jumpToPastType:
1826
- res = jumpToPast(history, action.index);
1827
- debug$1.log("perform jumpToPast to ".concat(action.index));
1828
- debug$1.end(res);
1829
- return skipReducer.apply(void 0, [res, action].concat(slices));
1830
-
1831
- case config.jumpToFutureType:
1832
- res = jumpToFuture(history, action.index);
1833
- debug$1.log("perform jumpToFuture to ".concat(action.index));
1834
- debug$1.end(res);
1835
- return skipReducer.apply(void 0, [res, action].concat(slices));
1836
-
1837
- case config.jumpType:
1838
- res = jump(history, action.index);
1839
- debug$1.log("perform jump to ".concat(action.index));
1840
- debug$1.end(res);
1841
- return skipReducer.apply(void 0, [res, action].concat(slices));
1842
-
1843
- case actionTypeAmongClearHistoryType(action.type, config.clearHistoryType):
1844
- res = createHistory(history.present, config.ignoreInitialState);
1845
- debug$1.log('perform clearHistory');
1846
- debug$1.end(res);
1847
- return skipReducer.apply(void 0, [res, action].concat(slices));
1848
-
1849
- default:
1850
- res = reducer.apply(void 0, [history.present, action].concat(slices));
1851
-
1852
- if (config.initTypes.some(function (actionType) {
1853
- return actionType === action.type;
1854
- })) {
1855
- debug$1.log('reset history due to init action');
1856
- debug$1.end(initialState);
1857
- return initialState;
1858
- }
1859
-
1860
- if (history._latestUnfiltered === res) {
1861
- // Don't handle this action. Do not call debug.end here,
1862
- // because this action should not produce side effects to the console
1863
- return history;
1864
- }
1865
- /* eslint-disable-next-line no-case-declarations */
1866
-
1867
-
1868
- var filtered = typeof config.filter === 'function' && !config.filter(action, res, history);
1869
-
1870
- if (filtered) {
1871
- // if filtering an action, merely update the present
1872
- var filteredState = (0, helpers.newHistory)(history.past, res, history.future, history.group);
1873
-
1874
- if (!config.syncFilter) {
1875
- filteredState._latestUnfiltered = history._latestUnfiltered;
1876
- }
1877
-
1878
- debug$1.log('filter ignored action, not storing it in past');
1879
- debug$1.end(filteredState);
1880
- return filteredState;
1881
- }
1882
- /* eslint-disable-next-line no-case-declarations */
1883
-
1884
-
1885
- var group = config.groupBy(action, res, history);
1886
-
1887
- if (group != null && group === history.group) {
1888
- // if grouping with the previous action, only update the present
1889
- var groupedState = (0, helpers.newHistory)(history.past, res, history.future, history.group);
1890
- debug$1.log('groupBy grouped the action with the previous action');
1891
- debug$1.end(groupedState);
1892
- return groupedState;
1893
- } // If the action wasn't filtered or grouped, insert normally
1894
-
1895
-
1896
- history = insert(history, res, config.limit, group);
1897
- debug$1.log('inserted new state into history');
1898
- debug$1.end(history);
1899
- return history;
1900
- }
1901
- };
1902
- }
1903
- });
1904
-
1905
- var lib = createCommonjsModule(function (module, exports) {
1906
-
1907
- Object.defineProperty(exports, "__esModule", {
1908
- value: true
1909
- });
1910
- Object.defineProperty(exports, "ActionTypes", {
1911
- enumerable: true,
1912
- get: function get() {
1913
- return actions.ActionTypes;
1914
- }
1915
- });
1916
- Object.defineProperty(exports, "ActionCreators", {
1917
- enumerable: true,
1918
- get: function get() {
1919
- return actions.ActionCreators;
1920
- }
1921
- });
1922
- Object.defineProperty(exports, "parseActions", {
1923
- enumerable: true,
1924
- get: function get() {
1925
- return helpers.parseActions;
1926
- }
1927
- });
1928
- Object.defineProperty(exports, "isHistory", {
1929
- enumerable: true,
1930
- get: function get() {
1931
- return helpers.isHistory;
1932
- }
1933
- });
1934
- Object.defineProperty(exports, "includeAction", {
1935
- enumerable: true,
1936
- get: function get() {
1937
- return helpers.includeAction;
1938
- }
1939
- });
1940
- Object.defineProperty(exports, "excludeAction", {
1941
- enumerable: true,
1942
- get: function get() {
1943
- return helpers.excludeAction;
1944
- }
1945
- });
1946
- Object.defineProperty(exports, "combineFilters", {
1947
- enumerable: true,
1948
- get: function get() {
1949
- return helpers.combineFilters;
1950
- }
1951
- });
1952
- Object.defineProperty(exports, "groupByActionTypes", {
1953
- enumerable: true,
1954
- get: function get() {
1955
- return helpers.groupByActionTypes;
1956
- }
1957
- });
1958
- Object.defineProperty(exports, "newHistory", {
1959
- enumerable: true,
1960
- get: function get() {
1961
- return helpers.newHistory;
1962
- }
1963
- });
1964
- Object.defineProperty(exports, "default", {
1965
- enumerable: true,
1966
- get: function get() {
1967
- return _reducer["default"];
1968
- }
1969
- });
1970
-
1971
-
1972
-
1973
-
1974
-
1975
- var _reducer = _interopRequireDefault(reducer);
1976
-
1977
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
1978
- });
1979
-
1980
- const undoable = /*@__PURE__*/getDefaultExportFromCjs(lib);
1981
-
1982
- const inicialHistState = {
1983
- currentTabIndex: {},
1984
- currentRecordIndex: {},
1985
- changes: {},
1986
- collapsedGroups: {},
1987
- newRecordIndex: {}
1988
- };
1989
- const inicialNonHistState = {
1990
- dataLoading: {},
1991
- invalidFields: {},
1992
- visibleButtons: {
1993
- previousVisible: true,
1994
- nextVisible: true,
1995
- addVisible: true,
1996
- removeVisible: true,
1997
- saveVisible: true,
1998
- cancelVisible: true,
1999
- reloadVisible: false
2000
- }
2001
- };
2002
- function formReducer(state = inicialHistState, action) {
2003
- switch (action.type) {
2004
- case "FORM/COLLAPSEGROUP":
2005
- return collapseGroup(state, action.payload);
2006
- case "FORM/CHANGETAB":
2007
- return changeTab(state, action.payload.formId, action.payload.index);
2008
- case "FORM/NAVIGATE":
2009
- return navigate(state, action.payload);
2010
- case "FORM/INSERT":
2011
- return insertRecord(state, action.payload);
2012
- case "FORM/CHANGEFIELD":
2013
- return changeFieldValue(state, action.payload);
2014
- case "FORM/CLEAREDITION":
2015
- return clearEdition(state, action.payload);
2016
- case "FORM/INVALIDFIELD":
2017
- return navigateToInvalid(state, action.payload);
2018
- default:
2019
- return state;
2020
- }
2021
- }
2022
- function formNonHistoricReducer(state = inicialNonHistState, action) {
2023
- switch (action.type) {
2024
- case "FORM/DATALOADING":
2025
- return dataLoading(state, action.payload);
2026
- case "FORM/DATALOADED":
2027
- return dataLoaded(state, action.payload);
2028
- case "FORM/SAVINGCHANGES":
2029
- return savingChanges(state, action.payload);
2030
- case "FORM/CHANGESSAVED":
2031
- return changesSaved(state, action.payload);
2032
- case "FORM/REMOVINGRECORD":
2033
- return removingRecord(state, action.payload);
2034
- case "FORM/RECORDREMOVED":
2035
- return recordRemoved(state, action.payload);
2036
- case "FORM/INVALIDFIELD":
2037
- return invalidField(state, action.payload);
2038
- case "FORM/CLEAREDITION":
2039
- return clearAllInvalidFields(state, action.payload);
2040
- case "FORM/CHANGEFIELD":
2041
- return clearInvalidField(state, action.payload);
2042
- case "FORM/SHOWHIDENAVBTN":
2043
- return showHideNavBtn(state, action.payload);
2044
- default:
2045
- return state;
2046
- }
2047
- }
2048
- function collapseGroup(state, { collapseId, collapsed }) {
2049
- const currentCollapsed = Object.assign({}, state.collapsedGroups);
2050
- if (collapsed) {
2051
- currentCollapsed[collapseId] = true;
2052
- }
2053
- else {
2054
- delete currentCollapsed[collapseId];
2055
- }
2056
- return Object.assign(Object.assign({}, state), { collapsedGroups: currentCollapsed });
2057
- }
2058
- function changeTab(state, formId, index) {
2059
- const currentTabIndex = Object.assign({}, state.currentTabIndex);
2060
- currentTabIndex[formId] = index;
2061
- return Object.assign(Object.assign({}, state), { currentTabIndex });
2062
- }
2063
- function navigate(state, { dataUnit, limit, backward }) {
2064
- const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
2065
- const recIndex = currentRecordIndex[dataUnit] || 0;
2066
- return gotoIndex(state, dataUnit, backward ? Math.max(limit, recIndex - 1) : Math.min(limit, recIndex + 1));
2067
- }
2068
- function gotoIndex(state, dataUnit, index) {
2069
- const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
2070
- currentRecordIndex[dataUnit] = index;
2071
- return Object.assign(Object.assign({}, state), { currentRecordIndex });
2072
- }
2073
- function insertRecord(state, { dataUnit, insertionIndex }) {
2074
- const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
2075
- const newRecordIndex = Object.assign({}, state.newRecordIndex);
2076
- currentRecordIndex[dataUnit] = insertionIndex;
2077
- newRecordIndex[dataUnit] = (state.newRecordIndex[dataUnit] || 0) + 1;
2078
- return Object.assign(Object.assign({}, state), { currentRecordIndex,
2079
- newRecordIndex });
2080
- }
2081
- function changeFieldValue(state, { dataUnit, recordId, fieldName, value }) {
2082
- const changes = Object.assign({}, state.changes);
2083
- const dataUnitChanges = Object.assign({}, changes[dataUnit]);
2084
- const recordChanges = Object.assign({}, dataUnitChanges[recordId]);
2085
- recordChanges[fieldName] = value;
2086
- dataUnitChanges[recordId] = recordChanges;
2087
- changes[dataUnit] = dataUnitChanges;
2088
- const invalidFields = Object.assign({}, state.invalidFields);
2089
- const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
2090
- const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
2091
- delete errorMessages[fieldName];
2092
- dataUnitInvalidRecords[recordId] = errorMessages;
2093
- invalidFields[dataUnit] = dataUnitInvalidRecords;
2094
- return Object.assign(Object.assign({}, state), { changes,
2095
- invalidFields, invalidFieldSelected: undefined });
2096
- }
2097
- function clearEdition(state, { dataUnit, recordsLimit }) {
2098
- const changes = Object.assign({}, state.changes);
2099
- const newRecordIndex = Object.assign({}, state.newRecordIndex);
2100
- const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
2101
- delete changes[dataUnit];
2102
- delete newRecordIndex[dataUnit];
2103
- const recIndex = currentRecordIndex[dataUnit] || 0;
2104
- currentRecordIndex[dataUnit] = Math.min(recordsLimit, recIndex);
2105
- return Object.assign(Object.assign({}, state), { changes,
2106
- newRecordIndex,
2107
- currentRecordIndex });
2108
- }
2109
- function navigateToInvalid(state, payload) {
2110
- let newState = Object.assign({}, state);
2111
- if (newState.invalidFieldSelected === undefined) {
2112
- newState.invalidFieldSelected = true;
2113
- newState = gotoIndex(newState, payload.dataUnit, payload.recordIndex);
2114
- newState = changeTab(newState, payload.tabController, payload.tabIndex);
2115
- }
2116
- return newState;
2117
- }
2118
- function dataLoading(state, { dataUnit }) {
2119
- const dataLoading = Object.assign({}, state.dataLoading);
2120
- dataLoading[dataUnit] = true;
2121
- return Object.assign(Object.assign({}, state), { dataLoading });
2122
- }
2123
- function dataLoaded(state, { dataUnit }) {
2124
- const dataLoading = Object.assign({}, state.dataLoading);
2125
- delete dataLoading[dataUnit];
2126
- return Object.assign(Object.assign({}, state), { dataLoading });
2127
- }
2128
- function savingChanges(state, { dataUnit }) {
2129
- const dataLoading = Object.assign({}, state.dataLoading);
2130
- dataLoading[dataUnit] = true;
2131
- return Object.assign(Object.assign({}, state), { dataLoading });
2132
- }
2133
- function changesSaved(state, { dataUnit }) {
2134
- const dataLoading = Object.assign({}, state.dataLoading);
2135
- delete dataLoading[dataUnit];
2136
- return Object.assign(Object.assign({}, state), { dataLoading });
2137
- }
2138
- function removingRecord(state, { dataUnit }) {
2139
- const dataLoading = Object.assign({}, state.dataLoading);
2140
- dataLoading[dataUnit] = true;
2141
- return Object.assign(Object.assign({}, state), { dataLoading });
2142
- }
2143
- function recordRemoved(state, { dataUnit }) {
2144
- const dataLoading = Object.assign({}, state.dataLoading);
2145
- delete dataLoading[dataUnit];
2146
- return Object.assign(Object.assign({}, state), { dataLoading });
2147
- }
2148
- function invalidField(state, { dataUnit, recordId, fieldName, errorMessage }) {
2149
- const invalidFields = Object.assign({}, state.invalidFields);
2150
- const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
2151
- const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
2152
- errorMessages[fieldName] = errorMessage;
2153
- dataUnitInvalidRecords[recordId] = errorMessages;
2154
- invalidFields[dataUnit] = dataUnitInvalidRecords;
2155
- return Object.assign(Object.assign({}, state), { invalidFields });
2156
- }
2157
- function clearAllInvalidFields(state, { dataUnit }) {
2158
- const invalidFields = Object.assign({}, state.invalidFields);
2159
- delete invalidFields[dataUnit];
2160
- return Object.assign(Object.assign({}, state), { invalidFields });
2161
- }
2162
- function clearInvalidField(state, { dataUnit, recordId, fieldName }) {
2163
- const invalidFields = Object.assign({}, state.invalidFields);
2164
- const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
2165
- const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
2166
- delete errorMessages[fieldName];
2167
- dataUnitInvalidRecords[recordId] = errorMessages;
2168
- invalidFields[dataUnit] = dataUnitInvalidRecords;
2169
- return Object.assign(Object.assign({}, state), { invalidFields });
2170
- }
2171
- function showHideNavBtn(state, { buttonName, status }) {
2172
- const visibleButtons = Object.assign({}, state.visibleButtons);
2173
- visibleButtons[buttonName] = status;
2174
- return Object.assign(Object.assign({}, state), { visibleButtons });
2175
- }
2176
-
2177
- class Application {
2178
- static async showDialog(title, message, icon = null, confirm, critical = false) {
2179
- return new Promise(resolve => {
2180
- let dialog = document.querySelector("ez-dialog");
2181
- if (!dialog) {
2182
- dialog = document.createElement("ez-dialog");
2183
- window.document.body.appendChild(dialog);
2184
- }
2185
- dialog.show(title, message, critical, confirm, icon).then(ok => resolve(ok));
2186
- });
2187
- }
2188
- static async alert(title, message, icon = null) {
2189
- return Application.showDialog(title, message, icon, false, false);
2190
- }
2191
- static async error(title, message, icon = null) {
2192
- return Application.showDialog(title, message, icon, false, true);
2193
- }
2194
- static async confirm(title, message, icon = null, critical = false) {
2195
- return Application.showDialog(title, message, icon, true, critical);
2196
- }
2197
- static async info(message) {
2198
- let toast = document.querySelector("ez-toast");
2199
- if (!toast) {
2200
- toast = document.createElement("ez-toast");
2201
- window.document.body.appendChild(toast);
2202
- }
2203
- toast.message = message;
2204
- toast.fadeTime = 4000;
2205
- toast.show();
2206
- }
2207
- }
2208
-
2209
- function removeHandler(dataUnit) {
2210
- Application.confirm("Exclusão de registro", "Tem certeza que deseja Remover?", null, true).then(ok => {
2211
- if (ok) {
2212
- dataUnit.remove();
2213
- }
2214
- });
2215
- }
2216
- function saveHandler(dataUnit) {
2217
- setTimeout(() => {
2218
- //Esse debouncing é necessário quando o usuário clica no botão de salvar
2219
- //sem ter tirado o foco o último campo alterado.
2220
- dataUnit.save();
2221
- }, 50);
2222
- }
2223
- const NavigationBar = ({ dataUnit: du, buttonProps, enabled }) => {
2224
- if (buttonProps.previousVisible
2225
- || buttonProps.nextVisible
2226
- || buttonProps.addVisible
2227
- || buttonProps.removeVisible
2228
- || buttonProps.saveVisible
2229
- || buttonProps.cancelVisible
2230
- || buttonProps.reloadVisible) {
2231
- return h("div", { class: "col col--sd-12 align--right" },
2232
- buttonProps.previousVisible ? h("ez-button", { key: du.name + "_previous", title: "Registro anterior", mode: "icon", enabled: enabled && du.hasPrevious(), onClick: () => du.previous(), image: "/themes/default/images/icons/actions-sprite.svg#previous-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
2233
- buttonProps.nextVisible ? h("ez-button", { key: du.name + "_next", title: "Pr\u00F3ximo registro", mode: "icon", enabled: enabled && du.hasNext(), onClick: () => du.next(), image: "/themes/default/images/icons/actions-sprite.svg#next-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
2234
- buttonProps.removeVisible ? h("ez-button", { key: du.name + "_remove", label: "Remover", enabled: enabled && du.hasCurrentRecord(), onClick: () => removeHandler(du), image: "/themes/default/images/icons/actions-sprite.svg#minus-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
2235
- buttonProps.addVisible ? h("ez-button", { key: du.name + "_add", label: "Adicionar", enabled: enabled, onClick: () => du.insert(), class: "button--secondary margin-right--medium" }) : null,
2236
- buttonProps.reloadVisible ? h("ez-button", { key: du.name + "_reload", title: "Recarregar", enabled: enabled, mode: "icon", onClick: () => du.load(), image: "/themes/default/images/icons/actions-sprite.svg#rotate", class: "button--secondary margin-right--medium" }) : null,
2237
- buttonProps.cancelVisible ? h("ez-button", { key: du.name + "_cancel", label: "Cancelar", enabled: enabled && du.hasChanges(), onClick: () => du.cancel(), class: "button--secondary margin-right--medium" }) : null,
2238
- buttonProps.saveVisible ? h("ez-button", { key: du.name + "_save", label: "Salvar", enabled: enabled && du.hasChanges(), onClick: () => saveHandler(du), class: "button--primary margin-right--medium" }) : null);
2239
- }
2240
- else {
2241
- return null;
2242
- }
2243
- };
2244
-
2245
- //histórico
2246
- const selectCurrentTab = (state, formName) => {
2247
- const data = state.hist.present.currentTabIndex;
2248
- return data[formName] || 0;
2249
- };
2250
- const selectIsCollapsedFieldSet = (state, fieldSetName) => {
2251
- const data = state.hist.present.collapsedGroups;
2252
- return data[fieldSetName];
2253
- };
2254
- const selectRecordChanges = (state, dataUnit, recordId) => {
2255
- const data = selectDataUnitChanges(state, dataUnit);
2256
- return data ? data[recordId] : undefined;
2257
- };
2258
- const selectDataUnitChanges = (state, dataUnit) => {
2259
- const data = state.hist.present.changes;
2260
- return data[dataUnit];
2261
- };
2262
- const selectCurrentRecordIndex = (state, dataUnit) => {
2263
- const data = state.hist.present.currentRecordIndex;
2264
- return data[dataUnit] || 0;
2265
- };
2266
- const selectNewRecordIndex = (state, dataUnit) => {
2267
- const data = state.hist.present.newRecordIndex;
2268
- return data[dataUnit] || 0;
2269
- };
2270
- //não histórico
2271
- const selectLoadingData = (state, dataUnit) => {
2272
- const data = state.nonhist.dataLoading;
2273
- return data[dataUnit];
2274
- };
2275
- const selectErrorMessage = (state, dataUnit, recordId, fieldName) => {
2276
- const data = state.nonhist.invalidFields;
2277
- const dataUnitMessages = data[dataUnit] || {};
2278
- const recordMessages = dataUnitMessages[recordId] || {};
2279
- return recordMessages[fieldName] || "";
2280
- };
2281
- const selectVisibleButtons = state => state.nonhist.visibleButtons;
2282
-
2283
- class DataUnit {
2284
- constructor(name, unitLabel, cardinality = "1", parentDU = null) {
2285
- this.name = name;
2286
- this.unitLabel = unitLabel;
2287
- this.cardinality = cardinality;
2288
- this._children = [];
2289
- this._fields = new Map();
2290
- this._requiredFields = [];
2291
- if (parentDU != null) {
2292
- parentDU._children.push(this);
2293
- this.parentDU = parentDU;
2294
- this.parentDUName = parentDU.name;
2295
- }
2296
- }
2297
- set store(store) {
2298
- this._store = store;
2299
- }
2300
- set fields(value) {
2301
- if (value) {
2302
- value.forEach(f => this.addFieldMetadata(f));
2303
- }
2304
- }
2305
- addFieldMetadata(field) {
2306
- this._fields.set(field.name, field);
2307
- if (field.required) {
2308
- this._requiredFields.push(field);
2309
- }
2310
- }
2311
- getFieldMetadata(name) {
2312
- if (this._fields) {
2313
- return this._fields.get(name);
2314
- }
2315
- return undefined;
2316
- }
2317
- get requiredFields() {
2318
- return this._requiredFields;
2319
- }
2320
- isLoading() {
2321
- return selectLoadingData(this._store.getState(), this.name);
2322
- }
2323
- hasChanges() {
2324
- const state = this._store.getState();
2325
- return selectDataUnitChanges(state, this.name) !== undefined || selectNewRecordIndex(state, this.name) > 0;
2326
- }
2327
- hasNext() {
2328
- return selectCurrentRecordIndex(this._store.getState(), this.name) < (this.records.length - 1);
2329
- }
2330
- hasPrevious() {
2331
- return selectCurrentRecordIndex(this._store.getState(), this.name) > 0;
2332
- }
2333
- hasCurrentRecord() {
2334
- return this.getCurrentRecord() != undefined;
2335
- }
2336
- previous() {
2337
- this._store.dispatch(previousRecord(this.name));
2338
- }
2339
- next() {
2340
- this._store.dispatch(nextRecord(this.name, this.records.length));
2341
- }
2342
- getValue(fieldName) {
2343
- const currentRecord = this.getCurrentRecord();
2344
- if (!currentRecord) {
2345
- return undefined;
2346
- }
2347
- const changes = this.getRecordChanges(currentRecord);
2348
- return changes && changes[fieldName] !== undefined ? changes[fieldName] : currentRecord[fieldName] || null;
2349
- }
2350
- getErrorMessage(fieldName) {
2351
- const currentRecord = this.getCurrentRecord();
2352
- return selectErrorMessage(this._store.getState(), this.name, currentRecord === null || currentRecord === void 0 ? void 0 : currentRecord.record__id, fieldName);
2353
- }
2354
- changeValue(fieldName, newValue) {
2355
- if (this.records.length == 0) {
2356
- this.insert();
2357
- }
2358
- if (this._changeDeboucing) {
2359
- window.clearTimeout(this._changeDeboucing);
2360
- }
2361
- this._changeDeboucing = window.setTimeout(() => {
2362
- const currentRecord = this.getCurrentRecord();
2363
- this._store.dispatch(changeFieldValue$1(this.name, currentRecord.record__id, fieldName, newValue));
2364
- }, 100);
2365
- }
2366
- cancel() {
2367
- this.records = this.records.filter(r => !r.record__id.startsWith("NEW_"));
2368
- this._store.dispatch(clearEdition$1(this.name, this.records.length - 1));
2369
- }
2370
- insert() {
2371
- const insertionIndex = this.records.length;
2372
- const newRecordIndex = selectNewRecordIndex(this._store.getState(), this.name);
2373
- const newRecord = { record__id: "NEW_" + (newRecordIndex + 1) };
2374
- this.bindToParent(newRecord);
2375
- this.records.push(newRecord);
2376
- this._store.dispatch(insertRecord$1(this.name, insertionIndex));
2377
- }
2378
- buildChange(r) {
2379
- const duChanges = selectDataUnitChanges(this._store.getState(), this.name);
2380
- let recordChanges;
2381
- if (duChanges) {
2382
- recordChanges = duChanges[r.record__id];
2383
- }
2384
- let subChanges = [];
2385
- this._children.forEach(duChild => {
2386
- subChanges = subChanges.concat(duChild.getSubChanges(r.record__id));
2387
- });
2388
- if (recordChanges || subChanges.length > 0) {
2389
- const change = {
2390
- "__data__unit": this.name,
2391
- "__record__id": r.record__id,
2392
- "__sub__changes": subChanges
2393
- };
2394
- if (recordChanges) {
2395
- Object.keys(recordChanges).forEach(fieldName => { change[fieldName] = recordChanges[fieldName]; });
2396
- }
2397
- return change;
2398
- }
2399
- return undefined;
2400
- }
2401
- getSubChanges(id) {
2402
- const result = [];
2403
- if (this._records) {
2404
- this._records.filter(r => r.parent__record__id === id).forEach(r => {
2405
- const c = this.buildChange(r);
2406
- if (c) {
2407
- result.push(c);
2408
- }
2409
- });
2410
- }
2411
- return result;
2412
- }
2413
- getChangesToSave() {
2414
- let result = [];
2415
- if (this._records) {
2416
- this._records.forEach(r => {
2417
- const change = this.buildChange(r);
2418
- if (change) {
2419
- result.push(change);
2420
- }
2421
- });
2422
- }
2423
- return result;
2424
- }
2425
- save() {
2426
- if (!this.validateRecords("SAVE")) {
2427
- return;
2428
- }
2429
- this._store.dispatch(savingChanges$1(this.name));
2430
- let saveResult;
2431
- if (this.saveExecutor) {
2432
- saveResult = this.saveExecutor(this.getChangesToSave());
2433
- }
2434
- if (saveResult instanceof Promise) {
2435
- saveResult
2436
- .then(r => this.processSaveResult(r))
2437
- .catch(e => {
2438
- this._store.dispatch(dataLoaded$1(this.name));
2439
- Application.error("Falha ao tentar salvar", e);
2440
- });
2441
- }
2442
- else {
2443
- this.processSaveResult(saveResult);
2444
- }
2445
- }
2446
- load() {
2447
- this._store.dispatch(dataLoading$1(this.name));
2448
- let result;
2449
- if (this.loadExecutor) {
2450
- result = this.loadExecutor({ dataUnit: this.name });
2451
- }
2452
- if (result instanceof Promise) {
2453
- result.then(r => this.processLoadResult(r));
2454
- }
2455
- else {
2456
- this.processLoadResult(result);
2457
- }
2458
- }
2459
- remove() {
2460
- const currentIndex = selectCurrentRecordIndex(this._store.getState(), this.name);
2461
- this._store.dispatch(removingRecord$1(this.name));
2462
- let removeResult;
2463
- if (this.removeExecutor) {
2464
- const record = this.getCurrentRecord();
2465
- removeResult = this.removeExecutor({ dataUnit: this.name, recordId: record.record__id, record });
2466
- }
2467
- else {
2468
- removeResult = true;
2469
- }
2470
- if (removeResult) {
2471
- if (removeResult instanceof Promise) {
2472
- removeResult.then(r => this.processRemoveResult(r, currentIndex));
2473
- }
2474
- else {
2475
- this.processRemoveResult(removeResult, currentIndex);
2476
- }
2477
- }
2478
- }
2479
- processSaveResult(result) {
2480
- if (result) {
2481
- if (result instanceof Array) {
2482
- result.forEach(item => this.processSaveResult(item));
2483
- }
2484
- else {
2485
- if (result.__data__unit === this.name) {
2486
- if (this.cardinality === "1") {
2487
- this.records = [this.buildRecordFromSaveResult(this.records[0], result)];
2488
- }
2489
- }
2490
- }
2491
- }
2492
- //FIXME: Isso está errado! tem que limpar todas as edições
2493
- this._store.dispatch(clearEdition$1(this.name, this.records.length - 1));
2494
- this._store.dispatch(changesSaved$1(this.name));
2495
- }
2496
- buildRecordFromSaveResult(baseRecord, saveResult) {
2497
- const newRecord = baseRecord ? Object.assign({}, baseRecord) : { record__id: "" };
2498
- Object.keys(saveResult).forEach(attrib => {
2499
- if (!attrib.startsWith("__")) {
2500
- newRecord[attrib] = saveResult[attrib];
2501
- }
2502
- });
2503
- return newRecord;
2504
- }
2505
- processLoadResult(records) {
2506
- this.records = records;
2507
- this._store.dispatch(clearEdition$1(this.name, this.records.length - 1));
2508
- this._store.dispatch(dataLoaded$1(this.name));
2509
- }
2510
- processRemoveResult(removed, recordIndex) {
2511
- if (removed) {
2512
- this.records.splice(recordIndex, 1);
2513
- this._store.dispatch(clearEdition$1(this.name, this.records.length - 1));
2514
- }
2515
- this._store.dispatch(recordRemoved$1(this.name));
2516
- }
2517
- set records(records) {
2518
- this._records = records;
2519
- if (this.parentDU) {
2520
- this._records.forEach(r => this.bindToParent(r));
2521
- }
2522
- }
2523
- bindToParent(r) {
2524
- if (this.parentDU) {
2525
- const parentRecord = this.parentDU.getCurrentRecord();
2526
- if (parentRecord) {
2527
- r.parent__record__id = parentRecord.record__id;
2528
- }
2529
- }
2530
- }
2531
- get records() {
2532
- if (!this._records) {
2533
- this._records = [];
2534
- }
2535
- return this._records;
2536
- }
2537
- getCurrentRecord() {
2538
- const currentIndex = selectCurrentRecordIndex(this._store.getState(), this.name);
2539
- return this.records[currentIndex];
2540
- }
2541
- getRecordChanges(currentRecord = undefined) {
2542
- if (currentRecord === undefined) {
2543
- currentRecord = this.getCurrentRecord();
2544
- }
2545
- return currentRecord ? selectRecordChanges(this._store.getState(), this.name, currentRecord.record__id) : undefined;
2546
- }
2547
- validateRecords(triggedBy = "UNKNOWN") {
2548
- if (!this.recordsValidator) {
2549
- return true;
2550
- }
2551
- const duChanges = selectDataUnitChanges(this._store.getState(), this.name);
2552
- const recordsToValidate = [];
2553
- this.records.forEach((record, i) => {
2554
- const changes = duChanges ? duChanges[record.record__id] : undefined;
2555
- if (changes) {
2556
- recordsToValidate.push(Object.assign(Object.assign(Object.assign({}, record), changes), { record__index: i, record__changedfields: Object.keys(changes) }));
2557
- }
2558
- });
2559
- const result = this.recordsValidator.validateRecords(this, recordsToValidate, triggedBy);
2560
- if (result.message) {
2561
- Application.info(result.message);
2562
- }
2563
- return result.isValid;
2564
- }
2565
- }
2566
- var DependencyType;
2567
- (function (DependencyType) {
2568
- DependencyType["SEARCHING"] = "SEARCHING";
2569
- DependencyType["REQUIREMENT"] = "REQUIREMENT";
2570
- DependencyType["VISIBILITY"] = "REQUIREMENT";
2571
- })(DependencyType || (DependencyType = {}));
2572
-
2573
- function scrollToView(forceScroll, elem) {
2574
- if (forceScroll) {
2575
- window.requestAnimationFrame(() => elem.scrollIntoView());
2576
- }
2577
- }
2578
- const Field = ({ dataUnit, field, forceScroll, enabled }) => {
2579
- const { name, form } = field;
2580
- const { label, userInterface, properties, required, dependencies, readOnly } = dataUnit.getFieldMetadata(name);
2581
- const value = dataUnit.getValue(name) || null;
2582
- const loadingData = dataUnit.isLoading();
2583
- const formattedLabel = required ? `* ${label} (obrigatório)` : label;
2584
- const errorMessage = dataUnit.getErrorMessage(name);
2585
- const key = `${dataUnit.name}-${name}`;
2586
- const isEnabled = enabled && !readOnly;
2587
- const changeFieldHandler = (newValue) => {
2588
- dataUnit.changeValue(name, newValue);
2589
- };
2590
- switch (userInterface) {
2591
- case "LONGTEXT":
2592
- return h("div", { class: "col col--sd-12 padding--small" }, loadingData ? h("place-holder", null) :
2593
- h("ez-text-area", { value: value || "", label: formattedLabel, onEzChange: evt => changeFieldHandler(evt.target["value"]), errorMessage: errorMessage, ref: elem => scrollToView(forceScroll, elem), key: key, enabled: isEnabled }));
2594
- case "CHECKBOX":
2595
- case "SWITCH":
2596
- return h("div", { class: "col col--sd-12 col--tb-3 padding--small align--middle padding-bottom--large" }, loadingData ? h("place-holder", null) :
2597
- h("ez-check", { value: value, label: label, enabled: isEnabled, mode: userInterface === "CHECKBOX" ? "regular" : "switch", onEzChange: (event) => changeFieldHandler(event.target["value"]), ref: elem => scrollToView(forceScroll, elem), key: key }));
2598
- case "OPTIONSELECTOR":
2599
- const optsObj = properties ? JSON.parse(getProp(properties, "options")) : {};
2600
- const normalized = Object.keys(optsObj).map(key => { return { value: key, label: optsObj[key] }; });
2601
- return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
2602
- h("ez-combo-box", { value: value, label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, ref: elem => scrollToView(forceScroll, elem), key: key, options: normalized }));
2603
- case "SEARCH":
2604
- const context = {
2605
- __MAIN_FORM: form,
2606
- __DATA_UNIT: dataUnit.name,
2607
- __FIELD_NAME: name
2608
- };
2609
- properties.forEach(({ name, value }) => {
2610
- context[name] = value;
2611
- });
2612
- let criteriaList = [];
2613
- dependencies === null || dependencies === void 0 ? void 0 : dependencies.forEach(dependency => {
2614
- var _a;
2615
- if (dependency.type === DependencyType.SEARCHING) {
2616
- if (((_a = dependency.masterFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
2617
- let criteria = {
2618
- expression: dependency.expression,
2619
- paramNames: [...dependency.masterFields],
2620
- paramResolver: name => dataUnit.getValue(name)
2621
- };
2622
- criteriaList.push(criteria);
2623
- }
2624
- }
2625
- });
2626
- if (criteriaList.length > 0) {
2627
- context["CRITERIA"] = criteriaList;
2628
- }
2629
- return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
2630
- h("ez-search", { value: value, label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, optionLoader: (argument) => {
2631
- if (form) {
2632
- return form.loadSearch(argument, context);
2633
- }
2634
- }, ref: elem => scrollToView(forceScroll, elem), key: key }));
2635
- case "FILE":
2636
- const target = getProp(properties, "URL");
2637
- const strHeaders = getProp(properties, "HEADERS");
2638
- const headers = strHeaders ? JSON.parse(strHeaders) : {};
2639
- const maxfiles = Number(getProp(properties, "maxfiles") || 0);
2640
- return (h("div", { class: "col col--sd-12 padding--small" }, loadingData ? h("place-holder", null) :
2641
- h("ez-upload", { value: value, label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.detail), urlUpload: target, requestHeaders: headers, maxFiles: maxfiles })));
2642
- case "DATE":
2643
- return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
2644
- h("ez-date-input", { value: !value ? null : DateUtils.clearTime(value), label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, ref: elem => scrollToView(forceScroll, elem), key: key }));
2645
- case "DECIMALNUMBER":
2646
- case "INTEGERNUMBER":
2647
- let precision = 0;
2648
- let prettyPrecision = 0;
2649
- if (userInterface === "DECIMALNUMBER") {
2650
- precision = Number(getProp(properties, "precision") || 2);
2651
- prettyPrecision = Number(getProp(properties, "prettyprecision") || precision);
2652
- }
2653
- return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
2654
- h("ez-numeric-input", { value: !value ? null : value, label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, precision: precision, prettyprecision: prettyPrecision, ref: elem => scrollToView(forceScroll, elem), key: key }));
2655
- //IMAGE, DATETIME, ELAPSEDTIME, PASSWORD, MASKEDTEXT, HTML
2656
- default:
2657
- return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
2658
- h("ez-text-input", { value: value, label: formattedLabel, enabled: isEnabled, loading: loadingData, onInput: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, ref: elem => scrollToView(forceScroll, elem), key: key }));
2659
- }
2660
- };
2661
- function getProp(properties, name) {
2662
- var _a;
2663
- return properties ? (_a = properties.find(prop => prop.name === name)) === null || _a === void 0 ? void 0 : _a.value : null;
2664
- }
2665
-
2666
- const FieldSet = ({ store, formName, source, dataUnit, enabled }) => {
2667
- const { label, fields } = source;
2668
- const fieldSetName = formName + label;
2669
- let isCollapsed = selectIsCollapsedFieldSet(store.getState(), formName + label);
2670
- let fieldToScroll;
2671
- source.fields.forEach((field) => {
2672
- if (fieldToScroll === undefined) {
2673
- const fieldError = dataUnit.getErrorMessage(field.name);
2674
- if (fieldError !== undefined && fieldError !== null && fieldError !== "") {
2675
- fieldToScroll = field.name;
2676
- }
2677
- }
2678
- });
2679
- if (fieldToScroll) {
2680
- isCollapsed = false;
2681
- }
2682
- return h("div", { class: "col col--sd-12 padding--small" },
2683
- h("div", { class: "row margin-top--large" },
2684
- h("div", { class: "col col--sd-12 align--middle padding-horizontal--medium" },
2685
- h("ez-collapsible-box", { value: isCollapsed, label: label, onEzChange: () => store.dispatch(collapseExpandGroup(fieldSetName, !isCollapsed)) }),
2686
- isCollapsed ? null :
2687
- h("div", { class: "col col--sd-12" }, fields.map(field => h(Field, { enabled: enabled, field: field, dataUnit: dataUnit, forceScroll: fieldToScroll === field.name }))))));
2688
- };
2689
-
2690
- function buildFormItem(source, formName, store, dataUnit, enabled) {
2691
- if ("fields" in source) {
2692
- return h(FieldSet, { enabled: enabled, source: source, store: store, formName: formName, dataUnit: dataUnit });
2693
- }
2694
- const fieldName = source.name;
2695
- const errorMsg = dataUnit.getErrorMessage(fieldName);
2696
- const forceScroll = errorMsg === undefined || errorMsg === null || errorMsg === "" ? false : true;
2697
- return h(Field, { enabled: enabled, field: source, dataUnit: dataUnit, forceScroll: forceScroll });
2698
- }
2699
- const FormSheet = ({ store, parentName, source, parentDataUnit, dataUnitBuilder, enabled }) => {
2700
- const selectedTab = selectCurrentTab(store.getState(), parentName);
2701
- const tabs = source.length > 1 ? source.map(form => h("ez-tab", { label: form.label, tabKey: form.name })) : null;
2702
- const { subForms, items, name } = source[selectedTab];
2703
- const dataUnit = dataUnitBuilder(source[selectedTab].dataUnit, parentDataUnit);
2704
- source[selectedTab].dataUnit = dataUnit;
2705
- const hasSubForms = subForms && subForms.length > 0;
2706
- const changeTabHandler = (index) => {
2707
- store.dispatch(changeTab$1(parentName, index));
2708
- };
2709
- //todos os campos e subformulários precisam estar ligados a um DU
2710
- const currentDU = dataUnit || parentDataUnit;
2711
- let buttons = selectVisibleButtons(store.getState());
2712
- if (currentDU.cardinality === "1") {
2713
- buttons.addVisible = false;
2714
- buttons.removeVisible = false;
2715
- buttons.nextVisible = false;
2716
- buttons.previousVisible = false;
2717
- }
2718
- return h("div", { class: "form-sheet" },
2719
- tabs ? h("ez-tabselector", { selectedIndex: selectedTab, selectedTab: name, onChange: (evt) => changeTabHandler(evt.target.selectedindex) }, tabs) : null,
2720
- dataUnit ? h(NavigationBar, { enabled: enabled, dataUnit: dataUnit, buttonProps: buttons }) : null,
2721
- h("div", { class: "tab__container" },
2722
- items ? items.map(item => buildFormItem(item, name, store, currentDU, enabled)) : null,
2723
- hasSubForms ? h(FormSheet, { enabled: enabled, store: store, source: subForms, parentName: name, parentDataUnit: currentDU, dataUnitBuilder: dataUnitBuilder }) : null));
2724
- };
2725
-
2726
- const ezFormCss = "ez-form{display:flex;flex-direction:column;width:100%}.form-sheet{display:flex;width:100%;flex-wrap:wrap;position:relative}.tab__container{display:flex;width:100%;flex-wrap:wrap;position:relative}";
2727
-
2728
- let EzForm = class {
2729
- constructor(hostRef) {
2730
- registerInstance(this, hostRef);
2731
- this.enabled = true;
2732
- this.loading = false;
2733
- this._dataUnits = new Map();
2734
- this._duSources = new Map();
2735
- this._tabPositionByField = new Map();
2736
- this._duToLoad = [];
2737
- }
2738
- cleanPreparedMetadata() {
2739
- this._preparedMetadata = undefined;
2740
- }
2741
- async validate() {
2742
- const duSourcesNames = Array.from(this._duSources.keys());
2743
- for (let i = 0; i < this._duSources.size; i++) {
2744
- const duName = duSourcesNames[i];
2745
- let du = this._dataUnits.get(duName);
2746
- if (du === undefined) {
2747
- const source = this._duSources.get(duName);
2748
- du = this.buildDataUnit(source, source.parentDUName);
2749
- }
2750
- if (!du.validateRecords()) {
2751
- return false;
2752
- }
2753
- }
2754
- return true;
2755
- }
2756
- async getChanges() {
2757
- let allChanges = [];
2758
- const dataUnits = Array.from(this._dataUnits.values());
2759
- for (let i = 0; i < this._dataUnits.size; i++) {
2760
- const du = dataUnits[i];
2761
- //Só devemos buscar as alterações de DU raiz, pois os sub DUs serão enviados junto.
2762
- if (!du.parentDU) {
2763
- const duChanges = du.getChangesToSave();
2764
- if (duChanges) {
2765
- allChanges = allChanges.concat(duChanges);
2766
- }
2767
- }
2768
- }
2769
- return allChanges;
2770
- }
2771
- async changeFieldValue(dataUnit, fieldName, value) {
2772
- const du = this._dataUnits.get(dataUnit);
2773
- if (du) {
2774
- du.changeValue(fieldName, value);
2775
- }
2776
- }
2777
- validateRecords(dataUnit, records, triggedBy) {
2778
- const result = { isValid: true, message: "" };
2779
- if (this.ignoreSaveValidation && triggedBy === "SAVE") {
2780
- return result;
2781
- }
2782
- const validateField = (field) => {
2783
- if (field.readOnly) {
2784
- return false;
2785
- }
2786
- if (field.userInterface === "SWITCH" || field.userInterface === "CHECKBOX") {
2787
- return false;
2788
- }
2789
- return true;
2790
- };
2791
- const recordValidator = record => {
2792
- dataUnit.requiredFields.forEach(field => {
2793
- if (validateField(field)) {
2794
- const recordIndex = record["record__index"];
2795
- const fieldName = field.name;
2796
- const fieldValue = record[fieldName];
2797
- if (fieldValue === null || fieldValue === undefined || fieldValue === "") {
2798
- const tabPosition = this._tabPositionByField.get(dataUnit.name + field.name);
2799
- this._store.dispatch(invalidField$1(tabPosition.tabName, tabPosition.index, dataUnit.name, recordIndex, record.record__id, field.name, "Essa informação é obrigatória"));
2800
- result.isValid = false;
2801
- result.message = "Há pelo menos um campo obrigatório não preenchido.";
2802
- }
2803
- }
2804
- });
2805
- };
2806
- if (dataUnit.records.length === 0) {
2807
- recordValidator({});
2808
- }
2809
- else {
2810
- let validatedRecords = {};
2811
- records.forEach(r => {
2812
- recordValidator(r);
2813
- validatedRecords[r.record__id] = true;
2814
- });
2815
- dataUnit.records.forEach(r => {
2816
- if (!validatedRecords[r.record__id]) {
2817
- recordValidator(r);
2818
- }
2819
- });
2820
- }
2821
- return result;
2822
- }
2823
- loadMDFromExecutor(callBack) {
2824
- const loadMetadataFunction = this.parseExecutor(this.metadataExecutor);
2825
- if (loadMetadataFunction) {
2826
- const result = loadMetadataFunction();
2827
- if (result) {
2828
- if (result instanceof Promise) {
2829
- result.then(md => {
2830
- callBack(md);
2831
- });
2832
- }
2833
- else {
2834
- callBack(result);
2835
- }
2836
- }
2837
- }
2838
- }
2839
- loadMDFromElement(callBack) {
2840
- const metadata = [];
2841
- Array.from(this._host.children).forEach(elem => {
2842
- if (elem.tagName === "FORM-METADATA") {
2843
- const formMetadata = elem;
2844
- metadata.push(formMetadata.metadata);
2845
- }
2846
- });
2847
- callBack(metadata.length > 0 ? metadata : null);
2848
- }
2849
- updateMetadata(metadata) {
2850
- if (metadata) {
2851
- const processFields = (duName, form, tabController, tabIndex) => {
2852
- var _a;
2853
- form.items.forEach(item => {
2854
- if ("fields" in item) {
2855
- const fSet = item;
2856
- fSet.fields.forEach(f => {
2857
- f.form = this;
2858
- this._tabPositionByField.set(duName + f.name, { tabName: tabController, index: tabIndex });
2859
- });
2860
- }
2861
- else {
2862
- const f = item;
2863
- f.form = this;
2864
- this._tabPositionByField.set(duName + f.name, { tabName: tabController, index: tabIndex });
2865
- }
2866
- });
2867
- (_a = form.subForms) === null || _a === void 0 ? void 0 : _a.forEach((subForm, index) => {
2868
- const subDu = subForm.dataUnit;
2869
- if (subDu) {
2870
- this._duSources.set(subDu.name, subDu);
2871
- subDu.parentDUName = duName;
2872
- }
2873
- processFields(subDu ? subDu.name : duName, subForm, form.name, index);
2874
- });
2875
- };
2876
- this._preparedMetadata = metadata.map((form, index) => {
2877
- const du = form.dataUnit;
2878
- if (form.autoLoad) {
2879
- this._duToLoad.push(du);
2880
- }
2881
- this.decorateDU(du);
2882
- const duName = du.name;
2883
- this._duSources.set(duName, du);
2884
- processFields(duName, form, "__MAIN__FORM__", index);
2885
- return form;
2886
- });
2887
- this._store.dispatch(formLoad());
2888
- }
2889
- }
2890
- parseExecutor(executor) {
2891
- if (executor) {
2892
- return executor instanceof Function ? executor : eval(executor);
2893
- }
2894
- return null;
2895
- }
2896
- componentWillRender() {
2897
- if (this._store === undefined) {
2898
- const rootReducer = combineReducers({
2899
- "hist": undoable(formReducer),
2900
- "nonhist": formNonHistoricReducer
2901
- });
2902
- this._store = createStore(rootReducer, applyMiddleware(thunk));
2903
- this._store.subscribe(() => { forceUpdate(this); });
2904
- if (this.slaveMode) {
2905
- this._store.dispatch(showHideNavigationButtons("saveVisible", false));
2906
- this._store.dispatch(showHideNavigationButtons("cancelVisible", false));
2907
- this._store.dispatch(showHideNavigationButtons("reloadVisible", false));
2908
- }
2909
- }
2910
- if (this._preparedMetadata === undefined) {
2911
- if (this.metadata) {
2912
- this.updateMetadata(this.metadata);
2913
- }
2914
- else {
2915
- this.loadMDFromElement((md) => this.updateMetadata(md));
2916
- if (!this._preparedMetadata) {
2917
- this.loadMDFromExecutor((md) => this.updateMetadata(md));
2918
- }
2919
- }
2920
- }
2921
- }
2922
- componentDidRender() {
2923
- this._duToLoad.forEach(du => du.load());
2924
- this._duToLoad = [];
2925
- }
2926
- loadSearch(argument, context) {
2927
- const fieldSearchExecutor = this.parseExecutor(this.fieldSearchExecutor);
2928
- if (fieldSearchExecutor) {
2929
- return fieldSearchExecutor(argument, context);
2930
- }
2931
- else {
2932
- return [{ value: 0, label: "Sem resultados" }];
2933
- }
2934
- }
2935
- buildDataUnit(dataUnit, parentDataUnit) {
2936
- if (dataUnit) {
2937
- const { name, unitLabel, records, cardinality, fields } = dataUnit;
2938
- if (!(dataUnit instanceof DataUnit)) {
2939
- let parent;
2940
- if (parentDataUnit instanceof DataUnit) {
2941
- parent = parentDataUnit;
2942
- }
2943
- else {
2944
- parent = this._dataUnits.get(parentDataUnit);
2945
- }
2946
- dataUnit = new DataUnit(name, unitLabel, cardinality, parent);
2947
- dataUnit.fields = fields;
2948
- this._dataUnits.set(dataUnit.name, dataUnit);
2949
- if (records) {
2950
- dataUnit.records = records;
2951
- }
2952
- }
2953
- this.decorateDU(dataUnit);
2954
- }
2955
- return dataUnit;
2956
- }
2957
- decorateDU(dataUnit) {
2958
- dataUnit.store = this._store;
2959
- dataUnit.loadExecutor = this.parseExecutor(this.loadExecutor);
2960
- dataUnit.saveExecutor = this.parseExecutor(this.saveExecutor);
2961
- dataUnit.removeExecutor = this.parseExecutor(this.removeExecutor);
2962
- dataUnit.recordsValidator = this;
2963
- }
2964
- render() {
2965
- if (this.loading) {
2966
- return h("place-holder", null);
2967
- }
2968
- else {
2969
- return this._preparedMetadata ? h(FormSheet, { enabled: this.enabled, store: this._store, source: this._preparedMetadata, parentName: "__MAIN__FORM__", dataUnitBuilder: (du, parentDataUnit) => this.buildDataUnit(du, parentDataUnit) }) : null;
2970
- }
2971
- }
2972
- static get assetsDirs() { return ["assets"]; }
2973
- get _host() { return getElement(this); }
2974
- static get watchers() { return {
2975
- "metadata": ["cleanPreparedMetadata"]
2976
- }; }
2977
- };
2978
- EzForm.style = ezFormCss;
2979
-
2980
- const ezIconCss = ":host{display:block;overflow:hidden;position:relative;--ez-icon--color:var(--icon--color, #ffffff)}svg{display:flex;justify-content:center;align-items:center;fill:var(--ez-icon--color)}.x-small{width:12px;height:12px}.small{width:16px;height:16px}.medium{width:20px;height:20px}.large{width:24px;height:24px}.x-large{width:30px;height:30px}";
2981
-
2982
- let EzIcon = class {
2983
- constructor(hostRef) {
2984
- registerInstance(this, hostRef);
2985
- /**
2986
- * Tamanho do ícone
2987
- */
2988
- this.size = 'medium';
2989
- }
2990
- isSprite() {
2991
- return this.href && this.href.indexOf('#') > -1;
2992
- }
2993
- render() {
2994
- return (h(Host, null, this.isSprite()
2995
- ?
2996
- h("svg", { class: this.size, role: "img" }, h("use", { xlinkHref: this.href }))
2997
- :
2998
- h("img", { class: this.size, src: this.href })));
2999
- }
3000
- };
3001
- EzIcon.style = ezIconCss;
3002
-
3003
- const ezNumericInputCss = ":host{display:block;width:100%;--ez-text-input__input--background-color:var(--background--medium, #e0e0e0);--ez-text-input__input--border-color:var(--ez-text-input__input--background-color)}.text-input{--ez-text-input__input--background-color:inherit;--ez-text-input__input--border-color:inherit}";
3004
-
3005
- let EzNumericInput = class {
3006
- constructor(hostRef) {
3007
- registerInstance(this, hostRef);
3008
- this.ezChange = createEvent(this, "ezChange", 7);
3009
- /**
3010
- * Deixa o campo disponível ou não para uso.
3011
- */
3012
- this.enabled = true;
3013
- }
3014
- setLabel() {
3015
- this._textInput.label = this.label;
3016
- }
3017
- setErrorMessage() {
3018
- this._textInput.errorMessage = this.errorMessage;
3019
- }
3020
- applyValueToInput() {
3021
- if (this._textInput) {
3022
- this._textInput.value = this.getTextValue(this.value);
3023
- }
3024
- }
3025
- changeValue(newValue) {
3026
- this._textInput.errorMessage = "";
3027
- if (newValue !== this.value) {
3028
- this.value = newValue;
3029
- this.ezChange.emit();
3030
- }
3031
- }
3032
- parseNumber() {
3033
- const parsedNumber = this._textInput.value ? NumberUtils.stringToNumber(this._textInput.value) : null;
3034
- if (parsedNumber != null && isNaN(parsedNumber)) {
3035
- this._textInput.errorMessage = "O valor digitado não é um número válido";
3036
- }
3037
- else {
3038
- this.changeValue(parsedNumber);
3039
- }
3040
- }
3041
- getTextValue(value) {
3042
- if (value) {
3043
- return this.precision > 0 ? NumberUtils.format(value.toString(), Number(this.precision), Number(this.prettyprecision)) : value.toString();
3044
- }
3045
- return null;
3046
- }
3047
- render() {
3048
- return (h("ez-text-input", { class: "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 }));
3049
- }
3050
- static get watchers() { return {
3051
- "label": ["setLabel"],
3052
- "errorMessage": ["setErrorMessage"],
3053
- "value": ["applyValueToInput"]
3054
- }; }
3055
- };
3056
- EzNumericInput.style = ezNumericInputCss;
3057
-
3058
- const ezSearchCss = ":host{width:100%}";
3059
-
3060
- let EzSearch = class {
3061
- constructor(hostRef) {
3062
- registerInstance(this, hostRef);
3063
- this.ezChange = createEvent(this, "ezChange", 7);
3064
- this.showPopup = createEvent(this, "showPopup", 7);
3065
- /**
3066
- * Deixa o campo disponível ou não.
3067
- */
3068
- this.enabled = true;
3069
- /**
3070
- * Ajusta a opção de mostrar o "value" ao selecionar uma opção.
3071
- */
3072
- this.showSelectedValue = true;
3073
- /**
3074
- * Ajusta a opção de mostrar o "value" para cada opção.
3075
- */
3076
- this.showOptionValue = true;
3077
- }
3078
- updateValue() {
3079
- if (this._comboElement) {
3080
- this._comboElement.value = this.value;
3081
- }
3082
- }
3083
- onComboChange(evt) {
3084
- evt.stopPropagation();
3085
- this.value = evt.detail;
3086
- this.ezChange.emit(evt.detail);
3087
- }
3088
- render() {
3089
- return (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 }));
3090
- }
3091
- ;
3092
- static get watchers() { return {
3093
- "value": ["updateValue"]
3094
- }; }
3095
- };
3096
- EzSearch.style = ezSearchCss;
3097
-
3098
- const ezTabselectorCss = "@keyframes activate{0%{clip-path:inset(calc(100% - 3px) 50% 0px 50%)}100%{clip-path:inset(calc(100% - 3px) 0px 0px 0px)}}:host{display:flex;position:relative;width:100%;overflow:hidden;margin-bottom:var(--space--large, 24px);--tabselector--backward-icon:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"16px\" width=\"10px\"><path d=\"M 9.7808475,13.860393 3.9204526,8.0000004 9.7808475,2.0624965 7.9301965,0.28895552 0.21915255,8.0000004 7.9301965,15.711044 Z\"/></svg>');--tabselector--forward-icon: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>')}.scroll{display:flex;width:100%;scroll-behavior:smooth;overflow-x:auto;scrollbar-width:none}.scroll.startHidden{-webkit-mask-image:linear-gradient(90deg, transparent 20px, #000 48px)}.scroll.midle{-webkit-mask-image:linear-gradient(90deg, transparent 20px, #000 48px, #000 calc(100% - 48px), transparent calc(100% - 20px))}.scroll.endHidden{-webkit-mask-image:linear-gradient(90deg, #000 calc(100% - 48px), transparent calc(100% - 20px))}.tab{display:flex;border:none;min-width:100px;background-color:unset;cursor:pointer;padding:6px 12px;align-items:center;justify-content:center;color:var(--text--primary, #626e82);font-family:var(--font-pattern, \"Sora, Algerian\");font-size:var(--title--small, 14px)}.tab:focus,.forward-button,.backward-button{outline:none}.is-active{position:relative;color:var(--color--primary, #008561)}.is-active::after{content:\"\";position:absolute;width:100%;height:100%;background-color:var(--color--primary, #008561);clip-path:inset(calc(100% - 3px) 0px 0px 0px);animation:activate 0.25s ease-in-out}.is-focused{border:1px dashed var(--color--primary, #000000c5)}.tab-label{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;text-shadow:var(--text-shadow);margin-bottom:var(--space--extra-small, 3px)}.forward-button,.backward-button{position:absolute;z-index:1;display:flex;box-sizing:border-box;padding:0px;top:0px;right:0px;width:16px;height:100%;border:none;background-color:unset;cursor:pointer;justify-content:center;align-items:center}.backward-button{left:0px}.forward-button::after,.backward-button::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:10px;height:16px}.forward-button::after{-webkit-mask-image:var(--tabselector--forward-icon);mask-image:var(--tabselector--forward-icon)}.backward-button::after{-webkit-mask-image:var(--tabselector--backward-icon);mask-image:var(--tabselector--backward-icon)}.forward-button:hover::after,.backward-button:hover::after{background-color:var(--color--primary, #4e4e4e)}.hidden{display:none}.scroll::-webkit-scrollbar{display:none}";
3099
-
3100
- let EzTabselector = class {
3101
- constructor(hostRef) {
3102
- registerInstance(this, hostRef);
3103
- this.ezChange = createEvent(this, "ezChange", 7);
3104
- this.setFocusedParam = (ev) => {
3105
- if (ev.key === "Enter") {
3106
- this.selectedIndex = this.focusedIndex;
3107
- this.focusedIndex = undefined;
3108
- this.selectedTab = this._processedTabs[this.selectedIndex]["tabKey"];
3109
- this.handleTabClick(this.selectedTab, parseInt(this.selectedIndex));
3110
- ev.preventDefault();
3111
- this.setFocusedTab(this.selectedIndex);
3112
- }
3113
- else if (ev.key === "ArrowLeft" || ev.key === "ArrowRight") {
3114
- let operator = undefined;
3115
- if (ev.key === "ArrowLeft") {
3116
- operator = false;
3117
- }
3118
- else if (ev.key === "ArrowRight") {
3119
- operator = true;
3120
- }
3121
- else {
3122
- return;
3123
- }
3124
- if (this.focusedIndex === undefined) {
3125
- if (operator === false) {
3126
- this.focusedIndex = this.selectedIndex !== undefined ? (parseInt(this.selectedIndex) - 1).toString() : undefined;
3127
- }
3128
- else {
3129
- this.focusedIndex = this.selectedIndex !== undefined ? (parseInt(this.selectedIndex) + 1).toString() : undefined;
3130
- }
3131
- }
3132
- else {
3133
- if (operator === false) {
3134
- this.focusedIndex = (parseInt(this.focusedIndex) - 1).toString();
3135
- }
3136
- else {
3137
- this.focusedIndex = (parseInt(this.focusedIndex) + 1).toString();
3138
- }
3139
- }
3140
- if (parseInt(this.focusedIndex) < 0) {
3141
- this.focusedIndex = "0";
3142
- }
3143
- else if (parseInt(this.focusedIndex) > this._processedTabs.length - 1) {
3144
- this.focusedIndex = (this._processedTabs.length - 1).toString();
3145
- }
3146
- this.setFocusedBtn(true, this.focusedIndex);
3147
- this.setFocusedTab(this.focusedIndex);
3148
- this.ezChange.emit();
3149
- }
3150
- else if (ev.key === "Tab" || ev.key === "Escape") {
3151
- this.focusedIndex = undefined;
3152
- this.selectedTab = this._processedTabs[this.selectedIndex]["tabKey"];
3153
- this.handleTabClick(this.selectedTab, parseInt(this.selectedIndex));
3154
- ev.preventDefault();
3155
- this.setFocusedTab(this.selectedIndex);
3156
- }
3157
- // this.setFocusedTab();
3158
- };
3159
- }
3160
- handleTabClick(tab, index) {
3161
- this.selectedIndex = index.toString();
3162
- this.focusedIndex = undefined;
3163
- this.selectedTab = tab;
3164
- this.ezChange.emit();
3165
- this.setFocusedBtn(false, this.selectedIndex);
3166
- }
3167
- componentWillRender() {
3168
- if (!this._processedTabs) {
3169
- this._processedTabs = [];
3170
- if (this.tabs) {
3171
- this.tabs.split(",").forEach((label) => {
3172
- label = label.trim();
3173
- this._processedTabs.push(new Tab(label, label));
3174
- });
3175
- }
3176
- this._hostElem.querySelectorAll("ez-tab").forEach((elem) => {
3177
- const tabKey = elem.getAttribute("tabKey");
3178
- const label = elem.getAttribute("label");
3179
- const t = new Tab(label, tabKey);
3180
- const content = elem.firstChild;
3181
- if (content) {
3182
- content.setAttribute("slot", "tab" + this._processedTabs.length);
3183
- this._hostElem.appendChild(content);
3184
- }
3185
- this._processedTabs.push(t);
3186
- });
3187
- }
3188
- }
3189
- handleSlotChange(ev) {
3190
- const slot = ev.target;
3191
- const content = slot.assignedElements()[0];
3192
- if (content) {
3193
- content.style.marginLeft = "6px";
3194
- }
3195
- }
3196
- scrollBackward() {
3197
- const container = this._scrollContainer;
3198
- if (container) {
3199
- container.scrollLeft -= container.clientWidth;
3200
- }
3201
- }
3202
- scrollFoward() {
3203
- const container = this._scrollContainer;
3204
- if (container) {
3205
- let lastTab = null;
3206
- container.querySelectorAll(".tab").forEach((tab) => {
3207
- if (tab.getBoundingClientRect().right < container.clientWidth) {
3208
- lastTab = tab;
3209
- }
3210
- });
3211
- container.scrollLeft = lastTab.offsetLeft + lastTab.offsetWidth;
3212
- }
3213
- }
3214
- componentDidRender() {
3215
- this.updateScroll();
3216
- }
3217
- updateScroll() {
3218
- const container = this._scrollContainer;
3219
- if (container) {
3220
- const { scrollWidth, clientWidth, scrollLeft } = container;
3221
- const remainingScroll = scrollWidth - clientWidth - Math.ceil(scrollLeft);
3222
- this._startHidden = container.scrollLeft > 0;
3223
- this._endHidden = remainingScroll > 0;
3224
- if (this._startHidden) {
3225
- this._backwardButton.classList.remove("hidden");
3226
- }
3227
- else {
3228
- this._backwardButton.classList.add("hidden");
3229
- }
3230
- if (this._endHidden) {
3231
- this._forwardButton.classList.remove("hidden");
3232
- }
3233
- else {
3234
- this._forwardButton.classList.add("hidden");
3235
- }
3236
- const classNames = ["", "startHidden", "endHidden", "midle"];
3237
- const currentClass = classNames[Number(this._startHidden) | Number(this._endHidden) << 1];
3238
- classNames.forEach((name) => {
3239
- if (name !== currentClass && container.classList.contains(name)) {
3240
- container.classList.remove(name);
3241
- }
3242
- });
3243
- if (currentClass && !container.classList.contains(currentClass)) {
3244
- container.classList.add(currentClass);
3245
- }
3246
- }
3247
- }
3248
- domScrollHandler() {
3249
- window.clearTimeout(this._scrollCallBack);
3250
- this._scrollCallBack = window.setTimeout(() => { this.updateScroll(); }, 200);
3251
- }
3252
- setFocusedTab(index) {
3253
- window.clearTimeout(this._scrollCallBackTest);
3254
- this._scrollCallBackTest = window.setTimeout(() => {
3255
- const tabtoscroll = this._scrollContainer.querySelector(`#tab${index}`);
3256
- tabtoscroll.scrollIntoView();
3257
- }, 200);
3258
- }
3259
- getTextWidth(text) {
3260
- if (this._textMesurement === undefined) {
3261
- this._textMesurement = this._hostElem.shadowRoot.ownerDocument.createElement("canvas");
3262
- }
3263
- const context = this._textMesurement.getContext("2d");
3264
- context.font = "14px Sora, Algerian";
3265
- return Math.min(220, 24 + context.measureText(text).width) + "px";
3266
- }
3267
- ;
3268
- setFocusedBtn(visible, parameter) {
3269
- const tabsButtons = this._scrollContainer.querySelectorAll(".tab");
3270
- tabsButtons.forEach((el) => {
3271
- el.classList.remove("is-focused");
3272
- if (el.id === "tab" + parameter && visible) {
3273
- el.classList.add("is-focused");
3274
- }
3275
- });
3276
- }
3277
- render() {
3278
- return (h(Host, null, h("button", { class: "backward-button", ref: (el) => this._backwardButton = el, onClick: () => this.scrollBackward() }), h("div", { class: "scroll", ref: (el) => this._scrollContainer = el, onScroll: () => this.domScrollHandler(), onKeyDown: (ev) => this.setFocusedParam(ev) }, this._processedTabs.map((tab, index) => {
3279
- const labelStyle = { "min-width": this.getTextWidth(tab.label) };
3280
- const tabId = "tab" + index;
3281
- const isSelected = index === parseInt(this.selectedIndex) || (this.selectedTab && tab.tabKey === this.selectedTab);
3282
- if (isSelected) {
3283
- this.selectedTab = tab.tabKey;
3284
- this.selectedIndex = index.toString();
3285
- }
3286
- return h("button", { id: tabId, class: `tab${isSelected ? " is-active" : ""}`, onClick: () => this.handleTabClick(tab.tabKey, index), style: labelStyle }, h("span", { class: "tab-label", title: tab.label }, tab.label), h("slot", { name: tabId, onSlotchange: (ev) => { this.handleSlotChange(ev); } }));
3287
- })), h("button", { class: "forward-button", ref: (el) => this._forwardButton = el, onClick: () => this.scrollFoward() })));
3288
- }
3289
- get _hostElem() { return getElement(this); }
3290
- };
3291
- class Tab {
3292
- constructor(label, tabKey) {
3293
- this.label = label;
3294
- this.tabKey = tabKey;
3295
- }
3296
- }
3297
- EzTabselector.style = ezTabselectorCss;
3298
-
3299
- 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)}";
3300
-
3301
- let EzTextArea = class {
3302
- constructor(hostRef) {
3303
- registerInstance(this, hostRef);
3304
- this.ezChange = createEvent(this, "ezChange", 7);
3305
- /**
3306
- * Deixa o campo disponível ou não para digitação.
3307
- */
3308
- this.enabled = true;
3309
- /**
3310
- * Ajusta o número de linhas e consequentemente o height do textarea. Valor default: 4
3311
- */
3312
- this.rows = 4;
3313
- }
3314
- showError() {
3315
- const hasError = typeof this.errorMessage === 'string' && this.errorMessage !== '';
3316
- if (hasError) {
3317
- this._container.classList.add('hasError');
3318
- this._messageBoxElem.classList.add('hasError');
3319
- }
3320
- else {
3321
- this._container.classList.remove('hasError');
3322
- this._messageBoxElem.classList.remove('hasError');
3323
- }
3324
- }
3325
- updateInputValue() {
3326
- this._inputElem.value = this.value;
3327
- this.handleChange();
3328
- this.adjustFloatingLabel();
3329
- this.ezChange.emit(this.value);
3330
- }
3331
- adjustFloatingLabel() {
3332
- if (this.label) {
3333
- const hasValue = this.value && this.value.toString().length > 0;
3334
- const containsFloatedClass = this._labelElem.classList.contains("textarea__label--floated");
3335
- if (hasValue || this.isFocused()) {
3336
- if (!containsFloatedClass) {
3337
- this._labelElem.classList.add("textarea__label--floated");
3338
- }
3339
- }
3340
- else {
3341
- if (containsFloatedClass) {
3342
- this._labelElem.classList.remove("textarea__label--floated");
3343
- }
3344
- }
3345
- }
3346
- }
3347
- isFocused() {
3348
- return this._hostElement.shadowRoot.activeElement !== null;
3349
- }
3350
- //---------------------------------------------
3351
- // Public methods
3352
- //---------------------------------------------
3353
- /**
3354
- * Faz o foco no componente de input
3355
- */
3356
- async setFocus() {
3357
- this._inputElem.focus();
3358
- }
3359
- /**
3360
- * Remove o foco no componente de input
3361
- */
3362
- async setBlur() {
3363
- this._inputElem.blur();
3364
- }
3365
- //---------------------------------------------
3366
- // Event handlers
3367
- //---------------------------------------------
3368
- handleFocusout() {
3369
- this.adjustFloatingLabel();
3370
- if (this._container && this._container.classList.contains("textarea--focus")) {
3371
- this._container.classList.remove("textarea--focus");
3372
- }
3373
- }
3374
- handleChange() {
3375
- this.value = this._inputElem.value;
3376
- }
3377
- handleFocus() {
3378
- if (this.label && this._labelElem && !this._labelElem.classList.contains("textarea__label--floated")) {
3379
- this._labelElem.classList.add("textarea__label--floated");
3380
- }
3381
- if (this._container && !this._container.classList.contains("textarea--focus")) {
3382
- this._container.classList.add("textarea--focus");
3383
- }
3384
- }
3385
- //---------------------------------------------
3386
- // Lifecycle web component
3387
- //---------------------------------------------
3388
- componentDidLoad() {
3389
- this.showError();
3390
- this.adjustFloatingLabel();
3391
- }
3392
- render() {
3393
- return (h(Host, null, h("div", { class: "textarea", ref: (el) => this._container = el }, this.label ?
3394
- 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)
3395
- : null, 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 })), h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errorMessage }, this.errorMessage)));
3396
- }
3397
- get _hostElement() { return getElement(this); }
3398
- static get watchers() { return {
3399
- "errorMessage": ["showError"],
3400
- "value": ["updateInputValue"]
3401
- }; }
3402
- };
3403
- EzTextArea.style = ezTextAreaCss;
3404
-
3405
- const ezTextInputCss = ":host{--ez-text-input--height:42px;--ez-text-input--width:100%;--ez-text-input__icon--width:48px;--ez-text-input--border-radius:var(--border--radius-medium, 12px);--ez-text-input--font-size:var(--text--medium, 14px);--ez-text-input--font-family:var(--font-pattern, Arial);--ez-text-input--font-weight:var(--text-weight--large, 500);--ez-text-input--color:var(--title--primary, #000);--ez-text-input__input--background-color:var(--background--medium, #e0e0e0);--ez-text-input__input--border:var(--border--medium, 2px solid);--ez-text-input__input--border-color:var(--ez-text-input__input--background-color);--ez-text-input__input--focus--border-color:var(--color--alert-cold-800, #042EFF);--ez-text-input__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-text-input__input--disabled--color:var(--text--disable, #AFB6C0);--ez-text-input__input--error--border-color:#CC2936;--ez-text-input__message_box--font-size:var(--text--small, 12px);--ez-text-input__message_box--info--color:var(--color--success, #22085d);--ez-text-input__message_box--error--color:var(--color--error, #FF0000);--ez-text-input__label--floating--top:6px;--ez-text-input__label--padding-top:12px;--ez-text-input__label--padding-left:14px;--ez-text-input__label--padding-right:12px;display:flex;flex-wrap:wrap;position:relative;width:var(--ez-text-input--width)}input{width:100%;box-sizing:border-box;padding:var(--space--medium, 6px);font-weight:var(--text-weight--large, 600);height:var(--ez-text-input--height);border-radius:var(--ez-text-input--border-radius);font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);border:var(--ez-text-input__input--border);border-color:var(--ez-text-input__input--border-color);background-color:var(--ez-text-input__input--background-color);color:var(--ez-text-input--color)}input:disabled{background-color:var(--ez-text-input__input--disabled--background-color);color:var(--ez-text-input__input--disabled--color)}input:focus{outline:none;border-color:var(--ez-text-input__input--focus--border-color)}input.icon--left{padding-left:var(--ez-text-input__icon--width)}input.icon--right{padding-right:var(--ez-text-input__icon--width)}input.hasError{color:var(--ez-text-input--color);border-color:var(--ez-text-input__input--error--border-color)}input.text--right{text-align:right}.message-box{display:flex;min-height:16px;min-width:100%;margin-top:2px;line-height:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input__message_box--font-size);color:var(--ez-text-input__message_box--info--color)}.hasError{color:var(--ez-text-input__message_box--error--color)}.input__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(--ez-text-input__label--padding-right));left:var(--ez-text-input--space--medium);font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color);top:var(--ez-text-input__label--padding-top);left:var(--ez-text-input__label--padding-left);padding-right:var(--ez-text-input__label--padding-right)}.input__label--floated{font-family:var(--ez-text-input--font-family);font-size:var(--text--extra-small);color:var(--text--primary);top:var(--ez-text-input__label--floating--top)}.input__label--disabled{color:var(--ez-text-input__input--disabled--color)}.input__label--left{text-align:left;left:calc(var(--ez-text-input__icon--width) + 2px);width:calc(100% - var(--ez-text-input__icon--width))}.input__label--right{right:var(--ez-text-input__icon--width);width:calc(100% - var(--ez-text-input__icon--width))}.input__label--left.input__label--right{left:calc(var(--ez-text-input__icon--width) + 2px);width:calc(100% - var(--ez-text-input__icon--width) * 2)}.input--with--label{padding-bottom:0}";
3406
-
3407
- let EzTextInput = class {
3408
- constructor(hostRef) {
3409
- registerInstance(this, hostRef);
3410
- this.ezChange = createEvent(this, "ezChange", 7);
3411
- /**
3412
- * Deixa o campo disponível ou não para digitação.
3413
- */
3414
- this.enabled = true;
3415
- }
3416
- showError() {
3417
- const hasError = typeof this.errorMessage === "string" && this.errorMessage !== "";
3418
- if (hasError) {
3419
- this._inputElem.classList.add("hasError");
3420
- this._messageBoxElem.classList.add("hasError");
3421
- }
3422
- else {
3423
- this._inputElem.classList.remove("hasError");
3424
- this._messageBoxElem.classList.remove("hasError");
3425
- }
3426
- }
3427
- prepareMask() {
3428
- if (this.mask) {
3429
- if (this._maskFormatter == undefined) {
3430
- this._maskFormatter = new MaskFormatter(this.mask);
3431
- }
3432
- else {
3433
- this._maskFormatter.mask = this.mask;
3434
- }
3435
- }
3436
- }
3437
- updateInputValue() {
3438
- if (this._inputElem) {
3439
- this._inputElem.value = this.value;
3440
- }
3441
- this.handleChange();
3442
- this.ezChange.emit(this.value);
3443
- this.adjustFloatingLabel();
3444
- }
3445
- adjustFloatingLabel() {
3446
- if (this.label && this._labelElem) {
3447
- if (this._inputElem && !this._inputElem.classList.contains("input--with--label")) {
3448
- this._inputElem.classList.add("input--with--label");
3449
- }
3450
- const hasValue = this.value && this.value.toString().length > 0;
3451
- const containsFloatedClass = this._labelElem.classList.contains("input__label--floated");
3452
- if (hasValue || this.isFocused()) {
3453
- if (!containsFloatedClass) {
3454
- this._labelElem.classList.add("input__label--floated");
3455
- }
3456
- }
3457
- else {
3458
- if (containsFloatedClass) {
3459
- this._labelElem.classList.remove("input__label--floated");
3460
- }
3461
- }
3462
- }
3463
- }
3464
- isFocused() {
3465
- return this._hostElement.shadowRoot.activeElement !== null;
3466
- }
3467
- //---------------------------------------------
3468
- // Public methods
3469
- //---------------------------------------------
3470
- /**
3471
- * Faz o foco no componente de input
3472
- */
3473
- async setFocus() {
3474
- this._inputElem.focus();
3475
- }
3476
- /**
3477
- * Remove o foco no componente de input
3478
- */
3479
- async setBlur() {
3480
- this._inputElem.blur();
3481
- }
3482
- //---------------------------------------------
3483
- // Event handlers
3484
- //---------------------------------------------
3485
- handleFocusout() {
3486
- const value = this._inputElem.value;
3487
- if (value && this._maskFormatter) {
3488
- try {
3489
- this._inputElem.value = this._maskFormatter.format(value);
3490
- }
3491
- catch (e) {
3492
- this.errorMessage = e.message;
3493
- }
3494
- }
3495
- this.value = this._inputElem.value;
3496
- this.adjustFloatingLabel();
3497
- }
3498
- isValidValue(value) {
3499
- if (this.restrict) {
3500
- return Array.from(value).reduce((valid, c) => valid && this.restrict.indexOf(c) > -1, true);
3501
- }
3502
- return true;
3503
- }
3504
- handleChange() {
3505
- if (!this._inputElem) {
3506
- return;
3507
- }
3508
- const value = this._inputElem.value;
3509
- if (this.isValidValue(value)) {
3510
- this._lastValidValue = value;
3511
- }
3512
- else {
3513
- this._inputElem.value = this._lastValidValue === undefined ? "" : this._lastValidValue;
3514
- }
3515
- this.value = this._inputElem.value;
3516
- }
3517
- handleSlotChange(ev) {
3518
- const slot = ev.target;
3519
- const content = slot.assignedElements()[0];
3520
- if (content) {
3521
- content.style.position = "absolute";
3522
- content.style.display = "flex";
3523
- content.style.alignItems = "center";
3524
- content.style.justifyContent = "center";
3525
- content.style.overflow = "hidden";
3526
- content.style.top = "0px";
3527
- content.style.width = "var(--ez-text-input__icon--width)";
3528
- content.style.height = "var(--ez-text-input--height)";
3529
- if (slot.name == "leftIcon") {
3530
- content.style.left = "0px";
3531
- content.style.borderRadius = "var(--ez-text-input--border-radius) 0 0 var(--ez-text-input--border-radius)";
3532
- this._inputElem.classList.add("icon--left");
3533
- if (this._labelElem) {
3534
- this._labelElem.classList.add("input__label--left");
3535
- }
3536
- }
3537
- else if (slot.name == "rightIcon") {
3538
- content.style.right = "0px";
3539
- content.style.borderRadius = "0 var(--ez-text-input--border-radius) var(--ez-text-input--border-radius) 0";
3540
- this._inputElem.classList.add("icon--right");
3541
- if (this._labelElem) {
3542
- this._labelElem.classList.add("input__label--right");
3543
- }
3544
- }
3545
- }
3546
- this.showError();
3547
- }
3548
- doFocus() {
3549
- if (this.label && this._labelElem && !this._labelElem.classList.contains("input__label--floated")) {
3550
- this._labelElem.classList.add("input__label--floated");
3551
- }
3552
- }
3553
- //---------------------------------------------
3554
- // Lifecycle web component
3555
- //---------------------------------------------
3556
- componentDidLoad() {
3557
- this.showError();
3558
- this.prepareMask();
3559
- this.adjustFloatingLabel();
3560
- }
3561
- componentWillLoad() {
3562
- this.prepareMask();
3563
- if (this.value) {
3564
- if (this._maskFormatter) {
3565
- try {
3566
- this.value = this._maskFormatter.format(this.value);
3567
- }
3568
- catch (e) {
3569
- this.errorMessage = e.message;
3570
- }
3571
- }
3572
- if (!this.isValidValue(this.value)) {
3573
- this._lastValidValue = "";
3574
- this.value = "";
3575
- }
3576
- }
3577
- }
3578
- render() {
3579
- return (h(Host, null, h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label ?
3580
- h("label", { ref: (el) => this._labelElem = el, class: this.enabled ? "input__label" : "input__label input__label--disabled", onClick: () => this._inputElem.focus(), title: this.label }, this.label)
3581
- : null, h("input", { onFocus: () => this.doFocus(), ref: (el) => this._inputElem = el, type: "text", value: this.value, disabled: !this.enabled, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); } }), h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errorMessage }, this.errorMessage)));
3582
- }
3583
- get _hostElement() { return getElement(this); }
3584
- static get watchers() { return {
3585
- "errorMessage": ["showError"],
3586
- "mask": ["prepareMask"],
3587
- "value": ["updateInputValue"]
3588
- }; }
3589
- };
3590
- EzTextInput.style = ezTextInputCss;
3591
-
3592
- class RemoteFile {
3593
- constructor(file) {
3594
- this.file = file;
3595
- this.size = file.size;
3596
- this.name = file.name;
3597
- }
3598
- abortUpload() {
3599
- if (this._uploadingXhr) {
3600
- this._aborted = true;
3601
- this._uploadingXhr.abort();
3602
- this._uploadingXhr = undefined;
3603
- }
3604
- }
3605
- isUploading() {
3606
- return this._uploadingXhr !== undefined;
3607
- }
3608
- async upload(server, headers, updateCallBack) {
3609
- return new Promise((resolve, reject) => {
3610
- const xhr = new XMLHttpRequest();
3611
- this._uploadingXhr = xhr;
3612
- this._aborted = false;
3613
- this.progress = 0;
3614
- xhr.upload.onprogress = (e) => {
3615
- const loaded = e.loaded;
3616
- const total = e.total;
3617
- this.progress = ~~((loaded / total) * 100);
3618
- updateCallBack(this, loaded, total);
3619
- };
3620
- xhr.onreadystatechange = () => {
3621
- if (xhr.readyState == 4) {
3622
- this._uploadingXhr = undefined;
3623
- const status = xhr.status;
3624
- if (!this._aborted) {
3625
- if (status === 0) {
3626
- reject("Servidor indisponível");
3627
- }
3628
- else if (status >= 500) {
3629
- reject("Erro inesperado no servidor");
3630
- }
3631
- else if (status >= 400) {
3632
- reject("Operação não permitida");
3633
- }
3634
- }
3635
- const response = xhr.response;
3636
- if (response) {
3637
- resolve(JSON.parse(response));
3638
- }
3639
- }
3640
- };
3641
- xhr.ontimeout = () => {
3642
- reject("Tempo limite de transferência atingido.");
3643
- };
3644
- const formData = new FormData();
3645
- formData.append("ARQUIVO", this.file, this.file.name);
3646
- xhr.open("POST", server, true);
3647
- if (headers) {
3648
- headers.forEach((value, key) => xhr.setRequestHeader(key, value));
3649
- }
3650
- xhr.send(formData);
3651
- });
3652
- }
3653
- async delete(item, server, headers) {
3654
- return new Promise((resolve, reject) => {
3655
- const xhr = new XMLHttpRequest();
3656
- xhr.onreadystatechange = () => {
3657
- if (xhr.readyState == 4) {
3658
- if (xhr.status === 0) {
3659
- reject("Servidor indisponível");
3660
- }
3661
- else if (xhr.status >= 500) {
3662
- reject("Erro inesperado no servidor");
3663
- }
3664
- else if (xhr.status >= 400) {
3665
- reject("Operação não permitida");
3666
- }
3667
- resolve(true);
3668
- }
3669
- };
3670
- xhr.ontimeout = () => {
3671
- reject("Tempo limite de remoção atingido.");
3672
- };
3673
- xhr.open("DELETE", server, true);
3674
- if (headers) {
3675
- headers.forEach((value, key) => xhr.setRequestHeader(key, value));
3676
- }
3677
- xhr.send(JSON.stringify(item));
3678
- });
3679
- }
3680
- }
3681
-
3682
- 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%}}";
3683
-
3684
- let EzUpload = class {
3685
- constructor(hostRef) {
3686
- registerInstance(this, hostRef);
3687
- this.ezChange = createEvent(this, "ezChange", 7);
3688
- this._filePointers = new Map();
3689
- /**
3690
- * Deixa o campo disponível ou não para digitação.
3691
- */
3692
- this.enabled = true;
3693
- }
3694
- changeValue(newValue) {
3695
- if (newValue !== this._updatingValue) {
3696
- this._filePointers.forEach(f => {
3697
- if (this.isRemoteFile(f)) {
3698
- f.abortUpload();
3699
- }
3700
- });
3701
- this._filePointers = new Map();
3702
- this.updateFilePointers();
3703
- }
3704
- this._updatingValue = undefined;
3705
- }
3706
- updateFilePointers() {
3707
- if (this.value) {
3708
- this.value.forEach(ezFile => this._filePointers.set(ezFile.name, ezFile));
3709
- }
3710
- }
3711
- normalizeRequestHeaders() {
3712
- this._requestHeaders = new Map();
3713
- if (typeof this.requestHeaders == "string") {
3714
- try {
3715
- this.requestHeaders = JSON.parse(this.requestHeaders);
3716
- }
3717
- catch (e) {
3718
- this.requestHeaders = undefined;
3719
- }
3720
- }
3721
- for (var key in this.requestHeaders) {
3722
- this._requestHeaders.set(key, this.requestHeaders[key]);
3723
- }
3724
- }
3725
- /**
3726
- * Método responsável por adicionar um ou mais arquivos ao componente.
3727
- */
3728
- async addFiles(files) {
3729
- if (this.maxFiles > 0) {
3730
- let countDistinctFiles = this._filePointers.size;
3731
- files.forEach(file => {
3732
- if (!this._filePointers.has(file.name)) {
3733
- countDistinctFiles++;
3734
- }
3735
- });
3736
- if (countDistinctFiles > this.maxFiles) {
3737
- this.showError(`A quantidade máxima de arquivos é ${this.maxFiles}.`);
3738
- return;
3739
- }
3740
- }
3741
- Array.prototype.forEach.call(files, this.addFile.bind(this));
3742
- }
3743
- async addFile(file) {
3744
- const oldFile = this._filePointers.get(file.name);
3745
- if (oldFile) {
3746
- Application.confirm("Substituir arquivo", `Já existe um arquivo chamado "${file.name}". Deseja substituí-lo?`)
3747
- .then(ok => {
3748
- if (ok) {
3749
- if (this.isRemoteFile(oldFile)) {
3750
- oldFile.abortUpload();
3751
- }
3752
- this.doAddFile(file);
3753
- }
3754
- });
3755
- }
3756
- else {
3757
- this.doAddFile(file);
3758
- }
3759
- }
3760
- async doAddFile(file) {
3761
- if (this.validateFile(file)) {
3762
- const uploadingFile = new RemoteFile(file);
3763
- this._filePointers.set(file.name, uploadingFile);
3764
- uploadingFile.upload(this.urlUpload, this._requestHeaders, (file) => this.updateFeedback(file))
3765
- .then((files) => files.forEach(ezFile => this.finishUpload(ezFile)))
3766
- .catch(msg => this.showError(msg));
3767
- forceUpdate(this);
3768
- }
3769
- }
3770
- finishUpload(ezFile) {
3771
- this._filePointers.set(ezFile.name, ezFile);
3772
- this.updateValue();
3773
- }
3774
- updateValue() {
3775
- this._updatingValue = [];
3776
- this._filePointers.forEach(f => {
3777
- if (!this.isRemoteFile(f)) {
3778
- this._updatingValue.push(f);
3779
- }
3780
- });
3781
- this.value = this._updatingValue;
3782
- this.ezChange.emit(this.value);
3783
- }
3784
- buildProgressId(uploading) {
3785
- let sanitizedName = uploading.name.replace(/[^a-z0-9_]/gi, "_");
3786
- return `PROGRESS_${sanitizedName}_${uploading.file.lastModified}`;
3787
- }
3788
- updateFeedback(uf) {
3789
- window.requestAnimationFrame(() => {
3790
- if (this._host) {
3791
- const progress = this._host.shadowRoot.querySelector("#" + this.buildProgressId(uf));
3792
- if (progress) {
3793
- progress.value = uf.progress;
3794
- }
3795
- }
3796
- });
3797
- }
3798
- validateFile(file) {
3799
- if (!this._filePointers.has(file.name) && this.maxFiles > 0 && this._filePointers.size >= this.maxFiles) {
3800
- this.showError(`A quantidade máxima de arquivos é ${this.maxFiles}.`);
3801
- return false;
3802
- }
3803
- if (file.size === 0) {
3804
- this.showError(`Erro de permissão: O arquivo "${file.name}" não pode ser enviado.`);
3805
- return false;
3806
- }
3807
- if (!this.urlUpload) {
3808
- this.showError("Endereço de upload não informado");
3809
- return false;
3810
- }
3811
- if (this.maxFileSize >= 0 && file.size > this.maxFileSize) {
3812
- this.showError("O tamanho máximo dos arquivos é de " + this.formatBytes(this.maxFileSize));
3813
- return false;
3814
- }
3815
- return true;
3816
- }
3817
- showError(message) {
3818
- Application.alert("Enviando arquivo", message);
3819
- }
3820
- formatBytes(bytes, decimals = 1) {
3821
- if (bytes === 0)
3822
- return "0 Bytes";
3823
- const k = 1024;
3824
- const dm = decimals < 0 ? 0 : decimals;
3825
- const sizes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
3826
- const i = Math.floor(Math.log(bytes) / Math.log(k));
3827
- return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
3828
- }
3829
- onFileInputChange(event) {
3830
- const input = event.target;
3831
- this.addFiles(Array.from(input.files));
3832
- this._fileInput.value = "";
3833
- }
3834
- isRemoteFile(item) {
3835
- return "file" in item;
3836
- }
3837
- removeFromList(name) {
3838
- this._filePointers.delete(name);
3839
- this.updateValue();
3840
- }
3841
- removeFile(name) {
3842
- const item = this._filePointers.get(name);
3843
- if (this.isRemoteFile(item)) {
3844
- item.abortUpload();
3845
- this.removeFromList(name);
3846
- }
3847
- else {
3848
- if (this.urlDelete) {
3849
- const uploadingFile = new RemoteFile(null);
3850
- this._filePointers.set(item.name, uploadingFile);
3851
- uploadingFile.delete(item, this.urlDelete, null)
3852
- .then(_ok => this.removeFromList(name))
3853
- .catch(msg => this.showError(msg));
3854
- }
3855
- else {
3856
- this.removeFromList(name);
3857
- }
3858
- }
3859
- }
3860
- openFilesDialog() {
3861
- if (this.enabled) {
3862
- this._fileInput.click();
3863
- }
3864
- }
3865
- componentDidLoad() {
3866
- if (this.enabled && this._dropZone && window.FileList && window.File) {
3867
- this._dropZone.addEventListener("dragover", event => {
3868
- event.stopPropagation();
3869
- event.preventDefault();
3870
- event.dataTransfer.dropEffect = "copy";
3871
- this._dropZone.style.background = "#c2dbff";
3872
- });
3873
- this._dropZone.addEventListener("drop", event => {
3874
- event.stopPropagation();
3875
- event.preventDefault();
3876
- this.addFiles(Array.from(event.dataTransfer.files));
3877
- this._dropZone.style.background = "";
3878
- });
3879
- this._dropZone.addEventListener("dragleave", _event => {
3880
- this._dropZone.style.background = "";
3881
- });
3882
- }
3883
- }
3884
- componentWillRender() {
3885
- if (this.value) {
3886
- if (this._filePointers.size < this.value.length) {
3887
- this.updateFilePointers();
3888
- }
3889
- }
3890
- }
3891
- render() {
3892
- return (h("div", { ref: (el) => this._dropZone = el, class: this.evalDisabledClass("iu", "background--disabled") }, h("div", { class: "iu__container", onClick: () => this.openFilesDialog() }, h("div", { class: "iu_header" }, this.label ? h("label", { class: this.evalDisabledClass("iu__label", "text--disabled"), title: this.label }, this.label) : null, h("div", { class: this.evalDisabledClass("iu__icon-label", "mouse-pointer--disabled") }, h("button", { class: "iu__file-icon", disabled: !this.enabled }), 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()), h("input", { ref: (el) => this._fileInput = el, onChange: (ev) => this.onFileInputChange(ev), type: "file", multiple: true, hidden: true })));
3893
- }
3894
- buildFooter() {
3895
- if (this._filePointers.size === 0) {
3896
- return null;
3897
- }
3898
- const items = [];
3899
- this._filePointers.forEach(item => items.push(this.buildFileItem(item)));
3900
- return (h("div", { class: "iu__footer" }, items));
3901
- }
3902
- buildFileItem(item) {
3903
- const fileName = item.name;
3904
- const progress = Number(item["progress"]);
3905
- const downloadURL = item["downloadURL"];
3906
- const label = `${fileName} (${this.formatBytes(item.size)})`;
3907
- return (h("div", { class: "iu__item", key: fileName, onClick: evt => evt.stopPropagation() }, h("div", { class: "iu__item-label modificador" }, h("div", { title: label, class: "col--stretch align--middle file__name text text--primary text--small text--ellipsis align--middle" }, downloadURL ? h("a", { href: downloadURL, download: true }, label) : label)), isNaN(progress)
3908
- ?
3909
- null
3910
- :
3911
- h("div", { class: "col col--sd-4 col--stretch align--middle" }, h("progress", { id: this.buildProgressId(item), value: progress, max: "100" })), this.enabled
3912
- ?
3913
- h("div", { class: "col col--stretch align--middle" }, h("button", { class: "btn-cancel ", onClick: () => this.removeFile(fileName) }))
3914
- :
3915
- null));
3916
- }
3917
- evalDisabledClass(regularClasses, disabledClass) {
3918
- return this.enabled ? regularClasses : `${regularClasses} ${disabledClass}`;
3919
- }
3920
- get _host() { return getElement(this); }
3921
- static get watchers() { return {
3922
- "value": ["changeValue"],
3923
- "requestHeaders": ["normalizeRequestHeaders"]
3924
- }; }
3925
- };
3926
- EzUpload.style = ezUploadCss;
3927
-
3928
- let FormMetadata = class {
3929
- constructor(hostRef) {
3930
- registerInstance(this, hostRef);
3931
- }
3932
- buildField(element) {
3933
- let label = element.getAttribute("label");
3934
- let name = element.getAttribute("name") || label;
3935
- let userInterface = element.getAttribute("ui") || "SHORTTEXT";
3936
- let properties = [];
3937
- if (userInterface === "OPTIONSELECTOR") {
3938
- if (!label) {
3939
- label = "Selecione uma das opções:";
3940
- }
3941
- const objOpts = {};
3942
- Array.from(element.getElementsByTagName("OPTION")).forEach((optElem, index) => {
3943
- const optValue = optElem.getAttribute("value") || index;
3944
- const optLabel = optElem.textContent;
3945
- objOpts[optValue] = optLabel;
3946
- });
3947
- properties.push({ name: "options", value: JSON.stringify(objOpts) });
3948
- }
3949
- else if (userInterface === "FILE") {
3950
- const urlElement = element.querySelector("URL");
3951
- const headersElement = element.querySelectorAll("HEADERS>HEADER");
3952
- if (urlElement) {
3953
- properties.push({ name: "URL", value: urlElement.textContent });
3954
- }
3955
- if (headersElement && headersElement.length > 0) {
3956
- const headers = {};
3957
- headersElement.forEach(header => {
3958
- headers[header.getAttribute("name")] = header.textContent;
3959
- });
3960
- properties.push({ name: "HEADERS", value: JSON.stringify(headers) });
3961
- }
3962
- this.addPropertyIfExists(properties, element, "maxfiles");
3963
- }
3964
- else {
3965
- if (!label) {
3966
- label = element.textContent;
3967
- }
3968
- this.addPropertyIfExists(properties, element, "precision");
3969
- this.addPropertyIfExists(properties, element, "prettyprecision");
3970
- }
3971
- const defaultValue = element.getAttribute("defaultValue");
3972
- const required = element.getAttribute("required") === "true";
3973
- const readOnly = element.getAttribute("readonly") === "true";
3974
- return { name, userInterface, label, defaultValue, required, readOnly, properties };
3975
- }
3976
- addPropertyIfExists(properties, element, name) {
3977
- const value = element.getAttribute(name);
3978
- if (value) {
3979
- properties.push({ name, value });
3980
- }
3981
- }
3982
- buildFieldSet(dataUnit, element) {
3983
- const label = element.getAttribute("label");
3984
- const fields = Array.from(element.getElementsByTagName("FIELD")).map(f => {
3985
- const field = this.buildField(f);
3986
- dataUnit.addFieldMetadata(field);
3987
- return { name: field.name };
3988
- });
3989
- return { label, fields };
3990
- }
3991
- fromElements(elements, label, name, dataUnit, autoLoad) {
3992
- const form = {
3993
- name: name || label,
3994
- dataUnit,
3995
- label,
3996
- autoLoad
3997
- };
3998
- Array.from(elements).forEach(child => {
3999
- const tagName = child.tagName.toUpperCase();
4000
- switch (tagName) {
4001
- case "FIELD":
4002
- if (!form.items) {
4003
- form.items = [];
4004
- }
4005
- const f = this.buildField(child);
4006
- dataUnit.addFieldMetadata(f);
4007
- form.items.push({ name: f.name });
4008
- break;
4009
- case "FIELD-SET":
4010
- if (!form.items) {
4011
- form.items = [];
4012
- }
4013
- form.items.push(this.buildFieldSet(dataUnit, child));
4014
- break;
4015
- case "SUB-FORM":
4016
- if (!form.subForms) {
4017
- form.subForms = [];
4018
- }
4019
- const label = child.getAttribute("label") || "Subform " + (form.subForms.length + 1);
4020
- const name = child.getAttribute("name") || label;
4021
- const subDuName = child.getAttribute("dataunit");
4022
- let subDu;
4023
- if (subDuName) {
4024
- subDu = new DataUnit(subDuName, "noname", child.hasAttribute("many") ? "N" : "1");
4025
- }
4026
- else {
4027
- subDu = dataUnit;
4028
- }
4029
- form.subForms.push(this.fromElements(child.children, label, name, subDu, child.getAttribute("autoload") === "true"));
4030
- break;
4031
- }
4032
- });
4033
- return form;
4034
- }
4035
- connectedCallback() {
4036
- if (!this.dataunit) {
4037
- this.dataunit = "dataunit_" + (this.name || this.label || new Date().getTime());
4038
- }
4039
- const du = new DataUnit(this.dataunit, "noname", this.many ? "N" : "1");
4040
- this.metadata = this.fromElements(this._host.children, this.label, this.name, du, this.autoload);
4041
- }
4042
- render() {
4043
- return h(Host, null);
4044
- }
4045
- get _host() { return getElement(this); }
4046
- };
4047
-
4048
- const placeHolderCss = ":host{display:flex;width:100%;height:42px;border-radius:12px;background:var(--background--medium);background-image:linear-gradient(to right, var(--background--medium) 0%, var(--background--strong) 20%, var(--background--medium) 40%, var(--background--medium) 100%);background-repeat:no-repeat;background-size:800px 1000px;animation-duration:1s;animation-fill-mode:forwards;animation-iteration-count:infinite;animation-name:placeholderShimmer;animation-timing-function:linear}@keyframes placeholderShimmer{0%{background-position:-800px 0}100%{background-position:800px 0}}";
4049
-
4050
- let PlaceHolder = class {
4051
- constructor(hostRef) {
4052
- registerInstance(this, hostRef);
4053
- }
4054
- render() {
4055
- return h(Host, null);
4056
- }
4057
- };
4058
- PlaceHolder.style = placeHolderCss;
4059
-
4060
- export { EzButton as ez_button, EzCalendar as ez_calendar, EzCheck as ez_check, EzCollapsibleBox as ez_collapsible_box, EzComboBox as ez_combo_box, EzDateInput as ez_date_input, EzForm as ez_form, EzIcon as ez_icon, EzNumericInput as ez_numeric_input, EzSearch as ez_search, EzTabselector as ez_tabselector, EzTextArea as ez_text_area, EzTextInput as ez_text_input, EzUpload as ez_upload, FormMetadata as form_metadata, PlaceHolder as place_holder };