UNPKG

@nextcloud/vue

Version:
141 lines (140 loc) 4.65 kB
import '../assets/NcActionTextEditable-TPYz4ma-.css'; import { m as mdiArrowRight } from "./mdi-XFJRiRqJ.mjs"; import { A as ActionTextMixin } from "./actionText-DYzDdbVe.mjs"; import { c as createElementId } from "./createElementId-DhjFt1I9.mjs"; import { N as NcIconSvgWrapper } from "./NcIconSvgWrapper-BvLanNaW.mjs"; import { resolveComponent, createElementBlock, openBlock, normalizeClass, createElementVNode, renderSlot, normalizeStyle, withModifiers, createCommentVNode, withDirectives, toDisplayString, mergeProps, createVNode, vShow } from "vue"; import { _ as _export_sfc } from "./_plugin-vue_export-helper-1tPrXgE0.mjs"; const _sfc_main = { name: "NcActionTextEditable", components: { NcIconSvgWrapper }, mixins: [ActionTextMixin], props: { /** * id attribute of the checkbox element */ id: { type: String, default: () => "action-" + createElementId(), validator: (id) => id.trim() !== "" }, /** * disabled state of the text area */ disabled: { type: Boolean, default: false }, /** * value attribute of the input field */ modelValue: { type: String, default: "" } }, emits: [ "input", "update:modelValue", "submit" ], setup() { return { mdiArrowRight }; }, computed: { /** * determines if the action is focusable * * @return {boolean} is the action focusable ? */ isFocusable() { return !this.disabled; }, computedId() { return createElementId(); } }, methods: { onInput(event) { this.$emit("input", event); this.$emit("update:modelValue", event.target.value); }, onSubmit(event) { event.preventDefault(); event.stopPropagation(); if (!this.disabled) { this.$emit("submit", event); } else { return false; } } } }; const _hoisted_1 = ["disabled"]; const _hoisted_2 = ["id"]; const _hoisted_3 = ["for"]; const _hoisted_4 = ["id", "disabled", "value"]; const _hoisted_5 = ["for"]; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { const _component_NcIconSvgWrapper = resolveComponent("NcIconSvgWrapper"); return openBlock(), createElementBlock("li", { class: normalizeClass(["action", { "action--disabled": $props.disabled }]) }, [ createElementVNode("span", { class: "action-text-editable", onClick: _cache[2] || (_cache[2] = (...args) => _ctx.onClick && _ctx.onClick(...args)) }, [ renderSlot(_ctx.$slots, "icon", {}, () => [ createElementVNode("span", { class: normalizeClass([[_ctx.isIconUrl ? "action-text-editable__icon--url" : _ctx.icon], "action-text-editable__icon"]), style: normalizeStyle({ backgroundImage: _ctx.isIconUrl ? `url(${_ctx.icon})` : null }) }, null, 6) ], true), createElementVNode("form", { ref: "form", class: "action-text-editable__form", disabled: $props.disabled, onSubmit: _cache[1] || (_cache[1] = withModifiers((...args) => $options.onSubmit && $options.onSubmit(...args), ["prevent"])) }, [ createElementVNode("input", { id: $props.id, type: "submit", class: "action-text-editable__submit" }, null, 8, _hoisted_2), _ctx.name ? (openBlock(), createElementBlock("label", { key: 0, class: "action-text-editable__name", for: $options.computedId }, toDisplayString(_ctx.name), 9, _hoisted_3)) : createCommentVNode("", true), createElementVNode("textarea", mergeProps({ id: $options.computedId, class: ["action-text-editable__textarea", [{ focusable: $options.isFocusable }]], disabled: $props.disabled, value: $props.modelValue }, _ctx.$attrs, { onInput: _cache[0] || (_cache[0] = (...args) => $options.onInput && $options.onInput(...args)) }), null, 16, _hoisted_4), withDirectives(createElementVNode("label", { for: $props.id, class: "action-text-editable__label" }, [ createVNode(_component_NcIconSvgWrapper, { directional: "", path: $setup.mdiArrowRight }, null, 8, ["path"]) ], 8, _hoisted_5), [ [vShow, !$props.disabled] ]) ], 40, _hoisted_1) ]) ], 2); } const NcActionTextEditable = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-24e8b746"]]); export { NcActionTextEditable as N }; //# sourceMappingURL=NcActionTextEditable-CoYA6jeC.mjs.map