@dataloop-ai/components 0.19.183 → 0.19.185
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 +5 -3
- package/src/components/essential/DlIcon/DlIcon.vue +97 -60
- package/src/components/essential/DlMarkDown/DlMarkdown.vue +28 -0
- package/src/components/essential/DlMarkDown/index.ts +2 -0
- package/src/components/essential/index.ts +1 -0
- package/src/demos/DlMarkdownDemo.vue +44 -0
- package/src/demos/index.ts +3 -1
- package/vite.config.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dataloop-ai/components",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.185",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": "./index.ts",
|
|
6
6
|
"./models": "./models.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"check-only": "if grep -E -H -r --exclude-dir=.git --exclude-dir=node_modules --exclude=*.json --exclude=*.yml '^(describe|it).only' .; then echo 'Found only in test files' && exit 1; fi"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@dataloop-ai/icons": "^3.0.
|
|
25
|
+
"@dataloop-ai/icons": "^3.0.32",
|
|
26
26
|
"@types/flat": "^5.0.2",
|
|
27
27
|
"@types/lodash": "^4.14.184",
|
|
28
28
|
"@types/sortablejs": "^1.15.7",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"flat": "^5.0.2",
|
|
31
31
|
"highlight.js": "^11.8.0",
|
|
32
32
|
"lodash": "^4.17.21",
|
|
33
|
+
"marked": "^11.1.1",
|
|
33
34
|
"moment": "^2.29.4",
|
|
34
35
|
"sass": "^1.51.0",
|
|
35
36
|
"sass-loader": "^12.6.0",
|
|
@@ -39,7 +40,8 @@
|
|
|
39
40
|
"vanilla-jsoneditor": "^0.10.2",
|
|
40
41
|
"vue-demi": "^0.14.5",
|
|
41
42
|
"vue-sortable": "^0.1.3",
|
|
42
|
-
"vue2-teleport": "^1.0.1"
|
|
43
|
+
"vue2-teleport": "^1.0.1",
|
|
44
|
+
"zero-md": "^2.5.3"
|
|
43
45
|
},
|
|
44
46
|
"devDependencies": {
|
|
45
47
|
"@babel/core": "^7.17.9",
|
|
@@ -37,7 +37,14 @@
|
|
|
37
37
|
<script lang="ts">
|
|
38
38
|
import { isString } from 'lodash'
|
|
39
39
|
import { v4 } from 'uuid'
|
|
40
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
computed,
|
|
42
|
+
defineComponent,
|
|
43
|
+
onUnmounted,
|
|
44
|
+
ref,
|
|
45
|
+
toRefs,
|
|
46
|
+
watch
|
|
47
|
+
} from 'vue-demi'
|
|
41
48
|
import { getColor, loggerFactory, stringStyleToRecord } from '../../../utils'
|
|
42
49
|
import { COLORED_ICONS } from '@dataloop-ai/icons/types'
|
|
43
50
|
|
|
@@ -74,100 +81,130 @@ export default defineComponent({
|
|
|
74
81
|
}
|
|
75
82
|
},
|
|
76
83
|
emits: ['click', 'mousemove', 'mouseup', 'mousedown'],
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
setup(props) {
|
|
85
|
+
const { styles, color, size, icon, svg, inline, svgSource } =
|
|
86
|
+
toRefs(props)
|
|
87
|
+
|
|
88
|
+
const svgIcon = ref(null)
|
|
89
|
+
const isDestroyed = ref(false)
|
|
90
|
+
const uuid = `dl-icon-${v4()}`
|
|
91
|
+
const externalIconSource = 'material-icons'
|
|
92
|
+
const logger = loggerFactory('dl-icon')
|
|
93
|
+
|
|
94
|
+
const computedStyles = computed<Record<string, string>>(() => {
|
|
95
|
+
const generatedStyles = isString(styles.value)
|
|
96
|
+
? stringStyleToRecord(styles.value)
|
|
97
|
+
: styles.value
|
|
98
|
+
|
|
99
|
+
return Object.assign({}, generatedStyles, {
|
|
100
|
+
width: size.value,
|
|
101
|
+
height: size.value
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
const cssIconVars = computed<Record<string, string>>(() => {
|
|
91
106
|
return {
|
|
92
|
-
'--dl-icon-font-size': `${
|
|
93
|
-
'--dl-icon-color':
|
|
107
|
+
'--dl-icon-font-size': `${size.value}`,
|
|
108
|
+
'--dl-icon-color': color.value
|
|
94
109
|
? // todo: remove this. this is needed for now until the swap of DLBTN in OA
|
|
95
110
|
getColor(
|
|
96
|
-
|
|
111
|
+
color.value === 'secondary'
|
|
97
112
|
? 'q-color-secondary'
|
|
98
|
-
:
|
|
113
|
+
: color.value,
|
|
99
114
|
'dl-color-icon-default'
|
|
100
115
|
)
|
|
101
116
|
: 'inherit'
|
|
102
117
|
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
)
|
|
114
|
-
},
|
|
115
|
-
cleanedIconName(): string {
|
|
116
|
-
return this.icon.startsWith('icon-dl-')
|
|
117
|
-
? this.icon.replace('icon-dl-', '')
|
|
118
|
-
: this.icon
|
|
119
|
-
},
|
|
120
|
-
isSVG(): boolean {
|
|
121
|
-
if (!this.icon) {
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
const cleanedIconName = computed<string>(() => {
|
|
121
|
+
return icon.value.startsWith('icon-dl-')
|
|
122
|
+
? icon.value.replace('icon-dl-', '')
|
|
123
|
+
: icon.value
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
const isSVG = computed<boolean>(() => {
|
|
127
|
+
if (!icon.value) {
|
|
122
128
|
return false
|
|
123
129
|
}
|
|
124
130
|
|
|
125
|
-
if (
|
|
131
|
+
if (svg.value) {
|
|
126
132
|
return true
|
|
127
133
|
}
|
|
128
134
|
|
|
129
135
|
const coloredIcons = Object.values(COLORED_ICONS)
|
|
130
|
-
return coloredIcons.includes(
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
return coloredIcons.includes(cleanedIconName.value as any)
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
const externalIcon = computed<boolean>(() => {
|
|
140
|
+
return (
|
|
141
|
+
!icon.value.startsWith('icon-dl-') &&
|
|
142
|
+
!icon.value.startsWith('fas') &&
|
|
143
|
+
!icon.value.startsWith('fa-')
|
|
144
|
+
)
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
const inlineStyles = computed<Record<string, string>>(() => {
|
|
148
|
+
return { display: inline.value ? 'inline-flex' : 'flex' }
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
watch(icon, () => {
|
|
152
|
+
const possibleToLoadSvg =
|
|
153
|
+
isSVG.value && icon.value && icon.value !== ''
|
|
154
|
+
if (possibleToLoadSvg) {
|
|
155
|
+
loadSvg()
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
const loadSvg = () => {
|
|
141
160
|
return new Promise<void>((resolve, reject) => {
|
|
142
161
|
const svgElement = new Image()
|
|
143
|
-
svgElement.setAttribute('height',
|
|
144
|
-
svgElement.setAttribute('width',
|
|
162
|
+
svgElement.setAttribute('height', size.value)
|
|
163
|
+
svgElement.setAttribute('width', size.value)
|
|
145
164
|
|
|
146
165
|
svgElement.onload = () => {
|
|
147
|
-
//
|
|
148
|
-
if (
|
|
166
|
+
// In order to handle events and loading that occur mid unmounting.
|
|
167
|
+
if (isDestroyed.value) {
|
|
149
168
|
return
|
|
150
169
|
}
|
|
151
|
-
const container =
|
|
170
|
+
const container = svgIcon.value as HTMLDivElement
|
|
152
171
|
if (!container) {
|
|
153
172
|
reject(new Error('No Ref'))
|
|
154
173
|
return
|
|
155
174
|
}
|
|
156
|
-
container.setAttribute('height',
|
|
157
|
-
container.setAttribute('width',
|
|
175
|
+
container.setAttribute('height', size.value)
|
|
176
|
+
container.setAttribute('width', size.value)
|
|
158
177
|
container?.firstChild?.replaceWith(svgElement)
|
|
159
178
|
resolve()
|
|
160
179
|
}
|
|
161
180
|
|
|
162
181
|
try {
|
|
163
|
-
svgElement.src =
|
|
164
|
-
? `${
|
|
165
|
-
: `https://raw.githubusercontent.com/dataloop-ai/icons/main/assets/${
|
|
182
|
+
svgElement.src = svgSource.value
|
|
183
|
+
? `${svgSource.value}/${cleanedIconName.value}.svg`
|
|
184
|
+
: `https://raw.githubusercontent.com/dataloop-ai/icons/main/assets/${cleanedIconName.value}.svg`
|
|
166
185
|
} catch (e) {
|
|
167
186
|
reject(e)
|
|
168
187
|
}
|
|
169
188
|
})
|
|
170
189
|
}
|
|
190
|
+
|
|
191
|
+
onUnmounted(() => {
|
|
192
|
+
isDestroyed.value = true
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
return {
|
|
196
|
+
uuid,
|
|
197
|
+
svgIcon,
|
|
198
|
+
externalIconSource,
|
|
199
|
+
computedStyles,
|
|
200
|
+
cssIconVars,
|
|
201
|
+
isSVG,
|
|
202
|
+
cleanedIconName,
|
|
203
|
+
loadSvg,
|
|
204
|
+
isDestroyed,
|
|
205
|
+
externalIcon,
|
|
206
|
+
inlineStyles
|
|
207
|
+
}
|
|
171
208
|
}
|
|
172
209
|
})
|
|
173
210
|
</script>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="dl-mark-down" v-html="renderedMD" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { defineComponent, computed, toRefs } from 'vue-demi'
|
|
7
|
+
import { marked } from 'marked'
|
|
8
|
+
|
|
9
|
+
export default defineComponent({
|
|
10
|
+
name: 'DlMarkdown',
|
|
11
|
+
props: {
|
|
12
|
+
text: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: ''
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
setup(props) {
|
|
18
|
+
const { text } = toRefs(props)
|
|
19
|
+
|
|
20
|
+
const renderedMD = computed(() => marked(text.value))
|
|
21
|
+
return {
|
|
22
|
+
renderedMD
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<style scoped lang="scss"></style>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<DlMarkdown :text="mdText" />
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import { DlMarkdown } from '../components'
|
|
9
|
+
import { defineComponent } from 'vue-demi'
|
|
10
|
+
|
|
11
|
+
export default defineComponent({
|
|
12
|
+
components: {
|
|
13
|
+
DlMarkdown
|
|
14
|
+
},
|
|
15
|
+
setup() {
|
|
16
|
+
const mdText = `# Hi
|
|
17
|
+
## This is a markdown demo
|
|
18
|
+
### It's a simple demo
|
|
19
|
+
#### It's a simple demo
|
|
20
|
+
##### It's a simple demo
|
|
21
|
+
|
|
22
|
+
*It's a simple demo*
|
|
23
|
+
|
|
24
|
+
**It's a simple demo**
|
|
25
|
+
|
|
26
|
+
***It's a simple demo***
|
|
27
|
+
|
|
28
|
+
> It's a simple demo
|
|
29
|
+
- [ ] It's a simple demo
|
|
30
|
+
- [x] It's a simple demo
|
|
31
|
+
|
|
32
|
+
[It's a simple demo]('https://www.google.com')
|
|
33
|
+
|
|
34
|
+
\`It's a simple demo\`
|
|
35
|
+
\`\`\`javascript
|
|
36
|
+
const highlight = "code";
|
|
37
|
+
\`\`\`
|
|
38
|
+
`
|
|
39
|
+
return {
|
|
40
|
+
mdText
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
</script>
|
package/src/demos/index.ts
CHANGED
|
@@ -68,6 +68,7 @@ import DlLayoutDemo from './DlLayoutDemo.vue'
|
|
|
68
68
|
import { DlCodeEditorDemo } from './DlCodeEditor'
|
|
69
69
|
import DlLabelPickerDemo from './DlLabelPickerDemo.vue'
|
|
70
70
|
import DlInfiniteScrollDemo from './DlInfiniteScrollDemo.vue'
|
|
71
|
+
import DlMarkDownDemo from './DlMarkDownDemo.vue'
|
|
71
72
|
|
|
72
73
|
export default {
|
|
73
74
|
AvatarDemo,
|
|
@@ -136,5 +137,6 @@ export default {
|
|
|
136
137
|
DlCodeEditorDemo,
|
|
137
138
|
DlLayoutDemo,
|
|
138
139
|
DlLabelPickerDemo,
|
|
139
|
-
DlInfiniteScrollDemo
|
|
140
|
+
DlInfiniteScrollDemo,
|
|
141
|
+
DlMarkDownDemo
|
|
140
142
|
}
|