@aplus-frontend/ui 0.4.2 → 0.4.4

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 (125) hide show
  1. package/es/index.mjs +158 -152
  2. package/es/src/ap-field/date/helper.d.ts +1 -1
  3. package/es/src/ap-field/date/helper.mjs +9 -9
  4. package/es/src/ap-field/date/index.vue.mjs +33 -25
  5. package/es/src/ap-field/date-range/index.vue.mjs +44 -43
  6. package/es/src/ap-field/interface.d.ts +0 -6
  7. package/es/src/ap-field/segmented/index.vue.d.ts +7 -1
  8. package/es/src/ap-field/select/index.vue.d.ts +4 -20
  9. package/es/src/ap-field/select/index.vue.mjs +11 -11
  10. package/es/src/ap-field/text/index.vue.d.ts +13 -1
  11. package/es/src/ap-form/items/text/index.vue.d.ts +26 -2
  12. package/es/src/ap-table/constants.d.ts +28 -12
  13. package/es/src/ap-table/utils.d.ts +13 -1
  14. package/es/src/business/ap-batch-action/ApBatchAction.vue.d.ts +8 -4
  15. package/es/src/business/ap-batch-action/ApBatchAction.vue2.mjs +45 -55
  16. package/es/src/business/ap-batch-action/index.d.ts +5 -3
  17. package/es/src/business/ap-group-search/ap-group-search.vue2.mjs +12 -12
  18. package/es/src/business/ap-group-search/extension-select/index.vue2.mjs +7 -7
  19. package/es/src/business/ap-group-search/index.d.ts +8 -34
  20. package/es/src/business/ap-group-search/popover-select/index.vue.d.ts +2 -10
  21. package/es/src/business/ap-group-search/popover-select/index.vue2.mjs +15 -15
  22. package/es/src/business/ap-table-modal/table-modal.vue2.mjs +8 -4
  23. package/es/src/business/batch-input-group/index.vue.d.ts +13 -1
  24. package/es/src/config-provider/hooks/use-namespace.d.ts +1 -1
  25. package/es/src/config-provider/hooks/use-namespace.mjs +3 -3
  26. package/es/src/hooks/index.d.ts +2 -0
  27. package/es/src/hooks/index.mjs +7 -3
  28. package/es/src/hooks/useManualRef.d.ts +6 -0
  29. package/es/src/hooks/useManualRef.mjs +27 -0
  30. package/es/src/hooks/useThrottleRef.d.ts +2 -0
  31. package/es/src/hooks/useThrottleRef.mjs +31 -0
  32. package/es/src/index.d.ts +1 -1
  33. package/es/src/index.mjs +231 -228
  34. package/es/src/path-map.mjs +1 -1
  35. package/es/src/scroll-bar/hooks/use-track.d.ts +30 -0
  36. package/es/src/scroll-bar/hooks/use-track.mjs +76 -0
  37. package/es/src/scroll-bar/index.d.ts +4 -0
  38. package/es/src/scroll-bar/index.mjs +3 -0
  39. package/es/src/scroll-bar/index.vue.d.ts +52 -0
  40. package/es/src/scroll-bar/index.vue.mjs +77 -0
  41. package/es/src/scroll-bar/index.vue2.mjs +4 -0
  42. package/es/src/scroll-bar/interface.d.ts +66 -0
  43. package/es/src/scroll-bar/internal.vue.d.ts +22 -0
  44. package/es/src/scroll-bar/internal.vue.mjs +132 -0
  45. package/es/src/scroll-bar/internal.vue2.mjs +4 -0
  46. package/es/src/scroll-bar/style/css.js +1 -0
  47. package/es/src/scroll-bar/style/index.js +1 -0
  48. package/es/src/scroll-bar/utils/index.d.ts +22 -0
  49. package/es/src/scroll-bar/utils/index.mjs +17 -0
  50. package/lib/index.js +1 -1
  51. package/lib/src/ap-field/date/helper.d.ts +1 -1
  52. package/lib/src/ap-field/date/helper.js +1 -1
  53. package/lib/src/ap-field/date/index.vue.js +1 -1
  54. package/lib/src/ap-field/date-range/index.vue.js +1 -1
  55. package/lib/src/ap-field/interface.d.ts +0 -6
  56. package/lib/src/ap-field/segmented/index.vue.d.ts +7 -1
  57. package/lib/src/ap-field/select/index.vue.d.ts +4 -20
  58. package/lib/src/ap-field/select/index.vue.js +1 -1
  59. package/lib/src/ap-field/text/index.vue.d.ts +13 -1
  60. package/lib/src/ap-form/items/text/index.vue.d.ts +26 -2
  61. package/lib/src/ap-table/constants.d.ts +28 -12
  62. package/lib/src/ap-table/utils.d.ts +13 -1
  63. package/lib/src/business/ap-batch-action/ApBatchAction.vue.d.ts +8 -4
  64. package/lib/src/business/ap-batch-action/ApBatchAction.vue2.js +1 -1
  65. package/lib/src/business/ap-batch-action/index.d.ts +5 -3
  66. package/lib/src/business/ap-group-search/ap-group-search.vue2.js +1 -1
  67. package/lib/src/business/ap-group-search/extension-select/index.vue2.js +1 -1
  68. package/lib/src/business/ap-group-search/index.d.ts +8 -34
  69. package/lib/src/business/ap-group-search/popover-select/index.vue.d.ts +2 -10
  70. package/lib/src/business/ap-group-search/popover-select/index.vue2.js +2 -2
  71. package/lib/src/business/ap-table-modal/table-modal.vue2.js +1 -1
  72. package/lib/src/business/batch-input-group/index.vue.d.ts +13 -1
  73. package/lib/src/config-provider/hooks/use-namespace.d.ts +1 -1
  74. package/lib/src/config-provider/hooks/use-namespace.js +1 -1
  75. package/lib/src/hooks/index.d.ts +2 -0
  76. package/lib/src/hooks/index.js +1 -1
  77. package/lib/src/hooks/useManualRef.d.ts +6 -0
  78. package/lib/src/hooks/useManualRef.js +1 -0
  79. package/lib/src/hooks/useThrottleRef.d.ts +2 -0
  80. package/lib/src/hooks/useThrottleRef.js +1 -0
  81. package/lib/src/index.d.ts +1 -1
  82. package/lib/src/index.js +1 -1
  83. package/lib/src/path-map.js +1 -1
  84. package/lib/src/scroll-bar/hooks/use-track.d.ts +30 -0
  85. package/lib/src/scroll-bar/hooks/use-track.js +1 -0
  86. package/lib/src/scroll-bar/index.d.ts +4 -0
  87. package/lib/src/scroll-bar/index.js +1 -0
  88. package/lib/src/scroll-bar/index.vue.d.ts +52 -0
  89. package/lib/src/scroll-bar/index.vue.js +1 -0
  90. package/lib/src/scroll-bar/index.vue2.js +1 -0
  91. package/lib/src/scroll-bar/interface.d.ts +66 -0
  92. package/lib/src/scroll-bar/internal.vue.d.ts +22 -0
  93. package/lib/src/scroll-bar/internal.vue.js +1 -0
  94. package/lib/src/scroll-bar/internal.vue2.js +1 -0
  95. package/lib/src/scroll-bar/style/css.cjs +1 -0
  96. package/lib/src/scroll-bar/style/index.cjs +1 -0
  97. package/lib/src/scroll-bar/utils/index.d.ts +22 -0
  98. package/lib/src/scroll-bar/utils/index.js +1 -0
  99. package/package.json +3 -3
  100. package/theme/index.css +36 -21
  101. package/theme/index.less +1 -1
  102. package/theme/scroll-bar/index.css +46 -0
  103. package/theme/scroll-bar/index.less +62 -0
  104. package/es/src/ap-scroll-bar/ap-scroll-bar.vue.d.ts +0 -8
  105. package/es/src/ap-scroll-bar/ap-scroll-bar.vue.mjs +0 -4
  106. package/es/src/ap-scroll-bar/ap-scroll-bar.vue2.mjs +0 -116
  107. package/es/src/ap-scroll-bar/index.d.ts +0 -29
  108. package/es/src/ap-scroll-bar/index.mjs +0 -8
  109. package/es/src/ap-scroll-bar/interface.d.ts +0 -4
  110. package/es/src/ap-scroll-bar/style/css.js +0 -1
  111. package/es/src/ap-scroll-bar/style/index.js +0 -1
  112. package/lib/src/ap-scroll-bar/ap-scroll-bar.vue.d.ts +0 -8
  113. package/lib/src/ap-scroll-bar/ap-scroll-bar.vue.js +0 -1
  114. package/lib/src/ap-scroll-bar/ap-scroll-bar.vue2.js +0 -1
  115. package/lib/src/ap-scroll-bar/index.d.ts +0 -29
  116. package/lib/src/ap-scroll-bar/index.js +0 -1
  117. package/lib/src/ap-scroll-bar/interface.d.ts +0 -4
  118. package/lib/src/ap-scroll-bar/style/css.cjs +0 -1
  119. package/lib/src/ap-scroll-bar/style/index.cjs +0 -1
  120. /package/es/src/{ap-scroll-bar → scroll-bar}/interface.mjs +0 -0
  121. /package/es/src/{ap-scroll-bar → scroll-bar}/style/css.d.ts +0 -0
  122. /package/es/src/{ap-scroll-bar → scroll-bar}/style/index.d.ts +0 -0
  123. /package/lib/src/{ap-scroll-bar → scroll-bar}/interface.js +0 -0
  124. /package/lib/src/{ap-scroll-bar → scroll-bar}/style/css.d.ts +0 -0
  125. /package/lib/src/{ap-scroll-bar → scroll-bar}/style/index.d.ts +0 -0
