@mythpe/quasar-ui-qui 0.1.33 → 0.1.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mythpe/quasar-ui-qui",
3
- "version": "0.1.33",
3
+ "version": "0.1.35",
4
4
  "description": "MyTh Quasar UI Kit App Extension",
5
5
  "author": {
6
6
  "name": "MyTh Ahmed Faiz",
@@ -14,10 +14,11 @@ import type { MDateProps as Props, MInputSlots } from '../../types'
14
14
  import { useTemplateRef } from 'vue'
15
15
  import MPicker from './MPicker.vue'
16
16
 
17
- type P = {
17
+ interface P {
18
18
  name: Props['name'];
19
19
  rules?: Props['rules'];
20
20
  }
21
+
21
22
  withDefaults(defineProps<P>(), {
22
23
  name: () => '',
23
24
  rules: undefined
@@ -16,6 +16,7 @@ import { useBindInput, useMyth } from '../../composable'
16
16
  import { useField } from 'vee-validate'
17
17
  import type { QFieldSlots } from 'quasar'
18
18
  import { QDate, QField, QTime } from 'quasar'
19
+ import { useI18n } from 'vue-i18n'
19
20
 
20
21
  const defSeparator = ' - '
21
22
 
@@ -47,6 +48,8 @@ interface P {
47
48
  readonly?: Props['readonly'];
48
49
  disable?: Props['disable'];
49
50
  fieldOptions?: Props['fieldOptions'];
51
+ locale?: Props['locale'];
52
+ noDefaultLocale?: boolean;
50
53
  }
51
54
 
52
55
  const props = withDefaults(defineProps<P>(), {
@@ -76,7 +79,9 @@ const props = withDefaults(defineProps<P>(), {
76
79
  btnProps: undefined,
77
80
  readonly: undefined,
78
81
  disable: undefined,
79
- fieldOptions: undefined
82
+ fieldOptions: undefined,
83
+ locale: undefined,
84
+ noDefaultLocale: !1
80
85
  })
81
86
 
82
87
  defineModel<Props['modelValue']>({ required: !1, default: undefined })
@@ -101,6 +106,35 @@ const isDate = computed(() => props.type !== 'time')
101
106
  // })
102
107
  const format = computed(() => isDate.value ? 'YYYY/MM/DD' : 'HH:mm')
103
108
  const dateRef = ref<string | null>(null)
109
+
110
+ const { t, te } = useI18n({ useScope: 'global' })
111
+ const daysShort = computed(() => {
112
+ if (!te('const.days.0')) {
113
+ return undefined
114
+ }
115
+ const l: string[] = []
116
+ for (let i = 0; i < 7; i++) {
117
+ l.push(t(`const.days.${i}`) as string)
118
+ }
119
+ return l
120
+ })
121
+ const monthsShort = computed(() => {
122
+ if (!te('const.months.1')) {
123
+ return undefined
124
+ }
125
+ const l: string[] = []
126
+ for (let i = 1; i <= 12; i++) {
127
+ l.push(t(`const.months.${i}`) as string)
128
+ }
129
+ return l
130
+ })
131
+ const localeComputed = computed(() => {
132
+ if (props.noDefaultLocale) {
133
+ return props.locale
134
+ }
135
+ return { ...props.locale, daysShort: daysShort.value, monthsShort: monthsShort.value }
136
+ })
137
+
104
138
  const onBeforeShow = () => {
105
139
  dateRef.value = value.value || null
106
140
  }
@@ -236,7 +270,8 @@ defineOptions({
236
270
  mask: format,
237
271
  multiple,
238
272
  range,
239
- modelValue: dateRef ?? null
273
+ modelValue: dateRef ?? null,
274
+ locale: localeComputed
240
275
  }"
241
276
  @update:model-value="dateRef = $event ?? null"
242
277
  >
@@ -265,7 +300,8 @@ defineOptions({
265
300
  ...$attrs,
266
301
  mask: format,
267
302
  nowBtn: getProp('nowBtn') === undefined? !0 : getProp('nowBtn'),
268
- modelValue: dateRef ?? null
303
+ modelValue: dateRef ?? null,
304
+ locale: localeComputed
269
305
  }"
270
306
  @update:model-value="dateRef = $event ?? null"
271
307
  >
@@ -399,7 +399,7 @@ export type MRadioProps = Omit<QRadioProps, 'name' | 'modelValue' | 'label'> & B
399
399
 
400
400
  export type MRadioSlots = MCheckboxSlots
401
401
 
402
- export type MPickerProps = BaseInputsProps & Omit<QDateProps, 'modelValue' | 'options'> & Omit<QTimeProps, 'modelValue'> & {
402
+ export interface MPickerProps extends BaseInputsProps, Omit<QDateProps, 'modelValue' | 'options'>, Omit<QTimeProps, 'modelValue'> {
403
403
  /**
404
404
  * Initial value of the picker.
405
405
  * Default is: null.
@@ -419,11 +419,18 @@ export type MPickerProps = BaseInputsProps & Omit<QDateProps, 'modelValue' | 'op
419
419
  * Default is: ' - '.
420
420
  */
421
421
  rangeSeparator?: string;
422
+ /**
423
+ * User long days & months names.
424
+ * Only work for 'date' type.
425
+ */
426
+ noDefaultLocale?: boolean;
422
427
  }
423
428
 
424
429
  export type MPickerSlots = MInputSlots
425
430
 
426
- export type MDateProps = Omit<MPickerProps, 'type'>
431
+ export interface MDateProps extends Omit<MPickerProps, 'type'> {
432
+ type?: 'date'
433
+ }
427
434
 
428
435
  export type MDateSlots = MPickerSlots
429
436
 
@@ -14,7 +14,7 @@ const { testPattern } = patterns
14
14
  export const veeRules = {
15
15
  float: (v: any) => lodash.isNumber(parseInt(v)) && !isNaN(parseInt(v)) && v?.toString()
16
16
  .split('.')?.length <= 2 && (/(\d)+/g.test(v) && !/[a-zA-Z]/.test(
17
- v)),
17
+ v)) && v !== undefined && v !== null,
18
18
  date: (v: any) => /^-?[\d]+-[0-1]\d-[0-3]\d$/.test(v),
19
19
  time: (v: any) => testPattern.time(v),
20
20
  fulltime: (v: any) => testPattern.fulltime(v),