@cmeslib/components 0.1.14 → 0.3.0-beta.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.
Files changed (91) hide show
  1. package/es/_virtual/_plugin-vue_export-helper.mjs +9 -0
  2. package/es/components/demo/index.mjs +2 -4
  3. package/es/components/demo/src/demo-button-setup-tsx.vue.mjs +3 -3
  4. package/es/components/demo/src/demo-button-setup-tsx.vue2.mjs +3 -3
  5. package/es/components/demo/src/demo-button.vue.mjs +4 -4
  6. package/es/components/demo/src/demo-button.vue2.mjs +5 -5
  7. package/es/components/hifleet/index.d.ts +4 -0
  8. package/es/components/hifleet/index.mjs +1 -0
  9. package/es/components/hifleet/src/helper.d.ts +32 -0
  10. package/es/components/hifleet/src/helper.mjs +261 -0
  11. package/es/components/hifleet/src/index.vue.d.ts +37 -0
  12. package/es/components/hifleet/src/index.vue.mjs +6 -0
  13. package/es/components/hifleet/src/index.vue2.mjs +123 -0
  14. package/es/components/hifleet/src/map-data.d.ts +18 -0
  15. package/es/components/hifleet/src/map-data.mjs +238 -0
  16. package/es/components/hifleet/src/types.d.ts +28 -0
  17. package/es/components/hifleet/src/types.mjs +1 -0
  18. package/es/components/index.d.ts +2 -0
  19. package/es/components/index.mjs +4 -3
  20. package/es/components/selectors/index.d.ts +6 -0
  21. package/es/components/selectors/index.mjs +2 -0
  22. package/es/components/selectors/src/DeptTreeSelect.vue.d.ts +13 -0
  23. package/es/components/selectors/src/DeptTreeSelect.vue.mjs +5 -0
  24. package/es/components/selectors/src/DeptTreeSelect.vue2.mjs +63 -0
  25. package/es/components/selectors/src/UserTreeSelect.vue.d.ts +13 -0
  26. package/es/components/selectors/src/UserTreeSelect.vue.mjs +5 -0
  27. package/es/components/selectors/src/UserTreeSelect.vue2.mjs +82 -0
  28. package/es/components/selectors/src/types.d.ts +27 -0
  29. package/es/components/selectors/src/types.mjs +1 -0
  30. package/es/directives/demo/index.d.ts +2 -0
  31. package/es/directives/demo/index.mjs +8 -0
  32. package/es/directives/index.d.ts +1 -1
  33. package/es/directives/index.mjs +1 -5
  34. package/es/hooks/common/index.d.ts +1 -0
  35. package/es/hooks/common/index.mjs +1 -0
  36. package/es/hooks/common/src/globalSingleFlight.d.ts +27 -0
  37. package/es/hooks/common/src/globalSingleFlight.mjs +108 -0
  38. package/es/hooks/demo/index.d.ts +1 -0
  39. package/es/hooks/demo/index.mjs +5 -0
  40. package/es/hooks/index.d.ts +2 -0
  41. package/es/hooks/index.mjs +2 -0
  42. package/es/index.css +63 -0
  43. package/es/index.d.ts +1 -0
  44. package/es/index.mjs +7 -4
  45. package/es/types/env.d.mjs +1 -0
  46. package/lib/_virtual/_plugin-vue_export-helper.js +13 -0
  47. package/lib/components/demo/index.js +4 -6
  48. package/lib/components/demo/src/demo-button-setup-tsx.vue.js +1 -1
  49. package/lib/components/demo/src/demo-button-setup-tsx.vue2.js +2 -2
  50. package/lib/components/demo/src/demo-button.vue.js +3 -3
  51. package/lib/components/demo/src/demo-button.vue2.js +3 -3
  52. package/lib/components/hifleet/index.d.ts +4 -0
  53. package/lib/components/hifleet/index.js +7 -0
  54. package/lib/components/hifleet/src/helper.d.ts +32 -0
  55. package/lib/components/hifleet/src/helper.js +272 -0
  56. package/lib/components/hifleet/src/index.vue.d.ts +37 -0
  57. package/lib/components/hifleet/src/index.vue.js +10 -0
  58. package/lib/components/hifleet/src/index.vue2.js +127 -0
  59. package/lib/components/hifleet/src/map-data.d.ts +18 -0
  60. package/lib/components/hifleet/src/map-data.js +241 -0
  61. package/lib/components/hifleet/src/types.d.ts +28 -0
  62. package/lib/components/hifleet/src/types.js +2 -0
  63. package/lib/components/index.d.ts +3 -0
  64. package/lib/components/index.js +8 -4
  65. package/lib/components/selectors/index.d.ts +6 -0
  66. package/lib/components/selectors/index.js +9 -0
  67. package/lib/components/selectors/src/DeptTreeSelect.vue.d.ts +13 -0
  68. package/lib/components/selectors/src/DeptTreeSelect.vue.js +9 -0
  69. package/lib/components/selectors/src/DeptTreeSelect.vue2.js +67 -0
  70. package/lib/components/selectors/src/UserTreeSelect.vue.d.ts +13 -0
  71. package/lib/components/selectors/src/UserTreeSelect.vue.js +9 -0
  72. package/lib/components/selectors/src/UserTreeSelect.vue2.js +86 -0
  73. package/lib/components/selectors/src/types.d.ts +27 -0
  74. package/lib/components/selectors/src/types.js +2 -0
  75. package/lib/directives/demo/index.d.ts +2 -0
  76. package/lib/directives/demo/index.js +10 -0
  77. package/lib/directives/index.d.ts +1 -1
  78. package/lib/directives/index.js +4 -4
  79. package/lib/hooks/common/index.d.ts +1 -0
  80. package/lib/hooks/common/index.js +8 -0
  81. package/lib/hooks/common/src/globalSingleFlight.d.ts +27 -0
  82. package/lib/hooks/common/src/globalSingleFlight.js +111 -0
  83. package/lib/hooks/demo/index.d.ts +1 -0
  84. package/lib/hooks/demo/index.js +7 -0
  85. package/lib/hooks/index.d.ts +2 -0
  86. package/lib/hooks/index.js +10 -0
  87. package/lib/index.css +63 -0
  88. package/lib/index.d.ts +3 -0
  89. package/lib/index.js +15 -6
  90. package/lib/types/env.d.js +2 -0
  91. package/package.json +5 -3
