@dataloop-ai/components 0.17.9 → 0.17.11
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
|
@@ -83,25 +83,84 @@ export class Stepper {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
88
|
+
* @param options { step?: number; preventNext?: boolean }
|
|
89
|
+
* @param options.step The steps to complete
|
|
90
|
+
* @param options.preventNext Prevents the stepper from moving to the next step
|
|
91
|
+
* @returns
|
|
92
|
+
*/
|
|
93
|
+
public completeStep(options: { step?: Step; preventNext?: boolean } = {}) {
|
|
94
|
+
const { step, preventNext } = options
|
|
95
|
+
const stepToComplete = step ?? this.currentStep
|
|
96
|
+
|
|
97
|
+
if (!stepToComplete) {
|
|
98
|
+
return
|
|
99
|
+
}
|
|
91
100
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
101
|
+
stepToComplete.completed = true
|
|
102
|
+
|
|
103
|
+
if (!preventNext) {
|
|
104
|
+
this.moveToNextStep()
|
|
105
|
+
}
|
|
95
106
|
}
|
|
96
107
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
108
|
+
/**
|
|
109
|
+
* @param message The error message
|
|
110
|
+
* @param options { step?: number; preventNext?: boolean }
|
|
111
|
+
* @param options.step The steps to Fail
|
|
112
|
+
* @returns
|
|
113
|
+
*/
|
|
114
|
+
public failStep(message?: string, options: { step?: Step } = {}) {
|
|
115
|
+
const { step } = options
|
|
116
|
+
const stepToFail = step ?? this.currentStep
|
|
117
|
+
|
|
118
|
+
if (!stepToFail) {
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
stepToFail.error = message ?? ''
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @param message The warning message
|
|
127
|
+
* @param options { step?: number; preventNext?: boolean }
|
|
128
|
+
* @param options.step The steps to Warn
|
|
129
|
+
* @param options.preventNext Prevents the stepper from moving to the next step
|
|
130
|
+
* @returns
|
|
131
|
+
*/
|
|
132
|
+
public setStepWarning(
|
|
133
|
+
message?: string,
|
|
134
|
+
options: { step?: Step; preventNext?: boolean } = {}
|
|
135
|
+
) {
|
|
136
|
+
const { step, preventNext } = options
|
|
137
|
+
const stepToWarn = step ?? this.currentStep
|
|
138
|
+
|
|
139
|
+
if (!stepToWarn) {
|
|
140
|
+
return
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
stepToWarn.warning = message ?? ''
|
|
144
|
+
|
|
145
|
+
if (!preventNext) {
|
|
146
|
+
this.moveToNextStep()
|
|
147
|
+
}
|
|
101
148
|
}
|
|
102
149
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
150
|
+
/**
|
|
151
|
+
*
|
|
152
|
+
* @param options { step?: number; preventNext?: boolean }
|
|
153
|
+
* @param options.step The steps to reset
|
|
154
|
+
* @returns
|
|
155
|
+
*/
|
|
156
|
+
public resetStep(options: { step?: Step } = {}) {
|
|
157
|
+
const { step } = options
|
|
158
|
+
const stepToReset = step ?? this.currentStep
|
|
159
|
+
|
|
160
|
+
if (!stepToReset) {
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
stepToReset.reset()
|
|
106
165
|
}
|
|
107
166
|
}
|
|
@@ -43,31 +43,40 @@ export default defineComponent({
|
|
|
43
43
|
|
|
44
44
|
virtualScrollSliceRatioBefore: {
|
|
45
45
|
type: [Number, String],
|
|
46
|
+
required: false,
|
|
46
47
|
default: 1
|
|
47
48
|
},
|
|
48
49
|
|
|
49
50
|
virtualScrollSliceRatioAfter: {
|
|
50
51
|
type: [Number, String],
|
|
52
|
+
required: false,
|
|
51
53
|
default: 1
|
|
52
54
|
},
|
|
53
55
|
|
|
54
56
|
virtualScrollItemSize: {
|
|
55
57
|
type: [Number, String],
|
|
58
|
+
required: false,
|
|
56
59
|
default: 0
|
|
57
60
|
},
|
|
58
61
|
|
|
59
62
|
virtualScrollStickySizeStart: {
|
|
60
63
|
type: [Number, String],
|
|
64
|
+
required: false,
|
|
61
65
|
default: 0
|
|
62
66
|
},
|
|
63
67
|
|
|
64
68
|
virtualScrollStickySizeEnd: {
|
|
65
69
|
type: [Number, String],
|
|
70
|
+
required: false,
|
|
66
71
|
default: 0
|
|
67
72
|
},
|
|
68
|
-
tableColspan: [Number, String],
|
|
69
|
-
virtualScrollHorizontal:
|
|
70
|
-
|
|
73
|
+
tableColspan: { type: [Number, String], required: false, default: 1 },
|
|
74
|
+
virtualScrollHorizontal: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
required: false,
|
|
77
|
+
default: false
|
|
78
|
+
},
|
|
79
|
+
onVirtualScroll: { type: Function, default: null },
|
|
71
80
|
items: {
|
|
72
81
|
type: Array,
|
|
73
82
|
default: () => [] as Record<string, any>[]
|
|
@@ -80,11 +89,12 @@ export default defineComponent({
|
|
|
80
89
|
typeOptions.includes(v)
|
|
81
90
|
},
|
|
82
91
|
|
|
83
|
-
itemsFn: { type: Function, default:
|
|
92
|
+
itemsFn: { type: Function, default: null },
|
|
84
93
|
itemsSize: { type: Number, default: 0 },
|
|
85
94
|
|
|
86
95
|
scrollTarget: {
|
|
87
|
-
|
|
96
|
+
type: [String, Object],
|
|
97
|
+
default: null
|
|
88
98
|
}
|
|
89
99
|
},
|
|
90
100
|
emits: ['virtual-scroll'],
|
|
@@ -92,8 +102,10 @@ export default defineComponent({
|
|
|
92
102
|
let localScrollTarget: HTMLElement | undefined
|
|
93
103
|
const rootRef: Ref<HTMLElement | null> = ref(null)
|
|
94
104
|
|
|
105
|
+
const isDefined = (v: any) => v !== undefined && v !== null
|
|
106
|
+
|
|
95
107
|
const virtualScrollLength = computed(() => {
|
|
96
|
-
return props.itemsSize >= 0 && props.itemsFn
|
|
108
|
+
return props.itemsSize >= 0 && isDefined(props.itemsFn)
|
|
97
109
|
? parseInt(props.itemsSize as unknown as string, 10)
|
|
98
110
|
: Array.isArray(props.items)
|
|
99
111
|
? props.items.length
|
|
@@ -121,20 +133,21 @@ export default defineComponent({
|
|
|
121
133
|
item
|
|
122
134
|
})
|
|
123
135
|
|
|
124
|
-
|
|
125
|
-
|
|
136
|
+
const itemsFn = props.itemsFn as Function
|
|
137
|
+
const items = props.items as Record<string, any>[]
|
|
138
|
+
|
|
139
|
+
return isDefined(itemsFn)
|
|
140
|
+
? itemsFn(
|
|
141
|
+
virtualScrollSliceRange.value.from,
|
|
142
|
+
virtualScrollSliceRange.value.to -
|
|
143
|
+
virtualScrollSliceRange.value.from
|
|
144
|
+
).map(mapFn)
|
|
145
|
+
: items
|
|
126
146
|
.slice(
|
|
127
147
|
virtualScrollSliceRange.value.from,
|
|
128
148
|
virtualScrollSliceRange.value.to
|
|
129
149
|
)
|
|
130
150
|
.map(mapFn)
|
|
131
|
-
: props
|
|
132
|
-
.itemsFn(
|
|
133
|
-
virtualScrollSliceRange.value.from,
|
|
134
|
-
virtualScrollSliceRange.value.to -
|
|
135
|
-
virtualScrollSliceRange.value.from
|
|
136
|
-
)
|
|
137
|
-
.map(mapFn)
|
|
138
151
|
})
|
|
139
152
|
|
|
140
153
|
const classes = computed(
|
|
@@ -143,11 +156,11 @@ export default defineComponent({
|
|
|
143
156
|
(props.virtualScrollHorizontal === true
|
|
144
157
|
? '--horizontal'
|
|
145
158
|
: '--vertical') +
|
|
146
|
-
(props.scrollTarget
|
|
159
|
+
(isDefined(props.scrollTarget) ? '' : ' scroll')
|
|
147
160
|
)
|
|
148
161
|
|
|
149
162
|
const attributes = computed(() =>
|
|
150
|
-
props.scrollTarget
|
|
163
|
+
isDefined(props.scrollTarget) ? {} : { tabindex: 0 }
|
|
151
164
|
)
|
|
152
165
|
|
|
153
166
|
watch(virtualScrollLength, () => {
|
|
@@ -173,7 +186,7 @@ export default defineComponent({
|
|
|
173
186
|
function configureScrollTarget() {
|
|
174
187
|
localScrollTarget = getScrollTarget(
|
|
175
188
|
getVirtualScrollEl(),
|
|
176
|
-
props.scrollTarget
|
|
189
|
+
props.scrollTarget as any
|
|
177
190
|
)
|
|
178
191
|
|
|
179
192
|
localScrollTarget!.addEventListener(
|
|
@@ -184,13 +197,13 @@ export default defineComponent({
|
|
|
184
197
|
}
|
|
185
198
|
|
|
186
199
|
function unconfigureScrollTarget() {
|
|
187
|
-
if (localScrollTarget
|
|
200
|
+
if (isDefined(localScrollTarget)) {
|
|
188
201
|
localScrollTarget.removeEventListener(
|
|
189
202
|
'scroll',
|
|
190
203
|
onVirtualScrollEvt,
|
|
191
204
|
listenOpts.passive
|
|
192
205
|
)
|
|
193
|
-
localScrollTarget =
|
|
206
|
+
localScrollTarget = null
|
|
194
207
|
}
|
|
195
208
|
}
|
|
196
209
|
|
|
@@ -203,7 +216,7 @@ export default defineComponent({
|
|
|
203
216
|
create
|
|
204
217
|
)
|
|
205
218
|
|
|
206
|
-
if (slots.before
|
|
219
|
+
if (isDefined(slots.before)) {
|
|
207
220
|
child = slots.before().concat(child)
|
|
208
221
|
}
|
|
209
222
|
|
|
@@ -245,6 +258,12 @@ export default defineComponent({
|
|
|
245
258
|
}
|
|
246
259
|
},
|
|
247
260
|
render(createElement: Function) {
|
|
261
|
+
/**
|
|
262
|
+
* Had to do some general Typescript hackery here to get this to work in webpack based builder project.
|
|
263
|
+
* The original code is written in Vue 2, but this project is using Vue 3.
|
|
264
|
+
* Some of the types are not compatible, so I had to cast some of the types to any.
|
|
265
|
+
*/
|
|
266
|
+
|
|
248
267
|
const renderFn = isVue2 ? createElement : h
|
|
249
268
|
const renderSlot = (fn: Function) => (isVue2 ? fn() : () => fn())
|
|
250
269
|
|
|
@@ -255,25 +274,36 @@ export default defineComponent({
|
|
|
255
274
|
return
|
|
256
275
|
}
|
|
257
276
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
+
const isDlTable = (this.$props as any).type === '__dltable'
|
|
278
|
+
const getVirtualChildren = (this as any).getVirtualChildren as Function
|
|
279
|
+
|
|
280
|
+
if (isDlTable) {
|
|
281
|
+
return getTableMiddle(
|
|
282
|
+
{
|
|
283
|
+
ref: 'rootRef',
|
|
284
|
+
class: 'dl-table__middle ' + this.classes
|
|
285
|
+
},
|
|
286
|
+
getVirtualChildren(renderFn),
|
|
287
|
+
renderFn
|
|
288
|
+
)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const attrs = this.attrs as Record<string, any>
|
|
292
|
+
const attributes = this.attributes as Record<string, any>
|
|
293
|
+
const classes = this.classes as string // todo: does this have to be casted to an object?
|
|
294
|
+
const attributeClasses = attrs.class as Record<string, any>
|
|
295
|
+
const tag = this.tag as string
|
|
296
|
+
|
|
297
|
+
return renderFn(
|
|
298
|
+
tag,
|
|
299
|
+
{
|
|
300
|
+
...attrs,
|
|
301
|
+
ref: 'rootRef',
|
|
302
|
+
class: [attributeClasses, classes],
|
|
303
|
+
...attributes
|
|
304
|
+
},
|
|
305
|
+
renderSlot(() => getVirtualChildren(renderFn))
|
|
306
|
+
)
|
|
277
307
|
}
|
|
278
308
|
})
|
|
279
309
|
</script>
|