@coreui/vue-pro 4.9.0 → 4.10.1

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": "@coreui/vue-pro",
3
- "version": "4.9.0",
3
+ "version": "4.10.1",
4
4
  "description": "UI Components Library for Vue.js",
5
5
  "keywords": [
6
6
  "vue",
@@ -477,7 +477,9 @@ const CDateRangePicker = defineComponent({
477
477
  const maxDate = ref(props.maxDate && new Date(props.maxDate))
478
478
  const minDate = ref(props.minDate && new Date(props.minDate))
479
479
  const selectEndDate = ref(false)
480
- const isValid = ref(props.valid || (props.invalid && false))
480
+ const isValid = ref<boolean | undefined>(
481
+ props.valid ?? (props.invalid === true ? false : undefined),
482
+ )
481
483
  const isMobile = ref(false)
482
484
 
483
485
  onMounted(() => {
@@ -487,7 +489,7 @@ const CDateRangePicker = defineComponent({
487
489
  watch(
488
490
  () => [props.valid, props.invalid],
489
491
  () => {
490
- isValid.value = props.valid || (props.invalid && false)
492
+ isValid.value = props.valid ?? (props.invalid === true ? false : undefined)
491
493
  },
492
494
  )
493
495
 
@@ -14,6 +14,12 @@ const CFormCheck = defineComponent({
14
14
  * @see http://coreui.io/vue/docs/components/button.html
15
15
  */
16
16
  button: Object,
17
+ /**
18
+ * Use in conjunction with the v-model directive to specify the value that should be assigned to the bound variable when the checkbox is in the `false` state.
19
+ *
20
+ * @since 4.10.0
21
+ */
22
+ falseValue: String,
17
23
  /**
18
24
  * Provide valuable, actionable feedback.
19
25
  *
@@ -66,7 +72,7 @@ const CFormCheck = defineComponent({
66
72
  * The default name for a value passed using v-model.
67
73
  */
68
74
  modelValue: {
69
- type: [Boolean, String],
75
+ type: [Array, Boolean, String],
70
76
  value: undefined,
71
77
  },
72
78
  /**
@@ -81,6 +87,12 @@ const CFormCheck = defineComponent({
81
87
  * @since 4.3.0
82
88
  */
83
89
  tooltipFeedback: Boolean,
90
+ /**
91
+ * Use in conjunction with the v-model directive to specify the value that should be assigned to the bound variable when the checkbox is in the `true` state.
92
+ *
93
+ * @since 4.10.0
94
+ */
95
+ trueValue: String,
84
96
  /**
85
97
  * Specifies the type of component.
86
98
  *
@@ -111,8 +123,35 @@ const CFormCheck = defineComponent({
111
123
  ],
112
124
  setup(props, { attrs, emit, slots }) {
113
125
  const handleChange = (event: InputEvent) => {
126
+ const target = event.target as HTMLInputElement
114
127
  emit('change', event)
115
- emit('update:modelValue', (event.target as HTMLInputElement).value)
128
+
129
+ if (props.falseValue && props.trueValue) {
130
+ emit('update:modelValue', target.checked ? props.trueValue : props.falseValue)
131
+ return
132
+ }
133
+
134
+ if (props.value && Array.isArray(props.modelValue)) {
135
+ if (props.modelValue.includes(props.value)) {
136
+ emit(
137
+ 'update:modelValue',
138
+ props.modelValue.filter((value) => value !== props.value),
139
+ )
140
+ } else {
141
+ emit('update:modelValue', [...props.modelValue, props.value])
142
+ }
143
+
144
+ return
145
+ }
146
+
147
+ if (props.value === undefined) {
148
+ emit('update:modelValue', target.checked)
149
+ return
150
+ }
151
+
152
+ if (props.value && (props.modelValue === undefined || typeof props.modelValue === 'string')) {
153
+ emit('update:modelValue', target.checked ? props.value : undefined)
154
+ }
116
155
  }
117
156
 
118
157
  const className = [
@@ -135,12 +174,22 @@ const CFormCheck = defineComponent({
135
174
  },
136
175
  ]
137
176
 
138
- const isChecked = computed(() => props.modelValue == props.value)
177
+ const isChecked = computed(() => {
178
+ if (Array.isArray(props.modelValue)) {
179
+ return props.modelValue.includes(props.value)
180
+ }
181
+
182
+ if (typeof props.modelValue === 'string') {
183
+ return props.modelValue === props.value
184
+ }
185
+
186
+ return props.modelValue
187
+ })
139
188
 
140
189
  const formControl = () => {
141
190
  return h('input', {
142
191
  ...attrs,
143
- ...(props.modelValue && { checked: isChecked.value }),
192
+ ...(props.modelValue && props.value && { checked: isChecked.value }),
144
193
  class: inputClassName,
145
194
  id: props.id,
146
195
  indeterminate: props.indeterminate,
@@ -210,4 +259,4 @@ const CFormCheck = defineComponent({
210
259
  },
211
260
  })
212
261
 
213
- export { CFormCheck }
262
+ export { CFormCheck }
@@ -140,11 +140,26 @@ const CSmartPagination = defineComponent({
140
140
  const limit = ref(props.limit)
141
141
  const pages = ref(props.pages)
142
142
 
143
- watch(props, () => {
144
- activePage.value = props.activePage
145
- limit.value = props.limit
146
- pages.value = props.pages
147
- })
143
+ watch(
144
+ () => props.activePage,
145
+ () => {
146
+ activePage.value = props.activePage
147
+ },
148
+ )
149
+
150
+ watch(
151
+ () => props.limit,
152
+ () => {
153
+ limit.value = props.limit
154
+ },
155
+ )
156
+
157
+ watch(
158
+ () => props.pages,
159
+ () => {
160
+ pages.value = props.pages
161
+ },
162
+ )
148
163
 
149
164
  const showDots = computed(() => {
150
165
  return props.dots && limit.value > 4 && limit.value < pages.value
@@ -293,7 +293,9 @@ const CTimePicker = defineComponent({
293
293
  listOfSeconds: [],
294
294
  hour12: false,
295
295
  })
296
- const isValid = ref(props.valid || (props.invalid && false))
296
+ const isValid = ref<boolean | undefined>(
297
+ props.valid ?? (props.invalid === true ? false : undefined),
298
+ )
297
299
 
298
300
  watch(
299
301
  () => props.time,
@@ -305,7 +307,7 @@ const CTimePicker = defineComponent({
305
307
  watch(
306
308
  () => [props.valid, props.invalid],
307
309
  () => {
308
- isValid.value = props.valid || (props.invalid && false)
310
+ isValid.value = props.valid ?? (props.invalid === true ? false : undefined)
309
311
  },
310
312
  )
311
313