myio-js-library 0.1.97 → 0.1.98

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
@@ -1943,6 +1943,7 @@ var MyIOSelectionStoreClass = class {
1943
1943
  }
1944
1944
  console.log("[SelectionStore] \u{1F3D7}\uFE0F NEW INSTANCE CREATED at:", (/* @__PURE__ */ new Date()).toISOString());
1945
1945
  console.trace("[SelectionStore] Constructor called from:");
1946
+ this.MAX_SELECTION = 6;
1946
1947
  this.state = { selectedDevice: null };
1947
1948
  this.selectedIds = /* @__PURE__ */ new Set();
1948
1949
  this.entities = /* @__PURE__ */ new Map();
@@ -1952,6 +1953,7 @@ var MyIOSelectionStoreClass = class {
1952
1953
  this.cacheExpiry = 5 * 60 * 1e3;
1953
1954
  this.eventListeners.set("selection:change", []);
1954
1955
  this.eventListeners.set("selection:totals", []);
1956
+ this.eventListeners.set("selection:limit-reached", []);
1955
1957
  this.eventListeners.set("comparison:open", []);
1956
1958
  this.eventListeners.set("comparison:too_many", []);
1957
1959
  try {
@@ -1974,11 +1976,26 @@ var MyIOSelectionStoreClass = class {
1974
1976
  add(id) {
1975
1977
  console.log("[MyIOSelectionStoreClass] Entrou na LIB", id);
1976
1978
  const wasSelected = this.selectedIds.has(id);
1977
- this.selectedIds.add(id);
1978
- if (!wasSelected) {
1979
- this._emitSelectionChange("add", id);
1980
- this._trackEvent("footer_dock.drop_add", { entityId: id });
1979
+ if (wasSelected) {
1980
+ console.log("[MyIOSelectionStoreClass] Item j\xE1 est\xE1 selecionado:", id);
1981
+ return;
1981
1982
  }
1983
+ if (this.selectedIds.size >= this.MAX_SELECTION) {
1984
+ console.warn(`[MyIOSelectionStoreClass] Limite de sele\xE7\xE3o atingido (${this.MAX_SELECTION})`);
1985
+ this._emit("selection:limit-reached", {
1986
+ maxAllowed: this.MAX_SELECTION,
1987
+ currentCount: this.selectedIds.size,
1988
+ attemptedId: id
1989
+ });
1990
+ this._trackEvent("selection.limit_reached", {
1991
+ entityId: id,
1992
+ limit: this.MAX_SELECTION
1993
+ });
1994
+ return;
1995
+ }
1996
+ this.selectedIds.add(id);
1997
+ this._emitSelectionChange("add", id);
1998
+ this._trackEvent("footer_dock.drop_add", { entityId: id });
1982
1999
  }
1983
2000
  remove(id) {
1984
2001
  console.log("[MyIOSelectionStoreClass] ITEM PARA REMO\xC7\xC3O ID", id);
package/dist/index.d.cts CHANGED
@@ -776,6 +776,7 @@ declare let MyIOSelectionStore: any;
776
776
  * @author MYIO Frontend Guild
777
777
  */
778
778
  declare class MyIOSelectionStoreClass {
779
+ MAX_SELECTION: number;
779
780
  state: {
780
781
  selectedDevice: any;
781
782
  };
package/dist/index.js CHANGED
@@ -1855,6 +1855,7 @@ var MyIOSelectionStoreClass = class {
1855
1855
  }
1856
1856
  console.log("[SelectionStore] \u{1F3D7}\uFE0F NEW INSTANCE CREATED at:", (/* @__PURE__ */ new Date()).toISOString());
1857
1857
  console.trace("[SelectionStore] Constructor called from:");
1858
+ this.MAX_SELECTION = 6;
1858
1859
  this.state = { selectedDevice: null };
1859
1860
  this.selectedIds = /* @__PURE__ */ new Set();
1860
1861
  this.entities = /* @__PURE__ */ new Map();
@@ -1864,6 +1865,7 @@ var MyIOSelectionStoreClass = class {
1864
1865
  this.cacheExpiry = 5 * 60 * 1e3;
1865
1866
  this.eventListeners.set("selection:change", []);
1866
1867
  this.eventListeners.set("selection:totals", []);
1868
+ this.eventListeners.set("selection:limit-reached", []);
1867
1869
  this.eventListeners.set("comparison:open", []);
1868
1870
  this.eventListeners.set("comparison:too_many", []);
1869
1871
  try {
@@ -1886,11 +1888,26 @@ var MyIOSelectionStoreClass = class {
1886
1888
  add(id) {
1887
1889
  console.log("[MyIOSelectionStoreClass] Entrou na LIB", id);
1888
1890
  const wasSelected = this.selectedIds.has(id);
1889
- this.selectedIds.add(id);
1890
- if (!wasSelected) {
1891
- this._emitSelectionChange("add", id);
1892
- this._trackEvent("footer_dock.drop_add", { entityId: id });
1891
+ if (wasSelected) {
1892
+ console.log("[MyIOSelectionStoreClass] Item j\xE1 est\xE1 selecionado:", id);
1893
+ return;
1893
1894
  }
1895
+ if (this.selectedIds.size >= this.MAX_SELECTION) {
1896
+ console.warn(`[MyIOSelectionStoreClass] Limite de sele\xE7\xE3o atingido (${this.MAX_SELECTION})`);
1897
+ this._emit("selection:limit-reached", {
1898
+ maxAllowed: this.MAX_SELECTION,
1899
+ currentCount: this.selectedIds.size,
1900
+ attemptedId: id
1901
+ });
1902
+ this._trackEvent("selection.limit_reached", {
1903
+ entityId: id,
1904
+ limit: this.MAX_SELECTION
1905
+ });
1906
+ return;
1907
+ }
1908
+ this.selectedIds.add(id);
1909
+ this._emitSelectionChange("add", id);
1910
+ this._trackEvent("footer_dock.drop_add", { entityId: id });
1894
1911
  }
1895
1912
  remove(id) {
1896
1913
  console.log("[MyIOSelectionStoreClass] ITEM PARA REMO\xC7\xC3O ID", id);
@@ -1861,6 +1861,7 @@
1861
1861
  }
1862
1862
  console.log("[SelectionStore] \u{1F3D7}\uFE0F NEW INSTANCE CREATED at:", (/* @__PURE__ */ new Date()).toISOString());
1863
1863
  console.trace("[SelectionStore] Constructor called from:");
1864
+ this.MAX_SELECTION = 6;
1864
1865
  this.state = { selectedDevice: null };
1865
1866
  this.selectedIds = /* @__PURE__ */ new Set();
1866
1867
  this.entities = /* @__PURE__ */ new Map();
@@ -1870,6 +1871,7 @@
1870
1871
  this.cacheExpiry = 5 * 60 * 1e3;
1871
1872
  this.eventListeners.set("selection:change", []);
1872
1873
  this.eventListeners.set("selection:totals", []);
1874
+ this.eventListeners.set("selection:limit-reached", []);
1873
1875
  this.eventListeners.set("comparison:open", []);
1874
1876
  this.eventListeners.set("comparison:too_many", []);
1875
1877
  try {
@@ -1892,11 +1894,26 @@
1892
1894
  add(id) {
1893
1895
  console.log("[MyIOSelectionStoreClass] Entrou na LIB", id);
1894
1896
  const wasSelected = this.selectedIds.has(id);
1895
- this.selectedIds.add(id);
1896
- if (!wasSelected) {
1897
- this._emitSelectionChange("add", id);
1898
- this._trackEvent("footer_dock.drop_add", { entityId: id });
1897
+ if (wasSelected) {
1898
+ console.log("[MyIOSelectionStoreClass] Item j\xE1 est\xE1 selecionado:", id);
1899
+ return;
1899
1900
  }
1901
+ if (this.selectedIds.size >= this.MAX_SELECTION) {
1902
+ console.warn(`[MyIOSelectionStoreClass] Limite de sele\xE7\xE3o atingido (${this.MAX_SELECTION})`);
1903
+ this._emit("selection:limit-reached", {
1904
+ maxAllowed: this.MAX_SELECTION,
1905
+ currentCount: this.selectedIds.size,
1906
+ attemptedId: id
1907
+ });
1908
+ this._trackEvent("selection.limit_reached", {
1909
+ entityId: id,
1910
+ limit: this.MAX_SELECTION
1911
+ });
1912
+ return;
1913
+ }
1914
+ this.selectedIds.add(id);
1915
+ this._emitSelectionChange("add", id);
1916
+ this._trackEvent("footer_dock.drop_add", { entityId: id });
1900
1917
  }
1901
1918
  remove(id) {
1902
1919
  console.log("[MyIOSelectionStoreClass] ITEM PARA REMO\xC7\xC3O ID", id);