@@ -0,0 +1,22 @@
1
+ import { InternalScrollBarProps, ScrollBarDirection } from './interface';
2
+ import { DefineComponent, Ref, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
3
+ declare function scroll(percent: number): void;
4
+ declare const _default: DefineComponent<InternalScrollBarProps, {
5
+ currentScroll: Ref<number, number>;
6
+ container: Ref<HTMLElement | undefined, HTMLElement | undefined>;
7
+ bar: Ref<HTMLElement | undefined, HTMLElement | undefined>;
8
+ track: Ref<HTMLElement | undefined, HTMLElement | undefined>;
9
+ scroll: typeof scroll;
10
+ }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<InternalScrollBarProps> & Readonly<{}>, {
11
+ scroll: number;
12
+ disabled: boolean;
13
+ direction: ScrollBarDirection;
14
+ barLength: number;
15
+ showTrack: boolean;
16
+ trackSpeed: number;
17
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {
18
+ container: HTMLDivElement;
19
+ track: HTMLDivElement;
20
+ bar: HTMLDivElement;
21
+ }, HTMLDivElement>;
22
+ export default _default;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue");require("../config-provider/index.js");const T=require("./hooks/use-track.js"),p=require("./utils/index.js"),P=require("../config-provider/hooks/use-namespace.js"),B=t.defineComponent({__name:"internal",props:{direction:{default:"vertical"},scroll:{default:0},barLength:{default:35},width:{},barColor:{},trackColor:{},trackWidth:{},disabled:{type:Boolean,default:!1},showTrack:{type:Boolean,default:!0},trackSpeed:{default:2},onScrollStart:{},onScroll:{},onScrollEnd:{}},setup(y,{expose:E}){const n=y,h=t.ref(),c=t.ref(),l=t.ref(),{b:L,e:b,m:C,em:u,cssVar:R}=P.useNamespace("scroll-bar"),o=t.ref(n.scroll),{handleMouseDown:k}=T.useTrack({currentScroll:o,track:c,bar:l,type:t.toRef(n,"direction"),trackSpeed:t.toRef(n,"trackSpeed"),barLength:t.toRef(n,"barLength"),disabled:t.toRef(n,"disabled"),onDown:e=>{var r;(r=n.onScrollStart)==null||r.call(n,e)},onUp:e=>{var r;(r=n.onScrollEnd)==null||r.call(n,e)},onScroll:e=>{var r;(r=n.onScroll)==null||r.call(n,e)}});t.watch(()=>n.scroll,e=>{o.value=e}),t.watchEffect(()=>{if(!t.unref(l))return;const e=`${(100-n.barLength)*o.value/n.barLength}%`,r=`${n.barLength}%`;n.direction==="vertical"?(l.value.style.height=r,l.value.style.transform=`translate3d(0, ${e}, 0)`):(l.value.style.width=r,l.value.style.transform=`translate3d(${e}, 0, 0)`)});let f,s,d;function M(e){var w;if(n.disabled||e.button!==0)return;e.preventDefault(),e.stopPropagation();const r=t.unref(c),i=t.unref(l);if(!r||!i)return;document.addEventListener("pointermove",v),document.addEventListener("pointerup",m);const a=r.getBoundingClientRect(),S=i.getBoundingClientRect();n.direction==="vertical"?(f=a.height,s=S.top-a.top,d=e.clientY):(f=a.width,s=S.left-a.left,d=e.clientX),(w=n.onScrollStart)==null||w.call(n,t.unref(o))}function v(e){var a;e.stopPropagation(),e.preventDefault();let r;n.direction==="vertical"?r=s+e.clientY-d:r=s+e.clientX-d;const i=r/f/(100-n.barLength)*1e4;o.value=p.ensureRangeValue(i),(a=n.onScroll)==null||a.call(n,t.unref(o))}function m(e){var r;e.preventDefault(),document.removeEventListener("pointermove",v),document.removeEventListener("pointerup",m),(r=n.onScrollEnd)==null||r.call(n,t.unref(o))}function g(e){e.cancelable&&(e.stopPropagation(),e.preventDefault())}function D(e){Math.abs(t.unref(o)-e)<=.001||(o.value=p.ensureRangeValue(e))}return E({currentScroll:o,container:h,bar:l,track:c,scroll:D}),(e,r)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:h,class:t.normalizeClass([t.unref(L)(),t.unref(C)(e.direction)]),style:t.normalizeStyle(t.unref(R)({"bar-color":e.barColor,"track-color":e.trackColor,"bar-width":e.width?`${e.width}px`:void 0,"track-width":e.trackWidth?`${e.trackWidth}px`:void 0}))},[t.createElementVNode("div",{ref_key:"track",ref:c,class:t.normalizeClass([t.unref(b)("track"),e.disabled?t.unref(u)("track","disabled"):null,e.showTrack?null:t.unref(u)("track","hidden")]),onPointerdown:r[0]||(r[0]=(...i)=>t.unref(k)&&t.unref(k)(...i)),onTouchstart:g},null,34),t.createElementVNode("div",{ref_key:"bar",ref:l,class:t.normalizeClass([t.unref(b)("bar"),t.unref(u)("bar",e.direction),e.disabled?t.unref(u)("bar","disabled"):null]),onPointerdown:M,onTouchstart:g},null,34)],6))}});exports.default=B;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal.vue.js");exports.default=e.default;
@@ -0,0 +1 @@
1
+ import '@aplus-frontend/ui/theme/scroll-bar/index.css';
@@ -0,0 +1 @@
1
+ import '@aplus-frontend/ui/theme/scroll-bar/index.less';
@@ -0,0 +1,22 @@
1
+ import { ScrollBarDirection } from '../interface';
2
+ /**
3
+ * 保证返回的值在[start,end]范围内
4
+ * @param target
5
+ * @param start
6
+ * @param end
7
+ * @returns
8
+ */
9
+ export declare function ensureRangeValue(target: number, start?: number, end?: number): number;
10
+ /**
11
+ * 获得某个可滚动元素的一些关键数据
12
+ * @param dom 可滚动元素
13
+ * @param direction 滚动方向
14
+ * @returns
15
+ */
16
+ export declare function getScrollable(dom: HTMLElement, direction: ScrollBarDirection): {
17
+ totalSize: number;
18
+ visibleSize: number;
19
+ distance: number;
20
+ topOrLeft: string;
21
+ widthOrHeight: string;
22
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(e,t=0,l=100){return Math.max(t,Math.min(e,l))}function r(e,t){const l=t==="horizontal"?"Left":"Top",n=t==="horizontal"?"Width":"Height";return{totalSize:e[`scroll${n}`],visibleSize:e[`offset${n}`],distance:e[`scroll${l}`],topOrLeft:l,widthOrHeight:n}}exports.ensureRangeValue=o;exports.getScrollable=r;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aplus-frontend/ui",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "main": "./lib/index.js",
5
5
  "type": "module",
6
6
  "files": [
@@ -69,13 +69,13 @@
69
69
  "@aplus-frontend/utils": "1.0.44"
70
70
  },
71
71
  "peerDependencies": {
72
- "@aplus-frontend/antdv": "^1.0.9",
72
+ "@aplus-frontend/antdv": "^1.0.10",
73
73
  "@aplus-frontend/icon": "^1.2.1",
74
74
  "@aplus-frontend/oss": "^1.1.2",
75
75
  "vue": "^3.5.13"
76
76
  },
77
77
  "devDependencies": {
78
- "@aplus-frontend/antdv": "^1.0.9",
78
+ "@aplus-frontend/antdv": "^1.0.10",
79
79
  "@aplus-frontend/icon": "^1.2.1",
80
80
  "@aplus-frontend/oss": "^1.1.2",
81
81
  "@types/sortablejs": "^1.15.8",
package/theme/index.css CHANGED
@@ -1720,36 +1720,51 @@ div.aplus-ap-info-layout-admin__header-shadow.aplus-ap-info-layout-admin__sticky
1720
1720
  left: 0px;
1721
1721
  top: -20px;
1722
1722
  }
1723
- .aplus-ap-scroll-bar {
1723
+ .aplus-scroll-bar {
1724
1724
  position: relative;
1725
- background-color: var(--ap-scroll-bar-background, rgba(0, 0, 0, 0.05));
1726
1725
  }
1727
- .aplus-ap-scroll-bar--horizontal {
1728
- height: 10px;
1726
+ .aplus-scroll-bar--horizontal {
1727
+ width: 100%;
1728
+ height: var(--aplus-scroll-bar-track-width, 10px);
1729
1729
  }
1730
- .aplus-ap-scroll-bar--vertical {
1731
- width: 10px;
1730
+ .aplus-scroll-bar--vertical {
1731
+ width: var(--aplus-scroll-bar-track-width, 10px);
1732
1732
  height: 100%;
1733
1733
  }
1734
- .aplus-ap-scroll-bar__bar {
1734
+ .aplus-scroll-bar__track {
1735
1735
  position: absolute;
1736
- border-radius: 8px;
1737
- background-color: rgba(144, 147, 153, 0.3);
1738
- background-color: var(--ap-scroll-bar-bar, rgba(144, 147, 153, 0.3));
1739
- box-shadow: var(--ap-scroll-bar-bar-shadow, inset 0 0 6px rgba(0, 0, 0, 0.2));
1736
+ width: 100%;
1737
+ height: 100%;
1738
+ top: 0;
1739
+ inset-inline-start: 0;
1740
+ cursor: pointer;
1741
+ background-color: var(--aplus-scroll-bar-track-color, rgba(0, 0, 0, 0.05));
1740
1742
  }
1741
- .aplus-ap-scroll-bar__bar--horizontal {
1742
- height: 8px;
1743
- top: 1px;
1743
+ .aplus-scroll-bar__track--disabled {
1744
+ pointer-events: none;
1745
+ background-color: rgba(0, 0, 0, 0.02);
1744
1746
  }
1745
- .aplus-ap-scroll-bar__bar--vertical {
1746
- width: 8px;
1747
- left: 1px;
1747
+ .aplus-scroll-bar__track--hidden {
1748
+ pointer-events: none;
1749
+ background-color: transparent;
1750
+ }
1751
+ .aplus-scroll-bar__bar {
1752
+ position: absolute;
1753
+ border-radius: var(--aplus-scroll-bar-bar-width, 8px);
1754
+ background-color: var(--aplus-scroll-bar-bar-color, #c7c8cc);
1755
+ cursor: pointer;
1756
+ }
1757
+ .aplus-scroll-bar__bar--disabled {
1758
+ pointer-events: none;
1759
+ box-shadow: none;
1760
+ }
1761
+ .aplus-scroll-bar__bar--horizontal {
1762
+ height: var(--aplus-scroll-bar-bar-width, 8px);
1763
+ top: calc(var(--aplus-scroll-bar-track-width, 10px) - var(--aplus-scroll-bar-bar-width, 8px));
1748
1764
  }
1749
- .aplus-ap-scroll-bar__bar:hover,
1750
- .aplus-ap-scroll-bar__bar:focus,
1751
- .aplus-ap-scroll-bar__bar:active {
1752
- background-color: var(--ap-scroll-bar-bar-active, rgba(144, 147, 153, 0.5));
1765
+ .aplus-scroll-bar__bar--vertical {
1766
+ width: var(--aplus-scroll-bar-bar-width, 8px);
1767
+ left: calc(var(--aplus-scroll-bar-track-width, 10px) / 2 - var(--aplus-scroll-bar-bar-width, 8px) / 2);
1753
1768
  }
1754
1769
  .aplus-ap-appendix__suffix {
1755
1770
  width: 100%;
package/theme/index.less CHANGED
@@ -26,7 +26,7 @@
26
26
  @import './work-order-modal/index.less';
27
27
  @import './ap-summary/index.less';
28
28
  @import './ap-table-modal/index.less';
29
- @import './ap-scroll-bar/index.less';
29
+ @import './scroll-bar/index.less';
30
30
  @import './ap-appendix/ap-appendix.less';
31
31
  @import './ap-group-search/ap-group-search.less';
32
32
  @import './ap-group-search/ap-popover-select.less';
@@ -0,0 +1,46 @@
1
+ .aplus-scroll-bar {
2
+ position: relative;
3
+ }
4
+ .aplus-scroll-bar--horizontal {
5
+ width: 100%;
6
+ height: var(--aplus-scroll-bar-track-width, 10px);
7
+ }
8
+ .aplus-scroll-bar--vertical {
9
+ width: var(--aplus-scroll-bar-track-width, 10px);
10
+ height: 100%;
11
+ }
12
+ .aplus-scroll-bar__track {
13
+ position: absolute;
14
+ width: 100%;
15
+ height: 100%;
16
+ top: 0;
17
+ inset-inline-start: 0;
18
+ cursor: pointer;
19
+ background-color: var(--aplus-scroll-bar-track-color, rgba(0, 0, 0, 0.05));
20
+ }
21
+ .aplus-scroll-bar__track--disabled {
22
+ pointer-events: none;
23
+ background-color: rgba(0, 0, 0, 0.02);
24
+ }
25
+ .aplus-scroll-bar__track--hidden {
26
+ pointer-events: none;
27
+ background-color: transparent;
28
+ }
29
+ .aplus-scroll-bar__bar {
30
+ position: absolute;
31
+ border-radius: var(--aplus-scroll-bar-bar-width, 8px);
32
+ background-color: var(--aplus-scroll-bar-bar-color, #c7c8cc);
33
+ cursor: pointer;
34
+ }
35
+ .aplus-scroll-bar__bar--disabled {
36
+ pointer-events: none;
37
+ box-shadow: none;
38
+ }
39
+ .aplus-scroll-bar__bar--horizontal {
40
+ height: var(--aplus-scroll-bar-bar-width, 8px);
41
+ top: calc(var(--aplus-scroll-bar-track-width, 10px) - var(--aplus-scroll-bar-bar-width, 8px));
42
+ }
43
+ .aplus-scroll-bar__bar--vertical {
44
+ width: var(--aplus-scroll-bar-bar-width, 8px);
45
+ left: calc(var(--aplus-scroll-bar-track-width, 10px) / 2 - var(--aplus-scroll-bar-bar-width, 8px) / 2);
46
+ }
@@ -0,0 +1,62 @@
1
+ @import '../mixins/mixins.less';
2
+ @import '../mixins/config.less';
3
+
4
+ @bar: ~'@{ns}-scroll-bar__bar--disabled';
5
+ @bc: ~'--@{ns}-scroll-bar-bar-color';
6
+ @tc: ~'--@{ns}-scroll-bar-track-color';
7
+ @bw: ~'--@{ns}-scroll-bar-bar-width';
8
+ @tw: ~'--@{ns}-scroll-bar-track-width';
9
+
10
+ .b('scroll-bar', {
11
+ position: relative;
12
+
13
+ &--horizontal {
14
+ width: 100%;
15
+ height: var(@tw, 10px);
16
+ }
17
+
18
+ &--vertical {
19
+ width: var(@tw, 10px);
20
+ height: 100%;
21
+ }
22
+
23
+ &__track {
24
+ position: absolute;
25
+ width: 100%;
26
+ height: 100%;
27
+ top: 0;
28
+ inset-inline-start: 0;
29
+ cursor: pointer;
30
+ background-color: var(@tc, rgb(0 0 0 / 5%));
31
+ &--disabled {
32
+ pointer-events: none;
33
+ background-color: rgb(0 0 0 / 2%);
34
+ }
35
+ &--hidden {
36
+ pointer-events: none;
37
+ background-color: transparent;
38
+ }
39
+ }
40
+
41
+ &__bar {
42
+ position: absolute;
43
+ border-radius: var(@bw, 8px);
44
+ background-color: var(@bc, #c7c8cc);
45
+ cursor: pointer;
46
+
47
+ &--disabled {
48
+ pointer-events: none;
49
+ box-shadow: none;
50
+ }
51
+
52
+ &--horizontal {
53
+ height: var(@bw, 8px);
54
+ top: calc(var(@tw, 10px) - var(@bw, 8px));
55
+ }
56
+
57
+ &--vertical {
58
+ width: var(@bw, 8px);
59
+ left: calc(var(@tw, 10px) / 2 - var(@bw, 8px) / 2);
60
+ }
61
+ }
62
+ });
@@ -1,8 +0,0 @@
1
- import { ApScrollBarProps } from './interface';
2
- import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
3
- declare const _default: DefineComponent<ApScrollBarProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ApScrollBarProps> & Readonly<{}>, {
4
- type: "horizontal" | "vertical";
5
- }, {}, {}, {}, string, ComponentProvideOptions, false, {
6
- containerRef: HTMLDivElement;
7
- }, HTMLDivElement>;
8
- export default _default;
@@ -1,4 +0,0 @@
1
- import f from "./ap-scroll-bar.vue2.mjs";
2
- export {
3
- f as default
4
- };
@@ -1,116 +0,0 @@
1
- import { defineComponent as O, ref as a, nextTick as $, onMounted as Q, watch as Z, onUnmounted as ee, openBlock as te, createElementBlock as le, normalizeClass as N, unref as u, normalizeStyle as U, createElementVNode as oe } from "vue";
2
- import "../config-provider/index.mjs";
3
- import { Subject as ae, fromEvent as v, map as _, takeUntil as h, throttleTime as X, concatAll as Y, withLatestFrom as ne } from "rxjs";
4
- import { useNamespace as ce } from "../config-provider/hooks/use-namespace.mjs";
5
- const ve = /* @__PURE__ */ O({
6
- __name: "ap-scroll-bar",
7
- props: {
8
- target: {},
9
- type: {
10
- default: "horizontal"
11
- }
12
- },
13
- setup(j) {
14
- const o = j, r = a(), H = a(0), T = a(0), p = a(0), d = a(0), g = a(), y = a(), b = a(), W = a(), t = a(), w = a(!1), f = new ae(), z = a();
15
- let k = 0, B = 0;
16
- const E = (e) => e / y.value, S = (e) => e * y.value, R = () => {
17
- if (t.value)
18
- if (o.type === "horizontal") {
19
- const e = t.value.scrollWidth, l = t.value.clientWidth;
20
- w.value = l >= e;
21
- } else {
22
- const e = t.value.scrollHeight, l = t.value.clientHeight;
23
- w.value = l >= e;
24
- }
25
- }, L = () => {
26
- if (t.value && r.value)
27
- if (o.type === "horizontal") {
28
- const e = t.value.scrollWidth, l = t.value.clientWidth, n = t.value.scrollLeft, s = r.value.clientWidth;
29
- g.value = l / e, y.value = s / e, H.value = Math.round(s * g.value), p.value = S(n);
30
- } else {
31
- const e = t.value.scrollHeight, l = t.value.clientHeight, n = t.value.scrollTop, s = r.value.clientHeight;
32
- g.value = l / e, y.value = s / e, T.value = Math.floor(s * g.value), d.value = E(n);
33
- }
34
- }, P = () => {
35
- const e = v(W.value, "mousedown"), l = v(b.value, "mousemove"), n = v(b.value, "mouseup"), s = v(b.value, "selectstart");
36
- e.pipe(_(() => s.pipe(h(n), h(f), X(16))), Y()).subscribe((c) => c.preventDefault()), e.pipe(_(() => l.pipe(h(n), h(f), X(16))), Y(), ne(e), _(([c, x]) => {
37
- console.log("move!!!", c);
38
- const m = c, i = x, C = m.pageX - z.value.left - i.offsetX, M = m.pageY - z.value.top - i.offsetY, J = r.value.clientWidth, K = r.value.clientHeight;
39
- return {
40
- x: C > 0 ? Math.min(C, J - H.value) : Math.max(C, 0),
41
- y: M > 0 ? Math.min(M, K - T.value) : Math.max(M, 0)
42
- };
43
- })).subscribe((c) => {
44
- var x, m;
45
- if (o.type === "horizontal") {
46
- const i = E(c.x);
47
- c.x !== p.value && t.value && ((x = t.value) == null || x.scrollTo({
48
- left: i
49
- })), p.value = c.x;
50
- } else {
51
- const i = E(c.y);
52
- c.y !== d.value && t.value && ((m = t.value) == null || m.scrollTo({
53
- top: i
54
- })), d.value = c.y;
55
- }
56
- });
57
- }, q = () => {
58
- t.value && v(t.value, "scroll").pipe(h(f)).subscribe((l) => {
59
- var s;
60
- const n = l.target;
61
- n && o.type === "horizontal" && (k = n.scrollLeft, p.value = S(k)), n && o.type === "vertical" && B !== ((s = t == null ? void 0 : t.value) == null ? void 0 : s.scrollTop) && (B = n.scrollTop, d.value = S(B));
62
- });
63
- }, A = () => {
64
- v(window, "resize").pipe(h(f)).subscribe(() => {
65
- R(), $(() => {
66
- var l;
67
- z.value = (l = r.value) == null ? void 0 : l.getBoundingClientRect(), L();
68
- });
69
- });
70
- }, F = () => {
71
- console.log("targetEle.value", t.value), t.value && W.value && (R(), $(() => {
72
- var e;
73
- z.value = (e = r.value) == null ? void 0 : e.getBoundingClientRect(), L(), P(), q(), A();
74
- }));
75
- };
76
- Q(() => {
77
- Z(() => o.target, () => {
78
- $(() => {
79
- var e, l;
80
- typeof o.target == "string" ? t.value = document.querySelector(o.target) : t.value = (e = o.target) == null ? void 0 : e.call(o), b.value = (l = document.getElementsByTagName("body")) == null ? void 0 : l[0], W.value = document.getElementById("bar"), F();
81
- });
82
- }, {
83
- immediate: !0
84
- });
85
- }), ee(() => {
86
- f.next(0);
87
- });
88
- const {
89
- b: V,
90
- e: G,
91
- m: D,
92
- em: I
93
- } = ce("ap-scroll-bar");
94
- return (e, l) => (te(), le("div", {
95
- ref_key: "containerRef",
96
- ref: r,
97
- class: N(`${u(V)()} ${o.type === "horizontal" ? u(D)("horizontal") : u(D)("vertical")}`),
98
- style: U({
99
- display: w.value ? "none" : "block"
100
- })
101
- }, [oe("div", {
102
- id: "bar",
103
- class: N(`${u(G)("bar")} ${o.type === "horizontal" ? u(I)("bar", "horizontal") : u(I)("bar", "vertical")}`),
104
- style: U(o.type === "horizontal" ? {
105
- width: `${H.value}px`,
106
- left: `${p.value}px`
107
- } : {
108
- height: `${T.value}px`,
109
- top: `${d.value}px`
110
- })
111
- }, null, 6)], 6));
112
- }
113
- });
114
- export {
115
- ve as default
116
- };
@@ -1,29 +0,0 @@
1
- import { CreateComponentPublicInstanceWithMixins, ComponentOptionsMixin, PublicProps, GlobalComponents, GlobalDirectives, ComponentProvideOptions, ComponentOptionsBase, VNodeProps, AllowedComponentProps, ComponentCustomProps, Plugin } from 'vue';
2
- import { ApScrollBarProps } from './interface';
3
- export * from './interface';
4
- declare const ApScrollBar: {
5
- new (...args: any[]): CreateComponentPublicInstanceWithMixins<Readonly< ApScrollBarProps> & Readonly<{}>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, PublicProps, {
6
- type: "horizontal" | "vertical";
7
- }, false, {}, {}, GlobalComponents, GlobalDirectives, string, {
8
- containerRef: HTMLDivElement;
9
- }, HTMLDivElement, ComponentProvideOptions, {
10
- P: {};
11
- B: {};
12
- D: {};
13
- C: {};
14
- M: {};
15
- Defaults: {};
16
- }, Readonly< ApScrollBarProps> & Readonly<{}>, {}, {}, {}, {}, {
17
- type: "horizontal" | "vertical";
18
- }>;
19
- __isFragment?: never;
20
- __isTeleport?: never;
21
- __isSuspense?: never;
22
- } & ComponentOptionsBase<Readonly< ApScrollBarProps> & Readonly<{}>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, {
23
- type: "horizontal" | "vertical";
24
- }, {}, string, {}, GlobalComponents, GlobalDirectives, string, ComponentProvideOptions> & VNodeProps & AllowedComponentProps & ComponentCustomProps & ( Plugin & (new (...args: any[]) => {
25
- $props: {
26
- onClick?: () => void;
27
- };
28
- }));
29
- export { ApScrollBar };
@@ -1,8 +0,0 @@
1
- import "./interface.mjs";
2
- import { withInstall as o } from "@aplus-frontend/utils";
3
- import "./ap-scroll-bar.vue.mjs";
4
- import r from "./ap-scroll-bar.vue2.mjs";
5
- const l = o(r);
6
- export {
7
- l as ApScrollBar
8
- };
@@ -1,4 +0,0 @@
1
- export interface ApScrollBarProps {
2
- target: string | (() => Element);
3
- type?: 'horizontal' | 'vertical';
4
- }
@@ -1 +0,0 @@
1
- import '@aplus-frontend/ui/theme/ap-scroll-bar/index.css';
@@ -1 +0,0 @@
1
- import '@aplus-frontend/ui/theme/ap-scroll-bar/index.less';
@@ -1,8 +0,0 @@
1
- import { ApScrollBarProps } from './interface';
2
- import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
3
- declare const _default: DefineComponent<ApScrollBarProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ApScrollBarProps> & Readonly<{}>, {
4
- type: "horizontal" | "vertical";
5
- }, {}, {}, {}, string, ComponentProvideOptions, false, {
6
- containerRef: HTMLDivElement;
7
- }, HTMLDivElement>;
8
- export default _default;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./ap-scroll-bar.vue2.js");exports.default=e.default;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue");require("../config-provider/index.js");const o=require("rxjs"),X=require("../config-provider/hooks/use-namespace.js"),Y=e.defineComponent({__name:"ap-scroll-bar",props:{target:{},type:{default:"horizontal"}},setup($){const a=$,i=e.ref(),z=e.ref(0),T=e.ref(0),v=e.ref(0),f=e.ref(0),d=e.ref(),p=e.ref(),g=e.ref(),x=e.ref(),l=e.ref(),E=e.ref(!1),h=new o.Subject,y=e.ref();let w=0,H=0;const W=t=>t/p.value,k=t=>t*p.value,B=()=>{if(l.value)if(a.type==="horizontal"){const t=l.value.scrollWidth,n=l.value.clientWidth;E.value=n>=t}else{const t=l.value.scrollHeight,n=l.value.clientHeight;E.value=n>=t}},C=()=>{if(l.value&&i.value)if(a.type==="horizontal"){const t=l.value.scrollWidth,n=l.value.clientWidth,r=l.value.scrollLeft,s=i.value.clientWidth;d.value=n/t,p.value=s/t,z.value=Math.round(s*d.value),v.value=k(r)}else{const t=l.value.scrollHeight,n=l.value.clientHeight,r=l.value.scrollTop,s=i.value.clientHeight;d.value=n/t,p.value=s/t,T.value=Math.floor(s*d.value),f.value=W(r)}},R=()=>{const t=o.fromEvent(x.value,"mousedown"),n=o.fromEvent(g.value,"mousemove"),r=o.fromEvent(g.value,"mouseup"),s=o.fromEvent(g.value,"selectstart");t.pipe(o.map(()=>s.pipe(o.takeUntil(r),o.takeUntil(h),o.throttleTime(16))),o.concatAll()).subscribe(c=>c.preventDefault()),t.pipe(o.map(()=>n.pipe(o.takeUntil(r),o.takeUntil(h),o.throttleTime(16))),o.concatAll(),o.withLatestFrom(t),o.map(([c,b])=>{console.log("move!!!",c);const m=c,u=b,S=m.pageX-y.value.left-u.offsetX,M=m.pageY-y.value.top-u.offsetY,I=i.value.clientWidth,P=i.value.clientHeight;return{x:S>0?Math.min(S,I-z.value):Math.max(S,0),y:M>0?Math.min(M,P-T.value):Math.max(M,0)}})).subscribe(c=>{var b,m;if(a.type==="horizontal"){const u=W(c.x);c.x!==v.value&&l.value&&((b=l.value)==null||b.scrollTo({left:u})),v.value=c.x}else{const u=W(c.y);c.y!==f.value&&l.value&&((m=l.value)==null||m.scrollTo({top:u})),f.value=c.y}})},q=()=>{l.value&&o.fromEvent(l.value,"scroll").pipe(o.takeUntil(h)).subscribe(n=>{var s;const r=n.target;r&&a.type==="horizontal"&&(w=r.scrollLeft,v.value=k(w)),r&&a.type==="vertical"&&H!==((s=l==null?void 0:l.value)==null?void 0:s.scrollTop)&&(H=r.scrollTop,f.value=k(H))})},L=()=>{o.fromEvent(window,"resize").pipe(o.takeUntil(h)).subscribe(()=>{B(),e.nextTick(()=>{var n;y.value=(n=i.value)==null?void 0:n.getBoundingClientRect(),C()})})},j=()=>{console.log("targetEle.value",l.value),l.value&&x.value&&(B(),e.nextTick(()=>{var t;y.value=(t=i.value)==null?void 0:t.getBoundingClientRect(),C(),R(),q(),L()}))};e.onMounted(()=>{e.watch(()=>a.target,()=>{e.nextTick(()=>{var t,n;typeof a.target=="string"?l.value=document.querySelector(a.target):l.value=(t=a.target)==null?void 0:t.call(a),g.value=(n=document.getElementsByTagName("body"))==null?void 0:n[0],x.value=document.getElementById("bar"),j()})},{immediate:!0})}),e.onUnmounted(()=>{h.next(0)});const{b:N,e:D,m:_,em:U}=X.useNamespace("ap-scroll-bar");return(t,n)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:i,class:e.normalizeClass(`${e.unref(N)()} ${a.type==="horizontal"?e.unref(_)("horizontal"):e.unref(_)("vertical")}`),style:e.normalizeStyle({display:E.value?"none":"block"})},[e.createElementVNode("div",{id:"bar",class:e.normalizeClass(`${e.unref(D)("bar")} ${a.type==="horizontal"?e.unref(U)("bar","horizontal"):e.unref(U)("bar","vertical")}`),style:e.normalizeStyle(a.type==="horizontal"?{width:`${z.value}px`,left:`${v.value}px`}:{height:`${T.value}px`,top:`${f.value}px`})},null,6)],6))}});exports.default=Y;
@@ -1,29 +0,0 @@
1
- import { CreateComponentPublicInstanceWithMixins, ComponentOptionsMixin, PublicProps, GlobalComponents, GlobalDirectives, ComponentProvideOptions, ComponentOptionsBase, VNodeProps, AllowedComponentProps, ComponentCustomProps, Plugin } from 'vue';
2
- import { ApScrollBarProps } from './interface';
3
- export * from './interface';
4
- declare const ApScrollBar: {
5
- new (...args: any[]): CreateComponentPublicInstanceWithMixins<Readonly< ApScrollBarProps> & Readonly<{}>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, PublicProps, {
6
- type: "horizontal" | "vertical";
7
- }, false, {}, {}, GlobalComponents, GlobalDirectives, string, {
8
- containerRef: HTMLDivElement;
9
- }, HTMLDivElement, ComponentProvideOptions, {
10
- P: {};
11
- B: {};
12
- D: {};
13
- C: {};
14
- M: {};
15
- Defaults: {};
16
- }, Readonly< ApScrollBarProps> & Readonly<{}>, {}, {}, {}, {}, {
17
- type: "horizontal" | "vertical";
18
- }>;
19
- __isFragment?: never;
20
- __isTeleport?: never;
21
- __isSuspense?: never;
22
- } & ComponentOptionsBase<Readonly< ApScrollBarProps> & Readonly<{}>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, {
23
- type: "horizontal" | "vertical";
24
- }, {}, string, {}, GlobalComponents, GlobalDirectives, string, ComponentProvideOptions> & VNodeProps & AllowedComponentProps & ComponentCustomProps & ( Plugin & (new (...args: any[]) => {
25
- $props: {
26
- onClick?: () => void;
27
- };
28
- }));
29
- export { ApScrollBar };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./interface.js");const e=require("@aplus-frontend/utils");require("./ap-scroll-bar.vue.js");const r=require("./ap-scroll-bar.vue2.js"),t=e.withInstall(r.default);exports.ApScrollBar=t;
@@ -1,4 +0,0 @@
1
- export interface ApScrollBarProps {
2
- target: string | (() => Element);
3
- type?: 'horizontal' | 'vertical';
4
- }
@@ -1 +0,0 @@
1
- import '@aplus-frontend/ui/theme/ap-scroll-bar/index.css';
@@ -1 +0,0 @@
1
- import '@aplus-frontend/ui/theme/ap-scroll-bar/index.less';