fuma 0.4.2 → 0.4.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.
@@ -1,22 +1,18 @@
1
1
  <script>import { mdiCalendarMonthOutline, mdiClose } from "@mdi/js";
2
2
  import dayjs from "dayjs";
3
3
  import { goto } from "$app/navigation";
4
- import { page } from "$app/stores";
5
4
  import { urlParam } from "../../store/param.js";
6
5
  import { formatRange } from "./format.js";
7
6
  import { Icon } from "../icon/index.js";
8
7
  import { DropDown } from "../menu/index.js";
9
8
  import { InputTime } from "../input/index.js";
10
9
  import { RangePicker } from "./index.js";
10
+ import { jsonParse } from "../../utils/jsonParse.js";
11
11
  export let minDate = void 0;
12
12
  export let maxDate = void 0;
13
13
  let dropDown;
14
- const start = $page.url.searchParams.get("start");
15
- const end = $page.url.searchParams.get("end");
16
- export let range = {
17
- start: start ? new Date(start) : void 0,
18
- end: end ? new Date(end) : void 0
19
- };
14
+ export let key = "range";
15
+ export let range = jsonParse($urlParam.get(key), { start: null, end: null });
20
16
  $:
21
17
  isValidPeriod = !!range.start && !!range.end;
22
18
  function getLabel(_range) {
@@ -30,16 +26,18 @@ function handleSubmit() {
30
26
  return;
31
27
  goto(
32
28
  $urlParam.with({
33
- start: dayjs(range.start).format("HH:mm"),
34
- end: dayjs(range.end).format("HH:mm")
29
+ [key]: JSON.stringify({
30
+ start: range.start?.toJSON(),
31
+ end: range.end?.toJSON()
32
+ })
35
33
  }),
36
34
  { replaceState: true, noScroll: true }
37
35
  );
38
36
  }
39
37
  function handleReset() {
40
38
  dropDown.hide();
41
- range = { start: void 0, end: void 0 };
42
- goto($urlParam.without("start", "end"), { replaceState: true, noScroll: true });
39
+ range = { start: null, end: null };
40
+ goto($urlParam.without(key), { replaceState: true, noScroll: true });
43
41
  }
44
42
  </script>
45
43
 
@@ -56,22 +54,9 @@ function handleReset() {
56
54
  {/if}
57
55
  </div>
58
56
 
59
- <form class="flex flex-col" on:submit|preventDefault={handleSubmit} data-sveltekit-replacestate>
57
+ <form class="flex flex-col" on:submit|preventDefault={handleSubmit}>
60
58
  <RangePicker numberOfMonths={1} bind:range {minDate} {maxDate} />
61
59
 
62
- <input
63
- class="hidden"
64
- type="text"
65
- name="start"
66
- value={range.start ? dayjs(range.start).toJSON() : ''}
67
- />
68
- <input
69
- class="hidden"
70
- type="text"
71
- name="end"
72
- value={range.end ? dayjs(range.end).toJSON() : ''}
73
- />
74
-
75
60
  <div class="flex gap-2 p-2">
76
61
  <InputTime
77
62
  label="A partir de"
@@ -4,6 +4,7 @@ declare const __propDef: {
4
4
  props: {
5
5
  minDate?: Date | number | string | undefined;
6
6
  maxDate?: Date | number | string | undefined;
7
+ key?: string | undefined;
7
8
  range?: Range | undefined;
8
9
  };
9
10
  events: {
@@ -1,4 +1,4 @@
1
- import { Dayjs } from 'dayjs';
1
+ import type { Dayjs } from 'dayjs';
2
2
  export type RangeDate = Date | Dayjs | null | undefined;
3
3
  export type Range = {
4
4
  start: RangeDate;
@@ -1 +1 @@
1
- import { Dayjs } from 'dayjs';
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fuma",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "My fullstack material build with sveltekit, daisyui, zod, prisma, lucia",
5
5
  "author": {
6
6
  "name": "Jonas Voisard",