@luxfi/ui 6.1.2 → 7.0.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/accordion.cjs +213 -0
- package/dist/accordion.d.cts +74 -0
- package/dist/accordion.d.ts +74 -0
- package/dist/accordion.js +186 -0
- package/dist/alert.cjs +553 -0
- package/dist/alert.d.cts +30 -0
- package/dist/alert.d.ts +30 -0
- package/dist/alert.js +531 -0
- package/dist/avatar.cjs +149 -0
- package/dist/avatar.d.cts +25 -0
- package/dist/avatar.d.ts +25 -0
- package/dist/avatar.js +125 -0
- package/dist/badge.cjs +611 -0
- package/dist/badge.d.cts +23 -0
- package/dist/badge.d.ts +23 -0
- package/dist/badge.js +589 -0
- package/dist/bank.cjs +272 -0
- package/dist/bank.d.cts +76 -0
- package/dist/bank.d.ts +76 -0
- package/dist/bank.js +258 -0
- package/dist/button.cjs +689 -0
- package/dist/button.d.cts +52 -0
- package/dist/button.d.ts +52 -0
- package/dist/button.js +664 -0
- package/dist/checkbox.cjs +265 -0
- package/dist/checkbox.d.cts +31 -0
- package/dist/checkbox.d.ts +31 -0
- package/dist/checkbox.js +241 -0
- package/dist/close-button.cjs +73 -0
- package/dist/close-button.d.cts +9 -0
- package/dist/close-button.d.ts +9 -0
- package/dist/close-button.js +51 -0
- package/dist/collapsible.cjs +702 -0
- package/dist/collapsible.d.cts +23 -0
- package/dist/collapsible.d.ts +23 -0
- package/dist/collapsible.js +679 -0
- package/dist/color-mode.cjs +96 -0
- package/dist/color-mode.d.cts +25 -0
- package/dist/color-mode.d.ts +25 -0
- package/dist/color-mode.js +72 -0
- package/dist/dialog.cjs +279 -0
- package/dist/dialog.d.cts +66 -0
- package/dist/dialog.d.ts +66 -0
- package/dist/dialog.js +246 -0
- package/dist/drawer.cjs +207 -0
- package/dist/drawer.d.cts +36 -0
- package/dist/drawer.d.ts +36 -0
- package/dist/drawer.js +175 -0
- package/dist/empty-state.cjs +93 -0
- package/dist/empty-state.d.cts +13 -0
- package/dist/empty-state.d.ts +13 -0
- package/dist/empty-state.js +71 -0
- package/dist/expiration-selector.cjs +138 -0
- package/dist/expiration-selector.d.cts +16 -0
- package/dist/expiration-selector.d.ts +16 -0
- package/dist/expiration-selector.js +116 -0
- package/dist/field.cjs +183 -0
- package/dist/field.d.cts +24 -0
- package/dist/field.d.ts +24 -0
- package/dist/field.js +160 -0
- package/dist/greeks-display.cjs +114 -0
- package/dist/greeks-display.d.cts +14 -0
- package/dist/greeks-display.d.ts +14 -0
- package/dist/greeks-display.js +92 -0
- package/dist/heading.cjs +46 -0
- package/dist/heading.d.cts +10 -0
- package/dist/heading.d.ts +10 -0
- package/dist/heading.js +40 -0
- package/dist/icon-button.cjs +491 -0
- package/dist/icon-button.d.cts +33 -0
- package/dist/icon-button.d.ts +33 -0
- package/dist/icon-button.js +470 -0
- package/dist/image.cjs +572 -0
- package/dist/image.d.cts +57 -0
- package/dist/image.d.ts +57 -0
- package/dist/image.js +551 -0
- package/dist/index.cjs +7316 -0
- package/dist/index.d.cts +58 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.js +7137 -0
- package/dist/input-group.cjs +155 -0
- package/dist/input-group.d.cts +17 -0
- package/dist/input-group.d.ts +17 -0
- package/dist/input-group.js +133 -0
- package/dist/input.cjs +65 -0
- package/dist/input.d.cts +11 -0
- package/dist/input.d.ts +11 -0
- package/dist/input.js +59 -0
- package/dist/link.cjs +630 -0
- package/dist/link.d.cts +37 -0
- package/dist/link.d.ts +37 -0
- package/dist/link.js +606 -0
- package/dist/menu.cjs +305 -0
- package/dist/menu.d.cts +84 -0
- package/dist/menu.d.ts +84 -0
- package/dist/menu.js +269 -0
- package/dist/option-chain.cjs +221 -0
- package/dist/option-chain.d.cts +37 -0
- package/dist/option-chain.d.ts +37 -0
- package/dist/option-chain.js +199 -0
- package/dist/option-position.cjs +164 -0
- package/dist/option-position.d.cts +29 -0
- package/dist/option-position.d.ts +29 -0
- package/dist/option-position.js +142 -0
- package/dist/pin-input.cjs +182 -0
- package/dist/pin-input.d.cts +25 -0
- package/dist/pin-input.d.ts +25 -0
- package/dist/pin-input.js +160 -0
- package/dist/pnl-diagram.cjs +453 -0
- package/dist/pnl-diagram.d.cts +11 -0
- package/dist/pnl-diagram.d.ts +11 -0
- package/dist/pnl-diagram.js +431 -0
- package/dist/popover.cjs +327 -0
- package/dist/popover.d.cts +73 -0
- package/dist/popover.d.ts +73 -0
- package/dist/popover.js +294 -0
- package/dist/progress-circle.cjs +152 -0
- package/dist/progress-circle.d.cts +47 -0
- package/dist/progress-circle.d.ts +47 -0
- package/dist/progress-circle.js +128 -0
- package/dist/progress.cjs +117 -0
- package/dist/progress.d.cts +28 -0
- package/dist/progress.d.ts +28 -0
- package/dist/progress.js +94 -0
- package/dist/provider.cjs +62 -0
- package/dist/provider.d.cts +7 -0
- package/dist/provider.d.ts +7 -0
- package/dist/provider.js +40 -0
- package/dist/radio.cjs +177 -0
- package/dist/radio.d.cts +53 -0
- package/dist/radio.d.ts +53 -0
- package/dist/radio.js +153 -0
- package/dist/rating.cjs +80 -0
- package/dist/rating.d.cts +14 -0
- package/dist/rating.d.ts +14 -0
- package/dist/rating.js +58 -0
- package/dist/select.cjs +791 -0
- package/dist/select.d.cts +130 -0
- package/dist/select.d.ts +130 -0
- package/dist/select.js +757 -0
- package/dist/separator.cjs +57 -0
- package/dist/separator.d.cts +13 -0
- package/dist/separator.d.ts +13 -0
- package/dist/separator.js +51 -0
- package/dist/skeleton.cjs +370 -0
- package/dist/skeleton.d.cts +60 -0
- package/dist/skeleton.d.ts +60 -0
- package/dist/skeleton.js +346 -0
- package/dist/slider.cjs +138 -0
- package/dist/slider.d.cts +24 -0
- package/dist/slider.d.ts +24 -0
- package/dist/slider.js +115 -0
- package/dist/strategy-builder.cjs +373 -0
- package/dist/strategy-builder.d.cts +26 -0
- package/dist/strategy-builder.d.ts +26 -0
- package/dist/strategy-builder.js +351 -0
- package/dist/switch.cjs +163 -0
- package/dist/switch.d.cts +27 -0
- package/dist/switch.d.ts +27 -0
- package/dist/switch.js +140 -0
- package/dist/table.cjs +1044 -0
- package/dist/table.d.cts +107 -0
- package/dist/table.d.ts +107 -0
- package/dist/table.js +1013 -0
- package/dist/tabs.cjs +240 -0
- package/dist/tabs.d.cts +78 -0
- package/dist/tabs.d.ts +78 -0
- package/dist/tabs.js +213 -0
- package/dist/tag.cjs +651 -0
- package/dist/tag.d.cts +21 -0
- package/dist/tag.d.ts +21 -0
- package/dist/tag.js +628 -0
- package/dist/textarea.cjs +65 -0
- package/dist/textarea.d.cts +11 -0
- package/dist/textarea.d.ts +11 -0
- package/dist/textarea.js +59 -0
- package/dist/toaster.cjs +99 -0
- package/dist/toaster.d.cts +29 -0
- package/dist/toaster.d.ts +29 -0
- package/dist/toaster.js +96 -0
- package/dist/tooltip.cjs +171 -0
- package/dist/tooltip.d.cts +39 -0
- package/dist/tooltip.d.ts +39 -0
- package/dist/tooltip.js +148 -0
- package/dist/utils.cjs +11 -0
- package/dist/utils.d.cts +5 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +9 -0
- package/package.json +284 -85
- package/src/accordion.tsx +285 -0
- package/src/alert.tsx +221 -0
- package/src/avatar.tsx +174 -0
- package/src/badge.tsx +158 -0
- package/src/bank.tsx +325 -0
- package/src/button.tsx +411 -0
- package/src/checkbox.tsx +307 -0
- package/src/close-button.tsx +51 -0
- package/src/collapsible.tsx +126 -0
- package/src/color-mode.tsx +125 -0
- package/src/dialog.tsx +356 -0
- package/src/drawer.tsx +186 -0
- package/src/empty-state.tsx +97 -0
- package/src/expiration-selector.tsx +163 -0
- package/src/field.tsx +202 -0
- package/src/greeks-display.tsx +138 -0
- package/src/heading.tsx +55 -0
- package/src/icon-button.tsx +192 -0
- package/src/image.tsx +280 -0
- package/src/index.ts +268 -0
- package/src/input-group.tsx +159 -0
- package/src/input.tsx +60 -0
- package/src/link.tsx +326 -0
- package/src/menu.tsx +471 -0
- package/src/option-chain.tsx +261 -0
- package/src/option-position.tsx +200 -0
- package/src/pin-input.tsx +187 -0
- package/src/pnl-diagram.tsx +458 -0
- package/src/popover.tsx +400 -0
- package/src/progress-circle.tsx +180 -0
- package/src/progress.tsx +109 -0
- package/src/provider.tsx +12 -0
- package/src/radio.tsx +175 -0
- package/src/rating.tsx +79 -0
- package/src/select.tsx +696 -0
- package/src/separator.tsx +59 -0
- package/src/skeleton.tsx +302 -0
- package/src/slider.tsx +152 -0
- package/src/strategy-builder.tsx +466 -0
- package/src/switch.tsx +158 -0
- package/src/table.tsx +621 -0
- package/src/tabs.tsx +354 -0
- package/src/tag.tsx +159 -0
- package/src/textarea.tsx +60 -0
- package/src/toaster.tsx +117 -0
- package/src/tokens.css +438 -0
- package/src/tooltip.tsx +184 -0
- package/src/utils/cn.ts +7 -0
- package/src/utils.ts +6 -0
- package/tokens.css +438 -0
- package/README.md +0 -109
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var AccordionPrimitive = require('@radix-ui/react-accordion');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var clsx = require('clsx');
|
|
7
|
+
var tailwindMerge = require('tailwind-merge');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
|
|
10
|
+
function _interopNamespace(e) {
|
|
11
|
+
if (e && e.__esModule) return e;
|
|
12
|
+
var n = Object.create(null);
|
|
13
|
+
if (e) {
|
|
14
|
+
Object.keys(e).forEach(function (k) {
|
|
15
|
+
if (k !== 'default') {
|
|
16
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return e[k]; }
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
n.default = e;
|
|
25
|
+
return Object.freeze(n);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var AccordionPrimitive__namespace = /*#__PURE__*/_interopNamespace(AccordionPrimitive);
|
|
29
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
30
|
+
|
|
31
|
+
// src/accordion.tsx
|
|
32
|
+
function cn(...inputs) {
|
|
33
|
+
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
34
|
+
}
|
|
35
|
+
var IndicatorIcon = ({ className }) => /* @__PURE__ */ jsxRuntime.jsx("svg", { className, viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M7.5 15L12.5 10L7.5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
36
|
+
var AccordionRoot = React__namespace.forwardRef(
|
|
37
|
+
function AccordionRoot2(props, ref) {
|
|
38
|
+
const {
|
|
39
|
+
multiple: _multiple,
|
|
40
|
+
value,
|
|
41
|
+
defaultValue,
|
|
42
|
+
onValueChange,
|
|
43
|
+
variant,
|
|
44
|
+
size,
|
|
45
|
+
noAnimation: _noAnimation,
|
|
46
|
+
lazyMount: _lazyMount,
|
|
47
|
+
className,
|
|
48
|
+
children,
|
|
49
|
+
position: _position,
|
|
50
|
+
w: _w,
|
|
51
|
+
bgColor: _bgColor,
|
|
52
|
+
borderRadius: _borderRadius,
|
|
53
|
+
...rest
|
|
54
|
+
} = props;
|
|
55
|
+
const handleValueChange = React__namespace.useCallback(
|
|
56
|
+
(next) => {
|
|
57
|
+
onValueChange?.({ value: next });
|
|
58
|
+
},
|
|
59
|
+
[onValueChange]
|
|
60
|
+
);
|
|
61
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
62
|
+
AccordionPrimitive__namespace.Root,
|
|
63
|
+
{
|
|
64
|
+
ref,
|
|
65
|
+
type: "multiple",
|
|
66
|
+
value,
|
|
67
|
+
defaultValue,
|
|
68
|
+
onValueChange: handleValueChange,
|
|
69
|
+
className: cn(
|
|
70
|
+
"w-full",
|
|
71
|
+
variant === "faq" && "accordion-faq",
|
|
72
|
+
size === "sm" && "accordion-sm",
|
|
73
|
+
className
|
|
74
|
+
),
|
|
75
|
+
"data-variant": variant,
|
|
76
|
+
"data-size": size,
|
|
77
|
+
...rest,
|
|
78
|
+
children
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
var AccordionItem = React__namespace.forwardRef(
|
|
84
|
+
function AccordionItem2(props, ref) {
|
|
85
|
+
const { className, as: _as, _first, _last, display: _display, ...rest } = props;
|
|
86
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
87
|
+
AccordionPrimitive__namespace.Item,
|
|
88
|
+
{
|
|
89
|
+
ref,
|
|
90
|
+
className: cn(
|
|
91
|
+
"border-b border-[var(--color-border-divider)]",
|
|
92
|
+
className
|
|
93
|
+
),
|
|
94
|
+
...rest
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
var AccordionItemTrigger = React__namespace.forwardRef(function AccordionItemTrigger2(props, ref) {
|
|
100
|
+
const {
|
|
101
|
+
children,
|
|
102
|
+
indicatorPlacement: indicatorPlacementProp,
|
|
103
|
+
variant,
|
|
104
|
+
noIndicator,
|
|
105
|
+
className,
|
|
106
|
+
// Strip Chakra style props
|
|
107
|
+
px: _px,
|
|
108
|
+
py: _py,
|
|
109
|
+
_hover,
|
|
110
|
+
wordBreak: _wordBreak,
|
|
111
|
+
textAlign: _textAlign,
|
|
112
|
+
cursor: _cursor,
|
|
113
|
+
display: _display,
|
|
114
|
+
alignItems: _alignItems,
|
|
115
|
+
columnGap: _columnGap,
|
|
116
|
+
...rest
|
|
117
|
+
} = props;
|
|
118
|
+
const indicatorPlacement = variant === "faq" ? "start" : indicatorPlacementProp ?? "end";
|
|
119
|
+
const indicator = variant === "faq" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
120
|
+
"span",
|
|
121
|
+
{
|
|
122
|
+
className: cn(
|
|
123
|
+
"relative inline-block h-3 w-3 shrink-0",
|
|
124
|
+
// horizontal bar (always visible)
|
|
125
|
+
"before:absolute before:left-0 before:top-1/2 before:block before:h-[2px] before:w-full before:-translate-y-1/2 before:rounded-[2px] before:bg-current",
|
|
126
|
+
// vertical bar (rotates to 0 when open)
|
|
127
|
+
"after:absolute after:left-1/2 after:top-0 after:block after:h-full after:w-[2px]",
|
|
128
|
+
"after:-translate-x-1/2 after:rounded-[2px] after:bg-current",
|
|
129
|
+
"after:transition-transform after:duration-200 after:ease-in-out",
|
|
130
|
+
// When parent trigger has data-state="open", rotate vertical bar
|
|
131
|
+
"group-data-[state=open]/trigger:after:rotate-90"
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
135
|
+
"span",
|
|
136
|
+
{
|
|
137
|
+
className: cn(
|
|
138
|
+
"inline-flex shrink-0 transition-transform duration-200",
|
|
139
|
+
"rotate-180",
|
|
140
|
+
"group-data-[state=open]/trigger:rotate-[270deg]"
|
|
141
|
+
),
|
|
142
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(IndicatorIcon, { className: "h-5 w-5" })
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AccordionPrimitive__namespace.Header, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
146
|
+
AccordionPrimitive__namespace.Trigger,
|
|
147
|
+
{
|
|
148
|
+
ref,
|
|
149
|
+
className: cn(
|
|
150
|
+
"group/trigger flex w-full cursor-pointer items-center gap-2 py-3 text-left text-[var(--color-text-primary)]",
|
|
151
|
+
"hover:text-[var(--color-hover)]",
|
|
152
|
+
"focus-visible:outline-none",
|
|
153
|
+
className
|
|
154
|
+
),
|
|
155
|
+
...rest,
|
|
156
|
+
children: [
|
|
157
|
+
indicatorPlacement === "start" && !noIndicator && indicator,
|
|
158
|
+
children,
|
|
159
|
+
indicatorPlacement === "end" && !noIndicator && indicator
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
) }) });
|
|
163
|
+
});
|
|
164
|
+
var AccordionItemContent = React__namespace.forwardRef(function AccordionItemContent2(props, ref) {
|
|
165
|
+
const { className, children, pb: _pb, pr: _pr, pl: _pl, w: _w, display: _display, flexDir: _flexDir, rowGap: _rowGap, ...rest } = props;
|
|
166
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
167
|
+
AccordionPrimitive__namespace.Content,
|
|
168
|
+
{
|
|
169
|
+
ref,
|
|
170
|
+
className: cn(
|
|
171
|
+
"overflow-hidden text-[var(--color-text-primary)]",
|
|
172
|
+
"data-[state=open]:animate-accordion-down",
|
|
173
|
+
"data-[state=closed]:animate-accordion-up",
|
|
174
|
+
className
|
|
175
|
+
),
|
|
176
|
+
...rest,
|
|
177
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pb-3", children })
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
});
|
|
181
|
+
function useAccordion(items) {
|
|
182
|
+
const [value, setValue] = React__namespace.useState([]);
|
|
183
|
+
const onValueChange = React__namespace.useCallback(({ value: value2 }) => {
|
|
184
|
+
setValue(value2);
|
|
185
|
+
}, []);
|
|
186
|
+
const scrollToItemFromUrl = React__namespace.useCallback(() => {
|
|
187
|
+
const hash = window.location.hash.replace("#", "");
|
|
188
|
+
if (!hash) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const itemToScroll = items.find((item) => item.id === hash);
|
|
192
|
+
if (itemToScroll) {
|
|
193
|
+
const el = document.getElementById(itemToScroll.id);
|
|
194
|
+
if (el) {
|
|
195
|
+
el.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
196
|
+
}
|
|
197
|
+
setValue([itemToScroll.id]);
|
|
198
|
+
}
|
|
199
|
+
}, [items]);
|
|
200
|
+
return React__namespace.useMemo(() => {
|
|
201
|
+
return {
|
|
202
|
+
value,
|
|
203
|
+
onValueChange,
|
|
204
|
+
scrollToItemFromUrl
|
|
205
|
+
};
|
|
206
|
+
}, [value, onValueChange, scrollToItemFromUrl]);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
exports.AccordionItem = AccordionItem;
|
|
210
|
+
exports.AccordionItemContent = AccordionItemContent;
|
|
211
|
+
exports.AccordionItemTrigger = AccordionItemTrigger;
|
|
212
|
+
exports.AccordionRoot = AccordionRoot;
|
|
213
|
+
exports.useAccordion = useAccordion;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
interface AccordionRootProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'defaultValue' | 'dir'> {
|
|
5
|
+
/** Open multiple items simultaneously. Defaults to true. */
|
|
6
|
+
readonly multiple?: boolean;
|
|
7
|
+
/** Controlled open items (array of `value` strings). */
|
|
8
|
+
readonly value?: Array<string>;
|
|
9
|
+
/** Uncontrolled initial open items. */
|
|
10
|
+
readonly defaultValue?: Array<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Called when open items change.
|
|
13
|
+
* Wraps the value in `{ value }` to stay compatible with the Chakra callback shape
|
|
14
|
+
* that consumers already rely on.
|
|
15
|
+
*/
|
|
16
|
+
readonly onValueChange?: (details: {
|
|
17
|
+
value: Array<string>;
|
|
18
|
+
}) => void;
|
|
19
|
+
readonly variant?: 'outline' | 'faq';
|
|
20
|
+
readonly size?: 'sm' | 'md';
|
|
21
|
+
/** Accepted for compatibility; not applied visually. */
|
|
22
|
+
readonly noAnimation?: boolean;
|
|
23
|
+
/** Accepted for compatibility; Radix defers rendering internally. */
|
|
24
|
+
readonly lazyMount?: boolean;
|
|
25
|
+
readonly children?: React.ReactNode;
|
|
26
|
+
readonly position?: string;
|
|
27
|
+
readonly w?: string;
|
|
28
|
+
readonly bgColor?: string | Record<string, string>;
|
|
29
|
+
readonly borderRadius?: string;
|
|
30
|
+
}
|
|
31
|
+
declare const AccordionRoot: React.ForwardRefExoticComponent<AccordionRootProps & React.RefAttributes<HTMLDivElement>>;
|
|
32
|
+
interface AccordionItemProps extends React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item> {
|
|
33
|
+
as?: string;
|
|
34
|
+
_first?: Record<string, unknown>;
|
|
35
|
+
_last?: Record<string, unknown>;
|
|
36
|
+
display?: string;
|
|
37
|
+
}
|
|
38
|
+
declare const AccordionItem: React.ForwardRefExoticComponent<AccordionItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
39
|
+
interface AccordionItemTriggerProps extends Omit<React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>, 'dir'> {
|
|
40
|
+
readonly indicatorPlacement?: 'start' | 'end';
|
|
41
|
+
readonly noIndicator?: boolean;
|
|
42
|
+
readonly variant?: 'outline' | 'faq';
|
|
43
|
+
px?: number | string;
|
|
44
|
+
py?: number | string;
|
|
45
|
+
_hover?: Record<string, string>;
|
|
46
|
+
wordBreak?: string;
|
|
47
|
+
textAlign?: string;
|
|
48
|
+
cursor?: string;
|
|
49
|
+
display?: string;
|
|
50
|
+
alignItems?: string;
|
|
51
|
+
columnGap?: number | string;
|
|
52
|
+
}
|
|
53
|
+
declare const AccordionItemTrigger: React.ForwardRefExoticComponent<AccordionItemTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
54
|
+
interface AccordionItemContentProps extends React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content> {
|
|
55
|
+
pb?: number | string;
|
|
56
|
+
pr?: number | string;
|
|
57
|
+
pl?: string;
|
|
58
|
+
w?: string;
|
|
59
|
+
display?: string;
|
|
60
|
+
flexDir?: string;
|
|
61
|
+
rowGap?: number | string;
|
|
62
|
+
}
|
|
63
|
+
declare const AccordionItemContent: React.ForwardRefExoticComponent<AccordionItemContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
64
|
+
declare function useAccordion(items: Array<{
|
|
65
|
+
id: string;
|
|
66
|
+
}>): {
|
|
67
|
+
value: string[];
|
|
68
|
+
onValueChange: ({ value }: {
|
|
69
|
+
value: Array<string>;
|
|
70
|
+
}) => void;
|
|
71
|
+
scrollToItemFromUrl: () => void;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export { AccordionItem, AccordionItemContent, type AccordionItemContentProps, AccordionItemTrigger, AccordionRoot, useAccordion };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
interface AccordionRootProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'defaultValue' | 'dir'> {
|
|
5
|
+
/** Open multiple items simultaneously. Defaults to true. */
|
|
6
|
+
readonly multiple?: boolean;
|
|
7
|
+
/** Controlled open items (array of `value` strings). */
|
|
8
|
+
readonly value?: Array<string>;
|
|
9
|
+
/** Uncontrolled initial open items. */
|
|
10
|
+
readonly defaultValue?: Array<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Called when open items change.
|
|
13
|
+
* Wraps the value in `{ value }` to stay compatible with the Chakra callback shape
|
|
14
|
+
* that consumers already rely on.
|
|
15
|
+
*/
|
|
16
|
+
readonly onValueChange?: (details: {
|
|
17
|
+
value: Array<string>;
|
|
18
|
+
}) => void;
|
|
19
|
+
readonly variant?: 'outline' | 'faq';
|
|
20
|
+
readonly size?: 'sm' | 'md';
|
|
21
|
+
/** Accepted for compatibility; not applied visually. */
|
|
22
|
+
readonly noAnimation?: boolean;
|
|
23
|
+
/** Accepted for compatibility; Radix defers rendering internally. */
|
|
24
|
+
readonly lazyMount?: boolean;
|
|
25
|
+
readonly children?: React.ReactNode;
|
|
26
|
+
readonly position?: string;
|
|
27
|
+
readonly w?: string;
|
|
28
|
+
readonly bgColor?: string | Record<string, string>;
|
|
29
|
+
readonly borderRadius?: string;
|
|
30
|
+
}
|
|
31
|
+
declare const AccordionRoot: React.ForwardRefExoticComponent<AccordionRootProps & React.RefAttributes<HTMLDivElement>>;
|
|
32
|
+
interface AccordionItemProps extends React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item> {
|
|
33
|
+
as?: string;
|
|
34
|
+
_first?: Record<string, unknown>;
|
|
35
|
+
_last?: Record<string, unknown>;
|
|
36
|
+
display?: string;
|
|
37
|
+
}
|
|
38
|
+
declare const AccordionItem: React.ForwardRefExoticComponent<AccordionItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
39
|
+
interface AccordionItemTriggerProps extends Omit<React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>, 'dir'> {
|
|
40
|
+
readonly indicatorPlacement?: 'start' | 'end';
|
|
41
|
+
readonly noIndicator?: boolean;
|
|
42
|
+
readonly variant?: 'outline' | 'faq';
|
|
43
|
+
px?: number | string;
|
|
44
|
+
py?: number | string;
|
|
45
|
+
_hover?: Record<string, string>;
|
|
46
|
+
wordBreak?: string;
|
|
47
|
+
textAlign?: string;
|
|
48
|
+
cursor?: string;
|
|
49
|
+
display?: string;
|
|
50
|
+
alignItems?: string;
|
|
51
|
+
columnGap?: number | string;
|
|
52
|
+
}
|
|
53
|
+
declare const AccordionItemTrigger: React.ForwardRefExoticComponent<AccordionItemTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
54
|
+
interface AccordionItemContentProps extends React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content> {
|
|
55
|
+
pb?: number | string;
|
|
56
|
+
pr?: number | string;
|
|
57
|
+
pl?: string;
|
|
58
|
+
w?: string;
|
|
59
|
+
display?: string;
|
|
60
|
+
flexDir?: string;
|
|
61
|
+
rowGap?: number | string;
|
|
62
|
+
}
|
|
63
|
+
declare const AccordionItemContent: React.ForwardRefExoticComponent<AccordionItemContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
64
|
+
declare function useAccordion(items: Array<{
|
|
65
|
+
id: string;
|
|
66
|
+
}>): {
|
|
67
|
+
value: string[];
|
|
68
|
+
onValueChange: ({ value }: {
|
|
69
|
+
value: Array<string>;
|
|
70
|
+
}) => void;
|
|
71
|
+
scrollToItemFromUrl: () => void;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export { AccordionItem, AccordionItemContent, type AccordionItemContentProps, AccordionItemTrigger, AccordionRoot, useAccordion };
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
import { twMerge } from 'tailwind-merge';
|
|
6
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
// src/accordion.tsx
|
|
9
|
+
function cn(...inputs) {
|
|
10
|
+
return twMerge(clsx(inputs));
|
|
11
|
+
}
|
|
12
|
+
var IndicatorIcon = ({ className }) => /* @__PURE__ */ jsx("svg", { className, viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { d: "M7.5 15L12.5 10L7.5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
13
|
+
var AccordionRoot = React.forwardRef(
|
|
14
|
+
function AccordionRoot2(props, ref) {
|
|
15
|
+
const {
|
|
16
|
+
multiple: _multiple,
|
|
17
|
+
value,
|
|
18
|
+
defaultValue,
|
|
19
|
+
onValueChange,
|
|
20
|
+
variant,
|
|
21
|
+
size,
|
|
22
|
+
noAnimation: _noAnimation,
|
|
23
|
+
lazyMount: _lazyMount,
|
|
24
|
+
className,
|
|
25
|
+
children,
|
|
26
|
+
position: _position,
|
|
27
|
+
w: _w,
|
|
28
|
+
bgColor: _bgColor,
|
|
29
|
+
borderRadius: _borderRadius,
|
|
30
|
+
...rest
|
|
31
|
+
} = props;
|
|
32
|
+
const handleValueChange = React.useCallback(
|
|
33
|
+
(next) => {
|
|
34
|
+
onValueChange?.({ value: next });
|
|
35
|
+
},
|
|
36
|
+
[onValueChange]
|
|
37
|
+
);
|
|
38
|
+
return /* @__PURE__ */ jsx(
|
|
39
|
+
AccordionPrimitive.Root,
|
|
40
|
+
{
|
|
41
|
+
ref,
|
|
42
|
+
type: "multiple",
|
|
43
|
+
value,
|
|
44
|
+
defaultValue,
|
|
45
|
+
onValueChange: handleValueChange,
|
|
46
|
+
className: cn(
|
|
47
|
+
"w-full",
|
|
48
|
+
variant === "faq" && "accordion-faq",
|
|
49
|
+
size === "sm" && "accordion-sm",
|
|
50
|
+
className
|
|
51
|
+
),
|
|
52
|
+
"data-variant": variant,
|
|
53
|
+
"data-size": size,
|
|
54
|
+
...rest,
|
|
55
|
+
children
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
var AccordionItem = React.forwardRef(
|
|
61
|
+
function AccordionItem2(props, ref) {
|
|
62
|
+
const { className, as: _as, _first, _last, display: _display, ...rest } = props;
|
|
63
|
+
return /* @__PURE__ */ jsx(
|
|
64
|
+
AccordionPrimitive.Item,
|
|
65
|
+
{
|
|
66
|
+
ref,
|
|
67
|
+
className: cn(
|
|
68
|
+
"border-b border-[var(--color-border-divider)]",
|
|
69
|
+
className
|
|
70
|
+
),
|
|
71
|
+
...rest
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
var AccordionItemTrigger = React.forwardRef(function AccordionItemTrigger2(props, ref) {
|
|
77
|
+
const {
|
|
78
|
+
children,
|
|
79
|
+
indicatorPlacement: indicatorPlacementProp,
|
|
80
|
+
variant,
|
|
81
|
+
noIndicator,
|
|
82
|
+
className,
|
|
83
|
+
// Strip Chakra style props
|
|
84
|
+
px: _px,
|
|
85
|
+
py: _py,
|
|
86
|
+
_hover,
|
|
87
|
+
wordBreak: _wordBreak,
|
|
88
|
+
textAlign: _textAlign,
|
|
89
|
+
cursor: _cursor,
|
|
90
|
+
display: _display,
|
|
91
|
+
alignItems: _alignItems,
|
|
92
|
+
columnGap: _columnGap,
|
|
93
|
+
...rest
|
|
94
|
+
} = props;
|
|
95
|
+
const indicatorPlacement = variant === "faq" ? "start" : indicatorPlacementProp ?? "end";
|
|
96
|
+
const indicator = variant === "faq" ? /* @__PURE__ */ jsx(
|
|
97
|
+
"span",
|
|
98
|
+
{
|
|
99
|
+
className: cn(
|
|
100
|
+
"relative inline-block h-3 w-3 shrink-0",
|
|
101
|
+
// horizontal bar (always visible)
|
|
102
|
+
"before:absolute before:left-0 before:top-1/2 before:block before:h-[2px] before:w-full before:-translate-y-1/2 before:rounded-[2px] before:bg-current",
|
|
103
|
+
// vertical bar (rotates to 0 when open)
|
|
104
|
+
"after:absolute after:left-1/2 after:top-0 after:block after:h-full after:w-[2px]",
|
|
105
|
+
"after:-translate-x-1/2 after:rounded-[2px] after:bg-current",
|
|
106
|
+
"after:transition-transform after:duration-200 after:ease-in-out",
|
|
107
|
+
// When parent trigger has data-state="open", rotate vertical bar
|
|
108
|
+
"group-data-[state=open]/trigger:after:rotate-90"
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
) : /* @__PURE__ */ jsx(
|
|
112
|
+
"span",
|
|
113
|
+
{
|
|
114
|
+
className: cn(
|
|
115
|
+
"inline-flex shrink-0 transition-transform duration-200",
|
|
116
|
+
"rotate-180",
|
|
117
|
+
"group-data-[state=open]/trigger:rotate-[270deg]"
|
|
118
|
+
),
|
|
119
|
+
children: /* @__PURE__ */ jsx(IndicatorIcon, { className: "h-5 w-5" })
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
return /* @__PURE__ */ jsx(AccordionPrimitive.Header, { asChild: true, children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(
|
|
123
|
+
AccordionPrimitive.Trigger,
|
|
124
|
+
{
|
|
125
|
+
ref,
|
|
126
|
+
className: cn(
|
|
127
|
+
"group/trigger flex w-full cursor-pointer items-center gap-2 py-3 text-left text-[var(--color-text-primary)]",
|
|
128
|
+
"hover:text-[var(--color-hover)]",
|
|
129
|
+
"focus-visible:outline-none",
|
|
130
|
+
className
|
|
131
|
+
),
|
|
132
|
+
...rest,
|
|
133
|
+
children: [
|
|
134
|
+
indicatorPlacement === "start" && !noIndicator && indicator,
|
|
135
|
+
children,
|
|
136
|
+
indicatorPlacement === "end" && !noIndicator && indicator
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
) }) });
|
|
140
|
+
});
|
|
141
|
+
var AccordionItemContent = React.forwardRef(function AccordionItemContent2(props, ref) {
|
|
142
|
+
const { className, children, pb: _pb, pr: _pr, pl: _pl, w: _w, display: _display, flexDir: _flexDir, rowGap: _rowGap, ...rest } = props;
|
|
143
|
+
return /* @__PURE__ */ jsx(
|
|
144
|
+
AccordionPrimitive.Content,
|
|
145
|
+
{
|
|
146
|
+
ref,
|
|
147
|
+
className: cn(
|
|
148
|
+
"overflow-hidden text-[var(--color-text-primary)]",
|
|
149
|
+
"data-[state=open]:animate-accordion-down",
|
|
150
|
+
"data-[state=closed]:animate-accordion-up",
|
|
151
|
+
className
|
|
152
|
+
),
|
|
153
|
+
...rest,
|
|
154
|
+
children: /* @__PURE__ */ jsx("div", { className: "pb-3", children })
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
});
|
|
158
|
+
function useAccordion(items) {
|
|
159
|
+
const [value, setValue] = React.useState([]);
|
|
160
|
+
const onValueChange = React.useCallback(({ value: value2 }) => {
|
|
161
|
+
setValue(value2);
|
|
162
|
+
}, []);
|
|
163
|
+
const scrollToItemFromUrl = React.useCallback(() => {
|
|
164
|
+
const hash = window.location.hash.replace("#", "");
|
|
165
|
+
if (!hash) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const itemToScroll = items.find((item) => item.id === hash);
|
|
169
|
+
if (itemToScroll) {
|
|
170
|
+
const el = document.getElementById(itemToScroll.id);
|
|
171
|
+
if (el) {
|
|
172
|
+
el.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
173
|
+
}
|
|
174
|
+
setValue([itemToScroll.id]);
|
|
175
|
+
}
|
|
176
|
+
}, [items]);
|
|
177
|
+
return React.useMemo(() => {
|
|
178
|
+
return {
|
|
179
|
+
value,
|
|
180
|
+
onValueChange,
|
|
181
|
+
scrollToItemFromUrl
|
|
182
|
+
};
|
|
183
|
+
}, [value, onValueChange, scrollToItemFromUrl]);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export { AccordionItem, AccordionItemContent, AccordionItemTrigger, AccordionRoot, useAccordion };
|