@app-studio/components 0.12.0 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/select.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",
|
|
@@ -21,15 +27,12 @@
|
|
|
21
27
|
],
|
|
22
28
|
"dependencies": {
|
|
23
29
|
"web": [
|
|
24
|
-
"@app-studio/components@0.11.13",
|
|
25
30
|
"lucide-react@^0.562.0"
|
|
26
31
|
],
|
|
27
32
|
"ios": [
|
|
28
|
-
"@app-studio/components@0.11.13",
|
|
29
33
|
"react-native-svg@>= 13"
|
|
30
34
|
],
|
|
31
35
|
"android": [
|
|
32
|
-
"@app-studio/components@0.11.13",
|
|
33
36
|
"react-native-svg@>= 13"
|
|
34
37
|
]
|
|
35
38
|
},
|
|
@@ -69,7 +72,7 @@
|
|
|
69
72
|
},
|
|
70
73
|
{
|
|
71
74
|
"path": "src/components/ActionSheet/ActionSheet/ActionSheet.view.native.tsx",
|
|
72
|
-
"content": "import React from 'react';\nimport {\n Keyboard,\n KeyboardAvoidingView,\n KeyboardEvent,\n Modal as RNModal,\n Platform,\n ScrollView,\n TouchableWithoutFeedback,\n useWindowDimensions,\n} from 'react-native';\nimport { Horizontal, Text, Vertical, View } from 'app-studio';\nimport { TickIcon } from '../../Icon/FixedIcons';\nimport { ActionSheetViewProps } from './ActionSheet.props';\nimport { ActionSheetItem } from './ActionSheet.type';\nimport {\n actionSheetShadow,\n ActionSheetItemSizes,\n ActionSheetTextSizes,\n} from './ActionSheet.style';\n\nconst getItemKey = (item: ActionSheetItem, index: number) =>\n item.id ?? item.value ?? `action-sheet-item-${index}`;\n\nconst getItemValue = (item: ActionSheetItem) => item.value ?? item.id;\n\nconst isItemDisabled = (item: ActionSheetItem) =>\n item.disabled || item.isDisabled || item.divider;\n\nconst isItemSelected = (\n item: ActionSheetItem,\n selectedValue: string | string[]\n) => {\n if (typeof item.selected === 'boolean') return item.selected;\n const itemValue = getItemValue(item);\n if (!itemValue) return false;\n if (Array.isArray(selectedValue)) return selectedValue.includes(itemValue);\n return selectedValue === itemValue;\n};\n\nconst resolveMaxHeight = (\n maxHeight: number | string | undefined,\n windowHeight: number\n) => {\n if (typeof maxHeight === 'number') return maxHeight;\n if (typeof maxHeight === 'string') {\n const trimmed = maxHeight.trim();\n if (trimmed.endsWith('%')) {\n const ratio = parseFloat(trimmed) / 100;\n if (!Number.isNaN(ratio)) return Math.round(windowHeight * ratio);\n }\n const parsed = parseFloat(trimmed.replace('px', ''));\n if (!Number.isNaN(parsed)) return parsed;\n }\n return Math.round(windowHeight * 0.88);\n};\n\nconst ActionSheetView: React.FC<ActionSheetViewProps> = ({\n isSheetOpen,\n closeSheet,\n selectedValue,\n setSelectedValue,\n isClosePrevented = false,\n dismissOnBackdropPress = true,\n title,\n description,\n header,\n children,\n items = [],\n isMulti = false,\n closeOnSelect,\n onSelect,\n onChange,\n showCancel = false,\n cancelLabel = 'Cancel',\n onCancel,\n showHandle = true,\n size = 'md',\n maxHeight,\n animationType = 'slide',\n views,\n ...props\n}) => {\n const { height: windowHeight } = useWindowDimensions();\n const [keyboardHeight, setKeyboardHeight] = React.useState(0);\n\n React.useEffect(() => {\n if (!isSheetOpen) {\n setKeyboardHeight(0);\n return;\n }\n\n const handleKeyboardShow = (event: KeyboardEvent) => {\n const screenY = event.endCoordinates?.screenY;\n const eventHeight = event.endCoordinates?.height ?? 0;\n const nextHeight =\n typeof screenY === 'number' && screenY > 0 && screenY < windowHeight\n ? windowHeight - screenY\n : eventHeight;\n\n setKeyboardHeight(Math.max(0, nextHeight));\n };\n\n const handleKeyboardHide = () => setKeyboardHeight(0);\n\n const showSub = Keyboard.addListener(\n Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow',\n handleKeyboardShow\n );\n const hideSub = Keyboard.addListener(\n Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide',\n handleKeyboardHide\n );\n\n return () => {\n showSub.remove();\n hideSub.remove();\n };\n }, [isSheetOpen, windowHeight]);\n\n const baseMaxHeight = resolveMaxHeight(maxHeight, windowHeight);\n const keyboardGap = keyboardHeight > 0 ? 12 : 0;\n const visibleMaxHeight =\n keyboardHeight > 0\n ? Math.max(220, windowHeight - keyboardHeight - keyboardGap)\n : windowHeight;\n const resolvedMaxHeight = Math.min(baseMaxHeight, visibleMaxHeight);\n\n const handleClose = () => {\n if (!isClosePrevented) closeSheet();\n };\n\n const handleBackdropPress = () => {\n if (dismissOnBackdropPress) handleClose();\n };\n\n const handleCancel = () => {\n onCancel?.();\n handleClose();\n };\n\n const handleItemPress = (item: ActionSheetItem) => {\n if (isItemDisabled(item)) return;\n\n const itemValue = getItemValue(item);\n let nextValue = selectedValue;\n\n if (itemValue) {\n if (isMulti) {\n const currentValue = Array.isArray(selectedValue)\n ? selectedValue\n : selectedValue\n ? [selectedValue]\n : [];\n nextValue = currentValue.includes(itemValue)\n ? currentValue.filter((value) => value !== itemValue)\n : [...currentValue, itemValue];\n } else {\n nextValue = itemValue;\n }\n\n setSelectedValue(nextValue);\n onSelect?.(itemValue, item);\n onChange?.(nextValue, item);\n }\n\n item.onPress?.(item);\n\n const shouldClose = item.closeOnSelect ?? closeOnSelect ?? !isMulti;\n if (shouldClose) handleClose();\n };\n\n return (\n <RNModal\n visible={isSheetOpen}\n transparent\n animationType={animationType}\n onRequestClose={handleClose}\n >\n <TouchableWithoutFeedback onPress={handleBackdropPress}>\n <View flex={1} backgroundColor=\"color-dark-50-360\" {...views?.overlay}>\n <KeyboardAvoidingView\n behavior={Platform.OS === 'ios' ? 'padding' : 'height'}\n keyboardVerticalOffset={0}\n style={{ flex: 1, justifyContent: 'flex-end' }}\n >\n <TouchableWithoutFeedback>\n <Vertical\n width=\"100%\"\n maxHeight={resolvedMaxHeight as any}\n backgroundColor=\"color-white\"\n borderTopLeftRadius={24}\n borderTopRightRadius={24}\n paddingTop={8}\n paddingBottom={Platform.OS === 'ios' ? 18 : 12}\n overflow=\"hidden\"\n style={actionSheetShadow as any}\n {...views?.container}\n {...views?.sheet}\n {...props}\n >\n {showHandle && (\n <View\n width={36}\n height={4}\n borderRadius={999}\n backgroundColor=\"color-gray-300\"\n alignSelf=\"center\"\n marginTop={4}\n marginBottom={8}\n {...views?.handle}\n />\n )}\n\n {(title || description) && (\n <Vertical\n paddingHorizontal={20}\n paddingTop={6}\n paddingBottom={12}\n gap={4}\n {...views?.header}\n >\n {title && (\n <Text\n fontSize={18}\n lineHeight={24}\n fontWeight=\"600\"\n color=\"color-gray-900\"\n {...views?.title}\n >\n {title}\n </Text>\n )}\n {description && (\n <Text\n fontSize={13}\n lineHeight={18}\n color=\"color-gray-500\"\n {...views?.description}\n >\n {description}\n </Text>\n )}\n </Vertical>\n )}\n\n {header}\n\n <ScrollView\n keyboardShouldPersistTaps=\"handled\"\n showsVerticalScrollIndicator={false}\n contentContainerStyle={{ paddingBottom: 4 }}\n >\n <Vertical {...views?.content}>\n {items.map((item, index) => {\n if (item.divider) {\n return (\n <View\n key={getItemKey(item, index)}\n height={1}\n backgroundColor=\"color-gray-200\"\n marginVertical={6}\n {...views?.divider}\n />\n );\n }\n\n const selected = isItemSelected(item, selectedValue);\n const disabled = isItemDisabled(item);\n const textColor = disabled\n ? 'color-gray-400'\n : item.destructive\n ? 'color-red-600'\n : selected\n ? 'theme-primary'\n : 'color-gray-900';\n\n return (\n <Horizontal\n key={getItemKey(item, index)}\n alignItems=\"center\"\n gap={12}\n opacity={disabled ? 0.5 : 1}\n onPress={() => handleItemPress(item)}\n onClick={() => handleItemPress(item)}\n {...ActionSheetItemSizes[size]}\n {...views?.item}\n >\n {item.icon && (\n <View flexShrink={0} {...views?.itemIcon}>\n {item.icon}\n </View>\n )}\n <Vertical flex={1} gap={2}>\n {typeof item.label === 'string' ? (\n <Text\n fontSize={ActionSheetTextSizes[size].label}\n lineHeight={\n ActionSheetTextSizes[size].label + 6\n }\n fontWeight={selected ? '600' : '400'}\n color={textColor}\n {...views?.itemLabel}\n >\n {item.label}\n </Text>\n ) : (\n item.label\n )}\n {item.description && (\n <Text\n fontSize={\n ActionSheetTextSizes[size].description\n }\n lineHeight={\n ActionSheetTextSizes[size].description + 5\n }\n color=\"color-gray-500\"\n {...views?.itemDescription}\n >\n {item.description}\n </Text>\n )}\n </Vertical>\n {selected && (\n <TickIcon\n widthHeight={18}\n color=\"theme-primary\"\n {...views?.itemIndicator}\n />\n )}\n </Horizontal>\n );\n })}\n {children}\n </Vertical>\n </ScrollView>\n\n {showCancel && (\n <View\n marginTop={8}\n paddingHorizontal={12}\n paddingTop={8}\n borderTopWidth={1}\n borderTopColor=\"color-gray-200\"\n >\n <Horizontal\n minHeight={52}\n alignItems=\"center\"\n justifyContent=\"center\"\n borderRadius={14}\n backgroundColor=\"color-gray-100\"\n onPress={handleCancel}\n onClick={handleCancel}\n {...views?.cancelButton}\n >\n <Text\n fontSize={ActionSheetTextSizes[size].label}\n lineHeight={ActionSheetTextSizes[size].label + 6}\n fontWeight=\"600\"\n color=\"color-gray-900\"\n {...views?.cancelLabel}\n >\n {cancelLabel}\n </Text>\n </Horizontal>\n </View>\n )}\n </Vertical>\n </TouchableWithoutFeedback>\n </KeyboardAvoidingView>\n </View>\n </TouchableWithoutFeedback>\n </RNModal>\n );\n};\n\nexport default ActionSheetView;\n",
|
|
75
|
+
"content": "import React from 'react';\nimport {\n Keyboard,\n KeyboardAvoidingView,\n KeyboardEvent,\n Modal as RNModal,\n Platform,\n ScrollView,\n TouchableWithoutFeedback,\n useWindowDimensions,\n type AccessibilityProps,\n} from 'react-native';\nimport { Horizontal, Text, Vertical, View } from 'app-studio';\nimport { TickIcon } from '../../Icon/FixedIcons';\nimport { ActionSheetViewProps } from './ActionSheet.props';\nimport { ActionSheetItem } from './ActionSheet.type';\nimport {\n actionSheetShadow,\n ActionSheetItemSizes,\n ActionSheetTextSizes,\n} from './ActionSheet.style';\n\nconst modalAccessibility: AccessibilityProps = {\n accessibilityViewIsModal: true,\n};\n\nconst getItemKey = (item: ActionSheetItem, index: number) =>\n item.id ?? item.value ?? `action-sheet-item-${index}`;\n\nconst getItemValue = (item: ActionSheetItem) => item.value ?? item.id;\n\nconst isItemDisabled = (item: ActionSheetItem) =>\n item.disabled || item.isDisabled || item.divider;\n\nconst isItemSelected = (\n item: ActionSheetItem,\n selectedValue: string | string[]\n) => {\n if (typeof item.selected === 'boolean') return item.selected;\n const itemValue = getItemValue(item);\n if (!itemValue) return false;\n if (Array.isArray(selectedValue)) return selectedValue.includes(itemValue);\n return selectedValue === itemValue;\n};\n\nconst resolveMaxHeight = (\n maxHeight: number | string | undefined,\n windowHeight: number\n) => {\n if (typeof maxHeight === 'number') return maxHeight;\n if (typeof maxHeight === 'string') {\n const trimmed = maxHeight.trim();\n if (trimmed.endsWith('%')) {\n const ratio = parseFloat(trimmed) / 100;\n if (!Number.isNaN(ratio)) return Math.round(windowHeight * ratio);\n }\n const parsed = parseFloat(trimmed.replace('px', ''));\n if (!Number.isNaN(parsed)) return parsed;\n }\n return Math.round(windowHeight * 0.88);\n};\n\nconst ActionSheetView: React.FC<ActionSheetViewProps> = ({\n isSheetOpen,\n closeSheet,\n selectedValue,\n setSelectedValue,\n isClosePrevented = false,\n dismissOnBackdropPress = true,\n title,\n description,\n header,\n children,\n items = [],\n isMulti = false,\n closeOnSelect,\n onSelect,\n onChange,\n showCancel = false,\n cancelLabel = 'Cancel',\n onCancel,\n showHandle = true,\n size = 'md',\n maxHeight,\n animationType = 'slide',\n views,\n ...props\n}) => {\n const { height: windowHeight } = useWindowDimensions();\n const [keyboardHeight, setKeyboardHeight] = React.useState(0);\n\n React.useEffect(() => {\n if (!isSheetOpen) {\n setKeyboardHeight(0);\n return;\n }\n\n const handleKeyboardShow = (event: KeyboardEvent) => {\n const screenY = event.endCoordinates?.screenY;\n const eventHeight = event.endCoordinates?.height ?? 0;\n const nextHeight =\n typeof screenY === 'number' && screenY > 0 && screenY < windowHeight\n ? windowHeight - screenY\n : eventHeight;\n\n setKeyboardHeight(Math.max(0, nextHeight));\n };\n\n const handleKeyboardHide = () => setKeyboardHeight(0);\n\n const showSub = Keyboard.addListener(\n Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow',\n handleKeyboardShow\n );\n const hideSub = Keyboard.addListener(\n Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide',\n handleKeyboardHide\n );\n\n return () => {\n showSub.remove();\n hideSub.remove();\n };\n }, [isSheetOpen, windowHeight]);\n\n const baseMaxHeight = resolveMaxHeight(maxHeight, windowHeight);\n const keyboardGap = keyboardHeight > 0 ? 12 : 0;\n const visibleMaxHeight =\n keyboardHeight > 0\n ? Math.max(220, windowHeight - keyboardHeight - keyboardGap)\n : windowHeight;\n const resolvedMaxHeight = Math.min(baseMaxHeight, visibleMaxHeight);\n\n const handleClose = () => {\n if (!isClosePrevented) closeSheet();\n };\n\n const handleBackdropPress = () => {\n if (dismissOnBackdropPress) handleClose();\n };\n\n const handleCancel = () => {\n onCancel?.();\n handleClose();\n };\n\n const handleItemPress = (item: ActionSheetItem) => {\n if (isItemDisabled(item)) return;\n\n const itemValue = getItemValue(item);\n let nextValue = selectedValue;\n\n if (itemValue) {\n if (isMulti) {\n const currentValue = Array.isArray(selectedValue)\n ? selectedValue\n : selectedValue\n ? [selectedValue]\n : [];\n nextValue = currentValue.includes(itemValue)\n ? currentValue.filter((value) => value !== itemValue)\n : [...currentValue, itemValue];\n } else {\n nextValue = itemValue;\n }\n\n setSelectedValue(nextValue);\n onSelect?.(itemValue, item);\n onChange?.(nextValue, item);\n }\n\n item.onPress?.(item);\n\n const shouldClose = item.closeOnSelect ?? closeOnSelect ?? !isMulti;\n if (shouldClose) handleClose();\n };\n\n return (\n <RNModal\n visible={isSheetOpen}\n transparent\n animationType={animationType}\n onRequestClose={handleClose}\n >\n <TouchableWithoutFeedback\n accessible={false}\n onPress={handleBackdropPress}\n >\n <View flex={1} backgroundColor=\"color-dark-50-360\" {...views?.overlay}>\n <KeyboardAvoidingView\n behavior={Platform.OS === 'ios' ? 'padding' : 'height'}\n keyboardVerticalOffset={0}\n style={{ flex: 1, justifyContent: 'flex-end' }}\n >\n <TouchableWithoutFeedback accessible={false}>\n <Vertical\n {...modalAccessibility}\n width=\"100%\"\n maxHeight={resolvedMaxHeight as any}\n backgroundColor=\"color-white\"\n borderTopLeftRadius={24}\n borderTopRightRadius={24}\n paddingTop={8}\n paddingBottom={Platform.OS === 'ios' ? 18 : 12}\n overflow=\"hidden\"\n style={actionSheetShadow as any}\n {...views?.container}\n {...views?.sheet}\n {...props}\n >\n {showHandle && (\n <View\n width={36}\n height={4}\n borderRadius={999}\n backgroundColor=\"color-gray-300\"\n alignSelf=\"center\"\n marginTop={4}\n marginBottom={8}\n {...views?.handle}\n />\n )}\n\n {(title || description) && (\n <Vertical\n paddingHorizontal={20}\n paddingTop={6}\n paddingBottom={12}\n gap={4}\n {...views?.header}\n >\n {title && (\n <Text\n fontSize={18}\n lineHeight={24}\n fontWeight=\"600\"\n color=\"color-gray-900\"\n {...views?.title}\n >\n {title}\n </Text>\n )}\n {description && (\n <Text\n fontSize={13}\n lineHeight={18}\n color=\"color-gray-500\"\n {...views?.description}\n >\n {description}\n </Text>\n )}\n </Vertical>\n )}\n\n {header}\n\n <ScrollView\n keyboardShouldPersistTaps=\"handled\"\n showsVerticalScrollIndicator={false}\n contentContainerStyle={{ paddingBottom: 4 }}\n >\n <Vertical {...views?.content}>\n {items.map((item, index) => {\n if (item.divider) {\n return (\n <View\n key={getItemKey(item, index)}\n height={1}\n backgroundColor=\"color-gray-200\"\n marginVertical={6}\n {...views?.divider}\n />\n );\n }\n\n const selected = isItemSelected(item, selectedValue);\n const disabled = isItemDisabled(item);\n const textColor = disabled\n ? 'color-gray-400'\n : item.destructive\n ? 'color-red-600'\n : selected\n ? 'theme-primary'\n : 'color-gray-900';\n\n return (\n <Horizontal\n key={getItemKey(item, index)}\n alignItems=\"center\"\n gap={12}\n accessible\n accessibilityRole=\"button\"\n accessibilityLabel={\n typeof item.label === 'string'\n ? item.label\n : undefined\n }\n accessibilityState={{\n selected,\n disabled: Boolean(disabled),\n }}\n opacity={disabled ? 0.5 : 1}\n onPress={\n disabled ? undefined : () => handleItemPress(item)\n }\n {...ActionSheetItemSizes[size]}\n {...views?.item}\n >\n {item.icon && (\n <View flexShrink={0} {...views?.itemIcon}>\n {item.icon}\n </View>\n )}\n <Vertical flex={1} gap={2}>\n {typeof item.label === 'string' ? (\n <Text\n fontSize={ActionSheetTextSizes[size].label}\n lineHeight={\n ActionSheetTextSizes[size].label + 6\n }\n fontWeight={selected ? '600' : '400'}\n color={textColor}\n {...views?.itemLabel}\n >\n {item.label}\n </Text>\n ) : (\n item.label\n )}\n {item.description && (\n <Text\n fontSize={\n ActionSheetTextSizes[size].description\n }\n lineHeight={\n ActionSheetTextSizes[size].description + 5\n }\n color=\"color-gray-500\"\n {...views?.itemDescription}\n >\n {item.description}\n </Text>\n )}\n </Vertical>\n {selected && (\n <TickIcon\n widthHeight={18}\n color=\"theme-primary\"\n {...views?.itemIndicator}\n />\n )}\n </Horizontal>\n );\n })}\n {children}\n </Vertical>\n </ScrollView>\n\n {showCancel && (\n <View\n marginTop={8}\n paddingHorizontal={12}\n paddingTop={8}\n borderTopWidth={1}\n borderTopColor=\"color-gray-200\"\n >\n <Horizontal\n minHeight={52}\n alignItems=\"center\"\n justifyContent=\"center\"\n borderRadius={14}\n backgroundColor=\"color-gray-100\"\n accessible\n accessibilityRole=\"button\"\n onPress={handleCancel}\n {...views?.cancelButton}\n >\n <Text\n fontSize={ActionSheetTextSizes[size].label}\n lineHeight={ActionSheetTextSizes[size].label + 6}\n fontWeight=\"600\"\n color=\"color-gray-900\"\n {...views?.cancelLabel}\n >\n {cancelLabel}\n </Text>\n </Horizontal>\n </View>\n )}\n </Vertical>\n </TouchableWithoutFeedback>\n </KeyboardAvoidingView>\n </View>\n </TouchableWithoutFeedback>\n </RNModal>\n );\n};\n\nexport default ActionSheetView;\n",
|
|
73
76
|
"type": "registry:ui"
|
|
74
77
|
},
|
|
75
78
|
{
|
|
@@ -104,12 +107,12 @@
|
|
|
104
107
|
},
|
|
105
108
|
{
|
|
106
109
|
"path": "src/components/Form/Select/Select.tsx",
|
|
107
|
-
"content": "import React from 'react';\nimport { SelectProps } from './Select/Select.props';\nimport { useSelectState } from './Select/Select.state';\nimport SelectView from './Select/Select.view';\nimport {
|
|
110
|
+
"content": "import React from 'react';\nimport { SelectProps } from './Select/Select.props';\nimport { useSelectState } from './Select/Select.state';\nimport SelectView from './Select/Select.view';\nimport { useFieldDesignSystemProps } from '../../Input/useFieldDesignSystemProps';\n\n// Defines a functional component named 'SelectComponent', which is expected to receive 'SelectProps' as properties.\nconst SelectComponent: React.FC<SelectProps> = (props) => {\n const { props: mergedProps, themeContainer } = useFieldDesignSystemProps(\n 'select',\n props\n );\n // Ensure options is always an array\n const safeProps = {\n ...mergedProps,\n options: mergedProps.options || [],\n };\n\n // Invokes the 'useSelectState' hook with props to obtain stateful logic for the Select component.\n const selectStates = useSelectState(safeProps);\n\n // Renders the 'SelectView' component, passing along any states controlled by 'useSelectState' and all properties passed to 'SelectComponent'.\n return (\n <SelectView\n {...selectStates}\n {...safeProps}\n themeContainer={themeContainer}\n // Restated after the props spread: `safeProps` now carries `value`, and\n // in uncontrolled mode that is `undefined` — letting it through would\n // blank out the selection the state hook just resolved.\n value={selectStates.value}\n onClick={(e: React.MouseEvent<HTMLDivElement>) => {\n // Stop propagation to prevent the global click handler from closing other dropdowns\n e.stopPropagation();\n if (mergedProps.onClick) mergedProps.onClick(e);\n }}\n />\n );\n};\n\n// Exports 'SelectComponent' as 'Select', making it available for import in other parts of the application.\nexport const Select = SelectComponent;\n",
|
|
108
111
|
"type": "registry:ui"
|
|
109
112
|
},
|
|
110
113
|
{
|
|
111
114
|
"path": "src/components/Form/Select/Select/Select.props.ts",
|
|
112
|
-
"content": "import { Elevation } from '../../../../utils/elevation';\nimport { InputProps, Shadow, ViewProps } from 'app-studio';\nimport { SelectStyles, Shape, Size, Variant, Option } from './Select.type';\n// Defines the interface for Select component properties, extending from InputProps but omitting 'size'.\n// `value`/`defaultValue` are re-declared rather than inherited: `InputProps`\n// types them after `HTMLInputElement`, where both are plain strings, and a\n// multi-select has to be able to carry an array.\nexport interface SelectProps\n extends Omit<\n InputProps,\n 'size' | 'shadow' | 'value' | 'defaultValue' | 'onChange'\n > {\n // Optional string identifier for the select element\n id?: string;\n // Flag to indicate if the select has an error state\n error?: boolean;\n // Name attribute for the select element, useful for form submission\n name?: string;\n // Label text associated with the select element\n label?: string;\n // Helper text that appears below the select box\n helperText?: string;\n // Placeholder text shown when the select is empty\n placeholder?: string;\n // Array of options that the user can choose from\n options: Option[];\n // Selected option value(s). Supplying it puts the select in controlled mode:\n // the displayed selection follows this prop and never moves on its own — the\n // component reports every change through `onChange` and waits for the parent\n // to pass the next value back down.\n value?: string | Array<string>;\n // Initial selection for uncontrolled use. Read once, on mount; ignored\n // entirely when `value` is supplied.\n defaultValue?: string | Array<string>;\n // Boolean to allow multi-selection\n isMulti?: boolean;\n // Boolean to set the select as read-only, preventing user modification\n isReadOnly?: boolean;\n // Boolean to disable the select element\n isDisabled?: boolean;\n // Boolean indicating the field is required for form submission\n isRequired?: boolean;\n // Boolean to autofocus the select when it mounts\n isAutoFocus?: boolean;\n /**\n * Called with the next selection whenever it changes: the chosen option's\n * value for a single select, the full array of selected values when\n * `isMulti`. It has to be the *next* selection rather than the option that\n * was just touched, otherwise a controlled parent has nothing to store.\n *\n * It is always the **value**, never the DOM event — `e.target.value` is a\n * compile error. The parameter is typed rather than left `any` so a\n * DOM-shaped handler fails to build instead of failing silently at runtime.\n *\n * Declared with method syntax on purpose. Method parameters are compared\n * bivariantly, so a single-select caller can still pass a plain\n * `(value: string) => void` (arrays only ever occur when `isMulti`) while a\n * `(e: ChangeEvent) => void` stays rejected — an event is unrelated to\n * `string | string[]` in both directions. Writing this as a property would\n * force every single-select consumer to narrow a union that their Select\n * can never produce.\n */\n onChange?(value: string | string[]): void;\n // Determines the overall shape of the select box, e.g., rounded or square edges\n shape?: Shape;\n // Defines the styling variant for the select component\n variant?: Variant;\n // Custom styles that can be applied to the select component\n views?: SelectStyles;\n // Defines the size of the component\n size?: Size;\n // Determines the shadow property of the select component\n shadow?: Shadow | Elevation | ViewProps;\n // Boolean to control whether the select options are scrollable\n isScrollable?: boolean;\n}\nexport interface SelectViewProps extends SelectProps {\n value: string | Array<string>;\n setValue: (value: string | string[]) => void;\n hide: boolean;\n setHide: (hide: boolean) => void;\n isHovered: boolean;\n setIsHovered: (hovered: boolean) => void;\n isFocused: boolean;\n setIsFocused: (focused: boolean) => void;\n highlightedIndex?: number;\n setHighlightedIndex?: (index: number) => void;\n}\nexport interface SelectBoxProps {\n options: Option[];\n value?: string | Array<string>;\n isDisabled?: boolean;\n placeholder?: string;\n removeOption?: (value: string) => void;\n views?: SelectStyles;\n size?: Size;\n}\nexport interface MultiSelectProps extends Omit<InputProps, 'size'> {\n option: string;\n removeOption: (value: string) => void;\n size?: Size;\n}\nexport interface ItemProps extends Omit<InputProps, 'size' | 'style'> {\n callback?: (option: string) => void;\n option: Option;\n size?: Size;\n style?: ViewProps;\n isHovered?: boolean;\n setIsHovered?: (hovered: boolean) => void;\n}\nexport interface HiddenSelectProps\n extends Omit<InputProps, 'size' | 'value' | 'onChange'> {\n id?: string;\n name?: string;\n value: string | Array<string>;\n isMulti?: boolean;\n isReadOnly?: boolean;\n isDisabled?: boolean;\n // Receives the same value-first argument as SelectProps.onChange — the\n // hidden <select> normalises its DOM event before forwarding.\n onChange?(value: string | string[]): void;\n options: Option[];\n}\nexport interface DropDownProps extends Omit<InputProps, 'size'> {\n size?: Size;\n callback?: (option: string) => void;\n options: Option[];\n views?: SelectStyles;\n highlightedIndex?: number;\n setHighlightedIndex?: (index: number) => void;\n}\n",
|
|
115
|
+
"content": "import { Elevation } from '../../../../utils/elevation';\nimport { InputProps, Shadow, ViewProps } from 'app-studio';\nimport { SelectStyles, Shape, Size, Variant, Option } from './Select.type';\n// Defines the interface for Select component properties, extending from InputProps but omitting 'size'.\n// `value`/`defaultValue` are re-declared rather than inherited: `InputProps`\n// types them after `HTMLInputElement`, where both are plain strings, and a\n// multi-select has to be able to carry an array.\nexport interface SelectProps\n extends Omit<\n InputProps,\n 'size' | 'shadow' | 'value' | 'defaultValue' | 'onChange'\n > {\n // Optional string identifier for the select element\n id?: string;\n // Flag to indicate if the select has an error state\n error?: boolean;\n // Name attribute for the select element, useful for form submission\n name?: string;\n // Label text associated with the select element\n label?: string;\n // Helper text that appears below the select box\n helperText?: string;\n // Placeholder text shown when the select is empty\n placeholder?: string;\n // Array of options that the user can choose from\n options: Option[];\n // Selected option value(s). Supplying it puts the select in controlled mode:\n // the displayed selection follows this prop and never moves on its own — the\n // component reports every change through `onChange` and waits for the parent\n // to pass the next value back down.\n value?: string | Array<string>;\n // Initial selection for uncontrolled use. Read once, on mount; ignored\n // entirely when `value` is supplied.\n defaultValue?: string | Array<string>;\n // Boolean to allow multi-selection\n isMulti?: boolean;\n // Boolean to set the select as read-only, preventing user modification\n isReadOnly?: boolean;\n // Boolean to disable the select element\n isDisabled?: boolean;\n // Boolean indicating the field is required for form submission\n isRequired?: boolean;\n // Boolean to autofocus the select when it mounts\n isAutoFocus?: boolean;\n /**\n * Called with the next selection whenever it changes: the chosen option's\n * value for a single select, the full array of selected values when\n * `isMulti`. It has to be the *next* selection rather than the option that\n * was just touched, otherwise a controlled parent has nothing to store.\n *\n * It is always the **value**, never the DOM event — `e.target.value` is a\n * compile error. The parameter is typed rather than left `any` so a\n * DOM-shaped handler fails to build instead of failing silently at runtime.\n *\n * Declared with method syntax on purpose. Method parameters are compared\n * bivariantly, so a single-select caller can still pass a plain\n * `(value: string) => void` (arrays only ever occur when `isMulti`) while a\n * `(e: ChangeEvent) => void` stays rejected — an event is unrelated to\n * `string | string[]` in both directions. Writing this as a property would\n * force every single-select consumer to narrow a union that their Select\n * can never produce.\n */\n onChange?(value: string | string[]): void;\n // Determines the overall shape of the select box, e.g., rounded or square edges\n shape?: Shape;\n // Defines the styling variant for the select component\n variant?: Variant;\n // Custom styles that can be applied to the select component\n views?: SelectStyles;\n // Defines the size of the component\n size?: Size;\n // Determines the shadow property of the select component\n shadow?: Shadow | Elevation | ViewProps;\n // Boolean to control whether the select options are scrollable\n isScrollable?: boolean;\n}\nexport interface SelectViewProps extends SelectProps {\n themeContainer?: ViewProps;\n value: string | Array<string>;\n setValue: (value: string | string[]) => void;\n hide: boolean;\n setHide: (hide: boolean) => void;\n isHovered: boolean;\n setIsHovered: (hovered: boolean) => void;\n isFocused: boolean;\n setIsFocused: (focused: boolean) => void;\n highlightedIndex?: number;\n setHighlightedIndex?: (index: number) => void;\n}\nexport interface SelectBoxProps {\n options: Option[];\n value?: string | Array<string>;\n isDisabled?: boolean;\n placeholder?: string;\n removeOption?: (value: string) => void;\n views?: SelectStyles;\n size?: Size;\n}\nexport interface MultiSelectProps extends Omit<InputProps, 'size'> {\n option: string;\n removeOption: (value: string) => void;\n size?: Size;\n}\nexport interface ItemProps extends Omit<InputProps, 'size' | 'style'> {\n callback?: (option: string) => void;\n option: Option;\n size?: Size;\n style?: ViewProps;\n isHovered?: boolean;\n setIsHovered?: (hovered: boolean) => void;\n}\nexport interface HiddenSelectProps\n extends Omit<InputProps, 'size' | 'value' | 'onChange'> {\n id?: string;\n name?: string;\n value: string | Array<string>;\n isMulti?: boolean;\n isReadOnly?: boolean;\n isDisabled?: boolean;\n // Receives the same value-first argument as SelectProps.onChange — the\n // hidden <select> normalises its DOM event before forwarding.\n onChange?(value: string | string[]): void;\n options: Option[];\n}\nexport interface DropDownProps extends Omit<InputProps, 'size'> {\n size?: Size;\n callback?: (option: string) => void;\n options: Option[];\n views?: SelectStyles;\n highlightedIndex?: number;\n setHighlightedIndex?: (index: number) => void;\n}\n",
|
|
113
116
|
"type": "registry:ui"
|
|
114
117
|
},
|
|
115
118
|
{
|
|
@@ -129,12 +132,12 @@
|
|
|
129
132
|
},
|
|
130
133
|
{
|
|
131
134
|
"path": "src/components/Form/Select/Select/Select.view.native.tsx",
|
|
132
|
-
"content": "/**\n * Select View Component (React Native)\n *\n * RN counterpart of Select.view.tsx. There is no native <select> on RN, so\n * we simulate it with a pressable field that opens a React Native <Modal/>\n * containing a scrollable list of options. Drops web-only concepts:\n * - <select>/<option> HTML elements\n * - HiddenSelect (no need to keep an a11y twin on RN)\n * - Portal + getBoundingClientRect-based dropdown positioning\n * (position: fixed, window.innerHeight, etc.)\n * - document.addEventListener / closeAllSelects custom event\n * - cursor, hover transitions, chevron rotation transitions\n *\n * Native presentation uses the shared ActionSheet so selects, menus, and\n * pickers get the same bottom-sheet interaction model.\n */\n\nimport React from 'react';\nimport { Typography, Horizontal, Text, View } from 'app-studio';\nimport { ActionSheet } from '../../../ActionSheet/ActionSheet';\nimport { FieldContainer } from '../../../Input/FieldContainer/FieldContainer';\nimport { FieldContent } from '../../../Input/FieldContent/FieldContent';\nimport { FieldIcons } from '../../../Input/FieldIcons/FieldIcons';\nimport { FieldLabel } from '../../../Input/FieldLabel/FieldLabel';\nimport { FieldWrapper } from '../../../Input/FieldWrapper/FieldWrapper';\nimport { ChevronIcon, CloseIcon } from '../../../Icon/FixedIcons';\nimport {\n MultiSelectProps,\n SelectBoxProps,\n SelectViewProps,\n} from './Select.props';\nimport { IconSizes, optionStyles, chipStyles } from './Select.style';\n\nconst withoutFieldShellView = <T extends Record<string, any>>(views?: T): T => {\n if (!views) return {} as T;\n const { container, content, ...layoutViews } = views;\n return layoutViews as T;\n};\n\nconst fieldSizeStyles = {\n xs: { minHeight: 24, shellPaddingY: 6, shellPaddingX: 10 },\n sm: { minHeight: 32, shellPaddingY: 8, shellPaddingX: 10 },\n md: { minHeight: 40, shellPaddingY: 10, shellPaddingX: 12 },\n lg: { minHeight: 48, shellPaddingY: 12, shellPaddingX: 14 },\n xl: { minHeight: 56, shellPaddingY: 14, shellPaddingX: 16 },\n} as const;\n\nconst SelectBox: React.FC<SelectBoxProps> = ({\n size = 'md',\n views = { field: {}, text: {} },\n value,\n isDisabled,\n placeholder,\n removeOption = () => {},\n options,\n}) => {\n const fieldView = views?.field || {};\n const textView = views?.text || {};\n const fieldStyles = {\n width: '95%',\n paddingVertical: 4,\n fontSize: Typography.fontSizes[size],\n fontWeight: '400' as const,\n lineHeight: 20,\n color: isDisabled ? 'color-gray-400' : 'color-gray-900',\n ...fieldView,\n ...textView,\n };\n const option: any =\n options.length > 0 && options.find((option) => option.value === value);\n\n const isEmpty = value === '' || (Array.isArray(value) && value.length === 0);\n\n return (\n <Text {...fieldStyles}>\n {isEmpty && !!placeholder ? (\n placeholder\n ) : typeof value === 'string' ? (\n (option && option.label) ?? value\n ) : Array.isArray(value) && value.length > 0 ? (\n <Horizontal gap={6}>\n {value.map((opt) => (\n <MultiSelect key={opt} option={opt} removeOption={removeOption} />\n ))}\n </Horizontal>\n ) : (\n String(value ?? '')\n )}\n </Text>\n );\n};\n\nexport const MultiSelect: React.FC<MultiSelectProps> = ({\n option,\n size = 'md',\n removeOption = () => {},\n ...props\n}) => {\n const handlePress = () => removeOption(option);\n return (\n <Horizontal gap={6} alignItems=\"center\" {...chipStyles} {...props}>\n <Text\n fontSize={Typography.fontSizes[size]}\n fontWeight=\"500\"\n color=\"color-gray-700\"\n >\n {option}\n </Text>\n <View onPress={handlePress}>\n <CloseIcon color=\"color-gray-500\" widthHeight={IconSizes[size]} />\n </View>\n </Horizontal>\n );\n};\n\nconst SelectView: React.FC<SelectViewProps> = ({\n id,\n name,\n label,\n value,\n placeholder,\n helperText,\n hide = false,\n error = false,\n isMulti = false,\n isFocused = false,\n isHovered = false,\n isDisabled = false,\n isReadOnly = false,\n options = [],\n shadow = {},\n size = 'md',\n shape = 'default',\n variant = 'default',\n views = {\n text: {},\n icon: {},\n dropDown: {},\n selectBox: {},\n label: {},\n helperText: {},\n },\n onChange = () => {},\n setHide = () => {},\n setValue = () => {},\n setIsHovered = () => {},\n setIsFocused = () => {},\n setHighlightedIndex,\n highlightedIndex,\n isScrollable: _isScrollable,\n ...props\n}) => {\n const handlePressTrigger = () => {\n if (isDisabled || isReadOnly) return;\n const newHideState = !hide;\n setHide(newHideState);\n setIsFocused(!newHideState);\n };\n\n const handleSelect = (optionValue: string) => {\n // Mirrors the web view: `onChange` carries the next selection — the whole\n // array when `isMulti` — so a controlled parent can store what it gets.\n if (isMulti && Array.isArray(value)) {\n if (!value.includes(optionValue)) {\n const newValue = [...value, optionValue];\n setValue(newValue);\n if (onChange) onChange(newValue);\n }\n } else {\n setValue(optionValue);\n if (onChange) onChange(optionValue);\n }\n if (!isMulti) setHide(true);\n };\n\n const handleRemoveOption = (valueOption: string) => {\n if (Array.isArray(value) && value.includes(valueOption)) {\n const newValue = value.filter((option) => option !== valueOption);\n setValue(newValue);\n if (onChange) onChange(newValue);\n }\n };\n\n const isOptionSelected = (optionValue: string) => {\n if (Array.isArray(value)) return value.includes(optionValue);\n return value === optionValue;\n };\n\n const showLabel = !!label;\n const layoutViews = withoutFieldShellView(views);\n\n return (\n <FieldContainer\n width=\"100%\"\n
|
|
135
|
+
"content": "/**\n * Select View Component (React Native)\n *\n * RN counterpart of Select.view.tsx. There is no native <select> on RN, so\n * we simulate it with a pressable field that opens a React Native <Modal/>\n * containing a scrollable list of options. Drops web-only concepts:\n * - <select>/<option> HTML elements\n * - HiddenSelect (no need to keep an a11y twin on RN)\n * - Portal + getBoundingClientRect-based dropdown positioning\n * (position: fixed, window.innerHeight, etc.)\n * - document.addEventListener / closeAllSelects custom event\n * - cursor, hover transitions, chevron rotation transitions\n *\n * Native presentation uses the shared ActionSheet so selects, menus, and\n * pickers get the same bottom-sheet interaction model.\n */\n\nimport React from 'react';\nimport { Typography, Horizontal, Text, View } from 'app-studio';\nimport { ActionSheet } from '../../../ActionSheet/ActionSheet';\nimport { FieldContainer } from '../../../Input/FieldContainer/FieldContainer';\nimport { FieldContent } from '../../../Input/FieldContent/FieldContent';\nimport { FieldIcons } from '../../../Input/FieldIcons/FieldIcons';\nimport { FieldLabel } from '../../../Input/FieldLabel/FieldLabel';\nimport { FieldWrapper } from '../../../Input/FieldWrapper/FieldWrapper';\nimport { ChevronIcon, CloseIcon } from '../../../Icon/FixedIcons';\nimport {\n MultiSelectProps,\n SelectBoxProps,\n SelectViewProps,\n} from './Select.props';\nimport { IconSizes, optionStyles, chipStyles } from './Select.style';\n\nconst withoutFieldShellView = <T extends Record<string, any>>(views?: T): T => {\n if (!views) return {} as T;\n const { container, content, ...layoutViews } = views;\n return layoutViews as T;\n};\n\nconst fieldSizeStyles = {\n xs: { minHeight: 24, shellPaddingY: 6, shellPaddingX: 10 },\n sm: { minHeight: 32, shellPaddingY: 8, shellPaddingX: 10 },\n md: { minHeight: 40, shellPaddingY: 10, shellPaddingX: 12 },\n lg: { minHeight: 48, shellPaddingY: 12, shellPaddingX: 14 },\n xl: { minHeight: 56, shellPaddingY: 14, shellPaddingX: 16 },\n} as const;\n\nconst SelectBox: React.FC<SelectBoxProps> = ({\n size = 'md',\n views = { field: {}, text: {} },\n value,\n isDisabled,\n placeholder,\n removeOption = () => {},\n options,\n}) => {\n const fieldView = views?.field || {};\n const textView = views?.text || {};\n const fieldStyles = {\n width: '95%',\n paddingVertical: 4,\n fontSize: Typography.fontSizes[size],\n fontWeight: '400' as const,\n lineHeight: 20,\n color: isDisabled ? 'color-gray-400' : 'color-gray-900',\n ...fieldView,\n ...textView,\n };\n const option: any =\n options.length > 0 && options.find((option) => option.value === value);\n\n const isEmpty = value === '' || (Array.isArray(value) && value.length === 0);\n\n return (\n <Text {...fieldStyles}>\n {isEmpty && !!placeholder ? (\n placeholder\n ) : typeof value === 'string' ? (\n (option && option.label) ?? value\n ) : Array.isArray(value) && value.length > 0 ? (\n <Horizontal gap={6}>\n {value.map((opt) => (\n <MultiSelect key={opt} option={opt} removeOption={removeOption} />\n ))}\n </Horizontal>\n ) : (\n String(value ?? '')\n )}\n </Text>\n );\n};\n\nexport const MultiSelect: React.FC<MultiSelectProps> = ({\n option,\n size = 'md',\n removeOption = () => {},\n ...props\n}) => {\n const handlePress = () => removeOption(option);\n return (\n <Horizontal gap={6} alignItems=\"center\" {...chipStyles} {...props}>\n <Text\n fontSize={Typography.fontSizes[size]}\n fontWeight=\"500\"\n color=\"color-gray-700\"\n >\n {option}\n </Text>\n <View onPress={handlePress}>\n <CloseIcon color=\"color-gray-500\" widthHeight={IconSizes[size]} />\n </View>\n </Horizontal>\n );\n};\n\nconst SelectView: React.FC<SelectViewProps> = ({\n id,\n name,\n label,\n value,\n placeholder,\n helperText,\n hide = false,\n error = false,\n isMulti = false,\n isFocused = false,\n isHovered = false,\n isDisabled = false,\n isReadOnly = false,\n options = [],\n shadow = {},\n size = 'md',\n shape = 'default',\n variant = 'default',\n themeContainer,\n views = {\n text: {},\n icon: {},\n dropDown: {},\n selectBox: {},\n label: {},\n helperText: {},\n },\n onChange = () => {},\n setHide = () => {},\n setValue = () => {},\n setIsHovered = () => {},\n setIsFocused = () => {},\n setHighlightedIndex,\n highlightedIndex,\n isScrollable: _isScrollable,\n ...props\n}) => {\n const handlePressTrigger = () => {\n if (isDisabled || isReadOnly) return;\n const newHideState = !hide;\n setHide(newHideState);\n setIsFocused(!newHideState);\n };\n\n const handleSelect = (optionValue: string) => {\n // Mirrors the web view: `onChange` carries the next selection — the whole\n // array when `isMulti` — so a controlled parent can store what it gets.\n if (isMulti && Array.isArray(value)) {\n if (!value.includes(optionValue)) {\n const newValue = [...value, optionValue];\n setValue(newValue);\n if (onChange) onChange(newValue);\n }\n } else {\n setValue(optionValue);\n if (onChange) onChange(optionValue);\n }\n if (!isMulti) setHide(true);\n };\n\n const handleRemoveOption = (valueOption: string) => {\n if (Array.isArray(value) && value.includes(valueOption)) {\n const newValue = value.filter((option) => option !== valueOption);\n setValue(newValue);\n if (onChange) onChange(newValue);\n }\n };\n\n const isOptionSelected = (optionValue: string) => {\n if (Array.isArray(value)) return value.includes(optionValue);\n return value === optionValue;\n };\n\n const showLabel = !!label;\n const layoutViews = withoutFieldShellView(views);\n const canOpen = !isDisabled && !isReadOnly && options.length > 0;\n const selectedText = (Array.isArray(value) ? value : [value])\n .filter((selected) => selected !== '')\n .map(\n (selected) =>\n options.find((option) => option.value === selected)?.label ?? selected\n )\n .join(', ');\n\n return (\n <FieldContainer\n width=\"100%\"\n helperText={helperText}\n error={error}\n views={layoutViews}\n >\n <FieldContent\n label={label}\n size={size}\n error={error}\n shape={shape}\n views={views}\n shadow={shadow}\n variant={variant}\n themeContainer={themeContainer}\n value={value}\n color={'theme-primary'}\n isHovered={isHovered}\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n isFocused={isFocused}\n showLabel={showLabel}\n minHeight={fieldSizeStyles[size].minHeight}\n paddingTop={fieldSizeStyles[size].shellPaddingY}\n paddingBottom={fieldSizeStyles[size].shellPaddingY}\n paddingLeft={fieldSizeStyles[size].shellPaddingX}\n paddingRight={fieldSizeStyles[size].shellPaddingX}\n {...(views as any)?.content}\n onPress={canOpen ? handlePressTrigger : undefined}\n nativeID={props.nativeID ?? id}\n testID={props.testID}\n accessible\n accessibilityRole=\"combobox\"\n accessibilityLabel={\n props.accessibilityLabel ??\n props['aria-label'] ??\n label ??\n placeholder\n }\n accessibilityState={{ expanded: !hide, disabled: !canOpen }}\n accessibilityValue={{ text: selectedText || placeholder }}\n >\n <FieldWrapper>\n {showLabel && (\n <FieldLabel\n error={error}\n views={{\n label: {\n color: error ? 'theme-error' : 'theme-text',\n ...views?.label,\n },\n }}\n >\n {label}\n </FieldLabel>\n )}\n <SelectBox\n options={options}\n size={size}\n views={views}\n value={value}\n isDisabled={isDisabled}\n placeholder={placeholder}\n removeOption={handleRemoveOption}\n />\n </FieldWrapper>\n <FieldIcons>\n {!isReadOnly && !isDisabled && (\n <ChevronIcon\n color=\"inherit\"\n widthHeight={IconSizes[size]}\n orientation={hide ? 'down' : 'up'}\n />\n )}\n </FieldIcons>\n </FieldContent>\n\n <ActionSheet\n isOpen={!hide && options.length > 0}\n onClose={() => {\n setHide(true);\n setIsFocused(false);\n }}\n title={label}\n value={value}\n isMulti={isMulti}\n closeOnSelect={!isMulti}\n showCancel\n size={\n size === 'xs' || size === 'sm' ? 'sm' : size === 'xl' ? 'lg' : 'md'\n }\n items={options.map((option) => ({\n id: option.value,\n value: option.value,\n label: option.label,\n selected: isOptionSelected(option.value),\n onPress: () => handleSelect(option.value),\n }))}\n views={{\n sheet: (views as any)?.dropDown,\n item: optionStyles,\n itemLabel: (views as any)?.text,\n }}\n />\n </FieldContainer>\n );\n};\n\nexport default SelectView;\n",
|
|
133
136
|
"type": "registry:ui"
|
|
134
137
|
},
|
|
135
138
|
{
|
|
136
139
|
"path": "src/components/Form/Select/Select/Select.view.tsx",
|
|
137
|
-
"content": "import React, { useCallback, useRef } from 'react';\nimport { Portal } from '../../../Portal/Portal';\nimport { Element, useElementPosition } from 'app-studio';\nimport { Typography } from 'app-studio';\nimport { Horizontal } from 'app-studio';\nimport { Text } from 'app-studio';\nimport { FieldContainer } from '../../../Input/FieldContainer/FieldContainer';\nimport { FieldContent } from '../../../Input/FieldContent/FieldContent';\nimport { FieldIcons } from '../../../Input/FieldIcons/FieldIcons';\nimport { FieldLabel } from '../../../Input/FieldLabel/FieldLabel';\nimport { FieldWrapper } from '../../../Input/FieldWrapper/FieldWrapper';\nimport { ChevronIcon, CloseIcon } from '../../../Icon/FixedIcons';\nimport {\n DropDownProps,\n HiddenSelectProps,\n ItemProps,\n MultiSelectProps,\n SelectBoxProps,\n SelectViewProps,\n} from './Select.props';\nimport {\n IconSizes,\n dropdownStyles,\n dropdownAnimation,\n optionStyles,\n optionStateStyles,\n chevronAnimation,\n chipStyles,\n scrollbarStyles,\n} from './Select.style';\n\nconst withoutFieldShellView = <T extends Record<string, any>>(views?: T): T => {\n if (!views) return {} as T;\n const { container, content, ...layoutViews } = views;\n return layoutViews as T;\n};\n\n// Field sizing now lives in `Input/fieldSizes` and is applied by FieldContent,\n// so this component no longer carries its own copy of the scale.\n\n/**\n * Item Component\n *\n * Renders an individual option item in the select dropdown\n */\nconst Item: React.FC<ItemProps & { isSelected?: boolean }> = ({\n isHovered,\n setIsHovered = () => {},\n option,\n size = 'md',\n callback = () => {},\n style,\n isSelected = false,\n ...props\n}) => {\n // Handles the click event on an option\n const handleOptionClick = (e: React.MouseEvent, option: string) => {\n e.stopPropagation();\n e.preventDefault();\n if (typeof callback === 'function') {\n callback(option);\n }\n };\n\n // Toggles the hover state on the item\n const handleHover = () => setIsHovered(!isHovered);\n\n // Get background color based on state priority\n const getStateStyle = () => {\n if (isSelected && isHovered) return optionStateStyles.selectedHighlighted;\n if (isSelected) return optionStateStyles.selected;\n if (isHovered) return optionStateStyles.highlighted;\n return optionStateStyles.default;\n };\n\n return (\n <Element\n as=\"li\"\n // An option has to say it is one. Without the role the listbox announces\n // a list of nothing, and anything that resolves controls by role — a\n // screen reader, voice control, a test driver — cannot reach these at all.\n role=\"option\"\n aria-selected={isSelected}\n // Layout - improved touch targets\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"space-between\"\n listStyleType=\"none\"\n // Apply option styles from design tokens\n {...optionStyles}\n {...getStateStyle()}\n // Event handlers\n onMouseEnter={handleHover}\n onMouseLeave={handleHover}\n onClick={(e: React.MouseEvent) => handleOptionClick(e, option.value)}\n // Apply custom props\n {...props}\n >\n <Text\n fontSize={Typography.fontSizes[size]}\n fontWeight={isSelected ? '500' : '400'}\n lineHeight=\"14px\"\n color={isSelected ? 'color-gray-900' : 'color-gray-700'}\n {...style}\n >\n {option.label}\n </Text>\n {/* Selected indicator */}\n {isSelected && (\n <Element\n as=\"span\"\n // Decoration, and hidden as such. `aria-selected` above already\n // carries this meaning in the way assistive technology reads it,\n // whereas a visible ✓ joins the option's accessible name and turns\n // \"Alpha\" into \"Alpha ✓\" — so a screen reader announces the wrong\n // name, voice control loses \"click Alpha\", and anything resolving\n // the option by its exact label stops finding it at all.\n aria-hidden=\"true\"\n color=\"theme-primary\"\n fontSize=\"14px\"\n marginLeft={8}\n display=\"flex\"\n alignItems=\"center\"\n >\n ✓\n </Element>\n )}\n </Element>\n );\n};\n/**\n * SelectBox Component\n *\n * Renders the main select box with selected value(s)\n */\nconst SelectBox: React.FC<SelectBoxProps> = ({\n size = 'md',\n views = { field: {}, text: {} },\n value,\n isDisabled,\n placeholder,\n removeOption = () => {},\n options,\n}) => {\n const fieldView = views?.field || {};\n const textView = views?.text || {};\n const isMultiValue = Array.isArray(value) && value.length > 0;\n /**\n * Styles for the select field\n */\n const fieldStyles = {\n // Layout properties\n margin: 0,\n width: '95%',\n height: '100%',\n border: 'none',\n // No vertical padding here: the field shell above already applies\n // `shellPaddingY` for the current size. Adding 4px on each side on top of\n // it pushed the content box past the shell's `minHeight`, so a `md` Select\n // rendered at 50px while a `md` TextField rendered at the intended 40px —\n // visibly misaligning the two whenever they sit in the same row.\n paddingVertical: 0,\n paddingHorizontal: 0,\n\n // Typography properties\n fontSize: Typography.fontSizes[size],\n\n fontWeight: '400', // Regular weight\n // Left to the natural line box, as TextField does. A fixed 20px line-height\n // does not fit the shell it lives in: at `md` the shell is 40px tall with\n // 10px of padding and a 1px border on each side, leaving 18px for content.\n // Hard-coding 20px pushed every Select 2px past its own declared height.\n letterSpacing: '-0.01em', // Slight negative tracking for modern look\n\n // Visual properties\n color: isDisabled ? 'color-gray-400' : 'color-gray-900',\n\n // State properties\n cursor: isDisabled ? 'not-allowed' : 'pointer',\n\n // Animation\n transition: 'all 0.2s ease-in-out',\n\n // A single-value trigger stays on one line and ellipsises, via `Text`'s own\n // `maxLines`. Without it a long option label wraps, which silently breaks\n // the control's declared height — a `md` Select showing \"Uma User's\n // workspace\" in a narrow sidebar became two lines tall.\n //\n // `minWidth: 0` is what actually lets it truncate: the trigger is a flex\n // child, and `min-width: auto` would otherwise stop it shrinking below its\n // content, so the clamp would never engage.\n //\n // Multi-select is excluded: its value renders as chips that are meant to\n // wrap, and clamping would hide selections rather than reflow them.\n ...(isMultiValue ? {} : { maxLines: 1, minWidth: 0 }),\n\n // Apply custom styles\n ...fieldView,\n ...textView,\n style: {\n backgroundColor: 'transparent',\n ...(fieldView as any).style,\n ...(textView as any).style,\n },\n };\n const option: any =\n options.length > 0 && options.find((option) => option.value === value);\n return (\n <Text {...fieldStyles}>\n {/* Check if value is an empty string or if value is an array but with no items, then show placeholder */}\n {(value === '' || (Array.isArray(value) && value.length === 0)) &&\n !!placeholder ? (\n placeholder\n ) : (\n <>\n {/* If value is a string, use the option label or value */}\n {typeof value === 'string' ? (\n (option && option.label) ?? value\n ) : // If value is an array and not empty, render MultiSelect options\n Array.isArray(value) && value.length > 0 ? (\n <Horizontal gap={6}>\n {value.map((option) => (\n <MultiSelect\n key={option}\n option={option}\n removeOption={removeOption}\n />\n ))}\n </Horizontal>\n ) : (\n // Handle any other types of value (including objects or unexpected values)\n <span>{value}</span>\n )}\n </>\n )}\n </Text>\n );\n};\nconst HiddenSelect: React.FC<HiddenSelectProps> = ({\n id,\n name,\n value,\n onChange,\n isMulti = false,\n isDisabled = false,\n isReadOnly = false,\n options = [],\n // Swallowed on purpose. `defaultValue` is the Select's own prop — the state\n // hook has already turned it into the `value` below — but it also rides\n // along in `...props`, and React errors on any <select> carrying both\n // (\"Select elements must be either controlled or uncontrolled\"). That error\n // fires on every render and fails test runs that treat console.error as\n // fatal, so the element has to be given one or the other, never both.\n defaultValue: _defaultValue,\n ...props\n}) => {\n // The hidden <select> is the only path that produced a DOM event where every\n // other path produced a value, so the same `onChange` prop had two different\n // argument shapes depending on which one fired. Normalise here.\n const handleChange = (event: React.ChangeEvent<HTMLSelectElement>) => {\n if (!onChange) return;\n onChange(\n isMulti\n ? Array.from(event.target.selectedOptions, (option) => option.value)\n : event.target.value\n );\n };\n return (\n <Element\n id={id}\n name={name}\n as=\"select\"\n opacity={0}\n width={1}\n height={1}\n overflow=\"hidden\"\n position=\"absolute\"\n pointerEvents=\"none\"\n tabIndex={-1}\n aria-hidden=\"true\"\n value={value}\n disabled={isDisabled}\n readOnly={isReadOnly}\n onChange={handleChange}\n multiple={isMulti}\n {...props}\n >\n {options.length > 0 &&\n options.map((option) => {\n return (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n );\n })}\n </Element>\n );\n};\n/**\n * DropDown Component\n *\n * Renders the dropdown list of options for the select component\n */\nconst DropDown: React.FC<\n DropDownProps & {\n selectedValue?: string | string[];\n listboxId?: string;\n getOptionId?: (index: number) => string;\n }\n> = ({\n size,\n views = {},\n options,\n callback = () => {},\n highlightedIndex,\n setHighlightedIndex = () => {},\n selectedValue,\n listboxId,\n getOptionId,\n}) => {\n const handleCallback = (option: string) => callback(option);\n\n // Check if an option is selected\n const isOptionSelected = (optionValue: string) => {\n if (Array.isArray(selectedValue)) {\n return selectedValue.includes(optionValue);\n }\n return selectedValue === optionValue;\n };\n\n return (\n <Element\n as=\"ul\"\n role=\"listbox\"\n id={listboxId}\n display=\"flex\"\n flexDirection=\"column\"\n margin={0}\n padding=\"4px\"\n {...dropdownStyles}\n style={scrollbarStyles}\n {...views?.dropDown}\n >\n {options &&\n options.length > 0 &&\n options.map((option, index) => (\n <Item\n key={option.value}\n id={getOptionId ? getOptionId(index) : undefined}\n size={size}\n style={views['text']}\n option={option}\n callback={handleCallback}\n isSelected={isOptionSelected(option.value)}\n isHovered={index === highlightedIndex}\n setIsHovered={() => {}}\n onMouseEnter={() => setHighlightedIndex(index)}\n />\n ))}\n </Element>\n );\n};\n/**\n * MultiSelect Component\n *\n * Renders a selected option in a multi-select component\n */\nexport const MultiSelect: React.FC<MultiSelectProps> = ({\n option,\n size = 'md',\n removeOption = () => {},\n ...props\n}) => {\n const handleClick = () => removeOption(option);\n\n return (\n <Horizontal\n gap={6}\n alignItems=\"center\"\n onClick={(event: any) => event.stopPropagation()}\n {...chipStyles}\n _hover={{\n backgroundColor: 'color-gray-200',\n }}\n {...props}\n >\n <Text\n fontSize={Typography.fontSizes[size]}\n fontWeight=\"500\"\n color=\"color-gray-700\"\n >\n {option}\n </Text>\n\n {/* A real button: `close-button` is not an ARIA role, so the remover was\n invisible to assistive tech and unreachable by keyboard. */}\n <Element\n as=\"button\"\n type=\"button\"\n aria-label={`Remove ${option}`}\n onClick={handleClick}\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n padding={0}\n border=\"none\"\n backgroundColor=\"transparent\"\n color=\"color-gray-500\"\n cursor=\"pointer\"\n transition=\"all 0.2s ease-in-out\"\n _hover={{\n color: 'color-gray-700',\n }}\n >\n <CloseIcon color=\"inherit\" widthHeight={IconSizes[size]} />\n </Element>\n </Horizontal>\n );\n};\nconst SelectView: React.FC<SelectViewProps> = ({\n id,\n name,\n label,\n value,\n placeholder,\n helperText,\n hide = false,\n error = false,\n isMulti = false,\n isFocused = false,\n isHovered = false,\n isDisabled = false,\n isReadOnly = false,\n isRequired = false,\n isAutoFocus = false,\n options = [],\n shadow = {},\n size = 'md',\n shape = 'default',\n variant = 'default',\n views = {\n text: {},\n icon: {},\n dropDown: {},\n selectBox: {},\n label: {},\n helperText: {},\n },\n onChange = () => {},\n setHide = () => {},\n setValue = () => {},\n setIsHovered = () => {},\n setIsFocused = () => {},\n setHighlightedIndex,\n highlightedIndex,\n isScrollable,\n // Pulled out so it can name the trigger. It used to fall into `...props`,\n // which never reaches the element a screen reader reads.\n 'aria-label': ariaLabel,\n ...props\n}) => {\n const generatedId = React.useId();\n // One id per element: the focusable combobox keeps the public `id`; the\n // aria-hidden native <select>, the label, the listbox and its options get\n // derived ids — the combobox and the native <select> used to share the same\n // `id`, which is invalid HTML and made `htmlFor` ambiguous. The `useId`\n // fallback is stripped of its delimiters because the id is used in `#id`\n // selector lookups below.\n const selectId = id ?? `select-${generatedId.replace(/[^a-zA-Z0-9_-]/g, '')}`;\n const nativeSelectId = `${selectId}-native`;\n const labelId = `${selectId}-label`;\n const listboxId = `${selectId}-listbox`;\n const getOptionId = (index: number) => `${selectId}-option-${index}`;\n\n const {\n ref: triggerRef,\n relation,\n updateRelation,\n } = useElementPosition({\n trackChanges: true,\n trackOnScroll: true,\n trackOnResize: true,\n throttleMs: 10,\n });\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n\n // Get optimal positioning style based on available space\n // Get optimal positioning style based on available space\n const getDropdownStyle = () => {\n if (!triggerRef.current) return {};\n\n const rect = triggerRef.current.getBoundingClientRect();\n const baseStyle: React.CSSProperties = {\n position: 'fixed',\n left: rect.left,\n width: rect.width,\n zIndex: 10000,\n };\n\n // Use relation to determine vertical placement if available, otherwise default to bottom\n const isTop = relation?.space?.vertical === 'top';\n\n if (isTop) {\n return {\n ...baseStyle,\n bottom: window.innerHeight - rect.top + 8, // 8px gap\n };\n } else {\n return {\n ...baseStyle,\n top: rect.bottom + 8, // 8px gap\n };\n }\n };\n // close when *any* other select opens\n React.useEffect(() => {\n const handleCloseAll = () => setHide(true);\n document.addEventListener('closeAllSelects', handleCloseAll);\n return () =>\n document.removeEventListener('closeAllSelects', handleCloseAll);\n }, [setHide]);\n\n // Mount-only autofocus, mirroring the native `autofocus` attribute: the\n // focusable element is the combobox trigger, not the aria-hidden <select>.\n React.useEffect(() => {\n if (isAutoFocus && !isDisabled && !isReadOnly) {\n triggerRef.current?.focus();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // Add a global click handler to close the dropdown when clicking outside\n React.useEffect(() => {\n const handleGlobalClick = (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n // Only close if clicking outside of this specific select component\n if (!target.closest(`#${selectId}`) && !hide) {\n setHide(true);\n }\n };\n\n document.addEventListener('click', handleGlobalClick);\n return () => {\n document.removeEventListener('click', handleGlobalClick);\n };\n }, [selectId, hide, setHide]);\n const handleHover = () => setIsHovered(!isHovered);\n const handleFocus = () => setIsFocused(true);\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n // tell all other selects to close\n document.dispatchEvent(new Event('closeAllSelects'));\n\n if (event && event.stopPropagation) event.stopPropagation();\n\n // Toggle dropdown visibility\n const newHideState = !hide;\n setHide(newHideState);\n setIsFocused(!newHideState); // Set focus state based on dropdown visibility\n };\n const handleCallback = useCallback(\n (option: string) => {\n // Close dropdown after selection\n setHide(true);\n\n // Tell all other selects to close\n document.dispatchEvent(new Event('closeAllSelects'));\n\n // Update value based on multi-select or single-select mode.\n // `onChange` reports the *next* selection, not the option that was\n // clicked: a controlled parent has to be able to store what it gets\n // back, and for a multi-select that is the whole array.\n if (isMulti && Array.isArray(value)) {\n if (!value.includes(option)) {\n const newValue = [...value, option];\n setValue(newValue);\n if (onChange) onChange(newValue);\n }\n } else {\n setValue(option);\n if (onChange) onChange(option);\n }\n\n // Set focus to indicate selection\n setIsFocused(true);\n },\n [isMulti, value, setHide, setValue, onChange, setIsFocused]\n );\n const handleRemoveOption = (valueOption: string) => {\n if (Array.isArray(value) && value.includes(valueOption)) {\n const newValue = value.filter((option) => option !== valueOption);\n setValue(newValue);\n // Removing a chip is a change like any other. Without this the parent of\n // a controlled multi-select never hears about it, so the chip comes\n // straight back on the next render.\n if (onChange) onChange(newValue);\n }\n };\n const showLabel = !!label;\n const layoutViews = withoutFieldShellView(views);\n\n return (\n <FieldContainer\n ref={triggerRef as React.RefObject<HTMLDivElement>}\n position=\"relative\"\n width=\"100%\"\n display=\"inline-block\"\n id={selectId}\n // `SelectBox` is not an ARIA role, so the trigger was exposed as a plain\n // container: not focusable, not announced, and operable only by mouse.\n // The native `<select>` behind it is `aria-hidden` and `tabIndex={-1}`, so\n // there was no keyboard path to this control at all.\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={!hide}\n // The visible label names the combobox via `aria-labelledby`; an explicit\n // `aria-label` prop wins when the caller provides one.\n aria-labelledby={!ariaLabel && showLabel ? labelId : undefined}\n aria-label={ariaLabel}\n aria-controls={listboxId}\n aria-activedescendant={\n !hide && options.length > 0\n ? getOptionId(highlightedIndex ?? 0)\n : undefined\n }\n aria-disabled={isDisabled || undefined}\n aria-required={isRequired || undefined}\n tabIndex={isDisabled || isReadOnly ? -1 : 0}\n helperText={helperText}\n error={error}\n views={layoutViews}\n onKeyDown={(e: React.KeyboardEvent<HTMLDivElement>) => {\n if (isDisabled || isReadOnly) return;\n // Keys pressed on descendants (the chip-remove buttons) must keep\n // their native activation instead of being hijacked by the trigger.\n if (e.target !== e.currentTarget) return;\n\n // Closed: Enter, Space and Down open the list — the same keys a\n // native select answers to, so nobody has to learn this one separately.\n if (hide) {\n if (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowDown') {\n e.preventDefault();\n document.dispatchEvent(new Event('closeAllSelects'));\n setHide(false);\n setIsFocused(true);\n }\n return;\n }\n\n // Open: arrows move the highlight, Enter commits it, Escape closes.\n const currentIndex = highlightedIndex ?? 0;\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n setHighlightedIndex?.(Math.min(currentIndex + 1, options.length - 1));\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n setHighlightedIndex?.(Math.max(currentIndex - 1, 0));\n } else if (e.key === 'Enter') {\n e.preventDefault();\n const option = options[currentIndex];\n if (option) handleCallback(option.value);\n } else if (e.key === 'Escape') {\n e.preventDefault();\n setHide(true);\n }\n }}\n onClick={(e: React.MouseEvent<HTMLDivElement>) => {\n // Stop propagation to prevent clicks from bubbling up\n e.stopPropagation();\n\n // Only handle click if not disabled or readonly\n if (!(isDisabled || isReadOnly)) {\n handleClick(e as unknown as React.MouseEvent<HTMLButtonElement>);\n }\n }}\n >\n <FieldContent\n label={label}\n size={size}\n error={error}\n shape={shape}\n views={views}\n shadow={shadow}\n variant={variant}\n value={value}\n color={'theme-primary'}\n isHovered={isHovered}\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n isFocused={isFocused}\n showLabel={showLabel}\n // Sizing comes from FieldContent's shared scale (`Input/fieldSizes`).\n onMouseEnter={handleHover}\n onMouseLeave={handleHover}\n position=\"relative\"\n {...views?.content}\n >\n <FieldWrapper>\n {showLabel && (\n <FieldLabel\n id={labelId}\n htmlFor={nativeSelectId}\n color={'theme-primary'}\n error={error}\n {...views?.label}\n >\n {label}\n </FieldLabel>\n )}\n <HiddenSelect\n id={nativeSelectId}\n name={name}\n options={options}\n onChange={onChange}\n value={value}\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n isMulti={isMulti}\n // Real form semantics live on the native element: `required`\n // makes submission enforcement work even though the visible\n // combobox is a div.\n required={isRequired || undefined}\n onFocus={handleFocus}\n {...props}\n />\n <SelectBox\n options={options}\n size={size}\n views={views}\n value={value}\n isDisabled={isDisabled}\n placeholder={placeholder}\n removeOption={handleRemoveOption}\n />\n </FieldWrapper>\n <FieldIcons>\n {!isReadOnly && !isDisabled && (\n <Element\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n style={hide ? chevronAnimation.closed : chevronAnimation.open}\n >\n <ChevronIcon\n color=\"inherit\"\n widthHeight={IconSizes[size]}\n style={views.icon}\n orientation=\"down\"\n />\n </Element>\n )}\n </FieldIcons>\n {!hide && options.length > 0 && (\n <Portal>\n <Element\n ref={dropdownRef}\n onClick={(e: React.MouseEvent) => e.stopPropagation()}\n style={{\n ...getDropdownStyle(),\n ...dropdownAnimation.enter,\n }}\n >\n <DropDown\n size={size}\n views={views}\n options={options}\n callback={handleCallback}\n highlightedIndex={highlightedIndex}\n setHighlightedIndex={setHighlightedIndex}\n selectedValue={value}\n listboxId={listboxId}\n getOptionId={getOptionId}\n />\n </Element>\n </Portal>\n )}\n </FieldContent>\n </FieldContainer>\n );\n};\nexport default SelectView;\n",
|
|
140
|
+
"content": "import React, { useCallback, useRef } from 'react';\nimport { Portal } from '../../../Portal/Portal';\nimport { Element, useElementPosition } from 'app-studio';\nimport { Typography } from 'app-studio';\nimport { Horizontal } from 'app-studio';\nimport { Text } from 'app-studio';\nimport { FieldContainer } from '../../../Input/FieldContainer/FieldContainer';\nimport { FieldContent } from '../../../Input/FieldContent/FieldContent';\nimport { FieldIcons } from '../../../Input/FieldIcons/FieldIcons';\nimport { FieldLabel } from '../../../Input/FieldLabel/FieldLabel';\nimport { FieldWrapper } from '../../../Input/FieldWrapper/FieldWrapper';\nimport { ChevronIcon, CloseIcon } from '../../../Icon/FixedIcons';\nimport {\n DropDownProps,\n HiddenSelectProps,\n ItemProps,\n MultiSelectProps,\n SelectBoxProps,\n SelectViewProps,\n} from './Select.props';\nimport {\n IconSizes,\n dropdownStyles,\n dropdownAnimation,\n optionStyles,\n optionStateStyles,\n chevronAnimation,\n chipStyles,\n scrollbarStyles,\n} from './Select.style';\n\nconst withoutFieldShellView = <T extends Record<string, any>>(views?: T): T => {\n if (!views) return {} as T;\n const { container, content, ...layoutViews } = views;\n return layoutViews as T;\n};\n\n// Field sizing now lives in `Input/fieldSizes` and is applied by FieldContent,\n// so this component no longer carries its own copy of the scale.\n\n/**\n * Item Component\n *\n * Renders an individual option item in the select dropdown\n */\nconst Item: React.FC<ItemProps & { isSelected?: boolean }> = ({\n isHovered,\n setIsHovered = () => {},\n option,\n size = 'md',\n callback = () => {},\n style,\n isSelected = false,\n ...props\n}) => {\n // Handles the click event on an option\n const handleOptionClick = (e: React.MouseEvent, option: string) => {\n e.stopPropagation();\n e.preventDefault();\n if (typeof callback === 'function') {\n callback(option);\n }\n };\n\n // Toggles the hover state on the item\n const handleHover = () => setIsHovered(!isHovered);\n\n // Get background color based on state priority\n const getStateStyle = () => {\n if (isSelected && isHovered) return optionStateStyles.selectedHighlighted;\n if (isSelected) return optionStateStyles.selected;\n if (isHovered) return optionStateStyles.highlighted;\n return optionStateStyles.default;\n };\n\n return (\n <Element\n as=\"li\"\n // An option has to say it is one. Without the role the listbox announces\n // a list of nothing, and anything that resolves controls by role — a\n // screen reader, voice control, a test driver — cannot reach these at all.\n role=\"option\"\n aria-selected={isSelected}\n // Layout - improved touch targets\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"space-between\"\n listStyleType=\"none\"\n // Apply option styles from design tokens\n {...optionStyles}\n {...getStateStyle()}\n // Event handlers\n onMouseEnter={handleHover}\n onMouseLeave={handleHover}\n onClick={(e: React.MouseEvent) => handleOptionClick(e, option.value)}\n // Apply custom props\n {...props}\n >\n <Text\n fontSize={Typography.fontSizes[size]}\n fontWeight={isSelected ? '500' : '400'}\n lineHeight=\"14px\"\n color={isSelected ? 'color-gray-900' : 'color-gray-700'}\n {...style}\n >\n {option.label}\n </Text>\n {/* Selected indicator */}\n {isSelected && (\n <Element\n as=\"span\"\n // Decoration, and hidden as such. `aria-selected` above already\n // carries this meaning in the way assistive technology reads it,\n // whereas a visible ✓ joins the option's accessible name and turns\n // \"Alpha\" into \"Alpha ✓\" — so a screen reader announces the wrong\n // name, voice control loses \"click Alpha\", and anything resolving\n // the option by its exact label stops finding it at all.\n aria-hidden=\"true\"\n color=\"theme-primary\"\n fontSize=\"14px\"\n marginLeft={8}\n display=\"flex\"\n alignItems=\"center\"\n >\n ✓\n </Element>\n )}\n </Element>\n );\n};\n/**\n * SelectBox Component\n *\n * Renders the main select box with selected value(s)\n */\nconst SelectBox: React.FC<SelectBoxProps> = ({\n size = 'md',\n views = { field: {}, text: {} },\n value,\n isDisabled,\n placeholder,\n removeOption = () => {},\n options,\n}) => {\n const fieldView = views?.field || {};\n const textView = views?.text || {};\n const isMultiValue = Array.isArray(value) && value.length > 0;\n /**\n * Styles for the select field\n */\n const fieldStyles = {\n // Layout properties\n margin: 0,\n width: '95%',\n height: '100%',\n border: 'none',\n // No vertical padding here: the field shell above already applies\n // `shellPaddingY` for the current size. Adding 4px on each side on top of\n // it pushed the content box past the shell's `minHeight`, so a `md` Select\n // rendered at 50px while a `md` TextField rendered at the intended 40px —\n // visibly misaligning the two whenever they sit in the same row.\n paddingVertical: 0,\n paddingHorizontal: 0,\n\n // Typography properties\n fontSize: Typography.fontSizes[size],\n\n fontWeight: '400', // Regular weight\n // Left to the natural line box, as TextField does. A fixed 20px line-height\n // does not fit the shell it lives in: at `md` the shell is 40px tall with\n // 10px of padding and a 1px border on each side, leaving 18px for content.\n // Hard-coding 20px pushed every Select 2px past its own declared height.\n letterSpacing: '-0.01em', // Slight negative tracking for modern look\n\n // Visual properties\n color: isDisabled ? 'color-gray-400' : 'color-gray-900',\n\n // State properties\n cursor: isDisabled ? 'not-allowed' : 'pointer',\n\n // Animation\n transition: 'all 0.2s ease-in-out',\n\n // A single-value trigger stays on one line and ellipsises, via `Text`'s own\n // `maxLines`. Without it a long option label wraps, which silently breaks\n // the control's declared height — a `md` Select showing \"Uma User's\n // workspace\" in a narrow sidebar became two lines tall.\n //\n // `minWidth: 0` is what actually lets it truncate: the trigger is a flex\n // child, and `min-width: auto` would otherwise stop it shrinking below its\n // content, so the clamp would never engage.\n //\n // Multi-select is excluded: its value renders as chips that are meant to\n // wrap, and clamping would hide selections rather than reflow them.\n ...(isMultiValue ? {} : { maxLines: 1, minWidth: 0 }),\n\n // Apply custom styles\n ...fieldView,\n ...textView,\n style: {\n backgroundColor: 'transparent',\n ...(fieldView as any).style,\n ...(textView as any).style,\n },\n };\n const option: any =\n options.length > 0 && options.find((option) => option.value === value);\n return (\n <Text {...fieldStyles}>\n {/* Check if value is an empty string or if value is an array but with no items, then show placeholder */}\n {(value === '' || (Array.isArray(value) && value.length === 0)) &&\n !!placeholder ? (\n placeholder\n ) : (\n <>\n {/* If value is a string, use the option label or value */}\n {typeof value === 'string' ? (\n (option && option.label) ?? value\n ) : // If value is an array and not empty, render MultiSelect options\n Array.isArray(value) && value.length > 0 ? (\n <Horizontal gap={6}>\n {value.map((option) => (\n <MultiSelect\n key={option}\n option={option}\n removeOption={removeOption}\n />\n ))}\n </Horizontal>\n ) : (\n // Handle any other types of value (including objects or unexpected values)\n <span>{value}</span>\n )}\n </>\n )}\n </Text>\n );\n};\nconst HiddenSelect: React.FC<HiddenSelectProps> = ({\n id,\n name,\n value,\n onChange,\n isMulti = false,\n isDisabled = false,\n isReadOnly = false,\n options = [],\n // Swallowed on purpose. `defaultValue` is the Select's own prop — the state\n // hook has already turned it into the `value` below — but it also rides\n // along in `...props`, and React errors on any <select> carrying both\n // (\"Select elements must be either controlled or uncontrolled\"). That error\n // fires on every render and fails test runs that treat console.error as\n // fatal, so the element has to be given one or the other, never both.\n defaultValue: _defaultValue,\n ...props\n}) => {\n // The hidden <select> is the only path that produced a DOM event where every\n // other path produced a value, so the same `onChange` prop had two different\n // argument shapes depending on which one fired. Normalise here.\n const handleChange = (event: React.ChangeEvent<HTMLSelectElement>) => {\n if (!onChange) return;\n onChange(\n isMulti\n ? Array.from(event.target.selectedOptions, (option) => option.value)\n : event.target.value\n );\n };\n return (\n <Element\n id={id}\n name={name}\n as=\"select\"\n opacity={0}\n width={1}\n height={1}\n overflow=\"hidden\"\n position=\"absolute\"\n pointerEvents=\"none\"\n tabIndex={-1}\n aria-hidden=\"true\"\n value={value}\n disabled={isDisabled}\n readOnly={isReadOnly}\n onChange={handleChange}\n multiple={isMulti}\n {...props}\n >\n {options.length > 0 &&\n options.map((option) => {\n return (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n );\n })}\n </Element>\n );\n};\n/**\n * DropDown Component\n *\n * Renders the dropdown list of options for the select component\n */\nconst DropDown: React.FC<\n DropDownProps & {\n selectedValue?: string | string[];\n listboxId?: string;\n getOptionId?: (index: number) => string;\n }\n> = ({\n size,\n views = {},\n options,\n callback = () => {},\n highlightedIndex,\n setHighlightedIndex = () => {},\n selectedValue,\n listboxId,\n getOptionId,\n}) => {\n const handleCallback = (option: string) => callback(option);\n\n // Check if an option is selected\n const isOptionSelected = (optionValue: string) => {\n if (Array.isArray(selectedValue)) {\n return selectedValue.includes(optionValue);\n }\n return selectedValue === optionValue;\n };\n\n return (\n <Element\n as=\"ul\"\n role=\"listbox\"\n id={listboxId}\n display=\"flex\"\n flexDirection=\"column\"\n margin={0}\n padding=\"4px\"\n {...dropdownStyles}\n style={scrollbarStyles}\n {...views?.dropDown}\n >\n {options &&\n options.length > 0 &&\n options.map((option, index) => (\n <Item\n key={option.value}\n id={getOptionId ? getOptionId(index) : undefined}\n size={size}\n style={views['text']}\n option={option}\n callback={handleCallback}\n isSelected={isOptionSelected(option.value)}\n isHovered={index === highlightedIndex}\n setIsHovered={() => {}}\n onMouseEnter={() => setHighlightedIndex(index)}\n />\n ))}\n </Element>\n );\n};\n/**\n * MultiSelect Component\n *\n * Renders a selected option in a multi-select component\n */\nexport const MultiSelect: React.FC<MultiSelectProps> = ({\n option,\n size = 'md',\n removeOption = () => {},\n ...props\n}) => {\n const handleClick = () => removeOption(option);\n\n return (\n <Horizontal\n gap={6}\n alignItems=\"center\"\n onClick={(event: any) => event.stopPropagation()}\n {...chipStyles}\n _hover={{\n backgroundColor: 'color-gray-200',\n }}\n {...props}\n >\n <Text\n fontSize={Typography.fontSizes[size]}\n fontWeight=\"500\"\n color=\"color-gray-700\"\n >\n {option}\n </Text>\n\n {/* A real button: `close-button` is not an ARIA role, so the remover was\n invisible to assistive tech and unreachable by keyboard. */}\n <Element\n as=\"button\"\n type=\"button\"\n aria-label={`Remove ${option}`}\n onClick={handleClick}\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n padding={0}\n border=\"none\"\n backgroundColor=\"transparent\"\n color=\"color-gray-500\"\n cursor=\"pointer\"\n transition=\"all 0.2s ease-in-out\"\n _hover={{\n color: 'color-gray-700',\n }}\n >\n <CloseIcon color=\"inherit\" widthHeight={IconSizes[size]} />\n </Element>\n </Horizontal>\n );\n};\nconst SelectView: React.FC<SelectViewProps> = ({\n id,\n name,\n label,\n value,\n placeholder,\n helperText,\n hide = false,\n error = false,\n isMulti = false,\n isFocused = false,\n isHovered = false,\n isDisabled = false,\n isReadOnly = false,\n isRequired = false,\n isAutoFocus = false,\n options = [],\n shadow = {},\n size = 'md',\n shape = 'default',\n variant = 'default',\n themeContainer,\n views = {\n text: {},\n icon: {},\n dropDown: {},\n selectBox: {},\n label: {},\n helperText: {},\n },\n onChange = () => {},\n setHide = () => {},\n setValue = () => {},\n setIsHovered = () => {},\n setIsFocused = () => {},\n setHighlightedIndex,\n highlightedIndex,\n isScrollable,\n // Pulled out so it can name the trigger. It used to fall into `...props`,\n // which never reaches the element a screen reader reads.\n 'aria-label': ariaLabel,\n ...props\n}) => {\n const generatedId = React.useId();\n // One id per element: the focusable combobox keeps the public `id`; the\n // aria-hidden native <select>, the label, the listbox and its options get\n // derived ids — the combobox and the native <select> used to share the same\n // `id`, which is invalid HTML and made `htmlFor` ambiguous. The `useId`\n // fallback is stripped of its delimiters because the id is used in `#id`\n // selector lookups below.\n const selectId = id ?? `select-${generatedId.replace(/[^a-zA-Z0-9_-]/g, '')}`;\n const nativeSelectId = `${selectId}-native`;\n const labelId = `${selectId}-label`;\n const listboxId = `${selectId}-listbox`;\n const getOptionId = (index: number) => `${selectId}-option-${index}`;\n\n const {\n ref: triggerRef,\n relation,\n updateRelation,\n } = useElementPosition({\n trackChanges: true,\n trackOnScroll: true,\n trackOnResize: true,\n throttleMs: 10,\n });\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n\n // Get optimal positioning style based on available space\n // Get optimal positioning style based on available space\n const getDropdownStyle = () => {\n if (!triggerRef.current) return {};\n\n const rect = triggerRef.current.getBoundingClientRect();\n const baseStyle: React.CSSProperties = {\n position: 'fixed',\n left: rect.left,\n width: rect.width,\n zIndex: 10000,\n };\n\n // Use relation to determine vertical placement if available, otherwise default to bottom\n const isTop = relation?.space?.vertical === 'top';\n\n if (isTop) {\n return {\n ...baseStyle,\n bottom: window.innerHeight - rect.top + 8, // 8px gap\n };\n } else {\n return {\n ...baseStyle,\n top: rect.bottom + 8, // 8px gap\n };\n }\n };\n // close when *any* other select opens\n React.useEffect(() => {\n const handleCloseAll = () => setHide(true);\n document.addEventListener('closeAllSelects', handleCloseAll);\n return () =>\n document.removeEventListener('closeAllSelects', handleCloseAll);\n }, [setHide]);\n\n // Mount-only autofocus, mirroring the native `autofocus` attribute: the\n // focusable element is the combobox trigger, not the aria-hidden <select>.\n React.useEffect(() => {\n if (isAutoFocus && !isDisabled && !isReadOnly) {\n triggerRef.current?.focus();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // Add a global click handler to close the dropdown when clicking outside\n React.useEffect(() => {\n const handleGlobalClick = (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n // Only close if clicking outside of this specific select component\n if (!target.closest(`#${selectId}`) && !hide) {\n setHide(true);\n }\n };\n\n document.addEventListener('click', handleGlobalClick);\n return () => {\n document.removeEventListener('click', handleGlobalClick);\n };\n }, [selectId, hide, setHide]);\n const handleHover = () => setIsHovered(!isHovered);\n const handleFocus = () => setIsFocused(true);\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n // tell all other selects to close\n document.dispatchEvent(new Event('closeAllSelects'));\n\n if (event && event.stopPropagation) event.stopPropagation();\n\n // Toggle dropdown visibility\n const newHideState = !hide;\n setHide(newHideState);\n setIsFocused(!newHideState); // Set focus state based on dropdown visibility\n };\n const handleCallback = useCallback(\n (option: string) => {\n // Close dropdown after selection\n setHide(true);\n\n // Tell all other selects to close\n document.dispatchEvent(new Event('closeAllSelects'));\n\n // Update value based on multi-select or single-select mode.\n // `onChange` reports the *next* selection, not the option that was\n // clicked: a controlled parent has to be able to store what it gets\n // back, and for a multi-select that is the whole array.\n if (isMulti && Array.isArray(value)) {\n if (!value.includes(option)) {\n const newValue = [...value, option];\n setValue(newValue);\n if (onChange) onChange(newValue);\n }\n } else {\n setValue(option);\n if (onChange) onChange(option);\n }\n\n // Set focus to indicate selection\n setIsFocused(true);\n },\n [isMulti, value, setHide, setValue, onChange, setIsFocused]\n );\n const handleRemoveOption = (valueOption: string) => {\n if (Array.isArray(value) && value.includes(valueOption)) {\n const newValue = value.filter((option) => option !== valueOption);\n setValue(newValue);\n // Removing a chip is a change like any other. Without this the parent of\n // a controlled multi-select never hears about it, so the chip comes\n // straight back on the next render.\n if (onChange) onChange(newValue);\n }\n };\n const showLabel = !!label;\n const layoutViews = withoutFieldShellView(views);\n\n return (\n <FieldContainer\n ref={triggerRef as React.RefObject<HTMLDivElement>}\n position=\"relative\"\n width=\"100%\"\n display=\"inline-block\"\n id={selectId}\n // `SelectBox` is not an ARIA role, so the trigger was exposed as a plain\n // container: not focusable, not announced, and operable only by mouse.\n // The native `<select>` behind it is `aria-hidden` and `tabIndex={-1}`, so\n // there was no keyboard path to this control at all.\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={!hide}\n // The visible label names the combobox via `aria-labelledby`; an explicit\n // `aria-label` prop wins when the caller provides one.\n aria-labelledby={!ariaLabel && showLabel ? labelId : undefined}\n aria-label={ariaLabel}\n aria-controls={listboxId}\n aria-activedescendant={\n !hide && options.length > 0\n ? getOptionId(highlightedIndex ?? 0)\n : undefined\n }\n aria-disabled={isDisabled || undefined}\n aria-required={isRequired || undefined}\n tabIndex={isDisabled || isReadOnly ? -1 : 0}\n helperText={helperText}\n error={error}\n views={layoutViews}\n onKeyDown={(e: React.KeyboardEvent<HTMLDivElement>) => {\n if (isDisabled || isReadOnly) return;\n // Keys pressed on descendants (the chip-remove buttons) must keep\n // their native activation instead of being hijacked by the trigger.\n if (e.target !== e.currentTarget) return;\n\n // Closed: Enter, Space and Down open the list — the same keys a\n // native select answers to, so nobody has to learn this one separately.\n if (hide) {\n if (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowDown') {\n e.preventDefault();\n document.dispatchEvent(new Event('closeAllSelects'));\n setHide(false);\n setIsFocused(true);\n }\n return;\n }\n\n // Open: arrows move the highlight, Enter commits it, Escape closes.\n const currentIndex = highlightedIndex ?? 0;\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n setHighlightedIndex?.(Math.min(currentIndex + 1, options.length - 1));\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n setHighlightedIndex?.(Math.max(currentIndex - 1, 0));\n } else if (e.key === 'Enter') {\n e.preventDefault();\n const option = options[currentIndex];\n if (option) handleCallback(option.value);\n } else if (e.key === 'Escape') {\n e.preventDefault();\n setHide(true);\n }\n }}\n onClick={(e: React.MouseEvent<HTMLDivElement>) => {\n // Stop propagation to prevent clicks from bubbling up\n e.stopPropagation();\n\n // Only handle click if not disabled or readonly\n if (!(isDisabled || isReadOnly)) {\n handleClick(e as unknown as React.MouseEvent<HTMLButtonElement>);\n }\n }}\n >\n <FieldContent\n label={label}\n size={size}\n error={error}\n shape={shape}\n views={views}\n shadow={shadow}\n variant={variant}\n themeContainer={themeContainer}\n value={value}\n color={'theme-primary'}\n isHovered={isHovered}\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n isFocused={isFocused}\n showLabel={showLabel}\n // Sizing comes from FieldContent's shared scale (`Input/fieldSizes`).\n onMouseEnter={handleHover}\n onMouseLeave={handleHover}\n position=\"relative\"\n {...views?.content}\n >\n <FieldWrapper>\n {showLabel && (\n <FieldLabel\n id={labelId}\n htmlFor={nativeSelectId}\n color={'theme-primary'}\n error={error}\n {...views?.label}\n >\n {label}\n </FieldLabel>\n )}\n <HiddenSelect\n id={nativeSelectId}\n name={name}\n options={options}\n onChange={onChange}\n value={value}\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n isMulti={isMulti}\n // Real form semantics live on the native element: `required`\n // makes submission enforcement work even though the visible\n // combobox is a div.\n required={isRequired || undefined}\n onFocus={handleFocus}\n {...props}\n />\n <SelectBox\n options={options}\n size={size}\n views={views}\n value={value}\n isDisabled={isDisabled}\n placeholder={placeholder}\n removeOption={handleRemoveOption}\n />\n </FieldWrapper>\n <FieldIcons>\n {!isReadOnly && !isDisabled && (\n <Element\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n style={hide ? chevronAnimation.closed : chevronAnimation.open}\n >\n <ChevronIcon\n color=\"inherit\"\n widthHeight={IconSizes[size]}\n style={views.icon}\n orientation=\"down\"\n />\n </Element>\n )}\n </FieldIcons>\n {!hide && options.length > 0 && (\n <Portal>\n <Element\n ref={dropdownRef}\n onClick={(e: React.MouseEvent) => e.stopPropagation()}\n style={{\n ...getDropdownStyle(),\n ...dropdownAnimation.enter,\n }}\n >\n <DropDown\n size={size}\n views={views}\n options={options}\n callback={handleCallback}\n highlightedIndex={highlightedIndex}\n setHighlightedIndex={setHighlightedIndex}\n selectedValue={value}\n listboxId={listboxId}\n getOptionId={getOptionId}\n />\n </Element>\n </Portal>\n )}\n </FieldContent>\n </FieldContainer>\n );\n};\nexport default SelectView;\n",
|
|
138
141
|
"type": "registry:ui"
|
|
139
142
|
},
|
|
140
143
|
{
|
|
@@ -164,12 +167,12 @@
|
|
|
164
167
|
},
|
|
165
168
|
{
|
|
166
169
|
"path": "src/components/Input/FieldContent/FieldContent.tsx",
|
|
167
|
-
"content": "/**\n * FieldContent Component\n *\n * Renders the content area of a form field with various styles and states\n * according to the design guidelines.\n */\n\nimport React from 'react';\nimport { Typography, useTheme } from 'app-studio';\n\nimport { InputVariants, Shapes } from '../Input.style';\nimport { fieldSizeProps } from '../fieldSizes';\nimport { Horizontal } from 'app-studio';\n\nimport { ContentProps } from './FieldContent/FieldContent.props';\n\nexport const FieldContent: React.FC<ContentProps> = ({\n label,\n shadow,\n children,\n value,\n size = 'md',\n shape = 'default',\n variant = 'default',\n error = false,\n showLabel = false,\n isFocused = false,\n isHovered = false,\n isDisabled = false,\n isReadOnly = false,\n views = { pickerBox: {} },\n ...props\n}) => {\n const { themeMode } = useTheme();\n const isDark = themeMode === 'dark';\n\n // Determine if the field is in an interactive state\n const isInteractive = (isHovered || isFocused) && !isDisabled;\n const color = error\n ? 'color-red-500'\n : isInteractive\n ? 'theme-primary'\n : 'color-gray-200';\n\n return (\n <Horizontal\n gap={8}\n width=\"100%\"\n // Fields set `width: 100%` and then add their own padding/border, so they\n // only fit their container under border-box. Declared here rather than\n // relying on a host `* { box-sizing: border-box }` reset, whose absence\n // otherwise makes every field overflow its parent by padding + border.\n boxSizing=\"border-box\"\n display=\"flex\"\n flexWrap=\"nowrap\"\n alignItems=\"center\"\n justifyContent=\"flex-start\"\n borderStyle=\"solid\"\n borderColor={color}\n backgroundColor={isDark ? 'color-gray-900' : 'color-white'}\n fontSize={Typography.fontSizes[size]}\n cursor={isDisabled ? 'not-allowed' : isReadOnly ? 'auto' : 'text'}\n opacity={isDisabled ? 0.7 : 1}\n transition=\"border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease\"\n // Sizing belongs to the shell, not to each field: without it every field\n // rendered at roughly `md` height whatever size was asked for. Placed\n // before `views`/`props` so a caller can still override.\n {...fieldSizeProps(size)}\n {...(typeof shadow === 'object' && shadow !== null ? shadow : {})}\n {...Shapes[shape]}\n {...
|
|
170
|
+
"content": "/**\n * FieldContent Component\n *\n * Renders the content area of a form field with various styles and states\n * according to the design guidelines.\n */\n\nimport React from 'react';\nimport { Typography, useTheme } from 'app-studio';\n\nimport { InputVariants, Shapes } from '../Input.style';\nimport { fieldSizeProps } from '../fieldSizes';\nimport { Horizontal } from 'app-studio';\n\nimport { ContentProps } from './FieldContent/FieldContent.props';\nimport { mergeDesignSystemViews } from '../../../design-system/theme';\n\nexport const FieldContent: React.FC<ContentProps> = ({\n label,\n shadow,\n children,\n value,\n size = 'md',\n shape = 'default',\n variant = 'default',\n error = false,\n showLabel = false,\n isFocused = false,\n isHovered = false,\n isDisabled = false,\n isReadOnly = false,\n views = { pickerBox: {} },\n themeContainer,\n ...props\n}) => {\n const { themeMode } = useTheme();\n const isDark = themeMode === 'dark';\n\n // Determine if the field is in an interactive state\n const isInteractive = (isHovered || isFocused) && !isDisabled;\n const color = error\n ? 'color-red-500'\n : isInteractive\n ? 'theme-primary'\n : 'color-gray-200';\n const variantStyle = InputVariants[variant];\n let container = views?.container;\n if (themeContainer) {\n const { borderRadius, ...style } = variantStyle ?? {};\n const decoration =\n variant === 'none'\n ? { borderWidth: 0, backgroundColor: 'transparent' }\n : {\n ...style,\n borderColor: error || isInteractive ? color : style.borderColor,\n };\n container = mergeDesignSystemViews(\n { container: themeContainer },\n { container: decoration },\n { container }\n ).container;\n }\n\n return (\n <Horizontal\n gap={8}\n width=\"100%\"\n // Fields set `width: 100%` and then add their own padding/border, so they\n // only fit their container under border-box. Declared here rather than\n // relying on a host `* { box-sizing: border-box }` reset, whose absence\n // otherwise makes every field overflow its parent by padding + border.\n boxSizing=\"border-box\"\n display=\"flex\"\n flexWrap=\"nowrap\"\n alignItems=\"center\"\n justifyContent=\"flex-start\"\n borderStyle=\"solid\"\n borderColor={color}\n backgroundColor={isDark ? 'color-gray-900' : 'color-white'}\n fontSize={Typography.fontSizes[size]}\n cursor={isDisabled ? 'not-allowed' : isReadOnly ? 'auto' : 'text'}\n opacity={isDisabled ? 0.7 : 1}\n _focusWithin={{ outline: '2px solid theme-primary', outlineOffset: 2 }}\n transition=\"border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease\"\n // Sizing belongs to the shell, not to each field: without it every field\n // rendered at roughly `md` height whatever size was asked for. Placed\n // before `views`/`props` so a caller can still override.\n {...fieldSizeProps(size)}\n {...(typeof shadow === 'object' && shadow !== null ? shadow : {})}\n {...Shapes[shape]}\n {...(!themeContainer && variantStyle)}\n {...container}\n {...props}\n >\n {children}\n </Horizontal>\n );\n};\n",
|
|
168
171
|
"type": "registry:ui"
|
|
169
172
|
},
|
|
170
173
|
{
|
|
171
174
|
"path": "src/components/Input/FieldContent/FieldContent/FieldContent.props.ts",
|
|
172
|
-
"content": "import React from 'react';\nimport { Shape, Size, TextFieldStyles, Variant } from '../../Input.type';\nimport { Shadow, ViewProps } from 'app-studio';\nimport { Elevation } from '../../../../utils/elevation';\n\nexport interface ContentProps extends Omit<ViewProps, 'size' | 'shadow'> {\n /**\n * Shadow applied to the field shell. Accepts the design-system primitives\n * (boolean / number / Shadow), the consumer's elevation token, or a raw\n * ViewProps-shaped style object used as a shadow descriptor.\n */\n shadow?: boolean | number | Shadow | Elevation | ViewProps;\n /**\n * The color of the Content component.\n */\n color?: string;\n /**\n * The content to be rendered inside the Content component.\n */\n children?: React.ReactNode;\n /**\n * Indicates whether the field has an error.\n */\n error?: boolean;\n /**\n * Indicates whether the field has label\n */\n showLabel?: boolean;\n /**\n * Determines whether the Content component is disabled. Default value is false.\n */\n isDisabled?: boolean;\n /**\n * Determines wheter the field is focused or not.\n */\n isFocused?: boolean;\n /**\n * Determines whether the Content component is currently being hovered over.\n */\n isHovered?: boolean;\n /**\n * Determines whether the Content component is read-only. Default value is false.\n */\n isReadOnly?: boolean;\n /**\n * The label associated with the Content component.\n */\n label?: string;\n /**\n * The default value of the field. Accepts the same shape as\n * HTMLInputElement.value (including `readonly string[]` for compatibility\n * with React 19's stricter Input typing).\n */\n value?: string | number | readonly string[];\n /**\n * Changes the Input style\n */\n variant?: Variant;\n /**\n * The shape of the Content component.\n */\n shape?: Shape;\n /**\n * The size of the Content component. Default value is \"md\".\n */\n size?: Size;\n /**\n * CSS styles applied to the Content component. Default value is an empty object.\n */\n views?: TextFieldStyles;\n}\n",
|
|
175
|
+
"content": "import React from 'react';\nimport { Shape, Size, TextFieldStyles, Variant } from '../../Input.type';\nimport { Shadow, ViewProps } from 'app-studio';\nimport { Elevation } from '../../../../utils/elevation';\n\nexport interface ContentProps extends Omit<ViewProps, 'size' | 'shadow'> {\n themeContainer?: ViewProps;\n /**\n * Shadow applied to the field shell. Accepts the design-system primitives\n * (boolean / number / Shadow), the consumer's elevation token, or a raw\n * ViewProps-shaped style object used as a shadow descriptor.\n */\n shadow?: boolean | number | Shadow | Elevation | ViewProps;\n /**\n * The color of the Content component.\n */\n color?: string;\n /**\n * The content to be rendered inside the Content component.\n */\n children?: React.ReactNode;\n /**\n * Indicates whether the field has an error.\n */\n error?: boolean;\n /**\n * Indicates whether the field has label\n */\n showLabel?: boolean;\n /**\n * Determines whether the Content component is disabled. Default value is false.\n */\n isDisabled?: boolean;\n /**\n * Determines wheter the field is focused or not.\n */\n isFocused?: boolean;\n /**\n * Determines whether the Content component is currently being hovered over.\n */\n isHovered?: boolean;\n /**\n * Determines whether the Content component is read-only. Default value is false.\n */\n isReadOnly?: boolean;\n /**\n * The label associated with the Content component.\n */\n label?: string;\n /**\n * The default value of the field. Accepts the same shape as\n * HTMLInputElement.value (including `readonly string[]` for compatibility\n * with React 19's stricter Input typing).\n */\n value?: string | number | readonly string[];\n /**\n * Changes the Input style\n */\n variant?: Variant;\n /**\n * The shape of the Content component.\n */\n shape?: Shape;\n /**\n * The size of the Content component. Default value is \"md\".\n */\n size?: Size;\n /**\n * CSS styles applied to the Content component. Default value is an empty object.\n */\n views?: TextFieldStyles;\n}\n",
|
|
173
176
|
"type": "registry:ui"
|
|
174
177
|
},
|
|
175
178
|
{
|
|
@@ -227,6 +230,11 @@
|
|
|
227
230
|
"content": "import { ViewProps } from 'app-studio';\n\nexport type Variant = 'outline' | 'default' | 'none';\n\nexport type Shape = 'default' | 'square' | 'rounded' | 'pill';\n\nexport type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\nexport type TextFieldStyles = {\n text?: ViewProps;\n label?: ViewProps;\n error?: ViewProps;\n helperText?: ViewProps;\n container?: ViewProps;\n};\n\nexport type Wrap = 'wrap' | 'nowrap' | 'wrap-reverse';\n\nexport type Justify =\n | 'flex-start'\n | 'center'\n | 'flex-end'\n | 'space-between'\n | 'space-around'\n | 'space-evenly';\n",
|
|
228
231
|
"type": "registry:ui"
|
|
229
232
|
},
|
|
233
|
+
{
|
|
234
|
+
"path": "src/components/Input/useFieldDesignSystemProps.ts",
|
|
235
|
+
"content": "import type { ViewProps } from 'app-studio';\nimport {\n mergeDesignSystemViews,\n useDesignSystemComponentLayers,\n} from '../../design-system/theme';\n\nexport function useFieldDesignSystemProps<\n T extends { views?: { container?: ViewProps } }\n>(\n name: 'input' | 'select',\n props: T\n): { props: T; themeContainer?: ViewProps } {\n const layers = useDesignSystemComponentLayers(name, props);\n if (!layers.themeViews) return { props: layers.props };\n\n const { container = {}, ...otherThemeViews } = layers.themeViews;\n return {\n props: {\n ...layers.props,\n views: mergeDesignSystemViews(\n otherThemeViews as Partial<NonNullable<T['views']>>,\n layers.props.views\n ),\n },\n themeContainer: container,\n };\n}\n",
|
|
236
|
+
"type": "registry:ui"
|
|
237
|
+
},
|
|
230
238
|
{
|
|
231
239
|
"path": "src/components/pilot/select.ts",
|
|
232
240
|
"content": "export * from '../Form/Select/Select';\nexport type { SelectProps } from '../Form/Select/Select/Select.props';\n",
|
|
@@ -16,7 +16,11 @@
|
|
|
16
16
|
"appStudio": {
|
|
17
17
|
"entry": "src/components/pilot/settings-panel.ts",
|
|
18
18
|
"engine": ">=0.9.5",
|
|
19
|
-
"
|
|
19
|
+
"engineByPlatform": {
|
|
20
|
+
"ios": ">=0.10.0",
|
|
21
|
+
"android": ">=0.10.0"
|
|
22
|
+
},
|
|
23
|
+
"version": "0.12.1",
|
|
20
24
|
"license": "MIT",
|
|
21
25
|
"platforms": [
|
|
22
26
|
"web",
|
|
@@ -39,7 +43,7 @@
|
|
|
39
43
|
},
|
|
40
44
|
{
|
|
41
45
|
"path": "src/components/pilot/blocks/SettingsPanel.tsx",
|
|
42
|
-
"content": "import React from 'react';\nimport { Text, Vertical } from 'app-studio';\nimport { Card } from '../card';\nimport { Select } from '../select';\nimport { Switch } from '../switch';\n\nconst appearances = [\n { label: 'System', value: 'system' },\n { label: 'Light', value: 'light' },\n { label: 'Dark', value: 'dark' },\n];\n\nexport interface SettingsPanelProps {\n appearance: string;\n notifications: boolean;\n onAppearanceChange: (appearance: string) => void;\n onNotificationsChange: (enabled: boolean) => void;\n}\n\nexport function SettingsPanel({\n appearance,\n notifications,\n onAppearanceChange,\n onNotificationsChange,\n}: SettingsPanelProps) {\n return (\n <Card>\n <Card.Header>\n <Text fontWeight=\"bold\"
|
|
46
|
+
"content": "import React from 'react';\nimport { Text, Vertical } from 'app-studio';\nimport { Card } from '../card';\nimport { Select } from '../select';\nimport { Switch } from '../switch';\n\nconst appearances = [\n { label: 'System', value: 'system' },\n { label: 'Light', value: 'light' },\n { label: 'Dark', value: 'dark' },\n];\n\nexport interface SettingsPanelProps {\n appearance: string;\n notifications: boolean;\n onAppearanceChange: (appearance: string) => void;\n onNotificationsChange: (enabled: boolean) => void;\n}\n\nexport function SettingsPanel({\n appearance,\n notifications,\n onAppearanceChange,\n onNotificationsChange,\n}: SettingsPanelProps) {\n return (\n <Card>\n <Card.Header>\n <Text fontWeight=\"bold\" color=\"theme-text\">\n Settings\n </Text>\n </Card.Header>\n <Card.Content>\n <Vertical gap={12}>\n <Select\n label=\"Appearance\"\n options={appearances}\n value={appearance}\n onChange={onAppearanceChange}\n />\n <Switch\n label=\"Notifications\"\n isChecked={notifications}\n onChange={onNotificationsChange}\n />\n </Vertical>\n </Card.Content>\n </Card>\n );\n}\n",
|
|
43
47
|
"type": "registry:block"
|
|
44
48
|
},
|
|
45
49
|
{
|
|
@@ -17,7 +17,11 @@
|
|
|
17
17
|
"appStudio": {
|
|
18
18
|
"entry": "src/components/pilot/sign-in.ts",
|
|
19
19
|
"engine": ">=0.9.5",
|
|
20
|
-
"
|
|
20
|
+
"engineByPlatform": {
|
|
21
|
+
"ios": ">=0.10.0",
|
|
22
|
+
"android": ">=0.10.0"
|
|
23
|
+
},
|
|
24
|
+
"version": "0.12.1",
|
|
21
25
|
"license": "MIT",
|
|
22
26
|
"platforms": [
|
|
23
27
|
"web",
|
|
@@ -40,7 +44,7 @@
|
|
|
40
44
|
},
|
|
41
45
|
{
|
|
42
46
|
"path": "src/components/pilot/blocks/SignIn.tsx",
|
|
43
|
-
"content": "import React, { useState } from 'react';\nimport { Form, Text } from 'app-studio';\nimport { Alert } from '../alert';\nimport { Button } from '../button';\nimport { Card } from '../card';\nimport { TextField } from '../text-field';\n\nexport interface SignInProps {\n onSubmit: (credentials: {\n email: string;\n password: string;\n }) => void | Promise<void>;\n}\n\nexport function SignIn({ onSubmit }: SignInProps) {\n const [email, setEmail] = useState('');\n const [password, setPassword] = useState('');\n const [pending, setPending] = useState(false);\n const [error, setError] = useState('');\n\n async function submit() {\n if (pending) return;\n const address = email.trim();\n if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(address) || !password) {\n setError('Enter a valid email address and password.');\n return;\n }\n setPending(true);\n setError('');\n try {\n await onSubmit({ email: address, password });\n setPassword('');\n } catch {\n setError('Sign-in failed. Please try again.');\n } finally {\n setPending(false);\n }\n }\n\n return (\n <Card>\n <Card.Header>\n <Text fontWeight=\"bold\"
|
|
47
|
+
"content": "import React, { useState } from 'react';\nimport { Form, Text } from 'app-studio';\nimport { Alert } from '../alert';\nimport { Button } from '../button';\nimport { Card } from '../card';\nimport { TextField } from '../text-field';\n\nexport interface SignInProps {\n onSubmit: (credentials: {\n email: string;\n password: string;\n }) => void | Promise<void>;\n}\n\nexport function SignIn({ onSubmit }: SignInProps) {\n const [email, setEmail] = useState('');\n const [password, setPassword] = useState('');\n const [pending, setPending] = useState(false);\n const [error, setError] = useState('');\n\n async function submit() {\n if (pending) return;\n const address = email.trim();\n if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(address) || !password) {\n setError('Enter a valid email address and password.');\n return;\n }\n setPending(true);\n setError('');\n try {\n await onSubmit({ email: address, password });\n setPassword('');\n } catch {\n setError('Sign-in failed. Please try again.');\n } finally {\n setPending(false);\n }\n }\n\n return (\n <Card>\n <Card.Header>\n <Text fontWeight=\"bold\" color=\"theme-text\">\n Sign in\n </Text>\n </Card.Header>\n <Card.Content>\n <Form\n display=\"flex\"\n flexDirection=\"column\"\n gap={12}\n noValidate\n onSubmit={(event: React.FormEvent) => {\n event.preventDefault();\n void submit();\n }}\n >\n <TextField\n label=\"Email\"\n type=\"email\"\n value={email}\n onChange={setEmail}\n isRequired\n isDisabled={pending}\n />\n <TextField\n label=\"Password\"\n type=\"password\"\n value={password}\n onChange={setPassword}\n isRequired\n isDisabled={pending}\n />\n {error && <Alert variant=\"error\" title={error} />}\n <Button\n isLoading={pending}\n aria-busy={pending || undefined}\n type=\"submit\"\n onClick={(event?: { preventDefault?: () => void }) => {\n event?.preventDefault?.();\n void submit();\n }}\n >\n Sign in\n </Button>\n </Form>\n </Card.Content>\n </Card>\n );\n}\n",
|
|
44
48
|
"type": "registry:block"
|
|
45
49
|
},
|
|
46
50
|
{
|