@mythpe/quasar-ui-qui 0.1.85 → 0.1.87

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.85",
3
+ "version": "0.1.87",
4
4
  "description": "MyTh Quasar UI Kit App Extension",
5
5
  "author": {
6
6
  "name": "MyTh Ahmed Faiz",
@@ -33,7 +33,6 @@
33
33
  "axios": "^1.7.8",
34
34
  "change-case": "^5.4.4",
35
35
  "ckeditor5": "^43.3.1",
36
- "pluralize": "^8.0.0",
37
36
  "qs": "^6.13.1",
38
37
  "radash": "^12.1.0",
39
38
  "typed.js": "^2.1.0",
@@ -50,7 +49,6 @@
50
49
  "@rollup/plugin-replace": "^6.0.1",
51
50
  "@types/express": "^5.0.0",
52
51
  "@types/node": "^22.10.1",
53
- "@types/pluralize": "^0.0.33",
54
52
  "@typescript-eslint/eslint-plugin": "^7.16.0",
55
53
  "@typescript-eslint/parser": "^7.16.0",
56
54
  "autoprefixer": "^10.4.20",
@@ -11,13 +11,30 @@
11
11
  setup
12
12
  >
13
13
  import type { MInputProps as Props, MInputSlots } from '../../types'
14
- import { useTemplateRef } from 'vue'
14
+ import { computed, toValue, useAttrs, useTemplateRef } from 'vue'
15
15
  import MInput from './MInput.vue'
16
16
  import { useMyth } from '../../composable'
17
+ import { useFieldValue } from 'vee-validate'
17
18
 
18
19
  const { props: pluginOptions, mobileRule: mobile } = useMyth()
19
20
  const modelValue = defineModel<Props['modelValue']>({ required: !1, default: undefined })
21
+ const attrs = useAttrs()
22
+ const name = computed<string>(() => (attrs.name as string) || '')
20
23
  const input = useTemplateRef<InstanceType<typeof MInput>>('input')
24
+ const field = useFieldValue(name)
25
+ const mobileLength = computed(() => {
26
+ const final = toValue(mobile)
27
+ if (typeof final === 'function') {
28
+ return final(field.value)
29
+ }
30
+ if (final === !0) {
31
+ return 10
32
+ }
33
+ if (!final) {
34
+ return undefined
35
+ }
36
+ return parseInt(final?.toString() || '0') || undefined
37
+ })
21
38
  defineExpose<{ input: typeof input }>({ input })
22
39
  defineOptions({
23
40
  name: 'MMobile',
@@ -29,7 +46,15 @@ defineOptions({
29
46
  <MInput
30
47
  ref="input"
31
48
  v-model="modelValue"
32
- v-bind="{ type: 'tel', mobile, maxlength:mobile === !0 ? 10 : (mobile ?? 10), ...pluginOptions.mobile as any, ...$attrs }"
49
+ v-bind="{
50
+ type: 'tel',
51
+ mobile: typeof mobile === 'function' ? mobile(field) : (
52
+ mobile !== !1 && mobile !== undefined && mobile !== null
53
+ ),
54
+ maxlength: mobileLength,
55
+ ...pluginOptions.mobile as any,
56
+ ...$attrs
57
+ }"
33
58
  >
34
59
  <template
35
60
  v-for="(_,slot) in $slots as Readonly<MInputSlots>"
@@ -298,7 +298,7 @@ export type BaseInputFormProps = {
298
298
  /**
299
299
  * Mobile Rule.
300
300
  */
301
- mobile?: boolean | string | number | undefined;
301
+ mobile?: boolean | string | number | ((value: unknown) => number | undefined) | undefined;
302
302
  /**
303
303
  * Email Rule.
304
304
  */
@@ -2,6 +2,7 @@ import type { AxiosInstance } from 'axios'
2
2
  import type { HelpersStubSchema } from './api-helpers'
3
3
  import type { ThemeContext } from './theme'
4
4
  import type { MythComponentsProps } from './plugin-props-option'
5
+ import type { MInputProps } from './components'
5
6
 
6
7
  export interface ApiContext {
7
8
  url: string;
@@ -38,5 +39,5 @@ export interface MythApi {
38
39
  * Default is true.
39
40
  * The Length must be 10.
40
41
  */
41
- mobileRule?: boolean | string | number;
42
+ mobileRule?: MInputProps['mobile'];
42
43
  }