@opentiny/vue-renderless 3.18.5 → 3.19.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 (122) hide show
  1. package/action-menu/index.js +2 -2
  2. package/action-menu/vue.js +2 -2
  3. package/anchor/index.js +8 -6
  4. package/anchor/vue.js +1 -1
  5. package/badge/index.js +4 -3
  6. package/base-select/index.js +3 -3
  7. package/breadcrumb-item/vue.js +1 -1
  8. package/bulletin-board/index.js +1 -1
  9. package/button/index.js +1 -1
  10. package/button-group/index.js +6 -1
  11. package/carousel-item/index.js +1 -1
  12. package/cascader/vue.js +17 -4
  13. package/chart-core/deps/utils.js +1 -1
  14. package/checkbox/index.js +1 -1
  15. package/common/deps/dom.js +9 -1
  16. package/common/deps/useWindowSize.js +23 -0
  17. package/common/deps/vue-popper.js +1 -1
  18. package/common/index.js +2 -2
  19. package/common/prop-util.js +43 -0
  20. package/common/runtime.js +1 -1
  21. package/crop/index.js +14 -22
  22. package/crop/vue.js +33 -29
  23. package/date-panel/index.js +13 -2
  24. package/date-panel/vue.js +16 -10
  25. package/dialog-select/index.js +78 -0
  26. package/dialog-select/vue.js +28 -6
  27. package/drawer/index.js +14 -1
  28. package/drawer/vue.js +4 -3
  29. package/dropdown-item/index.js +2 -2
  30. package/dropdown-item/vue.js +9 -6
  31. package/espace/index.js +1 -1
  32. package/fall-menu/index.js +5 -1
  33. package/fall-menu/vue.js +15 -2
  34. package/filter-box/vue.js +5 -2
  35. package/floatbar/index.js +1 -1
  36. package/fluent-editor/options.js +26 -24
  37. package/form/index.js +7 -4
  38. package/form/vue.js +1 -1
  39. package/grid/plugins/export.js +1 -1
  40. package/grid/utils/dom.js +3 -1
  41. package/guide/index.js +17 -2
  42. package/guide/vue.js +5 -3
  43. package/image-viewer/vue.js +1 -1
  44. package/input/index.js +6 -7
  45. package/input/vue.js +10 -11
  46. package/ip-address/index.js +0 -10
  47. package/ip-address/vue.js +2 -5
  48. package/load-list/index.js +43 -0
  49. package/load-list/vue.js +69 -0
  50. package/locales/index.js +1 -5
  51. package/logout/index.js +1 -1
  52. package/milestone/index.js +55 -8
  53. package/milestone/vue.js +16 -3
  54. package/modal/index.js +6 -6
  55. package/modal/vue.js +4 -3
  56. package/nav-menu/index.js +1 -1
  57. package/package.json +1 -1
  58. package/pager/index.js +25 -0
  59. package/pager/vue.js +18 -4
  60. package/picker/index.js +3 -3
  61. package/picker/vue.js +1 -1
  62. package/popeditor/index.js +12 -1
  63. package/popeditor/vue.js +9 -5
  64. package/rich-text/table-module.js +4 -3
  65. package/roles/index.js +1 -1
  66. package/select/index.js +6 -6
  67. package/select/vue.js +2 -1
  68. package/selected-box/vue.js +2 -1
  69. package/slider/index.js +2 -2
  70. package/slider-button-group/vue.js +3 -2
  71. package/split/vue.js +4 -2
  72. package/sticky/index.js +89 -0
  73. package/sticky/vue.js +74 -0
  74. package/tabbar-item/vue.js +1 -1
  75. package/tall-storage/index.js +1 -1
  76. package/time/vue.js +2 -1
  77. package/time-range/vue.js +4 -1
  78. package/time-spinner/index.js +4 -1
  79. package/toggle-menu/index.js +1 -1
  80. package/transfer-panel/vue.js +7 -6
  81. package/tree/index.js +17 -7
  82. package/tree/vue.js +10 -6
  83. package/tree-node/index.js +2 -2
  84. package/tree-node/vue.js +6 -2
  85. package/types/action-menu.type.d.ts +1 -1
  86. package/types/alert.type.d.ts +2 -0
  87. package/types/anchor.type.d.ts +5 -1
  88. package/types/badge.type.d.ts +1 -1
  89. package/types/button-group.type.d.ts +3 -0
  90. package/types/button.type.d.ts +1 -1
  91. package/types/date-picker.type.d.ts +3 -0
  92. package/types/drawer.type.d.ts +5 -1
  93. package/types/{dropdown-item.type-16d59fd0.d.ts → dropdown-item.type-c9badbc1.d.ts} +2 -2
  94. package/types/dropdown-item.type.d.ts +1 -1
  95. package/types/dropdown-menu.type.d.ts +1 -1
  96. package/types/fall-menu.type.d.ts +1 -0
  97. package/types/file-upload.type.d.ts +1 -1
  98. package/types/image.type.d.ts +4 -0
  99. package/types/input.type.d.ts +8 -4
  100. package/types/load-list.type.d.ts +58 -0
  101. package/types/milestone.type.d.ts +27 -1
  102. package/types/modal.type.d.ts +3 -2
  103. package/types/pager.type.d.ts +5 -1
  104. package/types/picker.type.d.ts +3 -0
  105. package/types/popover.type.d.ts +1 -1
  106. package/types/search.type.d.ts +0 -3
  107. package/types/steps.type.d.ts +1 -0
  108. package/types/tag.type.d.ts +1 -0
  109. package/types/tooltip.type.d.ts +3 -0
  110. package/types/transfer.type.d.ts +3 -3
  111. package/types/tree-menu.type.d.ts +8 -0
  112. package/types/upload-dragger.type.d.ts +1 -1
  113. package/types/{upload-list.type-4194f534.d.ts → upload-list.type-26173587.d.ts} +11 -3
  114. package/types/upload-list.type.d.ts +1 -1
  115. package/types/upload.type.d.ts +1 -1
  116. package/types/user-contact.type.d.ts +127 -1
  117. package/types/user-head.type.d.ts +1 -4
  118. package/upload-list/vue.js +7 -7
  119. package/virtual-scroll-box/index.js +294 -0
  120. package/virtual-scroll-box/vue.js +43 -0
  121. package/virtual-tree/index.js +168 -0
  122. package/virtual-tree/vue.js +53 -0
