svelte-common 6.10.3 → 6.10.4

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": "svelte-common",
3
- "version": "6.10.3",
3
+ "version": "6.10.4",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -61,7 +61,7 @@
61
61
  "c8": "^9.1.0",
62
62
  "documentation": "^14.0.3",
63
63
  "mf-styling": "^3.1.6",
64
- "npm-pkgbuild": "^15.2.5",
64
+ "npm-pkgbuild": "^15.3.0",
65
65
  "semantic-release": "^23.0.8",
66
66
  "stylelint": "^16.3.1",
67
67
  "stylelint-config-standard": "^36.0.0",
@@ -1,9 +1,12 @@
1
+ import { readable } from "svelte/store";
2
+
1
3
  /**
2
4
  * Pagination support store.
3
5
  * Pages go from 1 ... numberOfPages
4
- * @param {Map|Set|Array|Store} data
6
+ * @param {Map|Set|Array|readable} data
5
7
  * @param {Object} options
6
8
  * @param {number} [options.itemsPerPage]
9
+ * @param {number} [options.page]
7
10
  * @param {Function} [options.sorter]
8
11
  * @param {Function} [options.filter]
9
12
  */
@@ -164,8 +167,8 @@ export class Pagination {
164
167
  }
165
168
 
166
169
  /**
167
- * @see @link https://getbootstrap.com/docs/4.0/components/pagination
168
- * @see @link https://a11y-style-guide.com/style-guide/section-navigation.html#kssref-navigation-pagination
170
+ * @see https://getbootstrap.com/docs/4.0/components/pagination
171
+ * @see https://a11y-style-guide.com/style-guide/section-navigation.html#kssref-navigation-pagination
169
172
  */
