@apia/theme 0.2.2 → 0.3.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/LICENSE.md CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) [year] [fullname]
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) [year] [fullname]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
package/cleanDist.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "cleanDist": 0.006456232710121412
3
+ }
package/dist/index.d.ts CHANGED
@@ -90,11 +90,11 @@ interface TStates {
90
90
  }
91
91
  type TGetColorStateDefinition = Pick<ThemeUICSSObject, 'backgroundColor' | 'borderColor' | 'borderLeftColor' | 'borderRightColor' | 'borderBottomColor' | 'borderTopColor' | 'color'>;
92
92
  type TParsedPaletteColorStateRetriever = (color: string, state: keyof TStates) => string;
93
- type TColorStateRetriever = (color: string, state: keyof TStates, theme: Theme) => string;
93
+ type TColorStateRetriever = (color: string, state: keyof TStates, palette: TParsedPalette) => string;
94
94
  type TParsedPaletteStateRetriever = (definition: Partial<TGetColorStateDefinition>, state: keyof TStates) => TGetColorStateDefinition;
95
- type TStateRetriever = (definition: Partial<TGetColorStateDefinition>, state: keyof TStates, theme: Theme) => TGetColorStateDefinition;
95
+ type TStateRetriever = (definition: Partial<TGetColorStateDefinition>, state: keyof TStates, palette: TParsedPalette) => TGetColorStateDefinition;
96
96
  type TParsedPaletteStatesRetriever = (definition: Partial<TGetColorStateDefinition>, states?: TStates) => ThemeUICSSObject;
97
- type TStatesRetriever = (definition: Partial<TGetColorStateDefinition>, theme: Theme, states?: TStates) => ThemeUICSSObject;
97
+ type TStatesRetriever = (definition: Partial<TGetColorStateDefinition>, palette: TParsedPalette, states?: TStates) => ThemeUICSSObject;
98
98
  type TParsedPaletteStatesByDefinition = (definition: Partial<TGetColorStateDefinition>, options?: TGetColorsAndStatesOptions) => ThemeUICSSObject;
99
99
  type TApplyStates = (properties: Record<string, TColorDefinition | string | Record<string, unknown>>[], theme: Theme, states?: TStates) => void;
100
100
  interface TActionDefinition<OpacityColor = undefined | string | IActionOpacity> {
@@ -122,6 +122,7 @@ interface TPalette<ColorDefinition = IColorDefinition, ColorModifier = TColorMod
122
122
  border: {
123
123
  article: string;
124
124
  field: string;
125
+ ghost: string;
125
126
  section: string;
126
127
  };
127
128
  common: {
@@ -191,7 +192,11 @@ type TParsedPalette = Required<TPalette<Required<IColorDefinition>, TColorModifi
191
192
  getStatesFromDefinition: TParsedPaletteStatesByDefinition;
192
193
  getStatesFromPath: typeof getColorsAndStatesByPath;
193
194
  getSelectedColors: () => ThemeUICSSObject;
195
+ getColorsByPath: (path: string, options?: {
196
+ mergeObject?: Record<string, any>;
197
+ }) => TGetColorStateDefinition & Record<string, any>;
194
198
  };
199
+ type TCustomPalette = Partial<TPalette> & Partial<Pick<TParsedPalette, 'applyStates' | 'buildColorsObject' | 'buildStateObject' | 'getColor' | 'getColorStates' | 'getSelectedColors' | 'getContrastText' | 'getOneState' | 'getStatesForColors' | 'getStatesFromDefinition' | 'getStatesFromPath'>>;
195
200
  type TColorDefinitionPrimitive = Pick<ThemeUICSSObject, 'color' | 'backgroundColor' | 'borderColor'>;
196
201
  type TColorDefinition = TColorDefinitionPrimitive & {
197
202
  active?: TColorDefinitionPrimitive;
@@ -208,9 +213,10 @@ declare global {
208
213
  customPalette?: TPalette;
209
214
  defaultPalette?: TPalette;
210
215
  }
211
- }
216
+ }
217
+ type TThemeModifier = (theme: Theme) => Theme;
212
218
 
