glib-web 3.0.4 → 3.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.
@@ -7,7 +7,6 @@ export default class {
7
7
  const target = GLib.component.findById(spec.targetId);
8
8
  if (target) {
9
9
  Object.assign(target.spec, spec.views[0]);
10
- target.$recursiveUpdate();
11
10
  }
12
11
  }
13
12
  }
@@ -1,58 +1,21 @@
1
1
  <template>
2
- <!-- Use `click.prevent` to prevent bubbling when clicking a dropdown button that is
3
- located in a list row that has href. -->
4
- <v-btn :type="type" :disabled="disabled || $isBusy || spec.disabled" :style="styles()" :class="classes()"
5
- :href="$href()" :rel="$rel()" :variant="variant" :rounded="$classes().includes('rounded') || null" @click.prevent="
6
- type == 'submit' ? $dispatchEvent('forms/submit') : $onClick()
7
- ">
8
- <span v-if="spec.icon"><common-icon :spec="spec.icon || {}" /></span>
9
- <div :class="hideTextOnXs && spec.icon ? 'd-none d-sm-flex' : null">
10
- {{ spec.text }}
11
- </div>
12
- </v-btn>
2
+ <common-badge v-if="spec.badge" :spec="spec">
3
+ <internal-button :spec="spec" :disabled="$isBusy" />
4
+ </common-badge>
5
+ <internal-button v-else :spec="spec" :disable="$isBusy" />
13
6
  </template>
14
7
 
15
8
  <script>
16
- import { variants } from '../utils/constant'
9
+ import InternalButton from "./_internal_button.vue";
17
10
 
