vueless 0.0.503 → 0.0.505

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 (108) hide show
  1. package/package.json +1 -1
  2. package/plugin-vite.d.ts +43 -11
  3. package/types.ts +31 -3
  4. package/ui.button/UButton.vue +101 -240
  5. package/ui.button/storybook/Docs.mdx +2 -2
  6. package/ui.button/storybook/{stories.js → stories.ts} +25 -12
  7. package/ui.button/types.ts +121 -0
  8. package/ui.button/{useAttrs.js → useAttrs.ts} +6 -3
  9. package/ui.button-link/ULink.vue +72 -223
  10. package/ui.button-link/storybook/Docs.mdx +2 -2
  11. package/ui.button-link/storybook/{stories.js → stories.ts} +30 -17
  12. package/ui.button-link/types.ts +131 -0
  13. package/ui.button-link/{useAttrs.js → useAttrs.ts} +15 -3
  14. package/ui.button-toggle/UToggle.vue +47 -165
  15. package/ui.button-toggle/storybook/Docs.mdx +2 -2
  16. package/ui.button-toggle/storybook/{stories.js → stories.ts} +13 -5
  17. package/ui.button-toggle/types.ts +85 -0
  18. package/ui.button-toggle/useAttrs.ts +18 -0
  19. package/ui.button-toggle-item/UToggleItem.vue +59 -110
  20. package/ui.button-toggle-item/storybook/Docs.mdx +2 -2
  21. package/ui.button-toggle-item/storybook/{stories.js → stories.ts} +10 -3
  22. package/ui.button-toggle-item/types.ts +40 -0
  23. package/ui.button-toggle-item/{useAttrs.js → useAttrs.ts} +16 -4
  24. package/ui.other-dot/UDot.vue +14 -42
  25. package/ui.other-dot/storybook/Docs.mdx +2 -2
  26. package/ui.other-dot/storybook/{stories.js → stories.ts} +13 -5
  27. package/ui.other-dot/types.ts +46 -0
  28. package/ui.other-dot/useAttrs.ts +18 -0
  29. package/ui.text-alert/UAlert.vue +85 -157
  30. package/ui.text-alert/storybook/Docs.mdx +2 -2
  31. package/ui.text-alert/storybook/{stories.js → stories.ts} +17 -9
  32. package/ui.text-alert/types.ts +76 -0
  33. package/ui.text-alert/useAttrs.ts +18 -0
  34. package/ui.text-badge/UBadge.vue +1 -0
  35. package/ui.text-badge/storybook/stories.ts +1 -8
  36. package/ui.text-badge/types.ts +2 -0
  37. package/ui.text-badge/useAttrs.ts +1 -3
  38. package/ui.text-block/UText.vue +1 -0
  39. package/ui.text-block/storybook/stories.ts +1 -1
  40. package/ui.text-block/types.ts +2 -0
  41. package/ui.text-block/useAttrs.ts +1 -1
  42. package/ui.text-empty/UEmpty.vue +39 -75
  43. package/ui.text-empty/storybook/Docs.mdx +2 -2
  44. package/ui.text-empty/storybook/{stories.js → stories.ts} +14 -6
  45. package/ui.text-empty/types.ts +30 -0
  46. package/ui.text-empty/useAttrs.ts +18 -0
  47. package/ui.text-file/UFile.vue +49 -109
  48. package/ui.text-file/storybook/Docs.mdx +2 -2
  49. package/ui.text-file/storybook/{stories.js → stories.ts} +10 -3
  50. package/ui.text-file/types.ts +45 -0
  51. package/ui.text-file/useAttrs.ts +18 -0
  52. package/ui.text-files/UFiles.vue +46 -106
  53. package/ui.text-files/storybook/Docs.mdx +2 -2
  54. package/ui.text-files/storybook/{stories.js → stories.ts} +10 -3
  55. package/ui.text-files/types.ts +45 -0
  56. package/ui.text-files/useAttrs.ts +18 -0
  57. package/ui.text-header/UHeader.vue +19 -76
  58. package/ui.text-header/storybook/Docs.mdx +2 -2
  59. package/ui.text-header/storybook/{stories.js → stories.ts} +13 -5
  60. package/ui.text-header/types.ts +66 -0
  61. package/ui.text-header/useAttrs.ts +18 -0
  62. package/ui.text-money/UMoney.vue +58 -168
  63. package/ui.text-money/storybook/Docs.mdx +2 -2
  64. package/ui.text-money/storybook/{stories.js → stories.ts} +13 -5
  65. package/ui.text-money/types.ts +101 -0
  66. package/ui.text-money/useAttrs.ts +18 -0
  67. package/ui.text-money/{utilMoney.js → utilMoney.ts} +1 -1
  68. package/ui.text-notify/UNotify.vue +89 -116
  69. package/ui.text-notify/storybook/Docs.mdx +2 -2
  70. package/ui.text-notify/storybook/{stories.js → stories.ts} +12 -5
  71. package/ui.text-notify/types.ts +25 -0
  72. package/ui.text-notify/useAttrs.ts +18 -0
  73. package/ui.text-notify/utilNotify.ts +140 -0
  74. package/web-types.json +285 -135
  75. package/ui.button-toggle/useAttrs.js +0 -15
  76. package/ui.other-dot/useAttrs.js +0 -15
  77. package/ui.text-alert/useAttrs.js +0 -15
  78. package/ui.text-empty/useAttrs.js +0 -15
  79. package/ui.text-file/useAttrs.js +0 -15
  80. package/ui.text-files/useAttrs.js +0 -15
  81. package/ui.text-header/useAttrs.js +0 -15
  82. package/ui.text-money/useAttrs.js +0 -15
  83. package/ui.text-notify/useAttrs.js +0 -15
  84. package/ui.text-notify/utilNotify.js +0 -86
  85. /package/ui.button/{config.js → config.ts} +0 -0
  86. /package/ui.button/{constants.js → constants.ts} +0 -0
  87. /package/ui.button-link/{config.js → config.ts} +0 -0
  88. /package/ui.button-link/{constants.js → constants.ts} +0 -0
  89. /package/ui.button-toggle/{config.js → config.ts} +0 -0
  90. /package/ui.button-toggle/{constants.js → constants.ts} +0 -0
  91. /package/ui.button-toggle-item/{config.js → config.ts} +0 -0
  92. /package/ui.button-toggle-item/{constants.js → constants.ts} +0 -0
  93. /package/ui.other-dot/{config.js → config.ts} +0 -0
  94. /package/ui.other-dot/{constants.js → constants.ts} +0 -0
  95. /package/ui.text-alert/{config.js → config.ts} +0 -0
  96. /package/ui.text-alert/{constants.js → constants.ts} +0 -0
  97. /package/ui.text-empty/{config.js → config.ts} +0 -0
  98. /package/ui.text-empty/{constants.js → constants.ts} +0 -0
  99. /package/ui.text-file/{config.js → config.ts} +0 -0
  100. /package/ui.text-file/{constants.js → constants.ts} +0 -0
  101. /package/ui.text-files/{config.js → config.ts} +0 -0
  102. /package/ui.text-files/{constants.js → constants.ts} +0 -0
  103. /package/ui.text-header/{config.js → config.ts} +0 -0
  104. /package/ui.text-header/{constants.js → constants.ts} +0 -0
  105. /package/ui.text-money/{config.js → config.ts} +0 -0
  106. /package/ui.text-money/{constants.js → constants.ts} +0 -0
  107. /package/ui.text-notify/{config.js → config.ts} +0 -0
  108. /package/ui.text-notify/{constants.js → constants.ts} +0 -0
