@appscode/design-system 1.1.0-beta.63 → 1.1.0-beta.65

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.1.0-beta.63",
3
+ "version": "1.1.0-beta.65",
4
4
  "description": "A design system for Appscode websites and dashboards made using Bulma",
5
5
  "main": "main.scss",
6
6
  "scripts": {
@@ -77,9 +77,6 @@ const handleScroller = (value: number) => {
77
77
  emit("scroller", value);
78
78
  };
79
79
 
80
- const headerWidths = ref<number[]>([]);
81
- const totalWidth = ref<number>(0);
82
-
83
80
  const onWindowResize = () => {
84
81
  if (ac_table.value && props.isDynamicWidthTable) {
85
82
  const tableWidth = ac_table.value.clientWidth;
@@ -111,26 +108,6 @@ const emitSortEvent = (index: number) => {
111
108
  watch(
112
109
  () => props.tableHeaders,
113
110
  (n) => {
114
- // calculated column width based on percentages
115
- headerWidths.value = n.map((th) => th.width || 1);
116
- totalWidth.value = headerWidths.value.reduce((p, c) => p + c, 0);
117
- let collapsibleWidth = 0;
118
- let actionsWidth = 0;
119
- const collapsibleWidthPercent = 70 / (ac_table.value?.clientWidth || 0);
120
- const actionsWidthPercent = 140 / (ac_table.value?.clientWidth || 0);
121
- if (props.collapsible) {
122
- collapsibleWidth =
123
- (totalWidth.value * collapsibleWidthPercent) /
124
- (1 - collapsibleWidthPercent);
125
- headerWidths.value = [collapsibleWidth, ...headerWidths.value];
126
- }
127
- if (props.actionable) {
128
- actionsWidth =
129
- (totalWidth.value * actionsWidthPercent) / (1 - actionsWidthPercent);
130
- headerWidths.value = [...headerWidths.value, actionsWidth];
131
- }
132
- totalWidth.value += collapsibleWidth + actionsWidth;
133
-
134
111
  if (headerSortables.value.length === n.length) {
135
112
  n.forEach((th, idx) => {
136
113
  if (headerSortables.value[idx].enabled !== !!th?.sort?.enable) {
@@ -179,13 +156,6 @@ onUpdated(() => {
179
156
  // 'is-bordered': columnStriped,
180
157
  }"
181
158
  >
182
- <colgroup>
183
- <col
184
- v-for="(hw, idx) in headerWidths"
185
- :key="`${hw}-${idx}`"
186
- :width="`${(hw / totalWidth) * 100}%`"
187
- />
188
- </colgroup>
189
159
  <thead>
190
160
  <table-row v-if="isFullTableLoaderActive">
191
161
  <th v-for="i in loaderCols" :key="i">
@@ -473,6 +443,8 @@ onUpdated(() => {
473
443
  animation: collapse 0.5s ease-in-out;
474
444
  }
475
445
  }
446
+
447
+ white-space: nowrap;
476
448
  }
477
449
 
478
450
  .options-items {
@@ -8,18 +8,10 @@ interface Props {
8
8
  const props = withDefaults(defineProps<Props>(), {
9
9
  cellWidth: null,
10
10
  });
11
-
12
- const styleOb = computed(() => {
13
- const ob: { width?: string } = {};
14
- if (props.cellWidth) {
15
- ob.width = `${props.cellWidth}px`;
16
- }
17
- return ob || {};
18
- });
19
11
  </script>
20
12
 
21
13
  <template>
22
- <td :style="styleOb">
14
+ <td>
23
15
  <slot />
24
16
  </td>
25
17
  </template>
@@ -51,10 +51,10 @@ const printableStringObjs = computed(() => {
51
51
 
52
52
  const indexOfCharacterLengthExceed = computed(() => {
53
53
  let idx = -1;
54
- let cumulativeLen = 0;
54
+ let cumulativeLen = 2;
55
55
  for (const [index, po] of printableStringObjs.value.entries()) {
56
56
  const newLen = cumulativeLen + po.print.length + 2;
57
- if (newLen + 2 > props.maxCharacterLength) {
57
+ if (newLen + 4 > props.maxCharacterLength) {
58
58
  idx = index;
59
59
  break;
60
60
  }
@@ -66,34 +66,37 @@ const indexOfCharacterLengthExceed = computed(() => {
66
66
  </script>
67
67
 
68
68
  <template>
69
- <tags v-if="printableStringObjs.length">
70
- <tag
71
- v-for="(printableStringOb, idx) in printableStringObjs.slice(
72
- 0,
73
- indexOfCharacterLengthExceed
74
- )"
75
- :key="`${printableStringOb.print}-${idx}`"
76
- >
77
- <value-with-modal
78
- v-if="printableStringOb.exceededLength"
79
- :title="`${cellTitle}: ${idx}`"
80
- :value="printableStringOb.value"
81
- :print="printableStringOb.print"
82
- />
83
- <template v-else> {{ printableStringOb.print }} </template>
84
- </tag>
85
-
86
- <tag v-if="indexOfCharacterLengthExceed !== printableStringObjs.length">
87
- <a @click.prevent.stop="showFullData = true">
88
- <ellipsis-icon />
89
- <json-show-modal
90
- :open="showFullData"
91
- @closemodal="showFullData = false"
92
- :editor-title="cellTitle"
93
- :editor-content="items"
69
+ <span>
70
+ <tags v-if="printableStringObjs.length">
71
+ <tag
72
+ v-for="(printableStringOb, idx) in printableStringObjs.slice(
73
+ 0,
74
+ indexOfCharacterLengthExceed
75
+ )"
76
+ :key="`${printableStringOb.print}-${idx}`"
77
+ modifierClasses="is-primary is-light"
78
+ >
79
+ <value-with-modal
80
+ v-if="printableStringOb.exceededLength"
81
+ :title="`${cellTitle}: ${idx}`"
82
+ :value="printableStringOb.value"
83
+ :print="printableStringOb.print"
94
84
  />
95
- </a>
96
- </tag>
97
- </tags>
98
- <p v-else>-</p>
85
+ <template v-else> {{ printableStringOb.print }} </template>
86
+ </tag>
87
+
88
+ <tag v-if="indexOfCharacterLengthExceed !== printableStringObjs.length">
89
+ <a @click.prevent.stop="showFullData = true">
90
+ <ellipsis-icon />
91
+ <json-show-modal
92
+ :open="showFullData"
93
+ @closemodal="showFullData = false"
94
+ :editor-title="cellTitle"
95
+ :editor-content="items"
96
+ />
97
+ </a>
98
+ </tag>
99
+ </tags>
100
+ <p v-else>{{ printableStringObjs }}</p>
101
+ </span>
99
102
  </template>
@@ -1,12 +1,6 @@
1
1
  <script setup lang="ts">
2
- import {
3
- computed,
4
- defineAsyncComponent,
5
- nextTick,
6
- onMounted,
7
- ref,
8
- watch,
9
- } from "vue";
2
+ import { computed, defineAsyncComponent, ref } from "vue";
3
+ import { useElementSize } from "@vueuse/core";
10
4
 
11
5
  interface Props {
12
6
  isLoaderActive?: boolean;
@@ -37,7 +31,6 @@ const loaderDarkThemePrimaryColor = "#2e323c";
37
31
  const loaderLightThemeSecondaryColor = "#ecebeb";
38
32
  const loaderDarkThemeSecondaryColor = "#21272e";
39
33
 
40
- const computedCellWidth = ref(50);
41
34
  const cellLoaderDiv = ref<HTMLElement | null>(null);
42
35
  const cellDiv = ref<HTMLElement | null>(null);
43
36
 
@@ -49,8 +42,16 @@ const valueType = computed(() => {
49
42
  } else return typeof props.value;
50
43
  });
51
44
 
45
+ const { width: cellLoaderDivWidth } = useElementSize(cellLoaderDiv, {
46
+ width: 150,
47
+ height: 30,
48
+ });
49
+ const { width: cellDivWidth } = useElementSize(cellDiv, {
50
+ width: 150,
51
+ height: 30,
52
+ });
52
53
  const maxCharacterLength = computed(() => {
53
- return Math.ceil(computedCellWidth.value / 10);
54
+ return Math.ceil(cellDivWidth.value / 6);
54
55
  });
55
56
 
56
57
  const primaryColor = computed(() => {
@@ -64,41 +65,14 @@ const secondaryColor = computed(() => {
64
65
  ? loaderDarkThemeSecondaryColor
65
66
  : loaderLightThemeSecondaryColor;
66
67
  });
67
-
68
- const calcCellWidth = () => {
69
- if (props.isLoaderActive) {
70
- nextTick(() => {
71
- if (cellLoaderDiv.value) {
72
- computedCellWidth.value = cellLoaderDiv.value.offsetWidth;
73
- }
74
- });
75
- } else {
76
- nextTick(() => {
77
- if (cellDiv.value) {
78
- computedCellWidth.value = cellDiv.value.offsetWidth;
79
- }
80
- });
81
- }
82
- };
83
-
84
- onMounted(() => {
85
- calcCellWidth();
86
- });
87
-
88
- watch(
89
- () => props.isLoaderActive,
90
- () => {
91
- calcCellWidth();
92
- }
93
- );
94
68
  </script>
95
69
 
96
70
  <template>
97
71
  <div v-if="isLoaderActive" ref="cellLoaderDiv" :style="{ maxWidth: '300px' }">
98
72
  <content-loader
99
- :view-box="`0 0 ${computedCellWidth || 300} 10`"
73
+ :view-box="`0 0 ${cellLoaderDivWidth || 300} 10`"
100
74
  :speed="2"
101
- :key="computedCellWidth"
75
+ :key="cellLoaderDivWidth"
102
76
  :primaryColor="primaryColor"
103
77
  :secondaryColor="secondaryColor"
104
78
  />
@@ -119,7 +93,7 @@ watch(
119
93
  data-testid="array-cell-value"
120
94
  />
121
95
  <template v-else>
122
- <span class="is-ellipsis-1" :title="tooltip" data-testid="cell-value">{{
96
+ <span :title="tooltip" data-testid="cell-value">{{
123
97
  value || (value === 0 ? 0 : "-")
124
98
  }}</span>
125
99
  </template>
@@ -9,7 +9,7 @@ interface Props {
9
9
 
10
10
  const props = withDefaults(defineProps<Props>(), {
11
11
  cellTitle: "cell title",
12
- maxCharacterLength: 50,
12
+ maxCharacterLength: 64,
13
13
  obj: () => ({}),
14
14
  });
15
15
 
@@ -33,7 +33,7 @@ const objKeys = computed(() => {
33
33
 
34
34
  const printableStringObjs = computed(() => {
35
35
  return objKeys.value.map((key) => {
36
- let value = props.obj[key];
36
+ let value: string = props.obj[key] as string;
37
37
  if (typeof value === "object" && value !== null) {
38
38
  value = JSON.stringify(value);
39
39
  }
@@ -46,10 +46,10 @@ const printableStringObjs = computed(() => {
46
46
 
47
47
  const indexOfCharacterLengthExceed = computed(() => {
48
48
  let idx = -1;
49
- let cumulativeLen = 0;
49
+ let cumulativeLen = 2;
50
50
  for (const [index, po] of printableStringObjs.value.entries()) {
51
51
  const newLen = cumulativeLen + po.print.length + 2;
52
- if (newLen + 2 > props.maxCharacterLength) {
52
+ if (newLen + 4 > props.maxCharacterLength) {
53
53
  idx = index;
54
54
  break;
55
55
  }
@@ -61,38 +61,40 @@ const indexOfCharacterLengthExceed = computed(() => {
61
61
  </script>
62
62
 
63
63
  <template>
64
- <tags v-if="printableStringObjs.length">
65
- <tag
66
- v-for="printableStringOb in printableStringObjs.slice(
67
- 0,
68
- indexOfCharacterLengthExceed
69
- )"
70
- :key="printableStringOb.key"
71
- modifierClasses="is-primary is-light"
72
- >
73
- <value-with-modal
74
- v-if="printableStringOb.exceededLength"
75
- :title="printableStringOb.key"
76
- :value="printableStringOb.value as string"
77
- :print="printableStringOb.print"
78
- />
79
- <template v-else> {{ printableStringOb.print }} </template>
80
- </tag>
81
-
82
- <tag
83
- modifierClasses="is-info is-light"
84
- v-if="indexOfCharacterLengthExceed !== printableStringObjs.length"
85
- >
86
- <a @click.prevent.stop="showFullData = true">
87
- <ellipsis-icon />
88
- <json-show-modal
89
- :open="showFullData"
90
- @closemodal="showFullData = false"
91
- :editor-title="cellTitle"
92
- :editor-content="obj"
64
+ <span>
65
+ <tags v-if="printableStringObjs.length">
66
+ <tag
67
+ v-for="printableStringOb in printableStringObjs.slice(
68
+ 0,
69
+ indexOfCharacterLengthExceed
70
+ )"
71
+ :key="printableStringOb.key"
72
+ modifierClasses="is-primary is-light"
73
+ >
74
+ <value-with-modal
75
+ v-if="printableStringOb.exceededLength"
76
+ :title="printableStringOb.key"
77
+ :value="printableStringOb.value"
78
+ :print="printableStringOb.print"
93
79
  />
94
- </a>
95
- </tag>
96
- </tags>
97
- <p v-else>-</p>
80
+ <template v-else> {{ printableStringOb.print }} </template>
81
+ </tag>
82
+
83
+ <tag
84
+ modifierClasses="is-info is-light"
85
+ v-if="indexOfCharacterLengthExceed !== printableStringObjs.length"
86
+ >
87
+ <a @click.prevent.stop="showFullData = true">
88
+ <ellipsis-icon />
89
+ <json-show-modal
90
+ :open="showFullData"
91
+ @closemodal="showFullData = false"
92
+ :editor-title="cellTitle"
93
+ :editor-content="obj"
94
+ />
95
+ </a>
96
+ </tag>
97
+ </tags>
98
+ <p v-else>-</p>
99
+ </span>
98
100
  </template>