@mapomodule/uikit 1.0.0-alpha.9 → 2.0.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 (94) hide show
  1. package/README.md +167 -0
  2. package/dist/index.d.cts +2 -0
  3. package/dist/index.d.mts +2 -0
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.mjs +18 -0
  6. package/dist/module.d.cts +2 -0
  7. package/dist/module.d.mts +2 -0
  8. package/dist/module.d.ts +2 -0
  9. package/dist/module.json +9 -0
  10. package/dist/module.mjs +18 -0
  11. package/dist/types.d.mts +13 -0
  12. package/package.json +63 -10
  13. package/src/index.ts +10 -0
  14. package/src/module.ts +181 -0
  15. package/src/runtime/assets/main.css +59 -0
  16. package/src/runtime/components/MapoConfirmDialog.vue +34 -0
  17. package/src/runtime/components/MapoDetail.vue +861 -0
  18. package/src/runtime/components/MapoDetailLangSwitch.vue +166 -0
  19. package/src/runtime/components/MapoList.vue +339 -0
  20. package/src/runtime/components/MapoListActions.vue +152 -0
  21. package/src/runtime/components/MapoListFilters.vue +289 -0
  22. package/src/runtime/components/MapoListHead.vue +12 -0
  23. package/src/runtime/components/MapoListQuickEdit.vue +163 -0
  24. package/src/runtime/components/MapoListTable.vue +926 -0
  25. package/src/runtime/components/MapoListTabs.vue +48 -0
  26. package/src/runtime/components/MapoLogin.vue +209 -0
  27. package/src/runtime/components/MapoLogoutButton.vue +46 -0
  28. package/src/runtime/components/MapoRootComponents.vue +9 -0
  29. package/src/runtime/components/MapoSidebar.vue +112 -0
  30. package/src/runtime/components/MapoSidebarList.vue +35 -0
  31. package/src/runtime/components/MapoSidebarListItem.vue +79 -0
  32. package/src/runtime/components/MapoSidebarProfile.vue +57 -0
  33. package/src/runtime/components/MapoSnackBar.vue +42 -0
  34. package/src/runtime/components/MapoThemeToggle.vue +23 -0
  35. package/src/runtime/components/MapoTopbar.vue +36 -0
  36. package/src/runtime/layouts/default.vue +53 -0
  37. package/src/runtime/layouts/empty.vue +9 -0
  38. package/src/runtime/page-meta.nuxt.d.ts +45 -0
  39. package/src/runtime/pages/index.vue +14 -0
  40. package/src/runtime/pages/login.vue +7 -0
  41. package/src/runtime/types/list.ts +64 -0
  42. package/CHANGELOG.md +0 -177
  43. package/LICENSE.md +0 -20
  44. package/assets/mixins.scss +0 -22
  45. package/assets/variables.scss +0 -18
  46. package/components/ConfirmDialog.vue +0 -152
  47. package/components/Detail/Detail.vue +0 -566
  48. package/components/Detail/DetailField.vue +0 -142
  49. package/components/Detail/DetailLangSwitch.vue +0 -72
  50. package/components/Detail/defaults.js +0 -57
  51. package/components/DropArea.vue +0 -250
  52. package/components/List/List.vue +0 -254
  53. package/components/List/ListActions.vue +0 -164
  54. package/components/List/ListFilters.vue +0 -334
  55. package/components/List/ListHead.vue +0 -67
  56. package/components/List/ListQuickEdit.vue +0 -302
  57. package/components/List/ListTable.vue +0 -406
  58. package/components/List/ListTabs.vue +0 -65
  59. package/components/Login.vue +0 -124
  60. package/components/Logo.vue +0 -79
  61. package/components/LogoutButton.vue +0 -39
  62. package/components/MediaManager/MediaEditor.vue +0 -309
  63. package/components/MediaManager/MediaFolders.vue +0 -263
  64. package/components/MediaManager/MediaGallery.vue +0 -206
  65. package/components/MediaManager/MediaManager.vue +0 -233
  66. package/components/MediaManager/MediaManagerDialog.vue +0 -96
  67. package/components/MediaManager/MediaPreview.vue +0 -180
  68. package/components/MediaManager/MediaUploader.vue +0 -165
  69. package/components/RootComponents.vue +0 -25
  70. package/components/SnackBar.vue +0 -70
  71. package/components/fields/DateField.vue +0 -74
  72. package/components/fields/FksField.vue +0 -60
  73. package/components/fields/MediaField.vue +0 -213
  74. package/components/fields/MediaM2mField.vue +0 -243
  75. package/components/fields/SeoPreview.vue +0 -89
  76. package/components/fields/wygEditor/defaults.js +0 -55
  77. package/components/fields/wygEditor/utils/events.js +0 -64
  78. package/components/fields/wygEditor/utils/mapomedia.plugin.js +0 -31
  79. package/components/fields/wygEditor/utils/script.injector.js +0 -29
  80. package/components/fields/wygEditor/wygEditor.vue +0 -196
  81. package/components/layout/Sidebar/Sidebar.vue +0 -80
  82. package/components/layout/Sidebar/SidebarFooter.vue +0 -71
  83. package/components/layout/Sidebar/SidebarList.vue +0 -44
  84. package/components/layout/Sidebar/SidebarListItem.vue +0 -144
  85. package/components/layout/Topbar/Topbar.vue +0 -27
  86. package/components/layout/routebuilder.js +0 -48
  87. package/defaults.js +0 -29
  88. package/layouts/default.vue +0 -21
  89. package/layouts/empty.vue +0 -6
  90. package/layouts/error.vue +0 -45
  91. package/module.js +0 -78
  92. package/pages/index.vue +0 -35
  93. package/pages/login.vue +0 -10
  94. package/static/favicon.ico +0 -0
