smcgateway-sv 0.4.6 → 0.4.8

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.
@@ -3,13 +3,16 @@
3
3
 
4
4
  let {
5
5
  value = $bindable(),
6
+ id = '',
6
7
  class: className = '',
7
8
  disabled = false,
8
9
  nodate = '',
9
10
  min = new Date(2000, 1, 1),
10
- max = new Date()
11
+ max = new Date(),
12
+ ...rest
11
13
  }: {
12
14
  value: Date | '' | undefined;
15
+ id?: string;
13
16
  class?: string;
14
17
  disabled?: boolean;
15
18
  nodate?: Date | '';
@@ -45,7 +48,7 @@
45
48
  d.setHours(0, -d.getTimezoneOffset(), 0, 0);
46
49
  return d.toISOString().substring(0, 10);
47
50
  }
48
- return "";
51
+ return '';
49
52
  }
50
53
 
51
54
  function fromInputFormat(value: string): Date {
@@ -56,10 +59,10 @@
56
59
 
57
60
  function handleInput(event: Event) {
58
61
  const target = event.target as HTMLInputElement;
59
- if (target.value == "") {
60
- value = ""
61
- internal = ""
62
- return
62
+ if (target.value == '') {
63
+ value = '';
64
+ internal = '';
65
+ return;
63
66
  }
64
67
  if (target.value) {
65
68
  // Handle year being typed in
@@ -78,6 +81,7 @@
78
81
 
79
82
  <input
80
83
  type="date"
84
+ {id}
81
85
  class={className}
82
86
  {disabled}
83
87
  min={minDate}
@@ -1,5 +1,6 @@
1
1
  type $$ComponentProps = {
2
2
  value: Date | '' | undefined;
3
+ id?: string;
3
4
  class?: string;
4
5
  disabled?: boolean;
5
6
  nodate?: Date | '';
@@ -3,20 +3,23 @@
3
3
 
4
4
  let {
5
5
  value = $bindable(),
6
+ id = "",
6
7
  class: className = '',
7
8
  disabled = false,
8
9
  nodate = '',
9
10
  min = new Date(2000, 1, 1),
10
11
  max = new Date(),
11
- onchange = (e:Event) => {}
12
+ onchange = (e: Event) => {},
13
+ ...rest
12
14
  }: {
13
15
  value: Date | '';
16
+ id?: string;
14
17
  class?: string;
15
18
  disabled?: boolean;
16
19
  nodate?: Date | '';
17
20
  min?: Date;
18
21
  max?: Date;
19
- onchange?: (e:Event) => void;
22
+ onchange?: (e: Event) => void;
20
23
  } = $props();
21
24
 
22
25
  let minDate = $derived(toInputFormat(min));
@@ -72,10 +75,12 @@
72
75
 
73
76
  <input
74
77
  type="datetime-local"
78
+ {id}
75
79
  class={className}
76
80
  {disabled}
77
81
  min={minDate}
78
82
  max={maxDate}
79
83
  value={internal}
80
84
  oninput={handleInput}
85
+ {...rest}
81
86
  />
@@ -1,5 +1,6 @@
1
1
  type $$ComponentProps = {
2
2
  value: Date | '';
3
+ id?: string;
3
4
  class?: string;
4
5
  disabled?: boolean;
5
6
  nodate?: Date | '';
package/dist/index.d.ts CHANGED
@@ -12,5 +12,6 @@ import { recording, type Recording } from "./recording.svelte.js";
12
12
  import AudioTimeLinePlayer from "./AudioTimeLinePlayer.svelte";
13
13
  import VoicePlayer from "./VoicePlayer.svelte";
14
14
  import csv from "./csv.js";
15
- export { auth, gtime, geofence, device, ghistory, InputDate, InputDatetime, InputDebounced, InputIdentUri, LoginForm, recording, AudioTimeLinePlayer, VoicePlayer, csv, };
15
+ import settings from "./settings.svelte.js";
16
+ export { auth, gtime, geofence, device, ghistory, InputDate, InputDatetime, InputDebounced, InputIdentUri, LoginForm, recording, AudioTimeLinePlayer, VoicePlayer, csv, settings, };
16
17
  export type { User, GeoFence, Device, Log, State, Recording };
package/dist/index.js CHANGED
@@ -13,4 +13,5 @@ import { recording } from "./recording.svelte.js";
13
13
  import AudioTimeLinePlayer from "./AudioTimeLinePlayer.svelte";
14
14
  import VoicePlayer from "./VoicePlayer.svelte";
15
15
  import csv from "./csv.js";
16
- export { auth, gtime, geofence, device, ghistory, InputDate, InputDatetime, InputDebounced, InputIdentUri, LoginForm, recording, AudioTimeLinePlayer, VoicePlayer, csv, };
16
+ import settings from "./settings.svelte.js";
17
+ export { auth, gtime, geofence, device, ghistory, InputDate, InputDatetime, InputDebounced, InputIdentUri, LoginForm, recording, AudioTimeLinePlayer, VoicePlayer, csv, settings, };
@@ -0,0 +1,13 @@
1
+ declare class Settings {
2
+ private _loaded;
3
+ all: {
4
+ [key: string]: any;
5
+ };
6
+ constructor();
7
+ loaded(): Promise<boolean>;
8
+ getValue(path: string, defaultValue?: any): any;
9
+ getString(path: string, _default?: string): string;
10
+ getNumber(path: string, _default?: number): number;
11
+ }
12
+ declare const settings: Settings;
13
+ export default settings;
@@ -0,0 +1,74 @@
1
+ class Settings {
2
+ _loaded;
3
+ all = $state({});
4
+ constructor() {
5
+ let resolveLoaded;
6
+ this._loaded = new Promise((resolve) => {
7
+ resolveLoaded = resolve;
8
+ });
9
+ fetch("_settings", { signal: AbortSignal.timeout(5000) })
10
+ .then(resp => {
11
+ if (resp.status === 200) {
12
+ const regSection = /\[([a-zA-Z0-9]+)\]/;
13
+ const regKeyVal = /([a-zA-Z]+) *= *(.*)/;
14
+ resp.text().then(t => {
15
+ try {
16
+ this.all = JSON.parse(t);
17
+ }
18
+ catch (e) {
19
+ let currentSection = "";
20
+ t.split("\n").forEach(line => {
21
+ line = line.trim();
22
+ if (!line || line.startsWith("#"))
23
+ return;
24
+ if (line.startsWith("[")) {
25
+ const m = regSection.exec(line);
26
+ if (m) {
27
+ currentSection = m[1];
28
+ this.all[currentSection] = {};
29
+ }
30
+ }
31
+ else {
32
+ const m = regKeyVal.exec(line);
33
+ if (m) {
34
+ this.all[currentSection][m[1]] = m[2];
35
+ }
36
+ }
37
+ });
38
+ }
39
+ resolveLoaded(true);
40
+ });
41
+ }
42
+ else {
43
+ resolveLoaded(true); // resolve even if non-200
44
+ }
45
+ })
46
+ .catch(() => resolveLoaded(true)); // resolve even on fetch failure
47
+ }
48
+ async loaded() {
49
+ return this._loaded;
50
+ }
51
+ getValue(path, defaultValue) {
52
+ return path.split('.').reduce((acc, key) => {
53
+ if (acc && typeof acc === 'object' && key in acc) {
54
+ return acc[key];
55
+ }
56
+ return defaultValue;
57
+ }, this.all);
58
+ }
59
+ getString(path, _default = "") {
60
+ return path.split('.').reduce((acc, key) => {
61
+ if (acc && typeof acc === 'object' && key in acc) {
62
+ return acc[key];
63
+ }
64
+ return _default;
65
+ }, this.all).toString();
66
+ }
67
+ getNumber(path, _default = 0) {
68
+ const s = this.getString(path, "");
69
+ let v = parseFloat(s);
70
+ return v || _default;
71
+ }
72
+ }
73
+ const settings = new Settings();
74
+ export default settings;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smcgateway-sv",
3
- "version": "0.4.6",
3
+ "version": "0.4.8",
4
4
  "author": "Kevin Golding <kevin.golding@smc-gateway.com> (https://smc-gateway.com)",
5
5
  "license": "MIT",
6
6
  "scripts": {