@babylonlabs-io/core-ui 1.12.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Accordion/Accordion.d.ts +2 -2
- package/dist/components/Accordion/Accordion.js +25 -0
- package/dist/components/Accordion/Accordion.stories.d.ts +6 -0
- package/dist/components/Accordion/Accordion.stories.js +16 -0
- package/dist/components/Accordion/components/AccordionDetails.d.ts +1 -1
- package/dist/components/Accordion/components/AccordionDetails.js +29 -0
- package/dist/components/Accordion/components/AccordionSummary.d.ts +1 -1
- package/dist/components/Accordion/components/AccordionSummary.js +10 -0
- package/dist/components/Accordion/hooks/useHeightObserver.d.ts +1 -1
- package/dist/components/Accordion/hooks/useHeightObserver.js +24 -0
- package/dist/components/Accordion/index.d.ts +4 -3
- package/dist/components/Accordion/index.js +4 -0
- package/dist/components/AmountItem/AmountItem.d.ts +1 -1
- package/dist/components/AmountItem/AmountItem.js +5 -0
- package/dist/components/AmountItem/AmountItem.stories.d.ts +6 -0
- package/dist/components/AmountItem/AmountItem.stories.js +29 -0
- package/dist/components/AmountItem/index.d.ts +1 -1
- package/dist/components/AmountItem/index.js +1 -0
- package/dist/components/Avatar/Avatar.d.ts +2 -1
- package/dist/components/Avatar/Avatar.js +6 -0
- package/dist/components/Avatar/Avatar.stories.d.ts +7 -0
- package/dist/components/Avatar/Avatar.stories.js +18 -0
- package/dist/components/Avatar/AvatarGroup.d.ts +3 -2
- package/dist/components/Avatar/AvatarGroup.js +15 -0
- package/dist/components/Avatar/AvatarGroup.stories.d.ts +6 -0
- package/dist/components/Avatar/AvatarGroup.stories.js +21 -0
- package/dist/components/Avatar/index.d.ts +2 -2
- package/dist/components/Avatar/index.js +2 -0
- package/dist/components/Badge/Badge.d.ts +2 -1
- package/dist/components/Badge/Badge.js +10 -0
- package/dist/components/Badge/Badge.stories.d.ts +6 -0
- package/dist/components/Badge/Badge.stories.js +14 -0
- package/dist/components/Badge/index.d.ts +1 -1
- package/dist/components/Badge/index.js +1 -0
- package/dist/components/Button/Button.d.ts +3 -2
- package/dist/components/Button/Button.js +8 -0
- package/dist/components/Button/Button.stories.d.ts +6 -0
- package/dist/components/Button/Button.stories.js +9 -0
- package/dist/components/Button/IconButton.d.ts +2 -1
- package/dist/components/Button/IconButton.js +6 -0
- package/dist/components/Button/IconButton.stories.d.ts +6 -0
- package/dist/components/Button/IconButton.stories.js +13 -0
- package/dist/components/Button/WalletDisconnectButton.d.ts +2 -2
- package/dist/components/Button/WalletDisconnectButton.js +8 -0
- package/dist/components/Button/index.d.ts +3 -3
- package/dist/components/Button/index.js +3 -0
- package/dist/components/Card/Card.d.ts +4 -3
- package/dist/components/Card/Card.js +6 -0
- package/dist/components/Card/Card.stories.d.ts +6 -0
- package/dist/components/Card/Card.stories.js +10 -0
- package/dist/components/Card/index.d.ts +1 -1
- package/dist/components/Card/index.js +1 -0
- package/dist/components/Chip/Chip.d.ts +2 -1
- package/dist/components/Chip/Chip.js +6 -0
- package/dist/components/Chip/Chip.stories.d.ts +6 -0
- package/dist/components/Chip/Chip.stories.js +9 -0
- package/dist/components/Chip/index.d.ts +1 -1
- package/dist/components/Chip/index.js +1 -0
- package/dist/components/Copy/Copy.d.ts +1 -1
- package/dist/components/Copy/Copy.js +29 -0
- package/dist/components/Copy/index.js +1 -0
- package/dist/components/CounterButton/CounterButton.js +8 -0
- package/dist/components/CounterButton/CounterButton.stories.d.ts +10 -0
- package/dist/components/CounterButton/CounterButton.stories.js +41 -0
- package/dist/components/CounterButton/index.d.ts +1 -1
- package/dist/components/CounterButton/index.js +1 -0
- package/dist/components/Dialog/Dialog.d.ts +1 -1
- package/dist/components/Dialog/Dialog.js +9 -0
- package/dist/components/Dialog/Dialog.stories.d.ts +7 -0
- package/dist/components/Dialog/Dialog.stories.js +41 -0
- package/dist/components/Dialog/MobileDialog.d.ts +1 -1
- package/dist/components/Dialog/MobileDialog.js +10 -0
- package/dist/components/Dialog/MobileDialog.stories.d.ts +6 -0
- package/dist/components/Dialog/MobileDialog.stories.js +27 -0
- package/dist/components/Dialog/components/Backdrop.d.ts +2 -1
- package/dist/components/Dialog/components/Backdrop.js +4 -0
- package/dist/components/Dialog/components/DialogBody.d.ts +1 -1
- package/dist/components/Dialog/components/DialogBody.js +3 -0
- package/dist/components/Dialog/components/DialogFooter.d.ts +1 -1
- package/dist/components/Dialog/components/DialogFooter.js +3 -0
- package/dist/components/Dialog/components/DialogHeader.d.ts +1 -1
- package/dist/components/Dialog/components/DialogHeader.js +5 -0
- package/dist/components/Dialog/index.d.ts +6 -5
- package/dist/components/Dialog/index.js +6 -0
- package/dist/components/DisplayHash/DisplayHash.d.ts +1 -1
- package/dist/components/DisplayHash/DisplayHash.js +10 -0
- package/dist/components/DisplayHash/index.js +1 -0
- package/dist/components/FeeItem/FeeItem.d.ts +1 -1
- package/dist/components/FeeItem/FeeItem.js +6 -0
- package/dist/components/FeeItem/FeeItem.stories.d.ts +7 -0
- package/dist/components/FeeItem/FeeItem.stories.js +19 -0
- package/dist/components/Form/Checkbox.d.ts +2 -2
- package/dist/components/Form/Checkbox.js +10 -0
- package/dist/components/Form/Checkbox.stories.d.ts +6 -0
- package/dist/components/Form/Checkbox.stories.js +13 -0
- package/dist/components/Form/FormControl.d.ts +2 -1
- package/dist/components/Form/FormControl.js +6 -0
- package/dist/components/Form/FormControl.stories.d.ts +8 -0
- package/dist/components/Form/FormControl.stories.js +30 -0
- package/dist/components/Form/Input.d.ts +3 -2
- package/dist/components/Form/Input.js +8 -0
- package/dist/components/Form/Input.stories.d.ts +10 -0
- package/dist/components/Form/Input.stories.js +43 -0
- package/dist/components/Form/Radio.d.ts +2 -2
- package/dist/components/Form/Radio.js +10 -0
- package/dist/components/Form/Radio.stories.d.ts +6 -0
- package/dist/components/Form/Radio.stories.js +13 -0
- package/dist/components/Form/Select.d.ts +3 -2
- package/dist/components/Form/Select.js +39 -0
- package/dist/components/Form/Select.stories.d.ts +9 -0
- package/dist/components/Form/Select.stories.js +47 -0
- package/dist/components/Form/components/Toggle.d.ts +3 -2
- package/dist/components/Form/components/Toggle.js +22 -0
- package/dist/components/Form/index.d.ts +5 -5
- package/dist/components/Form/index.js +5 -0
- package/dist/components/Heading/Heading.d.ts +3 -2
- package/dist/components/Heading/Heading.js +9 -0
- package/dist/components/Heading/Heading.stories.d.ts +6 -0
- package/dist/components/Heading/Heading.stories.js +10 -0
- package/dist/components/Heading/index.d.ts +1 -1
- package/dist/components/Heading/index.js +1 -0
- package/dist/components/Icons/ThemedIcon.js +25 -0
- package/dist/components/Icons/common/CloseIcon.d.ts +1 -1
- package/dist/components/Icons/common/CloseIcon.js +7 -0
- package/dist/components/Icons/common/CopyIcon.d.ts +1 -1
- package/dist/components/Icons/common/CopyIcon.js +7 -0
- package/dist/components/Icons/index.d.ts +6 -6
- package/dist/components/Icons/index.js +18 -0
- package/dist/components/Icons/wallet/BitcoinPublicKeyIcon.d.ts +1 -1
- package/dist/components/Icons/wallet/BitcoinPublicKeyIcon.js +5 -0
- package/dist/components/Icons/wallet/LinkWalletIcon.d.ts +1 -1
- package/dist/components/Icons/wallet/LinkWalletIcon.js +5 -0
- package/dist/components/Icons/wallet/UsingInscriptionIcon.d.ts +1 -1
- package/dist/components/Icons/wallet/UsingInscriptionIcon.js +5 -0
- package/dist/components/List/List.d.ts +3 -2
- package/dist/components/List/List.js +16 -0
- package/dist/components/List/List.stories.d.ts +11 -0
- package/dist/components/List/List.stories.js +69 -0
- package/dist/components/List/components/ListItem.js +6 -0
- package/dist/components/List/index.d.ts +2 -2
- package/dist/components/List/index.js +2 -0
- package/dist/components/ListLegacy/ListLegacy.d.ts +3 -2
- package/dist/components/ListLegacy/ListLegacy.js +16 -0
- package/dist/components/ListLegacy/ListLegacy.stories.d.ts +11 -0
- package/dist/components/ListLegacy/ListLegacy.stories.js +71 -0
- package/dist/components/ListLegacy/components/ListItemLegacy.js +6 -0
- package/dist/components/ListLegacy/index.d.ts +2 -2
- package/dist/components/ListLegacy/index.js +2 -0
- package/dist/components/Loader/Loader.d.ts +1 -0
- package/dist/components/Loader/Loader.js +6 -0
- package/dist/components/Loader/Loader.stories.d.ts +6 -0
- package/dist/components/Loader/Loader.stories.js +11 -0
- package/dist/components/Loader/index.d.ts +1 -1
- package/dist/components/Loader/index.js +1 -0
- package/dist/components/Menu/Menu.d.ts +2 -2
- package/dist/components/Menu/Menu.js +29 -0
- package/dist/components/Menu/Menu.stories.d.ts +6 -0
- package/dist/components/Menu/Menu.stories.js +38 -0
- package/dist/components/Menu/MenuContext.d.ts +1 -1
- package/dist/components/Menu/MenuContext.js +9 -0
- package/dist/components/Menu/MenuDrawer.d.ts +1 -1
- package/dist/components/Menu/MenuDrawer.js +22 -0
- package/dist/components/Menu/MenuItem.d.ts +1 -1
- package/dist/components/Menu/MenuItem.js +20 -0
- package/dist/components/Menu/SubMenu.d.ts +1 -1
- package/dist/components/Menu/SubMenu.js +12 -0
- package/dist/components/Menu/SubMenuItem.d.ts +1 -1
- package/dist/components/Menu/SubMenuItem.js +6 -0
- package/dist/components/Menu/index.d.ts +6 -6
- package/dist/components/Menu/index.js +6 -0
- package/dist/components/Popover/Popover.d.ts +3 -2
- package/dist/components/Popover/Popover.js +16 -0
- package/dist/components/Popover/Popover.stories.d.ts +6 -0
- package/dist/components/Popover/Popover.stories.js +25 -0
- package/dist/components/Popover/index.d.ts +1 -1
- package/dist/components/Popover/index.js +1 -0
- package/dist/components/Portal/Portal.d.ts +2 -2
- package/dist/components/Portal/Portal.js +45 -0
- package/dist/components/Portal/index.d.ts +1 -1
- package/dist/components/Portal/index.js +1 -0
- package/dist/components/Spacer/Spacer.d.ts +1 -1
- package/dist/components/Spacer/Spacer.js +9 -0
- package/dist/components/Spacer/index.js +1 -0
- package/dist/components/SubSection/SubSection.d.ts +1 -1
- package/dist/components/SubSection/SubSection.js +3 -0
- package/dist/components/SubSection/SubSection.stories.d.ts +6 -0
- package/dist/components/SubSection/SubSection.stories.js +13 -0
- package/dist/components/SubSection/index.d.ts +1 -1
- package/dist/components/SubSection/index.js +1 -0
- package/dist/components/Table/Table.d.ts +2 -1
- package/dist/components/Table/Table.js +37 -0
- package/dist/components/Table/Table.stories.d.ts +7 -0
- package/dist/components/Table/Table.stories.js +131 -0
- package/dist/components/Table/components/Cell.d.ts +1 -1
- package/dist/components/Table/components/Cell.js +6 -0
- package/dist/components/Table/components/Column.d.ts +1 -1
- package/dist/components/Table/components/Column.js +17 -0
- package/dist/components/Table/components/Row.d.ts +1 -1
- package/dist/components/Table/components/Row.js +6 -0
- package/dist/components/Table/index.d.ts +4 -4
- package/dist/components/Table/index.js +4 -0
- package/dist/components/Table/types/index.d.ts +1 -1
- package/dist/components/Table/types/index.js +1 -0
- package/dist/components/Text/Text.d.ts +3 -2
- package/dist/components/Text/Text.js +11 -0
- package/dist/components/Text/Text.stories.d.ts +6 -0
- package/dist/components/Text/Text.stories.js +10 -0
- package/dist/components/Text/index.d.ts +1 -1
- package/dist/components/Text/index.js +1 -0
- package/dist/components/Toggle/Toggle.d.ts +1 -0
- package/dist/components/Toggle/Toggle.js +12 -0
- package/dist/components/Toggle/Toggle.stories.d.ts +6 -0
- package/dist/components/Toggle/Toggle.stories.js +14 -0
- package/dist/components/Toggle/index.d.ts +1 -1
- package/dist/components/Toggle/index.js +1 -0
- package/dist/components/Warning/Warning.d.ts +2 -1
- package/dist/components/Warning/Warning.js +6 -0
- package/dist/components/Warning/Warning.stories.d.ts +9 -0
- package/dist/components/Warning/Warning.stories.js +26 -0
- package/dist/components/Warning/index.d.ts +1 -1
- package/dist/components/Warning/index.js +1 -0
- package/dist/components/index.js +3 -0
- package/dist/context/Dialog.context.d.ts +2 -2
- package/dist/context/Dialog.context.js +33 -0
- package/dist/context/Table.context.d.ts +2 -2
- package/dist/context/Table.context.js +8 -0
- package/dist/elements/FinalityProviderItem/FinalityProviderItem.js +30 -0
- package/dist/elements/FinalityProviderItem/FinalityProviderItem.stories.d.ts +12 -0
- package/dist/elements/FinalityProviderItem/FinalityProviderItem.stories.js +97 -0
- package/dist/elements/FinalityProviderItem/index.d.ts +1 -1
- package/dist/elements/FinalityProviderItem/index.js +1 -0
- package/dist/elements/FinalityProviderLogo/FinalityProviderLogo.js +24 -0
- package/dist/elements/FinalityProviderLogo/FinalityProviderLogo.stories.d.ts +13 -0
- package/dist/elements/FinalityProviderLogo/FinalityProviderLogo.stories.js +61 -0
- package/dist/elements/FinalityProviderLogo/index.d.ts +1 -1
- package/dist/elements/FinalityProviderLogo/index.js +1 -0
- package/dist/elements/Icons/ChevronRightIcon.d.ts +1 -1
- package/dist/elements/Icons/ChevronRightIcon.js +2 -0
- package/dist/elements/Icons/SettingsIcon.d.ts +1 -1
- package/dist/elements/Icons/SettingsIcon.js +2 -0
- package/dist/elements/Icons/index.js +2 -0
- package/dist/elements/ProvidersList/ProvidersList.js +9 -0
- package/dist/elements/ProvidersList/ProvidersList.stories.d.ts +10 -0
- package/dist/elements/ProvidersList/ProvidersList.stories.js +139 -0
- package/dist/elements/ProvidersList/index.d.ts +1 -1
- package/dist/elements/ProvidersList/index.js +1 -0
- package/dist/elements/Table/Table.d.ts +1 -1
- package/dist/elements/Table/Table.js +14 -0
- package/dist/elements/Table/Table.stories.d.ts +8 -0
- package/dist/elements/Table/Table.stories.js +50 -0
- package/dist/elements/Table/index.d.ts +1 -1
- package/dist/elements/Table/index.js +1 -0
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/useClickOutside.js +17 -0
- package/dist/hooks/useControlledState.js +13 -0
- package/dist/hooks/useCopy.js +48 -0
- package/dist/hooks/useIsMobile.js +33 -0
- package/dist/hooks/useMemoizedArray.js +22 -0
- package/dist/hooks/useModalManager.js +28 -0
- package/dist/hooks/useResizeObserver.js +21 -0
- package/dist/hooks/useTableScroll.d.ts +1 -1
- package/dist/hooks/useTableScroll.js +22 -0
- package/dist/hooks/useTableSort.d.ts +1 -1
- package/dist/hooks/useTableSort.js +46 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +45 -44
- package/dist/index.es.js +900 -887
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +45 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/dist/utils/constants.js +3 -0
- package/dist/utils/css.js +6 -0
- package/dist/utils/helpers.js +71 -0
- package/dist/utils/trim.js +14 -0
- package/dist/widgets/form/CheckboxField/CheckboxField.d.ts +1 -1
- package/dist/widgets/form/CheckboxField/CheckboxField.js +7 -0
- package/dist/widgets/form/CheckboxField/CheckboxField.stories.d.ts +6 -0
- package/dist/widgets/form/CheckboxField/CheckboxField.stories.js +17 -0
- package/dist/widgets/form/CheckboxField/index.d.ts +1 -1
- package/dist/widgets/form/CheckboxField/index.js +1 -0
- package/dist/widgets/form/Form/Form.d.ts +3 -3
- package/dist/widgets/form/Form/Form.js +20 -0
- package/dist/widgets/form/Form/Form.stories.d.ts +6 -0
- package/dist/widgets/form/Form/Form.stories.js +27 -0
- package/dist/widgets/form/Form/index.d.ts +1 -1
- package/dist/widgets/form/Form/index.js +1 -0
- package/dist/widgets/form/HiddenField/HiddenField.d.ts +1 -1
- package/dist/widgets/form/HiddenField/HiddenField.js +13 -0
- package/dist/widgets/form/HiddenField/HiddenField.stories.d.ts +6 -0
- package/dist/widgets/form/HiddenField/HiddenField.stories.js +17 -0
- package/dist/widgets/form/HiddenField/index.d.ts +1 -1
- package/dist/widgets/form/HiddenField/index.js +1 -0
- package/dist/widgets/form/NumberField/NumberField.d.ts +2 -2
- package/dist/widgets/form/NumberField/NumberField.js +15 -0
- package/dist/widgets/form/NumberField/NumberField.stories.d.ts +6 -0
- package/dist/widgets/form/NumberField/NumberField.stories.js +31 -0
- package/dist/widgets/form/NumberField/index.d.ts +1 -1
- package/dist/widgets/form/NumberField/index.js +1 -0
- package/dist/widgets/form/RadioField/RadioField.d.ts +1 -1
- package/dist/widgets/form/RadioField/RadioField.js +7 -0
- package/dist/widgets/form/RadioField/RadioField.stories.d.ts +6 -0
- package/dist/widgets/form/RadioField/RadioField.stories.js +14 -0
- package/dist/widgets/form/RadioField/index.d.ts +1 -1
- package/dist/widgets/form/RadioField/index.js +1 -0
- package/dist/widgets/form/SelectField/SelectField.d.ts +3 -3
- package/dist/widgets/form/SelectField/SelectField.js +13 -0
- package/dist/widgets/form/SelectField/SelectField.stories.d.ts +6 -0
- package/dist/widgets/form/SelectField/SelectField.stories.js +33 -0
- package/dist/widgets/form/SelectField/index.d.ts +1 -1
- package/dist/widgets/form/SelectField/index.js +1 -0
- package/dist/widgets/form/TextField/TextField.d.ts +2 -2
- package/dist/widgets/form/TextField/TextField.js +9 -0
- package/dist/widgets/form/TextField/TextField.stories.d.ts +6 -0
- package/dist/widgets/form/TextField/TextField.stories.js +28 -0
- package/dist/widgets/form/TextField/index.d.ts +1 -1
- package/dist/widgets/form/TextField/index.js +1 -0
- package/dist/widgets/form/hooks.d.ts +3 -3
- package/dist/widgets/form/hooks.js +29 -0
- package/dist/widgets/form/types.js +1 -0
- package/dist/widgets/sections/AmountSubsection/AmountSubsection.js +29 -0
- package/dist/widgets/sections/AmountSubsection/AmountSubsection.stories.d.ts +6 -0
- package/dist/widgets/sections/AmountSubsection/AmountSubsection.stories.js +35 -0
- package/dist/widgets/sections/AmountSubsection/index.d.ts +1 -1
- package/dist/widgets/sections/AmountSubsection/index.js +1 -0
- package/dist/widgets/sections/FeesSection/BBNFeeAmount.js +7 -0
- package/dist/widgets/sections/FeesSection/BTCFeeAmount.js +19 -0
- package/dist/widgets/sections/FeesSection/BTCFeeRate.js +7 -0
- package/dist/widgets/sections/FeesSection/FeesSection.js +10 -0
- package/dist/widgets/sections/FeesSection/FeesSection.stories.d.ts +6 -0
- package/dist/widgets/sections/FeesSection/FeesSection.stories.js +14 -0
- package/dist/widgets/sections/FeesSection/Total.js +20 -0
- package/dist/widgets/sections/FeesSection/index.d.ts +6 -6
- package/dist/widgets/sections/FeesSection/index.js +6 -0
- package/dist/widgets/sections/FinalityProviderSubsection/FinalityProviderSubsection.d.ts +1 -1
- package/dist/widgets/sections/FinalityProviderSubsection/FinalityProviderSubsection.js +9 -0
- package/dist/widgets/sections/FinalityProviderSubsection/FinalityProviderSubsection.stories.d.ts +13 -0
- package/dist/widgets/sections/FinalityProviderSubsection/FinalityProviderSubsection.stories.js +191 -0
- package/dist/widgets/sections/FinalityProviderSubsection/index.d.ts +1 -1
- package/dist/widgets/sections/FinalityProviderSubsection/index.js +1 -0
- package/dist/widgets/sections/PreviewModal/PreviewModal.d.ts +1 -1
- package/dist/widgets/sections/PreviewModal/PreviewModal.js +37 -0
- package/dist/widgets/sections/PreviewModal/PreviewModal.stories.d.ts +6 -0
- package/dist/widgets/sections/PreviewModal/PreviewModal.stories.js +47 -0
- package/dist/widgets/sections/PreviewModal/index.d.ts +1 -1
- package/dist/widgets/sections/PreviewModal/index.js +1 -0
- package/dist/widgets/sections/RewardsPreviewModal/RewardsPreviewModal.d.ts +1 -1
- package/dist/widgets/sections/RewardsPreviewModal/RewardsPreviewModal.js +16 -0
- package/dist/widgets/sections/RewardsPreviewModal/RewardsPreviewModal.stories.d.ts +7 -0
- package/dist/widgets/sections/RewardsPreviewModal/RewardsPreviewModal.stories.js +60 -0
- package/dist/widgets/sections/RewardsSubsection/RewardsSubsection.js +13 -0
- package/dist/widgets/sections/RewardsSubsection/RewardsSubsection.stories.d.ts +7 -0
- package/dist/widgets/sections/RewardsSubsection/RewardsSubsection.stories.js +60 -0
- package/dist/widgets/sections/RewardsSubsection/index.d.ts +1 -1
- package/dist/widgets/sections/RewardsSubsection/index.js +1 -0
- package/dist/widgets/sections/SettingMenu/SettingMenu.d.ts +3 -3
- package/dist/widgets/sections/SettingMenu/SettingMenu.js +17 -0
- package/dist/widgets/sections/SettingMenu/SettingMenu.stories.d.ts +5 -0
- package/dist/widgets/sections/SettingMenu/SettingMenu.stories.js +35 -0
- package/dist/widgets/sections/SettingMenu/components/SettingMenuCustomContent.d.ts +1 -1
- package/dist/widgets/sections/SettingMenu/components/SettingMenuCustomContent.js +2 -0
- package/dist/widgets/sections/SettingMenu/components/SettingMenuDescription.d.ts +1 -1
- package/dist/widgets/sections/SettingMenu/components/SettingMenuDescription.js +4 -0
- package/dist/widgets/sections/SettingMenu/components/SettingMenuGroup.d.ts +1 -1
- package/dist/widgets/sections/SettingMenu/components/SettingMenuGroup.js +15 -0
- package/dist/widgets/sections/SettingMenu/components/SettingMenuItem.d.ts +1 -1
- package/dist/widgets/sections/SettingMenu/components/SettingMenuItem.js +13 -0
- package/dist/widgets/sections/SettingMenu/components/SettingMenuSubMenu.d.ts +1 -1
- package/dist/widgets/sections/SettingMenu/components/SettingMenuSubMenu.js +14 -0
- package/dist/widgets/sections/SettingMenu/components/SettingMenuTitle.d.ts +1 -1
- package/dist/widgets/sections/SettingMenu/components/SettingMenuTitle.js +4 -0
- package/dist/widgets/sections/SettingMenu/components/index.d.ts +12 -12
- package/dist/widgets/sections/SettingMenu/components/index.js +6 -0
- package/dist/widgets/sections/SettingMenu/index.d.ts +14 -14
- package/dist/widgets/sections/SettingMenu/index.js +7 -0
- package/dist/widgets/sections/TableElement/TableElement.d.ts +1 -1
- package/dist/widgets/sections/TableElement/TableElement.js +6 -0
- package/dist/widgets/sections/TableElement/TableElement.stories.d.ts +9 -0
- package/dist/widgets/sections/TableElement/TableElement.stories.js +54 -0
- package/dist/widgets/sections/TableElement/index.d.ts +1 -1
- package/dist/widgets/sections/TableElement/index.js +1 -0
- package/dist/widgets/sections/WalletMenu/WalletMenu.d.ts +1 -1
- package/dist/widgets/sections/WalletMenu/WalletMenu.js +22 -0
- package/dist/widgets/sections/WalletMenu/WalletMenu.stories.d.ts +6 -0
- package/dist/widgets/sections/WalletMenu/WalletMenu.stories.js +35 -0
- package/dist/widgets/sections/WalletMenu/components/WalletInfoCard.d.ts +1 -1
- package/dist/widgets/sections/WalletMenu/components/WalletInfoCard.js +9 -0
- package/dist/widgets/sections/WalletMenu/components/WalletInfoSection.d.ts +1 -1
- package/dist/widgets/sections/WalletMenu/components/WalletInfoSection.js +8 -0
- package/dist/widgets/sections/WalletMenu/components/WalletSettingItem.d.ts +1 -1
- package/dist/widgets/sections/WalletMenu/components/WalletSettingItem.js +7 -0
- package/dist/widgets/sections/WalletMenu/components/WalletToggle.d.ts +1 -1
- package/dist/widgets/sections/WalletMenu/components/WalletToggle.js +12 -0
- package/dist/widgets/sections/WalletMenu/components/index.js +4 -0
- package/dist/widgets/sections/WalletMenu/index.js +5 -0
- package/package.json +4 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./Loader";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Loader";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useState, useRef } from "react";
|
|
3
|
+
import { twJoin } from "tailwind-merge";
|
|
4
|
+
import { Popover } from "../Popover";
|
|
5
|
+
import { MobileDialog } from "../Dialog";
|
|
6
|
+
import { MenuProvider } from "./MenuContext";
|
|
7
|
+
import { MenuDrawer } from "./MenuDrawer";
|
|
8
|
+
import { useIsMobile } from "@/hooks/useIsMobile";
|
|
9
|
+
export const Menu = ({ children, trigger, open: controlledOpen, onOpenChange, placement = "bottom-end", offset = [0, 8], className, mobileMode = "dialog", }) => {
|
|
10
|
+
const [internalOpen, setInternalOpen] = useState(false);
|
|
11
|
+
const triggerRef = useRef(null);
|
|
12
|
+
const isMobile = useIsMobile();
|
|
13
|
+
const isOpen = controlledOpen !== undefined ? controlledOpen : internalOpen;
|
|
14
|
+
const setIsOpen = (open) => {
|
|
15
|
+
if (controlledOpen === undefined) {
|
|
16
|
+
setInternalOpen(open);
|
|
17
|
+
}
|
|
18
|
+
onOpenChange?.(open);
|
|
19
|
+
};
|
|
20
|
+
const onClose = () => setIsOpen(false);
|
|
21
|
+
const menuContent = _jsx("div", { className: "relative w-full overflow-hidden", children: children });
|
|
22
|
+
const triggerElement = trigger || (_jsx("button", { className: "rounded p-2 hover:bg-gray-100 dark:hover:bg-gray-800", onClick: () => setIsOpen(!isOpen), children: "Menu" }));
|
|
23
|
+
return (_jsxs(MenuProvider, { value: { isOpen, setIsOpen, onClose, isMobile }, children: [_jsx("div", { ref: triggerRef, className: "inline-block", children: React.isValidElement(triggerElement) &&
|
|
24
|
+
React.cloneElement(triggerElement, {
|
|
25
|
+
onClick: () => setIsOpen(!isOpen),
|
|
26
|
+
"aria-haspopup": "true",
|
|
27
|
+
"aria-expanded": isOpen,
|
|
28
|
+
}) }), isMobile ? (mobileMode === "dialog" ? (_jsx(MobileDialog, { open: isOpen, onClose: onClose, className: twJoin("relative bg-[#FFFFFF] dark:bg-[#252525] text-primary-main", className), children: menuContent })) : (_jsx(MenuDrawer, { isOpen: isOpen, onClose: onClose, onBackdropClick: onClose, fullHeight: true, fullWidth: true, showBackButton: true, showDivider: false, children: menuContent }))) : (_jsx(Popover, { anchorEl: triggerRef.current, open: isOpen, offset: offset, placement: placement, onClickOutside: onClose, className: twJoin("rounded-lg border border-[#38708533] bg-[#FFFFFF] shadow-lg dark:border-[#404040] dark:bg-[#252525]", "min-w-[294px]", className), children: menuContent }))] }));
|
|
29
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Menu } from "./Menu";
|
|
4
|
+
import { MenuItem } from "./MenuItem";
|
|
5
|
+
import { SubMenu } from "./SubMenu";
|
|
6
|
+
import { SubMenuItem } from "./SubMenuItem";
|
|
7
|
+
import { Button } from "../Button";
|
|
8
|
+
import { Text } from "../Text";
|
|
9
|
+
const meta = {
|
|
10
|
+
title: "Components/Menu",
|
|
11
|
+
component: Menu,
|
|
12
|
+
tags: ["autodocs"],
|
|
13
|
+
parameters: {
|
|
14
|
+
docs: {
|
|
15
|
+
description: {
|
|
16
|
+
component: "A menu component with support for nested submenus.",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
export default meta;
|
|
22
|
+
const SettingIcon = () => (_jsx("svg", { width: "29", height: "28", viewBox: "0 0 29 28", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M24.9127 15.3708C24.9711 14.9333 25.0002 14.4812 25.0002 14C25.0002 13.5333 24.9711 13.0667 24.8982 12.6292L27.8586 10.325C28.1211 10.1208 28.194 9.72708 28.0336 9.43542L25.2336 4.59375C25.0586 4.27292 24.694 4.17083 24.3732 4.27292L20.8877 5.67292C20.1586 5.11875 19.3857 4.65208 18.5252 4.30208L18.0002 0.597916C17.9419 0.247916 17.6502 0 17.3002 0H11.7002C11.3502 0 11.0732 0.247916 11.0148 0.597916L10.4898 4.30208C9.62941 4.65208 8.84191 5.13333 8.12732 5.67292L4.64191 4.27292C4.32107 4.15625 3.95649 4.27292 3.78149 4.59375L0.996075 9.43542C0.821075 9.74167 0.879408 10.1208 1.17107 10.325L4.13149 12.6292C4.05857 13.0667 4.00024 13.5479 4.00024 14C4.00024 14.4521 4.02941 14.9333 4.10232 15.3708L1.14191 17.675C0.879408 17.8792 0.806491 18.2729 0.966908 18.5646L3.76691 23.4062C3.94191 23.7271 4.30649 23.8292 4.62732 23.7271L8.11274 22.3271C8.84191 22.8812 9.61482 23.3479 10.4752 23.6979L11.0002 27.4021C11.0732 27.7521 11.3502 28 11.7002 28H17.3002C17.6502 28 17.9419 27.7521 17.9857 27.4021L18.5107 23.6979C19.3711 23.3479 20.1586 22.8812 20.8732 22.3271L24.3586 23.7271C24.6794 23.8438 25.044 23.7271 25.219 23.4062L28.019 18.5646C28.194 18.2437 28.1211 17.8792 27.844 17.675L24.9127 15.3708ZM14.5002 19.25C11.6127 19.25 9.25024 16.8875 9.25024 14C9.25024 11.1125 11.6127 8.75 14.5002 8.75C17.3877 8.75 19.7502 11.1125 19.7502 14C19.7502 16.8875 17.3877 19.25 14.5002 19.25Z", fill: "#9E9E9E" }) }));
|
|
23
|
+
const ThemeIcon = () => (_jsxs("svg", { width: "40", height: "40", viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("rect", { width: "40", height: "40", rx: "20", fill: "#387085", "fill-opacity": "0.12" }), _jsx("path", { d: "M20 30C25.52 30 30 25.52 30 20C30 14.48 25.52 10 20 10C14.48 10 10 14.48 10 20C10 25.52 14.48 30 20 30ZM21 12.07C24.94 12.56 28 15.92 28 20C28 24.08 24.95 27.44 21 27.93V12.07Z", fill: "#387085" })] }));
|
|
24
|
+
const ReportABugIcon = () => (_jsxs("svg", { width: "40", height: "40", viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("rect", { width: "40", height: "40", rx: "20", fill: "#387085", "fill-opacity": "0.12" }), _jsx("path", { d: "M23.73 11H16.27L11 16.27V23.73L16.27 29H23.73L29 23.73V16.27L23.73 11ZM20 25.3C19.28 25.3 18.7 24.72 18.7 24C18.7 23.28 19.28 22.7 20 22.7C20.72 22.7 21.3 23.28 21.3 24C21.3 24.72 20.72 25.3 20 25.3ZM21 21H19V15H21V21Z", fill: "#387085" })] }));
|
|
25
|
+
const ChevronRightIcon = () => (_jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M9 18L15 12L9 6", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }) }));
|
|
26
|
+
export const Default = {
|
|
27
|
+
render: () => {
|
|
28
|
+
const [selectedTheme, setSelectedTheme] = useState("auto");
|
|
29
|
+
const themes = [
|
|
30
|
+
{ id: "auto", label: "Auto", description: undefined },
|
|
31
|
+
{ id: "light", label: "Light", description: undefined },
|
|
32
|
+
{ id: "dark", label: "Dark", description: undefined },
|
|
33
|
+
];
|
|
34
|
+
return (_jsx("div", { className: "p-4", children: _jsxs(Menu, { trigger: _jsx("button", { children: _jsx(SettingIcon, {}) }), children: [_jsx(Text, { variant: "body1", className: "px-7 pb-6 text-accent-primary md:hidden", children: "Settings" }), _jsxs("div", { className: "mx-[21px] rounded-lg md:mx-0", children: [_jsx(SubMenu, { name: "Theme", description: selectedTheme, icon: _jsx(ThemeIcon, {}), suffix: _jsx(ChevronRightIcon, {}), className: "bg-secondary-highlight md:bg-transparent", children: _jsx("div", { className: "flex flex-col", children: themes.map((theme) => (_jsx(SubMenuItem, { label: theme.label, description: theme?.description ?? "", selected: selectedTheme === theme.id, onClick: () => {
|
|
35
|
+
setSelectedTheme(theme.id);
|
|
36
|
+
} }, theme.id))) }) }), _jsx(MenuItem, { name: "Report a bug", icon: _jsx(ReportABugIcon, {}), suffix: _jsx(ChevronRightIcon, {}), className: "mb-4 bg-secondary-highlight md:mb-0 md:bg-transparent" }), _jsx(MenuItem, { name: "Terms of Use", suffix: _jsx(ChevronRightIcon, {}), className: "bg-secondary-highlight md:bg-transparent" }), _jsx(MenuItem, { name: "Privacy Policy", suffix: _jsx(ChevronRightIcon, {}), className: "bg-secondary-highlight md:bg-transparent" })] }), _jsx("div", { className: "my-4 flex justify-center", children: _jsx(Button, { className: "!bg-[#D5FCE8] !text-black", variant: "contained", children: "Switch to BABY Staking" }) })] }) }));
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const MenuContext = createContext(undefined);
|
|
4
|
+
export const useMenuContext = () => {
|
|
5
|
+
return useContext(MenuContext);
|
|
6
|
+
};
|
|
7
|
+
export const MenuProvider = ({ children, value }) => {
|
|
8
|
+
return _jsx(MenuContext.Provider, { value: value, children: children });
|
|
9
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { twJoin } from "tailwind-merge";
|
|
3
|
+
import { Portal } from "../Portal";
|
|
4
|
+
export const MenuDrawer = ({ isOpen, onClose, title, children, className = "", titleAlign = "left", backIcon, fullHeight = false, fullWidth = false, showBackButton = true, showDivider = true, onBackdropClick, }) => {
|
|
5
|
+
const titleAlignment = {
|
|
6
|
+
left: "text-left",
|
|
7
|
+
center: "text-center",
|
|
8
|
+
right: "text-right",
|
|
9
|
+
};
|
|
10
|
+
const renderHeader = () => {
|
|
11
|
+
if (!(showBackButton || title))
|
|
12
|
+
return null;
|
|
13
|
+
return (_jsxs("div", { className: twJoin("flex items-center p-4", showDivider && "border-b border-[#38708533] dark:border-[#404040]"), children: [showBackButton && (_jsx("button", { onClick: onClose, className: "flex h-8 w-8 flex-shrink-0 items-center justify-center rounded transition-colors hover:bg-accent-secondary/10", "aria-label": "Go back", children: backIcon || (_jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "text-accent-primary", children: _jsx("path", { d: "M10 12L6 8L10 4", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })) })), title && (_jsx("h3", { className: twJoin("flex-1 text-sm font-medium text-accent-primary", showBackButton ? "ml-3" : "", titleAlignment[titleAlign]), children: title }))] }));
|
|
14
|
+
};
|
|
15
|
+
const renderContent = () => (_jsxs(_Fragment, { children: [renderHeader(), _jsx("div", { className: "flex-1 overflow-y-auto", children: children })] }));
|
|
16
|
+
// For fullHeight drawers (mobile), use Portal to ensure proper theme sync
|
|
17
|
+
if (fullHeight) {
|
|
18
|
+
return (_jsxs(Portal, { mounted: true, rootClassName: "menu-drawer-portal", children: [onBackdropClick && (_jsx("div", { className: twJoin("fixed inset-0 z-40 bg-black/50 transition-opacity duration-300", isOpen ? "opacity-100" : "pointer-events-none opacity-0"), onClick: onBackdropClick })), _jsx("div", { className: twJoin("transform transition-transform duration-300 ease-in-out", "bg-[#FFFFFF] dark:bg-[#252525]", "fixed inset-y-0 right-0 z-50", fullWidth ? "w-full" : "w-full max-w-sm", isOpen ? "translate-x-0" : "translate-x-full", className), children: renderContent() })] }));
|
|
19
|
+
}
|
|
20
|
+
// For non-fullHeight drawers (desktop), render normally
|
|
21
|
+
return (_jsx("div", { className: twJoin("transform transition-transform duration-300 ease-in-out", "bg-[#FFFFFF] dark:bg-[#252525]", "absolute inset-0 rounded-lg", isOpen ? "translate-x-0" : "translate-x-full", className), children: renderContent() }));
|
|
22
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { twJoin } from "tailwind-merge";
|
|
3
|
+
import { useMenuContext } from "./MenuContext";
|
|
4
|
+
export const MenuItem = ({ icon, name, description, onClick, disabled = false, className, children, suffix, selected = false, role = "menuitem", }) => {
|
|
5
|
+
const menuContext = useMenuContext();
|
|
6
|
+
const handleClick = () => {
|
|
7
|
+
if (disabled || !onClick)
|
|
8
|
+
return;
|
|
9
|
+
onClick();
|
|
10
|
+
// Close menu after click unless it has a suffix (indicating a submenu)
|
|
11
|
+
if (menuContext && !suffix) {
|
|
12
|
+
menuContext.onClose();
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
// If children are provided, render them instead of the default layout
|
|
16
|
+
if (children) {
|
|
17
|
+
return (_jsx("button", { onClick: handleClick, disabled: disabled, className: twJoin("w-full text-left", disabled && "cursor-not-allowed opacity-50", className), children: children }));
|
|
18
|
+
}
|
|
19
|
+
return (_jsxs("button", { onClick: handleClick, disabled: disabled, className: twJoin("flex w-full items-center justify-between p-6", "transition-colors hover:bg-accent-secondary/5", "text-left", "focus:outline-none", selected && "bg-accent-secondary/10", disabled && "cursor-not-allowed opacity-50", className), role: role, "aria-selected": selected, tabIndex: disabled ? -1 : 0, children: [_jsxs("div", { className: "flex items-center gap-3", children: [icon && _jsx("div", { className: "flex-shrink-0", children: icon }), _jsxs("div", { className: "flex flex-col", children: [_jsx("div", { className: "text-sm font-medium text-accent-primary", children: name }), description && _jsx("div", { className: "text-xs text-accent-secondary", children: description })] })] }), suffix] }));
|
|
20
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { twJoin } from "tailwind-merge";
|
|
4
|
+
import { MenuDrawer } from "./MenuDrawer";
|
|
5
|
+
import { useMenuContext } from "./MenuContext";
|
|
6
|
+
export const SubMenu = ({ children, name, description, icon, backIcon, suffix, className, contentClassName, titleAlign = "left", }) => {
|
|
7
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
8
|
+
const menuContext = useMenuContext();
|
|
9
|
+
const defaultBackIcon = (_jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "text-accent-primary", children: _jsx("path", { d: "M10 12L6 8L10 4", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
10
|
+
const chevronRightIcon = (_jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "text-accent-primary", children: _jsx("path", { d: "M6 4L10 8L6 12", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
11
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { onClick: () => setIsOpen(true), className: twJoin("flex w-full items-center justify-between p-6", "transition-colors hover:bg-accent-secondary/5", "text-left focus:outline-none", className), role: "menuitem", children: [_jsxs("div", { className: "flex items-center gap-3", children: [icon && _jsx("div", { className: "flex-shrink-0", children: icon }), _jsxs("div", { className: "flex flex-col", children: [_jsx("span", { className: "text-sm font-medium text-accent-primary", children: name }), description && _jsx("span", { className: "mt-0.5 text-xs text-accent-secondary", children: description })] })] }), suffix || chevronRightIcon] }), _jsx(MenuDrawer, { isOpen: isOpen, onClose: () => setIsOpen(false), title: name || "", titleAlign: titleAlign, backIcon: backIcon || defaultBackIcon, fullHeight: menuContext?.isMobile, fullWidth: menuContext?.isMobile, onBackdropClick: menuContext?.isMobile ? undefined : () => setIsOpen(false), className: twJoin(menuContext?.isMobile ? "z-60" : "z-50", contentClassName), children: children })] }));
|
|
12
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { twJoin } from "tailwind-merge";
|
|
3
|
+
export const SubMenuItem = ({ label, description, onClick, selected = false, className, suffix, disabled = false, }) => {
|
|
4
|
+
const defaultCheckmark = (_jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M16.6667 5L7.5 14.1667L3.33333 10", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
5
|
+
return (_jsxs("button", { role: "menuitem", onClick: onClick, disabled: disabled, className: twJoin("flex w-full items-center justify-between p-4", "transition-colors hover:bg-accent-secondary/5", "text-left focus:outline-none", selected && "bg-accent-secondary/10", disabled && "cursor-not-allowed opacity-50", className), "aria-selected": selected, tabIndex: disabled ? -1 : 0, children: [_jsxs("div", { className: "flex flex-col items-start", children: [_jsx("span", { className: "font-medium text-accent-primary", children: label }), description && _jsx("span", { className: "text-sm text-accent-secondary", children: description })] }), selected && (suffix || defaultCheckmark)] }));
|
|
6
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { useMenuContext } from
|
|
2
|
-
export { Menu } from
|
|
3
|
-
export { MenuItem } from
|
|
4
|
-
export { MenuDrawer } from
|
|
5
|
-
export { SubMenu } from
|
|
6
|
-
export { SubMenuItem } from
|
|
1
|
+
export { useMenuContext } from "./MenuContext";
|
|
2
|
+
export { Menu } from "./Menu";
|
|
3
|
+
export { MenuItem } from "./MenuItem";
|
|
4
|
+
export { MenuDrawer } from "./MenuDrawer";
|
|
5
|
+
export { SubMenu } from "./SubMenu";
|
|
6
|
+
export { SubMenuItem } from "./SubMenuItem";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { PropsWithChildren, CSSProperties } from
|
|
2
|
-
import { Placement } from
|
|
1
|
+
import { type PropsWithChildren, type CSSProperties } from "react";
|
|
2
|
+
import { type Placement } from "@popperjs/core";
|
|
3
|
+
import "./Popover.css";
|
|
3
4
|
export interface PopoverProps extends PropsWithChildren {
|
|
4
5
|
open?: boolean;
|
|
5
6
|
className?: string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { twJoin } from "tailwind-merge";
|
|
4
|
+
import { usePopper } from "react-popper";
|
|
5
|
+
import { Portal } from "@/components/Portal";
|
|
6
|
+
import { useClickOutside } from "@/hooks/useClickOutside";
|
|
7
|
+
import "./Popover.css";
|
|
8
|
+
export function Popover({ open = false, className, anchorEl, placement = "bottom-start", offset = [0, 0], children, style, onClickOutside, }) {
|
|
9
|
+
const [tooltipRef, setTooltipRef] = useState(null);
|
|
10
|
+
const { styles } = usePopper(anchorEl, tooltipRef, {
|
|
11
|
+
placement,
|
|
12
|
+
modifiers: [{ name: "offset", options: { offset } }],
|
|
13
|
+
});
|
|
14
|
+
useClickOutside([tooltipRef, anchorEl], onClickOutside, { enabled: open });
|
|
15
|
+
return (_jsx(Portal, { mounted: open, children: _jsx("div", { ref: setTooltipRef, style: { ...styles.popper, ...style }, className: twJoin("bbn-popover", className), children: children }) }));
|
|
16
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Text } from "@/components/Text";
|
|
4
|
+
import { Button } from "@/components/Button";
|
|
5
|
+
import { Popover } from "./Popover";
|
|
6
|
+
const meta = {
|
|
7
|
+
component: Popover,
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
export const Default = {
|
|
12
|
+
args: {
|
|
13
|
+
placement: "bottom-start",
|
|
14
|
+
children: (_jsx(Text, { variant: "body1", className: "text-accent-primary", children: "The content of the Popover" })),
|
|
15
|
+
},
|
|
16
|
+
render: (props) => {
|
|
17
|
+
const [open, setOpen] = useState(props.open);
|
|
18
|
+
const [anchorEl, setAnchorEl] = useState();
|
|
19
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { ref: setAnchorEl, onClick: () => {
|
|
20
|
+
setOpen((state) => !state);
|
|
21
|
+
}, children: "Show popover" }), _jsx(Popover, { ...props, open: open, anchorEl: anchorEl, onClickOutside: () => {
|
|
22
|
+
setOpen(false);
|
|
23
|
+
} })] }));
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./Popover";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Popover";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PropsWithChildren } from
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
2
|
interface PortalProps {
|
|
3
3
|
mounted?: boolean;
|
|
4
4
|
rootClassName?: string;
|
|
5
5
|
}
|
|
6
|
-
export declare function Portal({ children, mounted, rootClassName }: PropsWithChildren<PortalProps>): import(
|
|
6
|
+
export declare function Portal({ children, mounted, rootClassName }: PropsWithChildren<PortalProps>): import("react").ReactPortal | null;
|
|
7
7
|
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
3
|
+
export function Portal({ children, mounted = false, rootClassName = "portal-root" }) {
|
|
4
|
+
const [rootRef, setRootRef] = useState(null);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
if (!mounted) {
|
|
7
|
+
setRootRef(null);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const root = document.createElement("div");
|
|
11
|
+
root.className = rootClassName;
|
|
12
|
+
setRootRef(root);
|
|
13
|
+
document.body.appendChild(root);
|
|
14
|
+
// Sync dark/light classes or data-mode attribute from documentElement/body
|
|
15
|
+
const syncThemeClass = () => {
|
|
16
|
+
const isDark = document.documentElement.classList.contains("dark") ||
|
|
17
|
+
document.body.classList.contains("dark") ||
|
|
18
|
+
document.documentElement.getAttribute("data-mode") === "dark" ||
|
|
19
|
+
document.body.getAttribute("data-mode") === "dark";
|
|
20
|
+
if (isDark) {
|
|
21
|
+
root.classList.add("dark");
|
|
22
|
+
root.setAttribute("data-mode", "dark");
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
root.classList.remove("dark");
|
|
26
|
+
root.setAttribute("data-mode", "light");
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
syncThemeClass();
|
|
30
|
+
const observer = new MutationObserver(syncThemeClass);
|
|
31
|
+
observer.observe(document.documentElement, {
|
|
32
|
+
attributes: true,
|
|
33
|
+
attributeFilter: ["class", "data-mode"],
|
|
34
|
+
});
|
|
35
|
+
observer.observe(document.body, {
|
|
36
|
+
attributes: true,
|
|
37
|
+
attributeFilter: ["class", "data-mode"],
|
|
38
|
+
});
|
|
39
|
+
return () => {
|
|
40
|
+
observer.disconnect();
|
|
41
|
+
document.body.removeChild(root);
|
|
42
|
+
};
|
|
43
|
+
}, [mounted]);
|
|
44
|
+
return rootRef ? createPortal(children, rootRef) : null;
|
|
45
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./Portal";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Portal";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Spacer } from './Spacer';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { twJoin } from "tailwind-merge";
|
|
3
|
+
export const SubSection = ({ children, style, className, }) => (_jsx("div", { className: twJoin("flex rounded bg-secondary-highlight p-4 text-accent-primary", className), style: style, children: children }));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { SubSection } from "./SubSection";
|
|
3
|
+
import { Text } from "../Text";
|
|
4
|
+
const meta = {
|
|
5
|
+
component: SubSection,
|
|
6
|
+
tags: ["autodocs"],
|
|
7
|
+
};
|
|
8
|
+
export default meta;
|
|
9
|
+
export const Default = {
|
|
10
|
+
args: {
|
|
11
|
+
children: _jsx(Text, { children: "Lorem ipsum dolor sit amet" }),
|
|
12
|
+
},
|
|
13
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { SubSection } from
|
|
1
|
+
export { SubSection } from "./SubSection";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SubSection } from "./SubSection";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useMemo, useCallback, forwardRef, useImperativeHandle } from "react";
|
|
3
|
+
import { twJoin } from "tailwind-merge";
|
|
4
|
+
import { useTableScroll } from "@/hooks/useTableScroll";
|
|
5
|
+
import { TableContext } from "../../context/Table.context";
|
|
6
|
+
import { Column } from "./components/Column";
|
|
7
|
+
import "./Table.css";
|
|
8
|
+
import { useControlledState } from "@/hooks/useControlledState";
|
|
9
|
+
import { useTableSort } from "@/hooks/useTableSort";
|
|
10
|
+
import { Row } from "./components/Row";
|
|
11
|
+
function TableBase({ data, columns, className, wrapperClassName, hasMore = false, loading = false, onLoadMore, onRowSelect, isRowSelectable, selectedRow: selectedRowProp, defaultSelectedRow, onSelectedRowChange, ...restProps }, ref) {
|
|
12
|
+
const tableRef = useRef(null);
|
|
13
|
+
useImperativeHandle(ref, () => tableRef.current, []);
|
|
14
|
+
const { sortStates, handleColumnSort, sortedData } = useTableSort(data, columns);
|
|
15
|
+
const { isScrolledTop } = useTableScroll(tableRef, { onLoadMore, hasMore, loading });
|
|
16
|
+
const [selectedRow, setSelectedRow] = useControlledState({
|
|
17
|
+
value: selectedRowProp,
|
|
18
|
+
defaultValue: defaultSelectedRow ?? null,
|
|
19
|
+
onStateChange: onSelectedRowChange,
|
|
20
|
+
});
|
|
21
|
+
const handleRowSelect = useCallback((row) => {
|
|
22
|
+
if (!onRowSelect || (isRowSelectable && !isRowSelectable(row)))
|
|
23
|
+
return;
|
|
24
|
+
const newValue = selectedRow === row.id ? null : row.id;
|
|
25
|
+
setSelectedRow(newValue);
|
|
26
|
+
onRowSelect(newValue === null ? null : row);
|
|
27
|
+
}, [onRowSelect, isRowSelectable, selectedRow, setSelectedRow]);
|
|
28
|
+
const contextValue = useMemo(() => ({
|
|
29
|
+
data: sortedData,
|
|
30
|
+
columns,
|
|
31
|
+
sortStates,
|
|
32
|
+
onColumnSort: handleColumnSort,
|
|
33
|
+
onRowSelect: handleRowSelect,
|
|
34
|
+
}), [sortedData, columns, sortStates, handleColumnSort, handleRowSelect]);
|
|
35
|
+
return (_jsx(TableContext.Provider, { value: contextValue, children: _jsx("div", { ref: tableRef, className: twJoin("bbn-table-wrapper", wrapperClassName), children: _jsxs("table", { className: twJoin("bbn-table", className), ...restProps, children: [_jsx("thead", { className: twJoin("bbn-table-header", isScrolledTop && "scrolled-top"), children: _jsx("tr", { children: columns.map((column) => (_jsx(Column, { className: column.headerClassName, name: column.key, sorter: column.sorter, children: column.header }, column.key))) }) }), _jsx("tbody", { className: "bbn-table-body", children: sortedData.map((row) => (_jsx(Row, { row: row, columns: columns, isSelected: selectedRow === row.id, isSelectable: isRowSelectable ? isRowSelectable(row) : true, onSelect: handleRowSelect }, row.id))) })] }) }) }));
|
|
36
|
+
}
|
|
37
|
+
export const Table = forwardRef(TableBase);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Table } from ".";
|
|
3
|
+
declare const meta: Meta<typeof Table>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const ControlledSelection: Story;
|