wx-svelte-tasklist 2.3.0 → 2.4.1
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 +4 -4
- package/src/components/Layout.svelte +18 -13
- package/src/components/Task.svelte +47 -3
- package/whatsnew.md +15 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wx-svelte-tasklist",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "Simple Svelte component for adding a task list section on a page",
|
|
5
5
|
"productTag": "tasklist",
|
|
6
6
|
"productTrial": false,
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://svar.dev/svelte/core/",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@svar-ui/tasklist-locales": "2.
|
|
36
|
+
"@svar-ui/tasklist-locales": "2.4.1",
|
|
37
37
|
"@svar-ui/lib-data-provider": "1.7.1",
|
|
38
|
-
"@svar-ui/svelte-core": "2.
|
|
39
|
-
"@svar-ui/lib-dom": "0.
|
|
38
|
+
"@svar-ui/svelte-core": "2.4.1",
|
|
39
|
+
"@svar-ui/lib-dom": "0.12.0",
|
|
40
40
|
"@svar-ui/lib-state": "1.9.6"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { getContext } from "svelte";
|
|
2
|
+
import { getContext, setContext } from "svelte";
|
|
3
3
|
import { Button } from "@svar-ui/svelte-core";
|
|
4
|
-
import { delegateClick } from "@svar-ui/lib-dom";
|
|
5
4
|
import { tempID } from "@svar-ui/lib-state";
|
|
6
5
|
import Task from "./Task.svelte";
|
|
7
6
|
|
|
@@ -9,6 +8,9 @@
|
|
|
9
8
|
|
|
10
9
|
const _ = getContext("wx-i18n").getGroup("tasklist");
|
|
11
10
|
|
|
11
|
+
//prevent associating Checkboxes with outer Field label
|
|
12
|
+
setContext("wx-input-id", null);
|
|
13
|
+
|
|
12
14
|
const data = $derived(rawData ?? []);
|
|
13
15
|
let edit = $state(null);
|
|
14
16
|
let editTask = $state(null);
|
|
@@ -73,6 +75,10 @@
|
|
|
73
75
|
remove(id);
|
|
74
76
|
}
|
|
75
77
|
|
|
78
|
+
function onedit(id) {
|
|
79
|
+
if (!readonly) edit = id;
|
|
80
|
+
}
|
|
81
|
+
|
|
76
82
|
function onupdate({ task, content, status, next }) {
|
|
77
83
|
if (task.id === -1) {
|
|
78
84
|
edit = null;
|
|
@@ -85,26 +91,25 @@
|
|
|
85
91
|
remove(task.id);
|
|
86
92
|
}
|
|
87
93
|
} else {
|
|
88
|
-
if (content)
|
|
89
|
-
|
|
94
|
+
if (content) {
|
|
95
|
+
if (content !== task.content || status !== task.status) {
|
|
96
|
+
update(task.id, content, status);
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
remove(task.id);
|
|
100
|
+
}
|
|
90
101
|
edit = null;
|
|
91
102
|
}
|
|
92
103
|
}
|
|
93
|
-
|
|
94
|
-
const bodyClickHandlers = {
|
|
95
|
-
dblclick: id => {
|
|
96
|
-
if (!readonly) edit = id;
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
104
|
</script>
|
|
100
105
|
|
|
101
106
|
<div class="wx-tasks-list">
|
|
102
|
-
<div class="wx-list"
|
|
107
|
+
<div class="wx-list">
|
|
103
108
|
{#each data as task (task.id)}
|
|
104
|
-
<Task {task} {edit} {onupdate} {onremove} {readonly} />
|
|
109
|
+
<Task {task} {edit} {onupdate} {onremove} {onedit} {readonly} />
|
|
105
110
|
{/each}
|
|
106
111
|
{#if edit === -1}
|
|
107
|
-
<Task task={editTask} {edit} {onupdate}
|
|
112
|
+
<Task task={editTask} {edit} {onupdate} />
|
|
108
113
|
{/if}
|
|
109
114
|
</div>
|
|
110
115
|
{#if !readonly && edit !== -1}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { Checkbox } from "@svar-ui/svelte-core";
|
|
4
4
|
import { clickOutside } from "@svar-ui/lib-dom";
|
|
5
5
|
|
|
6
|
-
let { task, edit, readonly, onupdate, onremove } = $props();
|
|
6
|
+
let { task, edit, readonly, onupdate, onremove, onedit } = $props();
|
|
7
7
|
|
|
8
8
|
const _ = getContext("wx-i18n").getGroup("tasklist");
|
|
9
9
|
|
|
@@ -46,11 +46,15 @@
|
|
|
46
46
|
adjustHeight();
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
|
+
|
|
50
|
+
function handleEditClick() {
|
|
51
|
+
onedit(task.id);
|
|
52
|
+
}
|
|
49
53
|
</script>
|
|
50
54
|
|
|
51
55
|
<div class="wx-task" class:wx-done={task.status}>
|
|
52
56
|
<div class="wx-checkbox-wrapper">
|
|
53
|
-
{#if edit === task.id}
|
|
57
|
+
{#if edit === task.id && task.id === -1}
|
|
54
58
|
<div class="wx-icon-add"><i class="wxi-plus"></i></div>
|
|
55
59
|
{:else}
|
|
56
60
|
<Checkbox onchange={handleStatus} value={task.status} />
|
|
@@ -68,14 +72,25 @@
|
|
|
68
72
|
oninput={handleContent}
|
|
69
73
|
></textarea>
|
|
70
74
|
{:else}
|
|
71
|
-
|
|
75
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
76
|
+
<div class="wx-text-wrapper" ondblclick={() => onedit(task.id)}>
|
|
72
77
|
<span class="wx-text">{task.content}</span>
|
|
73
78
|
</div>
|
|
74
79
|
{/if}
|
|
75
80
|
</div>
|
|
76
81
|
|
|
82
|
+
<div class="wx-icon-edit">
|
|
83
|
+
{#if !readonly && edit !== task.id}
|
|
84
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
85
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
86
|
+
<i class="wxi-edit" onclick={handleEditClick}></i>
|
|
87
|
+
{/if}
|
|
88
|
+
</div>
|
|
89
|
+
|
|
77
90
|
<div class="wx-icon-close">
|
|
78
91
|
{#if !readonly && edit !== task.id}
|
|
92
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
93
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
79
94
|
<i class="wxi-close" onclick={() => onremove(task.id)}></i>
|
|
80
95
|
{/if}
|
|
81
96
|
</div>
|
|
@@ -172,6 +187,35 @@
|
|
|
172
187
|
color: var(--wx-color-font-alt);
|
|
173
188
|
}
|
|
174
189
|
|
|
190
|
+
.wx-icon-edit {
|
|
191
|
+
color: var(--wx-color-font-alt);
|
|
192
|
+
margin-left: 8px;
|
|
193
|
+
font-size: 20px;
|
|
194
|
+
height: 20px;
|
|
195
|
+
width: 20px;
|
|
196
|
+
opacity: 0;
|
|
197
|
+
transition: 0.3s linear;
|
|
198
|
+
display: none;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.wx-icon-edit .wxi-edit {
|
|
202
|
+
cursor: pointer;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.wx-icon-edit .wxi-edit:hover {
|
|
206
|
+
color: var(--wx-color-primary);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
@media (hover: none) {
|
|
210
|
+
.wx-icon-edit {
|
|
211
|
+
display: block;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.wx-task:hover .wx-icon-edit {
|
|
215
|
+
opacity: 1;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
175
219
|
.wx-icon-close {
|
|
176
220
|
color: var(--wx-color-font-alt);
|
|
177
221
|
margin-left: 8px;
|
package/whatsnew.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## 2.4.1
|
|
2
|
+
|
|
3
|
+
### Fixes
|
|
4
|
+
|
|
5
|
+
- Tasks cannot be edited on touch devices
|
|
6
|
+
|
|
7
|
+
## 2.4.0
|
|
8
|
+
|
|
9
|
+
### Fixes
|
|
10
|
+
|
|
11
|
+
- Checkbox is replaced by `plus` icon during editing
|
|
12
|
+
- The `onchange` event is issued after edit field was closed without actual changes
|
|
13
|
+
|
|
1
14
|
## 2.3.0
|
|
2
15
|
|
|
3
16
|
### New features
|
|
@@ -12,11 +25,11 @@
|
|
|
12
25
|
|
|
13
26
|
## 2.2.0
|
|
14
27
|
|
|
15
|
-
- Using
|
|
28
|
+
- Using Svelte Core v2.2.0
|
|
16
29
|
|
|
17
30
|
## 2.1.0
|
|
18
31
|
|
|
19
|
-
- Using
|
|
32
|
+
- Using Svelte Core v2.1.0
|
|
20
33
|
|
|
21
34
|
## 2.0.0
|
|
22
35
|
|