@redis-ui/styles 13.3.2 → 14.5.3

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.
Files changed (40) hide show
  1. package/dist/hooks/ThemeModeSwitching/SwitchableModeThemeProvider.d.ts +2 -0
  2. package/dist/hooks/ThemeModeSwitching/ThemeModeSwitching.context.d.ts +3 -0
  3. package/dist/hooks/ThemeModeSwitching/ThemeModeSwitching.types.d.ts +29 -0
  4. package/dist/hooks/ThemeModeSwitching/index.d.ts +4 -0
  5. package/dist/hooks/ThemeModeSwitching/useThemeModeSwitchingManager.d.ts +9 -0
  6. package/dist/hooks/useStorage.d.ts +9 -0
  7. package/dist/index.d.ts +3 -8
  8. package/dist/index.js +2219 -1381
  9. package/dist/index.umd.cjs +21 -19
  10. package/dist/normalized-styles.css +0 -4
  11. package/dist/themes/index.d.ts +5 -0
  12. package/dist/themes/themeDark/theme/components/layouts.d.ts +3 -0
  13. package/dist/themes/themeDark/theme/components/midBar.d.ts +3 -0
  14. package/dist/themes/themeDark/theme/components/themeModeSwitch.d.ts +3 -0
  15. package/dist/themes/themeDark2/theme/components/layouts.d.ts +3 -0
  16. package/dist/themes/themeDark2/theme/components/midBar.d.ts +3 -0
  17. package/dist/themes/themeDark2/theme/components/themeModeSwitch.d.ts +3 -0
  18. package/dist/themes/themeLight/theme/components/layouts.d.ts +3 -0
  19. package/dist/themes/themeLight/theme/components/midBar.d.ts +3 -0
  20. package/dist/themes/themeLight/theme/components/themeModeSwitch.d.ts +3 -0
  21. package/dist/themes/themeLight/tokens.d.ts +11 -0
  22. package/dist/themes/themeLight2/theme/components/layouts.d.ts +3 -0
  23. package/dist/themes/themeLight2/theme/components/midBar.d.ts +3 -0
  24. package/dist/themes/themeLight2/theme/components/themeModeSwitch.d.ts +3 -0
  25. package/dist/themes/types/index.d.ts +3 -0
  26. package/dist/themes/types/theme/components/index.d.ts +3 -0
  27. package/dist/themes/types/theme/components/input.types.d.ts +3 -1
  28. package/dist/themes/types/theme/components/layouts.types.d.ts +14 -0
  29. package/dist/themes/types/theme/components/midBar.types.d.ts +13 -0
  30. package/dist/themes/types/theme/components/table.types.d.ts +46 -0
  31. package/dist/themes/types/theme/components/textButton.types.d.ts +11 -5
  32. package/dist/themes/types/theme/components/themeModeSwitch.types.d.ts +15 -0
  33. package/dist/themes/types/theme/theme.types.d.ts +6 -3
  34. package/dist/themes/types/theme/themeCore.types.d.ts +9 -0
  35. package/dist/utils.d.ts +35 -0
  36. package/package.json +1 -1
  37. package/dist/hooks/ThemeSwitch/SwitchableThemeProvider.d.ts +0 -20
  38. package/dist/hooks/ThemeSwitch/index.d.ts +0 -3
  39. package/dist/hooks/ThemeSwitch/useStorage.d.ts +0 -9
  40. package/dist/hooks/ThemeSwitch/useThemeSelector.d.ts +0 -26
@@ -16,10 +16,6 @@ svg:not([fill]) {
16
16
  fill: currentColor;
17
17
  }
18
18
 
19
- svg {
20
- color: unset; /* fixes icons color attribute */
21
- }
22
-
23
19
  :focus {
24
20
  outline: 0;
25
21
  }
