sard-uniapp 1.19.4 → 1.20.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 (180) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +1 -1
  3. package/components/calendar/README.md +20 -20
  4. package/components/calendar/calendar.vue +1 -1
  5. package/components/calendar-input/README.md +10 -10
  6. package/components/calendar-input/calendar-input.vue +2 -2
  7. package/components/calendar-month/calendar-month.vue +17 -21
  8. package/components/calendar-popout/calendar-popout.vue +1 -1
  9. package/components/card/README.md +16 -8
  10. package/components/card/card.vue +7 -1
  11. package/components/card/common.d.ts +2 -0
  12. package/components/card/index.scss +30 -2
  13. package/components/card/variables.scss +16 -1
  14. package/components/checkbox/common.d.ts +1 -0
  15. package/components/checkbox/common.js +1 -0
  16. package/components/checkbox-input/checkbox-input.vue +9 -0
  17. package/components/checkbox-popout/README.md +27 -6
  18. package/components/checkbox-popout/checkbox-popout.vue +113 -47
  19. package/components/checkbox-popout/common.d.ts +3 -0
  20. package/components/checkbox-popout/index.scss +16 -0
  21. package/components/config/index.d.ts +6 -0
  22. package/components/config/index.js +6 -0
  23. package/components/datetime-picker/README.md +1 -71
  24. package/components/datetime-picker/common.d.ts +1 -0
  25. package/components/datetime-picker/common.js +21 -8
  26. package/components/datetime-picker/datetime-picker.vue +3 -3
  27. package/components/datetime-picker-input/README.md +10 -10
  28. package/components/datetime-picker-input/datetime-picker-input.vue +2 -2
  29. package/components/datetime-picker-popout/datetime-picker-popout.vue +1 -1
  30. package/components/datetime-range-picker/datetime-range-picker.vue +12 -10
  31. package/components/datetime-range-picker-input/README.md +10 -10
  32. package/components/datetime-range-picker-input/datetime-range-picker-input.vue +2 -2
  33. package/components/datetime-range-picker-popout/README.md +0 -6
  34. package/components/datetime-range-picker-popout/datetime-range-picker-popout.vue +11 -8
  35. package/components/floating-bubble/floating-bubble.vue +3 -3
  36. package/components/form/README.md +19 -19
  37. package/components/form/form.vue +2 -4
  38. package/components/form-item/form-item.vue +12 -0
  39. package/components/icon/icon.d.ts +1 -1
  40. package/components/indexes/README.md +4 -0
  41. package/components/indexes-nav/indexes-nav.vue +2 -2
  42. package/components/keyboard/common.d.ts +1 -2
  43. package/components/keyboard/common.js +2 -11
  44. package/components/keyboard/keyboard.d.ts +2 -2
  45. package/components/list-item/index.scss +4 -0
  46. package/components/locale/index.d.ts +4 -0
  47. package/components/locale/index.js +14 -1
  48. package/components/locale/lang/en-US.d.ts +4 -0
  49. package/components/locale/lang/en-US.js +4 -0
  50. package/components/locale/lang/zh-CN.d.ts +4 -0
  51. package/components/locale/lang/zh-CN.js +4 -0
  52. package/components/marquee/README.md +8 -2
  53. package/components/marquee/marquee.vue +9 -1
  54. package/components/notice-bar/README.md +8 -2
  55. package/components/notice-bar/notice-bar.vue +14 -8
  56. package/components/notify/notify.d.ts +1 -1
  57. package/components/notify-agent/notify-agent.d.ts +1 -1
  58. package/components/pagination/pagination.vue +2 -2
  59. package/components/popover/utils.js +4 -4
  60. package/components/pull-down-refresh/common.d.ts +1 -1
  61. package/components/radio/common.d.ts +1 -0
  62. package/components/radio/common.js +1 -0
  63. package/components/radio-input/radio-input.vue +6 -0
  64. package/components/radio-popout/README.md +20 -6
  65. package/components/radio-popout/common.d.ts +2 -0
  66. package/components/radio-popout/index.scss +4 -0
  67. package/components/radio-popout/radio-popout.vue +91 -45
  68. package/components/read-more/README.md +82 -0
  69. package/components/read-more/common.d.ts +24 -0
  70. package/components/read-more/common.js +2 -0
  71. package/components/read-more/index.d.ts +1 -0
  72. package/components/read-more/index.js +1 -0
  73. package/components/read-more/index.scss +41 -0
  74. package/components/read-more/read-more.d.ts +20 -0
  75. package/components/read-more/read-more.vue +168 -0
  76. package/components/read-more/variables.scss +12 -0
  77. package/components/resize-sensor/README.md +55 -0
  78. package/components/resize-sensor/common.d.ts +19 -0
  79. package/components/resize-sensor/common.js +2 -0
  80. package/components/resize-sensor/index.d.ts +1 -0
  81. package/components/resize-sensor/index.js +1 -0
  82. package/components/resize-sensor/index.scss +33 -0
  83. package/components/resize-sensor/resize-sensor.d.ts +16 -0
  84. package/components/resize-sensor/resize-sensor.vue +152 -0
  85. package/components/scroll-list/README.md +79 -0
  86. package/components/scroll-list/common.d.ts +23 -0
  87. package/components/scroll-list/common.js +1 -0
  88. package/components/scroll-list/index.d.ts +1 -0
  89. package/components/scroll-list/index.js +1 -0
  90. package/components/scroll-list/index.scss +35 -0
  91. package/components/scroll-list/scroll-list.d.ts +20 -0
  92. package/components/scroll-list/scroll-list.vue +158 -0
  93. package/components/scroll-list/variables.scss +11 -0
  94. package/components/sidebar/README.md +8 -8
  95. package/components/sidebar/sidebar.vue +1 -1
  96. package/components/slider/slider.vue +4 -4
  97. package/components/stepper/stepper.vue +2 -2
  98. package/components/sticky/README.md +92 -0
  99. package/components/sticky/common.d.ts +15 -0
  100. package/components/sticky/common.js +1 -0
  101. package/components/sticky/index.d.ts +1 -0
  102. package/components/sticky/index.js +1 -0
  103. package/components/sticky/index.scss +18 -0
  104. package/components/sticky/sticky.d.ts +10 -0
  105. package/components/sticky/sticky.vue +190 -0
  106. package/components/sticky-box/common.d.ts +19 -0
  107. package/components/sticky-box/common.js +1 -0
  108. package/components/sticky-box/index.d.ts +1 -0
  109. package/components/sticky-box/index.js +1 -0
  110. package/components/sticky-box/index.scss +19 -0
  111. package/components/sticky-box/sticky-box.d.ts +10 -0
  112. package/components/sticky-box/sticky-box.vue +82 -0
  113. package/components/style/mixins/border.scss +101 -38
  114. package/components/style/variables-dark.scss +4 -0
  115. package/components/style/variables.scss +8 -0
  116. package/components/table/table.vue +2 -1
  117. package/components/table-fixation/table-fixation.vue +2 -1
  118. package/components/toast/toast.d.ts +1 -1
  119. package/components/toast-agent/toast-agent.d.ts +1 -1
  120. package/components/tree/tree.d.ts +1 -1
  121. package/components/tree-node/tree-node.vue +2 -2
  122. package/components/upload/README.md +23 -15
  123. package/components/upload/common.d.ts +6 -4
  124. package/components/upload/upload.d.ts +2 -0
  125. package/components/upload/upload.vue +51 -13
  126. package/components/upload/utils.d.ts +1 -0
  127. package/components/upload/utils.js +2 -0
  128. package/components/upload-preview/index.scss +1 -0
  129. package/components/upload-preview/upload-preview.d.ts +6 -4
  130. package/components/upload-preview/upload-preview.vue +17 -24
  131. package/global.d.ts +5 -0
  132. package/index.d.ts +5 -0
  133. package/index.js +5 -0
  134. package/index.scss +2 -0
  135. package/package.json +4 -2
  136. package/use/index.d.ts +4 -0
  137. package/use/index.js +4 -0
  138. package/use/useIndeterminate.d.ts +10 -0
  139. package/use/useIndeterminate.js +27 -0
  140. package/use/useIntersectionObserver.d.ts +16 -0
  141. package/use/useIntersectionObserver.js +52 -0
  142. package/use/useSimulatedClick.js +2 -2
  143. package/use/useSimulatedPress.js +2 -2
  144. package/use/useSingleTask.d.ts +6 -0
  145. package/use/useSingleTask.js +40 -0
  146. package/use/useWindowResize.d.ts +4 -0
  147. package/use/useWindowResize.js +15 -0
  148. package/utils/array.d.ts +28 -0
  149. package/utils/array.js +90 -0
  150. package/utils/common.d.ts +3 -0
  151. package/utils/common.js +1 -0
  152. package/utils/date.d.ts +84 -11
  153. package/utils/date.js +120 -63
  154. package/utils/dom.js +2 -0
  155. package/utils/geometry.d.ts +56 -38
  156. package/utils/geometry.js +56 -30
  157. package/utils/index.d.ts +8 -1
  158. package/utils/index.js +8 -1
  159. package/utils/is.d.ts +12 -0
  160. package/utils/is.js +16 -0
  161. package/utils/number.d.ts +24 -0
  162. package/utils/number.js +37 -0
  163. package/utils/object.d.ts +29 -0
  164. package/utils/object.js +139 -0
  165. package/utils/persist.d.ts +15 -0
  166. package/utils/persist.js +89 -0
  167. package/utils/physics.d.ts +34 -0
  168. package/utils/physics.js +66 -0
  169. package/utils/request.d.ts +227 -0
  170. package/utils/request.js +249 -0
  171. package/utils/router.d.ts +47 -0
  172. package/utils/router.js +115 -0
  173. package/utils/string.d.ts +46 -0
  174. package/utils/string.js +134 -0
  175. package/utils/url-query.d.ts +19 -0
  176. package/utils/url-query.js +95 -0
  177. package/utils/utils.d.ts +0 -166
  178. package/utils/utils.js +0 -441
  179. package/utils/case.d.ts +0 -4
  180. package/utils/case.js +0 -26