@@ -0,0 +1,27 @@
1
+ export interface UserTreeSelectProps {
2
+ placeholder?: string;
3
+ multiple?: boolean;
4
+ filterable?: boolean;
5
+ hasMinWidth?: boolean;
6
+ getData: () => Promise<UserDataNode[]>;
7
+ }
8
+ export interface DeptTreeSelectProps {
9
+ placeholder?: string;
10
+ multiple?: boolean;
11
+ filterable?: boolean;
12
+ hasMinWidth?: boolean;
13
+ getData: () => Promise<DeptDataNode[]>;
14
+ disabledIds?: string | string[] | number | number[];
15
+ }
16
+ export interface UserDataNode {
17
+ id: string;
18
+ name: string;
19
+ children?: UserDataNode[];
20
+ visible?: boolean;
21
+ }
22
+ export interface DeptDataNode {
23
+ id: string;
24
+ name: string;
25
+ children?: DeptDataNode[];
26
+ disabled?: boolean;
27
+ }
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1,2 @@
1
+ import type { Directive } from 'vue';
2
+ export declare const vFocus: Directive<HTMLElement, boolean | undefined>;
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ const vFocus = {
4
+ mounted(el, binding) {
5
+ if (binding.value === false) return;
6
+ requestAnimationFrame(() => el.focus());
7
+ }
8
+ };
9
+
10
+ exports.vFocus = vFocus;
@@ -1 +1 @@
1
- export declare function DemoDirective(msg: string): void;
1
+ export * from './demo';
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- function DemoDirective(msg) {
4
- console.log("DemoDirective initialized", msg);
5
- }
3
+ var index = require('./demo/index.js');
6
4
 
