fds-vue-core 9.1.0 → 9.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/components.d.ts +4 -0
  2. package/dist/components/Blocks/FdsBlockLink/FdsBlockLink.js.map +1 -1
  3. package/dist/components/Blocks/FdsBlockLink/FdsBlockLink.vue_vue_type_script_setup_true_lang.js +1 -1
  4. package/dist/components/Blocks/FdsBlockLink/FdsBlockLink.vue_vue_type_script_setup_true_lang.js.map +1 -1
  5. package/dist/components/Buttons/FdsButtonIcon/FdsButtonIcon.vue_vue_type_script_setup_true_lang.js +1 -0
  6. package/dist/components/Buttons/FdsButtonIcon/FdsButtonIcon.vue_vue_type_script_setup_true_lang.js.map +1 -1
  7. package/dist/components/Buttons/FdsButtonIcon/types.d.ts +1 -0
  8. package/dist/components/FdsSearchSelect/FdsSearchSelect.js.map +1 -1
  9. package/dist/components/FdsSearchSelect/FdsSearchSelect.vue_vue_type_script_setup_true_lang.js +6 -3
  10. package/dist/components/FdsSearchSelect/FdsSearchSelect.vue_vue_type_script_setup_true_lang.js.map +1 -1
  11. package/dist/components/FdsSearchSelectPro/FdsSearchSelectPro.js.map +1 -1
  12. package/dist/components/FdsSearchSelectPro/FdsSearchSelectPro.vue_vue_type_script_setup_true_lang.js +6 -3
  13. package/dist/components/FdsSearchSelectPro/FdsSearchSelectPro.vue_vue_type_script_setup_true_lang.js.map +1 -1
  14. package/dist/components/FdsSnackbar/FdsSnackbar.js +6 -0
  15. package/dist/components/FdsSnackbar/FdsSnackbar.js.map +1 -0
  16. package/dist/components/FdsSnackbar/FdsSnackbar.vue.d.ts +7 -0
  17. package/dist/components/FdsSnackbar/FdsSnackbar.vue_vue_type_script_setup_true_lang.js +78 -0
  18. package/dist/components/FdsSnackbar/FdsSnackbar.vue_vue_type_script_setup_true_lang.js.map +1 -0
  19. package/dist/components/FdsSnackbar/types.d.ts +16 -0
  20. package/dist/components/FdsSnackbar/useSnackbar.d.ts +40 -0
  21. package/dist/components/FdsSnackbar/useSnackbar.js +19 -0
  22. package/dist/components/FdsSnackbar/useSnackbar.js.map +1 -0
  23. package/dist/components/FdsToastMessage/FdsToastMessage.js +6 -0
  24. package/dist/components/FdsToastMessage/FdsToastMessage.js.map +1 -0
  25. package/dist/components/FdsToastMessage/FdsToastMessage.vue.d.ts +8 -0
  26. package/dist/components/FdsToastMessage/FdsToastMessage.vue_vue_type_script_setup_true_lang.js +58 -0
  27. package/dist/components/FdsToastMessage/FdsToastMessage.vue_vue_type_script_setup_true_lang.js.map +1 -0
  28. package/dist/components/FdsToastMessage/FdsToastMessageCard.js +6 -0
  29. package/dist/components/FdsToastMessage/FdsToastMessageCard.js.map +1 -0
  30. package/dist/components/FdsToastMessage/FdsToastMessageCard.vue.d.ts +20 -0
  31. package/dist/components/FdsToastMessage/FdsToastMessageCard.vue_vue_type_script_setup_true_lang.js +185 -0
  32. package/dist/components/FdsToastMessage/FdsToastMessageCard.vue_vue_type_script_setup_true_lang.js.map +1 -0
  33. package/dist/components/FdsToastMessage/FdsToastRegions.js +8 -0
  34. package/dist/components/FdsToastMessage/FdsToastRegions.js.map +1 -0
  35. package/dist/components/FdsToastMessage/FdsToastRegions.vue.d.ts +28 -0
  36. package/dist/components/FdsToastMessage/FdsToastRegions.vue_vue_type_script_setup_true_lang.js +81 -0
  37. package/dist/components/FdsToastMessage/FdsToastRegions.vue_vue_type_script_setup_true_lang.js.map +1 -0
  38. package/dist/components/FdsToastMessage/createMessageQueue.d.ts +19 -0
  39. package/dist/components/FdsToastMessage/createMessageQueue.js +50 -0
  40. package/dist/components/FdsToastMessage/createMessageQueue.js.map +1 -0
  41. package/dist/components/FdsToastMessage/getReadingDuration.d.ts +1 -0
  42. package/dist/components/FdsToastMessage/getReadingDuration.js +11 -0
  43. package/dist/components/FdsToastMessage/getReadingDuration.js.map +1 -0
  44. package/dist/components/FdsToastMessage/types.d.ts +20 -0
  45. package/dist/components/FdsToastMessage/useToastMessage.d.ts +40 -0
  46. package/dist/components/FdsToastMessage/useToastMessage.js +19 -0
  47. package/dist/components/FdsToastMessage/useToastMessage.js.map +1 -0
  48. package/dist/fds-vue-core.css +2 -2
  49. package/dist/index.d.ts +8 -2
  50. package/dist/index.js +9 -3
  51. package/dist/index.js.map +1 -1
  52. package/dist/lang/en.js +6 -0
  53. package/dist/lang/en.js.map +1 -1
  54. package/dist/lang/sv.js +6 -0
  55. package/dist/lang/sv.js.map +1 -1
  56. package/dist/tsconfig.build.tsbuildinfo +1 -1
  57. package/package.json +13 -13
  58. package/src/components/Blocks/FdsBlockLink/FdsBlockLink.vue +1 -1
  59. package/src/components/Buttons/FdsButtonIcon/types.ts +1 -0
  60. package/src/components/FdsSearchSelect/FdsSearchSelect.vue +8 -3
  61. package/src/components/FdsSearchSelectPro/FdsSearchSelectPro.vue +8 -3
  62. package/src/components/FdsSnackbar/FdsSnackbar.stories.ts +111 -0
  63. package/src/components/FdsSnackbar/FdsSnackbar.vue +74 -0
  64. package/src/components/FdsSnackbar/types.ts +21 -0
  65. package/src/components/FdsSnackbar/useSnackbar.ts +19 -0
  66. package/src/components/FdsToastMessage/FdsToastMessage.stories.ts +122 -0
  67. package/src/components/FdsToastMessage/FdsToastMessage.vue +44 -0
  68. package/src/components/FdsToastMessage/FdsToastMessageCard.vue +173 -0
  69. package/src/components/FdsToastMessage/FdsToastRegions.vue +114 -0
  70. package/src/components/FdsToastMessage/createMessageQueue.ts +57 -0
  71. package/src/components/FdsToastMessage/getReadingDuration.ts +8 -0
  72. package/src/components/FdsToastMessage/types.ts +31 -0
  73. package/src/components/FdsToastMessage/useToastMessage.ts +19 -0
  74. package/src/docs/Start/Start.mdx +3 -1
  75. package/src/docs/Start/Start.stories.ts +18 -0
  76. package/src/index.ts +27 -0
  77. package/src/lang/en.json +6 -0
  78. package/src/lang/sv.json +6 -0
