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,234 @@
1
+ <template>
2
+ <div class="scrollable">
3
+ <div ref="topAnchor"></div>
4
+
5
+ <table :style="$styles()">
6
+ <template v-for="(section, sectionIndex) in sections">
7
+ <thead :key="`head_${sectionIndex}`">
8
+ <tr v-if="importable || exportable">
9
+ <td colspan="10">
10
+ <div class="pa-3">
11
+ <template v-if="importable">
12
+ <span
13
+ >{{
14
+ rows(section).length + section.dataRows.length
15
+ }}
16
+ rows</span
17
+ >
18
+ <input
19
+ ref="fileInput"
20
+ style="display: none;"
21
+ type="file"
22
+ accept=".csv"
23
+ @change="loadFile($event, section)"
24
+ />
25
+ <v-btn @click="triggerImport(sectionIndex)">Import</v-btn>
26
+ <v-btn
27
+ :disabled="totalRows(section) <= 0"
28
+ @click="submitRows($event, section)"
29
+ >Save</v-btn
30
+ >
31
+ <v-btn
32
+ :disabled="totalRows(section) <= 0"
33
+ @click="clear(section)"
34
+ >Clear</v-btn
35
+ >
36
+ </template>
37
+
38
+ <div class="float-right">
39
+ <v-btn
40
+ v-if="exportable"
41
+ :download="exportFile"
42
+ :href="exportCsv(section)"
43
+ >{{ exportLabel }}</v-btn
44
+ >
45
+ </div>
46
+ </div>
47
+
48
+ <div v-if="output" style="white-space: pre-line;">
49
+ {{ output }}
50
+ </div>
51
+ </td>
52
+ </tr>
53
+
54
+ <tr v-if="section.header" :style="genericStyles(section.header)">
55
+ <template v-if="section.header.dataCells">
56
+ <th
57
+ v-for="(cell, index) in section.header.dataCells"
58
+ :key="index"
59
+ >
60
+ {{ cell }}
61
+ </th>
62
+ </template>
63
+ <th
64
+ v-for="(cell, index) in section.header.cellViews"
65
+ v-else
66
+ :key="index"
67
+ >
68
+ <ui-component :spec="cell" />
69
+ </th>
70
+ </tr>
71
+ </thead>
72
+
73
+ <tbody :key="`body_${sectionIndex}`">
74
+ <!-- <tr v-for="(row, index) in section.rows" :key="`row_${index}`"> -->
75
+ <template v-for="(row, rowIndex) in section.rows">
76
+ <tr
77
+ :key="`row_${rowIndex}`"
78
+ :class="row.onClick ? 'clickable' : ''"
79
+ >
80
+ <td
81
+ v-for="(cell, cellIndex) in row.cellViews"
82
+ :key="`cell_${cellIndex}`"
83
+ :colSpan="colSpan(row, cellIndex)"
84
+ :style="colStyles(row, cellIndex)"
85
+ >
86
+ <!-- Prevent double links -->
87
+ <ui-component v-if="$href(cell)" :spec="cell" />
88
+ <a v-else :href="$href(row)" @click="$onClick($event, row)">
89
+ <ui-component :spec="cell" />
90
+ </a>
91
+ </td>
92
+ </tr>
93
+ </template>
94
+
95
+ <tr
96
+ v-for="(row, rowIndex) in section.dataRows"
97
+ :key="`data_row_${rowIndex}`"
98
+ >
99
+ <td
100
+ v-for="(cell, cellIndex) in row"
101
+ :key="`data_cell_${cellIndex}`"
102
+ >
103
+ <a class="data-cell">{{ cell }}</a>
104
+ </td>
105
+ </tr>
106
+ </tbody>
107
+ </template>
108
+ </table>
109
+
110
+ <div ref="bottomAnchor" class="py-3 px-6" :style="bottomAnchorStyles">
111
+ Loading...
112
+ </div>
113
+ </div>
114
+ </template>
115
+
116
+ <script>
117
+ import autoloadMixin from "../mixins/table/autoload.js";
118
+ import exportMixin from "../mixins/table/export.js";
119
+ import importMixin from "../mixins/table/import.js";
120
+
121
+ export default {
122
+ mixins: [autoloadMixin, exportMixin, importMixin],
123
+ props: {
124
+ spec: { type: Object, required: true }
125
+ },
126
+ data() {
127
+ return {
128
+ sections: []
129
+ };
130
+ },
131
+ computed: {
132
+ output() {
133
+ // let str = ""
134
+ // let count = 0
135
+ // for (const section of this.sections) {
136
+ // for (const row of section.dataRows) {
137
+ // const name = row[2]
138
+ // const email = row[3]
139
+ // const createdAt = row[5]
140
+ // const activationState = row[14] ? 'active' : 'pending'
141
+ // count += 1
142
+ // if (email.includes("'")) {
143
+ // console.log("INVALID NAME", name)
144
+ // }
145
+ // str += `{ name: "${name}".to_s, email: '${email}'.to_s, created_at: '${createdAt}', activation_state: '${activationState}'},\n`
146
+ // }
147
+ // }
148
+ // return `Processing ${count} rows:\n[\n${str}\n]`
149
+ return "";
150
+ }
151
+ },
152
+ methods: {
153
+ $ready() {
154
+ this.sections = this.spec.sections;
155
+ for (const section of this.sections) {
156
+ section.header = section.header || {};
157
+ // Use $set() to bind the nested property
158
+ this.$set(section, "dataRows", []);
159
+ }
160
+ this.autoloadAll(this.spec.nextPage);
161
+ this.initCsvExport();
162
+ this.initCsvImport();
163
+ this.enableInfiniteScrollIfApplicable();
164
+ },
165
+ $tearDown() {
166
+ this.cancelAutoloadRequest();
167
+ },
168
+ clear(section) {
169
+ section.rows = [];
170
+ section.dataRows = [];
171
+ },
172
+ colSpan(row, index) {
173
+ const spans = row.colSpans || [];
174
+ return spans[index] || 1;
175
+ },
176
+ colStyles(row, index) {
177
+ const colStyles = row.colStyles || [];
178
+ return this.$styles(colStyles[index] || {});
179
+ },
180
+ rows(section) {
181
+ return section.rows || [];
182
+ },
183
+ triggerImport(index) {
184
+ const input = this.$refs.fileInput[index];
185
+ input.click();
186
+ },
187
+ totalRows(section) {
188
+ return (section.rows || []).length + (section.dataRows || []).length;
189
+ }
190
+ }
191
+ };
192
+ </script>
193
+
194
+ <style lang="scss" scoped>
195
+ table {
196
+ border-spacing: 0;
197
+ }
198
+ thead {
199
+ th {
200
+ padding: 10px 4px;
201
+ border-top: 1px solid rgba(0, 0, 0, 0.12);
202
+ // border-left: 1px solid rgba(0, 0, 0, 0.12);
203
+ }
204
+ }
205
+ tbody {
206
+ tr.clickable {
207
+ td > a {
208
+ cursor: pointer;
209
+ }
210
+ &:hover {
211
+ background: #eee;
212
+ }
213
+ }
214
+
215
+ td {
216
+ border-top: 1px solid rgba(0, 0, 0, 0.12);
217
+ // border-left: 1px solid rgba(0, 0, 0, 0.12);
218
+
219
+ a {
220
+ padding: 10px 24px;
221
+ display: block;
222
+ color: inherit;
223
+ cursor: default;
224
+ }
225
+ }
226
+ }
227
+ .scrollable {
228
+ width: 100%;
229
+ overflow: auto;
230
+ }
231
+ .data-cell {
232
+ white-space: pre-line;
233
+ }
234
+ </style>
@@ -0,0 +1,34 @@
1
+ <template>
2
+ <ul :style="$styles()" :class="$classes()">
3
+ <!-- Use view name for key to avoid component reuse issue -->
4
+ <li v-for="(item, index) in spec.childViews" :key="`${index}_${item.view}`">
5
+ <ui-component :spec="item" />
6
+ </li>
7
+ </ul>
8
+ </template>
9
+
10
+ <script>
11
+ export default {
12
+ props: {
13
+ spec: { type: Object, required: true }
14
+ }
15
+ };
16
+ </script>
17
+
18
+ <style lang="scss" scoped>
19
+ // TODO: Need responsive support for mobile screens.
20
+ ul.breadcrumbs {
21
+ padding-left: 0px;
22
+ list-style: none;
23
+
24
+ li {
25
+ display: inline;
26
+ }
27
+
28
+ li + li:before {
29
+ padding: 4px 4px 4px 8px;
30
+ color: black;
31
+ content: "/\00a0";
32
+ }
33
+ }
34
+ </style>
@@ -0,0 +1,71 @@
1
+ <template>
2
+ <div :class="cssClasses" :style="cssStyles" @click="$onClick()">
3
+ <template v-for="(item, index) in spec.childViews">
4
+ <!-- Use view name for key to avoid component reuse issue -->
5
+ <ui-component :key="`${index}_${item.view}`" :spec="item" />
6
+ </template>
7
+ </div>
8
+ </template>
9
+
10
+ <script>
11
+ export default {
12
+ props: {
13
+ spec: { type: Object, required: true }
14
+ },
15
+ computed: {
16
+ cssClasses: function() {
17
+ // TODO: Remove this after migrating to `panels/responsive`
18
+ // Vertical panels are nameless when used in predefined layout (e.g. page.body, list.header, etc.)
19
+ this.spec.view = this.spec.view || "panels/vertical";
20
+
21
+ const classes = this.$classes().concat("layouts-vertical");
22
+ switch (this.spec.distribution) {
23
+ case "fillEqually":
24
+ classes.push("layouts-vertical--fill-equally");
25
+ break;
26
+ case "spaceEqually":
27
+ classes.push("layouts-vertical--space-equally");
28
+ break;
29
+ }
30
+ return classes;
31
+ },
32
+ cssStyles: function() {
33
+ const styles = this.genericStyles();
34
+ switch (this.spec.align) {
35
+ case "center":
36
+ styles["align-items"] = "center";
37
+ break;
38
+ case "right":
39
+ styles["align-items"] = "flex-end";
40
+ break;
41
+ default:
42
+ styles["align-items"] = "flex-start";
43
+ }
44
+ return styles;
45
+ }
46
+ }
47
+ };
48
+ </script>
49
+
50
+ <style scoped>
51
+ .layouts-vertical {
52
+ display: flex;
53
+ /* overflow: hidden; */
54
+ flex-direction: column;
55
+ }
56
+
57
+ /* From https://stackoverflow.com/questions/13483331/make-buttons-same-width-without-specifying-exact-size */
58
+ .layouts-vertical--space-equally {
59
+ justify-content: space-around;
60
+ }
61
+ </style>
62
+
63
+ <style>
64
+ .layouts-vertical--fill-equally > * {
65
+ flex: initial;
66
+ height: 100% !important;
67
+ }
68
+ .layouts-vertical--space-equally > * {
69
+ flex: initial;
70
+ }
71
+ </style>
@@ -0,0 +1,11 @@
1
+ <template>
2
+ <iframe :style="$styles()" :src="spec.url"></iframe>
3
+ </template>
4
+
5
+ <script>
6
+ export default {
7
+ props: {
8
+ spec: { type: Object, required: true }
9
+ }
10
+ };
11
+ </script>
@@ -0,0 +1,11 @@
1
+ <template>
2
+ <div :style="genericStyles()"></div>
3
+ </template>
4
+
5
+ <script>
6
+ export default {
7
+ props: {
8
+ spec: { type: Object, required: true }
9
+ }
10
+ };
11
+ </script>
@@ -0,0 +1,42 @@
1
+ <template>
2
+ <div :class="$classes()">
3
+ <v-switch
4
+ v-model="enabled"
5
+ :label="spec.text"
6
+ hide-details
7
+ @change="changed"
8
+ >
9
+ </v-switch>
10
+ </div>
11
+ </template>
12
+
13
+ <script>
14
+ export default {
15
+ props: {
16
+ spec: { type: Object, required: true }
17
+ },
18
+ data() {
19
+ return {
20
+ enabled: false
21
+ };
22
+ },
23
+ methods: {
24
+ $ready() {
25
+ this.enabled = this.spec.enabled;
26
+ },
27
+ changed() {
28
+ if (this.enabled) {
29
+ GLib.action.execute(this.spec.onEnabled, {}, this);
30
+ } else {
31
+ GLib.action.execute(this.spec.onDisabled, {}, this);
32
+ }
33
+ }
34
+ }
35
+ };
36
+ </script>
37
+
38
+ <style scoped>
39
+ .v-input--selection-controls {
40
+ margin-top: 0;
41
+ }
42
+ </style>
@@ -0,0 +1,44 @@
1
+ <template>
2
+ <v-tabs
3
+ v-model="tab"
4
+ grow
5
+ show-arrows
6
+ :background-color="spec.backgroundColor"
7
+ :slider-color="spec.color"
8
+ :style="'width: 100%'"
9
+ >
10
+ <v-tab
11
+ v-for="(item, index) in spec.buttons"
12
+ :key="index"
13
+ :href="$href(item)"
14
+ @click="$onClick($event, item)"
15
+ >
16
+ <common-icon v-if="item.icon" :spec="item.icon" />
17
+ <span :style="{ color: spec.color }">{{ item.text }}</span>
18
+ </v-tab>
19
+ </v-tabs>
20
+ </template>
21
+
22
+ <script>
23
+ export default {
24
+ props: {
25
+ spec: { type: Object, required: true }
26
+ },
27
+ data() {
28
+ return {
29
+ tab: null,
30
+ buttons: null
31
+ };
32
+ },
33
+ methods: {
34
+ $ready() {
35
+ this.buttons = this.spec.tabButtons || this.spec.buttons;
36
+ for (const [index, button] of this.buttons.entries()) {
37
+ if (button.disabled) {
38
+ this.tab = this.$href(button);
39
+ }
40
+ }
41
+ }
42
+ }
43
+ };
44
+ </script>
@@ -0,0 +1,20 @@
1
+ Array.prototype.remove = function(element) {
2
+ const index = this.indexOf(element);
3
+ if (index !== -1) {
4
+ this.splice(index, 1);
5
+ return true;
6
+ }
7
+ return false;
8
+ };
9
+
10
+ Array.prototype.clear = function() {
11
+ this.length = 0;
12
+ };
13
+
14
+ Array.prototype.first = function() {
15
+ return this[0];
16
+ };
17
+
18
+ Array.prototype.last = function() {
19
+ return this[this.length - 1];
20
+ };
@@ -0,0 +1,21 @@
1
+ // https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
2
+ String.prototype.hashCode = function() {
3
+ var hash = 0,
4
+ i,
5
+ chr;
6
+ if (this.length === 0) return hash;
7
+ for (i = 0; i < this.length; i++) {
8
+ chr = this.charCodeAt(i);
9
+ hash = (hash << 5) - hash + chr;
10
+ hash |= 0; // Convert to 32bit integer
11
+ }
12
+ return hash;
13
+ };
14
+
15
+ String.prototype.contains = function(substr) {
16
+ return this.indexOf(substr) > -1;
17
+ };
18
+
19
+ String.prototype.presence = function() {
20
+ return this.length > 0 ? this.toString() : null;
21
+ };
package/index.js ADDED
@@ -0,0 +1,195 @@
1
+ import Vue from "vue";
2
+ export { Vue };
3
+
4
+ import App from "./app.vue";
5
+
6
+ import * as VueGoogleMaps from "vue2-google-maps";
7
+ Vue.use(VueGoogleMaps, {
8
+ load: {
9
+ key: process.env.GMAPS_API_KEY,
10
+ libraries: "places"
11
+ }
12
+ });
13
+
14
+ import "./styles/test.scss";
15
+ import "./styles/test.sass";
16
+
17
+ import Vuetify from "vuetify";
18
+ import "vuetify/dist/vuetify.min.css";
19
+ // import "material-design-icons-iconfont/dist/material-design-icons.css";
20
+ // import "@mdi/font/css/materialdesignicons.css";
21
+ Vue.use(Vuetify);
22
+
23
+ import Chartkick from "vue-chartkick";
24
+ import Chart from "chart.js";
25
+ Vue.use(Chartkick.use(Chart));
26
+
27
+ // TODO: make this opt-in
28
+ import VueYoutube from "vue-youtube";
29
+ Vue.use(VueYoutube);
30
+
31
+ // import VueAnalytics from 'vue-analytics'
32
+ // // TODO: Avoid hardcoding
33
+ // Vue.use(VueAnalytics, {
34
+ // id: 'UA-146876849-1'
35
+ // })
36
+
37
+ import "./extensions/string.js";
38
+ import "./extensions/array.js";
39
+
40
+ // Recursive components must be global
41
+ import VerticalPanel from "./components/panels/vertical";
42
+ import ResponsivePanel from "./components/panels/responsive";
43
+ import Component from "./components/component";
44
+ import CommonIcon from "./components/_icon";
45
+ import CommonButton from "./components/_button";
46
+ import CommonMessage from "./components/_message";
47
+ import CommonDropdownMenu from "./components/_dropdownMenu";
48
+ import CommonTemplateMenu from "./templates/_menu";
49
+ Vue.component("panels-vertical", VerticalPanel);
50
+ Vue.component("panels-responsive", ResponsivePanel);
51
+ Vue.component("common-button", CommonButton);
52
+ Vue.component("common-icon", CommonIcon);
53
+ Vue.component("common-message", CommonMessage);
54
+ Vue.component("common-dropdownMenu", CommonDropdownMenu);
55
+ Vue.component("templates-menu", CommonTemplateMenu);
56
+
57
+ // TODO: Deprecate
58
+ Vue.component("ui-component", Component);
59
+
60
+ Vue.component("glib-component", Component);
61
+ Vue.component("glib-icon", CommonIcon);
62
+ Vue.component("glib-panels-responsive", ResponsivePanel);
63
+ // Vue.component("glib-templates-menu", CommonTemplateMenu);
64
+
65
+ import genericMixin from "./components/mixins/generic.js";
66
+ Vue.mixin(genericMixin);
67
+
68
+ import eventsMixin from "./components/mixins/events.js";
69
+ Vue.mixin(eventsMixin);
70
+
71
+ import stylesMixin from "./components/mixins/styles.js";
72
+ Vue.mixin(stylesMixin);
73
+
74
+ import scrollingMixin from "./components/mixins/scrolling.js";
75
+ Vue.mixin(scrollingMixin);
76
+
77
+ import longClickDirective from "./components/mixins/longClick.js";
78
+ window.longClickInstance = longClickDirective({ delay: 500, interval: 0 });
79
+ Vue.directive("longclick", window.longClickInstance);
80
+
81
+ // TODO: Deprecate
82
+ import TypeUtils from "./utils/type";
83
+ Vue.use({
84
+ install: function(Vue, options) {
85
+ Vue.prototype.$type = {
86
+ isObject: TypeUtils.isObject,
87
+ isString: TypeUtils.isString,
88
+ isNumber: TypeUtils.isNumber,
89
+ isArray: TypeUtils.isArray,
90
+
91
+ ifObject: TypeUtils.ifObject,
92
+ ifString: TypeUtils.ifString,
93
+ ifNumber: TypeUtils.ifNumber,
94
+ ifArray: TypeUtils.ifArray
95
+ };
96
+ }
97
+ });
98
+
99
+ import Utils from "./utils/helper";
100
+ window.Utils = Utils;
101
+
102
+ import Framework from "./utils/public";
103
+ window.GLib = Framework;
104
+
105
+ import { settings } from "./utils/settings";
106
+ export { settings };
107
+
108
+ // TODO: https://vuejs.org/v2/guide/components-dynamic-async.html#Async-Components
109
+ // Vue.component('async-webpack-example', function (resolve) {
110
+ // // This special require syntax will instruct Webpack to
111
+ // // automatically split your built code into bundles which
112
+ // // are loaded over Ajax requests.
113
+ // require(['./my-async-component'], resolve)
114
+ // })
115
+
116
+ import VueGtag from "vue-gtag";
117
+
118
+ document.addEventListener("DOMContentLoaded", () => {
119
+ const gtagId = settings.gtagId;
120
+ if (gtagId) {
121
+ Vue.use(VueGtag, {
122
+ config: {
123
+ id: settings.gtagId,
124
+ params: {
125
+ send_page_view: false
126
+ }
127
+ }
128
+ });
129
+ }
130
+
131
+ window.vueApp = {
132
+ vuetify: new Vuetify({
133
+ icons: {
134
+ iconfont: "md"
135
+ },
136
+ theme: {
137
+ themes: Utils.settings.themes
138
+ },
139
+ breakpoint: {
140
+ smAndDown: true
141
+ }
142
+ }),
143
+ page: window.__page,
144
+ indicator: false,
145
+ // Rename to isPageStale
146
+ isStale: false,
147
+ stateUpdatedAt: null,
148
+ webSocket: { channels: {}, header: {} },
149
+ actionCable: { channels: {} },
150
+ temp: {}
151
+ };
152
+ new Vue({
153
+ el: "#app",
154
+ vuetify: window.vueApp.vuetify,
155
+ data: {
156
+ vueApp: window.vueApp
157
+ },
158
+ // data: {
159
+ // vuetify: vuetify,
160
+ // page: window.__page,
161
+ // indicator: false,
162
+ // isStale: false,
163
+ // webSocket: { channels: {}, header: {}, listWindow: null }
164
+ // },
165
+ render: function(createElement) {
166
+ return createElement(App, { props: { page: this.$data.vueApp.page } });
167
+ }
168
+ });
169
+ });
170
+
171
+ // The above code uses Vue without the compiler, which means you cannot
172
+ // use Vue to target elements in your existing html templates. You would
173
+ // need to always use single file components.
174
+ // To be able to target elements in your existing html/erb templates,
175
+ // comment out the above code and uncomment the below
176
+ // Add <%= javascript_pack_tag 'hello_vue' %> to your layout
177
+ // Then add this markup to your html template:
178
+ //
179
+ // <div id='hello'>
180
+ // {{message}}
181
+ // <app></app>
182
+ // </div>
183
+
184
+ // import Vue from 'vue/dist/vue.esm'
185
+ // import App from '../app.vue'
186
+ //
187
+ // document.addEventListener('DOMContentLoaded', () => {
188
+ // const app = new Vue({
189
+ // el: '#hello',
190
+ // data: {
191
+ // message: "Can you say hello?"
192
+ // },
193
+ // components: { App }
194
+ // })
195
+ // })
package/keys.js ADDED
@@ -0,0 +1,12 @@
1
+ // See https://stackoverflow.com/questions/32647215/declaring-static-constants-in-es6-classes
2
+ // const csrfToken = "__csrfToken";
3
+
4
+ // See https://stackoverflow.com/questions/28784375/nested-es6-classes
5
+ export default class Keys {
6
+ }
7
+
8
+ Keys.Db = class {
9
+ // static get csrfToken() {
10
+ // return csrfToken;
11
+ // }
12
+ }