"use strict"; const Vue = require("vue"); const Components_NcButton = require("../Components/NcButton.cjs"); const NcIconSvgWrapper = require("./NcIconSvgWrapper-B_eOG2sZ.cjs"); const Components_NcLoadingIcon = require("../Components/NcLoadingIcon.cjs"); const _l10n = require("./_l10n-CjO_W5Dt.cjs"); const _pluginVue2_normalizer = require("./_plugin-vue2_normalizer-V0q-tHlQ.cjs"); _l10n.register(_l10n.t30); const _sfc_main = { __name: "NcDialogButton", props: { /** * The function that will be called when the button is pressed. * If the function returns `false` the click is ignored and the dialog will not be closed. * @type {() => unknown|false|Promise} */ callback: { type: Function, required: false, default: () => { } }, /** * The label of the button */ label: { type: String, required: true }, /** * Optional inline SVG icon for the button */ icon: { type: String, required: false, default: void 0 }, /** * The button type, see NcButton * @type {'primary'|'secondary'|'error'|'warning'|'success'} */ type: { type: String, required: false, default: "secondary", validator: (type) => typeof type === "string" && ["primary", "secondary", "tertiary", "error", "warning", "success"].includes(type) }, /** * See `nativeType` of `NcButton` */ nativeType: { type: String, required: false, default: "button", validator(value) { return ["submit", "reset", "button"].includes(value); } }, /** * If the button should be shown as disabled */ disabled: { type: Boolean, default: false } }, emits: ["click"], setup(__props, { emit }) { const props = __props; const isLoading = Vue.ref(false); const handleClick = async (e) => { if (isLoading.value) { return; } isLoading.value = true; try { const result = await props.callback?.(); if (result !== false) { emit("click", e, result); } } finally { isLoading.value = false; } }; return { __sfc: true, props, emit, isLoading, handleClick, NcButton: Components_NcButton, NcIconSvgWrapper: NcIconSvgWrapper.NcIconSvgWrapper, NcLoadingIcon: Components_NcLoadingIcon, t: _l10n.t }; } }; var _sfc_render = function render() { var _vm = this, _c = _vm._self._c, _setup = _vm._self._setupProxy; return _c(_setup.NcButton, { attrs: { "aria-label": _vm.label, "disabled": _vm.disabled, "native-type": _vm.nativeType, "type": _vm.type }, on: { "click": _setup.handleClick }, scopedSlots: _vm._u([{ key: "icon", fn: function() { return [_vm._t("icon", function() { return [_setup.isLoading ? _c(_setup.NcLoadingIcon, { attrs: { "name": _setup.t("Loading …") /* TRANSLATORS: The button is in a loading state*/ } }) : _vm.icon !== void 0 ? _c(_setup.NcIconSvgWrapper, { attrs: { "svg": _vm.icon } }) : _vm._e()]; })]; }, proxy: true }], null, true) }, [_vm._v(" " + _vm._s(_vm.label) + " ")]); }; var _sfc_staticRenderFns = []; var __component__ = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, null ); const NcDialogButton = __component__.exports; exports.NcDialogButton = NcDialogButton;