@coreui/vue-pro 4.1.4 → 4.3.0-beta.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.
Files changed (64) hide show
  1. package/README.md +1 -1
  2. package/dist/components/button/CButton.d.ts +29 -2
  3. package/dist/components/calendar/CCalendar.d.ts +185 -0
  4. package/dist/components/calendar/index.d.ts +6 -0
  5. package/dist/components/date-picker/CDatePicker.d.ts +406 -0
  6. package/dist/components/date-picker/index.d.ts +6 -0
  7. package/dist/components/date-range-picker/CDateRangePicker.d.ts +480 -0
  8. package/dist/components/date-range-picker/index.d.ts +6 -0
  9. package/dist/components/dropdown/CDropdown.d.ts +25 -0
  10. package/dist/components/dropdown/CDropdownToggle.d.ts +35 -1
  11. package/dist/components/index.d.ts +5 -0
  12. package/dist/components/multi-select/CMultiSelect.d.ts +2 -2
  13. package/dist/components/picker/CPicker.d.ts +11 -0
  14. package/dist/components/picker/index.d.ts +6 -0
  15. package/dist/components/popover/CPopover.d.ts +1 -1
  16. package/dist/components/sidebar/CSidebar.d.ts +1 -1
  17. package/dist/components/smart-table/CSmartTable.d.ts +35 -99
  18. package/dist/components/smart-table/CSmartTableInterface.d.ts +3 -3
  19. package/dist/components/time-picker/CTimePicker.d.ts +10 -0
  20. package/dist/components/time-picker/CTimePickerRollCol.d.ts +27 -0
  21. package/dist/components/time-picker/index.d.ts +6 -0
  22. package/dist/components/toast/CToast.d.ts +1 -1
  23. package/dist/index.es.js +3726 -1646
  24. package/dist/index.es.js.map +1 -1
  25. package/dist/index.js +3734 -1644
  26. package/dist/index.js.map +1 -1
  27. package/dist/utils/calendar.d.ts +21 -0
  28. package/dist/utils/time.d.ts +17 -0
  29. package/package.json +9 -9
  30. package/src/components/accordion/CAccordionButton.ts +1 -0
  31. package/src/components/accordion/__tests__/__snapshots__/CAccordionButton.spec.ts.snap +1 -1
  32. package/src/components/accordion/__tests__/__snapshots__/CAccordionHeader.spec.ts.snap +1 -1
  33. package/src/components/button/CButton.ts +30 -1
  34. package/src/components/button/__tests__/__snapshots__/CButton.spec.ts.snap +1 -1
  35. package/src/components/calendar/CCalendar.ts +546 -0
  36. package/src/components/calendar/index.ts +10 -0
  37. package/src/components/close-button/CCloseButton.ts +4 -1
  38. package/src/components/date-picker/CDatePicker.ts +243 -0
  39. package/src/components/date-picker/index.ts +10 -0
  40. package/src/components/date-range-picker/CDateRangePicker.ts +635 -0
  41. package/src/components/date-range-picker/index.ts +10 -0
  42. package/src/components/dropdown/CDropdown.ts +48 -49
  43. package/src/components/dropdown/CDropdownMenu.ts +52 -7
  44. package/src/components/dropdown/CDropdownToggle.ts +93 -29
  45. package/src/components/dropdown/__tests__/CDropdownMenu.spec.ts +7 -7
  46. package/src/components/dropdown/__tests__/CDropdownToggle.spec.ts +4 -5
  47. package/src/components/dropdown/__tests__/__snapshots__/CDropdownToggle.spec.ts.snap +2 -2
  48. package/src/components/form/CFormCheck.ts +2 -1
  49. package/src/components/form/CFormSwitch.ts +1 -7
  50. package/src/components/form/__tests__/__snapshots__/CFormCheck.spec.ts.snap +2 -8
  51. package/src/components/index.ts +5 -0
  52. package/src/components/modal/__tests__/__snapshots__/CModal.spec.ts.snap +2 -1
  53. package/src/components/pagination/CSmartPagination.ts +4 -4
  54. package/src/components/picker/CPicker.ts +220 -0
  55. package/src/components/picker/index.ts +10 -0
  56. package/src/components/sidebar/__tests__/__snapshots__/CSidebar.spec.ts.snap +8 -2
  57. package/src/components/smart-table/CSmartTable.ts +17 -49
  58. package/src/components/smart-table/CSmartTableInterface.ts +5 -3
  59. package/src/components/time-picker/CTimePicker.ts +410 -0
  60. package/src/components/time-picker/CTimePickerRollCol.ts +58 -0
  61. package/src/components/time-picker/index.ts +10 -0
  62. package/src/components/toast/__tests__/__snapshots__/CToastClose.spec.ts.snap +1 -1
  63. package/src/utils/calendar.ts +193 -0
  64. package/src/utils/time.ts +58 -0
