@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,4 +1,4 @@
1
- import { InjectionKey, PropType, Ref } from 'vue';
1
+ import { InjectionKey, Ref } from 'vue';
2
2
  export interface NotificationContextProps {
3
3
  classNames?: {
4
4
  notice?: string;
@@ -8,22 +8,3 @@ export interface NotificationContextProps {
8
8
  export declare const NotificationContext: InjectionKey<Ref<NotificationContextProps>>;
9
9
  export declare function useNotificationProvider(props: Ref<NotificationContextProps>): Ref<NotificationContextProps, NotificationContextProps>;
10
10
  export declare function useNotificationContext(): Ref<{}, {}>;
11
- declare const NotificationProvider: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
12
- classNames: {
13
- type: PropType<NotificationContextProps["classNames"]>;
14
- default: undefined;
15
- };
16
- }>, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
17
- [key: string]: any;
18
- }>[] | undefined, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
19
- classNames: {
20
- type: PropType<NotificationContextProps["classNames"]>;
21
- default: undefined;
22
- };
23
- }>> & Readonly<{}>, {
24
- classNames: {
25
- notice?: string;
26
- list?: string;
27
- } | undefined;
28
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
29
- export default NotificationProvider;
@@ -1,4 +1,4 @@
1
- import { computed, defineComponent, inject, provide, ref } from "vue";
1
+ import { inject, provide, ref } from "vue";
2
2
  //#region src/NotificationProvider.tsx
3
3
  var NotificationContext = Symbol("NotificationContext");
4
4
  function useNotificationProvider(props) {
@@ -8,16 +8,5 @@ function useNotificationProvider(props) {
8
8
  function useNotificationContext() {
9
9
  return inject(NotificationContext, ref({}));
10
10
  }
11
- var NotificationProvider = /* @__PURE__ */ defineComponent({
12
- name: "NotificationProvider",
13
- props: { classNames: {
14
- type: Object,
15
- default: void 0
16
- } },
17
- setup(props, { slots }) {
18
- provide(NotificationContext, computed(() => ({ classNames: props.classNames })));
19
- return () => slots.default?.();
20
- }
21
- });
22
11
  //#endregion
23
- export { NotificationContext, NotificationProvider as default, useNotificationContext, useNotificationProvider };
12
+ export { NotificationContext, useNotificationContext, useNotificationProvider };
@@ -1,20 +1,21 @@
1
+ import { CSSProperties, TransitionGroupProps } from 'vue';
1
2
  import { VueNode } from '@v-c/util/dist/type';
2
- import { CSSProperties, PropType, TransitionGroupProps } from 'vue';
3
- import { ComponentsType, NotificationClassNames, NotificationListConfig, NotificationStyles, Placement, StackInput } from './NotificationList';
4
- type Key = string | number | symbol;
3
+ import { Key, NotificationListConfig, Placement, StackConfig } from './interface';
4
+ import { ComponentsType } from './Notification';
5
+ import { NotificationClassNames, NotificationStyles } from './NotificationList';
5
6
  export interface NotificationsProps {
6
7
  prefixCls?: string;
8
+ motion?: TransitionGroupProps | ((placement: Placement) => TransitionGroupProps);
9
+ container?: HTMLElement | ShadowRoot;
10
+ maxCount?: number;
11
+ pauseOnHover?: boolean;
7
12
  classNames?: NotificationClassNames;
8
13
  styles?: NotificationStyles;
9
14
  components?: ComponentsType;
10
15
  className?: (placement: Placement) => string;
11
16
  style?: (placement: Placement) => CSSProperties;
12
- container?: HTMLElement | ShadowRoot;
13
- motion?: TransitionGroupProps | ((placement: Placement) => TransitionGroupProps);
14
- maxCount?: number;
15
- pauseOnHover?: boolean;
16
- stack?: StackInput;
17
17
  onAllRemoved?: VoidFunction;
18
+ stack?: StackConfig;
18
19
  renderNotifications?: (node: VueNode, info: {
19
20
  prefixCls: string;
20
21
  key: Key;
@@ -25,128 +26,5 @@ export interface NotificationsRef {
25
26
  close: (key: Key) => void;
26
27
  destroy: () => void;
27
28
  }
28
- declare const Notifications: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
29
- prefixCls: {
30
- type: StringConstructor;
31
- default: string;
32
- };
33
- classNames: {
34
- type: PropType<NotificationClassNames>;
35
- default: undefined;
36
- };
37
- styles: {
38
- type: PropType<NotificationStyles>;
39
- default: undefined;
40
- };
41
- components: {
42
- type: PropType<ComponentsType>;
43
- default: undefined;
44
- };
45
- className: {
46
- type: PropType<(p: Placement) => string>;
47
- default: undefined;
48
- };
49
- style: {
50
- type: PropType<(p: Placement) => CSSProperties>;
51
- default: undefined;
52
- };
53
- container: {
54
- type: PropType<HTMLElement | ShadowRoot>;
55
- default: undefined;
56
- };
57
- motion: {
58
- type: PropType<NotificationsProps["motion"]>;
59
- default: undefined;
60
- };
61
- maxCount: {
62
- type: NumberConstructor;
63
- default: undefined;
64
- };
65
- pauseOnHover: {
66
- type: BooleanConstructor;
67
- default: undefined;
68
- };
69
- stack: {
70
- type: PropType<StackInput>;
71
- default: undefined;
72
- };
73
- onAllRemoved: {
74
- type: PropType<VoidFunction>;
75
- default: undefined;
76
- };
77
- renderNotifications: {
78
- type: PropType<NotificationsProps["renderNotifications"]>;
79
- default: undefined;
80
- };
81
- }>, () => import("vue/jsx-runtime").JSX.Element | null, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
82
- prefixCls: {
83
- type: StringConstructor;
84
- default: string;
85
- };
86
- classNames: {
87
- type: PropType<NotificationClassNames>;
88
- default: undefined;
89
- };
90
- styles: {
91
- type: PropType<NotificationStyles>;
92
- default: undefined;
93
- };
94
- components: {
95
- type: PropType<ComponentsType>;
96
- default: undefined;
97
- };
98
- className: {
99
- type: PropType<(p: Placement) => string>;
100
- default: undefined;
101
- };
102
- style: {
103
- type: PropType<(p: Placement) => CSSProperties>;
104
- default: undefined;
105
- };
106
- container: {
107
- type: PropType<HTMLElement | ShadowRoot>;
108
- default: undefined;
109
- };
110
- motion: {
111
- type: PropType<NotificationsProps["motion"]>;
112
- default: undefined;
113
- };
114
- maxCount: {
115
- type: NumberConstructor;
116
- default: undefined;
117
- };
118
- pauseOnHover: {
119
- type: BooleanConstructor;
120
- default: undefined;
121
- };
122
- stack: {
123
- type: PropType<StackInput>;
124
- default: undefined;
125
- };
126
- onAllRemoved: {
127
- type: PropType<VoidFunction>;
128
- default: undefined;
129
- };
130
- renderNotifications: {
131
- type: PropType<NotificationsProps["renderNotifications"]>;
132
- default: undefined;
133
- };
134
- }>> & Readonly<{}>, {
135
- style: (p: Placement) => CSSProperties;
136
- prefixCls: string;
137
- classNames: NotificationClassNames;
138
- styles: NotificationStyles;
139
- components: ComponentsType;
140
- pauseOnHover: boolean;
141
- container: HTMLElement | ShadowRoot;
142
- motion: TransitionGroupProps | ((placement: Placement) => TransitionGroupProps) | undefined;
143
- stack: StackInput;
144
- onAllRemoved: VoidFunction;
145
- renderNotifications: ((node: VueNode, info: {
146
- prefixCls: string;
147
- key: Key;
148
- }) => VueNode) | undefined;
149
- className: (p: Placement) => string;
150
- maxCount: number;
151
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
29
+ declare const Notifications: import('vue').DefineSetupFnComponent<NotificationsProps, {}, {}, NotificationsProps & {}, import('vue').PublicProps>;
152
30
  export default Notifications;
@@ -1,149 +1,164 @@
1
1
  import NotificationList from "./NotificationList/index.js";
2
- import { Teleport, createVNode, defineComponent, isVNode, shallowRef, watch } from "vue";
2
+ import { Teleport, createVNode, defineComponent, isVNode, mergeDefaults, shallowRef, watch } from "vue";
3
3
  //#region src/Notifications.tsx
4
4
  function _isSlot(s) {
5
5
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
6
6
  }
7
- var Notifications = /* @__PURE__ */ defineComponent({
8
- name: "Notifications",
9
- inheritAttrs: false,
10
- props: {
7
+ var defaults = { prefixCls: "vc-notification" };
8
+ var Notifications = /* @__PURE__ */ defineComponent((props, { expose }) => {
9
+ const configList = shallowRef([]);
10
+ const onNoticeClose = (key) => {
11
+ const config = configList.value.find((item) => item.key === key);
12
+ const closable = config?.closable;
13
+ (closable && typeof closable === "object" ? closable : null)?.onClose?.();
14
+ config?.onClose?.();
15
+ configList.value = configList.value.filter((item) => item.key !== key);
16
+ };
17
+ expose({
18
+ open: (config) => {
19
+ const list = configList.value;
20
+ let clone = [...list];
21
+ const index = clone.findIndex((item) => item.key === config.key);
22
+ const innerConfig = { ...config };
23
+ if (index >= 0) {
24
+ innerConfig.times = (list[index]?.times ?? 0) + 1;
25
+ clone[index] = innerConfig;
26
+ } else {
27
+ innerConfig.times = 0;
28
+ clone.push(innerConfig);
29
+ }
30
+ const maxCount = props.maxCount ?? 0;
31
+ if (maxCount > 0 && clone.length > maxCount) clone = clone.slice(-maxCount);
32
+ configList.value = clone;
33
+ },
34
+ close: onNoticeClose,
35
+ destroy: () => {
36
+ configList.value = [];
37
+ }
38
+ });
39
+ const placements = shallowRef({});
40
+ watch(configList, () => {
41
+ const next = {};
42
+ configList.value.forEach((config) => {
43
+ const placement = config.placement ?? "topRight";
44
+ next[placement] = next[placement] || [];
45
+ next[placement].push(config);
46
+ });
47
+ Object.keys(placements.value).forEach((placement) => {
48
+ next[placement] = next[placement] || [];
49
+ });
50
+ placements.value = next;
51
+ });
52
+ const onAllNoticeRemoved = (placement) => {
53
+ const clone = { ...placements.value };
54
+ if (!(clone[placement] || []).length) delete clone[placement];
55
+ placements.value = clone;
56
+ };
57
+ const emptyRef = shallowRef(false);
58
+ watch(placements, () => {
59
+ if (Object.keys(placements.value).length > 0) emptyRef.value = true;
60
+ else if (emptyRef.value) {
61
+ props?.onAllRemoved?.();
62
+ emptyRef.value = false;
63
+ }
64
+ });
65
+ return () => {
66
+ let _slot;
67
+ const { container } = props;
68
+ const prefixCls = props.prefixCls ?? defaults.prefixCls;
69
+ if (!container) return null;
70
+ return createVNode(Teleport, { "to": container }, _isSlot(_slot = Object.keys(placements.value).map((rawPlacement) => {
71
+ const placement = rawPlacement;
72
+ const placementConfigList = placements.value[placement];
73
+ const list = createVNode(NotificationList, {
74
+ "key": placement,
75
+ "configList": placementConfigList,
76
+ "placement": placement,
77
+ "prefixCls": prefixCls,
78
+ "pauseOnHover": props.pauseOnHover,
79
+ "classNames": props.classNames,
80
+ "styles": props.styles,
81
+ "components": props.components,
82
+ "className": props.className?.(placement),
83
+ "style": props.style?.(placement),
84
+ "motion": props.motion,
85
+ "stack": props.stack,
86
+ "onAllRemoved": onAllNoticeRemoved,
87
+ "onNoticeClose": onNoticeClose
88
+ }, null);
89
+ return props.renderNotifications ? props.renderNotifications(list, {
90
+ prefixCls,
91
+ key: placement
92
+ }) : list;
93
+ })) ? _slot : { default: () => [_slot] });
94
+ };
95
+ }, {
96
+ props: /* @__PURE__ */ mergeDefaults({
11
97
  prefixCls: {
12
98
  type: String,
13
- default: "vc-notification"
99
+ required: false,
100
+ default: void 0
101
+ },
102
+ motion: {
103
+ type: [Object, Function],
104
+ required: false,
105
+ default: void 0
106
+ },
107
+ container: {
108
+ required: false,
109
+ default: void 0
110
+ },
111
+ maxCount: {
112
+ type: Number,
113
+ required: false,
114
+ default: void 0
115
+ },
116
+ pauseOnHover: {
117
+ type: Boolean,
118
+ required: false,
119
+ default: void 0
14
120
  },
15
121
  classNames: {
16
122
  type: Object,
123
+ required: false,
17
124
  default: void 0
18
125
  },
19
126
  styles: {
20
127
  type: Object,
128
+ required: false,
21
129
  default: void 0
22
130
  },
23
131
  components: {
24
132
  type: Object,
133
+ required: false,
25
134
  default: void 0
26
135
  },
27
136
  className: {
28
137
  type: Function,
138
+ required: false,
29
139
  default: void 0
30
140
  },
31
141
  style: {
32
142
  type: Function,
143
+ required: false,
33
144
  default: void 0
34
145
  },
35
- container: {
36
- type: Object,
37
- default: void 0
38
- },
39
- motion: {
40
- type: [Object, Function],
41
- default: void 0
42
- },
43
- maxCount: {
44
- type: Number,
45
- default: void 0
46
- },
47
- pauseOnHover: {
48
- type: Boolean,
146
+ onAllRemoved: {
147
+ required: false,
49
148
  default: void 0
50
149
  },
51
150
  stack: {
52
151
  type: [Boolean, Object],
53
- default: void 0
54
- },
55
- onAllRemoved: {
56
- type: Function,
152
+ required: false,
57
153
  default: void 0
58
154
  },
59
155
  renderNotifications: {
60
156
  type: Function,
157
+ required: false,
61
158
  default: void 0
62
159
  }
63
- },
64
- setup(props, { expose }) {
65
- const configList = shallowRef([]);
66
- const placements = shallowRef({});
67
- const emptyRef = shallowRef(false);
68
- expose({
69
- open: (config) => {
70
- const list = configList.value;
71
- let clone = [...list];
72
- const index = clone.findIndex((item) => item.key === config.key);
73
- const innerConfig = { ...config };
74
- if (index >= 0) {
75
- innerConfig.times = (list[index]?.times ?? 0) + 1;
76
- clone[index] = innerConfig;
77
- } else {
78
- innerConfig.times = 0;
79
- clone.push(innerConfig);
80
- }
81
- const maxCount = props.maxCount ?? 0;
82
- if (maxCount > 0 && clone.length > maxCount) clone = clone.slice(-maxCount);
83
- configList.value = clone;
84
- },
85
- close: (key) => {
86
- configList.value = configList.value.filter((item) => item.key !== key);
87
- },
88
- destroy: () => {
89
- configList.value = [];
90
- }
91
- });
92
- watch(configList, () => {
93
- const next = {};
94
- configList.value.forEach((config) => {
95
- const placement = config.placement ?? "topRight";
96
- next[placement] = next[placement] || [];
97
- next[placement].push(config);
98
- });
99
- Object.keys(placements.value).forEach((placement) => {
100
- next[placement] = next[placement] || [];
101
- });
102
- placements.value = next;
103
- }, { immediate: true });
104
- function onAllNoticeRemoved(placement) {
105
- const clone = { ...placements.value };
106
- if (!(clone[placement] || []).length) delete clone[placement];
107
- placements.value = clone;
108
- }
109
- watch(placements, () => {
110
- if (Object.keys(placements.value).length > 0) emptyRef.value = true;
111
- else if (emptyRef.value) {
112
- props.onAllRemoved?.();
113
- emptyRef.value = false;
114
- }
115
- });
116
- return () => {
117
- let _slot;
118
- const { container, prefixCls = "vc-notification" } = props;
119
- if (!container) return null;
120
- const placementList = Object.keys(placements.value);
121
- return createVNode(Teleport, { "to": container }, _isSlot(_slot = placementList.map((placement) => {
122
- const list = createVNode(NotificationList, {
123
- "key": placement,
124
- "configList": placements.value[placement],
125
- "placement": placement,
126
- "prefixCls": prefixCls,
127
- "pauseOnHover": props.pauseOnHover,
128
- "classNames": props.classNames,
129
- "styles": props.styles,
130
- "components": props.components,
131
- "class": props.className?.(placement),
132
- "style": props.style?.(placement),
133
- "motion": props.motion,
134
- "stack": props.stack,
135
- "onNoticeClose": (key) => {
136
- configList.value = configList.value.filter((item) => item.key !== key);
137
- },
138
- "onAllRemoved": onAllNoticeRemoved
139
- }, null);
140
- return props.renderNotifications ? props.renderNotifications(list, {
141
- prefixCls,
142
- key: placement
143
- }) : list;
144
- })) ? _slot : { default: () => [_slot] });
145
- };
146
- }
160
+ }, defaults),
161
+ name: "Notifications"
147
162
  });
148
163
  //#endregion
149
164
  export { Notifications as default };
@@ -1,8 +1,8 @@
1
- import { CSSProperties, FunctionalComponent } from 'vue';
1
+ import { CSSProperties } from 'vue';
2
2
  export interface NotificationProgressProps {
3
- class?: string;
3
+ className?: string;
4
4
  style?: CSSProperties;
5
5
  percent: number;
6
6
  }
7
- declare const Progress: FunctionalComponent<NotificationProgressProps>;
7
+ declare const Progress: import('vue').DefineSetupFnComponent<NotificationProgressProps, {}, {}, NotificationProgressProps & {}, import('vue').PublicProps>;
8
8
  export default Progress;
package/dist/Progress.js CHANGED
@@ -1,18 +1,31 @@
1
- import { createVNode } from "vue";
1
+ import { createVNode, defineComponent } from "vue";
2
2
  //#region src/Progress.tsx
3
- var Progress = (props) => {
4
- return createVNode("progress", {
5
- "class": props.class,
3
+ var Progress = /* @__PURE__ */ defineComponent((props) => {
4
+ return () => createVNode("progress", {
5
+ "class": props.className,
6
6
  "max": "100",
7
7
  "value": props.percent,
8
8
  "style": props.style
9
9
  }, null);
10
- };
11
- Progress.props = [
12
- "class",
13
- "style",
14
- "percent"
15
- ];
16
- Progress.inheritAttrs = false;
10
+ }, {
11
+ props: {
12
+ className: {
13
+ type: String,
14
+ required: false,
15
+ default: void 0
16
+ },
17
+ style: {
18
+ type: Object,
19
+ required: false,
20
+ default: void 0
21
+ },
22
+ percent: {
23
+ type: Number,
24
+ required: true
25
+ }
26
+ },
27
+ name: "NotificationProgress",
28
+ inheritAttrs: false
29
+ });
17
30
  //#endregion
18
31
  export { Progress as default };
@@ -1,22 +1,17 @@
1
+ import { AriaAttributes, ComputedRef } from 'vue';
1
2
  import { VueNode } from '@v-c/util/dist/type';
2
- import { ComputedRef, MaybeRef } from 'vue';
3
3
  export type ClosableConfig = {
4
4
  closeIcon?: VueNode;
5
5
  disabled?: boolean;
6
6
  onClose?: VoidFunction;
7
- } & Record<string, any>;
7
+ } & AriaAttributes & Record<`data-${string}`, unknown>;
8
8
  export type ClosableType = boolean | ClosableConfig | null | undefined;
9
- export interface ParsedClosableConfig {
9
+ export interface ParsedClosableConfig extends ClosableConfig {
10
10
  closeIcon: VueNode;
11
11
  disabled: boolean;
12
- onClose?: VoidFunction;
13
- [key: string]: any;
14
12
  }
15
13
  /**
16
- * Normalize the closable option into an enabled flag, parsed config, and aria props.
14
+ * Normalizes the closable option into a boolean flag, parsed config, and
15
+ * aria props for the close button. Mirrors rc-notification@2.0 useClosable.
17
16
  */
18
- export default function useClosable(closable: MaybeRef<ClosableType>): [
19
- ComputedRef<boolean>,
20
- ComputedRef<ParsedClosableConfig>,
21
- ComputedRef<Record<string, any>>
22
- ];
17
+ export default function useClosable(closable: ComputedRef<ClosableType>): [ComputedRef<boolean>, ComputedRef<ParsedClosableConfig>, ComputedRef<Record<string, unknown>>];
@@ -1,12 +1,13 @@
1
- import { computed, unref } from "vue";
1
+ import { computed } from "vue";
2
2
  import pickAttrs from "@v-c/util/dist/pickAttrs";
3
3
  //#region src/hooks/useClosable.ts
4
4
  /**
5
- * Normalize the closable option into an enabled flag, parsed config, and aria props.
5
+ * Normalizes the closable option into a boolean flag, parsed config, and
6
+ * aria props for the close button. Mirrors rc-notification@2.0 useClosable.
6
7
  */
7
8
  function useClosable(closable) {
8
9
  const closableObj = computed(() => {
9
- const value = unref(closable);
10
+ const value = closable.value;
10
11
  if (value === false) return {
11
12
  closeIcon: null,
12
13
  disabled: true
@@ -14,7 +15,6 @@ function useClosable(closable) {
14
15
  if (typeof value === "object" && value !== null) return value;
15
16
  return {};
16
17
  });
17
- const enabled = computed(() => !!unref(closable));
18
18
  const closableConfig = computed(() => {
19
19
  const obj = closableObj.value;
20
20
  return {
@@ -23,10 +23,11 @@ function useClosable(closable) {
23
23
  disabled: obj.disabled ?? false
24
24
  };
25
25
  });
26
+ const closableAriaProps = computed(() => pickAttrs(closableConfig.value, true));
26
27
  return [
27
- enabled,
28
+ computed(() => !!closable.value),
28
29
  closableConfig,
29
- computed(() => pickAttrs(closableConfig.value, true))
30
+ closableAriaProps
30
31
  ];
31
32
  }
32
33
  //#endregion
@@ -1,17 +1,18 @@
1
- import { ComputedRef, MaybeRef } from 'vue';
2
- import { StackConfig } from '../useStack';
3
- type Key = string | number | symbol;
4
- export interface ConfigItem {
5
- key: Key;
1
+ import { ComputedRef, Ref } from 'vue';
2
+ import { Key } from '../../interface';
3
+ export interface ListPositionStackConfig {
4
+ threshold?: number;
5
+ offset?: number;
6
6
  }
7
7
  /**
8
8
  * Calculates each notification's position and the full list height.
9
+ * Mirrors rc-notification@2.0 useListPosition.
9
10
  */
10
- export default function useListPosition(configList: MaybeRef<readonly ConfigItem[]>, stack: MaybeRef<StackConfig | undefined>, gap?: MaybeRef<number>): [
11
- ComputedRef<Map<string, number>>,
12
- (key: string, node: HTMLElement | null) => void,
13
- ComputedRef<number>,
14
- ComputedRef<number | undefined>,
15
- ComputedRef<number | undefined>
16
- ];
17
- export {};
11
+ export default function useListPosition(configList: ComputedRef<{
12
+ key: Key;
13
+ }[]>, stack: ComputedRef<ListPositionStackConfig | undefined>, gap: Ref<number>): readonly [ComputedRef<{
14
+ notificationPosition: Map<string, number>;
15
+ totalHeight: number;
16
+ topNoticeHeight: number | undefined;
17
+ topNoticeWidth: number | undefined;
18
+ }>, (key: string, node: HTMLDivElement | null) => void];