18
11
  export default {
19
- props: {
20
- spec: { type: Object, required: true },
21
- type: { type: String, default: "button" },
22
- disabled: { type: Boolean },
23
- hideTextOnXs: { type: Boolean },
24
- eventHandlers: { type: Object, default: null }
12
+ components: {
13
+ "internal-button": InternalButton,
25
14
  },
26
- data: function () {
27
- return {
28
- linkStyling: false,
29
- variant: 'elevated'
30
- };
15
+ props: {
16
+ spec: { type: Object, required: true }
31
17
  },
32
18
  methods: {
33
- $ready() {
34
- this.$type.ifArray(this.spec.styleClasses, val => {
35
- this.linkStyling = val.includes("link");
36
- });
37
-
38
- const vm = this
39
- variants.forEach((value) => {
40
- if (vm.$classes().includes(value)) {
41
- vm.variant = value
42
- }
43
- })
44
- },
45
- styles() {
46
- const styles = this.$styles();
47
- if (this.linkStyling) {
48
- styles["color"] = styles["color"] || "#1976d2";
49
- }
50
- return styles;
51
- },
52
- classes() {
53
- const classes = this.$classes();
54
- return classes;
55
- },
56
19
  $registryEnabled() {
57
20
  return false;
58
21
  }
@@ -60,67 +23,4 @@ export default {
60
23
  };
61
24
  </script>
62
25
 
63
- <style lang="scss">
64
- .v-btn {
65
- &.link {
66
- .v-icon {
67
- font-size: 16px;
68
- }
69
- }
70
- }
71
- </style>
72
-
73
- <style lang="scss" scoped>
74
- a,
75
- button {
76
- min-width: 0;
77
- margin: 0;
78
- }
79
-
80
- .v-btn {
81
- &.link {
82
- text-transform: none !important;
83
- /* text-decoration: underline; */
84
- padding-left: 0;
85
- padding-right: 0;
86
- /* `height: inherit/auto/initial` will stretch to max height when used inside a horizontal panel,
87
- presumably because it is affected by the panel's flex arrangement. */
88
- height: 16px;
89
- font-size: 16px;
90
- line-height: 1;
91
- min-width: auto;
92
- box-shadow: none !important;
93
- }
94
- }
95
-
96
- .v-btn--rounded {
97
- // Override .v-application.rounded
98
- border-radius: 28px !important;
99
- }
100
-
101
- .v-banner__wrapper .v-btn:not(.v-btn--round).v-size--default {
102
- min-width: 0;
103
- padding: 0;
104
- }
105
-
106
- .v-banner__wrapper .v-btn.v-size--default {
107
- font-size: 12px;
108
- }
109
-
110
- .breadcrumbs .v-btn.link {
111
- display: inline-table;
112
- justify-content: left;
113
- white-space: normal;
114
- }
115
-
116
- @media only screen and (min-width: 600px) {
117
- .v-banner__wrapper.v-btn.v-size--default {
118
- font-size: 0.875rem;
119
- }
120
-
121
- .v-banner__wrapper.v-btn:not(.v-btn--round).v-size--default {
122
- min-width: 64px;
123
- padding: 0 16px;
124
- }
125
- }
126
- </style>
26
+ <style scoped></style>
@@ -8,6 +8,7 @@
8
8
  :class="$classes()"
9
9
  :href="$href()"
10
10
  @click="$onClick()"
11
+ :density="density"
11
12
  :variant="variant"
12
13
  >
13
14
  {{ spec.text }}
@@ -17,6 +18,7 @@
17
18
  :style="genericStyles()"
18
19
  :color="color"
19
20
  :class="$classes()"
21
+ :density="density"
20
22
  :variant="variant"
21
23
  >
22
24
  {{ spec.text }}
@@ -26,32 +28,30 @@
26
28
  </template>
27
29
 
28
30
  <script>
29
- import { colors, variants } from "../utils/constant";
31
+ import { determineColor, determineDensity, determineVariant } from "../utils/constant";
30
32
 
31
33
  export default {
32
34
  data: function () {
33
35
  return {
34
- color: "",
35
- variant: "tonal",
36
+ // color: "",
37
+ // variant: "tonal",
36
38
  };
37
39
  },
38
40
  props: {
39
41
  spec: { type: Object, required: true },
40
42
  },
41
- // data: function() {
42
- // return {
43
- // tooltip: {}
44
- // };
45
- // },
46
- methods: {
47
- $ready() {
48
- colors.forEach((value) => {
49
- if (this.$classes().includes(value)) this.color = value;
50
- });
51
- variants.forEach((value) => {
52
- if (this.$classes().includes(value)) this.variant = value;
53
- });
43
+ computed: {
44
+ color() {
45
+ return determineColor(this.spec.styleClasses)
46
+ },
47
+ density() {
48
+ return determineDensity(this.spec.styleClasses)
54
49
  },
50
+ variant() {
51
+ return determineVariant(this.spec.styleClasses, 'tonal')
52
+ }
53
+ },
54
+ methods: {
55
55
  $registryEnabled() {
56
56
  return false;
57
57
  },
@@ -1,12 +1,12 @@
1
1
  <template>
2
- <!-- <common-badge :spec="spec"> -->
3
2
  <v-icon :style="genericStyles()" :size="size" :color="color">{{
4
3
  value
5
4
  }}</v-icon>
6
- <!-- </common-badge> -->
7
5
  </template>
8
6
 
9
7
  <script>
8
+ import { determineColor } from '../utils/constant'
9
+
10
10
  export default {
11
11
  props: {
12
12
  spec: { type: Object, required: true },
@@ -14,8 +14,8 @@ export default {
14
14
  },
15
15
  data() {
16
16
  return {
17
- badge: {},
18
- color: null,
17
+ // badge: {},
18
+ // color: null,
19
19
  name: null,
20
20
  size: null
21
21
  };
@@ -23,24 +23,44 @@ export default {
23
23
  computed: {
24
24
  value() {
25
25
  return this.isBusy || this.$isBusy ? "autorenew" : this.name;
26
+ },
27
+ color() {
28
+ // return this.spec.color
29
+ return this.spec.color || determineColor(this.spec.styleClasses)
30
+ }
31
+ },
32
+ watch: {
33
+ spec: {
34
+ handler(val) {
35
+ Utils.type.ifObject(val.fa, fa => {
36
+ this.name = `fab fa-${fa.name}`;
37
+ this.size = fa.size;
38
+ });
39
+
40
+ Utils.type.ifObject(val.material, material => {
41
+ this.name = material.name;
42
+ this.size = material.size;
43
+ });
44
+ },
45
+ immediate: true
26
46
  }
27
47
  },
28
48
  methods: {
29
- $ready() {
30
- this.badge = this.spec.badge || {};
31
- this.color =
32
- this.spec.color || this.$builtinColor(this.spec.styleClasses);
49
+ // $ready() {
50
+ // // this.badge = this.spec.badge || {};
51
+ // // this.color =
52
+ // // this.spec.color || this.$builtinColor(this.spec.styleClasses);
33
53
 
34
- Utils.type.ifObject(this.spec.fa, fa => {
35
- this.name = `fab fa-${fa.name}`;
36
- this.size = fa.size;
37
- });
54
+ // Utils.type.ifObject(this.spec.fa, fa => {
55
+ // this.name = `fab fa-${fa.name}`;
56
+ // this.size = fa.size;
57
+ // });
38
58
 
39
- Utils.type.ifObject(this.spec.material, material => {
40
- this.name = material.name;
41
- this.size = material.size;
42
- });
43
- }
59
+ // Utils.type.ifObject(this.spec.material, material => {
60
+ // this.name = material.name;
61
+ // this.size = material.size;
62
+ // });
63
+ // }
44
64
  }
45
65
  };
46
66
  </script>
@@ -0,0 +1,143 @@
1
+ <template>
2
+ <!-- Use `click.prevent` to prevent bubbling when clicking a dropdown button that is
3
+ located in a list row that has href. -->
4
+ <v-btn :type="type" :disabled="disabled || $isBusy || spec.disabled" :style="styles()" :class="$classes()"
5
+ :href="$href()" :rel="$rel()" :variant="variant"
6
+ :rounded="$classes().includes('rounded') || null"
7
+ :density="density"
8
+ :size="size"
9
+ :icon="$classes().includes('icon') ? $vuetify : null"
10
+ @click.prevent="
11
+ type == 'submit' ? $dispatchEvent('forms/submit') : $onClick()
12
+ ">
13
+ <span v-if="spec.icon"><common-icon :spec="spec.icon || {}" /></span>
14
+ <div :class="hideTextOnXs && spec.icon ? 'd-none d-sm-flex' : null">
15
+ {{ spec.text }}
16
+ </div>
17
+ </v-btn>
18
+ </template>
19
+
20
+ <script>
21
+ import { determineDensity, determineVariant, determineSize } from '../utils/constant'
22
+
23
+ export default {
24
+ props: {
25
+ spec: { type: Object, required: true },
26
+ type: { type: String, default: "button" },
27
+ disabled: { type: Boolean },
28
+ hideTextOnXs: { type: Boolean },
29
+ eventHandlers: { type: Object, default: null }
30
+ },
31
+ data: function () {
32
+ return {
33
+ // linkStyling: false,
34
+ // variant: 'elevated'
35
+ };
36
+ },
37
+ computed: {
38
+ density() {
39
+ return determineDensity(this.spec.styleClasses)
40
+ },
41
+ size() {
42
+ return determineSize(this.spec.styleClasses)
43
+ },
44
+ variant() {
45
+ return determineVariant(this.spec.styleClasses, 'elevated')
46
+ }
47
+ },
48
+ methods: {
49
+ // $ready() {
50
+ // this.$type.ifArray(this.spec.styleClasses, val => {
51
+ // this.linkStyling = val.includes("link");
52
+ // });
53
+
54
+ // // const vm = this
55
+ // // variants.forEach((value) => {
56
+ // // if (vm.$classes().includes(value)) {
57
+ // // vm.variant = value
58
+ // // }
59
+ // // })
60
+ // },
61
+ styles() {
62
+ const styles = this.$styles();
63
+ // if (this.linkStyling) {
64
+ if (this.$classes().includes('link')) {
65
+ styles["color"] = styles["color"] || "#1976d2";
66
+ }
67
+ return styles;
68
+ },
69
+ // classes() {
70
+ // const classes = this.$classes();
71
+ // return classes;
72
+ // },
73
+ $registryEnabled() {
74
+ return false;
75
+ }
76
+ }
77
+ };
78
+ </script>
79
+
80
+ <style lang="scss">
81
+ .v-btn {
82
+ &.link {
83
+ .v-icon {
84
+ font-size: 16px;
85
+ }
86
+ }
87
+ }
88
+ </style>
89
+
90
+ <style lang="scss" scoped>
91
+ a,
92
+ button {
93
+ min-width: 0;
94
+ margin: 0;
95
+ }
96
+
97
+ .v-btn {
98
+ &.link {
99
+ text-transform: none !important;
100
+ /* text-decoration: underline; */
101
+ padding-left: 0;
102
+ padding-right: 0;
103
+ /* `height: inherit/auto/initial` will stretch to max height when used inside a horizontal panel,
104
+ presumably because it is affected by the panel's flex arrangement. */
105
+ height: 16px;
106
+ font-size: 16px;
107
+ line-height: 1;
108
+ min-width: auto;
109
+ box-shadow: none !important;
110
+ }
111
+ }
112
+
113
+ .v-btn--rounded {
114
+ // Override .v-application.rounded
115
+ border-radius: 28px !important;
116
+ }
117
+
118
+ .v-banner__wrapper .v-btn:not(.v-btn--round).v-size--default {
119
+ min-width: 0;
120
+ padding: 0;
121
+ }
122
+
123
+ .v-banner__wrapper .v-btn.v-size--default {
124
+ font-size: 12px;
125
+ }
126
+
127
+ .breadcrumbs .v-btn.link {
128
+ display: inline-table;
129
+ justify-content: left;
130
+ white-space: normal;
131
+ }
132
+
133
+ @media only screen and (min-width: 600px) {
134
+ .v-banner__wrapper.v-btn.v-size--default {
135
+ font-size: 0.875rem;
136
+ }
137
+
138
+ .v-banner__wrapper.v-btn:not(.v-btn--round).v-size--default {
139
+ min-width: 64px;
140
+ padding: 0 16px;
141
+ }
142
+ }
143
+ </style>
@@ -1,24 +1,14 @@
1
1
  <template>
2
- <component
3
- :is="componentName"
4
- :class="cssClasses"
5
- :style="$styles()"
6
- :href="$href()"
7
- @click="$onClick()"
8
- >
9
- <v-row no-gutters class="full-height">
10
- <template v-for="(item, index) in spec.childViews">
11
- <glib-component
12
- v-if="isColumn(item)"
13
- :key="viewKey(item, index)"
14
- :spec="item"
15
- />
16
- <div
17
- v-else
18
- :key="'else-' + viewKey(item, index)"
19
- class="full-width"
20
- :style="innerStyles"
21
- >
2
+ <component :is="componentName" :class="cssClasses" :style="$styles()" :href="$href()" @click="$onClick()">
3
+ <!--
4
+ Only enable full-height when it's absolutely necessary because there seems to be an issue on some
5
+ browsers where full-height makes field typing laggy.
6
+ -->
7
+ <v-row no-gutters :class="fullHeight ? 'full-height' : null">
8
+ <!-- <v-row no-gutters> -->
9
+ <template v-for="(item, index) in spec.childViews" :key="viewKey(item, index)">
10
+ <glib-component v-if="isColumn(item)" :spec="item" />
11
+ <div v-else class="full-width" :style="innerStyles">
22
12
  <glib-component :spec="item" />
23
13
  </div>
24
14
  </template>
@@ -31,6 +21,7 @@ export default {
31
21
  props: {
32
22
  spec: { type: Object, required: true },
33
23
  eventHandlers: { type: Object, default: null },
24
+ fullHeight: { type: Boolean, default: false }
34
25
  },
35
26
  data() {
36
27
  return {
@@ -66,7 +57,8 @@ export default {
66
57
  },
67
58
  viewKey(item, index) {
68
59
  // Use view name for key to avoid component reuse issue
69
- return `view${index}_${item.view}`;
60
+ return `view${index}_${item.view}_value${item.value}`
61
+ // return item
70
62
  },
71
63
  $registryEnabled() {
72
64
  return false;
@@ -1,15 +1,12 @@
1
1
  <template>
2
- <!-- <common-tooltip :spec="spec"> -->
3
- <!-- <template v-slot:activator="{ on }"> -->
4
- <!-- <common-badge :spec="spec"> -->
5
- <v-avatar :size="spec.size">
6
- <!-- Use `img` instead of `v-img` otherwise the rounded border will not work. -->
7
- <img :style="$styles()" :src="spec.url || spec.base64Data" @click="$onClick()" />
8
- </v-avatar>
9
- <!-- </common-badge> -->
10
- <!-- </template> -->
11
- <!-- </common-tooltip>
12
- -->
2
+ <common-badge :spec="spec">
3
+ <v-avatar :size="spec.size">
4
+ <!-- Use `img` instead of `v-img` otherwise the rounded border will not work. -->
5
+ <!-- <img :style="$styles()" :src="spec.url || spec.base64Data" @click="$onClick()" /> -->
6
+
7
+ <v-img :style="$styles()" :src="spec.url || spec.base64Data" @click="$onClick()"></v-img>
8
+ </v-avatar>
9
+ </common-badge>
13
10
  </template>
14
11
 
15
12
  <script>
@@ -1,13 +1,18 @@
1
1
  <template>
2
- <v-alert :style="genericStyles()" :class="$classes()" :value="true" :color="color"
2
+ <v-alert :style="$styles()" :class="$classes()" :value="true" :color="color"
3
3
  :outlined="!$classes().includes('frameless') || null">
4
4
  <!-- <span class="padder" v-if="spec.icon"><common-icon :spec="spec.icon || {}" /></span> -->
5
5
  <!-- <common-icon :spec="spec.icon || {}" /> -->
6
+ <h3 v-if="spec.title">
7
+ {{ spec.title }}
8
+ </h3>
6
9
  <common-message :spec="spec" />
7
10
  </v-alert>
8
11
  </template>
9
12
 
10
13
  <script>
14
+ import { determineColor } from '../../utils/constant'
15
+
11
16
  export default {
12
17
  props: {
13
18
  spec: { type: Object, required: true }
@@ -20,18 +25,20 @@ export default {
20
25
  },
21
26
  methods: {
22
27
  $ready() {
23
- const vm = this;
28
+ this.color = determineColor(this.spec.styleClasses)
29
+
30
+ // const vm = this;
24
31
 
25
- this.$type.ifArray(this.spec.styleClasses, val => {
26
- ["success", "info", "warning", "error"].forEach(color => {
27
- if (val.remove(color)) {
28
- vm.color = color;
29
- }
30
- // if (val.includes(color)) {
31
- // vm.color = color
32
- // }
33
- });
34
- });
32
+ // this.$type.ifArray(this.spec.styleClasses, val => {
33
+ // ["success", "info", "warning", "error"].forEach(color => {
34
+ // if (val.remove(color)) {
35
+ // vm.color = color;
36
+ // }
37
+ // // if (val.includes(color)) {
38
+ // // vm.color = color
39
+ // // }
40
+ // });
41
+ // });
35
42
  }
36
43
  }
37
44
  };
@@ -1,21 +1,30 @@
1
1
  <template>
2
- <div :style="genericStyles()" :class="$classes()" :color="spec.color || color">
3
- <v-banner>
2
+ <!-- <div :style="genericStyles()" :class="$classes()" :color="spec.color || color"> -->
3
+ <v-banner :style="$styles()" :class="$classes()">
4
+ <template v-if="spec.icon" v-slot:prepend>
5
+ <common-icon slot="icon" :spec="spec.icon" />
6
+ </template>
4
7
 
5
- <template v-if="spec.icon" v-slot:prepend>
6
- <common-icon slot="icon" :spec="spec.icon" />
7
- </template>
8
+ <template v-slot:text>
9
+ <h3 v-if="spec.title">{{ spec.title }}</h3>
10
+ {{ spec.message }}
11
+ </template>
8
12
 
9
- <v-banner-text>{{ spec.message }}</v-banner-text>
13
+ <template v-slot:actions>
14
+ <template v-for="(item, index) in spec.buttons">
15
+ <common-dropdownMenu v-if="item.childButtons" :key="'left-' + index" :spec="item" :disabled="$isBusy" />
16
+ <common-button v-else :key="index" :spec="buttonSpec(item)" :disabled="$isBusy" :hide-text-on-xs="true" />
17
+ </template>
18
+ </template>
10
19
 
11
- <v-banner-actions>
20
+ <!-- <v-banner-actions>
12
21
  <template v-for="(item, index) in spec.buttons">
13
22
  <common-dropdownMenu v-if="item.childButtons" :key="'left-' + index" :spec="item" :disabled="$isBusy" />
14
23
  <common-button v-else :key="index" :spec="buttonSpec(item)" :disabled="$isBusy" :hide-text-on-xs="true" />
15
24
  </template>
16
- </v-banner-actions>
17
- </v-banner>
18
- </div>
25
+ </v-banner-actions> -->
26
+ </v-banner>
27
+ <!-- </div> -->
19
28
  </template>
20
29
 
21
30
  <script>
@@ -43,8 +52,8 @@ export default {
43
52
  },
44
53
  buttonSpec(item) {
45
54
  return Object.assign({}, item, {
46
- view: "button-v1",
47
- styleClasses: ["text"]
55
+ view: "button",
56
+ styleClasses: ["text", "small"]
48
57
  });
49
58
  }
50
59
  }
@@ -52,6 +61,11 @@ export default {
52
61
  </script>
53
62
 
54
63
  <style lang="scss" scoped>
64
+ // TODO: Avoid hardcoding colors. Can we use variables from Vuetify?
65
+ .warning {
66
+ background-color: #fb8c00;
67
+ }
68
+
55
69
  .frameless {
56
70
  padding: 0;
57
71
  }
@@ -67,3 +81,10 @@ export default {
67
81
  }
68
82
  }
69
83
  </style>
84
+
85
+ <style lang="scss">
86
+ .v-banner--density-default:not(.v-banner--one-line) .v-banner-actions {
87
+ margin-top: 0;
88
+ margin-bottom: 0;
89
+ }
90
+ </style>
@@ -1,8 +1,7 @@
1
1
  <template>
2
- <common-badge v-if="spec.badge" :spec="spec">
3
- <common-button :spec="spec" :disabled="$isBusy" />
4
- </common-badge>
5
- <common-button v-else :spec="spec" :disable="$isBusy" />
2
+ <common-button :spec="spec"
3
+ @[menter]="handleMouseEvent(spec.onMouseEnter)"
4
+ @[mleave]="handleMouseEvent(spec.onMouseLeave)" />
6
5
  </template>
7
6
 
8
7
  <script>
@@ -10,10 +9,22 @@ export default {
10
9
  props: {
11
10
  spec: { type: Object, required: true }
12
11
  },
12
+ // TODO: Reuse
13
+ computed: {
14
+ menter() {
15
+ return this.spec.onMouseEnter ? 'mouseenter' : null
16
+ },
17
+ mleave() {
18
+ return this.spec.onMouseLeave ? 'mouseleave' : null
19
+ }
20
+ },
13
21
  methods: {
22
+ handleMouseEvent(spec) {
23
+ GLib.action.execute(spec, this)
24
+ },
14
25
  action_merge(mergedSpec) {
15
26
  Object.assign(this.spec, mergedSpec);
16
- this.$refs.tooltip.updateData();
27
+ // this.$refs.tooltip.updateData();
17
28
  }
18
29
  }
19
30
  };