@uzum-tech/ui 2.0.6 → 2.0.7

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 (48) hide show
  1. package/dist/index.js +145 -81
  2. package/dist/index.mjs +145 -81
  3. package/dist/index.prod.js +2 -2
  4. package/dist/index.prod.mjs +2 -2
  5. package/es/_internal/icons/index.d.ts +0 -1
  6. package/es/_internal/icons/index.mjs +0 -1
  7. package/es/components.d.ts +67 -30
  8. package/es/tree/src/Tree.d.ts +49 -24
  9. package/es/tree/src/Tree.mjs +18 -13
  10. package/es/tree/src/TreeNodeCheckbox.d.ts +4 -0
  11. package/es/tree/src/TreeNodeSwitcher.mjs +24 -26
  12. package/es/tree/src/styles/index.cssr.mjs +11 -8
  13. package/es/tree/styles/light.d.ts +4 -0
  14. package/es/tree/styles/light.mjs +2 -0
  15. package/es/tree-select/index.d.ts +1 -1
  16. package/es/tree-select/src/TreeSelect.d.ts +43 -16
  17. package/es/tree-select/src/TreeSelect.mjs +65 -35
  18. package/es/tree-select/src/interface.d.ts +6 -1
  19. package/es/tree-select/src/scroll-option-end.d.ts +3 -0
  20. package/es/tree-select/src/scroll-option-end.mjs +28 -0
  21. package/es/tree-select/styles/light.d.ts +2 -0
  22. package/es/version.d.ts +1 -1
  23. package/es/version.mjs +1 -1
  24. package/lib/_internal/icons/index.d.ts +0 -1
  25. package/lib/_internal/icons/index.js +1 -3
  26. package/lib/components.d.ts +67 -30
  27. package/lib/tree/src/Tree.d.ts +49 -24
  28. package/lib/tree/src/Tree.js +16 -15
  29. package/lib/tree/src/TreeNodeCheckbox.d.ts +4 -0
  30. package/lib/tree/src/TreeNodeSwitcher.js +11 -14
  31. package/lib/tree/src/styles/index.cssr.js +11 -8
  32. package/lib/tree/styles/light.d.ts +4 -0
  33. package/lib/tree/styles/light.js +2 -0
  34. package/lib/tree-select/index.d.ts +1 -1
  35. package/lib/tree-select/src/TreeSelect.d.ts +43 -16
  36. package/lib/tree-select/src/TreeSelect.js +66 -40
  37. package/lib/tree-select/src/interface.d.ts +6 -1
  38. package/lib/tree-select/src/scroll-option-end.d.ts +3 -0
  39. package/lib/tree-select/src/scroll-option-end.js +30 -0
  40. package/lib/tree-select/styles/light.d.ts +2 -0
  41. package/lib/version.d.ts +1 -1
  42. package/lib/version.js +1 -1
  43. package/package.json +2 -2
  44. package/web-types.json +21 -1
  45. package/es/_internal/icons/Switcher.d.ts +0 -2
  46. package/es/_internal/icons/Switcher.mjs +0 -12
  47. package/lib/_internal/icons/Switcher.d.ts +0 -2
  48. package/lib/_internal/icons/Switcher.js +0 -10
package/dist/index.mjs CHANGED
@@ -11170,7 +11170,7 @@ function setCacheAdd(value) {
11170
11170
  * @name has
11171
11171
  * @memberOf SetCache
11172
11172
  * @param {*} value The value to search for.
11173
- * @returns {number} Returns `true` if `value` is found, else `false`.
11173
+ * @returns {boolean} Returns `true` if `value` is found, else `false`.
11174
11174
  */
11175
11175
  function setCacheHas(value) {
11176
11176
  return this.__data__.has(value);
@@ -14806,13 +14806,6 @@ var SuccessIcon = replaceable(
14806
14806
  ))
14807
14807
  );
14808
14808
 
