@coreui/vue-pro 4.7.0 → 4.8.0-next.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.
Files changed (34) hide show
  1. package/dist/components/calendar/utils.d.ts +23 -0
  2. package/dist/components/modal/CModal.d.ts +4 -20
  3. package/dist/components/offcanvas/COffcanvas.d.ts +35 -18
  4. package/dist/components/smart-table/CSmartTable.d.ts +65 -87
  5. package/dist/components/smart-table/CSmartTableBody.d.ts +16 -40
  6. package/dist/components/smart-table/CSmartTableHead.d.ts +17 -58
  7. package/dist/components/smart-table/CSmartTableInterface.d.ts +1 -1
  8. package/dist/components/smart-table/types.d.ts +50 -0
  9. package/dist/components/smart-table/utils.d.ts +17 -0
  10. package/dist/components/table/CTable.d.ts +1 -1
  11. package/dist/components/time-picker/types.d.ts +15 -0
  12. package/dist/components/time-picker/utils.d.ts +23 -0
  13. package/dist/index.es.js +752 -793
  14. package/dist/index.es.js.map +1 -1
  15. package/dist/index.js +752 -793
  16. package/dist/index.js.map +1 -1
  17. package/dist/utils/isObjectInArray.d.ts +2 -0
  18. package/package.json +6 -6
  19. package/src/components/calendar/CCalendar.ts +1 -1
  20. package/src/{utils/calendar.ts → components/calendar/utils.ts} +1 -1
  21. package/src/components/date-range-picker/CDateRangePicker.ts +1 -1
  22. package/src/components/element-cover/CElementCover.ts +14 -14
  23. package/src/components/modal/CModal.ts +10 -10
  24. package/src/components/multi-select/CMultiSelect.ts +0 -10
  25. package/src/components/offcanvas/COffcanvas.ts +50 -28
  26. package/src/components/smart-table/CSmartTable.ts +365 -268
  27. package/src/components/smart-table/CSmartTableBody.ts +126 -137
  28. package/src/components/smart-table/CSmartTableHead.ts +53 -138
  29. package/src/components/smart-table/CSmartTableInterface.ts +1 -1
  30. package/src/components/smart-table/types.ts +61 -0
  31. package/src/components/smart-table/utils.ts +212 -0
  32. package/src/components/time-picker/CTimePicker.ts +49 -27
  33. package/src/components/time-picker/types.ts +15 -0
  34. package/src/{utils/time.ts → components/time-picker/utils.ts} +43 -2
package/dist/index.es.js CHANGED
@@ -8715,38 +8715,34 @@ const getAmPm = (date, locale) => {
8715
8715
  }
8716
8716
  return date.getHours() >= 12 ? 'pm' : 'am';
8717
8717
  };
8718
- const getListOfHours = (locale, ampm = 'auto') => Array.from({ length: (ampm === 'auto' && isAmPm(locale)) || ampm === true ? 12 : 24 }, (_, i) => {
8719
- return {
8720
- value: (ampm === 'auto' && isAmPm(locale)) || ampm === true ? i + 1 : i,
8721
- label: ((ampm === 'auto' && isAmPm(locale)) || ampm === true ? i + 1 : i).toLocaleString(locale),
8722
- };
8723
- });
8724
- const getListOfMinutes = (locale, valueAsString = false) => Array.from({ length: 60 }, (_, i) => {
8725
- const d = new Date();
8726
- d.setMinutes(i);
8727
- return {
8728
- value: valueAsString ? i.toString() : i,
8729
- label: d
8730
- .toLocaleTimeString(locale, {
8731
- minute: '2-digit',
8732
- second: '2-digit',
8733
- })
8734
- .split(/[^A-Za-z0-9]/)[0],
8735
- };
8736
- });
8737
- const getListOfSeconds = (locale, valueAsString = false) => Array.from({ length: 60 }, (_, i) => {
8738
- const d = new Date();
8739
- d.setSeconds(i);
8718
+ const getLocalizedTimePartials = (locale, ampm = 'auto') => {
8719
+ const date = new Date();
8720
+ const hour12 = ['am', 'AM', 'pm', 'PM'].some((el) => date.toLocaleString(locale).includes(el));
8721
+ const listOfHours = Array.from({ length: (ampm === 'auto' && hour12) || ampm === true ? 12 : 24 }, (_, i) => {
8722
+ return {
8723
+ value: (ampm === 'auto' && hour12) || ampm === true ? i + 1 : i,
8724
+ label: ((ampm === 'auto' && hour12) || ampm === true ? i + 1 : i).toLocaleString(locale),
8725
+ };
8726
+ });
8727
+ const listOfMinutesSeconds = Array.from({ length: 60 }, (_, i) => {
8728
+ date.setMinutes(i);
8729
+ return {
8730
+ value: i,
8731
+ label: date
8732
+ .toLocaleTimeString(locale, {
8733
+ minute: '2-digit',
8734
+ second: '2-digit',
8735
+ })
8736
+ .split(/[^A-Za-z0-9\u06F0-\u06F90-9]/)[0],
8737
+ };
8738
+ });
8740
8739
  return {
8741
- value: valueAsString ? i.toString() : i,
8742
- label: d
8743
- .toLocaleTimeString(locale, {
8744
- minute: '2-digit',
8745
- second: '2-digit',
8746
- })
8747
- .split(/[^A-Za-z0-9]/)[1],
8740
+ listOfHours,
8741
+ listOfMinutes: listOfMinutesSeconds,
8742
+ listOfSeconds: listOfMinutesSeconds,
8743
+ hour12,
8748
8744
  };
8749
- });
8745
+ };
8750
8746
  const getSelectedHour = (date, locale, ampm = 'auto') => date
8751
8747
  ? (ampm === 'auto' && isAmPm(locale)) || ampm === true
8752
8748
  ? convert24hTo12h(date.getHours())
