@everchron/ec-shards 4.1.2 → 4.2.0

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": "4.1.2",
3
+ "version": "4.2.0",
4
4
  "private": false,
5
5
  "description": "Everchron Shards UI Library",
6
6
  "repository": "https://github.com/everchron/ec-shards.git",
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div class="ecs-data-grid-cell" :style="[fixedStyles]" :class="[fixedLeft ? 'fixed-left' : '', fixedLeftLast ? 'fixed-left-last' : '', fixedRight ? 'fixed-right' : '']">
3
3
  <div v-if="fixedRight" class="shadow" :class="fixedRight ? 'left' : ''" />
4
- <div class="ecs-data-grid-cell-inner" :style="[widthStyles, paddingStyles]" :data-test="computedId">
4
+ <div class="ecs-data-grid-cell-inner" :style="[widthStyles, paddingStyles]" :data-column="computedId" :data-test="computedId">
5
5
  <!-- @slot Tabe cell content slot. -->
6
6
  <slot></slot>
7
7
  </div>
@@ -60,18 +60,23 @@
60
60
 
61
61
  data () {
62
62
  return {
63
- widthStyles: {
64
- width: this.width + 'px',
65
- minWidth: this.minWidth + 'px',
66
- }
63
+ cellWidth:0,
64
+ cellFixedLeftOffset: ''
67
65
  }
68
66
  },
69
67
 
70
68
  computed: {
69
+ widthStyles(){
70
+ return {
71
+ width: this.cellWidth + 'px',
72
+ minWidth: this.minWidth + 'px',
73
+ }
74
+ },
75
+
71
76
  fixedStyles(){
72
77
  if(this.fixedLeft)
73
- if (this.fixedLeftOffset && this.fixedLeftOffset !== '')
74
- return { position: 'sticky', left: this.fixedLeftOffset + 'px', zIndex: '1' }
78
+ if (this.cellFixedLeftOffset && this.cellFixedLeftOffset !== '')
79
+ return { position: 'sticky', left: this.cellFixedLeftOffset + 'px', zIndex: '1' }
75
80
  else
76
81
  return { position: 'sticky', left: '0', zIndex: '1' }
77
82
  else if(this.fixedRight)
@@ -90,6 +95,21 @@
90
95
  return string.replace(/\W+/g, '-').toLowerCase() + '-column-cell'
91
96
  }
92
97
  },
98
+
99
+ methods: {
100
+ setWidth(val){
101
+ this.cellWidth = val
102
+ },
103
+
104
+ setFixedLeftOffset(val){
105
+ this.cellFixedLeftOffset = val
106
+ }
107
+ },
108
+
109
+ created(){
110
+ this.cellWidth = this.width
111
+ this.cellFixedLeftOffset = this.fixedLeftOffset
112
+ },
93
113
  }
94
114
  </script>
95
115
 
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div class="ecs-data-grid-head-cell" :style="[fixedStyles]" :class="[fixedLeft ? 'fixed-left' : '', fixedLeftLast ? 'fixed-left-last' : '', fixedRight ? 'fixed-right' : '']">
3
3
  <div v-if="fixedRight" class="shadow" :class="fixedRight ? 'left' : ''" />
4
- <div ref="resizer" class="ecs-data-grid-head-cell-inner" :style="[widthStyles, paddingStyles]" :data-test="computedId">
4
+ <div ref="resizer" class="ecs-data-grid-head-cell-inner" :style="[widthStyles, paddingStyles, resizeStyles]" :class="resizable ? 'resizable' : ''" :data-column="computedId" :data-test="computedId">
5
5
  <ecs-icon v-if="icon" :type="icon" size="20" color="#202127" :title="name" />
6
6
  <ecs-select v-else-if="select" @change="$emit('selection', $event.target.value)" type="invisible">
7
7
  <option v-for="(option, index) in select" :key="index" :value="option.value">{{ option.name }}</option>
@@ -92,6 +92,11 @@
92
92
  /** Overwrites the default padding. Should only be used when the cell contains e.g. a button which has it's own padding and thus needs to be aligned with the padding of other cells. Only pass padding shorthand values, for example: `4px 0 4px 8px`.*/
93
93
  padding: {
94
94
  type: String
95
+ },
96
+ /** Determines if the column should be resizable. */
97
+ resizable: {
98
+ type: Boolean,
99
+ default: false
95
100
  }
96
101
  },
97
102
 
@@ -102,15 +107,17 @@
102
107
  minWidth: this.minWidth + 'px',
103
108
  },
104
109
  newSort: this.sorting,
