ninemoon-ui 0.2.1 → 0.2.3

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.
@@ -13,7 +13,9 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
13
13
  inline: undefined;
14
14
  showRequire: boolean;
15
15
  labelPosition: undefined;
16
- }>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
16
+ }>>, {
17
+ validateLabel: (callBack?: Function, eventName?: string) => Promise<void>;
18
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
17
19
  label?: string;
18
20
  prop?: string;
19
21
  inline?: boolean;
package/dist/index.d.ts CHANGED
@@ -252,7 +252,9 @@ declare const LibFormLabel: {
252
252
  type: import('vue').PropType<boolean>;
253
253
  default: boolean;
254
254
  };
255
- }>> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').PublicProps, {
255
+ }>> & Readonly<{}>, {
256
+ validateLabel: (callBack?: Function, eventName?: string) => Promise<void>;
257
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').PublicProps, {
256
258
  width: number;
257
259
  inline: boolean;
258
260
  labelPosition: "top" | "left" | "right";
@@ -287,7 +289,9 @@ declare const LibFormLabel: {
287
289
  type: import('vue').PropType<boolean>;
288
290
  default: boolean;
289
291
  };
290
- }>> & Readonly<{}>, {}, {}, {}, {}, {
292
+ }>> & Readonly<{}>, {
293
+ validateLabel: (callBack?: Function, eventName?: string) => Promise<void>;
294
+ }, {}, {}, {}, {
291
295
  width: number;
292
296
  inline: boolean;
293
297
  labelPosition: "top" | "left" | "right";
@@ -319,7 +323,9 @@ declare const LibFormLabel: {
319
323
  type: import('vue').PropType<boolean>;
320
324
  default: boolean;
321
325
  };
322
- }>> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {
326
+ }>> & Readonly<{}>, {
327
+ validateLabel: (callBack?: Function, eventName?: string) => Promise<void>;
328
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {
323
329
  width: number;
324
330
  inline: boolean;
325
331
  labelPosition: "top" | "left" | "right";
@@ -40,6 +40,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
40
40
  translatexNum.value = body.value.offsetWidth;
41
41
  });
42
42
  const activeIndex = ref(props.startindex);
