@sankhyalabs/sankhyablocks 1.3.31 → 1.3.32

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.
@@ -7097,7 +7097,8 @@ class PesquisaFetcher {
7097
7097
  }`);
7098
7098
  }
7099
7099
  loadSearchOptions(entityName, argument, criteria, options) {
7100
- argument = (argument === null || argument === void 0 ? void 0 : argument.trim()) ? `%${argument}` : argument === null || argument === void 0 ? void 0 : argument.trim();
7100
+ const cleanText = (argument === null || argument === void 0 ? void 0 : argument.trim()) || undefined;
7101
+ argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
7101
7102
  return new Promise((resolve, reject) => {
7102
7103
  DataFetcher.get()
7103
7104
  .callGraphQL({
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-1133bc2a.js');
6
6
  const core = require('@sankhyalabs/core');
7
7
 
8
- const snkPesquisaCss = ".sc-snk-pesquisa-h{--snk-pesquisa--font-size:var(--text--medium, 14px);--snk-pesquisa--font-family:var(--font-pattern, Arial);--snk-pesquisa--font-weight:var(--text-weight--medium, 400);--snk-pesquisa__records--color:var(--text--primary, #626e82);--snk-pesquisa__records--padding-vertical:var(--space--medium, 12px);--snk-pesquisa__content--padding-right:var(--space--small, 6px);--snk-pesquisa__content-scrollbar--background-color:var(--text--primary, #626e82);--snk-pesquisa__content-scrollbar--border-radius:var(--border--radius-small, 6px);--snk-pesquisa__content-scrollbar--width:var(--space--medium, 12px);max-height:100%;height:100%;display:flex;flex-direction:column;overflow-y:auto}.snk-pesquisa.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%}.snk-pesquisa__input.sc-snk-pesquisa{display:flex;width:100%;box-sizing:border-box;padding-top:4px;padding-right:4px}.snk-pesquisa__input-close.sc-snk-pesquisa{cursor:pointer}.snk-pesquisa__content.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%;overflow-y:auto;padding-right:var(--snk-pesquisa__content--padding-right)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-track{background-color:#f0f2f5;border-radius:var(--snk-pesquisa__content-scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb{background-color:var(--snk-pesquisa__content-scrollbar--background-color);border-radius:var(--snk-pesquisa__content-scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar{background-color:#f0f2f5;width:var(--snk-pesquisa__content-scrollbar--width);max-width:var(--snk-pesquisa__content-scrollbar--width);min-width:var(--snk-pesquisa__content-scrollbar--width)}.snk-pesquisa__records.sc-snk-pesquisa{font-family:var(--snk-pesquisa--font-family);font-weight:var(--snk-pesquisa--font-weight);font-size:var(--snk-pesquisa--font-size);color:var(--snk-pesquisa__records--color);padding-bottom:var(--snk-pesquisa__records--padding-vertical);padding-top:var(--snk-pesquisa__records--padding-vertical)}";
8
+ const snkPesquisaCss = ".sc-snk-pesquisa-h{--snk-pesquisa--font-size:var(--text--medium, 14px);--snk-pesquisa--font-family:var(--font-pattern, Arial);--snk-pesquisa--font-weight:var(--text-weight--medium, 400);--snk-pesquisa__records--color:var(--text--primary, #626e82);--snk-pesquisa__records--padding-vertical:var(--space--medium, 12px);--snk-pesquisa__content--padding-right:var(--space--small, 6px);--snk-pesquisa__content-scrollbar--background-color:var(--title--primary, #2B3A54);--snk-pesquisa__content-scrollbar--border-radius:var(--border--radius-small, 6px);--snk-pesquisa__content-scrollbar--width:var(--space--medium, 12px);--snk-pesquisa__btn--color:var(--title--primary, #2B3A54);--snk-pesquisa__btn-disabled--color:var(--text--disable, #AFB6C0);--snk-pesquisa__btn-hover--color:var(--color--primary, #4e4e4e);max-height:100%;height:100%;display:flex;flex-direction:column;overflow-y:auto}.snk-pesquisa.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%}.snk-pesquisa__input.sc-snk-pesquisa{display:flex;width:100%;box-sizing:border-box;padding-top:4px;padding-right:4px}.snk-pesquisa__input.sc-snk-pesquisa ez-icon.sc-snk-pesquisa{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.snk-pesquisa__content.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%;overflow-y:auto;padding-right:var(--snk-pesquisa__content--padding-right)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-track{background-color:#f0f2f5;border-radius:var(--snk-pesquisa__content-scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb{background-color:var(--snk-pesquisa__content-scrollbar--background-color);border-radius:var(--snk-pesquisa__content-scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar{background-color:#f0f2f5;width:var(--snk-pesquisa__content-scrollbar--width);max-width:var(--snk-pesquisa__content-scrollbar--width);min-width:var(--snk-pesquisa__content-scrollbar--width)}.snk-pesquisa__records.sc-snk-pesquisa{font-family:var(--snk-pesquisa--font-family);font-weight:var(--snk-pesquisa--font-weight);font-size:var(--snk-pesquisa--font-size);color:var(--snk-pesquisa__records--color);padding-bottom:var(--snk-pesquisa__records--padding-vertical);padding-top:var(--snk-pesquisa__records--padding-vertical)}.snk-pesquisa__btn.sc-snk-pesquisa{outline:none;border:none;background:none;cursor:pointer;color:var(--snk-pesquisa__btn--color)}.snk-pesquisa__btn.sc-snk-pesquisa:disabled{cursor:unset;color:var(--snk-pesquisa__btn-disabled--color)}.snk-pesquisa__btn.sc-snk-pesquisa:disabled:hover{cursor:unset;color:var(--snk-pesquisa__btn-disabled--color)}.snk-pesquisa__btn.sc-snk-pesquisa:hover{color:var(--snk-pesquisa__btn-hover--color)}";
9
9
 
10
10
  const SnkPesquisa = class {
11
11
  constructor(hostRef) {
@@ -299,7 +299,10 @@ const SnkPesquisa = class {
299
299
  : 'Os resultados de sua pesquisa aparecerão aqui...';
300
300
  }
301
301
  render() {
302
- return (index.h(index.Host, null, index.h("div", { class: "snk-pesquisa" }, index.h("div", { class: "snk-pesquisa__input" }, index.h("ez-text-input", { label: "Buscar", class: "ez-margin-right--medium", canShowError: false, ref: (ref) => this._textInput = ref, onEzChange: (event) => this.onChangeValue(event), value: this.argument }, index.h("ez-icon", { slot: "leftIcon", iconName: "search" }), index.h("ez-icon", { class: "snk-pesquisa__input-close", slot: "rightIcon", iconName: "close", onClick: () => { this.clearSearch(); } })), index.h("ez-button", { class: "ez-button--primary", label: "Pesquisar", onClick: () => this.onClickSearch() })), index.h("label", { class: "snk-pesquisa__records" }, this.getMessageView()), index.h("div", { class: "snk-pesquisa__content" }, this._itemList && this._itemList.map((item) => {
302
+ var _a;
303
+ return (index.h(index.Host, null, index.h("div", { class: "snk-pesquisa" }, index.h("div", { class: "snk-pesquisa__input" }, index.h("ez-text-input", { label: "Buscar", class: "ez-margin-right--medium", canShowError: false, ref: (ref) => this._textInput = ref, onEzChange: (event) => this.onChangeValue(event), value: this.argument }, index.h("ez-icon", { slot: "leftIcon", iconName: "search" }), this.argument && ((_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value)
304
+ ? index.h("button", { slot: "rightIcon", class: "snk-pesquisa__btn", onClick: () => this.clearSearch() }, index.h("ez-icon", { iconName: "close" }))
305
+ : undefined), index.h("ez-button", { class: "ez-button--primary", label: "Pesquisar", onClick: () => this.onClickSearch() })), index.h("label", { class: "snk-pesquisa__records" }, this.getMessageView()), index.h("div", { class: "snk-pesquisa__content" }, this._itemList && this._itemList.map((item) => {
303
306
  return (index.h("ez-card-item", { onEzClick: (event) => this.createOption(event.detail), item: item }));
304
307
  })))));
305
308
  }
@@ -1,31 +1,38 @@
1
1
  :host {
2
+ /* general */
2
3
  /*@doc Define o tamanho da fonte do componente.*/
3
4
  --snk-pesquisa--font-size: var(--text--medium, 14px);
4
-
5
5
  /*@doc Define a família da fonte do componente.*/
6
6
  --snk-pesquisa--font-family: var(--font-pattern, Arial);
7
-
8
7
  /*@doc Define o peso da fonte do componente.*/
9
8
  --snk-pesquisa--font-weight: var(--text-weight--medium, 400);
10
9
 
10
+ /* records */
11
11
  /*@doc Define a cor da fonte do indicador de registros do componente.*/
12
12
  --snk-pesquisa__records--color: var(--text--primary, #626e82);
13
-
14
13
  /*@doc Define o espaçamento vertical do indicador de registros do componente.*/
15
14
  --snk-pesquisa__records--padding-vertical: var(--space--medium, 12px);
16
15
 
16
+ /* content */
17
17
  /*@doc Define o espaçamento da direita no conteúdo do componente.*/
18
18
  --snk-pesquisa__content--padding-right: var(--space--small, 6px);
19
19
 
20
+ /* scrollbar */
20
21
  /*@doc Define a cor da barra de rolagem do componente.*/
21
- --snk-pesquisa__content-scrollbar--background-color: var(--text--primary, #626e82);
22
-
22
+ --snk-pesquisa__content-scrollbar--background-color: var(--title--primary, #2B3A54);
23
23
  /*@doc Define o raio da borda da barra de rolagem do componente.*/
24
24
  --snk-pesquisa__content-scrollbar--border-radius: var(--border--radius-small, 6px);
25
-
26
25
  /*@doc Define a largura da barra de rolagem do componente.*/
27
26
  --snk-pesquisa__content-scrollbar--width: var(--space--medium, 12px);
28
27
 
28
+ /* buttons */
29
+ /*@doc Define a cor do botão de pesquisa do componente.*/
30
+ --snk-pesquisa__btn--color: var(--title--primary, #2B3A54);
31
+ /*@doc Define a cor do botão de pesquisa do componente quando desabilitado.*/
32
+ --snk-pesquisa__btn-disabled--color: var(--text--disable, #AFB6C0);
33
+ /*@doc Define a cor do botão de pesquisa do componente quando o mouse está sobre ele.*/
34
+ --snk-pesquisa__btn-hover--color: var(--color--primary, #4e4e4e);
35
+
29
36
  max-height: 100%;
30
37
  height: 100%;
31
38
  display: flex;
@@ -47,8 +54,11 @@
47
54
  padding-right: 4px;
48
55
  }
49
56
 
50
- .snk-pesquisa__input-close {
51
- cursor: pointer;
57
+ .snk-pesquisa__input ez-icon {
58
+ --ez-icon--color: inherit;
59
+
60
+ /*public*/
61
+ font-weight: var(--text-weight--large, 600);
52
62
  }
53
63
 
54
64
  .snk-pesquisa__content {
@@ -91,4 +101,33 @@
91
101
  color: var(--snk-pesquisa__records--color);
92
102
  padding-bottom: var(--snk-pesquisa__records--padding-vertical);
93
103
  padding-top: var(--snk-pesquisa__records--padding-vertical);
104
+ }
105
+
106
+ .snk-pesquisa__btn {
107
+ outline: none;
108
+ border: none;
109
+ background: none;
110
+ cursor: pointer;
111
+
112
+ /*public*/
113
+ color: var(--snk-pesquisa__btn--color);
114
+ }
115
+
116
+ .snk-pesquisa__btn:disabled {
117
+ cursor: unset;
118
+
119
+ /*public*/
120
+ color: var(--snk-pesquisa__btn-disabled--color);
121
+ }
122
+
123
+ .snk-pesquisa__btn:disabled:hover {
124
+ cursor: unset;
125
+
126
+ /*public*/
127
+ color: var(--snk-pesquisa__btn-disabled--color);
128
+ }
129
+
130
+ .snk-pesquisa__btn:hover {
131
+ /*public*/
132
+ color: var(--snk-pesquisa__btn-hover--color);
94
133
  }
@@ -291,12 +291,16 @@ export class SnkPesquisa {
291
291
  : 'Os resultados de sua pesquisa aparecerão aqui...';
292
292
  }
293
293
  render() {
294
+ var _a;
294
295
  return (h(Host, null,
295
296
  h("div", { class: "snk-pesquisa" },
296
297
  h("div", { class: "snk-pesquisa__input" },
297
298
  h("ez-text-input", { label: "Buscar", class: "ez-margin-right--medium", canShowError: false, ref: (ref) => this._textInput = ref, onEzChange: (event) => this.onChangeValue(event), value: this.argument },
298
299
  h("ez-icon", { slot: "leftIcon", iconName: "search" }),
299
- h("ez-icon", { class: "snk-pesquisa__input-close", slot: "rightIcon", iconName: "close", onClick: () => { this.clearSearch(); } })),
300
+ this.argument && ((_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value)
301
+ ? h("button", { slot: "rightIcon", class: "snk-pesquisa__btn", onClick: () => this.clearSearch() },
302
+ h("ez-icon", { iconName: "close" }))
303
+ : undefined),
300
304
  h("ez-button", { class: "ez-button--primary", label: "Pesquisar", onClick: () => this.onClickSearch() })),
301
305
  h("label", { class: "snk-pesquisa__records" }, this.getMessageView()),
302
306
  h("div", { class: "snk-pesquisa__content" }, this._itemList && this._itemList.map((item) => {
@@ -16,7 +16,8 @@ export class PesquisaFetcher {
16
16
  }`);
