{"version":3,"file":"message.vue2.mjs","sources":["../../../components/message/message.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { Icon } from '@/components/icon'\nimport { Renderer } from '@/components/renderer'\nimport { Popup } from '@/components/popup'\n\nimport { computed, reactive, ref } from 'vue'\n\nimport { useIcons, useNameHelper } from '@vexip-ui/config'\nimport { assertiveTypes, effectiveTypes } from './symbol'\n\nimport type { Key, MessageConfig, MessagePlacement } from './symbol'\n\ndefineOptions({ name: 'Message' })\n\nconst nh = useNameHelper('message')\nconst icons = useIcons()\n\nconst predefinedIcons = computed(() => ({\n  primary: icons.value.info,\n  info: icons.value.info,\n  success: icons.value.success,\n  warning: icons.value.warning,\n  error: icons.value.error\n}))\n\nconst placement = ref<MessagePlacement>('top')\nconst popup = ref<InstanceType<typeof Popup>>()\n\nconst placementCenter = computed(() => `${placement.value}-center` as const)\n\nasync function add(options: Record<string, any>) {\n  if (popup.value) {\n    await popup.value.add(options)\n  }\n}\n\nasync function remove(key: Key) {\n  return !!popup.value && (await popup.value.remove(key))\n}\n\nfunction config(config: MessageConfig) {\n  placement.value = config.placement || placement.value\n}\n\nfunction clear() {\n  popup.value && popup.value.clear()\n}\n\ndefineExpose(\n  reactive({\n    popup,\n    add,\n    remove,\n    clear,\n    config\n  })\n)\n</script>\n\n<template>\n  <!-- eslint-disable vue/no-v-html -->\n  <Popup\n    ref=\"popup\"\n    :class=\"nh.b()\"\n    :transition-name=\"nh.ns(`popup-${placement}`)\"\n    :placement=\"placementCenter\"\n  >\n    <template #item=\"{ item }: { item: import('./symbol').MessageOptions }\">\n      <div\n        :class=\"[\n          {\n            [nh.be('item')]: true,\n            [nh.bs('vars')]: true,\n            [nh.bem('item', item.type!)]: item.type && effectiveTypes.includes(item.type),\n            [nh.bem('item', 'background')]: item.background,\n            [nh.bem('item', 'color')]: item.background && item.color,\n            [nh.bem('item', 'color-only')]: !item.background && item.color,\n            [nh.bem('item', 'has-icon')]: item.icon,\n            [nh.bem('item', 'closable')]: item.closable\n          },\n          item.className\n        ]\"\n        role=\"alert\"\n        :style=\"[\n          {\n            color: typeof item.color === 'string' ? item.color : undefined,\n            backgroundColor: typeof item.background === 'string' ? item.background : undefined\n          },\n          item.style || {}\n        ]\"\n        aria-atomic=\"true\"\n        :aria-live=\"item.type && assertiveTypes.includes(item.type) ? 'assertive' : 'polite'\"\n      >\n        <div :class=\"nh.be('wrapper')\">\n          <div\n            v-if=\"item.icon || (item.type && effectiveTypes.includes(item.type))\"\n            :class=\"nh.be('icon')\"\n            :style=\"{ color: item.iconColor }\"\n          >\n            <Icon\n              v-if=\"item.icon\"\n              :icon=\"item.icon\"\n              :style=\"[{ color: item.iconColor }, (item.icon as any).style]\"\n            ></Icon>\n            <Icon\n              v-else\n              v-bind=\"predefinedIcons[item.type!]\"\n              :style=\"{ color: item.iconColor }\"\n            ></Icon>\n          </div>\n          <Renderer\n            v-if=\"typeof item.renderer === 'function'\"\n            :renderer=\"item.renderer\"\n            :data=\"item\"\n          ></Renderer>\n          <template v-else>\n            <div v-if=\"item.parseHtml\" :class=\"nh.be('content')\" v-html=\"item.content\"></div>\n            <div v-else :class=\"nh.be('content')\">\n              {{ item.content || '' }}\n            </div>\n          </template>\n        </div>\n        <button\n          v-if=\"item.closable\"\n          type=\"button\"\n          :class=\"nh.be('close')\"\n          @click=\"remove(item.key!)\"\n        >\n          <Icon v-bind=\"icons.close\" label=\"close\"></Icon>\n        </button>\n      </div>\n    </template>\n  </Popup>\n</template>\n"],"names":["nh","useNameHelper","icons","useIcons","predefinedIcons","computed","placement","ref","popup","placementCenter","add","options","remove","key","config","clear","__expose","reactive"],"mappings":";;;;;;;;;;;;;AAcM,UAAAA,IAAKC,EAAc,SAAS,GAC5BC,IAAQC,EAAS,GAEjBC,IAAkBC,EAAS,OAAO;AAAA,MACtC,SAASH,EAAM,MAAM;AAAA,MACrB,MAAMA,EAAM,MAAM;AAAA,MAClB,SAASA,EAAM,MAAM;AAAA,MACrB,SAASA,EAAM,MAAM;AAAA,MACrB,OAAOA,EAAM,MAAM;AAAA,IAAA,EACnB,GAEII,IAAYC,EAAsB,KAAK,GACvCC,IAAQD,EAAgC,GAExCE,IAAkBJ,EAAS,MAAM,GAAGC,EAAU,KAAK,SAAkB;AAE3E,mBAAeI,EAAIC,GAA8B;AAC/C,MAAIH,EAAM,SACF,MAAAA,EAAM,MAAM,IAAIG,CAAO;AAAA,IAC/B;AAGF,mBAAeC,EAAOC,GAAU;AACvB,aAAA,CAAC,CAACL,EAAM,SAAU,MAAMA,EAAM,MAAM,OAAOK,CAAG;AAAA,IAAA;AAGvD,aAASC,EAAOA,GAAuB;AAC3B,MAAAR,EAAA,QAAQQ,EAAO,aAAaR,EAAU;AAAA,IAAA;AAGlD,aAASS,IAAQ;AACT,MAAAP,EAAA,SAASA,EAAM,MAAM,MAAM;AAAA,IAAA;AAGnC,WAAAQ;AAAA,MACEC,EAAS;AAAA,QACP,OAAAT;AAAA,QACA,KAAAE;AAAA,QACA,QAAAE;AAAA,QACA,OAAAG;AAAA,QACA,QAAAD;AAAA,MACD,CAAA;AAAA,IACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}