@refraktor/core 0.0.4 → 0.0.5
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/build/components/progress-circle/progress-circle.d.ts.map +1 -1
- package/build/components/progress-circle/progress-circle.js +6 -6
- package/build/components/progress-circle/progress-circle.styles.d.ts +2 -7
- package/build/components/progress-circle/progress-circle.styles.d.ts.map +1 -1
- package/build/components/progress-circle/progress-circle.styles.js +2 -23
- package/build/components/progress-circle/progress-circle.types.d.ts +4 -3
- package/build/components/progress-circle/progress-circle.types.d.ts.map +1 -1
- package/build/components/slider/slider.d.ts.map +1 -1
- package/build/components/slider/slider.js +69 -20
- package/build/components/tooltip/tooltip.js +1 -1
- package/build/style.css +2 -2
- package/package.json +30 -3
- package/.turbo/turbo-build.log +0 -4
- package/refraktor-core-0.0.1-alpha.0.tgz +0 -0
- package/src/components/accordion/accordion-control/accordion-control.tsx +0 -156
- package/src/components/accordion/accordion-control/index.ts +0 -1
- package/src/components/accordion/accordion-item/accordion-item.tsx +0 -40
- package/src/components/accordion/accordion-item/index.ts +0 -1
- package/src/components/accordion/accordion-panel/accordion-panel.tsx +0 -58
- package/src/components/accordion/accordion-panel/index.ts +0 -1
- package/src/components/accordion/accordion.context.ts +0 -93
- package/src/components/accordion/accordion.styles.ts +0 -60
- package/src/components/accordion/accordion.test.tsx +0 -174
- package/src/components/accordion/accordion.tsx +0 -203
- package/src/components/accordion/accordion.types.ts +0 -126
- package/src/components/accordion/index.ts +0 -17
- package/src/components/avatar/avatar-group/avatar-group.tsx +0 -73
- package/src/components/avatar/avatar-group/index.ts +0 -1
- package/src/components/avatar/avatar.styles.ts +0 -11
- package/src/components/avatar/avatar.tsx +0 -142
- package/src/components/avatar/avatar.types.ts +0 -86
- package/src/components/avatar/index.ts +0 -8
- package/src/components/badge/badge.styles.ts +0 -21
- package/src/components/badge/badge.tsx +0 -62
- package/src/components/badge/badge.types.ts +0 -40
- package/src/components/badge/index.ts +0 -2
- package/src/components/breadcrumbs/breadcrumbs.styles.ts +0 -55
- package/src/components/breadcrumbs/breadcrumbs.test.tsx +0 -136
- package/src/components/breadcrumbs/breadcrumbs.tsx +0 -199
- package/src/components/breadcrumbs/breadcrumbs.types.ts +0 -78
- package/src/components/breadcrumbs/breadcrumbs.utils.ts +0 -70
- package/src/components/breadcrumbs/index.ts +0 -6
- package/src/components/button/button.styles.ts +0 -28
- package/src/components/button/button.test.tsx +0 -57
- package/src/components/button/button.tsx +0 -110
- package/src/components/button/button.types.ts +0 -69
- package/src/components/button/index.ts +0 -2
- package/src/components/checkbox/checkbox-group/checkbox-group.tsx +0 -93
- package/src/components/checkbox/checkbox-group/index.ts +0 -1
- package/src/components/checkbox/checkbox.context.ts +0 -14
- package/src/components/checkbox/checkbox.styles.ts +0 -49
- package/src/components/checkbox/checkbox.test.tsx +0 -80
- package/src/components/checkbox/checkbox.tsx +0 -192
- package/src/components/checkbox/checkbox.types.ts +0 -125
- package/src/components/checkbox/index.ts +0 -10
- package/src/components/chip/chip-group/chip-group.tsx +0 -107
- package/src/components/chip/chip-group/index.ts +0 -1
- package/src/components/chip/chip.context.ts +0 -15
- package/src/components/chip/chip.styles.ts +0 -36
- package/src/components/chip/chip.test.tsx +0 -197
- package/src/components/chip/chip.tsx +0 -208
- package/src/components/chip/chip.types.ts +0 -134
- package/src/components/chip/index.ts +0 -10
- package/src/components/color-swatch/color-swatch.styles.ts +0 -11
- package/src/components/color-swatch/color-swatch.test.tsx +0 -80
- package/src/components/color-swatch/color-swatch.tsx +0 -84
- package/src/components/color-swatch/color-swatch.types.ts +0 -46
- package/src/components/color-swatch/index.ts +0 -2
- package/src/components/drawer/drawer-body/drawer-body.tsx +0 -29
- package/src/components/drawer/drawer-body/index.ts +0 -1
- package/src/components/drawer/drawer-close/drawer-close.tsx +0 -43
- package/src/components/drawer/drawer-close/index.ts +0 -1
- package/src/components/drawer/drawer-content/drawer-content.tsx +0 -135
- package/src/components/drawer/drawer-content/index.ts +0 -1
- package/src/components/drawer/drawer-header/drawer-header.tsx +0 -40
- package/src/components/drawer/drawer-header/index.ts +0 -1
- package/src/components/drawer/drawer-overlay/drawer-overlay.tsx +0 -87
- package/src/components/drawer/drawer-overlay/index.ts +0 -1
- package/src/components/drawer/drawer-root/drawer-root.tsx +0 -93
- package/src/components/drawer/drawer-root/index.ts +0 -1
- package/src/components/drawer/drawer.context.ts +0 -26
- package/src/components/drawer/drawer.styles.ts +0 -32
- package/src/components/drawer/drawer.test.tsx +0 -274
- package/src/components/drawer/drawer.tsx +0 -58
- package/src/components/drawer/drawer.types.ts +0 -192
- package/src/components/drawer/index.ts +0 -18
- package/src/components/drawer/use-drawer.ts +0 -94
- package/src/components/file-input/file-input.test.tsx +0 -134
- package/src/components/file-input/file-input.tsx +0 -224
- package/src/components/file-input/file-input.types.ts +0 -78
- package/src/components/file-input/file-input.utils.test.ts +0 -36
- package/src/components/file-input/file-input.utils.ts +0 -130
- package/src/components/file-input/index.ts +0 -2
- package/src/components/for/for.test.tsx +0 -66
- package/src/components/for/for.tsx +0 -53
- package/src/components/for/for.types.ts +0 -40
- package/src/components/for/index.ts +0 -2
- package/src/components/index.ts +0 -35
- package/src/components/input/index.ts +0 -2
- package/src/components/input/input-description/index.ts +0 -2
- package/src/components/input/input-description/input-description.tsx +0 -36
- package/src/components/input/input-error/index.ts +0 -2
- package/src/components/input/input-error/input-error.tsx +0 -36
- package/src/components/input/input-field/index.ts +0 -1
- package/src/components/input/input-field/input-field.styles.ts +0 -23
- package/src/components/input/input-field/input-field.tsx +0 -94
- package/src/components/input/input-label/index.ts +0 -2
- package/src/components/input/input-label/input-label.tsx +0 -47
- package/src/components/input/input-wrapper/index.ts +0 -2
- package/src/components/input/input-wrapper/input-wrapper.tsx +0 -43
- package/src/components/input/input.tsx +0 -71
- package/src/components/input/input.types.ts +0 -111
- package/src/components/loader/index.ts +0 -2
- package/src/components/loader/loader.tsx +0 -89
- package/src/components/loader/loader.types.ts +0 -33
- package/src/components/menu/index.ts +0 -24
- package/src/components/menu/menu-dropdown/index.ts +0 -1
- package/src/components/menu/menu-dropdown/menu-dropdown.tsx +0 -220
- package/src/components/menu/menu-item/index.ts +0 -1
- package/src/components/menu/menu-item/menu-item.tsx +0 -126
- package/src/components/menu/menu-label/index.ts +0 -1
- package/src/components/menu/menu-label/menu-label.tsx +0 -30
- package/src/components/menu/menu-separator/index.ts +0 -1
- package/src/components/menu/menu-separator/menu-separator.tsx +0 -28
- package/src/components/menu/menu-sub/index.ts +0 -1
- package/src/components/menu/menu-sub/menu-sub.tsx +0 -117
- package/src/components/menu/menu-sub-dropdown/index.ts +0 -1
- package/src/components/menu/menu-sub-dropdown/menu-sub-dropdown.tsx +0 -221
- package/src/components/menu/menu-sub-trigger/index.ts +0 -1
- package/src/components/menu/menu-sub-trigger/menu-sub-trigger.tsx +0 -164
- package/src/components/menu/menu-trigger/index.ts +0 -1
- package/src/components/menu/menu-trigger/menu-trigger.tsx +0 -98
- package/src/components/menu/menu.context.ts +0 -162
- package/src/components/menu/menu.test.tsx +0 -136
- package/src/components/menu/menu.tsx +0 -133
- package/src/components/menu/menu.types.ts +0 -291
- package/src/components/menu/use-menu.ts +0 -204
- package/src/components/modal/index.ts +0 -18
- package/src/components/modal/modal-body/index.ts +0 -1
- package/src/components/modal/modal-body/modal-body.tsx +0 -29
- package/src/components/modal/modal-close/index.ts +0 -1
- package/src/components/modal/modal-close/modal-close.tsx +0 -43
- package/src/components/modal/modal-content/index.ts +0 -1
- package/src/components/modal/modal-content/modal-content.tsx +0 -119
- package/src/components/modal/modal-header/index.ts +0 -1
- package/src/components/modal/modal-header/modal-header.tsx +0 -40
- package/src/components/modal/modal-overlay/index.ts +0 -1
- package/src/components/modal/modal-overlay/modal-overlay.tsx +0 -87
- package/src/components/modal/modal-root/index.ts +0 -1
- package/src/components/modal/modal-root/modal-root.tsx +0 -93
- package/src/components/modal/modal.context.ts +0 -26
- package/src/components/modal/modal.test.tsx +0 -316
- package/src/components/modal/modal.tsx +0 -58
- package/src/components/modal/modal.types.ts +0 -189
- package/src/components/modal/use-modal.ts +0 -94
- package/src/components/number-input/index.ts +0 -2
- package/src/components/number-input/number-input.styles.ts +0 -37
- package/src/components/number-input/number-input.test.tsx +0 -22
- package/src/components/number-input/number-input.tsx +0 -381
- package/src/components/number-input/number-input.types.ts +0 -58
- package/src/components/pagination/index.ts +0 -7
- package/src/components/pagination/pagination.styles.ts +0 -84
- package/src/components/pagination/pagination.test.tsx +0 -117
- package/src/components/pagination/pagination.tsx +0 -371
- package/src/components/pagination/pagination.types.ts +0 -95
- package/src/components/pagination/pagination.utils.ts +0 -88
- package/src/components/password-input/index.ts +0 -2
- package/src/components/password-input/password-input.test.tsx +0 -72
- package/src/components/password-input/password-input.tsx +0 -85
- package/src/components/password-input/password-input.types.ts +0 -30
- package/src/components/pin-input/index.ts +0 -2
- package/src/components/pin-input/pin-input.test.tsx +0 -149
- package/src/components/pin-input/pin-input.tsx +0 -473
- package/src/components/pin-input/pin-input.types.ts +0 -78
- package/src/components/popover/index.ts +0 -12
- package/src/components/popover/popover-dropdown/index.ts +0 -1
- package/src/components/popover/popover-dropdown/popover-dropdown.tsx +0 -94
- package/src/components/popover/popover-trigger/index.ts +0 -1
- package/src/components/popover/popover-trigger/popover-trigger.tsx +0 -49
- package/src/components/popover/popover.context.ts +0 -20
- package/src/components/popover/popover.tsx +0 -113
- package/src/components/popover/popover.types.ts +0 -137
- package/src/components/popover/use-popover.ts +0 -219
- package/src/components/portal/index.ts +0 -2
- package/src/components/portal/portal.test.tsx +0 -39
- package/src/components/portal/portal.tsx +0 -104
- package/src/components/portal/portal.types.ts +0 -31
- package/src/components/progress/index.ts +0 -2
- package/src/components/progress/progress.styles.ts +0 -25
- package/src/components/progress/progress.test.tsx +0 -107
- package/src/components/progress/progress.tsx +0 -93
- package/src/components/progress/progress.types.ts +0 -52
- package/src/components/progress-circle/index.ts +0 -5
- package/src/components/progress-circle/progress-circle.styles.ts +0 -31
- package/src/components/progress-circle/progress-circle.test.tsx +0 -140
- package/src/components/progress-circle/progress-circle.tsx +0 -124
- package/src/components/progress-circle/progress-circle.types.ts +0 -52
- package/src/components/radio/index.ts +0 -10
- package/src/components/radio/radio-group/index.ts +0 -1
- package/src/components/radio/radio-group/radio-group.tsx +0 -89
- package/src/components/radio/radio.context.ts +0 -14
- package/src/components/radio/radio.styles.ts +0 -49
- package/src/components/radio/radio.test.tsx +0 -75
- package/src/components/radio/radio.tsx +0 -173
- package/src/components/radio/radio.types.ts +0 -126
- package/src/components/scroll-area/index.ts +0 -6
- package/src/components/scroll-area/scroll-area.test.tsx +0 -72
- package/src/components/scroll-area/scroll-area.tsx +0 -70
- package/src/components/scroll-area/scroll-area.types.ts +0 -37
- package/src/components/segmented-control/index.ts +0 -6
- package/src/components/segmented-control/segmented-control.styles.ts +0 -37
- package/src/components/segmented-control/segmented-control.test.tsx +0 -170
- package/src/components/segmented-control/segmented-control.tsx +0 -255
- package/src/components/segmented-control/segmented-control.types.ts +0 -78
- package/src/components/select/index.ts +0 -20
- package/src/components/select/select-dropdown/index.ts +0 -1
- package/src/components/select/select-dropdown/select-dropdown.tsx +0 -299
- package/src/components/select/select-group/index.ts +0 -1
- package/src/components/select/select-group/select-group.tsx +0 -47
- package/src/components/select/select-item/index.ts +0 -1
- package/src/components/select/select-item/select-item.tsx +0 -157
- package/src/components/select/select-root/index.ts +0 -1
- package/src/components/select/select-root/select-root.tsx +0 -333
- package/src/components/select/select-trigger/index.ts +0 -1
- package/src/components/select/select-trigger/select-trigger.tsx +0 -123
- package/src/components/select/select.context.ts +0 -140
- package/src/components/select/select.test.tsx +0 -190
- package/src/components/select/select.tsx +0 -82
- package/src/components/select/select.types.ts +0 -272
- package/src/components/select/use-select.ts +0 -170
- package/src/components/slider/index.ts +0 -7
- package/src/components/slider/slider.styles.ts +0 -37
- package/src/components/slider/slider.tsx +0 -275
- package/src/components/slider/slider.types.ts +0 -82
- package/src/components/switch/index.ts +0 -2
- package/src/components/switch/switch.styles.ts +0 -31
- package/src/components/switch/switch.tsx +0 -132
- package/src/components/switch/switch.types.ts +0 -62
- package/src/components/table/index.ts +0 -24
- package/src/components/table/table-body/index.ts +0 -1
- package/src/components/table/table-body/table-body.tsx +0 -37
- package/src/components/table/table-caption/index.ts +0 -1
- package/src/components/table/table-caption/table-caption.tsx +0 -32
- package/src/components/table/table-cell/index.ts +0 -1
- package/src/components/table/table-cell/table-cell.tsx +0 -33
- package/src/components/table/table-head/index.ts +0 -1
- package/src/components/table/table-head/table-head.tsx +0 -29
- package/src/components/table/table-header-cell/index.ts +0 -1
- package/src/components/table/table-header-cell/table-header-cell.tsx +0 -33
- package/src/components/table/table-row/index.ts +0 -1
- package/src/components/table/table-row/table-row.tsx +0 -30
- package/src/components/table/table.context.ts +0 -18
- package/src/components/table/table.styles.ts +0 -62
- package/src/components/table/table.test.tsx +0 -145
- package/src/components/table/table.tsx +0 -91
- package/src/components/table/table.types.ts +0 -145
- package/src/components/tabs/index.ts +0 -18
- package/src/components/tabs/tabs-list/index.ts +0 -1
- package/src/components/tabs/tabs-list/tabs-list.tsx +0 -42
- package/src/components/tabs/tabs-panel/index.ts +0 -1
- package/src/components/tabs/tabs-panel/tabs-panel.tsx +0 -58
- package/src/components/tabs/tabs-tab/index.ts +0 -1
- package/src/components/tabs/tabs-tab/tabs-tab.tsx +0 -210
- package/src/components/tabs/tabs.context.ts +0 -88
- package/src/components/tabs/tabs.styles.ts +0 -92
- package/src/components/tabs/tabs.test.tsx +0 -167
- package/src/components/tabs/tabs.tsx +0 -137
- package/src/components/tabs/tabs.types.ts +0 -128
- package/src/components/textarea/index.ts +0 -2
- package/src/components/textarea/textarea-field/index.ts +0 -1
- package/src/components/textarea/textarea-field/textarea-field.styles.ts +0 -34
- package/src/components/textarea/textarea-field/textarea-field.tsx +0 -96
- package/src/components/textarea/textarea.tsx +0 -64
- package/src/components/textarea/textarea.types.ts +0 -80
- package/src/components/timeline/index.ts +0 -11
- package/src/components/timeline/timeline-item/index.ts +0 -1
- package/src/components/timeline/timeline-item/timeline-item.tsx +0 -158
- package/src/components/timeline/timeline.context.ts +0 -21
- package/src/components/timeline/timeline.styles.ts +0 -135
- package/src/components/timeline/timeline.test.tsx +0 -150
- package/src/components/timeline/timeline.tsx +0 -124
- package/src/components/timeline/timeline.types.ts +0 -91
- package/src/components/tooltip/index.ts +0 -8
- package/src/components/tooltip/tooltip.tsx +0 -164
- package/src/components/tooltip/tooltip.types.ts +0 -104
- package/src/components/tooltip/use-tooltip.ts +0 -200
- package/src/components/transition/index.ts +0 -11
- package/src/components/transition/transition.test.tsx +0 -126
- package/src/components/transition/transition.tsx +0 -441
- package/src/components/transition/transition.types.ts +0 -97
- package/src/components/transition/transitions.ts +0 -140
- package/src/icons/check.tsx +0 -25
- package/src/icons/chevron.tsx +0 -46
- package/src/icons/eye-off.tsx +0 -30
- package/src/icons/eye.tsx +0 -24
- package/src/icons/index.ts +0 -7
- package/src/icons/minus.tsx +0 -24
- package/src/icons/types.ts +0 -9
- package/src/icons/user.tsx +0 -18
- package/src/icons/x.tsx +0 -35
- package/src/index.ts +0 -5
- package/src/style.css +0 -334
- package/src/theme/ThemeProvider/ThemeProvider.tsx +0 -111
- package/src/theme/ThemeProvider/context.ts +0 -7
- package/src/theme/ThemeProvider/generateVariables.test.ts +0 -49
- package/src/theme/ThemeProvider/generateVariables.ts +0 -124
- package/src/theme/ThemeProvider/index.ts +0 -3
- package/src/theme/ThemeProvider/types.ts +0 -37
- package/src/theme/createTheme/createTheme.ts +0 -41
- package/src/theme/createTheme/index.ts +0 -7
- package/src/theme/createTheme/types.ts +0 -62
- package/src/theme/defaults/colors.ts +0 -203
- package/src/theme/defaults/settings.ts +0 -8
- package/src/theme/index.ts +0 -4
- package/src/theme/types.ts +0 -31
- package/src/theme/utils/get-radius.ts +0 -23
- package/src/theme/utils/get-shade.ts +0 -16
- package/src/theme/utils/index.ts +0 -3
- package/src/theme/utils/use-theme.ts +0 -27
- package/src/utils/configs/create-config.ts +0 -15
- package/src/utils/configs/index.ts +0 -3
- package/src/utils/configs/use-class-names.ts +0 -41
- package/src/utils/configs/use-props.ts +0 -55
- package/src/utils/cx/index.ts +0 -6
- package/src/utils/factory/factory.ts +0 -23
- package/src/utils/factory/index.ts +0 -14
- package/src/utils/factory/types.ts +0 -92
- package/src/utils/index.ts +0 -3
- package/src/vitest/index.ts +0 -1
- package/src/vitest/setup.tsx +0 -20
- package/src/vitest/utils.tsx +0 -59
- package/tsconfig.json +0 -13
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.js +0 -19
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { createSafeContext } from "@refraktor/utils";
|
|
2
|
-
import { UsePopoverReturn } from "./use-popover";
|
|
3
|
-
import { PopoverClassNames } from "./popover.types";
|
|
4
|
-
import { RefraktorRadius } from "../../theme";
|
|
5
|
-
import { TransitionProps } from "../transition";
|
|
6
|
-
|
|
7
|
-
export interface PopoverContextValue {
|
|
8
|
-
popover: UsePopoverReturn;
|
|
9
|
-
showArrow: boolean;
|
|
10
|
-
radius: RefraktorRadius;
|
|
11
|
-
withinPortal: boolean;
|
|
12
|
-
transitionProps?: Omit<TransitionProps, "children" | "mounted">;
|
|
13
|
-
classNames?: PopoverClassNames;
|
|
14
|
-
getStyles: (part: keyof PopoverClassNames) => string | undefined;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const [PopoverProvider, usePopoverContext] =
|
|
18
|
-
createSafeContext<PopoverContextValue>(
|
|
19
|
-
"Popover component was not found in tree. Make sure you wrap Popover.Trigger and Popover.Dropdown with Popover component."
|
|
20
|
-
);
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { useId } from "@refraktor/utils";
|
|
2
|
-
import { useTheme } from "../../theme";
|
|
3
|
-
import {
|
|
4
|
-
createClassNamesConfig,
|
|
5
|
-
createComponentConfig,
|
|
6
|
-
factory,
|
|
7
|
-
useClassNames,
|
|
8
|
-
useProps
|
|
9
|
-
} from "../../utils";
|
|
10
|
-
import {
|
|
11
|
-
PopoverClassNames,
|
|
12
|
-
PopoverFactoryPayload,
|
|
13
|
-
PopoverProps
|
|
14
|
-
} from "./popover.types";
|
|
15
|
-
import { usePopover } from "./use-popover";
|
|
16
|
-
import { PopoverProvider } from "./popover.context";
|
|
17
|
-
import { PopoverTrigger } from "./popover-trigger";
|
|
18
|
-
import { PopoverDropdown } from "./popover-dropdown";
|
|
19
|
-
|
|
20
|
-
const defaultProps = {
|
|
21
|
-
positioning: {
|
|
22
|
-
placement: "bottom",
|
|
23
|
-
offset: 8
|
|
24
|
-
},
|
|
25
|
-
middlewares: { flip: true, shift: true },
|
|
26
|
-
trigger: "click",
|
|
27
|
-
openDelay: 0,
|
|
28
|
-
closeDelay: 0,
|
|
29
|
-
showArrow: false,
|
|
30
|
-
radius: "default",
|
|
31
|
-
withinPortal: true,
|
|
32
|
-
closeOnClickOutside: true,
|
|
33
|
-
closeOnEscape: true,
|
|
34
|
-
trapFocus: false
|
|
35
|
-
} satisfies Partial<PopoverProps>;
|
|
36
|
-
|
|
37
|
-
const Popover = factory<PopoverFactoryPayload>((_props, ref) => {
|
|
38
|
-
const { cx } = useTheme();
|
|
39
|
-
const {
|
|
40
|
-
id,
|
|
41
|
-
children,
|
|
42
|
-
opened,
|
|
43
|
-
defaultOpened,
|
|
44
|
-
onOpenedChange,
|
|
45
|
-
positioning,
|
|
46
|
-
middlewares,
|
|
47
|
-
disabled,
|
|
48
|
-
trigger,
|
|
49
|
-
openDelay,
|
|
50
|
-
closeDelay,
|
|
51
|
-
showArrow,
|
|
52
|
-
transitionProps,
|
|
53
|
-
radius,
|
|
54
|
-
withinPortal,
|
|
55
|
-
closeOnClickOutside,
|
|
56
|
-
closeOnEscape,
|
|
57
|
-
trapFocus,
|
|
58
|
-
className,
|
|
59
|
-
classNames,
|
|
60
|
-
...props
|
|
61
|
-
} = useProps("Popover", defaultProps, _props);
|
|
62
|
-
const classes = useClassNames("Popover", classNames);
|
|
63
|
-
|
|
64
|
-
const _id = useId(id);
|
|
65
|
-
|
|
66
|
-
const popover = usePopover({
|
|
67
|
-
opened,
|
|
68
|
-
defaultOpened,
|
|
69
|
-
onOpenedChange,
|
|
70
|
-
positioning,
|
|
71
|
-
middlewares,
|
|
72
|
-
disabled,
|
|
73
|
-
trigger,
|
|
74
|
-
showArrow,
|
|
75
|
-
closeOnClickOutside,
|
|
76
|
-
closeOnEscape,
|
|
77
|
-
openDelay,
|
|
78
|
-
closeDelay
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
const getStyles = (part: keyof PopoverClassNames) => classes[part];
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<PopoverProvider
|
|
85
|
-
value={{
|
|
86
|
-
popover,
|
|
87
|
-
showArrow: showArrow ?? false,
|
|
88
|
-
radius: radius ?? "default",
|
|
89
|
-
withinPortal: withinPortal ?? true,
|
|
90
|
-
transitionProps,
|
|
91
|
-
classNames,
|
|
92
|
-
getStyles
|
|
93
|
-
}}
|
|
94
|
-
>
|
|
95
|
-
<div
|
|
96
|
-
ref={ref}
|
|
97
|
-
id={_id}
|
|
98
|
-
className={cx("inline-block", classes.root, className)}
|
|
99
|
-
{...props}
|
|
100
|
-
>
|
|
101
|
-
{children}
|
|
102
|
-
</div>
|
|
103
|
-
</PopoverProvider>
|
|
104
|
-
);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
Popover.displayName = "@refraktor/core/Popover";
|
|
108
|
-
Popover.configure = createComponentConfig<PopoverProps>();
|
|
109
|
-
Popover.classNames = createClassNamesConfig<PopoverClassNames>();
|
|
110
|
-
Popover.Trigger = PopoverTrigger;
|
|
111
|
-
Popover.Dropdown = PopoverDropdown;
|
|
112
|
-
|
|
113
|
-
export default Popover;
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
-
import type {
|
|
3
|
-
FlipOptions,
|
|
4
|
-
InlineOptions,
|
|
5
|
-
Placement,
|
|
6
|
-
ShiftOptions
|
|
7
|
-
} from "@floating-ui/react";
|
|
8
|
-
import { TransitionProps } from "../transition";
|
|
9
|
-
import { RefraktorRadius } from "../../theme";
|
|
10
|
-
import {
|
|
11
|
-
createClassNamesConfig,
|
|
12
|
-
createComponentConfig,
|
|
13
|
-
FactoryPayload
|
|
14
|
-
} from "../../utils";
|
|
15
|
-
import { PopoverTrigger } from "./popover-trigger";
|
|
16
|
-
import { PopoverDropdown } from "./popover-dropdown";
|
|
17
|
-
|
|
18
|
-
export type PopoverClassNames = {
|
|
19
|
-
root?: string;
|
|
20
|
-
trigger?: string;
|
|
21
|
-
dropdown?: string;
|
|
22
|
-
arrow?: string;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export type PopoverPositioning = {
|
|
26
|
-
/** The placement of the popover relative to the trigger element @default `bottom` */
|
|
27
|
-
placement?: Placement;
|
|
28
|
-
|
|
29
|
-
/** Offset distance from the trigger element in pixels @default `8` */
|
|
30
|
-
offset?: number;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export type PopoverMiddlewares = {
|
|
34
|
-
shift?: boolean | ShiftOptions;
|
|
35
|
-
flip?: boolean | FlipOptions;
|
|
36
|
-
inline?: boolean | InlineOptions;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export type PopoverTrigger = "click" | "hover" | "focus";
|
|
40
|
-
|
|
41
|
-
export interface PopoverProps extends ComponentPropsWithoutRef<"div"> {
|
|
42
|
-
/** Children containing subcomponents */
|
|
43
|
-
children: ReactNode;
|
|
44
|
-
|
|
45
|
-
/** State of the popover (controlled) */
|
|
46
|
-
opened?: boolean;
|
|
47
|
-
|
|
48
|
-
/** Initial state of the popover (uncontrolled) */
|
|
49
|
-
defaultOpened?: boolean;
|
|
50
|
-
|
|
51
|
-
/** Callback called when the popover state changes */
|
|
52
|
-
onOpenedChange?: (opened: boolean) => void;
|
|
53
|
-
|
|
54
|
-
/** Positioning settings for the popover */
|
|
55
|
-
positioning?: PopoverPositioning;
|
|
56
|
-
|
|
57
|
-
/** Middlewares settings for the popover */
|
|
58
|
-
middlewares?: PopoverMiddlewares;
|
|
59
|
-
|
|
60
|
-
/** Whether the popover is disabled @default `false` */
|
|
61
|
-
disabled?: boolean;
|
|
62
|
-
|
|
63
|
-
/** Trigger type for the popover @default `click` */
|
|
64
|
-
trigger?: PopoverTrigger;
|
|
65
|
-
|
|
66
|
-
/** Delay in milliseconds before the popover opens @default `0` */
|
|
67
|
-
openDelay?: number;
|
|
68
|
-
|
|
69
|
-
/** Delay in milliseconds before the popover closes @default `0` */
|
|
70
|
-
closeDelay?: number;
|
|
71
|
-
|
|
72
|
-
/** Whether to show the arrow for the popover @default `false` */
|
|
73
|
-
showArrow?: boolean;
|
|
74
|
-
|
|
75
|
-
/** Transition props for the popover dropdown, uses Transition component internally */
|
|
76
|
-
transitionProps?: Omit<TransitionProps, "children" | "mounted">;
|
|
77
|
-
|
|
78
|
-
/** Radius for the popover dropdown @default `default` */
|
|
79
|
-
radius?: RefraktorRadius;
|
|
80
|
-
|
|
81
|
-
/** Whether to render the popover within a portal @default `true` */
|
|
82
|
-
withinPortal?: boolean;
|
|
83
|
-
|
|
84
|
-
/** Whether to close on click outside @default `true` */
|
|
85
|
-
closeOnClickOutside?: boolean;
|
|
86
|
-
|
|
87
|
-
/** Whether to close on escape key @default `true` */
|
|
88
|
-
closeOnEscape?: boolean;
|
|
89
|
-
|
|
90
|
-
/** Whether to trap focus within the popover @default `false` */
|
|
91
|
-
trapFocus?: boolean;
|
|
92
|
-
|
|
93
|
-
/** Used for editing root class name */
|
|
94
|
-
className?: string;
|
|
95
|
-
|
|
96
|
-
/** Used for styling different parts of the component */
|
|
97
|
-
classNames?: PopoverClassNames;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export interface PopoverTriggerProps extends ComponentPropsWithoutRef<"div"> {
|
|
101
|
-
/** The trigger element */
|
|
102
|
-
children: ReactNode;
|
|
103
|
-
|
|
104
|
-
/** Used for editing root class name */
|
|
105
|
-
className?: string;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export interface PopoverDropdownProps extends ComponentPropsWithoutRef<"div"> {
|
|
109
|
-
/** Content to display inside the dropdown */
|
|
110
|
-
children: ReactNode;
|
|
111
|
-
|
|
112
|
-
/** Used for editing root class name */
|
|
113
|
-
className?: string;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export interface PopoverFactoryPayload extends FactoryPayload {
|
|
117
|
-
props: PopoverProps;
|
|
118
|
-
ref: HTMLDivElement;
|
|
119
|
-
compound: {
|
|
120
|
-
configure: ReturnType<typeof createComponentConfig<PopoverProps>>;
|
|
121
|
-
classNames: ReturnType<
|
|
122
|
-
typeof createClassNamesConfig<PopoverClassNames>
|
|
123
|
-
>;
|
|
124
|
-
Trigger: typeof PopoverTrigger;
|
|
125
|
-
Dropdown: typeof PopoverDropdown;
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export interface PopoverTriggerFactoryPayload extends FactoryPayload {
|
|
130
|
-
props: PopoverTriggerProps;
|
|
131
|
-
ref: HTMLDivElement;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export interface PopoverDropdownFactoryPayload extends FactoryPayload {
|
|
135
|
-
props: PopoverDropdownProps;
|
|
136
|
-
ref: HTMLDivElement;
|
|
137
|
-
}
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import { useUncontrolled } from "@refraktor/utils";
|
|
2
|
-
import {
|
|
3
|
-
PopoverMiddlewares,
|
|
4
|
-
PopoverPositioning,
|
|
5
|
-
PopoverTrigger
|
|
6
|
-
} from "./popover.types";
|
|
7
|
-
import {
|
|
8
|
-
arrow,
|
|
9
|
-
autoUpdate,
|
|
10
|
-
flip,
|
|
11
|
-
FloatingContext,
|
|
12
|
-
inline,
|
|
13
|
-
Middleware,
|
|
14
|
-
offset,
|
|
15
|
-
Placement,
|
|
16
|
-
safePolygon,
|
|
17
|
-
shift,
|
|
18
|
-
useClick,
|
|
19
|
-
useDismiss,
|
|
20
|
-
useFloating,
|
|
21
|
-
useFocus,
|
|
22
|
-
useHover,
|
|
23
|
-
useInteractions,
|
|
24
|
-
useRole
|
|
25
|
-
} from "@floating-ui/react";
|
|
26
|
-
import { useCallback, useMemo, useRef } from "react";
|
|
27
|
-
|
|
28
|
-
interface UsePopoverProps {
|
|
29
|
-
opened?: boolean;
|
|
30
|
-
defaultOpened?: boolean;
|
|
31
|
-
onOpenedChange?: (opened: boolean) => void;
|
|
32
|
-
positioning?: PopoverPositioning;
|
|
33
|
-
middlewares?: PopoverMiddlewares;
|
|
34
|
-
disabled?: boolean;
|
|
35
|
-
trigger?: PopoverTrigger;
|
|
36
|
-
showArrow?: boolean;
|
|
37
|
-
closeOnClickOutside?: boolean;
|
|
38
|
-
closeOnEscape?: boolean;
|
|
39
|
-
openDelay?: number;
|
|
40
|
-
closeDelay?: number;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface UsePopoverReturn {
|
|
44
|
-
opened: boolean;
|
|
45
|
-
open: () => void;
|
|
46
|
-
close: () => void;
|
|
47
|
-
toggle: () => void;
|
|
48
|
-
context: FloatingContext;
|
|
49
|
-
refs: {
|
|
50
|
-
setReference: (node: HTMLElement | null) => void;
|
|
51
|
-
setFloating: (node: HTMLElement | null) => void;
|
|
52
|
-
reference: React.MutableRefObject<HTMLElement | null>;
|
|
53
|
-
floating: React.MutableRefObject<HTMLElement | null>;
|
|
54
|
-
};
|
|
55
|
-
floatingStyles: React.CSSProperties;
|
|
56
|
-
getReferenceProps: (
|
|
57
|
-
userProps?: React.HTMLAttributes<HTMLElement>
|
|
58
|
-
) => Record<string, unknown>;
|
|
59
|
-
getFloatingProps: (
|
|
60
|
-
userProps?: React.HTMLAttributes<HTMLElement>
|
|
61
|
-
) => Record<string, unknown>;
|
|
62
|
-
arrowRef: React.RefObject<SVGSVGElement | null>;
|
|
63
|
-
placement: Placement;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function usePopover(options: UsePopoverProps = {}): UsePopoverReturn {
|
|
67
|
-
const {
|
|
68
|
-
opened,
|
|
69
|
-
defaultOpened,
|
|
70
|
-
onOpenedChange,
|
|
71
|
-
positioning = {
|
|
72
|
-
placement: "bottom",
|
|
73
|
-
offset: 8
|
|
74
|
-
},
|
|
75
|
-
middlewares = { flip: true, shift: true },
|
|
76
|
-
disabled = false,
|
|
77
|
-
trigger = "click",
|
|
78
|
-
showArrow = false,
|
|
79
|
-
closeOnClickOutside = true,
|
|
80
|
-
closeOnEscape = true,
|
|
81
|
-
openDelay = 0,
|
|
82
|
-
closeDelay = 0
|
|
83
|
-
} = options;
|
|
84
|
-
|
|
85
|
-
const arrowRef = useRef<SVGSVGElement>(null);
|
|
86
|
-
|
|
87
|
-
const [isOpen, setIsOpen] = useUncontrolled({
|
|
88
|
-
value: opened,
|
|
89
|
-
defaultValue: defaultOpened,
|
|
90
|
-
finalValue: false,
|
|
91
|
-
onChange: onOpenedChange
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
const middleware = useMemo(() => {
|
|
95
|
-
const middlewareList: Middleware[] = [];
|
|
96
|
-
|
|
97
|
-
middlewareList.push(offset(positioning.offset ?? 8));
|
|
98
|
-
|
|
99
|
-
if (middlewares.flip) {
|
|
100
|
-
middlewareList.push(
|
|
101
|
-
flip(
|
|
102
|
-
typeof middlewares.flip === "boolean"
|
|
103
|
-
? undefined
|
|
104
|
-
: middlewares.flip
|
|
105
|
-
)
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (middlewares.shift) {
|
|
110
|
-
middlewareList.push(
|
|
111
|
-
shift(
|
|
112
|
-
typeof middlewares.shift === "boolean"
|
|
113
|
-
? undefined
|
|
114
|
-
: middlewares.shift
|
|
115
|
-
)
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (middlewares.inline) {
|
|
120
|
-
middlewareList.push(
|
|
121
|
-
inline(
|
|
122
|
-
typeof middlewares.inline === "boolean"
|
|
123
|
-
? undefined
|
|
124
|
-
: middlewares.inline
|
|
125
|
-
)
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (arrowRef.current && showArrow) {
|
|
130
|
-
middlewareList.push(
|
|
131
|
-
arrow({
|
|
132
|
-
element: arrowRef.current
|
|
133
|
-
})
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return middlewareList;
|
|
138
|
-
}, [positioning.offset, middlewares, showArrow, arrowRef]);
|
|
139
|
-
|
|
140
|
-
const floating = useFloating({
|
|
141
|
-
placement: positioning.placement,
|
|
142
|
-
open: isOpen,
|
|
143
|
-
onOpenChange: setIsOpen,
|
|
144
|
-
middleware: middleware,
|
|
145
|
-
whileElementsMounted: autoUpdate,
|
|
146
|
-
strategy: "fixed"
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
const click = useClick(floating.context, {
|
|
150
|
-
enabled: trigger === "click" && !disabled
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
const hover = useHover(floating.context, {
|
|
154
|
-
enabled: trigger === "hover" && !disabled,
|
|
155
|
-
handleClose: safePolygon(),
|
|
156
|
-
delay: {
|
|
157
|
-
open: openDelay,
|
|
158
|
-
close: closeDelay
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
const focus = useFocus(floating.context, {
|
|
163
|
-
enabled: trigger === "focus" && !disabled
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
const dismiss = useDismiss(floating.context, {
|
|
167
|
-
outsidePress: closeOnClickOutside,
|
|
168
|
-
escapeKey: closeOnEscape
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
const role = useRole(floating.context, {
|
|
172
|
-
role: "dialog"
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
176
|
-
click,
|
|
177
|
-
hover,
|
|
178
|
-
focus,
|
|
179
|
-
dismiss,
|
|
180
|
-
role
|
|
181
|
-
]);
|
|
182
|
-
|
|
183
|
-
const open = useCallback(() => {
|
|
184
|
-
if (!disabled) {
|
|
185
|
-
setIsOpen(true);
|
|
186
|
-
}
|
|
187
|
-
}, [setIsOpen, disabled]);
|
|
188
|
-
|
|
189
|
-
const close = useCallback(() => {
|
|
190
|
-
setIsOpen(false);
|
|
191
|
-
}, [setIsOpen]);
|
|
192
|
-
|
|
193
|
-
const toggle = useCallback(() => {
|
|
194
|
-
if (!disabled) {
|
|
195
|
-
setIsOpen(!isOpen);
|
|
196
|
-
}
|
|
197
|
-
}, [setIsOpen, isOpen, disabled]);
|
|
198
|
-
|
|
199
|
-
return {
|
|
200
|
-
opened: isOpen,
|
|
201
|
-
open,
|
|
202
|
-
close,
|
|
203
|
-
toggle,
|
|
204
|
-
context: floating.context,
|
|
205
|
-
refs: {
|
|
206
|
-
setReference: floating.refs.setReference,
|
|
207
|
-
setFloating: floating.refs.setFloating,
|
|
208
|
-
reference: floating.refs
|
|
209
|
-
.reference as React.MutableRefObject<HTMLElement | null>,
|
|
210
|
-
floating: floating.refs
|
|
211
|
-
.floating as React.MutableRefObject<HTMLElement | null>
|
|
212
|
-
},
|
|
213
|
-
floatingStyles: floating.floatingStyles,
|
|
214
|
-
getReferenceProps,
|
|
215
|
-
getFloatingProps,
|
|
216
|
-
placement: floating.placement,
|
|
217
|
-
arrowRef
|
|
218
|
-
};
|
|
219
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { render, screen } from "../../vitest";
|
|
3
|
-
import Portal from "./portal";
|
|
4
|
-
|
|
5
|
-
describe("@refraktor/core/Portal", () => {
|
|
6
|
-
it("renders into document.body by default", async () => {
|
|
7
|
-
await render(
|
|
8
|
-
<div data-testid="root">
|
|
9
|
-
<Portal>
|
|
10
|
-
<div data-testid="content">Portal content</div>
|
|
11
|
-
</Portal>
|
|
12
|
-
</div>
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
const root = screen.getByTestId("root");
|
|
16
|
-
const content = await screen.findByTestId("content");
|
|
17
|
-
|
|
18
|
-
expect(document.body).toContainElement(content);
|
|
19
|
-
expect(root).not.toContainElement(content);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("renders into custom target", async () => {
|
|
23
|
-
const target = document.createElement("div");
|
|
24
|
-
target.id = "portal-target";
|
|
25
|
-
document.body.appendChild(target);
|
|
26
|
-
|
|
27
|
-
await render(
|
|
28
|
-
<Portal target="#portal-target">
|
|
29
|
-
<div data-testid="content">Targeted content</div>
|
|
30
|
-
</Portal>
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const content = await screen.findByTestId("content");
|
|
34
|
-
|
|
35
|
-
expect(target).toContainElement(content);
|
|
36
|
-
|
|
37
|
-
target.remove();
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { createPortal } from "react-dom";
|
|
2
|
-
import { createComponentConfig, factory, useProps } from "../../utils";
|
|
3
|
-
import { PortalFactoryPayload, PortalProps } from "./portal.types";
|
|
4
|
-
import { ComponentPropsWithoutRef, useEffect, useRef, useState } from "react";
|
|
5
|
-
|
|
6
|
-
function createPortalNode(props: ComponentPropsWithoutRef<"div">) {
|
|
7
|
-
const node = document.createElement("div");
|
|
8
|
-
node.setAttribute("data-portal", "true");
|
|
9
|
-
typeof props.className === "string" &&
|
|
10
|
-
node.classList.add(...props.className.split(" ").filter(Boolean));
|
|
11
|
-
typeof props.style === "object" && Object.assign(node.style, props.style);
|
|
12
|
-
typeof props.id === "string" && node.setAttribute("id", props.id);
|
|
13
|
-
return node;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function getTargetNode({
|
|
17
|
-
target,
|
|
18
|
-
reuseTargetNode,
|
|
19
|
-
...others
|
|
20
|
-
}: Omit<PortalProps, "children">): HTMLElement {
|
|
21
|
-
if (target) {
|
|
22
|
-
if (typeof target === "string") {
|
|
23
|
-
return (
|
|
24
|
-
document.querySelector<HTMLElement>(target) ||
|
|
25
|
-
createPortalNode(others)
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return target;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (reuseTargetNode) {
|
|
33
|
-
const existingNode = document.querySelector<HTMLElement>(
|
|
34
|
-
"[data-velra-shared-portal-node]"
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
if (existingNode) {
|
|
38
|
-
return existingNode;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const node = createPortalNode(others);
|
|
42
|
-
node.setAttribute("data-velra-shared-portal-node", "true");
|
|
43
|
-
document.body.appendChild(node);
|
|
44
|
-
return node;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return createPortalNode(others);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const Portal = factory<PortalFactoryPayload>((_props, ref) => {
|
|
51
|
-
const { children, target, reuseTargetNode, ...others } = useProps(
|
|
52
|
-
"Portal",
|
|
53
|
-
null,
|
|
54
|
-
_props
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
const [mounted, setMounted] = useState(false);
|
|
58
|
-
const nodeRef = useRef<HTMLElement | null>(null);
|
|
59
|
-
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
setMounted(true);
|
|
62
|
-
nodeRef.current = getTargetNode({ target, reuseTargetNode, ...others });
|
|
63
|
-
|
|
64
|
-
if (ref) {
|
|
65
|
-
if (typeof ref === "function") {
|
|
66
|
-
ref(nodeRef.current as HTMLDivElement);
|
|
67
|
-
} else {
|
|
68
|
-
ref.current = nodeRef.current as HTMLDivElement;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (target && nodeRef.current) {
|
|
73
|
-
const computedStyle = window.getComputedStyle(nodeRef.current);
|
|
74
|
-
if (computedStyle.position === "static") {
|
|
75
|
-
nodeRef.current.style.position = "relative";
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (!target && !reuseTargetNode && nodeRef.current) {
|
|
80
|
-
document.body.appendChild(nodeRef.current);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return () => {
|
|
84
|
-
if (!target && !reuseTargetNode && nodeRef.current) {
|
|
85
|
-
try {
|
|
86
|
-
if (document.body.contains(nodeRef.current)) {
|
|
87
|
-
document.body.removeChild(nodeRef.current);
|
|
88
|
-
}
|
|
89
|
-
} catch (error) {}
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
}, [target, reuseTargetNode]);
|
|
93
|
-
|
|
94
|
-
if (!mounted || !nodeRef.current) {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return createPortal(<>{children}</>, nodeRef.current);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
Portal.displayName = "@refraktor/core/Portal";
|
|
102
|
-
Portal.configure = createComponentConfig<PortalProps>();
|
|
103
|
-
|
|
104
|
-
export default Portal;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
-
import {
|
|
3
|
-
createClassNamesConfig,
|
|
4
|
-
createComponentConfig,
|
|
5
|
-
FactoryPayload
|
|
6
|
-
} from "../../utils";
|
|
7
|
-
|
|
8
|
-
export interface BasePortalProps extends ComponentPropsWithoutRef<"div"> {
|
|
9
|
-
/** Target element to render the portal inside. Can be an HTMLElement or a CSS selector string. */
|
|
10
|
-
target?: HTMLElement | string;
|
|
11
|
-
|
|
12
|
-
/** Whether to reuse a shared portal node for all portals with this option enabled. @default false */
|
|
13
|
-
reuseTargetNode?: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface PortalProps extends BasePortalProps {
|
|
17
|
-
/** The content to render inside the portal */
|
|
18
|
-
children: ReactNode;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type PortalClassNames = {
|
|
22
|
-
root?: string;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export interface PortalFactoryPayload extends FactoryPayload {
|
|
26
|
-
props: PortalProps;
|
|
27
|
-
ref: HTMLDivElement;
|
|
28
|
-
compound: {
|
|
29
|
-
configure: ReturnType<typeof createComponentConfig<PortalProps>>;
|
|
30
|
-
};
|
|
31
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { RefraktorSize } from "../../theme";
|
|
2
|
-
|
|
3
|
-
type ProgressSizeStyles = {
|
|
4
|
-
track: string;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
const sizes: Record<RefraktorSize, ProgressSizeStyles> = {
|
|
8
|
-
xs: {
|
|
9
|
-
track: "h-1"
|
|
10
|
-
},
|
|
11
|
-
sm: {
|
|
12
|
-
track: "h-1.5"
|
|
13
|
-
},
|
|
14
|
-
md: {
|
|
15
|
-
track: "h-2"
|
|
16
|
-
},
|
|
17
|
-
lg: {
|
|
18
|
-
track: "h-2.5"
|
|
19
|
-
},
|
|
20
|
-
xl: {
|
|
21
|
-
track: "h-3"
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const getSize = (size: RefraktorSize = "md") => sizes[size];
|