@stainless-api/ui-primitives 0.1.0-beta.18 → 0.1.0-beta.19
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/.turbo/turbo-build.log +32 -2
- package/CHANGELOG.md +6 -0
- package/dist/Accordion-CJL9SWwS.d.ts +26 -0
- package/dist/Accordion-DLQE3Td6.js +31 -0
- package/dist/Button-DBhd6kU7.js +51 -0
- package/dist/Button-DwndlytB.d.ts +38 -0
- package/dist/Callout-CMz3Yl_5.d.ts +18 -0
- package/dist/Callout-UZQRuCQ5.js +28 -0
- package/dist/DropdownButton-DoYDi8tB.js +82 -0
- package/dist/DropdownButton-zcvep_xH.d.ts +50 -0
- package/dist/components/Accordion.d.ts +2 -0
- package/dist/components/Accordion.js +3 -0
- package/dist/components/Button.d.ts +2 -0
- package/dist/components/Button.js +3 -0
- package/dist/components/Callout.d.ts +2 -0
- package/dist/components/Callout.js +3 -0
- package/dist/components/DropdownButton.d.ts +2 -0
- package/dist/components/DropdownButton.js +3 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -0
- package/dist/scripts/index.d.ts +12 -0
- package/dist/scripts/index.js +33 -0
- package/dist/styles.css +1181 -0
- package/dist/styles.js +1 -0
- package/package.json +1 -1
- package/src/components/callout.css +23 -0
- package/src/components/dropdown-button.css +1 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @stainless-api/ui-primitives@0.1.0-beta.
|
|
4
|
-
>
|
|
3
|
+
> @stainless-api/ui-primitives@0.1.0-beta.17 build /Users/maxfreundlich/code/work/stl-api-docs/packages/ui-primitives
|
|
4
|
+
> tsdown
|
|
5
5
|
|
|
6
|
+
[34mℹ[39m tsdown [2mv0.15.12[22m powered by rolldown [2mv1.0.0-beta.45[22m
|
|
7
|
+
[34mℹ[39m Using tsdown config: [4m/Users/maxfreundlich/code/work/stl-api-docs/packages/ui-primitives/tsdown.config.ts[24m
|
|
8
|
+
[34mℹ[39m entry: [34msrc/index.ts, src/styles.css, src/components/Accordion.tsx, src/components/Button.tsx, src/components/Callout.tsx, src/components/DropdownButton.tsx, src/scripts/index.ts[39m
|
|
9
|
+
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
10
|
+
[34mℹ[39m Build start
|
|
11
|
+
[34mℹ[39m Cleaning 24 files
|
|
12
|
+
[34mℹ[39m [2mdist/[22m[1mscripts/index.js[22m [2m 1.21 kB[22m [2m│ gzip: 0.48 kB[22m
|
|
13
|
+
[34mℹ[39m [2mdist/[22m[1mindex.js[22m [2m 0.29 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
14
|
+
[34mℹ[39m [2mdist/[22m[1mcomponents/DropdownButton.js[22m [2m 0.10 kB[22m [2m│ gzip: 0.09 kB[22m
|
|
15
|
+
[34mℹ[39m [2mdist/[22m[1mcomponents/Accordion.js[22m [2m 0.08 kB[22m [2m│ gzip: 0.08 kB[22m
|
|
16
|
+
[34mℹ[39m [2mdist/[22m[1mcomponents/Callout.js[22m [2m 0.07 kB[22m [2m│ gzip: 0.08 kB[22m
|
|
17
|
+
[34mℹ[39m [2mdist/[22m[1mcomponents/Button.js[22m [2m 0.07 kB[22m [2m│ gzip: 0.08 kB[22m
|
|
18
|
+
[34mℹ[39m [2mdist/[22m[1mstyles.js[22m [2m 0.01 kB[22m [2m│ gzip: 0.03 kB[22m
|
|
19
|
+
[34mℹ[39m [2mdist/[22mstyles.css [2m40.38 kB[22m [2m│ gzip: 6.94 kB[22m
|
|
20
|
+
[34mℹ[39m [2mdist/[22mDropdownButton-DoYDi8tB.js [2m 2.69 kB[22m [2m│ gzip: 0.70 kB[22m
|
|
21
|
+
[34mℹ[39m [2mdist/[22mButton-DBhd6kU7.js [2m 1.51 kB[22m [2m│ gzip: 0.55 kB[22m
|
|
22
|
+
[34mℹ[39m [2mdist/[22mCallout-UZQRuCQ5.js [2m 0.82 kB[22m [2m│ gzip: 0.44 kB[22m
|
|
23
|
+
[34mℹ[39m [2mdist/[22mAccordion-DLQE3Td6.js [2m 0.80 kB[22m [2m│ gzip: 0.30 kB[22m
|
|
24
|
+
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.ts[22m[39m [2m 0.46 kB[22m [2m│ gzip: 0.20 kB[22m
|
|
25
|
+
[34mℹ[39m [2mdist/[22m[32m[1mscripts/index.d.ts[22m[39m [2m 0.30 kB[22m [2m│ gzip: 0.19 kB[22m
|
|
26
|
+
[34mℹ[39m [2mdist/[22m[32m[1mcomponents/Callout.d.ts[22m[39m [2m 0.14 kB[22m [2m│ gzip: 0.11 kB[22m
|
|
27
|
+
[34mℹ[39m [2mdist/[22m[32m[1mcomponents/Button.d.ts[22m[39m [2m 0.14 kB[22m [2m│ gzip: 0.10 kB[22m
|
|
28
|
+
[34mℹ[39m [2mdist/[22m[32m[1mcomponents/Accordion.d.ts[22m[39m [2m 0.12 kB[22m [2m│ gzip: 0.09 kB[22m
|
|
29
|
+
[34mℹ[39m [2mdist/[22m[32m[1mcomponents/DropdownButton.d.ts[22m[39m [2m 0.10 kB[22m [2m│ gzip: 0.08 kB[22m
|
|
30
|
+
[34mℹ[39m [2mdist/[22m[32mDropdownButton-zcvep_xH.d.ts[39m [2m 1.38 kB[22m [2m│ gzip: 0.40 kB[22m
|
|
31
|
+
[34mℹ[39m [2mdist/[22m[32mButton-DwndlytB.d.ts[39m [2m 1.27 kB[22m [2m│ gzip: 0.52 kB[22m
|
|
32
|
+
[34mℹ[39m [2mdist/[22m[32mAccordion-CJL9SWwS.d.ts[39m [2m 0.74 kB[22m [2m│ gzip: 0.32 kB[22m
|
|
33
|
+
[34mℹ[39m [2mdist/[22m[32mCallout-CMz3Yl_5.d.ts[39m [2m 0.57 kB[22m [2m│ gzip: 0.33 kB[22m
|
|
34
|
+
[34mℹ[39m 22 files, total: 53.24 kB
|
|
35
|
+
[32m✔[39m Build complete in [32m761ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as react_jsx_runtime3 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/components/Accordion.d.ts
|
|
5
|
+
type AccordionProps = React.ComponentProps<'details'>;
|
|
6
|
+
declare function Accordion({
|
|
7
|
+
className,
|
|
8
|
+
children,
|
|
9
|
+
...props
|
|
10
|
+
}: AccordionProps): react_jsx_runtime3.JSX.Element;
|
|
11
|
+
declare namespace Accordion {
|
|
12
|
+
var Summary: typeof AccordionSummary;
|
|
13
|
+
var Group: typeof AccordionGroup;
|
|
14
|
+
}
|
|
15
|
+
declare function AccordionSummary({
|
|
16
|
+
children,
|
|
17
|
+
className,
|
|
18
|
+
...props
|
|
19
|
+
}: React.ComponentProps<'summary'>): react_jsx_runtime3.JSX.Element;
|
|
20
|
+
declare function AccordionGroup({
|
|
21
|
+
className,
|
|
22
|
+
children,
|
|
23
|
+
...props
|
|
24
|
+
}: React.ComponentProps<'div'>): react_jsx_runtime3.JSX.Element;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { AccordionProps as n, Accordion as t };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/components/Accordion.tsx
|
|
6
|
+
function Accordion({ className, children,...props }) {
|
|
7
|
+
return /* @__PURE__ */ jsx("details", {
|
|
8
|
+
className: clsx("stl-ui-accordion", className),
|
|
9
|
+
...props,
|
|
10
|
+
children
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function AccordionSummary({ children, className,...props }) {
|
|
14
|
+
return /* @__PURE__ */ jsx("summary", {
|
|
15
|
+
className: clsx("stl-ui-accordion__summary", className),
|
|
16
|
+
...props,
|
|
17
|
+
children
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
Accordion.Summary = AccordionSummary;
|
|
21
|
+
function AccordionGroup({ className, children,...props }) {
|
|
22
|
+
return /* @__PURE__ */ jsx("div", {
|
|
23
|
+
className: clsx("stl-ui-accordion-group", className),
|
|
24
|
+
...props,
|
|
25
|
+
children
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
Accordion.Group = AccordionGroup;
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { Accordion as t };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/components/Button.tsx
|
|
6
|
+
function Button(props) {
|
|
7
|
+
const { variant, children } = props;
|
|
8
|
+
const classes = clsx("stl-ui-button", {
|
|
9
|
+
"stl-ui-button--outline": variant === "outline",
|
|
10
|
+
"stl-ui-button--ghost": variant === "ghost",
|
|
11
|
+
"stl-ui-button--accent": variant === "accent",
|
|
12
|
+
"stl-ui-button--accent-muted": variant === "accent-muted",
|
|
13
|
+
"stl-ui-button--muted": variant === "muted",
|
|
14
|
+
"stl-ui-button--success": variant === "success",
|
|
15
|
+
"stl-ui-button--destructive": variant === "destructive"
|
|
16
|
+
}, {
|
|
17
|
+
"stl-ui-button--size-sm": props.size === "sm",
|
|
18
|
+
"stl-ui-button--size-lg": props.size === "lg"
|
|
19
|
+
}, "not-content", "stl-ui-not-prose", props.className);
|
|
20
|
+
if ("href" in props) {
|
|
21
|
+
const { href,...rest$1 } = props;
|
|
22
|
+
return /* @__PURE__ */ jsx("a", {
|
|
23
|
+
href,
|
|
24
|
+
...rest$1,
|
|
25
|
+
className: classes,
|
|
26
|
+
children
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const { type,...rest } = props;
|
|
30
|
+
return /* @__PURE__ */ jsx("button", {
|
|
31
|
+
type: type ?? "button",
|
|
32
|
+
...rest,
|
|
33
|
+
className: classes,
|
|
34
|
+
children
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
Button.Label = function ButtonLabel({ className,...rest }) {
|
|
38
|
+
return /* @__PURE__ */ jsx("span", {
|
|
39
|
+
className: clsx("stl-ui-button-label leading-none", className),
|
|
40
|
+
...rest
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
Button.Icon = function ButtonIcon({ className, icon: Icon, size = 18 }) {
|
|
44
|
+
return /* @__PURE__ */ jsx("span", {
|
|
45
|
+
className: clsx("stl-ui-button__icon", className),
|
|
46
|
+
children: /* @__PURE__ */ jsx(Icon, { size })
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
export { Button as t };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
import { LucideIcon } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/Button.d.ts
|
|
6
|
+
type ButtonVariant = 'outline' | 'ghost' | 'accent' | 'accent-muted' | 'muted' | 'success' | 'destructive' | 'default';
|
|
7
|
+
type BaseProps = {
|
|
8
|
+
variant?: ButtonVariant;
|
|
9
|
+
className?: string;
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
size?: 'sm' | 'lg' | 'default';
|
|
12
|
+
};
|
|
13
|
+
type AnchorBranch = BaseProps & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'className' | 'children'> & {
|
|
14
|
+
href: string;
|
|
15
|
+
};
|
|
16
|
+
type ButtonBranch = BaseProps & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'className' | 'children'> & {
|
|
17
|
+
href?: never;
|
|
18
|
+
};
|
|
19
|
+
type ButtonProps = AnchorBranch | ButtonBranch;
|
|
20
|
+
declare function Button(props: ButtonProps): react_jsx_runtime0.JSX.Element;
|
|
21
|
+
declare namespace Button {
|
|
22
|
+
var Label: ({
|
|
23
|
+
className,
|
|
24
|
+
...rest
|
|
25
|
+
}: LabelProps) => react_jsx_runtime0.JSX.Element;
|
|
26
|
+
var Icon: ({
|
|
27
|
+
className,
|
|
28
|
+
icon: Icon,
|
|
29
|
+
size
|
|
30
|
+
}: IconProps) => react_jsx_runtime0.JSX.Element;
|
|
31
|
+
}
|
|
32
|
+
type LabelProps = React.HTMLAttributes<HTMLSpanElement>;
|
|
33
|
+
type IconProps = {
|
|
34
|
+
icon: LucideIcon;
|
|
35
|
+
size?: number;
|
|
36
|
+
} & React.HTMLAttributes<HTMLSpanElement>;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { ButtonProps as n, ButtonVariant as r, Button as t };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/components/Callout.d.ts
|
|
5
|
+
type CalloutVariant = 'info' | 'note' | 'tip' | 'success' | 'warning' | 'danger';
|
|
6
|
+
type CalloutProps = {
|
|
7
|
+
variant?: CalloutVariant;
|
|
8
|
+
className?: string;
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
} & Omit<React.ComponentProps<'aside'>, 'className' | 'children'>;
|
|
11
|
+
declare function Callout({
|
|
12
|
+
variant,
|
|
13
|
+
className,
|
|
14
|
+
children,
|
|
15
|
+
...props
|
|
16
|
+
}: CalloutProps): react_jsx_runtime2.JSX.Element;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { CalloutProps as n, CalloutVariant as r, Callout as t };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Check, CircleAlert, Info, Lightbulb, OctagonAlert, TriangleAlert } from "lucide-react";
|
|
5
|
+
|
|
6
|
+
//#region src/components/Callout.tsx
|
|
7
|
+
function Callout({ variant = "info", className, children,...props }) {
|
|
8
|
+
const classes = clsx("stl-ui-callout", `stl-ui-callout--${variant}`, className);
|
|
9
|
+
const Icon = {
|
|
10
|
+
info: Info,
|
|
11
|
+
note: CircleAlert,
|
|
12
|
+
tip: Lightbulb,
|
|
13
|
+
success: Check,
|
|
14
|
+
warning: TriangleAlert,
|
|
15
|
+
danger: OctagonAlert
|
|
16
|
+
}[variant];
|
|
17
|
+
return /* @__PURE__ */ jsxs("aside", {
|
|
18
|
+
className: classes,
|
|
19
|
+
...props,
|
|
20
|
+
children: [/* @__PURE__ */ jsx(Icon, { className: "stl-ui-callout__icon" }), /* @__PURE__ */ jsx("div", {
|
|
21
|
+
className: "stl-ui-callout__content",
|
|
22
|
+
children
|
|
23
|
+
})]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { Callout as t };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ChevronsUpDown, ExternalLink } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/DropdownButton.tsx
|
|
6
|
+
function PrimaryActionText({ children }) {
|
|
7
|
+
return /* @__PURE__ */ jsx("span", {
|
|
8
|
+
"data-part": "primary-action-text",
|
|
9
|
+
children
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function PrimaryAction({ className,...props }) {
|
|
13
|
+
return /* @__PURE__ */ jsx("button", {
|
|
14
|
+
"data-part": "primary-action",
|
|
15
|
+
...props,
|
|
16
|
+
className: clsx("stl-ui-dropdown-button__button stl-ui-dropdown-button--action", className)
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function Trigger({ className,...props }) {
|
|
20
|
+
return /* @__PURE__ */ jsx("button", {
|
|
21
|
+
"aria-haspopup": "listbox",
|
|
22
|
+
"aria-expanded": "false",
|
|
23
|
+
"data-part": "trigger",
|
|
24
|
+
...props,
|
|
25
|
+
className: clsx("stl-ui-dropdown-button__button stl-ui-dropdown-button__trigger", className),
|
|
26
|
+
children: /* @__PURE__ */ jsx(ChevronsUpDown, { size: 16 })
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function Menu({ className,...props }) {
|
|
30
|
+
return /* @__PURE__ */ jsx("div", {
|
|
31
|
+
"data-state": "closed",
|
|
32
|
+
"data-part": "menu",
|
|
33
|
+
...props,
|
|
34
|
+
className: clsx("stl-ui-dropdown-button__menu", className)
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function MenuItemIcon({ className,...props }) {
|
|
38
|
+
return /* @__PURE__ */ jsx("div", {
|
|
39
|
+
"data-part": "item-icon",
|
|
40
|
+
...props,
|
|
41
|
+
className: clsx("stl-ui-dropdown-button__menu-item-icon", className)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function MenuItemText({ className, subtle,...props }) {
|
|
45
|
+
return /* @__PURE__ */ jsx("span", {
|
|
46
|
+
"data-part": "item-text",
|
|
47
|
+
className: clsx(`stl-ui-dropdown-button__menu-item-text`, { "stl-ui-dropdown-button__menu-item-text--subtle": subtle }, className),
|
|
48
|
+
...props
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function MenuItem({ children, value, isExternalLink,...props }) {
|
|
52
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
53
|
+
"data-part": "item",
|
|
54
|
+
"data-value": value,
|
|
55
|
+
...props,
|
|
56
|
+
className: clsx("stl-ui-dropdown-button__menu-item", props.className),
|
|
57
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
58
|
+
className: "stl-ui-dropdown-button__menu-item-content",
|
|
59
|
+
children
|
|
60
|
+
}), isExternalLink && /* @__PURE__ */ jsx("div", {
|
|
61
|
+
className: "stl-ui-dropdown-button__menu-item-external-link-icon",
|
|
62
|
+
"data-part": "item-external-link-icon",
|
|
63
|
+
children: /* @__PURE__ */ jsx(ExternalLink, { size: 16 })
|
|
64
|
+
})]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function DropdownButton({ className,...props }) {
|
|
68
|
+
return /* @__PURE__ */ jsx("div", {
|
|
69
|
+
...props,
|
|
70
|
+
className: clsx("stl-ui-dropdown-button stl-ui-not-prose not-content", className)
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
DropdownButton.Menu = Menu;
|
|
74
|
+
DropdownButton.MenuItem = MenuItem;
|
|
75
|
+
DropdownButton.MenuItemIcon = MenuItemIcon;
|
|
76
|
+
DropdownButton.MenuItemText = MenuItemText;
|
|
77
|
+
DropdownButton.PrimaryAction = PrimaryAction;
|
|
78
|
+
DropdownButton.PrimaryActionText = PrimaryActionText;
|
|
79
|
+
DropdownButton.Trigger = Trigger;
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
export { DropdownButton as t };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
import * as react_jsx_runtime6 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/components/DropdownButton.d.ts
|
|
5
|
+
declare function DropdownButton({
|
|
6
|
+
className,
|
|
7
|
+
...props
|
|
8
|
+
}: ComponentPropsWithoutRef<'div'>): react_jsx_runtime6.JSX.Element;
|
|
9
|
+
declare namespace DropdownButton {
|
|
10
|
+
var Menu: ({
|
|
11
|
+
className,
|
|
12
|
+
...props
|
|
13
|
+
}: ComponentPropsWithoutRef<"div">) => react_jsx_runtime6.JSX.Element;
|
|
14
|
+
var MenuItem: ({
|
|
15
|
+
children,
|
|
16
|
+
value,
|
|
17
|
+
isExternalLink,
|
|
18
|
+
...props
|
|
19
|
+
}: ComponentPropsWithoutRef<"div"> & {
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
value: string;
|
|
22
|
+
isExternalLink?: boolean;
|
|
23
|
+
}) => react_jsx_runtime6.JSX.Element;
|
|
24
|
+
var MenuItemIcon: ({
|
|
25
|
+
className,
|
|
26
|
+
...props
|
|
27
|
+
}: ComponentPropsWithoutRef<"div">) => react_jsx_runtime6.JSX.Element;
|
|
28
|
+
var MenuItemText: ({
|
|
29
|
+
className,
|
|
30
|
+
subtle,
|
|
31
|
+
...props
|
|
32
|
+
}: ComponentPropsWithoutRef<"span"> & {
|
|
33
|
+
subtle?: boolean;
|
|
34
|
+
}) => react_jsx_runtime6.JSX.Element;
|
|
35
|
+
var PrimaryAction: ({
|
|
36
|
+
className,
|
|
37
|
+
...props
|
|
38
|
+
}: ComponentPropsWithoutRef<"button">) => react_jsx_runtime6.JSX.Element;
|
|
39
|
+
var PrimaryActionText: ({
|
|
40
|
+
children
|
|
41
|
+
}: {
|
|
42
|
+
children?: React.ReactNode;
|
|
43
|
+
}) => react_jsx_runtime6.JSX.Element;
|
|
44
|
+
var Trigger: ({
|
|
45
|
+
className,
|
|
46
|
+
...props
|
|
47
|
+
}: ComponentPropsWithoutRef<"button">) => react_jsx_runtime6.JSX.Element;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { DropdownButton as t };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { n as AccordionProps, t as Accordion } from "./Accordion-CJL9SWwS.js";
|
|
2
|
+
import { n as ButtonProps, r as ButtonVariant, t as Button } from "./Button-DwndlytB.js";
|
|
3
|
+
import { n as CalloutProps, r as CalloutVariant, t as Callout } from "./Callout-CMz3Yl_5.js";
|
|
4
|
+
import { t as DropdownButton } from "./DropdownButton-zcvep_xH.js";
|
|
5
|
+
export { Accordion, AccordionProps, Button, ButtonProps, ButtonVariant, Callout, CalloutProps, CalloutVariant, DropdownButton };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { t as Button } from "./Button-DBhd6kU7.js";
|
|
2
|
+
import { t as DropdownButton } from "./DropdownButton-DoYDi8tB.js";
|
|
3
|
+
import { t as Callout } from "./Callout-UZQRuCQ5.js";
|
|
4
|
+
import { t as Accordion } from "./Accordion-DLQE3Td6.js";
|
|
5
|
+
|
|
6
|
+
export { Accordion, Button, Callout, DropdownButton };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/scripts/dropdown-button.d.ts
|
|
2
|
+
declare function initDropdownButton({
|
|
3
|
+
dropdown,
|
|
4
|
+
onSelect,
|
|
5
|
+
onPrimaryAction
|
|
6
|
+
}: {
|
|
7
|
+
dropdown: Element;
|
|
8
|
+
onSelect: (value: string) => void;
|
|
9
|
+
onPrimaryAction: (primaryActionElement: Element) => void;
|
|
10
|
+
}): void;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { initDropdownButton };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/scripts/dropdown-button.ts
|
|
2
|
+
function initDropdownButton({ dropdown, onSelect, onPrimaryAction }) {
|
|
3
|
+
const trigger = dropdown.querySelector("[data-part=\"trigger\"]");
|
|
4
|
+
const menu = dropdown.querySelector("[data-part=\"menu\"]");
|
|
5
|
+
const primaryAction = dropdown.querySelector("[data-part=\"primary-action\"]");
|
|
6
|
+
if (!trigger || !menu || !primaryAction) return;
|
|
7
|
+
let isOpen = false;
|
|
8
|
+
function toggleDropdown() {
|
|
9
|
+
if (!trigger || !menu) return;
|
|
10
|
+
isOpen = !isOpen;
|
|
11
|
+
menu.dataset.state = isOpen ? "open" : "closed";
|
|
12
|
+
trigger.setAttribute("aria-expanded", String(isOpen));
|
|
13
|
+
}
|
|
14
|
+
trigger.addEventListener("click", toggleDropdown);
|
|
15
|
+
document.addEventListener("click", (event) => {
|
|
16
|
+
if (!isOpen) return;
|
|
17
|
+
if (!dropdown.contains(event.target)) toggleDropdown();
|
|
18
|
+
if (primaryAction && primaryAction.contains(event.target)) toggleDropdown();
|
|
19
|
+
});
|
|
20
|
+
dropdown.querySelectorAll("[data-part=\"item\"]").forEach((item) => {
|
|
21
|
+
item.addEventListener("click", () => {
|
|
22
|
+
const value = item.getAttribute("data-value");
|
|
23
|
+
if (value) onSelect(value);
|
|
24
|
+
toggleDropdown();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
primaryAction.addEventListener("click", () => {
|
|
28
|
+
onPrimaryAction(primaryAction);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { initDropdownButton };
|