{"version":3,"file":"UNotification.mjs","names":["watch","computed","Transition","genericComponent","propsFactory","useRender","makeComponentProps","makeTagProps","UIcon","useNotification","makeUNotificationProps","_objectSpread","UNotification","name","props","setup","_ref","slots","$useNotification","isActive","value","delay","_$useNotification$cur","currentNotification","elevation","_$useNotification$cur2","position","_$useNotification$cur3","iconLeft","_$useNotification$cur4","undefined","iconTop","_$useNotification$cur5","color","_$useNotification$cur6","transformClasses","transitionName","classes","onClose","close","closingTimer","newIsActive","setTimeout","clearTimeout","_$useNotification$cur7","_$useNotification$cur8","_$useNotification$cur9","_$useNotification$cur10","_$useNotification$cur11","_$useNotification$cur12","_$useNotification$cur13","_$useNotification$cur14","_slots$default","_createVNode","_default","style","_createTextVNode","title","subTitle","text","buttons","call"],"sources":["../../../src/components/UNotification/UNotification.tsx"],"sourcesContent":["import '@/components/UNotification/transition.scss'\nimport { ExtractPropTypes, watch, computed, Transition } from 'vue'\n\nimport { genericComponent, propsFactory, useRender } from '@/utils'\n\nimport { makeComponentProps } from '@/composables/component'\nimport { makeTagProps } from '@/composables/tag'\n\nimport { UIcon } from '@/components'\n\nimport { useNotification } from '@/components'\n\nexport const makeUNotificationProps = propsFactory(\n  {\n    ...makeComponentProps(),\n    ...makeTagProps(),\n  },\n  'UNotification'\n)\n\nexport type UNotificationProps = ExtractPropTypes<typeof makeUNotificationProps>\n\nexport type UNotificationSlots = {\n  default: never\n  notificationTitle: never\n  notificationSubtitle: never\n  notificationText: never\n  notificationButtons: never\n}\n\nexport const UNotification = genericComponent<UNotificationSlots>()({\n  name: 'UNotification',\n\n  props: makeUNotificationProps(),\n\n  setup(props, { slots }) {\n    const $useNotification = useNotification()\n\n    const isActive = computed(() => {\n      return $useNotification.isActive.value\n    })\n\n    const delay = computed(() => {\n      return $useNotification?.currentNotification.value?.delay || 5000\n    })\n\n    const elevation = computed(() => {\n      return (\n        'shadow-' + $useNotification?.currentNotification.value?.elevation || ''\n      )\n    })\n\n    const position = computed(() => {\n      return (\n        $useNotification?.currentNotification.value?.position || 'bottomRight'\n      )\n    })\n\n    const iconLeft = computed(() => {\n      return $useNotification?.currentNotification.value?.iconLeft || undefined\n    })\n\n    const iconTop = computed(() => {\n      return $useNotification?.currentNotification.value?.iconTop || undefined\n    })\n\n    const color = computed(() => {\n      return (\n        $useNotification?.currentNotification.value?.color + '-600' ||\n        'primary-600'\n      )\n    })\n\n    const transformClasses = computed(() => {\n      if (position.value === 'topLeft') return 'top-[24px] left-[24px]'\n      if (position.value === 'topRight') return 'top-[24px] right-[24px]'\n      if (position.value === 'bottomLeft') return 'bottom-[24px] left-[24px]'\n      if (position.value === 'bottomRight') return 'bottom-[24px] right-[24px]'\n      return ''\n    })\n\n    const transitionName = computed(() => {\n      if (position.value === 'topLeft' || position.value === 'bottomLeft')\n        return 'slide-in-from-left'\n      if (position.value === 'topRight' || position.value === 'bottomRight')\n        return 'slide-in-from-right'\n      return ''\n    })\n\n    const classes = computed(() => [\n      `fixed w-fit p-4 bg-white rounded-lg border border-gray-100 z-50`,\n      props.class,\n      elevation.value,\n      transformClasses.value,\n    ])\n\n    const onClose = () => {\n      $useNotification.close()\n    }\n\n    let closingTimer = 0\n    watch(\n      () => isActive.value,\n      (newIsActive) => {\n        if (newIsActive) {\n          closingTimer = setTimeout(() => {\n            $useNotification.close()\n          }, delay.value)\n        } else {\n          clearTimeout(closingTimer)\n        }\n      }\n    )\n\n    useRender(() => (\n      <Transition name={transitionName.value}>\n        {isActive.value ? (\n          <div class={classes.value} style={props.style}>\n            <div\n              class=\"close absolute p-2 top-8 right-8 cursor-pointer\"\n              onClick={onClose}\n            >\n              <UIcon color=\"gray-500\" size=\"20\">\n                xClose\n              </UIcon>\n            </div>\n            <div class=\"flex flex-col gap-3 pr-10\">\n              {iconTop.value ? (\n                <UIcon\n                  variant=\"lightCircleOutline\"\n                  size=\"20\"\n                  color={color.value}\n                >\n                  {iconTop.value}\n                </UIcon>\n              ) : null}\n              <div class=\"flex gap-[16px]\">\n                {iconLeft.value ? (\n                  <UIcon\n                    variant=\"lightCircleOutline\"\n                    size=\"20\"\n                    color={color.value}\n                  >\n                    {iconLeft.value}\n                  </UIcon>\n                ) : null}\n                <div class=\"flex flex-col gap-[16px]\">\n                  <div class=\"flex flex-col gap-1\">\n                    <div class=\"flex items-center gap-2\">\n                      {$useNotification?.currentNotification?.value?.title ? (\n                        <div class=\"text-text-sm font-semibold text-gray-900\">\n                          {$useNotification?.currentNotification?.value?.title}\n                        </div>\n                      ) : null}\n                      {$useNotification?.currentNotification.value?.subTitle ? (\n                        <div class=\"text-text-sm text-gray-500\">\n                          {\n                            $useNotification?.currentNotification?.value\n                              ?.subTitle\n                          }\n                        </div>\n                      ) : null}\n                    </div>\n                    {$useNotification?.currentNotification?.value?.text ? (\n                      <div class=\"text-text-sm text-gray-600 max-w-[276px]\">\n                        {$useNotification?.currentNotification?.value?.text}\n                      </div>\n                    ) : null}\n                  </div>\n                  {$useNotification?.currentNotification?.value?.buttons ? (\n                    <div class=\"flex items-center justify-start gap-3\">\n                      {$useNotification?.currentNotification?.value?.buttons}\n                    </div>\n                  ) : null}\n                </div>\n              </div>\n            </div>\n            {slots.default?.()}\n          </div>\n        ) : null}\n      </Transition>\n    ))\n    return {}\n  },\n})\n\nexport type UNotification = InstanceType<typeof UNotification>\n"],"mappings":";;;;;;;;AACA,SAA2BA,KAAK,EAAEC,QAAQ,EAAEC,UAAU,QAAQ,KAAK;AAAA,SAE1DC,gBAAgB,EAAEC,YAAY,EAAEC,SAAS;AAAA,SAEzCC,kBAAkB;AAAA,SAClBC,YAAY;AAAA,SAEZC,KAAK;AAAA,SAELC,eAAe;AAExB,OAAO,IAAMC,sBAAsB,GAAGN,YAAY,CAAAO,aAAA,CAAAA,aAAA,KAE3CL,kBAAkB,CAAC,CAAC,GACpBC,YAAY,CAAC,CAAC,GAEnB,eACF,CAAC;AAYD,OAAO,IAAMK,aAAa,GAAGT,gBAAgB,CAAqB,CAAC,CAAC;EAClEU,IAAI,EAAE,eAAe;EAErBC,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