@aws-amplify/ui 6.0.17 → 6.1.0
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/esm/i18n/dictionaries/authenticator/ja.mjs +2 -2
- package/dist/esm/i18n/dictionaries/authenticator/kr.mjs +10 -0
- package/dist/esm/index.mjs +5 -3
- package/dist/esm/theme/createTheme/createAnimationCSS.mjs +23 -0
- package/dist/esm/theme/createTheme/createColorPalette.mjs +21 -0
- package/dist/esm/theme/createTheme/createComponentCSS.mjs +86 -0
- package/dist/esm/theme/createTheme/createComponentClasses.mjs +60 -0
- package/dist/esm/theme/{createTheme.mjs → createTheme/createTheme.mjs} +33 -44
- package/dist/esm/theme/createTheme/defineComponentTheme.mjs +55 -0
- package/dist/esm/theme/createTheme/utils.mjs +236 -0
- package/dist/esm/utils/utils.mjs +21 -1
- package/dist/index.js +431 -37
- package/dist/types/theme/components/accordion.d.ts +4 -0
- package/dist/types/theme/components/alert.d.ts +4 -0
- package/dist/types/theme/components/autocomplete.d.ts +8 -0
- package/dist/types/theme/components/badge.d.ts +4 -0
- package/dist/types/theme/components/breadcrumbs.d.ts +7 -0
- package/dist/types/theme/components/button.d.ts +7 -0
- package/dist/types/theme/components/buttonGroup.d.ts +2 -0
- package/dist/types/theme/components/card.d.ts +2 -0
- package/dist/types/theme/components/checkbox.d.ts +7 -0
- package/dist/types/theme/components/checkboxField.d.ts +2 -0
- package/dist/types/theme/components/collection.d.ts +4 -0
- package/dist/types/theme/components/divider.d.ts +2 -0
- package/dist/types/theme/components/dropZone.d.ts +2 -0
- package/dist/types/theme/components/field.d.ts +6 -0
- package/dist/types/theme/components/fieldGroup.d.ts +11 -0
- package/dist/types/theme/components/fieldset.d.ts +4 -0
- package/dist/types/theme/components/heading.d.ts +4 -0
- package/dist/types/theme/components/highlightMatch.d.ts +4 -0
- package/dist/types/theme/components/index.d.ts +92 -0
- package/dist/types/theme/components/input.d.ts +2 -0
- package/dist/types/theme/components/loader.d.ts +4 -0
- package/dist/types/theme/components/menu.d.ts +4 -0
- package/dist/types/theme/components/message.d.ts +4 -0
- package/dist/types/theme/components/pagination.d.ts +4 -0
- package/dist/types/theme/components/placeholder.d.ts +2 -0
- package/dist/types/theme/components/radio.d.ts +6 -0
- package/dist/types/theme/components/rating.d.ts +5 -0
- package/dist/types/theme/components/scrollview.d.ts +2 -0
- package/dist/types/theme/components/searchField.d.ts +4 -0
- package/dist/types/theme/components/select.d.ts +5 -0
- package/dist/types/theme/components/selectField.d.ts +2 -0
- package/dist/types/theme/components/sliderField.d.ts +9 -0
- package/dist/types/theme/components/stepperField.d.ts +6 -0
- package/dist/types/theme/components/storageManager.d.ts +20 -0
- package/dist/types/theme/components/switchField.d.ts +8 -0
- package/dist/types/theme/components/table.d.ts +4 -0
- package/dist/types/theme/components/tabs.d.ts +6 -0
- package/dist/types/theme/components/text.d.ts +3 -0
- package/dist/types/theme/components/textField.d.ts +2 -0
- package/dist/types/theme/components/textarea.d.ts +2 -0
- package/dist/types/theme/components/textareaField.d.ts +2 -0
- package/dist/types/theme/components/toggleButton.d.ts +3 -0
- package/dist/types/theme/components/utils.d.ts +52 -0
- package/dist/types/theme/createTheme/createAnimationCSS.d.ts +6 -0
- package/dist/types/theme/createTheme/createColorPalette.d.ts +16 -0
- package/dist/types/theme/createTheme/createComponentCSS.d.ts +7 -0
- package/dist/types/theme/createTheme/createComponentClasses.d.ts +25 -0
- package/dist/types/theme/{createTheme.d.ts → createTheme/createTheme.d.ts} +3 -2
- package/dist/types/theme/createTheme/defineComponentTheme.d.ts +54 -0
- package/dist/types/theme/createTheme/index.d.ts +4 -0
- package/dist/types/theme/createTheme/utils.d.ts +92 -0
- package/dist/types/theme/index.d.ts +1 -2
- package/dist/types/theme/types.d.ts +20 -3
- package/dist/types/utils/classNames.d.ts +1 -1
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/utils.d.ts +8 -0
- package/package.json +3 -3
- package/dist/esm/theme/utils.mjs +0 -81
- package/dist/types/theme/utils.d.ts +0 -35
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentStyles, Elements, Modifiers } from './utils';
|
|
2
|
+
export type BreadcrumbsTheme<Required extends boolean = false> = ComponentStyles & Elements<{
|
|
3
|
+
list?: ComponentStyles;
|
|
4
|
+
separator?: ComponentStyles;
|
|
5
|
+
item?: ComponentStyles;
|
|
6
|
+
link?: ComponentStyles & Modifiers<'current', Required>;
|
|
7
|
+
}, Required>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ColorTheme, Size, Modifiers, ComponentStyles, Elements } from './utils';
|
|
2
|
+
type Variations = 'primary' | 'secondary' | 'destructive' | 'warning' | 'menu' | 'link';
|
|
3
|
+
export type ButtonColorThemeVariations = `${'primary' | 'link' | 'outlined'}--${ColorTheme | 'overlay'}`;
|
|
4
|
+
export type ButtonTheme<Required extends boolean = false> = ComponentStyles & Modifiers<Size | ButtonColorThemeVariations | Variations | 'loading' | 'fullwidth' | 'disabled', Required> & Elements<{
|
|
5
|
+
'loader-wrapper'?: ComponentStyles;
|
|
6
|
+
}, Required>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Modifiers, ComponentStyles, ColorTheme, Elements } from './utils';
|
|
2
|
+
export type CheckboxTheme<Required extends boolean = false> = ComponentStyles & Modifiers<ColorTheme | 'disabled', Required> & Elements<{
|
|
3
|
+
button?: ComponentStyles & Modifiers<'focused' | 'error' | 'disabled'>;
|
|
4
|
+
icon?: ComponentStyles & Modifiers<'checked' | 'indeterminate' | 'disabled'>;
|
|
5
|
+
label?: ComponentStyles;
|
|
6
|
+
input?: ComponentStyles;
|
|
7
|
+
}, Required>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Modifiers, ComponentStyles, Size, Elements } from './utils';
|
|
2
|
+
export type FieldTheme<Required extends boolean = false> = ComponentStyles & Modifiers<Size, Required> & Elements<{
|
|
3
|
+
description?: ComponentStyles;
|
|
4
|
+
'error-message'?: ComponentStyles;
|
|
5
|
+
'show-password'?: ComponentStyles & Modifiers<'error', Required>;
|
|
6
|
+
}, Required>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Modifiers, ComponentStyles, Elements } from './utils';
|
|
2
|
+
export type FieldGroupTheme<Required extends boolean = false> = ComponentStyles & Elements<{
|
|
3
|
+
'inner-start'?: ComponentStyles;
|
|
4
|
+
'inner-end'?: ComponentStyles;
|
|
5
|
+
'outer-start'?: ComponentStyles & Modifiers<'quiet', Required>;
|
|
6
|
+
'outer-end'?: ComponentStyles & Modifiers<'quiet', Required>;
|
|
7
|
+
'field-wrapper'?: ComponentStyles & Modifiers<'horizontal' | 'vertical', Required>;
|
|
8
|
+
control?: ComponentStyles;
|
|
9
|
+
icon?: ComponentStyles;
|
|
10
|
+
'icon-button'?: ComponentStyles;
|
|
11
|
+
}, Required> & Modifiers<'horizontal' | 'vertical' | 'has-inner-end' | 'has-inner-start', Required>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Modifiers, ComponentStyles, Size, Elements } from './utils';
|
|
2
|
+
export type FieldsetTheme<Required extends boolean = false> = ComponentStyles & Modifiers<Size | 'outlined' | 'plain', Required> & Elements<{
|
|
3
|
+
legend?: ComponentStyles & Modifiers<Size, Required>;
|
|
4
|
+
}, Required>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { WebTokens } from '../tokens';
|
|
2
|
+
import { AccordionTheme } from './accordion';
|
|
3
|
+
import { AlertTheme } from './alert';
|
|
4
|
+
import { AutoCompleteTheme } from './autocomplete';
|
|
5
|
+
import { BadgeTheme } from './badge';
|
|
6
|
+
import { BreadcrumbsTheme } from './breadcrumbs';
|
|
7
|
+
import { ButtonTheme } from './button';
|
|
8
|
+
import { ButtonGroupTheme } from './buttonGroup';
|
|
9
|
+
import { CardTheme } from './card';
|
|
10
|
+
import { CheckboxTheme } from './checkbox';
|
|
11
|
+
import { CheckboxFieldTheme } from './checkboxField';
|
|
12
|
+
import { CollectionTheme } from './collection';
|
|
13
|
+
import { DividerTheme } from './divider';
|
|
14
|
+
import { DropZoneTheme } from './dropZone';
|
|
15
|
+
import { FieldTheme } from './field';
|
|
16
|
+
import { FieldGroupTheme } from './fieldGroup';
|
|
17
|
+
import { FieldsetTheme } from './fieldset';
|
|
18
|
+
import { HeadingTheme } from './heading';
|
|
19
|
+
import { HighlightMatchTheme } from './highlightMatch';
|
|
20
|
+
import { InputTheme } from './input';
|
|
21
|
+
import { LoaderTheme } from './loader';
|
|
22
|
+
import { MenuTheme } from './menu';
|
|
23
|
+
import { MessageTheme } from './message';
|
|
24
|
+
import { PaginationTheme } from './pagination';
|
|
25
|
+
import { PlaceholderTheme } from './placeholder';
|
|
26
|
+
import { RadioTheme } from './radio';
|
|
27
|
+
import { RatingTheme } from './rating';
|
|
28
|
+
import { ScrollViewTheme } from './scrollview';
|
|
29
|
+
import { SearchFieldTheme } from './searchField';
|
|
30
|
+
import { SelectTheme } from './select';
|
|
31
|
+
import { SelectFieldTheme } from './selectField';
|
|
32
|
+
import { SliderFieldTheme } from './sliderField';
|
|
33
|
+
import { StepperFieldTheme } from './stepperField';
|
|
34
|
+
import { StorageManagerTheme } from './storageManager';
|
|
35
|
+
import { SwitchFieldTheme, SwitchTheme } from './switchField';
|
|
36
|
+
import { TableTheme } from './table';
|
|
37
|
+
import { TabsTheme } from './tabs';
|
|
38
|
+
import { TextTheme } from './text';
|
|
39
|
+
import { TextFieldTheme } from './textField';
|
|
40
|
+
import { TextareaTheme } from './textarea';
|
|
41
|
+
import { TextareaFieldTheme } from './textareaField';
|
|
42
|
+
import { ToggleButtonTheme, ToggleButtonGroupTheme } from './toggleButton';
|
|
43
|
+
import { ComponentTheme, BaseComponentTheme, BaseTheme } from './utils';
|
|
44
|
+
export { ClassNameFunction } from '../createTheme/createComponentClasses';
|
|
45
|
+
export type { ComponentTheme, BaseComponentTheme, BaseTheme };
|
|
46
|
+
export type ComponentsTheme<TokensType extends WebTokens = WebTokens> = BaseComponentTheme<BaseTheme, string, TokensType> | BaseComponentTheme<AccordionTheme, 'accordion', TokensType> | BaseComponentTheme<AlertTheme, 'alert', TokensType> | BaseComponentTheme<AutoCompleteTheme, 'autocomplete', TokensType> | BaseComponentTheme<BadgeTheme, 'badge', TokensType> | BaseComponentTheme<BreadcrumbsTheme, 'breadcrumbs', TokensType> | BaseComponentTheme<ButtonTheme, 'button', TokensType> | BaseComponentTheme<ButtonGroupTheme, 'buttongroup', TokensType> | BaseComponentTheme<CardTheme, 'card', TokensType> | BaseComponentTheme<CheckboxTheme, 'checkbox', TokensType> | BaseComponentTheme<CheckboxFieldTheme, 'checkboxfield', TokensType> | BaseComponentTheme<CollectionTheme, 'collection', TokensType> | BaseComponentTheme<DividerTheme, 'divider', TokensType> | BaseComponentTheme<DropZoneTheme, 'dropzone', TokensType> | BaseComponentTheme<FieldTheme, 'field', TokensType> | BaseComponentTheme<FieldGroupTheme, 'field-group', TokensType> | BaseComponentTheme<FieldsetTheme, 'fieldset', TokensType> | BaseComponentTheme<HeadingTheme, 'heading', TokensType> | BaseComponentTheme<HighlightMatchTheme, 'highlightmatch', TokensType> | BaseComponentTheme<InputTheme, 'input', TokensType> | BaseComponentTheme<LoaderTheme, 'loader', TokensType> | BaseComponentTheme<MenuTheme, 'menu', TokensType> | BaseComponentTheme<MessageTheme, 'message', TokensType> | BaseComponentTheme<PaginationTheme, 'pagination', TokensType> | BaseComponentTheme<PlaceholderTheme, 'placeholder', TokensType> | BaseComponentTheme<RatingTheme, 'rating', TokensType> | BaseComponentTheme<RadioTheme, 'radio', TokensType> | BaseComponentTheme<ScrollViewTheme, 'scrollview', TokensType> | BaseComponentTheme<SearchFieldTheme, 'searchfield', TokensType> | BaseComponentTheme<SelectTheme, 'select', TokensType> | BaseComponentTheme<SelectFieldTheme, 'selectfield', TokensType> | BaseComponentTheme<SliderFieldTheme, 'sliderfield', TokensType> | BaseComponentTheme<StepperFieldTheme, 'stepperfield', TokensType> | BaseComponentTheme<StorageManagerTheme, 'storagemanager', TokensType> | BaseComponentTheme<SwitchTheme, 'switch', TokensType> | BaseComponentTheme<SwitchFieldTheme, 'switchfield', TokensType> | BaseComponentTheme<TabsTheme, 'tabs', TokensType> | BaseComponentTheme<TableTheme, 'table', TokensType> | BaseComponentTheme<TextTheme, 'text', TokensType> | BaseComponentTheme<TextareaTheme, 'textarea', TokensType> | BaseComponentTheme<TextareaFieldTheme, 'textareafield', TokensType> | BaseComponentTheme<TextFieldTheme, 'textfield', TokensType> | BaseComponentTheme<ToggleButtonTheme, 'togglebutton', TokensType> | BaseComponentTheme<ToggleButtonGroupTheme, 'togglebuttongroup', TokensType>;
|
|
47
|
+
export type AllComponentThemes = {
|
|
48
|
+
accordion: AccordionTheme;
|
|
49
|
+
alert: AlertTheme;
|
|
50
|
+
autocomplete: AutoCompleteTheme;
|
|
51
|
+
badge: BadgeTheme;
|
|
52
|
+
breadcrumbs: BreadcrumbsTheme;
|
|
53
|
+
button: ButtonTheme;
|
|
54
|
+
buttongroup: ButtonGroupTheme;
|
|
55
|
+
card: CardTheme;
|
|
56
|
+
checkbox: CheckboxTheme;
|
|
57
|
+
checkboxfield: CheckboxFieldTheme;
|
|
58
|
+
collection: CollectionTheme;
|
|
59
|
+
divider: DividerTheme;
|
|
60
|
+
dropZone: DropZoneTheme;
|
|
61
|
+
field: FieldTheme;
|
|
62
|
+
'field-group': FieldGroupTheme;
|
|
63
|
+
fieldset: FieldsetTheme;
|
|
64
|
+
heading: HeadingTheme;
|
|
65
|
+
highlightmatch: HighlightMatchTheme;
|
|
66
|
+
input: InputTheme;
|
|
67
|
+
loader: LoaderTheme;
|
|
68
|
+
menu: MenuTheme;
|
|
69
|
+
message: MessageTheme;
|
|
70
|
+
pagination: PaginationTheme;
|
|
71
|
+
placeholder: PlaceholderTheme;
|
|
72
|
+
radio: RadioTheme;
|
|
73
|
+
rating: RatingTheme;
|
|
74
|
+
scrollview: ScrollViewTheme;
|
|
75
|
+
searchfield: SearchFieldTheme;
|
|
76
|
+
select: SelectTheme;
|
|
77
|
+
selectfield: SelectFieldTheme;
|
|
78
|
+
sliderfield: SliderFieldTheme;
|
|
79
|
+
stepperfield: StepperFieldTheme;
|
|
80
|
+
storagemanager: StorageManagerTheme;
|
|
81
|
+
switch: SwitchTheme;
|
|
82
|
+
switchfield: SwitchFieldTheme;
|
|
83
|
+
table: TableTheme;
|
|
84
|
+
tabs: TabsTheme;
|
|
85
|
+
text: TextTheme;
|
|
86
|
+
textarea: TextareaTheme;
|
|
87
|
+
textareaField: TextareaFieldTheme;
|
|
88
|
+
textField: TextFieldTheme;
|
|
89
|
+
toggleButton: ToggleButtonTheme;
|
|
90
|
+
toggleButtonGroup: ToggleButtonGroupTheme;
|
|
91
|
+
};
|
|
92
|
+
export type ComponentThemeFromName<T extends string, Theme extends BaseTheme = BaseTheme> = T extends keyof AllComponentThemes ? AllComponentThemes[T] : Theme;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Modifiers, ComponentStyles, Elements, ColorTheme } from './utils';
|
|
2
|
+
export type MessageTheme<Required extends boolean = false> = ComponentStyles & Modifiers<'plain' | 'outlined' | 'filled' | ColorTheme | 'neutral', Required> & Elements<{
|
|
3
|
+
[key in 'icon' | 'heading' | 'content' | 'dismiss']?: ComponentStyles;
|
|
4
|
+
}, Required>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ComponentStyles, Elements, Modifiers, Size } from './utils';
|
|
2
|
+
export type RadioTheme<Required extends boolean = false> = ComponentStyles & Modifiers<Size | 'disabled', Required> & Elements<{
|
|
3
|
+
input?: ComponentStyles;
|
|
4
|
+
button?: ComponentStyles & Modifiers<Size>;
|
|
5
|
+
label?: ComponentStyles & Modifiers<'disabled'>;
|
|
6
|
+
}, Required>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ComponentStyles, Elements, Modifiers, Size } from './utils';
|
|
2
|
+
export type RatingTheme<Required extends boolean = false> = ComponentStyles & Modifiers<Size> & Elements<{
|
|
3
|
+
item?: ComponentStyles;
|
|
4
|
+
icon?: ComponentStyles & Modifiers<'filled' | 'empty'>;
|
|
5
|
+
}, Required>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Modifiers, ComponentStyles, Elements, Size, FieldControlModifiers } from './utils';
|
|
2
|
+
export type SelectTheme<Required extends boolean = false> = ComponentStyles & Modifiers<FieldControlModifiers | 'expanded', Required> & Elements<{
|
|
3
|
+
wrapper?: ComponentStyles;
|
|
4
|
+
icon?: ComponentStyles & Modifiers<Size, Required>;
|
|
5
|
+
}, Required>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Modifiers, ComponentStyles, Elements, ColorTheme, Size } from './utils';
|
|
2
|
+
export type SliderFieldTheme<Required extends boolean = false> = ComponentStyles & Modifiers<ColorTheme, Required> & Elements<{
|
|
3
|
+
label?: ComponentStyles;
|
|
4
|
+
group?: ComponentStyles;
|
|
5
|
+
root?: ComponentStyles & Modifiers<'disabled' | 'horizontal' | 'vertical' | Size, Required>;
|
|
6
|
+
track?: ComponentStyles & Modifiers<'horizontal' | 'vertical' | Size, Required>;
|
|
7
|
+
range?: ComponentStyles & Modifiers<'disabled' | 'horizontal' | 'vertical', Required>;
|
|
8
|
+
thumb?: ComponentStyles & Modifiers<'disabled' | Size, Required>;
|
|
9
|
+
}, Required>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Modifiers, ComponentStyles, Elements, ColorTheme } from './utils';
|
|
2
|
+
export type StepperFieldTheme<Required extends boolean = false> = ComponentStyles & Modifiers<ColorTheme, Required> & Elements<{
|
|
3
|
+
'button--increase'?: ComponentStyles & Modifiers<'quiet' | 'disabled', Required>;
|
|
4
|
+
'button--decrease'?: ComponentStyles & Modifiers<'quiet' | 'disabled', Required>;
|
|
5
|
+
input?: ComponentStyles;
|
|
6
|
+
}, Required>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Modifiers, ComponentStyles, Elements, ColorTheme } from './utils';
|
|
2
|
+
export type StorageManagerTheme<Required extends boolean = false> = ComponentStyles & Modifiers<ColorTheme, Required> & Elements<{
|
|
3
|
+
dropzone?: ComponentStyles & Modifiers<'active' | 'small', Required>;
|
|
4
|
+
dropzone__icon?: ComponentStyles;
|
|
5
|
+
dropzone__text?: ComponentStyles;
|
|
6
|
+
file?: ComponentStyles;
|
|
7
|
+
file__picker?: ComponentStyles;
|
|
8
|
+
file__wrapper?: ComponentStyles;
|
|
9
|
+
file__name?: ComponentStyles;
|
|
10
|
+
file__size?: ComponentStyles;
|
|
11
|
+
file__list?: ComponentStyles;
|
|
12
|
+
file__main?: ComponentStyles;
|
|
13
|
+
file__image?: ComponentStyles;
|
|
14
|
+
file__status?: ComponentStyles & Modifiers<'error' | 'success', Required>;
|
|
15
|
+
loader?: ComponentStyles;
|
|
16
|
+
previewer?: ComponentStyles;
|
|
17
|
+
previewer__text?: ComponentStyles;
|
|
18
|
+
previewer__footer?: ComponentStyles;
|
|
19
|
+
previewer__actions?: ComponentStyles;
|
|
20
|
+
}, Required>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Modifiers, ComponentStyles, Elements, Size } from './utils';
|
|
2
|
+
export type SwitchTheme<Required extends boolean = false> = ComponentStyles & Elements<{
|
|
3
|
+
wrapper?: ComponentStyles & Modifiers<'start' | 'end' | 'top' | 'bottom', Required>;
|
|
4
|
+
track?: ComponentStyles & Modifiers<'checked' | 'disabled' | 'focused' | 'error'>;
|
|
5
|
+
thumb?: ComponentStyles & Modifiers<'checked' | 'disabled'>;
|
|
6
|
+
label?: ComponentStyles;
|
|
7
|
+
}, Required>;
|
|
8
|
+
export type SwitchFieldTheme<Required extends boolean = false> = ComponentStyles & Modifiers<Size, Required>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Modifiers, ComponentStyles, Size, Elements } from './utils';
|
|
2
|
+
export type TableTheme<Required extends boolean = false> = ComponentStyles & Modifiers<Size | 'bordered' | 'striped', Required> & Elements<{
|
|
3
|
+
[key in 'caption' | 'head' | 'body' | 'foot' | 'row' | 'th' | 'td']?: ComponentStyles;
|
|
4
|
+
}, Required>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ComponentStyles, Elements, Modifiers } from './utils';
|
|
2
|
+
export type TabsTheme<Required extends boolean = false> = ComponentStyles & Elements<{
|
|
3
|
+
list?: ComponentStyles & Modifiers<'equal' | 'relative' | 'top' | 'bottom'>;
|
|
4
|
+
panel?: ComponentStyles & Modifiers<'active'>;
|
|
5
|
+
item?: ComponentStyles & Modifiers<'active'>;
|
|
6
|
+
}, Required>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Modifiers, ComponentStyles } from './utils';
|
|
2
|
+
export type TextVariation = 'primary' | 'secondary' | 'tertiary' | 'error' | 'warning' | 'info' | 'success';
|
|
3
|
+
export type TextTheme<Required extends boolean = false> = ComponentStyles & Modifiers<TextVariation | 'truncated', Required>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
import { DesignToken } from '../types';
|
|
3
|
+
import { WebTokens } from '../tokens';
|
|
4
|
+
import { Breakpoints } from '../breakpoints';
|
|
5
|
+
export type ColorTheme = 'info' | 'warning' | 'success' | 'error';
|
|
6
|
+
export type Size = 'small' | 'large';
|
|
7
|
+
export type Orientation = 'horizontal' | 'vertical';
|
|
8
|
+
export type FieldControlModifiers = Size | 'error' | 'quiet';
|
|
9
|
+
export type CSSProperties = {
|
|
10
|
+
[Key in keyof CSS.Properties]: DesignToken<CSS.Properties[Key] | (string & {})> | CSS.Properties[Key];
|
|
11
|
+
};
|
|
12
|
+
export type Selectors = {
|
|
13
|
+
[key in CSS.HtmlAttributes | CSS.Pseudos]?: CSSProperties;
|
|
14
|
+
};
|
|
15
|
+
export interface ComponentStyles extends CSSProperties, Selectors {
|
|
16
|
+
_vars?: Record<string, DesignToken | string>;
|
|
17
|
+
}
|
|
18
|
+
export type Modifiers<Keys extends string = string, Required extends boolean = false> = Required extends true ? {
|
|
19
|
+
_modifiers: {
|
|
20
|
+
[key in Keys]: ComponentStyles;
|
|
21
|
+
};
|
|
22
|
+
} : {
|
|
23
|
+
_modifiers?: {
|
|
24
|
+
[key in Keys]?: ComponentStyles;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export type Elements<Properties extends Record<string, ComponentStyles & {
|
|
28
|
+
_modifiers?: Record<string, ComponentStyles>;
|
|
29
|
+
}>, Required extends boolean = false> = Required extends true ? {
|
|
30
|
+
_element: Properties;
|
|
31
|
+
} : {
|
|
32
|
+
_element?: Properties;
|
|
33
|
+
};
|
|
34
|
+
export interface BaseTheme extends ComponentStyles {
|
|
35
|
+
_modifiers?: Record<string, ComponentStyles>;
|
|
36
|
+
_element?: Record<string, ComponentStyles & {
|
|
37
|
+
_modifiers?: Record<string, ComponentStyles>;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
export type ComponentTheme<ThemeType extends BaseTheme = BaseTheme, TokensType extends WebTokens = WebTokens> = ThemeType | ((tokens: TokensType) => ThemeType);
|
|
41
|
+
export type ComponentThemeOverride<ThemeType> = {
|
|
42
|
+
theme: ThemeType;
|
|
43
|
+
colorMode?: 'light' | 'dark';
|
|
44
|
+
breakpoint?: keyof Breakpoints['values'];
|
|
45
|
+
mediaQuery?: string;
|
|
46
|
+
selector?: string;
|
|
47
|
+
};
|
|
48
|
+
export type BaseComponentTheme<ThemeType extends BaseTheme = BaseTheme, NameType extends string = string, TokensType extends WebTokens = WebTokens> = {
|
|
49
|
+
name: NameType;
|
|
50
|
+
theme: ComponentTheme<ThemeType, TokensType>;
|
|
51
|
+
overrides?: Array<ComponentThemeOverride<ComponentTheme<ThemeType, TokensType>>>;
|
|
52
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ColorValues, ScaleKey } from '../tokens/colors';
|
|
2
|
+
/**
|
|
3
|
+
* Takes a set of keys and a color name and returns an object of design tokens,
|
|
4
|
+
* used for applying a primary color at the theme level to our tokens.
|
|
5
|
+
*
|
|
6
|
+
* createColorPalette({keys: ['10','20',...], value: 'red'})
|
|
7
|
+
* returns {
|
|
8
|
+
* 10: { value: '{colors.red.10.value}' },
|
|
9
|
+
* 20: { value: '{colors.red.20.value}' },
|
|
10
|
+
* ...
|
|
11
|
+
* }
|
|
12
|
+
*/
|
|
13
|
+
export declare function createColorPalette<ColorType extends ColorValues<ScaleKey, 'default'> = ColorValues<ScaleKey, 'default'>>({ keys, value }: {
|
|
14
|
+
keys: string[];
|
|
15
|
+
value: string;
|
|
16
|
+
}): ColorType;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DefaultTheme, WebTheme } from '../types';
|
|
2
|
+
import { ComponentsTheme } from '../components';
|
|
3
|
+
/**
|
|
4
|
+
* This will take a component theme and create the appropriate CSS for it.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
export declare function createComponentCSS(themeName: string, components: Array<ComponentsTheme>, tokens: WebTheme['tokens'], breakpoints: DefaultTheme['breakpoints']): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ClassNamesArgs } from '../../utils';
|
|
2
|
+
import { ComponentThemeFromName } from '../components';
|
|
3
|
+
import { BaseTheme } from '../components/utils';
|
|
4
|
+
type ElementNames<T extends unknown> = T extends {
|
|
5
|
+
_element?: any;
|
|
6
|
+
} ? keyof Required<T['_element']> : never;
|
|
7
|
+
type ModifierNames<T extends unknown> = T extends {
|
|
8
|
+
_modifiers?: any;
|
|
9
|
+
} ? Arrayify<keyof Required<T['_modifiers']> | {
|
|
10
|
+
[key in keyof Required<T['_modifiers']>]?: boolean | null | undefined;
|
|
11
|
+
} | undefined> : never;
|
|
12
|
+
type Arrayify<T> = T | T[];
|
|
13
|
+
export type ClassNameArgs<T extends BaseTheme> = {
|
|
14
|
+
_element?: ElementNames<Required<T>> | {
|
|
15
|
+
[Key in ElementNames<Required<T>>]?: ModifierNames<Required<Required<Required<T>['_element']>[Key]>>;
|
|
16
|
+
};
|
|
17
|
+
_modifiers?: ModifierNames<Required<T>>;
|
|
18
|
+
};
|
|
19
|
+
export type ClassNameFunction<T extends BaseTheme = BaseTheme, NameType extends string = string> = (props?: ClassNameArgs<UnwrapTheme<ComponentThemeFromName<NameType, T>>>, extraClassnames?: ClassNamesArgs) => string;
|
|
20
|
+
type UnwrapTheme<ThemeType extends BaseTheme = BaseTheme> = ThemeType extends (...args: any) => any ? ReturnType<ThemeType> : ThemeType;
|
|
21
|
+
export declare function createComponentClasses<ThemeType extends BaseTheme, NameType extends string = string>({ name, prefix }: {
|
|
22
|
+
name: NameType;
|
|
23
|
+
prefix?: string;
|
|
24
|
+
}): ClassNameFunction<ThemeType, NameType>;
|
|
25
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Theme, DefaultTheme, WebTheme } from '
|
|
1
|
+
import { Theme, DefaultTheme, WebTheme } from '../types';
|
|
2
|
+
import { WebTokens } from '../tokens';
|
|
2
3
|
/**
|
|
3
4
|
* This will be used like `const myTheme = createTheme({})`
|
|
4
5
|
* `myTheme` can then be passed to a Provider or the generated CSS
|
|
@@ -6,4 +7,4 @@ import { Theme, DefaultTheme, WebTheme } from './types';
|
|
|
6
7
|
* const myTheme = createTheme({})
|
|
7
8
|
* const myOtherTheme = createTheme({}, myTheme);
|
|
8
9
|
*/
|
|
9
|
-
export declare function createTheme(theme?: Theme | WebTheme, DefaultTheme?: DefaultTheme | WebTheme): WebTheme;
|
|
10
|
+
export declare function createTheme<TokensType extends WebTokens = WebTokens>(theme?: Theme<TokensType> | WebTheme, DefaultTheme?: DefaultTheme | WebTheme): WebTheme;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ComponentThemeFromName, ComponentsTheme } from '../components';
|
|
2
|
+
import { BaseTheme, ComponentTheme, ComponentThemeOverride } from '../components/utils';
|
|
3
|
+
import { WebTokens } from '../tokens';
|
|
4
|
+
import { ClassNameFunction } from './createComponentClasses';
|
|
5
|
+
type CreateComponentThemeProps<TokensType extends WebTokens = WebTokens, ThemeType extends BaseTheme = BaseTheme, NameType extends string = string, OverridesType extends BaseTheme = BaseTheme> = {
|
|
6
|
+
name: NameType;
|
|
7
|
+
theme?: ComponentTheme<ThemeType, TokensType>;
|
|
8
|
+
overrides?: ComponentThemeOverride<ComponentTheme<OverridesType, TokensType>>[];
|
|
9
|
+
} & ComponentsTheme<TokensType>;
|
|
10
|
+
/**
|
|
11
|
+
* Use this to create the theme of a component. You can use this
|
|
12
|
+
* to both completely customize built-in components and
|
|
13
|
+
* build your own components!
|
|
14
|
+
*
|
|
15
|
+
* @experimental
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* // built-in component styling
|
|
19
|
+
* const alertTheme = defineComponentTheme({
|
|
20
|
+
* name: 'alert',
|
|
21
|
+
* theme: (tokens) => {
|
|
22
|
+
* return {
|
|
23
|
+
* padding: tokens.space.large
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // custom component styling
|
|
29
|
+
* const avatarTheme = defineComponentTheme({
|
|
30
|
+
* name: 'avatar',
|
|
31
|
+
* theme: (tokens) => {
|
|
32
|
+
* return {
|
|
33
|
+
* padding: tokens.space.large
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
* })
|
|
37
|
+
*
|
|
38
|
+
* const theme = createTheme({
|
|
39
|
+
* name: 'my-theme',
|
|
40
|
+
* components: [alertTheme, avatarTheme]
|
|
41
|
+
* })
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} params
|
|
45
|
+
* @param {string} params.name - The name of the component. Use a built-in component name like button to theme buttons.
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
export declare function defineComponentTheme<ThemeType extends BaseTheme = BaseTheme, TokensType extends WebTokens = WebTokens, NameType extends string = string>({ name, theme, overrides, }: CreateComponentThemeProps<TokensType, ThemeType, NameType>): {
|
|
49
|
+
className: ClassNameFunction<ComponentThemeFromName<NameType, ThemeType>>;
|
|
50
|
+
theme: typeof theme;
|
|
51
|
+
name: string;
|
|
52
|
+
overrides?: typeof overrides;
|
|
53
|
+
};
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createTheme } from './createTheme';
|
|
2
|
+
export { defineComponentTheme } from './defineComponentTheme';
|
|
3
|
+
export { cssNameTransform, setupTokens, SetupToken, isDesignToken, } from './utils';
|
|
4
|
+
export { createComponentClasses, ClassNameArgs, } from './createComponentClasses';
|