@udixio/theme 1.0.0-beta.8 → 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.
@@ -1,7 +1,6 @@
1
1
  import { VariantEntity } from '../theme';
2
2
  import { AddColorsOptions } from '../color';
3
- import { PluginAbstract } from '../plugin/plugin.abstract';
4
- import { AppService } from '../app.service';
3
+ import { PluginConstructor } from '../plugin/plugin.service';
5
4
  export interface ConfigInterface {
6
5
  sourceColor: string;
7
6
  contrastLevel?: 0;
@@ -10,5 +9,5 @@ export interface ConfigInterface {
10
9
  colors?: AddColorsOptions | AddColorsOptions[];
11
10
  useDefaultColors?: boolean;
12
11
  palettes?: Record<string, string>;
13
- plugins?: (new (appService: AppService) => PluginAbstract)[];
12
+ plugins?: (PluginConstructor | [PluginConstructor, object])[];
14
13
  }
@@ -1,6 +1,6 @@
1
1
  import { AppService } from '../app.service';
2
2
  export declare abstract class PluginAbstract {
3
- protected appService: AppService;
4
3
  static dependencies: (new () => PluginAbstract)[];
5
- protected constructor(appService: AppService);
4
+ protected abstract appService: AppService;
5
+ protected abstract options: object;
6
6
  }
@@ -1,9 +1,10 @@
1
1
  import { PluginAbstract } from './plugin.abstract';
2
2
  import { AppService } from '../app.service';
3
+ export type PluginConstructor = new (appService: AppService, options: any) => PluginAbstract;
3
4
  export declare class PluginService {
4
5
  private pluginInstances;
5
6
  private pluginConstructors;
6
- addPlugin(plugin: new (appService: AppService) => PluginAbstract): void;
7
+ addPlugin(plugin: PluginConstructor, config: object): void;
7
8
  loadPlugins(appService: AppService): void;
8
- getPlugin<T extends PluginAbstract>(plugin: new (appService: AppService) => T): T | undefined;
9
+ getPlugin<T extends PluginAbstract>(plugin: new (appService: AppService, options: any) => T): T;
9
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;
@@ -1834,7 +1834,11 @@ var ConfigService = /*#__PURE__*/function () {
1834
1834
  }
1835
1835
  if (plugins) {
1836
1836
  plugins.forEach(function (plugin) {
1837
- return pluginService.addPlugin(plugin);
1837
+ if (Array.isArray(plugin)) {
1838
+ pluginService.addPlugin(plugin[0], plugin[1]);
1839
+ } else {
1840
+ pluginService.addPlugin(plugin, {});
1841
+ }
1838
1842
  });
1839
1843
  pluginService.loadPlugins(this.appService);
1840
1844
  }
@@ -1886,17 +1890,21 @@ var PluginService = /*#__PURE__*/function () {
1886
1890
  this.pluginConstructors = new Map();
1887
1891
  }
1888
1892
  var _proto = PluginService.prototype;
1889
- _proto.addPlugin = function addPlugin(plugin) {
1890
- this.pluginConstructors.set(plugin.name, plugin);
1893
+ _proto.addPlugin = function addPlugin(plugin, config) {
1894
+ this.pluginConstructors.set(plugin.name, [plugin, config]);
1891
1895
  };
1892
1896
  _proto.loadPlugins = function loadPlugins(appService) {
1893
1897
  var _this = this;
1894
- this.pluginConstructors.forEach(function (plugin) {
1895
- _this.pluginInstances.set(plugin.name, new plugin(appService));
1898
+ this.pluginConstructors.forEach(function (_ref) {
1899
+ var plugin = _ref[0],
1900
+ option = _ref[1];
1901
+ _this.pluginInstances.set(plugin.name, new plugin(appService, option));
1896
1902
  });
1897
1903
  };
1898
1904
  _proto.getPlugin = function getPlugin(plugin) {
1899
- return this.pluginInstances.get(plugin.name);
1905
+ var pluginInstance = this.pluginInstances.get(plugin.name);
1906
+ if (!pluginInstance) throw new Error("Plugin " + plugin.name + " not found");
1907
+ return pluginInstance;
1900
1908
  };
1901
1909
  return PluginService;
1902
1910
  }();