sard-uniapp 1.23.4 → 1.24.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.
- package/CHANGELOG.md +37 -0
- package/README.md +2 -2
- package/components/calendar-input/calendar-input.vue +1 -0
- package/components/card/README.md +7 -0
- package/components/card/card.vue +17 -8
- package/components/card/common.d.ts +1 -0
- package/components/card/index.scss +1 -1
- package/components/cascader-input/cascader-input.vue +1 -0
- package/components/checkbox-input/checkbox-input.vue +1 -0
- package/components/config/index.d.ts +21 -0
- package/components/config/index.js +19 -1
- package/components/cool-icon/README.md +81 -0
- package/components/cool-icon/common.d.ts +21 -0
- package/components/cool-icon/common.js +2 -0
- package/components/cool-icon/cool-icon.d.ts +16 -0
- package/components/cool-icon/cool-icon.vue +86 -0
- package/components/cool-icon/index.d.ts +1 -0
- package/components/cool-icon/index.js +1 -0
- package/components/cool-icon/index.scss +186 -0
- package/components/cool-icon/variables.scss +12 -0
- package/components/datetime-picker-input/datetime-picker-input.vue +1 -0
- package/components/datetime-range-picker-input/datetime-range-picker-input.vue +1 -0
- package/components/input/common.d.ts +2 -0
- package/components/input/input.d.ts +1 -0
- package/components/input/input.vue +7 -3
- package/components/keyboard/README.md +15 -14
- package/components/keyboard/common.d.ts +3 -1
- package/components/keyboard/keyboard.d.ts +2 -1
- package/components/keyboard/keyboard.vue +9 -7
- package/components/radio-input/radio-input.vue +1 -0
- package/components/segmented/README.md +147 -0
- package/components/segmented/common.d.ts +52 -0
- package/components/segmented/common.js +8 -0
- package/components/segmented/index.d.ts +1 -0
- package/components/segmented/index.js +1 -0
- package/components/segmented/index.scss +60 -0
- package/components/segmented/segmented.d.ts +21 -0
- package/components/segmented/segmented.vue +163 -0
- package/components/segmented/variables.scss +21 -0
- package/components/segmented-item/common.d.ts +21 -0
- package/components/segmented-item/common.js +1 -0
- package/components/segmented-item/index.d.ts +1 -0
- package/components/segmented-item/index.js +1 -0
- package/components/segmented-item/index.scss +60 -0
- package/components/segmented-item/segmented-item.d.ts +14 -0
- package/components/segmented-item/segmented-item.vue +99 -0
- package/components/sticky/README.md +4 -0
- package/components/tree/README.md +5 -4
- package/components/tree/common.d.ts +5 -1
- package/components/tree/tree.d.ts +8 -0
- package/components/tree/tree.vue +11 -2
- package/components/tree-node/tree-node.vue +1 -1
- package/components/upload/README.md +15 -1
- package/components/upload/common.d.ts +2 -2
- package/components/upload/upload.d.ts +0 -1
- package/components/upload/upload.vue +2 -2
- package/components/upload/utils.d.ts +2 -2
- package/components/upload/utils.js +33 -2
- package/components/watermark/README.md +74 -0
- package/components/watermark/common.d.ts +37 -0
- package/components/watermark/common.js +10 -0
- package/components/watermark/index.d.ts +1 -0
- package/components/watermark/index.js +1 -0
- package/components/watermark/index.scss +28 -0
- package/components/watermark/variables.scss +5 -0
- package/components/watermark/watermark.d.ts +16 -0
- package/components/watermark/watermark.vue +263 -0
- package/global.d.ts +4 -0
- package/index.d.ts +4 -0
- package/index.js +4 -0
- package/index.scss +3 -0
- package/package.json +3 -2
- package/utils/array.d.ts +1 -1
- package/utils/geometry.d.ts +11 -0
- package/utils/geometry.js +28 -0
- package/utils/object.d.ts +2 -2
- package/utils/object.js +3 -3
- package/components/upload-preview/play.png +0 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
@use '../style/base' as *;
|
|
2
|
+
|
|
3
|
+
@mixin box-shadow {
|
|
4
|
+
&::before {
|
|
5
|
+
content: '';
|
|
6
|
+
display: block;
|
|
7
|
+
background: inherit;
|
|
8
|
+
filter: blur(5px);
|
|
9
|
+
position: absolute;
|
|
10
|
+
width: 100%;
|
|
11
|
+
height: 100%;
|
|
12
|
+
top: 5px;
|
|
13
|
+
left: 5px;
|
|
14
|
+
z-index: -1;
|
|
15
|
+
opacity: var(--sar-cool-icon-shadow-opacity);
|
|
16
|
+
transform-origin: 0 0;
|
|
17
|
+
border-radius: inherit;
|
|
18
|
+
transform: scale(1);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@include bem(cool-icon) {
|
|
23
|
+
@include b() {
|
|
24
|
+
@include universal;
|
|
25
|
+
|
|
26
|
+
position: relative;
|
|
27
|
+
display: inline-block;
|
|
28
|
+
|
|
29
|
+
width: var(--sar-cool-icon-size);
|
|
30
|
+
height: var(--sar-cool-icon-size);
|
|
31
|
+
font-size: var(--sar-cool-icon-icon-size);
|
|
32
|
+
|
|
33
|
+
@include m(square) {
|
|
34
|
+
border-radius: var(--sar-cool-icon-square-border-radius);
|
|
35
|
+
|
|
36
|
+
@include e(bg) {
|
|
37
|
+
@include box-shadow;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@include m(oval) {
|
|
42
|
+
border-radius: var(--sar-cool-icon-oval-border-radius);
|
|
43
|
+
|
|
44
|
+
@include e(bg) {
|
|
45
|
+
transform: rotate(-19deg);
|
|
46
|
+
@include box-shadow;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@include m(triangle) {
|
|
51
|
+
border-radius: var(--sar-cool-icon-triangle-border-radius);
|
|
52
|
+
|
|
53
|
+
@include e(bg) {
|
|
54
|
+
@include box-shadow;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@include m(circle) {
|
|
59
|
+
border-radius: 50%;
|
|
60
|
+
|
|
61
|
+
@include e(bg) {
|
|
62
|
+
@include box-shadow;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@include m(flower) {
|
|
67
|
+
border-radius: var(--sar-cool-icon-oval-border-radius);
|
|
68
|
+
|
|
69
|
+
@include e(bg) {
|
|
70
|
+
width: 62.5%;
|
|
71
|
+
margin: auto;
|
|
72
|
+
border-radius: var(--sar-rounded-full);
|
|
73
|
+
|
|
74
|
+
&::before,
|
|
75
|
+
&::after {
|
|
76
|
+
content: '';
|
|
77
|
+
position: absolute;
|
|
78
|
+
left: 0;
|
|
79
|
+
right: 0;
|
|
80
|
+
top: 0;
|
|
81
|
+
bottom: 0;
|
|
82
|
+
width: 100%;
|
|
83
|
+
height: 100%;
|
|
84
|
+
background: inherit;
|
|
85
|
+
border-radius: inherit;
|
|
86
|
+
transform-origin: center center;
|
|
87
|
+
opacity: 0.8;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&::before {
|
|
91
|
+
transform: rotate(60deg);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&::after {
|
|
95
|
+
transform: rotate(-60deg);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@include e(adorns) {
|
|
99
|
+
display: none;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@include e(bg) {
|
|
106
|
+
@include universal;
|
|
107
|
+
position: absolute;
|
|
108
|
+
left: 0;
|
|
109
|
+
right: 0;
|
|
110
|
+
top: 0;
|
|
111
|
+
bottom: 0;
|
|
112
|
+
width: 100%;
|
|
113
|
+
height: 100%;
|
|
114
|
+
border-radius: inherit;
|
|
115
|
+
z-index: 1;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@include e(icon) {
|
|
119
|
+
position: relative;
|
|
120
|
+
width: 100%;
|
|
121
|
+
height: 100%;
|
|
122
|
+
display: flex;
|
|
123
|
+
align-items: center;
|
|
124
|
+
justify-content: center;
|
|
125
|
+
font-size: inherit;
|
|
126
|
+
line-height: 1;
|
|
127
|
+
z-index: 2;
|
|
128
|
+
border-radius: inherit;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@include e(adorns) {
|
|
132
|
+
position: absolute;
|
|
133
|
+
left: 0;
|
|
134
|
+
right: 0;
|
|
135
|
+
top: 0;
|
|
136
|
+
z-index: 1;
|
|
137
|
+
bottom: 0;
|
|
138
|
+
width: 100%;
|
|
139
|
+
height: 100%;
|
|
140
|
+
border-radius: inherit;
|
|
141
|
+
overflow: hidden;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@include e(adorn) {
|
|
145
|
+
position: absolute;
|
|
146
|
+
border-radius: 50%;
|
|
147
|
+
background: var(--sar-cool-icon-adorn-bg);
|
|
148
|
+
|
|
149
|
+
&:nth-child(1) {
|
|
150
|
+
top: -13.33%;
|
|
151
|
+
left: -9.46%;
|
|
152
|
+
width: 45.33%;
|
|
153
|
+
height: 45.33%;
|
|
154
|
+
}
|
|
155
|
+
&:nth-child(2) {
|
|
156
|
+
top: 8.66%;
|
|
157
|
+
left: 66.66%;
|
|
158
|
+
width: 10%;
|
|
159
|
+
height: 10%;
|
|
160
|
+
}
|
|
161
|
+
&:nth-child(3) {
|
|
162
|
+
top: 79.33%;
|
|
163
|
+
left: 18%;
|
|
164
|
+
width: 6.66%;
|
|
165
|
+
height: 6.66%;
|
|
166
|
+
}
|
|
167
|
+
&:nth-child(4) {
|
|
168
|
+
top: 86%;
|
|
169
|
+
left: 26.66%;
|
|
170
|
+
width: 4%;
|
|
171
|
+
height: 4%;
|
|
172
|
+
}
|
|
173
|
+
&:nth-child(5) {
|
|
174
|
+
top: 72%;
|
|
175
|
+
left: 44.66%;
|
|
176
|
+
width: 47.33%;
|
|
177
|
+
height: 38.66%;
|
|
178
|
+
}
|
|
179
|
+
&:nth-child(6) {
|
|
180
|
+
top: 42%;
|
|
181
|
+
left: 58.66%;
|
|
182
|
+
width: 72.66%;
|
|
183
|
+
height: 66.66%;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// #variables
|
|
2
|
+
page,
|
|
3
|
+
.sar-portal {
|
|
4
|
+
--sar-cool-icon-size: 100rpx;
|
|
5
|
+
--sar-cool-icon-icon-size: 60rpx;
|
|
6
|
+
--sar-cool-icon-oval-border-radius: 43% 57% / 57% 43%;
|
|
7
|
+
--sar-cool-icon-square-border-radius: 25%;
|
|
8
|
+
--sar-cool-icon-triangle-border-radius: 68% 32% 40% 60%/44% 34% 66% 56%;
|
|
9
|
+
--sar-cool-icon-shadow-opacity: 0.4;
|
|
10
|
+
--sar-cool-icon-adorn-bg: rgba(255, 255, 255, 0.2);
|
|
11
|
+
}
|
|
12
|
+
// #endvariables
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type StyleValue } from 'vue';
|
|
2
2
|
export interface InputProps {
|
|
3
|
+
enableNative?: boolean;
|
|
3
4
|
placeholder?: string;
|
|
4
5
|
placeholderStyle?: string;
|
|
5
6
|
placeholderClass?: string;
|
|
@@ -49,6 +50,7 @@ export interface InputProps {
|
|
|
49
50
|
internalPrepend?: number;
|
|
50
51
|
}
|
|
51
52
|
export declare const defaultInputProps: {
|
|
53
|
+
enableNative: boolean;
|
|
52
54
|
maxlength: number;
|
|
53
55
|
adjustPosition: boolean;
|
|
54
56
|
ignoreCompositionEvent: boolean;
|
|
@@ -11,6 +11,7 @@ declare const __VLS_component: import("vue").DefineComponent<InputProps, {}, {},
|
|
|
11
11
|
confirmType: "send" | "search" | "next" | "go" | "done";
|
|
12
12
|
inputmode: "none" | "text" | "decimal" | "numeric" | "tel" | "search" | "email" | "url";
|
|
13
13
|
validateEvent: boolean;
|
|
14
|
+
enableNative: boolean;
|
|
14
15
|
maxlength: number;
|
|
15
16
|
cursorSpacing: number;
|
|
16
17
|
cursor: number;
|
|
@@ -16,10 +16,11 @@
|
|
|
16
16
|
bem.em('control', 'input-min-height', inputMinHeight),
|
|
17
17
|
)
|
|
18
18
|
"
|
|
19
|
+
:enableNative="enableNative"
|
|
20
|
+
:value="innerValue"
|
|
19
21
|
:placeholder="placeholder"
|
|
20
22
|
:placeholder-style="mergedPlaceholderStyle"
|
|
21
23
|
:placeholder-class="placeholderClass"
|
|
22
|
-
:value="innerValue"
|
|
23
24
|
:disabled="isDisabled || isReadonly"
|
|
24
25
|
:maxlength="maxlength"
|
|
25
26
|
:focus="focus"
|
|
@@ -51,6 +52,7 @@
|
|
|
51
52
|
<input
|
|
52
53
|
v-if="type !== 'textarea' && showPassword"
|
|
53
54
|
:class="classNames(bem.e('control'), bem.em('control', 'input'))"
|
|
55
|
+
:enableNative="enableNative"
|
|
54
56
|
:value="innerValue"
|
|
55
57
|
:placeholder="placeholder"
|
|
56
58
|
:placeholder-style="mergedPlaceholderStyle"
|
|
@@ -91,6 +93,7 @@
|
|
|
91
93
|
<input
|
|
92
94
|
v-if="type !== 'textarea' && !showPassword"
|
|
93
95
|
:class="classNames(bem.e('control'), bem.em('control', 'input'))"
|
|
96
|
+
:enableNative="enableNative"
|
|
94
97
|
:value="innerValue"
|
|
95
98
|
:placeholder="placeholder"
|
|
96
99
|
:placeholder-style="mergedPlaceholderStyle"
|
|
@@ -236,6 +239,7 @@ export default _defineComponent({
|
|
|
236
239
|
},
|
|
237
240
|
__name: "input",
|
|
238
241
|
props: _mergeDefaults({
|
|
242
|
+
enableNative: { type: Boolean, required: false },
|
|
239
243
|
placeholder: { type: String, required: false },
|
|
240
244
|
placeholderStyle: { type: String, required: false },
|
|
241
245
|
placeholderClass: { type: String, required: false },
|
|
@@ -386,10 +390,10 @@ export default _defineComponent({
|
|
|
386
390
|
const showPassword = computed(() => {
|
|
387
391
|
return props.type === "password" && isPlainText.value === false;
|
|
388
392
|
});
|
|
389
|
-
const mergedShowEye = computed(() => props.type === "password" && props.showEye);
|
|
390
393
|
const mergedType = computed(() => {
|
|
391
394
|
return showPassword.value ? "password" : props.type === "password" ? "text" : props.type;
|
|
392
395
|
});
|
|
396
|
+
const mergedShowEye = computed(() => props.type === "password" && props.showEye);
|
|
393
397
|
const inputClass = computed(() => {
|
|
394
398
|
return classNames(
|
|
395
399
|
bem.b(),
|
|
@@ -428,7 +432,7 @@ export default _defineComponent({
|
|
|
428
432
|
return oldValue;
|
|
429
433
|
}, set oldValue(v) {
|
|
430
434
|
oldValue = v;
|
|
431
|
-
}, onFocus, onBlur, clearVisible, holdupClear, onClearTouchStart, onClearTouchEnd, onClearMouseDown, onClearClick, onLinechange, onConfirm, onKeyboardheightchange, onClick, isPlainText, eyeIcon, onEyeClick, showPassword,
|
|
435
|
+
}, onFocus, onBlur, clearVisible, holdupClear, onClearTouchStart, onClearTouchEnd, onClearMouseDown, onClearClick, onLinechange, onConfirm, onKeyboardheightchange, onClick, isPlainText, eyeIcon, onEyeClick, showPassword, mergedType, mergedShowEye, inputClass, inputStyle, controlStyle, mergedPlaceholderStyle, get classNames() {
|
|
432
436
|
return classNames;
|
|
433
437
|
}, SarIcon };
|
|
434
438
|
return __returned__;
|
|
@@ -51,26 +51,27 @@ import Keyboard from 'sard-uniapp/components/keyboard/keyboard.vue'
|
|
|
51
51
|
|
|
52
52
|
### KeyboardProps
|
|
53
53
|
|
|
54
|
-
| 属性
|
|
55
|
-
|
|
|
56
|
-
| root-class
|
|
57
|
-
| root-style
|
|
58
|
-
| type
|
|
54
|
+
| 属性 | 描述 | 类型 | 默认值 |
|
|
55
|
+
| -------------------- | ------------------ | ------------------------------------------------------ | --------- |
|
|
56
|
+
| root-class | 组件根元素类名 | string | - |
|
|
57
|
+
| root-style | 组件根元素样式 | StyleValue | - |
|
|
58
|
+
| type | 键盘类型 | 'number' \| 'digit' \| 'idcard' \| 'random' \| 'plate' | 'number' |
|
|
59
|
+
| mode<sup>1.24+</sup> | plate 键盘时的模式 | 'chinese' \| 'english' | 'chinese' |
|
|
59
60
|
|
|
60
61
|
### KeyboardEmits
|
|
61
62
|
|
|
62
|
-
| 事件
|
|
63
|
-
|
|
|
64
|
-
| input
|
|
65
|
-
| delete
|
|
66
|
-
| toggle
|
|
63
|
+
| 事件 | 描述 | 类型 |
|
|
64
|
+
| ------------------------ | ------------------------ | -------------------------------------- |
|
|
65
|
+
| input | 可输入按键点击时触发 | (key: string) => void |
|
|
66
|
+
| delete | 点击删除按钮时触发 | () => void |
|
|
67
|
+
| toggle<sup>1.23.3+</sup> | 切换车牌号的中英文时触发 | (mode: 'chinese' \| 'english') => void |
|
|
67
68
|
|
|
68
69
|
### KeyBoardExpose
|
|
69
70
|
|
|
70
|
-
| 属性
|
|
71
|
-
|
|
|
72
|
-
| shuffle
|
|
73
|
-
| toggle
|
|
71
|
+
| 属性 | 描述 | 类型 |
|
|
72
|
+
| ------------------------ | ------------------------------------ | -------------------------------------- |
|
|
73
|
+
| shuffle | 重新打乱随机键盘按键 | () => void |
|
|
74
|
+
| toggle<sup>1.23.6+</sup> | 切换车牌号的中英文按键,可选传入mode | (mode?: 'chinese'\| 'english') => void |
|
|
74
75
|
|
|
75
76
|
## 主题定制
|
|
76
77
|
|
|
@@ -3,9 +3,11 @@ export interface KeyboardProps {
|
|
|
3
3
|
rootStyle?: StyleValue;
|
|
4
4
|
rootClass?: string;
|
|
5
5
|
type?: 'number' | 'digit' | 'idcard' | 'random' | 'plate';
|
|
6
|
+
mode?: KeyboardPlateMode;
|
|
6
7
|
}
|
|
7
8
|
export declare const defaultKeyboardProps: {
|
|
8
9
|
type: KeyboardProps["type"];
|
|
10
|
+
mode: KeyboardProps["mode"];
|
|
9
11
|
};
|
|
10
12
|
export interface KeyboardSlots {
|
|
11
13
|
default?(props: Record<string, never>): any;
|
|
@@ -18,7 +20,7 @@ export interface KeyboardEmits {
|
|
|
18
20
|
}
|
|
19
21
|
export interface KeyBoardExpose {
|
|
20
22
|
shuffle: () => void;
|
|
21
|
-
toggle: () => void;
|
|
23
|
+
toggle: (mode?: KeyboardPlateMode) => void;
|
|
22
24
|
}
|
|
23
25
|
export declare const numberKeys: string[];
|
|
24
26
|
export declare const digitKeys: string[];
|
|
@@ -2,7 +2,7 @@ import { type KeyboardProps, type KeyboardSlots, type KeyboardPlateMode } from '
|
|
|
2
2
|
declare function __VLS_template(): Readonly<KeyboardSlots> & KeyboardSlots;
|
|
3
3
|
declare const __VLS_component: import("vue").DefineComponent<KeyboardProps, {
|
|
4
4
|
shuffle: () => void;
|
|
5
|
-
toggle: () => void;
|
|
5
|
+
toggle: (mode?: KeyboardPlateMode) => void;
|
|
6
6
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
7
7
|
delete: () => any;
|
|
8
8
|
input: (key: string) => any;
|
|
@@ -13,6 +13,7 @@ declare const __VLS_component: import("vue").DefineComponent<KeyboardProps, {
|
|
|
13
13
|
onToggle?: ((mode: KeyboardPlateMode) => any) | undefined;
|
|
14
14
|
}>, {
|
|
15
15
|
type: "number" | "digit" | "idcard" | "random" | "plate";
|
|
16
|
+
mode: KeyboardPlateMode;
|
|
16
17
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
17
18
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
18
19
|
export default _default;
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
<view
|
|
88
88
|
:class="toggleClass"
|
|
89
89
|
:style="`order: ${interceptOrder}`"
|
|
90
|
-
@click="onToggle"
|
|
90
|
+
@click="onToggle()"
|
|
91
91
|
>
|
|
92
92
|
<view :class="bem.e('key')">
|
|
93
93
|
{{ toggleKey }}
|
|
@@ -121,6 +121,7 @@ import SarIcon from "../icon/icon.vue";
|
|
|
121
121
|
* @property {string} rootClass 组件根元素类名,默认值:-。
|
|
122
122
|
* @property {StyleValue} rootStyle 组件根元素样式,默认值:-。
|
|
123
123
|
* @property {'number' | 'digit' | 'idcard' | 'random' | 'plate'} type 键盘类型,默认值:'number'。
|
|
124
|
+
* @property {'chinese' | 'english'} mode plate 键盘时的模式,默认值:'chinese'。
|
|
124
125
|
* @event {(key: string) => void} input 可输入按键点击时触发
|
|
125
126
|
* @event {() => void} delete 点击删除按钮时触发
|
|
126
127
|
* @event {(mode: 'chinese' | 'english') => void} toggle 切换车牌号的中英文时触发
|
|
@@ -139,7 +140,8 @@ export default _defineComponent({
|
|
|
139
140
|
props: _mergeDefaults({
|
|
140
141
|
rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
|
|
141
142
|
rootClass: { type: String, required: false },
|
|
142
|
-
type: { type: String, required: false }
|
|
143
|
+
type: { type: String, required: false },
|
|
144
|
+
mode: { type: String, required: false }
|
|
143
145
|
}, defaultKeyboardProps),
|
|
144
146
|
emits: ["input", "delete", "toggle"],
|
|
145
147
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
@@ -156,8 +158,8 @@ export default _defineComponent({
|
|
|
156
158
|
shuffle() {
|
|
157
159
|
randomKeys.value = getRandomKeys();
|
|
158
160
|
},
|
|
159
|
-
toggle() {
|
|
160
|
-
onToggle();
|
|
161
|
+
toggle(mode2) {
|
|
162
|
+
onToggle(mode2);
|
|
161
163
|
}
|
|
162
164
|
});
|
|
163
165
|
const randomKeys = ref([]);
|
|
@@ -172,7 +174,7 @@ export default _defineComponent({
|
|
|
172
174
|
immediate: true
|
|
173
175
|
}
|
|
174
176
|
);
|
|
175
|
-
const mode = ref(
|
|
177
|
+
const mode = ref(props.mode);
|
|
176
178
|
const toggleKey = computed(() => {
|
|
177
179
|
return {
|
|
178
180
|
chinese: "ABC",
|
|
@@ -186,8 +188,8 @@ export default _defineComponent({
|
|
|
186
188
|
const overflow = chineseKeys.length % 10;
|
|
187
189
|
return chineseKeys.length - (overflow > 7 ? 0 : overflow + 1);
|
|
188
190
|
});
|
|
189
|
-
const onToggle = () => {
|
|
190
|
-
mode.value = mode.value === "chinese" ? "english" : "chinese";
|
|
191
|
+
const onToggle = (newMode) => {
|
|
192
|
+
mode.value = newMode || (mode.value === "chinese" ? "english" : "chinese");
|
|
191
193
|
emit("toggle", mode.value);
|
|
192
194
|
};
|
|
193
195
|
const keyboardClass = computed(() => {
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav: 组件
|
|
3
|
+
title: Segmented
|
|
4
|
+
subtitle: 分段控制器
|
|
5
|
+
group: 表单组件
|
|
6
|
+
version: 1.24+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 介绍
|
|
10
|
+
|
|
11
|
+
用于展示多个选项并允许用户选择其中单个选项。
|
|
12
|
+
|
|
13
|
+
## 引入
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import Segmented from 'sard-uniapp/components/segmented/segmented.vue'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 代码演示
|
|
20
|
+
|
|
21
|
+
### 基础使用
|
|
22
|
+
|
|
23
|
+
使用 `v-model` 双向绑定当前值,使用 `options` 定义选项内容。
|
|
24
|
+
|
|
25
|
+
@code('${DEMO_PATH}/segmented/demo/Basic.vue')
|
|
26
|
+
|
|
27
|
+
### 尺寸
|
|
28
|
+
|
|
29
|
+
通过 `size` 属性来定义尺寸大小。
|
|
30
|
+
|
|
31
|
+
@code('${DEMO_PATH}/segmented/demo/Size.vue')
|
|
32
|
+
|
|
33
|
+
### 胶囊形状
|
|
34
|
+
|
|
35
|
+
使用 `shape="round"` 属性可定义胶囊形状。
|
|
36
|
+
|
|
37
|
+
@code('${DEMO_PATH}/segmented/demo/Shape.vue')
|
|
38
|
+
|
|
39
|
+
### 设置图标
|
|
40
|
+
|
|
41
|
+
选项的 `icon` 属性可定义放置在 `label` 左边的图标。
|
|
42
|
+
|
|
43
|
+
@code('${DEMO_PATH}/segmented/demo/Icon.vue')
|
|
44
|
+
|
|
45
|
+
### 只设置图标
|
|
46
|
+
|
|
47
|
+
可以不配置 `label` 而只配置 `icon`。
|
|
48
|
+
|
|
49
|
+
@code('${DEMO_PATH}/segmented/demo/OnlyIcon.vue')
|
|
50
|
+
|
|
51
|
+
### 垂直方向
|
|
52
|
+
|
|
53
|
+
设置 `direction="vertical"` 属性可垂直排列分段器。
|
|
54
|
+
|
|
55
|
+
@code('${DEMO_PATH}/segmented/demo/Direction.vue')
|
|
56
|
+
|
|
57
|
+
### 禁用
|
|
58
|
+
|
|
59
|
+
可在 `segmented` 上设置 `disabled` 禁用所有选项,或者在选项上设置 `disabled` 禁用单个选项。
|
|
60
|
+
|
|
61
|
+
如果置于表单组件中,也受表单组件 `disabled` 属性的影响。
|
|
62
|
+
|
|
63
|
+
@code('${DEMO_PATH}/segmented/demo/Disabled.vue')
|
|
64
|
+
|
|
65
|
+
### 自定义内容
|
|
66
|
+
|
|
67
|
+
如果需要自定义内容,可使用 `segmented-item` 组件,需自定义循环和传递 `value` 属性。`options` 属性也需要传递,以便获取当前值的下标。
|
|
68
|
+
|
|
69
|
+
@code('${DEMO_PATH}/segmented/demo/Custom.vue')
|
|
70
|
+
|
|
71
|
+
## API
|
|
72
|
+
|
|
73
|
+
### SegmentedProps
|
|
74
|
+
|
|
75
|
+
| 属性 | 描述 | 类型 | 默认值 |
|
|
76
|
+
| -------------- | ------------------------------------- | ------------------------------ | -------------------------------- |
|
|
77
|
+
| root-class | 组件根元素类名 | string | - |
|
|
78
|
+
| root-style | 组件根元素样式 | StyleValue | - |
|
|
79
|
+
| model-value | 绑定值 | any | - |
|
|
80
|
+
| disabled | 是否禁用 | boolean | false |
|
|
81
|
+
| readonly | 是否只读 | boolean | false |
|
|
82
|
+
| size | 组件大小 | 'small' \| 'middle' \| 'large' | 'middle' |
|
|
83
|
+
| direction | 展示的方向 | 'horizontal' \| 'vertical' | 'horizontal' |
|
|
84
|
+
| shape | 形状 | 'square' \| 'round' | 'square' |
|
|
85
|
+
| options | 选项的数据 | SegmentedOption[] | - |
|
|
86
|
+
| option-keys | 自定义 options 的 label、value 的字段 | SegmentedOptionKeys | {label: 'label', value: 'value'} |
|
|
87
|
+
| validate-event | 是否触发表单验证 | boolean | true |
|
|
88
|
+
|
|
89
|
+
### SegmentedOption
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
type SegmentedOption =
|
|
93
|
+
| {
|
|
94
|
+
[key: PropertyKey]: any
|
|
95
|
+
}
|
|
96
|
+
| string
|
|
97
|
+
| number
|
|
98
|
+
| boolean
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### SegmentedOptionKeys
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
export interface SegmentedOptionKeys {
|
|
105
|
+
label?: string
|
|
106
|
+
value?: string
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### SegmentedSlots
|
|
111
|
+
|
|
112
|
+
| 插槽 | 描述 | 属性 |
|
|
113
|
+
| ------- | -------------- | ---- |
|
|
114
|
+
| default | 自定义默认内容 | - |
|
|
115
|
+
|
|
116
|
+
### SegmentedEmits
|
|
117
|
+
|
|
118
|
+
| 事件 | 描述 | 类型 |
|
|
119
|
+
| ------------------ | ------------------ | -------------------- |
|
|
120
|
+
| update:model-value | 当所选值更改时触发 | (value: any) => void |
|
|
121
|
+
| change | 当所选值更改时触发 | (value: any) => void |
|
|
122
|
+
|
|
123
|
+
### SegmentedItemProps
|
|
124
|
+
|
|
125
|
+
| 属性 | 描述 | 类型 | 默认值 |
|
|
126
|
+
| ----------- | -------------- | --------------------------- | ------ |
|
|
127
|
+
| root-class | 组件根元素类名 | string | - |
|
|
128
|
+
| root-style | 组件根元素样式 | StyleValue | - |
|
|
129
|
+
| label | 展示文本 | string \| number | - |
|
|
130
|
+
| value | 用于绑定的值 | string \| number \| boolean | - |
|
|
131
|
+
| icon | 图标 | string | - |
|
|
132
|
+
| icon-family | 图标字体 | string | - |
|
|
133
|
+
| icon-size | 图标大小 | string | - |
|
|
134
|
+
| disabled | 禁用状态 | boolean | false |
|
|
135
|
+
| readonly | 只读状态 | boolean | false |
|
|
136
|
+
|
|
137
|
+
### SegmentedItemSlots
|
|
138
|
+
|
|
139
|
+
| 插槽 | 描述 | 属性 |
|
|
140
|
+
| ------- | -------------- | ---- |
|
|
141
|
+
| default | 自定义默认内容 | - |
|
|
142
|
+
|
|
143
|
+
## 主题定制
|
|
144
|
+
|
|
145
|
+
### CSS 变量
|
|
146
|
+
|
|
147
|
+
@code('./variables.scss#variables')
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type StyleValue } from 'vue';
|
|
2
|
+
export type SegmentedOption = {
|
|
3
|
+
[key: PropertyKey]: any;
|
|
4
|
+
} | string | number | boolean;
|
|
5
|
+
export interface SegmentedOptionKeys {
|
|
6
|
+
label?: string;
|
|
7
|
+
value?: string;
|
|
8
|
+
disabled?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const defaultOptionKeys: {
|
|
11
|
+
label: string;
|
|
12
|
+
value: string;
|
|
13
|
+
disabled: string;
|
|
14
|
+
};
|
|
15
|
+
export type SegmentedSize = 'small' | 'middle' | 'large';
|
|
16
|
+
export interface SegmentedProps {
|
|
17
|
+
rootStyle?: StyleValue;
|
|
18
|
+
rootClass?: string;
|
|
19
|
+
modelValue?: any;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
readonly?: boolean;
|
|
22
|
+
size?: SegmentedSize;
|
|
23
|
+
direction?: 'horizontal' | 'vertical';
|
|
24
|
+
shape?: 'square' | 'round';
|
|
25
|
+
options?: SegmentedOption[];
|
|
26
|
+
optionKeys?: SegmentedOptionKeys;
|
|
27
|
+
validateEvent?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare const defaultSegmentedProps: {
|
|
30
|
+
size: SegmentedProps["size"];
|
|
31
|
+
shape: SegmentedProps["shape"];
|
|
32
|
+
direction: SegmentedProps["direction"];
|
|
33
|
+
validateEvent: boolean;
|
|
34
|
+
};
|
|
35
|
+
export interface SegmentedSlots {
|
|
36
|
+
default?(props: Record<string, never>): any;
|
|
37
|
+
}
|
|
38
|
+
export interface SegmentedEmits {
|
|
39
|
+
(e: 'update:model-value', value: any): void;
|
|
40
|
+
(e: 'change', value: any): void;
|
|
41
|
+
}
|
|
42
|
+
export interface SegmentedExpose {
|
|
43
|
+
}
|
|
44
|
+
export interface SegmentedContext {
|
|
45
|
+
disabled: SegmentedProps['disabled'];
|
|
46
|
+
readonly: SegmentedProps['readonly'];
|
|
47
|
+
size: SegmentedProps['size'];
|
|
48
|
+
shape: SegmentedProps['shape'];
|
|
49
|
+
value: any;
|
|
50
|
+
toggle: (value: any) => void;
|
|
51
|
+
}
|
|
52
|
+
export declare const segmentedContextSymbol: unique symbol;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defaultConfig } from '../config';
|
|
2
|
+
export const defaultOptionKeys = {
|
|
3
|
+
label: 'label',
|
|
4
|
+
value: 'value',
|
|
5
|
+
disabled: 'disabled',
|
|
6
|
+
};
|
|
7
|
+
export const defaultSegmentedProps = defaultConfig.segmented;
|
|
8
|
+
export const segmentedContextSymbol = Symbol('segmented-context');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { SegmentedProps, SegmentedSlots, SegmentedEmits, SegmentedExpose, SegmentedSize, } from './common';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|