sard-uniapp 1.20.1 → 1.21.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 (81) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +3 -2
  3. package/components/config/index.d.ts +5 -0
  4. package/components/config/index.js +5 -0
  5. package/components/crop-image-agent/common.js +1 -1
  6. package/components/crop-image-agent/crop-image-agent.vue +1 -1
  7. package/components/dialog/README.md +19 -3
  8. package/components/dialog/common.d.ts +0 -1
  9. package/components/dialog/dialog.vue +1 -2
  10. package/components/dialog-agent/common.d.ts +5 -2
  11. package/components/dialog-agent/common.js +2 -2
  12. package/components/dialog-agent/dialog-agent.d.ts +7 -1
  13. package/components/dialog-agent/dialog-agent.vue +123 -9
  14. package/components/dialog-agent/index.d.ts +1 -1
  15. package/components/dialog-agent/index.js +1 -1
  16. package/components/fab/README.md +6 -0
  17. package/components/fab/fab.vue +1 -1
  18. package/components/list/README.md +19 -12
  19. package/components/list/common.d.ts +6 -1
  20. package/components/list/common.js +1 -0
  21. package/components/list/index.scss +8 -0
  22. package/components/list/list.vue +12 -2
  23. package/components/list-item/index.scss +6 -0
  24. package/components/list-item/list-item.vue +6 -3
  25. package/components/locale/lang/en-US.js +1 -1
  26. package/components/locale/lang/zh-CN.js +1 -1
  27. package/components/notify/README.md +38 -3
  28. package/components/notify/common.d.ts +5 -1
  29. package/components/notify/index.d.ts +1 -1
  30. package/components/notify/notify.d.ts +14 -7
  31. package/components/notify/notify.vue +25 -4
  32. package/components/notify-agent/common.d.ts +5 -2
  33. package/components/notify-agent/common.js +2 -2
  34. package/components/notify-agent/index.d.ts +1 -1
  35. package/components/notify-agent/index.js +1 -1
  36. package/components/notify-agent/notify-agent.d.ts +7 -1
  37. package/components/notify-agent/notify-agent.vue +90 -5
  38. package/components/popup/common.d.ts +11 -0
  39. package/components/toast/README.md +28 -6
  40. package/components/toast/common.d.ts +2 -1
  41. package/components/toast/toast.d.ts +5 -3
  42. package/components/toast/toast.vue +17 -3
  43. package/components/toast-agent/common.d.ts +5 -2
  44. package/components/toast-agent/common.js +2 -2
  45. package/components/toast-agent/index.d.ts +1 -1
  46. package/components/toast-agent/index.js +1 -1
  47. package/components/toast-agent/toast-agent.d.ts +7 -1
  48. package/components/toast-agent/toast-agent.vue +85 -5
  49. package/components/upload/README.md +31 -23
  50. package/components/upload/common.d.ts +4 -1
  51. package/components/upload/upload.vue +4 -4
  52. package/components/waterfall/README.md +162 -0
  53. package/components/waterfall/common.d.ts +32 -0
  54. package/components/waterfall/common.js +3 -0
  55. package/components/waterfall/index.d.ts +1 -0
  56. package/components/waterfall/index.js +1 -0
  57. package/components/waterfall/index.scss +7 -0
  58. package/components/waterfall/test/SimulatedImage.vue +53 -0
  59. package/components/waterfall/variables.scss +6 -0
  60. package/components/waterfall/waterfall.d.ts +23 -0
  61. package/components/waterfall/waterfall.vue +182 -0
  62. package/components/waterfall-item/common.d.ts +23 -0
  63. package/components/waterfall-item/common.js +1 -0
  64. package/components/waterfall-item/index.d.ts +1 -0
  65. package/components/waterfall-item/index.js +1 -0
  66. package/components/waterfall-item/index.scss +18 -0
  67. package/components/waterfall-item/waterfall-item.d.ts +10 -0
  68. package/components/waterfall-item/waterfall-item.vue +115 -0
  69. package/components/waterfall-load/common.d.ts +19 -0
  70. package/components/waterfall-load/common.js +1 -0
  71. package/components/waterfall-load/index.d.ts +1 -0
  72. package/components/waterfall-load/index.js +1 -0
  73. package/components/waterfall-load/index.scss +12 -0
  74. package/components/waterfall-load/waterfall-load.d.ts +14 -0
  75. package/components/waterfall-load/waterfall-load.vue +87 -0
  76. package/global.d.ts +3 -0
  77. package/index.d.ts +3 -0
  78. package/index.js +3 -0
  79. package/index.scss +1 -0
  80. package/package.json +1 -1
  81. package/utils/utils.d.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,29 @@
