smcgateway-sv 0.4.3 → 0.4.5

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.
@@ -5,14 +5,14 @@
5
5
  value = $bindable(),
6
6
  class: className = '',
7
7
  disabled = false,
8
- nodate = "",
8
+ nodate = '',
9
9
  min = new Date(2000, 1, 1),
10
10
  max = new Date()
11
11
  }: {
12
- value: Date | "";
12
+ value: Date | '';
13
13
  class?: string;
14
14
  disabled?: boolean;
15
- nodate?: Date | "";
15
+ nodate?: Date | '';
16
16
  min?: Date;
17
17
  max?: Date;
18
18
  } = $props();
@@ -38,14 +38,14 @@
38
38
  }
39
39
  });
40
40
 
41
- function toInputFormat(date: Date | ""): string {
41
+ function toInputFormat(date: Date | ''): string {
42
42
  if (date instanceof Date && !isNaN(date.getTime())) {
43
43
  let d = new Date(date);
44
44
  // Remove timezone
45
45
  d.setHours(0, -d.getTimezoneOffset(), 0, 0);
46
46
  return d.toISOString().substring(0, 10);
47
47
  }
48
- return new Date().toISOString().substring(0, 10);
48
+ return "";
49
49
  }
50
50
 
51
51
  function fromInputFormat(value: string): Date {
@@ -56,11 +56,22 @@
56
56
 
57
57
  function handleInput(event: Event) {
58
58
  const target = event.target as HTMLInputElement;
59
+ if (target.value == "") {
60
+ value = ""
61
+ internal = ""
62
+ return
63
+ }
59
64
  if (target.value) {
65
+ // Handle year being typed in
66
+ const ymd = target.value.split('-');
67
+ const y = parseInt(ymd[0]);
68
+ if (y < 1000) {
69
+ return;
70
+ }
60
71
  value = fromInputFormat(target.value);
61
72
  } else {
62
- value = nodate
63
- internal = ""
73
+ value = nodate;
74
+ internal = '';
64
75
  }
65
76
  }
66
77
  </script>
@@ -1,8 +1,8 @@
1
1
  type $$ComponentProps = {
2
- value: Date | "";
2
+ value: Date | '';
3
3
  class?: string;
4
4
  disabled?: boolean;
5
- nodate?: Date | "";
5
+ nodate?: Date | '';
6
6
  min?: Date;
7
7
  max?: Date;
8
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smcgateway-sv",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "author": "Kevin Golding <kevin.golding@smc-gateway.com> (https://smc-gateway.com)",
5
5
  "license": "MIT",
6
6
  "scripts": {