@v-c/notification 2.0.0-beta.1 → 2.0.0-rc.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 (51) hide show
  1. package/dist/Notification.d.ts +7 -234
  2. package/dist/Notification.js +199 -135
  3. package/dist/NotificationList/Content.d.ts +3 -80
  4. package/dist/NotificationList/Content.js +33 -47
  5. package/dist/NotificationList/index.d.ts +7 -128
  6. package/dist/NotificationList/index.js +142 -122
  7. package/dist/NotificationProvider.d.ts +1 -20
  8. package/dist/NotificationProvider.js +2 -13
  9. package/dist/Notifications.d.ts +10 -132
  10. package/dist/Notifications.js +123 -108
  11. package/dist/Progress.d.ts +3 -3
  12. package/dist/Progress.js +24 -11
  13. package/dist/hooks/useClosable.d.ts +6 -11
  14. package/dist/hooks/useClosable.js +7 -6
  15. package/dist/hooks/useListPosition/index.d.ts +14 -13
  16. package/dist/hooks/useListPosition/index.js +16 -23
  17. package/dist/hooks/useListPosition/useSizes.d.ts +3 -6
  18. package/dist/hooks/useListPosition/useSizes.js +12 -10
  19. package/dist/hooks/useNoticeTimer.d.ts +5 -4
  20. package/dist/hooks/useNoticeTimer.js +33 -41
  21. package/dist/hooks/useNotification.d.ts +25 -7
  22. package/dist/hooks/useNotification.js +20 -25
  23. package/dist/hooks/useStack.d.ts +9 -8
  24. package/dist/hooks/useStack.js +17 -11
  25. package/dist/index.d.ts +9 -8
  26. package/dist/index.js +2 -2
  27. package/dist/interface.d.ts +30 -0
  28. package/dist/interface.js +0 -0
  29. package/docs/context.vue +1 -1
  30. package/docs/hooks.vue +4 -4
  31. package/docs/index.less +143 -62
  32. package/docs/maxCount.vue +1 -1
  33. package/docs/showProgress.vue +2 -2
  34. package/docs/stack.vue +1 -1
  35. package/package.json +2 -3
  36. package/src/Notification.tsx +128 -165
  37. package/src/NotificationList/Content.tsx +36 -54
  38. package/src/NotificationList/index.tsx +125 -141
  39. package/src/NotificationProvider.tsx +3 -23
  40. package/src/Notifications.tsx +62 -84
  41. package/src/Progress.tsx +19 -15
  42. package/src/hooks/useClosable.ts +15 -16
  43. package/src/hooks/useListPosition/index.ts +24 -40
  44. package/src/hooks/useListPosition/useSizes.ts +16 -15
  45. package/src/hooks/useNoticeTimer.ts +34 -45
  46. package/src/hooks/useNotification.tsx +71 -43
  47. package/src/hooks/useStack.ts +20 -24
  48. package/src/index.ts +28 -13
  49. package/src/interface.ts +45 -0
  50. package/vitest.config.ts +1 -3
  51. package/tests/index.spec.tsx +0 -200
@@ -1,48 +1,41 @@
1
1
  import useSizes from "./useSizes.js";
2
- import { computed, unref } from "vue";
2
+ import { computed } from "vue";
3
3
  //#region src/hooks/useListPosition/index.ts
4
4
  /**
5
5
  * Calculates each notification's position and the full list height.
6
+ * Mirrors rc-notification@2.0 useListPosition.
6
7
  */
