@mythpe/quasar-ui-qui 0.1.48 → 0.1.49
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 +1 -1
- package/src/components/form/MInput.vue +11 -3
- package/src/components/index.ts +1 -0
- package/src/components/util/index.ts +10 -0
- package/src/components/util/sar/MSarCol.vue +70 -0
- package/src/components/util/sar/MSarSvg.vue +42 -0
- package/src/components/util/sar/index.ts +12 -0
- package/src/plugin/defineAsyncComponents.ts +4 -0
- package/src/style/main.sass +7 -0
- package/src/types/components.d.ts +25 -1
- package/src/utils/Helpers.ts +68 -3
package/package.json
CHANGED
|
@@ -41,6 +41,7 @@ interface P {
|
|
|
41
41
|
mobile?: Props['mobile'];
|
|
42
42
|
email?: Props['email'];
|
|
43
43
|
float?: Props['float'];
|
|
44
|
+
sar?: boolean;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
const props = withDefaults(defineProps<P>(), {
|
|
@@ -59,7 +60,7 @@ const props = withDefaults(defineProps<P>(), {
|
|
|
59
60
|
help: undefined,
|
|
60
61
|
required: undefined,
|
|
61
62
|
rules: undefined,
|
|
62
|
-
viewMode:
|
|
63
|
+
viewMode: !1,
|
|
63
64
|
viewModeValue: undefined,
|
|
64
65
|
autocomplete: undefined,
|
|
65
66
|
topLabel: undefined,
|
|
@@ -67,7 +68,8 @@ const props = withDefaults(defineProps<P>(), {
|
|
|
67
68
|
clearable: undefined,
|
|
68
69
|
mobile: undefined,
|
|
69
70
|
email: undefined,
|
|
70
|
-
float: undefined
|
|
71
|
+
float: undefined,
|
|
72
|
+
sar: !1
|
|
71
73
|
})
|
|
72
74
|
defineModel<Props['modelValue']>({ required: !1, default: undefined })
|
|
73
75
|
const { __, props: pluginOptions } = useMyth()
|
|
@@ -133,6 +135,7 @@ defineOptions({
|
|
|
133
135
|
<component
|
|
134
136
|
:is="viewMode ? QField : QInput"
|
|
135
137
|
ref="input"
|
|
138
|
+
class="m--input"
|
|
136
139
|
v-bind="{
|
|
137
140
|
...$attrs,
|
|
138
141
|
...theme,
|
|
@@ -161,7 +164,12 @@ defineOptions({
|
|
|
161
164
|
>
|
|
162
165
|
<slot name="control">
|
|
163
166
|
<MInputFieldControl>
|
|
164
|
-
|
|
167
|
+
<template v-if="sar">
|
|
168
|
+
<MSarCol :text="!!viewModeValue?.toString?.()?.length ? viewModeValue : ( !!value?.toString?.()?.length ? value : undefined )" />
|
|
169
|
+
</template>
|
|
170
|
+
<template v-else>
|
|
171
|
+
{{ viewModeValue ?? value }}
|
|
172
|
+
</template>
|
|
165
173
|
</MInputFieldControl>
|
|
166
174
|
</slot>
|
|
167
175
|
</template>
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
- MyTh Ahmed Faiz Copyright © 2025 All rights reserved.
|
|
3
|
+
- Email: mythpe@gmail.com
|
|
4
|
+
- Mobile: +966590470092
|
|
5
|
+
- Website: https://www.4myth.com
|
|
6
|
+
- Github: https://github.com/mythpe
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
<script lang="ts" setup>
|
|
10
|
+
import MSarSvg from './MSarSvg.vue'
|
|
11
|
+
import { useI18n } from 'vue-i18n'
|
|
12
|
+
import { computed } from 'vue'
|
|
13
|
+
import { useMyth } from '../../../composable'
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
text?: any;
|
|
17
|
+
string?: boolean;
|
|
18
|
+
append?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
22
|
+
text: undefined,
|
|
23
|
+
string: !1,
|
|
24
|
+
append: !1
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const { te, n } = useI18n({ useScope: 'global' })
|
|
28
|
+
const { __, toFixedFormatted } = useMyth()
|
|
29
|
+
const getText = computed<string | undefined>(() => {
|
|
30
|
+
if (!props.text?.toString().length) {
|
|
31
|
+
return props.text
|
|
32
|
+
}
|
|
33
|
+
const text = props.text?.toString?.() || null
|
|
34
|
+
if (!text) {
|
|
35
|
+
return props.text
|
|
36
|
+
}
|
|
37
|
+
if (props.string) {
|
|
38
|
+
return te(`labels.${text}`) ? __(`labels.${text}`) : __(text)
|
|
39
|
+
}
|
|
40
|
+
const v = isNaN(text) ? toFixedFormatted(text || '') : toFixedFormatted(n(parseFloat(text || '0') || 0))
|
|
41
|
+
|
|
42
|
+
return v !== null && v !== undefined ? (v?.toString?.() || v) : undefined
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
defineOptions({
|
|
46
|
+
name: 'MSarCol',
|
|
47
|
+
inheritAttrs: !1
|
|
48
|
+
})
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<template>
|
|
52
|
+
<div
|
|
53
|
+
:class="`m--sar-col ${append ? 'm--sar-col__append' : ''}`"
|
|
54
|
+
v-bind="$attrs"
|
|
55
|
+
>
|
|
56
|
+
<MRow
|
|
57
|
+
class="items-center"
|
|
58
|
+
gutter
|
|
59
|
+
>
|
|
60
|
+
<slot name="default">
|
|
61
|
+
<div
|
|
62
|
+
v-if="text !== undefined && text !== null"
|
|
63
|
+
class="flex flex-center m--sar-col__text"
|
|
64
|
+
v-text="getText"
|
|
65
|
+
/>
|
|
66
|
+
</slot>
|
|
67
|
+
<MSarSvg />
|
|
68
|
+
</MRow>
|
|
69
|
+
</div>
|
|
70
|
+
</template>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
- MyTh Ahmed Faiz Copyright © 2016-2025 All rights reserved.
|
|
3
|
+
- Email: mythpe@gmail.com
|
|
4
|
+
- Mobile: +966590470092
|
|
5
|
+
- Website: https://www.4myth.com
|
|
6
|
+
- Github: https://github.com/mythpe
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
<script lang="ts" setup>
|
|
10
|
+
defineOptions({
|
|
11
|
+
name: 'MSarSvg',
|
|
12
|
+
inheritAttrs: !1
|
|
13
|
+
})
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<div
|
|
18
|
+
class="flex m--sar-svg"
|
|
19
|
+
v-bind="$attrs"
|
|
20
|
+
>
|
|
21
|
+
<slot />
|
|
22
|
+
<svg
|
|
23
|
+
id="Layer_1"
|
|
24
|
+
data-name="Layer 1"
|
|
25
|
+
height="15px"
|
|
26
|
+
viewBox="0 0 1124.14 1256.39"
|
|
27
|
+
width="100%"
|
|
28
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
29
|
+
>
|
|
30
|
+
<path
|
|
31
|
+
:fill="$q.dark.isActive ? '#FFF' : '#231f20'"
|
|
32
|
+
class="cls-1"
|
|
33
|
+
d="M699.62,1113.02h0c-20.06,44.48-33.32,92.75-38.4,143.37l424.51-90.24c20.06-44.47,33.31-92.75,38.4-143.37l-424.51,90.24Z"
|
|
34
|
+
/>
|
|
35
|
+
<path
|
|
36
|
+
:fill="$q.dark.isActive ? '#FFF' : '#231f20'"
|
|
37
|
+
class="cls-1"
|
|
38
|
+
d="M1085.73,895.8c20.06-44.47,33.32-92.75,38.4-143.37l-330.68,70.33v-135.2l292.27-62.11c20.06-44.47,33.32-92.75,38.4-143.37l-330.68,70.27V66.13c-50.67,28.45-95.67,66.32-132.25,110.99v403.35l-132.25,28.11V0c-50.67,28.44-95.67,66.32-132.25,110.99v525.69l-295.91,62.88c-20.06,44.47-33.33,92.75-38.42,143.37l334.33-71.05v170.26l-358.3,76.14c-20.06,44.47-33.32,92.75-38.4,143.37l375.04-79.7c30.53-6.35,56.77-24.4,73.83-49.24l68.78-101.97v-.02c7.14-10.55,11.3-23.27,11.3-36.97v-149.98l132.25-28.11v270.4l424.53-90.28Z"
|
|
39
|
+
/>
|
|
40
|
+
</svg>
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MyTh Ahmed Faiz Copyright © 2016-2024 All rights reserved.
|
|
3
|
+
* Email: mythpe@gmail.com
|
|
4
|
+
* Mobile: +966590470092
|
|
5
|
+
* Website: https://www.4myth.com
|
|
6
|
+
* Github: https://github.com/mythpe
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import MSarCol from './MSarCol.vue'
|
|
10
|
+
import MSarSvg from './MSarSvg.vue'
|
|
11
|
+
|
|
12
|
+
export { MSarCol, MSarSvg }
|
|
@@ -57,4 +57,8 @@ export const defineAsyncComponents = function (app: App) {
|
|
|
57
57
|
app.component('MDtAvatar', defineAsyncComponent(() => import('../components/datatable/MDtAvatar.vue')))
|
|
58
58
|
app.component('MDtBtn', defineAsyncComponent(() => import('../components/datatable/MDtBtn.vue')))
|
|
59
59
|
app.component('MDtContextmenuItems', defineAsyncComponent(() => import('../components/datatable/MDtContextmenuItems.vue')))
|
|
60
|
+
|
|
61
|
+
// Utils.
|
|
62
|
+
app.component('MSarCol', defineAsyncComponent(() => import('../components/util/sar/MSarSvg.vue')))
|
|
63
|
+
app.component('MSarSvg', defineAsyncComponent(() => import('../components/util/sar/MSarSvg.vue')))
|
|
60
64
|
}
|
package/src/style/main.sass
CHANGED
|
@@ -341,7 +341,9 @@ export type BaseInputsSlots = InputHelpSlots & {
|
|
|
341
341
|
'bottom-input': () => VNode[];
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
-
export
|
|
344
|
+
export interface MInputProps extends Omit<QInputProps, 'rules' | 'name' | 'modelValue' | 'label' | 'hint'>, BaseInputsProps {
|
|
345
|
+
sar?: boolean;
|
|
346
|
+
}
|
|
345
347
|
|
|
346
348
|
export type MInputSlots = QInputSlots & QFieldSlots & BaseInputsSlots
|
|
347
349
|
|
|
@@ -963,6 +965,24 @@ export type MCkeditorProps = Omit<BaseInputsProps, 'hint' | 'topLabel' | 'placeh
|
|
|
963
965
|
}
|
|
964
966
|
export type MCkeditorSlots = BaseInputsSlots
|
|
965
967
|
|
|
968
|
+
export interface MSarColProps {
|
|
969
|
+
text?: any;
|
|
970
|
+
string?: boolean;
|
|
971
|
+
append?: boolean;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
export interface MSarColSlots {
|
|
975
|
+
default: () => VNode[]
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
export interface MSarSvgProps {
|
|
979
|
+
[key: string]: any;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
export interface MSarSvgSlots {
|
|
983
|
+
default: () => VNode[]
|
|
984
|
+
}
|
|
985
|
+
|
|
966
986
|
declare module '@vue/runtime-core' {
|
|
967
987
|
interface GlobalComponents {
|
|
968
988
|
// Form.
|
|
@@ -1019,5 +1039,9 @@ declare module '@vue/runtime-core' {
|
|
|
1019
1039
|
MDtAvatar: GlobalComponentConstructor<MDtAvatarProps, MDtAvatarSlots>;
|
|
1020
1040
|
MDtBtn: GlobalComponentConstructor<MDtBtnProps, MDtBtnSlots>;
|
|
1021
1041
|
MDtContextmenuItems: GlobalComponentConstructor<MDtContextmenuItemsProps, MDtContextmenuItemsSlots>;
|
|
1042
|
+
|
|
1043
|
+
// Utils.
|
|
1044
|
+
MSarCol: GlobalComponentConstructor<MSarColProps, MSarColSlots>;
|
|
1045
|
+
MSarSvg: GlobalComponentConstructor<MSarSvgProps, MSarSvgSlots>;
|
|
1022
1046
|
}
|
|
1023
1047
|
}
|
package/src/utils/Helpers.ts
CHANGED
|
@@ -9,10 +9,32 @@
|
|
|
9
9
|
import type { AxiosInstance, AxiosRequestConfig } from 'axios'
|
|
10
10
|
import type { ConfigType, DownloadFromResponse, DownloadFromResponseCode, HelpersStubSchema, ParamsType, UrlType } from '../types'
|
|
11
11
|
import lodash from 'lodash'
|
|
12
|
-
import { openURL, scroll } from 'quasar'
|
|
13
|
-
|
|
12
|
+
import { colors, openURL, scroll, setCssVar } from 'quasar'
|
|
14
13
|
import { nextTick } from 'vue'
|
|
15
14
|
|
|
15
|
+
const defOpacity = 10
|
|
16
|
+
const darkenColor = (color: string, percent: number = defOpacity) => {
|
|
17
|
+
const { lighten } = colors
|
|
18
|
+
return lighten(color, percent * -1)
|
|
19
|
+
}
|
|
20
|
+
const lightenColor = (color: string, percent: number = defOpacity) => {
|
|
21
|
+
const { lighten } = colors
|
|
22
|
+
return lighten(color, percent)
|
|
23
|
+
}
|
|
24
|
+
const setCss: typeof setCssVar = (varName, value, element) => {
|
|
25
|
+
setCssVar(varName, value, element || document.documentElement)
|
|
26
|
+
if (varName === 'primary') {
|
|
27
|
+
const lighten = lightenColor(value, 50)
|
|
28
|
+
const dark = darkenColor(value, 10)
|
|
29
|
+
setCssVar('scrollbar-track', lighten)
|
|
30
|
+
setCssVar('scrollbar-hover', dark)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const colorIsDark = (color: string): boolean => {
|
|
34
|
+
const { luminosity } = colors
|
|
35
|
+
return luminosity(color) < 0.5
|
|
36
|
+
}
|
|
37
|
+
|
|
16
38
|
export const Helpers = {
|
|
17
39
|
appendArray (formData: FormData, values: File | Blob | Record<string, any> | any, name?: string | null | undefined) {
|
|
18
40
|
let value: never | any
|
|
@@ -306,5 +328,48 @@ export const Helpers = {
|
|
|
306
328
|
return `${l.protocol}//${l.host}/${path}`
|
|
307
329
|
}
|
|
308
330
|
return `//${path}`
|
|
309
|
-
}
|
|
331
|
+
},
|
|
332
|
+
toFixedFormatted (value: any) {
|
|
333
|
+
if (value) {
|
|
334
|
+
const text: string = value?.toString() || ''
|
|
335
|
+
if (!text) {
|
|
336
|
+
return value
|
|
337
|
+
}
|
|
338
|
+
const after: string = (text.split?.('.')[1] || '')?.toString() || ''
|
|
339
|
+
if (!after) {
|
|
340
|
+
return value
|
|
341
|
+
}
|
|
342
|
+
if (after?.length === 1) {
|
|
343
|
+
return `${value}0`
|
|
344
|
+
}
|
|
345
|
+
return value?.toString()
|
|
346
|
+
}
|
|
347
|
+
return value
|
|
348
|
+
},
|
|
349
|
+
calculateAspectRatio: (width: number | string, height: number | string): [number, string] => {
|
|
350
|
+
width = Number(width)
|
|
351
|
+
height = Number(height)
|
|
352
|
+
const gcd = (a: number, b: number) => (b === 0 ? a : gcd(b, a % b))
|
|
353
|
+
const divisor = gcd(width, height)
|
|
354
|
+
return [width / height, `${width / divisor}:${height / divisor}`]
|
|
355
|
+
},
|
|
356
|
+
convertToArabicNumbers: (input: string | number): string => {
|
|
357
|
+
const numberMap: { [key: string]: string } = {
|
|
358
|
+
0: '٠',
|
|
359
|
+
1: '١',
|
|
360
|
+
2: '٢',
|
|
361
|
+
3: '٣',
|
|
362
|
+
4: '٤',
|
|
363
|
+
5: '٥',
|
|
364
|
+
6: '٦',
|
|
365
|
+
7: '٧',
|
|
366
|
+
8: '٨',
|
|
367
|
+
9: '٩'
|
|
368
|
+
}
|
|
369
|
+
return input.toString().split('').map(char => numberMap[char] || char).join('')
|
|
370
|
+
},
|
|
371
|
+
lightenColor,
|
|
372
|
+
darkenColor,
|
|
373
|
+
setCss,
|
|
374
|
+
colorIsDark
|
|
310
375
|
}
|