@hellboy/ds 0.1.3 → 0.2.7
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/README.md +512 -162
- package/{src/style/components/badge → dist/components}/badge.css +9 -25
- package/dist/components/badge.d.mts +12 -0
- package/dist/components/badge.d.ts +12 -0
- package/dist/components/badge.js +42 -0
- package/dist/components/badge.mjs +15 -0
- package/dist/components/banner.css +280 -0
- package/dist/components/banner.d.mts +12 -0
- package/dist/components/banner.d.ts +12 -0
- package/dist/components/banner.js +184 -0
- package/dist/components/banner.mjs +147 -0
- package/dist/components/button-group.css +289 -0
- package/dist/components/button-group.d.mts +81 -0
- package/dist/components/button-group.d.ts +81 -0
- package/dist/components/button-group.js +180 -0
- package/dist/components/button-group.mjs +143 -0
- package/{src/style/components/button → dist/components}/button.css +59 -62
- package/dist/components/button.d.mts +57 -0
- package/dist/components/button.d.ts +57 -0
- package/dist/components/button.js +129 -0
- package/dist/components/button.mjs +92 -0
- package/{src/style/components/card → dist/components}/card.css +9 -30
- package/dist/components/card.d.mts +31 -0
- package/dist/components/card.d.ts +31 -0
- package/dist/components/card.js +59 -0
- package/dist/components/card.mjs +32 -0
- package/{src/style → dist}/components/checkbox.css +51 -43
- package/dist/components/checkbox.d.mts +31 -0
- package/dist/components/checkbox.d.ts +31 -0
- package/dist/components/checkbox.js +130 -0
- package/dist/components/checkbox.mjs +93 -0
- package/{src/style/components/code-block → dist/components}/code-block.css +3 -7
- package/dist/components/code-block.d.mts +24 -0
- package/dist/components/code-block.d.ts +24 -0
- package/dist/components/code-block.js +43 -0
- package/dist/components/code-block.mjs +16 -0
- package/dist/components/color-control.css +285 -0
- package/dist/components/color-control.d.mts +5 -0
- package/dist/components/color-control.d.ts +5 -0
- package/dist/components/color-control.js +534 -0
- package/dist/components/color-control.mjs +497 -0
- package/dist/components/dialog.css +930 -0
- package/dist/components/dialog.d.mts +32 -0
- package/dist/components/dialog.d.ts +32 -0
- package/dist/components/dialog.js +1111 -0
- package/dist/components/dialog.mjs +1074 -0
- package/dist/components/divider.css +356 -0
- package/dist/components/divider.d.mts +32 -0
- package/dist/components/divider.d.ts +32 -0
- package/dist/components/divider.js +344 -0
- package/dist/components/divider.mjs +307 -0
- package/{src/style/components/drag-handle → dist/components}/drag-handle.css +3 -18
- package/dist/components/drag-handle.d.mts +11 -0
- package/dist/components/drag-handle.d.ts +11 -0
- package/dist/components/drag-handle.js +103 -0
- package/dist/components/drag-handle.mjs +66 -0
- package/dist/components/drawer.css +1027 -0
- package/dist/components/drawer.d.mts +14 -0
- package/dist/components/drawer.d.ts +14 -0
- package/dist/components/drawer.js +1072 -0
- package/dist/components/drawer.mjs +1035 -0
- package/dist/components/floating-bar.css +17 -0
- package/dist/components/floating-bar.d.mts +25 -0
- package/dist/components/floating-bar.d.ts +25 -0
- package/dist/components/floating-bar.js +52 -0
- package/dist/components/floating-bar.mjs +25 -0
- package/dist/components/footer.css +40 -0
- package/dist/components/footer.d.mts +8 -0
- package/dist/components/footer.d.ts +8 -0
- package/dist/components/footer.js +44 -0
- package/dist/components/footer.mjs +17 -0
- package/dist/components/grid.css +47 -0
- package/dist/components/grid.d.mts +27 -0
- package/dist/components/grid.d.ts +27 -0
- package/dist/components/grid.js +52 -0
- package/dist/components/grid.mjs +25 -0
- package/dist/components/header.css +1075 -0
- package/dist/components/header.d.mts +35 -0
- package/dist/components/header.d.ts +35 -0
- package/dist/components/header.js +1402 -0
- package/dist/components/header.mjs +1365 -0
- package/dist/components/hero.css +121 -0
- package/dist/components/hero.d.mts +111 -0
- package/dist/components/hero.d.ts +111 -0
- package/dist/components/hero.js +285 -0
- package/dist/components/hero.mjs +248 -0
- package/{src/style/components/icons → dist/components}/icons.css +14 -15
- package/dist/components/icons.d.mts +104 -0
- package/dist/components/icons.d.ts +104 -0
- package/dist/components/icons.js +239 -0
- package/dist/components/icons.mjs +203 -0
- package/{src/style/components/input → dist/components}/input.css +189 -102
- package/dist/components/input.d.mts +114 -0
- package/dist/components/input.d.ts +114 -0
- package/dist/components/input.js +926 -0
- package/dist/components/input.mjs +879 -0
- package/dist/components/layout.css +551 -0
- package/dist/components/layout.d.mts +16 -0
- package/dist/components/layout.d.ts +16 -0
- package/dist/components/layout.js +387 -0
- package/dist/components/layout.mjs +352 -0
- package/{src/style/components/list → dist/components}/list.css +47 -41
- package/dist/components/list.d.mts +46 -0
- package/dist/components/list.d.ts +46 -0
- package/dist/components/list.js +124 -0
- package/dist/components/list.mjs +96 -0
- package/dist/components/navbar.css +706 -0
- package/dist/components/navbar.d.mts +56 -0
- package/dist/components/navbar.d.ts +56 -0
- package/dist/components/navbar.js +994 -0
- package/dist/components/navbar.mjs +952 -0
- package/{src/style/components/page-index → dist/components}/page-index.css +2 -47
- package/dist/components/page-index.d.mts +25 -0
- package/dist/components/page-index.d.ts +25 -0
- package/dist/components/page-index.js +239 -0
- package/dist/components/page-index.mjs +202 -0
- package/{src/style/components/page → dist/components}/page.css +4 -15
- package/dist/components/page.d.mts +30 -0
- package/dist/components/page.d.ts +30 -0
- package/dist/components/page.js +40 -0
- package/dist/components/page.mjs +13 -0
- package/dist/components/popover.css +87 -0
- package/dist/components/popover.d.mts +22 -0
- package/dist/components/popover.d.ts +22 -0
- package/dist/components/popover.js +243 -0
- package/dist/components/popover.mjs +206 -0
- package/{src/style → dist}/components/radio.css +8 -51
- package/dist/components/radio.d.mts +59 -0
- package/dist/components/radio.d.ts +59 -0
- package/dist/components/radio.js +133 -0
- package/dist/components/radio.mjs +95 -0
- package/dist/components/section.css +993 -0
- package/dist/components/section.d.mts +33 -0
- package/dist/components/section.d.ts +33 -0
- package/dist/components/section.js +1401 -0
- package/dist/components/section.mjs +1364 -0
- package/dist/components/select.css +391 -0
- package/dist/components/select.d.mts +63 -0
- package/dist/components/select.d.ts +63 -0
- package/dist/components/select.js +452 -0
- package/dist/components/select.mjs +415 -0
- package/{src/style/components/slider → dist/components}/slider.css +55 -33
- package/dist/components/slider.d.mts +69 -0
- package/dist/components/slider.d.ts +69 -0
- package/dist/components/slider.js +254 -0
- package/dist/components/slider.mjs +217 -0
- package/dist/components/switch.css +1081 -0
- package/dist/components/switch.d.mts +33 -0
- package/dist/components/switch.d.ts +33 -0
- package/dist/components/switch.js +1092 -0
- package/dist/components/switch.mjs +1055 -0
- package/{src/style/components/table → dist/components}/table.css +3 -28
- package/dist/components/table.d.mts +42 -0
- package/dist/components/table.d.ts +42 -0
- package/dist/components/table.js +108 -0
- package/dist/components/table.mjs +76 -0
- package/dist/components/tag.css +97 -0
- package/dist/components/tag.d.mts +12 -0
- package/dist/components/tag.d.ts +12 -0
- package/dist/components/tag.js +42 -0
- package/dist/components/tag.mjs +15 -0
- package/dist/components/textarea.css +1359 -0
- package/dist/components/textarea.d.mts +84 -0
- package/dist/components/textarea.d.ts +84 -0
- package/dist/components/textarea.js +1962 -0
- package/dist/components/textarea.mjs +1924 -0
- package/{src/style/components/theme-control → dist/components}/theme-control.css +3 -7
- package/dist/components/theme-control.d.mts +9 -0
- package/dist/components/theme-control.d.ts +9 -0
- package/dist/components/theme-control.js +235 -0
- package/dist/components/theme-control.mjs +200 -0
- package/{src/style/components/tooltip → dist/components}/tooltip.css +5 -13
- package/dist/components/tooltip.d.mts +12 -0
- package/dist/components/tooltip.d.ts +12 -0
- package/dist/components/tooltip.js +200 -0
- package/dist/components/tooltip.mjs +163 -0
- package/dist/icons-Czahnf-r.d.mts +15 -0
- package/dist/icons-Czahnf-r.d.ts +15 -0
- package/dist/index.css +2914 -2067
- package/dist/index.d.mts +144 -721
- package/dist/index.d.ts +144 -721
- package/dist/index.js +4076 -2282
- package/dist/index.mjs +4132 -2366
- package/dist/theme.css +34 -34
- package/package.json +27 -8
- package/dist/index.css.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/hellboy-ds-0.1.2.tgz +0 -0
- package/src/components/badge/Badge.tsx +0 -29
- package/src/components/badge/index.ts +0 -1
- package/src/components/banner/Banner.tsx +0 -48
- package/src/components/banner/banner.css +0 -44
- package/src/components/banner/index.ts +0 -1
- package/src/components/button/button.tsx +0 -127
- package/src/components/button/index.ts +0 -1
- package/src/components/card/card.tsx +0 -57
- package/src/components/card/index.ts +0 -1
- package/src/components/checkbox/Checkbox.tsx +0 -98
- package/src/components/checkbox/index.ts +0 -1
- package/src/components/code-block/code-block.tsx +0 -44
- package/src/components/code-block/index.ts +0 -1
- package/src/components/color-control/color-control.tsx +0 -322
- package/src/components/color-control/index.ts +0 -1
- package/src/components/drag-handle/DragHandle.tsx +0 -78
- package/src/components/drag-handle/index.ts +0 -1
- package/src/components/drawer/drawer.tsx +0 -82
- package/src/components/drawer/index.ts +0 -1
- package/src/components/floating-bar/floating-bar.tsx +0 -52
- package/src/components/floating-bar/index.ts +0 -2
- package/src/components/footer/footer.tsx +0 -28
- package/src/components/footer/index.ts +0 -1
- package/src/components/grid/Grid.tsx +0 -53
- package/src/components/grid/index.ts +0 -1
- package/src/components/header/header.tsx +0 -57
- package/src/components/header/index.ts +0 -1
- package/src/components/icons/icons.tsx +0 -44
- package/src/components/icons/index.ts +0 -1
- package/src/components/index.ts +0 -29
- package/src/components/input/DatePicker.tsx +0 -133
- package/src/components/input/Input.tsx +0 -220
- package/src/components/input/InputDate.tsx +0 -10
- package/src/components/input/InputDateTime.tsx +0 -10
- package/src/components/input/InputEmail.tsx +0 -10
- package/src/components/input/InputField.tsx +0 -137
- package/src/components/input/InputNumber.tsx +0 -10
- package/src/components/input/InputPassword.tsx +0 -10
- package/src/components/input/InputSearch.tsx +0 -10
- package/src/components/input/InputTel.tsx +0 -10
- package/src/components/input/InputText.tsx +0 -10
- package/src/components/input/InputTime.tsx +0 -10
- package/src/components/input/InputUrl.tsx +0 -10
- package/src/components/input/TimePicker.tsx +0 -151
- package/src/components/input/index.ts +0 -11
- package/src/components/layout/Layout.tsx +0 -244
- package/src/components/layout/index.ts +0 -1
- package/src/components/list/List.tsx +0 -159
- package/src/components/list/index.ts +0 -1
- package/src/components/navbar/MenuCategory.tsx +0 -20
- package/src/components/navbar/MenuGroup.tsx +0 -288
- package/src/components/navbar/MenuItem.tsx +0 -65
- package/src/components/navbar/Navbar.tsx +0 -23
- package/src/components/navbar/index.ts +0 -4
- package/src/components/page/index.ts +0 -1
- package/src/components/page/page.tsx +0 -46
- package/src/components/page-index/PageIndex.tsx +0 -275
- package/src/components/page-index/index.ts +0 -1
- package/src/components/popover/index.ts +0 -1
- package/src/components/popover/popover.tsx +0 -199
- package/src/components/radio/Radio.tsx +0 -176
- package/src/components/radio/index.ts +0 -1
- package/src/components/section/index.ts +0 -1
- package/src/components/section/section.tsx +0 -66
- package/src/components/select/Select.tsx +0 -212
- package/src/components/select/index.ts +0 -1
- package/src/components/slider/Slider.tsx +0 -267
- package/src/components/slider/index.ts +0 -1
- package/src/components/switch/index.ts +0 -1
- package/src/components/switch/switch.tsx +0 -99
- package/src/components/table/Table.tsx +0 -147
- package/src/components/table/index.ts +0 -1
- package/src/components/theme-control/index.ts +0 -1
- package/src/components/theme-control/theme-control.tsx +0 -78
- package/src/components/tooltip/index.ts +0 -1
- package/src/components/tooltip/tooltip.tsx +0 -207
- package/src/contexts/NavbarTooltipContext.tsx +0 -48
- package/src/contexts/index.ts +0 -1
- package/src/foundations/motion.md +0 -136
- package/src/index.ts +0 -40
- package/src/style/_shared/field.css +0 -69
- package/src/style/components/color-control/color-control.css +0 -126
- package/src/style/components/drawer/drawer.css +0 -210
- package/src/style/components/floating-bar/floating-bar.css +0 -39
- package/src/style/components/footer/footer.css +0 -108
- package/src/style/components/grid/grid.css +0 -33
- package/src/style/components/header/header.css +0 -44
- package/src/style/components/layout/layout.css +0 -205
- package/src/style/components/navbar/navbar.css +0 -342
- package/src/style/components/popover/popover.css +0 -44
- package/src/style/components/section/section.css +0 -67
- package/src/style/components/select/select.css +0 -143
- package/src/style/components/switch/switch.css +0 -267
- package/src/style/foundations/global.css +0 -316
- package/src/style/foundations/motion.css +0 -164
- package/src/style/foundations/spacing.css +0 -51
- package/src/style/foundations/typography.css +0 -39
- package/src/style/foundations/z-index.css +0 -81
- package/src/style/modes/dark.css +0 -146
- package/src/style/modes/light.css +0 -147
- package/src/style/semantic.css +0 -52
- package/src/style/styles.css +0 -51
- package/src/style/themes/theme.json +0 -37
- package/src/utils/README.md +0 -305
- package/src/utils/USER_PREFERENCES.md +0 -558
- package/src/utils/theme.ts +0 -127
- package/src/utils/user-preferences.ts +0 -577
- package/tsconfig.json +0 -25
- package/tsup.config.ts +0 -52
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode, useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
export type SectionSize = 'sm' | 'md' | 'lg';
|
|
4
|
-
|
|
5
|
-
export interface SectionProps {
|
|
6
|
-
/**
|
|
7
|
-
* Section title
|
|
8
|
-
*/
|
|
9
|
-
title?: ReactNode;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Section content
|
|
13
|
-
*/
|
|
14
|
-
children: ReactNode;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Section size/padding
|
|
18
|
-
* @default 'md'
|
|
19
|
-
*/
|
|
20
|
-
size?: SectionSize;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Custom class name
|
|
24
|
-
*/
|
|
25
|
-
className?: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Section component for content areas
|
|
30
|
-
* Provides consistent spacing and styling for content sections
|
|
31
|
-
*/
|
|
32
|
-
export const Section: React.FC<SectionProps> = ({ title, children, size = 'md', className }) => {
|
|
33
|
-
const sectionClasses = [
|
|
34
|
-
'section',
|
|
35
|
-
size !== 'md' && `section--${size}`,
|
|
36
|
-
className,
|
|
37
|
-
]
|
|
38
|
-
.filter(Boolean)
|
|
39
|
-
.join(' ');
|
|
40
|
-
|
|
41
|
-
// Generate ID from title for page index navigation
|
|
42
|
-
const sectionId = useMemo(() => {
|
|
43
|
-
if (typeof title === 'string' && title.trim()) {
|
|
44
|
-
return title
|
|
45
|
-
.toLowerCase()
|
|
46
|
-
.replace(/[^\w\s-]/g, '') // Remove special characters
|
|
47
|
-
.replace(/\s+/g, '-') // Replace spaces with hyphens
|
|
48
|
-
.replace(/-+/g, '-') // Replace multiple hyphens with single
|
|
49
|
-
.trim();
|
|
50
|
-
}
|
|
51
|
-
return undefined;
|
|
52
|
-
}, [title]);
|
|
53
|
-
|
|
54
|
-
const titleText = typeof title === 'string' ? title : undefined;
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<section
|
|
58
|
-
className={sectionClasses}
|
|
59
|
-
id={sectionId}
|
|
60
|
-
data-section-title={titleText}
|
|
61
|
-
>
|
|
62
|
-
{title && <h2 className="section__title">{title}</h2>}
|
|
63
|
-
<div className="section__content">{children}</div>
|
|
64
|
-
</section>
|
|
65
|
-
);
|
|
66
|
-
};
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Icon } from '../icons/icons';
|
|
3
|
-
import { Popover } from '../popover/popover';
|
|
4
|
-
import { List, ListItem } from '../list/List';
|
|
5
|
-
import '../../style/components/select/select.css';
|
|
6
|
-
|
|
7
|
-
export interface SelectOption {
|
|
8
|
-
value: string;
|
|
9
|
-
label: string;
|
|
10
|
-
icon?: string;
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface SelectProps {
|
|
15
|
-
/**
|
|
16
|
-
* Select options
|
|
17
|
-
*/
|
|
18
|
-
options: SelectOption[];
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Current value
|
|
22
|
-
*/
|
|
23
|
-
value?: string;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Change handler
|
|
27
|
-
*/
|
|
28
|
-
onChange?: (value: string) => void;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Label text
|
|
32
|
-
*/
|
|
33
|
-
label?: string;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Placeholder when no value selected
|
|
37
|
-
*/
|
|
38
|
-
placeholder?: string;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Helper text shown below the select
|
|
42
|
-
*/
|
|
43
|
-
helperText?: string;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Error message - when present, select is in error state
|
|
47
|
-
*/
|
|
48
|
-
error?: string;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Whether the select is disabled
|
|
52
|
-
*/
|
|
53
|
-
disabled?: boolean;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Full width select
|
|
57
|
-
* @default false
|
|
58
|
-
*/
|
|
59
|
-
fullWidth?: boolean;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Size variant
|
|
63
|
-
* @default 'md'
|
|
64
|
-
*/
|
|
65
|
-
size?: 'sm' | 'md' | 'lg';
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Custom class name
|
|
69
|
-
*/
|
|
70
|
-
className?: string;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* ID for accessibility
|
|
74
|
-
*/
|
|
75
|
-
id?: string;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export const Select: React.FC<SelectProps> = ({
|
|
79
|
-
options,
|
|
80
|
-
value,
|
|
81
|
-
onChange,
|
|
82
|
-
label,
|
|
83
|
-
placeholder = 'Select an option',
|
|
84
|
-
helperText,
|
|
85
|
-
error,
|
|
86
|
-
disabled = false,
|
|
87
|
-
fullWidth = false,
|
|
88
|
-
size = 'md',
|
|
89
|
-
className = '',
|
|
90
|
-
id,
|
|
91
|
-
}) => {
|
|
92
|
-
const [isOpen, setIsOpen] = React.useState(false);
|
|
93
|
-
const selectId = id || `select-${React.useId()}`;
|
|
94
|
-
|
|
95
|
-
const selectedOption = options.find((opt) => opt.value === value);
|
|
96
|
-
|
|
97
|
-
const handleSelect = (optionValue: string) => {
|
|
98
|
-
onChange?.(optionValue);
|
|
99
|
-
setIsOpen(false);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const handleKeyDown = (e: React.KeyboardEvent) => {
|
|
103
|
-
if (disabled) return;
|
|
104
|
-
|
|
105
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
106
|
-
e.preventDefault();
|
|
107
|
-
setIsOpen(!isOpen);
|
|
108
|
-
} else if (e.key === 'Escape') {
|
|
109
|
-
setIsOpen(false);
|
|
110
|
-
} else if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
111
|
-
e.preventDefault();
|
|
112
|
-
if (!isOpen) {
|
|
113
|
-
setIsOpen(true);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const containerClasses = [
|
|
119
|
-
'select-container',
|
|
120
|
-
fullWidth && 'select-container--full-width',
|
|
121
|
-
className,
|
|
122
|
-
]
|
|
123
|
-
.filter(Boolean)
|
|
124
|
-
.join(' ');
|
|
125
|
-
|
|
126
|
-
const triggerClasses = [
|
|
127
|
-
'select__trigger',
|
|
128
|
-
`select__trigger--${size}`,
|
|
129
|
-
error && 'select__trigger--error',
|
|
130
|
-
disabled && 'select__trigger--disabled',
|
|
131
|
-
isOpen && 'select__trigger--open',
|
|
132
|
-
]
|
|
133
|
-
.filter(Boolean)
|
|
134
|
-
.join(' ');
|
|
135
|
-
|
|
136
|
-
return (
|
|
137
|
-
<div className={containerClasses}>
|
|
138
|
-
{label && (
|
|
139
|
-
<label htmlFor={selectId} className="select__label">
|
|
140
|
-
{label}
|
|
141
|
-
</label>
|
|
142
|
-
)}
|
|
143
|
-
<Popover
|
|
144
|
-
trigger={
|
|
145
|
-
<button
|
|
146
|
-
id={selectId}
|
|
147
|
-
type="button"
|
|
148
|
-
className={triggerClasses}
|
|
149
|
-
onClick={() => !disabled && setIsOpen(!isOpen)}
|
|
150
|
-
onKeyDown={handleKeyDown}
|
|
151
|
-
disabled={disabled}
|
|
152
|
-
aria-haspopup="listbox"
|
|
153
|
-
aria-expanded={isOpen}
|
|
154
|
-
aria-labelledby={label ? `${selectId}-label` : undefined}
|
|
155
|
-
aria-describedby={
|
|
156
|
-
error ? `${selectId}-error` : helperText ? `${selectId}-helper` : undefined
|
|
157
|
-
}
|
|
158
|
-
aria-invalid={error ? 'true' : 'false'}
|
|
159
|
-
>
|
|
160
|
-
<span className="select__trigger-content">
|
|
161
|
-
{selectedOption?.icon && (
|
|
162
|
-
<Icon
|
|
163
|
-
name={selectedOption.icon}
|
|
164
|
-
size={size === 'sm' ? 16 : size === 'lg' ? 24 : 20}
|
|
165
|
-
/>
|
|
166
|
-
)}
|
|
167
|
-
<span className="select__trigger-text">
|
|
168
|
-
{selectedOption ? selectedOption.label : placeholder}
|
|
169
|
-
</span>
|
|
170
|
-
</span>
|
|
171
|
-
<Icon
|
|
172
|
-
name="chevron-down"
|
|
173
|
-
size={size === 'sm' ? 16 : size === 'lg' ? 24 : 20}
|
|
174
|
-
className="select__trigger-icon"
|
|
175
|
-
/>
|
|
176
|
-
</button>
|
|
177
|
-
}
|
|
178
|
-
isOpen={isOpen}
|
|
179
|
-
onToggle={() => !disabled && setIsOpen(!isOpen)}
|
|
180
|
-
placement="bottom"
|
|
181
|
-
>
|
|
182
|
-
<div className="select__dropdown" role="listbox">
|
|
183
|
-
<List>
|
|
184
|
-
{options.map((option) => (
|
|
185
|
-
<ListItem
|
|
186
|
-
key={option.value}
|
|
187
|
-
icon={option.icon}
|
|
188
|
-
selected={option.value === value}
|
|
189
|
-
disabled={option.disabled}
|
|
190
|
-
onClick={() => !option.disabled && handleSelect(option.value)}
|
|
191
|
-
role="option"
|
|
192
|
-
aria-selected={option.value === value}
|
|
193
|
-
>
|
|
194
|
-
{option.label}
|
|
195
|
-
</ListItem>
|
|
196
|
-
))}
|
|
197
|
-
</List>
|
|
198
|
-
</div>
|
|
199
|
-
</Popover>
|
|
200
|
-
{error && (
|
|
201
|
-
<p id={`${selectId}-error`} className="select__message select__message--error">
|
|
202
|
-
{error}
|
|
203
|
-
</p>
|
|
204
|
-
)}
|
|
205
|
-
{helperText && !error && (
|
|
206
|
-
<p id={`${selectId}-helper`} className="select__message">
|
|
207
|
-
{helperText}
|
|
208
|
-
</p>
|
|
209
|
-
)}
|
|
210
|
-
</div>
|
|
211
|
-
);
|
|
212
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Select, type SelectProps, type SelectOption } from './Select';
|
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import React, { useState, useCallback, useRef } from 'react';
|
|
2
|
-
import { Icon } from '../icons/icons';
|
|
3
|
-
import '../../style/components/slider/slider.css';
|
|
4
|
-
|
|
5
|
-
export interface SliderProps {
|
|
6
|
-
/**
|
|
7
|
-
* Minimum value
|
|
8
|
-
* @default 0
|
|
9
|
-
*/
|
|
10
|
-
min?: number;
|
|
11
|
-
/**
|
|
12
|
-
* Maximum value
|
|
13
|
-
* @default 100
|
|
14
|
-
*/
|
|
15
|
-
max?: number;
|
|
16
|
-
/**
|
|
17
|
-
* Current value
|
|
18
|
-
*/
|
|
19
|
-
value: number;
|
|
20
|
-
/**
|
|
21
|
-
* Step increment
|
|
22
|
-
* @default 1
|
|
23
|
-
*/
|
|
24
|
-
step?: number;
|
|
25
|
-
/**
|
|
26
|
-
* Callback when value changes
|
|
27
|
-
*/
|
|
28
|
-
onChange: (value: number) => void;
|
|
29
|
-
/**
|
|
30
|
-
* Callback when drag starts
|
|
31
|
-
*/
|
|
32
|
-
onDragStart?: () => void;
|
|
33
|
-
/**
|
|
34
|
-
* Callback when drag ends (value committed)
|
|
35
|
-
*/
|
|
36
|
-
onChangeEnd?: (value: number) => void;
|
|
37
|
-
/**
|
|
38
|
-
* Label for the slider
|
|
39
|
-
*/
|
|
40
|
-
label?: string;
|
|
41
|
-
/**
|
|
42
|
-
* Show value display
|
|
43
|
-
* @default true
|
|
44
|
-
*/
|
|
45
|
-
showValue?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Custom class name
|
|
48
|
-
*/
|
|
49
|
-
className?: string;
|
|
50
|
-
/**
|
|
51
|
-
* Disabled state
|
|
52
|
-
* @default false
|
|
53
|
-
*/
|
|
54
|
-
disabled?: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Slider type for different backgrounds
|
|
57
|
-
* @default 'default'
|
|
58
|
-
*/
|
|
59
|
-
type?: 'default' | 'hue' | 'saturation' | 'lightness';
|
|
60
|
-
/**
|
|
61
|
-
* Base color for saturation/lightness gradients (hsl values)
|
|
62
|
-
*/
|
|
63
|
-
baseHue?: number;
|
|
64
|
-
/**
|
|
65
|
-
* Base saturation for lightness gradient (0-100)
|
|
66
|
-
*/
|
|
67
|
-
baseSaturation?: number;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export const Slider: React.FC<SliderProps> = ({
|
|
71
|
-
min = 0,
|
|
72
|
-
max = 100,
|
|
73
|
-
value,
|
|
74
|
-
step = 1,
|
|
75
|
-
onChange,
|
|
76
|
-
onDragStart,
|
|
77
|
-
onChangeEnd,
|
|
78
|
-
label,
|
|
79
|
-
showValue = true,
|
|
80
|
-
className = '',
|
|
81
|
-
disabled = false,
|
|
82
|
-
type = 'default',
|
|
83
|
-
baseHue = 0,
|
|
84
|
-
baseSaturation = 70,
|
|
85
|
-
}) => {
|
|
86
|
-
const [isDragging, setIsDragging] = useState(false);
|
|
87
|
-
const inputRef = useRef<HTMLInputElement>(null);
|
|
88
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
89
|
-
const valueRef = useRef(value);
|
|
90
|
-
|
|
91
|
-
// Keep value ref in sync
|
|
92
|
-
React.useEffect(() => {
|
|
93
|
-
valueRef.current = value;
|
|
94
|
-
}, [value]);
|
|
95
|
-
|
|
96
|
-
const handleChange = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
|
|
97
|
-
const newValue = parseFloat(event.target.value);
|
|
98
|
-
onChange(newValue);
|
|
99
|
-
}, [onChange]);
|
|
100
|
-
|
|
101
|
-
const getValueFromPosition = useCallback((clientX: number) => {
|
|
102
|
-
if (!containerRef.current) return value;
|
|
103
|
-
const rect = containerRef.current.getBoundingClientRect();
|
|
104
|
-
const percentage = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
|
|
105
|
-
const rawValue = min + percentage * (max - min);
|
|
106
|
-
const steppedValue = Math.round(rawValue / step) * step;
|
|
107
|
-
return Math.max(min, Math.min(max, steppedValue));
|
|
108
|
-
}, [min, max, step, value]);
|
|
109
|
-
|
|
110
|
-
const handleMouseDown = useCallback((event: React.MouseEvent) => {
|
|
111
|
-
if (disabled) return;
|
|
112
|
-
event.preventDefault();
|
|
113
|
-
setIsDragging(true);
|
|
114
|
-
onDragStart?.();
|
|
115
|
-
const newValue = getValueFromPosition(event.clientX);
|
|
116
|
-
onChange(newValue);
|
|
117
|
-
}, [disabled, onDragStart, getValueFromPosition, onChange]);
|
|
118
|
-
|
|
119
|
-
const handleMouseMove = useCallback((event: MouseEvent) => {
|
|
120
|
-
if (!isDragging) return;
|
|
121
|
-
event.preventDefault();
|
|
122
|
-
const newValue = getValueFromPosition(event.clientX);
|
|
123
|
-
onChange(newValue);
|
|
124
|
-
}, [isDragging, getValueFromPosition, onChange]);
|
|
125
|
-
|
|
126
|
-
const handleMouseUp = useCallback(() => {
|
|
127
|
-
if (!isDragging) return;
|
|
128
|
-
setIsDragging(false);
|
|
129
|
-
onChangeEnd?.(valueRef.current);
|
|
130
|
-
}, [isDragging, onChangeEnd]);
|
|
131
|
-
|
|
132
|
-
// Add global mouse listeners for dragging
|
|
133
|
-
React.useEffect(() => {
|
|
134
|
-
if (!isDragging) return;
|
|
135
|
-
|
|
136
|
-
document.addEventListener('mousemove', handleMouseMove);
|
|
137
|
-
document.addEventListener('mouseup', handleMouseUp);
|
|
138
|
-
|
|
139
|
-
return () => {
|
|
140
|
-
document.removeEventListener('mousemove', handleMouseMove);
|
|
141
|
-
document.removeEventListener('mouseup', handleMouseUp);
|
|
142
|
-
};
|
|
143
|
-
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
144
|
-
|
|
145
|
-
// Handle touch events
|
|
146
|
-
const handleTouchStart = useCallback((event: React.TouchEvent) => {
|
|
147
|
-
if (disabled) return;
|
|
148
|
-
event.preventDefault();
|
|
149
|
-
setIsDragging(true);
|
|
150
|
-
onDragStart?.();
|
|
151
|
-
const touch = event.touches[0];
|
|
152
|
-
const newValue = getValueFromPosition(touch.clientX);
|
|
153
|
-
onChange(newValue);
|
|
154
|
-
}, [disabled, onDragStart, getValueFromPosition, onChange]);
|
|
155
|
-
|
|
156
|
-
const handleTouchMove = useCallback((event: TouchEvent) => {
|
|
157
|
-
if (!isDragging) return;
|
|
158
|
-
event.preventDefault();
|
|
159
|
-
const touch = event.touches[0];
|
|
160
|
-
const newValue = getValueFromPosition(touch.clientX);
|
|
161
|
-
onChange(newValue);
|
|
162
|
-
}, [isDragging, getValueFromPosition, onChange]);
|
|
163
|
-
|
|
164
|
-
const handleTouchEnd = useCallback(() => {
|
|
165
|
-
if (!isDragging) return;
|
|
166
|
-
setIsDragging(false);
|
|
167
|
-
onChangeEnd?.(valueRef.current);
|
|
168
|
-
}, [isDragging, onChangeEnd]);
|
|
169
|
-
|
|
170
|
-
React.useEffect(() => {
|
|
171
|
-
if (!isDragging) return;
|
|
172
|
-
|
|
173
|
-
document.addEventListener('touchmove', handleTouchMove);
|
|
174
|
-
document.addEventListener('touchend', handleTouchEnd);
|
|
175
|
-
|
|
176
|
-
return () => {
|
|
177
|
-
document.removeEventListener('touchmove', handleTouchMove);
|
|
178
|
-
document.removeEventListener('touchend', handleTouchEnd);
|
|
179
|
-
};
|
|
180
|
-
}, [isDragging, handleTouchMove, handleTouchEnd]);
|
|
181
|
-
|
|
182
|
-
const sliderClasses = [
|
|
183
|
-
'slider',
|
|
184
|
-
`slider--${type}`,
|
|
185
|
-
isDragging && 'slider--dragging',
|
|
186
|
-
disabled && 'slider--disabled',
|
|
187
|
-
className
|
|
188
|
-
].filter(Boolean).join(' ');
|
|
189
|
-
|
|
190
|
-
// Generate background based on type
|
|
191
|
-
const getBackground = () => {
|
|
192
|
-
switch (type) {
|
|
193
|
-
case 'hue':
|
|
194
|
-
return 'linear-gradient(to right, hsl(0, 70%, 50%), hsl(60, 70%, 50%), hsl(120, 70%, 50%), hsl(180, 70%, 50%), hsl(240, 70%, 50%), hsl(300, 70%, 50%), hsl(360, 70%, 50%))';
|
|
195
|
-
case 'saturation':
|
|
196
|
-
return `linear-gradient(to right, hsl(${baseHue}, 0%, 50%), hsl(${baseHue}, 100%, 50%))`;
|
|
197
|
-
case 'lightness':
|
|
198
|
-
return `linear-gradient(to right, hsl(${baseHue}, ${baseSaturation}%, 0%), hsl(${baseHue}, ${baseSaturation}%, 50%), hsl(${baseHue}, ${baseSaturation}%, 100%))`;
|
|
199
|
-
default:
|
|
200
|
-
return 'var(--color-action-primary)';
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
const inputStyle = { background: getBackground() };
|
|
205
|
-
|
|
206
|
-
// Generate step marks
|
|
207
|
-
const stepMarks = step > 1 ? Array.from({ length: Math.floor((max - min) / step) + 1 }, (_, i) => min + i * step) : [];
|
|
208
|
-
|
|
209
|
-
// Calculate thumb position as percentage
|
|
210
|
-
const thumbPosition = ((value - min) / (max - min)) * 100;
|
|
211
|
-
|
|
212
|
-
return (
|
|
213
|
-
<div className={sliderClasses}>
|
|
214
|
-
{(label || showValue) && (
|
|
215
|
-
<div className="slider__header">
|
|
216
|
-
{label && <label className="slider__label">{label}</label>}
|
|
217
|
-
{showValue && (
|
|
218
|
-
<span className="slider__value">{value}</span>
|
|
219
|
-
)}
|
|
220
|
-
</div>
|
|
221
|
-
)}
|
|
222
|
-
|
|
223
|
-
<div className="slider__container" ref={containerRef} onMouseDown={handleMouseDown} onTouchStart={handleTouchStart}>
|
|
224
|
-
<input
|
|
225
|
-
ref={inputRef}
|
|
226
|
-
type="range"
|
|
227
|
-
min={min}
|
|
228
|
-
max={max}
|
|
229
|
-
step={step}
|
|
230
|
-
value={value}
|
|
231
|
-
onChange={handleChange}
|
|
232
|
-
className="slider__input"
|
|
233
|
-
style={inputStyle}
|
|
234
|
-
disabled={disabled}
|
|
235
|
-
readOnly
|
|
236
|
-
/>
|
|
237
|
-
|
|
238
|
-
{/* Custom thumb with icon */}
|
|
239
|
-
<div
|
|
240
|
-
className="slider__thumb"
|
|
241
|
-
style={{
|
|
242
|
-
left: `${thumbPosition}%`,
|
|
243
|
-
transform: 'translateX(-50%)',
|
|
244
|
-
}}
|
|
245
|
-
>
|
|
246
|
-
<div className="slider__thumb-icon">
|
|
247
|
-
<Icon name="arrow-down" size={16} />
|
|
248
|
-
</div>
|
|
249
|
-
</div>
|
|
250
|
-
|
|
251
|
-
{stepMarks.length > 0 && (
|
|
252
|
-
<div className="slider__marks">
|
|
253
|
-
{stepMarks.map((mark) => (
|
|
254
|
-
<div
|
|
255
|
-
key={mark}
|
|
256
|
-
className="slider__mark"
|
|
257
|
-
style={{
|
|
258
|
-
left: `${((mark - min) / (max - min)) * 100}%`,
|
|
259
|
-
}}
|
|
260
|
-
/>
|
|
261
|
-
))}
|
|
262
|
-
</div>
|
|
263
|
-
)}
|
|
264
|
-
</div>
|
|
265
|
-
</div>
|
|
266
|
-
);
|
|
267
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./Slider";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Switch, type SwitchProps, type SwitchSize } from './switch';
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Icon } from '../icons';
|
|
3
|
-
import '../../style/components/switch/switch.css';
|
|
4
|
-
|
|
5
|
-
export type SwitchSize = 'sm' | 'md' | 'lg';
|
|
6
|
-
|
|
7
|
-
export interface SwitchProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'> {
|
|
8
|
-
/**
|
|
9
|
-
* Size of the switch
|
|
10
|
-
* @default 'md'
|
|
11
|
-
*/
|
|
12
|
-
size?: SwitchSize;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Label text for the switch
|
|
16
|
-
*/
|
|
17
|
-
label?: React.ReactNode;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Icon to display when switch is ON
|
|
21
|
-
*/
|
|
22
|
-
onIcon?: string;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Icon to display when switch is OFF
|
|
26
|
-
*/
|
|
27
|
-
offIcon?: string;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Error message to display below the switch
|
|
31
|
-
*/
|
|
32
|
-
error?: string;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Helper text to display below the switch
|
|
36
|
-
*/
|
|
37
|
-
helperText?: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const Switch = React.forwardRef<HTMLInputElement, SwitchProps>(
|
|
41
|
-
(
|
|
42
|
-
{
|
|
43
|
-
size = 'md',
|
|
44
|
-
label,
|
|
45
|
-
onIcon,
|
|
46
|
-
offIcon,
|
|
47
|
-
error,
|
|
48
|
-
helperText,
|
|
49
|
-
disabled = false,
|
|
50
|
-
className,
|
|
51
|
-
checked,
|
|
52
|
-
...props
|
|
53
|
-
},
|
|
54
|
-
ref
|
|
55
|
-
) => {
|
|
56
|
-
const switchClasses = [
|
|
57
|
-
'switch',
|
|
58
|
-
`switch--${size}`,
|
|
59
|
-
checked && 'switch--checked',
|
|
60
|
-
disabled && 'switch--disabled',
|
|
61
|
-
error && 'switch--error',
|
|
62
|
-
className,
|
|
63
|
-
]
|
|
64
|
-
.filter(Boolean)
|
|
65
|
-
.join(' ');
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<div className="switch__wrapper">
|
|
69
|
-
<label className="switch__label">
|
|
70
|
-
<input
|
|
71
|
-
type="checkbox"
|
|
72
|
-
ref={ref}
|
|
73
|
-
checked={checked}
|
|
74
|
-
disabled={disabled}
|
|
75
|
-
className="switch__input"
|
|
76
|
-
{...props}
|
|
77
|
-
/>
|
|
78
|
-
<span className={switchClasses}>
|
|
79
|
-
<span className="switch__track">
|
|
80
|
-
<span className="switch__thumb">
|
|
81
|
-
{onIcon && <Icon name={onIcon} size={16} className="switch__icon switch__icon--on" />}
|
|
82
|
-
{offIcon && <Icon name={offIcon} size={16} className="switch__icon switch__icon--off" />}
|
|
83
|
-
</span>
|
|
84
|
-
</span>
|
|
85
|
-
</span>
|
|
86
|
-
{label && <span className="switch__text">{label}</span>}
|
|
87
|
-
</label>
|
|
88
|
-
{(error || helperText) && (
|
|
89
|
-
<div className="switch__message">
|
|
90
|
-
{error && <span className="switch__error-text">{error}</span>}
|
|
91
|
-
{helperText && !error && <span className="switch__helper-text">{helperText}</span>}
|
|
92
|
-
</div>
|
|
93
|
-
)}
|
|
94
|
-
</div>
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
Switch.displayName = 'Switch';
|