@soft-stech/bootsman-ui-shadcn 1.5.0 → 1.5.2

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.
@@ -4,91 +4,104 @@
4
4
  "title": "You can't compress the program without quantifying the open-source SSD pixel!",
5
5
  "status": "in progress",
6
6
  "label": "documentation",
7
- "priority": "medium"
7
+ "priority": "medium",
8
+ "age": "4 days"
8
9
  },
9
10
  {
10
11
  "id": "TASK-7878",
11
12
  "title": "Try to calculate the EXE feed, maybe it will index the multi-byte pixel!",
12
13
  "status": "backlog",
13
14
  "label": "documentation",
14
- "priority": "medium"
15
+ "priority": "medium",
16
+ "age": "4 days"
15
17
  },
16
18
  {
17
19
  "id": "TASK-7839",
18
20
  "title": "We need to bypass the neural TCP card!",
19
21
  "status": "todo",
20
22
  "label": "bug",
21
- "priority": "high"
23
+ "priority": "high",
24
+ "age": "4 days"
22
25
  },
23
26
  {
24
27
  "id": "TASK-5562",
25
28
  "title": "The SAS interface is down, bypass the open-source pixel so we can back up the PNG bandwidth!",
26
29
  "status": "backlog",
27
30
  "label": "feature",
28
- "priority": "medium"
31
+ "priority": "medium",
32
+ "age": "4 days"
29
33
  },
30
34
  {
31
35
  "id": "TASK-8686",
32
36
  "title": "I'll parse the wireless SSL protocol, that should driver the API panel!",
33
37
  "status": "canceled",
34
38
  "label": "feature",
35
- "priority": "medium"
39
+ "priority": "medium",
40
+ "age": "4 days"
36
41
  },
37
42
  {
38
43
  "id": "TASK-1280",
39
44
  "title": "Use the digital TLS panel, then you can transmit the haptic system!",
40
45
  "status": "done",
41
46
  "label": "bug",
42
- "priority": "high"
47
+ "priority": "high",
48
+ "age": "4 days"
43
49
  },
44
50
  {
45
51
  "id": "TASK-7262",
46
52
  "title": "The UTF8 application is down, parse the neural bandwidth so we can back up the PNG firewall!",
47
53
  "status": "done",
48
54
  "label": "feature",
49
- "priority": "high"
55
+ "priority": "high",
56
+ "age": "4 days"
50
57
  },
51
58
  {
52
59
  "id": "TASK-1138",
53
60
  "title": "Generating the driver won't do anything, we need to quantify the 1080p SMTP bandwidth!",
54
61
  "status": "in progress",
55
62
  "label": "feature",
56
- "priority": "medium"
63
+ "priority": "medium",
64
+ "age": "4 days"
57
65
  },
58
66
  {
59
67
  "id": "TASK-7184",
60
68
  "title": "We need to program the back-end THX pixel!",
61
69
  "status": "todo",
62
70
  "label": "feature",
63
- "priority": "low"
71
+ "priority": "low",
72
+ "age": "4 days"
64
73
  },
65
74
  {
66
75
  "id": "TASK-5160",
67
76
  "title": "Calculating the bus won't do anything, we need to navigate the back-end JSON protocol!",
68
77
  "status": "in progress",
69
78
  "label": "documentation",
70
- "priority": "high"
79
+ "priority": "high",
80
+ "age": "4 days"
71
81
  },
72
82
  {
73
83
  "id": "TASK-5618",
74
84
  "title": "Generating the driver won't do anything, we need to index the online SSL application!",
75
85
  "status": "done",
76
86
  "label": "documentation",
77
- "priority": "medium"
87
+ "priority": "medium",
88
+ "age": "4 days"
78
89
  },
79
90
  {
80
91
  "id": "TASK-6699",
81
92
  "title": "I'll transmit the wireless JBOD capacitor, that should hard drive the SSD feed!",
82
93
  "status": "backlog",
83
94
  "label": "documentation",
84
- "priority": "medium"
95
+ "priority": "medium",
96
+ "age": "4 days"
85
97
  },
86
98
  {
87
99
  "id": "TASK-2858",
88
100
  "title": "We need to override the online UDP bus!",
89
101
  "status": "backlog",
90
102
  "label": "bug",
91
- "priority": "medium"
103
+ "priority": "medium",
104
+ "age": "4 days"
92
105
  },
