@edenapp/solid-kit 0.8.0 → 0.10.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/package.json +6 -2
- package/src/KeyboardButton.css +22 -0
- package/src/KeyboardButton.tsx +80 -0
- package/src/dialogs/index.ts +2 -2
- package/src/index.ts +1 -0
- package/src/styles.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edenapp/solid-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "High-level SolidJS UI primitives for Eden apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -23,8 +23,12 @@
|
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"solid-js": "^1.9.0"
|
|
25
25
|
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"solid-icons": "^1.1.0"
|
|
28
|
+
},
|
|
26
29
|
"devDependencies": {
|
|
27
|
-
"typescript": "^5.3.0"
|
|
30
|
+
"typescript": "^5.3.0",
|
|
31
|
+
"@edenapp/types": "0.10.0"
|
|
28
32
|
},
|
|
29
33
|
"keywords": [
|
|
30
34
|
"eden",
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.eden-keyboard-button {
|
|
2
|
+
width: 40px;
|
|
3
|
+
height: 40px;
|
|
4
|
+
min-width: 40px;
|
|
5
|
+
padding: 0;
|
|
6
|
+
border-radius: var(--eden-radius-lg);
|
|
7
|
+
color: var(--eden-color-text-primary);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.eden-keyboard-button svg {
|
|
11
|
+
width: 20px;
|
|
12
|
+
height: 20px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.eden-keyboard-button:hover {
|
|
16
|
+
background: var(--eden-color-surface-hover);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.eden-keyboard-button.active {
|
|
20
|
+
background: var(--eden-color-surface-active);
|
|
21
|
+
color: var(--eden-color-text-primary);
|
|
22
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { EdenKeyboardState } from "@edenapp/types";
|
|
2
|
+
import { BiSolidKeyboard } from "solid-icons/bi";
|
|
3
|
+
import { createSignal, onCleanup, onMount, Show } from "solid-js";
|
|
4
|
+
import "./KeyboardButton.css";
|
|
5
|
+
|
|
6
|
+
export interface KeyboardButtonProps {
|
|
7
|
+
label: string;
|
|
8
|
+
class?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const defaultKeyboardState: EdenKeyboardState = {
|
|
12
|
+
enabled: true,
|
|
13
|
+
visible: false,
|
|
14
|
+
placementMode: "docked",
|
|
15
|
+
bottomInset: 0,
|
|
16
|
+
layout: "text",
|
|
17
|
+
showNumberRow: true,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function KeyboardButton(props: KeyboardButtonProps) {
|
|
21
|
+
const [keyboardState, setKeyboardState] =
|
|
22
|
+
createSignal<EdenKeyboardState>(defaultKeyboardState);
|
|
23
|
+
let keyboardVisibleAtPointerDown: boolean | null = null;
|
|
24
|
+
|
|
25
|
+
const refreshKeyboardState = async () => {
|
|
26
|
+
try {
|
|
27
|
+
setKeyboardState(await window.edenKeyboard.getState());
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error("Failed to load keyboard state:", error);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const handleToggle = async () => {
|
|
34
|
+
try {
|
|
35
|
+
const shouldHide =
|
|
36
|
+
keyboardVisibleAtPointerDown ?? keyboardState().visible;
|
|
37
|
+
keyboardVisibleAtPointerDown = null;
|
|
38
|
+
|
|
39
|
+
if (shouldHide) {
|
|
40
|
+
await window.edenKeyboard.hide();
|
|
41
|
+
} else {
|
|
42
|
+
await window.edenKeyboard.show();
|
|
43
|
+
}
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error("Failed to toggle keyboard:", error);
|
|
46
|
+
} finally {
|
|
47
|
+
void refreshKeyboardState();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const handlePointerDown = () => {
|
|
52
|
+
keyboardVisibleAtPointerDown = keyboardState().visible;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
onMount(() => {
|
|
56
|
+
const unsubscribeKeyboard =
|
|
57
|
+
window.edenKeyboard.onStateChanged?.((state) => {
|
|
58
|
+
setKeyboardState(state);
|
|
59
|
+
}) ?? (() => {});
|
|
60
|
+
|
|
61
|
+
onCleanup(unsubscribeKeyboard);
|
|
62
|
+
void refreshKeyboardState();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<Show when={keyboardState().enabled}>
|
|
67
|
+
<button
|
|
68
|
+
type="button"
|
|
69
|
+
class={`eden-btn eden-btn-ghost eden-btn-icon eden-keyboard-button ${props.class ?? ""}`}
|
|
70
|
+
classList={{ active: keyboardState().visible }}
|
|
71
|
+
onClick={() => void handleToggle()}
|
|
72
|
+
onPointerDown={handlePointerDown}
|
|
73
|
+
title={props.label}
|
|
74
|
+
aria-label={props.label}
|
|
75
|
+
>
|
|
76
|
+
<BiSolidKeyboard />
|
|
77
|
+
</button>
|
|
78
|
+
</Show>
|
|
79
|
+
);
|
|
80
|
+
}
|
package/src/dialogs/index.ts
CHANGED
package/src/index.ts
CHANGED
package/src/styles.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module "*.css";
|