@@ -0,0 +1,220 @@
1
+ import { defineComponent, h, PropType, ref, watch } from 'vue'
2
+
3
+ import { CButton } from '../button/'
4
+ import { CDropdown, CDropdownMenu, CDropdownToggle } from '../dropdown/'
5
+
6
+ import { Color } from '../props'
7
+
8
+ const CPicker = defineComponent({
9
+ name: 'CPicker',
10
+ props: {
11
+ ...CDropdown.props,
12
+ /**
13
+ * Toggle visibility or set the content of cancel button.
14
+ */
15
+ cancelButton: {
16
+ type: [Boolean, String],
17
+ default: 'Cancel',
18
+ },
19
+ /**
20
+ * Sets the color context of the cancel button to one of CoreUI’s themed colors.
21
+ *
22
+ * @values 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'
23
+ */
24
+ cancelButtonColor: {
25
+ ...Color,
26
+ default: 'primary',
27
+ },
28
+ /**
29
+ * Size the cancel button small or large.
30
+ *
31
+ * @values 'sm', 'lg'
32
+ */
33
+ cancelButtonSize: {
34
+ type: String,
35
+ default: 'sm',
36
+ validator: (value: string) => {
37
+ return ['sm', 'lg'].includes(value)
38
+ },
39
+ },
40
+ /**
41
+ * Set the cancel button variant to an outlined button or a ghost button.
42
+ *
43
+ * @values 'ghost', 'outline'
44
+ */
45
+ cancelButtonVariant: {
46
+ type: String,
47
+ default: 'ghost',
48
+ validator: (value: string) => {
49
+ return ['ghost', 'outline'].includes(value)
50
+ },
51
+ },
52
+ /**
53
+ * Toggle visibility or set the content of confirm button.
54
+ */
55
+ confirmButton: {
56
+ type: [Boolean, String],
57
+ default: 'OK',
58
+ },
59
+ /**
60
+ * Sets the color context of the confirm button to one of CoreUI’s themed colors.
61
+ *
62
+ * @values 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'
63
+ */
64
+ confirmButtonColor: {
65
+ ...Color,
66
+ default: 'primary',
67
+ },
68
+ /**
69
+ * Size the confirm button small or large.
70
+ *
71
+ * @values 'sm', 'lg'
72
+ */
73
+ confirmButtonSize: {
74
+ type: String,
75
+ default: 'sm',
76
+ validator: (value: string) => {
77
+ return ['sm', 'lg'].includes(value)
78
+ },
79
+ },
80
+ /**
81
+ * Set the confirm button variant to an outlined button or a ghost button.
82
+ *
83
+ * @values 'ghost', 'outline'
84
+ */
85
+ confirmButtonVariant: {
86
+ type: String,
87
+ validator: (value: string) => {
88
+ return ['ghost', 'outline'].includes(value)
89
+ },
90
+ },
91
+ /**
92
+ * Set container type for the component.
93
+ */
94
+ container: {
95
+ type: String as PropType<'dropdown' | 'inline'>,
96
+ default: 'dropdown',
97
+ },
98
+ /**
99
+ * Toggle the disabled state for the component.
100
+ */
101
+ disabled: Boolean,
102
+ /**
103
+ * Toggle visibility of footer element or set the content of footer.
104
+ */
105
+ footer: Boolean,
106
+ /**
107
+ * Toggle the visibility of the component.
108
+ */
109
+ visible: Boolean,
110
+ },
111
+ emits: [
112
+ /**
113
+ * Callback fired when the cancel button has been clicked.
114
+ */
115
+ 'cancel',
116
+ /**
117
+ * Callback fired when the confirm button has been clicked.
118
+ */
119
+ 'confirm',
120
+ /**
121
+ * Callback fired when the component requests to be hidden.
122
+ */
123
+ 'hide',
124
+ /**
125
+ * Callback fired when the component requests to be shown.
126
+ */
127
+ 'show',
128
+ ],
129
+ setup(props, { emit, slots }) {
130
+ const visible = ref(props.visible)
131
+
132
+ watch(
133
+ () => props.visible,
134
+ () => {
135
+ visible.value = props.visible
136
+ },
137
+ )
138
+
139
+ const handleConfirm = () => {
140
+ emit('confirm')
141
+ visible.value = false
142
+ }
143
+
144
+ const Footer = () =>
145
+ h('div', { class: 'picker-footer' }, [
146
+ props.cancelButton &&
147
+ h(
148
+ CButton,
149
+ {
150
+ color: props.cancelButtonColor,
151
+ onClick: () => emit('cancel'),
152
+ size: props.cancelButtonSize,
153
+ variant: props.cancelButtonVariant,
154
+ },
155
+ /**
156
+ * @slot Location for the cancel button content.
157
+ */
158
+ () => (slots.cancelButton ? slots.cancelButton() : props.cancelButton),
159
+ ),
160
+ props.confirmButton &&
161
+ h(
162
+ CButton,
163
+ {
164
+ color: props.confirmButtonColor,
165
+ onClick: handleConfirm,
166
+ size: props.confirmButtonSize,
167
+ variant: props.confirmButtonVariant,
168
+ },
169
+ /**
170
+ * @slot Location for the confirm button content.
171
+ */
172
+ () => (slots.confirmButton ? slots.confirmButton() : props.confirmButton),
173
+ ),
174
+ ])
175
+
176
+ switch (props.container) {
177
+ case 'inline':
178
+ return () => h('div', { class: 'picker' }, slots.default && slots.default())
179
+ default:
180
+ return () =>
181
+ h(
182
+ CDropdown,
183
+ {
184
+ autoClose: 'outside',
185
+ class: 'picker',
186
+ onHide: () => {
187
+ visible.value = false
188
+ emit('hide')
189
+ },
190
+ onShow: () => {
191
+ visible.value = true
192
+ emit('show')
193
+ },
194
+ variant: 'dropdown',
195
+ visible: visible.value,
196
+ },
197
+ () => [
198
+ h(
199
+ CDropdownToggle,
200
+ {
201
+ custom: true,
202
+ disabled: visible.value || props.disabled,
203
+ },
204
+ {
205
+ /**
206
+ * @slot Location for the toggler element.
207
+ */
208
+ default: () => slots.toggler && slots.toggler(),
209
+ },
210
+ ),
211
+ h(CDropdownMenu, {}, () => [
212
+ slots.default && slots.default(),
213
+ props.footer && Footer(),
214
+ ]),
215
+ ],
216
+ )
217
+ }
218
+ },
219
+ })
220
+ export { CPicker }
@@ -0,0 +1,10 @@
1
+ import { App } from 'vue'
2
+ import { CPicker } from './CPicker'
3
+
4
+ const CPickerPlugin = {
5
+ install: (app: App): void => {
6
+ app.component(CPicker.name, CPicker)
7
+ },
8
+ }
9
+
10
+ export { CPicker, CPickerPlugin }
@@ -1,5 +1,11 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Customize CSidebar component renders correctly 1`] = `"<div class=\\"sidebar sidebar-narrow sidebar-overlaid sidebar-fixed sidebar-xl sidebar-narrow-unfoldable\\">Default slot</div>"`;
3
+ exports[`Customize CSidebar component renders correctly 1`] = `
4
+ "<div class=\\"sidebar sidebar-narrow sidebar-overlaid sidebar-fixed sidebar-xl sidebar-narrow-unfoldable\\">Default slot</div>
5
+ <!---->"
6
+ `;
4
7
 
5
- exports[`Loads and display CSidebar component renders correctly 1`] = `"<div class=\\"sidebar hide\\">Default slot</div>"`;
8
+ exports[`Loads and display CSidebar component renders correctly 1`] = `
9
+ "<div class=\\"sidebar hide\\">Default slot</div>
10
+ <!---->"
11
+ `;
@@ -31,8 +31,6 @@ const CSmartTable = defineComponent({
31
31
  props: {
32
32
  /**
33
33
  * Sets active page. If 'pagination' prop is enabled, activePage is set only initially.
34
- *
35
- * @default 1
36
34
  */
37
35
  activePage: {
38
36
  type: Number,
@@ -41,7 +39,7 @@ const CSmartTable = defineComponent({
41
39
  },
42
40
  /**
43
41
  * When set, displays table cleaner above table, next to the table filter (or in place of table filter if `tableFilter` prop is not set)
44
- * Cleaner resets `tableFilterValue`, `columnFilterValue`, `sorterValue`. If clean is possible it is clickable (`tabIndex="0"` `role="button"`, `color="danger"`), otherwise it is not clickable and transparent. Cleaner can be customized through the `cleaner` slot.
42
+ * Cleaner resets `tableFilterValue`, `columnFilterValue`, `sorterValue`. If clean is possible it is clickable (`tabIndex="0"` `role="button"`, `color="danger"`), otherwise it is not clickable and transparent. Cleaner can be customized through the `cleanerIcon` slot.
45
43
  *
46
44
  */
47
45
  cleaner: {
@@ -50,8 +48,6 @@ const CSmartTable = defineComponent({
50
48
  },
51
49
  /**
52
50
  * Style table items as clickable.
53
- *
54
- * @type boolean
55
51
  */
56
52
  clickableRows: {
57
53
  type: Boolean,
@@ -62,8 +58,6 @@ const CSmartTable = defineComponent({
62
58
  * Column filter can be customized, by passing prop as object with additional options as keys. Available options:
63
59
  * - external (Boolean) - Disables automatic filtering inside component.
64
60
  * - lazy (Boolean) - Set to true to trigger filter updates only on change event.
65
- *
66
- * @type boolean | ColumnFilter
67
61
  */
68
62
  columnFilter: {
69
63
  type: [Boolean, Object] as PropType<boolean | ColumnFilter>,
@@ -72,7 +66,6 @@ const CSmartTable = defineComponent({
72
66
  /**
73
67
  * Value of table filter. To set pass object where keys are column names and values are filter strings e.g.:
74
68
  * { user: 'John', age: 12 }
75
- * You can track state of this prop by setting .sync modifier.
76
69
  */
77
70
  columnFilterValue: {
78
71
  type: Object as PropType<ColumnFilterValue>,
@@ -80,17 +73,17 @@ const CSmartTable = defineComponent({
80
73
  required: false,
81
74
  },
82
75
  /**
83
- * Prop for table columns configuration. If prop is not defined, table will display columns based on the first item keys, omitting keys that begins with underscore (e.g. '_classes')
76
+ * Prop for table columns configuration. If prop is not defined, table will display columns based on the first item keys, omitting keys that begins with underscore (e.g. '_props')
84
77
  *
85
78
  * In columns prop each array item represents one column. Item might be specified in two ways:
86
79
  * String: each item define column name equal to item value.
87
80
  * Object: item is object with following keys available as column configuration:
88
81
  * - key (required)(String) - define column name equal to item key.
82
+ * - filter (Boolean) - removes filter from column when set to false.
89
83
  * - label (String) - define visible label of column. If not defined, label will be generated automatically based on column name, by converting kebab-case and snake_case to individual words and capitalization of each word.
90
- * - _classes (String/Array/Object) - adds classes to all cels in column
91
- * - _style (String/Array/Object) - adds styles to the column header (useful for defining widths)
92
84
  * - sorter (Boolean) - disables sorting of the column when set to false
93
- * - filter (Boolean) - removes filter from column when set to false.
85
+ * - [_props](https://coreui.io/vue/docs/components/table.html#ctableheadercell) (String/Array/Object) - add props to `CTableHeaderCell`.
86
+ * - _style (String/Array/Object) - adds styles to the column header (useful for defining widths)
94
87
  */
95
88
  columns: {
96
89
  type: Array as PropType<Column[] | string[]>,
@@ -102,8 +95,6 @@ const CSmartTable = defineComponent({
102
95
  * Sorter can be customized, by passing prop as object with additional options as keys. Available options:
103
96
  * - external (Boolean) - Disables automatic sorting inside component.
104
97
  * - resetable (Boolean) - If set to true clicking on sorter have three states: ascending, descending and null. That means that third click on sorter will reset sorting, and restore table to original order.
105
- *
106
- * @type boolean | Sorter
107
98
  */
108
99
  columnSorter: {
109
100
  type: [Boolean, Object] as PropType<boolean | Sorter>,
@@ -119,8 +110,6 @@ const CSmartTable = defineComponent({
119
110
  },
120
111
  /**
121
112
  * Set to false to remove table header.
122
- *
123
- * @default true
124
113
  */
125
114
  header: {
126
115
  type: Boolean,
@@ -128,7 +117,11 @@ const CSmartTable = defineComponent({
128
117
  default: true,
129
118
  },
130
119
  /**
131
- * Array of objects, where each object represents one item - row in table. Additionally, you can add style classes to each row by passing them by '_classes' key and to single cell by '_cellClasses'.
120
+ * Array of objects, where each object represents one item - row in table. Additionally, you can customize each row by passing them by [_props](http://coreui.io/vue/docs/components/table.html#ctablerow) key and single cell by [_cellProps](http://coreui.io/vue/docs/components/table.html#ctabledatacell).
121
+ *
122
+ * Examples:
123
+ * - `_props: { color: 'primary', align: 'middle'}`
124
+ * - `_cellProps: { all: { class: 'fw-semibold'}, 'name': { color: 'info' }}`
132
125
  */
133
126
  items: {
134
127
  type: Array as PropType<Item[]>,
@@ -137,8 +130,6 @@ const CSmartTable = defineComponent({
137
130
  },
138
131
  /**
139
132
  * Number of items per site, when pagination is enabled.
140
- *
141
- * @default 10
142
133
  */
143
134
  itemsPerPage: {
144
135
  type: Number,
@@ -146,8 +137,6 @@ const CSmartTable = defineComponent({
146
137
  },
147
138
  /**
148
139
  * Label for items per page selector.
149
- *
150
- * @default 'Items per page:'
151
140
  */
152
141
  itemsPerPageLabel: {
153
142
  type: String,
@@ -156,8 +145,6 @@ const CSmartTable = defineComponent({
156
145
  },
157
146
  /**
158
147
  * Items per page selector options.
159
- *
160
- * @default [5, 10, 20, 50]
161
148
  */
162
149
  itemsPerPageOptions: {
163
150
  type: Array as PropType<number[]>,
@@ -184,7 +171,6 @@ const CSmartTable = defineComponent({
184
171
  },
185
172
  /**
186
173
  * ReactNode or string for passing custom noItemsLabel texts.
187
- * @default 'No items found'
188
174
  */
189
175
  noItemsLabel: {
190
176
  type: String,
@@ -199,9 +185,7 @@ const CSmartTable = defineComponent({
199
185
  required: false,
200
186
  },
201
187
  /**
202
- * Properties to `CSmartPagination` component.
203
- *
204
- * @link https://coreui.io/vue/docs/4.0/components/smart-pagination#csmartpagination
188
+ * Properties to [CSmartPagination](https://coreui.io/vue/docs/components/smart-pagination#csmartpagination) component.
205
189
  */
206
190
  paginationProps: {
207
191
  type: Object,
@@ -213,10 +197,8 @@ const CSmartTable = defineComponent({
213
197
  */
214
198
  selectable: Boolean,
215
199
  /**
216
- * State of the sorter. Name key is column name, direction can be 'asc' or 'desc'. Set .sync modifier to track changes. eg.:
200
+ * State of the sorter. Name key is column name, direction can be 'asc' or 'desc'. eg.:
217
201
  * { column: 'status', state: 'asc' }
218
- *
219
- * @type SorterValue
220
202
  */
221
203
  sorterValue: {
222
204
  type: Object as PropType<SorterValue>,
@@ -224,9 +206,7 @@ const CSmartTable = defineComponent({
224
206
  required: false,
225
207
  },
226
208
  /**
227
- * Properties to `CTableBody` component.
228
- *
229
- * @link https://coreui.io/vue/docs/4.0/components/table/#ctablebody
209
+ * Properties to [CTableBody](https://coreui.io/vue/docs/components/table/#ctablebody) component.
230
210
  */
231
211
  tableBodyProps: {
232
212
  type: Object,
@@ -234,9 +214,7 @@ const CSmartTable = defineComponent({
234
214
  required: false,
235
215
  },
236
216
  /**
237
- * Properties to `CTableFoot` component.
238
- *
239
- * @link https://coreui.io/vue/docs/4.0/components/table/#ctablefoot
217
+ * Properties to [CTableFoot](https://coreui.io/vue/docs/components/table/#ctablefoot) component.
240
218
  */
241
219
  tableFootProps: {
242
220
  type: Object,
@@ -247,8 +225,6 @@ const CSmartTable = defineComponent({
247
225
  * When set, displays table filter above table, allowing filtering by specific column.
248
226
  *
249
227
  * Column filter can be customized, by passing prop as object with additional options as keys. Available options:
250
- * - placeholder (String) - Sets custom table filter placeholder.
251
- * - label (String) - Sets custom table filter label.
252
228
  * - external (Boolean) - Disables automatic filtering inside component.
253
229
  * - lazy (Boolean) - Set to true to trigger filter updates only on change event.
254
230
  */
@@ -266,8 +242,6 @@ const CSmartTable = defineComponent({
266
242
  },
267
243
  /**
268
244
  * Specifies a short hint that is visible in the search input.
269
- *
270
- * @default 'type string...'
271
245
  */
272
246
  tableFilterPlaceholder: {
273
247
  type: String,
@@ -275,9 +249,7 @@ const CSmartTable = defineComponent({
275
249
  required: false,
276
250
  },
277
251
  /**
278
- * Value of table filter. Set .sync modifier to track changes.
279
- *
280
- * @default 'Filter:'
252
+ * Value of table filter.
281
253
  */
282
254
  tableFilterValue: {
283
255
  type: String,
@@ -285,9 +257,7 @@ const CSmartTable = defineComponent({
285
257
  required: false,
286
258
  },
287
259
  /**
288
- * Properties to `CTableHead` component.
289
- *
290
- * @link https://coreui.io/vue/docs/4.0/components/table/#ctablehead
260
+ * Properties to [CTableHead](https://coreui.io/vue/docs/components/table/#ctablehead) component.
291
261
  */
292
262
  tableHeadProps: {
293
263
  type: Object,
@@ -295,9 +265,7 @@ const CSmartTable = defineComponent({
295
265
  required: false,
296
266
  },
297
267
  /**
298
- * Properties to `CTable` component.
299
- *
300
- * @link https://coreui.io/vue/docs/4.0/components/table/#ctable
268
+ * Properties to [CTable](https://coreui.io/vue/docs/components/table/#ctable) component.
301
269
  */
302
270
  tableProps: {
303
271
  type: Object,
@@ -4,10 +4,10 @@
4
4
  /* eslint-disable no-unused-vars */
5
5
  /* eslint-disable @typescript-eslint/ban-types */
6
6
  export interface Column {
7
- sorter?: boolean
7
+ filter?: boolean
8
8
  key: string
9
9
  label?: string
10
- filter?: boolean
10
+ sorter?: boolean
11
11
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
12
  _style?: any
13
13
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -53,9 +53,11 @@ export interface SorterValue {
53
53
  }
54
54
 
55
55
  export interface TableFilter {
56
- lazy?: boolean
57
56
  external?: boolean
57
+ lazy?: boolean
58
+ // TODO: depracated, remove in v5
58
59
  label?: string
60
+ // TODO: depracated, remove in v5
59
61
  placeholder?: string
60
62
  }
61
63