VChipGroup.mjs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import { createVNode as _createVNode, mergeProps as _mergeProps } from "vue";
  2. // Styles
  3. import "./VChipGroup.css";
  4. // Components
  5. import { makeVSlideGroupProps, VSlideGroup } from "../VSlideGroup/VSlideGroup.mjs"; // Composables
  6. import { makeComponentProps } from "../../composables/component.mjs";
  7. import { provideDefaults } from "../../composables/defaults.mjs";
  8. import { makeGroupProps, useGroup } from "../../composables/group.mjs";
  9. import { makeTagProps } from "../../composables/tag.mjs";
  10. import { makeThemeProps, provideTheme } from "../../composables/theme.mjs";
  11. import { makeVariantProps } from "../../composables/variant.mjs"; // Utilities
  12. import { toRef } from 'vue';
  13. import { deepEqual, genericComponent, propsFactory, useRender } from "../../util/index.mjs"; // Types
  14. export const VChipGroupSymbol = Symbol.for('vuetify:v-chip-group');
  15. export const makeVChipGroupProps = propsFactory({
  16. column: Boolean,
  17. filter: Boolean,
  18. valueComparator: {
  19. type: Function,
  20. default: deepEqual
  21. },
  22. ...makeVSlideGroupProps(),
  23. ...makeComponentProps(),
  24. ...makeGroupProps({
  25. selectedClass: 'v-chip--selected'
  26. }),
  27. ...makeTagProps(),
  28. ...makeThemeProps(),
  29. ...makeVariantProps({
  30. variant: 'tonal'
  31. })
  32. }, 'VChipGroup');
  33. export const VChipGroup = genericComponent()({
  34. name: 'VChipGroup',
  35. props: makeVChipGroupProps(),
  36. emits: {
  37. 'update:modelValue': value => true
  38. },
  39. setup(props, _ref) {
  40. let {
  41. slots
  42. } = _ref;
  43. const {
  44. themeClasses
  45. } = provideTheme(props);
  46. const {
  47. isSelected,
  48. select,
  49. next,
  50. prev,
  51. selected
  52. } = useGroup(props, VChipGroupSymbol);
  53. provideDefaults({
  54. VChip: {
  55. color: toRef(props, 'color'),
  56. disabled: toRef(props, 'disabled'),
  57. filter: toRef(props, 'filter'),
  58. variant: toRef(props, 'variant')
  59. }
  60. });
  61. useRender(() => {
  62. const slideGroupProps = VSlideGroup.filterProps(props);
  63. return _createVNode(VSlideGroup, _mergeProps(slideGroupProps, {
  64. "class": ['v-chip-group', {
  65. 'v-chip-group--column': props.column
  66. }, themeClasses.value, props.class],
  67. "style": props.style
  68. }), {
  69. default: () => [slots.default?.({
  70. isSelected,
  71. select,
  72. next,
  73. prev,
  74. selected: selected.value
  75. })]
  76. });
  77. });
  78. return {};
  79. }
  80. });
  81. //# sourceMappingURL=VChipGroup.mjs.map