sard-uniapp 1.2.2 → 1.4.0-alpha
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 +13 -0
- package/components/alert/alert.d.ts +35 -0
- package/components/alert/alert.vue +74 -0
- package/components/alert/common.d.ts +26 -0
- package/components/alert/common.js +8 -0
- package/components/alert/index.d.ts +1 -0
- package/components/alert/index.js +1 -0
- package/components/alert/index.scss +59 -0
- package/components/alert/variables.scss +14 -0
- package/components/button/button.d.ts +1 -1
- package/components/calendar-input/calendar-input.vue +8 -7
- package/components/cascader-input/cascader-input.vue +8 -7
- package/components/checkbox/common.d.ts +13 -0
- package/components/checkbox/common.js +4 -0
- package/components/checkbox-group/checkbox-group.vue +27 -7
- package/components/checkbox-input/checkbox-input.d.ts +35 -0
- package/components/checkbox-input/checkbox-input.vue +185 -0
- package/components/checkbox-input/common.d.ts +15 -0
- package/components/checkbox-input/common.js +5 -0
- package/components/checkbox-input/index.d.ts +1 -0
- package/components/checkbox-input/index.js +1 -0
- package/components/checkbox-input/index.scss +7 -0
- package/components/checkbox-input/variables.scss +5 -0
- package/components/config/index.d.ts +40 -0
- package/components/config/index.js +20 -0
- package/components/datetime-picker-input/datetime-picker-input.vue +2 -1
- package/components/form/variables.scss +2 -2
- package/components/input/common.d.ts +1 -0
- package/components/input/index.scss +21 -0
- package/components/input/input.vue +22 -4
- package/components/input/variables.scss +1 -0
- package/components/list/index.scss +6 -0
- package/components/list/list.vue +1 -0
- package/components/list-item/index.scss +1 -0
- package/components/notify/notify.d.ts +1 -1
- package/components/notify-agent/notify-agent.d.ts +1 -1
- package/components/picker-input/picker-input.vue +2 -1
- package/components/popout-input/common.d.ts +1 -0
- package/components/popout-input/popout-input.vue +6 -2
- package/components/qrcode/common.d.ts +23 -0
- package/components/qrcode/common.js +2 -0
- package/components/qrcode/index.d.ts +1 -0
- package/components/qrcode/index.js +1 -0
- package/components/qrcode/index.scss +17 -0
- package/components/qrcode/qrcode.d.ts +47 -0
- package/components/qrcode/qrcode.vue +107 -0
- package/components/qrcode/variables.scss +4 -0
- package/components/radio/common.d.ts +13 -0
- package/components/radio/common.js +4 -0
- package/components/radio-group/radio-group.vue +27 -7
- package/components/radio-input/common.d.ts +16 -0
- package/components/radio-input/common.js +5 -0
- package/components/radio-input/index.d.ts +1 -0
- package/components/radio-input/index.js +1 -0
- package/components/radio-input/index.scss +7 -0
- package/components/radio-input/radio-input.d.ts +38 -0
- package/components/radio-input/radio-input.vue +181 -0
- package/components/radio-input/variables.scss +5 -0
- package/components/result/result.d.ts +1 -1
- package/components/result/result.vue +1 -1
- package/components/tag/tag.d.ts +1 -1
- package/global.d.ts +9 -1
- package/index.d.ts +4 -0
- package/index.js +4 -0
- package/index.scss +4 -0
- package/package.json +2 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/is.d.ts +6 -0
- package/utils/is.js +8 -0
- package/utils/qrcode.d.ts +8 -0
- package/utils/qrcode.js +616 -0
package/changelog.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
# [1.4.0-alpha](https://github.com/sutras/sard-uniapp/compare/v1.3.0...v1.4.0-alpha) (2024-08-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# [1.3.0](https://github.com/sutras/sard-uniapp/compare/v1.2.2...v1.3.0) (2024-07-16)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* 新增radio-input, checkbox-input, alert组件 ([a2d24fc](https://github.com/sutras/sard-uniapp/commit/a2d24fc080337df2f39d6abdc887517adf8428c1))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
1
14
|
## [1.2.2](https://github.com/sutras/sard-uniapp/compare/v1.2.0...v1.2.2) (2024-07-13)
|
|
2
15
|
|
|
3
16
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type AlertProps, type AlertSlots } from './common';
|
|
2
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<AlertProps>, {
|
|
3
|
+
type: "primary";
|
|
4
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
5
|
+
close: () => void;
|
|
6
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<AlertProps>, {
|
|
7
|
+
type: "primary";
|
|
8
|
+
}>>> & {
|
|
9
|
+
onClose?: (() => any) | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
type: "success" | "primary" | "warning" | "danger";
|
|
12
|
+
}, {}>, Readonly<AlertSlots> & AlertSlots>;
|
|
13
|
+
export default _default;
|
|
14
|
+
type __VLS_WithDefaults<P, D> = {
|
|
15
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
16
|
+
default: D[K];
|
|
17
|
+
}> : P[K];
|
|
18
|
+
};
|
|
19
|
+
type __VLS_Prettify<T> = {
|
|
20
|
+
[K in keyof T]: T[K];
|
|
21
|
+
} & {};
|
|
22
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
23
|
+
new (): {
|
|
24
|
+
$slots: S;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
28
|
+
type __VLS_TypePropsToOption<T> = {
|
|
29
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
30
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
31
|
+
} : {
|
|
32
|
+
type: import('vue').PropType<T[K]>;
|
|
33
|
+
required: true;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view v-if="visible" :class="alertClass" :style="alertStyle">
|
|
3
|
+
<view v-if="showIcon" :class="bem.e('icon')">
|
|
4
|
+
<slot name="icon">
|
|
5
|
+
<sar-icon :name="mapTypeIcon[type]" />
|
|
6
|
+
</slot>
|
|
7
|
+
</view>
|
|
8
|
+
<view :class="bem.e('content')"><slot></slot></view>
|
|
9
|
+
<view v-if="closable" :class="bem.e('close')" @click="onClose">
|
|
10
|
+
<sar-icon name="close" />
|
|
11
|
+
</view>
|
|
12
|
+
</view>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
|
|
17
|
+
import { computed, ref } from "vue";
|
|
18
|
+
import { classNames, stringifyStyle, createBem } from "../../utils";
|
|
19
|
+
import {
|
|
20
|
+
alertPropsDefaults,
|
|
21
|
+
mapTypeIcon
|
|
22
|
+
} from "./common";
|
|
23
|
+
import SarIcon from "../icon/icon.vue";
|
|
24
|
+
export default _defineComponent({
|
|
25
|
+
...{
|
|
26
|
+
options: {
|
|
27
|
+
virtualHost: true,
|
|
28
|
+
styleIsolation: "shared"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
__name: "alert",
|
|
32
|
+
props: _mergeDefaults({
|
|
33
|
+
rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
|
|
34
|
+
rootClass: { type: String, required: false },
|
|
35
|
+
showIcon: { type: Boolean, required: false },
|
|
36
|
+
closable: { type: Boolean, required: false },
|
|
37
|
+
type: { type: String, required: false },
|
|
38
|
+
color: { type: String, required: false },
|
|
39
|
+
background: { type: String, required: false }
|
|
40
|
+
}, alertPropsDefaults),
|
|
41
|
+
emits: ["close"],
|
|
42
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
43
|
+
__expose();
|
|
44
|
+
const props = __props;
|
|
45
|
+
const emit = __emit;
|
|
46
|
+
const bem = createBem("alert");
|
|
47
|
+
const visible = ref(true);
|
|
48
|
+
const onClose = () => {
|
|
49
|
+
visible.value = false;
|
|
50
|
+
emit("close");
|
|
51
|
+
};
|
|
52
|
+
const alertClass = computed(() => {
|
|
53
|
+
return classNames(bem.b(), bem.m(props.type), props.rootClass);
|
|
54
|
+
});
|
|
55
|
+
const alertStyle = computed(() => {
|
|
56
|
+
return stringifyStyle(
|
|
57
|
+
{
|
|
58
|
+
color: props.color,
|
|
59
|
+
background: props.background
|
|
60
|
+
},
|
|
61
|
+
props.rootStyle
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
const __returned__ = { props, emit, bem, visible, onClose, alertClass, alertStyle, get mapTypeIcon() {
|
|
65
|
+
return mapTypeIcon;
|
|
66
|
+
}, SarIcon };
|
|
67
|
+
return __returned__;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<style lang="scss">
|
|
73
|
+
@import './index.scss';
|
|
74
|
+
</style>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type StyleValue } from 'vue';
|
|
2
|
+
export interface AlertProps {
|
|
3
|
+
rootStyle?: StyleValue;
|
|
4
|
+
rootClass?: string;
|
|
5
|
+
showIcon?: boolean;
|
|
6
|
+
closable?: boolean;
|
|
7
|
+
type?: 'primary' | 'success' | 'warning' | 'danger';
|
|
8
|
+
color?: string;
|
|
9
|
+
background?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const alertPropsDefaults: {
|
|
12
|
+
type: "primary";
|
|
13
|
+
};
|
|
14
|
+
export interface AlertSlots {
|
|
15
|
+
default?(props: Record<string, never>): any;
|
|
16
|
+
icon?(props: Record<string, never>): any;
|
|
17
|
+
}
|
|
18
|
+
export interface AlertEmits {
|
|
19
|
+
(e: 'close'): void;
|
|
20
|
+
}
|
|
21
|
+
export declare const mapTypeIcon: {
|
|
22
|
+
primary: string;
|
|
23
|
+
success: string;
|
|
24
|
+
warning: string;
|
|
25
|
+
danger: string;
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { AlertProps, AlertSlots, AlertEmits } from './common';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
@use '../style/base' as *;
|
|
2
|
+
|
|
3
|
+
@include bem(alert) {
|
|
4
|
+
@include b() {
|
|
5
|
+
@include universal;
|
|
6
|
+
flex-direction: row;
|
|
7
|
+
align-items: center;
|
|
8
|
+
padding: var(--sar-alert-paddding-y) var(--sar-alert-paddding-x);
|
|
9
|
+
font-size: var(--sar-alert-font-size);
|
|
10
|
+
|
|
11
|
+
@each $type,
|
|
12
|
+
$color
|
|
13
|
+
in (
|
|
14
|
+
primary: (
|
|
15
|
+
var(--sar-primary),
|
|
16
|
+
var(--sar-primary-rgb),
|
|
17
|
+
),
|
|
18
|
+
success: (
|
|
19
|
+
var(--sar-success),
|
|
20
|
+
var(--sar-success-rgb),
|
|
21
|
+
),
|
|
22
|
+
warning: (
|
|
23
|
+
var(--sar-warning),
|
|
24
|
+
var(--sar-warning-rgb),
|
|
25
|
+
),
|
|
26
|
+
danger: (
|
|
27
|
+
var(--sar-danger),
|
|
28
|
+
var(--sar-danger-rgb),
|
|
29
|
+
)
|
|
30
|
+
)
|
|
31
|
+
{
|
|
32
|
+
@include m($type) {
|
|
33
|
+
color: nth($color, 1);
|
|
34
|
+
background-color: rgba(nth($color, 2), var(--sar-alert-bg-opacity));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@include e(icon) {
|
|
40
|
+
@include universal;
|
|
41
|
+
margin-right: var(--sar-alert-icon-margin-right);
|
|
42
|
+
line-height: 1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@include e(content) {
|
|
46
|
+
@include universal;
|
|
47
|
+
flex: 1;
|
|
48
|
+
overflow: hidden;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@include e(close) {
|
|
52
|
+
@include universal;
|
|
53
|
+
font-size: var(--sar-alert-close-size);
|
|
54
|
+
padding: var(--sar-alert-close-padding);
|
|
55
|
+
margin: var(--sar-alert-close-margin) var(--sar-alert-close-margin)
|
|
56
|
+
var(--sar-alert-close-margin) 0;
|
|
57
|
+
cursor: pointer;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// #variables
|
|
2
|
+
page {
|
|
3
|
+
--sar-alert-paddding-x: 32rpx;
|
|
4
|
+
--sar-alert-paddding-y: 16rpx;
|
|
5
|
+
--sar-alert-font-size: var(--sar-text-base);
|
|
6
|
+
--sar-alert-bg-opacity: 0.1;
|
|
7
|
+
|
|
8
|
+
--sar-alert-icon-margin-right: 12rpx;
|
|
9
|
+
|
|
10
|
+
--sar-alert-close-padding: 16rpx;
|
|
11
|
+
--sar-alert-close-margin: -16rpx;
|
|
12
|
+
--sar-alert-close-size: var(--sar-text-base);
|
|
13
|
+
}
|
|
14
|
+
// #endvariables
|
|
@@ -14,7 +14,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
14
14
|
}, {
|
|
15
15
|
size: "small" | "medium" | "mini" | "large";
|
|
16
16
|
type: "text" | "default" | "pale" | "mild" | "outline" | "pale-text";
|
|
17
|
-
theme: "success" | "primary" | "info" | "
|
|
17
|
+
theme: "success" | "primary" | "info" | "warning" | "danger" | "secondary" | "neutral";
|
|
18
18
|
}, {}>, Readonly<ButtonSlots> & ButtonSlots>;
|
|
19
19
|
export default _default;
|
|
20
20
|
type __VLS_WithDefaults<P, D> = {
|
|
@@ -83,7 +83,8 @@ export default _defineComponent({
|
|
|
83
83
|
placeholder: { type: String, required: false },
|
|
84
84
|
readonly: { type: Boolean, required: false },
|
|
85
85
|
disabled: { type: Boolean, required: false },
|
|
86
|
-
clearable: { type: Boolean, required: false }
|
|
86
|
+
clearable: { type: Boolean, required: false },
|
|
87
|
+
multiline: { type: Boolean, required: false }
|
|
87
88
|
}, calendarInputPropsDefaults),
|
|
88
89
|
emits: ["update:visible", "update:model-value"],
|
|
89
90
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
@@ -109,11 +110,6 @@ export default _defineComponent({
|
|
|
109
110
|
const value = popoutValue.value;
|
|
110
111
|
return !value || Array.isArray(value) && value.length === 0;
|
|
111
112
|
});
|
|
112
|
-
const onConfirm = () => {
|
|
113
|
-
innerValue.value = popoutValue.value;
|
|
114
|
-
emit("update:model-value", popoutValue.value);
|
|
115
|
-
inputValue.value = getInputValue();
|
|
116
|
-
};
|
|
117
113
|
const onChange = (value) => {
|
|
118
114
|
popoutValue.value = value;
|
|
119
115
|
if (!props.showConfirm && !confirmDisabled.value) {
|
|
@@ -121,6 +117,11 @@ export default _defineComponent({
|
|
|
121
117
|
innerVisible.value = false;
|
|
122
118
|
}
|
|
123
119
|
};
|
|
120
|
+
const onConfirm = () => {
|
|
121
|
+
innerValue.value = popoutValue.value;
|
|
122
|
+
emit("update:model-value", popoutValue.value);
|
|
123
|
+
inputValue.value = getInputValue();
|
|
124
|
+
};
|
|
124
125
|
const inputValue = ref("");
|
|
125
126
|
const { t } = useTranslate("calendar");
|
|
126
127
|
function getOutletText(date, type) {
|
|
@@ -175,7 +176,7 @@ export default _defineComponent({
|
|
|
175
176
|
innerVisible.value = true;
|
|
176
177
|
emit("update:visible", true);
|
|
177
178
|
};
|
|
178
|
-
const __returned__ = { props, emit, formItemContext, innerValue, popoutValue, confirmDisabled,
|
|
179
|
+
const __returned__ = { props, emit, formItemContext, innerValue, popoutValue, confirmDisabled, onChange, onConfirm, inputValue, format, t, getOutletText, getInputValue, onClear, innerVisible, onVisible, onInputClick, SarPopoutInput, SarCalendar, SarPopout };
|
|
179
180
|
return __returned__;
|
|
180
181
|
}
|
|
181
182
|
});
|
|
@@ -76,7 +76,8 @@ export default _defineComponent({
|
|
|
76
76
|
readonly: { type: Boolean, required: false },
|
|
77
77
|
disabled: { type: Boolean, required: false },
|
|
78
78
|
clearable: { type: Boolean, required: false },
|
|
79
|
-
loading: { type: Boolean, required: false }
|
|
79
|
+
loading: { type: Boolean, required: false },
|
|
80
|
+
multiline: { type: Boolean, required: false }
|
|
80
81
|
}, cascaderInputPropsDefaults),
|
|
81
82
|
emits: ["update:visible", "update:model-value", "select"],
|
|
82
83
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
@@ -98,11 +99,6 @@ export default _defineComponent({
|
|
|
98
99
|
watch(innerValue, () => {
|
|
99
100
|
popoutValue.value = innerValue.value;
|
|
100
101
|
});
|
|
101
|
-
const onConfirm = () => {
|
|
102
|
-
innerValue.value = popoutValue.value;
|
|
103
|
-
emit("update:model-value", popoutValue.value);
|
|
104
|
-
inputValue.value = getInputValue();
|
|
105
|
-
};
|
|
106
102
|
const onChange = (value) => {
|
|
107
103
|
popoutValue.value = value;
|
|
108
104
|
if (!props.showConfirm && !isNullish(popoutValue.value)) {
|
|
@@ -110,6 +106,11 @@ export default _defineComponent({
|
|
|
110
106
|
innerVisible.value = false;
|
|
111
107
|
}
|
|
112
108
|
};
|
|
109
|
+
const onConfirm = () => {
|
|
110
|
+
innerValue.value = popoutValue.value;
|
|
111
|
+
emit("update:model-value", popoutValue.value);
|
|
112
|
+
inputValue.value = getInputValue();
|
|
113
|
+
};
|
|
113
114
|
const inputValue = ref("");
|
|
114
115
|
const fieldkeys = computed(() => {
|
|
115
116
|
return Object.assign(
|
|
@@ -167,7 +168,7 @@ export default _defineComponent({
|
|
|
167
168
|
innerVisible.value = true;
|
|
168
169
|
emit("update:visible", true);
|
|
169
170
|
};
|
|
170
|
-
const __returned__ = { props, emit, formItemContext, innerValue, popoutValue,
|
|
171
|
+
const __returned__ = { props, emit, formItemContext, innerValue, popoutValue, onChange, onConfirm, inputValue, fieldkeys, getOutletText, getInputValue, onClear, innerVisible, onVisible, onInputClick, SarPopoutInput, SarCascader, SarPopout };
|
|
171
172
|
return __returned__;
|
|
172
173
|
}
|
|
173
174
|
});
|
|
@@ -26,6 +26,17 @@ export interface CheckboxEmits {
|
|
|
26
26
|
(e: 'click', event: any): void;
|
|
27
27
|
(e: 'update:checked', checked: boolean): void;
|
|
28
28
|
}
|
|
29
|
+
export declare const defaultOptionKeys: {
|
|
30
|
+
label: string;
|
|
31
|
+
value: string;
|
|
32
|
+
};
|
|
33
|
+
export type CheckboxGroupOption = {
|
|
34
|
+
[key: PropertyKey]: any;
|
|
35
|
+
} | string | number | boolean;
|
|
36
|
+
export interface CheckboxGroupOptionKeys {
|
|
37
|
+
label?: string;
|
|
38
|
+
value?: string;
|
|
39
|
+
}
|
|
29
40
|
export interface CheckboxGroupProps {
|
|
30
41
|
rootStyle?: StyleValue;
|
|
31
42
|
rootClass?: string;
|
|
@@ -37,6 +48,8 @@ export interface CheckboxGroupProps {
|
|
|
37
48
|
checkedColor?: string;
|
|
38
49
|
direction?: 'horizontal' | 'vertical';
|
|
39
50
|
validateEvent?: boolean;
|
|
51
|
+
options?: CheckboxGroupOption[];
|
|
52
|
+
optionKeys?: CheckboxGroupOptionKeys;
|
|
40
53
|
}
|
|
41
54
|
export declare const checkboxGroupPropsDefaults: {
|
|
42
55
|
direction: "vertical";
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { defaultConfig } from '../config';
|
|
2
2
|
export const checkboxPropsDefaults = defaultConfig.checkbox;
|
|
3
|
+
export const defaultOptionKeys = {
|
|
4
|
+
label: 'label',
|
|
5
|
+
value: 'value',
|
|
6
|
+
};
|
|
3
7
|
export const checkboxGroupPropsDefaults = defaultConfig.checkboxGroup;
|
|
4
8
|
export const checkboxContextSymbol = Symbol('checkbox-context');
|
|
5
9
|
export const mapTypeIcon = {
|
|
@@ -9,19 +9,32 @@
|
|
|
9
9
|
:toggle="toggle"
|
|
10
10
|
:value="innerValue"
|
|
11
11
|
></slot>
|
|
12
|
-
<slot v-else
|
|
12
|
+
<slot v-else>
|
|
13
|
+
<template v-if="options">
|
|
14
|
+
<sar-checkbox
|
|
15
|
+
v-for="option in options"
|
|
16
|
+
:key="isPrimitive(option) ? option : option[fieldKeys.value]"
|
|
17
|
+
:value="isPrimitive(option) ? option : option[fieldKeys.value]"
|
|
18
|
+
:validate-event="false"
|
|
19
|
+
>
|
|
20
|
+
{{ isPrimitive(option) ? option : option[fieldKeys.label] }}
|
|
21
|
+
</sar-checkbox>
|
|
22
|
+
</template>
|
|
23
|
+
</slot>
|
|
13
24
|
</view>
|
|
14
25
|
</template>
|
|
15
26
|
|
|
16
27
|
<script>
|
|
17
28
|
import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
|
|
18
|
-
import { ref, watch, provide, toRef, reactive } from "vue";
|
|
29
|
+
import { ref, watch, provide, toRef, reactive, computed } from "vue";
|
|
19
30
|
import {
|
|
20
31
|
checkboxContextSymbol,
|
|
21
|
-
checkboxGroupPropsDefaults
|
|
32
|
+
checkboxGroupPropsDefaults,
|
|
33
|
+
defaultOptionKeys
|
|
22
34
|
} from "../checkbox/common";
|
|
23
|
-
import { classNames, createBem, stringifyStyle } from "../../utils";
|
|
35
|
+
import { classNames, createBem, isPrimitive, stringifyStyle } from "../../utils";
|
|
24
36
|
import { useFormItemContext } from "../form/common";
|
|
37
|
+
import SarCheckbox from "../checkbox/checkbox.vue";
|
|
25
38
|
export default _defineComponent({
|
|
26
39
|
...{
|
|
27
40
|
options: {
|
|
@@ -40,7 +53,9 @@ export default _defineComponent({
|
|
|
40
53
|
type: { type: String, required: false },
|
|
41
54
|
checkedColor: { type: String, required: false },
|
|
42
55
|
direction: { type: String, required: false },
|
|
43
|
-
validateEvent: { type: Boolean, required: false }
|
|
56
|
+
validateEvent: { type: Boolean, required: false },
|
|
57
|
+
options: { type: Array, required: false },
|
|
58
|
+
optionKeys: { type: Object, required: false }
|
|
44
59
|
}, checkboxGroupPropsDefaults),
|
|
45
60
|
emits: ["click", "update:model-value"],
|
|
46
61
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
@@ -49,6 +64,9 @@ export default _defineComponent({
|
|
|
49
64
|
const emit = __emit;
|
|
50
65
|
const bem = createBem("checkbox-group");
|
|
51
66
|
const formItemContext = useFormItemContext();
|
|
67
|
+
const fieldKeys = computed(() => {
|
|
68
|
+
return Object.assign({}, defaultOptionKeys, props.optionKeys);
|
|
69
|
+
});
|
|
52
70
|
const innerValue = ref(props.modelValue || []);
|
|
53
71
|
watch(
|
|
54
72
|
() => props.modelValue,
|
|
@@ -76,11 +94,13 @@ export default _defineComponent({
|
|
|
76
94
|
toggle
|
|
77
95
|
})
|
|
78
96
|
);
|
|
79
|
-
const __returned__ = { props, emit, bem, formItemContext, innerValue, toggle, get classNames() {
|
|
97
|
+
const __returned__ = { props, emit, bem, formItemContext, fieldKeys, innerValue, toggle, get classNames() {
|
|
80
98
|
return classNames;
|
|
99
|
+
}, get isPrimitive() {
|
|
100
|
+
return isPrimitive;
|
|
81
101
|
}, get stringifyStyle() {
|
|
82
102
|
return stringifyStyle;
|
|
83
|
-
} };
|
|
103
|
+
}, SarCheckbox };
|
|
84
104
|
return __returned__;
|
|
85
105
|
}
|
|
86
106
|
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type CheckboxInputProps } from './common';
|
|
2
|
+
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<CheckboxInputProps>, {
|
|
3
|
+
options: () => never[];
|
|
4
|
+
validateEvent: boolean;
|
|
5
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
|
+
"update:visible": (visible: boolean) => void;
|
|
7
|
+
"update:model-value": (value: any) => void;
|
|
8
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<CheckboxInputProps>, {
|
|
9
|
+
options: () => never[];
|
|
10
|
+
validateEvent: boolean;
|
|
11
|
+
}>>> & {
|
|
12
|
+
"onUpdate:model-value"?: ((value: any) => any) | undefined;
|
|
13
|
+
"onUpdate:visible"?: ((visible: boolean) => any) | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
options: import("../checkbox/common").CheckboxGroupOption[];
|
|
16
|
+
validateEvent: boolean;
|
|
17
|
+
}, {}>;
|
|
18
|
+
export default _default;
|
|
19
|
+
type __VLS_WithDefaults<P, D> = {
|
|
20
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
21
|
+
default: D[K];
|
|
22
|
+
}> : P[K];
|
|
23
|
+
};
|
|
24
|
+
type __VLS_Prettify<T> = {
|
|
25
|
+
[K in keyof T]: T[K];
|
|
26
|
+
} & {};
|
|
27
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
28
|
+
type __VLS_TypePropsToOption<T> = {
|
|
29
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
30
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
31
|
+
} : {
|
|
32
|
+
type: import('vue').PropType<T[K]>;
|
|
33
|
+
required: true;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<sar-popout-input
|
|
3
|
+
v-model="inputValue"
|
|
4
|
+
:placeholder="placeholder"
|
|
5
|
+
:readonly="readonly"
|
|
6
|
+
:disabled="disabled"
|
|
7
|
+
:clearable="clearable"
|
|
8
|
+
multiline
|
|
9
|
+
@clear="onClear"
|
|
10
|
+
@click="onInputClick"
|
|
11
|
+
/>
|
|
12
|
+
|
|
13
|
+
<sar-popout
|
|
14
|
+
:root-class="rootClass"
|
|
15
|
+
:root-style="rootStyle"
|
|
16
|
+
:visible="innerVisible"
|
|
17
|
+
@update:visible="onVisible"
|
|
18
|
+
:title="title ?? placeholder"
|
|
19
|
+
@confirm="onConfirm"
|
|
20
|
+
>
|
|
21
|
+
<template #visible="{ already }">
|
|
22
|
+
<scroll-view v-if="already" scroll-y :class="bem.e('scroll')">
|
|
23
|
+
<sar-checkbox-group
|
|
24
|
+
:size="size"
|
|
25
|
+
:type="type"
|
|
26
|
+
:checkedColor="checkedColor"
|
|
27
|
+
:direction="direction"
|
|
28
|
+
:validate-event="false"
|
|
29
|
+
:model-value="popoutValue"
|
|
30
|
+
@update:model-value="onChange"
|
|
31
|
+
>
|
|
32
|
+
<template #custom="{ toggle }">
|
|
33
|
+
<sar-list inlaid>
|
|
34
|
+
<sar-list-item
|
|
35
|
+
v-for="option in options"
|
|
36
|
+
:key="option[fieldKeys.value]"
|
|
37
|
+
:title="option[fieldKeys.label]"
|
|
38
|
+
hover
|
|
39
|
+
@click="toggle(option[fieldKeys.value])"
|
|
40
|
+
>
|
|
41
|
+
<template #value>
|
|
42
|
+
<sar-checkbox
|
|
43
|
+
readonly
|
|
44
|
+
:value="option[fieldKeys.value]"
|
|
45
|
+
:validate-event="false"
|
|
46
|
+
/>
|
|
47
|
+
</template>
|
|
48
|
+
</sar-list-item>
|
|
49
|
+
</sar-list>
|
|
50
|
+
</template>
|
|
51
|
+
</sar-checkbox-group>
|
|
52
|
+
</scroll-view>
|
|
53
|
+
</template>
|
|
54
|
+
</sar-popout>
|
|
55
|
+
</template>
|
|
56
|
+
|
|
57
|
+
<script>
|
|
58
|
+
import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
|
|
59
|
+
import { ref, watch, computed } from "vue";
|
|
60
|
+
import SarPopoutInput from "../popout-input/popout-input.vue";
|
|
61
|
+
import SarPopout from "../popout/popout.vue";
|
|
62
|
+
import SarCheckboxGroup from "../checkbox-group/checkbox-group.vue";
|
|
63
|
+
import SarCheckbox from "../checkbox/checkbox.vue";
|
|
64
|
+
import {
|
|
65
|
+
defaultOptionKeys
|
|
66
|
+
} from "../checkbox/common";
|
|
67
|
+
import {
|
|
68
|
+
checkboxInputPropsDefaults
|
|
69
|
+
} from "./common";
|
|
70
|
+
import { createBem, isNullish } from "../../utils";
|
|
71
|
+
import { useFormItemContext } from "../form/common";
|
|
72
|
+
export default _defineComponent({
|
|
73
|
+
...{
|
|
74
|
+
options: {
|
|
75
|
+
virtualHost: true,
|
|
76
|
+
styleIsolation: "shared"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
__name: "checkbox-input",
|
|
80
|
+
props: _mergeDefaults({
|
|
81
|
+
visible: { type: Boolean, required: false },
|
|
82
|
+
title: { type: String, required: false },
|
|
83
|
+
rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
|
|
84
|
+
rootClass: { type: String, required: false },
|
|
85
|
+
modelValue: { type: Array, required: false },
|
|
86
|
+
disabled: { type: Boolean, required: false },
|
|
87
|
+
readonly: { type: Boolean, required: false },
|
|
88
|
+
size: { type: String, required: false },
|
|
89
|
+
type: { type: String, required: false },
|
|
90
|
+
checkedColor: { type: String, required: false },
|
|
91
|
+
direction: { type: String, required: false },
|
|
92
|
+
validateEvent: { type: Boolean, required: false },
|
|
93
|
+
options: { type: Array, required: false },
|
|
94
|
+
optionKeys: { type: Object, required: false },
|
|
95
|
+
placeholder: { type: String, required: false },
|
|
96
|
+
clearable: { type: Boolean, required: false },
|
|
97
|
+
loading: { type: Boolean, required: false },
|
|
98
|
+
multiline: { type: Boolean, required: false }
|
|
99
|
+
}, checkboxInputPropsDefaults),
|
|
100
|
+
emits: ["update:visible", "update:model-value"],
|
|
101
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
102
|
+
__expose();
|
|
103
|
+
const props = __props;
|
|
104
|
+
const emit = __emit;
|
|
105
|
+
const bem = createBem("checkbox-input");
|
|
106
|
+
const formItemContext = useFormItemContext();
|
|
107
|
+
const fieldKeys = computed(() => {
|
|
108
|
+
return Object.assign({}, defaultOptionKeys, props.optionKeys);
|
|
109
|
+
});
|
|
110
|
+
const innerValue = ref(props.modelValue);
|
|
111
|
+
watch(
|
|
112
|
+
() => props.modelValue,
|
|
113
|
+
() => {
|
|
114
|
+
innerValue.value = props.modelValue;
|
|
115
|
+
if (props.validateEvent) {
|
|
116
|
+
formItemContext?.onChange();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
const popoutValue = ref(props.modelValue);
|
|
121
|
+
watch(innerValue, () => {
|
|
122
|
+
popoutValue.value = innerValue.value;
|
|
123
|
+
});
|
|
124
|
+
const onChange = (value) => {
|
|
125
|
+
popoutValue.value = value;
|
|
126
|
+
};
|
|
127
|
+
const onConfirm = () => {
|
|
128
|
+
innerValue.value = popoutValue.value;
|
|
129
|
+
emit("update:model-value", popoutValue.value);
|
|
130
|
+
inputValue.value = getInputValue();
|
|
131
|
+
};
|
|
132
|
+
const inputValue = ref("");
|
|
133
|
+
function getOutletText(options, optionKeys, value) {
|
|
134
|
+
return options.filter((option) => value.includes(option[optionKeys.value])).map((option) => option[optionKeys.label]).join(", ");
|
|
135
|
+
}
|
|
136
|
+
function getInputValue() {
|
|
137
|
+
if (isNullish(innerValue.value) || innerValue.value.length === 0) {
|
|
138
|
+
return "";
|
|
139
|
+
}
|
|
140
|
+
return getOutletText(props.options, fieldKeys.value, innerValue.value);
|
|
141
|
+
}
|
|
142
|
+
watch(
|
|
143
|
+
innerValue,
|
|
144
|
+
() => {
|
|
145
|
+
inputValue.value = getInputValue();
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
immediate: true
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
watch(
|
|
152
|
+
() => props.options,
|
|
153
|
+
() => {
|
|
154
|
+
inputValue.value = getInputValue();
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
const onClear = () => {
|
|
158
|
+
inputValue.value = "";
|
|
159
|
+
innerValue.value = void 0;
|
|
160
|
+
emit("update:model-value", void 0);
|
|
161
|
+
};
|
|
162
|
+
const innerVisible = ref(props.visible);
|
|
163
|
+
watch(
|
|
164
|
+
() => props.visible,
|
|
165
|
+
() => {
|
|
166
|
+
innerVisible.value = props.visible;
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
const onVisible = (visible) => {
|
|
170
|
+
innerVisible.value = visible;
|
|
171
|
+
emit("update:visible", visible);
|
|
172
|
+
};
|
|
173
|
+
const onInputClick = () => {
|
|
174
|
+
innerVisible.value = true;
|
|
175
|
+
emit("update:visible", true);
|
|
176
|
+
};
|
|
177
|
+
const __returned__ = { props, emit, bem, formItemContext, fieldKeys, innerValue, popoutValue, onChange, onConfirm, inputValue, getOutletText, getInputValue, onClear, innerVisible, onVisible, onInputClick, SarPopoutInput, SarPopout, SarCheckboxGroup, SarCheckbox };
|
|
178
|
+
return __returned__;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
</script>
|
|
182
|
+
|
|
183
|
+
<style lang="scss">
|
|
184
|
+
@import './index.scss';
|
|
185
|
+
</style>
|