@appscode/design-system 1.1.0-beta.56 → 1.1.0-beta.57

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.56",
3
+ "version": "1.1.0-beta.57",
4
4
  "description": "A design system for Appscode websites and dashboards made using Bulma",
5
5
  "main": "main.scss",
6
6
  "scripts": {
@@ -15,6 +15,7 @@ export interface AcTableCol {
15
15
  name: string;
16
16
  type: "object" | "string" | "number" | "date" | "integer";
17
17
  priority: number;
18
+ width?: number;
18
19
  pathTemplate?: string;
19
20
  format?: string;
20
21
  link?: Record<string, unknown>;
@@ -77,6 +77,9 @@ 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
+
80
83
  const onWindowResize = () => {
81
84
  if (ac_table.value && props.isDynamicWidthTable) {
82
85
  const tableWidth = ac_table.value.clientWidth;
@@ -108,6 +111,26 @@ const emitSortEvent = (index: number) => {
108
111
  watch(
109
112
  () => props.tableHeaders,
110
113
  (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
+
111
134
  if (headerSortables.value.length === n.length) {
112
135
  n.forEach((th, idx) => {
113
136
  if (headerSortables.value[idx].enabled !== !!th?.sort?.enable) {
@@ -145,7 +168,7 @@ onUpdated(() => {
145
168
  <table-container ref="ac_table_container" @scroller="handleScroller">
146
169
  <table
147
170
  ref="ac_table"
148
- class="table ac-table is-bordered"
171
+ class="table ac-table"
149
172
  :class="{
150
173
  'is-fullwidth':
151
174
  !isDynamicWidthTable ||
@@ -153,9 +176,16 @@ onUpdated(() => {
153
176
  isTableEmpty ||
154
177
  isLoaderActive,
155
178
  // 'ac-striped': !columnStriped,
156
- // 'is-bordered': columnStriped,
179
+ 'is-bordered': columnStriped,
157
180
  }"
158
181
  >
182
+ <colgroup>
183
+ <col
184
+ v-for="(hw, idx) in headerWidths"
185
+ :key="`${hw}-${idx}`"
186
+ :width="`${(hw / totalWidth) * 100}%`"
187
+ />
188
+ </colgroup>
159
189
  <thead>
160
190
  <table-row v-if="isFullTableLoaderActive">
161
191
  <th v-for="i in loaderCols" :key="i">
@@ -199,11 +229,7 @@ onUpdated(() => {
199
229
  <i class="fa fa-exclamation-triangle" />
200
230
  </span>
201
231
  </th>
202
- <th
203
- ref="action-section"
204
- v-if="actionable"
205
- style="min-width: 100px"
206
- ></th>
232
+ <th ref="action-section" v-if="actionable"></th>
207
233
  <fake-table-cell
208
234
  v-if="fakeCellWidth > 0"
209
235
  :is-header-cell="true"
@@ -50,7 +50,7 @@ const valueType = computed(() => {
50
50
  });
51
51
 
52
52
  const maxCharacterLength = computed(() => {
53
- return Math.ceil(computedCellWidth.value / 8);
53
+ return Math.ceil(computedCellWidth.value / 10);
54
54
  });
55
55
 
56
56
  const primaryColor = computed(() => {