cosey 0.6.5 → 0.6.7

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.
@@ -2,6 +2,9 @@ import { type CheckboxGroupValueType, type CheckboxGroupInstance, type CheckboxG
2
2
  import { type FieldComponentCommonProps } from '../common';
3
3
  import { Props } from '../../../../hooks';
4
4
  export type FieldCheckboxGroupOption = Partial<CheckboxProps> | string | number;
5
+ type CheckboxPropsObjectOption = Partial<CheckboxProps> & {
6
+ [k: string]: any;
7
+ };
5
8
  export interface FieldCheckboxGroupProps extends FieldComponentCommonProps {
6
9
  componentProps?: Partial<CheckboxGroupProps> & {
7
10
  'onUpdate:modelValue'?: (val: CheckboxGroupValueType) => void;
@@ -14,14 +17,21 @@ export interface FieldCheckboxGroupProps extends FieldComponentCommonProps {
14
17
  checkboxWidth?: string | number;
15
18
  indeterminate?: boolean;
16
19
  maxHeight?: string | number;
20
+ checkboxProps?: CheckboxPropsObjectOption | ((props: CheckboxPropsObjectOption, index: number) => CheckboxPropsObjectOption);
17
21
  };
18
22
  componentSlots?: Partial<FieldCheckboxGroupSlots>;
19
23
  }
24
+ export declare const fieldCheckboxGroupOmitKeys: readonly ["options", "props", "type", "checkboxWidth", "maxHeight", "checkboxProps"];
20
25
  export interface FieldCheckboxGroupSlots {
21
26
  default?: (props: Record<string, any>) => any;
27
+ checkbox?: (props: {
28
+ option: Record<PropertyKey, any>;
29
+ index: number;
30
+ }) => any;
22
31
  }
23
32
  export interface FieldCheckboxGroupEmits {
24
33
  (e: 'update:modelValue', val: CheckboxGroupValueType): void;
25
34
  (e: 'change', val: CheckboxValueType[]): void;
26
35
  }
27
36
  export type FieldCheckboxGroupExpose = CheckboxGroupInstance;
37
+ export {};
@@ -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;
@@ -50,17 +71,10 @@ var stdin_default = defineComponent(props => {
50
71
  style: {
51
72
  display: "flex",
52
73
  flexWrap: "wrap",
53
- columnGap: "32px"
54
- }
55
- }), () => convertedOptions.value.map(item => h(checkboxType.value, mergeProps({
56
- ...item,
57
- key: item.value
58
- }, {
59
- style: {
60
- width: checkboxWidth.value,
61
- margin: 0
74
+ columnGap: "30px",
75
+ rowGap: "12px"
62
76
  }
63
- }))));
77
+ }), () => convertedOptions.value.map((item, index) => renderCheckbox(item, index)));
64
78
  return componentProps.value.indeterminate ? h(stdin_default$1, {
65
79
  modelValue: checkboxGroupProps.value.modelValue,
66
80
  "onUpdate:modelValue": componentProps.value["onUpdate:modelValue"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosey",
3
- "version": "0.6.5",
3
+ "version": "0.6.7",
4
4
  "description": "基于 Vue3 + vite 的后台管理系统框架",
5
5
  "type": "module",
6
6
  "main": "index.js",