@moi952/decky-ui-kit 0.2.0 → 0.3.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 +35 -0
- package/dist/FieldTextInput.d.ts +3 -0
- package/dist/FieldTextInput.js +38 -5
- package/dist/InlineConfirm.d.ts +11 -0
- package/dist/InlineConfirm.js +44 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -124,5 +124,40 @@ import { FieldTextInput } from "@moi952/decky-ui-kit";
|
|
|
124
124
|
| `mustBeNumeric` | `boolean` | `false` | Restricts input to numeric characters. |
|
|
125
125
|
| `bottomSeparator` | `boolean` | `true` | Native Steam separator line below the row. |
|
|
126
126
|
| `highlightOnFocus` | `boolean` | `true` | Background highlight while the input has focus. |
|
|
127
|
+
| `placeholder` | `string` | — | Shown when empty (TextField has no native placeholder, this is a positioned overlay). |
|
|
128
|
+
| `iconStart` | `ReactNode` | — | Icon at the start of the input. |
|
|
129
|
+
| `iconEnd` | `ReactNode` | — | Icon at the end of the input. |
|
|
130
|
+
|
|
131
|
+
</details>
|
|
132
|
+
|
|
133
|
+
### `InlineConfirm`
|
|
134
|
+
|
|
135
|
+
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.
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
import { InlineConfirm } from "@moi952/decky-ui-kit";
|
|
139
|
+
|
|
140
|
+
{confirming && (
|
|
141
|
+
<InlineConfirm
|
|
142
|
+
description="Remove the wrapper from this game?"
|
|
143
|
+
confirmLabel="Remove"
|
|
144
|
+
onCancel={() => setConfirming(false)}
|
|
145
|
+
onConfirm={() => { removeWrapper(); setConfirming(false); }}
|
|
146
|
+
/>
|
|
147
|
+
)}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
<details>
|
|
151
|
+
<summary>Props</summary>
|
|
152
|
+
|
|
153
|
+
| Prop | Type | Default | Description |
|
|
154
|
+
| --- | --- | --- | --- |
|
|
155
|
+
| `description` | `ReactNode` | — | The confirmation message. |
|
|
156
|
+
| `onCancel` | `() => void` | — | Called when Cancel is picked. |
|
|
157
|
+
| `onConfirm` | `() => void` | — | Called when the confirm button is picked. |
|
|
158
|
+
| `cancelLabel` | `ReactNode` | `"Cancel"` | Cancel button text. |
|
|
159
|
+
| `confirmLabel` | `ReactNode` | `"Delete"` | Confirm button text. |
|
|
160
|
+
| `size` | `"small" \| "medium" \| "large"` | `"small"` | Button padding/font size. |
|
|
161
|
+
| `variant` | `"danger" \| "primary"` | `"danger"` | Red confirm button for a destructive action, or blue for a plain confirm. |
|
|
127
162
|
|
|
128
163
|
</details>
|
package/dist/FieldTextInput.d.ts
CHANGED
|
@@ -8,5 +8,8 @@ export interface FieldTextInputProps {
|
|
|
8
8
|
bottomSeparator?: boolean;
|
|
9
9
|
highlightOnFocus?: boolean;
|
|
10
10
|
labelPosition?: "top" | "left" | "right";
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
iconStart?: React.ReactNode;
|
|
13
|
+
iconEnd?: React.ReactNode;
|
|
11
14
|
}
|
|
12
15
|
export declare const FieldTextInput: React.FC<FieldTextInputProps>;
|
package/dist/FieldTextInput.js
CHANGED
|
@@ -1,11 +1,44 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Field, TextField } from "@decky/ui";
|
|
3
3
|
// TextField lacks bottomSeparator/highlightOnFocus/size, so this wraps it in Field.
|
|
4
|
-
export const FieldTextInput = ({ label, value, onChange, size = "default", mustBeNumeric, bottomSeparator = true, highlightOnFocus = true, labelPosition = "top", }) => {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export const FieldTextInput = ({ label, value, onChange, size = "default", mustBeNumeric, bottomSeparator = true, highlightOnFocus = true, labelPosition = "top", placeholder, iconStart, iconEnd, }) => {
|
|
5
|
+
const padV = size === "small" ? 6 : 10;
|
|
6
|
+
const padH = size === "small" ? 8 : 12;
|
|
7
|
+
// Fixed regardless of size, so icon margins stay identical in both.
|
|
8
|
+
const iconSlot = 30;
|
|
9
|
+
const fontSize = size === "small" ? 12 : 14;
|
|
10
|
+
const input = (_jsxs("div", { style: { position: "relative", width: "100%" }, children: [_jsx(TextField, { mustBeNumeric: mustBeNumeric, value: value, onChange: (e) => onChange(e.target.value), style: {
|
|
11
|
+
fontSize,
|
|
12
|
+
width: "100%",
|
|
13
|
+
boxSizing: "border-box",
|
|
14
|
+
padding: `${padV}px ${iconEnd ? iconSlot : padH}px ${padV}px ${iconStart ? iconSlot : padH}px`,
|
|
15
|
+
} }), !value && placeholder && (_jsx("span", { style: {
|
|
16
|
+
position: "absolute",
|
|
17
|
+
left: iconStart ? iconSlot : padH,
|
|
18
|
+
top: "50%",
|
|
19
|
+
transform: "translateY(-50%)",
|
|
20
|
+
fontSize,
|
|
21
|
+
color: "rgba(255, 255, 255, 0.4)",
|
|
22
|
+
pointerEvents: "none",
|
|
23
|
+
whiteSpace: "nowrap",
|
|
24
|
+
overflow: "hidden",
|
|
25
|
+
textOverflow: "ellipsis",
|
|
26
|
+
maxWidth: `calc(100% - ${(iconStart ? iconSlot : padH) + (iconEnd ? iconSlot : padH)}px)`,
|
|
27
|
+
}, children: placeholder })), iconStart && (_jsx("span", { style: {
|
|
28
|
+
position: "absolute",
|
|
29
|
+
left: (iconSlot - 16) / 2,
|
|
30
|
+
top: "50%",
|
|
31
|
+
transform: "translateY(-50%)",
|
|
32
|
+
display: "flex",
|
|
33
|
+
pointerEvents: "none",
|
|
34
|
+
}, children: iconStart })), iconEnd && (_jsx("span", { style: {
|
|
35
|
+
position: "absolute",
|
|
36
|
+
right: (iconSlot - 16) / 2,
|
|
37
|
+
top: "50%",
|
|
38
|
+
transform: "translateY(-50%)",
|
|
39
|
+
display: "flex",
|
|
40
|
+
pointerEvents: "none",
|
|
41
|
+
}, children: iconEnd }))] }));
|
|
9
42
|
return (_jsx(Field, { label: labelPosition === "right" ? undefined : label, bottomSeparator: bottomSeparator ? "standard" : "none", childrenLayout: labelPosition === "top" ? "below" : "inline", highlightOnFocus: highlightOnFocus, children: labelPosition === "right" ? (_jsxs("div", { style: {
|
|
10
43
|
display: "flex",
|
|
11
44
|
alignItems: "center",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface InlineConfirmProps {
|
|
3
|
+
description: React.ReactNode;
|
|
4
|
+
onCancel: () => void;
|
|
5
|
+
onConfirm: () => void;
|
|
6
|
+
cancelLabel?: React.ReactNode;
|
|
7
|
+
confirmLabel?: React.ReactNode;
|
|
8
|
+
size?: "small" | "medium" | "large";
|
|
9
|
+
variant?: "danger" | "primary";
|
|
10
|
+
}
|
|
11
|
+
export declare const InlineConfirm: React.FC<InlineConfirmProps>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import { DialogButton, Focusable } from "@decky/ui";
|
|
4
|
+
const SIZE_STYLE = {
|
|
5
|
+
small: { padding: "4px 8px", fontSize: 12, minHeight: 28 },
|
|
6
|
+
medium: { padding: "6px 12px", fontSize: 14, minHeight: 32 },
|
|
7
|
+
large: { padding: "8px 16px", fontSize: 16, minHeight: 36 },
|
|
8
|
+
};
|
|
9
|
+
const VARIANT_COLOR = {
|
|
10
|
+
danger: "#ef4444",
|
|
11
|
+
primary: "#3b82f6",
|
|
12
|
+
};
|
|
13
|
+
// A confirmation shown inline, below whatever triggered it — not a modal.
|
|
14
|
+
// Description line + an equal-width Cancel/Confirm pair.
|
|
15
|
+
export const InlineConfirm = ({ description, onCancel, onConfirm, cancelLabel = "Cancel", confirmLabel = "Delete", size = "small", variant = "danger", }) => {
|
|
16
|
+
const confirmCls = `dck-inline-confirm${useId().replace(/[^a-zA-Z0-9]/g, "")}`;
|
|
17
|
+
const buttonStyle = SIZE_STYLE[size];
|
|
18
|
+
const color = VARIANT_COLOR[variant];
|
|
19
|
+
return (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 8, width: "100%" }, children: [_jsx("style", { children: `
|
|
20
|
+
.${confirmCls} {
|
|
21
|
+
background-color: ${color} !important;
|
|
22
|
+
color: #fff !important;
|
|
23
|
+
}
|
|
24
|
+
.${confirmCls}:focus,
|
|
25
|
+
.${confirmCls}:hover {
|
|
26
|
+
background-color: #fff !important;
|
|
27
|
+
color: ${color} !important;
|
|
28
|
+
}
|
|
29
|
+
` }), _jsx("span", { style: { fontSize: 11, color: "#aaa" }, children: description }), _jsxs(Focusable, { style: { display: "flex", gap: 8, width: "100%" }, "flow-children": "horizontal", children: [_jsx("div", { style: { flex: 1 }, children: _jsx(DialogButton, { onClick: onCancel, style: {
|
|
30
|
+
...buttonStyle,
|
|
31
|
+
width: "100%",
|
|
32
|
+
display: "flex",
|
|
33
|
+
alignItems: "center",
|
|
34
|
+
justifyContent: "center",
|
|
35
|
+
minWidth: "unset",
|
|
36
|
+
}, children: cancelLabel }) }), _jsx("div", { style: { flex: 1 }, children: _jsx(DialogButton, { className: confirmCls, onClick: onConfirm, style: {
|
|
37
|
+
...buttonStyle,
|
|
38
|
+
width: "100%",
|
|
39
|
+
display: "flex",
|
|
40
|
+
alignItems: "center",
|
|
41
|
+
justifyContent: "center",
|
|
42
|
+
minWidth: "unset",
|
|
43
|
+
}, children: confirmLabel }) })] })] }));
|
|
44
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,3 +4,5 @@ export { CollapsibleSection } from "./CollapsibleSection";
|
|
|
4
4
|
export type { CollapsibleSectionProps } from "./CollapsibleSection";
|
|
5
5
|
export { FieldTextInput } from "./FieldTextInput";
|
|
6
6
|
export type { FieldTextInputProps } from "./FieldTextInput";
|
|
7
|
+
export { InlineConfirm } from "./InlineConfirm";
|
|
8
|
+
export type { InlineConfirmProps } from "./InlineConfirm";
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moi952/decky-ui-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Reusable UI components for Decky Loader plugins that need popups/dropdowns without triggering the native panel-remount bug",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|