{"version":3,"file":"form-reset.vue2.mjs","sources":["../../../components/form/form-reset.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { Button } from '@/components/button'\n\nimport { computed, inject, toRef } from 'vue'\n\nimport { createIconProp, emitEvent, useLocale, useNameHelper, useProps } from '@vexip-ui/config'\nimport { isPromise } from '@vexip-ui/utils'\nimport { formResetProps } from './props'\nimport { FORM_ACTIONS } from './symbol'\n\ndefineOptions({ name: 'FormReset' })\n\nconst _props = defineProps(formResetProps)\nconst props = useProps('formReset', _props, {\n  size: null,\n  locale: null,\n  type: 'default',\n  label: null,\n  dashed: null,\n  text: null,\n  simple: null,\n  ghost: null,\n  disabled: null,\n  loading: null,\n  circle: null,\n  loadingIcon: createIconProp(),\n  loadingEffect: null,\n  icon: createIconProp(),\n  color: null,\n  buttonType: null,\n  block: null,\n  onBeforeReset: {\n    default: null,\n    isFunc: true\n  }\n})\n\nconst slots = defineSlots<{\n  default?: () => any,\n  icon?: () => any,\n  loading?: () => any\n}>()\n\nconst actions = inject(FORM_ACTIONS, null)\n\nconst nh = useNameHelper('form')\nconst locale = useLocale('form', toRef(props, 'locale'))\n\nconst isInherit = computed(() => !!actions || props.inherit)\n\nasync function handleReset() {\n  if (props.disabled) return\n\n  let result: unknown = true\n\n  if (typeof props.onBeforeReset === 'function') {\n    result = props.onBeforeReset()\n\n    if (isPromise(result)) {\n      result = await result\n    }\n  }\n\n  if (result !== false) {\n    actions?.reset()\n    emitEvent(props.onReset)\n  }\n}\n</script>\n\n<template>\n  <Button\n    v-bind=\"$attrs\"\n    :inherit=\"isInherit\"\n    :class=\"nh.be('reset')\"\n    :size=\"props.size\"\n    :type=\"props.type\"\n    :simple=\"props.simple\"\n    :ghost=\"props.ghost\"\n    :dashed=\"props.dashed\"\n    :text=\"props.text\"\n    :disabled=\"props.disabled\"\n    :loading=\"props.loading\"\n    :circle=\"props.circle\"\n    :loading-icon=\"props.loadingIcon\"\n    :loading-effect=\"props.loadingEffect\"\n    :icon=\"props.icon\"\n    :color=\"props.color\"\n    :button-type=\"props.buttonType\"\n    :block=\"props.block\"\n    :tag=\"props.tag\"\n    @click=\"handleReset\"\n  >\n    <slot>\n      {{ props.label || locale.reset }}\n    </slot>\n    <template v-if=\"slots.icon\" #icon>\n      <slot name=\"icon\"></slot>\n    </template>\n    <template v-if=\"slots.loading\" #loading>\n      <slot name=\"loading\"></slot>\n    </template>\n  </Button>\n</template>\n"],"names":["props","useProps","__props","createIconProp","slots","_useSlots","actions","inject","FORM_ACTIONS","nh","useNameHelper","locale","useLocale","toRef","isInherit","computed","handleReset","result","isPromise","emitEvent"],"mappings":";;;;;;;;;;;;AAaM,UAAAA,IAAQC,EAAS,aADRC,GAC6B;AAAA,MAC1C,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,UAAU;AAAA,MACV,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,aAAaC,EAAe;AAAA,MAC5B,eAAe;AAAA,MACf,MAAMA,EAAe;AAAA,MACrB,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,OAAO;AAAA,MACP,eAAe;AAAA,QACb,SAAS;AAAA,QACT,QAAQ;AAAA,MAAA;AAAA,IACV,CACD,GAEKC,IAAQC,EAAA,GAMRC,IAAUC,EAAOC,GAAc,IAAI,GAEnCC,IAAKC,EAAc,MAAM,GACzBC,IAASC,EAAU,QAAQC,EAAMb,GAAO,QAAQ,CAAC,GAEjDc,IAAYC,EAAS,MAAM,CAAC,CAACT,KAAWN,EAAM,OAAO;AAE3D,mBAAegB,IAAc;AAC3B,UAAIhB,EAAM,SAAU;AAEpB,UAAIiB,IAAkB;AAElB,MAAA,OAAOjB,EAAM,iBAAkB,eACjCiB,IAASjB,EAAM,cAAc,GAEzBkB,EAAUD,CAAM,MAClBA,IAAS,MAAMA,KAIfA,MAAW,OACbX,KAAA,QAAAA,EAAS,SACTa,EAAUnB,EAAM,OAAO;AAAA,IACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}