diff --git a/packages/vant-cli/src/common/constant.ts b/packages/vant-cli/src/common/constant.ts
index e97c5f191..115e11aeb 100644
--- a/packages/vant-cli/src/common/constant.ts
+++ b/packages/vant-cli/src/common/constant.ts
@@ -15,9 +15,6 @@ function findRootDir(dir: string): string {
return findRootDir(parentDir);
}
-// Colors
-export const GREEN = '#07c160';
-
// Root paths
export const CWD = process.cwd();
export const ROOT = findRootDir(CWD);
@@ -29,7 +26,6 @@ export const SITE_DIST_DIR = join(ROOT, 'site-dist');
export const VANT_CONFIG_FILE = join(ROOT, 'vant.config.js');
export const PACKAGE_JSON_FILE = join(ROOT, 'package.json');
export const ROOT_POSTCSS_CONFIG_FILE = join(ROOT, 'postcss.config.js');
-export const CACHE_DIR = join(ROOT, 'node_modules/.cache');
// Relative paths
export const DIST_DIR = join(__dirname, '../../dist');
@@ -47,7 +43,6 @@ export const SITE_DESKTOP_SHARED_FILE = join(
export const STYLE_DEPS_JSON_FILE = join(DIST_DIR, 'style-deps.json');
// Config files
-export const BABEL_CONFIG_FILE = join(CONFIG_DIR, 'babel.config.js');
export const POSTCSS_CONFIG_FILE = join(CONFIG_DIR, 'postcss.config.js');
export const JEST_SETUP_FILE = join(CONFIG_DIR, 'jest.setup.js');
export const JEST_CONFIG_FILE = join(CONFIG_DIR, 'jest.config.js');
diff --git a/packages/vant/src/calendar/Calendar.tsx b/packages/vant/src/calendar/Calendar.tsx
index 03c0a7c33..9a0030dfd 100644
--- a/packages/vant/src/calendar/Calendar.tsx
+++ b/packages/vant/src/calendar/Calendar.tsx
@@ -415,8 +415,7 @@ export default defineComponent({
);
if (disabledDay) {
- const lastAbledEndDay = getPrevDay(disabledDay);
- select([startDay, lastAbledEndDay]);
+ select([startDay, getPrevDay(disabledDay)]);
} else {
select([startDay, date], true);
}
@@ -528,9 +527,9 @@ export default defineComponent({
showTitle={props.showTitle}
showSubtitle={props.showSubtitle}
firstDayOfWeek={dayOffset.value}
- onClick-subtitle={(event: MouseEvent) => {
- emit('click-subtitle', event);
- }}
+ onClick-subtitle={(event: MouseEvent) =>
+ emit('click-subtitle', event)
+ }
/>
{months.value.map(renderMonth)}
@@ -542,9 +541,7 @@ export default defineComponent({
watch(() => props.show, init);
watch(
() => [props.type, props.minDate, props.maxDate],
- () => {
- reset(getInitialDate(currentDate.value));
- }
+ () => reset(getInitialDate(currentDate.value))
);
watch(
() => props.defaultDate,
diff --git a/packages/vant/src/cascader/Cascader.tsx b/packages/vant/src/cascader/Cascader.tsx
index e0751a514..10e9ffcae 100644
--- a/packages/vant/src/cascader/Cascader.tsx
+++ b/packages/vant/src/cascader/Cascader.tsx
@@ -24,7 +24,7 @@ export type CascaderOption = {
type CascaderTab = {
options: CascaderOption[];
- selectedOption: CascaderOption | null;
+ selected: CascaderOption | null;
};
export type CascaderFieldNames = {
@@ -111,7 +111,7 @@ export default defineComponent({
state.tabs = selectedOptions.map((option) => {
const tab = {
options: optionsCursor,
- selectedOption: option,
+ selected: option,
};
const next = optionsCursor.find(
@@ -127,7 +127,7 @@ export default defineComponent({
if (optionsCursor) {
state.tabs.push({
options: optionsCursor,
- selectedOption: null,
+ selected: null,
});
}
@@ -142,7 +142,7 @@ export default defineComponent({
state.tabs = [
{
options: props.options,
- selectedOption: null,
+ selected: null,
},
];
};
@@ -152,7 +152,7 @@ export default defineComponent({
return;
}
- state.tabs[tabIndex].selectedOption = option;
+ state.tabs[tabIndex].selected = option;
if (state.tabs.length > tabIndex + 1) {
state.tabs = state.tabs.slice(0, tabIndex + 1);
@@ -161,7 +161,7 @@ export default defineComponent({
if (option[childrenKey]) {
const nextTab = {
options: option[childrenKey],
- selectedOption: null,
+ selected: null,
};
if (state.tabs[tabIndex + 1]) {
@@ -176,7 +176,7 @@ export default defineComponent({
}
const selectedOptions = state.tabs
- .map((tab) => tab.selectedOption)
+ .map((tab) => tab.selected)
.filter(Boolean);
const eventParams = {
@@ -260,19 +260,19 @@ export default defineComponent({
);
const renderTab = (tab: CascaderTab, tabIndex: number) => {
- const { options, selectedOption } = tab;
- const title = selectedOption
- ? selectedOption[textKey]
+ const { options, selected } = tab;
+ const title = selected
+ ? selected[textKey]
: props.placeholder || t('select');
return (
- {renderOptions(options, selectedOption, tabIndex)}
+ {renderOptions(options, selected, tabIndex)}
);
};
@@ -298,9 +298,7 @@ export default defineComponent({
() => props.modelValue,
(value) => {
if (value || value === 0) {
- const values = state.tabs.map(
- (tab) => tab.selectedOption?.[valueKey]
- );
+ const values = state.tabs.map((tab) => tab.selected?.[valueKey]);
if (values.includes(value)) {
return;
}
diff --git a/packages/vant/src/picker/PickerColumn.tsx b/packages/vant/src/picker/PickerColumn.tsx
index 48196c1b0..5940fad2e 100644
--- a/packages/vant/src/picker/PickerColumn.tsx
+++ b/packages/vant/src/picker/PickerColumn.tsx
@@ -29,10 +29,8 @@ const MOMENTUM_LIMIT_DISTANCE = 15;
const [name, bem] = createNamespace('picker-column');
function getElementTranslateY(element: Element) {
- const style = window.getComputedStyle(element);
- const transform = style.transform || style.webkitTransform;
+ const { transform } = window.getComputedStyle(element);
const translateY = transform.slice(7, transform.length - 1).split(', ')[5];
-
return Number(translateY);
}
@@ -316,36 +314,30 @@ export default defineComponent({
watch(
() => props.defaultIndex,
- (value) => {
- setIndex(value);
- }
+ (value) => setIndex(value)
);
- return () => {
- const wrapperStyle = {
- transform: `translate3d(0, ${state.offset + baseOffset()}px, 0)`,
- transitionDuration: `${state.duration}ms`,
- transitionProperty: state.duration ? 'all' : 'none',
- };
-
- return (
-
(
+
- );
- };
+ {renderOptions()}
+
+
+ );
},
});