@mframework/ui 0.1.0-beta.0 → 0.1.0-beta.1

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.
Files changed (111) hide show
  1. package/dist/adapters/adapter-directus/src/types/ui.d.ts +21 -0
  2. package/dist/adapters/adapter-directus/src/types/ui.js +1 -0
  3. package/dist/module.d.mts +9 -0
  4. package/dist/module.d.ts +6 -0
  5. package/dist/module.js +68 -0
  6. package/dist/module.json +9 -0
  7. package/dist/module.mjs +38 -0
  8. package/dist/modules/ui/src/module.d.ts +8 -0
  9. package/dist/modules/ui/src/module.js +75 -0
  10. package/dist/modules/ui/src/runtime/composables/useMToast.d.ts +5 -0
  11. package/dist/modules/ui/src/runtime/composables/useMToast.js +11 -0
  12. package/dist/modules/ui/src/runtime/design/tokens.d.ts +22 -0
  13. package/dist/modules/ui/src/runtime/design/tokens.js +22 -0
  14. package/dist/modules/ui/src/runtime/plugins/builder.d.ts +3 -0
  15. package/dist/modules/ui/src/runtime/plugins/builder.js +311 -0
  16. package/dist/modules/ui/src/runtime/plugins/fontawesome.d.ts +3 -0
  17. package/dist/modules/ui/src/runtime/plugins/fontawesome.js +9 -0
  18. package/dist/modules/ui/src/runtime/plugins/formkit.d.ts +3 -0
  19. package/dist/modules/ui/src/runtime/plugins/formkit.js +8 -0
  20. package/dist/modules/ui/src/runtime/plugins/motion.d.ts +2 -0
  21. package/dist/modules/ui/src/runtime/plugins/motion.js +5 -0
  22. package/dist/modules/ui/src/runtime/plugins/theme-switcher.d.ts +2 -0
  23. package/dist/modules/ui/src/runtime/plugins/theme-switcher.js +27 -0
  24. package/dist/modules/ui/src/runtime/plugins/theme.d.ts +2 -0
  25. package/dist/modules/ui/src/runtime/plugins/theme.js +44 -0
  26. package/dist/modules/ui/src/runtime/plugins/vuetify.d.ts +3 -0
  27. package/dist/modules/ui/src/runtime/plugins/vuetify.js +33 -0
  28. package/dist/modules/ui/src/runtime/search/client.d.ts +2 -0
  29. package/dist/modules/ui/src/runtime/search/client.js +21 -0
  30. package/dist/modules/ui/src/runtime/search/plugin.d.ts +2 -0
  31. package/dist/modules/ui/src/runtime/search/plugin.js +7 -0
  32. package/dist/modules/ui/src/utils/color.d.ts +2 -0
  33. package/dist/modules/ui/src/utils/color.js +11 -0
  34. package/dist/modules/ui/src/utils/fonts.d.ts +5 -0
  35. package/dist/modules/ui/src/utils/fonts.js +18 -0
  36. package/dist/modules/ui/src/utils/formkit.d.ts +12 -0
  37. package/dist/modules/ui/src/utils/formkit.js +59 -0
  38. package/dist/modules/ui/src/utils/icons.d.ts +4 -0
  39. package/dist/modules/ui/src/utils/icons.js +36 -0
  40. package/dist/runtime/assets/config/tailwind.conifg.d.ts +0 -0
  41. package/dist/runtime/assets/config/tailwind.conifg.js +11 -0
  42. package/dist/runtime/components/MButton.d.vue.ts +0 -0
  43. package/dist/runtime/components/MButton.vue +15 -0
  44. package/dist/runtime/components/MButton.vue.d.ts +0 -0
  45. package/dist/runtime/composables/useMToast.d.ts +5 -0
  46. package/dist/runtime/composables/useMToast.js +11 -0
  47. package/dist/runtime/plugins/builder.d.ts +3 -0
  48. package/dist/runtime/plugins/builder.js +311 -0
  49. package/dist/runtime/plugins/fontawesome.d.ts +3 -0
  50. package/dist/runtime/plugins/fontawesome.js +9 -0
  51. package/dist/runtime/plugins/formkit.d.ts +3 -0
  52. package/dist/runtime/plugins/formkit.js +8 -0
  53. package/dist/runtime/plugins/icon-switcher.d.ts +1 -1
  54. package/dist/runtime/plugins/icon-switcher.js +15 -9
  55. package/dist/runtime/plugins/lightgallery.d.ts +6 -0
  56. package/dist/runtime/plugins/lightgallery.js +15 -0
  57. package/dist/runtime/plugins/motion.d.ts +2 -0
  58. package/dist/runtime/plugins/motion.js +5 -0
  59. package/dist/runtime/plugins/theme-switcher.d.ts +2 -0
  60. package/dist/runtime/plugins/theme-switcher.js +27 -0
  61. package/dist/runtime/plugins/theme.d.ts +1 -1
  62. package/dist/runtime/plugins/theme.js +31 -25
  63. package/dist/runtime/plugins/vuetify.d.ts +1 -86
  64. package/dist/runtime/plugins/vuetify.js +28 -55
  65. package/dist/runtime/search/components/MSearch.d.vue.ts +0 -0
  66. package/dist/runtime/search/components/MSearch.vue +19 -0
  67. package/dist/runtime/search/components/MSearch.vue.d.ts +0 -0
  68. package/dist/runtime/styles/index.css +5 -0
  69. package/dist/runtime/styles/tailwind.css +1 -0
  70. package/dist/runtime/styles/vuetify.css +3 -0
  71. package/dist/types.d.mts +9 -0
  72. package/dist/utils/color.d.ts +2 -0
  73. package/dist/utils/color.js +11 -0
  74. package/dist/utils/fonts.d.ts +5 -0
  75. package/dist/utils/fonts.js +18 -0
  76. package/dist/utils/formkit.d.ts +12 -0
  77. package/dist/utils/formkit.js +59 -0
  78. package/dist/utils/icons.d.ts +4 -0
  79. package/dist/utils/icons.js +36 -0
  80. package/package.json +12 -10
  81. package/src/module.ts +105 -0
  82. package/src/runtime/assets/config/tailwind.conifg.js +42 -0
  83. package/src/runtime/components/Gallery.vue +66 -0
  84. package/src/runtime/components/MButton.vue +17 -0
  85. package/src/runtime/composables/useMToast.ts +14 -0
  86. package/src/runtime/design/tokens.ts +22 -0
  87. package/src/runtime/plugins/builder.ts +326 -0
  88. package/src/runtime/plugins/fontawesome.ts +11 -0
  89. package/src/runtime/plugins/formkit.ts +9 -0
  90. package/src/runtime/plugins/lightgallery.js +21 -0
  91. package/src/runtime/plugins/motion.ts +6 -0
  92. package/src/runtime/plugins/theme-switcher.ts +32 -0
  93. package/src/runtime/plugins/theme.ts +57 -0
  94. package/src/runtime/plugins/vuetify.ts +36 -0
  95. package/src/runtime/search/client.ts +25 -0
  96. package/src/runtime/search/components/MSearch.vue +19 -0
  97. package/src/runtime/search/plugin.ts +9 -0
  98. package/src/runtime/styles/index.scss +101 -0
  99. package/src/runtime/styles/tailwind.css +9 -0
  100. package/src/runtime/styles/vuetify.scss +5 -0
  101. package/src/types/runtime-config.d.ts +12 -0
  102. package/src/utils/color.js +11 -0
  103. package/src/utils/color.ts +14 -0
  104. package/src/utils/fonts.js +18 -0
  105. package/src/utils/fonts.ts +24 -0
  106. package/src/utils/formkit.js +59 -0
  107. package/src/utils/formkit.ts +75 -0
  108. package/src/utils/icons.js +36 -0
  109. package/src/utils/icons.ts +62 -0
  110. package/dist/runtime/plugins/icons.d.ts +0 -4
  111. package/dist/runtime/plugins/icons.js +0 -13