@@ -0,0 +1,101 @@
1
+ import defaultConfig from "./config.ts";
2
+
3
+ export type Config = Partial<typeof defaultConfig>;
4
+
5
+ export interface UMoneyProps {
6
+ /**
7
+ * Money value.
8
+ */
9
+ value?: number;
10
+
11
+ /**
12
+ * Money size.
13
+ */
14
+ size?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl";
15
+
16
+ /**
17
+ * Money color.
18
+ */
19
+ color?:
20
+ | "brand"
21
+ | "grayscale"
22
+ | "gray"
23
+ | "red"
24
+ | "orange"
25
+ | "amber"
26
+ | "yellow"
27
+ | "lime"
28
+ | "green"
29
+ | "emerald"
30
+ | "teal"
31
+ | "cyan"
32
+ | "sky"
33
+ | "blue"
34
+ | "indigo"
35
+ | "violet"
36
+ | "purple"
37
+ | "fuchsia"
38
+ | "pink"
39
+ | "rose"
40
+ | "white";
41
+
42
+ /**
43
+ * Money currency symbol.
44
+ */
45
+ symbol?: string;
46
+
47
+ /**
48
+ * Money currency symbol align.
49
+ */
50
+ symbolAlign?: "right" | "left";
51
+
52
+ /**
53
+ * Add space between currency symbol and sum.
54
+ */
55
+ symbolDivided?: boolean;
56
+
57
+ /**
58
+ * Money sign.
59
+ */
60
+ sign?: "default" | "positive" | "negative";
61
+
62
+ /**
63
+ * Minimal number of signs after the decimal separator (fractional part of a number).
64
+ */
65
+ minFractionDigits?: number;
66
+
67
+ /**
68
+ * Maximal number of signs after the decimal separator (fractional part of a number).
69
+ */
70
+ maxFractionDigits?: number;
71
+
72
+ /**
73
+ * A symbol used to separate the integer part from the fractional part of a number.
74
+ */
75
+ decimalSeparator?: string;
76
+
77
+ /**
78
+ * A symbol used to separate the thousand parts of a number.
79
+ */
80
+ thousandsSeparator?: string;
81
+
82
+ /**
83
+ * Money align.
84
+ */
85
+ align?: "right" | "left";
86
+
87
+ /**
88
+ * Make money planned (add brackets).
89
+ */
90
+ planned?: boolean;
91
+
92
+ /**
93
+ * Component config object.
94
+ */
95
+ config?: Partial<typeof defaultConfig>;
96
+
97
+ /**
98
+ * Data-test attribute for automated testing.
99
+ */
100
+ dataTest?: string;
101
+ }
@@ -0,0 +1,18 @@
1
+ import useUI from "../composables/useUI.ts";
2
+
3
+ import defaultConfig from "./config.ts";
4
+
5
+ import type { UseAttrs } from "../types.ts";
6
+ import type { UMoneyProps, Config } from "./types.ts";
7
+
8
+ export function useAttrs(props: UMoneyProps): UseAttrs<Config> {
9
+ const { config, getKeysAttrs, hasSlotContent } = useUI<Config>(defaultConfig, () => props.config);
10
+
11
+ const keysAttrs = getKeysAttrs();
12
+
13
+ return {
14
+ config,
15
+ ...keysAttrs,
16
+ hasSlotContent,
17
+ };
18
+ }
@@ -9,7 +9,7 @@ export const SINGLE_ZERO = "0";
9
9
  export const DOUBLE_ZERO = "00";
