glib-web 5.0.4 → 5.0.6

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.
@@ -0,0 +1,39 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Read(//home/hgani/workspace/glib-web/app/views/json_ui/garage/**)",
5
+ "Read(//home/hgani/workspace/glib-web-npm/doc/garage/**)",
6
+ "Read(//home/hgani/workspace/glib-web-npm/doc/common/**)",
7
+ "Bash(find:*)",
8
+ "Bash(npx cypress run:*)",
9
+ "Read(//home/hgani/workspace/glib-web/**)",
10
+ "Bash(curl:*)",
11
+ "Bash(pkill:*)",
12
+ "Bash(gh pr list:*)",
13
+ "WebSearch",
14
+ "WebFetch(domain:vuetifyjs.com)",
15
+ "Bash(lsof:*)",
16
+ "Bash(readlink:*)",
17
+ "WebFetch(domain:github.com)",
18
+ "Bash(npm run dev)",
19
+ "Bash(npm run)",
20
+ "Bash(npx eslint:*)",
21
+ "Bash(npm install:*)",
22
+ "Bash(yarn lint:*)",
23
+ "Bash(bin/rails db:migrate:*)",
24
+ "Bash(bin/rails server:*)",
25
+ "Bash(dpkg -S:*)",
26
+ "Bash(source:*)",
27
+ "Bash(node --version:*)",
28
+ "Bash(nvm ls:*)",
29
+ "Bash(nvm use:*)",
30
+ "Bash(git -C /home/hgani/workspace/glib-web-npm diff --cached --stat)",
31
+ "Bash(git -C /home/hgani/workspace/glib-web-npm diff --stat)",
32
+ "Bash(git *)",
33
+ "Bash(npm whoami *)",
34
+ "Bash(npm view *)"
35
+ ],
36
+ "deny": [],
37
+ "ask": []
38
+ }
39
+ }
@@ -3,7 +3,10 @@
3
3
  import countries from "moment-timezone/data/meta/latest.json";
4
4
  import Action from "../../action";
5
5
  import http from "../../utils/http";
6
- import merge from 'lodash.merge';
6
+ import * as mergeModule from 'lodash.merge';
7
+ import { interopDefault } from "../../utils/interop.js";
8
+
9
+ const merge = interopDefault(mergeModule);
7
10
 
