@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,152 @@
|
|
|
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
|
+
.cardWrapper.selected {
|
|
26
|
+
&::before {
|
|
27
|
+
content: "";
|
|
28
|
+
|
|
29
|
+
position: absolute;
|
|
30
|
+
z-index: 5;
|
|
31
|
+
top: -4px;
|
|
32
|
+
inset-inline-start: -4px;
|
|
33
|
+
|
|
34
|
+
border-top: 1rem solid theme(colors.accent.500);
|
|
35
|
+
border-bottom: 1rem solid transparent;
|
|
36
|
+
border-inline-start: 1rem solid theme(colors.accent.500);
|
|
37
|
+
border-inline-end: 1rem solid transparent;
|
|
38
|
+
border-start-start-radius: var(--rounding-cap);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&::after {
|
|
42
|
+
content: "✓";
|
|
43
|
+
|
|
44
|
+
position: absolute;
|
|
45
|
+
z-index: 5;
|
|
46
|
+
top: -4px;
|
|
47
|
+
inset-inline-start: -4px;
|
|
48
|
+
|
|
49
|
+
padding: 4px;
|
|
50
|
+
|
|
51
|
+
line-height: 1;
|
|
52
|
+
color: theme(colors.white);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.card {
|
|
57
|
+
background-color: var(--fabric-bg);
|
|
58
|
+
box-shadow: 0 0 0 1px theme(borderColor.muted);
|
|
59
|
+
|
|
60
|
+
& > * {
|
|
61
|
+
background-color: transparent;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
& .cardCover {
|
|
65
|
+
&.inheritScheme:has([data-colorset="dark"]) > .cardCoverContent,
|
|
66
|
+
&.dark > .cardCoverContent {
|
|
67
|
+
color: var(--white);
|
|
68
|
+
text-shadow: 0 0 2px var(--black);
|
|
69
|
+
background-image: linear-gradient(to bottom, #0000 0, #0006 100%);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&.inheritScheme:has([data-colorset="light"]) > .cardCoverContent,
|
|
73
|
+
&.light > .cardCoverContent {
|
|
74
|
+
color: var(--black);
|
|
75
|
+
text-shadow: 0 0 2px var(--white);
|
|
76
|
+
background-image: linear-gradient(to bottom, #fff0 0, #fff6 100%);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
& .cardBody {
|
|
81
|
+
padding: 1rem;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&.clickable {
|
|
85
|
+
box-shadow:
|
|
86
|
+
0 0 0 1px theme(borderColor.dimmed),
|
|
87
|
+
0 1px 2px 0 var(--fabric-shadow);
|
|
88
|
+
transition: box-shadow 0ms;
|
|
89
|
+
|
|
90
|
+
&:has(.cardBody:hover):not(:has([data-inner-clickable="true"]:hover)) {
|
|
91
|
+
box-shadow:
|
|
92
|
+
0 0 0 1px theme(borderColor.dimmed),
|
|
93
|
+
0 1px 4px 0 var(--fabric-shadow),
|
|
94
|
+
0 8px 16px 0 color-mix(in lab, var(--fabric-shadow) 35%, #0000);
|
|
95
|
+
transition-delay: 150ms;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&:has(.cardBody:active):not(:has([data-inner-clickable="true"]:hover)) {
|
|
99
|
+
transform: translateY(1px);
|
|
100
|
+
box-shadow: 0 0 0 1px theme(borderColor.dimmed);
|
|
101
|
+
transition-delay: 0ms;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
& .cardBody {
|
|
105
|
+
cursor: pointer;
|
|
106
|
+
|
|
107
|
+
&::after {
|
|
108
|
+
pointer-events: none;
|
|
109
|
+
content: "";
|
|
110
|
+
|
|
111
|
+
position: absolute;
|
|
112
|
+
z-index: 5;
|
|
113
|
+
inset: 0;
|
|
114
|
+
|
|
115
|
+
background-image: linear-gradient(
|
|
116
|
+
175deg,
|
|
117
|
+
rgb(255 255 255 / 5%) 0%,
|
|
118
|
+
transparent 18%,
|
|
119
|
+
transparent 72%,
|
|
120
|
+
rgb(0 0 0 / 5%) 100%
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@layer util {
|
|
129
|
+
.card {
|
|
130
|
+
& .cardBody {
|
|
131
|
+
& > * {
|
|
132
|
+
grid-area: unset;
|
|
133
|
+
background-color: transparent;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
& .cardCover {
|
|
138
|
+
& > [data-ref="image"],
|
|
139
|
+
& > [data-ref="video"] {
|
|
140
|
+
position: absolute;
|
|
141
|
+
z-index: 0;
|
|
142
|
+
inset: 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
& .cardCoverContent {
|
|
146
|
+
& > * {
|
|
147
|
+
flex: 0 0 auto;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
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 classNames from "classnames";
|
|
25
|
+
import {
|
|
26
|
+
Children,
|
|
27
|
+
useMemo,
|
|
28
|
+
type DragEvent,
|
|
29
|
+
type MouseEventHandler,
|
|
30
|
+
} from "react";
|
|
31
|
+
import { ErrorBoundary } from "../../core/boundary/ErrorBoundary";
|
|
32
|
+
import { type ContentProps } from "../../core/content/Content";
|
|
33
|
+
import {
|
|
34
|
+
Footer,
|
|
35
|
+
Header,
|
|
36
|
+
type HeadFootProps,
|
|
37
|
+
} from "../../core/headfoot/HeadFoot";
|
|
38
|
+
import {
|
|
39
|
+
type AriaProps,
|
|
40
|
+
type ChildrenProp,
|
|
41
|
+
type CssProp,
|
|
42
|
+
type TestProps,
|
|
43
|
+
} from "../../types";
|
|
44
|
+
import { nodeCheck } from "../../utils";
|
|
45
|
+
import classes from "./Card.module.css";
|
|
46
|
+
|
|
47
|
+
export interface CardProps
|
|
48
|
+
extends CssProp,
|
|
49
|
+
AriaProps,
|
|
50
|
+
TestProps,
|
|
51
|
+
ChildrenProp<React.ReactElement<HeadFootProps | ContentProps>> {
|
|
52
|
+
/**
|
|
53
|
+
* apply flex fill styling
|
|
54
|
+
*/
|
|
55
|
+
flex?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* click handler
|
|
58
|
+
*/
|
|
59
|
+
onClick?: MouseEventHandler;
|
|
60
|
+
/**
|
|
61
|
+
* body css classname(s)
|
|
62
|
+
*/
|
|
63
|
+
bodyClassName?: string;
|
|
64
|
+
/**
|
|
65
|
+
* show selected ring
|
|
66
|
+
*/
|
|
67
|
+
selected?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* show tick mark ribbon
|
|
70
|
+
*/
|
|
71
|
+
selectedRibbon?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* make card draggable
|
|
74
|
+
*/
|
|
75
|
+
draggable?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* drag event data key
|
|
78
|
+
*/
|
|
79
|
+
dragKey?: string;
|
|
80
|
+
/**
|
|
81
|
+
* drag event data
|
|
82
|
+
*/
|
|
83
|
+
dragData?: KeyValue;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const Card = ({
|
|
87
|
+
children,
|
|
88
|
+
className,
|
|
89
|
+
bodyClassName,
|
|
90
|
+
selected,
|
|
91
|
+
selectedRibbon,
|
|
92
|
+
onClick,
|
|
93
|
+
flex,
|
|
94
|
+
draggable,
|
|
95
|
+
dragKey,
|
|
96
|
+
dragData,
|
|
97
|
+
...aria
|
|
98
|
+
}: CardProps) => {
|
|
99
|
+
const [header, body, footer] = useMemo(() => {
|
|
100
|
+
return Children.toArray(children as AnyObject).reduce<AnyObject[]>(
|
|
101
|
+
(ret, node) => {
|
|
102
|
+
nodeCheck(node, Header)
|
|
103
|
+
? ret[0].push(node)
|
|
104
|
+
: nodeCheck(node, Footer)
|
|
105
|
+
? ret[2].push(node)
|
|
106
|
+
: ret[1].push(node);
|
|
107
|
+
return ret;
|
|
108
|
+
},
|
|
109
|
+
[[], [], []],
|
|
110
|
+
);
|
|
111
|
+
}, [children]);
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<div
|
|
115
|
+
className={classNames(
|
|
116
|
+
classes.cardWrapper,
|
|
117
|
+
"rounded-capped relative grid",
|
|
118
|
+
flex && "flex-1",
|
|
119
|
+
selected && selectedRibbon && classes.selected,
|
|
120
|
+
selected && "outline outline-2 outline-accent-500 outline-offset-2",
|
|
121
|
+
)}
|
|
122
|
+
>
|
|
123
|
+
<ErrorBoundary>
|
|
124
|
+
<div
|
|
125
|
+
className={classNames(
|
|
126
|
+
classes.card,
|
|
127
|
+
className,
|
|
128
|
+
"rounded-capped flex flex-col flex-nowrap overflow-hidden",
|
|
129
|
+
onClick && classes.clickable,
|
|
130
|
+
)}
|
|
131
|
+
draggable={draggable}
|
|
132
|
+
onDragStart={
|
|
133
|
+
!draggable
|
|
134
|
+
? undefined
|
|
135
|
+
: (e: DragEvent) =>
|
|
136
|
+
dragKey &&
|
|
137
|
+
e.dataTransfer?.setData(dragKey, JSON.stringify(dragData))
|
|
138
|
+
}
|
|
139
|
+
{...aria}
|
|
140
|
+
>
|
|
141
|
+
{header}
|
|
142
|
+
<div
|
|
143
|
+
role="none"
|
|
144
|
+
className={classNames(classes.cardBody, bodyClassName, "flex-1")}
|
|
145
|
+
onClick={onClick}
|
|
146
|
+
>
|
|
147
|
+
{body}
|
|
148
|
+
</div>
|
|
149
|
+
{footer}
|
|
150
|
+
</div>
|
|
151
|
+
</ErrorBoundary>
|
|
152
|
+
</div>
|
|
153
|
+
);
|
|
154
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
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 classNames from "classnames";
|
|
25
|
+
import { Children, useMemo } from "react";
|
|
26
|
+
import { type AriaProps, type ChildrenProp, type CssProp } from "../../types";
|
|
27
|
+
import { nodeCheck } from "../../utils";
|
|
28
|
+
import { Image, Video } from "../media/Media";
|
|
29
|
+
import classes from "./Card.module.css";
|
|
30
|
+
|
|
31
|
+
export interface CardCoverProps extends CssProp, AriaProps, ChildrenProp {
|
|
32
|
+
/**
|
|
33
|
+
* cover height
|
|
34
|
+
*/
|
|
35
|
+
height?: string | number;
|
|
36
|
+
/**
|
|
37
|
+
* cover color scheme
|
|
38
|
+
*/
|
|
39
|
+
colorScheme?: "light" | "dark";
|
|
40
|
+
/**
|
|
41
|
+
* justify content
|
|
42
|
+
*/
|
|
43
|
+
justify?: "start" | "center" | "end";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const CardCover = ({
|
|
47
|
+
className,
|
|
48
|
+
children,
|
|
49
|
+
height = 120,
|
|
50
|
+
justify = "end",
|
|
51
|
+
colorScheme,
|
|
52
|
+
...aria
|
|
53
|
+
}: CardCoverProps) => {
|
|
54
|
+
const [media, body] = useMemo(() => {
|
|
55
|
+
return Children.toArray(children as AnyObject).reduce<AnyObject[]>(
|
|
56
|
+
(ret, node) => {
|
|
57
|
+
nodeCheck(node, Image, Video) ? ret[0].push(node) : ret[1].push(node);
|
|
58
|
+
return ret;
|
|
59
|
+
},
|
|
60
|
+
[[], []],
|
|
61
|
+
);
|
|
62
|
+
}, [children]);
|
|
63
|
+
return (
|
|
64
|
+
<div
|
|
65
|
+
style={{ height }}
|
|
66
|
+
className={classNames(
|
|
67
|
+
classes.cardCover,
|
|
68
|
+
classes[colorScheme ?? "inheritScheme"],
|
|
69
|
+
"relative z-0",
|
|
70
|
+
)}
|
|
71
|
+
{...aria}
|
|
72
|
+
>
|
|
73
|
+
{media}
|
|
74
|
+
<div
|
|
75
|
+
className={classNames(
|
|
76
|
+
classes.cardCoverContent,
|
|
77
|
+
"relative pointer-events-none z-1 flex flex-col flex-nowrap p-4 h-full",
|
|
78
|
+
className,
|
|
79
|
+
`justify-${justify}`,
|
|
80
|
+
className,
|
|
81
|
+
)}
|
|
82
|
+
>
|
|
83
|
+
{body}
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
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
|
+
.chip {
|
|
26
|
+
--blank-gradient: linear-gradient(to bottom, #00000005 0%, #0000 10%);
|
|
27
|
+
|
|
28
|
+
color: theme(colors.tint.500);
|
|
29
|
+
background-image: var(--blank-gradient);
|
|
30
|
+
outline: 1px solid color-mix(in lab, currentcolor 20%, var(--fabric-bg));
|
|
31
|
+
outline-offset: -1px;
|
|
32
|
+
|
|
33
|
+
& > .chipLabel {
|
|
34
|
+
padding: 0.25em 0.5em;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
& > .chipIcon {
|
|
38
|
+
& + .chipLabel {
|
|
39
|
+
margin-inline-start: -0.5em;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
& > .chipRemove {
|
|
44
|
+
/* mayble add styles later */
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&.clickable {
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
background-image: var(--click-gradient);
|
|
50
|
+
|
|
51
|
+
&.disabled {
|
|
52
|
+
pointer-events: none;
|
|
53
|
+
opacity: 0.5;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@layer var {
|
|
60
|
+
.chip {
|
|
61
|
+
height: unset;
|
|
62
|
+
padding: unset;
|
|
63
|
+
background-color: color-mix(in lab, currentcolor 10%, var(--fabric-bg));
|
|
64
|
+
|
|
65
|
+
&[data-variant="outline"] {
|
|
66
|
+
outline-color: color-mix(in lab, currentcolor 50%, var(--fabric-bg));
|
|
67
|
+
box-shadow: 0 0 2px color-mix(in lab, currentcolor 50%, var(--tint)) inset;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
> * {
|
|
71
|
+
color: color-mix(in lab, currentcolor 50%, var(--fabric-text));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&.clickable {
|
|
75
|
+
&:hover {
|
|
76
|
+
background-color: color-mix(in lab, currentcolor 20%, var(--fabric-bg));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&:active,
|
|
80
|
+
&[data-dropdown-open="true"] {
|
|
81
|
+
background-color: color-mix(in lab, currentcolor 15%, var(--fabric-bg));
|
|
82
|
+
background-image: var(--active-gradient);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&[data-dropdown-open="true"] {
|
|
86
|
+
pointer-events: none;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&[data-variant="solid"] {
|
|
91
|
+
background-color: color-mix(in lab, currentcolor 35%, var(--fabric-bg));
|
|
92
|
+
outline-color: color-mix(in lab, currentcolor 50%, var(--fabric-bg));
|
|
93
|
+
|
|
94
|
+
& > * {
|
|
95
|
+
color: color-mix(in lab, currentcolor 5%, var(--fabric-text));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&.clickable {
|
|
99
|
+
&:hover {
|
|
100
|
+
background-color: color-mix(
|
|
101
|
+
in lab,
|
|
102
|
+
currentcolor 45%,
|
|
103
|
+
var(--fabric-bg)
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
&:active,
|
|
108
|
+
&[data-dropdown-open="true"] {
|
|
109
|
+
background-color: color-mix(
|
|
110
|
+
in lab,
|
|
111
|
+
currentcolor 30%,
|
|
112
|
+
var(--fabric-bg)
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
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 classNames from "classnames";
|
|
25
|
+
import { useCallback, type ReactElement } from "react";
|
|
26
|
+
import { useMemoDebugger } from "../../hooks/useEffectDebugger";
|
|
27
|
+
import {
|
|
28
|
+
type AriaProps,
|
|
29
|
+
type ChildProp,
|
|
30
|
+
type ColorType,
|
|
31
|
+
type CssProp,
|
|
32
|
+
type IconProps,
|
|
33
|
+
type PolymorphicProps,
|
|
34
|
+
type RefProp,
|
|
35
|
+
type SizeType,
|
|
36
|
+
type TestProps,
|
|
37
|
+
} from "../../types";
|
|
38
|
+
import { getColor, getColorClass } from "../../utils";
|
|
39
|
+
import { Icon } from "../icon/Icon";
|
|
40
|
+
import classes from "./Chip.module.css";
|
|
41
|
+
|
|
42
|
+
export interface ChipProps
|
|
43
|
+
extends CssProp,
|
|
44
|
+
AriaProps,
|
|
45
|
+
IconProps,
|
|
46
|
+
TestProps,
|
|
47
|
+
ChildProp<string | ReactElement>,
|
|
48
|
+
RefProp<HTMLDivElement> {
|
|
49
|
+
/**
|
|
50
|
+
* chip size
|
|
51
|
+
*/
|
|
52
|
+
size?: SizeType;
|
|
53
|
+
/**
|
|
54
|
+
* chip color (CSS color / tailwind color)
|
|
55
|
+
*/
|
|
56
|
+
color?: ColorType | string;
|
|
57
|
+
/**
|
|
58
|
+
* chip styling
|
|
59
|
+
*/
|
|
60
|
+
variant?: "solid" | "outline";
|
|
61
|
+
/**
|
|
62
|
+
* full rounded edges
|
|
63
|
+
*/
|
|
64
|
+
rounded?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* disabled state
|
|
67
|
+
*/
|
|
68
|
+
disabled?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* prevent click propagation
|
|
71
|
+
*/
|
|
72
|
+
stopPropagation?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* click handler
|
|
75
|
+
*/
|
|
76
|
+
onClick?: React.MouseEventHandler;
|
|
77
|
+
/**
|
|
78
|
+
* icon click handler
|
|
79
|
+
*/
|
|
80
|
+
onIconClick?: React.MouseEventHandler;
|
|
81
|
+
/**
|
|
82
|
+
* remove handler
|
|
83
|
+
*/
|
|
84
|
+
onRemove?: React.MouseEventHandler;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const SizeMap: KeyValue<string> = {
|
|
88
|
+
xs: "0.625rem",
|
|
89
|
+
sm: "0.875rem",
|
|
90
|
+
md: "1.125rem",
|
|
91
|
+
lg: "1.5rem",
|
|
92
|
+
xl: "2rem",
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const Chip = <Tag extends React.ElementType = "div">({
|
|
96
|
+
ref,
|
|
97
|
+
children,
|
|
98
|
+
className,
|
|
99
|
+
size,
|
|
100
|
+
color,
|
|
101
|
+
variant,
|
|
102
|
+
icon,
|
|
103
|
+
iconBg,
|
|
104
|
+
iconColor,
|
|
105
|
+
rtlFlip,
|
|
106
|
+
disabled,
|
|
107
|
+
onClick,
|
|
108
|
+
onIconClick,
|
|
109
|
+
onRemove,
|
|
110
|
+
rounded,
|
|
111
|
+
stopPropagation,
|
|
112
|
+
as,
|
|
113
|
+
...aria
|
|
114
|
+
}: ChipProps & PolymorphicProps<Tag>) => {
|
|
115
|
+
/** ***************** style map *******************/
|
|
116
|
+
const styles = useMemoDebugger(
|
|
117
|
+
() => {
|
|
118
|
+
const s: KeyValue = {};
|
|
119
|
+
if (color) {
|
|
120
|
+
s.color = getColor(color);
|
|
121
|
+
}
|
|
122
|
+
if (size && !(size in SizeMap)) {
|
|
123
|
+
s.fontSize = size;
|
|
124
|
+
}
|
|
125
|
+
if (size && size in SizeMap) {
|
|
126
|
+
s.fontSize = SizeMap[size];
|
|
127
|
+
}
|
|
128
|
+
return s;
|
|
129
|
+
},
|
|
130
|
+
[color, size],
|
|
131
|
+
"Chip styles",
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
const clickHandler = useCallback(
|
|
135
|
+
(e: React.MouseEvent) => {
|
|
136
|
+
if (stopPropagation) e.stopPropagation();
|
|
137
|
+
onClick?.(e);
|
|
138
|
+
},
|
|
139
|
+
[onClick, stopPropagation],
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
const removeHandler = useCallback(
|
|
143
|
+
(e: React.MouseEvent) => {
|
|
144
|
+
if (stopPropagation) e.stopPropagation();
|
|
145
|
+
onRemove?.(e);
|
|
146
|
+
},
|
|
147
|
+
[onRemove, stopPropagation],
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
const E = as ?? "div";
|
|
151
|
+
return (
|
|
152
|
+
<E
|
|
153
|
+
ref={ref}
|
|
154
|
+
role="term"
|
|
155
|
+
className={classNames(
|
|
156
|
+
classes.chip,
|
|
157
|
+
className,
|
|
158
|
+
color && getColorClass(color),
|
|
159
|
+
"select-none inline-flex flex-nowrap items-center max-w-72 text-sm leading-none rounded",
|
|
160
|
+
rounded && "rounded-full",
|
|
161
|
+
!!onClick && classes.clickable,
|
|
162
|
+
disabled && classes.disabled,
|
|
163
|
+
)}
|
|
164
|
+
style={styles}
|
|
165
|
+
data-variant={variant}
|
|
166
|
+
data-inner-clickable={!!onClick}
|
|
167
|
+
{...{ onClick: clickHandler }}
|
|
168
|
+
{...aria}
|
|
169
|
+
>
|
|
170
|
+
{icon && (
|
|
171
|
+
<Icon
|
|
172
|
+
className={classNames(classes.chipIcon, "m-1")}
|
|
173
|
+
icon={icon}
|
|
174
|
+
bg={iconBg}
|
|
175
|
+
onClick={onIconClick}
|
|
176
|
+
color={iconColor}
|
|
177
|
+
rtlFlip={rtlFlip}
|
|
178
|
+
/>
|
|
179
|
+
)}
|
|
180
|
+
{children && (
|
|
181
|
+
<label
|
|
182
|
+
className={classNames(classes.chipLabel, "leading-none truncate")}
|
|
183
|
+
>
|
|
184
|
+
{children}
|
|
185
|
+
</label>
|
|
186
|
+
)}
|
|
187
|
+
{onRemove && (
|
|
188
|
+
<span
|
|
189
|
+
role="none"
|
|
190
|
+
className={classNames(
|
|
191
|
+
classes.chipRemove,
|
|
192
|
+
"cursor-pointer pe-1 opacity-65 hover:opacity-90",
|
|
193
|
+
)}
|
|
194
|
+
onClick={removeHandler}
|
|
195
|
+
>
|
|
196
|
+
×
|
|
197
|
+
</span>
|
|
198
|
+
)}
|
|
199
|
+
</E>
|
|
200
|
+
);
|
|
201
|
+
};
|