-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: better support for complex values
- Loading branch information
Showing
14 changed files
with
467 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { useComputed, useSignal } from "@preact/signals"; | ||
|
||
import { Label } from "./Label.tsx"; | ||
|
||
export function KvKeyPartEditor() { | ||
const keyPartType = useSignal("string"); | ||
const keyPartEditor = useComputed(() => { | ||
switch (keyPartType.value) { | ||
case "bigint": | ||
return ( | ||
<input | ||
type="number" | ||
name="key_part" | ||
id="key_part" | ||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" | ||
placeholder="Key part value" | ||
required | ||
/> | ||
); | ||
case "number": | ||
return ( | ||
<input | ||
type="text" | ||
name="key_part" | ||
id="key_part" | ||
pattern="-?\d+(\.\d+)?|-?Infinity|NaN" | ||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" | ||
placeholder="Key part value" | ||
required | ||
/> | ||
); | ||
case "boolean": | ||
return ( | ||
<select | ||
name="key_part" | ||
id="key_part" | ||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" | ||
> | ||
<option selected value="true">true</option> | ||
<option value="false">false</option> | ||
</select> | ||
); | ||
default: | ||
return ( | ||
<input | ||
type="text" | ||
name="key_part" | ||
id="key_part" | ||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" | ||
placeholder="Key part value" | ||
required | ||
/> | ||
); | ||
} | ||
}); | ||
|
||
return ( | ||
<> | ||
<div> | ||
<Label for="key_part">Key Part</Label> | ||
{keyPartEditor} | ||
</div> | ||
<div> | ||
<Label for="key_part_type">Key Part Type</Label> | ||
<select | ||
id="key_part_type" | ||
name="key_part_type" | ||
value={keyPartType} | ||
onChange={(evt) => keyPartType.value = evt.currentTarget.value} | ||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" | ||
> | ||
<option selected value="string">String</option> | ||
<option value="number">Number</option> | ||
<option value="bigint">BigInt</option> | ||
<option value="boolean">Boolean</option> | ||
<option value="Uint8Array">Uint8Array</option> | ||
</select> | ||
</div> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,18 +17,15 @@ | |
}, | ||
"lint": { "rules": { "tags": ["fresh", "recommended"] } }, | ||
"imports": { | ||
"$fresh/": "https://deno.land/x/[email protected]/", | ||
"preact": "https://esm.sh/[email protected]", | ||
"preact/": "https://esm.sh/[email protected]/", | ||
"preact-render-to-string": "https://esm.sh/*[email protected]", | ||
"tailwindcss": "npm:[email protected]", | ||
"tailwindcss/": "npm:/[email protected]/", | ||
"tailwindcss/plugin": "npm:/[email protected]/plugin.js", | ||
"@deno/gfm": "jsr:/@deno/[email protected]", | ||
"@kitsonk/kv-toolbox": "jsr:/@kitsonk/[email protected]", | ||
"$components/": "./components/", | ||
"$fresh/": "https://deno.land/x/[email protected]/", | ||
"$islands/": "./islands/", | ||
"$utils/": "./utils/", | ||
"@deno/gfm": "jsr:/@deno/[email protected]", | ||
"@kitsonk/kv-toolbox": "jsr:/@kitsonk/[email protected]", | ||
"@oak/commons/": "jsr:/@oak/commons@~1/", | ||
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.2", | ||
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.1", | ||
"@preact/signals": "npm:/@preact/signals@1.3.0", | ||
"@preact/signals-core": "npm:/@preact/signals-core@1.8.0", | ||
"@std/assert/": "jsr:/@std/assert@~1/", | ||
"@std/async/": "jsr:/@std/async@~1/", | ||
"@std/crypto/": "jsr:/@std/crypto@~1/", | ||
|
@@ -38,9 +35,12 @@ | |
"@std/html/": "jsr:/@std/html@~1/", | ||
"@std/media-types/": "jsr:/@std/media-types@~1/", | ||
"@std/path/": "jsr:/@std/path@~1/", | ||
"$components/": "./components/", | ||
"$islands/": "./islands/", | ||
"$utils/": "./utils/" | ||
"object-inspect": "npm:object-inspect@^1.13.2", | ||
"preact": "npm:/[email protected]", | ||
"preact-render-to-string": "npm:/[email protected]", | ||
"prismjs": "npm:/[email protected]", | ||
"tailwindcss": "npm:/[email protected]", | ||
"tailwindcss/plugin": "npm:/[email protected]/plugin.js" | ||
}, | ||
"compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "preact" }, | ||
"exclude": ["**/_fresh/*"] | ||
|
Oops, something went wrong.