前端初始化

This commit is contained in:
“hsc”
2026-08-21 15:36:24 +08:00
commit e4d8ecde13
14411 changed files with 2275932 additions and 0 deletions
@@ -0,0 +1 @@
{"version":3,"file":"useProps.mjs","names":[],"sources":["../../../../../../packages/components/select-v2/src/useProps.ts"],"sourcesContent":["import { ref, watch } from 'vue'\nimport { get, isEqual } from 'lodash-unified'\n\nimport type { SelectV2Props } from './token'\nimport type { Option } from './select.types'\n\nexport interface Props {\n label?: string\n value?: string\n disabled?: string\n options?: string\n}\n\nexport const defaultProps: Required<Props> = {\n label: 'label',\n value: 'value',\n disabled: 'disabled',\n options: 'options',\n}\n\nexport function useProps(props: Pick<SelectV2Props, 'props'>) {\n const aliasProps = ref({ ...defaultProps, ...props.props })\n let cache = { ...props.props }\n\n watch(\n () => props.props,\n (val) => {\n // The props is an object, and its properties may be modified without changing the reference. In this case, the watch values before and after are equal. Here, we compare using the cached previous value.\n if (!isEqual(val, cache)) {\n aliasProps.value = { ...defaultProps, ...val }\n cache = { ...val }\n }\n },\n { deep: true }\n )\n\n const getLabel = (option: Option) => get(option, aliasProps.value.label)\n const getValue = (option: Option) => get(option, aliasProps.value.value)\n const getDisabled = (option: Option) => get(option, aliasProps.value.disabled)\n const getOptions = (option: Option) => get(option, aliasProps.value.options)\n\n return {\n aliasProps,\n getLabel,\n getValue,\n getDisabled,\n getOptions,\n }\n}\n"],"mappings":";;;AAaA,MAAa,eAAgC;CAC3C,OAAO;CACP,OAAO;CACP,UAAU;CACV,SAAS;CACV;AAED,SAAgB,SAAS,OAAqC;CAC5D,MAAM,aAAa,IAAI;EAAE,GAAG;EAAc,GAAG,MAAM;EAAO,CAAC;CAC3D,IAAI,QAAQ,EAAE,GAAG,MAAM,OAAO;CAE9B,YACQ,MAAM,QACX,QAAQ;EAEP,IAAI,CAAC,QAAQ,KAAK,MAAM,EAAE;GACxB,WAAW,QAAQ;IAAE,GAAG;IAAc,GAAG;IAAK;GAC9C,QAAQ,EAAE,GAAG,KAAK;;IAGtB,EAAE,MAAM,MAAM,CACf;CAED,MAAM,YAAY,WAAmB,IAAI,QAAQ,WAAW,MAAM,MAAM;CACxE,MAAM,YAAY,WAAmB,IAAI,QAAQ,WAAW,MAAM,MAAM;CACxE,MAAM,eAAe,WAAmB,IAAI,QAAQ,WAAW,MAAM,SAAS;CAC9E,MAAM,cAAc,WAAmB,IAAI,QAAQ,WAAW,MAAM,QAAQ;CAE5E,OAAO;EACL;EACA;EACA;EACA;EACA;EACD"}