93
106
  {
94
107
  "id": "TASK-9864",
@@ -24,7 +24,16 @@ import {
24
24
  getSortedRowModel,
25
25
  useVueTable
26
26
  } from '@tanstack/vue-table'
27
- import { computed, watchEffect, ref, watch, onMounted, onBeforeMount, onUnmounted } from 'vue'
27
+ import {
28
+ computed,
29
+ watchEffect,
30
+ ref,
31
+ watch,
32
+ onMounted,
33
+ onBeforeMount,
34
+ onUnmounted,
35
+ nextTick
36
+ } from 'vue'
28
37
  import {
29
38
  BuiTable,
30
39
  BuiTableBody,
@@ -128,8 +137,12 @@ const table = useVueTable({
128
137
  onRowSelectionChange: (updaterOrValue) => {
129
138
  valueUpdater(updaterOrValue, rowSelection)
130
139
  },
131
- onColumnVisibilityChange: (updaterOrValue) => {
140
+ onColumnVisibilityChange: async (updaterOrValue) => {
132
141
  valueUpdater(updaterOrValue, columnVisibility)
142
+
143
+ await nextTick()
144
+
145
+ setInitialColumnWidths()
133
146
  },
134
147
  onColumnOrderChange: (updaterOrValue) => {
135
148
  valueUpdater(updaterOrValue, columnOrder)
@@ -3,16 +3,16 @@ import BuiTableHeader from '@/components/ui/table/BuiTableHeader.vue'
3
3
  import { useEventListener } from '@vueuse/core'
4
4
 
5
5
  export function useResizeColumns() {
6
+ type CELL = {
7
+ [key: string]: { cell: HTMLTableCellElement; initialWidth: number; minWidth: number }
8
+ }
6
9
  const isResizing = ref<boolean>(false)
7
10
  const resizingCellId = ref<string>('')
8
11
  const neighborCellId = ref<string>('')
9
- const cells = ref<
10
- | {
11
- [key: string]: { cell: HTMLTableCellElement; initialWidth: number }
12
- }
13
- | undefined
14
- >(undefined)
15
- const minCellWidth = ref<number>(90)
12
+ const cells = ref<CELL | undefined>(undefined)
13
+ const MIN_CELL_WIDTH = 90
14
+ const LAST_CELL_EXTRA_SPACE = 56
15
+ const ACTIONS_CELL_MIN_WIDTH = 10
16
16
  const calculatedColumnSizing = ref<Record<string, number> | undefined>(undefined)
17
17
  const tableHeaderElement = ref<InstanceType<typeof BuiTableHeader> | null>(null)
18
18
  const unregisterMouseMove = ref<Function | undefined>(undefined)
@@ -23,7 +23,7 @@ export function useResizeColumns() {
23
23
 
24
24
  //установить заданные как модель изначальные размеры
25
25
  headerCells.forEach((cell) => {
26
- const cellId = cell.id.split('_')[0]
26
+ const cellId = getCellId(cell)
27
27
 
28
28
  if (columnSizing && columnSizing[cellId]) {
29
29
  cell.style.width = columnSizing[cellId] + 'px'
@@ -35,15 +35,17 @@ export function useResizeColumns() {
35
35
  const getCells = () => {
36
36
  if (tableHeaderElement.value && tableHeaderElement.value.headRef) {
37
37
  const headerCells = [...tableHeaderElement.value.headRef.querySelectorAll('th')]
38
- const headerCellsWidths: {
39
- [key: string]: { cell: HTMLTableCellElement; initialWidth: number }
40
- } = headerCells.reduce((acc, cell) => {
41
- const cellId = cell.id.split('_')[0]
38
+ const headerCellsWidths: CELL = headerCells.reduce((acc, cell) => {
39
+ const cellId = getCellId(cell)
42
40
  return {
43
41
  ...acc,
44
42
  [cellId]: {
45
43
  cell: cell,
46
- initialWidth: cell.offsetWidth
44
+ initialWidth: cell.offsetWidth,
45
+ minWidth:
46
+ cellId === 'actions'
47
+ ? ACTIONS_CELL_MIN_WIDTH
48
+ : Math.min(cell.offsetWidth, MIN_CELL_WIDTH)
47
49
  }
48
50
  }
49
51
  }, {})
@@ -92,8 +94,8 @@ export function useResizeColumns() {
92
94
  const currentCell = cells.value[cell]
93
95
  const newWidth = !currentCell.cell.hasAttribute('can-resize')
94
96
  ? currentCell.initialWidth
95
- : Math.floor(currentCell.cell.offsetWidth) <= minCellWidth.value
96
- ? minCellWidth.value
97
+ : Math.floor(currentCell.cell.offsetWidth) <= currentCell.minWidth
98
+ ? currentCell.minWidth
97
99
  : currentCell.cell.offsetWidth
98
100
 
99
101
  currentCell.cell.style.width = newWidth + 'px'
@@ -103,18 +105,19 @@ export function useResizeColumns() {
103
105
  calculatedColumnSizing.value = updatedColumnSizingValue
104
106
  }
105
107
  }
106
- const getLastCellOnTheRightExtraSpace = (cell: HTMLTableCellElement) => {
107
- if (!cell.nextElementSibling) {
108
- const cellWrapperElement = cell.querySelector('.header-cell_wrapper') as HTMLElement | null
109
108
 
110
- if (cellWrapperElement) {
111
- return parseInt(window.getComputedStyle(cellWrapperElement).paddingRight)
112
- }
109
+ const getLastCellOnTheRightExtraSpace = (cell: HTMLTableCellElement) => {
110
+ if (getCellId(cell) === 'actions') {
111
+ return LAST_CELL_EXTRA_SPACE
113
112
  }
114
113
 
115
114
  return 0
116
115
  }
117
116
 
117
+ const getCellId = (cell: HTMLTableCellElement) => {
118
+ return cell.id.split('_')[0]
119
+ }
120
+
118
121
  const resizeCells = (
119
122
  cell: HTMLTableCellElement | null,
120
123
  neighborCell: HTMLTableCellElement | null,
@@ -133,7 +136,12 @@ export function useResizeColumns() {
133
136
  const newNeighborCellWidth = Math.floor(parseInt(neighborCell.style.width)) - movementX
134
137
 
135
138
  if (direction === 'left') {
136
- if (newCellWidth <= minCellWidth.value || !cell.hasAttribute('can-resize')) {
139
+ const min =
140
+ cells.value && cells.value[getCellId(cell)]
141
+ ? cells.value[getCellId(cell)].minWidth
142
+ : MIN_CELL_WIDTH
143
+
144
+ if (newCellWidth <= min || !cell.hasAttribute('can-resize')) {
137
145
  const nextCell = cell.previousElementSibling as HTMLTableCellElement | null
138
146
 
139
147
  resizeCells(nextCell, neighborCell, e)
@@ -142,11 +150,13 @@ export function useResizeColumns() {
142
150
  neighborCell.style.width = newNeighborCellWidth + 'px'
143
151
  }
144
152
  } else {
145
- if (
146
- newNeighborCellWidth <=
147
- minCellWidth.value + getLastCellOnTheRightExtraSpace(neighborCell) ||
148
- !neighborCell.hasAttribute('can-resize')
149
- ) {
153
+ const min =
154
+ cells.value && cells.value[getCellId(neighborCell)]
155
+ ? cells.value[getCellId(neighborCell)].minWidth +
156
+ getLastCellOnTheRightExtraSpace(neighborCell)
157
+ : MIN_CELL_WIDTH
158
+
159
+ if (newNeighborCellWidth <= min || !neighborCell.hasAttribute('can-resize')) {
150
160
  const nextNeighborCell = neighborCell.nextElementSibling as HTMLTableCellElement | null
151
161
 
152
162
  resizeCells(cell, nextNeighborCell, e)
@@ -170,9 +180,16 @@ export function useResizeColumns() {
170
180
 
171
181
  const resetCells = () => {
172
182
  if (cells.value) {
183
+ const updatedColumnSizingValue: Record<string, number> = {}
184
+
173
185
  for (let cell in cells.value) {
174
- cells.value[cell].cell.style.width = cells.value[cell].initialWidth + 'px'
186
+ const inititalWidth = cells.value[cell].initialWidth
187
+
188
+ cells.value[cell].cell.style.width = inititalWidth + 'px'
189
+ updatedColumnSizingValue[cell] = inititalWidth
175
190
  }
191
+
192
+ calculatedColumnSizing.value = updatedColumnSizingValue
176
193
  }
177
194
  }
178
195
 
@@ -180,15 +197,22 @@ export function useResizeColumns() {
180
197
  cells.value = getCells()
181
198
 
182
199
  if (cells.value) {
200
+ const updatedColumnSizingValue: Record<string, number> = {}
201
+
183
202
  for (let cell in cells.value) {
184
203
  if (!cells.value[cell].cell.style.width) {
185
204
  cells.value[cell].cell.style.width = cells.value[cell].initialWidth + 'px'
186
205
  }
206
+
207
+ updatedColumnSizingValue[cell] = cells.value[cell].cell.offsetWidth
187
208
  }
209
+
210
+ calculatedColumnSizing.value = updatedColumnSizingValue
188
211
  }
189
212
  }
190
213
 
191
214
  return {
215
+ cells,
192
216
  tableHeaderElement,
193
217
  calculatedColumnSizing,
194
218
  isResizing,
@@ -28,6 +28,7 @@ export default {
28
28
  ring: 'hsl(var(--ring))',
29
29
  background: 'hsl(var(--background))',
30
30
  foreground: 'hsl(var(--foreground))',
31
+ sidebar: 'hsl(var(--side-bar))',
31
32
  primary: {
32
33
  DEFAULT: 'hsl(var(--primary) / <alpha-value>)',
33
34
  foreground: 'hsl(var(--primary-foreground) / <alpha-value>)'