UNPKG

@nextcloud/vue

Version:
166 lines (165 loc) 5.5 kB
"use strict"; const NcInputField = require("./NcInputField-DkhKrb8k.cjs"); const Close = require("./Close-CqmXxEKi.cjs"); const ArrowRight = require("./ArrowRight-DPARnmu3.cjs"); const _pluginVue2_normalizer = require("./_plugin-vue2_normalizer-V0q-tHlQ.cjs"); const _l10n = require("./_l10n-CjO_W5Dt.cjs"); const useModelMigration = require("./useModelMigration-D5zhrNXr.cjs"); const _sfc_main$1 = { name: "UndoVariantIcon", emits: ["click"], props: { title: { type: String }, fillColor: { type: String, default: "currentColor" }, size: { type: Number, default: 24 } } }; var _sfc_render$1 = function render() { var _vm = this, _c = _vm._self._c; return _c("span", _vm._b({ staticClass: "material-design-icon undo-variant-icon", attrs: { "aria-hidden": _vm.title ? null : "true", "aria-label": _vm.title, "role": "img" }, on: { "click": function($event) { return _vm.$emit("click", $event); } } }, "span", _vm.$attrs, false), [_c("svg", { staticClass: "material-design-icon__svg", attrs: { "fill": _vm.fillColor, "width": _vm.size, "height": _vm.size, "viewBox": "0 0 24 24" } }, [_c("path", { attrs: { "d": "M13.5,7A6.5,6.5 0 0,1 20,13.5A6.5,6.5 0 0,1 13.5,20H10V18H13.5C16,18 18,16 18,13.5C18,11 16,9 13.5,9H7.83L10.91,12.09L9.5,13.5L4,8L9.5,2.5L10.92,3.91L7.83,7H13.5M6,18H8V20H6V18Z" } }, [_vm.title ? _c("title", [_vm._v(_vm._s(_vm.title))]) : _vm._e()])])]); }; var _sfc_staticRenderFns$1 = []; var __component__$1 = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$1, _sfc_render$1, _sfc_staticRenderFns$1, false, null, null ); const Undo = __component__$1.exports; _l10n.register(_l10n.t16, _l10n.t47); const NcInputFieldProps = new Set(Object.keys(NcInputField.NcInputField.props)); const _sfc_main = { name: "NcTextField", components: { NcInputField: NcInputField.NcInputField, Close: Close.Close, ArrowRight: ArrowRight.ArrowRight, Undo }, // Allow forwarding all attributes inheritAttrs: false, model: { prop: "modelValue", event: "update:modelValue" }, props: { /** * Any [NcInputField](#/Components/NcFields?id=ncinputfield) props */ // Not an actual prop but needed to show in vue-styleguidist docs // eslint-disable-next-line " ": {}, // Reuse all the props from NcInputField for better typing and documentation ...NcInputField.NcInputField.props, /** * The `aria-label` to set on the trailing button * If no explicit value is set it will default to the one matching the `trailingButtonIcon`: * @default 'Clear text'|'Save changes'|'Undo changes' */ trailingButtonLabel: { type: String, default: "" }, // Custom props /** * Specifies which material design icon should be used for the trailing * button. * @type {'close'|'arrowRight'|'undo'} */ trailingButtonIcon: { type: String, default: "close", validator: (value) => [ "close", "arrowRight", "undo" ].includes(value) } }, emits: [ /** * Removed in v9 - use `update:modelValue` (`v-model`) instead * @deprecated */ "update:value", "update:modelValue", /** Same as update:modelValue for Vue 2 compatibility */ "update:model-value" ], setup() { const model = useModelMigration.useModelMigration("value", "update:value"); return { model }; }, computed: { propsAndAttrsToForward() { const predefinedLabels = { undo: _l10n.t("Undo changes"), close: _l10n.t("Clear text"), arrowRight: _l10n.t("Save changes") }; return { // Proxy all the HTML attributes ...this.$attrs, // Proxy original NcInputField's props ...Object.fromEntries( Object.entries(this.$props).filter(([key]) => NcInputFieldProps.has(key)) ), // Adjust aria-label for predefined trailing buttons trailingButtonLabel: this.trailingButtonLabel || predefinedLabels[this.trailingButtonIcon] }; } }, methods: { /** * Focus the input element * * @public */ focus() { this.$refs.inputField.focus(); }, /** * Select all the text in the input * * @public */ select() { this.$refs.inputField.select(); } } }; var _sfc_render = function render2() { var _vm = this, _c = _vm._self._c; return _c("NcInputField", _vm._g(_vm._b({ ref: "inputField", scopedSlots: _vm._u([!!_vm.$scopedSlots.icon || !!_vm.$slots.default || !!_vm.$scopedSlots.default ? { key: "icon", fn: function() { return [_vm._t("icon", function() { return [_vm._t("default")]; })]; }, proxy: true } : null, _vm.type !== "search" ? { key: "trailing-button-icon", fn: function() { return [_vm.trailingButtonIcon === "close" ? _c("Close", { attrs: { "size": 20 } }) : _vm.trailingButtonIcon === "arrowRight" ? _c("ArrowRight", { attrs: { "size": 20 } }) : _vm.trailingButtonIcon === "undo" ? _c("Undo", { attrs: { "size": 20 } }) : _vm._e()]; }, proxy: true } : null], null, true) }, "NcInputField", _vm.propsAndAttrsToForward, false), _vm.$listeners)); }; var _sfc_staticRenderFns = []; var __component__ = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, null ); const NcTextField = __component__.exports; exports.NcTextField = NcTextField;