@ark-ui/vue
Version:
A collection of unstyled, accessible UI components for Vue, utilizing state machines for seamless interaction.
46 lines (39 loc) • 1.31 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const toggle = require('@zag-js/toggle');
const vue$1 = require('@zag-js/vue');
const vue = require('vue');
const cleanProps = require('../../utils/clean-props.cjs');
function _interopNamespaceDefault(e) {
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
if (e) {
for (const k in e) {
if (k !== 'default') {
const d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: () => e[k]
});
}
}
}
n.default = e;
return Object.freeze(n);
}
const toggle__namespace = /*#__PURE__*/_interopNamespaceDefault(toggle);
function useToggle(props, emit) {
const machineProps = vue.computed(() => {
const localProps = vue.toValue(props);
return {
...cleanProps.cleanProps(localProps),
onPressedChange: (value) => {
emit?.("pressedChange", value);
emit?.("update:pressed", value);
localProps.onPressedChange?.(value);
}
};
});
const service = vue$1.useMachine(toggle__namespace.machine, machineProps);
return vue.computed(() => toggle__namespace.connect(service, vue$1.normalizeProps));
}
exports.useToggle = useToggle;