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.mjs
CHANGED
|
@@ -7206,32 +7206,49 @@ function RulersOverlay({ enabled }) {
|
|
|
7206
7206
|
);
|
|
7207
7207
|
}
|
|
7208
7208
|
var RULERS_VISIBLE_KEY = "direct-edit-rulers-visible";
|
|
7209
|
-
var
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7209
|
+
var canUseDOM = typeof window !== "undefined";
|
|
7210
|
+
var rulersVisibleListeners = /* @__PURE__ */ new Set();
|
|
7211
|
+
function readStoredRulersVisible() {
|
|
7212
|
+
if (!canUseDOM) {
|
|
7213
|
+
return true;
|
|
7214
|
+
}
|
|
7215
|
+
try {
|
|
7216
|
+
return localStorage.getItem(RULERS_VISIBLE_KEY) !== "false";
|
|
7217
|
+
} catch {
|
|
7218
|
+
return true;
|
|
7219
|
+
}
|
|
7220
|
+
}
|
|
7221
|
+
var rulersVisibleSnapshot = readStoredRulersVisible();
|
|
7222
|
+
function emitRulersVisible() {
|
|
7223
|
+
rulersVisibleListeners.forEach((listener) => listener());
|
|
7224
|
+
}
|
|
7225
|
+
function setRulersVisible(next) {
|
|
7226
|
+
if (rulersVisibleSnapshot === next) {
|
|
7227
|
+
return;
|
|
7228
|
+
}
|
|
7229
|
+
rulersVisibleSnapshot = next;
|
|
7230
|
+
if (canUseDOM) {
|
|
7213
7231
|
try {
|
|
7214
|
-
|
|
7232
|
+
localStorage.setItem(RULERS_VISIBLE_KEY, String(next));
|
|
7215
7233
|
} catch {
|
|
7216
7234
|
}
|
|
7217
|
-
}
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
}
|
|
7235
|
+
}
|
|
7236
|
+
emitRulersVisible();
|
|
7237
|
+
}
|
|
7238
|
+
function subscribeRulersVisible(listener) {
|
|
7239
|
+
rulersVisibleListeners.add(listener);
|
|
7240
|
+
return () => {
|
|
7241
|
+
rulersVisibleListeners.delete(listener);
|
|
7242
|
+
};
|
|
7243
|
+
}
|
|
7244
|
+
function useRulersVisible() {
|
|
7245
|
+
const visible = React15.useSyncExternalStore(
|
|
7246
|
+
subscribeRulersVisible,
|
|
7247
|
+
() => rulersVisibleSnapshot,
|
|
7248
|
+
() => true
|
|
7249
|
+
);
|
|
7225
7250
|
const toggle = React15.useCallback(() => {
|
|
7226
|
-
|
|
7227
|
-
const next = !prev;
|
|
7228
|
-
try {
|
|
7229
|
-
localStorage.setItem(RULERS_VISIBLE_KEY, String(next));
|
|
7230
|
-
} catch {
|
|
7231
|
-
}
|
|
7232
|
-
window.dispatchEvent(new CustomEvent(RULERS_TOGGLE_EVENT, { detail: next }));
|
|
7233
|
-
return next;
|
|
7234
|
-
});
|
|
7251
|
+
setRulersVisible(!rulersVisibleSnapshot);
|
|
7235
7252
|
}, []);
|
|
7236
7253
|
return [visible, toggle];
|
|
7237
7254
|
}
|