@ark-ui/vue
Version:
A collection of unstyled, accessible UI components for Vue, utilizing state machines for seamless interaction.
53 lines (46 loc) • 1.73 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const clipboard = require('@zag-js/clipboard');
const vue$1 = require('@zag-js/vue');
const vue = require('vue');
const useEnvironmentContext = require('../../providers/environment/use-environment-context.cjs');
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 clipboard__namespace = /*#__PURE__*/_interopNamespaceDefault(clipboard);
const useClipboard = (props = {}, emit) => {
const id = vue.useId();
const env = useEnvironmentContext.useEnvironmentContext(useEnvironmentContext.DEFAULT_ENVIRONMENT);
const context = vue.computed(() => {
const localeProps = vue.toValue(props);
return {
id,
getRootNode: env?.value.getRootNode,
value: localeProps.modelValue,
onStatusChange: (details) => emit?.("statusChange", details),
...cleanProps.cleanProps(localeProps),
onValueChange(details) {
emit?.("valueChange", details);
emit?.("update:modelValue", details.value);
localeProps.onValueChange?.(details);
}
};
});
const service = vue$1.useMachine(clipboard__namespace.machine, context);
return vue.computed(() => clipboard__namespace.connect(service, vue$1.normalizeProps));
};
exports.useClipboard = useClipboard;