@dataloop-ai/components 0.17.51 → 0.17.53

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataloop-ai/components",
3
- "version": "0.17.51",
3
+ "version": "0.17.53",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -67,7 +67,7 @@ import {
67
67
  setMaxHeight
68
68
  } from './utils'
69
69
  import type { ButtonSizes } from './utils'
70
- import { defineComponent, PropType, ref } from 'vue-demi'
70
+ import { computed, defineComponent, PropType, ref } from 'vue-demi'
71
71
  import { colorNames } from '../../../utils/css-color-names'
72
72
  import { useSizeObserver } from '../../../hooks/use-size-observer'
73
73
  import { v4 } from 'uuid'
@@ -166,20 +166,25 @@ export default defineComponent({
166
166
  */
167
167
  tooltip: { type: String, default: null, required: false },
168
168
  /**
169
- * The button will mentain the styles it has when it's pressed if this prop is active
169
+ * The button will maintain the styles it has when it's pressed if this prop is active
170
170
  */
171
171
  active: { type: Boolean, default: false, required: false },
172
172
  styles: { type: [Object, String], default: null }
173
173
  },
174
174
  emits: ['click', 'mousedown'],
175
- setup() {
175
+ setup(props) {
176
176
  const buttonLabelRef = ref(null)
177
177
  const { hasEllipsis } = useSizeObserver(buttonLabelRef)
178
178
 
179
+ const buttonClass = computed(() => {
180
+ return props.active ? 'dl-button active-class' : 'dl-button'
181
+ })
182
+
179
183
  return {
180
184
  uuid: `dl-button-${v4()}`,
181
185
  buttonLabelRef,
182
- isOverflowing: hasEllipsis
186
+ isOverflowing: hasEllipsis,
187
+ buttonClass
183
188
  }
184
189
  },
185
190
  computed: {
@@ -213,9 +218,6 @@ export default defineComponent({
213
218
  buttonLabel(): string {
214
219
  return textTransform(this.label)
215
220
  },
216
- buttonClass() {
217
- return this.active ? 'dl-button active-class' : 'dl-button'
218
- },
219
221
  hasIcon(): boolean {
220
222
  return typeof this.icon === 'string' && this.icon !== ''
221
223
  },
@@ -90,6 +90,18 @@ export class Step {
90
90
  set(this._state, 'sidebarNavigation', value)
91
91
  }
92
92
 
93
+ public clearError() {
94
+ set(this._state, 'error', '')
95
+ }
96
+
97
+ public clearWarning() {
98
+ set(this._state, 'warning', '')
99
+ }
100
+
101
+ public clearCompleted() {
102
+ set(this._state, 'completed', false)
103
+ }
104
+
93
105
  public reset() {
94
106
  for (const key of Object.keys(this._initialState)) {
95
107
  if (key !== 'active') {
@@ -163,4 +163,38 @@ export class Stepper {
163
163
 
164
164
  stepToReset.reset()
165
165
  }
166
+
167
+ /**
168
+ *
169
+ * @param options { step?: number; error?: boolean, warning?: boolean, completed?: boolean }
170
+ * @param options.step The step to clear its state
171
+ * @returns
172
+ */
173
+ public clearStepState(
174
+ options: {
175
+ step?: Step
176
+ error?: boolean
177
+ warning?: boolean
178
+ completed?: boolean
179
+ } = {}
180
+ ) {
181
+ const { step, error, warning, completed } = options
182
+ const stepToClear = step ?? this.currentStep
183
+
184
+ if (!stepToClear) {
185
+ return
186
+ }
187
+
188
+ if (error) {
189
+ stepToClear.clearError()
190
+ }
191
+
192
+ if (warning) {
193
+ stepToClear.clearWarning()
194
+ }
195
+
196
+ if (completed) {
197
+ stepToClear.clearCompleted()
198
+ }
199
+ }
166
200
  }