@@ -9,14 +9,14 @@ const computedMaxShowNum = ({ props, state }) => () => {
9
9
  return 2;
10
10
  }
11
11
  };
12
- const computedSpacing = ({ props, state }) => () => {
12
+ const computedSpacing = ({ props, state, designConfig }) => () => {
13
13
  if (props.spacing !== void 0) {
14
14
  return String(props.spacing).includes("px") ? props.spacing : props.spacing + "px";
15
15
  }
16
16
  if (state.isCardMode) {
17
17
  return "10px";
18
18
  } else {
19
- return "5px";
19
+ return (designConfig == null ? void 0 : designConfig.props.spacing) || "8px";
20
20
  }
21
21
  };
22
22
  const computedMoreText = ({ props, state, t }) => () => {
@@ -9,7 +9,7 @@ import {
9
9
  computedSuffixIcon
10
10
  } from "./index";
11
11
  const api = ["state", "handleMoreClick", "handleItemClick", "visibleChange"];
12
- const renderless = (props, { computed, reactive }, { emit, t }) => {
12
+ const renderless = (props, { computed, reactive }, { emit, t, designConfig }) => {
13
13
  const api2 = {};
14
14
  const state = reactive({
15
15
  visibleOptions: computed(() => props.options.slice(0, state.maxShowNum)),
@@ -26,7 +26,7 @@ const renderless = (props, { computed, reactive }, { emit, t }) => {
26
26
  handleItemClick: handleItemClick(emit),
27
27
  visibleChange: visibleChange(emit),
28
28
  computedMaxShowNum: computedMaxShowNum({ props, state }),
29
- computedSpacing: computedSpacing({ props, state }),
29
+ computedSpacing: computedSpacing({ props, state, designConfig }),
30
30
  computedMoreText: computedMoreText({ props, state, t }),
31
31
  computedSuffixIcon: computedSuffixIcon({ props, state })
32
32
  });
package/anchor/index.js CHANGED
@@ -94,7 +94,7 @@ const setChildOffsetTop = ({ state, props }) => {
94
94
  if (!((_a = props.links) == null ? void 0 : _a.length)) {
95
95
  return;
96
96
  }
97
- state.offsetTop = ((_b = document.querySelector(props.links[0].link)) == null ? void 0 : _b.offsetTop) || 0;
97
+ state.childOffsetTop = ((_b = document.querySelector(props.links[0].link)) == null ? void 0 : _b.offsetTop) || 0;
98
98
  };
99
99
  const getContainer = ({ props }) => () => props.containerId && document.querySelector(props.containerId) || document.body;
100
100
  const mounted = ({ state, api, props, nextTick }) => () => {
@@ -118,12 +118,14 @@ const unmounted = ({ state, api }) => () => {
118
118
  }
119
119
  };
120
120
  const onItersectionObserver = ({ state, props, api, vm, emit }) => () => {
121
- const { expandLink, scrollContainer } = state;
121
+ const { expandLink, scrollContainer, childOffsetTop } = state;
122
+ const { offsetTop } = props;
122
123
  state.currentLink && updateSkidPosition({ vm, state, emit });
124
+ const rootMargin = offsetTop ? `${-offsetTop}px 0px 0px 0px` : "";
123
125
  state.intersectionObserver = new IntersectionObserver(
124
126
  (entries) => {
125
127
  const { top } = scrollContainer.getBoundingClientRect();
126
- const scrollStartTop = top + state.offsetTop;
128
+ const scrollStartTop = top + childOffsetTop + offsetTop;
127
129
  entries.forEach((item) => {
128
130
  const key = item.target.id;
129
131
  state.observerLinks[key] = item;
@@ -141,7 +143,7 @@ const onItersectionObserver = ({ state, props, api, vm, emit }) => () => {
141
143
  for (let key in state.observerLinks) {
142
144
  if (Object.prototype.hasOwnProperty.call(state.observerLinks, key)) {
143
145
  const item = state.observerLinks[key];
144
- if (item.isIntersecting && item.intersectionRatio >= 0 && item.target.getBoundingClientRect().top < scrollStartTop) {
146
+ if (item.isIntersecting && item.intersectionRatio >= 0 && item.target.getBoundingClientRect().top <= scrollStartTop) {
145
147
  const link = `#${item.target.id}`;
146
148
  if (!expandLink[link].children) {
147
149
  api.getCurrentAnchor(link);
@@ -153,7 +155,7 @@ const onItersectionObserver = ({ state, props, api, vm, emit }) => () => {
153
155
  }
154
156
  }
155
157
  },
156
- { root: scrollContainer, threshold: [0, 0.25, 0.5, 1] }
158
+ { root: scrollContainer, threshold: [0, 0.25, 0.5, 1], rootMargin }
157
159
  );
158
160
  addObserver({ props, state });
159
161
  };
@@ -169,7 +171,7 @@ const linkClick = ({ state, vm, emit, props, api }) => (e, item) => {
169
171
  setMarkClass({ state, props });
170
172
  if (scrollContainer && scrollContainer !== document.body && !isChangeHash) {
171
173
  const linkEl = scrollContainer.querySelector(item.link);
172
- const top = (linkEl == null ? void 0 : linkEl.offsetTop) - scrollContainer.offsetTop;
174
+ const top = (linkEl == null ? void 0 : linkEl.getBoundingClientRect().top) - scrollContainer.getBoundingClientRect().top + scrollContainer.scrollTop - props.offsetTop;
173
175
  const param = { top, left: 0, behavior: "smooth" };
174
176
  scrollContainer == null ? void 0 : scrollContainer.scrollTo(param);
175
177
  scrollContainer == null ? void 0 : scrollContainer.addEventListener("scroll", api.handleScroll());
package/anchor/vue.js CHANGED
@@ -30,7 +30,7 @@ const renderless = (props, { onMounted, onUnmounted, onUpdated, reactive, watch
30
30
  currentHash: "",
31
31
  isScroll: false,
32
32
  scrollTimer: 0,
33
- offsetTop: 0
33
+ childOffsetTop: 0
34
34
  });
35
35
  Object.assign(api2, {
36
36
  state,
package/badge/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import "../chunk-G2ADBYYC.js";
2
- const computedContent = ({ props, state }) => () => typeof state.valueRef === "number" && typeof props.max === "number" ? props.max < state.valueRef ? `${props.max}+` : state.valueRef : state.valueRef;
2
+ const computedContent = ({ props, state }) => () => (typeof props.value === "number" || typeof props.value === "string") && typeof props.max === "number" ? props.max < Number(state.valueRef) ? `${props.max}+` : state.valueRef : state.valueRef;
3
3
  const computedValueRef = ({ props }) => () => {
4
- if (typeof props.value === "number") {
4
+ if (typeof props.value === "number" || typeof props.value === "string") {
5
5
  return props.value;
6
+ } else {
7
+ return void 0;
6
8
  }
7
- return typeof props.modelValue === "number" ? props.modelValue : void 0;
8
9
  };
9
10
  const computedTransform = ({ designConfig, props }) => () => {
10
11
  if ((designConfig == null ? void 0 : designConfig.transform) === "unset") {
@@ -420,7 +420,7 @@ const resetInputHeight = ({ constants, nextTick, props, vm, state, api, designCo
420
420
  if (!state.isDisplayOnly && (props.hoverExpand || props.clickExpand) && !props.disabled) {
421
421
  api.calcCollapseTags();
422
422
  }
423
- const sizeInMap = (designConfig == null ? void 0 : designConfig.state.initialInputHeight) || state.initialInputHeight || (state.isSaaSTheme ? 28 : 30);
423
+ const sizeInMap = (designConfig == null ? void 0 : designConfig.state.initialInputHeight) || state.initialInputHeight || 32;
424
424
  const noSelected = state.selected.length === 0;
425
425
  const spacingHeight = designConfig ? (_a = designConfig.state) == null ? void 0 : _a.spacingHeight : constants.SPACING_HEIGHT;
426
426
  if (!state.isDisplayOnly) {
@@ -1198,7 +1198,7 @@ const mounted = ({ api, parent, state, props, vm, designConfig }) => () => {
1198
1198
  document.activeElement.blur();
1199
1199
  }
1200
1200
  state.completed = true;
1201
- const defaultSizeMap = { default: 28, mini: 24, small: 32, medium: 40 };
1201
+ const defaultSizeMap = { default: 32, mini: 24, small: 36, medium: 40 };
1202
1202
  const sizeMap = ((_a = designConfig == null ? void 0 : designConfig.state) == null ? void 0 : _a.sizeMap) || defaultSizeMap;
1203
1203
  if (props.multiple && Array.isArray(props.modelValue) && props.modelValue.length > 0) {
1204
1204
  state.currentPlaceholder = "";
@@ -1249,7 +1249,7 @@ const optmzApis = {
1249
1249
  vm.$refs.scrollbar.$el.querySelectorAll(
1250
1250
  '.tiny-recycle-scroller__slot, .tiny-recycle-scroller__item-view:not([style*="transform: translateY(-9999px) translateX(0px)"])'
1251
1251
  )
1252
- ).map((item) => item.querySelector(`[data-tag="tiny-select-dropdown-item"]:not(${querySelectKey})`)).filter((v) => v);
1252
+ ).map((item) => item.querySelector(`[data-tag="tiny-option"]:not(${querySelectKey})`)).filter((v) => v);
1253
1253
  },
1254
1254
  setScrollTop: ({ refs, state }) => {
1255
1255
  const { optimizeStore } = state;
@@ -7,7 +7,7 @@ const renderless = (props, { reactive, inject, computed }, { refs, router, emit,
7
7
  const constants = breadcrumb._constants;
8
8
  const state = reactive({
9
9
  size: inject("size", null),
10
- separator: computed(() => breadcrumb.separator || (designConfig == null ? void 0 : designConfig.separator) || ">")
10
+ separator: computed(() => breadcrumb.separator || (designConfig == null ? void 0 : designConfig.separator) || "/")
11
11
  });
12
12
  const api2 = {
13
13
  state,
@@ -1,5 +1,5 @@
1
1
  import "../chunk-G2ADBYYC.js";
2
- import { xss } from "../common/xss.js";
2
+ import { xss } from "../common/xss";
3
3
  const getRoute = (route) => `/${route || ""}`.replace(/^\/+/, "/");
4
4
  const computedDataList = ({ props, state }) => () => {
5
5
  const list = props.data[Number(state.actName) - 1] || [];
package/button/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "../chunk-G2ADBYYC.js";
2
- import { xss } from "../common";
2
+ import { xss } from "../common/xss";
3
3
  const handleClick = ({ emit, props, state }) => (event) => {
4
4
  const urlHref = xss.filterUrl(props.href);
5
5
  if (urlHref) {
@@ -23,7 +23,12 @@ const getItemClass = ({ props, state }) => (node) => {
23
23
  if (state.disabled || node.disabled) {
24
24
  return { disabled: true };
25
25
  }
26
- return props.plain ? { plain: props.plain } : {};
26
+ return props.plain ? {
27
+ plain: props.plain,
28
+ medium: props.size === "medium",
29
+ small: props.size === "small",
30
+ mini: props.size === "mini"
31
+ } : {};
27
32
  };
28
33
  export {
29
34
  getItemClass,
@@ -46,7 +46,7 @@ const translateItem = ({ api, CARD_SCALE, parent, state, carouselParent }) => ({
46
46
  } else {
47
47
  state.active = index === activeIndex;
48
48
  if (length === 2 && !state.active) {
49
- state.translate = vnode.type === TYPE_VERTICAL ? -parentHeight : -parentWidth;
49
+ state.translate = vnode.type === TYPE_VERTICAL ? parentHeight : parentWidth;
50
50
  } else {
51
51
  state.translate = vnode.type === TYPE_VERTICAL ? parentHeight * (index - activeIndex) : parentWidth * (index - activeIndex);
52
52
  }
package/cascader/vue.js CHANGED
@@ -68,7 +68,8 @@ const initState = ({
68
68
  t,
69
69
  constants,
70
70
  vm,
71
- inject
71
+ inject,
72
+ designConfig
72
73
  }) => {
73
74
  const state = reactive({
74
75
  showAutoWidth: inject("showAutoWidth", null),
@@ -102,7 +103,8 @@ const initState = ({
102
103
  collapseTagsLength: 0,
103
104
  isHidden: false,
104
105
  tooltipVisible: false,
105
- tooltipContent: ""
106
+ tooltipContent: "",
107
+ tagTypeWhenMultiple: (designConfig == null ? void 0 : designConfig.tagTypeWhenMultiple) || ""
106
108
  });
107
109
  return state;
108
110
  };
@@ -206,7 +208,7 @@ const renderless = (props, {
206
208
  toRefs,
207
209
  watch,
208
210
  inject
209
- }, { t, emit, nextTick, constants, parent, slots, dispatch, vm }) => {
211
+ }, { t, emit, nextTick, constants, parent, slots, dispatch, vm, designConfig }) => {
210
212
  parent.tinyForm = parent.tinyForm || inject("form", null);
211
213
  const { updatePopper } = userPopper({
212
214
  reactive,
@@ -228,7 +230,18 @@ const renderless = (props, {
228
230
  onDeactivated
229
231
  });
230
232
  const api2 = {};
231
- const state = initState({ reactive, props, computed, parent, api: api2, t, constants, vm, inject });
233
+ const state = initState({
234
+ reactive,
235
+ props,
236
+ computed,
237
+ parent,
238
+ api: api2,
239
+ t,
240
+ constants,
241
+ vm,
242
+ inject,
243
+ designConfig
244
+ });
232
245
  initApi({ api: api2, state, constants, dispatch, emit, vm, props, updatePopper, nextTick, parent, t });
233
246
  initWatch({ watch, state, api: api2, props, nextTick, updatePopper });
234
247
  onBeforeUpdate(api2.handleBeforeUpdate);
@@ -7,7 +7,7 @@ import { isObject, typeOf as getType, isNull } from "../../common/type";
7
7
  import _debounce from "../../common/deps/debounce";
8
8
  import _numerify from "./numerify";
9
9
  import { escapeHtml } from "../../common/string";
10
- import { xss } from "../../common";
10
+ import { xss } from "../../common/xss";
11
11
  import { setObj, getObj, isEqual } from "../../common/object";
12
12
  import { typeOf, isObject as isObject2 } from "../../common/type";
13
13
  const debounce = (callback, delay) => _debounce(delay, false, callback);
package/checkbox/index.js CHANGED
@@ -111,7 +111,7 @@ const computedIsGroupDisplayOnly = ({ state }) => () => state.isGroup && (state.
111
111
  const computedDisplayLabel = ({ state, props, t }) => () => {
112
112
  state.showLabel = true;
113
113
  if (props.trueLabel !== void 0 && props.falseLabel !== void 0) {
114
- return props.modelValue ? String(props.trueLabel) : String(props.falseLabel);
114
+ return props.modelValue;
115
115
  } else {
116
116
  return props.modelValue ? t("yes") : t("no");
117
117
  }
@@ -170,6 +170,13 @@ const getScrollParent = (el, root = defaultRoot) => {
170
170
  }
171
171
  return root;
172
172
  };
173
+ const useScrollParent = ({ onMounted, ref, watch }) => (elRef, root = defaultRoot) => {
174
+ const scrollParent = ref();
175
+ const setScrollParent = () => scrollParent.value = getScrollParent(elRef.value, root);
176
+ watch(elRef, setScrollParent);
177
+ onMounted(() => elRef.value && setScrollParent());
178
+ return scrollParent;
179
+ };
173
180
  const isDisplayNone = (elm) => {
174
181
  if (isServer)
175
182
  return false;
@@ -205,5 +212,6 @@ export {
205
212
  preventDefault,
206
213
  removeClass,
207
214
  setStyle,
208
- stopPropagation
215
+ stopPropagation,
216
+ useScrollParent
209
217
  };
@@ -0,0 +1,23 @@
1
+ import "../../chunk-G2ADBYYC.js";
2
+ import { on, isServer } from "./dom";
3
+ let width;
4
+ let height;
5
+ const useWindowSize = (ref) => () => {
6
+ if (!width) {
7
+ width = ref(0);
8
+ height = ref(0);
9
+ if (!isServer) {
10
+ const update = () => {
11
+ width.value = window.innerWidth;
12
+ height.value = window.innerHeight;
13
+ };
14
+ update();
15
+ on(window, "resize", update, { passive: true });
16
+ on(window, "orientationchange", update, { passive: true });
17
+ }
18
+ }
19
+ return { width, height };
20
+ };
21
+ export {
22
+ useWindowSize
23
+ };
@@ -138,7 +138,7 @@ var vue_popper_default = (options) => {
138
138
  };
139
139
  const destroyPopper = (remove) => {
140
140
  if (remove) {
141
- if (state.popperElm) {
141
+ if (state.popperElm && state.popperElm.parentNode === document.body) {
142
142
  off(state.popperElm, "click", stop);
143
143
  state.popperElm.remove();
144
144
  }
package/common/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "../chunk-G2ADBYYC.js";
2
- import { log as uLog, xss } from "./xss.js";
2
+ import { log as uLog, xss } from "./xss";
3
3
  const KEY_CODE = {
4
4
  Backspace: 8,
5
5
  Tab: 9,
@@ -237,7 +237,7 @@ const CASCADER = {
237
237
  PropsHover: "hoverThreshold",
238
238
  MenuConnector: "cascader-menu-"
239
239
  };
240
- const version = "3.18.5";
240
+ const version = "3.19.0";
241
241
  const log = (data, type = "log") => {
242
242
  uLog.logger[type](data);
243
243
  };
@@ -0,0 +1,43 @@
1
+ import "../chunk-G2ADBYYC.js";
2
+ const unknownProp = null;
3
+ const numericProp = [Number, String];
4
+ const truthProp = {
5
+ type: Boolean,
6
+ default: true
7
+ };
8
+ const makeRequiredProp = (type) => ({
9
+ type,
10
+ required: true
11
+ });
12
+ const makeArrayProp = () => ({
13
+ type: Array,
14
+ default: () => []
15
+ });
16
+ const makeNumberProp = (defaultVal) => ({
17
+ type: Number,
18
+ default: defaultVal
19
+ });
20
+ const makeNumericProp = (defaultVal) => ({
21
+ type: numericProp,
22
+ default: defaultVal
23
+ });
24
+ const makeStringProp = (defaultVal) => ({
25
+ type: String,
26
+ default: defaultVal
27
+ });
28
+ const makeStringValidProp = (defaultVal, optionals = []) => ({
29
+ type: String,
30
+ default: defaultVal,
31
+ validator: (val) => optionals.includes(val)
32
+ });
33
+ export {
34
+ makeArrayProp,
35
+ makeNumberProp,
36
+ makeNumericProp,
37
+ makeRequiredProp,
38
+ makeStringProp,
39
+ makeStringValidProp,
40
+ numericProp,
41
+ truthProp,
42
+ unknownProp
43
+ };
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.18.5";
25
+ const version = "3.19.0";
26
26
  const Renderless = {
27
27
  browser,
28
28
  array,
package/crop/index.js CHANGED
@@ -1,9 +1,7 @@
1
1
  import "../chunk-G2ADBYYC.js";
2
2
  import { on, off } from "../common/deps/dom";
3
3
  import { toFileSize } from "../common/string";
4
- const computedCropImages = ({ constants, t }) => () => t(constants.CROP_IMAGE);
5
4
  const watchImageSrc = (state) => (value) => state.src = value;
6
- const watchAlt = (state) => (value) => state.alt = value || "image";
7
5
  const watchVisible = ({ api, state }) => (value) => {
8
6
  if (value) {
9
7
  on(document.body, "keydown", api.shortcutKeys);
@@ -13,35 +11,38 @@ const watchVisible = ({ api, state }) => (value) => {
13
11
  state.cropvisible = value;
14
12
  };
15
13
  const shortcutKeys = (api) => (e) => {
16
- if (e.keyCode == 187 && e.ctrlKey) {
14
+ if (e.keyCode === 187 && e.ctrlKey) {
17
15
  e.preventDefault();
18
16
  api.zoom(0.1);
19
17
  }
20
- if (e.keyCode == 189 && e.ctrlKey) {
18
+ if (e.keyCode === 189 && e.ctrlKey) {
21
19
  e.preventDefault();
22
20
  api.zoom(-0.1);
23
21
  }
24
- if (e.keyCode == 38 && e.ctrlKey) {
22
+ if (e.keyCode === 38 && e.ctrlKey) {
25
23
  e.preventDefault();
26
24
  api.move(0, 1);
27
25
  }
28
- if (e.keyCode == 40 && e.ctrlKey) {
26
+ if (e.keyCode === 40 && e.ctrlKey) {
29
27
  e.preventDefault();
30
28
  api.move(0, -1);
31
29
  }
32
- if (e.keyCode == 37 && e.ctrlKey) {
30
+ if (e.keyCode === 37 && e.ctrlKey) {
33
31
  e.preventDefault();
34
32
  api.move(1, 0);
35
33
  }
36
- if (e.keyCode == 39 && e.ctrlKey) {
34
+ if (e.keyCode === 39 && e.ctrlKey) {
37
35
  e.preventDefault();
38
36
  api.move(-1, 0);
39
37
  }
38
+ if (e.keyCode === 27) {
39
+ e.preventDefault();
40
+ api.closeCrop();
41
+ }
40
42
  };
41
43
  const closeCrop = ({ emit, state }) => () => {
42
44
  emit("update:cropvisible", false);
43
45
  emit("update:visible", false);
44
- state.cropImg = "";
45
46
  };
46
47
  const createCrop = ({ emit, props, refs, state }) => () => {
47
48
  const Cropper = props.plugin;
@@ -67,7 +68,6 @@ const createCrop = ({ emit, props, refs, state }) => () => {
67
68
  minCropBoxHeight: props.minCropBoxHeight,
68
69
  minContainerWidth: props.minContainerWidth,
69
70
  minContainerHeight: props.minContainerHeight,
70
- preview: document.querySelectorAll(".croppreview"),
71
71
  ready() {
72
72
  emit("ready");
73
73
  },
@@ -88,19 +88,13 @@ const createCrop = ({ emit, props, refs, state }) => () => {
88
88
  const closeCropArea = (api) => () => api.clear();
89
89
  const clear = (state) => () => state.cropper.clear();
90
90
  const cropImage = ({ api, emit, props, state }) => () => {
91
- state.cropImg = api.getCroppedCanvas().toDataURL("image/jpeg", props.quality);
91
+ const canvas = api.getCroppedCanvas();
92
92
  if (props.cropType.toLowerCase() === "base64") {
93
- emit("cropdata", api.getCroppedCanvas().toDataURL("image/jpeg", props.quality));
93
+ emit("cropdata", canvas.toDataURL("image/jpeg", props.quality));
94
94
  } else if (props.cropType.toLowerCase() === "blob") {
95
- let canvas = api.getCroppedCanvas();
96
- canvas.toBlob(
97
- (blobObj) => {
98
- emit("cropdata", blobObj);
99
- },
100
- "image/jpeg",
101
- props.quality
102
- );
95
+ canvas.toBlob((blobObj) => emit("cropdata", blobObj), "image/jpeg", props.quality);
103
96
  }
97
+ api.closeCrop();
104
98
  };
105
99
  const getCroppedCanvas = (state) => () => state.cropper.getCroppedCanvas();
106
100
  const getCropBoxData = (state) => () => state.cropper.getCropBoxData();
@@ -144,7 +138,6 @@ export {
144
138
  clear,
145
139
  closeCrop,
146
140
  closeCropArea,
147
- computedCropImages,
148
141
  createCrop,
149
142
  cropImage,
150
143
  destroy,
@@ -171,7 +164,6 @@ export {
171
164
  setImage,
172
165
  shortcutKeys,
173
166
  showFileChooser,
174
- watchAlt,
175
167
  watchImageSrc,
176
168
  watchVisible,
177
169
  zoom
package/crop/vue.js CHANGED
@@ -5,8 +5,6 @@ import {
5
5
  watchVisible,
6
6
  clear,
7
7
  replace,
8
- computedCropImages,
9
- watchAlt,
10
8
  getCroppedCanvas,
11
9
  setCanvasData,
12
10
  setDragMode,
@@ -66,62 +64,70 @@ const api = [
66
64
  "cropImage",
67
65
  "zoom"
68
66
  ];
69
- const initRenderIcon = (api2) => {
67
+ const initRenderIcon = (api2, t) => {
70
68
  const renderIcon = [
71
69
  {
72
70
  method: () => api2.showFileChooser(),
73
- icon: "IconNew"
71
+ icon: "IconNew",
72
+ title: t("ui.crop.choose")
74
73
  },
74
+ { split: true },
75
75
  {
76
- method: () => api2.zoom(0.1),
77
- icon: "IconZoomIn"
76
+ method: () => api2.zoom(-0.1),
77
+ icon: "IconZoomOut",
78
+ title: t("ui.crop.zoomOut")
78
79
  },
79
80
  {
80
- method: () => api2.zoom(-0.1),
81
- icon: "IconZoomOut"
81
+ method: () => api2.zoom(0.1),
82
+ icon: "IconZoomIn",
83
+ title: t("ui.crop.zoomIn")
82
84
  },
83
85
  {
84
86
  method: () => api2.rotate(-45),
85
- icon: "IconRepeat"
87
+ icon: "IconRepeat",
88
+ title: t("ui.crop.rotate_45")
86
89
  },
87
90
  {
88
91
  method: () => api2.rotate(45),
89
- icon: "IconRefres"
92
+ icon: "IconRefres",
93
+ title: t("ui.crop.rotate45")
90
94
  },
95
+ { split: true },
91
96
  {
92
97
  method: () => api2.closeCropArea(),
93
- icon: "IconCrop"
98
+ icon: "IconCrop",
99
+ title: t("ui.crop.closeCropArea")
94
100
  },
95
101
  {
96
102
  method: () => api2.reset(),
97
- icon: "IconConmentRefresh"
103
+ icon: "IconConmentRefresh",
104
+ title: t("ui.crop.reset")
98
105
  },
106
+ { split: true },
99
107
  {
100
- method: () => api2.cropImage(),
101
- icon: "IconYes"
108
+ method: () => api2.closeCrop(),
109
+ icon: "IconClose",
110
+ title: t("ui.crop.closeCrop")
102
111
  },
103
112
  {
104
- method: () => api2.closeCrop(),
105
- icon: "IconClose"
113
+ method: () => api2.cropImage(),
114
+ icon: "IconYes",
115
+ title: t("ui.crop.cropImage")
106
116
  }
107
117
  ];
108
118
  return renderIcon;
109
119
  };
110
- const initState = ({ reactive, props, computed, api: api2 }) => {
120
+ const initState = ({ reactive, props, api: api2, t }) => {
111
121
  const state = reactive({
112
122
  src: props.src,
113
- cropImg: "",
114
123
  cropper: "",
115
- alt: props.alt,
116
124
  data: null,
117
125
  cropvisible: props.cropvisible,
118
- renderIcon: initRenderIcon(api2),
119
- previewShow: props.previewShow,
120
- cropImages: computed(() => api2.computedCropImages())
126
+ renderIcon: initRenderIcon(api2, t)
121
127
  });
122
128
  return state;
123
129
  };
124
- const initApi = ({ api: api2, state, emit, refs, props, constants, t }) => {
130
+ const initApi = ({ api: api2, state, emit, refs, props }) => {
125
131
  Object.assign(api2, {
126
132
  state,
127
133
  zoom: zoom(state),
@@ -138,7 +144,6 @@ const initApi = ({ api: api2, state, emit, refs, props, constants, t }) => {
138
144
  getData: getData(state),
139
145
  disable: disable(state),
140
146
  destroy: destroy(state),
141
- watchAlt: watchAlt(state),
142
147
  setDragMode: setDragMode(state),
143
148
  getImageData: getImageData(state),
144
149
  watchImageSrc: watchImageSrc(state),
@@ -152,7 +157,7 @@ const initApi = ({ api: api2, state, emit, refs, props, constants, t }) => {
152
157
  getCroppedCanvas: getCroppedCanvas(state),
153
158
  getContainerData: getContainerData(state),
154
159
  createCrop: createCrop({ emit, props, refs, state }),
155
- computedCropImages: computedCropImages({ constants, t }),
160
+ // computedCropImages: computedCropImages({ constants, t }),
156
161
  shortcutKeys: shortcutKeys(api2),
157
162
  closeCropArea: closeCropArea(api2),
158
163
  setImage: setImage({ api: api2, state, props }),
@@ -163,12 +168,11 @@ const initApi = ({ api: api2, state, emit, refs, props, constants, t }) => {
163
168
  const initWatch = ({ watch, props, api: api2 }) => {
164
169
  watch(() => props.cropvisible, api2.watchVisible);
165
170
  watch(() => props.src, api2.watchImageSrc, { immediate: true });
166
- watch(() => props.alt, api2.watchAlt, { immediate: true });
167
171
  };
168
- const renderless = (props, { computed, onMounted, reactive, watch }, { t, emit, refs, constants }) => {
172
+ const renderless = (props, { onMounted, reactive, watch }, { emit, refs, t }) => {
169
173
  const api2 = {};
170
- const state = initState({ reactive, props, computed, api: api2 });
171
- initApi({ api: api2, state, emit, refs, props, constants, t });
174
+ const state = initState({ reactive, props, api: api2, t });
175
+ initApi({ api: api2, state, emit, refs, props });
172
176
  onMounted(api2.createCrop);
173
177
  initWatch({ watch, props, api: api2 });
174
178
  return api2;
@@ -219,8 +219,18 @@ const dateToLocaleStringForIE = (timezone, value) => {
219
219
  const offsetTime = new Date(value).getTime() + offsetTimezone * 36e5;
220
220
  return new Date(offsetTime);
221
221
  };
222
- const changeToNow = ({ api, state }) => () => {
223
- const now = /* @__PURE__ */ new Date();
222
+ const getNowTime = ({ props }) => () => {
223
+ return new Promise((resolve) => {
224
+ resolve(props.nowClick());
225
+ }).then((res) => {
226
+ return res;
227
+ });
228
+ };
229
+ const changeToNow = ({ api, state, props }) => async () => {
230
+ let now = /* @__PURE__ */ new Date();
231
+ if (props.nowClick !== void 0) {
232
+ now = await api.getNowTime();
233
+ }
224
234
  const timezone = state.timezone;
225
235
  const isServiceTimezone = timezone.isServiceTimezone;
226
236
  let disabledDate = !state.disabledDate;
@@ -442,6 +452,7 @@ export {
442
452
  getDefaultValue,
443
453
  getDisabledConfirm,
444
454
  getDisabledNow,
455
+ getNowTime,
445
456
  getRenderTz,
446
457
  getYearLabel,
447
458
  handleClear,