{"version":3,"file":"sort-selector.vue2.mjs","sources":["../../../../../../packages/components/sort-selector/src/sort-selector.vue"],"sourcesContent":["<template>\r\n  <div :class=\"[bem.b()]\">\r\n    <ll-select\r\n      v-model:value=\"selectValue\"\r\n      :size=\"size\"\r\n      placeholder=\"请选择\"\r\n      :style=\"{\r\n        minWidth: addUnit(minWidth),\r\n        maxWidth: maxWidth ? addUnit(maxWidth) : undefined,\r\n      }\"\r\n      :options=\"options\"\r\n      :field-names=\"fieldNames\"\r\n      :class=\"bem.e('select-content')\"\r\n      @select=\"handleSelect\"\r\n    />\r\n    <!-- 排序 -->\r\n    <ll-button\r\n      :class=\"[bem.e('sort-btn')]\"\r\n      type=\"text\"\r\n      :size=\"size\"\r\n      @click=\"handleSort\"\r\n    >\r\n      <template #icon>\r\n        <ll-icon-base\r\n          :arrow=\"true\"\r\n          :is-white-bg=\"false\"\r\n          :is-show-container=\"false\"\r\n          :tooltip-title=\"\r\n            sortValue === 'asc' ? ascText || '升序' : descText || '降序'\r\n          \"\r\n          :icon-name=\"\r\n            sortValue === 'asc' ? 'icon-ascending' : 'icon-descending'\r\n          \"\r\n        />\r\n      </template>\r\n    </ll-button>\r\n  </div>\r\n</template>\r\n\r\n<script setup lang=\"ts\">\r\nimport { addUnit, createNamespace } from '@ll-plus/utils'\r\nimport { computed, onMounted } from 'vue'\r\nimport { sortSelectorProps } from './sort-selector'\r\n\r\ndefineOptions({ name: 'LlSortSelector' })\r\n\r\nconst bem = createNamespace('sort-selector')\r\n\r\nconst props = defineProps(sortSelectorProps)\r\nconst emits = defineEmits(['change', 'update:selectValue', 'update:sortValue'])\r\n\r\nconst selectValue = computed({\r\n  get: () => props.selectValue || props.options?.[0]?.value || null,\r\n  set: (val: any) => {\r\n    emits('update:selectValue', val)\r\n  },\r\n})\r\n\r\nconst sortValue = computed({\r\n  get: () => props.sortValue || props.options?.[0]?.orderBy || 'asc',\r\n  set: (val: string) => {\r\n    emits('update:sortValue', val)\r\n  },\r\n})\r\n\r\n// 处理字段切换\r\n// const handleSelect = (_, option) => {\r\n//   sortValue.value = option.orderBy || 'asc'\r\n// }\r\n\r\n// // 处理排序方向切换\r\n// const handleSort = () => {\r\n//   sortValue.value = sortValue.value === 'asc' ? 'desc' : 'asc'\r\n// }\r\n\r\n// 处理字段切换\r\nconst handleSelect = (value, option) => {\r\n  const newSelectVal = value\r\n  const newSortVal = option.orderBy || 'asc'\r\n\r\n  selectValue.value = newSelectVal\r\n  sortValue.value = newSortVal\r\n\r\n  // 统一在这里触发一次 change 事件\r\n  emits('change', newSelectVal, newSortVal)\r\n}\r\n\r\n// 处理排序方向切换\r\nconst handleSort = () => {\r\n  const newSortVal = sortValue.value === 'asc' ? 'desc' : 'asc'\r\n  sortValue.value = newSortVal\r\n  emits('change', selectValue.value, newSortVal)\r\n}\r\n\r\nonMounted(() => {\r\n  if (!props.selectValue && props.options?.length > 0) {\r\n    emits('update:selectValue', props.options[0]?.value || '')\r\n  }\r\n  if (!props.sortValue) {\r\n    emits('update:sortValue', props.options[0]?.orderBy || 'asc')\r\n  }\r\n})\r\n</script>\r\n"],"names":["_createElementBlock","_normalizeClass","_unref","_createVNode","size","_normalizeStyle","minWidth","maxWidth","options","fieldNames","_createCommentVNode","ascText","descText"],"mappings":";;;;;;;;;;;;;AA8CA,IAAA,MAAM,GAAA,GAAM,gBAAgB,eAAe,CAAA;AAE3C,IAAA,MAAM,KAAA,GAAQ,OAAA;AACd,IAAA,MAAM,KAAA,GAAQ,MAAA;AAEd,IAAA,MAAM,cAAc,QAAA,CAAS;AAAA,MAC3B,GAAA,EAAK,MAAM,KAAA,CAAM,WAAA,IAAe,MAAM,OAAA,GAAU,CAAC,GAAG,KAAA,IAAS,IAAA;AAAA,MAC7D,GAAA,EAAK,CAAC,GAAA,KAAa;AACjB,QAAA,KAAA,CAAM,sBAAsB,GAAG,CAAA;AAAA,MACjC;AAAA,KACD,CAAA;AAED,IAAA,MAAM,YAAY,QAAA,CAAS;AAAA,MACzB,GAAA,EAA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