10
10
 
11
11
  export function separatedMoney(
12
- money,
12
+ money: number,
13
13
  minFractionDigits = 0,
14
14
  maxFractionDigits = 2,
15
15
  decimalSeparator = ",",
@@ -1,130 +1,25 @@
1
- <template>
2
- <TransitionGroup
3
- ref="notificationsWrapperRef"
4
- :style="notifyPositionStyles"
5
- tag="div"
6
- v-bind="{ ...config.transitionGroup, ...wrapperAttrs }"
7
- >
8
- <div
9
- v-for="notification in notifications"
10
- :key="notification.id"
11
- v-bind="bodyAttrs"
12
- :class="getNotificationClasses(notification)"
13
- >
14
- <UIcon
15
- v-if="notification.type === NOTIFY_TYPE.success"
16
- color="green"
17
- variant="light"
18
- size="md"
19
- internal
20
- :name="config.defaults.successIcon"
21
- v-bind="successIconAttrs"
22
- data-test="type-notify"
23
- />
24
-
25
- <UIcon
26
- v-else-if="notification.type === NOTIFY_TYPE.warning"
27
- color="orange"
28
- variant="light"
29
- size="md"
30
- internal
31
- :name="config.defaults.warningIcon"
32
- v-bind="warningIconAttrs"
33
- data-test="type-notify"
34
- />
35
-
36
- <UIcon
37
- v-else-if="notification.type === NOTIFY_TYPE.error"
38
- data-test="type-notify"
39
- color="red"
40
- variant="light"
41
- size="md"
42
- internal
43
- :name="config.defaults.errorIcon"
44
- v-bind="errorIconAttrs"
45
- />
46
-
47
- <div v-bind="contentAttrs">
48
- <template v-if="html">
49
- <span v-bind="labelAttrs" v-html="notification.label" />
50
- <span
51
- v-bind="descriptionAttrs"
52
- v-html="getText(notification.description, notification.type)"
53
- />
54
- </template>
55
-
56
- <template v-else>
57
- <span v-bind="labelAttrs" v-text="notification.label" />
58
- <span
59
- v-bind="descriptionAttrs"
60
- v-text="getText(notification.description, notification.type)"
61
- />
62
- </template>
63
- </div>
64
-
65
- <UIcon
66
- color="gray"
67
- variant="light"
68
- size="xs"
69
- internal
70
- interactive
71
- :name="config.defaults.closeIcon"
72
- v-bind="closeIconAttrs"
73
- @click="onClickClose(notification)"
74
- />
75
- </div>
76
- </TransitionGroup>
77
- </template>
78
-
79
- <script setup>
1
+ <script lang="ts" setup>
80
2
  import { computed, onBeforeUnmount, onMounted, ref } from "vue";
81
3
  import { merge } from "lodash-es";
82
4
 
83
5
  import { cx, getDefault, vuelessConfig } from "../utils/ui.ts";
84
6
  import { useLocale } from "../composables/useLocale.ts";
85
- import useAttrs from "./useAttrs.js";
7
+ import useAttrs from "./useAttrs.ts";
86
8
 
87
- import defaultConfig from "./config.js";
88
- import { UNotify, NOTIFY_TYPE, POSITION } from "./constants.js";
9
+ import defaultConfig from "./config.ts";
10
+ import { UNotify, NOTIFY_TYPE, POSITION } from "./constants.ts";
89
11
 
90
12
  import UIcon from "../ui.image-icon/UIcon.vue";
91
13
 
14
+ import type { UNotifyProps } from "./types.ts";
15
+
92
16
  defineOptions({ inheritAttrs: false });
93
17
 
94
- const props = defineProps({
95
- /**
96
- * A position on the x-axis.
97
- * @values left, center, right
98
- */
99
- xPosition: {
100
- type: String,
101
- default: getDefault(defaultConfig, UNotify).xPosition,
102
- },
103
-
104
- /**
105
- * A position on the y-axis.
106
- * @values top, bottom
107
- */
108
- yPosition: {
109
- type: String,
110
- default: getDefault(defaultConfig, UNotify).yPosition,
111
- },
112
-
113
- /**
114
- * Use html to render you own content.
115
- */
116
- html: {
117
- type: Boolean,
118
- default: getDefault(defaultConfig, UNotify).html,
119
- },
120
-
121
- /**
122
- * Component config object.
123
- */
124
- config: {
125
- type: Object,
126
- default: () => ({}),
127
- },
18
+ const props = withDefaults(defineProps<UNotifyProps>(), {
19
+ xPosition: getDefault<UNotifyProps>(defaultConfig, UNotify).xPosition,
20
+ yPosition: getDefault<UNotifyProps>(defaultConfig, UNotify).yPosition,
21
+ html: getDefault<UNotifyProps>(defaultConfig, UNotify).html,
22
+ dataTest: "",
128
23
  });
129
24
 
130
25
  const {
@@ -238,3 +133,81 @@ function getNotificationClasses(notification) {
238
133
  }
239
134
  }
240
135
  </script>
136
+
137
+ <template>
138
+ <TransitionGroup
139
+ ref="notificationsWrapperRef"
140
+ :style="notifyPositionStyles"
141
+ tag="div"
142
+ v-bind="{ ...config.transitionGroup, ...wrapperAttrs }"
143
+ >
144
+ <div
145
+ v-for="notification in notifications"
146
+ :key="notification.id"
147
+ v-bind="bodyAttrs"
148
+ :class="getNotificationClasses(notification)"
149
+ >
150
+ <UIcon
151
+ v-if="notification.type === NOTIFY_TYPE.success"
152
+ color="green"
153
+ variant="light"
154
+ size="md"
155
+ internal
156
+ :name="config.defaults.successIcon"
157
+ v-bind="successIconAttrs"
158
+ data-test="type-notify"
159
+ />
160
+
161
+ <UIcon
162
+ v-else-if="notification.type === NOTIFY_TYPE.warning"
163
+ color="orange"
164
+ variant="light"
165
+ size="md"
166
+ internal
167
+ :name="config.defaults.warningIcon"
168
+ v-bind="warningIconAttrs"
169
+ data-test="type-notify"
170
+ />
171
+
172
+ <UIcon
173
+ v-else-if="notification.type === NOTIFY_TYPE.error"
174
+ data-test="type-notify"
175
+ color="red"
176
+ variant="light"
177
+ size="md"
178
+ internal
179
+ :name="config.defaults.errorIcon"
180
+ v-bind="errorIconAttrs"
181
+ />
182
+
183
+ <div v-bind="contentAttrs">
184
+ <template v-if="html">
185
+ <span v-bind="labelAttrs" v-html="notification.label" />
186
+ <span
187
+ v-bind="descriptionAttrs"
188
+ v-html="getText(notification.description, notification.type)"
189
+ />
190
+ </template>
191
+
192
+ <template v-else>
193
+ <span v-bind="labelAttrs" v-text="notification.label" />
194
+ <span
195
+ v-bind="descriptionAttrs"
196
+ v-text="getText(notification.description, notification.type)"
197
+ />
198
+ </template>
199
+ </div>
200
+
201
+ <UIcon
202
+ color="gray"
203
+ variant="light"
204
+ size="xs"
205
+ internal
206
+ interactive
207
+ :name="config.defaults.closeIcon"
208
+ v-bind="closeIconAttrs"
209
+ @click="onClickClose(notification)"
210
+ />
211
+ </div>
212
+ </TransitionGroup>
213
+ </template>
@@ -1,8 +1,8 @@
1
1
  import { Meta, Title, Subtitle, Description, Primary, Controls, Stories, Source, Markdown } from "@storybook/blocks";
2
2
  import { getSource } from "../../utils/storybook.ts";
3
3
 
4
- import * as stories from "./stories.js";
5
- import defaultConfig from "../config.js?raw"
4
+ import * as stories from "./stories.ts";
5
+ import defaultConfig from "../config.ts?raw"
6
6
 
7
7
  <Meta of={stories} />
8
8
  <Title of={stories} />
@@ -6,6 +6,13 @@ import UNotify from "../../ui.text-notify/UNotify.vue";
6
6
  import UButton from "../../ui.button/UButton.vue";
7
7
  import UCol from "../../ui.container-col/UCol.vue";
8
8
 
9
+ import type { Meta, StoryFn } from "@storybook/vue3";
10
+ import type { UNotifyProps } from "../types.ts";
11
+
12
+ interface UNotifyArgs extends UNotifyProps {
13
+ slotTemplate?: string;
14
+ }
15
+
9
16
  /**
10
17
  * The `UNotify` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.text-notify)
11
18
  */
@@ -23,9 +30,9 @@ export default {
23
30
  },
24
31
  },
25
32
  },
26
- };
33
+ } as Meta;
27
34
 