@@ -0,0 +1,5 @@
1
+ import { Theme, ThemePair } from './types';
2
+ export * from './types';
3
+ export declare const theme: Theme;
4
+ export declare const themesDefault: ThemePair<Theme>;
5
+ export declare const themesRebrand: ThemePair<Theme>;
@@ -0,0 +1,3 @@
1
+ import { LayoutsTheme } from '../../../types/theme/components/layouts.types';
2
+ declare const theme: LayoutsTheme;
3
+ export default theme;
@@ -0,0 +1,3 @@
1
+ import { MidBarTheme } from '../../../types/theme/components/midBar.types';
2
+ declare const theme: MidBarTheme;
3
+ export default theme;
@@ -0,0 +1,3 @@
1
+ import { ThemeModeSwitchTheme } from '../../../types/theme/components/themeModeSwitch.types';
2
+ declare const theme: ThemeModeSwitchTheme;
3
+ export default theme;
@@ -0,0 +1,3 @@
1
+ import { LayoutsTheme } from '../../../types/theme/components/layouts.types';
2
+ declare const theme: LayoutsTheme;
3
+ export default theme;
@@ -0,0 +1,3 @@
1
+ import { MidBarTheme } from '../../../types/theme/components/midBar.types';
2
+ declare const theme: MidBarTheme;
3
+ export default theme;
@@ -0,0 +1,3 @@
1
+ import { ThemeModeSwitchTheme } from '../../../types/theme/components/themeModeSwitch.types';
2
+ declare const theme: ThemeModeSwitchTheme;
3
+ export default theme;
@@ -0,0 +1,3 @@
1
+ import { LayoutsTheme } from '../../../types/theme/components/layouts.types';
2
+ declare const theme: LayoutsTheme;
3
+ export default theme;
@@ -0,0 +1,3 @@
1
+ import { MidBarTheme } from '../../../types/theme/components/midBar.types';
2
+ declare const theme: MidBarTheme;
3
+ export default theme;
@@ -0,0 +1,3 @@
1
+ import { ThemeModeSwitchTheme } from '../../../types/theme/components/themeModeSwitch.types';
2
+ declare const theme: ThemeModeSwitchTheme;
3
+ export default theme;
@@ -568,6 +568,17 @@ export declare const tokens: {
568
568
  zIndex9998: number;
569
569
  zIndex9999: number;
570
570
  };
