made-refine 0.1.7 → 0.1.8
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 +39 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7247,32 +7247,49 @@ function RulersOverlay({ enabled }) {
|
|
|
7247
7247
|
);
|
|
7248
7248
|
}
|
|
7249
7249
|
var RULERS_VISIBLE_KEY = "direct-edit-rulers-visible";
|
|
7250
|
-
var
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
|
|
7250
|
+
var canUseDOM = typeof window !== "undefined";
|
|
7251
|
+
var rulersVisibleListeners = /* @__PURE__ */ new Set();
|
|
7252
|
+
function readStoredRulersVisible() {
|
|
7253
|
+
if (!canUseDOM) {
|
|
7254
|
+
return true;
|
|
7255
|
+
}
|
|
7256
|
+
try {
|
|
7257
|
+
return localStorage.getItem(RULERS_VISIBLE_KEY) !== "false";
|
|
7258
|
+
} catch {
|
|
7259
|
+
return true;
|
|
7260
|
+
}
|
|
7261
|
+
}
|
|
7262
|
+
var rulersVisibleSnapshot = readStoredRulersVisible();
|
|
7263
|
+
function emitRulersVisible() {
|
|
7264
|
+
rulersVisibleListeners.forEach((listener) => listener());
|
|
7265
|
+
}
|
|
7266
|
+
function setRulersVisible(next) {
|
|
7267
|
+
if (rulersVisibleSnapshot === next) {
|
|
7268
|
+
return;
|
|
7269
|
+
}
|
|
7270
|
+
rulersVisibleSnapshot = next;
|
|
7271
|
+
if (canUseDOM) {
|
|
7254
7272
|
try {
|
|
7255
|
-
|
|
7273
|
+
localStorage.setItem(RULERS_VISIBLE_KEY, String(next));
|
|
7256
7274
|
} catch {
|
|
7257
7275
|
}
|
|
7258
|
-
}
|
|
7259
|
-
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
|
|
7265
|
-
}
|
|
7276
|
+
}
|
|
7277
|
+
emitRulersVisible();
|
|
7278
|
+
}
|
|
7279
|
+
function subscribeRulersVisible(listener) {
|
|
7280
|
+
rulersVisibleListeners.add(listener);
|
|
7281
|
+
return () => {
|
|
7282
|
+
rulersVisibleListeners.delete(listener);
|
|
7283
|
+
};
|
|
7284
|
+
}
|
|
7285
|
+
function useRulersVisible() {
|
|
7286
|
+
const visible = React15.useSyncExternalStore(
|
|
7287
|
+
subscribeRulersVisible,
|
|
7288
|
+
() => rulersVisibleSnapshot,
|
|
7289
|
+
() => true
|
|
7290
|
+
);
|
|
7266
7291
|
const toggle = React15.useCallback(() => {
|
|
7267
|
-
|
|
7268
|
-
const next = !prev;
|
|
7269
|
-
try {
|
|
7270
|
-
localStorage.setItem(RULERS_VISIBLE_KEY, String(next));
|
|
7271
|
-
} catch {
|
|
7272
|
-
}
|
|
7273
|
-
window.dispatchEvent(new CustomEvent(RULERS_TOGGLE_EVENT, { detail: next }));
|
|
7274
|
-
return next;
|
|
7275
|
-
});
|
|
7292
|
+
setRulersVisible(!rulersVisibleSnapshot);
|
|
7276
7293
|
}, []);
|
|
7277
7294
|
return [visible, toggle];
|
|
7278
7295
|
}
|