7
- function useListPosition(configList, stack, gap = 0) {
8
+ function useListPosition(configList, stack, gap) {
8
9
  const [sizeMap, setNodeSize] = useSizes();
9
- const result = computed(() => {
10
- const list = unref(configList);
11
- const stackValue = unref(stack);
12
- const gapValue = unref(gap) ?? 0;
10
+ return [computed(() => {
13
11
  let offsetY = 0;
14
12
  let nextTotalHeight = 0;
15
- const stackThreshold = stackValue?.threshold ?? 0;
16
- const positions = /* @__PURE__ */ new Map();
13
+ const stackParams = stack.value;
14
+ const stackThreshold = stackParams?.threshold ?? 0;
15
+ const stackOffset = stackParams?.offset ?? 0;
16
+ const notificationPosition = /* @__PURE__ */ new Map();
17
17
  let topNoticeHeight;
18
18
  let topNoticeWidth;
19
- list.slice().reverse().forEach((config, index) => {
19
+ configList.value.slice().reverse().forEach((config, index) => {
20
20
  const key = String(config.key);
21
21
  const height = sizeMap.value[key]?.height ?? 0;
22
- const y = stackValue && index > 0 ? offsetY + (stackValue.offset ?? 0) - height : offsetY;
23
- positions.set(key, y);
22
+ const y = stackParams && index > 0 ? offsetY + stackOffset - height : offsetY;
23
+ notificationPosition.set(key, y);
24
24
  if (index === 0) {
25
25
  topNoticeHeight = height;
26
26
  topNoticeWidth = sizeMap.value[key]?.width ?? 0;
27
27
  }
28
- if (!stackValue || index < stackThreshold) nextTotalHeight = Math.max(nextTotalHeight, y + height);
29
- if (stackValue) offsetY = y + height;
30
- else offsetY += height + gapValue;
28
+ if (!stackParams || index < stackThreshold) nextTotalHeight = Math.max(nextTotalHeight, y + height);
29
+ if (stackParams) offsetY = y + height;
30
+ else offsetY += height + gap.value;
31
31
  });
32
32
  return {
33
- positions,
33
+ notificationPosition,
34
34
  totalHeight: nextTotalHeight,
35
35
  topNoticeHeight,
36
36
  topNoticeWidth
37
37
  };
38
- });
39
- return [
40
- computed(() => result.value.positions),
41
- setNodeSize,
42
- computed(() => result.value.totalHeight),
43
- computed(() => result.value.topNoticeHeight),
44
- computed(() => result.value.topNoticeWidth)
45
- ];
38
+ }), setNodeSize];
46
39
  }
47
40
  //#endregion
48
41
  export { useListPosition as default };
@@ -1,13 +1,10 @@
1
- import { Ref } from 'vue';
2
1
  export interface NodeSize {
3
2
  width: number;
4
3
  height: number;
5
4
  }
6
5
  export type NodeSizeMap = Record<string, NodeSize>;
7
6
  /**
8
- * Track measured node sizes by key. Returns the size map ref and a setter callback.
7
+ * Stores measured node sizes by key and exposes a callback to update them.
8
+ * Mirrors rc-notification@2.0 useSizes.
9
9
  */
10
- export default function useSizes(): [
11
- Ref<NodeSizeMap>,
12
- (key: string, node: HTMLElement | null) => void
13
- ];
10
+ export default function useSizes(): readonly [import('vue').ShallowRef<NodeSizeMap, NodeSizeMap>, (key: string, node: HTMLDivElement | null) => void];
@@ -1,28 +1,30 @@
1
- import { ref } from "vue";
1
+ import { shallowRef } from "vue";
2
2
  //#region src/hooks/useListPosition/useSizes.ts
3
3
  /**
4
- * Track measured node sizes by key. Returns the size map ref and a setter callback.
4
+ * Stores measured node sizes by key and exposes a callback to update them.
5
+ * Mirrors rc-notification@2.0 useSizes.
5
6
  */
6
7
  function useSizes() {
7
- const sizeMap = ref({});
8
- function setNodeSize(key, node) {
8
+ const sizeMap = shallowRef({});
9
+ const setNodeSize = (key, node) => {
9
10
  if (!node) {
10
11
  if (!(key in sizeMap.value)) return;
11
- const { [key]: _, ...rest } = sizeMap.value;
12
- sizeMap.value = rest;
12
+ const next = { ...sizeMap.value };
13
+ delete next[key];
14
+ sizeMap.value = next;
13
15
  return;
14
16
  }
15
- const next = {
17
+ const nextSize = {
16
18
  width: node.offsetWidth,
17
19
  height: node.offsetHeight
18
20
  };
19
21
  const prev = sizeMap.value[key];
20
- if (prev && prev.width === next.width && prev.height === next.height) return;
22
+ if (prev && prev.width === nextSize.width && prev.height === nextSize.height) return;
21
23
  sizeMap.value = {
22
24
  ...sizeMap.value,
23
- [key]: next
25
+ [key]: nextSize
24
26
  };
25
- }
27
+ };
26
28
  return [sizeMap, setNodeSize];
27
29
  }
28
30
  //#endregion
@@ -1,6 +1,7 @@
1
- import { ComputedRef, MaybeRef } from 'vue';
1
+ import { ComputedRef } from 'vue';
2
2
  /**
3
- * Run the auto-close timer for a notice and report progress updates.
4
- * Returns controls to pause and resume the timer.
3
+ * Runs the notice auto-close timer and reports progress updates via rAF.
4
+ * Returns controls to pause and resume the timer. Mirrors rc-notification@2.0
5
+ * useNoticeTimer.
5
6
  */
6
- export default function useNoticeTimer(duration: MaybeRef<number | false | null | undefined>, onClose: () => void, onUpdate: (ptg: number) => void): [() => void, () => void, ComputedRef<number>];
7
+ export default function useNoticeTimer(duration: ComputedRef<number | false | null | undefined>, onClose: () => void, onUpdate: (percent: number) => void): [() => void, () => void];
@@ -1,71 +1,63 @@
1
- import { computed, onBeforeUnmount, shallowRef, unref, watch } from "vue";
2
- import raf from "@v-c/util/dist/raf";
1
+ import { onScopeDispose, shallowRef, watch } from "vue";
3
2
  //#region src/hooks/useNoticeTimer.ts
4
3
  /**
5
- * Run the auto-close timer for a notice and report progress updates.
6
- * Returns controls to pause and resume the timer.
4
+ * Runs the notice auto-close timer and reports progress updates via rAF.
5
+ * Returns controls to pause and resume the timer. Mirrors rc-notification@2.0
6
+ * useNoticeTimer.
7
7
  */
8
8
  function useNoticeTimer(duration, onClose, onUpdate) {
9
- const durationMs = computed(() => {
10
- const value = unref(duration);
11
- return Math.max(typeof value === "number" ? value : 0, 0) * 1e3;
12
- });
13
- const walking = shallowRef(durationMs.value > 0);
14
- const passTime = shallowRef(0);
9
+ const durationMs = shallowRef(0);
10
+ const walking = shallowRef(false);
11
+ let passTime = 0;
15
12
  let lastRafTime = null;
16
13
  let rafId = null;
17
- function syncPassTime() {
14
+ const syncPassTime = () => {
18
15
  const now = Date.now();
19
- if (lastRafTime !== null) passTime.value += now - lastRafTime;
16
+ if (lastRafTime !== null) passTime += now - lastRafTime;
20
17
  lastRafTime = now;
21
- }
22
- function cancelRaf() {
18
+ };
19
+ const cancelStep = () => {
23
20
  if (rafId !== null) {
24
- raf.cancel(rafId);
21
+ cancelAnimationFrame(rafId);
25
22
  rafId = null;
26
23
  }
27
- }
28
- function onPause() {
24
+ };
25
+ const onPause = () => {
29
26
  syncPassTime();
30
27
  walking.value = false;
31
- }
32
- function onResume() {
28
+ };
29
+ const onResume = () => {
33
30
  if (durationMs.value > 0) {
34
31
  lastRafTime = Date.now();
35
32
  walking.value = true;
36
33
  } else onUpdate(0);
37
- }
38
- watch(durationMs, () => {
39
- passTime.value = 0;
40
- lastRafTime = null;
34
+ };
35
+ watch(duration, () => {
36
+ const next = typeof duration.value === "number" ? duration.value : 0;
37
+ durationMs.value = Math.max(next, 0) * 1e3;
38
+ passTime = 0;
41
39
  walking.value = durationMs.value > 0;
42
- });
40
+ }, { immediate: true });
43
41
  watch(walking, (isWalking) => {
44
- cancelRaf();
42
+ cancelStep();
45
43
  if (!isWalking) return;
46
- function step() {
44
+ lastRafTime = Date.now();
45
+ const step = () => {
47
46
  syncPassTime();
48
- if (passTime.value >= durationMs.value) {
47
+ if (passTime >= durationMs.value) {
49
48
  onUpdate(1);
50
49
  onClose();
51
- } else {
52
- onUpdate(Math.min(passTime.value / durationMs.value, 1));
53
- rafId = raf(step);
50
+ return;
54
51
  }
55
- }
52
+ onUpdate(Math.min(passTime / durationMs.value, 1));
53
+ rafId = requestAnimationFrame(step);
54
+ };
56
55
  step();
57
56
  }, { immediate: true });
58
- onBeforeUnmount(() => {
59
- cancelRaf();
57
+ onScopeDispose(() => {
58
+ cancelStep();
60
59
  });
61
- return [
62
- onResume,
63
- onPause,
64
- computed(() => {
65
- if (durationMs.value <= 0) return 0;
66
- return Math.min(passTime.value / durationMs.value, 1);
67
- })
68
- ];
60
+ return [onResume, onPause];
69
61
  }
70
62
  //#endregion
71
63
  export { useNoticeTimer as default };
@@ -1,15 +1,33 @@
1
+ import { CSSProperties, MaybeRef, TransitionGroupProps } from 'vue';
1
2
  import { VueNode } from '@v-c/util/dist/type';
2
- import { MaybeRef } from 'vue';
3
- import { NotificationListConfig, Placement } from '../NotificationList';
3
+ import { ClosableType, Key, NotificationListConfig, Placement, StackConfig } from '../interface';
4
+ import { ComponentsType } from '../Notification';
5
+ import { NotificationClassNames, NotificationStyles } from '../NotificationList';
4
6
  import { NotificationsProps } from '../Notifications';
5
- type Key = string | number | symbol;
6
7
  type OptionalConfig = Partial<NotificationListConfig>;
7
- export interface NotificationConfig extends Omit<NotificationsProps, 'container'> {
8
- placement?: Placement;
8
+ export interface NotificationConfig {
9
+ prefixCls?: string;
10
+ /** Customize container. It will repeat call which means you should return same container element. */
9
11
  getContainer?: () => HTMLElement | ShadowRoot;
10
- closable?: NotificationListConfig['closable'];
12
+ motion?: TransitionGroupProps | ((placement: Placement) => TransitionGroupProps);
13
+ closable?: ClosableType;
14
+ maxCount?: number;
11
15
  duration?: number | false | null;
12
- showProgress?: NotificationListConfig['showProgress'];
16
+ showProgress?: boolean;
17
+ pauseOnHover?: boolean;
18
+ placement?: Placement;
19
+ classNames?: NotificationClassNames;
20
+ styles?: NotificationStyles;
21
+ components?: ComponentsType;
22
+ /** @private. Config for notification holder style. Safe to remove if refactor */
23
+ className?: (placement: Placement) => string;
24
+ /** @private. Config for notification holder style. Safe to remove if refactor */
25
+ style?: (placement: Placement) => CSSProperties;
26
+ /** @private Trigger when all the notification closed. */
27
+ onAllRemoved?: VoidFunction;
28
+ stack?: StackConfig;
29
+ /** @private Slot for style in Notifications */
30
+ renderNotifications?: NotificationsProps['renderNotifications'];
13
31
  }
14
32
  export interface NotificationAPI {
15
33
  open: (config: OptionalConfig) => void;
@@ -7,8 +7,8 @@ function mergeConfig(...objList) {
7
7
  const clone = {};
8
8
  objList.forEach((obj) => {
9
9
  if (obj) Object.keys(obj).forEach((key) => {
10
- const value = obj[key];
11
- if (value !== void 0) clone[key] = value;
10
+ const val = obj[key];
11
+ if (val !== void 0) clone[key] = val;
12
12
  });
13
13
  });
14
14
  return clone;
@@ -16,23 +16,17 @@ function mergeConfig(...objList) {
16
16
  function useNotification(rootConfig = {}) {
17
17
  const configRef = computed(() => unref(rootConfig) || {});
18
18
  const container = shallowRef();
19
- const notificationsRef = shallowRef();
20
- const taskQueue = shallowRef([]);
19
+ const notificationRef = shallowRef();
21
20
  const shareConfig = computed(() => {
22
- const { placement, closable, duration, showProgress } = configRef.value;
23
- return {
24
- placement,
25
- closable,
26
- duration,
27
- showProgress
28
- };
21
+ const { getContainer, motion, prefixCls, maxCount, className, style, onAllRemoved, stack, renderNotifications, pauseOnHover, classNames, styles, components, ...restConfig } = configRef.value;
22
+ return restConfig;
29
23
  });
30
- function resolveContainer() {
24
+ const resolveContainer = () => {
31
25
  return (configRef.value.getContainer || defaultGetContainer)();
32
- }
26
+ };
33
27
  const contextHolder = () => createVNode(Notifications, {
34
28
  "container": container.value,
35
- "ref": notificationsRef,
29
+ "ref": notificationRef,
36
30
  "prefixCls": configRef.value.prefixCls,
37
31
  "motion": configRef.value.motion,
38
32
  "maxCount": configRef.value.maxCount,
@@ -46,16 +40,17 @@ function useNotification(rootConfig = {}) {
46
40
  "stack": configRef.value.stack,
47
41
  "renderNotifications": configRef.value.renderNotifications
48
42
  }, null);
43
+ const taskQueue = shallowRef([]);
49
44
  const api = {
50
45
  open(config) {
51
- const merged = mergeConfig(shareConfig.value, config);
52
- if (merged.key === null || merged.key === void 0) {
53
- merged.key = `vc-notification-${uniqueKey}`;
46
+ const mergedConfig = mergeConfig(shareConfig.value, config);
47
+ if (mergedConfig.key === null || mergedConfig.key === void 0) {
48
+ mergedConfig.key = `vc-notification-${uniqueKey}`;
54
49
  uniqueKey += 1;
55
50
  }
56
51
  taskQueue.value = [...taskQueue.value, {
57
52
  type: "open",
58
- config: merged
53
+ config: mergedConfig
59
54
  }];
60
55
  },
61
56
  close(key) {
@@ -75,22 +70,22 @@ function useNotification(rootConfig = {}) {
75
70
  container.value = resolveContainer();
76
71
  });
77
72
  watch(taskQueue, () => {
78
- if (notificationsRef.value && taskQueue.value.length) {
79
- const tasks = taskQueue.value;
80
- tasks.forEach((task) => {
73
+ if (notificationRef.value && taskQueue.value.length) {
74
+ taskQueue.value.forEach((task) => {
81
75
  switch (task.type) {
82
76
  case "open":
83
- notificationsRef.value?.open(task.config);
77
+ notificationRef.value?.open(task.config);
84
78
  break;
85
79
  case "close":
86
- notificationsRef.value?.close(task.key);
80
+ notificationRef.value?.close(task.key);
87
81
  break;
88
82
  case "destroy":
89
- notificationsRef.value?.destroy();
83
+ notificationRef.value?.destroy();
90
84
  break;
85
+ default: break;
91
86
  }
92
87
  });
93
- taskQueue.value = taskQueue.value.filter((task) => !tasks.includes(task));
88
+ taskQueue.value = [];
94
89
  }
95
90
  });
96
91
  return [api, contextHolder];
@@ -1,10 +1,11 @@
1
- import { ComputedRef, MaybeRef } from 'vue';
2
- export interface StackConfig {
3
- threshold?: number;
4
- offset?: number;
5
- }
6
- type StackParams = Required<StackConfig>;
7
- export type StackInput = boolean | StackConfig;
8
- type UseStack = (config?: MaybeRef<StackInput | undefined>) => [ComputedRef<boolean>, ComputedRef<StackParams>];
1
+ import { ComputedRef, MaybeRef, ToRefs } from 'vue';
2
+ import { StackConfig } from '../interface';
3
+ type StackParams = Exclude<StackConfig, boolean>;
4
+ type UseStack = (config?: MaybeRef<StackConfig | undefined>) => [ComputedRef<boolean>, ToRefs<StackParams>];
5
+ /**
6
+ * Resolves the stack setting into an enabled flag and normalized stack params.
7
+ * Mirrors rc-notification@2.0 useStack. The `gap` config is no longer surfaced
8
+ * here gap is now read from the list-content CSS `gap`/`row-gap`.
9
+ */
9
10
  declare const useStack: UseStack;
10
11
  export default useStack;
@@ -1,19 +1,25 @@
1
- import { computed, unref } from "vue";
1
+ import { computed, reactive, toRefs, unref, watchEffect } from "vue";
2
2
  //#region src/hooks/useStack.ts
3
3
  var DEFAULT_OFFSET = 8;
4
4
  var DEFAULT_THRESHOLD = 3;
5
+ /**
6
+ * Resolves the stack setting into an enabled flag and normalized stack params.
7
+ * Mirrors rc-notification@2.0 useStack. The `gap` config is no longer surfaced
8
+ * here — gap is now read from the list-content CSS `gap`/`row-gap`.
9
+ */
5
10
  var useStack = (config) => {
6
- return [computed(() => !!unref(config)), computed(() => {
11
+ const result = reactive({
12
+ offset: DEFAULT_OFFSET,
13
+ threshold: DEFAULT_THRESHOLD
14
+ });
15
+ watchEffect(() => {
7
16
  const value = unref(config);
8
- if (value && typeof value === "object") return {
9
- offset: value.offset ?? DEFAULT_OFFSET,
10
- threshold: value.threshold ?? DEFAULT_THRESHOLD
11
- };
12
- return {
13
- offset: DEFAULT_OFFSET,
14
- threshold: DEFAULT_THRESHOLD
15
- };
16
- })];
17
+ if (value && typeof value === "object") {
18
+ result.offset = value.offset ?? DEFAULT_OFFSET;
19
+ result.threshold = value.threshold ?? DEFAULT_THRESHOLD;
20
+ }
21
+ });
22
+ return [computed(() => !!unref(config)), toRefs(result)];
17
23
  };
18
24
  //#endregion
19
25
  export { useStack as default };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { NotificationAPI, NotificationConfig, default as useNotification } from './hooks/useNotification';
2
- import { ComponentsType, NotificationProps, default as Notification } from './Notification';
3
- import { NotificationProgressProps, default as Progress } from './Progress';
4
- import { default as NotificationList } from './NotificationList';
5
- import { default as NotificationProvider, useNotificationProvider } from './NotificationProvider';
6
- export { Notification, NotificationList, NotificationProvider, Progress, useNotification, useNotificationProvider, };
7
- export type { ComponentsType, NotificationAPI, NotificationConfig, NotificationProgressProps, NotificationProps, };
8
- export type { NotificationClassNames, NotificationListConfig, NotificationListProps, NotificationStyles, Placement, StackConfig, StackInput, } from './NotificationList';
1
+ import { default as useNotification, NotificationAPI, NotificationConfig } from './hooks/useNotification';
2
+ import { default as Notification, ComponentsType, NotificationClassNames as NoticeClassNames, NotificationProps, NotificationStyles as NoticeStyles } from './Notification';
3
+ import { default as NotificationList, NotificationClassNames, NotificationListProps, NotificationStyles, Placement } from './NotificationList';
4
+ import { useNotificationContext, useNotificationProvider } from './NotificationProvider';
5
+ import { default as Progress, NotificationProgressProps } from './Progress';
6
+ import { Key, NotificationListConfig, StackConfig } from './interface';
7
+ import { ClosableType, ParsedClosableConfig } from './hooks/useClosable';
8
+ export { Notification, NotificationList, Progress, useNotification, useNotificationContext, useNotificationProvider, };
9
+ export type { ClosableType, ComponentsType, Key, NoticeClassNames, NoticeStyles, NotificationAPI, NotificationClassNames, NotificationConfig, NotificationListConfig, NotificationListProps, NotificationProgressProps, NotificationProps, NotificationStyles, ParsedClosableConfig, Placement, StackConfig, };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import Progress from "./Progress.js";
2
2
  import Notification from "./Notification.js";
3
- import NotificationProvider, { useNotificationProvider } from "./NotificationProvider.js";
3
+ import { useNotificationContext, useNotificationProvider } from "./NotificationProvider.js";
4
4
  import NotificationList from "./NotificationList/index.js";
5
5
  import useNotification from "./hooks/useNotification.js";
6
- export { Notification, NotificationList, NotificationProvider, Progress, useNotification, useNotificationProvider };
6
+ export { Notification, NotificationList, Progress, useNotification, useNotificationContext, useNotificationProvider };
@@ -0,0 +1,30 @@
1
+ import { ClosableType } from './hooks/useClosable';
2
+ import { ComponentsType, NotificationProps } from './Notification';
3
+ export type Placement = 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight';
4
+ export type Key = string | number;
5
+ export type StackConfig = boolean | {
6
+ /**
7
+ * When the notice count exceeds this threshold, notices will be stacked.
8
+ * @default 3
9
+ */
10
+ threshold?: number;
11
+ /**
12
+ * Vertical offset applied between stacked notices.
13
+ * @default 8
14
+ */
15
+ offset?: number;
16
+ };
17
+ /**
18
+ * Configuration accepted by the public `api.open` call.
19
+ * Mirrors rc-notification@2.0 NotificationListConfig.
20
+ */
21
+ export interface NotificationListConfig extends Omit<NotificationProps, 'prefixCls'> {
22
+ key: Key;
23
+ placement?: Placement;
24
+ times?: number;
25
+ }
26
+ export type Placements = Partial<Record<Placement, NotificationListConfig[]>>;
27
+ export type InnerOpenConfig = NotificationListConfig & {
28
+ times?: number;
29
+ };
30
+ export type { ClosableType, ComponentsType, NotificationProps, };
File without changes
package/docs/context.vue CHANGED
@@ -5,7 +5,7 @@ import motion from './motion'
5
5
 
6
6
  const [{ open }, holder] = useNotification({ motion })
7
7
  const NOTICE = {
8
- description: h('span', ['simple show']),
8
+ content: h('span', ['simple show']),
9
9
  onclose() {
10
10
  console.log('simple close')
11
11
  },
package/docs/hooks.vue CHANGED
@@ -11,7 +11,7 @@ const [notice, contextHolder] = useNotification({ motion, closable: true })
11
11
  <button
12
12
  @click="() => {
13
13
  notice.open({
14
- description: `${new Date().toISOString()}`,
14
+ content: `${new Date().toISOString()}`,
15
15
  })
16
16
  }"
17
17
  >
@@ -20,7 +20,7 @@ const [notice, contextHolder] = useNotification({ motion, closable: true })
20
20
  <button
21
21
  @click="() => {
22
22
  notice.open({
23
- description: `${Array(Math.round(Math.random() * 5) + 1)
23
+ content: `${Array(Math.round(Math.random() * 5) + 1)
24
24
  .fill(1)
25
25
  .map(() => new Date().toISOString())
26
26
  .join('\n')}`,
@@ -34,7 +34,7 @@ const [notice, contextHolder] = useNotification({ motion, closable: true })
34
34
  <button
35
35
  @click="() => {
36
36
  notice.open({
37
- description: `${Array(5)
37
+ content: `${Array(5)
38
38
  .fill(1)
39
39
  .map(() => new Date().toISOString())
40
40
  .join('\n')}`,
@@ -50,7 +50,7 @@ const [notice, contextHolder] = useNotification({ motion, closable: true })
50
50
  <button
51
51
  @click="() => {
52
52
  notice.open({
53
- description: `No Close! ${new Date().toISOString()}`,
53
+ content: `No Close! ${new Date().toISOString()}`,
54
54
  duration: null,
55
55
  closable: false,
56
56
  key: 'No Close',