7
- exports.DemoDirective = DemoDirective;
5
+
6
+
7
+ exports.vFocus = index.vFocus;
@@ -0,0 +1 @@
1
+ export { useGlobalSingleFlight, clearSingleFlightRegistry } from './src/globalSingleFlight';
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var globalSingleFlight = require('./src/globalSingleFlight.js');
4
+
5
+
6
+
7
+ exports.clearSingleFlightRegistry = globalSingleFlight.clearSingleFlightRegistry;
8
+ exports.useGlobalSingleFlight = globalSingleFlight.useGlobalSingleFlight;
@@ -0,0 +1,27 @@
1
+ import { type Ref } from 'vue';
2
+ type MaybePromise<T> = T | Promise<T>;
3
+ export interface SingleFlightOptions<T> {
4
+ /** true=永久缓存;number=TTL 毫秒;false=不缓存 */
5
+ cache?: boolean | number;
6
+ /** 命中缓存时是否返回克隆,避免外部改动污染缓存 */
7
+ cloneOnHit?: boolean;
8
+ /** 自定义克隆 */
9
+ cloner?: (v: T) => T;
10
+ /** 可选:根据参数生成二级 key(实现“按参数去重”),默认不并入参数 */
11
+ argsKey?: (...args: unknown[]) => string;
12
+ }
13
+ interface Entry<T, Args extends unknown[] = unknown[]> {
14
+ promise: Ref<Promise<T> | null>;
15
+ value: Ref<T | undefined>;
16
+ error: Ref<unknown>;
17
+ startedAt: Ref<number | null>;
18
+ isRunning: Readonly<Ref<boolean>>;
19
+ isDone: Readonly<Ref<boolean>>;
20
+ run: (...args: Args) => Promise<T>;
21
+ invalidate: () => void;
22
+ reset: () => void;
23
+ }
24
+ export declare function useGlobalSingleFlight<TArgs extends unknown[], TResult>(baseKey: string, runner: (...args: TArgs) => MaybePromise<TResult>, options?: SingleFlightOptions<TResult>): Entry<TResult, TArgs>;
25
+ /** 可选工具:手动清理全局注册表(如在登出时) */
26
+ export declare function clearSingleFlightRegistry(): void;
27
+ export {};
@@ -0,0 +1,111 @@
1
+ 'use strict';
2
+
3
+ var vue = require('vue');
4
+
5
+ const registry = /* @__PURE__ */ new Map();
6
+ function now() {
7
+ return Date.now();
8
+ }
9
+ function makeFullKey(baseKey, options, args) {
10
+ if (!(options == null ? void 0 : options.argsKey) || !(args == null ? void 0 : args.length)) return baseKey;
11
+ return `${baseKey}::${options.argsKey(...args)}`;
12
+ }
13
+ function defaultClone(v) {
14
+ return JSON.parse(JSON.stringify(v));
15
+ }
16
+ function useGlobalSingleFlight(baseKey, runner, options = {}) {
17
+ function ensureEntry(fullKey) {
18
+ let e = registry.get(fullKey);
19
+ if (e) return e;
20
+ const promise = vue.ref(null);
21
+ const value = vue.ref();
22
+ const error = vue.ref();
23
+ const startedAt = vue.ref(null);
24
+ const isRunning = vue.computed(() => promise.value !== null);
25
+ const isDone = vue.computed(() => value.value !== void 0 && !isRunning.value);
26
+ const hasValidCache = () => {
27
+ const { cache = false } = options;
28
+ if (value.value === void 0) return false;
29
+ if (cache === true) return true;
30
+ if (typeof cache === "number") {
31
+ if (!startedAt.value) return false;
32
+ return now() - startedAt.value < cache;
33
+ }
34
+ return false;
35
+ };
36
+ const cloneValue = (v) => options.cloneOnHit ? options.cloner ? options.cloner(v) : defaultClone(v) : v;
37
+ async function run(...args) {
38
+ if (hasValidCache()) {
39
+ return Promise.resolve(cloneValue(value.value));
40
+ }
41
+ if (promise.value) return promise.value;
42
+ error.value = void 0;
43
+ const p = (async () => {
44
+ try {
45
+ const ret = await runner(...args);
46
+ value.value = ret;
47
+ startedAt.value = now();
48
+ return ret;
49
+ } catch (e2) {
50
+ value.value = void 0;
51
+ startedAt.value = null;
52
+ error.value = e2;
53
+ throw e2;
54
+ } finally {
55
+ promise.value = null;
56
+ }
57
+ })();
58
+ promise.value = p;
59
+ return p;
60
+ }
61
+ function invalidate() {
62
+ value.value = void 0;
63
+ startedAt.value = null;
64
+ }
65
+ function reset() {
66
+ promise.value = null;
67
+ value.value = void 0;
68
+ error.value = void 0;
69
+ startedAt.value = null;
70
+ }
71
+ e = { promise, value, error, startedAt, isRunning, isDone, run, invalidate, reset };
72
+ registry.set(fullKey, e);
73
+ return e;
74
+ }
75
+ const proxy = {
76
+ promise: vue.ref(null),
77
+ value: vue.ref(),
78
+ error: vue.ref(),
79
+ startedAt: vue.ref(null),
80
+ isRunning: vue.ref(false),
81
+ isDone: vue.ref(false),
82
+ async run(...args) {
83
+ const fullKey = makeFullKey(baseKey, options, args);
84
+ const e = ensureEntry(fullKey);
85
+ proxy.promise = e.promise;
86
+ proxy.value = e.value;
87
+ proxy.error = e.error;
88
+ proxy.startedAt = e.startedAt;
89
+ proxy.isRunning = e.isRunning;
90
+ proxy.isDone = e.isDone;
91
+ return e.run(...args);
92
+ },
93
+ invalidate() {
94
+ const fullKey = makeFullKey(baseKey, options);
95
+ const e = registry.get(fullKey);
96
+ e == null ? void 0 : e.invalidate();
97
+ },
98
+ reset() {
99
+ const fullKey = makeFullKey(baseKey, options);
100
+ const e = registry.get(fullKey);
101
+ e == null ? void 0 : e.reset();
102
+ }
103
+ };
104
+ return proxy;
105
+ }
106
+ function clearSingleFlightRegistry() {
107
+ registry.clear();
108
+ }
109
+
110
+ exports.clearSingleFlightRegistry = clearSingleFlightRegistry;
111
+ exports.useGlobalSingleFlight = useGlobalSingleFlight;
@@ -0,0 +1 @@
1
+ export declare function useDemoHook(): void;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ function useDemoHook() {
4
+ console.log("This is a demo hook from cmeslib-components.");
5
+ }
6
+
7
+ exports.useDemoHook = useDemoHook;
@@ -0,0 +1,2 @@
1
+ export * from './demo';
2
+ export * from './common';
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var index = require('./demo/index.js');
4
+ var globalSingleFlight = require('./common/src/globalSingleFlight.js');
5
+
6
+
7
+
8
+ exports.useDemoHook = index.useDemoHook;
9
+ exports.clearSingleFlightRegistry = globalSingleFlight.clearSingleFlightRegistry;
10
+ exports.useGlobalSingleFlight = globalSingleFlight.useGlobalSingleFlight;
package/lib/index.css CHANGED
@@ -2,4 +2,67 @@
2
2
  border-radius: 6px;
