@coreui/vue-pro 4.4.1 → 4.5.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/dist/components/multi-select/CMultiSelect copy.d.ts +305 -0
- package/dist/components/multi-select/CMultiSelect.d.ts +37 -0
- package/dist/components/smart-table/CSmartTable.d.ts +2 -2
- package/dist/components/smart-table/CSmartTableHead.d.ts +15 -3
- package/dist/components/smart-table/CSmartTableInterface.d.ts +1 -1
- package/dist/components/table/CTable.d.ts +170 -8
- package/dist/components/table/CTableDataCell.d.ts +14 -0
- package/dist/index.es.js +414 -230
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +414 -230
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/date-range-picker/CDateRangePicker.ts +1 -1
- package/src/components/form/CFormInput.ts +1 -1
- package/src/components/multi-select/CMultiSelect.ts +94 -83
- package/src/components/smart-table/CSmartTable.ts +22 -21
- package/src/components/smart-table/CSmartTableHead.ts +45 -24
- package/src/components/smart-table/CSmartTableInterface.ts +1 -1
- package/src/components/smart-table/CSmartTableItemsPerPageSelector.ts +1 -1
- package/src/components/table/CTable.ts +243 -9
- package/src/components/table/CTableDataCell.ts +9 -1
package/dist/index.es.js
CHANGED
|
@@ -8467,7 +8467,7 @@ const CFormInput = defineComponent({
|
|
|
8467
8467
|
onInput: (event) => handleInput(event),
|
|
8468
8468
|
readonly: props.readonly,
|
|
8469
8469
|
type: props.type,
|
|
8470
|
-
...(props.modelValue && { value: props.modelValue })
|
|
8470
|
+
...((props.modelValue || props.modelValue === 0) && { value: props.modelValue })
|
|
8471
8471
|
}, slots.default && slots.default()),
|
|
8472
8472
|
...(slots.feedback && { feedback: () => slots.feedback && slots.feedback() }),
|
|
8473
8473
|
...(slots.feedbackInvalid && {
|
|
@@ -12888,7 +12888,7 @@ const CDateRangePicker = defineComponent({
|
|
|
12888
12888
|
maxDate: maxDate.value,
|
|
12889
12889
|
minDate: minDate.value,
|
|
12890
12890
|
navigation: props.navigation,
|
|
12891
|
-
range:
|
|
12891
|
+
range: props.range,
|
|
12892
12892
|
selectEndDate: selectEndDate.value,
|
|
12893
12893
|
...(startDate.value && { startDate: startDate.value }),
|
|
12894
12894
|
onCalendarCellHover: (date) => handleCalendarCellHover(date),
|
|
@@ -14573,6 +14573,14 @@ const CMultiSelect = defineComponent({
|
|
|
14573
14573
|
required: false,
|
|
14574
14574
|
default: true,
|
|
14575
14575
|
},
|
|
14576
|
+
/**
|
|
14577
|
+
* Toggle the disabled state for the component.
|
|
14578
|
+
*/
|
|
14579
|
+
disabled: {
|
|
14580
|
+
type: Boolean,
|
|
14581
|
+
required: false,
|
|
14582
|
+
default: false,
|
|
14583
|
+
},
|
|
14576
14584
|
/**
|
|
14577
14585
|
* It specifies that multiple options can be selected at once.
|
|
14578
14586
|
*
|
|
@@ -14685,6 +14693,18 @@ const CMultiSelect = defineComponent({
|
|
|
14685
14693
|
default: 'item(s) selected',
|
|
14686
14694
|
required: false,
|
|
14687
14695
|
},
|
|
14696
|
+
/**
|
|
14697
|
+
* Size the component small or large.
|
|
14698
|
+
*
|
|
14699
|
+
* @values 'sm', 'lg'
|
|
14700
|
+
*/
|
|
14701
|
+
size: {
|
|
14702
|
+
type: String,
|
|
14703
|
+
required: false,
|
|
14704
|
+
validator: (value) => {
|
|
14705
|
+
return ['sm', 'lg'].includes(value);
|
|
14706
|
+
},
|
|
14707
|
+
},
|
|
14688
14708
|
/**
|
|
14689
14709
|
* Toggle the visibility of multi select dropdown.
|
|
14690
14710
|
*
|
|
@@ -14767,7 +14787,6 @@ const CMultiSelect = defineComponent({
|
|
|
14767
14787
|
}, [])
|
|
14768
14788
|
: options.value;
|
|
14769
14789
|
};
|
|
14770
|
-
const multiSelectRef = ref();
|
|
14771
14790
|
const nativeSelectRef = ref();
|
|
14772
14791
|
provide('nativeSelectRef', nativeSelectRef);
|
|
14773
14792
|
const searchRef = ref();
|
|
@@ -14777,8 +14796,9 @@ const CMultiSelect = defineComponent({
|
|
|
14777
14796
|
const visible = ref(props.visible);
|
|
14778
14797
|
const selected = ref(getSelectedOptions(props.options));
|
|
14779
14798
|
const count = ref(0);
|
|
14780
|
-
watch(() => props.options, () => {
|
|
14781
|
-
|
|
14799
|
+
watch(() => props.options, (newValue, oldValue) => {
|
|
14800
|
+
if (JSON.stringify(newValue) !== JSON.stringify(oldValue))
|
|
14801
|
+
options.value = newValue;
|
|
14782
14802
|
});
|
|
14783
14803
|
watch(options, () => {
|
|
14784
14804
|
const _selected = options.value && getSelectedOptions(options.value);
|
|
@@ -14801,24 +14821,6 @@ const CMultiSelect = defineComponent({
|
|
|
14801
14821
|
nativeSelectRef.value &&
|
|
14802
14822
|
nativeSelectRef.value.dispatchEvent(new Event('change', { bubbles: true }));
|
|
14803
14823
|
});
|
|
14804
|
-
onMounted(() => {
|
|
14805
|
-
window.addEventListener('click', handleClickOutside);
|
|
14806
|
-
window.addEventListener('keyup', handleKeyup);
|
|
14807
|
-
});
|
|
14808
|
-
onUnmounted(() => {
|
|
14809
|
-
window.removeEventListener('click', handleClickOutside);
|
|
14810
|
-
window.removeEventListener('keyup', handleKeyup);
|
|
14811
|
-
});
|
|
14812
|
-
const handleKeyup = (event) => {
|
|
14813
|
-
if (multiSelectRef.value && !multiSelectRef.value.contains(event.target)) {
|
|
14814
|
-
visible.value = false;
|
|
14815
|
-
}
|
|
14816
|
-
};
|
|
14817
|
-
const handleClickOutside = (event) => {
|
|
14818
|
-
if (multiSelectRef.value && !multiSelectRef.value.contains(event.target)) {
|
|
14819
|
-
visible.value = false;
|
|
14820
|
-
}
|
|
14821
|
-
};
|
|
14822
14824
|
const handleSearchChange = (event) => {
|
|
14823
14825
|
const target = event.target;
|
|
14824
14826
|
search.value = target.value.toLowerCase();
|
|
@@ -14852,56 +14854,64 @@ const CMultiSelect = defineComponent({
|
|
|
14852
14854
|
: selected.value.map((option) => option.value)[0],
|
|
14853
14855
|
onChange: () => emit('change', selected.value),
|
|
14854
14856
|
}),
|
|
14855
|
-
h$1(
|
|
14857
|
+
h$1(CPicker, {
|
|
14856
14858
|
class: [
|
|
14857
14859
|
'form-multi-select',
|
|
14858
14860
|
{
|
|
14859
|
-
|
|
14861
|
+
'form-multi-select-with-cleaner': props.cleaner,
|
|
14862
|
+
disabled: props.disabled,
|
|
14863
|
+
[`form-multi-select-${props.size}`]: props.size,
|
|
14860
14864
|
'form-multi-select-selection-tags': props.multiple && props.selectionType === 'tags',
|
|
14865
|
+
show: visible.value,
|
|
14861
14866
|
},
|
|
14862
14867
|
],
|
|
14863
|
-
|
|
14864
|
-
|
|
14868
|
+
disabled: props.disabled,
|
|
14869
|
+
onShow: () => {
|
|
14865
14870
|
props.search && searchRef.value && searchRef.value.focus();
|
|
14866
14871
|
},
|
|
14867
|
-
|
|
14868
|
-
|
|
14869
|
-
|
|
14870
|
-
|
|
14871
|
-
|
|
14872
|
-
|
|
14873
|
-
|
|
14874
|
-
|
|
14875
|
-
|
|
14876
|
-
}),
|
|
14877
|
-
props.multiple &&
|
|
14878
|
-
props.cleaner &&
|
|
14879
|
-
selected.value.length > 0 &&
|
|
14880
|
-
h$1('button', {
|
|
14881
|
-
type: 'button',
|
|
14882
|
-
class: 'form-multi-select-selection-cleaner',
|
|
14883
|
-
onClick: () => handleDeselectAll(),
|
|
14872
|
+
}, {
|
|
14873
|
+
toggler: () => h$1('div', {}, [
|
|
14874
|
+
h$1(CMultiSelectSelection, {
|
|
14875
|
+
multiple: props.multiple,
|
|
14876
|
+
onRemove: (option) => !props.disabled && handleOptionClick(option),
|
|
14877
|
+
search: props.search,
|
|
14878
|
+
selected: selected.value,
|
|
14879
|
+
selectionType: props.selectionType,
|
|
14880
|
+
selectionTypeCounterText: props.selectionTypeCounterText,
|
|
14884
14881
|
}),
|
|
14885
|
-
|
|
14886
|
-
|
|
14887
|
-
|
|
14888
|
-
|
|
14889
|
-
|
|
14890
|
-
|
|
14891
|
-
|
|
14892
|
-
|
|
14893
|
-
placeholder: `${selected.value.length} ${props.selectionTypeCounterText}`,
|
|
14882
|
+
props.multiple &&
|
|
14883
|
+
props.cleaner &&
|
|
14884
|
+
selected.value.length > 0 &&
|
|
14885
|
+
!props.disabled &&
|
|
14886
|
+
h$1('button', {
|
|
14887
|
+
type: 'button',
|
|
14888
|
+
class: 'form-multi-select-selection-cleaner',
|
|
14889
|
+
onClick: () => handleDeselectAll(),
|
|
14894
14890
|
}),
|
|
14895
|
-
|
|
14896
|
-
|
|
14897
|
-
|
|
14898
|
-
|
|
14899
|
-
|
|
14900
|
-
selected.value.length &&
|
|
14901
|
-
|
|
14902
|
-
|
|
14903
|
-
|
|
14904
|
-
|
|
14891
|
+
props.search &&
|
|
14892
|
+
h$1('input', {
|
|
14893
|
+
type: 'text',
|
|
14894
|
+
class: 'form-multi-select-search',
|
|
14895
|
+
autocomplete: 'off',
|
|
14896
|
+
...(selected.value.length === 0 && { placeholder: props.placeholder }),
|
|
14897
|
+
...(selected.value.length &&
|
|
14898
|
+
props.selectionType === 'counter' && {
|
|
14899
|
+
placeholder: `${selected.value.length} ${props.selectionTypeCounterText}`,
|
|
14900
|
+
}),
|
|
14901
|
+
...(selected.value.length &&
|
|
14902
|
+
!props.multiple && {
|
|
14903
|
+
placeholder: selected.value.map((option) => option.text)[0],
|
|
14904
|
+
}),
|
|
14905
|
+
disabled: props.disabled,
|
|
14906
|
+
onInput: (event) => handleSearchChange(event),
|
|
14907
|
+
onKeydown: (event) => handleSearchKeyDown(event),
|
|
14908
|
+
...(props.multiple &&
|
|
14909
|
+
selected.value.length &&
|
|
14910
|
+
props.selectionType !== 'counter' && { size: search.value.length + 2 }),
|
|
14911
|
+
ref: searchRef,
|
|
14912
|
+
}),
|
|
14913
|
+
]),
|
|
14914
|
+
default: () => h$1('div', {}, [
|
|
14905
14915
|
props.multiple &&
|
|
14906
14916
|
props.selectAll &&
|
|
14907
14917
|
h$1('button', { class: 'form-multi-select-all', onClick: () => handleSelectAll() }, props.selectAllLabel),
|
|
@@ -14913,7 +14923,7 @@ const CMultiSelect = defineComponent({
|
|
|
14913
14923
|
searchNoResultsLabel: props.searchNoResultsLabel,
|
|
14914
14924
|
}),
|
|
14915
14925
|
]),
|
|
14916
|
-
|
|
14926
|
+
}),
|
|
14917
14927
|
];
|
|
14918
14928
|
},
|
|
14919
14929
|
});
|
|
@@ -16572,142 +16582,6 @@ const CSidebarPlugin = {
|
|
|
16572
16582
|
},
|
|
16573
16583
|
};
|
|
16574
16584
|
|
|
16575
|
-
const CTable = defineComponent({
|
|
16576
|
-
name: 'CTable',
|
|
16577
|
-
props: {
|
|
16578
|
-
/**
|
|
16579
|
-
* Set the vertical aligment.
|
|
16580
|
-
*
|
|
16581
|
-
* @values 'bottom', 'middle', 'top'
|
|
16582
|
-
*/
|
|
16583
|
-
align: {
|
|
16584
|
-
type: String,
|
|
16585
|
-
default: undefined,
|
|
16586
|
-
required: false,
|
|
16587
|
-
validator: (value) => {
|
|
16588
|
-
return ['bottom', 'middle', 'top'].includes(value);
|
|
16589
|
-
},
|
|
16590
|
-
},
|
|
16591
|
-
/**
|
|
16592
|
-
* Sets the border color of the component to one of CoreUI’s themed colors.
|
|
16593
|
-
*
|
|
16594
|
-
* @values 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'
|
|
16595
|
-
*/
|
|
16596
|
-
borderColor: Color,
|
|
16597
|
-
/**
|
|
16598
|
-
* Add borders on all sides of the table and cells.
|
|
16599
|
-
*/
|
|
16600
|
-
bordered: {
|
|
16601
|
-
type: Boolean,
|
|
16602
|
-
required: false,
|
|
16603
|
-
},
|
|
16604
|
-
/**
|
|
16605
|
-
* Remove borders on all sides of the table and cells.
|
|
16606
|
-
*/
|
|
16607
|
-
borderless: {
|
|
16608
|
-
type: Boolean,
|
|
16609
|
-
required: false,
|
|
16610
|
-
},
|
|
16611
|
-
/**
|
|
16612
|
-
* Put the `<caption>` on the top of the table.
|
|
16613
|
-
*
|
|
16614
|
-
* @values 'top'
|
|
16615
|
-
*/
|
|
16616
|
-
caption: {
|
|
16617
|
-
type: String,
|
|
16618
|
-
default: undefined,
|
|
16619
|
-
required: false,
|
|
16620
|
-
validator: (value) => {
|
|
16621
|
-
return value === 'top';
|
|
16622
|
-
},
|
|
16623
|
-
},
|
|
16624
|
-
/**
|
|
16625
|
-
* Sets the color context of the component to one of CoreUI’s themed colors.
|
|
16626
|
-
*
|
|
16627
|
-
* @values 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light', string
|
|
16628
|
-
*/
|
|
16629
|
-
color: Color,
|
|
16630
|
-
/**
|
|
16631
|
-
* Enable a hover state on table rows within a `<CTableBody>`.
|
|
16632
|
-
*/
|
|
16633
|
-
hover: {
|
|
16634
|
-
type: Boolean,
|
|
16635
|
-
required: false,
|
|
16636
|
-
},
|
|
16637
|
-
/**
|
|
16638
|
-
* Make any table responsive across all viewports or pick a maximum breakpoint with which to have a responsive table up to.
|
|
16639
|
-
*
|
|
16640
|
-
* @values boolean, 'sm', 'md', 'lg', 'xl', 'xxl'
|
|
16641
|
-
*/
|
|
16642
|
-
responsive: {
|
|
16643
|
-
type: [Boolean, String],
|
|
16644
|
-
default: undefined,
|
|
16645
|
-
required: false,
|
|
16646
|
-
validator: (value) => {
|
|
16647
|
-
if (typeof value == 'string') {
|
|
16648
|
-
return ['sm', 'md', 'lg', 'xl', 'xxl'].includes(value);
|
|
16649
|
-
}
|
|
16650
|
-
if (typeof value == 'boolean') {
|
|
16651
|
-
return true;
|
|
16652
|
-
}
|
|
16653
|
-
return false;
|
|
16654
|
-
},
|
|
16655
|
-
},
|
|
16656
|
-
/**
|
|
16657
|
-
* Make table more compact by cutting all cell `padding` in half.
|
|
16658
|
-
*/
|
|
16659
|
-
small: {
|
|
16660
|
-
type: Boolean,
|
|
16661
|
-
required: false,
|
|
16662
|
-
},
|
|
16663
|
-
/**
|
|
16664
|
-
* Add zebra-striping to any table row within the `<CTableBody>`.
|
|
16665
|
-
*/
|
|
16666
|
-
striped: {
|
|
16667
|
-
type: Boolean,
|
|
16668
|
-
required: false,
|
|
16669
|
-
},
|
|
16670
|
-
/**
|
|
16671
|
-
* Add zebra-striping to any table column.
|
|
16672
|
-
*
|
|
16673
|
-
* @since 4.4.0
|
|
16674
|
-
*/
|
|
16675
|
-
stripedColumns: {
|
|
16676
|
-
type: Boolean,
|
|
16677
|
-
required: false,
|
|
16678
|
-
},
|
|
16679
|
-
},
|
|
16680
|
-
setup(props, { slots, attrs }) {
|
|
16681
|
-
const table = () => h$1('table', {
|
|
16682
|
-
class: [
|
|
16683
|
-
'table',
|
|
16684
|
-
{
|
|
16685
|
-
[`align-${props.align}`]: props.align,
|
|
16686
|
-
[`caption-${props.caption}`]: props.caption,
|
|
16687
|
-
[`border-${props.borderColor}`]: props.borderColor,
|
|
16688
|
-
'table-bordered': props.bordered,
|
|
16689
|
-
'table-borderless': props.borderless,
|
|
16690
|
-
[`table-${props.color}`]: props.color,
|
|
16691
|
-
'table-hover': props.hover,
|
|
16692
|
-
'table-sm': props.small,
|
|
16693
|
-
'table-striped': props.striped,
|
|
16694
|
-
'table-striped-columns': props.stripedColumns,
|
|
16695
|
-
},
|
|
16696
|
-
attrs.class,
|
|
16697
|
-
],
|
|
16698
|
-
}, slots.default && slots.default());
|
|
16699
|
-
return () => [
|
|
16700
|
-
props.responsive
|
|
16701
|
-
? h$1('div', {
|
|
16702
|
-
class: typeof props.responsive === 'boolean'
|
|
16703
|
-
? 'table-responsive'
|
|
16704
|
-
: `table-responsive-${props.responsive}`,
|
|
16705
|
-
}, table())
|
|
16706
|
-
: table(),
|
|
16707
|
-
];
|
|
16708
|
-
},
|
|
16709
|
-
});
|
|
16710
|
-
|
|
16711
16585
|
const CTableBody = defineComponent({
|
|
16712
16586
|
name: 'CTableBody',
|
|
16713
16587
|
props: {
|
|
@@ -16766,9 +16640,16 @@ const CTableDataCell = defineComponent({
|
|
|
16766
16640
|
* @values 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light', string
|
|
16767
16641
|
*/
|
|
16768
16642
|
color: Color,
|
|
16643
|
+
/**
|
|
16644
|
+
* @ignore
|
|
16645
|
+
*/
|
|
16646
|
+
scope: {
|
|
16647
|
+
type: String,
|
|
16648
|
+
required: false,
|
|
16649
|
+
},
|
|
16769
16650
|
},
|
|
16770
16651
|
setup(props, { slots }) {
|
|
16771
|
-
return () => h$1('td', {
|
|
16652
|
+
return () => h$1(props.scope ? 'th' : 'td', {
|
|
16772
16653
|
class: [
|
|
16773
16654
|
{
|
|
16774
16655
|
[`align-${props.align}`]: props.align,
|
|
@@ -16776,6 +16657,7 @@ const CTableDataCell = defineComponent({
|
|
|
16776
16657
|
[`table-${props.color}`]: props.color,
|
|
16777
16658
|
},
|
|
16778
16659
|
],
|
|
16660
|
+
...(props.scope && { scope: props.scope }),
|
|
16779
16661
|
}, slots.default && slots.default());
|
|
16780
16662
|
},
|
|
16781
16663
|
});
|
|
@@ -16886,6 +16768,293 @@ const CTableRow = defineComponent({
|
|
|
16886
16768
|
},
|
|
16887
16769
|
});
|
|
16888
16770
|
|
|
16771
|
+
const pretifyName = (name) => {
|
|
16772
|
+
return name
|
|
16773
|
+
.replace(/[-_.]/g, ' ')
|
|
16774
|
+
.replace(/ +/g, ' ')
|
|
16775
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
16776
|
+
.split(' ')
|
|
16777
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
16778
|
+
.join(' ');
|
|
16779
|
+
};
|
|
16780
|
+
const label = (column) => typeof column === 'object'
|
|
16781
|
+
? column.label !== undefined
|
|
16782
|
+
? column.label
|
|
16783
|
+
: pretifyName(column.key)
|
|
16784
|
+
: pretifyName(column);
|
|
16785
|
+
const CTable = defineComponent({
|
|
16786
|
+
name: 'CTable',
|
|
16787
|
+
props: {
|
|
16788
|
+
/**
|
|
16789
|
+
* Set the vertical aligment.
|
|
16790
|
+
*
|
|
16791
|
+
* @values 'bottom', 'middle', 'top'
|
|
16792
|
+
*/
|
|
16793
|
+
align: {
|
|
16794
|
+
type: String,
|
|
16795
|
+
default: undefined,
|
|
16796
|
+
required: false,
|
|
16797
|
+
validator: (value) => {
|
|
16798
|
+
return ['bottom', 'middle', 'top'].includes(value);
|
|
16799
|
+
},
|
|
16800
|
+
},
|
|
16801
|
+
/**
|
|
16802
|
+
* Sets the border color of the component to one of CoreUI’s themed colors.
|
|
16803
|
+
*
|
|
16804
|
+
* @values 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'
|
|
16805
|
+
*/
|
|
16806
|
+
borderColor: Color,
|
|
16807
|
+
/**
|
|
16808
|
+
* Add borders on all sides of the table and cells.
|
|
16809
|
+
*/
|
|
16810
|
+
bordered: {
|
|
16811
|
+
type: Boolean,
|
|
16812
|
+
required: false,
|
|
16813
|
+
},
|
|
16814
|
+
/**
|
|
16815
|
+
* Remove borders on all sides of the table and cells.
|
|
16816
|
+
*/
|
|
16817
|
+
borderless: {
|
|
16818
|
+
type: Boolean,
|
|
16819
|
+
required: false,
|
|
16820
|
+
},
|
|
16821
|
+
/**
|
|
16822
|
+
* Put the `<caption>` on the top of the table.
|
|
16823
|
+
*
|
|
16824
|
+
* @values 'top' | string
|
|
16825
|
+
*/
|
|
16826
|
+
caption: {
|
|
16827
|
+
type: String,
|
|
16828
|
+
default: undefined,
|
|
16829
|
+
required: false,
|
|
16830
|
+
},
|
|
16831
|
+
/**
|
|
16832
|
+
* Set the text of the table caption and the caption on the top of the table.
|
|
16833
|
+
*
|
|
16834
|
+
* @since 4.5.0
|
|
16835
|
+
*/
|
|
16836
|
+
captionTop: {
|
|
16837
|
+
type: String,
|
|
16838
|
+
default: undefined,
|
|
16839
|
+
required: false,
|
|
16840
|
+
},
|
|
16841
|
+
/**
|
|
16842
|
+
* 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')
|
|
16843
|
+
*
|
|
16844
|
+
* In columns prop each array item represents one column. Item might be specified in two ways:
|
|
16845
|
+
* String: each item define column name equal to item value.
|
|
16846
|
+
* Object: item is object with following keys available as column configuration:
|
|
16847
|
+
* - key (required)(String) - define column name equal to item key.
|
|
16848
|
+
* - 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.
|
|
16849
|
+
* - _props (Object) - adds classes to all cels in column, ex. _props: { scope: 'col', className: 'custom-class' },
|
|
16850
|
+
* - _style (Object) - adds styles to the column header (useful for defining widths)
|
|
16851
|
+
*
|
|
16852
|
+
* @since 4.5.0
|
|
16853
|
+
*/
|
|
16854
|
+
columns: {
|
|
16855
|
+
type: Array,
|
|
16856
|
+
required: false,
|
|
16857
|
+
},
|
|
16858
|
+
/**
|
|
16859
|
+
* Sets the color context of the component to one of CoreUI’s themed colors.
|
|
16860
|
+
*
|
|
16861
|
+
* @values 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light', string
|
|
16862
|
+
*/
|
|
16863
|
+
color: Color,
|
|
16864
|
+
/**
|
|
16865
|
+
* Array of objects or strings, where each element represents one cell in the table footer.
|
|
16866
|
+
*
|
|
16867
|
+
* Example items:
|
|
16868
|
+
* ['FooterCell', 'FooterCell', 'FooterCell']
|
|
16869
|
+
* or
|
|
16870
|
+
* [{ label: 'FooterCell', _props: { color: 'success' }, ...]
|
|
16871
|
+
*
|
|
16872
|
+
* @since 4.5.0
|
|
16873
|
+
*/
|
|
16874
|
+
footer: {
|
|
16875
|
+
type: Array,
|
|
16876
|
+
default: () => [],
|
|
16877
|
+
required: false,
|
|
16878
|
+
},
|
|
16879
|
+
/**
|
|
16880
|
+
* Enable a hover state on table rows within a `<CTableBody>`.
|
|
16881
|
+
*/
|
|
16882
|
+
hover: {
|
|
16883
|
+
type: Boolean,
|
|
16884
|
+
required: false,
|
|
16885
|
+
},
|
|
16886
|
+
/**
|
|
16887
|
+
* 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 '_props' key and to single cell by '_cellProps'.
|
|
16888
|
+
*
|
|
16889
|
+
* Example item:
|
|
16890
|
+
* { name: 'John' , age: 12, _props: { color: 'success' }, _cellProps: { age: { className: 'fw-bold'}}}
|
|
16891
|
+
*
|
|
16892
|
+
* @since 4.5.0
|
|
16893
|
+
*/
|
|
16894
|
+
items: {
|
|
16895
|
+
type: Array,
|
|
16896
|
+
default: () => [],
|
|
16897
|
+
required: false,
|
|
16898
|
+
},
|
|
16899
|
+
responsive: {
|
|
16900
|
+
type: [Boolean, String],
|
|
16901
|
+
default: undefined,
|
|
16902
|
+
required: false,
|
|
16903
|
+
validator: (value) => {
|
|
16904
|
+
if (typeof value == 'string') {
|
|
16905
|
+
return ['sm', 'md', 'lg', 'xl', 'xxl'].includes(value);
|
|
16906
|
+
}
|
|
16907
|
+
if (typeof value == 'boolean') {
|
|
16908
|
+
return true;
|
|
16909
|
+
}
|
|
16910
|
+
return false;
|
|
16911
|
+
},
|
|
16912
|
+
},
|
|
16913
|
+
/**
|
|
16914
|
+
* Make table more compact by cutting all cell `padding` in half.
|
|
16915
|
+
*/
|
|
16916
|
+
small: {
|
|
16917
|
+
type: Boolean,
|
|
16918
|
+
required: false,
|
|
16919
|
+
},
|
|
16920
|
+
/**
|
|
16921
|
+
* Add zebra-striping to any table row within the `<CTableBody>`.
|
|
16922
|
+
*/
|
|
16923
|
+
striped: {
|
|
16924
|
+
type: Boolean,
|
|
16925
|
+
required: false,
|
|
16926
|
+
},
|
|
16927
|
+
/**
|
|
16928
|
+
* Add zebra-striping to any table column.
|
|
16929
|
+
*
|
|
16930
|
+
* @since 4.4.0
|
|
16931
|
+
*/
|
|
16932
|
+
stripedColumns: {
|
|
16933
|
+
type: Boolean,
|
|
16934
|
+
required: false,
|
|
16935
|
+
},
|
|
16936
|
+
/**
|
|
16937
|
+
* Properties that will be passed to the table footer component.
|
|
16938
|
+
*
|
|
16939
|
+
* Properties to [CTableFoot](#ctablefoot) component.
|
|
16940
|
+
* @since 4.5.0
|
|
16941
|
+
*/
|
|
16942
|
+
tableFootProps: {
|
|
16943
|
+
type: Object,
|
|
16944
|
+
default: undefined,
|
|
16945
|
+
required: false,
|
|
16946
|
+
},
|
|
16947
|
+
/**
|
|
16948
|
+
* Properties that will be passed to the table head component.
|
|
16949
|
+
*
|
|
16950
|
+
* Properties to [CTableHead](#ctablehead) component.
|
|
16951
|
+
* @since 4.5.0
|
|
16952
|
+
*/
|
|
16953
|
+
tableHeadProps: {
|
|
16954
|
+
type: Object,
|
|
16955
|
+
default: undefined,
|
|
16956
|
+
required: false,
|
|
16957
|
+
},
|
|
16958
|
+
},
|
|
16959
|
+
setup(props, { slots, attrs }) {
|
|
16960
|
+
const rawColumnNames = computed(() => props.columns
|
|
16961
|
+
? props.columns.map((column) => {
|
|
16962
|
+
if (typeof column === 'object')
|
|
16963
|
+
return column.key;
|
|
16964
|
+
else
|
|
16965
|
+
return column;
|
|
16966
|
+
})
|
|
16967
|
+
: Object.keys(props.items[0] || {}).filter((el) => el.charAt(0) !== '_'));
|
|
16968
|
+
const table = () => h$1('table', {
|
|
16969
|
+
class: [
|
|
16970
|
+
'table',
|
|
16971
|
+
{
|
|
16972
|
+
[`align-${props.align}`]: props.align,
|
|
16973
|
+
[`caption-top`]: props.captionTop || props.caption === 'top',
|
|
16974
|
+
[`border-${props.borderColor}`]: props.borderColor,
|
|
16975
|
+
'table-bordered': props.bordered,
|
|
16976
|
+
'table-borderless': props.borderless,
|
|
16977
|
+
[`table-${props.color}`]: props.color,
|
|
16978
|
+
'table-hover': props.hover,
|
|
16979
|
+
'table-sm': props.small,
|
|
16980
|
+
'table-striped': props.striped,
|
|
16981
|
+
'table-striped-columns': props.stripedColumns,
|
|
16982
|
+
},
|
|
16983
|
+
attrs.class,
|
|
16984
|
+
],
|
|
16985
|
+
}, {
|
|
16986
|
+
default: () => [
|
|
16987
|
+
((props.caption && props.caption !== 'top') || props.captionTop) &&
|
|
16988
|
+
h$1(CTableCaption, {}, {
|
|
16989
|
+
default: () => props.caption || props.captionTop,
|
|
16990
|
+
}),
|
|
16991
|
+
props.columns &&
|
|
16992
|
+
h$1(CTableHead, {
|
|
16993
|
+
...props.tableHeadProps,
|
|
16994
|
+
}, {
|
|
16995
|
+
default: () => h$1(CTableRow, {}, {
|
|
16996
|
+
default: () => [
|
|
16997
|
+
props.columns &&
|
|
16998
|
+
props.columns.map((column) => h$1(CTableHeaderCell, {
|
|
16999
|
+
...(typeof column === 'object' &&
|
|
17000
|
+
column._props && { ...column._props }),
|
|
17001
|
+
...(typeof column === 'object' &&
|
|
17002
|
+
column._style && { style: { ...column._style } }),
|
|
17003
|
+
}, {
|
|
17004
|
+
default: () => label(column),
|
|
17005
|
+
})),
|
|
17006
|
+
],
|
|
17007
|
+
}),
|
|
17008
|
+
}),
|
|
17009
|
+
props.items &&
|
|
17010
|
+
h$1(CTableBody, {}, {
|
|
17011
|
+
default: () => [
|
|
17012
|
+
props.items.map((item) => h$1(CTableRow, {
|
|
17013
|
+
...(item._props && { ...item._props }),
|
|
17014
|
+
}, {
|
|
17015
|
+
default: () => [
|
|
17016
|
+
rawColumnNames.value.map((colName) => item[colName] &&
|
|
17017
|
+
h$1(CTableDataCell, {
|
|
17018
|
+
...(item._cellProps &&
|
|
17019
|
+
item._cellProps['all'] && { ...item._cellProps['all'] }),
|
|
17020
|
+
...(item._cellProps &&
|
|
17021
|
+
item._cellProps[colName] && { ...item._cellProps[colName] }),
|
|
17022
|
+
}, {
|
|
17023
|
+
default: () => item[colName],
|
|
17024
|
+
})),
|
|
17025
|
+
],
|
|
17026
|
+
})),
|
|
17027
|
+
],
|
|
17028
|
+
}),
|
|
17029
|
+
slots.default && slots.default(),
|
|
17030
|
+
props.footer &&
|
|
17031
|
+
h$1(CTableFoot, {
|
|
17032
|
+
...props.tableFootProps,
|
|
17033
|
+
}, {
|
|
17034
|
+
default: () => h$1(CTableRow, {}, {
|
|
17035
|
+
default: () => [
|
|
17036
|
+
props.footer.map((item) => h$1(CTableDataCell, {
|
|
17037
|
+
...(typeof item === 'object' && item._props && { ...item._props }),
|
|
17038
|
+
}, {
|
|
17039
|
+
default: () => (typeof item === 'object' ? item.label : item),
|
|
17040
|
+
})),
|
|
17041
|
+
],
|
|
17042
|
+
}),
|
|
17043
|
+
}),
|
|
17044
|
+
],
|
|
17045
|
+
});
|
|
17046
|
+
return () => [
|
|
17047
|
+
props.responsive
|
|
17048
|
+
? h$1('div', {
|
|
17049
|
+
class: typeof props.responsive === 'boolean'
|
|
17050
|
+
? 'table-responsive'
|
|
17051
|
+
: `table-responsive-${props.responsive}`,
|
|
17052
|
+
}, table())
|
|
17053
|
+
: table(),
|
|
17054
|
+
];
|
|
17055
|
+
},
|
|
17056
|
+
});
|
|
17057
|
+
|
|
16889
17058
|
const CTablePlugin = {
|
|
16890
17059
|
install: (app) => {
|
|
16891
17060
|
app.component(CTable.name, CTable);
|
|
@@ -17048,6 +17217,11 @@ const CSmartTableHead = defineComponent({
|
|
|
17048
17217
|
default: () => [],
|
|
17049
17218
|
required: false,
|
|
17050
17219
|
},
|
|
17220
|
+
items: {
|
|
17221
|
+
type: Array,
|
|
17222
|
+
default: () => [],
|
|
17223
|
+
required: false,
|
|
17224
|
+
},
|
|
17051
17225
|
selectable: Boolean,
|
|
17052
17226
|
selectAll: [Boolean, String],
|
|
17053
17227
|
sorterState: {
|
|
@@ -17056,7 +17230,7 @@ const CSmartTableHead = defineComponent({
|
|
|
17056
17230
|
require: false,
|
|
17057
17231
|
},
|
|
17058
17232
|
},
|
|
17059
|
-
emits: ['filterInput', 'filterChange', 'selectAllChecked', 'sortClick'],
|
|
17233
|
+
emits: ['customFilterChange', 'filterInput', 'filterChange', 'selectAllChecked', 'sortClick'],
|
|
17060
17234
|
setup(props, { slots, emit }) {
|
|
17061
17235
|
const handleSortClick = (key, index) => {
|
|
17062
17236
|
emit('sortClick', key, index);
|
|
@@ -17103,6 +17277,9 @@ const CSmartTableHead = defineComponent({
|
|
|
17103
17277
|
}
|
|
17104
17278
|
return 0;
|
|
17105
17279
|
};
|
|
17280
|
+
const getValues = (items, key) => {
|
|
17281
|
+
return items.map((a) => a[key]);
|
|
17282
|
+
};
|
|
17106
17283
|
const columnSorterIcon = (column) => {
|
|
17107
17284
|
if (getColumnSorterState(key(column)) === 0) {
|
|
17108
17285
|
return h$1('span', { class: 'opacity-25 float-end me-1' }, slots.sortingIcon && slots.sortingIcon());
|
|
@@ -17115,6 +17292,9 @@ const CSmartTableHead = defineComponent({
|
|
|
17115
17292
|
}
|
|
17116
17293
|
return;
|
|
17117
17294
|
};
|
|
17295
|
+
const handleOnCustomFilterChange = (key, value) => {
|
|
17296
|
+
emit('customFilterChange', key, value);
|
|
17297
|
+
};
|
|
17118
17298
|
const handleFilterInput = (key, value) => {
|
|
17119
17299
|
emit('filterInput', key, value);
|
|
17120
17300
|
};
|
|
@@ -17165,17 +17345,20 @@ const CSmartTableHead = defineComponent({
|
|
|
17165
17345
|
? true
|
|
17166
17346
|
: typeof column.filter === 'undefined'
|
|
17167
17347
|
? true
|
|
17168
|
-
: column.filter)
|
|
17169
|
-
|
|
17170
|
-
|
|
17171
|
-
|
|
17172
|
-
|
|
17173
|
-
|
|
17174
|
-
|
|
17175
|
-
|
|
17176
|
-
|
|
17177
|
-
|
|
17178
|
-
|
|
17348
|
+
: column.filter)
|
|
17349
|
+
? typeof column !== 'string' && typeof column.filter === 'function'
|
|
17350
|
+
? column.filter(getValues(props.items, key(column)), (value) => handleOnCustomFilterChange(key(column), value))
|
|
17351
|
+
: h$1(CFormInput, {
|
|
17352
|
+
size: 'sm',
|
|
17353
|
+
onInput: (event) => handleFilterInput(key(column), event.target.value),
|
|
17354
|
+
onChange: (event) => handleFilterChange(key(column), event.target.value),
|
|
17355
|
+
'aria-label': `column name: '${label(column)}' filter input`,
|
|
17356
|
+
...(props.columnFilterValue &&
|
|
17357
|
+
props.columnFilterValue[key(column)] && {
|
|
17358
|
+
value: props.columnFilterValue[key(column)],
|
|
17359
|
+
}),
|
|
17360
|
+
})
|
|
17361
|
+
: '',
|
|
17179
17362
|
})),
|
|
17180
17363
|
],
|
|
17181
17364
|
}),
|
|
@@ -17296,7 +17479,7 @@ const CSmartTableItemsPerPageSelector = defineComponent({
|
|
|
17296
17479
|
h$1('div', {
|
|
17297
17480
|
class: 'col-auto',
|
|
17298
17481
|
}, h$1(CFormSelect, {
|
|
17299
|
-
|
|
17482
|
+
value: props.itemsPerPage,
|
|
17300
17483
|
onChange: handleChange,
|
|
17301
17484
|
}, {
|
|
17302
17485
|
default: () => props.itemsPerPageOptions &&
|
|
@@ -17788,6 +17971,7 @@ const CSmartTable = defineComponent({
|
|
|
17788
17971
|
}
|
|
17789
17972
|
});
|
|
17790
17973
|
// functions
|
|
17974
|
+
const isLazy = (columnFilter) => columnFilter && typeof columnFilter === 'object' && columnFilter.lazy === true;
|
|
17791
17975
|
const isSortable = (i) => {
|
|
17792
17976
|
const isDataColumn = itemsDataColumns.value.includes(rawColumnNames.value[i]);
|
|
17793
17977
|
let column;
|
|
@@ -17859,10 +18043,8 @@ const CSmartTable = defineComponent({
|
|
|
17859
18043
|
});
|
|
17860
18044
|
};
|
|
17861
18045
|
const columnFilterChange = (colName, value, type) => {
|
|
17862
|
-
const
|
|
17863
|
-
|
|
17864
|
-
props.columnFilter.lazy === true;
|
|
17865
|
-
if ((isLazy && type === 'input') || (!isLazy && type === 'change')) {
|
|
18046
|
+
const _isLazy = isLazy(props.columnFilter);
|
|
18047
|
+
if ((_isLazy && type === 'input') || (!_isLazy && type === 'change')) {
|
|
17866
18048
|
return;
|
|
17867
18049
|
}
|
|
17868
18050
|
activePage.value = 1;
|
|
@@ -17870,10 +18052,8 @@ const CSmartTable = defineComponent({
|
|
|
17870
18052
|
emit('columnFilterChange', columnFilterState.value);
|
|
17871
18053
|
};
|
|
17872
18054
|
const tableFilterChange = (value, type) => {
|
|
17873
|
-
const
|
|
17874
|
-
|
|
17875
|
-
props.columnFilter.lazy === true;
|
|
17876
|
-
if ((isLazy && type === 'input') || (!isLazy && type === 'change')) {
|
|
18055
|
+
const _isLazy = isLazy(props.columnFilter);
|
|
18056
|
+
if ((_isLazy && type === 'input') || (!_isLazy && type === 'change')) {
|
|
17877
18057
|
return;
|
|
17878
18058
|
}
|
|
17879
18059
|
activePage.value = 1;
|
|
@@ -17898,7 +18078,7 @@ const CSmartTable = defineComponent({
|
|
|
17898
18078
|
: genCols.value); //! || el
|
|
17899
18079
|
const itemsDataColumns = computed(() => rawColumnNames.value.filter((name) => genCols.value.includes(name)));
|
|
17900
18080
|
// variables
|
|
17901
|
-
const
|
|
18081
|
+
const filteredColumns = computed(() => {
|
|
17902
18082
|
let _items = items.value;
|
|
17903
18083
|
if (props.columnFilter &&
|
|
17904
18084
|
typeof props.columnFilter === 'object' &&
|
|
@@ -17906,6 +18086,10 @@ const CSmartTable = defineComponent({
|
|
|
17906
18086
|
return _items;
|
|
17907
18087
|
}
|
|
17908
18088
|
Object.entries(columnFilterState.value).forEach(([key, value]) => {
|
|
18089
|
+
if (value instanceof Function) {
|
|
18090
|
+
_items = _items.filter((item) => value(item[key]));
|
|
18091
|
+
return;
|
|
18092
|
+
}
|
|
17909
18093
|
const columnFilter = String(value).toLowerCase();
|
|
17910
18094
|
if (columnFilter && itemsDataColumns.value.includes(key)) {
|
|
17911
18095
|
_items = _items.filter((item) => {
|
|
@@ -17914,9 +18098,9 @@ const CSmartTable = defineComponent({
|
|
|
17914
18098
|
}
|
|
17915
18099
|
});
|
|
17916
18100
|
return _items;
|
|
17917
|
-
};
|
|
17918
|
-
const
|
|
17919
|
-
let items =
|
|
18101
|
+
});
|
|
18102
|
+
const filteredTable = computed(() => {
|
|
18103
|
+
let items = filteredColumns.value;
|
|
17920
18104
|
if (!tableFilterState.value ||
|
|
17921
18105
|
(props.tableFilter && typeof props.tableFilter === 'object' && props.tableFilter.external)) {
|
|
17922
18106
|
return items;
|
|
@@ -17936,12 +18120,12 @@ const CSmartTable = defineComponent({
|
|
|
17936
18120
|
(props.columnSorter &&
|
|
17937
18121
|
typeof props.columnSorter === 'object' &&
|
|
17938
18122
|
props.columnSorter.external)) {
|
|
17939
|
-
return
|
|
18123
|
+
return filteredTable.value;
|
|
17940
18124
|
}
|
|
17941
18125
|
//if values in column are to be sorted by numeric value they all have to be type number
|
|
17942
18126
|
// const flip = sorterState.asc ? 1 : -1
|
|
17943
18127
|
const flip = sorterState.state === 'asc' ? 1 : sorterState.state === 'desc' ? -1 : 0;
|
|
17944
|
-
const sorted =
|
|
18128
|
+
const sorted = filteredTable.value.slice().sort((item, item2) => {
|
|
17945
18129
|
const value = item[col];
|
|
17946
18130
|
const value2 = item2[col];
|
|
17947
18131
|
const a = typeof value === 'number' ? value : String(value).toLowerCase();
|
|
@@ -18004,9 +18188,11 @@ const CSmartTable = defineComponent({
|
|
|
18004
18188
|
columnFilterValue: columnFilterState.value,
|
|
18005
18189
|
columns: props.columns ? props.columns : rawColumnNames.value,
|
|
18006
18190
|
columnSorter: props.columnSorter,
|
|
18191
|
+
items: items.value,
|
|
18007
18192
|
selectable: props.selectable,
|
|
18008
18193
|
selectAll: selectedAll.value,
|
|
18009
18194
|
sorterState: sorterState,
|
|
18195
|
+
onCustomFilterChange: (key, value) => columnFilterChange(key, value),
|
|
18010
18196
|
onFilterInput: (key, value) => columnFilterChange(key, value, 'input'),
|
|
18011
18197
|
onFilterChange: (key, value) => columnFilterChange(key, value, 'change'),
|
|
18012
18198
|
onSelectAllChecked: () => handleSelectAllChecked(),
|
|
@@ -18066,8 +18252,6 @@ const CSmartTable = defineComponent({
|
|
|
18066
18252
|
columns: props.columns ? props.columns : rawColumnNames.value,
|
|
18067
18253
|
selectable: props.selectable,
|
|
18068
18254
|
selectAll: selectedAll.value,
|
|
18069
|
-
onFilterInput: (key, value) => columnFilterChange(key, value, 'input'),
|
|
18070
|
-
onFilterChange: (key, value) => columnFilterChange(key, value, 'change'),
|
|
18071
18255
|
onSelectAllChecked: () => handleSelectAllChecked(),
|
|
18072
18256
|
}),
|
|
18073
18257
|
],
|