@moi952/decky-ui-kit 0.1.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 +96 -0
- package/dist/AnchoredDropdown.d.ts +24 -0
- package/dist/AnchoredDropdown.js +260 -0
- package/dist/CollapsibleSection.d.ts +8 -0
- package/dist/CollapsibleSection.js +7 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# decky-ui-kit
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@moi952/decky-ui-kit)
|
|
4
|
+
[](https://www.npmjs.com/package/@moi952/decky-ui-kit)
|
|
5
|
+
|
|
6
|
+
[](https://moi952.github.io/decky-ui-kit/)
|
|
7
|
+
|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
Reusable UI components for [Decky Loader](https://github.com/SteamDeckHomebrew/decky-loader) plugins, built for cases where Steam's own native popup components (`DropdownItem`, `showContextMenu`, `Menu`) can't be used — opening any of them resets the whole plugin panel back to its home view once closed. Every component here is a hand-built inline overlay instead, with its own keyboard/mouse/gamepad focus handling.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @moi952/decky-ui-kit
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Or pin an exact version: `npm install @moi952/decky-ui-kit@0.1.0`.
|
|
19
|
+
|
|
20
|
+
Installing straight from GitHub also works (`npm install github:moi952/decky-ui-kit#v0.1.0`) — `dist/` is committed on every release, so it needs no install-time build step either way.
|
|
21
|
+
|
|
22
|
+
## Demo
|
|
23
|
+
|
|
24
|
+
Every prop combination side by side, with a live Playground panel per component. It's a plain-browser visual reference, not the real Steam client: `Field`/`DialogButton`/`Focusable` are mocked, so corner-radius inheritance, the native focus halo, and gamepad input aren't reproduced there.
|
|
25
|
+
|
|
26
|
+
Run it locally with `npm run demo:dev`.
|
|
27
|
+
|
|
28
|
+
## Components
|
|
29
|
+
|
|
30
|
+
### `AnchoredDropdown`
|
|
31
|
+
|
|
32
|
+
A dropdown whose option list renders inline, anchored to its own trigger — not through a native Steam popup.
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { AnchoredDropdown } from "@moi952/decky-ui-kit";
|
|
36
|
+
|
|
37
|
+
<AnchoredDropdown
|
|
38
|
+
variant="boxed"
|
|
39
|
+
focusStyle="fill"
|
|
40
|
+
options={[
|
|
41
|
+
{ value: "a", label: "Option A" },
|
|
42
|
+
{ value: "b", label: "Option B" },
|
|
43
|
+
]}
|
|
44
|
+
selectedValue={value}
|
|
45
|
+
onChange={setValue}
|
|
46
|
+
/>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
<details>
|
|
50
|
+
<summary>Props</summary>
|
|
51
|
+
|
|
52
|
+
| Prop | Type | Default | Description |
|
|
53
|
+
| --- | --- | --- | --- |
|
|
54
|
+
| `options` | `{ value: string; label: string }[]` | — | The list of choices. |
|
|
55
|
+
| `selectedValue` | `string` | — | Current value. In `multiple` mode, a comma-joined list of values. |
|
|
56
|
+
| `onChange` | `(value: string) => void` | — | Called with the new value (or comma-joined list, in `multiple` mode). |
|
|
57
|
+
| `variant` | `"row" \| "boxed"` | `"boxed"` | `"row"`: flat, matches surrounding list rows. `"boxed"`: bordered box with an arrow. |
|
|
58
|
+
| `focusStyle` | `"fill" \| "outline"` | `"fill"` | `"fill"`: solid white background on focus. `"outline"`: transparent border that fills on focus. |
|
|
59
|
+
| `size` | `"default" \| "small"` | `"default"` | Row/trigger height and font size. |
|
|
60
|
+
| `bgColor` | `string` | Steam-like dark gray | Background color. |
|
|
61
|
+
| `textColor` | `string` | Steam-like light gray | Text color. |
|
|
62
|
+
| `borderColor` | `string` | `"transparent"` | Trigger and list border color. |
|
|
63
|
+
| `blurBackground` | `boolean` | `true` | Blurs the panel behind the list while it's open. |
|
|
64
|
+
| `multiple` | `boolean` | `false` | Multi-select mode (comma-joined value). |
|
|
65
|
+
| `maxDisplayLines` | `number` | `1` | Lines the trigger's selected-value summary can wrap before clipping. |
|
|
66
|
+
| `maxVisibleOptions` | `number` | — | Rows visible before the list scrolls. Defaults to a fixed max height. |
|
|
67
|
+
| `highlightOnFocus` | `boolean` | `true` | Native Steam focus highlight band, themeable via CSS Loader. |
|
|
68
|
+
| `bottomSeparator` | `boolean` | `true` | Native Steam separator line below the trigger. |
|
|
69
|
+
|
|
70
|
+
</details>
|
|
71
|
+
|
|
72
|
+
The list's corner radius is read at runtime from the trigger's own computed `border-radius`, so it automatically matches Steam's native rounding — including any CSS Loader "round" theme — without hardcoding a variable name.
|
|
73
|
+
|
|
74
|
+
### `CollapsibleSection`
|
|
75
|
+
|
|
76
|
+
An expand/collapse row built on `Field`, for tucking secondary content (settings, history, details) behind a single toggleable header.
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import { CollapsibleSection } from "@moi952/decky-ui-kit";
|
|
80
|
+
|
|
81
|
+
<CollapsibleSection label="Advanced settings" expanded={expanded} onToggle={() => setExpanded(!expanded)}>
|
|
82
|
+
<MySettingsFields />
|
|
83
|
+
</CollapsibleSection>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
<details>
|
|
87
|
+
<summary>Props</summary>
|
|
88
|
+
|
|
89
|
+
| Prop | Type | Default | Description |
|
|
90
|
+
| --- | --- | --- | --- |
|
|
91
|
+
| `label` | `string` | — | Header text. |
|
|
92
|
+
| `expanded` | `boolean` | — | Whether the children are shown. State is owned by the caller. |
|
|
93
|
+
| `onToggle` | `() => void` | — | Called on click/activate; flip `expanded` in response. |
|
|
94
|
+
| `children` | `ReactNode` | — | Rendered below the header while `expanded` is `true`. |
|
|
95
|
+
|
|
96
|
+
</details>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface DropdownOption {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
}
|
|
6
|
+
export interface AnchoredDropdownProps {
|
|
7
|
+
options: DropdownOption[];
|
|
8
|
+
selectedValue: string;
|
|
9
|
+
onChange: (value: string) => void;
|
|
10
|
+
variant?: "row" | "boxed";
|
|
11
|
+
focusStyle?: "fill" | "outline";
|
|
12
|
+
size?: "default" | "small";
|
|
13
|
+
bgColor?: string;
|
|
14
|
+
textColor?: string;
|
|
15
|
+
borderColor?: string;
|
|
16
|
+
blurBackground?: boolean;
|
|
17
|
+
multiple?: boolean;
|
|
18
|
+
maxDisplayLines?: number;
|
|
19
|
+
maxVisibleOptions?: number;
|
|
20
|
+
highlightOnFocus?: boolean;
|
|
21
|
+
bottomSeparator?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const AnchoredDropdown: React.FC<AnchoredDropdownProps>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
import { DialogButton, Field, Focusable, GamepadButton } from "@decky/ui";
|
|
4
|
+
import { FaChevronDown, FaChevronRight, FaCheck } from "react-icons/fa";
|
|
5
|
+
const DEFAULT_BG = "#35373c";
|
|
6
|
+
const DEFAULT_TEXT = "#bfbfbf";
|
|
7
|
+
const DEFAULT_BORDER = "transparent";
|
|
8
|
+
const FALLBACK_RADIUS = "6px";
|
|
9
|
+
// Shared across every instance so a "row" dropdown reuses the real native
|
|
10
|
+
// radius a "boxed" one already measured, instead of measuring its own
|
|
11
|
+
// differently-shaped native element (Field vs DialogButton).
|
|
12
|
+
let sharedBoxedRadius = null;
|
|
13
|
+
let uidCounter = 0;
|
|
14
|
+
const splitCsv = (value) => value.split(",").map((v) => v.trim()).filter(Boolean);
|
|
15
|
+
const toggleCsv = (csv, value, options) => {
|
|
16
|
+
const selected = splitCsv(csv);
|
|
17
|
+
const next = selected.includes(value)
|
|
18
|
+
? selected.filter((v) => v !== value)
|
|
19
|
+
: [...selected, value];
|
|
20
|
+
return options
|
|
21
|
+
.filter((o) => next.includes(o.value))
|
|
22
|
+
.map((o) => o.value)
|
|
23
|
+
.join(",");
|
|
24
|
+
};
|
|
25
|
+
// Native Steam popups reset the whole plugin panel on close — this renders
|
|
26
|
+
// an inline overlay anchored to its own trigger instead.
|
|
27
|
+
export const AnchoredDropdown = ({ options, selectedValue, onChange, variant = "boxed", focusStyle = "fill", size = "default", bgColor = DEFAULT_BG, textColor = DEFAULT_TEXT, borderColor = DEFAULT_BORDER, blurBackground = true, multiple = false, maxDisplayLines = 1, maxVisibleOptions, highlightOnFocus = true, bottomSeparator = true, }) => {
|
|
28
|
+
// Scoped per instance so sibling dropdowns don't share class names.
|
|
29
|
+
const [uid] = useState(() => `dck-anchored-dd${uidCounter++}`);
|
|
30
|
+
const [expanded, setExpanded] = useState(false);
|
|
31
|
+
const [focusedIndex, setFocusedIndex] = useState(0);
|
|
32
|
+
const itemRefs = useRef([]);
|
|
33
|
+
const wrapperRef = useRef(null);
|
|
34
|
+
const triggerRef = useRef(null);
|
|
35
|
+
const [openUp, setOpenUp] = useState(false);
|
|
36
|
+
// Mirrors the trigger's real computed radius instead of a guessed CSS var.
|
|
37
|
+
const [listRadius, setListRadius] = useState(FALLBACK_RADIUS);
|
|
38
|
+
// text-overflow only works against a real pixel width — CSS alone (flex
|
|
39
|
+
// shrink, % width) proved unreliable through Field's own layout, so this
|
|
40
|
+
// measures the trigger's actual rendered width instead of guessing it.
|
|
41
|
+
const [labelMaxWidth, setLabelMaxWidth] = useState(undefined);
|
|
42
|
+
useLayoutEffect(() => {
|
|
43
|
+
if (variant !== "boxed" || !triggerRef.current)
|
|
44
|
+
return;
|
|
45
|
+
const el = triggerRef.current;
|
|
46
|
+
const horizontalPadding = size === "small" ? 10 : 14;
|
|
47
|
+
const overhead = horizontalPadding * 2 + 12 + 8;
|
|
48
|
+
const measure = () => setLabelMaxWidth(Math.max(0, el.clientWidth - overhead));
|
|
49
|
+
measure();
|
|
50
|
+
const ro = new ResizeObserver(measure);
|
|
51
|
+
ro.observe(el);
|
|
52
|
+
return () => ro.disconnect();
|
|
53
|
+
}, [variant, size]);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (variant === "boxed" && triggerRef.current) {
|
|
56
|
+
const r = getComputedStyle(triggerRef.current).borderRadius;
|
|
57
|
+
if (r) {
|
|
58
|
+
sharedBoxedRadius = r;
|
|
59
|
+
setListRadius(r);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else if (sharedBoxedRadius) {
|
|
63
|
+
setListRadius(sharedBoxedRadius);
|
|
64
|
+
}
|
|
65
|
+
}, [variant]);
|
|
66
|
+
const selectedValues = multiple ? splitCsv(selectedValue) : [];
|
|
67
|
+
const singleSelected = options.find((o) => o.value === selectedValue);
|
|
68
|
+
const displayLabel = multiple
|
|
69
|
+
? selectedValues
|
|
70
|
+
.map((v) => options.find((o) => o.value === v)?.label ?? v)
|
|
71
|
+
.join(", ") || selectedValue
|
|
72
|
+
: singleSelected?.label ?? selectedValue;
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (!expanded)
|
|
75
|
+
return;
|
|
76
|
+
const idx = options.findIndex((o) => multiple ? selectedValues.includes(o.value) : o.value === selectedValue);
|
|
77
|
+
setFocusedIndex(idx >= 0 ? idx : 0);
|
|
78
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
79
|
+
}, [expanded]);
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (expanded)
|
|
82
|
+
itemRefs.current[focusedIndex]?.focus();
|
|
83
|
+
}, [focusedIndex, expanded]);
|
|
84
|
+
// The list unmounts on close, dropping focus — send it back to the trigger.
|
|
85
|
+
const closeList = () => {
|
|
86
|
+
setExpanded(false);
|
|
87
|
+
triggerRef.current?.focus();
|
|
88
|
+
};
|
|
89
|
+
const pick = (value) => {
|
|
90
|
+
if (multiple) {
|
|
91
|
+
onChange(toggleCsv(selectedValue, value, options));
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
onChange(value);
|
|
95
|
+
closeList();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
// Steam's focus engine picks by screen geometry — handle DIR_UP/DOWN
|
|
99
|
+
// ourselves to stay inside the list.
|
|
100
|
+
const handleListButtonDown = (evt) => {
|
|
101
|
+
if (evt.detail.button === GamepadButton.DIR_DOWN) {
|
|
102
|
+
evt.stopPropagation();
|
|
103
|
+
setFocusedIndex((i) => Math.min(i + 1, options.length - 1));
|
|
104
|
+
}
|
|
105
|
+
else if (evt.detail.button === GamepadButton.DIR_UP) {
|
|
106
|
+
evt.stopPropagation();
|
|
107
|
+
setFocusedIndex((i) => Math.max(i - 1, 0));
|
|
108
|
+
}
|
|
109
|
+
else if (evt.detail.button === GamepadButton.CANCEL) {
|
|
110
|
+
evt.stopPropagation();
|
|
111
|
+
closeList();
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
// Padding + font line-height + the option's own 2px top/bottom border
|
|
115
|
+
// (previously missing from this estimate, clipping the last visible row).
|
|
116
|
+
const rowHeight = size === "small" ? 26 : 42;
|
|
117
|
+
const listMaxHeight = maxVisibleOptions
|
|
118
|
+
? maxVisibleOptions * (rowHeight + 2)
|
|
119
|
+
: 220;
|
|
120
|
+
const toggle = () => {
|
|
121
|
+
setExpanded((prev) => {
|
|
122
|
+
const next = !prev;
|
|
123
|
+
if (next && wrapperRef.current) {
|
|
124
|
+
const r = wrapperRef.current.getBoundingClientRect();
|
|
125
|
+
const spaceBelow = window.innerHeight - r.bottom;
|
|
126
|
+
const spaceAbove = r.top;
|
|
127
|
+
setOpenUp(spaceBelow < listMaxHeight && spaceAbove > spaceBelow);
|
|
128
|
+
}
|
|
129
|
+
return next;
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
const optionCls = `${uid}-option`;
|
|
133
|
+
const selectedCls = `${uid}-selected`;
|
|
134
|
+
const triggerCls = `${uid}-trigger`;
|
|
135
|
+
const triggerLabelCls = `${uid}-trigger-label`;
|
|
136
|
+
const wrapperCls = `${uid}-wrapper`;
|
|
137
|
+
const optionPadding = size === "small" ? "4px 8px" : "10px 14px";
|
|
138
|
+
const optionFontSize = size === "small" ? "11px" : "14px";
|
|
139
|
+
const triggerPadding = size === "small" ? "6px 10px" : "10px 14px";
|
|
140
|
+
const triggerFontSize = size === "small" ? "12px" : "15px";
|
|
141
|
+
return (_jsxs("div", { ref: wrapperRef, className: wrapperCls, style: { position: "relative", width: "100%", maxWidth: "100%", boxSizing: "border-box" }, children: [_jsx("style", { children: `
|
|
142
|
+
.${optionCls} {
|
|
143
|
+
box-sizing: border-box !important;
|
|
144
|
+
padding: ${optionPadding} !important;
|
|
145
|
+
font-size: ${optionFontSize} !important;
|
|
146
|
+
min-width: 0 !important;
|
|
147
|
+
width: 100% !important;
|
|
148
|
+
display: flex !important;
|
|
149
|
+
justify-content: space-between !important;
|
|
150
|
+
align-items: center !important;
|
|
151
|
+
background: ${bgColor} !important;
|
|
152
|
+
background-image: none !important;
|
|
153
|
+
box-shadow: none !important;
|
|
154
|
+
border: 2px solid transparent !important;
|
|
155
|
+
color: ${textColor} !important;
|
|
156
|
+
}
|
|
157
|
+
.${triggerCls} {
|
|
158
|
+
box-sizing: border-box !important;
|
|
159
|
+
width: calc(100% - 6px) !important;
|
|
160
|
+
max-width: calc(100% - 6px) !important;
|
|
161
|
+
margin: 3px !important;
|
|
162
|
+
display: flex !important;
|
|
163
|
+
justify-content: space-between !important;
|
|
164
|
+
align-items: center !important;
|
|
165
|
+
gap: 8px !important;
|
|
166
|
+
padding: ${triggerPadding} !important;
|
|
167
|
+
font-size: ${triggerFontSize} !important;
|
|
168
|
+
background: ${bgColor} !important;
|
|
169
|
+
border: 1px solid ${borderColor} !important;
|
|
170
|
+
color: ${textColor} !important;
|
|
171
|
+
}
|
|
172
|
+
.${triggerLabelCls} {
|
|
173
|
+
display: -webkit-box !important;
|
|
174
|
+
-webkit-box-orient: vertical !important;
|
|
175
|
+
-webkit-line-clamp: ${maxDisplayLines} !important;
|
|
176
|
+
overflow: hidden !important;
|
|
177
|
+
text-overflow: ellipsis !important;
|
|
178
|
+
text-align: left !important;
|
|
179
|
+
flex: 1 !important;
|
|
180
|
+
min-width: 0 !important;
|
|
181
|
+
}
|
|
182
|
+
${focusStyle === "outline"
|
|
183
|
+
? `
|
|
184
|
+
.${optionCls}.${selectedCls} {
|
|
185
|
+
border-color: #dcdedf !important;
|
|
186
|
+
color: #fff !important;
|
|
187
|
+
}
|
|
188
|
+
.${optionCls}:focus,
|
|
189
|
+
.${optionCls}:hover {
|
|
190
|
+
background: #555 !important;
|
|
191
|
+
border-color: #fff !important;
|
|
192
|
+
color: #fff !important;
|
|
193
|
+
}
|
|
194
|
+
.${wrapperCls}:focus-within .${triggerCls},
|
|
195
|
+
.${triggerCls}:hover {
|
|
196
|
+
background: #555 !important;
|
|
197
|
+
border-color: #fff !important;
|
|
198
|
+
color: #fff !important;
|
|
199
|
+
}
|
|
200
|
+
`
|
|
201
|
+
: `
|
|
202
|
+
.${optionCls}.${selectedCls} {
|
|
203
|
+
color: #fff !important;
|
|
204
|
+
}
|
|
205
|
+
.${optionCls}:focus,
|
|
206
|
+
.${optionCls}:hover {
|
|
207
|
+
background: #fff !important;
|
|
208
|
+
color: #111 !important;
|
|
209
|
+
}
|
|
210
|
+
.${wrapperCls}:focus-within .${triggerCls},
|
|
211
|
+
.${triggerCls}:hover {
|
|
212
|
+
background: #fff !important;
|
|
213
|
+
color: #111 !important;
|
|
214
|
+
}
|
|
215
|
+
`}
|
|
216
|
+
` }), variant === "boxed" ? (_jsx(Field, { focusable: true, highlightOnFocus: highlightOnFocus, bottomSeparator: bottomSeparator ? "standard" : "none", childrenContainerWidth: "max", onActivate: toggle, onClick: toggle, children: _jsxs(DialogButton, { className: triggerCls, ref: (el) => {
|
|
217
|
+
triggerRef.current = el;
|
|
218
|
+
}, children: [_jsx("span", { className: triggerLabelCls, style: labelMaxWidth !== undefined ? { maxWidth: labelMaxWidth } : undefined, children: displayLabel }), _jsx(FaChevronDown, { size: 12, style: { flexShrink: 0 } })] }) })) : (_jsx(Field, { focusable: true, highlightOnFocus: highlightOnFocus, bottomSeparator: bottomSeparator ? "standard" : "none", onActivate: toggle, onClick: toggle, label: displayLabel, childrenLayout: "inline", ref: (el) => {
|
|
219
|
+
triggerRef.current = el;
|
|
220
|
+
}, children: expanded ? _jsx(FaChevronDown, { size: 12 }) : _jsx(FaChevronRight, { size: 12 }) })), expanded && blurBackground && (_jsx("div", { onClick: closeList, style: {
|
|
221
|
+
position: "fixed",
|
|
222
|
+
inset: 0,
|
|
223
|
+
zIndex: 49,
|
|
224
|
+
background: "rgba(0,0,0,0.25)",
|
|
225
|
+
backdropFilter: "blur(6px)",
|
|
226
|
+
WebkitBackdropFilter: "blur(6px)",
|
|
227
|
+
} })), expanded && (
|
|
228
|
+
// This div owns the rounded/clipped box; Focusable inside only
|
|
229
|
+
// handles scrolling and gamepad focus (it's a native Steam module,
|
|
230
|
+
// its own classes can beat an inline style).
|
|
231
|
+
_jsx("div", { style: {
|
|
232
|
+
boxSizing: "border-box",
|
|
233
|
+
position: "absolute",
|
|
234
|
+
...(openUp ? { bottom: "100%" } : { top: "100%" }),
|
|
235
|
+
left: 0,
|
|
236
|
+
right: 0,
|
|
237
|
+
zIndex: 50,
|
|
238
|
+
maxHeight: listMaxHeight,
|
|
239
|
+
overflow: "hidden",
|
|
240
|
+
background: bgColor,
|
|
241
|
+
border: `1px solid ${borderColor}`,
|
|
242
|
+
borderRadius: listRadius,
|
|
243
|
+
boxShadow: "0 4px 12px rgba(0,0,0,0.5)",
|
|
244
|
+
marginTop: openUp ? 0 : 2,
|
|
245
|
+
marginBottom: openUp ? 2 : 0,
|
|
246
|
+
}, children: _jsx(Focusable, { noFocusRing: true, onCancelButton: closeList, onButtonDown: handleListButtonDown, style: {
|
|
247
|
+
display: "flex",
|
|
248
|
+
flexDirection: "column",
|
|
249
|
+
gap: 2,
|
|
250
|
+
maxHeight: listMaxHeight,
|
|
251
|
+
overflowY: "auto",
|
|
252
|
+
}, "flow-children": "vertical", children: options.map((opt, i) => {
|
|
253
|
+
const isSelected = multiple
|
|
254
|
+
? selectedValues.includes(opt.value)
|
|
255
|
+
: opt.value === selectedValue;
|
|
256
|
+
return (_jsxs(DialogButton, { ref: (el) => {
|
|
257
|
+
itemRefs.current[i] = el;
|
|
258
|
+
}, className: `${optionCls}${isSelected ? ` ${selectedCls}` : ""}`, onClick: () => pick(opt.value), children: [_jsx("span", { children: opt.label }), isSelected && _jsx(FaCheck, { size: 10 })] }, opt.value));
|
|
259
|
+
}) }) }))] }));
|
|
260
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Field } from "@decky/ui";
|
|
3
|
+
import { FaChevronDown, FaChevronRight } from "react-icons/fa";
|
|
4
|
+
// Field is the generic building block Decky's own ToggleField/SliderField
|
|
5
|
+
// are built on — using it here gets native padding/separator for free,
|
|
6
|
+
// instead of approximating them with a hand-styled button.
|
|
7
|
+
export const CollapsibleSection = ({ label, expanded, onToggle, children, }) => (_jsxs(_Fragment, { children: [_jsx(Field, { label: label, onActivate: onToggle, onClick: onToggle, focusable: true, bottomSeparator: "standard", childrenLayout: "inline", children: expanded ? _jsx(FaChevronDown, { size: 12 }) : _jsx(FaChevronRight, { size: 12 }) }), expanded && children] }));
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@moi952/decky-ui-kit",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Reusable UI components for Decky Loader plugins that need popups/dropdowns without triggering the native panel-remount bug",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"demo:dev": "vite",
|
|
17
|
+
"demo:build": "vite build"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"@decky/ui": ">=4.0.0",
|
|
21
|
+
"react": ">=18.0.0",
|
|
22
|
+
"react-icons": ">=5.0.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/react": "19.1.1",
|
|
26
|
+
"@types/react-dom": "19.1.1",
|
|
27
|
+
"@vitejs/plugin-react": "^4.3.0",
|
|
28
|
+
"react": "^18.3.1",
|
|
29
|
+
"react-dom": "^18.3.1",
|
|
30
|
+
"react-icons": "^5.3.0",
|
|
31
|
+
"typescript": "^5.6.2",
|
|
32
|
+
"vite": "^5.4.0"
|
|
33
|
+
},
|
|
34
|
+
"author": "moi952",
|
|
35
|
+
"license": "BSD-3-Clause",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/moi952/decky-ui-kit.git"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"decky",
|
|
42
|
+
"decky-loader",
|
|
43
|
+
"steam-deck",
|
|
44
|
+
"ui",
|
|
45
|
+
"dropdown"
|
|
46
|
+
]
|
|
47
|
+
}
|