@flipova/foundation 2.4.4 → 3.0.0-alpha.1
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/CHANGES.md +66 -0
- package/COMPONENTS.md +102 -0
- package/DOCS.md +261 -0
- package/LICENSE +1 -1
- package/README.md +169 -118
- package/components/contract/index.ts +3 -0
- package/components/contract/recipes/accordion.ts +42 -0
- package/components/contract/recipes/avatar.ts +41 -0
- package/components/contract/recipes/badge.ts +46 -0
- package/components/contract/recipes/button.ts +58 -0
- package/components/contract/recipes/calendar.ts +118 -0
- package/components/contract/recipes/card.ts +21 -0
- package/components/contract/recipes/checkbox.ts +33 -0
- package/components/contract/recipes/divider.ts +9 -0
- package/components/contract/recipes/fab.ts +31 -0
- package/components/contract/recipes/feedback.ts +66 -0
- package/components/contract/recipes/formcontrol.ts +16 -0
- package/components/contract/recipes/heading.ts +16 -0
- package/components/contract/recipes/icon.ts +40 -0
- package/components/contract/recipes/index.ts +30 -0
- package/components/contract/recipes/input.ts +39 -0
- package/components/contract/recipes/layout.ts +44 -0
- package/components/contract/recipes/link.ts +6 -0
- package/components/contract/recipes/modal.ts +40 -0
- package/components/contract/recipes/overlay.ts +250 -0
- package/components/contract/recipes/progress.ts +27 -0
- package/components/contract/recipes/radio.ts +39 -0
- package/components/contract/recipes/select.ts +63 -0
- package/components/contract/recipes/skeleton.ts +25 -0
- package/components/contract/recipes/slider.ts +50 -0
- package/components/contract/recipes/spinner.ts +12 -0
- package/components/contract/recipes/switch.ts +26 -0
- package/components/contract/recipes/table.ts +37 -0
- package/components/contract/recipes/tabs.ts +31 -0
- package/components/contract/recipes/text.ts +12 -0
- package/components/contract/recipes/textarea.ts +37 -0
- package/components/contract/recipes/util.ts +15 -0
- package/components/contract/theme.ts +116 -0
- package/components/contract/types.ts +598 -0
- package/components/providers/css-vars.ts +43 -0
- package/components/providers/flipova/components/Accordion.tsx +41 -0
- package/components/providers/flipova/components/ActionSheet.tsx +34 -0
- package/components/providers/flipova/components/Alert.tsx +15 -0
- package/components/providers/flipova/components/AlertDialog.tsx +31 -0
- package/components/providers/flipova/components/Avatar.tsx +30 -0
- package/components/providers/flipova/components/Badge.tsx +14 -0
- package/components/providers/flipova/components/BottomSheet.tsx +24 -0
- package/components/providers/flipova/components/Box.tsx +1 -0
- package/components/providers/flipova/components/Button.tsx +31 -0
- package/components/providers/flipova/components/Calendar.tsx +85 -0
- package/components/providers/flipova/components/Card.tsx +13 -0
- package/components/providers/flipova/components/Center.tsx +11 -0
- package/components/providers/flipova/components/Checkbox.tsx +24 -0
- package/components/providers/flipova/components/DateTimePicker.tsx +45 -0
- package/components/providers/flipova/components/Divider.tsx +9 -0
- package/components/providers/flipova/components/Drawer.tsx +18 -0
- package/components/providers/flipova/components/Fab.tsx +22 -0
- package/components/providers/flipova/components/FlatList.tsx +1 -0
- package/components/providers/flipova/components/FormControl.tsx +27 -0
- package/components/providers/flipova/components/Grid.tsx +18 -0
- package/components/providers/flipova/components/HStack.tsx +13 -0
- package/components/providers/flipova/components/Heading.tsx +19 -0
- package/components/providers/flipova/components/Icon.tsx +20 -0
- package/components/providers/flipova/components/Image.tsx +1 -0
- package/components/providers/flipova/components/ImageBackground.tsx +1 -0
- package/components/providers/flipova/components/ImageViewer.tsx +25 -0
- package/components/providers/flipova/components/Input.tsx +29 -0
- package/components/providers/flipova/components/InputAccessoryView.tsx +1 -0
- package/components/providers/flipova/components/KeyboardAvoidingView.tsx +1 -0
- package/components/providers/flipova/components/Link.tsx +21 -0
- package/components/providers/flipova/components/LiquidGlass.tsx +13 -0
- package/components/providers/flipova/components/Menu.tsx +43 -0
- package/components/providers/flipova/components/Modal.tsx +24 -0
- package/components/providers/flipova/components/Popover.tsx +23 -0
- package/components/providers/flipova/components/Portal.tsx +42 -0
- package/components/providers/flipova/components/Pressable.tsx +1 -0
- package/components/providers/flipova/components/Progress.tsx +22 -0
- package/components/providers/flipova/components/RadioGroup.tsx +36 -0
- package/components/providers/flipova/components/RefreshControl.tsx +1 -0
- package/components/providers/flipova/components/SafeAreaView.tsx +1 -0
- package/components/providers/flipova/components/ScrollView.tsx +1 -0
- package/components/providers/flipova/components/SectionList.tsx +1 -0
- package/components/providers/flipova/components/Select.tsx +61 -0
- package/components/providers/flipova/components/Skeleton.tsx +25 -0
- package/components/providers/flipova/components/Slider.tsx +52 -0
- package/components/providers/flipova/components/Spinner.tsx +19 -0
- package/components/providers/flipova/components/StatusBar.tsx +1 -0
- package/components/providers/flipova/components/Switch.tsx +21 -0
- package/components/providers/flipova/components/Table.tsx +33 -0
- package/components/providers/flipova/components/Tabs.tsx +39 -0
- package/components/providers/flipova/components/Text.tsx +13 -0
- package/components/providers/flipova/components/Textarea.tsx +28 -0
- package/components/providers/flipova/components/Toast.tsx +28 -0
- package/components/providers/flipova/components/Tooltip.tsx +34 -0
- package/components/providers/flipova/components/VStack.tsx +13 -0
- package/components/providers/flipova/components/View.tsx +1 -0
- package/components/providers/flipova/components/VirtualizedList.tsx +1 -0
- package/components/providers/flipova/index.tsx +189 -0
- package/components/providers/gluestack/index.tsx +226 -0
- package/components/providers/gluestack/more.tsx +151 -0
- package/components/{ui → providers/gluestack/ui}/accordion/index.tsx +2 -2
- package/components/{ui → providers/gluestack/ui}/actionsheet/index.tsx +15 -15
- package/components/{ui → providers/gluestack/ui}/alert/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/alert-dialog/index.tsx +3 -3
- package/components/{ui → providers/gluestack/ui}/badge/index.tsx +2 -2
- package/components/{ui → providers/gluestack/ui}/bottomsheet/index.tsx +11 -10
- package/components/{ui → providers/gluestack/ui}/box/index.tsx +4 -1
- package/components/{ui → providers/gluestack/ui}/button/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/calendar/index.tsx +4 -4
- package/components/{ui → providers/gluestack/ui}/card/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/center/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/checkbox/index.tsx +9 -8
- package/components/{ui → providers/gluestack/ui}/date-time-picker/index.tsx +4 -4
- package/components/providers/gluestack/ui/date-time-picker/index.web.tsx +197 -0
- package/components/{ui → providers/gluestack/ui}/divider/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/drawer/index.tsx +2 -2
- package/components/{ui → providers/gluestack/ui}/fab/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/form-control/index.tsx +3 -3
- package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/config.ts +1 -62
- package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/tokens.js +1 -1
- package/components/{ui → providers/gluestack/ui}/grid/index.tsx +3 -3
- package/components/{ui → providers/gluestack/ui}/heading/index.tsx +7 -7
- package/components/{ui → providers/gluestack/ui}/hstack/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/icon/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/image/index.tsx +0 -1
- package/components/{ui → providers/gluestack/ui}/image-viewer/index.tsx +96 -99
- package/components/providers/gluestack/ui/index.ts +58 -0
- package/components/{ui → providers/gluestack/ui}/input/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/link/index.tsx +2 -2
- package/components/{ui → providers/gluestack/ui}/liquid-glass/index.tsx +2 -2
- package/components/{ui → providers/gluestack/ui}/menu/index.tsx +5 -4
- package/components/{ui → providers/gluestack/ui}/modal/index.tsx +19 -17
- package/components/{ui → providers/gluestack/ui}/popover/index.tsx +4 -4
- package/components/{ui → providers/gluestack/ui}/portal/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/progress/index.tsx +2 -2
- package/components/{ui → providers/gluestack/ui}/radio/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/select/index.tsx +8 -12
- package/components/{ui → providers/gluestack/ui}/select/select-actionsheet.tsx +13 -13
- package/components/{ui → providers/gluestack/ui}/skeleton/index.tsx +2 -2
- package/components/{ui → providers/gluestack/ui}/slider/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/spinner/index.tsx +2 -2
- package/components/{ui → providers/gluestack/ui}/table/index.tsx +33 -33
- package/components/{ui → providers/gluestack/ui}/tabs/TabsAnimatedIndicator.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/tabs/index.tsx +2 -2
- package/components/{ui → providers/gluestack/ui}/text/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/toast/index.tsx +4 -4
- package/components/{ui → providers/gluestack/ui}/tooltip/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/vstack/index.tsx +1 -1
- package/components/providers/index.ts +2 -0
- package/components/providers/paper/index.tsx +449 -0
- package/components/providers/provider.tsx +80 -0
- package/components/providers/reusables/classes.ts +163 -0
- package/components/providers/reusables/index.tsx +289 -0
- package/components/providers/rn-base/Box.tsx +7 -0
- package/components/providers/rn-base/FlatList.tsx +16 -0
- package/components/providers/rn-base/Image.tsx +18 -0
- package/components/providers/rn-base/ImageBackground.tsx +11 -0
- package/components/providers/rn-base/InputAccessoryView.tsx +9 -0
- package/components/providers/rn-base/KeyboardAvoidingView.tsx +15 -0
- package/components/providers/rn-base/Pressable.tsx +19 -0
- package/components/providers/rn-base/RefreshControl.tsx +16 -0
- package/components/providers/rn-base/SafeAreaView.tsx +11 -0
- package/components/providers/rn-base/ScrollView.tsx +11 -0
- package/components/providers/rn-base/SectionList.tsx +22 -0
- package/components/providers/rn-base/StatusBar.tsx +17 -0
- package/components/providers/rn-base/View.tsx +7 -0
- package/components/providers/rn-base/VirtualizedList.tsx +18 -0
- package/components/providers/rn-base/index.tsx +64 -0
- package/components/providers/tamagui/index.tsx +375 -0
- package/components/providers/types.ts +17 -0
- package/components/theme/design-theme.ts +230 -0
- package/components/ui/create.tsx +14 -0
- package/components/ui/index.ts +68 -58
- package/components/ui/resolve.ts +40 -0
- package/design/canonical.index.txt +2 -16
- package/design/manifest.xml +4 -3
- package/design/schema.xsd +44 -434
- package/design/themes.xml +7 -177
- package/design/tools/{npm.js → cli.js} +173 -73
- package/design/tools/gui/index.html +998 -0
- package/design/tools/lib/check.js +533 -0
- package/design/tools/lib/contract.js +23 -0
- package/design/tools/lib/edit.js +166 -0
- package/design/tools/lib/generate.js +465 -0
- package/design/tools/lib/gui.js +614 -0
- package/design/tools/lib/lint.js +139 -0
- package/design/tools/lib/registry.js +135 -0
- package/design/tools/lib/util.js +53 -0
- package/design/tools/lib/xml.js +257 -0
- package/design/tools/lib/xsd.js +408 -0
- package/dist/chunk-2QM2ZUDS.mjs +1308 -0
- package/dist/chunk-2QM2ZUDS.mjs.map +1 -0
- package/dist/chunk-2T2TCUYF.js +1371 -0
- package/dist/chunk-2T2TCUYF.js.map +1 -0
- package/dist/chunk-6UKTC4KF.js +43 -0
- package/dist/chunk-6UKTC4KF.js.map +1 -0
- package/dist/chunk-6Z4WRTI4.mjs +37 -0
- package/dist/chunk-6Z4WRTI4.mjs.map +1 -0
- package/dist/chunk-G3K6J5KY.js +157 -0
- package/dist/chunk-G3K6J5KY.js.map +1 -0
- package/dist/chunk-GM45RCSI.mjs +96 -0
- package/dist/chunk-GM45RCSI.mjs.map +1 -0
- package/dist/chunk-GQJLHH2P.mjs +3 -0
- package/dist/chunk-GQJLHH2P.mjs.map +1 -0
- package/dist/chunk-ICNR56VP.js +1653 -0
- package/dist/chunk-ICNR56VP.js.map +1 -0
- package/dist/chunk-J5LGTIGS.mjs +9 -0
- package/dist/chunk-J5LGTIGS.mjs.map +1 -0
- package/dist/chunk-LRPZLF2K.mjs +30 -0
- package/dist/chunk-LRPZLF2K.mjs.map +1 -0
- package/dist/chunk-OC4MXNXU.js +32 -0
- package/dist/chunk-OC4MXNXU.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +11 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-RWVTZUEG.js +161 -0
- package/dist/chunk-RWVTZUEG.js.map +1 -0
- package/dist/chunk-V473I5XQ.js +4 -0
- package/dist/chunk-V473I5XQ.js.map +1 -0
- package/dist/chunk-V4ULAISZ.js +915 -0
- package/dist/chunk-V4ULAISZ.js.map +1 -0
- package/dist/chunk-WRJERTJS.mjs +145 -0
- package/dist/chunk-WRJERTJS.mjs.map +1 -0
- package/dist/chunk-YIBPE3KQ.mjs +864 -0
- package/dist/chunk-YIBPE3KQ.mjs.map +1 -0
- package/dist/chunk-YUAQIZPN.mjs +1556 -0
- package/dist/chunk-YUAQIZPN.mjs.map +1 -0
- package/dist/contract/index.d.mts +304 -0
- package/dist/contract/index.d.ts +304 -0
- package/dist/contract/index.js +256 -0
- package/dist/contract/index.js.map +1 -0
- package/dist/contract/index.mjs +3 -0
- package/dist/contract/index.mjs.map +1 -0
- package/dist/index.d.mts +4 -40
- package/dist/index.d.ts +4 -40
- package/dist/index.js +73 -992
- package/dist/index.mjs +2 -1
- package/dist/providers/flipova/index.d.mts +133 -0
- package/dist/providers/flipova/index.d.ts +133 -0
- package/dist/providers/flipova/index.js +249 -0
- package/dist/providers/flipova/index.js.map +1 -0
- package/dist/providers/flipova/index.mjs +4 -0
- package/dist/providers/flipova/index.mjs.map +1 -0
- package/dist/providers/gluestack/index.d.mts +7 -0
- package/dist/providers/gluestack/index.d.ts +7 -0
- package/dist/providers/gluestack/index.js +240 -0
- package/dist/providers/gluestack/index.js.map +1 -0
- package/dist/providers/gluestack/index.mjs +238 -0
- package/dist/providers/gluestack/index.mjs.map +1 -0
- package/dist/providers/gluestack/ui/index.d.mts +3472 -0
- package/dist/providers/gluestack/ui/index.d.ts +3472 -0
- package/dist/{chunk-LCTFQJZM.js → providers/gluestack/ui/index.js} +860 -2297
- package/dist/providers/gluestack/ui/index.js.map +1 -0
- package/dist/{chunk-2R66P5X5.mjs → providers/gluestack/ui/index.mjs} +468 -2062
- package/dist/providers/gluestack/ui/index.mjs.map +1 -0
- package/dist/providers/index.d.mts +37 -0
- package/dist/providers/index.d.ts +37 -0
- package/dist/providers/index.js +28 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/index.mjs +3 -0
- package/dist/providers/index.mjs.map +1 -0
- package/dist/providers/paper/index.d.mts +30 -0
- package/dist/providers/paper/index.d.ts +30 -0
- package/dist/providers/paper/index.js +362 -0
- package/dist/providers/paper/index.js.map +1 -0
- package/dist/providers/paper/index.mjs +353 -0
- package/dist/providers/paper/index.mjs.map +1 -0
- package/dist/providers/reusables/index.d.mts +60 -0
- package/dist/providers/reusables/index.d.ts +60 -0
- package/dist/providers/reusables/index.js +348 -0
- package/dist/providers/reusables/index.js.map +1 -0
- package/dist/providers/reusables/index.mjs +311 -0
- package/dist/providers/reusables/index.mjs.map +1 -0
- package/dist/providers/tamagui/index.d.mts +15 -0
- package/dist/providers/tamagui/index.d.ts +15 -0
- package/dist/providers/tamagui/index.js +275 -0
- package/dist/providers/tamagui/index.js.map +1 -0
- package/dist/providers/tamagui/index.mjs +270 -0
- package/dist/providers/tamagui/index.mjs.map +1 -0
- package/dist/theme-BznFrVT1.d.mts +566 -0
- package/dist/theme-BznFrVT1.d.ts +566 -0
- package/dist/types-C7P80VKR.d.ts +22 -0
- package/dist/types-Tspvmask.d.mts +22 -0
- package/dist/ui/index.d.mts +190 -7017
- package/dist/ui/index.d.ts +190 -7017
- package/dist/ui/index.js +73 -992
- package/dist/ui/index.mjs +2 -1
- package/package.json +136 -35
- package/components/ui/date-time-picker/index.web.tsx +0 -195
- package/design/documentation.xml +0 -607
- package/design/tools/design.js +0 -188
- package/design/tools/requirements.txt +0 -35
- package/design/tools/sources/.checker/__init__.py +0 -81
- package/design/tools/sources/.checker/checks.py +0 -198
- package/design/tools/sources/.checker/cli.py +0 -154
- package/design/tools/sources/.checker/io.py +0 -242
- package/design/tools/sources/.checker/model.py +0 -144
- package/design/tools/sources/.checker/registry.py +0 -115
- package/design/tools/sources/.checker/report.py +0 -21
- package/design/tools/sources/.docgen/__init__.py +0 -45
- package/design/tools/sources/.docgen/cli.py +0 -101
- package/design/tools/sources/.docgen/model.py +0 -147
- package/design/tools/sources/.docgen/reference.py +0 -97
- package/design/tools/sources/.docgen/site.py +0 -145
- package/design/tools/sources/.docgen/xsddoc.py +0 -329
- package/design/tools/sources/.generate/__init__.py +0 -35
- package/design/tools/sources/.generate/cli.py +0 -76
- package/design/tools/sources/.generate/common.py +0 -33
- package/design/tools/sources/.generate/config.py +0 -177
- package/design/tools/sources/.generate/model.py +0 -51
- package/design/tools/sources/.generate/tokens.py +0 -141
- package/design/tools/sources/.linter/__init__.py +0 -9
- package/design/tools/sources/.linter/cli.py +0 -44
- package/design/tools/sources/.linter/discovery.py +0 -30
- package/design/tools/sources/.linter/errors.py +0 -45
- package/design/tools/sources/.linter/linter.py +0 -68
- package/design/tools/sources/.xmleditor/__init__.py +0 -74
- package/design/tools/sources/.xmleditor/blocks.py +0 -185
- package/design/tools/sources/.xmleditor/cli.py +0 -141
- package/design/tools/sources/.xmleditor/editor.py +0 -906
- package/design/tools/sources/.xmleditor/model.py +0 -708
- package/design/tools/sources/.xmleditor/widgets.py +0 -1832
- package/design/tools/sources/.xmleditor/xsdmodel.py +0 -753
- package/design/tools/sources/checker.py +0 -55
- package/design/tools/sources/docgen.py +0 -66
- package/design/tools/sources/generate.py +0 -48
- package/design/tools/sources/linter.py +0 -54
- package/design/tools/sources/ruff.toml +0 -12
- package/design/tools/sources/xmleditor.py +0 -62
- package/design/tools/unix/_venv_python.sh +0 -16
- package/design/tools/unix/check.sh +0 -13
- package/design/tools/unix/doc.sh +0 -14
- package/design/tools/unix/gen.sh +0 -14
- package/design/tools/unix/lint.sh +0 -10
- package/design/tools/unix/run.sh +0 -20
- package/design/tools/unix/verify.sh +0 -12
- package/design/tools/unix/xmledit.sh +0 -12
- package/design/tools/windows/check.cmd +0 -12
- package/design/tools/windows/doc.cmd +0 -12
- package/design/tools/windows/gen.cmd +0 -11
- package/design/tools/windows/lint.cmd +0 -9
- package/design/tools/windows/run.cmd +0 -26
- package/design/tools/windows/verify.cmd +0 -10
- package/design/tools/windows/xmledit.cmd +0 -10
- package/dist/chunk-2R66P5X5.mjs.map +0 -1
- package/dist/chunk-LCTFQJZM.js.map +0 -1
- /package/components/{ui → providers/gluestack/ui}/accordion/ANIMATION_CUSTOMIZATION.md +0 -0
- /package/components/{ui → providers/gluestack/ui}/accordion/AccordionAnimatedHeight.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/accordion/AccordionAnimatedIcon.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/accordion/AnimatedHeight.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/accordion/AnimatedIcon.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/accordion/MIGRATION_SUMMARY.md +0 -0
- /package/components/{ui → providers/gluestack/ui}/accordion/USAGE_EXAMPLE.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/accordion/animation-config.ts +0 -0
- /package/components/{ui → providers/gluestack/ui}/avatar/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/box/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/box/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/calendar/creator.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/calendar/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/card/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/card/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/center/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/center/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/date-time-picker/creator.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/date-time-picker/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/flat-list/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/script.ts +0 -0
- /package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/theme-context.ts +0 -0
- /package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/tokens.d.ts +0 -0
- /package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/useGluestackColors.ts +0 -0
- /package/components/{ui → providers/gluestack/ui}/grid/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/grid/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/heading/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/heading/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/hstack/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/hstack/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/icon/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/image-background/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/image-viewer/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/input-accessory-view/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/keyboard-avoiding-view/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/pressable/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/refresh-control/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/safe-area-view/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/scroll-view/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/section-list/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/skeleton/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/skeleton/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/status-bar/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/switch/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/table/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/table/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/tabs/animation-config.ts +0 -0
- /package/components/{ui → providers/gluestack/ui}/tabs/creator.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/text/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/text/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/textarea/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/view/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/virtualized-list/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/vstack/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/vstack/styles.tsx +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ResolvedTheme } from '../theme';
|
|
2
|
+
import type { RadioGroupProps } from '../types';
|
|
3
|
+
import { px, type Style } from './util';
|
|
4
|
+
|
|
5
|
+
export interface RadioRecipe {
|
|
6
|
+
group: Style;
|
|
7
|
+
row: Style;
|
|
8
|
+
circle: (selected: boolean) => Style;
|
|
9
|
+
dot: Style;
|
|
10
|
+
label: Style;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function radioRecipe(
|
|
14
|
+
{ orientation = 'vertical', disabled = false }: RadioGroupProps,
|
|
15
|
+
t: ResolvedTheme,
|
|
16
|
+
): RadioRecipe {
|
|
17
|
+
const c = t.colors;
|
|
18
|
+
const size = px(t, 'spacing', '5');
|
|
19
|
+
const dot = px(t, 'spacing', '2.5');
|
|
20
|
+
return {
|
|
21
|
+
group: {
|
|
22
|
+
flexDirection: orientation === 'horizontal' ? 'row' : 'column',
|
|
23
|
+
gap: px(t, 'spacing', orientation === 'horizontal' ? '4' : '2'),
|
|
24
|
+
opacity: disabled ? 0.4 : 1,
|
|
25
|
+
},
|
|
26
|
+
row: { flexDirection: 'row', alignItems: 'center', gap: px(t, 'spacing', '2') },
|
|
27
|
+
circle: (selected) => ({
|
|
28
|
+
width: size,
|
|
29
|
+
height: size,
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
justifyContent: 'center',
|
|
32
|
+
borderRadius: px(t, 'radii', 'full'),
|
|
33
|
+
borderWidth: 1,
|
|
34
|
+
borderColor: selected ? c.primary : c.input,
|
|
35
|
+
}),
|
|
36
|
+
dot: { width: dot, height: dot, borderRadius: px(t, 'radii', 'full'), backgroundColor: c.primary },
|
|
37
|
+
label: { color: c.foreground, fontSize: px(t, 'fontSizes', 'sm') },
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { withAlpha, type ResolvedTheme } from '../theme';
|
|
2
|
+
import type { SelectProps } from '../types';
|
|
3
|
+
import { px, weight, type Style } from './util';
|
|
4
|
+
|
|
5
|
+
export interface SelectRecipe {
|
|
6
|
+
trigger: Style;
|
|
7
|
+
triggerLabel: Style;
|
|
8
|
+
placeholderColor: string;
|
|
9
|
+
menu: Style;
|
|
10
|
+
option: Style;
|
|
11
|
+
optionSelected: Style;
|
|
12
|
+
optionLabel: Style;
|
|
13
|
+
optionLabelSelected: Style;
|
|
14
|
+
disabledOptionOpacity: number;
|
|
15
|
+
focusBorderColor: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function selectRecipe({ disabled = false, invalid = false }: SelectProps, t: ResolvedTheme): SelectRecipe {
|
|
19
|
+
const c = t.colors;
|
|
20
|
+
const sh = t.scale.shadows.md;
|
|
21
|
+
return {
|
|
22
|
+
trigger: {
|
|
23
|
+
height: px(t, 'spacing', '9'),
|
|
24
|
+
width: '100%',
|
|
25
|
+
flexDirection: 'row',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
justifyContent: 'space-between',
|
|
28
|
+
gap: px(t, 'spacing', '2'),
|
|
29
|
+
paddingHorizontal: px(t, 'spacing', '3'),
|
|
30
|
+
borderRadius: px(t, 'radii', 'md'),
|
|
31
|
+
borderWidth: 1,
|
|
32
|
+
borderColor: invalid ? withAlpha(c.destructive, 0.4) : c.border,
|
|
33
|
+
backgroundColor: 'transparent',
|
|
34
|
+
opacity: disabled ? 0.5 : 1,
|
|
35
|
+
},
|
|
36
|
+
triggerLabel: { flex: 1, color: c.foreground, fontSize: px(t, 'fontSizes', 'sm') },
|
|
37
|
+
placeholderColor: c.mutedForeground,
|
|
38
|
+
menu: {
|
|
39
|
+
marginTop: px(t, 'spacing', '1'),
|
|
40
|
+
padding: px(t, 'spacing', '1'),
|
|
41
|
+
maxHeight: px(t, 'spacing', '48') + px(t, 'spacing', '12'),
|
|
42
|
+
backgroundColor: c.popover,
|
|
43
|
+
borderRadius: px(t, 'radii', 'md'),
|
|
44
|
+
borderWidth: 1,
|
|
45
|
+
borderColor: c.border,
|
|
46
|
+
shadowColor: sh.color,
|
|
47
|
+
shadowOffset: { width: sh.offsetX, height: sh.offsetY },
|
|
48
|
+
shadowOpacity: sh.opacity,
|
|
49
|
+
shadowRadius: sh.radius,
|
|
50
|
+
elevation: sh.elevation,
|
|
51
|
+
},
|
|
52
|
+
option: {
|
|
53
|
+
paddingHorizontal: px(t, 'spacing', '2'),
|
|
54
|
+
paddingVertical: px(t, 'spacing', '1.5'),
|
|
55
|
+
borderRadius: px(t, 'radii', 'sm'),
|
|
56
|
+
},
|
|
57
|
+
optionSelected: { backgroundColor: c.accent },
|
|
58
|
+
optionLabel: { color: c.popoverForeground, fontSize: px(t, 'fontSizes', 'sm') },
|
|
59
|
+
optionLabelSelected: { color: c.accentForeground, fontWeight: weight(t, 'medium') },
|
|
60
|
+
disabledOptionOpacity: 0.4,
|
|
61
|
+
focusBorderColor: c.ring,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ResolvedTheme } from '../theme';
|
|
2
|
+
import type { SkeletonProps } from '../types';
|
|
3
|
+
import { px, type Style } from './util';
|
|
4
|
+
|
|
5
|
+
export interface SkeletonRecipe {
|
|
6
|
+
block: Style;
|
|
7
|
+
/** the pulse: opacity goes from 1 to `minOpacity` and back, one way in `durationMs` */
|
|
8
|
+
pulse: { minOpacity: number; durationMs: number };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function skeletonRecipe(
|
|
12
|
+
{ width = '100%', height, circle = false }: SkeletonProps,
|
|
13
|
+
t: ResolvedTheme,
|
|
14
|
+
): SkeletonRecipe {
|
|
15
|
+
const h = height ?? px(t, 'spacing', '4');
|
|
16
|
+
return {
|
|
17
|
+
block: {
|
|
18
|
+
width: circle ? h : width,
|
|
19
|
+
height: h,
|
|
20
|
+
borderRadius: px(t, 'radii', circle ? 'full' : 'md'),
|
|
21
|
+
backgroundColor: t.colors.muted,
|
|
22
|
+
},
|
|
23
|
+
pulse: { minOpacity: px(t, 'opacity', 'dim'), durationMs: px(t, 'duration', 'slower') * 2 },
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ResolvedTheme } from '../theme';
|
|
2
|
+
import type { SliderProps } from '../types';
|
|
3
|
+
import { px, type Style } from './util';
|
|
4
|
+
|
|
5
|
+
export interface SliderRecipe {
|
|
6
|
+
root: Style;
|
|
7
|
+
track: Style;
|
|
8
|
+
filled: Style;
|
|
9
|
+
thumb: Style;
|
|
10
|
+
thumbSize: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function sliderRecipe({ disabled = false }: SliderProps, t: ResolvedTheme): SliderRecipe {
|
|
14
|
+
const c = t.colors;
|
|
15
|
+
const thumb = px(t, 'spacing', '5');
|
|
16
|
+
return {
|
|
17
|
+
thumbSize: thumb,
|
|
18
|
+
root: { width: '100%', height: thumb, justifyContent: 'center', opacity: disabled ? 0.4 : 1 },
|
|
19
|
+
track: {
|
|
20
|
+
height: px(t, 'spacing', '1.5'),
|
|
21
|
+
borderRadius: px(t, 'radii', 'full'),
|
|
22
|
+
backgroundColor: c.muted,
|
|
23
|
+
overflow: 'hidden',
|
|
24
|
+
},
|
|
25
|
+
filled: { height: '100%', backgroundColor: c.primary },
|
|
26
|
+
thumb: {
|
|
27
|
+
position: 'absolute',
|
|
28
|
+
width: thumb,
|
|
29
|
+
height: thumb,
|
|
30
|
+
borderRadius: px(t, 'radii', 'full'),
|
|
31
|
+
backgroundColor: c.background,
|
|
32
|
+
borderWidth: 2,
|
|
33
|
+
borderColor: c.primary,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** value -> 0..1 position, clamped */
|
|
39
|
+
export function sliderFraction(value: number, min: number, max: number): number {
|
|
40
|
+
if (!(max > min)) return 0;
|
|
41
|
+
return Math.min(1, Math.max(0, (value - min) / (max - min)));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** 0..1 position -> value, snapped to `step` and clamped to [min, max] */
|
|
45
|
+
export function sliderValue(fraction: number, min: number, max: number, step: number): number {
|
|
46
|
+
const raw = min + Math.min(1, Math.max(0, fraction)) * (max - min);
|
|
47
|
+
const snapped = step > 0 ? Math.round((raw - min) / step) * step + min : raw;
|
|
48
|
+
const decimals = (String(step).split('.')[1] ?? '').length;
|
|
49
|
+
return Math.min(max, Math.max(min, Number(snapped.toFixed(decimals))));
|
|
50
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ResolvedTheme } from '../theme';
|
|
2
|
+
import type { SpinnerProps } from '../types';
|
|
3
|
+
|
|
4
|
+
export interface SpinnerRecipe {
|
|
5
|
+
size: 'small' | 'large';
|
|
6
|
+
color: string;
|
|
7
|
+
scale: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function spinnerRecipe({ size = 'md' }: SpinnerProps, t: ResolvedTheme): SpinnerRecipe {
|
|
11
|
+
return { size: size === 'sm' ? 'small' : 'large', scale: { sm: 1, md: 1, lg: 1.5 }[size], color: t.colors.primary };
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ResolvedTheme } from '../theme';
|
|
2
|
+
import type { SwitchProps } from '../types';
|
|
3
|
+
import { px } from './util';
|
|
4
|
+
|
|
5
|
+
export interface SwitchRecipe {
|
|
6
|
+
trackOn: string;
|
|
7
|
+
trackOff: string;
|
|
8
|
+
thumb: string;
|
|
9
|
+
/** scale applied to the whole control (sm 0.75, md 1, lg 1.25) */
|
|
10
|
+
scale: number;
|
|
11
|
+
opacity: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function switchRecipe({ size = 'md', disabled = false }: SwitchProps, t: ResolvedTheme): SwitchRecipe {
|
|
17
|
+
return {
|
|
18
|
+
trackOn: t.colors.primary,
|
|
19
|
+
trackOff: t.colors.input,
|
|
20
|
+
thumb: t.colors.background,
|
|
21
|
+
scale: { sm: 0.75, md: 1, lg: 1.25 }[size],
|
|
22
|
+
opacity: disabled ? 0.4 : 1,
|
|
23
|
+
width: px(t, 'spacing', '11'),
|
|
24
|
+
height: px(t, 'spacing', '6'),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ResolvedTheme } from '../theme';
|
|
2
|
+
import type { TableColumn } from '../types';
|
|
3
|
+
import { px, weight, type Style } from './util';
|
|
4
|
+
|
|
5
|
+
export interface TableRecipe {
|
|
6
|
+
container: Style;
|
|
7
|
+
caption: Style;
|
|
8
|
+
headRow: Style;
|
|
9
|
+
row: (last: boolean) => Style;
|
|
10
|
+
head: (align: TableColumn['align']) => Style;
|
|
11
|
+
cell: (align: TableColumn['align']) => Style;
|
|
12
|
+
headLabel: Style;
|
|
13
|
+
cellLabel: Style;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function tableRecipe(t: ResolvedTheme): TableRecipe {
|
|
17
|
+
const c = t.colors;
|
|
18
|
+
const align = (a: TableColumn['align'] = 'left') => ({ left: 'flex-start', center: 'center', right: 'flex-end' })[a];
|
|
19
|
+
const pad = { paddingHorizontal: px(t, 'spacing', '3'), paddingVertical: px(t, 'spacing', '2') };
|
|
20
|
+
return {
|
|
21
|
+
container: {
|
|
22
|
+
width: '100%',
|
|
23
|
+
borderWidth: 1,
|
|
24
|
+
borderColor: c.border,
|
|
25
|
+
borderRadius: px(t, 'radii', 'lg'),
|
|
26
|
+
overflow: 'hidden',
|
|
27
|
+
backgroundColor: c.card,
|
|
28
|
+
},
|
|
29
|
+
caption: { color: c.mutedForeground, fontSize: px(t, 'fontSizes', 'xs'), padding: px(t, 'spacing', '2') },
|
|
30
|
+
headRow: { flexDirection: 'row', backgroundColor: c.muted, borderBottomWidth: 1, borderBottomColor: c.border },
|
|
31
|
+
row: (last) => ({ flexDirection: 'row', borderBottomWidth: last ? 0 : 1, borderBottomColor: c.border }),
|
|
32
|
+
head: (a) => ({ flex: 1, ...pad, alignItems: align(a) }),
|
|
33
|
+
cell: (a) => ({ flex: 1, ...pad, alignItems: align(a) }),
|
|
34
|
+
headLabel: { color: c.mutedForeground, fontSize: px(t, 'fontSizes', 'xs'), fontWeight: weight(t, 'semibold') },
|
|
35
|
+
cellLabel: { color: c.cardForeground, fontSize: px(t, 'fontSizes', 'sm') },
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ResolvedTheme } from '../theme';
|
|
2
|
+
import type { TabsProps } from '../types';
|
|
3
|
+
import { px, weight, type Style } from './util';
|
|
4
|
+
|
|
5
|
+
export interface TabsRecipe {
|
|
6
|
+
list: Style;
|
|
7
|
+
tab: (active: boolean, disabled: boolean) => Style;
|
|
8
|
+
label: (active: boolean) => Style;
|
|
9
|
+
panel: Style;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function tabsRecipe(_p: TabsProps, t: ResolvedTheme): TabsRecipe {
|
|
13
|
+
const c = t.colors;
|
|
14
|
+
return {
|
|
15
|
+
list: { flexDirection: 'row', borderBottomWidth: 1, borderBottomColor: c.border },
|
|
16
|
+
tab: (active, disabled) => ({
|
|
17
|
+
paddingHorizontal: px(t, 'spacing', '4'),
|
|
18
|
+
paddingVertical: px(t, 'spacing', '2'),
|
|
19
|
+
borderBottomWidth: 2,
|
|
20
|
+
marginBottom: -1,
|
|
21
|
+
borderBottomColor: active ? c.primary : 'transparent',
|
|
22
|
+
opacity: disabled ? 0.4 : 1,
|
|
23
|
+
}),
|
|
24
|
+
label: (active) => ({
|
|
25
|
+
color: active ? c.foreground : c.mutedForeground,
|
|
26
|
+
fontSize: px(t, 'fontSizes', 'sm'),
|
|
27
|
+
fontWeight: weight(t, 'medium'),
|
|
28
|
+
}),
|
|
29
|
+
panel: { paddingTop: px(t, 'spacing', '4') },
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ResolvedTheme } from '../theme';
|
|
2
|
+
import type { TextProps } from '../types';
|
|
3
|
+
import { px, weight, type Style } from './util';
|
|
4
|
+
|
|
5
|
+
export function textRecipe({ size = 'md', bold, underline, strikeThrough }: TextProps, t: ResolvedTheme): Style {
|
|
6
|
+
const style: Style = { color: t.colors.foreground, fontSize: px(t, 'fontSizes', size) };
|
|
7
|
+
if (bold) style.fontWeight = weight(t, 'bold');
|
|
8
|
+
if (underline || strikeThrough)
|
|
9
|
+
style.textDecorationLine =
|
|
10
|
+
underline && strikeThrough ? 'underline line-through' : underline ? 'underline' : 'line-through';
|
|
11
|
+
return style;
|
|
12
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { withAlpha, type ResolvedTheme } from '../theme';
|
|
2
|
+
import type { TextareaProps } from '../types';
|
|
3
|
+
import { px, type Style } from './util';
|
|
4
|
+
|
|
5
|
+
export interface TextareaRecipe {
|
|
6
|
+
field: Style;
|
|
7
|
+
placeholderTextColor: string;
|
|
8
|
+
focusBorderColor: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function textareaRecipe(
|
|
12
|
+
{ rows = 4, disabled = false, invalid = false }: TextareaProps,
|
|
13
|
+
t: ResolvedTheme,
|
|
14
|
+
): TextareaRecipe {
|
|
15
|
+
const c = t.colors;
|
|
16
|
+
const line = t.scale.lineHeights.sm;
|
|
17
|
+
const pad = px(t, 'spacing', '2');
|
|
18
|
+
return {
|
|
19
|
+
field: {
|
|
20
|
+
width: '100%',
|
|
21
|
+
minHeight: rows * line + 2 * pad + 2,
|
|
22
|
+
paddingHorizontal: px(t, 'spacing', '3'),
|
|
23
|
+
paddingVertical: pad,
|
|
24
|
+
borderRadius: px(t, 'radii', 'md'),
|
|
25
|
+
borderWidth: 1,
|
|
26
|
+
borderColor: invalid ? withAlpha(c.destructive, 0.4) : c.border,
|
|
27
|
+
backgroundColor: 'transparent',
|
|
28
|
+
color: c.foreground,
|
|
29
|
+
fontSize: px(t, 'fontSizes', 'sm'),
|
|
30
|
+
lineHeight: line,
|
|
31
|
+
textAlignVertical: 'top',
|
|
32
|
+
opacity: disabled ? 0.5 : 1,
|
|
33
|
+
},
|
|
34
|
+
placeholderTextColor: c.mutedForeground,
|
|
35
|
+
focusBorderColor: c.ring,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ResolvedTheme } from '../theme';
|
|
2
|
+
|
|
3
|
+
/** Plain numbers / '#rrggbb' / 'rgba()' strings, valid as React Native and web style props. */
|
|
4
|
+
export type Style = Record<string, string | number | { width: number; height: number }>;
|
|
5
|
+
|
|
6
|
+
type NumericScale = 'spacing' | 'radii' | 'fontSizes' | 'fontWeights' | 'opacity' | 'duration';
|
|
7
|
+
|
|
8
|
+
/** A value of a scale, or an error naming the token the registry lacks (never a silent `undefined` style). */
|
|
9
|
+
export const px = (theme: ResolvedTheme, scale: NumericScale, key: string): number => {
|
|
10
|
+
const v = theme.scale[scale][key];
|
|
11
|
+
if (v === undefined) throw new Error(`design token ${scale}.${key} is missing from the registry`);
|
|
12
|
+
return v;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const weight = (theme: ResolvedTheme, key: string): string => String(px(theme, 'fontWeights', key));
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { designTheme } from '../theme/design-theme';
|
|
2
|
+
|
|
3
|
+
export type Mode = 'light' | 'dark';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The colour roles the components read. A theme is free to define more (they are available as `colors.<role>`), but
|
|
7
|
+
* these must exist: `resolveTheme` refuses a theme that lacks one and names it, so a missing role is found at start-up,
|
|
8
|
+
* not as an undefined colour on screen. `flipova-design` and its GUI check the same list.
|
|
9
|
+
*/
|
|
10
|
+
export const REQUIRED_ROLES = [
|
|
11
|
+
'background',
|
|
12
|
+
'foreground',
|
|
13
|
+
'card',
|
|
14
|
+
'cardForeground',
|
|
15
|
+
'popover',
|
|
16
|
+
'popoverForeground',
|
|
17
|
+
'primary',
|
|
18
|
+
'primaryForeground',
|
|
19
|
+
'secondary',
|
|
20
|
+
'secondaryForeground',
|
|
21
|
+
'muted',
|
|
22
|
+
'mutedForeground',
|
|
23
|
+
'accent',
|
|
24
|
+
'accentForeground',
|
|
25
|
+
'destructive',
|
|
26
|
+
'destructiveForeground',
|
|
27
|
+
'border',
|
|
28
|
+
'input',
|
|
29
|
+
'ring',
|
|
30
|
+
'success',
|
|
31
|
+
'successForeground',
|
|
32
|
+
'warning',
|
|
33
|
+
'warningForeground',
|
|
34
|
+
'error',
|
|
35
|
+
'errorForeground',
|
|
36
|
+
'info',
|
|
37
|
+
'infoForeground',
|
|
38
|
+
] as const;
|
|
39
|
+
export type ColorRole = (typeof REQUIRED_ROLES)[number];
|
|
40
|
+
|
|
41
|
+
export interface ShadowToken {
|
|
42
|
+
color: string;
|
|
43
|
+
offsetX: number;
|
|
44
|
+
offsetY: number;
|
|
45
|
+
radius: number;
|
|
46
|
+
opacity: number;
|
|
47
|
+
elevation: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The numeric scales every theme registry provides (see design/tokens.xml). */
|
|
51
|
+
export interface Scale {
|
|
52
|
+
spacing: Record<string, number>;
|
|
53
|
+
radii: Record<string, number>;
|
|
54
|
+
fontSizes: Record<string, number>;
|
|
55
|
+
fontWeights: Record<string, number>;
|
|
56
|
+
lineHeights: Record<string, number>;
|
|
57
|
+
letterSpacings: Record<string, number>;
|
|
58
|
+
opacity: Record<string, number>;
|
|
59
|
+
duration: Record<string, number>;
|
|
60
|
+
zIndex: Record<string, number>;
|
|
61
|
+
breakpoints: Record<string, number>;
|
|
62
|
+
fontFamilies: Record<string, { native: string; web?: string }>;
|
|
63
|
+
shadows: Record<string, ShadowToken>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* What `flipova-design gen` writes (design-theme.ts) and what <FlipovaProvider theme={...}> takes. The shape is fixed;
|
|
68
|
+
* the contents (theme names, palettes, scales) are the app's: nothing in this package assumes a theme id.
|
|
69
|
+
*/
|
|
70
|
+
export interface ThemeRegistry {
|
|
71
|
+
themes: Record<string, { mode: string; variant: string; colors: Record<string, string> }>;
|
|
72
|
+
/** variant -> mode -> theme id */
|
|
73
|
+
variants: Record<string, Record<string, string>>;
|
|
74
|
+
scale: Scale;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The registry bundled with the package (a neutral light/dark starter), used when the app gives none. */
|
|
78
|
+
export const defaultRegistry: ThemeRegistry = designTheme as unknown as ThemeRegistry;
|
|
79
|
+
|
|
80
|
+
/** One theme of a registry, ready to read: colours as '#rrggbb', every scale as numbers. */
|
|
81
|
+
export interface ResolvedTheme {
|
|
82
|
+
id: string;
|
|
83
|
+
mode: string;
|
|
84
|
+
variant: string;
|
|
85
|
+
colors: Record<ColorRole, string> & Record<string, string>;
|
|
86
|
+
scale: Scale;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** variant + mode -> theme id, the way the registry declares its light/dark pairs (`default`, then any pair, when unknown). */
|
|
90
|
+
export function themeIdFor(variant: string | undefined, mode: Mode, theme: ThemeRegistry = defaultRegistry): string {
|
|
91
|
+
const variants = theme.variants;
|
|
92
|
+
const pair = (variant && variants[variant]) || variants.default || Object.values(variants)[0];
|
|
93
|
+
const byMode = pair?.[mode];
|
|
94
|
+
if (byMode && theme.themes[byMode]) return byMode;
|
|
95
|
+
const any = Object.entries(theme.themes).find(([, t]) => t.mode === mode) ?? Object.entries(theme.themes)[0];
|
|
96
|
+
if (!any) throw new Error('the theme registry declares no theme');
|
|
97
|
+
return any[0];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function resolveTheme(id: string, theme: ThemeRegistry = defaultRegistry): ResolvedTheme {
|
|
101
|
+
const t = theme.themes[id];
|
|
102
|
+
if (!t) throw new Error(`unknown theme "${id}" (known: ${Object.keys(theme.themes).join(', ')})`);
|
|
103
|
+
const missing = REQUIRED_ROLES.filter((r) => !(r in t.colors));
|
|
104
|
+
if (missing.length)
|
|
105
|
+
throw new Error(`theme "${id}" lacks the colour role(s) the components read: ${missing.join(', ')}`);
|
|
106
|
+
return { id, mode: t.mode, variant: t.variant, colors: t.colors as ResolvedTheme['colors'], scale: theme.scale };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** '#rrggbb' + opacity -> 'rgba(r, g, b, a)' (what Tailwind's `/40` means, spelled for style objects). */
|
|
110
|
+
export function withAlpha(hex: string, alpha: number): string {
|
|
111
|
+
let d = hex.replace('#', '');
|
|
112
|
+
if (d.length === 3) d = [...d].map((c) => c + c).join('');
|
|
113
|
+
const n = parseInt(d.slice(0, 6), 16);
|
|
114
|
+
const a = Math.round(alpha * 1000) / 1000;
|
|
115
|
+
return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${a})`;
|
|
116
|
+
}
|