@fleetia/components 1.1.1
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/dist/Badge/Badge.css.d.ts +1 -0
- package/dist/Badge/Badge.d.ts +7 -0
- package/dist/Badge/Badge.js +9 -0
- package/dist/Badge/Badge.styles.js +6 -0
- package/dist/Badge/index.d.ts +1 -0
- package/dist/Badge/index.js +1 -0
- package/dist/Box/Box.css.d.ts +4 -0
- package/dist/Box/Box.d.ts +8 -0
- package/dist/Box/Box.js +14 -0
- package/dist/Box/Box.styles.js +9 -0
- package/dist/Box/index.d.ts +1 -0
- package/dist/Box/index.js +1 -0
- package/dist/Breadcrumb/Breadcrumb.css.d.ts +4 -0
- package/dist/Breadcrumb/Breadcrumb.d.ts +11 -0
- package/dist/Breadcrumb/Breadcrumb.js +10 -0
- package/dist/Breadcrumb/Breadcrumb.styles.js +9 -0
- package/dist/Breadcrumb/index.d.ts +1 -0
- package/dist/Breadcrumb/index.js +1 -0
- package/dist/Button/Button.css.d.ts +2 -0
- package/dist/Button/Button.d.ts +12 -0
- package/dist/Button/Button.js +9 -0
- package/dist/Button/Button.styles.js +7 -0
- package/dist/Button/index.d.ts +1 -0
- package/dist/Button/index.js +1 -0
- package/dist/CardPagination/CardPagination.css.d.ts +3 -0
- package/dist/CardPagination/CardPagination.d.ts +9 -0
- package/dist/CardPagination/CardPagination.js +15 -0
- package/dist/CardPagination/CardPagination.styles.js +8 -0
- package/dist/CardPagination/index.d.ts +1 -0
- package/dist/CardPagination/index.js +1 -0
- package/dist/Checkbox/Checkbox.css.d.ts +3 -0
- package/dist/Checkbox/Checkbox.d.ts +9 -0
- package/dist/Checkbox/Checkbox.js +11 -0
- package/dist/Checkbox/Checkbox.styles.js +8 -0
- package/dist/Checkbox/index.d.ts +1 -0
- package/dist/Checkbox/index.js +1 -0
- package/dist/CollapsibleSection/CollapsibleSection.css.d.ts +3 -0
- package/dist/CollapsibleSection/CollapsibleSection.d.ts +8 -0
- package/dist/CollapsibleSection/CollapsibleSection.js +11 -0
- package/dist/CollapsibleSection/CollapsibleSection.styles.js +8 -0
- package/dist/CollapsibleSection/index.d.ts +1 -0
- package/dist/CollapsibleSection/index.js +1 -0
- package/dist/ColorPicker/ColorPicker.constants.d.ts +5 -0
- package/dist/ColorPicker/ColorPicker.constants.js +8 -0
- package/dist/ColorPicker/ColorPicker.css.d.ts +19 -0
- package/dist/ColorPicker/ColorPicker.d.ts +6 -0
- package/dist/ColorPicker/ColorPicker.js +55 -0
- package/dist/ColorPicker/ColorPicker.styles.js +24 -0
- package/dist/ColorPicker/ColorPicker.type.d.ts +8 -0
- package/dist/ColorPicker/ColorPicker.utils.d.ts +6 -0
- package/dist/ColorPicker/ColorPicker.utils.js +49 -0
- package/dist/ColorPicker/NativeColorPicker.d.ts +2 -0
- package/dist/ColorPicker/NativeColorPicker.js +13 -0
- package/dist/ColorPicker/index.d.ts +1 -0
- package/dist/ColorPicker/index.js +1 -0
- package/dist/ColorPicker/useColorPanel.d.ts +11 -0
- package/dist/ColorPicker/useColorPanel.js +38 -0
- package/dist/ColorPicker/useColorWheel.d.ts +18 -0
- package/dist/ColorPicker/useColorWheel.js +232 -0
- package/dist/ColorRow/ColorRow.css.d.ts +1 -0
- package/dist/ColorRow/ColorRow.d.ts +9 -0
- package/dist/ColorRow/ColorRow.js +9 -0
- package/dist/ColorRow/ColorRow.styles.js +5 -0
- package/dist/ColorRow/index.d.ts +1 -0
- package/dist/ColorRow/index.js +1 -0
- package/dist/ConfirmDialog/ConfirmDialog.css.d.ts +7 -0
- package/dist/ConfirmDialog/ConfirmDialog.d.ts +4 -0
- package/dist/ConfirmDialog/ConfirmDialog.js +22 -0
- package/dist/ConfirmDialog/ConfirmDialog.styles.js +12 -0
- package/dist/ConfirmDialog/ConfirmDialog.type.d.ts +9 -0
- package/dist/ConfirmDialog/index.d.ts +1 -0
- package/dist/ConfirmDialog/index.js +1 -0
- package/dist/ContextMenu/ContextMenu.css.d.ts +3 -0
- package/dist/ContextMenu/ContextMenu.d.ts +5 -0
- package/dist/ContextMenu/ContextMenu.js +16 -0
- package/dist/ContextMenu/ContextMenu.styles.js +8 -0
- package/dist/ContextMenu/ContextMenu.type.d.ts +11 -0
- package/dist/ContextMenu/index.d.ts +1 -0
- package/dist/ContextMenu/index.js +1 -0
- package/dist/ContextMenu/useContextMenuKeyboard.d.ts +5 -0
- package/dist/ContextMenu/useContextMenuKeyboard.js +63 -0
- package/dist/ContextMenu/useViewportClamp.d.ts +2 -0
- package/dist/ContextMenu/useViewportClamp.js +18 -0
- package/dist/DateInput/DateInput.css.d.ts +5 -0
- package/dist/DateInput/DateInput.d.ts +11 -0
- package/dist/DateInput/DateInput.js +23 -0
- package/dist/DateInput/DateInput.styles.js +10 -0
- package/dist/DateInput/index.d.ts +1 -0
- package/dist/DateInput/index.js +1 -0
- package/dist/IconButton/IconButton.css.d.ts +7 -0
- package/dist/IconButton/IconButton.d.ts +5 -0
- package/dist/IconButton/IconButton.js +22 -0
- package/dist/IconButton/IconButton.styles.js +12 -0
- package/dist/IconButton/IconButton.type.d.ts +27 -0
- package/dist/IconButton/index.d.ts +1 -0
- package/dist/IconButton/index.js +1 -0
- package/dist/Modal/Modal.css.d.ts +6 -0
- package/dist/Modal/Modal.d.ts +4 -0
- package/dist/Modal/Modal.js +19 -0
- package/dist/Modal/Modal.styles.js +11 -0
- package/dist/Modal/Modal.type.d.ts +9 -0
- package/dist/Modal/index.d.ts +1 -0
- package/dist/Modal/index.js +1 -0
- package/dist/NavigationButton/NavigationButton.css.d.ts +1 -0
- package/dist/NavigationButton/NavigationButton.d.ts +8 -0
- package/dist/NavigationButton/NavigationButton.js +14 -0
- package/dist/NavigationButton/NavigationButton.styles.js +6 -0
- package/dist/NavigationButton/index.d.ts +1 -0
- package/dist/NavigationButton/index.js +1 -0
- package/dist/PositionGrid/PositionGrid.css.d.ts +10 -0
- package/dist/PositionGrid/PositionGrid.d.ts +5 -0
- package/dist/PositionGrid/PositionGrid.js +17 -0
- package/dist/PositionGrid/PositionGrid.styles.js +15 -0
- package/dist/PositionGrid/PositionGrid.type.d.ts +13 -0
- package/dist/PositionGrid/index.d.ts +1 -0
- package/dist/PositionGrid/index.js +1 -0
- package/dist/RadioGroup/RadioGroup.css.d.ts +3 -0
- package/dist/RadioGroup/RadioGroup.d.ts +15 -0
- package/dist/RadioGroup/RadioGroup.js +15 -0
- package/dist/RadioGroup/RadioGroup.styles.js +8 -0
- package/dist/RadioGroup/index.d.ts +1 -0
- package/dist/RadioGroup/index.js +1 -0
- package/dist/RangeInput/RangeInput.css.d.ts +4 -0
- package/dist/RangeInput/RangeInput.d.ts +12 -0
- package/dist/RangeInput/RangeInput.js +10 -0
- package/dist/RangeInput/RangeInput.styles.js +9 -0
- package/dist/RangeInput/index.d.ts +1 -0
- package/dist/RangeInput/index.js +1 -0
- package/dist/Select/Select.css.d.ts +4 -0
- package/dist/Select/Select.d.ts +20 -0
- package/dist/Select/Select.js +15 -0
- package/dist/Select/Select.styles.js +8 -0
- package/dist/Select/index.d.ts +1 -0
- package/dist/Select/index.js +1 -0
- package/dist/Sidebar/Sidebar.css.d.ts +3 -0
- package/dist/Sidebar/Sidebar.d.ts +10 -0
- package/dist/Sidebar/Sidebar.js +9 -0
- package/dist/Sidebar/Sidebar.styles.js +8 -0
- package/dist/Sidebar/index.d.ts +1 -0
- package/dist/Sidebar/index.js +1 -0
- package/dist/Tabs/Tabs.css.d.ts +5 -0
- package/dist/Tabs/Tabs.d.ts +14 -0
- package/dist/Tabs/Tabs.js +33 -0
- package/dist/Tabs/Tabs.styles.js +10 -0
- package/dist/Tabs/index.d.ts +1 -0
- package/dist/Tabs/index.js +1 -0
- package/dist/TextInput/TextInput.css.d.ts +5 -0
- package/dist/TextInput/TextInput.d.ts +17 -0
- package/dist/TextInput/TextInput.js +14 -0
- package/dist/TextInput/TextInput.styles.js +10 -0
- package/dist/TextInput/index.d.ts +1 -0
- package/dist/TextInput/index.js +1 -0
- package/dist/Toggle/Toggle.css.d.ts +4 -0
- package/dist/Toggle/Toggle.d.ts +9 -0
- package/dist/Toggle/Toggle.js +14 -0
- package/dist/Toggle/Toggle.styles.js +9 -0
- package/dist/Toggle/index.d.ts +1 -0
- package/dist/Toggle/index.js +1 -0
- package/dist/Tree/Tree.css.d.ts +10 -0
- package/dist/Tree/Tree.d.ts +4 -0
- package/dist/Tree/Tree.js +72 -0
- package/dist/Tree/Tree.styles.js +15 -0
- package/dist/Tree/Tree.type.d.ts +26 -0
- package/dist/Tree/TreeLevel.d.ts +3 -0
- package/dist/Tree/TreeLevel.js +42 -0
- package/dist/Tree/index.d.ts +1 -0
- package/dist/Tree/index.js +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/useBodyScrollLock.d.ts +1 -0
- package/dist/hooks/useBodyScrollLock.js +15 -0
- package/dist/hooks/useFocusTrap.d.ts +7 -0
- package/dist/hooks/useFocusTrap.js +59 -0
- package/dist/i18n/I18nProvider.d.ts +8 -0
- package/dist/i18n/I18nProvider.js +13 -0
- package/dist/i18n/context.d.ts +9 -0
- package/dist/i18n/context.js +15 -0
- package/dist/i18n/index.d.ts +3 -0
- package/dist/i18n/index.js +2 -0
- package/dist/i18n/locales/en.d.ts +3 -0
- package/dist/i18n/locales/en.js +152 -0
- package/dist/i18n/locales/ja.d.ts +3 -0
- package/dist/i18n/locales/ja.js +152 -0
- package/dist/i18n/locales/ko.d.ts +3 -0
- package/dist/i18n/locales/ko.js +152 -0
- package/dist/i18n/types.d.ts +3 -0
- package/dist/icons/ChevronLeftIcon.d.ts +7 -0
- package/dist/icons/ChevronLeftIcon.js +7 -0
- package/dist/icons/ChevronRightIcon.d.ts +7 -0
- package/dist/icons/ChevronRightIcon.js +7 -0
- package/dist/icons/DragHandleIcon.d.ts +7 -0
- package/dist/icons/DragHandleIcon.js +7 -0
- package/dist/icons/EyeIcon.d.ts +8 -0
- package/dist/icons/EyeIcon.js +10 -0
- package/dist/icons/FolderIcon.d.ts +7 -0
- package/dist/icons/FolderIcon.js +7 -0
- package/dist/icons/GearIcon.d.ts +7 -0
- package/dist/icons/GearIcon.js +7 -0
- package/dist/icons/TriangleDownIcon.d.ts +7 -0
- package/dist/icons/TriangleDownIcon.js +7 -0
- package/dist/icons/TriangleUpIcon.d.ts +7 -0
- package/dist/icons/TriangleUpIcon.js +7 -0
- package/dist/icons/index.d.ts +8 -0
- package/dist/icons/index.js +8 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -0
- package/dist/styles/Badge/Badge.css +22 -0
- package/dist/styles/Box/Box.css +20 -0
- package/dist/styles/Breadcrumb/Breadcrumb.css +28 -0
- package/dist/styles/Button/Button.css +51 -0
- package/dist/styles/CardPagination/CardPagination.css +29 -0
- package/dist/styles/Checkbox/Checkbox.css +22 -0
- package/dist/styles/CollapsibleSection/CollapsibleSection.css +21 -0
- package/dist/styles/ColorPicker/ColorPicker.css +153 -0
- package/dist/styles/ColorRow/ColorRow.css +9 -0
- package/dist/styles/ConfirmDialog/ConfirmDialog.css +52 -0
- package/dist/styles/ContextMenu/ContextMenu.css +34 -0
- package/dist/styles/DateInput/DateInput.css +47 -0
- package/dist/styles/IconButton/IconButton.css +79 -0
- package/dist/styles/Modal/Modal.css +58 -0
- package/dist/styles/NavigationButton/NavigationButton.css +13 -0
- package/dist/styles/PositionGrid/PositionGrid.css +70 -0
- package/dist/styles/RadioGroup/RadioGroup.css +26 -0
- package/dist/styles/RangeInput/RangeInput.css +33 -0
- package/dist/styles/Select/Select.css +39 -0
- package/dist/styles/Sidebar/Sidebar.css +18 -0
- package/dist/styles/Tabs/Tabs.css +61 -0
- package/dist/styles/TextInput/TextInput.css +37 -0
- package/dist/styles/Toggle/Toggle.css +46 -0
- package/dist/styles/Tree/Tree.css +89 -0
- package/dist/styles/tokens.css +13 -0
- package/dist/styles/tokens.css.d.ts +15 -0
- package/dist/styles/tokens.styles.js +5 -0
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/index.js +1 -0
- package/dist/theme/presets.d.ts +3 -0
- package/dist/theme/presets.js +22 -0
- package/dist/theme/types.d.ts +10 -0
- package/dist/utils/colorUtils.d.ts +32 -0
- package/dist/utils/colorUtils.js +227 -0
- package/dist/utils/cssVariable.d.ts +2 -0
- package/dist/utils/cssVariable.js +11 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/package.json +191 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const variant: Record<"default" | "active" | "inactive", string>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { variant } from './Badge.styles.js';
|
|
4
|
+
|
|
5
|
+
function Badge({ variant: variant$1 = "default", children, className }) {
|
|
6
|
+
return (jsx("span", { role: variant$1 !== "default" ? "status" : undefined, className: clsx(variant[variant$1], className), children: children }));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { Badge };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import './../styles/tokens.css';
|
|
2
|
+
import './../styles/Badge/Badge.css';
|
|
3
|
+
|
|
4
|
+
var variant = {active:'Badge_variant_active__oin6dk1 Badge_base__oin6dk0',inactive:'Badge_variant_inactive__oin6dk2 Badge_base__oin6dk0','default':'Badge_variant_default__oin6dk3 Badge_base__oin6dk0'};
|
|
5
|
+
|
|
6
|
+
export { variant };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Badge, type BadgeProps } from "./Badge";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Badge } from './Badge.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type BoxProps = {
|
|
3
|
+
title?: React.ReactNode;
|
|
4
|
+
subtitle?: React.ReactNode;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function Box({ title, subtitle, children, className }: BoxProps): React.ReactElement;
|
package/dist/Box/Box.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { header, title, subtitle, container } from './Box.styles.js';
|
|
5
|
+
|
|
6
|
+
function Box({ title: title$1, subtitle: subtitle$1, children, className }) {
|
|
7
|
+
const titleId = useId();
|
|
8
|
+
const hasHeader = title$1 != null || subtitle$1 != null;
|
|
9
|
+
const isStringTitle = typeof title$1 === "string";
|
|
10
|
+
return (jsxs("section", { role: isStringTitle ? "group" : undefined, "aria-labelledby": isStringTitle ? titleId : undefined, className: clsx(container, className), children: [hasHeader && (jsxs("div", { className: header, children: [isStringTitle ? (jsx("span", { id: titleId, className: title, children: title$1 })) : (title$1), subtitle$1 != null &&
|
|
11
|
+
(typeof subtitle$1 === "string" ? (jsx("span", { className: subtitle, children: subtitle$1 })) : (subtitle$1))] })), children] }));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { Box };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import './../styles/tokens.css';
|
|
2
|
+
import './../styles/Box/Box.css';
|
|
3
|
+
|
|
4
|
+
var container = 'Box_container__141rrv70';
|
|
5
|
+
var header = 'Box_header__141rrv71';
|
|
6
|
+
var subtitle = 'Box_subtitle__141rrv73';
|
|
7
|
+
var title = 'Box_title__141rrv72';
|
|
8
|
+
|
|
9
|
+
export { container, header, subtitle, title };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Box, type BoxProps } from "./Box";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Box } from './Box.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type BreadcrumbItem = {
|
|
3
|
+
label: string;
|
|
4
|
+
onClick?: () => void;
|
|
5
|
+
};
|
|
6
|
+
export type BreadcrumbProps = {
|
|
7
|
+
items: BreadcrumbItem[];
|
|
8
|
+
className?: string;
|
|
9
|
+
};
|
|
10
|
+
declare function Breadcrumb({ items, className }: BreadcrumbProps): React.ReactElement;
|
|
11
|
+
export { Breadcrumb };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import { breadcrumbSeparator, breadcrumbItem, breadcrumbItemActive, breadcrumb } from './Breadcrumb.styles.js';
|
|
5
|
+
|
|
6
|
+
function Breadcrumb({ items, className }) {
|
|
7
|
+
return (jsx("nav", { "aria-label": "Breadcrumb", className: clsx(breadcrumb, className), children: items.map((item, i) => (jsxs(React.Fragment, { children: [i > 0 && (jsx("span", { className: breadcrumbSeparator, "aria-hidden": "true", children: "/" })), jsx("button", { className: clsx(breadcrumbItem, i === items.length - 1 && breadcrumbItemActive), onClick: item.onClick, "aria-current": i === items.length - 1 ? "page" : undefined, children: item.label })] }, item.label))) }));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { Breadcrumb };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import './../styles/tokens.css';
|
|
2
|
+
import './../styles/Breadcrumb/Breadcrumb.css';
|
|
3
|
+
|
|
4
|
+
var breadcrumb = 'Breadcrumb_breadcrumb__1bb9vx80';
|
|
5
|
+
var breadcrumbItem = 'Breadcrumb_breadcrumbItem__1bb9vx81';
|
|
6
|
+
var breadcrumbItemActive = 'Breadcrumb_breadcrumbItemActive__1bb9vx82';
|
|
7
|
+
var breadcrumbSeparator = 'Breadcrumb_breadcrumbSeparator__1bb9vx83';
|
|
8
|
+
|
|
9
|
+
export { breadcrumb, breadcrumbItem, breadcrumbItemActive, breadcrumbSeparator };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Breadcrumb, type BreadcrumbProps, type BreadcrumbItem } from "./Breadcrumb";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Breadcrumb } from './Breadcrumb.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type ButtonProps = {
|
|
3
|
+
variant?: "primary" | "secondary" | "ghost" | "danger";
|
|
4
|
+
size?: "sm" | "md";
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
8
|
+
type?: "button" | "submit" | "reset";
|
|
9
|
+
className?: string;
|
|
10
|
+
"aria-busy"?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare function Button({ variant, size, disabled, children, onClick, type, className, "aria-busy": ariaBusy }: ButtonProps): React.ReactElement;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { size, variant } from './Button.styles.js';
|
|
4
|
+
|
|
5
|
+
function Button({ variant: variant$1 = "secondary", size: size$1 = "md", disabled, children, onClick, type = "button", className, "aria-busy": ariaBusy }) {
|
|
6
|
+
return (jsx("button", { type: type, disabled: disabled, "aria-disabled": disabled || undefined, "aria-busy": ariaBusy, onClick: onClick, className: clsx(size[size$1], variant[variant$1], className), children: children }));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { Button };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import './../styles/tokens.css';
|
|
2
|
+
import './../styles/Button/Button.css';
|
|
3
|
+
|
|
4
|
+
var size = {sm:'Button_size_sm__171gz8m1 Button_base__171gz8m0',md:'Button_size_md__171gz8m2 Button_base__171gz8m0'};
|
|
5
|
+
var variant = {primary:'Button_variant_primary__171gz8m3',secondary:'Button_variant_secondary__171gz8m4',ghost:'Button_variant_ghost__171gz8m5',danger:'Button_variant_danger__171gz8m6'};
|
|
6
|
+
|
|
7
|
+
export { size, variant };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Button, type ButtonProps } from "./Button";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Button } from './Button.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type CardPaginationProps = {
|
|
3
|
+
currentPage: number;
|
|
4
|
+
totalPages: number;
|
|
5
|
+
onPrev: () => void;
|
|
6
|
+
onNext: () => void;
|
|
7
|
+
};
|
|
8
|
+
declare const CardPagination: React.NamedExoticComponent<CardPaginationProps>;
|
|
9
|
+
export { CardPagination };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { TriangleUpIcon } from '../icons/TriangleUpIcon.js';
|
|
4
|
+
import { TriangleDownIcon } from '../icons/TriangleDownIcon.js';
|
|
5
|
+
import { useTranslation } from '../i18n/context.js';
|
|
6
|
+
import { cardNav, cardNavButton, cardNavIndicator } from './CardPagination.styles.js';
|
|
7
|
+
|
|
8
|
+
const CardPagination = React.memo(function CardPagination({ currentPage, totalPages, onPrev, onNext }) {
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const isFirst = currentPage === 0;
|
|
11
|
+
const isLast = currentPage === totalPages - 1;
|
|
12
|
+
return (jsxs("nav", { "aria-label": "Pagination", className: cardNav, children: [jsx("button", { className: cardNavButton, onClick: onPrev, "aria-label": t("pagination.previousPage"), disabled: isFirst, "aria-disabled": isFirst, children: jsx(TriangleUpIcon, {}) }), jsxs("span", { className: cardNavIndicator, "aria-current": "page", children: [currentPage + 1, "/", totalPages] }), jsx("button", { className: cardNavButton, onClick: onNext, "aria-label": t("pagination.nextPage"), disabled: isLast, "aria-disabled": isLast, children: jsx(TriangleDownIcon, {}) })] }));
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export { CardPagination };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import './../styles/tokens.css';
|
|
2
|
+
import './../styles/CardPagination/CardPagination.css';
|
|
3
|
+
|
|
4
|
+
var cardNav = 'CardPagination_cardNav__nwr0gc0';
|
|
5
|
+
var cardNavButton = 'CardPagination_cardNavButton__nwr0gc1';
|
|
6
|
+
var cardNavIndicator = 'CardPagination_cardNavIndicator__nwr0gc2';
|
|
7
|
+
|
|
8
|
+
export { cardNav, cardNavButton, cardNavIndicator };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CardPagination, type CardPaginationProps } from "./CardPagination";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CardPagination } from './CardPagination.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type CheckboxProps = {
|
|
3
|
+
label: string;
|
|
4
|
+
checked: boolean;
|
|
5
|
+
onChange: (checked: boolean) => void;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
className?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function Checkbox({ label, checked, onChange, disabled, className }: CheckboxProps): React.ReactElement;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { input, label, wrapper } from './Checkbox.styles.js';
|
|
5
|
+
|
|
6
|
+
function Checkbox({ label: label$1, checked, onChange, disabled, className }) {
|
|
7
|
+
const inputId = useId();
|
|
8
|
+
return (jsxs("label", { htmlFor: inputId, className: clsx(wrapper, className), "data-disabled": disabled || undefined, children: [jsx("input", { id: inputId, type: "checkbox", checked: checked, "aria-checked": checked, onChange: e => onChange(e.target.checked), disabled: disabled, className: input }), jsx("span", { className: label, children: label$1 })] }));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { Checkbox };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Checkbox, type CheckboxProps } from "./Checkbox";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Checkbox } from './Checkbox.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type CollapsibleSectionProps = {
|
|
3
|
+
title: string;
|
|
4
|
+
defaultOpen?: boolean;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
};
|
|
7
|
+
declare function CollapsibleSection({ title, defaultOpen, children }: CollapsibleSectionProps): React.ReactElement;
|
|
8
|
+
export { CollapsibleSection };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useId } from 'react';
|
|
3
|
+
import { item, title, body } from './CollapsibleSection.styles.js';
|
|
4
|
+
|
|
5
|
+
function CollapsibleSection({ title: title$1, defaultOpen = false, children }) {
|
|
6
|
+
const [isOpen, setIsOpen] = useState(defaultOpen);
|
|
7
|
+
const contentId = useId();
|
|
8
|
+
return (jsxs("div", { className: item, children: [jsx("button", { className: title, onClick: () => setIsOpen(prev => !prev), "aria-expanded": isOpen, "aria-controls": contentId, children: title$1 }), isOpen && (jsx("div", { id: contentId, className: body, children: children }))] }));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { CollapsibleSection };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import './../styles/tokens.css';
|
|
2
|
+
import './../styles/CollapsibleSection/CollapsibleSection.css';
|
|
3
|
+
|
|
4
|
+
var body = 'CollapsibleSection_body__1ktikzy2';
|
|
5
|
+
var item = 'CollapsibleSection_item__1ktikzy0';
|
|
6
|
+
var title = 'CollapsibleSection_title__1ktikzy1';
|
|
7
|
+
|
|
8
|
+
export { body, item, title };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CollapsibleSection, type CollapsibleSectionProps } from "./CollapsibleSection";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CollapsibleSection } from './CollapsibleSection.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const WHEEL_SIZE = 220;
|
|
2
|
+
const RING_WIDTH = 22;
|
|
3
|
+
const INNER_RADIUS = WHEEL_SIZE / 2 - RING_WIDTH;
|
|
4
|
+
const TRIANGLE_RADIUS = INNER_RADIUS - 4;
|
|
5
|
+
const isTouchDevice = typeof window !== "undefined" &&
|
|
6
|
+
window.matchMedia("(pointer: coarse)").matches;
|
|
7
|
+
|
|
8
|
+
export { INNER_RADIUS, RING_WIDTH, TRIANGLE_RADIUS, WHEEL_SIZE, isTouchDevice };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const wrapper: string;
|
|
2
|
+
export declare const trigger: string;
|
|
3
|
+
export declare const swatch: string;
|
|
4
|
+
export declare const panel: string;
|
|
5
|
+
export declare const canvasWrap: string;
|
|
6
|
+
export declare const alphaSection: string;
|
|
7
|
+
export declare const alphaLabel: string;
|
|
8
|
+
export declare const alphaTrack: string;
|
|
9
|
+
export declare const alphaGradient: string;
|
|
10
|
+
export declare const alphaThumb: string;
|
|
11
|
+
export declare const formatRow: string;
|
|
12
|
+
export declare const formatButton: string;
|
|
13
|
+
export declare const formatButtonActive: string;
|
|
14
|
+
export declare const inputRow: string;
|
|
15
|
+
export declare const fieldGroup: string;
|
|
16
|
+
export declare const fieldInput: string;
|
|
17
|
+
export declare const fieldLabel: string;
|
|
18
|
+
export declare const backdrop: string;
|
|
19
|
+
export declare const nativeInput: string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ColorPickerProps } from "./ColorPicker.type";
|
|
3
|
+
declare function ColorPickerSwitch(props: ColorPickerProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare const MemoizedColorPicker: React.MemoExoticComponent<typeof ColorPickerSwitch>;
|
|
5
|
+
export { MemoizedColorPicker as ColorPicker };
|
|
6
|
+
export type { ColorPickerProps };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
import { rgbToHex, hslToRgb } from '../utils/colorUtils.js';
|
|
6
|
+
import { truncate } from './ColorPicker.utils.js';
|
|
7
|
+
import { useColorWheel } from './useColorWheel.js';
|
|
8
|
+
import { useColorPanel } from './useColorPanel.js';
|
|
9
|
+
import { isTouchDevice } from './ColorPicker.constants.js';
|
|
10
|
+
import { NativeColorPicker } from './NativeColorPicker.js';
|
|
11
|
+
import { trigger, swatch, backdrop, panel, canvasWrap, alphaSection, alphaLabel, alphaTrack, alphaGradient, alphaThumb, formatRow, formatButton, formatButtonActive, inputRow, fieldGroup, fieldInput, fieldLabel, wrapper } from './ColorPicker.styles.js';
|
|
12
|
+
|
|
13
|
+
function ColorPicker({ value, onChange, showAlpha = false, align = "right", className }) {
|
|
14
|
+
const { hsla, format, setFormat, displayValue, swatchColor, canvasRef, alphaTrackRef, drawWheel, handlePointerDown, handlePointerMove, handlePointerUp, handleAlphaPointerDown, handleAlphaPointerMove, handleFieldChange, handleHexInput } = useColorWheel(value, onChange, showAlpha);
|
|
15
|
+
const { open, setOpen, panelPos, wrapperRef, toggleOpen } = useColorPanel(align);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (open)
|
|
18
|
+
drawWheel();
|
|
19
|
+
}, [open, drawWheel]);
|
|
20
|
+
return (jsxs("div", { className: clsx(wrapper, className), ref: wrapperRef, children: [jsxs("button", { type: "button", className: trigger, onClick: toggleOpen, children: [jsx("span", { className: swatch, style: { background: swatchColor } }), jsx("span", { children: truncate(displayValue, 22) })] }), open &&
|
|
21
|
+
createPortal(jsxs(Fragment, { children: [jsx("div", { className: backdrop, onClick: () => setOpen(false), "aria-label": "Close color picker" }), jsxs("div", { className: panel, style: panelPos
|
|
22
|
+
? { top: panelPos.top, left: panelPos.left }
|
|
23
|
+
: undefined, role: "dialog", "aria-label": "Color picker", children: [jsx("div", { className: canvasWrap, children: jsx("canvas", { ref: canvasRef, onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, onPointerUp: handlePointerUp }) }), showAlpha && (jsxs("div", { className: alphaSection, children: [jsxs("span", { className: alphaLabel, children: ["Alpha: ", Math.round(hsla.a * 100), "%"] }), jsxs("div", { ref: alphaTrackRef, className: alphaTrack, onPointerDown: handleAlphaPointerDown, onPointerMove: handleAlphaPointerMove, onPointerUp: handlePointerUp, children: [jsx("div", { className: alphaGradient, style: {
|
|
24
|
+
background: `linear-gradient(to right, transparent, ${rgbToHex(...hslToRgb(hsla.h, hsla.s, hsla.l))})`
|
|
25
|
+
} }), jsx("div", { className: alphaThumb, style: { left: `${hsla.a * 100}%` } })] })] })), jsx("div", { className: formatRow, children: ["hex", "rgba", "hsla"].map(f => (jsx("button", { type: "button", className: clsx(formatButton, format === f && formatButtonActive), onClick: () => setFormat(f), children: f.toUpperCase() }, f))) }), format === "hex" && (jsx("div", { className: inputRow, children: jsxs("div", { className: fieldGroup, children: [jsx("input", { className: fieldInput, value: rgbToHex(...hslToRgb(hsla.h, hsla.s, hsla.l)), onChange: e => handleHexInput(e.target.value) }), jsx("span", { className: fieldLabel, children: "HEX" })] }) })), format === "rgba" &&
|
|
26
|
+
(() => {
|
|
27
|
+
const [r, g, b] = hslToRgb(hsla.h, hsla.s, hsla.l);
|
|
28
|
+
const fields = [
|
|
29
|
+
{ label: "R", field: "r", value: r, max: 255 },
|
|
30
|
+
{ label: "G", field: "g", value: g, max: 255 },
|
|
31
|
+
{ label: "B", field: "b", value: b, max: 255 },
|
|
32
|
+
...(showAlpha
|
|
33
|
+
? [{ label: "A", field: "a", value: hsla.a, max: 1 }]
|
|
34
|
+
: [])
|
|
35
|
+
];
|
|
36
|
+
return (jsx("div", { className: inputRow, children: fields.map(({ label, field, value: v }) => (jsxs("div", { className: fieldGroup, children: [jsx("input", { className: fieldInput, type: "number", step: field === "a" ? 0.01 : 1, value: v, onChange: e => handleFieldChange(field, e.target.value) }), jsx("span", { className: fieldLabel, children: label })] }, field))) }));
|
|
37
|
+
})(), format === "hsla" &&
|
|
38
|
+
(() => {
|
|
39
|
+
const fields = [
|
|
40
|
+
{ label: "H", field: "h", value: hsla.h },
|
|
41
|
+
{ label: "S", field: "s", value: hsla.s },
|
|
42
|
+
{ label: "L", field: "l", value: hsla.l },
|
|
43
|
+
...(showAlpha
|
|
44
|
+
? [{ label: "A", field: "a", value: hsla.a }]
|
|
45
|
+
: [])
|
|
46
|
+
];
|
|
47
|
+
return (jsx("div", { className: inputRow, children: fields.map(({ label, field, value: v }) => (jsxs("div", { className: fieldGroup, children: [jsx("input", { className: fieldInput, type: "number", step: field === "a" ? 0.01 : 1, value: v, onChange: e => handleFieldChange(field, e.target.value) }), jsx("span", { className: fieldLabel, children: label })] }, field))) }));
|
|
48
|
+
})()] })] }), document.body)] }));
|
|
49
|
+
}
|
|
50
|
+
function ColorPickerSwitch(props) {
|
|
51
|
+
return isTouchDevice ? (jsx(NativeColorPicker, { value: props.value, onChange: props.onChange, className: props.className })) : (jsx(ColorPicker, { ...props }));
|
|
52
|
+
}
|
|
53
|
+
const MemoizedColorPicker = React.memo(ColorPickerSwitch);
|
|
54
|
+
|
|
55
|
+
export { MemoizedColorPicker as ColorPicker };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import './../styles/tokens.css';
|
|
2
|
+
import './../styles/ColorPicker/ColorPicker.css';
|
|
3
|
+
|
|
4
|
+
var alphaGradient = 'ColorPicker_alphaGradient__1m4hgd48';
|
|
5
|
+
var alphaLabel = 'ColorPicker_alphaLabel__1m4hgd46';
|
|
6
|
+
var alphaSection = 'ColorPicker_alphaSection__1m4hgd45';
|
|
7
|
+
var alphaThumb = 'ColorPicker_alphaThumb__1m4hgd49';
|
|
8
|
+
var alphaTrack = 'ColorPicker_alphaTrack__1m4hgd47';
|
|
9
|
+
var backdrop = 'ColorPicker_backdrop__1m4hgd4h';
|
|
10
|
+
var canvasWrap = 'ColorPicker_canvasWrap__1m4hgd44';
|
|
11
|
+
var fieldGroup = 'ColorPicker_fieldGroup__1m4hgd4e';
|
|
12
|
+
var fieldInput = 'ColorPicker_fieldInput__1m4hgd4f';
|
|
13
|
+
var fieldLabel = 'ColorPicker_fieldLabel__1m4hgd4g';
|
|
14
|
+
var formatButton = 'ColorPicker_formatButton__1m4hgd4b';
|
|
15
|
+
var formatButtonActive = 'ColorPicker_formatButtonActive__1m4hgd4c';
|
|
16
|
+
var formatRow = 'ColorPicker_formatRow__1m4hgd4a';
|
|
17
|
+
var inputRow = 'ColorPicker_inputRow__1m4hgd4d';
|
|
18
|
+
var nativeInput = 'ColorPicker_nativeInput__1m4hgd4i';
|
|
19
|
+
var panel = 'ColorPicker_panel__1m4hgd43';
|
|
20
|
+
var swatch = 'ColorPicker_swatch__1m4hgd42';
|
|
21
|
+
var trigger = 'ColorPicker_trigger__1m4hgd41';
|
|
22
|
+
var wrapper = 'ColorPicker_wrapper__1m4hgd40';
|
|
23
|
+
|
|
24
|
+
export { alphaGradient, alphaLabel, alphaSection, alphaThumb, alphaTrack, backdrop, canvasWrap, fieldGroup, fieldInput, fieldLabel, formatButton, formatButtonActive, formatRow, inputRow, nativeInput, panel, swatch, trigger, wrapper };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Point, ColorFormat } from "../utils/colorUtils";
|
|
2
|
+
export declare function drawTriangle(ctx: CanvasRenderingContext2D, v0: Point, v1: Point, v2: Point, hue: number): void;
|
|
3
|
+
export declare function drawIndicator(ctx: CanvasRenderingContext2D, x: number, y: number, r: number, color: string): void;
|
|
4
|
+
export declare function detectFormat(value: string): ColorFormat;
|
|
5
|
+
export declare function clamp(v: number, min: number, max: number): number;
|
|
6
|
+
export declare function truncate(s: string, max: number): string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
function drawTriangle(ctx, v0, v1, v2, hue) {
|
|
2
|
+
ctx.save();
|
|
3
|
+
ctx.beginPath();
|
|
4
|
+
ctx.moveTo(v0.x, v0.y);
|
|
5
|
+
ctx.lineTo(v1.x, v1.y);
|
|
6
|
+
ctx.lineTo(v2.x, v2.y);
|
|
7
|
+
ctx.closePath();
|
|
8
|
+
ctx.clip();
|
|
9
|
+
ctx.fillStyle = "#fff";
|
|
10
|
+
ctx.fill();
|
|
11
|
+
const grad1 = ctx.createLinearGradient(v0.x, v0.y, (v1.x + v2.x) / 2, (v1.y + v2.y) / 2);
|
|
12
|
+
grad1.addColorStop(0, `hsl(${hue}, 100%, 50%)`);
|
|
13
|
+
grad1.addColorStop(1, "rgba(255,255,255,0)");
|
|
14
|
+
ctx.fillStyle = grad1;
|
|
15
|
+
ctx.fill();
|
|
16
|
+
const grad2 = ctx.createLinearGradient(v2.x, v2.y, (v0.x + v1.x) / 2, (v0.y + v1.y) / 2);
|
|
17
|
+
grad2.addColorStop(0, "rgba(0,0,0,1)");
|
|
18
|
+
grad2.addColorStop(1, "rgba(0,0,0,0)");
|
|
19
|
+
ctx.fillStyle = grad2;
|
|
20
|
+
ctx.fill();
|
|
21
|
+
ctx.restore();
|
|
22
|
+
}
|
|
23
|
+
function drawIndicator(ctx, x, y, r, color) {
|
|
24
|
+
ctx.beginPath();
|
|
25
|
+
ctx.arc(x, y, r, 0, Math.PI * 2);
|
|
26
|
+
ctx.fillStyle = color;
|
|
27
|
+
ctx.fill();
|
|
28
|
+
ctx.strokeStyle = "#fff";
|
|
29
|
+
ctx.lineWidth = 2;
|
|
30
|
+
ctx.stroke();
|
|
31
|
+
ctx.strokeStyle = "rgba(0,0,0,0.3)";
|
|
32
|
+
ctx.lineWidth = 1;
|
|
33
|
+
ctx.stroke();
|
|
34
|
+
}
|
|
35
|
+
function detectFormat(value) {
|
|
36
|
+
if (value.match(/^rgba?\(/))
|
|
37
|
+
return "rgba";
|
|
38
|
+
if (value.match(/^hsla?\(/))
|
|
39
|
+
return "hsla";
|
|
40
|
+
return "hex";
|
|
41
|
+
}
|
|
42
|
+
function clamp(v, min, max) {
|
|
43
|
+
return Math.max(min, Math.min(max, v));
|
|
44
|
+
}
|
|
45
|
+
function truncate(s, max) {
|
|
46
|
+
return s.length > max ? s.slice(0, max) + "…" : s;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { clamp, detectFormat, drawIndicator, drawTriangle, truncate };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import { parseColor, rgbToHex, hslToRgb } from '../utils/colorUtils.js';
|
|
4
|
+
import { truncate } from './ColorPicker.utils.js';
|
|
5
|
+
import { trigger, swatch, nativeInput, wrapper } from './ColorPicker.styles.js';
|
|
6
|
+
|
|
7
|
+
function NativeColorPicker({ value, onChange, className }) {
|
|
8
|
+
const hsla = parseColor(value);
|
|
9
|
+
const hex = rgbToHex(...hslToRgb(hsla.h, hsla.s, hsla.l));
|
|
10
|
+
return (jsx("div", { className: clsx(wrapper, className), children: jsxs("label", { className: trigger, children: [jsx("span", { className: swatch, style: { background: hex } }), jsx("span", { children: truncate(value, 22) }), jsx("input", { type: "color", value: hex, onChange: e => onChange(e.target.value), className: nativeInput })] }) }));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { NativeColorPicker };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ColorPicker, type ColorPickerProps } from "./ColorPicker";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ColorPicker } from './ColorPicker.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ColorPickerProps } from "./ColorPicker.type";
|
|
2
|
+
export declare function useColorPanel(align?: ColorPickerProps["align"]): {
|
|
3
|
+
open: boolean;
|
|
4
|
+
setOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
5
|
+
panelPos: {
|
|
6
|
+
top: number;
|
|
7
|
+
left: number;
|
|
8
|
+
} | null;
|
|
9
|
+
wrapperRef: import("react").RefObject<HTMLDivElement | null>;
|
|
10
|
+
toggleOpen: () => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useState, useRef, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
function useColorPanel(align = "right") {
|
|
4
|
+
const [open, setOpen] = useState(false);
|
|
5
|
+
const [panelPos, setPanelPos] = useState(null);
|
|
6
|
+
const wrapperRef = useRef(null);
|
|
7
|
+
const toggleOpen = () => {
|
|
8
|
+
if (!open) {
|
|
9
|
+
const rect = wrapperRef.current?.getBoundingClientRect();
|
|
10
|
+
if (rect) {
|
|
11
|
+
const panelW = 240;
|
|
12
|
+
const panelH = 340;
|
|
13
|
+
const flipUp = rect.bottom + panelH > window.innerHeight;
|
|
14
|
+
const top = flipUp ? rect.top - panelH - 4 : rect.bottom + 4;
|
|
15
|
+
let left = align === "left" ? rect.left : rect.right - panelW;
|
|
16
|
+
// clamp to viewport
|
|
17
|
+
left = Math.max(4, Math.min(left, window.innerWidth - panelW - 4));
|
|
18
|
+
setPanelPos({ top, left });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
setOpen(!open);
|
|
22
|
+
};
|
|
23
|
+
// Close on Escape
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!open)
|
|
26
|
+
return;
|
|
27
|
+
const handleKeyDown = (e) => {
|
|
28
|
+
if (e.key === "Escape") {
|
|
29
|
+
setOpen(false);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
33
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
34
|
+
}, [open]);
|
|
35
|
+
return { open, setOpen, panelPos, wrapperRef, toggleOpen };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { useColorPanel };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type HSLA, type ColorFormat } from "../utils/colorUtils";
|
|
2
|
+
export declare function useColorWheel(value: string, onChange: (color: string) => void, showAlpha: boolean): {
|
|
3
|
+
hsla: HSLA;
|
|
4
|
+
format: ColorFormat;
|
|
5
|
+
setFormat: import("react").Dispatch<import("react").SetStateAction<ColorFormat>>;
|
|
6
|
+
displayValue: string;
|
|
7
|
+
swatchColor: string;
|
|
8
|
+
canvasRef: import("react").RefObject<HTMLCanvasElement | null>;
|
|
9
|
+
alphaTrackRef: import("react").RefObject<HTMLDivElement | null>;
|
|
10
|
+
drawWheel: () => void;
|
|
11
|
+
handlePointerDown: (e: React.PointerEvent<HTMLCanvasElement>) => void;
|
|
12
|
+
handlePointerMove: (e: React.PointerEvent<HTMLCanvasElement>) => void;
|
|
13
|
+
handlePointerUp: () => void;
|
|
14
|
+
handleAlphaPointerDown: (e: React.PointerEvent<HTMLDivElement>) => void;
|
|
15
|
+
handleAlphaPointerMove: (e: React.PointerEvent<HTMLDivElement>) => void;
|
|
16
|
+
handleFieldChange: (field: string, raw: string) => void;
|
|
17
|
+
handleHexInput: (raw: string) => void;
|
|
18
|
+
};
|