@blockle/blocks 0.8.3 → 0.8.5
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 +10 -8
- package/dist/index.mjs +10 -8
- package/dist/momotaro.chunk.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -415,16 +415,18 @@ const usePreventBodyScroll = (enabled = true) => {
|
|
|
415
415
|
};
|
|
416
416
|
}, [enabled]);
|
|
417
417
|
};
|
|
418
|
+
const isBrowser = typeof window !== "undefined";
|
|
418
419
|
const useRestoreFocus = (active) => {
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
}, [active]);
|
|
420
|
+
const target = react.useRef(null);
|
|
421
|
+
if (isBrowser && active && !target.current) {
|
|
422
|
+
target.current = document.activeElement;
|
|
423
|
+
}
|
|
425
424
|
react.useEffect(() => {
|
|
426
|
-
if (!active && target instanceof HTMLElement) {
|
|
427
|
-
target.focus();
|
|
425
|
+
if (target.current && !active && target.current instanceof HTMLElement) {
|
|
426
|
+
target.current.focus();
|
|
427
|
+
}
|
|
428
|
+
if (!active) {
|
|
429
|
+
target.current = null;
|
|
428
430
|
}
|
|
429
431
|
}, [active]);
|
|
430
432
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -415,16 +415,18 @@ const usePreventBodyScroll = (enabled = true) => {
|
|
|
415
415
|
};
|
|
416
416
|
}, [enabled]);
|
|
417
417
|
};
|
|
418
|
+
const isBrowser = typeof window !== "undefined";
|
|
418
419
|
const useRestoreFocus = (active) => {
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
}, [active]);
|
|
420
|
+
const target = useRef(null);
|
|
421
|
+
if (isBrowser && active && !target.current) {
|
|
422
|
+
target.current = document.activeElement;
|
|
423
|
+
}
|
|
425
424
|
useEffect(() => {
|
|
426
|
-
if (!active && target instanceof HTMLElement) {
|
|
427
|
-
target.focus();
|
|
425
|
+
if (target.current && !active && target.current instanceof HTMLElement) {
|
|
426
|
+
target.current.focus();
|
|
427
|
+
}
|
|
428
|
+
if (!active) {
|
|
429
|
+
target.current = null;
|
|
428
430
|
}
|
|
429
431
|
}, [active]);
|
|
430
432
|
};
|
package/dist/momotaro.chunk.d.ts
CHANGED
|
@@ -425,7 +425,7 @@ type ComponentTheme<T extends RecordLike> = ComponentThemeToStyles<T> & {
|
|
|
425
425
|
defaultVariants?: ComponentThemeDefaultVariants<T>;
|
|
426
426
|
};
|
|
427
427
|
type ThemeComponentsStyles = {
|
|
428
|
-
[K in keyof ComponentThemes]
|
|
428
|
+
[K in keyof ComponentThemes]?: ComponentTheme<ComponentThemes[K]>;
|
|
429
429
|
};
|
|
430
430
|
declare function makeComponentTheme<T extends keyof ThemeComponentsStyles>(component: T, componentTheme: ThemeComponentsStyles[T]): ThemeComponentsStyles[T];
|
|
431
431
|
|