@dataloop-ai/components 0.18.64 → 0.18.65
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 +1 -1
- package/src/StateManager.ts +73 -0
- package/src/components/compound/DlInput/DlInput.vue +7 -0
- package/src/components/compound/DlJsonEditor/DlJsonEditor.vue +8 -2
- package/src/components/essential/DlThemeProvider/DlThemeProvider.vue +3 -4
- package/src/demos/DlCodeEditor/DlCodeEditorDemo.vue +3 -8
- package/src/demos/DlDatasetBrowserLayoutDemo/components/MainContent/EmptyState/LayoutEmptyState.vue +4 -7
- package/src/index.ts +1 -22
package/package.json
CHANGED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { computed, reactive } from 'vue-demi'
|
|
2
|
+
|
|
3
|
+
export interface DlComponentsState {
|
|
4
|
+
theme: 'light' | 'dark'
|
|
5
|
+
locale: 'en' | 'es'
|
|
6
|
+
disableDebounce: boolean
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class StateManager {
|
|
10
|
+
private static _instance: StateManager | null = null
|
|
11
|
+
public static get instance(): StateManager {
|
|
12
|
+
if (StateManager._instance === null) {
|
|
13
|
+
StateManager._instance = new StateManager()
|
|
14
|
+
}
|
|
15
|
+
return StateManager._instance
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
private _state: DlComponentsState = null
|
|
19
|
+
|
|
20
|
+
private constructor() {
|
|
21
|
+
this._state = reactive({
|
|
22
|
+
theme: 'light',
|
|
23
|
+
locale: 'en',
|
|
24
|
+
disableDebounce: false
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public get state(): DlComponentsState {
|
|
29
|
+
return this._state
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// public theme = computed({
|
|
33
|
+
// get: () => this._state.theme,
|
|
34
|
+
// set: (theme: 'light' | 'dark') => {
|
|
35
|
+
// this._state.theme = theme
|
|
36
|
+
// }
|
|
37
|
+
// })
|
|
38
|
+
|
|
39
|
+
// public disableDebounce = computed({
|
|
40
|
+
// get: () => this._state.disableDebounce,
|
|
41
|
+
// set: (disableDebounce: boolean) => {
|
|
42
|
+
// this._state.disableDebounce = disableDebounce
|
|
43
|
+
// }
|
|
44
|
+
// })
|
|
45
|
+
|
|
46
|
+
// public isDarkTheme = computed(() => this._state.theme === 'dark')
|
|
47
|
+
// public isLightTheme = computed(() => this._state.theme === 'light')
|
|
48
|
+
|
|
49
|
+
public get theme(): 'light' | 'dark' {
|
|
50
|
+
return this._state.theme
|
|
51
|
+
}
|
|
52
|
+
public set theme(theme: 'light' | 'dark') {
|
|
53
|
+
this._state.theme = theme
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public get disableDebounce(): boolean {
|
|
57
|
+
return this._state.disableDebounce
|
|
58
|
+
}
|
|
59
|
+
public set disableDebounce(value: boolean) {
|
|
60
|
+
this._state.disableDebounce = value
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public get isDarkTheme(): boolean {
|
|
64
|
+
return this._state.theme === 'dark'
|
|
65
|
+
}
|
|
66
|
+
public get isLightTheme(): boolean {
|
|
67
|
+
return this._state.theme === 'light'
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const stateManager = StateManager.instance
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
window.DlComponents = StateManager.instance
|
|
@@ -256,6 +256,7 @@ import { DlMenu, DlIcon, DlList, DlEllipsis } from '../../essential'
|
|
|
256
256
|
import { DlButton } from '../../basic'
|
|
257
257
|
import { InputSizes, TInputSizes } from '../../../utils/input-sizes'
|
|
258
258
|
import { v4 } from 'uuid'
|
|
259
|
+
import { stateManager } from '../../../StateManager'
|
|
259
260
|
|
|
260
261
|
export default defineComponent({
|
|
261
262
|
name: 'DlInput',
|
|
@@ -545,6 +546,9 @@ export default defineComponent({
|
|
|
545
546
|
return !!this.suggestItems.length && !!this.modelValue
|
|
546
547
|
},
|
|
547
548
|
debouncedBlur(): any {
|
|
549
|
+
if (stateManager.disableDebounce) {
|
|
550
|
+
return this.onBlur.bind(this)
|
|
551
|
+
}
|
|
548
552
|
const debounced = debounce(this.onBlur.bind(this), 50)
|
|
549
553
|
return debounced
|
|
550
554
|
},
|
|
@@ -572,6 +576,9 @@ export default defineComponent({
|
|
|
572
576
|
return classes
|
|
573
577
|
},
|
|
574
578
|
debouncedInput(): any {
|
|
579
|
+
if (stateManager.disableDebounce) {
|
|
580
|
+
return this.onChange.bind(this)
|
|
581
|
+
}
|
|
575
582
|
const debounced = debounce(this.onChange.bind(this), this.debounce)
|
|
576
583
|
return debounced
|
|
577
584
|
}
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
TextContent
|
|
26
26
|
} from 'vanilla-jsoneditor'
|
|
27
27
|
import { debounce } from 'lodash'
|
|
28
|
+
import { stateManager } from '../../../StateManager'
|
|
28
29
|
|
|
29
30
|
export default defineComponent({
|
|
30
31
|
model: {
|
|
@@ -110,11 +111,16 @@ export default defineComponent({
|
|
|
110
111
|
emit('change', (content as TextContent).text)
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
const debouncedHandleJSONChange =
|
|
114
|
+
const debouncedHandleJSONChange = computed(() => {
|
|
115
|
+
if (stateManager.disableDebounce) {
|
|
116
|
+
return handleJSONChange
|
|
117
|
+
}
|
|
118
|
+
return debounce(handleJSONChange, 100)
|
|
119
|
+
})
|
|
114
120
|
|
|
115
121
|
const initJsonEditor = () => {
|
|
116
122
|
const initialAttrs: JSONEditorPropsOptional = {
|
|
117
|
-
onChange: debouncedHandleJSONChange,
|
|
123
|
+
onChange: debouncedHandleJSONChange.value,
|
|
118
124
|
indentation: indentation.value,
|
|
119
125
|
mode: mode.value,
|
|
120
126
|
readOnly: readonly.value || mode.value === Mode.tree,
|
|
@@ -9,6 +9,7 @@ import { defineComponent, onMounted, watch, provide, ref } from 'vue-demi'
|
|
|
9
9
|
import { getThemeModeAttr } from '../../../utils'
|
|
10
10
|
import '@dataloop-ai/icons/style.css'
|
|
11
11
|
import { v4 } from 'uuid'
|
|
12
|
+
import { stateManager } from '../../../StateManager'
|
|
12
13
|
|
|
13
14
|
export default defineComponent({
|
|
14
15
|
props: {
|
|
@@ -26,8 +27,7 @@ export default defineComponent({
|
|
|
26
27
|
|
|
27
28
|
const isDarkTheme = ref(props.isDark)
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
window.DlComponents?.setTheme(props.isDark ? 'dark' : 'light')
|
|
30
|
+
stateManager.theme = props.isDark ? 'dark' : 'light'
|
|
31
31
|
|
|
32
32
|
provide('theme', isDarkTheme)
|
|
33
33
|
|
|
@@ -40,8 +40,7 @@ export default defineComponent({
|
|
|
40
40
|
getThemeModeAttr(isDark)
|
|
41
41
|
) // sets the dl data-theme attr
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
window.DlComponents?.setTheme(props.isDark ? 'dark' : 'light')
|
|
43
|
+
stateManager.theme = props.isDark ? 'dark' : 'light'
|
|
45
44
|
}
|
|
46
45
|
)
|
|
47
46
|
},
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<dl-switch
|
|
4
|
-
v-model="isDark"
|
|
5
|
-
left-label="Dark Mode"
|
|
6
|
-
/>
|
|
7
3
|
<dl-switch
|
|
8
4
|
v-model="lines"
|
|
9
5
|
left-label="code lines"
|
|
@@ -17,7 +13,7 @@
|
|
|
17
13
|
width="45vw"
|
|
18
14
|
height="75vh"
|
|
19
15
|
:language="language"
|
|
20
|
-
:theme="
|
|
16
|
+
:theme="theme"
|
|
21
17
|
:readonly="readonly"
|
|
22
18
|
:options="options"
|
|
23
19
|
/>
|
|
@@ -28,6 +24,7 @@
|
|
|
28
24
|
import { computed, defineComponent, ref, watch } from 'vue-demi'
|
|
29
25
|
import { DlCodeEditor, DlSwitch } from '../../components'
|
|
30
26
|
import { DlCodeEditorOptions, DlCodeEditorTheme } from '../../components/types'
|
|
27
|
+
import { stateManager } from '../../StateManager'
|
|
31
28
|
|
|
32
29
|
export default defineComponent({
|
|
33
30
|
name: 'DlCodeEditorDemo',
|
|
@@ -37,7 +34,6 @@ export default defineComponent({
|
|
|
37
34
|
},
|
|
38
35
|
setup() {
|
|
39
36
|
const readonly = ref(false)
|
|
40
|
-
const isDark = ref(false)
|
|
41
37
|
const lines = ref(false)
|
|
42
38
|
|
|
43
39
|
const codeEditorValue = ref(
|
|
@@ -213,7 +209,7 @@ export default defineComponent({
|
|
|
213
209
|
const language = ref('python')
|
|
214
210
|
|
|
215
211
|
const theme = computed(() => {
|
|
216
|
-
return
|
|
212
|
+
return stateManager.isDarkTheme
|
|
217
213
|
? DlCodeEditorTheme.Dark
|
|
218
214
|
: DlCodeEditorTheme.Light
|
|
219
215
|
})
|
|
@@ -230,7 +226,6 @@ export default defineComponent({
|
|
|
230
226
|
lines,
|
|
231
227
|
codeEditorValue,
|
|
232
228
|
language,
|
|
233
|
-
isDark,
|
|
234
229
|
theme,
|
|
235
230
|
readonly,
|
|
236
231
|
options
|
package/src/demos/DlDatasetBrowserLayoutDemo/components/MainContent/EmptyState/LayoutEmptyState.vue
CHANGED
|
@@ -20,6 +20,7 @@ import { computed, defineComponent, ref } from 'vue-demi'
|
|
|
20
20
|
import UploadData from './UploadData.vue'
|
|
21
21
|
import { DlCodeEditor } from '../../../../../components'
|
|
22
22
|
import { DlCodeEditorTheme } from '../../../../../components/types'
|
|
23
|
+
import { stateManager } from '../../../../../StateManager'
|
|
23
24
|
|
|
24
25
|
export default defineComponent({
|
|
25
26
|
name: 'LayoutEmptyState',
|
|
@@ -201,13 +202,9 @@ export default defineComponent({
|
|
|
201
202
|
const language = ref('python')
|
|
202
203
|
|
|
203
204
|
const theme = computed(() => {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
) {
|
|
208
|
-
return DlCodeEditorTheme.Dark
|
|
209
|
-
}
|
|
210
|
-
return DlCodeEditorTheme.Light
|
|
205
|
+
return stateManager.isDarkTheme
|
|
206
|
+
? DlCodeEditorTheme.Dark
|
|
207
|
+
: DlCodeEditorTheme.Light
|
|
211
208
|
})
|
|
212
209
|
|
|
213
210
|
return {
|
package/src/index.ts
CHANGED
|
@@ -1,28 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { install } from 'vue-demi'
|
|
2
2
|
|
|
3
3
|
install()
|
|
4
4
|
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
window.DlComponents = window.DlComponents || {
|
|
7
|
-
state: reactive({}),
|
|
8
|
-
setTheme: (theme: 'light' | 'dark') => {
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
window.DlComponents.state.theme = theme
|
|
11
|
-
},
|
|
12
|
-
get theme(): 'light' | 'dark' {
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
return window.DlComponents.state.theme
|
|
15
|
-
},
|
|
16
|
-
isDark: computed(() => {
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
return window.DlComponents.state.theme === 'dark'
|
|
19
|
-
}),
|
|
20
|
-
isLight: computed(() => {
|
|
21
|
-
// @ts-ignore
|
|
22
|
-
return window.DlComponents.state.theme === 'light'
|
|
23
|
-
})
|
|
24
|
-
}
|
|
25
|
-
|
|
26
5
|
export * from './components'
|
|
27
6
|
export * from './layouts'
|
|
28
7
|
|