@ark-ui/vue
Version:
A collection of unstyled, accessible UI components for Vue, utilizing state machines for seamless interaction.
52 lines (47 loc) • 1.82 kB
JavaScript
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const vue = require('vue');
const autoResize = require('@zag-js/auto-resize');
const useForwardExpose = require('../../utils/use-forward-expose.cjs');
const factory = require('../factory.cjs');
const useFieldContext = require('./use-field-context.cjs');
const unrefElement = require('../../utils/unref-element.cjs');
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
__name: "field-textarea",
props: {
modelValue: {},
autoresize: { type: Boolean },
asChild: { type: Boolean }
},
emits: ["update:modelValue"],
setup(__props, { emit: __emit }) {
const props = __props;
const field = useFieldContext.useFieldContext();
const emit = __emit;
const textareaRef = vue.ref();
vue.onMounted(() => {
const node = unrefElement.unrefElement(textareaRef);
if (!node || !props.autoresize) return;
const cleanup = autoResize.autoresizeTextarea(node);
vue.onBeforeUnmount(() => cleanup?.());
});
useForwardExpose.useForwardExpose();
return (_ctx, _cache) => {
return vue.openBlock(), vue.createBlock(vue.unref(factory.ark).textarea, vue.mergeProps({
ref_key: "textareaRef",
ref: textareaRef
}, vue.unref(field).getTextareaProps(), {
value: _ctx.modelValue,
onInput: _cache[0] || (_cache[0] = (event) => emit("update:modelValue", event.target.value)),
style: props.autoresize ? { resize: "none", overflow: "hidden" } : void 0,
"as-child": _ctx.asChild
}), {
default: vue.withCtx(() => [
vue.renderSlot(_ctx.$slots, "default")
]),
_: 3
}, 16, ["value", "style", "as-child"]);
};
}
});
exports.default = _sfc_main;
;