@open-slot-ui/core 0.3.1 → 0.3.2

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.js CHANGED
@@ -2010,26 +2010,40 @@ function installResponsive(ui, responsive) {
2010
2010
  if (!c) continue;
2011
2011
  base.set(id, { layout: cloneLayout(c.layout), hidden: ui.hidden.has(id) });
2012
2012
  }
2013
+ let applying = false;
2013
2014
  const apply = (screen) => {
2014
- const keys = activeKeys(screen);
2015
- for (const [id, b] of base) {
2016
- const c = ui.control(id);
2017
- if (!c) continue;
2018
- let layout = b.layout;
2019
- let hidden = b.hidden;
2020
- for (const key of keys) {
2021
- const ov = responsive[key]?.controls?.[id];
2022
- if (!ov) continue;
2023
- if (ov.layout) layout = ov.layout;
2024
- if (ov.hidden != null) hidden = ov.hidden;
2015
+ applying = true;
2016
+ try {
2017
+ const keys = activeKeys(screen);
2018
+ for (const [id, b] of base) {
2019
+ const c = ui.control(id);
2020
+ if (!c) continue;
2021
+ let layout = b.layout;
2022
+ let hidden = b.hidden;
2023
+ for (const key of keys) {
2024
+ const ov = responsive[key]?.controls?.[id];
2025
+ if (!ov) continue;
2026
+ if (ov.layout) layout = ov.layout;
2027
+ if (ov.hidden != null) hidden = ov.hidden;
2028
+ }
2029
+ c.layout = cloneLayout(layout);
2030
+ ui.setHidden(id, hidden);
2025
2031
  }
2026
- c.layout = cloneLayout(layout);
2027
- ui.setHidden(id, hidden);
2032
+ } finally {
2033
+ applying = false;
2028
2034
  }
2029
2035
  };
2036
+ const offVis = ui.on("visibilityChanged", ({ id, hidden }) => {
2037
+ if (applying) return;
2038
+ const b = base.get(id);
2039
+ if (b) b.hidden = hidden;
2040
+ });
2030
2041
  const off = ui.screen.subscribe(apply);
2031
2042
  apply(ui.screen.get());
2032
- return off;
2043
+ return () => {
2044
+ off();
2045
+ offVis();
2046
+ };
2033
2047
  }
2034
2048
 
2035
2049
  // src/spec/createUI.ts