@@ -1,142 +0,0 @@
1
- <template>
2
- <div>
3
- <span class="mapo-label" :class="`mapo-label-${conf.value}`">{{label}}</span>
4
- <component :is="is" v-model="model" v-bind="fieldAttrs"></component>
5
- </div>
6
- </template>
7
-
8
- <style>
9
- .mapo-label {
10
- display: none;
11
- }
12
- </style>
13
-
14
- <script>
15
- import wygEditor from "@mapomodule/uikit/components/fields/wygEditor/wygEditor.vue";
16
- import DateField from "@mapomodule/uikit/components/fields/DateField.vue";
17
- import FksField from "@mapomodule/uikit/components/fields/FksField.vue";
18
- import MediaM2mField from "@mapomodule/uikit/components/fields/MediaM2mField.vue";
19
- import MediaField from "@mapomodule/uikit/components/fields/MediaField.vue";
20
- import SeoPreview from "@mapomodule/uikit/components/fields/SeoPreview.vue";
21
-
22
-
23
- import { getPointed, setPointed } from "@mapomodule/utils/helpers/objHelpers";
24
- import defaults from "./defaults";
25
-
26
- /**
27
- * This is mainly an internal component. It is used by the [`DetailComponent`](/components/detail/Detail/) in order to render dinamic fields inside the main form.
28
- */
29
- export default {
30
- name: "DetailField",
31
- components: {
32
- wygEditor,
33
- DateField,
34
- FksField,
35
- MediaM2mField,
36
- MediaField,
37
- SeoPreview,
38
- },
39
-
40
- data() {
41
- return {
42
- model: null,
43
- defaultMap: defaults.mapping,
44
- defaultAttrs: defaults.props,
45
- defaultAccess: defaults.accessor,
46
- };
47
- },
48
- props: {
49
- // V-model of the payload needed to edit the field value in realtime.
50
- value: {
51
- type: Object,
52
- required: true,
53
- },
54
- // An object representing all the errors of all fields. This means that this component will find the error of its field following the dottedPath of the value in the error dict.
55
- errors: Object,
56
- // The main configuration that determines the rendering of the field. See [FieldConfiguration](/components/detail/Detail/#fieldconfiguration).
57
- conf: {
58
- // [`FieldConfiguration`](/components/detail/Detail/#fieldconfiguration)
59
- type: Object,
60
- required: true,
61
- },
62
- },
63
- watch: {
64
- value: {
65
- deep: true,
66
- handler(val) {
67
- this.setModel(val);
68
- },
69
- },
70
- "conf.value"(newValue, oldValue) {
71
- if (newValue !== oldValue) {
72
- this.setModel();
73
- }
74
- },
75
- model(val) {
76
- const dump = { ...this.value };
77
- setPointed(
78
- dump,
79
- this.conf.value,
80
- this.accessor.set({ model: { ...this.value }, val })
81
- );
82
- // Fired when the v-model changes.
83
- // @arg Emits the entire payload modified.
84
- this.$emit("input", dump);
85
- },
86
- },
87
- methods: {
88
- setModel(val = this.value) {
89
- var model = this.accessor.get({
90
- model: { ...val },
91
- val: getPointed({ ...val }, this.conf.value),
92
- });
93
- if (val && JSON.stringify(this.model) !== JSON.stringify(model))
94
- this.model = model;
95
- },
96
- },
97
- computed: {
98
- accessor() {
99
- let func = function ({ val }) {
100
- return val;
101
- };
102
- return {
103
- get: func,
104
- set: func,
105
- ...(this.defaultAccess[this.is] || {}),
106
- ...this.conf.accessor,
107
- };
108
- },
109
- fieldAttrs() {
110
- return {
111
- label: this.label,
112
- errorMessages: getPointed(this.errors || {}, this.conf.value, []),
113
- ...this.defaultAttrs.All,
114
- ...(this.defaultAttrs[this.is.replace(/-./g, x=>x[1].toUpperCase())] || {}),
115
- ...this.conf.attrs,
116
- };
117
- },
118
- label() {
119
- if (this.conf.label !== undefined) {
120
- return this.conf.label;
121
- }
122
- const titleCase = (string) =>
123
- (string && string[0].toUpperCase() + string.slice(1).toLowerCase()) ||
124
- "";
125
- return titleCase(
126
- (this.conf.value || "")
127
- .replace(/^translations\.\w\w\./, "")
128
- .split(".")
129
- .join(" ")
130
- .replace(/_/, " ")
131
- );
132
- },
133
- is() {
134
- return (
135
- this.conf.is ||
136
- (this.conf.type && this.defaultMap[this.conf.type]) ||
137
- "vTextField"
138
- );
139
- },
140
- },
141
- };
142
- </script>
@@ -1,72 +0,0 @@
1
- <template>
2
- <v-tabs v-model="tab" show-arrows>
3
- <v-tab v-for="lang in langs" :key="lang">
4
- <v-badge :value="hasErrors(lang)" color="error" dot>
5
- {{ lang }}
6
- </v-badge>
7
- </v-tab>
8
- </v-tabs>
9
- </template>
10
-
11
- <script>
12
- import { getPointed } from "@mapomodule/utils/helpers/objHelpers";
13
- /**
14
- * This is mainly an internal component. It is used by the [`DetailComponent`](/components/detail/Detail/) in order to render and manage all the language choices for the payload.
15
- */
16
- export default {
17
- name: "DetailLangSwitch",
18
- data() {
19
- return {
20
- tab: null,
21
- };
22
- },
23
- props: {
24
- // V-model representing the current selected language.
25
- value: String,
26
- // A list of languages into which the payload needs to be translated.
27
- langs: {
28
- type: Array,
29
- default: () => [],
30
- },
31
- // An object representing all the errors of all fields. This component will find errors in each language and will display a little dot in the tab if there are any errors.
32
- errors: Object,
33
- },
34
- computed: {
35
- currentLang() {
36
- return this.langs[this.tab];
37
- },
38
- },
39
- watch: {
40
- tab(val) {
41
- this.saveQparams();
42
- // Fired when the v-model changes.
43
- // @arg Emits the current language choice.
44
- this.$emit("input", this.langs[val]);
45
- },
46
- value(val) {
47
- this.tab = this.langs.indexOf(val);
48
- },
49
- },
50
- methods: {
51
- saveQparams() {
52
- const { lang } = this.$route.query;
53
- if (lang !== this.currentLang) {
54
- this.$router.replace({
55
- query: { ...this.$route.query, lang: this.currentLang },
56
- });
57
- }
58
- },
59
- hasErrors(lang) {
60
- const error = getPointed(
61
- this.errors || {},
62
- `translations.${lang}`,
63
- false
64
- );
65
- return error && Object.keys(error).length;
66
- },
67
- },
68
- mounted() {
69
- this.tab = this.langs.indexOf(this.$route.query.lang);
70
- },
71
- };
72
- </script>
@@ -1,57 +0,0 @@
1
- const mapping = {
2
- text: "vTextField",
3
- select: "vSelect",
4
- date: "DateField",
5
- textarea: "vTextarea",
6
- switch: "vSwitch",
7
- slider: "vSlider",
8
- file: "vFileInput",
9
- editor: "wygEditor",
10
- media: "MediaField",
11
- fks: "FksField",
12
- m2m: "FksField",
13
- mediaList: "MediaM2mField",
14
- seoPreview: "SeoPreview"
15
- }
16
-
17
- const props = {
18
- vSelect: {
19
- itemText: "text",
20
- itemValue: "value"
21
- },
22
- MediaField: {
23
- outlined: false
24
- },
25
- vSwitch: {
26
- inset: true,
27
- ripple: false
28
- },
29
- FksField:{
30
- itemValue: "id",
31
- returnObject: true,
32
- },
33
- All : {
34
- outlined: true,
35
- class: "rounded-0",
36
- }
37
- }
38
-
39
- const dateFunc = function ({ val }) {
40
- return val && new Date(val).toISOString().split("T")[0];
41
- };
42
-
43
- const accessor = {
44
- vDatePicker: {
45
- get: dateFunc, set: dateFunc
46
- },
47
- DateField: {
48
- get: dateFunc, set: dateFunc
49
- },
50
- SeoPreview: {
51
- get: ({ val }) => ({ title: "", permalink: "", description: "", ...val }),
52
- set: ({ val }) => ({ title: "", permalink: "", description: "", ...val })
53
- }
54
- }
55
- export default {
56
- mapping, props, accessor
57
- }
@@ -1,250 +0,0 @@
1
- <template>
2
- <v-card
3
- @drop.prevent="onDrop($event)"
4
- @dragover.prevent="dragover = true"
5
- @dragenter.prevent="dragover = true"
6
- @dragend.prevent="dragover = false"
7
- @dragleave.prevent="dragover = false"
8
- :class="{ 'grey darken-3': dragover }"
9
- v-bind="{ light, dark, elevation }"
10
- >
11
- <v-card-text>
12
- <v-row
13
- @click.stop="pickFile"
14
- class="d-flex flex-column cursor-pointer"
15
- dense
16
- align="center"
17
- justify="center"
18
- >
19
- <v-icon :class="[dragover ? 'mt-2, mb-6' : 'mt-5']" size="60">
20
- mdi-cloud-upload
21
- </v-icon>
22
- <p>Drop your file(s) here, or click to select them.</p>
23
- <input
24
- type="file"
25
- style="display: none"
26
- ref="fileInput"
27
- :multiple="multiple"
28
- @change="onFilePicked"
29
- />
30
- </v-row>
31
- <v-virtual-scroll
32
- :items="uploadedFiles"
33
- :height="
34
- uploadedFiles.length * 64 > 256 ? 256 : uploadedFiles.length * 64
35
- "
36
- item-height="64"
37
- >
38
- <template v-slot:default="{ item }">
39
- <v-list-item :key="item.info.name">
40
- <v-list-item-avatar tile v-if="item.info.objectURL">
41
- <v-img :src="item.info.objectURL"></v-img>
42
- </v-list-item-avatar>
43
-
44
- <v-list-item-content
45
- class="cursor-pointer"
46
- @click.stop="editItem(item)"
47
- >
48
- <v-list-item-title>
49
- {{ item.info.name }}
50
- </v-list-item-title>
51
- <v-list-item-subtitle>
52
- {{ item.info.type || "type/unknow" }}, {{ item.info.size }}
53
- </v-list-item-subtitle>
54
- </v-list-item-content>
55
-
56
- <v-list-item-action>
57
- <v-btn @click.stop="removeFile(item.info.name)" icon>
58
- <v-icon> mdi-close-circle </v-icon>
59
- </v-btn>
60
- </v-list-item-action>
61
- </v-list-item>
62
-
63
- <v-divider></v-divider>
64
- </template>
65
- </v-virtual-scroll>
66
- </v-card-text>
67
- <v-card-actions>
68
- <v-spacer></v-spacer>
69
- <!-- Slot to provide custom button actions inside the drop area -->
70
- <slot v-bind:clearList="clearList" name="actions">
71
- <!-- `<v-btn @click="clearList" icon><v-icon>mdi-close</v-icon></v-btn>` -->
72
- <v-btn v-if="uploadedFiles && uploadedFiles.length" @click="clearList" icon>
73
- <v-icon>mdi-close</v-icon>
74
- </v-btn>
75
- </slot>
76
- </v-card-actions>
77
- <v-dialog
78
- v-model="editDialog"
79
- v-bind="{ light, dark, elevation }"
80
- max-width="500px"
81
- >
82
- <v-card v-if="editedItem">
83
- <v-card-title>
84
- <!-- Slot to provide custom edit card title. Exposes `editedItem`. -->
85
- <slot v-bind:editedItem="editedItem" name="editTitle">
86
- <!-- `<v-img v-if="editedItem.objectURL" max-height="200" contain :src="editedItem.objectURL"></v-img>` -->
87
- <v-img
88
- v-if="editedItem.objectURL"
89
- max-height="200"
90
- contain
91
- :src="editedItem.objectURL"
92
- ></v-img>
93
- </slot>
94
- </v-card-title>
95
-
96
- <v-card-text>
97
- <!-- Slot to provide custom edit card content. Exposes `editedItem`. -->
98
- <slot v-bind:editedItem="editedItem" name="editContent">
99
- <!-- `<v-container><v-row><v-col cols="12"><v-text-field v-model="editedItem.name" label="File name"></v-text-field></v-col></v-row></v-container>` -->
100
- <v-container>
101
- <v-row>
102
- <v-col cols="12">
103
- <v-text-field
104
- v-model="editedItem.name"
105
- label="File name"
106
- ></v-text-field>
107
- </v-col>
108
- </v-row>
109
- </v-container>
110
- </slot>
111
- </v-card-text>
112
-
113
- <v-card-actions>
114
- <v-spacer></v-spacer>
115
- <v-btn color="primary" text @click="closeEdit"> Cancel </v-btn>
116
- <v-btn color="primary" text @click="saveEdit"> Save </v-btn>
117
- </v-card-actions>
118
- </v-card>
119
- </v-dialog>
120
- </v-card>
121
- </template>
122
-
123
- <style lang="scss" scoped>
124
- .cursor-pointer {
125
- cursor: pointer;
126
- }
127
- </style>
128
-
129
- <script>
130
- import { humanFileSize } from "@mapomodule/utils/helpers/formatters";
131
- /**
132
- * This component creates a drop area for uploads.
133
- * You can drag and drop over the button or click it to load the files.
134
- * When files are loaded into the component it will emit an event containing all the files.
135
- * This component will not take care of the actual file upload.
136
- *
137
- */
138
- export default {
139
- name: "DropArea",
140
- props: {
141
- // This determines whether the component accepts multiple files or a single file.
142
- multiple: {
143
- type: Boolean,
144
- default: false,
145
- },
146
- // Light theme (style).
147
- light: {
148
- type: Boolean,
149
- default: false,
150
- },
151
- // Dark theme (style).
152
- dark: {
153
- type: Boolean,
154
- default: false,
155
- },
156
- // Elevation shadow (style).
157
- elevation: {
158
- // `Number|String`.
159
- type: Number | String,
160
- default: undefined,
161
- },
162
- },
163
- data() {
164
- return {
165
- editDialog: false,
166
- editedItem: null,
167
- editedIndex: -1,
168
- dragover: false,
169
- uploadedFiles: [],
170
- };
171
- },
172
- methods: {
173
- clearList() {
174
- this.uploadedFiles = [];
175
- },
176
- removeFile(fileName) {
177
- const index = this.uploadedFiles.findIndex(
178
- (file) => file.info.name === fileName
179
- );
180
- if (index > -1) this.uploadedFiles.splice(index, 1);
181
- },
182
- pickFile() {
183
- this.$refs.fileInput.click();
184
- },
185
- onFilePicked(e) {
186
- this.procesFiles(e.target.files);
187
- },
188
- onDrop(e) {
189
- this.dragover = false;
190
- this.procesFiles(e.dataTransfer.files);
191
- },
192
- procesFiles(files) {
193
- if (this.uploadedFiles.length > 0) this.uploadedFiles = [];
194
- if (!this.multiple && files.length > 1) {
195
- this.$mapo.$snack.open({
196
- message: "Only one file can be uploaded at a time..",
197
- color: "error",
198
- });
199
- } else {
200
- const stack = [];
201
- for (let i = 0; i < files.length; i++) {
202
- stack.push(this.processFile(files[i]));
203
- }
204
- this.uploadedFiles = stack.slice();
205
- }
206
- },
207
- processFile(blob) {
208
- return {
209
- info: {
210
- objectURL: blob.type.startsWith("image/")
211
- ? URL.createObjectURL(blob)
212
- : null,
213
- name: blob.name,
214
- size: humanFileSize(blob.size, true, 2),
215
- type: blob.type,
216
- },
217
- blob,
218
- };
219
- },
220
- editItem(item) {
221
- this.editedIndex = this.uploadedFiles.indexOf(item);
222
- this.editedItem = Object.assign({}, item.info);
223
- this.editDialog = true;
224
- },
225
- saveEdit() {
226
- this.uploadedFiles[this.editedIndex].info = Object.assign(
227
- {},
228
- this.editedItem
229
- );
230
- this.closeEdit();
231
- },
232
- closeEdit() {
233
- this.editDialog = false;
234
- this.$nextTick(() => {
235
- this.editedItem = null;
236
- this.editedIndex = -1;
237
- });
238
- },
239
- },
240
- watch: {
241
- uploadedFiles(val) {
242
- /** Fires when the list of files loaded changes
243
- * @arg This emits a list of files in the format {info, blob} where the blob is a
244
- * [File](https://developer.mozilla.org/en-US/docs/Web/API/File) and info are some custom info about the file.
245
- */
246
- this.$emit("change", val);
247
- },
248
- },
249
- };
250
- </script>