17
17
  }
18
18
  loadSearchOptions(entityName, argument, criteria, options) {
19
- argument = (argument === null || argument === void 0 ? void 0 : argument.trim()) ? `%${argument}` : argument === null || argument === void 0 ? void 0 : argument.trim();
19
+ const cleanText = (argument === null || argument === void 0 ? void 0 : argument.trim()) || undefined;
20
+ argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
20
21
  return new Promise((resolve, reject) => {
21
22
  DataFetcher.get()
22
23
  .callGraphQL({
@@ -7094,7 +7094,8 @@ class PesquisaFetcher {
7094
7094
  }`);
7095
7095
  }
7096
7096
  loadSearchOptions(entityName, argument, criteria, options) {
7097
- argument = (argument === null || argument === void 0 ? void 0 : argument.trim()) ? `%${argument}` : argument === null || argument === void 0 ? void 0 : argument.trim();
7097
+ const cleanText = (argument === null || argument === void 0 ? void 0 : argument.trim()) || undefined;
7098
+ argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
7098
7099
  return new Promise((resolve, reject) => {
7099
7100
  DataFetcher.get()
7100
7101
  .callGraphQL({
@@ -1,7 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
2
  import { ObjectUtils, StringUtils } from '@sankhyalabs/core';
3
3
 
4
- const snkPesquisaCss = ".sc-snk-pesquisa-h{--snk-pesquisa--font-size:var(--text--medium, 14px);--snk-pesquisa--font-family:var(--font-pattern, Arial);--snk-pesquisa--font-weight:var(--text-weight--medium, 400);--snk-pesquisa__records--color:var(--text--primary, #626e82);--snk-pesquisa__records--padding-vertical:var(--space--medium, 12px);--snk-pesquisa__content--padding-right:var(--space--small, 6px);--snk-pesquisa__content-scrollbar--background-color:var(--text--primary, #626e82);--snk-pesquisa__content-scrollbar--border-radius:var(--border--radius-small, 6px);--snk-pesquisa__content-scrollbar--width:var(--space--medium, 12px);max-height:100%;height:100%;display:flex;flex-direction:column;overflow-y:auto}.snk-pesquisa.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%}.snk-pesquisa__input.sc-snk-pesquisa{display:flex;width:100%;box-sizing:border-box;padding-top:4px;padding-right:4px}.snk-pesquisa__input-close.sc-snk-pesquisa{cursor:pointer}.snk-pesquisa__content.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%;overflow-y:auto;padding-right:var(--snk-pesquisa__content--padding-right)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-track{background-color:#f0f2f5;border-radius:var(--snk-pesquisa__content-scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb{background-color:var(--snk-pesquisa__content-scrollbar--background-color);border-radius:var(--snk-pesquisa__content-scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar{background-color:#f0f2f5;width:var(--snk-pesquisa__content-scrollbar--width);max-width:var(--snk-pesquisa__content-scrollbar--width);min-width:var(--snk-pesquisa__content-scrollbar--width)}.snk-pesquisa__records.sc-snk-pesquisa{font-family:var(--snk-pesquisa--font-family);font-weight:var(--snk-pesquisa--font-weight);font-size:var(--snk-pesquisa--font-size);color:var(--snk-pesquisa__records--color);padding-bottom:var(--snk-pesquisa__records--padding-vertical);padding-top:var(--snk-pesquisa__records--padding-vertical)}";
4
+ const snkPesquisaCss = ".sc-snk-pesquisa-h{--snk-pesquisa--font-size:var(--text--medium, 14px);--snk-pesquisa--font-family:var(--font-pattern, Arial);--snk-pesquisa--font-weight:var(--text-weight--medium, 400);--snk-pesquisa__records--color:var(--text--primary, #626e82);--snk-pesquisa__records--padding-vertical:var(--space--medium, 12px);--snk-pesquisa__content--padding-right:var(--space--small, 6px);--snk-pesquisa__content-scrollbar--background-color:var(--title--primary, #2B3A54);--snk-pesquisa__content-scrollbar--border-radius:var(--border--radius-small, 6px);--snk-pesquisa__content-scrollbar--width:var(--space--medium, 12px);--snk-pesquisa__btn--color:var(--title--primary, #2B3A54);--snk-pesquisa__btn-disabled--color:var(--text--disable, #AFB6C0);--snk-pesquisa__btn-hover--color:var(--color--primary, #4e4e4e);max-height:100%;height:100%;display:flex;flex-direction:column;overflow-y:auto}.snk-pesquisa.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%}.snk-pesquisa__input.sc-snk-pesquisa{display:flex;width:100%;box-sizing:border-box;padding-top:4px;padding-right:4px}.snk-pesquisa__input.sc-snk-pesquisa ez-icon.sc-snk-pesquisa{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.snk-pesquisa__content.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%;overflow-y:auto;padding-right:var(--snk-pesquisa__content--padding-right)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-track{background-color:#f0f2f5;border-radius:var(--snk-pesquisa__content-scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb{background-color:var(--snk-pesquisa__content-scrollbar--background-color);border-radius:var(--snk-pesquisa__content-scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar{background-color:#f0f2f5;width:var(--snk-pesquisa__content-scrollbar--width);max-width:var(--snk-pesquisa__content-scrollbar--width);min-width:var(--snk-pesquisa__content-scrollbar--width)}.snk-pesquisa__records.sc-snk-pesquisa{font-family:var(--snk-pesquisa--font-family);font-weight:var(--snk-pesquisa--font-weight);font-size:var(--snk-pesquisa--font-size);color:var(--snk-pesquisa__records--color);padding-bottom:var(--snk-pesquisa__records--padding-vertical);padding-top:var(--snk-pesquisa__records--padding-vertical)}.snk-pesquisa__btn.sc-snk-pesquisa{outline:none;border:none;background:none;cursor:pointer;color:var(--snk-pesquisa__btn--color)}.snk-pesquisa__btn.sc-snk-pesquisa:disabled{cursor:unset;color:var(--snk-pesquisa__btn-disabled--color)}.snk-pesquisa__btn.sc-snk-pesquisa:disabled:hover{cursor:unset;color:var(--snk-pesquisa__btn-disabled--color)}.snk-pesquisa__btn.sc-snk-pesquisa:hover{color:var(--snk-pesquisa__btn-hover--color)}";
5
5
 
6
6
  const SnkPesquisa = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
7
  constructor() {
@@ -296,7 +296,10 @@ const SnkPesquisa = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
296
296
  : 'Os resultados de sua pesquisa aparecerão aqui...';
297
297
  }
298
298
  render() {
299
- return (h(Host, null, h("div", { class: "snk-pesquisa" }, h("div", { class: "snk-pesquisa__input" }, h("ez-text-input", { label: "Buscar", class: "ez-margin-right--medium", canShowError: false, ref: (ref) => this._textInput = ref, onEzChange: (event) => this.onChangeValue(event), value: this.argument }, h("ez-icon", { slot: "leftIcon", iconName: "search" }), h("ez-icon", { class: "snk-pesquisa__input-close", slot: "rightIcon", iconName: "close", onClick: () => { this.clearSearch(); } })), h("ez-button", { class: "ez-button--primary", label: "Pesquisar", onClick: () => this.onClickSearch() })), h("label", { class: "snk-pesquisa__records" }, this.getMessageView()), h("div", { class: "snk-pesquisa__content" }, this._itemList && this._itemList.map((item) => {
299
+ var _a;
300
+ return (h(Host, null, h("div", { class: "snk-pesquisa" }, h("div", { class: "snk-pesquisa__input" }, h("ez-text-input", { label: "Buscar", class: "ez-margin-right--medium", canShowError: false, ref: (ref) => this._textInput = ref, onEzChange: (event) => this.onChangeValue(event), value: this.argument }, h("ez-icon", { slot: "leftIcon", iconName: "search" }), this.argument && ((_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value)
301
+ ? h("button", { slot: "rightIcon", class: "snk-pesquisa__btn", onClick: () => this.clearSearch() }, h("ez-icon", { iconName: "close" }))
302
+ : undefined), h("ez-button", { class: "ez-button--primary", label: "Pesquisar", onClick: () => this.onClickSearch() })), h("label", { class: "snk-pesquisa__records" }, this.getMessageView()), h("div", { class: "snk-pesquisa__content" }, this._itemList && this._itemList.map((item) => {
300
303
  return (h("ez-card-item", { onEzClick: (event) => this.createOption(event.detail), item: item }));
301
304
  })))));
302
305
  }
@@ -7093,7 +7093,8 @@ class PesquisaFetcher {
7093
7093
  }`);
7094
7094
  }
7095
7095
  loadSearchOptions(entityName, argument, criteria, options) {
7096
- argument = (argument === null || argument === void 0 ? void 0 : argument.trim()) ? `%${argument}` : argument === null || argument === void 0 ? void 0 : argument.trim();
7096
+ const cleanText = (argument === null || argument === void 0 ? void 0 : argument.trim()) || undefined;
7097
+ argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
7097
7098
  return new Promise((resolve, reject) => {
7098
7099
  DataFetcher.get()
7099
7100
  .callGraphQL({
@@ -1,7 +1,7 @@
1
1
  import { r as registerInstance, h, H as Host } from './index-ffda6382.js';
2
2
  import { ObjectUtils, StringUtils } from '@sankhyalabs/core';
3
3
 
4
- const snkPesquisaCss = ".sc-snk-pesquisa-h{--snk-pesquisa--font-size:var(--text--medium, 14px);--snk-pesquisa--font-family:var(--font-pattern, Arial);--snk-pesquisa--font-weight:var(--text-weight--medium, 400);--snk-pesquisa__records--color:var(--text--primary, #626e82);--snk-pesquisa__records--padding-vertical:var(--space--medium, 12px);--snk-pesquisa__content--padding-right:var(--space--small, 6px);--snk-pesquisa__content-scrollbar--background-color:var(--text--primary, #626e82);--snk-pesquisa__content-scrollbar--border-radius:var(--border--radius-small, 6px);--snk-pesquisa__content-scrollbar--width:var(--space--medium, 12px);max-height:100%;height:100%;display:flex;flex-direction:column;overflow-y:auto}.snk-pesquisa.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%}.snk-pesquisa__input.sc-snk-pesquisa{display:flex;width:100%;box-sizing:border-box;padding-top:4px;padding-right:4px}.snk-pesquisa__input-close.sc-snk-pesquisa{cursor:pointer}.snk-pesquisa__content.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%;overflow-y:auto;padding-right:var(--snk-pesquisa__content--padding-right)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-track{background-color:#f0f2f5;border-radius:var(--snk-pesquisa__content-scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb{background-color:var(--snk-pesquisa__content-scrollbar--background-color);border-radius:var(--snk-pesquisa__content-scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar{background-color:#f0f2f5;width:var(--snk-pesquisa__content-scrollbar--width);max-width:var(--snk-pesquisa__content-scrollbar--width);min-width:var(--snk-pesquisa__content-scrollbar--width)}.snk-pesquisa__records.sc-snk-pesquisa{font-family:var(--snk-pesquisa--font-family);font-weight:var(--snk-pesquisa--font-weight);font-size:var(--snk-pesquisa--font-size);color:var(--snk-pesquisa__records--color);padding-bottom:var(--snk-pesquisa__records--padding-vertical);padding-top:var(--snk-pesquisa__records--padding-vertical)}";
4
+ const snkPesquisaCss = ".sc-snk-pesquisa-h{--snk-pesquisa--font-size:var(--text--medium, 14px);--snk-pesquisa--font-family:var(--font-pattern, Arial);--snk-pesquisa--font-weight:var(--text-weight--medium, 400);--snk-pesquisa__records--color:var(--text--primary, #626e82);--snk-pesquisa__records--padding-vertical:var(--space--medium, 12px);--snk-pesquisa__content--padding-right:var(--space--small, 6px);--snk-pesquisa__content-scrollbar--background-color:var(--title--primary, #2B3A54);--snk-pesquisa__content-scrollbar--border-radius:var(--border--radius-small, 6px);--snk-pesquisa__content-scrollbar--width:var(--space--medium, 12px);--snk-pesquisa__btn--color:var(--title--primary, #2B3A54);--snk-pesquisa__btn-disabled--color:var(--text--disable, #AFB6C0);--snk-pesquisa__btn-hover--color:var(--color--primary, #4e4e4e);max-height:100%;height:100%;display:flex;flex-direction:column;overflow-y:auto}.snk-pesquisa.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%}.snk-pesquisa__input.sc-snk-pesquisa{display:flex;width:100%;box-sizing:border-box;padding-top:4px;padding-right:4px}.snk-pesquisa__input.sc-snk-pesquisa ez-icon.sc-snk-pesquisa{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.snk-pesquisa__content.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%;overflow-y:auto;padding-right:var(--snk-pesquisa__content--padding-right)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-track{background-color:#f0f2f5;border-radius:var(--snk-pesquisa__content-scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb{background-color:var(--snk-pesquisa__content-scrollbar--background-color);border-radius:var(--snk-pesquisa__content-scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar{background-color:#f0f2f5;width:var(--snk-pesquisa__content-scrollbar--width);max-width:var(--snk-pesquisa__content-scrollbar--width);min-width:var(--snk-pesquisa__content-scrollbar--width)}.snk-pesquisa__records.sc-snk-pesquisa{font-family:var(--snk-pesquisa--font-family);font-weight:var(--snk-pesquisa--font-weight);font-size:var(--snk-pesquisa--font-size);color:var(--snk-pesquisa__records--color);padding-bottom:var(--snk-pesquisa__records--padding-vertical);padding-top:var(--snk-pesquisa__records--padding-vertical)}.snk-pesquisa__btn.sc-snk-pesquisa{outline:none;border:none;background:none;cursor:pointer;color:var(--snk-pesquisa__btn--color)}.snk-pesquisa__btn.sc-snk-pesquisa:disabled{cursor:unset;color:var(--snk-pesquisa__btn-disabled--color)}.snk-pesquisa__btn.sc-snk-pesquisa:disabled:hover{cursor:unset;color:var(--snk-pesquisa__btn-disabled--color)}.snk-pesquisa__btn.sc-snk-pesquisa:hover{color:var(--snk-pesquisa__btn-hover--color)}";
5
5
 
6
6
  const SnkPesquisa = class {
7
7
  constructor(hostRef) {
@@ -295,7 +295,10 @@ const SnkPesquisa = class {
295
295
  : 'Os resultados de sua pesquisa aparecerão aqui...';
296
296
  }
297
297
  render() {
298
- return (h(Host, null, h("div", { class: "snk-pesquisa" }, h("div", { class: "snk-pesquisa__input" }, h("ez-text-input", { label: "Buscar", class: "ez-margin-right--medium", canShowError: false, ref: (ref) => this._textInput = ref, onEzChange: (event) => this.onChangeValue(event), value: this.argument }, h("ez-icon", { slot: "leftIcon", iconName: "search" }), h("ez-icon", { class: "snk-pesquisa__input-close", slot: "rightIcon", iconName: "close", onClick: () => { this.clearSearch(); } })), h("ez-button", { class: "ez-button--primary", label: "Pesquisar", onClick: () => this.onClickSearch() })), h("label", { class: "snk-pesquisa__records" }, this.getMessageView()), h("div", { class: "snk-pesquisa__content" }, this._itemList && this._itemList.map((item) => {
298
+ var _a;
299
+ return (h(Host, null, h("div", { class: "snk-pesquisa" }, h("div", { class: "snk-pesquisa__input" }, h("ez-text-input", { label: "Buscar", class: "ez-margin-right--medium", canShowError: false, ref: (ref) => this._textInput = ref, onEzChange: (event) => this.onChangeValue(event), value: this.argument }, h("ez-icon", { slot: "leftIcon", iconName: "search" }), this.argument && ((_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value)
300
+ ? h("button", { slot: "rightIcon", class: "snk-pesquisa__btn", onClick: () => this.clearSearch() }, h("ez-icon", { iconName: "close" }))
301
+ : undefined), h("ez-button", { class: "ez-button--primary", label: "Pesquisar", onClick: () => this.onClickSearch() })), h("label", { class: "snk-pesquisa__records" }, this.getMessageView()), h("div", { class: "snk-pesquisa__content" }, this._itemList && this._itemList.map((item) => {
299
302
  return (h("ez-card-item", { onEzClick: (event) => this.createOption(event.detail), item: item }));
300
303
  })))));
301
304
  }
@@ -0,0 +1 @@
1
+ import{r as s,h as t,H as e}from"./p-edcb9d8e.js";import{ObjectUtils as i,StringUtils as r}from"@sankhyalabs/core";const n=class{constructor(t){s(this,t),this._mdByName={},this._startHighlightTag="<span class='card-item__highlight'>",this._endHighlightTag="</span>",this._specialCharsRegex=/[[.\-\$\+\*,_\&\(\)%\/\\#@!:\|\=\'\"]/gim,this._charsWithAccentuation="ÁÉÍÓÚ_ÃÕ_ÂÊÎÔÛ_ÀÈÌÒÙ_Ü_Ç_áéíóú_ãõ_âêîôû_àèìòù_ü_ç",this._charsWithoutAccentuation="AEIOU_AO_AEIOU_AEIOU_U_C_aeiou_ao_aeiou_aeiou_u_c",this._changeDeboucingTimeout=null,this._limitCharsToSearch=3,this._deboucingTime=450,this._startLoading=!1}observeArgument(){this._textInput&&(this._textInput.value=this.argument)}clearSearch(){this.argument="",this._itemList=void 0}buildDetails(s,t){let e={};for(let i=0;i<s.length;i++){const r=s[i],n=t[r.fieldName];e[r.description]=this.highlightValue(t.__matchFields,r.options&&r.options[n]||n,s,!0)}return e}buildFirstFields(s,t,e=6){return s&&Array.isArray(s)&&s.forEach((s=>{let e=this.removeReference(t,this._mdByName[s]);e&&t.unshift(e)})),t=t.slice(0,e)}doSearch(s){this.searchLoader&&"function"==typeof this.searchLoader&&(this._startLoading=!0,this.searchLoader(s).then((s=>{if(this._startLoading=!1,s){let t=(s=i.stringToObject(s.json.$)).descriptionField,e=s.pkField;if(t&&e){let i=[];s.data.forEach((r=>{var n;let a=this.filterFieldsMetadata(s,r),o=this.buildFirstFields(r.__matchFields,a),l={key:this.highlightValue(r.__matchFields,null===(n=r[e])||void 0===n?void 0:n.toString(),o,!0),title:this.highlightValue(r.__matchFields,r[t],o,!0),details:this.buildDetails(o,r)};i.push(l)})),this._itemList=i}}})).catch((s=>{this._startLoading=!1,this._itemList=[],console.warn(s)})))}filterFieldsMetadata(s,t){return s.fieldsMetadata.filter((e=>{let i=!r.isEmpty(t[e.fieldName])&&!1!==e.visible&&"B"!==e.type&&s.pkField!==e.fieldName&&s.descriptionField!==e.fieldName&&(e.isPrimaryKey||!e.isLinkField)&&!("S"===e.type&&"H"===e.presentationType);return i&&(this._mdByName[e.fieldName]=e),("string"!=typeof t[e.fieldName]||!(t[e.fieldName].indexOf("<img")>-1||t[e.fieldName].indexOf("<svg")>-1))&&i}))}removeAtIndex(s,t){if(t>=0&&t<s.length)return s.splice(t,1)[0]}removeReference(s,t){let e=this.indexOf(s,t);return this.removeAtIndex(s,e)}indexOf(s,t){let e=-1;return Array.isArray(s)&&this.find(s,((s,i)=>(e=i,this.equals(t,s)))),e}equals(s,t){return i.objectToString(s)===i.objectToString(t)}find(s,t){if(s)for(let e=0,i=s.length;e<i;e++)if(t(s[e],e,s))return s[e]}highlightValue(s,t,e,i){let r=this.replaceHtmlEntities(t);if(this.argument&&(i||this.isIn(s,e.fieldName))){const s=this.getArgumentNumber();let t=(isNaN(s)?this.argument:s.toString()).split(/%|,|\s+/),i=0,n=this.replaceAccentuatedChars(r);t.forEach((s=>{if(s){s=this.replaceAccentuatedChars(s);let t=this.getSpecialCharacters(s);null!=t&&t.length>0&&(s=this.removeSpecialCharacters(s)),(e.mask||"CGC_CPF"===e.uiType||"Phone"===e.uiType)&&(s=s.split("").join("\\.?\\-?\\/?\\(?\\)?"));let a=new RegExp(s,"ig");a.lastIndex=i;let o=a.exec(n);if(o&&o.length>0){i=o.index;let s=o[0].length,t=r.substring(i,i+s),e=(null==t?void 0:t.trim())?this._startHighlightTag+t+this._endHighlightTag:"",a=r.substring(0,i),l=r.substring(i+s);r=a+e+l,i+=e.length,n=this.replaceAccentuatedChars(r)}}}))}return r}replaceHtmlEntities(s){return null==s?s:String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}replaceAccentuatedChars(s){return null==s?s:this.replaceToSpace(s,["&amp;","&lt;","&gt;","&quot;"]).replace(/[^\w ]/g,(s=>{let t=this._charsWithAccentuation.indexOf(s);return t>-1&&(s=this._charsWithoutAccentuation.charAt(t)),s||""}))}replaceToSpace(s,t=[]){return null==s||t.forEach((t=>{const e=new RegExp(t,"g");let i="";for(let s=0;s<t.length;s++)i+=" ";s=String(s).replace(e,i)})),s}isIn(s,t){return this.indexOf(s,t)>-1}getSpecialCharacters(s){let t,e=[];for(;t=this._specialCharsRegex.exec(s);)e.push(s[t.index]);return e}removeSpecialCharacters(s){return this.getSpecialCharacters(s).forEach((t=>{s=this.replaceAll(s,t,"")})),s}replaceAll(s,t,e){let i=(null!=s?s:"").indexOf(t);for(;i>-1;)i=(s=s.replace(t,e)).indexOf(t);return s}getArgumentNumber(){return Number(this.argument||void 0)}createOption(s){const{key:t,title:e}=s,i=new RegExp(this._startHighlightTag,"g"),r=new RegExp(this._endHighlightTag,"g"),n={value:null==t?void 0:t.replace(i,"").replace(r,""),label:null==e?void 0:e.replace(i,"").replace(r,"")};this.selectItem(n)}onChangeValue(s){if(this.clearDeboucingTimeout(),this._startLoading)return void(this._changeDeboucingTimeout=setTimeout((()=>{this.onChangeValue(s)}),this._deboucingTime));this.argument=(s.detail||"").trim();const t=this.getArgumentNumber();this.argument&&(!isNaN(t)||this.argument.length>=this._limitCharsToSearch)?this._changeDeboucingTimeout=setTimeout((()=>{this.doSearch(isNaN(t)?this.argument:t.toString())}),this._deboucingTime):this._itemList=void 0}clearDeboucingTimeout(){this._changeDeboucingTimeout&&(clearTimeout(this._changeDeboucingTimeout),this._changeDeboucingTimeout=void 0)}onClickSearch(){this.doSearch((this.argument||"").trim())}getMessageView(){return this._startLoading?"Aguarde, buscando registros...":this._itemList?this._itemList.length>=1?`${this._itemList.length} ${this._itemList.length>1?"registros encontrados":"registro encontrado"}`:"Nenhum registro encontrado":"Os resultados de sua pesquisa aparecerão aqui..."}render(){var s;return t(e,null,t("div",{class:"snk-pesquisa"},t("div",{class:"snk-pesquisa__input"},t("ez-text-input",{label:"Buscar",class:"ez-margin-right--medium",canShowError:!1,ref:s=>this._textInput=s,onEzChange:s=>this.onChangeValue(s),value:this.argument},t("ez-icon",{slot:"leftIcon",iconName:"search"}),this.argument&&(null===(s=this._textInput)||void 0===s?void 0:s.value)?t("button",{slot:"rightIcon",class:"snk-pesquisa__btn",onClick:()=>this.clearSearch()},t("ez-icon",{iconName:"close"})):void 0),t("ez-button",{class:"ez-button--primary",label:"Pesquisar",onClick:()=>this.onClickSearch()})),t("label",{class:"snk-pesquisa__records"},this.getMessageView()),t("div",{class:"snk-pesquisa__content"},this._itemList&&this._itemList.map((s=>t("ez-card-item",{onEzClick:s=>this.createOption(s.detail),item:s}))))))}static get watchers(){return{argument:["observeArgument"]}}};n.style=".sc-snk-pesquisa-h{--snk-pesquisa--font-size:var(--text--medium, 14px);--snk-pesquisa--font-family:var(--font-pattern, Arial);--snk-pesquisa--font-weight:var(--text-weight--medium, 400);--snk-pesquisa__records--color:var(--text--primary, #626e82);--snk-pesquisa__records--padding-vertical:var(--space--medium, 12px);--snk-pesquisa__content--padding-right:var(--space--small, 6px);--snk-pesquisa__content-scrollbar--background-color:var(--title--primary, #2B3A54);--snk-pesquisa__content-scrollbar--border-radius:var(--border--radius-small, 6px);--snk-pesquisa__content-scrollbar--width:var(--space--medium, 12px);--snk-pesquisa__btn--color:var(--title--primary, #2B3A54);--snk-pesquisa__btn-disabled--color:var(--text--disable, #AFB6C0);--snk-pesquisa__btn-hover--color:var(--color--primary, #4e4e4e);max-height:100%;height:100%;display:flex;flex-direction:column;overflow-y:auto}.snk-pesquisa.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%}.snk-pesquisa__input.sc-snk-pesquisa{display:flex;width:100%;box-sizing:border-box;padding-top:4px;padding-right:4px}.snk-pesquisa__input.sc-snk-pesquisa ez-icon.sc-snk-pesquisa{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.snk-pesquisa__content.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%;overflow-y:auto;padding-right:var(--snk-pesquisa__content--padding-right)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-track{background-color:#f0f2f5;border-radius:var(--snk-pesquisa__content-scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb{background-color:var(--snk-pesquisa__content-scrollbar--background-color);border-radius:var(--snk-pesquisa__content-scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar{background-color:#f0f2f5;width:var(--snk-pesquisa__content-scrollbar--width);max-width:var(--snk-pesquisa__content-scrollbar--width);min-width:var(--snk-pesquisa__content-scrollbar--width)}.snk-pesquisa__records.sc-snk-pesquisa{font-family:var(--snk-pesquisa--font-family);font-weight:var(--snk-pesquisa--font-weight);font-size:var(--snk-pesquisa--font-size);color:var(--snk-pesquisa__records--color);padding-bottom:var(--snk-pesquisa__records--padding-vertical);padding-top:var(--snk-pesquisa__records--padding-vertical)}.snk-pesquisa__btn.sc-snk-pesquisa{outline:none;border:none;background:none;cursor:pointer;color:var(--snk-pesquisa__btn--color)}.snk-pesquisa__btn.sc-snk-pesquisa:disabled{cursor:unset;color:var(--snk-pesquisa__btn-disabled--color)}.snk-pesquisa__btn.sc-snk-pesquisa:disabled:hover{cursor:unset;color:var(--snk-pesquisa__btn-disabled--color)}.snk-pesquisa__btn.sc-snk-pesquisa:hover{color:var(--snk-pesquisa__btn-hover--color)}";export{n as snk_pesquisa}
@@ -66,4 +66,4 @@ import{r as e,c as t,h as n}from"./p-edcb9d8e.js";import{ErrorException as i,Str
66
66
  value
67
67
  label
68
68
  }
69
- }`)}loadSearchOptions(e,t,n,i){return t=(null==t?void 0:t.trim())?`%${t}`:null==t?void 0:t.trim(),new Promise(((r,s)=>{ee.get().callGraphQL({values:{argument:t,entityName:e,criteria:n,options:i},query:this._templateByQuery.get("search")}).then((e=>{r(e)})).catch((e=>{s(e)}))}))}loadAdvancedSearch(e,t,n,i){const r={query:{$:null==n?void 0:n.expression}};(null==n?void 0:n.params.length)>0&&(r.params={param:n.params.map((e=>({$:e.value,type:ce(e.dataType)})))});const s={serviceName:"PesquisaSP.getSuggestion",requestBody:{criteria:{entityName:e,compacted:!1,ignoreEntityCriteria:!1,limit:this._defaultPageSize,query:{$:t},orderByDesc:!1,externalCriteria:r,localEntityName:null==i?void 0:i.rootEntity},clientEventList:{clientEvent:[]}}};return new Promise(((e,t)=>{ee.get().callServiceBroker("PesquisaSP.getSuggestion",JSON.stringify(s)).then((t=>e(t))).catch((e=>t(e)))}))}}function ce(e){switch(e){case o.NUMBER:return"I";case o.DATE:return"D";default:return"S"}}class he extends se{getData(e){const t=`cfg://auth/${e}`;return new Promise(((e,n)=>{this.loadResource(t).then((t=>{let n=c.stringToObject(t);n&&"object"==typeof n&&e(n)})).catch((e=>{n(e)}))}))}}!function(e){e.INSERT="I",e.UPDATE="A",e.REMOVE="E",e.SHOW="C",e.CONFIG="F",e.CONFIG_NUMBER="N",e.CLONE="D",e.CONFIG_GRID="G"}(w||(w={}));const le=fe;function fe(e,t){const n=de();return(fe=function(e){return n[e-=378]})(e,t)}function de(){const e=["true","863GKWjmo","parse","56355fjjjAm","isSup","putAccess","4324480sjuCdS","hasOwnProperty","239748okvJLB","name","6055770tXeRaU","actions","forEach","7RPRvzn","1042CHxkUw","2988126NIwRMm","20MTNzmH","authorizationSf","item","string","hasAccess","isArray","Objeto não pode ser indefinido.","3071943fWslZp","parseFromJSON"];return(de=function(){return e})()}!function(){const e=fe,t=de();for(;;)try{if(281287==parseInt(e(399))/1*(-parseInt(e(387))/2)+-parseInt(e(401))/3+parseInt(e(381))/4*(-parseInt(e(389))/5)+parseInt(e(388))/6*(-parseInt(e(386))/7)+parseInt(e(379))/8+parseInt(e(396))/9+parseInt(e(383))/10)break;t.push(t.shift())}catch(e){t.push(t.shift())}}();class ve{[le(397)](e){const t=le;if(typeof(e=utxt(e[t(390)]))==t(392)&&(e=JSON[t(400)](e)),null==e)throw Error(t(395));const n=new pe("S"===e[t(402)]||!0===e[t(402)]);return Array[t(394)](e[t(391)])&&e[t(391)][t(385)]((e=>n.putAccess(e[t(382)],String(e.status)==t(398)))),n}}class pe{constructor(e){const t=le;this.isSup=e,this[t(384)]={}}[le(378)](e,t){this[le(384)][e]=t}[le(393)](e){const t=le;if(this[t(402)])return!0;let n=!0;return this[t(384)][t(380)](e)&&(n=this.actions[e]),n}isUserSup(){return this.isSup}}class me{constructor(e){this._app=e,window.addEventListener("error",(e=>this.errorHandler(e))),window.addEventListener("unhandledrejection",(e=>this.rejectionHandler(e)))}rejectionHandler(e){const t=e.reason;t instanceof h||(t?this.processException(t):this._app.isDebugMode().then((e=>{e&&this._app.error("Promise rejeitada","Erro interno: Uma promise foi rejeitada sem razão determinada.")})))}errorHandler(e){this.processException(e.error)}processException(e){e instanceof h||e instanceof l?this._app.alert(e.title,e.message):e instanceof i?this._app.error(e.title,e.message):this._app.isDebugMode().then((t=>{t&&(e instanceof Error?this._app.error(e.name,e.message):this._app.error((null==e?void 0:e.title)||"Erro detectado","string"==typeof e?e:e.message||`Erro interno "${e}"`))}))}}function ye(){const e=["2909523kXwted","CompanyName=Sankhya Jiva Tecnologia e Inovao Ltda,LicensedApplication=Sankhya Gestao,LicenseType=SingleApplication,LicensedConcurrentDeveloperCount=2,LicensedProductionInstancesCount=0,AssetReference=AG-019460,ExpiryDate=9_November_2022_[v2]_MTY2Nzk1MjAwMDAwMA==10487151e296ee4360f80961ca960869","1131048CARoeW","502909mLEPmu","447255iQEXuN","428UHbJwW","270AFTxAV","194369jhGqTI","1540nWuTrj","2044062GicUQI","30CkXPWg"];return(ye=function(){return e})()}const be=we;function we(e,t){const n=ye();return(we=function(e){return n[e-=392]})(e,t)}!function(){const e=we,t=ye();for(;;)try{if(951926==-parseInt(e(398))/1+-parseInt(e(393))/2+parseInt(e(395))/3+-parseInt(e(400))/4*(parseInt(e(392))/5)+-parseInt(e(401))/6*(-parseInt(e(402))/7)+parseInt(e(397))/8+-parseInt(e(399))/9*(-parseInt(e(394))/10))break;t.push(t.shift())}catch(e){t.push(t.shift())}}();const ge=be(396),Oe=class{constructor(n){e(this,n),this.applicationLoaded=t(this,"applicationLoaded",7),this.applicationLoading=t(this,"applicationLoading",7),this._requestListener=new Se}get parameters(){return this._parameters||(this._parameters=new re),this._parameters}get resourceID(){return this._resourceID||(this._resourceID=this.urlParams.get("workspaceResourceID")||this.urlParams.get("resourceID")||ie.resourceID||"unknown.resource.id"),this._resourceID}get auth(){return new Promise(((e,t)=>{this._auth?e(this._auth):this.authFetcher.getData(this._resourceID).then((t=>{this._auth=t,e(t)})).catch((e=>t(e)))}))}async isUserSup(){return new Promise(((e,t)=>{this.auth.then((n=>{this.getAuthList(n).then((t=>{e(t.isSup)})).catch((e=>t(e)))}))}))}async hasAccess(e){return new Promise(((t,n)=>{this.auth.then((i=>{this.getAuthList(i).then((n=>{t(n.isSup||n.actions[e])})).catch((e=>n(e)))}))}))}async getAllAccess(){return new Promise(((e,t)=>{this.auth.then((n=>{this.getAuthList(n).then((t=>{const n={};n.isSup=t.isSup,Object.entries(w).forEach((e=>{n[e[0]]=t.actions[e[1]]||!1})),e(n)})).catch((e=>t(e)))}))}))}async getAuthList(e){return await(new ve).parseFromJSON(e)}async getStringParam(e){return this.parameters.asString(e,this.resourceID)}async getIntParam(e){return this.parameters.asInteger(e,this.resourceID)}async getFloatParam(e){return this.parameters.asFloat(e,this.resourceID)}async getBooleanParam(e){return this.parameters.asBoolean(e,this.resourceID)}async getDateParam(e){return this.parameters.asDate(e,this.resourceID)}async showPopUp(e){this.clearPopUpContent(),this._popUp.appendChild(e),this._popUp.opened=!0}async closePopUp(){this.clearPopUpContent(),this._popUp.opened=!1}async temOpcional(e){const t=e.split(",");return new Promise(((e,n)=>{this.getAttributeFromHTMLWrapper("opc0009").then((i=>{"1"===i?e(!0):Promise.all(t.map((e=>this.getAttributeFromHTMLWrapper("opc"+e)))).then((t=>{e(t.includes("1"))})).catch((e=>{n(e)}))})).catch((e=>{n(e)}))}))}async getConfig(e){let t={serviceName:"SystemUtilsSP.getConf",requestBody:{config:{chave:e,tipo:"T"}}};return new Promise(((e,n)=>{ee.get().callServiceBroker("SystemUtilsSP.getConf",JSON.stringify(t)).then((t=>{var n;return e(null===(n=t.config)||void 0===n?void 0:n.data)})).catch((e=>n(e)))}))}async saveConfig(e,t){let n={serviceName:"SystemUtilsSP.saveConf",requestBody:{config:{chave:e,tipo:"T",data:t}}};return new Promise(((e,t)=>{ee.get().callServiceBroker("SystemUtilsSP.saveConf",JSON.stringify(n)).then((t=>e(t))).catch((e=>t(e)))}))}async getAttributeFromHTMLWrapper(e){return Promise.resolve(window[e])}async openApp(e,t){ie.openAppActivity(e,t)}async createDataunit(e){return new Promise((t=>{const n=this.dataUnitFetcher.getDataUnit(e,this.resourceID);n.loadMetadata().then((()=>t(n)))}))}async getResourceID(){return Promise.resolve(this.resourceID)}async alert(e,t,n,i){return v.alert(e,t,n,i)}async error(e,t,n,i){return v.error(e,t,n,i)}async confirm(e,t,n,i,r){return v.confirm(e,t,n,i,r)}async info(e,t){return v.info(e,t)}async loadFormConfig(e){return this.formConfigFetcher.loadFormConfig(e,this.resourceID)}async loadGridConfig(){return this.gridConfigFetcher.getConfig(this.resourceID)}async saveGridConfig(e){return this.gridConfigFetcher.saveConfig(e,this.resourceID)}get urlParams(){return this._urlParams||(this._urlParams=Z.getQueryParams(location.search)),this._urlParams}get dataUnitFetcher(){return this._dataUnitFetcher||(this._dataUnitFetcher=new ne),this._dataUnitFetcher}get formConfigFetcher(){return this._formConfigFetcher||(this._formConfigFetcher=new oe),this._formConfigFetcher}get gridConfigFetcher(){return this._gridConfigFetcher||(this._gridConfigFetcher=new ae),this._gridConfigFetcher}get pesquisaFetcher(){return this._pesquisaFetcher||(this._pesquisaFetcher=new ue),this._pesquisaFetcher}get authFetcher(){return this._authFetcher||(this._authFetcher=new he),this._authFetcher}async executeSearch(e,t,n){const i=null==n?void 0:n.getField(t);if(i){const{mode:t,argument:r}=e,{ENTITYNAME:s,CODEFIELD:a,DESCRIPTIONFIELD:u,ROOTENTITY:c,DESCRIPTIONENTITY:h}=i.properties,l=i.dependencies;let f;const d={rootEntity:c,descriptionFieldName:u,codeFieldName:a,showInactives:!1};return null==l||l.filter((e=>{var t;return null===(t=e.masterFields)||void 0===t?void 0:t.every((e=>{var t;return null===(t=n.getField(e))||void 0===t?void 0:t.visible}))})).forEach((e=>{var t;e.type===p.SEARCHING&&(null===(t=e.masterFields)||void 0===t?void 0:t.length)>0&&(f={expression:e.expression,params:e.masterFields.map((e=>{const t=n.getField(e),i=(null==t?void 0:t.dataType)||o.TEXT,r=n.getFieldValue(e);if(null==r)throw this.alert("Erro ao pesquisar",`É necessario informar o campo ${t.label} para executar a pesquisa.`),new Error(`É necessario informar o campo ${t.label} para executar a pesquisa.`);return{name:e,value:r,dataType:i}}))})})),"ADVANCED"===t?new Promise((e=>{const t=document.createElement("snk-pesquisa");t.argument=r,t.searchLoader=e=>this.pesquisaFetcher.loadAdvancedSearch(s,e,f,d),t.selectItem=t=>{e(t),this.clearPopUpTitle(),this.closePopUp()},this.setPopUpTitle(h),this.showPopUp(t)})):this.pesquisaFetcher.loadSearchOptions(s,r,f,d)}}async isDebugMode(){return new Promise((e=>{e(window.isDebugMode)}))}clearPopUpContent(){this._popUp&&Array.from(this._popUp.children).forEach((e=>{this._popUp.removeChild(e)}))}clearPopUpTitle(){this._popUp.ezTitle=""}setPopUpTitle(e){this._popUp.ezTitle=e}componentWillLoad(){this._errorHandler=new me(this),f.setContextValue("__EZUI__UPLOAD__ADD__URL__",`${Z.getUrlBase()}/mge/upload/file`),f.setContextValue("__EZUI__SEARCH__OPTION__LOADER__",((e,t,n)=>this.executeSearch(e,t,n))),f.setContextValue("__EZUI__GRID_LICENSE__",ge),d.init()}connectedCallback(){ee.addRequestListener(this._requestListener)}disconnectedCallback(){ee.removeRequestListener(this._requestListener)}componentDidLoad(){this.applicationLoading.emit(!0),window.requestAnimationFrame((()=>{this.applicationLoaded.emit(!0)}))}render(){return n("div",null,n("ez-loading-bar",{ref:e=>this._requestListener.loadingBar=e}),n("ez-popup",{opened:!1,ref:e=>this._popUp=e,onEzClosePopup:()=>this.closePopUp()}))}};class Se{constructor(){this._debounceTime=1e3,this._countRequest=0}onRequestStart(){this.loadingBar.show(),this._countRequest++,this._timerLoading&&clearTimeout(this._timerLoading)}onRequestEnd(){this._countRequest--,this._timerLoading=setTimeout((()=>{this._countRequest<=0&&this.loadingBar.hide()}),this._debounceTime)}}Oe.style=".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";export{Oe as snk_application}
69
+ }`)}loadSearchOptions(e,t,n,i){const r=(null==t?void 0:t.trim())||void 0;return t=isNaN(Number(r))&&r?`%${r}`:r,new Promise(((r,s)=>{ee.get().callGraphQL({values:{argument:t,entityName:e,criteria:n,options:i},query:this._templateByQuery.get("search")}).then((e=>{r(e)})).catch((e=>{s(e)}))}))}loadAdvancedSearch(e,t,n,i){const r={query:{$:null==n?void 0:n.expression}};(null==n?void 0:n.params.length)>0&&(r.params={param:n.params.map((e=>({$:e.value,type:ce(e.dataType)})))});const s={serviceName:"PesquisaSP.getSuggestion",requestBody:{criteria:{entityName:e,compacted:!1,ignoreEntityCriteria:!1,limit:this._defaultPageSize,query:{$:t},orderByDesc:!1,externalCriteria:r,localEntityName:null==i?void 0:i.rootEntity},clientEventList:{clientEvent:[]}}};return new Promise(((e,t)=>{ee.get().callServiceBroker("PesquisaSP.getSuggestion",JSON.stringify(s)).then((t=>e(t))).catch((e=>t(e)))}))}}function ce(e){switch(e){case o.NUMBER:return"I";case o.DATE:return"D";default:return"S"}}class he extends se{getData(e){const t=`cfg://auth/${e}`;return new Promise(((e,n)=>{this.loadResource(t).then((t=>{let n=c.stringToObject(t);n&&"object"==typeof n&&e(n)})).catch((e=>{n(e)}))}))}}!function(e){e.INSERT="I",e.UPDATE="A",e.REMOVE="E",e.SHOW="C",e.CONFIG="F",e.CONFIG_NUMBER="N",e.CLONE="D",e.CONFIG_GRID="G"}(w||(w={}));const le=fe;function fe(e,t){const n=de();return(fe=function(e){return n[e-=378]})(e,t)}function de(){const e=["true","863GKWjmo","parse","56355fjjjAm","isSup","putAccess","4324480sjuCdS","hasOwnProperty","239748okvJLB","name","6055770tXeRaU","actions","forEach","7RPRvzn","1042CHxkUw","2988126NIwRMm","20MTNzmH","authorizationSf","item","string","hasAccess","isArray","Objeto não pode ser indefinido.","3071943fWslZp","parseFromJSON"];return(de=function(){return e})()}!function(){const e=fe,t=de();for(;;)try{if(281287==parseInt(e(399))/1*(-parseInt(e(387))/2)+-parseInt(e(401))/3+parseInt(e(381))/4*(-parseInt(e(389))/5)+parseInt(e(388))/6*(-parseInt(e(386))/7)+parseInt(e(379))/8+parseInt(e(396))/9+parseInt(e(383))/10)break;t.push(t.shift())}catch(e){t.push(t.shift())}}();class ve{[le(397)](e){const t=le;if(typeof(e=utxt(e[t(390)]))==t(392)&&(e=JSON[t(400)](e)),null==e)throw Error(t(395));const n=new pe("S"===e[t(402)]||!0===e[t(402)]);return Array[t(394)](e[t(391)])&&e[t(391)][t(385)]((e=>n.putAccess(e[t(382)],String(e.status)==t(398)))),n}}class pe{constructor(e){const t=le;this.isSup=e,this[t(384)]={}}[le(378)](e,t){this[le(384)][e]=t}[le(393)](e){const t=le;if(this[t(402)])return!0;let n=!0;return this[t(384)][t(380)](e)&&(n=this.actions[e]),n}isUserSup(){return this.isSup}}class me{constructor(e){this._app=e,window.addEventListener("error",(e=>this.errorHandler(e))),window.addEventListener("unhandledrejection",(e=>this.rejectionHandler(e)))}rejectionHandler(e){const t=e.reason;t instanceof h||(t?this.processException(t):this._app.isDebugMode().then((e=>{e&&this._app.error("Promise rejeitada","Erro interno: Uma promise foi rejeitada sem razão determinada.")})))}errorHandler(e){this.processException(e.error)}processException(e){e instanceof h||e instanceof l?this._app.alert(e.title,e.message):e instanceof i?this._app.error(e.title,e.message):this._app.isDebugMode().then((t=>{t&&(e instanceof Error?this._app.error(e.name,e.message):this._app.error((null==e?void 0:e.title)||"Erro detectado","string"==typeof e?e:e.message||`Erro interno "${e}"`))}))}}function ye(){const e=["2909523kXwted","CompanyName=Sankhya Jiva Tecnologia e Inovao Ltda,LicensedApplication=Sankhya Gestao,LicenseType=SingleApplication,LicensedConcurrentDeveloperCount=2,LicensedProductionInstancesCount=0,AssetReference=AG-019460,ExpiryDate=9_November_2022_[v2]_MTY2Nzk1MjAwMDAwMA==10487151e296ee4360f80961ca960869","1131048CARoeW","502909mLEPmu","447255iQEXuN","428UHbJwW","270AFTxAV","194369jhGqTI","1540nWuTrj","2044062GicUQI","30CkXPWg"];return(ye=function(){return e})()}const be=we;function we(e,t){const n=ye();return(we=function(e){return n[e-=392]})(e,t)}!function(){const e=we,t=ye();for(;;)try{if(951926==-parseInt(e(398))/1+-parseInt(e(393))/2+parseInt(e(395))/3+-parseInt(e(400))/4*(parseInt(e(392))/5)+-parseInt(e(401))/6*(-parseInt(e(402))/7)+parseInt(e(397))/8+-parseInt(e(399))/9*(-parseInt(e(394))/10))break;t.push(t.shift())}catch(e){t.push(t.shift())}}();const ge=be(396),Oe=class{constructor(n){e(this,n),this.applicationLoaded=t(this,"applicationLoaded",7),this.applicationLoading=t(this,"applicationLoading",7),this._requestListener=new Se}get parameters(){return this._parameters||(this._parameters=new re),this._parameters}get resourceID(){return this._resourceID||(this._resourceID=this.urlParams.get("workspaceResourceID")||this.urlParams.get("resourceID")||ie.resourceID||"unknown.resource.id"),this._resourceID}get auth(){return new Promise(((e,t)=>{this._auth?e(this._auth):this.authFetcher.getData(this._resourceID).then((t=>{this._auth=t,e(t)})).catch((e=>t(e)))}))}async isUserSup(){return new Promise(((e,t)=>{this.auth.then((n=>{this.getAuthList(n).then((t=>{e(t.isSup)})).catch((e=>t(e)))}))}))}async hasAccess(e){return new Promise(((t,n)=>{this.auth.then((i=>{this.getAuthList(i).then((n=>{t(n.isSup||n.actions[e])})).catch((e=>n(e)))}))}))}async getAllAccess(){return new Promise(((e,t)=>{this.auth.then((n=>{this.getAuthList(n).then((t=>{const n={};n.isSup=t.isSup,Object.entries(w).forEach((e=>{n[e[0]]=t.actions[e[1]]||!1})),e(n)})).catch((e=>t(e)))}))}))}async getAuthList(e){return await(new ve).parseFromJSON(e)}async getStringParam(e){return this.parameters.asString(e,this.resourceID)}async getIntParam(e){return this.parameters.asInteger(e,this.resourceID)}async getFloatParam(e){return this.parameters.asFloat(e,this.resourceID)}async getBooleanParam(e){return this.parameters.asBoolean(e,this.resourceID)}async getDateParam(e){return this.parameters.asDate(e,this.resourceID)}async showPopUp(e){this.clearPopUpContent(),this._popUp.appendChild(e),this._popUp.opened=!0}async closePopUp(){this.clearPopUpContent(),this._popUp.opened=!1}async temOpcional(e){const t=e.split(",");return new Promise(((e,n)=>{this.getAttributeFromHTMLWrapper("opc0009").then((i=>{"1"===i?e(!0):Promise.all(t.map((e=>this.getAttributeFromHTMLWrapper("opc"+e)))).then((t=>{e(t.includes("1"))})).catch((e=>{n(e)}))})).catch((e=>{n(e)}))}))}async getConfig(e){let t={serviceName:"SystemUtilsSP.getConf",requestBody:{config:{chave:e,tipo:"T"}}};return new Promise(((e,n)=>{ee.get().callServiceBroker("SystemUtilsSP.getConf",JSON.stringify(t)).then((t=>{var n;return e(null===(n=t.config)||void 0===n?void 0:n.data)})).catch((e=>n(e)))}))}async saveConfig(e,t){let n={serviceName:"SystemUtilsSP.saveConf",requestBody:{config:{chave:e,tipo:"T",data:t}}};return new Promise(((e,t)=>{ee.get().callServiceBroker("SystemUtilsSP.saveConf",JSON.stringify(n)).then((t=>e(t))).catch((e=>t(e)))}))}async getAttributeFromHTMLWrapper(e){return Promise.resolve(window[e])}async openApp(e,t){ie.openAppActivity(e,t)}async createDataunit(e){return new Promise((t=>{const n=this.dataUnitFetcher.getDataUnit(e,this.resourceID);n.loadMetadata().then((()=>t(n)))}))}async getResourceID(){return Promise.resolve(this.resourceID)}async alert(e,t,n,i){return v.alert(e,t,n,i)}async error(e,t,n,i){return v.error(e,t,n,i)}async confirm(e,t,n,i,r){return v.confirm(e,t,n,i,r)}async info(e,t){return v.info(e,t)}async loadFormConfig(e){return this.formConfigFetcher.loadFormConfig(e,this.resourceID)}async loadGridConfig(){return this.gridConfigFetcher.getConfig(this.resourceID)}async saveGridConfig(e){return this.gridConfigFetcher.saveConfig(e,this.resourceID)}get urlParams(){return this._urlParams||(this._urlParams=Z.getQueryParams(location.search)),this._urlParams}get dataUnitFetcher(){return this._dataUnitFetcher||(this._dataUnitFetcher=new ne),this._dataUnitFetcher}get formConfigFetcher(){return this._formConfigFetcher||(this._formConfigFetcher=new oe),this._formConfigFetcher}get gridConfigFetcher(){return this._gridConfigFetcher||(this._gridConfigFetcher=new ae),this._gridConfigFetcher}get pesquisaFetcher(){return this._pesquisaFetcher||(this._pesquisaFetcher=new ue),this._pesquisaFetcher}get authFetcher(){return this._authFetcher||(this._authFetcher=new he),this._authFetcher}async executeSearch(e,t,n){const i=null==n?void 0:n.getField(t);if(i){const{mode:t,argument:r}=e,{ENTITYNAME:s,CODEFIELD:a,DESCRIPTIONFIELD:u,ROOTENTITY:c,DESCRIPTIONENTITY:h}=i.properties,l=i.dependencies;let f;const d={rootEntity:c,descriptionFieldName:u,codeFieldName:a,showInactives:!1};return null==l||l.filter((e=>{var t;return null===(t=e.masterFields)||void 0===t?void 0:t.every((e=>{var t;return null===(t=n.getField(e))||void 0===t?void 0:t.visible}))})).forEach((e=>{var t;e.type===p.SEARCHING&&(null===(t=e.masterFields)||void 0===t?void 0:t.length)>0&&(f={expression:e.expression,params:e.masterFields.map((e=>{const t=n.getField(e),i=(null==t?void 0:t.dataType)||o.TEXT,r=n.getFieldValue(e);if(null==r)throw this.alert("Erro ao pesquisar",`É necessario informar o campo ${t.label} para executar a pesquisa.`),new Error(`É necessario informar o campo ${t.label} para executar a pesquisa.`);return{name:e,value:r,dataType:i}}))})})),"ADVANCED"===t?new Promise((e=>{const t=document.createElement("snk-pesquisa");t.argument=r,t.searchLoader=e=>this.pesquisaFetcher.loadAdvancedSearch(s,e,f,d),t.selectItem=t=>{e(t),this.clearPopUpTitle(),this.closePopUp()},this.setPopUpTitle(h),this.showPopUp(t)})):this.pesquisaFetcher.loadSearchOptions(s,r,f,d)}}async isDebugMode(){return new Promise((e=>{e(window.isDebugMode)}))}clearPopUpContent(){this._popUp&&Array.from(this._popUp.children).forEach((e=>{this._popUp.removeChild(e)}))}clearPopUpTitle(){this._popUp.ezTitle=""}setPopUpTitle(e){this._popUp.ezTitle=e}componentWillLoad(){this._errorHandler=new me(this),f.setContextValue("__EZUI__UPLOAD__ADD__URL__",`${Z.getUrlBase()}/mge/upload/file`),f.setContextValue("__EZUI__SEARCH__OPTION__LOADER__",((e,t,n)=>this.executeSearch(e,t,n))),f.setContextValue("__EZUI__GRID_LICENSE__",ge),d.init()}connectedCallback(){ee.addRequestListener(this._requestListener)}disconnectedCallback(){ee.removeRequestListener(this._requestListener)}componentDidLoad(){this.applicationLoading.emit(!0),window.requestAnimationFrame((()=>{this.applicationLoaded.emit(!0)}))}render(){return n("div",null,n("ez-loading-bar",{ref:e=>this._requestListener.loadingBar=e}),n("ez-popup",{opened:!1,ref:e=>this._popUp=e,onEzClosePopup:()=>this.closePopUp()}))}};class Se{constructor(){this._debounceTime=1e3,this._countRequest=0}onRequestStart(){this.loadingBar.show(),this._countRequest++,this._timerLoading&&clearTimeout(this._timerLoading)}onRequestEnd(){this._countRequest--,this._timerLoading=setTimeout((()=>{this._countRequest<=0&&this.loadingBar.hide()}),this._debounceTime)}}Oe.style=".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";export{Oe as snk_application}
@@ -1 +1 @@
1
- import{p as e,b as a}from"./p-edcb9d8e.js";(()=>{const a=import.meta.url,t={};return""!==a&&(t.resourcesUrl=new URL(".",a).href),e(t)})().then((e=>a([["p-49fdec1f",[[2,"snk-pesquisa",{searchLoader:[16],selectItem:[16],argument:[1025],_itemList:[32],_startLoading:[32]}]]],["p-9bc9abe0",[[2,"snk-application",{isUserSup:[64],hasAccess:[64],getAllAccess:[64],getStringParam:[64],getIntParam:[64],getFloatParam:[64],getBooleanParam:[64],getDateParam:[64],showPopUp:[64],closePopUp:[64],temOpcional:[64],getConfig:[64],saveConfig:[64],getAttributeFromHTMLWrapper:[64],openApp:[64],createDataunit:[64],getResourceID:[64],alert:[64],error:[64],confirm:[64],info:[64],loadFormConfig:[64],loadGridConfig:[64],saveGridConfig:[64],executeSearch:[64],isDebugMode:[64]}]]],["p-2a7b4cb3",[[1,"teste-pesquisa"]]]],e)));
1
+ import{p as e,b as a}from"./p-edcb9d8e.js";(()=>{const a=import.meta.url,t={};return""!==a&&(t.resourcesUrl=new URL(".",a).href),e(t)})().then((e=>a([["p-24238a55",[[2,"snk-pesquisa",{searchLoader:[16],selectItem:[16],argument:[1025],_itemList:[32],_startLoading:[32]}]]],["p-bd1b31db",[[2,"snk-application",{isUserSup:[64],hasAccess:[64],getAllAccess:[64],getStringParam:[64],getIntParam:[64],getFloatParam:[64],getBooleanParam:[64],getDateParam:[64],showPopUp:[64],closePopUp:[64],temOpcional:[64],getConfig:[64],saveConfig:[64],getAttributeFromHTMLWrapper:[64],openApp:[64],createDataunit:[64],getResourceID:[64],alert:[64],error:[64],confirm:[64],info:[64],loadFormConfig:[64],loadGridConfig:[64],saveGridConfig:[64],executeSearch:[64],isDebugMode:[64]}]]],["p-2a7b4cb3",[[1,"teste-pesquisa"]]]],e)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sankhyalabs/sankhyablocks",
3
- "version": "1.3.31",
3
+ "version": "1.3.32",
4
4
  "description": "Stencil Component Starter",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -1 +0,0 @@
1
- import{r as s,h as t,H as i}from"./p-edcb9d8e.js";import{ObjectUtils as e,StringUtils as r}from"@sankhyalabs/core";const a=class{constructor(t){s(this,t),this._mdByName={},this._startHighlightTag="<span class='card-item__highlight'>",this._endHighlightTag="</span>",this._specialCharsRegex=/[[.\-\$\+\*,_\&\(\)%\/\\#@!:\|\=\'\"]/gim,this._charsWithAccentuation="ÁÉÍÓÚ_ÃÕ_ÂÊÎÔÛ_ÀÈÌÒÙ_Ü_Ç_áéíóú_ãõ_âêîôû_àèìòù_ü_ç",this._charsWithoutAccentuation="AEIOU_AO_AEIOU_AEIOU_U_C_aeiou_ao_aeiou_aeiou_u_c",this._changeDeboucingTimeout=null,this._limitCharsToSearch=3,this._deboucingTime=450,this._startLoading=!1}observeArgument(){this._textInput&&(this._textInput.value=this.argument)}clearSearch(){this.argument="",this._itemList=void 0}buildDetails(s,t){let i={};for(let e=0;e<s.length;e++){const r=s[e],a=t[r.fieldName];i[r.description]=this.highlightValue(t.__matchFields,r.options&&r.options[a]||a,s,!0)}return i}buildFirstFields(s,t,i=6){return s&&Array.isArray(s)&&s.forEach((s=>{let i=this.removeReference(t,this._mdByName[s]);i&&t.unshift(i)})),t=t.slice(0,i)}doSearch(s){this.searchLoader&&"function"==typeof this.searchLoader&&(this._startLoading=!0,this.searchLoader(s).then((s=>{if(this._startLoading=!1,s){let t=(s=e.stringToObject(s.json.$)).descriptionField,i=s.pkField;if(t&&i){let e=[];s.data.forEach((r=>{var a;let n=this.filterFieldsMetadata(s,r),o=this.buildFirstFields(r.__matchFields,n),l={key:this.highlightValue(r.__matchFields,null===(a=r[i])||void 0===a?void 0:a.toString(),o,!0),title:this.highlightValue(r.__matchFields,r[t],o,!0),details:this.buildDetails(o,r)};e.push(l)})),this._itemList=e}}})).catch((s=>{this._startLoading=!1,this._itemList=[],console.warn(s)})))}filterFieldsMetadata(s,t){return s.fieldsMetadata.filter((i=>{let e=!r.isEmpty(t[i.fieldName])&&!1!==i.visible&&"B"!==i.type&&s.pkField!==i.fieldName&&s.descriptionField!==i.fieldName&&(i.isPrimaryKey||!i.isLinkField)&&!("S"===i.type&&"H"===i.presentationType);return e&&(this._mdByName[i.fieldName]=i),("string"!=typeof t[i.fieldName]||!(t[i.fieldName].indexOf("<img")>-1||t[i.fieldName].indexOf("<svg")>-1))&&e}))}removeAtIndex(s,t){if(t>=0&&t<s.length)return s.splice(t,1)[0]}removeReference(s,t){let i=this.indexOf(s,t);return this.removeAtIndex(s,i)}indexOf(s,t){let i=-1;return Array.isArray(s)&&this.find(s,((s,e)=>(i=e,this.equals(t,s)))),i}equals(s,t){return e.objectToString(s)===e.objectToString(t)}find(s,t){if(s)for(let i=0,e=s.length;i<e;i++)if(t(s[i],i,s))return s[i]}highlightValue(s,t,i,e){let r=this.replaceHtmlEntities(t);if(this.argument&&(e||this.isIn(s,i.fieldName))){const s=this.getArgumentNumber();let t=(isNaN(s)?this.argument:s.toString()).split(/%|,|\s+/),e=0,a=this.replaceAccentuatedChars(r);t.forEach((s=>{if(s){s=this.replaceAccentuatedChars(s);let t=this.getSpecialCharacters(s);null!=t&&t.length>0&&(s=this.removeSpecialCharacters(s)),(i.mask||"CGC_CPF"===i.uiType||"Phone"===i.uiType)&&(s=s.split("").join("\\.?\\-?\\/?\\(?\\)?"));let n=new RegExp(s,"ig");n.lastIndex=e;let o=n.exec(a);if(o&&o.length>0){e=o.index;let s=o[0].length,t=r.substring(e,e+s),i=(null==t?void 0:t.trim())?this._startHighlightTag+t+this._endHighlightTag:"",n=r.substring(0,e),l=r.substring(e+s);r=n+i+l,e+=i.length,a=this.replaceAccentuatedChars(r)}}}))}return r}replaceHtmlEntities(s){return null==s?s:String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}replaceAccentuatedChars(s){return null==s?s:this.replaceToSpace(s,["&amp;","&lt;","&gt;","&quot;"]).replace(/[^\w ]/g,(s=>{let t=this._charsWithAccentuation.indexOf(s);return t>-1&&(s=this._charsWithoutAccentuation.charAt(t)),s||""}))}replaceToSpace(s,t=[]){return null==s||t.forEach((t=>{const i=new RegExp(t,"g");let e="";for(let s=0;s<t.length;s++)e+=" ";s=String(s).replace(i,e)})),s}isIn(s,t){return this.indexOf(s,t)>-1}getSpecialCharacters(s){let t,i=[];for(;t=this._specialCharsRegex.exec(s);)i.push(s[t.index]);return i}removeSpecialCharacters(s){return this.getSpecialCharacters(s).forEach((t=>{s=this.replaceAll(s,t,"")})),s}replaceAll(s,t,i){let e=(null!=s?s:"").indexOf(t);for(;e>-1;)e=(s=s.replace(t,i)).indexOf(t);return s}getArgumentNumber(){return Number(this.argument||void 0)}createOption(s){const{key:t,title:i}=s,e=new RegExp(this._startHighlightTag,"g"),r=new RegExp(this._endHighlightTag,"g"),a={value:null==t?void 0:t.replace(e,"").replace(r,""),label:null==i?void 0:i.replace(e,"").replace(r,"")};this.selectItem(a)}onChangeValue(s){if(this.clearDeboucingTimeout(),this._startLoading)return void(this._changeDeboucingTimeout=setTimeout((()=>{this.onChangeValue(s)}),this._deboucingTime));this.argument=(s.detail||"").trim();const t=this.getArgumentNumber();this.argument&&(!isNaN(t)||this.argument.length>=this._limitCharsToSearch)?this._changeDeboucingTimeout=setTimeout((()=>{this.doSearch(isNaN(t)?this.argument:t.toString())}),this._deboucingTime):this._itemList=void 0}clearDeboucingTimeout(){this._changeDeboucingTimeout&&(clearTimeout(this._changeDeboucingTimeout),this._changeDeboucingTimeout=void 0)}onClickSearch(){this.doSearch((this.argument||"").trim())}getMessageView(){return this._startLoading?"Aguarde, buscando registros...":this._itemList?this._itemList.length>=1?`${this._itemList.length} ${this._itemList.length>1?"registros encontrados":"registro encontrado"}`:"Nenhum registro encontrado":"Os resultados de sua pesquisa aparecerão aqui..."}render(){return t(i,null,t("div",{class:"snk-pesquisa"},t("div",{class:"snk-pesquisa__input"},t("ez-text-input",{label:"Buscar",class:"ez-margin-right--medium",canShowError:!1,ref:s=>this._textInput=s,onEzChange:s=>this.onChangeValue(s),value:this.argument},t("ez-icon",{slot:"leftIcon",iconName:"search"}),t("ez-icon",{class:"snk-pesquisa__input-close",slot:"rightIcon",iconName:"close",onClick:()=>{this.clearSearch()}})),t("ez-button",{class:"ez-button--primary",label:"Pesquisar",onClick:()=>this.onClickSearch()})),t("label",{class:"snk-pesquisa__records"},this.getMessageView()),t("div",{class:"snk-pesquisa__content"},this._itemList&&this._itemList.map((s=>t("ez-card-item",{onEzClick:s=>this.createOption(s.detail),item:s}))))))}static get watchers(){return{argument:["observeArgument"]}}};a.style=".sc-snk-pesquisa-h{--snk-pesquisa--font-size:var(--text--medium, 14px);--snk-pesquisa--font-family:var(--font-pattern, Arial);--snk-pesquisa--font-weight:var(--text-weight--medium, 400);--snk-pesquisa__records--color:var(--text--primary, #626e82);--snk-pesquisa__records--padding-vertical:var(--space--medium, 12px);--snk-pesquisa__content--padding-right:var(--space--small, 6px);--snk-pesquisa__content-scrollbar--background-color:var(--text--primary, #626e82);--snk-pesquisa__content-scrollbar--border-radius:var(--border--radius-small, 6px);--snk-pesquisa__content-scrollbar--width:var(--space--medium, 12px);max-height:100%;height:100%;display:flex;flex-direction:column;overflow-y:auto}.snk-pesquisa.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%}.snk-pesquisa__input.sc-snk-pesquisa{display:flex;width:100%;box-sizing:border-box;padding-top:4px;padding-right:4px}.snk-pesquisa__input-close.sc-snk-pesquisa{cursor:pointer}.snk-pesquisa__content.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%;overflow-y:auto;padding-right:var(--snk-pesquisa__content--padding-right)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-track{background-color:#f0f2f5;border-radius:var(--snk-pesquisa__content-scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb{background-color:var(--snk-pesquisa__content-scrollbar--background-color);border-radius:var(--snk-pesquisa__content-scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar{background-color:#f0f2f5;width:var(--snk-pesquisa__content-scrollbar--width);max-width:var(--snk-pesquisa__content-scrollbar--width);min-width:var(--snk-pesquisa__content-scrollbar--width)}.snk-pesquisa__records.sc-snk-pesquisa{font-family:var(--snk-pesquisa--font-family);font-weight:var(--snk-pesquisa--font-weight);font-size:var(--snk-pesquisa--font-size);color:var(--snk-pesquisa__records--color);padding-bottom:var(--snk-pesquisa__records--padding-vertical);padding-top:var(--snk-pesquisa__records--padding-vertical)}";export{a as snk_pesquisa}