105
- resizeWidth: null
110
+ resizeWidth: null,
111
+ initialized: false,
112
+ cellFixedLeftOffset: ''
106
113
  }
107
114
  },
108
115
 
109
116
  computed: {
110
117
  fixedStyles(){
111
118
  if(this.fixedLeft)
112
- if (this.fixedLeftOffset && this.fixedLeftOffset !== '')
113
- return { position: 'sticky', left: this.fixedLeftOffset + 'px', zIndex: '1' }
119
+ if (this.cellFixedLeftOffset && this.cellFixedLeftOffset !== '')
120
+ return { position: 'sticky', left: this.cellFixedLeftOffset + 'px', zIndex: '1' }
114
121
  else
115
122
  return { position: 'sticky', left: '0', zIndex: '1' }
116
123
  else if(this.fixedRight)
@@ -144,6 +151,11 @@
144
151
  if(this.id && this.id !== '')
145
152
  string = this.id
146
153
  return string.replace(/\W+/g, '-').toLowerCase() + '-column-head'
154
+ },
155
+
156
+ resizeStyles(){
157
+ if(this.resizable)
158
+ return { resize: 'horizontal', overflow: 'hidden' }
147
159
  }
148
160
  },
149
161
 
@@ -158,7 +170,74 @@
158
170
 
159
171
  /** Emitted when the sort button is clicked. Returns the new sort order for the column. */
160
172
  this.$emit('sortby', this.newSort)
173
+ },
174
+
175
+ setColumnCellsWidth(){
176
+ if(!this.initialized) {
177
+ this.initialized = true
178
+ return
179
+ }
180
+
181
+ const resizedEl = document.querySelector('[data-column="'+ this.computedId +'"]')
182
+ const currentColumnWidth = resizedEl.offsetWidth
183
+
184
+ /** Emitted when the column has been resized. Returns the new width of the column in pixels. */
185
+ this.$emit('resizedWidth', currentColumnWidth)
186
+
187
+ let columnCells = document.querySelectorAll('[data-column="' + this.name.toLowerCase() + '-column-cell"]')
188
+ columnCells.forEach(cell => {
189
+ cell.parentElement.__vue__.setWidth(currentColumnWidth)
190
+ })
191
+
192
+ if(this.fixedLeft)
193
+ this.setCellsFixedLeftOffset()
194
+ },
195
+
196
+ setCellsFixedLeftOffset(){
197
+ let gridColumnCells = document.querySelectorAll('.ecs-data-grid-head-cell-inner')
198
+ let startIndex
199
+
200
+ for(let idx = 0; idx < gridColumnCells.length; idx++){
201
+ if(gridColumnCells[idx].attributes['data-column'].value == this.computedId){
202
+ startIndex = idx
203
+ }
204
+ else if(!isNaN(startIndex) && idx > startIndex && gridColumnCells[idx].parentElement.__vue__.fixedLeft && gridColumnCells[idx].parentElement.__vue__.cellFixedLeftOffset){
205
+ let updatedLeft = gridColumnCells[idx - 1].offsetWidth
206
+ if(gridColumnCells[idx - 1].parentElement.__vue__.cellFixedLeftOffset)
207
+ updatedLeft += gridColumnCells[idx - 1].parentElement.__vue__.cellFixedLeftOffset
208
+ gridColumnCells[idx].parentElement.__vue__.setFixedLeftOffset(updatedLeft)
209
+ let columnCells = document.querySelectorAll('[data-column="' + gridColumnCells[idx].parentElement.__vue__.name.toLowerCase() + '-column-cell"]')
210
+ columnCells.forEach(cell => {
211
+ cell.parentElement.__vue__.setFixedLeftOffset(updatedLeft)
212
+ })
213
+ }
214
+ }
215
+ },
216
+
217
+ setFixedLeftOffset(val){
218
+ this.cellFixedLeftOffset = val
219
+ }
220
+ },
221
+
222
+ created(){
223
+ this.cellFixedLeftOffset = this.fixedLeftOffset
224
+ this.resizeObserver = new ResizeObserver(entries => {
225
+ entries.forEach(entry => {
226
+ this.setColumnCellsWidth()
227
+ })
228
+ })
229
+ },
230
+
231
+ mounted(){
232
+ if(this.resizable && this.resizeObserver){
233
+ const resizeEl = document.querySelector('[data-column="'+ this.computedId +'"]')
234
+ this.resizeObserver.observe(resizeEl)
161
235
  }
236
+ },
237
+
238
+ destroyed(){
239
+ if(this.resizeObserver)
240
+ this.resizeObserver.disconnect()
162
241
  }
