wx-svelte-tasklist 2.2.1 → 2.4.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 +9 -7
- package/readme.md +3 -3
- package/src/components/Layout.svelte +16 -8
- package/src/components/Task.svelte +5 -3
- package/src/components/Tasklist.svelte +2 -2
- package/types/index.d.ts +22 -0
- package/whatsnew.md +13 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wx-svelte-tasklist",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Simple Svelte component for adding a task list section on a page",
|
|
5
5
|
"productTag": "tasklist",
|
|
6
6
|
"productTrial": false,
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"svelte": "src/index.js",
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
|
-
"svelte": "./src/index.js"
|
|
21
|
+
"svelte": "./src/index.js",
|
|
22
|
+
"types": "./types/index.d.ts"
|
|
22
23
|
},
|
|
23
24
|
"./package.json": "./package.json"
|
|
24
25
|
},
|
|
@@ -32,14 +33,15 @@
|
|
|
32
33
|
},
|
|
33
34
|
"homepage": "https://svar.dev/svelte/core/",
|
|
34
35
|
"dependencies": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
36
|
+
"@svar-ui/tasklist-locales": "2.4.0",
|
|
37
|
+
"@svar-ui/lib-data-provider": "1.7.1",
|
|
38
|
+
"@svar-ui/svelte-core": "2.4.0",
|
|
39
|
+
"@svar-ui/lib-dom": "0.11.1",
|
|
40
|
+
"@svar-ui/lib-state": "1.9.6"
|
|
40
41
|
},
|
|
41
42
|
"files": [
|
|
42
43
|
"src",
|
|
44
|
+
"types",
|
|
43
45
|
"readme.md",
|
|
44
46
|
"whatsnew.md",
|
|
45
47
|
"license.txt"
|
package/readme.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# SVAR Svelte TaskList
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/@svar-ui/svelte-tasklist)
|
|
6
6
|
[](https://github.com/svar-widgets/tasklist/blob/main/license.txt)
|
|
7
|
-
[](https://www.npmjs.com/package/@svar-ui/svelte-tasklist)
|
|
8
8
|
|
|
9
9
|
</div>
|
|
10
10
|
|
|
@@ -28,7 +28,7 @@ To use the widget, simply import the package and include the component in your S
|
|
|
28
28
|
|
|
29
29
|
```svelte
|
|
30
30
|
<script>
|
|
31
|
-
import { Tasklist } from "
|
|
31
|
+
import { Tasklist } from "@svar-ui/svelte-tasklist";
|
|
32
32
|
|
|
33
33
|
const value = [];
|
|
34
34
|
</script>
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { getContext } from "svelte";
|
|
3
|
-
import { Button } from "
|
|
4
|
-
import { delegateClick } from "
|
|
5
|
-
import { tempID } from "
|
|
2
|
+
import { getContext, setContext } from "svelte";
|
|
3
|
+
import { Button } from "@svar-ui/svelte-core";
|
|
4
|
+
import { delegateClick } from "@svar-ui/lib-dom";
|
|
5
|
+
import { tempID } from "@svar-ui/lib-state";
|
|
6
6
|
import Task from "./Task.svelte";
|
|
7
7
|
|
|
8
8
|
let { data: rawData, readonly = false, onchange } = $props();
|
|
9
9
|
|
|
10
10
|
const _ = getContext("wx-i18n").getGroup("tasklist");
|
|
11
11
|
|
|
12
|
+
//prevent associating Checkboxes with outer Field label
|
|
13
|
+
setContext("wx-input-id", null);
|
|
14
|
+
|
|
12
15
|
const data = $derived(rawData ?? []);
|
|
13
16
|
let edit = $state(null);
|
|
14
17
|
let editTask = $state(null);
|
|
15
18
|
|
|
16
19
|
function openEditor() {
|
|
17
20
|
edit = -1;
|
|
18
|
-
editTask = { id: -1, content: "",
|
|
21
|
+
editTask = { id: -1, content: "", status: 0 };
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
function add(content) {
|
|
22
25
|
const task = {
|
|
23
26
|
id: tempID(),
|
|
24
27
|
content,
|
|
25
|
-
|
|
28
|
+
status: 0,
|
|
26
29
|
};
|
|
27
30
|
|
|
28
31
|
rawData = [...data, task];
|
|
@@ -85,8 +88,13 @@
|
|
|
85
88
|
remove(task.id);
|
|
86
89
|
}
|
|
87
90
|
} else {
|
|
88
|
-
if (content)
|
|
89
|
-
|
|
91
|
+
if (content) {
|
|
92
|
+
if (content !== task.content || status !== task.status) {
|
|
93
|
+
update(task.id, content, status);
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
remove(task.id);
|
|
97
|
+
}
|
|
90
98
|
edit = null;
|
|
91
99
|
}
|
|
92
100
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { getContext } from "svelte";
|
|
3
|
-
import { Checkbox } from "
|
|
4
|
-
import { clickOutside } from "
|
|
3
|
+
import { Checkbox } from "@svar-ui/svelte-core";
|
|
4
|
+
import { clickOutside } from "@svar-ui/lib-dom";
|
|
5
5
|
|
|
6
6
|
let { task, edit, readonly, onupdate, onremove } = $props();
|
|
7
7
|
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
|
|
51
51
|
<div class="wx-task" class:wx-done={task.status}>
|
|
52
52
|
<div class="wx-checkbox-wrapper">
|
|
53
|
-
{#if edit === task.id}
|
|
53
|
+
{#if edit === task.id && task.id === -1}
|
|
54
54
|
<div class="wx-icon-add"><i class="wxi-plus"></i></div>
|
|
55
55
|
{:else}
|
|
56
56
|
<Checkbox onchange={handleStatus} value={task.status} />
|
|
@@ -76,6 +76,8 @@
|
|
|
76
76
|
|
|
77
77
|
<div class="wx-icon-close">
|
|
78
78
|
{#if !readonly && edit !== task.id}
|
|
79
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
80
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
79
81
|
<i class="wxi-close" onclick={() => onremove(task.id)}></i>
|
|
80
82
|
{/if}
|
|
81
83
|
</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import Layout from "./Layout.svelte";
|
|
3
|
-
import { Locale } from "
|
|
4
|
-
import { en } from "
|
|
3
|
+
import { Locale } from "@svar-ui/svelte-core";
|
|
4
|
+
import { en } from "@svar-ui/tasklist-locales";
|
|
5
5
|
|
|
6
6
|
const { ondata, onchange, value, ...props } = $props();
|
|
7
7
|
const finalData = $derived(ondata && value ? ondata(value) : value);
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Component } from "svelte";
|
|
2
|
+
|
|
3
|
+
export interface IChange {
|
|
4
|
+
action: "add" | "update" | "delete";
|
|
5
|
+
id?: string | number;
|
|
6
|
+
task?: ITask;
|
|
7
|
+
value: ITask[];
|
|
8
|
+
originalValue: string | number | ITask[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ITask {
|
|
12
|
+
id?: string | number;
|
|
13
|
+
content: string;
|
|
14
|
+
status?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export declare const Tasklist: Component<{
|
|
18
|
+
ondata?: (value: string | number) => Promise<ITask[]> | ITask[];
|
|
19
|
+
onchange?: (ev: IChange) => void;
|
|
20
|
+
value?: string | number | ITask[];
|
|
21
|
+
readonly?: boolean;
|
|
22
|
+
}>;
|
package/whatsnew.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## 2.4.0
|
|
2
|
+
|
|
3
|
+
### Fixes
|
|
4
|
+
|
|
5
|
+
- Checkbox is replaced by `plus` icon during editing
|
|
6
|
+
- The `onchange` event is issued after edit field was closed without actual changes
|
|
7
|
+
|
|
8
|
+
## 2.3.0
|
|
9
|
+
|
|
10
|
+
### New features
|
|
11
|
+
|
|
12
|
+
- TypeScript definitions
|
|
13
|
+
|
|
1
14
|
## 2.2.1
|
|
2
15
|
|
|
3
16
|
### Fixes
|