glib-web 0.5.77

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 (204) hide show
  1. package/.eslintrc.js +37 -0
  2. package/LICENSE +201 -0
  3. package/README.md +33 -0
  4. package/action.js +167 -0
  5. package/actions/analytics/logEvent.js +26 -0
  6. package/actions/auth/creditCard.js +29 -0
  7. package/actions/auth/restart.js +5 -0
  8. package/actions/auth/saveCsrfToken.js +12 -0
  9. package/actions/cables/push.js +38 -0
  10. package/actions/dialogs/alert.js +15 -0
  11. package/actions/dialogs/close.js +7 -0
  12. package/actions/dialogs/notification.js +14 -0
  13. package/actions/dialogs/oauth.js +6 -0
  14. package/actions/dialogs/open.js +7 -0
  15. package/actions/dialogs/options.js +5 -0
  16. package/actions/dialogs/show.js +5 -0
  17. package/actions/forms/submit.js +15 -0
  18. package/actions/http/delete.js +7 -0
  19. package/actions/http/patch.js +7 -0
  20. package/actions/http/post.js +7 -0
  21. package/actions/http/put.js +7 -0
  22. package/actions/panels/scrollTo.js +18 -0
  23. package/actions/panels/scrollToBottom.js +11 -0
  24. package/actions/runMultiple.js +11 -0
  25. package/actions/sheets/select.js +5 -0
  26. package/actions/snackbars/alert.js +15 -0
  27. package/actions/snackbars/select.js +5 -0
  28. package/actions/timeouts/set.js +20 -0
  29. package/actions/windows/close.js +13 -0
  30. package/actions/windows/closeAll.js +16 -0
  31. package/actions/windows/closeWithReload.js +18 -0
  32. package/actions/windows/open.js +5 -0
  33. package/actions/windows/openWeb.js +5 -0
  34. package/actions/windows/refreshState.js +5 -0
  35. package/actions/windows/reload.js +24 -0
  36. package/actions/ws/push.js +35 -0
  37. package/app.vue +180 -0
  38. package/components/_button.vue +101 -0
  39. package/components/_dropdownMenu.vue +76 -0
  40. package/components/_icon.vue +50 -0
  41. package/components/_message.vue +25 -0
  42. package/components/avatar.vue +16 -0
  43. package/components/banners/alert.vue +49 -0
  44. package/components/banners/select.vue +82 -0
  45. package/components/button.vue +13 -0
  46. package/components/calendar.vue +105 -0
  47. package/components/charts/column.vue +26 -0
  48. package/components/charts/line.vue +61 -0
  49. package/components/chip.vue +24 -0
  50. package/components/component.vue +222 -0
  51. package/components/datetime.vue +54 -0
  52. package/components/fab.vue +33 -0
  53. package/components/fields/_patternText.vue +61 -0
  54. package/components/fields/_select.vue +86 -0
  55. package/components/fields/autocomplete.vue +73 -0
  56. package/components/fields/check.vue +104 -0
  57. package/components/fields/checkGroup.vue +51 -0
  58. package/components/fields/country/countries.js +251 -0
  59. package/components/fields/country/field.vue +81 -0
  60. package/components/fields/country/regions.js +12 -0
  61. package/components/fields/creditCard.vue +105 -0
  62. package/components/fields/date.vue +24 -0
  63. package/components/fields/datetime.vue +49 -0
  64. package/components/fields/dynamicGroup.vue +106 -0
  65. package/components/fields/dynamicSelect.vue +173 -0
  66. package/components/fields/file.vue +166 -0
  67. package/components/fields/googlePlace.vue +158 -0
  68. package/components/fields/hidden.vue +18 -0
  69. package/components/fields/location.vue +223 -0
  70. package/components/fields/newRichText.vue +191 -0
  71. package/components/fields/phone/countries.js +315 -0
  72. package/components/fields/phone/field.vue +348 -0
  73. package/components/fields/phone/sprite.css +1071 -0
  74. package/components/fields/radio.vue +64 -0
  75. package/components/fields/radioGroup.vue +93 -0
  76. package/components/fields/rating.vue +26 -0
  77. package/components/fields/richText.vue +172 -0
  78. package/components/fields/select.vue +17 -0
  79. package/components/fields/stripe/stripeFields.vue +93 -0
  80. package/components/fields/stripe/stripeIndividualFields.vue +207 -0
  81. package/components/fields/stripeExternalAccount.vue +135 -0
  82. package/components/fields/stripeToken.vue +59 -0
  83. package/components/fields/submit.vue +23 -0
  84. package/components/fields/text.vue +144 -0
  85. package/components/fields/textarea.vue +59 -0
  86. package/components/fields/timeZone.vue +22 -0
  87. package/components/fields/timer.vue +83 -0
  88. package/components/h1.vue +28 -0
  89. package/components/h2.vue +20 -0
  90. package/components/h3.vue +22 -0
  91. package/components/h4.vue +20 -0
  92. package/components/h5.vue +20 -0
  93. package/components/h6.vue +20 -0
  94. package/components/hr.vue +13 -0
  95. package/components/html.vue +13 -0
  96. package/components/icon.vue +25 -0
  97. package/components/image.vue +87 -0
  98. package/components/label.vue +62 -0
  99. package/components/map.vue +206 -0
  100. package/components/markdown.vue +52 -0
  101. package/components/mixins/events.js +178 -0
  102. package/components/mixins/generic.js +58 -0
  103. package/components/mixins/list/autoload.js +144 -0
  104. package/components/mixins/longClick.js +56 -0
  105. package/components/mixins/scrolling.js +35 -0
  106. package/components/mixins/styles.js +221 -0
  107. package/components/mixins/table/autoload.js +131 -0
  108. package/components/mixins/table/export.js +52 -0
  109. package/components/mixins/table/import.js +106 -0
  110. package/components/mixins/text.js +20 -0
  111. package/components/mixins/ws/actionCable.js +48 -0
  112. package/components/mixins/ws/phoenixSocket.js +117 -0
  113. package/components/p.vue +36 -0
  114. package/components/panels/carousel.vue +55 -0
  115. package/components/panels/column.vue +117 -0
  116. package/components/panels/custom.vue +52 -0
  117. package/components/panels/flow.vue +81 -0
  118. package/components/panels/form.vue +126 -0
  119. package/components/panels/horizontal.vue +73 -0
  120. package/components/panels/list.vue +241 -0
  121. package/components/panels/responsive.vue +88 -0
  122. package/components/panels/scroll.vue +68 -0
  123. package/components/panels/split.vue +52 -0
  124. package/components/panels/table.vue +234 -0
  125. package/components/panels/ul.vue +34 -0
  126. package/components/panels/vertical.vue +71 -0
  127. package/components/panels/web.vue +11 -0
  128. package/components/spacer.vue +11 -0
  129. package/components/switch.vue +42 -0
  130. package/components/tabBar.vue +44 -0
  131. package/extensions/array.js +20 -0
  132. package/extensions/string.js +21 -0
  133. package/index.js +195 -0
  134. package/keys.js +12 -0
  135. package/nav/appbar.vue +117 -0
  136. package/nav/content.vue +40 -0
  137. package/nav/dialog.vue +127 -0
  138. package/nav/drawer.vue +88 -0
  139. package/nav/drawerButton.vue +28 -0
  140. package/nav/drawerLabel.vue +21 -0
  141. package/nav/sheet.vue +57 -0
  142. package/nav/snackbar.vue +72 -0
  143. package/package.json +42 -0
  144. package/settings.json.example +21 -0
  145. package/static/plugins/alignment/alignment.js +76 -0
  146. package/static/plugins/alignment/alignment.min.js +1 -0
  147. package/static/plugins/beyondgrammar/beyondgrammar.js +46 -0
  148. package/static/plugins/beyondgrammar/beyondgrammar.min.js +1 -0
  149. package/static/plugins/blockcode/blockcode.js +110 -0
  150. package/static/plugins/blockcode/blockcode.min.js +1 -0
  151. package/static/plugins/clips/clips.js +44 -0
  152. package/static/plugins/clips/clips.min.js +1 -0
  153. package/static/plugins/counter/counter.js +60 -0
  154. package/static/plugins/counter/counter.min.js +1 -0
  155. package/static/plugins/definedlinks/definedlinks.js +64 -0
  156. package/static/plugins/definedlinks/definedlinks.min.js +1 -0
  157. package/static/plugins/handle/handle.js +173 -0
  158. package/static/plugins/handle/handle.min.js +1 -0
  159. package/static/plugins/icons/icons.js +72 -0
  160. package/static/plugins/icons/icons.min.js +1 -0
  161. package/static/plugins/imageposition/imageposition.js +85 -0
  162. package/static/plugins/imageposition/imageposition.min.js +1 -0
  163. package/static/plugins/inlineformat/inlineformat.js +85 -0
  164. package/static/plugins/inlineformat/inlineformat.min.js +1 -0
  165. package/static/plugins/removeformat/removeformat.js +28 -0
  166. package/static/plugins/removeformat/removeformat.min.js +1 -0
  167. package/static/plugins/selector/selector.js +96 -0
  168. package/static/plugins/selector/selector.min.js +1 -0
  169. package/static/plugins/specialchars/specialchars.js +63 -0
  170. package/static/plugins/specialchars/specialchars.min.js +1 -0
  171. package/static/plugins/textdirection/textdirection.js +55 -0
  172. package/static/plugins/textdirection/textdirection.min.js +1 -0
  173. package/static/plugins/textexpander/textexpander.js +46 -0
  174. package/static/plugins/textexpander/textexpander.min.js +1 -0
  175. package/static/plugins/underline/underline.js +27 -0
  176. package/static/plugins/underline/underline.min.js +1 -0
  177. package/static/redactorx.css +1344 -0
  178. package/static/redactorx.js +14254 -0
  179. package/static/redactorx.min.css +1 -0
  180. package/static/redactorx.min.js +1 -0
  181. package/static/redactorx.usm.min.js +2 -0
  182. package/styles/test.sass +3 -0
  183. package/styles/test.scss +5 -0
  184. package/templates/_menu.vue +38 -0
  185. package/templates/comment.vue +202 -0
  186. package/templates/featured.vue +32 -0
  187. package/templates/thumbnail.vue +138 -0
  188. package/templates/unsupported.vue +12 -0
  189. package/utils/app.js +14 -0
  190. package/utils/dom.js +13 -0
  191. package/utils/form.js +34 -0
  192. package/utils/format.js +14 -0
  193. package/utils/hash.js +29 -0
  194. package/utils/helper.js +44 -0
  195. package/utils/history.js +70 -0
  196. package/utils/http.js +209 -0
  197. package/utils/launch.js +135 -0
  198. package/utils/private/ws.js +22 -0
  199. package/utils/public.js +23 -0
  200. package/utils/settings.js +48 -0
  201. package/utils/storage.js +9 -0
  202. package/utils/type.js +69 -0
  203. package/utils/uploader.js +121 -0
  204. package/utils/url.js +132 -0
