@blockle/blocks-react 3.0.1 → 3.2.0
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/README.md +138 -0
- package/dist/components/display/Tag/Tag.d.ts +28 -0
- package/dist/components/display/Tag/Tag.d.ts.map +1 -0
- package/dist/components/display/Tag/Tag.js +46 -0
- package/dist/components/feedback/Alert/Alert.d.ts +17 -2
- package/dist/components/feedback/Alert/Alert.d.ts.map +1 -1
- package/dist/components/feedback/Alert/Alert.js +8 -35
- package/dist/components/feedback/Toast/Toast.css.d.ts +10 -1
- package/dist/components/feedback/Toast/Toast.css.d.ts.map +1 -1
- package/dist/components/feedback/Toast/Toast.css.js +37 -10
- package/dist/components/feedback/Toast/ToastContext.d.ts +6 -0
- package/dist/components/feedback/Toast/ToastContext.d.ts.map +1 -1
- package/dist/components/feedback/Toast/ToastProvider.d.ts +15 -1
- package/dist/components/feedback/Toast/ToastProvider.d.ts.map +1 -1
- package/dist/components/feedback/Toast/ToastProvider.js +128 -44
- package/dist/components/feedback/Toast/useCountdowns.d.ts +14 -0
- package/dist/components/feedback/Toast/useCountdowns.d.ts.map +1 -0
- package/dist/components/feedback/Toast/useCountdowns.js +74 -0
- package/dist/components/form/Button/Button.d.ts +11 -3
- package/dist/components/form/Button/Button.d.ts.map +1 -1
- package/dist/components/form/Checkbox/Checkbox.d.ts +0 -1
- package/dist/components/form/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/components/form/Checkbox/Checkbox.js +7 -27
- package/dist/components/form/Checkbox/checkbox.css.d.ts.map +1 -1
- package/dist/components/form/Checkbox/checkbox.css.js +1 -0
- package/dist/components/form/IconButton/IconButton.d.ts +29 -0
- package/dist/components/form/IconButton/IconButton.d.ts.map +1 -0
- package/dist/components/form/IconButton/IconButton.js +61 -0
- package/dist/components/form/NumericInput/NumericInput.d.ts +11 -1
- package/dist/components/form/NumericInput/NumericInput.d.ts.map +1 -1
- package/dist/components/form/NumericInput/NumericInput.js +52 -24
- package/dist/components/form/Radio/Radio.d.ts +0 -1
- package/dist/components/form/Radio/Radio.d.ts.map +1 -1
- package/dist/components/form/Radio/Radio.js +1 -11
- package/dist/components/form/Radio/radio.css.d.ts.map +1 -1
- package/dist/components/form/Radio/radio.css.js +1 -0
- package/dist/components/form/Select/Select.d.ts +2 -1
- package/dist/components/form/Select/Select.d.ts.map +1 -1
- package/dist/components/form/Select/Select.js +4 -24
- package/dist/components/form/Switch/Switch.d.ts +5 -1
- package/dist/components/form/Switch/Switch.d.ts.map +1 -1
- package/dist/components/form/Switch/Switch.js +19 -29
- package/dist/components/form/Switch/switch.css.d.ts.map +1 -1
- package/dist/components/form/Switch/switch.css.js +1 -0
- package/dist/components/form/TextInput/TextInput.d.ts +0 -1
- package/dist/components/form/TextInput/TextInput.d.ts.map +1 -1
- package/dist/components/form/TextInput/TextInput.js +0 -2
- package/dist/components/form/Textarea/Textarea.css.d.ts +2 -0
- package/dist/components/form/Textarea/Textarea.css.d.ts.map +1 -1
- package/dist/components/form/Textarea/Textarea.css.js +17 -1
- package/dist/components/form/Textarea/Textarea.d.ts +11 -0
- package/dist/components/form/Textarea/Textarea.d.ts.map +1 -1
- package/dist/components/form/Textarea/Textarea.js +8 -2
- package/dist/components/layout/Inline/Inline.d.ts +11 -3
- package/dist/components/layout/Inline/Inline.d.ts.map +1 -1
- package/dist/components/layout/Inline/Inline.js +5 -3
- package/dist/components/layout/Stack/Stack.d.ts +12 -8
- package/dist/components/layout/Stack/Stack.d.ts.map +1 -1
- package/dist/components/layout/Stack/Stack.js +8 -4
- package/dist/components/navigation/Link/Link.d.ts +1 -1
- package/dist/components/navigation/Link/Link.d.ts.map +1 -1
- package/dist/components/navigation/Link/Link.js +2 -2
- package/dist/components/overlay/Dialog/Dialog.d.ts +4 -1
- package/dist/components/overlay/Dialog/Dialog.d.ts.map +1 -1
- package/dist/components/overlay/Dialog/Dialog.js +19 -46
- package/dist/components/overlay/Drawer/Drawer.d.ts +9 -2
- package/dist/components/overlay/Drawer/Drawer.d.ts.map +1 -1
- package/dist/components/overlay/Drawer/Drawer.js +25 -44
- package/dist/components/overlay/Drawer/drawer.css.d.ts.map +1 -1
- package/dist/components/overlay/Drawer/drawer.css.js +4 -8
- package/dist/components/overlay/Popover/Popover.d.ts +15 -3
- package/dist/components/overlay/Popover/Popover.d.ts.map +1 -1
- package/dist/components/overlay/Popover/Popover.js +35 -11
- package/dist/components/overlay/Popover/popover-utils.d.ts +38 -1
- package/dist/components/overlay/Popover/popover-utils.d.ts.map +1 -1
- package/dist/components/overlay/Popover/popover-utils.js +92 -41
- package/dist/components/overlay/Tooltip/Tooltip.d.ts +8 -0
- package/dist/components/overlay/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/components/overlay/Tooltip/Tooltip.js +3 -2
- package/dist/components/overlay/requestCloseReason.d.ts +6 -0
- package/dist/components/overlay/requestCloseReason.d.ts.map +1 -0
- package/dist/components/overlay/useModalOverlay.d.ts +35 -0
- package/dist/components/overlay/useModalOverlay.d.ts.map +1 -0
- package/dist/components/overlay/useModalOverlay.js +85 -0
- package/dist/components/typography/Heading/Heading.d.ts +2 -1
- package/dist/components/typography/Heading/Heading.d.ts.map +1 -1
- package/dist/components/typography/Heading/Heading.js +9 -1
- package/dist/components/typography/Text/Text.d.ts +3 -2
- package/dist/components/typography/Text/Text.d.ts.map +1 -1
- package/dist/components/typography/Text/Text.js +9 -1
- package/dist/components/typography/textOverflow.css.d.ts +3 -0
- package/dist/components/typography/textOverflow.css.d.ts.map +1 -0
- package/dist/components/typography/textOverflow.css.js +32 -0
- package/dist/components/typography/textOverflow.d.ts +9 -0
- package/dist/components/typography/textOverflow.d.ts.map +1 -0
- package/dist/components/typography/textOverflow.js +10 -0
- package/dist/hooks/useClickOutside/useClickOutside.d.ts.map +1 -1
- package/dist/hooks/useClickOutside/useClickOutside.js +27 -7
- package/dist/hooks/useModalDialog/useModalDialog.d.ts +13 -0
- package/dist/hooks/useModalDialog/useModalDialog.d.ts.map +1 -0
- package/dist/hooks/useModalDialog/useModalDialog.js +39 -0
- package/dist/icons/icons.d.ts +8 -0
- package/dist/icons/icons.d.ts.map +1 -0
- package/dist/icons/icons.js +39 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/testUtils/browser/consumerStyles.css.d.ts +2 -0
- package/dist/testUtils/browser/consumerStyles.css.d.ts.map +1 -0
- package/dist/testUtils/browser/pointer.d.ts +18 -0
- package/dist/testUtils/browser/pointer.d.ts.map +1 -0
- package/dist/testUtils/testTheme.css.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/components/feedback/Alert/Alert.css.d.ts +0 -2
- package/dist/components/feedback/Alert/Alert.css.d.ts.map +0 -1
- package/dist/components/feedback/Alert/Alert.css.js +0 -15
- package/dist/components/overlay/Dialog/dialogHelper.d.ts +0 -7
- package/dist/components/overlay/Dialog/dialogHelper.d.ts.map +0 -1
- package/dist/components/overlay/Dialog/dialogHelper.js +0 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawer.css.d.ts","sourceRoot":"","sources":["../../../../src/components/overlay/Drawer/drawer.css.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,QAmBjB,CAAC;AAEH,eAAO,MAAM,SAAS;;;;;
|
|
1
|
+
{"version":3,"file":"drawer.css.d.ts","sourceRoot":"","sources":["../../../../src/components/overlay/Drawer/drawer.css.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,QAmBjB,CAAC;AAEH,eAAO,MAAM,SAAS;;;;;CAuCrB,CAAC"}
|
|
@@ -29,8 +29,7 @@ const placement = {
|
|
|
29
29
|
top: 0,
|
|
30
30
|
bottom: 0,
|
|
31
31
|
left: 0,
|
|
32
|
-
height: "100%"
|
|
33
|
-
width: "300px"
|
|
32
|
+
height: "100%"
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
}),
|
|
@@ -40,8 +39,7 @@ const placement = {
|
|
|
40
39
|
top: 0,
|
|
41
40
|
right: 0,
|
|
42
41
|
bottom: 0,
|
|
43
|
-
height: "100%"
|
|
44
|
-
width: "300px"
|
|
42
|
+
height: "100%"
|
|
45
43
|
}
|
|
46
44
|
}
|
|
47
45
|
}),
|
|
@@ -50,8 +48,7 @@ const placement = {
|
|
|
50
48
|
[layers.molecule]: {
|
|
51
49
|
top: 0,
|
|
52
50
|
left: 0,
|
|
53
|
-
width: "100%"
|
|
54
|
-
height: "300px"
|
|
51
|
+
width: "100%"
|
|
55
52
|
}
|
|
56
53
|
}
|
|
57
54
|
}),
|
|
@@ -60,8 +57,7 @@ const placement = {
|
|
|
60
57
|
[layers.molecule]: {
|
|
61
58
|
bottom: 0,
|
|
62
59
|
left: 0,
|
|
63
|
-
width: "100%"
|
|
64
|
-
height: "300px"
|
|
60
|
+
width: "100%"
|
|
65
61
|
}
|
|
66
62
|
}
|
|
67
63
|
})
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { HTMLElementProps } from '@blockle/blocks-core';
|
|
2
|
-
|
|
2
|
+
import { RequestCloseReason } from '../requestCloseReason.js';
|
|
3
|
+
import { PopoverPlacement } from './popover-utils.js';
|
|
4
|
+
export type { PopoverPlacement };
|
|
3
5
|
export type PopoverProps = {
|
|
4
6
|
anchorElement: React.RefObject<HTMLElement | null>;
|
|
5
|
-
onRequestClose: () => void;
|
|
7
|
+
onRequestClose: (reason: RequestCloseReason) => void;
|
|
6
8
|
open: boolean;
|
|
7
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Side of the anchor to open on, and which of its edges to line up with.
|
|
11
|
+
* Flips to the opposite side when there is no room, and shifts to stay
|
|
12
|
+
* inside the viewport.
|
|
13
|
+
* @default 'top'
|
|
14
|
+
*/
|
|
15
|
+
placement?: PopoverPlacement;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use `placement`, which wins when both are passed
|
|
18
|
+
*/
|
|
19
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
8
20
|
sticky?: boolean;
|
|
9
21
|
} & HTMLElementProps<HTMLDivElement>;
|
|
10
22
|
export declare const Popover: React.FC<PopoverProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../../src/components/overlay/Popover/Popover.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,gBAAgB,EAEtB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../../src/components/overlay/Popover/Popover.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,gBAAgB,EAEtB,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE/E,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAIjC,MAAM,MAAM,YAAY,GAAG;IACzB,aAAa,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACnD,cAAc,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACrD,IAAI,EAAE,OAAO,CAAC;IACd;;;;;OAKG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IAC/C,MAAM,CAAC,EAAE,OAAO,CAAC;CAElB,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAAC;AAErC,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAkJ1C,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { hasAnimationDuration, classnames, composeRefs } from "@blockle/blocks-core";
|
|
4
|
-
import { useRef, useState,
|
|
4
|
+
import { useRef, useState, useCallback, useEffect } from "react";
|
|
5
5
|
import { useClickOutside } from "../../../hooks/useClickOutside/useClickOutside.js";
|
|
6
6
|
import { useComponentStyles } from "../../../hooks/useComponentStyles/useComponentStyles.js";
|
|
7
7
|
import { useIsomorphicLayoutEffect } from "../../../hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";
|
|
@@ -14,17 +14,32 @@ const Popover = ({
|
|
|
14
14
|
className,
|
|
15
15
|
onRequestClose,
|
|
16
16
|
open,
|
|
17
|
-
|
|
17
|
+
placement: placementProp,
|
|
18
|
+
position,
|
|
19
|
+
ref,
|
|
18
20
|
sticky,
|
|
19
21
|
style,
|
|
20
22
|
...restProps
|
|
21
23
|
}) => {
|
|
24
|
+
const placement = placementProp ?? position ?? "top";
|
|
22
25
|
const popoverRef = useRef(null);
|
|
23
26
|
const [popoverPosition, setPopoverPosition] = useState({ x: 0, y: 0 });
|
|
24
27
|
const [visible, setVisible] = useState(open);
|
|
25
28
|
const popoverClassName = useComponentStyles("popover", { root: true }, false);
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
const onEscape = useCallback(
|
|
30
|
+
(event) => {
|
|
31
|
+
if (event.defaultPrevented) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
onRequestClose("escape");
|
|
36
|
+
},
|
|
37
|
+
[onRequestClose]
|
|
38
|
+
);
|
|
39
|
+
useKeyboard("Escape", onEscape, { enabled: open });
|
|
40
|
+
useClickOutside(popoverRef, () => onRequestClose("outside-click"), {
|
|
41
|
+
enabled: open
|
|
42
|
+
});
|
|
28
43
|
useIsomorphicLayoutEffect(() => {
|
|
29
44
|
const element = popoverRef.current;
|
|
30
45
|
if (open && visible) {
|
|
@@ -35,7 +50,7 @@ const Popover = ({
|
|
|
35
50
|
return;
|
|
36
51
|
}
|
|
37
52
|
element.showPopover();
|
|
38
|
-
const [x, y] = getPopoverPosition(
|
|
53
|
+
const [x, y] = getPopoverPosition(placement, anchorElement, popoverRef);
|
|
39
54
|
setPopoverPosition({ x, y });
|
|
40
55
|
} else if (open) {
|
|
41
56
|
setVisible(true);
|
|
@@ -43,21 +58,30 @@ const Popover = ({
|
|
|
43
58
|
if (!hasAnimationDuration(popoverRef.current)) {
|
|
44
59
|
setVisible(false);
|
|
45
60
|
}
|
|
46
|
-
|
|
61
|
+
if (!element) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (typeof element.hidePopover !== "function") {
|
|
65
|
+
console.warn(
|
|
66
|
+
"Popover: hidePopover method is not available on the element."
|
|
67
|
+
);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
element.hidePopover();
|
|
47
71
|
}
|
|
48
72
|
}, [open, visible]);
|
|
49
73
|
useEffect(() => {
|
|
50
74
|
if (open) {
|
|
51
|
-
const [x, y] = getPopoverPosition(
|
|
75
|
+
const [x, y] = getPopoverPosition(placement, anchorElement, popoverRef);
|
|
52
76
|
setPopoverPosition({ x, y });
|
|
53
77
|
}
|
|
54
|
-
}, [open, anchorElement,
|
|
78
|
+
}, [open, anchorElement, placement]);
|
|
55
79
|
useEffect(() => {
|
|
56
80
|
if (!open || !sticky) {
|
|
57
81
|
return;
|
|
58
82
|
}
|
|
59
83
|
function updatePopoverPosition() {
|
|
60
|
-
const [x, y] = getPopoverPosition(
|
|
84
|
+
const [x, y] = getPopoverPosition(placement, anchorElement, popoverRef);
|
|
61
85
|
setPopoverPosition((prev) => {
|
|
62
86
|
if (prev.x === x && prev.y === y) {
|
|
63
87
|
return prev;
|
|
@@ -71,7 +95,7 @@ const Popover = ({
|
|
|
71
95
|
window.removeEventListener("resize", updatePopoverPosition);
|
|
72
96
|
window.removeEventListener("scroll", updatePopoverPosition);
|
|
73
97
|
};
|
|
74
|
-
}, [
|
|
98
|
+
}, [placement, anchorElement, open, sticky]);
|
|
75
99
|
const onAnimationEnd = useCallback(() => {
|
|
76
100
|
if (!open) {
|
|
77
101
|
setVisible(false);
|
|
@@ -83,7 +107,7 @@ const Popover = ({
|
|
|
83
107
|
return /* @__PURE__ */ jsx(
|
|
84
108
|
Box,
|
|
85
109
|
{
|
|
86
|
-
ref: composeRefs(
|
|
110
|
+
ref: composeRefs(ref, popoverRef),
|
|
87
111
|
"data-open": open ? "" : void 0,
|
|
88
112
|
popover: "manual",
|
|
89
113
|
className: classnames(popoverClassName, className),
|
|
@@ -1,3 +1,40 @@
|
|
|
1
1
|
export type PopoverPositions = [x: number, y: number];
|
|
2
|
-
|
|
2
|
+
type PopoverSide = 'top' | 'bottom' | 'left' | 'right';
|
|
3
|
+
type PopoverEdge = 'start' | 'end';
|
|
4
|
+
export type PopoverPlacement = PopoverSide | `${PopoverSide}-${PopoverEdge}`;
|
|
5
|
+
type Rect = {
|
|
6
|
+
top: number;
|
|
7
|
+
left: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
type Margin = {
|
|
12
|
+
top: number;
|
|
13
|
+
right: number;
|
|
14
|
+
bottom: number;
|
|
15
|
+
left: number;
|
|
16
|
+
};
|
|
17
|
+
export type ComputePopoverPositionOptions = {
|
|
18
|
+
placement: PopoverPlacement;
|
|
19
|
+
/** The anchor's border box, relative to the viewport */
|
|
20
|
+
anchor: Rect;
|
|
21
|
+
/** The popover's untransformed border-box size and its margins */
|
|
22
|
+
popover: {
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
margin: Margin;
|
|
26
|
+
};
|
|
27
|
+
viewport: {
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
scrollX: number;
|
|
31
|
+
scrollY: number;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Returns the popover's `left` and `top`, relative to the document
|
|
36
|
+
*/
|
|
37
|
+
export declare function computePopoverPosition({ placement, anchor, popover, viewport, }: ComputePopoverPositionOptions): PopoverPositions;
|
|
38
|
+
export declare function getPopoverPosition(placement: PopoverPlacement, anchorRef: React.RefObject<HTMLElement | null>, popoverRef: React.RefObject<HTMLElement | null>): PopoverPositions;
|
|
39
|
+
export {};
|
|
3
40
|
//# sourceMappingURL=popover-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover-utils.d.ts","sourceRoot":"","sources":["../../../../src/components/overlay/Popover/popover-utils.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;AAEtD,
|
|
1
|
+
{"version":3,"file":"popover-utils.d.ts","sourceRoot":"","sources":["../../../../src/components/overlay/Popover/popover-utils.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;AAEtD,KAAK,WAAW,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAEvD,KAAK,WAAW,GAAG,OAAO,GAAG,KAAK,CAAC;AAEnC,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,GAAG,WAAW,IAAI,WAAW,EAAE,CAAC;AAE7E,KAAK,IAAI,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzE,KAAK,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,6BAA6B,GAAG;IAC1C,SAAS,EAAE,gBAAgB,CAAC;IAC5B,wDAAwD;IACxD,MAAM,EAAE,IAAI,CAAC;IACb,kEAAkE;IAClE,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3D,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/E,CAAC;AAEF;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,SAAS,EACT,MAAM,EACN,OAAO,EACP,QAAQ,GACT,EAAE,6BAA6B,GAAG,gBAAgB,CAyClD;AAoED,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,gBAAgB,EAC3B,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EAC9C,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,GAC9C,gBAAgB,CAyClB"}
|
|
@@ -1,57 +1,108 @@
|
|
|
1
1
|
import { getOriginalElementSize, cssValueToNumber } from "@blockle/blocks-core";
|
|
2
|
-
function
|
|
2
|
+
function computePopoverPosition({
|
|
3
|
+
placement,
|
|
4
|
+
anchor,
|
|
5
|
+
popover,
|
|
6
|
+
viewport
|
|
7
|
+
}) {
|
|
8
|
+
const [preferredSide, edge] = placement.split("-");
|
|
9
|
+
const { margin } = popover;
|
|
10
|
+
const side = flipSide(preferredSide, anchor, popover, viewport);
|
|
11
|
+
let left;
|
|
12
|
+
let top;
|
|
13
|
+
if (side === "top" || side === "bottom") {
|
|
14
|
+
top = side === "top" ? anchor.top - margin.bottom - popover.height : anchor.top + anchor.height + margin.top;
|
|
15
|
+
left = alignOnCrossAxis(
|
|
16
|
+
edge,
|
|
17
|
+
anchor.left,
|
|
18
|
+
anchor.width,
|
|
19
|
+
popover.width,
|
|
20
|
+
viewport.width
|
|
21
|
+
);
|
|
22
|
+
} else {
|
|
23
|
+
left = side === "left" ? anchor.left - margin.right - popover.width : anchor.left + anchor.width + margin.left;
|
|
24
|
+
top = alignOnCrossAxis(
|
|
25
|
+
edge,
|
|
26
|
+
anchor.top,
|
|
27
|
+
anchor.height,
|
|
28
|
+
popover.height,
|
|
29
|
+
viewport.height
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
return [
|
|
33
|
+
left - margin.left + viewport.scrollX,
|
|
34
|
+
top - margin.top + viewport.scrollY
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
const VIEWPORT_PADDING = 8;
|
|
38
|
+
const oppositeSide = {
|
|
39
|
+
top: "bottom",
|
|
40
|
+
bottom: "top",
|
|
41
|
+
left: "right",
|
|
42
|
+
right: "left"
|
|
43
|
+
};
|
|
44
|
+
function flipSide(side, anchor, popover, viewport) {
|
|
45
|
+
const { margin } = popover;
|
|
46
|
+
const room = {
|
|
47
|
+
top: anchor.top,
|
|
48
|
+
bottom: viewport.height - anchor.top - anchor.height,
|
|
49
|
+
left: anchor.left,
|
|
50
|
+
right: viewport.width - anchor.left - anchor.width
|
|
51
|
+
};
|
|
52
|
+
const needed = side === "top" || side === "bottom" ? popover.height + margin.top + margin.bottom : popover.width + margin.left + margin.right;
|
|
53
|
+
const opposite = oppositeSide[side];
|
|
54
|
+
if (room[side] < needed && room[opposite] > room[side]) {
|
|
55
|
+
return opposite;
|
|
56
|
+
}
|
|
57
|
+
return side;
|
|
58
|
+
}
|
|
59
|
+
function alignOnCrossAxis(edge, anchorStart, anchorSize, popoverSize, viewportSize) {
|
|
60
|
+
let start = anchorStart + (anchorSize - popoverSize) / 2;
|
|
61
|
+
if (edge === "start") {
|
|
62
|
+
start = anchorStart;
|
|
63
|
+
} else if (edge === "end") {
|
|
64
|
+
start = anchorStart + anchorSize - popoverSize;
|
|
65
|
+
}
|
|
66
|
+
const max = viewportSize - VIEWPORT_PADDING - popoverSize;
|
|
67
|
+
return Math.max(VIEWPORT_PADDING, Math.min(start, max));
|
|
68
|
+
}
|
|
69
|
+
function getPopoverPosition(placement, anchorRef, popoverRef) {
|
|
3
70
|
if (!anchorRef.current || !popoverRef.current) {
|
|
4
71
|
return [0, 0];
|
|
5
72
|
}
|
|
6
73
|
const anchorRect = anchorRef.current.getBoundingClientRect();
|
|
7
74
|
const popoverRect = popoverRef.current.getBoundingClientRect();
|
|
8
75
|
const popoverStyles = getComputedStyle(popoverRef.current);
|
|
9
|
-
const [
|
|
76
|
+
const [width, height] = getOriginalElementSize(
|
|
10
77
|
popoverStyles,
|
|
11
78
|
popoverRect.width,
|
|
12
79
|
popoverRect.height
|
|
13
80
|
);
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const rightPosition = anchorRect.left + anchorRect.width + popoverWidth;
|
|
36
|
-
const bottomPosition = anchorRect.top + anchorRect.height + popoverHeight;
|
|
37
|
-
const leftPosition = anchorRect.left - popoverWidth;
|
|
38
|
-
const offsetX = anchorLeft - marginLeft - (popoverWidth - anchorRect.width) / 2;
|
|
39
|
-
const offsetY = anchorTop - marginTop - (popoverHeight - anchorRect.height) / 2;
|
|
40
|
-
switch (position) {
|
|
41
|
-
case "top": {
|
|
42
|
-
return topPosition > 0 ? [offsetX, anchorTop - popoverHeight - marginY] : [offsetX, anchorTop + anchorRect.height];
|
|
43
|
-
}
|
|
44
|
-
case "bottom": {
|
|
45
|
-
return bottomPosition < docHeight || topPosition < 0 ? [offsetX, anchorTop + anchorRect.height] : [offsetX, anchorTop - popoverHeight - marginY];
|
|
81
|
+
const { documentElement } = document;
|
|
82
|
+
return computePopoverPosition({
|
|
83
|
+
placement,
|
|
84
|
+
anchor: anchorRect,
|
|
85
|
+
popover: {
|
|
86
|
+
width,
|
|
87
|
+
height,
|
|
88
|
+
margin: {
|
|
89
|
+
top: cssValueToNumber(popoverStyles.getPropertyValue("margin-top")),
|
|
90
|
+
right: cssValueToNumber(popoverStyles.getPropertyValue("margin-right")),
|
|
91
|
+
bottom: cssValueToNumber(
|
|
92
|
+
popoverStyles.getPropertyValue("margin-bottom")
|
|
93
|
+
),
|
|
94
|
+
left: cssValueToNumber(popoverStyles.getPropertyValue("margin-left"))
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
viewport: {
|
|
98
|
+
width: documentElement.clientWidth,
|
|
99
|
+
height: documentElement.clientHeight,
|
|
100
|
+
scrollX: documentElement.scrollLeft,
|
|
101
|
+
scrollY: documentElement.scrollTop
|
|
46
102
|
}
|
|
47
|
-
|
|
48
|
-
return leftPosition > docWidth || leftPosition > 0 ? [anchorLeft - popoverWidth - marginX, offsetY] : [anchorLeft + anchorRect.width, offsetY];
|
|
49
|
-
}
|
|
50
|
-
case "right": {
|
|
51
|
-
return rightPosition < docWidth || leftPosition < 0 ? [anchorLeft + anchorRect.width, offsetY] : [anchorLeft - popoverWidth - marginX, offsetY];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
103
|
+
});
|
|
54
104
|
}
|
|
55
105
|
export {
|
|
106
|
+
computePopoverPosition,
|
|
56
107
|
getPopoverPosition
|
|
57
108
|
};
|
|
@@ -3,6 +3,14 @@ import { PopoverProps } from '../Popover/Popover.js';
|
|
|
3
3
|
type ReactElement = React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
4
4
|
type TooltipTheme = ComponentThemes['tooltip'];
|
|
5
5
|
export type TooltipProps = {
|
|
6
|
+
/**
|
|
7
|
+
* Side of the child to open on, and which of its edges to line up with
|
|
8
|
+
* @default 'top'
|
|
9
|
+
*/
|
|
10
|
+
placement?: PopoverProps['placement'];
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use `placement`, which wins when both are passed
|
|
13
|
+
*/
|
|
6
14
|
position?: PopoverProps['position'];
|
|
7
15
|
children: ReactElement;
|
|
8
16
|
content: React.ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../../src/components/overlay/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAY9B,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEnE,KAAK,YAAY,GAAG,KAAK,CAAC,YAAY,CAEpC,GAAG,EAEH,MAAM,GAAG,KAAK,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAC1C,CAAC;AAEF,KAAK,YAAY,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;AAE/C,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;IACpC,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,MAAM,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC;CAC7C,GAAG,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,EAAE,KAAK,GAAG,UAAU,CAAC,CAAC;AAE/D,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../../src/components/overlay/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAY9B,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEnE,KAAK,YAAY,GAAG,KAAK,CAAC,YAAY,CAEpC,GAAG,EAEH,MAAM,GAAG,KAAK,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAC1C,CAAC;AAEF,KAAK,YAAY,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;AAE/C,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,SAAS,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;IACpC,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,MAAM,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC;CAC7C,GAAG,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,EAAE,KAAK,GAAG,UAAU,CAAC,CAAC;AAE/D,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAgF1C,CAAC"}
|
|
@@ -5,7 +5,8 @@ import { useId, useRef, useState, useEffect, Children, isValidElement, cloneElem
|
|
|
5
5
|
import { useComponentStyles } from "../../../hooks/useComponentStyles/useComponentStyles.js";
|
|
6
6
|
import { Popover } from "../Popover/Popover.js";
|
|
7
7
|
const Tooltip = ({
|
|
8
|
-
|
|
8
|
+
placement,
|
|
9
|
+
position,
|
|
9
10
|
children,
|
|
10
11
|
content,
|
|
11
12
|
intent
|
|
@@ -61,7 +62,7 @@ const Tooltip = ({
|
|
|
61
62
|
onRequestClose: () => {
|
|
62
63
|
setOpen(false);
|
|
63
64
|
},
|
|
64
|
-
position,
|
|
65
|
+
placement: placement ?? position,
|
|
65
66
|
className: tooltipClassName,
|
|
66
67
|
children: content
|
|
67
68
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestCloseReason.d.ts","sourceRoot":"","sources":["../../../src/components/overlay/requestCloseReason.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { RequestCloseReason } from './requestCloseReason.js';
|
|
2
|
+
type DialogContextValue = {
|
|
3
|
+
setEnabled: (active: boolean) => void;
|
|
4
|
+
};
|
|
5
|
+
export declare const DialogContext: import('react').Context<DialogContextValue | undefined>;
|
|
6
|
+
export declare const useNestedDialog: (open: boolean) => boolean;
|
|
7
|
+
type UseDialogCloseRequestsOptions = {
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
onRequestClose: (reason: RequestCloseReason) => void;
|
|
10
|
+
onKeyDown?: React.KeyboardEventHandler<HTMLDialogElement>;
|
|
11
|
+
onKeyDownCapture?: React.KeyboardEventHandler<HTMLDialogElement>;
|
|
12
|
+
onCancel?: React.ReactEventHandler<HTMLDialogElement>;
|
|
13
|
+
};
|
|
14
|
+
type UseModalOverlayOptions = Omit<UseDialogCloseRequestsOptions, 'enabled'> & {
|
|
15
|
+
open: boolean;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The behaviour Dialog and Drawer share while open: focus is restored when
|
|
19
|
+
* closed, the body does not scroll, and an Escape, close request or click
|
|
20
|
+
* outside requests to close.
|
|
21
|
+
*
|
|
22
|
+
* While a nested Dialog or Drawer is open, the outer one ignores Escape and
|
|
23
|
+
* clicks outside, and leaves the body scroll lock to the outermost one.
|
|
24
|
+
* Provide `contextValue` through DialogContext to the dialog's content.
|
|
25
|
+
*/
|
|
26
|
+
export declare const useModalOverlay: (dialogRef: React.RefObject<HTMLDialogElement | null>, { open, onRequestClose, ...handlers }: UseModalOverlayOptions) => {
|
|
27
|
+
contextValue: DialogContextValue;
|
|
28
|
+
closeRequestProps: {
|
|
29
|
+
onKeyDown: (event: React.KeyboardEvent<HTMLDialogElement>) => void;
|
|
30
|
+
onKeyDownCapture: (event: React.KeyboardEvent<HTMLDialogElement>) => void;
|
|
31
|
+
onCancel: (event: React.SyntheticEvent<HTMLDialogElement>) => void;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=useModalOverlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useModalOverlay.d.ts","sourceRoot":"","sources":["../../../src/components/overlay/useModalOverlay.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,KAAK,kBAAkB,GAAG;IACxB,UAAU,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC,CAAC;AAEF,eAAO,MAAM,aAAa,yDAEzB,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,MAAM,OAAO,KAAG,OAgB/C,CAAC;AAEF,KAAK,6BAA6B,GAAG;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACrD,SAAS,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;IAC1D,gBAAgB,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;IACjE,QAAQ,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;CACvD,CAAC;AA6EF,KAAK,sBAAsB,GAAG,IAAI,CAAC,6BAA6B,EAAE,SAAS,CAAC,GAAG;IAC7E,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAC1B,WAAW,KAAK,CAAC,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,EACpD,uCAAuC,sBAAsB;;;2BA/D/B,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC;kCAR3D,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC;0BA2BlB,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC;;CAqErE,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState, createContext, useContext, useEffect, useRef } from "react";
|
|
3
|
+
import { useClickOutside } from "../../hooks/useClickOutside/useClickOutside.js";
|
|
4
|
+
import { usePreventBodyScroll } from "../../hooks/usePreventBodyScroll/usePreventBodyScroll.js";
|
|
5
|
+
import { useRestoreFocus } from "../../hooks/useRestoreFocus/useRestoreFocus.js";
|
|
6
|
+
const DialogContext = createContext(
|
|
7
|
+
void 0
|
|
8
|
+
);
|
|
9
|
+
const useNestedDialog = (open) => {
|
|
10
|
+
const parentDialog = useContext(DialogContext);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!parentDialog || !open) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
parentDialog.setEnabled(false);
|
|
16
|
+
return () => {
|
|
17
|
+
parentDialog.setEnabled(true);
|
|
18
|
+
};
|
|
19
|
+
}, [parentDialog, open]);
|
|
20
|
+
return !!parentDialog;
|
|
21
|
+
};
|
|
22
|
+
const useDialogCloseRequests = ({
|
|
23
|
+
enabled,
|
|
24
|
+
onRequestClose,
|
|
25
|
+
onKeyDown,
|
|
26
|
+
onKeyDownCapture,
|
|
27
|
+
onCancel
|
|
28
|
+
}) => {
|
|
29
|
+
const stoppedEscapeRef = useRef(null);
|
|
30
|
+
const handleKeyDownCapture = (event) => {
|
|
31
|
+
onKeyDownCapture?.(event);
|
|
32
|
+
stoppedEscapeRef.current = event.key === "Escape" ? event.nativeEvent : null;
|
|
33
|
+
};
|
|
34
|
+
const handleKeyDown = (event) => {
|
|
35
|
+
onKeyDown?.(event);
|
|
36
|
+
if (event.key !== "Escape") {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
stoppedEscapeRef.current = null;
|
|
40
|
+
if (!enabled || event.defaultPrevented) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
onRequestClose("escape");
|
|
45
|
+
};
|
|
46
|
+
const handleCancel = (event) => {
|
|
47
|
+
onCancel?.(event);
|
|
48
|
+
if (event.target !== event.currentTarget) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
const stoppedEscape = stoppedEscapeRef.current;
|
|
53
|
+
const claimed = stoppedEscape !== null && !stoppedEscape.defaultPrevented;
|
|
54
|
+
stoppedEscapeRef.current = null;
|
|
55
|
+
if (enabled && !claimed) {
|
|
56
|
+
onRequestClose("escape");
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
onKeyDown: handleKeyDown,
|
|
61
|
+
onKeyDownCapture: handleKeyDownCapture,
|
|
62
|
+
onCancel: handleCancel
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
const useModalOverlay = (dialogRef, { open, onRequestClose, ...handlers }) => {
|
|
66
|
+
const [enabled, setEnabled] = useState(true);
|
|
67
|
+
const [contextValue] = useState(() => ({ setEnabled }));
|
|
68
|
+
useRestoreFocus(open);
|
|
69
|
+
const isNested = useNestedDialog(open);
|
|
70
|
+
usePreventBodyScroll(open && !isNested);
|
|
71
|
+
useClickOutside(dialogRef, () => onRequestClose("outside-click"), {
|
|
72
|
+
enabled: open && enabled
|
|
73
|
+
});
|
|
74
|
+
const closeRequestProps = useDialogCloseRequests({
|
|
75
|
+
enabled: open && enabled,
|
|
76
|
+
onRequestClose,
|
|
77
|
+
...handlers
|
|
78
|
+
});
|
|
79
|
+
return { contextValue, closeRequestProps };
|
|
80
|
+
};
|
|
81
|
+
export {
|
|
82
|
+
DialogContext,
|
|
83
|
+
useModalOverlay,
|
|
84
|
+
useNestedDialog
|
|
85
|
+
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { HTMLElementProps, MarginAtoms, PaddingAtoms, TextAtoms } from '@blockle/blocks-core';
|
|
2
2
|
import { TextColor } from '../textColor.js';
|
|
3
|
+
import { TextOverflowProps } from '../textOverflow.js';
|
|
3
4
|
export type HeadingProps = {
|
|
4
5
|
className?: string;
|
|
5
6
|
/** A text Color role, which follows the Color mode, or a fixed Palette color. */
|
|
6
7
|
color?: TextColor;
|
|
7
8
|
level?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
8
|
-
} & HTMLElementProps<HTMLHeadingElement> & Omit<TextAtoms, 'color'> & MarginAtoms & PaddingAtoms;
|
|
9
|
+
} & TextOverflowProps & HTMLElementProps<HTMLHeadingElement> & Omit<TextAtoms, 'color'> & MarginAtoms & PaddingAtoms;
|
|
9
10
|
export declare const Heading: React.FC<HeadingProps>;
|
|
10
11
|
//# sourceMappingURL=Heading.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Heading.d.ts","sourceRoot":"","sources":["../../../../src/components/typography/Heading/Heading.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,sBAAsB,CAAC;AAI9B,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"Heading.d.ts","sourceRoot":"","sources":["../../../../src/components/typography/Heading/Heading.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,sBAAsB,CAAC;AAI9B,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,iBAAiB,CAAC;AAChE,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,oBAAoB,CAAC;AAG5B,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iFAAiF;IACjF,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CAC/B,GAAG,iBAAiB,GACnB,gBAAgB,CAAC,kBAAkB,CAAC,GACpC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,GACxB,WAAW,GACX,YAAY,CAAC;AAEf,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA8B1C,CAAC"}
|
|
@@ -3,11 +3,14 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { classnames } from "@blockle/blocks-core";
|
|
4
4
|
import { useComponentStyles } from "../../../hooks/useComponentStyles/useComponentStyles.js";
|
|
5
5
|
import { Box } from "../../layout/Box/Box.js";
|
|
6
|
+
import { textOverflowClassName } from "../textOverflow.js";
|
|
6
7
|
import { heading } from "./heading.css.js";
|
|
7
8
|
const Heading = ({
|
|
8
9
|
className,
|
|
9
10
|
color,
|
|
10
11
|
level = 1,
|
|
12
|
+
lineClamp,
|
|
13
|
+
truncate,
|
|
11
14
|
children,
|
|
12
15
|
...restProps
|
|
13
16
|
}) => {
|
|
@@ -20,7 +23,12 @@ const Heading = ({
|
|
|
20
23
|
Box,
|
|
21
24
|
{
|
|
22
25
|
asChild: true,
|
|
23
|
-
className: classnames(
|
|
26
|
+
className: classnames(
|
|
27
|
+
heading,
|
|
28
|
+
themeClassName,
|
|
29
|
+
textOverflowClassName("Heading", { lineClamp, truncate }),
|
|
30
|
+
className
|
|
31
|
+
),
|
|
24
32
|
color,
|
|
25
33
|
...restProps,
|
|
26
34
|
children: /* @__PURE__ */ jsx(Tag, { children })
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HTMLElementProps, MarginAtoms, PaddingAtoms, TextAtoms } from '@blockle/blocks-core';
|
|
2
2
|
import { default as React } from 'react';
|
|
3
3
|
import { TextColor } from '../textColor.js';
|
|
4
|
+
import { TextOverflowProps } from '../textOverflow.js';
|
|
4
5
|
type Tags = 'cite' | 'code' | 'del' | 'em' | 'ins' | 'kbd' | 'label' | 'mark' | 'p' | 'q' | 's' | 'small' | 'span' | 'strong' | 'sub' | 'sup';
|
|
5
6
|
export type TextProps<Tag extends Tags = 'span'> = {
|
|
6
7
|
asChild?: boolean;
|
|
@@ -9,7 +10,7 @@ export type TextProps<Tag extends Tags = 'span'> = {
|
|
|
9
10
|
tag?: Tag;
|
|
10
11
|
/** A text Color role, which follows the Color mode, or a fixed Palette color. */
|
|
11
12
|
color?: TextColor;
|
|
12
|
-
} & Omit<HTMLElementProps<HTMLSpanElement>, 'children' | 'ref'> & Omit<TextAtoms, 'color'> & MarginAtoms & PaddingAtoms;
|
|
13
|
-
export declare const Text: <T extends Tags = "span">({ asChild, children, className, color, ref, tag, ...restProps }: TextProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
} & TextOverflowProps & Omit<HTMLElementProps<HTMLSpanElement>, 'children' | 'ref'> & Omit<TextAtoms, 'color'> & MarginAtoms & PaddingAtoms;
|
|
14
|
+
export declare const Text: <T extends Tags = "span">({ asChild, children, className, color, lineClamp, ref, tag, truncate, ...restProps }: TextProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
14
15
|
export {};
|
|
15
16
|
//# sourceMappingURL=Text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../../src/components/typography/Text/Text.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../../src/components/typography/Text/Text.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,iBAAiB,CAAC;AAChE,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,oBAAoB,CAAC;AAG5B,KAAK,IAAI,GACL,MAAM,GACN,MAAM,GACN,KAAK,GACL,IAAI,GACJ,KAAK,GACL,KAAK,GACL,OAAO,GACP,MAAM,GACN,GAAG,GACH,GAAG,GACH,GAAG,GACH,OAAO,GACP,MAAM,GACN,QAAQ,GACR,KAAK,GACL,KAAK,CAAC;AAEV,MAAM,MAAM,SAAS,CAAC,GAAG,SAAS,IAAI,GAAG,MAAM,IAAI;IACjD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5C,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,iFAAiF;IACjF,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,GAAG,iBAAiB,GACnB,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,EAAE,UAAU,GAAG,KAAK,CAAC,GAC3D,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,GACxB,WAAW,GACX,YAAY,CAAC;AAEf,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,IAAI,GAAG,MAAM,EAAE,sFAU3C,SAAS,CAAC,CAAC,CAAC,4CA2Bd,CAAC"}
|