@stonecrop/atable 0.2.44 → 0.2.45

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.
@@ -0,0 +1,2 @@
1
+ export declare const isHtmlString: (htmlString: string) => boolean;
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,eAAgB,MAAM,YAG9C,CAAA"}
package/dist/utils.js ADDED
@@ -0,0 +1,4 @@
1
+ export const isHtmlString = (htmlString) => {
2
+ const $document = new DOMParser().parseFromString(htmlString, 'text/html');
3
+ return Array.from($document.body.childNodes).some(node => node.nodeType === 1);
4
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stonecrop/atable",
3
- "version": "0.2.44",
3
+ "version": "0.2.45",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "author": {
@@ -34,8 +34,8 @@
34
34
  "@vueuse/components": "^10.11.0",
35
35
  "@vueuse/core": "^11.1.0",
36
36
  "vue": "^3.5.6",
37
- "@stonecrop/themes": "0.2.44",
38
- "@stonecrop/utilities": "0.2.44"
37
+ "@stonecrop/utilities": "0.2.45",
38
+ "@stonecrop/themes": "0.2.45"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@microsoft/api-documenter": "^7.25.3",
@@ -20,8 +20,8 @@
20
20
  v-if="column.cellComponent"
21
21
  :is="column.cellComponent"
22
22
  :value="displayValue"
23
- v-bind="column.cellComponentProps">
24
- </component>
23
+ v-bind="column.cellComponentProps" />
24
+ <span v-else-if="isHtmlValue" v-html="displayValue" />
25
25
  <span v-else>{{ displayValue }}</span>
26
26
  </td>
27
27
  </template>
@@ -33,6 +33,7 @@ import { computed, CSSProperties, inject, ref, useTemplateRef } from 'vue'
33
33
 
34
34
  import TableDataStore from '.'
35
35
  import type { CellContext } from '@/types'
36
+ import { isHtmlString } from '@/utils'
36
37
 
37
38
  const {
38
39
  colIndex,
@@ -87,6 +88,11 @@ const displayValue = computed(() => {
87
88
  return cellData
88
89
  })
89
90
 
91
+ const isHtmlValue = computed(() => {
92
+ // TODO: check if display value is a native DOM element
93
+ return typeof displayValue.value === 'string' ? isHtmlString(displayValue.value) : false
94
+ })
95
+
90
96
  const handleInput = () => {
91
97
  if (column.mask) {
92
98
  // TODO: add masking to cell values
package/src/utils.ts ADDED
@@ -0,0 +1,4 @@
1
+ export const isHtmlString = (htmlString: string) => {
2
+ const $document = new DOMParser().parseFromString(htmlString, 'text/html')
3
+ return Array.from($document.body.childNodes).some(node => node.nodeType === 1)
4
+ }