@@ -0,0 +1,40 @@
1
+ import { FdsSnackbarOptions } from './types';
2
+ export declare function useSnackbar(): {
3
+ snackbars: Readonly<import('vue').ShallowRef<(FdsSnackbarOptions & {
4
+ id: number;
5
+ })[], (FdsSnackbarOptions & {
6
+ id: number;
7
+ })[]>>;
8
+ show: (options: FdsSnackbarOptions) => number;
9
+ dismiss: (id: number) => void;
10
+ clear: () => void;
11
+ success: (message: string, options: {
12
+ dataTestid?: string | undefined;
13
+ closeable?: boolean | undefined;
14
+ action: import('./types').FdsSnackbarAction;
15
+ duration?: number | undefined;
16
+ position?: import('../..').FdsToastMessagePosition | undefined;
17
+ }) => number;
18
+ info: (message: string, options: {
19
+ dataTestid?: string | undefined;
20
+ closeable?: boolean | undefined;
21
+ action: import('./types').FdsSnackbarAction;
22
+ duration?: number | undefined;
23
+ position?: import('../..').FdsToastMessagePosition | undefined;
24
+ }) => number;
25
+ warning: (message: string, options: {
26
+ dataTestid?: string | undefined;
27
+ closeable?: boolean | undefined;
28
+ action: import('./types').FdsSnackbarAction;
29
+ duration?: number | undefined;
30
+ position?: import('../..').FdsToastMessagePosition | undefined;
31
+ }) => number;
32
+ error: (message: string, options: {
33
+ dataTestid?: string | undefined;
34
+ closeable?: boolean | undefined;
35
+ action: import('./types').FdsSnackbarAction;
36
+ duration?: number | undefined;
37
+ position?: import('../..').FdsToastMessagePosition | undefined;
38
+ }) => number;
39
+ };
40
+ export declare const useSnackbarContainer: () => import('vue').ComputedRef<boolean>;
@@ -0,0 +1,19 @@
1
+ import { createMessageQueue } from "../FdsToastMessage/createMessageQueue.js";
2
+ // src/components/FdsSnackbar/useSnackbar.ts
3
+ var snackbarQueue = createMessageQueue();
4
+ function useSnackbar() {
5
+ return {
6
+ snackbars: snackbarQueue.items,
7
+ show: snackbarQueue.show,
8
+ dismiss: snackbarQueue.dismiss,
9
+ clear: snackbarQueue.clear,
10
+ success: snackbarQueue.success,
11
+ info: snackbarQueue.info,
12
+ warning: snackbarQueue.warning,
13
+ error: snackbarQueue.error
14
+ };
15
+ }
16
+ var useSnackbarContainer = snackbarQueue.useContainer;
17
+ export { useSnackbar, useSnackbarContainer };
18
+
19
+ //# sourceMappingURL=useSnackbar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSnackbar.js","names":[],"sources":["../../../src/components/FdsSnackbar/useSnackbar.ts"],"sourcesContent":["import { createMessageQueue } from '../FdsToastMessage/createMessageQueue'\nimport type { FdsSnackbarOptions } from './types'\n\nconst snackbarQueue = createMessageQueue<FdsSnackbarOptions>()\n\nexport function useSnackbar() {\n return {\n snackbars: snackbarQueue.items,\n show: snackbarQueue.show,\n dismiss: snackbarQueue.dismiss,\n clear: snackbarQueue.clear,\n success: snackbarQueue.success,\n info: snackbarQueue.info,\n warning: snackbarQueue.warning,\n error: snackbarQueue.error,\n }\n}\n\nexport const useSnackbarContainer = snackbarQueue.useContainer\n"],"mappings":";;AAGA,IAAM,gBAAgB,mBAAuC;AAE7D,SAAgB,cAAc;CAC5B,OAAO;EACL,WAAW,cAAc;EACzB,MAAM,cAAc;EACpB,SAAS,cAAc;EACvB,OAAO,cAAc;EACrB,SAAS,cAAc;EACvB,MAAM,cAAc;EACpB,SAAS,cAAc;EACvB,OAAO,cAAc;CACvB;AACF;AAEA,IAAa,uBAAuB,cAAc"}
@@ -0,0 +1,6 @@
1
+ import FdsToastMessage_vue_vue_type_script_setup_true_lang_default from "./FdsToastMessage.vue_vue_type_script_setup_true_lang.js";
2
+ // src/components/FdsToastMessage/FdsToastMessage.vue
3
+ var FdsToastMessage_default = FdsToastMessage_vue_vue_type_script_setup_true_lang_default;
4
+ export { FdsToastMessage_default as default };
5
+
6
+ //# sourceMappingURL=FdsToastMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FdsToastMessage.js","names":["_sfc_main"],"sources":["../../../src/components/FdsToastMessage/FdsToastMessage.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport FdsToastMessageCard from './FdsToastMessageCard.vue'\nimport FdsToastRegions from './FdsToastRegions.vue'\nimport { getReadingDuration } from './getReadingDuration'\nimport type { FdsToastMessageItem, FdsToastMessageProps } from './types'\nimport { useToastMessage, useToastMessageContainer } from './useToastMessage'\n\nwithDefaults(defineProps<FdsToastMessageProps>(), {\n position: 'bottom-right',\n duration: 5000,\n max: 3,\n})\n\nconst { toasts, dismiss } = useToastMessage()\nconst isActiveContainer = useToastMessageContainer()\n\nfunction getDuration(toast: FdsToastMessageItem, minimumDuration: number) {\n if (toast.duration !== undefined) return toast.duration\n if (toast.type === 'error' || toast.type === 'warning') return 0\n return getReadingDuration(`${toast.heading ?? ''} ${toast.message}`, minimumDuration)\n}\n</script>\n\n<template>\n <FdsToastRegions\n v-if=\"isActiveContainer\"\n :items=\"toasts\"\n :position=\"position\"\n :max=\"max\"\n widthClass=\"sm:w-96\"\n >\n <template #item=\"{ item }\">\n <FdsToastMessageCard\n :message=\"item.message\"\n :heading=\"item.heading\"\n :type=\"item.type ?? 'info'\"\n :duration=\"getDuration(item, duration)\"\n :closeable=\"item.closeable ?? true\"\n :dataTestid=\"item.dataTestid\"\n @close=\"dismiss(item.id)\"\n />\n </template>\n </FdsToastRegions>\n</template>\n"],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { FdsToastMessageProps } from './types';
2
+ declare const __VLS_export: import('vue').DefineComponent<FdsToastMessageProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<FdsToastMessageProps> & Readonly<{}>, {
3
+ max: number;
4
+ duration: number;
5
+ position: import('./types').FdsToastMessagePosition;
6
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
@@ -0,0 +1,58 @@
1
+ import FdsToastMessageCard_default from "./FdsToastMessageCard.js";
2
+ import FdsToastRegions_default from "./FdsToastRegions.js";
3
+ import { getReadingDuration } from "./getReadingDuration.js";
4
+ import { useToastMessage, useToastMessageContainer } from "./useToastMessage.js";
5
+ import { createBlock, createCommentVNode, createVNode, defineComponent, openBlock, unref, withCtx } from "vue";
6
+ // src/components/FdsToastMessage/FdsToastMessage.vue?vue&type=script&setup=true&lang.ts
7
+ var FdsToastMessage_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
8
+ __name: "FdsToastMessage",
9
+ props: {
10
+ position: { default: "bottom-right" },
11
+ duration: { default: 5e3 },
12
+ max: { default: 3 }
13
+ },
14
+ setup(__props) {
15
+ const { toasts, dismiss } = useToastMessage();
16
+ const isActiveContainer = useToastMessageContainer();
17
+ function getDuration(toast, minimumDuration) {
18
+ if (toast.duration !== void 0) return toast.duration;
19
+ if (toast.type === "error" || toast.type === "warning") return 0;
20
+ return getReadingDuration(`${toast.heading ?? ""} ${toast.message}`, minimumDuration);
21
+ }
22
+ return (_ctx, _cache) => {
23
+ return unref(isActiveContainer) ? (openBlock(), createBlock(FdsToastRegions_default, {
24
+ key: 0,
25
+ items: unref(toasts),
26
+ position: __props.position,
27
+ max: __props.max,
28
+ widthClass: "sm:w-96"
29
+ }, {
30
+ item: withCtx(({ item }) => [createVNode(FdsToastMessageCard_default, {
31
+ message: item.message,
32
+ heading: item.heading,
33
+ type: item.type ?? "info",
34
+ duration: getDuration(item, __props.duration),
35
+ closeable: item.closeable ?? true,
36
+ dataTestid: item.dataTestid,
37
+ onClose: ($event) => unref(dismiss)(item.id)
38
+ }, null, 8, [
39
+ "message",
40
+ "heading",
41
+ "type",
42
+ "duration",
43
+ "closeable",
44
+ "dataTestid",
45
+ "onClose"
46
+ ])]),
47
+ _: 1
48
+ }, 8, [
49
+ "items",
50
+ "position",
51
+ "max"
52
+ ])) : createCommentVNode("", true);
53
+ };
54
+ }
55
+ });
56
+ export { FdsToastMessage_vue_vue_type_script_setup_true_lang_default as default };
57
+
58
+ //# sourceMappingURL=FdsToastMessage.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FdsToastMessage.vue_vue_type_script_setup_true_lang.js","names":["_unref","_openBlock","_createBlock","FdsToastRegions","_withCtx","_createVNode","FdsToastMessageCard","_createCommentVNode"],"sources":["../../../src/components/FdsToastMessage/FdsToastMessage.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport FdsToastMessageCard from './FdsToastMessageCard.vue'\nimport FdsToastRegions from './FdsToastRegions.vue'\nimport { getReadingDuration } from './getReadingDuration'\nimport type { FdsToastMessageItem, FdsToastMessageProps } from './types'\nimport { useToastMessage, useToastMessageContainer } from './useToastMessage'\n\nwithDefaults(defineProps<FdsToastMessageProps>(), {\n position: 'bottom-right',\n duration: 5000,\n max: 3,\n})\n\nconst { toasts, dismiss } = useToastMessage()\nconst isActiveContainer = useToastMessageContainer()\n\nfunction getDuration(toast: FdsToastMessageItem, minimumDuration: number) {\n if (toast.duration !== undefined) return toast.duration\n if (toast.type === 'error' || toast.type === 'warning') return 0\n return getReadingDuration(`${toast.heading ?? ''} ${toast.message}`, minimumDuration)\n}\n</script>\n\n<template>\n <FdsToastRegions\n v-if=\"isActiveContainer\"\n :items=\"toasts\"\n :position=\"position\"\n :max=\"max\"\n widthClass=\"sm:w-96\"\n >\n <template #item=\"{ item }\">\n <FdsToastMessageCard\n :message=\"item.message\"\n :heading=\"item.heading\"\n :type=\"item.type ?? 'info'\"\n :duration=\"getDuration(item, duration)\"\n :closeable=\"item.closeable ?? true\"\n :dataTestid=\"item.dataTestid\"\n @close=\"dismiss(item.id)\"\n />\n </template>\n </FdsToastRegions>\n</template>\n"],"mappings":";;;;;;;;;;;;;;EAaA,MAAM,EAAE,QAAQ,YAAY,gBAAgB;EAC5C,MAAM,oBAAoB,yBAAyB;EAEnD,SAAS,YAAY,OAA4B,iBAAyB;GACxE,IAAI,MAAM,aAAa,KAAA,GAAW,OAAO,MAAM;GAC/C,IAAI,MAAM,SAAS,WAAW,MAAM,SAAS,WAAW,OAAO;GAC/D,OAAO,mBAAmB,GAAG,MAAM,WAAW,GAAG,GAAG,MAAM,WAAW,eAAe;EACtF;;GAKU,OAAAA,MAAA,iBAAA,KADRC,UAAA,GAAAC,YAkBkBC,yBAAA;;IAhBf,OAAOH,MAAA,MAAA;IACP,UAAU,QAAA;IACV,KAAK,QAAA;IACN,YAAW;;IAEA,MAAII,SASX,EATe,WAAI,CACrBC,YAQEC,6BAAA;KAPC,SAAS,KAAK;KACd,SAAS,KAAK;KACd,MAAM,KAAK,QAAI;KACf,UAAU,YAAY,MAAM,QAAA,QAAQ;KACpC,WAAW,KAAK,aAAS;KACzB,YAAY,KAAK;KACjB,UAAK,WAAEN,MAAA,OAAA,CAAO,CAAC,KAAK,EAAE"}
@@ -0,0 +1,6 @@
1
+ import FdsToastMessageCard_vue_vue_type_script_setup_true_lang_default from "./FdsToastMessageCard.vue_vue_type_script_setup_true_lang.js";
2
+ // src/components/FdsToastMessage/FdsToastMessageCard.vue
3
+ var FdsToastMessageCard_default = FdsToastMessageCard_vue_vue_type_script_setup_true_lang_default;
4
+ export { FdsToastMessageCard_default as default };
5
+
6
+ //# sourceMappingURL=FdsToastMessageCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FdsToastMessageCard.js","names":["_sfc_main"],"sources":["../../../src/components/FdsToastMessage/FdsToastMessageCard.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { useFdsI18n } from '../../plugin/useFdsI18n'\nimport FdsButtonIcon from '../Buttons/FdsButtonIcon/FdsButtonIcon.vue'\nimport FdsButtonMinor from '../Buttons/FdsButtonMinor/FdsButtonMinor.vue'\nimport FdsIcon from '../FdsIcon/FdsIcon.vue'\nimport type { FdsIconName } from '../FdsIcon/types'\nimport type { FdsToastMessageType } from './types'\n\nconst props = defineProps<{\n message: string\n heading?: string\n type: FdsToastMessageType\n duration: number\n closeable: boolean\n actionLabel?: string\n screenReaderHint?: string\n dataTestid?: string\n}>()\n\nconst emit = defineEmits<{\n (e: 'close'): void\n (e: 'action'): void\n}>()\n\nconst { t } = useFdsI18n()\n\nconst typeStyles: Record<FdsToastMessageType, { card: string; icon: string; action: string; iconName: FdsIconName }> =\n {\n success: { card: 'bg-green-100 inset-ring-green-300', icon: 'fill-green-700', action: '', iconName: 'success' },\n info: { card: 'bg-blue-100 inset-ring-blue-300', icon: 'fill-blue-700', action: '', iconName: 'information' },\n warning: {\n card: 'bg-yellow-200 inset-ring-yellow-300',\n icon: 'fill-yellow-700',\n action:\n '[&_button]:text-gray-900! [&_button]:underline [&_button]:hover:bg-gray-100! [&_button]:active:bg-gray-200!',\n iconName: 'warning',\n },\n error: { card: 'bg-red-100 inset-ring-red-300', icon: 'fill-red-700', action: '', iconName: 'alert' },\n }\n\nconst style = computed(() => typeStyles[props.type])\n\nconst typeLabel = computed(() => {\n const labels: Record<FdsToastMessageType, string> = {\n success: t('FdsToastMessage.type.success'),\n info: t('FdsToastMessage.type.info'),\n warning: t('FdsToastMessage.type.warning'),\n error: t('FdsToastMessage.type.error'),\n }\n return labels[props.type]\n})\n\nconst isHovered = ref(false)\nconst isFocused = ref(false)\nconst isSwiping = ref(false)\nconst swipeOffset = ref(0)\nlet swipeStartX = 0\nlet swipeStartTime = 0\n\nconst isPaused = computed(() => isHovered.value || isFocused.value || isSwiping.value)\n\nconst cardStyle = computed(() => ({\n transform: swipeOffset.value ? `translateX(${swipeOffset.value}px)` : undefined,\n opacity: swipeOffset.value ? Math.max(0.3, 1 - Math.abs(swipeOffset.value) / 250) : undefined,\n}))\n\nlet remainingTime = props.duration\nlet closeTimer: number | undefined\nlet timerStartedAt = 0\n\nfunction startCloseTimer() {\n if (props.duration <= 0 || closeTimer !== undefined) return\n timerStartedAt = Date.now()\n closeTimer = window.setTimeout(() => emit('close'), remainingTime)\n}\n\nfunction pauseCloseTimer() {\n if (closeTimer === undefined) return\n window.clearTimeout(closeTimer)\n closeTimer = undefined\n remainingTime -= Date.now() - timerStartedAt\n}\n\nwatch(isPaused, (paused) => (paused ? pauseCloseTimer() : startCloseTimer()))\n\nonMounted(startCloseTimer)\n\nonBeforeUnmount(pauseCloseTimer)\n\nfunction handlePointerDown(event: PointerEvent) {\n if (event.pointerType === 'mouse' || (event.target instanceof Element && event.target.closest('button, a'))) return\n isSwiping.value = true\n swipeStartX = event.clientX\n swipeStartTime = event.timeStamp\n}\n\nfunction handlePointerMove(event: PointerEvent) {\n if (!isSwiping.value) return\n const distance = event.clientX - swipeStartX\n if (swipeOffset.value === 0 && Math.abs(distance) < 10) return\n swipeOffset.value = distance\n}\n\nfunction handlePointerUp(event: PointerEvent) {\n if (!isSwiping.value) return\n isSwiping.value = false\n const distance = Math.abs(swipeOffset.value)\n const speed = distance / Math.max(1, event.timeStamp - swipeStartTime)\n if (distance > 100 || (distance > 30 && speed > 0.5)) {\n emit('close')\n return\n }\n swipeOffset.value = 0\n}\n\nfunction handlePointerCancel() {\n isSwiping.value = false\n swipeOffset.value = 0\n}\n\nfunction handleFocusOut(event: FocusEvent) {\n if (event.currentTarget instanceof Element && event.relatedTarget instanceof Node) {\n isFocused.value = event.currentTarget.contains(event.relatedTarget)\n return\n }\n isFocused.value = false\n}\n</script>\n\n<template>\n <div\n :role=\"type === 'error' ? 'alert' : undefined\"\n v-bind=\"{ 'data-testid': dataTestid }\"\n :class=\"[\n 'pointer-events-auto flex items-start gap-3 overflow-hidden rounded-md inset-ring-1 p-4 shadow-lg touch-pan-y',\n style.card,\n isSwiping ? '' : 'transition-[transform,opacity] duration-200 ease-out',\n swipeOffset !== 0 && 'select-none',\n ]\"\n :style=\"cardStyle\"\n @mouseenter=\"isHovered = true\"\n @mouseleave=\"isHovered = false\"\n @focusin=\"isFocused = true\"\n @focusout=\"handleFocusOut\"\n @keydown.esc=\"closeable && emit('close')\"\n @pointerdown=\"handlePointerDown\"\n @pointermove=\"handlePointerMove\"\n @pointerup=\"handlePointerUp\"\n @pointercancel=\"handlePointerCancel\"\n >\n <div class=\"h-7 flex items-center shrink-0\">\n <FdsIcon :name=\"style.iconName\" :size=\"24\" :class=\"style.icon\" aria-hidden=\"true\" />\n </div>\n <div class=\"flex-1 min-w-0 flex flex-col py-0.5 break-words\">\n <span class=\"sr-only\">{{ typeLabel }}</span>\n <span v-if=\"heading\" class=\"font-bold\">{{ heading }}</span>\n <span>{{ message }}</span>\n <span v-if=\"screenReaderHint\" class=\"sr-only\">{{ screenReaderHint }}</span>\n </div>\n <div v-if=\"actionLabel\" class=\"flex flex-col justify-center self-center shrink-0\">\n <FdsButtonMinor :text=\"actionLabel\" :class=\"style.action\" @click=\"emit('action')\" />\n </div>\n <FdsButtonIcon\n v-if=\"closeable\"\n icon=\"cross\"\n :size=\"28\"\n class=\"shrink-0 fill-gray-900! hover:bg-gray-100 active:bg-gray-200\"\n v-bind=\"{ 'aria-label': t('FdsToastMessage.close') }\"\n @click=\"emit('close')\"\n />\n </div>\n</template>\n"],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import { FdsToastMessageType } from './types';
2
+ type __VLS_Props = {
3
+ message: string;
4
+ heading?: string;
5
+ type: FdsToastMessageType;
6
+ duration: number;
7
+ closeable: boolean;
8
+ actionLabel?: string;
9
+ screenReaderHint?: string;
10
+ dataTestid?: string;
11
+ };
12
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
13
+ close: () => any;
14
+ action: () => any;
15
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
16
+ onClose?: (() => any) | undefined;
17
+ onAction?: (() => any) | undefined;
18
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
19
+ declare const _default: typeof __VLS_export;
20
+ export default _default;
@@ -0,0 +1,185 @@
1
+ import { useFdsI18n } from "../../plugin/useFdsI18n.js";
2
+ import FdsButtonIcon_default from "../Buttons/FdsButtonIcon/FdsButtonIcon.js";
3
+ import FdsButtonMinor_default from "../Buttons/FdsButtonMinor/FdsButtonMinor.js";
4
+ import FdsIcon_default from "../FdsIcon/FdsIcon.js";
5
+ import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, mergeProps, normalizeClass, onBeforeUnmount, onMounted, openBlock, ref, toDisplayString, unref, watch, withKeys } from "vue";
6
+ // src/components/FdsToastMessage/FdsToastMessageCard.vue?vue&type=script&setup=true&lang.ts
7
+ var _hoisted_1 = ["role"];
8
+ var _hoisted_2 = { class: "h-7 flex items-center shrink-0" };
9
+ var _hoisted_3 = { class: "flex-1 min-w-0 flex flex-col py-0.5 break-words" };
10
+ var _hoisted_4 = { class: "sr-only" };
11
+ var _hoisted_5 = {
12
+ key: 0,
13
+ class: "font-bold"
14
+ };
15
+ var _hoisted_6 = {
16
+ key: 1,
17
+ class: "sr-only"
18
+ };
19
+ var _hoisted_7 = {
20
+ key: 0,
21
+ class: "flex flex-col justify-center self-center shrink-0"
22
+ };
23
+ var FdsToastMessageCard_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
24
+ __name: "FdsToastMessageCard",
25
+ props: {
26
+ message: {},
27
+ heading: {},
28
+ type: {},
29
+ duration: {},
30
+ closeable: { type: Boolean },
31
+ actionLabel: {},
32
+ screenReaderHint: {},
33
+ dataTestid: {}
34
+ },
35
+ emits: ["close", "action"],
36
+ setup(__props, { emit: __emit }) {
37
+ const props = __props;
38
+ const emit = __emit;
39
+ const { t } = useFdsI18n();
40
+ const typeStyles = {
41
+ success: {
42
+ card: "bg-green-100 inset-ring-green-300",
43
+ icon: "fill-green-700",
44
+ action: "",
45
+ iconName: "success"
46
+ },
47
+ info: {
48
+ card: "bg-blue-100 inset-ring-blue-300",
49
+ icon: "fill-blue-700",
50
+ action: "",
51
+ iconName: "information"
52
+ },
53
+ warning: {
54
+ card: "bg-yellow-200 inset-ring-yellow-300",
55
+ icon: "fill-yellow-700",
56
+ action: "[&_button]:text-gray-900! [&_button]:underline [&_button]:hover:bg-gray-100! [&_button]:active:bg-gray-200!",
57
+ iconName: "warning"
58
+ },
59
+ error: {
60
+ card: "bg-red-100 inset-ring-red-300",
61
+ icon: "fill-red-700",
62
+ action: "",
63
+ iconName: "alert"
64
+ }
65
+ };
66
+ const style = computed(() => typeStyles[props.type]);
67
+ const typeLabel = computed(() => {
68
+ return {
69
+ success: t("FdsToastMessage.type.success"),
70
+ info: t("FdsToastMessage.type.info"),
71
+ warning: t("FdsToastMessage.type.warning"),
72
+ error: t("FdsToastMessage.type.error")
73
+ }[props.type];
74
+ });
75
+ const isHovered = ref(false);
76
+ const isFocused = ref(false);
77
+ const isSwiping = ref(false);
78
+ const swipeOffset = ref(0);
79
+ let swipeStartX = 0;
80
+ let swipeStartTime = 0;
81
+ const isPaused = computed(() => isHovered.value || isFocused.value || isSwiping.value);
82
+ const cardStyle = computed(() => ({
83
+ transform: swipeOffset.value ? `translateX(${swipeOffset.value}px)` : void 0,
84
+ opacity: swipeOffset.value ? Math.max(.3, 1 - Math.abs(swipeOffset.value) / 250) : void 0
85
+ }));
86
+ let remainingTime = props.duration;
87
+ let closeTimer;
88
+ let timerStartedAt = 0;
89
+ function startCloseTimer() {
90
+ if (props.duration <= 0 || closeTimer !== void 0) return;
91
+ timerStartedAt = Date.now();
92
+ closeTimer = window.setTimeout(() => emit("close"), remainingTime);
93
+ }
94
+ function pauseCloseTimer() {
95
+ if (closeTimer === void 0) return;
96
+ window.clearTimeout(closeTimer);
97
+ closeTimer = void 0;
98
+ remainingTime -= Date.now() - timerStartedAt;
99
+ }
100
+ watch(isPaused, (paused) => paused ? pauseCloseTimer() : startCloseTimer());
101
+ onMounted(startCloseTimer);
102
+ onBeforeUnmount(pauseCloseTimer);
103
+ function handlePointerDown(event) {
104
+ if (event.pointerType === "mouse" || event.target instanceof Element && event.target.closest("button, a")) return;
105
+ isSwiping.value = true;
106
+ swipeStartX = event.clientX;
107
+ swipeStartTime = event.timeStamp;
108
+ }
109
+ function handlePointerMove(event) {
110
+ if (!isSwiping.value) return;
111
+ const distance = event.clientX - swipeStartX;
112
+ if (swipeOffset.value === 0 && Math.abs(distance) < 10) return;
113
+ swipeOffset.value = distance;
114
+ }
115
+ function handlePointerUp(event) {
116
+ if (!isSwiping.value) return;
117
+ isSwiping.value = false;
118
+ const distance = Math.abs(swipeOffset.value);
119
+ const speed = distance / Math.max(1, event.timeStamp - swipeStartTime);
120
+ if (distance > 100 || distance > 30 && speed > .5) {
121
+ emit("close");
122
+ return;
123
+ }
124
+ swipeOffset.value = 0;
125
+ }
126
+ function handlePointerCancel() {
127
+ isSwiping.value = false;
128
+ swipeOffset.value = 0;
129
+ }
130
+ function handleFocusOut(event) {
131
+ if (event.currentTarget instanceof Element && event.relatedTarget instanceof Node) {
132
+ isFocused.value = event.currentTarget.contains(event.relatedTarget);
133
+ return;
134
+ }
135
+ isFocused.value = false;
136
+ }
137
+ return (_ctx, _cache) => {
138
+ return openBlock(), createElementBlock("div", mergeProps({ role: __props.type === "error" ? "alert" : void 0 }, { "data-testid": __props.dataTestid }, {
139
+ class: [
140
+ "pointer-events-auto flex items-start gap-3 overflow-hidden rounded-md inset-ring-1 p-4 shadow-lg touch-pan-y",
141
+ style.value.card,
142
+ isSwiping.value ? "" : "transition-[transform,opacity] duration-200 ease-out",
143
+ swipeOffset.value !== 0 && "select-none"
144
+ ],
145
+ style: cardStyle.value,
146
+ onMouseenter: _cache[2] || (_cache[2] = ($event) => isHovered.value = true),
147
+ onMouseleave: _cache[3] || (_cache[3] = ($event) => isHovered.value = false),
148
+ onFocusin: _cache[4] || (_cache[4] = ($event) => isFocused.value = true),
149
+ onFocusout: handleFocusOut,
150
+ onKeydown: _cache[5] || (_cache[5] = withKeys(($event) => __props.closeable && emit("close"), ["esc"])),
151
+ onPointerdown: handlePointerDown,
152
+ onPointermove: handlePointerMove,
153
+ onPointerup: handlePointerUp,
154
+ onPointercancel: handlePointerCancel
155
+ }), [
156
+ createElementVNode("div", _hoisted_2, [createVNode(FdsIcon_default, {
157
+ name: style.value.iconName,
158
+ size: 24,
159
+ class: normalizeClass(style.value.icon),
160
+ "aria-hidden": "true"
161
+ }, null, 8, ["name", "class"])]),
162
+ createElementVNode("div", _hoisted_3, [
163
+ createElementVNode("span", _hoisted_4, toDisplayString(typeLabel.value), 1),
164
+ __props.heading ? (openBlock(), createElementBlock("span", _hoisted_5, toDisplayString(__props.heading), 1)) : createCommentVNode("", true),
165
+ createElementVNode("span", null, toDisplayString(__props.message), 1),
166
+ __props.screenReaderHint ? (openBlock(), createElementBlock("span", _hoisted_6, toDisplayString(__props.screenReaderHint), 1)) : createCommentVNode("", true)
167
+ ]),
168
+ __props.actionLabel ? (openBlock(), createElementBlock("div", _hoisted_7, [createVNode(FdsButtonMinor_default, {
169
+ text: __props.actionLabel,
170
+ class: normalizeClass(style.value.action),
171
+ onClick: _cache[0] || (_cache[0] = ($event) => emit("action"))
172
+ }, null, 8, ["text", "class"])])) : createCommentVNode("", true),
173
+ __props.closeable ? (openBlock(), createBlock(FdsButtonIcon_default, mergeProps({
174
+ key: 1,
175
+ icon: "cross",
176
+ size: 28,
177
+ class: "shrink-0 fill-gray-900! hover:bg-gray-100 active:bg-gray-200"
178
+ }, { "aria-label": unref(t)("FdsToastMessage.close") }, { onClick: _cache[1] || (_cache[1] = ($event) => emit("close")) }), null, 16)) : createCommentVNode("", true)
179
+ ], 16, _hoisted_1);
180
+ };
181
+ }
182
+ });
183
+ export { FdsToastMessageCard_vue_vue_type_script_setup_true_lang_default as default };
184
+
185
+ //# sourceMappingURL=FdsToastMessageCard.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FdsToastMessageCard.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_mergeProps","_withKeys","_createElementVNode","_createVNode","FdsIcon","_normalizeClass","_toDisplayString","_createCommentVNode","FdsButtonMinor","_createBlock","FdsButtonIcon","_unref"],"sources":["../../../src/components/FdsToastMessage/FdsToastMessageCard.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { useFdsI18n } from '../../plugin/useFdsI18n'\nimport FdsButtonIcon from '../Buttons/FdsButtonIcon/FdsButtonIcon.vue'\nimport FdsButtonMinor from '../Buttons/FdsButtonMinor/FdsButtonMinor.vue'\nimport FdsIcon from '../FdsIcon/FdsIcon.vue'\nimport type { FdsIconName } from '../FdsIcon/types'\nimport type { FdsToastMessageType } from './types'\n\nconst props = defineProps<{\n message: string\n heading?: string\n type: FdsToastMessageType\n duration: number\n closeable: boolean\n actionLabel?: string\n screenReaderHint?: string\n dataTestid?: string\n}>()\n\nconst emit = defineEmits<{\n (e: 'close'): void\n (e: 'action'): void\n}>()\n\nconst { t } = useFdsI18n()\n\nconst typeStyles: Record<FdsToastMessageType, { card: string; icon: string; action: string; iconName: FdsIconName }> =\n {\n success: { card: 'bg-green-100 inset-ring-green-300', icon: 'fill-green-700', action: '', iconName: 'success' },\n info: { card: 'bg-blue-100 inset-ring-blue-300', icon: 'fill-blue-700', action: '', iconName: 'information' },\n warning: {\n card: 'bg-yellow-200 inset-ring-yellow-300',\n icon: 'fill-yellow-700',\n action:\n '[&_button]:text-gray-900! [&_button]:underline [&_button]:hover:bg-gray-100! [&_button]:active:bg-gray-200!',\n iconName: 'warning',\n },\n error: { card: 'bg-red-100 inset-ring-red-300', icon: 'fill-red-700', action: '', iconName: 'alert' },\n }\n\nconst style = computed(() => typeStyles[props.type])\n\nconst typeLabel = computed(() => {\n const labels: Record<FdsToastMessageType, string> = {\n success: t('FdsToastMessage.type.success'),\n info: t('FdsToastMessage.type.info'),\n warning: t('FdsToastMessage.type.warning'),\n error: t('FdsToastMessage.type.error'),\n }\n return labels[props.type]\n})\n\nconst isHovered = ref(false)\nconst isFocused = ref(false)\nconst isSwiping = ref(false)\nconst swipeOffset = ref(0)\nlet swipeStartX = 0\nlet swipeStartTime = 0\n\nconst isPaused = computed(() => isHovered.value || isFocused.value || isSwiping.value)\n\nconst cardStyle = computed(() => ({\n transform: swipeOffset.value ? `translateX(${swipeOffset.value}px)` : undefined,\n opacity: swipeOffset.value ? Math.max(0.3, 1 - Math.abs(swipeOffset.value) / 250) : undefined,\n}))\n\nlet remainingTime = props.duration\nlet closeTimer: number | undefined\nlet timerStartedAt = 0\n\nfunction startCloseTimer() {\n if (props.duration <= 0 || closeTimer !== undefined) return\n timerStartedAt = Date.now()\n closeTimer = window.setTimeout(() => emit('close'), remainingTime)\n}\n\nfunction pauseCloseTimer() {\n if (closeTimer === undefined) return\n window.clearTimeout(closeTimer)\n closeTimer = undefined\n remainingTime -= Date.now() - timerStartedAt\n}\n\nwatch(isPaused, (paused) => (paused ? pauseCloseTimer() : startCloseTimer()))\n\nonMounted(startCloseTimer)\n\nonBeforeUnmount(pauseCloseTimer)\n\nfunction handlePointerDown(event: PointerEvent) {\n if (event.pointerType === 'mouse' || (event.target instanceof Element && event.target.closest('button, a'))) return\n isSwiping.value = true\n swipeStartX = event.clientX\n swipeStartTime = event.timeStamp\n}\n\nfunction handlePointerMove(event: PointerEvent) {\n if (!isSwiping.value) return\n const distance = event.clientX - swipeStartX\n if (swipeOffset.value === 0 && Math.abs(distance) < 10) return\n swipeOffset.value = distance\n}\n\nfunction handlePointerUp(event: PointerEvent) {\n if (!isSwiping.value) return\n isSwiping.value = false\n const distance = Math.abs(swipeOffset.value)\n const speed = distance / Math.max(1, event.timeStamp - swipeStartTime)\n if (distance > 100 || (distance > 30 && speed > 0.5)) {\n emit('close')\n return\n }\n swipeOffset.value = 0\n}\n\nfunction handlePointerCancel() {\n isSwiping.value = false\n swipeOffset.value = 0\n}\n\nfunction handleFocusOut(event: FocusEvent) {\n if (event.currentTarget instanceof Element && event.relatedTarget instanceof Node) {\n isFocused.value = event.currentTarget.contains(event.relatedTarget)\n return\n }\n isFocused.value = false\n}\n</script>\n\n<template>\n <div\n :role=\"type === 'error' ? 'alert' : undefined\"\n v-bind=\"{ 'data-testid': dataTestid }\"\n :class=\"[\n 'pointer-events-auto flex items-start gap-3 overflow-hidden rounded-md inset-ring-1 p-4 shadow-lg touch-pan-y',\n style.card,\n isSwiping ? '' : 'transition-[transform,opacity] duration-200 ease-out',\n swipeOffset !== 0 && 'select-none',\n ]\"\n :style=\"cardStyle\"\n @mouseenter=\"isHovered = true\"\n @mouseleave=\"isHovered = false\"\n @focusin=\"isFocused = true\"\n @focusout=\"handleFocusOut\"\n @keydown.esc=\"closeable && emit('close')\"\n @pointerdown=\"handlePointerDown\"\n @pointermove=\"handlePointerMove\"\n @pointerup=\"handlePointerUp\"\n @pointercancel=\"handlePointerCancel\"\n >\n <div class=\"h-7 flex items-center shrink-0\">\n <FdsIcon :name=\"style.iconName\" :size=\"24\" :class=\"style.icon\" aria-hidden=\"true\" />\n </div>\n <div class=\"flex-1 min-w-0 flex flex-col py-0.5 break-words\">\n <span class=\"sr-only\">{{ typeLabel }}</span>\n <span v-if=\"heading\" class=\"font-bold\">{{ heading }}</span>\n <span>{{ message }}</span>\n <span v-if=\"screenReaderHint\" class=\"sr-only\">{{ screenReaderHint }}</span>\n </div>\n <div v-if=\"actionLabel\" class=\"flex flex-col justify-center self-center shrink-0\">\n <FdsButtonMinor :text=\"actionLabel\" :class=\"style.action\" @click=\"emit('action')\" />\n </div>\n <FdsButtonIcon\n v-if=\"closeable\"\n icon=\"cross\"\n :size=\"28\"\n class=\"shrink-0 fill-gray-900! hover:bg-gray-100 active:bg-gray-200\"\n v-bind=\"{ 'aria-label': t('FdsToastMessage.close') }\"\n @click=\"emit('close')\"\n />\n </div>\n</template>\n"],"mappings":"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"}
@@ -0,0 +1,8 @@
1
+ import FdsToastRegions_vue_vue_type_script_setup_true_lang_default from "./FdsToastRegions.vue_vue_type_script_setup_true_lang.js";
2
+ /* empty css */
3
+ import _plugin_vue_export_helper_default from "../../_virtual/_plugin-vue_export-helper.js";
4
+ // src/components/FdsToastMessage/FdsToastRegions.vue
5
+ var FdsToastRegions_default = /*#__PURE__*/ _plugin_vue_export_helper_default(FdsToastRegions_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-71cccc4a"]]);
6
+ export { FdsToastRegions_default as default };
7
+
8
+ //# sourceMappingURL=FdsToastRegions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FdsToastRegions.js","names":["_sfc_main"],"sources":["../../../src/components/FdsToastMessage/FdsToastRegions.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"Item extends FdsToastMessageItem\">\nimport { computed } from 'vue'\nimport type { FdsToastMessageItem, FdsToastMessagePosition } from './types'\n\nconst props = defineProps<{\n items: readonly Item[]\n position: FdsToastMessagePosition\n max: number\n widthClass: string\n}>()\n\ndefineSlots<{\n item(props: { item: Item }): unknown\n}>()\n\nconst regionStyles: Record<FdsToastMessagePosition, { classes: string; enterX: string; enterY: string }> = {\n 'top-left': { classes: 'top-0 left-0 flex-col', enterX: '-2rem', enterY: '0' },\n 'top-center': { classes: 'top-0 left-1/2 -translate-x-1/2 flex-col', enterX: '0', enterY: '-1rem' },\n 'top-right': { classes: 'top-0 right-0 flex-col', enterX: '2rem', enterY: '0' },\n 'bottom-left': { classes: 'bottom-0 left-0 flex-col-reverse', enterX: '-2rem', enterY: '0' },\n 'bottom-center': { classes: 'bottom-0 left-1/2 -translate-x-1/2 flex-col-reverse', enterX: '0', enterY: '1rem' },\n 'bottom-right': { classes: 'bottom-0 right-0 flex-col-reverse', enterX: '2rem', enterY: '0' },\n}\n\nconst regions = computed(() =>\n (Object.keys(regionStyles) as FdsToastMessagePosition[]).map((position) => ({\n position,\n ...regionStyles[position],\n items: props.items.filter((item) => (item.position ?? props.position) === position).slice(0, props.max),\n })),\n)\n</script>\n\n<template>\n <Teleport to=\"body\">\n <div\n v-for=\"region in regions\"\n :key=\"region.position\"\n aria-live=\"polite\"\n :class=\"['fixed z-[100000] flex w-full p-2.5 pointer-events-none', widthClass, region.classes]\"\n :style=\"{\n '--fds-toast-enter-x': region.enterX,\n '--fds-toast-enter-y': region.enterY,\n }\"\n >\n <TransitionGroup name=\"fds-toast\">\n <div v-for=\"item in region.items\" :key=\"item.id\" class=\"fds-toast\">\n <div class=\"min-h-0\">\n <div class=\"py-1.5\">\n <slot name=\"item\" :item=\"item\" />\n </div>\n </div>\n </div>\n </TransitionGroup>\n </div>\n </Teleport>\n</template>\n\n<style scoped>\n.fds-toast {\n display: grid;\n grid-template-rows: 1fr;\n will-change: transform, opacity;\n}\n\n.fds-toast-enter-active {\n transition:\n opacity 120ms ease-out,\n transform 200ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n\n.fds-toast-move {\n transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n\n.fds-toast-leave-active {\n transition:\n opacity 140ms ease-out,\n transform 140ms ease-out,\n grid-template-rows 110ms cubic-bezier(0.4, 0, 0.2, 1) 90ms;\n}\n\n.fds-toast-leave-active > div {\n overflow: hidden;\n}\n\n.fds-toast-enter-from {\n opacity: 0;\n transform: translate(var(--fds-toast-enter-x), var(--fds-toast-enter-y));\n}\n\n.fds-toast-leave-to {\n grid-template-rows: 0fr;\n opacity: 0;\n transform: scale(0.98);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .fds-toast-enter-active,\n .fds-toast-leave-active {\n transition: opacity 150ms linear;\n }\n\n .fds-toast-move {\n transition: none;\n }\n\n .fds-toast-enter-from,\n .fds-toast-leave-to {\n grid-template-rows: 1fr;\n transform: none;\n }\n}\n</style>\n"],"mappings":""}
@@ -0,0 +1,28 @@
1
+ import { FdsToastMessageItem, FdsToastMessagePosition } from './types';
2
+ declare const __VLS_export: <Item extends FdsToastMessageItem>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
+ props: import('vue').PublicProps & __VLS_PrettifyLocal<{
4
+ items: readonly Item[];
5
+ position: FdsToastMessagePosition;
6
+ max: number;
7
+ widthClass: string;
8
+ }> & (typeof globalThis extends {
9
+ __VLS_PROPS_FALLBACK: infer P;
10
+ } ? P : {});
11
+ expose: (exposed: {}) => void;
12
+ attrs: any;
13
+ slots: {
14
+ item(props: {
15
+ item: Item;
16
+ }): unknown;
17
+ };
18
+ emit: {};
19
+ }>) => import('vue').VNode & {
20
+ __ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
21
+ };
22
+ declare const _default: typeof __VLS_export;
23
+ export default _default;
24
+ type __VLS_PrettifyLocal<T> = (T extends any ? {
25
+ [K in keyof T]: T[K];
26
+ } : {
27
+ [K in keyof T as K]: T[K];
28
+ }) & {};
@@ -0,0 +1,81 @@
1
+ import { Fragment, Teleport, TransitionGroup, computed, createBlock, createElementBlock, createElementVNode, createVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, renderList, renderSlot, withCtx } from "vue";
2
+ // src/components/FdsToastMessage/FdsToastRegions.vue?vue&type=script&setup=true&lang.ts
3
+ var _hoisted_1 = { class: "min-h-0" };
4
+ var _hoisted_2 = { class: "py-1.5" };
5
+ var FdsToastRegions_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
6
+ __name: "FdsToastRegions",
7
+ props: {
8
+ items: {},
9
+ position: {},
10
+ max: {},
11
+ widthClass: {}
12
+ },
13
+ setup(__props) {
14
+ const props = __props;
15
+ const regionStyles = {
16
+ "top-left": {
17
+ classes: "top-0 left-0 flex-col",
18
+ enterX: "-2rem",
19
+ enterY: "0"
20
+ },
21
+ "top-center": {
22
+ classes: "top-0 left-1/2 -translate-x-1/2 flex-col",
23
+ enterX: "0",
24
+ enterY: "-1rem"
25
+ },
26
+ "top-right": {
27
+ classes: "top-0 right-0 flex-col",
28
+ enterX: "2rem",
29
+ enterY: "0"
30
+ },
31
+ "bottom-left": {
32
+ classes: "bottom-0 left-0 flex-col-reverse",
33
+ enterX: "-2rem",
34
+ enterY: "0"
35
+ },
36
+ "bottom-center": {
37
+ classes: "bottom-0 left-1/2 -translate-x-1/2 flex-col-reverse",
38
+ enterX: "0",
39
+ enterY: "1rem"
40
+ },
41
+ "bottom-right": {
42
+ classes: "bottom-0 right-0 flex-col-reverse",
43
+ enterX: "2rem",
44
+ enterY: "0"
45
+ }
46
+ };
47
+ const regions = computed(() => Object.keys(regionStyles).map((position) => ({
48
+ position,
49
+ ...regionStyles[position],
50
+ items: props.items.filter((item) => (item.position ?? props.position) === position).slice(0, props.max)
51
+ })));
52
+ return (_ctx, _cache) => {
53
+ return openBlock(), createBlock(Teleport, { to: "body" }, [(openBlock(true), createElementBlock(Fragment, null, renderList(regions.value, (region) => {
54
+ return openBlock(), createElementBlock("div", {
55
+ key: region.position,
56
+ "aria-live": "polite",
57
+ class: normalizeClass([
58
+ "fixed z-[100000] flex w-full p-2.5 pointer-events-none",
59
+ __props.widthClass,
60
+ region.classes
61
+ ]),
62
+ style: normalizeStyle({
63
+ "--fds-toast-enter-x": region.enterX,
64
+ "--fds-toast-enter-y": region.enterY
65
+ })
66
+ }, [createVNode(TransitionGroup, { name: "fds-toast" }, {
67
+ default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(region.items, (item) => {
68
+ return openBlock(), createElementBlock("div", {
69
+ key: item.id,
70
+ class: "fds-toast"
71
+ }, [createElementVNode("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [renderSlot(_ctx.$slots, "item", { item }, void 0, true)])])]);
72
+ }), 128))]),
73
+ _: 2
74
+ }, 1024)], 6);
75
+ }), 128))]);
76
+ };
77
+ }
78
+ });
79
+ export { FdsToastRegions_vue_vue_type_script_setup_true_lang_default as default };
80
+
81
+ //# sourceMappingURL=FdsToastRegions.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FdsToastRegions.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_Teleport","_createElementBlock","_Fragment","_renderList","_normalizeClass","_normalizeStyle","_createVNode","_TransitionGroup","_withCtx","_createElementVNode","_renderSlot"],"sources":["../../../src/components/FdsToastMessage/FdsToastRegions.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"Item extends FdsToastMessageItem\">\nimport { computed } from 'vue'\nimport type { FdsToastMessageItem, FdsToastMessagePosition } from './types'\n\nconst props = defineProps<{\n items: readonly Item[]\n position: FdsToastMessagePosition\n max: number\n widthClass: string\n}>()\n\ndefineSlots<{\n item(props: { item: Item }): unknown\n}>()\n\nconst regionStyles: Record<FdsToastMessagePosition, { classes: string; enterX: string; enterY: string }> = {\n 'top-left': { classes: 'top-0 left-0 flex-col', enterX: '-2rem', enterY: '0' },\n 'top-center': { classes: 'top-0 left-1/2 -translate-x-1/2 flex-col', enterX: '0', enterY: '-1rem' },\n 'top-right': { classes: 'top-0 right-0 flex-col', enterX: '2rem', enterY: '0' },\n 'bottom-left': { classes: 'bottom-0 left-0 flex-col-reverse', enterX: '-2rem', enterY: '0' },\n 'bottom-center': { classes: 'bottom-0 left-1/2 -translate-x-1/2 flex-col-reverse', enterX: '0', enterY: '1rem' },\n 'bottom-right': { classes: 'bottom-0 right-0 flex-col-reverse', enterX: '2rem', enterY: '0' },\n}\n\nconst regions = computed(() =>\n (Object.keys(regionStyles) as FdsToastMessagePosition[]).map((position) => ({\n position,\n ...regionStyles[position],\n items: props.items.filter((item) => (item.position ?? props.position) === position).slice(0, props.max),\n })),\n)\n</script>\n\n<template>\n <Teleport to=\"body\">\n <div\n v-for=\"region in regions\"\n :key=\"region.position\"\n aria-live=\"polite\"\n :class=\"['fixed z-[100000] flex w-full p-2.5 pointer-events-none', widthClass, region.classes]\"\n :style=\"{\n '--fds-toast-enter-x': region.enterX,\n '--fds-toast-enter-y': region.enterY,\n }\"\n >\n <TransitionGroup name=\"fds-toast\">\n <div v-for=\"item in region.items\" :key=\"item.id\" class=\"fds-toast\">\n <div class=\"min-h-0\">\n <div class=\"py-1.5\">\n <slot name=\"item\" :item=\"item\" />\n </div>\n </div>\n </div>\n </TransitionGroup>\n </div>\n </Teleport>\n</template>\n\n<style scoped>\n.fds-toast {\n display: grid;\n grid-template-rows: 1fr;\n will-change: transform, opacity;\n}\n\n.fds-toast-enter-active {\n transition:\n opacity 120ms ease-out,\n transform 200ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n\n.fds-toast-move {\n transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n\n.fds-toast-leave-active {\n transition:\n opacity 140ms ease-out,\n transform 140ms ease-out,\n grid-template-rows 110ms cubic-bezier(0.4, 0, 0.2, 1) 90ms;\n}\n\n.fds-toast-leave-active > div {\n overflow: hidden;\n}\n\n.fds-toast-enter-from {\n opacity: 0;\n transform: translate(var(--fds-toast-enter-x), var(--fds-toast-enter-y));\n}\n\n.fds-toast-leave-to {\n grid-template-rows: 0fr;\n opacity: 0;\n transform: scale(0.98);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .fds-toast-enter-active,\n .fds-toast-leave-active {\n transition: opacity 150ms linear;\n }\n\n .fds-toast-move {\n transition: none;\n }\n\n .fds-toast-enter-from,\n .fds-toast-leave-to {\n grid-template-rows: 1fr;\n transform: none;\n }\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;EAIA,MAAM,QAAQ;EAWd,MAAM,eAAqG;GACzG,YAAY;IAAE,SAAS;IAAyB,QAAQ;IAAS,QAAQ;GAAI;GAC7E,cAAc;IAAE,SAAS;IAA4C,QAAQ;IAAK,QAAQ;GAAQ;GAClG,aAAa;IAAE,SAAS;IAA0B,QAAQ;IAAQ,QAAQ;GAAI;GAC9E,eAAe;IAAE,SAAS;IAAoC,QAAQ;IAAS,QAAQ;GAAI;GAC3F,iBAAiB;IAAE,SAAS;IAAuD,QAAQ;IAAK,QAAQ;GAAO;GAC/G,gBAAgB;IAAE,SAAS;IAAqC,QAAQ;IAAQ,QAAQ;GAAI;EAC9F;EAEA,MAAM,UAAU,eACb,OAAO,KAAK,YAAY,CAAC,CAA+B,KAAK,cAAc;GAC1E;GACA,GAAG,aAAa;GAChB,OAAO,MAAM,MAAM,QAAQ,UAAU,KAAK,YAAY,MAAM,cAAc,QAAQ,CAAC,CAAC,MAAM,GAAG,MAAM,GAAG;EACxG,EAAE,CACJ;;GAIE,OAAAA,UAAA,GAAAC,YAqBWC,UAAA,EArBD,IAAG,OAAM,GAAA,EACjBF,UAAA,IAAA,GAAAG,mBAmBMC,UAAA,MAAAC,WAlBa,QAAA,QAAV,WAAM;IADf,OAAAL,UAAA,GAAAG,mBAmBM,OAAA;KAjBH,KAAK,OAAO;KACb,aAAU;KACT,OAAKG,eAAA;MAAA;MAA6D,QAAA;MAAY,OAAO;KAAO,CAAA;KAC5F,OAAKC,eAAA;MAAmC,uBAAA,OAAO;MAAuC,uBAAA,OAAO;;I,IAK9FC,YAQkBC,iBAAA,EARD,MAAK,YAAW,GAAA;KAC1B,SAAAC,cAA4B,EAAjCV,UAAA,IAAA,GAAAG,mBAMMC,UAAA,MAAAC,WANc,OAAO,QAAf,SAAI;MAAhB,OAAAL,UAAA,GAAAG,mBAMM,OAAA;OAN6B,KAAK,KAAK;OAAI,OAAM;M,IACrDQ,mBAIM,OAJN,YAIM,CAHJA,mBAEM,OAFN,YAEM,CADJC,WAAiC,KAAA,QAAA,QAAA,EAAR,KAAI,GAAA,KAAA,GAAA,IAAA,C"}
@@ -0,0 +1,19 @@
1
+ import { FdsToastMessageOptions } from './types';
2
+ type ShortcutOptions<Options> = Omit<Options, 'message' | 'type'>;
3
+ type ShortcutArguments<Options> = Partial<ShortcutOptions<Options>> extends ShortcutOptions<Options> ? [options?: ShortcutOptions<Options>] : [options: ShortcutOptions<Options>];
4
+ export declare function createMessageQueue<Options extends FdsToastMessageOptions>(): {
5
+ items: Readonly<import('vue').ShallowRef<(Options & {
6
+ id: number;
7
+ })[], (Options & {
8
+ id: number;
9
+ })[]>>;
10
+ show: (options: Options) => number;
11
+ dismiss: (id: number) => void;
12
+ clear: () => void;
13
+ success: (message: string, ...[options]: ShortcutArguments<Options>) => number;
14
+ info: (message: string, ...[options]: ShortcutArguments<Options>) => number;
15
+ warning: (message: string, ...[options]: ShortcutArguments<Options>) => number;
16
+ error: (message: string, ...[options]: ShortcutArguments<Options>) => number;
17
+ useContainer: () => import('vue').ComputedRef<boolean>;
18
+ };
19
+ export {};
@@ -0,0 +1,50 @@
1
+ import { computed, onBeforeUnmount, onMounted, shallowReadonly, shallowRef } from "vue";
2
+ // src/components/FdsToastMessage/createMessageQueue.ts
3
+ function createMessageQueue() {
4
+ const items = shallowRef([]);
5
+ const mountedContainers = shallowRef([]);
6
+ let nextId = 0;
7
+ const show = (options) => {
8
+ nextId += 1;
9
+ items.value = [...items.value, {
10
+ ...options,
11
+ id: nextId
12
+ }];
13
+ return nextId;
14
+ };
15
+ const dismiss = (id) => {
16
+ items.value = items.value.filter((item) => item.id !== id);
17
+ };
18
+ const clear = () => {
19
+ items.value = [];
20
+ };
21
+ const showType = (type) => (message, ...[options]) => show({
22
+ ...options,
23
+ message,
24
+ type
25
+ });
26
+ const useContainer = () => {
27
+ const containerId = Symbol("FdsMessageContainer");
28
+ onMounted(() => {
29
+ mountedContainers.value = [...mountedContainers.value, containerId];
30
+ });
31
+ onBeforeUnmount(() => {
32
+ mountedContainers.value = mountedContainers.value.filter((id) => id !== containerId);
33
+ });
34
+ return computed(() => mountedContainers.value[0] === containerId);
35
+ };
36
+ return {
37
+ items: shallowReadonly(items),
38
+ show,
39
+ dismiss,
40
+ clear,
41
+ success: showType("success"),
42
+ info: showType("info"),
43
+ warning: showType("warning"),
44
+ error: showType("error"),
45
+ useContainer
46
+ };
47
+ }
48
+ export { createMessageQueue };
49
+
50
+ //# sourceMappingURL=createMessageQueue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createMessageQueue.js","names":[],"sources":["../../../src/components/FdsToastMessage/createMessageQueue.ts"],"sourcesContent":["import { computed, onBeforeUnmount, onMounted, shallowReadonly, shallowRef } from 'vue'\nimport type { FdsToastMessageOptions, FdsToastMessageType } from './types'\n\ntype ShortcutOptions<Options> = Omit<Options, 'message' | 'type'>\n\ntype ShortcutArguments<Options> =\n Partial<ShortcutOptions<Options>> extends ShortcutOptions<Options>\n ? [options?: ShortcutOptions<Options>]\n : [options: ShortcutOptions<Options>]\n\nexport function createMessageQueue<Options extends FdsToastMessageOptions>() {\n const items = shallowRef<(Options & { id: number })[]>([])\n const mountedContainers = shallowRef<symbol[]>([])\n let nextId = 0\n\n const show = (options: Options): number => {\n nextId += 1\n items.value = [...items.value, { ...options, id: nextId }]\n return nextId\n }\n\n const dismiss = (id: number) => {\n items.value = items.value.filter((item) => item.id !== id)\n }\n\n const clear = () => {\n items.value = []\n }\n\n const showType =\n (type: FdsToastMessageType) =>\n (message: string, ...[options]: ShortcutArguments<Options>) =>\n show({ ...options, message, type } as Options)\n\n const useContainer = () => {\n const containerId = Symbol('FdsMessageContainer')\n onMounted(() => {\n mountedContainers.value = [...mountedContainers.value, containerId]\n })\n onBeforeUnmount(() => {\n mountedContainers.value = mountedContainers.value.filter((id) => id !== containerId)\n })\n return computed(() => mountedContainers.value[0] === containerId)\n }\n\n return {\n items: shallowReadonly(items),\n show,\n dismiss,\n clear,\n success: showType('success'),\n info: showType('info'),\n warning: showType('warning'),\n error: showType('error'),\n useContainer,\n }\n}\n"],"mappings":";;AAUA,SAAgB,qBAA6D;CAC3E,MAAM,QAAQ,WAAyC,CAAC,CAAC;CACzD,MAAM,oBAAoB,WAAqB,CAAC,CAAC;CACjD,IAAI,SAAS;CAEb,MAAM,QAAQ,YAA6B;EACzC,UAAU;EACV,MAAM,QAAQ,CAAC,GAAG,MAAM,OAAO;GAAE,GAAG;GAAS,IAAI;EAAO,CAAC;EACzD,OAAO;CACT;CAEA,MAAM,WAAW,OAAe;EAC9B,MAAM,QAAQ,MAAM,MAAM,QAAQ,SAAS,KAAK,OAAO,EAAE;CAC3D;CAEA,MAAM,cAAc;EAClB,MAAM,QAAQ,CAAC;CACjB;CAEA,MAAM,YACH,UACA,SAAiB,GAAG,CAAC,aACpB,KAAK;EAAE,GAAG;EAAS;EAAS;CAAK,CAAY;CAEjD,MAAM,qBAAqB;EACzB,MAAM,cAAc,OAAO,qBAAqB;EAChD,gBAAgB;GACd,kBAAkB,QAAQ,CAAC,GAAG,kBAAkB,OAAO,WAAW;EACpE,CAAC;EACD,sBAAsB;GACpB,kBAAkB,QAAQ,kBAAkB,MAAM,QAAQ,OAAO,OAAO,WAAW;EACrF,CAAC;EACD,OAAO,eAAe,kBAAkB,MAAM,OAAO,WAAW;CAClE;CAEA,OAAO;EACL,OAAO,gBAAgB,KAAK;EAC5B;EACA;EACA;EACA,SAAS,SAAS,SAAS;EAC3B,MAAM,SAAS,MAAM;EACrB,SAAS,SAAS,SAAS;EAC3B,OAAO,SAAS,OAAO;EACvB;CACF;AACF"}