Group.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
  2. import { createVNode as _createVNode } from "vue";
  3. import { computed, defineComponent } from 'vue';
  4. import { FormItemInputContext } from '../form/FormItemContext';
  5. import useConfigInject from '../config-provider/hooks/useConfigInject';
  6. import classNames from '../_util/classNames';
  7. // CSSINJS
  8. import useStyle from './style';
  9. export default defineComponent({
  10. compatConfig: {
  11. MODE: 3
  12. },
  13. name: 'AInputGroup',
  14. inheritAttrs: false,
  15. props: {
  16. prefixCls: String,
  17. size: {
  18. type: String
  19. },
  20. compact: {
  21. type: Boolean,
  22. default: undefined
  23. }
  24. },
  25. setup(props, _ref) {
  26. let {
  27. slots,
  28. attrs
  29. } = _ref;
  30. const {
  31. prefixCls,
  32. direction,
  33. getPrefixCls
  34. } = useConfigInject('input-group', props);
  35. const formItemInputContext = FormItemInputContext.useInject();
  36. FormItemInputContext.useProvide(formItemInputContext, {
  37. isFormItemInput: false
  38. });
  39. // style
  40. const inputPrefixCls = computed(() => getPrefixCls('input'));
  41. const [wrapSSR, hashId] = useStyle(inputPrefixCls);
  42. const cls = computed(() => {
  43. const pre = prefixCls.value;
  44. return {
  45. [`${pre}`]: true,
  46. [hashId.value]: true,
  47. [`${pre}-lg`]: props.size === 'large',
  48. [`${pre}-sm`]: props.size === 'small',
  49. [`${pre}-compact`]: props.compact,
  50. [`${pre}-rtl`]: direction.value === 'rtl'
  51. };
  52. });
  53. return () => {
  54. var _a;
  55. return wrapSSR(_createVNode("span", _objectSpread(_objectSpread({}, attrs), {}, {
  56. "class": classNames(cls.value, attrs.class)
  57. }), [(_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)]));
  58. };
  59. }
  60. });