cc1-ui 0.0.11 → 1.0.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.
package/dist/cc1-ui.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { defineAsyncComponent } from 'vue';
2
2
 
3
- const DRdominfo = () => import('./dominfo-FpTvKs8K.js');
3
+ const DRdominfo = () => import('./dominfo-0VtYQrCk.js');
4
4
  const VButton = () => defineAsyncComponent(() => import('./index-lDlR9NjA.js'));
5
5
  const VSwitch = () => defineAsyncComponent(() => import('./index-BvvdDtUd.js'));
6
6
  const VScale = () => defineAsyncComponent(() => import('./index-l4J1-e0K.js'));
7
7
  const VMask = () => defineAsyncComponent(() => import('./index-ycYY--mh.js'));
8
8
  const VCircle = () => defineAsyncComponent(() => import('./index-ti4E-Nv5.js'));
9
9
  const VIcon = () => defineAsyncComponent(() => import('./index-BGzY32VF.js'));
10
- const VSelect = () => defineAsyncComponent(() => import('./index-CpyM3z5X.js'));
10
+ const VSelect = () => defineAsyncComponent(() => import('./index-ClZ7RWBn.js'));
11
11
  const VSIcon = () => defineAsyncComponent(() => import('./index-mrAwG3J3.js'));
12
12
  const installDR = (fun, app) => {
13
13
  fun().then((module) => module.install(app));
@@ -8,6 +8,7 @@ const install = (app) => {
8
8
  console.error("dominfo 指令的值必须是一个对象");
9
9
  return;
10
10
  }
11
+ if (value.dominfo) return;
11
12
  const debounce = (fn, delay) => {
12
13
  let timeoutId;
13
14
  return (...args) => {
@@ -1,5 +1,4 @@
1
- import { defineComponent, ref, reactive, watch, onMounted, resolveComponent, createElementBlock, openBlock, createElementVNode, createVNode, withDirectives, vModelText, normalizeStyle, Transition, withCtx, withModifiers, normalizeClass, Fragment, renderList, toDisplayString, vShow } from 'vue';
2
- import { Scope } from 'tools-vue3';
1
+ import { defineComponent, ref, reactive, watch, nextTick, onMounted, onUnmounted, resolveComponent, createElementBlock, openBlock, createElementVNode, createVNode, withDirectives, vModelText, normalizeStyle, Transition, withCtx, withModifiers, normalizeClass, Fragment, renderList, toDisplayString, vShow } from 'vue';
3
2
 
4
3
  const _hoisted_1 = { style: { "width": "calc(100% - 18px)" } };
5
4
  const _hoisted_2 = ["readonly", "autocomplete", "placeholder"];
@@ -21,7 +20,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
21
20
  const emit = __emit;
22
21
  const dialogRef = ref({});
23
22
  const inputRef = ref({});
24
- const timer = Scope.Timer();
25
23
  const conf = reactive({
26
24
  activeItem: { value: "", label: "" },
27
25
  input: {
@@ -98,26 +96,68 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
98
96
  () => props.active,
99
97
  () => conf.input.initValue()
100
98
  );
99
+ const updateDialogPosition = () => {
100
+ if (!conf.dialog.show || !inputRef.value?.getBoundingClientRect || !dialogRef.value?.getBoundingClientRect) {
101
+ return;
102
+ }
103
+ const inputrect = inputRef.value.getBoundingClientRect();
104
+ const rect = dialogRef.value.getBoundingClientRect();
105
+ if (inputrect.top + inputrect.height + rect.height > document.body.clientHeight) {
106
+ dialogRef.value.style.top = "";
107
+ dialogRef.value.style.bottom = inputrect.height + 10 + "px";
108
+ conf.dialog.transition = "fade-down";
109
+ } else {
110
+ dialogRef.value.style.top = inputrect.height + 10 + "px";
111
+ dialogRef.value.style.bottom = "";
112
+ conf.dialog.transition = "fade-up";
113
+ }
114
+ };
115
+ watch(
116
+ () => conf.dialog.show,
117
+ async (show) => {
118
+ if (show) {
119
+ await nextTick();
120
+ updateDialogPosition();
121
+ if (resizeObserver && dialogRef.value) {
122
+ resizeObserver.observe(dialogRef.value);
123
+ }
124
+ } else {
125
+ if (resizeObserver && dialogRef.value) {
126
+ resizeObserver.unobserve(dialogRef.value);
127
+ }
128
+ }
129
+ }
130
+ );
131
+ let resizeObserver = null;
132
+ let scrollHandler = null;
101
133
  onMounted(() => {
102
134
  conf.input.initValue();
103
- timer.on(() => {
104
- if (!conf.dialog.show) return;
105
- if (inputRef.value?.getBoundingClientRect) {
106
- const inputrect = inputRef.value.getBoundingClientRect();
107
- if (dialogRef.value?.getBoundingClientRect) {
108
- const rect = dialogRef.value.getBoundingClientRect();
109
- if (inputrect.top + inputrect.height + rect.height > document.body.clientHeight) {
110
- dialogRef.value.style.top = "";
111
- dialogRef.value.style.bottom = inputrect.height + 10 + "px";
112
- conf.dialog.transition = "fade-down";
113
- } else {
114
- dialogRef.value.style.top = inputrect.height + 10 + "px";
115
- dialogRef.value.style.bottom = "";
116
- conf.dialog.transition = "fade-up";
117
- }
135
+ scrollHandler = () => {
136
+ if (conf.dialog.show) {
137
+ updateDialogPosition();
138
+ }
139
+ };
140
+ window.addEventListener("scroll", scrollHandler, true);
141
+ window.addEventListener("resize", scrollHandler);
142
+ if (window.ResizeObserver) {
143
+ resizeObserver = new ResizeObserver(() => {
144
+ if (conf.dialog.show) {
145
+ updateDialogPosition();
118
146
  }
147
+ });
148
+ if (inputRef.value) {
149
+ resizeObserver.observe(inputRef.value);
119
150
  }
120
- }, 10);
151
+ }
152
+ });
153
+ onUnmounted(() => {
154
+ if (scrollHandler) {
155
+ window.removeEventListener("scroll", scrollHandler, true);
156
+ window.removeEventListener("resize", scrollHandler);
157
+ }
158
+ if (resizeObserver) {
159
+ resizeObserver.disconnect();
160
+ }
121
161
  });
122
162
  return (_ctx, _cache) => {
123
163
  const _component_VIcon = resolveComponent("VIcon");
package/dist/index.d.ts CHANGED
@@ -14,8 +14,8 @@ declare module 'vue' {
14
14
  export interface GlobalComponents {
15
15
  VButton:typeof import('./components/Button/index.vue')['default']
16
16
  VCircle:typeof import('./components/Circle/index.vue')['default']
17
- VIcon:typeof import('./components/Icon/index.vue')['default']
18
17
  VMask:typeof import('./components/Mask/index.vue')['default']
18
+ VIcon:typeof import('./components/Icon/index.vue')['default']
19
19
  VSIcon:typeof import('./components/SIcon/index.vue')['default']
20
20
  VScale:typeof import('./components/Scale/index.vue')['default']
21
21
  VSelect:typeof import('./components/Select/index.vue')['default']
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc1-ui",
3
- "version": "0.0.11",
3
+ "version": "1.0.1",
4
4
  "description": "我来助你-Vue3UI库",
5
5
  "repository": {
6
6
  "type": "git",
@@ -45,9 +45,9 @@
45
45
  "less": "4.3.0",
46
46
  "prettier": "3.2.5",
47
47
  "terser": "5.44.1",
48
- "tools-javascript": "*",
49
- "tools-mock": "^2.0.8",
50
- "tools-vue3": "*",
48
+ "cc1-js": "*",
49
+ "cc1-node": "*",
50
+ "cc1-vue3": "*",
51
51
  "ts-node": "*",
52
52
  "tsc-alias": "1.8.11",
53
53
  "tsx": "4.19.4",