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
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type CheckboxGroupOption, type CheckboxGroupProps } from '../checkbox/common';
|
|
2
|
+
import { type PopoutInputProps } from '../popout-input/common';
|
|
3
|
+
export type CheckboxInputOption = CheckboxGroupOption;
|
|
4
|
+
export interface CheckboxInputProps extends CheckboxGroupProps, Omit<PopoutInputProps, 'modelValue'> {
|
|
5
|
+
visible?: boolean;
|
|
6
|
+
title?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const checkboxInputPropsDefaults: {
|
|
9
|
+
options: () => never[];
|
|
10
|
+
validateEvent: boolean;
|
|
11
|
+
};
|
|
12
|
+
export interface CheckboxInputEmits {
|
|
13
|
+
(e: 'update:visible', visible: boolean): void;
|
|
14
|
+
(e: 'update:model-value', value: any): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { CheckboxInputProps, CheckboxInputEmits } from './common';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,6 +4,9 @@ export declare const defaultConfig: {
|
|
|
4
4
|
overlayClosable: boolean;
|
|
5
5
|
duration: number;
|
|
6
6
|
};
|
|
7
|
+
alert: {
|
|
8
|
+
type: "primary";
|
|
9
|
+
};
|
|
7
10
|
avatar: {
|
|
8
11
|
shape: "circle";
|
|
9
12
|
};
|
|
@@ -36,6 +39,9 @@ export declare const defaultConfig: {
|
|
|
36
39
|
direction: "vertical";
|
|
37
40
|
validateEvent: boolean;
|
|
38
41
|
};
|
|
42
|
+
checkboxInput: {
|
|
43
|
+
validateEvent: boolean;
|
|
44
|
+
};
|
|
39
45
|
countDown: {
|
|
40
46
|
time: number;
|
|
41
47
|
autoStart: boolean;
|
|
@@ -194,10 +200,24 @@ export declare const defaultConfig: {
|
|
|
194
200
|
transitionDuration: number;
|
|
195
201
|
doneDuration: number;
|
|
196
202
|
};
|
|
203
|
+
qrcode: {
|
|
204
|
+
ecl: "M";
|
|
205
|
+
size: string;
|
|
206
|
+
canvasSize: number;
|
|
207
|
+
type: "canvas";
|
|
208
|
+
text: string;
|
|
209
|
+
color: string;
|
|
210
|
+
bgColor: string;
|
|
211
|
+
quietZoneModules: number;
|
|
212
|
+
};
|
|
197
213
|
radioGroup: {
|
|
198
214
|
direction: "vertical";
|
|
199
215
|
validateEvent: boolean;
|
|
200
216
|
};
|
|
217
|
+
radioInput: {
|
|
218
|
+
validateEvent: boolean;
|
|
219
|
+
type: "record";
|
|
220
|
+
};
|
|
201
221
|
rate: {
|
|
202
222
|
count: number;
|
|
203
223
|
icon: string;
|
|
@@ -332,6 +352,9 @@ export declare function useConfigContext(): DeepPartial<{
|
|
|
332
352
|
overlayClosable: boolean;
|
|
333
353
|
duration: number;
|
|
334
354
|
};
|
|
355
|
+
alert: {
|
|
356
|
+
type: "primary";
|
|
357
|
+
};
|
|
335
358
|
avatar: {
|
|
336
359
|
shape: "circle";
|
|
337
360
|
};
|
|
@@ -364,6 +387,9 @@ export declare function useConfigContext(): DeepPartial<{
|
|
|
364
387
|
direction: "vertical";
|
|
365
388
|
validateEvent: boolean;
|
|
366
389
|
};
|
|
390
|
+
checkboxInput: {
|
|
391
|
+
validateEvent: boolean;
|
|
392
|
+
};
|
|
367
393
|
countDown: {
|
|
368
394
|
time: number;
|
|
369
395
|
autoStart: boolean;
|
|
@@ -522,10 +548,24 @@ export declare function useConfigContext(): DeepPartial<{
|
|
|
522
548
|
transitionDuration: number;
|
|
523
549
|
doneDuration: number;
|
|
524
550
|
};
|
|
551
|
+
qrcode: {
|
|
552
|
+
ecl: "M";
|
|
553
|
+
size: string;
|
|
554
|
+
canvasSize: number;
|
|
555
|
+
type: "canvas";
|
|
556
|
+
text: string;
|
|
557
|
+
color: string;
|
|
558
|
+
bgColor: string;
|
|
559
|
+
quietZoneModules: number;
|
|
560
|
+
};
|
|
525
561
|
radioGroup: {
|
|
526
562
|
direction: "vertical";
|
|
527
563
|
validateEvent: boolean;
|
|
528
564
|
};
|
|
565
|
+
radioInput: {
|
|
566
|
+
validateEvent: boolean;
|
|
567
|
+
type: "record";
|
|
568
|
+
};
|
|
529
569
|
rate: {
|
|
530
570
|
count: number;
|
|
531
571
|
icon: string;
|
|
@@ -5,6 +5,9 @@ export const defaultConfig = {
|
|
|
5
5
|
overlayClosable: true,
|
|
6
6
|
duration: 300,
|
|
7
7
|
},
|
|
8
|
+
alert: {
|
|
9
|
+
type: 'primary',
|
|
10
|
+
},
|
|
8
11
|
avatar: {
|
|
9
12
|
shape: 'circle',
|
|
10
13
|
},
|
|
@@ -37,6 +40,9 @@ export const defaultConfig = {
|
|
|
37
40
|
direction: 'vertical',
|
|
38
41
|
validateEvent: true,
|
|
39
42
|
},
|
|
43
|
+
checkboxInput: {
|
|
44
|
+
validateEvent: true,
|
|
45
|
+
},
|
|
40
46
|
countDown: {
|
|
41
47
|
time: 0,
|
|
42
48
|
autoStart: true,
|
|
@@ -195,10 +201,24 @@ export const defaultConfig = {
|
|
|
195
201
|
transitionDuration: 300,
|
|
196
202
|
doneDuration: 0,
|
|
197
203
|
},
|
|
204
|
+
qrcode: {
|
|
205
|
+
ecl: 'M',
|
|
206
|
+
size: '320rpx',
|
|
207
|
+
canvasSize: 400,
|
|
208
|
+
type: 'canvas',
|
|
209
|
+
text: '',
|
|
210
|
+
color: '#000',
|
|
211
|
+
bgColor: '#fff',
|
|
212
|
+
quietZoneModules: 2,
|
|
213
|
+
},
|
|
198
214
|
radioGroup: {
|
|
199
215
|
direction: 'vertical',
|
|
200
216
|
validateEvent: true,
|
|
201
217
|
},
|
|
218
|
+
radioInput: {
|
|
219
|
+
validateEvent: true,
|
|
220
|
+
type: 'record',
|
|
221
|
+
},
|
|
202
222
|
rate: {
|
|
203
223
|
count: 5,
|
|
204
224
|
icon: 'star-fill',
|
|
@@ -74,7 +74,8 @@ export default _defineComponent({
|
|
|
74
74
|
placeholder: { type: String, required: false },
|
|
75
75
|
readonly: { type: Boolean, required: false },
|
|
76
76
|
disabled: { type: Boolean, required: false },
|
|
77
|
-
clearable: { type: Boolean, required: false }
|
|
77
|
+
clearable: { type: Boolean, required: false },
|
|
78
|
+
multiline: { type: Boolean, required: false }
|
|
78
79
|
}, datetimePickerInputPropsDefaults),
|
|
79
80
|
emits: ["update:visible", "update:model-value"],
|
|
80
81
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
@@ -11,10 +11,10 @@ page {
|
|
|
11
11
|
--sar-form-item-label-margin-right: 24rpx;
|
|
12
12
|
--sar-form-item-label-margin-bottom: 8rpx;
|
|
13
13
|
--sar-form-item-label-font-size: var(--sar-text-base);
|
|
14
|
-
--sar-form-item-label-line-height: var(--sar-leading-
|
|
14
|
+
--sar-form-item-label-line-height: var(--sar-leading-normal);
|
|
15
15
|
|
|
16
16
|
--sar-form-item-star-font-size: var(--sar-text-base);
|
|
17
|
-
--sar-form-item-star-line-height: var(--sar-leading-
|
|
17
|
+
--sar-form-item-star-line-height: var(--sar-leading-normal);
|
|
18
18
|
--sar-form-item-star-color: var(--sar-danger);
|
|
19
19
|
--sar-form-item-star-gap: 8rpx;
|
|
20
20
|
|
|
@@ -21,6 +21,7 @@ export interface InputProps {
|
|
|
21
21
|
fixed?: boolean;
|
|
22
22
|
showConfirmBar?: boolean;
|
|
23
23
|
disableDefaultPadding?: boolean;
|
|
24
|
+
inputMinHeight?: boolean;
|
|
24
25
|
type?: 'text' | 'number' | 'idcard' | 'digit' | 'tel' | 'safe-password' | 'nickname' | 'password' | 'textarea';
|
|
25
26
|
alwaysEmbed?: boolean;
|
|
26
27
|
safePasswordCertPath?: string;
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
padding: 0;
|
|
50
50
|
border-width: 0;
|
|
51
51
|
font-size: var(--sar-input-control-font-size);
|
|
52
|
+
line-height: var(--sar-input-control-line-height);
|
|
52
53
|
|
|
53
54
|
@include m(input) {
|
|
54
55
|
height: var(--sar-input-control-input-height);
|
|
@@ -58,10 +59,30 @@
|
|
|
58
59
|
height: var(--sar-input-control-textarea-height);
|
|
59
60
|
min-height: var(--sar-input-control-textarea-height);
|
|
60
61
|
}
|
|
62
|
+
|
|
63
|
+
@include m(input-min-height) {
|
|
64
|
+
min-height: var(--sar-input-control-input-height);
|
|
65
|
+
line-height: var(--sar-input-control-input-height);
|
|
66
|
+
}
|
|
61
67
|
}
|
|
62
68
|
|
|
63
69
|
@include e(placeholder) {
|
|
64
70
|
color: var(--sar-input-placeholder-color);
|
|
71
|
+
line-height: var(--sar-input-control-line-height);
|
|
72
|
+
|
|
73
|
+
@include m(textarea) {
|
|
74
|
+
position: absolute;
|
|
75
|
+
top: 0;
|
|
76
|
+
left: 0;
|
|
77
|
+
right: 0;
|
|
78
|
+
bottom: 0;
|
|
79
|
+
overflow: hidden;
|
|
80
|
+
pointer-events: none;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@include m(input-min-height) {
|
|
84
|
+
line-height: var(--sar-input-control-input-height);
|
|
85
|
+
}
|
|
65
86
|
}
|
|
66
87
|
|
|
67
88
|
@include e(prepend, append) {
|
|
@@ -4,13 +4,30 @@
|
|
|
4
4
|
<view v-if="$slots.prepend" :class="bem.e('prepend')">
|
|
5
5
|
<slot name="prepend"></slot>
|
|
6
6
|
</view>
|
|
7
|
+
<view
|
|
8
|
+
v-if="type === 'textarea' && innerValue === '' && placeholder"
|
|
9
|
+
:class="
|
|
10
|
+
classNames(
|
|
11
|
+
bem.e('placeholder'),
|
|
12
|
+
bem.em('placeholder', 'textarea'),
|
|
13
|
+
bem.em('placeholder', 'input-min-height', inputMinHeight),
|
|
14
|
+
placeholderClass,
|
|
15
|
+
)
|
|
16
|
+
"
|
|
17
|
+
:style="placeholderStyle"
|
|
18
|
+
>
|
|
19
|
+
{{ placeholder }}
|
|
20
|
+
</view>
|
|
7
21
|
<textarea
|
|
8
22
|
v-if="type === 'textarea'"
|
|
9
|
-
:class="
|
|
23
|
+
:class="
|
|
24
|
+
classNames(
|
|
25
|
+
bem.e('control'),
|
|
26
|
+
bem.em('control', 'textarea'),
|
|
27
|
+
bem.em('control', 'input-min-height', inputMinHeight),
|
|
28
|
+
)
|
|
29
|
+
"
|
|
10
30
|
:value="innerValue"
|
|
11
|
-
:placeholder="placeholder"
|
|
12
|
-
:placeholder-style="placeholderStyle"
|
|
13
|
-
:placeholder-class="classNames(bem.e('placeholder'), placeholderClass)"
|
|
14
31
|
:disabled="isDisabled || isReadonly"
|
|
15
32
|
:maxlength="maxlength"
|
|
16
33
|
:focus="focus"
|
|
@@ -139,6 +156,7 @@ export default _defineComponent({
|
|
|
139
156
|
fixed: { type: Boolean, required: false },
|
|
140
157
|
showConfirmBar: { type: Boolean, required: false },
|
|
141
158
|
disableDefaultPadding: { type: Boolean, required: false },
|
|
159
|
+
inputMinHeight: { type: Boolean, required: false },
|
|
142
160
|
type: { type: String, required: false },
|
|
143
161
|
alwaysEmbed: { type: Boolean, required: false },
|
|
144
162
|
safePasswordCertPath: { type: String, required: false },
|
|
@@ -11,6 +11,7 @@ page {
|
|
|
11
11
|
|
|
12
12
|
--sar-input-control-font-size: var(--sar-text-base);
|
|
13
13
|
--sar-input-control-input-height: 48rpx;
|
|
14
|
+
--sar-input-control-line-height: var(--sar-leading-normal);
|
|
14
15
|
--sar-input-control-textarea-height: 168rpx;
|
|
15
16
|
|
|
16
17
|
--sar-input-placeholder-color: var(--sar-quaternary-color);
|
package/components/list/list.vue
CHANGED
|
@@ -19,7 +19,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
19
19
|
onClick?: ((event: any) => any) | undefined;
|
|
20
20
|
"onUpdate:visible"?: ((event: any) => any) | undefined;
|
|
21
21
|
}, {
|
|
22
|
-
type: "success" | "primary" | "
|
|
22
|
+
type: "success" | "primary" | "warning" | "error";
|
|
23
23
|
duration: number;
|
|
24
24
|
position: "top" | "bottom";
|
|
25
25
|
timeout: number;
|
|
@@ -12,7 +12,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
12
12
|
duration: number;
|
|
13
13
|
timeout: number;
|
|
14
14
|
}>>>, {
|
|
15
|
-
type: "success" | "primary" | "
|
|
15
|
+
type: "success" | "primary" | "warning" | "error";
|
|
16
16
|
id: string;
|
|
17
17
|
duration: number;
|
|
18
18
|
position: "top" | "bottom";
|
|
@@ -71,7 +71,8 @@ export default _defineComponent({
|
|
|
71
71
|
readonly: { type: Boolean, required: false },
|
|
72
72
|
disabled: { type: Boolean, required: false },
|
|
73
73
|
clearable: { type: Boolean, required: false },
|
|
74
|
-
loading: { type: Boolean, required: false }
|
|
74
|
+
loading: { type: Boolean, required: false },
|
|
75
|
+
multiline: { type: Boolean, required: false }
|
|
75
76
|
}, pickerInputPropsDefaults),
|
|
76
77
|
emits: ["update:visible", "update:model-value"],
|
|
77
78
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
:readonly="isReadonly"
|
|
9
9
|
:disabled="isDisabled"
|
|
10
10
|
:clearable="clearable"
|
|
11
|
-
@clear="onClear"
|
|
12
11
|
:validate-event="false"
|
|
12
|
+
:type="multiline ? 'textarea' : undefined"
|
|
13
|
+
:auto-height="multiline"
|
|
14
|
+
:input-min-height="multiline"
|
|
15
|
+
@clear="onClear"
|
|
13
16
|
>
|
|
14
17
|
<template #append>
|
|
15
18
|
<view :class="bem.e('append')">
|
|
@@ -59,7 +62,8 @@ export default _defineComponent({
|
|
|
59
62
|
readonly: { type: Boolean, required: false },
|
|
60
63
|
disabled: { type: Boolean, required: false },
|
|
61
64
|
clearable: { type: Boolean, required: false },
|
|
62
|
-
loading: { type: Boolean, required: false }
|
|
65
|
+
loading: { type: Boolean, required: false },
|
|
66
|
+
multiline: { type: Boolean, required: false }
|
|
63
67
|
},
|
|
64
68
|
emits: ["click", "update:model-value", "clear"],
|
|
65
69
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type StyleValue } from 'vue';
|
|
2
|
+
export interface QrcodeProps {
|
|
3
|
+
rootStyle?: StyleValue;
|
|
4
|
+
rootClass?: string;
|
|
5
|
+
text?: string;
|
|
6
|
+
ecl?: 'L' | 'M' | 'Q' | 'H';
|
|
7
|
+
type?: 'canvas' | 'image';
|
|
8
|
+
size?: string;
|
|
9
|
+
canvasSize?: number;
|
|
10
|
+
color?: string;
|
|
11
|
+
bgColor?: string;
|
|
12
|
+
quietZoneModules?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare const qrcodePropsDefaults: {
|
|
15
|
+
ecl: "M";
|
|
16
|
+
size: string;
|
|
17
|
+
canvasSize: number;
|
|
18
|
+
type: "canvas";
|
|
19
|
+
text: string;
|
|
20
|
+
color: string;
|
|
21
|
+
bgColor: string;
|
|
22
|
+
quietZoneModules: number;
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { QrcodeProps } from './common';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type QrcodeProps } from './common';
|
|
2
|
+
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<QrcodeProps>, {
|
|
3
|
+
ecl: "M";
|
|
4
|
+
size: string;
|
|
5
|
+
canvasSize: number;
|
|
6
|
+
type: "canvas";
|
|
7
|
+
text: string;
|
|
8
|
+
color: string;
|
|
9
|
+
bgColor: string;
|
|
10
|
+
quietZoneModules: number;
|
|
11
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<QrcodeProps>, {
|
|
12
|
+
ecl: "M";
|
|
13
|
+
size: string;
|
|
14
|
+
canvasSize: number;
|
|
15
|
+
type: "canvas";
|
|
16
|
+
text: string;
|
|
17
|
+
color: string;
|
|
18
|
+
bgColor: string;
|
|
19
|
+
quietZoneModules: number;
|
|
20
|
+
}>>>, {
|
|
21
|
+
text: string;
|
|
22
|
+
ecl: "M" | "H" | "L" | "Q";
|
|
23
|
+
size: string;
|
|
24
|
+
type: "canvas" | "image";
|
|
25
|
+
canvasSize: number;
|
|
26
|
+
color: string;
|
|
27
|
+
bgColor: string;
|
|
28
|
+
quietZoneModules: number;
|
|
29
|
+
}, {}>;
|
|
30
|
+
export default _default;
|
|
31
|
+
type __VLS_WithDefaults<P, D> = {
|
|
32
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
33
|
+
default: D[K];
|
|
34
|
+
}> : P[K];
|
|
35
|
+
};
|
|
36
|
+
type __VLS_Prettify<T> = {
|
|
37
|
+
[K in keyof T]: T[K];
|
|
38
|
+
} & {};
|
|
39
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
40
|
+
type __VLS_TypePropsToOption<T> = {
|
|
41
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
42
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
43
|
+
} : {
|
|
44
|
+
type: import('vue').PropType<T[K]>;
|
|
45
|
+
required: true;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="qrcodeClass" :style="qrcodeStyle">
|
|
3
|
+
<canvas type="2d" :class="bem.e('canvas')" :id="canvasId"></canvas>
|
|
4
|
+
<image :src="dataURL" mode="aspectFit" :class="bem.e('image')" />
|
|
5
|
+
</view>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
|
|
10
|
+
import { computed, getCurrentInstance, onMounted, shallowRef } from "vue";
|
|
11
|
+
import {
|
|
12
|
+
classNames,
|
|
13
|
+
stringifyStyle,
|
|
14
|
+
createBem,
|
|
15
|
+
uniqid,
|
|
16
|
+
qrcode
|
|
17
|
+
} from "../../utils";
|
|
18
|
+
import { qrcodePropsDefaults } from "./common";
|
|
19
|
+
export default _defineComponent({
|
|
20
|
+
...{
|
|
21
|
+
options: {
|
|
22
|
+
virtualHost: true,
|
|
23
|
+
styleIsolation: "shared"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
__name: "qrcode",
|
|
27
|
+
props: _mergeDefaults({
|
|
28
|
+
rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
|
|
29
|
+
rootClass: { type: String, required: false },
|
|
30
|
+
text: { type: String, required: false },
|
|
31
|
+
ecl: { type: String, required: false },
|
|
32
|
+
type: { type: String, required: false },
|
|
33
|
+
size: { type: String, required: false },
|
|
34
|
+
canvasSize: { type: Number, required: false },
|
|
35
|
+
color: { type: String, required: false },
|
|
36
|
+
bgColor: { type: String, required: false },
|
|
37
|
+
quietZoneModules: { type: Number, required: false }
|
|
38
|
+
}, qrcodePropsDefaults),
|
|
39
|
+
setup(__props, { expose: __expose }) {
|
|
40
|
+
__expose();
|
|
41
|
+
const props = __props;
|
|
42
|
+
const bem = createBem("qrcode");
|
|
43
|
+
const canvasId = uniqid();
|
|
44
|
+
const canvasRef = shallowRef();
|
|
45
|
+
const qrcodeMap = computed(() => {
|
|
46
|
+
return qrcode(props.text, {
|
|
47
|
+
ecl: props.ecl
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
const dataURL = computed(() => {
|
|
51
|
+
const canvas = canvasRef.value;
|
|
52
|
+
if (!canvas) {
|
|
53
|
+
return "";
|
|
54
|
+
}
|
|
55
|
+
const map = qrcodeMap.value;
|
|
56
|
+
const size = props.canvasSize;
|
|
57
|
+
canvas.width = size;
|
|
58
|
+
canvas.height = size;
|
|
59
|
+
const context = canvas.getContext("2d");
|
|
60
|
+
const moduleSize = size / (map.length + props.quietZoneModules * 2);
|
|
61
|
+
const margin = moduleSize * props.quietZoneModules;
|
|
62
|
+
const path = canvas.createPath2D ? canvas.createPath2D() : new Path2D();
|
|
63
|
+
map.forEach((row, rowIndex) => {
|
|
64
|
+
row.forEach((col, colIndex) => {
|
|
65
|
+
if (col === 1) {
|
|
66
|
+
path.rect(
|
|
67
|
+
colIndex * moduleSize + margin,
|
|
68
|
+
rowIndex * moduleSize + margin,
|
|
69
|
+
moduleSize,
|
|
70
|
+
moduleSize
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
context.clearRect(0, 0, size, size);
|
|
76
|
+
context.fillStyle = props.bgColor;
|
|
77
|
+
context.fillRect(0, 0, size, size);
|
|
78
|
+
context.fillStyle = props.color;
|
|
79
|
+
context.fill(path);
|
|
80
|
+
return canvas.toDataURL();
|
|
81
|
+
});
|
|
82
|
+
const instance = getCurrentInstance();
|
|
83
|
+
onMounted(() => {
|
|
84
|
+
uni.createSelectorQuery().in(instance).select(`#${canvasId}`).node((res) => {
|
|
85
|
+
if (res && res.node) {
|
|
86
|
+
canvasRef.value = res.node;
|
|
87
|
+
}
|
|
88
|
+
}).exec();
|
|
89
|
+
});
|
|
90
|
+
const qrcodeClass = computed(() => {
|
|
91
|
+
return classNames(bem.b(), props.rootClass);
|
|
92
|
+
});
|
|
93
|
+
const qrcodeStyle = computed(() => {
|
|
94
|
+
return stringifyStyle(props.rootStyle, {
|
|
95
|
+
width: props.size,
|
|
96
|
+
height: props.size
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
const __returned__ = { props, bem, canvasId, canvasRef, qrcodeMap, dataURL, instance, qrcodeClass, qrcodeStyle };
|
|
100
|
+
return __returned__;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
</script>
|
|
104
|
+
|
|
105
|
+
<style lang="scss">
|
|
106
|
+
@import './index.scss';
|
|
107
|
+
</style>
|
|
@@ -20,6 +20,17 @@ export interface RadioSlots {
|
|
|
20
20
|
export interface RadioEmits {
|
|
21
21
|
(e: 'click', event: any): void;
|
|
22
22
|
}
|
|
23
|
+
export declare const defaultOptionKeys: {
|
|
24
|
+
label: string;
|
|
25
|
+
value: string;
|
|
26
|
+
};
|
|
27
|
+
export type RadioGroupOption = {
|
|
28
|
+
[key: PropertyKey]: any;
|
|
29
|
+
} | string | number | boolean;
|
|
30
|
+
export interface RadioGroupOptionKeys {
|
|
31
|
+
label?: string;
|
|
32
|
+
value?: string;
|
|
33
|
+
}
|
|
23
34
|
export interface RadioGroupProps {
|
|
24
35
|
rootStyle?: StyleValue;
|
|
25
36
|
rootClass?: string;
|
|
@@ -31,6 +42,8 @@ export interface RadioGroupProps {
|
|
|
31
42
|
checkedColor?: string;
|
|
32
43
|
direction?: 'horizontal' | 'vertical';
|
|
33
44
|
validateEvent?: boolean;
|
|
45
|
+
options?: RadioGroupOption[];
|
|
46
|
+
optionKeys?: RadioGroupOptionKeys;
|
|
34
47
|
}
|
|
35
48
|
export declare const radioGroupPropsDefaults: {
|
|
36
49
|
direction: "vertical";
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { defaultConfig } from '../config';
|
|
2
|
+
export const defaultOptionKeys = {
|
|
3
|
+
label: 'label',
|
|
4
|
+
value: 'value',
|
|
5
|
+
};
|
|
2
6
|
export const radioGroupPropsDefaults = defaultConfig.radioGroup;
|
|
3
7
|
export const radioContextSymbol = Symbol('radio-context');
|
|
4
8
|
export const mapTypeIcon = {
|