@volverjs/ui-vue 0.0.10-beta.43 → 0.0.10-beta.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.
@@ -146,15 +146,15 @@ const hasTabindex = computed(() => {
146
146
  const localModelValue = computed({
147
147
  get: () => {
148
148
  if (Array.isArray(props.modelValue)) {
149
- return new Set(props.modelValue)
149
+ return props.modelValue
150
150
  }
151
- return props.modelValue !== undefined && props.modelValue !== null ? new Set([props.modelValue]) : new Set()
151
+ return props.modelValue !== undefined && props.modelValue !== null ? [props.modelValue] : []
152
152
  },
153
- set: (value: Set<unknown>) => {
154
- emit('update:modelValue', props.multiple || Array.isArray(props.modelValue) ? [...value] : [...value].pop())
153
+ set: (value: unknown[]) => {
154
+ emit('update:modelValue', props.multiple || Array.isArray(props.modelValue) ? value : value.pop())
155
155
  },
156
156
  })
157
- const sizeOfModelValue = computed(() => localModelValue.value.size)
157
+ const sizeOfModelValue = computed(() => localModelValue.value.length)
158
158
  const isDirty = computed(() => sizeOfModelValue.value > 0)
159
159
  const hasMaxValues = computed(() => {
160
160
  if (!props.multiple) {
@@ -173,7 +173,7 @@ const isUnselectable = computed(() => {
173
173
  if (!props.unselectable) {
174
174
  return false
175
175
  }
176
- return sizeOfModelValue.value > Number(props.minValues)
176
+ return Number(props.minValues) === 0 || (sizeOfModelValue.value > Number(props.minValues))
177
177
  })
178
178
  const isSelectable = computed(() => {
179
179
  if (isDisabledOrReadonly.value) {
@@ -247,7 +247,16 @@ const filteredOptions = computedAsync(async () => {
247
247
  * @param {T} option
248
248
  */
249
249
  function isOptionSelected(option: T) {
250
- return localModelValue.value.has(getOptionValue(option))
250
+ const optionValue = getOptionValue(option)
251
+ if (typeof optionValue === 'object') {
252
+ return localModelValue.value.some((item) => {
253
+ if (typeof item === 'object') {
254
+ return JSON.stringify(item) === JSON.stringify(optionValue)
255
+ }
256
+ return false
257
+ })
258
+ }
259
+ return localModelValue.value.includes(optionValue)
251
260
  }
252
261
 
253
262
  /**
@@ -288,17 +297,21 @@ function onClickInput() {
288
297
  */
289
298
  function onInput(option: T) {
290
299
  const isSelected = isOptionSelected(option)
300
+ const optionValue = getOptionValue(option)
291
301
  if (isSelected && isUnselectable.value) {
292
- localModelValue.value.delete(getOptionValue(option))
302
+ localModelValue.value = localModelValue.value.filter((item) => {
303
+ if (typeof optionValue === 'object' && typeof item === 'object') {
304
+ return JSON.stringify(item) !== JSON.stringify(optionValue)
305
+ }
306
+ return item !== optionValue
307
+ })
293
308
  }
294
309
  else if (!isSelected && isSelectable.value) {
295
310
  if (!props.multiple) {
296
- localModelValue.value.clear()
311
+ localModelValue.value = []
297
312
  }
298
- localModelValue.value.add(getOptionValue(option))
313
+ localModelValue.value = [...localModelValue.value, optionValue]
299
314
  }
300
- // force reactivity
301
- localModelValue.value = new Set(localModelValue.value)
302
315
  if (!props.multiple && !props.keepOpen) {
303
316
  collapse()
304
317
  }
@@ -61,7 +61,7 @@ function getSvgContent(svg: string): SVGSVGElement | undefined {
61
61
  let dom
62
62
  if (typeof window === 'undefined') {
63
63
  // SSR
64
- // eslint-disable-next-line ts/no-var-requires, ts/no-require-imports
64
+ // eslint-disable-next-line ts/no-require-imports, ts/no-var-requires
65
65
  const { JSDOM } = require('jsdom')
66
66
  dom = new JSDOM().window
67
67
  }
@@ -19,7 +19,7 @@ const propsDefaults = useDefaults<typeof VvInputFileProps>(
19
19
  VvInputFileProps,
20
20
  props,
21
21
  )
22
- const { modifiers, id, readonly, icon, iconPosition, iconDownload }
22
+ const { modifiers, id, readonly, disabled, icon, iconPosition, iconDownload }
23
23
  = toRefs(props)
24
24
  const hasId = useUniqueId(id)
25
25
  const hasHintId = computed(() => `${hasId.value}-hint`)
@@ -83,12 +83,14 @@ const files = computed({
83
83
  },
84
84
  })
85
85
 
86
+ const isDisabledOrReadonly = computed(() => props.disabled || props.readonly)
87
+
86
88
  const hasMax = computed(() => {
87
89
  return typeof props.max === 'string' ? Number.parseInt(props.max) : props.max
88
90
  })
89
91
 
90
92
  const hasDropArea = computed(() => {
91
- return props.dropArea && !readonly.value
93
+ return props.dropArea && !isDisabledOrReadonly.value
92
94
  })
93
95
 
94
96
  const isMultiple = computed(() => {
@@ -161,7 +163,7 @@ function onClickDropArea() {
161
163
  if (!inputEl.value) {
162
164
  return
163
165
  }
164
- if (!readonly.value) {
166
+ if (!isDisabledOrReadonly.value) {
165
167
  inputEl.value.click()
166
168
  }
167
169
  }
@@ -302,6 +304,7 @@ export default {
302
304
  modifiers="action"
303
305
  :label="!previewSrc ? dropdAreaActionLabel : undefined"
304
306
  :title="previewSrc ? dropdAreaActionLabel : undefined"
307
+ :disabled="disabled"
305
308
  :class="{
306
309
  'vv-input-file__drop-area-action': previewSrc,
307
310
  }"
@@ -317,6 +320,7 @@ export default {
317
320
  ref="inputEl"
318
321
  type="file"
319
322
  :readonly="readonly"
323
+ :disabled="disabled"
320
324
  :placeholder="placeholder"
321
325
  :aria-describedby="hasHintLabelOrSlot ? hasHintId : undefined"
322
326
  :aria-invalid="invalid"
@@ -379,6 +383,7 @@ export default {
379
383
  type="button"
380
384
  class="vv-input-file__item-remove"
381
385
  :title="labelRemove"
386
+ :disabled="disabled"
382
387
  @click.stop="onClickRemoveFile(index)"
383
388
  />
384
389
  </li>
@@ -7,6 +7,7 @@ import {
7
7
  LabelProps,
8
8
  LoadingProps,
9
9
  ReadonlyProps,
10
+ DisabledProps,
10
11
  IconProps,
11
12
  } from '../../props'
12
13
  import { type VvIconProps, ACTION_ICONS } from '../VvIcon'
@@ -33,6 +34,7 @@ export const VvInputFileProps = {
33
34
  ...LabelProps,
34
35
  ...LoadingProps,
35
36
  ...ReadonlyProps,
37
+ ...DisabledProps,
36
38
  ...IconProps,
37
39
  /**
38
40
  * Input value
@@ -44,6 +44,14 @@ export const Readonly: Story = {
44
44
  },
45
45
  }
46
46
 
47
+ export const Disabled: Story = {
48
+ ...Default,
49
+ args: {
50
+ ...defaultArgs,
51
+ disabled: true,
52
+ },
53
+ }
54
+
47
55
  export const Valid: Story = {
48
56
  ...Default,
49
57
  args: {