@stainless-api/ui-primitives 0.1.0-beta.2 → 0.1.0-beta.20

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.
Files changed (51) hide show
  1. package/.turbo/turbo-build.log +35 -0
  2. package/CHANGELOG.md +112 -0
  3. package/dist/Accordion-CJL9SWwS.d.ts +26 -0
  4. package/dist/Accordion-DLQE3Td6.js +31 -0
  5. package/dist/Button-DBhd6kU7.js +51 -0
  6. package/dist/Button-DwndlytB.d.ts +38 -0
  7. package/dist/Callout-CMz3Yl_5.d.ts +18 -0
  8. package/dist/Callout-UZQRuCQ5.js +28 -0
  9. package/dist/DropdownButton-DoYDi8tB.js +82 -0
  10. package/dist/DropdownButton-zcvep_xH.d.ts +50 -0
  11. package/dist/components/Accordion.d.ts +2 -0
  12. package/dist/components/Accordion.js +3 -0
  13. package/dist/components/Button.d.ts +2 -0
  14. package/dist/components/Button.js +3 -0
  15. package/dist/components/Callout.d.ts +2 -0
  16. package/dist/components/Callout.js +3 -0
  17. package/dist/components/DropdownButton.d.ts +2 -0
  18. package/dist/components/DropdownButton.js +3 -0
  19. package/dist/index.d.ts +5 -0
  20. package/dist/index.js +6 -0
  21. package/dist/scripts/index.d.ts +12 -0
  22. package/dist/scripts/index.js +33 -0
  23. package/dist/styles.css +1181 -0
  24. package/dist/styles.js +1 -0
  25. package/package.json +9 -9
  26. package/src/components/Accordion.tsx +41 -0
  27. package/src/components/Button.tsx +1 -0
  28. package/src/components/accordion.css +145 -0
  29. package/src/components/button.css +165 -135
  30. package/src/components/callout.css +78 -57
  31. package/src/components/dropdown/Dropdown.tsx +51 -0
  32. package/src/components/dropdown/DropdownButton.tsx +54 -0
  33. package/src/components/dropdown/DropdownMenu.tsx +113 -0
  34. package/src/components/dropdown/dropdown.css +231 -0
  35. package/src/index.ts +3 -2
  36. package/src/scripts/dropdown-button.ts +20 -36
  37. package/src/scripts/dropdown.ts +193 -0
  38. package/src/scripts/index.ts +1 -0
  39. package/src/styles/layout.css +3 -1
  40. package/src/styles/scales.css +1 -1
  41. package/src/styles/starlight-compat.css +138 -107
  42. package/src/styles/swatches.css +2 -2
  43. package/src/styles/theme.css +2 -2
  44. package/src/styles/typography.css +117 -147
  45. package/src/styles.css +2 -2
  46. package/tsconfig.json +3 -7
  47. package/.env +0 -1
  48. package/src/components/DetailsGroup.tsx +0 -17
  49. package/src/components/DropdownButton.tsx +0 -98
  50. package/src/components/details.css +0 -126
  51. package/src/components/dropdown-button.css +0 -162
@@ -0,0 +1,35 @@
1
+
2
+ 
3
+ > @stainless-api/ui-primitives@0.1.0-beta.17 build /Users/maxfreundlich/code/work/stl-api-docs/packages/ui-primitives
4
+ > tsdown
5
+
6
+ ℹ tsdown v0.15.12 powered by rolldown v1.0.0-beta.45
7
+ ℹ Using tsdown config: /Users/maxfreundlich/code/work/stl-api-docs/packages/ui-primitives/tsdown.config.ts
8
+ ℹ entry: src/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
9
+ ℹ tsconfig: tsconfig.json
10
+ ℹ Build start
11
+ ℹ Cleaning 24 files
12
+ ℹ dist/scripts/index.js  1.21 kB │ gzip: 0.48 kB
13
+ ℹ dist/index.js  0.29 kB │ gzip: 0.16 kB
14
+ ℹ dist/components/DropdownButton.js  0.10 kB │ gzip: 0.09 kB
15
+ ℹ dist/components/Accordion.js  0.08 kB │ gzip: 0.08 kB
16
+ ℹ dist/components/Callout.js  0.07 kB │ gzip: 0.08 kB
17
+ ℹ dist/components/Button.js  0.07 kB │ gzip: 0.08 kB
18
+ ℹ dist/styles.js  0.01 kB │ gzip: 0.03 kB
19
+ ℹ dist/styles.css 40.38 kB │ gzip: 6.94 kB
20
+ ℹ dist/DropdownButton-DoYDi8tB.js  2.69 kB │ gzip: 0.70 kB
21
+ ℹ dist/Button-DBhd6kU7.js  1.51 kB │ gzip: 0.55 kB
22
+ ℹ dist/Callout-UZQRuCQ5.js  0.82 kB │ gzip: 0.44 kB
23
+ ℹ dist/Accordion-DLQE3Td6.js  0.80 kB │ gzip: 0.30 kB
24
+ ℹ dist/index.d.ts  0.46 kB │ gzip: 0.20 kB
25
+ ℹ dist/scripts/index.d.ts  0.30 kB │ gzip: 0.19 kB
26
+ ℹ dist/components/Callout.d.ts  0.14 kB │ gzip: 0.11 kB
27
+ ℹ dist/components/Button.d.ts  0.14 kB │ gzip: 0.10 kB
28
+ ℹ dist/components/Accordion.d.ts  0.12 kB │ gzip: 0.09 kB
29
+ ℹ dist/components/DropdownButton.d.ts  0.10 kB │ gzip: 0.08 kB
30
+ ℹ dist/DropdownButton-zcvep_xH.d.ts  1.38 kB │ gzip: 0.40 kB
31
+ ℹ dist/Button-DwndlytB.d.ts  1.27 kB │ gzip: 0.52 kB
32
+ ℹ dist/Accordion-CJL9SWwS.d.ts  0.74 kB │ gzip: 0.32 kB
33
+ ℹ dist/Callout-CMz3Yl_5.d.ts  0.57 kB │ gzip: 0.33 kB
34
+ ℹ 22 files, total: 53.24 kB
35
+ ✔ Build complete in 761ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,117 @@
1
1
  # @stainless-api/ui-primitives