1
+ # [1.21.0](https://github.com/sutras/sard-uniapp/compare/v1.20.2...v1.21.0) (2025-07-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * upload组件修改beforeChoose,多返回一个参数sourceType,用于区分当前选择项 ([d440c7e](https://github.com/sutras/sard-uniapp/commit/d440c7e166db4987507e642bda8d3fb6aa2a4c9b))
7
+ * 修复 fab 图标设置失败问题 ([da00f11](https://github.com/sutras/sard-uniapp/commit/da00f11ce8cd19ab712572d106ce94856739a228))
8
+
9
+
10
+ ### Features
11
+
12
+ * list 新增隐藏边框属性 ([6fbab69](https://github.com/sutras/sard-uniapp/commit/6fbab69ad4e637bc1bb12dea360e12413e398c74))
13
+ * upload组件选择前置允许配置 ([5f2a753](https://github.com/sutras/sard-uniapp/commit/5f2a7538f985a85226e52c19aa11699fa1c6aa9f))
14
+ * 新增瀑布流组件 ([8da700b](https://github.com/sutras/sard-uniapp/commit/8da700b367a63725f074d4431ac72e26b3e64cae))
15
+
16
+
17
+
18
+ ## [1.20.2](https://github.com/sutras/sard-uniapp/compare/v1.20.1...v1.20.2) (2025-07-02)
19
+
20
+
21
+ ### Features
22
+
23
+ * dialog, notify, toast 新增事件 ([54e5c4b](https://github.com/sutras/sard-uniapp/commit/54e5c4b8c8240df6dd77edb01bfee9e8ecabae96))
24
+
25
+
26
+
1
27
  ## [1.20.1](https://github.com/sutras/sard-uniapp/compare/v1.20.0...v1.20.1) (2025-07-02)
2
28
 
3
29
 
package/README.md CHANGED
@@ -25,7 +25,7 @@
25
25
 
26
26
  ## 特性
27
27
 
28
- - 🧩 95+个高质量组件,覆盖移动端主流场景
28
+ - 🧩 96+个高质量组件,覆盖移动端主流场景
29
29
  - 💪 支持一套代码同时开发 H5 / 小程序 / App
30
30
  - 🌿 支持按需引入和 `Tree Shaking`
31
31
  - 📖 详尽的文档和案例展示
@@ -49,7 +49,8 @@
49
49
  ### 前提条件
50
50
 
51
51
  - 确保 node >= 20
52
- - 建议使用 pnpm
52
+ - 建议使用 pnpm 包管理器
53
+ - 建议使用 vscode 编辑器
53
54
 
54
55
  ### 克隆仓库到本地
55
56
 
@@ -479,6 +479,11 @@ export declare const defaultConfig: {
479
479
  uploadPreview: {
480
480
  status: UploadPreviewProps["status"];
481
481
  };
482
+ waterfall: {
483
+ columns: number;
484
+ columnGap: number;
485
+ rowGap: number;
486
+ };
482
487
  };
483
488
  export type ConfigOptions = typeof defaultConfig;
484
489
  export declare function setConfig(...optionsArgs: DeepPartial<ConfigOptions>[]): void;
@@ -433,6 +433,11 @@ export const defaultConfig = {
433
433
  uploadPreview: {
434
434
  status: 'pending',
435
435
  },
436
+ waterfall: {
437
+ columns: 2,
438
+ columnGap: 16,
439
+ rowGap: 16,
440
+ },
436
441
  };
437
442
  function extendProps(source, target) {
438
443
  Object.keys(target).forEach((key) => {
@@ -1,4 +1,4 @@
1
- import { getAvailableImperative } from '../../use/useImperative';
1
+ import { getAvailableImperative } from '../../use';
2
2
  import { defaultConfig } from '../config';
3
3
  import { defaultCropImageProps } from '../crop-image/common';
4
4
  export const defaultCropImageAgentProps = () => ({
@@ -10,7 +10,7 @@ import {
10
10
  defaultCropImageAgentProps,
11
11
  imperativeName
12
12
  } from "./common";
13
- import { useImperative } from "../../use/useImperative";
13
+ import { useImperative } from "../../use";
14
14
  export default _defineComponent({
15
15
  components: {
16
16
  SarCropImage,
@@ -139,9 +139,25 @@ type DialogBeforeClose = (
139
139
 
140
140
  继承 [`DialogProps`](#DialogProps) 并有以下额外属性。
141
141
 
142
- | 属性 | 描述 | 类型 | 默认值 |
143
- | ---- | --------------- | ------ | -------- |
144
- | id | 对话框组件的 id | string | 'dialog' |
142
+ | 属性 | 描述 | 类型 | 默认值 |
143
+ | ----------------------------------- | --------------------------- | ---------------------------------- | -------- |
144
+ | id | 对话框组件的 id | string | 'dialog' |
145
+ | onClose <sup>1.20.2+</sup> | 点击关闭按钮或遮罩时调用 | () => void |
146
+ | onCancel <sup>1.20.2+</sup> | 点击取消按钮时调用 | () => void |
147
+ | onConfirm <sup>1.20.2+</sup> | 点击确定按钮时调用 | () => void |
148
+ | onVisibleHook <sup>1.20.2+</sup> | 入场/退场动画状态改变时调用 | (name: TransitionHookName) => void |
149
+ | onBeforeEnter <sup>1.20.2+</sup> | 入场动画开始前调用 | () => void |
150
+ | onEnter <sup>1.20.2+</sup> | 入场动画开始时调用 | () => void |
151
+ | onAfterEnter <sup>1.20.2+</sup> | 入场动画结束时调用 | () => void |
152
+ | onEnterCancelled <sup>1.20.2+</sup> | 入场动画取消时调用 | () => void |
153
+ | onBeforeLeave <sup>1.20.2+</sup> | 退场动画开始前调用 | () => void |
154
+ | onLeave <sup>1.20.2+</sup> | 退场动画开始时调用 | () => void |
155
+ | onAfterLeave <sup>1.20.2+</sup> | 退场动画结束时调用 | () => void |
156
+ | onLeaveCancelled <sup>1.20.2+</sup> | 退场动画取消时调用 | () => void |
157
+
158
+ ### DialogAgentEmits <sup>1.20.2+</sup>
159
+
160
+ 继承 [`DialogEmits`](#DialogEmits)。
145
161
 
146
162
  ### 命令式方法
147
163
 
@@ -25,7 +25,6 @@ export interface DialogProps {
25
25
  duration?: number;
26
26
  cancelProps?: ButtonProps;
27
27
  confirmProps?: ButtonProps;
28
- id?: string;
29
28
  }
30
29
  export declare const defaultDialogProps: {
31
30
  headed: boolean;
@@ -156,8 +156,7 @@ export default _defineComponent({
156
156
  beforeClose: { type: Function, required: false },
157
157
  duration: { type: Number, required: false },
158
158
  cancelProps: { type: Object, required: false },
159
- confirmProps: { type: Object, required: false },
160
- id: { type: String, required: false }
159
+ confirmProps: { type: Object, required: false }
161
160
  }, defaultDialogProps),
162
161
  emits: ["update:visible", "close", "cancel", "confirm", "before-enter", "enter", "after-enter", "enter-cancelled", "before-leave", "leave", "after-leave", "leave-cancelled", "visible-hook"],
163
162
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -1,5 +1,6 @@
1
- import { type DialogProps } from '../dialog/common';
2
- export interface DialogAgentProps extends DialogProps {
1
+ import { type DialogEmits, type DialogProps } from '../dialog/common';
2
+ import { type TransitionHookCallbacks } from '../popup/common';
3
+ export interface DialogAgentProps extends DialogProps, TransitionHookCallbacks {
3
4
  id?: string;
4
5
  onClose?: () => void;
5
6
  onCancel?: () => void;
@@ -14,6 +15,8 @@ export declare const defaultDialogAgentProps: () => {
14
15
  overlayClosable: boolean;
15
16
  duration: number;
16
17
  };
18
+ export interface DialogAgentEmits extends DialogEmits {
19
+ }
17
20
  export declare const imperativeName = "dialog";
18
21
  export interface DialogImperative {
19
22
  show(newProps: Record<string, any>): void;
@@ -1,6 +1,6 @@
1
- import { defaultDialogProps } from '../dialog/common';
1
+ import { defaultDialogProps, } from '../dialog/common';
2
2
  import { defaultConfig } from '../config';
3
- import { getAllImperatives, getAvailableImperative, getImperatives, } from '../../use/useImperative';
3
+ import { getAllImperatives, getAvailableImperative, getImperatives, } from '../../use';
4
4
  export const defaultDialogAgentProps = () => ({
5
5
  ...defaultDialogProps,
6
6
  ...defaultConfig.dialogAgent,
@@ -1,5 +1,11 @@
1
1
  import { type DialogAgentProps } from './common';
2
- declare const _default: import("vue").DefineComponent<DialogAgentProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<DialogAgentProps> & Readonly<{}>, {
2
+ declare const _default: import("vue").DefineComponent<DialogAgentProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
3
+ [x: string]: any;
4
+ } & {
5
+ [x: string]: any;
6
+ }, string, import("vue").PublicProps, Readonly<DialogAgentProps> & Readonly<{
7
+ [x: `on${Capitalize<any>}`]: ((...args: any) => any) | undefined;
8
+ }>, {
3
9
  id: string;
4
10
  buttonType: "round" | "text";
5
11
  showConfirm: boolean;
@@ -1,10 +1,36 @@
1
1
  <template>
2
2
  <sar-dialog
3
- v-bind="innerProps"
4
- v-model:visible="innerProps.visible"
5
- @confirm="innerProps.onConfirm"
6
- @close="innerProps.onClose"
7
- @cancel="innerProps.onCancel"
3
+ :root-style="innerProps.rootStyle"
4
+ :root-class="innerProps.rootClass"
5
+ :popup-style="innerProps.popupStyle"
6
+ :popup-class="innerProps.popupClass"
7
+ :visible="innerProps.visible"
8
+ :title="innerProps.title"
9
+ :message="innerProps.message"
10
+ :headed="innerProps.headed"
11
+ :button-type="innerProps.buttonType"
12
+ :show-cancel="innerProps.showCancel"
13
+ :cancel-text="innerProps.cancelText"
14
+ :show-confirm="innerProps.showConfirm"
15
+ :confirm-text="innerProps.confirmText"
16
+ :overlay-closable="innerProps.overlayClosable"
17
+ :before-close="innerProps.beforeClose"
18
+ :duration="innerProps.duration"
19
+ :cancel-props="innerProps.cancelProps"
20
+ :confirm-props="innerProps.confirmProps"
21
+ @update:visible="onUpdateVisible"
22
+ @confirm="onConfirm"
23
+ @close="onClose"
24
+ @cancel="onCancel"
25
+ @visible-hook="onVisibleHook"
26
+ @before-enter="onBeforeEnter"
27
+ @enter="onEnter"
28
+ @after-enter="onAfterEnter"
29
+ @enter-cancelled="onEnterCancelled"
30
+ @before-leave="onBeforeLeave"
31
+ @leave="onLeave"
32
+ @after-leave="onAfterLeave"
33
+ @leave-cancelled="onLeaveCancelled"
8
34
  />
9
35
  </template>
10
36
 
@@ -16,7 +42,7 @@ import {
16
42
  defaultDialogAgentProps,
17
43
  imperativeName
18
44
  } from "./common";
19
- import { useImperative } from "../../use/useImperative";
45
+ import { useImperative } from "../../use";
20
46
  /**
21
47
  * @property {string} rootClass 对话框根元素类名,默认值:-。
22
48
  * @property {StyleValue} rootStyle 对话框根元素样式,默认值:-。
@@ -37,6 +63,31 @@ import { useImperative } from "../../use/useImperative";
37
63
  * @property {ButtonProps} confirmProps 设置确定按钮 props,默认值:-。
38
64
  * @property {ButtonProps} cancelProps 设置取消按钮 props,默认值:-。
39
65
  * @property {string} id 对话框组件的 id,默认值:'dialog'。
66
+ * @property {() => void} onClose 点击关闭按钮或遮罩时调用,默认值:undefined。
67
+ * @property {() => void} onCancel 点击取消按钮时调用,默认值:undefined。
68
+ * @property {() => void} onConfirm 点击确定按钮时调用,默认值:undefined。
69
+ * @property {(name: TransitionHookName) => void} onVisibleHook 入场/退场动画状态改变时调用,默认值:undefined。
70
+ * @property {() => void} onBeforeEnter 入场动画开始前调用,默认值:undefined。
71
+ * @property {() => void} onEnter 入场动画开始时调用,默认值:undefined。
72
+ * @property {() => void} onAfterEnter 入场动画结束时调用,默认值:undefined。
73
+ * @property {() => void} onEnterCancelled 入场动画取消时调用,默认值:undefined。
74
+ * @property {() => void} onBeforeLeave 退场动画开始前调用,默认值:undefined。
75
+ * @property {() => void} onLeave 退场动画开始时调用,默认值:undefined。
76
+ * @property {() => void} onAfterLeave 退场动画结束时调用,默认值:undefined。
77
+ * @property {() => void} onLeaveCancelled 退场动画取消时调用,默认值:undefined。
78
+ * @event {(visible: boolean) => void} update 对话框显隐时触发
79
+ * @event {() => void} close 点击关闭按钮或遮罩时触发
80
+ * @event {() => void} cancel 点击取消按钮时触发
81
+ * @event {() => void} confirm 点击确定按钮时触发
82
+ * @event {(name: TransitionHookName) => void} visible-hook 入场/退场动画状态改变时触发
83
+ * @event {() => void} before-enter 入场动画开始前触发
84
+ * @event {() => void} enter 入场动画开始时触发
85
+ * @event {() => void} after-enter 入场动画结束时触发
86
+ * @event {() => void} enter-cancelled 入场动画取消时触发
87
+ * @event {() => void} before-leave 退场动画开始前触发
88
+ * @event {() => void} leave 退场动画开始时触发
89
+ * @event {() => void} after-leave 退场动画结束时触发
90
+ * @event {() => void} leave-cancelled 退场动画取消时触发
40
91
  */
41
92
  export default _defineComponent({
42
93
  components: {
@@ -71,11 +122,22 @@ export default _defineComponent({
71
122
  beforeClose: { type: Function, required: false },
72
123
  duration: { type: Number, required: false },
73
124
  cancelProps: { type: Object, required: false },
74
- confirmProps: { type: Object, required: false }
125
+ confirmProps: { type: Object, required: false },
126
+ onVisibleHook: { type: Function, required: false },
127
+ onBeforeEnter: { type: Function, required: false },
128
+ onEnter: { type: Function, required: false },
129
+ onAfterEnter: { type: Function, required: false },
130
+ onEnterCancelled: { type: Function, required: false },
131
+ onBeforeLeave: { type: Function, required: false },
132
+ onLeave: { type: Function, required: false },
133
+ onAfterLeave: { type: Function, required: false },
134
+ onLeaveCancelled: { type: Function, required: false }
75
135
  }, defaultDialogAgentProps()),
76
- setup(__props, { expose: __expose }) {
136
+ emits: ["update:visible", "close", "cancel", "confirm", "before-enter", "enter", "after-enter", "enter-cancelled", "before-leave", "leave", "after-leave", "leave-cancelled", "visible-hook"],
137
+ setup(__props, { expose: __expose, emit: __emit }) {
77
138
  __expose();
78
139
  const props = __props;
140
+ const emit = __emit;
79
141
  const innerProps = ref({ ...props });
80
142
  const imperative = {
81
143
  show(newProps) {
@@ -92,12 +154,64 @@ export default _defineComponent({
92
154
  };
93
155
  }
94
156
  };
157
+ const onConfirm = () => {
158
+ emit("confirm");
159
+ innerProps.value.onConfirm?.();
160
+ };
161
+ const onClose = () => {
162
+ emit("close");
163
+ innerProps.value.onClose?.();
164
+ };
165
+ const onCancel = () => {
166
+ emit("cancel");
167
+ innerProps.value.onCancel?.();
168
+ };
169
+ const onUpdateVisible = (visible) => {
170
+ innerProps.value.visible = visible;
171
+ emit("update:visible", visible);
172
+ };
173
+ const onVisibleHook = (name) => {
174
+ emit("visible-hook", name);
175
+ innerProps.value.onVisibleHook?.(name);
176
+ };
177
+ const onBeforeEnter = () => {
178
+ emit("before-enter");
179
+ innerProps.value.onBeforeEnter?.();
180
+ };
181
+ const onEnter = () => {
182
+ emit("enter");
183
+ innerProps.value.onEnter?.();
184
+ };
185
+ const onAfterEnter = () => {
186
+ emit("after-enter");
187
+ innerProps.value.onAfterEnter?.();
188
+ };
189
+ const onEnterCancelled = () => {
190
+ emit("enter-cancelled");
191
+ innerProps.value.onEnterCancelled?.();
192
+ };
193
+ const onBeforeLeave = () => {
194
+ emit("before-leave");
195
+ innerProps.value.onBeforeLeave?.();
196
+ };
197
+ const onLeave = () => {
198
+ emit("leave");
199
+ innerProps.value.onLeave?.();
200
+ };
201
+ const onAfterLeave = () => {
202
+ emit("after-leave");
203
+ innerProps.value.onAfterLeave?.();
204
+ };
205
+ const onLeaveCancelled = () => {
206
+ emit("leave-cancelled");
207
+ innerProps.value.onLeaveCancelled?.();
208
+ };
95
209
  useImperative(
96
210
  imperativeName,
97
211
  imperative,
98
212
  computed(() => innerProps.value.id)
99
213
  );
100
- const __returned__ = { props, innerProps, imperative, SarDialog };
214
+ const __returned__ = { props, emit, innerProps, imperative, onConfirm, onClose, onCancel, onUpdateVisible, onVisibleHook, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, SarDialog };
101
215
  return __returned__;
102
216
  }
103
217
  });
@@ -1 +1 @@
1
- export { type DialogAgentProps, type DialogOptions, dialog } from './common';
1
+ export { type DialogAgentProps, type DialogOptions, type DialogAgentEmits, dialog, } from './common';
@@ -1 +1 @@
1
- export { dialog } from './common';
1
+ export { dialog, } from './common';
@@ -60,6 +60,12 @@ import Fab from 'sard-uniapp/components/fab/fab.vue'
60
60
 
61
61
  @code('${DEMO_PATH}/fab/demo/NonItemList.vue')
62
62
 
63
+ ### 自定义图标
64
+
65
+ 使用 `icon` 和 `icon-family` 可自定义悬浮按钮图标。
66
+
67
+ @code('${DEMO_PATH}/fab/demo/Icon.vue')
68
+
63
69
  ## API
64
70
 
65
71
  ### FabProps
@@ -33,7 +33,7 @@
33
33
  </view>
34
34
  <view :class="itemEntryClass" @click="onItemEntryClick">
35
35
  <view :class="bem.e('item-btn')" :style="itemEntryBtnStyle">
36
- <sar-icon family="sari" name="plus" />
36
+ <sar-icon :family="iconFamily || 'sari'" :name="icon || 'plus'" />
37
37
  </view>
38
38
  </view>
39
39
  </view>
@@ -32,15 +32,15 @@ import ListItem from 'sard-uniapp/components/list-item/list-item.vue'
32
32
 
33
33
  ### 图标
34
34
 
35
- 设置`icon`属性或插槽可以在左边显示图标。
35
+ 设置 `icon` 属性或插槽可以在左边显示图标。
36
36
 
37
37
  @code('${DEMO_PATH}/list/demo/Icon.vue')
38
38
 
39
39
  ### 自定义内容
40
40
 
41
- 列表项的`body`和`footer`默认平分水平空间,如果`footer`需要占据更多的空间,可以设置`body`不扩展。
41
+ 列表项的 `body` 和 `footer` 默认平分水平空间,如果 `footer` 需要占据更多的空间,可以设置 `body` 不扩展。
42
42
 
43
- `value`中的元素默认会向右边靠,如果有使用`footer`属性定义内容,则内容会纵向排列。
43
+ `value` 中的元素默认会向右边靠,如果有使用 `footer` 属性定义内容,则内容会纵向排列。
44
44
 
45
45
  @code('${DEMO_PATH}/list/demo/Slot.vue')
46
46
 
@@ -52,22 +52,29 @@ import ListItem from 'sard-uniapp/components/list-item/list-item.vue'
52
52
 
53
53
  ### 卡片风格
54
54
 
55
- 可以使用`card`属性让列表显示为卡片风格。
55
+ 可以使用 `card` 属性让列表显示为卡片风格。
56
56
 
57
57
  @code('${DEMO_PATH}/list/demo/Card.vue')
58
58
 
59
+ ### 隐藏边框 <sup>1.21.0+</sup>
60
+
61
+ 可以使用 `hide-border` 属性隐藏边框。
62
+
63
+ @code('${DEMO_PATH}/list/demo/HideBorder.vue')
64
+
59
65
  ## API
60
66
 
61
67
  ### ListProps
62
68
 
63
- | 属性 | 描述 | 类型 | 默认值 |
64
- | ----------- | -------------- | ---------------- | ------ |
65
- | root-class | 组件根元素类名 | string | - |
66
- | root-style | 组件根元素样式 | StyleValue | - |
67
- | title | 列表顶部标题 | string \| number | - |
68
- | description | 列表底部描述 | string \| number | - |
69
- | card | 卡片风格 | boolean | false |
70
- | inlaid | 嵌入式列表 | boolean | false |
69
+ | 属性 | 描述 | 类型 | 默认值 |
70
+ | ------------------------------ | -------------- | ---------------- | ------ |
71
+ | root-class | 组件根元素类名 | string | - |
72
+ | root-style | 组件根元素样式 | StyleValue | - |
73
+ | title | 列表顶部标题 | string \| number | - |
74
+ | description | 列表底部描述 | string \| number | - |
75
+ | card | 卡片风格 | boolean | false |
76
+ | inlaid | 嵌入式列表 | boolean | false |
77
+ | hide-border <sup>1.21.0+</sup> | 是否隐藏边框 | boolean | false |
71
78
 
72
79
  ### ListSlots
73
80
 
@@ -1,4 +1,4 @@
1
- import { type StyleValue } from 'vue';
1
+ import { InjectionKey, type StyleValue } from 'vue';
2
2
  export interface ListProps {
3
3
  rootStyle?: StyleValue;
4
4
  rootClass?: string;
@@ -6,6 +6,7 @@ export interface ListProps {
6
6
  description?: string | number;
7
7
  inlaid?: boolean;
8
8
  card?: boolean;
9
+ hideBorder?: boolean;
9
10
  }
10
11
  export interface ListSlots {
11
12
  default?(props: Record<string, never>): any;
@@ -40,3 +41,7 @@ export interface ListItemSlots {
40
41
  arrow?(props: Record<string, never>): any;
41
42
  icon?(props: Record<string, never>): any;
42
43
  }
44
+ export interface ListContext {
45
+ hideBorder?: boolean;
46
+ }
47
+ export declare const listContextKey: InjectionKey<ListContext>;
@@ -1,2 +1,3 @@
1
1
  import { defaultConfig } from '../config';
2
2
  export const defaultListItemProps = defaultConfig.listItem;
3
+ export const listContextKey = Symbol('list-context');
@@ -24,6 +24,14 @@
24
24
  }
25
25
  }
26
26
 
27
+ @include m(borderless) {
28
+ @include e(content) {
29
+ &::before {
30
+ display: none;
31
+ }
32
+ }
33
+ }
34
+
27
35
  @include e(description) {
28
36
  @include universal;
29
37
  margin-left: var(--sar-list-description-margin-x);
@@ -17,13 +17,14 @@
17
17
 
18
18
  <script>
19
19
  import { defineComponent as _defineComponent } from "vue";
20
- import { computed } from "vue";
20
+ import { computed, provide, reactive, toRef } from "vue";
21
21
  import {
22
22
  classNames,
23
23
  stringifyStyle,
24
24
  isRenderVisible,
25
25
  createBem
26
26
  } from "../../utils";
27
+ import { listContextKey } from "./common";
27
28
  /**
28
29
  * @property {string} rootClass 组件根元素类名,默认值:-。
29
30
  * @property {StyleValue} rootStyle 组件根元素样式,默认值:-。
@@ -31,6 +32,7 @@ import {
31
32
  * @property {string | number} description 列表底部描述,默认值:-。
32
33
  * @property {boolean} card 卡片风格,默认值:false。
33
34
  * @property {boolean} inlaid 嵌入式列表,默认值:false。
35
+ * @property {boolean} hideBorder 是否隐藏边框,默认值:false。
34
36
  */
35
37
  export default _defineComponent({
36
38
  ...{
@@ -46,18 +48,26 @@ export default _defineComponent({
46
48
  title: { type: [String, Number], required: false },
47
49
  description: { type: [String, Number], required: false },
48
50
  inlaid: { type: Boolean, required: false },
49
- card: { type: Boolean, required: false }
51
+ card: { type: Boolean, required: false },
52
+ hideBorder: { type: Boolean, required: false }
50
53
  },
51
54
  setup(__props, { expose: __expose }) {
52
55
  __expose();
53
56
  const props = __props;
54
57
  const bem = createBem("list");
58
+ provide(
59
+ listContextKey,
60
+ reactive({
61
+ hideBorder: toRef(() => props.hideBorder)
62
+ })
63
+ );
55
64
  const listClass = computed(() => {
56
65
  return classNames(
57
66
  bem.b(),
58
67
  bem.m("card", props.card),
59
68
  bem.m("not-card", !props.card),
60
69
  bem.m("inlaid", props.inlaid),
70
+ bem.m("borderless", props.hideBorder),
61
71
  props.rootClass
62
72
  );
63
73
  });
@@ -26,6 +26,12 @@
26
26
  right: var(--sar-list-item-padding-x);
27
27
  }
28
28
 
29
+ @include m(borderless) {
30
+ &::before {
31
+ display: none;
32
+ }
33
+ }
34
+
29
35
  &:first-child::before {
30
36
  display: none;
31
37
  }
@@ -42,7 +42,7 @@
42
42
 
43
43
  <script>
44
44
  import { useSlots as _useSlots, mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
45
- import { computed } from "vue";
45
+ import { computed, inject } from "vue";
46
46
  import {
47
47
  classNames,
48
48
  stringifyStyle,
@@ -51,7 +51,8 @@ import {
51
51
  } from "../../utils";
52
52
  import SarIcon from "../icon/icon.vue";
53
53
  import {
54
- defaultListItemProps
54
+ defaultListItemProps,
55
+ listContextKey
55
56
  } from "../list/common";
56
57
  /**
57
58
  * @property {string} rootClass 组件根元素类名,默认值:-。
@@ -100,6 +101,7 @@ export default _defineComponent({
100
101
  const slots = _useSlots();
101
102
  const emit = __emit;
102
103
  const bem = createBem("list-item");
104
+ const context = inject(listContextKey);
103
105
  const onClick = (event) => {
104
106
  emit("click", event);
105
107
  };
@@ -108,10 +110,11 @@ export default _defineComponent({
108
110
  bem.b(),
109
111
  bem.m("hover", props.hover),
110
112
  bem.m("custom", !!slots.default),
113
+ bem.m("borderless", context?.hideBorder),
111
114
  props.rootClass
112
115
  );
113
116
  });
114
- const __returned__ = { props, slots, emit, bem, onClick, listItemClass, get stringifyStyle() {
117
+ const __returned__ = { props, slots, emit, bem, context, onClick, listItemClass, get stringifyStyle() {
115
118
  return stringifyStyle;
116
119
  }, get isRenderVisible() {
117
120
  return isRenderVisible;
@@ -91,7 +91,7 @@ export default {
91
91
  },
92
92
  },
93
93
  loadMore: {
94
- incompleteText: 'Load more',
94
+ incompleteText: 'Click to load more',
95
95
  loadingText: 'Loading...',
96
96
  errorText: 'Request failed. Click to reload',
97
97
  completeText: 'No more',
@@ -91,7 +91,7 @@ export default {
91
91
  },
92
92
  },
93
93
  loadMore: {
94
- incompleteText: '加载更多',
94
+ incompleteText: '点击加载更多',
95
95
  loadingText: '加载中...',
96
96
  completeText: '没有更多了',
97
97
  errorText: '请求失败,点击重新加载',