213
- declare function parsePalette(palette: TPalette, theme: Theme): TParsedPalette;
219
+ declare function parsePalette(palette: TCustomPalette): TParsedPalette;
214
220
 
215
221
  type CustomTheme = Omit<Theme, 'palette'>;
216
222
 
@@ -245,7 +251,7 @@ declare const getColorStates: TStatesRetriever;
245
251
  * Esta función calcula los colores de los estados a partir de la definición
246
252
  * pasada.
247
253
  */
248
- declare function getColorsAndStatesByDefinition(definition: Partial<TGetColorStateDefinition>, theme: Theme, options?: TGetColorsAndStatesOptions): ThemeUICSSObject;
254
+ declare function getColorsAndStatesByDefinition(definition: Partial<TGetColorStateDefinition>, palette: TParsedPalette, options?: TGetColorsAndStatesOptions): ThemeUICSSObject;
249
255
 
250
256
  /**
251
257
  * Esta función arma un objeto con los colores que se deben aplicar para
@@ -291,7 +297,7 @@ declare function getColorsByPath(path: string, options?: {
291
297
  */
292
298
  declare const getOneColorState: TColorStateRetriever;
293
299
 
294
- declare function useMainTheme(customTheme?: CustomTheme, customPalette?: TPalette): Theme;
300
+ declare function useMainTheme(customTheme?: () => CustomTheme, customPalette?: TCustomPalette, themeModifier?: TThemeModifier): Theme;
295
301
 
296
302
  /**
297
303
  * Permite crear un componente cuyos estilos pueden ser redefinidos por un
@@ -346,12 +352,34 @@ declare function injectStyles(path: string, styles: ThemeUICSSObject): void;
346
352
  */
347
353
  declare function injectStyles(styles: ThemeUICSSObject): void;
348
354
 
355
+ declare const spacingLayouts: readonly ["dense", "clever", "vertical__clever", "horizontal__clever"];
356
+ type TSpacingLayout = (typeof spacingLayouts)[number];
357
+ declare function getSpacingLayouts(): {
358
+ '&.dense': {
359
+ px: number;
360
+ py: number;
361
+ };
362
+ '&.horizontal__clever': {
363
+ px: number;
364
+ py: number;
365
+ };
366
+ '&.vertical__clever': {
367
+ px: number;
368
+ py: number;
369
+ };
370
+ '&.clever': {
371
+ px: number;
372
+ py: number;
373
+ };
374
+ };
375
+
349
376
  interface TThemeProvider {
350
377
  children: ReactNode;
351
- customTheme?: Omit<Theme, 'palette'>;
352
- customPalette?: TPalette;
378
+ customTheme?: () => Omit<Theme, 'palette'>;
379
+ customPalette?: TCustomPalette;
380
+ themeModifier?: TThemeModifier;
353
381
  }
354
- declare const ApiaThemeProvider: ({ children, customTheme, customPalette, }: TThemeProvider) => react.JSX.Element;
382
+ declare const ApiaThemeProvider: ({ children, customTheme, customPalette, themeModifier, }: TThemeProvider) => react.JSX.Element;
355
383
 
356
384
  declare module 'theme-ui' {
357
385
  interface Theme {
@@ -359,4 +387,4 @@ declare module 'theme-ui' {
359
387
  }
360
388
  }
361
389
 
362
- export { ApiaThemeProvider, CustomTheme, TColorDefinition, TPalette, TParsedPalette, applyStatesGetColor, focusOutline, getColorState, getColorStates, getColorsAndStatesByDefinition, getColorsAndStatesByPath, getColorsByDefinition, getColorsByPath, getOneColorState, getVariant, injectStyles, makeStyledComponent, parsePalette, responsive, smallButton, spacing, useMainTheme };
390
+ export { ApiaThemeProvider, CustomTheme, TColorDefinition, TPalette, TParsedPalette, TSpacingLayout, TThemeModifier, applyStatesGetColor, focusOutline, getColorState, getColorStates, getColorsAndStatesByDefinition, getColorsAndStatesByPath, getColorsByDefinition, getColorsByPath, getOneColorState, getSpacingLayouts, getVariant, injectStyles, makeStyledComponent, parsePalette, responsive, smallButton, spacing, spacingLayouts, useMainTheme };