@app-studio/components 0.12.0 → 0.12.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/README.md +1 -1
- package/dist/alert.cjs.js +1 -1
- package/dist/alert.esm.mjs +1 -1
- package/dist/avatar.cjs.js +1 -1
- package/dist/avatar.esm.mjs +1 -1
- package/dist/button.cjs.js +1 -1
- package/dist/button.esm.mjs +1 -1
- package/dist/card.cjs.js +1 -1
- package/dist/card.esm.mjs +1 -1
- package/dist/checkbox.cjs.js +1 -1
- package/dist/checkbox.esm.mjs +1 -1
- package/dist/chunks/{Alert-Q1HlVX8f.mjs → Alert-B5vkpWXy.mjs} +55 -42
- package/dist/chunks/Alert-B5vkpWXy.mjs.map +1 -0
- package/dist/chunks/Alert-BHlgJZAo.cjs +2 -0
- package/dist/chunks/Alert-BHlgJZAo.cjs.map +1 -0
- package/dist/chunks/{AttachmentPreview-8d8gZ5kk.mjs → AttachmentPreview-B2-kP0Bn.mjs} +1745 -2997
- package/dist/chunks/AttachmentPreview-B2-kP0Bn.mjs.map +1 -0
- package/dist/chunks/AttachmentPreview-BZV6xSa4.cjs +2 -0
- package/dist/chunks/AttachmentPreview-BZV6xSa4.cjs.map +1 -0
- package/dist/chunks/{Avatar-D-GkyL2c.mjs → Avatar-CC1SDq6h.mjs} +34 -32
- package/dist/chunks/Avatar-CC1SDq6h.mjs.map +1 -0
- package/dist/chunks/Avatar-DtfD7QQ6.cjs +2 -0
- package/dist/chunks/Avatar-DtfD7QQ6.cjs.map +1 -0
- package/dist/chunks/Button.core-BB25t8wB.cjs +7 -0
- package/dist/chunks/Button.core-BB25t8wB.cjs.map +1 -0
- package/dist/chunks/{Button.core-Bc5cSn_z.mjs → Button.core-oxCH_VTn.mjs} +236 -222
- package/dist/chunks/Button.core-oxCH_VTn.mjs.map +1 -0
- package/dist/chunks/Button.pilot-BJK10U1-.mjs +6 -0
- package/dist/chunks/{Button.pilot-C4BIb08S.mjs.map → Button.pilot-BJK10U1-.mjs.map} +1 -1
- package/dist/chunks/Button.pilot-eWGY9Jm5.cjs +2 -0
- package/dist/chunks/{Button.pilot-JmR2DCSE.cjs.map → Button.pilot-eWGY9Jm5.cjs.map} +1 -1
- package/dist/chunks/Card-CK_D7gzP.cjs +2 -0
- package/dist/chunks/Card-CK_D7gzP.cjs.map +1 -0
- package/dist/chunks/Card-ymI5Thma.mjs +208 -0
- package/dist/chunks/Card-ymI5Thma.mjs.map +1 -0
- package/dist/chunks/Checkbox-BXbEChdd.cjs +2 -0
- package/dist/chunks/Checkbox-BXbEChdd.cjs.map +1 -0
- package/dist/chunks/Checkbox-DnwrApdj.mjs +21 -0
- package/dist/chunks/Checkbox-DnwrApdj.mjs.map +1 -0
- package/dist/chunks/Checkbox.view-B7K8ycvs.cjs +2 -0
- package/dist/chunks/Checkbox.view-B7K8ycvs.cjs.map +1 -0
- package/dist/chunks/{Checkbox.view-dhc-rfEX.mjs → Checkbox.view-CCGfVtqr.mjs} +140 -119
- package/dist/chunks/Checkbox.view-CCGfVtqr.mjs.map +1 -0
- package/dist/chunks/{Formik.Uploader-DRIyxMI0.mjs → Formik.Uploader-CIYySBWB.mjs} +18 -18
- package/dist/chunks/{Formik.Uploader-DRIyxMI0.mjs.map → Formik.Uploader-CIYySBWB.mjs.map} +1 -1
- package/dist/chunks/{Formik.Uploader-D0nzjyau.cjs → Formik.Uploader-DePTdd7A.cjs} +4 -4
- package/dist/chunks/{Formik.Uploader-D0nzjyau.cjs.map → Formik.Uploader-DePTdd7A.cjs.map} +1 -1
- package/dist/chunks/{Icon-DrAZswNH.mjs → Icon-Cy5kEVYz.mjs} +60 -60
- package/dist/chunks/{Icon-DrAZswNH.mjs.map → Icon-Cy5kEVYz.mjs.map} +1 -1
- package/dist/chunks/Modal-BzlrQQu5.cjs +2 -0
- package/dist/chunks/Modal-BzlrQQu5.cjs.map +1 -0
- package/dist/chunks/{Modal-DkckCT8-.mjs → Modal-CqbUQXoc.mjs} +92 -75
- package/dist/chunks/Modal-CqbUQXoc.mjs.map +1 -0
- package/dist/chunks/Select-CrOxhfvQ.mjs +28 -0
- package/dist/chunks/Select-CrOxhfvQ.mjs.map +1 -0
- package/dist/chunks/Select-DRMUC3NX.cjs +2 -0
- package/dist/chunks/Select-DRMUC3NX.cjs.map +1 -0
- package/dist/chunks/{Select.view-CPMqT8pn.mjs → Select.view-BHMiRNIc.mjs} +126 -124
- package/dist/chunks/Select.view-BHMiRNIc.mjs.map +1 -0
- package/dist/chunks/Select.view-BV01zWHM.cjs +2 -0
- package/dist/chunks/Select.view-BV01zWHM.cjs.map +1 -0
- package/dist/chunks/{Switch-DWx1g3jT.mjs → Switch-04GGHGrV.mjs} +2 -2
- package/dist/chunks/{Switch-DWx1g3jT.mjs.map → Switch-04GGHGrV.mjs.map} +1 -1
- package/dist/chunks/{Switch-D80yPNFV.cjs → Switch-DqgmPp8M.cjs} +2 -2
- package/dist/chunks/{Switch-D80yPNFV.cjs.map → Switch-DqgmPp8M.cjs.map} +1 -1
- package/dist/chunks/Switch.view-6ncV6Ifz.cjs +2 -0
- package/dist/chunks/Switch.view-6ncV6Ifz.cjs.map +1 -0
- package/dist/chunks/{Switch.view-QLZ7O5Z7.mjs → Switch.view-DUvFLhyy.mjs} +34 -39
- package/dist/chunks/Switch.view-DUvFLhyy.mjs.map +1 -0
- package/dist/chunks/Tabs-BdoE88Ee.mjs +567 -0
- package/dist/chunks/Tabs-BdoE88Ee.mjs.map +1 -0
- package/dist/chunks/Tabs-DneEt-le.cjs +2 -0
- package/dist/chunks/Tabs-DneEt-le.cjs.map +1 -0
- package/dist/chunks/{TextField-DOU2CL5J.mjs → TextField-Bwc_F2Rq.mjs} +97 -86
- package/dist/chunks/TextField-Bwc_F2Rq.mjs.map +1 -0
- package/dist/chunks/TextField-CwaxvcqN.cjs +2 -0
- package/dist/chunks/TextField-CwaxvcqN.cjs.map +1 -0
- package/dist/chunks/{default-nRKhMTzF.mjs → default-1F10zins.mjs} +2 -2
- package/dist/chunks/{default-nRKhMTzF.mjs.map → default-1F10zins.mjs.map} +1 -1
- package/dist/chunks/default-W-NMTEJ3.cjs +2 -0
- package/dist/chunks/default-W-NMTEJ3.cjs.map +1 -0
- package/dist/chunks/designSystem.page-BgmjSYsz.cjs +11 -0
- package/dist/chunks/designSystem.page-BgmjSYsz.cjs.map +1 -0
- package/dist/chunks/{designSystem.page-K0ajTvy7.mjs → designSystem.page-CM_h09Ui.mjs} +18 -16
- package/dist/chunks/designSystem.page-CM_h09Ui.mjs.map +1 -0
- package/dist/chunks/{FieldWrapper-Bb0j8Iog.mjs → useFieldDesignSystemProps-BZj7d9gK.mjs} +118 -87
- package/dist/chunks/useFieldDesignSystemProps-BZj7d9gK.mjs.map +1 -0
- package/dist/chunks/useFieldDesignSystemProps-CgVU3R10.cjs +2 -0
- package/dist/chunks/useFieldDesignSystemProps-CgVU3R10.cjs.map +1 -0
- package/dist/design-system-preview.cjs.js +1 -1
- package/dist/design-system-preview.esm.mjs +14 -14
- package/dist/formik.cjs.js +1 -1
- package/dist/formik.esm.mjs +2 -2
- package/dist/link.esm.mjs +1 -1
- package/dist/modal.cjs.js +1 -1
- package/dist/modal.esm.mjs +1 -1
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.view.native.js +13 -5
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.view.native.js.map +1 -1
- package/dist/native/components/Alert/Alert/Alert.view.d.ts +3 -1
- package/dist/native/components/Alert/Alert/Alert.view.js +16 -6
- package/dist/native/components/Alert/Alert/Alert.view.js.map +1 -1
- package/dist/native/components/Alert/Alert/Alert.view.native.d.ts +3 -1
- package/dist/native/components/Alert/Alert/Alert.view.native.js +15 -4
- package/dist/native/components/Alert/Alert/Alert.view.native.js.map +1 -1
- package/dist/native/components/Alert/Alert.js +3 -3
- package/dist/native/components/Alert/Alert.js.map +1 -1
- package/dist/native/components/Avatar/Avatar/Avatar.props.d.ts +1 -1
- package/dist/native/components/Avatar/Avatar/Avatar.state.d.ts +2 -2
- package/dist/native/components/Avatar/Avatar/Avatar.state.js +6 -5
- package/dist/native/components/Avatar/Avatar/Avatar.state.js.map +1 -1
- package/dist/native/components/Avatar/Avatar/Avatar.view.d.ts +1 -1
- package/dist/native/components/Avatar/Avatar/Avatar.view.js +2 -2
- package/dist/native/components/Avatar/Avatar/Avatar.view.js.map +1 -1
- package/dist/native/components/Avatar/Avatar.js +2 -2
- package/dist/native/components/Avatar/Avatar.js.map +1 -1
- package/dist/native/components/Button/Button/Button.style.js +11 -6
- package/dist/native/components/Button/Button/Button.style.js.map +1 -1
- package/dist/native/components/Button/Button/Button.view.d.ts +2 -0
- package/dist/native/components/Button/Button/Button.view.js +9 -3
- package/dist/native/components/Button/Button/Button.view.js.map +1 -1
- package/dist/native/components/Button/Button/Button.view.native.d.ts +1 -0
- package/dist/native/components/Button/Button/Button.view.native.js +19 -4
- package/dist/native/components/Button/Button/Button.view.native.js.map +1 -1
- package/dist/native/components/Button/Button.core.js +3 -3
- package/dist/native/components/Button/Button.core.js.map +1 -1
- package/dist/native/components/Card/Card/Card.view.d.ts +3 -1
- package/dist/native/components/Card/Card/Card.view.js +32 -24
- package/dist/native/components/Card/Card/Card.view.js.map +1 -1
- package/dist/native/components/Card/Card.js +3 -3
- package/dist/native/components/Card/Card.js.map +1 -1
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.props.d.ts +1 -0
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.state.d.ts +5 -1
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.state.js +13 -0
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.state.js.map +1 -1
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.style.d.ts +3 -12
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.style.js +3 -12
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.style.js.map +1 -1
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.view.js +19 -16
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.view.js.map +1 -1
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.view.native.js +36 -30
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.view.native.js.map +1 -1
- package/dist/native/components/Form/Checkbox/Checkbox.js +3 -3
- package/dist/native/components/Form/Checkbox/Checkbox.js.map +1 -1
- package/dist/native/components/Form/DatePicker/DatePicker/DatePicker.state.js +8 -2
- package/dist/native/components/Form/DatePicker/DatePicker/DatePicker.state.js.map +1 -1
- package/dist/native/components/Form/Select/Select/Select.props.d.ts +1 -0
- package/dist/native/components/Form/Select/Select/Select.view.js +2 -2
- package/dist/native/components/Form/Select/Select/Select.view.js.map +1 -1
- package/dist/native/components/Form/Select/Select/Select.view.native.js +17 -4
- package/dist/native/components/Form/Select/Select/Select.view.native.js.map +1 -1
- package/dist/native/components/Form/Select/Select.js +3 -3
- package/dist/native/components/Form/Select/Select.js.map +1 -1
- package/dist/native/components/Form/Switch/Switch/Switch.style.d.ts +3 -8
- package/dist/native/components/Form/Switch/Switch/Switch.style.js +3 -8
- package/dist/native/components/Form/Switch/Switch/Switch.style.js.map +1 -1
- package/dist/native/components/Form/Switch/Switch/Switch.view.js +1 -5
- package/dist/native/components/Form/Switch/Switch/Switch.view.js.map +1 -1
- package/dist/native/components/Form/Switch/Switch/Switch.view.native.js +7 -4
- package/dist/native/components/Form/Switch/Switch/Switch.view.native.js.map +1 -1
- package/dist/native/components/Form/TextField/TextField/TextField.props.d.ts +1 -0
- package/dist/native/components/Form/TextField/TextField/TextField.view.js +2 -2
- package/dist/native/components/Form/TextField/TextField/TextField.view.js.map +1 -1
- package/dist/native/components/Form/TextField/TextField/TextField.view.native.js +9 -4
- package/dist/native/components/Form/TextField/TextField/TextField.view.native.js.map +1 -1
- package/dist/native/components/Form/TextField/TextField.js +3 -3
- package/dist/native/components/Form/TextField/TextField.js.map +1 -1
- package/dist/native/components/Input/FieldContent/FieldContent/FieldContent.props.d.ts +1 -0
- package/dist/native/components/Input/FieldContent/FieldContent.js +16 -3
- package/dist/native/components/Input/FieldContent/FieldContent.js.map +1 -1
- package/dist/native/components/Input/useFieldDesignSystemProps.d.ts +9 -0
- package/dist/native/components/Input/useFieldDesignSystemProps.js +15 -0
- package/dist/native/components/Input/useFieldDesignSystemProps.js.map +1 -0
- package/dist/native/components/Modal/Modal/Modal.props.d.ts +2 -0
- package/dist/native/components/Modal/Modal/Modal.view.js +6 -4
- package/dist/native/components/Modal/Modal/Modal.view.js.map +1 -1
- package/dist/native/components/Modal/Modal/Modal.view.native.js +5 -4
- package/dist/native/components/Modal/Modal/Modal.view.native.js.map +1 -1
- package/dist/native/components/Tabs/Tabs/TabHeader.d.ts +2 -0
- package/dist/native/components/Tabs/Tabs/TabHeader.js +7 -6
- package/dist/native/components/Tabs/Tabs/TabHeader.js.map +1 -1
- package/dist/native/components/Tabs/Tabs/Tabs.props.d.ts +10 -0
- package/dist/native/components/Tabs/Tabs/Tabs.state.d.ts +1 -0
- package/dist/native/components/Tabs/Tabs/Tabs.state.js +20 -43
- package/dist/native/components/Tabs/Tabs/Tabs.state.js.map +1 -1
- package/dist/native/components/Tabs/Tabs/Tabs.styles.d.ts +11 -0
- package/dist/native/components/Tabs/Tabs/Tabs.styles.js +7 -0
- package/dist/native/components/Tabs/Tabs/Tabs.styles.js.map +1 -0
- package/dist/native/components/Tabs/Tabs/Tabs.type.d.ts +4 -0
- package/dist/native/components/Tabs/Tabs/Tabs.view.js +146 -58
- package/dist/native/components/Tabs/Tabs/Tabs.view.js.map +1 -1
- package/dist/native/components/Tabs/Tabs/Tabs.view.native.js +83 -19
- package/dist/native/components/Tabs/Tabs/Tabs.view.native.js.map +1 -1
- package/dist/native/components/Tabs/Tabs.js +8 -8
- package/dist/native/components/Tabs/Tabs.js.map +1 -1
- package/dist/native/components/index.js +1 -1
- package/dist/native/components/index.js.map +1 -1
- package/dist/native/components/pilot/blocks/SettingsPanel.js +3 -1
- package/dist/native/components/pilot/blocks/SettingsPanel.js.map +1 -1
- package/dist/native/components/pilot/blocks/SignIn.js +3 -1
- package/dist/native/components/pilot/blocks/SignIn.js.map +1 -1
- package/dist/native/design-system/DesignSystemProvider.d.ts +1 -1
- package/dist/native/design-system/DesignSystemProvider.js +2 -2
- package/dist/native/design-system/DesignSystemProvider.js.map +1 -1
- package/dist/native/design-system/configs/default.json +1 -1
- package/dist/native/design-system/theme.d.ts +10 -1
- package/dist/native/design-system/theme.js +41 -12
- package/dist/native/design-system/theme.js.map +1 -1
- package/dist/native/design-system/types.d.ts +3 -9
- package/dist/native/design-system/utils.d.ts +5 -2
- package/dist/native/design-system/utils.js +42 -10
- package/dist/native/design-system/utils.js.map +1 -1
- package/dist/presets.cjs.js +1 -1
- package/dist/presets.esm.mjs +1 -1
- package/dist/registry/alert.json +13 -12
- package/dist/registry/avatar.json +15 -15
- package/dist/registry/button.json +14 -12
- package/dist/registry/card.json +13 -13
- package/dist/registry/checkbox.json +14 -11
- package/dist/registry/modal.json +8 -4
- package/dist/registry/registry.json +178 -78
- package/dist/registry/select.json +20 -12
- package/dist/registry/settings-panel.json +6 -2
- package/dist/registry/sign-in.json +6 -2
- package/dist/registry/switch.json +15 -15
- package/dist/registry/tabs.json +23 -18
- package/dist/registry/text-field.json +19 -11
- package/dist/registry/theme.json +71 -0
- package/dist/select.cjs.js +1 -1
- package/dist/select.esm.mjs +1 -1
- package/dist/settings-panel.cjs.js +1 -1
- package/dist/settings-panel.cjs.js.map +1 -1
- package/dist/settings-panel.esm.mjs +9 -9
- package/dist/settings-panel.esm.mjs.map +1 -1
- package/dist/sign-in.cjs.js +1 -1
- package/dist/sign-in.cjs.js.map +1 -1
- package/dist/sign-in.esm.mjs +15 -15
- package/dist/sign-in.esm.mjs.map +1 -1
- package/dist/switch.cjs.js +1 -1
- package/dist/switch.esm.mjs +1 -1
- package/dist/tabs.cjs.js +1 -1
- package/dist/tabs.esm.mjs +1 -1
- package/dist/text-field.cjs.js +1 -1
- package/dist/text-field.esm.mjs +1 -1
- package/dist/theme.cjs.js +1 -1
- package/dist/theme.cjs.js.map +1 -1
- package/dist/theme.esm.mjs +125 -72
- package/dist/theme.esm.mjs.map +1 -1
- package/dist/types/components/Alert/Alert/Alert.view.d.ts +3 -1
- package/dist/types/components/Avatar/Avatar/Avatar.props.d.ts +1 -1
- package/dist/types/components/Avatar/Avatar/Avatar.state.d.ts +2 -2
- package/dist/types/components/Avatar/Avatar/Avatar.view.d.ts +1 -1
- package/dist/types/components/Button/Button/Button.view.d.ts +2 -0
- package/dist/types/components/Card/Card/Card.view.d.ts +3 -1
- package/dist/types/components/Form/Checkbox/Checkbox/Checkbox.props.d.ts +1 -0
- package/dist/types/components/Form/Checkbox/Checkbox/Checkbox.state.d.ts +5 -1
- package/dist/types/components/Form/Checkbox/Checkbox/Checkbox.style.d.ts +3 -12
- package/dist/types/components/Form/Select/Select/Select.props.d.ts +1 -0
- package/dist/types/components/Form/Switch/Switch/Switch.style.d.ts +3 -8
- package/dist/types/components/Form/TextField/TextField/TextField.props.d.ts +1 -0
- package/dist/types/components/IconPicker/IconPicker/IconPicker.state.d.ts +2 -2
- package/dist/types/components/Input/FieldContent/FieldContent/FieldContent.props.d.ts +1 -0
- package/dist/types/components/Input/useFieldDesignSystemProps.d.ts +9 -0
- package/dist/types/components/Modal/Modal/Modal.props.d.ts +2 -0
- package/dist/types/components/Tabs/Tabs/TabHeader.d.ts +2 -0
- package/dist/types/components/Tabs/Tabs/Tabs.props.d.ts +10 -0
- package/dist/types/components/Tabs/Tabs/Tabs.state.d.ts +1 -0
- package/dist/types/components/Tabs/Tabs/Tabs.styles.d.ts +11 -0
- package/dist/types/components/Tabs/Tabs/Tabs.type.d.ts +4 -0
- package/dist/types/design-system/DesignSystemProvider.d.ts +1 -1
- package/dist/types/design-system/configs/default.json.d.ts +1 -1
- package/dist/types/design-system/theme.d.ts +10 -1
- package/dist/types/design-system/types.d.ts +3 -9
- package/dist/types/design-system/utils.d.ts +5 -2
- package/dist/web.cjs.js +16 -16
- package/dist/web.esm.mjs +44 -41
- package/dist/web.umd.js +38 -38
- package/dist/web.umd.js.map +1 -1
- package/docs/getting-started/react-native.md +17 -3
- package/docs/guides/performance.mdx +5 -0
- package/docs/guides/react-native.mdx +10 -0
- package/docs/guides/registry-guide.mdx +72 -8
- package/package.json +6 -4
- package/dist/chunks/Alert-Bjl40k3x.cjs +0 -2
- package/dist/chunks/Alert-Bjl40k3x.cjs.map +0 -1
- package/dist/chunks/Alert-Q1HlVX8f.mjs.map +0 -1
- package/dist/chunks/AttachmentPreview-8d8gZ5kk.mjs.map +0 -1
- package/dist/chunks/AttachmentPreview-Bwrz5TJh.cjs +0 -2
- package/dist/chunks/AttachmentPreview-Bwrz5TJh.cjs.map +0 -1
- package/dist/chunks/Avatar-BB0DeN9j.cjs +0 -2
- package/dist/chunks/Avatar-BB0DeN9j.cjs.map +0 -1
- package/dist/chunks/Avatar-D-GkyL2c.mjs.map +0 -1
- package/dist/chunks/Button.core-Bc5cSn_z.mjs.map +0 -1
- package/dist/chunks/Button.core-BhtOm8ak.cjs +0 -7
- package/dist/chunks/Button.core-BhtOm8ak.cjs.map +0 -1
- package/dist/chunks/Button.pilot-C4BIb08S.mjs +0 -6
- package/dist/chunks/Button.pilot-JmR2DCSE.cjs +0 -2
- package/dist/chunks/Card-CNSl9fD5.cjs +0 -2
- package/dist/chunks/Card-CNSl9fD5.cjs.map +0 -1
- package/dist/chunks/Card-DMhV_NTt.mjs +0 -200
- package/dist/chunks/Card-DMhV_NTt.mjs.map +0 -1
- package/dist/chunks/Checkbox-Bo7IRVRE.mjs +0 -11
- package/dist/chunks/Checkbox-Bo7IRVRE.mjs.map +0 -1
- package/dist/chunks/Checkbox-CAI6RtuO.cjs +0 -2
- package/dist/chunks/Checkbox-CAI6RtuO.cjs.map +0 -1
- package/dist/chunks/Checkbox.view-DGdNPlF9.cjs +0 -2
- package/dist/chunks/Checkbox.view-DGdNPlF9.cjs.map +0 -1
- package/dist/chunks/Checkbox.view-dhc-rfEX.mjs.map +0 -1
- package/dist/chunks/FieldWrapper-Bb0j8Iog.mjs.map +0 -1
- package/dist/chunks/FieldWrapper-DRCn7BLi.cjs +0 -2
- package/dist/chunks/FieldWrapper-DRCn7BLi.cjs.map +0 -1
- package/dist/chunks/Modal-DkckCT8-.mjs.map +0 -1
- package/dist/chunks/Modal-zok954As.cjs +0 -2
- package/dist/chunks/Modal-zok954As.cjs.map +0 -1
- package/dist/chunks/Select-C6R0Tei-.cjs +0 -2
- package/dist/chunks/Select-C6R0Tei-.cjs.map +0 -1
- package/dist/chunks/Select-C7IBNyjR.mjs +0 -24
- package/dist/chunks/Select-C7IBNyjR.mjs.map +0 -1
- package/dist/chunks/Select.view-CPMqT8pn.mjs.map +0 -1
- package/dist/chunks/Select.view-Pq1yAcMm.cjs +0 -2
- package/dist/chunks/Select.view-Pq1yAcMm.cjs.map +0 -1
- package/dist/chunks/Switch.view-CQZO_Js7.cjs +0 -2
- package/dist/chunks/Switch.view-CQZO_Js7.cjs.map +0 -1
- package/dist/chunks/Switch.view-QLZ7O5Z7.mjs.map +0 -1
- package/dist/chunks/Tabs-D5chMrkE.mjs +0 -403
- package/dist/chunks/Tabs-D5chMrkE.mjs.map +0 -1
- package/dist/chunks/Tabs-DQeBJwkz.cjs +0 -2
- package/dist/chunks/Tabs-DQeBJwkz.cjs.map +0 -1
- package/dist/chunks/TextField-DOU2CL5J.mjs.map +0 -1
- package/dist/chunks/TextField-Da4JCcAU.cjs +0 -2
- package/dist/chunks/TextField-Da4JCcAU.cjs.map +0 -1
- package/dist/chunks/default-D7ePSMKP.cjs +0 -2
- package/dist/chunks/default-D7ePSMKP.cjs.map +0 -1
- package/dist/chunks/designSystem.page-B74Vm2Dt.cjs +0 -11
- package/dist/chunks/designSystem.page-B74Vm2Dt.cjs.map +0 -1
- package/dist/chunks/designSystem.page-K0ajTvy7.mjs.map +0 -1
|
@@ -7,12 +7,18 @@
|
|
|
7
7
|
"categories": [
|
|
8
8
|
"Forms"
|
|
9
9
|
],
|
|
10
|
-
"registryDependencies": [
|
|
10
|
+
"registryDependencies": [
|
|
11
|
+
"theme"
|
|
12
|
+
],
|
|
11
13
|
"meta": {
|
|
12
14
|
"appStudio": {
|
|
13
15
|
"entry": "src/components/pilot/switch.ts",
|
|
14
16
|
"engine": ">=0.9.5",
|
|
15
|
-
"
|
|
17
|
+
"engineByPlatform": {
|
|
18
|
+
"ios": ">=0.10.0",
|
|
19
|
+
"android": ">=0.10.0"
|
|
20
|
+
},
|
|
21
|
+
"version": "0.12.1",
|
|
16
22
|
"license": "MIT",
|
|
17
23
|
"platforms": [
|
|
18
24
|
"web",
|
|
@@ -20,15 +26,9 @@
|
|
|
20
26
|
"android"
|
|
21
27
|
],
|
|
22
28
|
"dependencies": {
|
|
23
|
-
"web": [
|
|
24
|
-
|
|
25
|
-
]
|
|
26
|
-
"ios": [
|
|
27
|
-
"@app-studio/components@0.11.13"
|
|
28
|
-
],
|
|
29
|
-
"android": [
|
|
30
|
-
"@app-studio/components@0.11.13"
|
|
31
|
-
]
|
|
29
|
+
"web": [],
|
|
30
|
+
"ios": [],
|
|
31
|
+
"android": []
|
|
32
32
|
},
|
|
33
33
|
"npmImport": "@app-studio/components/switch"
|
|
34
34
|
}
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
68
|
"path": "src/components/Form/Switch/Switch.tsx",
|
|
69
|
-
"content": "import React from 'react';\nimport { SwitchProps } from './Switch/Switch.props';\nimport { useSwitchState } from './Switch/Switch.state';\nimport SwitchView from './Switch/Switch.view';\nimport { useMergedDesignSystemComponentProps } from '
|
|
69
|
+
"content": "import React from 'react';\nimport { SwitchProps } from './Switch/Switch.props';\nimport { useSwitchState } from './Switch/Switch.state';\nimport SwitchView from './Switch/Switch.view';\nimport { useMergedDesignSystemComponentProps } from '../../../design-system/theme';\n// Defines the SwitchComponent as a functional component that takes SwitchProps as props.\nconst SwitchComponent: React.FC<SwitchProps> = (props) => {\n const mergedProps = useMergedDesignSystemComponentProps('switch', props);\n // Invokes useSwitchState hook to obtain state for this component, passing props to it.\n const switchStates = useSwitchState(mergedProps);\n // Renders the SwitchView component, spreading the switchStates and props to pass all necessary data.\n return <SwitchView {...switchStates} {...mergedProps} />;\n};\n// Exports the SwitchComponent as 'Switch' for use in other parts of the application.\nexport const Switch = SwitchComponent;\n",
|
|
70
70
|
"type": "registry:ui"
|
|
71
71
|
},
|
|
72
72
|
{
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
83
|
"path": "src/components/Form/Switch/Switch/Switch.style.ts",
|
|
84
|
-
"content": "/**\n * Switch Styles\n *\n * Defines the styles for the Switch component following the design guidelines:\n * - Typography: Inter/Geist font, specific sizes/weights\n * - Spacing: 4px grid system\n * - Colors: Neutral palette with semantic colors\n * - Rounded corners: Consistent border radius\n * - Transitions: Subtle animations\n */\n\nimport { ViewProps } from 'app-studio';\nimport { Size } from './Switch.type';\n/**\n * Knob (circle) sizes for the Switch component\n * Following the 4px grid system - dimensions réduites\n */\nexport const KnobSizes: Record<Size, ViewProps> = {\n xs: { height: '10px', width: '10px' },\n sm: { height: '14px', width: '14px' },\n md: { height: '18px', width: '18px' },\n lg: { height: '22px', width: '22px' },\n xl: { height: '26px', width: '26px' },\n};\n\n/**\n * Slider (track) sizes for the Switch component\n * Following the 4px grid system - dimensions réduites\n */\nexport const SliderSizes: Record<Size, ViewProps> = {\n xs: {\n height: '20px',\n width: '40px',\n },\n sm: {\n height: '24px',\n width: '48px',\n },\n md: {\n height: '28px',\n width: '56px',\n },\n lg: {\n height: '32px',\n width: '64px',\n },\n xl: {\n height: '36px',\n width: '72px',\n },\n};\n\n/**\n * Slider (track) sizes when the Switch has activeChild/inActiveChild content.\n * Wider tracks ensure the text rendered alongside the knob is readable.\n */\nexport const ContentSliderSizes: Record<Size, ViewProps> = {\n xs: {\n height: '22px',\n width: '52px',\n },\n sm: {\n height: '26px',\n width: '62px',\n },\n md: {\n height: '30px',\n width: '72px',\n },\n lg: {\n height: '34px',\n width: '84px',\n },\n xl: {\n height: '38px',\n width: '96px',\n },\n};\n\n/**\n * Default font sizes for activeChild/inActiveChild text — matched to the\n * Switch size so the embedded label remains legible.\n */\nexport const ContentFontSizes: Record<Size, string> = {\n xs: '9px',\n sm: '10px',\n md: '11px',\n lg: '12px',\n xl: '13px',\n};\n\n/**\n * Padding for the Switch slider - ajusté pour les nouvelles dimensions\n * Following the 4px grid system\n */\nexport const SliderPadding: Record<Size, Record<string, number>> = {\n xs: { paddingVertical: 5, paddingHorizontal: 3 },\n sm: { paddingVertical: 5, paddingHorizontal: 3 },\n md: { paddingVertical: 5, paddingHorizontal: 5 },\n lg: { paddingVertical: 5, paddingHorizontal: 5 },\n xl: { paddingVertical: 5, paddingHorizontal: 5 },\n};\n\n/**\n * Color schemes for the Switch component\n */\nexport const ColorSchemes = {\n // Default colors\n default: {\n active: 'theme-primary',\n inactive: 'color-gray-300',\n knob: 'color-white',\n disabled: 'color-gray-200',\n },\n // State-specific colors\n states: {\n hover: {\n active: 'theme-primary',\n inactive: 'color-gray-400',\n activeOpacity: 0.9,\n },\n focus: {\n
|
|
84
|
+
"content": "/**\n * Switch Styles\n *\n * Defines the styles for the Switch component following the design guidelines:\n * - Typography: Inter/Geist font, specific sizes/weights\n * - Spacing: 4px grid system\n * - Colors: Neutral palette with semantic colors\n * - Rounded corners: Consistent border radius\n * - Transitions: Subtle animations\n */\n\nimport { ViewProps } from 'app-studio';\nimport { Size } from './Switch.type';\n/**\n * Knob (circle) sizes for the Switch component\n * Following the 4px grid system - dimensions réduites\n */\nexport const KnobSizes: Record<Size, ViewProps> = {\n xs: { height: '10px', width: '10px' },\n sm: { height: '14px', width: '14px' },\n md: { height: '18px', width: '18px' },\n lg: { height: '22px', width: '22px' },\n xl: { height: '26px', width: '26px' },\n};\n\n/**\n * Slider (track) sizes for the Switch component\n * Following the 4px grid system - dimensions réduites\n */\nexport const SliderSizes: Record<Size, ViewProps> = {\n xs: {\n height: '20px',\n width: '40px',\n },\n sm: {\n height: '24px',\n width: '48px',\n },\n md: {\n height: '28px',\n width: '56px',\n },\n lg: {\n height: '32px',\n width: '64px',\n },\n xl: {\n height: '36px',\n width: '72px',\n },\n};\n\n/**\n * Slider (track) sizes when the Switch has activeChild/inActiveChild content.\n * Wider tracks ensure the text rendered alongside the knob is readable.\n */\nexport const ContentSliderSizes: Record<Size, ViewProps> = {\n xs: {\n height: '22px',\n width: '52px',\n },\n sm: {\n height: '26px',\n width: '62px',\n },\n md: {\n height: '30px',\n width: '72px',\n },\n lg: {\n height: '34px',\n width: '84px',\n },\n xl: {\n height: '38px',\n width: '96px',\n },\n};\n\n/**\n * Default font sizes for activeChild/inActiveChild text — matched to the\n * Switch size so the embedded label remains legible.\n */\nexport const ContentFontSizes: Record<Size, string> = {\n xs: '9px',\n sm: '10px',\n md: '11px',\n lg: '12px',\n xl: '13px',\n};\n\n/**\n * Padding for the Switch slider - ajusté pour les nouvelles dimensions\n * Following the 4px grid system\n */\nexport const SliderPadding: Record<Size, Record<string, number>> = {\n xs: { paddingVertical: 5, paddingHorizontal: 3 },\n sm: { paddingVertical: 5, paddingHorizontal: 3 },\n md: { paddingVertical: 5, paddingHorizontal: 5 },\n lg: { paddingVertical: 5, paddingHorizontal: 5 },\n xl: { paddingVertical: 5, paddingHorizontal: 5 },\n};\n\n/**\n * Color schemes for the Switch component\n */\nexport const ColorSchemes = {\n // Default colors\n default: {\n active: 'theme-primary',\n inactive: 'color-gray-300',\n knob: 'color-white',\n disabled: 'color-gray-200',\n },\n // State-specific colors\n states: {\n hover: {\n active: 'theme-primary',\n inactive: 'color-gray-400',\n activeOpacity: 0.9,\n },\n focus: {\n outline: '2px solid theme-primary',\n outlineOffset: 2,\n boxShadow: '0 0 0 2px color-white',\n },\n },\n};\n\n/**\n * Transition styles for the Switch component\n */\nexport const TransitionStyles = {\n slider: {\n transition: 'all 0.2s ease-in-out',\n },\n knob: {\n transition: 'all 0.2s ease-in-out',\n },\n};\n",
|
|
85
85
|
"type": "registry:ui"
|
|
86
86
|
},
|
|
87
87
|
{
|
|
@@ -91,12 +91,12 @@
|
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
93
|
"path": "src/components/Form/Switch/Switch/Switch.view.native.tsx",
|
|
94
|
-
"content": "/**\n * Switch View Component (React Native)\n *\n * RN counterpart of Switch.view.tsx. Uses React Native's built-in <Switch/>\n * for the native toggle UX (drops the custom slider/knob/active-child concept,\n * which is a notable simplification — activeChild/inActiveChild are not\n * rendered because RN's Switch has no slot for in-track content).\n *\n * Drops web-only concepts: cursor, transitions, _hover, boxShadow ring, the\n * hidden checkbox input, the custom-painted slider/knob.\n */\n\nimport React from 'react';\nimport { Switch as RNSwitch } from 'react-native';\nimport { Horizontal, Text, useTheme, View } from 'app-studio';\nimport { SwitchViewProps } from './Switch.props';\nimport { ColorSchemes } from './Switch.style';\n\nconst SwitchView: React.FC<SwitchViewProps> = ({\n id,\n name,\n label,\n isChecked,\n labelPosition = 'right',\n size = 'sm',\n value = false,\n isHovered = false,\n isDisabled = false,\n isReadOnly = false,\n on,\n setOn = () => {},\n onChange,\n setValue = () => {},\n setIsHovered = () => {},\n helperText,\n inActiveChild: _inActiveChild,\n activeChild: _activeChild,\n shadow: _shadow,\n views = { slider: {}, circle: {}, label: {} },\n ...props\n}) => {\n const checked = typeof isChecked === 'boolean' ? isChecked : Boolean(value);\n const { getColor } = useTheme();\n\n const handleToggle = (newValue: boolean) => {\n if (!isReadOnly && !isDisabled) {\n setValue(newValue);\n setOn(newValue);\n if (onChange) onChange(newValue);\n }\n };\n\n const containerStyle = {\n gap: 12,\n opacity: isDisabled ? 0.6 : 1,\n ...views.label,\n };\n\n return (\n <View {...containerStyle} {...props}>\n <Horizontal gap={12} alignItems=\"center\">\n {labelPosition === 'left' && label && (\n <Text
|
|
94
|
+
"content": "/**\n * Switch View Component (React Native)\n *\n * RN counterpart of Switch.view.tsx. Uses React Native's built-in <Switch/>\n * for the native toggle UX (drops the custom slider/knob/active-child concept,\n * which is a notable simplification — activeChild/inActiveChild are not\n * rendered because RN's Switch has no slot for in-track content).\n *\n * Drops web-only concepts: cursor, transitions, _hover, boxShadow ring, the\n * hidden checkbox input, the custom-painted slider/knob.\n */\n\nimport React from 'react';\nimport { Switch as RNSwitch } from 'react-native';\nimport { Horizontal, Text, useTheme, View } from 'app-studio';\nimport { SwitchViewProps } from './Switch.props';\nimport { ColorSchemes } from './Switch.style';\n\nconst SwitchView: React.FC<SwitchViewProps> = ({\n id,\n name,\n label,\n accessibilityLabel,\n 'aria-label': ariaLabel,\n isChecked,\n labelPosition = 'right',\n size = 'sm',\n value = false,\n isHovered = false,\n isDisabled = false,\n isReadOnly = false,\n on,\n setOn = () => {},\n onChange,\n setValue = () => {},\n setIsHovered = () => {},\n helperText,\n inActiveChild: _inActiveChild,\n activeChild: _activeChild,\n shadow: _shadow,\n views = { slider: {}, circle: {}, label: {} },\n ...props\n}) => {\n const checked = typeof isChecked === 'boolean' ? isChecked : Boolean(value);\n const { getColor } = useTheme();\n\n const handleToggle = (newValue: boolean) => {\n if (!isReadOnly && !isDisabled) {\n setValue(newValue);\n setOn(newValue);\n if (onChange) onChange(newValue);\n }\n };\n\n const containerStyle = {\n gap: 12,\n opacity: isDisabled ? 0.6 : 1,\n ...views.label,\n };\n const labelColor =\n views.label?.color ?? (isDisabled ? 'color-gray-400' : 'theme-text');\n\n return (\n <View {...containerStyle} {...props}>\n <Horizontal gap={12} alignItems=\"center\">\n {labelPosition === 'left' && label && (\n <Text fontWeight=\"500\" color={labelColor}>\n {label}\n </Text>\n )}\n <RNSwitch\n accessibilityLabel={\n accessibilityLabel ??\n ariaLabel ??\n (typeof label === 'string' ? label : undefined)\n }\n value={checked}\n disabled={isDisabled || isReadOnly}\n onValueChange={handleToggle}\n trackColor={{\n false: getColor(ColorSchemes.default.inactive),\n true: getColor(ColorSchemes.default.active),\n }}\n thumbColor={getColor(ColorSchemes.default.knob)}\n ios_backgroundColor={getColor(ColorSchemes.default.inactive)}\n />\n {labelPosition === 'right' && label && (\n <Text fontWeight=\"500\" color={labelColor}>\n {label}\n </Text>\n )}\n </Horizontal>\n </View>\n );\n};\n\nexport default SwitchView;\n",
|
|
95
95
|
"type": "registry:ui"
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
98
|
"path": "src/components/Form/Switch/Switch/Switch.view.tsx",
|
|
99
|
-
"content": "/**\n * Switch View Component\n *\n * Renders a switch toggle with various styles and states\n * according to the design guidelines.\n */\n\nimport React from 'react';\nimport { Input } from 'app-studio';\nimport { Label } from '../../../Form/Label/Label';\nimport { View } from 'app-studio';\nimport { Text } from 'app-studio';\nimport { Vertical } from 'app-studio';\nimport { SwitchViewProps } from './Switch.props';\nimport {\n KnobSizes,\n SliderPadding,\n SliderSizes,\n ContentSliderSizes,\n ContentFontSizes,\n ColorSchemes,\n TransitionStyles,\n} from './Switch.style';\nconst SwitchContent = (props: any) => <Input type=\"checkbox\" {...props} />;\nconst SwitchView: React.FC<SwitchViewProps> = ({\n id,\n name,\n label,\n inActiveChild,\n isChecked,\n activeChild,\n labelPosition = 'right',\n shadow = {},\n size = 'sm',\n value = false,\n isHovered = false,\n isDisabled = false,\n isReadOnly = false,\n on,\n setOn = () => {},\n onChange,\n setValue = () => {},\n setIsHovered = () => {},\n helperText,\n description,\n views = { slider: {}, circle: {}, label: {} },\n ...props\n}) => {\n const generatedId = React.useId();\n const switchId = id ?? generatedId;\n const [isFocused, setIsFocused] = React.useState(false);\n const checked = typeof isChecked === 'boolean' ? isChecked : value;\n const hasContent = Boolean(activeChild || inActiveChild);\n const sliderDimensions = hasContent\n ? ContentSliderSizes[size]\n : SliderSizes[size];\n const knobOffset = `${SliderPadding[size].paddingHorizontal}px`;\n const contentSpace = `${SliderPadding[size].paddingHorizontal + 2}px`;\n const contentInset = `calc(${KnobSizes[size].width} + ${SliderPadding[size].paddingHorizontal}px + 4px)`;\n const contentFontSize = ContentFontSizes[size];\n\n const handleToggle = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (!isReadOnly && !isDisabled) {\n const newValue = event.target.checked;\n setValue(newValue);\n setOn(newValue);\n if (onChange) onChange(newValue);\n }\n };\n const handleMouseEnter = () => setIsHovered(true);\n const handleMouseLeave = () => setIsHovered(false);\n const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n let visible = true;\n try {\n visible = event.target.matches(':focus-visible');\n } catch {\n // engines without :focus-visible support: always show the ring\n }\n setIsFocused(visible);\n };\n const handleBlur = () => setIsFocused(false);\n const descriptionId = `${switchId}-description`;\n /**\n * Styles for the switch component\n */\n const switchStyle = {\n container: {\n // Layout properties\n gap: 12, // 3 × 4px grid\n display: 'flex',\n height: 'fit-content',\n width: 'fit-content',\n alignItems: 'center',\n\n // Typography properties\n\n // State properties\n cursor: isDisabled ? 'not-allowed' : isReadOnly ? 'default' : 'pointer',\n opacity: isDisabled ? 0.6 : 1,\n\n // Animation\n transition: 'all 0.2s ease-in-out',\n\n // Apply custom styles\n ...views.label,\n },\n };\n // Rest props are routed to the input only: spreading them here as well\n // landed consumer `aria-*`/`id` attributes on two elements at once.\n const control = (\n <Label\n htmlFor={switchId}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n {...switchStyle.container}\n >\n {/* Label on the left side */}\n {labelPosition === 'left' && label && (\n <Text\n fontWeight=\"500\" // Medium weight for better readability\n color={isDisabled ? 'color-gray-400' : 'inherit'}\n transition=\"color 0.2s ease, opacity 0.2s ease\"\n >\n {label}\n </Text>\n )}\n\n {/* Switch slider */}\n <View\n // Layout properties\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n position=\"relative\"\n marginBottom={4} // 1 × 4px grid\n // Visual properties\n borderRadius=\"9999px\" // Full rounded for pill shape\n backgroundColor={\n isDisabled\n ? ColorSchemes.default.disabled\n : checked\n ? isHovered\n ? ColorSchemes.states.hover.active\n : ColorSchemes.default.active\n : isHovered\n ? ColorSchemes.states.hover.inactive\n : ColorSchemes.default.inactive\n }\n opacity={\n !isDisabled && checked && isHovered\n ? ColorSchemes.states.hover.activeOpacity\n : 1\n }\n // State properties\n cursor=\"pointer\"\n // Animation\n {...TransitionStyles.slider}\n // Apply styles\n {...shadow}\n {...SliderPadding[size]}\n {...sliderDimensions}\n {...views['slider']}\n {...(isFocused
|
|
99
|
+
"content": "/**\n * Switch View Component\n *\n * Renders a switch toggle with various styles and states\n * according to the design guidelines.\n */\n\nimport React from 'react';\nimport { Input } from 'app-studio';\nimport { Label } from '../../../Form/Label/Label';\nimport { View } from 'app-studio';\nimport { Text } from 'app-studio';\nimport { Vertical } from 'app-studio';\nimport { SwitchViewProps } from './Switch.props';\nimport {\n KnobSizes,\n SliderPadding,\n SliderSizes,\n ContentSliderSizes,\n ContentFontSizes,\n ColorSchemes,\n TransitionStyles,\n} from './Switch.style';\nconst SwitchContent = (props: any) => <Input type=\"checkbox\" {...props} />;\nconst SwitchView: React.FC<SwitchViewProps> = ({\n id,\n name,\n label,\n inActiveChild,\n isChecked,\n activeChild,\n labelPosition = 'right',\n shadow = {},\n size = 'sm',\n value = false,\n isHovered = false,\n isDisabled = false,\n isReadOnly = false,\n on,\n setOn = () => {},\n onChange,\n setValue = () => {},\n setIsHovered = () => {},\n helperText,\n description,\n views = { slider: {}, circle: {}, label: {} },\n ...props\n}) => {\n const generatedId = React.useId();\n const switchId = id ?? generatedId;\n const [isFocused, setIsFocused] = React.useState(false);\n const checked = typeof isChecked === 'boolean' ? isChecked : value;\n const hasContent = Boolean(activeChild || inActiveChild);\n const sliderDimensions = hasContent\n ? ContentSliderSizes[size]\n : SliderSizes[size];\n const knobOffset = `${SliderPadding[size].paddingHorizontal}px`;\n const contentSpace = `${SliderPadding[size].paddingHorizontal + 2}px`;\n const contentInset = `calc(${KnobSizes[size].width} + ${SliderPadding[size].paddingHorizontal}px + 4px)`;\n const contentFontSize = ContentFontSizes[size];\n\n const handleToggle = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (!isReadOnly && !isDisabled) {\n const newValue = event.target.checked;\n setValue(newValue);\n setOn(newValue);\n if (onChange) onChange(newValue);\n }\n };\n const handleMouseEnter = () => setIsHovered(true);\n const handleMouseLeave = () => setIsHovered(false);\n const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n let visible = true;\n try {\n visible = event.target.matches(':focus-visible');\n } catch {\n // engines without :focus-visible support: always show the ring\n }\n setIsFocused(visible);\n };\n const handleBlur = () => setIsFocused(false);\n const descriptionId = `${switchId}-description`;\n /**\n * Styles for the switch component\n */\n const switchStyle = {\n container: {\n // Layout properties\n gap: 12, // 3 × 4px grid\n display: 'flex',\n height: 'fit-content',\n width: 'fit-content',\n alignItems: 'center',\n\n // Typography properties\n\n // State properties\n cursor: isDisabled ? 'not-allowed' : isReadOnly ? 'default' : 'pointer',\n opacity: isDisabled ? 0.6 : 1,\n\n // Animation\n transition: 'all 0.2s ease-in-out',\n\n // Apply custom styles\n ...views.label,\n },\n };\n // Rest props are routed to the input only: spreading them here as well\n // landed consumer `aria-*`/`id` attributes on two elements at once.\n const control = (\n <Label\n htmlFor={switchId}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n {...switchStyle.container}\n >\n {/* Label on the left side */}\n {labelPosition === 'left' && label && (\n <Text\n fontWeight=\"500\" // Medium weight for better readability\n color={isDisabled ? 'color-gray-400' : 'inherit'}\n transition=\"color 0.2s ease, opacity 0.2s ease\"\n >\n {label}\n </Text>\n )}\n\n {/* Switch slider */}\n <View\n // Layout properties\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n position=\"relative\"\n marginBottom={4} // 1 × 4px grid\n // Visual properties\n borderRadius=\"9999px\" // Full rounded for pill shape\n backgroundColor={\n isDisabled\n ? ColorSchemes.default.disabled\n : checked\n ? isHovered\n ? ColorSchemes.states.hover.active\n : ColorSchemes.default.active\n : isHovered\n ? ColorSchemes.states.hover.inactive\n : ColorSchemes.default.inactive\n }\n opacity={\n !isDisabled && checked && isHovered\n ? ColorSchemes.states.hover.activeOpacity\n : 1\n }\n // State properties\n cursor=\"pointer\"\n // Animation\n {...TransitionStyles.slider}\n // Apply styles\n {...shadow}\n {...SliderPadding[size]}\n {...sliderDimensions}\n {...views['slider']}\n {...(isFocused ? ColorSchemes.states.focus : {})}\n >\n {/* Real control: a transparent input covering the whole track, so the\n element found by role/name is the one that receives clicks */}\n <SwitchContent\n id={switchId}\n name={name}\n role=\"switch\"\n aria-checked={checked}\n position=\"absolute\"\n top={0}\n left={0}\n width=\"100%\"\n height=\"100%\"\n margin={0}\n opacity={0}\n zIndex={2}\n cursor={\n isDisabled ? 'not-allowed' : isReadOnly ? 'default' : 'pointer'\n }\n checked={checked}\n onChange={handleToggle}\n onFocus={handleFocus}\n onBlur={handleBlur}\n disabled={isDisabled}\n readOnly={isReadOnly}\n aria-describedby={description ? descriptionId : undefined}\n {...props}\n />\n {/* Active content */}\n {activeChild && checked && (\n <View\n marginLeft={contentSpace}\n marginRight={contentInset}\n transition=\"all 0.2s ease-in-out\"\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n height=\"100%\"\n width=\"100%\"\n overflow=\"hidden\"\n fontSize={contentFontSize}\n color=\"color-white\"\n fontWeight={600}\n >\n {activeChild}\n </View>\n )}\n\n {/* Knob */}\n <View\n position=\"absolute\"\n top=\"50%\"\n left={checked ? undefined : knobOffset}\n right={checked ? knobOffset : undefined}\n borderRadius=\"50%\"\n backgroundColor={ColorSchemes.default.knob}\n boxShadow={\n isHovered\n ? '0 4px 10px rgba(15, 23, 42, 0.18)'\n : '0 1px 3px rgba(15, 23, 42, 0.18)'\n }\n transform={`translateY(-50%) ${\n isHovered ? 'scale(1.05)' : 'scale(1)'\n }`}\n {...TransitionStyles.knob}\n zIndex={1} // Ensure knob is above content\n {...KnobSizes[size]}\n {...views['circle']}\n />\n\n {/* Inactive content */}\n {inActiveChild && !checked && (\n <View\n marginLeft={contentInset}\n marginRight={contentSpace}\n transition=\"all 0.2s ease-in-out\"\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n height=\"100%\"\n width=\"100%\"\n overflow=\"hidden\"\n fontSize={contentFontSize}\n color=\"color-white\"\n fontWeight={600}\n >\n {inActiveChild}\n </View>\n )}\n </View>\n\n {/* Label on the right side */}\n {labelPosition === 'right' && label && (\n <Text\n fontWeight=\"500\" // Medium weight for better readability\n color={isDisabled ? 'color-gray-400' : 'inherit'}\n transition=\"all 0.2s ease-in-out\"\n >\n {label}\n </Text>\n )}\n </Label>\n );\n\n if (!description) return control;\n\n // The description sits outside the <label> so it describes the input via\n // `aria-describedby` instead of polluting its accessible name.\n return (\n <Vertical gap={4} width=\"fit-content\">\n {control}\n <Text\n id={descriptionId}\n color=\"color-gray-500\"\n fontSize=\"14px\"\n lineHeight=\"20px\"\n >\n {description}\n </Text>\n </Vertical>\n );\n};\nexport default SwitchView;\n",
|
|
100
100
|
"type": "registry:ui"
|
|
101
101
|
},
|
|
102
102
|
{
|
package/dist/registry/tabs.json
CHANGED
|
@@ -7,12 +7,18 @@
|
|
|
7
7
|
"categories": [
|
|
8
8
|
"Navigation"
|
|
9
9
|
],
|
|
10
|
-
"registryDependencies": [
|
|
10
|
+
"registryDependencies": [
|
|
11
|
+
"theme"
|
|
12
|
+
],
|
|
11
13
|
"meta": {
|
|
12
14
|
"appStudio": {
|
|
13
15
|
"entry": "src/components/pilot/tabs.ts",
|
|
14
16
|
"engine": ">=0.9.5",
|
|
15
|
-
"
|
|
17
|
+
"engineByPlatform": {
|
|
18
|
+
"ios": ">=0.10.0",
|
|
19
|
+
"android": ">=0.10.0"
|
|
20
|
+
},
|
|
21
|
+
"version": "0.12.1",
|
|
16
22
|
"license": "MIT",
|
|
17
23
|
"platforms": [
|
|
18
24
|
"web",
|
|
@@ -20,15 +26,9 @@
|
|
|
20
26
|
"android"
|
|
21
27
|
],
|
|
22
28
|
"dependencies": {
|
|
23
|
-
"web": [
|
|
24
|
-
|
|
25
|
-
]
|
|
26
|
-
"ios": [
|
|
27
|
-
"@app-studio/components@0.11.13"
|
|
28
|
-
],
|
|
29
|
-
"android": [
|
|
30
|
-
"@app-studio/components@0.11.13"
|
|
31
|
-
]
|
|
29
|
+
"web": [],
|
|
30
|
+
"ios": [],
|
|
31
|
+
"android": []
|
|
32
32
|
},
|
|
33
33
|
"npmImport": "@app-studio/components/tabs"
|
|
34
34
|
}
|
|
@@ -46,37 +46,42 @@
|
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
"path": "src/components/Tabs/Tabs.tsx",
|
|
49
|
-
"content": "import React from 'react';\nimport { TabsProps } from './Tabs/Tabs.props';\nimport {
|
|
49
|
+
"content": "import React, { useId } from 'react';\nimport { TabsProps } from './Tabs/Tabs.props';\nimport {\n getTabId,\n useTabsState,\n useTabsCompoundState,\n} from './Tabs/Tabs.state';\nimport {\n TabsView,\n TabsContext,\n TabsList,\n TabsTrigger,\n TabsContent,\n} from './Tabs/Tabs.view';\nimport { Tab } from './Tabs/Tabs.type'; // Import Tab type\nimport { useDesignSystemComponentLayers } from '../../design-system/theme';\n\n/**\n * Tabs component allows users to navigate between different sections of content.\n * Supports both data-driven approach (with tabs prop) and compound component pattern.\n */\nconst TabsComponent: React.FC<TabsProps> = (props) => {\n const id = useId();\n const { props: mergedProps, themeViews } = useDesignSystemComponentLayers(\n 'tabs',\n props\n );\n const {\n tabs,\n views,\n defaultValue,\n onTabChange,\n renderTab,\n renderContent,\n variant = 'underline',\n iconPosition = 'left',\n keepMounted = false,\n value,\n onValueChange,\n children,\n 'aria-label': label,\n 'aria-labelledby': labelledBy,\n } = mergedProps;\n // For compound component pattern\n const compoundState = useTabsCompoundState(\n defaultValue,\n value,\n onValueChange\n );\n\n // For data-driven pattern\n const dataState = useTabsState(tabs || [], defaultValue, value);\n\n // If using compound component pattern (children provided)\n if (children) {\n return (\n <TabsContext.Provider\n value={{ ...compoundState, variant, id, views, themeViews }}\n >\n {children}\n </TabsContext.Provider>\n );\n }\n\n // If using data-driven pattern (tabs provided)\n if (tabs) {\n // Handler function to change the active tab and trigger the callback\n const handleTabClick = (tab: Tab) => {\n // Only update state and call callback if the clicked tab is different from the current one\n if (\n !dataState.activeTab ||\n getTabId(dataState.activeTab) !== getTabId(tab)\n ) {\n dataState.setActiveTab(tab);\n // Call the onTabChange callback if provided\n if (onTabChange) {\n onTabChange(tab);\n }\n }\n };\n\n // Render the presentation component with the necessary props\n return (\n <TabsView\n id={id}\n aria-label={label}\n aria-labelledby={labelledBy}\n tabs={tabs}\n views={views}\n themeViews={themeViews}\n activeTab={dataState.activeTab} // Pass the activeTab object from state\n handleTabClick={handleTabClick} // Pass the click handler\n renderTab={renderTab}\n renderContent={renderContent}\n variant={variant}\n iconPosition={iconPosition}\n keepMounted={keepMounted}\n />\n );\n }\n\n // If neither tabs nor children are provided, return null\n return null;\n};\n\n// Define the compound component type\ninterface TabsType extends React.FC<TabsProps> {\n List: typeof TabsList;\n Trigger: typeof TabsTrigger;\n Content: typeof TabsContent;\n}\n\n// Export the component wrapped in React.memo for performance optimization\nconst TabsMemoized = React.memo(TabsComponent);\n\n// Create the compound component with proper typing\nexport const Tabs = TabsMemoized as unknown as TabsType;\n\n// Assign the sub-components to the main component\nTabs.List = TabsList;\nTabs.Trigger = TabsTrigger;\nTabs.Content = TabsContent;\n",
|
|
50
50
|
"type": "registry:ui"
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
53
|
"path": "src/components/Tabs/Tabs/TabHeader.tsx",
|
|
54
|
-
"content": "import React from 'react';\nimport { Element, Text, ViewProps } from 'app-studio';\nimport { Tab } from './Tabs.type';\n\nexport interface TabHeaderProps {\n /** The tab data */\n tab: Tab;\n /** Whether this tab is currently active */\n isActive: boolean;\n /** Handler for when the tab is clicked */\n onClick: () => void;\n /** Position of the icon relative to the text */\n iconPosition?: 'left' | 'right' | 'top' | 'bottom';\n /** Custom styles for the tab header */\n tabStyles?: ViewProps;\n /** Custom styles for the tab text */\n textStyles?: ViewProps;\n}\n\n/**\n * TabHeader component renders a single tab in the tab navigation.\n * It's designed to be a lightweight alternative to using Button components.\n */\nexport const TabHeader: React.FC<TabHeaderProps> = React.memo(\n ({\n tab,\n isActive,\n onClick,\n iconPosition = 'left',\n tabStyles,\n textStyles,\n }) => {\n // Determine the flex direction based on icon position\n const getFlexDirection = () => {\n switch (iconPosition) {\n case 'top':\n return 'column';\n case 'bottom':\n return 'column-reverse';\n case 'right':\n return 'row-reverse';\n case 'left':\n default:\n return 'row';\n }\n };\n\n // Determine the gap based on icon position\n const getGap = () => {\n return ['top', 'bottom'].includes(iconPosition) ? '4px' : '8px';\n };\n\n // Clone icon to apply active styles (e.g. bold stroke) if valid.\n // Use isValidElement's generic to give `tab.icon.props` a concrete shape\n // (React 19 types it as `unknown` by default).\n const iconElement =\n tab.icon && React.isValidElement<{ strokeWidth?: number }>(tab.icon)\n ? React.cloneElement(tab.icon, {\n strokeWidth: isActive ? 2.5 : 2,\n })\n : tab.icon;\n\n return (\n <Element\n as=\"div\"\n
|
|
54
|
+
"content": "import React from 'react';\nimport { Element, Text, ViewProps } from 'app-studio';\nimport { Tab } from './Tabs.type';\n\nexport interface TabHeaderProps {\n id: string;\n controls?: string;\n /** The tab data */\n tab: Tab;\n /** Whether this tab is currently active */\n isActive: boolean;\n /** Handler for when the tab is clicked */\n onClick: () => void;\n /** Position of the icon relative to the text */\n iconPosition?: 'left' | 'right' | 'top' | 'bottom';\n /** Custom styles for the tab header */\n tabStyles?: ViewProps;\n /** Custom styles for the tab text */\n textStyles?: ViewProps;\n}\n\n/**\n * TabHeader component renders a single tab in the tab navigation.\n * It's designed to be a lightweight alternative to using Button components.\n */\nexport const TabHeader: React.FC<TabHeaderProps> = React.memo(\n ({\n id,\n controls,\n tab,\n isActive,\n onClick,\n iconPosition = 'left',\n tabStyles,\n textStyles,\n }) => {\n // Determine the flex direction based on icon position\n const getFlexDirection = () => {\n switch (iconPosition) {\n case 'top':\n return 'column';\n case 'bottom':\n return 'column-reverse';\n case 'right':\n return 'row-reverse';\n case 'left':\n default:\n return 'row';\n }\n };\n\n // Determine the gap based on icon position\n const getGap = () => {\n return ['top', 'bottom'].includes(iconPosition) ? '4px' : '8px';\n };\n\n // Clone icon to apply active styles (e.g. bold stroke) if valid.\n // Use isValidElement's generic to give `tab.icon.props` a concrete shape\n // (React 19 types it as `unknown` by default).\n const iconElement =\n tab.icon && React.isValidElement<{ strokeWidth?: number }>(tab.icon)\n ? React.cloneElement(tab.icon, {\n strokeWidth: isActive ? 2.5 : 2,\n })\n : tab.icon;\n const label = tab.title ?? tab.label;\n\n return (\n <Element\n as=\"div\"\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n cursor=\"pointer\"\n transition=\"background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease\"\n {...tabStyles}\n flexDirection={getFlexDirection()}\n gap={getGap()}\n onClick={onClick}\n id={id}\n role=\"tab\"\n aria-selected={isActive}\n aria-controls={controls}\n tabIndex={isActive ? 0 : -1}\n data-state={isActive ? 'active' : 'inactive'}\n >\n {/* \n Force icon remount when active state changes to ensure strokeWidth prop is applied \n even if the Icon component doesn't handle prop updates correctly.\n */}\n {iconElement && (\n <Element key={isActive ? 'active-icon' : 'inactive-icon'}>\n {iconElement}\n </Element>\n )}\n\n {/* Grid wrapper to prevent layout shift when font weight changes */}\n <Element display=\"grid\" alignItems=\"center\" justifyContent=\"center\">\n {/* Invisible bold text to reserve space */}\n {(typeof label === 'string' || typeof label === 'number') && (\n <Text\n {...textStyles}\n fontWeight=\"600\"\n visibility=\"hidden\"\n gridColumn=\"1\"\n gridRow=\"1\"\n aria-hidden=\"true\"\n >\n {label}\n </Text>\n )}\n {/* Visible text */}\n <Text\n {...textStyles}\n fontWeight={isActive ? '600' : '500'}\n gridColumn=\"1\"\n gridRow=\"1\"\n >\n {label}\n </Text>\n </Element>\n </Element>\n );\n }\n);\n",
|
|
55
55
|
"type": "registry:ui"
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
"path": "src/components/Tabs/Tabs/Tabs.props.ts",
|
|
59
|
-
"content": "import React from 'react';\nimport { TabsStyles, TabsVariant, Tab } from './Tabs.type';\nimport { ViewProps } from 'app-studio';\n\n/**\n * Props for the main Tabs component (External API).\n * Supports both data-driven approach (with tabs prop) and compound component pattern.\n */\nexport interface TabsProps {\n /** Array of tab objects to be displayed. Each tab needs a unique `value`. (Data-driven approach) */\n tabs?: Tab[];\n /** Optional value of the tab to be active initially. Defaults to the first tab if not provided or not found. */\n defaultValue?: string | number;\n /** Optional callback function triggered when the active tab changes. Receives the newly active tab object. */\n onTabChange?: (activeTab: Tab) => void;\n /** Optional styles object to customize the appearance of the tabs container, headers, text, and content area. */\n views?: TabsStyles;\n /** Visual presentation style for the tab list. */\n variant?: TabsVariant;\n /** Optional position of the icon relative to the text in tab headers. */\n iconPosition?: 'left' | 'right' | 'top' | 'bottom';\n /**\n * Optional custom renderer for a single tab header.\n * Receives the tab data, whether it's currently active, and an onClick handler to activate the tab.\n */\n renderTab?: (\n tab: Tab,\n isActive: boolean,\n onClick: () => void\n ) => React.ReactNode;\n /**\n * Optional custom renderer for the content area.\n * Receives the currently active tab object.\n * If not provided, the `content` property from the active tab object will be rendered.\n */\n renderContent?: (activeTab: Tab) => React.ReactNode;\n\n /**\n * By default only the ACTIVE tab's content is mounted — inactive tabs do\n * not exist in the DOM (their state resets on switch, and tests must\n * activate a tab before asserting on its content). Set `keepMounted` to\n * mount every tab's content up front and toggle visibility with\n * `display: none`, preserving internal state across switches. Only applies\n * to the data-driven `tabs` path; `renderContent` still receives the active\n * tab only.\n */\n keepMounted?: boolean;\n\n /** Current value for controlled compound component pattern */\n value?: string | number;\n /**\n * Callback when tab value changes in compound component pattern. Receives\n * the tab's value — matching `Tabs.type.ts` and `Tabs.state.ts`, which\n * already declared `string | number` while this one said `any`.\n */\n onValueChange?: (value: string | number) => void;\n /** Children for compound component pattern */\n children?: React.ReactNode;\n}\n\n/**\n * Props specifically for the TabsView component (Internal).\n * These props are derived or passed down from the main Tabs component.\n */\nexport interface TabsViewProps {\n variant?: TabsVariant;\n iconPosition?: 'left' | 'right' | 'bottom' | 'top'; // Added iconPosition prop\n /** The original array of tab objects. */\n tabs: Tab[];\n /** The currently active tab object, or undefined if none is active. */\n activeTab: Tab | undefined;\n /** Callback function to handle clicking on a tab header/button. */\n handleTabClick: (tab: Tab) => void;\n /** Optional styles object. */\n views?: TabsStyles;\n /** Optional custom renderer for a tab button/header. */\n renderTab?: (\n tab: Tab,\n isActive: boolean,\n onClick: () => void\n ) => React.ReactNode;\n /** Optional custom renderer for the content area. */\n renderContent?: (activeTab: Tab) => React.ReactNode;\n /** Mount every tab's content and hide inactive ones with display:none. */\n keepMounted?: boolean;\n}\n\n/**\n * Props for TabsList compound component\n */\nexport interface TabsListProps {\n /** Children (TabsTrigger components) */\n children: React.ReactNode;\n /** Custom styles for the list container */\n views?: {\n container?: ViewProps;\n };\n}\n\n/**\n * Props for TabsTrigger compound component\n */\nexport interface TabsTriggerProps {\n /** Unique value for this tab */\n value: string;\n /** Children content for the trigger */\n children: React.ReactNode;\n /** Whether this trigger is disabled */\n disabled?: boolean;\n /** Custom styles for the trigger */\n views?: {\n trigger?: ViewProps;\n activeState?: ViewProps;\n };\n}\n\n/**\n * Props for TabsContent compound component\n */\nexport interface TabsContentProps {\n /** Value that this content corresponds to */\n value: string;\n /** Children content to display when this tab is active */\n children: React.ReactNode;\n /** Custom styles for the content */\n views?: {\n content?: ViewProps;\n };\n}\n",
|
|
59
|
+
"content": "import React from 'react';\nimport { TabsStyles, TabsVariant, Tab } from './Tabs.type';\nimport { ViewProps } from 'app-studio';\n\n/**\n * Props for the main Tabs component (External API).\n * Supports both data-driven approach (with tabs prop) and compound component pattern.\n */\nexport interface TabsProps {\n /** Array of tab objects to be displayed. Each tab needs a unique `value`. (Data-driven approach) */\n tabs?: Tab[];\n /** Optional value of the tab to be active initially. Defaults to the first tab if not provided or not found. */\n defaultValue?: string | number;\n /** Optional callback function triggered when the active tab changes. Receives the newly active tab object. */\n onTabChange?: (activeTab: Tab) => void;\n /** Optional styles object to customize the appearance of the tabs container, headers, text, and content area. */\n views?: TabsStyles;\n /** Accessible name for the data-driven tab list. */\n 'aria-label'?: string;\n /** ID of the element naming the data-driven tab list. */\n 'aria-labelledby'?: string;\n /** Visual presentation style for the tab list. */\n variant?: TabsVariant;\n /** Optional position of the icon relative to the text in tab headers. */\n iconPosition?: 'left' | 'right' | 'top' | 'bottom';\n /**\n * Optional custom renderer for a single tab header.\n * Receives the tab data, whether it's currently active, and an onClick handler to activate the tab.\n */\n renderTab?: (\n tab: Tab,\n isActive: boolean,\n onClick: () => void\n ) => React.ReactNode;\n /**\n * Optional custom renderer for the content area.\n * Receives the currently active tab object.\n * If not provided, the `content` property from the active tab object will be rendered.\n */\n renderContent?: (activeTab: Tab) => React.ReactNode;\n\n /**\n * By default only the ACTIVE tab's content is mounted — inactive tabs do\n * not exist in the DOM (their state resets on switch, and tests must\n * activate a tab before asserting on its content). Set `keepMounted` to\n * mount every tab's content up front and toggle visibility with\n * `display: none`, preserving internal state across switches. Only applies\n * to the data-driven `tabs` path; `renderContent` still receives the active\n * tab only.\n */\n keepMounted?: boolean;\n\n /** Current value for controlled compound component pattern */\n value?: string | number;\n /**\n * Callback when tab value changes in compound component pattern. Receives\n * the tab's value — matching `Tabs.type.ts` and `Tabs.state.ts`, which\n * already declared `string | number` while this one said `any`.\n */\n onValueChange?: (value: string | number) => void;\n /** Children for compound component pattern */\n children?: React.ReactNode;\n}\n\n/**\n * Props specifically for the TabsView component (Internal).\n * These props are derived or passed down from the main Tabs component.\n */\nexport interface TabsViewProps {\n id: string;\n themeViews?: TabsStyles;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n variant?: TabsVariant;\n iconPosition?: 'left' | 'right' | 'bottom' | 'top'; // Added iconPosition prop\n /** The original array of tab objects. */\n tabs: Tab[];\n /** The currently active tab object, or undefined if none is active. */\n activeTab: Tab | undefined;\n /** Callback function to handle clicking on a tab header/button. */\n handleTabClick: (tab: Tab) => void;\n /** Optional styles object. */\n views?: TabsStyles;\n /** Optional custom renderer for a tab button/header. */\n renderTab?: (\n tab: Tab,\n isActive: boolean,\n onClick: () => void\n ) => React.ReactNode;\n /** Optional custom renderer for the content area. */\n renderContent?: (activeTab: Tab) => React.ReactNode;\n /** Mount every tab's content and hide inactive ones with display:none. */\n keepMounted?: boolean;\n}\n\n/**\n * Props for TabsList compound component\n */\nexport interface TabsListProps {\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n /** Children (TabsTrigger components) */\n children: React.ReactNode;\n /** Custom styles for the list container */\n views?: {\n container?: ViewProps;\n };\n}\n\n/**\n * Props for TabsTrigger compound component\n */\nexport interface TabsTriggerProps {\n /** Unique value for this tab */\n value: string;\n /** Children content for the trigger */\n children: React.ReactNode;\n /** Whether this trigger is disabled */\n disabled?: boolean;\n /** Custom styles for the trigger */\n views?: {\n trigger?: ViewProps;\n activeState?: ViewProps;\n };\n}\n\n/**\n * Props for TabsContent compound component\n */\nexport interface TabsContentProps {\n /** Value that this content corresponds to */\n value: string;\n /** Children content to display when this tab is active */\n children: React.ReactNode;\n /** Custom styles for the content */\n views?: {\n content?: ViewProps;\n };\n}\n",
|
|
60
60
|
"type": "registry:ui"
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
63
|
"path": "src/components/Tabs/Tabs/Tabs.state.ts",
|
|
64
|
-
"content": "import { useState, useEffect } from 'react';\nimport { Tab } from './Tabs.type';\n\n/**\n * Custom hook to manage the state of the active tab.\n * @param propTabs - The array of tab objects provided as props.\n * @param defaultValue - The optional title of the tab to be initially active.\n * @returns An object containing the current activeTab and a function to update it.\n */\nexport const useTabsState = (\n propTabs: Tab[],\n defaultValue?: string | number,\n value?: string | number\n) => {\n
|
|
64
|
+
"content": "import { useState, useEffect } from 'react';\nimport { Tab } from './Tabs.type';\n\nexport const getTabId = (tab: Tab) => tab.value ?? tab.title;\n\n/**\n * Custom hook to manage the state of the active tab.\n * @param propTabs - The array of tab objects provided as props.\n * @param defaultValue - The optional title of the tab to be initially active.\n * @returns An object containing the current activeTab and a function to update it.\n */\nexport const useTabsState = (\n propTabs: Tab[],\n defaultValue?: string | number,\n value?: string | number\n) => {\n const initialTab =\n (defaultValue === undefined\n ? undefined\n : propTabs.find((tab) => getTabId(tab) === defaultValue)) ?? propTabs[0];\n const [selection, setSelection] = useState(() => ({\n defaultValue,\n id: initialTab && getTabId(initialTab),\n }));\n const activeTab =\n value !== undefined\n ? propTabs.find((tab) => getTabId(tab) === value)\n : (selection.defaultValue === defaultValue\n ? propTabs.find((tab) => getTabId(tab) === selection.id)\n : undefined) ?? initialTab;\n const activeId = activeTab && getTabId(activeTab);\n\n useEffect(() => {\n if (\n value === undefined &&\n (selection.id !== activeId || selection.defaultValue !== defaultValue)\n ) {\n setSelection({ defaultValue, id: activeId });\n }\n }, [activeId, defaultValue, selection, value]);\n\n const setActiveTab = (tab: Tab) => {\n if (value === undefined) {\n setSelection({ defaultValue, id: getTabId(tab) });\n }\n };\n\n return {\n activeTab,\n setActiveTab,\n };\n};\n\n/**\n * Custom hook to manage the state for compound component pattern.\n * @param defaultValue - The default value for the active tab (uncontrolled)\n * @param value - The current value for the active tab (controlled)\n * @param onValueChange - Callback when the active value changes\n * @returns An object containing the current activeValue and a function to update it.\n */\nexport const useTabsCompoundState = (\n defaultValue?: string | number,\n value?: string | number,\n onValueChange?: (value: string | number) => void\n) => {\n const [internalValue, setInternalValue] = useState<string | number | null>(\n defaultValue ?? null\n );\n\n // Use controlled value if provided, otherwise use internal state\n const activeValue = value !== undefined ? value : internalValue;\n\n const setActiveValue = (newValue: string | number) => {\n // Only update internal state if not controlled\n if (value === undefined) {\n setInternalValue(newValue);\n }\n\n // Always call the callback\n if (onValueChange) {\n onValueChange(newValue);\n }\n };\n\n return {\n activeValue,\n setActiveValue,\n };\n};\n",
|
|
65
|
+
"type": "registry:ui"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"path": "src/components/Tabs/Tabs/Tabs.styles.ts",
|
|
69
|
+
"content": "import type { ViewProps } from 'app-studio';\nimport { mergeDesignSystemViews } from '../../../design-system/theme';\nimport type { TabsStyles } from './Tabs.type';\n\nexport function resolveTabStyles(\n recipe: {\n tab: ViewProps;\n activeTab: ViewProps;\n text: ViewProps;\n activeText: ViewProps;\n },\n active: boolean,\n views: TabsStyles,\n themeViews: TabsStyles\n) {\n return mergeDesignSystemViews(\n { tab: themeViews.tab, title: themeViews.title },\n active\n ? { tab: themeViews.activeTab, title: themeViews.activeText }\n : undefined,\n { tab: recipe.tab, title: recipe.text },\n active ? { tab: recipe.activeTab, title: recipe.activeText } : undefined,\n { tab: views.tab, title: views.title },\n active ? { tab: views.activeTab, title: views.activeText } : undefined\n );\n}\n",
|
|
65
70
|
"type": "registry:ui"
|
|
66
71
|
},
|
|
67
72
|
{
|
|
68
73
|
"path": "src/components/Tabs/Tabs/Tabs.type.ts",
|
|
69
|
-
"content": "import { ViewProps } from 'app-studio';\nimport React from 'react';\n\nexport type TabsVariant = 'underline' | 'segmented' | 'pill';\n\n/**\n * Defines the structure for a single tab.\n */\nexport type Tab = {\n /** The text displayed on the tab header/button. */\n title?: string;\n /** Optional label used as an alternative to `title` in some compositions. */\n label?: React.ReactNode;\n /** Unique value to identify the tab. If not provided, title will be used. */\n value?: string | number;\n /** Optional icon element to display next to the title. */\n icon?: React.ReactNode; // Use React.ReactNode instead of any\n /** The content to display when this tab is active. Can be any renderable React node. */\n content?: React.ReactNode; // Use React.ReactNode instead of any\n};\n\n/**\n * Context type for managing tab state in compound components\n */\nexport interface TabsContextType {\n /** Currently active tab value */\n activeValue: string | number | null;\n /** Function to set the active tab */\n setActiveValue: (value: string | number) => void;\n /** Visual variant for the tabs */\n variant?: TabsVariant;\n /** Default value for initial tab */\n defaultValue?: string | number;\n /** Callback when tab changes */\n onValueChange?: (value: string | number) => void;\n}\n\n/**\n * Defines the structure for applying custom styles to various parts of the Tabs component.\n * Allows using either direct CSSProperties or passing props compatible with underlying Button/Text components.\n */\nexport type TabsStyles = {\n /** Styles for the main container wrapping the tabs and content. */\n container?: ViewProps;\n /** Styles applied specifically to the active tab header. Merged with `tab` views. */\n activeTab?: ViewProps;\n /** Styles applied specifically to the text within the active tab header. Merged with `title` views. */\n activeText?: ViewProps;\n /** Styles applied to each tab header (both active and inactive). */\n tab?: ViewProps;\n /** Styles applied to the content area displaying the active tab's content. */\n content?: ViewProps;\n /** Styles applied to the text within each tab header (both active and inactive). */\n title?: ViewProps;\n /** Styles applied to the container element that wraps the tab buttons/headers. */\n headerTabs?: ViewProps;\n};\n",
|
|
74
|
+
"content": "import { ViewProps } from 'app-studio';\nimport React from 'react';\n\nexport type TabsVariant = 'underline' | 'segmented' | 'pill';\n\n/**\n * Defines the structure for a single tab.\n */\nexport type Tab = {\n /** The text displayed on the tab header/button. */\n title?: string;\n /** Optional label used as an alternative to `title` in some compositions. */\n label?: React.ReactNode;\n /** Unique value to identify the tab. If not provided, title will be used. */\n value?: string | number;\n /** Optional icon element to display next to the title. */\n icon?: React.ReactNode; // Use React.ReactNode instead of any\n /** The content to display when this tab is active. Can be any renderable React node. */\n content?: React.ReactNode; // Use React.ReactNode instead of any\n};\n\n/**\n * Context type for managing tab state in compound components\n */\nexport interface TabsContextType {\n /** Scope DOM IDs to this tabs instance. */\n id: string;\n views?: TabsStyles;\n themeViews?: TabsStyles;\n /** Currently active tab value */\n activeValue: string | number | null;\n /** Function to set the active tab */\n setActiveValue: (value: string | number) => void;\n /** Visual variant for the tabs */\n variant?: TabsVariant;\n /** Default value for initial tab */\n defaultValue?: string | number;\n /** Callback when tab changes */\n onValueChange?: (value: string | number) => void;\n}\n\n/**\n * Defines the structure for applying custom styles to various parts of the Tabs component.\n * Allows using either direct CSSProperties or passing props compatible with underlying Button/Text components.\n */\nexport type TabsStyles = {\n /** Styles for the main container wrapping the tabs and content. */\n container?: ViewProps;\n /** Styles applied specifically to the active tab header. Merged with `tab` views. */\n activeTab?: ViewProps;\n /** Styles applied specifically to the text within the active tab header. Merged with `title` views. */\n activeText?: ViewProps;\n /** Styles applied to each tab header (both active and inactive). */\n tab?: ViewProps;\n /** Styles applied to the content area displaying the active tab's content. */\n content?: ViewProps;\n /** Styles applied to the text within each tab header (both active and inactive). */\n title?: ViewProps;\n /** Styles applied to the container element that wraps the tab buttons/headers. */\n headerTabs?: ViewProps;\n};\n",
|
|
70
75
|
"type": "registry:ui"
|
|
71
76
|
},
|
|
72
77
|
{
|
|
73
78
|
"path": "src/components/Tabs/Tabs/Tabs.view.native.tsx",
|
|
74
|
-
"content": "import React, { createContext, useCallback, useContext } from 'react';\nimport {\n View,\n Horizontal,\n Vertical,\n Text,\n useTheme,\n ViewProps,\n} from 'app-studio';\nimport {\n TabsViewProps,\n TabsListProps,\n TabsTriggerProps,\n TabsContentProps,\n} from './Tabs.props';\nimport { TabsContextType, TabsVariant } from './Tabs.type';\nimport { deepMerge, useDesignSystemComponentProps } from '@app-studio/components/theme';\n\nconst getTabsVariantStyles = (\n variant: TabsVariant,\n themeMode: string\n): {\n header: ViewProps;\n tab: ViewProps;\n activeTab: ViewProps;\n text: ViewProps;\n activeText: ViewProps;\n content: ViewProps;\n} => {\n const isDark = themeMode === 'dark';\n if (variant === 'segmented') {\n return {\n header: {\n alignSelf: 'flex-start',\n gap: 6,\n padding: 6,\n borderRadius: 16,\n backgroundColor: isDark ? 'color-gray-800' : 'color-gray-100',\n },\n tab: {\n minHeight: 44,\n paddingHorizontal: 22,\n borderRadius: 12,\n color: isDark ? 'color-gray-300' : 'color-gray-600',\n borderWidth: 1,\n borderStyle: 'solid',\n borderColor: isDark ? 'color-gray-800' : 'color-gray-100',\n },\n activeTab: {\n backgroundColor: isDark ? 'color-gray-700' : 'color-white',\n color: isDark ? 'color-white' : 'color-gray-900',\n },\n text: { fontSize: 14, lineHeight: 20 },\n activeText: {},\n content: { width: '100%' },\n };\n }\n if (variant === 'pill') {\n return {\n header: {\n width: '100%',\n flexWrap: 'wrap',\n gap: 12,\n },\n tab: {\n minHeight: 44,\n paddingHorizontal: 22,\n borderRadius: 999,\n backgroundColor: isDark ? 'color-gray-900' : 'color-white',\n color: isDark ? 'color-gray-200' : 'color-gray-600',\n borderWidth: 1,\n borderStyle: 'solid',\n borderColor: isDark ? 'color-gray-700' : 'color-gray-200',\n },\n activeTab: {\n backgroundColor: 'theme-primary',\n color: 'color-white',\n borderColor: 'theme-primary',\n },\n text: { fontSize: 14, lineHeight: 20 },\n activeText: {},\n content: { width: '100%' },\n };\n }\n return {\n header: { width: '100%', gap: 20 },\n tab: {\n minHeight: 44,\n paddingHorizontal: 4,\n borderRadius: 0,\n color: isDark ? 'color-gray-400' : 'color-gray-500',\n borderBottomWidth: 3,\n borderBottomColor: isDark ? 'color-gray-900' : 'color-white',\n },\n activeTab: {\n color: 'theme-primary',\n borderBottomColor: 'theme-primary',\n },\n text: { fontSize: 14, lineHeight: 20 },\n activeText: {},\n content: { width: '100%', paddingTop: 12 },\n };\n};\n\nexport const TabsView: React.FC<TabsViewProps> = ({\n tabs = [],\n activeTab,\n handleTabClick,\n views = {},\n renderTab,\n renderContent,\n variant = 'underline',\n iconPosition = 'left',\n}) => {\n const { themeMode } = useTheme();\n const variantStyles = getTabsVariantStyles(variant, themeMode);\n if (!activeTab) return null;\n return (\n <Vertical width=\"100%\" height={'100%'} {...views.container}>\n <Horizontal\n alignItems=\"center\"\n {...variantStyles.header}\n {...views.headerTabs}\n >\n {tabs.map((tab) => {\n const isActive =\n (tab.value !== undefined ? tab.value : tab.title) ===\n (activeTab.value !== undefined ? activeTab.value : activeTab.title);\n const onPress = () => handleTabClick(tab);\n if (renderTab) {\n return renderTab(tab, isActive, onPress);\n }\n return (\n <View\n key={tab.title}\n onPress={onPress}\n onClick={onPress}\n alignItems=\"center\"\n justifyContent=\"center\"\n {...variantStyles.tab}\n {...views.tab}\n {...(isActive ? variantStyles.activeTab : {})}\n {...(isActive ? views.activeTab : {})}\n >\n <Text\n {...variantStyles.text}\n {...views.title}\n {...(isActive ? variantStyles.activeText : {})}\n {...(isActive ? views.activeText : {})}\n >\n {tab.title}\n </Text>\n </View>\n );\n })}\n </Horizontal>\n <View height=\"100%\" {...variantStyles.content} {...views.content}>\n {renderContent ? renderContent(activeTab) : activeTab.content}\n </View>\n </Vertical>\n );\n};\n\nexport const TabsContext = createContext<TabsContextType | null>(null);\n\nexport const useTabsContext = () => {\n const context = useContext(TabsContext);\n if (!context) {\n throw new Error('useTabsContext must be used within a Tabs component');\n }\n return context;\n};\n\nexport const TabsList: React.FC<TabsListProps> = React.memo(\n ({ children, views }) => {\n const { themeMode } = useTheme();\n const { variant = 'underline' } = useTabsContext();\n const variantStyles = getTabsVariantStyles(variant, themeMode);\n const designSystemTabs = useDesignSystemComponentProps('tabs');\n const mergedViews = deepMerge(\n { container: designSystemTabs.views?.headerTabs },\n views\n );\n return (\n <Horizontal\n alignItems=\"center\"\n {...variantStyles.header}\n {...mergedViews?.container}\n >\n {children}\n </Horizontal>\n );\n }\n);\n\nexport const TabsTrigger: React.FC<TabsTriggerProps> = React.memo(\n ({ value, children, disabled = false, views }) => {\n const { themeMode } = useTheme();\n const {\n activeValue,\n setActiveValue,\n variant = 'underline',\n } = useTabsContext();\n const isActive = activeValue === value;\n const variantStyles = getTabsVariantStyles(variant, themeMode);\n const designSystemTabs = useDesignSystemComponentProps('tabs');\n const mergedViews = deepMerge(\n {\n trigger: designSystemTabs.views?.tab,\n activeState: designSystemTabs.views?.activeTab,\n },\n views\n );\n const handlePress = useCallback(() => {\n if (!disabled) setActiveValue(value);\n }, [disabled, value, setActiveValue]);\n return (\n <View\n opacity={disabled ? 0.6 : 1}\n alignItems=\"center\"\n justifyContent=\"center\"\n {...variantStyles.tab}\n {...(isActive ? variantStyles.activeTab : {})}\n onPress={handlePress}\n onClick={handlePress}\n {...mergedViews?.trigger}\n {...(isActive ? mergedViews?.activeState : {})}\n >\n <View\n {...variantStyles.text}\n {...(isActive ? variantStyles.activeText : {})}\n >\n {children}\n </View>\n </View>\n );\n }\n);\n\nexport const TabsContent: React.FC<TabsContentProps> = React.memo(\n ({ value, children, views }) => {\n const { activeValue } = useTabsContext();\n if (activeValue !== value) return null;\n return (\n <View width=\"100%\" padding={24} {...views?.content}>\n {children}\n </View>\n );\n }\n);\n",
|
|
79
|
+
"content": "import React, { createContext, useCallback, useContext } from 'react';\nimport {\n View,\n Horizontal,\n Vertical,\n Text,\n useTheme,\n ViewProps,\n} from 'app-studio';\nimport {\n TabsViewProps,\n TabsListProps,\n TabsTriggerProps,\n TabsContentProps,\n} from './Tabs.props';\nimport { TabsContextType, TabsStyles, TabsVariant } from './Tabs.type';\nimport { getTabId } from './Tabs.state';\nimport {\n deepMerge,\n useDesignSystemComponentProps,\n mergeDesignSystemViews,\n} from '../../../design-system/theme';\nimport { resolveTabStyles } from './Tabs.styles';\n\nconst iconDirections = {\n left: 'row',\n right: 'row-reverse',\n top: 'column',\n bottom: 'column-reverse',\n} as const;\n\nfunction getTabColor(view?: ViewProps) {\n const inline = view?.style;\n return (\n (inline && typeof inline === 'object' && 'color' in inline\n ? inline.color\n : undefined) ?? view?.color\n );\n}\n\nconst getTabsVariantStyles = (\n variant: TabsVariant,\n themeMode: string\n): {\n header: ViewProps;\n tab: ViewProps;\n activeTab: ViewProps;\n text: ViewProps;\n activeText: ViewProps;\n content: ViewProps;\n} => {\n const isDark = themeMode === 'dark';\n if (variant === 'segmented') {\n return {\n header: {\n alignSelf: 'flex-start',\n gap: 6,\n padding: 6,\n borderRadius: 16,\n backgroundColor: isDark ? 'color-gray-800' : 'color-gray-100',\n },\n tab: {\n minHeight: 44,\n paddingHorizontal: 22,\n borderRadius: 12,\n color: isDark ? 'color-gray-300' : 'color-gray-600',\n borderWidth: 1,\n borderStyle: 'solid',\n borderColor: isDark ? 'color-gray-800' : 'color-gray-100',\n },\n activeTab: {\n backgroundColor: isDark ? 'color-gray-700' : 'color-white',\n color: isDark ? 'color-white' : 'color-gray-900',\n },\n text: { fontSize: 14, lineHeight: 20 },\n activeText: {},\n content: { width: '100%' },\n };\n }\n if (variant === 'pill') {\n return {\n header: {\n width: '100%',\n flexWrap: 'wrap',\n gap: 12,\n },\n tab: {\n minHeight: 44,\n paddingHorizontal: 22,\n borderRadius: 999,\n backgroundColor: isDark ? 'color-gray-900' : 'color-white',\n color: isDark ? 'color-gray-200' : 'color-gray-600',\n borderWidth: 1,\n borderStyle: 'solid',\n borderColor: isDark ? 'color-gray-700' : 'color-gray-200',\n },\n activeTab: {\n backgroundColor: 'theme-primary',\n color: 'color-white',\n borderColor: 'theme-primary',\n },\n text: { fontSize: 14, lineHeight: 20 },\n activeText: {},\n content: { width: '100%' },\n };\n }\n return {\n header: { width: '100%', gap: 20 },\n tab: {\n minHeight: 44,\n paddingHorizontal: 4,\n borderRadius: 0,\n color: isDark ? 'color-gray-400' : 'color-gray-500',\n borderBottomWidth: 3,\n borderBottomColor: isDark ? 'color-gray-900' : 'color-white',\n },\n activeTab: {\n color: 'theme-primary',\n borderBottomColor: 'theme-primary',\n },\n text: { fontSize: 14, lineHeight: 20 },\n activeText: {},\n content: { width: '100%', paddingTop: 12 },\n };\n};\n\nexport const TabsView: React.FC<TabsViewProps> = ({\n 'aria-label': label,\n 'aria-labelledby': labelledBy,\n tabs = [],\n activeTab,\n handleTabClick,\n views: instanceViews = {},\n themeViews,\n renderTab,\n renderContent,\n variant = 'underline',\n iconPosition = 'left',\n keepMounted = false,\n}) => {\n const { themeMode } = useTheme();\n const variantStyles = getTabsVariantStyles(variant, themeMode);\n const views = themeViews\n ? mergeDesignSystemViews<TabsStyles>(\n themeViews,\n { headerTabs: variantStyles.header, content: variantStyles.content },\n instanceViews\n )\n : instanceViews;\n if (!activeTab) return null;\n return (\n <Vertical width=\"100%\" height={'100%'} {...views.container}>\n <Horizontal\n alignItems=\"center\"\n {...variantStyles.header}\n {...views.headerTabs}\n accessibilityRole=\"tablist\"\n accessibilityLabel={label ?? views.headerTabs?.accessibilityLabel}\n aria-labelledby={labelledBy ?? views.headerTabs?.['aria-labelledby']}\n >\n {tabs.map((tab, index) => {\n const isActive = tab === activeTab;\n const onPress = () => handleTabClick(tab);\n if (renderTab) {\n return renderTab(tab, isActive, onPress);\n }\n const style =\n themeViews &&\n resolveTabStyles(\n variantStyles,\n isActive,\n instanceViews,\n themeViews\n );\n return (\n <View\n key={getTabId(tab) ?? index}\n onPress={onPress}\n alignItems=\"center\"\n justifyContent=\"center\"\n flexDirection={iconDirections[iconPosition]}\n gap={iconPosition === 'top' || iconPosition === 'bottom' ? 4 : 8}\n {...(style\n ? style.tab\n : {\n ...variantStyles.tab,\n ...views.tab,\n ...(isActive ? variantStyles.activeTab : {}),\n ...(isActive ? views.activeTab : {}),\n })}\n accessible\n accessibilityRole=\"tab\"\n accessibilityState={{ selected: isActive }}\n >\n {tab.icon}\n <Text\n color={\n style\n ? getTabColor(style.tab)\n : isActive\n ? variantStyles.activeTab.color\n : variantStyles.tab.color\n }\n {...(style\n ? style.title\n : {\n ...variantStyles.text,\n ...views.title,\n ...(isActive ? variantStyles.activeText : {}),\n ...(isActive ? views.activeText : {}),\n })}\n >\n {tab.title ?? tab.label}\n </Text>\n </View>\n );\n })}\n </Horizontal>\n <View height=\"100%\" {...variantStyles.content} {...views.content}>\n {renderContent\n ? renderContent(activeTab)\n : keepMounted\n ? tabs.map((tab, index) => (\n <View\n key={getTabId(tab) ?? index}\n display={tab === activeTab ? undefined : 'none'}\n >\n {tab.content}\n </View>\n ))\n : activeTab.content}\n </View>\n </Vertical>\n );\n};\n\nexport const TabsContext = createContext<TabsContextType | null>(null);\n\nexport const useTabsContext = () => {\n const context = useContext(TabsContext);\n if (!context) {\n throw new Error('useTabsContext must be used within a Tabs component');\n }\n return context;\n};\n\nexport const TabsList: React.FC<TabsListProps> = React.memo(\n ({ children, views, 'aria-label': label, 'aria-labelledby': labelledBy }) => {\n const { themeMode } = useTheme();\n const {\n variant = 'underline',\n views: rootViews,\n themeViews,\n } = useTabsContext();\n const variantStyles = getTabsVariantStyles(variant, themeMode);\n const designSystemTabs = useDesignSystemComponentProps('tabs');\n const mergedViews = themeViews\n ? mergeDesignSystemViews(\n { container: themeViews.headerTabs },\n { container: variantStyles.header },\n { container: rootViews?.headerTabs },\n views\n )\n : deepMerge({ container: designSystemTabs.views?.headerTabs }, views);\n return (\n <Horizontal\n alignItems=\"center\"\n {...variantStyles.header}\n {...mergedViews?.container}\n accessibilityRole=\"tablist\"\n accessibilityLabel={label ?? mergedViews?.container?.accessibilityLabel}\n aria-labelledby={\n labelledBy ?? mergedViews?.container?.['aria-labelledby']\n }\n >\n {children}\n </Horizontal>\n );\n }\n);\n\nexport const TabsTrigger: React.FC<TabsTriggerProps> = React.memo(\n ({ value, children, disabled = false, views }) => {\n const { themeMode } = useTheme();\n const {\n activeValue,\n setActiveValue,\n variant = 'underline',\n views: rootViews,\n themeViews,\n } = useTabsContext();\n const isActive = activeValue === value;\n const variantStyles = getTabsVariantStyles(variant, themeMode);\n const designSystemTabs = useDesignSystemComponentProps('tabs');\n const mergedViews = deepMerge(\n {\n trigger: designSystemTabs.views?.tab,\n activeState: designSystemTabs.views?.activeTab,\n },\n views\n );\n const standardStyles =\n themeViews &&\n resolveTabStyles(\n variantStyles,\n isActive,\n mergeDesignSystemViews(rootViews, {\n tab: views?.trigger,\n activeTab: views?.activeState,\n }),\n themeViews\n );\n const handlePress = useCallback(() => {\n if (!disabled) setActiveValue(value);\n }, [disabled, value, setActiveValue]);\n return (\n <View\n opacity={disabled ? 0.6 : 1}\n alignItems=\"center\"\n justifyContent=\"center\"\n onPress={disabled ? undefined : handlePress}\n {...(standardStyles\n ? standardStyles.tab\n : {\n ...variantStyles.tab,\n ...(isActive ? variantStyles.activeTab : {}),\n ...mergedViews?.trigger,\n ...(isActive ? mergedViews?.activeState : {}),\n })}\n accessible\n accessibilityRole=\"tab\"\n accessibilityState={{ selected: isActive, disabled }}\n >\n <View\n color={standardStyles ? getTabColor(standardStyles.tab) : undefined}\n {...(standardStyles\n ? standardStyles.title\n : {\n ...variantStyles.text,\n ...(isActive ? variantStyles.activeText : {}),\n })}\n >\n {children}\n </View>\n </View>\n );\n }\n);\n\nexport const TabsContent: React.FC<TabsContentProps> = React.memo(\n ({ value, children, views }) => {\n const { activeValue, views: rootViews, themeViews } = useTabsContext();\n if (activeValue !== value) return null;\n return (\n <View\n width=\"100%\"\n padding={24}\n {...(themeViews\n ? mergeDesignSystemViews(\n { content: themeViews.content },\n { content: rootViews?.content },\n views\n ).content\n : views?.content)}\n >\n {children}\n </View>\n );\n }\n);\n",
|
|
75
80
|
"type": "registry:ui"
|
|
76
81
|
},
|
|
77
82
|
{
|
|
78
83
|
"path": "src/components/Tabs/Tabs/Tabs.view.tsx",
|
|
79
|
-
"content": "import React, { createContext, useCallback, useContext, useMemo } from 'react';\nimport { View, Horizontal, Vertical, useTheme, ViewProps } from 'app-studio';\nimport {\n TabsViewProps,\n TabsListProps,\n TabsTriggerProps,\n TabsContentProps,\n} from './Tabs.props';\nimport { TabsContextType, TabsVariant } from './Tabs.type';\nimport { TabHeader } from './TabHeader';\nimport { deepMerge, useDesignSystemComponentProps } from '@app-studio/components/theme';\n\nconst getTabsVariantStyles = (\n variant: TabsVariant,\n themeMode: string\n): {\n header: ViewProps;\n tab: ViewProps;\n activeTab: ViewProps;\n text: ViewProps;\n activeText: ViewProps;\n content: ViewProps;\n} => {\n const isDark = themeMode === 'dark';\n\n if (variant === 'segmented') {\n return {\n header: {\n width: 'fit-content',\n alignSelf: 'flex-start',\n gap: 6,\n padding: 6,\n borderRadius: 16, // radius-xl\n backgroundColor: 'color-gray-100',\n },\n tab: {\n minHeight: 44,\n padding: '0 22px',\n borderRadius: 12, // radius-lg\n color: 'color-gray-600',\n borderWidth: 1,\n borderStyle: 'solid',\n borderColor: 'color-gray-100',\n style: { backgroundColor: 'transparent' },\n },\n activeTab: {\n backgroundColor: 'color-white',\n color: 'color-gray-900',\n boxShadow: isDark\n ? '0 1px 3px rgba(0, 0, 0, 0.35)'\n : '0 1px 2px rgba(0, 0, 0, 0.06)',\n },\n text: {\n fontSize: 14,\n lineHeight: '20px',\n letterSpacing: '-0.01em',\n },\n activeText: {},\n content: {\n width: '100%',\n },\n };\n }\n\n if (variant === 'pill') {\n return {\n header: {\n width: '100%',\n flexWrap: 'wrap',\n gap: 12,\n },\n tab: {\n minHeight: 44,\n padding: '0 22px',\n borderRadius: '999px',\n backgroundColor: 'color-white',\n color: 'color-gray-600',\n borderWidth: 1,\n borderStyle: 'solid',\n borderColor: 'color-gray-200',\n },\n activeTab: {\n backgroundColor: 'theme-primary',\n color: 'color-white',\n borderColor: 'theme-primary',\n },\n text: {\n fontSize: 14,\n lineHeight: '20px',\n letterSpacing: '-0.01em',\n color: 'inherit',\n },\n activeText: {\n color: 'inherit',\n },\n content: {\n width: '100%',\n },\n };\n }\n\n return {\n header: {\n width: '100%',\n gap: 20,\n borderBottom: 'none',\n },\n tab: {\n minHeight: 44,\n padding: '0 4px',\n borderRadius: 0,\n color: 'color-gray-500',\n borderBottom: '3px solid',\n borderColor: 'color-white',\n style: { backgroundColor: 'transparent' },\n },\n activeTab: {\n color: 'theme-primary',\n borderColor: 'theme-primary',\n },\n text: {\n fontSize: 14,\n lineHeight: '20px',\n letterSpacing: '-0.01em',\n color: 'inherit',\n },\n activeText: {\n color: 'inherit',\n },\n content: {\n width: '100%',\n paddingTop: 12,\n },\n };\n};\n\n/**\n * The presentation component for Tabs. Renders the UI based on props.\n */\nexport const TabsView: React.FC<TabsViewProps> = ({\n tabs = [], // Default to empty array\n activeTab,\n handleTabClick,\n views = {}, // Default to empty object\n renderTab,\n renderContent,\n variant = 'underline',\n iconPosition = 'left', // Default to left\n keepMounted = false,\n}) => {\n const { themeMode } = useTheme();\n const variantStyles = getTabsVariantStyles(variant, themeMode);\n\n // If there's no active tab (e.g., tabs array is empty), render nothing or a placeholder\n if (!activeTab) {\n // Optionally render a placeholder when no tabs are active/available\n // return <View {...views.container}><Text>No tabs available.</Text></View>;\n return null; // Or simply render nothing\n }\n\n return (\n // Use Vertical layout for overall structure (tabs header above content)\n <Vertical width=\"100%\" height={'100%'} {...views.container}>\n {/* Horizontal layout for the tab headers/buttons */}\n <Horizontal\n alignItems=\"center\"\n {...variantStyles.header}\n {...views.headerTabs}\n >\n {tabs.map((tab) => {\n // Determine if the current tab in the loop is the active one\n const isActive =\n (tab.value !== undefined ? tab.value : tab.title) ===\n (activeTab.value !== undefined ? activeTab.value : activeTab.title);\n // Prepare the onClick handler for this specific tab\n const onClick = () => handleTabClick(tab);\n\n // Use the custom renderTab function if provided\n if (renderTab) {\n return renderTab(tab, isActive, onClick);\n }\n\n // Default rendering for a tab using our custom TabHeader component\n return (\n <TabHeader\n key={tab.title} // Use the unique title as the key\n tab={tab}\n isActive={isActive}\n onClick={onClick}\n iconPosition={iconPosition}\n tabStyles={{\n ...variantStyles.tab,\n ...views.tab,\n ...(isActive ? variantStyles.activeTab : {}),\n ...(isActive ? views.activeTab : {}),\n }}\n textStyles={{\n ...variantStyles.text,\n ...views.title,\n ...(isActive ? variantStyles.activeText : {}),\n ...(isActive ? views.activeText : {}),\n }}\n />\n );\n })}\n </Horizontal>\n\n {/* Content area */}\n <View height=\"100%\" {...variantStyles.content} {...views.content}>\n {/* Use the custom renderContent function if provided */}\n {renderContent\n ? renderContent(activeTab)\n : keepMounted\n ? // All panes stay mounted so their internal state survives tab\n // switches; inactive ones are hidden, not unmounted.\n tabs.map((tab) => {\n const tabId = tab.value !== undefined ? tab.value : tab.title;\n const activeId =\n activeTab.value !== undefined\n ? activeTab.value\n : activeTab.title;\n return (\n <View\n key={tab.title}\n display={tabId === activeId ? 'contents' : 'none'}\n >\n {tab.content}\n </View>\n );\n })\n : // Otherwise, render the content property from the active tab object\n activeTab.content}\n </View>\n </Vertical>\n );\n};\n\n// Context for compound components\nexport const TabsContext = createContext<TabsContextType | null>(null);\n\n// Hook to use the Tabs context\nexport const useTabsContext = () => {\n const context = useContext(TabsContext);\n if (!context) {\n throw new Error('useTabsContext must be used within a Tabs component');\n }\n return context;\n};\n\n// TabsList compound component\nexport const TabsList: React.FC<TabsListProps> = React.memo(\n ({ children, views }) => {\n const { themeMode } = useTheme();\n const { variant = 'underline' } = useTabsContext();\n const variantStyles = getTabsVariantStyles(variant, themeMode);\n const designSystemTabs = useDesignSystemComponentProps('tabs');\n const mergedViews = deepMerge(\n {\n container: designSystemTabs.views?.headerTabs,\n },\n views\n );\n\n return (\n <Horizontal\n alignItems=\"center\"\n {...variantStyles.header}\n {...mergedViews?.container}\n >\n {children}\n </Horizontal>\n );\n }\n);\n\n// TabsTrigger compound component\nexport const TabsTrigger: React.FC<TabsTriggerProps> = React.memo(\n ({ value, children, disabled = false, views }) => {\n const { themeMode } = useTheme();\n const {\n activeValue,\n setActiveValue,\n variant = 'underline',\n } = useTabsContext();\n const isActive = activeValue === value;\n const variantStyles = getTabsVariantStyles(variant, themeMode);\n const designSystemTabs = useDesignSystemComponentProps('tabs');\n const mergedViews = deepMerge(\n {\n trigger: designSystemTabs.views?.tab,\n activeState: designSystemTabs.views?.activeTab,\n },\n views\n );\n\n const handleClick = useCallback(() => {\n if (!disabled) {\n setActiveValue(value);\n }\n }, [disabled, value, setActiveValue]);\n\n return (\n <View\n cursor={disabled ? 'not-allowed' : 'pointer'}\n opacity={disabled ? 0.6 : 1}\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n transition=\"all 0.2s ease-in-out\"\n {...variantStyles.tab}\n {...(isActive ? variantStyles.activeTab : {})}\n _hover={\n !disabled\n ? variant === 'underline'\n ? { color: 'theme-primary' }\n : { opacity: 0.9 }\n : {}\n }\n onClick={handleClick}\n {...mergedViews?.trigger}\n {...(isActive ? mergedViews?.activeState : {})}\n >\n <View\n {...variantStyles.text}\n {...(isActive ? variantStyles.activeText : {})}\n >\n {children}\n </View>\n </View>\n );\n }\n);\n\n// TabsContent compound component\nexport const TabsContent: React.FC<TabsContentProps> = React.memo(\n ({ value, children, views }) => {\n const { activeValue } = useTabsContext();\n\n if (activeValue !== value) {\n return null;\n }\n\n return (\n <View width=\"100%\" padding=\"24px\" {...views?.content}>\n {children}\n </View>\n );\n }\n);\n",
|
|
84
|
+
"content": "import React, { createContext, useCallback, useContext } from 'react';\nimport { View, Horizontal, Vertical, useTheme, ViewProps } from 'app-studio';\nimport {\n TabsViewProps,\n TabsListProps,\n TabsTriggerProps,\n TabsContentProps,\n} from './Tabs.props';\nimport { TabsContextType, TabsStyles, TabsVariant } from './Tabs.type';\nimport { TabHeader } from './TabHeader';\nimport { getTabId } from './Tabs.state';\nimport {\n deepMerge,\n useDesignSystemComponentProps,\n mergeDesignSystemViews,\n} from '../../../design-system/theme';\nimport { resolveTabStyles } from './Tabs.styles';\n\nfunction getIds(scope: string, value: string | number) {\n const suffix = encodeURIComponent(value);\n return {\n trigger: `${scope}-tab-${suffix}`,\n panel: `${scope}-panel-${suffix}`,\n };\n}\n\nfunction handleListKeyDown(event: React.KeyboardEvent<HTMLElement>) {\n const list = event.currentTarget;\n const target = (event.target as HTMLElement).closest<HTMLElement>(\n '[role=\"tab\"]'\n );\n if (\n event.defaultPrevented ||\n target !== event.target ||\n target.closest('[role=\"tablist\"]') !== list\n )\n return;\n\n if (event.key === 'Enter' || event.key === ' ') {\n if (target.matches('button, a[href]')) return;\n event.preventDefault();\n if (target.getAttribute('aria-disabled') !== 'true') target.click();\n return;\n }\n\n const key = event.key;\n if (!['Home', 'End', 'ArrowLeft', 'ArrowRight'].includes(key)) return;\n const tabs = Array.from(\n list.querySelectorAll<HTMLElement>('[role=\"tab\"]')\n ).filter(\n (tab) =>\n tab.closest('[role=\"tablist\"]') === list &&\n !tab.matches(':disabled, [aria-disabled=\"true\"]')\n );\n const focused = tabs.indexOf(target);\n if (focused === -1) return;\n\n const rtl =\n list.ownerDocument.defaultView?.getComputedStyle(list).direction === 'rtl';\n let next: number;\n switch (key) {\n case 'Home':\n next = 0;\n break;\n case 'End':\n next = tabs.length - 1;\n break;\n default: {\n const step = (key === 'ArrowRight') !== rtl ? 1 : -1;\n next = (focused + step + tabs.length) % tabs.length;\n break;\n }\n }\n\n event.preventDefault();\n tabs[next].focus();\n if (tabs[next].getAttribute('aria-selected') !== 'true') tabs[next].click();\n}\n\nconst getTabsVariantStyles = (\n variant: TabsVariant,\n themeMode: string,\n standardPrecedence = false\n): {\n header: ViewProps;\n tab: ViewProps;\n activeTab: ViewProps;\n text: ViewProps;\n activeText: ViewProps;\n content: ViewProps;\n} => {\n const isDark = themeMode === 'dark';\n const transparent = standardPrecedence\n ? { backgroundColor: 'transparent' }\n : { style: { backgroundColor: 'transparent' } };\n\n if (variant === 'segmented') {\n return {\n header: {\n width: 'fit-content',\n alignSelf: 'flex-start',\n gap: 6,\n padding: 6,\n borderRadius: 16, // radius-xl\n backgroundColor: 'color-gray-100',\n },\n tab: {\n minHeight: 44,\n padding: '0 22px',\n borderRadius: 12, // radius-lg\n color: 'color-gray-600',\n borderWidth: 1,\n borderStyle: 'solid',\n borderColor: 'color-gray-100',\n ...transparent,\n },\n activeTab: {\n backgroundColor: 'color-white',\n color: 'color-gray-900',\n boxShadow: isDark\n ? '0 1px 3px rgba(0, 0, 0, 0.35)'\n : '0 1px 2px rgba(0, 0, 0, 0.06)',\n },\n text: {\n fontSize: 14,\n lineHeight: '20px',\n letterSpacing: '-0.01em',\n },\n activeText: {},\n content: {\n width: '100%',\n },\n };\n }\n\n if (variant === 'pill') {\n return {\n header: {\n width: '100%',\n flexWrap: 'wrap',\n gap: 12,\n },\n tab: {\n minHeight: 44,\n padding: '0 22px',\n borderRadius: '999px',\n backgroundColor: 'color-white',\n color: 'color-gray-600',\n borderWidth: 1,\n borderStyle: 'solid',\n borderColor: 'color-gray-200',\n },\n activeTab: {\n backgroundColor: 'theme-primary',\n color: 'color-white',\n borderColor: 'theme-primary',\n },\n text: {\n fontSize: 14,\n lineHeight: '20px',\n letterSpacing: '-0.01em',\n color: 'inherit',\n },\n activeText: {\n color: 'inherit',\n },\n content: {\n width: '100%',\n },\n };\n }\n\n return {\n header: {\n width: '100%',\n gap: 20,\n borderBottom: 'none',\n },\n tab: {\n minHeight: 44,\n padding: '0 4px',\n borderRadius: 0,\n color: 'color-gray-500',\n borderBottom: '3px solid',\n borderColor: 'color-white',\n ...transparent,\n },\n activeTab: {\n color: 'theme-primary',\n borderColor: 'theme-primary',\n },\n text: {\n fontSize: 14,\n lineHeight: '20px',\n letterSpacing: '-0.01em',\n color: 'inherit',\n },\n activeText: {\n color: 'inherit',\n },\n content: {\n width: '100%',\n paddingTop: 12,\n },\n };\n};\n\n/**\n * The presentation component for Tabs. Renders the UI based on props.\n */\nexport const TabsView: React.FC<TabsViewProps> = ({\n id,\n 'aria-label': label,\n 'aria-labelledby': labelledBy,\n tabs = [], // Default to empty array\n activeTab,\n handleTabClick,\n views: instanceViews = {},\n themeViews,\n renderTab,\n renderContent,\n variant = 'underline',\n iconPosition = 'left', // Default to left\n keepMounted = false,\n}) => {\n const { themeMode } = useTheme();\n const variantStyles = getTabsVariantStyles(\n variant,\n themeMode,\n Boolean(themeViews)\n );\n const views = themeViews\n ? mergeDesignSystemViews<TabsStyles>(\n themeViews,\n { headerTabs: variantStyles.header, content: variantStyles.content },\n instanceViews\n )\n : instanceViews;\n\n // If there's no active tab (e.g., tabs array is empty), render nothing or a placeholder\n if (!activeTab) {\n // Optionally render a placeholder when no tabs are active/available\n // return <View {...views.container}><Text>No tabs available.</Text></View>;\n return null; // Or simply render nothing\n }\n const activeIndex = tabs.indexOf(activeTab);\n const activeIds = getIds(id, activeIndex);\n const keepPanelsMounted = keepMounted && !renderContent;\n\n return (\n // Use Vertical layout for overall structure (tabs header above content)\n <Vertical width=\"100%\" height={'100%'} {...views.container}>\n {/* Horizontal layout for the tab headers/buttons */}\n <Horizontal\n alignItems=\"center\"\n {...variantStyles.header}\n {...views.headerTabs}\n role=\"tablist\"\n aria-label={label ?? views.headerTabs?.['aria-label']}\n aria-labelledby={labelledBy ?? views.headerTabs?.['aria-labelledby']}\n onKeyDown={(event: React.KeyboardEvent<HTMLElement>) => {\n views.headerTabs?.onKeyDown?.(event);\n handleListKeyDown(event);\n }}\n >\n {tabs.map((tab, index) => {\n const isActive = index === activeIndex;\n const ids = getIds(id, index);\n // Prepare the onClick handler for this specific tab\n const onClick = () => handleTabClick(tab);\n\n // Use the custom renderTab function if provided\n if (renderTab) {\n return renderTab(tab, isActive, onClick);\n }\n const style =\n themeViews &&\n resolveTabStyles(\n variantStyles,\n isActive,\n instanceViews,\n themeViews\n );\n\n // Default rendering for a tab using our custom TabHeader component\n return (\n <TabHeader\n key={getTabId(tab) ?? index}\n id={ids.trigger}\n controls={isActive || keepPanelsMounted ? ids.panel : undefined}\n tab={tab}\n isActive={isActive}\n onClick={onClick}\n iconPosition={iconPosition}\n tabStyles={\n style\n ? style.tab\n : {\n ...variantStyles.tab,\n ...views.tab,\n ...(isActive ? variantStyles.activeTab : {}),\n ...(isActive ? views.activeTab : {}),\n }\n }\n textStyles={\n style\n ? style.title\n : {\n ...variantStyles.text,\n ...views.title,\n ...(isActive ? variantStyles.activeText : {}),\n ...(isActive ? views.activeText : {}),\n }\n }\n />\n );\n })}\n </Horizontal>\n\n {/* Content area */}\n <View height=\"100%\" {...variantStyles.content} {...views.content}>\n {/* Use the custom renderContent function if provided */}\n {keepPanelsMounted ? (\n tabs.map((tab, index) => {\n const ids = getIds(id, index);\n const isActive = index === activeIndex;\n return (\n <View\n key={getTabId(tab) ?? index}\n id={ids.panel}\n role=\"tabpanel\"\n aria-labelledby={renderTab ? undefined : ids.trigger}\n display={isActive ? undefined : 'none'}\n tabIndex={isActive ? 0 : -1}\n >\n {tab.content}\n </View>\n );\n })\n ) : (\n <View\n id={activeIds.panel}\n role=\"tabpanel\"\n aria-labelledby={renderTab ? undefined : activeIds.trigger}\n tabIndex={0}\n >\n {renderContent ? renderContent(activeTab) : activeTab.content}\n </View>\n )}\n </View>\n </Vertical>\n );\n};\n\n// Context for compound components\nexport const TabsContext = createContext<TabsContextType | null>(null);\n\n// Hook to use the Tabs context\nexport const useTabsContext = () => {\n const context = useContext(TabsContext);\n if (!context) {\n throw new Error('useTabsContext must be used within a Tabs component');\n }\n return context;\n};\n\n// TabsList compound component\nexport const TabsList: React.FC<TabsListProps> = React.memo(\n ({ children, views, 'aria-label': label, 'aria-labelledby': labelledBy }) => {\n const { themeMode } = useTheme();\n const {\n variant = 'underline',\n views: rootViews,\n themeViews,\n } = useTabsContext();\n const variantStyles = getTabsVariantStyles(\n variant,\n themeMode,\n Boolean(themeViews)\n );\n const designSystemTabs = useDesignSystemComponentProps('tabs');\n const mergedViews = themeViews\n ? mergeDesignSystemViews(\n { container: themeViews.headerTabs },\n { container: variantStyles.header },\n { container: rootViews?.headerTabs },\n views\n )\n : deepMerge(\n {\n container: designSystemTabs.views?.headerTabs,\n },\n views\n );\n\n return (\n <Horizontal\n alignItems=\"center\"\n {...variantStyles.header}\n {...mergedViews?.container}\n role=\"tablist\"\n aria-label={label ?? mergedViews?.container?.['aria-label']}\n aria-labelledby={\n labelledBy ?? mergedViews?.container?.['aria-labelledby']\n }\n onKeyDown={(event: React.KeyboardEvent<HTMLElement>) => {\n mergedViews?.container?.onKeyDown?.(event);\n handleListKeyDown(event);\n }}\n >\n {children}\n </Horizontal>\n );\n }\n);\n\n// TabsTrigger compound component\nexport const TabsTrigger: React.FC<TabsTriggerProps> = React.memo(\n ({ value, children, disabled = false, views }) => {\n const { themeMode } = useTheme();\n const {\n id,\n activeValue,\n setActiveValue,\n variant = 'underline',\n views: rootViews,\n themeViews,\n } = useTabsContext();\n const isActive = activeValue === value;\n const ids = getIds(id, value);\n const variantStyles = getTabsVariantStyles(\n variant,\n themeMode,\n Boolean(themeViews)\n );\n const designSystemTabs = useDesignSystemComponentProps('tabs');\n const mergedViews = deepMerge(\n {\n trigger: designSystemTabs.views?.tab,\n activeState: designSystemTabs.views?.activeTab,\n },\n views\n );\n const hover = disabled\n ? {}\n : variant === 'underline'\n ? { color: 'theme-primary' }\n : { opacity: 0.9 };\n const standardStyles =\n themeViews &&\n resolveTabStyles(\n { ...variantStyles, tab: { ...variantStyles.tab, _hover: hover } },\n isActive,\n mergeDesignSystemViews(rootViews, {\n tab: views?.trigger,\n activeTab: views?.activeState,\n }),\n themeViews\n );\n\n const handleClick = useCallback(() => {\n if (!disabled) {\n setActiveValue(value);\n }\n }, [disabled, value, setActiveValue]);\n\n return (\n <View\n cursor={disabled ? 'not-allowed' : 'pointer'}\n opacity={disabled ? 0.6 : 1}\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n transition=\"all 0.2s ease-in-out\"\n onClick={handleClick}\n {...(standardStyles\n ? standardStyles.tab\n : {\n ...variantStyles.tab,\n ...(isActive ? variantStyles.activeTab : {}),\n _hover: hover,\n ...mergedViews?.trigger,\n ...(isActive ? mergedViews?.activeState : {}),\n })}\n id={ids.trigger}\n role=\"tab\"\n aria-selected={isActive}\n aria-disabled={disabled || undefined}\n aria-controls={isActive ? ids.panel : undefined}\n tabIndex={!disabled && (isActive || activeValue === null) ? 0 : -1}\n >\n <View\n {...(standardStyles\n ? standardStyles.title\n : {\n ...variantStyles.text,\n ...(isActive ? variantStyles.activeText : {}),\n })}\n >\n {children}\n </View>\n </View>\n );\n }\n);\n\n// TabsContent compound component\nexport const TabsContent: React.FC<TabsContentProps> = React.memo(\n ({ value, children, views }) => {\n const { id, activeValue, views: rootViews, themeViews } = useTabsContext();\n\n if (activeValue !== value) {\n return null;\n }\n\n const ids = getIds(id, value);\n return (\n <View\n width=\"100%\"\n padding=\"24px\"\n {...(themeViews\n ? mergeDesignSystemViews(\n { content: themeViews.content },\n { content: rootViews?.content },\n views\n ).content\n : views?.content)}\n id={ids.panel}\n role=\"tabpanel\"\n aria-labelledby={ids.trigger}\n tabIndex={0}\n >\n {children}\n </View>\n );\n }\n);\n",
|
|
80
85
|
"type": "registry:ui"
|
|
81
86
|
}
|
|
82
87
|
]
|