@@ -0,0 +1,106 @@
1
+ export default {
2
+ data: function() {
3
+ return {
4
+ importable: false,
5
+ importSubmitUrl: null,
6
+ importParamName: "row"
7
+ };
8
+ },
9
+ methods: {
10
+ initCsvImport() {
11
+ const vm = this;
12
+ Utils.type.ifObject(this.spec.import, obj => {
13
+ vm.importable = true;
14
+ vm.importSubmitUrl = obj.submitUrl;
15
+ vm.importParamName = obj.paramName;
16
+ });
17
+ },
18
+ submitRows(event, section) {
19
+ const vm = this;
20
+ const keys = section.header.dataCells;
21
+ const rows = [];
22
+ section.dataRows.forEach(row => {
23
+ const cells = {};
24
+ row.forEach((cell, index) => {
25
+ const key = `${vm.importParamName}[${keys[index]}]`;
26
+ cells[key] = cell;
27
+ });
28
+ rows.push(cells);
29
+ });
30
+
31
+ if (Utils.type.isString(this.importSubmitUrl)) {
32
+ vm._submitEachRow(rows, event.target);
33
+ }
34
+ },
35
+ _submitEachRow(rows, target) {
36
+ const vm = this;
37
+ const row = rows.shift();
38
+ if (row) {
39
+ const data = {
40
+ url: this.importSubmitUrl,
41
+ formData: row
42
+ };
43
+ Utils.http.execute(data, "POST", vm, response => {
44
+ GLib.action.handleResponse(response, vm);
45
+ // Action.execute(response["onResponse"], target, vm);
46
+ vm._submitEachRow(rows, target);
47
+ });
48
+ }
49
+ },
50
+ loadFile(event, section) {
51
+ const reader = new FileReader();
52
+ reader.readAsText(event.target.files[0]);
53
+ reader.onload = e => {
54
+ const rows = this._parseCsv(e.target.result);
55
+ section.header.dataCells = rows.shift().map(cell => {
56
+ return cell.trim();
57
+ });
58
+ section.dataRows = rows;
59
+ };
60
+
61
+ // Reset value so it will trigger again the next time the same file is selected.
62
+ event.target.value = null;
63
+ },
64
+ _parseCsv: function(csvString) {
65
+ // https://stackoverflow.com/a/41563966/9970813
66
+ let prevLetter = "",
67
+ row = [""],
68
+ result = [row],
69
+ columnIndex = 0,
70
+ rowIndex = 0,
71
+ canSplit = true,
72
+ letter;
73
+ for (let i = 0; i <= csvString.length; ++i) {
74
+ letter = csvString[i];
75
+
76
+ if ('"' === letter) {
77
+ if (canSplit && letter === prevLetter) {
78
+ row[columnIndex] += letter;
79
+ }
80
+ canSplit = !canSplit;
81
+ } else if ("," === letter && canSplit) {
82
+ letter = row[++columnIndex] = "";
83
+ } else if ("\n" === letter && canSplit) {
84
+ if ("\r" === prevLetter) {
85
+ row[columnIndex] = row[columnIndex].slice(0, -1);
86
+ }
87
+ row = result[++rowIndex] = [(letter = "")];
88
+ columnIndex = 0;
89
+ } else if (Utils.type.isString(letter)) {
90
+ row[columnIndex] += letter;
91
+ }
92
+ prevLetter = letter;
93
+ }
94
+
95
+ // Remove any blank rows
96
+ result = result.filter(r => {
97
+ return r[0] !== "";
98
+ });
99
+ // result = result.filter(r => {
100
+ // return r[0] !== "undefined"
101
+ // });
102
+
103
+ return result;
104
+ }
105
+ }
106
+ };
@@ -0,0 +1,20 @@
1
+ export default {
2
+ methods: {
3
+ textStyles(spec) {
4
+ const styles = this.$styles(spec);
5
+
6
+ switch (this.spec.textAlign) {
7
+ case "center":
8
+ styles["text-align"] = "center";
9
+ break;
10
+ case "right":
11
+ styles["text-align"] = "right";
12
+ break;
13
+ default:
14
+ styles["text-align"] = "left";
15
+ }
16
+
17
+ return styles;
18
+ }
19
+ }
20
+ };
@@ -0,0 +1,48 @@
1
+ import { createConsumer } from "@rails/actioncable";
2
+
3
+ const consumer = createConsumer();
4
+
5
+ export default {
6
+ data: function() {
7
+ return {
8
+ _wsSocket: null
9
+ };
10
+ },
11
+ methods: {
12
+ $wsInitActionCable(spec) {
13
+ const component = this;
14
+ Utils.type.ifObject(
15
+ spec,
16
+ ws => {
17
+ const channelName = ws.channel;
18
+ const subscription = Object.assign({}, ws.params, {
19
+ channel: channelName
20
+ });
21
+
22
+ console.log("Connecting to channel", subscription);
23
+
24
+ consumer.subscriptions.create(subscription, {
25
+ connected() {
26
+ const ws = window.vueApp.actionCable;
27
+ ws.channels[channelName] = this;
28
+ console.log("Connected to channel", channelName);
29
+ },
30
+
31
+ disconnected() {},
32
+
33
+ received(data) {
34
+ const action = data.action;
35
+ const payload = { ...action, filterKey: ws.filterKey };
36
+ if (ws.filterKey === data.filterKey) {
37
+ GLib.action.execute(payload, null, component);
38
+ }
39
+ }
40
+ });
41
+ },
42
+ () => {
43
+ // this._wsDisconnectSocket();
44
+ }
45
+ );
46
+ }
47
+ }
48
+ };
@@ -0,0 +1,117 @@
1
+ import { Socket } from "phoenix";
2
+ import Hash from "../../../utils/hash";
3
+
4
+ export default {
5
+ data: function() {
6
+ return {
7
+ _wsSocket: null
8
+ };
9
+ },
10
+ methods: {
11
+ $wsInitPhoenixSocket(spec) {
12
+ Utils.type.ifObject(
13
+ spec,
14
+ ws => {
15
+ console.log("Connecting socket...");
16
+ Utils.launch.snackbar.indicator("Connecting...");
17
+ Utils.http.startIndicator(this);
18
+
19
+ // Without this, at times the indicator doesn't disappear because there isn't enough delay
20
+ // between startIndicator() and stopIndicator()
21
+ setTimeout(() => {
22
+ this._wsConnectSocket(ws);
23
+ }, 100);
24
+ },
25
+ () => {
26
+ this._wsDisconnectSocket();
27
+ }
28
+ );
29
+ },
30
+ // https://medium.com/@imiked/real-time-feature-with-phoenix-and-vue-js-c7677663a6f5
31
+ _wsConnectSocket(spec) {
32
+ const host = Utils.settings.isDev
33
+ ? "ws://localhost:4019"
34
+ : "wss://prod.com";
35
+
36
+ // const host = Utils.settings.isDev
37
+ // ? "ws://192.168.1.109:4019"
38
+ // : "wss://prod.com";
39
+
40
+ // const url = Utils.url.appendParams(
41
+ // `${host}${conf.endpoint}?`,
42
+ // conf.params
43
+ // );
44
+
45
+ const conf = spec.socket;
46
+ // See https://github.com/phoenixframework/phoenix/blob/master/assets/js/phoenix.js
47
+ const endpoint = `${host}${conf.endpoint}`.replace(/\/websocket$/, "");
48
+ const params = new Hash(conf.params);
49
+ const version = params.remove("vsn");
50
+ const socket = new Socket(endpoint, {
51
+ params: params,
52
+ vsn: version
53
+ });
54
+
55
+ this._wsSocket = socket;
56
+ socket.onOpen(() => {
57
+ console.log("Connected socket");
58
+ this._wsJoinChannel(socket, spec);
59
+ Utils.http.stopIndicator(this);
60
+ });
61
+ socket.onError(() => {
62
+ // Start the indicator again because this can trigger even after successfully connected.
63
+ Utils.http.startIndicator(this);
64
+ console.log("Unable to connect socket");
65
+ });
66
+ socket.connect();
67
+ },
68
+ _wsJoinChannel(socket, spec) {
69
+ const ws = window.vueApp.webSocket;
70
+ Utils.type.ifObject(spec.header, header => {
71
+ ws.header = header;
72
+ });
73
+
74
+ const topicName = spec.topic;
75
+ const events = spec.events;
76
+ if (!Utils.type.isString(topicName) || !Utils.type.isArray(events)) {
77
+ return;
78
+ }
79
+
80
+ const channel = socket.channel(topicName, {});
81
+
82
+ for (const eventName of events) {
83
+ console.log(`Registering event '${eventName}'`);
84
+ channel.on(eventName, payload => {
85
+ console.debug(`Received '${eventName}' event`, payload);
86
+ Utils.ws.handleResponse(payload.onResponse, this);
87
+ });
88
+ }
89
+
90
+ channel
91
+ .join()
92
+ .receive("ok", resp => {
93
+ console.log(`Channel joined '${topicName}'`, resp);
94
+ ws.channels[topicName] = channel;
95
+ })
96
+ .receive("error", resp => {
97
+ console.log(`Unable to join channel '${topicName}'`, resp);
98
+ Utils.launch.snackbar.error("Unable to connect. Please try again.");
99
+ });
100
+ },
101
+ _wsDisconnectSocket() {
102
+ if (this._wsSocket) {
103
+ console.log("Disconnecting socket");
104
+ // Sometimes this doesn't prevent errorneous socket from trying to reconnect. In this case,
105
+ // the socket will keep attempting to connect.
106
+ this._wsSocket.disconnect();
107
+ this._wsSocket = null;
108
+
109
+ const ws = window.vueApp.webSocket;
110
+ ws.channels = {};
111
+ ws.header = {};
112
+
113
+ Utils.http.stopIndicator(this);
114
+ }
115
+ }
116
+ }
117
+ };
@@ -0,0 +1,36 @@
1
+ <template>
2
+ <!-- <p :style="genericStyles()" :class="$classes()" v-html="compiledText" /> -->
3
+ <p :style="genericStyles()" :class="$classes()">{{ spec.text }}</p>
4
+ </template>
5
+
6
+ <script>
7
+ // import marked from "marked";
8
+
9
+ export default {
10
+ props: {
11
+ spec: { type: Object, required: true }
12
+ }
13
+ // computed: {
14
+ // compiledText() {
15
+ // if (this.spec.format == "markdown") {
16
+ // return marked(this.spec.text, { sanitize: true });
17
+ // } else {
18
+ // return this.spec.text;
19
+ // }
20
+ // }
21
+ // }
22
+ };
23
+ </script>
24
+
25
+ <style scoped>
26
+ p {
27
+ white-space: pre-line;
28
+
29
+ /* Without this, padding-top doesn't work */
30
+ display: inline-block;
31
+ margin-bottom: 0;
32
+ }
33
+ p.muted {
34
+ opacity: 0.7;
35
+ }
36
+ </style>
@@ -0,0 +1,55 @@
1
+ <template>
2
+ <v-card flat tile :style="$styles()">
3
+ <v-window v-model="selectedIndex">
4
+ <v-window-item v-for="(item, index) in spec.childViews" :key="index">
5
+ <ui-component :spec="item" />
6
+ </v-window-item>
7
+ </v-window>
8
+
9
+ <v-card-actions class="justify-space-between">
10
+ <v-btn text @click="prev">
11
+ <v-icon>chevron_left</v-icon>
12
+ </v-btn>
13
+ <v-item-group v-model="selectedIndex" class="text-center" mandatory>
14
+ <v-item v-for="(item, index) in spec.childViews" :key="index">
15
+ <v-btn
16
+ slot-scope="{ active, toggle }"
17
+ :input-value="active"
18
+ icon
19
+ @click="toggle"
20
+ >
21
+ <v-icon size="8">lens</v-icon>
22
+ </v-btn>
23
+ </v-item>
24
+ </v-item-group>
25
+ <v-btn text @click="next">
26
+ <v-icon>chevron_right</v-icon>
27
+ </v-btn>
28
+ </v-card-actions>
29
+ </v-card>
30
+ </template>
31
+
32
+ <script>
33
+ export default {
34
+ props: {
35
+ spec: { type: Object, required: true }
36
+ },
37
+ data: () => ({
38
+ selectedIndex: 0
39
+ }),
40
+ methods: {
41
+ next() {
42
+ const length = this.spec.childViews.length;
43
+ this.selectedIndex =
44
+ this.selectedIndex + 1 === length ? 0 : this.selectedIndex + 1;
45
+ },
46
+ prev() {
47
+ const length = this.spec.childViews.length;
48
+ this.selectedIndex =
49
+ this.selectedIndex - 1 < 0 ? length - 1 : this.selectedIndex - 1;
50
+ }
51
+ }
52
+ };
53
+ </script>
54
+
55
+ <style scoped></style>
@@ -0,0 +1,117 @@
1
+ <template>
2
+ <v-col
3
+ :xl="xl.cols"
4
+ :lg="lg.cols"
5
+ :md="md.cols"
6
+ :sm="sm.cols"
7
+ :style="cssStyles()"
8
+ cols="12"
9
+ >
10
+ <panels-responsive :spec="spec" />
11
+ </v-col>
12
+ </template>
13
+
14
+ <script>
15
+ export default {
16
+ props: {
17
+ spec: { type: Object, required: true }
18
+ },
19
+ data() {
20
+ return {
21
+ xl: {},
22
+ lg: {},
23
+ md: {},
24
+ sm: {},
25
+ xs: {}
26
+ };
27
+ },
28
+ methods: {
29
+ $ready() {
30
+ this.xl = this.spec.xl || this.xl;
31
+ this.lg = this.spec.lg || this.lg;
32
+ this.md = this.spec.md || this.md;
33
+ this.sm = this.spec.sm || this.sm;
34
+ this.xs = this.spec.xs || this.xs;
35
+ },
36
+ cssStyles() {
37
+ const styles = this.$styles();
38
+ switch (this.$vuetify.breakpoint.name) {
39
+ case "xl":
40
+ this.applyStyles(styles, this.xs);
41
+ this.applyStyles(styles, this.sm);
42
+ this.applyStyles(styles, this.md);
43
+ this.applyStyles(styles, this.lg);
44
+ this.applyStyles(styles, this.xl);
45
+ this.applyStyles(styles, this.spec.xlAndDown || {});
46
+ this.applyStyles(styles, this.spec.xlOnly || {});
47
+ break;
48
+ case "lg":
49
+ this.applyStyles(styles, this.xs);
50
+ this.applyStyles(styles, this.sm);
51
+ this.applyStyles(styles, this.md);
52
+ this.applyStyles(styles, this.lg);
53
+ this.applyStyles(styles, this.spec.xlAndDown || {});
54
+ this.applyStyles(styles, this.spec.lgAndDown || {});
55
+ this.applyStyles(styles, this.spec.lgOnly || {});
56
+ break;
57
+ case "md":
58
+ this.applyStyles(styles, this.xs);
59
+ this.applyStyles(styles, this.sm);
60
+ this.applyStyles(styles, this.md);
61
+ this.applyStyles(styles, this.spec.xlAndDown || {});
62
+ this.applyStyles(styles, this.spec.lgAndDown || {});
63
+ this.applyStyles(styles, this.spec.mdAndDown || {});
64
+ this.applyStyles(styles, this.spec.mdOnly || {});
65
+ break;
66
+ case "sm":
67
+ this.applyStyles(styles, this.xs);
68
+ this.applyStyles(styles, this.sm);
69
+ this.applyStyles(styles, this.spec.xlAndDown || {});
70
+ this.applyStyles(styles, this.spec.lgAndDown || {});
71
+ this.applyStyles(styles, this.spec.mdAndDown || {});
72
+ this.applyStyles(styles, this.spec.smAndDown || {});
73
+ this.applyStyles(styles, this.spec.smOnly || {});
74
+ break;
75
+ case "xs":
76
+ this.applyStyles(styles, this.xs);
77
+ this.applyStyles(styles, this.spec.xlAndDown || {});
78
+ this.applyStyles(styles, this.spec.lgAndDown || {});
79
+ this.applyStyles(styles, this.spec.mdAndDown || {});
80
+ this.applyStyles(styles, this.spec.smAndDown || {});
81
+ this.applyStyles(styles, this.spec.xsAndDown || {});
82
+ this.applyStyles(styles, this.spec.xsOnly || {});
83
+ break;
84
+
85
+ // const padding = this.lg.padding;
86
+ // Utils.type.ifObject(this.lg.padding, padding => {
87
+ // Utils.type.ifNumber(
88
+ // padding.top,
89
+ // top => (styles["padding-top"] = `${top}px`)
90
+ // );
91
+ // Utils.type.ifNumber(
92
+ // padding.bottom,
93
+ // bottom => (styles["padding-bottom"] = `${bottom}px`)
94
+ // );
95
+ // Utils.type.ifNumber(
96
+ // padding.left,
97
+ // left => (styles["padding-left"] = `${left}px`)
98
+ // );
99
+ // Utils.type.ifNumber(
100
+ // padding.right,
101
+ // right => (styles["padding-right"] = `${right}px`)
102
+ // );
103
+ // });
104
+ }
105
+ return styles;
106
+ },
107
+ applyStyles(styles, spec) {
108
+ Object.assign(styles, this.$styles(spec));
109
+ Utils.type.ifBoolean(spec.hide, () => {
110
+ styles["display"] = "none";
111
+ });
112
+ }
113
+ }
114
+ };
115
+ </script>
116
+
117
+ <style scoped></style>
@@ -0,0 +1,52 @@
1
+ <template>
2
+ <div :style="genericStyles()">
3
+ <component
4
+ :is="template"
5
+ v-if="customData"
6
+ :name="spec.template"
7
+ :spec="customData"
8
+ />
9
+ </div>
10
+ </template>
11
+
12
+ <script>
13
+ import UnsupportedTemplate from "../../templates/unsupported";
14
+ import ThumbnailTemplate from "../../templates/thumbnail";
15
+ import FeaturedTemplate from "../../templates/featured";
16
+
17
+ export default {
18
+ components: {
19
+ "template-thumbnail": ThumbnailTemplate,
20
+ "template-featured": FeaturedTemplate,
21
+ "template-unsupported": UnsupportedTemplate
22
+ },
23
+ props: {
24
+ spec: { type: Object, required: true }
25
+ },
26
+ data() {
27
+ return {
28
+ customData: null
29
+ };
30
+ },
31
+ computed: {
32
+ template() {
33
+ const name = `template-${this.spec.template.replace("/", "-")}`;
34
+ const strict = false;
35
+ if (strict) {
36
+ return name;
37
+ } else {
38
+ if (this.$options.components[name]) {
39
+ return name;
40
+ }
41
+ return "template-unsupported";
42
+ }
43
+ }
44
+ },
45
+ methods: {
46
+ $ready() {
47
+ const onClick = this.spec.onClick ? { onClick: this.spec.onClick } : {};
48
+ this.customData = Object.assign(onClick, this.spec.data);
49
+ }
50
+ }
51
+ };
52
+ </script>
@@ -0,0 +1,81 @@
1
+ <template>
2
+ <div :class="cssClasses" :style="cssStyles">
3
+ <template v-for="(item, index) in spec.childViews">
4
+ <!--
5
+ The wrapper prevents its content (e.g. image component) from getting stretched to fill
6
+ remaining space on the new line.
7
+ -->
8
+ <div :key="index" :style="innerStyles">
9
+ <ui-component :spec="item" />
10
+ </div>
11
+ </template>
12
+ </div>
13
+ </template>
14
+
15
+ <script>
16
+ export default {
17
+ props: {
18
+ spec: { type: Object, required: true }
19
+ },
20
+ computed: {
21
+ cssClasses: function() {
22
+ const classes = this.$classes().concat("layouts-flow");
23
+ // switch(this.spec.distribution) {
24
+ // case 'fillEqually':
25
+ // classes.push('layouts-horizontal--fill-equally')
26
+ // break
27
+ // case 'spaceEqually':
28
+ // classes.push('layouts-horizontal--space-equally')
29
+ // break
30
+ // }
31
+ return classes;
32
+ },
33
+ cssStyles: function() {
34
+ const styles = this.$styles();
35
+ // switch(this.spec.align) {
36
+ // case 'middle':
37
+ // styles['align-items'] = 'center'
38
+ // break
39
+ // case 'bottom':
40
+ // styles['align-items'] = 'flex-end'
41
+ // break
42
+ // default:
43
+ // styles['align-items'] = 'flex-start'
44
+ // }
45
+ return styles;
46
+ },
47
+ innerStyles() {
48
+ const styles = {};
49
+ Utils.type.ifObject(this.spec.innerPadding, padding => {
50
+ Utils.type.ifNumber(
51
+ padding.top,
52
+ top => (styles["padding-top"] = `${top}px`)
53
+ );
54
+ Utils.type.ifNumber(
55
+ padding.bottom,
56
+ bottom => (styles["padding-bottom"] = `${bottom}px`)
57
+ );
58
+ Utils.type.ifNumber(
59
+ padding.left,
60
+ left => (styles["padding-left"] = `${left}px`)
61
+ );
62
+ Utils.type.ifNumber(
63
+ padding.right,
64
+ right => (styles["padding-right"] = `${right}px`)
65
+ );
66
+ });
67
+ return styles;
68
+ }
69
+ }
70
+ };
71
+ </script>
72
+
73
+ <style lang="scss" scoped>
74
+ .layouts-flow {
75
+ display: flex;
76
+ flex-wrap: wrap;
77
+ }
78
+ /* .layouts-horizontal > div {
79
+ display: inline-block;
80
+ } */
81
+ </style>