28
- const DefaultTemplate = (args) => ({
35
+ const DefaultTemplate: StoryFn<UNotifyArgs> = (args: UNotifyArgs) => ({
29
36
  components: { UNotify, UButton },
30
37
  setup() {
31
38
  function onClick() {
@@ -42,16 +49,16 @@ const DefaultTemplate = (args) => ({
42
49
  },
43
50
  template: `
44
51
  <UNotify class="m-4" v-bind="args">
45
- ${args.slotTemplate || getSlotsFragment()}
52
+ ${args.slotTemplate || getSlotsFragment("")}
46
53
  </UNotify>
47
54
  <UButton label="Show notify" @click="onClick"/>
48
55
  `,
49
56
  });
50
57
 
51
- const TypesTemplate = (args) => ({
58
+ const TypesTemplate: StoryFn<UNotifyArgs> = (args: UNotifyArgs) => ({
52
59
  components: { UNotify, UButton, UCol },
53
60
  setup() {
54
- function onClick(type) {
61
+ function onClick(type: string) {
55
62
  if (type === "success") {
56
63
  notify({
57
64
  type,
@@ -0,0 +1,25 @@
1
+ import defaultConfig from "./config.ts";
2
+
3
+ export type Config = Partial<typeof defaultConfig>;
4
+
5
+ export interface UNotifyProps {
6
+ /**
7
+ * A position on the x-axis.
8
+ */
9
+ xPosition?: "left" | "center" | "right";
10
+
11
+ /**
12
+ * A position on the y-axis.
13
+ */
14
+ yPosition?: "top" | "bottom";
15
+
16
+ /**
17
+ * Use html to render you own content.
18
+ */
19
+ html?: boolean;
20
+
21
+ /**
22
+ * Component config object.
23
+ */
24
+ config?: Partial<typeof defaultConfig>;
25
+ }
@@ -0,0 +1,18 @@
1
+ import useUI from "../composables/useUI.ts";
2
+
3
+ import defaultConfig from "./config.ts";
4
+
5
+ import type { UseAttrs } from "../types.ts";
6
+ import type { UNotifyProps, Config } from "./types.ts";
7
+
8
+ export default function useAttrs(props: UNotifyProps): UseAttrs<Config> {
9
+ const { config, getKeysAttrs, hasSlotContent } = useUI<Config>(defaultConfig, () => props.config);
10
+
11
+ const keysAttrs = getKeysAttrs();
12
+
13
+ return {
14
+ config,
15
+ ...keysAttrs,
16
+ hasSlotContent,
17
+ };
18
+ }
@@ -0,0 +1,140 @@
1
+ import { getRandomId, vuelessConfig } from "../utils/ui.ts";
2
+ import { DELAY_BETWEEN_CLONES, DURATION, LOCAL_STORAGE_ID, NOTIFY_TYPE } from "./constants.ts";
3
+
4
+ interface NotifyConfig {
5
+ type?: (typeof NOTIFY_TYPE)[keyof typeof NOTIFY_TYPE];
6
+ label?: string;
7
+ description?: string;
8
+ duration?: number;
9
+ ignoreDuplicates?: boolean;
10
+ }
11
+
12
+ interface NotifyEventDetail {
13
+ type: (typeof NOTIFY_TYPE)[keyof typeof NOTIFY_TYPE];
14
+ id: string;
15
+ label: string;
16
+ description: string;
17
+ duration: number;
18
+ }
19
+
20
+ interface VuelessNotifyConfig {
21
+ duration?: {
22
+ short?: number;
23
+ medium?: number;
24
+ long?: number;
25
+ };
26
+ }
27
+
28
+ const globalNotifyDuration = (vuelessConfig.component?.UNotify as VuelessNotifyConfig)?.duration;
29
+ const notifyClearAllEvent: Event = new Event("notifyClearAll");
30
+
31
+ let lastMessageTime: Date | undefined = undefined;
32
+ let lastMessage: string | undefined = undefined;
33
+
34
+ export function notify({
35
+ type,
36
+ label = "",
37
+ description = "",
38
+ duration,
39
+ ignoreDuplicates,
40
+ }: NotifyConfig = {}): void {
41
+ const notifyDuration: number = duration || globalNotifyDuration?.short || DURATION.short;
42
+
43
+ const isSameMessage = Boolean(
44
+ lastMessage === description &&
45
+ lastMessageTime &&
46
+ new Date().getTime() - lastMessageTime.getTime() < DELAY_BETWEEN_CLONES,
47
+ );
48
+
49
+ if ((isSameMessage || !description) && ignoreDuplicates) {
50
+ return;
51
+ }
52
+
53
+ lastMessageTime = new Date();
54
+ lastMessage = description;
55
+
56
+ const eventDetail: NotifyEventDetail = {
57
+ type: type as (typeof NOTIFY_TYPE)[keyof typeof NOTIFY_TYPE],
58
+ id: getRandomId(),
59
+ label,
60
+ description,
61
+ duration: notifyDuration,
62
+ };
63
+
64
+ const notifyStart: CustomEvent<NotifyEventDetail> = new CustomEvent("notifyStart", {
65
+ detail: eventDetail,
66
+ });
67
+ const notifyEnd: CustomEvent<NotifyEventDetail> = new CustomEvent("notifyEnd", {
68
+ detail: eventDetail,
69
+ });
70
+
71
+ window.dispatchEvent(notifyStart);
72
+
73
+ setTimeout(() => window.dispatchEvent(notifyEnd), notifyDuration);
74
+ }
75
+
76
+ export function notifySuccess({
77
+ label,
78
+ description,
79
+ duration,
80
+ ignoreDuplicates,
81
+ }: Omit<NotifyConfig, "type"> = {}): void {
82
+ notify({
83
+ label,
84
+ description,
85
+ ignoreDuplicates,
86
+ type: NOTIFY_TYPE.success,
87
+ duration: duration || globalNotifyDuration?.short || DURATION.short,
88
+ });
89
+ }
90
+
91
+ export function notifyWarning({
92
+ label,
93
+ description,
94
+ duration,
95
+ ignoreDuplicates,
96
+ }: Omit<NotifyConfig, "type"> = {}): void {
97
+ notify({
98
+ label,
99
+ description,
100
+ ignoreDuplicates,
101
+ type: NOTIFY_TYPE.warning,
102
+ duration: duration || globalNotifyDuration?.medium || DURATION.medium,
103
+ });
104
+ }
105
+
106
+ export function notifyError({
107
+ label,
108
+ description,
109
+ duration,
110
+ ignoreDuplicates,
111
+ }: Omit<NotifyConfig, "type"> = {}): void {
112
+ notify({
113
+ label,
114
+ description,
115
+ ignoreDuplicates,
116
+ type: NOTIFY_TYPE.error,
117
+ duration: duration || globalNotifyDuration?.long || DURATION.long,
118
+ });
119
+ }
120
+
121
+ export function clearNotifications(): void {
122
+ window.dispatchEvent(notifyClearAllEvent);
123
+ }
124
+
125
+ export function setDelayedNotify(settings: NotifyConfig): void {
126
+ localStorage.setItem(LOCAL_STORAGE_ID, JSON.stringify(settings));
127
+ }
128
+
129
+ export function getDelayedNotify(): void {
130
+ const notifyData: NotifyConfig | null = JSON.parse(
131
+ localStorage.getItem(LOCAL_STORAGE_ID) || "null",
132
+ );
133
+
134
+ clearNotifications();
135
+
136
+ if (notifyData) {
137
+ notify(notifyData);
138
+ localStorage.removeItem(LOCAL_STORAGE_ID);
139
+ }
140
+ }