@@ -0,0 +1,19 @@
1
+ import { type NodeRect } from '../../utils';
2
+ import { type StyleValue } from 'vue';
3
+ export interface ResizeSensorProps {
4
+ rootStyle?: StyleValue;
5
+ rootClass?: string;
6
+ initial?: boolean;
7
+ threshold?: number;
8
+ }
9
+ export declare const defaultResizeSensorProps: {
10
+ threshold: number;
11
+ };
12
+ export interface ResizeSensorSlots {
13
+ default?(props: Record<string, never>): any;
14
+ }
15
+ export interface ResizeSensorEmits {
16
+ (e: 'resize', value: NodeRect): void;
17
+ }
18
+ export interface ResizeSensorExpose {
19
+ }
@@ -0,0 +1,2 @@
1
+ import { defaultConfig } from '../config';
2
+ export const defaultResizeSensorProps = defaultConfig.resizeSensor;
@@ -0,0 +1 @@
1
+ export type { ResizeSensorProps, ResizeSensorSlots, ResizeSensorEmits, ResizeSensorExpose, } from './common';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,33 @@
1
+ @use '../style/base' as *;
2
+
3
+ @include bem(resize-sensor) {
4
+ @include b() {
5
+ position: absolute;
6
+ top: 0;
7
+ right: 0;
8
+ bottom: 0;
9
+ left: 0;
10
+ z-index: -9999;
11
+ overflow: hidden;
12
+ pointer-events: none;
13
+ visibility: hidden;
14
+ }
15
+
16
+ @include e(scroll-view) {
17
+ position: absolute;
18
+ top: 0;
19
+ right: 0;
20
+ bottom: 0;
21
+ left: 0;
22
+ }
23
+
24
+ @include e(increase) {
25
+ width: 100000px;
26
+ height: 100000px;
27
+ }
28
+
29
+ @include e(decrease) {
30
+ width: 200%;
31
+ height: 200%;
32
+ }
33
+ }
@@ -0,0 +1,16 @@
1
+ import { type ResizeSensorProps, type ResizeSensorSlots } from './common';
2
+ declare function __VLS_template(): Readonly<ResizeSensorSlots> & ResizeSensorSlots;
3
+ declare const __VLS_component: import("vue").DefineComponent<ResizeSensorProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
4
+ resize: (value: import("../../utils").NodeRect) => any;
5
+ }, string, import("vue").PublicProps, Readonly<ResizeSensorProps> & Readonly<{
6
+ onResize?: ((value: import("../../utils").NodeRect) => any) | undefined;
7
+ }>, {
8
+ threshold: number;
9
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
11
+ export default _default;
12
+ type __VLS_WithTemplateSlots<T, S> = T & {
13
+ new (): {
14
+ $slots: S;
15
+ };
16
+ };
@@ -0,0 +1,152 @@
1
+ <template>
2
+ <view :class="resizeClass" :style="resizeStyle">
3
+ <scroll-view
4
+ :class="bem.e('scroll-view')"
5
+ scroll-x
6
+ scroll-y
7
+ :scroll-left="scrollValue"
8
+ :scroll-top="scrollValue"
9
+ @scroll="onDebouncedScroll"
10
+ >
11
+ <view :class="bem.e('increase')"></view>
12
+ </scroll-view>
13
+ <scroll-view
14
+ :class="bem.e('scroll-view')"
15
+ scroll-x
16
+ scroll-y
17
+ :scroll-left="scrollValue"
18
+ :scroll-top="scrollValue"
19
+ @scroll="onDebouncedScroll"
20
+ >
21
+ <view :class="bem.e('decrease')"></view>
22
+ </scroll-view>
23
+ </view>
24
+ </template>
25
+
26
+ <script>
27
+ import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
28
+ import {
29
+ computed,
30
+ getCurrentInstance,
31
+ nextTick,
32
+ onMounted,
33
+ ref,
34
+ watch
35
+ } from "vue";
36
+ import {
37
+ classNames,
38
+ stringifyStyle,
39
+ createBem,
40
+ uniqid,
41
+ getBoundingClientRect,
42
+ debounce
43
+ } from "../../utils";
44
+ import {
45
+ defaultResizeSensorProps
46
+ } from "./common";
47
+ /**
48
+ * @property {string} rootClass 组件根元素类名,默认值:-。
49
+ * @property {StyleValue} rootStyle 组件根元素样式,默认值:-。
50
+ * @property {boolean} initial 是否在初始化时触发 `resize` 事件,默认值:false。
51
+ * @property {number} threshold 触发 `resize` 事件的阈值,单位毫秒,默认值:150。
52
+ * @event {(value: NodeRect) => void} resize 在元素宽或高发生变化时触发
53
+ */
54
+ export default _defineComponent({
55
+ ...{
56
+ options: {
57
+ virtualHost: true,
58
+ styleIsolation: "shared"
59
+ }
60
+ },
61
+ __name: "resize-sensor",
62
+ props: _mergeDefaults({
63
+ rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
64
+ rootClass: { type: String, required: false },
65
+ initial: { type: Boolean, required: false },
66
+ threshold: { type: Number, required: false }
67
+ }, defaultResizeSensorProps),
68
+ emits: ["resize"],
69
+ setup(__props, { expose: __expose, emit: __emit }) {
70
+ const props = __props;
71
+ const emit = __emit;
72
+ const bem = createBem("resize-sensor");
73
+ const instance = getCurrentInstance();
74
+ const resizeId = uniqid();
75
+ const bounding = ref({
76
+ top: 0,
77
+ right: 0,
78
+ bottom: 0,
79
+ left: 0,
80
+ height: 0,
81
+ width: 0
82
+ });
83
+ let firstTime = true;
84
+ watch(bounding, () => {
85
+ if (!firstTime || props.initial) {
86
+ emit("resize", { ...bounding.value });
87
+ }
88
+ firstTime = false;
89
+ });
90
+ const scrollValue = ref(0);
91
+ let count = 0;
92
+ const reset = () => {
93
+ scrollValue.value = 1e5 + ++count;
94
+ };
95
+ const debouncedUpdate = debounce(
96
+ async () => {
97
+ const rect = await getBoundingClientRect(`.${resizeId}`, instance);
98
+ bounding.value = {
99
+ top: rect.top,
100
+ right: rect.right,
101
+ bottom: rect.bottom,
102
+ left: rect.left,
103
+ height: rect.height,
104
+ width: rect.width
105
+ };
106
+ },
107
+ props.threshold,
108
+ {
109
+ maxWait: 0,
110
+ leading: false,
111
+ trailing: true
112
+ }
113
+ );
114
+ const onDebouncedScroll = debounce(
115
+ () => {
116
+ reset();
117
+ debouncedUpdate();
118
+ },
119
+ 15,
120
+ {
121
+ maxWait: 0,
122
+ leading: true,
123
+ trailing: false
124
+ }
125
+ );
126
+ onMounted(() => {
127
+ nextTick(reset);
128
+ });
129
+ __expose({});
130
+ const resizeClass = computed(() => {
131
+ return classNames(bem.b(), resizeId, props.rootClass);
132
+ });
133
+ const resizeStyle = computed(() => {
134
+ return stringifyStyle(props.rootStyle);
135
+ });
136
+ const __returned__ = { props, emit, bem, instance, resizeId, bounding, get firstTime() {
137
+ return firstTime;
138
+ }, set firstTime(v) {
139
+ firstTime = v;
140
+ }, scrollValue, get count() {
141
+ return count;
142
+ }, set count(v) {
143
+ count = v;
144
+ }, reset, debouncedUpdate, onDebouncedScroll, resizeClass, resizeStyle };
145
+ return __returned__;
146
+ }
147
+ });
148
+ </script>
149
+
150
+ <style lang="scss">
151
+ @import './index.scss';
152
+ </style>
@@ -0,0 +1,79 @@
1
+ ---
2
+ nav: 组件
3
+ title: ScrollList
4
+ subtitle: 横向滚动列表
5
+ group: 数据展示
6
+ version: 1.20+
7
+ ---
8
+
9
+ ## 介绍
10
+
11
+ 给横向滚动容器添加模拟滚动条,一般用于同时展示多个商品、分类列表的场景。
12
+
13
+ ## 引入
14
+
15
+ ```ts
16
+ import ScrollList from 'sard-uniapp/components/scroll-list/scroll-list.vue'
17
+ ```
18
+
19
+ ## 代码演示
20
+
21
+ ### 基础使用
22
+
23
+ 在默认插槽里编写任意内容。
24
+
25
+ @code('${DEMO_PATH}/scroll-list/demo/Basic.vue')
26
+
27
+ ### 滚动条颜色
28
+
29
+ 使用 `scrollbar-bg` 属性设置滚动条背景色,使用 `thumb-bg` 属性设置滑块背景色。
30
+
31
+ 也可以通过 css 变量设置。
32
+
33
+ @code('${DEMO_PATH}/scroll-list/demo/Color.vue')
34
+
35
+ ### 异步获取数据
36
+
37
+ 组件内部能够通过观察滚动内容宽度变化,动态调整滑块的宽度。
38
+
39
+ @code('${DEMO_PATH}/scroll-list/demo/Async.vue')
40
+
41
+ ### 隐藏滚动条
42
+
43
+ 如果滚动内容宽度小于滚动容器的宽度,会自动隐藏滚动条。
44
+
45
+ @code('${DEMO_PATH}/scroll-list/demo/HideThumb.vue')
46
+
47
+ ## API
48
+
49
+ ### ScrollListProps
50
+
51
+ | 属性 | 描述 | 类型 | 默认值 |
52
+ | --------------- | ----------------------------------------------- | ---------- | ------ |
53
+ | root-class | 组件根元素类名 | string | - |
54
+ | root-style | 组件根元素样式 | StyleValue | - |
55
+ | scrollbar-width | 滚动条宽度 | string | - |
56
+ | scrollbar-bg | 滚动条的背景色 | string | - |
57
+ | thumb-bg | 滑块的的背景色 | string | - |
58
+ | upper-threshold | 距左边多远时(单位px),触发 scrolltoupper 事件 | number | 50 |
59
+ | lower-threshold | 距右边多远时(单位px),触发 scrolltolower 事件 | number | 50 |
60
+
61
+ ### ScrollListSlots
62
+
63
+ | 插槽 | 描述 | 属性 |
64
+ | ------- | -------------- | ---- |
65
+ | default | 自定义默认内容 | - |
66
+
67
+ ### ScrollListEmits
68
+
69
+ | 事件 | 描述 | 类型 |
70
+ | ------------- | ---------------- | --------------------- |
71
+ | scroll | 滚动时触发 | ( event: any) => void |
72
+ | scrolltoupper | 滚动到左边时触发 | ( event: any) => void |
73
+ | scrolltolower | 滚动到右边时触发 | ( event: any) => void |
74
+
75
+ ## 主题定制
76
+
77
+ ### CSS 变量
78
+
79
+ @code('./variables.scss#variables')
@@ -0,0 +1,23 @@
1
+ import { type StyleValue } from 'vue';
2
+ export interface ScrollListProps {
3
+ rootStyle?: StyleValue;
4
+ rootClass?: string;
5
+ scrollbarBg?: string;
6
+ scrollbarWidth?: number;
7
+ thumbBg?: string;
8
+ thumbWidth?: number;
9
+ upperThreshold?: number;
10
+ lowerThreshold?: number;
11
+ }
12
+ export declare const defaultScrollListProps: {};
13
+ export interface ScrollListSlots {
14
+ default?(props: Record<string, never>): any;
15
+ }
16
+ export interface ScrollListEmits {
17
+ (e: 'scroll', event: any): void;
18
+ (e: 'scrolltoupper', event: any): void;
19
+ (e: 'scrolltolower', event: any): void;
20
+ }
21
+ export interface ScrollListExpose {
22
+ update: () => Promise<void>;
23
+ }
@@ -0,0 +1 @@
1
+ export const defaultScrollListProps = {};
@@ -0,0 +1 @@
1
+ export type { ScrollListProps, ScrollListSlots, ScrollListEmits, ScrollListExpose, } from './common';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ @use '../style/base' as *;
2
+
3
+ @include bem(scroll-list) {
4
+ @include b() {
5
+ @include universal;
6
+ }
7
+
8
+ @include e(content) {
9
+ @include universal;
10
+ display: inline-flex;
11
+ flex-direction: row;
12
+ }
13
+
14
+ @include e(scrollbar) {
15
+ @include universal;
16
+ width: var(--sar-scroll-list-scrollbar-width);
17
+ height: var(--sar-scroll-list-scrollbar-height);
18
+ margin-top: var(--sar-scroll-list-scrollbar-margin-top);
19
+ margin-left: auto;
20
+ margin-right: auto;
21
+ border-radius: var(--sar-rounded-full);
22
+ background-color: var(--sar-scroll-list-scrollbar-bg);
23
+ }
24
+
25
+ @include e(scrollbar-thumb) {
26
+ @include universal;
27
+ top: 0;
28
+ left: 0;
29
+ position: absolute;
30
+ width: var(--sar-scroll-list-scrollbar-thumb-width);
31
+ height: 100%;
32
+ border-radius: var(--sar-rounded-full);
33
+ background-color: var(--sar-scroll-list-scrollbar-thumb-bg);
34
+ }
35
+ }
@@ -0,0 +1,20 @@
1
+ import { type ScrollListProps, type ScrollListSlots } from './common';
2
+ declare function __VLS_template(): Readonly<ScrollListSlots> & ScrollListSlots;
3
+ declare const __VLS_component: import("vue").DefineComponent<ScrollListProps, {
4
+ update: () => Promise<void>;
5
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
6
+ scroll: (event: any) => any;
7
+ scrolltoupper: (event: any) => any;
8
+ scrolltolower: (event: any) => any;
9
+ }, string, import("vue").PublicProps, Readonly<ScrollListProps> & Readonly<{
10
+ onScroll?: ((event: any) => any) | undefined;
11
+ onScrolltoupper?: ((event: any) => any) | undefined;
12
+ onScrolltolower?: ((event: any) => any) | undefined;
13
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
15
+ export default _default;
16
+ type __VLS_WithTemplateSlots<T, S> = T & {
17
+ new (): {
18
+ $slots: S;
19
+ };
20
+ };
@@ -0,0 +1,158 @@
1
+ <template>
2
+ <view :class="scrollListClass" :style="scrollListStyle">
3
+ <scroll-view
4
+ scroll-x
5
+ :class="bem.e('scroll-view')"
6
+ :upper-threshold="upperThreshold"
7
+ :lower-threshold="lowerThreshold"
8
+ @scroll="onScroll"
9
+ @scrolltoupper="onScrolltoupper"
10
+ @scrolltolower="onScrolltolower"
11
+ >
12
+ <view :id="contentId" :class="bem.e('content')">
13
+ <slot></slot>
14
+ <sar-resize-sensor initial :threshold="0" @resize="onResize" />
15
+ </view>
16
+ </scroll-view>
17
+ <view
18
+ v-if="!hideScrollbar"
19
+ :class="bem.e('scrollbar')"
20
+ :style="scrollbarStyle"
21
+ >
22
+ <view :class="bem.e('scrollbar-thumb')" :style="thumbStyle"></view>
23
+ </view>
24
+ </view>
25
+ </template>
26
+
27
+ <script>
28
+ import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
29
+ import { computed, getCurrentInstance, ref } from "vue";
30
+ import {
31
+ classNames,
32
+ stringifyStyle,
33
+ createBem,
34
+ uniqid,
35
+ getBoundingClientRect,
36
+ debounce
37
+ } from "../../utils";
38
+ import SarResizeSensor from "../resize-sensor/resize-sensor.vue";
39
+ import {
40
+ defaultScrollListProps
41
+ } from "./common";
42
+ import { useWindowResize } from "../../use";
43
+ /**
44
+ * @property {string} rootClass 组件根元素类名,默认值:-。
45
+ * @property {StyleValue} rootStyle 组件根元素样式,默认值:-。
46
+ * @property {string} scrollbarWidth 滚动条宽度,默认值:-。
47
+ * @property {string} scrollbarBg 滚动条的背景色,默认值:-。
48
+ * @property {string} thumbBg 滑块的的背景色,默认值:-。
49
+ * @property {number} upperThreshold 距左边多远时(单位px),触发 scrolltoupper 事件,默认值:50。
50
+ * @property {number} lowerThreshold 距右边多远时(单位px),触发 scrolltolower 事件,默认值:50。
51
+ * @event {( event: any) => void} scroll 滚动时触发
52
+ * @event {( event: any) => void} scrolltoupper 滚动到左边时触发
53
+ * @event {( event: any) => void} scrolltolower 滚动到右边时触发
54
+ */
55
+ export default _defineComponent({
56
+ components: {
57
+ SarResizeSensor,
58
+ },
59
+ ...{
60
+ options: {
61
+ virtualHost: true,
62
+ styleIsolation: "shared"
63
+ }
64
+ },
65
+ __name: "scroll-list",
66
+ props: _mergeDefaults({
67
+ rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
68
+ rootClass: { type: String, required: false },
69
+ scrollbarBg: { type: String, required: false },
70
+ scrollbarWidth: { type: Number, required: false },
71
+ thumbBg: { type: String, required: false },
72
+ thumbWidth: { type: Number, required: false },
73
+ upperThreshold: { type: Number, required: false },
74
+ lowerThreshold: { type: Number, required: false }
75
+ }, defaultScrollListProps),
76
+ emits: ["scroll", "scrolltoupper", "scrolltolower"],
77
+ setup(__props, { expose: __expose, emit: __emit }) {
78
+ const props = __props;
79
+ const emit = __emit;
80
+ const bem = createBem("scroll-list");
81
+ const scrollListId = uniqid();
82
+ const contentId = uniqid();
83
+ const instance = getCurrentInstance();
84
+ const scrollLeft = ref(0);
85
+ const scrollWidth = ref(0);
86
+ const clientWidth = ref(0);
87
+ const update = debounce(
88
+ async () => {
89
+ const scrollListRect = await getBoundingClientRect(
90
+ `.${scrollListId}`,
91
+ instance
92
+ );
93
+ clientWidth.value = scrollListRect.width;
94
+ const contentRect = await getBoundingClientRect(`#${contentId}`, instance);
95
+ scrollWidth.value = contentRect.width;
96
+ },
97
+ 50,
98
+ {
99
+ leading: false,
100
+ trailing: true
101
+ }
102
+ );
103
+ useWindowResize(update);
104
+ const onResize = () => {
105
+ update();
106
+ };
107
+ const onScroll = (event) => {
108
+ scrollLeft.value = event.detail.scrollLeft;
109
+ scrollWidth.value = event.detail.scrollWidth;
110
+ emit("scroll", event);
111
+ };
112
+ const onScrolltoupper = (event) => {
113
+ emit("scrolltoupper", event);
114
+ };
115
+ const onScrolltolower = (event) => {
116
+ emit("scrolltolower", event);
117
+ };
118
+ __expose({ update });
119
+ const scrollListClass = computed(() => {
120
+ return classNames(bem.b(), scrollListId, props.rootClass);
121
+ });
122
+ const scrollListStyle = computed(() => {
123
+ return stringifyStyle(props.rootStyle);
124
+ });
125
+ const scrollbarStyle = computed(() => {
126
+ return {
127
+ width: props.scrollbarWidth || "",
128
+ backgroundColor: props.scrollbarBg
129
+ };
130
+ });
131
+ const thumbWidth = computed(() => {
132
+ let width = clientWidth.value / scrollWidth.value;
133
+ if (!Number.isFinite(width)) {
134
+ width = 0;
135
+ }
136
+ return width;
137
+ });
138
+ const hideScrollbar = computed(() => thumbWidth.value >= 1);
139
+ const thumbStyle = computed(() => {
140
+ let left = scrollLeft.value / scrollWidth.value;
141
+ if (!Number.isFinite(left)) {
142
+ left = 0;
143
+ }
144
+ return {
145
+ left: left * 100 + "%",
146
+ width: thumbWidth.value * 100 + "%",
147
+ backgroundColor: props.thumbBg
148
+ };
149
+ });
150
+ const __returned__ = { props, emit, bem, scrollListId, contentId, instance, scrollLeft, scrollWidth, clientWidth, update, onResize, onScroll, onScrolltoupper, onScrolltolower, scrollListClass, scrollListStyle, scrollbarStyle, thumbWidth, hideScrollbar, thumbStyle, SarResizeSensor };
151
+ return __returned__;
152
+ }
153
+ });
154
+ </script>
155
+
156
+ <style lang="scss">
157
+ @import './index.scss';
158
+ </style>
@@ -0,0 +1,11 @@
1
+ // #variables
2
+ page,
3
+ .sar-portal {
4
+ --sar-scroll-list-scrollbar-width: 100rpx;
5
+ --sar-scroll-list-scrollbar-height: 8rpx;
6
+ --sar-scroll-list-scrollbar-margin-top: 32rpx;
7
+ --sar-scroll-list-scrollbar-bg: var(--sar-tertiary-bg);
8
+ --sar-scroll-list-scrollbar-thumb-width: 40rpx;
9
+ --sar-scroll-list-scrollbar-thumb-bg: var(--sar-primary);
10
+ }
11
+ // #endvariables
@@ -67,14 +67,14 @@ import SidebarItem from 'sard-uniapp/components/sidebar-item/sidebar-item.vue'
67
67
 
68
68
  ### SidebarProps
69
69
 
70
- | 属性 | 描述 | 类型 | 默认值 |
71
- | ------------------------ | -------------------------- | ---------------------------------------------------------- | --------------------------------------------------- |
72
- | root-class | 组件根元素类名 | string | - |
73
- | root-style | 组件根元素样式 | StyleValue | - |
74
- | current | 当前绑定导航项的名称 | string \| number | - |
75
- | round | 当前导航项是否显示为圆角 | boolean | false |
76
- | line | 当前导航项是否添加左边线条 | boolean | false |
77
- | scroll-into-view-options | 自定义滚动配置选项 | [ScrollIntoViewOptions](../guide/scroll-into-view-options) | {position: 'nearest', startOffset: 0, endOffset: 0} |
70
+ | 属性 | 描述 | 类型 | 默认值 |
71
+ | ------------------------ | -------------------------- | -------------------------------------------------------------------- | --------------------------------------------------- |
72
+ | root-class | 组件根元素类名 | string | - |
73
+ | root-style | 组件根元素样式 | StyleValue | - |
74
+ | current | 当前绑定导航项的名称 | string \| number | - |
75
+ | round | 当前导航项是否显示为圆角 | boolean | false |
76
+ | line | 当前导航项是否添加左边线条 | boolean | false |
77
+ | scroll-into-view-options | 自定义滚动配置选项 | [ScrollIntoViewOptions](../utilities/geometry#ScrollIntoViewOptions) | {position: 'nearest', startOffset: 0, endOffset: 0} |
78
78
 
79
79
  ### SidebarSlots
80
80
 
@@ -41,7 +41,7 @@ import {
41
41
  * @property {string | number} current 当前绑定导航项的名称,默认值:-。
42
42
  * @property {boolean} round 当前导航项是否显示为圆角,默认值:false。
43
43
  * @property {boolean} line 当前导航项是否添加左边线条,默认值:false。
44
- * @property {[ScrollIntoViewOptions](../guide/scroll-into-view-options)} scrollIntoViewOptions 自定义滚动配置选项,默认值:{position: 'nearest', startOffset: 0, endOffset: 0}。
44
+ * @property {[ScrollIntoViewOptions](../utilities/geometry#ScrollIntoViewOptions)} scrollIntoViewOptions 自定义滚动配置选项,默认值:{position: 'nearest', startOffset: 0, endOffset: 0}。
45
45
  * @event {(name: string | number) => void} update 当前导航项改变时触发
46
46
  * @event {(name: string | number) => void} change 当前导航项改变时触发
47
47
  */
@@ -88,7 +88,7 @@ import {
88
88
  createBem,
89
89
  uniqid,
90
90
  getBoundingClientRect,
91
- minmax,
91
+ clamp,
92
92
  mround,
93
93
  arrayEqual,
94
94
  toArray
@@ -196,7 +196,7 @@ export default _defineComponent({
196
196
  if (isDisabled.value || isReadonly.value) {
197
197
  return;
198
198
  }
199
- const { clientY, clientX } = "touches" in event ? event.touches[0] : event;
199
+ const { clientY, clientX } = "touches" in event ? event.touches[0] : "detail" in event && "clientX" in event.detail ? event.detail : event;
200
200
  trackRect = await getBoundingClientRect(`#${trackId}`, instance);
201
201
  const trackSize = props.vertical ? trackRect.height : trackRect.width;
202
202
  const tapCoord = props.vertical ? clientY : clientX;
@@ -204,7 +204,7 @@ export default _defineComponent({
204
204
  const offset = tapCoord - startCoord;
205
205
  const ratio = offset / trackSize;
206
206
  const total = props.max - props.min;
207
- const tapValue = minmax(
207
+ const tapValue = clamp(
208
208
  mround(props.min + total * ratio, props.step),
209
209
  props.min,
210
210
  props.max
@@ -268,7 +268,7 @@ export default _defineComponent({
268
268
  const delta = props.vertical ? deltaY : deltaX;
269
269
  const ratio = delta / trackSize + downRatio;
270
270
  const total = props.max - props.min;
271
- const tapValue = minmax(
271
+ const tapValue = clamp(
272
272
  mround(props.min + total * ratio, props.step),
273
273
  props.min,
274
274
  props.max
@@ -57,7 +57,7 @@ import {
57
57
  stringifyStyle,
58
58
  createBem,
59
59
  isNullish,
60
- minmax
60
+ clamp
61
61
  } from "../../utils";
62
62
  import SarIcon from "../icon/icon.vue";
63
63
  import { useFormContext, useFormItemContext } from "../form/common";
@@ -155,7 +155,7 @@ export default _defineComponent({
155
155
  inputValue.value = value;
156
156
  };
157
157
  const normalizedValue = (value) => {
158
- value = minmax(value, props.min, props.max);
158
+ value = clamp(value, props.min, props.max);
159
159
  if (props.precision !== void 0) {
160
160
  value = +value.toFixed(props.precision);
161
161
  }