8
11
  export default class {
9
12
  async execute(spec, component) {
@@ -1,4 +1,7 @@
1
- import Push from "push.js";
1
+ import * as PushModule from "push.js";
2
+ import { interopDefault } from "../../utils/interop.js";
3
+
4
+ const Push = interopDefault(PushModule);
2
5
 
3
6
  export default class {
4
7
  execute(properties, component) {
@@ -1,9 +1,12 @@
1
- import jsonLogic from 'json-logic-js';
1
+ import * as jsonLogicModule from 'json-logic-js';
2
+ import { interopDefault } from "../../utils/interop.js";
2
3
  // Method "closest" return nothing, so use getAllFormData instead
3
4
  // One page can consist of many forms
4
5
  // so please use carefully
5
6
  import { getAllFormData } from "../../components/composable/form";
6
7
 
8
+ const jsonLogic = interopDefault(jsonLogicModule);
9
+
7
10
  export default class {
8
11
  execute(spec, component) {
9
12
  let condition = spec.condition;
@@ -1,10 +1,14 @@
1
- import jsonLogic from 'json-logic-js';
2
- import merge from 'lodash.merge';
1
+ import * as jsonLogicModule from 'json-logic-js';
2
+ import * as mergeModule from 'lodash.merge';
3
3
  import { nextTick } from "vue";
4
4
  import { sanitize } from "../../components/composable/date";
5
5
  import { isPresent } from "../../utils/type";
6
+ import { interopDefault } from "../../utils/interop.js";
6
7
  import { getFormData as _getFormData } from "../../components/composable/form";
7
8
 
9
+ const jsonLogic = interopDefault(jsonLogicModule);
10
+ const merge = interopDefault(mergeModule);
11
+
8
12
  const sumDate = function (a, b) {
9
13
  const date = new Date(a);
10
14
  const tzoffset = date.getTimezoneOffset() * 60000;
@@ -8,9 +8,9 @@
8
8
  <!-- model-value must be true to make the badge visible.
9
9
  Vuetify's v-badge uses this prop to toggle display:none/block -->
10
10
  <template #badge>{{ badge.text }}</template>
11
- <InternalIcon :spec="spec" />
11
+ <InternalIcon ref="delegate" :spec="spec" />
12
12
  </v-badge>
13
- <InternalIcon v-else :spec="spec" />
13
+ <InternalIcon v-else ref="delegate" :spec="spec" />
14
14
  </template>
15
15
 
16
16
  <script>
@@ -1,5 +1,8 @@
1
- import moment from "moment-timezone";
1
+ import * as momentModule from "moment-timezone";
2
2
  import { isString } from "../../utils/type";
3
+ import { interopDefault } from "../../utils/interop.js";
4
+
5
+ const moment = interopDefault(momentModule);
3
6
 
4
7
  export function sanitize(val, type, timeZone) {
5
8
  if (!val) return;
@@ -14,7 +14,9 @@ function waitForGmapLoaded() {
14
14
 
15
15
  export function useAutocomplete({ inputRef, options, onPlaceChanged }) {
16
16
  let autocompleteInstance = null;
17
- onMounted(() => {
17
+ onMounted(async () => {
18
+ await waitForGmapLoaded();
19
+
18
20
  let inputElement = null;
19
21
  if (inputRef.value instanceof HTMLElement) {
20
22
  inputElement = inputRef.value;
@@ -3,8 +3,11 @@
3
3
  </template>
4
4
 
5
5
  <script>
6
- import moment from "moment";
6
+ import * as momentModule from "moment";
7
7
  import GlibBase from "./base/glibBase.js";
8
+ import { interopDefault } from "../utils/interop.js";
9
+
10
+ const moment = interopDefault(momentModule);
8
11
 
9
12
  export default {
10
13
  extends: GlibBase,
@@ -55,7 +55,6 @@ export default {
55
55
  fileTitle: null,
56
56
  fileImage: null,
57
57
  fileValue: null,
58
- inputElement: null,
59
58
  placeholder: {},
60
59
  buttonLabels: { delete: 'Delete', upload: 'Upload', change: 'Change' }
61
60
  };
@@ -92,14 +91,11 @@ export default {
92
91
  }
93
92
 
94
93
  this.placeholder = this.spec.placeholderView || { inputPlaceholder: 'Upload your file' };
95
- this.$nextTick(() => {
96
- this.inputElement = this.$refs.directUploadFile;
97
- });
98
94
  const defaultLabels = { delete: 'Delete', upload: 'Upload', change: 'Change' };
99
95
  this.buttonLabels = Object.assign(defaultLabels, this.spec.buttonLabels);
100
96
  },
101
97
  triggerUpload() {
102
- this.inputElement.click();
98
+ this.$refs.directUploadFile.click();
103
99
  },
104
100
  removeImage() {
105
101
  this.uploaded = false;
@@ -139,7 +135,7 @@ export default {
139
135
  this.spec.metadata
140
136
  );
141
137
 
142
- const input = this.inputElement;
138
+ const input = this.$refs.directUploadFile;
143
139
  if (validateFile(this.spec.accepts, file)) {
144
140
  this.$dispatchEvent("forms/setBusy", { value: true });
145
141
 
@@ -39,9 +39,10 @@ export default {
39
39
 
40
40
  const { mapInstance, mapPromise } = useGmap({ mapRef: map, options: { zoom: 4 } });
41
41
 
42
- const marker = new google.maps.Marker({ draggable: true });
42
+ let marker = null;
43
+ const markerPromise = mapPromise().then((map) => {
44
+ marker = new google.maps.Marker({ draggable: true });
43
45
 
44
- mapPromise().then((map) => {
45
46
  const zoomRef = zoomField.value;
46
47
  if (zoomRef) {
47
48
  const zoomInput = zoomRef.$el.querySelector('input');
@@ -66,13 +67,15 @@ export default {
66
67
  lngComponent.fieldModel = position.lng();
67
68
  }
68
69
  });
70
+
71
+ return { map, marker };
69
72
  });
70
73
 
71
74
  const { autocompleteInstance } = useAutocomplete({
72
75
  inputRef: autocomplete,
73
76
  options: spec.autocompleteOptions,
74
77
  onPlaceChanged: (instance) => {
75
- mapPromise().then((map) => {
78
+ markerPromise.then(({ map, marker }) => {
76
79
  const location = instance.getPlace().geometry.location;
77
80
  map.setCenter(location);
78
81
 
@@ -26,8 +26,11 @@
26
26
 
27
27
  <script>
28
28
  import GlibBase from "../../base/glibBase.js";
29
- import PhoneNumber from "awesome-phonenumber";
29
+ import * as PhoneNumberModule from "awesome-phonenumber";
30
30
  import allCountries from "./countries";
31
+ import { interopDefault } from "../../../utils/interop.js";
32
+
33
+ const PhoneNumber = interopDefault(PhoneNumberModule);
31
34
 
32
35
  function getCountryByIp() {
33
36
  return fetch("https://ip2c.org/s")
@@ -4,7 +4,8 @@
4
4
  :placeholder="spec.placeholder" :maxlength="maxLength" :readonly="spec.readOnly" :height="height"
5
5
  :rules="$validation()" counter :outlined="$classes().includes('outlined')" :disabled="inputDisabled"
6
6
  :no-resize="$classes().includes('no-resize')" validate-on="blur" :variant="variant" :density="density"
7
- persistent-placeholder :clearable="spec.clearable" @update:modelValue="onChange()">
7
+ persistent-placeholder :clearable="spec.clearable" :rows="spec.rows || 5"
8
+ @update:modelValue="onChange()">
8
9
 
9
10
  <template #counter="{ counter }">
10
11
  <span v-if="!spec.readOnly">{{ counter }}</span>
@@ -1,9 +1,9 @@
1
1
  <template>
2
2
  <common-badge v-if="spec.badge" :spec="spec">
3
- <img class="aligner" :src="spec.url || spec.base64Data" :style="styles" :height="height" :width="width"
3
+ <img class="aligner" :src="spec.url || spec.base64Data" :alt="spec.alt" :style="styles" :height="height" :width="width"
4
4
  :class="$classes()" @click="$onClick()" />
5
5
  </common-badge>
6
- <img v-else class="aligner" :src="spec.url || spec.base64Data" :style="styles" :height="height" :width="width"
6
+ <img v-else class="aligner" :src="spec.url || spec.base64Data" :alt="spec.alt" :style="styles" :height="height" :width="width"
7
7
  :class="$classes()" @click="$onClick()" />
8
8
  </template>
9
9
 
@@ -2,8 +2,12 @@ import Hash from "../../utils/hash";
2
2
  import { determineColor } from "../../utils/constant";
3
3
  import { triggerOnChange } from "../composable/form";
4
4
  import { realComponent } from "../helper";
5
- import set from "lodash.set";
6
- import merge from "lodash.merge";
5
+ import * as setModule from "lodash.set";
6
+ import * as mergeModule from "lodash.merge";
7
+ import { interopDefault } from "../../utils/interop.js";
8
+
9
+ const set = interopDefault(setModule);
10
+ const merge = interopDefault(mergeModule);
7
11
  const NUMBER_PRECISION = 2;
8
12
  const isNeedToBeFixed = (val, component) => {
9
13
  return component.type == 'number' && !Number.isInteger(val) && Number.isFinite(val);
@@ -70,9 +70,12 @@ export default {
70
70
  import { computed, getCurrentInstance, onMounted, reactive, ref, watch } from "vue";
71
71
  import Action from "../../action";
72
72
  import Hash from "../../utils/hash";
73
- import Papa from "papaparse";
73
+ import * as PapaModule from "papaparse";
74
74
  import launch from "../../utils/launch";
75
75
  import { isPresent } from "../../utils/type";
76
+ import { interopDefault } from "../../utils/interop.js";
77
+
78
+ const Papa = interopDefault(PapaModule);
76
79
 
77
80
  class Row {
78
81
  constructor({ id, columns, selected, index, status }) {
@@ -14,7 +14,7 @@
14
14
  -->
15
15
  <!-- <component ref="ccomp" :is="template" v-if="customData" :name="spec.template" :spec="customData" /> -->
16
16
 
17
- <component :is="template" :name="spec.template" :spec="contentSpec" />
17
+ <component :is="template" :compName="spec.template" :spec="contentSpec" />
18
18
 
19
19
  </div>
20
20
  </template>
@@ -53,12 +53,13 @@
53
53
  <td v-for="(cell, cellIndex) in row.cellViews" :key="`cell_${cellIndex}`"
54
54
  :colSpan="colSpan(row, cellIndex)" :style="colStyles(row, cellIndex)">
55
55
  <span>
56
- <!-- Prevent double links -->
57
- <glib-component v-if="$href(cell)" :spec="cell" />
58
- <!-- without "|| null" the browser will reload strangely -->
59
- <a v-else :href="$href(row) || null" @click="$onClick($event, row)">
56
+ <!-- Cell has its own click target — render it directly to avoid nested anchors. -->
57
+ <glib-component v-if="cell.onClick || $href(cell)" :spec="cell" />
58
+ <!-- `:href="... || null"` so Vue omits the attribute when there's no URL; an empty string would trigger a page reload. -->
59
+ <a v-else-if="row.onClick" :href="$href(row) || null" @click="$onClick($event, row)">
60
60
  <glib-component :spec="cell" />
61
61
  </a>
62
+ <glib-component v-else :spec="cell" />
62
63
  </span>
63
64
  </td>
64
65
  </tr>
@@ -216,24 +217,40 @@ table {
216
217
  // }
217
218
 
218
219
  tbody {
219
- tr.clickable {
220
- td>a {
221
- cursor: pointer;
222
- }
223
-
224
- &:hover {
225
- background: #eee;
226
- }
227
- }
228
-
229
220
  td {
230
221
  border-top: 1px solid rgba(0, 0, 0, 0.12);
231
222
 
232
223
  span {
233
224
  display: block;
234
225
  color: inherit;
226
+ }
227
+
228
+ // Non-clickable cells: default cursor; nested spans inherit it.
229
+ > span:not(:has(> a)) {
235
230
  cursor: default;
236
231
  }
232
+
233
+ // Clickable cell: move the span's padding onto the <a> so the full padded
234
+ // area is part of the click target. Children inherit the pointer cursor.
235
+ > span:has(> a) {
236
+ padding: 0;
237
+ }
238
+
239
+ > span > a {
240
+ display: block;
241
+ padding: var(--cell-padding);
242
+ cursor: pointer;
243
+ text-decoration: none;
244
+ color: inherit;
245
+ }
246
+ }
247
+
248
+ tr.clickable {
249
+ cursor: pointer;
250
+
251
+ &:hover {
252
+ background: #eee;
253
+ }
237
254
  }
238
255
  }
239
256
 
@@ -256,9 +273,7 @@ table.table--grid {
256
273
 
257
274
  table.table--plain {
258
275
  td {
259
- >span {
260
- padding: unset;
261
- }
276
+ --cell-padding: 0;
262
277
  }
263
278
  }
264
279
  </style>
@@ -273,8 +288,12 @@ table.table--plain {
273
288
  }
274
289
 
275
290
  td {
291
+ // Override via --cell-padding (not `padding` on the span) so that clickable
292
+ // cells — which move the padding onto the inner <a> — stay in sync.
293
+ --cell-padding: 10px 24px;
294
+
276
295
  >span {
277
- padding: 10px 24px;
296
+ padding: var(--cell-padding);
278
297
  }
279
298
  }
280
299
  }
@@ -46,6 +46,7 @@ export default {
46
46
  busCloseHandler: null,
47
47
  onAppClick: null,
48
48
  onResize: null,
49
+ dialogClickEl: null,
49
50
  body: null,
50
51
  };
51
52
  },
@@ -59,29 +60,63 @@ export default {
59
60
  },
60
61
  mounted() {
61
62
  popovers.value.push(this);
62
- this.busOpenHandler = (body) => {
63
- this.body = body;
64
- this.key = strandom();
65
- };
66
- bus.$on(`popovers/open-${this.spec.key}`, this.busOpenHandler);
63
+ this.registerBusOpen();
64
+ this.handleMounted();
67
65
  },
68
66
  methods: {
69
- $mounted() {
70
- const appEl = document.getElementById(APP_ID);
67
+ registerBusOpen() {
68
+ this.busOpenHandler = (body) => {
69
+ this.body = body;
70
+ this.key = strandom();
71
+ };
72
+ bus.$on(`popovers/open-${this.spec.key}`, this.busOpenHandler);
73
+ },
74
+ registerBusClose(appEl) {
71
75
  this.busCloseHandler = () => {
72
76
  if (appEl) {
73
77
  appEl.removeEventListener("click", this.onAppClick);
74
78
  }
79
+ if (TypeUtils.isNotNull(this.dialogClickEl)) {
80
+ this.dialogClickEl.removeEventListener("click", this.onAppClick);
81
+ }
75
82
  this.close();
76
83
  };
77
84
  bus.$once(`popover/close-${this.spec.key}`, this.busCloseHandler);
85
+ },
86
+ registerOutsideListeners(appEl) {
87
+ this.onAppClick = this.handleClose;
88
+ if (appEl) {
89
+ appEl.addEventListener("click", this.onAppClick);
90
+ }
91
+ this.dialogClickEl = this.resolveDialogEl();
92
+ if (TypeUtils.isNotNull(this.dialogClickEl)) {
93
+ this.dialogClickEl.addEventListener("click", this.onAppClick);
94
+ }
95
+ this.onResize = () => this.close();
96
+ window.addEventListener("resize", this.onResize);
97
+ },
98
+ removeOutsideListeners(appEl) {
99
+ if (TypeUtils.isFunction(this.onAppClick) && appEl) {
100
+ appEl.removeEventListener("click", this.onAppClick);
101
+ }
102
+ if (TypeUtils.isFunction(this.onAppClick) && TypeUtils.isNotNull(this.dialogClickEl)) {
103
+ this.dialogClickEl.removeEventListener("click", this.onAppClick);
104
+ }
105
+ if (TypeUtils.isFunction(this.onResize)) {
106
+ window.removeEventListener("resize", this.onResize);
107
+ }
108
+ },
109
+ resolveDialogEl() {
110
+ if (TypeUtils.isNotNull(this.reference) && TypeUtils.isFunction(this.reference.closest)) {
111
+ return this.reference.closest(".v-dialog");
112
+ }
113
+ return null;
114
+ },
115
+ handleMounted() {
116
+ const appEl = document.getElementById(APP_ID);
117
+ this.registerBusClose(appEl);
78
118
  if (!this.spec.persistent) {
79
- this.onAppClick = this.handleClose;
80
- if (appEl) {
81
- appEl.addEventListener("click", this.onAppClick);
82
- }
83
- this.onResize = () => this.close();
84
- window.addEventListener("resize", this.onResize);
119
+ this.registerOutsideListeners(appEl);
85
120
  }
86
121
  if (this.spec.overlay) {
87
122
  this.driverObj.highlight({ element: this.reference });
@@ -96,12 +131,7 @@ export default {
96
131
  }
97
132
  if (!this.spec.persistent) {
98
133
  const appEl = document.getElementById(APP_ID);
99
- if (TypeUtils.isFunction(this.onAppClick) && appEl) {
100
- appEl.removeEventListener("click", this.onAppClick);
101
- }
102
- if (TypeUtils.isFunction(this.onResize)) {
103
- window.removeEventListener("resize", this.onResize);
104
- }
134
+ this.removeOutsideListeners(appEl);
105
135
  }
106
136
  },
107
137
  handleClose(event) {
@@ -14,7 +14,10 @@ import GlibBase from "./base/glibBase.js";
14
14
  import Action from "../action";
15
15
  import { Vue } from "..";
16
16
 
17
- import VueSocialSharing from "vue-social-sharing";
17
+ import * as VueSocialSharingModule from "vue-social-sharing";
18
+ import { interopDefault } from "../utils/interop.js";
19
+
20
+ const VueSocialSharing = interopDefault(VueSocialSharingModule);
18
21
  Vue.use(VueSocialSharing, { networks: { copy: "" } });
19
22
 
20
23
  export default {
@@ -34,8 +34,11 @@ import { defineComponent, ref } from "vue";
34
34
  import * as dropUploader from "./composable/upload";
35
35
  import * as delegateUploader from "./composable/upload_delegator";
36
36
  import { watch } from "vue";
37
- import merge from 'lodash.merge';
37
+ import * as mergeModule from 'lodash.merge';
38
38
  import { useFileUtils } from "./composable/file";
39
+ import { interopDefault } from "../utils/interop.js";
40
+
41
+ const merge = interopDefault(mergeModule);
39
42
  const { signedIds } = useFileUtils();
40
43
 
41
44
  export default defineComponent({
package/index.js CHANGED
@@ -8,7 +8,10 @@ import { jsonView, vueApp } from "./store";
8
8
  import './app.scss';
9
9
 
10
10
  // lib for deep merge
11
- import merge from 'lodash.merge';
11
+ import * as mergeModule from 'lodash.merge';
12
+ import { interopDefault } from "./utils/interop.js";
13
+
14
+ const merge = interopDefault(mergeModule);
12
15
 
13
16
  const APP_ID = 'app';
14
17
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "glib-web",
4
- "version": "5.0.4",
4
+ "version": "5.0.6",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {
@@ -68,4 +68,4 @@
68
68
  "vite-plugin-istanbul": "^7.2.1",
69
69
  "vite-plugin-ruby": "^5.1.1"
70
70
  }
71
- }
71
+ }
@@ -1,12 +1,12 @@
1
1
  <template>
2
- <div>Unsupported template: {{ name }}</div>
2
+ <div>Unsupported template: {{ compName }}</div>
3
3
  </template>
4
4
 
5
5
  <script>
6
6
  export default {
7
7
  props: {
8
8
  spec: { type: Object, required: true },
9
- name: { type: String, required: true }
9
+ compName: { type: String, required: true }
10
10
  }
11
11
  };
12
12
  </script>
package/utils/eventBus.js CHANGED
@@ -1,5 +1,8 @@
1
1
  // eventBus.js
2
- import EventEmitter2 from "eventemitter2";
2
+ import * as EventEmitter2Module from "eventemitter2";
3
+ import { interopDefaultOr } from "./interop.js";
4
+
5
+ const EventEmitter2 = interopDefaultOr(EventEmitter2Module, "EventEmitter2");
3
6
 
4
7
  const emitter = new EventEmitter2({ delimiter: '-', maxListeners: 0 });
5
8
 
package/utils/hash.js CHANGED
@@ -1,4 +1,7 @@
1
- import merge from 'lodash.merge';
1
+ import * as mergeModule from 'lodash.merge';
2
+ import { interopDefault } from "./interop.js";
3
+
4
+ const merge = interopDefault(mergeModule);
2
5
  export default class Hash {
3
6
  constructor(object) {
4
7
  if (object) {
@@ -0,0 +1,9 @@
1
+ export function interopDefault(moduleRef) {
2
+ return moduleRef && moduleRef.default ? moduleRef.default : moduleRef;
3
+ }
4
+
5
+ export function interopDefaultOr(moduleRef, namedExport) {
6
+ if (moduleRef && moduleRef.default) return moduleRef.default;
7
+ if (moduleRef && moduleRef[namedExport]) return moduleRef[namedExport];
8
+ return moduleRef;
9
+ }