3
3
  background-color: #747bff;
4
4
  color: red;
5
+ }
6
+ .hifleet-map-container[data-v-0b224a81] {
7
+ position: relative;
8
+ }
9
+ .hifleet-map-container .hifleet-map-container-maptype[data-v-0b224a81] {
10
+ position: absolute;
11
+ right: 10px;
12
+ bottom: 0;
13
+ z-index: 999;
14
+ display: flex;
15
+ padding: 0;
16
+ margin: 0;
17
+ list-style: none;
18
+ }
19
+ .hifleet-map-container .hifleet-map-container-maptype .map__type--li[data-v-0b224a81] {
20
+ padding: 10px;
21
+ padding-bottom: 0;
22
+ font-size: 14px;
23
+ font-weight: bold;
24
+ color: #666;
25
+ cursor: pointer;
26
+ }
27
+
28
+ .missing-ais[data-v-0b224a81] {
29
+ position: absolute;
30
+ top: 20px;
31
+ left: 20px;
32
+ z-index: 1000;
33
+ font-size: 18px;
34
+ color: red;
35
+ }
36
+
37
+ .map__position--wrapper[data-v-0b224a81] {
38
+ position: absolute;
39
+ right: 10px;
40
+ bottom: 25px;
41
+ z-index: 1000;
42
+ width: 120px;
43
+ padding: 2px 5px;
44
+ font-size: 12px;
45
+ color: #000;
46
+ background: rgba(233, 239, 235, 0.8);
47
+ border: 1px solid #f5f5f5;
48
+ box-shadow: 0 5px 5px rgba(0, 0, 0, 0.3);
49
+ }
50
+ .map__position--wrapper .map__position--des[data-v-0b224a81] {
51
+ position: absolute;
52
+ top: -10px;
53
+ right: -10px;
54
+ z-index: 1;
55
+ min-width: 16px;
56
+ min-height: 10px;
57
+ padding: 0 2px;
58
+ font-size: 12px;
59
+ font-weight: 500;
60
+ line-height: 14px;
61
+ color: #fff;
62
+ text-align: center;
63
+ cursor: pointer;
64
+ background-color: #02a0ff;
65
+ border: 1px solid #fff;
66
+ border-radius: 4px;
67
+ box-sizing: border-box;
5
68
  }
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './components';
2
+ export * from './directives';
3
+ export * from './hooks';
package/lib/index.js CHANGED
@@ -1,15 +1,24 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./directives/index.js');
4
- require('./components/demo/src/demo-button.vue.js');
5
- var demoButton_vue_vue_type_script_setup_true_lang = require('./components/demo/src/demo-button.vue2.js');
6
- require('./components/demo/src/demo-button-setup-tsx.vue.js');
7
3
  var demoButtonSetupTsx_vue_vue_type_script_setup_true_lang = require('./components/demo/src/demo-button-setup-tsx.vue2.js');
