Skip to content

Commit

Permalink
chore: useExpose -> context.expose (#2697)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiinu authored Dec 4, 2023
1 parent bc03bf1 commit f51b4cc
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 36 deletions.
5 changes: 2 additions & 3 deletions src/packages/__VUE/calendar/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ const { create } = createComponent('calendar');
import NutCalendarItem from '../calendaritem/index.taro.vue';
import NutPopup from '../popup/index.taro.vue';
import Utils from '@/packages/utils/date';
import { useExpose } from '@/packages/utils/useExpose/index';
import { CalendarRef } from '../calendaritem/type';
export default create({
Expand Down Expand Up @@ -176,7 +175,7 @@ export default create({
disabledDate: Function
},
emits: ['choose', 'close', 'update:visible', 'select'],
setup(props, { emit, slots }) {
setup(props, { emit, slots, expose }) {
const showTopBtn = computed(() => {
return slots.btn;
});
Expand All @@ -200,7 +199,7 @@ export default create({
const initPosition = () => {
calendarRef.value?.initPosition();
};
useExpose({
expose({
scrollToDate,
initPosition
});
Expand Down
5 changes: 2 additions & 3 deletions src/packages/__VUE/calendar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ const { create } = createComponent('calendar');
import NutCalendarItem from '../calendaritem/index.vue';
import NutPopup from '../popup/index.vue';
import Utils from '@/packages/utils/date';
import { useExpose } from '@/packages/utils/useExpose/index';
import { CalendarRef } from '../calendaritem/type';
export default create({
Expand Down Expand Up @@ -176,7 +175,7 @@ export default create({
disabledDate: Function
},
emits: ['choose', 'close', 'update:visible', 'select'],
setup(props, { emit, slots }) {
setup(props, { emit, slots, expose }) {
const showTopBtn = computed(() => {
return slots.btn;
});
Expand All @@ -200,7 +199,7 @@ export default create({
const initPosition = () => {
calendarRef.value?.initPosition();
};
useExpose({
expose({
scrollToDate,
initPosition
});
Expand Down
5 changes: 2 additions & 3 deletions src/packages/__VUE/calendaritem/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ import NutScrollView from '../scroll-view/index.taro.vue';
import Utils from '@/packages/utils/date';
import requestAniFrame from '@/packages/utils/raf';
import { MonthInfo, Day, CalendarTaroState } from './type';
import { useExpose } from '@/packages/utils/useExpose/index';
import { useLocale } from '@/packages/utils/useLocale';
const { create } = createComponent('calendar-item');
Expand Down Expand Up @@ -172,7 +171,7 @@ export default create({
},
emits: ['choose', 'update', 'close', 'select'],
setup(props, { emit, slots }) {
setup(props, { emit, slots, expose }) {
const translate = useLocale(cN);
// 新增:自定义周起始日
const weekdays = (translate('weekdays') as any).map((day: string, index: number) => ({
Expand Down Expand Up @@ -711,7 +710,7 @@ export default create({
const initPosition = () => {
state.scrollTop = Math.ceil(state.monthsData[state.currentIndex].cssScrollHeight);
};
useExpose({
expose({
scrollToDate,
initPosition
});
Expand Down
5 changes: 2 additions & 3 deletions src/packages/__VUE/calendaritem/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ import { createComponent } from '@/packages/utils/create';
import Utils from '@/packages/utils/date';
import requestAniFrame from '@/packages/utils/raf';
import { MonthInfo, Day, CalendarState } from './type';
import { useExpose } from '@/packages/utils/useExpose/index';
import { useLocale } from '@/packages/utils/useLocale';
const { create } = createComponent('calendar-item');
Expand Down Expand Up @@ -159,7 +158,7 @@ export default create({
},
emits: ['choose', 'update', 'close', 'select'],
setup(props, { emit, slots }) {
setup(props, { emit, slots, expose }) {
const translate = useLocale(cN);
// 新增:自定义周起始日
const weekdays = (translate('weekdays') as any).map((day: string, index: number) => ({
Expand Down Expand Up @@ -705,7 +704,7 @@ export default create({
months.value.scrollTop = state.monthsData[state.currentIndex].cssScrollHeight;
}
};
useExpose({
expose({
scrollToDate,
initPosition
});
Expand Down
5 changes: 2 additions & 3 deletions src/packages/__VUE/checkboxgroup/index.taro.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts">
import { h, watch, provide, computed, ComponentInternalInstance, reactive, ComponentPublicInstance } from 'vue';
import { createComponent } from '@/packages/utils/create';
import { useExpose } from '@/packages/utils/useExpose/index';
import { CHECKBOX_KEY } from '../checkbox/types';
const { create, componentName } = createComponent('checkbox-group');
Expand All @@ -21,7 +20,7 @@ export default create({
}
},
emits: ['change', 'update:modelValue'],
setup(props, { slots, emit }) {
setup(props, { slots, emit, expose }) {
const state = reactive({
children: [] as ComponentPublicInstance[]
});
Expand Down Expand Up @@ -80,7 +79,7 @@ export default create({
}
);
useExpose({ toggleAll, toggleReverse });
expose({ toggleAll, toggleReverse });
return () => {
return h(
Expand Down
5 changes: 2 additions & 3 deletions src/packages/__VUE/checkboxgroup/index.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts">
import { h, watch, provide, computed, ComponentInternalInstance, reactive, ComponentPublicInstance } from 'vue';
import { createComponent } from '@/packages/utils/create';
import { useExpose } from '@/packages/utils/useExpose/index';
import { CHECKBOX_KEY } from '../checkbox/types';
const { create, componentName } = createComponent('checkbox-group');
Expand All @@ -21,7 +20,7 @@ export default create({
}
},
emits: ['change', 'update:modelValue'],
setup(props, { slots, emit }) {
setup(props, { slots, emit, expose }) {
const state = reactive({
children: [] as ComponentPublicInstance[]
});
Expand Down Expand Up @@ -80,7 +79,7 @@ export default create({
}
);
useExpose({ toggleAll, toggleReverse });
expose({ toggleAll, toggleReverse });
return () => {
return h(
Expand Down
11 changes: 5 additions & 6 deletions src/packages/__VUE/elevator/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
<script lang="ts">
import { computed, reactive, toRefs, nextTick, ref, Ref, watch, PropType } from 'vue';
import { createComponent } from '@/packages/utils/create';
import { useExpose } from '@/packages/utils/useExpose/index';
import { ElevatorData } from './type';
const { create } = createComponent('elevator');
Expand Down Expand Up @@ -95,7 +94,7 @@ export default create({
}
},
emits: ['clickItem', 'clickIndex', 'change'],
setup(props, context) {
setup(props, { emit, expose }) {
const spaceHeight = 23;
const listview: Ref<HTMLElement> = ref() as Ref<HTMLElement>;
const state = reactive({
Expand Down Expand Up @@ -187,13 +186,13 @@ export default create({
};
const handleClickItem = (key: string, item: ElevatorData) => {
context.emit('clickItem', key, item);
emit('clickItem', key, item);
state.currentData = item;
state.currentKey = key;
};
const handleClickIndex = (key: string) => {
context.emit('clickIndex', key);
emit('clickIndex', key);
};
const listViewScroll = (e: Event) => {
Expand All @@ -211,7 +210,7 @@ export default create({
}
};
useExpose({
expose({
scrollTo
});
Expand All @@ -225,7 +224,7 @@ export default create({
watch(
() => state.currentIndex,
(newVal: number) => {
context.emit('change', newVal);
emit('change', newVal);
}
);
Expand Down
11 changes: 5 additions & 6 deletions src/packages/__VUE/elevator/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
<script lang="ts">
import { computed, reactive, toRefs, nextTick, ref, Ref, watch, onMounted, PropType } from 'vue';
import { createComponent } from '@/packages/utils/create';
import { useExpose } from '@/packages/utils/useExpose/index';
import { ElevatorData } from './type';
const { create } = createComponent('elevator');
Expand Down Expand Up @@ -73,7 +72,7 @@ export default create({
}
},
emits: ['clickItem', 'clickIndex', 'change'],
setup(props, context) {
setup(props, { emit, expose }) {
const listview: Ref<any> = ref(null);
const state = reactive({
anchorIndex: 0,
Expand Down Expand Up @@ -153,13 +152,13 @@ export default create({
};
const handleClickItem = (key: string, item: ElevatorData) => {
context.emit('clickItem', key, item);
emit('clickItem', key, item);
state.currentData = item;
state.currentKey = key;
};
const handleClickIndex = (key: string) => {
context.emit('clickIndex', key);
emit('clickIndex', key);
};
const listViewScroll = (e: Event) => {
Expand All @@ -186,7 +185,7 @@ export default create({
}
});
useExpose({
expose({
scrollTo
});
Expand Down Expand Up @@ -214,7 +213,7 @@ export default create({
watch(
() => state.currentIndex,
(newVal: number) => {
context.emit('change', newVal);
emit('change', newVal);
}
);
Expand Down
5 changes: 2 additions & 3 deletions src/packages/__VUE/swiper/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import {
import { createComponent } from '@/packages/utils/create';
import { useTouch } from '@/packages/utils/useTouch/index';
import { useTaroRect } from '@/packages/utils/useTaroRect';
import { useExpose } from '@/packages/utils/useExpose/index';
import requestAniFrame from '@/packages/utils/raf';
import { clamp } from '@/packages/utils/util';
import Taro, { eventCenter, getCurrentInstance } from '@tarojs/taro';
Expand Down Expand Up @@ -99,7 +98,7 @@ export default create({
},
emits: ['change'],
setup(props, { emit, slots }) {
setup(props, { emit, slots, expose }) {
const container = ref<HTMLElement>();
const refRandomId = Math.random().toString(36).slice(-8);
const state = reactive({
Expand Down Expand Up @@ -399,7 +398,7 @@ export default create({
relation
});
useExpose({
expose({
prev,
next,
to
Expand Down
5 changes: 2 additions & 3 deletions src/packages/__VUE/swiper/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {
} from 'vue';
import { createComponent } from '@/packages/utils/create';
import { useTouch } from '@/packages/utils/useTouch/index';
import { useExpose } from '@/packages/utils/useExpose/index';
import { clamp } from '@/packages/utils/util';
import requestAniFrame from '@/packages/utils/raf';
import { SWIPER_KEY } from './types';
Expand Down Expand Up @@ -96,7 +95,7 @@ export default create({
},
emits: ['change'],
setup(props, { emit, slots }) {
setup(props, { emit, slots, expose }) {
const container = ref();
const state = reactive({
active: 0,
Expand Down Expand Up @@ -391,7 +390,7 @@ export default create({
relation
});
useExpose({
expose({
prev,
next,
to
Expand Down

0 comments on commit f51b4cc

Please sign in to comment.