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