@@ -9020,14 +9016,21 @@ const CTimePicker = defineComponent({
9020
9016
  'update:time',
9021
9017
  ],
9022
9018
  setup(props, { emit, attrs, slots }) {
9023
- const visible = ref(props.visible);
9024
9019
  const date = ref(convertTimeToDate(props.time));
9025
- const initialDate = ref(null);
9026
9020
  const ampm = ref(date.value ? getAmPm(new Date(date.value), props.locale) : 'am');
9021
+ const initialDate = ref(null);
9022
+ const visible = ref(props.visible);
9023
+ const localizedTimePartials = ref({
9024
+ listOfHours: [],
9025
+ listOfMinutes: [],
9026
+ listOfSeconds: [],
9027
+ hour12: false,
9028
+ });
9027
9029
  watch(() => props.time, () => {
9028
9030
  date.value = convertTimeToDate(props.time);
9029
9031
  });
9030
9032
  watch(date, () => {
9033
+ localizedTimePartials.value = getLocalizedTimePartials(props.locale, props.ampm);
9031
9034
  if (date.value) {
9032
9035
  ampm.value = getAmPm(new Date(date.value), props.locale);
9033
9036
  }
@@ -9049,7 +9052,7 @@ const CTimePicker = defineComponent({
9049
9052
  }
9050
9053
  }
9051
9054
  if (set === 'hours') {
9052
- if ((props.ampm === 'auto' && isAmPm(props.locale)) || props.ampm === true) {
9055
+ if (localizedTimePartials.value && localizedTimePartials.value.hour12) {
9053
9056
  _date.setHours(convert12hTo24h(ampm.value, parseInt(value)));
9054
9057
  }
9055
9058
  else {
@@ -9079,8 +9082,7 @@ const CTimePicker = defineComponent({
9079
9082
  readonly: props.inputReadOnly,
9080
9083
  value: date.value
9081
9084
  ? date.value.toLocaleTimeString(props.locale, {
9082
- hour12: (props.ampm === 'auto' && isAmPm(props.locale)) ||
9083
- (props.ampm === 'boolean' && props.ampm),
9085
+ hour12: localizedTimePartials.value && localizedTimePartials.value.hour12,
9084
9086
  ...(!props.seconds && { timeStyle: 'short' }),
9085
9087
  })
9086
9088
  : '',
@@ -9107,33 +9109,45 @@ const CTimePicker = defineComponent({
9107
9109
  h$1('span', { class: 'time-picker-inline-icon' }),
9108
9110
  h$1(CFormSelect, {
9109
9111
  disabled: props.disabled,
9110
- options: getListOfHours(props.locale).map((option) => {
9111
- return {
9112
- value: option.value.toString(),
9113
- label: option.label,
9114
- };
9115
- }),
9112
+ options: localizedTimePartials.value &&
9113
+ localizedTimePartials.value.listOfHours?.map((option) => {
9114
+ return {
9115
+ value: option.value.toString(),
9116
+ label: option.label,
9117
+ };
9118
+ }),
9116
9119
  onChange: (event) => handleTimeChange('hours', event.target.value),
9117
9120
  ...(date.value && { value: getSelectedHour(date.value, props.locale) }),
9118
9121
  }),
9119
9122
  ':',
9120
- // @ts-expect-error the getListOfMinutes function returns corect type
9121
9123
  h$1(CFormSelect, {
9122
9124
  disabled: props.disabled,
9123
- options: getListOfMinutes(props.locale, true),
9125
+ options: localizedTimePartials.value &&
9126
+ localizedTimePartials.value.listOfMinutes.map((option) => {
9127
+ return {
9128
+ value: option.value.toString(),
9129
+ label: option.label,
9130
+ };
9131
+ }),
9124
9132
  onChange: (event) => handleTimeChange('minutes', event.target.value),
9125
9133
  ...(date.value && { value: getSelectedMinutes(date.value) }),
9126
9134
  }),
9127
9135
  props.seconds && ':',
9128
9136
  props.seconds &&
9129
- // @ts-expect-error the getListOfMinutes function returns corect type
9130
9137
  h$1(CFormSelect, {
9131
9138
  disabled: props.disabled,
9132
- options: getListOfSeconds(props.locale, true),
9139
+ options: localizedTimePartials.value &&
9140
+ localizedTimePartials.value.listOfSeconds.map((option) => {
9141
+ return {
9142
+ value: option.value.toString(),
9143
+ label: option.label,
9144
+ };
9145
+ }),
9133
9146
  onChange: (event) => handleTimeChange('seconds', event.target.value),
9134
9147
  ...(date.value && { value: getSelectedSeconds(date.value) }),
9135
9148
  }),
9136
- isAmPm(props.locale) &&
9149
+ localizedTimePartials.value &&
9150
+ localizedTimePartials.value.hour12 &&
9137
9151
  h$1(CFormSelect, {
9138
9152
  disabled: props.disabled,
9139
9153
  options: [
@@ -9146,22 +9160,23 @@ const CTimePicker = defineComponent({
9146
9160
  ];
9147
9161
  const TimePickerRoll = () => [
9148
9162
  h$1(CTimePickerRollCol, {
9149
- elements: getListOfHours(props.locale, props.ampm),
9163
+ elements: localizedTimePartials.value && localizedTimePartials.value.listOfHours,
9150
9164
  onClick: (index) => handleTimeChange('hours', index.toString()),
9151
9165
  selected: getSelectedHour(date.value, props.locale, props.ampm),
9152
9166
  }),
9153
9167
  h$1(CTimePickerRollCol, {
9154
- elements: getListOfMinutes(props.locale),
9168
+ elements: localizedTimePartials.value && localizedTimePartials.value.listOfMinutes,
9155
9169
  onClick: (index) => handleTimeChange('minutes', index.toString()),
9156
9170
  selected: getSelectedMinutes(date.value),
9157
9171
  }),
9158
9172
  props.seconds &&
9159
9173
  h$1(CTimePickerRollCol, {
9160
- elements: getListOfSeconds(props.locale),
9174
+ elements: localizedTimePartials.value && localizedTimePartials.value.listOfSeconds,
9161
9175
  onClick: (index) => handleTimeChange('seconds', index.toString()),
9162
9176
  selected: getSelectedSeconds(date.value),
9163
9177
  }),
9164
- ((props.ampm === 'auto' && isAmPm(props.locale)) || props.ampm === true) &&
9178
+ localizedTimePartials.value &&
9179
+ localizedTimePartials.value.hour12 &&
9165
9180
  h$1(CTimePickerRollCol, {
9166
9181
  elements: [
9167
9182
  { value: 'am', label: 'AM' },
@@ -10484,16 +10499,16 @@ const CElementCover = defineComponent({
10484
10499
  return () => h$1('div', {
10485
10500
  style: { ...coverStyles, ...customBoundaries.value },
10486
10501
  ref: elementCoverRef,
10502
+ }, h$1('div', {
10503
+ style: {
10504
+ position: 'absolute',
10505
+ top: '50%',
10506
+ left: '50%',
10507
+ transform: 'translateX(-50%) translateY(-50%)',
10508
+ },
10487
10509
  }, slots.default
10488
10510
  ? slots.default()
10489
- : h$1('div', {
10490
- style: {
10491
- position: 'absolute',
10492
- top: '50%',
10493
- left: '50%',
10494
- transform: 'translateX(-50%) translateY(-50%)',
10495
- },
10496
- }, h$1(CSpinner, {
10511
+ : h$1(CSpinner, {
10497
10512
  variant: 'grow',
10498
10513
  color: 'primary',
10499
10514
  })));
@@ -11183,7 +11198,6 @@ const CModal = defineComponent({
11183
11198
  */
11184
11199
  alignment: {
11185
11200
  default: 'top',
11186
- required: false,
11187
11201
  validator: (value) => {
11188
11202
  return ['top', 'center'].includes(value);
11189
11203
  },
@@ -11191,12 +11205,20 @@ const CModal = defineComponent({
11191
11205
  /**
11192
11206
  * Apply a backdrop on body while offcanvas is open.
11193
11207
  *
11194
- * @values 'static'
11208
+ * @values boolean | 'static'
11195
11209
  */
11196
11210
  backdrop: {
11197
11211
  type: [Boolean, String],
11198
11212
  default: true,
11199
- require: false,
11213
+ validator: (value) => {
11214
+ if (typeof value == 'string') {
11215
+ return ['static'].includes(value);
11216
+ }
11217
+ if (typeof value == 'boolean') {
11218
+ return true;
11219
+ }
11220
+ return false;
11221
+ },
11200
11222
  },
11201
11223
  /**
11202
11224
  * A string of all className you want applied to the modal content component.
@@ -11204,7 +11226,6 @@ const CModal = defineComponent({
11204
11226
  contentClassName: {
11205
11227
  type: String,
11206
11228
  default: undefined,
11207
- required: false,
11208
11229
  },
11209
11230
  /**
11210
11231
  * Set modal to covers the entire user viewport
@@ -11214,7 +11235,6 @@ const CModal = defineComponent({
11214
11235
  fullscreen: {
11215
11236
  type: [Boolean, String],
11216
11237
  default: undefined,
11217
- required: false,
11218
11238
  validator: (value) => {
11219
11239
  if (typeof value == 'string') {
11220
11240
  return ['sm', 'md', 'lg', 'xl', 'xxl'].includes(value);
@@ -11231,14 +11251,12 @@ const CModal = defineComponent({
11231
11251
  keyboard: {
11232
11252
  type: Boolean,
11233
11253
  default: true,
11234
- required: false,
11235
11254
  },
11236
11255
  /**
11237
11256
  * Create a scrollable modal that allows scrolling the modal body.
11238
11257
  */
11239
11258
  scrollable: {
11240
11259
  type: Boolean,
11241
- required: false,
11242
11260
  },
11243
11261
  /**
11244
11262
  * Size the component small, large, or extra large.
@@ -11248,7 +11266,6 @@ const CModal = defineComponent({
11248
11266
  size: {
11249
11267
  type: String,
11250
11268
  default: undefined,
11251
- required: false,
11252
11269
  validator: (value) => {
11253
11270
  return ['sm', 'lg', 'xl'].includes(value);
11254
11271
  },
@@ -11259,7 +11276,6 @@ const CModal = defineComponent({
11259
11276
  transition: {
11260
11277
  type: Boolean,
11261
11278
  default: true,
11262
- required: false,
11263
11279
  },
11264
11280
  /**
11265
11281
  * By default the component is unmounted after close animation, if you want to keep the component mounted set this property to false.
@@ -11267,7 +11283,6 @@ const CModal = defineComponent({
11267
11283
  unmountOnClose: {
11268
11284
  type: Boolean,
11269
11285
  default: true,
11270
- required: false,
11271
11286
  },
11272
11287
  /**
11273
11288
  * Toggle the visibility of alert component.
@@ -12018,13 +12033,6 @@ const CMultiSelect = defineComponent({
12018
12033
  }, [])
12019
12034
  : options.value;
12020
12035
  };
12021
- // watch(
12022
- // () => props.options,
12023
- // (newValue, oldValue) => {
12024
- // console.log(props.options)
12025
- // if (JSON.stringify(newValue) !== JSON.stringify(oldValue)) options.value = newValue
12026
- // },
12027
- // )
12028
12036
  const handleSearchChange = (event) => {
12029
12037
  const target = event.target;
12030
12038
  search.value = target.value.toLowerCase();
@@ -12609,11 +12617,21 @@ const COffcanvas = defineComponent({
12609
12617
  props: {
12610
12618
  /**
12611
12619
  * Apply a backdrop on body while offcanvas is open.
12620
+ *
12621
+ * @values boolean | 'static'
12612
12622
  */
12613
12623
  backdrop: {
12614
- type: Boolean,
12624
+ type: [Boolean, String],
12615
12625
  default: true,
12616
- require: false,
12626
+ validator: (value) => {
12627
+ if (typeof value === 'string') {
12628
+ return ['static'].includes(value);
12629
+ }
12630
+ if (typeof value === 'boolean') {
12631
+ return true;
12632
+ }
12633
+ return false;
12634
+ },
12617
12635
  },
12618
12636
  /**
12619
12637
  * Closes the offcanvas when escape key is pressed.
@@ -12621,7 +12639,6 @@ const COffcanvas = defineComponent({
12621
12639
  keyboard: {
12622
12640
  type: Boolean,
12623
12641
  default: true,
12624
- require: false,
12625
12642
  },
12626
12643
  /**
12627
12644
  * Components placement, there’s no default placement.
@@ -12636,21 +12653,36 @@ const COffcanvas = defineComponent({
12636
12653
  return ['start', 'end', 'top', 'bottom'].includes(value);
12637
12654
  },
12638
12655
  },
12656
+ /**
12657
+ * Responsive offcanvas property hide content outside the viewport from a specified breakpoint and down.
12658
+ *
12659
+ * @values boolean | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'
12660
+ * @since 4.7.0
12661
+ */
12662
+ responsive: {
12663
+ type: [Boolean, String],
12664
+ default: true,
12665
+ validator: (value) => {
12666
+ if (typeof value === 'string') {
12667
+ return ['sm', 'md', 'lg', 'xl', 'xxl'].includes(value);
12668
+ }
12669
+ if (typeof value === 'boolean') {
12670
+ return true;
12671
+ }
12672
+ return false;
12673
+ },
12674
+ },
12639
12675
  /**
12640
12676
  * Allow body scrolling while offcanvas is open
12641
12677
  */
12642
12678
  scroll: {
12643
12679
  type: Boolean,
12644
12680
  default: false,
12645
- required: false,
12646
12681
  },
12647
12682
  /**
12648
12683
  * Toggle the visibility of offcanvas component.
12649
12684
  */
12650
- visible: {
12651
- type: Boolean,
12652
- require: false,
12653
- },
12685
+ visible: Boolean,
12654
12686
  },
12655
12687
  emits: [
12656
12688
  /**
@@ -12685,40 +12717,31 @@ const COffcanvas = defineComponent({
12685
12717
  emit('show');
12686
12718
  executeAfterTransition(() => done(), el);
12687
12719
  setTimeout(() => {
12688
- el.style.visibility = 'visible';
12689
12720
  el.classList.add('show');
12690
12721
  }, 1);
12691
12722
  };
12692
12723
  const handleAfterEnter = () => {
12693
- window.addEventListener('mousedown', handleMouseDown);
12694
- window.addEventListener('keyup', handleKeyUp);
12724
+ offcanvasRef.value.focus();
12695
12725
  };
12696
12726
  const handleLeave = (el, done) => {
12697
12727
  executeAfterTransition(() => done(), el);
12698
- window.removeEventListener('mousedown', handleMouseDown);
12699
- window.removeEventListener('keyup', handleKeyUp);
12700
- el.classList.remove('show');
12728
+ el.classList.add('hiding');
12701
12729
  };
12702
12730
  const handleAfterLeave = (el) => {
12703
- el.style.visibility = 'hidden';
12731
+ el.classList.remove('show', 'hiding');
12704
12732
  };
12705
12733
  const handleDismiss = () => {
12706
12734
  visible.value = false;
12707
12735
  emit('hide');
12708
12736
  };
12709
- const handleKeyUp = (event) => {
12710
- if (offcanvasRef.value && !offcanvasRef.value.contains(event.target)) {
12711
- if (event.key === 'Escape' && props.keyboard && props.backdrop) {
12712
- return handleDismiss();
12713
- }
12737
+ const handleBackdropDismiss = () => {
12738
+ if (props.backdrop !== 'static') {
12739
+ handleDismiss();
12714
12740
  }
12715
12741
  };
12716
- const handleMouseDown = (event) => {
12717
- window.addEventListener('mouseup', () => handleMouseUp(event), { once: true });
12718
- };
12719
- const handleMouseUp = (event) => {
12720
- if (offcanvasRef.value && !offcanvasRef.value.contains(event.target)) {
12721
- props.backdrop && handleDismiss();
12742
+ const handleKeyDown = (event) => {
12743
+ if (event.key === 'Escape' && props.keyboard) {
12744
+ handleDismiss();
12722
12745
  }
12723
12746
  };
12724
12747
  return () => [
@@ -12730,17 +12753,20 @@ const COffcanvas = defineComponent({
12730
12753
  onAfterLeave: (el) => handleAfterLeave(el),
12731
12754
  }, () => withDirectives(h$1('div', {
12732
12755
  class: [
12733
- 'offcanvas',
12734
12756
  {
12757
+ [`offcanvas${typeof props.responsive !== 'boolean' ? '-' + props.responsive : ''}`]: props.responsive,
12735
12758
  [`offcanvas-${props.placement}`]: props.placement,
12736
12759
  },
12737
12760
  ],
12761
+ onKeydown: (event) => handleKeyDown(event),
12738
12762
  ref: offcanvasRef,
12739
12763
  role: 'dialog',
12764
+ tabindex: -1,
12740
12765
  }, slots.default && slots.default()), [[vVisible, props.visible]])),
12741
12766
  props.backdrop &&
12742
12767
  h$1(CBackdrop, {
12743
12768
  class: 'offcanvas-backdrop',
12769
+ onClick: handleBackdropDismiss,
12744
12770
  visible: visible.value,
12745
12771
  }),
12746
12772
  ];
@@ -13830,6 +13856,140 @@ const CSmartPaginationPlugin = {
13830
13856
  },
13831
13857
  };
13832
13858
 
13859
+ var cilArrowBottom = ["512 512", "<polygon fill='var(--ci-primary-color, currentColor)' points='367.997 338.75 271.999 434.747 271.999 17.503 239.999 17.503 239.999 434.745 144.003 338.75 121.376 361.377 256 496 390.624 361.377 367.997 338.75' class='ci-primary'/>"];
13860
+
13861
+ var cilArrowTop = ["512 512", "<polygon fill='var(--ci-primary-color, currentColor)' points='390.624 150.625 256 16 121.376 150.625 144.004 173.252 240.001 77.254 240.001 495.236 272.001 495.236 272.001 77.257 367.996 173.252 390.624 150.625' class='ci-primary'/>"];
13862
+
13863
+ var cilFilterX = ["512 512", "<polygon fill='var(--ci-primary-color, currentColor)' points='40 16 40 53.828 109.024 136 150.815 136 76.896 48 459.51 48 304 242.388 304 401.373 241.373 464 240 464 240 368 208 368 208 496 254.627 496 336 414.627 336 253.612 496 53.612 496 16 40 16' class='ci-primary'/><polygon fill='var(--ci-primary-color, currentColor)' points='166.403 248.225 226.864 187.763 204.237 165.135 143.775 225.597 83.313 165.135 60.687 187.763 121.148 248.225 60.687 308.687 83.313 331.314 143.775 270.852 204.237 331.314 226.864 308.687 166.403 248.225' class='ci-primary'/>"];
13864
+
13865
+ var cilSwapVertical = ["512 512", "<polygon fill='var(--ci-primary-color, currentColor)' points='384 433.373 384 160 352 160 352 434.51 282.177 364.687 259.55 387.313 367.432 495.196 475.313 387.313 452.687 364.687 384 433.373' class='ci-primary'/><polygon fill='var(--ci-primary-color, currentColor)' points='159.432 17.372 51.55 125.255 74.177 147.882 144 78.059 144 352 176 352 176 79.195 244.687 147.882 267.313 125.255 159.432 17.372' class='ci-primary'/>"];
13866
+
13867
+ const CIcon = defineComponent({
13868
+ name: 'CIcon',
13869
+ props: {
13870
+ /**
13871
+ * Use `:icon="..."` instead of
13872
+ *
13873
+ * @deprecated since version 3.0
13874
+ */
13875
+ content: {
13876
+ type: [String, Array],
13877
+ default: undefined,
13878
+ required: false,
13879
+ },
13880
+ /**
13881
+ * Use for replacing default CIcon component classes. Prop is overriding the 'size' prop.
13882
+ */
13883
+ customClassName: {
13884
+ type: [String, Array, Object],
13885
+ default: undefined,
13886
+ required: false,
13887
+ },
13888
+ /**
13889
+ * Name of the icon placed in React object or SVG content.
13890
+ */
13891
+ icon: {
13892
+ type: [String, Array],
13893
+ default: undefined,
13894
+ required: false,
13895
+ },
13896
+ /**
13897
+ * Use `icon="..."` instead of
13898
+ *
13899
+ * @deprecated since version 3.0
13900
+ */
13901
+ name: {
13902
+ type: String,
13903
+ default: undefined,
13904
+ required: false,
13905
+ },
13906
+ /**
13907
+ * Size of the icon. Available sizes: 'sm', 'lg', 'xl', 'xxl', '3xl...9xl', 'custom', 'custom-size'.
13908
+ */
13909
+ size: {
13910
+ type: String,
13911
+ default: undefined,
13912
+ required: false,
13913
+ validator: (value) => {
13914
+ return [
13915
+ 'custom',
13916
+ 'custom-size',
13917
+ 'sm',
13918
+ 'lg',
13919
+ 'xl',
13920
+ 'xxl',
13921
+ '3xl',
13922
+ '4xl',
13923
+ '5xl',
13924
+ '6xl',
13925
+ '7xl',
13926
+ '8xl',
13927
+ '9xl',
13928
+ ].includes(value);
13929
+ },
13930
+ },
13931
+ /**
13932
+ * Title tag content.
13933
+ */
13934
+ title: {
13935
+ type: String,
13936
+ default: undefined,
13937
+ required: false,
13938
+ },
13939
+ /**
13940
+ * If defined component will be rendered using 'use' tag.
13941
+ */
13942
+ use: {
13943
+ type: String,
13944
+ default: undefined,
13945
+ required: false,
13946
+ },
13947
+ },
13948
+ setup(props, { attrs }) {
13949
+ const icons = inject('icons');
13950
+ const _icon = props.icon || props.content || props.name;
13951
+ const toCamelCase = (str) => {
13952
+ return str
13953
+ .replace(/([-_][a-z0-9])/gi, ($1) => {
13954
+ return $1.toUpperCase();
13955
+ })
13956
+ .replace(/-/gi, '');
13957
+ };
13958
+ const iconName = computed(() => _icon && typeof _icon === 'string' ? (_icon.includes('-') ? toCamelCase(_icon) : _icon) : '');
13959
+ const titleCode = props.title ? `<title>${props.title}</title>` : 'undefined';
13960
+ const code = computed(() => Array.isArray(_icon)
13961
+ ? _icon
13962
+ : typeof _icon === 'string' && iconName.value && icons[iconName.value]
13963
+ ? icons[iconName.value]
13964
+ : 'undefined');
13965
+ const iconCode = Array.isArray(code.value) ? code.value[1] || code.value[0] : code.value;
13966
+ const scale = Array.isArray(code.value) && code.value.length > 1 ? code.value[0] : '64 64';
13967
+ const viewBox = attrs.viewBox || `0 0 ${scale}`;
13968
+ const size = () => {
13969
+ const addCustom = !props.size && (attrs.width || attrs.height);
13970
+ return props.size === 'custom' || addCustom ? 'custom-size' : props.size;
13971
+ };
13972
+ const classNames = (() => {
13973
+ return [props.customClassName || ['icon', { [`icon-${size()}`]: size() }], attrs.class];
13974
+ })();
13975
+ return () => props.use
13976
+ ? h$1('svg', {
13977
+ ...attrs,
13978
+ xmlns: 'http://www.w3.org/2000/svg',
13979
+ class: classNames,
13980
+ role: 'img',
13981
+ }, h$1('use', { href: props.use }))
13982
+ : h$1('svg', {
13983
+ ...attrs,
13984
+ xmlns: 'http://www.w3.org/2000/svg',
13985
+ class: classNames,
13986
+ viewBox: viewBox,
13987
+ innerHTML: `${titleCode}${iconCode}`,
13988
+ role: 'img',
13989
+ });
13990
+ },
13991
+ });
13992
+
13833
13993
  const CTableBody = defineComponent({
13834
13994
  name: 'CTableBody',
13835
13995
  props: {
@@ -14015,7 +14175,7 @@ const CTableRow = defineComponent({
14015
14175
  },
14016
14176
  });
14017
14177
 
14018
- const pretifyName = (name) => {
14178
+ const pretifyName$1 = (name) => {
14019
14179
  return name
14020
14180
  .replace(/[-_.]/g, ' ')
14021
14181
  .replace(/ +/g, ' ')
@@ -14027,8 +14187,8 @@ const pretifyName = (name) => {
14027
14187
  const label = (column) => typeof column === 'object'
14028
14188
  ? column.label !== undefined
14029
14189
  ? column.label
14030
- : pretifyName(column.key)
14031
- : pretifyName(column);
14190
+ : pretifyName$1(column.key)
14191
+ : pretifyName$1(column);
14032
14192
  const CTable = defineComponent({
14033
14193
  name: 'CTable',
14034
14194
  props: {
@@ -14318,120 +14478,244 @@ const CTablePlugin = {
14318
14478
  },
14319
14479
  };
14320
14480
 
14321
- const CSmartTableBody = defineComponent({
14322
- name: 'CSmartTableBody',
14323
- props: {
14324
- clickableRows: {
14325
- type: Boolean,
14326
- require: false,
14327
- },
14328
- currentItems: {
14329
- type: Array,
14330
- default: () => [],
14331
- required: false,
14332
- },
14333
- firstItemOnActivePageIndex: {
14334
- type: Number,
14335
- require: true,
14336
- default: 0,
14337
- },
14338
- noItemLabel: {
14339
- type: String,
14340
- default: undefined,
14341
- require: false,
14342
- },
14343
- rawColumnNames: {
14344
- type: Array,
14345
- default: () => [],
14346
- require: true,
14347
- },
14348
- scopedSlots: {
14349
- type: Object,
14350
- default: undefined,
14351
- require: false,
14481
+ const filterColumns = (items, columnFilter, columnFilterState, itemsDataColumns) => {
14482
+ if (columnFilter && typeof columnFilter === 'object' && columnFilter.external) {
14483
+ return items;
14484
+ }
14485
+ Object.entries(columnFilterState).forEach(([key, value]) => {
14486
+ if (value instanceof Function) {
14487
+ items = items.filter((item) => value(item[key]));
14488
+ return;
14489
+ }
14490
+ const columnFilter = String(value).toLowerCase();
14491
+ if (columnFilter && itemsDataColumns.includes(key)) {
14492
+ items = items.filter((item) => {
14493
+ return String(item[key]).toLowerCase().includes(columnFilter);
14494
+ });
14495
+ }
14496
+ });
14497
+ return items;
14498
+ };
14499
+ const filterTable = (items, tableFilter, tableFilterState, itemsDataColumns) => {
14500
+ if (!tableFilterState ||
14501
+ (tableFilter && typeof tableFilter === 'object' && tableFilter.external)) {
14502
+ return items;
14503
+ }
14504
+ const filter = tableFilterState.toLowerCase();
14505
+ const valueContainFilter = (val) => String(val).toLowerCase().includes(filter);
14506
+ items = items.filter((item) => {
14507
+ return !!itemsDataColumns.find((key) => valueContainFilter(item[key]));
14508
+ });
14509
+ return items;
14510
+ };
14511
+ const getClickedColumnName = (target, columnNames) => {
14512
+ const closest = target.closest('tr');
14513
+ const children = closest ? Array.from(closest.children) : [];
14514
+ const clickedCell = children.filter((child) => child.contains(target))[0];
14515
+ return columnNames[children.indexOf(clickedCell)];
14516
+ };
14517
+ const getColumnKey = (column) => typeof column === 'object' ? column.key : column;
14518
+ const getColumnLabel = (column) => typeof column === 'object'
14519
+ ? column.label !== undefined
14520
+ ? column.label
14521
+ : pretifyName(column.key)
14522
+ : pretifyName(column);
14523
+ const getColumnNames = (columns, items) => columns
14524
+ ? columns.map((column) => {
14525
+ if (typeof column === 'object')
14526
+ return column.key;
14527
+ else
14528
+ return column;
14529
+ })
14530
+ : getColumnNamesFromItems(items);
14531
+ const getColumnNamesFromItems = (items) => Object.keys(items[0] || {}).filter((el) => el.charAt(0) !== '_');
14532
+ const getColumnSorterState = (key, sorterState) => {
14533
+ if (sorterState && sorterState.column === key) {
14534
+ if (sorterState.state) {
14535
+ return sorterState.state;
14536
+ }
14537
+ return 0;
14538
+ }
14539
+ return 0;
14540
+ };
14541
+ const getColumnValues = (items, key) => {
14542
+ return items.map((item) => item[key]);
14543
+ };
14544
+ const getTableDataCellProps = (item, colName) => {
14545
+ const props = item._cellProps && {
14546
+ ...(item._cellProps['all'] && { ...item._cellProps['all'] }),
14547
+ ...(item._cellProps[colName] && { ...item._cellProps[colName] }),
14548
+ };
14549
+ return props;
14550
+ };
14551
+ const getTableHeaderCellProps = (column) => {
14552
+ if (typeof column === 'object' && column._props) {
14553
+ return column._props;
14554
+ }
14555
+ return {};
14556
+ };
14557
+ const getTableHeaderCellStyles = (column, columnSorter) => {
14558
+ const style = {};
14559
+ if (columnSorter &&
14560
+ (typeof column !== 'object' ||
14561
+ (typeof column === 'object' && (typeof column.sorter === 'undefined' || column.sorter)))) {
14562
+ style['cursor'] = 'pointer';
14563
+ }
14564
+ if (typeof column === 'object' && column._style) {
14565
+ return { ...style, ...column._style };
14566
+ }
14567
+ return style;
14568
+ };
14569
+ const isObjectInArray = (array, item, ignore = []) => array.some((_item) => {
14570
+ let result = true;
14571
+ for (const key in item) {
14572
+ if (!ignore.includes(key) && item[key] !== _item[key]) {
14573
+ result = false;
14574
+ break;
14575
+ }
14576
+ }
14577
+ return result;
14578
+ });
14579
+ const isSortable = (i, columns, columnSorter, itemsDataColumns, columnNames) => {
14580
+ const isDataColumn = itemsDataColumns.includes(columnNames[i]);
14581
+ let column;
14582
+ if (columns)
14583
+ column = columns[i];
14584
+ return (columnSorter &&
14585
+ (!columns ||
14586
+ typeof column !== 'object' ||
14587
+ (typeof column === 'object' && (typeof column.sorter === 'undefined' || column.sorter))) &&
14588
+ isDataColumn);
14589
+ };
14590
+ const pretifyName = (name) => {
14591
+ return name
14592
+ .replace(/[-_.]/g, ' ')
14593
+ .replace(/ +/g, ' ')
14594
+ .replace(/([a-z0-9])([A-Z])/g, '$1 $2')
14595
+ .split(' ')
14596
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
14597
+ .join(' ');
14598
+ };
14599
+ const sortItems = (columnSorter, items, itemsDataColumns, sorterState) => {
14600
+ const column = sorterState.column;
14601
+ if (!column ||
14602
+ !itemsDataColumns.includes(column) ||
14603
+ (columnSorter && typeof columnSorter === 'object' && columnSorter.external)) {
14604
+ return items;
14605
+ }
14606
+ const flip = sorterState.state === 'asc' ? 1 : sorterState.state === 'desc' ? -1 : 0;
14607
+ const sorted = items.slice().sort((item, item2) => {
14608
+ const value = item[column];
14609
+ const value2 = item2[column];
14610
+ const a = typeof value === 'number' ? value : String(value).toLowerCase();
14611
+ const b = typeof value2 === 'number' ? value2 : String(value2).toLowerCase();
14612
+ return a > b ? 1 * flip : b > a ? -1 * flip : 0;
14613
+ });
14614
+ return sorted;
14615
+ };
14616
+
14617
+ const CSmartTableBody = defineComponent({
14618
+ name: 'CSmartTableBody',
14619
+ props: {
14620
+ clickableRows: Boolean,
14621
+ columnNames: {
14622
+ type: Array,
14623
+ default: () => [],
14624
+ require: true,
14625
+ },
14626
+ currentItems: {
14627
+ type: Array,
14628
+ default: () => [],
14352
14629
  },
14630
+ firstItemOnActivePageIndex: {
14631
+ type: Number,
14632
+ require: true,
14633
+ default: 0,
14634
+ },
14635
+ noItemsLabel: String,
14636
+ scopedSlots: Object,
14353
14637
  selectable: Boolean,
14638
+ selected: Array,
14354
14639
  },
14355
14640
  emits: ['rowChecked', 'rowClick'],
14356
14641
  setup(props, { emit }) {
14357
- const handleRowClick = (item, index, columnName, event) => {
14358
- emit('rowClick', item, index, columnName, event);
14359
- };
14360
- const handleRowChecked = (id, value) => {
14361
- emit('rowChecked', id, value);
14362
- };
14363
- const tableDataCellProps = (item, colName) => {
14364
- const props = item._cellProps && {
14365
- ...(item._cellProps['all'] && { ...item._cellProps['all'] }),
14366
- ...(item._cellProps[colName] && { ...item._cellProps[colName] }),
14367
- };
14368
- return props;
14369
- };
14370
- const getColumnName = (event) => {
14371
- const target = event.target;
14372
- const closest = target.closest('tr');
14373
- const children = closest ? Array.from(closest.children) : [];
14374
- const clickedCell = children.filter((child) => child.contains(target))[0];
14375
- return props.rawColumnNames[children.indexOf(clickedCell)];
14376
- };
14642
+ const colspan = props.selectable
14643
+ ? props.columnNames.length + 1
14644
+ : props.columnNames.length;
14377
14645
  return () => h$1(CTableBody, {
14378
14646
  ...(props.clickableRows && { style: 'cursor:pointer;' }),
14379
14647
  }, {
14380
- default: () => props.currentItems.map((item, trIndex) => [
14381
- h$1(CTableRow, {
14382
- ...(item._props && { ...item._props }),
14383
- ...(props.clickableRows && { tabindex: 0 }),
14384
- onClick: (event) => handleRowClick(item, trIndex + props.firstItemOnActivePageIndex, getColumnName(event), event),
14385
- }, {
14386
- default: () => [
14387
- props.selectable &&
14388
- h$1(CTableDataCell, {}, () => h$1(CFormCheck, {
14389
- checked: item._selected ? item._selected : false,
14390
- onChange: (event) => handleRowChecked(item._id, event.target.checked),
14391
- })),
14392
- props.rawColumnNames.map((colName) => props.scopedSlots &&
14393
- props.scopedSlots[colName] &&
14394
- typeof props.scopedSlots[colName] === 'function'
14395
- ? h$1(props.scopedSlots[colName], { item: item })
14396
- : h$1(CTableDataCell, {
14397
- ...tableDataCellProps(item, colName),
14398
- }, {
14399
- default: () => String(item[colName]),
14400
- })),
14401
- ],
14402
- }),
14403
- props.scopedSlots &&
14404
- props.scopedSlots['details'] && [
14405
- h$1(CTableRow, {
14406
- colspan: props.selectable
14407
- ? props.rawColumnNames.length + 1
14408
- : props.rawColumnNames.length,
14409
- class: 'p-0',
14410
- style: { 'border-bottom-width': '0' },
14411
- tabindex: '-1',
14412
- }),
14648
+ default: () => props.currentItems.length
14649
+ ? props.currentItems.map((item, trIndex) => [
14413
14650
  h$1(CTableRow, {
14414
- class: 'p-0',
14415
- key: `details${trIndex}`,
14416
- onClick: (event) => handleRowClick(item, trIndex + props.firstItemOnActivePageIndex, getColumnName(event), true),
14651
+ ...(item._props && { ...item._props }),
14652
+ ...(props.clickableRows && { tabindex: 0 }),
14653
+ onClick: (event) => {
14654
+ emit('rowClick', item, trIndex + props.firstItemOnActivePageIndex, getClickedColumnName(event.target, props.columnNames), event);
14655
+ },
14417
14656
  }, {
14418
- default: () => h$1(CTableDataCell, {
14657
+ default: () => [
14658
+ props.selectable &&
14659
+ h$1(CTableDataCell, {}, () => h$1(CFormCheck, {
14660
+ checked: props.selected &&
14661
+ isObjectInArray(props.selected, item, [
14662
+ '_cellProps',
14663
+ '_props',
14664
+ '_selected',
14665
+ ]),
14666
+ onChange: (event) => {
14667
+ emit('rowChecked', item, event.target.checked);
14668
+ },
14669
+ })),
14670
+ props.columnNames.map((colName) => props.scopedSlots &&
14671
+ props.scopedSlots[colName] &&
14672
+ typeof props.scopedSlots[colName] === 'function'
14673
+ ? h$1(props.scopedSlots[colName], { item: item })
14674
+ : h$1(CTableDataCell, {
14675
+ ...getTableDataCellProps(item, colName),
14676
+ }, {
14677
+ default: () => String(item[colName]),
14678
+ })),
14679
+ ],
14680
+ }),
14681
+ props.scopedSlots &&
14682
+ props.scopedSlots['details'] && [
14683
+ h$1(CTableRow, {
14419
14684
  colspan: props.selectable
14420
- ? props.rawColumnNames.length + 1
14421
- : props.rawColumnNames.length,
14685
+ ? props.columnNames.length + 1
14686
+ : props.columnNames.length,
14422
14687
  class: 'p-0',
14423
- style: { border: 0 },
14688
+ style: { 'border-bottom-width': '0' },
14689
+ tabindex: '-1',
14690
+ }),
14691
+ h$1(CTableRow, {
14692
+ class: 'p-0',
14693
+ key: `details${trIndex}`,
14694
+ onClick: (event) => {
14695
+ emit('rowClick', item, trIndex + props.firstItemOnActivePageIndex, getClickedColumnName(event.target, props.columnNames), true);
14696
+ },
14424
14697
  }, {
14425
- default: () => props.scopedSlots &&
14426
- props.scopedSlots['details'] &&
14427
- h$1(props.scopedSlots['details'], {
14428
- item: item,
14429
- onClick: (event) => handleRowClick(item, trIndex + props.firstItemOnActivePageIndex, getColumnName(event), true),
14430
- }),
14698
+ default: () => h$1(CTableDataCell, {
14699
+ colspan: props.selectable
14700
+ ? props.columnNames.length + 1
14701
+ : props.columnNames.length,
14702
+ class: 'p-0',
14703
+ style: { border: 0 },
14704
+ }, {
14705
+ default: () => props.scopedSlots &&
14706
+ props.scopedSlots['details'] &&
14707
+ h$1(props.scopedSlots['details'], {
14708
+ item: item,
14709
+ }),
14710
+ }),
14431
14711
  }),
14712
+ ],
14713
+ ])
14714
+ : h$1(CTableRow, {}, {
14715
+ default: () => h$1(CTableDataCell, { colspan: colspan }, {
14716
+ default: () => props.noItemsLabel,
14432
14717
  }),
14433
- ],
14434
- ]),
14718
+ }),
14435
14719
  });
14436
14720
  },
14437
14721
  });
@@ -14439,140 +14723,63 @@ const CSmartTableBody = defineComponent({
14439
14723
  const CSmartTableHead = defineComponent({
14440
14724
  name: 'CSmartTableHead',
14441
14725
  props: {
14442
- clearSorterAndFilter: {
14443
- type: String,
14444
- require: false,
14445
- default: '',
14446
- },
14447
- columnFilter: {
14448
- type: [Boolean, Object],
14449
- require: false,
14450
- },
14451
- columnFilterValue: {
14452
- type: Object,
14453
- required: false,
14454
- },
14455
- columnSorter: {
14456
- type: [Boolean, Object],
14457
- default: undefined,
14458
- require: false,
14459
- },
14726
+ columnFilter: [Boolean, Object],
14727
+ columnFilterValue: Object,
14728
+ columnSorter: [Boolean, Object],
14460
14729
  component: {
14461
14730
  type: String,
14462
14731
  default: 'head',
14463
- require: false,
14464
14732
  },
14465
14733
  columns: {
14466
14734
  type: Array,
14467
14735
  default: () => [],
14468
- required: false,
14469
14736
  },
14470
14737
  items: {
14471
14738
  type: Array,
14472
14739
  default: () => [],
14473
- required: false,
14474
14740
  },
14475
14741
  selectable: Boolean,
14476
- selectAll: [Boolean, String],
14477
- sorterState: {
14478
- type: Object,
14479
- default: undefined,
14480
- require: false,
14481
- },
14742
+ selectAll: [Boolean, Object],
14743
+ selectedAll: [Boolean, String],
14744
+ sorterState: Object,
14482
14745
  },
14483
14746
  emits: ['customFilterChange', 'filterInput', 'filterChange', 'selectAllChecked', 'sortClick'],
14484
14747
  setup(props, { slots, emit }) {
14485
- const handleSortClick = (key, index) => {
14486
- emit('sortClick', key, index);
14487
- };
14488
- const tableHeaderCellProps = (column) => {
14489
- if (typeof column === 'object' && column._props) {
14490
- return column._props;
14491
- }
14492
- return {};
14493
- };
14494
- const tableHeaderCellStyles = (column) => {
14495
- const style = { verticalAlign: 'middle', overflow: 'hidden', cursor: '' };
14496
- if (props.columnSorter &&
14497
- (typeof column !== 'object' ||
14498
- (typeof column === 'object' && (typeof column.sorter === 'undefined' || column.sorter)))) {
14499
- style.cursor = 'pointer';
14500
- }
14501
- if (typeof column === 'object' && column._style) {
14502
- return { ...style, ...column._style };
14503
- }
14504
- return style;
14505
- };
14506
- const pretifyName = (name) => {
14507
- return name
14508
- .replace(/[-_.]/g, ' ')
14509
- .replace(/ +/g, ' ')
14510
- .replace(/([a-z0-9])([A-Z])/g, '$1 $2')
14511
- .split(' ')
14512
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
14513
- .join(' ');
14514
- };
14515
- const label = (column) => typeof column === 'object'
14516
- ? column.label !== undefined
14517
- ? column.label
14518
- : pretifyName(column.key)
14519
- : pretifyName(column);
14520
- const key = (column) => (typeof column === 'object' ? column.key : column);
14521
- const getColumnSorterState = (key) => {
14522
- if (props.sorterState && props.sorterState.column === key) {
14523
- if (props.sorterState.state) {
14524
- return props.sorterState.state;
14525
- }
14526
- return 0;
14527
- }
14528
- return 0;
14529
- };
14530
- const getValues = (items, key) => {
14531
- return items.map((a) => a[key]);
14532
- };
14533
14748
  const columnSorterIcon = (column) => {
14534
- if (getColumnSorterState(key(column)) === 0) {
14749
+ if (getColumnSorterState(getColumnKey(column), props.sorterState) === 0) {
14535
14750
  return h$1('span', { class: 'opacity-25 float-end me-1' }, slots.sortingIcon && slots.sortingIcon());
14536
14751
  }
14537
- if (getColumnSorterState(key(column)) === 'asc') {
14752
+ if (getColumnSorterState(getColumnKey(column), props.sorterState) === 'asc') {
14538
14753
  return h$1('span', { class: 'float-end me-1' }, slots.sortingIconAscending && slots.sortingIconAscending());
14539
14754
  }
14540
- if (getColumnSorterState(key(column)) === 'desc') {
14755
+ if (getColumnSorterState(getColumnKey(column), props.sorterState) === 'desc') {
14541
14756
  return h$1('span', { class: 'float-end me-1' }, slots.sortingIconDescending && slots.sortingIconDescending());
14542
14757
  }
14543
14758
  return;
14544
14759
  };
14545
- const handleOnCustomFilterChange = (key, value) => {
14546
- emit('customFilterChange', key, value);
14547
- };
14548
- const handleFilterInput = (key, value) => {
14549
- emit('filterInput', key, value);
14550
- };
14551
- const handleFilterChange = (key, value) => {
14552
- emit('filterChange', key, value);
14553
- };
14554
- const handleSelectAllChecked = () => {
14555
- emit('selectAllChecked');
14556
- };
14557
14760
  return () => h$1(props.component === 'head' ? CTableHead : CTableFoot, {}, {
14558
14761
  default: () => [
14559
14762
  h$1(CTableRow, {}, {
14560
14763
  default: () => [
14561
14764
  props.selectable &&
14562
14765
  h$1(CTableHeaderCell, {}, () => h$1(CFormCheck, {
14563
- checked: typeof props.selectAll === 'boolean' ? props.selectAll : false,
14564
- indeterminate: props.selectAll === 'indeterminate' ? true : false,
14565
- onChange: () => handleSelectAllChecked(),
14766
+ checked: typeof props.selectedAll === 'boolean' ? props.selectAll : false,
14767
+ indeterminate: props.selectedAll === 'indeterminate' ? true : false,
14768
+ onChange: () => {
14769
+ emit('selectAllChecked');
14770
+ },
14566
14771
  })),
14567
14772
  props.columns.map((column, index) => h$1(CTableHeaderCell, {
14568
- ...tableHeaderCellProps(column),
14569
- onClick: () => handleSortClick(key(column), index),
14570
- style: tableHeaderCellStyles(column),
14773
+ ...getTableHeaderCellProps(column),
14774
+ onClick: () => {
14775
+ emit('sortClick', getColumnKey(column), index);
14776
+ },
14777
+ style: getTableHeaderCellStyles(column, props.columnSorter),
14571
14778
  }, {
14572
14779
  default: () => [
14573
14780
  h$1('div', {
14574
14781
  class: 'd-inline',
14575
- }, label(column)),
14782
+ }, getColumnLabel(column)),
14576
14783
  props.columnSorter &&
14577
14784
  (typeof column !== 'object'
14578
14785
  ? true
@@ -14589,7 +14796,7 @@ const CSmartTableHead = defineComponent({
14589
14796
  default: () => [
14590
14797
  props.selectable && h$1(CTableHeaderCell),
14591
14798
  props.columns.map((column) => h$1(CTableHeaderCell, {
14592
- ...tableHeaderCellProps(column),
14799
+ ...getTableHeaderCellProps(column),
14593
14800
  }, {
14594
14801
  default: () => (typeof column !== 'object'
14595
14802
  ? true
@@ -14597,15 +14804,21 @@ const CSmartTableHead = defineComponent({
14597
14804
  ? true
14598
14805
  : column.filter)
14599
14806
  ? typeof column !== 'string' && typeof column.filter === 'function'
14600
- ? column.filter(getValues(props.items, key(column)), (value) => handleOnCustomFilterChange(key(column), value))
14807
+ ? column.filter(getColumnValues(props.items, getColumnKey(column)), (value) => {
14808
+ emit('customFilterChange', getColumnKey(column), value);
14809
+ })
14601
14810
  : h$1(CFormInput, {
14602
14811
  size: 'sm',
14603
- onInput: (event) => handleFilterInput(key(column), event.target.value),
14604
- onChange: (event) => handleFilterChange(key(column), event.target.value),
14605
- 'aria-label': `column name: '${label(column)}' filter input`,
14812
+ onInput: (event) => {
14813
+ emit('filterInput', getColumnKey(column), event.target.value);
14814
+ },
14815
+ onChange: (event) => {
14816
+ emit('filterChange', event.target.value);
14817
+ },
14818
+ 'aria-label': `column name: '${getColumnLabel(column)}' filter input`,
14606
14819
  ...(props.columnFilterValue &&
14607
- props.columnFilterValue[key(column)] && {
14608
- value: props.columnFilterValue[key(column)],
14820
+ props.columnFilterValue[getColumnKey(column)] && {
14821
+ value: props.columnFilterValue[getColumnKey(column)],
14609
14822
  }),
14610
14823
  })
14611
14824
  : '',
@@ -14617,268 +14830,6 @@ const CSmartTableHead = defineComponent({
14617
14830
  },
14618
14831
  });
14619
14832
 
14620
- const CSmartTableFilterProps = {
14621
- filterLabel: {
14622
- type: String,
14623
- require: false,
14624
- default: 'Filter:',
14625
- },
14626
- filterPlaceholder: {
14627
- type: String,
14628
- require: false,
14629
- default: 'type string...',
14630
- },
14631
- value: {
14632
- type: [String, Number],
14633
- require: false,
14634
- default: '',
14635
- },
14636
- };
14637
- const CSmartTableFilter = defineComponent({
14638
- name: 'CSmartTableFilter',
14639
- props: CSmartTableFilterProps,
14640
- emits: ['filterInput', 'filterChange'],
14641
- setup(props, { emit }) {
14642
- const handleFilterInput = (event) => {
14643
- const target = event.target;
14644
- emit('filterInput', target.value);
14645
- };
14646
- const handleFilterChange = (event) => {
14647
- const target = event.target;
14648
- emit('filterChange', target.value);
14649
- };
14650
- return () => h$1('div', {
14651
- class: 'row mb-2',
14652
- }, {
14653
- default: () => [
14654
- h$1(CFormLabel, {
14655
- class: 'col-sm-auto col-form-label',
14656
- }, {
14657
- default: () => props.filterLabel,
14658
- }),
14659
- h$1('div', {
14660
- class: 'col-sm-auto',
14661
- }, h$1(CFormInput, {
14662
- placeholder: props.filterPlaceholder,
14663
- value: props.value,
14664
- onInput: handleFilterInput,
14665
- onChange: handleFilterChange,
14666
- })),
14667
- ],
14668
- });
14669
- },
14670
- });
14671
-
14672
- const CSmartTableCleaner = defineComponent({
14673
- name: 'CSmartTableCleaner',
14674
- props: {
14675
- isFiltered: {
14676
- type: String,
14677
- default: undefined,
14678
- required: false,
14679
- },
14680
- },
14681
- emits: ['tableCleanerClick'],
14682
- setup(props, { emit, slots }) {
14683
- const handleClick = () => {
14684
- emit('tableCleanerClick');
14685
- };
14686
- return () => h$1('button', {
14687
- type: 'button',
14688
- class: 'btn btn-transparent',
14689
- ...(!props.isFiltered && { disabled: true, tabIndex: -1 }),
14690
- onClick: handleClick,
14691
- }, slots.cleanerIcon && slots.cleanerIcon());
14692
- },
14693
- });
14694
-
14695
- const CSmartTableItemsPerPageSelector = defineComponent({
14696
- name: 'CSmartTableItemsPerPageSelector',
14697
- props: {
14698
- itemsPerPage: {
14699
- type: Number,
14700
- default: undefined,
14701
- require: false,
14702
- },
14703
- itemsPerPageLabel: {
14704
- type: String,
14705
- default: undefined,
14706
- require: false,
14707
- },
14708
- itemsPerPageOptions: {
14709
- type: Array,
14710
- default: () => [],
14711
- require: false,
14712
- },
14713
- },
14714
- emits: ['changeItemsPerPage'],
14715
- setup(props, { emit }) {
14716
- const handleChange = (event) => {
14717
- const target = event.target;
14718
- emit('changeItemsPerPage', Number(target.value));
14719
- };
14720
- return () => h$1('div', {
14721
- class: 'row',
14722
- }, {
14723
- default: () => [
14724
- h$1(CFormLabel, {
14725
- class: 'col-auto col-form-label',
14726
- }, {
14727
- default: () => props.itemsPerPageLabel,
14728
- }),
14729
- h$1('div', {
14730
- class: 'col-auto',
14731
- }, h$1(CFormSelect, {
14732
- value: props.itemsPerPage,
14733
- onChange: handleChange,
14734
- }, {
14735
- default: () => props.itemsPerPageOptions &&
14736
- props.itemsPerPageOptions.map((number, index) => {
14737
- return h$1('option', {
14738
- value: number,
14739
- key: index,
14740
- }, number);
14741
- }),
14742
- })),
14743
- ],
14744
- });
14745
- },
14746
- });
14747
-
14748
- const CIcon = defineComponent({
14749
- name: 'CIcon',
14750
- props: {
14751
- /**
14752
- * Use `:icon="..."` instead of
14753
- *
14754
- * @deprecated since version 3.0
14755
- */
14756
- content: {
14757
- type: [String, Array],
14758
- default: undefined,
14759
- required: false,
14760
- },
14761
- /**
14762
- * Use for replacing default CIcon component classes. Prop is overriding the 'size' prop.
14763
- */
14764
- customClassName: {
14765
- type: [String, Array, Object],
14766
- default: undefined,
14767
- required: false,
14768
- },
14769
- /**
14770
- * Name of the icon placed in React object or SVG content.
14771
- */
14772
- icon: {
14773
- type: [String, Array],
14774
- default: undefined,
14775
- required: false,
14776
- },
14777
- /**
14778
- * Use `icon="..."` instead of
14779
- *
14780
- * @deprecated since version 3.0
14781
- */
14782
- name: {
14783
- type: String,
14784
- default: undefined,
14785
- required: false,
14786
- },
14787
- /**
14788
- * Size of the icon. Available sizes: 'sm', 'lg', 'xl', 'xxl', '3xl...9xl', 'custom', 'custom-size'.
14789
- */
14790
- size: {
14791
- type: String,
14792
- default: undefined,
14793
- required: false,
14794
- validator: (value) => {
14795
- return [
14796
- 'custom',
14797
- 'custom-size',
14798
- 'sm',
14799
- 'lg',
14800
- 'xl',
14801
- 'xxl',
14802
- '3xl',
14803
- '4xl',
14804
- '5xl',
14805
- '6xl',
14806
- '7xl',
14807
- '8xl',
14808
- '9xl',
14809
- ].includes(value);
14810
- },
14811
- },
14812
- /**
14813
- * Title tag content.
14814
- */
14815
- title: {
14816
- type: String,
14817
- default: undefined,
14818
- required: false,
14819
- },
14820
- /**
14821
- * If defined component will be rendered using 'use' tag.
14822
- */
14823
- use: {
14824
- type: String,
14825
- default: undefined,
14826
- required: false,
14827
- },
14828
- },
14829
- setup(props, { attrs }) {
14830
- const icons = inject('icons');
14831
- const _icon = props.icon || props.content || props.name;
14832
- const toCamelCase = (str) => {
14833
- return str
14834
- .replace(/([-_][a-z0-9])/gi, ($1) => {
14835
- return $1.toUpperCase();
14836
- })
14837
- .replace(/-/gi, '');
14838
- };
14839
- const iconName = computed(() => _icon && typeof _icon === 'string' ? (_icon.includes('-') ? toCamelCase(_icon) : _icon) : '');
14840
- const titleCode = props.title ? `<title>${props.title}</title>` : 'undefined';
14841
- const code = computed(() => Array.isArray(_icon)
14842
- ? _icon
14843
- : typeof _icon === 'string' && iconName.value && icons[iconName.value]
14844
- ? icons[iconName.value]
14845
- : 'undefined');
14846
- const iconCode = Array.isArray(code.value) ? code.value[1] || code.value[0] : code.value;
14847
- const scale = Array.isArray(code.value) && code.value.length > 1 ? code.value[0] : '64 64';
14848
- const viewBox = attrs.viewBox || `0 0 ${scale}`;
14849
- const size = () => {
14850
- const addCustom = !props.size && (attrs.width || attrs.height);
14851
- return props.size === 'custom' || addCustom ? 'custom-size' : props.size;
14852
- };
14853
- const classNames = (() => {
14854
- return [props.customClassName || ['icon', { [`icon-${size()}`]: size() }], attrs.class];
14855
- })();
14856
- return () => props.use
14857
- ? h$1('svg', {
14858
- ...attrs,
14859
- xmlns: 'http://www.w3.org/2000/svg',
14860
- class: classNames,
14861
- role: 'img',
14862
- }, h$1('use', { href: props.use }))
14863
- : h$1('svg', {
14864
- ...attrs,
14865
- xmlns: 'http://www.w3.org/2000/svg',
14866
- class: classNames,
14867
- viewBox: viewBox,
14868
- innerHTML: `${titleCode}${iconCode}`,
14869
- role: 'img',
14870
- });
14871
- },
14872
- });
14873
-
14874
- var cilArrowBottom = ["512 512", "<polygon fill='var(--ci-primary-color, currentColor)' points='367.997 338.75 271.999 434.747 271.999 17.503 239.999 17.503 239.999 434.745 144.003 338.75 121.376 361.377 256 496 390.624 361.377 367.997 338.75' class='ci-primary'/>"];
14875
-
14876
- var cilArrowTop = ["512 512", "<polygon fill='var(--ci-primary-color, currentColor)' points='390.624 150.625 256 16 121.376 150.625 144.004 173.252 240.001 77.254 240.001 495.236 272.001 495.236 272.001 77.257 367.996 173.252 390.624 150.625' class='ci-primary'/>"];
14877
-
14878
- var cilFilterX = ["512 512", "<polygon fill='var(--ci-primary-color, currentColor)' points='40 16 40 53.828 109.024 136 150.815 136 76.896 48 459.51 48 304 242.388 304 401.373 241.373 464 240 464 240 368 208 368 208 496 254.627 496 336 414.627 336 253.612 496 53.612 496 16 40 16' class='ci-primary'/><polygon fill='var(--ci-primary-color, currentColor)' points='166.403 248.225 226.864 187.763 204.237 165.135 143.775 225.597 83.313 165.135 60.687 187.763 121.148 248.225 60.687 308.687 83.313 331.314 143.775 270.852 204.237 331.314 226.864 308.687 166.403 248.225' class='ci-primary'/>"];
14879
-
14880
- var cilSwapVertical = ["512 512", "<polygon fill='var(--ci-primary-color, currentColor)' points='384 433.373 384 160 352 160 352 434.51 282.177 364.687 259.55 387.313 367.432 495.196 475.313 387.313 452.687 364.687 384 433.373' class='ci-primary'/><polygon fill='var(--ci-primary-color, currentColor)' points='159.432 17.372 51.55 125.255 74.177 147.882 144 78.059 144 352 176 352 176 79.195 244.687 147.882 267.313 125.255 159.432 17.372' class='ci-primary'/>"];
14881
-
14882
14833
  const CSmartTable = defineComponent({
14883
14834
  name: 'CSmartTable',
14884
14835
  props: {
@@ -14888,7 +14839,6 @@ const CSmartTable = defineComponent({
14888
14839
  activePage: {
14889
14840
  type: Number,
14890
14841
  default: 1,
14891
- required: false,
14892
14842
  },
14893
14843
  /**
14894
14844
  * When set, displays table cleaner above table, next to the table filter (or in place of table filter if `tableFilter` prop is not set)
@@ -14897,14 +14847,12 @@ const CSmartTable = defineComponent({
14897
14847
  */
14898
14848
  cleaner: {
14899
14849
  type: Boolean,
14900
- required: false,
14901
14850
  },
14902
14851
  /**
14903
14852
  * Style table items as clickable.
14904
14853
  */
14905
14854
  clickableRows: {
14906
14855
  type: Boolean,
14907
- required: false,
14908
14856
  },
14909
14857
  /**
14910
14858
  * When set, displays additional filter row between table header and items, allowing filtering by specific column.
@@ -14914,7 +14862,6 @@ const CSmartTable = defineComponent({
14914
14862
  */
14915
14863
  columnFilter: {
14916
14864
  type: [Boolean, Object],
14917
- required: false,
14918
14865
  },
14919
14866
  /**
14920
14867
  * Value of table filter. To set pass object where keys are column names and values are filter strings e.g.:
@@ -14922,8 +14869,6 @@ const CSmartTable = defineComponent({
14922
14869
  */
14923
14870
  columnFilterValue: {
14924
14871
  type: Object,
14925
- default: undefined,
14926
- required: false,
14927
14872
  },
14928
14873
  /**
14929
14874
  * 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')
@@ -14940,7 +14885,6 @@ const CSmartTable = defineComponent({
14940
14885
  */
14941
14886
  columns: {
14942
14887
  type: Array,
14943
- required: false,
14944
14888
  },
14945
14889
  /**
14946
14890
  * Enables table sorting by column value. Sorting will be performed corectly only if values in column are of one type: string (case insensitive) or number.
@@ -14951,8 +14895,6 @@ const CSmartTable = defineComponent({
14951
14895
  */
14952
14896
  columnSorter: {
14953
14897
  type: [Boolean, Object],
14954
- default: undefined,
14955
- required: false,
14956
14898
  },
14957
14899
  /**
14958
14900
  * If `true` Displays table footer, which mirrors table header. (without column filter).
@@ -14965,14 +14907,12 @@ const CSmartTable = defineComponent({
14965
14907
  */
14966
14908
  footer: {
14967
14909
  type: [Boolean, Array],
14968
- required: false,
14969
14910
  },
14970
14911
  /**
14971
14912
  * Set to false to remove table header.
14972
14913
  */
14973
14914
  header: {
14974
14915
  type: Boolean,
14975
- required: false,
14976
14916
  default: true,
14977
14917
  },
14978
14918
  /**
@@ -14985,22 +14925,25 @@ const CSmartTable = defineComponent({
14985
14925
  items: {
14986
14926
  type: Array,
14987
14927
  default: () => [],
14988
- required: false,
14989
14928
  },
14929
+ /**
14930
+ * The total number of items. Use if you pass a portion of data from an external source to let know component what is the total number of items.
14931
+ *
14932
+ * @since 4.8.0
14933
+ */
14934
+ itemsNumber: Number,
14990
14935
  /**
14991
14936
  * Number of items per site, when pagination is enabled.
14992
14937
  */
14993
14938
  itemsPerPage: {
14994
14939
  type: Number,
14995
14940
  default: 10,
14996
- required: false,
14997
14941
  },
14998
14942
  /**
14999
14943
  * Label for items per page selector.
15000
14944
  */
15001
14945
  itemsPerPageLabel: {
15002
14946
  type: String,
15003
- required: false,
15004
14947
  default: 'Items per page:',
15005
14948
  },
15006
14949
  /**
@@ -15009,7 +14952,6 @@ const CSmartTable = defineComponent({
15009
14952
  itemsPerPageOptions: {
15010
14953
  type: Array,
15011
14954
  default: () => [5, 10, 20, 50],
15012
- required: false,
15013
14955
  },
15014
14956
  /**
15015
14957
  * Adds select element over table, which is used for control items per page in pagination. If you want to customize this element, pass object with optional values:
@@ -15019,15 +14961,12 @@ const CSmartTable = defineComponent({
15019
14961
  */
15020
14962
  itemsPerPageSelect: {
15021
14963
  type: [Boolean, Object],
15022
- default: undefined,
15023
- required: false,
15024
14964
  },
15025
14965
  /**
15026
14966
  * When set, table will have loading style: loading spinner and reduced opacity. When 'small' prop is enabled spinner will be also smaller.
15027
14967
  */
15028
14968
  loading: {
15029
14969
  type: Boolean,
15030
- required: false,
15031
14970
  },
15032
14971
  /**
15033
14972
  * ReactNode or string for passing custom noItemsLabel texts.
@@ -15035,51 +14974,63 @@ const CSmartTable = defineComponent({
15035
14974
  noItemsLabel: {
15036
14975
  type: String,
15037
14976
  default: 'No items found',
15038
- required: false,
15039
14977
  },
15040
14978
  /**
15041
14979
  * Enables default pagination. Set to true for default setup or pass an object with additional CPagination props. Default pagination will always have the computed number of pages that cannot be changed. The number of pages is generated based on the number of passed items and 'itemsPerPage' prop. If this restriction is an obstacle, you can make external CPagination instead.
15042
14980
  */
15043
14981
  pagination: {
15044
14982
  type: [Boolean, Object],
15045
- required: false,
15046
14983
  },
15047
14984
  /**
15048
14985
  * Properties to [CSmartPagination](https://coreui.io/vue/docs/components/smart-pagination#csmartpagination) component.
15049
14986
  */
15050
14987
  paginationProps: {
15051
14988
  type: Object,
15052
- default: undefined,
15053
- required: false,
15054
14989
  },
15055
14990
  /**
15056
14991
  * Add checkboxes to make table rows selectable.
15057
14992
  */
15058
14993
  selectable: Boolean,
14994
+ /**
14995
+ * Enables select all checkbox displayed in the header of the table.
14996
+ *
14997
+ * Can be customized, by passing prop as object with additional options as keys. Available options:
14998
+ * - external (Boolean) - Disables automatic selection inside the component.
14999
+ *
15000
+ * @since 4.8.0
15001
+ */
15002
+ selectAll: {
15003
+ type: [Boolean, Object],
15004
+ },
15005
+ /**
15006
+ * Array of selected objects, where each object represents one item - row in table.
15007
+ *
15008
+ * Example item: `{ name: 'John' , age: 12 }`
15009
+ *
15010
+ * @since 4.8.0
15011
+ */
15012
+ selected: {
15013
+ type: Array,
15014
+ default: () => [],
15015
+ },
15059
15016
  /**
15060
15017
  * State of the sorter. Name key is column name, direction can be 'asc' or 'desc'. eg.:
15061
15018
  * { column: 'status', state: 'asc' }
15062
15019
  */
15063
15020
  sorterValue: {
15064
15021
  type: Object,
15065
- default: undefined,
15066
- required: false,
15067
15022
  },
15068
15023
  /**
15069
15024
  * Properties to [CTableBody](https://coreui.io/vue/docs/components/table/#ctablebody) component.
15070
15025
  */
15071
15026
  tableBodyProps: {
15072
15027
  type: Object,
15073
- default: undefined,
15074
- required: false,
15075
15028
  },
15076
15029
  /**
15077
15030
  * Properties to [CTableFoot](https://coreui.io/vue/docs/components/table/#ctablefoot) component.
15078
15031
  */
15079
15032
  tableFootProps: {
15080
15033
  type: Object,
15081
- default: undefined,
15082
- required: false,
15083
15034
  },
15084
15035
  /**
15085
15036
  * When set, displays table filter above table, allowing filtering by specific column.
@@ -15090,7 +15041,6 @@ const CSmartTable = defineComponent({
15090
15041
  */
15091
15042
  tableFilter: {
15092
15043
  type: [Boolean, Object],
15093
- required: false,
15094
15044
  },
15095
15045
  /**
15096
15046
  * The element represents a caption for a component.
@@ -15098,7 +15048,6 @@ const CSmartTable = defineComponent({
15098
15048
  tableFilterLabel: {
15099
15049
  type: String,
15100
15050
  default: 'Filter:',
15101
- required: false,
15102
15051
  },
15103
15052
  /**
15104
15053
  * Specifies a short hint that is visible in the search input.
@@ -15106,31 +15055,24 @@ const CSmartTable = defineComponent({
15106
15055
  tableFilterPlaceholder: {
15107
15056
  type: String,
15108
15057
  default: 'type string...',
15109
- required: false,
15110
15058
  },
15111
15059
  /**
15112
15060
  * Value of table filter.
15113
15061
  */
15114
15062
  tableFilterValue: {
15115
15063
  type: String,
15116
- default: undefined,
15117
- required: false,
15118
15064
  },
15119
15065
  /**
15120
15066
  * Properties to [CTableHead](https://coreui.io/vue/docs/components/table/#ctablehead) component.
15121
15067
  */
15122
15068
  tableHeadProps: {
15123
15069
  type: Object,
15124
- default: undefined,
15125
- required: false,
15126
15070
  },
15127
15071
  /**
15128
15072
  * Properties to [CTable](https://coreui.io/vue/docs/components/table/#ctable) component.
15129
15073
  */
15130
15074
  tableProps: {
15131
15075
  type: Object,
15132
- default: undefined,
15133
- required: false,
15134
15076
  },
15135
15077
  },
15136
15078
  emits: [
@@ -15167,6 +15109,12 @@ const CSmartTable = defineComponent({
15167
15109
  * @property {event} event
15168
15110
  */
15169
15111
  'rowClick',
15112
+ /**
15113
+ * Select all callback.
15114
+ *
15115
+ * @since 4.8.0
15116
+ */
15117
+ 'selectAll',
15170
15118
  /**
15171
15119
  * Selected items change callback.
15172
15120
  *
@@ -15187,66 +15135,90 @@ const CSmartTable = defineComponent({
15187
15135
  'tableFilterChange',
15188
15136
  ],
15189
15137
  setup(props, { emit, slots }) {
15190
- // reactive data
15138
+ const activePage = ref(props.activePage);
15139
+ const columnFilterState = ref(props.columnFilterValue ? props.columnFilterValue : {});
15191
15140
  const items = ref(props.items.map((item, index) => {
15192
15141
  return { ...item, _id: index };
15193
15142
  }));
15143
+ const itemsNumber = ref(props.itemsNumber);
15144
+ const itemsPerPage = ref(props.itemsPerPage || items.value.length);
15145
+ const selected = ref([]);
15146
+ const selectedAll = ref();
15147
+ const sorterState = ref(props.sorterValue || {});
15148
+ const tableFilterState = ref(props.tableFilterValue ? props.tableFilterValue : '');
15149
+ watch(() => props.activePage, () => {
15150
+ activePage.value = props.activePage;
15151
+ });
15152
+ watch(() => props.columnFilterValue, () => {
15153
+ if (props.columnFilterValue) {
15154
+ columnFilterState.value = props.columnFilterValue;
15155
+ }
15156
+ });
15194
15157
  watch(() => props.items, () => {
15195
- items.value = props.items.map((item, index) => {
15196
- return { ...item, _id: index };
15197
- });
15198
- if (items.value &&
15199
- items.value.length < itemsPerPage.value * activePage.value - itemsPerPage.value) {
15158
+ if (props.items &&
15159
+ props.items.length < itemsPerPage.value * activePage.value - itemsPerPage.value) {
15200
15160
  activePage.value = 1;
15201
15161
  }
15162
+ props.items.forEach((item) => {
15163
+ if (item._selected) {
15164
+ const _item = { ...item };
15165
+ delete _item['_cellProps'];
15166
+ delete _item['_props'];
15167
+ delete _item['_selected'];
15168
+ selected.value = [...selected.value, _item];
15169
+ }
15170
+ });
15171
+ if (Array.isArray(props.items)) {
15172
+ items.value = props.items;
15173
+ itemsNumber.value = props.itemsNumber || props.items.length;
15174
+ }
15202
15175
  });
15203
- const selectedAll = ref();
15204
- watch(items, () => {
15205
- const selected = items.value.filter((item) => item._selected === true);
15176
+ watch(() => props.itemsNumber, () => {
15177
+ itemsNumber.value = props.itemsNumber;
15178
+ });
15179
+ watch(() => props.itemsPerPage, () => {
15180
+ itemsPerPage.value = props.itemsPerPage;
15181
+ });
15182
+ watch(() => props.selected, () => {
15183
+ selected.value = props.selected;
15184
+ });
15185
+ watch(() => props.sorterValue, () => {
15186
+ if (props.sorterValue) {
15187
+ sorterState.value = props.sorterValue;
15188
+ }
15189
+ });
15190
+ watch(itemsPerPage, () => {
15191
+ if (props.itemsPerPage !== itemsPerPage.value) {
15192
+ activePage.value = 1; // TODO: set proper page after _itemsPerPage update
15193
+ }
15194
+ emit('itemsPerPageChange', itemsPerPage.value);
15195
+ });
15196
+ watch([selected, itemsNumber], () => {
15206
15197
  emit('selectedItemsChange', selected);
15207
- if (selected.length === items.value.length) {
15198
+ if (selected.value.length === itemsNumber.value) {
15208
15199
  selectedAll.value = true;
15209
15200
  return;
15210
15201
  }
15211
- if (selected.length === 0) {
15202
+ if (selected.value.length === 0) {
15212
15203
  selectedAll.value = false;
15213
15204
  return;
15214
15205
  }
15215
- if (selected.length !== 0 && selected.length !== items.value.length) {
15206
+ if (selected.value.length !== 0 && selected.value.length !== itemsNumber.value) {
15216
15207
  selectedAll.value = 'indeterminate';
15217
15208
  }
15218
15209
  });
15219
- const itemsPerPage = ref(props.itemsPerPage || items.value.length);
15220
- const activePage = ref(props.activePage);
15221
- const sorterState = reactive(props.sorterValue || {});
15222
- const columnFilterState = ref(props.columnFilterValue ? props.columnFilterValue : {});
15223
- const tableFilterState = ref(props.tableFilterValue ? props.tableFilterValue : '');
15224
15210
  onMounted(() => {
15225
15211
  if (items.value &&
15226
15212
  items.value.length < itemsPerPage.value * activePage.value - itemsPerPage.value) {
15227
15213
  activePage.value = 1;
15228
15214
  }
15229
15215
  });
15230
- // functions
15231
- const isLazy = (columnFilter) => columnFilter && typeof columnFilter === 'object' && columnFilter.lazy === true;
15232
- const isSortable = (i) => {
15233
- const isDataColumn = itemsDataColumns.value.includes(rawColumnNames.value[i]);
15234
- let column;
15235
- if (props.columns)
15236
- column = props.columns[i];
15237
- return (props.columnSorter &&
15238
- (!props.columns ||
15239
- typeof column !== 'object' ||
15240
- (typeof column === 'object' &&
15241
- (typeof column.sorter === 'undefined' || column.sorter))) &&
15242
- isDataColumn);
15243
- };
15244
- const sorterChange = (column, index) => {
15245
- if (!isSortable(index)) {
15216
+ const handleSorterChange = (column, index) => {
15217
+ if (!isSortable(index, props.columns, props.columnSorter, itemsDataColumns.value, columnNames.value)) {
15246
15218
  return;
15247
15219
  }
15248
15220
  //if column changed or sort was descending change asc to true
15249
- const state = sorterState;
15221
+ const state = sorterState.value;
15250
15222
  if (state.column === column) {
15251
15223
  if (state.state === 0) {
15252
15224
  state.state = 'asc';
@@ -15267,40 +15239,47 @@ const CSmartTable = defineComponent({
15267
15239
  state.column = column;
15268
15240
  state.state = 'asc';
15269
15241
  }
15270
- sorterState.column = state.column;
15271
- sorterState.state = state.state;
15272
- emit('sorterChange', sorterState);
15242
+ sorterState.value.column = state.column;
15243
+ sorterState.value.state = state.state;
15244
+ emit('sorterChange', sorterState.value);
15273
15245
  };
15274
15246
  const handleActivePageChange = (page) => {
15275
15247
  activePage.value = page;
15276
15248
  emit('activePageChange', page);
15277
15249
  };
15278
- const handleItemsPerPageChange = (itemsPerPageNumber) => {
15279
- itemsPerPage.value = itemsPerPageNumber;
15280
- itemsPerPageNumber !== props.itemsPerPage && handleActivePageChange(1); // TODO: set proper page after _itemsPerPage update
15281
- emit('itemsPerPageChange', itemsPerPageNumber);
15282
- };
15283
- const handleRowChecked = (id, value) => {
15284
- const newArr = [...items.value];
15285
- newArr[id]._selected = value;
15286
- items.value = newArr;
15250
+ const handleItemsPerPageChange = (event) => {
15251
+ if (typeof props.itemsPerPageSelect !== 'object' ||
15252
+ (typeof props.itemsPerPageSelect === 'object' && !props.itemsPerPageSelect.external)) {
15253
+ itemsPerPage.value = Number(event.target.value);
15254
+ }
15287
15255
  };
15288
- const handleRowClick = (item, index, columnName, event) => {
15289
- emit('rowClick', item, index, columnName, event);
15256
+ const handleRowChecked = (item, value) => {
15257
+ if (value && !isObjectInArray(selected.value, item, ['_cellProps', '_props', '_selected'])) {
15258
+ selected.value = [...selected.value, item];
15259
+ return;
15260
+ }
15261
+ selected.value = selected.value.filter((_item) => !isObjectInArray([_item], item, ['_cellProps', '_props', '_selected']));
15290
15262
  };
15291
15263
  const handleSelectAllChecked = () => {
15292
15264
  if (selectedAll.value === true) {
15293
- items.value = items.value.map((item) => {
15294
- return { ...item, _selected: false };
15295
- });
15265
+ selected.value = [];
15266
+ return;
15267
+ }
15268
+ emit('selectAll');
15269
+ if (props.selectAll && typeof props.selectAll === 'object' && props.selectAll.external) {
15296
15270
  return;
15297
15271
  }
15298
- items.value = items.value.map((item) => {
15299
- return { ...item, _selected: true };
15272
+ selected.value = items.value.map((item) => {
15273
+ delete item['_cellProps'];
15274
+ delete item['_props'];
15275
+ delete item['_selected'];
15276
+ return item;
15300
15277
  });
15301
15278
  };
15302
- const columnFilterChange = (colName, value, type) => {
15303
- const _isLazy = isLazy(props.columnFilter);
15279
+ const handleColumnFilterChange = (colName, value, type) => {
15280
+ const _isLazy = props.columnFilter &&
15281
+ typeof props.columnFilter === 'object' &&
15282
+ props.columnFilter.lazy === true;
15304
15283
  if ((_isLazy && type === 'input') || (!_isLazy && type === 'change')) {
15305
15284
  return;
15306
15285
  }
@@ -15308,98 +15287,32 @@ const CSmartTable = defineComponent({
15308
15287
  columnFilterState.value = { ...columnFilterState.value, [`${colName}`]: value };
15309
15288
  emit('columnFilterChange', columnFilterState.value);
15310
15289
  };
15311
- const tableFilterChange = (value, type) => {
15312
- const _isLazy = isLazy(props.columnFilter);
15290
+ const handleTableFilterChange = (value, type) => {
15291
+ const _isLazy = props.columnFilter &&
15292
+ typeof props.columnFilter === 'object' &&
15293
+ props.columnFilter.lazy === true;
15313
15294
  if ((_isLazy && type === 'input') || (!_isLazy && type === 'change')) {
15314
15295
  return;
15315
15296
  }
15316
15297
  activePage.value = 1;
15317
15298
  tableFilterState.value = value;
15318
- emit('tableFilterChange', tableFilterState);
15299
+ emit('tableFilterChange', tableFilterState.value);
15319
15300
  };
15320
- const clean = () => {
15301
+ const handleClean = () => {
15321
15302
  tableFilterState.value = '';
15322
15303
  columnFilterState.value = {};
15323
- sorterState.column = '';
15324
- sorterState.state = '';
15304
+ sorterState.value = {};
15325
15305
  };
15326
- // computed
15327
- const genCols = computed(() => Object.keys(items.value[0] || {}).filter((el) => el.charAt(0) !== '_'));
15328
- const rawColumnNames = computed(() => props.columns
15329
- ? props.columns.map((column) => {
15330
- if (typeof column === 'object')
15331
- return column.key;
15332
- else
15333
- return column;
15334
- })
15335
- : genCols.value); //! || el
15336
- const itemsDataColumns = computed(() => rawColumnNames.value.filter((name) => genCols.value.includes(name)));
15337
- // variables
15338
- const filteredColumns = computed(() => {
15339
- let _items = items.value;
15340
- if (props.columnFilter &&
15341
- typeof props.columnFilter === 'object' &&
15342
- props.columnFilter.external) {
15343
- return _items;
15344
- }
15345
- Object.entries(columnFilterState.value).forEach(([key, value]) => {
15346
- if (value instanceof Function) {
15347
- _items = _items.filter((item) => value(item[key]));
15348
- return;
15349
- }
15350
- const columnFilter = String(value).toLowerCase();
15351
- if (columnFilter && itemsDataColumns.value.includes(key)) {
15352
- _items = _items.filter((item) => {
15353
- return String(item[key]).toLowerCase().includes(columnFilter);
15354
- });
15355
- }
15356
- });
15357
- return _items;
15358
- });
15359
- const filteredTable = computed(() => {
15360
- let items = filteredColumns.value;
15361
- if (!tableFilterState.value ||
15362
- (props.tableFilter && typeof props.tableFilter === 'object' && props.tableFilter.external)) {
15363
- return items;
15364
- }
15365
- const filter = tableFilterState.value.toLowerCase();
15366
- const valueContainFilter = (val) => String(val).toLowerCase().includes(filter);
15367
- items = items.filter((item) => {
15368
- return !!itemsDataColumns.value.find((key) => valueContainFilter(item[key]));
15369
- });
15370
- emit('filteredItemsChange', items);
15371
- return items;
15372
- });
15373
- const sortedItems = computed(() => {
15374
- const col = sorterState.column;
15375
- if (!col ||
15376
- !itemsDataColumns.value.includes(col) ||
15377
- (props.columnSorter &&
15378
- typeof props.columnSorter === 'object' &&
15379
- props.columnSorter.external)) {
15380
- return filteredTable.value;
15381
- }
15382
- //if values in column are to be sorted by numeric value they all have to be type number
15383
- // const flip = sorterState.asc ? 1 : -1
15384
- const flip = sorterState.state === 'asc' ? 1 : sorterState.state === 'desc' ? -1 : 0;
15385
- const sorted = filteredTable.value.slice().sort((item, item2) => {
15386
- const value = item[col];
15387
- const value2 = item2[col];
15388
- const a = typeof value === 'number' ? value : String(value).toLowerCase();
15389
- const b = typeof value2 === 'number' ? value2 : String(value2).toLowerCase();
15390
- return a > b ? 1 * flip : b > a ? -1 * flip : 0;
15391
- });
15392
- return sorted;
15393
- });
15306
+ const columnNames = computed(() => getColumnNames(props.columns, items.value));
15307
+ const itemsDataColumns = computed(() => columnNames.value.filter((name) => getColumnNamesFromItems(items.value).includes(name)));
15308
+ const filteredColumns = computed(() => filterColumns(items.value, props.columnFilter, columnFilterState.value, itemsDataColumns.value));
15309
+ const filteredTable = computed(() => filterTable(filteredColumns.value, props.tableFilter, tableFilterState.value, itemsDataColumns.value));
15310
+ const sortedItems = computed(() => sortItems(props.columnSorter, filteredTable.value, itemsDataColumns.value, sorterState.value));
15394
15311
  const numberOfPages = computed(() => itemsPerPage.value ? Math.ceil(sortedItems.value.length / itemsPerPage.value) : 1);
15395
15312
  const firstItemOnActivePageIndex = computed(() => activePage.value ? (activePage.value - 1) * itemsPerPage.value : 0);
15396
- const itemsOnActivePage = computed(() => sortedItems.value.slice(firstItemOnActivePageIndex.value, firstItemOnActivePageIndex.value + itemsPerPage.value));
15397
- const currentItems = computed(() => activePage.value ? itemsOnActivePage.value : sortedItems.value);
15398
- const isFiltered = computed(() => {
15399
- return (tableFilterState.value ||
15400
- sorterState.column ||
15401
- Object.values(columnFilterState.value).join(''));
15402
- });
15313
+ const currentItems = computed(() => activePage.value
15314
+ ? sortedItems.value.slice(firstItemOnActivePageIndex.value, firstItemOnActivePageIndex.value + itemsPerPage.value)
15315
+ : sortedItems.value);
15403
15316
  return () => h$1('div', {}, [
15404
15317
  (props.tableFilter || props.cleaner) &&
15405
15318
  h$1('div', {
@@ -15409,25 +15322,46 @@ const CSmartTable = defineComponent({
15409
15322
  h$1('div', {
15410
15323
  class: 'col-auto p-0',
15411
15324
  }, props.tableFilter &&
15412
- h$1(CSmartTableFilter, {
15413
- filterLabel: props.tableFilterLabel,
15414
- filterPlaceholder: props.tableFilterPlaceholder,
15415
- onFilterInput: (value) => tableFilterChange(value, 'input'),
15416
- onFilterChange: (value) => tableFilterChange(value, 'change'),
15417
- value: tableFilterState.value,
15325
+ h$1('div', {
15326
+ class: 'row mb-2',
15327
+ }, {
15328
+ default: () => [
15329
+ h$1(CFormLabel, {
15330
+ class: 'col-sm-auto col-form-label',
15331
+ }, {
15332
+ default: () => props.tableFilterLabel,
15333
+ }),
15334
+ h$1('div', {
15335
+ class: 'col-sm-auto',
15336
+ }, h$1(CFormInput, {
15337
+ onInput: (e) => {
15338
+ handleTableFilterChange(e.target.value, 'input');
15339
+ },
15340
+ onChange: (e) => {
15341
+ handleTableFilterChange(e.target.value, 'change');
15342
+ },
15343
+ placeholder: props.tableFilterPlaceholder,
15344
+ value: tableFilterState.value,
15345
+ })),
15346
+ ],
15418
15347
  })),
15419
15348
  props.cleaner &&
15420
15349
  h$1('div', {
15421
15350
  class: 'col-auto p-0',
15422
- }, h$1(CSmartTableCleaner, {
15423
- onClick: () => clean(),
15424
- isFiltered: isFiltered.value,
15425
- }, {
15426
- // @slot Cleaner icon.
15427
- cleanerIcon: () => slots.cleanerIcon
15428
- ? slots.cleanerIcon()
15429
- : h$1(CIcon, { width: '18', content: cilFilterX }),
15430
- })),
15351
+ }, h$1('button', {
15352
+ type: 'button',
15353
+ class: 'btn btn-transparent',
15354
+ ...(!(tableFilterState.value ||
15355
+ sorterState.value.column ||
15356
+ Object.values(columnFilterState.value).join('')) && { disabled: true, tabIndex: -1 }),
15357
+ onClick: () => handleClean(),
15358
+ onKeydown: (event) => {
15359
+ if (event.key === 'Enter')
15360
+ handleClean();
15361
+ },
15362
+ }, slots.cleanerIcon
15363
+ ? slots.cleanerIcon()
15364
+ : h$1(CIcon, { width: '18', content: cilFilterX }))),
15431
15365
  ]),
15432
15366
  h$1('div', {
15433
15367
  class: 'position-relative',
@@ -15443,17 +15377,18 @@ const CSmartTable = defineComponent({
15443
15377
  ...props.tableHeadProps,
15444
15378
  columnFilter: props.columnFilter,
15445
15379
  columnFilterValue: columnFilterState.value,
15446
- columns: props.columns ? props.columns : rawColumnNames.value,
15380
+ columns: props.columns ? props.columns : columnNames.value,
15447
15381
  columnSorter: props.columnSorter,
15448
15382
  items: items.value,
15449
15383
  selectable: props.selectable,
15450
- selectAll: selectedAll.value,
15451
- sorterState: sorterState,
15452
- onCustomFilterChange: (key, value) => columnFilterChange(key, value),
15453
- onFilterInput: (key, value) => columnFilterChange(key, value, 'input'),
15454
- onFilterChange: (key, value) => columnFilterChange(key, value, 'change'),
15384
+ selectAll: props.selectAll,
15385
+ selectedAll: selectedAll.value,
15386
+ sorterState: sorterState.value,
15387
+ onCustomFilterChange: (key, value) => handleColumnFilterChange(key, value),
15388
+ onFilterInput: (key, value) => handleColumnFilterChange(key, value, 'input'),
15389
+ onFilterChange: (key, value) => handleColumnFilterChange(key, value, 'change'),
15455
15390
  onSelectAllChecked: () => handleSelectAllChecked(),
15456
- onSortClick: (key, index) => sorterChange(key, index),
15391
+ onSortClick: (key, index) => handleSorterChange(key, index),
15457
15392
  }, {
15458
15393
  // @slot Sorter icon when items are unsorted.
15459
15394
  sortingIcon: () => slots.sortingIcon
@@ -15468,36 +15403,35 @@ const CSmartTable = defineComponent({
15468
15403
  // @slot Sorter icon when items are sorted ascending.
15469
15404
  sortingIconAscending: () => slots.sortingIconAscending
15470
15405
  ? slots.sortingIconAscending()
15471
- : // : h(CIcon, { content: cilArrowBottom }, 'b'),
15472
- h$1('svg', {
15473
- xmlns: 'http://www.w3.org/2000/svg',
15474
- class: 'icon',
15475
- viewBox: '0 0 512 512',
15476
- role: 'img',
15477
- innerHTML: cilArrowBottom[1],
15478
- }),
15406
+ : h$1('svg', {
15407
+ xmlns: 'http://www.w3.org/2000/svg',
15408
+ class: 'icon',
15409
+ viewBox: '0 0 512 512',
15410
+ role: 'img',
15411
+ innerHTML: cilArrowBottom[1],
15412
+ }),
15479
15413
  // @slot Sorter icon when items are sorted descending.
15480
15414
  sortingIconDescending: () => slots.sortingIconDescending
15481
15415
  ? slots.sortingIconDescending()
15482
- : // : h(CIcon, { content: cilArrowTop }, 'c'),
15483
- h$1('svg', {
15484
- xmlns: 'http://www.w3.org/2000/svg',
15485
- class: 'icon',
15486
- viewBox: '0 0 512 512',
15487
- role: 'img',
15488
- innerHTML: cilArrowTop[1],
15489
- }),
15416
+ : h$1('svg', {
15417
+ xmlns: 'http://www.w3.org/2000/svg',
15418
+ class: 'icon',
15419
+ viewBox: '0 0 512 512',
15420
+ role: 'img',
15421
+ innerHTML: cilArrowTop[1],
15422
+ }),
15490
15423
  }),
15491
15424
  h$1(CSmartTableBody, {
15425
+ clickableRows: props.clickableRows,
15426
+ columnNames: columnNames.value,
15492
15427
  currentItems: currentItems.value,
15493
15428
  firstItemOnActivePageIndex: firstItemOnActivePageIndex.value,
15494
15429
  noItemsLabel: props.noItemsLabel,
15430
+ onRowChecked: (item, value) => handleRowChecked(item, value),
15431
+ onRowClick: (item, index, columnName, event) => props.clickableRows && emit('rowClick', item, index, columnName, event),
15495
15432
  scopedSlots: slots,
15496
15433
  selectable: props.selectable,
15497
- onRowChecked: (id, value) => handleRowChecked(id, value),
15498
- onRowClick: (item, index, columnName, event) => handleRowClick(item, index, columnName, event),
15499
- rawColumnNames: rawColumnNames.value,
15500
- clickableRows: props.clickableRows,
15434
+ selected: selected.value,
15501
15435
  ...props.tableBodyProps,
15502
15436
  }),
15503
15437
  typeof props.footer === 'boolean' &&
@@ -15507,9 +15441,10 @@ const CSmartTable = defineComponent({
15507
15441
  ...props.tableFootProps,
15508
15442
  columnFilter: false,
15509
15443
  columnSorter: false,
15510
- columns: props.columns ? props.columns : rawColumnNames.value,
15444
+ columns: props.columns ? props.columns : columnNames.value,
15511
15445
  selectable: props.selectable,
15512
- selectAll: selectedAll.value,
15446
+ selectAll: props.selectAll,
15447
+ selectedAll: selectedAll.value,
15513
15448
  onSelectAllChecked: () => handleSelectAllChecked(),
15514
15449
  }),
15515
15450
  Array.isArray(props.footer) &&
@@ -15536,6 +15471,11 @@ const CSmartTable = defineComponent({
15536
15471
  { sides: ['top'], query: 'tbody' },
15537
15472
  { sides: ['bottom'], query: 'tbody' },
15538
15473
  ],
15474
+ }, {
15475
+ // @slot elementCover.
15476
+ ...(slots.elementCover && {
15477
+ default: () => slots.elementCover && slots.elementCover(),
15478
+ }),
15539
15479
  }),
15540
15480
  ],
15541
15481
  }),
@@ -15558,14 +15498,33 @@ const CSmartTable = defineComponent({
15558
15498
  h$1('div', {
15559
15499
  class: 'col-auto ms-auto',
15560
15500
  }, props.itemsPerPageSelect &&
15561
- h$1(CSmartTableItemsPerPageSelector, {
15562
- itemsPerPage: itemsPerPage.value,
15563
- itemsPerPageLabel: props.itemsPerPageLabel,
15564
- itemsPerPageOptions: props.itemsPerPageOptions,
15565
- onChangeItemsPerPage: handleItemsPerPageChange,
15501
+ h$1('div', {
15502
+ class: 'row',
15503
+ }, {
15504
+ default: () => [
15505
+ h$1(CFormLabel, {
15506
+ class: 'col-auto col-form-label',
15507
+ }, {
15508
+ default: () => props.itemsPerPageLabel,
15509
+ }),
15510
+ h$1('div', {
15511
+ class: 'col-auto',
15512
+ }, h$1(CFormSelect, {
15513
+ value: itemsPerPage.value,
15514
+ onChange: handleItemsPerPageChange,
15515
+ }, {
15516
+ default: () => props.itemsPerPageOptions &&
15517
+ props.itemsPerPageOptions.map((number, index) => {
15518
+ return h$1('option', {
15519
+ value: number,
15520
+ key: index,
15521
+ }, number);
15522
+ }),
15523
+ })),
15524
+ ],
15566
15525
  })),
15567
15526
  ]),
15568
- ]); //h
15527
+ ]);
15569
15528
  },
15570
15529
  });
15571
15530