sard-uniapp 1.1.5 → 1.1.6

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.
package/changelog.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [1.1.6](https://github.com/sutras/sard-uniapp/compare/v1.1.5...v1.1.6) (2024-05-19)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * 修复 notify 组件显示问题、优化文档 ([7ed66fd](https://github.com/sutras/sard-uniapp/commit/7ed66fd09870b24d485fd82ed6f152373b665f3c))
7
+
8
+
9
+
1
10
  ## [1.1.5](https://github.com/sutras/sard-uniapp/compare/v1.1.4...v1.1.5) (2024-05-18)
2
11
 
3
12
 
@@ -9,10 +9,11 @@ export declare const notifyAgentPropsDefaults: {
9
9
  duration: number;
10
10
  timeout: number;
11
11
  };
12
- export declare const mapIdImperative: Record<string, {
13
- show(props: Record<string, any>): void;
12
+ export declare const imperativeName = "notify";
13
+ export interface NotifyImperative {
14
+ show(newProps: Record<string, any>): void;
14
15
  hide(): void;
15
- }>;
16
+ }
16
17
  export type NotifyOptions = NotifyAgentProps;
17
18
  export interface NotifySimpleShowFunction {
18
19
  (options: NotifyOptions): void;
@@ -1,9 +1,11 @@
1
+ import { notifyPropsDefaults } from '../notify/common';
1
2
  import { defaultConfig } from '../config';
3
+ import { getAllImperatives, getAvailableImperative, getImperatives, } from '../../use/useImperative';
2
4
  export const notifyAgentPropsDefaults = {
3
- ...defaultConfig.notify,
5
+ ...notifyPropsDefaults,
4
6
  ...defaultConfig.notifyAgent,
5
7
  };
6
- export const mapIdImperative = {};
8
+ export const imperativeName = 'notify';
7
9
  const show = (optionsOrMessage, options = {}, internalType) => {
8
10
  if (optionsOrMessage && typeof optionsOrMessage === 'object') {
9
11
  options = optionsOrMessage;
@@ -12,8 +14,8 @@ const show = (optionsOrMessage, options = {}, internalType) => {
12
14
  options.message = optionsOrMessage;
13
15
  }
14
16
  options.type = internalType;
15
- const { id = 'notify' } = options;
16
- const imperative = mapIdImperative[id];
17
+ const { id = defaultConfig.notifyAgent.id } = options;
18
+ const imperative = getAvailableImperative(imperativeName, id);
17
19
  if (imperative) {
18
20
  imperative.show(options);
19
21
  }
@@ -30,14 +32,19 @@ const warning = (optionsOrMessage, options) => {
30
32
  const error = (optionsOrMessage, options) => {
31
33
  show(optionsOrMessage, options, 'error');
32
34
  };
33
- const hide = (id = 'notify') => {
34
- const imperative = mapIdImperative[id];
35
- if (imperative) {
36
- imperative.hide();
35
+ const hide = (id = defaultConfig.notifyAgent.id) => {
36
+ const imperatives = getImperatives(imperativeName, id);
37
+ if (imperatives && imperatives.length > 0) {
38
+ imperatives.forEach((item) => {
39
+ item.imperative.hide();
40
+ });
37
41
  }
38
42
  };
39
43
  const hideAll = () => {
40
- Object.keys(mapIdImperative).forEach(hide);
44
+ const mapImperatives = getAllImperatives()[imperativeName];
45
+ if (mapImperatives) {
46
+ Object.keys(mapImperatives).forEach(hide);
47
+ }
41
48
  };
42
49
  notify.success = success;
43
50
  notify.warning = warning;
@@ -15,12 +15,13 @@
15
15
 
16
16
  <script>
17
17
  import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
18
- import { onMounted, onUnmounted, ref } from "vue";
18
+ import { computed, ref } from "vue";
19
19
  import SarNotify from "../notify/notify.vue";
20
20
  import {
21
- mapIdImperative,
21
+ imperativeName,
22
22
  notifyAgentPropsDefaults
23
23
  } from "./common";
24
+ import { useImperative } from "../../use/useImperative";
24
25
  export default _defineComponent({
25
26
  ...{
26
27
  options: {
@@ -64,16 +65,11 @@ export default _defineComponent({
64
65
  elRef.value?.cancelHide();
65
66
  }
66
67
  };
67
- onMounted(() => {
68
- if (innerProps.value.id) {
69
- mapIdImperative[innerProps.value.id] = imperative;
70
- }
71
- });
72
- onUnmounted(() => {
73
- if (innerProps.value.id) {
74
- delete mapIdImperative[innerProps.value.id];
75
- }
76
- });
68
+ useImperative(
69
+ imperativeName,
70
+ imperative,
71
+ computed(() => innerProps.value.id)
72
+ );
77
73
  const __returned__ = { props, innerProps, elRef, imperative, SarNotify };
78
74
  return __returned__;
79
75
  }
@@ -1,3 +1,3 @@
1
- import { Position } from './utils';
1
+ import type { Position } from './utils';
2
2
  export { usePopover } from './usePopover';
3
3
  export type PopoverPosition = Position;
@@ -19,7 +19,7 @@ export declare const toastPropsDefaults: {
19
19
  duration: number;
20
20
  };
21
21
  export interface ToastEmits {
22
- (e: 'update:visible', event: any): void;
22
+ (e: 'update:visible', visible: boolean): void;
23
23
  }
24
24
  export interface ToastExpose {
25
25
  reHideLater: () => void;
@@ -9,7 +9,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
9
9
  reHideLater: () => void;
10
10
  cancelHide: () => void;
11
11
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
- "update:visible": (event: any) => void;
12
+ "update:visible": (visible: boolean) => void;
13
13
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<ToastProps>, {
14
14
  type: "text";
15
15
  position: "center";
@@ -17,7 +17,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
17
17
  timeout: number;
18
18
  duration: number;
19
19
  }>>> & {
20
- "onUpdate:visible"?: ((event: any) => any) | undefined;
20
+ "onUpdate:visible"?: ((visible: boolean) => any) | undefined;
21
21
  }, {
22
22
  type: "success" | "text" | "loading" | "fail";
23
23
  overlay: boolean;
package/package.json CHANGED
@@ -2,7 +2,8 @@
2
2
  "id": "sard-uniapp",
3
3
  "name": "sard-uniapp",
4
4
  "displayName": "sard-uniapp",
5
- "version": "1.1.5",
5
+ "version": "1.1.6",
6
+ "type": "module",
6
7
  "description": "sard-uniapp 是一套基于 Uniapp + Vue3 框架开发的兼容多端的 UI 组件库",
7
8
  "keywords": [
8
9
  "uniapp",
@@ -24,8 +25,8 @@
24
25
  "test": "vitest"
25
26
  },
26
27
  "peerDependencies": {
27
- "@dcloudio/types": "^3.3.2",
28
- "vue": "^3.3.11"
28
+ "@dcloudio/types": "^3.4.8",
29
+ "vue": "^3.4.27"
29
30
  },
30
31
  "devDependencies": {
31
32
  "@sard/uniapp-cli": "workspace:*",