Skip to content

Commit 7b4362d

Browse files
authored
Swap node for deno (#319)
* swap node for deno * migrate to deno reusable GH workflows * fix .github/workflows/test.yml, add explicit width example for #255 on /ui page * fix maxSelect playwright test
1 parent f025db8 commit 7b4362d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+432
-332
lines changed

.github/workflows/gh-pages.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,4 @@ on:
99

1010
jobs:
1111
build:
12-
uses: janosh/workflows/.github/workflows/nodejs-gh-pages.yml@main
13-
with:
14-
install-cmd: npm install --force
12+
uses: janosh/workflows/.github/workflows/deno-gh-pages.yml@main

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ on:
1111

1212
jobs:
1313
tests:
14-
uses: janosh/workflows/.github/workflows/npm-test.yml@main
14+
uses: janosh/workflows/.github/workflows/deno-test.yml@main
1515
with:
16-
test-cmd: npm run test:unit
17-
install-e2e: npx playwright install chromium
18-
e2e-test-cmd: npx playwright test tests/*.ts
16+
test-cmd: deno task vitest --run
17+
e2e-install-cmd: npx playwright install chromium
18+
e2e-test-cmd: npx playwright test

.pre-commit-config.yaml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ci:
22
autoupdate_schedule: quarterly
3-
skip: [eslint]
3+
skip: [eslint, deno-lint, deno-fmt]
44

55
default_stages: [pre-commit]
66

@@ -19,15 +19,20 @@ repos:
1919
- id: mixed-line-ending
2020
- id: trailing-whitespace
2121

22-
- repo: https://github.com/pre-commit/mirrors-prettier
23-
rev: v4.0.0-alpha.8
22+
- repo: local
2423
hooks:
25-
- id: prettier
26-
args: [--write] # edit files in-place
27-
additional_dependencies:
28-
- prettier
29-
- prettier-plugin-svelte
30-
- svelte
24+
- id: deno-fmt
25+
name: Deno format
26+
entry: deno fmt
27+
types_or: [file]
28+
language: system
29+
args: [--config, deno.jsonc]
30+
- id: deno-lint
31+
name: Deno lint
32+
entry: deno lint
33+
types_or: [file]
34+
language: system
35+
args: [--config, deno.jsonc, --permit-no-files, --fix]
3136

3237
- repo: https://github.com/codespell-project/codespell
3338
rev: v2.4.1
@@ -38,7 +43,7 @@ repos:
3843
exclude: changelog\.md
3944

4045
- repo: https://github.com/pre-commit/mirrors-eslint
41-
rev: v9.28.0
46+
rev: v9.30.0
4247
hooks:
4348
- id: eslint
4449
types: [file]

.prettierrc.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

deno.jsonc

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"tasks": {
3+
"dev": "deno run -A --node-modules-dir npm:vite dev",
4+
"build": "deno run -A --node-modules-dir npm:vite build",
5+
"preview": "deno run -A --node-modules-dir npm:vite preview",
6+
"serve": "deno task build && deno task preview",
7+
"test": "deno task vitest --run && deno task e2e",
8+
"vitest": "deno run -A --node-modules-dir npm:vitest",
9+
"e2e": "npx playwright test",
10+
"test:install": "npx playwright install chromium",
11+
"package": "svelte-package",
12+
"changelog": "deno run -A https://github.com/janosh/workflows/raw/refs/heads/main/scripts/make-release-notes.ts"
13+
},
14+
"lock": false,
15+
"imports": {
16+
"$lib": "./src/lib",
17+
"$lib/": "./src/lib/",
18+
"$site": "./src/site",
19+
"$site/": "./src/site/"
20+
},
21+
"lint": {
22+
"rules": {
23+
"tags": ["recommended"],
24+
"include": [
25+
"ban-unused-ignore",
26+
"default-param-last",
27+
"eqeqeq",
28+
"guard-for-in",
29+
"jsx-key",
30+
"jsx-no-duplicate-props",
31+
"jsx-no-useless-fragment",
32+
"no-async-promise-executor",
33+
"no-await-in-loop",
34+
// "no-boolean-literal-for-arguments", // TODO only disable this in test files or even just for .toBe(true)
35+
"no-const-assign",
36+
"no-eval",
37+
"no-explicit-any",
38+
"no-non-null-asserted-optional-chain",
39+
"no-non-null-assertion",
40+
"no-self-compare",
41+
"no-sparse-arrays",
42+
"no-sync-fn-in-async-fn",
43+
"no-throw-literal",
44+
"no-unused-vars",
45+
"no-useless-rename",
46+
"prefer-const",
47+
"require-await",
48+
"single-var-declarator"
49+
],
50+
"exclude": ["no-sloppy-imports"]
51+
}
52+
},
53+
"fmt": {
54+
"indentWidth": 2,
55+
"lineWidth": 90,
56+
"semiColons": false,
57+
"singleQuote": true,
58+
"proseWrap": "preserve"
59+
},
60+
"unstable": ["fmt-component", "sloppy-imports"],
61+
"compilerOptions": {
62+
"lib": ["dom", "esnext"]
63+
},
64+
"nodeModulesDir": "auto"
65+
}

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
},
2828
"devDependencies": {
2929
"@playwright/test": "^1.53.0",
30-
"@stylistic/eslint-plugin": "^4.4.1",
30+
"@stylistic/eslint-plugin": "^5.1.0",
3131
"@sveltejs/adapter-static": "^3.0.8",
3232
"@sveltejs/kit": "^2.21.5",
33-
"@sveltejs/package": "2.3.11",
33+
"@sveltejs/package": "2.3.12",
3434
"@sveltejs/vite-plugin-svelte": "^5.1.0",
3535
"@types/node": "^24.0.1",
3636
"@vitest/coverage-v8": "^3.2.3",
@@ -41,8 +41,6 @@
4141
"jsdom": "^26.1.0",
4242
"mdsvex": "^0.12.6",
4343
"mdsvexamples": "^0.5.0",
44-
"prettier": "^3.5.3",
45-
"prettier-plugin-svelte": "^3.4.0",
4644
"rehype-autolink-headings": "^7.1.0",
4745
"rehype-slug": "^6.0.0",
4846
"svelte": "^5.34.1",
@@ -53,7 +51,7 @@
5351
"svelte2tsx": "^0.7.39",
5452
"typescript": "5.8.3",
5553
"typescript-eslint": "^8.34.0",
56-
"vite": "^6.3.5",
54+
"vite": "^7.0.0",
5755
"vitest": "^3.2.3"
5856
},
5957
"keywords": [

readme.md

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ Favorite Frontend Tools?
6666
<MultiSelect bind:selected options={ui_libs} />
6767
```
6868

69-
## 🧠 &thinsp; Mental Model & Core Concepts
69+
## 🧠 &thinsp; Mental Model
7070

71-
| Prop | Purpose | Value |
72-
| --------------- | ---------------------------------------------- | ----------------------------------------------------------------------------------- |
73-
| `options` | What users can choose from | Array of strings, numbers, or objects with `label` property |
74-
| `bind:selected` | What they've chosen | Always an array: `[]`, `['Apple']` or `['Apple', 'Banana']` |
75-
| `bind:value` | Single-select convenience for what users chose | Single item: `'Apple'` (or `null`) if `maxSelect={1}`, otherwise same as `selected` |
71+
| Prop | Purpose | Value |
72+
| --------------- | ------------------------------------------------------ | ----------------------------------------------------------------------------------- |
73+
| `options` | What users can choose from | Array of strings, numbers, or objects with `label` property |
74+
| `bind:selected` | Which options users have chosen | Always an array: `[]`, `['Apple']` or `['Apple', 'Banana']` |
75+
| `bind:value` | Single-select convenience for the user-selected option | Single item: `'Apple'` (or `null`) if `maxSelect={1}`, otherwise same as `selected` |
7676

7777
### Common Patterns
7878

@@ -83,11 +83,14 @@ Favorite Frontend Tools?
8383
<!-- Single-select -->
8484
<MultiSelect bind:value options={colors} maxSelect={1} />
8585
86-
<!-- Object options (need 'label' property) -->
87-
<MultiSelect bind:selected options={[
88-
{ label: 'Red', value: '#ff0000' },
89-
{ label: 'Blue', value: '#0000ff' }
90-
]} />
86+
<!-- Object options (need 'label' property, can have arbitrary other keys, some like `value`, `disabled`, `preselected`, `style` have special meaning, see type ObjectOption) -->
87+
<MultiSelect
88+
bind:selected
89+
options={[
90+
{ label: 'Red', value: '#ff0000' },
91+
{ label: 'Blue', value: '#0000ff' },
92+
]}
93+
/>
9194
```
9295

9396
### Troubleshooting
@@ -118,10 +121,12 @@ These are the core props you'll use in most cases:
118121
<MultiSelect options={['Red', 'Green', 'Blue']} />
119122
120123
<!-- Object options -->
121-
<MultiSelect options={[
122-
{ label: 'Red', value: '#ff0000', hex: true },
123-
{ label: 'Green', value: '#00ff00', hex: true }
124-
]} />
124+
<MultiSelect
125+
options={[
126+
{ label: 'Red', value: '#ff0000', hex: true },
127+
{ label: 'Green', value: '#00ff00', hex: true },
128+
]}
129+
/>
125130
```
126131

127132
1. ```ts
@@ -132,7 +137,7 @@ These are the core props you'll use in most cases:
132137

133138
```svelte
134139
<script>
135-
let selected = $state(['Red']) // Pre-select Red
140+
let selected = $state(['Red']) // Pre-select Red
136141
</script>
137142
<MultiSelect bind:selected options={colors} />
138143
```
@@ -250,12 +255,14 @@ These are the core props you'll use in most cases:
250255

251256
Whether to allow selecting the same option multiple times.
252257

258+
<!-- deno-fmt-ignore -->
253259
1. ```ts
254260
filterFunc: (opt: Option, searchText: string) => boolean
255261
```
256262

257263
Custom function to filter options based on search text. Default filters by label.
258264

265+
<!-- deno-fmt-ignore -->
259266
1. ```ts
260267
key: (opt: Option) => unknown
261268
```
@@ -400,6 +407,7 @@ These are the core props you'll use in most cases:
400407

401408
Tooltip for individual remove buttons.
402409

410+
<!-- deno-fmt-ignore -->
403411
1. ```ts
404412
maxSelectMsg: ((current: number, max: number) => string) | null
405413
```
@@ -567,10 +575,10 @@ Example using several snippets:
567575
```svelte
568576
<MultiSelect options={[`Red`, `Green`, `Blue`, `Yellow`, `Purple`]}>
569577
{#snippet children({ idx, option })}
570-
<span style="display: flex; align-items: center; gap: 6pt;">
578+
<span style="display: flex; align-items: center; gap: 6pt">
571579
<span
572580
style:background={`${option}`}
573-
style="border-radius: 50%; width: 1em; height: 1em;"
581+
style="border-radius: 50%; width: 1em; height: 1em"
574582
></span>
575583
{idx + 1}
576584
{option}
@@ -676,10 +684,10 @@ You can also import [the types this component uses](https://github.com/janosh/sv
676684

677685
```ts
678686
import {
679-
Option,
680-
ObjectOption,
681687
DispatchEvents,
682688
MultiSelectEvents,
689+
ObjectOption,
690+
Option,
683691
} from 'svelte-multiselect'
684692
```
685693

src/app.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en">
33
<head>
44
<title>Svelte MultiSelect</title>
@@ -49,23 +49,26 @@
4949
<path
5050
fill="currentColor"
5151
d="M8 0c4.42 0 8 3.58 8 8a8.01 8.01 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38c0-.27.01-1.13.01-2.2c0-.75-.25-1.23-.54-1.48c1.78-.2 3.65-.88 3.65-3.95c0-.88-.31-1.59-.82-2.15c.08-.2.36-1.02-.08-2.12c0 0-.67-.22-2.2.82c-.64-.18-1.32-.27-2-.27s-1.36.09-2 .27c-1.53-1.03-2.2-.82-2.2-.82c-.44 1.1-.16 1.92-.08 2.12c-.51.56-.82 1.28-.82 2.15c0 3.06 1.86 3.75 3.64 3.95c-.23.2-.44.55-.51 1.07c-.46.21-1.61.55-2.33-.66c-.15-.24-.6-.83-1.23-.82c-.67.01-.27.38.01.53c.34.19.73.9.82 1.13c.16.45.68 1.31 2.69.94c0 .67.01 1.3.01 1.49c0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8"
52-
></path>
52+
>
53+
</path>
5354
</symbol>
5455

5556
<symbol viewBox="0 0 24 24" id="material-symbols-auto-awesome">
5657
<!-- Icon from Material Symbols by Google - https://github.com/google/material-design-icons/blob/master/LICENSE -->
5758
<path
5859
fill="currentColor"
5960
d="m19 9l-1.25-2.75L15 5l2.75-1.25L19 1l1.25 2.75L23 5l-2.75 1.25L19 9Zm0 14l-1.25-2.75L15 19l2.75-1.25L19 15l1.25 2.75L23 19l-2.75 1.25L19 23ZM9 20l-2.5-5.5L1 12l5.5-2.5L9 4l2.5 5.5L17 12l-5.5 2.5L9 20Z"
60-
></path>
61+
>
62+
</path>
6163
</symbol>
6264

6365
<symbol viewBox="0 0 32 32" id="carbon-edit">
6466
<!-- Icon from Carbon by IBM - undefined -->
6567
<path
6668
fill="currentColor"
6769
d="M2 26h28v2H2zM25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4zm-5-5L24 7.6l-3 3L17.4 7zM6 22v-3.6l10-10l3.6 3.6l-10 10z"
68-
></path>
70+
>
71+
</path>
6972
</symbol>
7073
</svg>
7174

src/lib/CircleSpinner.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
{color}"
1414
style:width={size}
1515
style:height={size}
16-
></div>
16+
>
17+
</div>
1718

1819
<style>
1920
div {

src/lib/CmdPalette.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
2+
import { MultiSelect } from '$lib'
23
import { fade } from 'svelte/transition'
3-
import { MultiSelect } from '.'
44
import type { MultiSelectProps, ObjectOption, Option } from './types'
55
66
interface Action extends ObjectOption {

0 commit comments

Comments
 (0)