@sankhyalabs/sankhyablocks 2.0.1 → 2.1.0

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.
@@ -185,8 +185,12 @@ const SnkConfigOptions = class {
185
185
  const { config, descriptor } = field;
186
186
  const { name, label, readOnly, required, defaultValue } = config;
187
187
  const { userInterface, properties } = descriptor;
188
- const enabled = (properties === null || properties === void 0 ? void 0 : properties.allowDefault) != undefined ? properties.allowDefault === "true" : !readOnly;
188
+ const allowDefault = properties === null || properties === void 0 ? void 0 : properties.allowDefault;
189
189
  let value;
190
+ let enabled = core.StringUtils.getBooleanValue(allowDefault, !readOnly);
191
+ if (userInterface === core.UserInterface.FILE) {
192
+ enabled = false;
193
+ }
190
194
  if (enabled) {
191
195
  value = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.value;
192
196
  if (value != undefined) {
@@ -1,5 +1,5 @@
1
1
  import { h, Host } from "@stencil/core";
2
- import { ApplicationContext, UserInterface, ObjectUtils } from '@sankhyalabs/core';
2
+ import { ApplicationContext, UserInterface, ObjectUtils, StringUtils } from '@sankhyalabs/core';
3
3
  import { DataType, getConvertedValue } from "@sankhyalabs/core/dist/dataunit/metadata/DataType";
4
4
  import { CheckMode } from "@sankhyalabs/ezui/dist/collection/utils";
5
5
  import { DEFAULT_TYPE, TAGS_BY_TYPE, VARS_BY_TYPE } from "../../../../lib/utils/constants";
@@ -176,8 +176,12 @@ export class SnkConfigOptions {
176
176
  const { config, descriptor } = field;
177
177
  const { name, label, readOnly, required, defaultValue } = config;
178
178
  const { userInterface, properties } = descriptor;
179
- const enabled = (properties === null || properties === void 0 ? void 0 : properties.allowDefault) != undefined ? properties.allowDefault === "true" : !readOnly;
179
+ const allowDefault = properties === null || properties === void 0 ? void 0 : properties.allowDefault;
180
180
  let value;
181
+ let enabled = StringUtils.getBooleanValue(allowDefault, !readOnly);
182
+ if (userInterface === UserInterface.FILE) {
183
+ enabled = false;
184
+ }
181
185
  if (enabled) {
182
186
  value = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.value;
183
187
  if (value != undefined) {
@@ -0,0 +1,66 @@
1
+ import { ApplicationContext } from "@sankhyalabs/core";
2
+ import { FormConfigFetcher } from "../http/data-fetcher/fetchers/form-config-fetcher";
3
+ import GridConfigFetcher from "../http/data-fetcher/fetchers/grid-config-fetcher";
4
+ const CONFIG_SOURCE = {
5
+ form: "form",
6
+ grid: "grid"
7
+ };
8
+ export class ConfigStorage {
9
+ static get() {
10
+ if (!ConfigStorage.instance) {
11
+ const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
12
+ if (application != undefined) {
13
+ ConfigStorage.instance = new ConfigStorage();
14
+ application.getResourceID().then((resourceID) => {
15
+ const configName = application.configName;
16
+ ConfigStorage.resourceID = resourceID;
17
+ ConfigStorage.loadFormConfig(configName);
18
+ ConfigStorage.loadGridConfig(configName);
19
+ });
20
+ }
21
+ }
22
+ return this.instance;
23
+ }
24
+ static async loadFormConfig(name) {
25
+ if (name == undefined) {
26
+ return;
27
+ }
28
+ const cacheID = this.getCacheID(name, CONFIG_SOURCE.form);
29
+ if (!this.configById.has(cacheID)) {
30
+ this.configById.set(cacheID, this.formConfigFetcher.loadFormConfig(name, this.resourceID));
31
+ }
32
+ return this.configById.get(cacheID);
33
+ }
34
+ static async loadGridConfig(name) {
35
+ if (name == undefined) {
36
+ return;
37
+ }
38
+ const cacheID = this.getCacheID(name, CONFIG_SOURCE.grid);
39
+ if (!this.configById.has(cacheID)) {
40
+ this.configById.set(cacheID, this.gridConfigFetcher.getConfig(name, this.resourceID));
41
+ }
42
+ return this.configById.get(cacheID);
43
+ }
44
+ static async saveFormConfig(config, name) {
45
+ if (config == undefined || name == undefined) {
46
+ return;
47
+ }
48
+ const cacheID = this.getCacheID(name, CONFIG_SOURCE.form);
49
+ this.configById.delete(cacheID);
50
+ return this.formConfigFetcher.saveConfig(config, name, this.resourceID);
51
+ }
52
+ static async saveGridConfig(config, name) {
53
+ if (config == undefined || name == undefined) {
54
+ return;
55
+ }
56
+ const cacheID = this.getCacheID(name, CONFIG_SOURCE.grid);
57
+ this.configById.delete(cacheID);
58
+ return this.gridConfigFetcher.saveConfig(config, this.resourceID);
59
+ }
60
+ static getCacheID(name, source) {
61
+ return `req_${source}_${name}_${this.resourceID}`;
62
+ }
63
+ }
64
+ ConfigStorage.configById = new Map();
65
+ ConfigStorage.formConfigFetcher = new FormConfigFetcher();
66
+ ConfigStorage.gridConfigFetcher = new GridConfigFetcher();
@@ -1,5 +1,5 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
- import { UserInterface, ObjectUtils, ApplicationContext } from '@sankhyalabs/core';
2
+ import { UserInterface, ObjectUtils, StringUtils, ApplicationContext } from '@sankhyalabs/core';
3
3
  import { DataType, getConvertedValue } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
4
4
  import { CheckMode } from '@sankhyalabs/ezui/dist/collection/utils';
5
5
  import { a as VARS_BY_TYPE, D as DEFAULT_TYPE, T as TAGS_BY_TYPE } from './constants.js';
@@ -182,8 +182,12 @@ const SnkConfigOptions = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
182
182
  const { config, descriptor } = field;
183
183
  const { name, label, readOnly, required, defaultValue } = config;
184
184
  const { userInterface, properties } = descriptor;
185
- const enabled = (properties === null || properties === void 0 ? void 0 : properties.allowDefault) != undefined ? properties.allowDefault === "true" : !readOnly;
185
+ const allowDefault = properties === null || properties === void 0 ? void 0 : properties.allowDefault;
186
186
  let value;
187
+ let enabled = StringUtils.getBooleanValue(allowDefault, !readOnly);
188
+ if (userInterface === UserInterface.FILE) {
189
+ enabled = false;
190
+ }
187
191
  if (enabled) {
188
192
  value = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.value;
189
193
  if (value != undefined) {
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-e4121713.js';
2
- import { UserInterface, ObjectUtils, ApplicationContext } from '@sankhyalabs/core';
2
+ import { UserInterface, ObjectUtils, StringUtils, ApplicationContext } from '@sankhyalabs/core';
3
3
  import { DataType, getConvertedValue } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
4
4
  import { CheckMode } from '@sankhyalabs/ezui/dist/collection/utils';
5
5
  import { V as VARS_BY_TYPE, D as DEFAULT_TYPE, a as TAGS_BY_TYPE } from './constants-c6039d3d.js';
@@ -181,8 +181,12 @@ const SnkConfigOptions = class {
181
181
  const { config, descriptor } = field;
182
182
  const { name, label, readOnly, required, defaultValue } = config;
183
183
  const { userInterface, properties } = descriptor;
184
- const enabled = (properties === null || properties === void 0 ? void 0 : properties.allowDefault) != undefined ? properties.allowDefault === "true" : !readOnly;
184
+ const allowDefault = properties === null || properties === void 0 ? void 0 : properties.allowDefault;
185
185
  let value;
186
+ let enabled = StringUtils.getBooleanValue(allowDefault, !readOnly);
187
+ if (userInterface === UserInterface.FILE) {
188
+ enabled = false;
189
+ }
186
190
  if (enabled) {
187
191
  value = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.value;
188
192
  if (value != undefined) {
@@ -0,0 +1 @@
1
+ import{r as i,c as e,h as t,H as l,g as s}from"./p-9ba3df4c.js";import{UserInterface as n,ObjectUtils as o,StringUtils as a,ApplicationContext as r}from"@sankhyalabs/core";import{DataType as d,getConvertedValue as u}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{CheckMode as h}from"@sankhyalabs/ezui/dist/collection/utils";import{V as c,D as v,a as p}from"./p-a5b26df2.js";const b=class{constructor(t){i(this,t),this.configOptionsChanged=e(this,"configOptionsChanged",7),this.fieldConfig={}}onConfigDefault(i){null!=i&&(this._defaultType=i,this.fieldConfig.defaultValue={type:this._defaultType},this.configOptionsChanged.emit(this.fieldConfig))}buildOptions(){var i,e,t;const l=null===(t=null===(i=this.dataUnit)||void 0===i?void 0:i.getField(null===(e=this.fieldConfig)||void 0===e?void 0:e.name))||void 0===t?void 0:t.userInterface;return c.UserInterface[l]}enabledValueDefault(){var i,e,t;const l=null===(i=this.dataUnit)||void 0===i?void 0:i.getField(null===(e=this.fieldConfig)||void 0===e?void 0:e.name),s=null===(t=null==l?void 0:l.properties)||void 0===t?void 0:t.allowDefault,n=c.UserInterface.hasOwnProperty(null==l?void 0:l.userInterface);return!(null!=s&&"true"!==s||!n)}isAllowDefault(){var i,e;const t=null===(e=null===(i=this._fieldProperties)||void 0===i?void 0:i.properties)||void 0===e?void 0:e.allowDefault;return null==t||"true"===t}loadDefaultValue(){var i;null==this.fieldConfig?(this._defaultType=v.fixed,this.fieldConfig={defaultValue:{type:this._defaultType}}):null==(null===(i=this.fieldConfig.defaultValue)||void 0===i?void 0:i.type)?(this._defaultType=v.fixed,this.fieldConfig.defaultValue={type:this._defaultType}):this._defaultType=this.fieldConfig.defaultValue.type}getFieldProperties(i){var e;if(null!=i)return null===(e=this.dataUnit)||void 0===e?void 0:e.getField(i)}getMessage(i,e){return this._application.messagesBuilder.getMessage(i,e)}getDefaultType(){var i;return null!==(i=this.fieldConfig.defaultValue.type)&&void 0!==i?i:v.fixed}getEnabledByProperty(i){const e=this._fieldProperties;return null==e||!0!==e[i]}getValueByProperty(i){const e=this._fieldProperties;return null!=e&&!0===e[i]||this.fieldConfig[i]}getValidatedValue(i){var e,t;if(null==i)return;const l=null===(e=this.dataUnit)||void 0===e?void 0:e.getField(null===(t=this.fieldConfig)||void 0===t?void 0:t.name),s=null==l?void 0:l.dataType;if(null==s)return;const n=null!=(null==i?void 0:i.waitmessage)?void 0:s!==d.OBJECT&&s!==d.DATE&&"object"==typeof i?i.value:i;return s===d.OBJECT?JSON.stringify(n):n}buildInputDefault({value:i,enabled:e,label:l,name:s,required:a,userInterface:r},d,u){let h,c=0,v=0;const b=null==r||null==p[r]?p.DEFAULT:p[r];if(r===n.OPTIONSELECTOR){const i=null==d?void 0:d.options;if("string"==typeof i){const e=o.stringToObject(i);h=Object.keys(e).map((i=>({value:i,label:e[i]})))}else h=i}else r===n.DECIMALNUMBER&&(c=Number((null==d?void 0:d.precision)||2),v=Number((null==d?void 0:d.prettyPrecision)||c));return t(b,Object.assign({value:i,enabled:e,label:l,"data-field-name":s,key:s,onEzChange:i=>this.onChange(null==i?void 0:i.detail)},this.getConditionalAttributes(r,a,h,c,v,u)))}getConditionalAttributes(i,e,t,l,s,o){switch(i){case n.SEARCH:return{suppressEmptyOption:e,optionLoader:i=>this.onSearch(i)};case n.OPTIONSELECTOR:return{suppressEmptyOption:e,options:t};case n.CHECKBOX:case n.SWITCH:return{mode:o};case n.INTEGERNUMBER:case n.DECIMALNUMBER:return{precision:l,prettyPrecision:s,onEzStartChange:i=>this.onChange(null==i?void 0:i.detail)};case n.DATE:case n.DATETIME:case n.TIME:return{onEzStartChange:i=>this.onChange(null==i?void 0:i.detail)};default:return{}}}onChange(i){this.fieldConfig.defaultValue.value=this.getValidatedValue(i),this.configOptionsChanged.emit(this.fieldConfig)}onSearch(i){if(null!=this._application&&null!=this.fieldConfig)return this._application.executeSearch(i,this.fieldConfig.name,this.dataUnit)}buildField(i){const{config:e,descriptor:t}=i,{name:l,label:s,readOnly:o,required:r,defaultValue:d}=e,{userInterface:c,properties:v}=t;let p,b=a.getBooleanValue(null==v?void 0:v.allowDefault,!o);c===n.FILE&&(b=!1),b&&(p=null==d?void 0:d.value,null!=p&&(p=u(null==t?void 0:t.dataType,p)));const f={value:p,enabled:b,label:s,name:l,required:r,userInterface:c};switch(c){case n.SWITCH:return this.buildInputDefault(f,void 0,h.SWITCH);case n.CHECKBOX:return this.buildInputDefault(f,void 0,h.REGULAR);case n.OPTIONSELECTOR:case n.DECIMALNUMBER:return this.buildInputDefault(f,v);default:return this.buildInputDefault(f)}}componentWillLoad(){var i;this.loadDefaultValue(),this._application=r.getContextValue("__SNK__APPLICATION__"),this._fieldProperties=this.getFieldProperties(null===(i=this.fieldConfig)||void 0===i?void 0:i.name)}render(){var i,e;return t(l,null,t("div",{id:this.idConfig},t("div",{class:"ez-row ez-padding--medium"},t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-text-input",{label:this.getMessage("snkConfigOptions.label.nameField"),value:null===(i=this.fieldConfig)||void 0===i?void 0:i.label,onEzChange:i=>{this.fieldConfig.label=i.detail,this.configOptionsChanged.emit(this.fieldConfig)}})),t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-combo-box",{label:this.getMessage("snkConfigOptions.label.typeValueDefault"),suppressEmptyOption:!0,enabled:this.enabledValueDefault(),onEzChange:i=>{var e;return this.onConfigDefault(null===(e=i.detail)||void 0===e?void 0:e.value)},value:this.getDefaultType()},t("option",{value:v.fixed},this.getMessage("snkConfigOptions.options.valueFixed")),t("option",{value:v.variable},this.getMessage("snkConfigOptions.options.variable")))),t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},this._defaultType===v.variable?t("ez-combo-box",{label:this.getMessage("snkConfigOptions.label.valueDefault"),enabled:this.isAllowDefault(),onEzChange:i=>{var e;this.fieldConfig.defaultValue.value=null===(e=i.detail)||void 0===e?void 0:e.value,this.configOptionsChanged.emit(this.fieldConfig)},value:this.fieldConfig.defaultValue.value,options:this.buildOptions()}):(null===(e=this._fieldProperties)||void 0===e?void 0:e.userInterface)&&this.buildField({descriptor:this._fieldProperties,config:this.fieldConfig}))),t("div",{class:"ez-row ez-padding--medium config-options__switch-row"},t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-check",{mode:h.SWITCH,label:this.getMessage("snkConfigOptions.label.clearDuplicate"),value:this.fieldConfig.cleanOnCopy,onEzChange:i=>{this.fieldConfig.cleanOnCopy=i.detail,this.configOptionsChanged.emit(this.fieldConfig)}})),t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-check",{mode:h.SWITCH,label:this.getMessage("snkConfigOptions.label.requiredField"),enabled:this.getEnabledByProperty("required"),value:this.getValueByProperty("required"),onEzChange:i=>{this.fieldConfig.required=i.detail,this.configOptionsChanged.emit(this.fieldConfig)}})),t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-check",{mode:h.SWITCH,label:this.getMessage("snkConfigOptions.label.protectedField"),enabled:this.getEnabledByProperty("readOnly"),value:this.getValueByProperty("readOnly"),onEzChange:i=>{this.fieldConfig.readOnly=i.detail,this.configOptionsChanged.emit(this.fieldConfig)}})))))}get _element(){return s(this)}};b.style=".sc-snk-config-options-h{width:100%;border:2px solid var(--color--secondary-200);border-radius:15px}.config-options__switch-row.sc-snk-config-options{margin-top:-30px}";export{b as snk_config_options}
@@ -1 +1 @@
1
- import{p as e,b as t}from"./p-9ba3df4c.js";(()=>{const t=import.meta.url,a={};return""!==t&&(a.resourcesUrl=new URL(".",t).href),e(a)})().then((e=>t([["p-44ce5b90",[[1,"teste-pesquisa"]]],["p-92782503",[[2,"snk-data-unit",{dataState:[1040],dataUnitName:[1,"data-unit-name"],entityName:[1,"entity-name"],pageSize:[2,"page-size"],dataUnit:[1040],beforeSave:[16],afterSave:[16],getDataUnit:[64]}]]],["p-9dc4426d",[[0,"snk-filter-binary-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-3a276f3d",[[0,"snk-filter-multi-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-cc4bef9f",[[0,"snk-filter-number",{config:[16],value:[2],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-029ae4e4",[[0,"snk-filter-period",{config:[16],value:[8],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-12ad2a19",[[0,"snk-filter-personalized",{config:[16],value:[1040],fix:[16],unfix:[16],show:[64]}]]],["p-2dc76d79",[[0,"snk-filter-search",{config:[16],value:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-e9beab79",[[0,"snk-filter-text",{config:[16],value:[1]},[[0,"ezChange","ezChangeListener"]]]]],["p-ac71ef38",[[2,"snk-pesquisa",{searchLoader:[16],selectItem:[16],argument:[1025],_itemList:[32],_startLoading:[32]}]]],["p-e871aa92",[[2,"snk-config-options",{fieldConfig:[16],idConfig:[513,"id-config"],dataUnit:[16],_defaultType:[32]}]]],["p-f37cdeb5",[[6,"snk-tab-config",{selectedIndex:[1538,"selected-index"],selectedTab:[1537,"selected-tab"],tabs:[1],_processedTabs:[32],_activeEditText:[32],_activeEditTextIndex:[32],_actionsHide:[32],_actionsShow:[32]}]]],["p-deb1f523",[[0,"snk-filter-detail",{config:[1040],getMessage:[16],show:[64]}]]],["p-eb23420d",[[6,"snk-grid",{configName:[1,"config-name"],actionsList:[16],taskbarManager:[16],statusResolver:[16],_dataUnit:[32],_dataState:[32],_gridConfig:[32],setShowGridConfig:[64],setConfig:[64]}],[2,"snk-field-config",{isConfigActive:[16],fieldConfig:[16],modeInsertion:[516,"mode-insertion"],dataUnit:[16]}]]],["p-626cf022",[[2,"snk-form-config",{dataUnit:[16],formConfig:[16],parentForm:[16],_formConfigOptions:[32],_fieldConfigSelected:[32],_layoutFormConfig:[32],_fieldsAvailable:[32],_formConfig:[32],_formConfigChanged:[32],_optionFormConfigSelected:[32],_optionFormConfigChanged:[32],_tempGroups:[32]}]]],["p-60eef7cd",[[2,"snk-config-modal",{configName:[1,"config-name"],gridMode:[4,"grid-mode"]}]]],["p-e8591491",[[2,"snk-filter-bar",{dataUnit:[1040],configName:[1,"config-name"],filterConfig:[1040],allowDefault:[32]},[[0,"filterChange","filterChangeListener"]]],[6,"snk-taskbar",{configName:[1,"config-name"],buttons:[1],customButtons:[16],actionsList:[16],primaryButton:[1,"primary-button"],disabledButtons:[16],dataUnit:[16],_permissions:[32]}],[0,"snk-filter-item",{config:[1040],getMessage:[16],detailIsVisible:[32],showUp:[64],hideDetail:[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]],[4,"snk-filter-list",{label:[1],iconName:[1,"icon-name"],items:[16],getMessage:[16],emptyText:[1,"empty-text"],findFilterText:[1,"find-filter-text"],buttonClass:[1,"button-class"],_filterArgument:[32],_showAll:[32],hideDetail:[64]},[[2,"keydown","keyDownHandler"]]],[0,"snk-filter-modal",{getMessage:[16],items:[1040],modalTitle:[1,"modal-title"],modalSubTitle:[1,"modal-sub-title"],cancelButtonLabel:[1,"cancel-button-label"],okButtonLabel:[1,"ok-button-label"],infoText:[1,"info-text"],useSearch:[4,"use-search"],processModalAction:[16],_filterArgument:[32]}],[2,"snk-configurator",{configName:[1,"config-name"],name:[1],enabled:[4]}]]],["p-2b891c4a",[[2,"snk-form",{configName:[1,"config-name"],recordsValidator:[16],actionsList:[16],taskbarManager:[16],_dataUnit:[32],_dataState:[32],_editionFormConfig:[32],_insertionFormConfig:[32],_showFormConfig:[32],setShowFormConfig:[64],setConfig:[64]}]]],["p-e128f747",[[6,"snk-crud",{configName:[1025,"config-name"],actionsList:[16],taskbarManager:[16],recordsValidator:[16],statusResolver:[16],_dataUnit:[32],_dataState:[32],goToView:[64]}]]],["p-4c887c1f",[[2,"snk-application",{messagesBuilder:[1040],configName:[1,"config-name"],isUserSup:[64],hasAccess:[64],getAllAccess:[64],getStringParam:[64],getIntParam:[64],getFloatParam:[64],getBooleanParam:[64],getDateParam:[64],showPopUp:[64],showModal:[64],closeModal:[64],closePopUp:[64],temOpcional:[64],getConfig:[64],saveConfig:[64],getAttributeFromHTMLWrapper:[64],openApp:[64],createDataunit:[64],getDataUnit:[64],getResourceID:[64],getUserID:[64],alert:[64],error:[64],success:[64],message:[64],confirm:[64],info:[64],loadFormConfig:[64],loadGridConfig:[64],fetchUserAvailableConfigs:[64],fetchLegacyConfig:[64],fetchDefaultConfig:[64],loadTotals:[64],saveGridConfig:[64],getFilterBarConfig:[64],saveFilterBarConfig:[64],saveFormConfig:[64],executeSearch:[64],executePreparedSearch:[64],isDebugMode:[64]}]]]],e)));
1
+ import{p as e,b as t}from"./p-9ba3df4c.js";(()=>{const t=import.meta.url,a={};return""!==t&&(a.resourcesUrl=new URL(".",t).href),e(a)})().then((e=>t([["p-44ce5b90",[[1,"teste-pesquisa"]]],["p-92782503",[[2,"snk-data-unit",{dataState:[1040],dataUnitName:[1,"data-unit-name"],entityName:[1,"entity-name"],pageSize:[2,"page-size"],dataUnit:[1040],beforeSave:[16],afterSave:[16],getDataUnit:[64]}]]],["p-9dc4426d",[[0,"snk-filter-binary-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-3a276f3d",[[0,"snk-filter-multi-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-cc4bef9f",[[0,"snk-filter-number",{config:[16],value:[2],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-029ae4e4",[[0,"snk-filter-period",{config:[16],value:[8],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-12ad2a19",[[0,"snk-filter-personalized",{config:[16],value:[1040],fix:[16],unfix:[16],show:[64]}]]],["p-2dc76d79",[[0,"snk-filter-search",{config:[16],value:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-e9beab79",[[0,"snk-filter-text",{config:[16],value:[1]},[[0,"ezChange","ezChangeListener"]]]]],["p-ac71ef38",[[2,"snk-pesquisa",{searchLoader:[16],selectItem:[16],argument:[1025],_itemList:[32],_startLoading:[32]}]]],["p-8706fe65",[[2,"snk-config-options",{fieldConfig:[16],idConfig:[513,"id-config"],dataUnit:[16],_defaultType:[32]}]]],["p-f37cdeb5",[[6,"snk-tab-config",{selectedIndex:[1538,"selected-index"],selectedTab:[1537,"selected-tab"],tabs:[1],_processedTabs:[32],_activeEditText:[32],_activeEditTextIndex:[32],_actionsHide:[32],_actionsShow:[32]}]]],["p-deb1f523",[[0,"snk-filter-detail",{config:[1040],getMessage:[16],show:[64]}]]],["p-eb23420d",[[6,"snk-grid",{configName:[1,"config-name"],actionsList:[16],taskbarManager:[16],statusResolver:[16],_dataUnit:[32],_dataState:[32],_gridConfig:[32],setShowGridConfig:[64],setConfig:[64]}],[2,"snk-field-config",{isConfigActive:[16],fieldConfig:[16],modeInsertion:[516,"mode-insertion"],dataUnit:[16]}]]],["p-626cf022",[[2,"snk-form-config",{dataUnit:[16],formConfig:[16],parentForm:[16],_formConfigOptions:[32],_fieldConfigSelected:[32],_layoutFormConfig:[32],_fieldsAvailable:[32],_formConfig:[32],_formConfigChanged:[32],_optionFormConfigSelected:[32],_optionFormConfigChanged:[32],_tempGroups:[32]}]]],["p-60eef7cd",[[2,"snk-config-modal",{configName:[1,"config-name"],gridMode:[4,"grid-mode"]}]]],["p-e8591491",[[2,"snk-filter-bar",{dataUnit:[1040],configName:[1,"config-name"],filterConfig:[1040],allowDefault:[32]},[[0,"filterChange","filterChangeListener"]]],[6,"snk-taskbar",{configName:[1,"config-name"],buttons:[1],customButtons:[16],actionsList:[16],primaryButton:[1,"primary-button"],disabledButtons:[16],dataUnit:[16],_permissions:[32]}],[0,"snk-filter-item",{config:[1040],getMessage:[16],detailIsVisible:[32],showUp:[64],hideDetail:[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]],[4,"snk-filter-list",{label:[1],iconName:[1,"icon-name"],items:[16],getMessage:[16],emptyText:[1,"empty-text"],findFilterText:[1,"find-filter-text"],buttonClass:[1,"button-class"],_filterArgument:[32],_showAll:[32],hideDetail:[64]},[[2,"keydown","keyDownHandler"]]],[0,"snk-filter-modal",{getMessage:[16],items:[1040],modalTitle:[1,"modal-title"],modalSubTitle:[1,"modal-sub-title"],cancelButtonLabel:[1,"cancel-button-label"],okButtonLabel:[1,"ok-button-label"],infoText:[1,"info-text"],useSearch:[4,"use-search"],processModalAction:[16],_filterArgument:[32]}],[2,"snk-configurator",{configName:[1,"config-name"],name:[1],enabled:[4]}]]],["p-2b891c4a",[[2,"snk-form",{configName:[1,"config-name"],recordsValidator:[16],actionsList:[16],taskbarManager:[16],_dataUnit:[32],_dataState:[32],_editionFormConfig:[32],_insertionFormConfig:[32],_showFormConfig:[32],setShowFormConfig:[64],setConfig:[64]}]]],["p-e128f747",[[6,"snk-crud",{configName:[1025,"config-name"],actionsList:[16],taskbarManager:[16],recordsValidator:[16],statusResolver:[16],_dataUnit:[32],_dataState:[32],goToView:[64]}]]],["p-4c887c1f",[[2,"snk-application",{messagesBuilder:[1040],configName:[1,"config-name"],isUserSup:[64],hasAccess:[64],getAllAccess:[64],getStringParam:[64],getIntParam:[64],getFloatParam:[64],getBooleanParam:[64],getDateParam:[64],showPopUp:[64],showModal:[64],closeModal:[64],closePopUp:[64],temOpcional:[64],getConfig:[64],saveConfig:[64],getAttributeFromHTMLWrapper:[64],openApp:[64],createDataunit:[64],getDataUnit:[64],getResourceID:[64],getUserID:[64],alert:[64],error:[64],success:[64],message:[64],confirm:[64],info:[64],loadFormConfig:[64],loadGridConfig:[64],fetchUserAvailableConfigs:[64],fetchLegacyConfig:[64],fetchDefaultConfig:[64],loadTotals:[64],saveGridConfig:[64],getFilterBarConfig:[64],saveFilterBarConfig:[64],saveFormConfig:[64],executeSearch:[64],executePreparedSearch:[64],isDebugMode:[64]}]]]],e)));
@@ -0,0 +1,15 @@
1
+ import { IFormConfig } from "@sankhyalabs/ezui/dist/types/components/ez-form/ez-form";
2
+ import { IGridConfig } from "@sankhyalabs/ezui/dist/types/components/ez-grid/controller/EzGridController";
3
+ export declare class ConfigStorage {
4
+ private static instance;
5
+ private static configById;
6
+ private static formConfigFetcher;
7
+ private static gridConfigFetcher;
8
+ private static resourceID;
9
+ static get(): ConfigStorage;
10
+ static loadFormConfig(name: string): Promise<IFormConfig>;
11
+ static loadGridConfig(name: string): Promise<IGridConfig>;
12
+ static saveFormConfig(config: IFormConfig, name: string): Promise<boolean>;
13
+ static saveGridConfig(config: IGridConfig, name: string): Promise<boolean>;
14
+ private static getCacheID;
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sankhyalabs/sankhyablocks",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
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 i,c as e,h as t,H as l,g as s}from"./p-9ba3df4c.js";import{UserInterface as n,ObjectUtils as o,ApplicationContext as a}from"@sankhyalabs/core";import{DataType as r,getConvertedValue as d}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{CheckMode as u}from"@sankhyalabs/ezui/dist/collection/utils";import{V as h,D as c,a as v}from"./p-a5b26df2.js";const p=class{constructor(t){i(this,t),this.configOptionsChanged=e(this,"configOptionsChanged",7),this.fieldConfig={}}onConfigDefault(i){null!=i&&(this._defaultType=i,this.fieldConfig.defaultValue={type:this._defaultType},this.configOptionsChanged.emit(this.fieldConfig))}buildOptions(){var i,e,t;const l=null===(t=null===(i=this.dataUnit)||void 0===i?void 0:i.getField(null===(e=this.fieldConfig)||void 0===e?void 0:e.name))||void 0===t?void 0:t.userInterface;return h.UserInterface[l]}enabledValueDefault(){var i,e,t;const l=null===(i=this.dataUnit)||void 0===i?void 0:i.getField(null===(e=this.fieldConfig)||void 0===e?void 0:e.name),s=null===(t=null==l?void 0:l.properties)||void 0===t?void 0:t.allowDefault,n=h.UserInterface.hasOwnProperty(null==l?void 0:l.userInterface);return!(null!=s&&"true"!==s||!n)}isAllowDefault(){var i,e;const t=null===(e=null===(i=this._fieldProperties)||void 0===i?void 0:i.properties)||void 0===e?void 0:e.allowDefault;return null==t||"true"===t}loadDefaultValue(){var i;null==this.fieldConfig?(this._defaultType=c.fixed,this.fieldConfig={defaultValue:{type:this._defaultType}}):null==(null===(i=this.fieldConfig.defaultValue)||void 0===i?void 0:i.type)?(this._defaultType=c.fixed,this.fieldConfig.defaultValue={type:this._defaultType}):this._defaultType=this.fieldConfig.defaultValue.type}getFieldProperties(i){var e;if(null!=i)return null===(e=this.dataUnit)||void 0===e?void 0:e.getField(i)}getMessage(i,e){return this._application.messagesBuilder.getMessage(i,e)}getDefaultType(){var i;return null!==(i=this.fieldConfig.defaultValue.type)&&void 0!==i?i:c.fixed}getEnabledByProperty(i){const e=this._fieldProperties;return null==e||!0!==e[i]}getValueByProperty(i){const e=this._fieldProperties;return null!=e&&!0===e[i]||this.fieldConfig[i]}getValidatedValue(i){var e,t;if(null==i)return;const l=null===(e=this.dataUnit)||void 0===e?void 0:e.getField(null===(t=this.fieldConfig)||void 0===t?void 0:t.name),s=null==l?void 0:l.dataType;if(null==s)return;const n=null!=(null==i?void 0:i.waitmessage)?void 0:s!==r.OBJECT&&s!==r.DATE&&"object"==typeof i?i.value:i;return s===r.OBJECT?JSON.stringify(n):n}buildInputDefault({value:i,enabled:e,label:l,name:s,required:a,userInterface:r},d,u){let h,c=0,p=0;const b=null==r||null==v[r]?v.DEFAULT:v[r];if(r===n.OPTIONSELECTOR){const i=null==d?void 0:d.options;if("string"==typeof i){const e=o.stringToObject(i);h=Object.keys(e).map((i=>({value:i,label:e[i]})))}else h=i}else r===n.DECIMALNUMBER&&(c=Number((null==d?void 0:d.precision)||2),p=Number((null==d?void 0:d.prettyPrecision)||c));return t(b,Object.assign({value:i,enabled:e,label:l,"data-field-name":s,key:s,onEzChange:i=>this.onChange(null==i?void 0:i.detail)},this.getConditionalAttributes(r,a,h,c,p,u)))}getConditionalAttributes(i,e,t,l,s,o){switch(i){case n.SEARCH:return{suppressEmptyOption:e,optionLoader:i=>this.onSearch(i)};case n.OPTIONSELECTOR:return{suppressEmptyOption:e,options:t};case n.CHECKBOX:case n.SWITCH:return{mode:o};case n.INTEGERNUMBER:case n.DECIMALNUMBER:return{precision:l,prettyPrecision:s,onEzStartChange:i=>this.onChange(null==i?void 0:i.detail)};case n.DATE:case n.DATETIME:case n.TIME:return{onEzStartChange:i=>this.onChange(null==i?void 0:i.detail)};default:return{}}}onChange(i){this.fieldConfig.defaultValue.value=this.getValidatedValue(i),this.configOptionsChanged.emit(this.fieldConfig)}onSearch(i){if(null!=this._application&&null!=this.fieldConfig)return this._application.executeSearch(i,this.fieldConfig.name,this.dataUnit)}buildField(i){const{config:e,descriptor:t}=i,{name:l,label:s,readOnly:o,required:a,defaultValue:r}=e,{userInterface:h,properties:c}=t,v=null!=(null==c?void 0:c.allowDefault)?"true"===c.allowDefault:!o;let p;v&&(p=null==r?void 0:r.value,null!=p&&(p=d(null==t?void 0:t.dataType,p)));const b={value:p,enabled:v,label:s,name:l,required:a,userInterface:h};switch(h){case n.SWITCH:return this.buildInputDefault(b,void 0,u.SWITCH);case n.CHECKBOX:return this.buildInputDefault(b,void 0,u.REGULAR);case n.OPTIONSELECTOR:case n.DECIMALNUMBER:return this.buildInputDefault(b,c);default:return this.buildInputDefault(b)}}componentWillLoad(){var i;this.loadDefaultValue(),this._application=a.getContextValue("__SNK__APPLICATION__"),this._fieldProperties=this.getFieldProperties(null===(i=this.fieldConfig)||void 0===i?void 0:i.name)}render(){var i,e;return t(l,null,t("div",{id:this.idConfig},t("div",{class:"ez-row ez-padding--medium"},t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-text-input",{label:this.getMessage("snkConfigOptions.label.nameField"),value:null===(i=this.fieldConfig)||void 0===i?void 0:i.label,onEzChange:i=>{this.fieldConfig.label=i.detail,this.configOptionsChanged.emit(this.fieldConfig)}})),t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-combo-box",{label:this.getMessage("snkConfigOptions.label.typeValueDefault"),suppressEmptyOption:!0,enabled:this.enabledValueDefault(),onEzChange:i=>{var e;return this.onConfigDefault(null===(e=i.detail)||void 0===e?void 0:e.value)},value:this.getDefaultType()},t("option",{value:c.fixed},this.getMessage("snkConfigOptions.options.valueFixed")),t("option",{value:c.variable},this.getMessage("snkConfigOptions.options.variable")))),t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},this._defaultType===c.variable?t("ez-combo-box",{label:this.getMessage("snkConfigOptions.label.valueDefault"),enabled:this.isAllowDefault(),onEzChange:i=>{var e;this.fieldConfig.defaultValue.value=null===(e=i.detail)||void 0===e?void 0:e.value,this.configOptionsChanged.emit(this.fieldConfig)},value:this.fieldConfig.defaultValue.value,options:this.buildOptions()}):(null===(e=this._fieldProperties)||void 0===e?void 0:e.userInterface)&&this.buildField({descriptor:this._fieldProperties,config:this.fieldConfig}))),t("div",{class:"ez-row ez-padding--medium config-options__switch-row"},t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-check",{mode:u.SWITCH,label:this.getMessage("snkConfigOptions.label.clearDuplicate"),value:this.fieldConfig.cleanOnCopy,onEzChange:i=>{this.fieldConfig.cleanOnCopy=i.detail,this.configOptionsChanged.emit(this.fieldConfig)}})),t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-check",{mode:u.SWITCH,label:this.getMessage("snkConfigOptions.label.requiredField"),enabled:this.getEnabledByProperty("required"),value:this.getValueByProperty("required"),onEzChange:i=>{this.fieldConfig.required=i.detail,this.configOptionsChanged.emit(this.fieldConfig)}})),t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-check",{mode:u.SWITCH,label:this.getMessage("snkConfigOptions.label.protectedField"),enabled:this.getEnabledByProperty("readOnly"),value:this.getValueByProperty("readOnly"),onEzChange:i=>{this.fieldConfig.readOnly=i.detail,this.configOptionsChanged.emit(this.fieldConfig)}})))))}get _element(){return s(this)}};p.style=".sc-snk-config-options-h{width:100%;border:2px solid var(--color--secondary-200);border-radius:15px}.config-options__switch-row.sc-snk-config-options{margin-top:-30px}";export{p as snk_config_options}