@awes-io/ui 2.29.3 → 2.31.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/CHANGELOG.md CHANGED
@@ -3,6 +3,40 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.31.0](https://github.com/awes-io/client/compare/@awes-io/ui@2.30.0...@awes-io/ui@2.31.0) (2021-10-21)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * bump version ([ed4612a](https://github.com/awes-io/client/commit/ed4612ad6f81c698a06590c91356c0a47be87f81))
12
+
13
+
14
+ ### Features
15
+
16
+ * bump version ([dc0250d](https://github.com/awes-io/client/commit/dc0250d3b671a7df341ea5e6bb8d752577011c0f))
17
+
18
+
19
+
20
+
21
+
22
+ # [2.30.0](https://github.com/awes-io/client/compare/@awes-io/ui@2.29.3...@awes-io/ui@2.30.0) (2021-10-21)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **aw-modal:** overlay-aside animation fixed ([cd4e960](https://github.com/awes-io/client/commit/cd4e960f377af53df9f20492c857667baf636ba0))
28
+ * **aw-select-object:** do not encode search param ([4141879](https://github.com/awes-io/client/commit/41418793d0e3f3dd732155867b35ec9b98753333))
29
+ * sanitize v-html ([95ecf78](https://github.com/awes-io/client/commit/95ecf78cd95e9e8cab96d81e9fa0697a1e86e3bc))
30
+
31
+
32
+ ### Features
33
+
34
+ * **aw-select:** disabling options added ([a83da1a](https://github.com/awes-io/client/commit/a83da1a0986d081f036ac4ce92ed7d9cc528105b))
35
+
36
+
37
+
38
+
39
+
6
40
  ## [2.29.3](https://github.com/awes-io/client/compare/@awes-io/ui@2.29.2...@awes-io/ui@2.29.3) (2021-10-18)
7
41
 
8
42
 
@@ -29,6 +29,11 @@
29
29
  @apply bg-mono-800;
30
30
  }
31
31
  }
32
+
33
+ &[disabled] > span {
34
+ opacity: 0.5;
35
+ cursor: not-allowed;
36
+ }
32
37
  }
33
38
 
34
39
  @screen md {
@@ -435,7 +435,7 @@ $modal-t-dur: 250ms;
435
435
  transform: none;
436
436
 
437
437
  .aw-modal__dialog {
438
- transform: translateX(100%);
438
+ transform: translateX(95%);
439
439
  }
440
440
  }
441
441
 
@@ -1,4 +1,5 @@
1
- import { split, reduce } from 'rambdax'
1
+ import insane from 'insane'
2
+ import { split, reduce, clone } from 'rambdax'
2
3
 
3
4
  export const ucFirst = (text = '') => {
4
5
  return text.charAt(0).toUpperCase() + text.substr(1)
@@ -34,3 +35,56 @@ export const hashStringToIndex = (str, limit) => {
34
35
 
35
36
  return hash
36
37
  }
38
+
39
+ export const SANITIZE_DEFAULTS = {
40
+ allowedAttributes: {
41
+ a: ['href', 'name', 'target', 'class', 'style'],
42
+ iframe: ['allowfullscreen', 'frameborder', 'src', 'class', 'style'],
43
+ img: [
44
+ 'src',
45
+ 'alt',
46
+ 'srcset',
47
+ 'sizes',
48
+ 'width',
49
+ 'height',
50
+ 'class',
51
+ 'style'
52
+ ],
53
+ button: ['class', 'id', 'style'],
54
+ allowedTags: [
55
+ 'a',
56
+ 'b',
57
+ 'br',
58
+ 'del',
59
+ 'div',
60
+ 'em',
61
+ 'i',
62
+ 'img',
63
+ 'ins',
64
+ 'kbd',
65
+ 'li',
66
+ 'ol',
67
+ 'p',
68
+ 'span',
69
+ 'strike',
70
+ 'strong',
71
+ 'sub',
72
+ 'sup',
73
+ 'u',
74
+ 'ul'
75
+ ]
76
+ }
77
+ }
78
+
79
+ export const getSanitizer = (options, strict = false) => {
80
+ let _options = clone(options)
81
+
82
+ if (!strict) {
83
+ _options = { ...SANITIZE_DEFAULTS, ..._options }
84
+ }
85
+
86
+ return (html) => (typeof html === 'string' ? insane(html, _options) : html)
87
+ }
88
+
89
+ export const sanitize = (html) =>
90
+ typeof html === 'string' ? insane(html, SANITIZE_DEFAULTS) : html
@@ -27,7 +27,7 @@
27
27
  class="inline mr-1"
28
28
  />
29
29
 
30
- <slot v-html="label">{{ label }}</slot>
30
+ <slot>{{ label }}</slot>
31
31
 
32
32
  <component
33
33
  :is="_iconSecondComponent"
@@ -192,13 +192,20 @@
192
192
  <!-- options list -->
193
193
  <template v-if="optionsList.length && _isEditingOptions">
194
194
  <AwDropdownButton
195
- v-for="({ optionLabel, optionValue, index, active },
195
+ v-for="({
196
+ optionLabel,
197
+ optionValue,
198
+ index,
199
+ active,
200
+ disabled
201
+ },
196
202
  i) in optionsList"
197
203
  :key="`${optionLabel}-${index}`"
198
204
  :active="active"
199
205
  :data-select-index="index"
200
206
  :data-selected="active ? '' : null"
201
207
  :data-value="optionValue"
208
+ :disabled="disabled"
202
209
  tabindex="-1"
203
210
  data-arrow-focus
204
211
  >
@@ -244,6 +251,7 @@ import CancelToken from 'axios/lib/cancel/CancelToken'
244
251
  import isCancel from 'axios/lib/cancel/isCancel'
245
252
  import arrowFocusMixin from '@AwMixins/arrow-focus'
246
253
  import { TEST_ID_ATTR } from '@AwUtils/constants'
254
+ import { sanitize } from '@AwUtils/string'
247
255
 
248
256
  const returnSelf = (arg) => arg
249
257
 
@@ -274,6 +282,11 @@ export default {
274
282
  default: ''
275
283
  },
276
284
 
285
+ optionDisabled: {
286
+ type: Function,
287
+ default: () => false
288
+ },
289
+
277
290
  trackBy: {
278
291
  type: String,
279
292
  default: ''
@@ -423,6 +436,7 @@ export default {
423
436
  const matchSerach = this._hasInternalSearch
424
437
  ? this._matchSearch(option)
425
438
  : true
439
+ const disabled = this.optionDisabled(option)
426
440
 
427
441
  return inRange && matchSerach
428
442
  ? acc.concat({
@@ -430,7 +444,8 @@ export default {
430
444
  optionLabel: this._getLabel(option),
431
445
  optionValue: this._getValue(option),
432
446
  index,
433
- active
447
+ active,
448
+ disabled
434
449
  })
435
450
  : acc
436
451
  }, [])
@@ -654,11 +669,11 @@ export default {
654
669
 
655
670
  _highlightOption(option) {
656
671
  if (!this.searchPhrase.trim().length) {
657
- return option
672
+ return sanitize(option)
658
673
  }
659
674
 
660
675
  try {
661
- const opt = String(option)
676
+ const opt = String(sanitize(option))
662
677
  const phrase = this._escapeRegExpSpecialChars(this.searchPhrase)
663
678
  const matches = opt.match(new RegExp(phrase, 'gi'))
664
679
  return this._addBoldTagsToString(opt, matches)
@@ -120,13 +120,20 @@
120
120
  <!-- options list -->
121
121
  <template v-if="optionsList.length">
122
122
  <AwDropdownButton
123
- v-for="({ optionLabel, optionValue, index, active },
123
+ v-for="({
124
+ optionLabel,
125
+ optionValue,
126
+ index,
127
+ active,
128
+ disabled
129
+ },
124
130
  i) in optionsList"
125
131
  :key="`${optionLabel}-${index}`"
126
132
  :active="active"
127
133
  :data-select-index="index"
128
134
  :data-selected="active ? '' : null"
129
135
  :data-value="optionValue"
136
+ :disabled="disabled"
130
137
  tabindex="-1"
131
138
  data-arrow-focus
132
139
  >
@@ -174,6 +181,7 @@ import CancelToken from 'axios/lib/cancel/CancelToken'
174
181
  import isCancel from 'axios/lib/cancel/isCancel'
175
182
  import arrowFocusMixin from '@AwMixins/arrow-focus'
176
183
  import { TEST_ID_ATTR } from '@AwUtils/constants'
184
+ import { sanitize } from '@AwUtils/string'
177
185
  import AwSelectInput from './_AwSelectInput.vue'
178
186
 
179
187
  const isObject = (val) => val !== null && typeof val === 'object'
@@ -211,6 +219,11 @@ export default {
211
219
  default: ''
212
220
  },
213
221
 
222
+ optionDisabled: {
223
+ type: Function,
224
+ default: () => false
225
+ },
226
+
214
227
  trackBy: {
215
228
  type: String,
216
229
  default: ''
@@ -339,13 +352,15 @@ export default {
339
352
  const optionLabel = this._getLabel(option)
340
353
  const optionValue = this._getValue(option)
341
354
  const active = this._isActive(optionValue)
355
+ const disabled = this.optionDisabled(option)
342
356
 
343
357
  return acc.concat({
344
358
  option,
345
359
  optionLabel,
346
360
  optionValue,
347
361
  index,
348
- active
362
+ active,
363
+ disabled
349
364
  })
350
365
  } else {
351
366
  return acc
@@ -597,9 +612,11 @@ export default {
597
612
  }
598
613
 
599
614
  try {
600
- return option.replace(this._optionSearchRegEx, '<b>$&</b>')
615
+ return sanitize(
616
+ option.replace(this._optionSearchRegEx, '<b>$&</b>')
617
+ )
601
618
  } catch (e) {
602
- return option
619
+ return sanitize(option)
603
620
  }
604
621
  },
605
622
 
@@ -730,10 +747,7 @@ export default {
730
747
  this.cancellation = CancelToken.source()
731
748
 
732
749
  try {
733
- let config = this.options(
734
- encodeURIComponent(this.searchPhrase),
735
- page
736
- )
750
+ let config = this.options(this.searchPhrase, page)
737
751
 
738
752
  if (typeof config === 'string') {
739
753
  config = {
@@ -129,7 +129,7 @@ export default {
129
129
 
130
130
  computed: {
131
131
  switchers() {
132
- return MODES.map(mode => this.$t(`AwMarkdownEditor.${mode}`))
132
+ return MODES.map((mode) => this.$t(`AwMarkdownEditor.${mode}`))
133
133
  },
134
134
 
135
135
  isPreview() {
@@ -66,7 +66,7 @@
66
66
  >
67
67
  <div
68
68
  class="flex-1 text-sm text-mono-400"
69
- v-html="$t('AwLayoutDefault.footer')"
69
+ v-html="$sanitize($t('AwLayoutDefault.footer'))"
70
70
  ></div>
71
71
  <div class="flex-1 text-center">
72
72
  <AwButton
@@ -19,7 +19,7 @@
19
19
  </div>
20
20
 
21
21
  <div
22
- v-html="$t('AwLayoutDefault.footer')"
22
+ v-html="$sanitize($t('AwLayoutDefault.footer'))"
23
23
  class="pt-8 text-sm"
24
24
  ></div>
25
25
  </div>
@@ -14,7 +14,7 @@
14
14
  class="aw-header-notification__content container-fluid"
15
15
  >
16
16
  <AwIcon v-if="config.icon" :name="config.icon" />
17
- <span v-html="config.text" class="text-center"></span>
17
+ <span v-html="$sanitize(config.text)" class="text-center"></span>
18
18
  <AwButton
19
19
  v-for="({ listeners, ...props }, i) in config.buttons"
20
20
  :key="i"
@@ -17,7 +17,7 @@
17
17
  {{ text }}
18
18
  <span
19
19
  v-if="description"
20
- v-html="description"
20
+ v-html="$sanitize(description)"
21
21
  class="aw-mobile-menu-item__description"
22
22
  ></span>
23
23
  </span>
@@ -53,7 +53,7 @@
53
53
  </template>
54
54
 
55
55
  <script>
56
- import insane from 'insane'
56
+ import { sanitize } from '@AwUtils/string'
57
57
  import AwIcon from '@AwAtoms/AwIcon/AwIcon.vue'
58
58
  import AwIconSystemMono from '@AwAtoms/AwIcon/AwIconSystemMono.vue'
59
59
 
@@ -100,6 +100,6 @@ export default {
100
100
  }
101
101
  },
102
102
 
103
- sanitize: insane
103
+ sanitize
104
104
  }
105
105
  </script>
@@ -0,0 +1,5 @@
1
+ import { sanitize } from '@AwUtils/string'
2
+
3
+ export default (ctx, inject) => {
4
+ inject('sanitize', sanitize)
5
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awes-io/ui",
3
- "version": "2.29.3",
3
+ "version": "2.31.0",
4
4
  "description": "User Interface (UI) components",
5
5
  "keywords": [
6
6
  "ui",
@@ -9,7 +9,7 @@
9
9
  "awes-io",
10
10
  "material design"
11
11
  ],
12
- "homepage": "https://www.awes.io",
12
+ "homepage": "https://awes.io",
13
13
  "bugs": {
14
14
  "url": "https://github.com/awes-io/client/issues"
15
15
  },
@@ -123,5 +123,5 @@
123
123
  "vue-template-compiler": "^2.6.10",
124
124
  "webfonts-generator": "^0.4.0"
125
125
  },
126
- "gitHead": "5c5a00315a440874e7c43aaf2c4ac2e9b035c74d"
126
+ "gitHead": "c2b5c259d670718d335f294b240d5c264f4c30b9"
127
127
  }
package/readme.md ADDED
@@ -0,0 +1 @@
1
+ Awes.io/Ui
package/assets/.DS_Store DELETED
Binary file
Binary file
Binary file
Binary file