@mythpe/quasar-ui-qui 0.0.27 → 0.0.29-dev
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/index.d.ts +13 -0
- package/package.json +17 -8
- package/src/boot/register.ts +14 -0
- package/src/components/datatable/MDatatable.vue +2305 -0
- package/src/components/datatable/MDtAvatar.vue +49 -0
- package/src/components/datatable/MDtBtn.vue +153 -0
- package/src/components/datatable/MDtContextmenuItems.vue +54 -0
- package/src/components/datatable/index.ts +6 -0
- package/src/components/form/MAvatarViewer.vue +327 -0
- package/src/components/form/MAxios.vue +144 -0
- package/src/components/form/MBtn.vue +271 -93
- package/src/components/form/MCheckbox.vue +150 -0
- package/src/components/form/MCkeditor.vue +403 -0
- package/src/components/form/MColor.vue +122 -0
- package/src/components/form/MDate.vue +50 -0
- package/src/components/form/MEditor.vue +285 -0
- package/src/components/form/MEmail.vue +43 -0
- package/src/components/form/MField.vue +148 -0
- package/src/components/form/MFile.vue +215 -0
- package/src/components/form/MForm.vue +89 -0
- package/src/components/form/MHidden.vue +86 -0
- package/src/components/form/MHiddenInput.vue +58 -0
- package/src/components/form/MInput.vue +178 -0
- package/src/components/form/MInputFieldControl.vue +27 -0
- package/src/components/form/MInputLabel.vue +38 -0
- package/src/components/form/MMobile.vue +43 -0
- package/src/components/form/MOptions.vue +255 -0
- package/src/components/form/MOtp.vue +292 -0
- package/src/components/form/MPassword.vue +73 -0
- package/src/components/form/MPicker.vue +313 -0
- package/src/components/form/MRadio.vue +181 -0
- package/src/components/form/MSelect.vue +352 -0
- package/src/components/form/MTime.vue +48 -0
- package/src/components/form/MToggle.vue +211 -0
- package/src/components/form/MUploader.vue +511 -0
- package/src/components/form/index.ts +65 -0
- package/src/components/grid/MBlock.vue +39 -18
- package/src/components/grid/MCol.vue +11 -15
- package/src/components/grid/MColumn.vue +12 -1
- package/src/components/grid/MContainer.vue +22 -13
- package/src/components/grid/MHelpRow.vue +13 -12
- package/src/components/grid/MRow.vue +31 -10
- package/src/components/grid/index.ts +16 -0
- package/src/components/index.ts +15 -0
- package/src/components/modal/MDialog.vue +58 -0
- package/src/components/modal/MModalMenu.vue +62 -0
- package/src/components/modal/MTooltip.vue +39 -0
- package/src/components/modal/index.ts +5 -0
- package/src/components/parials/UploaderItem.vue +298 -0
- package/src/components/parials/index.ts +3 -0
- package/src/components/transition/MFadeTransition.vue +27 -0
- package/src/components/transition/MFadeXTransition.vue +26 -0
- package/src/components/transition/MTransition.vue +44 -0
- package/src/components/transition/index.ts +13 -0
- package/src/components/typography/MTypingString.vue +8 -0
- package/src/components/typography/index.ts +11 -0
- package/src/composable/index.ts +12 -0
- package/src/composable/useBindInput.ts +209 -0
- package/src/composable/useError.ts +11 -0
- package/src/composable/useMyth.ts +311 -0
- package/src/composable/useValue.ts +12 -0
- package/src/index.common.js +19 -1
- package/src/index.esm.js +18 -3
- package/src/index.js +19 -0
- package/src/index.sass +9 -26
- package/src/index.ts +18 -4
- package/src/index.umd.js +17 -2
- package/src/style/m-container.sass +13 -0
- package/src/style/main.sass +146 -0
- package/src/style/print.sass +14 -0
- package/src/style/transition.sass +40 -0
- package/src/types/api-helpers.d.ts +62 -0
- package/src/types/components.d.ts +1108 -27
- package/src/types/index.d.ts +21 -1
- package/src/types/install-options.d.ts +19 -0
- package/src/types/lodash.d.ts +26 -0
- package/src/types/m-datatable.d.ts +316 -0
- package/src/types/m-geolocation.d.ts +16 -0
- package/src/types/m-helpers.d.ts +97 -0
- package/src/types/plugin-props-option.d.ts +305 -0
- package/src/types/quasar-helpers.d.ts +7 -0
- package/src/types/theme.d.ts +12 -0
- package/src/utils/Helpers.ts +293 -0
- package/src/utils/Str.ts +211 -0
- package/src/utils/index.ts +13 -0
- package/src/utils/myth.ts +109 -0
- package/src/utils/vee-rules.ts +32 -0
- package/src/utils/vue-plugin.ts +163 -0
- package/tsconfig.json +9 -13
- package/src/myth.ts +0 -30
- package/src/types/myth.ts +0 -42
- package/src/vue-plugin.ts +0 -41
- package/types.d.ts +0 -1
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
MAvatarViewerProps,
|
|
3
|
+
MBlockProps,
|
|
4
|
+
MBtnProps,
|
|
5
|
+
MCheckboxProps, MCkeditorProps,
|
|
6
|
+
MColProps,
|
|
7
|
+
MColumnProps,
|
|
8
|
+
MContainerProps,
|
|
9
|
+
MDateProps,
|
|
10
|
+
MDialogProps,
|
|
11
|
+
MEditorProps,
|
|
12
|
+
MFileProps,
|
|
13
|
+
MHelpRowProps,
|
|
14
|
+
MInputProps,
|
|
15
|
+
MModalMenuProps,
|
|
16
|
+
MOptionsProps,
|
|
17
|
+
MOtpProps,
|
|
18
|
+
MPickerProps,
|
|
19
|
+
MRadioProps,
|
|
20
|
+
MRowProps,
|
|
21
|
+
MSelectProps,
|
|
22
|
+
MTimeProps,
|
|
23
|
+
MToggleProps,
|
|
24
|
+
MTooltipProps,
|
|
25
|
+
MTypingStringProps,
|
|
26
|
+
MUploaderProps
|
|
27
|
+
} from './components'
|
|
28
|
+
import type {
|
|
29
|
+
QBtnDropdownProps,
|
|
30
|
+
QBtnProps,
|
|
31
|
+
QCardProps, QDialogOptions,
|
|
32
|
+
QDialogProps,
|
|
33
|
+
QFieldProps, QIconProps, QItemLabelProps,
|
|
34
|
+
QItemProps, QItemSectionProps, QListProps,
|
|
35
|
+
QMenuProps,
|
|
36
|
+
QNotifyCreateOptions,
|
|
37
|
+
QPageStickyProps,
|
|
38
|
+
QPopupProxyProps
|
|
39
|
+
} from 'quasar'
|
|
40
|
+
import { MDatatableProps, MDtBtnProps } from './m-datatable'
|
|
41
|
+
|
|
42
|
+
export interface PropsContext {
|
|
43
|
+
// Grid.
|
|
44
|
+
/**
|
|
45
|
+
* MBlock component.
|
|
46
|
+
*/
|
|
47
|
+
block?: Partial<MBlockProps>;
|
|
48
|
+
/**
|
|
49
|
+
* MCol component.
|
|
50
|
+
*/
|
|
51
|
+
col?: Partial<MColProps>;
|
|
52
|
+
/**
|
|
53
|
+
* MColumn component.
|
|
54
|
+
*/
|
|
55
|
+
column?: Partial<MColumnProps>;
|
|
56
|
+
/**
|
|
57
|
+
* MContainer component.
|
|
58
|
+
*/
|
|
59
|
+
container?: Partial<MContainerProps>;
|
|
60
|
+
/**
|
|
61
|
+
* MHelpRow component.
|
|
62
|
+
*/
|
|
63
|
+
helpRow?: Partial<MHelpRowProps>;
|
|
64
|
+
/**
|
|
65
|
+
* MRow component.
|
|
66
|
+
*/
|
|
67
|
+
row?: Partial<MRowProps>;
|
|
68
|
+
/**
|
|
69
|
+
* MTypingString component.
|
|
70
|
+
*/
|
|
71
|
+
typingString?: Partial<MTypingStringProps>;
|
|
72
|
+
/**
|
|
73
|
+
* MAvatarViewer component.
|
|
74
|
+
*/
|
|
75
|
+
avatarViewer?: Partial<MAvatarViewerProps>;
|
|
76
|
+
/**
|
|
77
|
+
* MBtn component.
|
|
78
|
+
*/
|
|
79
|
+
btn?: Partial<MBtnProps>;
|
|
80
|
+
/**
|
|
81
|
+
* MInput component.
|
|
82
|
+
*/
|
|
83
|
+
input?: Partial<MInputProps>;
|
|
84
|
+
/**
|
|
85
|
+
* MFile component.
|
|
86
|
+
*/
|
|
87
|
+
file?: Partial<MFileProps>;
|
|
88
|
+
/**
|
|
89
|
+
* MMobile component.
|
|
90
|
+
*/
|
|
91
|
+
mobile?: Partial<MInputProps>;
|
|
92
|
+
/**
|
|
93
|
+
* MOptions component.
|
|
94
|
+
*/
|
|
95
|
+
options?: Partial<MOptionsProps>;
|
|
96
|
+
/**
|
|
97
|
+
* MOtp component.
|
|
98
|
+
*/
|
|
99
|
+
otp?: Partial<MOtpProps>;
|
|
100
|
+
/**
|
|
101
|
+
* MInput view mode props.
|
|
102
|
+
*/
|
|
103
|
+
field?: Partial<QFieldProps>;
|
|
104
|
+
/**
|
|
105
|
+
* MCheckbox component.
|
|
106
|
+
*/
|
|
107
|
+
checkbox?: Partial<MCheckboxProps>;
|
|
108
|
+
/**
|
|
109
|
+
* MCkeditor component.
|
|
110
|
+
*/
|
|
111
|
+
ckeditor?: Partial<MCkeditorProps>;
|
|
112
|
+
/**
|
|
113
|
+
* MRadio component.
|
|
114
|
+
*/
|
|
115
|
+
radio?: Partial<MRadioProps>;
|
|
116
|
+
/**
|
|
117
|
+
* MSelect component.
|
|
118
|
+
*/
|
|
119
|
+
select?: Partial<MSelectProps>;
|
|
120
|
+
/**
|
|
121
|
+
* MPicker component.
|
|
122
|
+
*/
|
|
123
|
+
picker?: Partial<MPickerProps>;
|
|
124
|
+
/**
|
|
125
|
+
* q-btn component props.
|
|
126
|
+
*/
|
|
127
|
+
pickerBtn?: Partial<QBtnProps>;
|
|
128
|
+
/**
|
|
129
|
+
* MDate component.
|
|
130
|
+
*/
|
|
131
|
+
date?: Partial<MDateProps>;
|
|
132
|
+
/**
|
|
133
|
+
* MEditor component.
|
|
134
|
+
*/
|
|
135
|
+
editor?: Partial<MEditorProps>;
|
|
136
|
+
/**
|
|
137
|
+
* MTime component.
|
|
138
|
+
*/
|
|
139
|
+
time?: Partial<MTimeProps>;
|
|
140
|
+
/**
|
|
141
|
+
* MToggle component.
|
|
142
|
+
*/
|
|
143
|
+
toggle?: Partial<MToggleProps>;
|
|
144
|
+
/**
|
|
145
|
+
* MUploader component.
|
|
146
|
+
*/
|
|
147
|
+
uploader?: Partial<MUploaderProps>;
|
|
148
|
+
/**
|
|
149
|
+
* MUploader options.
|
|
150
|
+
*/
|
|
151
|
+
uploaderOptions?: {
|
|
152
|
+
downloadBtnProps?: Partial<QBtnProps>;
|
|
153
|
+
removeBtnProps?: Partial<QBtnProps>;
|
|
154
|
+
iconsSize?: MUploaderProps['iconsSize'];
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Notify Props.
|
|
158
|
+
*/
|
|
159
|
+
notify?: Partial<QNotifyCreateOptions>;
|
|
160
|
+
/**
|
|
161
|
+
* MDialog component.
|
|
162
|
+
*/
|
|
163
|
+
dialog?: Partial<MDialogProps>;
|
|
164
|
+
confirmDialog?: Partial<QDialogOptions>;
|
|
165
|
+
confirmDialogOptions?: {
|
|
166
|
+
buttons?: Partial<QBtnProps>;
|
|
167
|
+
okProps?: Partial<QBtnProps>;
|
|
168
|
+
cancelProps?: Partial<QBtnProps>;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* MModalMenu component.
|
|
172
|
+
*/
|
|
173
|
+
modalMenu?: Partial<MModalMenuProps>;
|
|
174
|
+
/**
|
|
175
|
+
* MModalMenu options.
|
|
176
|
+
*/
|
|
177
|
+
modalMenuOptions?: {
|
|
178
|
+
card?: Partial<QCardProps>;
|
|
179
|
+
closeBtn?: Partial<QItemProps>;
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* MTooltip component.
|
|
183
|
+
*/
|
|
184
|
+
tooltip?: Partial<MTooltipProps>;
|
|
185
|
+
/**
|
|
186
|
+
* MDatatable component.
|
|
187
|
+
*/
|
|
188
|
+
datatable?: Partial<MDatatableProps>;
|
|
189
|
+
/**
|
|
190
|
+
* Styles for DataTable.
|
|
191
|
+
*/
|
|
192
|
+
dt?: {
|
|
193
|
+
/**
|
|
194
|
+
* Style of the DataTable.
|
|
195
|
+
*/
|
|
196
|
+
dense?: boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Quasar loading with datatable loading props.
|
|
199
|
+
*/
|
|
200
|
+
useQuasarLoading?: boolean;
|
|
201
|
+
/**
|
|
202
|
+
* MModalMenu props.
|
|
203
|
+
* Inside table top slot.
|
|
204
|
+
* defaults: no-close-btn & persistent & position="top"
|
|
205
|
+
*/
|
|
206
|
+
filterDialogProps?: Partial<QDialogProps> & Partial<QMenuProps> & Partial<QPopupProxyProps>;
|
|
207
|
+
showDialogProps?: Partial<QDialogProps>;
|
|
208
|
+
formDialogProps?: Partial<QDialogProps>;
|
|
209
|
+
fabBtn?: {
|
|
210
|
+
pageStickyProps?: Partial<QPageStickyProps>;
|
|
211
|
+
offset?: QPageStickyProps['offset'];
|
|
212
|
+
position?: QPageStickyProps['position'];
|
|
213
|
+
buttonProps?: Partial<QBtnProps>;
|
|
214
|
+
},
|
|
215
|
+
contextmenu?: {
|
|
216
|
+
menu?: Partial<MModalMenuProps>;
|
|
217
|
+
list?: Partial<QListProps>;
|
|
218
|
+
btnStyle?: {
|
|
219
|
+
showLabel?: boolean;
|
|
220
|
+
updateColor?: string;
|
|
221
|
+
showColor?: string;
|
|
222
|
+
destroyColor?: string;
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
buttons?: {
|
|
226
|
+
filter?: Partial<MDtBtnProps>;
|
|
227
|
+
refresh?: Partial<MDtBtnProps>;
|
|
228
|
+
more?: Partial<MDtBtnProps>;
|
|
229
|
+
fullscreen?: Partial<MDtBtnProps>;
|
|
230
|
+
moreMenu?: Partial<QMenuProps>;
|
|
231
|
+
moreList?: Partial<QListProps>;
|
|
232
|
+
moreItem?: Partial<QItemProps>;
|
|
233
|
+
},
|
|
234
|
+
topSelection?: {
|
|
235
|
+
btn?: Partial<MDtBtnProps>;
|
|
236
|
+
},
|
|
237
|
+
searchInput?: {
|
|
238
|
+
props?: Partial<MInputProps>;
|
|
239
|
+
optionsIcon?: string;
|
|
240
|
+
menuProps?: Partial<QMenuProps>;
|
|
241
|
+
menuBtn?: Partial<QBtnProps>;
|
|
242
|
+
};
|
|
243
|
+
dialogButtonsProps?: Partial<MBtnProps>;
|
|
244
|
+
listItem?: {
|
|
245
|
+
item?: Partial<QItemProps>;
|
|
246
|
+
avatarSection?: Partial<QItemSectionProps>;
|
|
247
|
+
icon?: Partial<QIconProps>;
|
|
248
|
+
labelSection?: Partial<QItemSectionProps>;
|
|
249
|
+
labelItem?: Partial<QItemLabelProps>;
|
|
250
|
+
};
|
|
251
|
+
btn?: Partial<MDtBtnProps>;
|
|
252
|
+
/**
|
|
253
|
+
* Dropdown of control column in table.
|
|
254
|
+
* q-btn-dropdown
|
|
255
|
+
*/
|
|
256
|
+
controlDropdown?: Partial<QBtnDropdownProps>;
|
|
257
|
+
MDtBtn?: {
|
|
258
|
+
/**
|
|
259
|
+
* List mode Props.
|
|
260
|
+
*/
|
|
261
|
+
item?: {
|
|
262
|
+
/**
|
|
263
|
+
* Item Props.
|
|
264
|
+
*/
|
|
265
|
+
props?: Partial<QItemProps>;
|
|
266
|
+
/**
|
|
267
|
+
* q-item-section.
|
|
268
|
+
* Props of avatar section.
|
|
269
|
+
*/
|
|
270
|
+
avatarProps?: Partial<QItemSectionProps>;
|
|
271
|
+
/**
|
|
272
|
+
* q-icon.
|
|
273
|
+
* Props of icon inside avatar section.
|
|
274
|
+
*/
|
|
275
|
+
iconProps?: Partial<QIconProps>;
|
|
276
|
+
/**
|
|
277
|
+
* q-item-section.
|
|
278
|
+
* Props of label section.
|
|
279
|
+
*/
|
|
280
|
+
labelSectionProps?: Partial<QItemSectionProps>;
|
|
281
|
+
/**
|
|
282
|
+
* q-item-label.
|
|
283
|
+
* Props of label inside label section.
|
|
284
|
+
*/
|
|
285
|
+
itemLabelProps?: Partial<QItemLabelProps>;
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* MDtBtn btn mode Props.
|
|
289
|
+
*/
|
|
290
|
+
btn?: {
|
|
291
|
+
props?: Partial<QBtnProps>;
|
|
292
|
+
};
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Default loading q-btn loading slot.
|
|
299
|
+
*/
|
|
300
|
+
export type BtnLoading = {
|
|
301
|
+
type: 'audio' | 'ball' | 'bars' | 'box' | 'clock' | 'comment' | 'cube' | 'dots' | 'facebook' | 'gears' | 'grid' | 'hearts' | 'hourglass' | 'infinity' | 'ios' | 'orbit' | 'oval' | 'pie' | 'puff' | 'radio' | 'rings' | 'tail' | 'spinner';
|
|
302
|
+
color?: string | undefined;
|
|
303
|
+
size?: string | undefined;
|
|
304
|
+
noLabel?: boolean;
|
|
305
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DialogChainObject, QNotifyCreateOptions, QNotifyUpdateOptions } from 'quasar'
|
|
2
|
+
|
|
3
|
+
export type Vue3MAlertMessageOptions = QNotifyCreateOptions | string;
|
|
4
|
+
|
|
5
|
+
export type Vue3MAlertMessage = (props?: QNotifyUpdateOptions) => void;
|
|
6
|
+
|
|
7
|
+
export type Vue3MConfirmMessage = DialogChainObject
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { QBtnProps, QInputProps } from 'quasar'
|
|
2
|
+
|
|
3
|
+
export type ThemeSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'none' | string;
|
|
4
|
+
export type ThemeShadow = string | number | 'transition' | 'none';
|
|
5
|
+
export type ThemeRounded = boolean;
|
|
6
|
+
export type ThemeFluid = boolean;
|
|
7
|
+
export type ThemeInput =
|
|
8
|
+
Partial<Pick<QInputProps, 'standout' | 'dense' | 'filled' | 'outlined' | 'rounded' | 'borderless' | 'counter' | 'noErrorIcon' | 'hideBottomSpace' | 'bottomSlots' | 'clearIcon' | 'itemAligned' | 'square' | 'stackLabel'>>
|
|
9
|
+
& {
|
|
10
|
+
topLabel?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type ThemeBtn = Partial<Pick<QBtnProps, 'flat' | 'outline' | 'push' | 'unelevated' | 'noCaps' | 'rounded' | 'glossy' | 'square' | 'padding' | 'ripple' | 'dense'>>
|
|
@@ -0,0 +1,293 @@
|
|
|
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 type { AxiosInstance, AxiosRequestConfig } from 'axios'
|
|
10
|
+
import type { ConfigType, DownloadFromResponse, DownloadFromResponseCode, HelpersStubSchema, ParamsType, UrlType } from '../types'
|
|
11
|
+
import lodash from 'lodash'
|
|
12
|
+
import { openURL, scroll } from 'quasar'
|
|
13
|
+
|
|
14
|
+
import { nextTick } from 'vue'
|
|
15
|
+
|
|
16
|
+
export const Helpers = {
|
|
17
|
+
appendArray (formData: FormData, values: File | Blob | Record<string, any> | any, name?: string | null | undefined) {
|
|
18
|
+
let value: never | any
|
|
19
|
+
if ((values instanceof File || values instanceof Blob) && name) {
|
|
20
|
+
const _name = values instanceof File ? values.name : name
|
|
21
|
+
formData.append(name, values, _name)
|
|
22
|
+
} else {
|
|
23
|
+
for (const key in values) {
|
|
24
|
+
value = values[key]
|
|
25
|
+
if (value !== null && value !== undefined && typeof value === 'object') {
|
|
26
|
+
const k = name ? name + '[' + key + ']' : key
|
|
27
|
+
if (lodash.isArray(value) && value.length < 1) {
|
|
28
|
+
formData.append(`${key}`, '')
|
|
29
|
+
} else {
|
|
30
|
+
this.appendArray(formData, value, k)
|
|
31
|
+
}
|
|
32
|
+
} else {
|
|
33
|
+
if (value === !0) {
|
|
34
|
+
value = 1
|
|
35
|
+
}
|
|
36
|
+
if (value === false) {
|
|
37
|
+
value = 0
|
|
38
|
+
}
|
|
39
|
+
if (value === null || value === undefined) {
|
|
40
|
+
value = ''
|
|
41
|
+
// console.log('null----', name,key, value)
|
|
42
|
+
}
|
|
43
|
+
// if (value !== undefined) {
|
|
44
|
+
if (name) {
|
|
45
|
+
formData.append(name + '[' + key + ']', value)
|
|
46
|
+
} else {
|
|
47
|
+
formData.append(key, value)
|
|
48
|
+
}
|
|
49
|
+
// }
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return formData
|
|
54
|
+
},
|
|
55
|
+
Stub (baseUrl: UrlType, axios: () => AxiosInstance): HelpersStubSchema {
|
|
56
|
+
const makeUrl = Helpers.StubUrl(baseUrl)
|
|
57
|
+
return {
|
|
58
|
+
async index (config?: ConfigType) {
|
|
59
|
+
const u = makeUrl()
|
|
60
|
+
return axios().get(u, config)
|
|
61
|
+
},
|
|
62
|
+
async staticIndex (config?: ConfigType) {
|
|
63
|
+
const u = `Static${baseUrl ? `/${baseUrl}` : ''}`
|
|
64
|
+
return axios().get(u, config)
|
|
65
|
+
},
|
|
66
|
+
async export (data?: ParamsType, config?: AxiosRequestConfig) {
|
|
67
|
+
return axios().post(makeUrl('Export'), data, config)
|
|
68
|
+
},
|
|
69
|
+
async store (data?: ParamsType, config?: AxiosRequestConfig) {
|
|
70
|
+
const u = makeUrl()
|
|
71
|
+
const formData = new FormData()
|
|
72
|
+
data && Helpers.appendArray(formData, data)
|
|
73
|
+
return axios().post(u, formData, config)
|
|
74
|
+
},
|
|
75
|
+
async show (id: UrlType, config?: AxiosRequestConfig) {
|
|
76
|
+
const u = makeUrl(id)
|
|
77
|
+
return axios().get(u, config)
|
|
78
|
+
},
|
|
79
|
+
async staticShow (id: UrlType, config?: AxiosRequestConfig) {
|
|
80
|
+
const u = `Static${baseUrl ? `/${baseUrl}` : ''}` + `/${id}`
|
|
81
|
+
return axios().get(u, config)
|
|
82
|
+
},
|
|
83
|
+
async update (id: UrlType, data?: ParamsType, config?: AxiosRequestConfig) {
|
|
84
|
+
const u = makeUrl(id)
|
|
85
|
+
const formData = new FormData()
|
|
86
|
+
formData.append('_method', 'put')
|
|
87
|
+
data && Helpers.appendArray(formData, data)
|
|
88
|
+
return axios().post(u, formData, config)
|
|
89
|
+
},
|
|
90
|
+
async destroy (id: UrlType, config?: AxiosRequestConfig) {
|
|
91
|
+
const u = makeUrl(id)
|
|
92
|
+
return axios().delete(u, config)
|
|
93
|
+
},
|
|
94
|
+
async destroyAll (ids?: UrlType[], config?: AxiosRequestConfig) {
|
|
95
|
+
const u = makeUrl('DestroyAll')
|
|
96
|
+
return axios().post(u, { ids: (ids || []) }, config)
|
|
97
|
+
},
|
|
98
|
+
getUploadAttachmentsUrl: (id: UrlType): string => makeUrl(`${id}/Attachment/Upload`),
|
|
99
|
+
async uploadAttachments (id: UrlType, data: Record<string, any>, config?: AxiosRequestConfig) {
|
|
100
|
+
const _url = makeUrl(`${id}/Attachment/Upload`)
|
|
101
|
+
return axios().post(_url, data, config)
|
|
102
|
+
},
|
|
103
|
+
async deleteAttachment (id: UrlType, fileId: string | number, config?: AxiosRequestConfig) {
|
|
104
|
+
const _url = makeUrl(`${id}/Attachment/${fileId}/Delete`)
|
|
105
|
+
return axios().delete(_url, config)
|
|
106
|
+
},
|
|
107
|
+
async updateAttachment (id: UrlType, fileId: string | number, data: Record<string, any>, config?: AxiosRequestConfig) {
|
|
108
|
+
const _url = makeUrl(`${id}/Attachment/${fileId}/Update`)
|
|
109
|
+
return axios().post(_url, data, config)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
StubUrl: (group?: UrlType): ((segments?: UrlType, parent?: UrlType) => string) => (
|
|
114
|
+
segments?: UrlType,
|
|
115
|
+
parent?: UrlType
|
|
116
|
+
): string => ((parent ?? '') + (parent && group ? '/' : '')) + (group ?? '') + ((group && segments ? '/' : '') + (segments ?? '')),
|
|
117
|
+
findBy (search: any, value: any, column: string | number = 'id') {
|
|
118
|
+
return lodash.find(search, (e: any) => lodash.isPlainObject(e) ? e[column] === value : e === value)
|
|
119
|
+
},
|
|
120
|
+
// queryStringify: (v: never) => new URLSearchParams(qs.stringify(v, {
|
|
121
|
+
// arrayFormat: 'indices'
|
|
122
|
+
// // encodeValuesOnly: true,
|
|
123
|
+
// // encode: false,
|
|
124
|
+
// })),
|
|
125
|
+
/**
|
|
126
|
+
* Open unique window popup of application
|
|
127
|
+
*
|
|
128
|
+
* @param url
|
|
129
|
+
* @param reject
|
|
130
|
+
* @param windowFeatures
|
|
131
|
+
*/
|
|
132
|
+
openWindow<F extends (...args: any[]) => any> (url: string, reject?: F, windowFeatures?: object) {
|
|
133
|
+
return openURL(url, reject, windowFeatures)
|
|
134
|
+
},
|
|
135
|
+
/**
|
|
136
|
+
* Customized helper to download blob from axios response
|
|
137
|
+
* @param response
|
|
138
|
+
* @param callback
|
|
139
|
+
*/
|
|
140
|
+
downloadFromResponse (response: any, callback?: ((url: string, response: any) => void)) {
|
|
141
|
+
return new Promise<DownloadFromResponse>((resolve, reject) => {
|
|
142
|
+
const rejectPromise = (e?: { code: DownloadFromResponseCode }) => reject(e ?? { status: !1, code: 'unknown' })
|
|
143
|
+
const resolvePromise = (response: DownloadFromResponse['response']) => resolve({ status: !0, response })
|
|
144
|
+
try {
|
|
145
|
+
if (!response) {
|
|
146
|
+
rejectPromise({ code: 'no_response' })
|
|
147
|
+
return
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (response?.data?.data?.url) {
|
|
151
|
+
const url = response?.data?.data?.url
|
|
152
|
+
if (callback) {
|
|
153
|
+
callback(url, response)
|
|
154
|
+
resolvePromise(response)
|
|
155
|
+
return
|
|
156
|
+
}
|
|
157
|
+
const elm = document.createElement('a')
|
|
158
|
+
elm.setAttribute('href', url)
|
|
159
|
+
elm.setAttribute('target', '_blank')
|
|
160
|
+
document.body.appendChild(elm)
|
|
161
|
+
elm.click()
|
|
162
|
+
resolvePromise(response)
|
|
163
|
+
return
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const name = (response.headers['content-disposition'] || '').split('filename=').pop().replace(/^"+|"+$/g, '')
|
|
167
|
+
if (!name) {
|
|
168
|
+
rejectPromise({ code: 'no_file_name' })
|
|
169
|
+
return
|
|
170
|
+
}
|
|
171
|
+
const file = new Blob([response.data])
|
|
172
|
+
const fileURL = window.URL.createObjectURL(file)
|
|
173
|
+
const fileLink = document.createElement('a')
|
|
174
|
+
if (!fileLink || !fileURL) {
|
|
175
|
+
rejectPromise({ code: 'no_file_url' })
|
|
176
|
+
return
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
fileLink.href = fileURL
|
|
180
|
+
fileLink.setAttribute('download', name)
|
|
181
|
+
document.body.appendChild(fileLink)
|
|
182
|
+
fileLink.click()
|
|
183
|
+
resolvePromise(response)
|
|
184
|
+
setTimeout(() => {
|
|
185
|
+
try {
|
|
186
|
+
document.body.removeChild(fileLink)
|
|
187
|
+
URL.revokeObjectURL(fileURL)
|
|
188
|
+
} catch (e: any) {
|
|
189
|
+
console.log(e)
|
|
190
|
+
if (e?.message) {
|
|
191
|
+
alert(e.message)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}, 3000)
|
|
195
|
+
} catch (e: any) {
|
|
196
|
+
console.log(e)
|
|
197
|
+
rejectPromise(e)
|
|
198
|
+
}
|
|
199
|
+
})
|
|
200
|
+
},
|
|
201
|
+
async scrollToElement (el: HTMLElement | string, opt?: { target?: HTMLElement | string, duration?: number; }) {
|
|
202
|
+
await nextTick()
|
|
203
|
+
const { getScrollTarget, setVerticalScrollPosition, getVerticalScrollPosition } = scroll
|
|
204
|
+
const scrollTo = typeof el === 'string' ? document.querySelector(el) as HTMLElement : el
|
|
205
|
+
if (!scrollTo) {
|
|
206
|
+
return
|
|
207
|
+
}
|
|
208
|
+
await nextTick()
|
|
209
|
+
const { target: t } = opt || {}
|
|
210
|
+
const targetSelector = typeof t === 'string' ? document.querySelector(t) as HTMLElement : t
|
|
211
|
+
const target = getScrollTarget(scrollTo, targetSelector || window.document.documentElement)
|
|
212
|
+
// console.log(targetSelector, target)
|
|
213
|
+
// let offset = 0
|
|
214
|
+
// try {
|
|
215
|
+
// let parent = scrollTo
|
|
216
|
+
// do {
|
|
217
|
+
// // console.log(parent.getBoundingClientRect().top)
|
|
218
|
+
// offset += parent?.offsetTop || 0
|
|
219
|
+
// parent = parent.offsetParent as HTMLElement
|
|
220
|
+
// } while (parent?.offsetParent)
|
|
221
|
+
// } catch (e) {
|
|
222
|
+
// offset = scrollTo?.offsetTop || 0
|
|
223
|
+
// }
|
|
224
|
+
// offset = scrollTo.getBoundingClientRect().top
|
|
225
|
+
const current = getVerticalScrollPosition(target)
|
|
226
|
+
// console.log(current, target)
|
|
227
|
+
// const offset = scrollTo.getBoundingClientRect().top
|
|
228
|
+
const duration = opt?.duration || 1000
|
|
229
|
+
|
|
230
|
+
let offset = 0
|
|
231
|
+
let parent = scrollTo
|
|
232
|
+
try {
|
|
233
|
+
do {
|
|
234
|
+
offset = parent.getBoundingClientRect().top
|
|
235
|
+
if (offset === 0 && !parent.parentElement) {
|
|
236
|
+
offset = parent.scrollTop
|
|
237
|
+
break
|
|
238
|
+
} else if (offset !== 0 && parent.parentElement) {
|
|
239
|
+
break
|
|
240
|
+
}
|
|
241
|
+
parent = parent.parentElement as HTMLElement
|
|
242
|
+
} while (parent)
|
|
243
|
+
} catch (e) {
|
|
244
|
+
console.log(e)
|
|
245
|
+
offset = scrollTo?.offsetTop || 0
|
|
246
|
+
}
|
|
247
|
+
// console.log(offset, parent, current)
|
|
248
|
+
// const position = offset
|
|
249
|
+
// if (offset > current) {
|
|
250
|
+
// position = (current - offset) + current
|
|
251
|
+
// } else if (offset < current) {
|
|
252
|
+
// position = current + offset
|
|
253
|
+
// }
|
|
254
|
+
// console.log({
|
|
255
|
+
// target,
|
|
256
|
+
// scrollTo,
|
|
257
|
+
// position,
|
|
258
|
+
// offset,
|
|
259
|
+
// current
|
|
260
|
+
// })
|
|
261
|
+
setVerticalScrollPosition(target, (offset + current) - 100, duration)
|
|
262
|
+
},
|
|
263
|
+
async scrollToElementFromErrors (errors?: Partial<Record<string, string[] | string | null | undefined>>, elm?: any, target?: any) {
|
|
264
|
+
if (!errors) {
|
|
265
|
+
return
|
|
266
|
+
}
|
|
267
|
+
for (const [name, value] of Object.entries(errors)) {
|
|
268
|
+
const val = value && Array.isArray(value) ? value[0] : value
|
|
269
|
+
if (val?.toString?.()?.length) {
|
|
270
|
+
if (!elm) {
|
|
271
|
+
const selector = `[data-input-name='${name}']`
|
|
272
|
+
const e = document.querySelector(selector) as HTMLElement
|
|
273
|
+
// console.log(e)
|
|
274
|
+
await this.scrollToElement(e || `[name='${name}']`, { target })
|
|
275
|
+
} else {
|
|
276
|
+
await this.scrollToElement(elm, { target })
|
|
277
|
+
}
|
|
278
|
+
break
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
makeUrl (path: string) {
|
|
283
|
+
path = path || ''
|
|
284
|
+
if (path.slice(0, 1) === '/') {
|
|
285
|
+
path = path.slice(1)
|
|
286
|
+
}
|
|
287
|
+
if (window) {
|
|
288
|
+
const l = window.location
|
|
289
|
+
return `${l.protocol}//${l.host}/${path}`
|
|
290
|
+
}
|
|
291
|
+
return `//${path}`
|
|
292
|
+
}
|
|
293
|
+
}
|