Skip to content

Commit

Permalink
fix: missing types for slots
Browse files Browse the repository at this point in the history
  • Loading branch information
07akioni committed Jan 1, 2025
1 parent 3cb6a61 commit 942de11
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 28 deletions.
1 change: 0 additions & 1 deletion src/_utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export {
omit,
render,
resolveSlot,
resolveSlotWithProps,
resolveSlotWithTypedProps,
resolveWrappedSlot,
resolveWrappedSlotWithProps,
Expand Down
1 change: 0 additions & 1 deletion src/_utils/vue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export { render } from './render'
export {
isSlotEmpty,
resolveSlot,
resolveSlotWithProps,
resolveSlotWithTypedProps,
resolveWrappedSlot,
resolveWrappedSlotWithProps
Expand Down
8 changes: 0 additions & 8 deletions src/_utils/vue/resolve-slot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ export function resolveSlot(
return (slot && ensureValidVNode(slot())) || fallback()
}

export function resolveSlotWithProps<T>(
slot: Slot | undefined,
props: T,
fallback: (props: T) => VNodeArrayChildren
): VNodeArrayChildren {
return (slot && ensureValidVNode(slot(props))) || fallback(props)
}

export function resolveSlotWithTypedProps<T>(
slot: Slot<T> | undefined,
props: T,
Expand Down
6 changes: 3 additions & 3 deletions src/collapse/src/CollapseItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
import { useConfig } from '../../_mixins'
import { useRtl } from '../../_mixins/use-rtl'
import {
resolveSlotWithProps,
resolveSlotWithTypedProps,
resolveWrappedSlotWithProps,
throwError
} from '../../_utils'
Expand Down Expand Up @@ -129,7 +129,7 @@ export default defineComponent({
disabled,
triggerAreas
} = this
const headerNode = resolveSlotWithProps(
const headerNode = resolveSlotWithTypedProps(
$slots.header,
{ collapsed },
() => [this.title]
Expand Down Expand Up @@ -165,7 +165,7 @@ export default defineComponent({
key={this.rtlEnabled ? 0 : 1}
data-arrow
>
{resolveSlotWithProps(arrowSlot, { collapsed }, () => [
{resolveSlotWithTypedProps(arrowSlot, { collapsed }, () => [
<NBaseIcon clsPrefix={mergedClsPrefix}>
{{
default: () =>
Expand Down
10 changes: 7 additions & 3 deletions src/date-picker/src/panel/date.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import {
FastForwardIcon,
ForwardIcon
} from '../../../_internal/icons'
import { resolveSlot, resolveSlotWithProps, warnOnce } from '../../../_utils'
import {
resolveSlot,
resolveSlotWithTypedProps,
warnOnce
} from '../../../_utils'
import { NButton, NxButton } from '../../../button'
import PanelHeader from './panelHeader'
import { useCalendar, useCalendarProps } from './use-calendar'
Expand Down Expand Up @@ -194,7 +198,7 @@ export default defineComponent({
</div>
<div class={`${mergedClsPrefix}-date-panel-actions__suffix`}>
{this.actions?.includes('clear')
? resolveSlotWithProps(
? resolveSlotWithTypedProps(
this.$slots.clear,
{
onClear: this.handleClearClick,
Expand All @@ -213,7 +217,7 @@ export default defineComponent({
)
: null}
{this.actions?.includes('now')
? resolveSlotWithProps(
? resolveSlotWithTypedProps(
this.$slots.now,
{
onNow: this.handleNowClick,
Expand Down
10 changes: 7 additions & 3 deletions src/date-picker/src/panel/daterange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import {
FastForwardIcon,
ForwardIcon
} from '../../../_internal/icons'
import { resolveSlot, resolveSlotWithProps, warnOnce } from '../../../_utils'
import {
resolveSlot,
resolveSlotWithTypedProps,
warnOnce
} from '../../../_utils'
import { NButton, NxButton } from '../../../button'
import PanelHeader from './panelHeader'
import { useDualCalendar, useDualCalendarProps } from './use-dual-calendar'
Expand Down Expand Up @@ -283,7 +287,7 @@ export default defineComponent({
</div>
<div class={`${mergedClsPrefix}-date-panel-actions__suffix`}>
{this.actions?.includes('clear')
? resolveSlotWithProps(
? resolveSlotWithTypedProps(
datePickerSlots.clear,
{
onClear: this.handleClearClick,
Expand All @@ -302,7 +306,7 @@ export default defineComponent({
)
: null}
{this.actions?.includes('confirm')
? resolveSlotWithProps(
? resolveSlotWithTypedProps(
datePickerSlots.confirm,
{
onConfirm: this.handleConfirmClick,
Expand Down
8 changes: 4 additions & 4 deletions src/date-picker/src/panel/datetime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
FastForwardIcon,
ForwardIcon
} from '../../../_internal/icons'
import { resolveSlot, resolveSlotWithProps } from '../../../_utils'
import { resolveSlot, resolveSlotWithTypedProps } from '../../../_utils'
import { NButton, NxButton } from '../../../button'
import { NInput } from '../../../input'
import { NTimePicker } from '../../../time-picker'
Expand Down Expand Up @@ -206,7 +206,7 @@ export default defineComponent({
</div>
<div class={`${mergedClsPrefix}-date-panel-actions__suffix`}>
{this.actions?.includes('clear')
? resolveSlotWithProps(
? resolveSlotWithTypedProps(
this.datePickerSlots.clear,
{
onClear: this.clearSelectedDateTime,
Expand All @@ -225,7 +225,7 @@ export default defineComponent({
)
: null}
{this.actions?.includes('now')
? resolveSlotWithProps(
? resolveSlotWithTypedProps(
datePickerSlots.now,
{
onNow: this.handleNowClick,
Expand All @@ -244,7 +244,7 @@ export default defineComponent({
)
: null}
{this.actions?.includes('confirm')
? resolveSlotWithProps(
? resolveSlotWithTypedProps(
datePickerSlots.confirm,
{
onConfirm: this.handleConfirmClick,
Expand Down
10 changes: 7 additions & 3 deletions src/date-picker/src/panel/datetimerange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import {
FastForwardIcon,
ForwardIcon
} from '../../../_internal/icons'
import { resolveSlot, resolveSlotWithProps, warnOnce } from '../../../_utils'
import {
resolveSlot,
resolveSlotWithTypedProps,
warnOnce
} from '../../../_utils'
import { NButton, NxButton } from '../../../button'
import { NInput } from '../../../input'
import { NTimePicker } from '../../../time-picker'
Expand Down Expand Up @@ -372,7 +376,7 @@ export default defineComponent({
</div>
<div class={`${mergedClsPrefix}-date-panel-actions__suffix`}>
{this.actions?.includes('clear')
? resolveSlotWithProps(
? resolveSlotWithTypedProps(
datePickerSlots.clear,
{
onClear: this.handleClearClick,
Expand All @@ -391,7 +395,7 @@ export default defineComponent({
)
: null}
{this.actions?.includes('confirm')
? resolveSlotWithProps(
? resolveSlotWithTypedProps(
datePickerSlots.confirm,
{
onConfirm: this.handleConfirmClick,
Expand Down
4 changes: 2 additions & 2 deletions src/input/src/WordCount.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { computed, defineComponent, h, inject } from 'vue'
import { resolveSlotWithProps } from '../../_utils'
import { resolveSlotWithTypedProps } from '../../_utils'
import { inputInjectionKey } from './interface'
import { len } from './utils'

Expand All @@ -23,7 +23,7 @@ export default defineComponent({
const { value: mergedValue } = mergedValueRef
return (
<span class={`${mergedClsPrefixRef.value}-input-word-count`}>
{resolveSlotWithProps(
{resolveSlotWithTypedProps(
slots.default,
{
value:
Expand Down

0 comments on commit 942de11

Please sign in to comment.