@seed-design/lynx-react 0.7.1 → 0.9.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/lib/components/Accordion/Accordion.jsx +2 -2
- package/lib/components/ActionButton/ActionButton.jsx +1 -1
- package/lib/components/AlertDialog/AlertDialog.d.ts +64 -0
- package/lib/components/AlertDialog/AlertDialog.d.ts.map +1 -0
- package/lib/components/AlertDialog/AlertDialog.jsx +138 -0
- package/lib/components/AlertDialog/AlertDialog.namespace.d.ts +2 -0
- package/lib/components/AlertDialog/AlertDialog.namespace.d.ts.map +1 -0
- package/lib/components/AlertDialog/AlertDialog.namespace.js +17 -0
- package/lib/components/AlertDialog/index.d.ts +3 -0
- package/lib/components/AlertDialog/index.d.ts.map +1 -0
- package/lib/components/AppBar/AppBar.d.ts +14 -1
- package/lib/components/AppBar/AppBar.d.ts.map +1 -1
- package/lib/components/AppBar/AppBar.jsx +42 -16
- package/lib/components/AppBar/AppBar.namespace.d.ts +1 -1
- package/lib/components/AppBar/AppBar.namespace.d.ts.map +1 -1
- package/lib/components/AppBar/context.d.ts +2 -1
- package/lib/components/AppBar/context.d.ts.map +1 -1
- package/lib/components/AppBar/index.d.ts +1 -1
- package/lib/components/AppBar/index.d.ts.map +1 -1
- package/lib/components/AppBar/useAppBar.d.ts +2 -1
- package/lib/components/AppBar/useAppBar.d.ts.map +1 -1
- package/lib/components/AppBar/useAppBar.js +17 -15
- package/lib/components/AttachmentDisplay/AttachmentDisplay.d.ts +182 -0
- package/lib/components/AttachmentDisplay/AttachmentDisplay.d.ts.map +1 -0
- package/lib/components/AttachmentDisplay/AttachmentDisplay.jsx +444 -0
- package/lib/components/AttachmentDisplay/index.d.ts +2 -0
- package/lib/components/AttachmentDisplay/index.d.ts.map +1 -0
- package/lib/components/AttachmentInput/AttachmentInput.d.ts +179 -0
- package/lib/components/AttachmentInput/AttachmentInput.d.ts.map +1 -0
- package/lib/components/AttachmentInput/AttachmentInput.jsx +520 -0
- package/lib/components/AttachmentInput/index.d.ts +2 -0
- package/lib/components/AttachmentInput/index.d.ts.map +1 -0
- package/lib/components/BottomSheet/BottomSheet.d.ts +1 -1
- package/lib/components/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/lib/components/BottomSheet/BottomSheet.jsx +1 -7
- package/lib/components/Box/Box.d.ts +3 -3
- package/lib/components/Box/Box.d.ts.map +1 -1
- package/lib/components/Callout/Callout.jsx +2 -2
- package/lib/components/Checkbox/Checkbox.jsx +2 -2
- package/lib/components/Chip/Chip.jsx +2 -2
- package/lib/components/ChipTabs/ChipTabs.d.ts +41 -0
- package/lib/components/ChipTabs/ChipTabs.d.ts.map +1 -0
- package/lib/components/ChipTabs/ChipTabs.jsx +39 -0
- package/lib/components/ChipTabs/ChipTabs.namespace.d.ts +2 -0
- package/lib/components/ChipTabs/ChipTabs.namespace.d.ts.map +1 -0
- package/lib/components/ChipTabs/ChipTabs.namespace.js +13 -0
- package/lib/components/ChipTabs/index.d.ts +3 -0
- package/lib/components/ChipTabs/index.d.ts.map +1 -0
- package/lib/components/ContextualFloatingButton/ContextualFloatingButton.d.ts +18 -0
- package/lib/components/ContextualFloatingButton/ContextualFloatingButton.d.ts.map +1 -0
- package/lib/components/ContextualFloatingButton/ContextualFloatingButton.jsx +113 -0
- package/lib/components/ContextualFloatingButton/index.d.ts +2 -0
- package/lib/components/ContextualFloatingButton/index.d.ts.map +1 -0
- package/lib/components/Dialog/Dialog.d.ts +87 -0
- package/lib/components/Dialog/Dialog.d.ts.map +1 -0
- package/lib/components/Dialog/Dialog.jsx +147 -0
- package/lib/components/Dialog/Dialog.namespace.d.ts +2 -0
- package/lib/components/Dialog/Dialog.namespace.d.ts.map +1 -0
- package/lib/components/Dialog/Dialog.namespace.js +18 -0
- package/lib/components/Dialog/index.d.ts +3 -0
- package/lib/components/Dialog/index.d.ts.map +1 -0
- package/lib/components/FloatingActionButton/FloatingActionButton.d.ts +23 -0
- package/lib/components/FloatingActionButton/FloatingActionButton.d.ts.map +1 -0
- package/lib/components/FloatingActionButton/FloatingActionButton.jsx +76 -0
- package/lib/components/FloatingActionButton/FloatingActionButton.namespace.d.ts +2 -0
- package/lib/components/FloatingActionButton/FloatingActionButton.namespace.d.ts.map +1 -0
- package/lib/components/FloatingActionButton/FloatingActionButton.namespace.js +10 -0
- package/lib/components/FloatingActionButton/index.d.ts +3 -0
- package/lib/components/FloatingActionButton/index.d.ts.map +1 -0
- package/lib/components/HelpBubble/HelpBubble.d.ts +67 -0
- package/lib/components/HelpBubble/HelpBubble.d.ts.map +1 -0
- package/lib/components/HelpBubble/HelpBubble.jsx +600 -0
- package/lib/components/HelpBubble/HelpBubble.namespace.d.ts +2 -0
- package/lib/components/HelpBubble/HelpBubble.namespace.d.ts.map +1 -0
- package/lib/components/HelpBubble/HelpBubble.namespace.js +18 -0
- package/lib/components/HelpBubble/index.d.ts +3 -0
- package/lib/components/HelpBubble/index.d.ts.map +1 -0
- package/lib/components/Icon/Icon.d.ts +1 -0
- package/lib/components/Icon/Icon.d.ts.map +1 -1
- package/lib/components/Icon/Icon.jsx +2 -1
- package/lib/components/IdentityPlaceholder/IdentityPlaceholder.d.ts +28 -0
- package/lib/components/IdentityPlaceholder/IdentityPlaceholder.d.ts.map +1 -0
- package/lib/components/IdentityPlaceholder/IdentityPlaceholder.jsx +37 -0
- package/lib/components/IdentityPlaceholder/IdentityPlaceholder.namespace.d.ts +2 -0
- package/lib/components/IdentityPlaceholder/IdentityPlaceholder.namespace.d.ts.map +1 -0
- package/lib/components/IdentityPlaceholder/IdentityPlaceholder.namespace.js +9 -0
- package/lib/components/IdentityPlaceholder/identity-placeholder-business.js +4 -0
- package/lib/components/IdentityPlaceholder/identity-placeholder-person.js +4 -0
- package/lib/components/IdentityPlaceholder/index.d.ts +3 -0
- package/lib/components/IdentityPlaceholder/index.d.ts.map +1 -0
- package/lib/components/InputButton/InputButton.d.ts +2 -0
- package/lib/components/InputButton/InputButton.d.ts.map +1 -1
- package/lib/components/InputButton/InputButton.jsx +40 -8
- package/lib/components/List/List.d.ts +1 -1
- package/lib/components/List/List.d.ts.map +1 -1
- package/lib/components/List/List.jsx +26 -12
- package/lib/components/Menu/Menu.d.ts.map +1 -1
- package/lib/components/Menu/Menu.jsx +15 -5
- package/lib/components/PageBanner/PageBanner.d.ts +3 -0
- package/lib/components/PageBanner/PageBanner.d.ts.map +1 -1
- package/lib/components/PageBanner/PageBanner.jsx +49 -11
- package/lib/components/QuantityPicker/QuantityPicker.d.ts +53 -0
- package/lib/components/QuantityPicker/QuantityPicker.d.ts.map +1 -0
- package/lib/components/QuantityPicker/QuantityPicker.jsx +282 -0
- package/lib/components/QuantityPicker/QuantityPicker.namespace.d.ts +2 -0
- package/lib/components/QuantityPicker/QuantityPicker.namespace.d.ts.map +1 -0
- package/lib/components/QuantityPicker/QuantityPicker.namespace.js +11 -0
- package/lib/components/QuantityPicker/index.d.ts +3 -0
- package/lib/components/QuantityPicker/index.d.ts.map +1 -0
- package/lib/components/RadioGroup/RadioGroup.jsx +2 -2
- package/lib/components/ReactionButton/ReactionButton.d.ts +1 -1
- package/lib/components/ReactionButton/ReactionButton.d.ts.map +1 -1
- package/lib/components/ReactionButton/ReactionButton.jsx +22 -13
- package/lib/components/ScrollFog/ScrollFog.d.ts +41 -0
- package/lib/components/ScrollFog/ScrollFog.d.ts.map +1 -0
- package/lib/components/ScrollFog/ScrollFog.jsx +65 -0
- package/lib/components/ScrollFog/index.d.ts +2 -0
- package/lib/components/ScrollFog/index.d.ts.map +1 -0
- package/lib/components/SegmentedControl/SegmentedControl.jsx +2 -2
- package/lib/components/Select/Select.d.ts +112 -0
- package/lib/components/Select/Select.d.ts.map +1 -0
- package/lib/components/Select/Select.jsx +885 -0
- package/lib/components/Select/Select.namespace.d.ts +2 -0
- package/lib/components/Select/Select.namespace.d.ts.map +1 -0
- package/lib/components/Select/Select.namespace.js +23 -0
- package/lib/components/Select/index.d.ts +3 -0
- package/lib/components/Select/index.d.ts.map +1 -0
- package/lib/components/Skeleton/Skeleton.d.ts +15 -0
- package/lib/components/Skeleton/Skeleton.d.ts.map +1 -0
- package/lib/components/Skeleton/Skeleton.jsx +18 -0
- package/lib/components/Skeleton/index.d.ts +2 -0
- package/lib/components/Skeleton/index.d.ts.map +1 -0
- package/lib/components/Slider/Slider.d.ts +101 -0
- package/lib/components/Slider/Slider.d.ts.map +1 -0
- package/lib/components/Slider/Slider.jsx +573 -0
- package/lib/components/Slider/Slider.namespace.d.ts +2 -0
- package/lib/components/Slider/Slider.namespace.d.ts.map +1 -0
- package/lib/components/Slider/Slider.namespace.js +19 -0
- package/lib/components/Slider/Slider.utils.d.ts +19 -0
- package/lib/components/Slider/Slider.utils.d.ts.map +1 -0
- package/lib/components/Slider/Slider.utils.js +106 -0
- package/lib/components/Slider/index.d.ts +3 -0
- package/lib/components/Slider/index.d.ts.map +1 -0
- package/lib/components/Stack/Stack.d.ts +7 -9
- package/lib/components/Stack/Stack.d.ts.map +1 -1
- package/lib/components/SwipeableMenuSheet/SwipeableMenuSheet.d.ts.map +1 -1
- package/lib/components/SwipeableMenuSheet/SwipeableMenuSheet.jsx +22 -8
- package/lib/components/Switch/Switch.d.ts.map +1 -1
- package/lib/components/Switch/Switch.jsx +5 -3
- package/lib/components/Tabs/Tabs.d.ts +34 -2
- package/lib/components/Tabs/Tabs.d.ts.map +1 -1
- package/lib/components/Tabs/Tabs.jsx +186 -56
- package/lib/components/Tabs/Tabs.utils.d.ts +14 -1
- package/lib/components/Tabs/Tabs.utils.d.ts.map +1 -1
- package/lib/components/Tabs/Tabs.utils.js +24 -3
- package/lib/components/Tabs/index.d.ts +1 -1
- package/lib/components/Tabs/index.d.ts.map +1 -1
- package/lib/components/index.d.ts +14 -0
- package/lib/components/index.d.ts.map +1 -1
- package/lib/hooks/useControllableState.d.ts +1 -14
- package/lib/hooks/useControllableState.d.ts.map +1 -1
- package/lib/hooks/usePressTap.d.ts +1 -27
- package/lib/hooks/usePressTap.d.ts.map +1 -1
- package/lib/hooks/useSafeArea.d.ts +8 -4
- package/lib/hooks/useSafeArea.d.ts.map +1 -1
- package/lib/hooks/useSafeArea.js +22 -20
- package/lib/index.js +29 -6
- package/lib/{hooks/useControllableState.js → packages/lynx-react-headless/use-controllable-state/lib/index.js} +2 -3
- package/lib/{hooks/usePressTap.js → packages/lynx-react-headless/use-press-tap/lib/index.js} +13 -10
- package/lib/types.d.ts +1 -0
- package/lib/types.d.ts.map +1 -1
- package/lib/utils/styled.d.ts +46 -6
- package/lib/utils/styled.d.ts.map +1 -1
- package/lib/utils/styled.js +19 -4
- package/package.json +9 -5
- package/src/components/AlertDialog/AlertDialog.namespace.ts +22 -0
- package/src/components/AlertDialog/AlertDialog.test.tsx +226 -0
- package/src/components/AlertDialog/AlertDialog.tsx +374 -0
- package/src/components/AlertDialog/index.ts +24 -0
- package/src/components/AppBar/AppBar.namespace.ts +1 -0
- package/src/components/AppBar/AppBar.test.tsx +252 -3
- package/src/components/AppBar/AppBar.tsx +108 -25
- package/src/components/AppBar/context.ts +3 -1
- package/src/components/AppBar/index.ts +1 -0
- package/src/components/AppBar/useAppBar.ts +21 -15
- package/src/components/AttachmentDisplay/AttachmentDisplay.tsx +886 -0
- package/src/components/AttachmentDisplay/index.ts +48 -0
- package/src/components/AttachmentInput/AttachmentInput.tsx +1001 -0
- package/src/components/AttachmentInput/index.ts +49 -0
- package/src/components/BottomSheet/BottomSheet.test.tsx +22 -7
- package/src/components/BottomSheet/BottomSheet.tsx +1 -19
- package/src/components/Box/Box.test.tsx +104 -0
- package/src/components/Box/Box.tsx +9 -6
- package/src/components/ChipTabs/ChipTabs.namespace.ts +14 -0
- package/src/components/ChipTabs/ChipTabs.tsx +119 -0
- package/src/components/ChipTabs/index.ts +16 -0
- package/src/components/ContextualFloatingButton/ContextualFloatingButton.test.tsx +63 -0
- package/src/components/ContextualFloatingButton/ContextualFloatingButton.tsx +232 -0
- package/src/components/ContextualFloatingButton/index.ts +4 -0
- package/src/components/Dialog/Dialog.namespace.ts +24 -0
- package/src/components/Dialog/Dialog.test.tsx +172 -0
- package/src/components/Dialog/Dialog.tsx +373 -0
- package/src/components/Dialog/index.ts +26 -0
- package/src/components/FloatingActionButton/FloatingActionButton.namespace.ts +8 -0
- package/src/components/FloatingActionButton/FloatingActionButton.test.tsx +59 -0
- package/src/components/FloatingActionButton/FloatingActionButton.tsx +207 -0
- package/src/components/FloatingActionButton/index.ts +10 -0
- package/src/components/HelpBubble/HelpBubble.namespace.ts +24 -0
- package/src/components/HelpBubble/HelpBubble.tsx +998 -0
- package/src/components/HelpBubble/index.ts +26 -0
- package/src/components/Icon/Icon.test.tsx +0 -3
- package/src/components/Icon/Icon.tsx +11 -1
- package/src/components/IdentityPlaceholder/IdentityPlaceholder.namespace.ts +6 -0
- package/src/components/IdentityPlaceholder/IdentityPlaceholder.tsx +103 -0
- package/src/components/IdentityPlaceholder/assets.d.ts +4 -0
- package/src/components/IdentityPlaceholder/identity-placeholder-business.webp +0 -0
- package/src/components/IdentityPlaceholder/identity-placeholder-person.webp +0 -0
- package/src/components/IdentityPlaceholder/index.ts +8 -0
- package/src/components/InputButton/InputButton.test.tsx +128 -1
- package/src/components/InputButton/InputButton.tsx +60 -9
- package/src/components/List/List.test.tsx +54 -2
- package/src/components/List/List.tsx +43 -10
- package/src/components/Menu/Menu.tsx +14 -4
- package/src/components/Menu/__tests__/Menu.test.tsx +34 -0
- package/src/components/PageBanner/PageBanner.test.tsx +110 -3
- package/src/components/PageBanner/PageBanner.tsx +83 -19
- package/src/components/QuantityPicker/QuantityPicker.namespace.ts +10 -0
- package/src/components/QuantityPicker/QuantityPicker.test.tsx +235 -0
- package/src/components/QuantityPicker/QuantityPicker.tsx +605 -0
- package/src/components/QuantityPicker/index.ts +14 -0
- package/src/components/ReactionButton/ReactionButton.feedback.test.tsx +50 -0
- package/src/components/ReactionButton/ReactionButton.test.tsx +5 -3
- package/src/components/ReactionButton/ReactionButton.tsx +20 -12
- package/src/components/ScrollFog/ScrollFog.test.tsx +222 -0
- package/src/components/ScrollFog/ScrollFog.tsx +172 -0
- package/src/components/ScrollFog/index.ts +1 -0
- package/src/components/Select/Select.namespace.ts +34 -0
- package/src/components/Select/Select.test.tsx +297 -0
- package/src/components/Select/Select.tsx +1483 -0
- package/src/components/Select/index.ts +39 -0
- package/src/components/Skeleton/Skeleton.test.tsx +64 -0
- package/src/components/Skeleton/Skeleton.tsx +45 -0
- package/src/components/Skeleton/index.ts +1 -0
- package/src/components/Slider/Slider.namespace.ts +26 -0
- package/src/components/Slider/Slider.test.tsx +260 -0
- package/src/components/Slider/Slider.tsx +897 -0
- package/src/components/Slider/Slider.utils.ts +167 -0
- package/src/components/Slider/index.ts +30 -0
- package/src/components/Stack/Stack.test.tsx +7 -0
- package/src/components/Stack/Stack.tsx +11 -10
- package/src/components/SwipeableMenuSheet/SwipeableMenuSheet.test.tsx +21 -1
- package/src/components/SwipeableMenuSheet/SwipeableMenuSheet.tsx +30 -7
- package/src/components/Switch/Switch.tsx +14 -13
- package/src/components/Tabs/Tabs.test.tsx +218 -1
- package/src/components/Tabs/Tabs.tsx +346 -75
- package/src/components/Tabs/Tabs.utils.ts +51 -1
- package/src/components/Tabs/index.ts +17 -1
- package/src/components/index.ts +14 -0
- package/src/hooks/useControllableState.ts +1 -43
- package/src/hooks/usePressTap.test.ts +23 -11
- package/src/hooks/usePressTap.ts +1 -60
- package/src/hooks/useSafeArea.test.ts +13 -1
- package/src/hooks/useSafeArea.ts +25 -23
- package/src/types.ts +1 -0
- package/src/utils/styled.ts +127 -9
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
import { useControllableState } from "../../packages/lynx-react-headless/use-controllable-state/lib/index.js";
|
|
2
|
+
import { usePressTap } from "../../packages/lynx-react-headless/use-press-tap/lib/index.js";
|
|
3
|
+
import { mergeProps } from "../../utils/merge-props.js";
|
|
4
|
+
import { createSlotRecipeContext } from "../../utils/create-slot-recipe-context.jsx";
|
|
5
|
+
import { useStyleProps } from "../../utils/styled.js";
|
|
6
|
+
import { computePosition } from "../private/Positioning.js";
|
|
7
|
+
import * as React from "@lynx-js/react";
|
|
8
|
+
import clsx from "clsx";
|
|
9
|
+
import { getRectByRef } from "@lynx-js/lynx-ui-common";
|
|
10
|
+
import { helpBubble } from "@seed-design/lynx-css/recipes/help-bubble";
|
|
11
|
+
//#region src/components/HelpBubble/HelpBubble.tsx
|
|
12
|
+
var { ClassNamesProvider, useClassNames } = createSlotRecipeContext(helpBubble);
|
|
13
|
+
var HelpBubbleContext = React.createContext(null);
|
|
14
|
+
function useHelpBubbleContext(consumer) {
|
|
15
|
+
const context = React.useContext(HelpBubbleContext);
|
|
16
|
+
if (!context) throw new Error(`<${consumer}/> must be rendered inside <HelpBubbleRoot/>.`);
|
|
17
|
+
return context;
|
|
18
|
+
}
|
|
19
|
+
function mergeNodeRef(forwardedRef, node) {
|
|
20
|
+
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
21
|
+
else if (forwardedRef) forwardedRef.current = node;
|
|
22
|
+
}
|
|
23
|
+
function toPixel(value) {
|
|
24
|
+
return `${value}px`;
|
|
25
|
+
}
|
|
26
|
+
function getLayoutSize(event) {
|
|
27
|
+
const width = event.detail?.width ?? event.params?.width;
|
|
28
|
+
const height = event.detail?.height ?? event.params?.height;
|
|
29
|
+
if (!Number.isFinite(width) || !Number.isFinite(height)) return null;
|
|
30
|
+
return {
|
|
31
|
+
width: Math.max(0, width),
|
|
32
|
+
height: Math.max(0, height)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function hasExitTransition(event) {
|
|
36
|
+
if (event.target.uid !== event.currentTarget.uid) return false;
|
|
37
|
+
return event.params.animation_type === "transition-opacity" || event.params.animation_name === "opacity";
|
|
38
|
+
}
|
|
39
|
+
var EXIT_TRANSITION_FALLBACK_MS = 200;
|
|
40
|
+
function getRootRect() {
|
|
41
|
+
"background only";
|
|
42
|
+
return getRectByRef({ current: lynx.createSelectorQuery().selectRoot() }, true);
|
|
43
|
+
}
|
|
44
|
+
function areStylesEqual(left, right) {
|
|
45
|
+
if (left === right) return true;
|
|
46
|
+
if (!left || !right) return false;
|
|
47
|
+
const leftEntries = Object.entries(left);
|
|
48
|
+
if (leftEntries.length !== Object.keys(right).length) return false;
|
|
49
|
+
return leftEntries.every(([key, value]) => Object.is(value, right[key]));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @platform Lynx
|
|
53
|
+
*
|
|
54
|
+
* The native implementation uses fixed positioned views rather than DOM portals.
|
|
55
|
+
* `closeOnInteractOutside={false}` has no full-screen hit surface, so other native
|
|
56
|
+
* controls and independently-open HelpBubbles remain interactive.
|
|
57
|
+
*/
|
|
58
|
+
var HelpBubbleRoot = React.forwardRef((props, ref) => {
|
|
59
|
+
const { children, className, style, open: openProp, defaultOpen = false, onOpenChange, placement = "top", gutter = 4, overflowPadding = 16, arrowPadding = 14, flip = true, closeOnInteractOutside = true, ...nativeProps } = props;
|
|
60
|
+
const [open, setOpen] = useControllableState({
|
|
61
|
+
value: openProp,
|
|
62
|
+
defaultValue: defaultOpen
|
|
63
|
+
});
|
|
64
|
+
const [mounted, setMounted] = React.useState(open);
|
|
65
|
+
const [position, setPositionState] = React.useState(null);
|
|
66
|
+
const [positionedEpoch, setPositionedEpoch] = React.useState(null);
|
|
67
|
+
const [referenceRect, setReferenceRect] = React.useState(null);
|
|
68
|
+
const [positionRevision, setPositionRevision] = React.useState(0);
|
|
69
|
+
const positionRevisionRef = React.useRef(0);
|
|
70
|
+
const isOpenRef = React.useRef(open);
|
|
71
|
+
const openEpochRef = React.useRef(0);
|
|
72
|
+
const anchorRef = React.useRef(null);
|
|
73
|
+
const triggerRef = React.useRef(null);
|
|
74
|
+
if (open && !isOpenRef.current) openEpochRef.current += 1;
|
|
75
|
+
isOpenRef.current = open;
|
|
76
|
+
const openEpoch = openEpochRef.current;
|
|
77
|
+
const positioned = positionedEpoch === openEpoch;
|
|
78
|
+
React.useEffect(() => {
|
|
79
|
+
"background only";
|
|
80
|
+
if (open) {
|
|
81
|
+
setMounted(true);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (!positioned) setMounted(false);
|
|
85
|
+
}, [open, positioned]);
|
|
86
|
+
const requestOpen = React.useCallback((nextOpen) => {
|
|
87
|
+
"background only";
|
|
88
|
+
if (nextOpen === open) return;
|
|
89
|
+
setOpen(nextOpen);
|
|
90
|
+
onOpenChange?.(nextOpen);
|
|
91
|
+
}, [
|
|
92
|
+
onOpenChange,
|
|
93
|
+
open,
|
|
94
|
+
setOpen
|
|
95
|
+
]);
|
|
96
|
+
const finishClose = React.useCallback(() => {
|
|
97
|
+
"background only";
|
|
98
|
+
if (!isOpenRef.current) {
|
|
99
|
+
setMounted(false);
|
|
100
|
+
setPositionedEpoch(null);
|
|
101
|
+
setPositionState(null);
|
|
102
|
+
setReferenceRect(null);
|
|
103
|
+
}
|
|
104
|
+
}, []);
|
|
105
|
+
const setPosition = React.useCallback((nextPosition, nextReferenceRect) => {
|
|
106
|
+
setPositionState((previous) => {
|
|
107
|
+
if (previous !== null && nextPosition !== null && previous.left === nextPosition.left && previous.top === nextPosition.top && previous.width === nextPosition.width && previous.height === nextPosition.height && previous.placement === nextPosition.placement && previous.transformOrigin === nextPosition.transformOrigin && previous.availableWidth === nextPosition.availableWidth && previous.availableHeight === nextPosition.availableHeight && previous.arrow?.left === nextPosition.arrow?.left && previous.arrow?.top === nextPosition.arrow?.top && previous.arrow?.centerOffset === nextPosition.arrow?.centerOffset) return previous;
|
|
108
|
+
return nextPosition;
|
|
109
|
+
});
|
|
110
|
+
setReferenceRect((previous) => {
|
|
111
|
+
if (previous !== null && nextReferenceRect !== null && previous.left === nextReferenceRect.left && previous.top === nextReferenceRect.top && previous.right === nextReferenceRect.right && previous.bottom === nextReferenceRect.bottom && previous.width === nextReferenceRect.width && previous.height === nextReferenceRect.height) return previous;
|
|
112
|
+
return nextReferenceRect;
|
|
113
|
+
});
|
|
114
|
+
setPositionedEpoch(nextPosition ? openEpochRef.current : null);
|
|
115
|
+
}, []);
|
|
116
|
+
const resetPosition = React.useCallback(() => {
|
|
117
|
+
setPositionState(null);
|
|
118
|
+
setReferenceRect(null);
|
|
119
|
+
setPositionedEpoch(null);
|
|
120
|
+
}, []);
|
|
121
|
+
const requestPositionUpdate = React.useCallback(() => {
|
|
122
|
+
positionRevisionRef.current += 1;
|
|
123
|
+
setPositionRevision(positionRevisionRef.current);
|
|
124
|
+
}, []);
|
|
125
|
+
const classes = helpBubble({
|
|
126
|
+
open,
|
|
127
|
+
positioned,
|
|
128
|
+
side: position?.placement.split("-")[0],
|
|
129
|
+
pressed: false
|
|
130
|
+
});
|
|
131
|
+
const contextValue = React.useMemo(() => ({
|
|
132
|
+
open,
|
|
133
|
+
mounted,
|
|
134
|
+
positioned,
|
|
135
|
+
side: position?.placement.split("-")[0] ?? "top",
|
|
136
|
+
placement,
|
|
137
|
+
gutter,
|
|
138
|
+
overflowPadding,
|
|
139
|
+
arrowPadding,
|
|
140
|
+
flip,
|
|
141
|
+
closeOnInteractOutside,
|
|
142
|
+
openEpoch,
|
|
143
|
+
isOpenRef,
|
|
144
|
+
openEpochRef,
|
|
145
|
+
anchorRef,
|
|
146
|
+
triggerRef,
|
|
147
|
+
position,
|
|
148
|
+
referenceRect,
|
|
149
|
+
positionRevision,
|
|
150
|
+
positionRevisionRef,
|
|
151
|
+
requestOpen,
|
|
152
|
+
finishClose,
|
|
153
|
+
setPosition,
|
|
154
|
+
resetPosition,
|
|
155
|
+
requestPositionUpdate
|
|
156
|
+
}), [
|
|
157
|
+
arrowPadding,
|
|
158
|
+
closeOnInteractOutside,
|
|
159
|
+
finishClose,
|
|
160
|
+
flip,
|
|
161
|
+
gutter,
|
|
162
|
+
mounted,
|
|
163
|
+
open,
|
|
164
|
+
openEpoch,
|
|
165
|
+
overflowPadding,
|
|
166
|
+
placement,
|
|
167
|
+
position,
|
|
168
|
+
positioned,
|
|
169
|
+
requestOpen,
|
|
170
|
+
resetPosition,
|
|
171
|
+
setPosition,
|
|
172
|
+
referenceRect,
|
|
173
|
+
positionRevisionRef,
|
|
174
|
+
positionRevision,
|
|
175
|
+
requestPositionUpdate
|
|
176
|
+
]);
|
|
177
|
+
return <HelpBubbleContext.Provider value={contextValue}>
|
|
178
|
+
<ClassNamesProvider value={classes}>
|
|
179
|
+
<view {...mergeProps(ref ? { ref } : {}, nativeProps)} className={className} style={style}>
|
|
180
|
+
{children}
|
|
181
|
+
</view>
|
|
182
|
+
</ClassNamesProvider>
|
|
183
|
+
</HelpBubbleContext.Provider>;
|
|
184
|
+
});
|
|
185
|
+
HelpBubbleRoot.displayName = "HelpBubbleRoot";
|
|
186
|
+
var HelpBubbleAnchor = React.forwardRef((props, ref) => {
|
|
187
|
+
const { children, className, style, bindlayoutchange, ...nativeProps } = props;
|
|
188
|
+
const context = useHelpBubbleContext("HelpBubbleAnchor");
|
|
189
|
+
const handleRef = React.useCallback((node) => {
|
|
190
|
+
context.anchorRef.current = node;
|
|
191
|
+
mergeNodeRef(ref, node);
|
|
192
|
+
}, [context.anchorRef, ref]);
|
|
193
|
+
const handleLayoutChange = React.useCallback((...args) => {
|
|
194
|
+
"background only";
|
|
195
|
+
context.requestPositionUpdate();
|
|
196
|
+
bindlayoutchange?.(...args);
|
|
197
|
+
}, [bindlayoutchange, context.requestPositionUpdate]);
|
|
198
|
+
return <view ref={handleRef} className={className} style={style} bindlayoutchange={handleLayoutChange} {...nativeProps}>
|
|
199
|
+
{children}
|
|
200
|
+
</view>;
|
|
201
|
+
});
|
|
202
|
+
HelpBubbleAnchor.displayName = "HelpBubbleAnchor";
|
|
203
|
+
var HelpBubbleTrigger = React.forwardRef((props, ref) => {
|
|
204
|
+
const { children, className, style, bindtap, bindlayoutchange, "main-thread:bindtap": mainThreadBindtap, "accessibility-element": accessibilityElement = true, "accessibility-label": accessibilityLabel, "accessibility-traits": accessibilityTraits, ...nativeProps } = props;
|
|
205
|
+
const context = useHelpBubbleContext("HelpBubbleTrigger");
|
|
206
|
+
const { pressed: _pressed, bindtap: triggerTap, ...pressHandlers } = usePressTap({
|
|
207
|
+
onTap: React.useCallback((event, instance) => {
|
|
208
|
+
"background only";
|
|
209
|
+
context.requestOpen(!context.open);
|
|
210
|
+
bindtap?.(event, instance);
|
|
211
|
+
}, [bindtap, context]),
|
|
212
|
+
mainThreadOnTap: mainThreadBindtap
|
|
213
|
+
});
|
|
214
|
+
const handleRef = React.useCallback((node) => {
|
|
215
|
+
context.triggerRef.current = node;
|
|
216
|
+
mergeNodeRef(ref, node);
|
|
217
|
+
}, [context.triggerRef, ref]);
|
|
218
|
+
const handleLayoutChange = React.useCallback((...args) => {
|
|
219
|
+
"background only";
|
|
220
|
+
context.requestPositionUpdate();
|
|
221
|
+
bindlayoutchange?.(...args);
|
|
222
|
+
}, [bindlayoutchange, context.requestPositionUpdate]);
|
|
223
|
+
return <view ref={handleRef} className={className} style={style} accessibility-element={accessibilityElement} accessibility-label={accessibilityLabel} accessibility-role-description="button" accessibility-value={context.open ? "expanded" : "collapsed"} accessibility-traits={accessibilityTraits ?? "button"} {...nativeProps} {...pressHandlers} bindtap={triggerTap} bindlayoutchange={handleLayoutChange}>
|
|
224
|
+
{children}
|
|
225
|
+
</view>;
|
|
226
|
+
});
|
|
227
|
+
HelpBubbleTrigger.displayName = "HelpBubbleTrigger";
|
|
228
|
+
function OutsidePressCatcher({ referenceRect, onTap }) {
|
|
229
|
+
const screen = typeof SystemInfo === "undefined" ? void 0 : SystemInfo;
|
|
230
|
+
const pixelRatio = screen?.pixelRatio;
|
|
231
|
+
const width = screen?.pixelWidth;
|
|
232
|
+
const height = screen?.pixelHeight;
|
|
233
|
+
if (typeof pixelRatio !== "number" || pixelRatio <= 0 || typeof width !== "number" || typeof height !== "number") return null;
|
|
234
|
+
const screenWidth = width / pixelRatio;
|
|
235
|
+
const screenHeight = height / pixelRatio;
|
|
236
|
+
const left = Math.max(0, referenceRect.left);
|
|
237
|
+
const top = Math.max(0, referenceRect.top);
|
|
238
|
+
const right = Math.min(screenWidth, referenceRect.right);
|
|
239
|
+
const bottom = Math.min(screenHeight, referenceRect.bottom);
|
|
240
|
+
const areas = [
|
|
241
|
+
{
|
|
242
|
+
top: 0,
|
|
243
|
+
left: 0,
|
|
244
|
+
width: screenWidth,
|
|
245
|
+
height: top
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
top: bottom,
|
|
249
|
+
left: 0,
|
|
250
|
+
width: screenWidth,
|
|
251
|
+
height: Math.max(0, screenHeight - bottom)
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
top,
|
|
255
|
+
left: 0,
|
|
256
|
+
width: left,
|
|
257
|
+
height: Math.max(0, bottom - top)
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
top,
|
|
261
|
+
left: right,
|
|
262
|
+
width: Math.max(0, screenWidth - right),
|
|
263
|
+
height: Math.max(0, bottom - top)
|
|
264
|
+
}
|
|
265
|
+
];
|
|
266
|
+
return <>
|
|
267
|
+
{areas.map((area, index) => area.width > 0 && area.height > 0 ? <view key={index} style={{
|
|
268
|
+
position: "fixed",
|
|
269
|
+
top: toPixel(area.top),
|
|
270
|
+
left: toPixel(area.left),
|
|
271
|
+
width: toPixel(area.width),
|
|
272
|
+
height: toPixel(area.height),
|
|
273
|
+
zIndex: 0
|
|
274
|
+
}} bindtap={onTap} /> : null)}
|
|
275
|
+
</>;
|
|
276
|
+
}
|
|
277
|
+
var HelpBubblePositioner = React.forwardRef((props, ref) => {
|
|
278
|
+
const { children, className, style, zIndexOffset = 0, ...nativeProps } = props;
|
|
279
|
+
const context = useHelpBubbleContext("HelpBubblePositioner");
|
|
280
|
+
const classNames = useClassNames();
|
|
281
|
+
const handleOutsideTap = React.useCallback(() => {
|
|
282
|
+
"background only";
|
|
283
|
+
context.requestOpen(false);
|
|
284
|
+
}, [context.requestOpen]);
|
|
285
|
+
if (!context.mounted) return null;
|
|
286
|
+
return <view {...mergeProps(ref ? { ref } : {}, nativeProps)} className={clsx(classNames.positioner, className)} style={{
|
|
287
|
+
left: toPixel(context.position?.left ?? 0),
|
|
288
|
+
top: toPixel(context.position?.top ?? 0),
|
|
289
|
+
width: context.position ? toPixel(context.position.width) : void 0,
|
|
290
|
+
zIndex: 99 + zIndexOffset,
|
|
291
|
+
...style
|
|
292
|
+
}}>
|
|
293
|
+
{context.closeOnInteractOutside && context.open && context.referenceRect ? <OutsidePressCatcher referenceRect={context.referenceRect} onTap={handleOutsideTap} /> : null}
|
|
294
|
+
{children}
|
|
295
|
+
</view>;
|
|
296
|
+
});
|
|
297
|
+
HelpBubblePositioner.displayName = "HelpBubblePositioner";
|
|
298
|
+
var HelpBubbleContent = React.forwardRef((props, ref) => {
|
|
299
|
+
const { style, restProps } = useStyleProps(props);
|
|
300
|
+
const { children, className, ...nativeProps } = restProps;
|
|
301
|
+
const context = useHelpBubbleContext("HelpBubbleContent");
|
|
302
|
+
const measurementVersionRef = React.useRef(0);
|
|
303
|
+
const intrinsicWidthRef = React.useRef(null);
|
|
304
|
+
const measurementConfigRef = React.useRef(0);
|
|
305
|
+
const configuredClassNameRef = React.useRef(className);
|
|
306
|
+
const configuredStyleRef = React.useRef(style);
|
|
307
|
+
const [contentNode, setContentNode] = React.useState(null);
|
|
308
|
+
const [measurementRevision, setMeasurementRevision] = React.useState(0);
|
|
309
|
+
const [intrinsicSize, setIntrinsicSize] = React.useState(null);
|
|
310
|
+
const [widthConstraint, setWidthConstraint] = React.useState(null);
|
|
311
|
+
const closeFinishedRef = React.useRef(false);
|
|
312
|
+
const finishClose = React.useCallback(() => {
|
|
313
|
+
"background only";
|
|
314
|
+
if (closeFinishedRef.current) return;
|
|
315
|
+
closeFinishedRef.current = true;
|
|
316
|
+
context.finishClose();
|
|
317
|
+
}, [context.finishClose]);
|
|
318
|
+
const measureIntrinsicSize = React.useCallback(async () => {
|
|
319
|
+
"background only";
|
|
320
|
+
const openEpoch = context.openEpoch;
|
|
321
|
+
const config = measurementConfigRef.current;
|
|
322
|
+
if (!context.open || !contentNode) return;
|
|
323
|
+
const version = ++measurementVersionRef.current;
|
|
324
|
+
try {
|
|
325
|
+
const rect = await getRectByRef({ current: contentNode }, true);
|
|
326
|
+
if (version !== measurementVersionRef.current || !context.isOpenRef.current || openEpoch !== context.openEpochRef.current || config !== measurementConfigRef.current) return;
|
|
327
|
+
if (intrinsicWidthRef.current === null) intrinsicWidthRef.current = rect.width;
|
|
328
|
+
setIntrinsicSize((current) => {
|
|
329
|
+
const width = intrinsicWidthRef.current ?? rect.width;
|
|
330
|
+
if (current?.width === width && current.height === rect.height && current.epoch === openEpoch && current.config === config) return current;
|
|
331
|
+
return {
|
|
332
|
+
width,
|
|
333
|
+
height: rect.height,
|
|
334
|
+
epoch: openEpoch,
|
|
335
|
+
config
|
|
336
|
+
};
|
|
337
|
+
});
|
|
338
|
+
} catch {}
|
|
339
|
+
}, [
|
|
340
|
+
contentNode,
|
|
341
|
+
context.isOpenRef,
|
|
342
|
+
context.open,
|
|
343
|
+
context.openEpoch,
|
|
344
|
+
context.openEpochRef
|
|
345
|
+
]);
|
|
346
|
+
const measurePosition = React.useCallback(async () => {
|
|
347
|
+
"background only";
|
|
348
|
+
const referenceNode = context.anchorRef.current ?? context.triggerRef.current;
|
|
349
|
+
const openEpoch = context.openEpoch;
|
|
350
|
+
const positionRevision = context.positionRevisionRef.current;
|
|
351
|
+
if (!context.open || !referenceNode || !intrinsicSize || intrinsicSize.epoch !== openEpoch || intrinsicSize.config !== measurementConfigRef.current) return;
|
|
352
|
+
const version = ++measurementVersionRef.current;
|
|
353
|
+
try {
|
|
354
|
+
const [reference, boundary] = await Promise.all([getRectByRef({ current: referenceNode }, true), getRootRect()]);
|
|
355
|
+
if (version !== measurementVersionRef.current || !context.isOpenRef.current || openEpoch !== context.openEpochRef.current || positionRevision !== context.positionRevisionRef.current) return;
|
|
356
|
+
const width = widthConstraint ?? intrinsicWidthRef.current ?? intrinsicSize.width;
|
|
357
|
+
const nextPosition = await computePosition({
|
|
358
|
+
reference,
|
|
359
|
+
boundary,
|
|
360
|
+
width,
|
|
361
|
+
height: intrinsicSize.height,
|
|
362
|
+
placement: context.placement,
|
|
363
|
+
gutter: context.gutter,
|
|
364
|
+
overflowPadding: context.overflowPadding,
|
|
365
|
+
flip: context.flip === false ? false : context.flip === true ? { fallbackStrategy: "bestFit" } : context.flip,
|
|
366
|
+
shift: {
|
|
367
|
+
crossAxis: true,
|
|
368
|
+
limit: true
|
|
369
|
+
},
|
|
370
|
+
arrow: {
|
|
371
|
+
size: 12,
|
|
372
|
+
tipHeight: 8,
|
|
373
|
+
padding: context.arrowPadding
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
if (version !== measurementVersionRef.current || !context.isOpenRef.current || openEpoch !== context.openEpochRef.current || positionRevision !== context.positionRevisionRef.current) return;
|
|
377
|
+
if (nextPosition.availableWidth < width) {
|
|
378
|
+
const constrainedWidth = nextPosition.availableWidth;
|
|
379
|
+
if (widthConstraint !== constrainedWidth) {
|
|
380
|
+
setWidthConstraint(constrainedWidth);
|
|
381
|
+
setIntrinsicSize(null);
|
|
382
|
+
context.resetPosition();
|
|
383
|
+
setMeasurementRevision((current) => current + 1);
|
|
384
|
+
}
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
context.setPosition(nextPosition, reference);
|
|
388
|
+
} catch {}
|
|
389
|
+
}, [
|
|
390
|
+
context.anchorRef,
|
|
391
|
+
context.arrowPadding,
|
|
392
|
+
context.flip,
|
|
393
|
+
context.gutter,
|
|
394
|
+
context.isOpenRef,
|
|
395
|
+
context.open,
|
|
396
|
+
context.openEpoch,
|
|
397
|
+
context.openEpochRef,
|
|
398
|
+
context.overflowPadding,
|
|
399
|
+
context.placement,
|
|
400
|
+
context.resetPosition,
|
|
401
|
+
context.setPosition,
|
|
402
|
+
context.triggerRef,
|
|
403
|
+
intrinsicSize,
|
|
404
|
+
widthConstraint
|
|
405
|
+
]);
|
|
406
|
+
React.useEffect(() => {
|
|
407
|
+
"background only";
|
|
408
|
+
measurementVersionRef.current += 1;
|
|
409
|
+
intrinsicWidthRef.current = null;
|
|
410
|
+
setWidthConstraint(null);
|
|
411
|
+
setIntrinsicSize(null);
|
|
412
|
+
context.resetPosition();
|
|
413
|
+
}, [context.openEpoch, context.resetPosition]);
|
|
414
|
+
React.useEffect(() => {
|
|
415
|
+
"background only";
|
|
416
|
+
if (configuredClassNameRef.current === className && areStylesEqual(configuredStyleRef.current, style)) return;
|
|
417
|
+
measurementVersionRef.current += 1;
|
|
418
|
+
intrinsicWidthRef.current = null;
|
|
419
|
+
measurementConfigRef.current += 1;
|
|
420
|
+
configuredClassNameRef.current = className;
|
|
421
|
+
configuredStyleRef.current = style;
|
|
422
|
+
setWidthConstraint(null);
|
|
423
|
+
setIntrinsicSize(null);
|
|
424
|
+
context.resetPosition();
|
|
425
|
+
setMeasurementRevision((current) => current + 1);
|
|
426
|
+
}, [
|
|
427
|
+
className,
|
|
428
|
+
context.resetPosition,
|
|
429
|
+
style
|
|
430
|
+
]);
|
|
431
|
+
React.useEffect(() => {
|
|
432
|
+
"background only";
|
|
433
|
+
if (!context.open) return;
|
|
434
|
+
const frame = requestAnimationFrame(() => {
|
|
435
|
+
"background only";
|
|
436
|
+
measureIntrinsicSize();
|
|
437
|
+
});
|
|
438
|
+
return () => cancelAnimationFrame(frame);
|
|
439
|
+
}, [
|
|
440
|
+
context.open,
|
|
441
|
+
context.openEpoch,
|
|
442
|
+
measureIntrinsicSize,
|
|
443
|
+
measurementRevision
|
|
444
|
+
]);
|
|
445
|
+
React.useEffect(() => {
|
|
446
|
+
"background only";
|
|
447
|
+
if (!context.open) return;
|
|
448
|
+
let disposed = false;
|
|
449
|
+
let frame;
|
|
450
|
+
const trackPosition = () => {
|
|
451
|
+
measurePosition().finally(() => {
|
|
452
|
+
if (!disposed && context.isOpenRef.current) frame = requestAnimationFrame(trackPosition);
|
|
453
|
+
});
|
|
454
|
+
};
|
|
455
|
+
trackPosition();
|
|
456
|
+
return () => {
|
|
457
|
+
disposed = true;
|
|
458
|
+
measurementVersionRef.current += 1;
|
|
459
|
+
if (frame !== void 0) cancelAnimationFrame(frame);
|
|
460
|
+
};
|
|
461
|
+
}, [
|
|
462
|
+
context.isOpenRef,
|
|
463
|
+
context.open,
|
|
464
|
+
context.openEpoch,
|
|
465
|
+
context.positionRevision,
|
|
466
|
+
measurePosition
|
|
467
|
+
]);
|
|
468
|
+
React.useEffect(() => {
|
|
469
|
+
"background only";
|
|
470
|
+
if (context.open) {
|
|
471
|
+
closeFinishedRef.current = false;
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
if (!context.mounted) return;
|
|
475
|
+
const timer = setTimeout(() => {
|
|
476
|
+
"background only";
|
|
477
|
+
finishClose();
|
|
478
|
+
}, EXIT_TRANSITION_FALLBACK_MS);
|
|
479
|
+
return () => clearTimeout(timer);
|
|
480
|
+
}, [
|
|
481
|
+
context.mounted,
|
|
482
|
+
context.open,
|
|
483
|
+
finishClose
|
|
484
|
+
]);
|
|
485
|
+
const handleRef = React.useCallback((node) => {
|
|
486
|
+
measurementVersionRef.current += 1;
|
|
487
|
+
setContentNode(node);
|
|
488
|
+
mergeNodeRef(ref, node);
|
|
489
|
+
}, [ref]);
|
|
490
|
+
const handleLayoutChange = React.useCallback((event) => {
|
|
491
|
+
"background only";
|
|
492
|
+
const nextSize = getLayoutSize(event);
|
|
493
|
+
if (!nextSize || !context.open) return;
|
|
494
|
+
measurementVersionRef.current += 1;
|
|
495
|
+
if (intrinsicWidthRef.current === null) intrinsicWidthRef.current = nextSize.width;
|
|
496
|
+
setIntrinsicSize((current) => {
|
|
497
|
+
const width = intrinsicWidthRef.current ?? nextSize.width;
|
|
498
|
+
if (current?.width === width && current.height === nextSize.height && current.epoch === context.openEpoch && current.config === measurementConfigRef.current) return current;
|
|
499
|
+
return {
|
|
500
|
+
width,
|
|
501
|
+
height: nextSize.height,
|
|
502
|
+
epoch: context.openEpoch,
|
|
503
|
+
config: measurementConfigRef.current
|
|
504
|
+
};
|
|
505
|
+
});
|
|
506
|
+
}, [context.open, context.openEpoch]);
|
|
507
|
+
const handleTransitionEnd = React.useCallback((event) => {
|
|
508
|
+
"background only";
|
|
509
|
+
if (!context.open && hasExitTransition(event)) finishClose();
|
|
510
|
+
}, [context.open, finishClose]);
|
|
511
|
+
const motionClassName = useClassNames().motion;
|
|
512
|
+
return <view className={motionClassName} bindtransitionend={handleTransitionEnd}>
|
|
513
|
+
<view ref={handleRef} className={clsx(useClassNames().content, className)} style={{
|
|
514
|
+
...style,
|
|
515
|
+
...widthConstraint != null ? { width: toPixel(widthConstraint) } : {}
|
|
516
|
+
}} bindlayoutchange={handleLayoutChange} {...nativeProps}>
|
|
517
|
+
{children}
|
|
518
|
+
</view>
|
|
519
|
+
</view>;
|
|
520
|
+
});
|
|
521
|
+
HelpBubbleContent.displayName = "HelpBubbleContent";
|
|
522
|
+
var HelpBubbleArrow = React.forwardRef((props, ref) => {
|
|
523
|
+
const { children, className, style, ...nativeProps } = props;
|
|
524
|
+
const context = useHelpBubbleContext("HelpBubbleArrow");
|
|
525
|
+
const arrow = context.position?.arrow;
|
|
526
|
+
const side = context.side;
|
|
527
|
+
const geometryStyle = side === "top" ? {
|
|
528
|
+
left: toPixel(arrow?.left ?? 0),
|
|
529
|
+
top: "100%"
|
|
530
|
+
} : side === "bottom" ? {
|
|
531
|
+
left: toPixel(arrow?.left ?? 0),
|
|
532
|
+
bottom: "100%"
|
|
533
|
+
} : side === "right" ? {
|
|
534
|
+
top: toPixel(arrow?.top ?? 0),
|
|
535
|
+
right: "100%"
|
|
536
|
+
} : {
|
|
537
|
+
top: toPixel(arrow?.top ?? 0),
|
|
538
|
+
left: "100%"
|
|
539
|
+
};
|
|
540
|
+
return <view {...mergeProps(ref ? { ref } : {}, nativeProps)} className={clsx(useClassNames().arrow, className)} style={{
|
|
541
|
+
...geometryStyle,
|
|
542
|
+
...style
|
|
543
|
+
}}>
|
|
544
|
+
{children}
|
|
545
|
+
</view>;
|
|
546
|
+
});
|
|
547
|
+
HelpBubbleArrow.displayName = "HelpBubbleArrow";
|
|
548
|
+
var HelpBubbleArrowTip = React.forwardRef((props, ref) => {
|
|
549
|
+
const { children, className, style, ...nativeProps } = props;
|
|
550
|
+
return <view {...mergeProps(ref ? { ref } : {}, nativeProps)} className={clsx(useClassNames().arrowTip, className)} style={style} accessibility-elements-hidden={true}>
|
|
551
|
+
{children}
|
|
552
|
+
</view>;
|
|
553
|
+
});
|
|
554
|
+
HelpBubbleArrowTip.displayName = "HelpBubbleArrowTip";
|
|
555
|
+
var HelpBubbleBody = React.forwardRef((props, ref) => {
|
|
556
|
+
const { children, className, style, ...nativeProps } = props;
|
|
557
|
+
return <view {...mergeProps(ref ? { ref } : {}, nativeProps)} className={clsx(useClassNames().body, className)} style={style}>
|
|
558
|
+
{children}
|
|
559
|
+
</view>;
|
|
560
|
+
});
|
|
561
|
+
HelpBubbleBody.displayName = "HelpBubbleBody";
|
|
562
|
+
var HelpBubbleTitle = React.forwardRef((props, ref) => {
|
|
563
|
+
const { children, className, style, ...nativeProps } = props;
|
|
564
|
+
return <text {...mergeProps(ref ? { ref } : {}, nativeProps)} className={clsx(useClassNames().title, className)} style={style}>
|
|
565
|
+
{children}
|
|
566
|
+
</text>;
|
|
567
|
+
});
|
|
568
|
+
HelpBubbleTitle.displayName = "HelpBubbleTitle";
|
|
569
|
+
var HelpBubbleDescription = React.forwardRef((props, ref) => {
|
|
570
|
+
const { children, className, style, ...nativeProps } = props;
|
|
571
|
+
return <text {...mergeProps(ref ? { ref } : {}, nativeProps)} className={clsx(useClassNames().description, className)} style={style}>
|
|
572
|
+
{children}
|
|
573
|
+
</text>;
|
|
574
|
+
});
|
|
575
|
+
HelpBubbleDescription.displayName = "HelpBubbleDescription";
|
|
576
|
+
var HelpBubbleCloseButton = React.forwardRef((props, ref) => {
|
|
577
|
+
const { children, className, style, bindtap, "main-thread:bindtap": mainThreadBindtap, "accessibility-element": accessibilityElement = true, "accessibility-label": accessibilityLabel, "accessibility-traits": accessibilityTraits = "button", ...nativeProps } = props;
|
|
578
|
+
const context = useHelpBubbleContext("HelpBubbleCloseButton");
|
|
579
|
+
const { pressed, ...pressHandlers } = usePressTap({
|
|
580
|
+
onTap: React.useCallback((event, instance) => {
|
|
581
|
+
"background only";
|
|
582
|
+
bindtap?.(event, instance);
|
|
583
|
+
context.requestOpen(false);
|
|
584
|
+
}, [bindtap, context]),
|
|
585
|
+
mainThreadOnTap: mainThreadBindtap
|
|
586
|
+
});
|
|
587
|
+
const closeButtonClassNames = helpBubble({
|
|
588
|
+
open: context.open,
|
|
589
|
+
positioned: context.positioned,
|
|
590
|
+
side: context.side,
|
|
591
|
+
pressed
|
|
592
|
+
});
|
|
593
|
+
if (process.env.NODE_ENV !== "production" && accessibilityElement && !accessibilityLabel) console.warn("HelpBubbleCloseButton requires `accessibility-label` for accessibility.");
|
|
594
|
+
return <view {...mergeProps(ref ? { ref } : {}, pressHandlers, nativeProps)} accessibility-element={accessibilityElement} accessibility-label={accessibilityLabel} accessibility-traits={accessibilityTraits} className={clsx(closeButtonClassNames.closeButton, className)} style={style} flatten={false}>
|
|
595
|
+
{children}
|
|
596
|
+
</view>;
|
|
597
|
+
});
|
|
598
|
+
HelpBubbleCloseButton.displayName = "HelpBubbleCloseButton";
|
|
599
|
+
//#endregion
|
|
600
|
+
export { HelpBubbleAnchor, HelpBubbleArrow, HelpBubbleArrowTip, HelpBubbleBody, HelpBubbleCloseButton, HelpBubbleContent, HelpBubbleDescription, HelpBubblePositioner, HelpBubbleRoot, HelpBubbleTitle, HelpBubbleTrigger };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { HelpBubbleAnchor as Anchor, HelpBubbleArrow as Arrow, HelpBubbleArrowTip as ArrowTip, HelpBubbleBody as Body, HelpBubbleCloseButton as CloseButton, HelpBubbleContent as Content, HelpBubbleDescription as Description, HelpBubblePositioner as Positioner, HelpBubbleRoot as Root, HelpBubbleTitle as Title, HelpBubbleTrigger as Trigger, type HelpBubbleAnchorProps as AnchorProps, type HelpBubbleArrowProps as ArrowProps, type HelpBubbleArrowTipProps as ArrowTipProps, type HelpBubbleBodyProps as BodyProps, type HelpBubbleCloseButtonProps as CloseButtonProps, type HelpBubbleContentProps as ContentProps, type HelpBubbleDescriptionProps as DescriptionProps, type HelpBubblePositionerProps as PositionerProps, type HelpBubbleRootProps as RootProps, type HelpBubbleTitleProps as TitleProps, type HelpBubbleTriggerProps as TriggerProps, } from './HelpBubble';
|
|
2
|
+
//# sourceMappingURL=HelpBubble.namespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HelpBubble.namespace.d.ts","sourceRoot":"","sources":["../../../src/components/HelpBubble/HelpBubble.namespace.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,IAAI,MAAM,EAC1B,eAAe,IAAI,KAAK,EACxB,kBAAkB,IAAI,QAAQ,EAC9B,cAAc,IAAI,IAAI,EACtB,qBAAqB,IAAI,WAAW,EACpC,iBAAiB,IAAI,OAAO,EAC5B,qBAAqB,IAAI,WAAW,EACpC,oBAAoB,IAAI,UAAU,EAClC,cAAc,IAAI,IAAI,EACtB,eAAe,IAAI,KAAK,EACxB,iBAAiB,IAAI,OAAO,EAC5B,KAAK,qBAAqB,IAAI,WAAW,EACzC,KAAK,oBAAoB,IAAI,UAAU,EACvC,KAAK,uBAAuB,IAAI,aAAa,EAC7C,KAAK,mBAAmB,IAAI,SAAS,EACrC,KAAK,0BAA0B,IAAI,gBAAgB,EACnD,KAAK,sBAAsB,IAAI,YAAY,EAC3C,KAAK,0BAA0B,IAAI,gBAAgB,EACnD,KAAK,yBAAyB,IAAI,eAAe,EACjD,KAAK,mBAAmB,IAAI,SAAS,EACrC,KAAK,oBAAoB,IAAI,UAAU,EACvC,KAAK,sBAAsB,IAAI,YAAY,GAC5C,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { HelpBubbleAnchor, HelpBubbleArrow, HelpBubbleArrowTip, HelpBubbleBody, HelpBubbleCloseButton, HelpBubbleContent, HelpBubbleDescription, HelpBubblePositioner, HelpBubbleRoot, HelpBubbleTitle, HelpBubbleTrigger } from "./HelpBubble.jsx";
|
|
3
|
+
//#region src/components/HelpBubble/HelpBubble.namespace.ts
|
|
4
|
+
var HelpBubble_namespace_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
Anchor: () => HelpBubbleAnchor,
|
|
6
|
+
Arrow: () => HelpBubbleArrow,
|
|
7
|
+
ArrowTip: () => HelpBubbleArrowTip,
|
|
8
|
+
Body: () => HelpBubbleBody,
|
|
9
|
+
CloseButton: () => HelpBubbleCloseButton,
|
|
10
|
+
Content: () => HelpBubbleContent,
|
|
11
|
+
Description: () => HelpBubbleDescription,
|
|
12
|
+
Positioner: () => HelpBubblePositioner,
|
|
13
|
+
Root: () => HelpBubbleRoot,
|
|
14
|
+
Title: () => HelpBubbleTitle,
|
|
15
|
+
Trigger: () => HelpBubbleTrigger
|
|
16
|
+
});
|
|
17
|
+
//#endregion
|
|
18
|
+
export { HelpBubble_namespace_exports };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { HelpBubbleAnchor, HelpBubbleArrow, HelpBubbleArrowTip, HelpBubbleBody, HelpBubbleCloseButton, HelpBubbleContent, HelpBubbleDescription, HelpBubblePositioner, HelpBubbleRoot, HelpBubbleTitle, HelpBubbleTrigger, type HelpBubbleAnchorProps, type HelpBubbleArrowProps, type HelpBubbleArrowTipProps, type HelpBubbleBodyProps, type HelpBubbleCloseButtonProps, type HelpBubbleContentProps, type HelpBubbleDescriptionProps, type HelpBubblePositionerProps, type HelpBubbleRootProps, type HelpBubbleTitleProps, type HelpBubbleTriggerProps, } from './HelpBubble';
|
|
2
|
+
export * as HelpBubble from './HelpBubble.namespace';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/HelpBubble/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,GAC5B,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC"}
|
|
@@ -36,6 +36,7 @@ export declare const SuffixIcon: React.ForwardRefExoticComponent<SuffixIconProps
|
|
|
36
36
|
export interface InternalIconProps extends LynxStyledElementProps {
|
|
37
37
|
icon: ReactElement<LynxIconElementProps>;
|
|
38
38
|
deps?: DependencyList;
|
|
39
|
+
disableDefaultResize?: boolean;
|
|
39
40
|
}
|
|
40
41
|
export declare const InternalIcon: React.ForwardRefExoticComponent<InternalIconProps & React.RefAttributes<unknown>>;
|
|
41
42
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../../../src/components/Icon/Icon.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,sBAAsB,EAAe,MAAM,aAAa,CAAC;AAC7F,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGnF,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,YAAY,GAAG,YAAY,CAAC;AAIhE,UAAU,oBAAoB;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB;AAWD,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;CAClB,qBAyCA;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,oBAAoB,CAAC;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,qBAEA;AAeD,wBAAgB,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,GAAG,YAAY,GAAG,IAAI,CAI1E;AAaD,MAAM,WAAW,SAAU,SAAQ,sBAAsB;IACvD,IAAI,EAAE,YAAY,CAAC,oBAAoB,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC;IACrC,KAAK,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC5B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,eAAgB,SAAQ,SAAS;CAAG;AAErD,MAAM,WAAW,eAAgB,SAAQ,SAAS;CAAG;AA+GrD,eAAO,MAAM,IAAI,2EAA8D,CAAC;AAChF,eAAO,MAAM,UAAU,iFAItB,CAAC;AACF,eAAO,MAAM,UAAU,iFAItB,CAAC;AAIF,MAAM,WAAW,iBAAkB,SAAQ,sBAAsB;IAC/D,IAAI,EAAE,YAAY,CAAC,oBAAoB,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../../../src/components/Icon/Icon.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,sBAAsB,EAAe,MAAM,aAAa,CAAC;AAC7F,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGnF,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,YAAY,GAAG,YAAY,CAAC;AAIhE,UAAU,oBAAoB;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB;AAWD,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;CAClB,qBAyCA;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,oBAAoB,CAAC;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,qBAEA;AAeD,wBAAgB,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,GAAG,YAAY,GAAG,IAAI,CAI1E;AAaD,MAAM,WAAW,SAAU,SAAQ,sBAAsB;IACvD,IAAI,EAAE,YAAY,CAAC,oBAAoB,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC;IACrC,KAAK,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC5B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,eAAgB,SAAQ,SAAS;CAAG;AAErD,MAAM,WAAW,eAAgB,SAAQ,SAAS;CAAG;AA+GrD,eAAO,MAAM,IAAI,2EAA8D,CAAC;AAChF,eAAO,MAAM,UAAU,iFAItB,CAAC;AACF,eAAO,MAAM,UAAU,iFAItB,CAAC;AAIF,MAAM,WAAW,iBAAkB,SAAQ,sBAAsB;IAC/D,IAAI,EAAE,YAAY,CAAC,oBAAoB,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,eAAO,MAAM,YAAY,mFAsCvB,CAAC"}
|
|
@@ -130,7 +130,7 @@ var Icon = createIconComponent("Icon", "icon", "seed-icon");
|
|
|
130
130
|
var PrefixIcon = createIconComponent("PrefixIcon", "prefixIcon", "seed-prefix-icon");
|
|
131
131
|
var SuffixIcon = createIconComponent("SuffixIcon", "suffixIcon", "seed-suffix-icon");
|
|
132
132
|
var InternalIcon = React.forwardRef((props, ref) => {
|
|
133
|
-
const { icon, deps = [], className, style, children: _children, ...nativeProps } = props;
|
|
133
|
+
const { icon, deps = [], className, style, children: _children, disableDefaultResize = false, ...nativeProps } = props;
|
|
134
134
|
const sourceRef = useMainThreadRef(null);
|
|
135
135
|
const iconColor = useIconColor([
|
|
136
136
|
className,
|
|
@@ -141,6 +141,7 @@ var InternalIcon = React.forwardRef((props, ref) => {
|
|
|
141
141
|
return <view {...mergeProps({ "main-thread:ref": sourceRef }, ref ? { ref } : {}, nativeProps)} className={className} style={style}>
|
|
142
142
|
{cloneElement(icon, {
|
|
143
143
|
...iconColor,
|
|
144
|
+
...disableDefaultResize ? { "disable-default-resize": true } : {},
|
|
144
145
|
className: icon.props.className,
|
|
145
146
|
style: {
|
|
146
147
|
...icon.props.style,
|