@udixio/theme 1.0.0-beta.7 → 1.0.0-beta.9

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 (63) hide show
  1. package/dist/app.service.d.ts +6 -3
  2. package/dist/color/color.interface.d.ts +1 -2
  3. package/dist/color/entities/color.entity.d.ts +6 -1
  4. package/dist/color/index.d.ts +1 -2
  5. package/dist/color/models/default-color.model.d.ts +2 -3
  6. package/dist/color/services/color-manager.service.d.ts +18 -0
  7. package/dist/color/services/color.service.d.ts +21 -0
  8. package/dist/color/services/index.d.ts +2 -0
  9. package/dist/config/config.interface.d.ts +13 -0
  10. package/dist/config/config.module.d.ts +2 -0
  11. package/dist/config/config.service.d.ts +12 -0
  12. package/dist/config/index.d.ts +2 -0
  13. package/dist/index.d.ts +1 -0
  14. package/dist/main.d.ts +2 -1
  15. package/dist/plugin/plugin.abstract.d.ts +6 -0
  16. package/dist/plugin/plugin.module.d.ts +2 -0
  17. package/dist/plugin/plugin.service.d.ts +10 -0
  18. package/dist/plugins/tailwind/Tailwind.plugin.d.ts +14 -0
  19. package/dist/plugins/tailwind/main.d.ts +10 -0
  20. package/dist/plugins/tailwind/plugins-tailwind/state.d.ts +4 -0
  21. package/dist/plugins/tailwind/plugins-tailwind/themer.d.ts +4 -0
  22. package/dist/theme/entities/variant.entity.d.ts +2 -1
  23. package/dist/theme/services/scheme.service.d.ts +7 -2
  24. package/dist/theme/services/theme.service.d.ts +10 -4
  25. package/dist/theme/services/variant.service.d.ts +4 -0
  26. package/dist/theme.cjs.development.js +1081 -506
  27. package/dist/theme.cjs.development.js.map +1 -1
  28. package/dist/theme.cjs.production.min.js +1 -1
  29. package/dist/theme.cjs.production.min.js.map +1 -1
  30. package/dist/theme.esm.js +1079 -507
  31. package/dist/theme.esm.js.map +1 -1
  32. package/package.json +4 -3
  33. package/src/app.container.ts +9 -1
  34. package/src/app.service.ts +8 -2
  35. package/src/color/color.interface.ts +1 -3
  36. package/src/color/color.module.ts +2 -2
  37. package/src/color/entities/color.entity.ts +13 -1
  38. package/src/color/index.ts +1 -2
  39. package/src/color/models/default-color.model.ts +205 -202
  40. package/src/color/{color-manager.service.ts → services/color-manager.service.ts} +17 -10
  41. package/src/color/{color.service.spec.ts → services/color.service.spec.ts} +1 -1
  42. package/src/color/{color.service.ts → services/color.service.ts} +33 -21
  43. package/src/color/services/index.ts +2 -0
  44. package/src/config/config.interface.ts +14 -0
  45. package/src/config/config.module.ts +7 -0
  46. package/src/config/config.service.ts +74 -0
  47. package/src/config/index.ts +2 -0
  48. package/src/index.ts +1 -0
  49. package/src/main.ts +9 -1
  50. package/src/plugin/plugin.abstract.ts +8 -0
  51. package/src/plugin/plugin.module.ts +7 -0
  52. package/src/plugin/plugin.service.ts +30 -0
  53. package/src/plugins/tailwind/Tailwind.plugin.ts +53 -0
  54. package/src/plugins/tailwind/main.ts +18 -0
  55. package/src/plugins/tailwind/plugins-tailwind/state.ts +88 -0
  56. package/src/plugins/tailwind/plugins-tailwind/themer.ts +53 -0
  57. package/src/theme/entities/variant.entity.ts +2 -1
  58. package/src/theme/models/variant.model.ts +7 -0
  59. package/src/theme/services/scheme.service.ts +31 -7
  60. package/src/theme/services/theme.service.ts +18 -8
  61. package/src/theme/services/variant.service.ts +36 -2
  62. package/dist/color/color-manager.service.d.ts +0 -17
  63. package/dist/color/color.service.d.ts +0 -16
