@christianriedl/utils 1.0.159 → 1.0.160

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/iOpenAI.d.ts CHANGED
@@ -174,4 +174,5 @@ export interface IOpenAIAppConfig {
174
174
  openAIOptions: string;
175
175
  openAITools: string;
176
176
  openAISpeechModel: string;
177
+ openAIUseProxy: boolean;
177
178
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@christianriedl/utils",
3
- "version": "1.0.159",
3
+ "version": "1.0.160",
4
4
  "description": "Interfaces, local storage, service worker, configuration, application state",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -4,9 +4,10 @@
4
4
  import { VDateInput } from 'vuetify/labs/VDateInput';
5
5
  import { VIconBtn } from 'vuetify/labs/VIconBtn'
6
6
 
7
- const props = defineProps<{ modelValue: Date, withTime?: boolean, utc?: boolean, steps?: number, nextPrev?: boolean, variant?: any, density?: any }>();
7
+ const props = defineProps<{ modelValue: Date, withTime?: boolean, utc?: boolean, steps?: number, nextPrev?: boolean, clearable?: boolean, variant?: any, density?: any }>();
8
8
  const emits = defineEmits<{ (e: 'update:modelValue', value: Date): void }>();
9
9
 
10
+ const noDate: Date = null as unknown as Date;
10
11
 
11
12
  const dateValue = ref(new Date());
12
13
  const timeValue = ref("00:00");
@@ -19,10 +20,16 @@
19
20
  }
20
21
  watch(props, () => init());
21
22
  init();
22
- onDateChange();
23
+ if (dateValue.value)
24
+ onDateChange();
23
25
 
24
26
  function init () {
25
- dateValue.value = props.modelValue ?? new Date();
27
+ dateValue.value = props.modelValue;
28
+ if (!dateValue.value) {
29
+ if (props.clearable)
30
+ return;
31
+ dateValue.value = new Date();
32
+ }
26
33
  if (props.withTime)
27
34
  timeValue.value = props.utc ? Helper.formatUTCTime(dateValue.value) : Helper.formatTime(dateValue.value);
28
35
  if (props.utc)
@@ -32,7 +39,7 @@
32
39
  }
33
40
  function onDateChange() {
34
41
  let date = dateValue.value;
35
- if (props.withTime) {
42
+ if (props.withTime && date) {
36
43
  let ticks = date.getTime();
37
44
  const arrTime = timeValue.value.split(':');
38
45
  ticks += (Number(arrTime[0]) * 3600 + Number(arrTime[1]) * 60) * 1000;
@@ -40,6 +47,9 @@
40
47
  }
41
48
  emits('update:modelValue', date);
42
49
  }
50
+ function onClear() {
51
+ timeValue.value = "00:00";
52
+ }
43
53
  function onNext(evt?: MouseEvent) {
44
54
  if (steps == 31)
45
55
  dateValue.value = new Date(dateValue.value.getFullYear(), dateValue.value.getMonth() + 1, dateValue.value.getDate());
@@ -51,7 +61,7 @@
51
61
  if (steps == 31)
52
62
  dateValue.value = new Date(dateValue.value.getFullYear(), dateValue.value.getMonth() - 1, dateValue.value.getDate());
53
63
  else
54
- dateValue.value = new Date(dateValue.value.getTime() + steps * 24 * 60 * 60 * 1000);
64
+ dateValue.value = new Date(dateValue.value.getTime() - steps * 24 * 60 * 60 * 1000);
55
65
  onDateChange();
56
66
  }
57
67
  function onNavigate(direction: EDirection): void {
@@ -66,8 +76,8 @@
66
76
  <div class="d-flex align-center">
67
77
  <v-icon-btn v-if="props.nextPrev" icon="$prev" variant="tonal" @click="onPrevious"></v-icon-btn>
68
78
  <v-date-input v-model="dateValue" prepend-icon=""
69
- hide-details :variant="props.variant" :density="props.density"
70
- @update:modelValue="onDateChange" @click:prepend="onPrevious" @click:append="onNext">
79
+ hide-details :variant="props.variant" :density="props.density" :clearable="!!props.clearable"
80
+ @update:modelValue="onDateChange" @click:clear="onClear">
71
81
  </v-date-input>
72
82
  <v-icon-btn v-if="props.nextPrev" icon="$next" variant="tonal" @click="onNext"></v-icon-btn>
73
83
  <v-text-field v-if="props.withTime" v-model="timeValue" type="time" hide-details :variant="props.variant" :density="props.density"
@@ -1,62 +0,0 @@
1
- <script setup lang="ts">
2
- import { inject, ref, onUnmounted, onMounted, watch } from 'vue';
3
- import { Helper, EDirection, IAppState, appStateSymbol } from '@christianriedl/utils';
4
-
5
- const props = defineProps<{ modelValue: Date, utc?: boolean, steps?: number }>();
6
- const emits = defineEmits<{ (e: 'update:modelValue', value: Date): void }>();
7
-
8
- const appState = inject(appStateSymbol)!;
9
- const dateFormatted = ref('');
10
-
11
- let now = new Date(1970, 1, 1);
12
- const steps = props.steps ? props.steps : 1;
13
-
14
- onMounted(() => { appState.navigate.value = onNavigate; });
15
- onUnmounted(() => { appState.navigate.value = null });
16
- watch(props, () => init());
17
-
18
- init ();
19
-
20
- function init () {
21
- const date = props.modelValue ? props.modelValue : new Date();
22
- if (props.utc)
23
- date.setUTCHours(0, 0, 0, 0);
24
- else
25
- date.setHours(0, 0, 0, 0);
26
- setCurrent(date);
27
- }
28
- function setCurrent(date: Date) {
29
- if (now.getTime() != date.getTime()) {
30
- now = date;
31
- dateFormatted.value = props.utc ? Helper.formatUtcDate(now, '-') : Helper.formatDate(now, '-');
32
- emits('update:modelValue', props.utc ? now : Helper.toLocal(now));
33
- }
34
- }
35
- function onDateChange() {
36
- setCurrent (new Date(dateFormatted.value));
37
- }
38
- function onNext() {
39
- if (steps == 31)
40
- setCurrent (new Date (now.getFullYear(), now.getMonth() + 1, now.getDate()))
41
- else
42
- setCurrent (new Date(now.getTime() + steps * 24 * 60 * 60 * 1000));
43
- }
44
- function onPrevious() {
45
- if (steps == 31)
46
- setCurrent(new Date(now.getFullYear(), now.getMonth() - 1, now.getDate()))
47
- else
48
- setCurrent(new Date(now.getTime() - steps * 24 * 60 * 60 * 1000));
49
- }
50
- function onNavigate(direction: EDirection): void {
51
- if (direction === EDirection.Left)
52
- onPrevious();
53
- if (direction === EDirection.Right)
54
- onNext();
55
- }
56
- </script>
57
-
58
- <template>
59
- <v-text-field v-model="dateFormatted" type="date" prepend-icon="$prev" append-icon="$next"
60
- @update:modelValue="onDateChange" @click:prepend="onPrevious" @click:append="onNext">
61
- </v-text-field>
62
- </template>