UNPKG

linkmore-design

Version:

🌈 🚀lm组件库。🚀

77 lines (74 loc) 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _react = require("react"); const useCoreOptions = ({ state, dispatch, props }) => { // 初始化打开窗口重置数据 const onOpen = () => { dispatch({ type: 'init', props: { ...props, visible: true } }); dispatch({ type: 'changeVisible', visible: true }); }; const onClose = () => { dispatch({ type: 'changeVisible', visible: false }); }; const onUpdate = (rest = {}) => { const { filter = [], columns = [], size, cardMode, card = [] } = props || {}; dispatch({ type: 'update', props: { filter, columns, size, card, cardMode, ...rest } }); }; // 初始化重置参数 // useEffect(() => { // dispatch({ type: 'init', props }) // }, [props]) // 组件初始化挂载触发 (0, _react.useEffect)(() => { // props.onMount?.(); }, []); const CoreMethods = { onOpen, onClose }; const RefMethods = { getState: () => state, onUpdate }; return { CoreMethods, RefMethods }; }; var _default = useCoreOptions; exports.default = _default;