@opentiny/vue-renderless 3.11.0-alpha.0 → 3.11.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 (55) hide show
  1. package/anchor/index.js +4 -1
  2. package/common/deps/fastdom/singleton.js +1 -1
  3. package/common/deps/popper.js +15 -8
  4. package/common/deps/popup-manager.js +1 -0
  5. package/common/event.js +8 -1
  6. package/common/index.js +1 -1
  7. package/common/runtime.js +1 -1
  8. package/dialog-box/index.js +2 -2
  9. package/form/index.js +22 -0
  10. package/form/vue.js +9 -0
  11. package/form-item/index.js +24 -0
  12. package/form-item/vue.js +11 -2
  13. package/grid/utils/dom.js +2 -1
  14. package/image/index.js +38 -3
  15. package/image/vue.js +7 -2
  16. package/image-viewer/index.js +326 -41
  17. package/image-viewer/vue.js +63 -18
  18. package/nav-menu/index.js +96 -14
  19. package/nav-menu/vue.js +18 -8
  20. package/package.json +1 -1
  21. package/picker/vue.js +1 -1
  22. package/popover/vue.js +8 -3
  23. package/rich-text-edtior/index.js +4 -0
  24. package/rich-text-edtior/vue.js +14 -14
  25. package/search/index.js +4 -1
  26. package/search/vue.js +3 -3
  27. package/tabbar/index.js +35 -2
  28. package/tabbar/vue.js +35 -9
  29. package/tabbar-item/index.js +10 -5
  30. package/tabbar-item/vue.js +13 -8
  31. package/tag/index.js +1 -1
  32. package/types/anchor.type.d.mts +4 -0
  33. package/types/checkbox.type.d.mts +2 -2
  34. package/types/collapse.type.d.mts +1 -1
  35. package/types/file-upload.type.d.mts +1 -1
  36. package/types/form-item.type.d.mts +1 -1
  37. package/types/{form.type-7fc7c2ad.d.ts → form.type-004ecf93.d.ts} +32 -12
  38. package/types/form.type.d.mts +1 -1
  39. package/types/image.type.d.mts +37 -4
  40. package/types/milestone.type.d.mts +1 -1
  41. package/types/nav-menu.type.d.mts +7 -1
  42. package/types/popeditor.type.d.mts +1 -1
  43. package/types/popover.type.d.mts +2 -1
  44. package/types/progress.type.d.mts +1 -1
  45. package/types/shared.type.d.mts +5 -5
  46. package/types/steps.type.d.mts +1 -1
  47. package/types/switch.type.d.mts +3 -3
  48. package/types/upload-dragger.type.d.mts +2 -2
  49. package/types/{upload-list.type-4dfd7aba.d.ts → upload-list.type-aa21a42e.d.ts} +10 -3
  50. package/types/upload-list.type.d.mts +1 -1
  51. package/types/upload.type.d.mts +1 -1
  52. package/upload/index.js +23 -0
  53. package/upload/vue.js +3 -0
  54. package/user/index.js +2 -1
  55. package/user/vue.js +1 -1
