cosey 0.6.5 → 0.6.6
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.
|
@@ -14,11 +14,17 @@ export interface FieldCheckboxGroupProps extends FieldComponentCommonProps {
|
|
|
14
14
|
checkboxWidth?: string | number;
|
|
15
15
|
indeterminate?: boolean;
|
|
16
16
|
maxHeight?: string | number;
|
|
17
|
+
checkboxProps?: Record<PropertyKey, any> | ((props: Record<PropertyKey, any>, index: number) => Record<PropertyKey, any>);
|
|
17
18
|
};
|
|
18
19
|
componentSlots?: Partial<FieldCheckboxGroupSlots>;
|
|
19
20
|
}
|
|
21
|
+
export declare const fieldCheckboxGroupOmitKeys: readonly ["options", "props", "type", "checkboxWidth", "maxHeight", "checkboxProps"];
|
|
20
22
|
export interface FieldCheckboxGroupSlots {
|
|
21
23
|
default?: (props: Record<string, any>) => any;
|
|
24
|
+
checkbox?: (props: {
|
|
25
|
+
option: Record<PropertyKey, any>;
|
|
26
|
+
index: number;
|
|
27
|
+
}) => any;
|
|
22
28
|
}
|
|
23
29
|
export interface FieldCheckboxGroupEmits {
|
|
24
30
|
(e: 'update:modelValue', val: CheckboxGroupValueType): void;
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { ElCheckboxButton, ElCheckbox, ElCheckboxGroup } from 'element-plus';
|
|
2
2
|
import { defineComponent, computed, h, mergeProps } from 'vue';
|
|
3
|
+
import { fieldCheckboxGroupOmitKeys } from './checkbox-group.js';
|
|
3
4
|
import stdin_default$1 from './panel.vue.js';
|
|
4
5
|
import { omit } from 'lodash-es';
|
|
5
6
|
import { useProps } from '../../../../hooks/useProps.js';
|
|
7
|
+
import { isNumber, isFunction } from '../../../../utils/is.js';
|
|
6
8
|
import { getLabelByValue } from '../../../../utils/collection.js';
|
|
7
|
-
import { isNumber } from '../../../../utils/is.js';
|
|
8
9
|
import { addNullablePlaceholder } from '../../../../utils/vue.js';
|
|
9
10
|
|
|
10
|
-
var stdin_default = defineComponent(props
|
|
11
|
+
var stdin_default = defineComponent((props, {
|
|
12
|
+
slots
|
|
13
|
+
}) => {
|
|
11
14
|
const componentProps = computed(() => props.componentProps || {});
|
|
12
15
|
const checkboxGroupProps = computed(() => {
|
|
13
|
-
return omit(componentProps.value,
|
|
16
|
+
return omit(componentProps.value, fieldCheckboxGroupOmitKeys);
|
|
14
17
|
});
|
|
15
18
|
const {
|
|
16
19
|
getLabel,
|
|
17
|
-
getValue
|
|
20
|
+
getValue,
|
|
21
|
+
getKey
|
|
18
22
|
} = useProps(componentProps);
|
|
19
23
|
const convertedOptions = computed(() => {
|
|
20
24
|
return (componentProps.value.options ?? []).map(option => {
|
|
@@ -38,6 +42,23 @@ var stdin_default = defineComponent(props => {
|
|
|
38
42
|
const width = componentProps.value.checkboxWidth;
|
|
39
43
|
return isNumber(width) ? width + "px" : width;
|
|
40
44
|
});
|
|
45
|
+
function renderCheckbox(option, index) {
|
|
46
|
+
const checkboxProps = componentProps.value.checkboxProps;
|
|
47
|
+
const value = getValue(option);
|
|
48
|
+
return h(checkboxType.value, mergeProps({
|
|
49
|
+
...option,
|
|
50
|
+
key: getKey(value),
|
|
51
|
+
...(isFunction(checkboxProps) ? checkboxProps(option, index) : checkboxProps)
|
|
52
|
+
}, {
|
|
53
|
+
style: {
|
|
54
|
+
width: checkboxWidth.value,
|
|
55
|
+
margin: 0
|
|
56
|
+
}
|
|
57
|
+
}), slots.checkbox ? () => slots.checkbox({
|
|
58
|
+
option,
|
|
59
|
+
index
|
|
60
|
+
}) : void 0);
|
|
61
|
+
}
|
|
41
62
|
return () => {
|
|
42
63
|
if (props.readonly) {
|
|
43
64
|
const value = componentProps.value.modelValue;
|
|
@@ -52,15 +73,7 @@ var stdin_default = defineComponent(props => {
|
|
|
52
73
|
flexWrap: "wrap",
|
|
53
74
|
columnGap: "32px"
|
|
54
75
|
}
|
|
55
|
-
}), () => convertedOptions.value.map(item =>
|
|
56
|
-
...item,
|
|
57
|
-
key: item.value
|
|
58
|
-
}, {
|
|
59
|
-
style: {
|
|
60
|
-
width: checkboxWidth.value,
|
|
61
|
-
margin: 0
|
|
62
|
-
}
|
|
63
|
-
}))));
|
|
76
|
+
}), () => convertedOptions.value.map((item, index) => renderCheckbox(item, index)));
|
|
64
77
|
return componentProps.value.indeterminate ? h(stdin_default$1, {
|
|
65
78
|
modelValue: checkboxGroupProps.value.modelValue,
|
|
66
79
|
"onUpdate:modelValue": componentProps.value["onUpdate:modelValue"],
|