@react-fabric/core 1.0.0-beta.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/LICENSE +21 -0
- package/README.md +10 -0
- package/css/flags.rect.css +1607 -0
- package/css/flags.wavy.css +1606 -0
- package/css/index.js +250 -0
- package/css/reset/_gradients.css +51 -0
- package/css/reset/_reset.css +407 -0
- package/css/reset/_text.css +179 -0
- package/css/reset/_theme.css +110 -0
- package/css/reset/index.css +27 -0
- package/css/styles.css +31 -0
- package/css/tailwind/colors.ts +158 -0
- package/dist/cjs/components/actionLabel/ActionLabel.js +56 -0
- package/dist/cjs/components/actionLabel/ActionLabel.module.css +1 -0
- package/dist/cjs/components/animations/Animations.js +135 -0
- package/dist/cjs/components/animations/Animations.module.css +1 -0
- package/dist/cjs/components/avatar/Avatar.js +144 -0
- package/dist/cjs/components/avatar/Avatar.module.css +1 -0
- package/dist/cjs/components/avatar/AvatarGroup.js +74 -0
- package/dist/cjs/components/badge/Badge.js +82 -0
- package/dist/cjs/components/badge/Badge.module.css +1 -0
- package/dist/cjs/components/breadcrumbs/Breadcrumbs.js +71 -0
- package/dist/cjs/components/breadcrumbs/Breadcrumbs.module.css +1 -0
- package/dist/cjs/components/button/Button.js +170 -0
- package/dist/cjs/components/button/Button.module.css +1 -0
- package/dist/cjs/components/button/ButtonGroup.js +41 -0
- package/dist/cjs/components/button/ConfirmButton.js +166 -0
- package/dist/cjs/components/button/ToggleButtonGroup.js +68 -0
- package/dist/cjs/components/callout/Callout.js +54 -0
- package/dist/cjs/components/card/Card.js +62 -0
- package/dist/cjs/components/card/Card.module.css +1 -0
- package/dist/cjs/components/card/CardCover.js +48 -0
- package/dist/cjs/components/chip/Chip.js +94 -0
- package/dist/cjs/components/chip/Chip.module.css +1 -0
- package/dist/cjs/components/collapsable/Collapsable.js +84 -0
- package/dist/cjs/components/collapsable/Collapsable.module.css +1 -0
- package/dist/cjs/components/divider/Divider.js +65 -0
- package/dist/cjs/components/dropdown/Dropdown.js +180 -0
- package/dist/cjs/components/dropdown/Dropdown.module.css +1 -0
- package/dist/cjs/components/dropdown/DropdownTool.js +26 -0
- package/dist/cjs/components/empty/EmptyContent.js +92 -0
- package/dist/cjs/components/icon/Icon.js +106 -0
- package/dist/cjs/components/icon/Icon.module.css +1 -0
- package/dist/cjs/components/media/Media.js +149 -0
- package/dist/cjs/components/media/Media.module.css +1 -0
- package/dist/cjs/components/menu/ContextMenu.js +84 -0
- package/dist/cjs/components/menu/Menu.js +204 -0
- package/dist/cjs/components/menu/Menu.module.css +1 -0
- package/dist/cjs/components/menu/MenuItem.js +119 -0
- package/dist/cjs/components/meter/Meter.js +41 -0
- package/dist/cjs/components/meter/Meter.module.css +1 -0
- package/dist/cjs/components/navigator/Navigator.js +54 -0
- package/dist/cjs/components/panel/Panel.js +125 -0
- package/dist/cjs/components/panel/Panel.module.css +1 -0
- package/dist/cjs/components/panel/PanelGroup.js +50 -0
- package/dist/cjs/components/panel/PanelStack.js +85 -0
- package/dist/cjs/components/progress/Progress.module.css +1 -0
- package/dist/cjs/components/progress/ProgressBar.js +62 -0
- package/dist/cjs/components/progress/ProgressCircle.js +96 -0
- package/dist/cjs/components/tabpanel/Tab.js +78 -0
- package/dist/cjs/components/tabpanel/TabPanel.js +77 -0
- package/dist/cjs/components/tabpanel/TabPanel.module.css +1 -0
- package/dist/cjs/context/Global.js +169 -0
- package/dist/cjs/context/NotificationCenter.js +254 -0
- package/dist/cjs/core/aside/Aside.js +152 -0
- package/dist/cjs/core/aside/Aside.module.css +1 -0
- package/dist/cjs/core/boundary/ErrorBoundary.js +140 -0
- package/dist/cjs/core/boundary/ErrorBoundary.module.css +1 -0
- package/dist/cjs/core/boundary/ErrorIcon.js +51 -0
- package/dist/cjs/core/content/Content.js +70 -0
- package/dist/cjs/core/content/Content.module.css +1 -0
- package/dist/cjs/core/headfoot/HeadFoot.js +62 -0
- package/dist/cjs/core/headfoot/HeadFoot.module.css +1 -0
- package/dist/cjs/core/page/Page.js +65 -0
- package/dist/cjs/core/page/Page.module.css +1 -0
- package/dist/cjs/core/responsive/Responsive.js +64 -0
- package/dist/cjs/core/responsive/Responsive.module.css +1 -0
- package/dist/cjs/core/section/Section.js +44 -0
- package/dist/cjs/core/section/Section.module.css +1 -0
- package/dist/cjs/core/theme/Theme.module.css +1 -0
- package/dist/cjs/core/theme/ThemeProvider.js +74 -0
- package/dist/cjs/core/viewport/Viewport.js +39 -0
- package/dist/cjs/core/viewport/Viewport.module.css +1 -0
- package/dist/cjs/hooks/useClientService.js +30 -0
- package/dist/cjs/hooks/useControlledValue.js +22 -0
- package/dist/cjs/hooks/useDebounce.js +56 -0
- package/dist/cjs/hooks/useEffectDebugger.js +113 -0
- package/dist/cjs/hooks/useIsDark.js +33 -0
- package/dist/cjs/hooks/useIsRtl.js +27 -0
- package/dist/cjs/hooks/useNavigator.js +36 -0
- package/dist/cjs/hooks/useOverlayService.js +55 -0
- package/dist/cjs/hooks/usePropToggle.js +40 -0
- package/dist/cjs/hooks/useResize.js +75 -0
- package/dist/cjs/hooks/useResizeObserver.js +38 -0
- package/dist/cjs/hooks/useStorage.js +44 -0
- package/dist/cjs/hotkeys/HotKey.js +47 -0
- package/dist/cjs/hotkeys/HotKeyLabel.js +52 -0
- package/dist/cjs/hotkeys/HotKeyWrapper.js +98 -0
- package/dist/cjs/hotkeys/commons.js +56 -0
- package/dist/cjs/i18n/ar.json.js +31 -0
- package/dist/cjs/i18n/en.json.js +46 -0
- package/dist/cjs/i18n/index.js +55 -0
- package/dist/cjs/index.js +162 -0
- package/dist/cjs/overlays/alert/Alert.js +163 -0
- package/dist/cjs/overlays/alert/Alert.module.css +1 -0
- package/dist/cjs/overlays/flyout/Flyout.js +152 -0
- package/dist/cjs/overlays/flyout/Flyout.module.css +1 -0
- package/dist/cjs/overlays/message/Message.js +84 -0
- package/dist/cjs/overlays/message/Message.module.css +1 -0
- package/dist/cjs/overlays/modal/Modal.js +132 -0
- package/dist/cjs/overlays/modal/Modal.module.css +1 -0
- package/dist/cjs/overlays/toast/Toast.js +166 -0
- package/dist/cjs/overlays/toast/Toast.module.css +1 -0
- package/dist/cjs/overlays/tooltip/Tooltip.js +133 -0
- package/dist/cjs/overlays/tooltip/Tooltip.module.css +1 -0
- package/dist/cjs/types/icons.js +197 -0
- package/dist/cjs/typography/Abbr.js +108 -0
- package/dist/cjs/typography/Copy.js +59 -0
- package/dist/cjs/typography/Link.js +55 -0
- package/dist/cjs/typography/Mark.js +86 -0
- package/dist/cjs/typography/Text.js +121 -0
- package/dist/cjs/typography/Title.js +58 -0
- package/dist/cjs/typography/Typography.module.css +1 -0
- package/dist/cjs/typography/types.js +42 -0
- package/dist/cjs/utils/calculateDimensions.js +51 -0
- package/dist/cjs/utils/getColor.js +52 -0
- package/dist/cjs/utils/nodeCheck.js +35 -0
- package/dist/esm/components/actionLabel/ActionLabel.js +56 -0
- package/dist/esm/components/actionLabel/ActionLabel.module.css +1 -0
- package/dist/esm/components/animations/Animations.js +131 -0
- package/dist/esm/components/animations/Animations.module.css +1 -0
- package/dist/esm/components/avatar/Avatar.js +144 -0
- package/dist/esm/components/avatar/Avatar.module.css +1 -0
- package/dist/esm/components/avatar/AvatarGroup.js +74 -0
- package/dist/esm/components/badge/Badge.js +81 -0
- package/dist/esm/components/badge/Badge.module.css +1 -0
- package/dist/esm/components/breadcrumbs/Breadcrumbs.js +71 -0
- package/dist/esm/components/breadcrumbs/Breadcrumbs.module.css +1 -0
- package/dist/esm/components/button/Button.js +170 -0
- package/dist/esm/components/button/Button.module.css +1 -0
- package/dist/esm/components/button/ButtonGroup.js +41 -0
- package/dist/esm/components/button/ConfirmButton.js +166 -0
- package/dist/esm/components/button/ToggleButtonGroup.js +68 -0
- package/dist/esm/components/callout/Callout.js +54 -0
- package/dist/esm/components/card/Card.js +62 -0
- package/dist/esm/components/card/Card.module.css +1 -0
- package/dist/esm/components/card/CardCover.js +48 -0
- package/dist/esm/components/chip/Chip.js +94 -0
- package/dist/esm/components/chip/Chip.module.css +1 -0
- package/dist/esm/components/collapsable/Collapsable.js +84 -0
- package/dist/esm/components/collapsable/Collapsable.module.css +1 -0
- package/dist/esm/components/divider/Divider.js +65 -0
- package/dist/esm/components/dropdown/Dropdown.js +179 -0
- package/dist/esm/components/dropdown/Dropdown.module.css +1 -0
- package/dist/esm/components/dropdown/DropdownTool.js +26 -0
- package/dist/esm/components/empty/EmptyContent.js +92 -0
- package/dist/esm/components/icon/Icon.js +106 -0
- package/dist/esm/components/icon/Icon.module.css +1 -0
- package/dist/esm/components/media/Media.js +148 -0
- package/dist/esm/components/media/Media.module.css +1 -0
- package/dist/esm/components/menu/ContextMenu.js +84 -0
- package/dist/esm/components/menu/Menu.js +204 -0
- package/dist/esm/components/menu/Menu.module.css +1 -0
- package/dist/esm/components/menu/MenuItem.js +119 -0
- package/dist/esm/components/meter/Meter.js +41 -0
- package/dist/esm/components/meter/Meter.module.css +1 -0
- package/dist/esm/components/navigator/Navigator.js +54 -0
- package/dist/esm/components/panel/Panel.js +125 -0
- package/dist/esm/components/panel/Panel.module.css +1 -0
- package/dist/esm/components/panel/PanelGroup.js +50 -0
- package/dist/esm/components/panel/PanelStack.js +85 -0
- package/dist/esm/components/progress/Progress.module.css +1 -0
- package/dist/esm/components/progress/ProgressBar.js +62 -0
- package/dist/esm/components/progress/ProgressCircle.js +96 -0
- package/dist/esm/components/tabpanel/Tab.js +78 -0
- package/dist/esm/components/tabpanel/TabPanel.js +77 -0
- package/dist/esm/components/tabpanel/TabPanel.module.css +1 -0
- package/dist/esm/context/Global.js +165 -0
- package/dist/esm/context/NotificationCenter.js +254 -0
- package/dist/esm/core/aside/Aside.js +152 -0
- package/dist/esm/core/aside/Aside.module.css +1 -0
- package/dist/esm/core/boundary/ErrorBoundary.js +140 -0
- package/dist/esm/core/boundary/ErrorBoundary.module.css +1 -0
- package/dist/esm/core/boundary/ErrorIcon.js +51 -0
- package/dist/esm/core/content/Content.js +70 -0
- package/dist/esm/core/content/Content.module.css +1 -0
- package/dist/esm/core/headfoot/HeadFoot.js +61 -0
- package/dist/esm/core/headfoot/HeadFoot.module.css +1 -0
- package/dist/esm/core/page/Page.js +65 -0
- package/dist/esm/core/page/Page.module.css +1 -0
- package/dist/esm/core/responsive/Responsive.js +62 -0
- package/dist/esm/core/responsive/Responsive.module.css +1 -0
- package/dist/esm/core/section/Section.js +44 -0
- package/dist/esm/core/section/Section.module.css +1 -0
- package/dist/esm/core/theme/Theme.module.css +1 -0
- package/dist/esm/core/theme/ThemeProvider.js +74 -0
- package/dist/esm/core/viewport/Viewport.js +39 -0
- package/dist/esm/core/viewport/Viewport.module.css +1 -0
- package/dist/esm/hooks/useClientService.js +30 -0
- package/dist/esm/hooks/useControlledValue.js +22 -0
- package/dist/esm/hooks/useDebounce.js +56 -0
- package/dist/esm/hooks/useEffectDebugger.js +111 -0
- package/dist/esm/hooks/useIsDark.js +33 -0
- package/dist/esm/hooks/useIsRtl.js +27 -0
- package/dist/esm/hooks/useNavigator.js +36 -0
- package/dist/esm/hooks/useOverlayService.js +55 -0
- package/dist/esm/hooks/usePropToggle.js +40 -0
- package/dist/esm/hooks/useResize.js +75 -0
- package/dist/esm/hooks/useResizeObserver.js +38 -0
- package/dist/esm/hooks/useStorage.js +43 -0
- package/dist/esm/hotkeys/HotKey.js +47 -0
- package/dist/esm/hotkeys/HotKeyLabel.js +52 -0
- package/dist/esm/hotkeys/HotKeyWrapper.js +96 -0
- package/dist/esm/hotkeys/commons.js +56 -0
- package/dist/esm/i18n/ar.json.js +27 -0
- package/dist/esm/i18n/en.json.js +41 -0
- package/dist/esm/i18n/index.js +55 -0
- package/dist/esm/index.js +75 -0
- package/dist/esm/overlays/alert/Alert.js +163 -0
- package/dist/esm/overlays/alert/Alert.module.css +1 -0
- package/dist/esm/overlays/flyout/Flyout.js +152 -0
- package/dist/esm/overlays/flyout/Flyout.module.css +1 -0
- package/dist/esm/overlays/message/Message.js +84 -0
- package/dist/esm/overlays/message/Message.module.css +1 -0
- package/dist/esm/overlays/modal/Modal.js +132 -0
- package/dist/esm/overlays/modal/Modal.module.css +1 -0
- package/dist/esm/overlays/toast/Toast.js +166 -0
- package/dist/esm/overlays/toast/Toast.module.css +1 -0
- package/dist/esm/overlays/tooltip/Tooltip.js +132 -0
- package/dist/esm/overlays/tooltip/Tooltip.module.css +1 -0
- package/dist/esm/types/icons.js +199 -0
- package/dist/esm/typography/Abbr.js +108 -0
- package/dist/esm/typography/Copy.js +59 -0
- package/dist/esm/typography/Link.js +55 -0
- package/dist/esm/typography/Mark.js +86 -0
- package/dist/esm/typography/Text.js +121 -0
- package/dist/esm/typography/Title.js +58 -0
- package/dist/esm/typography/Typography.module.css +1 -0
- package/dist/esm/typography/types.js +41 -0
- package/dist/esm/utils/calculateDimensions.js +50 -0
- package/dist/esm/utils/getColor.js +49 -0
- package/dist/esm/utils/nodeCheck.js +35 -0
- package/dist/types/components/actionLabel/ActionLabel.d.ts +21 -0
- package/dist/types/components/animations/Animations.d.ts +23 -0
- package/dist/types/components/avatar/Avatar.d.ts +48 -0
- package/dist/types/components/avatar/AvatarGroup.d.ts +24 -0
- package/dist/types/components/badge/Badge.d.ts +25 -0
- package/dist/types/components/breadcrumbs/Breadcrumbs.d.ts +17 -0
- package/dist/types/components/button/Button.d.ts +94 -0
- package/dist/types/components/button/ButtonGroup.d.ts +34 -0
- package/dist/types/components/button/ConfirmButton.d.ts +27 -0
- package/dist/types/components/button/ToggleButtonGroup.d.ts +56 -0
- package/dist/types/components/callout/Callout.d.ts +28 -0
- package/dist/types/components/card/Card.d.ts +39 -0
- package/dist/types/components/card/CardCover.d.ts +16 -0
- package/dist/types/components/chip/Chip.d.ts +41 -0
- package/dist/types/components/collapsable/Collapsable.d.ts +43 -0
- package/dist/types/components/divider/Divider.d.ts +20 -0
- package/dist/types/components/dropdown/Dropdown.d.ts +50 -0
- package/dist/types/components/dropdown/DropdownTool.d.ts +8 -0
- package/dist/types/components/empty/EmptyContent.d.ts +21 -0
- package/dist/types/components/icon/Icon.d.ts +44 -0
- package/dist/types/components/index.d.ts +33 -0
- package/dist/types/components/media/Media.d.ts +37 -0
- package/dist/types/components/menu/ContextMenu.d.ts +7 -0
- package/dist/types/components/menu/Menu.d.ts +2 -0
- package/dist/types/components/menu/MenuItem.d.ts +4 -0
- package/dist/types/components/menu/types.d.ts +59 -0
- package/dist/types/components/meter/Meter.d.ts +12 -0
- package/dist/types/components/navigator/Navigator.d.ts +12 -0
- package/dist/types/components/panel/Panel.d.ts +59 -0
- package/dist/types/components/panel/PanelGroup.d.ts +12 -0
- package/dist/types/components/panel/PanelStack.d.ts +16 -0
- package/dist/types/components/progress/ProgressBar.d.ts +24 -0
- package/dist/types/components/progress/ProgressCircle.d.ts +16 -0
- package/dist/types/components/tabpanel/Tab.d.ts +41 -0
- package/dist/types/components/tabpanel/TabPanel.d.ts +41 -0
- package/dist/types/context/Global.d.ts +81 -0
- package/dist/types/context/NotificationCenter.d.ts +11 -0
- package/dist/types/core/aside/Aside.d.ts +52 -0
- package/dist/types/core/boundary/ErrorBoundary.d.ts +26 -0
- package/dist/types/core/boundary/ErrorIcon.d.ts +1 -0
- package/dist/types/core/content/Content.d.ts +15 -0
- package/dist/types/core/headfoot/HeadFoot.d.ts +24 -0
- package/dist/types/core/index.d.ts +9 -0
- package/dist/types/core/page/Page.d.ts +23 -0
- package/dist/types/core/responsive/Responsive.d.ts +53 -0
- package/dist/types/core/section/Section.d.ts +7 -0
- package/dist/types/core/theme/ThemeProvider.d.ts +37 -0
- package/dist/types/core/viewport/Viewport.d.ts +5 -0
- package/dist/types/hooks/useClientService.d.ts +1 -0
- package/dist/types/hooks/useControlledValue.d.ts +5 -0
- package/dist/types/hooks/useDebounce.d.ts +4 -0
- package/dist/types/hooks/useEffectDebugger.d.ts +4 -0
- package/dist/types/hooks/useIsDark.d.ts +1 -0
- package/dist/types/hooks/useIsRtl.d.ts +1 -0
- package/dist/types/hooks/useNavigator.d.ts +7 -0
- package/dist/types/hooks/useOverlayService.d.ts +10 -0
- package/dist/types/hooks/usePropToggle.d.ts +9 -0
- package/dist/types/hooks/useResize.d.ts +27 -0
- package/dist/types/hooks/useResizeObserver.d.ts +3 -0
- package/dist/types/hooks/useStorage.d.ts +2 -0
- package/dist/types/hotkeys/HotKey.d.ts +2 -0
- package/dist/types/hotkeys/HotKeyLabel.d.ts +2 -0
- package/dist/types/hotkeys/HotKeyWrapper.d.ts +11 -0
- package/dist/types/hotkeys/commons.d.ts +28 -0
- package/dist/types/i18n/index.d.ts +6 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/overlays/alert/Alert.d.ts +33 -0
- package/dist/types/overlays/flyout/Flyout.d.ts +57 -0
- package/dist/types/overlays/index.d.ts +6 -0
- package/dist/types/overlays/message/Message.d.ts +21 -0
- package/dist/types/overlays/modal/Modal.d.ts +53 -0
- package/dist/types/overlays/toast/Toast.d.ts +33 -0
- package/dist/types/overlays/tooltip/Tooltip.d.ts +18 -0
- package/dist/types/types/icons.d.ts +194 -0
- package/dist/types/types/index.d.ts +140 -0
- package/dist/types/typography/Abbr.d.ts +22 -0
- package/dist/types/typography/Copy.d.ts +9 -0
- package/dist/types/typography/Link.d.ts +24 -0
- package/dist/types/typography/Mark.d.ts +18 -0
- package/dist/types/typography/Text.d.ts +35 -0
- package/dist/types/typography/Title.d.ts +29 -0
- package/dist/types/typography/index.d.ts +6 -0
- package/dist/types/typography/types.d.ts +2 -0
- package/dist/types/utils/calculateDimensions.d.ts +6 -0
- package/dist/types/utils/getColor.d.ts +4 -0
- package/dist/types/utils/index.d.ts +3 -0
- package/dist/types/utils/nodeCheck.d.ts +2 -0
- package/package.json +60 -0
- package/src/components/actionLabel/ActionLabel.module.css +38 -0
- package/src/components/actionLabel/ActionLabel.tsx +97 -0
- package/src/components/animations/Animations.module.css +253 -0
- package/src/components/animations/Animations.tsx +190 -0
- package/src/components/avatar/Avatar.module.css +90 -0
- package/src/components/avatar/Avatar.tsx +218 -0
- package/src/components/avatar/AvatarGroup.tsx +140 -0
- package/src/components/badge/Badge.module.css +165 -0
- package/src/components/badge/Badge.tsx +148 -0
- package/src/components/breadcrumbs/Breadcrumbs.module.css +189 -0
- package/src/components/breadcrumbs/Breadcrumbs.tsx +109 -0
- package/src/components/button/Button.module.css +375 -0
- package/src/components/button/Button.tsx +323 -0
- package/src/components/button/ButtonGroup.tsx +112 -0
- package/src/components/button/ConfirmButton.tsx +221 -0
- package/src/components/button/ToggleButtonGroup.tsx +161 -0
- package/src/components/callout/Callout.tsx +104 -0
- package/src/components/card/Card.module.css +152 -0
- package/src/components/card/Card.tsx +154 -0
- package/src/components/card/CardCover.tsx +87 -0
- package/src/components/chip/Chip.module.css +118 -0
- package/src/components/chip/Chip.tsx +201 -0
- package/src/components/collapsable/Collapsable.module.css +30 -0
- package/src/components/collapsable/Collapsable.tsx +153 -0
- package/src/components/divider/Divider.tsx +105 -0
- package/src/components/dropdown/Dropdown.module.css +39 -0
- package/src/components/dropdown/Dropdown.tsx +307 -0
- package/src/components/dropdown/DropdownTool.tsx +56 -0
- package/src/components/empty/EmptyContent.tsx +141 -0
- package/src/components/icon/Icon.module.css +71 -0
- package/src/components/icon/Icon.tsx +188 -0
- package/src/components/index.ts +61 -0
- package/src/components/media/Media.module.css +112 -0
- package/src/components/media/Media.tsx +224 -0
- package/src/components/menu/ContextMenu.tsx +116 -0
- package/src/components/menu/Menu.module.css +109 -0
- package/src/components/menu/Menu.tsx +278 -0
- package/src/components/menu/MenuItem.tsx +162 -0
- package/src/components/menu/types.ts +100 -0
- package/src/components/meter/Meter.module.css +116 -0
- package/src/components/meter/Meter.tsx +80 -0
- package/src/components/navigator/Navigator.tsx +77 -0
- package/src/components/panel/Panel.module.css +86 -0
- package/src/components/panel/Panel.tsx +254 -0
- package/src/components/panel/PanelGroup.tsx +99 -0
- package/src/components/panel/PanelStack.tsx +133 -0
- package/src/components/progress/Progress.module.css +70 -0
- package/src/components/progress/ProgressBar.tsx +122 -0
- package/src/components/progress/ProgressCircle.tsx +118 -0
- package/src/components/tabpanel/Tab.tsx +175 -0
- package/src/components/tabpanel/TabPanel.module.css +200 -0
- package/src/components/tabpanel/TabPanel.tsx +155 -0
- package/src/context/Global.tsx +241 -0
- package/src/context/NotificationCenter.tsx +223 -0
- package/src/core/aside/Aside.module.css +231 -0
- package/src/core/aside/Aside.tsx +262 -0
- package/src/core/boundary/ErrorBoundary.module.css +65 -0
- package/src/core/boundary/ErrorBoundary.tsx +146 -0
- package/src/core/boundary/ErrorIcon.tsx +50 -0
- package/src/core/content/Content.module.css +40 -0
- package/src/core/content/Content.tsx +91 -0
- package/src/core/headfoot/HeadFoot.module.css +38 -0
- package/src/core/headfoot/HeadFoot.tsx +114 -0
- package/src/core/index.ts +32 -0
- package/src/core/page/Page.module.css +46 -0
- package/src/core/page/Page.tsx +100 -0
- package/src/core/responsive/Responsive.module.css +85 -0
- package/src/core/responsive/Responsive.tsx +172 -0
- package/src/core/section/Section.module.css +28 -0
- package/src/core/section/Section.tsx +48 -0
- package/src/core/theme/Theme.module.css +30 -0
- package/src/core/theme/ThemeProvider.tsx +112 -0
- package/src/core/viewport/Viewport.module.css +32 -0
- package/src/core/viewport/Viewport.tsx +43 -0
- package/src/hooks/useClientService.tsx +29 -0
- package/src/hooks/useControlledValue.tsx +43 -0
- package/src/hooks/useDebounce.ts +52 -0
- package/src/hooks/useEffectDebugger.ts +154 -0
- package/src/hooks/useIsDark.ts +50 -0
- package/src/hooks/useIsRtl.ts +46 -0
- package/src/hooks/useNavigator.tsx +54 -0
- package/src/hooks/useOverlayService.tsx +51 -0
- package/src/hooks/usePropToggle.ts +61 -0
- package/src/hooks/useResize.ts +90 -0
- package/src/hooks/useResizeObserver.ts +55 -0
- package/src/hooks/useStorage.ts +76 -0
- package/src/hotkeys/HotKey.tsx +39 -0
- package/src/hotkeys/HotKeyLabel.tsx +61 -0
- package/src/hotkeys/HotKeyWrapper.tsx +137 -0
- package/src/hotkeys/commons.ts +74 -0
- package/src/i18n/ar.json +21 -0
- package/src/i18n/en.json +34 -0
- package/src/i18n/index.ts +50 -0
- package/src/index.ts +51 -0
- package/src/overlays/alert/Alert.module.css +44 -0
- package/src/overlays/alert/Alert.tsx +229 -0
- package/src/overlays/flyout/Flyout.module.css +52 -0
- package/src/overlays/flyout/Flyout.tsx +283 -0
- package/src/overlays/index.ts +29 -0
- package/src/overlays/message/Message.module.css +37 -0
- package/src/overlays/message/Message.tsx +107 -0
- package/src/overlays/modal/Modal.module.css +53 -0
- package/src/overlays/modal/Modal.tsx +244 -0
- package/src/overlays/toast/Toast.module.css +37 -0
- package/src/overlays/toast/Toast.tsx +216 -0
- package/src/overlays/tooltip/Tooltip.module.css +53 -0
- package/src/overlays/tooltip/Tooltip.tsx +200 -0
- package/src/types/global.d.ts +83 -0
- package/src/types/icons.ts +420 -0
- package/src/types/index.ts +238 -0
- package/src/typography/Abbr.tsx +152 -0
- package/src/typography/Copy.tsx +61 -0
- package/src/typography/Link.tsx +110 -0
- package/src/typography/Mark.tsx +122 -0
- package/src/typography/Text.tsx +194 -0
- package/src/typography/Title.tsx +126 -0
- package/src/typography/Typography.module.css +68 -0
- package/src/typography/index.ts +29 -0
- package/src/typography/types.ts +38 -0
- package/src/utils/calculateDimensions.ts +72 -0
- package/src/utils/getColor.ts +49 -0
- package/src/utils/index.ts +28 -0
- package/src/utils/nodeCheck.ts +34 -0
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version: 1.0.0
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* The MIT License (MIT)
|
|
7
|
+
* Copyright (c) 2024 Adarsh Pastakia
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
+
* subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
+
* portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
@layer comp {
|
|
25
|
+
.buttonWrapper {
|
|
26
|
+
--color: theme(colors.primary.500);
|
|
27
|
+
|
|
28
|
+
font-size: 1rem;
|
|
29
|
+
border-radius: var(--rounding);
|
|
30
|
+
|
|
31
|
+
& .button {
|
|
32
|
+
color: var(--text);
|
|
33
|
+
|
|
34
|
+
background-color: var(--bg);
|
|
35
|
+
background-image: var(--click-gradient);
|
|
36
|
+
border-radius: inherit;
|
|
37
|
+
outline: 1px solid var(--outline);
|
|
38
|
+
|
|
39
|
+
&.spinOnHover:hover .buttonIcon {
|
|
40
|
+
& :global {
|
|
41
|
+
animation: spin 2s linear infinite;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
& > * {
|
|
46
|
+
pointer-events: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&:not(:disabled) input[type="file"] {
|
|
50
|
+
pointer-events: auto;
|
|
51
|
+
|
|
52
|
+
&::-webkit-file-upload-button {
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
position: absolute;
|
|
55
|
+
inset: 0;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
& .rounded {
|
|
61
|
+
border-radius: 9999px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
& .buttonLabel {
|
|
65
|
+
order: 1;
|
|
66
|
+
padding: 0.5em 1em;
|
|
67
|
+
line-height: 1;
|
|
68
|
+
|
|
69
|
+
& + .altIcon {
|
|
70
|
+
margin-inline-start: -1em;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
& .buttonChild {
|
|
75
|
+
order: 1;
|
|
76
|
+
padding: 0.5em;
|
|
77
|
+
line-height: 1;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
& .buttonIcon {
|
|
81
|
+
padding: 0.3889em;
|
|
82
|
+
font-size: 1.125em;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
& :global(.hotkey-label) {
|
|
86
|
+
align-self: center;
|
|
87
|
+
order: 3;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
& .altIcon {
|
|
91
|
+
align-self: center;
|
|
92
|
+
order: 4;
|
|
93
|
+
padding: 0.125em 0.5em;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
& [data-ref="badge"] {
|
|
97
|
+
align-self: center;
|
|
98
|
+
order: 2;
|
|
99
|
+
margin-inline-end: 0.5em;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.buttonGroup {
|
|
104
|
+
& > .buttonWrapper {
|
|
105
|
+
flex: 0 1 1em;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&:not(.flex) + &:not(.flex) {
|
|
109
|
+
margin-inline-start: 0.5rem;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@layer util {
|
|
115
|
+
.buttonWrapper {
|
|
116
|
+
&[data-size="xs"] {
|
|
117
|
+
font-size: 0.625rem;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
&[data-size="sm"] {
|
|
121
|
+
font-size: 0.875rem;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
&[data-size="md"] {
|
|
125
|
+
font-size: 1.125rem;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&[data-size="lg"] {
|
|
129
|
+
font-size: 1.25rem;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&[data-size="xl"] {
|
|
133
|
+
font-size: 1.5rem;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.button {
|
|
138
|
+
--bg: color-mix(in lab, var(--fabric-bg) 99%, var(--tint));
|
|
139
|
+
--outline: color-mix(in lab, var(--bg) 90%, var(--fabric-text));
|
|
140
|
+
--text: color-mix(in lab, var(--color) 80%, var(--fabric-text));
|
|
141
|
+
--bg-hover: color-mix(in lab, var(--color) 18%, var(--fabric-bg));
|
|
142
|
+
--bg-click: color-mix(in lab, var(--color) 25%, var(--fabric-bg));
|
|
143
|
+
--bg-active: color-mix(in lab, var(--color) 36%, var(--fabric-bg));
|
|
144
|
+
|
|
145
|
+
&[data-color="accent"] {
|
|
146
|
+
--color: theme(colors.accent.500);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
&[data-color="info"] {
|
|
150
|
+
--color: theme(colors.info.500);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
&[data-color="danger"] {
|
|
154
|
+
--color: theme(colors.danger.500);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
&[data-color="success"] {
|
|
158
|
+
--color: theme(colors.success.500);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
&[data-color="warning"] {
|
|
162
|
+
--color: theme(colors.warning.500);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
&[data-variant="outline"] {
|
|
166
|
+
--outline: var(--color);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
&[data-variant="solid"] {
|
|
170
|
+
--outline: var(--color);
|
|
171
|
+
--bg: color-mix(in lab, var(--color) 96%, var(--fabric-text));
|
|
172
|
+
--text: theme(colors.white);
|
|
173
|
+
--bg-hover: color-mix(in lab, var(--color) 90%, var(--fabric-bg));
|
|
174
|
+
--bg-click: color-mix(in lab, var(--color) 80%, theme(colors.black));
|
|
175
|
+
--bg-active: color-mix(in lab, var(--color) 70%, theme(colors.black));
|
|
176
|
+
|
|
177
|
+
& :global(.hotkey-label) {
|
|
178
|
+
color: theme(colors.white/70%);
|
|
179
|
+
background-color: theme(backgroundColor.dark/30%);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
&[data-variant="link"] {
|
|
184
|
+
--bg: transparent;
|
|
185
|
+
--outline: transparent;
|
|
186
|
+
|
|
187
|
+
background-image: none;
|
|
188
|
+
box-shadow: none;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
&[data-color="invert"] {
|
|
192
|
+
--bg: theme(backgroundColor.invert);
|
|
193
|
+
--text: color-mix(in lab, var(--color) 90%, theme(textColor.invert));
|
|
194
|
+
--bg-hover: color-mix(
|
|
195
|
+
in lab,
|
|
196
|
+
var(--color) 15%,
|
|
197
|
+
theme(backgroundColor.invert)
|
|
198
|
+
);
|
|
199
|
+
--bg-click: color-mix(
|
|
200
|
+
in lab,
|
|
201
|
+
var(--color) 35%,
|
|
202
|
+
theme(backgroundColor.invert)
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.buttonIcon[data-align="start"] {
|
|
208
|
+
order: 0;
|
|
209
|
+
|
|
210
|
+
& + .buttonLabel[data-colored-icon="false"] {
|
|
211
|
+
margin-inline-start: -1em;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.buttonIcon[data-align="end"] {
|
|
216
|
+
order: 2;
|
|
217
|
+
|
|
218
|
+
& ~ .buttonLabel[data-colored-icon="false"] {
|
|
219
|
+
margin-inline-end: -1em;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@layer var {
|
|
225
|
+
.buttonWrapper {
|
|
226
|
+
height: unset;
|
|
227
|
+
padding: unset;
|
|
228
|
+
|
|
229
|
+
&[data-disabled="true"] {
|
|
230
|
+
cursor: not-allowed;
|
|
231
|
+
|
|
232
|
+
& .button {
|
|
233
|
+
pointer-events: none;
|
|
234
|
+
opacity: 0.5;
|
|
235
|
+
background-image: var(--active-gradient);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
&[data-loading="true"] {
|
|
240
|
+
cursor: wait;
|
|
241
|
+
|
|
242
|
+
& .button {
|
|
243
|
+
pointer-events: none;
|
|
244
|
+
background-image: var(--progress-gradient);
|
|
245
|
+
background-size: 1em 1em;
|
|
246
|
+
|
|
247
|
+
& :global {
|
|
248
|
+
animation: progress 750ms linear infinite;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
& .button:not([data-variant="solid"]) {
|
|
253
|
+
background-color: color-mix(in lab, var(--color) 15%, var(--fabric-bg));
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
&:global(.btn-dashed) > .button {
|
|
258
|
+
color: theme(colors.tint.600);
|
|
259
|
+
outline: 1px dashed theme(colors.tint.600);
|
|
260
|
+
|
|
261
|
+
&[data-invalid="true"] {
|
|
262
|
+
color: theme(colors.danger.600);
|
|
263
|
+
background-color: theme(colors.danger.100);
|
|
264
|
+
outline: 1px dashed theme(colors.danger.600);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.button {
|
|
270
|
+
--tw-ring-color: var(--color);
|
|
271
|
+
|
|
272
|
+
&:hover {
|
|
273
|
+
background-color: var(--bg-hover);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
&:active {
|
|
277
|
+
background-color: var(--bg-click);
|
|
278
|
+
background-image: var(--active-gradient);
|
|
279
|
+
|
|
280
|
+
.buttonIcon,
|
|
281
|
+
.buttonLabel {
|
|
282
|
+
transform: translateY(1px);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
&[data-active="true"],
|
|
287
|
+
&[data-checked="true"],
|
|
288
|
+
&[data-dropdown-open="true"] {
|
|
289
|
+
background-color: var(--bg-active);
|
|
290
|
+
background-image: none;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
&[data-dropdown-open="true"] {
|
|
294
|
+
pointer-events: none;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
&[data-active="true"] {
|
|
298
|
+
pointer-events: none;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.buttonGroup {
|
|
303
|
+
& > .buttonWrapper {
|
|
304
|
+
margin: 0;
|
|
305
|
+
|
|
306
|
+
& .button[data-variant="link"] {
|
|
307
|
+
--outline: theme(backgroundColor.base);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
&:not(.vertical) {
|
|
312
|
+
& > :not(:first-child) {
|
|
313
|
+
&::before {
|
|
314
|
+
content: "";
|
|
315
|
+
|
|
316
|
+
position: absolute;
|
|
317
|
+
inset-block: 5%;
|
|
318
|
+
inset-inline-start: -0.5px;
|
|
319
|
+
|
|
320
|
+
border-inline-start: 0.5px solid theme(borderColor.base);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
&.separator > :not(:first-child) {
|
|
325
|
+
margin-inline-start: 2px;
|
|
326
|
+
|
|
327
|
+
&::before {
|
|
328
|
+
inset-inline-start: -1.5px;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
& > :not(:last-child) .button {
|
|
333
|
+
border-start-end-radius: 0;
|
|
334
|
+
border-end-end-radius: 0;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
& > :not(:first-child) .button {
|
|
338
|
+
border-start-start-radius: 0;
|
|
339
|
+
border-end-start-radius: 0;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
&.vertical {
|
|
344
|
+
& > :not(:first-child) {
|
|
345
|
+
&::before {
|
|
346
|
+
content: "";
|
|
347
|
+
|
|
348
|
+
position: absolute;
|
|
349
|
+
inset-block-start: -0.5px;
|
|
350
|
+
inset-inline: 5%;
|
|
351
|
+
|
|
352
|
+
border-block-start: 0.5px solid theme(borderColor.base);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
&.separator > :not(:first-child) {
|
|
357
|
+
margin-block-start: 1px;
|
|
358
|
+
|
|
359
|
+
&::before {
|
|
360
|
+
inset-block-start: -1px;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
& > :not(:last-child) .button {
|
|
365
|
+
border-end-start-radius: 0;
|
|
366
|
+
border-end-end-radius: 0;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
& > :not(:first-child) .button {
|
|
370
|
+
border-start-start-radius: 0;
|
|
371
|
+
border-start-end-radius: 0;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version: 1.0.0
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* The MIT License (MIT)
|
|
7
|
+
* Copyright (c) 2024 Adarsh Pastakia
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
+
* subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
+
* portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { isNil, isString, mergeRefs } from "@react-fabric/utilities";
|
|
25
|
+
import classNames from "classnames";
|
|
26
|
+
import {
|
|
27
|
+
Fragment,
|
|
28
|
+
isValidElement,
|
|
29
|
+
type MouseEventHandler,
|
|
30
|
+
useCallback,
|
|
31
|
+
useEffect,
|
|
32
|
+
useMemo,
|
|
33
|
+
useRef,
|
|
34
|
+
useState,
|
|
35
|
+
type WheelEventHandler,
|
|
36
|
+
} from "react";
|
|
37
|
+
import { useEffectDebugger } from "../../hooks/useEffectDebugger";
|
|
38
|
+
import { HotKey } from "../../hotkeys/HotKey";
|
|
39
|
+
import { HotKeyLabel } from "../../hotkeys/HotKeyLabel";
|
|
40
|
+
import { Tooltip } from "../../overlays/tooltip/Tooltip";
|
|
41
|
+
import {
|
|
42
|
+
type AriaProps,
|
|
43
|
+
type BadgeType,
|
|
44
|
+
type CallbackReturn,
|
|
45
|
+
type ColorType,
|
|
46
|
+
type CssProp,
|
|
47
|
+
type IconProps,
|
|
48
|
+
type PolymorphicProps,
|
|
49
|
+
type RefProp,
|
|
50
|
+
type SizeType,
|
|
51
|
+
type TestProps,
|
|
52
|
+
type TooltipType,
|
|
53
|
+
} from "../../types";
|
|
54
|
+
import { AnimationIndicator } from "../animations/Animations";
|
|
55
|
+
import { Badge, getBadgeProps } from "../badge/Badge";
|
|
56
|
+
import { Icon } from "../icon/Icon";
|
|
57
|
+
import classes from "./Button.module.css";
|
|
58
|
+
|
|
59
|
+
export interface BaseProps
|
|
60
|
+
extends CssProp,
|
|
61
|
+
AriaProps,
|
|
62
|
+
IconProps,
|
|
63
|
+
RefProp,
|
|
64
|
+
TestProps {
|
|
65
|
+
/**
|
|
66
|
+
* primary icon alignment
|
|
67
|
+
*/
|
|
68
|
+
iconAlign?: "start" | "end";
|
|
69
|
+
/**
|
|
70
|
+
* alternate icon align end (caret, arrow)
|
|
71
|
+
*/
|
|
72
|
+
altIcon?: string;
|
|
73
|
+
/**
|
|
74
|
+
* button size
|
|
75
|
+
*/
|
|
76
|
+
size?: SizeType;
|
|
77
|
+
/**
|
|
78
|
+
* button color
|
|
79
|
+
*/
|
|
80
|
+
color?: ColorType;
|
|
81
|
+
/**
|
|
82
|
+
* button type
|
|
83
|
+
*/
|
|
84
|
+
type?: "button" | "reset" | "submit";
|
|
85
|
+
/**
|
|
86
|
+
* button styling
|
|
87
|
+
*/
|
|
88
|
+
variant?: "outline" | "solid" | "link";
|
|
89
|
+
/**
|
|
90
|
+
* active state with click disabled
|
|
91
|
+
*/
|
|
92
|
+
active?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* loading state with animation and click disabled
|
|
95
|
+
*/
|
|
96
|
+
loading?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* full rounded edges
|
|
99
|
+
*/
|
|
100
|
+
rounded?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* spin icon on hover
|
|
103
|
+
*/
|
|
104
|
+
spinOnHover?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* disabled state
|
|
107
|
+
*/
|
|
108
|
+
disabled?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* stretch to full width
|
|
111
|
+
*/
|
|
112
|
+
fullWidth?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* action completed message works best with `onClick` Promise return.
|
|
115
|
+
* To hide completed message onClick/Promise return should be false
|
|
116
|
+
*/
|
|
117
|
+
actionMessage?: string;
|
|
118
|
+
/**
|
|
119
|
+
* manually force show action message
|
|
120
|
+
*/
|
|
121
|
+
showActionDone?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* show action message `onClick` or manually by setting `showActionDone` true
|
|
124
|
+
*/
|
|
125
|
+
showActionDoneEvent?: "click" | "manual";
|
|
126
|
+
/**
|
|
127
|
+
* click handler, return Promise to autoset loading state
|
|
128
|
+
*/
|
|
129
|
+
onClick?: (e?: React.MouseEvent) => CallbackReturn;
|
|
130
|
+
/**
|
|
131
|
+
* badges
|
|
132
|
+
*/
|
|
133
|
+
badge?: string | number | BadgeType;
|
|
134
|
+
/**
|
|
135
|
+
* keyboard shortcut
|
|
136
|
+
*/
|
|
137
|
+
hotKey?: string;
|
|
138
|
+
|
|
139
|
+
onMouseOut?: MouseEventHandler;
|
|
140
|
+
onMouseOver?: MouseEventHandler;
|
|
141
|
+
onMouseMove?: MouseEventHandler;
|
|
142
|
+
onMouseEnter?: MouseEventHandler;
|
|
143
|
+
onMouseLeave?: MouseEventHandler;
|
|
144
|
+
|
|
145
|
+
onWheel?: WheelEventHandler;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export type ButtonProps =
|
|
149
|
+
| { children: string | React.ReactElement; "aria-label"?: string }
|
|
150
|
+
| { children?: never; "aria-label": string };
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Clickable action button
|
|
154
|
+
*/
|
|
155
|
+
export const Button = <Tag extends React.ElementType = "button">({
|
|
156
|
+
as,
|
|
157
|
+
ref,
|
|
158
|
+
children,
|
|
159
|
+
className,
|
|
160
|
+
active,
|
|
161
|
+
color = "primary",
|
|
162
|
+
icon,
|
|
163
|
+
iconBg,
|
|
164
|
+
iconColor,
|
|
165
|
+
iconAlign = "start",
|
|
166
|
+
altIcon,
|
|
167
|
+
rtlFlip,
|
|
168
|
+
rounded,
|
|
169
|
+
size,
|
|
170
|
+
disabled,
|
|
171
|
+
loading,
|
|
172
|
+
variant,
|
|
173
|
+
badge,
|
|
174
|
+
fullWidth,
|
|
175
|
+
spinOnHover,
|
|
176
|
+
onClick,
|
|
177
|
+
actionMessage,
|
|
178
|
+
type = "button",
|
|
179
|
+
hotKey,
|
|
180
|
+
showActionDone,
|
|
181
|
+
showActionDoneEvent = "click",
|
|
182
|
+
tabIndex = 0,
|
|
183
|
+
// @ts-expect-error ignore
|
|
184
|
+
"data-ref": dataRef,
|
|
185
|
+
...aria
|
|
186
|
+
}: BaseProps & ButtonProps & PolymorphicProps<Tag>) => {
|
|
187
|
+
const refEl = useRef<AnyObject>(null);
|
|
188
|
+
const [busy, setBusy] = useState(false);
|
|
189
|
+
const [actionDone, setActionDone] = useState(false);
|
|
190
|
+
|
|
191
|
+
const clickHandler = useCallback(
|
|
192
|
+
(e: React.MouseEvent) => {
|
|
193
|
+
setBusy(true);
|
|
194
|
+
// e.stopPropagation();
|
|
195
|
+
const ret = onClick?.(e);
|
|
196
|
+
void Promise.resolve(ret).then((b) => {
|
|
197
|
+
setBusy(false);
|
|
198
|
+
if (b !== false && actionMessage && showActionDoneEvent === "click") {
|
|
199
|
+
setActionDone(true);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
},
|
|
203
|
+
[onClick, disabled, actionMessage, showActionDoneEvent],
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
/** ***************** reset done state on timeout *******************/
|
|
207
|
+
useEffect(() => {
|
|
208
|
+
actionMessage && showActionDone && setActionDone(true);
|
|
209
|
+
}, [showActionDone, actionMessage]);
|
|
210
|
+
useEffectDebugger(
|
|
211
|
+
() => {
|
|
212
|
+
if (actionDone) {
|
|
213
|
+
const timer = setTimeout(() => setActionDone(false), 2000);
|
|
214
|
+
return () => clearTimeout(timer);
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
[actionDone],
|
|
218
|
+
"ActionButton done handler",
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
const TooltipWrapper = useMemo(
|
|
222
|
+
() => (actionMessage ? Tooltip : Fragment),
|
|
223
|
+
[actionMessage, actionDone],
|
|
224
|
+
);
|
|
225
|
+
const tooltipProps = useMemo(() => {
|
|
226
|
+
if (actionDone && actionMessage) {
|
|
227
|
+
return {
|
|
228
|
+
content: actionMessage,
|
|
229
|
+
placement: "top",
|
|
230
|
+
color,
|
|
231
|
+
open: true,
|
|
232
|
+
} as TooltipType;
|
|
233
|
+
}
|
|
234
|
+
}, [actionDone, actionMessage, color]);
|
|
235
|
+
|
|
236
|
+
const badgeProps = useMemo(() => {
|
|
237
|
+
return getBadgeProps(badge);
|
|
238
|
+
}, [badge]);
|
|
239
|
+
|
|
240
|
+
const E = as ?? "button";
|
|
241
|
+
return (
|
|
242
|
+
<div
|
|
243
|
+
className={classNames(
|
|
244
|
+
classes.buttonWrapper,
|
|
245
|
+
className,
|
|
246
|
+
"relative align-text-top select-none focus-within:z-1",
|
|
247
|
+
fullWidth ? "block w-full" : "inline-block",
|
|
248
|
+
)}
|
|
249
|
+
data-ref={dataRef ?? "button"}
|
|
250
|
+
data-size={size}
|
|
251
|
+
data-loading={busy || loading}
|
|
252
|
+
data-disabled={disabled}
|
|
253
|
+
>
|
|
254
|
+
{hotKey && (
|
|
255
|
+
<HotKey
|
|
256
|
+
keyCombo={hotKey}
|
|
257
|
+
handler={() => !disabled && refEl.current?.click()}
|
|
258
|
+
/>
|
|
259
|
+
)}
|
|
260
|
+
<TooltipWrapper {...tooltipProps}>
|
|
261
|
+
<E
|
|
262
|
+
ref={mergeRefs(ref, refEl)}
|
|
263
|
+
role="button"
|
|
264
|
+
className={classNames(
|
|
265
|
+
classes.button,
|
|
266
|
+
"pointer-events-auto cursor-pointer select-none flex flex-nowrap w-full h-full items-center border-0 -outline-offset-1 justify-center max-w-72 p-0 font-sans font-medium appearance-none",
|
|
267
|
+
`focus-visible:ring-2 focus-visible:ring-offset-2 buttonInner`,
|
|
268
|
+
fullWidth && "max-w-full w-full",
|
|
269
|
+
rounded && "rounded-full",
|
|
270
|
+
spinOnHover && classes.spinOnHover,
|
|
271
|
+
)}
|
|
272
|
+
type={type}
|
|
273
|
+
disabled={disabled}
|
|
274
|
+
tabIndex={tabIndex}
|
|
275
|
+
data-inner-clickable
|
|
276
|
+
onClick={clickHandler}
|
|
277
|
+
data-color={color}
|
|
278
|
+
data-active={active}
|
|
279
|
+
data-variant={variant}
|
|
280
|
+
{...aria}
|
|
281
|
+
>
|
|
282
|
+
{icon && (
|
|
283
|
+
<Icon
|
|
284
|
+
className={classes.buttonIcon}
|
|
285
|
+
icon={icon}
|
|
286
|
+
bg={iconBg}
|
|
287
|
+
color={iconColor}
|
|
288
|
+
rtlFlip={rtlFlip}
|
|
289
|
+
data-align={iconAlign}
|
|
290
|
+
/>
|
|
291
|
+
)}
|
|
292
|
+
{isValidElement(children) && (
|
|
293
|
+
<div className={classes.buttonChild}>{children}</div>
|
|
294
|
+
)}
|
|
295
|
+
{isString(children) && (
|
|
296
|
+
<label
|
|
297
|
+
className={classNames(classes.buttonLabel, "truncate")}
|
|
298
|
+
data-colored-icon={!!iconBg}
|
|
299
|
+
>
|
|
300
|
+
{children}
|
|
301
|
+
</label>
|
|
302
|
+
)}
|
|
303
|
+
{!isNil(badge) && <Badge {...badgeProps} />}
|
|
304
|
+
{hotKey && <HotKeyLabel keyCombo={hotKey} />}
|
|
305
|
+
{altIcon && (
|
|
306
|
+
<Icon className={classes.altIcon} icon={altIcon} rtlFlip />
|
|
307
|
+
)}
|
|
308
|
+
</E>
|
|
309
|
+
</TooltipWrapper>
|
|
310
|
+
{actionDone && (
|
|
311
|
+
<div
|
|
312
|
+
className={classNames(
|
|
313
|
+
"absolute inset-0 overflow-hidden flex justify-center items-center",
|
|
314
|
+
`bg-${color}-300`,
|
|
315
|
+
rounded ? "rounded-full" : "rounded",
|
|
316
|
+
)}
|
|
317
|
+
>
|
|
318
|
+
<AnimationIndicator type="check" color={color} />
|
|
319
|
+
</div>
|
|
320
|
+
)}
|
|
321
|
+
</div>
|
|
322
|
+
);
|
|
323
|
+
};
|