@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,208 +0,0 @@
|
|
|
1
|
-
import { useId, useUncontrolled } from "@refraktor/utils";
|
|
2
|
-
import { KeyboardEvent } from "react";
|
|
3
|
-
import { XIcon } from "../../icons";
|
|
4
|
-
import { useTheme } from "../../theme";
|
|
5
|
-
import {
|
|
6
|
-
createClassNamesConfig,
|
|
7
|
-
createComponentConfig,
|
|
8
|
-
factory,
|
|
9
|
-
useClassNames,
|
|
10
|
-
useProps
|
|
11
|
-
} from "../../utils";
|
|
12
|
-
import { useChipGroupContext } from "./chip.context";
|
|
13
|
-
import { ChipGroup } from "./chip-group";
|
|
14
|
-
import { getSize, getVariant } from "./chip.styles";
|
|
15
|
-
import { ChipClassNames, ChipFactoryPayload, ChipProps } from "./chip.types";
|
|
16
|
-
|
|
17
|
-
const defaultProps = {
|
|
18
|
-
size: "sm",
|
|
19
|
-
radius: "full",
|
|
20
|
-
variant: "default",
|
|
21
|
-
selectable: false,
|
|
22
|
-
removable: false
|
|
23
|
-
} satisfies Partial<ChipProps>;
|
|
24
|
-
|
|
25
|
-
const Chip = factory<ChipFactoryPayload>((_props, ref) => {
|
|
26
|
-
const { cx, getRadius } = useTheme();
|
|
27
|
-
const {
|
|
28
|
-
id,
|
|
29
|
-
value,
|
|
30
|
-
children,
|
|
31
|
-
selected,
|
|
32
|
-
defaultSelected,
|
|
33
|
-
onSelectedChange,
|
|
34
|
-
selectable,
|
|
35
|
-
removable,
|
|
36
|
-
onRemove,
|
|
37
|
-
removeButtonLabel,
|
|
38
|
-
leftSection,
|
|
39
|
-
rightSection,
|
|
40
|
-
size,
|
|
41
|
-
radius,
|
|
42
|
-
variant,
|
|
43
|
-
disabled,
|
|
44
|
-
className,
|
|
45
|
-
classNames,
|
|
46
|
-
onClick,
|
|
47
|
-
onKeyDown,
|
|
48
|
-
...props
|
|
49
|
-
} = useProps("Chip", defaultProps, _props);
|
|
50
|
-
const classes = useClassNames<ChipClassNames>("Chip", classNames);
|
|
51
|
-
const chipGroup = useChipGroupContext();
|
|
52
|
-
|
|
53
|
-
const _id = useId(id);
|
|
54
|
-
|
|
55
|
-
const [uncontrolledSelected, setUncontrolledSelected] =
|
|
56
|
-
useUncontrolled<boolean>({
|
|
57
|
-
value: selected,
|
|
58
|
-
defaultValue: defaultSelected,
|
|
59
|
-
finalValue: false,
|
|
60
|
-
onChange: onSelectedChange
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const hasGroupValue = !!chipGroup && typeof value === "string";
|
|
64
|
-
const isSelectable = selectable || hasGroupValue;
|
|
65
|
-
const isRemovable = removable || typeof onRemove === "function";
|
|
66
|
-
const isDisabled = !!(disabled || chipGroup?.disabled);
|
|
67
|
-
const resolvedSize = size ?? chipGroup?.size ?? "sm";
|
|
68
|
-
const resolvedRadius = radius ?? chipGroup?.radius ?? "full";
|
|
69
|
-
const resolvedVariant = variant ?? chipGroup?.variant ?? "default";
|
|
70
|
-
const isSelected = hasGroupValue
|
|
71
|
-
? chipGroup.value.includes(value)
|
|
72
|
-
: uncontrolledSelected;
|
|
73
|
-
|
|
74
|
-
const toggleChip = () => {
|
|
75
|
-
if (!isSelectable || isDisabled) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const nextSelected = !isSelected;
|
|
80
|
-
|
|
81
|
-
if (hasGroupValue) {
|
|
82
|
-
chipGroup.onValueChange(value, nextSelected);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
setUncontrolledSelected(nextSelected);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {
|
|
90
|
-
onClick?.(event);
|
|
91
|
-
|
|
92
|
-
if (event.defaultPrevented) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
toggleChip();
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
|
|
100
|
-
onKeyDown?.(event);
|
|
101
|
-
|
|
102
|
-
if (event.defaultPrevented || isDisabled || !isSelectable) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
107
|
-
event.preventDefault();
|
|
108
|
-
toggleChip();
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const handleRemove = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
113
|
-
event.stopPropagation();
|
|
114
|
-
|
|
115
|
-
if (isDisabled) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (hasGroupValue) {
|
|
120
|
-
chipGroup.onValueChange(value, false);
|
|
121
|
-
} else if (isSelectable && isSelected) {
|
|
122
|
-
setUncontrolledSelected(false);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
onRemove?.(event);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
return (
|
|
129
|
-
<div
|
|
130
|
-
ref={ref}
|
|
131
|
-
id={_id}
|
|
132
|
-
data-selected={isSelected}
|
|
133
|
-
data-disabled={isDisabled}
|
|
134
|
-
data-selectable={isSelectable}
|
|
135
|
-
data-removable={isRemovable}
|
|
136
|
-
role={isSelectable ? "button" : undefined}
|
|
137
|
-
tabIndex={isSelectable ? (isDisabled ? -1 : 0) : undefined}
|
|
138
|
-
aria-pressed={isSelectable ? isSelected : undefined}
|
|
139
|
-
aria-disabled={isDisabled || undefined}
|
|
140
|
-
className={cx(
|
|
141
|
-
"inline-flex w-fit max-w-full items-center justify-center border select-none transition-colors",
|
|
142
|
-
"focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--refraktor-primary)]",
|
|
143
|
-
"data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50 data-[disabled=true]:pointer-events-none",
|
|
144
|
-
isSelectable ? "cursor-pointer" : "cursor-default",
|
|
145
|
-
getSize(resolvedSize),
|
|
146
|
-
getRadius(resolvedRadius),
|
|
147
|
-
getVariant(resolvedVariant, isSelected),
|
|
148
|
-
classes.root,
|
|
149
|
-
className
|
|
150
|
-
)}
|
|
151
|
-
onClick={handleClick}
|
|
152
|
-
onKeyDown={handleKeyDown}
|
|
153
|
-
{...props}
|
|
154
|
-
>
|
|
155
|
-
{leftSection && (
|
|
156
|
-
<span
|
|
157
|
-
className={cx(
|
|
158
|
-
"inline-flex shrink-0 items-center justify-center",
|
|
159
|
-
classes.leftSection
|
|
160
|
-
)}
|
|
161
|
-
aria-hidden="true"
|
|
162
|
-
>
|
|
163
|
-
{leftSection}
|
|
164
|
-
</span>
|
|
165
|
-
)}
|
|
166
|
-
|
|
167
|
-
<span className={cx("truncate", classes.label)}>{children}</span>
|
|
168
|
-
|
|
169
|
-
{rightSection && (
|
|
170
|
-
<span
|
|
171
|
-
className={cx(
|
|
172
|
-
"inline-flex shrink-0 items-center justify-center",
|
|
173
|
-
classes.rightSection
|
|
174
|
-
)}
|
|
175
|
-
aria-hidden="true"
|
|
176
|
-
>
|
|
177
|
-
{rightSection}
|
|
178
|
-
</span>
|
|
179
|
-
)}
|
|
180
|
-
|
|
181
|
-
{isRemovable && (
|
|
182
|
-
<button
|
|
183
|
-
type="button"
|
|
184
|
-
tabIndex={isDisabled ? -1 : 0}
|
|
185
|
-
aria-label={removeButtonLabel ?? "Remove chip"}
|
|
186
|
-
className={cx(
|
|
187
|
-
"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 cursor-pointer",
|
|
188
|
-
"focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--refraktor-primary)]",
|
|
189
|
-
classes.removeButton
|
|
190
|
-
)}
|
|
191
|
-
onClick={handleRemove}
|
|
192
|
-
disabled={isDisabled}
|
|
193
|
-
>
|
|
194
|
-
<span className={cx("inline-flex", classes.removeIcon)}>
|
|
195
|
-
<XIcon size={12} />
|
|
196
|
-
</span>
|
|
197
|
-
</button>
|
|
198
|
-
)}
|
|
199
|
-
</div>
|
|
200
|
-
);
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
Chip.displayName = "@refraktor/core/Chip";
|
|
204
|
-
Chip.configure = createComponentConfig<ChipProps>();
|
|
205
|
-
Chip.classNames = createClassNamesConfig<ChipClassNames>();
|
|
206
|
-
Chip.Group = ChipGroup;
|
|
207
|
-
|
|
208
|
-
export default Chip;
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
-
import { RefraktorRadius, RefraktorSize } from "../../theme";
|
|
3
|
-
import {
|
|
4
|
-
createClassNamesConfig,
|
|
5
|
-
createComponentConfig,
|
|
6
|
-
FactoryPayload
|
|
7
|
-
} from "../../utils";
|
|
8
|
-
import { ChipGroup } from "./chip-group";
|
|
9
|
-
|
|
10
|
-
export type ChipVariant = "default" | "outline";
|
|
11
|
-
export type ChipGroupOrientation = "horizontal" | "vertical";
|
|
12
|
-
|
|
13
|
-
export type ChipClassNames = {
|
|
14
|
-
root?: string;
|
|
15
|
-
leftSection?: string;
|
|
16
|
-
label?: string;
|
|
17
|
-
rightSection?: string;
|
|
18
|
-
removeButton?: string;
|
|
19
|
-
removeIcon?: string;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type ChipGroupClassNames = {
|
|
23
|
-
root?: string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export interface ChipProps extends ComponentPropsWithoutRef<"div"> {
|
|
27
|
-
/** The value used by Chip.Group */
|
|
28
|
-
value?: string;
|
|
29
|
-
|
|
30
|
-
/** The selected state of the chip (controlled) */
|
|
31
|
-
selected?: boolean;
|
|
32
|
-
|
|
33
|
-
/** The initial selected state of the chip (uncontrolled) */
|
|
34
|
-
defaultSelected?: boolean;
|
|
35
|
-
|
|
36
|
-
/** Callback called when selected state changes */
|
|
37
|
-
onSelectedChange?: (selected: boolean) => void;
|
|
38
|
-
|
|
39
|
-
/** Whether chip can be toggled @default `false` */
|
|
40
|
-
selectable?: boolean;
|
|
41
|
-
|
|
42
|
-
/** Whether to show remove button @default `false` */
|
|
43
|
-
removable?: boolean;
|
|
44
|
-
|
|
45
|
-
/** Callback called when remove button is clicked */
|
|
46
|
-
onRemove?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
47
|
-
|
|
48
|
-
/** Accessible label for remove button */
|
|
49
|
-
removeButtonLabel?: string;
|
|
50
|
-
|
|
51
|
-
/** Content rendered at the start of the chip */
|
|
52
|
-
leftSection?: ReactNode;
|
|
53
|
-
|
|
54
|
-
/** Content rendered before remove button at the end of the chip */
|
|
55
|
-
rightSection?: ReactNode;
|
|
56
|
-
|
|
57
|
-
/** The size of the chip @default `sm` */
|
|
58
|
-
size?: RefraktorSize;
|
|
59
|
-
|
|
60
|
-
/** The radius of the chip @default `full` */
|
|
61
|
-
radius?: RefraktorRadius;
|
|
62
|
-
|
|
63
|
-
/** The variant of the chip @default `default` */
|
|
64
|
-
variant?: ChipVariant;
|
|
65
|
-
|
|
66
|
-
/** Whether chip is disabled @default `false` */
|
|
67
|
-
disabled?: boolean;
|
|
68
|
-
|
|
69
|
-
/** Used for editing root class name */
|
|
70
|
-
className?: string;
|
|
71
|
-
|
|
72
|
-
/** Used for styling different parts of the component */
|
|
73
|
-
classNames?: ChipClassNames;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface ChipGroupProps
|
|
77
|
-
extends Omit<ComponentPropsWithoutRef<"div">, "onChange"> {
|
|
78
|
-
/** Chip components to render */
|
|
79
|
-
children: ReactNode;
|
|
80
|
-
|
|
81
|
-
/** Selected values (controlled) */
|
|
82
|
-
value?: string[];
|
|
83
|
-
|
|
84
|
-
/** Initial selected values (uncontrolled) */
|
|
85
|
-
defaultValue?: string[];
|
|
86
|
-
|
|
87
|
-
/** Callback called when values change */
|
|
88
|
-
onChange?: (value: string[]) => void;
|
|
89
|
-
|
|
90
|
-
/** Hidden input name used for form submission */
|
|
91
|
-
name?: string;
|
|
92
|
-
|
|
93
|
-
/** Whether all chips in group are disabled */
|
|
94
|
-
disabled?: boolean;
|
|
95
|
-
|
|
96
|
-
/** Shared chip size */
|
|
97
|
-
size?: RefraktorSize;
|
|
98
|
-
|
|
99
|
-
/** Shared chip radius */
|
|
100
|
-
radius?: RefraktorRadius;
|
|
101
|
-
|
|
102
|
-
/** Shared chip variant */
|
|
103
|
-
variant?: ChipVariant;
|
|
104
|
-
|
|
105
|
-
/** Layout direction @default `horizontal` */
|
|
106
|
-
orientation?: ChipGroupOrientation;
|
|
107
|
-
|
|
108
|
-
/** Used for editing root class name */
|
|
109
|
-
className?: string;
|
|
110
|
-
|
|
111
|
-
/** Used for styling different parts of the component */
|
|
112
|
-
classNames?: ChipGroupClassNames;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export interface ChipFactoryPayload extends FactoryPayload {
|
|
116
|
-
props: ChipProps;
|
|
117
|
-
ref: HTMLDivElement;
|
|
118
|
-
compound: {
|
|
119
|
-
configure: ReturnType<typeof createComponentConfig<ChipProps>>;
|
|
120
|
-
classNames: ReturnType<typeof createClassNamesConfig<ChipClassNames>>;
|
|
121
|
-
Group: typeof ChipGroup;
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export interface ChipGroupFactoryPayload extends FactoryPayload {
|
|
126
|
-
props: ChipGroupProps;
|
|
127
|
-
ref: HTMLDivElement;
|
|
128
|
-
compound: {
|
|
129
|
-
configure: ReturnType<typeof createComponentConfig<ChipGroupProps>>;
|
|
130
|
-
classNames: ReturnType<
|
|
131
|
-
typeof createClassNamesConfig<ChipGroupClassNames>
|
|
132
|
-
>;
|
|
133
|
-
};
|
|
134
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { createRef } from "react";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
import { render, screen } from "../../vitest";
|
|
4
|
-
import ColorSwatch from "./color-swatch";
|
|
5
|
-
|
|
6
|
-
describe("@refraktor/core/ColorSwatch", () => {
|
|
7
|
-
it("renders with provided color", async () => {
|
|
8
|
-
await render(
|
|
9
|
-
<ColorSwatch
|
|
10
|
-
color="rgba(255, 0, 0, 0.5)"
|
|
11
|
-
data-testid="swatch"
|
|
12
|
-
classNames={{ color: "custom-color" }}
|
|
13
|
-
/>
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
const swatch = screen.getByTestId("swatch");
|
|
17
|
-
const colorLayer = swatch.querySelector(".custom-color") as HTMLSpanElement;
|
|
18
|
-
|
|
19
|
-
expect(colorLayer).toBeInTheDocument();
|
|
20
|
-
expect(colorLayer).toHaveStyle({ background: "rgba(255, 0, 0, 0.5)" });
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("forwards ref correctly", async () => {
|
|
24
|
-
const ref = createRef<HTMLDivElement>();
|
|
25
|
-
|
|
26
|
-
await render(<ColorSwatch ref={ref} data-testid="swatch" />);
|
|
27
|
-
|
|
28
|
-
expect(ref.current).toBeInstanceOf(HTMLDivElement);
|
|
29
|
-
expect(ref.current?.tagName).toBe("DIV");
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("supports root and slot class names", async () => {
|
|
33
|
-
const { container } = await render(
|
|
34
|
-
<ColorSwatch
|
|
35
|
-
className="custom-root"
|
|
36
|
-
classNames={{
|
|
37
|
-
grid: "custom-grid",
|
|
38
|
-
color: "custom-color",
|
|
39
|
-
content: "custom-content"
|
|
40
|
-
}}
|
|
41
|
-
>
|
|
42
|
-
A
|
|
43
|
-
</ColorSwatch>
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
const root = container.firstElementChild as HTMLDivElement;
|
|
47
|
-
const gridLayer = root.querySelector(".custom-grid") as HTMLSpanElement;
|
|
48
|
-
const colorLayer = root.querySelector(".custom-color") as HTMLSpanElement;
|
|
49
|
-
const contentLayer = root.querySelector(".custom-content") as HTMLSpanElement;
|
|
50
|
-
|
|
51
|
-
expect(root).toHaveClass("custom-root");
|
|
52
|
-
expect(gridLayer).toBeInTheDocument();
|
|
53
|
-
expect(colorLayer).toBeInTheDocument();
|
|
54
|
-
expect(contentLayer).toBeInTheDocument();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("includes transparency grid class", async () => {
|
|
58
|
-
await render(
|
|
59
|
-
<ColorSwatch
|
|
60
|
-
data-testid="swatch"
|
|
61
|
-
classNames={{ grid: "custom-grid" }}
|
|
62
|
-
color="rgba(0, 128, 255, 0.4)"
|
|
63
|
-
/>
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const swatch = screen.getByTestId("swatch");
|
|
67
|
-
const gridLayer = swatch.querySelector(".custom-grid") as HTMLSpanElement;
|
|
68
|
-
|
|
69
|
-
expect(gridLayer).toHaveClass("refraktor-transparency-grid");
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("applies size and radius classes", async () => {
|
|
73
|
-
await render(<ColorSwatch size="xl" radius="full" data-testid="swatch" />);
|
|
74
|
-
|
|
75
|
-
const swatch = screen.getByTestId("swatch");
|
|
76
|
-
|
|
77
|
-
expect(swatch.className).toContain("size-10");
|
|
78
|
-
expect(swatch.className).toContain("rounded-[var(--refraktor-radius-full)]");
|
|
79
|
-
});
|
|
80
|
-
});
|
|
@@ -1,84 +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
|
-
ColorSwatchClassNames,
|
|
12
|
-
ColorSwatchFactoryPayload,
|
|
13
|
-
ColorSwatchProps
|
|
14
|
-
} from "./color-swatch.types";
|
|
15
|
-
import { getSize } from "./color-swatch.styles";
|
|
16
|
-
|
|
17
|
-
const defaultProps = {
|
|
18
|
-
color: "transparent",
|
|
19
|
-
size: "md",
|
|
20
|
-
radius: "default"
|
|
21
|
-
} satisfies Partial<ColorSwatchProps>;
|
|
22
|
-
|
|
23
|
-
const ColorSwatch = factory<ColorSwatchFactoryPayload>((_props, ref) => {
|
|
24
|
-
const { cx, getRadius } = useTheme();
|
|
25
|
-
const {
|
|
26
|
-
id,
|
|
27
|
-
color,
|
|
28
|
-
size,
|
|
29
|
-
radius,
|
|
30
|
-
children,
|
|
31
|
-
className,
|
|
32
|
-
classNames,
|
|
33
|
-
...props
|
|
34
|
-
} = useProps("ColorSwatch", defaultProps, _props);
|
|
35
|
-
const classes = useClassNames("ColorSwatch", classNames);
|
|
36
|
-
|
|
37
|
-
const _id = useId(id);
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<div
|
|
41
|
-
ref={ref}
|
|
42
|
-
id={_id}
|
|
43
|
-
className={cx(
|
|
44
|
-
"relative inline-flex items-center justify-center overflow-hidden shrink-0 border border-[var(--refraktor-border)]",
|
|
45
|
-
getSize(size),
|
|
46
|
-
getRadius(radius),
|
|
47
|
-
classes.root,
|
|
48
|
-
className
|
|
49
|
-
)}
|
|
50
|
-
{...props}
|
|
51
|
-
>
|
|
52
|
-
<span
|
|
53
|
-
aria-hidden
|
|
54
|
-
className={cx(
|
|
55
|
-
"absolute inset-0 refraktor-transparency-grid pointer-events-none",
|
|
56
|
-
classes.grid
|
|
57
|
-
)}
|
|
58
|
-
/>
|
|
59
|
-
|
|
60
|
-
<span
|
|
61
|
-
aria-hidden
|
|
62
|
-
className={cx("absolute inset-0 pointer-events-none", classes.color)}
|
|
63
|
-
style={{ background: color }}
|
|
64
|
-
/>
|
|
65
|
-
|
|
66
|
-
{children && (
|
|
67
|
-
<span
|
|
68
|
-
className={cx(
|
|
69
|
-
"relative z-[1] inline-flex items-center justify-center",
|
|
70
|
-
classes.content
|
|
71
|
-
)}
|
|
72
|
-
>
|
|
73
|
-
{children}
|
|
74
|
-
</span>
|
|
75
|
-
)}
|
|
76
|
-
</div>
|
|
77
|
-
);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
ColorSwatch.displayName = "@refraktor/core/ColorSwatch";
|
|
81
|
-
ColorSwatch.configure = createComponentConfig<ColorSwatchProps>();
|
|
82
|
-
ColorSwatch.classNames = createClassNamesConfig<ColorSwatchClassNames>();
|
|
83
|
-
|
|
84
|
-
export default ColorSwatch;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
-
import { RefraktorRadius, RefraktorSize } from "../../theme";
|
|
3
|
-
import {
|
|
4
|
-
createClassNamesConfig,
|
|
5
|
-
createComponentConfig,
|
|
6
|
-
FactoryPayload
|
|
7
|
-
} from "../../utils";
|
|
8
|
-
|
|
9
|
-
export type ColorSwatchClassNames = {
|
|
10
|
-
root?: string;
|
|
11
|
-
grid?: string;
|
|
12
|
-
color?: string;
|
|
13
|
-
content?: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export interface ColorSwatchProps
|
|
17
|
-
extends Omit<ComponentPropsWithoutRef<"div">, "color"> {
|
|
18
|
-
/** Swatch color value (hex, rgb, rgba, hsl, etc.) */
|
|
19
|
-
color?: string;
|
|
20
|
-
|
|
21
|
-
/** Swatch size @default `md` */
|
|
22
|
-
size?: RefraktorSize;
|
|
23
|
-
|
|
24
|
-
/** Swatch radius @default `default` */
|
|
25
|
-
radius?: RefraktorRadius;
|
|
26
|
-
|
|
27
|
-
/** Optional centered content */
|
|
28
|
-
children?: ReactNode;
|
|
29
|
-
|
|
30
|
-
/** Used for editing root class name */
|
|
31
|
-
className?: string;
|
|
32
|
-
|
|
33
|
-
/** Used for styling different parts of the component */
|
|
34
|
-
classNames?: ColorSwatchClassNames;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface ColorSwatchFactoryPayload extends FactoryPayload {
|
|
38
|
-
props: ColorSwatchProps;
|
|
39
|
-
ref: HTMLDivElement;
|
|
40
|
-
compound: {
|
|
41
|
-
configure: ReturnType<typeof createComponentConfig<ColorSwatchProps>>;
|
|
42
|
-
classNames: ReturnType<
|
|
43
|
-
typeof createClassNamesConfig<ColorSwatchClassNames>
|
|
44
|
-
>;
|
|
45
|
-
};
|
|
46
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { useTheme } from "../../../theme";
|
|
2
|
-
import { factory } from "../../../utils";
|
|
3
|
-
import { useDrawerContext } from "../drawer.context";
|
|
4
|
-
import { DrawerBodyFactoryPayload } from "../drawer.types";
|
|
5
|
-
|
|
6
|
-
const DrawerBody = factory<DrawerBodyFactoryPayload>(
|
|
7
|
-
({ children, className, ...props }, ref) => {
|
|
8
|
-
const { cx } = useTheme();
|
|
9
|
-
const { getStyles } = useDrawerContext();
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<div
|
|
13
|
-
ref={ref}
|
|
14
|
-
className={cx(
|
|
15
|
-
"overflow-y-auto",
|
|
16
|
-
getStyles("body"),
|
|
17
|
-
className
|
|
18
|
-
)}
|
|
19
|
-
{...props}
|
|
20
|
-
>
|
|
21
|
-
{children}
|
|
22
|
-
</div>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
DrawerBody.displayName = "@refraktor/core/Drawer.Body";
|
|
28
|
-
|
|
29
|
-
export default DrawerBody;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as DrawerBody } from "./drawer-body";
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { XIcon } from "../../../icons";
|
|
2
|
-
import { useTheme } from "../../../theme";
|
|
3
|
-
import { factory } from "../../../utils";
|
|
4
|
-
import { useDrawerContext } from "../drawer.context";
|
|
5
|
-
import { DrawerCloseFactoryPayload } from "../drawer.types";
|
|
6
|
-
|
|
7
|
-
const DrawerClose = factory<DrawerCloseFactoryPayload>(
|
|
8
|
-
({ children, className, onClick, type = "button", ...props }, ref) => {
|
|
9
|
-
const { cx } = useTheme();
|
|
10
|
-
const { drawer, getStyles } = useDrawerContext();
|
|
11
|
-
|
|
12
|
-
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
13
|
-
onClick?.(event);
|
|
14
|
-
|
|
15
|
-
if (event.defaultPrevented) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
drawer.close();
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<button
|
|
24
|
-
ref={ref}
|
|
25
|
-
type={type}
|
|
26
|
-
aria-label="Close"
|
|
27
|
-
className={cx(
|
|
28
|
-
"size-6 cursor-pointer text-[var(--refraktor-text-secondary)] transition-colors hover:text-[var(--refraktor-text)]",
|
|
29
|
-
getStyles("close"),
|
|
30
|
-
className
|
|
31
|
-
)}
|
|
32
|
-
onClick={handleClick}
|
|
33
|
-
{...props}
|
|
34
|
-
>
|
|
35
|
-
{children ?? <XIcon />}
|
|
36
|
-
</button>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
DrawerClose.displayName = "@refraktor/core/Drawer.Close";
|
|
42
|
-
|
|
43
|
-
export default DrawerClose;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as DrawerClose } from "./drawer-close";
|