@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,254 +0,0 @@
1
- <template>
2
- <div>
3
- <ListHead v-bind="$attrs" />
4
-
5
- <div>
6
- <v-row class="mb-1">
7
- <v-col cols="12" md="4">
8
- <ListActions
9
- v-bind="$attrs"
10
- :crud="crud"
11
- :selection="allSelected ? 'all' : selection"
12
- :selectionQuery="selectionQuery"
13
- @actionCompleted="refresh"
14
- />
15
- </v-col>
16
- <v-col cols="12" md="8" class="d-flex flex-nowrap justify-end align-center">
17
- <ListFilters v-bind="$attrs" v-model="filters">
18
- <template v-for="(_, slot) in $slots" :slot="slot">
19
- <!-- @vuese-ignore -->
20
- <slot :name="slot"></slot>
21
- </template>
22
- <template v-for="(_, slot) in $scopedSlots" v-slot:[slot]="props">
23
- <!-- @vuese-ignore -->
24
- <slot :name="slot" v-bind="props" />
25
- </template>
26
- </ListFilters>
27
- </v-col>
28
- </v-row>
29
- <div class="d-flex justify-end">
30
- <!-- Overrides counter for selected items. -->
31
- <slot name="item-counter" v-bind="{ selection, canSelectAll, allSelected, toggleSelectAll }">
32
- <div v-if="selection" class="caption mr-1 mb-1">
33
- <b v-if="allSelected">All items selected</b>
34
- <span v-else-if="selection.length">
35
- {{ selection.length }} items selected
36
- <v-btn
37
- v-if="selection != 'all' && canSelectAll"
38
- @click="toggleSelectAll"
39
- outlined
40
- tile
41
- x-small
42
- class="ml-1 d-inline-flex"
43
- >Select all</v-btn
44
- >
45
- </span>
46
- </div>
47
- </slot>
48
- </div>
49
- </div>
50
- <div>
51
- <ListTable
52
- v-model="selection"
53
- v-bind="{...$attrs, crud, filters}"
54
- v-on="$listeners"
55
- ref="dtable"
56
- >
57
- <template v-for="(_, slot) in $slots" :slot="slot">
58
- <!-- @vuese-ignore -->
59
- <slot :name="slot"></slot>
60
- </template>
61
- <template v-for="(_, slot) in $scopedSlots" v-slot:[slot]="props">
62
- <!-- @vuese-ignore -->
63
- <slot :name="slot" v-bind="props" />
64
- </template>
65
- </ListTable>
66
- </div>
67
- </div>
68
- </template>
69
-
70
- <script>
71
- /**
72
- * The purpose of this component is to provide you with a very quick way to create a page that can show a list of resources retrieved from the server.
73
- * A use case example could be "build a page that lists all the products of an ecommerce". <br><br>
74
- * This component is a wrapper and is made up of several parts.
75
- * The props and slots of this component are passed to its childs.
76
- * For detailed explanations see [Transparent Wrapping](#transparent-wrapping). <br> <h4>Index:</h4> [[toc]]
77
- */
78
- export default {
79
- name: "List",
80
- data() {
81
- return {
82
- tabActiveStatus: 1,
83
- selection: [],
84
- allSelected: false,
85
- filters: []
86
- };
87
- },
88
- props: {
89
- // The url of the endpoint that provides the data to display. From this url a complete crud (See [this.$mapo.$api.crud](/core/#$api.crud)) will be created.
90
- endpoint: {
91
- type: String
92
- },
93
- // Add option to select all items in all pages
94
- canSelectAll: Boolean,
95
- },
96
- computed: {
97
- crud() {
98
- return this.$mapo.$api.crud(this.endpoint);
99
- },
100
- selectionQuery() {
101
- return this.$refs?.dtable?.getHttpParams();
102
- }
103
- },
104
- watch: {
105
- selection(val) {
106
- this.allSelected = val == 'all';
107
- // Fires when you select some row of the table.
108
- // @arg Emit "all" if all items are selected, else the list of the selected rows.
109
- this.$emit("selectionChange", val);
110
- },
111
- },
112
- methods: {
113
- refresh() {
114
- return this.$refs.dtable.getDataFromApi();
115
- },
116
- toggleSelectAll() {
117
- return this.$refs?.dtable?.toggleSelectAll();
118
- }
119
- },
120
- mounted() {},
121
- };
122
- </script>
123
-
124
-
125
- <docs>
126
-
127
- ## Transparent Wrapping
128
-
129
-
130
- This component, as we said, is a wrapper and is made up of several parts:
131
- - [ListActions](../ListActions/)
132
- - [ListFilters](../ListFilters/)
133
- - [ListHead](../ListHead/)
134
- - [ListQuickEdit](../ListQuickEdit/)
135
- - [ListTable](../ListTable/)
136
-
137
- Each component within it inherits its props and slots.
138
-
139
- ### Props
140
- For the list of available prop refer to the documentation of each single part.
141
-
142
- ### Slots
143
- Other slots related to sub-components can be reached through these namespaces:
144
- - `"filter"` is the namespace of [`ListFilters`](../ListFilters/#slots) slots.
145
- - `"dtable"` is the namespace of [`ListTable`](../ListTable/#slots) slots.
146
- - `"qedit"` is the namespace of [`ListQuickEdit`](../ListQuickEdit/#slots) slots.
147
-
148
- <br><br>
149
-
150
- ## Live Demo
151
-
152
- <br>
153
-
154
- ::: warning LIVE DEMO 🎉🎉🎉
155
- This is an interactive example. You can play with it but remember that all http features are disabled since there is no backend server.
156
- :::
157
-
158
- ::: demo
159
- <template>
160
- <v-app>
161
- <List
162
- show-select
163
- title="Sweets archive:"
164
- lookup="name"
165
- :headers="headers"
166
- :editFields="editFields"
167
- :filters="availableFilters"
168
- multi-sort
169
- can-select-all
170
- searchable
171
- :data.sync="desserts"
172
- :actions="[]"
173
- >
174
- </List>
175
- <br>
176
- <h3> Data: </h3>
177
- <pre>{{ desserts }}</pre>
178
- </v-app>
179
- </template>
180
-
181
- <script>
182
- export default {
183
- data() {
184
- return {
185
- headers: [
186
- {
187
- text: "Dessert (100g serving)",
188
- align: "start",
189
- sortable: false,
190
- value: "name",
191
- },
192
- { text: "Protein (g)", value: "protein" },
193
- { text: "Gluten-Free", value: "glutenfree" },
194
- { text: "Actions", value: "actions", sortable: false },
195
- ],
196
- editFields: [
197
- { attrs: { rules: [(v) => !!v || "Name is required"] }, value: "name" },
198
- { value: "protein" }
199
- ],
200
- availableFilters: [
201
- {
202
- text: "Gluten Free",
203
- value: "glutenfree",
204
- choices: [
205
- { text: "Yes", value: true },
206
- { text: "No", value: false },
207
- ],
208
- },
209
- ],
210
- desserts: [
211
- {
212
- name: "Frozen Yogurt",
213
- protein: 4.0,
214
- glutenfree: true,
215
- },
216
- {
217
- name: "Ice cream sandwich",
218
- protein: 4.3,
219
- glutenfree: false,
220
- },
221
- {
222
- name: "Eclair",
223
- protein: 6.0,
224
- glutenfree: false,
225
- },
226
- {
227
- name: "Jelly bean",
228
- protein: 0.0,
229
- glutenfree: true,
230
- },
231
- {
232
- name: "Lollipop",
233
- protein: 0,
234
- glutenfree: true,
235
- },
236
- {
237
- name: "KitKat",
238
- protein: 7,
239
- glutenfree: false,
240
- },
241
- {
242
- name: "KitKat2",
243
- protein: 77,
244
- glutenfree: false,
245
- },
246
- ],
247
- };
248
- },
249
- };
250
- </script>
251
- :::
252
-
253
-
254
- </docs>
@@ -1,164 +0,0 @@
1
- <template>
2
- <div v-if="isActive" class="d-flex flex-row align-center fill-height">
3
- <v-select
4
- label="Group Actions"
5
- v-bind="$attrs"
6
- v-model="action"
7
- :items="filteredActions"
8
- :item-disabled="isDisabled"
9
- item-text="label"
10
- item-value="handler"
11
- outlined
12
- dense
13
- hide-details
14
- clearable
15
- no-data-text="No actions available"
16
- class="rounded-0"
17
- ></v-select>
18
- <v-btn
19
- class="rounded-0 elevation-0 ml-2"
20
- outlined
21
- color="primary"
22
- :disabled="!action"
23
- @click="handleAction"
24
- >Apply</v-btn
25
- >
26
- </div>
27
- </template>
28
- <script>
29
- /**
30
- * This components renders the select box in the upper-left. This select box contains a list of actions that can be used on a selection of items.
31
- * By default the only action mapo provides is a bulk delete. But with the proper configuration you can do any action you want.
32
- */
33
- export default {
34
- name: "ListActions",
35
- data() {
36
- return {
37
- action: null,
38
- };
39
- },
40
- props: {
41
- // The key used to identify each object passed to the action.
42
- lookup: {
43
- type: String,
44
- default: "id",
45
- },
46
- // This is the main configuration of the component. It contains a list of actions.
47
- actions: {
48
- // [`Array<Action>`](#action-config)
49
- type: Array,
50
- // The bulk delete action.
51
- default() {
52
- return [
53
- {
54
- label: "Permanent delete",
55
- handler: function ({ selection, lookup, crud }) {
56
- return Promise.all(selection.map((i) => crud && crud.delete(i[lookup])));
57
- },
58
- permissions: "delete"
59
- },
60
- ];
61
- },
62
- },
63
- // ❌ This is an internal prop. Sorry..
64
- selection: {
65
- // -
66
- type: [Array, String],
67
- // -
68
- default: () => [],
69
- },
70
- // ❌ This is an internal prop. Sorry..
71
- selectionQuery: {
72
- // -
73
- type: URLSearchParams,
74
- // -
75
- default: () => new URLSearchParams(),
76
- },
77
- // ❌ This is an internal prop. Sorry..
78
- crud: {
79
- // -
80
- type: Object,
81
- required: true,
82
- },
83
- },
84
- computed: {
85
- isActive() {
86
- return this.$attrs["show-select"] !== undefined;
87
- },
88
- filteredActions() {
89
- return this.actions.filter((action) => {
90
- return (this.selection != "all" && (action.handleMultiple ?? true)) || (this.selection == "all" && (action.handleAll ?? false));
91
- });
92
- }
93
- },
94
- methods: {
95
- isDisabled(action){
96
- const p = typeof action.permissions == "string" ? [action.permissions] : action.permissions || []
97
- if (p.length){
98
- return !p.every(a => this.userCan(a))
99
- }
100
- return false
101
- },
102
- userCan(action) {
103
- if (this.$mapo.$auth.routeMiddlewares.includes("permissions")){
104
- return this.$mapo.$auth.user.permissions.includes(action)
105
- }
106
- return true
107
- },
108
- handleAction() {
109
- if (!this.selectAll && !this.selection.length) {
110
- return this.$mapo.$snack.open({
111
- message: "You need to select at least one item.",
112
- color: "error",
113
- });
114
- }
115
- const ctx = {
116
- selection: this.selection,
117
- selectionQuery: this.selectionQuery,
118
- lookup: this.lookup,
119
- crud: this.crud,
120
- };
121
- return this.action
122
- ? this.action(ctx).then((res) => this.$emit("actionCompleted", res))
123
- : () => {};
124
- },
125
- },
126
- };
127
- </script>
128
-
129
- <docs>
130
- ## Action config
131
-
132
-
133
- The actions prop is a list of `Action` objects containing these keys:
134
-
135
- - **"label"** `String` ==> The name of the action that will be renered inside the select button.
136
- - **"handleMultiple"** `Boolean` ==> Make the action callable on multiple items. Default: `true`.
137
- - **"handleAll"** `Boolean` ==> Make the action callable on all items. Default: `false`.
138
- - **"handler"** `Function` ==> The callback function that will be executed once the user confirms the action.
139
- - **"permissions"** `String | Array` ==> The list of permissions needed by the user to perform action in a page with permission middleware
140
-
141
- The handler function will be called with a ctx containing:
142
- - **"selection"** `Array<Object>` or `String` ==> `"all"` if all items are selected else the list of selected objects.
143
- - **"selectionQuery"** `URLSearchParams` ==> GET parameters for the current list of objects.
144
- - **"lookup"** `String` ==> The lookup prop.
145
- - **"crud"** [`Crud`](/core/#api.crud) ==> The inherited crud from [List](../List/) component.
146
-
147
-
148
- ## Example
149
- Here the "bulk delete" action provided by default, you can use it as a basis to write other custom actions:
150
-
151
- ```js
152
- const actions = [
153
- {
154
- label: "Permanent delete",
155
- handler: function ({ selection, lookup, crud }) {
156
- return Promise.all(
157
- selection.map((i) => crud.delete(i[lookup]))
158
- );
159
- },
160
- permissions: "delete"
161
- }
162
- ]
163
- ```
164
- </docs>