UNPKG

@shopware-ag/meteor-component-library

Version:

The meteor component library is a Vue component library developed by Shopware. It is based on the [Meteor Design System](https://shopware.design/).

121 lines (120 loc) 4.91 kB
import '../mt-textarea.css'; import { defineComponent, mergeModels, useModel, openBlock, createElementBlock, createBlock, unref, withCtx, createTextVNode, toDisplayString, createCommentVNode, withDirectives, createElementVNode, normalizeClass, vModelText, renderSlot } from "vue"; import { u as useId } from "../useId-90f9ff46.mjs"; import MtFieldLabel from "./MtFieldLabel.js"; import MtFieldError from "./MtFieldError.js"; import MtHelpText from "./MtHelpText.js"; import { _ as _export_sfc } from "../_plugin-vue_export-helper-cc2b3d55.mjs"; import "../id-1e5b8276.mjs"; import "./MtInheritanceSwitch.js"; import "../mt-icon.vue_vue_type_style_index_0_lang-2cc5f73e.mjs"; import "./MtTooltip.js"; import "../floating-ui.vue-fe27ebef.mjs"; import "../floating-ui.dom-f450fda4.mjs"; import "../useIsInsideTooltip-0c3bd290.mjs"; import "../index-221bad05.mjs"; import "vue-i18n"; import "./MtText.js"; const _hoisted_1 = { class: "mt-textarea" }; const _hoisted_2 = ["id", "required", "disabled", "name", "placeholder", "maxlength"]; const _hoisted_3 = { key: 3, class: "mt-textarea__hint" }; const _hoisted_4 = { key: 4, class: "mt-textarea__max-length" }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "mt-textarea", props: /* @__PURE__ */ mergeModels({ required: { type: Boolean }, disabled: { type: Boolean }, name: {}, label: {}, placeholder: {}, error: {}, helpText: {}, maxLength: {}, isInherited: { type: Boolean }, isInheritanceField: { type: Boolean } }, { "modelValue": { type: String }, "modelModifiers": {} }), emits: /* @__PURE__ */ mergeModels(["change", "inheritance-remove", "inheritance-restore", "focus", "blur"], ["update:modelValue"]), setup(__props) { const model = useModel(__props, "modelValue"); const id = useId(); return (_ctx, _cache) => { var _a; return openBlock(), createElementBlock("div", _hoisted_1, [ !!_ctx.label ? (openBlock(), createBlock(MtFieldLabel, { key: 0, for: unref(id), required: _ctx.required, "has-error": !!_ctx.error && !!_ctx.error.detail, inheritance: !_ctx.isInheritanceField ? "none" : _ctx.isInherited ? "linked" : "unlinked", style: { gridArea: "label", marginBottom: "var(--scale-size-2)" }, "onUpdate:inheritance": _cache[0] || (_cache[0] = ($event) => { if (_ctx.isInherited) { _ctx.$emit("inheritance-remove"); } else { _ctx.$emit("inheritance-restore"); } }) }, { default: withCtx(() => [ createTextVNode(toDisplayString(_ctx.label), 1) ]), _: 1 }, 8, ["for", "required", "has-error", "inheritance"])) : createCommentVNode("", true), !!_ctx.helpText ? (openBlock(), createBlock(MtHelpText, { key: 1, text: _ctx.helpText, style: { gridArea: "help-text", justifySelf: "end" } }, null, 8, ["text"])) : createCommentVNode("", true), withDirectives(createElementVNode("textarea", { "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => model.value = $event), class: normalizeClass([ "mt-textarea__textarea", { "mt-textarea__textarea--error": !!_ctx.error && !!_ctx.error.detail } ]), onChange: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("change", model.value)), onFocus: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("focus")), onBlur: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("blur")), id: unref(id), required: _ctx.required, disabled: _ctx.disabled || _ctx.isInherited, name: _ctx.name, placeholder: _ctx.placeholder, maxlength: _ctx.maxLength }, null, 42, _hoisted_2), [ [vModelText, model.value] ]), !!_ctx.error && !!_ctx.error.detail ? (openBlock(), createBlock(MtFieldError, { key: 2, error: _ctx.error, style: { gridArea: "error" } }, null, 8, ["error"])) : createCommentVNode("", true), !!_ctx.$slots.hint ? (openBlock(), createElementBlock("div", _hoisted_3, [ renderSlot(_ctx.$slots, "hint", {}, void 0, true) ])) : createCommentVNode("", true), !!_ctx.maxLength ? (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(((_a = model.value) == null ? void 0 : _a.length) ?? 0) + "/" + toDisplayString(_ctx.maxLength), 1)) : createCommentVNode("", true) ]); }; } }); const mtTextarea_vue_vue_type_style_index_0_scoped_59f3eb48_lang = ""; const mtTextarea = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-59f3eb48"]]); export { mtTextarea as default }; //# sourceMappingURL=MtTextarea.js.map