plain-design 1.0.0-beta.153 → 1.0.0-beta.154
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/package.json
CHANGED
|
@@ -12,6 +12,7 @@ export const $imageSelector = (
|
|
|
12
12
|
handleConfirm,
|
|
13
13
|
title,
|
|
14
14
|
aspectRatio,
|
|
15
|
+
imageFit,
|
|
15
16
|
}: {
|
|
16
17
|
title?: string,
|
|
17
18
|
selectOptions: iImageSelectOption[],
|
|
@@ -19,25 +20,33 @@ export const $imageSelector = (
|
|
|
19
20
|
dialogServiceOption?: iDialogServiceOption,
|
|
20
21
|
handleConfirm?: (selectValue: string, selectOption: iImageSelectOption) => void | boolean | Promise<void | boolean>,
|
|
21
22
|
aspectRatio?: string,
|
|
23
|
+
imageFit?: string,
|
|
22
24
|
}
|
|
23
25
|
) => {
|
|
24
|
-
|
|
26
|
+
const _handleConfirm = async () => {
|
|
27
|
+
if (!selectValue) {
|
|
28
|
+
$message.error(i18n.$it('base.pleaseSelect').d('请选择'));
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
const flag = await handleConfirm?.(selectValue, selectOptions.find(i => i.val === selectValue)!);
|
|
32
|
+
if (flag !== false) {close();}
|
|
33
|
+
};
|
|
34
|
+
const close = $dialog({
|
|
25
35
|
title,
|
|
26
36
|
width: 800,
|
|
27
37
|
render: () => <ImageSelector
|
|
38
|
+
imageFit={imageFit}
|
|
28
39
|
modelValue={selectValue}
|
|
29
40
|
onUpdateModelValue={val => selectValue = val}
|
|
30
41
|
selectOptions={selectOptions}
|
|
31
42
|
aspectRatio={aspectRatio}
|
|
43
|
+
onDoubleClickOption={() => {_handleConfirm();}}
|
|
32
44
|
/>,
|
|
33
45
|
confirmButton: true,
|
|
34
46
|
cancelButton: true,
|
|
35
|
-
handleConfirm:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
return handleConfirm?.(selectValue, selectOptions.find(i => i.val === selectValue)!);
|
|
47
|
+
handleConfirm: () => {
|
|
48
|
+
_handleConfirm();
|
|
49
|
+
return false;
|
|
41
50
|
},
|
|
42
51
|
...dialogServiceOption,
|
|
43
52
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {designComponent, getComponentCls, PropType, useModel} from "@peryl/react-compose";
|
|
1
|
+
import {designComponent, getComponentCls, iMouseEvent, PropType, useModel} from "@peryl/react-compose";
|
|
2
2
|
import {Scroll} from "../Scroll";
|
|
3
3
|
import {Box} from "../Box";
|
|
4
4
|
import {Icon} from "../Icon";
|
|
@@ -11,9 +11,11 @@ export const ImageSelector = designComponent({
|
|
|
11
11
|
modelValue: { type: [String, Number] },
|
|
12
12
|
selectOptions: { type: Array as PropType<iImageSelectOption[]> },
|
|
13
13
|
aspectRatio: { type: String, default: '3 / 4' },
|
|
14
|
+
imageFit: { type: String, default: 'contain' }
|
|
14
15
|
},
|
|
15
16
|
emits: {
|
|
16
17
|
onUpdateModelValue: (val?: string | number | null | undefined) => true,
|
|
18
|
+
onDoubleClickOption: (e: iMouseEvent) => true,
|
|
17
19
|
},
|
|
18
20
|
setup({ props, event: { emit } }) {
|
|
19
21
|
|
|
@@ -28,8 +30,9 @@ export const ImageSelector = designComponent({
|
|
|
28
30
|
key={item.val}
|
|
29
31
|
data-selected={String(model.value === item.val)}
|
|
30
32
|
onClick={() => {model.value = item.val;}}
|
|
33
|
+
onDoubleClick={emit.onDoubleClickOption}
|
|
31
34
|
>
|
|
32
|
-
<Image src={item.url} previewOnClick={false} fit=
|
|
35
|
+
<Image src={item.url} previewOnClick={false} fit={props.imageFit as any} position="center left"/>
|
|
33
36
|
<div className="image-select-option-checked">
|
|
34
37
|
<Icon icon="pi-check"/>
|
|
35
38
|
</div>
|