fuma 0.3.43 → 0.3.44
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/dist/ui/input/InputTime.svelte +5 -13
- package/dist/ui/period/PeriodPickerButton.svelte +6 -5
- package/dist/ui/table/head/TableHeadDate.svelte +7 -6
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/time.d.ts +2 -0
- package/dist/utils/time.js +13 -0
- package/package.json +1 -1
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import {
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
import { FormControl } from "./index.js";
|
|
3
|
+
import { msToTime } from "../../utils/time.js";
|
|
3
4
|
export let value = void 0;
|
|
4
5
|
export let input = {};
|
|
5
6
|
$:
|
|
6
7
|
({ class: inputClass = "", ...inputProps } = input);
|
|
7
8
|
let valueAsNumber = value;
|
|
8
|
-
let valueAsString =
|
|
9
|
+
let valueAsString = msToTime(value);
|
|
9
10
|
$:
|
|
10
11
|
if (value !== valueAsNumber)
|
|
11
|
-
valueAsString =
|
|
12
|
+
valueAsString = msToTime(value);
|
|
12
13
|
const dispatch = createEventDispatcher();
|
|
13
|
-
function msToString(ms) {
|
|
14
|
-
if (ms === null || ms === void 0)
|
|
15
|
-
return "";
|
|
16
|
-
const hours = Math.floor(ms / (1e3 * 60 * 60));
|
|
17
|
-
const minutes = Math.floor(ms / (1e3 * 60) - hours * 60);
|
|
18
|
-
const secondes = Math.floor(ms / 1e3 - minutes * 60);
|
|
19
|
-
const format = (n) => n.toString().padStart(2, "0");
|
|
20
|
-
return [format(hours), format(minutes), format(secondes)].join(":");
|
|
21
|
-
}
|
|
22
14
|
const onInput = (event) => {
|
|
23
15
|
valueAsNumber = event.currentTarget.valueAsNumber;
|
|
24
16
|
value = valueAsNumber;
|
|
@@ -7,6 +7,7 @@ import { Icon } from "../icon/index.js";
|
|
|
7
7
|
import { DropDown } from "../menu/index.js";
|
|
8
8
|
import { InputTime } from "../input/index.js";
|
|
9
9
|
import { PeriodPicker } from "./index.js";
|
|
10
|
+
import { msToTime, timeToMs } from "../../utils/time.js";
|
|
10
11
|
let dropDown;
|
|
11
12
|
const start = $page.url.searchParams.get("start")?.split("T") || [];
|
|
12
13
|
const end = $page.url.searchParams.get("end")?.split("T") || [];
|
|
@@ -15,8 +16,8 @@ let period = {
|
|
|
15
16
|
end: end[0] || ""
|
|
16
17
|
};
|
|
17
18
|
let time = {
|
|
18
|
-
start: start[1] || "00:00",
|
|
19
|
-
end: end[1] || "23:59"
|
|
19
|
+
start: timeToMs(start[1] || "00:00"),
|
|
20
|
+
end: timeToMs(end[1] || "23:59")
|
|
20
21
|
};
|
|
21
22
|
$:
|
|
22
23
|
isValidPeriod = period.start && period.end && time.start && time.start;
|
|
@@ -24,8 +25,8 @@ function getLabel(_period, _time) {
|
|
|
24
25
|
if (!_period || !_period.start || !_period.end)
|
|
25
26
|
return "P\xE9riodes";
|
|
26
27
|
return formatRange({
|
|
27
|
-
start: /* @__PURE__ */ new Date(`${_period.start}T${_time.start}`),
|
|
28
|
-
end: /* @__PURE__ */ new Date(`${_period.end}T${_time.end}`)
|
|
28
|
+
start: /* @__PURE__ */ new Date(`${_period.start}T${msToTime(_time.start)}`),
|
|
29
|
+
end: /* @__PURE__ */ new Date(`${_period.end}T${msToTime(_time.end)}`)
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
function handleSubmit() {
|
|
@@ -43,7 +44,7 @@ function handleSubmit() {
|
|
|
43
44
|
function handleReset() {
|
|
44
45
|
dropDown.hide();
|
|
45
46
|
period = { start: "", end: "" };
|
|
46
|
-
time = { start:
|
|
47
|
+
time = { start: 0, end: timeToMs("23:59") };
|
|
47
48
|
goto($urlParam.without("start", "end"), { replaceState: true, noScroll: true });
|
|
48
49
|
}
|
|
49
50
|
</script>
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
<script>import { goto } from "$app/navigation";
|
|
2
2
|
import { page } from "$app/stores";
|
|
3
|
+
import { mdiCalendarFilterOutline } from "@mdi/js";
|
|
3
4
|
import { DropDown } from "../../menu/index.js";
|
|
4
5
|
import { InputTime } from "../../input/index.js";
|
|
5
6
|
import { formatRange } from "../../../utils/formatRange.js";
|
|
7
|
+
import { msToTime, timeToMs } from "../../../utils/time.js";
|
|
6
8
|
import { PeriodPicker } from "../../period/index.js";
|
|
7
9
|
import { urlParam } from "../../../store/param.js";
|
|
8
10
|
import { jsonParse } from "../../../utils/jsonParse.js";
|
|
9
11
|
import { Icon } from "../../icon/index.js";
|
|
10
|
-
import { mdiCalendarFilterOutline } from "@mdi/js";
|
|
11
12
|
export let field;
|
|
12
13
|
let dropDown;
|
|
13
14
|
const initialValue = jsonParse(
|
|
@@ -21,15 +22,15 @@ let period = {
|
|
|
21
22
|
end: end[0] || ""
|
|
22
23
|
};
|
|
23
24
|
let time = {
|
|
24
|
-
start: start[1] || "00:00",
|
|
25
|
-
end: end[1] || "23:59"
|
|
25
|
+
start: timeToMs(start[1] || "00:00"),
|
|
26
|
+
end: timeToMs(end[1] || "23:59")
|
|
26
27
|
};
|
|
27
28
|
$:
|
|
28
29
|
isValidPeriod = period.start && period.end && time.start && time.start;
|
|
29
30
|
function getLabel(_period, _time) {
|
|
30
31
|
return formatRange({
|
|
31
|
-
start: /* @__PURE__ */ new Date(`${_period.start}T${_time.start}`),
|
|
32
|
-
end: /* @__PURE__ */ new Date(`${_period.end}T${_time.end}`)
|
|
32
|
+
start: /* @__PURE__ */ new Date(`${_period.start}T${msToTime(_time.start)}`),
|
|
33
|
+
end: /* @__PURE__ */ new Date(`${_period.end}T${msToTime(_time.end)}`)
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
function handleSubmit() {
|
|
@@ -53,7 +54,7 @@ function handleSubmit() {
|
|
|
53
54
|
function handleReset() {
|
|
54
55
|
dropDown.hide();
|
|
55
56
|
period = { start: "", end: "" };
|
|
56
|
-
time = { start:
|
|
57
|
+
time = { start: 0, end: timeToMs("23:59") };
|
|
57
58
|
goto($urlParam.without(field.key, "skip", "take"), { replaceState: true, noScroll: true });
|
|
58
59
|
}
|
|
59
60
|
</script>
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function msToTime(ms) {
|
|
2
|
+
if (ms === null || ms === undefined)
|
|
3
|
+
return '';
|
|
4
|
+
const hours = Math.floor(ms / (1000 * 60 * 60));
|
|
5
|
+
const minutes = Math.floor(ms / (1000 * 60) - hours * 60);
|
|
6
|
+
const secondes = Math.floor(ms / 1000 - minutes * 60 - hours * 60 * 60);
|
|
7
|
+
const format = (n) => n.toString().padStart(2, '0');
|
|
8
|
+
return [format(hours % 24), format(minutes), format(secondes)].join(':');
|
|
9
|
+
}
|
|
10
|
+
export function timeToMs(time) {
|
|
11
|
+
const [h = 0, m = 0, s = 0] = time.split(':').map((s) => +s);
|
|
12
|
+
return (h * 60 * 60 + m * 60 + s) * 1000;
|
|
13
|
+
}
|