@weconstudio/nuxt 0.0.0-stage → 1.72.0
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/LICENSE +1 -0
- package/README.md +115 -2
- package/dist/module.d.mts +7 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +250 -0
- package/dist/runtime/components/We/Autocomplete.d.vue.ts +13 -0
- package/dist/runtime/components/We/Autocomplete.vue +91 -0
- package/dist/runtime/components/We/Autocomplete.vue.d.ts +13 -0
- package/dist/runtime/components/We/BoldText.d.vue.ts +17 -0
- package/dist/runtime/components/We/BoldText.vue +29 -0
- package/dist/runtime/components/We/BoldText.vue.d.ts +17 -0
- package/dist/runtime/components/We/ColorPicker.d.vue.ts +11 -0
- package/dist/runtime/components/We/ColorPicker.vue +199 -0
- package/dist/runtime/components/We/ColorPicker.vue.d.ts +11 -0
- package/dist/runtime/components/We/ConfirmDialog.d.vue.ts +104 -0
- package/dist/runtime/components/We/ConfirmDialog.vue +143 -0
- package/dist/runtime/components/We/ConfirmDialog.vue.d.ts +104 -0
- package/dist/runtime/components/We/Datatable.d.vue.ts +40 -0
- package/dist/runtime/components/We/Datatable.vue +87 -0
- package/dist/runtime/components/We/Datatable.vue.d.ts +40 -0
- package/dist/runtime/components/We/DatatableInternal.d.vue.ts +194 -0
- package/dist/runtime/components/We/DatatableInternal.vue +638 -0
- package/dist/runtime/components/We/DatatableInternal.vue.d.ts +194 -0
- package/dist/runtime/components/We/DatePicker.d.vue.ts +51 -0
- package/dist/runtime/components/We/DatePicker.vue +901 -0
- package/dist/runtime/components/We/DatePicker.vue.d.ts +51 -0
- package/dist/runtime/components/We/Dt/Actions.d.vue.ts +51 -0
- package/dist/runtime/components/We/Dt/Actions.vue +106 -0
- package/dist/runtime/components/We/Dt/Actions.vue.d.ts +51 -0
- package/dist/runtime/components/We/Dt/BooleanFormatter.d.vue.ts +8 -0
- package/dist/runtime/components/We/Dt/BooleanFormatter.vue +26 -0
- package/dist/runtime/components/We/Dt/BooleanFormatter.vue.d.ts +8 -0
- package/dist/runtime/components/We/Dt/CardFilterContainer.d.vue.ts +17 -0
- package/dist/runtime/components/We/Dt/CardFilterContainer.vue +60 -0
- package/dist/runtime/components/We/Dt/CardFilterContainer.vue.d.ts +17 -0
- package/dist/runtime/components/We/Dt/CheckboxFilter.d.vue.ts +16 -0
- package/dist/runtime/components/We/Dt/CheckboxFilter.vue +47 -0
- package/dist/runtime/components/We/Dt/CheckboxFilter.vue.d.ts +16 -0
- package/dist/runtime/components/We/Dt/ChipGroupSelect.d.vue.ts +7 -0
- package/dist/runtime/components/We/Dt/ChipGroupSelect.vue +35 -0
- package/dist/runtime/components/We/Dt/ChipGroupSelect.vue.d.ts +7 -0
- package/dist/runtime/components/We/Dt/ClusterFilter.d.vue.ts +18 -0
- package/dist/runtime/components/We/Dt/ClusterFilter.vue +68 -0
- package/dist/runtime/components/We/Dt/ClusterFilter.vue.d.ts +18 -0
- package/dist/runtime/components/We/Dt/DatasetFormatter.d.vue.ts +19 -0
- package/dist/runtime/components/We/Dt/DatasetFormatter.vue +65 -0
- package/dist/runtime/components/We/Dt/DatasetFormatter.vue.d.ts +19 -0
- package/dist/runtime/components/We/Dt/DaterangeFilter.d.vue.ts +28 -0
- package/dist/runtime/components/We/Dt/DaterangeFilter.vue +140 -0
- package/dist/runtime/components/We/Dt/DaterangeFilter.vue.d.ts +28 -0
- package/dist/runtime/components/We/Dt/Filter.d.vue.ts +7 -0
- package/dist/runtime/components/We/Dt/Filter.vue +234 -0
- package/dist/runtime/components/We/Dt/Filter.vue.d.ts +7 -0
- package/dist/runtime/components/We/Dt/Filters.d.vue.ts +6 -0
- package/dist/runtime/components/We/Dt/Filters.vue +24 -0
- package/dist/runtime/components/We/Dt/Filters.vue.d.ts +6 -0
- package/dist/runtime/components/We/Dt/LuxonFormatter.d.vue.ts +12 -0
- package/dist/runtime/components/We/Dt/LuxonFormatter.vue +23 -0
- package/dist/runtime/components/We/Dt/LuxonFormatter.vue.d.ts +12 -0
- package/dist/runtime/components/We/Dt/SelectFilter.d.vue.ts +60 -0
- package/dist/runtime/components/We/Dt/SelectFilter.vue +333 -0
- package/dist/runtime/components/We/Dt/SelectFilter.vue.d.ts +60 -0
- package/dist/runtime/components/We/Dt/SelectResourceFilter.d.vue.ts +43 -0
- package/dist/runtime/components/We/Dt/SelectResourceFilter.vue +127 -0
- package/dist/runtime/components/We/Dt/SelectResourceFilter.vue.d.ts +43 -0
- package/dist/runtime/components/We/Dt/dt.types.d.ts +8 -0
- package/dist/runtime/components/We/EndpointSwitcher.d.vue.ts +12 -0
- package/dist/runtime/components/We/EndpointSwitcher.vue +256 -0
- package/dist/runtime/components/We/EndpointSwitcher.vue.d.ts +12 -0
- package/dist/runtime/components/We/Import.d.vue.ts +118 -0
- package/dist/runtime/components/We/Import.vue +730 -0
- package/dist/runtime/components/We/Import.vue.d.ts +118 -0
- package/dist/runtime/components/We/ImportDefaultValues.d.vue.ts +3666 -0
- package/dist/runtime/components/We/ImportDefaultValues.vue +115 -0
- package/dist/runtime/components/We/ImportDefaultValues.vue.d.ts +3666 -0
- package/dist/runtime/components/We/ImportMatchColumns.d.vue.ts +66 -0
- package/dist/runtime/components/We/ImportMatchColumns.vue +172 -0
- package/dist/runtime/components/We/ImportMatchColumns.vue.d.ts +66 -0
- package/dist/runtime/components/We/ImportPreviewResults.d.vue.ts +38 -0
- package/dist/runtime/components/We/ImportPreviewResults.vue +165 -0
- package/dist/runtime/components/We/ImportPreviewResults.vue.d.ts +38 -0
- package/dist/runtime/components/We/ImportSelectStart.d.vue.ts +47 -0
- package/dist/runtime/components/We/ImportSelectStart.vue +106 -0
- package/dist/runtime/components/We/ImportSelectStart.vue.d.ts +47 -0
- package/dist/runtime/components/We/Notification.d.vue.ts +7 -0
- package/dist/runtime/components/We/Notification.vue +49 -0
- package/dist/runtime/components/We/Notification.vue.d.ts +7 -0
- package/dist/runtime/components/We/S3Dropzone.d.vue.ts +17 -0
- package/dist/runtime/components/We/S3Dropzone.vue +527 -0
- package/dist/runtime/components/We/S3Dropzone.vue.d.ts +17 -0
- package/dist/runtime/components/We/Select.d.vue.ts +39 -0
- package/dist/runtime/components/We/Select.vue +354 -0
- package/dist/runtime/components/We/Select.vue.d.ts +39 -0
- package/dist/runtime/components/We/TipTap.d.vue.ts +26 -0
- package/dist/runtime/components/We/TipTap.vue +362 -0
- package/dist/runtime/components/We/TipTap.vue.d.ts +26 -0
- package/dist/runtime/components/We/datatable.props.d.ts +57 -0
- package/dist/runtime/components/We/datatable.props.js +60 -0
- package/dist/runtime/composables/datatable/useAutoFillHeight.d.ts +31 -0
- package/dist/runtime/composables/datatable/useAutoFillHeight.js +57 -0
- package/dist/runtime/composables/datatable/useDataTable.d.ts +33 -0
- package/dist/runtime/composables/datatable/useDataTable.js +161 -0
- package/dist/runtime/composables/datatable/useDatatableColumns.d.ts +12 -0
- package/dist/runtime/composables/datatable/useDatatableColumns.js +96 -0
- package/dist/runtime/composables/useApi.d.ts +56 -0
- package/dist/runtime/composables/useApi.js +230 -0
- package/dist/runtime/composables/useApiFetch.d.ts +2 -0
- package/dist/runtime/composables/useApiFetch.js +9 -0
- package/dist/runtime/composables/useApiUrl.d.ts +10 -0
- package/dist/runtime/composables/useApiUrl.js +37 -0
- package/dist/runtime/composables/useAuth.d.ts +9 -0
- package/dist/runtime/composables/useAuth.js +22 -0
- package/dist/runtime/composables/useBus.d.ts +8 -0
- package/dist/runtime/composables/useBus.js +18 -0
- package/dist/runtime/composables/useDateRangePresets.d.ts +21 -0
- package/dist/runtime/composables/useDateRangePresets.js +90 -0
- package/dist/runtime/composables/useForm.d.ts +29 -0
- package/dist/runtime/composables/useForm.js +74 -0
- package/dist/runtime/composables/useFormLock.d.ts +11 -0
- package/dist/runtime/composables/useFormLock.js +8 -0
- package/dist/runtime/composables/useFormWrapper.d.ts +16 -0
- package/dist/runtime/composables/useFormWrapper.js +36 -0
- package/dist/runtime/composables/useImportJob.d.ts +55 -0
- package/dist/runtime/composables/useImportJob.js +94 -0
- package/dist/runtime/composables/useLux.d.ts +1 -0
- package/dist/runtime/composables/useLux.js +8 -0
- package/dist/runtime/composables/useNotify.d.ts +12 -0
- package/dist/runtime/composables/useNotify.js +24 -0
- package/dist/runtime/composables/usePaginatedFetch.d.ts +24 -0
- package/dist/runtime/composables/usePaginatedFetch.js +154 -0
- package/dist/runtime/composables/useServerErrors.d.ts +16 -0
- package/dist/runtime/composables/useServerErrors.js +60 -0
- package/dist/runtime/composables/useValidators.d.ts +18 -0
- package/dist/runtime/composables/useValidators.js +56 -0
- package/dist/runtime/generator/code/dt.d.ts +8 -0
- package/dist/runtime/generator/code/dt.js +97 -0
- package/dist/runtime/generator/code/edit.d.ts +4 -0
- package/dist/runtime/generator/code/edit.js +41 -0
- package/dist/runtime/generator/code/form.d.ts +6 -0
- package/dist/runtime/generator/code/form.js +229 -0
- package/dist/runtime/generator/code/i18n.d.ts +5 -0
- package/dist/runtime/generator/code/i18n.js +43 -0
- package/dist/runtime/generator/code/index.d.ts +11 -0
- package/dist/runtime/generator/code/index.js +90 -0
- package/dist/runtime/generator/components/CodeSnippet.d.vue.ts +14 -0
- package/dist/runtime/generator/components/CodeSnippet.vue +49 -0
- package/dist/runtime/generator/components/CodeSnippet.vue.d.ts +14 -0
- package/dist/runtime/generator/components/Configuration.d.vue.ts +16 -0
- package/dist/runtime/generator/components/Configuration.vue +154 -0
- package/dist/runtime/generator/components/Configuration.vue.d.ts +16 -0
- package/dist/runtime/generator/components/GeneratorPage.d.vue.ts +50 -0
- package/dist/runtime/generator/components/GeneratorPage.vue +226 -0
- package/dist/runtime/generator/components/GeneratorPage.vue.d.ts +50 -0
- package/dist/runtime/generator/fs.d.ts +16 -0
- package/dist/runtime/generator/fs.js +79 -0
- package/dist/runtime/generator/index.d.vue.ts +52 -0
- package/dist/runtime/generator/index.vue +17 -0
- package/dist/runtime/generator/index.vue.d.ts +52 -0
- package/dist/runtime/internals/api.d.ts +3 -0
- package/dist/runtime/internals/api.js +16 -0
- package/dist/runtime/internals/bus.d.ts +1 -0
- package/dist/runtime/internals/bus.js +2 -0
- package/dist/runtime/internals/dt.d.ts +24 -0
- package/dist/runtime/internals/dt.js +57 -0
- package/dist/runtime/lang/en.json +211 -0
- package/dist/runtime/lang/it.json +211 -0
- package/dist/runtime/mixins/formValidator.d.ts +38 -0
- package/dist/runtime/mixins/formValidator.js +118 -0
- package/dist/runtime/plugins/api-legacy.d.ts +76 -0
- package/dist/runtime/plugins/api-legacy.js +11 -0
- package/dist/runtime/plugins/auth-legacy.d.ts +22 -0
- package/dist/runtime/plugins/auth-legacy.js +14 -0
- package/dist/runtime/plugins/bus-legacy.d.ts +6 -0
- package/dist/runtime/plugins/bus-legacy.js +9 -0
- package/dist/runtime/plugins/notify-legacy.d.ts +25 -0
- package/dist/runtime/plugins/notify-legacy.js +35 -0
- package/dist/runtime/plugins/portal.d.ts +2 -0
- package/dist/runtime/plugins/portal.js +5 -0
- package/dist/runtime/plugins/update-sanctum-app-config.d.ts +2 -0
- package/dist/runtime/plugins/update-sanctum-app-config.js +44 -0
- package/dist/runtime/plugins/vuetify-nuxt-icon.d.ts +4 -0
- package/dist/runtime/plugins/vuetify-nuxt-icon.js +30 -0
- package/dist/runtime/types/app-config.d.ts +24 -0
- package/dist/runtime/types/app-config.js +1 -0
- package/dist/runtime/types/icons.d.ts +82 -0
- package/dist/runtime/types/icons.js +84 -0
- package/dist/runtime/types/index.d.ts +2 -0
- package/dist/runtime/types/index.js +2 -0
- package/dist/runtime/types/module-options.d.ts +29 -0
- package/dist/runtime/types/module-options.js +0 -0
- package/dist/runtime/types/runtime-hooks.d.ts +17 -0
- package/dist/runtime/types/runtime-hooks.js +1 -0
- package/dist/runtime/utils/color.d.ts +10 -0
- package/dist/runtime/utils/color.js +38 -0
- package/dist/runtime/utils/file.d.ts +17 -0
- package/dist/runtime/utils/file.js +108 -0
- package/dist/runtime/utils/format.d.ts +1 -0
- package/dist/runtime/utils/format.js +14 -0
- package/dist/runtime/utils/make-enum.d.ts +15 -0
- package/dist/runtime/utils/make-enum.js +27 -0
- package/dist/runtime/utils/mergeDefaults.d.ts +1 -0
- package/dist/runtime/utils/mergeDefaults.js +18 -0
- package/dist/runtime/utils/object-to-formdata.d.ts +10 -0
- package/dist/runtime/utils/object-to-formdata.js +82 -0
- package/dist/runtime/utils/uuid.d.ts +1 -0
- package/dist/runtime/utils/uuid.js +9 -0
- package/dist/types.d.mts +9 -0
- package/package.json +92 -4
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface WeNuxtModuleOptions {
|
|
2
|
+
host: string;
|
|
3
|
+
bus: {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
optionsApi: boolean;
|
|
6
|
+
};
|
|
7
|
+
notify: {
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
css: boolean | string[];
|
|
10
|
+
optionsApi: boolean;
|
|
11
|
+
};
|
|
12
|
+
portal: {
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
};
|
|
15
|
+
form: {
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
formValidatorMixin: boolean;
|
|
18
|
+
};
|
|
19
|
+
api: {
|
|
20
|
+
baseUrl?: string;
|
|
21
|
+
endpoints?: string[];
|
|
22
|
+
apiSuffix?: string;
|
|
23
|
+
cache?: {
|
|
24
|
+
ttl: number;
|
|
25
|
+
max: number;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
gen: boolean;
|
|
29
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { HookResult } from '@nuxt/schema';
|
|
2
|
+
import type { FetchContext, FetchResponse } from 'ofetch';
|
|
3
|
+
declare module '#app' {
|
|
4
|
+
interface RuntimeNuxtHooks {
|
|
5
|
+
'we-api:onRequest': (options: FetchContext) => HookResult;
|
|
6
|
+
'we-api:onRequestError': (error: FetchContext & {
|
|
7
|
+
error: Error;
|
|
8
|
+
}) => HookResult;
|
|
9
|
+
'we-api:onResponseError': (error: FetchContext & {
|
|
10
|
+
response: FetchResponse<any>;
|
|
11
|
+
}) => HookResult;
|
|
12
|
+
'we-api:onResponse': (response: FetchContext & {
|
|
13
|
+
response: FetchResponse<any>;
|
|
14
|
+
}) => HookResult;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Luminanza relativa WCAG (0 = nero, 1 = bianco), o `null` se il colore non è parsabile
|
|
3
|
+
* — i colori con nome CSS (`rebeccapurple`) richiederebbero il DOM.
|
|
4
|
+
*/
|
|
5
|
+
export declare function relativeLuminance(color: string): number | null;
|
|
6
|
+
/**
|
|
7
|
+
* Colore da usare per il testo scritto sopra `color`: `#000` sui colori chiari, `#fff`
|
|
8
|
+
* sugli scuri. Se il colore non è parsabile ritorna `fallback`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function textColorOn(color: string, fallback?: string): string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const HEX_RE = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
2
|
+
const RGB_RE = /^rgba?\(\s*(\d+(?:\.\d+)?)[\s,]+(\d+(?:\.\d+)?)[\s,]+(\d+(?:\.\d+)?)/i;
|
|
3
|
+
const LIGHT_THRESHOLD = 0.4;
|
|
4
|
+
function parseColor(color) {
|
|
5
|
+
const value = color.trim();
|
|
6
|
+
if (HEX_RE.test(value)) {
|
|
7
|
+
const hex = value.slice(1);
|
|
8
|
+
const step = hex.length <= 4 ? 1 : 2;
|
|
9
|
+
const at = (i) => {
|
|
10
|
+
const part = hex.slice(i * step, i * step + step);
|
|
11
|
+
return Number.parseInt(step === 1 ? part + part : part, 16);
|
|
12
|
+
};
|
|
13
|
+
return { r: at(0), g: at(1), b: at(2) };
|
|
14
|
+
}
|
|
15
|
+
const rgb = RGB_RE.exec(value);
|
|
16
|
+
if (rgb) {
|
|
17
|
+
return { r: Number(rgb[1]), g: Number(rgb[2]), b: Number(rgb[3]) };
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
export function relativeLuminance(color) {
|
|
22
|
+
const rgb = parseColor(color);
|
|
23
|
+
if (!rgb) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const channel = (value) => {
|
|
27
|
+
const v = Math.min(Math.max(value, 0), 255) / 255;
|
|
28
|
+
return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
|
|
29
|
+
};
|
|
30
|
+
return 0.2126 * channel(rgb.r) + 0.7152 * channel(rgb.g) + 0.0722 * channel(rgb.b);
|
|
31
|
+
}
|
|
32
|
+
export function textColorOn(color, fallback = "#fff") {
|
|
33
|
+
const luminance = relativeLuminance(color);
|
|
34
|
+
if (luminance === null) {
|
|
35
|
+
return fallback;
|
|
36
|
+
}
|
|
37
|
+
return luminance > LIGHT_THRESHOLD ? "#000" : "#fff";
|
|
38
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type FileTypeCategory = 'image' | 'audio' | 'video' | 'pdf' | 'document' | 'text' | 'archive' | 'code' | 'application' | 'excel' | 'powerPoint' | 'csv';
|
|
2
|
+
export declare const extensions: {
|
|
3
|
+
value: string;
|
|
4
|
+
type: FileTypeCategory;
|
|
5
|
+
}[];
|
|
6
|
+
export declare const fileTypeMap: Record<FileTypeCategory, {
|
|
7
|
+
icon: string;
|
|
8
|
+
color: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function getFileUrlExtension(url: string): string;
|
|
11
|
+
export declare function getExtensionType(ext: string): FileTypeCategory;
|
|
12
|
+
export declare function getFileType(file: File | string | Record<string, any>): string;
|
|
13
|
+
export declare function getFileName(file: File | string | Record<string, any>): string;
|
|
14
|
+
export declare function getFileCategory(file: File | string | Record<string, any>): {
|
|
15
|
+
icon: string;
|
|
16
|
+
color: string;
|
|
17
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
export const extensions = [
|
|
2
|
+
// Image
|
|
3
|
+
{ value: "jpg", type: "image" },
|
|
4
|
+
{ value: "jpeg", type: "image" },
|
|
5
|
+
{ value: "png", type: "image" },
|
|
6
|
+
{ value: "gif", type: "image" },
|
|
7
|
+
{ value: "tiff", type: "image" },
|
|
8
|
+
{ value: "webp", type: "image" },
|
|
9
|
+
{ value: "svg", type: "image" },
|
|
10
|
+
// Audio
|
|
11
|
+
{ value: "m4a", type: "audio" },
|
|
12
|
+
{ value: "flac", type: "audio" },
|
|
13
|
+
{ value: "mp3", type: "audio" },
|
|
14
|
+
{ value: "wav", type: "audio" },
|
|
15
|
+
{ value: "wma", type: "audio" },
|
|
16
|
+
{ value: "aac", type: "audio" },
|
|
17
|
+
{ value: "ogg", type: "audio" },
|
|
18
|
+
// Video
|
|
19
|
+
{ value: "mp4", type: "video" },
|
|
20
|
+
{ value: "mov", type: "video" },
|
|
21
|
+
{ value: "wmv", type: "video" },
|
|
22
|
+
{ value: "avi", type: "video" },
|
|
23
|
+
{ value: "mkv", type: "video" },
|
|
24
|
+
{ value: "webm", type: "video" },
|
|
25
|
+
// Excel
|
|
26
|
+
{ value: "xls", type: "excel" },
|
|
27
|
+
{ value: "xlsx", type: "excel" },
|
|
28
|
+
// Word
|
|
29
|
+
{ value: "doc", type: "document" },
|
|
30
|
+
{ value: "docx", type: "document" },
|
|
31
|
+
// Pdf
|
|
32
|
+
{ value: "pdf", type: "pdf" },
|
|
33
|
+
// PowerPoint
|
|
34
|
+
{ value: "ppt", type: "powerPoint" },
|
|
35
|
+
{ value: "pptx", type: "powerPoint" },
|
|
36
|
+
// Csv
|
|
37
|
+
{ value: "csv", type: "csv" },
|
|
38
|
+
// Text
|
|
39
|
+
{ value: "txt", type: "text" },
|
|
40
|
+
{ value: "md", type: "text" },
|
|
41
|
+
// Archive
|
|
42
|
+
{ value: "zip", type: "archive" },
|
|
43
|
+
{ value: "rar", type: "archive" },
|
|
44
|
+
{ value: "7z", type: "archive" },
|
|
45
|
+
{ value: "tar", type: "archive" },
|
|
46
|
+
{ value: "gz", type: "archive" },
|
|
47
|
+
// Code
|
|
48
|
+
{ value: "js", type: "code" },
|
|
49
|
+
{ value: "ts", type: "code" },
|
|
50
|
+
{ value: "json", type: "code" },
|
|
51
|
+
{ value: "html", type: "code" },
|
|
52
|
+
{ value: "css", type: "code" },
|
|
53
|
+
{ value: "py", type: "code" },
|
|
54
|
+
{ value: "java", type: "code" },
|
|
55
|
+
{ value: "cpp", type: "code" },
|
|
56
|
+
{ value: "c", type: "code" },
|
|
57
|
+
{ value: "php", type: "code" },
|
|
58
|
+
{ value: "sql", type: "code" }
|
|
59
|
+
];
|
|
60
|
+
export const fileTypeMap = {
|
|
61
|
+
image: { icon: "mdi-file-image", color: "#87CEEB" },
|
|
62
|
+
audio: { icon: "mdi-music", color: "#673AB7" },
|
|
63
|
+
video: { icon: "mdi-filmstrip", color: "#3F51B5" },
|
|
64
|
+
pdf: { icon: "mdi-file-pdf-box", color: "#FF0000" },
|
|
65
|
+
text: { icon: "mdi-file-document-outline", color: "#795548" },
|
|
66
|
+
document: { icon: "mdi-file-document", color: "#0000FF" },
|
|
67
|
+
archive: { icon: "mdi-folder-zip", color: "#607D8B" },
|
|
68
|
+
code: { icon: "mdi-code-json", color: "#9C27B0" },
|
|
69
|
+
excel: { icon: "mdi-file-excel", color: "#008000" },
|
|
70
|
+
csv: { icon: "mdi-file-excel", color: "#008000" },
|
|
71
|
+
powerPoint: { icon: "mdi-file-powerpoint", color: "#ED6C47" },
|
|
72
|
+
application: { icon: "mdi-file", color: "#009688" }
|
|
73
|
+
};
|
|
74
|
+
export function getFileUrlExtension(url) {
|
|
75
|
+
return url?.split(/[#?]/)[0]?.split(".").pop()?.trim().toLowerCase() || "";
|
|
76
|
+
}
|
|
77
|
+
export function getExtensionType(ext) {
|
|
78
|
+
const found = extensions.find((e) => e.value === ext.toLowerCase());
|
|
79
|
+
return found ? found.type : "application";
|
|
80
|
+
}
|
|
81
|
+
export function getFileType(file) {
|
|
82
|
+
if (file instanceof File) {
|
|
83
|
+
return file.type || `application/${getFileUrlExtension(getFileName(file))}`;
|
|
84
|
+
}
|
|
85
|
+
if (typeof file === "object") {
|
|
86
|
+
const ext = file.extension || getFileUrlExtension(getFileName(file));
|
|
87
|
+
return `${getExtensionType(ext)}/${ext}`;
|
|
88
|
+
}
|
|
89
|
+
if (typeof file === "string") {
|
|
90
|
+
const ext = getFileUrlExtension(file);
|
|
91
|
+
return `${getExtensionType(ext)}/${ext}`;
|
|
92
|
+
}
|
|
93
|
+
return "application/octet-stream";
|
|
94
|
+
}
|
|
95
|
+
export function getFileName(file) {
|
|
96
|
+
if (typeof file === "object") {
|
|
97
|
+
return file.name || file.file_name || file.filename || file.url || "";
|
|
98
|
+
}
|
|
99
|
+
if (typeof file === "string") {
|
|
100
|
+
return file.split(/[#?]/)[0].split("/").pop()?.trim() || "";
|
|
101
|
+
}
|
|
102
|
+
return "";
|
|
103
|
+
}
|
|
104
|
+
export function getFileCategory(file) {
|
|
105
|
+
const type = getFileType(file);
|
|
106
|
+
const category = type.split("/")[0];
|
|
107
|
+
return fileTypeMap[category] || fileTypeMap.application;
|
|
108
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function humanFileSize(bytes: number, si?: boolean, dp?: number): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function humanFileSize(bytes, si = false, dp = 1) {
|
|
2
|
+
const thresh = si ? 1e3 : 1024;
|
|
3
|
+
if (Math.abs(bytes) < thresh) {
|
|
4
|
+
return `${bytes} B`;
|
|
5
|
+
}
|
|
6
|
+
const units = si ? ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] : ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
|
|
7
|
+
let u = -1;
|
|
8
|
+
const r = 10 ** dp;
|
|
9
|
+
do {
|
|
10
|
+
bytes /= thresh;
|
|
11
|
+
++u;
|
|
12
|
+
} while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1);
|
|
13
|
+
return `${bytes.toFixed(dp)} ${units[u]}`;
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface BaseEnumConfig {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
}
|
|
4
|
+
type EnumConfig = Record<string, BaseEnumConfig>;
|
|
5
|
+
type EnumItem<T extends BaseEnumConfig> = T & {
|
|
6
|
+
value: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function makeEnum<T extends EnumConfig>(config: T): {
|
|
9
|
+
Keys: Record<keyof T & string, keyof T & string>;
|
|
10
|
+
Values: T;
|
|
11
|
+
get: (key: keyof T & string) => EnumItem<T[keyof T & string]>;
|
|
12
|
+
getAll: () => EnumItem<T[keyof T & string]>[];
|
|
13
|
+
getByValue: (value: keyof T & string) => EnumItem<T[keyof T & string]> | undefined;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function makeEnum(config) {
|
|
2
|
+
const Keys = Object.keys(config).reduce((acc, key) => {
|
|
3
|
+
acc[key] = key;
|
|
4
|
+
return acc;
|
|
5
|
+
}, {});
|
|
6
|
+
const Values = config;
|
|
7
|
+
function get(key) {
|
|
8
|
+
return {
|
|
9
|
+
value: key,
|
|
10
|
+
...config[key]
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function getAll() {
|
|
14
|
+
return Object.keys(config).map((key) => get(key));
|
|
15
|
+
}
|
|
16
|
+
function getByValue(value) {
|
|
17
|
+
const key = value;
|
|
18
|
+
return config[key] ? get(key) : void 0;
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
Keys,
|
|
22
|
+
Values,
|
|
23
|
+
get,
|
|
24
|
+
getAll,
|
|
25
|
+
getByValue
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mergeDefaults(obj: any, ...defaults: any[]): any;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createDefu } from "defu";
|
|
2
|
+
import { cloneDeep } from "es-toolkit/object";
|
|
3
|
+
function isObject(obj) {
|
|
4
|
+
return obj !== null && typeof obj === "object";
|
|
5
|
+
}
|
|
6
|
+
const merger = createDefu((obj, key, value) => {
|
|
7
|
+
if (Array.isArray(obj[key]) && Array.isArray(value)) {
|
|
8
|
+
obj[key] = [...value];
|
|
9
|
+
return true;
|
|
10
|
+
} else if (isObject(obj[key]) && isObject(value)) {
|
|
11
|
+
obj[key] = merger(value, obj[key]);
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return !(key in obj);
|
|
15
|
+
});
|
|
16
|
+
export function mergeDefaults(obj, ...defaults) {
|
|
17
|
+
return merger(obj, ...cloneDeep(defaults));
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface Options {
|
|
2
|
+
indices?: boolean;
|
|
3
|
+
nullsAsUndefineds?: boolean;
|
|
4
|
+
booleansAsIntegers?: boolean;
|
|
5
|
+
allowEmptyArrays?: boolean;
|
|
6
|
+
noAttributesWithArrayNotation?: boolean;
|
|
7
|
+
noFilesWithArrayNotation?: boolean;
|
|
8
|
+
dotsForObjectNotation?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function objectToFormData<T>(obj: T, cfg?: Options, fd?: FormData, pre?: string): FormData;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
function isUndefined(value) {
|
|
2
|
+
return value === void 0;
|
|
3
|
+
}
|
|
4
|
+
function isNull(value) {
|
|
5
|
+
return value === null;
|
|
6
|
+
}
|
|
7
|
+
function isBoolean(value) {
|
|
8
|
+
return typeof value === "boolean";
|
|
9
|
+
}
|
|
10
|
+
function isObject(value) {
|
|
11
|
+
return value === Object(value);
|
|
12
|
+
}
|
|
13
|
+
function isArray(value) {
|
|
14
|
+
return Array.isArray(value);
|
|
15
|
+
}
|
|
16
|
+
function isDate(value) {
|
|
17
|
+
return value instanceof Date;
|
|
18
|
+
}
|
|
19
|
+
function isBlob(value, isReactNative) {
|
|
20
|
+
return isReactNative ? isObject(value) && !isUndefined(value.uri) : isObject(value) && typeof value.size === "number" && typeof value.type === "string" && typeof value.slice === "function";
|
|
21
|
+
}
|
|
22
|
+
function isFile(value, isReactNative) {
|
|
23
|
+
return isBlob(value, isReactNative) && typeof value.name === "string" && (isObject(value.lastModifiedDate) || typeof value.lastModified === "number");
|
|
24
|
+
}
|
|
25
|
+
function initCfg(value) {
|
|
26
|
+
return isUndefined(value) ? false : value;
|
|
27
|
+
}
|
|
28
|
+
export function objectToFormData(obj, cfg, fd, pre) {
|
|
29
|
+
cfg = cfg || {};
|
|
30
|
+
fd = fd || new FormData();
|
|
31
|
+
cfg.indices = initCfg(cfg.indices);
|
|
32
|
+
cfg.nullsAsUndefineds = initCfg(cfg.nullsAsUndefineds);
|
|
33
|
+
cfg.booleansAsIntegers = initCfg(cfg.booleansAsIntegers);
|
|
34
|
+
cfg.allowEmptyArrays = initCfg(cfg.allowEmptyArrays);
|
|
35
|
+
cfg.noAttributesWithArrayNotation = initCfg(
|
|
36
|
+
cfg.noAttributesWithArrayNotation
|
|
37
|
+
);
|
|
38
|
+
cfg.noFilesWithArrayNotation = initCfg(cfg.noFilesWithArrayNotation);
|
|
39
|
+
cfg.dotsForObjectNotation = initCfg(cfg.dotsForObjectNotation);
|
|
40
|
+
const isReactNative = typeof fd.getParts === "function";
|
|
41
|
+
if (isUndefined(obj)) {
|
|
42
|
+
return fd;
|
|
43
|
+
} else if (isNull(obj)) {
|
|
44
|
+
if (!cfg.nullsAsUndefineds) {
|
|
45
|
+
fd.append(pre, "");
|
|
46
|
+
}
|
|
47
|
+
} else if (isBoolean(obj)) {
|
|
48
|
+
if (cfg.booleansAsIntegers) {
|
|
49
|
+
fd.append(pre, obj ? 1 : 0);
|
|
50
|
+
} else {
|
|
51
|
+
fd.append(pre, obj);
|
|
52
|
+
}
|
|
53
|
+
} else if (isArray(obj)) {
|
|
54
|
+
if (obj.length) {
|
|
55
|
+
obj.forEach((value, index) => {
|
|
56
|
+
let key = `${pre}[${cfg.indices ? index : ""}]`;
|
|
57
|
+
if (cfg.noAttributesWithArrayNotation || cfg.noFilesWithArrayNotation && isFile(value, isReactNative)) {
|
|
58
|
+
key = pre;
|
|
59
|
+
}
|
|
60
|
+
objectToFormData(value, cfg, fd, key);
|
|
61
|
+
});
|
|
62
|
+
} else if (cfg.allowEmptyArrays) {
|
|
63
|
+
fd.append(cfg.noAttributesWithArrayNotation ? pre : `${pre}[]`, "");
|
|
64
|
+
}
|
|
65
|
+
} else if (isDate(obj)) {
|
|
66
|
+
fd.append(pre, obj.toISOString());
|
|
67
|
+
} else if (isObject(obj) && !isBlob(obj, isReactNative)) {
|
|
68
|
+
Object.keys(obj).forEach((prop) => {
|
|
69
|
+
const value = obj[prop];
|
|
70
|
+
if (isArray(value)) {
|
|
71
|
+
while (prop.length > 2 && prop.lastIndexOf("[]") === prop.length - 2) {
|
|
72
|
+
prop = prop.substring(0, prop.length - 2);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const key = pre ? cfg.dotsForObjectNotation ? `${pre}.${prop}` : `${pre}[${prop}]` : prop;
|
|
76
|
+
objectToFormData(value, cfg, fd, key);
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
fd.append(pre, obj);
|
|
80
|
+
}
|
|
81
|
+
return fd;
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generateUUID(): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function generateUUID() {
|
|
2
|
+
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
3
|
+
return crypto.randomUUID();
|
|
4
|
+
}
|
|
5
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
6
|
+
const r = Math.random() * 16 | 0;
|
|
7
|
+
return (c === "x" ? r : r & 3 | 8).toString(16);
|
|
8
|
+
});
|
|
9
|
+
}
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NuxtModule } from '@nuxt/schema'
|
|
2
|
+
|
|
3
|
+
import type { default as Module } from './module.mjs'
|
|
4
|
+
|
|
5
|
+
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
|
+
|
|
7
|
+
export { default } from './module.mjs'
|
|
8
|
+
|
|
9
|
+
export * from '../dist/runtime/types/index.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,94 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weconstudio/nuxt",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.72.0",
|
|
5
|
+
"packageManager": "pnpm@12.14.0",
|
|
6
|
+
"description": "Nuxt module base dei frontend Weconstudio",
|
|
7
|
+
"license": "UNLICENSED",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/weconstudio/nuxt.git"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/types.d.mts",
|
|
18
|
+
"import": "./dist/module.mjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"main": "./dist/module.mjs",
|
|
22
|
+
"typesVersions": {
|
|
23
|
+
"*": {
|
|
24
|
+
".": [
|
|
25
|
+
"./dist/types.d.mts"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"prepack": "nuxt-module-build build",
|
|
34
|
+
"dev": "pnpm --dir playground dev",
|
|
35
|
+
"dev:build": "nuxt build playground",
|
|
36
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && cd playground && nuxt prepare",
|
|
37
|
+
"lint": "eslint .",
|
|
38
|
+
"test": "vitest run",
|
|
39
|
+
"test:watch": "vitest watch",
|
|
40
|
+
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
41
|
+
"vuetify:lang": "node scripts/lang.mjs"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@nuxt/icon": "^1.15.0",
|
|
45
|
+
"@nuxt/kit": "^3.17.4",
|
|
46
|
+
"@nuxtjs/i18n": "^10.6.0",
|
|
47
|
+
"@tiptap/extensions": "^3.32.2",
|
|
48
|
+
"@tiptap/pm": "^3.32.2",
|
|
49
|
+
"@tiptap/starter-kit": "^3.32.2",
|
|
50
|
+
"@tiptap/vue-3": "^3.32.2",
|
|
51
|
+
"@vuepic/vue-datepicker": "^11.0.2",
|
|
52
|
+
"@vueuse/nuxt": "^11.3.0",
|
|
53
|
+
"consola": "^3.3.3",
|
|
54
|
+
"defu": "^6.1.4",
|
|
55
|
+
"es-toolkit": "^1.42.0",
|
|
56
|
+
"file-saver-es": "^2.0.5",
|
|
57
|
+
"lru-cache": "^11.0.2",
|
|
58
|
+
"mitt": "^3.0.1",
|
|
59
|
+
"notivue": "^2.4.5",
|
|
60
|
+
"nuxt-auth-sanctum": "^1.4.3",
|
|
61
|
+
"nuxt-eslint-auto-explicit-import": "^0.1.1",
|
|
62
|
+
"ofetch": "^1.4.1",
|
|
63
|
+
"portal-vue": "^3.0.0",
|
|
64
|
+
"rollup-plugin-sbom": "^5.0.1",
|
|
65
|
+
"vue-lux": "^1.2.2",
|
|
66
|
+
"vuetify": "^3.12.4",
|
|
67
|
+
"vuetify-nuxt-module": "^0.19.2"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@antfu/eslint-config": "^5.2.1",
|
|
71
|
+
"@intlify/eslint-plugin-vue-i18n": "^4.1.0",
|
|
72
|
+
"@nuxt/cli": "^3.34.0",
|
|
73
|
+
"@nuxt/devtools": "^1.6.0",
|
|
74
|
+
"@nuxt/eslint": "^1.9.0",
|
|
75
|
+
"@nuxt/eslint-config": "^0.6.1",
|
|
76
|
+
"@nuxt/module-builder": "^1.0.1",
|
|
77
|
+
"@nuxt/schema": "^3.17.4",
|
|
78
|
+
"@nuxt/test-utils": "^3.19.0",
|
|
79
|
+
"@types/file-saver-es": "^2.0.3",
|
|
80
|
+
"@types/luxon": "^3.7.1",
|
|
81
|
+
"@types/node": "^22.15.21",
|
|
82
|
+
"eslint": "^9.14.0",
|
|
83
|
+
"eslint-plugin-format": "^1.0.1",
|
|
84
|
+
"eslint-plugin-vuetify": "^2.5.2",
|
|
85
|
+
"nuxi": "^3.25.1",
|
|
86
|
+
"nuxt": "^4.1.0",
|
|
87
|
+
"sass": "^1.89.0",
|
|
88
|
+
"sass-embedded": "^1.89.0",
|
|
89
|
+
"scss": "^0.2.4",
|
|
90
|
+
"typescript": "^5.7.2",
|
|
91
|
+
"vitest": "^4.0.15",
|
|
92
|
+
"vue-tsc": "^2.1.10"
|
|
93
|
+
}
|
|
94
|
+
}
|