sard-uniapp 1.27.0 → 1.27.1
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.
- package/CHANGELOG.md +9 -0
- package/components/config/index.js +1 -0
- package/components/select/common.d.ts +2 -0
- package/components/select/select.d.ts +2 -0
- package/components/select/select.vue +6 -3
- package/components/select/useSelect.js +9 -1
- package/components/select-input/select-input.vue +1 -0
- package/components/select-popout/README.md +9 -8
- package/components/select-popout/select-popout.vue +10 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## [1.27.1](https://github.com/sutras/sard-uniapp/compare/v1.27.0...v1.27.1) (2026-03-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **select-popout:** 新增show-confirm属性 ([017d4ba](https://github.com/sutras/sard-uniapp/commit/017d4ba86f05ebe368ace11d4b47f2ff6f752c67))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
1
10
|
# [1.27.0](https://github.com/sutras/sard-uniapp/compare/v1.26.3...v1.27.0) (2026-02-23)
|
|
2
11
|
|
|
3
12
|
|
|
@@ -281,6 +281,7 @@ export interface SelectSlots {
|
|
|
281
281
|
export interface SelectEmits {
|
|
282
282
|
(e: 'update:model-value', value: any): void;
|
|
283
283
|
(e: 'change', value: any): void;
|
|
284
|
+
(e: 'select', value: any): void;
|
|
284
285
|
}
|
|
285
286
|
export interface SelectExpose {
|
|
286
287
|
}
|
|
@@ -300,5 +301,6 @@ export interface SelectContext {
|
|
|
300
301
|
getEnabledValue: () => any[];
|
|
301
302
|
selectItems: Ref<SelectItem[]>;
|
|
302
303
|
setToggle: (toggle: (value: any) => void) => void;
|
|
304
|
+
setSelect: (select: (value: any) => void) => void;
|
|
303
305
|
}
|
|
304
306
|
export declare const selectContextSymbol: unique symbol;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type SelectProps, type SelectSlots } from './common';
|
|
2
2
|
declare function __VLS_template(): Readonly<SelectSlots> & SelectSlots;
|
|
3
3
|
declare const __VLS_component: import("vue").DefineComponent<SelectProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
4
|
+
select: (value: any) => any;
|
|
4
5
|
"update:model-value": (value: any) => any;
|
|
5
6
|
change: (value: any) => any;
|
|
6
7
|
}, string, import("vue").PublicProps, Readonly<SelectProps> & Readonly<{
|
|
8
|
+
onSelect?: ((value: any) => any) | undefined;
|
|
7
9
|
"onUpdate:model-value"?: ((value: any) => any) | undefined;
|
|
8
10
|
onChange?: ((value: any) => any) | undefined;
|
|
9
11
|
}>, {
|
|
@@ -176,7 +176,7 @@ export default _defineComponent({
|
|
|
176
176
|
valueKey: { type: String, required: false },
|
|
177
177
|
internalDefault: { type: Number, required: false }
|
|
178
178
|
}, defaultSelectProps()),
|
|
179
|
-
emits: ["update:model-value", "change"],
|
|
179
|
+
emits: ["update:model-value", "change", "select"],
|
|
180
180
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
181
181
|
const props = __props;
|
|
182
182
|
const emit = __emit;
|
|
@@ -188,10 +188,13 @@ export default _defineComponent({
|
|
|
188
188
|
return first && Array.isArray(getChildren(first));
|
|
189
189
|
});
|
|
190
190
|
const scrollViewId = uniqid();
|
|
191
|
-
const { innerValue, selectItems, getEnabledValue, setToggle } = inject(selectContextSymbol, null) || useSelect(props);
|
|
191
|
+
const { innerValue, selectItems, getEnabledValue, setToggle, setSelect } = inject(selectContextSymbol, null) || useSelect(props);
|
|
192
192
|
setToggle((value) => {
|
|
193
193
|
triggerChange(value);
|
|
194
194
|
});
|
|
195
|
+
setSelect((value) => {
|
|
196
|
+
emit("select", value);
|
|
197
|
+
});
|
|
195
198
|
watch(
|
|
196
199
|
() => props.modelValue,
|
|
197
200
|
(value) => {
|
|
@@ -312,7 +315,7 @@ export default _defineComponent({
|
|
|
312
315
|
bem.em("scroll", "filterable", props.filterable)
|
|
313
316
|
);
|
|
314
317
|
});
|
|
315
|
-
const __returned__ = { props, emit, bem, t, getLabel, getValue, getChildren, getKey, isGroupable, scrollViewId, innerValue, selectItems, getEnabledValue, setToggle, triggerChange, scrollSide, onSideScroll, onScrolltoupper, onScrolltolower, searchValue, status, onLoadMore, onReload, refresh, loadMoreId, debouncedRefresh, isEmpty, onClear, onSelectAll, showSelectAll, instance, scrollTop, get memoScrollTop() {
|
|
318
|
+
const __returned__ = { props, emit, bem, t, getLabel, getValue, getChildren, getKey, isGroupable, scrollViewId, innerValue, selectItems, getEnabledValue, setToggle, setSelect, triggerChange, scrollSide, onSideScroll, onScrolltoupper, onScrolltolower, searchValue, status, onLoadMore, onReload, refresh, loadMoreId, debouncedRefresh, isEmpty, onClear, onSelectAll, showSelectAll, instance, scrollTop, get memoScrollTop() {
|
|
316
319
|
return memoScrollTop;
|
|
317
320
|
}, set memoScrollTop(v) {
|
|
318
321
|
memoScrollTop = v;
|
|
@@ -20,6 +20,7 @@ export function useSelect(props) {
|
|
|
20
20
|
.map((item) => item.value());
|
|
21
21
|
};
|
|
22
22
|
let onToggle;
|
|
23
|
+
let onSelect;
|
|
23
24
|
const toggle = (value) => {
|
|
24
25
|
let nextValue;
|
|
25
26
|
if (props.multiple) {
|
|
@@ -28,15 +29,21 @@ export function useSelect(props) {
|
|
|
28
29
|
: innerValue.value.concat(value);
|
|
29
30
|
}
|
|
30
31
|
else {
|
|
31
|
-
if (value === innerValue.value)
|
|
32
|
+
if (value === innerValue.value) {
|
|
33
|
+
onSelect?.(value);
|
|
32
34
|
return;
|
|
35
|
+
}
|
|
33
36
|
nextValue = value;
|
|
34
37
|
}
|
|
35
38
|
onToggle?.(nextValue);
|
|
39
|
+
onSelect?.(value);
|
|
36
40
|
};
|
|
37
41
|
const setToggle = (toggle) => {
|
|
38
42
|
onToggle = toggle;
|
|
39
43
|
};
|
|
44
|
+
const setSelect = (select) => {
|
|
45
|
+
onSelect = select;
|
|
46
|
+
};
|
|
40
47
|
const context = {
|
|
41
48
|
innerValue,
|
|
42
49
|
toggle,
|
|
@@ -47,6 +54,7 @@ export function useSelect(props) {
|
|
|
47
54
|
getEnabledValue,
|
|
48
55
|
selectItems,
|
|
49
56
|
setToggle,
|
|
57
|
+
setSelect,
|
|
50
58
|
};
|
|
51
59
|
provide(selectContextSymbol, context);
|
|
52
60
|
return context;
|
|
@@ -66,6 +66,7 @@ import { useSelect } from "../select/useSelect";
|
|
|
66
66
|
* @property {StyleValue} popoutStyle 弹窗框根元素样式,默认值:-。
|
|
67
67
|
* @property {boolean} visible 是否显示弹出框,默认值:-。
|
|
68
68
|
* @property {string} title 弹出框标题,默认值:-。
|
|
69
|
+
* @property {boolean} showConfirm 单选时是否显示确定按钮,隐藏按钮可用于快捷选择,默认值:true。
|
|
69
70
|
* @property {boolean} validateEvent 是否触发表单验证,默认值:true。
|
|
70
71
|
* @property {boolean} resettable 关闭弹出框后,是否可复位弹出框值,默认值:false。
|
|
71
72
|
* @property {number} maxLabels 多选时,输入框最大展示标签个数,设为 -1 表示不限制,默认值:10。
|
|
@@ -88,14 +88,15 @@ import SelectPopout from 'sard-uniapp/components/select-popout/select-popout.vue
|
|
|
88
88
|
|
|
89
89
|
继承 [`SelectProps`](./select#SelectProps) 并有以下额外属性:
|
|
90
90
|
|
|
91
|
-
| 属性
|
|
92
|
-
|
|
|
93
|
-
| popout-class
|
|
94
|
-
| popout-style
|
|
95
|
-
| visible (v-model)
|
|
96
|
-
| title
|
|
97
|
-
|
|
|
98
|
-
|
|
|
91
|
+
| 属性 | 描述 | 类型 | 默认值 |
|
|
92
|
+
| ------------------------------- | ---------------------------------------------- | ---------- | ------ |
|
|
93
|
+
| popout-class | 弹窗框根元素类名 | string | - |
|
|
94
|
+
| popout-style | 弹窗框根元素样式 | StyleValue | - |
|
|
95
|
+
| visible (v-model) | 是否显示弹出框 | boolean | - |
|
|
96
|
+
| title | 弹出框标题 | string | - |
|
|
97
|
+
| show-confirm <sup>1.27.1+</sup> | 单选时是否显示确定按钮,隐藏按钮可用于快捷选择 | boolean | true |
|
|
98
|
+
| validate-event | 是否触发表单验证 | boolean | true |
|
|
99
|
+
| resettable | 关闭弹出框后,是否可复位弹出框值 | boolean | false |
|
|
99
100
|
|
|
100
101
|
### SelectPopoutSlots
|
|
101
102
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
<sar-popout
|
|
3
3
|
v-model:visible="innerVisible"
|
|
4
4
|
:title="$slots.title ? '' : title"
|
|
5
|
+
:show-confirm="showConfirm"
|
|
5
6
|
:root-class="popoutClass"
|
|
6
7
|
:root-style="popoutStyle"
|
|
7
8
|
@confirm="onConfirm"
|
|
@@ -14,6 +15,7 @@
|
|
|
14
15
|
:model-value="popoutValue"
|
|
15
16
|
:internal-default="internalDefault"
|
|
16
17
|
@change="onChange"
|
|
18
|
+
@select="onSelect"
|
|
17
19
|
>
|
|
18
20
|
<slot></slot>
|
|
19
21
|
</sar-select>
|
|
@@ -53,6 +55,7 @@ import { isNumber } from "../../utils";
|
|
|
53
55
|
* @property {StyleValue} popoutStyle 弹窗框根元素样式,默认值:-。
|
|
54
56
|
* @property {boolean} visible 是否显示弹出框,默认值:-。
|
|
55
57
|
* @property {string} title 弹出框标题,默认值:-。
|
|
58
|
+
* @property {boolean} showConfirm 单选时是否显示确定按钮,隐藏按钮可用于快捷选择,默认值:true。
|
|
56
59
|
* @property {boolean} validateEvent 是否触发表单验证,默认值:true。
|
|
57
60
|
* @property {boolean} resettable 关闭弹出框后,是否可复位弹出框值,默认值:false。
|
|
58
61
|
* @event {(visible: boolean) => void} update 弹出框显隐时触发
|
|
@@ -112,6 +115,12 @@ export default _defineComponent({
|
|
|
112
115
|
const emit = __emit;
|
|
113
116
|
const omittedProps = omitFormPopoutProps(props);
|
|
114
117
|
const { innerVisible, popoutValue, onChange, onConfirm, onVisibleHook } = useFormPopout(props, emit);
|
|
118
|
+
const onSelect = () => {
|
|
119
|
+
if (!props.multiple && !props.showConfirm) {
|
|
120
|
+
onConfirm(false);
|
|
121
|
+
innerVisible.value = false;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
115
124
|
const internalDefault = computed(
|
|
116
125
|
() => isNumber(props.internalDefault) ? props.internalDefault : slots.default ? 1 : 0
|
|
117
126
|
);
|
|
@@ -119,7 +128,7 @@ export default _defineComponent({
|
|
|
119
128
|
useSelect(props);
|
|
120
129
|
}
|
|
121
130
|
__expose({});
|
|
122
|
-
const __returned__ = { props, slots, emit, omittedProps, innerVisible, popoutValue, onChange, onConfirm, onVisibleHook, internalDefault, SarPopout, SarSelect };
|
|
131
|
+
const __returned__ = { props, slots, emit, omittedProps, innerVisible, popoutValue, onChange, onConfirm, onVisibleHook, onSelect, internalDefault, SarPopout, SarSelect };
|
|
123
132
|
return __returned__;
|
|
124
133
|
}
|
|
125
134
|
});
|