14809
- var SwitcherIcon = defineComponent({
14810
- name: "Switcher",
14811
- render() {
14812
- return /* @__PURE__ */ h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 32 32" }, /* @__PURE__ */ h("path", { d: "M12 8l10 8l-10 8z" }));
14813
- }
14814
- });
14815
-
14816
14809
  var TimeIcon = replaceable(
14817
14810
  "time",
14818
14811
  /* @__PURE__ */ h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512" }, /* @__PURE__ */ h(
@@ -49217,6 +49210,8 @@ function self$g(vars) {
49217
49210
  nodeColorPressed: elementsQuaternary,
49218
49211
  nodeColorActive: brandPrimary100,
49219
49212
  arrowColor: elementsPrimary,
49213
+ switcherColor: elementsTertiary,
49214
+ switcherSize: "22px",
49220
49215
  nodeTextColor: textPrimary,
49221
49216
  nodeTextColorDisabled: textSecondary,
49222
49217
  loadingColor: elementsPrimary,
@@ -108199,6 +108194,16 @@ var UTreeNodeSwitcher = defineComponent({
108199
108194
  treeInjectionKey,
108200
108195
  null
108201
108196
  );
108197
+ const renderSwitchIcon = () => {
108198
+ const { value: renderSwitcherIcon } = renderSwitcherIconRef;
108199
+ return /* @__PURE__ */ h(UIconSwitchTransition, null, {
108200
+ default: () => renderSwitcherIcon ? renderSwitcherIcon({
108201
+ expanded: props.expanded,
108202
+ selected: props.selected,
108203
+ option: props.tmNode.rawNode
108204
+ }) : /* @__PURE__ */ h(UBaseIcon, { clsPrefix: props.clsPrefix, key: "switcher" }, { default: () => /* @__PURE__ */ h(ChevronRightIcon, null) })
108205
+ });
108206
+ };
108202
108207
  return () => {
108203
108208
  const { clsPrefix, expanded, hide, indent, onClick } = props;
108204
108209
  return /* @__PURE__ */ h(
@@ -108213,28 +108218,16 @@ var UTreeNodeSwitcher = defineComponent({
108213
108218
  style: { width: `${indent}px` },
108214
108219
  onClick
108215
108220
  },
108216
- /* @__PURE__ */ h("div", { class: `${clsPrefix}-tree-node-switcher__icon` }, /* @__PURE__ */ h(UIconSwitchTransition, null, {
108217
- default: () => {
108218
- if (props.loading) {
108219
- return /* @__PURE__ */ h(
108220
- UBaseLoading,
108221
- {
108222
- clsPrefix,
108223
- key: "loading",
108224
- radius: 85,
108225
- strokeWidth: 20,
108226
- ...spinPropsRef?.value
108227
- }
108228
- );
108229
- }
108230
- const { value: renderSwitcherIcon } = renderSwitcherIconRef;
108231
- return renderSwitcherIcon ? renderSwitcherIcon({
108232
- expanded: props.expanded,
108233
- selected: props.selected,
108234
- option: props.tmNode.rawNode
108235
- }) : /* @__PURE__ */ h(UBaseIcon, { clsPrefix, key: "switcher" }, { default: () => /* @__PURE__ */ h(SwitcherIcon, null) });
108221
+ /* @__PURE__ */ h("div", { class: `${clsPrefix}-tree-node-switcher__icon` }, props.loading ? /* @__PURE__ */ h(
108222
+ UBaseLoading,
108223
+ {
108224
+ clsPrefix,
108225
+ key: "loading",
108226
+ radius: 85,
108227
+ strokeWidth: 20,
108228
+ ...spinPropsRef?.value
108236
108229
  }
108237
- }))
108230
+ ) : renderSwitchIcon())
108238
108231
  );
108239
108232
  };
108240
108233
  }
@@ -108922,19 +108915,20 @@ var style$3 = cB("tree", `
108922
108915
  vertical-align: bottom;
108923
108916
  `, [cE("icon", `
108924
108917
  position: relative;
108925
- height: 14px;
108926
- width: 14px;
108918
+ height: var(--u-switcher-size);
108919
+ width: var(--u-switcher-size);
108927
108920
  display: flex;
108921
+ align-items: center;
108922
+ justify-content: center;
108923
+ border-radius: 50%;
108928
108924
  color: var(--u-arrow-color);
108929
- transition: color .3s var(--u-bezier);
108925
+ background-color: var(--u-switcher-color);
108926
+ transition:
108927
+ color .3s var(--u-bezier),
108928
+ background-color .3s var(--u-bezier);
108930
108929
  font-size: 14px;
108931
108930
  `, [cB("icon", [iconSwitchTransitionNode]), cB("base-loading", `
108932
108931
  color: var(--u-loading-color);
108933
- position: absolute;
108934
- left: 0;
108935
- top: 0;
108936
- right: 0;
108937
- bottom: 0;
108938
108932
  `, [iconSwitchTransitionNode]), cB("base-icon", [iconSwitchTransitionNode])]), cM("hide", "visibility: hidden;"), cM("expanded", "transform: rotate(90deg);")]), cB("tree-node-checkbox", `
108939
108933
  display: inline-flex;
108940
108934
  height: var(--u-node-content-height);
@@ -109071,7 +109065,7 @@ const treeProps = {
109071
109065
  scrollbarProps: Object,
109072
109066
  indent: {
109073
109067
  type: Number,
109074
- default: 24
109068
+ default: 36
109075
109069
  },
109076
109070
  allowDrop: {
109077
109071
  type: Function,
@@ -109107,6 +109101,7 @@ const treeProps = {
109107
109101
  "onUpdate:checkedKeys": [Function, Array],
109108
109102
  onUpdateSelectedKeys: [Function, Array],
109109
109103
  "onUpdate:selectedKeys": [Function, Array],
109104
+ onScroll: [Function, Array],
109110
109105
  ...treeSharedProps,
109111
109106
  // internal props for tree-select
109112
109107
  internalTreeSelect: Boolean,
@@ -109846,8 +109841,8 @@ var _UTree = defineComponent({
109846
109841
  }
109847
109842
  doDragLeave({ event, node: node.rawNode });
109848
109843
  }
109849
- function handleDragLeaveTree(e) {
109850
- if (e.target !== e.currentTarget)
109844
+ function handleDragLeaveTree(event) {
109845
+ if (event.target !== event.currentTarget)
109851
109846
  return;
109852
109847
  resetDropState();
109853
109848
  }
@@ -110044,22 +110039,26 @@ var _UTree = defineComponent({
110044
110039
  });
110045
110040
  resetDndState();
110046
110041
  }
110047
- function handleScroll() {
110042
+ function doScroll(event) {
110043
+ props.onScroll && call(props.onScroll, event);
110044
+ }
110045
+ function handleScroll(event) {
110048
110046
  syncScrollbar();
110047
+ doScroll(event);
110049
110048
  }
110050
110049
  function handleResize() {
110051
110050
  syncScrollbar();
110052
110051
  }
110053
- function handleFocusout(e) {
110052
+ function handleFocusout(event) {
110054
110053
  if (props.virtualScroll || props.internalScrollable) {
110055
110054
  const { value: scrollbarInst } = scrollbarInstRef;
110056
- if (scrollbarInst?.containerRef?.contains(e.relatedTarget)) {
110055
+ if (scrollbarInst?.containerRef?.contains(event.relatedTarget)) {
110057
110056
  return;
110058
110057
  }
110059
110058
  pendingNodeKeyRef.value = null;
110060
110059
  } else {
110061
110060
  const { value: selfEl } = selfElRef;
110062
- if (selfEl?.contains(e.relatedTarget))
110061
+ if (selfEl?.contains(event.relatedTarget))
110063
110062
  return;
110064
110063
  pendingNodeKeyRef.value = null;
110065
110064
  }
@@ -110172,6 +110171,8 @@ var _UTree = defineComponent({
110172
110171
  nodeColorPressed,
110173
110172
  nodeColorActive,
110174
110173
  arrowColor,
110174
+ switcherColor,
110175
+ switcherSize,
110175
110176
  loadingColor,
110176
110177
  nodeTextColor,
110177
110178
  nodeTextColorDisabled,
@@ -110188,6 +110189,8 @@ var _UTree = defineComponent({
110188
110189
  );
110189
110190
  return {
110190
110191
  "--u-arrow-color": arrowColor,
110192
+ "--u-switcher-color": switcherColor,
110193
+ "--u-switcher-size": switcherSize,
110191
110194
  "--u-loading-color": loadingColor,
110192
110195
  "--u-bezier": cubicBezierEaseInOut,
110193
110196
  "--u-font-size": fontSize,
@@ -110336,6 +110339,7 @@ var _UTree = defineComponent({
110336
110339
  ...scrollbarProps,
110337
110340
  class: treeClass,
110338
110341
  tabindex,
110342
+ onScroll: this.handleScroll,
110339
110343
  onKeydown: mergedFocusable ? handleKeydown : void 0,
110340
110344
  onFocusout: mergedFocusable ? handleFocusout : void 0,
110341
110345
  style: this.cssVars,
@@ -110379,6 +110383,34 @@ var _UTree = defineComponent({
110379
110383
  }
110380
110384
  });
110381
110385
 
110386
+ function isVerticallyVisibleWithin(element, containerRect) {
110387
+ const elementRect = element.getBoundingClientRect();
110388
+ return elementRect.top < containerRect.bottom && elementRect.bottom > containerRect.top;
110389
+ }
110390
+ function scanReachedRootOptions(scrollElement, rootNodes, expandedKeys, previousVisibleKeys) {
110391
+ const containerRect = scrollElement.getBoundingClientRect();
110392
+ const visibleKeys = /* @__PURE__ */new Set();
110393
+ const reachedOptions = [];
110394
+ for (const rootNode of rootNodes) {
110395
+ const {
110396
+ children
110397
+ } = rootNode;
110398
+ if (!children?.length || !expandedKeys?.includes(rootNode.key)) continue;
110399
+ const lastChild = children[children.length - 1];
110400
+ const lastChildElement = scrollElement.querySelector(`[data-key="${createDataKey(lastChild.key)}"]`);
110401
+ const isHiddenOrMissing = !lastChildElement || !isVerticallyVisibleWithin(lastChildElement, containerRect);
110402
+ if (isHiddenOrMissing) continue;
110403
+ visibleKeys.add(rootNode.key);
110404
+ if (!previousVisibleKeys.has(rootNode.key)) {
110405
+ reachedOptions.push(rootNode.rawNode);
110406
+ }
110407
+ }
110408
+ return {
110409
+ reachedOptions,
110410
+ visibleKeys
110411
+ };
110412
+ }
110413
+
110382
110414
  var style$2 = c$1([cB("tree-select", `
110383
110415
  z-index: auto;
110384
110416
  outline: none;
@@ -110497,6 +110529,8 @@ const treeSelectProps = {
110497
110529
  nodeProps: Function,
110498
110530
  onBlur: Function,
110499
110531
  onFocus: Function,
110532
+ onScroll: [Function, Array],
110533
+ onScrollOptionEnd: [Function, Array],
110500
110534
  onLoad: Function,
110501
110535
  onUpdateShow: [Function, Array],
110502
110536
  onUpdateValue: [Function, Array],
@@ -110585,6 +110619,7 @@ var _UTreeSelect = defineComponent({
110585
110619
  uncontrolledExpandedKeysRef
110586
110620
  );
110587
110621
  const focusedRef = ref(false);
110622
+ let visibleRootEndKeys = /* @__PURE__ */ new Set();
110588
110623
  const mergedPlaceholderRef = computed(() => {
110589
110624
  const { placeholder } = props;
110590
110625
  if (placeholder !== void 0)
@@ -110727,17 +110762,17 @@ var _UTreeSelect = defineComponent({
110727
110762
  }
110728
110763
  uncontrolledExpandedKeysRef.value = keys;
110729
110764
  }
110730
- function doFocus(e) {
110765
+ function doFocus(event) {
110731
110766
  const { onFocus } = props;
110732
110767
  if (onFocus)
110733
- onFocus(e);
110768
+ onFocus(event);
110734
110769
  triggerFormFocus();
110735
110770
  }
110736
- function doBlur(e) {
110771
+ function doBlur(event) {
110737
110772
  closeMenu();
110738
110773
  const { onBlur } = props;
110739
110774
  if (onBlur)
110740
- onBlur(e);
110775
+ onBlur(event);
110741
110776
  triggerFormBlur();
110742
110777
  }
110743
110778
  function closeMenu() {
@@ -110754,11 +110789,12 @@ var _UTreeSelect = defineComponent({
110754
110789
  }
110755
110790
  function handleMenuLeave() {
110756
110791
  patternRef.value = "";
110792
+ visibleRootEndKeys = /* @__PURE__ */ new Set();
110757
110793
  }
110758
- function handleMenuClickoutside(e) {
110794
+ function handleMenuClickoutside(event) {
110759
110795
  if (mergedShowRef.value) {
110760
110796
  if (!triggerInstRef.value?.$el.contains(
110761
- getPreciseEventTarget(e)
110797
+ getPreciseEventTarget(event)
110762
110798
  )) {
110763
110799
  closeMenu();
110764
110800
  }
@@ -110806,34 +110842,34 @@ var _UTreeSelect = defineComponent({
110806
110842
  doUpdateIndeterminateKeys(keys, getOptionsByKeys(keys));
110807
110843
  }
110808
110844
  }
110809
- function handleTriggerFocus(e) {
110810
- if (menuElRef.value?.contains(e.relatedTarget))
110845
+ function handleTriggerFocus(event) {
110846
+ if (menuElRef.value?.contains(event.relatedTarget))
110811
110847
  return;
110812
110848
  focusedRef.value = true;
110813
- doFocus(e);
110849
+ doFocus(event);
110814
110850
  }
110815
- function handleTriggerBlur(e) {
110816
- if (menuElRef.value?.contains(e.relatedTarget))
110851
+ function handleTriggerBlur(event) {
110852
+ if (menuElRef.value?.contains(event.relatedTarget))
110817
110853
  return;
110818
110854
  focusedRef.value = false;
110819
- doBlur(e);
110855
+ doBlur(event);
110820
110856
  }
110821
- function handleMenuFocusin(e) {
110822
- if (menuElRef.value?.contains(e.relatedTarget) || triggerInstRef.value?.$el?.contains(e.relatedTarget)) {
110857
+ function handleMenuFocusin(event) {
110858
+ if (menuElRef.value?.contains(event.relatedTarget) || triggerInstRef.value?.$el?.contains(event.relatedTarget)) {
110823
110859
  return;
110824
110860
  }
110825
110861
  focusedRef.value = true;
110826
- doFocus(e);
110862
+ doFocus(event);
110827
110863
  }
110828
- function handleMenuFocusout(e) {
110829
- if (menuElRef.value?.contains(e.relatedTarget) || triggerInstRef.value?.$el?.contains(e.relatedTarget)) {
110864
+ function handleMenuFocusout(event) {
110865
+ if (menuElRef.value?.contains(event.relatedTarget) || triggerInstRef.value?.$el?.contains(event.relatedTarget)) {
110830
110866
  return;
110831
110867
  }
110832
110868
  focusedRef.value = false;
110833
- doBlur(e);
110869
+ doBlur(event);
110834
110870
  }
110835
- function handleClear(e) {
110836
- e.stopPropagation();
110871
+ function handleClear(event) {
110872
+ event.stopPropagation();
110837
110873
  const { multiple } = props;
110838
110874
  if (!multiple && props.filterable) {
110839
110875
  closeMenu();
@@ -110886,20 +110922,20 @@ var _UTreeSelect = defineComponent({
110886
110922
  }
110887
110923
  }
110888
110924
  }
110889
- function handlePatternInput(e) {
110890
- const { value } = e.target;
110925
+ function handlePatternInput(event) {
110926
+ const { value } = event.target;
110891
110927
  patternRef.value = value;
110892
110928
  }
110893
- function treeHandleKeydown(e) {
110929
+ function treeHandleKeydown(event) {
110894
110930
  const { value: treeInst } = treeInstRef;
110895
110931
  if (treeInst) {
110896
- treeInst.handleKeydown(e);
110932
+ treeInst.handleKeydown(event);
110897
110933
  }
110898
110934
  }
110899
- function handleKeydown(e) {
110900
- if (e.key === "Enter") {
110935
+ function handleKeydown(event) {
110936
+ if (event.key === "Enter") {
110901
110937
  if (mergedShowRef.value) {
110902
- treeHandleKeydown(e);
110938
+ treeHandleKeydown(event);
110903
110939
  if (!props.multiple) {
110904
110940
  closeMenu();
110905
110941
  focusSelection();
@@ -110907,17 +110943,17 @@ var _UTreeSelect = defineComponent({
110907
110943
  } else {
110908
110944
  openMenu();
110909
110945
  }
110910
- e.preventDefault();
110911
- } else if (e.key === "Escape") {
110946
+ event.preventDefault();
110947
+ } else if (event.key === "Escape") {
110912
110948
  if (mergedShowRef.value) {
110913
- markEventEffectPerformed(e);
110949
+ markEventEffectPerformed(event);
110914
110950
  closeMenu();
110915
110951
  focusSelection();
110916
110952
  }
110917
110953
  } else {
110918
110954
  if (mergedShowRef.value) {
110919
- treeHandleKeydown(e);
110920
- } else if (e.key === "ArrowDown") {
110955
+ treeHandleKeydown(event);
110956
+ } else if (event.key === "ArrowDown") {
110921
110957
  openMenu();
110922
110958
  }
110923
110959
  }
@@ -110926,9 +110962,35 @@ var _UTreeSelect = defineComponent({
110926
110962
  closeMenu();
110927
110963
  focusSelection();
110928
110964
  }
110929
- function handleMenuMousedown(e) {
110930
- if (!happensIn(e, "action"))
110931
- e.preventDefault();
110965
+ function handleMenuMousedown(event) {
110966
+ if (!happensIn(event, "action"))
110967
+ event.preventDefault();
110968
+ }
110969
+ function doScroll(event) {
110970
+ const { onScroll } = props;
110971
+ if (onScroll)
110972
+ call(onScroll, event);
110973
+ }
110974
+ function doScrollOptionEnd(option, event) {
110975
+ props.onScrollOptionEnd && call(props.onScrollOptionEnd, option, event);
110976
+ }
110977
+ function handleTreeScroll(event) {
110978
+ doScroll(event);
110979
+ if (!props.onScrollOptionEnd)
110980
+ return;
110981
+ const scrollElement = event.currentTarget || event.target;
110982
+ if (!scrollElement)
110983
+ return;
110984
+ const { reachedOptions, visibleKeys } = scanReachedRootOptions(
110985
+ scrollElement,
110986
+ dataTreeMateRef.value.treeNodes,
110987
+ mergedExpandedKeysRef.value,
110988
+ visibleRootEndKeys
110989
+ );
110990
+ visibleRootEndKeys = visibleKeys;
110991
+ for (const reachedOption of reachedOptions) {
110992
+ doScrollOptionEnd(reachedOption, event);
110993
+ }
110932
110994
  }
110933
110995
  const selectionRenderTagRef = computed(() => {
110934
110996
  const { renderTag } = props;
@@ -111081,6 +111143,7 @@ var _UTreeSelect = defineComponent({
111081
111143
  handleKeydown,
111082
111144
  handleTabOut,
111083
111145
  handleMenuMousedown,
111146
+ handleTreeScroll,
111084
111147
  mergedTheme: themeRef,
111085
111148
  cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
111086
111149
  themeClass: themeClassHandle?.themeClass,
@@ -111241,7 +111304,8 @@ var _UTreeSelect = defineComponent({
111241
111304
  onLoad: this.onLoad,
111242
111305
  onUpdateCheckedKeys: this.handleUpdateCheckedKeys,
111243
111306
  onUpdateIndeterminateKeys: this.handleUpdateIndeterminateKeys,
111244
- onUpdateExpandedKeys: this.doUpdateExpandedKeys
111307
+ onUpdateExpandedKeys: this.doUpdateExpandedKeys,
111308
+ onScroll: this.handleTreeScroll
111245
111309
  }
111246
111310
  ),
111247
111311
  resolveWrappedSlot($slots.action, (children) => {
@@ -113169,7 +113233,7 @@ function useThemeVars() {
113169
113233
  });
113170
113234
  }
113171
113235
 
113172
- var version = "2.0.6";
113236
+ var version = "2.0.7";
113173
113237
 
113174
113238
  function create({
113175
113239
  componentPrefix = "U",