@moi952/decky-ui-kit 0.3.0 → 0.5.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 +237 -4
- package/dist/ActionButton.d.ts +22 -0
- package/dist/ActionButton.js +77 -0
- package/dist/AnchoredDropdown.d.ts +3 -1
- package/dist/AnchoredDropdown.js +34 -14
- package/dist/CollapsibleSection.d.ts +7 -1
- package/dist/CollapsibleSection.js +39 -3
- package/dist/FieldTextInput.d.ts +2 -1
- package/dist/FieldTextInput.js +19 -5
- package/dist/InfoTable.d.ts +17 -0
- package/dist/InfoTable.js +34 -0
- package/dist/InlineConfirm.d.ts +2 -1
- package/dist/InlineConfirm.js +28 -28
- package/dist/MediaRow.d.ts +28 -0
- package/dist/MediaRow.js +175 -0
- package/dist/QrCodeButton.d.ts +12 -0
- package/dist/QrCodeButton.js +36 -0
- package/dist/ScreenshotCarousel.d.ts +14 -0
- package/dist/ScreenshotCarousel.js +149 -0
- package/dist/StatusCard.d.ts +9 -0
- package/dist/StatusCard.js +63 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +7 -0
- package/dist/internal/Separator.d.ts +7 -0
- package/dist/internal/Separator.js +15 -0
- package/dist/internal/focusHighlight.d.ts +16 -0
- package/dist/internal/focusHighlight.js +57 -0
- package/dist/internal/theme.d.ts +23 -0
- package/dist/internal/theme.js +73 -0
- package/dist/useRemoteJson.d.ts +6 -0
- package/dist/useRemoteJson.js +49 -0
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ import { AnchoredDropdown } from "@moi952/decky-ui-kit";
|
|
|
56
56
|
| `onChange` | `(value: string) => void` | — | Called with the new value (or comma-joined list, in `multiple` mode). |
|
|
57
57
|
| `variant` | `"row" \| "boxed"` | `"boxed"` | `"row"`: flat, matches surrounding list rows. `"boxed"`: bordered box with an arrow. |
|
|
58
58
|
| `focusStyle` | `"fill" \| "outline"` | `"fill"` | `"fill"`: solid white background on focus. `"outline"`: transparent border that fills on focus. |
|
|
59
|
-
| `size` | `"
|
|
59
|
+
| `size` | `"small" \| "medium" \| "large"` | `"small"` | Row/trigger height and font size — same scale as `ActionButton`/`FieldTextInput`. |
|
|
60
60
|
| `bgColor` | `string` | Steam-like dark gray | Background color. |
|
|
61
61
|
| `textColor` | `string` | Steam-like light gray | Text color. |
|
|
62
62
|
| `borderColor` | `string` | `"transparent"` | Trigger and list border color. |
|
|
@@ -79,7 +79,7 @@ The list's corner radius is read at runtime from the trigger's own computed `bor
|
|
|
79
79
|
|
|
80
80
|
### `CollapsibleSection`
|
|
81
81
|
|
|
82
|
-
An expand/collapse row
|
|
82
|
+
An expand/collapse row, for tucking secondary content (settings, history, details) behind a single toggleable header. Two looks, picked with `variant`: `"field"` (default) is built on `Field` — native Steam padding/highlight/separator, right for a settings-page-style toggle. `"group-header"` is a flat, transparent, uppercase trigger with an optional icon+count instead — a collapsible category header for a list (e.g. a game list grouped by status), not a settings row.
|
|
83
83
|
|
|
84
84
|
```tsx
|
|
85
85
|
import { CollapsibleSection } from "@moi952/decky-ui-kit";
|
|
@@ -89,15 +89,36 @@ import { CollapsibleSection } from "@moi952/decky-ui-kit";
|
|
|
89
89
|
</CollapsibleSection>
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
+
```tsx
|
|
93
|
+
import { FiCheckCircle } from "react-icons/fi";
|
|
94
|
+
|
|
95
|
+
<CollapsibleSection
|
|
96
|
+
variant="group-header"
|
|
97
|
+
label="Ready"
|
|
98
|
+
icon={FiCheckCircle}
|
|
99
|
+
iconColor="#4caf50"
|
|
100
|
+
count={12}
|
|
101
|
+
expanded={expanded}
|
|
102
|
+
onToggle={() => setExpanded(!expanded)}
|
|
103
|
+
>
|
|
104
|
+
{games.map((g) => <GameRow key={g.id} game={g} />)}
|
|
105
|
+
</CollapsibleSection>
|
|
106
|
+
```
|
|
107
|
+
|
|
92
108
|
<details>
|
|
93
109
|
<summary>Props</summary>
|
|
94
110
|
|
|
95
111
|
| Prop | Type | Default | Description |
|
|
96
112
|
| --- | --- | --- | --- |
|
|
97
|
-
| `label` | `
|
|
113
|
+
| `label` | `ReactNode` | — | Header text. |
|
|
98
114
|
| `expanded` | `boolean` | — | Whether the children are shown. State is owned by the caller. |
|
|
99
115
|
| `onToggle` | `() => void` | — | Called on click/activate; flip `expanded` in response. |
|
|
100
116
|
| `children` | `ReactNode` | — | Rendered below the header while `expanded` is `true`. |
|
|
117
|
+
| `variant` | `"field" \| "group-header"` | `"field"` | `"field"`: native `Field`-based row. `"group-header"`: flat, transparent, uppercase trigger with an optional icon+count — a fixed look, no color/size props of its own. |
|
|
118
|
+
| `contentBottomSeparator` | `boolean` | `false` | `"field"` variant only. A second separator drawn after the expanded content, mirroring the one `Field`'s own `bottomSeparator` already draws before it. |
|
|
119
|
+
| `icon` | `IconType` | — | `"group-header"` variant only. An icon (from `react-icons`) shown before the label. |
|
|
120
|
+
| `iconColor` | `string` | `"#888"` | `"group-header"` variant only. Color for `icon`. |
|
|
121
|
+
| `count` | `number` | — | `"group-header"` variant only. A small counter shown after the label (e.g. how many items are in this group). Omitted entirely when not passed. |
|
|
101
122
|
|
|
102
123
|
</details>
|
|
103
124
|
|
|
@@ -119,7 +140,7 @@ import { FieldTextInput } from "@moi952/decky-ui-kit";
|
|
|
119
140
|
| `value` | `string` | — | Current value. |
|
|
120
141
|
| `onChange` | `(value: string) => void` | — | Called with the new value on every keystroke. |
|
|
121
142
|
| `label` | `ReactNode` | — | Label text/content. |
|
|
122
|
-
| `size` | `"
|
|
143
|
+
| `size` | `"small" \| "medium" \| "large"` | `"medium"` | Input font size and padding — same scale as `ActionButton`/`AnchoredDropdown`. |
|
|
123
144
|
| `labelPosition` | `"top" \| "left" \| "right"` | `"top"` | Where the label sits relative to the input. |
|
|
124
145
|
| `mustBeNumeric` | `boolean` | `false` | Restricts input to numeric characters. |
|
|
125
146
|
| `bottomSeparator` | `boolean` | `true` | Native Steam separator line below the row. |
|
|
@@ -130,6 +151,52 @@ import { FieldTextInput } from "@moi952/decky-ui-kit";
|
|
|
130
151
|
|
|
131
152
|
</details>
|
|
132
153
|
|
|
154
|
+
### `InfoTable`
|
|
155
|
+
|
|
156
|
+
A bordered, rounded key/value table for a single entity's details — icon, short label, value right-aligned. Built for a detail screen (an app, a package, a save file, ...) sitting below its header: version, source, file path, and so on, one row each. A row's `accent` color (e.g. green for an available update) tints both its icon and its value.
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
import { InfoTable } from "@moi952/decky-ui-kit";
|
|
160
|
+
import { FiTag, FiUpload, FiFile } from "react-icons/fi";
|
|
161
|
+
|
|
162
|
+
<InfoTable
|
|
163
|
+
rows={[
|
|
164
|
+
{ icon: <FiTag size={13} />, label: "Version", value: "1.4.2" },
|
|
165
|
+
{
|
|
166
|
+
icon: <FiUpload size={13} />,
|
|
167
|
+
label: "Available",
|
|
168
|
+
value: "1.5.0",
|
|
169
|
+
accent: "#4caf50",
|
|
170
|
+
},
|
|
171
|
+
{ icon: <FiFile size={13} />, label: "Path", value: "/home/deck/App.AppImage" },
|
|
172
|
+
]}
|
|
173
|
+
/>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
<details>
|
|
177
|
+
<summary>Props</summary>
|
|
178
|
+
|
|
179
|
+
| Prop | Type | Default | Description |
|
|
180
|
+
| --- | --- | --- | --- |
|
|
181
|
+
| `rows` | `InfoTableRow[]` | — | The rows to render, top to bottom. |
|
|
182
|
+
| `labelWidth` | `number` | `90` | Label column width — every row's value starts at this same x position. |
|
|
183
|
+
| `labelColor` | `string` | Steam-like light gray | Label text color. |
|
|
184
|
+
| `iconColor` | `string` | Steam-like dark gray | A row's icon color, when it has no `accent`. |
|
|
185
|
+
| `valueColor` | `string` | `"#fff"` | A row's value color, when it has no `accent`. |
|
|
186
|
+
| `bgColor` | `string` | Steam-like dark, translucent | Table background. |
|
|
187
|
+
| `borderColor` | `string` | Steam-like dark, translucent | Table border. |
|
|
188
|
+
|
|
189
|
+
`InfoTableRow`:
|
|
190
|
+
|
|
191
|
+
| Field | Type | Description |
|
|
192
|
+
| --- | --- | --- |
|
|
193
|
+
| `icon` | `ReactNode` | — |
|
|
194
|
+
| `label` | `ReactNode` | Short label on the left (fixed width, so values stay aligned across rows). |
|
|
195
|
+
| `value` | `ReactNode` | Right-aligned; wraps on overflow rather than clipping. |
|
|
196
|
+
| `accent` | `string` | Tints this row's icon and value (default: neutral gray icon, white value). |
|
|
197
|
+
|
|
198
|
+
</details>
|
|
199
|
+
|
|
133
200
|
### `InlineConfirm`
|
|
134
201
|
|
|
135
202
|
A destructive-action confirmation shown inline, right below whatever triggered it — not a modal. A description line plus an equal-width Cancel/Confirm button pair. No i18n of its own — pass your own translated labels.
|
|
@@ -161,3 +228,169 @@ import { InlineConfirm } from "@moi952/decky-ui-kit";
|
|
|
161
228
|
| `variant` | `"danger" \| "primary"` | `"danger"` | Red confirm button for a destructive action, or blue for a plain confirm. |
|
|
162
229
|
|
|
163
230
|
</details>
|
|
231
|
+
|
|
232
|
+
### `MediaRow`
|
|
233
|
+
|
|
234
|
+
A focusable media+title(+details)(+actions) row. The same shape covers both "a list of apps, each with a status stack and inline Update/Exclude buttons" and "a grid of game capsules, each just a cover and a title" — which of the two a given instance looks like follows entirely from which props are passed: give it `actions` and it splits into a header + a separate collapsible action row; leave `actions` out and the whole thing is one single-press card. `mediaLayout="stretch"` swaps the centered-icon box for a fixed-height, auto-width cover-image box instead of the icon's centered square — the media sizes itself from its own aspect ratio, so it's never cropped.
|
|
235
|
+
|
|
236
|
+
```tsx
|
|
237
|
+
import { MediaRow } from "@moi952/decky-ui-kit";
|
|
238
|
+
import { FiEyeOff } from "react-icons/fi";
|
|
239
|
+
|
|
240
|
+
// A status-stack app row, with an inline action row
|
|
241
|
+
<MediaRow
|
|
242
|
+
media={<img src={iconUrl} style={{ maxWidth: "100%", maxHeight: "100%" }} />}
|
|
243
|
+
title="Firefox"
|
|
244
|
+
details={
|
|
245
|
+
<div style={{ fontSize: 11, color: "#9aa1a8" }}>128.0</div>
|
|
246
|
+
}
|
|
247
|
+
onPress={() => openDetails()}
|
|
248
|
+
actions={
|
|
249
|
+
<ActionButton onClick={exclude}><FiEyeOff size={12} /></ActionButton>
|
|
250
|
+
}
|
|
251
|
+
color="transparent"
|
|
252
|
+
bottomSeparator
|
|
253
|
+
/>
|
|
254
|
+
|
|
255
|
+
// A cover-image capsule, no actions row at all
|
|
256
|
+
<MediaRow
|
|
257
|
+
mediaLayout="stretch"
|
|
258
|
+
mediaHeight={37}
|
|
259
|
+
media={<img src={coverUrl} style={{ height: "100%", width: "auto" }} />}
|
|
260
|
+
title="Half-Life 2"
|
|
261
|
+
titleLines={2}
|
|
262
|
+
onPress={() => launch()}
|
|
263
|
+
spacing={4}
|
|
264
|
+
color="light"
|
|
265
|
+
/>
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
<details>
|
|
269
|
+
<summary>Props</summary>
|
|
270
|
+
|
|
271
|
+
| Prop | Type | Default | Description |
|
|
272
|
+
| --- | --- | --- | --- |
|
|
273
|
+
| `media` | `ReactNode` | — | The leading visual — an `<img>`, a placeholder, badges overlaid on it. This component only sizes/positions the box around it. |
|
|
274
|
+
| `mediaWidth` | `number` | `32` | Media box width — only used by `mediaLayout="fixed"`. |
|
|
275
|
+
| `mediaHeight` | `number` | `32` | Media box height. |
|
|
276
|
+
| `mediaLayout` | `"fixed" \| "stretch"` | `"fixed"` | `"fixed"`: media centered in an exact `mediaWidth`×`mediaHeight` box (a small icon). `"stretch"`: exactly `mediaHeight` tall, but no fixed width at all — the media renders at whatever width its own aspect ratio calls for at that height (e.g. `<img style={{ height: "100%", width: "auto" }} />`), so a cover image always shows in full. |
|
|
277
|
+
| `mediaAlign` | `"top" \| "center" \| "bottom"` | `"center"` for `mediaLayout="fixed"`, `"top"` for `"stretch"` | Where the fixed-height media box sits once `titleLines > 1` makes the row taller than `mediaHeight`. The default matches each layout's own prior look exactly (before this prop existed), so it's opt-in, not a behavior change. |
|
|
278
|
+
| `title` | `ReactNode` | — | The row's title. |
|
|
279
|
+
| `titleLines` | `number` | `1` | `1`: ellipsis-truncated single line. `>1`: line-clamped over that many lines. |
|
|
280
|
+
| `details` | `ReactNode` | — | Extra content under the title — your own pre-colored status line(s). Omit for a title-only row. |
|
|
281
|
+
| `onPress` | `() => void` | — | Called when the header is pressed. |
|
|
282
|
+
| `actions` | `ReactNode` | — | Rendered in its own row below the header, inside a `Focusable`. Omit entirely for a single-button card with no action row. Given without `onPress`, pressing the header toggles this row instead of navigating. |
|
|
283
|
+
| `collapsedByDefault` | `boolean` | `false` | Only relevant when `actions` is given and `onPress` isn't — starts with the actions row hidden until the header is pressed once. |
|
|
284
|
+
| `color` | `"light" \| "dark" \| "transparent" \| "success" \| "danger" \| "info" \| "warning"` | — (required) | The row's own look — border + matching background. There's no "no color" state, so a row's border width never shifts depending on which color a sibling happens to have. `"light"`/`"dark"` are the two plain card backgrounds with no state implied; `"transparent"` is for a flush row inside a `bottomSeparator` list, which must show no card look of its own; the rest are accent colors for flagging a real state (e.g. `"success"` for "currently active"). |
|
|
285
|
+
| `accentBorderColor` | `string` | — | Overrides `color`'s border color. |
|
|
286
|
+
| `accentBorderWidth` | `number` | `2` | Border width — the same value applies to every color, so a row's size never shifts between states. |
|
|
287
|
+
| `accentBackground` | `string` | — | Overrides `color`'s background color. |
|
|
288
|
+
| `borderOnFocus` | `boolean` | `true` | A real border on focus/hover, via an inset box-shadow (not `outline` — outline doesn't respect border-radius). Independent of `highlightOnFocus` below — same convention as `ScreenshotCarousel`'s own `borderOnFocus`. |
|
|
289
|
+
| `highlightColor` | `string` | `"#dcdedf"` | Border color on focus/hover (used when `borderOnFocus`). Same default across every focusable component in this library. |
|
|
290
|
+
| `highlightOnFocus` | `boolean` | `true` | A background tint on focus/hover, independent of `borderOnFocus` above. |
|
|
291
|
+
| `highlightBackground` | `string` | `"#2a3a4a"` | Background color on focus/hover (used when `highlightOnFocus`). |
|
|
292
|
+
| `spacing` | `number` | `0` | Gap below the row, for a list of spaced-apart cards. An alternative to `bottomSeparator`, not meant combined with it. |
|
|
293
|
+
| `bottomSeparator` | `boolean` | `false` | A bottom divider line, for a continuous divided list — the alternative to `spacing`. Pair with `color="transparent"` so the row shows no card background of its own, just the divider and the focus highlight. |
|
|
294
|
+
| `onSecondaryButton` | `(evt) => void` | — | Fires on gamepad X / Steam "Secondary" while the row has focus. |
|
|
295
|
+
| `onSecondaryActionDescription` | `ReactNode` | — | Shown in Steam's own bottom action-legend bar next to the X prompt (only while `onSecondaryButton` is set). |
|
|
296
|
+
|
|
297
|
+
</details>
|
|
298
|
+
|
|
299
|
+
### `QrCodeButton`
|
|
300
|
+
|
|
301
|
+
A collapsible section (built on `CollapsibleSection`) that reveals a QR code on expand — for handing a URL off to the user's phone (a feedback form, a release page, ...) instead of them typing it on a gamepad. The revealed code is itself a real gamepad-focusable button — pressing it opens the URL directly in Steam's own browser overlay, for anyone who'd rather not reach for their phone.
|
|
302
|
+
|
|
303
|
+
```tsx
|
|
304
|
+
import { QrCodeButton } from "@moi952/decky-ui-kit";
|
|
305
|
+
|
|
306
|
+
<QrCodeButton
|
|
307
|
+
value="https://github.com/moi952/decky-proton-launch/issues"
|
|
308
|
+
label="Suggest a feature"
|
|
309
|
+
hint="Scan with your phone"
|
|
310
|
+
/>
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
<details>
|
|
314
|
+
<summary>Props</summary>
|
|
315
|
+
|
|
316
|
+
| Prop | Type | Default | Description |
|
|
317
|
+
| --- | --- | --- | --- |
|
|
318
|
+
| `value` | `string` | — | The URL (or any text) encoded into the QR code. |
|
|
319
|
+
| `label` | `ReactNode` | — | Collapsible section header text. |
|
|
320
|
+
| `hint` | `ReactNode` | — | Shown under the code once revealed. |
|
|
321
|
+
| `qrSize` | `number` | `160` | QR code size in pixels. |
|
|
322
|
+
| `borderOnFocus` | `boolean` | `true` | A real border on focus/hover — same convention as `MediaRow`'s own `borderOnFocus`. |
|
|
323
|
+
| `highlightColor` | `string` | `"#2a3a4a"` | Border color on focus/hover (used when `borderOnFocus`). Darker than `MediaRow`'s own default (`"#dcdedf"`, invisible against this component's white QR panel), but the same shared `DEFAULT_HIGHLIGHT_BACKGROUND` constant used elsewhere in this library — not an arbitrary one-off color. |
|
|
324
|
+
| `highlightOnFocus` | `boolean` | `false` | A background tint on focus/hover, independent of `borderOnFocus` above. Off by default here (unlike `MediaRow`'s own `true`): the panel is deliberately white to keep the QR code scannable, and the shared default tint would wash out over it. |
|
|
325
|
+
| `highlightBackground` | `string` | `"#2a3a4a"` | Background color on focus/hover (used when `highlightOnFocus`). |
|
|
326
|
+
|
|
327
|
+
</details>
|
|
328
|
+
|
|
329
|
+
### `ScreenshotCarousel`
|
|
330
|
+
|
|
331
|
+
A single screenshot "stage" — app store/catalog "photos", one shown at a time, reading as one pressable card (same rounded corners, same `bottomSeparator`/focus-border conventions as `MediaRow`). Moved with DIR_LEFT/DIR_RIGHT or LB/RB (advertised in Steam's own bottom action-legend bar) — no on-screen prev/next buttons on this inline view, those only live in the full-screen zoom pressing the photo opens (a real Steam modal, via `showModal`/`ModalRoot`). Renders nothing at all when `screenshots` is empty, so a caller never needs its own length check around it.
|
|
332
|
+
|
|
333
|
+
```tsx
|
|
334
|
+
import { ScreenshotCarousel } from "@moi952/decky-ui-kit";
|
|
335
|
+
|
|
336
|
+
<ScreenshotCarousel screenshots={entry.screenshots} height={140} />
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
<details>
|
|
340
|
+
<summary>Props</summary>
|
|
341
|
+
|
|
342
|
+
| Prop | Type | Default | Description |
|
|
343
|
+
| --- | --- | --- | --- |
|
|
344
|
+
| `screenshots` | `string[]` | — | Image URLs (or data URIs). Renders nothing when empty. |
|
|
345
|
+
| `height` | `number` | `120` | Height of the inline (non-zoomed) view. |
|
|
346
|
+
| `bottomSeparator` | `boolean` | `false` | A bottom divider line, for sitting inside a continuous divided list — same convention as `MediaRow`'s own `bottomSeparator`. |
|
|
347
|
+
| `borderOnFocus` | `boolean` | `true` | A real border on focus/hover, via an inset box-shadow (not `outline`). Independent of `highlightOnFocus` below — same convention as `MediaRow`'s own `borderOnFocus`. |
|
|
348
|
+
| `highlightColor` | `string` | `"#dcdedf"` | Border color on focus/hover (used when `borderOnFocus`). Same default across every focusable component in this library. |
|
|
349
|
+
| `highlightOnFocus` | `boolean` | `true` | A background tint behind the stage on focus/hover (only visible where the photo doesn't already fill the box), independent of `borderOnFocus` above. |
|
|
350
|
+
| `highlightBackground` | `string` | `"#2a3a4a"` | Background color on focus/hover (used when `highlightOnFocus`). |
|
|
351
|
+
| `prevActionDescription` | `ReactNode` | `"Previous"` | Shown in Steam's own bottom action-legend bar next to the LB prompt (only while there's more than one screenshot). |
|
|
352
|
+
| `nextActionDescription` | `ReactNode` | `"Next"` | Shown next to the RB prompt. |
|
|
353
|
+
|
|
354
|
+
</details>
|
|
355
|
+
|
|
356
|
+
### `StatusCard`
|
|
357
|
+
|
|
358
|
+
A finished-state card — "done, here's what happened" — for after an update/install/check completes. `variant="info"` is the odd one out: not a finished-state verdict, a plain announcement/notice instead (e.g. "check out my other plugins"), same card look, neutral blue. Colors and layout match the hand-rolled success/error/notice cards several Decky plugins had already converged on independently. No first-class dismiss-button prop — the same `children` slot that already fits a "Reboot now"/"Try again" action fits a dismiss button just as well (render one, e.g. `ActionButton`, straight into `children`).
|
|
359
|
+
|
|
360
|
+
```tsx
|
|
361
|
+
import { StatusCard } from "@moi952/decky-ui-kit";
|
|
362
|
+
|
|
363
|
+
<StatusCard title="Everything is up to date" />
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
<details>
|
|
367
|
+
<summary>Props</summary>
|
|
368
|
+
|
|
369
|
+
| Prop | Type | Default | Description |
|
|
370
|
+
| --- | --- | --- | --- |
|
|
371
|
+
| `variant` | `"success" \| "error" \| "info"` | `"success"` | Icon/text/border color. |
|
|
372
|
+
| `title` | `ReactNode` | — | Bold headline. |
|
|
373
|
+
| `description` | `ReactNode` | — | Smaller text below the title. |
|
|
374
|
+
| `icon` | `ReactNode` | A check/X/info circle matching `variant` | Overrides the default icon. |
|
|
375
|
+
| `children` | `ReactNode` | — | Rendered below the description — e.g. a "Reboot now"/"Try again"/"Got it" action or dismiss button. |
|
|
376
|
+
|
|
377
|
+
</details>
|
|
378
|
+
|
|
379
|
+
## Hooks
|
|
380
|
+
|
|
381
|
+
### `useRemoteJson`
|
|
382
|
+
|
|
383
|
+
Fetches and JSON-parses a URL once, keeping the result in memory for a TTL (default 12h) so every component calling this with the same URL during that window reuses the same result instead of re-fetching. Never throws into the caller — a failed fetch (offline, CDN hiccup, ...) just leaves `data` null and `error` true.
|
|
384
|
+
|
|
385
|
+
```tsx
|
|
386
|
+
import { useRemoteJson } from "@moi952/decky-ui-kit";
|
|
387
|
+
|
|
388
|
+
const { data, loading, error } = useRemoteJson<MyType>("https://cdn.jsdelivr.net/gh/user/repo@main/data.json");
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
| Param | Type | Default | Description |
|
|
392
|
+
| --- | --- | --- | --- |
|
|
393
|
+
| `url` | `string` | — | Fetched with a plain `fetch(url).then(r => r.json())` — same-origin/CORS rules apply like any other `fetch` call. |
|
|
394
|
+
| `ttlMs` | `number` | `43200000` (12h) | How long a successful result is reused before the next mount re-fetches. |
|
|
395
|
+
|
|
396
|
+
Returns `{ data: T \| null, loading: boolean, error: boolean }`.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FooterLegendProps } from "@decky/ui";
|
|
3
|
+
import { ComponentSize } from "./internal/theme";
|
|
4
|
+
type GamepadEvt = Parameters<NonNullable<FooterLegendProps["onSecondaryButton"]>>[0];
|
|
5
|
+
export interface ActionButtonProps {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
onClick: () => void;
|
|
8
|
+
size?: ComponentSize;
|
|
9
|
+
variant?: "normal" | "bordered" | "danger" | "primary";
|
|
10
|
+
width?: string | number;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
onSecondaryButton?: (evt: GamepadEvt) => void;
|
|
13
|
+
onSecondaryActionDescription?: React.ReactNode;
|
|
14
|
+
onOptionsButton?: (evt: GamepadEvt) => void;
|
|
15
|
+
onOptionsActionDescription?: React.ReactNode;
|
|
16
|
+
onMenuButton?: (evt: GamepadEvt) => void;
|
|
17
|
+
onMenuActionDescription?: React.ReactNode;
|
|
18
|
+
onOKButton?: (evt: GamepadEvt) => void;
|
|
19
|
+
onOKActionDescription?: React.ReactNode;
|
|
20
|
+
}
|
|
21
|
+
export declare const ActionButton: React.FC<ActionButtonProps>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DialogButton } from "@decky/ui";
|
|
3
|
+
import { ACCENT_DANGER, ACCENT_INFO, SIZE_STYLE } from "./internal/theme";
|
|
4
|
+
// Padding only — vertical rhythm (fontSize/minHeight) comes from the
|
|
5
|
+
// shared SIZE_STYLE table instead, the same one FieldTextInput and
|
|
6
|
+
// AnchoredDropdown's own trigger use, so all three actually line up
|
|
7
|
+
// instead of each deriving a close-but-not-guaranteed height from their
|
|
8
|
+
// own padding+font independently.
|
|
9
|
+
const PADDING_V = { small: 4, medium: 6, large: 8 };
|
|
10
|
+
const PADDING_H = { small: 8, medium: 12, large: 16 };
|
|
11
|
+
const SOLID_VARIANT_COLOR = {
|
|
12
|
+
danger: ACCENT_DANGER,
|
|
13
|
+
primary: ACCENT_INFO,
|
|
14
|
+
};
|
|
15
|
+
// Never sets its own border-radius, for any variant — Steam's own native
|
|
16
|
+
// DialogButton chrome already gives every button a sensible radius on
|
|
17
|
+
// its own (a CSSLoader "round corners" theme controls it same as
|
|
18
|
+
// anywhere else), so there's nothing for this component to add or
|
|
19
|
+
// override there.
|
|
20
|
+
export const ActionButton = ({ children, onClick, size = "small", variant = "normal", width, disabled, onSecondaryButton, onSecondaryActionDescription, onOptionsButton, onOptionsActionDescription, onMenuButton, onMenuActionDescription, onOKButton, onOKActionDescription, }) => {
|
|
21
|
+
const { fontSize, minHeight } = SIZE_STYLE[size];
|
|
22
|
+
const style = {
|
|
23
|
+
padding: `${PADDING_V[size]}px ${PADDING_H[size]}px`,
|
|
24
|
+
fontSize,
|
|
25
|
+
minHeight,
|
|
26
|
+
// Reserved for every variant that gets a background override below
|
|
27
|
+
// (bordered/danger/primary) — even the ones with no visible border
|
|
28
|
+
// of their own (danger/primary) still occupy the same 1px of
|
|
29
|
+
// box-model space "bordered" uses for its own real one, so all
|
|
30
|
+
// three add up to the exact same height instead of "bordered" alone
|
|
31
|
+
// needing 2px more room than the others at the same size. "normal"
|
|
32
|
+
// stays fully untouched, per its own documented promise above — no
|
|
33
|
+
// override at all, not even an invisible one.
|
|
34
|
+
...(variant !== "normal" ? { border: "1px solid transparent" } : {}),
|
|
35
|
+
};
|
|
36
|
+
const cls = variant !== "normal" ? `dck-action-btn-${variant}` : undefined;
|
|
37
|
+
return (_jsxs(_Fragment, { children: [variant === "bordered" && (_jsx("style", { children: `
|
|
38
|
+
.dck-action-btn-bordered {
|
|
39
|
+
background: rgba(255, 255, 255, 0.08) !important;
|
|
40
|
+
border-color: rgba(255, 255, 255, 0.18) !important;
|
|
41
|
+
}
|
|
42
|
+
.dck-action-btn-bordered:focus,
|
|
43
|
+
.dck-action-btn-bordered:hover {
|
|
44
|
+
background: #dcdedf !important;
|
|
45
|
+
color: #000 !important;
|
|
46
|
+
border-color: #dcdedf !important;
|
|
47
|
+
}
|
|
48
|
+
.dck-action-btn-bordered:disabled,
|
|
49
|
+
.dck-action-btn-bordered[disabled] {
|
|
50
|
+
opacity: 1 !important;
|
|
51
|
+
background: #2a2e35 !important;
|
|
52
|
+
border-color: rgba(255, 255, 255, 0.15) !important;
|
|
53
|
+
color: #6b7076 !important;
|
|
54
|
+
}
|
|
55
|
+
` })), (variant === "danger" || variant === "primary") && (_jsx("style", { children: `
|
|
56
|
+
.dck-action-btn-${variant} {
|
|
57
|
+
background-color: ${SOLID_VARIANT_COLOR[variant]} !important;
|
|
58
|
+
color: #fff !important;
|
|
59
|
+
}
|
|
60
|
+
.dck-action-btn-${variant}:focus,
|
|
61
|
+
.dck-action-btn-${variant}:hover {
|
|
62
|
+
background-color: #fff !important;
|
|
63
|
+
color: ${SOLID_VARIANT_COLOR[variant]} !important;
|
|
64
|
+
}
|
|
65
|
+
` })), _jsx(DialogButton, { className: cls, style: {
|
|
66
|
+
...style,
|
|
67
|
+
// Without this, sizing is content-box by default (the
|
|
68
|
+
// browser's own native default) — padding would add on top of
|
|
69
|
+
// minHeight instead of being absorbed inside it.
|
|
70
|
+
boxSizing: "border-box",
|
|
71
|
+
display: "inline-flex",
|
|
72
|
+
alignItems: "center",
|
|
73
|
+
justifyContent: "center",
|
|
74
|
+
width: width ?? "fit-content",
|
|
75
|
+
minWidth: "unset",
|
|
76
|
+
}, onClick: onClick, disabled: disabled, onSecondaryButton: onSecondaryButton, onSecondaryActionDescription: onSecondaryActionDescription, onOptionsButton: onOptionsButton, onOptionsActionDescription: onOptionsActionDescription, onMenuButton: onMenuButton, onMenuActionDescription: onMenuActionDescription, onOKButton: onOKButton, onOKActionDescription: onOKActionDescription, children: children })] }));
|
|
77
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { ComponentSize } from "./internal/theme";
|
|
2
3
|
interface DropdownOption {
|
|
3
4
|
value: string;
|
|
4
5
|
label: string;
|
|
@@ -7,9 +8,10 @@ export interface AnchoredDropdownProps {
|
|
|
7
8
|
options: DropdownOption[];
|
|
8
9
|
selectedValue: string;
|
|
9
10
|
onChange: (value: string) => void;
|
|
11
|
+
label?: React.ReactNode;
|
|
10
12
|
variant?: "row" | "boxed";
|
|
11
13
|
focusStyle?: "fill" | "outline";
|
|
12
|
-
size?:
|
|
14
|
+
size?: ComponentSize;
|
|
13
15
|
bgColor?: string;
|
|
14
16
|
textColor?: string;
|
|
15
17
|
borderColor?: string;
|
package/dist/AnchoredDropdown.js
CHANGED
|
@@ -2,10 +2,26 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
3
3
|
import { DialogButton, Field, Focusable, GamepadButton } from "@decky/ui";
|
|
4
4
|
import { FaChevronDown, FaChevronRight, FaCheck } from "react-icons/fa";
|
|
5
|
-
|
|
5
|
+
import { DEFAULT_PANEL_BACKGROUND, SIZE_STYLE } from "./internal/theme";
|
|
6
|
+
const DEFAULT_BG = DEFAULT_PANEL_BACKGROUND;
|
|
6
7
|
const DEFAULT_TEXT = "#bfbfbf";
|
|
7
8
|
const DEFAULT_BORDER = "transparent";
|
|
8
9
|
const FALLBACK_RADIUS = "6px";
|
|
10
|
+
// The trigger's own horizontal padding/vertical rhythm — fontSize and
|
|
11
|
+
// minHeight (the actual height-determining values) come from the shared
|
|
12
|
+
// SIZE_STYLE table instead (see internal/theme.ts), the same one
|
|
13
|
+
// ActionButton/FieldTextInput use, so this trigger lines up with them at
|
|
14
|
+
// "the same size" instead of merely resembling it — but only ever grows
|
|
15
|
+
// from there (min-height, not height), so a long selected-value label
|
|
16
|
+
// wrapping to 2+ lines (see maxDisplayLines) still has room to grow into
|
|
17
|
+
// instead of getting clipped. The open option list below stays on its
|
|
18
|
+
// own separate scale (OPTION_PADDING/OPTION_FONT_SIZE) — it has no
|
|
19
|
+
// reason to match an external row's height.
|
|
20
|
+
const TRIGGER_PADDING_V = { small: 6, medium: 10, large: 14 };
|
|
21
|
+
const TRIGGER_PADDING_H = { small: 10, medium: 14, large: 18 };
|
|
22
|
+
const OPTION_PADDING = { small: "4px 8px", medium: "10px 14px", large: "12px 16px" };
|
|
23
|
+
const OPTION_FONT_SIZE = { small: "11px", medium: "14px", large: "16px" };
|
|
24
|
+
const OPTION_ROW_HEIGHT = { small: 26, medium: 42, large: 48 };
|
|
9
25
|
// Shared across instances so "row" reuses a "boxed" one's measured radius.
|
|
10
26
|
let sharedBoxedRadius = null;
|
|
11
27
|
let uidCounter = 0;
|
|
@@ -21,7 +37,7 @@ const toggleCsv = (csv, value, options) => {
|
|
|
21
37
|
.join(",");
|
|
22
38
|
};
|
|
23
39
|
// Native Steam popups reset the panel on close — this is an inline overlay instead.
|
|
24
|
-
export const AnchoredDropdown = ({ options, selectedValue, onChange, variant = "boxed", focusStyle = "fill", size = "
|
|
40
|
+
export const AnchoredDropdown = ({ options, selectedValue, onChange, label, variant = "boxed", focusStyle = "fill", size = "medium", bgColor = DEFAULT_BG, textColor = DEFAULT_TEXT, borderColor = DEFAULT_BORDER, blurBackground = true, multiple = false, selectedValuesLayout = "inline", selectedCountLabel, onSecondaryButton, onSecondaryActionDescription, onOptionsButton, onOptionsActionDescription, maxDisplayLines = 1, maxVisibleOptions, highlightOnFocus = true, bottomSeparator = true, }) => {
|
|
25
41
|
// Scoped per instance so sibling dropdowns don't share class names.
|
|
26
42
|
const [uid] = useState(() => `dck-anchored-dd${uidCounter++}`);
|
|
27
43
|
const [expanded, setExpanded] = useState(false);
|
|
@@ -38,7 +54,7 @@ export const AnchoredDropdown = ({ options, selectedValue, onChange, variant = "
|
|
|
38
54
|
if (variant !== "boxed" || !triggerRef.current)
|
|
39
55
|
return;
|
|
40
56
|
const el = triggerRef.current;
|
|
41
|
-
const horizontalPadding = size
|
|
57
|
+
const horizontalPadding = TRIGGER_PADDING_H[size];
|
|
42
58
|
const overhead = horizontalPadding * 2 + 12 + 8;
|
|
43
59
|
const measure = () => setLabelMaxWidth(Math.max(0, el.clientWidth - overhead));
|
|
44
60
|
measure();
|
|
@@ -119,7 +135,7 @@ export const AnchoredDropdown = ({ options, selectedValue, onChange, variant = "
|
|
|
119
135
|
}
|
|
120
136
|
};
|
|
121
137
|
// Padding + line-height + the option's 2px border.
|
|
122
|
-
const rowHeight = size
|
|
138
|
+
const rowHeight = OPTION_ROW_HEIGHT[size];
|
|
123
139
|
// 0 means "show every option, no scroll cap".
|
|
124
140
|
const listMaxHeight = maxVisibleOptions === 0 ? undefined : maxVisibleOptions ? maxVisibleOptions * (rowHeight + 2) : 220;
|
|
125
141
|
const toggle = () => {
|
|
@@ -140,11 +156,10 @@ export const AnchoredDropdown = ({ options, selectedValue, onChange, variant = "
|
|
|
140
156
|
const triggerLabelCls = `${uid}-trigger-label`;
|
|
141
157
|
const countCls = `${uid}-count`;
|
|
142
158
|
const wrapperCls = `${uid}-wrapper`;
|
|
143
|
-
const optionPadding = size
|
|
144
|
-
const optionFontSize = size
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
const triggerFontSize = size === "small" ? "12px" : "15px";
|
|
159
|
+
const optionPadding = OPTION_PADDING[size];
|
|
160
|
+
const optionFontSize = OPTION_FONT_SIZE[size];
|
|
161
|
+
const triggerPadding = `${TRIGGER_PADDING_V[size]}px ${TRIGGER_PADDING_H[size]}px`;
|
|
162
|
+
const { fontSize: triggerFontSize, minHeight: triggerMinHeight } = SIZE_STYLE[size];
|
|
148
163
|
return (_jsxs("div", { ref: wrapperRef, className: wrapperCls, style: { position: "relative", width: "100%", maxWidth: "100%", boxSizing: "border-box" }, children: [_jsx("style", { children: `
|
|
149
164
|
.${optionCls} {
|
|
150
165
|
box-sizing: border-box !important;
|
|
@@ -163,15 +178,15 @@ export const AnchoredDropdown = ({ options, selectedValue, onChange, variant = "
|
|
|
163
178
|
}
|
|
164
179
|
.${triggerCls} {
|
|
165
180
|
box-sizing: border-box !important;
|
|
166
|
-
width:
|
|
167
|
-
max-width:
|
|
168
|
-
margin: 3px !important;
|
|
181
|
+
width: 100% !important;
|
|
182
|
+
max-width: 100% !important;
|
|
169
183
|
display: flex !important;
|
|
170
184
|
justify-content: space-between !important;
|
|
171
185
|
align-items: center !important;
|
|
172
186
|
gap: 8px !important;
|
|
173
187
|
padding: ${triggerPadding} !important;
|
|
174
188
|
font-size: ${triggerFontSize} !important;
|
|
189
|
+
min-height: ${triggerMinHeight}px !important;
|
|
175
190
|
background: ${bgColor} !important;
|
|
176
191
|
border: 1px solid ${borderColor} !important;
|
|
177
192
|
color: ${textColor} !important;
|
|
@@ -235,11 +250,16 @@ export const AnchoredDropdown = ({ options, selectedValue, onChange, variant = "
|
|
|
235
250
|
` }), (() => {
|
|
236
251
|
const countNode = multiple && selectedCountLabel && selectedValues.length > 0 ? (_jsx("div", { className: countCls, children: selectedCountLabel(selectedValues.length) })) : null;
|
|
237
252
|
if (variant === "boxed") {
|
|
238
|
-
return (_jsx(Field, { focusable: true,
|
|
253
|
+
return (_jsx(Field, { focusable: true, label: label,
|
|
254
|
+
// Field's own default isn't "label sits above the
|
|
255
|
+
// control" — explicit here so a caller-supplied label
|
|
256
|
+
// renders on top, the same convention FieldTextInput's own
|
|
257
|
+
// labelPosition="top" already uses.
|
|
258
|
+
childrenLayout: label ? "below" : undefined, highlightOnFocus: highlightOnFocus, bottomSeparator: bottomSeparator ? "standard" : "none", childrenContainerWidth: "max", onActivate: toggle, onClick: toggle, onSecondaryButton: onSecondaryButton, onSecondaryActionDescription: onSecondaryButton ? onSecondaryActionDescription : undefined, onOptionsButton: onOptionsButton, onOptionsActionDescription: onOptionsButton ? onOptionsActionDescription : undefined, children: _jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 2, width: "100%" }, children: [countNode, _jsxs(DialogButton, { className: triggerCls, ref: (el) => {
|
|
239
259
|
triggerRef.current = el;
|
|
240
260
|
}, children: [_jsx("span", { className: triggerLabelCls, style: labelMaxWidth !== undefined ? { maxWidth: labelMaxWidth } : undefined, children: displayLabel }), _jsx(FaChevronDown, { size: 12, style: { flexShrink: 0 } })] })] }) }));
|
|
241
261
|
}
|
|
242
|
-
return (_jsx(Field, { focusable: true, highlightOnFocus: highlightOnFocus, bottomSeparator: bottomSeparator ? "standard" : "none", onActivate: toggle, onClick: toggle, onSecondaryButton: onSecondaryButton, onSecondaryActionDescription: onSecondaryButton ? onSecondaryActionDescription : undefined, onOptionsButton: onOptionsButton, onOptionsActionDescription: onOptionsButton ? onOptionsActionDescription : undefined, label: countNode ? (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 2, width: "100%" }, children: [countNode, displayLabel] })) : (displayLabel), childrenLayout: "inline", ref: (el) => {
|
|
262
|
+
return (_jsx(Field, { focusable: true, highlightOnFocus: highlightOnFocus, bottomSeparator: bottomSeparator ? "standard" : "none", onActivate: toggle, onClick: toggle, onSecondaryButton: onSecondaryButton, onSecondaryActionDescription: onSecondaryButton ? onSecondaryActionDescription : undefined, onOptionsButton: onOptionsButton, onOptionsActionDescription: onOptionsButton ? onOptionsActionDescription : undefined, label: label || countNode ? (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 2, width: "100%" }, children: [label, countNode, displayLabel] })) : (displayLabel), childrenLayout: "inline", ref: (el) => {
|
|
243
263
|
triggerRef.current = el;
|
|
244
264
|
}, children: expanded ? _jsx(FaChevronDown, { size: 12 }) : _jsx(FaChevronRight, { size: 12 }) }));
|
|
245
265
|
})(), expanded && blurBackground && (_jsx("div", { onClick: closeList, style: {
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { IconType } from "react-icons";
|
|
2
3
|
export interface CollapsibleSectionProps {
|
|
3
|
-
label:
|
|
4
|
+
label: React.ReactNode;
|
|
4
5
|
expanded: boolean;
|
|
5
6
|
onToggle: () => void;
|
|
6
7
|
children: React.ReactNode;
|
|
8
|
+
contentBottomSeparator?: boolean;
|
|
9
|
+
variant?: "field" | "group-header";
|
|
10
|
+
icon?: IconType;
|
|
11
|
+
iconColor?: string;
|
|
12
|
+
count?: number;
|
|
7
13
|
}
|
|
8
14
|
export declare const CollapsibleSection: React.FC<CollapsibleSectionProps>;
|
|
@@ -1,7 +1,43 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
2
|
-
import { Field } from "@decky/ui";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { DialogButton, Field } from "@decky/ui";
|
|
3
3
|
import { FaChevronDown, FaChevronRight } from "react-icons/fa";
|
|
4
|
+
import { FiChevronDown, FiChevronRight } from "react-icons/fi";
|
|
5
|
+
const DIVIDER_COLOR = "rgba(255, 255, 255, 0.08)";
|
|
6
|
+
// Scoped by module load, not per-instance — this variant's focus/hover
|
|
7
|
+
// look never varies by caller (no color/size props), so one shared class
|
|
8
|
+
// for every instance is simpler than InlineConfirm/QrCodeButton's own
|
|
9
|
+
// per-instance useId() pattern, and it's already how the original
|
|
10
|
+
// GameGroupHeader this variant reproduces did it.
|
|
11
|
+
const GROUP_HEADER_CLASS = "dck-collapsible-group-header";
|
|
12
|
+
const groupHeaderStyleTag = `
|
|
13
|
+
.${GROUP_HEADER_CLASS}:focus {
|
|
14
|
+
outline: 2px solid #dcdedf !important;
|
|
15
|
+
outline-offset: 0px !important;
|
|
16
|
+
background: #2a3a4a !important;
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
4
19
|
// Field is the generic building block Decky's own ToggleField/SliderField
|
|
5
20
|
// are built on — using it here gets native padding/separator for free,
|
|
6
21
|
// instead of approximating them with a hand-styled button.
|
|
7
|
-
export const CollapsibleSection = ({ label, expanded, onToggle, children,
|
|
22
|
+
export const CollapsibleSection = ({ label, expanded, onToggle, children, contentBottomSeparator = false, variant = "field", icon: Icon, iconColor = "#888", count, }) => {
|
|
23
|
+
if (variant === "group-header") {
|
|
24
|
+
return (_jsxs(_Fragment, { children: [_jsx("style", { children: groupHeaderStyleTag }), _jsxs(DialogButton, { className: GROUP_HEADER_CLASS, onClick: onToggle, style: {
|
|
25
|
+
width: "100%",
|
|
26
|
+
boxSizing: "border-box",
|
|
27
|
+
display: "flex",
|
|
28
|
+
alignItems: "center",
|
|
29
|
+
justifyContent: "space-between",
|
|
30
|
+
padding: "6px 10px",
|
|
31
|
+
marginBottom: "4px",
|
|
32
|
+
background: "transparent",
|
|
33
|
+
border: "none",
|
|
34
|
+
}, children: [_jsxs("span", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [Icon && _jsx(Icon, { size: 9, color: iconColor }), _jsx("span", { style: {
|
|
35
|
+
fontSize: 11,
|
|
36
|
+
fontWeight: 600,
|
|
37
|
+
color: "#aaa",
|
|
38
|
+
textTransform: "uppercase",
|
|
39
|
+
letterSpacing: "0.04em",
|
|
40
|
+
}, children: label }), count !== undefined && _jsx("span", { style: { fontSize: 11, color: "#666" }, children: count })] }), expanded ? _jsx(FiChevronDown, { size: 12, color: "#888" }) : _jsx(FiChevronRight, { size: 12, color: "#888" })] }), expanded && children] }));
|
|
41
|
+
}
|
|
42
|
+
return (_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, expanded && contentBottomSeparator && (_jsx("div", { style: { marginTop: 8, borderBottom: `1px solid ${DIVIDER_COLOR}` } }))] }));
|
|
43
|
+
};
|
package/dist/FieldTextInput.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { ComponentSize } from "./internal/theme";
|
|
2
3
|
export interface FieldTextInputProps {
|
|
3
4
|
label?: React.ReactNode;
|
|
4
5
|
value: string;
|
|
5
6
|
onChange: (value: string) => void;
|
|
6
|
-
size?:
|
|
7
|
+
size?: ComponentSize;
|
|
7
8
|
mustBeNumeric?: boolean;
|
|
8
9
|
bottomSeparator?: boolean;
|
|
9
10
|
highlightOnFocus?: boolean;
|
package/dist/FieldTextInput.js
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Field, TextField } from "@decky/ui";
|
|
3
|
+
import { DEFAULT_ROUNDNESS, SIZE_STYLE } from "./internal/theme";
|
|
3
4
|
// TextField lacks bottomSeparator/highlightOnFocus/size, so this wraps it in Field.
|
|
4
|
-
export const FieldTextInput = ({ label, value, onChange, size = "
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
export const FieldTextInput = ({ label, value, onChange, size = "medium", mustBeNumeric, bottomSeparator = true, highlightOnFocus = true, labelPosition = "top", placeholder, iconStart, iconEnd, }) => {
|
|
6
|
+
const { fontSize, minHeight } = SIZE_STYLE[size];
|
|
7
|
+
// Horizontal-only — vertical rhythm comes entirely from the shared
|
|
8
|
+
// table's own minHeight below, not from padding, so this can never
|
|
9
|
+
// drift from what ActionButton/AnchoredDropdown's own trigger resolve
|
|
10
|
+
// to at "the same size". A native <input> never wraps to more than one
|
|
11
|
+
// line regardless, so minHeight vs. a fixed height makes no practical
|
|
12
|
+
// difference here — kept as minHeight anyway, only for consistency
|
|
13
|
+
// with the other two (which do need the real floor, not a hard cap).
|
|
14
|
+
const padH = { small: 8, medium: 12, large: 16 }[size];
|
|
7
15
|
// Fixed regardless of size, so icon margins stay identical in both.
|
|
8
16
|
const iconSlot = 30;
|
|
9
|
-
const fontSize = size === "small" ? 12 : 14;
|
|
10
17
|
const input = (_jsxs("div", { style: { position: "relative", width: "100%" }, children: [_jsx(TextField, { mustBeNumeric: mustBeNumeric, value: value, onChange: (e) => onChange(e.target.value), style: {
|
|
11
18
|
fontSize,
|
|
12
19
|
width: "100%",
|
|
13
20
|
boxSizing: "border-box",
|
|
14
|
-
|
|
21
|
+
// No vertical padding — a native <input> already centers its
|
|
22
|
+
// own text within its box regardless of extra height, so
|
|
23
|
+
// minHeight alone reserves the room, guaranteeing this lines
|
|
24
|
+
// up with ActionButton/AnchoredDropdown's own trigger at "the
|
|
25
|
+
// same size" instead of merely resembling it.
|
|
26
|
+
padding: `0 ${iconEnd ? iconSlot : padH}px 0 ${iconStart ? iconSlot : padH}px`,
|
|
27
|
+
minHeight,
|
|
28
|
+
borderRadius: DEFAULT_ROUNDNESS,
|
|
15
29
|
} }), !value && placeholder && (_jsx("span", { style: {
|
|
16
30
|
position: "absolute",
|
|
17
31
|
left: iconStart ? iconSlot : padH,
|