@appscode/design-system 1.0.43-alpha.144 → 1.0.43-alpha.145

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appscode/design-system",
3
- "version": "1.0.43-alpha.144",
3
+ "version": "1.0.43-alpha.145",
4
4
  "description": "A design system for Appscode websites and dashboards made using Bulma",
5
5
  "main": "main.scss",
6
6
  "scripts": {
@@ -0,0 +1,143 @@
1
+ <template>
2
+ <table-container>
3
+ <table
4
+ class="table ac-info-table is-fullwidth"
5
+ :class="{ 'pl-0 pr-0': removeContentPadding }"
6
+ >
7
+ <tbody v-if="isFullTableLoaderActive">
8
+ <table-row v-for="i in loaderCols" :key="i">
9
+ <table-cell>
10
+ <cell-value :is-loader-active="true" />
11
+ </table-cell>
12
+ <table-cell>
13
+ <cell-value :is-loader-active="true" />
14
+ </table-cell>
15
+ </table-row>
16
+ </tbody>
17
+ <tbody
18
+ v-else
19
+ :class="{
20
+ 'no-data-available has-text-centered p-10': isTableEmpty,
21
+ 'pl-0 pr-0': removeContentPadding,
22
+ }"
23
+ >
24
+ <template v-if="!isTableEmpty">
25
+ <table-row
26
+ v-for="(tableHeader, idx) in tableHeaders"
27
+ :key="headerLabels[idx]"
28
+ >
29
+ <table-cell>
30
+ <slot :name="`table-cell-icon-${idx}`" />
31
+ {{ headerLabels[idx] }}
32
+ </table-cell>
33
+ <table-cell v-if="isLoaderActive">
34
+ <cell-value :is-loader-active="true" />
35
+ </table-cell>
36
+ <slot v-else :name="`slot-${idx}`" />
37
+ </table-row>
38
+ </template>
39
+
40
+ <empty-table-info v-else />
41
+ </tbody>
42
+ </table>
43
+
44
+ <!-- pagination start -->
45
+ <slot name="table-pagination" />
46
+ <!-- pagination end -->
47
+ </table-container>
48
+ </template>
49
+
50
+ <script>
51
+ import { defineComponent, defineAsyncComponent } from "vue";
52
+
53
+ export default defineComponent({
54
+ props: {
55
+ isLoaderActive: {
56
+ type: Boolean,
57
+ default: false,
58
+ },
59
+ isTableEmpty: {
60
+ type: Boolean,
61
+ default: true,
62
+ },
63
+ tableHeaders: {
64
+ type: Array,
65
+ default: () => [],
66
+ },
67
+ removeContentPadding: {
68
+ type: Boolean,
69
+ default: false,
70
+ },
71
+ },
72
+
73
+ components: {
74
+ TableContainer: defineAsyncComponent(() =>
75
+ import("../../v2/table/TableContainer.vue").then(
76
+ (module) => module.default
77
+ )
78
+ ),
79
+ EmptyTableInfo: defineAsyncComponent(() =>
80
+ import("../../v2/table/EmptyTableInfo.vue").then(
81
+ (module) => module.default
82
+ )
83
+ ),
84
+ TableRow: defineAsyncComponent(() =>
85
+ import("./TableRow.vue").then((module) => module.default)
86
+ ),
87
+ TableCell: defineAsyncComponent(() =>
88
+ import("./TableCell.vue").then((module) => module.default)
89
+ ),
90
+ CellValue: defineAsyncComponent(() =>
91
+ import("./table-cell/CellValue.vue").then((module) => module.default)
92
+ ),
93
+ },
94
+
95
+ data() {
96
+ return {
97
+ loaderCols: 5,
98
+ headerSortables: [],
99
+ };
100
+ },
101
+
102
+ computed: {
103
+ isFullTableLoaderActive() {
104
+ return !this.tableHeaders.length;
105
+ },
106
+ headerLabels() {
107
+ return this.tableHeaders.map((th) =>
108
+ typeof th === "string" ? th : th?.name || "Label"
109
+ );
110
+ },
111
+ },
112
+
113
+ watch: {
114
+ tableHeaders: {
115
+ immediate: true,
116
+ handler(n) {
117
+ if (this.headerSortables.length === n.length) {
118
+ n.forEach((th, idx) => {
119
+ if (this.headerSortables[idx].enabled !== !!th?.sort?.enable) {
120
+ this.headerSortables[idx].enabled = !!th?.sort?.enable;
121
+ this.headerSortables[idx].mode = "";
122
+ }
123
+ });
124
+ } else {
125
+ this.headerSortables = n.map((th) => {
126
+ if (typeof th === "string") {
127
+ return {
128
+ enabled: false,
129
+ mode: "",
130
+ };
131
+ } else {
132
+ return {
133
+ enabled: !!th?.sort?.enable,
134
+ mode: "",
135
+ };
136
+ }
137
+ });
138
+ }
139
+ },
140
+ },
141
+ },
142
+ });
143
+ </script>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <table-container>
2
+ <table-container ref="ac-table-container" @scroller="handleScroller">
3
3
  <table
4
4
  ref="ac-table"
5
5
  class="table ac-table ac-striped"
@@ -140,12 +140,10 @@ export default defineComponent({
140
140
  default: 1920,
141
141
  },
142
142
  },
143
- emits: ["sort"],
143
+ emits: ["sort", "scroller"],
144
144
  components: {
145
145
  TableContainer: defineAsyncComponent(() =>
146
- import("../../v2/table/TableContainer.vue").then(
147
- (module) => module.default
148
- )
146
+ import("./TableContainer.vue").then((module) => module.default)
149
147
  ),
150
148
  TableRow: defineAsyncComponent(() =>
151
149
  import("./TableRow.vue").then((module) => module.default)
@@ -222,7 +220,6 @@ export default defineComponent({
222
220
  },
223
221
  },
224
222
  },
225
-
226
223
  updated() {
227
224
  this.$nextTick(() => {
228
225
  this.onWindowResize();
@@ -230,6 +227,9 @@ export default defineComponent({
230
227
  },
231
228
 
232
229
  methods: {
230
+ handleScroller(value) {
231
+ this.$emit("scroller", value);
232
+ },
233
233
  onWindowResize() {
234
234
  if (this.$refs["ac-table"] && this.isDynamicWidthTable) {
235
235
  const tableWidth = this.$refs["ac-table"].clientWidth;
@@ -0,0 +1,35 @@
1
+ <template>
2
+ <div class="ac-table-container table-container" ref="tableContainer">
3
+ <slot />
4
+ </div>
5
+ </template>
6
+
7
+ <script lang="ts">
8
+ import { emit } from 'process'
9
+ import { defineComponent, ref, onMounted, nextTick } from 'vue'
10
+
11
+ export default defineComponent({
12
+ emits: ['scroller'],
13
+
14
+ setup(props, { emit }) {
15
+ const tableContainer = ref(null)
16
+
17
+ function isScrollerShowing() {
18
+ return tableContainer.value.scrollWidth > tableContainer.value.clientWidth
19
+ }
20
+
21
+ onMounted(() => {
22
+ setTimeout(() => {
23
+ nextTick(() => {
24
+ console.log({ tableContainer: tableContainer.value })
25
+ emit('scroller', isScrollerShowing())
26
+ })
27
+ }, 50)
28
+ })
29
+
30
+ return {
31
+ tableContainer,
32
+ }
33
+ },
34
+ })
35
+ </script>