cosey 0.4.31 → 0.4.33

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.
@@ -1,6 +1,7 @@
1
1
  import { type SelectProps } from 'element-plus/es/components/select/src/select.mjs';
2
2
  import { type FieldComponentCommonProps } from '../common';
3
3
  import { type ExtractPropTypes } from 'vue';
4
+ import { type OptionProps } from 'element-plus/es/components/select/src/type.mjs';
4
5
  export interface FieldSelectObjectOption {
5
6
  label?: string | number;
6
7
  value?: string | number | boolean;
@@ -31,6 +32,7 @@ export interface FieldSelectProps extends FieldComponentCommonProps {
31
32
  options?: FieldSelectOption[];
32
33
  labelKey?: string;
33
34
  valueKey?: string;
35
+ optionProps?: OptionProps | ((props: FieldSelectObjectOption, index: number) => OptionProps);
34
36
  };
35
37
  componentSlots?: Partial<FieldSelectSlots>;
36
38
  }
@@ -44,7 +46,7 @@ export interface FieldSelectSlots {
44
46
  tag?: (props: Record<string, any>) => any;
45
47
  loading?: (props: Record<string, any>) => any;
46
48
  label?: (props: Record<string, any>) => any;
47
- option?: (props: FieldSelectObjectOption) => any;
49
+ option?: (props: FieldSelectObjectOption, index: number) => any;
48
50
  }
49
51
  export interface FieldSelectEmits {
50
52
  (e: 'update:modelValue', value: any): void;
@@ -2,6 +2,7 @@ import { ElSelect, ElOptionGroup, ElOption } from 'element-plus';
2
2
  import { defineComponent, computed, unref, h, mergeProps } from 'vue';
3
3
  import { fieldSelectOmitKeys, flatGroup } from './select.js';
4
4
  import { omit } from 'lodash-es';
5
+ import { isFunction } from '../../../../utils/is.js';
5
6
  import { useLocale } from '../../../../hooks/useLocale.js';
6
7
  import { addNullablePlaceholder } from '../../../../utils/vue.js';
7
8
  import { getLabelByValue } from '../../../../utils/collection.js';
@@ -38,11 +39,13 @@ var stdin_default = defineComponent((props, {
38
39
  const convertedOptions = computed(() => {
39
40
  return convertRecur(unref(componentProps.value.options) ?? []);
40
41
  });
41
- function renderOption(option) {
42
+ function renderOption(option, index) {
43
+ const optionProps = componentProps.value.optionProps;
42
44
  return h(ElOption, {
43
45
  ...option,
44
- key: option.value
45
- }, slots.option ? () => slots.option(option) : void 0);
46
+ key: option.value,
47
+ ...(isFunction(optionProps) ? optionProps(option, index) : optionProps)
48
+ }, slots.option ? () => slots.option(option, index) : void 0);
46
49
  }
47
50
  return () => {
48
51
  if (props.readonly) {
@@ -60,10 +63,10 @@ var stdin_default = defineComponent((props, {
60
63
  }
61
64
  }, omittedProps.value), {
62
65
  ...slots,
63
- default: () => convertedOptions.value.map(item => "children" in item ? h(ElOptionGroup, {
66
+ default: () => convertedOptions.value.map((item, index) => "children" in item ? h(ElOptionGroup, {
64
67
  label: item.label,
65
68
  disabled: item.disabled
66
- }, () => item.children.map(item2 => renderOption(item2))) : renderOption(item))
69
+ }, () => item.children.map((item2, index2) => renderOption(item2, index2))) : renderOption(item, index))
67
70
  });
68
71
  };
69
72
  }, {
@@ -54,7 +54,7 @@ var stdin_default = /* @__PURE__ */defineComponent({
54
54
  class: normalizeClass([unref(hashId), unref(prefixCls)])
55
55
  }, [(openBlock(true), createElementBlock(Fragment, null, renderList(mergedSrcset.value, item => {
56
56
  return openBlock(), createBlock(stdin_default$2, mergeProps({
57
- key: item.src + Math.random(),
57
+ key: item.src,
58
58
  ref_for: true
59
59
  }, item, {
60
60
  size: _ctx.size,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosey",
3
- "version": "0.4.31",
3
+ "version": "0.4.33",
4
4
  "description": "基于 Vue3 + vite 的后台管理系统框架",
5
5
  "type": "module",
6
6
  "main": "index.js",