163
242
  }
164
243
  </script>
@@ -179,6 +258,31 @@
179
258
  column-gap: $spacing-10;
180
259
  height: 40px;
181
260
  position: relative;
261
+
262
+ &.resizable:after{
263
+ content: "";
264
+ width: 16px;
265
+ height: 16px;
266
+ right: 0;
267
+ bottom: 0;
268
+ background: svg-uri('<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="16" height="16" fill="white"/><path d="M4 12L12 4" stroke="#157EFB" stroke-linecap="round"/><path d="M8 12L12 8" stroke="#157EFB" stroke-linecap="round"/></svg>');
269
+ position: absolute;
270
+ transition: .2s;
271
+ opacity: 0;
272
+ transform: scale(.2);
273
+ transform-origin: bottom right;
274
+ pointer-events: none;
275
+ }
276
+
277
+ &.resizable:hover:after,
278
+ &.resizing:after{
279
+ opacity: 1;
280
+ transform: scale(1);
281
+ }
282
+
283
+ &::-webkit-resizer{
284
+ display: none;
285
+ }
182
286
  }
183
287
 
184
288
  &-text{
@@ -37,11 +37,13 @@
37
37
 
38
38
  .ecs-formatted{
39
39
  font-size: $type-scale-3-font-size;
40
- line-height: 1.4em;
41
- min-height: 1.4em;
40
+ line-height: $type-scale-3-line-height;
41
+ min-height: $type-scale-3-line-height;
42
42
 
43
43
  &-sml{
44
44
  font-size: $type-scale-2-font-size;
45
+ line-height: $type-scale-2-line-height;
46
+ min-height: $type-scale-2-line-height;
45
47
  }
46
48
 
47
49
  p{
@@ -77,19 +79,6 @@
77
79
  opacity: 1;
78
80
  }
79
81
  }
80
-
81
- &[href*="//"]:not([href*="everchron.com"]):after,
82
- &[href*="//"]:not([href*="everchron.me"]):after,
83
- &[href*="//"]:not([href*="everchron.co.uk"]):after,
84
- &[href*="//"]:not([href*="everchron.com.au"]):after,
85
- &[href*="//"]:not([href*="everchron.wtf"]):after{
86
- content: "";
87
- background: svg-uri('<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8"><path fill="#858E9E" d="M7.625,3.5 C7.524,3.5 7.434,3.459 7.366,3.395 C7.364,3.393 7.361,3.393 7.359,3.391 L6.427,2.458 L4.067,4.818 C3.823,5.061 3.427,5.061 3.183,4.818 C2.939,4.574 2.939,4.178 3.183,3.934 L5.542,1.575 L4.609,0.641 C4.607,0.639 4.607,0.636 4.605,0.634 C4.541,0.566 4.5,0.476 4.5,0.375 C4.5,0.168 4.668,0 4.875,0 L7.5,0 C7.776,0 8,0.224 8,0.5 L8,3.125 C8,3.332 7.832,3.5 7.625,3.5 Z M1,2.25 L1,6.75 C1,6.888 1.112,7 1.25,7 L5.75,7 C5.888,7 6,6.888 6,6.75 L6,4 L7,5 L7,7 C7,7.553 6.553,8 6,8 L1,8 C0.448,8 0,7.553 0,7 L0,2 C0,1.448 0.448,1 1,1 L3,1 L4,2 L1.25,2 C1.112,2 1,2.112 1,2.25 Z"/></svg>');
88
- width: 8px;
89
- display: inline-block;
90
- height: 8px;
91
- margin-left: 4px;
92
- }
93
82
  }
94
83
 
95
84
  ul{
@@ -163,13 +163,16 @@
163
163
  border: 0;
164
164
  }
165
165
 