43
+ const handleWheel = (e) => {
44
+ e.preventDefault();
45
+ if (e.deltaY < 0) {
46
+ preHandle();
47
+ } else {
48
+ nextHandle();
49
+ }
50
+ };
51
+ const isHovered = ref(false);
43
52
  const flattenSlots = (nodes) => {
44
53
  const result = [];
45
54
  for (const node of nodes) {
@@ -118,7 +127,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
118
127
  const flagTime = ref(null);
119
128
  const animationFrame = ref(null);
120
129
  const startAutoplay = () => {
121
- if (totalLen.value <= 1) {
130
+ if (totalLen.value <= 1 || isHovered.value) {
122
131
  animationFrame.value && cancelAnimationFrame(animationFrame.value);
123
132
  return;
124
133
  }
@@ -132,11 +141,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
132
141
  animationFrame.value = requestAnimationFrame(startAutoplay);
133
142
  };
134
143
  const stopAutoAddHandle = () => {
144
+ isHovered.value = true;
135
145
  flagTime.value = null;
136
146
  animationFrame.value && cancelAnimationFrame(animationFrame.value);
137
147
  };
138
148
  const mouseLeaveHandle = () => {
139
- stopAutoAddHandle();
149
+ isHovered.value = false;
140
150
  startAutoplay();
141
151
  };
142
152
  onMounted(() => {
@@ -159,7 +169,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
159
169
  class: "relative w-full group text-center overflow-x-hidden",
160
170
  ref_key: "body",
161
171
  ref: body,
162
- style: normalizeStyle({ height: `${props.height || 200}px` })
172
+ style: normalizeStyle({ height: `${props.height || 200}px` }),
173
+ onWheel: handleWheel
163
174
  }, [
164
175
  createVNode(_sfc_main$1, { onClick: preHandle }),
165
176
  createVNode(_sfc_main$1, {
@@ -14,16 +14,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
14
14
  showRequire: { type: Boolean, default: false },
15
15
  labelPosition: { default: void 0 }
16
16
  },
17
- setup(__props) {
17
+ setup(__props, { expose: __expose }) {
18
18
  const props = __props;
19
19
  const haslabel = computed(() => !!props.label);
20
20
  const Rules = inject("_ParentRules_", {});
21
- inject("_ParentModels_", ref());
22
- inject("_formRuleCheck_", () => null);
23
- inject("_validateClear_", () => null);
21
+ const Model = inject("_ParentModels_", ref());
22
+ const sendCheck = inject("_formRuleCheck_", () => null);
23
+ const sendClear = inject("_validateClear_", () => null);
24
24
  const parentLineStatus = inject("_ParentLineStatus_", ref());
25
25
  const parentLabelPosition = inject("_ParentLabelPosition_", ref());
26
- computed(() => {
26
+ const getThisRule = computed(() => {
27
27
  if (!props.prop) {
28
28
  return [];
29
29
  }
@@ -43,20 +43,88 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
43
43
  return parentLabelPosition.value;
44
44
  }
45
45
  });
46
- const tip = ref("");
47
- const showTip = ref(false);
48
- if (props.prop) {
49
- const updateTip = (newTip, newShow) => {
50
- tip.value = newTip;
51
- showTip.value = newShow;
46
+ const checkPropHandle = async (callBack, eventName) => {
47
+ if (!props.prop)
48
+ return;
49
+ if (getThisRule.value.length === 0) {
50
+ callBack && callBack(true);
51
+ return;
52
+ }
53
+ const setErrHandle = (errword) => {
54
+ if (errword)
55
+ tip.value = errword;
56
+ showTip.value = true;
57
+ callBack && callBack(false);
52
58
  };
53
- const validateClear = () => {
54
- tip.value = "";
59
+ const aimdata = Model.value[props.prop];
60
+ const filterRule = getThisRule.value.filter(
61
+ (rule) => !eventName || rule.trigger === eventName
62
+ );
63
+ let i = 0;
64
+ for (; i < filterRule.length; i++) {
65
+ const { type, min, max, message, validator } = filterRule[i];
66
+ tip.value = message || "";
67
+ if (min || max) {
68
+ const toNum = Number(aimdata);
69
+ if (isNaN(toNum)) {
70
+ setErrHandle("请输入数字");
71
+ break;
72
+ }
73
+ if (min && toNum < min || max && toNum > max) {
74
+ setErrHandle();
75
+ break;
76
+ }
77
+ }
78
+ if (type) {
79
+ if (!validateType(aimdata, type)) {
80
+ setErrHandle();
81
+ break;
82
+ }
83
+ }
84
+ if (validator) {
85
+ const result = await FunctionToPromise(validator, aimdata);
86
+ if (result !== void 0) {
87
+ setErrHandle(result);
88
+ break;
89
+ }
90
+ }
91
+ if (aimdata === null || aimdata === "" || aimdata === void 0) {
92
+ setErrHandle();
93
+ break;
94
+ }
95
+ }
96
+ if (i === getThisRule.value.length) {
55
97
  showTip.value = false;
56
- };
57
- provide("_updateTip_", updateTip);
58
- provide("_validateClear_", validateClear);
59
- }
98
+ tip.value = "";
99
+ callBack && callBack(true);
100
+ }
101
+ };
102
+ const validateType = (value, type) => {
103
+ if (type === "array")
104
+ return Array.isArray(value);
105
+ return typeof value === type;
106
+ };
107
+ const tip = ref("");
108
+ const showTip = ref(false);
109
+ const resetField = () => {
110
+ tip.value = "";
111
+ showTip.value = false;
112
+ };
113
+ const FunctionToPromise = (callBack, receiveData) => {
114
+ return new Promise((resolve) => {
115
+ callBack(receiveData, (result) => {
116
+ resolve(result);
117
+ });
118
+ });
119
+ };
120
+ props.prop && sendCheck(props.prop, checkPropHandle);
121
+ sendClear(resetField);
122
+ provide("inputHandle", () => checkPropHandle(void 0, "input"));
123
+ provide("blurHandle", () => checkPropHandle(void 0, "blur"));
124
+ provide("changeHandle", () => checkPropHandle(void 0, "change"));
125
+ __expose({
126
+ validateLabel: checkPropHandle
127
+ });
60
128
  return (_ctx, _cache) => {
61
129
  return openBlock(), createElementBlock("div", {
62
130
  class: normalizeClass([
@@ -1,5 +1,5 @@
1
- import { openBlock, createElementBlock, createElementVNode, defineComponent, ref, watch, Fragment, createVNode, createCommentVNode, renderSlot, createBlock, Teleport, Transition, withCtx, normalizeStyle, withDirectives, withModifiers, normalizeClass, unref } from "vue";
2
- import { _ as _export_sfc, b as createDraggableDirective, d as createWheelDirective, z as zIndexManager } from "../index/index.js";
1
+ import { openBlock, createElementBlock, createElementVNode, defineComponent, ref, watch, Fragment, createVNode, createCommentVNode, renderSlot, createBlock, Teleport, unref, Transition, withCtx, withDirectives, normalizeStyle, withModifiers, normalizeClass } from "vue";
2
+ import { _ as _export_sfc, b as createDraggableDirective, d as createWheelDirective, z as zIndexManager, s as selector } from "../index/index.js";
3
3
  import { d as delIcon } from "../delete/delete.js";
4
4
  const _sfc_main$3 = {};
5
5
  const _hoisted_1$3 = {
@@ -50,10 +50,9 @@ function _sfc_render(_ctx, _cache) {
50
50
  const turnRightIcon = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render]]);
51
51
  const _hoisted_1 = { class: "relative inline-block h-full w-full" };
52
52
  const _hoisted_2 = ["src"];
53
- const _hoisted_3 = { key: 0 };
54
- const _hoisted_4 = { class: "pointer-events-none fixed top-0 right-0 left-0 bottom-0 text-center" };
55
- const _hoisted_5 = { class: "pointer-events-auto absolute top-0 left-0 z-10 flex w-full items-center bg-black bg-opacity-10" };
56
- const _hoisted_6 = ["src"];
53
+ const _hoisted_3 = { class: "pointer-events-none fixed top-0 right-0 left-0 bottom-0 text-center" };
54
+ const _hoisted_4 = { class: "pointer-events-auto absolute top-0 left-0 z-10 flex w-full items-center bg-black bg-opacity-10" };
55
+ const _hoisted_5 = ["src"];
57
56
  const _sfc_main = /* @__PURE__ */ defineComponent({
58
57
  __name: "image",
59
58
  props: {
@@ -64,7 +63,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
64
63
  emits: ["openPreview", "closePreview"],
65
64
  setup(__props, { emit: __emit }) {
66
65
  const draggableConfig = {
67
- throttleWait: 16,
66
+ throttleWait: 10,
68
67
  onDrag: (pos) => {
69
68
  transX.value = pos.x;
70
69
  transY.value = pos.y;
@@ -131,18 +130,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
131
130
  ])) : createCommentVNode("", true),
132
131
  renderSlot(_ctx.$slots, "default")
133
132
  ]),
134
- (openBlock(), createBlock(Teleport, { to: "body" }, [
133
+ (openBlock(), createBlock(Teleport, {
134
+ to: `#${unref(selector)}`
135
+ }, [
135
136
  createVNode(Transition, { name: "opacity" }, {
136
137
  default: withCtx(() => [
137
- showBig.value ? (openBlock(), createElementBlock("div", _hoisted_3, [
138
+ showBig.value ? withDirectives((openBlock(), createElementBlock("div", {
139
+ key: 0,
140
+ style: normalizeStyle({ "z-index": currentZIndex.value })
141
+ }, [
138
142
  createElementVNode("div", {
139
143
  class: "pointer-events-auto fixed top-0 right-0 left-0 bottom-0 bg-black bg-opacity-30",
140
- style: normalizeStyle({ "z-index": currentZIndex.value }),
141
- key: "1",
142
144
  onClick: hidenPreview
143
- }, null, 4),
144
- withDirectives((openBlock(), createElementBlock("div", _hoisted_4, [
145
- createElementVNode("div", _hoisted_5, [
145
+ }),
146
+ createElementVNode("div", _hoisted_3, [
147
+ createElementVNode("div", _hoisted_4, [
146
148
  createElementVNode("button", {
147
149
  type: "button",
148
150
  class: "flex h-10 w-10 items-center justify-center text-white",
@@ -178,18 +180,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
178
180
  style: normalizeStyle({
179
181
  transform: `scale3d(${scaleNumber.value}, ${scaleNumber.value}, 1) rotate(${rotateNumber.value}deg)`
180
182
  })
181
- }, null, 14, _hoisted_6)
183
+ }, null, 14, _hoisted_5)
182
184
  ], 4)), [
183
185
  [unref(vMove), showBig.value]
184
186
  ])
185
- ])), [
186
- [unref(vWheel), showBig.value]
187
187
  ])
188
- ])) : createCommentVNode("", true)
188
+ ], 4)), [
189
+ [unref(vWheel), showBig.value]
190
+ ]) : createCommentVNode("", true)
189
191
  ]),
190
192
  _: 1
191
193
  })
192
- ]))
194
+ ], 8, ["to"]))
193
195
  ], 64);
194
196
  };
195
197
  }
@@ -1,4 +1,4 @@
1
- import { defineComponent, computed, useSlots, h, nextTick, normalizeClass, ref, openBlock, createElementBlock, Fragment, createElementVNode, renderList, withDirectives, vModelCheckbox, createCommentVNode, createTextVNode, toDisplayString, createBlock, resolveDynamicComponent, Comment, Text } from "vue";
1
+ import { defineComponent, computed, useSlots, h, nextTick, ref, openBlock, createElementBlock, Fragment, createElementVNode, normalizeClass, renderList, withDirectives, vModelCheckbox, createCommentVNode, createTextVNode, toDisplayString, createBlock, markRaw, Comment, Text } from "vue";
2
2
  import { S as ShapeFlags } from "../shapeFlag/shapeFlag.js";
3
3
  const _hoisted_1 = ["width"];
4
4
  const _hoisted_2 = { key: 0 };
@@ -79,7 +79,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
79
79
  return flattenSlots(defaultSlots);
80
80
  });
81
81
  const groupedSlots = computed(() => {
82
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
83
82
  const groups = {
84
83
  append: null,
85
84
  prepend: null,
@@ -89,7 +88,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
89
88
  hasindex: false,
90
89
  hascheck: false
91
90
  };
92
- for (const slot of validSlots.value) {
91
+ validSlots.value.forEach((slot) => {
92
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
93
93
  const type = (_a = slot.props) == null ? void 0 : _a.type;
94
94
  switch (type) {
95
95
  case "append":
@@ -133,19 +133,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
133
133
  });
134
134
  break;
135
135
  }
136
- }
136
+ });
137
137
  return groups;
138
138
  });
139
139
  const prependSlot = computed(() => groupedSlots.value.prepend);
140
140
  const appendSlot = computed(() => groupedSlots.value.append);
141
- const dynamicPre = computed(() => (props2) => {
141
+ const dynamicPre = (props2) => {
142
142
  var _a, _b, _c;
143
143
  return (_c = (_a = prependSlot.value) == null ? void 0 : (_b = _a.children).default) == null ? void 0 : _c.call(_b, props2);
144
- });
145
- const dynamicAppend = computed(() => (props2) => {
144
+ };
145
+ const dynamicAppend = (props2) => {
146
146
  var _a, _b, _c;
147
147
  return (_c = (_a = appendSlot.value) == null ? void 0 : (_b = _a.children).default) == null ? void 0 : _c.call(_b, props2);
148
- });
148
+ };
149
149
  const hasindexSlot = computed(() => groupedSlots.value.hasindex);
150
150
  const hascheckSlot = computed(() => groupedSlots.value.hascheck);
151
151
  const normalSlots = computed(() => groupedSlots.value.normal);
@@ -168,19 +168,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
168
168
  nextTick(() => {
169
169
  emit("finishRender");
170
170
  });
171
- const dynormalRenderHandle = computed(() => {
172
- return (rowprops) => {
173
- return dynamicnormal.value.map((rh, _) => {
174
- return h(
175
- "td",
176
- {
177
- class: normalizeClass(["text-center py-2", props.cellclass])
178
- },
179
- rh({ row: rowprops.row, index: rowprops.rowindex })
180
- );
181
- });
182
- };
183
- });
171
+ const dynormalRenderHandle = (rowprops) => {
172
+ return dynamicnormal.value.map((rh, _) => {
173
+ return h(
174
+ "td",
175
+ {
176
+ class: normalizeClass(["text-center py-2", props.cellclass])
177
+ },
178
+ rh({ row: rowprops.row, index: rowprops.rowindex })
179
+ );
180
+ });
181
+ };
184
182
  const getRowKey = (rowdata, index) => props.idKey ? `row_${rowdata[props.idKey]}` : `row_${index}`;
185
183
  const getPreRowkey = (rowdata, index) => props.idKey ? `prepend_${rowdata[props.idKey]}` : `prepend_${index}`;
186
184
  const getAppendRowkey = (rowdata, index) => props.idKey ? `append_${rowdata[props.idKey]}` : `append_${index}`;
@@ -307,8 +305,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
307
305
  }, [
308
306
  prependSlot.value ? (openBlock(), createElementBlock("tr", _hoisted_2, [
309
307
  createElementVNode("td", { colspan: colSpan.value }, [
310
- (openBlock(), createBlock(resolveDynamicComponent(dynamicPre.value), {
311
- row: rowdata,
308
+ (openBlock(), createBlock(dynamicPre, {
309
+ row: markRaw(rowdata),
312
310
  index: rowindex,
313
311
  key: getPreRowkey(rowdata, rowindex)
314
312
  }, null, 8, ["row", "index"]))
@@ -332,16 +330,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
332
330
  hasindexSlot.value ? (openBlock(), createElementBlock("td", _hoisted_8, [
333
331
  createElementVNode("div", null, toDisplayString(rowindex + 1), 1)
334
332
  ])) : createCommentVNode("", true),
335
- (openBlock(), createBlock(resolveDynamicComponent(dynormalRenderHandle.value), {
336
- row: rowdata,
333
+ (openBlock(), createBlock(dynormalRenderHandle, {
334
+ row: markRaw(rowdata),
337
335
  rowindex,
338
336
  key: getRowKey(rowdata, rowindex)
339
337
  }, null, 8, ["row", "rowindex"]))
340
338
  ]),
341
339
  appendSlot.value ? (openBlock(), createElementBlock("tr", _hoisted_9, [
342
340
  createElementVNode("td", { colspan: colSpan.value }, [
343
- (openBlock(), createBlock(resolveDynamicComponent(dynamicAppend.value), {
344
- row: rowdata,
341
+ (openBlock(), createBlock(dynamicAppend, {
342
+ row: markRaw(rowdata),
345
343
  index: rowindex,
346
344
  key: getAppendRowkey(rowdata, rowindex)
347
345
  }, null, 8, ["row", "index"]))
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninemoon-ui",
3
3
  "private": false,
4
- "version": "0.2.1",
4
+ "version": "0.2.3",
5
5
  "author": "zhuboy",
6
6
  "keywords": [
7
7
  "vue3",