4
+ var DeptTreeSelect_vue_vue_type_script_setup_true_lang = require('./components/selectors/src/DeptTreeSelect.vue2.js');
5
+ var UserTreeSelect_vue_vue_type_script_setup_true_lang = require('./components/selectors/src/UserTreeSelect.vue2.js');
6
+ var demoButton = require('./components/demo/src/demo-button.vue.js');
8
7
  var demoButtonTsx = require('./components/demo/src/demo-button-tsx.js');
8
+ var index = require('./components/hifleet/src/index.vue.js');
9
+ var globalSingleFlight = require('./hooks/common/src/globalSingleFlight.js');
10
+ var index$1 = require('./hooks/demo/index.js');
11
+ var index$2 = require('./directives/demo/index.js');
9
12
 
10
13
 
11
14
 
12
- exports.DemoDirective = index.DemoDirective;
13
- exports.DemoButton = demoButton_vue_vue_type_script_setup_true_lang.default;
14
15
  exports.DemoButtonSetupTsx = demoButtonSetupTsx_vue_vue_type_script_setup_true_lang.default;
16
+ exports.DeptTreeSelect = DeptTreeSelect_vue_vue_type_script_setup_true_lang.default;
17
+ exports.UserTreeSelect = UserTreeSelect_vue_vue_type_script_setup_true_lang.default;
18
+ exports.DemoButton = demoButton.default;
15
19
  exports.DemoButtonTsx = demoButtonTsx.default;
20
+ exports.HiFleetMap = index.default;
21
+ exports.clearSingleFlightRegistry = globalSingleFlight.clearSingleFlightRegistry;
22
+ exports.useGlobalSingleFlight = globalSingleFlight.useGlobalSingleFlight;
23
+ exports.useDemoHook = index$1.useDemoHook;
24
+ exports.vFocus = index$2.vFocus;
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmeslib/components",
3
- "version": "0.1.14",
3
+ "version": "0.3.0-beta.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.mjs",
@@ -10,15 +10,17 @@
10
10
  "import": "./es/index.mjs",
11
11
  "require": "./lib/index.js",
12
12
  "types": "./es/index.d.ts"
13
- }
13
+ },
14
+ "./*": "./*"
14
15
  },
15
16
  "keywords": [],
16
17
  "author": "",
17
18
  "license": "ISC",
18
19
  "dependencies": {
19
- "@cmeslib/utils": "0.1.3"
20
+ "@cmeslib/utils": "0.3.0-beta.0"
20
21
  },
21
22
  "devDependencies": {
23
+ "@types/leaflet": "^1.9.21",
22
24
  "element-plus": "^2.11.1",
23
25
  "vue": "^3.5.21"
24
26
  },