@stainless-api/ui-primitives 0.1.0-beta.21 → 0.1.0-beta.23
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-DLQE3Td6.js → Accordion-CL3Oarbz.js} +3 -3
- package/dist/{Accordion-CJL9SWwS.d.ts → Accordion-Cj5GURin.d.ts} +4 -4
- package/dist/{Button-DwndlytB.d.ts → Button-CxQtPObH.d.ts} +4 -4
- package/dist/{Button-DBhd6kU7.js → Button-DFAg4M-E.js} +3 -3
- package/dist/{Callout-UZQRuCQ5.js → Callout-BGkXD7D2.js} +1 -1
- package/dist/{Callout-CMz3Yl_5.d.ts → Callout-DlwbfFHm.d.ts} +2 -2
- package/dist/components/Accordion.d.ts +1 -1
- package/dist/components/Accordion.js +1 -1
- package/dist/components/Button.d.ts +1 -1
- package/dist/components/Button.js +1 -1
- package/dist/components/Callout.d.ts +1 -1
- package/dist/components/Callout.js +1 -1
- package/dist/index.d.ts +170 -5
- package/dist/index.js +175 -5
- package/dist/scripts/index.d.ts +12 -1
- package/dist/scripts/index.js +150 -22
- package/dist/styles.css +210 -96
- package/dist/styles.js +0 -1
- package/package.json +21 -12
- package/.turbo/turbo-build.log +0 -35
- package/CHANGELOG.md +0 -133
- package/dist/DropdownButton-DoYDi8tB.js +0 -82
- package/dist/DropdownButton-zcvep_xH.d.ts +0 -50
- package/dist/components/DropdownButton.d.ts +0 -2
- package/dist/components/DropdownButton.js +0 -3
- package/eslint.config.js +0 -2
- package/src/components/Accordion.tsx +0 -41
- package/src/components/Button.tsx +0 -95
- package/src/components/Callout.tsx +0 -31
- package/src/components/accordion.css +0 -145
- package/src/components/button.css +0 -187
- package/src/components/callout.css +0 -93
- package/src/components/dropdown/Dropdown.tsx +0 -51
- package/src/components/dropdown/DropdownButton.tsx +0 -54
- package/src/components/dropdown/DropdownMenu.tsx +0 -113
- package/src/components/dropdown/dropdown.css +0 -232
- package/src/index.ts +0 -5
- package/src/scripts/dropdown-button.ts +0 -39
- package/src/scripts/dropdown.ts +0 -193
- package/src/scripts/index.ts +0 -2
- package/src/styles/layout.css +0 -13
- package/src/styles/scales.css +0 -129
- package/src/styles/starlight-compat.css +0 -156
- package/src/styles/swatches.css +0 -87
- package/src/styles/theme.css +0 -49
- package/src/styles/typography.css +0 -169
- package/src/styles.css +0 -11
- package/tsconfig.json +0 -11
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
.stl-ui-button {
|
|
2
|
-
--stl-ui-button-color: var(--stl-ui-inverse-foreground);
|
|
3
|
-
--stl-ui-button-background-color: var(--stl-ui-inverse-background);
|
|
4
|
-
--stl-ui-button-background-color-hover: color-mix(
|
|
5
|
-
in oklch,
|
|
6
|
-
var(--stl-ui-inverse-background) 90%,
|
|
7
|
-
var(--stl-ui-background)
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
--stl-ui-button-border-color: transparent;
|
|
11
|
-
--stl-ui-button-border-color-hover: transparent;
|
|
12
|
-
|
|
13
|
-
--stl-ui-button-height: 32px;
|
|
14
|
-
--stl-ui-button-padding: 8px 10px;
|
|
15
|
-
--stl-ui-button-border-radius: var(--stl-ui-layout-border-radius-sml);
|
|
16
|
-
--stl-ui-button-line-height: 150%;
|
|
17
|
-
--stl-ui-button-font-weight: 500;
|
|
18
|
-
--stl-ui-button-font-size: var(--stl-ui-type-scale-text-sm);
|
|
19
|
-
--stl-ui-button-font-family: var(--stl-ui-typography-font);
|
|
20
|
-
|
|
21
|
-
cursor: pointer;
|
|
22
|
-
display: inline-flex;
|
|
23
|
-
align-items: center;
|
|
24
|
-
justify-content: center;
|
|
25
|
-
gap: 2px;
|
|
26
|
-
white-space: nowrap;
|
|
27
|
-
flex-shrink: 0;
|
|
28
|
-
|
|
29
|
-
height: var(--stl-ui-button-height);
|
|
30
|
-
padding: var(--stl-ui-button-padding);
|
|
31
|
-
border-radius: var(--stl-ui-button-border-radius);
|
|
32
|
-
line-height: var(--stl-ui-button-line-height);
|
|
33
|
-
font-weight: var(--stl-ui-button-font-weight);
|
|
34
|
-
font-size: var(--stl-ui-button-font-size);
|
|
35
|
-
|
|
36
|
-
border: 1px solid var(--stl-ui-button-border-color);
|
|
37
|
-
font-family: var(--stl-ui-button-font-family);
|
|
38
|
-
|
|
39
|
-
color: var(--stl-ui-button-color);
|
|
40
|
-
background-color: var(--stl-ui-button-background-color);
|
|
41
|
-
|
|
42
|
-
&:hover {
|
|
43
|
-
background-color: var(--stl-ui-button-background-color-hover);
|
|
44
|
-
border-color: var(--stl-ui-button-border-color-hover);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/* --- COLOR VARIANTS --- */
|
|
49
|
-
.stl-ui-button--accent {
|
|
50
|
-
--stl-ui-button-color: var(--stl-ui-accent-foreground);
|
|
51
|
-
--stl-ui-button-background-color: var(--stl-ui-accent-background);
|
|
52
|
-
--stl-ui-button-background-color-hover: color-mix(
|
|
53
|
-
in oklch,
|
|
54
|
-
var(--stl-ui-accent-background) 90%,
|
|
55
|
-
var(--stl-ui-inverse-foreground)
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.stl-ui-button--accent-muted {
|
|
60
|
-
--stl-ui-button-color: var(--stl-ui-accent-muted-foreground);
|
|
61
|
-
--stl-ui-button-background-color: var(--stl-ui-accent-muted-background);
|
|
62
|
-
--stl-ui-button-background-color-hover: color-mix(
|
|
63
|
-
in oklch,
|
|
64
|
-
var(--stl-ui-accent-background) 10%,
|
|
65
|
-
var(--stl-ui-inverse-foreground)
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.stl-ui-button--muted {
|
|
70
|
-
--stl-ui-button-color: var(--stl-ui-foreground);
|
|
71
|
-
--stl-ui-button-background-color: var(--stl-ui-muted-background);
|
|
72
|
-
--stl-ui-button-background-color-hover: color-mix(
|
|
73
|
-
in oklch,
|
|
74
|
-
var(--stl-ui-foreground) 10%,
|
|
75
|
-
var(--stl-ui-inverse-foreground)
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.stl-ui-button--outline {
|
|
80
|
-
--stl-ui-button-color: var(--stl-ui-foreground);
|
|
81
|
-
--stl-ui-button-background-color: var(--stl-ui-card-background);
|
|
82
|
-
--stl-ui-button-background-color-hover: color-mix(
|
|
83
|
-
in oklch,
|
|
84
|
-
var(--stl-ui-foreground) 5%,
|
|
85
|
-
var(--stl-ui-inverse-foreground)
|
|
86
|
-
);
|
|
87
|
-
--stl-ui-button-border-color: var(--stl-ui-border);
|
|
88
|
-
--stl-ui-button-border-color-hover: var(--stl-ui-border-emphasis);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.stl-ui-button--ghost {
|
|
92
|
-
--stl-ui-button-color: var(--stl-ui-foreground);
|
|
93
|
-
--stl-ui-button-background-color: transparent;
|
|
94
|
-
--stl-ui-button-background-color-hover: color-mix(
|
|
95
|
-
in oklch,
|
|
96
|
-
var(--stl-ui-foreground) 5%,
|
|
97
|
-
var(--stl-ui-inverse-foreground)
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.stl-ui-button--success {
|
|
102
|
-
--stl-ui-button-color: var(--stl-ui-swatch-gray-white);
|
|
103
|
-
--stl-ui-button-background-color: var(--stl-ui-swatch-green-base);
|
|
104
|
-
--stl-ui-button-background-color-hover: color-mix(
|
|
105
|
-
in oklch,
|
|
106
|
-
var(--stl-ui-swatch-green-base) 90%,
|
|
107
|
-
var(--stl-ui-inverse-foreground)
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.stl-ui-button--destructive {
|
|
112
|
-
--stl-ui-button-color: var(--stl-ui-swatch-gray-white);
|
|
113
|
-
--stl-ui-button-background-color: var(--stl-ui-swatch-red-base);
|
|
114
|
-
--stl-ui-button-background-color-hover: color-mix(
|
|
115
|
-
in oklch,
|
|
116
|
-
var(--stl-ui-swatch-red-base) 90%,
|
|
117
|
-
var(--stl-ui-inverse-foreground)
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/* --- SIZE VARIANTS --- */
|
|
122
|
-
.stl-ui-button--size-sm {
|
|
123
|
-
--stl-ui-button-height: 24px;
|
|
124
|
-
--stl-ui-button-padding: 0 6px;
|
|
125
|
-
--stl-ui-button-border-radius: var(--stl-ui-layout-border-radius-xs);
|
|
126
|
-
--stl-ui-button-line-height: 100%;
|
|
127
|
-
--stl-ui-button-font-weight: 500;
|
|
128
|
-
--stl-ui-button-font-size: var(--stl-ui-typography-text-body-xs);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.stl-ui-button--size-lg {
|
|
132
|
-
--stl-ui-button-height: 40px;
|
|
133
|
-
--stl-ui-button-padding: 8px 14px;
|
|
134
|
-
--stl-ui-button-border-radius: var(--stl-ui-layout-border-radius);
|
|
135
|
-
--stl-ui-button-line-height: 150%;
|
|
136
|
-
--stl-ui-button-font-weight: 500;
|
|
137
|
-
--stl-ui-button-font-size: var(--stl-ui-typography-text-body);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/* --- ICONS --- */
|
|
141
|
-
.stl-ui-button__icon {
|
|
142
|
-
flex-shrink: 0;
|
|
143
|
-
display: flex;
|
|
144
|
-
align-items: center;
|
|
145
|
-
justify-content: center;
|
|
146
|
-
|
|
147
|
-
svg {
|
|
148
|
-
margin-top: 0;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/* Left Icon */
|
|
153
|
-
.stl-ui-button:has(.stl-ui-button__icon:first-child) .stl-ui-button__icon {
|
|
154
|
-
margin-left: -4px;
|
|
155
|
-
margin-right: 4px;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.stl-ui-button:has(.stl-ui-button__icon:last-child) .stl-ui-button__icon {
|
|
159
|
-
/* Right Icon */
|
|
160
|
-
margin-right: -4px;
|
|
161
|
-
margin-left: 4px;
|
|
162
|
-
|
|
163
|
-
/* Right & Left Icon */
|
|
164
|
-
&:first-child {
|
|
165
|
-
margin-left: -4px;
|
|
166
|
-
margin-right: 4px;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/* Only Icon */
|
|
171
|
-
.stl-ui-button:not(:has(.stl-ui-button-label)):has(.stl-ui-button__icon:last-child):has(
|
|
172
|
-
.stl-ui-button__icon:first-child
|
|
173
|
-
) {
|
|
174
|
-
width: var(--stl-ui-button-height);
|
|
175
|
-
|
|
176
|
-
.stl-ui-button__icon {
|
|
177
|
-
margin-left: -4px;
|
|
178
|
-
margin-right: -4px;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/* --- LINKS --- */
|
|
183
|
-
|
|
184
|
-
a.stl-ui-button {
|
|
185
|
-
text-decoration: none;
|
|
186
|
-
text-align: center;
|
|
187
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
.stl-ui-callout {
|
|
2
|
-
--stl-ui-callout-background-color: var(--stl-ui-muted-background);
|
|
3
|
-
--stl-ui-callout-border-color: var(--stl-ui-border);
|
|
4
|
-
--stl-ui-callout-accent-color: var(--stl-ui-foreground-muted);
|
|
5
|
-
--stl-ui-callout-strong-color: var(--stl-ui-callout-accent-color);
|
|
6
|
-
--stl-ui-callout-selection-background: var(--stl-ui-swatch-gray-gray-6);
|
|
7
|
-
|
|
8
|
-
border: 1px solid var(--stl-ui-callout-border-color);
|
|
9
|
-
background-color: var(--stl-ui-callout-background-color);
|
|
10
|
-
border-radius: var(--stl-ui-layout-border-radius);
|
|
11
|
-
padding: 12px;
|
|
12
|
-
line-height: var(--stl-ui-typography-line-height);
|
|
13
|
-
font-weight: 400;
|
|
14
|
-
font-size: var(--stl-ui-typography-text-body);
|
|
15
|
-
|
|
16
|
-
display: flex;
|
|
17
|
-
align-items: flex-start;
|
|
18
|
-
gap: 8px;
|
|
19
|
-
|
|
20
|
-
:where(a) {
|
|
21
|
-
color: var(--stl-ui-callout-strong-color);
|
|
22
|
-
text-decoration-color: rgba(from currentColor r g b / 0.4);
|
|
23
|
-
transition: text-decoration-color 0.1s ease;
|
|
24
|
-
&:hover {
|
|
25
|
-
text-decoration-color: rgba(from currentColor r g b / 0.8);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
::selection {
|
|
30
|
-
background-color: var(--stl-ui-callout-selection-background);
|
|
31
|
-
color: var(--stl-ui-foreground);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.stl-ui-callout--info {
|
|
36
|
-
--stl-ui-callout-background-color: var(--stl-ui-muted-background);
|
|
37
|
-
--stl-ui-callout-border-color: var(--stl-ui-border);
|
|
38
|
-
--stl-ui-callout-accent-color: var(--stl-ui-foreground-muted);
|
|
39
|
-
--stl-ui-callout-strong-color: var(--stl-ui-foreground);
|
|
40
|
-
--stl-ui-callout-selection-background: var(--stl-ui-swatch-gray-gray-6);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.stl-ui-callout--note {
|
|
44
|
-
--stl-ui-callout-background-color: var(--stl-ui-swatch-blue-faint);
|
|
45
|
-
--stl-ui-callout-border-color: var(--stl-ui-swatch-blue-muted);
|
|
46
|
-
--stl-ui-callout-accent-color: var(--stl-ui-swatch-blue-base);
|
|
47
|
-
--stl-ui-callout-selection-background: var(--stl-ui-swatch-blue-muted);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.stl-ui-callout--tip {
|
|
51
|
-
--stl-ui-callout-background-color: var(--stl-ui-swatch-purple-faint);
|
|
52
|
-
--stl-ui-callout-border-color: var(--stl-ui-swatch-purple-muted);
|
|
53
|
-
--stl-ui-callout-accent-color: var(--stl-ui-swatch-purple-base);
|
|
54
|
-
--stl-ui-callout-selection-background: var(--stl-ui-swatch-purple-muted);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.stl-ui-callout--success {
|
|
58
|
-
--stl-ui-callout-background-color: var(--stl-ui-swatch-green-faint);
|
|
59
|
-
--stl-ui-callout-border-color: var(--stl-ui-swatch-green-muted);
|
|
60
|
-
--stl-ui-callout-accent-color: var(--stl-ui-swatch-green-base);
|
|
61
|
-
--stl-ui-callout-selection-background: var(--stl-ui-swatch-green-muted);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.stl-ui-callout--warning {
|
|
65
|
-
--stl-ui-callout-background-color: var(--stl-ui-swatch-yellow-faint);
|
|
66
|
-
--stl-ui-callout-border-color: var(--stl-ui-swatch-yellow-muted);
|
|
67
|
-
--stl-ui-callout-accent-color: var(--stl-ui-swatch-yellow-base);
|
|
68
|
-
--stl-ui-callout-selection-background: var(--stl-ui-swatch-yellow-muted);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.stl-ui-callout--danger {
|
|
72
|
-
--stl-ui-callout-background-color: var(--stl-ui-swatch-red-faint);
|
|
73
|
-
--stl-ui-callout-border-color: var(--stl-ui-swatch-red-muted);
|
|
74
|
-
--stl-ui-callout-accent-color: var(--stl-ui-swatch-red-base);
|
|
75
|
-
--stl-ui-callout-selection-background: var(--stl-ui-swatch-red-muted);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.stl-ui-callout__icon {
|
|
79
|
-
color: var(--stl-ui-callout-accent-color);
|
|
80
|
-
flex-shrink: 0;
|
|
81
|
-
width: 1em;
|
|
82
|
-
height: 1em;
|
|
83
|
-
margin: calc((1lh - 1em) / 2);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.stl-ui-callout__content {
|
|
87
|
-
flex: 1;
|
|
88
|
-
margin-top: 0;
|
|
89
|
-
|
|
90
|
-
& > :first-child {
|
|
91
|
-
margin-top: 0;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
|
-
import type { ComponentProps } from 'react';
|
|
3
|
-
import { Menu } from './DropdownMenu';
|
|
4
|
-
|
|
5
|
-
function Trigger({ className, ...props }: ComponentProps<'button'>) {
|
|
6
|
-
return (
|
|
7
|
-
<button {...props} data-part="trigger" className={clsx('stl-ui-dropdown__button', className)}>
|
|
8
|
-
{props.children}
|
|
9
|
-
</button>
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function TriggerSelectedItem({ className, ...props }: ComponentProps<'div'>) {
|
|
14
|
-
return (
|
|
15
|
-
<div
|
|
16
|
-
{...props}
|
|
17
|
-
data-part="trigger-selected"
|
|
18
|
-
className={clsx('stl-ui-dropdown__trigger-selected', className)}
|
|
19
|
-
/>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function TriggerIcon({ className, ...props }: ComponentProps<'span'>) {
|
|
24
|
-
return (
|
|
25
|
-
<span {...props} data-part="trigger-icon" className={clsx('stl-ui-dropdown__trigger-icon', className)} />
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function Icon({ className, ...props }: ComponentProps<'div'>) {
|
|
30
|
-
return <div {...props} data-part="item-icon" className={clsx('stl-ui-dropdown__icon', className)} />;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function Dropdown({ className, ...props }: ComponentProps<'div'>) {
|
|
34
|
-
return (
|
|
35
|
-
<div
|
|
36
|
-
{...props}
|
|
37
|
-
aria-haspopup="listbox"
|
|
38
|
-
aria-expanded="false"
|
|
39
|
-
className={clsx('stl-ui-dropdown stl-ui-not-prose not-content', className)}
|
|
40
|
-
/>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
Dropdown.Menu = Menu;
|
|
45
|
-
Dropdown.MenuItem = Menu.Item;
|
|
46
|
-
Dropdown.MenuItemText = Menu.ItemText;
|
|
47
|
-
Dropdown.MenuItemTemplate = Menu.ItemTemplate;
|
|
48
|
-
Dropdown.Trigger = Trigger;
|
|
49
|
-
Dropdown.TriggerSelectedItem = TriggerSelectedItem;
|
|
50
|
-
Dropdown.TriggerIcon = TriggerIcon;
|
|
51
|
-
Dropdown.Icon = Icon;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
|
-
import { ChevronsUpDown } from 'lucide-react';
|
|
3
|
-
import type { ComponentProps } from 'react';
|
|
4
|
-
import { Menu } from './DropdownMenu';
|
|
5
|
-
|
|
6
|
-
function PrimaryActionText({ children }: { children?: React.ReactNode }) {
|
|
7
|
-
return <span data-part="primary-action-text">{children}</span>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function PrimaryAction({ className, ...props }: ComponentProps<'button'>) {
|
|
11
|
-
return (
|
|
12
|
-
<button
|
|
13
|
-
{...props}
|
|
14
|
-
data-part="primary-action"
|
|
15
|
-
className={clsx('stl-ui-dropdown__button stl-ui-dropdown-button--action', className)}
|
|
16
|
-
/>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function Trigger({ className, ...props }: ComponentProps<'button'>) {
|
|
21
|
-
return (
|
|
22
|
-
<button
|
|
23
|
-
{...props}
|
|
24
|
-
type="button"
|
|
25
|
-
data-part="trigger"
|
|
26
|
-
className={clsx('stl-ui-dropdown__button stl-ui-dropdown-button__trigger', className)}
|
|
27
|
-
>
|
|
28
|
-
<ChevronsUpDown size={16} />
|
|
29
|
-
</button>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function Icon({ className, ...props }: ComponentProps<'div'>) {
|
|
34
|
-
return <div data-part="item-icon" {...props} className={clsx('stl-ui-dropdown__icon', className)} />;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function DropdownButton({ className, ...props }: ComponentProps<'div'>) {
|
|
38
|
-
return (
|
|
39
|
-
<div
|
|
40
|
-
{...props}
|
|
41
|
-
aria-haspopup="listbox"
|
|
42
|
-
aria-expanded="false"
|
|
43
|
-
className={clsx('stl-ui-dropdown stl-ui-not-prose not-content', className)}
|
|
44
|
-
/>
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
DropdownButton.Menu = Menu;
|
|
49
|
-
DropdownButton.MenuItem = Menu.Item;
|
|
50
|
-
DropdownButton.MenuItemText = Menu.ItemText;
|
|
51
|
-
DropdownButton.PrimaryAction = PrimaryAction;
|
|
52
|
-
DropdownButton.PrimaryActionText = PrimaryActionText;
|
|
53
|
-
DropdownButton.Trigger = Trigger;
|
|
54
|
-
DropdownButton.Icon = Icon;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
|
-
import { CheckIcon, ExternalLink } from 'lucide-react';
|
|
3
|
-
import type { ComponentProps } from 'react';
|
|
4
|
-
|
|
5
|
-
export function Menu({ className, ...props }: ComponentProps<'div'>) {
|
|
6
|
-
return (
|
|
7
|
-
<div
|
|
8
|
-
{...props}
|
|
9
|
-
role="listbox"
|
|
10
|
-
data-state="closed"
|
|
11
|
-
data-part="menu"
|
|
12
|
-
className={clsx('stl-ui-dropdown-menu', className)}
|
|
13
|
-
/>
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function MenuItemText({ className, subtle, ...props }: ComponentProps<'span'> & { subtle?: boolean }) {
|
|
18
|
-
return (
|
|
19
|
-
<span
|
|
20
|
-
{...props}
|
|
21
|
-
data-part="item-text"
|
|
22
|
-
className={clsx(
|
|
23
|
-
`stl-ui-dropdown-menu__item-text`,
|
|
24
|
-
{
|
|
25
|
-
'stl-ui-dropdown-menu__item-text--subtle': subtle,
|
|
26
|
-
},
|
|
27
|
-
className,
|
|
28
|
-
)}
|
|
29
|
-
/>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
type MenuItemBaseProps = {
|
|
34
|
-
children?: React.ReactNode;
|
|
35
|
-
value: string;
|
|
36
|
-
isExternalLink?: boolean;
|
|
37
|
-
isSelected?: boolean;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
type MenuItemWithHref = MenuItemBaseProps &
|
|
41
|
-
ComponentProps<'a'> & {
|
|
42
|
-
href: string;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
type MenuItemWithoutHref = MenuItemBaseProps &
|
|
46
|
-
ComponentProps<'button'> & {
|
|
47
|
-
href?: never;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
type MenuItemProps = MenuItemWithHref | MenuItemWithoutHref;
|
|
51
|
-
|
|
52
|
-
function MenuItem({ children, value, href, isExternalLink, isSelected, ...props }: MenuItemProps) {
|
|
53
|
-
const inner = (
|
|
54
|
-
<>
|
|
55
|
-
<div className="stl-ui-dropdown-menu__item-content">{children}</div>
|
|
56
|
-
{isSelected && (
|
|
57
|
-
<div className="stl-ui-dropdown-menu__item-icon" data-part="item-selected-icon">
|
|
58
|
-
<CheckIcon size={16} />
|
|
59
|
-
</div>
|
|
60
|
-
)}
|
|
61
|
-
{isExternalLink && (
|
|
62
|
-
<div className="stl-ui-dropdown-menu__item-subtle-icon" data-part="item-external-link-icon">
|
|
63
|
-
<ExternalLink size={16} />
|
|
64
|
-
</div>
|
|
65
|
-
)}
|
|
66
|
-
</>
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
if (href) {
|
|
70
|
-
return (
|
|
71
|
-
<a
|
|
72
|
-
role="option"
|
|
73
|
-
data-part="item"
|
|
74
|
-
data-value={value}
|
|
75
|
-
aria-selected={isSelected}
|
|
76
|
-
href={href}
|
|
77
|
-
{...(props as ComponentProps<'a'>)}
|
|
78
|
-
className={clsx('stl-ui-dropdown-menu__item', 'stl-ui-dropdown-menu__item-link', props.className)}
|
|
79
|
-
>
|
|
80
|
-
{inner}
|
|
81
|
-
</a>
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<button
|
|
87
|
-
{...(props as ComponentProps<'button'>)}
|
|
88
|
-
role="option"
|
|
89
|
-
data-part="item"
|
|
90
|
-
data-value={value}
|
|
91
|
-
aria-selected={isSelected}
|
|
92
|
-
className={clsx('stl-ui-dropdown-menu__item', props.className)}
|
|
93
|
-
>
|
|
94
|
-
{inner}
|
|
95
|
-
</button>
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* A template component that defines the content to be displayed in the dropdown trigger
|
|
101
|
-
* when a menu item is selected. This template is used to customize the appearance of
|
|
102
|
-
* the selected item in the trigger button.
|
|
103
|
-
*
|
|
104
|
-
* @param props - Standard HTML template element props
|
|
105
|
-
* @returns A template element marked with the "selected-template" data part
|
|
106
|
-
*/
|
|
107
|
-
function MenuItemTemplate({ ...props }: ComponentProps<'template'>) {
|
|
108
|
-
return <template data-part="selected-template" {...props} />;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
Menu.Item = MenuItem;
|
|
112
|
-
Menu.ItemText = MenuItemText;
|
|
113
|
-
Menu.ItemTemplate = MenuItemTemplate;
|