571
+ icon: {
572
+ size: {
573
+ XS: string;
574
+ S: string;
575
+ M: string;
576
+ L: string;
577
+ XL: string;
578
+ 'for-text': string;
579
+ 'by-font': string;
580
+ };
581
+ };
571
582
  font: {
572
583
  fontFamily: {
573
584
  regular: string;
@@ -0,0 +1,3 @@
1
+ import { LayoutsTheme } from '../../../types/theme/components/layouts.types';
2
+ declare const theme: LayoutsTheme;
3
+ export default theme;
@@ -0,0 +1,3 @@
1
+ import { MidBarTheme } from '../../../types/theme/components/midBar.types';
2
+ declare const theme: MidBarTheme;
3
+ export default theme;
@@ -0,0 +1,3 @@
1
+ import { ThemeModeSwitchTheme } from '../../../types/theme/components/themeModeSwitch.types';
2
+ declare const theme: ThemeModeSwitchTheme;
3
+ export default theme;
@@ -1,2 +1,5 @@
1
1
  export type { Theme } from './theme/theme.types';
2
2
  export type { Tokens } from './theme/tokens.types';
3
+ export * from './theme/themeCore.types';
4
+ export * from './theme/components';
5
+ export * from './theme/globals';
@@ -19,9 +19,11 @@ export * from './formField.types';
19
19
  export * from './iconButton.types';
20
20
  export * from './input.types';
21
21
  export * from './label.types';
22
+ export * from './layouts.types';
22
23
  export * from './link.types';
23
24
  export * from './loader.types';
24
25
  export * from './menu.types';
26
+ export * from './midBar.types';
25
27
  export * from './modal.types';
26
28
  export * from './moreInfoIcon.types';
27
29
  export * from './popover.types';
@@ -43,6 +45,7 @@ export * from './table.types';
43
45
  export * from './tableHeading.types';
44
46
  export * from './tabs.types';
45
47
  export * from './textButton.types';
48
+ export * from './themeModeSwitch.types';
46
49
  export * from './toast.types';
47
50
  export * from './toggleButton.types';
48
51
  export * from './tooltip.types';
@@ -56,7 +56,9 @@ export type InputTheme = {
56
56
  };
57
57
  password: {
58
58
  padding: string;
59
- fontSize: string;
59
+ fontFamily?: string;
60
+ fontSize?: string;
61
+ fontSizeAdjust?: string;
60
62
  };
61
63
  additionalText: {
62
64
  margin: string;
@@ -0,0 +1,14 @@
1
+ type FlexGroupGapSize = 'XXS' | 'XS' | 'S' | 'M' | 'L' | 'XL' | 'XXL';
2
+ type FlexDividerPaddingSize = 'XXS' | 'XS' | 'S' | 'M' | 'L' | 'XL' | 'XXL' | 'none';
3
+ export type LayoutsTheme = {
4
+ flexGroup: {
5
+ gap: Record<FlexGroupGapSize, string>;
6
+ };
7
+ flexDivider: {
8
+ color: string;
9
+ size: string;
10
+ padding: Record<FlexDividerPaddingSize, string>;
11
+ spacing: Record<FlexDividerPaddingSize, string>;
12
+ };
13
+ };
14
+ export {};
@@ -0,0 +1,13 @@
1
+ export type MidBarTheme = {
2
+ header: {
3
+ height: string;
4
+ paddingInline: string;
5
+ gap: string;
6
+ tabBar: {
7
+ gap: string;
8
+ };
9
+ group: {
10
+ gap: string;
11
+ };
12
+ };
13
+ };
@@ -1,19 +1,65 @@
1
1
  export type TableTheme = {
2
2
  table: {
3
3
  tableContainer: {
4
+ borderRadius: string;
4
5
  backgroundColor: string;
5
6
  boxShadow: string;
6
7
  };
8
+ topBar: {
9
+ minHeight: string;
10
+ padding: string;
11
+ gap: string;
12
+ bgColor: string;
13
+ separator: {
14
+ color: string;
15
+ width: string;
16
+ };
17
+ };
18
+ bottomBar: {
19
+ minHeight: string;
20
+ padding: string;
21
+ gap: string;
22
+ bgColor: string;
23
+ separator: {
24
+ color: string;
25
+ width: string;
26
+ };
27
+ };
28
+ tableHeaderRow: {
29
+ minHeight: string;
30
+ bgColor: string;
31
+ separator: {
32
+ color: string;
33
+ width: string;
34
+ };
35
+ };
36
+ tableHeaderCell: {
37
+ padding: string;
38
+ color: string;
39
+ separator: {
40
+ color: string;
41
+ width: string;
42
+ blockPadding: string;
43
+ };
44
+ };
45
+ /** @deprecated use `tableHeaderCell.*` */
7
46
  tableTh: {
8
47
  color: string;
9
48
  borderRight: string;
10
49
  };
11
50
  tableBodyRow: {
51
+ /** @deprecated use `separator.*` */
12
52
  borderTop: string;
53
+ minHeight: string;
54
+ separator: {
55
+ color: string;
56
+ width: string;
57
+ };
13
58
  backgroundColor: string;
14
59
  hoverBoxShadow: string;
15
60
  };
16
61
  tableBodyCell: {
62
+ padding: string;
17
63
  color: string;
18
64
  };
19
65
  };
@@ -1,12 +1,18 @@
1
1
  import { ButtonStateColors, ButtonStatesTheme } from './button.types';
2
+ type TextButtonLayout = 'block' | 'inline';
2
3
  type TextButtonVariants = 'primary' | 'destructive' | 'primary-inline' | 'destructive-inline';
4
+ type TextButtonSizes = 'M';
3
5
  export type TextButtonTheme = {
4
- gap: string;
5
- height: string;
6
- lineHeight: string;
6
+ layouts: Record<TextButtonLayout, {
7
+ sizes: Record<TextButtonSizes, {
8
+ borderRadius: string;
9
+ padding: string;
10
+ height: string;
11
+ lineHeight: string;
12
+ gap: string;
13
+ }>;
14
+ }>;
7
15
  variants: Record<TextButtonVariants, {
8
- padding: string;
9
- borderRadius: string;
10
16
  states: ButtonStatesTheme<ButtonStateColors>;
11
17
  }>;
12
18
  };
@@ -0,0 +1,15 @@
1
+ export type ThemeModeSwitchTheme = {
2
+ width: string;
3
+ height: string;
4
+ padding: string;
5
+ borderRadius: string;
6
+ borderWidth: string;
7
+ borderColor: string;
8
+ bgColor: string;
9
+ thumb: {
10
+ icon: string;
11
+ iconAspectRatio: string;
12
+ borderRadius: string;
13
+ bgColor: string;
14
+ };
15
+ };
@@ -1,8 +1,8 @@
1
1
  import { Tokens } from './tokens.types';
2
- import { ActionIconButtonTheme, AppBarTheme, AppSelectionMenuTheme, AutoCompleteTheme, BadgeTheme, BannerTheme, BoxSelectionGroupTheme, ButtonGroupTheme, ButtonTheme, CardTheme, CheckboxTheme, ChipListTheme, ChipTheme, CountryFlagTheme, DatePickerTheme, DrawerTheme, FiltersTheme, FormFieldTheme, IconButtonTheme, InputTheme, LabelTheme, LinkTheme, LoaderTheme, MenuTheme, ModalTheme, MoreInfoIconTheme, PopoverTheme, PopupCardTheme, ProfileIconTheme, ProgressBarTheme, RadioTheme, SearchBarTheme, SectionTheme, SelectTheme, SemanticButtonTheme, SemanticContainerTheme, SemanticIconTheme, SideBarTheme, SkeletonTheme, StepperTheme, SwitchTheme, TableHeadingTheme, TableTheme, TabsTheme, TextButtonTheme, ToastTheme, ToggleButtonTheme, TooltipTheme, TreeViewTheme, TypoTheme, WindowBarTheme } from './components';
2
+ import { ActionIconButtonTheme, AppBarTheme, AppSelectionMenuTheme, AutoCompleteTheme, BadgeTheme, BannerTheme, BoxSelectionGroupTheme, ButtonGroupTheme, ButtonTheme, CardTheme, CheckboxTheme, ChipListTheme, ChipTheme, CountryFlagTheme, DatePickerTheme, DrawerTheme, FiltersTheme, FormFieldTheme, IconButtonTheme, InputTheme, LabelTheme, LayoutsTheme, LinkTheme, LoaderTheme, MenuTheme, MidBarTheme, ModalTheme, MoreInfoIconTheme, PopoverTheme, PopupCardTheme, ProfileIconTheme, ProgressBarTheme, RadioTheme, SearchBarTheme, SectionTheme, SelectTheme, SemanticButtonTheme, SemanticContainerTheme, SemanticIconTheme, SideBarTheme, SkeletonTheme, StepperTheme, SwitchTheme, TableHeadingTheme, TableTheme, TabsTheme, TextButtonTheme, ThemeModeSwitchTheme, ToastTheme, ToggleButtonTheme, TooltipTheme, TreeViewTheme, TypoTheme, WindowBarTheme } from './components';
3
3
  import { BodyTheme, ScrollbarTheme } from './globals';
4
- export interface Theme extends Tokens {
5
- name: string;
4
+ import { ThemeCore } from './themeCore.types';
5
+ export interface Theme extends ThemeCore, Tokens {
6
6
  components: {
7
7
  actionIconButton: ActionIconButtonTheme;
8
8
  appBar: AppBarTheme;
@@ -25,9 +25,11 @@ export interface Theme extends Tokens {
25
25
  iconButton: IconButtonTheme;
26
26
  input: InputTheme;
27
27
  label: LabelTheme;
28
+ layouts: LayoutsTheme;
28
29
  link: LinkTheme;
29
30
  loader: LoaderTheme;
30
31
  menu: MenuTheme;
32
+ midBar: MidBarTheme;
31
33
  modal: ModalTheme;
32
34
  moreInfoIcon: MoreInfoIconTheme;
33
35
  popover: PopoverTheme;
@@ -49,6 +51,7 @@ export interface Theme extends Tokens {
49
51
  tableHeading: TableHeadingTheme;
50
52
  tabs: TabsTheme;
51
53
  textButton: TextButtonTheme;
54
+ themeModeSwitch: ThemeModeSwitchTheme;
52
55
  toast: ToastTheme;
53
56
  toggleButton: ToggleButtonTheme;
54
57
  tooltip: TooltipTheme;
@@ -0,0 +1,9 @@
1
+ /** Theme type that can be applied to an application */
2
+ export type ThemeMode = 'light' | 'dark';
3
+ /** Core Theme properties */
4
+ export type ThemeCore = {
5
+ name: string;
6
+ mode: ThemeMode;
7
+ };
8
+ /** Light-Dark theme pair */
9
+ export type ThemePair<T extends ThemeCore = ThemeCore> = Record<ThemeMode, T>;
package/dist/utils.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { ThemeMode, Theme, ThemeCore, ThemePair } from './themes';
1
2
  /**
2
3
  * This function is intended to be used only within CSS and not for plain color manipulations.
3
4
  * Opacity needs to be between 0 and 1.
@@ -10,3 +11,37 @@ export declare const withOpacity: (cssColor: string, opacity: number) => string;
10
11
  * @param base Any CSS color string.
11
12
  */
12
13
  export declare function withContrast(base: string): string;
14
+ /** Groups themes from pairs by mode */
15
+ export declare const groupThemesByMode: <T extends Theme>(themePairs: ThemePair<T>[]) => {
16
+ light: Theme[];
17
+ dark: Theme[];
18
+ };
19
+ /** Makes flat array of themes from pairs */
20
+ export declare const getThemesFlatList: <T extends ThemeCore>(themePairs: ThemePair<T>[]) => T[];
21
+ /** converts flat theme array to the map by name with theme pair as value */
22
+ export declare const groupFlatByNameAndMode: <T extends ThemeCore>(themeList: T[]) => Record<string, ThemePair<T>>;
23
+ /** converts flat theme array to the map by mode with theme list as value */
24
+ export declare const groupFlatByMode: <T extends ThemeCore>(themeList: T[]) => Record<ThemeMode, T[]>;
25
+ export type ThemesForSearch<T extends ThemeCore> = {
26
+ groupedByName: Record<string, ThemePair<T>>;
27
+ groupedByMode: Record<ThemeMode, T[]>;
28
+ };
29
+ /**
30
+ * Prepares theme list for quick search by existing parameters.
31
+ * Converts flat list to maps by name and mode for quick access.
32
+ *
33
+ * Place default themes first in list. they will be taken if nothing is found.
34
+ * @param themeList - flat array of themes
35
+ */
36
+ export declare const prepareThemesForSearch: <T extends ThemeCore>(themeList: T[]) => ThemesForSearch<T>;
37
+ /**
38
+ * Quick search for most suitable theme by optional theme name and/or mode.
39
+ * If not found, use your default one.
40
+ *
41
+ * Receives pre-grouped theme lists. Build them statically (out of components and hooks)
42
+ * from flat array of your themes, using `prepareThemesForSearch`
43
+ * @param themes - use `prepareThemesForSearch` to build this (build it statically)
44
+ * @param themeName - theme name, if exists
45
+ * @param themeMode - theme mode, if exists
46
+ */
47
+ export declare const findThemeByNameAndMode: <T extends ThemeCore>(themes: ThemesForSearch<T>, themeName: string | undefined, themeMode: ThemeMode | undefined) => T | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@redis-ui/styles",
3
3
  "license": "UNLICENSED",
4
- "version": "13.3.2",
4
+ "version": "14.5.3",
5
5
  "publishConfig": {
6
6
  "registry": "https://npm.pkg.github.com/"
7
7
  },
@@ -1,20 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { Theme } from '../../themes/types';
3
- import { UseThemeSelectorParams } from './useThemeSelector';
4
- import { UseStorageParams } from './useStorage';
5
- export interface ThemeSwitchContextParams extends Pick<UseThemeSelectorParams, 'systemThemeName' | 'lightThemeName' | 'darkThemeName'> {
6
- selectedTheme: string;
7
- setSelectedTheme: (themeName: string) => void;
8
- }
9
- interface ThemeSwitchProviderProps extends ThemeSwitchContextParams {
10
- children: ReactNode;
11
- }
12
- export declare const ThemeSwitchProvider: ({ children, selectedTheme, setSelectedTheme, lightThemeName, darkThemeName, systemThemeName }: ThemeSwitchProviderProps) => import("react/jsx-runtime").JSX.Element;
13
- export declare const useThemeSwitchContext: () => ThemeSwitchContextParams;
14
- interface SwitchableThemeProviderProps extends Pick<UseThemeSelectorParams, 'systemThemeName' | 'initialThemeName'>, Pick<UseStorageParams, 'storageKey'> {
15
- children: ReactNode;
16
- lightTheme: Theme;
17
- darkTheme: Theme;
18
- }
19
- export declare const SwitchableThemeProvider: ({ children, lightTheme, darkTheme, systemThemeName, initialThemeName, storageKey }: SwitchableThemeProviderProps) => import("react/jsx-runtime").JSX.Element;
20
- export {};
@@ -1,3 +0,0 @@
1
- export * from './useThemeSelector';
2
- export * from './useStorage';
3
- export * from './SwitchableThemeProvider';
@@ -1,9 +0,0 @@
1
- export type UseStorageParams = {
2
- storageKey: string;
3
- value: string;
4
- onChange: (value: string) => void;
5
- };
6
- export declare const useStorage: ({ value, ...params }: UseStorageParams) => {
7
- readFromStorage: () => string;
8
- saveToStorage: (newValue: string) => void;
9
- };
@@ -1,26 +0,0 @@
1
- export type UseThemeSelectorParams = {
2
- /**
3
- * One of valid theme names, defined in other parameters: light/dark/system.
4
- */
5
- initialThemeName?: string;
6
- /**
7
- * Name of the light theme
8
- */
9
- lightThemeName: string;
10
- /**
11
- * Name of the dark theme
12
- */
13
- darkThemeName: string;
14
- /**
15
- * Optional name of the system theme.
16
- * This can be any string, just to define the value for the storage and theme identifier.
17
- * If it is defined, then it can be used as initialThemeName and can be selected by user.
18
- * If system theme is selected, the current browser theme will be monitored and applied to the app.
19
- */
20
- systemThemeName?: string;
21
- };
22
- export declare const useThemeSelector: (params: UseThemeSelectorParams) => {
23
- setSelectedTheme: (newSelection: string) => boolean;
24
- selectedTheme: string;
25
- currentTheme: string;
26
- };