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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wx-svelte-tasklist",
3
- "version": "2.2.1",
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
- "wx-tasklist-locales": "2.2.1",
36
- "wx-lib-data-provider": "1.6.0",
37
- "wx-svelte-core": "2.2.1",
38
- "wx-lib-dom": "0.9.1",
39
- "wx-lib-state": "1.9.3"
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
- [![npm](https://img.shields.io/npm/v/wx-svelte-tasklist.svg)](https://www.npmjs.com/package/wx-svelte-tasklist)
5
+ [![npm](https://img.shields.io/npm/v/@svar-ui/svelte-tasklist.svg)](https://www.npmjs.com/package/@svar-ui/svelte-tasklist)
6
6
  [![License](https://img.shields.io/github/license/svar-widgets/tasklist)](https://github.com/svar-widgets/tasklist/blob/main/license.txt)
7
- [![npm downloads](https://img.shields.io/npm/dm/wx-svelte-tasklist.svg)](https://www.npmjs.com/package/wx-svelte-tasklist)
7
+ [![npm downloads](https://img.shields.io/npm/dm/@svar-ui/svelte-tasklist.svg)](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 "wx-svelte-tasklist";
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 "wx-svelte-core";
4
- import { delegateClick } from "wx-lib-dom";
5
- import { tempID } from "wx-lib-state";
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: "", state: false };
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
- state: false,
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) update(task.id, content, status);
89
- else remove(task.id);
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 "wx-svelte-core";
4
- import { clickOutside } from "wx-lib-dom";
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 "wx-svelte-core";
4
- import { en } from "wx-tasklist-locales";
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);
@@ -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