myio-js-library 0.1.564 → 0.1.565

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.
package/dist/index.cjs CHANGED
@@ -130,6 +130,7 @@ __export(src_exports, {
130
130
  DEFAULT_SIDEBAR_CONFIG: () => DEFAULT_SIDEBAR_CONFIG,
131
131
  DEFAULT_SOLENOID_SETTINGS: () => DEFAULT_SOLENOID_SETTINGS,
132
132
  DEFAULT_SOLENOID_STATE: () => DEFAULT_SOLENOID_STATE,
133
+ DEFAULT_STORE_SEGMENTS: () => DEFAULT_STORE_SEGMENTS,
133
134
  DEFAULT_SWITCH_SETTINGS: () => DEFAULT_SWITCH_SETTINGS,
134
135
  DEFAULT_SWITCH_STATE: () => DEFAULT_SWITCH_STATE,
135
136
  DEFAULT_TABS: () => DEFAULT_TABS,
@@ -922,7 +923,7 @@ module.exports = __toCommonJS(src_exports);
922
923
  // package.json
923
924
  var package_default = {
924
925
  name: "myio-js-library",
925
- version: "0.1.564",
926
+ version: "0.1.565",
926
927
  description: "A clean, standalone JS SDK for MYIO projects",
927
928
  license: "MIT",
928
929
  repository: "github:gh-myio/myio-js-library",
@@ -63935,6 +63936,171 @@ function createTicketsTab(config2) {
63935
63936
  return { destroy: () => tab.destroy() };
63936
63937
  }
63937
63938
 
63939
+ // src/components/premium-modals/settings/commercialCatalog.ts
63940
+ var DEFAULT_STORE_SEGMENTS = [
63941
+ {
63942
+ segment: "Conveni\xEAncia / Servi\xE7os",
63943
+ activities: [
63944
+ "Ag\xEAncias De Viagens",
63945
+ "Alimentos Especias",
63946
+ "Consertos",
63947
+ "Correio",
63948
+ "Educa\xE7\xE3o/Ensino",
63949
+ "Emp\xF3rios",
63950
+ "Farm\xE1cias E Drogarias",
63951
+ "Foto Revela\xE7\xE3o",
63952
+ "Lavanderia",
63953
+ "Lot\xE9rica",
63954
+ "Outros Servi\xE7os",
63955
+ "Pet Shop",
63956
+ "Servi\xE7os Automotivos",
63957
+ "Servi\xE7os Est\xE9ticos",
63958
+ "Servi\xE7os Financeiros",
63959
+ "Servi\xE7os Gr\xE1ficos",
63960
+ "Servi\xE7os M\xE9dicos(Cl\xEDnicas/Laborat\xF3rios)",
63961
+ "Servi\xE7os P\xFAblicos",
63962
+ "Tatuagem/Piercing",
63963
+ "Venda E Loca\xE7\xE3o De Ve\xEDculos"
63964
+ ]
63965
+ },
63966
+ {
63967
+ segment: "Entretenimento",
63968
+ activities: [
63969
+ "Arena Gamer",
63970
+ "Boliche",
63971
+ "Cinemas",
63972
+ "Outros(Museu,Espa\xE7o Cultural,Etc)",
63973
+ "Parques E Games"
63974
+ ]
63975
+ },
63976
+ {
63977
+ segment: "Lojas \xC2ncoras",
63978
+ activities: [
63979
+ "Academias",
63980
+ "Artigos Esportivos",
63981
+ "Centros Educacionais / Escolas / Faculdades / Universidades",
63982
+ "Constru\xE7\xE3o E Decora\xE7\xE3o",
63983
+ "Eletrodom\xE9sticos, Eletr\xF4nicos",
63984
+ "Hipermercado / Supermercado / Atacarejo",
63985
+ "Magazines E/Ou Utens\xEDlios Para O Lar E Conveni\xEAncia",
63986
+ "Moda",
63987
+ "Outros"
63988
+ ]
63989
+ },
63990
+ {
63991
+ segment: "Lojas Sat\xE9lites",
63992
+ activities: [
63993
+ "Acess\xF3rios",
63994
+ "Acess\xF3rios E Artigos Para Viagens",
63995
+ "Artigos Eletr\xF4nicos/Tecnologia Da Informa\xE7\xE3o(Ti)",
63996
+ "Brinquedos",
63997
+ "Caf\xE9s, Bares E Ch\xE1s",
63998
+ "Cal\xE7ados Esportivos",
63999
+ "Cal\xE7ados Feminimos",
64000
+ "Cal\xE7ados Geral",
64001
+ "Cal\xE7ados Infantis",
64002
+ "Cal\xE7ados Masculinos",
64003
+ "Cama/Mesa/Banho",
64004
+ "Colch\xF5es",
64005
+ "Docerias",
64006
+ "Fast-Food",
64007
+ "Livraria",
64008
+ "Moda Esportiva",
64009
+ "Moda Feminina",
64010
+ "Moda Geral",
64011
+ "Moda Infantil",
64012
+ "Moda \xCDntima E Roupas Para Dormir",
64013
+ "Moda Masculina",
64014
+ "Moda Praia",
64015
+ "Moda Unissex",
64016
+ "\xD3ticas",
64017
+ "Outros",
64018
+ "Perfumaria, Maquiagem E Cosm\xE9ticos",
64019
+ "Puericultura",
64020
+ "Relojoarias, Joalherias",
64021
+ "Restaurantes Com Servi\xE7os",
64022
+ "Restaurantes Sem Servi\xE7os",
64023
+ "Surfewear / Streetwear",
64024
+ "Telefonia Geral",
64025
+ "Utens\xEDlios P/ Lar, Acess\xF3rios P/ Decora\xE7\xE3o E Presentes"
64026
+ ]
64027
+ },
64028
+ {
64029
+ segment: "Mall E Merchandising",
64030
+ activities: [
64031
+ "Acess\xF3rios",
64032
+ "Alimenta\xE7\xE3o E Bebidas",
64033
+ "Antenas De Operadoras",
64034
+ "Artigos Esportivos",
64035
+ "Artigos Para O Lar",
64036
+ "Brinquedos",
64037
+ "Cal\xE7ados",
64038
+ "Conveni\xEAncia / Servi\xE7os",
64039
+ "Eletr\xF4nicos",
64040
+ "Eventos",
64041
+ "Geek",
64042
+ "Livraria",
64043
+ "M\xEDdia",
64044
+ "\xD3ticas",
64045
+ "Outros",
64046
+ "Papelaria",
64047
+ "Perfumaria, Maquiagem E Cosm\xE9ticos",
64048
+ "Relojoarias E Joalherias",
64049
+ "Telefonia E Acess\xF3rios",
64050
+ "Vending Machines",
64051
+ "Vestu\xE1rio"
64052
+ ]
64053
+ },
64054
+ {
64055
+ segment: "Megalojas",
64056
+ activities: [
64057
+ "Alimenta\xE7\xE3o E Bebidas",
64058
+ "Artigos Esportivos",
64059
+ "Brinquedos",
64060
+ "Centros Educacionais / Escolas / Faculdades / Universidades",
64061
+ "Constru\xE7\xE3o, Decora\xE7\xE3o",
64062
+ "Eletrodom\xE9sticos, Eletr\xF4nicos, Magazines E/Ou Utens. P/Lar",
64063
+ "Livrarias",
64064
+ "Magazines E/Ou Utens\xEDlios Para O Lar E Conveni\xEAncia",
64065
+ "Material De Escrit\xF3rio / Papelaria / Inform\xE1tica",
64066
+ "Moda",
64067
+ "Outros",
64068
+ "Puericultura"
64069
+ ]
64070
+ },
64071
+ {
64072
+ segment: "Semi-\xC2ncoras",
64073
+ activities: [
64074
+ "Academias",
64075
+ "Alimenta\xE7\xE3o E Bebidas",
64076
+ "Artigos Esportivos",
64077
+ "Brinquedos",
64078
+ "Centros Educacionais / Escolas / Faculdades / Universidades",
64079
+ "Eletrodom\xE9sticos, Eletr\xF4nicos, Magazines E/Ou Utens. P/Lar",
64080
+ "Livrarias",
64081
+ "Magazines E/Ou Utens\xEDlios Para O Lar E Conveni\xEAncia",
64082
+ "Material De Escrit\xF3rio / Papelaria / Inform\xE1tica",
64083
+ "Moda",
64084
+ "Outros"
64085
+ ]
64086
+ }
64087
+ ];
64088
+ async function loadStoreSegmentCatalog(source) {
64089
+ if (!source) return DEFAULT_STORE_SEGMENTS;
64090
+ try {
64091
+ const list = typeof source === "function" ? await source() : source;
64092
+ return Array.isArray(list) && list.length > 0 ? list : DEFAULT_STORE_SEGMENTS;
64093
+ } catch (err) {
64094
+ console.warn("[SettingsModal] segmentCatalog loader falhou \u2014 usando cat\xE1logo padr\xE3o:", err);
64095
+ return DEFAULT_STORE_SEGMENTS;
64096
+ }
64097
+ }
64098
+ function activitiesForSegment(catalog, segment, currentActivity) {
64099
+ const list = catalog.find((s) => s.segment === segment)?.activities ?? [];
64100
+ if (currentActivity && !list.includes(currentActivity)) return [...list, currentActivity];
64101
+ return list;
64102
+ }
64103
+
63938
64104
  // src/components/createInputDateRangePickerInsideDIV.ts
63939
64105
  var PREMIUM_STYLES = `
63940
64106
  .myio-daterange-wrapper {
@@ -64283,6 +64449,9 @@ var SettingsModalView = class _SettingsModalView {
64283
64449
  if (lastUpdatedEl) {
64284
64450
  lastUpdatedEl.textContent = formData.lastUpdatedTime ? this.formatTs(formData.lastUpdatedTime) : "\u2014";
64285
64451
  }
64452
+ if (this.isSuperAdmin()) {
64453
+ this.initCommercialFields(formData);
64454
+ }
64286
64455
  if (!this.config.gcdrDeviceId && formData.gcdrDeviceId) {
64287
64456
  this.config.gcdrDeviceId = formData.gcdrDeviceId;
64288
64457
  }
@@ -64916,6 +65085,7 @@ var SettingsModalView = class _SettingsModalView {
64916
65085
  </div>
64917
65086
 
64918
65087
  </div>
65088
+ ${this.isSuperAdmin() ? this.getCommercialFieldsHTML() : ""}
64919
65089
  </div>
64920
65090
 
64921
65091
  <!-- Central/gateway identity+telemetry \u2014 only for CentralSettingsModal (isGateway);
@@ -64933,6 +65103,71 @@ var SettingsModalView = class _SettingsModalView {
64933
65103
  </div>
64934
65104
  `;
64935
65105
  }
65106
+ /**
65107
+ * Campos comerciais — só @myio / superadmin (o bloco nem é renderizado para os demais,
65108
+ * então getFormData não envia essas chaves e o save não as sobrescreve).
65109
+ * Linha 1: ABL + Contrato (texto). Linha 2: Segmento → Atividade (selects em cascata,
65110
+ * opções preenchidas em initCommercialFields após carregar o catálogo).
65111
+ */
65112
+ getCommercialFieldsHTML() {
65113
+ const customerName = String(
65114
+ this.config.customerName || window.MyIOUtils?.customerName || ""
65115
+ ).trim();
65116
+ const escName = customerName.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
65117
+ return `
65118
+ <div class="commercial-block">
65119
+ <div class="commercial-title">Dados de Cadastro${escName ? ` <span class="commercial-sep">|</span> <span class="commercial-customer">${escName.toLocaleUpperCase("pt-BR")}</span>` : ""}</div>
65120
+ <div class="commercial-grid">
65121
+ <div class="commercial-field">
65122
+ <label class="identity-field-label" for="abl">ABL</label>
65123
+ <input type="text" id="abl" name="abl" class="identity-input" maxlength="50" placeholder="Ex.: 120,50 m\xB2">
65124
+ </div>
65125
+ <div class="commercial-field">
65126
+ <label class="identity-field-label" for="contract">Contrato</label>
65127
+ <input type="text" id="contract" name="contract" class="identity-input" maxlength="100" placeholder="N\xBA / identifica\xE7\xE3o do contrato">
65128
+ </div>
65129
+ <div class="commercial-field">
65130
+ <label class="identity-field-label" for="segment">Segmento</label>
65131
+ <select id="segment" name="segment" class="identity-input" disabled>
65132
+ <option value="">Carregando segmentos\u2026</option>
65133
+ </select>
65134
+ </div>
65135
+ <div class="commercial-field">
65136
+ <label class="identity-field-label" for="activity">Atividade</label>
65137
+ <select id="activity" name="activity" class="identity-input" disabled>
65138
+ <option value="">Selecione o segmento primeiro</option>
65139
+ </select>
65140
+ </div>
65141
+ </div>
65142
+ </div>
65143
+ `;
65144
+ }
65145
+ /** Carrega o catálogo de segmentos e liga a cascata Segmento → Atividade, restaurando os valores salvos. */
65146
+ async initCommercialFields(saved) {
65147
+ const segmentEl = this.modal.querySelector("#segment");
65148
+ const activityEl = this.modal.querySelector("#activity");
65149
+ if (!segmentEl || !activityEl) return;
65150
+ const esc9 = (s) => s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
65151
+ const options = (values, selected, placeholder) => `<option value="">${placeholder}</option>` + values.map((v) => `<option value="${esc9(v)}"${v === selected ? " selected" : ""}>${esc9(v)}</option>`).join("");
65152
+ const catalog = await loadStoreSegmentCatalog(this.config.segmentCatalog);
65153
+ const savedSegment = String(saved.segment || "");
65154
+ const savedActivity = String(saved.activity || "");
65155
+ const segments = catalog.map((s) => s.segment);
65156
+ if (savedSegment && !segments.includes(savedSegment)) segments.push(savedSegment);
65157
+ segmentEl.innerHTML = options(segments, savedSegment, "Selecione\u2026");
65158
+ segmentEl.disabled = false;
65159
+ const fillActivities = (segment, selected) => {
65160
+ if (!segment) {
65161
+ activityEl.innerHTML = options([], "", "Selecione o segmento primeiro");
65162
+ activityEl.disabled = true;
65163
+ return;
65164
+ }
65165
+ activityEl.innerHTML = options(activitiesForSegment(catalog, segment, selected), selected, "Selecione\u2026");
65166
+ activityEl.disabled = false;
65167
+ };
65168
+ fillActivities(savedSegment, savedActivity);
65169
+ segmentEl.addEventListener("change", () => fillActivities(segmentEl.value, ""));
65170
+ }
64936
65171
  /** RFC-0171: Offset de Temperatura — sempre visível para domain=temperature; editável só para @myio.com.br */
64937
65172
  getTemperatureOffsetHTML() {
64938
65173
  const superAdmin = this.isSuperAdmin();
@@ -66616,6 +66851,49 @@ var SettingsModalView = class _SettingsModalView {
66616
66851
  cursor: default;
66617
66852
  }
66618
66853
 
66854
+ /* Campos comerciais (s\xF3 @myio / superadmin) */
66855
+ .commercial-block {
66856
+ margin-top: 14px;
66857
+ padding-top: 12px;
66858
+ border-top: 1px dashed #e5e7eb;
66859
+ }
66860
+ .commercial-title {
66861
+ display: flex;
66862
+ align-items: center;
66863
+ gap: 8px;
66864
+ font-size: 12px;
66865
+ font-weight: 700;
66866
+ color: #495057;
66867
+ margin-bottom: 8px;
66868
+ }
66869
+ .commercial-sep {
66870
+ color: #ced4da;
66871
+ font-weight: 400;
66872
+ }
66873
+ .commercial-customer {
66874
+ color: var(--myio-brand-700, #3e1a7d);
66875
+ letter-spacing: 0.3px;
66876
+ }
66877
+ .commercial-grid {
66878
+ display: grid;
66879
+ grid-template-columns: 1fr 1fr;
66880
+ gap: 10px 16px;
66881
+ }
66882
+ .commercial-field {
66883
+ display: flex;
66884
+ flex-direction: column;
66885
+ gap: 5px;
66886
+ }
66887
+ select.identity-input {
66888
+ height: 30px;
66889
+ cursor: pointer;
66890
+ }
66891
+ select.identity-input:disabled {
66892
+ background: #f8f9fa;
66893
+ color: #9ca3af;
66894
+ cursor: not-allowed;
66895
+ }
66896
+
66619
66897
  /* Col 3: date info block */
66620
66898
  .identity-dates-block {
66621
66899
  grid-column: 3;
@@ -67614,6 +67892,11 @@ var SettingsModalView = class _SettingsModalView {
67614
67892
  color: #6c757d;
67615
67893
  border-color: #373a40;
67616
67894
  }
67895
+ .theme-dark .commercial-block { border-top-color: #373a40; }
67896
+ .theme-dark .commercial-title { color: #ced4da; }
67897
+ .theme-dark .commercial-sep { color: #495057; }
67898
+ .theme-dark .commercial-customer { color: #c4b5fd; }
67899
+ .theme-dark select.identity-input:disabled { background: #1a1b1e; color: #6c757d; }
67617
67900
  .theme-dark .device-name-subtitle {
67618
67901
  color: #6c757d;
67619
67902
  }
@@ -78101,6 +78384,8 @@ var DefaultSettingsFetcher = class _DefaultSettingsFetcher {
78101
78384
  attributes.lastUpdatedTime = attr.value;
78102
78385
  } else if (attr.key === "gcdrDeviceId") {
78103
78386
  attributes.gcdrDeviceId = attr.value;
78387
+ } else if (["abl", "contract", "segment", "activity"].includes(attr.key)) {
78388
+ attributes[attr.key] = String(attr.value);
78104
78389
  }
78105
78390
  }
78106
78391
  }
@@ -78130,7 +78415,12 @@ var DefaultSettingsFetcher = class _DefaultSettingsFetcher {
78130
78415
  const stringFields = [
78131
78416
  "label",
78132
78417
  "floor",
78133
- "identifier"
78418
+ "identifier",
78419
+ // Campos comerciais (só @myio / superadmin no modal)
78420
+ "abl",
78421
+ "contract",
78422
+ "segment",
78423
+ "activity"
78134
78424
  ];
78135
78425
  for (const field of stringFields) {
78136
78426
  if (data[field] && typeof data[field] === "string") {
@@ -78240,6 +78530,7 @@ var SettingsController = class {
78240
78530
  superadmin: params.superadmin,
78241
78531
  userEmail: params.userEmail || window.MyIOUtils?.currentUserEmail || null,
78242
78532
  holdingAdmin: params.holdingAdmin ?? window.MyIOUtils?.HoldingAdmin ?? false,
78533
+ segmentCatalog: params.segmentCatalog,
78243
78534
  // RFC-0144: Pass enableAnnotationsOnboarding flag for onboarding control
78244
78535
  enableAnnotationsOnboarding: params.enableAnnotationsOnboarding ?? false,
78245
78536
  // RFC-0180: Raw device name + GCDR identifiers for Alarms tab
@@ -78563,6 +78854,12 @@ var SettingsController = class {
78563
78854
  if (formData.floor && formData.floor.length > 50) {
78564
78855
  errors.push("Floor must be 50 characters or less");
78565
78856
  }
78857
+ if (formData.abl && formData.abl.length > 50) {
78858
+ errors.push("ABL must be 50 characters or less");
78859
+ }
78860
+ if (formData.contract && formData.contract.length > 100) {
78861
+ errors.push("Contract must be 100 characters or less");
78862
+ }
78566
78863
  if (formData.storeNumber && formData.storeNumber.length > 20) {
78567
78864
  errors.push("Store number must be 20 characters or less");
78568
78865
  }
@@ -175969,6 +176266,7 @@ var version = package_default.version || "0.0.0";
175969
176266
  DEFAULT_SIDEBAR_CONFIG,
175970
176267
  DEFAULT_SOLENOID_SETTINGS,
175971
176268
  DEFAULT_SOLENOID_STATE,
176269
+ DEFAULT_STORE_SEGMENTS,
175972
176270
  DEFAULT_SWITCH_SETTINGS,
175973
176271
  DEFAULT_SWITCH_STATE,
175974
176272
  DEFAULT_TABS,