@everchron/ec-shards 7.5.1 → 7.5.3

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": "@everchron/ec-shards",
3
- "version": "7.5.1",
3
+ "version": "7.5.3",
4
4
  "private": false,
5
5
  "description": "Everchron Shards UI Library",
6
6
  "repository": "https://github.com/everchron/ec-shards.git",
@@ -18,7 +18,7 @@
18
18
 
19
19
  <div v-if="firstNonStaticCell" class="first-cell-spacer" />
20
20
  <ecs-icon v-if="icon" :type="icon" size="20" color="#202127" :title="name" />
21
- <ecs-select v-else-if="select" @change="$emit('selection', $event.target.value)" type="invisible">
21
+ <ecs-select v-else-if="select" v-model="selectCellValue" @change="$emit('selection', selectCellValue)" type="invisible">
22
22
  <option v-for="(option, index) in select" :key="index" :selected="option.selected" :value="option.value">{{ option.name }}</option>
23
23
  </ecs-select>
24
24
  <div v-else class="ecs-data-grid-head-cell-text" :title="name">
@@ -103,7 +103,8 @@
103
103
  },
104
104
  /** If passed, the head cell won't render the slot in the text, but a select menu with the passed options instead. This is useful when one column should be able to switch the data that is shown in it. For example, you could have a column with a selector in the head cell which allows you to switch between ECID, Bates Range, and Trial Exhibit No. The array needs to contain objects with `value`, `name` and `selected`. */
105
105
  select: {
106
- type: Array
106
+ type: Array,
107
+ validator: v => v.every(o => o.hasOwnProperty('value') && o.hasOwnProperty('name') && o.hasOwnProperty('selected'))
107
108
  },
108
109
  /** Determines if the column should be sortable. */
109
110
  sortable: {
@@ -142,7 +143,8 @@
142
143
  resizeWidth: null,
143
144
  initialized: false,
144
145
  beingResized : false,
145
- cellFixedLeftOffset: ''
146
+ cellFixedLeftOffset: '',
147
+ selectCellValue: ''
146
148
  }
147
149
  },
148
150
 
@@ -286,6 +288,19 @@
286
288
  }
287
289
  },
288
290
 
291
+ watch: {
292
+ select: {
293
+ handler(newVal) {
294
+ newVal.forEach(option => {
295
+ if (option.selected) {
296
+ this.selectCellValue = option.value
297
+ }
298
+ })
299
+ },
300
+ deep: true
301
+ }
302
+ },
303
+
289
304
  created(){
290
305
  this.cellFixedLeftOffset = this.fixedLeftOffset
291
306
  this.resizeObserver = new ResizeObserver(entries => {
@@ -300,6 +315,13 @@
300
315
  const resizeEls = document.querySelectorAll('[data-column="'+ this.computedId +'"]')
301
316
  resizeEls.forEach(el => { this.resizeObserver.observe(el) })
302
317
  }
318
+
319
+ if(this.select && this.select !== ''){
320
+ this.select.forEach(option => {
321
+ if(option.selected)
322
+ this.selectCellValue = option.value
323
+ })
324
+ }
303
325
  },
304
326
 
305
327
  destroyed(){
@@ -8,7 +8,7 @@
8
8
  </ecs-flex-row>
9
9
  <ecs-flex-row :gap="4">
10
10
  <span>Page</span>
11
- <ecs-select @change="$emit('updatePage', $event.target.value)" :disabled="!totalPages" size="sml">
11
+ <ecs-select v-model="updatedCurrentPage" @change="$emit('updatePage', Number(updatedCurrentPage))" :disabled="!totalPages" size="sml">
12
12
  <option v-for="n in totalPages" :key="n" :value="n" :selected="n === currentPage">{{ n }}</option>
13
13
  </ecs-select>
14
14
  <span v-if="totalPages" class="total">of {{ totalPages }}</span>
@@ -36,7 +36,7 @@
36
36
 
37
37
  <ecs-flex-row v-if="showItemsPerPage && type == 'paginated'" :gap="4" class="ecs-pagination-items">
38
38
  <span>Items per page</span>
39
- <ecs-select @change="$emit('itemsPerPage', $event.target.value)" :disabled="loading" size="sml">
39
+ <ecs-select v-model="updatedItemsPerPageSelected" @change="$emit('itemsPerPage', Number(updatedItemsPerPageSelected))" :disabled="loading" size="sml">
40
40
  <option v-for="n in itemsPerPage" :key="n" :value="n" :selected="n === itemsPerPageSelected">{{ n }}</option>
41
41
  </ecs-select>
42
42
  </ecs-flex-row>
@@ -123,6 +123,13 @@
123
123
  }
124
124
  },
125
125
 
126
+ data() {
127
+ return {
128
+ updatedItemsPerPageSelected: this.itemsPerPageSelected,
129
+ updatedCurrentPage: this.currentPage,
130
+ }
131
+ },
132
+
126
133
  computed: {
127
134
  hasRange() {
128
135
  if (
@@ -134,6 +141,16 @@
134
141
  this.itemRangeTotal !== '')
135
142
  return true
136
143
  }
144
+ },
145
+
146
+ watch: {
147
+ currentPage(newVal) {
148
+ this.updatedCurrentPage = newVal;
149
+ },
150
+
151
+ itemsPerPageSelected(newVal) {
152
+ this.updatedItemsPerPageSelected = newVal;
153
+ },
137
154
  }
138
155
  }
139
156
  </script>
@@ -48,7 +48,9 @@ export default {
48
48
  /** Sets the `name` attribute. */
49
49
  name: String,
50
50
  /** Allows to programmatically select a specific option item via it's value. */
51
- value: String
51
+ value: {
52
+ type: [String, Number]
53
+ }
52
54
  },
53
55
 
54
56
  data() {
@@ -95,8 +97,8 @@ export default {
95
97
  onChange(event) {
96
98
  this.currentValue = event.target.value;
97
99
  this.hasPlaceholder = false
98
- this.$emit('change', event)
99
100
  this.$emit('input', this.currentValue)
101
+ this.$emit('change', event)
100
102
  }
101
103
  },
102
104
 
@@ -109,8 +111,8 @@ export default {
109
111
  option.selected = true
110
112
  if (newValue !== this.currentValue) {
111
113
  this.currentValue = newValue
112
- this.$emit('change', { target: { value: newValue } });
113
114
  this.$emit('input', this.currentValue)
115
+ this.$emit('change', { target: { value: newValue } });
114
116
  }
115
117
  }
116
118
  }
@@ -29,9 +29,9 @@ export const headCellSelect = () => ({
29
29
  data() {
30
30
  return {
31
31
  selectOptions: [
32
- { value: 'ecid', name: 'ECID' },
32
+ { value: 'ecid', name: 'ECID', selected: false },
33
33
  { value: 'bates', name: 'Bates Range', selected: true },
34
- { value: 'trialex', name: 'Trial Exhibit'}
34
+ { value: 'trialex', name: 'Trial Exhibit', selected: false}
35
35
  ]
36
36
  }
37
37
  },