@mframework/ui 0.1.0-beta.0 → 0.1.0-beta.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/dist/adapters/adapter-directus/src/types/ui.d.ts +21 -0
- package/dist/adapters/adapter-directus/src/types/ui.js +1 -0
- package/dist/module.d.mts +9 -0
- package/dist/module.d.ts +6 -0
- package/dist/module.js +68 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +38 -0
- package/dist/modules/ui/src/module.d.ts +8 -0
- package/dist/modules/ui/src/module.js +75 -0
- package/dist/modules/ui/src/runtime/composables/useMToast.d.ts +5 -0
- package/dist/modules/ui/src/runtime/composables/useMToast.js +11 -0
- package/dist/modules/ui/src/runtime/design/tokens.d.ts +22 -0
- package/dist/modules/ui/src/runtime/design/tokens.js +22 -0
- package/dist/modules/ui/src/runtime/plugins/builder.d.ts +3 -0
- package/dist/modules/ui/src/runtime/plugins/builder.js +311 -0
- package/dist/modules/ui/src/runtime/plugins/fontawesome.d.ts +3 -0
- package/dist/modules/ui/src/runtime/plugins/fontawesome.js +9 -0
- package/dist/modules/ui/src/runtime/plugins/formkit.d.ts +3 -0
- package/dist/modules/ui/src/runtime/plugins/formkit.js +8 -0
- package/dist/modules/ui/src/runtime/plugins/motion.d.ts +2 -0
- package/dist/modules/ui/src/runtime/plugins/motion.js +5 -0
- package/dist/modules/ui/src/runtime/plugins/theme-switcher.d.ts +2 -0
- package/dist/modules/ui/src/runtime/plugins/theme-switcher.js +27 -0
- package/dist/modules/ui/src/runtime/plugins/theme.d.ts +2 -0
- package/dist/modules/ui/src/runtime/plugins/theme.js +44 -0
- package/dist/modules/ui/src/runtime/plugins/vuetify.d.ts +3 -0
- package/dist/modules/ui/src/runtime/plugins/vuetify.js +33 -0
- package/dist/modules/ui/src/runtime/search/client.d.ts +2 -0
- package/dist/modules/ui/src/runtime/search/client.js +21 -0
- package/dist/modules/ui/src/runtime/search/plugin.d.ts +2 -0
- package/dist/modules/ui/src/runtime/search/plugin.js +7 -0
- package/dist/modules/ui/src/utils/color.d.ts +2 -0
- package/dist/modules/ui/src/utils/color.js +11 -0
- package/dist/modules/ui/src/utils/fonts.d.ts +5 -0
- package/dist/modules/ui/src/utils/fonts.js +18 -0
- package/dist/modules/ui/src/utils/formkit.d.ts +12 -0
- package/dist/modules/ui/src/utils/formkit.js +59 -0
- package/dist/modules/ui/src/utils/icons.d.ts +4 -0
- package/dist/modules/ui/src/utils/icons.js +36 -0
- package/dist/runtime/assets/config/tailwind.conifg.d.ts +0 -0
- package/dist/runtime/assets/config/tailwind.conifg.js +11 -0
- package/dist/runtime/components/MButton.d.vue.ts +0 -0
- package/dist/runtime/components/MButton.vue +15 -0
- package/dist/runtime/components/MButton.vue.d.ts +0 -0
- package/dist/runtime/composables/useMToast.d.ts +5 -0
- package/dist/runtime/composables/useMToast.js +11 -0
- package/dist/runtime/plugins/builder.d.ts +3 -0
- package/dist/runtime/plugins/builder.js +311 -0
- package/dist/runtime/plugins/fontawesome.d.ts +3 -0
- package/dist/runtime/plugins/fontawesome.js +9 -0
- package/dist/runtime/plugins/formkit.d.ts +3 -0
- package/dist/runtime/plugins/formkit.js +8 -0
- package/dist/runtime/plugins/icon-switcher.d.ts +1 -1
- package/dist/runtime/plugins/icon-switcher.js +15 -9
- package/dist/runtime/plugins/lightgallery.d.ts +6 -0
- package/dist/runtime/plugins/lightgallery.js +15 -0
- package/dist/runtime/plugins/motion.d.ts +2 -0
- package/dist/runtime/plugins/motion.js +5 -0
- package/dist/runtime/plugins/theme-switcher.d.ts +2 -0
- package/dist/runtime/plugins/theme-switcher.js +27 -0
- package/dist/runtime/plugins/theme.d.ts +1 -1
- package/dist/runtime/plugins/theme.js +31 -25
- package/dist/runtime/plugins/vuetify.d.ts +1 -86
- package/dist/runtime/plugins/vuetify.js +28 -55
- package/dist/runtime/search/components/MSearch.d.vue.ts +0 -0
- package/dist/runtime/search/components/MSearch.vue +19 -0
- package/dist/runtime/search/components/MSearch.vue.d.ts +0 -0
- package/dist/runtime/styles/index.css +5 -0
- package/dist/runtime/styles/tailwind.css +1 -0
- package/dist/runtime/styles/vuetify.css +3 -0
- package/dist/types.d.mts +9 -0
- package/dist/utils/color.d.ts +2 -0
- package/dist/utils/color.js +11 -0
- package/dist/utils/fonts.d.ts +5 -0
- package/dist/utils/fonts.js +18 -0
- package/dist/utils/formkit.d.ts +12 -0
- package/dist/utils/formkit.js +59 -0
- package/dist/utils/icons.d.ts +4 -0
- package/dist/utils/icons.js +36 -0
- package/package.json +12 -10
- package/src/module.ts +105 -0
- package/src/runtime/assets/config/tailwind.conifg.js +42 -0
- package/src/runtime/components/Gallery.vue +66 -0
- package/src/runtime/components/MButton.vue +17 -0
- package/src/runtime/composables/useMToast.ts +14 -0
- package/src/runtime/design/tokens.ts +22 -0
- package/src/runtime/plugins/builder.ts +326 -0
- package/src/runtime/plugins/fontawesome.ts +11 -0
- package/src/runtime/plugins/formkit.ts +9 -0
- package/src/runtime/plugins/lightgallery.js +21 -0
- package/src/runtime/plugins/motion.ts +6 -0
- package/src/runtime/plugins/theme-switcher.ts +32 -0
- package/src/runtime/plugins/theme.ts +57 -0
- package/src/runtime/plugins/vuetify.ts +36 -0
- package/src/runtime/search/client.ts +25 -0
- package/src/runtime/search/components/MSearch.vue +19 -0
- package/src/runtime/search/plugin.ts +9 -0
- package/src/runtime/styles/index.scss +101 -0
- package/src/runtime/styles/tailwind.css +9 -0
- package/src/runtime/styles/vuetify.scss +5 -0
- package/src/types/runtime-config.d.ts +12 -0
- package/src/utils/color.js +11 -0
- package/src/utils/color.ts +14 -0
- package/src/utils/fonts.js +18 -0
- package/src/utils/fonts.ts +24 -0
- package/src/utils/formkit.js +59 -0
- package/src/utils/formkit.ts +75 -0
- package/src/utils/icons.js +36 -0
- package/src/utils/icons.ts +62 -0
- package/dist/runtime/plugins/icons.d.ts +0 -4
- package/dist/runtime/plugins/icons.js +0 -13
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineNuxtPlugin } from 'nuxt/app';
|
|
2
|
+
import { useTheme } from 'vuetify';
|
|
3
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
4
|
+
if (process.server)
|
|
5
|
+
return;
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
const setTheme = (mode) => {
|
|
8
|
+
theme.global.name.value = mode;
|
|
9
|
+
document.documentElement.classList.toggle('dark', mode === 'dark');
|
|
10
|
+
localStorage.setItem('mframework-theme', mode);
|
|
11
|
+
};
|
|
12
|
+
const toggleTheme = () => {
|
|
13
|
+
const current = theme.global.name.value === 'light' ? 'dark' : 'light';
|
|
14
|
+
setTheme(current);
|
|
15
|
+
};
|
|
16
|
+
// Load saved theme
|
|
17
|
+
const saved = localStorage.getItem('mframework-theme');
|
|
18
|
+
if (saved === 'light' || saved === 'dark') {
|
|
19
|
+
setTheme(saved);
|
|
20
|
+
}
|
|
21
|
+
// Expose composable
|
|
22
|
+
nuxtApp.provide('mTheme', {
|
|
23
|
+
setTheme,
|
|
24
|
+
toggleTheme,
|
|
25
|
+
current: () => theme.global.name.value
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defineNuxtPlugin, useRuntimeConfig } from 'nuxt/app';
|
|
2
|
+
import { useTheme } from 'vuetify';
|
|
3
|
+
export default defineNuxtPlugin(() => {
|
|
4
|
+
if (process.server)
|
|
5
|
+
return;
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
const config = useRuntimeConfig();
|
|
8
|
+
const baseColors = {
|
|
9
|
+
primary: 'var(--m-primary)',
|
|
10
|
+
secondary: 'var(--m-secondary)',
|
|
11
|
+
accent: 'var(--m-accent)',
|
|
12
|
+
surface: 'var(--m-surface)',
|
|
13
|
+
background: 'var(--m-muted)',
|
|
14
|
+
border: 'var(--m-border)',
|
|
15
|
+
// Required Vuetify system colors
|
|
16
|
+
success: '#22c55e',
|
|
17
|
+
warning: '#f59e0b',
|
|
18
|
+
error: '#ef4444',
|
|
19
|
+
info: '#3b82f6',
|
|
20
|
+
// Vuetify internal required fields
|
|
21
|
+
'on-primary': '#ffffff',
|
|
22
|
+
'on-secondary': '#ffffff',
|
|
23
|
+
'on-surface': '#ffffff',
|
|
24
|
+
'on-background': '#ffffff',
|
|
25
|
+
'on-success': '#ffffff',
|
|
26
|
+
'on-warning': '#ffffff',
|
|
27
|
+
'on-error': '#ffffff',
|
|
28
|
+
'on-info': '#ffffff'
|
|
29
|
+
};
|
|
30
|
+
const defaultTheme = config.public.mframeworkUi?.theme || 'light';
|
|
31
|
+
theme.global.name.value = defaultTheme;
|
|
32
|
+
theme.themes.value = {
|
|
33
|
+
light: {
|
|
34
|
+
dark: false,
|
|
35
|
+
colors: baseColors,
|
|
36
|
+
variables: {}
|
|
37
|
+
},
|
|
38
|
+
dark: {
|
|
39
|
+
dark: true,
|
|
40
|
+
colors: baseColors,
|
|
41
|
+
variables: {}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineNuxtPlugin, useRuntimeConfig } from 'nuxt/app';
|
|
2
|
+
import { createVuetify } from 'vuetify';
|
|
3
|
+
import * as components from 'vuetify/components';
|
|
4
|
+
import * as directives from 'vuetify/directives';
|
|
5
|
+
import 'vuetify/styles';
|
|
6
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
7
|
+
const config = useRuntimeConfig();
|
|
8
|
+
const theme = config.public.mframeworkUi?.theme || 'light';
|
|
9
|
+
const vuetify = createVuetify({
|
|
10
|
+
components,
|
|
11
|
+
directives,
|
|
12
|
+
theme: {
|
|
13
|
+
defaultTheme: theme,
|
|
14
|
+
themes: {
|
|
15
|
+
light: {
|
|
16
|
+
dark: false,
|
|
17
|
+
colors: {
|
|
18
|
+
primary: '#3b82f6',
|
|
19
|
+
secondary: '#64748b'
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
dark: {
|
|
23
|
+
dark: true,
|
|
24
|
+
colors: {
|
|
25
|
+
primary: '#3b82f6',
|
|
26
|
+
secondary: '#64748b'
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
nuxtApp.vueApp.use(vuetify);
|
|
33
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function getSearchClient() {
|
|
2
|
+
let mod;
|
|
3
|
+
try {
|
|
4
|
+
mod = require('@searchkit/instantsearch-client');
|
|
5
|
+
}
|
|
6
|
+
catch {
|
|
7
|
+
console.warn('[mframework-ui] Searchkit client missing');
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const candidate = mod?.default?.default ||
|
|
11
|
+
mod?.default?.createClient ||
|
|
12
|
+
mod?.default ||
|
|
13
|
+
mod?.createClient ||
|
|
14
|
+
mod;
|
|
15
|
+
if (typeof candidate !== 'function')
|
|
16
|
+
return null;
|
|
17
|
+
const host = process.env.NUXT_PUBLIC_SEARCHKIT_HOST;
|
|
18
|
+
if (!host)
|
|
19
|
+
return null;
|
|
20
|
+
return candidate({ host });
|
|
21
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getSearchClient } from './client';
|
|
2
|
+
export default (nuxtApp) => {
|
|
3
|
+
const client = getSearchClient();
|
|
4
|
+
const indexName = process.env.NUXT_PUBLIC_SEARCH_INDEX || 'default';
|
|
5
|
+
nuxtApp.provide('mSearchClient', client);
|
|
6
|
+
nuxtApp.provide('mSearchIndex', indexName);
|
|
7
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function getContrastColor(hexColor) {
|
|
2
|
+
// Convert hex color to RGB format
|
|
3
|
+
const red = parseInt(hexColor.slice(1, 3), 16);
|
|
4
|
+
const green = parseInt(hexColor.slice(3, 5), 16);
|
|
5
|
+
const blue = parseInt(hexColor.slice(5, 7), 16);
|
|
6
|
+
// Calculate relative luminance of the color
|
|
7
|
+
const luminance = (0.2126 * red + 0.7152 * green + 0.0722 * blue) / 255;
|
|
8
|
+
// Return black or white depending on the luminance value
|
|
9
|
+
return luminance > 0.5 ? '#000000' : '#ffffff';
|
|
10
|
+
}
|
|
11
|
+
export { getContrastColor };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const formatFonts = (families, defaultWeights = [400]) => {
|
|
2
|
+
const formatted = [];
|
|
3
|
+
for (const font in families) {
|
|
4
|
+
const formattedFont = font.replace(/ /g, '+'); // Replace spaces with '+'
|
|
5
|
+
const weights = families[font];
|
|
6
|
+
if (weights === true) {
|
|
7
|
+
for (const weight of defaultWeights) {
|
|
8
|
+
formatted.push(`${formattedFont}:${weight}`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
else if (Array.isArray(weights)) {
|
|
12
|
+
for (const weight of weights) {
|
|
13
|
+
formatted.push(`${formattedFont}:${weight}`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return formatted;
|
|
18
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface Condition {
|
|
2
|
+
field: string;
|
|
3
|
+
action: 'show' | 'hide';
|
|
4
|
+
condition: 'is_empty' | 'is_filled' | 'contains' | 'not_contains' | 'equals' | 'not_equal';
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function mapConditions(conditions: Condition[]): void;
|
|
8
|
+
export declare function transformSchema(schema: Array<object>): {
|
|
9
|
+
$cmp: any;
|
|
10
|
+
children: any;
|
|
11
|
+
props: any;
|
|
12
|
+
}[];
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { unref } from 'vue';
|
|
2
|
+
function convertBoolean(value) {
|
|
3
|
+
if (value === 'true' || value === 'false') {
|
|
4
|
+
return value === 'true';
|
|
5
|
+
}
|
|
6
|
+
else {
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function mapCondition(condition, target) {
|
|
11
|
+
switch (condition) {
|
|
12
|
+
case 'is_empty':
|
|
13
|
+
return `!$get(${target}).value)`;
|
|
14
|
+
case 'is_filled':
|
|
15
|
+
return `$get(${target}).value)`;
|
|
16
|
+
default:
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function mapConditions(conditions) {
|
|
21
|
+
// Both $el and $cmp schema nodes can leverage an if property that roughly equates to a v-if in Vue. If the expression assigned to the if property is truthy, the node is rendered, otherwise it is not:
|
|
22
|
+
}
|
|
23
|
+
export function transformSchema(schema) {
|
|
24
|
+
// Loop through the form schema from Directus
|
|
25
|
+
// This is required for FormKit to work
|
|
26
|
+
const items = unref(schema);
|
|
27
|
+
return items.map((item) => {
|
|
28
|
+
const { conditions, field, name, children, ...props } = item;
|
|
29
|
+
// console.log('conditions', conditions);
|
|
30
|
+
// console.log('mapCondition', mapCondition(conditions[0].condition, field));
|
|
31
|
+
const cmpSchema = {
|
|
32
|
+
$cmp: item.$el ? item.$el : 'FormKit',
|
|
33
|
+
children: children,
|
|
34
|
+
// if: conditions ? mapCondition(conditions[0].condition, field) : undefined,
|
|
35
|
+
props: {
|
|
36
|
+
id: name,
|
|
37
|
+
...props,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
// Switch statement to handle item widths
|
|
41
|
+
switch (item.width) {
|
|
42
|
+
case '33':
|
|
43
|
+
cmpSchema.props.outerClass = 'md:col-span-2';
|
|
44
|
+
break;
|
|
45
|
+
case '50':
|
|
46
|
+
cmpSchema.props.outerClass = 'md:col-span-3';
|
|
47
|
+
break;
|
|
48
|
+
case '67':
|
|
49
|
+
cmpSchema.props.outerClass = 'md:col-span-4';
|
|
50
|
+
break;
|
|
51
|
+
case '100':
|
|
52
|
+
cmpSchema.props.outerClass = 'md:col-span-6';
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
cmpSchema.props.outerClass = 'md:col-span-6';
|
|
56
|
+
}
|
|
57
|
+
return cmpSchema;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
type FileType = 'folder' | 'image/jpeg' | 'image/png' | 'image/gif' | 'image/svg+xml' | 'image/webp' | 'video/mp4' | 'video/quicktime' | 'audio/mp3' | 'audio/aac' | 'audio/wav' | 'audio/ogg' | 'text/csv' | 'text/plain' | 'application/pdf' | 'application/vnd.ms-excel' | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'application/msword' | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' | 'application/vnd.ms-powerpoint' | 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
|
|
2
|
+
export declare const fileIconMap: Record<FileType, string>;
|
|
3
|
+
export declare function getFileIcon(filetype: FileType | string | null | undefined): string;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const fileIconMap = {
|
|
2
|
+
folder: 'material-symbols:folder',
|
|
3
|
+
// Images
|
|
4
|
+
'image/jpeg': 'material-symbols:image',
|
|
5
|
+
'image/png': 'material-symbols:image',
|
|
6
|
+
'image/gif': 'material-symbols:image',
|
|
7
|
+
'image/svg+xml': 'material-symbols:image',
|
|
8
|
+
'image/webp': 'material-symbols:image',
|
|
9
|
+
// Videos
|
|
10
|
+
'video/mp4': 'material-symbols:smart-display',
|
|
11
|
+
'video/quicktime': 'material-symbols:smart-display',
|
|
12
|
+
// Audio
|
|
13
|
+
'audio/mp3': 'material-symbols:audio-file',
|
|
14
|
+
'audio/aac': 'material-symbols:audio-file',
|
|
15
|
+
'audio/wav': 'material-symbols:audio-file',
|
|
16
|
+
'audio/ogg': 'material-symbols:audio-file',
|
|
17
|
+
// Text
|
|
18
|
+
'text/csv': 'material-symbols:csv',
|
|
19
|
+
'text/plain': 'material-symbols:text-snippet',
|
|
20
|
+
// Files
|
|
21
|
+
'application/pdf': 'material-symbols:picture-as-pdf-sharp',
|
|
22
|
+
'application/vnd.ms-excel': 'material-symbols:sheets',
|
|
23
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'material-symbols:sheets',
|
|
24
|
+
'application/msword': 'material-symbols:docs',
|
|
25
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'material-symbols:docs',
|
|
26
|
+
'application/vnd.ms-powerpoint': 'material-symbols:slides',
|
|
27
|
+
'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'material-symbols:slides',
|
|
28
|
+
};
|
|
29
|
+
export function getFileIcon(filetype) {
|
|
30
|
+
if (!filetype)
|
|
31
|
+
return 'material-symbols:attachment';
|
|
32
|
+
if (typeof filetype === 'string' && !(filetype in fileIconMap)) {
|
|
33
|
+
return 'material-symbols:attachment';
|
|
34
|
+
}
|
|
35
|
+
return fileIconMap[filetype];
|
|
36
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-btn :color="color" class="m-btn" v-bind="$attrs">
|
|
3
|
+
<slot />
|
|
4
|
+
</v-btn>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup>
|
|
8
|
+
defineProps({
|
|
9
|
+
color: { type: String, required: false }
|
|
10
|
+
});
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<style scoped>
|
|
14
|
+
.m-btn{@apply px-4 py-2 rounded-md}
|
|
15
|
+
</style>
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import iziToast from 'izitoast';
|
|
2
|
+
import 'izitoast/dist/css/iziToast.min.css';
|
|
3
|
+
export const useMToast = () => {
|
|
4
|
+
const success = (message, title = 'Success') => {
|
|
5
|
+
iziToast.success({ title, message });
|
|
6
|
+
};
|
|
7
|
+
const error = (message, title = 'Error') => {
|
|
8
|
+
iziToast.error({ title, message });
|
|
9
|
+
};
|
|
10
|
+
return { success, error };
|
|
11
|
+
};
|