@heyramzi/tasks 0.5.0 → 0.5.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 +1 -1
- package/src/board-order.ts +17 -17
- package/src/dates.ts +1 -1
- package/src/index.ts +1 -1
- package/src/reorder.ts +1 -2
- package/src/side-panel-types.ts +16 -0
- package/src/side-panel.svelte +2 -13
package/package.json
CHANGED
package/src/board-order.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// (see the README credit). Kept inline so this package carries no runtime deps.
|
|
5
5
|
const DIGITS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
6
6
|
const INT_DIGITS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
7
|
-
const ZERO = DIGITS
|
|
7
|
+
const ZERO = DIGITS.charAt(0);
|
|
8
8
|
|
|
9
9
|
function integerLength(head: string): number {
|
|
10
10
|
const i = INT_DIGITS.indexOf(head);
|
|
@@ -14,13 +14,13 @@ function integerLength(head: string): number {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function integerPart(key: string): string {
|
|
17
|
-
const length = integerLength(key
|
|
17
|
+
const length = integerLength(key.charAt(0));
|
|
18
18
|
if (length > key.length) throw new Error("invalid order key: " + key);
|
|
19
19
|
return key.slice(0, length);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
function smallestInteger(): string {
|
|
23
|
-
return INT_DIGITS
|
|
23
|
+
return INT_DIGITS.charAt(0) + ZERO.repeat(INT_DIGITS.length / 2);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
function midpoint(a: string, b: string | null): string {
|
|
@@ -33,44 +33,44 @@ function midpoint(a: string, b: string | null): string {
|
|
|
33
33
|
if (n > 0) return b.slice(0, n) + midpoint(a.slice(n), b.slice(n));
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
const digitA = a ? DIGITS.indexOf(a
|
|
37
|
-
const digitB = b != null ? DIGITS.indexOf(b
|
|
36
|
+
const digitA = a ? DIGITS.indexOf(a.charAt(0)) : 0;
|
|
37
|
+
const digitB = b != null ? DIGITS.indexOf(b.charAt(0)) : DIGITS.length;
|
|
38
38
|
if (digitB - digitA > 1) {
|
|
39
|
-
return DIGITS
|
|
39
|
+
return DIGITS.charAt(Math.round(0.5 * (digitA + digitB)));
|
|
40
40
|
}
|
|
41
41
|
if (b && b.length > 1) return b.slice(0, 1);
|
|
42
|
-
return DIGITS
|
|
42
|
+
return DIGITS.charAt(digitA) + midpoint(a.slice(1), null);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
function incrementInteger(x: string): string | null {
|
|
46
|
-
const head = x
|
|
46
|
+
const head = x.charAt(0);
|
|
47
47
|
let trailing = "";
|
|
48
48
|
for (let i = x.length - 1; i >= 1; i--) {
|
|
49
|
-
const d = DIGITS.indexOf(x
|
|
49
|
+
const d = DIGITS.indexOf(x.charAt(i)) + 1;
|
|
50
50
|
if (d === DIGITS.length) trailing = ZERO + trailing;
|
|
51
|
-
else return head + x.slice(1, i) + DIGITS
|
|
51
|
+
else return head + x.slice(1, i) + DIGITS.charAt(d) + trailing;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
const headIndex = INT_DIGITS.indexOf(head);
|
|
55
55
|
if (headIndex === INT_DIGITS.length - 1) return null;
|
|
56
|
-
const h = INT_DIGITS
|
|
56
|
+
const h = INT_DIGITS.charAt(headIndex + 1);
|
|
57
57
|
const delta = integerLength(h) - integerLength(head);
|
|
58
58
|
return h + (delta > 0 ? trailing + ZERO : delta < 0 ? trailing.slice(1) : trailing);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
function decrementInteger(x: string): string | null {
|
|
62
|
-
const head = x
|
|
63
|
-
const last = DIGITS
|
|
62
|
+
const head = x.charAt(0);
|
|
63
|
+
const last = DIGITS.charAt(DIGITS.length - 1);
|
|
64
64
|
let trailing = "";
|
|
65
65
|
for (let i = x.length - 1; i >= 1; i--) {
|
|
66
|
-
const d = DIGITS.indexOf(x
|
|
66
|
+
const d = DIGITS.indexOf(x.charAt(i)) - 1;
|
|
67
67
|
if (d === -1) trailing = last + trailing;
|
|
68
|
-
else return head + x.slice(1, i) + DIGITS
|
|
68
|
+
else return head + x.slice(1, i) + DIGITS.charAt(d) + trailing;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
const headIndex = INT_DIGITS.indexOf(head);
|
|
72
72
|
if (headIndex === 0) return null;
|
|
73
|
-
const h = INT_DIGITS
|
|
73
|
+
const h = INT_DIGITS.charAt(headIndex - 1);
|
|
74
74
|
const delta = integerLength(h) - integerLength(head);
|
|
75
75
|
return h + (delta > 0 ? trailing + last : delta < 0 ? trailing.slice(1) : trailing);
|
|
76
76
|
}
|
|
@@ -80,7 +80,7 @@ export function keyBetween(a: string | null, b: string | null): string {
|
|
|
80
80
|
if (a != null && b != null && a > b) [a, b] = [b, a];
|
|
81
81
|
|
|
82
82
|
if (a == null) {
|
|
83
|
-
if (b == null) return INT_DIGITS
|
|
83
|
+
if (b == null) return INT_DIGITS.charAt(INT_DIGITS.length / 2) + ZERO;
|
|
84
84
|
const ib = integerPart(b);
|
|
85
85
|
const fb = b.slice(ib.length);
|
|
86
86
|
if (ib === smallestInteger()) return ib + midpoint("", fb);
|
package/src/dates.ts
CHANGED
|
@@ -4,7 +4,7 @@ const DAY_MS = 86_400_000;
|
|
|
4
4
|
|
|
5
5
|
/** Days since 1970-01-01 for an ISO date. Anything after the date part is ignored. */
|
|
6
6
|
export function dayNumber(iso: string): number {
|
|
7
|
-
const [y, m, d] = iso.slice(0, 10).split("-").map(Number);
|
|
7
|
+
const [y = 1970, m = 1, d = 1] = iso.slice(0, 10).split("-").map(Number);
|
|
8
8
|
return Math.round(Date.UTC(y, m - 1, d) / DAY_MS);
|
|
9
9
|
}
|
|
10
10
|
|
package/src/index.ts
CHANGED
|
@@ -25,7 +25,7 @@ export type {
|
|
|
25
25
|
Statuses,
|
|
26
26
|
} from "./status-types.js";
|
|
27
27
|
export { default as SidePanel } from "./side-panel.svelte";
|
|
28
|
-
export type { PanelStat, SidePanelWidth } from "./side-panel.
|
|
28
|
+
export type { PanelStat, SidePanelWidth } from "./side-panel-types.js";
|
|
29
29
|
export { default as TaskList } from "./task-list.svelte";
|
|
30
30
|
export { default as TaskGantt } from "./task-gantt.svelte";
|
|
31
31
|
export { addDays, dayNumber, isoFromDay, todayIso } from "./dates.js";
|
package/src/reorder.ts
CHANGED
|
@@ -14,7 +14,6 @@ export function reorderByIds<Item extends Identifiable>(
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
const next = items.slice();
|
|
17
|
-
|
|
18
|
-
next.splice(overIndex, 0, moved);
|
|
17
|
+
next.splice(overIndex, 0, ...next.splice(activeIndex, 1));
|
|
19
18
|
return next;
|
|
20
19
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// In a .ts file, not the panel's module script, so a plain `tsc` consumer of the
|
|
2
|
+
// barrel can read them. tsc sees a .svelte file as a default export only.
|
|
3
|
+
|
|
4
|
+
/** How wide the panel opens from `sm` (a short form) to `2xl` (a reader). Under
|
|
5
|
+
the `sm` breakpoint every panel is full width. */
|
|
6
|
+
export type SidePanelWidth = "sm" | "md" | "lg" | "xl" | "2xl";
|
|
7
|
+
|
|
8
|
+
/** One number the record is judged on. They sit in the header, in the order given. */
|
|
9
|
+
export type PanelStat = {
|
|
10
|
+
label: string;
|
|
11
|
+
value: string;
|
|
12
|
+
/** A quiet note beside the value: the rate behind a count, or what the figure is. */
|
|
13
|
+
sub?: string;
|
|
14
|
+
/** One severity vocabulary: a count that should be zero is `bad`. */
|
|
15
|
+
tone?: "default" | "muted" | "good" | "bad";
|
|
16
|
+
};
|
package/src/side-panel.svelte
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export type SidePanelWidth = "sm" | "md" | "lg" | "xl" | "2xl";
|
|
5
|
-
|
|
6
|
-
/** One number the record is judged on. They sit in the header, in the order given. */
|
|
7
|
-
export type PanelStat = {
|
|
8
|
-
label: string;
|
|
9
|
-
value: string;
|
|
10
|
-
/** A quiet note beside the value: the rate behind a count, or what the figure is. */
|
|
11
|
-
sub?: string;
|
|
12
|
-
/** One severity vocabulary: a count that should be zero is `bad`. */
|
|
13
|
-
tone?: "default" | "muted" | "good" | "bad";
|
|
14
|
-
};
|
|
2
|
+
import type { PanelStat, SidePanelWidth } from "./side-panel-types.js";
|
|
3
|
+
export type { PanelStat, SidePanelWidth };
|
|
15
4
|
</script>
|
|
16
5
|
|
|
17
6
|
<script lang="ts">
|