2
2
 
3
+ ## 0.1.0-beta.20
4
+
5
+ ### Patch Changes
6
+
7
+ - 7ef572c: feat: updated dropdowns
8
+
9
+ ## 0.1.0-beta.19
10
+
11
+ ### Patch Changes
12
+
13
+ - 58040d8: feat: ui primitives updates, cursor support
14
+
15
+ ## 0.1.0-beta.18
16
+
17
+ ### Minor Changes
18
+
19
+ - c635741: Updated worker and fixed docs-ui jsx issue
20
+
21
+ ## 0.1.0-beta.17
22
+
23
+ ### Patch Changes
24
+
25
+ - 1517484: fixing font loading, updating nav bar height
26
+
27
+ ## 0.1.0-beta.16
28
+
29
+ ### Patch Changes
30
+
31
+ - 9cdb24d: Update pagination components, fix search modal
32
+
33
+ ## 0.1.0-beta.15
34
+
35
+ ### Patch Changes
36
+
37
+ - 15c003d: fix react peer dependencies
38
+
39
+ ## 0.1.0-beta.14
40
+
41
+ ### Patch Changes
42
+
43
+ - 0618d05: Markdown rendering of prose pages, ai context menu, auth via cli, minor fixes
44
+
45
+ ## 0.1.0-beta.13
46
+
47
+ ### Patch Changes
48
+
49
+ - e35360f: include ui-primitive packages
50
+
51
+ ## 0.1.0-beta.12
52
+
53
+ ### Patch Changes
54
+
55
+ - a529fd4: fix: site title height
56
+
57
+ ## 0.1.0-beta.11
58
+
59
+ ### Patch Changes
60
+
61
+ - 26a4786: fix: include missing starlight config options
62
+
63
+ ## 0.1.0-beta.10
64
+
65
+ ### Patch Changes
66
+
67
+ - 3e44a9c: Reduce specificity on prose elements
68
+
69
+ ## 0.1.0-beta.9
70
+
71
+ ### Patch Changes
72
+
73
+ - c96f895: Remove css layers, update sidebar styles, add new prose elements
74
+
75
+ ## 0.1.0-beta.8
76
+
77
+ ### Patch Changes
78
+
79
+ - d15a520: fix initialization of dropdown buttons
80
+
81
+ ## 0.1.0-beta.7
82
+
83
+ ### Patch Changes
84
+
85
+ - 34e7c61: verify dependents update
86
+
87
+ ## 0.1.0-beta.6
88
+
89
+ ### Minor Changes
90
+
91
+ - f664b4d: Creating design system css variables, markdown styles, and typography improvements
92
+
93
+ ### Patch Changes
94
+
95
+ - 34cbd12: verify publishing
96
+
97
+ ## 0.1.0-beta.5
98
+
99
+ ### Patch Changes
100
+
101
+ - e7a2a96: verifying dependent packages update
102
+
103
+ ## 0.1.0-beta.4
104
+
105
+ ### Patch Changes
106
+
107
+ - 2853ae8: fixing dependency structure
108
+
109
+ ## 0.1.0-beta.3
110
+
111
+ ### Patch Changes
112
+
113
+ - 870af8d: verify dependent packages update
114
+
3
115
  ## 0.1.0-beta.2
4
116
 
5
117
  ## 0.1.0-beta.1
@@ -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 };
@@ -0,0 +1,2 @@
1
+ import { n as AccordionProps, t as Accordion } from "../Accordion-CJL9SWwS.js";
2
+ export { Accordion, AccordionProps };
@@ -0,0 +1,3 @@
1
+ import { t as Accordion } from "../Accordion-DLQE3Td6.js";
2
+
3
+ export { Accordion };
@@ -0,0 +1,2 @@
1
+ import { n as ButtonProps, r as ButtonVariant, t as Button } from "../Button-DwndlytB.js";
2
+ export { Button, ButtonProps, ButtonVariant };
@@ -0,0 +1,3 @@
1
+ import { t as Button } from "../Button-DBhd6kU7.js";
2
+
3
+ export { Button };
@@ -0,0 +1,2 @@
1
+ import { n as CalloutProps, r as CalloutVariant, t as Callout } from "../Callout-CMz3Yl_5.js";
2
+ export { Callout, CalloutProps, CalloutVariant };
@@ -0,0 +1,3 @@
1
+ import { t as Callout } from "../Callout-UZQRuCQ5.js";
2
+
3
+ export { Callout };
@@ -0,0 +1,2 @@
1
+ import { t as DropdownButton } from "../DropdownButton-zcvep_xH.js";
2
+ export { DropdownButton };
@@ -0,0 +1,3 @@
1
+ import { t as DropdownButton } from "../DropdownButton-DoYDi8tB.js";
2
+
3
+ export { DropdownButton };
@@ -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 };