Skip to content

Commit

Permalink
refactor: slots modification simplified
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-solanki committed Feb 17, 2023
1 parent c31055b commit 9a422bf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions packages/anu-vue/src/components/card/slots.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { typographySlots } from '@/components/typography/slots'
import { removeKeys } from '@/utils/helpers'

// TODO: Fix type

export const cardOwnSlots = {
default: {},
} as const
export const cardTypographySlots = removeKeys(typographySlots, ['default'])

const { default: _, ...cardTypographySlots } = typographySlots
export { cardTypographySlots }

export const cardSlots = {
...cardOwnSlots,
Expand Down
18 changes: 9 additions & 9 deletions packages/anu-vue/src/components/select/slots.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { baseInputSlots } from '@/components/base-input'
import { cardSlots } from '@/components/card'
import { listSlots } from '@/components/list'
import { prefixObjectKeys, removeKeys } from '@/utils/helpers'
import { prefixObjectKeys } from '@/utils/helpers'

export const selectBaseInputSlots = removeKeys(baseInputSlots, ['default'])
export const selectCardSlots = removeKeys(cardSlots, ['default'])
// Remove default slot
const { default: _, ...selectBaseInputSlots } = baseInputSlots
const { default: __, ...selectCardSlots } = cardSlots

const { default: selectListDefaultSlot, ...selectListRestSlots } = listSlots
export { selectBaseInputSlots }
export { selectCardSlots }

// export const selectListSlots = renameObjKey(
// prefixObjectKeys(listSlots, 'options-'),
// 'options-default',
// 'default',
// )
const { default: selectListDefaultSlot, ...selectListRestSlots } = listSlots

export const selectListSlots = {
...prefixObjectKeys(selectListRestSlots, 'options-'),

// 鈩癸笍 We aren't renaming default slot but we want to get `prefixObjectKeys` return value like object
...prefixObjectKeys({ default: selectListDefaultSlot }, ''),
}

Expand Down

0 comments on commit 9a422bf

Please sign in to comment.