package/anchor/index.js CHANGED
@@ -30,10 +30,13 @@ const updateSkidPosition = ({ vm, state, emit }) => {
30
30
  const { currentLink } = state;
31
31
  const activeEl = vm.$refs[currentLink];
32
32
  const { skidRef, maskRef, anchorRef } = vm.$refs;
33
- if (!activeEl || !anchorRef) {
33
+ if (!activeEl) {
34
34
  return;
35
35
  }
36
36
  emit("onChange", currentLink);
37
+ if (!anchorRef || !skidRef || !maskRef) {
38
+ return;
39
+ }
37
40
  const { offsetHeight, offsetWidth } = activeEl;
38
41
  const { top: linkTitleClientTop, left: linkTitleClientLeft } = activeEl.getBoundingClientRect();
39
42
  const { top: anchorClientTop, left: anchorClientLeft } = anchorRef.getBoundingClientRect();
@@ -64,7 +64,7 @@ class FastDom {
64
64
  }
65
65
  extend(props) {
66
66
  if (!props || typeof props !== "object")
67
- throw new Error("[AUI][FastDom] expected object");
67
+ throw new Error("[TINY][FastDom] expected object");
68
68
  const child = Object.create(this);
69
69
  mixin(child, props);
70
70
  child.fastdom = this;
@@ -85,14 +85,17 @@ const getScrollParent = (el) => {
85
85
  };
86
86
  const getOffsetRectRelativeToCustomParent = (el, parent, fixed) => {
87
87
  let { top, left, width, height } = getBoundingClientRect(el);
88
- let parentRect = getBoundingClientRect(parent);
89
88
  if (fixed) {
90
- let { scrollTop, scrollLeft } = getScrollParent(parent);
91
- parentRect.top += scrollTop;
92
- parentRect.bottom += scrollTop;
93
- parentRect.left += scrollLeft;
94
- parentRect.right += scrollLeft;
89
+ return {
90
+ top,
91
+ left,
92
+ bottom: top + height,
93
+ right: left + width,
94
+ width,
95
+ height
96
+ };
95
97
  }
98
+ let parentRect = getBoundingClientRect(parent);
96
99
  let rect = {
97
100
  top: top - parentRect.top,
98
101
  left: left - parentRect.left,
@@ -137,6 +140,9 @@ const getAllScrollParents = (el, parents = []) => {
137
140
  const parent = el.parentNode;
138
141
  if (parent) {
139
142
  isScrollElement(parent) && parents.push(parent);
143
+ if (getStyleComputedProperty(parent, "position") === "fixed") {
144
+ return parents;
145
+ }
140
146
  return getAllScrollParents(parent, parents);
141
147
  }
142
148
  return parents;
@@ -483,10 +489,11 @@ class Popper {
483
489
  let isFixed2 = data.offsets.popper.position === "fixed";
484
490
  let scrollTop = isFixed2 ? 0 : getScrollTopValue(scrollParent);
485
491
  let scrollLeft = isFixed2 ? 0 : getScrollLeftValue(scrollParent);
492
+ const viewportWindow = PopupManager.viewportWindow || window;
486
493
  boundaries = {
487
494
  top: 0 - (offsetParentRect.top - scrollTop),
488
- right: window.document.documentElement.clientWidth - (offsetParentRect.left - scrollLeft),
489
- bottom: window.document.documentElement.clientHeight - (offsetParentRect.top - scrollTop),
495
+ right: viewportWindow.document.documentElement.clientWidth - (offsetParentRect.left - scrollLeft),
496
+ bottom: viewportWindow.document.documentElement.clientHeight - (offsetParentRect.top - scrollTop),
490
497
  left: 0 - (offsetParentRect.left - scrollLeft)
491
498
  };
492
499
  } else {
@@ -30,6 +30,7 @@ const PopupManager = {
30
30
  // 当前是否有Modal
31
31
  popLockClass: "popup-parent--hidden",
32
32
  oldBodyBorder: "",
33
+ viewportWindow: null,
33
34
  fixBodyBorder() {
34
35
  const barWidth = window.innerWidth - document.documentElement.clientWidth;
35
36
  if (barWidth) {
package/common/event.js CHANGED
@@ -13,6 +13,13 @@ const emitEvent = (emit, name, ...args) => {
13
13
  }
14
14
  return !cancel;
15
15
  };
16
+ const getActualTarget = (e) => {
17
+ if (!e || !e.target) {
18
+ return null;
19
+ }
20
+ return e.target.shadowRoot && e.composed ? e.composedPath()[0] || e.target : e.target;
21
+ };
16
22
  export {
17
- emitEvent
23
+ emitEvent,
24
+ getActualTarget
18
25
  };
package/common/index.js CHANGED
@@ -224,7 +224,7 @@ const CASCADER = {
224
224
  PropsHover: "hoverThreshold",
225
225
  MenuConnector: "cascader-menu-"
226
226
  };
227
- const version = "3.11.0-alpha.0";
227
+ const version = "3.11.0";
228
228
  const log = (data, type = "log") => {
229
229
  uLog.logger[type](data);
230
230
  };
package/common/runtime.js CHANGED
@@ -22,7 +22,7 @@ import vuePopup from "./deps/vue-popup";
22
22
  import validate from "./validate";
23
23
  import memorize from "./deps/memorize";
24
24
  import * as common from ".";
25
- const version = "3.11.0-alpha.0";
25
+ const version = "3.11.0";
26
26
  const Renderless = {
27
27
  browser,
28
28
  array,
@@ -193,8 +193,8 @@ const handleDrag = ({ parent, props, state, emit }) => (event) => {
193
193
  }
194
194
  let offsetWidth = modalBoxElem.offsetWidth;
195
195
  let offsetHeight = modalBoxElem.offsetHeight;
196
- let maxX = visibleWidth - offsetWidth;
197
- let maxY = visibleHeight - offsetHeight;
196
+ let maxX = Math.max(visibleWidth - offsetWidth, 0);
197
+ let maxY = Math.max(visibleHeight - offsetHeight, 0);
198
198
  let left = event2.clientX - disX;
199
199
  let top = event2.clientY - disY;
200
200
  left = left < 0 ? 0 : left > maxX ? maxX : left;
package/form/index.js CHANGED
@@ -24,6 +24,25 @@ const computedHideRequiredAsterisk = ({ props, designConfig }) => () => {
24
24
  var _a, _b;
25
25
  return (_b = (_a = props.hideRequiredAsterisk) != null ? _a : designConfig == null ? void 0 : designConfig.hideRequiredAsterisk) != null ? _b : false;
26
26
  };
27
+ const computedValidateIcon = ({ props, designConfig }) => () => {
28
+ var _a, _b, _c;
29
+ return (_c = (_b = props.validateIcon) != null ? _b : (_a = designConfig == null ? void 0 : designConfig.icons) == null ? void 0 : _a.validateIcon) != null ? _c : null;
30
+ };
31
+ const computedIsErrorInline = ({ props, designConfig }) => () => {
32
+ if (props.messageType) {
33
+ return props.messageType === "inline";
34
+ }
35
+ if (typeof props.inlineMessage === "boolean") {
36
+ return props.inlineMessage;
37
+ }
38
+ return (designConfig == null ? void 0 : designConfig.messageType) === "inline" || false;
39
+ };
40
+ const computedIsErrorBlock = ({ props, designConfig }) => () => {
41
+ if (props.messageType) {
42
+ return props.messageType === "block";
43
+ }
44
+ return (designConfig == null ? void 0 : designConfig.messageType) === "block" || false;
45
+ };
27
46
  const created = ({ parent, state }) => () => {
28
47
  parent.$on("form:addField", (field) => {
29
48
  if (field) {
@@ -166,6 +185,9 @@ export {
166
185
  clearValidate,
167
186
  computedAutoLabelWidth,
168
187
  computedHideRequiredAsterisk,
188
+ computedIsErrorBlock,
189
+ computedIsErrorInline,
190
+ computedValidateIcon,
169
191
  created,
170
192
  deregisterLabelWidth,
171
193
  getLabelWidthIndex,
package/form/vue.js CHANGED
@@ -3,6 +3,9 @@ import {
3
3
  watchRules,
4
4
  computedAutoLabelWidth,
5
5
  computedHideRequiredAsterisk,
6
+ computedValidateIcon,
7
+ computedIsErrorInline,
8
+ computedIsErrorBlock,
6
9
  created,
7
10
  resetFields,
8
11
  clearValidate,
@@ -41,6 +44,9 @@ const renderless = (props, { computed, inject, provide, reactive, watch, onBefor
41
44
  potentialLabelWidthArr: [],
42
45
  autoLabelWidth: computed(() => api2.computedAutoLabelWidth()),
43
46
  hideRequiredAsterisk: computed(() => api2.computedHideRequiredAsterisk()),
47
+ validateIcon: computed(() => api2.computedValidateIcon()),
48
+ isErrorInline: computed(() => api2.computedIsErrorInline()),
49
+ isErrorBlock: computed(() => api2.computedIsErrorBlock()),
44
50
  isDisplayOnly: computed(() => props.displayOnly),
45
51
  hasRequired: computed(() => {
46
52
  if (props.rules) {
@@ -61,6 +67,9 @@ const renderless = (props, { computed, inject, provide, reactive, watch, onBefor
61
67
  updateTip: updateTip({ props, state }),
62
68
  computedAutoLabelWidth: computedAutoLabelWidth({ state }),
63
69
  computedHideRequiredAsterisk: computedHideRequiredAsterisk({ props, designConfig }),
70
+ computedValidateIcon: computedValidateIcon({ props, designConfig }),
71
+ computedIsErrorInline: computedIsErrorInline({ props, designConfig }),
72
+ computedIsErrorBlock: computedIsErrorBlock({ props, designConfig }),
64
73
  created: created({ parent, state }),
65
74
  resetFields: resetFields({ props, state }),
66
75
  clearValidate: clearValidate(state),
@@ -16,6 +16,27 @@ const watchValidateStatus = (state) => (value) => {
16
16
  state.validateState = value;
17
17
  };
18
18
  const computedGetValidateType = ({ props, state }) => () => props.validateType || (state.formInstance ? state.formInstance.validateType : "");
19
+ const computedValidateIcon = ({ props, state }) => () => {
20
+ var _a, _b, _c, _d;
21
+ return (_d = (_c = props.validateIcon) != null ? _c : (_b = (_a = state == null ? void 0 : state.formInstance) == null ? void 0 : _a.state) == null ? void 0 : _b.validateIcon) != null ? _d : null;
22
+ };
23
+ const computedIsErrorInline = ({ props, state }) => () => {
24
+ var _a, _b, _c;
25
+ if (props.messageType) {
26
+ return props.messageType === "inline";
27
+ }
28
+ if (typeof props.inlineMessage === "boolean") {
29
+ return props.inlineMessage;
30
+ }
31
+ return (_c = (_b = (_a = state == null ? void 0 : state.formInstance) == null ? void 0 : _a.state) == null ? void 0 : _b.isErrorInline) != null ? _c : false;
32
+ };
33
+ const computedIsErrorBlock = ({ props, state }) => () => {
34
+ var _a, _b, _c;
35
+ if (props.messageType) {
36
+ return props.messageType === "block";
37
+ }
38
+ return (_c = (_b = (_a = state == null ? void 0 : state.formInstance) == null ? void 0 : _a.state) == null ? void 0 : _b.isErrorBlock) != null ? _c : false;
39
+ };
19
40
  const computedLabelStyle = ({ props, state }) => () => {
20
41
  const result = { width: "" };
21
42
  if (state.form.labelPosition === POSITION.Top) {
@@ -343,8 +364,11 @@ export {
343
364
  computedFieldValue,
344
365
  computedForm,
345
366
  computedGetValidateType,
367
+ computedIsErrorBlock,
368
+ computedIsErrorInline,
346
369
  computedIsRequired,
347
370
  computedLabelStyle,
371
+ computedValidateIcon,
348
372
  computedValueStyle,
349
373
  getDisplayedValue,
350
374
  getFilteredRule,
package/form-item/vue.js CHANGED
@@ -21,6 +21,9 @@ import {
21
21
  computedIsRequired,
22
22
  computedFieldValue,
23
23
  computedGetValidateType,
24
+ computedValidateIcon,
25
+ computedIsErrorInline,
26
+ computedIsErrorBlock,
24
27
  updateTip,
25
28
  wrapValidate,
26
29
  getDisplayedValue,
@@ -85,12 +88,15 @@ const initState = ({
85
88
  isDisplayOnly: computed(() => state.formInstance.displayOnly),
86
89
  labelPosition: computed(() => state.formInstance.labelPosition),
87
90
  hideRequiredAsterisk: computed(() => state.formInstance.state.hideRequiredAsterisk),
91
+ // isErrorInline: computed(() => state.formInstance.state.isErrorInline),
88
92
  labelSuffix: computed(() => state.formInstance.labelSuffix),
89
93
  labelWidth: computed(() => state.formInstance.labelWidth),
90
94
  showMessage: computed(() => state.formInstance.showMessage),
91
- inlineMessage: computed(() => state.formInstance.inlineMessage),
92
95
  sizeClass: computed(() => state.formItemSize),
93
- getValidateType: computed(() => api2.computedGetValidateType())
96
+ getValidateType: computed(() => api2.computedGetValidateType()),
97
+ validateIcon: computed(() => api2.computedValidateIcon()),
98
+ isErrorInline: computed(() => api2.computedIsErrorInline()),
99
+ isErrorBlock: computed(() => api2.computedIsErrorBlock())
94
100
  });
95
101
  return state;
96
102
  };
@@ -108,6 +114,9 @@ const initApi = ({ api: api2, state, dispatch, broadcast, refs, props, constants
108
114
  computedForm: computedForm({ constants, instance, state }),
109
115
  computedFieldValue: computedFieldValue({ props, state }),
110
116
  computedGetValidateType: computedGetValidateType({ props, state }),
117
+ computedValidateIcon: computedValidateIcon({ props, state }),
118
+ computedIsErrorInline: computedIsErrorInline({ props, state }),
119
+ computedIsErrorBlock: computedIsErrorBlock({ props, state }),
111
120
  clearValidate: clearValidate(state),
112
121
  getRules: getRules({ props, state }),
113
122
  updateComputedLabelWidth: updateComputedLabelWidth(state),
package/grid/utils/dom.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import "../../chunk-G2ADBYYC.js";
2
2
  import { getRowid } from "./common";
3
3
  import { hasClass } from "../../common/deps/dom";
4
+ import { getActualTarget } from "../../common/event";
4
5
  import { arrayIndexOf } from "../static";
5
6
  const ATTR_NAME = "data-rowid";
6
7
  const CELL_CLS = ".tiny-grid-cell";
@@ -107,7 +108,7 @@ const getDomNode = () => {
107
108
  };
108
109
  const getEventTargetNode = (event, container, queryCls) => {
109
110
  let targetEl;
110
- let target = event.target;
111
+ let target = getActualTarget(event);
111
112
  while (target && target.nodeType && target !== document) {
112
113
  if (queryCls && hasClass(target, queryCls)) {
113
114
  targetEl = target;
package/image/index.js CHANGED
@@ -3,8 +3,16 @@ import { on, off, getScrollContainer, isInContainer } from "../common/deps/dom";
3
3
  import { typeOf } from "../common/type";
4
4
  import "../common/deps/requestAnimationFrame";
5
5
  import { rafThrottle } from "../image-viewer";
6
+ const isSupportObjectFit = () => document.documentElement.style.objectFit !== void 0;
6
7
  const isHtmlElement = (node) => node && node.nodeType === Node.ELEMENT_NODE;
7
- const computedGetImageStyle = ({ props }) => () => props.fit ? { "object-fit": props.fit } : {};
8
+ const computedGetImageStyle = ({ props, api }) => () => {
9
+ const { fit } = props;
10
+ if (fit) {
11
+ return isSupportObjectFit() ? { "object-fit": fit } : api.getImageStyle(fit);
12
+ }
13
+ return {};
14
+ };
15
+ const computedGetAlignCenter = ({ props, constants }) => () => !isSupportObjectFit() && props.fit !== constants.FILL;
8
16
  const computedGetPreview = (props) => () => Array.isArray(props.previewSrcList) && props.previewSrcList.length > 0;
9
17
  const loadImage = ({ state, api, attrs, props }) => () => {
10
18
  state.loading = true;
@@ -18,7 +26,7 @@ const loadImage = ({ state, api, attrs, props }) => () => {
18
26
  img.setAttribute(key, value);
19
27
  }
20
28
  });
21
- img.src = props.src;
29
+ img.src = props.src || "";
22
30
  };
23
31
  const handleLoad = ({ state, emit }) => (event, img) => {
24
32
  state.imageWidth = img.width;
@@ -66,7 +74,32 @@ const removeLazyLoadListener = (state) => () => {
66
74
  state._scrollContainer = null;
67
75
  state._lazyLoadHandler = null;
68
76
  };
69
- const clickHandler = (state) => () => state.showViewer = true;
77
+ const getImageStyle = ({ state, vm, constants }) => (fit) => {
78
+ const { imageWidth, imageHeight } = state;
79
+ const { clientWidth: containerWidth, clientHeight: containerHeight } = vm.$el;
80
+ if (!imageWidth || !imageHeight || !containerWidth || !containerHeight) {
81
+ return {};
82
+ }
83
+ const vertical = imageWidth / imageHeight < 1;
84
+ if (fit === constants.SCALE_DOWN) {
85
+ const isSmaller = imageWidth < containerWidth && imageHeight < containerHeight;
86
+ fit = isSmaller ? constants.NONE : constants.CONTAIN;
87
+ }
88
+ if (fit === constants.NONE) {
89
+ return { width: "auto", height: "auto" };
90
+ }
91
+ if (fit === constants.CONTAIN) {
92
+ return vertical ? { width: "auto" } : { height: "auto" };
93
+ }
94
+ if (fit === constants.COVER) {
95
+ return vertical ? { height: "auto" } : { width: "auto" };
96
+ }
97
+ return {};
98
+ };
99
+ const clickHandler = (state) => () => {
100
+ state.showViewer = true;
101
+ state.mfPreviewVisible = true;
102
+ };
70
103
  const closeViewer = (state) => () => state.showViewer = false;
71
104
  const mounted = ({ props, api }) => () => {
72
105
  if (props.lazy) {
@@ -79,9 +112,11 @@ export {
79
112
  addLazyLoadListener,
80
113
  clickHandler,
81
114
  closeViewer,
115
+ computedGetAlignCenter,
82
116
  computedGetImageStyle,
83
117
  computedGetPreview,
84
118
  deleteHander,
119
+ getImageStyle,
85
120
  handleError,
86
121
  handleLazyLoad,
87
122
  handleLoad,
package/image/vue.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import "../chunk-G2ADBYYC.js";
2
2
  import {
3
3
  computedGetImageStyle,
4
+ computedGetAlignCenter,
4
5
  computedGetPreview,
5
6
  loadImage,
6
7
  handleLoad,
@@ -8,6 +9,7 @@ import {
8
9
  handleLazyLoad,
9
10
  addLazyLoadListener,
10
11
  removeLazyLoadListener,
12
+ getImageStyle,
11
13
  clickHandler,
12
14
  closeViewer,
13
15
  mounted,
@@ -43,7 +45,8 @@ const initState = ({
43
45
  show: !props.lazy,
44
46
  showViewer: false,
45
47
  getPreview: computed(() => api2.computedGetPreview()),
46
- getImageStyle: computed(() => api2.computedGetImageStyle())
48
+ getImageStyle: computed(() => api2.computedGetImageStyle()),
49
+ getAlignCenter: computed(() => api2.computedGetAlignCenter())
47
50
  });
48
51
  return state;
49
52
  };
@@ -65,10 +68,12 @@ const initApi = ({
65
68
  handleError: handleError({ state, emit }),
66
69
  computedGetPreview: computedGetPreview(props),
67
70
  removeLazyLoadListener: removeLazyLoadListener(state),
71
+ getImageStyle: getImageStyle({ state, vm, constants }),
72
+ computedGetAlignCenter: computedGetAlignCenter({ props, constants }),
68
73
  mounted: mounted({ api: api2, props }),
69
74
  handleLazyLoad: handleLazyLoad({ api: api2, state, vm, nextTick }),
70
75
  loadImage: loadImage({ api: api2, state, props, attrs }),
71
- computedGetImageStyle: computedGetImageStyle({ props }),
76
+ computedGetImageStyle: computedGetImageStyle({ api: api2, props }),
72
77
  addLazyLoadListener: addLazyLoadListener({ api: api2, props, state, vm }),
73
78
  deleteHander: deleteHander(emit)
74
79
  });