UNPKG

@opentiny/vue-renderless

Version:

An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.

38 lines (37 loc) 1.22 kB
import "../chunk-G2ADBYYC.js"; import { handleClick, clearTimer } from "./index"; const api = ["state", "handleClick"]; const renderless = (props, { computed, onBeforeUnmount, reactive, watch, inject }, { emit, parent, designConfig }) => { parent.tinyForm = parent.tinyForm || inject("form", null); const state = reactive({ timer: 0, disabled: props.disabled, plain: computed(() => props.plain || (parent.buttonGroup || {}).plain), round: computed(() => { var _a, _b, _c; return (_c = (_b = props.round) != null ? _b : (_a = designConfig == null ? void 0 : designConfig.props) == null ? void 0 : _a.round) != null ? _c : false; }), formDisabled: computed(() => (parent.tinyForm || {}).disabled), buttonDisabled: computed( () => props.disabled || state.disabled || (parent.buttonGroup || {}).disabled || state.formDisabled ) }); watch( () => props.disabled, (value) => { state.disabled = value; }, { immediate: true } ); const api2 = { state, clearTimer: clearTimer(state), handleClick: handleClick({ emit, props, state, designConfig }) }; onBeforeUnmount(api2.clearTimer); return api2; }; export { api, renderless };