@nori-ui/core 0.0.5 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/animated-view.cjs +13 -0
- package/dist/animation/animated-view.cjs.map +1 -0
- package/dist/animation/animated-view.d.cts +6 -0
- package/dist/animation/animated-view.d.ts +6 -0
- package/dist/animation/animated-view.js +4 -0
- package/dist/animation/animated-view.js.map +1 -0
- package/dist/animation/animated-view.web.cjs +9 -0
- package/dist/animation/animated-view.web.cjs.map +1 -0
- package/dist/animation/animated-view.web.d.cts +5 -0
- package/dist/animation/animated-view.web.d.ts +5 -0
- package/dist/animation/animated-view.web.js +8 -0
- package/dist/animation/animated-view.web.js.map +1 -0
- package/dist/animation/use-animated-number.cjs +80 -0
- package/dist/animation/use-animated-number.cjs.map +1 -0
- package/dist/animation/use-animated-number.d.cts +8 -0
- package/dist/animation/use-animated-number.d.ts +8 -0
- package/dist/animation/use-animated-number.js +4 -0
- package/dist/animation/use-animated-number.js.map +1 -0
- package/dist/animation/use-animated-number.web.cjs +28 -0
- package/dist/animation/use-animated-number.web.cjs.map +1 -0
- package/dist/animation/use-animated-number.web.d.cts +8 -0
- package/dist/animation/use-animated-number.web.d.ts +8 -0
- package/dist/animation/use-animated-number.web.js +25 -0
- package/dist/animation/use-animated-number.web.js.map +1 -0
- package/dist/{chunk-RX7UULY3.js → chunk-33S7ADWM.js} +3 -3
- package/dist/{chunk-RX7UULY3.js.map → chunk-33S7ADWM.js.map} +1 -1
- package/dist/chunk-3BDDPFCI.js +108 -0
- package/dist/chunk-3BDDPFCI.js.map +1 -0
- package/dist/chunk-3F4TXKDY.js +314 -0
- package/dist/chunk-3F4TXKDY.js.map +1 -0
- package/dist/chunk-5A2QOOVN.js +15 -0
- package/dist/chunk-5A2QOOVN.js.map +1 -0
- package/dist/chunk-5XEGZFG5.js +208 -0
- package/dist/chunk-5XEGZFG5.js.map +1 -0
- package/dist/chunk-6AD6KCVB.js +178 -0
- package/dist/chunk-6AD6KCVB.js.map +1 -0
- package/dist/chunk-7GPDNQSX.js +967 -0
- package/dist/chunk-7GPDNQSX.js.map +1 -0
- package/dist/chunk-7UKRN73P.js +42 -0
- package/dist/chunk-7UKRN73P.js.map +1 -0
- package/dist/chunk-7Z4NMNX6.js +64 -0
- package/dist/chunk-7Z4NMNX6.js.map +1 -0
- package/dist/chunk-ACLHDHX3.js +29 -0
- package/dist/chunk-ACLHDHX3.js.map +1 -0
- package/dist/chunk-BZLT6R62.js +80 -0
- package/dist/chunk-BZLT6R62.js.map +1 -0
- package/dist/chunk-CCUXO2HN.js +450 -0
- package/dist/chunk-CCUXO2HN.js.map +1 -0
- package/dist/chunk-CHXHRJNZ.js +43 -0
- package/dist/chunk-CHXHRJNZ.js.map +1 -0
- package/dist/chunk-DDGMLLS3.js +188 -0
- package/dist/chunk-DDGMLLS3.js.map +1 -0
- package/dist/chunk-EWWQQ5DB.js +654 -0
- package/dist/chunk-EWWQQ5DB.js.map +1 -0
- package/dist/chunk-FEPTH5RV.js +169 -0
- package/dist/chunk-FEPTH5RV.js.map +1 -0
- package/dist/{chunk-SSTXLK5I.js → chunk-FT2XBBQJ.js} +42 -6
- package/dist/chunk-FT2XBBQJ.js.map +1 -0
- package/dist/chunk-IKLA2CVQ.js +260 -0
- package/dist/chunk-IKLA2CVQ.js.map +1 -0
- package/dist/chunk-JQQ3FBN7.js +18 -0
- package/dist/chunk-JQQ3FBN7.js.map +1 -0
- package/dist/chunk-JSAG5YO7.js +69 -0
- package/dist/chunk-JSAG5YO7.js.map +1 -0
- package/dist/chunk-JZ774T7U.js +76 -0
- package/dist/chunk-JZ774T7U.js.map +1 -0
- package/dist/chunk-KWRDJPP3.js +10 -0
- package/dist/chunk-KWRDJPP3.js.map +1 -0
- package/dist/chunk-LVWNMQGR.js +1106 -0
- package/dist/chunk-LVWNMQGR.js.map +1 -0
- package/dist/chunk-LWLK6HSW.js +143 -0
- package/dist/chunk-LWLK6HSW.js.map +1 -0
- package/dist/chunk-MDOZGILD.js +134 -0
- package/dist/chunk-MDOZGILD.js.map +1 -0
- package/dist/chunk-MKSDYRWQ.js +446 -0
- package/dist/chunk-MKSDYRWQ.js.map +1 -0
- package/dist/chunk-MRJWPRCX.js +80 -0
- package/dist/chunk-MRJWPRCX.js.map +1 -0
- package/dist/chunk-NRYWNOG5.js +410 -0
- package/dist/chunk-NRYWNOG5.js.map +1 -0
- package/dist/chunk-OMU4R4Y5.js +144 -0
- package/dist/chunk-OMU4R4Y5.js.map +1 -0
- package/dist/chunk-PNP7L4TA.js +103 -0
- package/dist/chunk-PNP7L4TA.js.map +1 -0
- package/dist/chunk-QI6646JZ.js +3 -0
- package/dist/{chunk-UAKFCMWK.js.map → chunk-QI6646JZ.js.map} +1 -1
- package/dist/chunk-QJNV7YQP.js +138 -0
- package/dist/chunk-QJNV7YQP.js.map +1 -0
- package/dist/chunk-R5JMDDCB.js +292 -0
- package/dist/chunk-R5JMDDCB.js.map +1 -0
- package/dist/chunk-RB3YBWQ4.js +77 -0
- package/dist/chunk-RB3YBWQ4.js.map +1 -0
- package/dist/chunk-RFW5SRZA.js +23 -0
- package/dist/chunk-RFW5SRZA.js.map +1 -0
- package/dist/chunk-RGJ3NBKE.js +8 -0
- package/dist/chunk-RGJ3NBKE.js.map +1 -0
- package/dist/chunk-SFNDR6DI.js +485 -0
- package/dist/chunk-SFNDR6DI.js.map +1 -0
- package/dist/chunk-SWC5CNKE.js +13 -0
- package/dist/chunk-SWC5CNKE.js.map +1 -0
- package/dist/chunk-TLS54G6Y.js +15 -0
- package/dist/chunk-TLS54G6Y.js.map +1 -0
- package/dist/chunk-WCQVDF3K.js +12 -0
- package/dist/{chunk-7QVYU63E.js.map → chunk-WCQVDF3K.js.map} +1 -1
- package/dist/chunk-WGT345SV.js +427 -0
- package/dist/chunk-WGT345SV.js.map +1 -0
- package/dist/chunk-X7APG7G2.js +1566 -0
- package/dist/chunk-X7APG7G2.js.map +1 -0
- package/dist/chunk-XALU6LOT.js +306 -0
- package/dist/chunk-XALU6LOT.js.map +1 -0
- package/dist/chunk-YNKKEO2A.js +336 -0
- package/dist/chunk-YNKKEO2A.js.map +1 -0
- package/dist/chunk-ZBW3BA5R.js +148 -0
- package/dist/chunk-ZBW3BA5R.js.map +1 -0
- package/dist/{chunk-FXKIWONG.js → chunk-ZIBNLXIV.js} +12 -6
- package/dist/chunk-ZIBNLXIV.js.map +1 -0
- package/dist/chunk-ZMSIYLSI.js +563 -0
- package/dist/chunk-ZMSIYLSI.js.map +1 -0
- package/dist/chunk-ZQMNGPLE.js +981 -0
- package/dist/chunk-ZQMNGPLE.js.map +1 -0
- package/dist/chunk-ZRD4FQBT.js +153 -0
- package/dist/chunk-ZRD4FQBT.js.map +1 -0
- package/dist/client.cjs +11289 -439
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +68 -117
- package/dist/client.d.ts +68 -117
- package/dist/client.js +58 -40
- package/dist/client.js.map +1 -1
- package/dist/components/Accordion/index.cjs +900 -0
- package/dist/components/Accordion/index.cjs.map +1 -0
- package/dist/components/Accordion/index.d.cts +72 -0
- package/dist/components/Accordion/index.d.ts +72 -0
- package/dist/components/Accordion/index.js +10 -0
- package/dist/components/Accordion/index.js.map +1 -0
- package/dist/components/Alert/index.cjs +567 -0
- package/dist/components/Alert/index.cjs.map +1 -0
- package/dist/components/Alert/index.d.cts +41 -0
- package/dist/components/Alert/index.d.ts +41 -0
- package/dist/components/Alert/index.js +8 -0
- package/dist/components/Alert/index.js.map +1 -0
- package/dist/components/AlertDialog/index.cjs +892 -0
- package/dist/components/AlertDialog/index.cjs.map +1 -0
- package/dist/components/AlertDialog/index.d.cts +68 -0
- package/dist/components/AlertDialog/index.d.ts +68 -0
- package/dist/components/AlertDialog/index.js +9 -0
- package/dist/components/AlertDialog/index.js.map +1 -0
- package/dist/components/Avatar/index.cjs +427 -0
- package/dist/components/Avatar/index.cjs.map +1 -0
- package/dist/components/Avatar/index.d.cts +40 -0
- package/dist/components/Avatar/index.d.ts +40 -0
- package/dist/components/Avatar/index.js +7 -0
- package/dist/components/Avatar/index.js.map +1 -0
- package/dist/components/Badge/index.cjs +433 -0
- package/dist/components/Badge/index.cjs.map +1 -0
- package/dist/components/Badge/index.d.cts +35 -0
- package/dist/components/Badge/index.d.ts +35 -0
- package/dist/components/Badge/index.js +7 -0
- package/dist/components/Badge/index.js.map +1 -0
- package/dist/components/Box/index.cjs +415 -0
- package/dist/components/Box/index.cjs.map +1 -0
- package/dist/components/Box/index.d.cts +24 -0
- package/dist/components/Box/index.d.ts +24 -0
- package/dist/components/Box/index.js +9 -0
- package/dist/components/Box/index.js.map +1 -0
- package/dist/components/Breadcrumb/index.cjs +1939 -0
- package/dist/components/Breadcrumb/index.cjs.map +1 -0
- package/dist/components/Breadcrumb/index.d.cts +186 -0
- package/dist/components/Breadcrumb/index.d.ts +186 -0
- package/dist/components/Breadcrumb/index.js +11 -0
- package/dist/components/Breadcrumb/index.js.map +1 -0
- package/dist/components/Button/index.cjs +631 -0
- package/dist/components/Button/index.cjs.map +1 -0
- package/dist/components/Button/index.d.cts +27 -0
- package/dist/components/Button/index.d.ts +27 -0
- package/dist/components/Button/index.js +9 -0
- package/dist/components/Button/index.js.map +1 -0
- package/dist/components/Calendar/index.cjs +3017 -0
- package/dist/components/Calendar/index.cjs.map +1 -0
- package/dist/components/Calendar/index.d.cts +169 -0
- package/dist/components/Calendar/index.d.ts +169 -0
- package/dist/components/Calendar/index.js +11 -0
- package/dist/components/Calendar/index.js.map +1 -0
- package/dist/components/Card/index.cjs +469 -0
- package/dist/components/Card/index.cjs.map +1 -0
- package/dist/components/Card/index.d.cts +33 -0
- package/dist/components/Card/index.d.ts +33 -0
- package/dist/components/Card/index.js +7 -0
- package/dist/components/Card/index.js.map +1 -0
- package/dist/components/Checkbox/index.cjs +590 -0
- package/dist/components/Checkbox/index.cjs.map +1 -0
- package/dist/components/Checkbox/index.d.cts +22 -0
- package/dist/components/Checkbox/index.d.ts +22 -0
- package/dist/components/Checkbox/index.js +9 -0
- package/dist/components/Checkbox/index.js.map +1 -0
- package/dist/components/Dialog/index.cjs +888 -0
- package/dist/components/Dialog/index.cjs.map +1 -0
- package/dist/components/Dialog/index.d.cts +56 -0
- package/dist/components/Dialog/index.d.ts +56 -0
- package/dist/components/Dialog/index.js +10 -0
- package/dist/components/Dialog/index.js.map +1 -0
- package/dist/components/FloatButton/index.cjs +1254 -0
- package/dist/components/FloatButton/index.cjs.map +1 -0
- package/dist/components/FloatButton/index.d.cts +133 -0
- package/dist/components/FloatButton/index.d.ts +133 -0
- package/dist/components/FloatButton/index.js +11 -0
- package/dist/components/FloatButton/index.js.map +1 -0
- package/dist/components/HStack/index.cjs +480 -0
- package/dist/components/HStack/index.cjs.map +1 -0
- package/dist/components/HStack/index.d.cts +24 -0
- package/dist/components/HStack/index.d.ts +24 -0
- package/dist/components/HStack/index.js +9 -0
- package/dist/components/HStack/index.js.map +1 -0
- package/dist/components/InputGroup/index.cjs +638 -0
- package/dist/components/InputGroup/index.cjs.map +1 -0
- package/dist/components/InputGroup/index.d.cts +33 -0
- package/dist/components/InputGroup/index.d.ts +33 -0
- package/dist/components/InputGroup/index.js +7 -0
- package/dist/components/InputGroup/index.js.map +1 -0
- package/dist/components/Pagination/index.cjs +2501 -0
- package/dist/components/Pagination/index.cjs.map +1 -0
- package/dist/components/Pagination/index.d.cts +164 -0
- package/dist/components/Pagination/index.d.ts +164 -0
- package/dist/components/Pagination/index.js +12 -0
- package/dist/components/Pagination/index.js.map +1 -0
- package/dist/components/Popover/index.cjs +739 -0
- package/dist/components/Popover/index.cjs.map +1 -0
- package/dist/components/Popover/index.d.cts +44 -0
- package/dist/components/Popover/index.d.ts +44 -0
- package/dist/components/Popover/index.js +8 -0
- package/dist/components/Popover/index.js.map +1 -0
- package/dist/components/Progress/index.cjs +493 -0
- package/dist/components/Progress/index.cjs.map +1 -0
- package/dist/components/Progress/index.d.cts +63 -0
- package/dist/components/Progress/index.d.ts +63 -0
- package/dist/components/Progress/index.js +7 -0
- package/dist/components/Progress/index.js.map +1 -0
- package/dist/components/Radio/index.cjs +584 -0
- package/dist/components/Radio/index.cjs.map +1 -0
- package/dist/components/Radio/index.d.cts +51 -0
- package/dist/components/Radio/index.d.ts +51 -0
- package/dist/components/Radio/index.js +7 -0
- package/dist/components/Radio/index.js.map +1 -0
- package/dist/components/SegmentedControl/index.cjs +502 -0
- package/dist/components/SegmentedControl/index.cjs.map +1 -0
- package/dist/components/SegmentedControl/index.d.cts +45 -0
- package/dist/components/SegmentedControl/index.d.ts +45 -0
- package/dist/components/SegmentedControl/index.js +7 -0
- package/dist/components/SegmentedControl/index.js.map +1 -0
- package/dist/components/Select/index.cjs +1359 -0
- package/dist/components/Select/index.cjs.map +1 -0
- package/dist/components/Select/index.d.cts +140 -0
- package/dist/components/Select/index.d.ts +140 -0
- package/dist/components/Select/index.js +8 -0
- package/dist/components/Select/index.js.map +1 -0
- package/dist/components/Separator/index.cjs +358 -0
- package/dist/components/Separator/index.cjs.map +1 -0
- package/dist/components/Separator/index.d.cts +28 -0
- package/dist/components/Separator/index.d.ts +28 -0
- package/dist/components/Separator/index.js +6 -0
- package/dist/components/Separator/index.js.map +1 -0
- package/dist/components/Skeleton/index.cjs +384 -0
- package/dist/components/Skeleton/index.cjs.map +1 -0
- package/dist/components/Skeleton/index.d.cts +30 -0
- package/dist/components/Skeleton/index.d.ts +30 -0
- package/dist/components/Skeleton/index.js +6 -0
- package/dist/components/Skeleton/index.js.map +1 -0
- package/dist/components/Slider/index.cjs +880 -0
- package/dist/components/Slider/index.cjs.map +1 -0
- package/dist/components/Slider/index.d.cts +84 -0
- package/dist/components/Slider/index.d.ts +84 -0
- package/dist/components/Slider/index.js +6 -0
- package/dist/components/Slider/index.js.map +1 -0
- package/dist/components/Spinner/index.cjs +32 -0
- package/dist/components/Spinner/index.cjs.map +1 -0
- package/dist/components/Spinner/index.d.cts +25 -0
- package/dist/components/Spinner/index.d.ts +25 -0
- package/dist/components/Spinner/index.js +4 -0
- package/dist/components/Spinner/index.js.map +1 -0
- package/dist/components/Switch/index.cjs +623 -0
- package/dist/components/Switch/index.cjs.map +1 -0
- package/dist/components/Switch/index.d.cts +22 -0
- package/dist/components/Switch/index.d.ts +22 -0
- package/dist/components/Switch/index.js +10 -0
- package/dist/components/Switch/index.js.map +1 -0
- package/dist/components/Tabs/index.cjs +630 -0
- package/dist/components/Tabs/index.cjs.map +1 -0
- package/dist/components/Tabs/index.d.cts +63 -0
- package/dist/components/Tabs/index.d.ts +63 -0
- package/dist/components/Tabs/index.js +7 -0
- package/dist/components/Tabs/index.js.map +1 -0
- package/dist/components/Text/index.cjs +401 -0
- package/dist/components/Text/index.cjs.map +1 -0
- package/dist/components/Text/index.d.cts +24 -0
- package/dist/components/Text/index.d.ts +24 -0
- package/dist/components/Text/index.js +7 -0
- package/dist/components/Text/index.js.map +1 -0
- package/dist/components/TextArea/index.cjs +482 -0
- package/dist/components/TextArea/index.cjs.map +1 -0
- package/dist/components/TextArea/index.d.cts +25 -0
- package/dist/components/TextArea/index.d.ts +25 -0
- package/dist/components/TextArea/index.js +8 -0
- package/dist/components/TextArea/index.js.map +1 -0
- package/dist/components/TextInput/index.cjs +477 -0
- package/dist/components/TextInput/index.cjs.map +1 -0
- package/dist/components/TextInput/index.d.cts +33 -0
- package/dist/components/TextInput/index.d.ts +33 -0
- package/dist/components/TextInput/index.js +7 -0
- package/dist/components/TextInput/index.js.map +1 -0
- package/dist/components/Toast/index.cjs +167 -0
- package/dist/components/Toast/index.cjs.map +1 -0
- package/dist/components/Toast/index.d.cts +143 -0
- package/dist/components/Toast/index.d.ts +143 -0
- package/dist/components/Toast/index.js +4 -0
- package/dist/components/Toast/index.js.map +1 -0
- package/dist/components/Toggle/index.cjs +770 -0
- package/dist/components/Toggle/index.cjs.map +1 -0
- package/dist/components/Toggle/index.d.cts +83 -0
- package/dist/components/Toggle/index.d.ts +83 -0
- package/dist/components/Toggle/index.js +7 -0
- package/dist/components/Toggle/index.js.map +1 -0
- package/dist/components/Tooltip/index.cjs +813 -0
- package/dist/components/Tooltip/index.cjs.map +1 -0
- package/dist/components/Tooltip/index.d.cts +55 -0
- package/dist/components/Tooltip/index.d.ts +55 -0
- package/dist/components/Tooltip/index.js +8 -0
- package/dist/components/Tooltip/index.js.map +1 -0
- package/dist/components/VStack/index.cjs +480 -0
- package/dist/components/VStack/index.cjs.map +1 -0
- package/dist/components/VStack/index.d.cts +19 -0
- package/dist/components/VStack/index.d.ts +19 -0
- package/dist/components/VStack/index.js +9 -0
- package/dist/components/VStack/index.js.map +1 -0
- package/dist/i18n/index.cjs +39 -3
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/i18n/index.d.cts +4 -60
- package/dist/i18n/index.d.ts +4 -60
- package/dist/i18n/index.js +3 -2
- package/dist/icons/index.cjs +326 -26
- package/dist/icons/index.cjs.map +1 -1
- package/dist/icons/index.js +4 -3
- package/dist/index-D3_M3G6U.d.ts +19 -0
- package/dist/index-uXPK_Rg8.d.cts +19 -0
- package/dist/index.cjs +11176 -463
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +39 -183
- package/dist/index.d.ts +39 -183
- package/dist/index.js +49 -9
- package/dist/resolve-D-GOaxZy.d.cts +60 -0
- package/dist/resolve-D-GOaxZy.d.ts +60 -0
- package/dist/slot/index.cjs +9 -3
- package/dist/slot/index.cjs.map +1 -1
- package/dist/slot/index.js +2 -2
- package/dist/stories/index.cjs +108 -0
- package/dist/stories/index.cjs.map +1 -0
- package/dist/stories/index.d.cts +46 -0
- package/dist/stories/index.d.ts +46 -0
- package/dist/stories/index.js +94 -0
- package/dist/stories/index.js.map +1 -0
- package/dist/theme/index.cjs +259 -26
- package/dist/theme/index.cjs.map +1 -1
- package/dist/theme/index.d.cts +26 -0
- package/dist/theme/index.d.ts +26 -0
- package/dist/theme/index.js +4 -3
- package/dist/use-theme-CoqfnvRs.d.cts +112 -0
- package/dist/use-theme-CoqfnvRs.d.ts +112 -0
- package/dist/utils/cn.cjs +18 -6
- package/dist/utils/cn.cjs.map +1 -1
- package/dist/utils/cn.js +2 -2
- package/package.json +41 -10
- package/dist/chunk-6OABNXBY.js +0 -213
- package/dist/chunk-6OABNXBY.js.map +0 -1
- package/dist/chunk-7QVYU63E.js +0 -6
- package/dist/chunk-FXKIWONG.js.map +0 -1
- package/dist/chunk-NDEDMCHT.js +0 -40
- package/dist/chunk-NDEDMCHT.js.map +0 -1
- package/dist/chunk-SSTXLK5I.js.map +0 -1
- package/dist/chunk-UAKFCMWK.js +0 -3
- package/dist/chunk-X3AJNNF6.js +0 -539
- package/dist/chunk-X3AJNNF6.js.map +0 -1
- package/dist/chunk-XGM2K4TT.js +0 -31
- package/dist/chunk-XGM2K4TT.js.map +0 -1
- package/dist/stories/story-registry.cjs +0 -776
- package/dist/stories/story-registry.cjs.map +0 -1
- package/dist/stories/story-registry.d.cts +0 -13
- package/dist/stories/story-registry.d.ts +0 -13
- package/dist/stories/story-registry.js +0 -106
- package/dist/stories/story-registry.js.map +0 -1
|
@@ -0,0 +1,2501 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var reactNative = require('react-native');
|
|
5
|
+
var jsxRuntime = require('nativewind/jsx-runtime');
|
|
6
|
+
var reactDom = require('react-dom');
|
|
7
|
+
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
|
|
11
|
+
// src/i18n/default-dictionary.ts
|
|
12
|
+
var defaultDictionary = {
|
|
13
|
+
// generic / shared
|
|
14
|
+
"common.cancel": "Cancel",
|
|
15
|
+
"common.confirm": "Confirm",
|
|
16
|
+
"common.close": "Close",
|
|
17
|
+
"common.back": "Back",
|
|
18
|
+
"common.loading": "Loading",
|
|
19
|
+
"common.error": "Something went wrong",
|
|
20
|
+
"common.retry": "Try again",
|
|
21
|
+
// breadcrumb
|
|
22
|
+
"breadcrumb.ariaLabel": "Breadcrumb",
|
|
23
|
+
"breadcrumb.expandLabel": "Show full path",
|
|
24
|
+
"breadcrumb.ellipsisLabel": "More",
|
|
25
|
+
"breadcrumb.currentPageLabel": "Current page",
|
|
26
|
+
"breadcrumb.siblingMenuLabel": "Open sibling pages",
|
|
27
|
+
// pagination
|
|
28
|
+
"pagination.ariaLabel": "Pagination",
|
|
29
|
+
"pagination.previous": "Previous page",
|
|
30
|
+
"pagination.next": "Next page",
|
|
31
|
+
"pagination.first": "First page",
|
|
32
|
+
"pagination.last": "Last page",
|
|
33
|
+
"pagination.ellipsis": "More pages",
|
|
34
|
+
"pagination.currentPage": "Current page",
|
|
35
|
+
"pagination.gotoPage": "Go to page {{page}}",
|
|
36
|
+
"pagination.range": "Showing {{from}}\u2013{{to}} of {{total}}",
|
|
37
|
+
"pagination.pageOf": "Page {{page}} of {{total}}",
|
|
38
|
+
"pagination.pageSizeLabel": "Items per page",
|
|
39
|
+
"pagination.jumperLabel": "Go to page",
|
|
40
|
+
"pagination.jumperPlaceholder": "#",
|
|
41
|
+
// floatButton
|
|
42
|
+
"floatButton.backToTop": "Back to top",
|
|
43
|
+
// calendar
|
|
44
|
+
"calendar.header.previous": "Previous",
|
|
45
|
+
"calendar.header.next": "Next",
|
|
46
|
+
"calendar.header.openMonthView": "Open month picker",
|
|
47
|
+
"calendar.header.openYearView": "Open year picker",
|
|
48
|
+
"calendar.header.openDayView": "Open day picker",
|
|
49
|
+
"calendar.today": "Today",
|
|
50
|
+
"calendar.clear": "Clear",
|
|
51
|
+
// button
|
|
52
|
+
"button.loadingLabel": "Loading",
|
|
53
|
+
// input
|
|
54
|
+
"input.clear": "Clear",
|
|
55
|
+
"input.passwordShow": "Show password",
|
|
56
|
+
"input.passwordHide": "Hide password",
|
|
57
|
+
// checkbox / switch
|
|
58
|
+
"checkbox.checked": "Checked",
|
|
59
|
+
"checkbox.unchecked": "Unchecked",
|
|
60
|
+
"switch.on": "On",
|
|
61
|
+
"switch.off": "Off"
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// src/i18n/resolve.ts
|
|
65
|
+
function resolveI18n(input, defaults) {
|
|
66
|
+
if (typeof input === "function") {
|
|
67
|
+
return (keyOrKeys, options) => input(keyOrKeys, options);
|
|
68
|
+
}
|
|
69
|
+
const dict = input ?? {};
|
|
70
|
+
return (keyOrKeys, options) => {
|
|
71
|
+
const keys = Array.isArray(keyOrKeys) ? keyOrKeys : [keyOrKeys];
|
|
72
|
+
for (const rawKey of keys) {
|
|
73
|
+
const key = pluralize(rawKey, options?.count);
|
|
74
|
+
const template = dict[key] ?? defaults[key];
|
|
75
|
+
if (template !== void 0) {
|
|
76
|
+
return interpolate(template, options);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const lastKey = keys[keys.length - 1];
|
|
80
|
+
if (options?.defaultValue !== void 0) {
|
|
81
|
+
return interpolate(options.defaultValue, options);
|
|
82
|
+
}
|
|
83
|
+
return lastKey ?? "";
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
__name(resolveI18n, "resolveI18n");
|
|
87
|
+
function pluralize(key, count) {
|
|
88
|
+
if (count === void 0) {
|
|
89
|
+
return key;
|
|
90
|
+
}
|
|
91
|
+
if (count === 1) {
|
|
92
|
+
return `${key}_one`;
|
|
93
|
+
}
|
|
94
|
+
return `${key}_other`;
|
|
95
|
+
}
|
|
96
|
+
__name(pluralize, "pluralize");
|
|
97
|
+
function interpolate(template, options) {
|
|
98
|
+
if (!options) {
|
|
99
|
+
return template;
|
|
100
|
+
}
|
|
101
|
+
return template.replace(/\{\{\s*([A-Za-z0-9_.-]+)\s*\}\}/g, (_match, name) => {
|
|
102
|
+
const value = options[name];
|
|
103
|
+
return value === void 0 || value === null ? "" : String(value);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
__name(interpolate, "interpolate");
|
|
107
|
+
var defaultValue = {
|
|
108
|
+
t: resolveI18n(void 0, defaultDictionary)
|
|
109
|
+
};
|
|
110
|
+
var I18nContext = react.createContext(defaultValue);
|
|
111
|
+
I18nContext.displayName = "I18nContext";
|
|
112
|
+
|
|
113
|
+
// src/i18n/use-translation.ts
|
|
114
|
+
function useTranslation() {
|
|
115
|
+
return react.useContext(I18nContext);
|
|
116
|
+
}
|
|
117
|
+
__name(useTranslation, "useTranslation");
|
|
118
|
+
|
|
119
|
+
// src/slot/compose-refs.ts
|
|
120
|
+
function composeRefs(...refs) {
|
|
121
|
+
return (node) => {
|
|
122
|
+
for (const ref of refs) {
|
|
123
|
+
if (ref == null) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (typeof ref === "function") {
|
|
127
|
+
ref(node);
|
|
128
|
+
} else {
|
|
129
|
+
ref.current = node;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
__name(composeRefs, "composeRefs");
|
|
135
|
+
var Slot = react.forwardRef(/* @__PURE__ */ __name(function Slot2(props, forwardedRef) {
|
|
136
|
+
const { children, ...slotProps } = props;
|
|
137
|
+
if (!react.isValidElement(children)) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
const child = react.Children.only(children);
|
|
141
|
+
const merged = mergeProps(slotProps, child.props);
|
|
142
|
+
const childRef = child.ref;
|
|
143
|
+
if (forwardedRef || childRef) {
|
|
144
|
+
merged.ref = composeRefs(forwardedRef, childRef);
|
|
145
|
+
}
|
|
146
|
+
return react.cloneElement(child, merged);
|
|
147
|
+
}, "Slot"));
|
|
148
|
+
Slot.displayName = "Slot";
|
|
149
|
+
function mergeProps(outer, inner) {
|
|
150
|
+
const merged = { ...outer };
|
|
151
|
+
for (const key of Object.keys(inner)) {
|
|
152
|
+
const outerValue = outer[key];
|
|
153
|
+
const innerValue = inner[key];
|
|
154
|
+
if (key === "className" || key === "class") {
|
|
155
|
+
merged[key] = joinClass(outerValue, innerValue);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (key === "style") {
|
|
159
|
+
merged[key] = {
|
|
160
|
+
...outerValue,
|
|
161
|
+
...innerValue
|
|
162
|
+
};
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
if (isEventHandler(key, outerValue, innerValue)) {
|
|
166
|
+
merged[key] = composeHandlers(outerValue, innerValue);
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
merged[key] = innerValue;
|
|
170
|
+
}
|
|
171
|
+
return merged;
|
|
172
|
+
}
|
|
173
|
+
__name(mergeProps, "mergeProps");
|
|
174
|
+
function joinClass(outer, inner) {
|
|
175
|
+
const a = typeof outer === "string" ? outer : "";
|
|
176
|
+
const b = typeof inner === "string" ? inner : "";
|
|
177
|
+
const joined = [a, b].filter(Boolean).join(" ");
|
|
178
|
+
return joined.length > 0 ? joined : void 0;
|
|
179
|
+
}
|
|
180
|
+
__name(joinClass, "joinClass");
|
|
181
|
+
function isEventHandler(key, outer, inner) {
|
|
182
|
+
if (!key.startsWith("on") || key.length < 3) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
if (key[2] !== key[2]?.toUpperCase()) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
return typeof outer === "function" && typeof inner === "function";
|
|
189
|
+
}
|
|
190
|
+
__name(isEventHandler, "isEventHandler");
|
|
191
|
+
function composeHandlers(outer, inner) {
|
|
192
|
+
return (...args) => {
|
|
193
|
+
outer(...args);
|
|
194
|
+
inner(...args);
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
__name(composeHandlers, "composeHandlers");
|
|
198
|
+
|
|
199
|
+
// src/theme/px.ts
|
|
200
|
+
function px(value) {
|
|
201
|
+
if (typeof value === "number") {
|
|
202
|
+
return value;
|
|
203
|
+
}
|
|
204
|
+
const n = Number.parseFloat(value);
|
|
205
|
+
return Number.isFinite(n) ? n : 0;
|
|
206
|
+
}
|
|
207
|
+
__name(px, "px");
|
|
208
|
+
|
|
209
|
+
// ../tokens/build/theme.ts
|
|
210
|
+
var theme = {
|
|
211
|
+
color: {
|
|
212
|
+
danger: "#ef4444",
|
|
213
|
+
info: "#3b82f6",
|
|
214
|
+
neutral: {
|
|
215
|
+
"100": "#f4f4f5",
|
|
216
|
+
"200": "#e4e4e7",
|
|
217
|
+
"300": "#d4d4d8",
|
|
218
|
+
"400": "#a1a1aa",
|
|
219
|
+
"50": "#fafafa",
|
|
220
|
+
"500": "#71717a",
|
|
221
|
+
"600": "#52525b",
|
|
222
|
+
"700": "#3f3f46",
|
|
223
|
+
"800": "#27272a",
|
|
224
|
+
"900": "#18181b"
|
|
225
|
+
},
|
|
226
|
+
primary: {
|
|
227
|
+
"100": "#ccfbf1",
|
|
228
|
+
"200": "#99f6e4",
|
|
229
|
+
"300": "#5eead4",
|
|
230
|
+
"400": "#2dd4bf",
|
|
231
|
+
"50": "#f0fdfa",
|
|
232
|
+
"500": "#14b8a6",
|
|
233
|
+
"600": "#0d9488",
|
|
234
|
+
"700": "#0f766e",
|
|
235
|
+
"800": "#115e59",
|
|
236
|
+
"900": "#134e4a"
|
|
237
|
+
},
|
|
238
|
+
success: "#22c55e",
|
|
239
|
+
warning: "#f59e0b"
|
|
240
|
+
},
|
|
241
|
+
fontFamily: {
|
|
242
|
+
body: "system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",
|
|
243
|
+
display: "ui-serif, Georgia, 'Times New Roman', serif",
|
|
244
|
+
mono: "ui-monospace, 'SF Mono', Menlo, Consolas, 'DejaVu Sans Mono', monospace"
|
|
245
|
+
},
|
|
246
|
+
fontSize: {
|
|
247
|
+
"2xl": "24px",
|
|
248
|
+
"3xl": "30px",
|
|
249
|
+
"4xl": "36px",
|
|
250
|
+
lg: "18px",
|
|
251
|
+
md: "16px",
|
|
252
|
+
sm: "14px",
|
|
253
|
+
xl: "20px",
|
|
254
|
+
xs: "12px"
|
|
255
|
+
},
|
|
256
|
+
fontWeight: {
|
|
257
|
+
bold: "700",
|
|
258
|
+
medium: "500",
|
|
259
|
+
regular: "400",
|
|
260
|
+
semibold: "600"
|
|
261
|
+
},
|
|
262
|
+
lineHeight: {
|
|
263
|
+
normal: "1.4",
|
|
264
|
+
relaxed: "1.6",
|
|
265
|
+
tight: "1.2"
|
|
266
|
+
},
|
|
267
|
+
radius: {
|
|
268
|
+
"2xl": "16px",
|
|
269
|
+
full: "9999px",
|
|
270
|
+
lg: "8px",
|
|
271
|
+
md: "6px",
|
|
272
|
+
none: "0px",
|
|
273
|
+
sm: "4px",
|
|
274
|
+
xl: "12px"
|
|
275
|
+
},
|
|
276
|
+
semantic: {
|
|
277
|
+
background: {
|
|
278
|
+
default: "#fafafa",
|
|
279
|
+
elevated: "#ffffff",
|
|
280
|
+
subtle: "#f4f4f5"
|
|
281
|
+
},
|
|
282
|
+
border: {
|
|
283
|
+
default: "#e4e4e7",
|
|
284
|
+
strong: "#d4d4d8"
|
|
285
|
+
},
|
|
286
|
+
interactive: {
|
|
287
|
+
destructive: "#ef4444",
|
|
288
|
+
primary: "#0d9488",
|
|
289
|
+
primaryHover: "#0f766e",
|
|
290
|
+
primaryPressed: "#115e59"
|
|
291
|
+
},
|
|
292
|
+
text: {
|
|
293
|
+
default: "#18181b",
|
|
294
|
+
inverted: "#fafafa",
|
|
295
|
+
muted: "#52525b"
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
shadow: {
|
|
299
|
+
lg: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",
|
|
300
|
+
md: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)",
|
|
301
|
+
sm: "0 1px 2px 0 rgba(0, 0, 0, 0.05)"
|
|
302
|
+
},
|
|
303
|
+
spacing: {
|
|
304
|
+
"0": "0px",
|
|
305
|
+
"1": "4px",
|
|
306
|
+
"10": "40px",
|
|
307
|
+
"12": "48px",
|
|
308
|
+
"16": "64px",
|
|
309
|
+
"2": "8px",
|
|
310
|
+
"20": "80px",
|
|
311
|
+
"24": "96px",
|
|
312
|
+
"3": "12px",
|
|
313
|
+
"4": "16px",
|
|
314
|
+
"5": "20px",
|
|
315
|
+
"6": "24px",
|
|
316
|
+
"8": "32px"
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
var themeDark = {
|
|
320
|
+
color: {
|
|
321
|
+
danger: "#ef4444",
|
|
322
|
+
info: "#3b82f6",
|
|
323
|
+
neutral: {
|
|
324
|
+
"100": "#f4f4f5",
|
|
325
|
+
"200": "#e4e4e7",
|
|
326
|
+
"300": "#d4d4d8",
|
|
327
|
+
"400": "#a1a1aa",
|
|
328
|
+
"50": "#fafafa",
|
|
329
|
+
"500": "#71717a",
|
|
330
|
+
"600": "#52525b",
|
|
331
|
+
"700": "#3f3f46",
|
|
332
|
+
"800": "#27272a",
|
|
333
|
+
"900": "#18181b"
|
|
334
|
+
},
|
|
335
|
+
primary: {
|
|
336
|
+
"100": "#ccfbf1",
|
|
337
|
+
"200": "#99f6e4",
|
|
338
|
+
"300": "#5eead4",
|
|
339
|
+
"400": "#2dd4bf",
|
|
340
|
+
"50": "#f0fdfa",
|
|
341
|
+
"500": "#14b8a6",
|
|
342
|
+
"600": "#0d9488",
|
|
343
|
+
"700": "#0f766e",
|
|
344
|
+
"800": "#115e59",
|
|
345
|
+
"900": "#134e4a"
|
|
346
|
+
},
|
|
347
|
+
success: "#22c55e",
|
|
348
|
+
warning: "#f59e0b"
|
|
349
|
+
},
|
|
350
|
+
fontFamily: {
|
|
351
|
+
body: "system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",
|
|
352
|
+
display: "ui-serif, Georgia, 'Times New Roman', serif",
|
|
353
|
+
mono: "ui-monospace, 'SF Mono', Menlo, Consolas, 'DejaVu Sans Mono', monospace"
|
|
354
|
+
},
|
|
355
|
+
fontSize: {
|
|
356
|
+
"2xl": "24px",
|
|
357
|
+
"3xl": "30px",
|
|
358
|
+
"4xl": "36px",
|
|
359
|
+
lg: "18px",
|
|
360
|
+
md: "16px",
|
|
361
|
+
sm: "14px",
|
|
362
|
+
xl: "20px",
|
|
363
|
+
xs: "12px"
|
|
364
|
+
},
|
|
365
|
+
fontWeight: {
|
|
366
|
+
bold: "700",
|
|
367
|
+
medium: "500",
|
|
368
|
+
regular: "400",
|
|
369
|
+
semibold: "600"
|
|
370
|
+
},
|
|
371
|
+
lineHeight: {
|
|
372
|
+
normal: "1.4",
|
|
373
|
+
relaxed: "1.6",
|
|
374
|
+
tight: "1.2"
|
|
375
|
+
},
|
|
376
|
+
radius: {
|
|
377
|
+
"2xl": "16px",
|
|
378
|
+
full: "9999px",
|
|
379
|
+
lg: "8px",
|
|
380
|
+
md: "6px",
|
|
381
|
+
none: "0px",
|
|
382
|
+
sm: "4px",
|
|
383
|
+
xl: "12px"
|
|
384
|
+
},
|
|
385
|
+
semantic: {
|
|
386
|
+
background: {
|
|
387
|
+
default: "#18181b",
|
|
388
|
+
elevated: "#3f3f46",
|
|
389
|
+
subtle: "#27272a"
|
|
390
|
+
},
|
|
391
|
+
border: {
|
|
392
|
+
default: "#3f3f46",
|
|
393
|
+
strong: "#52525b"
|
|
394
|
+
},
|
|
395
|
+
interactive: {
|
|
396
|
+
destructive: "#ef4444",
|
|
397
|
+
primary: "#2dd4bf",
|
|
398
|
+
primaryHover: "#5eead4",
|
|
399
|
+
primaryPressed: "#99f6e4"
|
|
400
|
+
},
|
|
401
|
+
text: {
|
|
402
|
+
default: "#fafafa",
|
|
403
|
+
inverted: "#18181b",
|
|
404
|
+
muted: "#a1a1aa"
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
shadow: {
|
|
408
|
+
lg: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",
|
|
409
|
+
md: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)",
|
|
410
|
+
sm: "0 1px 2px 0 rgba(0, 0, 0, 0.05)"
|
|
411
|
+
},
|
|
412
|
+
spacing: {
|
|
413
|
+
"0": "0px",
|
|
414
|
+
"1": "4px",
|
|
415
|
+
"10": "40px",
|
|
416
|
+
"12": "48px",
|
|
417
|
+
"16": "64px",
|
|
418
|
+
"2": "8px",
|
|
419
|
+
"20": "80px",
|
|
420
|
+
"24": "96px",
|
|
421
|
+
"3": "12px",
|
|
422
|
+
"4": "16px",
|
|
423
|
+
"5": "20px",
|
|
424
|
+
"6": "24px",
|
|
425
|
+
"8": "32px"
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
var defaultTheme = {
|
|
429
|
+
light: theme,
|
|
430
|
+
dark: themeDark
|
|
431
|
+
};
|
|
432
|
+
var ThemeContext = react.createContext(defaultTheme);
|
|
433
|
+
ThemeContext.displayName = "ThemeContext";
|
|
434
|
+
var ColorSchemeOverrideContext = react.createContext(null);
|
|
435
|
+
ColorSchemeOverrideContext.displayName = "ColorSchemeOverrideContext";
|
|
436
|
+
var isWeb = reactNative.Platform.OS === "web";
|
|
437
|
+
function readWebScheme() {
|
|
438
|
+
if (typeof document === "undefined") {
|
|
439
|
+
return "light";
|
|
440
|
+
}
|
|
441
|
+
const root = document.documentElement;
|
|
442
|
+
if (root.classList.contains("dark")) {
|
|
443
|
+
return "dark";
|
|
444
|
+
}
|
|
445
|
+
if (root.getAttribute("data-theme") === "dark") {
|
|
446
|
+
return "dark";
|
|
447
|
+
}
|
|
448
|
+
return "light";
|
|
449
|
+
}
|
|
450
|
+
__name(readWebScheme, "readWebScheme");
|
|
451
|
+
function useColorScheme() {
|
|
452
|
+
const override = react.useContext(ColorSchemeOverrideContext);
|
|
453
|
+
const [scheme, setScheme] = react.useState(() => {
|
|
454
|
+
if (isWeb) {
|
|
455
|
+
return readWebScheme();
|
|
456
|
+
}
|
|
457
|
+
return reactNative.Appearance.getColorScheme() ?? "light";
|
|
458
|
+
});
|
|
459
|
+
react.useEffect(() => {
|
|
460
|
+
if (isWeb) {
|
|
461
|
+
const root = document.documentElement;
|
|
462
|
+
const update = /* @__PURE__ */ __name(() => setScheme(readWebScheme()), "update");
|
|
463
|
+
const observer = new MutationObserver(update);
|
|
464
|
+
observer.observe(root, { attributes: true, attributeFilter: ["class", "data-theme"] });
|
|
465
|
+
update();
|
|
466
|
+
return () => observer.disconnect();
|
|
467
|
+
}
|
|
468
|
+
const sub = reactNative.Appearance.addChangeListener(({ colorScheme }) => {
|
|
469
|
+
setScheme(colorScheme ?? "light");
|
|
470
|
+
});
|
|
471
|
+
return () => sub.remove();
|
|
472
|
+
}, []);
|
|
473
|
+
return override ?? scheme;
|
|
474
|
+
}
|
|
475
|
+
__name(useColorScheme, "useColorScheme");
|
|
476
|
+
|
|
477
|
+
// src/theme/use-theme-colors.ts
|
|
478
|
+
function useThemeColors() {
|
|
479
|
+
const scheme = useColorScheme();
|
|
480
|
+
const themePair = react.useContext(ThemeContext);
|
|
481
|
+
return scheme === "dark" ? themePair.dark : themePair.light;
|
|
482
|
+
}
|
|
483
|
+
__name(useThemeColors, "useThemeColors");
|
|
484
|
+
|
|
485
|
+
// src/utils/cn.ts
|
|
486
|
+
function cn(...inputs) {
|
|
487
|
+
const out = [];
|
|
488
|
+
for (const input of inputs) {
|
|
489
|
+
append(out, input);
|
|
490
|
+
}
|
|
491
|
+
return out.join(" ");
|
|
492
|
+
}
|
|
493
|
+
__name(cn, "cn");
|
|
494
|
+
function append(out, input) {
|
|
495
|
+
if (!input) {
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
if (typeof input === "string") {
|
|
499
|
+
if (input.length > 0) {
|
|
500
|
+
out.push(input);
|
|
501
|
+
}
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
if (typeof input === "number") {
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
if (Array.isArray(input)) {
|
|
508
|
+
for (const inner of input) {
|
|
509
|
+
append(out, inner);
|
|
510
|
+
}
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
if (typeof input === "object") {
|
|
514
|
+
for (const key of Object.keys(input)) {
|
|
515
|
+
if (input[key]) {
|
|
516
|
+
out.push(key);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
__name(append, "append");
|
|
522
|
+
var isWeb2 = reactNative.Platform.OS === "web";
|
|
523
|
+
var make = /* @__PURE__ */ __name(({ path, glyph }) => /* @__PURE__ */ __name(function PlaceholderIcon({ size = 20, color = "currentColor" }) {
|
|
524
|
+
const colors = useThemeColors();
|
|
525
|
+
if (isWeb2) {
|
|
526
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
527
|
+
"svg",
|
|
528
|
+
{
|
|
529
|
+
width: size,
|
|
530
|
+
height: size,
|
|
531
|
+
viewBox: "0 0 24 24",
|
|
532
|
+
fill: "none",
|
|
533
|
+
stroke: color,
|
|
534
|
+
strokeWidth: "2",
|
|
535
|
+
strokeLinecap: "round",
|
|
536
|
+
strokeLinejoin: "round",
|
|
537
|
+
"aria-hidden": "true",
|
|
538
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: path })
|
|
539
|
+
}
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
const resolvedColor = color === "currentColor" ? colors.semantic.text.default : color;
|
|
543
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
544
|
+
reactNative.Text,
|
|
545
|
+
{
|
|
546
|
+
accessibilityElementsHidden: true,
|
|
547
|
+
importantForAccessibility: "no-hide-descendants",
|
|
548
|
+
style: { fontSize: size, lineHeight: size, color: resolvedColor },
|
|
549
|
+
children: glyph
|
|
550
|
+
}
|
|
551
|
+
);
|
|
552
|
+
}, "PlaceholderIcon"), "make");
|
|
553
|
+
var defaultSemanticIcons = {
|
|
554
|
+
checkmark: make({ path: "M20 6 9 17l-5-5", glyph: "\u2713" }),
|
|
555
|
+
close: make({ path: "M18 6 6 18 M6 6l12 12", glyph: "\u2715" }),
|
|
556
|
+
eye: make({
|
|
557
|
+
path: "M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z M12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6z",
|
|
558
|
+
glyph: "\u{1F441}"
|
|
559
|
+
}),
|
|
560
|
+
eyeOff: make({
|
|
561
|
+
path: "M17.94 17.94A10 10 0 0 1 2 12s3.5-7 10-7c2 0 3.8.6 5.4 1.5 M1 1l22 22",
|
|
562
|
+
glyph: "\u{1F648}"
|
|
563
|
+
}),
|
|
564
|
+
chevronDown: make({ path: "m6 9 6 6 6-6", glyph: "\u2304" }),
|
|
565
|
+
chevronUp: make({ path: "m18 15-6-6-6 6", glyph: "\u2303" }),
|
|
566
|
+
alertTriangle: make({
|
|
567
|
+
path: "M12 9v4 M12 17h.01 M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z",
|
|
568
|
+
glyph: "\u26A0"
|
|
569
|
+
}),
|
|
570
|
+
info: make({
|
|
571
|
+
path: "M12 8h.01 M11 12h1v4h1 M12 22C6.48 22 2 17.52 2 12 2 6.48 6.48 2 12 2c5.52 0 10 4.48 10 10 0 5.52-4.48 10-10 10z",
|
|
572
|
+
glyph: "\u24D8"
|
|
573
|
+
}),
|
|
574
|
+
check: make({ path: "M20 6 9 17l-5-5", glyph: "\u2713" }),
|
|
575
|
+
x: make({ path: "M18 6 6 18 M6 6l12 12", glyph: "\u2715" })
|
|
576
|
+
};
|
|
577
|
+
var DEFAULT_PAGE_SIZE = 50;
|
|
578
|
+
var DEFAULT_ITEM_HEIGHT = 36;
|
|
579
|
+
var DEFAULT_MAX_MENU = 320;
|
|
580
|
+
var SEARCH_DEBOUNCE_MS = 150;
|
|
581
|
+
var VIRTUAL_OVERSCAN = 4;
|
|
582
|
+
var TYPE_AHEAD_RESET_MS = 500;
|
|
583
|
+
var defaultFilter = /* @__PURE__ */ __name((option, search) => {
|
|
584
|
+
if (!search) {
|
|
585
|
+
return true;
|
|
586
|
+
}
|
|
587
|
+
return option.label.toLowerCase().includes(search.toLowerCase());
|
|
588
|
+
}, "defaultFilter");
|
|
589
|
+
var Select = /* @__PURE__ */ __name((props) => {
|
|
590
|
+
const {
|
|
591
|
+
options: staticOptions,
|
|
592
|
+
loadOptions,
|
|
593
|
+
pageSize = DEFAULT_PAGE_SIZE,
|
|
594
|
+
searchable: searchableProp,
|
|
595
|
+
searchPlaceholder = "Search\u2026",
|
|
596
|
+
filterOption,
|
|
597
|
+
renderOption,
|
|
598
|
+
placeholder = "Select\u2026",
|
|
599
|
+
locale,
|
|
600
|
+
sortByLocale = true,
|
|
601
|
+
noOptionsMessage = "No options",
|
|
602
|
+
loadingMessage = "Loading\u2026",
|
|
603
|
+
disabled = false,
|
|
604
|
+
dir = "ltr",
|
|
605
|
+
virtualized: virtualizedProp,
|
|
606
|
+
itemHeight = DEFAULT_ITEM_HEIGHT,
|
|
607
|
+
maxMenuHeight = DEFAULT_MAX_MENU,
|
|
608
|
+
className,
|
|
609
|
+
testID
|
|
610
|
+
} = props;
|
|
611
|
+
const ariaLabel = props["aria-label"];
|
|
612
|
+
const multiple = props.multiple === true;
|
|
613
|
+
const maxSelected = multiple ? props.maxSelected : void 0;
|
|
614
|
+
const maxChips = multiple ? props.maxChips ?? 3 : void 0;
|
|
615
|
+
const baseId = react.useId();
|
|
616
|
+
const colors = useThemeColors();
|
|
617
|
+
const [open, setOpen] = react.useState(false);
|
|
618
|
+
const controlledValues = multiple ? props.value : props.value !== void 0 ? [props.value] : void 0;
|
|
619
|
+
const defaultValues = multiple ? props.defaultValue ?? [] : props.defaultValue !== void 0 ? [props.defaultValue] : [];
|
|
620
|
+
const [innerValues, setInnerValues] = react.useState(defaultValues);
|
|
621
|
+
const isControlled = controlledValues !== void 0;
|
|
622
|
+
const currentValues = isControlled ? controlledValues : innerValues;
|
|
623
|
+
const current = currentValues[0];
|
|
624
|
+
const [searchInput, setSearchInput] = react.useState("");
|
|
625
|
+
const [debouncedSearch, setDebouncedSearch] = react.useState("");
|
|
626
|
+
const [activeIndex, setActiveIndex] = react.useState(0);
|
|
627
|
+
react.useEffect(() => {
|
|
628
|
+
const t = setTimeout(() => setDebouncedSearch(searchInput), SEARCH_DEBOUNCE_MS);
|
|
629
|
+
return () => clearTimeout(t);
|
|
630
|
+
}, [searchInput]);
|
|
631
|
+
const [asyncItems, setAsyncItems] = react.useState([]);
|
|
632
|
+
const [asyncLoading, setAsyncLoading] = react.useState(false);
|
|
633
|
+
const [asyncTotal, setAsyncTotal] = react.useState(void 0);
|
|
634
|
+
const asyncRequestId = react.useRef(0);
|
|
635
|
+
const isAsync = loadOptions !== void 0;
|
|
636
|
+
react.useEffect(() => {
|
|
637
|
+
if (!isAsync || !loadOptions || !open) {
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
const requestId = ++asyncRequestId.current;
|
|
641
|
+
setAsyncLoading(true);
|
|
642
|
+
setAsyncItems([]);
|
|
643
|
+
setAsyncTotal(void 0);
|
|
644
|
+
loadOptions({ search: debouncedSearch, offset: 0, limit: pageSize }).then((result) => {
|
|
645
|
+
if (requestId !== asyncRequestId.current) {
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
setAsyncItems(result.items.slice());
|
|
649
|
+
setAsyncTotal(result.total);
|
|
650
|
+
}).catch(() => {
|
|
651
|
+
}).finally(() => {
|
|
652
|
+
if (requestId === asyncRequestId.current) {
|
|
653
|
+
setAsyncLoading(false);
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
}, [debouncedSearch, isAsync, loadOptions, pageSize, open]);
|
|
657
|
+
const loadMore = react.useCallback(() => {
|
|
658
|
+
if (!isAsync || !loadOptions || asyncLoading) {
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
const haveAll = asyncTotal !== void 0 && asyncItems.length >= asyncTotal;
|
|
662
|
+
if (haveAll) {
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
const requestId = ++asyncRequestId.current;
|
|
666
|
+
setAsyncLoading(true);
|
|
667
|
+
loadOptions({ search: debouncedSearch, offset: asyncItems.length, limit: pageSize }).then((result) => {
|
|
668
|
+
if (requestId !== asyncRequestId.current) {
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
setAsyncItems((prev) => prev.concat(result.items));
|
|
672
|
+
if (result.total !== void 0) {
|
|
673
|
+
setAsyncTotal(result.total);
|
|
674
|
+
}
|
|
675
|
+
}).catch(() => void 0).finally(() => {
|
|
676
|
+
if (requestId === asyncRequestId.current) {
|
|
677
|
+
setAsyncLoading(false);
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
}, [asyncItems.length, asyncLoading, asyncTotal, debouncedSearch, isAsync, loadOptions, pageSize]);
|
|
681
|
+
const visibleOptions = react.useMemo(() => {
|
|
682
|
+
const source = isAsync ? asyncItems : staticOptions ?? [];
|
|
683
|
+
const filtered = isAsync ? source.slice() : source.filter((opt) => (filterOption ?? defaultFilter)(opt, debouncedSearch));
|
|
684
|
+
if (locale && sortByLocale) {
|
|
685
|
+
const collator = new Intl.Collator(locale, { sensitivity: "base", numeric: true });
|
|
686
|
+
return filtered.slice().sort((a, b) => {
|
|
687
|
+
const ga = a.group ?? "";
|
|
688
|
+
const gb = b.group ?? "";
|
|
689
|
+
const groupDelta = collator.compare(ga, gb);
|
|
690
|
+
if (groupDelta !== 0) {
|
|
691
|
+
return groupDelta;
|
|
692
|
+
}
|
|
693
|
+
return collator.compare(a.label, b.label);
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
return filtered;
|
|
697
|
+
}, [isAsync, asyncItems, staticOptions, filterOption, debouncedSearch, locale, sortByLocale]);
|
|
698
|
+
const selectedOption = react.useMemo(() => {
|
|
699
|
+
const all = isAsync ? asyncItems : staticOptions ?? [];
|
|
700
|
+
return all.find((o) => o.value === current);
|
|
701
|
+
}, [asyncItems, isAsync, staticOptions, current]);
|
|
702
|
+
const selectedOptions = react.useMemo(() => {
|
|
703
|
+
if (!multiple) {
|
|
704
|
+
return [];
|
|
705
|
+
}
|
|
706
|
+
const all = isAsync ? asyncItems : staticOptions ?? [];
|
|
707
|
+
const map = new Map(all.map((o) => [o.value, o]));
|
|
708
|
+
return currentValues.map((v) => map.get(v)).filter((o) => o !== void 0);
|
|
709
|
+
}, [multiple, currentValues, asyncItems, isAsync, staticOptions]);
|
|
710
|
+
const searchable = searchableProp ?? (isAsync || staticOptions !== void 0 && staticOptions.length >= 10);
|
|
711
|
+
const virtualized = virtualizedProp ?? visibleOptions.length > 100;
|
|
712
|
+
react.useEffect(() => {
|
|
713
|
+
setActiveIndex((idx) => Math.min(Math.max(0, idx), Math.max(0, visibleOptions.length - 1)));
|
|
714
|
+
}, [visibleOptions.length]);
|
|
715
|
+
const onSelect = react.useCallback(
|
|
716
|
+
(option) => {
|
|
717
|
+
if (option.disabled) {
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
if (multiple) {
|
|
721
|
+
const has = currentValues.includes(option.value);
|
|
722
|
+
let nextValues;
|
|
723
|
+
if (has) {
|
|
724
|
+
nextValues = currentValues.filter((v) => v !== option.value);
|
|
725
|
+
} else {
|
|
726
|
+
if (maxSelected !== void 0 && currentValues.length >= maxSelected) {
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
nextValues = [...currentValues, option.value];
|
|
730
|
+
}
|
|
731
|
+
if (!isControlled) {
|
|
732
|
+
setInnerValues(nextValues);
|
|
733
|
+
}
|
|
734
|
+
const allOpts = [
|
|
735
|
+
...staticOptions ?? [],
|
|
736
|
+
...asyncItems
|
|
737
|
+
];
|
|
738
|
+
const optMap = new Map(allOpts.map((o) => [o.value, o]));
|
|
739
|
+
const selectedOpts = nextValues.map((v) => optMap.get(v)).filter((o) => o !== void 0);
|
|
740
|
+
props.onChange?.(nextValues, selectedOpts);
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
if (!isControlled) {
|
|
744
|
+
setInnerValues([option.value]);
|
|
745
|
+
}
|
|
746
|
+
props.onChange?.(option.value, option);
|
|
747
|
+
setOpen(false);
|
|
748
|
+
setSearchInput("");
|
|
749
|
+
},
|
|
750
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: `props` is the discriminated union — destructuring it would defeat the narrowing; the asyncItems / staticOptions captures intentionally re-trigger the callback when the option pool changes
|
|
751
|
+
[multiple, isControlled, currentValues, maxSelected, staticOptions, asyncItems, props]
|
|
752
|
+
);
|
|
753
|
+
const clearAll = react.useCallback(() => {
|
|
754
|
+
if (!isControlled) {
|
|
755
|
+
setInnerValues([]);
|
|
756
|
+
}
|
|
757
|
+
props.onChange?.([], []);
|
|
758
|
+
}, [isControlled, props]);
|
|
759
|
+
const moveActive = react.useCallback(
|
|
760
|
+
(delta) => {
|
|
761
|
+
setActiveIndex((idx) => {
|
|
762
|
+
if (visibleOptions.length === 0) {
|
|
763
|
+
return 0;
|
|
764
|
+
}
|
|
765
|
+
let next = (idx + delta + visibleOptions.length) % visibleOptions.length;
|
|
766
|
+
for (let attempts = 0; attempts < visibleOptions.length; attempts += 1) {
|
|
767
|
+
if (!visibleOptions[next]?.disabled) {
|
|
768
|
+
return next;
|
|
769
|
+
}
|
|
770
|
+
next = (next + delta + visibleOptions.length) % visibleOptions.length;
|
|
771
|
+
}
|
|
772
|
+
return idx;
|
|
773
|
+
});
|
|
774
|
+
},
|
|
775
|
+
[visibleOptions]
|
|
776
|
+
);
|
|
777
|
+
const typeAheadRef = react.useRef({
|
|
778
|
+
buffer: "",
|
|
779
|
+
timer: null
|
|
780
|
+
});
|
|
781
|
+
react.useEffect(() => {
|
|
782
|
+
return () => {
|
|
783
|
+
if (typeAheadRef.current.timer) {
|
|
784
|
+
clearTimeout(typeAheadRef.current.timer);
|
|
785
|
+
typeAheadRef.current.timer = null;
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
}, []);
|
|
789
|
+
const handleTypeAhead = react.useCallback(
|
|
790
|
+
(char) => {
|
|
791
|
+
if (visibleOptions.length === 0) {
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
if (typeAheadRef.current.timer) {
|
|
795
|
+
clearTimeout(typeAheadRef.current.timer);
|
|
796
|
+
}
|
|
797
|
+
const nextBuffer = typeAheadRef.current.buffer + char.toLowerCase();
|
|
798
|
+
typeAheadRef.current.buffer = nextBuffer;
|
|
799
|
+
typeAheadRef.current.timer = setTimeout(() => {
|
|
800
|
+
typeAheadRef.current.buffer = "";
|
|
801
|
+
typeAheadRef.current.timer = null;
|
|
802
|
+
}, TYPE_AHEAD_RESET_MS);
|
|
803
|
+
const allSame = nextBuffer.length > 1 && nextBuffer.split("").every((c) => c === nextBuffer[0]);
|
|
804
|
+
const cycleMode = nextBuffer.length === 1 || allSame;
|
|
805
|
+
const needle = cycleMode ? nextBuffer.charAt(0) : nextBuffer;
|
|
806
|
+
const len = visibleOptions.length;
|
|
807
|
+
const startFrom = cycleMode ? (activeIndex + 1) % len : 0;
|
|
808
|
+
for (let i = 0; i < len; i += 1) {
|
|
809
|
+
const idx = (startFrom + i) % len;
|
|
810
|
+
const opt = visibleOptions[idx];
|
|
811
|
+
if (!opt || opt.disabled) {
|
|
812
|
+
continue;
|
|
813
|
+
}
|
|
814
|
+
if (opt.label.toLowerCase().startsWith(needle)) {
|
|
815
|
+
setActiveIndex(idx);
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
},
|
|
820
|
+
[visibleOptions, activeIndex]
|
|
821
|
+
);
|
|
822
|
+
const handleListKeyDown = react.useCallback(
|
|
823
|
+
(event) => {
|
|
824
|
+
switch (event.key) {
|
|
825
|
+
case "ArrowDown":
|
|
826
|
+
event.preventDefault();
|
|
827
|
+
moveActive(1);
|
|
828
|
+
return true;
|
|
829
|
+
case "ArrowUp":
|
|
830
|
+
event.preventDefault();
|
|
831
|
+
moveActive(-1);
|
|
832
|
+
return true;
|
|
833
|
+
case "Home": {
|
|
834
|
+
event.preventDefault();
|
|
835
|
+
const idx = visibleOptions.findIndex((o) => !o.disabled);
|
|
836
|
+
if (idx >= 0) {
|
|
837
|
+
setActiveIndex(idx);
|
|
838
|
+
}
|
|
839
|
+
return true;
|
|
840
|
+
}
|
|
841
|
+
case "End": {
|
|
842
|
+
event.preventDefault();
|
|
843
|
+
for (let i = visibleOptions.length - 1; i >= 0; i -= 1) {
|
|
844
|
+
if (!visibleOptions[i]?.disabled) {
|
|
845
|
+
setActiveIndex(i);
|
|
846
|
+
break;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
return true;
|
|
850
|
+
}
|
|
851
|
+
case "Enter": {
|
|
852
|
+
const opt = visibleOptions[activeIndex];
|
|
853
|
+
if (opt) {
|
|
854
|
+
event.preventDefault();
|
|
855
|
+
onSelect(opt);
|
|
856
|
+
}
|
|
857
|
+
return true;
|
|
858
|
+
}
|
|
859
|
+
case "Escape":
|
|
860
|
+
event.preventDefault();
|
|
861
|
+
setOpen(false);
|
|
862
|
+
if (reactNative.Platform.OS === "web") {
|
|
863
|
+
const trigger = triggerRef.current;
|
|
864
|
+
trigger?.focus?.();
|
|
865
|
+
}
|
|
866
|
+
return true;
|
|
867
|
+
case "Tab":
|
|
868
|
+
setOpen(false);
|
|
869
|
+
return true;
|
|
870
|
+
}
|
|
871
|
+
return false;
|
|
872
|
+
},
|
|
873
|
+
[moveActive, activeIndex, visibleOptions, onSelect]
|
|
874
|
+
);
|
|
875
|
+
const handleSearchKeyDown = react.useCallback(
|
|
876
|
+
(event) => {
|
|
877
|
+
handleListKeyDown(event);
|
|
878
|
+
},
|
|
879
|
+
[handleListKeyDown]
|
|
880
|
+
);
|
|
881
|
+
const handlePopupKeyDown = react.useCallback(
|
|
882
|
+
(event) => {
|
|
883
|
+
if (handleListKeyDown(event)) {
|
|
884
|
+
return;
|
|
885
|
+
}
|
|
886
|
+
if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey && event.key !== " ") {
|
|
887
|
+
event.preventDefault();
|
|
888
|
+
handleTypeAhead(event.key);
|
|
889
|
+
}
|
|
890
|
+
},
|
|
891
|
+
[handleListKeyDown, handleTypeAhead]
|
|
892
|
+
);
|
|
893
|
+
const handleTriggerKeyDown = react.useCallback(
|
|
894
|
+
(event) => {
|
|
895
|
+
switch (event.key) {
|
|
896
|
+
case " ":
|
|
897
|
+
case "Enter":
|
|
898
|
+
case "ArrowDown":
|
|
899
|
+
case "ArrowUp":
|
|
900
|
+
event.preventDefault();
|
|
901
|
+
setOpen(true);
|
|
902
|
+
return;
|
|
903
|
+
}
|
|
904
|
+
if (!disabled && event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
|
|
905
|
+
event.preventDefault();
|
|
906
|
+
setOpen(true);
|
|
907
|
+
handleTypeAhead(event.key);
|
|
908
|
+
}
|
|
909
|
+
},
|
|
910
|
+
[disabled, handleTypeAhead]
|
|
911
|
+
);
|
|
912
|
+
const containerRef = react.useRef(null);
|
|
913
|
+
const triggerRef = react.useRef(null);
|
|
914
|
+
const popupRef = react.useRef(null);
|
|
915
|
+
react.useEffect(() => {
|
|
916
|
+
if (reactNative.Platform.OS !== "web" || typeof document === "undefined" || typeof document.addEventListener !== "function") {
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
if (!open) {
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
922
|
+
const onDocClick = /* @__PURE__ */ __name((event) => {
|
|
923
|
+
const node = containerRef.current;
|
|
924
|
+
const popup = popupRef.current;
|
|
925
|
+
const target = event.target;
|
|
926
|
+
if (node?.contains(target)) {
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
if (popup?.contains(target)) {
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
setOpen(false);
|
|
933
|
+
}, "onDocClick");
|
|
934
|
+
document.addEventListener("mousedown", onDocClick);
|
|
935
|
+
return () => document.removeEventListener("mousedown", onDocClick);
|
|
936
|
+
}, [open]);
|
|
937
|
+
const [triggerRect, setTriggerRect] = react.useState(
|
|
938
|
+
null
|
|
939
|
+
);
|
|
940
|
+
const measureTrigger = react.useCallback(() => {
|
|
941
|
+
const node = triggerRef.current;
|
|
942
|
+
if (!node) {
|
|
943
|
+
return;
|
|
944
|
+
}
|
|
945
|
+
if (reactNative.Platform.OS === "web" && typeof node.getBoundingClientRect === "function") {
|
|
946
|
+
const rect = node.getBoundingClientRect();
|
|
947
|
+
setTriggerRect({ top: rect.top, left: rect.left, width: rect.width, height: rect.height });
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
if (typeof node.measure === "function") {
|
|
951
|
+
node.measure((_x, _y, w, h, pageX, pageY) => {
|
|
952
|
+
setTriggerRect({ top: pageY, left: pageX, width: w, height: h });
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
}, []);
|
|
956
|
+
react.useEffect(() => {
|
|
957
|
+
if (!open) {
|
|
958
|
+
return;
|
|
959
|
+
}
|
|
960
|
+
if (reactNative.Platform.OS !== "web" || typeof window === "undefined" || typeof window.addEventListener !== "function") {
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
measureTrigger();
|
|
964
|
+
window.addEventListener("scroll", measureTrigger, true);
|
|
965
|
+
window.addEventListener("resize", measureTrigger);
|
|
966
|
+
return () => {
|
|
967
|
+
window.removeEventListener("scroll", measureTrigger, true);
|
|
968
|
+
window.removeEventListener("resize", measureTrigger);
|
|
969
|
+
};
|
|
970
|
+
}, [open, measureTrigger]);
|
|
971
|
+
react.useEffect(() => {
|
|
972
|
+
if (!open || searchable || reactNative.Platform.OS !== "web") {
|
|
973
|
+
return;
|
|
974
|
+
}
|
|
975
|
+
const id = requestAnimationFrame(() => {
|
|
976
|
+
const node = popupRef.current;
|
|
977
|
+
node?.focus?.();
|
|
978
|
+
});
|
|
979
|
+
return () => cancelAnimationFrame(id);
|
|
980
|
+
}, [open, searchable]);
|
|
981
|
+
const onListScroll = react.useCallback(
|
|
982
|
+
(event) => {
|
|
983
|
+
if (!isAsync) {
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
const { contentOffset, contentSize, layoutMeasurement } = event.nativeEvent;
|
|
987
|
+
const remaining = contentSize.height - contentOffset.y - layoutMeasurement.height;
|
|
988
|
+
if (remaining < itemHeight * 4) {
|
|
989
|
+
loadMore();
|
|
990
|
+
}
|
|
991
|
+
},
|
|
992
|
+
[isAsync, itemHeight, loadMore]
|
|
993
|
+
);
|
|
994
|
+
const triggerStyle = {
|
|
995
|
+
flexDirection: "row",
|
|
996
|
+
alignItems: "center",
|
|
997
|
+
justifyContent: "space-between",
|
|
998
|
+
gap: px(colors.spacing["2"]),
|
|
999
|
+
paddingHorizontal: px(colors.spacing["3"]),
|
|
1000
|
+
paddingVertical: px(colors.spacing["2"]),
|
|
1001
|
+
minHeight: 36,
|
|
1002
|
+
// component-density literal — not from theme
|
|
1003
|
+
borderWidth: 1,
|
|
1004
|
+
borderColor: colors.semantic.border.default,
|
|
1005
|
+
borderRadius: px(colors.radius.md),
|
|
1006
|
+
backgroundColor: colors.semantic.background.elevated,
|
|
1007
|
+
opacity: disabled ? 0.6 : 1
|
|
1008
|
+
};
|
|
1009
|
+
const winDims = reactNative.useWindowDimensions();
|
|
1010
|
+
const popupStyle = triggerRect ? {
|
|
1011
|
+
position: reactNative.Platform.OS === "web" ? "fixed" : "absolute",
|
|
1012
|
+
top: triggerRect.top + triggerRect.height + px(colors.spacing["1"]),
|
|
1013
|
+
left: dir === "rtl" ? void 0 : triggerRect.left,
|
|
1014
|
+
right: dir === "rtl" ? reactNative.Platform.OS === "web" && typeof window !== "undefined" ? window.innerWidth - (triggerRect.left + triggerRect.width) : winDims.width - (triggerRect.left + triggerRect.width) : void 0,
|
|
1015
|
+
minWidth: Math.max(200, triggerRect.width),
|
|
1016
|
+
backgroundColor: colors.semantic.background.elevated,
|
|
1017
|
+
borderRadius: px(colors.radius.lg),
|
|
1018
|
+
borderWidth: 1,
|
|
1019
|
+
borderColor: colors.semantic.border.default,
|
|
1020
|
+
// 2147483646 (max int32 - 1) so we sit above any third-party
|
|
1021
|
+
// chrome (toasts, modals, dev banners) without picking a fight
|
|
1022
|
+
// for the very top slot. Combined with portaling to body below,
|
|
1023
|
+
// this also dodges any ancestor stacking context that would
|
|
1024
|
+
// otherwise trap our z-index inside a sibling preview frame.
|
|
1025
|
+
zIndex: 2147483646,
|
|
1026
|
+
...{ boxShadow: "0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1)" }
|
|
1027
|
+
} : {
|
|
1028
|
+
// Trigger not yet measured — render off-screen until the
|
|
1029
|
+
// first measurement lands. Avoids a one-frame flash at (0,0).
|
|
1030
|
+
position: reactNative.Platform.OS === "web" ? "fixed" : "absolute",
|
|
1031
|
+
top: -9999,
|
|
1032
|
+
left: -9999
|
|
1033
|
+
};
|
|
1034
|
+
const containerProps = {
|
|
1035
|
+
ref: /* @__PURE__ */ __name((node) => {
|
|
1036
|
+
containerRef.current = node;
|
|
1037
|
+
}, "ref"),
|
|
1038
|
+
...testID !== void 0 ? { testID } : {},
|
|
1039
|
+
dir
|
|
1040
|
+
};
|
|
1041
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ...containerProps, className: cn("relative", className), style: { position: "relative" }, children: [
|
|
1042
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1043
|
+
reactNative.Pressable,
|
|
1044
|
+
{
|
|
1045
|
+
ref: (node) => {
|
|
1046
|
+
triggerRef.current = node;
|
|
1047
|
+
},
|
|
1048
|
+
...{
|
|
1049
|
+
onKeyDown: handleTriggerKeyDown,
|
|
1050
|
+
role: "combobox",
|
|
1051
|
+
accessibilityRole: "combobox",
|
|
1052
|
+
"aria-expanded": open,
|
|
1053
|
+
"aria-controls": `${baseId}-listbox`,
|
|
1054
|
+
"aria-haspopup": "listbox",
|
|
1055
|
+
tabIndex: disabled ? -1 : 0,
|
|
1056
|
+
...ariaLabel !== void 0 ? { "aria-label": ariaLabel, accessibilityLabel: ariaLabel } : {},
|
|
1057
|
+
...disabled ? { "aria-disabled": true, disabled: true } : {}
|
|
1058
|
+
},
|
|
1059
|
+
onPress: () => {
|
|
1060
|
+
if (disabled) {
|
|
1061
|
+
return;
|
|
1062
|
+
}
|
|
1063
|
+
measureTrigger();
|
|
1064
|
+
setOpen((v) => !v);
|
|
1065
|
+
},
|
|
1066
|
+
style: triggerStyle,
|
|
1067
|
+
children: [
|
|
1068
|
+
multiple ? /* @__PURE__ */ jsxRuntime.jsx(MultiTriggerLabel, { options: selectedOptions, placeholder, maxChips: maxChips ?? 3 }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1069
|
+
reactNative.Text,
|
|
1070
|
+
{
|
|
1071
|
+
style: {
|
|
1072
|
+
color: selectedOption ? colors.semantic.text.default : colors.semantic.text.muted,
|
|
1073
|
+
fontFamily: colors.fontFamily.body,
|
|
1074
|
+
fontSize: px(colors.fontSize.sm),
|
|
1075
|
+
flex: 1
|
|
1076
|
+
},
|
|
1077
|
+
numberOfLines: 1,
|
|
1078
|
+
children: selectedOption?.label ?? placeholder
|
|
1079
|
+
}
|
|
1080
|
+
),
|
|
1081
|
+
/* @__PURE__ */ jsxRuntime.jsx(defaultSemanticIcons.chevronDown, { size: 16, color: colors.semantic.text.muted })
|
|
1082
|
+
]
|
|
1083
|
+
}
|
|
1084
|
+
),
|
|
1085
|
+
open ? renderPopup() : null
|
|
1086
|
+
] });
|
|
1087
|
+
function renderPopup() {
|
|
1088
|
+
const popup = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1089
|
+
reactNative.View,
|
|
1090
|
+
{
|
|
1091
|
+
ref: (node) => {
|
|
1092
|
+
popupRef.current = node;
|
|
1093
|
+
},
|
|
1094
|
+
...{
|
|
1095
|
+
role: "listbox",
|
|
1096
|
+
id: `${baseId}-listbox`,
|
|
1097
|
+
...multiple ? { "aria-multiselectable": true } : {},
|
|
1098
|
+
// Without a search field there's no input to capture
|
|
1099
|
+
// keystrokes — make the popup itself focusable and own
|
|
1100
|
+
// arrow / Enter / Escape / type-ahead. With a search
|
|
1101
|
+
// field these belong to the input below.
|
|
1102
|
+
...searchable ? {} : { tabIndex: -1, onKeyDown: handlePopupKeyDown }
|
|
1103
|
+
},
|
|
1104
|
+
style: popupStyle,
|
|
1105
|
+
children: [
|
|
1106
|
+
searchable ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1107
|
+
SearchInput,
|
|
1108
|
+
{
|
|
1109
|
+
value: searchInput,
|
|
1110
|
+
onChange: setSearchInput,
|
|
1111
|
+
onKeyDown: handleSearchKeyDown,
|
|
1112
|
+
placeholder: searchPlaceholder,
|
|
1113
|
+
dir
|
|
1114
|
+
}
|
|
1115
|
+
) : null,
|
|
1116
|
+
multiple && currentValues.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(MultiSelectionHeader, { count: currentValues.length, onClearAll: clearAll }) : null,
|
|
1117
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1118
|
+
SelectList,
|
|
1119
|
+
{
|
|
1120
|
+
options: visibleOptions,
|
|
1121
|
+
activeIndex,
|
|
1122
|
+
currentValue: current,
|
|
1123
|
+
selectedValues: currentValues,
|
|
1124
|
+
multiple,
|
|
1125
|
+
onSelect,
|
|
1126
|
+
onActiveChange: setActiveIndex,
|
|
1127
|
+
...renderOption !== void 0 ? { renderOption } : {},
|
|
1128
|
+
itemHeight,
|
|
1129
|
+
maxHeight: maxMenuHeight,
|
|
1130
|
+
virtualized,
|
|
1131
|
+
loading: isAsync && asyncLoading,
|
|
1132
|
+
loadingMessage,
|
|
1133
|
+
noOptionsMessage,
|
|
1134
|
+
listboxId: `${baseId}-listbox`,
|
|
1135
|
+
onScroll: onListScroll
|
|
1136
|
+
}
|
|
1137
|
+
)
|
|
1138
|
+
]
|
|
1139
|
+
}
|
|
1140
|
+
);
|
|
1141
|
+
if (reactNative.Platform.OS === "web" && typeof document !== "undefined") {
|
|
1142
|
+
return reactDom.createPortal(popup, document.body);
|
|
1143
|
+
}
|
|
1144
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Modal, { transparent: true, visible: true, animationType: "fade", onRequestClose: () => setOpen(false), statusBarTranslucent: true, children: [
|
|
1145
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1146
|
+
reactNative.Pressable,
|
|
1147
|
+
{
|
|
1148
|
+
onPress: () => setOpen(false),
|
|
1149
|
+
style: {
|
|
1150
|
+
position: "absolute",
|
|
1151
|
+
top: 0,
|
|
1152
|
+
left: 0,
|
|
1153
|
+
right: 0,
|
|
1154
|
+
bottom: 0
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
),
|
|
1158
|
+
popup
|
|
1159
|
+
] });
|
|
1160
|
+
}
|
|
1161
|
+
}, "Select");
|
|
1162
|
+
var SearchInput = /* @__PURE__ */ __name(({ value, onChange, onKeyDown, placeholder, dir }) => {
|
|
1163
|
+
const colors = useThemeColors();
|
|
1164
|
+
const inputRef = react.useRef(null);
|
|
1165
|
+
react.useEffect(() => {
|
|
1166
|
+
inputRef.current?.focus?.();
|
|
1167
|
+
}, []);
|
|
1168
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1169
|
+
reactNative.View,
|
|
1170
|
+
{
|
|
1171
|
+
style: {
|
|
1172
|
+
paddingHorizontal: px(colors.spacing["2"]),
|
|
1173
|
+
paddingVertical: px(colors.spacing["2"]),
|
|
1174
|
+
borderBottomWidth: 1,
|
|
1175
|
+
borderBottomColor: colors.semantic.border.default
|
|
1176
|
+
},
|
|
1177
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1178
|
+
"input",
|
|
1179
|
+
{
|
|
1180
|
+
ref: inputRef,
|
|
1181
|
+
type: "text",
|
|
1182
|
+
value,
|
|
1183
|
+
onChange: (event) => onChange(event.target.value),
|
|
1184
|
+
onKeyDown,
|
|
1185
|
+
placeholder,
|
|
1186
|
+
dir,
|
|
1187
|
+
"aria-label": "Search options",
|
|
1188
|
+
style: {
|
|
1189
|
+
width: "100%",
|
|
1190
|
+
// Inline `padding: '6px 8px'` shorthand intentionally kept as a
|
|
1191
|
+
// string for the native HTML <input> — it's not an RN style prop.
|
|
1192
|
+
padding: `${px(colors.spacing["2"]) - 2}px ${px(colors.spacing["2"])}px`,
|
|
1193
|
+
fontFamily: colors.fontFamily.body,
|
|
1194
|
+
fontSize: px(colors.fontSize.sm),
|
|
1195
|
+
color: colors.semantic.text.default,
|
|
1196
|
+
backgroundColor: colors.semantic.background.elevated,
|
|
1197
|
+
border: `1px solid ${colors.semantic.border.default}`,
|
|
1198
|
+
borderRadius: px(colors.radius.sm),
|
|
1199
|
+
outline: "none"
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
)
|
|
1203
|
+
}
|
|
1204
|
+
);
|
|
1205
|
+
}, "SearchInput");
|
|
1206
|
+
var SelectList = /* @__PURE__ */ __name(({
|
|
1207
|
+
options,
|
|
1208
|
+
activeIndex,
|
|
1209
|
+
currentValue,
|
|
1210
|
+
selectedValues,
|
|
1211
|
+
multiple,
|
|
1212
|
+
onSelect,
|
|
1213
|
+
onActiveChange,
|
|
1214
|
+
renderOption,
|
|
1215
|
+
itemHeight,
|
|
1216
|
+
maxHeight,
|
|
1217
|
+
virtualized,
|
|
1218
|
+
loading,
|
|
1219
|
+
loadingMessage,
|
|
1220
|
+
noOptionsMessage,
|
|
1221
|
+
listboxId,
|
|
1222
|
+
onScroll
|
|
1223
|
+
}) => {
|
|
1224
|
+
const colors = useThemeColors();
|
|
1225
|
+
const [scrollTop, setScrollTop] = react.useState(0);
|
|
1226
|
+
const totalHeight = options.length * itemHeight;
|
|
1227
|
+
const visibleStart = virtualized ? Math.max(0, Math.floor(scrollTop / itemHeight) - VIRTUAL_OVERSCAN) : 0;
|
|
1228
|
+
const visibleEnd = virtualized ? Math.min(options.length, Math.ceil((scrollTop + maxHeight) / itemHeight) + VIRTUAL_OVERSCAN) : options.length;
|
|
1229
|
+
const handleScroll = /* @__PURE__ */ __name((event) => {
|
|
1230
|
+
if (virtualized) {
|
|
1231
|
+
setScrollTop(event.nativeEvent.contentOffset.y);
|
|
1232
|
+
}
|
|
1233
|
+
onScroll(event);
|
|
1234
|
+
}, "handleScroll");
|
|
1235
|
+
if (loading && options.length === 0) {
|
|
1236
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: { padding: px(colors.spacing["4"]), alignItems: "center" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1237
|
+
reactNative.Text,
|
|
1238
|
+
{
|
|
1239
|
+
style: {
|
|
1240
|
+
color: colors.semantic.text.muted,
|
|
1241
|
+
fontFamily: colors.fontFamily.body,
|
|
1242
|
+
fontSize: px(colors.fontSize.sm)
|
|
1243
|
+
},
|
|
1244
|
+
children: loadingMessage
|
|
1245
|
+
}
|
|
1246
|
+
) });
|
|
1247
|
+
}
|
|
1248
|
+
if (options.length === 0) {
|
|
1249
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: { padding: px(colors.spacing["4"]), alignItems: "center" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1250
|
+
reactNative.Text,
|
|
1251
|
+
{
|
|
1252
|
+
style: {
|
|
1253
|
+
color: colors.semantic.text.muted,
|
|
1254
|
+
fontFamily: colors.fontFamily.body,
|
|
1255
|
+
fontSize: px(colors.fontSize.sm)
|
|
1256
|
+
},
|
|
1257
|
+
children: noOptionsMessage
|
|
1258
|
+
}
|
|
1259
|
+
) });
|
|
1260
|
+
}
|
|
1261
|
+
const items = [];
|
|
1262
|
+
let lastGroup;
|
|
1263
|
+
for (let i = visibleStart; i < visibleEnd; i += 1) {
|
|
1264
|
+
const opt = options[i];
|
|
1265
|
+
if (!opt) {
|
|
1266
|
+
continue;
|
|
1267
|
+
}
|
|
1268
|
+
if (opt.group !== lastGroup && opt.group !== void 0) {
|
|
1269
|
+
items.push(
|
|
1270
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1271
|
+
reactNative.View,
|
|
1272
|
+
{
|
|
1273
|
+
style: {
|
|
1274
|
+
paddingHorizontal: px(colors.spacing["3"]),
|
|
1275
|
+
paddingTop: px(colors.spacing["2"]),
|
|
1276
|
+
paddingBottom: px(colors.spacing["1"]),
|
|
1277
|
+
position: virtualized ? "absolute" : "relative",
|
|
1278
|
+
top: virtualized ? i * itemHeight - px(colors.spacing["4"]) : void 0,
|
|
1279
|
+
left: 0,
|
|
1280
|
+
right: 0
|
|
1281
|
+
},
|
|
1282
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1283
|
+
reactNative.Text,
|
|
1284
|
+
{
|
|
1285
|
+
style: {
|
|
1286
|
+
color: colors.semantic.text.muted,
|
|
1287
|
+
fontFamily: colors.fontFamily.body,
|
|
1288
|
+
fontSize: 11,
|
|
1289
|
+
// group header — component-density literal — not from theme (smaller than xs)
|
|
1290
|
+
fontWeight: colors.fontWeight.semibold,
|
|
1291
|
+
textTransform: "uppercase",
|
|
1292
|
+
letterSpacing: 0.5
|
|
1293
|
+
},
|
|
1294
|
+
children: opt.group
|
|
1295
|
+
}
|
|
1296
|
+
)
|
|
1297
|
+
},
|
|
1298
|
+
`grp-${i}-${opt.group}`
|
|
1299
|
+
)
|
|
1300
|
+
);
|
|
1301
|
+
lastGroup = opt.group;
|
|
1302
|
+
}
|
|
1303
|
+
const selected = multiple ? selectedValues.includes(opt.value) : opt.value === currentValue;
|
|
1304
|
+
const active = i === activeIndex;
|
|
1305
|
+
const itemNode = renderOption ? renderOption(opt, { selected, active }) : /* @__PURE__ */ jsxRuntime.jsx(DefaultOptionRow, { option: opt, selected, active, multiple });
|
|
1306
|
+
items.push(
|
|
1307
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1308
|
+
reactNative.Pressable,
|
|
1309
|
+
{
|
|
1310
|
+
...{
|
|
1311
|
+
role: "option",
|
|
1312
|
+
accessibilityRole: "none",
|
|
1313
|
+
"aria-selected": selected,
|
|
1314
|
+
onMouseEnter: /* @__PURE__ */ __name(() => onActiveChange(i), "onMouseEnter"),
|
|
1315
|
+
...opt.disabled ? { "aria-disabled": true, disabled: true } : {}
|
|
1316
|
+
},
|
|
1317
|
+
onPress: () => onSelect(opt),
|
|
1318
|
+
style: {
|
|
1319
|
+
position: virtualized ? "absolute" : "relative",
|
|
1320
|
+
top: virtualized ? i * itemHeight : void 0,
|
|
1321
|
+
left: 0,
|
|
1322
|
+
right: 0,
|
|
1323
|
+
height: itemHeight,
|
|
1324
|
+
flexDirection: "row",
|
|
1325
|
+
alignItems: "center",
|
|
1326
|
+
paddingHorizontal: px(colors.spacing["3"]),
|
|
1327
|
+
backgroundColor: active ? colors.semantic.background.subtle : "transparent",
|
|
1328
|
+
opacity: opt.disabled ? 0.5 : 1
|
|
1329
|
+
},
|
|
1330
|
+
children: itemNode
|
|
1331
|
+
},
|
|
1332
|
+
`opt-${i}-${opt.value}`
|
|
1333
|
+
)
|
|
1334
|
+
);
|
|
1335
|
+
}
|
|
1336
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1337
|
+
reactNative.ScrollView,
|
|
1338
|
+
{
|
|
1339
|
+
nativeID: listboxId,
|
|
1340
|
+
onScroll: handleScroll,
|
|
1341
|
+
scrollEventThrottle: 16,
|
|
1342
|
+
style: { maxHeight },
|
|
1343
|
+
contentContainerStyle: virtualized ? { height: totalHeight, position: "relative" } : void 0,
|
|
1344
|
+
children: items
|
|
1345
|
+
}
|
|
1346
|
+
);
|
|
1347
|
+
}, "SelectList");
|
|
1348
|
+
var DefaultOptionRow = /* @__PURE__ */ __name(({
|
|
1349
|
+
option,
|
|
1350
|
+
selected,
|
|
1351
|
+
active,
|
|
1352
|
+
multiple = false
|
|
1353
|
+
}) => {
|
|
1354
|
+
const colors = useThemeColors();
|
|
1355
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: { flexDirection: "row", alignItems: "center", flex: 1, gap: px(colors.spacing["2"]) }, children: [
|
|
1356
|
+
multiple ? (
|
|
1357
|
+
// Inline checkbox-style indicator. We don't reuse <Checkbox>
|
|
1358
|
+
// here because the row is already a Pressable — nesting two
|
|
1359
|
+
// pressable surfaces breaks tap handling on native; this
|
|
1360
|
+
// is purely visual (the Pressable parent owns the toggle).
|
|
1361
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1362
|
+
reactNative.View,
|
|
1363
|
+
{
|
|
1364
|
+
"aria-hidden": true,
|
|
1365
|
+
accessibilityElementsHidden: true,
|
|
1366
|
+
importantForAccessibility: "no-hide-descendants",
|
|
1367
|
+
style: {
|
|
1368
|
+
width: 18,
|
|
1369
|
+
height: 18,
|
|
1370
|
+
borderWidth: 1,
|
|
1371
|
+
borderRadius: px(colors.radius.sm),
|
|
1372
|
+
borderColor: selected ? colors.semantic.interactive.primary : colors.semantic.border.strong,
|
|
1373
|
+
backgroundColor: selected ? colors.semantic.interactive.primary : "transparent",
|
|
1374
|
+
alignItems: "center",
|
|
1375
|
+
justifyContent: "center"
|
|
1376
|
+
},
|
|
1377
|
+
children: selected ? /* @__PURE__ */ jsxRuntime.jsx(defaultSemanticIcons.check, { size: 12, color: colors.semantic.text.inverted }) : null
|
|
1378
|
+
}
|
|
1379
|
+
)
|
|
1380
|
+
) : null,
|
|
1381
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1382
|
+
reactNative.Text,
|
|
1383
|
+
{
|
|
1384
|
+
style: {
|
|
1385
|
+
color: colors.semantic.text.default,
|
|
1386
|
+
fontFamily: colors.fontFamily.body,
|
|
1387
|
+
fontSize: px(colors.fontSize.sm),
|
|
1388
|
+
fontWeight: selected ? colors.fontWeight.semibold : colors.fontWeight.regular,
|
|
1389
|
+
flex: 1
|
|
1390
|
+
},
|
|
1391
|
+
numberOfLines: 1,
|
|
1392
|
+
children: option.label
|
|
1393
|
+
}
|
|
1394
|
+
),
|
|
1395
|
+
selected && !multiple ? /* @__PURE__ */ jsxRuntime.jsx(defaultSemanticIcons.check, { size: 16, color: colors.semantic.interactive.primary }) : null,
|
|
1396
|
+
active ? null : null
|
|
1397
|
+
] });
|
|
1398
|
+
}, "DefaultOptionRow");
|
|
1399
|
+
var MultiTriggerLabel = /* @__PURE__ */ __name(({
|
|
1400
|
+
options,
|
|
1401
|
+
placeholder,
|
|
1402
|
+
maxChips
|
|
1403
|
+
}) => {
|
|
1404
|
+
const colors = useThemeColors();
|
|
1405
|
+
if (options.length === 0) {
|
|
1406
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1407
|
+
reactNative.Text,
|
|
1408
|
+
{
|
|
1409
|
+
style: {
|
|
1410
|
+
color: colors.semantic.text.muted,
|
|
1411
|
+
fontFamily: colors.fontFamily.body,
|
|
1412
|
+
fontSize: px(colors.fontSize.sm),
|
|
1413
|
+
flex: 1
|
|
1414
|
+
},
|
|
1415
|
+
numberOfLines: 1,
|
|
1416
|
+
children: placeholder
|
|
1417
|
+
}
|
|
1418
|
+
);
|
|
1419
|
+
}
|
|
1420
|
+
if (options.length > maxChips) {
|
|
1421
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1422
|
+
reactNative.Text,
|
|
1423
|
+
{
|
|
1424
|
+
style: {
|
|
1425
|
+
color: colors.semantic.text.default,
|
|
1426
|
+
fontFamily: colors.fontFamily.body,
|
|
1427
|
+
fontSize: px(colors.fontSize.sm),
|
|
1428
|
+
fontWeight: colors.fontWeight.medium,
|
|
1429
|
+
fontVariant: ["tabular-nums"],
|
|
1430
|
+
flex: 1
|
|
1431
|
+
},
|
|
1432
|
+
numberOfLines: 1,
|
|
1433
|
+
children: [
|
|
1434
|
+
options.length,
|
|
1435
|
+
" selected"
|
|
1436
|
+
]
|
|
1437
|
+
}
|
|
1438
|
+
);
|
|
1439
|
+
}
|
|
1440
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1441
|
+
reactNative.View,
|
|
1442
|
+
{
|
|
1443
|
+
style: {
|
|
1444
|
+
flexDirection: "row",
|
|
1445
|
+
alignItems: "center",
|
|
1446
|
+
flexWrap: "wrap",
|
|
1447
|
+
rowGap: px(colors.spacing["1"]),
|
|
1448
|
+
columnGap: px(colors.spacing["1"]),
|
|
1449
|
+
flex: 1
|
|
1450
|
+
},
|
|
1451
|
+
children: options.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1452
|
+
reactNative.View,
|
|
1453
|
+
{
|
|
1454
|
+
style: {
|
|
1455
|
+
flexDirection: "row",
|
|
1456
|
+
alignItems: "center",
|
|
1457
|
+
paddingHorizontal: px(colors.spacing["2"]),
|
|
1458
|
+
paddingVertical: 2,
|
|
1459
|
+
borderRadius: px(colors.radius.sm),
|
|
1460
|
+
backgroundColor: colors.semantic.background.subtle,
|
|
1461
|
+
borderWidth: 1,
|
|
1462
|
+
borderColor: colors.semantic.border.default
|
|
1463
|
+
},
|
|
1464
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1465
|
+
reactNative.Text,
|
|
1466
|
+
{
|
|
1467
|
+
style: {
|
|
1468
|
+
color: colors.semantic.text.default,
|
|
1469
|
+
fontFamily: colors.fontFamily.body,
|
|
1470
|
+
fontSize: px(colors.fontSize.sm)
|
|
1471
|
+
},
|
|
1472
|
+
numberOfLines: 1,
|
|
1473
|
+
children: opt.label
|
|
1474
|
+
}
|
|
1475
|
+
)
|
|
1476
|
+
},
|
|
1477
|
+
`chip-${opt.value}`
|
|
1478
|
+
))
|
|
1479
|
+
}
|
|
1480
|
+
);
|
|
1481
|
+
}, "MultiTriggerLabel");
|
|
1482
|
+
var MultiSelectionHeader = /* @__PURE__ */ __name(({ count, onClearAll }) => {
|
|
1483
|
+
const colors = useThemeColors();
|
|
1484
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1485
|
+
reactNative.View,
|
|
1486
|
+
{
|
|
1487
|
+
style: {
|
|
1488
|
+
flexDirection: "row",
|
|
1489
|
+
alignItems: "center",
|
|
1490
|
+
justifyContent: "space-between",
|
|
1491
|
+
paddingHorizontal: px(colors.spacing["3"]),
|
|
1492
|
+
paddingVertical: px(colors.spacing["2"]),
|
|
1493
|
+
borderBottomWidth: 1,
|
|
1494
|
+
borderBottomColor: colors.semantic.border.default
|
|
1495
|
+
},
|
|
1496
|
+
children: [
|
|
1497
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1498
|
+
reactNative.Text,
|
|
1499
|
+
{
|
|
1500
|
+
style: {
|
|
1501
|
+
color: colors.semantic.text.muted,
|
|
1502
|
+
fontFamily: colors.fontFamily.body,
|
|
1503
|
+
fontSize: px(colors.fontSize.sm),
|
|
1504
|
+
fontVariant: ["tabular-nums"]
|
|
1505
|
+
},
|
|
1506
|
+
children: [
|
|
1507
|
+
count,
|
|
1508
|
+
" selected"
|
|
1509
|
+
]
|
|
1510
|
+
}
|
|
1511
|
+
),
|
|
1512
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1513
|
+
reactNative.Pressable,
|
|
1514
|
+
{
|
|
1515
|
+
role: "button",
|
|
1516
|
+
accessibilityRole: "button",
|
|
1517
|
+
"aria-label": "Clear all",
|
|
1518
|
+
accessibilityLabel: "Clear all",
|
|
1519
|
+
onPress: onClearAll,
|
|
1520
|
+
style: ({ pressed }) => ({
|
|
1521
|
+
paddingHorizontal: px(colors.spacing["2"]),
|
|
1522
|
+
paddingVertical: 2,
|
|
1523
|
+
borderRadius: px(colors.radius.sm),
|
|
1524
|
+
opacity: pressed ? 0.6 : 1
|
|
1525
|
+
}),
|
|
1526
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1527
|
+
reactNative.Text,
|
|
1528
|
+
{
|
|
1529
|
+
style: {
|
|
1530
|
+
color: colors.semantic.interactive.primary,
|
|
1531
|
+
fontFamily: colors.fontFamily.body,
|
|
1532
|
+
fontSize: px(colors.fontSize.sm),
|
|
1533
|
+
fontWeight: colors.fontWeight.medium
|
|
1534
|
+
},
|
|
1535
|
+
children: "Clear all"
|
|
1536
|
+
}
|
|
1537
|
+
)
|
|
1538
|
+
}
|
|
1539
|
+
)
|
|
1540
|
+
]
|
|
1541
|
+
}
|
|
1542
|
+
);
|
|
1543
|
+
}, "MultiSelectionHeader");
|
|
1544
|
+
var range = /* @__PURE__ */ __name((from, to) => {
|
|
1545
|
+
if (to < from) {
|
|
1546
|
+
return [];
|
|
1547
|
+
}
|
|
1548
|
+
const out = new Array(to - from + 1);
|
|
1549
|
+
for (let i = 0; i < out.length; i += 1) {
|
|
1550
|
+
out[i] = from + i;
|
|
1551
|
+
}
|
|
1552
|
+
return out;
|
|
1553
|
+
}, "range");
|
|
1554
|
+
function usePagination(args) {
|
|
1555
|
+
const {
|
|
1556
|
+
page: controlledPage,
|
|
1557
|
+
defaultPage = 1,
|
|
1558
|
+
pageCount,
|
|
1559
|
+
siblingCount = 1,
|
|
1560
|
+
boundaryCount = 1,
|
|
1561
|
+
showFirstLast = false,
|
|
1562
|
+
showPrevNext = true,
|
|
1563
|
+
onPageChange
|
|
1564
|
+
} = args;
|
|
1565
|
+
const isControlled = controlledPage !== void 0;
|
|
1566
|
+
const [uncontrolledPage, setUncontrolledPage] = react.useState(defaultPage);
|
|
1567
|
+
const onChangeRef = react.useRef(onPageChange);
|
|
1568
|
+
onChangeRef.current = onPageChange;
|
|
1569
|
+
const safePageCount = Math.max(1, Math.floor(pageCount));
|
|
1570
|
+
const rawPage = isControlled ? controlledPage : uncontrolledPage;
|
|
1571
|
+
const currentPage = Math.min(Math.max(1, Math.floor(rawPage)), safePageCount);
|
|
1572
|
+
const goToPage = react.useCallback(
|
|
1573
|
+
(next2) => {
|
|
1574
|
+
const clamped = Math.min(Math.max(1, Math.floor(next2)), Math.max(1, Math.floor(pageCount)));
|
|
1575
|
+
if (!isControlled) {
|
|
1576
|
+
setUncontrolledPage(clamped);
|
|
1577
|
+
}
|
|
1578
|
+
onChangeRef.current?.(clamped);
|
|
1579
|
+
},
|
|
1580
|
+
[isControlled, pageCount]
|
|
1581
|
+
);
|
|
1582
|
+
const prev = react.useCallback(() => goToPage(currentPage - 1), [goToPage, currentPage]);
|
|
1583
|
+
const next = react.useCallback(() => goToPage(currentPage + 1), [goToPage, currentPage]);
|
|
1584
|
+
const first = react.useCallback(() => goToPage(1), [goToPage]);
|
|
1585
|
+
const last = react.useCallback(() => goToPage(safePageCount), [goToPage, safePageCount]);
|
|
1586
|
+
const pages = react.useMemo(() => {
|
|
1587
|
+
const items = [];
|
|
1588
|
+
const safeSibling = Math.max(0, Math.floor(siblingCount));
|
|
1589
|
+
const safeBoundary = Math.max(0, Math.floor(boundaryCount));
|
|
1590
|
+
if (showFirstLast) {
|
|
1591
|
+
items.push({ type: "first", disabled: currentPage <= 1 });
|
|
1592
|
+
}
|
|
1593
|
+
if (showPrevNext) {
|
|
1594
|
+
items.push({ type: "prev", disabled: currentPage <= 1 });
|
|
1595
|
+
}
|
|
1596
|
+
const startPages = range(1, Math.min(safeBoundary, safePageCount));
|
|
1597
|
+
const endPages = range(Math.max(safePageCount - safeBoundary + 1, safeBoundary + 1), safePageCount);
|
|
1598
|
+
const siblingsStart = Math.max(
|
|
1599
|
+
Math.min(currentPage - safeSibling, safePageCount - safeBoundary - safeSibling * 2 - 1),
|
|
1600
|
+
safeBoundary + 2
|
|
1601
|
+
);
|
|
1602
|
+
const siblingsEnd = Math.min(
|
|
1603
|
+
Math.max(currentPage + safeSibling, safeBoundary + safeSibling * 2 + 2),
|
|
1604
|
+
endPages.length > 0 ? endPages[0] - 2 : safePageCount - 1
|
|
1605
|
+
);
|
|
1606
|
+
const middle = [];
|
|
1607
|
+
if (siblingsStart > safeBoundary + 2) {
|
|
1608
|
+
middle.push("ellipsis");
|
|
1609
|
+
} else if (safeBoundary + 1 < safePageCount - safeBoundary) {
|
|
1610
|
+
middle.push(safeBoundary + 1);
|
|
1611
|
+
}
|
|
1612
|
+
for (const p of range(siblingsStart, siblingsEnd)) {
|
|
1613
|
+
middle.push(p);
|
|
1614
|
+
}
|
|
1615
|
+
if (siblingsEnd < safePageCount - safeBoundary - 1) {
|
|
1616
|
+
middle.push("ellipsis");
|
|
1617
|
+
} else if (safePageCount - safeBoundary > safeBoundary) {
|
|
1618
|
+
middle.push(safePageCount - safeBoundary);
|
|
1619
|
+
}
|
|
1620
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1621
|
+
const pushPage = /* @__PURE__ */ __name((n) => {
|
|
1622
|
+
if (n < 1 || n > safePageCount || seen.has(n)) {
|
|
1623
|
+
return;
|
|
1624
|
+
}
|
|
1625
|
+
seen.add(n);
|
|
1626
|
+
items.push({ type: "page", page: n, selected: n === currentPage });
|
|
1627
|
+
}, "pushPage");
|
|
1628
|
+
for (const n of startPages) {
|
|
1629
|
+
pushPage(n);
|
|
1630
|
+
}
|
|
1631
|
+
for (const m of middle) {
|
|
1632
|
+
if (m === "ellipsis") {
|
|
1633
|
+
items.push({ type: "ellipsis" });
|
|
1634
|
+
} else {
|
|
1635
|
+
pushPage(m);
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
for (const n of endPages) {
|
|
1639
|
+
pushPage(n);
|
|
1640
|
+
}
|
|
1641
|
+
if (showPrevNext) {
|
|
1642
|
+
items.push({ type: "next", disabled: currentPage >= safePageCount });
|
|
1643
|
+
}
|
|
1644
|
+
if (showFirstLast) {
|
|
1645
|
+
items.push({ type: "last", disabled: currentPage >= safePageCount });
|
|
1646
|
+
}
|
|
1647
|
+
return items;
|
|
1648
|
+
}, [currentPage, safePageCount, siblingCount, boundaryCount, showFirstLast, showPrevNext]);
|
|
1649
|
+
return {
|
|
1650
|
+
page: currentPage,
|
|
1651
|
+
pages,
|
|
1652
|
+
canPrev: currentPage > 1,
|
|
1653
|
+
canNext: currentPage < safePageCount,
|
|
1654
|
+
goToPage,
|
|
1655
|
+
prev,
|
|
1656
|
+
next,
|
|
1657
|
+
first,
|
|
1658
|
+
last
|
|
1659
|
+
};
|
|
1660
|
+
}
|
|
1661
|
+
__name(usePagination, "usePagination");
|
|
1662
|
+
var PAGINATION_COMPACT_BREAKPOINT = 480;
|
|
1663
|
+
var PaginationContext = react.createContext(null);
|
|
1664
|
+
var usePaginationContext = /* @__PURE__ */ __name((label) => {
|
|
1665
|
+
const ctx = react.useContext(PaginationContext);
|
|
1666
|
+
if (!ctx) {
|
|
1667
|
+
throw new Error(`<${label}> must be rendered inside a <Pagination> or <Pagination.Root>.`);
|
|
1668
|
+
}
|
|
1669
|
+
return ctx;
|
|
1670
|
+
}, "usePaginationContext");
|
|
1671
|
+
var ItemButton = /* @__PURE__ */ __name(({ type, selected, disabled, ariaLabel, ariaCurrent, label, onPress, testID }) => {
|
|
1672
|
+
const colors = useThemeColors();
|
|
1673
|
+
const isChevron = type === "prev" || type === "next" || type === "first" || type === "last";
|
|
1674
|
+
const isInteractive = !disabled && type !== "ellipsis";
|
|
1675
|
+
const size = px(colors.spacing["8"]);
|
|
1676
|
+
if (type === "ellipsis") {
|
|
1677
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1678
|
+
reactNative.View,
|
|
1679
|
+
{
|
|
1680
|
+
"aria-hidden": true,
|
|
1681
|
+
accessibilityElementsHidden: true,
|
|
1682
|
+
importantForAccessibility: "no-hide-descendants",
|
|
1683
|
+
style: {
|
|
1684
|
+
minWidth: size,
|
|
1685
|
+
minHeight: size,
|
|
1686
|
+
alignItems: "center",
|
|
1687
|
+
justifyContent: "center"
|
|
1688
|
+
},
|
|
1689
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1690
|
+
reactNative.Text,
|
|
1691
|
+
{
|
|
1692
|
+
style: {
|
|
1693
|
+
fontFamily: colors.fontFamily.body,
|
|
1694
|
+
fontSize: px(colors.fontSize.sm),
|
|
1695
|
+
color: colors.semantic.text.muted,
|
|
1696
|
+
// Optical adjust so the dots sit on the row baseline.
|
|
1697
|
+
marginTop: -2,
|
|
1698
|
+
letterSpacing: 1
|
|
1699
|
+
},
|
|
1700
|
+
children: label
|
|
1701
|
+
}
|
|
1702
|
+
)
|
|
1703
|
+
}
|
|
1704
|
+
);
|
|
1705
|
+
}
|
|
1706
|
+
const baseStyle = {
|
|
1707
|
+
minWidth: size,
|
|
1708
|
+
height: size,
|
|
1709
|
+
paddingHorizontal: px(colors.spacing["2"]),
|
|
1710
|
+
alignItems: "center",
|
|
1711
|
+
justifyContent: "center",
|
|
1712
|
+
borderRadius: px(colors.radius.md),
|
|
1713
|
+
// Selected: filled pill in primary. Default: transparent. Press/hover
|
|
1714
|
+
// deltas overlay this in the style fn below.
|
|
1715
|
+
backgroundColor: selected ? colors.semantic.interactive.primary : "transparent",
|
|
1716
|
+
// A 1px transparent border is reserved on every item so the layout
|
|
1717
|
+
// stays stable when the selected one shows its accent border.
|
|
1718
|
+
borderWidth: 1,
|
|
1719
|
+
borderColor: selected ? colors.semantic.interactive.primary : "transparent",
|
|
1720
|
+
opacity: disabled ? 0.35 : 1
|
|
1721
|
+
};
|
|
1722
|
+
const webExtras = reactNative.Platform.OS === "web" ? {
|
|
1723
|
+
transitionProperty: "background-color, color, border-color",
|
|
1724
|
+
transitionDuration: "120ms",
|
|
1725
|
+
transitionTimingFunction: "cubic-bezier(0.2, 0, 0, 1)"
|
|
1726
|
+
} : null;
|
|
1727
|
+
const staticStyle = { ...baseStyle, ...webExtras ?? {} };
|
|
1728
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1729
|
+
reactNative.Pressable,
|
|
1730
|
+
{
|
|
1731
|
+
...testID !== void 0 ? { testID } : {},
|
|
1732
|
+
role: "button",
|
|
1733
|
+
accessibilityRole: "button",
|
|
1734
|
+
accessibilityLabel: ariaLabel,
|
|
1735
|
+
"aria-label": ariaLabel,
|
|
1736
|
+
...ariaCurrent ? { "aria-current": ariaCurrent } : {},
|
|
1737
|
+
disabled,
|
|
1738
|
+
"aria-disabled": disabled || void 0,
|
|
1739
|
+
onPress: isInteractive ? onPress : void 0,
|
|
1740
|
+
style: reactNative.Platform.OS === "web" ? (state) => {
|
|
1741
|
+
const { pressed, hovered } = state;
|
|
1742
|
+
const interactive = !selected && (pressed || hovered) ? colors.semantic.background.subtle : staticStyle.backgroundColor;
|
|
1743
|
+
return { ...staticStyle, backgroundColor: interactive };
|
|
1744
|
+
} : staticStyle,
|
|
1745
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1746
|
+
reactNative.Text,
|
|
1747
|
+
{
|
|
1748
|
+
style: {
|
|
1749
|
+
fontFamily: colors.fontFamily.body,
|
|
1750
|
+
fontSize: isChevron ? px(colors.fontSize.md) : px(colors.fontSize.sm),
|
|
1751
|
+
lineHeight: px(colors.fontSize.md),
|
|
1752
|
+
color: selected ? colors.semantic.text.inverted : disabled ? colors.semantic.text.muted : colors.semantic.text.default,
|
|
1753
|
+
fontWeight: selected ? colors.fontWeight.semibold : colors.fontWeight.medium,
|
|
1754
|
+
fontVariant: ["tabular-nums"],
|
|
1755
|
+
// Chevron glyphs sit a hair high in most fonts.
|
|
1756
|
+
marginTop: isChevron ? -1 : 0
|
|
1757
|
+
},
|
|
1758
|
+
children: label
|
|
1759
|
+
}
|
|
1760
|
+
)
|
|
1761
|
+
}
|
|
1762
|
+
);
|
|
1763
|
+
}, "ItemButton");
|
|
1764
|
+
var LiveRegion = /* @__PURE__ */ __name(({ message }) => {
|
|
1765
|
+
if (reactNative.Platform.OS === "web") {
|
|
1766
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1767
|
+
reactNative.View,
|
|
1768
|
+
{
|
|
1769
|
+
style: {
|
|
1770
|
+
position: "absolute",
|
|
1771
|
+
width: 1,
|
|
1772
|
+
height: 1,
|
|
1773
|
+
overflow: "hidden",
|
|
1774
|
+
opacity: 0
|
|
1775
|
+
},
|
|
1776
|
+
role: "status",
|
|
1777
|
+
"aria-live": "polite",
|
|
1778
|
+
"aria-atomic": true,
|
|
1779
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityLiveRegion: "polite", children: message })
|
|
1780
|
+
}
|
|
1781
|
+
);
|
|
1782
|
+
}
|
|
1783
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityLiveRegion: "polite", style: { width: 0, height: 0 }, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { children: message }) });
|
|
1784
|
+
}, "LiveRegion");
|
|
1785
|
+
var ItemsRenderer = /* @__PURE__ */ __name(({ items, onItemPress }) => {
|
|
1786
|
+
const { labels, renderItem, dir } = usePaginationContext("Pagination.Items");
|
|
1787
|
+
const elements = items.map((item, idx) => {
|
|
1788
|
+
const key = `${item.type}-${item.page ?? idx}-${idx}`;
|
|
1789
|
+
const ariaLabel = ariaLabelFor(item, labels);
|
|
1790
|
+
const ariaCurrent = item.selected ? "page" : void 0;
|
|
1791
|
+
const display = displayLabelFor(item, labels, dir);
|
|
1792
|
+
const onPress = /* @__PURE__ */ __name(() => onItemPress(item), "onPress");
|
|
1793
|
+
if (renderItem && item.type !== "ellipsis") {
|
|
1794
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { children: renderItem({
|
|
1795
|
+
type: item.type,
|
|
1796
|
+
...item.page !== void 0 ? { page: item.page } : {},
|
|
1797
|
+
selected: item.selected ?? false,
|
|
1798
|
+
disabled: item.disabled ?? false,
|
|
1799
|
+
ariaLabel,
|
|
1800
|
+
...ariaCurrent ? { ariaCurrent } : {},
|
|
1801
|
+
children: display,
|
|
1802
|
+
onPress
|
|
1803
|
+
}) }, key);
|
|
1804
|
+
}
|
|
1805
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1806
|
+
ItemButton,
|
|
1807
|
+
{
|
|
1808
|
+
type: item.type,
|
|
1809
|
+
...item.page !== void 0 ? { page: item.page } : {},
|
|
1810
|
+
selected: item.selected ?? false,
|
|
1811
|
+
disabled: item.disabled ?? false,
|
|
1812
|
+
ariaLabel,
|
|
1813
|
+
...ariaCurrent ? { ariaCurrent } : {},
|
|
1814
|
+
label: display,
|
|
1815
|
+
onPress
|
|
1816
|
+
},
|
|
1817
|
+
key
|
|
1818
|
+
);
|
|
1819
|
+
});
|
|
1820
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: elements });
|
|
1821
|
+
}, "ItemsRenderer");
|
|
1822
|
+
function ariaLabelFor(item, labels) {
|
|
1823
|
+
switch (item.type) {
|
|
1824
|
+
case "first":
|
|
1825
|
+
return labels.first;
|
|
1826
|
+
case "prev":
|
|
1827
|
+
return labels.prev;
|
|
1828
|
+
case "next":
|
|
1829
|
+
return labels.next;
|
|
1830
|
+
case "last":
|
|
1831
|
+
return labels.last;
|
|
1832
|
+
case "ellipsis":
|
|
1833
|
+
return labels.ellipsis;
|
|
1834
|
+
case "page":
|
|
1835
|
+
return item.selected ? labels.currentPage : labels.gotoPage(item.page ?? 0);
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
__name(ariaLabelFor, "ariaLabelFor");
|
|
1839
|
+
function displayLabelFor(item, labels, dir) {
|
|
1840
|
+
const flip = dir === "rtl";
|
|
1841
|
+
switch (item.type) {
|
|
1842
|
+
case "first":
|
|
1843
|
+
return flip ? "\xBB" : "\xAB";
|
|
1844
|
+
case "last":
|
|
1845
|
+
return flip ? "\xAB" : "\xBB";
|
|
1846
|
+
case "prev":
|
|
1847
|
+
return flip ? "\u203A" : "\u2039";
|
|
1848
|
+
case "next":
|
|
1849
|
+
return flip ? "\u2039" : "\u203A";
|
|
1850
|
+
case "ellipsis":
|
|
1851
|
+
return "\u2026";
|
|
1852
|
+
case "page":
|
|
1853
|
+
return String(item.page ?? "");
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
__name(displayLabelFor, "displayLabelFor");
|
|
1857
|
+
var CompactView = /* @__PURE__ */ __name(({
|
|
1858
|
+
onPrev,
|
|
1859
|
+
onNext,
|
|
1860
|
+
canPrev,
|
|
1861
|
+
canNext,
|
|
1862
|
+
pageLabel
|
|
1863
|
+
}) => {
|
|
1864
|
+
const colors = useThemeColors();
|
|
1865
|
+
const { labels, dir } = usePaginationContext("Pagination(compact)");
|
|
1866
|
+
const flip = dir === "rtl";
|
|
1867
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1868
|
+
reactNative.View,
|
|
1869
|
+
{
|
|
1870
|
+
style: {
|
|
1871
|
+
flexDirection: "row",
|
|
1872
|
+
alignItems: "center",
|
|
1873
|
+
justifyContent: "space-between",
|
|
1874
|
+
gap: px(colors.spacing["1"]),
|
|
1875
|
+
flexGrow: 1
|
|
1876
|
+
},
|
|
1877
|
+
children: [
|
|
1878
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1879
|
+
ItemButton,
|
|
1880
|
+
{
|
|
1881
|
+
type: "prev",
|
|
1882
|
+
selected: false,
|
|
1883
|
+
disabled: !canPrev,
|
|
1884
|
+
ariaLabel: labels.prev,
|
|
1885
|
+
label: flip ? "\u203A" : "\u2039",
|
|
1886
|
+
onPress: onPrev
|
|
1887
|
+
}
|
|
1888
|
+
),
|
|
1889
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1890
|
+
reactNative.View,
|
|
1891
|
+
{
|
|
1892
|
+
style: {
|
|
1893
|
+
flexGrow: 1,
|
|
1894
|
+
alignItems: "center",
|
|
1895
|
+
justifyContent: "center",
|
|
1896
|
+
paddingHorizontal: px(colors.spacing["3"])
|
|
1897
|
+
},
|
|
1898
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1899
|
+
reactNative.Text,
|
|
1900
|
+
{
|
|
1901
|
+
style: {
|
|
1902
|
+
fontFamily: colors.fontFamily.body,
|
|
1903
|
+
fontSize: px(colors.fontSize.sm),
|
|
1904
|
+
color: colors.semantic.text.default,
|
|
1905
|
+
fontWeight: colors.fontWeight.medium,
|
|
1906
|
+
fontVariant: ["tabular-nums"]
|
|
1907
|
+
},
|
|
1908
|
+
children: pageLabel
|
|
1909
|
+
}
|
|
1910
|
+
)
|
|
1911
|
+
}
|
|
1912
|
+
),
|
|
1913
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1914
|
+
ItemButton,
|
|
1915
|
+
{
|
|
1916
|
+
type: "next",
|
|
1917
|
+
selected: false,
|
|
1918
|
+
disabled: !canNext,
|
|
1919
|
+
ariaLabel: labels.next,
|
|
1920
|
+
label: flip ? "\u2039" : "\u203A",
|
|
1921
|
+
onPress: onNext
|
|
1922
|
+
}
|
|
1923
|
+
)
|
|
1924
|
+
]
|
|
1925
|
+
}
|
|
1926
|
+
);
|
|
1927
|
+
}, "CompactView");
|
|
1928
|
+
var ANNOUNCE_DEBOUNCE_MS = 150;
|
|
1929
|
+
var PaginationRoot = /* @__PURE__ */ __name((props) => {
|
|
1930
|
+
const {
|
|
1931
|
+
page: controlledPage,
|
|
1932
|
+
defaultPage = 1,
|
|
1933
|
+
pageCount,
|
|
1934
|
+
siblingCount = 1,
|
|
1935
|
+
boundaryCount = 1,
|
|
1936
|
+
showFirstLast = false,
|
|
1937
|
+
hideOnSinglePage = true,
|
|
1938
|
+
variant = "auto",
|
|
1939
|
+
showRange = false,
|
|
1940
|
+
itemCount,
|
|
1941
|
+
pageSize: pageSizeProp,
|
|
1942
|
+
onPageChange,
|
|
1943
|
+
renderItem,
|
|
1944
|
+
dir = "ltr",
|
|
1945
|
+
previousLabel,
|
|
1946
|
+
nextLabel,
|
|
1947
|
+
firstLabel,
|
|
1948
|
+
lastLabel,
|
|
1949
|
+
ariaLabel,
|
|
1950
|
+
className,
|
|
1951
|
+
testID,
|
|
1952
|
+
children
|
|
1953
|
+
} = props;
|
|
1954
|
+
const { t } = useTranslation();
|
|
1955
|
+
const colors = useThemeColors();
|
|
1956
|
+
const { width } = reactNative.useWindowDimensions();
|
|
1957
|
+
const [internalPageSize, setInternalPageSize] = react.useState(pageSizeProp);
|
|
1958
|
+
react.useEffect(() => {
|
|
1959
|
+
setInternalPageSize(pageSizeProp);
|
|
1960
|
+
}, [pageSizeProp]);
|
|
1961
|
+
const effectivePageSize = pageSizeProp ?? internalPageSize;
|
|
1962
|
+
const labels = react.useMemo(
|
|
1963
|
+
() => ({
|
|
1964
|
+
prev: previousLabel ?? t("pagination.previous", { defaultValue: "Previous page" }),
|
|
1965
|
+
next: nextLabel ?? t("pagination.next", { defaultValue: "Next page" }),
|
|
1966
|
+
first: firstLabel ?? t("pagination.first", { defaultValue: "First page" }),
|
|
1967
|
+
last: lastLabel ?? t("pagination.last", { defaultValue: "Last page" }),
|
|
1968
|
+
ellipsis: t("pagination.ellipsis", { defaultValue: "More pages" }),
|
|
1969
|
+
currentPage: t("pagination.currentPage", { defaultValue: "Current page" }),
|
|
1970
|
+
gotoPage: /* @__PURE__ */ __name((n) => t("pagination.gotoPage", { page: n, defaultValue: `Go to page ${n}` }), "gotoPage"),
|
|
1971
|
+
rangeFmt: /* @__PURE__ */ __name((from, to, total) => t("pagination.range", {
|
|
1972
|
+
from,
|
|
1973
|
+
to,
|
|
1974
|
+
total,
|
|
1975
|
+
defaultValue: `Showing ${from}\u2013${to} of ${total}`
|
|
1976
|
+
}), "rangeFmt"),
|
|
1977
|
+
pageOfFmt: /* @__PURE__ */ __name((p, total) => t("pagination.pageOf", { page: p, total, defaultValue: `Page ${p} of ${total}` }), "pageOfFmt"),
|
|
1978
|
+
pageSize: t("pagination.pageSizeLabel", { defaultValue: "Items per page" }),
|
|
1979
|
+
jumperLabel: t("pagination.jumperLabel", { defaultValue: "Go to page" }),
|
|
1980
|
+
jumperPlaceholder: t("pagination.jumperPlaceholder", { defaultValue: "#" })
|
|
1981
|
+
}),
|
|
1982
|
+
[t, previousLabel, nextLabel, firstLabel, lastLabel]
|
|
1983
|
+
);
|
|
1984
|
+
const [announcement, setAnnouncement] = react.useState("");
|
|
1985
|
+
const announceTimer = react.useRef(null);
|
|
1986
|
+
react.useEffect(() => {
|
|
1987
|
+
return () => {
|
|
1988
|
+
if (announceTimer.current) {
|
|
1989
|
+
clearTimeout(announceTimer.current);
|
|
1990
|
+
}
|
|
1991
|
+
};
|
|
1992
|
+
}, []);
|
|
1993
|
+
const handlePageChange = react.useCallback(
|
|
1994
|
+
(next) => {
|
|
1995
|
+
onPageChange?.(next, effectivePageSize !== void 0 ? { pageSize: effectivePageSize } : void 0);
|
|
1996
|
+
if (announceTimer.current) {
|
|
1997
|
+
clearTimeout(announceTimer.current);
|
|
1998
|
+
}
|
|
1999
|
+
announceTimer.current = setTimeout(() => {
|
|
2000
|
+
setAnnouncement(labels.pageOfFmt(next, Math.max(1, pageCount)));
|
|
2001
|
+
}, ANNOUNCE_DEBOUNCE_MS);
|
|
2002
|
+
},
|
|
2003
|
+
[onPageChange, effectivePageSize, labels, pageCount]
|
|
2004
|
+
);
|
|
2005
|
+
const setPageSize = react.useCallback(
|
|
2006
|
+
(next) => {
|
|
2007
|
+
if (pageSizeProp === void 0) {
|
|
2008
|
+
setInternalPageSize(next);
|
|
2009
|
+
}
|
|
2010
|
+
onPageChange?.(1, { pageSize: next });
|
|
2011
|
+
},
|
|
2012
|
+
[onPageChange, pageSizeProp]
|
|
2013
|
+
);
|
|
2014
|
+
const pagination = usePagination({
|
|
2015
|
+
...controlledPage !== void 0 ? { page: controlledPage } : {},
|
|
2016
|
+
defaultPage,
|
|
2017
|
+
pageCount,
|
|
2018
|
+
siblingCount,
|
|
2019
|
+
boundaryCount,
|
|
2020
|
+
showFirstLast,
|
|
2021
|
+
onPageChange: handlePageChange
|
|
2022
|
+
});
|
|
2023
|
+
if (hideOnSinglePage && Math.max(1, pageCount) <= 1) {
|
|
2024
|
+
return null;
|
|
2025
|
+
}
|
|
2026
|
+
const ctxValue = {
|
|
2027
|
+
page: pagination.page,
|
|
2028
|
+
pageCount: Math.max(1, pageCount),
|
|
2029
|
+
pageSize: effectivePageSize,
|
|
2030
|
+
itemCount,
|
|
2031
|
+
siblingCount,
|
|
2032
|
+
boundaryCount,
|
|
2033
|
+
showFirstLast,
|
|
2034
|
+
dir,
|
|
2035
|
+
labels,
|
|
2036
|
+
...renderItem ? { renderItem } : {},
|
|
2037
|
+
goToPage: pagination.goToPage,
|
|
2038
|
+
setPageSize
|
|
2039
|
+
};
|
|
2040
|
+
if (children !== void 0) {
|
|
2041
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(PaginationContext.Provider, { value: ctxValue, children: [
|
|
2042
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2043
|
+
reactNative.View,
|
|
2044
|
+
{
|
|
2045
|
+
...testID !== void 0 ? { testID } : {},
|
|
2046
|
+
role: "navigation",
|
|
2047
|
+
"aria-label": ariaLabel ?? t("pagination.ariaLabel", { defaultValue: "Pagination" }),
|
|
2048
|
+
accessibilityLabel: ariaLabel ?? t("pagination.ariaLabel", { defaultValue: "Pagination" }),
|
|
2049
|
+
accessible: true,
|
|
2050
|
+
className: cn("flex-row items-center flex-wrap", className),
|
|
2051
|
+
style: {
|
|
2052
|
+
flexDirection: "row",
|
|
2053
|
+
alignItems: "center",
|
|
2054
|
+
flexWrap: "wrap",
|
|
2055
|
+
rowGap: px(colors.spacing["2"]),
|
|
2056
|
+
columnGap: px(colors.spacing["1"]),
|
|
2057
|
+
direction: dir
|
|
2058
|
+
},
|
|
2059
|
+
children
|
|
2060
|
+
}
|
|
2061
|
+
),
|
|
2062
|
+
/* @__PURE__ */ jsxRuntime.jsx(LiveRegion, { message: announcement })
|
|
2063
|
+
] });
|
|
2064
|
+
}
|
|
2065
|
+
const isCompact = variant === "compact" || variant === "auto" && width > 0 && width < PAGINATION_COMPACT_BREAKPOINT;
|
|
2066
|
+
const onItemPress = /* @__PURE__ */ __name((item) => {
|
|
2067
|
+
if (item.disabled) {
|
|
2068
|
+
return;
|
|
2069
|
+
}
|
|
2070
|
+
switch (item.type) {
|
|
2071
|
+
case "first":
|
|
2072
|
+
pagination.first();
|
|
2073
|
+
return;
|
|
2074
|
+
case "prev":
|
|
2075
|
+
pagination.prev();
|
|
2076
|
+
return;
|
|
2077
|
+
case "next":
|
|
2078
|
+
pagination.next();
|
|
2079
|
+
return;
|
|
2080
|
+
case "last":
|
|
2081
|
+
pagination.last();
|
|
2082
|
+
return;
|
|
2083
|
+
case "page":
|
|
2084
|
+
if (item.page !== void 0) {
|
|
2085
|
+
pagination.goToPage(item.page);
|
|
2086
|
+
}
|
|
2087
|
+
return;
|
|
2088
|
+
case "ellipsis":
|
|
2089
|
+
return;
|
|
2090
|
+
}
|
|
2091
|
+
}, "onItemPress");
|
|
2092
|
+
const showRangeBlock = showRange && itemCount !== void 0 && effectivePageSize !== void 0;
|
|
2093
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(PaginationContext.Provider, { value: ctxValue, children: [
|
|
2094
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2095
|
+
reactNative.View,
|
|
2096
|
+
{
|
|
2097
|
+
...testID !== void 0 ? { testID } : {},
|
|
2098
|
+
role: "navigation",
|
|
2099
|
+
"aria-label": ariaLabel ?? t("pagination.ariaLabel", { defaultValue: "Pagination" }),
|
|
2100
|
+
accessibilityLabel: ariaLabel ?? t("pagination.ariaLabel", { defaultValue: "Pagination" }),
|
|
2101
|
+
accessible: true,
|
|
2102
|
+
className: cn(isCompact ? "flex-col items-stretch" : "flex-row items-center flex-wrap", className),
|
|
2103
|
+
style: {
|
|
2104
|
+
// Compact mode lays out as a column so the Range/PageSize
|
|
2105
|
+
// block falls below the controls instead of overflowing
|
|
2106
|
+
// a phone-width row. Numbered mode wraps on overflow.
|
|
2107
|
+
flexDirection: isCompact ? "column" : "row",
|
|
2108
|
+
alignItems: isCompact ? "stretch" : "center",
|
|
2109
|
+
flexWrap: isCompact ? "nowrap" : "wrap",
|
|
2110
|
+
rowGap: px(colors.spacing["2"]),
|
|
2111
|
+
columnGap: px(colors.spacing["1"]),
|
|
2112
|
+
direction: dir
|
|
2113
|
+
},
|
|
2114
|
+
children: [
|
|
2115
|
+
isCompact ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2116
|
+
CompactView,
|
|
2117
|
+
{
|
|
2118
|
+
onPrev: pagination.prev,
|
|
2119
|
+
onNext: pagination.next,
|
|
2120
|
+
canPrev: pagination.canPrev,
|
|
2121
|
+
canNext: pagination.canNext,
|
|
2122
|
+
pageLabel: labels.pageOfFmt(pagination.page, Math.max(1, pageCount))
|
|
2123
|
+
}
|
|
2124
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(ItemsRenderer, { items: pagination.pages, onItemPress }),
|
|
2125
|
+
showRangeBlock ? /* @__PURE__ */ jsxRuntime.jsx(PaginationRange, {}) : null
|
|
2126
|
+
]
|
|
2127
|
+
}
|
|
2128
|
+
),
|
|
2129
|
+
/* @__PURE__ */ jsxRuntime.jsx(LiveRegion, { message: announcement })
|
|
2130
|
+
] });
|
|
2131
|
+
}, "PaginationRoot");
|
|
2132
|
+
var CompoundActionButton = /* @__PURE__ */ __name(({
|
|
2133
|
+
actionType,
|
|
2134
|
+
asChild,
|
|
2135
|
+
children,
|
|
2136
|
+
testID
|
|
2137
|
+
}) => {
|
|
2138
|
+
const ctx = usePaginationContext(`Pagination.${actionType[0].toUpperCase() + actionType.slice(1)}`);
|
|
2139
|
+
const disabled = actionType === "prev" || actionType === "first" ? ctx.page <= 1 : ctx.page >= ctx.pageCount;
|
|
2140
|
+
const onPress = /* @__PURE__ */ __name(() => {
|
|
2141
|
+
if (disabled) {
|
|
2142
|
+
return;
|
|
2143
|
+
}
|
|
2144
|
+
switch (actionType) {
|
|
2145
|
+
case "first":
|
|
2146
|
+
ctx.goToPage(1);
|
|
2147
|
+
return;
|
|
2148
|
+
case "prev":
|
|
2149
|
+
ctx.goToPage(ctx.page - 1);
|
|
2150
|
+
return;
|
|
2151
|
+
case "next":
|
|
2152
|
+
ctx.goToPage(ctx.page + 1);
|
|
2153
|
+
return;
|
|
2154
|
+
case "last":
|
|
2155
|
+
ctx.goToPage(ctx.pageCount);
|
|
2156
|
+
return;
|
|
2157
|
+
}
|
|
2158
|
+
}, "onPress");
|
|
2159
|
+
const ariaLabel = actionType === "prev" ? ctx.labels.prev : actionType === "next" ? ctx.labels.next : actionType === "first" ? ctx.labels.first : ctx.labels.last;
|
|
2160
|
+
if (asChild) {
|
|
2161
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2162
|
+
Slot,
|
|
2163
|
+
{
|
|
2164
|
+
"aria-label": ariaLabel,
|
|
2165
|
+
"aria-disabled": disabled || void 0,
|
|
2166
|
+
onPress,
|
|
2167
|
+
onClick: onPress,
|
|
2168
|
+
children
|
|
2169
|
+
}
|
|
2170
|
+
);
|
|
2171
|
+
}
|
|
2172
|
+
const fallbackGlyph = actionType === "prev" ? "\u2039" : actionType === "next" ? "\u203A" : actionType === "first" ? "\xAB" : "\xBB";
|
|
2173
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2174
|
+
ItemButton,
|
|
2175
|
+
{
|
|
2176
|
+
type: actionType,
|
|
2177
|
+
selected: false,
|
|
2178
|
+
disabled,
|
|
2179
|
+
ariaLabel,
|
|
2180
|
+
label: children ?? fallbackGlyph,
|
|
2181
|
+
onPress,
|
|
2182
|
+
...testID !== void 0 ? { testID } : {}
|
|
2183
|
+
}
|
|
2184
|
+
);
|
|
2185
|
+
}, "CompoundActionButton");
|
|
2186
|
+
var PaginationPrev = /* @__PURE__ */ __name(({ asChild, children, testID }) => CompoundActionButton({
|
|
2187
|
+
actionType: "prev",
|
|
2188
|
+
...asChild !== void 0 ? { asChild } : {},
|
|
2189
|
+
...children !== void 0 ? { children } : {},
|
|
2190
|
+
...testID !== void 0 ? { testID } : {}
|
|
2191
|
+
}), "PaginationPrev");
|
|
2192
|
+
var PaginationNext = /* @__PURE__ */ __name(({ asChild, children, testID }) => CompoundActionButton({
|
|
2193
|
+
actionType: "next",
|
|
2194
|
+
...asChild !== void 0 ? { asChild } : {},
|
|
2195
|
+
...children !== void 0 ? { children } : {},
|
|
2196
|
+
...testID !== void 0 ? { testID } : {}
|
|
2197
|
+
}), "PaginationNext");
|
|
2198
|
+
var PaginationFirst = /* @__PURE__ */ __name(({ asChild, children, testID }) => CompoundActionButton({
|
|
2199
|
+
actionType: "first",
|
|
2200
|
+
...asChild !== void 0 ? { asChild } : {},
|
|
2201
|
+
...children !== void 0 ? { children } : {},
|
|
2202
|
+
...testID !== void 0 ? { testID } : {}
|
|
2203
|
+
}), "PaginationFirst");
|
|
2204
|
+
var PaginationLast = /* @__PURE__ */ __name(({ asChild, children, testID }) => CompoundActionButton({
|
|
2205
|
+
actionType: "last",
|
|
2206
|
+
...asChild !== void 0 ? { asChild } : {},
|
|
2207
|
+
...children !== void 0 ? { children } : {},
|
|
2208
|
+
...testID !== void 0 ? { testID } : {}
|
|
2209
|
+
}), "PaginationLast");
|
|
2210
|
+
var PaginationItem = /* @__PURE__ */ __name(({
|
|
2211
|
+
page,
|
|
2212
|
+
asChild,
|
|
2213
|
+
children,
|
|
2214
|
+
testID
|
|
2215
|
+
}) => {
|
|
2216
|
+
const ctx = usePaginationContext("Pagination.Item");
|
|
2217
|
+
const selected = page === ctx.page;
|
|
2218
|
+
const onPress = /* @__PURE__ */ __name(() => ctx.goToPage(page), "onPress");
|
|
2219
|
+
const ariaLabel = selected ? ctx.labels.currentPage : ctx.labels.gotoPage(page);
|
|
2220
|
+
if (asChild) {
|
|
2221
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2222
|
+
Slot,
|
|
2223
|
+
{
|
|
2224
|
+
"aria-label": ariaLabel,
|
|
2225
|
+
...selected ? { "aria-current": "page" } : {},
|
|
2226
|
+
onPress,
|
|
2227
|
+
onClick: onPress,
|
|
2228
|
+
children
|
|
2229
|
+
}
|
|
2230
|
+
);
|
|
2231
|
+
}
|
|
2232
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2233
|
+
ItemButton,
|
|
2234
|
+
{
|
|
2235
|
+
type: "page",
|
|
2236
|
+
page,
|
|
2237
|
+
selected,
|
|
2238
|
+
disabled: false,
|
|
2239
|
+
ariaLabel,
|
|
2240
|
+
...selected ? { ariaCurrent: "page" } : {},
|
|
2241
|
+
label: children ?? String(page),
|
|
2242
|
+
onPress,
|
|
2243
|
+
...testID !== void 0 ? { testID } : {}
|
|
2244
|
+
}
|
|
2245
|
+
);
|
|
2246
|
+
}, "PaginationItem");
|
|
2247
|
+
var PaginationItems = /* @__PURE__ */ __name(({ children }) => {
|
|
2248
|
+
const ctx = usePaginationContext("Pagination.Items");
|
|
2249
|
+
const result = usePagination({
|
|
2250
|
+
page: ctx.page,
|
|
2251
|
+
pageCount: ctx.pageCount,
|
|
2252
|
+
siblingCount: ctx.siblingCount,
|
|
2253
|
+
boundaryCount: ctx.boundaryCount,
|
|
2254
|
+
showFirstLast: false,
|
|
2255
|
+
showPrevNext: false
|
|
2256
|
+
});
|
|
2257
|
+
if (children !== void 0) {
|
|
2258
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
2259
|
+
}
|
|
2260
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2261
|
+
ItemsRenderer,
|
|
2262
|
+
{
|
|
2263
|
+
items: result.pages,
|
|
2264
|
+
onItemPress: (item) => {
|
|
2265
|
+
if (item.type === "page" && item.page !== void 0) {
|
|
2266
|
+
ctx.goToPage(item.page);
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
);
|
|
2271
|
+
}, "PaginationItems");
|
|
2272
|
+
var PaginationEllipsis = /* @__PURE__ */ __name(({ children }) => {
|
|
2273
|
+
const ctx = usePaginationContext("Pagination.Ellipsis");
|
|
2274
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2275
|
+
ItemButton,
|
|
2276
|
+
{
|
|
2277
|
+
type: "ellipsis",
|
|
2278
|
+
selected: false,
|
|
2279
|
+
disabled: true,
|
|
2280
|
+
label: children ?? "\u2026",
|
|
2281
|
+
ariaLabel: ctx.labels.ellipsis,
|
|
2282
|
+
onPress: () => {
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
);
|
|
2286
|
+
}, "PaginationEllipsis");
|
|
2287
|
+
var PaginationRange = /* @__PURE__ */ __name(() => {
|
|
2288
|
+
const ctx = usePaginationContext("Pagination.Range");
|
|
2289
|
+
const colors = useThemeColors();
|
|
2290
|
+
if (ctx.itemCount === void 0 || ctx.pageSize === void 0) {
|
|
2291
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2292
|
+
console.warn("<Pagination.Range> requires both `itemCount` and `pageSize` on <Pagination>.");
|
|
2293
|
+
}
|
|
2294
|
+
return null;
|
|
2295
|
+
}
|
|
2296
|
+
const from = (ctx.page - 1) * ctx.pageSize + 1;
|
|
2297
|
+
const to = Math.min(ctx.itemCount, ctx.page * ctx.pageSize);
|
|
2298
|
+
const message = ctx.labels.rangeFmt(from, to, ctx.itemCount);
|
|
2299
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2300
|
+
reactNative.Text,
|
|
2301
|
+
{
|
|
2302
|
+
role: "status",
|
|
2303
|
+
"aria-live": "polite",
|
|
2304
|
+
style: {
|
|
2305
|
+
fontFamily: colors.fontFamily.body,
|
|
2306
|
+
fontSize: px(colors.fontSize.sm),
|
|
2307
|
+
color: colors.semantic.text.muted,
|
|
2308
|
+
fontVariant: ["tabular-nums"],
|
|
2309
|
+
paddingHorizontal: px(colors.spacing["2"]),
|
|
2310
|
+
// Sits on the same baseline as the 32px buttons.
|
|
2311
|
+
lineHeight: px(colors.spacing["8"])
|
|
2312
|
+
},
|
|
2313
|
+
children: message
|
|
2314
|
+
}
|
|
2315
|
+
);
|
|
2316
|
+
}, "PaginationRange");
|
|
2317
|
+
var PaginationPageSize = /* @__PURE__ */ __name(({ options, testID }) => {
|
|
2318
|
+
const ctx = usePaginationContext("Pagination.PageSize");
|
|
2319
|
+
const colors = useThemeColors();
|
|
2320
|
+
const value = ctx.pageSize !== void 0 ? String(ctx.pageSize) : "";
|
|
2321
|
+
const selectOptions = react.useMemo(
|
|
2322
|
+
() => options.map((n) => ({ value: String(n), label: String(n) })),
|
|
2323
|
+
[options]
|
|
2324
|
+
);
|
|
2325
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2326
|
+
reactNative.View,
|
|
2327
|
+
{
|
|
2328
|
+
style: {
|
|
2329
|
+
flexDirection: "row",
|
|
2330
|
+
alignItems: "center",
|
|
2331
|
+
gap: px(colors.spacing["2"])
|
|
2332
|
+
},
|
|
2333
|
+
children: [
|
|
2334
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2335
|
+
reactNative.Text,
|
|
2336
|
+
{
|
|
2337
|
+
style: {
|
|
2338
|
+
fontFamily: colors.fontFamily.body,
|
|
2339
|
+
fontSize: px(colors.fontSize.sm),
|
|
2340
|
+
color: colors.semantic.text.muted
|
|
2341
|
+
},
|
|
2342
|
+
children: ctx.labels.pageSize
|
|
2343
|
+
}
|
|
2344
|
+
),
|
|
2345
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2346
|
+
Select,
|
|
2347
|
+
{
|
|
2348
|
+
...testID !== void 0 ? { testID } : {},
|
|
2349
|
+
"aria-label": ctx.labels.pageSize,
|
|
2350
|
+
options: selectOptions,
|
|
2351
|
+
value,
|
|
2352
|
+
onChange: (v) => {
|
|
2353
|
+
const n = Number(v);
|
|
2354
|
+
if (Number.isFinite(n) && n > 0) {
|
|
2355
|
+
ctx.setPageSize(n);
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
)
|
|
2360
|
+
]
|
|
2361
|
+
}
|
|
2362
|
+
);
|
|
2363
|
+
}, "PaginationPageSize");
|
|
2364
|
+
var PaginationJumper = /* @__PURE__ */ __name(({
|
|
2365
|
+
showLabel = false,
|
|
2366
|
+
label,
|
|
2367
|
+
placeholder,
|
|
2368
|
+
inputWidth = 56,
|
|
2369
|
+
testID
|
|
2370
|
+
}) => {
|
|
2371
|
+
const ctx = usePaginationContext("Pagination.Jumper");
|
|
2372
|
+
const colors = useThemeColors();
|
|
2373
|
+
const [draft, setDraft] = react.useState("");
|
|
2374
|
+
const [focused, setFocused] = react.useState(false);
|
|
2375
|
+
const [hovered, setHovered] = react.useState(false);
|
|
2376
|
+
const visibleLabel = label ?? ctx.labels.jumperLabel;
|
|
2377
|
+
const placeholderText = placeholder ?? ctx.labels.jumperPlaceholder;
|
|
2378
|
+
const submit = /* @__PURE__ */ __name(() => {
|
|
2379
|
+
const trimmed = draft.trim();
|
|
2380
|
+
if (trimmed === "") {
|
|
2381
|
+
return;
|
|
2382
|
+
}
|
|
2383
|
+
const n = Number(trimmed);
|
|
2384
|
+
if (!Number.isFinite(n) || n < 1) {
|
|
2385
|
+
setDraft("");
|
|
2386
|
+
return;
|
|
2387
|
+
}
|
|
2388
|
+
const clamped = Math.min(Math.max(1, Math.floor(n)), ctx.pageCount);
|
|
2389
|
+
ctx.goToPage(clamped);
|
|
2390
|
+
setDraft("");
|
|
2391
|
+
}, "submit");
|
|
2392
|
+
const borderColor = focused ? colors.semantic.interactive.primary : hovered ? colors.semantic.border.strong : colors.semantic.border.default;
|
|
2393
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2394
|
+
reactNative.View,
|
|
2395
|
+
{
|
|
2396
|
+
style: {
|
|
2397
|
+
flexDirection: "row",
|
|
2398
|
+
alignItems: "center",
|
|
2399
|
+
gap: px(colors.spacing["2"])
|
|
2400
|
+
},
|
|
2401
|
+
children: [
|
|
2402
|
+
showLabel ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2403
|
+
reactNative.Text,
|
|
2404
|
+
{
|
|
2405
|
+
style: {
|
|
2406
|
+
fontFamily: colors.fontFamily.body,
|
|
2407
|
+
fontSize: px(colors.fontSize.sm),
|
|
2408
|
+
color: colors.semantic.text.muted
|
|
2409
|
+
},
|
|
2410
|
+
children: visibleLabel
|
|
2411
|
+
}
|
|
2412
|
+
) : null,
|
|
2413
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2414
|
+
reactNative.View,
|
|
2415
|
+
{
|
|
2416
|
+
onPointerEnter: reactNative.Platform.OS === "web" ? () => setHovered(true) : void 0,
|
|
2417
|
+
onPointerLeave: reactNative.Platform.OS === "web" ? () => setHovered(false) : void 0,
|
|
2418
|
+
style: {
|
|
2419
|
+
width: inputWidth,
|
|
2420
|
+
height: px(colors.spacing["8"]),
|
|
2421
|
+
borderWidth: 1,
|
|
2422
|
+
borderColor,
|
|
2423
|
+
borderRadius: px(colors.radius.md),
|
|
2424
|
+
backgroundColor: colors.semantic.background.elevated,
|
|
2425
|
+
paddingHorizontal: px(colors.spacing["2"]),
|
|
2426
|
+
justifyContent: "center",
|
|
2427
|
+
// Web-only properties (silently dropped on native).
|
|
2428
|
+
...focused ? {
|
|
2429
|
+
boxShadow: `0 0 0 3px ${withAlpha(colors.semantic.interactive.primary, 0.15)}`
|
|
2430
|
+
} : null,
|
|
2431
|
+
transitionProperty: "border-color, box-shadow",
|
|
2432
|
+
transitionDuration: "120ms",
|
|
2433
|
+
transitionTimingFunction: "cubic-bezier(0.2, 0, 0, 1)"
|
|
2434
|
+
},
|
|
2435
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2436
|
+
reactNative.TextInput,
|
|
2437
|
+
{
|
|
2438
|
+
...testID !== void 0 ? { testID } : {},
|
|
2439
|
+
value: draft,
|
|
2440
|
+
onChangeText: setDraft,
|
|
2441
|
+
onSubmitEditing: submit,
|
|
2442
|
+
onBlur: () => {
|
|
2443
|
+
setFocused(false);
|
|
2444
|
+
submit();
|
|
2445
|
+
},
|
|
2446
|
+
onFocus: () => setFocused(true),
|
|
2447
|
+
keyboardType: "number-pad",
|
|
2448
|
+
inputMode: "numeric",
|
|
2449
|
+
placeholder: placeholderText,
|
|
2450
|
+
placeholderTextColor: colors.semantic.text.muted,
|
|
2451
|
+
"aria-label": visibleLabel,
|
|
2452
|
+
accessibilityLabel: visibleLabel,
|
|
2453
|
+
returnKeyType: "go",
|
|
2454
|
+
selectTextOnFocus: true,
|
|
2455
|
+
style: {
|
|
2456
|
+
fontFamily: colors.fontFamily.body,
|
|
2457
|
+
fontSize: px(colors.fontSize.sm),
|
|
2458
|
+
color: colors.semantic.text.default,
|
|
2459
|
+
fontVariant: ["tabular-nums"],
|
|
2460
|
+
textAlign: "center",
|
|
2461
|
+
// Strip the browser's default outline — we draw our own
|
|
2462
|
+
// focus ring on the wrapper.
|
|
2463
|
+
...reactNative.Platform.OS === "web" ? { outline: "none" } : null
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
)
|
|
2467
|
+
}
|
|
2468
|
+
)
|
|
2469
|
+
]
|
|
2470
|
+
}
|
|
2471
|
+
);
|
|
2472
|
+
}, "PaginationJumper");
|
|
2473
|
+
function withAlpha(color, alpha) {
|
|
2474
|
+
if (color.startsWith("#") && (color.length === 7 || color.length === 4)) {
|
|
2475
|
+
const expanded = color.length === 4 ? `#${color[1]}${color[1]}${color[2]}${color[2]}${color[3]}${color[3]}` : color;
|
|
2476
|
+
const r = Number.parseInt(expanded.slice(1, 3), 16);
|
|
2477
|
+
const g = Number.parseInt(expanded.slice(3, 5), 16);
|
|
2478
|
+
const b = Number.parseInt(expanded.slice(5, 7), 16);
|
|
2479
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
2480
|
+
}
|
|
2481
|
+
return color;
|
|
2482
|
+
}
|
|
2483
|
+
__name(withAlpha, "withAlpha");
|
|
2484
|
+
var Pagination = Object.assign(PaginationRoot, {
|
|
2485
|
+
Items: PaginationItems,
|
|
2486
|
+
Item: PaginationItem,
|
|
2487
|
+
Prev: PaginationPrev,
|
|
2488
|
+
Next: PaginationNext,
|
|
2489
|
+
First: PaginationFirst,
|
|
2490
|
+
Last: PaginationLast,
|
|
2491
|
+
Ellipsis: PaginationEllipsis,
|
|
2492
|
+
Range: PaginationRange,
|
|
2493
|
+
PageSize: PaginationPageSize,
|
|
2494
|
+
Jumper: PaginationJumper
|
|
2495
|
+
});
|
|
2496
|
+
|
|
2497
|
+
exports.PAGINATION_COMPACT_BREAKPOINT = PAGINATION_COMPACT_BREAKPOINT;
|
|
2498
|
+
exports.Pagination = Pagination;
|
|
2499
|
+
exports.usePagination = usePagination;
|
|
2500
|
+
//# sourceMappingURL=index.cjs.map
|
|
2501
|
+
//# sourceMappingURL=index.cjs.map
|