170
173
  get pageNavigationElement() {
171
174
  const nav = document.createElement("nav");
package/src/sorting.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { getAttribute } from "pacc";
2
+ import { writable } from "svelte/store";
2
3
 
3
4
  export const SORT_NONE = "none";
4
5
  export const SORT_ASCENDING = "ascending";
@@ -27,7 +28,7 @@ export function toggleOrderBy(orderBy) {
27
28
  * Add sortable toggle button to a th node.
28
29
  * Synchronizes store value with the nodes "aria-sort" attribute.
29
30
  * @param {Element} th the header node
30
- * @param {WritableStore} store keep in sync with sorting properties
31
+ * @param {writable} store keep in sync with sorting properties
31
32
  */
32
33
  export function sortable(th, store) {
33
34
  const unsubscribe = store.subscribe(orderBy =>
package/src/util.mjs CHANGED
@@ -1,3 +1,5 @@
1
+ import { writable } from "svelte/store";
2
+
1
3
  export const dateFormatter = new Intl.DateTimeFormat("default", {
2
4
  year: "numeric",
3
5
  month: "numeric",
@@ -39,10 +41,10 @@ export function formatDurationISO(seconds) {
39
41
  t = true;
40
42
  }
41
43
 
42
- const n = Math.floor(seconds / d[0]);
44
+ const n = Math.floor(seconds / Number(d[0]));
43
45
  if (n > 0) {
44
46
  out += `${n}${d[1]}`;
45
- seconds -= n * d[0];
47
+ seconds -= n * Number(d[0]);
46
48
  }
47
49
  }
48
50
 
@@ -60,10 +62,10 @@ const durations = [
60
62
  export function formatDuration(seconds) {
61
63
  const out = [];
62
64
  for (const d of durations) {
63
- const n = Math.floor(seconds / d[0]);
65
+ const n = Math.floor(seconds / Number(d[0]));
64
66
  if (n > 0) {
65
67
  out.push(`${n}${d[1]}`);
66
- seconds -= n * d[0];
68
+ seconds -= n * Number(d[0]);
67
69
  }
68
70
  }
69
71
 
@@ -100,9 +102,9 @@ function liveDuration(seconds) {
100
102
  * ```
101
103
  * { a: 1, b: 2 } -> { foo_a: 1 foo_b: 2 } // prefix: foo_
102
104
  * ```
103
- * @param {WriteableStore} store we derive from
105
+ * @param {writable} store we derive from
104
106
  * @param {string} prefix for each key
105
- * @returns {WriteableStore}
107
+ * @returns {writable}
106
108
  */
107
109
  export function keyPrefixStore(store, prefix) {
108
110
  const subscriptions = new Set();
@@ -10,9 +10,10 @@ export function navigationItems(numberOfPages: number, currentPage: number, numb
10
10
  /**
11
11
  * Pagination support store.
12
12
  * Pages go from 1 ... numberOfPages
13
- * @param {Map|Set|Array|Store} data
13
+ * @param {Map|Set|Array|readable} data
14
14
  * @param {Object} options
15
15
  * @param {number} [options.itemsPerPage]
16
+ * @param {number} [options.page]
16
17
  * @param {Function} [options.sorter]
17
18
  * @param {Function} [options.filter]
18
19
  */
@@ -56,8 +57,8 @@ export class Pagination {
56
57
  */
57
58
  get length(): number;
58
59
  /**
59
- * @see @link https://getbootstrap.com/docs/4.0/components/pagination
60
- * @see @link https://a11y-style-guide.com/style-guide/section-navigation.html#kssref-navigation-pagination
60
+ * @see https://getbootstrap.com/docs/4.0/components/pagination
61
+ * @see https://a11y-style-guide.com/style-guide/section-navigation.html#kssref-navigation-pagination
61
62
  */
62
63
  get pageNavigationElement(): HTMLElement;
63
64
  [Symbol.iterator](): Generator<any, void, any>;
@@ -1,3 +1,4 @@
1
+ /// <reference types="svelte" />
1
2
  /**
2
3
  * Deliver next value in the order by cycle.
3
4
  * SORT_NONE -> SORT_ASCENDING -> SORT_DESCENDING -> SORT_NONE ...
@@ -9,9 +10,9 @@ export function toggleOrderBy(orderBy: string): string;
9
10
  * Add sortable toggle button to a th node.
10
11
  * Synchronizes store value with the nodes "aria-sort" attribute.
11
12
  * @param {Element} th the header node
12
- * @param {WritableStore} store keep in sync with sorting properties
13
+ * @param {writable} store keep in sync with sorting properties
13
14
  */
14
- export function sortable(th: Element, store: WritableStore): {
15
+ export function sortable(th: Element, store: typeof writable): {
15
16
  destroy(): void;
16
17
  };
17
18
  /**
@@ -30,3 +31,4 @@ export namespace orderByCycle {
30
31
  export { SORT_DESCENDING as ascending };
31
32
  export { SORT_ASCENDING as descending };
32
33
  }
34
+ import { writable } from "svelte/store";
package/types/util.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="svelte" />
1
2
  export function formatBytes(bytes: any, decimals?: number): string;
2
3
  export function formatDurationISO(seconds: any): string;
3
4
  export function formatDuration(seconds: any): string;
@@ -7,9 +8,10 @@ export function formatSecondsSinceEpoch(sse: any): string;
7
8
  * ```
8
9
  * { a: 1, b: 2 } -> { foo_a: 1 foo_b: 2 } // prefix: foo_
9
10
  * ```
10
- * @param {WriteableStore} store we derive from
11
+ * @param {writable} store we derive from
11
12
  * @param {string} prefix for each key
12
- * @returns {WriteableStore}
13
+ * @returns {writable}
13
14
  */
14
- export function keyPrefixStore(store: WriteableStore, prefix: string): WriteableStore;
15
+ export function keyPrefixStore(store: typeof writable, prefix: string): typeof writable;
15
16
  export const dateFormatter: Intl.DateTimeFormat;
17
+ import { writable } from "svelte/store";