Compare commits

...

277 Commits
v3.5.4 ... next

Author SHA1 Message Date
chenjiahan
b45b0b7608 chore: update branches in GitHub actions 2022-09-10 21:57:09 +08:00
chenjiahan
c309ca2aaf docs: switch dev branch to v4 2022-09-10 21:53:49 +08:00
chenjiahan
66df033ec8 Merge branch 'dev' into next 2022-09-10 21:51:26 +08:00
neverland
e2ea3be819
feat: export props of all components (#11024) 2022-09-10 21:49:21 +08:00
neverland
019c328975
chore: remove *.less from sideEffects (#11023) 2022-09-10 17:17:23 +08:00
neverland
0e55b72200
feat(Image): add block prop (#11022) 2022-09-10 17:13:14 +08:00
neverland
69d3ba000c
chore: bump pnpm version to 7.11 (#11021) 2022-09-10 12:46:55 +08:00
neverland
9418fe371d
docs: improve use component guide (#11020) 2022-09-10 12:28:43 +08:00
neverland
5d8282ddae
docs(Toast): add component usage guide (#11019) 2022-09-10 11:40:11 +08:00
neverland
43ff890d79
feat(Toast): add message slot (#11018) 2022-09-10 11:32:38 +08:00
neverland
98642589ee
docs: add picker-group to migration guide (#11016) 2022-09-08 23:16:08 +08:00
neverland
6f910c9913
feat(Dialog): message-align can be justify (#11014) 2022-09-07 23:20:28 +08:00
chenjiahan
1b08f84ac6 docs(changelog): @vant/cli 4.0.4 2022-09-06 00:03:50 +08:00
chenjiahan
f0d3e04fba release: @vant/cli 4.0.4 2022-09-06 00:03:00 +08:00
neverland
830a1eb5cf
fix(@vant/cli): failed to build types of sfc (#11012) 2022-09-06 00:00:28 +08:00
Fengyuan Chen
cd439c04f3 fix(utils): avoid getting unexpected value (#11010)
For example, when calling `get({}, 'button.small')`, it expects to return an empty string, but return a function (`''.small` is a native function, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/small).
2022-09-05 23:42:11 +08:00
neverland
0aac165d4e
fix(Picker): failed to update value in some cases (#11009) 2022-09-04 21:00:18 +08:00
chenjiahan
f60a3b840d docs(changelog): vant@4.0.0-rc.0 2022-09-04 14:51:32 +08:00
chenjiahan
997f3e0acd release: 4.0.0-rc.0 2022-09-04 14:49:15 +08:00
chenjiahan
e2fe50250c Merge branch 'dev' into next 2022-09-04 14:34:46 +08:00
neverland
bc024a105c
docs(changelog): vant@3.6.2 (#11008) 2022-09-04 14:31:12 +08:00
chenjiahan
7afb74345a release: 3.6.2 2022-09-04 14:26:50 +08:00
neverland
65fdb2155b
chore: bump all deps (#11007)
* chore: bump all deps

* chore: fix type

* chore: fix withInstall type
2022-09-04 14:24:59 +08:00
neverland
c6bc97f4e4
docs: update quickstart guide (#11006)
* docs: update quickstart guide

* docs: update
2022-09-04 10:01:19 +08:00
chenjiahan
7d023fd6e4 docs: update babel-plugin-import tip 2022-09-04 09:59:42 +08:00
neverland
1afe960f30
feat: add new PickerGroup component (#11005)
* feat: add PickerGroup component

* chore: remove log

* chore: en doc

* chore: add snapshot

* docs: update
2022-09-04 09:39:37 +08:00
neverland
3e039b02b5
docs: add function component style guide (#11003) 2022-09-02 23:24:27 +08:00
Alan Wang
1837ed712f
fix(indexBar): index-bar not positioned correctly when scrolled to the bottom (#10994) 2022-09-02 23:01:22 +08:00
chenjiahan
94c5afe65c release: @vant/area-data 1.3.2 2022-09-01 23:23:23 +08:00
yanbo
5174a1a668
fix(area-data): update counties of Daxinganling region (#11000) 2022-09-01 16:29:17 +08:00
童欧巴
ed8cd77449
docs: fix card overflow issue (#10988)
Co-authored-by: huoyitong <huoyitong@lixiang.com>
2022-08-29 18:44:18 +08:00
neverland
a677bee2b8
fix(DatePicker): min-date prop not work correctly (#10985) 2022-08-28 17:11:04 +08:00
neverland
05544c109f
fix(DatePicker): failed to update model value (#10984) 2022-08-28 16:59:41 +08:00
neverland
21c57caa9b
docs(DatePicker): fix toolbar slot name (#10983) 2022-08-28 11:52:14 +08:00
chenjiahan
66aa2906e0 docs(DatePicker): fix basic usage 2022-08-28 11:01:49 +08:00
chenjiahan
61ef6b9a98 chore(Picker): add getEventParams function 2022-08-28 10:50:49 +08:00
neverland
c25acb8d46
chore(PIcker): split PickerToolbar component (#10982) 2022-08-28 10:43:14 +08:00
chenjiahan
8bcb34724f fix(Picker): fix passive event 2022-08-28 10:01:14 +08:00
chenjiahan
cf5e7e6629 Merge branch 'dev' into next 2022-08-28 09:47:56 +08:00
neverland
a02cfe9604
fix(Swipe): should not prevent touch move when reach edge (#10980) 2022-08-27 15:44:06 +08:00
neverland
71354f7742
fix(@vant/cli): add passive for global touchstart (#10979) 2022-08-27 15:22:56 +08:00
neverland
84b05f0668
docs: prefer using externalVue in nuxt 3 (#10978) 2022-08-27 15:07:43 +08:00
neverland
95542bf06e
docs: add nuxt 3 guide (#10977) 2022-08-27 13:48:59 +08:00
neverland
8d15fa4fdf
fix(Calendar): allow default date to be maxDate when enable allowSameDay (#10976) 2022-08-27 11:29:30 +08:00
chenyunjie
35f81fb208
fix(Calendar): range type defaultDate when set allowSameDay (#10971) 2022-08-27 11:15:46 +08:00
neverland
da3400435f
fix: reduce passive event warning of touchmove event (#10975) 2022-08-27 11:12:36 +08:00
neverland
50ee584953
docs(changelog): vant@4.0.0-beta.1 (#10966) 2022-08-24 22:53:35 +08:00
chenjiahan
889b28609a release: 4.0.0-beta.1 2022-08-24 22:47:17 +08:00
chenjiahan
6a7376d15d docs(changelog): 3.6.1 2022-08-24 22:43:13 +08:00
chenjiahan
2cca630808 release: 3.6.1 2022-08-24 22:40:20 +08:00
neverland
dcffa09812
feat(Popup): improve style when position is center (#10965) 2022-08-24 22:40:11 +08:00
chenjiahan
0881de82af docs(ImagePreview): fix cell style in demo 2022-08-24 22:19:13 +08:00
chenjiahan
86adc66dd9 Restore "fix(Popup&Toast): invalid adaptive width (#10961)"
This reverts commit aa1689fed8e58d52db2367263ccbcc08853ff848.
2022-08-24 22:04:46 +08:00
chenjiahan
1d87343195 Merge branch 'dev' into next 2022-08-24 22:04:34 +08:00
chenjiahan
aa1689fed8 Revert "fix(Popup&Toast): invalid adaptive width (#10961)"
This reverts commit b6dd0cb36c0445e199335c36a4c21e696cf8b073.
2022-08-24 21:56:10 +08:00
yinhaogt
b6dd0cb36c
fix(Popup&Toast): invalid adaptive width (#10961)
* fix(Popup&Toast):Invalid adaptive width

* Update index.less

Co-authored-by: neverland <jait.chen@foxmail.com>
2022-08-24 21:45:10 +08:00
neverland
4b2e06b34d
fix(Tabs): resize not work for swipeable tabs (#10964) 2022-08-24 21:32:29 +08:00
neverland
717f244d2f
fix: reduce passive event warning of touchstart event (#10954) 2022-08-21 22:08:27 +08:00
neverland
6b7ae0f6a0
types(@vant/use): improve useEventListener typing (#10952) 2022-08-21 17:49:48 +08:00
neverland
cb93bd2da3
perf: add correct passive flag to improve scroll performance (#10951) 2022-08-21 17:33:57 +08:00
neverland
ca583e1075
docs(NoticeBar): disable swipe drag in demo (#10950) 2022-08-21 17:28:32 +08:00
chenjiahan
667034322e docs(changelog): vant@3.6.0 2022-08-21 11:30:21 +08:00
chenjiahan
8d51f9e08e release: 3.6.0 2022-08-21 11:23:01 +08:00
neverland
236a2e43f3
fix(Popover): can not scroll inside popup (#10949)
* fix(Popover): can not scroll inside popup

* fix: ref
2022-08-21 11:18:20 +08:00
chenjiahan
326880a4e1 release: @vant/use 1.4.2 2022-08-21 10:56:57 +08:00
neverland
31ac5faa3a
feat(@vant/use): useClickAway support multiple targets (#10948) 2022-08-21 10:55:18 +08:00
neverland
1e8187bc37
chore: fix failed to deploy website (#10947) 2022-08-21 10:06:45 +08:00
neverland
72d515b30e
fix: incorrect tag name in WebStorm (#10946) 2022-08-21 10:03:05 +08:00
neverland
b4072ef2bd
docs: import quick start document (#10945) 2022-08-21 09:52:09 +08:00
neverland
ec1d32db4a
fix(Empty): generate unique id to avoid render issue (#10943) 2022-08-20 22:51:08 +08:00
neverland
dfdc27a755
docs: add faq of remove babel-plugin-import (#10942)
* docs: add faq of remove babel-plugin-import

* docs: update
2022-08-20 22:35:12 +08:00
neverland
8574339579
docs: add import tips (#10941) 2022-08-20 22:28:05 +08:00
neverland
5c6992f97c
feat(ConfigProvider): add theme-vars-dark and theme-vars-light props (#10939) 2022-08-19 23:10:41 +08:00
chenjiahan
292ac6b55e Merge branch 'dev' into next 2022-08-19 22:14:47 +08:00
neverland
1945c35b17
fix(PullRefresh): remove passive event warning (#10938) 2022-08-19 22:04:52 +08:00
Yanghc
da3ad139d4
docs(Search): fix action-text type (#10936) 2022-08-19 17:35:45 +08:00
Yanghc
3aca130ca5
docs(Search): fix action-text type (#10935) 2022-08-19 17:35:26 +08:00
小镇靓仔
f060d1a813
docs: add tips in advanced-usage.zh-CN.md (#10927)
* docs: add tips in advanced-usage.zh-CN.md

* Update advanced-usage.zh-CN.md

Co-authored-by: neverland <jait.chen@foxmail.com>
2022-08-18 15:01:45 +08:00
zhangenming
041039b5e9
feat(Badge): fix the problem mentioned at README. (#10921)
* Update Badge.tsx

* Update README.zh-CN.md

* Update README.zh-CN.md

Co-authored-by: neverland <jait.chen@foxmail.com>
Co-authored-by: neverland <chenjiahan@youzan.com>
2022-08-17 11:51:35 +08:00
neverland
68b93a4008
chore: fix CI not work for pull request (#10923) 2022-08-17 11:48:19 +08:00
neverland
4e83e5ecc0
feat(ConfigProvider): add z-index prop (#10915) 2022-08-16 22:09:48 +08:00
limingxin
8ef197ea12
docs: fix link address in migrate-from-v3.md (#10919) 2022-08-16 16:09:35 +08:00
neverland
dc0a29be17
feat(Form): add validateEmpty option of rule (#10913) 2022-08-14 11:03:49 +08:00
neverland
a06f1567db
docs(Form): fix the type of rule trigger option (#10912)
* docs(Form): fix the type of rule trigger option

* docs: update
2022-08-14 09:53:38 +08:00
neverland
e17cc35dcf
fix(Search): --van-search-input-height var not work (#10911)
* fix(Search): --van-search-input-height var not work

* chore: update padding
2022-08-14 09:44:52 +08:00
neverland
04494a450d
fix(Calendar): content disappeared when hiding (#10910)
* fix(Calendar): content disappeared when hiding

* chore: add comment

* chore: upd
2022-08-13 13:24:12 +08:00
neverland
e5cc32ca97
fix(Calendar): reading getFullYear error in some cases (#10909) 2022-08-13 12:03:07 +08:00
neverland
c3776877ca
fix(Calendar): fix reading getFullYear error (#10908) 2022-08-13 11:43:15 +08:00
neverland
f61b00175e
fix(ConfigProvider): should remove theme class on unmount (#10898) 2022-08-10 08:31:46 +08:00
chenjiahan
6a1516ca37 Merge branch 'dev' into next 2022-08-10 07:58:38 +08:00
chenjiahan
7eaefd04fa test(Popup): fix snapshot 2022-08-09 10:08:23 +08:00
richex-cn
ed5ea225ca
feat(Popup): add role and tabindex for a11y (#10894)
* feat(Popup): add role and tabindex for a11y

* Update Popup.tsx

Co-authored-by: neverland <jait.chen@foxmail.com>
2022-08-09 10:04:13 +08:00
neverland
b117e21dc4
feat(touch-emulator): support .mjs extension (#10888) 2022-08-06 22:53:57 +08:00
chenjiahan
961f70d523 docs(changelog): 3.5.4 2022-08-06 20:13:04 +08:00
chenjiahan
cfdb5c1fbe release: 3.5.4 2022-08-06 20:12:56 +08:00
neverland
89718934af
fix(@vant/cli): should replace NODE_ENV in vite v3 (#10887) 2022-08-06 17:37:16 +08:00
neverland
6fee5cfed8
docs(Space): add version tip (#10886) 2022-08-06 17:34:30 +08:00
neverland
9e8a0864c3
chore(Space): improve demo and document (#10870) 2022-07-31 20:09:13 +08:00
luopei
c3a8275ebf
feat(Space): add new component space (#10857)
* feat(Space): add new component space

* feat(Space): improve functions,documents and add test
2022-07-31 18:20:16 +08:00
neverland
d3c679aa27
docs: add babel-plugin-import migration guide (#10867) 2022-07-30 20:22:43 +08:00
neverland
2f6ef7aed8
feat(Picker): add clickOption event (#10865)
* feat(Picker): add clickOption event

* chore: update
2022-07-30 14:04:43 +08:00
chenjiahan
83a4e286bd Merge branch 'dev' into next 2022-07-23 22:20:49 +08:00
chenjiahan
178df39c44 Merge branch 'dev' into next 2022-07-23 21:20:27 +08:00
dyh333
627661e0ed
docs(Icon): separate usingUrl demo from basicUsage (#10828)
Co-authored-by: dingyihui <dingyihui@cmss.chinamobile.com>
2022-07-20 21:36:08 +08:00
neverland
b46b429682
docs(changelog): 4.0.0-beta.0 (#10825) 2022-07-16 15:07:38 +08:00
chenjiahan
15142770f2 release: 4.0.0-beta.0 2022-07-16 15:00:14 +08:00
chenjiahan
aea97f90e6 Merge branch 'dev' into next 2022-07-16 14:58:24 +08:00
chenjiahan
a0bd47dd84 Merge branch 'dev' into next 2022-07-10 21:23:47 +08:00
neverland
e998c1be95
feat: add @vant/compat package (#10806)
* feat: add @vant/compat package

* chore: remove prepare script
2022-07-09 20:54:27 +08:00
neverland
1ce400bb7f
refactor(Toast): redesign function-call API (#10804) 2022-07-09 17:09:54 +08:00
neverland
5a3fe7ed0f
chore: rename unreleased API (#10803) 2022-07-09 15:38:28 +08:00
neverland
1bc6cbdb69
refactor(ImagePreview): redesign function-call API (#10802) 2022-07-09 15:32:02 +08:00
neverland
5f526c9f0e
chore(Dialog): rename unreleased API (#10783) 2022-07-03 13:54:06 +08:00
neverland
ec78d5b1d9
refactor(Notify): redesign function-call API (#10782)
* refactor(Notify): redesign function-call API

* docs: update
2022-07-03 13:39:27 +08:00
neverland
e5e6e8aaa4
refactor(Dialog): redesign function-call API (#10781)
* refactor(Dialog): re-design function-call API

* chore: remove invalid char

* docs: order

* chore: remove var
2022-07-03 12:28:25 +08:00
chenjiahan
e27efdad0d Merge branch 'dev' into next 2022-07-03 10:57:43 +08:00
neverland
154408fa8b
perf: remove less source file to remove bundle size (#10752)
* perf: remove css source file to remove bundle size

* docs: update migration guide
2022-06-26 21:52:40 +08:00
chenjiahan
20ee462cab Merge branch 'dev' into next 2022-06-26 21:43:49 +08:00
chenjiahan
2b77f96fc5 Merge branch 'dev' into next 2022-06-25 12:48:53 +08:00
chenjiahan
1d5cb1e051 Merge branch 'dev' into next 2022-06-18 20:34:49 +08:00
chenjiahan
5d81dcb549 Merge branch 'dev' into next 2022-06-11 20:23:35 +08:00
chenjiahan
63519433f1 docs(changelog): 4.0.0-alpha.4 2022-05-31 20:12:05 +08:00
chenjiahan
1f19fb0d9f release: 4.0.0-alpha.4 2022-05-31 20:09:47 +08:00
chenjiahan
f13601cb9f Merge branch 'dev' into next 2022-05-31 20:05:10 +08:00
neverland
5cd731594f
feat: using mjs extension for esmodule (#10625) 2022-05-22 20:10:14 +08:00
chenjiahan
582582e480 Merge branch 'dev' into next 2022-05-22 19:59:35 +08:00
chenjiahan
fe2115ee5c docs(changelog): 4.0.0-alpha.3 2022-05-02 11:09:34 +08:00
chenjiahan
bc60f5116b release: 4.0.0-alpha.3 2022-05-02 11:07:49 +08:00
chenjiahan
b65396ef06 Merge branch 'dev' into next 2022-05-02 11:03:12 +08:00
Alan Wang
523d9ef400
fix(Search): style error in dark mode (#10527) 2022-04-23 09:58:09 +08:00
chenjiahan
912a5f17b1 docs(changelog): 4.0.0-alpha.2 2022-04-16 22:09:58 +08:00
chenjiahan
ea57c9e9ff release: 4.0.0-alpha.2 2022-04-16 22:08:38 +08:00
chenjiahan
ac7d6dd542 Merge branch 'dev' into next 2022-04-16 21:59:33 +08:00
chenjiahan
a0389defcc Merge branch 'dev' into next 2022-04-05 10:31:21 +08:00
chenjiahan
26cbffe6c1 chore: fix some Numeric type 2022-03-27 18:13:09 +08:00
chenjiahan
a541090f3a Merge branch 'dev' into next 2022-03-27 18:12:42 +08:00
chenjiahan
e08e9845a2 breaking change(AddressEdit): remove postal 2022-03-26 20:12:24 +08:00
chenjiahan
8e822a591d Merge branch 'dev' into next 2022-03-26 19:10:50 +08:00
chenjiahan
8e78b6d8ad Merge branch 'dev' into next 2022-03-23 09:11:13 +08:00
chenjiahan
5bff9e8c5f docs(changelog): 4.0.0-alpha.1 2022-03-19 20:08:46 +08:00
chenjiahan
475d108ccb release: 4.0.0-alpha.1 2022-03-19 20:06:05 +08:00
chenjiahan
527bad9cc2 Merge branch 'dev' into next 2022-03-19 20:04:31 +08:00
neverland
47a5151a20
docs(Picker): add v-model usage (#10417) 2022-03-19 20:02:56 +08:00
neverland
dd724fde4d
docs(DatePicker): fix formatter usage (#10416) 2022-03-19 19:51:03 +08:00
neverland
a584cc217b
fix(DatePicker): failed to update model value (#10415) 2022-03-19 19:48:28 +08:00
neverland
5b72c4005b
test: fix snapshots of cell (#10414) 2022-03-19 19:44:45 +08:00
neverland
d2f6a3c96f
fix(ConfigProvider): dark mode not work as default value (#10413) 2022-03-19 19:42:28 +08:00
TeRny
239be20cbf
fix(Calendar, Picker): Fix calendar and picker's title color in dark mode (#10403)
* 解决Dialog组件的标题、消息内容在深色模式下仍显示黑色的问题

* 解决Picker和Calendar组件的Title在深色模式下为黑色的问题

Co-authored-by: 朱坤 <zhukun.gz@chinatelecom.cn>
2022-03-17 20:34:45 +08:00
chenjiahan
101dcc3ef2 Merge branch 'dev' into next 2022-03-13 16:27:20 +08:00
TeRny
8572393881
fix(Dialog): Fix dialog title and message color in dark mode (#10379)
Co-authored-by: 朱坤 <zhukun.gz@chinatelecom.cn>
2022-03-11 14:56:39 +08:00
neverland
0d79eb244b
docs: update 4.0.0-alpha changelog (#10339) 2022-02-27 20:57:46 +08:00
chenjiahan
db2e6ca12f docs: fix publicPath 2022-02-21 13:39:21 +08:00
chenjiahan
992eea3eeb build: fix workflow name 2022-02-21 12:27:25 +08:00
chenjiahan
3a1e792e31 docs: update 2022-02-21 12:26:31 +08:00
chenjiahan
06199faf2c build: deploy v4 site 2022-02-21 12:22:46 +08:00
chenjiahan
c206642d2d release: 4.0.0-alpha.0 2022-02-21 12:13:17 +08:00
chenjiahan
5bade79394 chore: add npm tag 2022-02-21 12:11:18 +08:00
chenjiahan
2ceb68e691 docs: update Vant 4 2022-02-20 21:02:09 +08:00
chenjiahan
9cfef027aa docs(Form): fix Picker demo 2022-02-20 20:54:16 +08:00
chenjiahan
0b4b04eefb chore: fix Cell usage 2022-02-20 20:48:20 +08:00
chenjiahan
0a7b535533 style(Cell): remove value aline style 2022-02-20 20:47:01 +08:00
chenjiahan
17c2022a6f chore(AddressEdit): avoid using innerHTML 2022-02-20 20:36:04 +08:00
chenjiahan
cce3ceb5b6 style(TreeSelect): using primary color 2022-02-20 20:24:11 +08:00
chenjiahan
fcd91cb0b0 style(AddressList): using primary color 2022-02-20 20:22:49 +08:00
chenjiahan
3692014070 style(Card): blue tag 2022-02-20 20:19:27 +08:00
chenjiahan
85c5ad6718 style(CouponList): change default color 2022-02-20 20:17:05 +08:00
chenjiahan
bef919c7f0 style: increase font-weight bold 2022-02-20 10:04:39 +08:00
chenjiahan
d39f6a898a style(ContactList): using primary color 2022-02-18 14:22:25 +08:00
chenjiahan
43ae30026a style(ContactEdit): adjust submit button 2022-02-18 14:11:54 +08:00
chenjiahan
27c46b01ae types(AddressEdit): SearchItem optional 2022-02-18 11:36:55 +08:00
chenjiahan
3979ddc40a fix(AddressEdit): selectedOption maybe undefined 2022-02-17 16:35:07 +08:00
chenjiahan
967cb56c18 types(Picker): fix return type of getSelectedOptions 2022-02-17 16:25:53 +08:00
chenjiahan
c65d4f9672 style(AddressEdit): submit button using primary type 2022-02-17 16:16:55 +08:00
chenjiahan
73788f9e88 style(Switch): adjust width 2022-02-17 15:36:23 +08:00
chenjiahan
2acd47b5ee style(Switch): adjust style 2022-02-17 15:31:52 +08:00
chenjiahan
b3cf1dfb54 breaking change(AddressEdit): adjust change-area event params 2022-02-16 12:14:01 +08:00
chenjiahan
35a50012c7 feat(Area): add getSelectedOptions method 2022-02-16 12:02:46 +08:00
chenjiahan
83295e655d feat(Picker): add getSelectedOptions method 2022-02-16 12:00:32 +08:00
chenjiahan
e2790fe95d chore(DatePicker): reuse genOptions 2022-02-16 11:06:58 +08:00
chenjiahan
b608fb23f0 types(TimePicker): export TimePickerColumnType 2022-02-16 10:59:31 +08:00
chenjiahan
829db06d5b types(DatePicker): export DatePickerColumnType 2022-02-16 10:59:20 +08:00
chenjiahan
2e053ad76b feat(TimePicker): support select second 2022-02-16 10:57:09 +08:00
chenjiahan
c942efb76b docs(DatePicker): fix currentDate of year-month 2022-02-16 10:56:46 +08:00
chenjiahan
fdcf9931be refactor(TimePicker): modelValue now is string array 2022-02-15 17:44:53 +08:00
chenjiahan
e61bd487fa fix(Picker): should update modelValue immediately 2022-02-15 17:36:49 +08:00
chenjiahan
7deba88b91 docs(Form): fix demo 2022-02-15 16:08:31 +08:00
chenjiahan
980f976011 fix(DatePicker): allow modelValue to be empty 2022-02-15 15:55:09 +08:00
chenjiahan
c00fa4cd70 chore: remove legacy DatetimePicker 2022-02-15 15:54:24 +08:00
chenjiahan
ef8e66a924 refactor(DatePicker): v-model now is string array 2022-02-15 15:42:23 +08:00
chenjiahan
e8ffc80dc6 feat(DatePicker): date columns calculation 2022-02-15 15:08:59 +08:00
chenjiahan
3920ebe25b Merge branch 'dev' into next 2022-02-14 11:03:20 +08:00
chenjiahan
5b407566db refactor: DatePicker Component 2022-02-14 10:55:10 +08:00
chenjiahan
f327d5bbc2 test(TimePicker): migrate test cases 2022-02-10 19:48:18 +08:00
chenjiahan
2a8bb86fbb fix(Picker): should update selectedValues correctly 2022-02-10 19:41:19 +08:00
chenjiahan
7dae50b0c9 fix(TimePicker): should update modelValue immediately 2022-02-10 17:56:51 +08:00
chenjiahan
d68053ea7f docs: update migration guide 2022-02-10 16:50:20 +08:00
chenjiahan
8ca9741845 breaking change: event name become camelCase 2022-02-10 16:49:45 +08:00
chenjiahan
c9c312c4ba test: update all snapshots 2022-02-10 16:22:18 +08:00
chenjiahan
5dca6fe2e2 chore: remove unused snapshot 2022-02-10 16:20:34 +08:00
chenjiahan
fdc5436249 test(TimePicker): demo snapshot 2022-02-10 16:19:31 +08:00
chenjiahan
7d22cc2155 fix(TimePicker): remove columns-order prop 2022-02-10 15:57:57 +08:00
chenjiahan
42d1dd836c refactor: TimePicker component 2022-02-10 15:12:21 +08:00
chenjiahan
15e7461a93 docs: docsearch version v4 2022-02-09 16:35:58 +08:00
chenjiahan
0fdaf133bb Merge branch 'dev' into next 2022-02-09 16:31:47 +08:00
chenjiahan
d4584aafda docs: dark mode 2022-02-09 16:31:07 +08:00
chenjiahan
5b3c4f1546 style: update van doc background 2022-02-09 11:34:25 +08:00
chenjiahan
25302fb333 Merge branch 'dev' into next 2022-02-09 11:20:28 +08:00
chenjiahan
2f02f19cec Merge branch 'dev' into next 2022-02-08 14:56:38 +08:00
chenjiahan
82e0e454d0 style(CouponList): update field background color in dark mode 2022-01-28 10:15:46 +08:00
chenjiahan
650bdd2294 feat(ActionBar): update icon text color 2022-01-28 10:15:08 +08:00
chenjiahan
cb2d99c8cf style(Card): improve card mode style 2022-01-28 10:14:45 +08:00
chenjiahan
42f03fe1a2 style(GridItem): adust text color 2022-01-28 10:04:01 +08:00
chenjiahan
fc2847fdb4 style(Slider): improve dark mode color 2022-01-27 19:44:00 +08:00
chenjiahan
d6e80e8954 style(IndexBar): increase font weight of active index 2022-01-27 11:21:00 +08:00
chenjiahan
39b51d5dae style(Tabbar): adjust text color 2022-01-27 11:19:32 +08:00
chenjiahan
8e98e97449 style(Field): adjust label color 2022-01-27 11:07:02 +08:00
chenjiahan
f5c32c29f1 style(@vant/cli): improve mobile style in dark mode 2022-01-27 11:00:38 +08:00
chenjiahan
98b999d911 refactor: rename --van-background-light to --van-background-2 2022-01-27 10:35:57 +08:00
chenjiahan
0e8e3200a2 style(@vant/cli): improve demo style in dark mode 2022-01-26 17:05:47 +08:00
chenjiahan
73322fd310 feat: add dark mode basic variables 2022-01-26 16:00:16 +08:00
chenjiahan
97b074ad0c feat(ConfigProvider): dark theme class 2022-01-26 15:59:52 +08:00
chenjiahan
541458c41b refactor: attach css variables to body element 2022-01-26 15:58:48 +08:00
chenjiahan
df24a3b683 feat(@vant/cli): mobile site support dark mode 2022-01-26 15:57:28 +08:00
chenjiahan
966af9dd68 Merge branch 'dev' into next 2022-01-26 14:12:40 +08:00
chenjiahan
b6fcd32dcf style(@vant/cli): adjust css vars 2022-01-26 10:26:15 +08:00
chenjiahan
35a990ed65 feat(@vant/cli): desktop site support dark mode 2022-01-25 20:03:05 +08:00
chenjiahan
f9573402a7 feat(ConfigProvider): add theme prop 2022-01-25 15:38:57 +08:00
chenjiahan
437dcc6c41 Merge branch 'dev' into next 2022-01-25 14:42:56 +08:00
chenjiahan
5a15660c77 style(Steps): update default button border color 2022-01-24 16:58:56 +08:00
chenjiahan
0706d464b6 test(Area): update all test cases 2022-01-24 16:43:57 +08:00
chenjiahan
8d49b88748 fix(Area): allow to reset modelValue 2022-01-24 16:43:40 +08:00
chenjiahan
5900affe37 test(Picker): update cascade test cases 2022-01-24 16:09:08 +08:00
chenjiahan
bda3617d14 style(Button): adjust font-smoothing 2022-01-24 15:54:32 +08:00
chenjiahan
bd24288a12 style(Button): update default button border color 2022-01-24 15:37:49 +08:00
chenjiahan
3b10d66bb9 style(Tabs): using primary color by default 2022-01-24 15:19:46 +08:00
chenjiahan
41b1cd7185 style(Stepper): using primary color by default 2022-01-24 15:19:25 +08:00
chenjiahan
eeb233bf99 style(Sidebar): using primary color by default 2022-01-24 15:18:28 +08:00
chenjiahan
8b95db1574 style(IndexBar): using primary color by default 2022-01-24 15:17:50 +08:00
chenjiahan
37e7c618b8 style(DropdownMenu): using primary color by default 2022-01-24 15:17:33 +08:00
chenjiahan
84b90b1f4c style(Cascader): using primary color by default 2022-01-24 15:16:58 +08:00
chenjiahan
4e89e88845 style(Calendar): using primary color by default 2022-01-24 15:15:02 +08:00
chenjiahan
d867710cc9 style(Button): increase default border radius from 2px to 4px 2022-01-23 21:39:04 +08:00
chenjiahan
526f54595d chore: fix van-background-light var in demos 2022-01-21 17:19:21 +08:00
chenjiahan
3c3f58a7be Merge branch 'next' of github.com:youzan/vant into next 2022-01-21 16:52:51 +08:00
chenjiahan
e4ab2156f1 test(Picker): update basic test cases 2022-01-21 16:52:32 +08:00
chenjiahan
6bba2906bc chore(Area): adjust some codes 2022-01-21 16:52:32 +08:00
chenjiahan
95cf27745b chore: remove empty area.ts 2022-01-21 16:52:32 +08:00
chenjiahan
a9baa3b2d1 docs(Area): update documents 2022-01-21 16:52:32 +08:00
chenjiahan
0186219586 fix(Picker): error when options is empty 2022-01-21 16:52:32 +08:00
chenjiahan
cca428aac6 refactor: Area component 2022-01-21 16:52:32 +08:00
chenjiahan
113e1b7a62 fix(Picker): currentColumns calculation 2022-01-21 16:52:32 +08:00
chenjiahan
ff69fdacc7 fix(Picker): failed to update modelValue 2022-01-21 16:52:32 +08:00
chenjiahan
6c64bc33c1 types(Picker): fix columns prop typing 2022-01-21 16:52:32 +08:00
chenjiahan
fda3f1be94 docs(@vant/cli): changelog 4.0.0-rc.6 2022-01-21 16:52:32 +08:00
chenjiahan
e93ae7b430 release: @vant/cli 4.0.0-rc.6 2022-01-21 16:52:32 +08:00
zoy-l
4ee1a3d766 fix(vant-cli): pnpm compatibility (#10214)
* fix(vant-cli): pnpm compatibility

* chore: clean code, semantic naming
2022-01-21 16:52:32 +08:00
chenjiahan
cc10eb1f2a docs(Picker): new document 2022-01-21 16:52:32 +08:00
chenjiahan
d16075f39e fix(Picker): option.className not work 2022-01-21 16:52:32 +08:00
chenjiahan
f436b5ae09 docs: update migration guide 2022-01-21 16:52:32 +08:00
chenjiahan
ceaab349f1 docs(Picker): update demo 2022-01-21 16:52:32 +08:00
chenjiahan
22654bf518 fix(Picker): fix some bugs 2022-01-21 16:52:32 +08:00
chenjiahan
c061412138 refactor(Picker): rename item-height to option-height 2022-01-21 16:52:32 +08:00
chenjiahan
89b029aa42 refactor(Picker): data driven 2022-01-21 16:52:32 +08:00
chenjiahan
2c7bafe3c1 Merge branch 'dev' into next 2022-01-19 15:54:57 +08:00
chenjiahan
bcb7eabff3 Merge branch 'dev' into next 2022-01-17 19:48:33 +08:00
chenjiahan
e63f471c77 Merge branch 'dev' into next 2021-12-11 10:41:38 +08:00
chenjiahan
1fc72c68dd Merge branch 'dev' into next 2021-11-19 11:00:11 +08:00
chenjiahan
1bd2ab00ac Merge branch 'dev' into next 2021-11-15 10:59:04 +08:00
chenjiahan
e713e8eade Merge branch 'dev' into next 2021-11-10 15:31:33 +08:00
chenjiahan
26fa234026 Merge branch 'dev' into next 2021-11-04 20:21:28 +08:00
chenjiahan
6c24fa728e docs: update v4 migration guide 2021-11-04 17:48:37 +08:00
chenjiahan
0fedd1dbea Merge branch 'dev' into next 2021-11-04 11:26:29 +08:00
chenjiahan
722f73dfbe Merge branch 'dev' into next 2021-11-03 17:47:44 +08:00
chenjiahan
7d6916b946 breaking change: shorter css var names 2021-11-03 17:36:17 +08:00
chenjiahan
ada5db011c breaking change: no longer support less vars 2021-11-03 16:45:49 +08:00
chenjiahan
099141f6c5 breaking change(Tabs): remove click、disabled event 2021-11-03 16:05:37 +08:00
chenjiahan
6a4033b6bc breaking change(Picker): remove default slot、value-key prop 2021-11-03 16:03:15 +08:00
767 changed files with 21023 additions and 19265 deletions

View File

@ -1,4 +1,4 @@
name: Deploy V3 Site name: Deploy V4 Site
on: on:
push: push:
@ -15,7 +15,7 @@ jobs:
- name: Checkout 🛎️ - name: Checkout 🛎️
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
ref: 'dev' ref: 'next'
- name: Install pnpm - name: Install pnpm
run: npm i pnpm@7 -g run: npm i pnpm@7 -g
@ -36,4 +36,5 @@ jobs:
with: with:
branch: gh-pages branch: gh-pages
folder: packages/vant/site-dist folder: packages/vant/site-dist
target-folder: v4
clean: false clean: false

View File

@ -2,7 +2,9 @@ name: Sync to Gitee
on: on:
push: push:
branches: [dev, 2.x, gh-pages] branches: [dev, 2.x, 3.x, gh-pages]
workflow_dispatch:
jobs: jobs:
build: build:

View File

@ -1,6 +1,15 @@
name: CI name: CI
on: [push] on:
push:
branches:
- '**'
pull_request:
branches:
- dev
workflow_dispatch:
jobs: jobs:
lint: lint:

2
.npmrc
View File

@ -1 +1,3 @@
registry=https://registry.npmmirror.com/ registry=https://registry.npmmirror.com/
strict-peer-dependencies=false

View File

@ -67,10 +67,14 @@ pnpm add vant
```js ```js
import { createApp } from 'vue'; import { createApp } from 'vue';
// 1. Import the components you need
import { Button } from 'vant'; import { Button } from 'vant';
// 2. Import the components style
import 'vant/lib/index.css'; import 'vant/lib/index.css';
const app = createApp(); const app = createApp();
// 3. Register the components you need
app.use(Button); app.use(Button);
``` ```

View File

@ -71,10 +71,14 @@ pnpm add vant
```js ```js
import { createApp } from 'vue'; import { createApp } from 'vue';
// 1. 引入你需要的组件
import { Button } from 'vant'; import { Button } from 'vant';
// 2. 引入组件样式
import 'vant/lib/index.css'; import 'vant/lib/index.css';
const app = createApp(); const app = createApp();
// 3. 注册你需要的组件
app.use(Button); app.use(Button);
``` ```

View File

@ -14,14 +14,14 @@
"*.{ts,tsx,js,vue,less}": "prettier --write", "*.{ts,tsx,js,vue,less}": "prettier --write",
"*.{ts,tsx,js,vue}": "eslint --fix" "*.{ts,tsx,js,vue}": "eslint --fix"
}, },
"packageManager": "pnpm@7.1.6", "packageManager": "pnpm@7.11.0",
"devDependencies": { "devDependencies": {
"@vant/cli": "workspace:*", "@vant/cli": "workspace:*",
"@vant/eslint-config": "workspace:*", "@vant/eslint-config": "workspace:*",
"eslint": "^8.2.0", "eslint": "^8.23.0",
"husky": "^8.0.1", "husky": "^8.0.1",
"nano-staged": "^0.8.0", "nano-staged": "^0.8.0",
"prettier": "^2.5.0", "prettier": "^2.7.1",
"rimraf": "^3.0.2" "rimraf": "^3.0.2"
}, },
"pnpm": { "pnpm": {

View File

@ -32,15 +32,15 @@
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@types/fs-extra": "^9.0.13", "@types/fs-extra": "^9.0.13",
"@types/inquirer": "^8.1.3", "@types/inquirer": "^8.2.3",
"release-it": "^15.1.1", "release-it": "^15.4.1",
"typescript": "^4.7.4" "typescript": "^4.8.2"
}, },
"dependencies": { "dependencies": {
"consola": "^2.11.3", "consola": "^2.11.3",
"fast-glob": "^3.2.4", "fast-glob": "^3.2.11",
"fs-extra": "^10.0.0", "fs-extra": "^10.1.0",
"inquirer": "^8.0.0", "inquirer": "^8.2.4",
"picocolors": "^1.0.0" "picocolors": "^1.0.0"
}, },
"release-it": { "release-it": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@vant/area-data", "name": "@vant/area-data",
"version": "1.3.1", "version": "1.3.2",
"description": "Vant 省市区数据", "description": "Vant 省市区数据",
"main": "dist/index.cjs.js", "main": "dist/index.cjs.js",
"module": "dist/index.esm.mjs", "module": "dist/index.esm.mjs",
@ -36,9 +36,9 @@
"author": "chenjiahan", "author": "chenjiahan",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"esbuild": "^0.14.29", "esbuild": "^0.14.54",
"release-it": "^15.1.1", "release-it": "^15.4.1",
"typescript": "^4.7.4" "typescript": "^4.8.2"
}, },
"release-it": { "release-it": {
"git": { "git": {

View File

@ -1150,10 +1150,10 @@ export const areaList = {
232701: '漠河市', 232701: '漠河市',
232721: '呼玛县', 232721: '呼玛县',
232722: '塔河县', 232722: '塔河县',
232790: '松岭区', 232761: '加格达奇区',
232791: '呼中区', 232762: '松岭区',
232792: '加格达奇区', 232763: '新林区',
232793: '新林区', 232764: '呼中区',
310101: '黄浦区', 310101: '黄浦区',
310104: '徐汇区', 310104: '徐汇区',
310105: '长宁区', 310105: '长宁区',

View File

@ -31,6 +31,12 @@ yarn add stylelint@13 @vant/stylelint-config
现在会默认生成 WebStorm 所需的 web-types.json 文件到 `lib/web-types.json` 目录下。 现在会默认生成 WebStorm 所需的 web-types.json 文件到 `lib/web-types.json` 目录下。
## v4.0.4
`2022-07-02`
- 修复构建 sfc 文件的类型定义时报错的问题
## v4.0.3 ## v4.0.3
`2022-07-02` `2022-07-02`

View File

@ -1,6 +1,6 @@
{ {
"name": "@vant/cli", "name": "@vant/cli",
"version": "4.0.3", "version": "4.0.4",
"type": "module", "type": "module",
"main": "lib/index.js", "main": "lib/index.js",
"typings": "lib/index.d.ts", "typings": "lib/index.d.ts",
@ -39,56 +39,56 @@
"author": "chenjiahan", "author": "chenjiahan",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@jest/types": "^27.5.1",
"@types/fs-extra": "^9.0.13", "@types/fs-extra": "^9.0.13",
"@types/less": "^3.0.3", "@types/less": "^3.0.3",
"@types/markdown-it": "^12.2.3", "@types/markdown-it": "^12.2.3",
"@jest/types": "^27", "react": "^18.2.0",
"vue": "^3.2.27", "react-dom": "^18.2.0",
"react": "^18", "vue": "^3.2.38"
"react-dom": "^18"
}, },
"dependencies": { "dependencies": {
"@babel/core": "^7.16.0", "@babel/core": "^7.18.13",
"@babel/preset-typescript": "^7.16.0", "@babel/preset-typescript": "^7.18.6",
"@docsearch/css": "^3.0.0", "@docsearch/css": "^3.2.1",
"@docsearch/js": "^3.0.0", "@docsearch/js": "^3.2.1",
"@types/jest": "^27.0.3", "@types/jest": "^27.5.2",
"@vant/eslint-config": "^3.3.2", "@vant/eslint-config": "^3.5.0",
"@vant/touch-emulator": "^1.3.2", "@vant/touch-emulator": "^1.4.0",
"@vitejs/plugin-vue": "^3.0.1", "@vitejs/plugin-vue": "^3.0.3",
"@vitejs/plugin-vue-jsx": "^2.0.0", "@vitejs/plugin-vue-jsx": "^2.0.1",
"@vue/babel-plugin-jsx": "^1.1.1", "@vue/babel-plugin-jsx": "^1.1.1",
"autoprefixer": "^10.4.0", "autoprefixer": "^10.4.8",
"commander": "^9.3.0", "commander": "^9.4.0",
"consola": "^2.15.3", "consola": "^2.15.3",
"conventional-changelog": "^3.1.24", "conventional-changelog": "^3.1.25",
"esbuild": "^0.14.29", "esbuild": "^0.14.54",
"eslint": "^8.1.0", "eslint": "^8.23.0",
"execa": "^5.1.1", "execa": "^5.1.1",
"fast-glob": "^3.2.7", "fast-glob": "^3.2.11",
"fs-extra": "^10.0.0", "fs-extra": "^10.1.0",
"hash-sum": "^2.0.0", "hash-sum": "^2.0.0",
"highlight.js": "^11.3.1", "highlight.js": "^11.6.0",
"husky": "^8.0.1", "husky": "^8.0.1",
"jest": "^27.3.1", "jest": "^27.5.1",
"jest-canvas-mock": "^2.3.1", "jest-canvas-mock": "^2.4.0",
"jest-serializer-html": "^7.1.0", "jest-serializer-html": "^7.1.0",
"less": "^4.1.2", "less": "^4.1.3",
"markdown-it": "^12.2.0", "markdown-it": "^12.3.2",
"markdown-it-anchor": "^8.4.1", "markdown-it-anchor": "^8.6.4",
"nano-staged": "^0.8.0", "nano-staged": "^0.8.0",
"nanospinner": "^1.1.0", "nanospinner": "^1.1.0",
"picocolors": "^1.0.0", "picocolors": "^1.0.0",
"postcss": "^8.3.11", "postcss": "^8.4.16",
"postcss-load-config": "^3.1.0", "postcss-load-config": "^3.1.4",
"prettier": "^2.5.0", "prettier": "^2.7.1",
"release-it": "^15.1.1", "release-it": "^15.4.1",
"transliteration": "^2.2.0", "transliteration": "^2.3.5",
"typescript": "^4.7.4", "typescript": "^4.8.2",
"vite": "^3.0.0", "vite": "^3.0.9",
"vite-plugin-html": "^2.1.1", "vite-plugin-html": "^2.1.2",
"vite-plugin-md": "^0.11.4", "vite-plugin-md": "^0.11.9",
"vue-router": "^4.0.12" "vue-router": "^4.1.5"
}, },
"release-it": { "release-it": {
"git": { "git": {

View File

@ -1,7 +1,4 @@
/** import { ref } from 'vue';
* 同步父窗口和 iframe vue-router 状态
*/
import { config } from 'site-desktop-shared'; import { config } from 'site-desktop-shared';
let queue = []; let queue = [];
@ -62,6 +59,49 @@ export function syncPathToChild() {
} }
} }
export function syncThemeToChild(theme) {
const iframe = document.querySelector('iframe');
if (iframe) {
iframeReady(() => {
iframe.contentWindow.postMessage(
{
type: 'updateTheme',
value: theme,
},
'*'
);
});
}
}
export function getDefaultTheme() {
const cache = window.localStorage.getItem('vantTheme');
if (cache) {
return cache;
}
const useDark =
window.matchMedia &&
window.matchMedia('(prefers-color-scheme: dark)').matches;
return useDark ? 'dark' : 'light';
}
export function useCurrentTheme() {
const theme = ref(getDefaultTheme());
window.addEventListener('message', (event) => {
if (event.data?.type !== 'updateTheme') {
return;
}
const newTheme = event.data?.value || '';
theme.value = newTheme;
});
return theme;
}
export function listenToSyncPath(router) { export function listenToSyncPath(router) {
window.addEventListener('message', (event) => { window.addEventListener('message', (event) => {
if (event.data?.type !== 'replacePath') { if (event.data?.type !== 'replacePath') {

View File

@ -1,15 +1,15 @@
@import './var'; @import './vars.less';
body { body {
min-width: 1100px; min-width: 1100px;
margin: 0; margin: 0;
overflow-x: auto; overflow-x: auto;
color: @van-doc-black; color: var(--van-doc-text-color-2);
font-size: 16px; font-size: 16px;
font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Helvetica Neue',
Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'miui',
'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif;
background-color: @van-doc-background-color; background-color: var(--van-doc-background);
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
} }
@ -41,8 +41,8 @@ a {
.van-doc-row { .van-doc-row {
width: 100%; width: 100%;
@media (min-width: @van-doc-row-max-width) { @media (min-width: var(--van-doc-row-max-width)) {
width: @van-doc-row-max-width; width: var(--van-doc-row-max-width);
margin: 0 auto; margin: 0 auto;
} }
} }

View File

@ -1,20 +1,18 @@
@import './var';
code { code {
position: relative; position: relative;
display: block; display: block;
padding: 16px 20px; padding: 16px 20px;
overflow-x: auto; overflow-x: auto;
color: @van-doc-code-color; color: var(--van-doc-code-color);
font-weight: 400; font-weight: 400;
font-size: 14px; font-size: 14px;
font-family: @van-doc-code-font-family; font-family: 'Source Code Pro', 'Monaco', 'Inconsolata', monospace;
line-height: 26px; line-height: 26px;
white-space: pre-wrap; white-space: pre-wrap;
word-wrap: break-word; word-wrap: break-word;
-webkit-font-smoothing: auto; -webkit-font-smoothing: auto;
background-color: #f8f8f8; background-color: var(--van-doc-code-background);
border-radius: @van-doc-border-radius; border-radius: var(--van-doc-border-radius);
} }
pre { pre {
@ -33,7 +31,7 @@ pre {
} }
.hljs-subst { .hljs-subst {
color: @van-doc-code-color; color: var(--van-doc-code-color);
} }
.hljs-string, .hljs-string,
@ -42,18 +40,18 @@ pre {
.hljs-template-tag, .hljs-template-tag,
.hljs-template-variable, .hljs-template-variable,
.hljs-addition { .hljs-addition {
color: @van-doc-green; color: var(--van-doc-green);
} }
.hljs-comment, .hljs-comment,
.hljs-quote { .hljs-quote {
color: #999; color: var(--van-doc-code-comment-color);
} }
.hljs-params, .hljs-params,
.hljs-keyword, .hljs-keyword,
.hljs-attribute { .hljs-attribute {
color: @van-doc-purple; color: var(--van-doc-purple);
} }
.hljs-deletion, .hljs-deletion,

View File

@ -1,27 +0,0 @@
@van-doc-black: #323233;
@van-doc-blue: #1989fa;
@van-doc-purple: #8080ff;
@van-doc-fuchsia: #a7419e;
@van-doc-green: #4fc08d;
@van-doc-text-color: #34495e;
@van-doc-text-light-blue: rgba(69, 90, 100, 0.6);
@van-doc-background-color: #f7f8fa;
@van-doc-grey: #999;
@van-doc-dark-grey: #666;
@van-doc-light-grey: #ccc;
@van-doc-border-color: #f1f4f8;
@van-doc-code-color: #58727e;
@van-doc-code-background-color: #f1f4f8;
@van-doc-code-font-family: 'Source Code Pro', 'Monaco', 'Inconsolata', monospace;
@van-doc-padding: 24px;
@van-doc-row-max-width: 1680px;
@van-doc-nav-width: 220px;
@van-doc-border-radius: 20px;
// header
@van-doc-header-top-height: 64px;
@van-doc-header-bottom-height: 50px;
// simulator
@van-doc-simulator-width: 360px;
@van-doc-simulator-height: 620px;

View File

@ -0,0 +1,74 @@
body {
// colors
--van-doc-black: #000;
--van-doc-white: #fff;
--van-doc-gray-1: #f7f8fa;
--van-doc-gray-2: #f2f3f5;
--van-doc-gray-3: #ebedf0;
--van-doc-gray-4: #dcdee0;
--van-doc-gray-5: #c8c9cc;
--van-doc-gray-6: #969799;
--van-doc-gray-7: #646566;
--van-doc-gray-8: #323233;
--van-doc-blue: #1989fa;
--van-doc-green: #07c160;
// sizes
--van-doc-padding: 24px;
--van-doc-row-max-width: 1680px;
--van-doc-nav-width: 220px;
--van-doc-border-radius: 20px;
--van-doc-simulator-width: 360px;
--van-doc-simulator-height: 620px;
--van-doc-header-top-height: 64px;
}
.van-doc-theme-light {
// text
--van-doc-text-color-1: var(--van-doc-black);
--van-doc-text-color-2: var(--van-doc-gray-8);
--van-doc-text-color-3: #34495e;
--van-doc-text-color-4: var(--van-doc-gray-6);
--van-doc-link-color: var(--van-doc-blue);
// background
--van-doc-background: #eff2f5;
--van-doc-background-2: var(--van-doc-white);
--van-doc-background-3: var(--van-doc-white);
--van-doc-header-background: #011f3c;
--van-doc-border-color: var(--van-doc-gray-2);
// code
--van-doc-code-color: #58727e;
--van-doc-code-comment-color: var(--van-doc-gray-6);
--van-doc-code-background: var(--van-doc-gray-1);
// blockquote
--van-doc-blockquote-color: #4994df;
--van-doc-blockquote-background: #ecf9ff;
}
.van-doc-theme-dark {
// text
--van-doc-text-color-1: var(--van-doc-white);
--van-doc-text-color-2: rgba(255, 255, 255, 0.9);
--van-doc-text-color-3: rgba(255, 255, 255, 0.75);
--van-doc-text-color-4: rgba(255, 255, 255, 0.6);
--van-doc-link-color: #1bb5fe;
// background
--van-doc-background: #202124;
--van-doc-background-2: rgba(255, 255, 255, 0.06);
--van-doc-background-3: rgba(255, 255, 255, 0.1);
--van-doc-header-background: rgba(1, 31, 60, 0.3);
--van-doc-border-color: #3a3a3c;
// code
--van-doc-code-color: rgba(200, 200, 200, 0.85);
--van-doc-code-comment-color: var(--van-doc-gray-7);
--van-doc-code-background: rgba(0, 0, 0, 0.24);
// blockquote
--van-doc-blockquote-color: #bae6fd;
--van-doc-blockquote-background: rgba(7, 89, 133, 0.25);
}

View File

@ -8,6 +8,7 @@
:simulator="simulator" :simulator="simulator"
:has-simulator="hasSimulator" :has-simulator="hasSimulator"
:lang-configs="langConfigs" :lang-configs="langConfigs"
:dark-mode-class="darkModeClass"
> >
<router-view /> <router-view />
</van-doc> </van-doc>
@ -27,6 +28,7 @@ export default {
data() { data() {
return { return {
hasSimulator: true, hasSimulator: true,
darkModeClass: config.site.darkModeClass,
}; };
}, },
@ -70,18 +72,18 @@ export default {
watch: { watch: {
// eslint-disable-next-line // eslint-disable-next-line
'$route.path'() { '$route.path'() {
this.setTitleAndToogleSimulator(); this.setTitleAndToggleSimulator();
}, },
lang(val) { lang(val) {
setLang(val); setLang(val);
this.setTitleAndToogleSimulator(); this.setTitleAndToggleSimulator();
}, },
config: { config: {
handler(val) { handler(val) {
if (val) { if (val) {
this.setTitleAndToogleSimulator(); this.setTitleAndToggleSimulator();
} }
}, },
immediate: true, immediate: true,
@ -100,7 +102,7 @@ export default {
}, },
methods: { methods: {
setTitleAndToogleSimulator() { setTitleAndToggleSimulator() {
let { title } = this.config; let { title } = this.config;
const navItems = this.config.nav.reduce( const navItems = this.config.nav.reduce(

View File

@ -18,18 +18,18 @@ export default {
</script> </script>
<style lang="less"> <style lang="less">
@import '../../common/style/var';
.van-doc-container { .van-doc-container {
box-sizing: border-box; box-sizing: border-box;
padding-left: @van-doc-nav-width; padding-left: var(--van-doc-nav-width);
overflow: hidden; overflow: hidden;
&--with-simulator { &--with-simulator {
padding-right: @van-doc-simulator-width + @van-doc-padding; padding-right: calc(
var(--van-doc-simulator-width) + var(--van-doc-padding)
);
@media (max-width: 1100px) { @media (max-width: 1100px) {
padding-right: @van-doc-simulator-width - 8px; padding-right: calc(var(--van-doc-simulator-width) - 8px);
} }
} }
} }

View File

@ -82,14 +82,12 @@ export default {
</script> </script>
<style lang="less"> <style lang="less">
@import '../../common/style/var';
.van-doc-card { .van-doc-card {
margin-bottom: 24px; margin-bottom: 24px;
padding: 24px; padding: 24px;
background-color: #fff; background-color: var(--van-doc-background-2);
border-radius: @van-doc-border-radius; border-radius: var(--van-doc-border-radius);
box-shadow: 0 8px 12px #ebedf0; overflow: auto;
> pre code { > pre code {
position: relative; position: relative;
@ -144,15 +142,15 @@ export default {
> table a, > table a,
> blockquote a { > blockquote a {
margin: 0 1px; margin: 0 1px;
color: @van-doc-blue; color: var(--van-doc-link-color);
-webkit-font-smoothing: auto; -webkit-font-smoothing: auto;
&:hover { &:hover {
color: darken(@van-doc-blue, 10%); opacity: 0.8;
} }
&:active { &:active {
color: darken(@van-doc-blue, 20%); opacity: 0.6;
} }
} }
@ -160,7 +158,6 @@ export default {
> h4, > h4,
> h5, > h5,
> h6 { > h6 {
color: @van-doc-black;
font-weight: normal; font-weight: normal;
line-height: 1.6; line-height: 1.6;
@ -189,23 +186,19 @@ export default {
> p { > p {
margin-top: 8px; margin-top: 8px;
} color: var(--van-doc-text-color-3);
> p,
> blockquote p {
color: @van-doc-text-color;
font-size: 15px; font-size: 15px;
line-height: 26px; line-height: 26px;
strong { strong {
color: black; color: var(--van-doc-text-color-1);
} }
} }
> table { > table {
width: 100%; width: 100%;
margin-top: 12px; margin-top: 12px;
color: @van-doc-text-color; color: var(--van-doc-text-color-3);
font-size: 14px; font-size: 14px;
line-height: 1.5; line-height: 1.5;
border-collapse: collapse; border-collapse: collapse;
@ -226,7 +219,7 @@ export default {
td { td {
padding: 8px; padding: 8px;
border-top: 1px solid @van-doc-code-background-color; border-top: 1px solid var(--van-doc-border-color);
&:first-child { &:first-child {
padding-left: 0; padding-left: 0;
@ -235,10 +228,10 @@ export default {
code { code {
margin: 0; margin: 0;
padding: 2px 6px; padding: 2px 6px;
color: @van-doc-blue; color: var(--van-doc-blue);
font-weight: 600; font-weight: 600;
font-size: 11px; font-size: 11px;
background-color: fade(@van-doc-blue, 10%); background-color: rgba(25, 137, 250, 0.15);
border-radius: 20px; border-radius: 20px;
} }
} }
@ -250,9 +243,9 @@ export default {
em { em {
display: inline-block; display: inline-block;
color: @van-doc-green; color: var(--van-doc-green);
font-size: 14px; font-size: 14px;
font-family: @van-doc-code-font-family; font-family: 'Source Code Pro', 'Monaco', 'Inconsolata', monospace;
font-style: normal; font-style: normal;
max-width: 300px; max-width: 300px;
-webkit-font-smoothing: auto; -webkit-font-smoothing: auto;
@ -268,7 +261,7 @@ export default {
position: relative; position: relative;
margin: 5px 0 5px 10px; margin: 5px 0 5px 10px;
padding-left: 15px; padding-left: 15px;
color: @van-doc-text-color; color: var(--van-doc-text-color-3);
font-size: 15px; font-size: 15px;
line-height: 26px; line-height: 26px;
@ -280,7 +273,7 @@ export default {
width: 6px; width: 6px;
height: 6px; height: 6px;
margin-top: 10px; margin-top: 10px;
border: 1px solid @van-doc-dark-grey; border: 1px solid currentColor;
border-radius: 50%; border-radius: 50%;
content: ''; content: '';
} }
@ -310,15 +303,17 @@ export default {
> blockquote { > blockquote {
margin: 16px 0 0; margin: 16px 0 0;
padding: 16px; padding: 16px;
background-color: #ecf9ff; font-size: 14px;
border-radius: @van-doc-border-radius; color: var(--van-doc-blockquote-color);
background-color: var(--van-doc-blockquote-background);
border-radius: var(--van-doc-border-radius);
} }
> img, > img,
> p img { > p img {
width: 100%; width: 100%;
margin: 16px 0; margin: 16px 0;
border-radius: @van-doc-border-radius; border-radius: var(--van-doc-border-radius);
} }
} }
@ -333,7 +328,6 @@ export default {
h1, h1,
h2 { h2 {
color: @van-doc-black;
font-weight: normal; font-weight: normal;
line-height: 1.5; line-height: 1.5;

View File

@ -24,6 +24,16 @@
</a> </a>
</li> </li>
<li v-if="darkModeClass" class="van-doc-header__top-nav-item">
<a
class="van-doc-header__link"
target="_blank"
@click="toggleTheme"
>
<img :src="themeImg" />
</a>
</li>
<li <li
ref="version" ref="version"
v-if="versions" v-if="versions"
@ -69,6 +79,7 @@
<script> <script>
import SearchInput from './SearchInput.vue'; import SearchInput from './SearchInput.vue';
import { packageVersion } from 'site-desktop-shared'; import { packageVersion } from 'site-desktop-shared';
import { getDefaultTheme, syncThemeToChild } from '../../common/iframe-sync';
export default { export default {
name: 'VanDocHeader', name: 'VanDocHeader',
@ -82,10 +93,12 @@ export default {
config: Object, config: Object,
versions: Array, versions: Array,
langConfigs: Array, langConfigs: Array,
darkModeClass: String,
}, },
data() { data() {
return { return {
currentTheme: getDefaultTheme(),
packageVersion, packageVersion,
showVersionPop: false, showVersionPop: false,
}; };
@ -112,9 +125,32 @@ export default {
searchConfig() { searchConfig() {
return this.config.searchConfig; return this.config.searchConfig;
}, },
themeImg() {
if (this.currentTheme === 'light') {
return 'https://b.yzcdn.cn/vant/dark-theme.svg';
}
return 'https://b.yzcdn.cn/vant/light-theme.svg';
},
},
watch: {
currentTheme: {
handler(newVal, oldVal) {
window.localStorage.setItem('vantTheme', newVal);
document.body.classList.remove(`van-doc-theme-${oldVal}`);
document.body.classList.add(`van-doc-theme-${newVal}`);
syncThemeToChild(newVal);
},
immediate: true,
},
}, },
methods: { methods: {
toggleTheme() {
this.currentTheme = this.currentTheme === 'light' ? 'dark' : 'light';
},
toggleVersionPop() { toggleVersionPop() {
const val = !this.showVersionPop; const val = !this.showVersionPop;
@ -147,18 +183,16 @@ export default {
</script> </script>
<style lang="less"> <style lang="less">
@import '../../common/style/var';
.van-doc-header { .van-doc-header {
width: 100%; width: 100%;
background-color: #001938; background-color: var(--van-doc-header-background);
user-select: none; user-select: none;
&__top { &__top {
display: flex; display: flex;
align-items: center; align-items: center;
height: @van-doc-header-top-height; height: var(--van-doc-header-top-height);
padding: 0 @van-doc-padding; padding: 0 var(--van-doc-padding);
&-nav { &-nav {
flex: 1; flex: 1;
@ -234,7 +268,7 @@ export default {
transition: 0.2s; transition: 0.2s;
&:hover { &:hover {
color: @van-doc-blue; color: var(--van-doc-link-color);
background-color: #f7f8fa; background-color: #f7f8fa;
} }
} }
@ -268,6 +302,8 @@ export default {
} }
&__link { &__link {
cursor: pointer;
span { span {
color: #fff; color: #fff;
font-size: 16px; font-size: 16px;

View File

@ -71,22 +71,19 @@ export default {
</script> </script>
<style lang="less"> <style lang="less">
@import '../../common/style/var';
.van-doc-nav { .van-doc-nav {
position: fixed; position: fixed;
left: 0; left: 0;
z-index: 1; z-index: 1;
min-width: @van-doc-nav-width; min-width: var(--van-doc-nav-width);
max-width: @van-doc-nav-width; max-width: var(--van-doc-nav-width);
padding: @van-doc-padding 0; padding: 8px 0;
overflow-y: scroll; overflow-y: scroll;
background-color: #fff; background-color: var(--van-doc-background-2);
box-shadow: 0 8px 12px #ebedf0;
@media (min-width: @van-doc-row-max-width) { @media (min-width: var(--van-doc-row-max-width)) {
left: 50%; left: 50%;
margin-left: -(@van-doc-row-max-width / 2); margin-left: calc((var(--van-doc-row-max-width) / 2 * -1));
} }
&::-webkit-scrollbar { &::-webkit-scrollbar {
@ -110,8 +107,8 @@ export default {
} }
&__title { &__title {
padding: 8px 0 8px @van-doc-padding; padding: 24px 0 0 var(--van-doc-padding);
color: #455a64; color: var(--van-doc-text-color-2);
font-weight: 600; font-weight: 600;
font-size: 15px; font-size: 15px;
line-height: 28px; line-height: 28px;
@ -121,21 +118,19 @@ export default {
a { a {
display: block; display: block;
margin: 8px 0; margin: 8px 0;
padding: 8px 0 8px @van-doc-padding; padding: 6px 0 6px var(--van-doc-padding);
color: #455a64; color: var(--van-doc-text-color-3);
font-size: 14px; font-size: 14px;
line-height: 20px; line-height: 20px;
transition: color 0.2s; transition: color 0.2s;
&:hover, &:hover,
&.active { &.active {
color: @van-doc-green; color: var(--van-doc-link-color);
} }
&.active { &.active {
font-weight: 600; font-weight: 600;
background-color: #ebfff0;
border-radius: 999px;
} }
span { span {

View File

@ -38,8 +38,6 @@ export default {
</script> </script>
<style lang="less"> <style lang="less">
@import '../../common/style/var';
#docsearch { #docsearch {
display: inline-block; display: inline-block;
vertical-align: middle; vertical-align: middle;

View File

@ -44,34 +44,31 @@ export default {
</script> </script>
<style lang="less"> <style lang="less">
@import '../../common/style/var';
.van-doc-simulator { .van-doc-simulator {
position: absolute; position: absolute;
top: @van-doc-padding + @van-doc-header-top-height; top: calc(var(--van-doc-padding) + var(--van-doc-header-top-height));
right: @van-doc-padding; right: var(--van-doc-padding);
z-index: 1; z-index: 1;
box-sizing: border-box; box-sizing: border-box;
width: @van-doc-simulator-width; width: var(--van-doc-simulator-width);
min-width: @van-doc-simulator-width; min-width: var(--van-doc-simulator-width);
overflow: hidden; overflow: hidden;
background: #fafafa; background: var(--van-doc-background-2);
border-radius: @van-doc-border-radius; border-radius: var(--van-doc-border-radius);
box-shadow: 0 8px 12px #ebedf0;
@media (max-width: 1100px) { @media (max-width: 1100px) {
right: auto; right: auto;
left: 750px; left: 750px;
} }
@media (min-width: @van-doc-row-max-width) { @media (min-width: var(--van-doc-row-max-width)) {
right: 50%; right: 50%;
margin-right: -(@van-doc-row-max-width / 2) + 24px; margin-right: calc(var(--van-doc-row-max-width) / 2 * -1 + 24px);
} }
&-fixed { &-fixed {
position: fixed; position: fixed;
top: @van-doc-padding; top: var(--van-doc-padding);
} }
iframe { iframe {

View File

@ -5,6 +5,7 @@
:config="config" :config="config"
:versions="versions" :versions="versions"
:lang-configs="langConfigs" :lang-configs="langConfigs"
:dark-mode-class="darkModeClass"
@switch-version="$emit('switch-version', $event)" @switch-version="$emit('switch-version', $event)"
/> />
<doc-nav :lang="lang" :nav-config="config.nav" /> <doc-nav :lang="lang" :nav-config="config.nav" />
@ -39,8 +40,9 @@ export default {
lang: String, lang: String,
versions: Array, versions: Array,
simulator: String, simulator: String,
hasSimulator: Boolean,
langConfigs: Array, langConfigs: Array,
hasSimulator: Boolean,
darkModeClass: String,
config: { config: {
type: Object, type: Object,
required: true, required: true,
@ -108,7 +110,3 @@ export default {
}, },
}; };
</script> </script>
<style lang="less">
@import '../../common/style/var';
</style>

View File

@ -3,7 +3,7 @@ import { createRouter, createWebHashHistory } from 'vue-router';
import { isMobile, decamelize } from '../common'; import { isMobile, decamelize } from '../common';
import { config, documents } from 'site-desktop-shared'; import { config, documents } from 'site-desktop-shared';
import { getLang, setDefaultLang } from '../common/locales'; import { getLang, setDefaultLang } from '../common/locales';
import { listenToSyncPath, syncPathToChild } from '../common/iframe-router'; import { listenToSyncPath, syncPathToChild } from '../common/iframe-sync';
if (isMobile) { if (isMobile) {
location.replace('mobile.html' + location.hash); location.replace('mobile.html' + location.hash);

View File

@ -30,7 +30,7 @@
</script> </script>
<% } %> <% } %>
</head> </head>
<body ontouchstart> <body>
<div id="app"></div> <div id="app"></div>
<script type="module" src="/desktop/main.js"></script> <script type="module" src="/desktop/main.js"></script>
</body> </body>

View File

@ -39,7 +39,7 @@
</script> </script>
<% } %> <% } %>
</head> </head>
<body ontouchstart> <body>
<div id="app"></div> <div id="app"></div>
<script type="module" src="/mobile/main.js"></script> <script type="module" src="/mobile/main.js"></script>
</body> </body>

View File

@ -10,21 +10,49 @@
</template> </template>
<script> <script>
import { watch } from 'vue';
import DemoNav from './components/DemoNav.vue'; import DemoNav from './components/DemoNav.vue';
import { useCurrentTheme } from '../common/iframe-sync';
import { config } from 'site-mobile-shared';
export default { export default {
components: { DemoNav }, components: { DemoNav },
setup() {
const theme = useCurrentTheme();
watch(
theme,
(newVal, oldVal) => {
document.body.classList.remove(`van-doc-theme-${oldVal}`);
document.body.classList.add(`van-doc-theme-${newVal}`);
const { darkModeClass } = config.site;
if (darkModeClass) {
document.body.classList.toggle(darkModeClass, newVal === 'dark');
}
},
{ immediate: true }
);
},
}; };
</script> </script>
<style lang="less"> <style lang="less">
@import '../common/style/var';
@import '../common/style/base'; @import '../common/style/base';
body { body {
min-width: 100vw; min-width: 100vw;
} }
.van-doc-theme-light {
background-color: var(--van-doc-gray-1);
}
.van-doc-theme-dark {
background-color: var(--van-doc-black);
}
::-webkit-scrollbar { ::-webkit-scrollbar {
width: 0; width: 0;
background: transparent; background: transparent;

View File

@ -20,13 +20,11 @@ export default {
</script> </script>
<style lang="less"> <style lang="less">
@import '../../common/style/var';
.van-doc-demo-block { .van-doc-demo-block {
&__title { &__title {
margin: 0; margin: 0;
padding: 32px 16px 16px; padding: 32px 16px 16px;
color: @van-doc-text-light-blue; color: var(--van-doc-text-color-4);
font-weight: normal; font-weight: normal;
font-size: 14px; font-size: 14px;
line-height: 16px; line-height: 16px;

View File

@ -52,14 +52,11 @@ export default {
</script> </script>
<style lang="less"> <style lang="less">
@import '../../common/style/var';
.demo-home { .demo-home {
box-sizing: border-box; box-sizing: border-box;
width: 100%; width: 100%;
min-height: 100vh; min-height: 100vh;
padding: 46px 20px 20px; padding: 46px 20px 20px;
background: #fff;
&__title, &__title,
&__desc { &__desc {
@ -94,7 +91,7 @@ export default {
&__desc { &__desc {
margin: 0 0 40px; margin: 0 0 40px;
color: rgba(69, 90, 100, 0.6); color: var(--van-doc-text-color-4);
font-size: 14px; font-size: 14px;
} }
} }

View File

@ -43,12 +43,10 @@ export default {
</script> </script>
<style lang="less"> <style lang="less">
@import '../../common/style/var';
.demo-home-nav { .demo-home-nav {
&__title { &__title {
margin: 24px 0 8px 16px; margin: 24px 0 8px 16px;
color: rgba(69, 90, 100, 0.6); color: var(--van-doc-text-color-4);
font-size: 14px; font-size: 14px;
} }
@ -57,20 +55,20 @@ export default {
display: flex; display: flex;
margin: 0 0 12px; margin: 0 0 12px;
padding-left: 20px; padding-left: 20px;
color: #323233; color: var(--van-doc-text-color-3);
font-weight: 600; font-weight: 600;
font-size: 14px; font-size: 14px;
line-height: 40px; line-height: 40px;
background: #f7f8fa; background-color: var(--van-doc-background-3);
border-radius: 99px; border-radius: 99px;
transition: background 0.3s; transition: opacity 0.3s;
&:hover { &:hover {
background: darken(#f7f8fa, 3%); opacity: 0.8;
} }
&:active { &:active {
background: darken(#f7f8fa, 6%); opacity: 0.6;
} }
} }

View File

@ -42,7 +42,7 @@ export default {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
height: 56px; height: 56px;
background-color: #fff; background-color: var(--van-doc-background-3);
&__title { &__title {
font-weight: 600; font-weight: 600;

View File

@ -13,3 +13,8 @@ window.app = createApp(App)
setTimeout(() => { setTimeout(() => {
window.app.mount('#app'); window.app.mount('#app');
}, 0); }, 0);
// https://stackoverflow.com/questions/3885018/active-pseudo-class-doesnt-work-in-mobile-safari/33681490#33681490
document.addEventListener('touchstart', () => {}, {
passive: true,
});

View File

@ -4,7 +4,7 @@ import DemoHome from './components/DemoHome.vue';
import { decamelize } from '../common'; import { decamelize } from '../common';
import { demos, config } from 'site-mobile-shared'; import { demos, config } from 'site-mobile-shared';
import { getLang, setDefaultLang } from '../common/locales'; import { getLang, setDefaultLang } from '../common/locales';
import { listenToSyncPath, syncPathToParent } from '../common/iframe-router'; import { listenToSyncPath, syncPathToParent } from '../common/iframe-sync';
const { locales, defaultLang } = config.site; const { locales, defaultLang } = config.site;

View File

@ -12,7 +12,7 @@ import { compileBundles } from '../compiler/compile-bundles.js';
import { genPackageEntry } from '../compiler/gen-package-entry.js'; import { genPackageEntry } from '../compiler/gen-package-entry.js';
import { genStyleDepsMap } from '../compiler/gen-style-deps-map.js'; import { genStyleDepsMap } from '../compiler/gen-style-deps-map.js';
import { genComponentStyle } from '../compiler/gen-component-style.js'; import { genComponentStyle } from '../compiler/gen-component-style.js';
import { SRC_DIR, LIB_DIR, ES_DIR } from '../common/constant.js'; import { SRC_DIR, LIB_DIR, ES_DIR, getVantConfig } from '../common/constant.js';
import { genPackageStyle } from '../compiler/gen-package-style.js'; import { genPackageStyle } from '../compiler/gen-package-style.js';
import { genWebStormTypes } from '../compiler/web-types/index.js'; import { genWebStormTypes } from '../compiler/web-types/index.js';
import { import {
@ -135,9 +135,10 @@ async function buildPackageStyleEntry() {
} }
async function buildBundledOutputs() { async function buildBundledOutputs() {
const config = getVantConfig();
setModuleEnv('esmodule'); setModuleEnv('esmodule');
await compileBundles(); await compileBundles();
genWebStormTypes(); genWebStormTypes(config.build?.tagPrefix);
} }
const tasks = [ const tasks = [

View File

@ -87,11 +87,6 @@ export async function compileSfc(filePath: string): Promise<any> {
new Promise((resolve) => { new Promise((resolve) => {
let script = ''; let script = '';
// the generated render fn lacks type definitions
if (lang === 'ts') {
script += '// @ts-nocheck\n';
}
let bindingMetadata; let bindingMetadata;
if (descriptor.scriptSetup) { if (descriptor.scriptSetup) {
const { bindings, content } = compileScript(descriptor, { const { bindings, content } = compileScript(descriptor, {
@ -125,6 +120,12 @@ export async function compileSfc(filePath: string): Promise<any> {
script += `\n${EXPORT} ${VUEIDS}`; script += `\n${EXPORT} ${VUEIDS}`;
// ts-nocheck should be placed on the first line
// the generated render fn lacks type definitions
if (lang === 'ts') {
script = '// @ts-nocheck\n' + script;
}
outputFile(scriptFilePath, script).then(resolve); outputFile(scriptFilePath, script).then(resolve);
}) })
); );

View File

@ -40,7 +40,7 @@ export async function parseAndWrite(options: Options) {
); );
} }
export function genWebStormTypes() { export function genWebStormTypes(tagPrefix?: string) {
const pkgJson = getPackageJson(); const pkgJson = getPackageJson();
const vantConfig = getVantConfig(); const vantConfig = getVantConfig();
@ -50,5 +50,6 @@ export function genWebStormTypes() {
test: /README\.md/, test: /README\.md/,
version: pkgJson.version, version: pkgJson.version,
outputDir: LIB_DIR, outputDir: LIB_DIR,
tagPrefix,
}); });
} }

View File

@ -14,12 +14,19 @@ export function getViteConfigForPackage({
const { name, build } = getVantConfig(); const { name, build } = getVantConfig();
const entryExtension = build?.extensions?.esm || '.js'; const entryExtension = build?.extensions?.esm || '.js';
const entry = join(ES_DIR, `index${entryExtension}`); const entry = join(ES_DIR, `index${entryExtension}`);
const shouldReplaceEnv = minify || formats?.includes('umd');
return { return {
root: CWD, root: CWD,
logLevel: 'silent', logLevel: 'silent',
define: shouldReplaceEnv
? {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}
: undefined,
build: { build: {
lib: { lib: {
name, name,
@ -30,6 +37,7 @@ export function getViteConfigForPackage({
return minify ? `${name}${suffix}.min.js` : `${name}${suffix}.js`; return minify ? `${name}${suffix}.min.js` : `${name}${suffix}.js`;
}, },
}, },
// terser has better compression than esbuild // terser has better compression than esbuild
minify: minify ? 'terser' : false, minify: minify ? 'terser' : false,
rollupOptions: { rollupOptions: {

View File

@ -0,0 +1,10 @@
MIT License
Copyright (c) Youzan
Copyright (c) Chen Jiahan and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,32 @@
# @vant/compat
This package provides Vant 3 compatible behavior for Vant 4 users.
## Install
```shell
# with npm
npm i @vant/compat
# with yarn
yarn add @vant/compat
# with pnpm
pnpm add @vant/compat
```
## Usage
```js
// Same as Toast in Vant 3
import { Toast } from '@vant/compat';
// Same as Dialog in Vant 3
import { Dialog } from '@vant/compat';
// Same as Notify in Vant 3
import { Notify } from '@vant/compat';
// Same as ImagePreview in Vant 3
import { ImagePreview } from '@vant/compat';
```

View File

@ -0,0 +1 @@
require('../vant-use/build');

View File

@ -0,0 +1,52 @@
{
"name": "@vant/compat",
"version": "1.0.0",
"description": "Provide Vant 3 compatible behavior for Vant 4",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.mjs",
"types": "dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.esm.mjs",
"require": "./dist/index.cjs.js"
}
},
"sideEffects": false,
"files": [
"dist"
],
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"scripts": {
"clean": "rimraf ./dist",
"dev": "node ./build.js -w",
"build:types": "tsc -p ./tsconfig.json --emitDeclarationOnly",
"build:bundle": "node ./build.js",
"build": "pnpm clean && pnpm build:bundle && pnpm build:types",
"release": "pnpm build && release-it"
},
"repository": {
"type": "git",
"url": "https://github.com/vant-ui/vant.git",
"directory": "packages/vant-compat"
},
"bugs": "https://github.com/vant-ui/vant/issues",
"author": "chenjiahan",
"license": "MIT",
"devDependencies": {
"@vue/runtime-core": "^3.2.27",
"vant": "workspace:*",
"vue": "^3.2.27",
"esbuild": "^0.14.29",
"release-it": "^15.1.1",
"typescript": "^4.7.4"
},
"release-it": {
"git": {
"tag": false,
"commitMessage": "release: @vant/compat ${version}"
}
}
}

View File

@ -0,0 +1,30 @@
import {
Dialog as VanDialog,
showDialog,
closeDialog,
showConfirmDialog,
setDialogDefaultOptions,
resetDialogDefaultOptions,
} from 'vant';
import type { App } from 'vue';
export const Dialog = (...args: Parameters<typeof showDialog>) =>
showDialog(...args);
Dialog.Component = VanDialog;
Dialog.alert = Dialog;
Dialog.config = showConfirmDialog;
Dialog.close = closeDialog;
Dialog.setDefaultOptions = setDialogDefaultOptions;
Dialog.resetDefaultOptions = resetDialogDefaultOptions;
Dialog.install = (app: App) => {
app.use(Dialog.Component);
app.config.globalProperties.$dialog = Dialog;
};
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
$dialog: typeof Dialog;
}
}

View File

@ -0,0 +1,11 @@
import { ImagePreview as VanImagePreview, showImagePreview } from 'vant';
import type { App } from 'vue';
export const ImagePreview = (...args: Parameters<typeof showImagePreview>) =>
showImagePreview(...args);
ImagePreview.Component = VanImagePreview;
ImagePreview.install = (app: App) => {
app.use(ImagePreview.Component);
};

View File

@ -0,0 +1,4 @@
export * from './toast';
export * from './notify';
export * from './dialog';
export * from './image-preview';

View File

@ -0,0 +1,27 @@
import {
Notify as VanNotify,
showNotify,
closeNotify,
setNotifyDefaultOptions,
resetNotifyDefaultOptions,
} from 'vant';
import type { App } from 'vue';
export const Notify = (...args: Parameters<typeof showNotify>) =>
showNotify(...args);
Notify.clear = closeNotify;
Notify.Component = VanNotify;
Notify.setDefaultOptions = setNotifyDefaultOptions;
Notify.resetDefaultOptions = resetNotifyDefaultOptions;
Notify.install = (app: App) => {
app.use(Notify.Component);
app.config.globalProperties.$notify = Notify;
};
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
$notify: typeof Notify;
}
}

View File

@ -0,0 +1,49 @@
import {
showToast,
closeToast,
showFailToast,
showSuccessToast,
allowMultipleToast,
setToastDefaultOptions,
resetToastDefaultOptions,
} from 'vant';
import type { App } from 'vue';
export const Toast = (...args: Parameters<typeof showToast>) => {
const toast = showToast(...args);
return {
clear: toast.close,
...toast,
};
};
Toast.fail = (...args: Parameters<typeof showFailToast>) => {
const toast = showFailToast(...args);
return {
clear: toast.close,
...toast,
};
};
Toast.success = (...args: Parameters<typeof showSuccessToast>) => {
const toast = showSuccessToast(...args);
return {
clear: toast.close,
...toast,
};
};
Toast.clear = closeToast;
Toast.allowMultiple = allowMultipleToast;
Toast.setDefaultOptions = setToastDefaultOptions;
Toast.resetDefaultOptions = resetToastDefaultOptions;
Toast.install = (app: App) => {
app.config.globalProperties.$toast = Toast;
};
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
$toast: typeof Toast;
}
}

View File

@ -0,0 +1,8 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "./dist",
"declaration": true
},
"include": ["src/**/*"]
}

View File

@ -20,17 +20,17 @@
"author": "chenjiahan", "author": "chenjiahan",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/eslint-plugin": "^5.30.3", "@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.30.3", "@typescript-eslint/parser": "^5.36.1",
"eslint-config-airbnb-base": "^15.0.0", "eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0", "eslint-plugin-import": "^2.26.0",
"eslint-plugin-vue": "^9.1.1" "eslint-plugin-vue": "^9.4.0"
}, },
"devDependencies": { "devDependencies": {
"enhanced-resolve": "^5.10.0", "enhanced-resolve": "^5.10.0",
"eslint": "^8.19.0", "eslint": "^8.23.0",
"typescript": "^4.7.4" "typescript": "^4.8.2"
}, },
"peerDependencies": { "peerDependencies": {
"eslint": "^7.32.0 || ^8.2.0" "eslint": "^7.32.0 || ^8.2.0"

View File

@ -23,7 +23,7 @@
"author": "chenjiahan", "author": "chenjiahan",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"release-it": "^15.1.1" "release-it": "^15.4.1"
}, },
"release-it": { "release-it": {
"git": { "git": {

View File

@ -31,18 +31,18 @@
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/vant-ui/vant.git", "url": "https://github.com/vant-ui/vant.git",
"directory": "packages/vant-markdown-loader" "directory": "packages/vant-popperjs"
}, },
"bugs": "https://github.com/vant-ui/vant/issues", "bugs": "https://github.com/vant-ui/vant/issues",
"author": "chenjiahan", "author": "chenjiahan",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@popperjs/core": "^2.9.2" "@popperjs/core": "^2.11.6"
}, },
"devDependencies": { "devDependencies": {
"esbuild": "^0.14.29", "esbuild": "^0.14.54",
"release-it": "^15.1.1", "release-it": "^15.4.1",
"typescript": "^4.7.4" "typescript": "^4.8.2"
}, },
"release-it": { "release-it": {
"git": { "git": {

View File

@ -0,0 +1,11 @@
const fs = require('fs');
const path = require('path');
const srcFile = path.join(__dirname, 'src', 'index.js');
const distDir = path.join(__dirname, 'dist');
if (!fs.existsSync(distDir)) {
fs.mkdirSync(distDir);
}
fs.copyFileSync(srcFile, path.join(distDir, 'index.js'));
fs.copyFileSync(srcFile, path.join(distDir, 'index.mjs'));

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
### [v1.4.0]
`2022-08-06`
- support `.mjs` extension
### [v1.3.1] ### [v1.3.1]
`2021-07-06` `2021-07-06`

View File

@ -1,10 +1,16 @@
{ {
"name": "@vant/touch-emulator", "name": "@vant/touch-emulator",
"version": "1.3.2", "version": "1.4.0",
"description": "Vant touch emulator", "description": "Vant touch emulator",
"main": "index.js", "main": "dist/index.js",
"module": "dist/index.mjs",
"scripts": {
"build": "node ./build.js",
"prepare": "pnpm build"
},
"publishConfig": { "publishConfig": {
"access": "public" "access": "public",
"registry": "https://registry.npmjs.org/"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -14,7 +14,7 @@ function bundleBundle(format) {
outfile, outfile,
// preserve Chinese character // preserve Chinese character
charset: 'utf8', charset: 'utf8',
external: ['vue'], external: ['vue', 'vant'],
entryPoints: ['./src/index.ts'], entryPoints: ['./src/index.ts'],
}).then(finish); }).then(finish);
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@vant/use", "name": "@vant/use",
"version": "1.4.1", "version": "1.4.2",
"description": "Vant Composition API", "description": "Vant Composition API",
"main": "dist/index.cjs.js", "main": "dist/index.cjs.js",
"module": "dist/index.esm.mjs", "module": "dist/index.esm.mjs",
@ -37,10 +37,10 @@
"author": "chenjiahan", "author": "chenjiahan",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"esbuild": "^0.14.29", "esbuild": "^0.14.54",
"release-it": "^15.1.1", "release-it": "^15.4.1",
"typescript": "^4.7.4", "typescript": "^4.8.2",
"vue": "^3.2.27" "vue": "^3.2.38"
}, },
"release-it": { "release-it": {
"git": { "git": {

View File

@ -7,7 +7,10 @@ export type UseClickAwayOptions = {
}; };
export function useClickAway( export function useClickAway(
target: Element | Ref<Element | undefined>, target:
| Element
| Ref<Element | undefined>
| Array<Element | Ref<Element | undefined>>,
listener: EventListener, listener: EventListener,
options: UseClickAwayOptions = {} options: UseClickAwayOptions = {}
) { ) {
@ -18,8 +21,13 @@ export function useClickAway(
const { eventName = 'click' } = options; const { eventName = 'click' } = options;
const onClick = (event: Event) => { const onClick = (event: Event) => {
const element = unref(target); const targets = Array.isArray(target) ? target : [target];
if (element && !element.contains(event.target as Node)) { const isClickAway = targets.every((item) => {
const element = unref(item);
return element && !element.contains(event.target as Node);
});
if (isClickAway) {
listener(event); listener(event);
} }
}; };

View File

@ -10,6 +10,16 @@ export type UseEventListenerOptions = {
passive?: boolean; passive?: boolean;
}; };
export function useEventListener<K extends keyof DocumentEventMap>(
type: K,
listener: (event: DocumentEventMap[K]) => void,
options?: UseEventListenerOptions
): void;
export function useEventListener(
type: string,
listener: EventListener,
options?: UseEventListenerOptions
): void;
export function useEventListener( export function useEventListener(
type: string, type: string,
listener: EventListener, listener: EventListener,
@ -27,7 +37,10 @@ export function useEventListener(
const element = unref(target); const element = unref(target);
if (element && !attached) { if (element && !attached) {
element.addEventListener(type, listener, { capture, passive }); element.addEventListener(type, listener, {
capture,
passive,
});
attached = true; attached = true;
} }
}; };

View File

@ -1,7 +1,7 @@
import { ref, Ref } from 'vue'; import { ref, Ref } from 'vue';
import { inBrowser } from '../utils'; import { inBrowser } from '../utils';
type VisibilityState = "hidden" | "visible"; type VisibilityState = 'hidden' | 'visible';
let visibility: Ref<VisibilityState>; let visibility: Ref<VisibilityState>;

View File

@ -172,6 +172,8 @@ module.exports = {
}; };
``` ```
> Tips: 在配置 postcss-pxtorem 时,同样应避免 ignore node_modules 目录,否则会导致 Vant 样式无法被编译。
#### 其他设计稿尺寸 #### 其他设计稿尺寸
如果设计稿的尺寸不是 375而是 750 或其他大小,可以将 `rootValue` 配置调整为: 如果设计稿的尺寸不是 375而是 750 或其他大小,可以将 `rootValue` 配置调整为:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
感谢你使用 Vant。 感谢你使用 Vant。
以下是关于向 Vant 提交反馈或代码的指南。在向 Vant 提交 issue 或者 PR 之前,请先花几分钟时间阅读以下文字 以下是关于向 Vant 提交反馈或代码的指南。在向 Vant 提交 issue 或者 PR 之前,请先花几分钟时间阅读以下内容
### Issue 规范 ### Issue 规范
@ -15,7 +15,7 @@
### 本地开发 ### 本地开发
在进行本地开发前,请先确保你的开发环境中安装了 [Node.js >= 14](https://nodejs.org) 和 [pnpm](https://pnpm.io). 在进行本地开发前,请先确保你的开发环境中安装了 [Node.js >= 14.19.0](https://nodejs.org)。
按照下面的步骤操作,即可在本地开发 Vant 组件。 按照下面的步骤操作,即可在本地开发 Vant 组件。
@ -23,6 +23,12 @@
# 克隆仓库 # 克隆仓库
git clone git@github.com:vant-ui/vant.git git clone git@github.com:vant-ui/vant.git
# 启用 pnpm 包管理器
corepack enable
# 如果无法使用 corepack你也可以手动安装 pnpm
npm install -g pnpm@7
# 安装依赖 # 安装依赖
pnpm i pnpm i
@ -32,9 +38,9 @@ pnpm dev
仓库的不同分支对应不同的 Vant 版本,请切换到对应分支进行开发: 仓库的不同分支对应不同的 Vant 版本,请切换到对应分支进行开发:
- dev 分支对应 Vant 4 版本,适用于 Vue 3
- 3.x 分支对应 Vant 3 版本 ,适用于 Vue 3
- 2.x 分支对应 Vant 2 版本,适用于 Vue 2 - 2.x 分支对应 Vant 2 版本,适用于 Vue 2
- dev 分支对应 Vant 3 版本 ,适用于 Vue 3
- next 分支对应 Vant 4 版本,适用于 Vue 3
### 镜像仓库 ### 镜像仓库

View File

@ -31,7 +31,7 @@ Vant 是一个**轻量、可靠的移动端组件库**,于 2017 年开源。
### 版本提示 ### 版本提示
你当前浏览的是 **Vant 3.x 版本** 的文档,适用于 Vue 3 开发。如果你在使用 Vue 2请浏览 [Vant 2 文档](https://vant-contrib.gitee.io/vant/v2)。 你当前浏览的是 **Vant 4.x 版本** 的文档,适用于 Vue 3 开发。如果你在使用 Vue 2请浏览 [Vant 2 文档](https://vant-contrib.gitee.io/vant/v2)。
### 快速上手 ### 快速上手

View File

@ -1,4 +1,4 @@
# 从 v2 升级 # 从 v2 升级到 v3
### 介绍 ### 介绍

View File

@ -0,0 +1,365 @@
# 从 v3 升级到 v4
### 介绍
本文档提供了从 Vant 3 到 Vant 4 的升级指南。
## 按需引入方式调整
### 移除 babel-plugin-import
从 Vant 4.0 版本开始,将不再支持 `babel-plugin-import`,请移除项目中依赖的 `babel-plugin-import` 插件。
只需要删除 `babel.config.js` 中的以下代码即可:
```diff
module.exports = {
plugins: [
- ['import', {
- libraryName: 'vant',
- libraryDirectory: 'es',
- style: true
- }, 'vant']
]
};
```
#### 收益
移除 `babel-plugin-import` 有以下收益:
- 不再强依赖 babel项目可以使用 esbuild、swc 等更高效的编译工具,大幅度提升编译效率。
- 不再受到 `babel-plugin-import` 的 import 写法限制,可以从 vant 中导入除了组件以外的其他内容,比如 Vant 4 中新增的 `showToast` 等方法:
```ts
import { showToast, showDialog } from 'vant';
```
#### 样式引入方案
移除 `babel-plugin-import` 对项目的 JS 体积不会有影响,因为 Vant 默认支持通过 Tree Shaking 优化来移除不需要的 JS 代码。
而 CSS 代码的引入方式可以从以下两种方式中进行选择:
- 通过 [unplugin-vue-components](https://github.com/antfu/unplugin-vue-components) 插件实现按需引入样式,详细用法参见 [快速上手](#/zh-CN/quickstart)。
- 在项目中全量引入 Vant 的样式文件:
```js
import 'vant/lib/index.css';
```
## 组件重构
### 介绍
在 Vant 4 中,一共有三个组件被完全重构,它们是:
- `Area`
- `Picker`
- `DatetimePicker`
之所以重构这三个组件,是因为在之前的版本中,`Picker` 组件的 API 设计存在一些不合理的设计,导致大家在使用时经常遇到问题,比如:
- columns 数据格式定义不合理,容易产生误解
- 数据流不清晰,暴露了过多的实例方法来对数据进行操作
为了解决上述问题,我们在 v4 版本中对 `Picker` 组件进行了重构,同时也重构了基于 `Picker` 派生出的 `Area``DatetimePicker` 组件。
### Picker 组件重构
#### 主要变更
- 支持通过 `v-model` 绑定当前选中的值,移除 `default-index` 属性
- 重新定义了 `columns` 属性的结构
- 移除了操作内部数据的实例方法,仅保留 `confirm` 方法
- 新增 `getSelectedOptions` 实例方法
- 调整了 `confirm``cancel``change` 事件的参数
- 重命名 `item-height` 属性为 `option-height`
- 重命名 `visible-item-count` 属性为 `visible-option-num`
> 详细用法请参见 [Picker 组件文档](#/zh-CN/picker)。
### DatetimePicker 组件重构
DatetimePicker 组件被拆分为:
- [TimePicker](#/zh-CN/time-picker): 用于时间选择。
- [DatePicker](#/zh-CN/date-picker): 用于日期选择。
- [PickerGroup](#/zh-CN/picker-group): 用于用于结合多个 Picker 选择器组件。
同时TimePicker 和 DatePicker 组件也基于新版 Picker 组件进行重构,并优化了部分 API 设计。
#### 主要变更
以下是 TimePicker 和 DatePicker 的主要 API 变化,更多细节请参考 [TimePicker](#/zh-CN/time-picker) 和 [DatePicker](#/zh-CN/date-picker) 文档。
- `v-model` 绑定的值调整为数组格式
- 新增 `columns-type` 属性,用于控制选项类型和顺序
- 移除 `type` 属性和 `columns-order` 属性
- 移除 `getPicker` 方法
- 调整 `confirm``cancel``change` 事件的参数,与 Picker 组件保持一致
> Vant 4 不再提供旧版的 DatetimePicker 组件,使用 PickerGroup 组件可以实现更灵活、更丰富的交互效果,具体用法请参考 [PickerGroup](#/zh-CN/picker-group) 组件文档。
### Area 组件重构
Area 组件是基于 Picker 组件进行封装的,因此本次升级也对 Area 组件进行了内部逻辑的重构,并优化了部分 API 设计。
#### 主要变更
- 支持通过 `v-model` 绑定当前选中的值
- 移除 `reset` 方法,现在可以通过修改 `v-model` 来进行重置
- 移除 `is-oversea-code` 属性
- 调整 `confirm``cancel``change` 事件的参数,与 Picker 组件保持一致
- 重命名 `value` 属性为 `modelValue`
- 重命名 `item-height` 属性为 `option-height`
- 重命名 `visible-item-count` 属性为 `visible-option-num`
> 详细用法请参见 [Area 组件文档](#/zh-CN/area)。
## API 调整
### Dialog 调用方式调整
在 Vant 3 中,`Dialog` 是一个函数,调用函数可以快速唤起全局的弹窗组件,而 `Dialog.Component` 才是 `Dialog` 组件对象,这与大部分组件的用法存在差异,容易导致使用错误。
为了更符合直觉,我们在 Vant 4 中调整了 `Dialog` 的调用方式,将 `Dialog()` 函数重命名为 `showDialog()`
```js
// Vant 3
Dialog(); // 函数调用
Dialog.Component; // 组件对象
// Vant 4
showDialog(); // 函数调用
Dialog; // 组件对象
```
`Dialog` 上挂载的其他方法也进行了重命名,新旧 API 的映射关系如下:
```js
Dialog(); // -> showDialog()
Dialog.alert(); // -> showDialog()
Dialog.confirm(); // -> showConfirmDialog()
Dialog.close(); // -> closeDialog();
Dialog.setDefaultOptions(); // -> setDialogDefaultOptions()
Dialog.resetDefaultOptions(); // -> resetDialogDefaultOptions()
```
#### 兼容方案
为了便于代码迁移,我们提供了兼容方案,你可以使用 `@vant/compat` 中导出的 `Dialog` 对象来兼容原有代码。
```js
import { Dialog } from '@vant/compat';
Dialog();
Dialog.close();
```
`@vant/compat` 中导出的 `Dialog` 与 Vant 3 中的 `Dialog` 拥有完全一致的 API 和行为,因此你只需要修改 `Dialog` 的引用路径,其他代码可以保持不变。
### Toast 调用方式调整
Vant 4 中,`Toast` 组件的调用方式也进行了调整,与 `Dialog` 组件的改动一致:
```js
// Vant 3
Toast(); // 函数调用
// Vant 4
showToast(); // 函数调用
Toast; // 组件对象
```
`Toast` 上挂载的其他方法也进行了重命名,新旧 API 的映射关系如下:
```js
Toast(); // -> showToast()
Toast.fail(); // -> showFailToast()
Toast.success(); // -> showSuccessToast()
Toast.loading(); // -> showLoadingToast()
Toast.clear(); // -> closeToast()
Toast.setDefaultOptions(); // -> setToastDefaultOptions()
Toast.resetDefaultOptions(); // -> resetToastDefaultOptions()
```
同时Vant 4 将不再在 `this` 对象上全局注册 `$toast` 方法,这意味着 `this` 对象上将无法访问到 `$toast`
#### 兼容方案
为了便于代码迁移,我们提供了兼容方案,你可以使用 `@vant/compat` 中导出的 `Toast` 对象来兼容原有代码。
```js
import { Toast } from '@vant/compat';
Toast();
Toast.clear();
```
`@vant/compat` 中导出的 `Toast` 与 Vant 3 中的 `Toast` 拥有完全一致的 API 和行为,因此你只需要修改 `Toast` 的引用路径,其他代码可以保持不变。
### Notify 调用方式调整
Vant 4 中,`Notify` 组件的调用方式也进行了调整,与 `Dialog` 组件的改动一致:
```js
// Vant 3
Notify(); // 函数调用
Notify.Component; // 组件对象
// Vant 4
showNotify(); // 函数调用
Notify; // 组件对象
```
`Notify` 上挂载的其他方法也进行了重命名,新旧 API 的映射关系如下:
```js
Notify(); // -> showNotify()
Notify.clear(); // -> closeNotify()
Notify.setDefaultOptions(); // -> setNotifyDefaultOptions()
Notify.resetDefaultOptions(); // -> resetNotifyDefaultOptions()
```
同时Vant 4 将不再在 `this` 对象上全局注册 `$notify` 方法,这意味着 `this` 对象上将无法访问到 `$notify`
#### 兼容方案
为了便于代码迁移,我们提供了兼容方案,你可以使用 `@vant/compat` 中导出的 `Notify` 对象来兼容原有代码。
```js
import { Notify } from '@vant/compat';
Notify();
Notify.clear();
```
`@vant/compat` 中导出的 `Notify` 与 Vant 3 中的 `Notify` 拥有完全一致的 API 和行为,因此你只需要修改 `Notify` 的引用路径,其他代码可以保持不变。
### ImagePreview 调用方式调整
Vant 4 中,`ImagePreview` 组件的调用方式也进行了调整,与 `ImagePreview` 组件的改动一致:
```js
// Vant 3
ImagePreview(); // 函数调用
ImagePreview.Component; // 组件对象
// Vant 4
showImagePreview(); // 函数调用
ImagePreview; // 组件对象
```
#### 兼容方案
为了便于代码迁移,我们提供了兼容方案,你可以使用 `@vant/compat` 中导出的 `ImagePreview` 对象来兼容原有代码。
```js
import { ImagePreview } from '@vant/compat';
ImagePreview();
```
`@vant/compat` 中导出的 `ImagePreview` 与 Vant 3 中的 `ImagePreview` 拥有完全一致的 API 和行为,因此你只需要修改 `ImagePreview` 的引用路径,其他代码可以保持不变。
### 事件命名调整
从 Vant 4 开始,所有的事件均采用 Vue 官方推荐的**驼峰格式**进行命名。
```js
// Vant 3
emit('click-input');
// Vant 4
emit('clickInput');
```
这项改动**不影响原有的模板代码**Vue 会自动在模板中对事件名进行格式转换:
```html
<!-- 以下代码可以照常运行,无须做任何更改 -->
<van-field @click-input="onClick" />
```
如果你在 JSX 中使用 Vant 组件,需要将监听的事件名调整为驼峰格式,新的监听方式更加符合 JSX 本身的规范:
```jsx
// Vant 3
<Field onClick-input={onClick} />
// Vant 4
<Field onClickInput={onClick} />
```
### 其他 API 调整
在 Vant 4.0 版本中,以下 API 进行了不兼容更新:
#### AddressEdit
- 移除 `show-postal` 属性
- 移除 `postal-validator` 属性
- `change-area` 事件的参数调整为 `PickerOption[]` 类型
- 移除未在文档中标注的 `getArea` 实例方法
#### Popup
Popup 的 CSS 样式进行了一定调整,请确认是否对项目中的 UI 产生影响。
- 默认添加了 `box-sizing: border-box` 样式
- 调整了 `position="center"` 时的水平居中方式,以解决弹窗宽度无法正确自适应的问题:
```less
// Vant 3
.van-popup--center {
left: 50%;
transform: translate3d(-50%, -50%, 0);
}
// Vant 4
.van-popup--center {
left: 0;
right: 0;
width: fit-content;
max-width: calc(100vw - var(--van-padding-md) * 2);
margin: 0 auto;
transform: translateY(-50%);
}
```
#### Tabs
- 移除了 `click``disabled` 事件,请使用 `click-tab` 事件代替
## 样式变量调整
### 移除 Less 变量
目前 Vant 已经支持了基于 CSS 变量的主题定制能力,因此后续将不再提供基于 Less 的主题定制方式。
这意味着 Vant 的 npm 包中将不再会包含 `.less` 样式源文件,只会提供编译后的 `.css` 样式文件。
如果你的项目正在使用旧版的 Less 主题定制,请使用 [ConfigProvider 全局配置](#/zh-CN/config-provider) 组件进行替换。
### 简化 CSS 变量名
考虑到 **代码体积****使用便捷性**,我们对部分 CSS 变量的名称进行了简化,在变量名中使用更简短的单词,涉及以下变更:
```less
animation-duration -> duration
animation-timing-function-enter -> ease-out
animation-timing-function-leave -> ease-in
background-color -> background
background-color-light -> background-2
border-radius -> radius
border-width-base -> border-width
box-shadow -> shadow
font-family -> font
font-weight-bold -> font-bold
price-integer-font -> price-font
text-link -> link
transition-duration -> duration
```
由于涉及的 CSS 变量较多,建议在代码仓库中进行全局匹配和替换。

View File

@ -26,7 +26,7 @@ pnpm add vant
### CDN ### CDN
The easiest way to use Vant is to include a CDN link in the html file, after which you can access all components via the global variable `vant`. The easiest way to use Vant is to include a CDN link in the HTML file, after which you can access all components via the global variable `vant`.
```html ```html
<!-- import style --> <!-- import style -->
@ -50,7 +50,7 @@ The easiest way to use Vant is to include a CDN link in the html file, after whi
app.use(vant.Lazyload); app.use(vant.Lazyload);
// Call function component // Call function component
vant.Toast('Message'); vant.showToast('Message');
app.mount('#app'); app.mount('#app');
</script> </script>
@ -92,9 +92,28 @@ In the GUI, click on 'Dependencies' -> `Install Dependencies` and add `vant` to
## Usage ## Usage
### Import on demand (recommended) ### Basic Usage
If you are using vite, webpack or vue-cli, please use [unplugin-vue-components](https://github.com/antfu/unplugin-vue-components). The basic usage of Vant components;
```js
import { createApp } from 'vue';
// 1. Import the components you need
import { Button } from 'vant';
// 2. Import the components style
import 'vant/lib/index.css';
const app = createApp();
// 3. Register the components you need
app.use(Button);
```
> Tip: Vant supports Tree Shaking by default, so you don't need to configure any plugins, the unused JS code will be removed by Tree Shaking, but CSS styles cannot be optimized by it.
### Import on demand
If you are using vite, webpack or vue-cli, you can use [unplugin-vue-components](https://github.com/antfu/unplugin-vue-components), this plugin can help you to auto importing components and reduce CSS file size.
#### 1. Install Plugin #### 1. Install Plugin
@ -160,16 +179,14 @@ module.exports = {
}; };
``` ```
#### 3. Import Components #### 3. Using Components
Then you can import components from Vant: Then you can using components from Vant in the template, the `unplugin-vue-components` will automatically import the corresponding Vant components.
```js ```html
import { createApp } from 'vue'; <template>
import { Button } from 'vant'; <van-button type="primary" />
</template>
const app = createApp();
app.use(Button);
``` ```
#### 4. Style of Function Components #### 4. Style of Function Components
@ -178,43 +195,41 @@ Some components of Vant are provided as function, including `Toast`, `Dialog`, `
```js ```js
// Toast // Toast
import { Toast } from 'vant'; import { showToast } from 'vant';
import 'vant/es/toast/style'; import 'vant/es/toast/style';
// Dialog // Dialog
import { Dialog } from 'vant'; import { showDialog } from 'vant';
import 'vant/es/dialog/style'; import 'vant/es/dialog/style';
// Notify // Notify
import { Notify } from 'vant'; import { showNotify } from 'vant';
import 'vant/es/notify/style'; import 'vant/es/notify/style';
// ImagePreview // ImagePreview
import { ImagePreview } from 'vant'; import { showImagePreview } from 'vant';
import 'vant/es/image-preview/style'; import 'vant/es/image-preview/style';
``` ```
> Vant supports tree shaking by default, so you don't necessarily need the webpack plugin, if you can't accept the full import of css. > Tip: "Full Import" and "On-demand Import" should not be used at the same time, otherwise it will lead to problems such as code duplication and style overrides.
### Import all components (not recommended) ## With Frameworks
Import all components will **increase the bundle size**, so this is not recommended. ### Use Vant in Nuxt 3
```js When using Vant in Nuxt 3, you should add `/vant/` to the `build.transpile`:
import { createApp } from 'vue';
import Vant from 'vant';
import 'vant/lib/index.css';
const app = createApp(); ```ts
app.use(Vant); import { defineNuxtConfig } from 'nuxt';
export default defineNuxtConfig({
experimental: {
externalVue: true,
},
});
``` ```
### Manually import (not recommended) Reference:
```js - [nuxt/framework#6761](https://github.com/nuxt/framework/issues/6761)
// import script - [nuxt/framework#4084](https://github.com/nuxt/framework/issues/4084)
import Button from 'vant/es/button/index';
// import style
// if the component does not have a style file, there is no need to import
import 'vant/es/button/style/index';
```

View File

@ -30,7 +30,7 @@ pnpm add vant
### 通过 CDN 安装 ### 通过 CDN 安装
使用 Vant 最简单的方法是直接在 html 文件中引入 CDN 链接,之后你可以通过全局变量 `vant` 访问到所有组件。 使用 Vant 最简单的方法是直接在 HTML 文件中引入 CDN 链接,之后你可以通过全局变量 `vant` 访问到所有组件。
```html ```html
<!-- 引入样式文件 --> <!-- 引入样式文件 -->
@ -54,8 +54,8 @@ pnpm add vant
// 可以通过下面的方式手动注册 // 可以通过下面的方式手动注册
app.use(vant.Lazyload); app.use(vant.Lazyload);
// 调用函数组件,弹出一个 Toast // 调用工具函数,弹出一个 Toast
vant.Toast('提示'); vant.showToast('提示');
app.mount('#app'); app.mount('#app');
</script> </script>
@ -93,9 +93,32 @@ pnpm add vant
## 引入组件 ## 引入组件
### 按需引入组件(推荐) ### 方法一. 常规用法
在基于 `vite``webpack``vue-cli` 的项目中使用 Vant 时,推荐安装 [unplugin-vue-components](https://github.com/antfu/unplugin-vue-components) 插件,它可以自动按需引入组件。 下面是使用 Vant 组件的用法示例:
```js
import { createApp } from 'vue';
// 1. 引入你需要的组件
import { Button } from 'vant';
// 2. 引入组件样式
import 'vant/lib/index.css';
const app = createApp();
// 3. 注册你需要的组件
app.use(Button);
```
Vant 支持多种组件注册方式,除了在 app 上全局注册组件,你也可以选择其他的方式,比如局部注册,详见 [组件注册](#/zh-CN/advanced-usage#zu-jian-zhu-ce) 章节。
> 提示Vant 默认支持 Tree Shaking因此你不需要配置任何插件通过 Tree Shaking 即可移除不需要的 JS 代码,但 CSS 样式无法通过这种方式优化,如果需要按需引入 CSS 样式,请参考下面的方法二。
### 方法二. 按需引入组件样式
在基于 `vite``webpack``vue-cli` 的项目中使用 Vant 时,可以使用 [unplugin-vue-components](https://github.com/antfu/unplugin-vue-components) 插件,它可以自动引入组件,并按需引入组件的样式。
相比于常规用法,这种方式可以按需引入组件的 CSS 样式,从而减少一部分代码体积,但使用起来会变得繁琐一些。如果业务对 CSS 的体积要求不是特别极致,我们推荐使用更简便的常规用法。
#### 1. 安装插件 #### 1. 安装插件
@ -161,16 +184,14 @@ module.exports = {
}; };
``` ```
#### 3. 引入组件 #### 3. 使用组件
完成以上两步,就可以直接使用 Vant 组件了: 完成以上两步,就可以直接在模板中使用 Vant 组件了,`unplugin-vue-components` 会解析模板并自动注册对应的组件。
```js ```html
import { createApp } from 'vue'; <template>
import { Button } from 'vant'; <van-button type="primary" />
</template>
const app = createApp();
app.use(Button);
``` ```
#### 4. 引入函数组件的样式 #### 4. 引入函数组件的样式
@ -179,45 +200,74 @@ Vant 中有个别组件是以函数的形式提供的,包括 `Toast``Dialog
```js ```js
// Toast // Toast
import { Toast } from 'vant'; import { showToast } from 'vant';
import 'vant/es/toast/style'; import 'vant/es/toast/style';
// Dialog // Dialog
import { Dialog } from 'vant'; import { showDialog } from 'vant';
import 'vant/es/dialog/style'; import 'vant/es/dialog/style';
// Notify // Notify
import { Notify } from 'vant'; import { showNotify } from 'vant';
import 'vant/es/notify/style'; import 'vant/es/notify/style';
// ImagePreview // ImagePreview
import { ImagePreview } from 'vant'; import { showImagePreview } from 'vant';
import 'vant/es/image-preview/style'; import 'vant/es/image-preview/style';
``` ```
> 注意Vant 支持 Tree Shaking因此你也可以不配置任何插件通过 Tree Shaking 即可移除不需要的 JS 代码,但 CSS 无法通过这种方式优化 你可以在项目的入口文件或公共模块中引入以上组件的样式,这样在业务代码中使用组件时,便不再需要重复引入样式了
### 导入所有组件(不推荐) > 提示:在单个项目中不应该同时使用「全量引入」和「按需引入」,否则会导致代码重复、样式错乱等问题。
Vant 支持一次性导入所有组件,引入所有组件会**增加代码包体积**,因此不推荐这种做法。 ## 在框架中使用
```js ### 在 Nuxt 3 中使用
import { createApp } from 'vue';
import Vant from 'vant';
import 'vant/lib/index.css';
const app = createApp(); 在 Nuxt 3 中使用 Vant 时,由于 Nuxt 3 框架本身的限制,需要在 `nuxt.config.ts` 中添加以下配置:
app.use(Vant);
```ts
import { defineNuxtConfig } from 'nuxt';
export default defineNuxtConfig({
experimental: {
externalVue: true,
},
});
``` ```
### 手动按需引入组件(不推荐) 关于该问题的背景,可以参考以下 issue
在不使用任何构建插件的情况下,可以手动引入需要使用的组件和样式。 - [nuxt/framework#6761](https://github.com/nuxt/framework/issues/6761)
- [nuxt/framework#4084](https://github.com/nuxt/framework/issues/4084)
```js ## 迁移提示
// 引入组件脚本
import Button from 'vant/es/button/index'; ### 移除 babel-plugin-import
// 引入组件样式
// 若组件没有样式文件,则无须引入 从 Vant 4.0 版本开始,将不再支持 `babel-plugin-import`,请移除项目中依赖的 `babel-plugin-import` 插件。
import 'vant/es/button/style/index';
只需要删除 `babel.config.js` 中的以下代码即可:
```diff
module.exports = {
plugins: [
- ['import', {
- libraryName: 'vant',
- libraryDirectory: 'es',
- style: true
- }, 'vant']
]
};
```
#### 收益
移除 `babel-plugin-import` 有以下收益:
- 不再强依赖 babel项目可以使用 esbuild、swc 等更高效的编译工具,大幅度提升编译效率。
- 不再受到 `babel-plugin-import` 的 import 写法限制,可以从 vant 中导入除了组件以外的其他内容,比如 Vant 4 中新增的 `showToast` 等方法:
```ts
import { showToast, showDialog } from 'vant';
``` ```

View File

@ -1,176 +0,0 @@
# Custom Theme
### Deprecated
This document is deprecated. Vant provides a more convenient [ConfigProvider](#/en-US/config-provider) component for theme configuration. Less variables **will be removed in the next major version**.
### Intro
Vant use [Less](http://lesscss.org/) as css preprocessoryou can override the default less variables to custom theme.
### Less variables
There are some [basic variables](<(https://github.com/vant-ui/vant/blob/dev/packages/vant/src/style/var.less)>) below, for component less variables, please refer to the documentation of each component, or view the `var.less` file in the component source directory.
```less
// Color Palette
@black: #000;
@white: #fff;
@gray-1: #f7f8fa;
@gray-2: #f2f3f5;
@gray-3: #ebedf0;
@gray-4: #dcdee0;
@gray-5: #c8c9cc;
@gray-6: #969799;
@gray-7: #646566;
@gray-8: #323233;
@red: #ee0a24;
@blue: #1989fa;
@orange: #ff976a;
@orange-dark: #ed6a0c;
@orange-light: #fffbe8;
@green: #07c160;
// Gradient Colors
@gradient-red: linear-gradient(to right, #ff6034, #ee0a24);
@gradient-orange: linear-gradient(to right, #ffd01e, #ff8917);
// Component Colors
@text-color: @gray-8;
@active-color: @gray-2;
@active-opacity: 0.7;
@disabled-opacity: 0.5;
@background-color: @gray-1;
@background-color-light: @white;
@text-link-color: #576b95;
// Padding
@padding-base: 4px;
@padding-xs: @padding-base * 2;
@padding-sm: @padding-base * 3;
@padding-md: @padding-base * 4;
@padding-lg: @padding-base * 6;
@padding-xl: @padding-base * 8;
// Font
@font-size-xs: 10px;
@font-size-sm: 12px;
@font-size-md: 14px;
@font-size-lg: 16px;
@font-weight-bold: 500;
@line-height-xs: 14px;
@line-height-sm: 18px;
@line-height-md: 20px;
@line-height-lg: 22px;
@base-font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue',
Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', 'Hiragino Sans GB',
'Microsoft Yahei', sans-serif;
@price-integer-font-family: Avenir-Heavy, PingFang SC, Helvetica Neue, Arial,
sans-serif;
// Animation
@animation-duration-base: 0.3s;
@animation-duration-fast: 0.2s;
@animation-timing-function-enter: ease-out;
@animation-timing-function-leave: ease-in;
// Border
@border-color: @gray-3;
@border-width-base: 1px;
@border-radius-sm: 2px;
@border-radius-md: 4px;
@border-radius-lg: 8px;
@border-radius-max: 999px;
```
## How to custom theme
### Step 1: import less file
First you should import the less source file to your project. you can use babel-plugin-import to automatically import or just manually import less file.
#### Automatically import style
Configure babel plugin in babel.config.js, if you are using babel6, please manually import less file.
```js
module.exports = {
plugins: [
[
'import',
{
libraryName: 'vant',
libraryDirectory: 'es',
// specify less file path
style: (name) => `${name}/style/less`,
},
'vant',
],
],
};
```
#### Manually import style
```js
// import all styles
import 'vant/lib/index.less';
// import style of single component
import 'vant/lib/button/style/less';
```
### Step 2: modify less variables
Use [modifyVars](http://lesscss.org/usage/#using-less-in-the-browser-modify-variables) provided by less.js to modify less variableswebpack config for reference:
```js
// webpack.config.js
module.exports = {
rules: [
{
test: /\.less$/,
use: [
// ...other loaders
{
loader: 'less-loader',
options: {
lessOptions: {
modifyVars: {
// override with less vars
'text-color': '#111',
'border-color': '#eee',
// or override with less file
hack: `true; @import "your-less-file-path.less";`,
},
},
},
},
],
},
],
};
```
If you build a project by vue-cli,it can be configured in `vue.config.js`:
```js
// vue.config.js
module.exports = {
css: {
loaderOptions: {
less: {
lessOptions: {
modifyVars: {
// override with less vars
'text-color': '#111',
'border-color': '#eee',
// or override with less file
hack: `true; @import "your-less-file-path.less";`,
},
},
},
},
},
};
```

View File

@ -1,184 +0,0 @@
# 定制主题
### 废弃提示
本文档已废弃Vant 提供了更方便的 [ConfigProvider 全局配置](#/zh-CN/config-provider) 组件进行主题配置。基于 Less 变量进行定制的方式**将在下个大版本废弃**。
### 介绍
Vant 提供了一套默认主题CSS 命名采用 BEM 的风格,方便使用者覆盖样式。如果你想完全替换主题色或者其他样式,可以按照本文档进行主题定制。
### 示例工程
我们提供了一个基于 Vue CLI 3 的示例工程,仓库地址为 [Vant Demo](https://github.com/vant-ui/vant-demo),其中包含了定制主题的基本配置,可以作为参考。
### 样式变量
Vant 使用了 [Less](http://lesscss.org/) 对样式进行预处理,并内置了一些样式变量,通过替换样式变量即可定制你自己需要的主题。
下面是所有的[基础样式变量](https://github.com/vant-ui/vant/blob/dev/packages/vant/src/style/var.less),组件的样式变量请参考各个组件的文档,或查看组件源码目录下的 `var.less` 文件。
```less
// Color Palette
@black: #000;
@white: #fff;
@gray-1: #f7f8fa;
@gray-2: #f2f3f5;
@gray-3: #ebedf0;
@gray-4: #dcdee0;
@gray-5: #c8c9cc;
@gray-6: #969799;
@gray-7: #646566;
@gray-8: #323233;
@red: #ee0a24;
@blue: #1989fa;
@orange: #ff976a;
@orange-dark: #ed6a0c;
@orange-light: #fffbe8;
@green: #07c160;
// Gradient Colors
@gradient-red: linear-gradient(to right, #ff6034, #ee0a24);
@gradient-orange: linear-gradient(to right, #ffd01e, #ff8917);
// Component Colors
@text-color: @gray-8;
@active-color: @gray-2;
@active-opacity: 0.7;
@disabled-opacity: 0.5;
@background-color: @gray-1;
@background-color-light: @white;
@text-link-color: #576b95;
// Padding
@padding-base: 4px;
@padding-xs: @padding-base * 2;
@padding-sm: @padding-base * 3;
@padding-md: @padding-base * 4;
@padding-lg: @padding-base * 6;
@padding-xl: @padding-base * 8;
// Font
@font-size-xs: 10px;
@font-size-sm: 12px;
@font-size-md: 14px;
@font-size-lg: 16px;
@font-weight-bold: 500;
@line-height-xs: 14px;
@line-height-sm: 18px;
@line-height-md: 20px;
@line-height-lg: 22px;
@base-font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue',
Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', 'Hiragino Sans GB',
'Microsoft Yahei', sans-serif;
@price-integer-font-family: Avenir-Heavy, PingFang SC, Helvetica Neue, Arial,
sans-serif;
// Animation
@animation-duration-base: 0.3s;
@animation-duration-fast: 0.2s;
@animation-timing-function-enter: ease-out;
@animation-timing-function-leave: ease-in;
// Border
@border-color: @gray-3;
@border-width-base: 1px;
@border-radius-sm: 2px;
@border-radius-md: 4px;
@border-radius-lg: 8px;
@border-radius-max: 999px;
```
## 定制方法
### 步骤一 引入样式源文件
定制主题时,需要引入组件对应的 Less 样式文件,支持按需引入和手动引入两种方式。
#### 按需引入样式(推荐)
在 babel.config.js 中配置按需引入样式源文件,注意 babel 6 不支持按需引入样式,请手动引入样式。
```js
module.exports = {
plugins: [
[
'import',
{
libraryName: 'vant',
libraryDirectory: 'es',
// 指定样式路径
style: (name) => `${name}/style/less`,
},
'vant',
],
],
};
```
#### 手动引入样式
```js
// 引入全部样式
import 'vant/lib/index.less';
// 引入单个组件样式
import 'vant/lib/button/style/less';
```
### 步骤二 修改样式变量
使用 Less 提供的 [modifyVars](http://lesscss.org/usage/#using-less-in-the-browser-modify-variables) 即可对变量进行修改,下面是参考的 webpack 配置。
```js
// webpack.config.js
module.exports = {
rules: [
{
test: /\.less$/,
use: [
// ...其他 loader 配置
{
loader: 'less-loader',
options: {
// 若 less-loader 版本小于 6.0,请移除 lessOptions 这一级,直接配置选项。
lessOptions: {
modifyVars: {
// 直接覆盖变量
'text-color': '#111',
'border-color': '#eee',
// 或者可以通过 less 文件覆盖(文件路径为绝对路径)
hack: `true; @import "your-less-file-path.less";`,
},
},
},
},
],
},
],
};
```
如果 vue-cli 搭建的项目,可以在 `vue.config.js` 中进行配置。
```js
// vue.config.js
module.exports = {
css: {
loaderOptions: {
less: {
// 若 less-loader 版本小于 6.0,请移除 lessOptions 这一级,直接配置选项。
lessOptions: {
modifyVars: {
// 直接覆盖变量
'text-color': '#111',
'border-color': '#eee',
// 或者可以通过 less 文件覆盖(文件路径为绝对路径)
hack: `true; @import "your-less-file-path.less";`,
},
},
},
},
},
};
```

View File

@ -74,7 +74,7 @@ function useClickAway(
| Name | Description | Type | Default Value | | Name | Description | Type | Default Value |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| target | Target element | _Element \| Ref\<Element>_ | - | | target | Target element, support multiple elements | _Element \| Ref\<Element> \| Array\<Element \| Ref\<Element>>_ | - |
| listener | Callback function when the outside is clicked | _EventListener_ | - | | listener | Callback function when the outside is clicked | _EventListener_ | - |
| options | Options | _Options_ | `{ eventName: 'click' }` | | options | Options | _Options_ | `{ eventName: 'click' }` |

View File

@ -75,8 +75,8 @@ function useClickAway(
### 参数 ### 参数
| 参数 | 说明 | 类型 | 默认值 | | 参数 | 说明 | 类型 | 默认值 |
| -------- | ------------------------ | -------------------------- | ------ | | --- | --- | --- | --- |
| target | 绑定事件的元素 | _Element \| Ref\<Element>_ | - | | target | 绑定事件的元素,支持传入数组来绑定多个元素 | _Element \| Ref\<Element> \| Array\<Element \| Ref\<Element>>_ | - |
| listener | 点击外部时触发的回调函数 | _EventListener_ | - | | listener | 点击外部时触发的回调函数 | _EventListener_ | - |
| options | 可选的配置项 | _Options_ | 见下表 | | options | 可选的配置项 | _Options_ | 见下表 |

View File

@ -52,6 +52,7 @@ export function initDemoLocale() {
disabled: '禁用状态', disabled: '禁用状态',
uneditable: '不可编辑', uneditable: '不可编辑',
basicUsage: '基础用法', basicUsage: '基础用法',
usingUrl: '使用图片 URL',
advancedUsage: '高级用法', advancedUsage: '高级用法',
loadingStatus: '加载状态', loadingStatus: '加载状态',
}, },
@ -78,6 +79,7 @@ export function initDemoLocale() {
disabled: 'Disabled', disabled: 'Disabled',
uneditable: 'Uneditable', uneditable: 'Uneditable',
basicUsage: 'Basic Usage', basicUsage: 'Basic Usage',
usingUrl: 'Using URL',
advancedUsage: 'Advanced Usage', advancedUsage: 'Advanced Usage',
loadingStatus: 'Loading', loadingStatus: 'Loading',
}, },

View File

@ -1,13 +1,16 @@
{ {
"name": "vant", "name": "vant",
"version": "3.5.3", "version": "4.0.0-rc.0",
"description": "Lightweight Mobile UI Components built on Vue", "description": "Mobile UI Components built on Vue",
"main": "lib/vant.cjs.js", "main": "lib/vant.cjs.js",
"module": "es/index.mjs", "module": "es/index.mjs",
"style": "lib/index.css", "style": "lib/index.css",
"typings": "lib/index.d.ts", "typings": "lib/index.d.ts",
"unpkg": "lib/vant.min.js", "unpkg": "lib/vant.min.js",
"jsdelivr": "lib/vant.min.js", "jsdelivr": "lib/vant.min.js",
"npm": {
"tag": "next"
},
"files": [ "files": [
"es", "es",
"lib" "lib"
@ -46,27 +49,27 @@
"dependencies": { "dependencies": {
"@vant/icons": "^1.8.0", "@vant/icons": "^1.8.0",
"@vant/popperjs": "^1.2.1", "@vant/popperjs": "^1.2.1",
"@vant/use": "^1.4.1" "@vant/use": "^1.4.2"
}, },
"peerDependencies": { "peerDependencies": {
"vue": "^3.0.0" "vue": "^3.0.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^16", "@types/node": "^16.11.56",
"@types/jest": "^27.0.0",
"@vant/area-data": "workspace:*", "@vant/area-data": "workspace:*",
"@vant/cli": "workspace:*", "@vant/cli": "workspace:*",
"@vant/eslint-config": "workspace:*", "@vant/eslint-config": "workspace:*",
"@vue/runtime-core": "^3.2.27", "@vue/runtime-core": "^3.2.38",
"@vue/test-utils": "^2.0.1", "@vue/test-utils": "^2.0.2",
"typescript": "^4.7.4", "typescript": "^4.8.2",
"vue": "^3.2.27", "vue": "^3.2.38",
"vue-router": "^4.0.12" "vue-router": "^4.1.5"
}, },
"sideEffects": [ "sideEffects": [
"es/**/style/*", "es/**/style/*",
"lib/**/style/*", "lib/**/style/*",
"*.css", "*.css"
"*.less"
], ],
"web-types": "lib/web-types.json" "web-types": "lib/web-types.json"
} }

View File

@ -17,7 +17,7 @@ import { Button, ButtonType } from '../button';
const [name, bem] = createNamespace('action-bar-button'); const [name, bem] = createNamespace('action-bar-button');
const actionBarButtonProps = extend({}, routeProps, { export const actionBarButtonProps = extend({}, routeProps, {
type: String as PropType<ButtonType>, type: String as PropType<ButtonType>,
text: String, text: String,
icon: String, icon: String,

View File

@ -1,29 +1,27 @@
@import './var.less'; body {
--van-action-bar-button-height: 40px;
:root { --van-action-bar-button-warning-color: var(--van-gradient-orange);
--van-action-bar-button-height: @action-bar-button-height; --van-action-bar-button-danger-color: var(--van-gradient-red);
--van-action-bar-button-warning-color: @action-bar-button-warning-color;
--van-action-bar-button-danger-color: @action-bar-button-danger-color;
} }
.van-action-bar-button { .van-action-bar-button {
flex: 1; flex: 1;
height: var(--van-action-bar-button-height); height: var(--van-action-bar-button-height);
font-weight: var(--van-font-weight-bold); font-weight: var(--van-font-bold);
font-size: var(--van-font-size-md); font-size: var(--van-font-size-md);
border: none; border: none;
border-radius: 0; border-radius: 0;
&--first { &--first {
margin-left: 5px; margin-left: 5px;
border-top-left-radius: var(--van-border-radius-max); border-top-left-radius: var(--van-radius-max);
border-bottom-left-radius: var(--van-border-radius-max); border-bottom-left-radius: var(--van-radius-max);
} }
&--last { &--last {
margin-right: 5px; margin-right: 5px;
border-top-right-radius: var(--van-border-radius-max); border-top-right-radius: var(--van-radius-max);
border-bottom-right-radius: var(--van-border-radius-max); border-bottom-right-radius: var(--van-radius-max);
} }
&--warning { &--warning {

View File

@ -3,6 +3,7 @@ import _ActionBarButton from './ActionBarButton';
export const ActionBarButton = withInstall(_ActionBarButton); export const ActionBarButton = withInstall(_ActionBarButton);
export default ActionBarButton; export default ActionBarButton;
export { actionBarButtonProps } from './ActionBarButton';
export type { ActionBarButtonProps } from './ActionBarButton'; export type { ActionBarButtonProps } from './ActionBarButton';
declare module 'vue' { declare module 'vue' {

View File

@ -1,5 +0,0 @@
@import '../style/var.less';
@action-bar-button-height: 40px;
@action-bar-button-warning-color: var(--van-gradient-orange);
@action-bar-button-danger-color: var(--van-gradient-red);

View File

@ -12,7 +12,7 @@ import { Badge, type BadgeProps } from '../badge';
const [name, bem] = createNamespace('action-bar-icon'); const [name, bem] = createNamespace('action-bar-icon');
const actionBarIconProps = extend({}, routeProps, { export const actionBarIconProps = extend({}, routeProps, {
dot: Boolean, dot: Boolean,
text: String, text: String,
icon: String, icon: String,

View File

@ -1,14 +1,12 @@
@import './var.less'; body {
--van-action-bar-icon-width: 48px;
:root { --van-action-bar-icon-height: 100%;
--van-action-bar-icon-width: @action-bar-icon-width; --van-action-bar-icon-color: var(--van-text-color);
--van-action-bar-icon-height: @action-bar-icon-height; --van-action-bar-icon-size: 18px;
--van-action-bar-icon-color: @action-bar-icon-color; --van-action-bar-icon-font-size: var(--van-font-size-xs);
--van-action-bar-icon-size: @action-bar-icon-size; --van-action-bar-icon-active-color: var(--van-active-color);
--van-action-bar-icon-font-size: @action-bar-icon-font-size; --van-action-bar-icon-text-color: var(--van-text-color);
--van-action-bar-icon-active-color: @action-bar-icon-active-color; --van-action-bar-icon-background: var(--van-background-2);
--van-action-bar-icon-text-color: @action-bar-icon-text-color;
--van-action-bar-icon-background-color: @action-bar-icon-background-color;
} }
.van-action-bar-icon { .van-action-bar-icon {
@ -21,7 +19,7 @@
font-size: var(--van-action-bar-icon-font-size); font-size: var(--van-action-bar-icon-font-size);
line-height: 1; line-height: 1;
text-align: center; text-align: center;
background: var(--van-action-bar-icon-background-color); background: var(--van-action-bar-icon-background);
cursor: pointer; cursor: pointer;
&:active { &:active {

View File

@ -3,6 +3,7 @@ import _ActionBarIcon from './ActionBarIcon';
export const ActionBarIcon = withInstall(_ActionBarIcon); export const ActionBarIcon = withInstall(_ActionBarIcon);
export default ActionBarIcon; export default ActionBarIcon;
export { actionBarIconProps } from './ActionBarIcon';
export type { ActionBarIconProps } from './ActionBarIcon'; export type { ActionBarIconProps } from './ActionBarIcon';
declare module 'vue' { declare module 'vue' {

View File

@ -1,10 +0,0 @@
@import '../style/var.less';
@action-bar-icon-width: 48px;
@action-bar-icon-height: 100%;
@action-bar-icon-color: var(--van-text-color);
@action-bar-icon-size: 18px;
@action-bar-icon-font-size: var(--van-font-size-xs);
@action-bar-icon-active-color: var(--van-active-color);
@action-bar-icon-text-color: var(--van-gray-7);
@action-bar-icon-background-color: var(--van-background-color-light);

View File

@ -7,7 +7,7 @@ const [name, bem] = createNamespace('action-bar');
export const ACTION_BAR_KEY = Symbol(name); export const ACTION_BAR_KEY = Symbol(name);
const actionBarProps = { export const actionBarProps = {
placeholder: Boolean, placeholder: Boolean,
safeAreaInsetBottom: truthProp, safeAreaInsetBottom: truthProp,
}; };

View File

@ -32,12 +32,12 @@ app.use(ActionBarButton);
``` ```
```js ```js
import { Toast } from 'vant'; import { showToast } from 'vant';
export default { export default {
setup() { setup() {
const onClickIcon = () => Toast('Click Icon'); const onClickIcon = () => showToast('Click Icon');
const onClickButton = () => Toast('Click Button'); const onClickButton = () => showToast('Click Button');
return { return {
onClickIcon, onClickIcon,
onClickButton, onClickButton,
@ -155,7 +155,7 @@ The component provides the following CSS variables, which can be used to customi
| Name | Default Value | Description | | Name | Default Value | Description |
| --- | --- | --- | | --- | --- | --- |
| --van-action-bar-background-color | _var(--van-background-color-light)_ | - | | --van-action-bar-background | _var(--van-background-2)_ | - |
| --van-action-bar-height | _50px_ | - | | --van-action-bar-height | _50px_ | - |
| --van-action-bar-icon-width | _48px_ | - | | --van-action-bar-icon-width | _48px_ | - |
| --van-action-bar-icon-height | _100%_ | - | | --van-action-bar-icon-height | _100%_ | - |
@ -163,8 +163,8 @@ The component provides the following CSS variables, which can be used to customi
| --van-action-bar-icon-size | _18px_ | - | | --van-action-bar-icon-size | _18px_ | - |
| --van-action-bar-icon-font-size | _var(--van-font-size-xs)_ | - | | --van-action-bar-icon-font-size | _var(--van-font-size-xs)_ | - |
| --van-action-bar-icon-active-color | _var(--van-active-color)_ | - | | --van-action-bar-icon-active-color | _var(--van-active-color)_ | - |
| --van-action-bar-icon-text-color | _var(--van-gray-7)_ | - | | --van-action-bar-icon-text-color | _var(--van-text-color)_ | - |
| --van-action-bar-icon-background-color | _var(--van-background-color-light)_ | - | | --van-action-bar-icon-background | _var(--van-background-2)_ | - |
| --van-action-bar-button-height | _40px_ | - | | --van-action-bar-button-height | _40px_ | - |
| --van-action-bar-button-warning-color | _var(--van-gradient-orange)_ | - | | --van-action-bar-button-warning-color | _var(--van-gradient-orange)_ | - |
| --van-action-bar-button-danger-color | _var(--van-gradient-red)_ | - | | --van-action-bar-button-danger-color | _var(--van-gradient-red)_ | - |

View File

@ -32,12 +32,12 @@ app.use(ActionBarButton);
``` ```
```js ```js
import { Toast } from 'vant'; import { showToast } from 'vant';
export default { export default {
setup() { setup() {
const onClickIcon = () => Toast('点击图标'); const onClickIcon = () => showToast('点击图标');
const onClickButton = () => Toast('点击按钮'); const onClickButton = () => showToast('点击按钮');
return { return {
onClickIcon, onClickIcon,
onClickButton, onClickButton,
@ -158,8 +158,8 @@ import type {
组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](#/zh-CN/config-provider)。 组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](#/zh-CN/config-provider)。
| 名称 | 默认值 | 描述 | | 名称 | 默认值 | 描述 |
| --- | --- | --- | | ------------------------------------- | ---------------------------- | ---- |
| --van-action-bar-background-color | _var(--van-background-color-light)_ | - | | --van-action-bar-background | _var(--van-background-2)_ | - |
| --van-action-bar-height | _50px_ | - | | --van-action-bar-height | _50px_ | - |
| --van-action-bar-icon-width | _48px_ | - | | --van-action-bar-icon-width | _48px_ | - |
| --van-action-bar-icon-height | _100%_ | - | | --van-action-bar-icon-height | _100%_ | - |
@ -167,8 +167,8 @@ import type {
| --van-action-bar-icon-size | _18px_ | - | | --van-action-bar-icon-size | _18px_ | - |
| --van-action-bar-icon-font-size | _var(--van-font-size-xs)_ | - | | --van-action-bar-icon-font-size | _var(--van-font-size-xs)_ | - |
| --van-action-bar-icon-active-color | _var(--van-active-color)_ | - | | --van-action-bar-icon-active-color | _var(--van-active-color)_ | - |
| --van-action-bar-icon-text-color | _var(--van-gray-7)_ | - | | --van-action-bar-icon-text-color | _var(--van-text-color)_ | - |
| --van-action-bar-icon-background-color | _var(--van-background-color-light)_ | - | | --van-action-bar-icon-background | _var(--van-background-2)_ | - |
| --van-action-bar-button-height | _40px_ | - | | --van-action-bar-button-height | _40px_ | - |
| --van-action-bar-button-warning-color | _var(--van-gradient-orange)_ | - | | --van-action-bar-button-warning-color | _var(--van-gradient-orange)_ | - |
| --van-action-bar-button-danger-color | _var(--van-gradient-red)_ | - | | --van-action-bar-button-danger-color | _var(--van-gradient-red)_ | - |

View File

@ -3,7 +3,7 @@ import VanActionBar from '..';
import VanActionBarIcon from '../../action-bar-icon'; import VanActionBarIcon from '../../action-bar-icon';
import VanActionBarButton from '../../action-bar-button'; import VanActionBarButton from '../../action-bar-button';
import { useTranslate } from '../../../docs/site'; import { useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { showToast } from '../../toast';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {
@ -33,8 +33,8 @@ const t = useTranslate({
customButtonColor: 'Custom Button Color', customButtonColor: 'Custom Button Color',
}, },
}); });
const onClickIcon = () => Toast(t('clickIcon')); const onClickIcon = () => showToast(t('clickIcon'));
const onClickButton = () => Toast(t('clickButton')); const onClickButton = () => showToast(t('clickButton'));
</script> </script>
<template> <template>

View File

@ -1,8 +1,6 @@
@import './var.less'; body {
--van-action-bar-background: var(--van-background-2);
:root { --van-action-bar-height: 50px;
--van-action-bar-background-color: @action-bar-background-color;
--van-action-bar-height: @action-bar-height;
} }
.van-action-bar { .van-action-bar {
@ -14,5 +12,5 @@
align-items: center; align-items: center;
box-sizing: content-box; box-sizing: content-box;
height: var(--van-action-bar-height); height: var(--van-action-bar-height);
background: var(--van-action-bar-background-color); background: var(--van-action-bar-background);
} }

View File

@ -3,6 +3,7 @@ import _ActionBar from './ActionBar';
export const ActionBar = withInstall(_ActionBar); export const ActionBar = withInstall(_ActionBar);
export default ActionBar; export default ActionBar;
export { actionBarProps } from './ActionBar';
export type { ActionBarProps } from './ActionBar'; export type { ActionBarProps } from './ActionBar';
declare module 'vue' { declare module 'vue' {

View File

@ -1,4 +0,0 @@
@import '../style/var.less';
@action-bar-background-color: var(--van-background-color-light);
@action-bar-height: 50px;

View File

@ -29,7 +29,7 @@ export type ActionSheetAction = {
className?: unknown; className?: unknown;
}; };
const actionSheetProps = extend({}, popupSharedProps, { export const actionSheetProps = extend({}, popupSharedProps, {
title: String, title: String,
round: truthProp, round: truthProp,
actions: makeArrayProp<ActionSheetAction>(), actions: makeArrayProp<ActionSheetAction>(),

View File

@ -29,7 +29,7 @@ Use `actions` prop to set options of action-sheet.
```js ```js
import { ref } from 'vue'; import { ref } from 'vue';
import { Toast } from 'vant'; import { showToast } from 'vant';
export default { export default {
setup() { setup() {
@ -41,7 +41,7 @@ export default {
]; ];
const onSelect = (item) => { const onSelect = (item) => {
show.value = false; show.value = false;
Toast(item.name); showToast(item.name);
}; };
return { return {
@ -67,7 +67,7 @@ export default {
```js ```js
import { ref } from 'vue'; import { ref } from 'vue';
import { Toast } from 'vant'; import { showToast } from 'vant';
export default { export default {
setup() { setup() {
@ -77,7 +77,7 @@ export default {
{ name: 'Option 2' }, { name: 'Option 2' },
{ name: 'Option 3' }, { name: 'Option 3' },
]; ];
const onCancel = () => Toast('cancel'); const onCancel = () => showToast('cancel');
return { return {
show, show,
@ -247,7 +247,7 @@ The component provides the following CSS variables, which can be used to customi
| --van-action-sheet-description-color | _var(--van-text-color-2)_ | - | | --van-action-sheet-description-color | _var(--van-text-color-2)_ | - |
| --van-action-sheet-description-font-size | _var(--van-font-size-md)_ | - | | --van-action-sheet-description-font-size | _var(--van-font-size-md)_ | - |
| --van-action-sheet-description-line-height | _var(--van-line-height-md)_ | - | | --van-action-sheet-description-line-height | _var(--van-line-height-md)_ | - |
| --van-action-sheet-item-background | _var(--van-background-color-light)_ | - | | --van-action-sheet-item-background | _var(--van-background-2)_ | - |
| --van-action-sheet-item-font-size | _var(--van-font-size-lg)_ | - | | --van-action-sheet-item-font-size | _var(--van-font-size-lg)_ | - |
| --van-action-sheet-item-line-height | _var(--van-line-height-lg)_ | - | | --van-action-sheet-item-line-height | _var(--van-line-height-lg)_ | - |
| --van-action-sheet-item-text-color | _var(--van-text-color)_ | - | | --van-action-sheet-item-text-color | _var(--van-text-color)_ | - |
@ -260,5 +260,5 @@ The component provides the following CSS variables, which can be used to customi
| --van-action-sheet-close-icon-padding | _0 var(--van-padding-md)_ | - | | --van-action-sheet-close-icon-padding | _0 var(--van-padding-md)_ | - |
| --van-action-sheet-cancel-text-color | _var(--van-gray-7)_ | - | | --van-action-sheet-cancel-text-color | _var(--van-gray-7)_ | - |
| --van-action-sheet-cancel-padding-top | _var(--van-padding-xs)_ | - | | --van-action-sheet-cancel-padding-top | _var(--van-padding-xs)_ | - |
| --van-action-sheet-cancel-padding-color | _var(--van-background-color)_ | - | | --van-action-sheet-cancel-padding-color | _var(--van-background)_ | - |
| --van-action-sheet-loading-icon-size | _22px_ | - | | --van-action-sheet-loading-icon-size | _22px_ | - |

View File

@ -29,7 +29,7 @@ app.use(ActionSheet);
```js ```js
import { ref } from 'vue'; import { ref } from 'vue';
import { Toast } from 'vant'; import { showToast } from 'vant';
export default { export default {
setup() { setup() {
@ -43,7 +43,7 @@ export default {
// 默认情况下点击选项时不会自动收起 // 默认情况下点击选项时不会自动收起
// 可以通过 close-on-click-action 属性开启自动收起 // 可以通过 close-on-click-action 属性开启自动收起
show.value = false; show.value = false;
Toast(item.name); showToast(item.name);
}; };
return { return {
@ -71,7 +71,7 @@ export default {
```js ```js
import { ref } from 'vue'; import { ref } from 'vue';
import { Toast } from 'vant'; import { showToast } from 'vant';
export default { export default {
setup() { setup() {
@ -81,7 +81,7 @@ export default {
{ name: '选项二' }, { name: '选项二' },
{ name: '选项三' }, { name: '选项三' },
]; ];
const onCancel = () => Toast('取消'); const onCancel = () => showToast('取消');
return { return {
show, show,
@ -259,7 +259,7 @@ import type { ActionSheetProps, ActionSheetAction } from 'vant';
| --van-action-sheet-description-color | _var(--van-text-color-2)_ | - | | --van-action-sheet-description-color | _var(--van-text-color-2)_ | - |
| --van-action-sheet-description-font-size | _var(--van-font-size-md)_ | - | | --van-action-sheet-description-font-size | _var(--van-font-size-md)_ | - |
| --van-action-sheet-description-line-height | _var(--van-line-height-md)_ | - | | --van-action-sheet-description-line-height | _var(--van-line-height-md)_ | - |
| --van-action-sheet-item-background | _var(--van-background-color-light)_ | - | | --van-action-sheet-item-background | _var(--van-background-2)_ | - |
| --van-action-sheet-item-font-size | _var(--van-font-size-lg)_ | - | | --van-action-sheet-item-font-size | _var(--van-font-size-lg)_ | - |
| --van-action-sheet-item-line-height | _var(--van-line-height-lg)_ | - | | --van-action-sheet-item-line-height | _var(--van-line-height-lg)_ | - |
| --van-action-sheet-item-text-color | _var(--van-text-color)_ | - | | --van-action-sheet-item-text-color | _var(--van-text-color)_ | - |
@ -272,5 +272,5 @@ import type { ActionSheetProps, ActionSheetAction } from 'vant';
| --van-action-sheet-close-icon-padding | _0 var(--van-padding-md)_ | - | | --van-action-sheet-close-icon-padding | _0 var(--van-padding-md)_ | - |
| --van-action-sheet-cancel-text-color | _var(--van-gray-7)_ | - | | --van-action-sheet-cancel-text-color | _var(--van-gray-7)_ | - |
| --van-action-sheet-cancel-padding-top | _var(--van-padding-xs)_ | - | | --van-action-sheet-cancel-padding-top | _var(--van-padding-xs)_ | - |
| --van-action-sheet-cancel-padding-color | _var(--van-background-color)_ | - | | --van-action-sheet-cancel-padding-color | _var(--van-background)_ | - |
| --van-action-sheet-loading-icon-size | _22px_ | - | | --van-action-sheet-loading-icon-size | _22px_ | - |

View File

@ -3,7 +3,7 @@ import VanCell from '../../cell';
import VanActionSheet, { ActionSheetAction } from '..'; import VanActionSheet, { ActionSheetAction } from '..';
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
import { useTranslate } from '../../../docs/site'; import { useTranslate } from '../../../docs/site';
import { Toast } from '../../toast'; import { showToast } from '../../toast';
const t = useTranslate({ const t = useTranslate({
'zh-CN': { 'zh-CN': {
@ -61,10 +61,10 @@ const actionsWithDescription = computed<ActionSheetAction[]>(() => [
const onSelect = (item: ActionSheetAction) => { const onSelect = (item: ActionSheetAction) => {
showBasic.value = false; showBasic.value = false;
Toast(item.name); showToast(item.name);
}; };
const onCancel = () => Toast(t('cancel')); const onCancel = () => showToast(t('cancel'));
</script> </script>
<template> <template>

View File

@ -1,28 +1,27 @@
@import './var.less';
@import '../style/mixins/hairline'; @import '../style/mixins/hairline';
:root { body {
--van-action-sheet-max-height: @action-sheet-max-height; --van-action-sheet-max-height: 80%;
--van-action-sheet-header-height: @action-sheet-header-height; --van-action-sheet-header-height: 48px;
--van-action-sheet-header-font-size: @action-sheet-header-font-size; --van-action-sheet-header-font-size: var(--van-font-size-lg);
--van-action-sheet-description-color: @action-sheet-description-color; --van-action-sheet-description-color: var(--van-text-color-2);
--van-action-sheet-description-font-size: @action-sheet-description-font-size; --van-action-sheet-description-font-size: var(--van-font-size-md);
--van-action-sheet-description-line-height: @action-sheet-description-line-height; --van-action-sheet-description-line-height: var(--van-line-height-md);
--van-action-sheet-item-background: @action-sheet-item-background; --van-action-sheet-item-background: var(--van-background-2);
--van-action-sheet-item-font-size: @action-sheet-item-font-size; --van-action-sheet-item-font-size: var(--van-font-size-lg);
--van-action-sheet-item-line-height: @action-sheet-item-line-height; --van-action-sheet-item-line-height: var(--van-line-height-lg);
--van-action-sheet-item-text-color: @action-sheet-item-text-color; --van-action-sheet-item-text-color: var(--van-text-color);
--van-action-sheet-item-disabled-text-color: @action-sheet-item-disabled-text-color; --van-action-sheet-item-disabled-text-color: var(--van-text-color-3);
--van-action-sheet-subname-color: @action-sheet-subname-color; --van-action-sheet-subname-color: var(--van-text-color-2);
--van-action-sheet-subname-font-size: @action-sheet-subname-font-size; --van-action-sheet-subname-font-size: var(--van-font-size-sm);
--van-action-sheet-subname-line-height: @action-sheet-subname-line-height; --van-action-sheet-subname-line-height: var(--van-line-height-sm);
--van-action-sheet-close-icon-size: @action-sheet-close-icon-size; --van-action-sheet-close-icon-size: 22px;
--van-action-sheet-close-icon-color: @action-sheet-close-icon-color; --van-action-sheet-close-icon-color: var(--van-gray-5);
--van-action-sheet-close-icon-padding: @action-sheet-close-icon-padding; --van-action-sheet-close-icon-padding: 0 var(--van-padding-md);
--van-action-sheet-cancel-text-color: @action-sheet-cancel-text-color; --van-action-sheet-cancel-text-color: var(--van-gray-7);
--van-action-sheet-cancel-padding-top: @action-sheet-cancel-padding-top; --van-action-sheet-cancel-padding-top: var(--van-padding-xs);
--van-action-sheet-cancel-padding-color: @action-sheet-cancel-padding-color; --van-action-sheet-cancel-padding-color: var(--van-background);
--van-action-sheet-loading-icon-size: @action-sheet-loading-icon-size; --van-action-sheet-loading-icon-size: 22px;
} }
.van-action-sheet { .van-action-sheet {
@ -95,7 +94,7 @@
&__header { &__header {
flex-shrink: 0; flex-shrink: 0;
font-weight: var(--van-font-weight-bold); font-weight: var(--van-font-bold);
font-size: var(--van-action-sheet-header-font-size); font-size: var(--van-action-sheet-header-font-size);
line-height: var(--van-action-sheet-header-height); line-height: var(--van-action-sheet-header-height);
text-align: center; text-align: center;

View File

@ -3,6 +3,7 @@ import _ActionSheet from './ActionSheet';
export const ActionSheet = withInstall(_ActionSheet); export const ActionSheet = withInstall(_ActionSheet);
export default ActionSheet; export default ActionSheet;
export { actionSheetProps } from './ActionSheet';
export type { ActionSheetProps, ActionSheetAction } from './ActionSheet'; export type { ActionSheetProps, ActionSheetAction } from './ActionSheet';
declare module 'vue' { declare module 'vue' {

View File

@ -67,23 +67,33 @@ exports[`should render demo and match snapshot 1`] = `
</i> </i>
</div> </div>
</div> </div>
<transition-stub> <transition-stub role="button"
tabindex="0"
>
</transition-stub> </transition-stub>
<transition-stub> <transition-stub>
</transition-stub> </transition-stub>
<transition-stub> <transition-stub role="button"
tabindex="0"
>
</transition-stub> </transition-stub>
<transition-stub> <transition-stub>
</transition-stub> </transition-stub>
<transition-stub> <transition-stub role="button"
tabindex="0"
>
</transition-stub> </transition-stub>
<transition-stub> <transition-stub>
</transition-stub> </transition-stub>
<transition-stub> <transition-stub role="button"
tabindex="0"
>
</transition-stub> </transition-stub>
<transition-stub> <transition-stub>
</transition-stub> </transition-stub>
<transition-stub> <transition-stub role="button"
tabindex="0"
>
</transition-stub> </transition-stub>
<transition-stub> <transition-stub>
</transition-stub> </transition-stub>

View File

@ -22,12 +22,17 @@ exports[`should render cancel slot correctly 1`] = `
`; `;
exports[`should render default slot correctly 1`] = ` exports[`should render default slot correctly 1`] = `
<transition-stub> <transition-stub role="button"
tabindex="0"
>
<div class="van-overlay"> <div class="van-overlay">
</div> </div>
</transition-stub> </transition-stub>
<transition-stub> <transition-stub>
<div class="van-popup van-popup--round van-popup--bottom van-safe-area-bottom van-action-sheet"> <div role="dialog"
tabindex="0"
class="van-popup van-popup--round van-popup--bottom van-safe-area-bottom van-action-sheet"
>
<div class="van-action-sheet__header"> <div class="van-action-sheet__header">
Title Title
<i class="van-badge__wrapper van-icon van-icon-cross van-action-sheet__close van-haptics-feedback"> <i class="van-badge__wrapper van-icon van-icon-cross van-action-sheet__close van-haptics-feedback">

Some files were not shown because too many files have changed in this diff Show More