@seed-design/lynx-react 0.7.1 → 0.8.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 +39 -8
- 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/index.d.ts +1 -1
- package/lib/components/AppBar/index.d.ts.map +1 -1
- 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/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/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/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/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 +231 -0
- package/src/components/AppBar/AppBar.tsx +105 -13
- package/src/components/AppBar/index.ts +1 -0
- 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/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/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/types.ts +1 -0
|
@@ -1,15 +1,29 @@
|
|
|
1
|
-
import { useControllableState } from "../../
|
|
2
|
-
import { usePressTap } from "../../
|
|
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
3
|
import { useScaleFeedback } from "../../hooks/useScaleFeedback.js";
|
|
4
4
|
import { mergeProps } from "../../utils/merge-props.js";
|
|
5
5
|
import { createSlotRecipeContext } from "../../utils/create-slot-recipe-context.jsx";
|
|
6
6
|
import { Box } from "../Box/Box.jsx";
|
|
7
|
-
import {
|
|
7
|
+
import { HStack } from "../Stack/Stack.jsx";
|
|
8
|
+
import { areTabsTransitionsEnabled, getTabsLayoutWidth, getTabsOrderedItems, getTabsScrollOffset, getTabsTriggerRects } from "./Tabs.utils.js";
|
|
8
9
|
import * as React from "@lynx-js/react";
|
|
10
|
+
import { runOnMainThread } from "@lynx-js/react";
|
|
9
11
|
import clsx from "clsx";
|
|
10
12
|
import { tabs } from "@seed-design/lynx-css/recipes/tabs";
|
|
11
13
|
//#region src/components/Tabs/Tabs.tsx
|
|
12
|
-
|
|
14
|
+
function getTabsContentInsets(contentRef) {
|
|
15
|
+
"main thread";
|
|
16
|
+
const content = contentRef.current;
|
|
17
|
+
if (!content || typeof content.getComputedStyleProperty !== "function") return null;
|
|
18
|
+
const start = Number.parseFloat(content.getComputedStyleProperty("padding-left"));
|
|
19
|
+
const end = Number.parseFloat(content.getComputedStyleProperty("padding-right"));
|
|
20
|
+
if (!Number.isFinite(start) || !Number.isFinite(end) || start < 0 || end < 0) return null;
|
|
21
|
+
return {
|
|
22
|
+
start,
|
|
23
|
+
end
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
var { ClassNamesProvider } = createSlotRecipeContext(tabs);
|
|
13
27
|
function invokeSelectTab(pager, index, smooth) {
|
|
14
28
|
"background only";
|
|
15
29
|
if (!pager || index < 0) return;
|
|
@@ -52,9 +66,8 @@ function useTabsCarouselContext(consumer) {
|
|
|
52
66
|
if (!context) throw new Error(`<${consumer}/> must be rendered inside <TabsCarousel/>.`);
|
|
53
67
|
return context;
|
|
54
68
|
}
|
|
55
|
-
var
|
|
56
|
-
const
|
|
57
|
-
const { children, className, style, value: valueProp, defaultValue, onValueChange, ...nativeProps } = otherProps;
|
|
69
|
+
var TabsRootPrimitive = React.forwardRef((props, ref) => {
|
|
70
|
+
const { recipe, inlineNotification = false, children, className, style, value: valueProp, defaultValue, onValueChange, ...nativeProps } = props;
|
|
58
71
|
const [value, setValueInternal] = useControllableState({
|
|
59
72
|
value: valueProp,
|
|
60
73
|
defaultValue,
|
|
@@ -67,24 +80,20 @@ var TabsRoot = React.forwardRef((props, ref) => {
|
|
|
67
80
|
const [contentValues, setContentValues] = React.useState([]);
|
|
68
81
|
const [indicatorValue, setIndicatorValue] = React.useState();
|
|
69
82
|
const [triggerWidths, setTriggerWidths] = React.useState({});
|
|
70
|
-
const listRef = React.useRef(null);
|
|
71
83
|
const pagerRef = React.useRef(null);
|
|
72
84
|
const indicatorRef = React.useMainThreadRef(null);
|
|
73
85
|
const pagerValues = React.useMemo(() => contentValues.filter((contentValue) => !items.find((item) => item.value === contentValue)?.disabled), [contentValues, items]);
|
|
74
|
-
const triggerRects = React.useMemo(() => getTabsTriggerRects(items.map((item) => item.value), triggerWidths), [
|
|
86
|
+
const triggerRects = React.useMemo(() => getTabsTriggerRects(items.map((item) => item.value), triggerWidths, recipe.triggerGap), [
|
|
87
|
+
items,
|
|
88
|
+
recipe.triggerGap,
|
|
89
|
+
triggerWidths
|
|
90
|
+
]);
|
|
75
91
|
const transitionsEnabled = areTabsTransitionsEnabled(items.map((item) => item.value), triggerRects);
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
transitionEnabled: transitionsEnabled
|
|
79
|
-
});
|
|
92
|
+
const getClassNames = recipe.getClassNames;
|
|
93
|
+
const classNames = getClassNames({ transitionEnabled: transitionsEnabled });
|
|
80
94
|
const visualValue = indicatorValue ?? value;
|
|
81
95
|
const indicatorIndex = items.findIndex((item) => item.value === visualValue);
|
|
82
96
|
const selectedPagerIndex = value === void 0 ? -1 : pagerValues.indexOf(value);
|
|
83
|
-
const selectedOffset = (value === void 0 ? void 0 : triggerRects[value])?.left ?? null;
|
|
84
|
-
const setListNode = React.useCallback((node) => {
|
|
85
|
-
listRef.current = node;
|
|
86
|
-
if (node && selectedOffset !== null) invokeScrollToOffset(node, selectedOffset);
|
|
87
|
-
}, [selectedOffset]);
|
|
88
97
|
const setPagerNode = React.useCallback((node) => {
|
|
89
98
|
pagerRef.current = node;
|
|
90
99
|
if (node && selectedPagerIndex >= 0) invokeSelectTab(node, selectedPagerIndex, false);
|
|
@@ -148,12 +157,14 @@ var TabsRoot = React.forwardRef((props, ref) => {
|
|
|
148
157
|
React.useEffect(() => {
|
|
149
158
|
"background only";
|
|
150
159
|
if (selectedPagerIndex >= 0) invokeSelectTab(pagerRef.current, selectedPagerIndex, false);
|
|
151
|
-
|
|
152
|
-
}, [selectedPagerIndex, selectedOffset]);
|
|
160
|
+
}, [selectedPagerIndex]);
|
|
153
161
|
const contextValue = React.useMemo(() => ({
|
|
154
162
|
value,
|
|
155
163
|
visualValue,
|
|
156
|
-
|
|
164
|
+
classNames,
|
|
165
|
+
getClassNames,
|
|
166
|
+
getIndicatorClassName: recipe.getIndicatorClassName,
|
|
167
|
+
inlineNotification,
|
|
157
168
|
items,
|
|
158
169
|
pagerValues,
|
|
159
170
|
indicatorIndex,
|
|
@@ -166,7 +177,6 @@ var TabsRoot = React.forwardRef((props, ref) => {
|
|
|
166
177
|
updateTriggerDisabled,
|
|
167
178
|
syncTriggerOrder,
|
|
168
179
|
updateTriggerWidth,
|
|
169
|
-
setListRef: setListNode,
|
|
170
180
|
setPagerRef: setPagerNode,
|
|
171
181
|
selectValue,
|
|
172
182
|
handlePagerWillChange,
|
|
@@ -174,7 +184,10 @@ var TabsRoot = React.forwardRef((props, ref) => {
|
|
|
174
184
|
}), [
|
|
175
185
|
value,
|
|
176
186
|
visualValue,
|
|
177
|
-
|
|
187
|
+
classNames,
|
|
188
|
+
getClassNames,
|
|
189
|
+
recipe.getIndicatorClassName,
|
|
190
|
+
inlineNotification,
|
|
178
191
|
items,
|
|
179
192
|
pagerValues,
|
|
180
193
|
indicatorIndex,
|
|
@@ -187,20 +200,36 @@ var TabsRoot = React.forwardRef((props, ref) => {
|
|
|
187
200
|
updateTriggerDisabled,
|
|
188
201
|
syncTriggerOrder,
|
|
189
202
|
updateTriggerWidth,
|
|
190
|
-
setListNode,
|
|
191
203
|
setPagerNode,
|
|
192
204
|
selectValue,
|
|
193
205
|
handlePagerWillChange,
|
|
194
206
|
handlePagerChange
|
|
195
207
|
]);
|
|
196
208
|
return <TabsContext.Provider value={contextValue}>
|
|
197
|
-
<
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
</view>
|
|
201
|
-
</ClassNamesProvider>
|
|
209
|
+
<view {...mergeProps(ref ? { ref } : {}, nativeProps)} className={clsx(classNames.root, className)} style={style}>
|
|
210
|
+
{children}
|
|
211
|
+
</view>
|
|
202
212
|
</TabsContext.Provider>;
|
|
203
213
|
});
|
|
214
|
+
TabsRootPrimitive.displayName = "TabsRootPrimitive";
|
|
215
|
+
var TabsRoot = React.forwardRef((props, ref) => {
|
|
216
|
+
const [variantProps, rootProps] = tabs.splitVariantProps(props);
|
|
217
|
+
const getClassNames = React.useCallback((state = {}) => tabs({
|
|
218
|
+
...variantProps,
|
|
219
|
+
selected: state.selected,
|
|
220
|
+
disabled: state.disabled,
|
|
221
|
+
inCarousel: state.inCarousel,
|
|
222
|
+
transitionEnabled: state.transitionEnabled
|
|
223
|
+
}), [variantProps]);
|
|
224
|
+
const recipe = React.useMemo(() => ({
|
|
225
|
+
getClassNames,
|
|
226
|
+
getIndicatorClassName: (state) => getClassNames(state).indicator,
|
|
227
|
+
triggerGap: 0
|
|
228
|
+
}), [getClassNames]);
|
|
229
|
+
return <ClassNamesProvider value={getClassNames()}>
|
|
230
|
+
<TabsRootPrimitive {...rootProps} ref={ref} recipe={recipe} />
|
|
231
|
+
</ClassNamesProvider>;
|
|
232
|
+
});
|
|
204
233
|
TabsRoot.displayName = "TabsRoot";
|
|
205
234
|
function getTabsTriggerValues(children) {
|
|
206
235
|
const values = [];
|
|
@@ -220,10 +249,21 @@ function getTabsTriggerValues(children) {
|
|
|
220
249
|
return values;
|
|
221
250
|
}
|
|
222
251
|
var TabsList = React.forwardRef((props, ref) => {
|
|
223
|
-
const { children, className, style, ...nativeProps } = props;
|
|
224
|
-
const classNames =
|
|
225
|
-
const
|
|
252
|
+
const { children, className, style, scrollAlign = "start", ...nativeProps } = props;
|
|
253
|
+
const { classNames, items, syncTriggerOrder, triggerRects, value } = useTabsContext("TabsList");
|
|
254
|
+
const scrollRef = React.useRef(null);
|
|
255
|
+
const contentRef = React.useMainThreadRef(null);
|
|
256
|
+
const metricsRef = React.useRef({
|
|
257
|
+
currentOffset: 0,
|
|
258
|
+
viewportWidth: null,
|
|
259
|
+
contentWidth: null,
|
|
260
|
+
insets: null
|
|
261
|
+
});
|
|
262
|
+
const contentInsetRequestRef = React.useRef(0);
|
|
263
|
+
const selectedValueRef = React.useRef(value);
|
|
264
|
+
const [geometryRevision, setGeometryRevision] = React.useState(0);
|
|
226
265
|
const triggerOrder = React.useMemo(() => getTabsTriggerValues(children), [children]);
|
|
266
|
+
selectedValueRef.current = value;
|
|
227
267
|
React.useEffect(() => {
|
|
228
268
|
"background only";
|
|
229
269
|
syncTriggerOrder(triggerOrder);
|
|
@@ -232,9 +272,84 @@ var TabsList = React.forwardRef((props, ref) => {
|
|
|
232
272
|
syncTriggerOrder,
|
|
233
273
|
triggerOrder
|
|
234
274
|
]);
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
275
|
+
const requestContentInsets = React.useCallback(() => {
|
|
276
|
+
"background only";
|
|
277
|
+
const request = ++contentInsetRequestRef.current;
|
|
278
|
+
metricsRef.current.insets = null;
|
|
279
|
+
runOnMainThread(getTabsContentInsets)(contentRef).then((insets) => {
|
|
280
|
+
"background only";
|
|
281
|
+
if (request !== contentInsetRequestRef.current || !insets) return;
|
|
282
|
+
metricsRef.current.insets = insets;
|
|
283
|
+
setGeometryRevision((revision) => revision + 1);
|
|
284
|
+
}, () => {});
|
|
285
|
+
}, [contentRef]);
|
|
286
|
+
const handleListLayoutChange = React.useCallback((event) => {
|
|
287
|
+
"background only";
|
|
288
|
+
const width = getTabsLayoutWidth(event);
|
|
289
|
+
if (width !== null && width > 0 && metricsRef.current.viewportWidth !== width) {
|
|
290
|
+
metricsRef.current.viewportWidth = width;
|
|
291
|
+
setGeometryRevision((revision) => revision + 1);
|
|
292
|
+
}
|
|
293
|
+
}, []);
|
|
294
|
+
const handleContentLayoutChange = React.useCallback((event) => {
|
|
295
|
+
"background only";
|
|
296
|
+
const width = getTabsLayoutWidth(event);
|
|
297
|
+
if (width !== null && width > 0 && metricsRef.current.contentWidth !== width) {
|
|
298
|
+
metricsRef.current.contentWidth = width;
|
|
299
|
+
setGeometryRevision((revision) => revision + 1);
|
|
300
|
+
}
|
|
301
|
+
requestContentInsets();
|
|
302
|
+
}, [requestContentInsets]);
|
|
303
|
+
const updateScrollMetrics = React.useCallback((scrollLeft, scrollWidth) => {
|
|
304
|
+
"background only";
|
|
305
|
+
if (Number.isFinite(scrollLeft)) metricsRef.current.currentOffset = Math.max(0, scrollLeft);
|
|
306
|
+
if (Number.isFinite(scrollWidth) && scrollWidth > 0 && metricsRef.current.contentWidth !== scrollWidth) {
|
|
307
|
+
metricsRef.current.contentWidth = scrollWidth;
|
|
308
|
+
requestContentInsets();
|
|
309
|
+
setGeometryRevision((revision) => revision + 1);
|
|
310
|
+
}
|
|
311
|
+
}, [requestContentInsets]);
|
|
312
|
+
const handleScroll = React.useCallback((event) => {
|
|
313
|
+
"background only";
|
|
314
|
+
updateScrollMetrics(event.detail.scrollLeft, event.detail.scrollWidth);
|
|
315
|
+
}, [updateScrollMetrics]);
|
|
316
|
+
const handleContentSizeChanged = React.useCallback((event) => {
|
|
317
|
+
"background only";
|
|
318
|
+
updateScrollMetrics(event.detail.scrollLeft, event.detail.scrollWidth);
|
|
319
|
+
}, [updateScrollMetrics]);
|
|
320
|
+
React.useEffect(() => {
|
|
321
|
+
"background only";
|
|
322
|
+
const selectedRect = value === void 0 ? void 0 : triggerRects[value];
|
|
323
|
+
const { currentOffset, viewportWidth, contentWidth, insets } = metricsRef.current;
|
|
324
|
+
if (!scrollRef.current || value === void 0 || !selectedRect || viewportWidth === null || contentWidth === null || insets === null) return;
|
|
325
|
+
const targetOffset = getTabsScrollOffset({
|
|
326
|
+
scrollAlign,
|
|
327
|
+
currentOffset,
|
|
328
|
+
viewportWidth,
|
|
329
|
+
contentWidth,
|
|
330
|
+
contentInsetStart: insets.start,
|
|
331
|
+
contentInsetEnd: insets.end,
|
|
332
|
+
triggerRect: selectedRect
|
|
333
|
+
});
|
|
334
|
+
if (selectedValueRef.current !== value || targetOffset === currentOffset) return;
|
|
335
|
+
invokeScrollToOffset(scrollRef.current, targetOffset);
|
|
336
|
+
}, [
|
|
337
|
+
geometryRevision,
|
|
338
|
+
items,
|
|
339
|
+
scrollAlign,
|
|
340
|
+
triggerRects,
|
|
341
|
+
value
|
|
342
|
+
]);
|
|
343
|
+
const mergedRef = React.useMemo(() => mergeProps({ ref: scrollRef }, { ref }).ref, [ref]);
|
|
344
|
+
return <scroll-view {...mergeProps({
|
|
345
|
+
ref: mergedRef,
|
|
346
|
+
bindlayoutchange: handleListLayoutChange,
|
|
347
|
+
bindscroll: handleScroll,
|
|
348
|
+
bindcontentsizechanged: handleContentSizeChanged
|
|
349
|
+
}, nativeProps)} scroll-orientation="horizontal" scroll-bar-enable={false} accessibility-element={false} accessibility-traits="tabbar" className={clsx(classNames.list, className)} style={style}>
|
|
350
|
+
<view className={classNames.listContent} main-thread:ref={contentRef} bindlayoutchange={handleContentLayoutChange}>
|
|
351
|
+
{children}
|
|
352
|
+
</view>
|
|
238
353
|
</scroll-view>;
|
|
239
354
|
});
|
|
240
355
|
TabsList.displayName = "TabsList";
|
|
@@ -255,7 +370,7 @@ var TabsTrigger = React.forwardRef((props, ref) => {
|
|
|
255
370
|
triggerValue,
|
|
256
371
|
disabled
|
|
257
372
|
]);
|
|
258
|
-
const { pressed
|
|
373
|
+
const { pressed, bindtouchstart, bindtouchend, bindtouchcancel, ...pressHandlers } = usePressTap({
|
|
259
374
|
disabled,
|
|
260
375
|
onTap: React.useCallback((...args) => {
|
|
261
376
|
"background only";
|
|
@@ -278,25 +393,29 @@ var TabsTrigger = React.forwardRef((props, ref) => {
|
|
|
278
393
|
const width = getTabsLayoutWidth(args[0]);
|
|
279
394
|
if (width !== null) context.updateTriggerWidth(triggerValue, width);
|
|
280
395
|
}, [context.updateTriggerWidth, triggerValue]);
|
|
281
|
-
const triggerClasses =
|
|
282
|
-
...context.variantProps,
|
|
396
|
+
const triggerClasses = context.getClassNames({
|
|
283
397
|
selected: visuallySelected,
|
|
284
398
|
disabled,
|
|
399
|
+
pressed,
|
|
285
400
|
transitionEnabled: context.transitionsEnabled
|
|
286
401
|
});
|
|
287
402
|
const label = typeof children === "string" || typeof children === "number" ? String(children) : void 0;
|
|
288
403
|
return <view {...mergeProps({ bindlayoutchange: handleLayoutChange }, ref ? { ref } : {}, pressHandlers, scaleFeedbackTargetProps, scaleFeedbackTriggerProps, nativeProps)} flatten={false} accessibility-element={true} accessibility-role-description="tab" accessibility-label={accessibilityLabel ?? label} accessibility-value={selected ? "selected" : "not selected"} accessibility-traits={disabled ? "disabled" : selected ? "selected" : "button"} className={clsx(triggerClasses.trigger, className)} style={style}>
|
|
289
|
-
{notification ? <
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
404
|
+
{notification ? context.inlineNotification ? <HStack position="relative" gap="x1_5">
|
|
405
|
+
<text className={triggerClasses.triggerLabel}>{children}</text>
|
|
406
|
+
<view accessibility-elements-hidden={true}>{notification}</view>
|
|
407
|
+
</HStack> : <Box position="relative">
|
|
408
|
+
<text className={triggerClasses.triggerLabel}>{children}</text>
|
|
409
|
+
{notification}
|
|
410
|
+
</Box> : <text className={triggerClasses.triggerLabel}>{children}</text>}
|
|
293
411
|
</view>;
|
|
294
412
|
});
|
|
295
413
|
TabsTrigger.displayName = "TabsTrigger";
|
|
296
414
|
var TabsIndicator = React.forwardRef((props, ref) => {
|
|
297
415
|
const { className, style, ...nativeProps } = props;
|
|
298
|
-
const
|
|
299
|
-
|
|
416
|
+
const { indicatorRef, items, indicatorIndex, triggerRects, getIndicatorClassName, transitionsEnabled } = useTabsContext("TabsIndicator");
|
|
417
|
+
if (!getIndicatorClassName) throw new Error("<TabsIndicator/> is only supported inside <TabsRoot/>.");
|
|
418
|
+
const indicatorClassName = getIndicatorClassName({ transitionEnabled: transitionsEnabled });
|
|
300
419
|
const position = indicatorIndex;
|
|
301
420
|
const lowerIndex = Math.max(0, Math.floor(position));
|
|
302
421
|
const upperIndex = Math.min(items.length - 1, Math.ceil(position));
|
|
@@ -305,7 +424,7 @@ var TabsIndicator = React.forwardRef((props, ref) => {
|
|
|
305
424
|
const upperRect = triggerRects[items[upperIndex]?.value ?? ""] ?? lowerRect;
|
|
306
425
|
const x = lowerRect ? lowerRect.left + ((upperRect?.left ?? lowerRect.left) - lowerRect.left) * progress : 0;
|
|
307
426
|
const width = lowerRect ? lowerRect.width + ((upperRect?.width ?? lowerRect.width) - lowerRect.width) * progress : 0;
|
|
308
|
-
return <view {...mergeProps({ "main-thread:ref": indicatorRef }, ref ? { ref } : {}, nativeProps)} accessibility-elements-hidden={true} className={clsx(
|
|
427
|
+
return <view {...mergeProps({ "main-thread:ref": indicatorRef }, ref ? { ref } : {}, nativeProps)} accessibility-elements-hidden={true} className={clsx(indicatorClassName, className)} style={{
|
|
309
428
|
"--tabs-indicator-x": `${x}px`,
|
|
310
429
|
"--tabs-indicator-width": `${width}px`,
|
|
311
430
|
...style
|
|
@@ -318,8 +437,7 @@ var TabsContent = React.forwardRef((props, ref) => {
|
|
|
318
437
|
const inCarousel = useTabsCarouselCameraContext();
|
|
319
438
|
const selected = tabsContext.value === contentValue;
|
|
320
439
|
const disabled = tabsContext.items.find((item) => item.value === contentValue)?.disabled ?? false;
|
|
321
|
-
const contentClasses =
|
|
322
|
-
...tabsContext.variantProps,
|
|
440
|
+
const contentClasses = tabsContext.getClassNames({
|
|
323
441
|
selected,
|
|
324
442
|
inCarousel
|
|
325
443
|
});
|
|
@@ -343,7 +461,7 @@ var TabsContent = React.forwardRef((props, ref) => {
|
|
|
343
461
|
TabsContent.displayName = "TabsContent";
|
|
344
462
|
var TabsCarousel = React.forwardRef((props, ref) => {
|
|
345
463
|
const { children, className, style, swipeable = false, iosBackGestureEdgeWidth = 32, onSettle, onSwipeStart, onSwipeEnd, ...nativeProps } = props;
|
|
346
|
-
const classNames =
|
|
464
|
+
const { classNames } = useTabsContext("TabsCarousel");
|
|
347
465
|
const contextValue = React.useMemo(() => ({
|
|
348
466
|
swipeable,
|
|
349
467
|
iosBackGestureEdgeWidth,
|
|
@@ -366,19 +484,33 @@ var TabsCarousel = React.forwardRef((props, ref) => {
|
|
|
366
484
|
TabsCarousel.displayName = "TabsCarousel";
|
|
367
485
|
var TabsCarouselCamera = React.forwardRef((props, ref) => {
|
|
368
486
|
const { children, className, style, bindchange, bindwillchange, bindoffsetchange, ...nativeProps } = props;
|
|
369
|
-
const classNames = useClassNames();
|
|
370
487
|
const tabsContext = useTabsContext("TabsCarouselCamera");
|
|
488
|
+
const { classNames } = tabsContext;
|
|
371
489
|
const carouselContext = useTabsCarouselContext("TabsCarouselCamera");
|
|
372
490
|
const swipingRef = React.useRef(false);
|
|
373
491
|
const { indicatorRef, pagerValues, triggerRects } = tabsContext;
|
|
374
492
|
const indicatorRects = pagerValues.map((value) => triggerRects[value] ?? null);
|
|
375
493
|
const mergedRef = React.useMemo(() => mergeProps({ ref: tabsContext.setPagerRef }, { ref }).ref, [ref, tabsContext.setPagerRef]);
|
|
494
|
+
const finishSwipe = React.useCallback(() => {
|
|
495
|
+
"background only";
|
|
496
|
+
if (!swipingRef.current) return;
|
|
497
|
+
swipingRef.current = false;
|
|
498
|
+
carouselContext.onSwipeEnd?.();
|
|
499
|
+
}, [carouselContext.onSwipeEnd]);
|
|
500
|
+
const handleTouchEnd = React.useCallback(() => {
|
|
501
|
+
"background only";
|
|
502
|
+
finishSwipe();
|
|
503
|
+
}, [finishSwipe]);
|
|
504
|
+
const handleTouchCancel = React.useCallback(() => {
|
|
505
|
+
"background only";
|
|
506
|
+
finishSwipe();
|
|
507
|
+
}, [finishSwipe]);
|
|
376
508
|
const handleWillChange = React.useCallback((event) => {
|
|
377
509
|
"background only";
|
|
378
510
|
bindwillchange?.(event);
|
|
379
511
|
if (event.detail.isDragged) {
|
|
380
512
|
tabsContext.handlePagerWillChange(event.detail.index);
|
|
381
|
-
if (!swipingRef.current) {
|
|
513
|
+
if (carouselContext.swipeable && !swipingRef.current) {
|
|
382
514
|
swipingRef.current = true;
|
|
383
515
|
carouselContext.onSwipeStart?.();
|
|
384
516
|
}
|
|
@@ -386,6 +518,7 @@ var TabsCarouselCamera = React.forwardRef((props, ref) => {
|
|
|
386
518
|
}, [
|
|
387
519
|
bindwillchange,
|
|
388
520
|
carouselContext.onSwipeStart,
|
|
521
|
+
carouselContext.swipeable,
|
|
389
522
|
tabsContext.handlePagerWillChange
|
|
390
523
|
]);
|
|
391
524
|
const handleChange = React.useCallback((event) => {
|
|
@@ -393,14 +526,9 @@ var TabsCarouselCamera = React.forwardRef((props, ref) => {
|
|
|
393
526
|
bindchange?.(event);
|
|
394
527
|
tabsContext.handlePagerChange(event.detail.index);
|
|
395
528
|
carouselContext.onSettle?.();
|
|
396
|
-
if (swipingRef.current || event.detail.isDragged) {
|
|
397
|
-
swipingRef.current = false;
|
|
398
|
-
carouselContext.onSwipeEnd?.();
|
|
399
|
-
}
|
|
400
529
|
}, [
|
|
401
530
|
bindchange,
|
|
402
531
|
carouselContext.onSettle,
|
|
403
|
-
carouselContext.onSwipeEnd,
|
|
404
532
|
tabsContext.handlePagerChange
|
|
405
533
|
]);
|
|
406
534
|
const handleOffsetChange = React.useCallback((event) => {
|
|
@@ -426,6 +554,8 @@ var TabsCarouselCamera = React.forwardRef((props, ref) => {
|
|
|
426
554
|
}
|
|
427
555
|
return <viewpager {...mergeProps({
|
|
428
556
|
ref: mergedRef,
|
|
557
|
+
bindtouchend: handleTouchEnd,
|
|
558
|
+
bindtouchcancel: handleTouchCancel,
|
|
429
559
|
bindwillchange: handleWillChange,
|
|
430
560
|
bindchange: handleChange,
|
|
431
561
|
bindoffsetchange: handleOffsetChange,
|
|
@@ -438,4 +568,4 @@ var TabsCarouselCamera = React.forwardRef((props, ref) => {
|
|
|
438
568
|
});
|
|
439
569
|
TabsCarouselCamera.displayName = "TabsCarouselCamera";
|
|
440
570
|
//#endregion
|
|
441
|
-
export { TabsCarousel, TabsCarouselCamera, TabsContent, TabsIndicator, TabsList, TabsRoot, TabsTrigger };
|
|
571
|
+
export { TabsCarousel, TabsCarouselCamera, TabsContent, TabsIndicator, TabsList, TabsRoot, TabsRootPrimitive, TabsTrigger };
|
|
@@ -14,6 +14,19 @@ export declare function getTabsLayoutWidth(event: TabsLayoutChangeEvent): number
|
|
|
14
14
|
export declare function getTabsOrderedItems<T extends {
|
|
15
15
|
value: string;
|
|
16
16
|
}>(items: T[], values: string[]): T[];
|
|
17
|
-
export declare function getTabsTriggerRects(values: string[], widths: Record<string, number
|
|
17
|
+
export declare function getTabsTriggerRects(values: string[], widths: Record<string, number>, triggerGap?: number): Record<string, TabsLayoutRect>;
|
|
18
|
+
/**
|
|
19
|
+
* Trigger rectangles begin at the first trigger, so they exclude list-content
|
|
20
|
+
* padding. Scroll offsets are measured from the scroll content edge.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getTabsScrollOffset({ scrollAlign, currentOffset, viewportWidth, contentWidth, contentInsetStart, contentInsetEnd, triggerRect, }: {
|
|
23
|
+
scrollAlign: "nearest" | "start" | "center" | "end";
|
|
24
|
+
currentOffset: number;
|
|
25
|
+
viewportWidth: number;
|
|
26
|
+
contentWidth: number;
|
|
27
|
+
contentInsetStart: number;
|
|
28
|
+
contentInsetEnd: number;
|
|
29
|
+
triggerRect: TabsLayoutRect;
|
|
30
|
+
}): number;
|
|
18
31
|
export declare function areTabsTransitionsEnabled(values: string[], rects: Record<string, TabsLayoutRect>): boolean;
|
|
19
32
|
//# sourceMappingURL=Tabs.utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.utils.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/Tabs.utils.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,qBAAqB,GAAG,MAAM,GAAG,IAAI,CAI9E;AAED,wBAAgB,mBAAmB,CAAC,CAAC,SAAS;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EAC7D,KAAK,EAAE,CAAC,EAAE,EACV,MAAM,EAAE,MAAM,EAAE,GACf,CAAC,EAAE,CAUL;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EAAE,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"Tabs.utils.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/Tabs.utils.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,qBAAqB,GAAG,MAAM,GAAG,IAAI,CAI9E;AAED,wBAAgB,mBAAmB,CAAC,CAAC,SAAS;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EAC7D,KAAK,EAAE,CAAC,EAAE,EACV,MAAM,EAAE,MAAM,EAAE,GACf,CAAC,EAAE,CAUL;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EAAE,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,UAAU,SAAI,GACb,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAiBhC;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,WAAW,EACX,aAAa,EACb,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,WAAW,GACZ,EAAE;IACD,WAAW,EAAE,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACpD,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,cAAc,CAAC;CAC7B,GAAG,MAAM,CA2BT;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,EAAE,EAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GACpC,OAAO,CAET"}
|
|
@@ -15,7 +15,7 @@ function getTabsOrderedItems(items, values) {
|
|
|
15
15
|
ordered.push(...itemsByValue.values());
|
|
16
16
|
return ordered;
|
|
17
17
|
}
|
|
18
|
-
function getTabsTriggerRects(values, widths) {
|
|
18
|
+
function getTabsTriggerRects(values, widths, triggerGap = 0) {
|
|
19
19
|
const rects = Object.create(null);
|
|
20
20
|
let left = 0;
|
|
21
21
|
let hasCompletePrefix = true;
|
|
@@ -29,12 +29,33 @@ function getTabsTriggerRects(values, widths) {
|
|
|
29
29
|
left,
|
|
30
30
|
width
|
|
31
31
|
};
|
|
32
|
-
left += width;
|
|
32
|
+
left += width + triggerGap;
|
|
33
33
|
}
|
|
34
34
|
return rects;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Trigger rectangles begin at the first trigger, so they exclude list-content
|
|
38
|
+
* padding. Scroll offsets are measured from the scroll content edge.
|
|
39
|
+
*/
|
|
40
|
+
function getTabsScrollOffset({ scrollAlign, currentOffset, viewportWidth, contentWidth, contentInsetStart, contentInsetEnd, triggerRect }) {
|
|
41
|
+
const maxOffset = Math.max(0, contentWidth - viewportWidth);
|
|
42
|
+
const clampOffset = (offset) => Math.min(maxOffset, Math.max(0, offset));
|
|
43
|
+
const clampedCurrentOffset = clampOffset(currentOffset);
|
|
44
|
+
if (maxOffset === 0) return clampedCurrentOffset;
|
|
45
|
+
const triggerStart = contentInsetStart + triggerRect.left;
|
|
46
|
+
const triggerEnd = triggerStart + triggerRect.width;
|
|
47
|
+
if (scrollAlign === "nearest") {
|
|
48
|
+
const visibleStart = clampedCurrentOffset;
|
|
49
|
+
const visibleEnd = clampedCurrentOffset + viewportWidth;
|
|
50
|
+
if (triggerStart >= visibleStart && triggerEnd <= visibleEnd) return clampedCurrentOffset;
|
|
51
|
+
return clampOffset(triggerStart < visibleStart ? triggerStart - contentInsetStart : triggerEnd + contentInsetEnd - viewportWidth);
|
|
52
|
+
}
|
|
53
|
+
if (scrollAlign === "start") return clampOffset(triggerStart - contentInsetStart);
|
|
54
|
+
if (scrollAlign === "center") return clampOffset(triggerStart + triggerRect.width / 2 - viewportWidth / 2);
|
|
55
|
+
return clampOffset(triggerEnd + contentInsetEnd - viewportWidth);
|
|
56
|
+
}
|
|
36
57
|
function areTabsTransitionsEnabled(values, rects) {
|
|
37
58
|
return values.length > 0 && values.every((value) => rects[value] !== void 0);
|
|
38
59
|
}
|
|
39
60
|
//#endregion
|
|
40
|
-
export { areTabsTransitionsEnabled, getTabsLayoutWidth, getTabsOrderedItems, getTabsTriggerRects };
|
|
61
|
+
export { areTabsTransitionsEnabled, getTabsLayoutWidth, getTabsOrderedItems, getTabsScrollOffset, getTabsTriggerRects };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { TabsCarousel, TabsCarouselCamera, TabsContent, TabsIndicator, TabsList, TabsRoot, TabsTrigger, type TabsCarouselCameraProps, type TabsCarouselProps, type TabsContentProps, type TabsIndicatorProps, type TabsListProps, type TabsRootProps, type TabsTriggerProps, } from './Tabs';
|
|
2
2
|
export * as Tabs from './Tabs.namespace';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,GACtB,MAAM,QAAQ,CAAC;AAEhB,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC"}
|
|
@@ -7,10 +7,17 @@ export * from './BottomSheet';
|
|
|
7
7
|
export * from './Callout';
|
|
8
8
|
export * from './Checkbox';
|
|
9
9
|
export * from './Chip';
|
|
10
|
+
export * from './ChipTabs';
|
|
10
11
|
export * from './Count';
|
|
12
|
+
export * from './ContextualFloatingButton';
|
|
11
13
|
export * from './Divider';
|
|
12
14
|
export * from './Field';
|
|
15
|
+
export * from './FloatingActionButton';
|
|
13
16
|
export * from './Icon';
|
|
17
|
+
export * from './Dialog';
|
|
18
|
+
export * from './AlertDialog';
|
|
19
|
+
export * from './HelpBubble';
|
|
20
|
+
export * from './IdentityPlaceholder';
|
|
14
21
|
export * from './InputButton';
|
|
15
22
|
export * from './KeyboardAvoidingScrollView';
|
|
16
23
|
export * from './MannerTemp';
|
|
@@ -20,16 +27,23 @@ export * from './NotificationBadge';
|
|
|
20
27
|
export * from './PageBanner';
|
|
21
28
|
export * from './List';
|
|
22
29
|
export * from './ProgressCircle';
|
|
30
|
+
export * from './QuantityPicker';
|
|
23
31
|
export * from './RadioGroup';
|
|
24
32
|
export * from './ReactionButton';
|
|
25
33
|
export * from './ScaleFeedback';
|
|
26
34
|
export * from './SegmentedControl';
|
|
35
|
+
export * from './Select';
|
|
27
36
|
export * from './SelectBox';
|
|
37
|
+
export * from './Skeleton';
|
|
38
|
+
export * from './Slider';
|
|
28
39
|
export * from './Stack';
|
|
29
40
|
export * from './Switch';
|
|
41
|
+
export * from './ScrollFog';
|
|
30
42
|
export * from './SwipeableMenuSheet';
|
|
31
43
|
export * from './Tabs';
|
|
32
44
|
export * from './TagGroup';
|
|
33
45
|
export * from './Text';
|
|
34
46
|
export * from './TextField';
|
|
47
|
+
export * from './AttachmentInput';
|
|
48
|
+
export * from './AttachmentDisplay';
|
|
35
49
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AACrC,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
value?: T;
|
|
3
|
-
defaultValue: T;
|
|
4
|
-
onChange?: (value: T) => void;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Controlled/uncontrolled state pattern for Lynx components.
|
|
8
|
-
*
|
|
9
|
-
* - When `value` is provided, the component is controlled.
|
|
10
|
-
* - When `value` is `undefined`, the component manages its own state
|
|
11
|
-
* starting from `defaultValue`.
|
|
12
|
-
* - `onChange` fires in both modes.
|
|
13
|
-
*/
|
|
14
|
-
export declare function useControllableState<T>(props: UseControllableStateProps<T>): [T, (value: T) => void];
|
|
1
|
+
export * from '@seed-design/lynx-react-use-controllable-state';
|
|
15
2
|
//# sourceMappingURL=useControllableState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useControllableState.d.ts","sourceRoot":"","sources":["../../src/hooks/useControllableState.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useControllableState.d.ts","sourceRoot":"","sources":["../../src/hooks/useControllableState.ts"],"names":[],"mappings":"AAAA,cAAc,gDAAgD,CAAC"}
|
|
@@ -1,28 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { LynxTouchProps } from '../types';
|
|
3
|
-
type TouchHandler = EventHandler<BaseTouchEvent<Target>>;
|
|
4
|
-
type PressStateHandler = TouchHandler & (() => void);
|
|
5
|
-
export interface UsePressTapOptions {
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
onTap?: TouchHandler;
|
|
8
|
-
mainThreadOnTap?: LynxTouchProps["main-thread:bindtap"];
|
|
9
|
-
}
|
|
10
|
-
export interface UsePressTapReturn {
|
|
11
|
-
pressed: boolean;
|
|
12
|
-
bindtap: TouchHandler;
|
|
13
|
-
bindtouchstart: PressStateHandler;
|
|
14
|
-
bindtouchend: PressStateHandler;
|
|
15
|
-
bindtouchcancel: PressStateHandler;
|
|
16
|
-
"main-thread:bindtap"?: LynxTouchProps["main-thread:bindtap"];
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Hook that provides press/tap interaction state for Lynx elements.
|
|
20
|
-
*
|
|
21
|
-
* - Tracks `pressed` state via touch events.
|
|
22
|
-
* - When `disabled` is true, the element cannot become active and no tap fires.
|
|
23
|
-
* - If the element becomes disabled during a press, the active state is cleared.
|
|
24
|
-
* - `main-thread:bindtap` is conditionally included (only when enabled and provided).
|
|
25
|
-
*/
|
|
26
|
-
export declare function usePressTap(options?: UsePressTapOptions): UsePressTapReturn;
|
|
27
|
-
export {};
|
|
1
|
+
export * from '@seed-design/lynx-react-use-press-tap';
|
|
28
2
|
//# sourceMappingURL=usePressTap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePressTap.d.ts","sourceRoot":"","sources":["../../src/hooks/usePressTap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePressTap.d.ts","sourceRoot":"","sources":["../../src/hooks/usePressTap.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAC"}
|