@heliosgraphics/ui 2.0.0-alpha.96 → 2.0.0-alpha.98
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.
|
@@ -30,23 +30,23 @@ export const Dialog: FC<DialogProps> = ({
|
|
|
30
30
|
useEffect(() => {
|
|
31
31
|
dialogRef?.current?.scrollTo?.(0, 0)
|
|
32
32
|
|
|
33
|
-
if (isOpen)
|
|
34
|
-
triggerRef.current = document.activeElement
|
|
35
|
-
document.documentElement.style.overflow = "hidden"
|
|
33
|
+
if (!isOpen) return
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
triggerRef.current = document.activeElement
|
|
36
|
+
document.documentElement.style.overflow = "hidden"
|
|
37
|
+
|
|
38
|
+
if (!dialogRef.current?.open) {
|
|
39
|
+
dialogRef?.current?.showModal?.()
|
|
40
|
+
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
return (): void => {
|
|
43
|
+
document.documentElement.style.overflow = ""
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
triggerRef.current = null
|
|
45
|
+
const trigger = triggerRef.current
|
|
46
|
+
if (trigger && trigger instanceof HTMLElement) {
|
|
47
|
+
trigger.focus()
|
|
49
48
|
}
|
|
49
|
+
triggerRef.current = null
|
|
50
50
|
}
|
|
51
51
|
}, [isOpen])
|
|
52
52
|
|
package/components/Flex/Flex.tsx
CHANGED
|
@@ -7,7 +7,7 @@ export const Flex: FC<FlexProps> = (props) => {
|
|
|
7
7
|
const flexClasses: string = getFlexUtility(restProps)
|
|
8
8
|
const safeProps = getSafeFlexProps(restProps)
|
|
9
9
|
|
|
10
|
-
const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
|
|
10
|
+
const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>): void => {
|
|
11
11
|
if (restProps.onClick && (event.key === "Enter" || event.key === " ")) {
|
|
12
12
|
event.preventDefault()
|
|
13
13
|
restProps.onClick(event as unknown as React.MouseEvent<HTMLDivElement>)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { type FC,
|
|
3
|
+
import { type FC, useId, useInsertionEffect } from "react"
|
|
4
4
|
import type { MasonryProps } from "./Masonry.types"
|
|
5
5
|
|
|
6
6
|
export const Masonry: FC<MasonryProps> = ({
|
|
@@ -9,32 +9,40 @@ export const Masonry: FC<MasonryProps> = ({
|
|
|
9
9
|
gap = [2, 4, 6],
|
|
10
10
|
breakpoints = [0, 640, 960],
|
|
11
11
|
}) => {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
.${id} {
|
|
22
|
-
|
|
12
|
+
const reactId = useId()
|
|
13
|
+
const id = `masonry${reactId.replace(/:/g, "")}`
|
|
14
|
+
|
|
15
|
+
useInsertionEffect(() => {
|
|
16
|
+
const style = document.createElement("style")
|
|
17
|
+
|
|
18
|
+
style.dataset["masonryId"] = id
|
|
19
|
+
style.textContent = `
|
|
20
|
+
.${id} { column-count: ${columns[0]}; column-gap: ${gap[0]}px; }
|
|
21
|
+
.${id} > * { break-inside: avoid; margin-bottom: ${gap[0]}px; }
|
|
22
|
+
|
|
23
|
+
@media (min-width: ${breakpoints[1]}px) {
|
|
24
|
+
.${id} { column-count: ${columns[1]}; column-gap: ${gap[1]}px; }
|
|
25
|
+
.${id} > * { margin-bottom: ${gap[1]}px; }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@media (min-width: ${breakpoints[2]}px) {
|
|
29
|
+
.${id} { column-count: ${columns[2]}; column-gap: ${gap[2]}px; }
|
|
30
|
+
.${id} > * { margin-bottom: ${gap[2]}px; }
|
|
31
|
+
}
|
|
32
|
+
`
|
|
33
|
+
document.head.appendChild(style)
|
|
34
|
+
|
|
35
|
+
return (): void => {
|
|
36
|
+
style.remove()
|
|
23
37
|
}
|
|
38
|
+
}, [id, columns, gap, breakpoints])
|
|
24
39
|
|
|
25
|
-
|
|
26
|
-
.${id} { column-count: ${columns[2]}; column-gap: ${gap[2]}px; }
|
|
27
|
-
.${id} > * { margin-bottom: ${gap[2]}px; }
|
|
28
|
-
}
|
|
29
|
-
`
|
|
40
|
+
if (!children) return null
|
|
30
41
|
|
|
31
42
|
return (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
{children}
|
|
36
|
-
</div>
|
|
37
|
-
</>
|
|
43
|
+
<div className={id} data-ui-component="Masonry">
|
|
44
|
+
{children}
|
|
45
|
+
</div>
|
|
38
46
|
)
|
|
39
47
|
}
|
|
40
48
|
|
|
@@ -20,8 +20,8 @@ export const useResizeObserver = (): readonly [(element: HTMLDivElement | null)
|
|
|
20
20
|
if (element) {
|
|
21
21
|
resizeObserverRef.current = new ResizeObserver((entries) => {
|
|
22
22
|
if (entries[0]) {
|
|
23
|
-
const
|
|
24
|
-
setWidth(
|
|
23
|
+
const entryWidth = entries[0].contentRect.width
|
|
24
|
+
setWidth(entryWidth)
|
|
25
25
|
}
|
|
26
26
|
})
|
|
27
27
|
|