@@ -1,10 +1,13 @@
1
- import { ColorService } from './color/color.service';
2
- import { ThemeService } from './theme/services/theme.service';
1
+ import { ColorService } from './color';
2
+ import { ThemeService } from './theme';
3
+ import { PluginService } from './plugin/plugin.service';
3
4
  export declare class AppService {
4
5
  colorService: ColorService;
5
6
  themeService: ThemeService;
6
- constructor({ colorService, themeService, }: {
7
+ pluginService: PluginService;
8
+ constructor({ colorService, themeService, pluginService, }: {
7
9
  colorService: ColorService;
8
10
  themeService: ThemeService;
11
+ pluginService: PluginService;
9
12
  });
10
13
  }
@@ -4,6 +4,5 @@ export interface ColorInterface {
4
4
  removeColor(key: string): boolean;
5
5
  getColor(key: string): ColorEntity;
6
6
  updateColor(key: string, newColor: ColorOptions): ColorEntity;
7
- getAllColors(): ReadonlyMap<string, ColorEntity>;
8
- addColors(colors: Record<string, ColorOptions>): ColorEntity[];
7
+ getColors(): ReadonlyMap<string, ColorEntity>;
9
8
  }
@@ -3,7 +3,7 @@ import { SchemeEntity } from '../../theme/entities/scheme.entity';
3
3
  import { DynamicColor } from '../../material-color-utilities/dynamic_color';
4
4
  import { ContrastCurve } from '../../material-color-utilities';
5
5
  import { SchemeService } from '../../theme/services/scheme.service';
6
- import { ColorManagerService } from '../color-manager.service';
6
+ import { ColorManagerService } from '../services/color-manager.service';
7
7
  export interface ColorOptions {
8
8
  palette: (scheme: SchemeEntity) => TonalPalette;
9
9
  tone: (scheme: SchemeEntity) => number;
@@ -32,6 +32,11 @@ export declare class ColorEntity {
32
32
  }>): void;
33
33
  getHex(): string;
34
34
  getArgb(): number;
35
+ getRgb(): {
36
+ r: number;
37
+ g: number;
38
+ b: number;
39
+ };
35
40
  getName(): string;
36
41
  getDynamicColor(): DynamicColor;
37
42
  }
@@ -1,6 +1,5 @@
1
- export * from './color-manager.service';
2
1
  export * from './color.interface';
3
2
  export * from './color.module';
4
- export * from './color.service';
5
3
  export * from './entities';
6
4
  export * from './models';
5
+ export * from './services';
@@ -1,4 +1,3 @@
1
- import { ColorOptions } from '../entities/color.entity';
2
- import { ColorManagerService } from '../color-manager.service';
1
+ import { AddColorsOptions } from '../services/color.service';
3
2
  export type DynamicColorKey = 'background' | 'onBackground' | 'surface' | 'surfaceDim' | 'surfaceBright' | 'surfaceContainerLowest' | 'surfaceContainerLow' | 'surfaceContainer' | 'surfaceContainerHigh' | 'surfaceContainerHighest' | 'onSurface' | 'surfaceVariant' | 'onSurfaceVariant' | 'inverseSurface' | 'inverseOnSurface' | 'outline' | 'outlineVariant' | 'shadow' | 'scrim' | 'surfaceTint' | 'primary' | 'onPrimary' | 'primaryContainer' | 'onPrimaryContainer' | 'inversePrimary' | 'secondary' | 'onSecondary' | 'secondaryContainer' | 'onSecondaryContainer' | 'tertiary' | 'onTertiary' | 'tertiaryContainer' | 'onTertiaryContainer' | 'error' | 'onError' | 'errorContainer' | 'onErrorContainer' | 'primaryFixed' | 'primaryFixedDim' | 'onPrimaryFixed' | 'onPrimaryFixedVariant' | 'secondaryFixed' | 'secondaryFixedDim' | 'onSecondaryFixed' | 'onSecondaryFixedVariant' | 'tertiaryFixed' | 'tertiaryFixedDim' | 'onTertiaryFixed' | 'onTertiaryFixedVariant';
4
- export declare const defaultColors: (colorManagerService: ColorManagerService) => Partial<Record<DynamicColorKey, Partial<ColorOptions>>>;
3
+ export declare const defaultColors: AddColorsOptions;
@@ -0,0 +1,18 @@
1
+ import { DynamicColor } from '../../material-color-utilities/dynamic_color';
2
+ import { SchemeEntity } from '../../theme/entities/scheme.entity';
3
+ import { ColorEntity, ColorOptions } from '../entities/color.entity';
4
+ import { SchemeService } from '../../theme/services/scheme.service';
5
+ import { ColorService } from './color.service';
6
+ export declare const highestSurface: (s: SchemeEntity, colorService: ColorManagerService | ColorService) => DynamicColor;
7
+ export declare class ColorManagerService {
8
+ private colorMap;
9
+ private readonly schemeService;
10
+ constructor({ schemeService }: {
11
+ schemeService: SchemeService;
12
+ });
13
+ createOrUpdate(key: string, args: Partial<ColorOptions>): ColorEntity;
14
+ remove(key: string): boolean;
15
+ get(key: string): ColorEntity;
16
+ getAll(): ReadonlyMap<string, ColorEntity>;
17
+ addFromPalette(key: string): void;
18
+ }
@@ -0,0 +1,21 @@
1
+ import { ColorManagerService } from './color-manager.service';
2
+ import { ColorInterface } from '../color.interface';
3
+ import { ColorEntity, ColorOptions } from '../entities';
4
+ type AddColors = {
5
+ colors?: Record<string, Partial<ColorOptions>>;
6
+ fromPalettes?: string[] | string;
7
+ };
8
+ export type AddColorsOptions = AddColors | ((colorService: ColorService) => AddColors);
9
+ export declare class ColorService implements ColorInterface {
10
+ private readonly colorManagerService;
11
+ constructor({ colorManagerService, }: {
12
+ colorManagerService: ColorManagerService;
13
+ });
14
+ getColors(): ReadonlyMap<string, ColorEntity>;
15
+ addColor(key: string, color: Partial<ColorOptions>): ColorEntity;
16
+ addColors(args: AddColorsOptions | AddColorsOptions[]): void;
17
+ getColor(key: string): ColorEntity;
18
+ removeColor(key: string): boolean;
19
+ updateColor(key: string, newColor: Partial<ColorOptions>): ColorEntity;
20
+ }
21
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './color-manager.service';
2
+ export * from './color.service';
@@ -0,0 +1,13 @@
1
+ import { VariantEntity } from '../theme';
2
+ import { AddColorsOptions } from '../color';
3
+ import { PluginConstructor } from '../plugin/plugin.service';
4
+ export interface ConfigInterface {
5
+ sourceColor: string;
6
+ contrastLevel?: 0;
7
+ isDark?: boolean;
8
+ variant?: VariantEntity;
9
+ colors?: AddColorsOptions | AddColorsOptions[];
10
+ useDefaultColors?: boolean;
11
+ palettes?: Record<string, string>;
12
+ plugins?: (PluginConstructor | [PluginConstructor, object])[];
13
+ }
@@ -0,0 +1,2 @@
1
+ import { Module } from '../app.container';
2
+ export declare const ConfigModule: Module;
@@ -0,0 +1,12 @@
1
+ import { ConfigInterface } from './config.interface';
2
+ import { AppService } from '../app.service';
3
+ export declare function defineConfig(configObject: ConfigInterface): ConfigInterface;
4
+ export declare class ConfigService {
5
+ configPath: string;
6
+ private appService;
7
+ constructor({ appService }: {
8
+ appService: AppService;
9
+ });
10
+ loadConfig(): Promise<void>;
11
+ private getConfig;
12
+ }
@@ -0,0 +1,2 @@
1
+ export * from './config.interface';
2
+ export * from './config.service';
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from './app.container';
3
3
  export * from './app.module';
4
4
  export * from './app.service';
5
5
  export * from './color';
6
+ export * from './config';
6
7
  export * from './main';
7
8
  export * from './material-color-utilities';
8
9
  export * from './theme';
package/dist/main.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  import { AppService } from './app.service';
2
- export declare function main(): AppService;
2
+ export declare function bootstrap(): AppService;
3
+ export declare function bootstrapFromConfig(path?: string): Promise<AppService>;
@@ -0,0 +1,6 @@
1
+ import { AppService } from '../app.service';
2
+ export declare abstract class PluginAbstract {
3
+ static dependencies: (new () => PluginAbstract)[];
4
+ protected abstract appService: AppService;
5
+ protected abstract options: object;
6
+ }
@@ -0,0 +1,2 @@
1
+ import { Module } from '../app.container';
2
+ export declare const PluginModule: Module;
@@ -0,0 +1,10 @@
1
+ import { PluginAbstract } from './plugin.abstract';
2
+ import { AppService } from '../app.service';
3
+ export type PluginConstructor = new (appService: AppService, options: any) => PluginAbstract;
4
+ export declare class PluginService {
5
+ private pluginInstances;
6
+ private pluginConstructors;
7
+ addPlugin(plugin: PluginConstructor, config: object): void;
8
+ loadPlugins(appService: AppService): void;
9
+ getPlugin<T extends PluginAbstract>(plugin: new (appService: AppService, options: any) => T): T;
10
+ }
@@ -0,0 +1,14 @@
1
+ import { PluginAbstract } from '../../plugin/plugin.abstract';
2
+ import { AppService } from '../../app.service';
3
+ import { Theme } from './main';
4
+ interface TailwindPluginOptions {
5
+ darkMode: 'class' | 'media';
6
+ }
7
+ export declare class TailwindPlugin extends PluginAbstract {
8
+ protected appService: AppService;
9
+ protected options: TailwindPluginOptions;
10
+ constructor(appService: AppService, options: TailwindPluginOptions);
11
+ static config(options: TailwindPluginOptions): TailwindPluginOptions;
12
+ getTheme(): Theme;
13
+ }
14
+ export {};
@@ -0,0 +1,10 @@
1
+ import { PluginsConfig } from 'tailwindcss/types/config';
2
+ export type Theme = {
3
+ colors: Record<string, string>;
4
+ fontFamily: {
5
+ expressive: string[];
6
+ neutral: string[];
7
+ };
8
+ plugins: Partial<PluginsConfig>;
9
+ };
10
+ export declare const createTheme: () => Promise<Theme>;
@@ -0,0 +1,4 @@
1
+ export declare const state: (colorkeys: string[]) => {
2
+ handler: import("tailwindcss/types/config").PluginCreator;
3
+ config?: Partial<import("tailwindcss/types/config").Config>;
4
+ };
@@ -0,0 +1,4 @@
1
+ export declare const themer: (colors: Record<string, {
2
+ light: string;
3
+ dark: string;
4
+ }>, darkMode: "class" | "media") => any;
@@ -2,5 +2,6 @@ import { Hct, TonalPalette } from '@material/material-color-utilities';
2
2
  export declare const getRotatedHue: (sourceColor: Hct, hues: number[], rotations: number[]) => number;
3
3
  export declare class VariantEntity {
4
4
  palettes: Record<string, (sourceColorHct: Hct) => TonalPalette>;
5
- constructor(palettes?: Record<string, (sourceColorHct: Hct) => TonalPalette>);
5
+ customPalettes?: ((colorHct: Hct) => TonalPalette) | undefined;
6
+ constructor(palettes?: Record<string, (sourceColorHct: Hct) => TonalPalette>, customPalettes?: ((colorHct: Hct) => TonalPalette) | undefined);
6
7
  }
@@ -1,8 +1,13 @@
1
1
  import { SchemeEntity, SchemeOptions } from '../entities/scheme.entity';
2
2
  import { Hct, TonalPalette } from '@material/material-color-utilities';
3
3
  export type SchemeServiceOptions = Omit<SchemeOptions, 'palettes' | 'sourceColorArgb'> & {
4
- sourceColorHex: string;
5
- palettes: Record<string, (sourceColorHct: Hct) => TonalPalette>;
4
+ sourcesColorHex: Record<string, string> & {
5
+ primary?: string;
6
+ };
7
+ palettes: Record<string, {
8
+ sourceColorkey?: string;
9
+ tonalPalette: (sourceColorHct: Hct) => TonalPalette;
10
+ }>;
6
11
  };
7
12
  export declare class SchemeService {
8
13
  private schemeEntity?;
@@ -1,7 +1,9 @@
1
1
  import { SchemeService, SchemeServiceOptions } from './scheme.service';
2
2
  import { VariantService } from './variant.service';
3
3
  import { VariantEntity } from '../entities/variant.entity';
4
- type ThemeOptions = Omit<SchemeServiceOptions, 'palettes'>;
4
+ type ThemeOptions = Omit<SchemeServiceOptions, 'palettes' | 'sourcesColorHex'> & {
5
+ sourceColorHex: string;
6
+ };
5
7
  export declare class ThemeService {
6
8
  private readonly schemeService;
7
9
  private readonly variantService;
@@ -9,8 +11,12 @@ export declare class ThemeService {
9
11
  schemeService: SchemeService;
10
12
  variantService: VariantService;
11
13
  });
12
- create(options: ThemeOptions): void;
13
- addVariant(variant: VariantEntity): void;
14
- update(options: Partial<ThemeOptions>): void;
14
+ create(options: ThemeOptions & {
15
+ variant: VariantEntity;
16
+ }): void;
17
+ update(options: Partial<ThemeOptions> & {
18
+ variant?: VariantEntity;
19
+ }): void;
20
+ addCustomPalette(key: string, colorHex: string): void;
15
21
  }
16
22
  export {};
@@ -1,9 +1,13 @@
1
1
  import { SchemeService } from './scheme.service';
2
2
  import { VariantEntity } from '../entities/variant.entity';
3
3
  export declare class VariantService {
4
+ customPalettes: Record<string, string>;
5
+ private variantEntity?;
4
6
  private readonly schemeService;
5
7
  constructor({ schemeService }: {
6
8
  schemeService: SchemeService;
7
9
  });
10
+ addCustomPalette(key: string, colorHex: string): void;
8
11
  set(variantEntity: VariantEntity): void;
12
+ private update;
9
13
  }