@coreui/vue-pro 4.8.0-next.1 → 4.8.0

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.8.0-next.1",
3
+ "version": "4.8.0",
4
4
  "description": "UI Components Library for Vue.js",
5
5
  "keywords": [
6
6
  "vue",
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  defineComponent,
3
3
  h,
4
- reactive,
5
4
  ref,
6
5
  VNode,
7
6
  onBeforeMount,
@@ -79,10 +78,15 @@ const CCarousel = defineComponent({
79
78
  },
80
79
  setup(props, { slots }) {
81
80
  const carouselRef = ref()
82
- const timeout = ref()
81
+
82
+ const active = ref(props.index)
83
83
  const animating = ref(false)
84
- const visible = ref()
85
84
  const customInterval = ref<boolean | number>(props.interval)
85
+ const direction = ref('next')
86
+ const items = ref<VNode[]>([])
87
+ const timeout = ref()
88
+ const visible = ref()
89
+
86
90
  const setAnimating = (value: boolean) => {
87
91
  animating.value = value
88
92
  }
@@ -105,28 +109,15 @@ const CCarousel = defineComponent({
105
109
  }
106
110
  }
107
111
 
108
- const state = reactive({
109
- items: [] as VNode[],
110
- active: props.index,
111
- direction: 'next',
112
- })
113
-
114
- onBeforeMount(() => {
115
- if (slots.default) {
116
- // @ts-expect-error TODO: fix types
117
- state.items = slots.default().filter((child) => child.type.name === 'CCarouselItem')
118
- }
119
- })
120
-
121
- const handleControlClick = (direction: string) => {
112
+ const handleControlClick = (_direction: string) => {
122
113
  if (animating.value) {
123
114
  return
124
115
  }
125
- state.direction = direction
126
- if (direction === 'next') {
127
- state.active === state.items.length - 1 ? (state.active = 0) : state.active++
116
+ direction.value = _direction
117
+ if (_direction === 'next') {
118
+ active.value === items.value.length - 1 ? (active.value = 0) : active.value++
128
119
  } else {
129
- state.active === 0 ? (state.active = state.items.length - 1) : state.active--
120
+ active.value === 0 ? (active.value = items.value.length - 1) : active.value--
130
121
  }
131
122
  }
132
123
 
@@ -139,19 +130,19 @@ const CCarousel = defineComponent({
139
130
  }
140
131
 
141
132
  const handleIndicatorClick = (index: number) => {
142
- if (state.active === index) {
133
+ if (active.value === index) {
143
134
  return
144
135
  }
145
136
 
146
- if (state.active < index) {
147
- state.direction = 'next'
148
- state.active = index
137
+ if (active.value < index) {
138
+ direction.value = 'next'
139
+ active.value = index
149
140
  return
150
141
  }
151
142
 
152
- if (state.active > index) {
153
- state.direction = 'prev'
154
- state.active = index
143
+ if (active.value > index) {
144
+ direction.value = 'prev'
145
+ active.value = index
155
146
  }
156
147
  }
157
148
 
@@ -163,6 +154,17 @@ const CCarousel = defineComponent({
163
154
  }
164
155
  }
165
156
 
157
+ onBeforeMount(() => {
158
+ if (slots.default) {
159
+ const children = typeof slots.default()[0].type === 'symbol' ? slots.default()[0].children : slots.default()
160
+
161
+ if (children && Array.isArray(children)) {
162
+ // @ts-expect-error TODO: fix types
163
+ items.value = children.filter((child) => child.type.name === 'CCarouselItem')
164
+ }
165
+ }
166
+ })
167
+
166
168
  onMounted(() => {
167
169
  window.addEventListener('scroll', handleScroll)
168
170
  })
@@ -174,7 +176,7 @@ const CCarousel = defineComponent({
174
176
  return
175
177
  }
176
178
 
177
- if (!props.wrap && state.active < state.items.length - 1) {
179
+ if (!props.wrap && active.value < items.value.length - 1) {
178
180
  !animating.value && cycle()
179
181
  }
180
182
  })
@@ -204,12 +206,12 @@ const CCarousel = defineComponent({
204
206
  {
205
207
  class: 'carousel-indicators',
206
208
  },
207
- state.items.map((_, index) => {
209
+ items.value.map((_, index) => {
208
210
  return h('button', {
209
211
  type: 'button',
210
212
  id: index,
211
213
  'data-coreui-target': '',
212
- ...(state.active === index && { class: 'active' }),
214
+ ...(active.value === index && { class: 'active' }),
213
215
  onClick: () => handleIndicatorClick(index),
214
216
  })
215
217
  }),
@@ -217,10 +219,10 @@ const CCarousel = defineComponent({
217
219
  h(
218
220
  'div',
219
221
  { class: 'carousel-inner' },
220
- state.items.map((item, index) => {
222
+ items.value.map((item, index) => {
221
223
  return h(item, {
222
- active: state.active === index ? true : false,
223
- direction: state.direction,
224
+ active: active.value === index ? true : false,
225
+ direction: direction.value,
224
226
  })
225
227
  }),
226
228
  ),
@@ -83,6 +83,12 @@ const CFormCheck = defineComponent({
83
83
  type: [Boolean, String],
84
84
  value: undefined,
85
85
  },
86
+ /**
87
+ * Put checkboxes or radios on the opposite side.
88
+ *
89
+ * @sinve 4.8.0
90
+ */
91
+ reverse: Boolean,
86
92
  /**
87
93
  * Display validation feedback in a styled tooltip.
88
94
  *
@@ -126,6 +132,7 @@ const CFormCheck = defineComponent({
126
132
  'form-check',
127
133
  {
128
134
  'form-check-inline': props.inline,
135
+ 'form-check-reverse': props.reverse,
129
136
  'is-invalid': props.invalid,
130
137
  'is-valid': props.valid,
131
138
  },
@@ -31,6 +31,12 @@ const CFormSwitch = defineComponent({
31
31
  type: [Boolean, String],
32
32
  value: undefined,
33
33
  },
34
+ /**
35
+ * Put checkboxes or radios on the opposite side.
36
+ *
37
+ * @sinve 4.8.0
38
+ */
39
+ reverse: Boolean,
34
40
  /**
35
41
  * Size the component large or extra large. Works only with `switch`.
36
42
  *
@@ -82,6 +88,7 @@ const CFormSwitch = defineComponent({
82
88
  class: [
83
89
  'form-check form-switch',
84
90
  {
91
+ 'form-check-reverse': props.reverse,
85
92
  [`form-switch-${props.size}`]: props.size,
86
93
  'is-invalid': props.invalid,
87
94
  'is-valid': props.valid,
@@ -1,22 +0,0 @@
1
- declare const CAccordionCollapse: import("vue").DefineComponent<{
2
- /**
3
- * Toggle the visibility of component.
4
- */
5
- visible: {
6
- type: BooleanConstructor;
7
- required: false;
8
- };
9
- }, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
10
- [key: string]: any;
11
- }>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
12
- /**
13
- * Toggle the visibility of component.
14
- */
15
- visible: {
16
- type: BooleanConstructor;
17
- required: false;
18
- };
19
- }>>, {
20
- visible: boolean;
21
- }>;
22
- export { CAccordionCollapse };
@@ -1,305 +0,0 @@
1
- import { PropType } from 'vue';
2
- export interface Option {
3
- disabled?: boolean;
4
- label?: string;
5
- options?: Option[];
6
- order?: number;
7
- selected?: boolean;
8
- text: string;
9
- value: number | string;
10
- }
11
- declare const CMultiSelect: import("vue").DefineComponent<{
12
- /**
13
- * Enables selection cleaner element.
14
- *
15
- * @default true
16
- */
17
- cleaner: {
18
- type: BooleanConstructor;
19
- required: false;
20
- default: boolean;
21
- };
22
- /**
23
- * Toggle the disabled state for the component.
24
- */
25
- disabled: {
26
- type: BooleanConstructor;
27
- required: false;
28
- default: boolean;
29
- };
30
- /**
31
- * It specifies that multiple options can be selected at once.
32
- *
33
- * @default true
34
- */
35
- multiple: {
36
- type: BooleanConstructor;
37
- default: boolean;
38
- required: false;
39
- };
40
- /**
41
- * List of option elements.
42
- */
43
- options: {
44
- type: PropType<Option[]>;
45
- default: () => never[];
46
- required: false;
47
- };
48
- /**
49
- * Sets maxHeight of options list.
50
- *
51
- * @default 'auto'
52
- */
53
- optionsMaxHeight: {
54
- type: (NumberConstructor | StringConstructor)[];
55
- default: string;
56
- required: false;
57
- };
58
- /**
59
- * Sets option style.
60
- *
61
- * @values 'checkbox', 'text'
62
- * @default 'checkbox'
63
- */
64
- optionsStyle: {
65
- type: StringConstructor;
66
- default: string;
67
- required: false;
68
- validator: (value: string) => boolean;
69
- };
70
- /**
71
- * Specifies a short hint that is visible in the search input.
72
- *
73
- * @default 'Select...''
74
- */
75
- placeholder: {
76
- type: StringConstructor;
77
- default: string;
78
- required: false;
79
- };
80
- /**
81
- * Enables search input element.
82
- */
83
- search: {
84
- type: BooleanConstructor;
85
- default: boolean;
86
- required: false;
87
- };
88
- /**
89
- * Sets the label for no results when filtering.
90
- */
91
- searchNoResultsLabel: {
92
- type: StringConstructor;
93
- default: string;
94
- required: false;
95
- };
96
- /**
97
- * Enables select all button.
98
- *
99
- * @default true
100
- */
101
- selectAll: {
102
- type: BooleanConstructor;
103
- required: false;
104
- default: boolean;
105
- };
106
- /**
107
- * Sets the select all button label.
108
- *
109
- * @default 'Select all options'
110
- */
111
- selectAllLabel: {
112
- type: StringConstructor;
113
- required: false;
114
- default: string;
115
- };
116
- /**
117
- * Sets the selection style.
118
- *
119
- * @values 'counter', 'tags', 'text'
120
- * @default 'tags'
121
- */
122
- selectionType: {
123
- type: StringConstructor;
124
- default: string;
125
- required: false;
126
- validator: (value: string) => boolean;
127
- };
128
- /**
129
- * Sets the counter selection label.
130
- *
131
- * @default 'item(s) selected'
132
- */
133
- selectionTypeCounterText: {
134
- type: StringConstructor;
135
- default: string;
136
- required: false;
137
- };
138
- /**
139
- * Toggle the visibility of multi select dropdown.
140
- *
141
- * @default false
142
- */
143
- visible: {
144
- type: BooleanConstructor;
145
- default: boolean;
146
- required: false;
147
- };
148
- }, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
149
- [key: string]: any;
150
- }>[], unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "change"[], "change", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
151
- /**
152
- * Enables selection cleaner element.
153
- *
154
- * @default true
155
- */
156
- cleaner: {
157
- type: BooleanConstructor;
158
- required: false;
159
- default: boolean;
160
- };
161
- /**
162
- * Toggle the disabled state for the component.
163
- */
164
- disabled: {
165
- type: BooleanConstructor;
166
- required: false;
167
- default: boolean;
168
- };
169
- /**
170
- * It specifies that multiple options can be selected at once.
171
- *
172
- * @default true
173
- */
174
- multiple: {
175
- type: BooleanConstructor;
176
- default: boolean;
177
- required: false;
178
- };
179
- /**
180
- * List of option elements.
181
- */
182
- options: {
183
- type: PropType<Option[]>;
184
- default: () => never[];
185
- required: false;
186
- };
187
- /**
188
- * Sets maxHeight of options list.
189
- *
190
- * @default 'auto'
191
- */
192
- optionsMaxHeight: {
193
- type: (NumberConstructor | StringConstructor)[];
194
- default: string;
195
- required: false;
196
- };
197
- /**
198
- * Sets option style.
199
- *
200
- * @values 'checkbox', 'text'
201
- * @default 'checkbox'
202
- */
203
- optionsStyle: {
204
- type: StringConstructor;
205
- default: string;
206
- required: false;
207
- validator: (value: string) => boolean;
208
- };
209
- /**
210
- * Specifies a short hint that is visible in the search input.
211
- *
212
- * @default 'Select...''
213
- */
214
- placeholder: {
215
- type: StringConstructor;
216
- default: string;
217
- required: false;
218
- };
219
- /**
220
- * Enables search input element.
221
- */
222
- search: {
223
- type: BooleanConstructor;
224
- default: boolean;
225
- required: false;
226
- };
227
- /**
228
- * Sets the label for no results when filtering.
229
- */
230
- searchNoResultsLabel: {
231
- type: StringConstructor;
232
- default: string;
233
- required: false;
234
- };
235
- /**
236
- * Enables select all button.
237
- *
238
- * @default true
239
- */
240
- selectAll: {
241
- type: BooleanConstructor;
242
- required: false;
243
- default: boolean;
244
- };
245
- /**
246
- * Sets the select all button label.
247
- *
248
- * @default 'Select all options'
249
- */
250
- selectAllLabel: {
251
- type: StringConstructor;
252
- required: false;
253
- default: string;
254
- };
255
- /**
256
- * Sets the selection style.
257
- *
258
- * @values 'counter', 'tags', 'text'
259
- * @default 'tags'
260
- */
261
- selectionType: {
262
- type: StringConstructor;
263
- default: string;
264
- required: false;
265
- validator: (value: string) => boolean;
266
- };
267
- /**
268
- * Sets the counter selection label.
269
- *
270
- * @default 'item(s) selected'
271
- */
272
- selectionTypeCounterText: {
273
- type: StringConstructor;
274
- default: string;
275
- required: false;
276
- };
277
- /**
278
- * Toggle the visibility of multi select dropdown.
279
- *
280
- * @default false
281
- */
282
- visible: {
283
- type: BooleanConstructor;
284
- default: boolean;
285
- required: false;
286
- };
287
- }>> & {
288
- onChange?: ((...args: any[]) => any) | undefined;
289
- }, {
290
- search: boolean;
291
- visible: boolean;
292
- disabled: boolean;
293
- multiple: boolean;
294
- options: Option[];
295
- cleaner: boolean;
296
- placeholder: string;
297
- optionsMaxHeight: string | number;
298
- optionsStyle: string;
299
- searchNoResultsLabel: string;
300
- selectionType: string;
301
- selectionTypeCounterText: string;
302
- selectAll: boolean;
303
- selectAllLabel: string;
304
- }>;
305
- export { CMultiSelect };