166
- &:disabled,
167
- &[readonly] {
166
+ &:disabled{
168
167
  background-color: rgba($color-gray-6, .15);
169
168
  color: $color-gray-8;
170
169
  cursor: default;
171
170
  }
172
171
 
172
+ &[readonly] {
173
+ cursor: default;
174
+ }
175
+
173
176
  &-subtle{
174
177
  background-color: rgba($color-gray-8, .15);
175
178
  border: 1px solid rgba($color-gray-8, .2);
@@ -180,8 +183,7 @@
180
183
  box-shadow: none;
181
184
  }
182
185
 
183
- &:disabled,
184
- &[readonly] {
186
+ &:disabled{
185
187
  background-color: rgba($color-gray-8, .1);
186
188
  border: 1px solid rgba($color-gray-8, .1);
187
189
  opacity: .8;
@@ -6,6 +6,13 @@ import { Meta } from '@storybook/addon-docs/blocks';
6
6
  Changelog
7
7
  </h1>
8
8
 
9
+ ## Version 3.1.2 (15 December 2022)
10
+
11
+ ### Fixes
12
+
13
+ - Fixed readonly state styles of EcsInput
14
+ - Fixed line height scales of EcsFormatted
15
+
9
16
  ## Version 3.1.1 (29 November 2022)
10
17
 
11
18
  ### Fixes
@@ -14,15 +14,21 @@ export const grid = () => ({
14
14
  template: `<div style="width: 100%; height: 500px">
15
15
  <ecs-data-grid :striped="false">
16
16
  <template slot="head">
17
- <ecs-data-grid-head-cell name="First Column" :min-width="200" :width="400" fixed-left fixed-left-last />
18
- <ecs-data-grid-head-cell name="Second Column" :min-width="300" :width="500" />
19
- <ecs-data-grid-head-cell name="Third Column" :min-width="140" :width="200" />
17
+ <ecs-data-grid-head-cell name="First-Column" :min-width="140" :width="200" fixed-left resizable/>
18
+ <ecs-data-grid-head-cell name="Second-Column" :min-width="140" :width="200" :fixed-left-offset="200" fixed-left/>
19
+ <ecs-data-grid-head-cell name="Third-Column" :min-width="140" :width="200" :fixed-left-offset="400" fixed-left resizable/>
20
+ <ecs-data-grid-head-cell name="Fourth-Column" :min-width="200" :width="200" :fixed-left-offset="600" fixed-left fixed-left-last />
21
+ <ecs-data-grid-head-cell name="Fifth-Column" :min-width="200" :width="300" resizable />
22
+ <ecs-data-grid-head-cell name="Sixth-Column" :min-width="140" :width="200" />
20
23
  </template>
21
24
 
22
25
  <ecs-data-grid-row v-for="index in 100" :key="index">
23
- <ecs-data-grid-cell column="first" :min-width="200" :width="400" fixed-left fixed-left-last>First Column</ecs-data-grid-cell>
24
- <ecs-data-grid-cell column="second" :min-width="300" :width="500">Second Column</ecs-data-grid-cell>
25
- <ecs-data-grid-cell column="third" :min-width="140" :width="200">Third Column</ecs-data-grid-cell>
26
+ <ecs-data-grid-cell column="first-column" :min-width="140" :width="200" fixed-left>First Column</ecs-data-grid-cell>
27
+ <ecs-data-grid-cell column="second-column" :min-width="140" :width="200" :fixed-left-offset="200" fixed-left>Second Column</ecs-data-grid-cell>
28
+ <ecs-data-grid-cell column="third-column" :min-width="140" :width="200" :fixed-left-offset="400" fixed-left>Third Column</ecs-data-grid-cell>
29
+ <ecs-data-grid-cell column="fourth-column" :min-width="200" :width="200" :fixed-left-offset="600" fixed-left fixed-left-last>Fourth Column</ecs-data-grid-cell>
30
+ <ecs-data-grid-cell column="fifth-column" :min-width="200" :width="300">Fifth Column</ecs-data-grid-cell>
31
+ <ecs-data-grid-cell column="sixth-column" :min-width="140" :width="200">Sixth Column</ecs-data-grid-cell>
26
32
  </ecs-data-grid-row>
27
33
  </ecs-data-grid>
28
34
  </div>`,
@@ -9,8 +9,8 @@ export const input = () => ({
9
9
  components: { EcsInput },
10
10
  template: `<div>
11
11
  <ecs-input placeholder="Enter your name" class="mb-2" />
12
- <ecs-input readonly placeholder="Enter your name" class="mb-2" />
13
- <ecs-input disabled placeholder="Enter your name" />
12
+ <ecs-input readonly value="Readonly" class="mb-2" />
13
+ <ecs-input disabled value="Disabled" />
14
14
  </div>`,
15
15
  });
16
16
 
@@ -33,8 +33,9 @@ export const inputSizes = () => ({
33
33
  export const inputSubtle = () => ({
34
34
  components: { EcsInput },
35
35
  template: `<div>
36
- <ecs-input placeholder="Enter your name" class="mb-2" />
37
- <ecs-input subtle placeholder="Enter your name" />
36
+ <ecs-input subtle placeholder="Enter your name" class="mb-2" />
37
+ <ecs-input subtle readonly value="Readonly" class="mb-2" />
38
+ <ecs-input subtle disabled value="Disabled" />
38
39
  </div>`,
39
40
  });
40
41