@oxide/design-system 3.1.0 → 3.1.1--canary.152.18514620224.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -14
- package/dist/chunk-7VKKHVZC.js +45 -0
- package/dist/chunk-7VKKHVZC.js.map +1 -0
- package/dist/components/src/asciidoc/index.d.ts +72 -0
- package/dist/components/src/{index.js → asciidoc/index.js} +18 -409
- package/dist/components/src/asciidoc/index.js.map +1 -0
- package/dist/components/src/{index.d.ts → ui/index.d.ts} +1 -70
- package/dist/components/src/ui/index.js +360 -0
- package/dist/components/src/ui/index.js.map +1 -0
- package/package.json +5 -12
- package/dist/components/src/index.js.map +0 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
titleCase
|
|
3
|
+
} from "../../../chunk-7VKKHVZC.js";
|
|
4
|
+
import {
|
|
3
5
|
DirectionRightIcon_default,
|
|
4
|
-
Link16Icon_default
|
|
5
|
-
|
|
6
|
-
} from "../../chunk-BTKC2KJ2.js";
|
|
6
|
+
Link16Icon_default
|
|
7
|
+
} from "../../../chunk-BTKC2KJ2.js";
|
|
7
8
|
|
|
8
9
|
// components/src/asciidoc/index.tsx
|
|
9
10
|
import asciidoctor2 from "@asciidoctor/core";
|
|
@@ -11,48 +12,6 @@ import { Content as Content4 } from "@oxide/react-asciidoc";
|
|
|
11
12
|
|
|
12
13
|
// components/src/asciidoc/Admonition.tsx
|
|
13
14
|
import { Content, parse, Title } from "@oxide/react-asciidoc";
|
|
14
|
-
|
|
15
|
-
// components/src/utils.ts
|
|
16
|
-
import cn from "classnames";
|
|
17
|
-
import { createElement } from "react";
|
|
18
|
-
var titleCase = (text) => {
|
|
19
|
-
return text.replace(
|
|
20
|
-
/\w\S*/g,
|
|
21
|
-
(text2) => text2.charAt(0).toUpperCase() + text2.substring(1).toLowerCase()
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
var make = (tag) => (
|
|
25
|
-
// only one argument here means string interpolations are not allowed
|
|
26
|
-
(strings) => {
|
|
27
|
-
const Comp = ({ className, children, ...rest }) => createElement(tag, { className: cn(strings[0], className), ...rest }, children);
|
|
28
|
-
Comp.displayName = `classed.${tag}`;
|
|
29
|
-
return Comp;
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
var classed = {
|
|
33
|
-
button: make("button"),
|
|
34
|
-
div: make("div"),
|
|
35
|
-
h1: make("h1"),
|
|
36
|
-
h2: make("h2"),
|
|
37
|
-
h3: make("h3"),
|
|
38
|
-
h4: make("h4"),
|
|
39
|
-
hr: make("hr"),
|
|
40
|
-
header: make("header"),
|
|
41
|
-
input: make("input"),
|
|
42
|
-
label: make("label"),
|
|
43
|
-
li: make("li"),
|
|
44
|
-
main: make("main"),
|
|
45
|
-
ol: make("ol"),
|
|
46
|
-
p: make("p"),
|
|
47
|
-
span: make("span"),
|
|
48
|
-
table: make("table"),
|
|
49
|
-
tbody: make("tbody"),
|
|
50
|
-
td: make("td"),
|
|
51
|
-
th: make("th"),
|
|
52
|
-
tr: make("tr")
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
// components/src/asciidoc/Admonition.tsx
|
|
56
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
57
16
|
var Admonition = ({ node }) => {
|
|
58
17
|
const attrs2 = node.attributes;
|
|
@@ -119,8 +78,8 @@ var Admonition_default = Admonition;
|
|
|
119
78
|
|
|
120
79
|
// components/src/asciidoc/Section.tsx
|
|
121
80
|
import { Content as Content2, parse as parse2 } from "@oxide/react-asciidoc";
|
|
122
|
-
import
|
|
123
|
-
import { createElement
|
|
81
|
+
import cn from "classnames";
|
|
82
|
+
import { createElement } from "react";
|
|
124
83
|
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
125
84
|
var stripAnchors = (str) => str.replace(/<a[^>]*>(.*?)<\/a>/gi, "$1");
|
|
126
85
|
var Section = ({ node }) => {
|
|
@@ -137,12 +96,12 @@ var Section = ({ node }) => {
|
|
|
137
96
|
] });
|
|
138
97
|
if (level === 0) {
|
|
139
98
|
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
140
|
-
/* @__PURE__ */ jsx2("h1", { className:
|
|
99
|
+
/* @__PURE__ */ jsx2("h1", { className: cn("sect0", node.role), "data-sectnum": sectNum, children: title }),
|
|
141
100
|
/* @__PURE__ */ jsx2(Content2, { blocks: node.blocks })
|
|
142
101
|
] });
|
|
143
102
|
} else {
|
|
144
|
-
return /* @__PURE__ */ jsxs2("div", { className:
|
|
145
|
-
|
|
103
|
+
return /* @__PURE__ */ jsxs2("div", { className: cn(`sect${level}`, node.role), children: [
|
|
104
|
+
createElement(`h${level + 1}`, { "data-sectnum": sectNum }, title),
|
|
146
105
|
/* @__PURE__ */ jsx2("div", { className: "sectionbody", children: /* @__PURE__ */ jsx2(Content2, { blocks: node.blocks }) })
|
|
147
106
|
] });
|
|
148
107
|
}
|
|
@@ -158,7 +117,7 @@ var Table_default = Table;
|
|
|
158
117
|
// components/src/asciidoc/TableOfContents.tsx
|
|
159
118
|
import { parse as parse3 } from "@oxide/react-asciidoc";
|
|
160
119
|
import * as Accordion from "@radix-ui/react-accordion";
|
|
161
|
-
import
|
|
120
|
+
import cn2 from "classnames";
|
|
162
121
|
import { Fragment as Fragment2, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
163
122
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
164
123
|
function useIntersectionObserver(elements, callback, options) {
|
|
@@ -322,12 +281,12 @@ var DesktopOutline = ({
|
|
|
322
281
|
"li",
|
|
323
282
|
{
|
|
324
283
|
"data-level": item.level,
|
|
325
|
-
className:
|
|
284
|
+
className: cn2("text-sans-sm mb-0 list-none", item.level > 2 && "hidden"),
|
|
326
285
|
children: /* @__PURE__ */ jsx4(
|
|
327
286
|
"a",
|
|
328
287
|
{
|
|
329
288
|
href: `#${item.id}`,
|
|
330
|
-
className:
|
|
289
|
+
className: cn2(
|
|
331
290
|
"block border-l py-[4px] pr-4",
|
|
332
291
|
activeItem === item.id ? "active text-accent-secondary border-accent-secondary hover:text-accent" : "text-tertiary border-secondary hover:text-secondary"
|
|
333
292
|
),
|
|
@@ -343,7 +302,7 @@ var DesktopOutline = ({
|
|
|
343
302
|
] }, item.id));
|
|
344
303
|
};
|
|
345
304
|
if (toc && toc.length > 0) {
|
|
346
|
-
return /* @__PURE__ */ jsx4("ul", { className:
|
|
305
|
+
return /* @__PURE__ */ jsx4("ul", { className: cn2("toc w-(--toc-width)", className), children: renderToc(toc) });
|
|
347
306
|
}
|
|
348
307
|
return null;
|
|
349
308
|
};
|
|
@@ -359,13 +318,13 @@ var SmallScreenOutline = ({
|
|
|
359
318
|
"li",
|
|
360
319
|
{
|
|
361
320
|
"data-level": item.level,
|
|
362
|
-
className:
|
|
321
|
+
className: cn2("text-sans-sm list-none", item.level > 2 && "hidden"),
|
|
363
322
|
children: /* @__PURE__ */ jsx4(
|
|
364
323
|
"a",
|
|
365
324
|
{
|
|
366
325
|
href: `#${item.id}`,
|
|
367
326
|
onClick: () => setValue(""),
|
|
368
|
-
className:
|
|
327
|
+
className: cn2(
|
|
369
328
|
"block border-l py-[4px]",
|
|
370
329
|
activeItem === item.id ? "active text-accent-secondary border-accent-secondary hover:text-accent" : "text-tertiary border-secondary hover:text-secondary"
|
|
371
330
|
),
|
|
@@ -385,7 +344,7 @@ var SmallScreenOutline = ({
|
|
|
385
344
|
Accordion.Root,
|
|
386
345
|
{
|
|
387
346
|
type: "single",
|
|
388
|
-
className:
|
|
347
|
+
className: cn2(
|
|
389
348
|
"toc bg-default border-secondary sticky top-[calc(var(--header-height)-1px)] z-10 -mt-px mb-10 block w-full border-b border-t print:hidden",
|
|
390
349
|
className
|
|
391
350
|
),
|
|
@@ -2062,368 +2021,18 @@ var InlineConverter = class {
|
|
|
2062
2021
|
return this.baseConverter.convert(node, transform);
|
|
2063
2022
|
}
|
|
2064
2023
|
};
|
|
2065
|
-
|
|
2066
|
-
// components/src/ui/badge/Badge.tsx
|
|
2067
|
-
import cn4 from "classnames";
|
|
2068
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
2069
|
-
var badgeColors = {
|
|
2070
|
-
default: {
|
|
2071
|
-
default: "bg-accent-secondary text-accent ring-accent/15",
|
|
2072
|
-
destructive: "bg-destructive-secondary text-destructive ring-destructive/15",
|
|
2073
|
-
notice: "bg-notice-secondary text-notice ring-notice/15",
|
|
2074
|
-
blue: "bg-blue-200 text-blue-800 ring-blue-800/15",
|
|
2075
|
-
purple: "bg-purple-200 text-purple-800 ring-purple-800/15",
|
|
2076
|
-
neutral: "bg-secondary text-default ring-neutral-700/15"
|
|
2077
|
-
},
|
|
2078
|
-
solid: {
|
|
2079
|
-
default: "bg-accent text-inverse",
|
|
2080
|
-
destructive: "bg-destructive text-inverse",
|
|
2081
|
-
notice: "bg-notice text-inverse",
|
|
2082
|
-
neutral: "bg-inverse-tertiary text-inverse",
|
|
2083
|
-
purple: "bg-purple-700 text-inverse",
|
|
2084
|
-
blue: "bg-info text-inverse"
|
|
2085
|
-
}
|
|
2086
|
-
};
|
|
2087
|
-
var Badge = ({
|
|
2088
|
-
className,
|
|
2089
|
-
children,
|
|
2090
|
-
color = "default",
|
|
2091
|
-
variant = "default"
|
|
2092
|
-
}) => {
|
|
2093
|
-
return /* @__PURE__ */ jsx6(
|
|
2094
|
-
"span",
|
|
2095
|
-
{
|
|
2096
|
-
className: cn4(
|
|
2097
|
-
"ox-badge ring ring-inset",
|
|
2098
|
-
`variant-${variant}`,
|
|
2099
|
-
"text-mono-sm inline-flex h-4 items-center whitespace-nowrap rounded-sm px-[3px] py-[1px] uppercase",
|
|
2100
|
-
badgeColors[variant][color],
|
|
2101
|
-
className
|
|
2102
|
-
),
|
|
2103
|
-
children: /* @__PURE__ */ jsx6("span", { children })
|
|
2104
|
-
}
|
|
2105
|
-
);
|
|
2106
|
-
};
|
|
2107
|
-
|
|
2108
|
-
// components/src/ui/button/Button.tsx
|
|
2109
|
-
import cn5 from "classnames";
|
|
2110
|
-
import { forwardRef } from "react";
|
|
2111
|
-
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2112
|
-
var buttonSizes = ["sm", "icon", "base"];
|
|
2113
|
-
var variants = ["primary", "secondary", "ghost", "danger"];
|
|
2114
|
-
var sizeStyle = {
|
|
2115
|
-
sm: "h-8 px-3 text-mono-sm svg:w-4",
|
|
2116
|
-
// meant for buttons that only contain a single icon
|
|
2117
|
-
icon: "h-8 w-8 text-mono-sm svg:w-4",
|
|
2118
|
-
base: "h-10 px-4 text-mono-sm svg:w-5"
|
|
2119
|
-
};
|
|
2120
|
-
var buttonStyle = ({
|
|
2121
|
-
size: size2 = "base",
|
|
2122
|
-
variant = "primary"
|
|
2123
|
-
} = {}) => {
|
|
2124
|
-
return cn5(
|
|
2125
|
-
"ox-button inline-flex items-center justify-center rounded align-top elevation-1 disabled:cursor-not-allowed",
|
|
2126
|
-
`btn-${variant}`,
|
|
2127
|
-
sizeStyle[size2],
|
|
2128
|
-
variant === "danger" ? "focus:outline-destructive-secondary" : "focus:outline-accent-secondary"
|
|
2129
|
-
);
|
|
2130
|
-
};
|
|
2131
|
-
var noop = (e) => {
|
|
2132
|
-
e.stopPropagation();
|
|
2133
|
-
e.preventDefault();
|
|
2134
|
-
};
|
|
2135
|
-
var Button = forwardRef(
|
|
2136
|
-
({
|
|
2137
|
-
type = "button",
|
|
2138
|
-
children,
|
|
2139
|
-
size: size2,
|
|
2140
|
-
variant,
|
|
2141
|
-
className,
|
|
2142
|
-
loading,
|
|
2143
|
-
innerClassName,
|
|
2144
|
-
disabled,
|
|
2145
|
-
onClick,
|
|
2146
|
-
// needs to be a spread because we sometimes get passed arbitrary <button>
|
|
2147
|
-
// props by the parent
|
|
2148
|
-
...rest
|
|
2149
|
-
}, ref) => {
|
|
2150
|
-
const isDisabled = disabled || loading;
|
|
2151
|
-
return /* @__PURE__ */ jsxs4(
|
|
2152
|
-
"button",
|
|
2153
|
-
{
|
|
2154
|
-
className: cn5(buttonStyle({ size: size2, variant }), className, {
|
|
2155
|
-
"visually-disabled": isDisabled
|
|
2156
|
-
}),
|
|
2157
|
-
ref,
|
|
2158
|
-
type,
|
|
2159
|
-
onMouseDown: isDisabled ? noop : void 0,
|
|
2160
|
-
onClick: isDisabled ? noop : onClick,
|
|
2161
|
-
"aria-disabled": isDisabled,
|
|
2162
|
-
...rest,
|
|
2163
|
-
children: [
|
|
2164
|
-
loading && /* @__PURE__ */ jsx7(Spinner, { className: "absolute", variant }),
|
|
2165
|
-
/* @__PURE__ */ jsx7("span", { className: cn5("flex items-center", innerClassName, { invisible: loading }), children })
|
|
2166
|
-
]
|
|
2167
|
-
}
|
|
2168
|
-
);
|
|
2169
|
-
}
|
|
2170
|
-
);
|
|
2171
|
-
|
|
2172
|
-
// components/src/ui/spinner/Spinner.tsx
|
|
2173
|
-
import cn6 from "classnames";
|
|
2174
|
-
import { useEffect as useEffect3, useRef as useRef2, useState as useState2 } from "react";
|
|
2175
|
-
import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2176
|
-
var spinnerSizes = ["base", "lg"];
|
|
2177
|
-
var spinnerVariants = ["primary", "secondary", "ghost", "danger"];
|
|
2178
|
-
var Spinner = ({
|
|
2179
|
-
className,
|
|
2180
|
-
size: size2 = "base",
|
|
2181
|
-
variant = "primary"
|
|
2182
|
-
}) => {
|
|
2183
|
-
const frameSize = size2 === "lg" ? 36 : 12;
|
|
2184
|
-
const center = size2 === "lg" ? 18 : 6;
|
|
2185
|
-
const radius = size2 === "lg" ? 16 : 5;
|
|
2186
|
-
const strokeWidth = size2 === "lg" ? 3 : 2;
|
|
2187
|
-
return /* @__PURE__ */ jsxs5(
|
|
2188
|
-
"svg",
|
|
2189
|
-
{
|
|
2190
|
-
width: frameSize,
|
|
2191
|
-
height: frameSize,
|
|
2192
|
-
viewBox: `0 0 ${frameSize + " " + frameSize}`,
|
|
2193
|
-
fill: "none",
|
|
2194
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
2195
|
-
"aria-labelledby": "Spinner",
|
|
2196
|
-
className: cn6("spinner", `spinner-${variant}`, `spinner-${size2}`, className),
|
|
2197
|
-
children: [
|
|
2198
|
-
/* @__PURE__ */ jsx8(
|
|
2199
|
-
"circle",
|
|
2200
|
-
{
|
|
2201
|
-
fill: "none",
|
|
2202
|
-
className: "bg",
|
|
2203
|
-
strokeWidth,
|
|
2204
|
-
strokeLinecap: "round",
|
|
2205
|
-
cx: center,
|
|
2206
|
-
cy: center,
|
|
2207
|
-
r: radius,
|
|
2208
|
-
strokeOpacity: 0.2
|
|
2209
|
-
}
|
|
2210
|
-
),
|
|
2211
|
-
/* @__PURE__ */ jsx8(
|
|
2212
|
-
"circle",
|
|
2213
|
-
{
|
|
2214
|
-
className: "path",
|
|
2215
|
-
fill: "none",
|
|
2216
|
-
stroke: "currentColor",
|
|
2217
|
-
strokeWidth,
|
|
2218
|
-
strokeLinecap: "round",
|
|
2219
|
-
cx: center,
|
|
2220
|
-
cy: center,
|
|
2221
|
-
r: radius
|
|
2222
|
-
}
|
|
2223
|
-
)
|
|
2224
|
-
]
|
|
2225
|
-
}
|
|
2226
|
-
);
|
|
2227
|
-
};
|
|
2228
|
-
var SpinnerLoader = ({ isLoading, children = null, minTime = 500 }) => {
|
|
2229
|
-
const [isVisible, setIsVisible] = useState2(isLoading);
|
|
2230
|
-
const hideTimeout = useRef2(null);
|
|
2231
|
-
const loadingStartTime = useRef2(0);
|
|
2232
|
-
useEffect3(() => {
|
|
2233
|
-
if (isLoading) {
|
|
2234
|
-
setIsVisible(true);
|
|
2235
|
-
loadingStartTime.current = Date.now();
|
|
2236
|
-
} else {
|
|
2237
|
-
if (hideTimeout.current) clearTimeout(hideTimeout.current);
|
|
2238
|
-
const elapsedTime = Date.now() - loadingStartTime.current;
|
|
2239
|
-
const remainingTime = Math.max(0, minTime - elapsedTime);
|
|
2240
|
-
if (remainingTime === 0) {
|
|
2241
|
-
setIsVisible(false);
|
|
2242
|
-
} else {
|
|
2243
|
-
hideTimeout.current = setTimeout(() => setIsVisible(false), remainingTime);
|
|
2244
|
-
}
|
|
2245
|
-
}
|
|
2246
|
-
return () => {
|
|
2247
|
-
if (hideTimeout.current) clearTimeout(hideTimeout.current);
|
|
2248
|
-
};
|
|
2249
|
-
}, [isLoading, minTime]);
|
|
2250
|
-
return isVisible ? /* @__PURE__ */ jsx8(Spinner, {}) : /* @__PURE__ */ jsx8(Fragment3, { children });
|
|
2251
|
-
};
|
|
2252
|
-
|
|
2253
|
-
// components/src/ui/tabs/Tabs.tsx
|
|
2254
|
-
import { Content as Content5, List, Root as Root2, Trigger as Trigger2 } from "@radix-ui/react-tabs";
|
|
2255
|
-
import cn7 from "classnames";
|
|
2256
|
-
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
2257
|
-
var Tabs = {
|
|
2258
|
-
Root: ({ className, ...props }) => /* @__PURE__ */ jsx9(Root2, { ...props, className: cn7("ox-tabs", className) }),
|
|
2259
|
-
Trigger: ({ children, className, ...props }) => /* @__PURE__ */ jsx9(Trigger2, { ...props, className: cn7("ox-tab", className), children: /* @__PURE__ */ jsx9("div", { children }) }),
|
|
2260
|
-
List: ({ className, ...props }) => /* @__PURE__ */ jsx9(List, { ...props, className: cn7("ox-tabs-list", className) }),
|
|
2261
|
-
Content: ({ className, ...props }) => /* @__PURE__ */ jsx9(Content5, { ...props, className: cn7("ox-tabs-panel", className) })
|
|
2262
|
-
};
|
|
2263
|
-
|
|
2264
|
-
// components/src/ui/checkbox/Checkbox.tsx
|
|
2265
|
-
import cn8 from "classnames";
|
|
2266
|
-
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2267
|
-
var Check = () => /* @__PURE__ */ jsx10(Checkmark12Icon_default, { className: "text-accent pointer-events-none absolute left-0.5 top-0.5 h-3 w-3 fill-current" });
|
|
2268
|
-
var Indeterminate = classed.div`absolute w-2 h-0.5 left-1 top-[7px] bg-accent pointer-events-none`;
|
|
2269
|
-
var inputStyle = `
|
|
2270
|
-
appearance-none border border-default bg-default h-4 w-4 rounded-sm absolute left-0 outline-none
|
|
2271
|
-
disabled:cursor-not-allowed
|
|
2272
|
-
hover:border-hover hover:cursor-pointer
|
|
2273
|
-
checked:bg-accent-secondary checked:border-accent-secondary checked:hover:border-accent
|
|
2274
|
-
indeterminate:bg-accent-secondary indeterminate:border-accent hover:indeterminate:bg-accent-secondary-hover
|
|
2275
|
-
`;
|
|
2276
|
-
var Checkbox = ({
|
|
2277
|
-
indeterminate,
|
|
2278
|
-
children,
|
|
2279
|
-
className,
|
|
2280
|
-
...inputProps
|
|
2281
|
-
}) => /* @__PURE__ */ jsxs6("label", { className: "inline-flex items-center", children: [
|
|
2282
|
-
/* @__PURE__ */ jsxs6("span", { className: "relative h-4 w-4", children: [
|
|
2283
|
-
/* @__PURE__ */ jsx10(
|
|
2284
|
-
"input",
|
|
2285
|
-
{
|
|
2286
|
-
className: cn8(inputStyle, className),
|
|
2287
|
-
type: "checkbox",
|
|
2288
|
-
ref: (el) => {
|
|
2289
|
-
if (el) el.indeterminate = !!indeterminate;
|
|
2290
|
-
},
|
|
2291
|
-
...inputProps
|
|
2292
|
-
}
|
|
2293
|
-
),
|
|
2294
|
-
inputProps.checked && !indeterminate && /* @__PURE__ */ jsx10(Check, {}),
|
|
2295
|
-
indeterminate && /* @__PURE__ */ jsx10(Indeterminate, {})
|
|
2296
|
-
] }),
|
|
2297
|
-
children && /* @__PURE__ */ jsx10("span", { className: "text-sans-md text-secondary ml-2.5", children })
|
|
2298
|
-
] });
|
|
2299
|
-
|
|
2300
|
-
// components/src/ui/listbox/Listbox.tsx
|
|
2301
|
-
import { flip, FloatingPortal, offset, size, useFloating } from "@floating-ui/react";
|
|
2302
|
-
import { Listbox as Select } from "@headlessui/react";
|
|
2303
|
-
import cn9 from "classnames";
|
|
2304
|
-
import { Fragment as Fragment4, jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2305
|
-
var Listbox = ({
|
|
2306
|
-
name,
|
|
2307
|
-
selected,
|
|
2308
|
-
items,
|
|
2309
|
-
placeholder = "Select an option",
|
|
2310
|
-
className,
|
|
2311
|
-
onChange,
|
|
2312
|
-
hasError = false,
|
|
2313
|
-
disabled,
|
|
2314
|
-
isLoading = false,
|
|
2315
|
-
...props
|
|
2316
|
-
}) => {
|
|
2317
|
-
const { refs, floatingStyles } = useFloating({
|
|
2318
|
-
middleware: [
|
|
2319
|
-
offset(12),
|
|
2320
|
-
flip(),
|
|
2321
|
-
size({
|
|
2322
|
-
apply({ rects, elements }) {
|
|
2323
|
-
Object.assign(elements.floating.style, {
|
|
2324
|
-
width: `${rects.reference.width}px`
|
|
2325
|
-
});
|
|
2326
|
-
}
|
|
2327
|
-
})
|
|
2328
|
-
]
|
|
2329
|
-
});
|
|
2330
|
-
const selectedItem = selected && items.find((i) => i.value === selected);
|
|
2331
|
-
const noItems = !isLoading && items.length === 0;
|
|
2332
|
-
const isDisabled = disabled || noItems;
|
|
2333
|
-
return /* @__PURE__ */ jsx11("div", { className: cn9("relative", className), children: /* @__PURE__ */ jsx11(
|
|
2334
|
-
Select,
|
|
2335
|
-
{
|
|
2336
|
-
value: selected,
|
|
2337
|
-
onChange: (val) => val !== null && onChange(val),
|
|
2338
|
-
disabled: isDisabled || isLoading,
|
|
2339
|
-
children: ({ open }) => /* @__PURE__ */ jsxs7(Fragment4, { children: [
|
|
2340
|
-
/* @__PURE__ */ jsxs7(
|
|
2341
|
-
Select.Button,
|
|
2342
|
-
{
|
|
2343
|
-
name,
|
|
2344
|
-
ref: refs.setReference,
|
|
2345
|
-
className: cn9(
|
|
2346
|
-
`text-sans-md flex h-10 w-full items-center justify-between rounded border`,
|
|
2347
|
-
hasError ? "focus-error border-error-secondary hover:border-error" : "border-default hover:border-hover",
|
|
2348
|
-
open && "ring-accent-secondary ring-2",
|
|
2349
|
-
open && hasError && "ring-error-secondary",
|
|
2350
|
-
isDisabled ? "text-disabled bg-disabled !border-default cursor-not-allowed" : "bg-default",
|
|
2351
|
-
isDisabled && hasError && "!border-error-secondary"
|
|
2352
|
-
),
|
|
2353
|
-
...props,
|
|
2354
|
-
children: [
|
|
2355
|
-
/* @__PURE__ */ jsx11("div", { className: "w-full px-3 text-left", children: selectedItem ? (
|
|
2356
|
-
// labelString is one line, which is what we need when label is a ReactNode
|
|
2357
|
-
selectedItem.labelString || selectedItem.label
|
|
2358
|
-
) : /* @__PURE__ */ jsx11("span", { className: "text-quaternary", children: noItems ? "No items" : placeholder }) }),
|
|
2359
|
-
!isDisabled && /* @__PURE__ */ jsx11(SpinnerLoader, { isLoading }),
|
|
2360
|
-
/* @__PURE__ */ jsx11(
|
|
2361
|
-
"div",
|
|
2362
|
-
{
|
|
2363
|
-
className: "border-secondary ml-3 flex h-[calc(100%-12px)] items-center border-l px-3",
|
|
2364
|
-
"aria-hidden": true,
|
|
2365
|
-
children: /* @__PURE__ */ jsx11(SelectArrows6Icon_default, { className: "text-tertiary h-[14px] w-2" })
|
|
2366
|
-
}
|
|
2367
|
-
)
|
|
2368
|
-
]
|
|
2369
|
-
}
|
|
2370
|
-
),
|
|
2371
|
-
/* @__PURE__ */ jsx11(FloatingPortal, { children: /* @__PURE__ */ jsx11(
|
|
2372
|
-
Select.Options,
|
|
2373
|
-
{
|
|
2374
|
-
ref: refs.setFloating,
|
|
2375
|
-
style: floatingStyles,
|
|
2376
|
-
className: "ox-menu pointer-events-auto z-50 overflow-y-auto !outline-none",
|
|
2377
|
-
children: items.map((item) => /* @__PURE__ */ jsx11(
|
|
2378
|
-
Select.Option,
|
|
2379
|
-
{
|
|
2380
|
-
value: item.value,
|
|
2381
|
-
className: "border-secondary relative border-b last:border-0",
|
|
2382
|
-
children: ({ active, selected: selected2 }) => /* @__PURE__ */ jsx11(
|
|
2383
|
-
"div",
|
|
2384
|
-
{
|
|
2385
|
-
className: cn9(
|
|
2386
|
-
"ox-menu-item text-secondary",
|
|
2387
|
-
selected2 && "is-selected",
|
|
2388
|
-
active && "is-highlighted"
|
|
2389
|
-
),
|
|
2390
|
-
children: item.label
|
|
2391
|
-
}
|
|
2392
|
-
)
|
|
2393
|
-
},
|
|
2394
|
-
item.value
|
|
2395
|
-
))
|
|
2396
|
-
}
|
|
2397
|
-
) })
|
|
2398
|
-
] })
|
|
2399
|
-
}
|
|
2400
|
-
) });
|
|
2401
|
-
};
|
|
2402
2024
|
export {
|
|
2403
2025
|
AsciiDocBlocks,
|
|
2404
|
-
Badge,
|
|
2405
|
-
Button,
|
|
2406
|
-
Checkbox,
|
|
2407
2026
|
DesktopOutline,
|
|
2408
2027
|
InlineConverter,
|
|
2409
|
-
Listbox,
|
|
2410
2028
|
SmallScreenOutline,
|
|
2411
|
-
Spinner,
|
|
2412
|
-
SpinnerLoader,
|
|
2413
|
-
Tabs,
|
|
2414
2029
|
attrs,
|
|
2415
|
-
badgeColors,
|
|
2416
|
-
buttonSizes,
|
|
2417
|
-
buttonStyle,
|
|
2418
2030
|
handleDocument,
|
|
2419
2031
|
highlight,
|
|
2420
2032
|
loadAsciidoctor,
|
|
2421
2033
|
renderWithBreaks,
|
|
2422
|
-
spinnerSizes,
|
|
2423
|
-
spinnerVariants,
|
|
2424
2034
|
useActiveSectionTracking,
|
|
2425
2035
|
useDelegatedReactRouterLinks,
|
|
2426
|
-
useIntersectionObserver
|
|
2427
|
-
variants
|
|
2036
|
+
useIntersectionObserver
|
|
2428
2037
|
};
|
|
2429
2038
|
//# sourceMappingURL=index.js.map
|