@mythpe/quasar-ui-qui 0.5.0 → 0.5.2
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/README.md +9 -6
- package/dist/components/MBtn/MBtn.d.ts +35 -0
- package/dist/components/grid/MColumn/MColumn.d.ts +28 -0
- package/dist/components/grid/MContainer/MContainer.d.ts +23 -0
- package/dist/components/grid/MGrid.d.ts +12 -0
- package/dist/components/grid/MRow/MRow.d.ts +11 -0
- package/dist/components/index.d.ts +19 -0
- package/dist/composables/useMyth.d.ts +6765 -0
- package/dist/composables/useMythMeta.d.ts +30 -0
- package/dist/config/config.d.ts +3411 -0
- package/dist/config/grid.d.ts +6 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/index.common.js +1 -0
- package/dist/index.css +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/index.umd.js +1 -0
- package/dist/types/config.d.ts +69 -0
- package/dist/types/helpers.d.ts +14 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/vue-prop-types.d.ts +5 -0
- package/dist/utils/helpers.d.ts +40 -0
- package/dist/utils/icons.d.ts +4 -0
- package/dist/utils/index.d.ts +21 -0
- package/dist/utils/str.d.ts +67 -0
- package/dist/utils/vee-rules.d.ts +17 -0
- package/dist/vue-plugin.d.ts +16 -0
- package/package.json +31 -20
- package/rREADME.md +0 -147
- package/src/components/MBtn/MBtn.ts +0 -38
- package/src/components/MBtn/MBtn.vue +0 -142
- package/src/components/grid/MColumn/MColumn.ts +0 -15
- package/src/components/grid/MColumn/MColumn.vue +0 -28
- package/src/components/grid/MContainer/MContainer.ts +0 -39
- package/src/components/grid/MContainer/MContainer.vue +0 -66
- package/src/components/grid/MGrid.ts +0 -16
- package/src/components/grid/MGrid.vue +0 -47
- package/src/components/grid/MRow/MRow.ts +0 -15
- package/src/components/grid/MRow/MRow.vue +0 -28
- package/src/components/index.ts +0 -30
- package/src/composables/useMyth.ts +0 -93
- package/src/composables/useMythMeta.ts +0 -40
- package/src/config/config.ts +0 -16
- package/src/config/grid.ts +0 -10
- package/src/config/index.ts +0 -2
- package/src/css/components/m-btn.scss +0 -13
- package/src/css/index.scss +0 -9
- package/src/env.d.ts +0 -14
- package/src/index.common.js +0 -1
- package/src/index.ts +0 -4
- package/src/index.umd.js +0 -2
- package/src/shims-myth.d.ts +0 -6
- package/src/shims-vue.d.ts +0 -22
- package/src/types/config.ts +0 -136
- package/src/types/helpers.ts +0 -21
- package/src/types/index.ts +0 -9
- package/src/types/vue-prop-types.ts +0 -13
- package/src/utils/helpers.ts +0 -446
- package/src/utils/icons.ts +0 -4
- package/src/utils/index.ts +0 -77
- package/src/utils/str.ts +0 -237
- package/src/utils/vee-rules.ts +0 -40
- package/src/vue-plugin.ts +0 -76
package/src/utils/helpers.ts
DELETED
|
@@ -1,446 +0,0 @@
|
|
|
1
|
-
import type { AxiosInstance, AxiosRequestConfig } from 'axios'
|
|
2
|
-
import { colors, openURL, scroll, setCssVar } from 'quasar'
|
|
3
|
-
import { nextTick } from 'vue'
|
|
4
|
-
import type {
|
|
5
|
-
ConfigType,
|
|
6
|
-
DownloadFromResponse,
|
|
7
|
-
DownloadFromResponseCode,
|
|
8
|
-
HelpersStubSchema,
|
|
9
|
-
ParamsType,
|
|
10
|
-
UrlType
|
|
11
|
-
} from '../types/helpers'
|
|
12
|
-
|
|
13
|
-
const defOpacity = 10
|
|
14
|
-
export const darkenColor = (color: string, percent: number = defOpacity) => {
|
|
15
|
-
const { lighten } = colors
|
|
16
|
-
return lighten(color, percent * -1)
|
|
17
|
-
}
|
|
18
|
-
export const lightenColor = (color: string, percent: number = defOpacity) => {
|
|
19
|
-
const { lighten } = colors
|
|
20
|
-
return lighten(color, percent)
|
|
21
|
-
}
|
|
22
|
-
export const setCss: typeof setCssVar = (varName, value, element) => {
|
|
23
|
-
setCssVar(varName, value, element || document.documentElement)
|
|
24
|
-
if (varName === 'primary') {
|
|
25
|
-
const lighten = lightenColor(value, 50)
|
|
26
|
-
const dark = darkenColor(value, 10)
|
|
27
|
-
setCssVar('scrollbar-track', lighten)
|
|
28
|
-
setCssVar('scrollbar-hover', dark)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export const colorIsDark = (color: string): boolean => {
|
|
32
|
-
const { luminosity } = colors
|
|
33
|
-
return luminosity(color) < 0.5
|
|
34
|
-
}
|
|
35
|
-
export const appendArray = (
|
|
36
|
-
formData: FormData,
|
|
37
|
-
values: File | Blob | Record<string, any> | any,
|
|
38
|
-
name?: string | null
|
|
39
|
-
) => {
|
|
40
|
-
let value: never | any
|
|
41
|
-
if ((values instanceof File || values instanceof Blob) && name) {
|
|
42
|
-
const _name = values instanceof File ? values.name : name
|
|
43
|
-
formData.append(name, values, _name)
|
|
44
|
-
} else {
|
|
45
|
-
for (const key in values) {
|
|
46
|
-
value = values[key]
|
|
47
|
-
if (value !== null && value !== undefined && typeof value === 'object') {
|
|
48
|
-
const k = name ? name + '[' + key + ']' : key
|
|
49
|
-
if (Array.isArray(value) && value.length < 1) {
|
|
50
|
-
formData.append(`${key}`, '')
|
|
51
|
-
} else {
|
|
52
|
-
appendArray(formData, value, k)
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
if (value === !0) {
|
|
56
|
-
value = 1
|
|
57
|
-
}
|
|
58
|
-
if (value === false) {
|
|
59
|
-
value = 0
|
|
60
|
-
}
|
|
61
|
-
if (value === null || value === undefined) {
|
|
62
|
-
value = ''
|
|
63
|
-
// console.log('null----', name,key, value)
|
|
64
|
-
}
|
|
65
|
-
// if (value !== undefined) {
|
|
66
|
-
if (name) {
|
|
67
|
-
formData.append(name + '[' + key + ']', value)
|
|
68
|
-
} else {
|
|
69
|
-
formData.append(key, value)
|
|
70
|
-
}
|
|
71
|
-
// }
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return formData
|
|
76
|
-
}
|
|
77
|
-
export const Stub = (baseUrl: UrlType, axios: () => AxiosInstance): HelpersStubSchema => {
|
|
78
|
-
const makeUrl = StubUrl(baseUrl)
|
|
79
|
-
return {
|
|
80
|
-
async index(config?: ConfigType) {
|
|
81
|
-
const u = makeUrl()
|
|
82
|
-
return axios().get(u, config)
|
|
83
|
-
},
|
|
84
|
-
async staticIndex(config?: ConfigType) {
|
|
85
|
-
const u = `Static${baseUrl ? `/${baseUrl}` : ''}`
|
|
86
|
-
return axios().get(u, config)
|
|
87
|
-
},
|
|
88
|
-
async export(data?: ParamsType, config?: AxiosRequestConfig) {
|
|
89
|
-
return axios().post(makeUrl('Export'), data, config)
|
|
90
|
-
},
|
|
91
|
-
async exampleUrl(config?: AxiosRequestConfig) {
|
|
92
|
-
return axios().get(makeUrl('ExampleUrl'), config)
|
|
93
|
-
},
|
|
94
|
-
async store(data?: ParamsType, config?: AxiosRequestConfig) {
|
|
95
|
-
const u = makeUrl()
|
|
96
|
-
const formData = new FormData()
|
|
97
|
-
data && appendArray(formData, data)
|
|
98
|
-
return axios().post(u, formData, config)
|
|
99
|
-
},
|
|
100
|
-
async show(id: UrlType, config?: AxiosRequestConfig) {
|
|
101
|
-
const u = makeUrl(id)
|
|
102
|
-
return axios().get(u, config)
|
|
103
|
-
},
|
|
104
|
-
async staticShow(id: UrlType, config?: AxiosRequestConfig) {
|
|
105
|
-
const u = `Static${baseUrl ? `/${baseUrl}` : ''}` + `/${id}`
|
|
106
|
-
return axios().get(u, config)
|
|
107
|
-
},
|
|
108
|
-
async update(id: UrlType, data?: ParamsType, config?: AxiosRequestConfig) {
|
|
109
|
-
const u = makeUrl(id)
|
|
110
|
-
const formData = new FormData()
|
|
111
|
-
formData.append('_method', 'put')
|
|
112
|
-
data && appendArray(formData, data)
|
|
113
|
-
return axios().post(u, formData, config)
|
|
114
|
-
},
|
|
115
|
-
async clone(id: UrlType, data?: ParamsType, config?: AxiosRequestConfig) {
|
|
116
|
-
const u = makeUrl(`${id}/Clone`)
|
|
117
|
-
const formData = new FormData()
|
|
118
|
-
data && appendArray(formData, data)
|
|
119
|
-
return axios().post(u, formData, config)
|
|
120
|
-
},
|
|
121
|
-
async destroy(id: UrlType, config?: AxiosRequestConfig) {
|
|
122
|
-
const u = makeUrl(id)
|
|
123
|
-
return axios().delete(u, config)
|
|
124
|
-
},
|
|
125
|
-
async destroyAll(ids?: UrlType[], config?: AxiosRequestConfig) {
|
|
126
|
-
const u = makeUrl('DestroyAll')
|
|
127
|
-
return axios().post(u, { ids: ids || [] }, config)
|
|
128
|
-
},
|
|
129
|
-
getUploadAttachmentsUrl: (id: UrlType): string => makeUrl(`${id}/Attachment/Upload`),
|
|
130
|
-
async uploadAttachments(id: UrlType, data: Record<string, any>, config?: AxiosRequestConfig) {
|
|
131
|
-
const _url = makeUrl(`${id}/Attachment/Upload`)
|
|
132
|
-
return axios().post(_url, data, config)
|
|
133
|
-
},
|
|
134
|
-
async deleteAttachment(id: UrlType, fileId: string | number, config?: AxiosRequestConfig) {
|
|
135
|
-
const _url = makeUrl(`${id}/Attachment/${fileId}/Delete`)
|
|
136
|
-
return axios().delete(_url, config)
|
|
137
|
-
},
|
|
138
|
-
async updateAttachment(
|
|
139
|
-
id: UrlType,
|
|
140
|
-
fileId: string | number,
|
|
141
|
-
data: Record<string, any>,
|
|
142
|
-
config?: AxiosRequestConfig
|
|
143
|
-
) {
|
|
144
|
-
const _url = makeUrl(`${id}/Attachment/${fileId}/Update`)
|
|
145
|
-
return axios().post(_url, data, config)
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
export const StubUrl = (group?: UrlType): ((segments?: UrlType, parent?: UrlType) => string) => {
|
|
150
|
-
return (segments?: UrlType, parent?: UrlType): string =>
|
|
151
|
-
(parent ?? '') +
|
|
152
|
-
(parent && group ? '/' : '') +
|
|
153
|
-
(group ?? '') +
|
|
154
|
-
((group && segments ? '/' : '') + (segments ?? ''))
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Open unique window popup of application
|
|
158
|
-
*
|
|
159
|
-
* @param url
|
|
160
|
-
* @param reject
|
|
161
|
-
* @param windowFeatures
|
|
162
|
-
*/
|
|
163
|
-
export const openWindow = <F extends (...args: any[]) => any>(
|
|
164
|
-
url: string,
|
|
165
|
-
reject?: F,
|
|
166
|
-
windowFeatures?: object
|
|
167
|
-
) => {
|
|
168
|
-
return openURL(url, reject, windowFeatures)
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Customized helper to download blob from axios response
|
|
172
|
-
* @param response
|
|
173
|
-
* @param callback
|
|
174
|
-
*/
|
|
175
|
-
export const downloadFromResponse = (
|
|
176
|
-
response: any,
|
|
177
|
-
callback?: (url: string, response: any) => void
|
|
178
|
-
) => {
|
|
179
|
-
return new Promise<DownloadFromResponse>((resolve, reject) => {
|
|
180
|
-
const rejectPromise = (e?: { code: DownloadFromResponseCode }) =>
|
|
181
|
-
reject(e ?? { status: !1, code: 'unknown' })
|
|
182
|
-
const resolvePromise = (response: DownloadFromResponse['response']) =>
|
|
183
|
-
resolve({ status: !0, response })
|
|
184
|
-
try {
|
|
185
|
-
if (!response) {
|
|
186
|
-
rejectPromise({ code: 'no_response' })
|
|
187
|
-
return
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (response?.data?.data?.url) {
|
|
191
|
-
const url = response?.data?.data?.url
|
|
192
|
-
if (callback) {
|
|
193
|
-
callback(url, response)
|
|
194
|
-
resolvePromise(response)
|
|
195
|
-
return
|
|
196
|
-
}
|
|
197
|
-
const elm = document.createElement('a')
|
|
198
|
-
elm.setAttribute('href', url)
|
|
199
|
-
elm.setAttribute('target', '_blank')
|
|
200
|
-
document.body.appendChild(elm)
|
|
201
|
-
elm.click()
|
|
202
|
-
resolvePromise(response)
|
|
203
|
-
return
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const name = (response.headers['content-disposition'] || '')
|
|
207
|
-
.split('filename=')
|
|
208
|
-
.pop()
|
|
209
|
-
.replace(/^"+|"+$/g, '')
|
|
210
|
-
if (!name) {
|
|
211
|
-
rejectPromise({ code: 'no_file_name' })
|
|
212
|
-
return
|
|
213
|
-
}
|
|
214
|
-
const file = new Blob([response.data])
|
|
215
|
-
const fileURL = window.URL.createObjectURL(file)
|
|
216
|
-
const fileLink = document.createElement('a')
|
|
217
|
-
if (!fileLink || !fileURL) {
|
|
218
|
-
rejectPromise({ code: 'no_file_url' })
|
|
219
|
-
return
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
fileLink.href = fileURL
|
|
223
|
-
fileLink.setAttribute('download', name)
|
|
224
|
-
document.body.appendChild(fileLink)
|
|
225
|
-
fileLink.click()
|
|
226
|
-
resolvePromise(response)
|
|
227
|
-
setTimeout(() => {
|
|
228
|
-
try {
|
|
229
|
-
document.body.removeChild(fileLink)
|
|
230
|
-
URL.revokeObjectURL(fileURL)
|
|
231
|
-
} catch (e: any) {
|
|
232
|
-
console.log(e)
|
|
233
|
-
if (e?.message) {
|
|
234
|
-
alert(e.message)
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}, 3000)
|
|
238
|
-
} catch (e: any) {
|
|
239
|
-
console.log(e)
|
|
240
|
-
rejectPromise(e)
|
|
241
|
-
}
|
|
242
|
-
})
|
|
243
|
-
}
|
|
244
|
-
export const isElementInViewport = (element: Element | Window | HTMLElement): boolean => {
|
|
245
|
-
const rect =
|
|
246
|
-
element instanceof Window
|
|
247
|
-
? element.document?.body?.getBoundingClientRect()
|
|
248
|
-
: element?.getBoundingClientRect?.()
|
|
249
|
-
if (!rect) return false
|
|
250
|
-
return (
|
|
251
|
-
rect.top >= 0 &&
|
|
252
|
-
rect.left >= 0 &&
|
|
253
|
-
rect.bottom <= window.innerHeight + rect.height &&
|
|
254
|
-
rect.right <= window.innerWidth + rect.width
|
|
255
|
-
)
|
|
256
|
-
}
|
|
257
|
-
export const scrollToElement = async (
|
|
258
|
-
el: Element | HTMLElement | string,
|
|
259
|
-
opt?: { target?: HTMLElement | string; duration?: number; offset?: number }
|
|
260
|
-
) => {
|
|
261
|
-
await nextTick()
|
|
262
|
-
const { getScrollTarget, setVerticalScrollPosition, getVerticalScrollPosition } = scroll
|
|
263
|
-
const scrollTo = typeof el === 'string' ? (document.querySelector(el) as HTMLElement) : el
|
|
264
|
-
if (!scrollTo) {
|
|
265
|
-
return
|
|
266
|
-
}
|
|
267
|
-
await nextTick()
|
|
268
|
-
const { target: t } = opt || {}
|
|
269
|
-
const targetSelector = typeof t === 'string' ? (document.querySelector(t) as HTMLElement) : t
|
|
270
|
-
const target = getScrollTarget(scrollTo, targetSelector || window.document.documentElement)
|
|
271
|
-
const current = getVerticalScrollPosition(target)
|
|
272
|
-
const duration = opt?.duration || 1000
|
|
273
|
-
let offset
|
|
274
|
-
let parent = scrollTo
|
|
275
|
-
try {
|
|
276
|
-
do {
|
|
277
|
-
offset = parent.getBoundingClientRect().top
|
|
278
|
-
if (offset === 0 && !parent.parentElement) {
|
|
279
|
-
offset = parent.scrollTop
|
|
280
|
-
break
|
|
281
|
-
} else if (offset !== 0 && parent.parentElement) {
|
|
282
|
-
break
|
|
283
|
-
}
|
|
284
|
-
parent = parent.parentElement as HTMLElement
|
|
285
|
-
} while (parent)
|
|
286
|
-
} catch (e) {
|
|
287
|
-
console.log(e)
|
|
288
|
-
offset = 'offsetTop' in scrollTo ? (scrollTo?.offsetTop as number) || 0 : 0
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
const _offset = offset + current - (100 + (opt?.offset || 0))
|
|
292
|
-
if (!isElementInViewport(scrollTo)) {
|
|
293
|
-
setVerticalScrollPosition(target, _offset, duration)
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
export const scrollToElementFromErrors = async (
|
|
297
|
-
errors?: Partial<Record<string, string[] | string | null | undefined>>,
|
|
298
|
-
elm?: any,
|
|
299
|
-
target?: any
|
|
300
|
-
) => {
|
|
301
|
-
if (!errors) {
|
|
302
|
-
return
|
|
303
|
-
}
|
|
304
|
-
const allErrors = Object.entries(errors)
|
|
305
|
-
const keys = allErrors.map(([k]) => k)
|
|
306
|
-
let siblings: Element[] = []
|
|
307
|
-
if (allErrors.length > 0) {
|
|
308
|
-
siblings = Array.from(
|
|
309
|
-
document.body.querySelectorAll('[data-input-name].m-input__error') || []
|
|
310
|
-
).filter(k => keys.includes(k?.getAttribute('data-input-name') as string))
|
|
311
|
-
}
|
|
312
|
-
if (siblings.length > 0) {
|
|
313
|
-
for (const s of siblings) {
|
|
314
|
-
const e = allErrors.find(e => e[0] === s.getAttribute('data-input-name'))
|
|
315
|
-
if (e?.[1]) {
|
|
316
|
-
const name = e[0]
|
|
317
|
-
await scrollToElement(s || `[name='${name}']`, { target })
|
|
318
|
-
break
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
return
|
|
322
|
-
}
|
|
323
|
-
for (const [name, value] of allErrors) {
|
|
324
|
-
const val = value && Array.isArray(value) ? value[0] : value
|
|
325
|
-
if (val?.toString?.()?.length) {
|
|
326
|
-
if (!elm) {
|
|
327
|
-
const selector = `[data-input-name='${name}']`
|
|
328
|
-
const e = document.querySelector(selector) as HTMLElement
|
|
329
|
-
await scrollToElement(e || `[name='${name}']`, { target })
|
|
330
|
-
} else {
|
|
331
|
-
await scrollToElement(elm, { target })
|
|
332
|
-
}
|
|
333
|
-
break
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
export const scrollToBottom = async (
|
|
338
|
-
scrollTarget?: HTMLElement | Element | Window | string,
|
|
339
|
-
duration?: number,
|
|
340
|
-
offset?: number
|
|
341
|
-
) => {
|
|
342
|
-
const { setVerticalScrollPosition, getScrollHeight } = scroll
|
|
343
|
-
if (!scrollTarget) {
|
|
344
|
-
scrollTarget = window
|
|
345
|
-
}
|
|
346
|
-
const str = scrollTarget && typeof scrollTarget === 'string'
|
|
347
|
-
const target = str
|
|
348
|
-
? (document.querySelector(scrollTarget as string) as HTMLElement) || window
|
|
349
|
-
: (scrollTarget as any)
|
|
350
|
-
offset = offset || getScrollHeight(target)
|
|
351
|
-
duration = duration || 600
|
|
352
|
-
setVerticalScrollPosition(target, offset, duration)
|
|
353
|
-
}
|
|
354
|
-
export const makeUrl = (path: string) => {
|
|
355
|
-
path = path || ''
|
|
356
|
-
if (path.slice(0, 1) === '/') {
|
|
357
|
-
path = path.slice(1)
|
|
358
|
-
}
|
|
359
|
-
if (window) {
|
|
360
|
-
const l = window.location
|
|
361
|
-
return `${l.protocol}//${l.host}/${path}`
|
|
362
|
-
}
|
|
363
|
-
return `//${path}`
|
|
364
|
-
}
|
|
365
|
-
export const formatMoney = (
|
|
366
|
-
value: any = '',
|
|
367
|
-
suffix: string = '',
|
|
368
|
-
options?: Intl.NumberFormatOptions
|
|
369
|
-
): string => {
|
|
370
|
-
let numValue = typeof value !== 'number' ? parseFloat(value) : value
|
|
371
|
-
if (isNaN(numValue)) {
|
|
372
|
-
numValue = 0.0
|
|
373
|
-
}
|
|
374
|
-
const opt = {
|
|
375
|
-
minimumFractionDigits: 2,
|
|
376
|
-
maximumFractionDigits: 2,
|
|
377
|
-
...(options || {})
|
|
378
|
-
}
|
|
379
|
-
const formattedValue = numValue.toLocaleString('en-US', opt)
|
|
380
|
-
return `${formattedValue} ${suffix}`.trim()
|
|
381
|
-
}
|
|
382
|
-
export const calculateAspectRatio = (
|
|
383
|
-
width: number | string,
|
|
384
|
-
height: number | string
|
|
385
|
-
): [number, string] => {
|
|
386
|
-
width = Number(width)
|
|
387
|
-
height = Number(height)
|
|
388
|
-
const gcd: any = (a: number, b: number) => (b === 0 ? a : gcd(b, a % b))
|
|
389
|
-
const divisor = gcd(width, height)
|
|
390
|
-
return [width / height, `${width / divisor}:${height / divisor}`]
|
|
391
|
-
}
|
|
392
|
-
export const convertToArabicNumbers = (input: string | number): string => {
|
|
393
|
-
const numberMap: { [key: string]: string } = {
|
|
394
|
-
0: '٠',
|
|
395
|
-
1: '١',
|
|
396
|
-
2: '٢',
|
|
397
|
-
3: '٣',
|
|
398
|
-
4: '٤',
|
|
399
|
-
5: '٥',
|
|
400
|
-
6: '٦',
|
|
401
|
-
7: '٧',
|
|
402
|
-
8: '٨',
|
|
403
|
-
9: '٩'
|
|
404
|
-
}
|
|
405
|
-
return input
|
|
406
|
-
.toString()
|
|
407
|
-
.split('')
|
|
408
|
-
.map(char => numberMap[char] || char)
|
|
409
|
-
.join('')
|
|
410
|
-
}
|
|
411
|
-
export const uniqBy = <T>(array: T[], key: keyof T): T[] => {
|
|
412
|
-
const seen = new Set()
|
|
413
|
-
return array.filter(item => {
|
|
414
|
-
if (!item) return false
|
|
415
|
-
const value = item[key]
|
|
416
|
-
if (seen.has(value)) {
|
|
417
|
-
return false
|
|
418
|
-
}
|
|
419
|
-
seen.add(value)
|
|
420
|
-
return true
|
|
421
|
-
})
|
|
422
|
-
}
|
|
423
|
-
export const uniq = <T>(array: T[]): T[] => {
|
|
424
|
-
return [...new Set(array)]
|
|
425
|
-
}
|
|
426
|
-
export const shuffle = <T = any>(array: readonly T[]): T[] => {
|
|
427
|
-
const newArray = [...(array || [])]
|
|
428
|
-
for (let i = newArray.length - 1; i > 0; i--) {
|
|
429
|
-
const j = Math.floor(Math.random() * (i + 1))
|
|
430
|
-
;[newArray[i], newArray[j]] = [newArray[j], newArray[i]] as [T, T]
|
|
431
|
-
}
|
|
432
|
-
return newArray
|
|
433
|
-
}
|
|
434
|
-
export const detectWebPlatform = (): 'ios' | 'android' | 'other' => {
|
|
435
|
-
let userAgent = navigator.userAgent || navigator.vendor
|
|
436
|
-
userAgent = userAgent ? userAgent.toLowerCase() : ''
|
|
437
|
-
if (/ipad|iphone|ipod/g.test(userAgent)) {
|
|
438
|
-
return 'ios'
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
if (/android/i.test(userAgent)) {
|
|
442
|
-
return 'android'
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
return 'other'
|
|
446
|
-
}
|
package/src/utils/icons.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export const iconSet = 'myth-'
|
|
2
|
-
export const icons = {
|
|
3
|
-
sar: '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&&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|0 0 1124.14 1256.39'
|
|
4
|
-
}
|
package/src/utils/index.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { colors, copyToClipboard } from 'quasar'
|
|
2
|
-
|
|
3
|
-
const { getPaletteColor } = colors
|
|
4
|
-
|
|
5
|
-
export interface DimensionOptions {
|
|
6
|
-
width?: string | number
|
|
7
|
-
height?: string | number
|
|
8
|
-
ratio?: string | number
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Calculates dimensions or aspect ratio based on provided values.
|
|
13
|
-
*/
|
|
14
|
-
export const dimension = (options?: DimensionOptions): number | null => {
|
|
15
|
-
if (!options) return null
|
|
16
|
-
|
|
17
|
-
const isPresent = (v: unknown): v is number | string => v !== undefined && v !== null
|
|
18
|
-
|
|
19
|
-
const ratio = isPresent(options.ratio)
|
|
20
|
-
? typeof options.ratio === 'string'
|
|
21
|
-
? parseFloat(options.ratio)
|
|
22
|
-
: options.ratio
|
|
23
|
-
: undefined
|
|
24
|
-
|
|
25
|
-
const height = isPresent(options.height)
|
|
26
|
-
? typeof options.height === 'string'
|
|
27
|
-
? parseFloat(options.height)
|
|
28
|
-
: options.height
|
|
29
|
-
: undefined
|
|
30
|
-
|
|
31
|
-
const width = isPresent(options.width)
|
|
32
|
-
? typeof options.width === 'string'
|
|
33
|
-
? parseFloat(options.width)
|
|
34
|
-
: options.width
|
|
35
|
-
: undefined
|
|
36
|
-
|
|
37
|
-
if (isPresent(width) && isPresent(height)) {
|
|
38
|
-
return height === 0 ? null : width / height
|
|
39
|
-
}
|
|
40
|
-
if (isPresent(ratio) && isPresent(height)) {
|
|
41
|
-
return ratio * height // Calculates implied width
|
|
42
|
-
}
|
|
43
|
-
if (isPresent(ratio) && isPresent(width)) {
|
|
44
|
-
return ratio === 0 ? null : width / ratio // Calculates implied height
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return null
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Converts a hex or Quasar palette color token into a CSS inline style string.
|
|
52
|
-
*/
|
|
53
|
-
export const colorStyle = (value: string | null | undefined, bg = false): string => {
|
|
54
|
-
if (!value) return ''
|
|
55
|
-
|
|
56
|
-
let parsedColor = value
|
|
57
|
-
if (!value.startsWith('#') && value !== 'transparent') {
|
|
58
|
-
parsedColor = getPaletteColor(value)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const property = bg ? 'background-color' : 'color'
|
|
62
|
-
return `${property}: ${parsedColor};`
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Copies string content to the system clipboard and returns the processed value.
|
|
67
|
-
*/
|
|
68
|
-
export const copyText = async (text: string | number | null | undefined): Promise<string> => {
|
|
69
|
-
const cleanText = text !== undefined && text !== null ? String(text) : ''
|
|
70
|
-
await copyToClipboard(cleanText)
|
|
71
|
-
return cleanText
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export * from './helpers'
|
|
75
|
-
export * from './icons'
|
|
76
|
-
export * from './str'
|
|
77
|
-
export * from './vee-rules'
|