@hostlink/nuxt-light 1.15.2 → 1.15.3

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/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "1.15.2",
4
+ "version": "1.15.3",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.3",
7
7
  "unbuild": "2.0.0"
@@ -344,7 +344,7 @@ if (route.fullPath == "/" && my.default_page) {
344
344
 
345
345
  <q-btn flat round dense icon="sym_o_person" class="q-mr-sm">
346
346
  <q-menu max-width="250px">
347
- <q-list>
347
+ <q-list >
348
348
  <q-item v-close-popup to="/User/profile">
349
349
  <q-item-section avatar>
350
350
  <q-icon name="sym_o_person" />
@@ -2,11 +2,13 @@
2
2
  import { ref, computed } from "vue";
3
3
  import { useLight } from '#imports';
4
4
 
5
- import { type QDateProps } from "quasar";
5
+ import { date, type QDateProps, type QInputProps } from "quasar";
6
6
  import { useI18n } from 'vue-i18n';
7
7
 
8
8
  const { t } = useI18n();
9
9
 
10
+ const modelValue = defineModel<string | DateRange | null | undefined>();
11
+
10
12
  interface DateRange {
11
13
  from: string,
12
14
  to: string
@@ -14,7 +16,6 @@ interface DateRange {
14
16
 
15
17
 
16
18
  export interface LDatePickerProps {
17
- modelValue?: string | DateRange
18
19
  label?: string
19
20
  required?: boolean
20
21
  hideBottomSpace?: boolean
@@ -40,67 +41,59 @@ const props = withDefaults(defineProps<LDatePickerProps>(), {
40
41
  square: undefined,
41
42
  stackLabel: undefined,
42
43
  mask: "YYYY-MM-DD",
44
+ range: false
43
45
  })
44
46
 
45
47
 
46
48
  const light = useLight();
47
49
 
48
- const emit = defineEmits<{
49
- (e: 'update:modelValue', value?: string | object): void
50
- }>();
51
-
52
50
  const popup = ref<any>(null);
53
51
  const localValue = computed({
54
52
  get: () => {
55
- //if is object
56
- if (props.modelValue) {
57
- if (typeof props.modelValue == "object") {
58
- return props.modelValue.from + " - " + props.modelValue.to
53
+ if (modelValue.value) {
54
+ if (typeof modelValue.value == "object") {
55
+ return modelValue.value.from + " - " + modelValue.value.to
59
56
  }
60
57
  }
61
58
 
62
- return props.modelValue
59
+ return modelValue.value
63
60
  },
64
- set: (value) => {
65
- if (value == null) {
66
- emit('update:modelValue', value)
67
- return;
68
- }
69
-
70
- //is object
71
- if (typeof value == "object") {
72
- emit('update:modelValue', value)
73
- return;
74
- }
61
+ set: (value: string) => {
62
+
75
63
 
76
64
  if (props.range) {
77
-
78
65
  //try to split
79
66
  const parts = value.split(" - ");
80
67
  if (parts.length == 2) {
81
68
  const from = parts[0];
82
69
  const to = parts[1];
83
70
  if (from.match(/^\d{4}-\d{2}-\d{2}$/) && to.match(/^\d{4}-\d{2}-\d{2}$/)) {
84
- emit('update:modelValue', { from, to })
71
+ modelValue.value = { from, to }
85
72
  return;
86
73
  }
87
74
  }
88
75
  }
89
76
 
90
- emit('update:modelValue', value)
77
+ if (value.match(/^\d{4}-\d{2}-\d{2}$/)) {
78
+ modelValue.value = value;
79
+ return;
80
+ }
81
+
82
+
83
+ modelValue.value = null;
91
84
  }
92
85
  });
93
86
 
94
87
  const dateValue = computed({
95
88
  get: () => {
96
- return props.modelValue
89
+ return modelValue
97
90
  },
98
- set: (value) => {
91
+ set: (value: string) => {
99
92
  if (popup.value) {
100
93
  popup.value.hide();
101
94
  }
102
- (localValue as any).value = value;
103
- emit('update:modelValue', value)
95
+ localValue.value = value;
96
+ modelValue.value = value;
104
97
  }
105
98
  });
106
99
 
@@ -126,7 +119,11 @@ if (!props.range) {
126
119
  }
127
120
 
128
121
  const input_attrs = computed(() => {
129
- let a = { ...props }
122
+ let a: QInputProps = {
123
+ modelValue: localValue.value,
124
+ ...props
125
+ }
126
+
130
127
  a.rules = rules;
131
128
  a.mask = props.range ? "####-##-## - ####-##-##" : "####-##-##"
132
129
 
@@ -1,64 +1,84 @@
1
- <script setup>
1
+ <script setup lang="ts">
2
2
  import { computed, ref, useAttrs } from "vue";
3
- import { useLight } from '../';
3
+ import { useLight } from '#imports';
4
+ import type { ValidationRule, QInputProps } from "quasar";
5
+ import { useI18n } from "vue-i18n";
4
6
  const light = useLight();
7
+ const { t } = useI18n();
8
+ const modelValue = defineModel<string | null | undefined>();
5
9
 
6
- const props = defineProps({
7
- modelValue: {
8
- type: [String, Object],
9
- required: false,
10
- default: null
11
- }, required: {
12
- type: Boolean,
13
- default: false
14
- },
15
- label: {
16
- type: String,
17
- },
18
- hint: {
19
- type: String,
20
- default: ""
21
- }
22
- });
10
+ export interface LTimePickerProps {
11
+ modelValue?: string | null | undefined
12
+ required?: boolean
13
+ label?: string
14
+ hint?: string
15
+ nowBtn?: boolean
16
+ withSeconds?: boolean
17
+ format24h?: boolean
18
+ mask?: string
19
+ hideBottomSpace?: boolean
20
+ }
21
+
22
+ const props = withDefaults(defineProps<LTimePickerProps>(), {
23
+ required: false,
24
+ format24h: true,
25
+ mask: "time",
26
+ hideBottomSpace: true
27
+ })
23
28
 
24
- const emit = defineEmits(["update:modelValue"]);
25
29
  const popup = ref(null);
26
- const localValue = computed({
27
- get: () => props.modelValue,
28
- set: (value) => {
29
- // popup.value.hide();
30
- emit('update:modelValue', value)
30
+ const localValue = computed<string | null | undefined>({
31
+ get: (): string | null | undefined => {
32
+ return modelValue.value;
33
+ },
34
+ set: (value: string | null | undefined) => {
35
+ modelValue.value = value;
31
36
  }
32
37
  });
33
38
 
34
- const rules = ["timeOrFulltime"];
39
+ const rules: ValidationRule[] = ["timeOrFulltime"];
35
40
  //const rules = [];
36
41
  if (props.required) {
37
42
  rules.push(val => !!val || 'Required.');
38
43
  }
39
44
 
40
45
 
41
- const attrs = {
42
- ...{
46
+ const input_attrs = computed(() => {
47
+
48
+ let attrs: QInputProps = {
49
+ modelValue: localValue.value,
43
50
  filled: light.getStyle("inputFilled"),
44
51
  outlined: light.getStyle("inputOutlined"),
45
52
  standout: light.getStyle("inputStandout"),
46
53
  rounded: light.getStyle("inputRounded"),
47
54
  dense: light.getStyle("inputDense"),
48
55
  square: light.getStyle("inputSquare"),
49
- stackLabel: light.getStyle("inputStackLabel")
50
- },
51
- ...useAttrs(),
52
- }
56
+ stackLabel: light.getStyle("inputStackLabel"),
57
+ }
58
+
59
+ if (props.label) {
60
+ attrs.label = t(props.label);
61
+ }
62
+
63
+ if (props.hint) {
64
+ attrs.hint = t(props.hint);
65
+ }
53
66
 
67
+ if (props.mask) {
68
+ attrs.mask = props.mask;
69
+ }
70
+ return attrs;
71
+ })
54
72
 
55
73
  </script>
56
74
  <template>
57
- <q-input v-bind="attrs" v-model="localValue" mask="time" :rules="rules" :label="$t(label)" :hint="$t(hint)">
75
+ <q-input v-bind="input_attrs" v-model="localValue" :rules="rules" :color="$light.color"
76
+ :hide-bottom-space="hideBottomSpace">
58
77
  <template v-slot:prepend>
59
78
  <q-btn icon="sym_o_access_time" round dense flat>
60
79
  <q-popup-proxy cover transition-show="scale" transition-hide="scale" ref="popup">
61
- <q-time v-model="localValue" format24h>
80
+ <q-time v-model="localValue" :format24h="format24h" :color="$light.color" :now-btn="nowBtn"
81
+ :with-seconds="withSeconds">
62
82
  <div class="row items-center justify-end">
63
83
  <q-btn v-close-popup label="Close" :color="$light.color" flat />
64
84
  </div>
@@ -46,7 +46,8 @@ eventLogCols.forEach(col => {
46
46
 
47
47
  </script>
48
48
  <template>
49
- <l-page title="User profile">
49
+ <l-page title="User profile" gutter="sm">
50
+
50
51
  <template #header>
51
52
  <l-btn icon="sym_o_password" to="setting/password" label="Update password" />
52
53
  <l-btn icon="sym_o_key" to="setting/two-factor-auth" label="Two factor auth" />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "1.15.2",
3
+ "version": "1.15.3",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": {
6
6
  "type": "git",