storybook 10.1.0-alpha.9 → 10.1.0-beta.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/dist/_browser-chunks/Color-FTG7SQDA.js +1097 -0
- package/dist/_browser-chunks/WithTooltip-LMROHDUP.js +1651 -0
- package/dist/_browser-chunks/chunk-2FRVAXCZ.js +7 -0
- package/dist/_browser-chunks/{chunk-FDWKXLBI.js → chunk-2XZMBGTA.js} +44 -109
- package/dist/_browser-chunks/chunk-3IAH5M2U.js +171 -0
- package/dist/_browser-chunks/chunk-3OXGAGBE.js +779 -0
- package/dist/_browser-chunks/{chunk-TMDZCWME.js → chunk-3PJE6VLG.js} +1 -3
- package/dist/_browser-chunks/{chunk-VAMFPZY3.js → chunk-45UGUKRX.js} +2 -7
- package/dist/_browser-chunks/chunk-6XWLIJQL.js +11 -0
- package/dist/_browser-chunks/{chunk-MM7DTO55.js → chunk-A242L54C.js} +10 -16
- package/dist/_browser-chunks/chunk-AIOS4NGK.js +252 -0
- package/dist/_browser-chunks/chunk-AS2HQEYC.js +14 -0
- package/dist/_browser-chunks/chunk-AXG2BOBL.js +836 -0
- package/dist/_browser-chunks/{chunk-MH6AXFXB.js → chunk-CHUV5WSW.js} +0 -5
- package/dist/_browser-chunks/chunk-EUVGDK4H.js +93 -0
- package/dist/_browser-chunks/chunk-EZSQOHRI.js +18 -0
- package/dist/_browser-chunks/{chunk-CADGRH3P.js → chunk-FNXWN6IK.js} +3 -8
- package/dist/_browser-chunks/chunk-FQ7SLVLR.js +66 -0
- package/dist/_browser-chunks/chunk-GFLS4VP3.js +64 -0
- package/dist/_browser-chunks/chunk-GFY5R5EY.js +47 -0
- package/dist/_browser-chunks/{chunk-L2D73C6Z.js → chunk-H6XK3RSC.js} +13 -21
- package/dist/_browser-chunks/chunk-IPA5A322.js +71 -0
- package/dist/_browser-chunks/chunk-JP7NCOJX.js +37 -0
- package/dist/_browser-chunks/chunk-KJHJLCBK.js +11 -0
- package/dist/_browser-chunks/{chunk-OWPZQM2D.js → chunk-L4RMQ7D7.js} +60 -110
- package/dist/_browser-chunks/chunk-P4F4UVXX.js +951 -0
- package/dist/_browser-chunks/{chunk-AB7OOPUX.js → chunk-QKODTO7K.js} +0 -5
- package/dist/_browser-chunks/chunk-RP5RXKFU.js +2491 -0
- package/dist/_browser-chunks/chunk-SL75JR6Y.js +9 -0
- package/dist/_browser-chunks/chunk-SS2NHR7W.js +2969 -0
- package/dist/_browser-chunks/chunk-UD6FQLAF.js +1481 -0
- package/dist/_browser-chunks/chunk-VYJQ7RU5.js +2853 -0
- package/dist/_browser-chunks/chunk-WJYERY3R.js +136 -0
- package/dist/_browser-chunks/chunk-XJNX76GA.js +85 -0
- package/dist/_browser-chunks/{chunk-F4Q6SGTB.js → chunk-YKE5S47A.js} +177 -399
- package/dist/_browser-chunks/{chunk-SN4J4IQ3.js → chunk-ZUWEVLDX.js} +1 -7
- package/dist/_browser-chunks/{formatter-OMEEQ6HG.js → formatter-QJ4M4OGQ.js} +4 -9
- package/dist/_browser-chunks/{syntaxhighlighter-CAVLW7PM.js → syntaxhighlighter-IQDEPFLK.js} +704 -1848
- package/dist/_node-chunks/{builder-manager-SM3UWERX.js → builder-manager-BDAQHXFI.js} +510 -1019
- package/dist/_node-chunks/camelcase-3C7DZZPX.js +37 -0
- package/dist/_node-chunks/chunk-2IIQTGNE.js +6024 -0
- package/dist/_node-chunks/chunk-56U5LEMP.js +3043 -0
- package/dist/_node-chunks/chunk-7LIRCAQE.js +20 -0
- package/dist/_node-chunks/chunk-7RN6TXKP.js +603 -0
- package/dist/_node-chunks/chunk-7SJ7PZNL.js +4523 -0
- package/dist/_node-chunks/{chunk-HHSTA6QS.js → chunk-BG4RDXG7.js} +8 -10
- package/dist/_node-chunks/chunk-CBQKMXLQ.js +18 -0
- package/dist/_node-chunks/chunk-CN2IW2KQ.js +1564 -0
- package/dist/_node-chunks/chunk-CQMAU6UQ.js +943 -0
- package/dist/_node-chunks/{chunk-EBUEXRH5.js → chunk-D6ND3TVY.js} +116 -276
- package/dist/_node-chunks/chunk-DC355CYB.js +61 -0
- package/dist/_node-chunks/{chunk-SGM3ZCCT.js → chunk-EVK2SBW5.js} +292 -688
- package/dist/_node-chunks/chunk-IXWEUXJ2.js +119 -0
- package/dist/_node-chunks/{chunk-F6EFOEC7.js → chunk-KVRF22SH.js} +469 -983
- package/dist/_node-chunks/chunk-LEDP4QQW.js +919 -0
- package/dist/_node-chunks/{chunk-GHIBZRKD.js → chunk-MMVV6DGG.js} +8133 -8887
- package/dist/_node-chunks/chunk-O5CGEVRI.js +29 -0
- package/dist/_node-chunks/chunk-OZZO56XN.js +299 -0
- package/dist/_node-chunks/chunk-POT2EVGD.js +78 -0
- package/dist/_node-chunks/chunk-R5YGFSTV.js +3781 -0
- package/dist/_node-chunks/chunk-SQCTM2OS.js +23 -0
- package/dist/_node-chunks/chunk-UFOFO5H7.js +54 -0
- package/dist/_node-chunks/chunk-VBF7ALJF.js +72 -0
- package/dist/_node-chunks/chunk-W6MAMTUF.js +70 -0
- package/dist/_node-chunks/chunk-WURL4XOT.js +46662 -0
- package/dist/_node-chunks/chunk-XGK6MVKR.js +61 -0
- package/dist/_node-chunks/chunk-YV3GDSDT.js +765 -0
- package/dist/_node-chunks/{chunk-ATDHMMIZ.js → chunk-YWV55YW3.js} +15 -24
- package/dist/_node-chunks/dist-KEP4IFRN.js +121 -0
- package/dist/_node-chunks/globby-4WUBTDCN.js +3452 -0
- package/dist/_node-chunks/lib-JVOEKTYM.js +366 -0
- package/dist/_node-chunks/mdx-N42X6CFJ-C5WFYYXR.js +14329 -0
- package/dist/_node-chunks/p-limit-LDY632RS.js +116 -0
- package/dist/actions/decorator.js +21 -42
- package/dist/actions/index.js +3 -3
- package/dist/babel/index.d.ts +671 -335
- package/dist/babel/index.js +10 -11
- package/dist/bin/core.js +601 -1548
- package/dist/bin/dispatcher.js +36 -36
- package/dist/bin/loader.js +24 -38
- package/dist/channels/index.js +98 -234
- package/dist/cli/index.d.ts +1479 -133
- package/dist/cli/index.js +30 -8540
- package/dist/client-logger/index.js +31 -61
- package/dist/common/index.d.ts +139 -62
- package/dist/common/index.js +66 -51
- package/dist/components/index.d.ts +575 -273
- package/dist/components/index.js +14863 -4313
- package/dist/core-events/index.js +2 -66
- package/dist/core-server/index.d.ts +3 -2
- package/dist/core-server/index.js +2908 -8518
- package/dist/core-server/presets/common-manager.css +2 -2
- package/dist/core-server/presets/common-manager.js +2521 -5233
- package/dist/core-server/presets/common-override-preset.js +31 -60
- package/dist/core-server/presets/common-preset.js +663 -962
- package/dist/csf/index.js +534 -1179
- package/dist/csf-tools/index.js +9 -9
- package/dist/docs-tools/index.js +6 -6
- package/dist/highlight/index.js +2 -2
- package/dist/instrumenter/index.js +199 -415
- package/dist/manager/globals-runtime.js +59044 -67141
- package/dist/manager/globals.js +2 -3
- package/dist/manager/manager-stores.d.ts +1 -0
- package/dist/manager/manager-stores.js +23 -0
- package/dist/manager/runtime.js +11511 -10953
- package/dist/manager-api/index.d.ts +1811 -2
- package/dist/manager-api/index.js +1348 -2401
- package/dist/manager-errors.d.ts +9 -0
- package/dist/manager-errors.js +3 -3
- package/dist/mocking-utils/index.d.ts +1126 -0
- package/dist/mocking-utils/index.js +1181 -0
- package/dist/node-logger/index.d.ts +192 -24
- package/dist/node-logger/index.js +23 -4471
- package/dist/preview/globals.js +2 -3
- package/dist/preview/runtime.js +10799 -22393
- package/dist/preview-api/index.d.ts +68 -69
- package/dist/preview-api/index.js +13 -13
- package/dist/preview-errors.d.ts +9 -0
- package/dist/preview-errors.js +4 -4
- package/dist/router/index.js +347 -899
- package/dist/server-errors.d.ts +34 -1
- package/dist/server-errors.js +17 -10
- package/dist/telemetry/index.d.ts +24 -3
- package/dist/telemetry/index.js +25 -24
- package/dist/test/index.js +6131 -11916
- package/dist/theming/create.d.ts +1 -0
- package/dist/theming/create.js +4 -4
- package/dist/theming/index.d.ts +3366 -2599
- package/dist/theming/index.js +501 -1091
- package/dist/types/index.d.ts +72 -8
- package/dist/types/index.js +27 -12
- package/dist/viewport/index.js +3 -3
- package/package.json +26 -17
- package/dist/_browser-chunks/Color-7ZNS6F6B.js +0 -1676
- package/dist/_browser-chunks/WithTooltip-SK46ZJ2J.js +0 -13
- package/dist/_browser-chunks/chunk-6A7OIVEL.js +0 -66
- package/dist/_browser-chunks/chunk-B4A3ADP3.js +0 -3816
- package/dist/_browser-chunks/chunk-BOOOPFZF.js +0 -2335
- package/dist/_browser-chunks/chunk-FSBVR7H5.js +0 -106
- package/dist/_browser-chunks/chunk-FUOHXXZT.js +0 -23
- package/dist/_browser-chunks/chunk-GTKOCWCT.js +0 -17
- package/dist/_browser-chunks/chunk-HHW4FUMO.js +0 -12
- package/dist/_browser-chunks/chunk-JVSKG4YS.js +0 -4052
- package/dist/_browser-chunks/chunk-LASUB7TL.js +0 -76
- package/dist/_browser-chunks/chunk-LYCSRYYR.js +0 -101
- package/dist/_browser-chunks/chunk-NVV6MIOE.js +0 -243
- package/dist/_browser-chunks/chunk-OBXWFEPB.js +0 -852
- package/dist/_browser-chunks/chunk-OPCDBBL3.js +0 -48
- package/dist/_browser-chunks/chunk-PB6FZ3WE.js +0 -130
- package/dist/_browser-chunks/chunk-RNE2IUTB.js +0 -1300
- package/dist/_browser-chunks/chunk-RW5PKMWM.js +0 -4182
- package/dist/_browser-chunks/chunk-SYS437NN.js +0 -122
- package/dist/_browser-chunks/chunk-U46RQHA4.js +0 -12
- package/dist/_browser-chunks/chunk-UTNZYD2N.js +0 -311
- package/dist/_browser-chunks/chunk-VUAFL5XK.js +0 -20
- package/dist/_browser-chunks/chunk-XDGMHOV7.js +0 -2197
- package/dist/_browser-chunks/chunk-XW6KSYKF.js +0 -16
- package/dist/_browser-chunks/chunk-Y3M7TW6K.js +0 -1041
- package/dist/_browser-chunks/chunk-ZNRFDIVA.js +0 -233
- package/dist/_node-chunks/camelcase-H5QSGQLK.js +0 -18
- package/dist/_node-chunks/chunk-3THWHQOC.js +0 -61
- package/dist/_node-chunks/chunk-45YUOLTU.js +0 -69
- package/dist/_node-chunks/chunk-4QSNCPAU.js +0 -64656
- package/dist/_node-chunks/chunk-744PQSOU.js +0 -79
- package/dist/_node-chunks/chunk-74Z2U7QG.js +0 -1544
- package/dist/_node-chunks/chunk-7MB7TFPO.js +0 -1198
- package/dist/_node-chunks/chunk-A7GS4RFT.js +0 -697
- package/dist/_node-chunks/chunk-BIA3A5UM.js +0 -61
- package/dist/_node-chunks/chunk-C5G7CLWX.js +0 -1657
- package/dist/_node-chunks/chunk-DLFUKMYJ.js +0 -1531
- package/dist/_node-chunks/chunk-EMRGRXKT.js +0 -111
- package/dist/_node-chunks/chunk-EX46EHHY.js +0 -420
- package/dist/_node-chunks/chunk-F76QKNOJ.js +0 -304
- package/dist/_node-chunks/chunk-HDCRUTEF.js +0 -220
- package/dist/_node-chunks/chunk-HUYAOIPH.js +0 -90
- package/dist/_node-chunks/chunk-IBJZQZJC.js +0 -101
- package/dist/_node-chunks/chunk-KZN2RDDT.js +0 -6712
- package/dist/_node-chunks/chunk-LYUNFU3F.js +0 -4741
- package/dist/_node-chunks/chunk-N44SIS6K.js +0 -28
- package/dist/_node-chunks/chunk-NILZM6KR.js +0 -18
- package/dist/_node-chunks/chunk-PC4ZRP6W.js +0 -34
- package/dist/_node-chunks/chunk-TJNGOQUH.js +0 -4272
- package/dist/_node-chunks/chunk-UBSYLHIL.js +0 -1250
- package/dist/_node-chunks/chunk-UTCLXPOC.js +0 -1518
- package/dist/_node-chunks/chunk-WOXXODXP.js +0 -5029
- package/dist/_node-chunks/chunk-XC4MEUA6.js +0 -1586
- package/dist/_node-chunks/chunk-YRXXMKRR.js +0 -2256
- package/dist/_node-chunks/dist-SL73W244.js +0 -175
- package/dist/_node-chunks/globby-ZSHAUQZ5.js +0 -5222
- package/dist/_node-chunks/lib-U2VIPUTI.js +0 -518
- package/dist/_node-chunks/mdx-N42X6CFJ-ZLHD33JK.js +0 -22017
- package/dist/_node-chunks/p-limit-K5BS5MSV.js +0 -168
- package/dist/_node-chunks/plugin-5PD4YIUH.js +0 -129
- package/dist/_node-chunks/plugin-MONDT2WL.js +0 -159
- package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-EUZJRG3W.js +0 -69102
- package/dist/_node-chunks/webpack-mock-plugin-T4LDXEHE.js +0 -124
- package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +0 -36
- package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +0 -33
|
@@ -0,0 +1,951 @@
|
|
|
1
|
+
// src/components/components/ActionBar/ActionBar.tsx
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { styled } from "storybook/theming";
|
|
4
|
+
var Container = styled.div(({ theme }) => ({
|
|
5
|
+
position: "absolute",
|
|
6
|
+
bottom: 0,
|
|
7
|
+
right: 0,
|
|
8
|
+
maxWidth: "100%",
|
|
9
|
+
display: "flex",
|
|
10
|
+
background: theme.background.content,
|
|
11
|
+
zIndex: 1
|
|
12
|
+
})), ActionButton = styled.button(
|
|
13
|
+
({ theme }) => ({
|
|
14
|
+
margin: 0,
|
|
15
|
+
border: "0 none",
|
|
16
|
+
padding: "4px 10px",
|
|
17
|
+
cursor: "pointer",
|
|
18
|
+
display: "flex",
|
|
19
|
+
alignItems: "center",
|
|
20
|
+
color: theme.color.defaultText,
|
|
21
|
+
background: theme.background.content,
|
|
22
|
+
fontSize: 12,
|
|
23
|
+
lineHeight: "16px",
|
|
24
|
+
fontFamily: theme.typography.fonts.base,
|
|
25
|
+
fontWeight: theme.typography.weight.bold,
|
|
26
|
+
borderTop: `1px solid ${theme.appBorderColor}`,
|
|
27
|
+
borderLeft: `1px solid ${theme.appBorderColor}`,
|
|
28
|
+
marginLeft: -1,
|
|
29
|
+
borderRadius: "4px 0 0 0",
|
|
30
|
+
"&:not(:last-child)": { borderRight: `1px solid ${theme.appBorderColor}` },
|
|
31
|
+
"& + *": {
|
|
32
|
+
borderLeft: `1px solid ${theme.appBorderColor}`,
|
|
33
|
+
borderRadius: 0
|
|
34
|
+
},
|
|
35
|
+
"&:focus": {
|
|
36
|
+
boxShadow: `${theme.color.secondary} 0 -3px 0 0 inset`,
|
|
37
|
+
outline: "0 none",
|
|
38
|
+
"@media (forced-colors: active)": {
|
|
39
|
+
outline: "1px solid highlight"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}),
|
|
43
|
+
({ disabled }) => disabled && {
|
|
44
|
+
cursor: "not-allowed",
|
|
45
|
+
opacity: 0.5
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
ActionButton.displayName = "ActionButton";
|
|
49
|
+
var ActionBar = ({ actionItems, ...props }) => React.createElement(Container, { ...props }, actionItems.map(({ title, className, onClick, disabled }, index) => React.createElement(ActionButton, { key: index, className, onClick, disabled: !!disabled }, title)));
|
|
50
|
+
|
|
51
|
+
// src/components/components/ScrollArea/ScrollArea.tsx
|
|
52
|
+
import React11, { forwardRef as forwardRef4 } from "react";
|
|
53
|
+
|
|
54
|
+
// ../node_modules/@radix-ui/react-scroll-area/dist/index.mjs
|
|
55
|
+
import * as React23 from "react";
|
|
56
|
+
|
|
57
|
+
// ../node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-primitive/dist/index.mjs
|
|
58
|
+
import * as React4 from "react";
|
|
59
|
+
import * as ReactDOM from "react-dom";
|
|
60
|
+
|
|
61
|
+
// ../node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-slot/dist/index.mjs
|
|
62
|
+
import * as React3 from "react";
|
|
63
|
+
|
|
64
|
+
// ../node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-compose-refs/dist/index.mjs
|
|
65
|
+
import * as React2 from "react";
|
|
66
|
+
function setRef(ref, value) {
|
|
67
|
+
typeof ref == "function" ? ref(value) : ref != null && (ref.current = value);
|
|
68
|
+
}
|
|
69
|
+
function composeRefs(...refs) {
|
|
70
|
+
return (node) => refs.forEach((ref) => setRef(ref, node));
|
|
71
|
+
}
|
|
72
|
+
function useComposedRefs(...refs) {
|
|
73
|
+
return React2.useCallback(composeRefs(...refs), refs);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ../node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-slot/dist/index.mjs
|
|
77
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
78
|
+
var Slot = React3.forwardRef((props, forwardedRef) => {
|
|
79
|
+
let { children, ...slotProps } = props, childrenArray = React3.Children.toArray(children), slottable = childrenArray.find(isSlottable);
|
|
80
|
+
if (slottable) {
|
|
81
|
+
let newElement = slottable.props.children, newChildren = childrenArray.map((child) => child === slottable ? React3.Children.count(newElement) > 1 ? React3.Children.only(null) : React3.isValidElement(newElement) ? newElement.props.children : null : child);
|
|
82
|
+
return jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React3.isValidElement(newElement) ? React3.cloneElement(newElement, void 0, newChildren) : null });
|
|
83
|
+
}
|
|
84
|
+
return jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
85
|
+
});
|
|
86
|
+
Slot.displayName = "Slot";
|
|
87
|
+
var SlotClone = React3.forwardRef((props, forwardedRef) => {
|
|
88
|
+
let { children, ...slotProps } = props;
|
|
89
|
+
if (React3.isValidElement(children)) {
|
|
90
|
+
let childrenRef = getElementRef(children);
|
|
91
|
+
return React3.cloneElement(children, {
|
|
92
|
+
...mergeProps(slotProps, children.props),
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
ref: forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return React3.Children.count(children) > 1 ? React3.Children.only(null) : null;
|
|
98
|
+
});
|
|
99
|
+
SlotClone.displayName = "SlotClone";
|
|
100
|
+
var Slottable = ({ children }) => jsx(Fragment, { children });
|
|
101
|
+
function isSlottable(child) {
|
|
102
|
+
return React3.isValidElement(child) && child.type === Slottable;
|
|
103
|
+
}
|
|
104
|
+
function mergeProps(slotProps, childProps) {
|
|
105
|
+
let overrideProps = { ...childProps };
|
|
106
|
+
for (let propName in childProps) {
|
|
107
|
+
let slotPropValue = slotProps[propName], childPropValue = childProps[propName];
|
|
108
|
+
/^on[A-Z]/.test(propName) ? slotPropValue && childPropValue ? overrideProps[propName] = (...args) => {
|
|
109
|
+
childPropValue(...args), slotPropValue(...args);
|
|
110
|
+
} : slotPropValue && (overrideProps[propName] = slotPropValue) : propName === "style" ? overrideProps[propName] = { ...slotPropValue, ...childPropValue } : propName === "className" && (overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" "));
|
|
111
|
+
}
|
|
112
|
+
return { ...slotProps, ...overrideProps };
|
|
113
|
+
}
|
|
114
|
+
function getElementRef(element) {
|
|
115
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
116
|
+
return mayWarn ? element.ref : (getter = Object.getOwnPropertyDescriptor(element, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning, mayWarn ? element.props.ref : element.props.ref || element.ref);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// ../node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-primitive/dist/index.mjs
|
|
120
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
121
|
+
var NODES = [
|
|
122
|
+
"a",
|
|
123
|
+
"button",
|
|
124
|
+
"div",
|
|
125
|
+
"form",
|
|
126
|
+
"h2",
|
|
127
|
+
"h3",
|
|
128
|
+
"img",
|
|
129
|
+
"input",
|
|
130
|
+
"label",
|
|
131
|
+
"li",
|
|
132
|
+
"nav",
|
|
133
|
+
"ol",
|
|
134
|
+
"p",
|
|
135
|
+
"span",
|
|
136
|
+
"svg",
|
|
137
|
+
"ul"
|
|
138
|
+
], Primitive = NODES.reduce((primitive, node) => {
|
|
139
|
+
let Node = React4.forwardRef((props, forwardedRef) => {
|
|
140
|
+
let { asChild, ...primitiveProps } = props, Comp = asChild ? Slot : node;
|
|
141
|
+
return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), jsx2(Comp, { ...primitiveProps, ref: forwardedRef });
|
|
142
|
+
});
|
|
143
|
+
return Node.displayName = `Primitive.${node}`, { ...primitive, [node]: Node };
|
|
144
|
+
}, {});
|
|
145
|
+
|
|
146
|
+
// ../node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-presence/dist/index.mjs
|
|
147
|
+
import * as React22 from "react";
|
|
148
|
+
import * as ReactDOM2 from "react-dom";
|
|
149
|
+
|
|
150
|
+
// ../node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs
|
|
151
|
+
import * as React5 from "react";
|
|
152
|
+
var useLayoutEffect2 = globalThis?.document ? React5.useLayoutEffect : () => {
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// ../node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-presence/dist/index.mjs
|
|
156
|
+
import * as React6 from "react";
|
|
157
|
+
function useStateMachine(initialState, machine) {
|
|
158
|
+
return React6.useReducer((state, event) => machine[state][event] ?? state, initialState);
|
|
159
|
+
}
|
|
160
|
+
var Presence = (props) => {
|
|
161
|
+
let { present, children } = props, presence = usePresence(present), child = typeof children == "function" ? children({ present: presence.isPresent }) : React22.Children.only(children), ref = useComposedRefs(presence.ref, getElementRef2(child));
|
|
162
|
+
return typeof children == "function" || presence.isPresent ? React22.cloneElement(child, { ref }) : null;
|
|
163
|
+
};
|
|
164
|
+
Presence.displayName = "Presence";
|
|
165
|
+
function usePresence(present) {
|
|
166
|
+
let [node, setNode] = React22.useState(), stylesRef = React22.useRef({}), prevPresentRef = React22.useRef(present), prevAnimationNameRef = React22.useRef("none"), initialState = present ? "mounted" : "unmounted", [state, send] = useStateMachine(initialState, {
|
|
167
|
+
mounted: {
|
|
168
|
+
UNMOUNT: "unmounted",
|
|
169
|
+
ANIMATION_OUT: "unmountSuspended"
|
|
170
|
+
},
|
|
171
|
+
unmountSuspended: {
|
|
172
|
+
MOUNT: "mounted",
|
|
173
|
+
ANIMATION_END: "unmounted"
|
|
174
|
+
},
|
|
175
|
+
unmounted: {
|
|
176
|
+
MOUNT: "mounted"
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
return React22.useEffect(() => {
|
|
180
|
+
let currentAnimationName = getAnimationName(stylesRef.current);
|
|
181
|
+
prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
|
|
182
|
+
}, [state]), useLayoutEffect2(() => {
|
|
183
|
+
let styles = stylesRef.current, wasPresent = prevPresentRef.current;
|
|
184
|
+
if (wasPresent !== present) {
|
|
185
|
+
let prevAnimationName = prevAnimationNameRef.current, currentAnimationName = getAnimationName(styles);
|
|
186
|
+
present ? send("MOUNT") : currentAnimationName === "none" || styles?.display === "none" ? send("UNMOUNT") : send(wasPresent && prevAnimationName !== currentAnimationName ? "ANIMATION_OUT" : "UNMOUNT"), prevPresentRef.current = present;
|
|
187
|
+
}
|
|
188
|
+
}, [present, send]), useLayoutEffect2(() => {
|
|
189
|
+
if (node) {
|
|
190
|
+
let handleAnimationEnd = (event) => {
|
|
191
|
+
let isCurrentAnimation = getAnimationName(stylesRef.current).includes(event.animationName);
|
|
192
|
+
event.target === node && isCurrentAnimation && ReactDOM2.flushSync(() => send("ANIMATION_END"));
|
|
193
|
+
}, handleAnimationStart = (event) => {
|
|
194
|
+
event.target === node && (prevAnimationNameRef.current = getAnimationName(stylesRef.current));
|
|
195
|
+
};
|
|
196
|
+
return node.addEventListener("animationstart", handleAnimationStart), node.addEventListener("animationcancel", handleAnimationEnd), node.addEventListener("animationend", handleAnimationEnd), () => {
|
|
197
|
+
node.removeEventListener("animationstart", handleAnimationStart), node.removeEventListener("animationcancel", handleAnimationEnd), node.removeEventListener("animationend", handleAnimationEnd);
|
|
198
|
+
};
|
|
199
|
+
} else
|
|
200
|
+
send("ANIMATION_END");
|
|
201
|
+
}, [node, send]), {
|
|
202
|
+
isPresent: ["mounted", "unmountSuspended"].includes(state),
|
|
203
|
+
ref: React22.useCallback((node2) => {
|
|
204
|
+
node2 && (stylesRef.current = getComputedStyle(node2)), setNode(node2);
|
|
205
|
+
}, [])
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function getAnimationName(styles) {
|
|
209
|
+
return styles?.animationName || "none";
|
|
210
|
+
}
|
|
211
|
+
function getElementRef2(element) {
|
|
212
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
213
|
+
return mayWarn ? element.ref : (getter = Object.getOwnPropertyDescriptor(element, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning, mayWarn ? element.props.ref : element.props.ref || element.ref);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// ../node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-context/dist/index.mjs
|
|
217
|
+
import * as React7 from "react";
|
|
218
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
219
|
+
function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
220
|
+
let defaultContexts = [];
|
|
221
|
+
function createContext3(rootComponentName, defaultContext) {
|
|
222
|
+
let BaseContext = React7.createContext(defaultContext), index = defaultContexts.length;
|
|
223
|
+
defaultContexts = [...defaultContexts, defaultContext];
|
|
224
|
+
function Provider(props) {
|
|
225
|
+
let { scope, children, ...context } = props, Context = scope?.[scopeName][index] || BaseContext, value = React7.useMemo(() => context, Object.values(context));
|
|
226
|
+
return jsx3(Context.Provider, { value, children });
|
|
227
|
+
}
|
|
228
|
+
function useContext22(consumerName, scope) {
|
|
229
|
+
let Context = scope?.[scopeName][index] || BaseContext, context = React7.useContext(Context);
|
|
230
|
+
if (context) return context;
|
|
231
|
+
if (defaultContext !== void 0) return defaultContext;
|
|
232
|
+
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
|
|
233
|
+
}
|
|
234
|
+
return Provider.displayName = rootComponentName + "Provider", [Provider, useContext22];
|
|
235
|
+
}
|
|
236
|
+
let createScope = () => {
|
|
237
|
+
let scopeContexts = defaultContexts.map((defaultContext) => React7.createContext(defaultContext));
|
|
238
|
+
return function(scope) {
|
|
239
|
+
let contexts = scope?.[scopeName] || scopeContexts;
|
|
240
|
+
return React7.useMemo(
|
|
241
|
+
() => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
|
|
242
|
+
[scope, contexts]
|
|
243
|
+
);
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
return createScope.scopeName = scopeName, [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
|
|
247
|
+
}
|
|
248
|
+
function composeContextScopes(...scopes) {
|
|
249
|
+
let baseScope = scopes[0];
|
|
250
|
+
if (scopes.length === 1) return baseScope;
|
|
251
|
+
let createScope = () => {
|
|
252
|
+
let scopeHooks = scopes.map((createScope2) => ({
|
|
253
|
+
useScope: createScope2(),
|
|
254
|
+
scopeName: createScope2.scopeName
|
|
255
|
+
}));
|
|
256
|
+
return function(overrideScopes) {
|
|
257
|
+
let nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
|
|
258
|
+
let currentScope = useScope(overrideScopes)[`__scope${scopeName}`];
|
|
259
|
+
return { ...nextScopes2, ...currentScope };
|
|
260
|
+
}, {});
|
|
261
|
+
return React7.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
return createScope.scopeName = baseScope.scopeName, createScope;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// ../node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs
|
|
268
|
+
import * as React8 from "react";
|
|
269
|
+
function useCallbackRef(callback) {
|
|
270
|
+
let callbackRef = React8.useRef(callback);
|
|
271
|
+
return React8.useEffect(() => {
|
|
272
|
+
callbackRef.current = callback;
|
|
273
|
+
}), React8.useMemo(() => (...args) => callbackRef.current?.(...args), []);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// ../node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-direction/dist/index.mjs
|
|
277
|
+
import * as React9 from "react";
|
|
278
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
279
|
+
var DirectionContext = React9.createContext(void 0);
|
|
280
|
+
function useDirection(localDir) {
|
|
281
|
+
let globalDir = React9.useContext(DirectionContext);
|
|
282
|
+
return localDir || globalDir || "ltr";
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// ../node_modules/@radix-ui/number/dist/index.mjs
|
|
286
|
+
function clamp(value, [min, max]) {
|
|
287
|
+
return Math.min(max, Math.max(min, value));
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// ../node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/primitive/dist/index.mjs
|
|
291
|
+
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = !0 } = {}) {
|
|
292
|
+
return function(event) {
|
|
293
|
+
if (originalEventHandler?.(event), checkForDefaultPrevented === !1 || !event.defaultPrevented)
|
|
294
|
+
return ourEventHandler?.(event);
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// ../node_modules/@radix-ui/react-scroll-area/dist/index.mjs
|
|
299
|
+
import * as React10 from "react";
|
|
300
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs } from "react/jsx-runtime";
|
|
301
|
+
function useStateMachine2(initialState, machine) {
|
|
302
|
+
return React10.useReducer((state, event) => machine[state][event] ?? state, initialState);
|
|
303
|
+
}
|
|
304
|
+
var SCROLL_AREA_NAME = "ScrollArea", [createScrollAreaContext, createScrollAreaScope] = createContextScope(SCROLL_AREA_NAME), [ScrollAreaProvider, useScrollAreaContext] = createScrollAreaContext(SCROLL_AREA_NAME), ScrollArea = React23.forwardRef(
|
|
305
|
+
(props, forwardedRef) => {
|
|
306
|
+
let {
|
|
307
|
+
__scopeScrollArea,
|
|
308
|
+
type = "hover",
|
|
309
|
+
dir,
|
|
310
|
+
scrollHideDelay = 600,
|
|
311
|
+
...scrollAreaProps
|
|
312
|
+
} = props, [scrollArea, setScrollArea] = React23.useState(null), [viewport, setViewport] = React23.useState(null), [content, setContent] = React23.useState(null), [scrollbarX, setScrollbarX] = React23.useState(null), [scrollbarY, setScrollbarY] = React23.useState(null), [cornerWidth, setCornerWidth] = React23.useState(0), [cornerHeight, setCornerHeight] = React23.useState(0), [scrollbarXEnabled, setScrollbarXEnabled] = React23.useState(!1), [scrollbarYEnabled, setScrollbarYEnabled] = React23.useState(!1), composedRefs = useComposedRefs(forwardedRef, (node) => setScrollArea(node)), direction = useDirection(dir);
|
|
313
|
+
return jsx5(
|
|
314
|
+
ScrollAreaProvider,
|
|
315
|
+
{
|
|
316
|
+
scope: __scopeScrollArea,
|
|
317
|
+
type,
|
|
318
|
+
dir: direction,
|
|
319
|
+
scrollHideDelay,
|
|
320
|
+
scrollArea,
|
|
321
|
+
viewport,
|
|
322
|
+
onViewportChange: setViewport,
|
|
323
|
+
content,
|
|
324
|
+
onContentChange: setContent,
|
|
325
|
+
scrollbarX,
|
|
326
|
+
onScrollbarXChange: setScrollbarX,
|
|
327
|
+
scrollbarXEnabled,
|
|
328
|
+
onScrollbarXEnabledChange: setScrollbarXEnabled,
|
|
329
|
+
scrollbarY,
|
|
330
|
+
onScrollbarYChange: setScrollbarY,
|
|
331
|
+
scrollbarYEnabled,
|
|
332
|
+
onScrollbarYEnabledChange: setScrollbarYEnabled,
|
|
333
|
+
onCornerWidthChange: setCornerWidth,
|
|
334
|
+
onCornerHeightChange: setCornerHeight,
|
|
335
|
+
children: jsx5(
|
|
336
|
+
Primitive.div,
|
|
337
|
+
{
|
|
338
|
+
dir: direction,
|
|
339
|
+
...scrollAreaProps,
|
|
340
|
+
ref: composedRefs,
|
|
341
|
+
style: {
|
|
342
|
+
position: "relative",
|
|
343
|
+
// Pass corner sizes as CSS vars to reduce re-renders of context consumers
|
|
344
|
+
"--radix-scroll-area-corner-width": cornerWidth + "px",
|
|
345
|
+
"--radix-scroll-area-corner-height": cornerHeight + "px",
|
|
346
|
+
...props.style
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
)
|
|
350
|
+
}
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
);
|
|
354
|
+
ScrollArea.displayName = SCROLL_AREA_NAME;
|
|
355
|
+
var VIEWPORT_NAME = "ScrollAreaViewport", ScrollAreaViewport = React23.forwardRef(
|
|
356
|
+
(props, forwardedRef) => {
|
|
357
|
+
let { __scopeScrollArea, children, asChild, nonce, ...viewportProps } = props, context = useScrollAreaContext(VIEWPORT_NAME, __scopeScrollArea), ref = React23.useRef(null), composedRefs = useComposedRefs(forwardedRef, ref, context.onViewportChange);
|
|
358
|
+
return jsxs(Fragment2, { children: [
|
|
359
|
+
jsx5(
|
|
360
|
+
"style",
|
|
361
|
+
{
|
|
362
|
+
dangerouslySetInnerHTML: {
|
|
363
|
+
__html: `
|
|
364
|
+
[data-radix-scroll-area-viewport] {
|
|
365
|
+
scrollbar-width: none;
|
|
366
|
+
-ms-overflow-style: none;
|
|
367
|
+
-webkit-overflow-scrolling: touch;
|
|
368
|
+
}
|
|
369
|
+
[data-radix-scroll-area-viewport]::-webkit-scrollbar {
|
|
370
|
+
display: none;
|
|
371
|
+
}
|
|
372
|
+
:where([data-radix-scroll-area-viewport]) {
|
|
373
|
+
display: flex;
|
|
374
|
+
flex-direction: column;
|
|
375
|
+
align-items: stretch;
|
|
376
|
+
}
|
|
377
|
+
:where([data-radix-scroll-area-content]) {
|
|
378
|
+
flex-grow: 1;
|
|
379
|
+
}
|
|
380
|
+
`
|
|
381
|
+
},
|
|
382
|
+
nonce
|
|
383
|
+
}
|
|
384
|
+
),
|
|
385
|
+
jsx5(
|
|
386
|
+
Primitive.div,
|
|
387
|
+
{
|
|
388
|
+
"data-radix-scroll-area-viewport": "",
|
|
389
|
+
...viewportProps,
|
|
390
|
+
asChild,
|
|
391
|
+
ref: composedRefs,
|
|
392
|
+
style: {
|
|
393
|
+
/**
|
|
394
|
+
* We don't support `visible` because the intention is to have at least one scrollbar
|
|
395
|
+
* if this component is used and `visible` will behave like `auto` in that case
|
|
396
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/overflow#description
|
|
397
|
+
*
|
|
398
|
+
* We don't handle `auto` because the intention is for the native implementation
|
|
399
|
+
* to be hidden if using this component. We just want to ensure the node is scrollable
|
|
400
|
+
* so could have used either `scroll` or `auto` here. We picked `scroll` to prevent
|
|
401
|
+
* the browser from having to work out whether to render native scrollbars or not,
|
|
402
|
+
* we tell it to with the intention of hiding them in CSS.
|
|
403
|
+
*/
|
|
404
|
+
overflowX: context.scrollbarXEnabled ? "scroll" : "hidden",
|
|
405
|
+
overflowY: context.scrollbarYEnabled ? "scroll" : "hidden",
|
|
406
|
+
...props.style
|
|
407
|
+
},
|
|
408
|
+
children: getSubtree({ asChild, children }, (children2) => jsx5(
|
|
409
|
+
"div",
|
|
410
|
+
{
|
|
411
|
+
"data-radix-scroll-area-content": "",
|
|
412
|
+
ref: context.onContentChange,
|
|
413
|
+
style: { minWidth: context.scrollbarXEnabled ? "fit-content" : void 0 },
|
|
414
|
+
children: children2
|
|
415
|
+
}
|
|
416
|
+
))
|
|
417
|
+
}
|
|
418
|
+
)
|
|
419
|
+
] });
|
|
420
|
+
}
|
|
421
|
+
);
|
|
422
|
+
ScrollAreaViewport.displayName = VIEWPORT_NAME;
|
|
423
|
+
var SCROLLBAR_NAME = "ScrollAreaScrollbar", ScrollAreaScrollbar = React23.forwardRef(
|
|
424
|
+
(props, forwardedRef) => {
|
|
425
|
+
let { forceMount, ...scrollbarProps } = props, context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea), { onScrollbarXEnabledChange, onScrollbarYEnabledChange } = context, isHorizontal = props.orientation === "horizontal";
|
|
426
|
+
return React23.useEffect(() => (isHorizontal ? onScrollbarXEnabledChange(!0) : onScrollbarYEnabledChange(!0), () => {
|
|
427
|
+
isHorizontal ? onScrollbarXEnabledChange(!1) : onScrollbarYEnabledChange(!1);
|
|
428
|
+
}), [isHorizontal, onScrollbarXEnabledChange, onScrollbarYEnabledChange]), context.type === "hover" ? jsx5(ScrollAreaScrollbarHover, { ...scrollbarProps, ref: forwardedRef, forceMount }) : context.type === "scroll" ? jsx5(ScrollAreaScrollbarScroll, { ...scrollbarProps, ref: forwardedRef, forceMount }) : context.type === "auto" ? jsx5(ScrollAreaScrollbarAuto, { ...scrollbarProps, ref: forwardedRef, forceMount }) : context.type === "always" ? jsx5(ScrollAreaScrollbarVisible, { ...scrollbarProps, ref: forwardedRef }) : null;
|
|
429
|
+
}
|
|
430
|
+
);
|
|
431
|
+
ScrollAreaScrollbar.displayName = SCROLLBAR_NAME;
|
|
432
|
+
var ScrollAreaScrollbarHover = React23.forwardRef((props, forwardedRef) => {
|
|
433
|
+
let { forceMount, ...scrollbarProps } = props, context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea), [visible, setVisible] = React23.useState(!1);
|
|
434
|
+
return React23.useEffect(() => {
|
|
435
|
+
let scrollArea = context.scrollArea, hideTimer = 0;
|
|
436
|
+
if (scrollArea) {
|
|
437
|
+
let handlePointerEnter = () => {
|
|
438
|
+
window.clearTimeout(hideTimer), setVisible(!0);
|
|
439
|
+
}, handlePointerLeave = () => {
|
|
440
|
+
hideTimer = window.setTimeout(() => setVisible(!1), context.scrollHideDelay);
|
|
441
|
+
};
|
|
442
|
+
return scrollArea.addEventListener("pointerenter", handlePointerEnter), scrollArea.addEventListener("pointerleave", handlePointerLeave), () => {
|
|
443
|
+
window.clearTimeout(hideTimer), scrollArea.removeEventListener("pointerenter", handlePointerEnter), scrollArea.removeEventListener("pointerleave", handlePointerLeave);
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
}, [context.scrollArea, context.scrollHideDelay]), jsx5(Presence, { present: forceMount || visible, children: jsx5(
|
|
447
|
+
ScrollAreaScrollbarAuto,
|
|
448
|
+
{
|
|
449
|
+
"data-state": visible ? "visible" : "hidden",
|
|
450
|
+
...scrollbarProps,
|
|
451
|
+
ref: forwardedRef
|
|
452
|
+
}
|
|
453
|
+
) });
|
|
454
|
+
}), ScrollAreaScrollbarScroll = React23.forwardRef((props, forwardedRef) => {
|
|
455
|
+
let { forceMount, ...scrollbarProps } = props, context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea), isHorizontal = props.orientation === "horizontal", debounceScrollEnd = useDebounceCallback(() => send("SCROLL_END"), 100), [state, send] = useStateMachine2("hidden", {
|
|
456
|
+
hidden: {
|
|
457
|
+
SCROLL: "scrolling"
|
|
458
|
+
},
|
|
459
|
+
scrolling: {
|
|
460
|
+
SCROLL_END: "idle",
|
|
461
|
+
POINTER_ENTER: "interacting"
|
|
462
|
+
},
|
|
463
|
+
interacting: {
|
|
464
|
+
SCROLL: "interacting",
|
|
465
|
+
POINTER_LEAVE: "idle"
|
|
466
|
+
},
|
|
467
|
+
idle: {
|
|
468
|
+
HIDE: "hidden",
|
|
469
|
+
SCROLL: "scrolling",
|
|
470
|
+
POINTER_ENTER: "interacting"
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
return React23.useEffect(() => {
|
|
474
|
+
if (state === "idle") {
|
|
475
|
+
let hideTimer = window.setTimeout(() => send("HIDE"), context.scrollHideDelay);
|
|
476
|
+
return () => window.clearTimeout(hideTimer);
|
|
477
|
+
}
|
|
478
|
+
}, [state, context.scrollHideDelay, send]), React23.useEffect(() => {
|
|
479
|
+
let viewport = context.viewport, scrollDirection = isHorizontal ? "scrollLeft" : "scrollTop";
|
|
480
|
+
if (viewport) {
|
|
481
|
+
let prevScrollPos = viewport[scrollDirection], handleScroll = () => {
|
|
482
|
+
let scrollPos = viewport[scrollDirection];
|
|
483
|
+
prevScrollPos !== scrollPos && (send("SCROLL"), debounceScrollEnd()), prevScrollPos = scrollPos;
|
|
484
|
+
};
|
|
485
|
+
return viewport.addEventListener("scroll", handleScroll), () => viewport.removeEventListener("scroll", handleScroll);
|
|
486
|
+
}
|
|
487
|
+
}, [context.viewport, isHorizontal, send, debounceScrollEnd]), jsx5(Presence, { present: forceMount || state !== "hidden", children: jsx5(
|
|
488
|
+
ScrollAreaScrollbarVisible,
|
|
489
|
+
{
|
|
490
|
+
"data-state": state === "hidden" ? "hidden" : "visible",
|
|
491
|
+
...scrollbarProps,
|
|
492
|
+
ref: forwardedRef,
|
|
493
|
+
onPointerEnter: composeEventHandlers(props.onPointerEnter, () => send("POINTER_ENTER")),
|
|
494
|
+
onPointerLeave: composeEventHandlers(props.onPointerLeave, () => send("POINTER_LEAVE"))
|
|
495
|
+
}
|
|
496
|
+
) });
|
|
497
|
+
}), ScrollAreaScrollbarAuto = React23.forwardRef((props, forwardedRef) => {
|
|
498
|
+
let context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea), { forceMount, ...scrollbarProps } = props, [visible, setVisible] = React23.useState(!1), isHorizontal = props.orientation === "horizontal", handleResize = useDebounceCallback(() => {
|
|
499
|
+
if (context.viewport) {
|
|
500
|
+
let isOverflowX = context.viewport.offsetWidth < context.viewport.scrollWidth, isOverflowY = context.viewport.offsetHeight < context.viewport.scrollHeight;
|
|
501
|
+
setVisible(isHorizontal ? isOverflowX : isOverflowY);
|
|
502
|
+
}
|
|
503
|
+
}, 10);
|
|
504
|
+
return useResizeObserver(context.viewport, handleResize), useResizeObserver(context.content, handleResize), jsx5(Presence, { present: forceMount || visible, children: jsx5(
|
|
505
|
+
ScrollAreaScrollbarVisible,
|
|
506
|
+
{
|
|
507
|
+
"data-state": visible ? "visible" : "hidden",
|
|
508
|
+
...scrollbarProps,
|
|
509
|
+
ref: forwardedRef
|
|
510
|
+
}
|
|
511
|
+
) });
|
|
512
|
+
}), ScrollAreaScrollbarVisible = React23.forwardRef((props, forwardedRef) => {
|
|
513
|
+
let { orientation = "vertical", ...scrollbarProps } = props, context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea), thumbRef = React23.useRef(null), pointerOffsetRef = React23.useRef(0), [sizes, setSizes] = React23.useState({
|
|
514
|
+
content: 0,
|
|
515
|
+
viewport: 0,
|
|
516
|
+
scrollbar: { size: 0, paddingStart: 0, paddingEnd: 0 }
|
|
517
|
+
}), thumbRatio = getThumbRatio(sizes.viewport, sizes.content), commonProps = {
|
|
518
|
+
...scrollbarProps,
|
|
519
|
+
sizes,
|
|
520
|
+
onSizesChange: setSizes,
|
|
521
|
+
hasThumb: thumbRatio > 0 && thumbRatio < 1,
|
|
522
|
+
onThumbChange: (thumb) => thumbRef.current = thumb,
|
|
523
|
+
onThumbPointerUp: () => pointerOffsetRef.current = 0,
|
|
524
|
+
onThumbPointerDown: (pointerPos) => pointerOffsetRef.current = pointerPos
|
|
525
|
+
};
|
|
526
|
+
function getScrollPosition(pointerPos, dir) {
|
|
527
|
+
return getScrollPositionFromPointer(pointerPos, pointerOffsetRef.current, sizes, dir);
|
|
528
|
+
}
|
|
529
|
+
return orientation === "horizontal" ? jsx5(
|
|
530
|
+
ScrollAreaScrollbarX,
|
|
531
|
+
{
|
|
532
|
+
...commonProps,
|
|
533
|
+
ref: forwardedRef,
|
|
534
|
+
onThumbPositionChange: () => {
|
|
535
|
+
if (context.viewport && thumbRef.current) {
|
|
536
|
+
let scrollPos = context.viewport.scrollLeft, offset = getThumbOffsetFromScroll(scrollPos, sizes, context.dir);
|
|
537
|
+
thumbRef.current.style.transform = `translate3d(${offset}px, 0, 0)`;
|
|
538
|
+
}
|
|
539
|
+
},
|
|
540
|
+
onWheelScroll: (scrollPos) => {
|
|
541
|
+
context.viewport && (context.viewport.scrollLeft = scrollPos);
|
|
542
|
+
},
|
|
543
|
+
onDragScroll: (pointerPos) => {
|
|
544
|
+
context.viewport && (context.viewport.scrollLeft = getScrollPosition(pointerPos, context.dir));
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
) : orientation === "vertical" ? jsx5(
|
|
548
|
+
ScrollAreaScrollbarY,
|
|
549
|
+
{
|
|
550
|
+
...commonProps,
|
|
551
|
+
ref: forwardedRef,
|
|
552
|
+
onThumbPositionChange: () => {
|
|
553
|
+
if (context.viewport && thumbRef.current) {
|
|
554
|
+
let scrollPos = context.viewport.scrollTop, offset = getThumbOffsetFromScroll(scrollPos, sizes);
|
|
555
|
+
thumbRef.current.style.transform = `translate3d(0, ${offset}px, 0)`;
|
|
556
|
+
}
|
|
557
|
+
},
|
|
558
|
+
onWheelScroll: (scrollPos) => {
|
|
559
|
+
context.viewport && (context.viewport.scrollTop = scrollPos);
|
|
560
|
+
},
|
|
561
|
+
onDragScroll: (pointerPos) => {
|
|
562
|
+
context.viewport && (context.viewport.scrollTop = getScrollPosition(pointerPos));
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
) : null;
|
|
566
|
+
}), ScrollAreaScrollbarX = React23.forwardRef((props, forwardedRef) => {
|
|
567
|
+
let { sizes, onSizesChange, ...scrollbarProps } = props, context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea), [computedStyle, setComputedStyle] = React23.useState(), ref = React23.useRef(null), composeRefs2 = useComposedRefs(forwardedRef, ref, context.onScrollbarXChange);
|
|
568
|
+
return React23.useEffect(() => {
|
|
569
|
+
ref.current && setComputedStyle(getComputedStyle(ref.current));
|
|
570
|
+
}, [ref]), jsx5(
|
|
571
|
+
ScrollAreaScrollbarImpl,
|
|
572
|
+
{
|
|
573
|
+
"data-orientation": "horizontal",
|
|
574
|
+
...scrollbarProps,
|
|
575
|
+
ref: composeRefs2,
|
|
576
|
+
sizes,
|
|
577
|
+
style: {
|
|
578
|
+
bottom: 0,
|
|
579
|
+
left: context.dir === "rtl" ? "var(--radix-scroll-area-corner-width)" : 0,
|
|
580
|
+
right: context.dir === "ltr" ? "var(--radix-scroll-area-corner-width)" : 0,
|
|
581
|
+
"--radix-scroll-area-thumb-width": getThumbSize(sizes) + "px",
|
|
582
|
+
...props.style
|
|
583
|
+
},
|
|
584
|
+
onThumbPointerDown: (pointerPos) => props.onThumbPointerDown(pointerPos.x),
|
|
585
|
+
onDragScroll: (pointerPos) => props.onDragScroll(pointerPos.x),
|
|
586
|
+
onWheelScroll: (event, maxScrollPos) => {
|
|
587
|
+
if (context.viewport) {
|
|
588
|
+
let scrollPos = context.viewport.scrollLeft + event.deltaX;
|
|
589
|
+
props.onWheelScroll(scrollPos), isScrollingWithinScrollbarBounds(scrollPos, maxScrollPos) && event.preventDefault();
|
|
590
|
+
}
|
|
591
|
+
},
|
|
592
|
+
onResize: () => {
|
|
593
|
+
ref.current && context.viewport && computedStyle && onSizesChange({
|
|
594
|
+
content: context.viewport.scrollWidth,
|
|
595
|
+
viewport: context.viewport.offsetWidth,
|
|
596
|
+
scrollbar: {
|
|
597
|
+
size: ref.current.clientWidth,
|
|
598
|
+
paddingStart: toInt(computedStyle.paddingLeft),
|
|
599
|
+
paddingEnd: toInt(computedStyle.paddingRight)
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
);
|
|
605
|
+
}), ScrollAreaScrollbarY = React23.forwardRef((props, forwardedRef) => {
|
|
606
|
+
let { sizes, onSizesChange, ...scrollbarProps } = props, context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea), [computedStyle, setComputedStyle] = React23.useState(), ref = React23.useRef(null), composeRefs2 = useComposedRefs(forwardedRef, ref, context.onScrollbarYChange);
|
|
607
|
+
return React23.useEffect(() => {
|
|
608
|
+
ref.current && setComputedStyle(getComputedStyle(ref.current));
|
|
609
|
+
}, [ref]), jsx5(
|
|
610
|
+
ScrollAreaScrollbarImpl,
|
|
611
|
+
{
|
|
612
|
+
"data-orientation": "vertical",
|
|
613
|
+
...scrollbarProps,
|
|
614
|
+
ref: composeRefs2,
|
|
615
|
+
sizes,
|
|
616
|
+
style: {
|
|
617
|
+
top: 0,
|
|
618
|
+
right: context.dir === "ltr" ? 0 : void 0,
|
|
619
|
+
left: context.dir === "rtl" ? 0 : void 0,
|
|
620
|
+
bottom: "var(--radix-scroll-area-corner-height)",
|
|
621
|
+
"--radix-scroll-area-thumb-height": getThumbSize(sizes) + "px",
|
|
622
|
+
...props.style
|
|
623
|
+
},
|
|
624
|
+
onThumbPointerDown: (pointerPos) => props.onThumbPointerDown(pointerPos.y),
|
|
625
|
+
onDragScroll: (pointerPos) => props.onDragScroll(pointerPos.y),
|
|
626
|
+
onWheelScroll: (event, maxScrollPos) => {
|
|
627
|
+
if (context.viewport) {
|
|
628
|
+
let scrollPos = context.viewport.scrollTop + event.deltaY;
|
|
629
|
+
props.onWheelScroll(scrollPos), isScrollingWithinScrollbarBounds(scrollPos, maxScrollPos) && event.preventDefault();
|
|
630
|
+
}
|
|
631
|
+
},
|
|
632
|
+
onResize: () => {
|
|
633
|
+
ref.current && context.viewport && computedStyle && onSizesChange({
|
|
634
|
+
content: context.viewport.scrollHeight,
|
|
635
|
+
viewport: context.viewport.offsetHeight,
|
|
636
|
+
scrollbar: {
|
|
637
|
+
size: ref.current.clientHeight,
|
|
638
|
+
paddingStart: toInt(computedStyle.paddingTop),
|
|
639
|
+
paddingEnd: toInt(computedStyle.paddingBottom)
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
);
|
|
645
|
+
}), [ScrollbarProvider, useScrollbarContext] = createScrollAreaContext(SCROLLBAR_NAME), ScrollAreaScrollbarImpl = React23.forwardRef((props, forwardedRef) => {
|
|
646
|
+
let {
|
|
647
|
+
__scopeScrollArea,
|
|
648
|
+
sizes,
|
|
649
|
+
hasThumb,
|
|
650
|
+
onThumbChange,
|
|
651
|
+
onThumbPointerUp,
|
|
652
|
+
onThumbPointerDown,
|
|
653
|
+
onThumbPositionChange,
|
|
654
|
+
onDragScroll,
|
|
655
|
+
onWheelScroll,
|
|
656
|
+
onResize,
|
|
657
|
+
...scrollbarProps
|
|
658
|
+
} = props, context = useScrollAreaContext(SCROLLBAR_NAME, __scopeScrollArea), [scrollbar, setScrollbar] = React23.useState(null), composeRefs2 = useComposedRefs(forwardedRef, (node) => setScrollbar(node)), rectRef = React23.useRef(null), prevWebkitUserSelectRef = React23.useRef(""), viewport = context.viewport, maxScrollPos = sizes.content - sizes.viewport, handleWheelScroll = useCallbackRef(onWheelScroll), handleThumbPositionChange = useCallbackRef(onThumbPositionChange), handleResize = useDebounceCallback(onResize, 10);
|
|
659
|
+
function handleDragScroll(event) {
|
|
660
|
+
if (rectRef.current) {
|
|
661
|
+
let x = event.clientX - rectRef.current.left, y = event.clientY - rectRef.current.top;
|
|
662
|
+
onDragScroll({ x, y });
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
return React23.useEffect(() => {
|
|
666
|
+
let handleWheel = (event) => {
|
|
667
|
+
let element = event.target;
|
|
668
|
+
scrollbar?.contains(element) && handleWheelScroll(event, maxScrollPos);
|
|
669
|
+
};
|
|
670
|
+
return document.addEventListener("wheel", handleWheel, { passive: !1 }), () => document.removeEventListener("wheel", handleWheel, { passive: !1 });
|
|
671
|
+
}, [viewport, scrollbar, maxScrollPos, handleWheelScroll]), React23.useEffect(handleThumbPositionChange, [sizes, handleThumbPositionChange]), useResizeObserver(scrollbar, handleResize), useResizeObserver(context.content, handleResize), jsx5(
|
|
672
|
+
ScrollbarProvider,
|
|
673
|
+
{
|
|
674
|
+
scope: __scopeScrollArea,
|
|
675
|
+
scrollbar,
|
|
676
|
+
hasThumb,
|
|
677
|
+
onThumbChange: useCallbackRef(onThumbChange),
|
|
678
|
+
onThumbPointerUp: useCallbackRef(onThumbPointerUp),
|
|
679
|
+
onThumbPositionChange: handleThumbPositionChange,
|
|
680
|
+
onThumbPointerDown: useCallbackRef(onThumbPointerDown),
|
|
681
|
+
children: jsx5(
|
|
682
|
+
Primitive.div,
|
|
683
|
+
{
|
|
684
|
+
...scrollbarProps,
|
|
685
|
+
ref: composeRefs2,
|
|
686
|
+
style: { position: "absolute", ...scrollbarProps.style },
|
|
687
|
+
onPointerDown: composeEventHandlers(props.onPointerDown, (event) => {
|
|
688
|
+
event.button === 0 && (event.target.setPointerCapture(event.pointerId), rectRef.current = scrollbar.getBoundingClientRect(), prevWebkitUserSelectRef.current = document.body.style.webkitUserSelect, document.body.style.webkitUserSelect = "none", context.viewport && (context.viewport.style.scrollBehavior = "auto"), handleDragScroll(event));
|
|
689
|
+
}),
|
|
690
|
+
onPointerMove: composeEventHandlers(props.onPointerMove, handleDragScroll),
|
|
691
|
+
onPointerUp: composeEventHandlers(props.onPointerUp, (event) => {
|
|
692
|
+
let element = event.target;
|
|
693
|
+
element.hasPointerCapture(event.pointerId) && element.releasePointerCapture(event.pointerId), document.body.style.webkitUserSelect = prevWebkitUserSelectRef.current, context.viewport && (context.viewport.style.scrollBehavior = ""), rectRef.current = null;
|
|
694
|
+
})
|
|
695
|
+
}
|
|
696
|
+
)
|
|
697
|
+
}
|
|
698
|
+
);
|
|
699
|
+
}), THUMB_NAME = "ScrollAreaThumb", ScrollAreaThumb = React23.forwardRef(
|
|
700
|
+
(props, forwardedRef) => {
|
|
701
|
+
let { forceMount, ...thumbProps } = props, scrollbarContext = useScrollbarContext(THUMB_NAME, props.__scopeScrollArea);
|
|
702
|
+
return jsx5(Presence, { present: forceMount || scrollbarContext.hasThumb, children: jsx5(ScrollAreaThumbImpl, { ref: forwardedRef, ...thumbProps }) });
|
|
703
|
+
}
|
|
704
|
+
), ScrollAreaThumbImpl = React23.forwardRef(
|
|
705
|
+
(props, forwardedRef) => {
|
|
706
|
+
let { __scopeScrollArea, style, ...thumbProps } = props, scrollAreaContext = useScrollAreaContext(THUMB_NAME, __scopeScrollArea), scrollbarContext = useScrollbarContext(THUMB_NAME, __scopeScrollArea), { onThumbPositionChange } = scrollbarContext, composedRef = useComposedRefs(
|
|
707
|
+
forwardedRef,
|
|
708
|
+
(node) => scrollbarContext.onThumbChange(node)
|
|
709
|
+
), removeUnlinkedScrollListenerRef = React23.useRef(), debounceScrollEnd = useDebounceCallback(() => {
|
|
710
|
+
removeUnlinkedScrollListenerRef.current && (removeUnlinkedScrollListenerRef.current(), removeUnlinkedScrollListenerRef.current = void 0);
|
|
711
|
+
}, 100);
|
|
712
|
+
return React23.useEffect(() => {
|
|
713
|
+
let viewport = scrollAreaContext.viewport;
|
|
714
|
+
if (viewport) {
|
|
715
|
+
let handleScroll = () => {
|
|
716
|
+
if (debounceScrollEnd(), !removeUnlinkedScrollListenerRef.current) {
|
|
717
|
+
let listener = addUnlinkedScrollListener(viewport, onThumbPositionChange);
|
|
718
|
+
removeUnlinkedScrollListenerRef.current = listener, onThumbPositionChange();
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
return onThumbPositionChange(), viewport.addEventListener("scroll", handleScroll), () => viewport.removeEventListener("scroll", handleScroll);
|
|
722
|
+
}
|
|
723
|
+
}, [scrollAreaContext.viewport, debounceScrollEnd, onThumbPositionChange]), jsx5(
|
|
724
|
+
Primitive.div,
|
|
725
|
+
{
|
|
726
|
+
"data-state": scrollbarContext.hasThumb ? "visible" : "hidden",
|
|
727
|
+
...thumbProps,
|
|
728
|
+
ref: composedRef,
|
|
729
|
+
style: {
|
|
730
|
+
width: "var(--radix-scroll-area-thumb-width)",
|
|
731
|
+
height: "var(--radix-scroll-area-thumb-height)",
|
|
732
|
+
...style
|
|
733
|
+
},
|
|
734
|
+
onPointerDownCapture: composeEventHandlers(props.onPointerDownCapture, (event) => {
|
|
735
|
+
let thumbRect = event.target.getBoundingClientRect(), x = event.clientX - thumbRect.left, y = event.clientY - thumbRect.top;
|
|
736
|
+
scrollbarContext.onThumbPointerDown({ x, y });
|
|
737
|
+
}),
|
|
738
|
+
onPointerUp: composeEventHandlers(props.onPointerUp, scrollbarContext.onThumbPointerUp)
|
|
739
|
+
}
|
|
740
|
+
);
|
|
741
|
+
}
|
|
742
|
+
);
|
|
743
|
+
ScrollAreaThumb.displayName = THUMB_NAME;
|
|
744
|
+
var CORNER_NAME = "ScrollAreaCorner", ScrollAreaCorner = React23.forwardRef(
|
|
745
|
+
(props, forwardedRef) => {
|
|
746
|
+
let context = useScrollAreaContext(CORNER_NAME, props.__scopeScrollArea), hasBothScrollbarsVisible = !!(context.scrollbarX && context.scrollbarY);
|
|
747
|
+
return context.type !== "scroll" && hasBothScrollbarsVisible ? jsx5(ScrollAreaCornerImpl, { ...props, ref: forwardedRef }) : null;
|
|
748
|
+
}
|
|
749
|
+
);
|
|
750
|
+
ScrollAreaCorner.displayName = CORNER_NAME;
|
|
751
|
+
var ScrollAreaCornerImpl = React23.forwardRef((props, forwardedRef) => {
|
|
752
|
+
let { __scopeScrollArea, ...cornerProps } = props, context = useScrollAreaContext(CORNER_NAME, __scopeScrollArea), [width, setWidth] = React23.useState(0), [height, setHeight] = React23.useState(0), hasSize = !!(width && height);
|
|
753
|
+
return useResizeObserver(context.scrollbarX, () => {
|
|
754
|
+
let height2 = context.scrollbarX?.offsetHeight || 0;
|
|
755
|
+
context.onCornerHeightChange(height2), setHeight(height2);
|
|
756
|
+
}), useResizeObserver(context.scrollbarY, () => {
|
|
757
|
+
let width2 = context.scrollbarY?.offsetWidth || 0;
|
|
758
|
+
context.onCornerWidthChange(width2), setWidth(width2);
|
|
759
|
+
}), hasSize ? jsx5(
|
|
760
|
+
Primitive.div,
|
|
761
|
+
{
|
|
762
|
+
...cornerProps,
|
|
763
|
+
ref: forwardedRef,
|
|
764
|
+
style: {
|
|
765
|
+
width,
|
|
766
|
+
height,
|
|
767
|
+
position: "absolute",
|
|
768
|
+
right: context.dir === "ltr" ? 0 : void 0,
|
|
769
|
+
left: context.dir === "rtl" ? 0 : void 0,
|
|
770
|
+
bottom: 0,
|
|
771
|
+
...props.style
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
) : null;
|
|
775
|
+
});
|
|
776
|
+
function toInt(value) {
|
|
777
|
+
return value ? parseInt(value, 10) : 0;
|
|
778
|
+
}
|
|
779
|
+
function getThumbRatio(viewportSize, contentSize) {
|
|
780
|
+
let ratio = viewportSize / contentSize;
|
|
781
|
+
return isNaN(ratio) ? 0 : ratio;
|
|
782
|
+
}
|
|
783
|
+
function getThumbSize(sizes) {
|
|
784
|
+
let ratio = getThumbRatio(sizes.viewport, sizes.content), scrollbarPadding = sizes.scrollbar.paddingStart + sizes.scrollbar.paddingEnd, thumbSize = (sizes.scrollbar.size - scrollbarPadding) * ratio;
|
|
785
|
+
return Math.max(thumbSize, 18);
|
|
786
|
+
}
|
|
787
|
+
function getScrollPositionFromPointer(pointerPos, pointerOffset, sizes, dir = "ltr") {
|
|
788
|
+
let thumbSizePx = getThumbSize(sizes), thumbCenter = thumbSizePx / 2, offset = pointerOffset || thumbCenter, thumbOffsetFromEnd = thumbSizePx - offset, minPointerPos = sizes.scrollbar.paddingStart + offset, maxPointerPos = sizes.scrollbar.size - sizes.scrollbar.paddingEnd - thumbOffsetFromEnd, maxScrollPos = sizes.content - sizes.viewport, scrollRange = dir === "ltr" ? [0, maxScrollPos] : [maxScrollPos * -1, 0];
|
|
789
|
+
return linearScale([minPointerPos, maxPointerPos], scrollRange)(pointerPos);
|
|
790
|
+
}
|
|
791
|
+
function getThumbOffsetFromScroll(scrollPos, sizes, dir = "ltr") {
|
|
792
|
+
let thumbSizePx = getThumbSize(sizes), scrollbarPadding = sizes.scrollbar.paddingStart + sizes.scrollbar.paddingEnd, scrollbar = sizes.scrollbar.size - scrollbarPadding, maxScrollPos = sizes.content - sizes.viewport, maxThumbPos = scrollbar - thumbSizePx, scrollClampRange = dir === "ltr" ? [0, maxScrollPos] : [maxScrollPos * -1, 0], scrollWithoutMomentum = clamp(scrollPos, scrollClampRange);
|
|
793
|
+
return linearScale([0, maxScrollPos], [0, maxThumbPos])(scrollWithoutMomentum);
|
|
794
|
+
}
|
|
795
|
+
function linearScale(input, output) {
|
|
796
|
+
return (value) => {
|
|
797
|
+
if (input[0] === input[1] || output[0] === output[1]) return output[0];
|
|
798
|
+
let ratio = (output[1] - output[0]) / (input[1] - input[0]);
|
|
799
|
+
return output[0] + ratio * (value - input[0]);
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
function isScrollingWithinScrollbarBounds(scrollPos, maxScrollPos) {
|
|
803
|
+
return scrollPos > 0 && scrollPos < maxScrollPos;
|
|
804
|
+
}
|
|
805
|
+
var addUnlinkedScrollListener = (node, handler = () => {
|
|
806
|
+
}) => {
|
|
807
|
+
let prevPosition = { left: node.scrollLeft, top: node.scrollTop }, rAF = 0;
|
|
808
|
+
return (function loop() {
|
|
809
|
+
let position = { left: node.scrollLeft, top: node.scrollTop }, isHorizontalScroll = prevPosition.left !== position.left, isVerticalScroll = prevPosition.top !== position.top;
|
|
810
|
+
(isHorizontalScroll || isVerticalScroll) && handler(), prevPosition = position, rAF = window.requestAnimationFrame(loop);
|
|
811
|
+
})(), () => window.cancelAnimationFrame(rAF);
|
|
812
|
+
};
|
|
813
|
+
function useDebounceCallback(callback, delay) {
|
|
814
|
+
let handleCallback = useCallbackRef(callback), debounceTimerRef = React23.useRef(0);
|
|
815
|
+
return React23.useEffect(() => () => window.clearTimeout(debounceTimerRef.current), []), React23.useCallback(() => {
|
|
816
|
+
window.clearTimeout(debounceTimerRef.current), debounceTimerRef.current = window.setTimeout(handleCallback, delay);
|
|
817
|
+
}, [handleCallback, delay]);
|
|
818
|
+
}
|
|
819
|
+
function useResizeObserver(element, onResize) {
|
|
820
|
+
let handleResize = useCallbackRef(onResize);
|
|
821
|
+
useLayoutEffect2(() => {
|
|
822
|
+
let rAF = 0;
|
|
823
|
+
if (element) {
|
|
824
|
+
let resizeObserver = new ResizeObserver(() => {
|
|
825
|
+
cancelAnimationFrame(rAF), rAF = window.requestAnimationFrame(handleResize);
|
|
826
|
+
});
|
|
827
|
+
return resizeObserver.observe(element), () => {
|
|
828
|
+
window.cancelAnimationFrame(rAF), resizeObserver.unobserve(element);
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
}, [element, handleResize]);
|
|
832
|
+
}
|
|
833
|
+
function getSubtree(options, content) {
|
|
834
|
+
let { asChild, children } = options;
|
|
835
|
+
if (!asChild) return typeof content == "function" ? content(children) : content;
|
|
836
|
+
let firstChild = React23.Children.only(children);
|
|
837
|
+
return React23.cloneElement(firstChild, {
|
|
838
|
+
children: typeof content == "function" ? content(firstChild.props.children) : content
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
var Root = ScrollArea, Viewport = ScrollAreaViewport, Scrollbar = ScrollAreaScrollbar, Thumb = ScrollAreaThumb, Corner = ScrollAreaCorner;
|
|
842
|
+
|
|
843
|
+
// src/components/components/ScrollArea/ScrollArea.tsx
|
|
844
|
+
import { styled as styled2 } from "storybook/theming";
|
|
845
|
+
var ScrollAreaRoot = styled2(Root)(
|
|
846
|
+
({ scrollbarsize, offset }) => ({
|
|
847
|
+
width: "100%",
|
|
848
|
+
height: "100%",
|
|
849
|
+
overflow: "hidden",
|
|
850
|
+
"--scrollbar-size": `${scrollbarsize + offset}px`,
|
|
851
|
+
"--radix-scroll-area-thumb-width": `${scrollbarsize}px`
|
|
852
|
+
})
|
|
853
|
+
), ScrollAreaViewport2 = styled2(Viewport)({
|
|
854
|
+
width: "100%",
|
|
855
|
+
height: "100%"
|
|
856
|
+
}), ScrollAreaScrollbar2 = styled2(Scrollbar)(({ offset, horizontal, vertical }) => ({
|
|
857
|
+
display: "flex",
|
|
858
|
+
userSelect: "none",
|
|
859
|
+
// ensures no selection
|
|
860
|
+
touchAction: "none",
|
|
861
|
+
// disable browser handling of all panning and zooming gestures on touch devices
|
|
862
|
+
background: "transparent",
|
|
863
|
+
transition: "all 0.2s ease-out",
|
|
864
|
+
borderRadius: "var(--scrollbar-size)",
|
|
865
|
+
zIndex: 1,
|
|
866
|
+
'&[data-orientation="vertical"]': {
|
|
867
|
+
width: "var(--scrollbar-size)",
|
|
868
|
+
paddingRight: offset,
|
|
869
|
+
marginTop: offset,
|
|
870
|
+
marginBottom: horizontal === "true" && vertical === "true" ? 0 : offset
|
|
871
|
+
},
|
|
872
|
+
'&[data-orientation="horizontal"]': {
|
|
873
|
+
flexDirection: "column",
|
|
874
|
+
height: "var(--scrollbar-size)",
|
|
875
|
+
paddingBottom: offset,
|
|
876
|
+
marginLeft: offset,
|
|
877
|
+
marginRight: horizontal === "true" && vertical === "true" ? 0 : offset
|
|
878
|
+
}
|
|
879
|
+
})), ScrollAreaThumb2 = styled2(Thumb)(({ theme }) => ({
|
|
880
|
+
flex: 1,
|
|
881
|
+
background: theme.textMutedColor,
|
|
882
|
+
opacity: 0.5,
|
|
883
|
+
borderRadius: "var(--scrollbar-size)",
|
|
884
|
+
position: "relative",
|
|
885
|
+
transition: "opacity 0.2s ease-out",
|
|
886
|
+
zIndex: 1,
|
|
887
|
+
"&:hover": { opacity: 0.8 },
|
|
888
|
+
/* increase target size for touch devices https://www.w3.org/WAI/WCAG21/Understanding/target-size.html */
|
|
889
|
+
"::before": {
|
|
890
|
+
content: '""',
|
|
891
|
+
position: "absolute",
|
|
892
|
+
top: "50%",
|
|
893
|
+
left: "50%",
|
|
894
|
+
transform: "translate(-50%,-50%)",
|
|
895
|
+
width: "100%",
|
|
896
|
+
height: "100%"
|
|
897
|
+
}
|
|
898
|
+
})), ScrollArea2 = forwardRef4(
|
|
899
|
+
({
|
|
900
|
+
children,
|
|
901
|
+
horizontal = !1,
|
|
902
|
+
vertical = !1,
|
|
903
|
+
offset = 2,
|
|
904
|
+
scrollbarSize = 6,
|
|
905
|
+
scrollPadding = 0,
|
|
906
|
+
className
|
|
907
|
+
}, ref) => React11.createElement(ScrollAreaRoot, { scrollbarsize: scrollbarSize, offset, className }, React11.createElement(ScrollAreaViewport2, { ref, style: { scrollPadding } }, children), horizontal && React11.createElement(
|
|
908
|
+
ScrollAreaScrollbar2,
|
|
909
|
+
{
|
|
910
|
+
orientation: "horizontal",
|
|
911
|
+
offset,
|
|
912
|
+
horizontal: horizontal.toString(),
|
|
913
|
+
vertical: vertical.toString()
|
|
914
|
+
},
|
|
915
|
+
React11.createElement(ScrollAreaThumb2, null)
|
|
916
|
+
), vertical && React11.createElement(
|
|
917
|
+
ScrollAreaScrollbar2,
|
|
918
|
+
{
|
|
919
|
+
orientation: "vertical",
|
|
920
|
+
offset,
|
|
921
|
+
horizontal: horizontal.toString(),
|
|
922
|
+
vertical: vertical.toString()
|
|
923
|
+
},
|
|
924
|
+
React11.createElement(ScrollAreaThumb2, null)
|
|
925
|
+
), horizontal && vertical && React11.createElement(Corner, null))
|
|
926
|
+
);
|
|
927
|
+
ScrollArea2.displayName = "ScrollArea";
|
|
928
|
+
|
|
929
|
+
// src/components/components/syntaxhighlighter/clipboard.ts
|
|
930
|
+
import { global } from "@storybook/global";
|
|
931
|
+
var { document: document2, window: globalWindow } = global;
|
|
932
|
+
async function copyUsingClipboardAPI(text) {
|
|
933
|
+
try {
|
|
934
|
+
await globalWindow.top?.navigator.clipboard.writeText(text);
|
|
935
|
+
} catch {
|
|
936
|
+
await globalWindow.navigator.clipboard.writeText(text);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
async function copyUsingWorkAround(text) {
|
|
940
|
+
let tmp = document2.createElement("TEXTAREA"), focus = document2.activeElement;
|
|
941
|
+
tmp.value = text, document2.body.appendChild(tmp), tmp.select(), document2.execCommand("copy"), document2.body.removeChild(tmp), focus.focus();
|
|
942
|
+
}
|
|
943
|
+
function createCopyToClipboardFunction() {
|
|
944
|
+
return globalWindow.navigator?.clipboard ? copyUsingClipboardAPI : copyUsingWorkAround;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
export {
|
|
948
|
+
ActionBar,
|
|
949
|
+
ScrollArea2 as ScrollArea,
|
|
950
|
+
createCopyToClipboardFunction
|
|
951
|
+
};
|