mrxy-yk 1.3.4 → 1.4.0

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.
@@ -254,6 +254,7 @@ declare const __VLS_component: DefineComponent<__VLS_Props, {}, {}, {}, {}, Comp
254
254
  modal: boolean;
255
255
  appendToBody: boolean;
256
256
  fullscreen: boolean;
257
+ showClose: boolean;
257
258
  }, {}, {}, {}, string, ComponentProvideOptions, false, {
258
259
  formRef: {
259
260
  $: ComponentInternalInstance;
@@ -20,7 +20,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
20
20
  fullscreen: { type: Boolean, default: false },
21
21
  closeOnClickModal: { type: Boolean },
22
22
  dialogCenter: { type: Boolean },
23
- showClose: { type: Boolean }
23
+ showClose: { type: Boolean, default: true }
24
24
  },
25
25
  setup(__props) {
26
26
  const props = __props;
@@ -1,3 +1,5 @@
1
1
  export * from './table-search';
2
2
  export * from './inject-events';
3
+ export * from './life-cycle';
4
+ export * from './setup-module';
3
5
  export * from '../components/empty/hooks';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 重新激活时调用
3
+ * 与onActivated不同的是,onActivated在组件激活时调用,而onReactivated在组件重新激活时调用
4
+ * 不会和onMounted同时调用
5
+ * @param hook
6
+ */
7
+ export declare function onReactivated(hook: () => void): void;
@@ -0,0 +1,14 @@
1
+ import { onMounted, onActivated } from "vue";
2
+ function onReactivated(hook) {
3
+ let isMounted = false;
4
+ onMounted(() => {
5
+ isMounted = true;
6
+ });
7
+ onActivated(() => {
8
+ if (isMounted) isMounted = false;
9
+ else hook();
10
+ });
11
+ }
12
+ export {
13
+ onReactivated
14
+ };
@@ -0,0 +1,41 @@
1
+ import { ExcludePrefixKeys, Prefix } from './type';
2
+ /**
3
+ * 模块钩子
4
+ * 用于把相同的业务放入同一个模块中,可以避免命名冲突。模拟Setup的属性方式,支持多些生命周期
5
+ * 如示例所示
6
+ * - 命名:`levelTree.nodeCLick`的方式,而不是`levelTreeNodeClick`,这样有其他业务的树也可以使用`nodeCLick`,
7
+ * 如`userTree.nodeCLick`,避免名称困难
8
+ * - 生命周期:使用`[SetupLifeCycle.onMounted]`的方式来定义生命周期,可以在模块中写多个
9
+ *
10
+ * ```ts
11
+ * const levelTree = useSetupModuleHooks({
12
+ * // region 获取数据
13
+ * treeData: ref(),
14
+ * getTreeData() {},
15
+ * [SetupLifeCycle.onMounted]() {
16
+ * levelTree.getTreeData()
17
+ * },
18
+ * // endregion
19
+ *
20
+ * // region 搜索
21
+ * searchQuery: ref(''),
22
+ * [SetupLifeCycle.onMounted]() {
23
+ * watch(levelTree.searchQuery, () => {})
24
+ * },
25
+ * // endregion
26
+ *
27
+ * // region 事件
28
+ * nodeCLick() {}
29
+ * // endregion
30
+ * })
31
+ * ```
32
+ * @param ops
33
+ */
34
+ export declare function useSetupModuleHooks<T>(ops: T): ExcludePrefixKeys<T, Prefix>;
35
+ export declare const SetupLifeCycle: {
36
+ onMounted: Prefix;
37
+ onBeforeUnmount: Prefix;
38
+ onActivated: Prefix;
39
+ onDeactivated: Prefix;
40
+ onReactivated: Prefix;
41
+ };
@@ -0,0 +1,33 @@
1
+ import { onReactivated } from "../life-cycle/index.js";
2
+ import { onDeactivated, onActivated, onBeforeUnmount, onMounted } from "vue";
3
+ const lifeCycle = {
4
+ "onMounted": onMounted,
5
+ "onBeforeUnmount": onBeforeUnmount,
6
+ "onActivated": onActivated,
7
+ "onDeactivated": onDeactivated,
8
+ "onReactivated": onReactivated
9
+ };
10
+ function useSetupModuleHooks(ops) {
11
+ Object.keys(ops).forEach((key) => {
12
+ if (key.startsWith("_Module")) {
13
+ const keys = key.split("_");
14
+ if (lifeCycle[keys[2]] && typeof ops[key] === "function") {
15
+ lifeCycle[keys[2]](ops[key]);
16
+ }
17
+ delete ops[key];
18
+ return;
19
+ }
20
+ });
21
+ return ops;
22
+ }
23
+ let _Module_Index = 0;
24
+ const SetupLifeCycle = new Proxy({}, {
25
+ get(target, prop) {
26
+ if (_Module_Index >= Number.MAX_SAFE_INTEGER) _Module_Index = 0;
27
+ return `_Module_${prop.toString()}_${_Module_Index++}`;
28
+ }
29
+ });
30
+ export {
31
+ SetupLifeCycle,
32
+ useSetupModuleHooks
33
+ };
@@ -0,0 +1,4 @@
1
+ export type Prefix = '_Module'
2
+ export type ExcludePrefixKeys<T, Prefix extends string> = {
3
+ [K in keyof T as K extends `${Prefix}${string}` ? never : K]: T[K]
4
+ }
package/dist/index.js CHANGED
@@ -3,6 +3,8 @@ import * as index$2 from "./directives/index.js";
3
3
  import "./element-plus/index.js";
4
4
  import { useTableSearchHooks } from "./hooks/table-search/index.js";
5
5
  import { useInjectEventsHooks } from "./hooks/inject-events/index.js";
6
+ import { onReactivated } from "./hooks/life-cycle/index.js";
7
+ import { SetupLifeCycle, useSetupModuleHooks } from "./hooks/setup-module/index.js";
6
8
  import { useEmptyHooks } from "./components/empty/hooks/index.js";
7
9
  import { MatchUnit } from "./utils/match-unit/index.js";
8
10
  import { TransitionFade } from "./utils/transition-fade/index.js";
@@ -74,6 +76,7 @@ export {
74
76
  Pages,
75
77
  PromiseUtil,
76
78
  RejectError,
79
+ SetupLifeCycle,
77
80
  TableUtil,
78
81
  TransitionFade,
79
82
  YsVideo,
@@ -88,6 +91,7 @@ export {
88
91
  newAMapMarkerCluster,
89
92
  numberRule,
90
93
  numberTag,
94
+ onReactivated,
91
95
  passwordRule,
92
96
  passwordTag,
93
97
  phoneRule,
@@ -112,6 +116,7 @@ export {
112
116
  useElTableSortHooks,
113
117
  useEmptyHooks,
114
118
  useInjectEventsHooks,
119
+ useSetupModuleHooks,
115
120
  useTableSearchHooks,
116
121
  usernameRule,
117
122
  usernameTag,
@@ -1,4 +1,4 @@
1
- const directives = ["RefHeight"];
1
+ const directives = /* @__PURE__ */ new Set(["RefHeight"]);
2
2
  var index = () => {
3
3
  return [
4
4
  {
@@ -12,7 +12,7 @@ var index = () => {
12
12
  {
13
13
  type: "directive",
14
14
  resolve: async (name) => {
15
- if (name in directives) {
15
+ if (directives.has(name)) {
16
16
  return { name, from: "mrxy-yk/directives" };
17
17
  }
18
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mrxy-yk",
3
- "version": "1.3.4",
3
+ "version": "1.4.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "A collection of Vue 3 components and utilities",
@@ -53,6 +53,16 @@
53
53
  "types": "./dist/*.d.ts"
54
54
  }
55
55
  },
56
+ "typesVersions": {
57
+ "*": {
58
+ "config": ["dist/config/index.d.ts"],
59
+ "resolver": ["dist/resolver/index.d.ts"],
60
+ "directives": ["dist/directives/index.d.ts"],
61
+ "components": ["dist/components/index.d.ts"],
62
+ "element-plus": ["dist/element-plus/index.d.ts"],
63
+ "*": ["dist/*"]
64
+ }
65
+ },
56
66
  "sideEffects": [
57
67
  "dist/*",
58
68
  "src/**/*.css",
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "mrxy-yk",
4
- "version": "1.3.4",
4
+ "version": "1.4.0",
5
5
  "js-types-syntax": "typescript",
6
6
  "contributions": {
7
7
  "html": {
@@ -753,7 +753,7 @@
753
753
  "type": [
754
754
  "boolean"
755
755
  ],
756
- "description": "Dialog右上角是否显示关闭按钮"
756
+ "description": "Dialog右上角是否显示关闭按钮,缺省值为true"
757
757
  }
758
758
  ],
759
759
  "slots": [