useMergedPickerSemantic.js 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. import * as React from 'react';
  2. import cls from 'classnames';
  3. import useMergeSemantic from '../../_util/hooks/useMergeSemantic';
  4. import { useComponentConfig } from '../../config-provider/context';
  5. const useMergedPickerSemantic = (pickerType, classNames, styles, popupClassName, popupStyle) => {
  6. const {
  7. classNames: contextClassNames,
  8. styles: contextStyles
  9. } = useComponentConfig(pickerType);
  10. const [mergedClassNames, mergedStyles] = useMergeSemantic([contextClassNames, classNames], [contextStyles, styles], {
  11. popup: {
  12. _default: 'root'
  13. }
  14. });
  15. return React.useMemo(() => {
  16. var _a, _b;
  17. // ClassNames
  18. const filledClassNames = Object.assign(Object.assign({}, mergedClassNames), {
  19. popup: Object.assign(Object.assign({}, mergedClassNames.popup), {
  20. root: cls((_a = mergedClassNames.popup) === null || _a === void 0 ? void 0 : _a.root, popupClassName)
  21. })
  22. });
  23. // Styles
  24. const filledStyles = Object.assign(Object.assign({}, mergedStyles), {
  25. popup: Object.assign(Object.assign({}, mergedStyles.popup), {
  26. root: Object.assign(Object.assign({}, (_b = mergedStyles.popup) === null || _b === void 0 ? void 0 : _b.root), popupStyle)
  27. })
  28. });
  29. // Return
  30. return [filledClassNames, filledStyles];
  31. }, [mergedClassNames, mergedStyles, popupClassName, popupStyle]);
  32. };
  33. export default useMergedPickerSemantic;