cosey 0.6.4 → 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 +1,10 @@
1
+ const fieldCheckboxGroupOmitKeys = [
2
+ "options",
3
+ "props",
4
+ "type",
5
+ "checkboxWidth",
6
+ "maxHeight",
7
+ "checkboxProps"
8
+ ];
1
9
 
10
+ export { fieldCheckboxGroupOmitKeys };
@@ -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, ["options", "props", "type", "checkboxWidth", "maxHeight"]);
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;
@@ -47,16 +68,12 @@ var stdin_default = defineComponent(props => {
47
68
  });
48
69
  }
49
70
  const checkboxGroupVnode = h(ElCheckboxGroup, mergeProps(checkboxGroupProps.value, {
50
- class: "flex flex-wrap gap-x-8"
51
- }), () => convertedOptions.value.map(item => h(checkboxType.value, mergeProps({
52
- ...item,
53
- key: item.value
54
- }, {
55
71
  style: {
56
- width: checkboxWidth.value
57
- },
58
- class: "!me-0"
59
- }))));
72
+ display: "flex",
73
+ flexWrap: "wrap",
74
+ columnGap: "32px"
75
+ }
76
+ }), () => convertedOptions.value.map((item, index) => renderCheckbox(item, index)));
60
77
  return componentProps.value.indeterminate ? h(stdin_default$1, {
61
78
  modelValue: checkboxGroupProps.value.modelValue,
62
79
  "onUpdate:modelValue": componentProps.value["onUpdate:modelValue"],
@@ -260,12 +260,6 @@ var stdin_default = /* @__PURE__ */defineComponent({
260
260
  return;
261
261
  }).filter(Boolean);
262
262
  });
263
- console.log(columns.value);
264
- console.log(slots.default?.({
265
- row: {},
266
- index: 0,
267
- getProp
268
- }));
269
263
  __expose(createMergedExpose(formListExposeKeys, () => formItemRef.value, {
270
264
  add,
271
265
  remove,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosey",
3
- "version": "0.6.4",
3
+ "version": "0.6.6",
4
4
  "description": "基于 Vue3 + vite 的后台管理系统框架",
5
5
  "type": "module",
6
6
  "main": "index.js",