@react-fabric/core 1.0.0-beta.4 → 1.0.0-beta.41
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/{src/components/actionLabel/ActionLabel.module.css → css/components/_actionLabel.css} +4 -4
- package/{src/overlays/alert/Alert.module.css → css/components/_alert.css} +3 -3
- package/{src/components/animations/Animations.module.css → css/components/_animations.css} +9 -9
- package/{src/components/avatar/Avatar.module.css → css/components/_avatar.css} +11 -11
- package/{src/components/badge/Badge.module.css → css/components/_badge.css} +19 -17
- package/{src/components/breadcrumbs/Breadcrumbs.module.css → css/components/_breadcrumbs.css} +49 -44
- package/{src/components/button/Button.module.css → css/components/_button.css} +68 -78
- package/{src/components/card/Card.module.css → css/components/_card.css} +32 -28
- package/{src/components/chip/Chip.module.css → css/components/_chip.css} +15 -11
- package/{src/components/collapsable/Collapsable.module.css → css/components/_collapsable.css} +3 -3
- package/css/components/_divider.css +32 -0
- package/{src/components/dropdown/Dropdown.module.css → css/components/_dropdown.css} +2 -2
- package/{src/overlays/flyout/Flyout.module.css → css/components/_flyout.css} +6 -6
- package/{src/components/icon/Icon.module.css → css/components/_icon.css} +8 -5
- package/{src/components/media/Media.module.css → css/components/_media.css} +17 -17
- package/{src/components/menu/Menu.module.css → css/components/_menu.css} +15 -16
- package/{src/overlays/message/Message.module.css → css/components/_message.css} +2 -2
- package/{src/components/meter/Meter.module.css → css/components/_meter.css} +10 -10
- package/{src/overlays/modal/Modal.module.css → css/components/_modal.css} +6 -6
- package/{src/components/panel/Panel.module.css → css/components/_panel.css} +17 -17
- package/{src/components/progress/Progress.module.css → css/components/_progress.css} +7 -10
- package/{src/components/tabpanel/TabPanel.module.css → css/components/_tabPanel.css} +73 -84
- package/{src/overlays/toast/Toast.module.css → css/components/_toast.css} +2 -2
- package/css/components/_tooltip.css +29 -0
- package/{src/core/content/Content.module.css → css/components/index.css} +25 -18
- package/{src/core/aside/Aside.module.css → css/core/_aside.css} +42 -42
- package/{src/core/section/Section.module.css → css/core/_content.css} +5 -3
- package/{src/core/boundary/ErrorBoundary.module.css → css/core/_errorboundary.css} +9 -9
- package/{src/core/headfoot/HeadFoot.module.css → css/core/_headfoot.css} +4 -10
- package/{src/core/page/Page.module.css → css/core/_page.css} +10 -14
- package/{src/core/responsive/Responsive.module.css → css/core/_responsive.css} +10 -10
- package/css/core/_section.css +28 -0
- package/{src/core/theme/Theme.module.css → css/core/_theme.css} +3 -3
- package/{src/typography/Typography.module.css → css/core/_typography.css} +14 -12
- package/{src/core/viewport/Viewport.module.css → css/core/_viewport.css} +7 -3
- package/css/core/index.css +33 -0
- package/css/reset/_gradients.css +8 -8
- package/css/reset/_reset.css +41 -223
- package/css/reset/_text.css +14 -29
- package/css/reset/_theme.css +315 -32
- package/css/reset/index.css +4 -4
- package/css/styles.css +7 -6
- package/css/theme/_colors.css +320 -0
- package/css/theme/_utilities.css +530 -0
- package/css/theme/index.css +44 -0
- package/dist/cjs/components/actionLabel/ActionLabel.js +3 -3
- package/dist/cjs/components/animations/Animations.js +29 -18
- package/dist/cjs/components/avatar/Avatar.js +10 -13
- package/dist/cjs/components/avatar/AvatarGroup.js +3 -3
- package/dist/cjs/components/badge/Badge.js +5 -5
- package/dist/cjs/components/breadcrumbs/Breadcrumbs.js +10 -8
- package/dist/cjs/components/button/Button.js +18 -14
- package/dist/cjs/components/button/ButtonGroup.js +4 -3
- package/dist/cjs/components/button/ConfirmButton.js +7 -2
- package/dist/cjs/components/button/ToggleButtonGroup.js +3 -3
- package/dist/cjs/components/callout/Callout.js +15 -4
- package/dist/cjs/components/card/Card.js +8 -7
- package/dist/cjs/components/card/CardCover.js +10 -5
- package/dist/cjs/components/chip/Chip.js +11 -7
- package/dist/cjs/components/collapsable/Collapsable.js +5 -5
- package/dist/cjs/components/divider/Divider.js +10 -7
- package/dist/cjs/components/dropdown/Dropdown.js +5 -4
- package/dist/cjs/components/dropdown/DropdownTool.js +4 -3
- package/dist/cjs/components/empty/EmptyContent.js +6 -3
- package/dist/cjs/components/icon/Icon.js +15 -14
- package/dist/cjs/components/media/Media.js +116 -75
- package/dist/cjs/components/menu/ContextMenu.js +30 -10
- package/dist/cjs/components/menu/Menu.js +39 -20
- package/dist/cjs/components/menu/MenuItem.js +30 -16
- package/dist/cjs/components/meter/Meter.js +2 -3
- package/dist/cjs/components/navigator/Navigator.js +16 -9
- package/dist/cjs/components/panel/Panel.js +10 -9
- package/dist/cjs/components/panel/PanelGroup.js +1 -2
- package/dist/cjs/components/progress/ProgressBar.js +6 -5
- package/dist/cjs/components/progress/ProgressCircle.js +6 -4
- package/dist/cjs/components/tabpanel/Tab.js +58 -38
- package/dist/cjs/components/tabpanel/TabPanel.js +20 -16
- package/dist/cjs/core/aside/Aside.js +11 -10
- package/dist/cjs/core/boundary/ErrorBoundary.js +6 -7
- package/dist/cjs/core/boundary/ErrorIcon.js +1 -2
- package/dist/cjs/core/content/Content.js +9 -7
- package/dist/cjs/core/headfoot/HeadFoot.js +2 -20
- package/dist/cjs/core/page/Page.js +3 -3
- package/dist/cjs/core/responsive/Responsive.js +3 -4
- package/dist/cjs/core/section/Section.js +1 -2
- package/dist/cjs/core/theme/ThemeProvider.js +7 -8
- package/dist/cjs/core/viewport/Viewport.js +4 -2
- package/dist/cjs/hooks/useNavigator.js +6 -4
- package/dist/cjs/hotkeys/HotKeyLabel.js +1 -1
- package/dist/cjs/hotkeys/HotKeyWrapper.js +3 -1
- package/dist/cjs/index.js +6 -2
- package/dist/cjs/overlays/alert/Alert.js +19 -13
- package/dist/cjs/overlays/flyout/Flyout.js +49 -60
- package/dist/cjs/overlays/message/Message.js +6 -3
- package/dist/cjs/overlays/modal/Modal.js +11 -11
- package/dist/cjs/overlays/toast/Toast.js +17 -9
- package/dist/cjs/overlays/tooltip/Tooltip.js +20 -8
- package/dist/cjs/types/icons.js +4 -0
- package/dist/cjs/typography/Abbr.js +2 -3
- package/dist/cjs/typography/{Link.js → Anchor.js} +5 -4
- package/dist/cjs/typography/Mark.js +2 -3
- package/dist/cjs/typography/Text.js +3 -4
- package/dist/cjs/typography/Title.js +3 -3
- package/dist/cjs/utils/cloneElement.js +44 -0
- package/dist/cjs/utils/getColor.js +1 -18
- package/dist/esm/components/actionLabel/ActionLabel.js +3 -3
- package/dist/esm/components/animations/Animations.js +30 -19
- package/dist/esm/components/avatar/Avatar.js +11 -14
- package/dist/esm/components/avatar/AvatarGroup.js +3 -3
- package/dist/esm/components/badge/Badge.js +5 -5
- package/dist/esm/components/breadcrumbs/Breadcrumbs.js +10 -8
- package/dist/esm/components/button/Button.js +18 -14
- package/dist/esm/components/button/ButtonGroup.js +5 -4
- package/dist/esm/components/button/ConfirmButton.js +7 -2
- package/dist/esm/components/button/ToggleButtonGroup.js +4 -4
- package/dist/esm/components/callout/Callout.js +15 -4
- package/dist/esm/components/card/Card.js +8 -7
- package/dist/esm/components/card/CardCover.js +10 -5
- package/dist/esm/components/chip/Chip.js +12 -8
- package/dist/esm/components/collapsable/Collapsable.js +5 -5
- package/dist/esm/components/divider/Divider.js +11 -8
- package/dist/esm/components/dropdown/Dropdown.js +5 -4
- package/dist/esm/components/dropdown/DropdownTool.js +4 -3
- package/dist/esm/components/empty/EmptyContent.js +6 -3
- package/dist/esm/components/icon/Icon.js +15 -14
- package/dist/esm/components/media/Media.js +117 -76
- package/dist/esm/components/menu/ContextMenu.js +32 -12
- package/dist/esm/components/menu/Menu.js +41 -22
- package/dist/esm/components/menu/MenuItem.js +24 -10
- package/dist/esm/components/meter/Meter.js +2 -3
- package/dist/esm/components/navigator/Navigator.js +16 -9
- package/dist/esm/components/panel/Panel.js +10 -9
- package/dist/esm/components/panel/PanelGroup.js +1 -2
- package/dist/esm/components/progress/ProgressBar.js +6 -5
- package/dist/esm/components/progress/ProgressCircle.js +6 -4
- package/dist/esm/components/tabpanel/Tab.js +59 -39
- package/dist/esm/components/tabpanel/TabPanel.js +20 -16
- package/dist/esm/core/aside/Aside.js +11 -10
- package/dist/esm/core/boundary/ErrorBoundary.js +6 -7
- package/dist/esm/core/boundary/ErrorIcon.js +1 -2
- package/dist/esm/core/content/Content.js +9 -7
- package/dist/esm/core/headfoot/HeadFoot.js +2 -20
- package/dist/esm/core/page/Page.js +3 -3
- package/dist/esm/core/responsive/Responsive.js +3 -4
- package/dist/esm/core/section/Section.js +1 -2
- package/dist/esm/core/theme/ThemeProvider.js +7 -8
- package/dist/esm/core/viewport/Viewport.js +4 -2
- package/dist/esm/hooks/useNavigator.js +7 -5
- package/dist/esm/hotkeys/HotKeyLabel.js +1 -1
- package/dist/esm/hotkeys/HotKeyWrapper.js +3 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/overlays/alert/Alert.js +20 -14
- package/dist/esm/overlays/flyout/Flyout.js +52 -63
- package/dist/esm/overlays/message/Message.js +7 -4
- package/dist/esm/overlays/modal/Modal.js +12 -12
- package/dist/esm/overlays/toast/Toast.js +18 -10
- package/dist/esm/overlays/tooltip/Tooltip.js +20 -8
- package/dist/esm/types/icons.js +4 -0
- package/dist/esm/typography/Abbr.js +2 -3
- package/dist/esm/typography/{Link.js → Anchor.js} +6 -5
- package/dist/esm/typography/Mark.js +2 -3
- package/dist/esm/typography/Text.js +4 -5
- package/dist/esm/typography/Title.js +4 -4
- package/dist/esm/utils/cloneElement.js +44 -0
- package/dist/esm/utils/getColor.js +2 -16
- package/dist/types/components/actionLabel/ActionLabel.d.ts +2 -2
- package/dist/types/components/animations/Animations.d.ts +5 -5
- package/dist/types/components/avatar/Avatar.d.ts +3 -3
- package/dist/types/components/badge/Badge.d.ts +5 -1
- package/dist/types/components/breadcrumbs/Breadcrumbs.d.ts +2 -2
- package/dist/types/components/button/Button.d.ts +7 -5
- package/dist/types/components/button/ButtonGroup.d.ts +2 -2
- package/dist/types/components/button/ConfirmButton.d.ts +6 -1
- package/dist/types/components/callout/Callout.d.ts +2 -2
- package/dist/types/components/card/Card.d.ts +3 -3
- package/dist/types/components/chip/Chip.d.ts +3 -3
- package/dist/types/components/collapsable/Collapsable.d.ts +5 -1
- package/dist/types/components/divider/Divider.d.ts +7 -3
- package/dist/types/components/dropdown/DropdownTool.d.ts +2 -1
- package/dist/types/components/empty/EmptyContent.d.ts +6 -2
- package/dist/types/components/icon/Icon.d.ts +3 -3
- package/dist/types/components/media/Media.d.ts +2 -2
- package/dist/types/components/menu/ContextMenu.d.ts +2 -1
- package/dist/types/components/menu/MenuItem.d.ts +1 -1
- package/dist/types/components/menu/types.d.ts +2 -2
- package/dist/types/components/navigator/Navigator.d.ts +4 -4
- package/dist/types/components/progress/ProgressBar.d.ts +2 -2
- package/dist/types/components/progress/ProgressCircle.d.ts +2 -2
- package/dist/types/components/tabpanel/Tab.d.ts +5 -5
- package/dist/types/components/tabpanel/TabPanel.d.ts +10 -1
- package/dist/types/core/content/Content.d.ts +3 -2
- package/dist/types/core/headfoot/HeadFoot.d.ts +1 -9
- package/dist/types/core/responsive/Responsive.d.ts +1 -1
- package/dist/types/core/theme/ThemeProvider.d.ts +4 -4
- package/dist/types/hooks/useOverlayService.d.ts +3 -5
- package/dist/types/index.d.ts +3 -0
- package/dist/types/overlays/alert/Alert.d.ts +2 -2
- package/dist/types/overlays/flyout/Flyout.d.ts +3 -2
- package/dist/types/overlays/message/Message.d.ts +2 -2
- package/dist/types/overlays/modal/Modal.d.ts +4 -3
- package/dist/types/overlays/toast/Toast.d.ts +2 -2
- package/dist/types/overlays/tooltip/Tooltip.d.ts +1 -1
- package/dist/types/types/icons.d.ts +4 -0
- package/dist/types/types/index.d.ts +18 -6
- package/dist/types/typography/Abbr.d.ts +6 -2
- package/dist/types/typography/Anchor.d.ts +25 -0
- package/dist/types/typography/Mark.d.ts +2 -2
- package/dist/types/typography/index.d.ts +1 -1
- package/dist/types/utils/cloneElement.d.ts +2 -0
- package/dist/types/utils/getColor.d.ts +1 -4
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +7 -9
- package/src/components/actionLabel/ActionLabel.tsx +15 -6
- package/src/components/animations/Animations.tsx +29 -23
- package/src/components/avatar/Avatar.tsx +74 -88
- package/src/components/avatar/AvatarGroup.tsx +4 -4
- package/src/components/badge/Badge.tsx +11 -7
- package/src/components/breadcrumbs/Breadcrumbs.tsx +13 -9
- package/src/components/button/Button.tsx +27 -22
- package/src/components/button/ButtonGroup.tsx +7 -7
- package/src/components/button/ConfirmButton.tsx +15 -5
- package/src/components/button/ToggleButtonGroup.tsx +5 -5
- package/src/components/callout/Callout.tsx +26 -11
- package/src/components/card/Card.tsx +10 -7
- package/src/components/card/CardCover.tsx +11 -6
- package/src/components/chip/Chip.tsx +17 -13
- package/src/components/collapsable/Collapsable.tsx +9 -4
- package/src/components/divider/Divider.tsx +15 -10
- package/src/components/dropdown/Dropdown.tsx +5 -5
- package/src/components/dropdown/DropdownTool.tsx +5 -3
- package/src/components/empty/EmptyContent.tsx +17 -2
- package/src/components/icon/Icon.tsx +55 -67
- package/src/components/media/Media.tsx +141 -106
- package/src/components/menu/ContextMenu.tsx +36 -11
- package/src/components/menu/Menu.tsx +51 -30
- package/src/components/menu/MenuItem.tsx +19 -9
- package/src/components/menu/types.ts +2 -2
- package/src/components/meter/Meter.tsx +2 -3
- package/src/components/navigator/Navigator.tsx +19 -5
- package/src/components/panel/Panel.tsx +10 -9
- package/src/components/panel/PanelGroup.tsx +1 -2
- package/src/components/progress/ProgressBar.tsx +8 -9
- package/src/components/progress/ProgressCircle.tsx +6 -9
- package/src/components/tabpanel/Tab.tsx +81 -64
- package/src/components/tabpanel/TabPanel.tsx +34 -12
- package/src/core/aside/Aside.tsx +11 -10
- package/src/core/boundary/ErrorBoundary.tsx +8 -7
- package/src/core/boundary/ErrorIcon.tsx +1 -2
- package/src/core/content/Content.tsx +17 -12
- package/src/core/headfoot/HeadFoot.tsx +2 -35
- package/src/core/page/Page.tsx +3 -3
- package/src/core/responsive/Responsive.tsx +8 -7
- package/src/core/section/Section.tsx +1 -2
- package/src/core/theme/ThemeProvider.tsx +11 -12
- package/src/core/viewport/Viewport.tsx +1 -2
- package/src/hooks/useNavigator.tsx +10 -5
- package/src/hooks/useOverlayService.tsx +12 -6
- package/src/hotkeys/HotKeyLabel.tsx +1 -1
- package/src/hotkeys/HotKeyWrapper.tsx +3 -1
- package/src/index.ts +4 -0
- package/src/overlays/alert/Alert.tsx +25 -31
- package/src/overlays/flyout/Flyout.tsx +71 -84
- package/src/overlays/message/Message.tsx +10 -7
- package/src/overlays/modal/Modal.tsx +20 -15
- package/src/overlays/toast/Toast.tsx +18 -27
- package/src/overlays/tooltip/Tooltip.tsx +30 -9
- package/src/types/icons.ts +9 -0
- package/src/types/index.ts +251 -27
- package/src/typography/Abbr.tsx +15 -9
- package/src/typography/{Link.tsx → Anchor.tsx} +8 -13
- package/src/typography/Mark.tsx +4 -9
- package/src/typography/Text.tsx +4 -12
- package/src/typography/Title.tsx +2 -6
- package/src/typography/index.ts +1 -1
- package/src/utils/cloneElement.ts +44 -0
- package/src/utils/getColor.ts +1 -17
- package/src/utils/index.ts +1 -0
- package/css/index.js +0 -250
- package/css/tailwind/colors.ts +0 -158
- package/dist/cjs/components/actionLabel/ActionLabel.module.css +0 -1
- package/dist/cjs/components/animations/Animations.module.css +0 -1
- package/dist/cjs/components/avatar/Avatar.module.css +0 -1
- package/dist/cjs/components/badge/Badge.module.css +0 -1
- package/dist/cjs/components/breadcrumbs/Breadcrumbs.module.css +0 -1
- package/dist/cjs/components/button/Button.module.css +0 -1
- package/dist/cjs/components/card/Card.module.css +0 -1
- package/dist/cjs/components/chip/Chip.module.css +0 -1
- package/dist/cjs/components/collapsable/Collapsable.module.css +0 -1
- package/dist/cjs/components/dropdown/Dropdown.module.css +0 -1
- package/dist/cjs/components/icon/Icon.module.css +0 -1
- package/dist/cjs/components/media/Media.module.css +0 -1
- package/dist/cjs/components/menu/Menu.module.css +0 -1
- package/dist/cjs/components/meter/Meter.module.css +0 -1
- package/dist/cjs/components/panel/Panel.module.css +0 -1
- package/dist/cjs/components/progress/Progress.module.css +0 -1
- package/dist/cjs/components/tabpanel/TabPanel.module.css +0 -1
- package/dist/cjs/core/aside/Aside.module.css +0 -1
- package/dist/cjs/core/boundary/ErrorBoundary.module.css +0 -1
- package/dist/cjs/core/content/Content.module.css +0 -1
- package/dist/cjs/core/headfoot/HeadFoot.module.css +0 -1
- package/dist/cjs/core/page/Page.module.css +0 -1
- package/dist/cjs/core/responsive/Responsive.module.css +0 -1
- package/dist/cjs/core/section/Section.module.css +0 -1
- package/dist/cjs/core/theme/Theme.module.css +0 -1
- package/dist/cjs/core/viewport/Viewport.module.css +0 -1
- package/dist/cjs/overlays/alert/Alert.module.css +0 -1
- package/dist/cjs/overlays/flyout/Flyout.module.css +0 -1
- package/dist/cjs/overlays/message/Message.module.css +0 -1
- package/dist/cjs/overlays/modal/Modal.module.css +0 -1
- package/dist/cjs/overlays/toast/Toast.module.css +0 -1
- package/dist/cjs/overlays/tooltip/Tooltip.module.css +0 -1
- package/dist/cjs/typography/Typography.module.css +0 -1
- package/dist/esm/components/actionLabel/ActionLabel.module.css +0 -1
- package/dist/esm/components/animations/Animations.module.css +0 -1
- package/dist/esm/components/avatar/Avatar.module.css +0 -1
- package/dist/esm/components/badge/Badge.module.css +0 -1
- package/dist/esm/components/breadcrumbs/Breadcrumbs.module.css +0 -1
- package/dist/esm/components/button/Button.module.css +0 -1
- package/dist/esm/components/card/Card.module.css +0 -1
- package/dist/esm/components/chip/Chip.module.css +0 -1
- package/dist/esm/components/collapsable/Collapsable.module.css +0 -1
- package/dist/esm/components/dropdown/Dropdown.module.css +0 -1
- package/dist/esm/components/icon/Icon.module.css +0 -1
- package/dist/esm/components/media/Media.module.css +0 -1
- package/dist/esm/components/menu/Menu.module.css +0 -1
- package/dist/esm/components/meter/Meter.module.css +0 -1
- package/dist/esm/components/panel/Panel.module.css +0 -1
- package/dist/esm/components/progress/Progress.module.css +0 -1
- package/dist/esm/components/tabpanel/TabPanel.module.css +0 -1
- package/dist/esm/core/aside/Aside.module.css +0 -1
- package/dist/esm/core/boundary/ErrorBoundary.module.css +0 -1
- package/dist/esm/core/content/Content.module.css +0 -1
- package/dist/esm/core/headfoot/HeadFoot.module.css +0 -1
- package/dist/esm/core/page/Page.module.css +0 -1
- package/dist/esm/core/responsive/Responsive.module.css +0 -1
- package/dist/esm/core/section/Section.module.css +0 -1
- package/dist/esm/core/theme/Theme.module.css +0 -1
- package/dist/esm/core/viewport/Viewport.module.css +0 -1
- package/dist/esm/overlays/alert/Alert.module.css +0 -1
- package/dist/esm/overlays/flyout/Flyout.module.css +0 -1
- package/dist/esm/overlays/message/Message.module.css +0 -1
- package/dist/esm/overlays/modal/Modal.module.css +0 -1
- package/dist/esm/overlays/toast/Toast.module.css +0 -1
- package/dist/esm/overlays/tooltip/Tooltip.module.css +0 -1
- package/dist/esm/typography/Typography.module.css +0 -1
- package/dist/types/typography/Link.d.ts +0 -25
- package/src/overlays/tooltip/Tooltip.module.css +0 -53
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
import { isSvgPath } from "@react-fabric/utilities";
|
|
25
25
|
import BoringAvatar from "boring-avatars";
|
|
26
26
|
import classNames from "classnames";
|
|
27
|
-
import { useState } from "react";
|
|
28
|
-
import { useMemoDebugger } from "../../hooks/useEffectDebugger";
|
|
27
|
+
import { useMemo, useState } from "react";
|
|
29
28
|
import {
|
|
29
|
+
type PaletteType,
|
|
30
30
|
type AriaProps,
|
|
31
31
|
type ColorType,
|
|
32
32
|
type CssProp,
|
|
@@ -34,8 +34,7 @@ import {
|
|
|
34
34
|
type SizeType,
|
|
35
35
|
type TestProps,
|
|
36
36
|
} from "../../types";
|
|
37
|
-
import {
|
|
38
|
-
import classes from "./Avatar.module.css";
|
|
37
|
+
import { getColor } from "../../utils";
|
|
39
38
|
|
|
40
39
|
export interface AvatarProps extends CssProp, AriaProps, TestProps, RefProp {
|
|
41
40
|
/**
|
|
@@ -57,11 +56,11 @@ export interface AvatarProps extends CssProp, AriaProps, TestProps, RefProp {
|
|
|
57
56
|
/**
|
|
58
57
|
* background color (CSS color / tailwind color)
|
|
59
58
|
*/
|
|
60
|
-
bg?: ColorType | string;
|
|
59
|
+
bg?: ColorType | PaletteType | string;
|
|
61
60
|
/**
|
|
62
61
|
* icon color (CSS color / tailwind color)
|
|
63
62
|
*/
|
|
64
|
-
color?: ColorType | string;
|
|
63
|
+
color?: ColorType | PaletteType | string;
|
|
65
64
|
/**
|
|
66
65
|
* icon size
|
|
67
66
|
*/
|
|
@@ -109,99 +108,86 @@ export const Avatar = ({
|
|
|
109
108
|
const [fallback, setFallback] = useState(true);
|
|
110
109
|
|
|
111
110
|
/** ***************** style map *******************/
|
|
112
|
-
const styles =
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
},
|
|
129
|
-
[bg, color, size],
|
|
130
|
-
"Avatar styles",
|
|
131
|
-
);
|
|
111
|
+
const styles = useMemo(() => {
|
|
112
|
+
const s: KeyValue = {};
|
|
113
|
+
if (bg) {
|
|
114
|
+
s.backgroundColor = getColor(bg);
|
|
115
|
+
}
|
|
116
|
+
if (color) {
|
|
117
|
+
s.color = getColor(color);
|
|
118
|
+
}
|
|
119
|
+
if (size && !(size in SizeMap)) {
|
|
120
|
+
s.fontSize = size;
|
|
121
|
+
}
|
|
122
|
+
if (size && size in SizeMap) {
|
|
123
|
+
s.fontSize = SizeMap[size];
|
|
124
|
+
}
|
|
125
|
+
return s;
|
|
126
|
+
}, [bg, color, size]);
|
|
132
127
|
|
|
133
128
|
/** ***************** render icon *******************/
|
|
134
|
-
const avatarImage =
|
|
135
|
-
()
|
|
136
|
-
|
|
129
|
+
const avatarImage = useMemo(() => {
|
|
130
|
+
setFallback(!avatar);
|
|
131
|
+
return (
|
|
132
|
+
avatar && (
|
|
133
|
+
<div className="contents">
|
|
134
|
+
<div
|
|
135
|
+
className={classNames(
|
|
136
|
+
"fabric-imgPlaceholder",
|
|
137
|
+
"absolute inset-0 bg-gray animate-pulse",
|
|
138
|
+
)}
|
|
139
|
+
/>
|
|
140
|
+
<img
|
|
141
|
+
src={avatar}
|
|
142
|
+
alt={avatar}
|
|
143
|
+
className="align-baseline"
|
|
144
|
+
onError={() => setFallback(true)}
|
|
145
|
+
onLoad={(e) => e.currentTarget.previousElementSibling?.remove()}
|
|
146
|
+
/>
|
|
147
|
+
</div>
|
|
148
|
+
)
|
|
149
|
+
);
|
|
150
|
+
}, [avatar]);
|
|
151
|
+
|
|
152
|
+
const fallbackAvatar = useMemo(() => {
|
|
153
|
+
if (fallbackIcon) {
|
|
154
|
+
return isSvgPath(fallbackIcon) ? (
|
|
155
|
+
<svg viewBox={viewBox}>
|
|
156
|
+
<path fill="currentColor" d={fallbackIcon.toString()} />
|
|
157
|
+
</svg>
|
|
158
|
+
) : (
|
|
159
|
+
<i className={fallbackIcon} />
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
if (variant === "text") {
|
|
163
|
+
const [, first, second, group] = name.match(
|
|
164
|
+
/(?=(\w).* (\w).*)|(?=(\w\w).*)/,
|
|
165
|
+
) as string[];
|
|
137
166
|
return (
|
|
138
|
-
|
|
139
|
-
<
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
onError={() => setFallback(true)}
|
|
151
|
-
onLoad={(e) => e.currentTarget.previousElementSibling?.remove()}
|
|
152
|
-
/>
|
|
153
|
-
</div>
|
|
154
|
-
)
|
|
167
|
+
<svg role="img">
|
|
168
|
+
<text
|
|
169
|
+
x="50%"
|
|
170
|
+
y="50%"
|
|
171
|
+
dy=".1em"
|
|
172
|
+
dominantBaseline="middle"
|
|
173
|
+
textAnchor="middle"
|
|
174
|
+
style={{ fontSize: ".5em", fontWeight: 500 }}
|
|
175
|
+
>
|
|
176
|
+
{group ?? `${first}${second}`}
|
|
177
|
+
</text>
|
|
178
|
+
</svg>
|
|
155
179
|
);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
const fallbackAvatar = useMemoDebugger(
|
|
162
|
-
() => {
|
|
163
|
-
if (fallbackIcon) {
|
|
164
|
-
return isSvgPath(fallbackIcon) ? (
|
|
165
|
-
<svg viewBox={viewBox}>
|
|
166
|
-
<path fill="currentColor" d={fallbackIcon.toString()} />
|
|
167
|
-
</svg>
|
|
168
|
-
) : (
|
|
169
|
-
<i className={fallbackIcon} />
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
if (variant === "text") {
|
|
173
|
-
const [, first, second, group] =
|
|
174
|
-
name.match(/(?=(\w).* (\w).*)|(?=(\w\w).*)/) ?? [];
|
|
175
|
-
return (
|
|
176
|
-
<svg role="img">
|
|
177
|
-
<text
|
|
178
|
-
x="50%"
|
|
179
|
-
y="50%"
|
|
180
|
-
dy=".1em"
|
|
181
|
-
dominantBaseline="middle"
|
|
182
|
-
textAnchor="middle"
|
|
183
|
-
style={{ fontSize: ".5em", fontWeight: 500 }}
|
|
184
|
-
>
|
|
185
|
-
{group ?? `${first}${second}`}
|
|
186
|
-
</text>
|
|
187
|
-
</svg>
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
return <BoringAvatar square size={64} variant={variant} name={name} />;
|
|
191
|
-
},
|
|
192
|
-
[name, variant, fallbackIcon],
|
|
193
|
-
"Avatar fallback",
|
|
194
|
-
);
|
|
180
|
+
}
|
|
181
|
+
return <BoringAvatar square size={64} variant={variant} name={name} />;
|
|
182
|
+
}, [name, variant, fallbackIcon]);
|
|
195
183
|
|
|
196
184
|
return (
|
|
197
185
|
<dfn
|
|
198
186
|
role="presentation"
|
|
199
187
|
className={classNames(
|
|
200
|
-
|
|
188
|
+
"fabric-avatar",
|
|
201
189
|
className,
|
|
202
190
|
"select-none relative overflow-hidden inline-block box-content leading-none not-italic text-center",
|
|
203
|
-
bg && getBgClass(bg),
|
|
204
|
-
color && getColorClass(color),
|
|
205
191
|
!rounded && "rounded",
|
|
206
192
|
rounded && "rounded-full",
|
|
207
193
|
)}
|
|
@@ -31,7 +31,6 @@ import {
|
|
|
31
31
|
type SizeType,
|
|
32
32
|
} from "../../types";
|
|
33
33
|
import { type AvatarProps } from "./Avatar";
|
|
34
|
-
import classes from "./Avatar.module.css";
|
|
35
34
|
|
|
36
35
|
type AvatarChild =
|
|
37
36
|
| ReactElement<Omit<AvatarProps, "size" | "rounded">>
|
|
@@ -104,7 +103,7 @@ export const AvatarGroup = ({
|
|
|
104
103
|
{...aria}
|
|
105
104
|
ref={ref as AnyObject}
|
|
106
105
|
className={classNames(
|
|
107
|
-
|
|
106
|
+
"fabric-avatarGroup",
|
|
108
107
|
className,
|
|
109
108
|
"inline-flex flex-nowrap",
|
|
110
109
|
!rounded && "rounded",
|
|
@@ -115,10 +114,11 @@ export const AvatarGroup = ({
|
|
|
115
114
|
{avatars}
|
|
116
115
|
{!!diff && (
|
|
117
116
|
<dfn
|
|
117
|
+
data-ref="avatarCount"
|
|
118
118
|
className={classNames(
|
|
119
|
-
|
|
119
|
+
"fabric-avatar",
|
|
120
120
|
"select-none relative overflow-hidden inline-block box-content leading-none not-italic text-center",
|
|
121
|
-
|
|
121
|
+
"fabric-avatarGroup--extra",
|
|
122
122
|
)}
|
|
123
123
|
>
|
|
124
124
|
<svg>
|
|
@@ -32,7 +32,6 @@ import {
|
|
|
32
32
|
type RefProp,
|
|
33
33
|
} from "../../types";
|
|
34
34
|
import { Icon } from "../icon/Icon";
|
|
35
|
-
import classes from "./Badge.module.css";
|
|
36
35
|
|
|
37
36
|
export interface BadgeProps
|
|
38
37
|
extends CssProp,
|
|
@@ -43,6 +42,10 @@ export interface BadgeProps
|
|
|
43
42
|
* make wrapper a block element
|
|
44
43
|
*/
|
|
45
44
|
block?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* inline badge
|
|
47
|
+
*/
|
|
48
|
+
inline?: boolean;
|
|
46
49
|
/**
|
|
47
50
|
* badge value
|
|
48
51
|
*/
|
|
@@ -90,6 +93,7 @@ export const Badge = ({
|
|
|
90
93
|
max,
|
|
91
94
|
ping,
|
|
92
95
|
block,
|
|
96
|
+
inline,
|
|
93
97
|
placement = "top-end",
|
|
94
98
|
children,
|
|
95
99
|
// @ts-expect-error ignore
|
|
@@ -120,8 +124,8 @@ export const Badge = ({
|
|
|
120
124
|
return (
|
|
121
125
|
<div
|
|
122
126
|
className={classNames(
|
|
123
|
-
forButton ? "contents" : "
|
|
124
|
-
|
|
127
|
+
forButton || inline ? "contents" : block ? "block" : "inline-block",
|
|
128
|
+
forButton || inline ? "" : "relative",
|
|
125
129
|
)}
|
|
126
130
|
>
|
|
127
131
|
{children &&
|
|
@@ -129,16 +133,16 @@ export const Badge = ({
|
|
|
129
133
|
...rest,
|
|
130
134
|
ref: innerRef,
|
|
131
135
|
})}
|
|
132
|
-
{(!!ping || label) && (
|
|
136
|
+
{(!!ping || (label ?? icon)) && (
|
|
133
137
|
<div
|
|
134
138
|
data-ref="badge"
|
|
135
139
|
data-ping={ping}
|
|
136
140
|
data-placement={placement}
|
|
137
141
|
className={classNames(
|
|
138
|
-
|
|
142
|
+
"fabric-badge",
|
|
139
143
|
className,
|
|
140
|
-
"inline-block p-px min-w-2 min-h-2 text-center select-none rounded-full leading-none z-
|
|
141
|
-
forButton && !placement ? "relative" : "absolute",
|
|
144
|
+
"inline-block p-px min-w-2 min-h-2 text-center select-none rounded-full leading-none z-2 pointer-events-none",
|
|
145
|
+
(forButton && !placement) || inline ? "relative" : "absolute",
|
|
142
146
|
)}
|
|
143
147
|
>
|
|
144
148
|
{label && <span className="p-1">{label}</span>}
|
|
@@ -24,14 +24,13 @@
|
|
|
24
24
|
import classNames from "classnames";
|
|
25
25
|
import { Children, useMemo } from "react";
|
|
26
26
|
import { type AriaProps, type ChildrenProp, type CssProp } from "../../types";
|
|
27
|
-
import {
|
|
27
|
+
import { Anchor } from "../../typography/Anchor";
|
|
28
28
|
import { Dropdown } from "../dropdown/Dropdown";
|
|
29
|
-
import classes from "./Breadcrumbs.module.css";
|
|
30
29
|
|
|
31
30
|
export interface BreadcrumbProps
|
|
32
31
|
extends CssProp,
|
|
33
32
|
AriaProps,
|
|
34
|
-
ChildrenProp<typeof
|
|
33
|
+
ChildrenProp<typeof Anchor> {
|
|
35
34
|
/**
|
|
36
35
|
* breadcrumb styling
|
|
37
36
|
*/
|
|
@@ -64,10 +63,11 @@ export const Breadcrumbs = ({
|
|
|
64
63
|
|
|
65
64
|
return (
|
|
66
65
|
<nav
|
|
66
|
+
data-ref="breadcrumbs"
|
|
67
67
|
data-color={color}
|
|
68
68
|
data-variant={variant}
|
|
69
69
|
className={classNames(
|
|
70
|
-
|
|
70
|
+
"fabric-breadcrumbs",
|
|
71
71
|
className,
|
|
72
72
|
"flex flex-nowrap items-center",
|
|
73
73
|
)}
|
|
@@ -76,7 +76,7 @@ export const Breadcrumbs = ({
|
|
|
76
76
|
{start.map((link, idx) => (
|
|
77
77
|
<li
|
|
78
78
|
key={idx}
|
|
79
|
-
className={
|
|
79
|
+
className={"fabric-breadcrumbLink"}
|
|
80
80
|
data-separator={separator}
|
|
81
81
|
>
|
|
82
82
|
{link}
|
|
@@ -84,12 +84,16 @@ export const Breadcrumbs = ({
|
|
|
84
84
|
))}
|
|
85
85
|
{overflow && (
|
|
86
86
|
<Dropdown closeOnClick showArrow>
|
|
87
|
-
<li
|
|
88
|
-
|
|
87
|
+
<li
|
|
88
|
+
className={"fabric-breadcrumbLink"}
|
|
89
|
+
data-separator={separator}
|
|
90
|
+
data-ref="breadcrumbOverflow"
|
|
91
|
+
>
|
|
92
|
+
<Anchor data->...</Anchor>
|
|
89
93
|
</li>
|
|
90
94
|
<div
|
|
91
95
|
data-color={color}
|
|
92
|
-
className={classNames(
|
|
96
|
+
className={classNames("fabric-breadcrumbOverflow", "flex flex-col")}
|
|
93
97
|
>
|
|
94
98
|
{overflow}
|
|
95
99
|
</div>
|
|
@@ -98,7 +102,7 @@ export const Breadcrumbs = ({
|
|
|
98
102
|
{end?.map((link, idx) => (
|
|
99
103
|
<li
|
|
100
104
|
key={idx}
|
|
101
|
-
className={
|
|
105
|
+
className={"fabric-breadcrumbLink"}
|
|
102
106
|
data-separator={separator}
|
|
103
107
|
>
|
|
104
108
|
{link}
|
|
@@ -26,12 +26,12 @@ import classNames from "classnames";
|
|
|
26
26
|
import {
|
|
27
27
|
Fragment,
|
|
28
28
|
isValidElement,
|
|
29
|
-
type MouseEventHandler,
|
|
30
29
|
useCallback,
|
|
31
30
|
useEffect,
|
|
32
31
|
useMemo,
|
|
33
32
|
useRef,
|
|
34
33
|
useState,
|
|
34
|
+
type MouseEventHandler,
|
|
35
35
|
type WheelEventHandler,
|
|
36
36
|
} from "react";
|
|
37
37
|
import { useEffectDebugger } from "../../hooks/useEffectDebugger";
|
|
@@ -39,10 +39,10 @@ import { HotKey } from "../../hotkeys/HotKey";
|
|
|
39
39
|
import { HotKeyLabel } from "../../hotkeys/HotKeyLabel";
|
|
40
40
|
import { Tooltip } from "../../overlays/tooltip/Tooltip";
|
|
41
41
|
import {
|
|
42
|
+
type ColorState,
|
|
42
43
|
type AriaProps,
|
|
43
44
|
type BadgeType,
|
|
44
45
|
type CallbackReturn,
|
|
45
|
-
type ColorType,
|
|
46
46
|
type CssProp,
|
|
47
47
|
type IconProps,
|
|
48
48
|
type PolymorphicProps,
|
|
@@ -51,10 +51,10 @@ import {
|
|
|
51
51
|
type TestProps,
|
|
52
52
|
type TooltipType,
|
|
53
53
|
} from "../../types";
|
|
54
|
+
import { getColor } from "../../utils";
|
|
54
55
|
import { AnimationIndicator } from "../animations/Animations";
|
|
55
56
|
import { Badge, getBadgeProps } from "../badge/Badge";
|
|
56
57
|
import { Icon } from "../icon/Icon";
|
|
57
|
-
import classes from "./Button.module.css";
|
|
58
58
|
|
|
59
59
|
export interface BaseProps
|
|
60
60
|
extends CssProp,
|
|
@@ -77,7 +77,7 @@ export interface BaseProps
|
|
|
77
77
|
/**
|
|
78
78
|
* button color
|
|
79
79
|
*/
|
|
80
|
-
color?:
|
|
80
|
+
color?: ColorState;
|
|
81
81
|
/**
|
|
82
82
|
* button type
|
|
83
83
|
*/
|
|
@@ -85,7 +85,7 @@ export interface BaseProps
|
|
|
85
85
|
/**
|
|
86
86
|
* button styling
|
|
87
87
|
*/
|
|
88
|
-
variant?: "outline" | "solid" | "link";
|
|
88
|
+
variant?: "outline" | "soft" | "solid" | "link";
|
|
89
89
|
/**
|
|
90
90
|
* active state with click disabled
|
|
91
91
|
*/
|
|
@@ -147,10 +147,14 @@ export interface BaseProps
|
|
|
147
147
|
onWheel?: WheelEventHandler;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
type ButtonTypeProps =
|
|
151
151
|
| { children: string | React.ReactElement; "aria-label"?: string }
|
|
152
152
|
| { children?: never; "aria-label": string };
|
|
153
153
|
|
|
154
|
+
export type ButtonProps<Tag extends React.ElementType = "button"> = BaseProps &
|
|
155
|
+
ButtonTypeProps &
|
|
156
|
+
PolymorphicProps<Tag>;
|
|
157
|
+
|
|
154
158
|
/**
|
|
155
159
|
* Clickable action button
|
|
156
160
|
*/
|
|
@@ -186,7 +190,7 @@ export const Button = <Tag extends React.ElementType = "button">({
|
|
|
186
190
|
// @ts-expect-error ignore
|
|
187
191
|
"data-ref": dataRef,
|
|
188
192
|
...aria
|
|
189
|
-
}:
|
|
193
|
+
}: ButtonProps<Tag>) => {
|
|
190
194
|
const refEl = useRef<AnyObject>(null);
|
|
191
195
|
const [busy, setBusy] = useState(false);
|
|
192
196
|
const [actionDone, setActionDone] = useState(false);
|
|
@@ -230,7 +234,7 @@ export const Button = <Tag extends React.ElementType = "button">({
|
|
|
230
234
|
return {
|
|
231
235
|
content: actionMessage,
|
|
232
236
|
placement: "top",
|
|
233
|
-
color
|
|
237
|
+
color: `${color}-100`,
|
|
234
238
|
open: true,
|
|
235
239
|
} as TooltipType;
|
|
236
240
|
}
|
|
@@ -240,11 +244,15 @@ export const Button = <Tag extends React.ElementType = "button">({
|
|
|
240
244
|
return getBadgeProps(badge);
|
|
241
245
|
}, [badge]);
|
|
242
246
|
|
|
247
|
+
const hotKeyHandler = useRef(() => {
|
|
248
|
+
!disabled && refEl.current?.click();
|
|
249
|
+
});
|
|
250
|
+
|
|
243
251
|
const E = as ?? "button";
|
|
244
252
|
return (
|
|
245
253
|
<div
|
|
246
254
|
className={classNames(
|
|
247
|
-
|
|
255
|
+
"fabric-buttonWrapper",
|
|
248
256
|
className,
|
|
249
257
|
"relative align-text-top select-none focus-within:z-1",
|
|
250
258
|
fullWidth ? "block w-full" : "inline-block",
|
|
@@ -254,23 +262,18 @@ export const Button = <Tag extends React.ElementType = "button">({
|
|
|
254
262
|
data-loading={busy || loading}
|
|
255
263
|
data-disabled={disabled}
|
|
256
264
|
>
|
|
257
|
-
{hotKey &&
|
|
258
|
-
<HotKey
|
|
259
|
-
keyCombo={hotKey}
|
|
260
|
-
handler={() => !disabled && refEl.current?.click()}
|
|
261
|
-
/>
|
|
262
|
-
)}
|
|
265
|
+
{hotKey && <HotKey keyCombo={hotKey} handler={hotKeyHandler.current} />}
|
|
263
266
|
<TooltipWrapper {...tooltipProps}>
|
|
264
267
|
<E
|
|
265
268
|
ref={mergeRefs(ref, refEl)}
|
|
266
269
|
role="button"
|
|
267
270
|
className={classNames(
|
|
268
|
-
|
|
271
|
+
"fabric-button",
|
|
269
272
|
"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",
|
|
270
273
|
`focus-visible:ring-2 focus-visible:ring-offset-2 buttonInner`,
|
|
271
274
|
fullWidth && "max-w-full w-full",
|
|
272
275
|
rounded && "rounded-full",
|
|
273
|
-
spinOnHover &&
|
|
276
|
+
spinOnHover && "fabric-spinOnHover",
|
|
274
277
|
)}
|
|
275
278
|
type={type}
|
|
276
279
|
disabled={disabled}
|
|
@@ -284,7 +287,7 @@ export const Button = <Tag extends React.ElementType = "button">({
|
|
|
284
287
|
>
|
|
285
288
|
{icon && (
|
|
286
289
|
<Icon
|
|
287
|
-
className={
|
|
290
|
+
className={"fabric-buttonIcon"}
|
|
288
291
|
icon={icon}
|
|
289
292
|
bg={iconBg}
|
|
290
293
|
color={iconColor}
|
|
@@ -293,11 +296,11 @@ export const Button = <Tag extends React.ElementType = "button">({
|
|
|
293
296
|
/>
|
|
294
297
|
)}
|
|
295
298
|
{isValidElement(children) && (
|
|
296
|
-
<div className={
|
|
299
|
+
<div className={"fabric-buttonChild"}>{children}</div>
|
|
297
300
|
)}
|
|
298
301
|
{isString(children) && (
|
|
299
302
|
<label
|
|
300
|
-
className={classNames(
|
|
303
|
+
className={classNames("fabric-buttonLabel", "truncate")}
|
|
301
304
|
data-colored-icon={!!iconBg}
|
|
302
305
|
>
|
|
303
306
|
{children}
|
|
@@ -306,7 +309,7 @@ export const Button = <Tag extends React.ElementType = "button">({
|
|
|
306
309
|
{!isNil(badge) && <Badge {...badgeProps} />}
|
|
307
310
|
{hotKey && <HotKeyLabel keyCombo={hotKey} />}
|
|
308
311
|
{altIcon && (
|
|
309
|
-
<Icon className={
|
|
312
|
+
<Icon className={"fabric-altIcon"} icon={altIcon} rtlFlip />
|
|
310
313
|
)}
|
|
311
314
|
</E>
|
|
312
315
|
</TooltipWrapper>
|
|
@@ -314,9 +317,11 @@ export const Button = <Tag extends React.ElementType = "button">({
|
|
|
314
317
|
<div
|
|
315
318
|
className={classNames(
|
|
316
319
|
"absolute inset-0 overflow-hidden flex justify-center items-center",
|
|
317
|
-
`bg-${color}-300`,
|
|
318
320
|
rounded ? "rounded-full" : "rounded",
|
|
319
321
|
)}
|
|
322
|
+
style={{
|
|
323
|
+
backgroundColor: getColor(`${color}-300`),
|
|
324
|
+
}}
|
|
320
325
|
>
|
|
321
326
|
<AnimationIndicator type="check" color={color} />
|
|
322
327
|
</div>
|
|
@@ -22,18 +22,18 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import classNames from "classnames";
|
|
25
|
-
import {
|
|
25
|
+
import { cloneElement } from "react";
|
|
26
26
|
import {
|
|
27
27
|
type AriaProps,
|
|
28
28
|
type ChildrenProp,
|
|
29
|
-
type
|
|
29
|
+
type ColorState,
|
|
30
30
|
type CssProp,
|
|
31
31
|
type RefProp,
|
|
32
32
|
type SizeType,
|
|
33
33
|
type TestProps,
|
|
34
34
|
} from "../../types";
|
|
35
|
+
import { cloneChildren } from "../../utils";
|
|
35
36
|
import { type Button } from "./Button";
|
|
36
|
-
import classes from "./Button.module.css";
|
|
37
37
|
|
|
38
38
|
export interface ButtonGroupProps
|
|
39
39
|
extends CssProp,
|
|
@@ -56,7 +56,7 @@ export interface ButtonGroupProps
|
|
|
56
56
|
/**
|
|
57
57
|
* button color
|
|
58
58
|
*/
|
|
59
|
-
color?:
|
|
59
|
+
color?: ColorState;
|
|
60
60
|
/**
|
|
61
61
|
* full rounded edges
|
|
62
62
|
*/
|
|
@@ -87,16 +87,16 @@ export const ButtonGroup = ({
|
|
|
87
87
|
<div
|
|
88
88
|
data-ref="buttonGroup"
|
|
89
89
|
className={classNames(
|
|
90
|
-
|
|
90
|
+
"fabric-buttonGroup",
|
|
91
91
|
className,
|
|
92
92
|
fullWidth ? "flex" : "inline-flex",
|
|
93
93
|
"flex-nowrap align-middle rounded",
|
|
94
|
-
vertical &&
|
|
94
|
+
vertical && "vertical",
|
|
95
95
|
vertical && "flex-col items-stretch",
|
|
96
96
|
)}
|
|
97
97
|
{...aria}
|
|
98
98
|
>
|
|
99
|
-
{
|
|
99
|
+
{cloneChildren(children, (child: AnyObject) =>
|
|
100
100
|
cloneElement(child, {
|
|
101
101
|
color,
|
|
102
102
|
size,
|
|
@@ -22,18 +22,19 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
|
-
FloatingArrow,
|
|
26
|
-
FloatingFocusManager,
|
|
27
|
-
FloatingPortal,
|
|
28
25
|
arrow,
|
|
29
26
|
autoUpdate,
|
|
30
27
|
flip,
|
|
28
|
+
FloatingArrow,
|
|
29
|
+
FloatingFocusManager,
|
|
30
|
+
FloatingPortal,
|
|
31
31
|
offset,
|
|
32
32
|
shift,
|
|
33
33
|
useClick,
|
|
34
34
|
useDismiss,
|
|
35
35
|
useFloating,
|
|
36
36
|
useInteractions,
|
|
37
|
+
type Placement,
|
|
37
38
|
} from "@floating-ui/react";
|
|
38
39
|
import { mergeRefs } from "@react-fabric/utilities";
|
|
39
40
|
import classNames from "classnames";
|
|
@@ -66,6 +67,10 @@ interface ExtendedProps extends Omit<BaseProps, "onClick">, RefProp {
|
|
|
66
67
|
* ok label
|
|
67
68
|
*/
|
|
68
69
|
cancelLabel?: string;
|
|
70
|
+
/**
|
|
71
|
+
* dropdown placement
|
|
72
|
+
*/
|
|
73
|
+
placement?: Placement;
|
|
69
74
|
/**
|
|
70
75
|
* click handler, return Promise to autoset loading state
|
|
71
76
|
*/
|
|
@@ -85,6 +90,7 @@ export const ConfirmButton = <Tag extends React.ElementType = "button">({
|
|
|
85
90
|
cancelLabel,
|
|
86
91
|
onClick,
|
|
87
92
|
loading,
|
|
93
|
+
placement = "bottom",
|
|
88
94
|
actionMessage,
|
|
89
95
|
showActionDone,
|
|
90
96
|
showActionDoneEvent = "click",
|
|
@@ -127,7 +133,7 @@ export const ConfirmButton = <Tag extends React.ElementType = "button">({
|
|
|
127
133
|
}
|
|
128
134
|
},
|
|
129
135
|
strategy: "fixed",
|
|
130
|
-
placement
|
|
136
|
+
placement,
|
|
131
137
|
whileElementsMounted: autoUpdate,
|
|
132
138
|
middleware: [
|
|
133
139
|
shift({ padding: 8 }),
|
|
@@ -185,11 +191,14 @@ export const ConfirmButton = <Tag extends React.ElementType = "button">({
|
|
|
185
191
|
{...getFloatingProps()}
|
|
186
192
|
>
|
|
187
193
|
<div className="font-medium ">
|
|
188
|
-
<p className="py-2 px-4">
|
|
194
|
+
<p className="py-2 px-4" data-ref="confirmMessage">
|
|
195
|
+
{message}
|
|
196
|
+
</p>
|
|
189
197
|
<div className="flex justify-end py-2 px-4 gap-2">
|
|
190
198
|
<Button
|
|
191
199
|
size="sm"
|
|
192
200
|
variant="link"
|
|
201
|
+
data-ref="confirmCancel"
|
|
193
202
|
color={color}
|
|
194
203
|
onClick={() => [clickHandler(false), setIsOpen(false)]}
|
|
195
204
|
>
|
|
@@ -200,6 +209,7 @@ export const ConfirmButton = <Tag extends React.ElementType = "button">({
|
|
|
200
209
|
variant="solid"
|
|
201
210
|
color={color}
|
|
202
211
|
autoFocus
|
|
212
|
+
data-ref="confirmOk"
|
|
203
213
|
onClick={() => [clickHandler(true), setIsOpen(false)]}
|
|
204
214
|
>
|
|
205
215
|
{okLabel ?? t("action.ok")}
|