svelte-common 4.6.13 → 4.8.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 +11 -11
- package/src/index.svelte +8 -0
- package/src/sorting.mjs +26 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-common",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"prepare": "vite build",
|
|
24
24
|
"start": "vite",
|
|
25
25
|
"test": "npm run test:ava && npm run test:cafe",
|
|
26
|
-
"test:cafe": "testcafe $BROWSER:headless tests/cafe/*.js -s build/test --page-request-timeout 3000 --app-init-delay 3000 --app vite",
|
|
26
|
+
"test:cafe": "testcafe $BROWSER:headless tests/cafe/*.js -s build/test --page-request-timeout 3000 --app-init-delay 3000 --app \"vite preview\"",
|
|
27
27
|
"test:ava": "ava --timeout 2m tests/*.mjs",
|
|
28
28
|
"docs": "documentation readme --section=API ./src/**/*.mjs",
|
|
29
29
|
"lint": "npm run lint:css && npm run lint:docs",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"preview": "vite preview"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"svelte-command": "^1.1.
|
|
35
|
+
"svelte-command": "^1.1.23",
|
|
36
36
|
"svelte-entitlement": "^1.2.30"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
@@ -42,17 +42,17 @@
|
|
|
42
42
|
"@sveltejs/vite-plugin-svelte": "^1.0.1",
|
|
43
43
|
"ava": "^4.3.1",
|
|
44
44
|
"documentation": "^13.2.5",
|
|
45
|
-
"mf-styling": "^1.2.
|
|
46
|
-
"npm-pkgbuild": "^10.
|
|
45
|
+
"mf-styling": "^1.2.45",
|
|
46
|
+
"npm-pkgbuild": "^10.14.8",
|
|
47
47
|
"semantic-release": "^19.0.3",
|
|
48
|
-
"stylelint": "^14.
|
|
49
|
-
"stylelint-config-standard": "^
|
|
48
|
+
"stylelint": "^14.10.0",
|
|
49
|
+
"stylelint-config-standard": "^27.0.0",
|
|
50
50
|
"svelte": "^3.49.0",
|
|
51
|
-
"testcafe": "^1.20.
|
|
52
|
-
"vite": "^3.0.
|
|
51
|
+
"testcafe": "^1.20.1",
|
|
52
|
+
"vite": "^3.0.8"
|
|
53
53
|
},
|
|
54
54
|
"optionalDependencies": {
|
|
55
|
-
"mf-hosting": "^1.7.
|
|
55
|
+
"mf-hosting": "^1.7.2"
|
|
56
56
|
},
|
|
57
57
|
"repository": {
|
|
58
58
|
"type": "git",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"arlac77/template-cloudflare",
|
|
91
91
|
"arlac77/template-css",
|
|
92
92
|
"arlac77/template-pacman",
|
|
93
|
-
"arlac77/template-svelte-component
|
|
93
|
+
"arlac77/template-svelte-component"
|
|
94
94
|
]
|
|
95
95
|
}
|
|
96
96
|
}
|
package/src/index.svelte
CHANGED
|
@@ -44,5 +44,13 @@
|
|
|
44
44
|
formatDurationISO,
|
|
45
45
|
formatSecondsSinceEpoch
|
|
46
46
|
} from "./util.mjs";
|
|
47
|
+
export {
|
|
48
|
+
sortable,
|
|
49
|
+
toggleOrdeBy,
|
|
50
|
+
orderByCycle,
|
|
51
|
+
SORT_NONE,
|
|
52
|
+
SORT_ASCENDING,
|
|
53
|
+
SORT_DESCENDING
|
|
54
|
+
} from "./sorting.mjs";
|
|
47
55
|
export { initializeServiceWorker } from "./service-worker.mjs";
|
|
48
56
|
</script>
|
package/src/sorting.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const SORT_NONE = "none";
|
|
2
|
+
export const SORT_ASCENDING = "ascending";
|
|
3
|
+
export const SORT_DESCENDING = "descending";
|
|
4
|
+
|
|
5
|
+
export const orderByCycle = {
|
|
6
|
+
[SORT_NONE]: SORT_ASCENDING,
|
|
7
|
+
[SORT_ASCENDING]: SORT_DESCENDING,
|
|
8
|
+
[SORT_DESCENDING]: SORT_NONE
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Deliver next value in the order by cycle.
|
|
13
|
+
* SORT_NONE -> SORT_ASCENDING -> SORT_DESCENDING -> SORT_NONE ...
|
|
14
|
+
* @param {string} orderBy
|
|
15
|
+
* @returns {string} new order either SORT_NONE, SORT_ASCENDING or SORT_DESCENDING
|
|
16
|
+
*/
|
|
17
|
+
export function toggleOrdeBy(orderBy) { return orderByCycle[orderBy] || "none"; }
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Add sortable toggle to a node.
|
|
22
|
+
* @param {Node} node
|
|
23
|
+
*/
|
|
24
|
+
export function sortable(node) {
|
|
25
|
+
node.click = () => { node.sortable = toggleOrderBy(node.sortable); };
|
|
26
|
+
}
|