@@ -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,14 @@
1
+ function getContrastColor(hexColor: string) {
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
+
7
+ // Calculate relative luminance of the color
8
+ const luminance = (0.2126 * red + 0.7152 * green + 0.0722 * blue) / 255;
9
+
10
+ // Return black or white depending on the luminance value
11
+ return luminance > 0.5 ? '#000000' : '#ffffff';
12
+ }
13
+
14
+ 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,24 @@
1
+ type FontFamilies = {
2
+ [font: string]: boolean | number[];
3
+ };
4
+
5
+ export const formatFonts = (families: FontFamilies, defaultWeights: number[] = [400]): string[] => {
6
+ const formatted: string[] = [];
7
+
8
+ for (const font in families) {
9
+ const formattedFont = font.replace(/ /g, '+'); // Replace spaces with '+'
10
+ const weights = families[font];
11
+
12
+ if (weights === true) {
13
+ for (const weight of defaultWeights) {
14
+ formatted.push(`${formattedFont}:${weight}`);
15
+ }
16
+ } else if (Array.isArray(weights)) {
17
+ for (const weight of weights) {
18
+ formatted.push(`${formattedFont}:${weight}`);
19
+ }
20
+ }
21
+ }
22
+
23
+ return formatted;
24
+ };
@@ -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,75 @@
1
+ import { unref } from 'vue';
2
+
3
+ export interface Condition {
4
+ field: string;
5
+ action: 'show' | 'hide';
6
+ condition: 'is_empty' | 'is_filled' | 'contains' | 'not_contains' | 'equals' | 'not_equal';
7
+ value: string;
8
+ }
9
+
10
+ function convertBoolean(value: string) {
11
+ if (value === 'true' || value === 'false') {
12
+ return value === 'true';
13
+ } else {
14
+ return value;
15
+ }
16
+ }
17
+
18
+ function mapCondition(condition: Condition['condition'], target: string) {
19
+ switch (condition) {
20
+ case 'is_empty':
21
+ return `!$get(${target}).value)`;
22
+ case 'is_filled':
23
+ return `$get(${target}).value)`;
24
+ default:
25
+ return undefined;
26
+ }
27
+ }
28
+
29
+ export function mapConditions(conditions: Condition[]) {
30
+ // 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:
31
+ }
32
+
33
+ export function transformSchema(schema: Array<object>) {
34
+ // Loop through the form schema from Directus
35
+ // This is required for FormKit to work
36
+ const items = unref(schema);
37
+ return items.map((item: any) => {
38
+ const { conditions, field, name, children, ...props } = item;
39
+
40
+ // console.log('conditions', conditions);
41
+ // console.log('mapCondition', mapCondition(conditions[0].condition, field));
42
+
43
+ const cmpSchema = {
44
+ $cmp: item.$el ? item.$el : 'FormKit',
45
+
46
+ children: children,
47
+ // if: conditions ? mapCondition(conditions[0].condition, field) : undefined,
48
+
49
+ props: {
50
+ id: name,
51
+ ...props,
52
+ },
53
+ };
54
+
55
+ // Switch statement to handle item widths
56
+ switch (item.width) {
57
+ case '33':
58
+ cmpSchema.props.outerClass = 'md:col-span-2';
59
+ break;
60
+ case '50':
61
+ cmpSchema.props.outerClass = 'md:col-span-3';
62
+ break;
63
+ case '67':
64
+ cmpSchema.props.outerClass = 'md:col-span-4';
65
+ break;
66
+ case '100':
67
+ cmpSchema.props.outerClass = 'md:col-span-6';
68
+ break;
69
+ default:
70
+ cmpSchema.props.outerClass = 'md:col-span-6';
71
+ }
72
+
73
+ return cmpSchema;
74
+ });
75
+ }
@@ -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
+ }
@@ -0,0 +1,62 @@
1
+ type FileType =
2
+ | 'folder'
3
+ | 'image/jpeg'
4
+ | 'image/png'
5
+ | 'image/gif'
6
+ | 'image/svg+xml'
7
+ | 'image/webp'
8
+ | 'video/mp4'
9
+ | 'video/quicktime'
10
+ | 'audio/mp3'
11
+ | 'audio/aac'
12
+ | 'audio/wav'
13
+ | 'audio/ogg'
14
+ | 'text/csv'
15
+ | 'text/plain'
16
+ | 'application/pdf'
17
+ | 'application/vnd.ms-excel'
18
+ | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
19
+ | 'application/msword'
20
+ | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
21
+ | 'application/vnd.ms-powerpoint'
22
+ | 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
23
+
24
+ export const fileIconMap: Record<FileType, string> = {
25
+ folder: 'material-symbols:folder',
26
+ // Images
27
+ 'image/jpeg': 'material-symbols:image',
28
+ 'image/png': 'material-symbols:image',
29
+ 'image/gif': 'material-symbols:image',
30
+ 'image/svg+xml': 'material-symbols:image',
31
+ 'image/webp': 'material-symbols:image',
32
+ // Videos
33
+ 'video/mp4': 'material-symbols:smart-display',
34
+ 'video/quicktime': 'material-symbols:smart-display',
35
+ // Audio
36
+ 'audio/mp3': 'material-symbols:audio-file',
37
+ 'audio/aac': 'material-symbols:audio-file',
38
+ 'audio/wav': 'material-symbols:audio-file',
39
+ 'audio/ogg': 'material-symbols:audio-file',
40
+ // Text
41
+ 'text/csv': 'material-symbols:csv',
42
+ 'text/plain': 'material-symbols:text-snippet',
43
+
44
+ // Files
45
+ 'application/pdf': 'material-symbols:picture-as-pdf-sharp',
46
+ 'application/vnd.ms-excel': 'material-symbols:sheets',
47
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'material-symbols:sheets',
48
+ 'application/msword': 'material-symbols:docs',
49
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'material-symbols:docs',
50
+ 'application/vnd.ms-powerpoint': 'material-symbols:slides',
51
+ 'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'material-symbols:slides',
52
+ };
53
+
54
+ export function getFileIcon(filetype: FileType | string | null | undefined) {
55
+ if (!filetype) return 'material-symbols:attachment';
56
+
57
+ if (typeof filetype === 'string' && !(filetype in fileIconMap)) {
58
+ return 'material-symbols:attachment';
59
+ }
60
+
61
+ return fileIconMap[filetype as FileType];
62
+ }
@@ -1,4 +0,0 @@
1
- import '@fortawesome/fontawesome-free/css/all.css';
2
- import '@mdi/font/css/materialdesignicons.css';
3
- declare const _default: any;
4
- export default _default;
@@ -1,13 +0,0 @@
1
- // @mframework/ui/runtime/plugins/icons.ts
2
- import { defineNuxtPlugin } from '#imports';
3
- import { library } from '@fortawesome/fontawesome-svg-core';
4
- import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
5
- import { fas } from '@fortawesome/free-solid-svg-icons';
6
- import '@fortawesome/fontawesome-free/css/all.css';
7
- import '@mdi/font/css/materialdesignicons.css';
8
- export default defineNuxtPlugin((nuxtApp) => {
9
- // Add all solid icons (you can be more selective if you want)
10
- library.add(fas);
11
- // Register global FA component
12
- nuxtApp.vueApp.component('FaIcon', FontAwesomeIcon);
13
- });