@vitus-labs/unistyle 0.23.0 → 0.25.0-alpha.2

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 (32) hide show
  1. package/lib/analysis/vitus-labs-unistyle.browser.js.html +1 -1
  2. package/lib/analysis/vitus-labs-unistyle.js.html +1 -1
  3. package/lib/analysis/vitus-labs-unistyle.module.js.html +1 -1
  4. package/lib/analysis/vitus-labs-unistyle.native.js.html +1 -1
  5. package/lib/analysis/vitus-labs-unistyle.umd.js.html +1 -1
  6. package/lib/analysis/vitus-labs-unistyle.umd.min.js.html +1 -1
  7. package/lib/index.d.ts +20 -25
  8. package/lib/types/index.d.ts +2 -3
  9. package/lib/types/responsive/createMediaQueries.d.ts +1 -1
  10. package/lib/types/styles/extendCss.d.ts +1 -1
  11. package/lib/types/styles/shorthands/index.d.ts +4 -0
  12. package/lib/types/styles/shorthands/insetShorthand.d.ts +12 -0
  13. package/lib/types/styles/shorthands/spacingShorthand.d.ts +12 -0
  14. package/lib/types/styles/styles/types.d.ts +11 -11
  15. package/lib/types/styles/styles/utils.d.ts +11 -0
  16. package/lib/types/types.d.ts +6 -0
  17. package/lib/types/units/value.d.ts +2 -1
  18. package/lib/vitus-labs-unistyle.browser.js +166 -41
  19. package/lib/vitus-labs-unistyle.browser.js.map +1 -1
  20. package/lib/vitus-labs-unistyle.js +163 -35
  21. package/lib/vitus-labs-unistyle.js.map +1 -1
  22. package/lib/vitus-labs-unistyle.module.js +166 -41
  23. package/lib/vitus-labs-unistyle.module.js.map +1 -1
  24. package/lib/vitus-labs-unistyle.native.js +166 -41
  25. package/lib/vitus-labs-unistyle.native.js.map +1 -1
  26. package/lib/vitus-labs-unistyle.umd.js +163 -35
  27. package/lib/vitus-labs-unistyle.umd.js.map +1 -1
  28. package/lib/vitus-labs-unistyle.umd.min.js +158 -170
  29. package/lib/vitus-labs-unistyle.umd.min.js.map +1 -1
  30. package/package.json +3 -3
  31. package/lib/types/hooks/index.d.ts +0 -3
  32. package/lib/types/hooks/useWindowResize.d.ts +0 -9
package/lib/index.d.ts CHANGED
@@ -13,15 +13,6 @@ declare type TProvider = {
13
13
  } & Partial<Record<string, unknown>>;
14
14
  declare const Provider: FC<TProvider>;
15
15
 
16
- declare type UseWindowResize = (throttleDelay?: number, defaultValues?: Partial<{
17
- width: number;
18
- height: number;
19
- }>) => {
20
- width: number;
21
- height: number;
22
- };
23
- declare const useWindowResize: UseWindowResize;
24
-
25
16
  declare const breakpoints: {
26
17
  readonly rootSize: 16;
27
18
  readonly breakpoints: {
@@ -35,14 +26,19 @@ declare const breakpoints: {
35
26
  };
36
27
  declare type Breakpoints = typeof breakpoints;
37
28
 
38
- declare type CreateMediaQueries = <B, R extends number, C extends (...args: any) => any>({ breakpoints, rootSize, css, }: {
29
+ declare type CreateMediaQueries = <B, R extends number, C extends (...args: any) => any>(props: {
39
30
  breakpoints: B;
40
31
  rootSize: R;
41
32
  css: C;
42
33
  }) => Record<keyof B, ReturnType<C>>;
43
34
  declare const createMediaQueries: CreateMediaQueries;
44
35
 
45
- declare type Css = typeof config.css;
36
+ declare type Css = typeof config.css;
37
+ declare type Defaults = 'initial' | 'inherit';
38
+ declare type Units = 'px' | 'rem' | 'em' | '%' | 'vh' | 'vw' | 'vmin' | 'vmax';
39
+ declare type UnitValue = number | `${number}${Units}`;
40
+ declare type Value$2 = UnitValue | 'auto' | Defaults;
41
+ declare type Color = `#${string | number}` | 'currentcolor' | 'transparent' | `rgb(${number}, ${number}, ${number})` | `rgba(${number}, ${number}, ${number}, ${number})` | `hsl(${number}, ${number}%, ${number}%)` | `hsla(${number}, ${number}%, ${number}%, ${number})` | Defaults;
46
42
 
47
43
  declare type SortBreakpoints = <T extends Record<string, number>>(breakpoints: T) => Array<keyof T>;
48
44
  declare const sortBreakpoints: SortBreakpoints;
@@ -85,10 +81,7 @@ declare type TransformTheme = ({ theme, breakpoints, }: {
85
81
  }) => any;
86
82
  declare const transformTheme: TransformTheme;
87
83
 
88
- declare type Value$2 = 'auto' | 'inital' | 'inherit' | number | string;
89
- declare type Defaults = 'initial' | 'inherit';
90
- declare type Length = number | string;
91
- declare type BorderColor = 'transparent' | string | Defaults;
84
+ declare type BorderColor = Color | Defaults;
92
85
  declare type BorderImageRepeat = 'stretch' | 'repeat' | 'round' | 'space' | Defaults;
93
86
  declare type TextDecoration = 'none' | 'underline' | 'overline' | 'line-through' | 'blink' | Defaults;
94
87
  declare type BorderStyle = 'none' | 'hidden' | 'dotted' | 'dashed' | 'solid' | 'double' | 'groove' | 'ridge' | 'inset' | 'outset' | Defaults;
@@ -96,8 +89,10 @@ declare type FontSize = 'medium' | 'xx-small' | 'x-small' | 'small' | 'large' |
96
89
  declare type ListStyleType = 'disc' | 'armenian' | 'circle' | 'cjk-ideographic' | 'decimal' | 'decimal-leading-zero' | 'georgian' | 'hebrew' | 'hiragana' | 'hiragana-iroha' | 'katakana' | 'katakana-iroha' | 'lower-alpha' | 'lower-greek' | 'lower-latin' | 'lower-roman' | 'none' | 'square' | 'upper-alpha' | 'upper-greek' | 'upper-latin' | 'upper-roman' | Defaults;
97
90
  declare type Overflow = 'visible' | 'hidden' | 'scroll' | 'auto' | Defaults;
98
91
  declare type Cursor = 'alias' | 'all-scroll' | 'auto' | 'cell' | 'context-menu' | 'col-resize' | 'copy' | 'crosshair' | 'default' | 'e-resize' | 'ew-resize' | 'grab' | 'grabbing' | 'help' | 'move' | 'n-resize' | 'ne-resize' | 'nesw-resize' | 'ns-resize' | 'nw-resize' | 'nwse-resize' | 'no-drop' | 'none' | 'not-allowed' | 'pointer' | 'progress' | 'row-resize' | 's-resize' | 'se-resize' | 'sw-resize' | 'text' | 'URL' | 'vertical-text' | 'w-resize' | 'wait' | 'zoom-in' | 'zoom-out' | Defaults;
99
- declare type ITheme = Partial<{
100
- inset: string;
92
+ declare type ITheme = {
93
+ inset: Value$2;
94
+ insetX: Value$2;
95
+ insetY: Value$2;
101
96
  top: Value$2;
102
97
  bottom: Value$2;
103
98
  left: Value$2;
@@ -136,7 +131,7 @@ declare type ITheme = Partial<{
136
131
  background: string;
137
132
  backgroundAttachment: 'scroll' | 'fixed' | Defaults;
138
133
  backgroundClip: 'border-box' | 'padding-box' | 'content-box' | Defaults;
139
- backgroundColor: string | 'transparent' | Defaults;
134
+ backgroundColor: Color;
140
135
  backgroundImage: string | 'none' | Defaults;
141
136
  backgroundOrigin: 'padding-box' | 'border-box' | 'content-box' | Defaults;
142
137
  backgroundPosition: any;
@@ -191,7 +186,7 @@ declare type ITheme = Partial<{
191
186
  clear: 'left' | 'right' | 'auto' | 'both' | 'none' | Defaults;
192
187
  clip: 'shape' | 'auto' | Defaults;
193
188
  clipPath: string;
194
- color: string;
189
+ color: Color;
195
190
  content: 'normal' | 'none' | 'counter' | 'open-quote' | 'close-quote' | 'no-open-quote' | 'no-close-quote' | Defaults | string;
196
191
  counterIncrement: string;
197
192
  counterReset: string;
@@ -219,7 +214,7 @@ declare type ITheme = Partial<{
219
214
  justifyContent: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around';
220
215
  keyframe: any;
221
216
  letterSpacing: 'normal' | Value$2 | Defaults;
222
- lineHeight: 'normal' | Defaults | Length;
217
+ lineHeight: Value$2 | 'normal' | 'revert' | 'unset' | Defaults;
223
218
  listStyle: string;
224
219
  listStyleImage: 'none' | string | Defaults;
225
220
  listStylePosition: string;
@@ -276,9 +271,9 @@ declare type ITheme = Partial<{
276
271
  clearFix: boolean;
277
272
  fullScreen: boolean;
278
273
  extendCss: ReturnType<typeof config.css> | string;
279
- }>;
274
+ };
280
275
  declare type Theme = {
281
- [I in keyof ITheme]: ITheme[I] | null;
276
+ [I in keyof ITheme]: ITheme[I] | null | undefined;
282
277
  };
283
278
 
284
279
  declare type Styles = ({ theme, css, rootSize, }: {
@@ -320,7 +315,7 @@ declare type AlignContent = ({ direction, alignX, alignY, }: {
320
315
  }) => ReturnType<typeof config.css> | null;
321
316
  declare const alignContent: AlignContent;
322
317
 
323
- declare type ExtendCss = (styles: string | ((css: typeof config.css) => ReturnType<typeof css>) | null | undefined) => string | ReturnType<typeof config.css>;
318
+ declare type ExtendCss = (styles: ((css: typeof config.css) => ReturnType<typeof css>) | string | null | undefined) => string | ReturnType<typeof config.css>;
324
319
  declare const extendCss: ExtendCss;
325
320
 
326
321
  declare type NormalizeUnit = ({ param, rootSize, outputUnit, }: {
@@ -335,7 +330,7 @@ declare type Unit<V> = V extends string ? string : undefined;
335
330
  declare type StripUnit = <V extends ReactText, UR extends boolean = false>(value: V, unitReturn?: UR) => UR extends true ? [Value$1<V>, Unit<V>] : Value$1<V>;
336
331
  declare const stripUnit: StripUnit;
337
332
 
338
- declare type Value = (values: Array<unknown>, rootSize?: number, outputUnit?: 'px' | 'rem' | '%' | string) => string | number;
333
+ declare type Value = (values: Array<unknown>, rootSize?: number, outputUnit?: Units) => string | number;
339
334
  declare const value: Value;
340
335
 
341
- export { ALIGN_CONTENT_DIRECTION, ALIGN_CONTENT_MAP_X, ALIGN_CONTENT_MAP_Y, AlignContent, AlignContentAlignXKeys, AlignContentAlignYKeys, AlignContentDirectionKeys, Breakpoints, CreateMediaQueries, ExtendCss, MakeItResponsive, MakeItResponsiveStyles, NormalizeTheme, NormalizeUnit, Provider, SortBreakpoints, StripUnit, Styles, Theme as StylesTheme, TProvider, TransformTheme, UseWindowResize, Value, alignContent, breakpoints, createMediaQueries, extendCss, makeItResponsive, normalizeTheme, normalizeUnit, sortBreakpoints, stripUnit, styles, transformTheme, useWindowResize, value };
336
+ export { ALIGN_CONTENT_DIRECTION, ALIGN_CONTENT_MAP_X, ALIGN_CONTENT_MAP_Y, AlignContent, AlignContentAlignXKeys, AlignContentAlignYKeys, AlignContentDirectionKeys, Breakpoints, CreateMediaQueries, ExtendCss, MakeItResponsive, MakeItResponsiveStyles, NormalizeTheme, NormalizeUnit, Provider, SortBreakpoints, StripUnit, Styles, Theme as StylesTheme, TProvider, TransformTheme, Value, alignContent, breakpoints, createMediaQueries, extendCss, makeItResponsive, normalizeTheme, normalizeUnit, sortBreakpoints, stripUnit, styles, transformTheme, value };
@@ -1,7 +1,6 @@
1
1
  import Provider, { context, TProvider } from "./context";
2
- import { useWindowResize, UseWindowResize } from "./hooks";
3
2
  import { breakpoints, createMediaQueries, makeItResponsive, normalizeTheme, sortBreakpoints, transformTheme, Breakpoints, CreateMediaQueries, MakeItResponsive, MakeItResponsiveStyles, NormalizeTheme, SortBreakpoints, TransformTheme } from "./responsive";
4
3
  import { styles, alignContent, ALIGN_CONTENT_DIRECTION, ALIGN_CONTENT_MAP_X, ALIGN_CONTENT_MAP_Y, extendCss, Styles, StylesTheme, AlignContent, AlignContentAlignXKeys, AlignContentAlignYKeys, AlignContentDirectionKeys, ExtendCss } from "./styles";
5
4
  import { stripUnit, normalizeUnit, value, StripUnit, NormalizeUnit, Value } from "./units";
6
- export type { TProvider, Breakpoints, UseWindowResize, CreateMediaQueries, MakeItResponsive, MakeItResponsiveStyles, NormalizeTheme, SortBreakpoints, TransformTheme, Styles, StylesTheme, AlignContent, AlignContentAlignXKeys, AlignContentAlignYKeys, AlignContentDirectionKeys, ExtendCss, StripUnit, NormalizeUnit, Value, };
7
- export { breakpoints, Provider, context, useWindowResize, makeItResponsive, sortBreakpoints, createMediaQueries, transformTheme, normalizeTheme, styles, alignContent, ALIGN_CONTENT_DIRECTION, ALIGN_CONTENT_MAP_X, ALIGN_CONTENT_MAP_Y, extendCss, stripUnit, normalizeUnit, value, };
5
+ export type { TProvider, Breakpoints, CreateMediaQueries, MakeItResponsive, MakeItResponsiveStyles, NormalizeTheme, SortBreakpoints, TransformTheme, Styles, StylesTheme, AlignContent, AlignContentAlignXKeys, AlignContentAlignYKeys, AlignContentDirectionKeys, ExtendCss, StripUnit, NormalizeUnit, Value, };
6
+ export { breakpoints, Provider, context, makeItResponsive, sortBreakpoints, createMediaQueries, transformTheme, normalizeTheme, styles, alignContent, ALIGN_CONTENT_DIRECTION, ALIGN_CONTENT_MAP_X, ALIGN_CONTENT_MAP_Y, extendCss, stripUnit, normalizeUnit, value, };
@@ -1,4 +1,4 @@
1
- export declare type CreateMediaQueries = <B, R extends number, C extends (...args: any) => any>({ breakpoints, rootSize, css, }: {
1
+ export declare type CreateMediaQueries = <B, R extends number, C extends (...args: any) => any>(props: {
2
2
  breakpoints: B;
3
3
  rootSize: R;
4
4
  css: C;
@@ -1,4 +1,4 @@
1
1
  import { config } from '@vitus-labs/core';
2
- export declare type ExtendCss = (styles: string | ((css: typeof config.css) => ReturnType<typeof css>) | null | undefined) => string | ReturnType<typeof config.css>;
2
+ export declare type ExtendCss = (styles: ((css: typeof config.css) => ReturnType<typeof css>) | string | null | undefined) => string | ReturnType<typeof config.css>;
3
3
  declare const extendCss: ExtendCss;
4
4
  export default extendCss;
@@ -0,0 +1,4 @@
1
+ import insetShorthand, { InsetShorthand } from './insetShorthand';
2
+ import spacingShorthand, { SpacingShorthand } from './spacingShorthand';
3
+ export type { InsetShorthand, SpacingShorthand };
4
+ export { insetShorthand, spacingShorthand };
@@ -0,0 +1,12 @@
1
+ import { Value } from "../../types";
2
+ export declare type InsetShorthand = (rootSize?: number) => (props: {
3
+ top: Value | null | undefined;
4
+ left: Value | null | undefined;
5
+ right: Value | null | undefined;
6
+ bottom: Value | null | undefined;
7
+ x: Value | null | undefined;
8
+ y: Value | null | undefined;
9
+ full: Value | null | undefined;
10
+ }) => string | null;
11
+ declare const insetShorthand: InsetShorthand;
12
+ export default insetShorthand;
@@ -0,0 +1,12 @@
1
+ import { Value } from "../../types";
2
+ export declare type SpacingShorthand = (property: 'padding' | 'margin', rootSize?: number) => (props: {
3
+ top: Value | null | undefined;
4
+ left: Value | null | undefined;
5
+ right: Value | null | undefined;
6
+ bottom: Value | null | undefined;
7
+ x: Value | null | undefined;
8
+ y: Value | null | undefined;
9
+ full: Value | null | undefined;
10
+ }) => string | null;
11
+ declare const spacingShorthand: SpacingShorthand;
12
+ export default spacingShorthand;
@@ -1,8 +1,6 @@
1
1
  import { config } from '@vitus-labs/core';
2
- declare type Value = 'auto' | 'inital' | 'inherit' | number | string;
3
- declare type Defaults = 'initial' | 'inherit';
4
- declare type Length = number | string;
5
- declare type BorderColor = 'transparent' | string | Defaults;
2
+ import { Value, Defaults, Color } from "../../types";
3
+ declare type BorderColor = Color | Defaults;
6
4
  declare type BorderImageRepeat = 'stretch' | 'repeat' | 'round' | 'space' | Defaults;
7
5
  declare type TextDecoration = 'none' | 'underline' | 'overline' | 'line-through' | 'blink' | Defaults;
8
6
  declare type BorderStyle = 'none' | 'hidden' | 'dotted' | 'dashed' | 'solid' | 'double' | 'groove' | 'ridge' | 'inset' | 'outset' | Defaults;
@@ -10,8 +8,10 @@ declare type FontSize = 'medium' | 'xx-small' | 'x-small' | 'small' | 'large' |
10
8
  declare type ListStyleType = 'disc' | 'armenian' | 'circle' | 'cjk-ideographic' | 'decimal' | 'decimal-leading-zero' | 'georgian' | 'hebrew' | 'hiragana' | 'hiragana-iroha' | 'katakana' | 'katakana-iroha' | 'lower-alpha' | 'lower-greek' | 'lower-latin' | 'lower-roman' | 'none' | 'square' | 'upper-alpha' | 'upper-greek' | 'upper-latin' | 'upper-roman' | Defaults;
11
9
  declare type Overflow = 'visible' | 'hidden' | 'scroll' | 'auto' | Defaults;
12
10
  declare type Cursor = 'alias' | 'all-scroll' | 'auto' | 'cell' | 'context-menu' | 'col-resize' | 'copy' | 'crosshair' | 'default' | 'e-resize' | 'ew-resize' | 'grab' | 'grabbing' | 'help' | 'move' | 'n-resize' | 'ne-resize' | 'nesw-resize' | 'ns-resize' | 'nw-resize' | 'nwse-resize' | 'no-drop' | 'none' | 'not-allowed' | 'pointer' | 'progress' | 'row-resize' | 's-resize' | 'se-resize' | 'sw-resize' | 'text' | 'URL' | 'vertical-text' | 'w-resize' | 'wait' | 'zoom-in' | 'zoom-out' | Defaults;
13
- export declare type ITheme = Partial<{
14
- inset: string;
11
+ export declare type ITheme = {
12
+ inset: Value;
13
+ insetX: Value;
14
+ insetY: Value;
15
15
  top: Value;
16
16
  bottom: Value;
17
17
  left: Value;
@@ -50,7 +50,7 @@ export declare type ITheme = Partial<{
50
50
  background: string;
51
51
  backgroundAttachment: 'scroll' | 'fixed' | Defaults;
52
52
  backgroundClip: 'border-box' | 'padding-box' | 'content-box' | Defaults;
53
- backgroundColor: string | 'transparent' | Defaults;
53
+ backgroundColor: Color;
54
54
  backgroundImage: string | 'none' | Defaults;
55
55
  backgroundOrigin: 'padding-box' | 'border-box' | 'content-box' | Defaults;
56
56
  backgroundPosition: any;
@@ -105,7 +105,7 @@ export declare type ITheme = Partial<{
105
105
  clear: 'left' | 'right' | 'auto' | 'both' | 'none' | Defaults;
106
106
  clip: 'shape' | 'auto' | Defaults;
107
107
  clipPath: string;
108
- color: string;
108
+ color: Color;
109
109
  content: 'normal' | 'none' | 'counter' | 'open-quote' | 'close-quote' | 'no-open-quote' | 'no-close-quote' | Defaults | string;
110
110
  counterIncrement: string;
111
111
  counterReset: string;
@@ -133,7 +133,7 @@ export declare type ITheme = Partial<{
133
133
  justifyContent: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around';
134
134
  keyframe: any;
135
135
  letterSpacing: 'normal' | Value | Defaults;
136
- lineHeight: 'normal' | Defaults | Length;
136
+ lineHeight: Value | 'normal' | 'revert' | 'unset' | Defaults;
137
137
  listStyle: string;
138
138
  listStyleImage: 'none' | string | Defaults;
139
139
  listStylePosition: string;
@@ -190,8 +190,8 @@ export declare type ITheme = Partial<{
190
190
  clearFix: boolean;
191
191
  fullScreen: boolean;
192
192
  extendCss: ReturnType<typeof config.css> | string;
193
- }>;
193
+ };
194
194
  export declare type Theme = {
195
- [I in keyof ITheme]: ITheme[I] | null;
195
+ [I in keyof ITheme]: ITheme[I] | null | undefined;
196
196
  };
197
197
  export {};
@@ -0,0 +1,11 @@
1
+ import { Value } from "../../types";
2
+ export declare type SpacingShorthand = (property: 'padding' | 'margin') => (props: {
3
+ top: Value | null | undefined;
4
+ left: Value | null | undefined;
5
+ right: Value | null | undefined;
6
+ bottom: Value | null | undefined;
7
+ x: Value | null | undefined;
8
+ y: Value | null | undefined;
9
+ full: Value | null | undefined;
10
+ }) => string;
11
+ export declare const spacingShorthand: SpacingShorthand;
@@ -1,2 +1,8 @@
1
1
  import { config } from '@vitus-labs/core';
2
2
  export declare type Css = typeof config.css;
3
+ export declare type Defaults = 'initial' | 'inherit';
4
+ export declare type Units = 'px' | 'rem' | 'em' | '%' | 'vh' | 'vw' | 'vmin' | 'vmax';
5
+ export declare type UnitValue = number | `${number}${Units}`;
6
+ export declare type Value = UnitValue | 'auto' | Defaults;
7
+ export declare type Color = `#${string | number}` | 'currentcolor' | 'transparent' | `rgb(${number}, ${number}, ${number})` | `rgba(${number}, ${number}, ${number}, ${number})` | `hsl(${number}, ${number}%, ${number}%)` | `hsla(${number}, ${number}%, ${number}%, ${number})` | Defaults;
8
+ export declare type BrowserColors = 'black' | 'silver' | 'gray' | 'white' | 'maroon' | 'red' | 'purple' | 'fuchsia' | 'green' | 'lime' | 'olive' | 'yellow' | 'navy' | 'blue' | 'teal' | 'aqua' | 'orange' | 'aliceblue' | 'antiquewhite' | 'aquamarine' | 'azure' | 'beige' | 'bisque' | 'blanchedalmond' | 'blueviolet' | 'brown' | 'burlywood' | 'cadetblue' | 'chartreuse' | 'chocolate' | 'coral' | 'cornflowerblue' | 'cornsilk' | 'crimson' | 'cyan' | 'darkblue' | 'darkcyan' | 'darkgoldenrod' | 'darkgray' | 'darkgreen' | 'darkgrey' | 'darkkhaki' | 'darkmagenta' | 'darkolivegreen' | 'darkorange' | 'darkorchid' | 'darkred' | 'darksalmon' | 'darkseagreen' | 'darkslateblue' | 'darkslategray' | 'darkslategrey' | 'darkturquoise' | 'darkviolet' | 'deeppink' | 'deepskyblue' | 'dimgray' | 'dimgrey' | 'dodgerblue' | 'firebrick' | 'floralwhite' | 'forestgreen' | 'gainsboro' | 'ghostwhite' | 'gold' | 'goldenrod' | 'greenyellow' | 'grey' | 'honeydew' | 'hotpink' | 'indianred' | 'indigo' | 'ivory' | 'khaki' | 'lavender' | 'lavenderblush' | 'lawngreen' | 'lemonchiffon' | 'lightblue' | 'lightcoral' | 'lightcyan' | 'lightgoldenrodyellow' | 'lightgray' | 'lightgreen' | 'lightgrey' | 'lightpink' | 'lightsalmon' | 'lightseagreen' | 'lightskyblue' | 'lightslategray' | 'lightslategrey' | 'lightsteelblue' | 'lightyellow' | 'limegreen' | 'linen' | 'magenta' | 'mediumaquamarine' | 'mediumblue' | 'mediumorchid' | 'mediumpurple' | 'mediumseagreen' | 'mediumslateblue' | 'mediumspringgreen' | 'mediumturquoise' | 'mediumvioletred' | 'midnightblue' | 'mintcream' | 'mistyrose' | 'moccasin' | 'navajowhite' | 'oldlace' | 'olivedrab' | 'orangered' | 'orchid' | 'palegoldenrod' | 'palegreen' | 'paleturquoise' | 'palevioletred' | 'papayawhip' | 'peachpuff' | 'peru' | 'pink' | 'plum' | 'powderblue' | 'rosybrown' | 'royalblue' | 'saddlebrown' | 'salmon' | 'sandybrown' | 'seagreen' | 'seashell' | 'sienna' | 'skyblue' | 'slateblue' | 'slategray' | 'slategrey' | 'snow' | 'springgreen' | 'steelblue' | 'tan' | 'thistle' | 'tomato' | 'turquoise' | 'violet' | 'wheat' | 'whitesmoke' | 'yellowgreen' | 'rebeccapurple';
@@ -1,3 +1,4 @@
1
- export declare type Value = (values: Array<unknown>, rootSize?: number, outputUnit?: 'px' | 'rem' | '%' | string) => string | number;
1
+ import type { Units } from "../types";
2
+ export declare type Value = (values: Array<unknown>, rootSize?: number, outputUnit?: Units) => string | number;
2
3
  declare const value: Value;
3
4
  export default value;
@@ -1,5 +1,5 @@
1
- import React, { useMemo, useState, useEffect } from 'react';
2
- import { memoize, isEmpty, set, config, Provider as Provider$1, throttle } from '@vitus-labs/core';
1
+ import React, { useMemo } from 'react';
2
+ import { memoize, isEmpty, set, config, Provider as Provider$1 } from '@vitus-labs/core';
3
3
  export { context } from '@vitus-labs/core';
4
4
 
5
5
  const breakpoints = {
@@ -64,7 +64,7 @@ const handleObjectCb = (obj) => (bp, i, bps, res) => {
64
64
  };
65
65
  const handleValueCb = (value) => () => value;
66
66
  const shouldNormalize = (props) => Object.values(props).some((item) => typeof item === 'object' || Array.isArray(item));
67
- const normalizeTheme = memoize(({ theme, breakpoints }) => {
67
+ const normalizeTheme = ({ theme, breakpoints }) => {
68
68
  if (!shouldNormalize(theme))
69
69
  return theme;
70
70
  const getBpValues = assignToBreakbointKey(breakpoints);
@@ -86,7 +86,7 @@ const normalizeTheme = memoize(({ theme, breakpoints }) => {
86
86
  }
87
87
  });
88
88
  return result;
89
- }, { isDeepEqual: true, maxSize: 4000 });
89
+ };
90
90
 
91
91
  const removeUnexpectedKeys = (obj, keys) => {
92
92
  const result = {};
@@ -208,22 +208,6 @@ const Provider = ({ theme, children, ...props }) => {
208
208
  return (React.createElement(Provider$1, { theme: result, ...props }, children));
209
209
  };
210
210
 
211
- const useWindowResize = (throttleDelay = 200, { width = 0, height = 0 } = {}) => {
212
- const getSize = () => ({
213
- width: window.innerWidth ,
214
- height: window.innerHeight ,
215
- });
216
- const [windowSize, setWindowSize] = useState(getSize);
217
- useEffect(() => {
218
- const handleResize = throttle(() => {
219
- setWindowSize(getSize());
220
- }, throttleDelay);
221
- window.addEventListener('resize', handleResize, false);
222
- return () => window.removeEventListener('resize', handleResize, false);
223
- }, []); // Empty array ensures that effect is only run on mount and unmount
224
- return windowSize;
225
- };
226
-
227
211
  const stripUnit = (value, unitReturn) => {
228
212
  const cssRegex = /^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;
229
213
  if (typeof value !== 'string')
@@ -239,11 +223,12 @@ const stripUnit = (value, unitReturn) => {
239
223
  return value;
240
224
  };
241
225
 
242
- const normalizeUnit = memoize(({ param, rootSize = 16, outputUnit = 'rem' }) => {
243
- if (!param && param !== 0)
226
+ const isNotValue = (value) => !value && value !== 0;
227
+ const normalizeUnit = ({ param, rootSize = 16, outputUnit = 'rem' , }) => {
228
+ if (isNotValue(param))
244
229
  return null;
245
230
  const [value, unit] = stripUnit(param, true);
246
- if (!value && value !== 0)
231
+ if (isNotValue(value))
247
232
  return null;
248
233
  if (value === 0 || typeof value === 'string')
249
234
  return param; // zero should be unitless
@@ -258,7 +243,7 @@ const normalizeUnit = memoize(({ param, rootSize = 16, outputUnit = 'rem' }) =>
258
243
  if (unit)
259
244
  return param;
260
245
  return `${value}${outputUnit}`;
261
- }, { isDeepEqual: true, maxSize: 1000 });
246
+ };
262
247
 
263
248
  const getValueOf = (...values) => values.find((value) => typeof value !== 'undefined' && value !== null);
264
249
  const value = (values, rootSize, outputUnit) => {
@@ -279,6 +264,134 @@ const value = (values, rootSize, outputUnit) => {
279
264
  });
280
265
  };
281
266
 
267
+ const isValidValue$1 = (value) => !!value || value === 0;
268
+ // eslint-disable-next-line import/prefer-default-export
269
+ const insetShorthand = (rootSize) => ({ top, left, right, bottom, x, y, full }) => {
270
+ if (!isValidValue$1(top) &&
271
+ !isValidValue$1(bottom) &&
272
+ !isValidValue$1(left) &&
273
+ !isValidValue$1(right) &&
274
+ !isValidValue$1(x) &&
275
+ !isValidValue$1(y) &&
276
+ !isValidValue$1(full)) {
277
+ return null;
278
+ }
279
+ const value = (param) => normalizeUnit({ param, rootSize });
280
+ // top - right - bottom - left
281
+ const spacing = [full, full, full, full];
282
+ if (isValidValue$1(x)) {
283
+ spacing[1] = x;
284
+ spacing[3] = x;
285
+ }
286
+ if (isValidValue$1(y)) {
287
+ spacing[0] = y;
288
+ spacing[2] = y;
289
+ }
290
+ if (isValidValue$1(top)) {
291
+ spacing[0] = top;
292
+ }
293
+ if (isValidValue$1(right)) {
294
+ spacing[1] = right;
295
+ }
296
+ if (isValidValue$1(bottom)) {
297
+ spacing[2] = bottom;
298
+ }
299
+ if (isValidValue$1(left)) {
300
+ spacing[3] = left;
301
+ }
302
+ const [t, r, b, l] = spacing;
303
+ if (spacing.every((val, _, arr) => isValidValue$1(val) && val === arr[0])) {
304
+ return `inset: ${t};`;
305
+ }
306
+ if (t === b && r === l) {
307
+ return `inset: ${value(t)} ${value(r)};`;
308
+ }
309
+ if (t && r === l && b) {
310
+ return `inset: ${value(t)} ${value(r)} ${value(b)};`;
311
+ }
312
+ if (spacing.every((val) => !!val)) {
313
+ return `inset: ${value(t)} ${value(r)} ${value(b)} ${value(l)};`;
314
+ }
315
+ let output = '';
316
+ if (isValidValue$1(t)) {
317
+ output += `$-top: ${value([t])};`;
318
+ }
319
+ if (isValidValue$1(b)) {
320
+ output += `bottom: ${value([b])};`;
321
+ }
322
+ if (isValidValue$1(l)) {
323
+ output += `left: ${value([l])};`;
324
+ }
325
+ if (isValidValue$1(r)) {
326
+ output += `right: ${value([r])};`;
327
+ }
328
+ return output;
329
+ };
330
+
331
+ const isValidValue = (value) => !!value || value === 0;
332
+ // eslint-disable-next-line import/prefer-default-export
333
+ const spacingShorthand = (property, rootSize) => ({ top, left, right, bottom, x, y, full }) => {
334
+ if (!isValidValue(top) &&
335
+ !isValidValue(bottom) &&
336
+ !isValidValue(left) &&
337
+ !isValidValue(right) &&
338
+ !isValidValue(x) &&
339
+ !isValidValue(y) &&
340
+ !isValidValue(full)) {
341
+ return null;
342
+ }
343
+ const value = (param) => normalizeUnit({ param, rootSize });
344
+ // top - right - bottom - left
345
+ const spacing = [full, full, full, full];
346
+ if (isValidValue(x)) {
347
+ spacing[1] = x;
348
+ spacing[3] = x;
349
+ }
350
+ if (isValidValue(y)) {
351
+ spacing[0] = y;
352
+ spacing[2] = y;
353
+ }
354
+ if (isValidValue(top)) {
355
+ spacing[0] = top;
356
+ }
357
+ if (isValidValue(right)) {
358
+ spacing[1] = right;
359
+ }
360
+ if (isValidValue(bottom)) {
361
+ spacing[2] = bottom;
362
+ }
363
+ if (isValidValue(left)) {
364
+ spacing[3] = left;
365
+ }
366
+ const [t, r, b, l] = spacing;
367
+ if (spacing.every((val, _, arr) => isValidValue(val) && val === arr[0])) {
368
+ return `${property}: ${t};`;
369
+ }
370
+ if (t === b && r === l) {
371
+ return `${property}: ${value(t)} ${value(r)};`;
372
+ }
373
+ if (t && r === l && b) {
374
+ return `${property}: ${value(t)} ${value(r)} ${value(b)};`;
375
+ }
376
+ if (spacing.every((val) => !!val)) {
377
+ return `${property}: ${value(t)} ${value(r)} ${value(b)} ${value(l)};`;
378
+ }
379
+ let output = '';
380
+ if (isValidValue(t)) {
381
+ output += `${property}-top: ${value([t])};`;
382
+ }
383
+ if (isValidValue(b)) {
384
+ output += `${property}-bottom: ${value([b])};`;
385
+ }
386
+ if (isValidValue(l)) {
387
+ output += `${property}-left: ${value([l])};`;
388
+ }
389
+ if (isValidValue(r)) {
390
+ output += `${property}-right: ${value([r])};`;
391
+ }
392
+ return output;
393
+ };
394
+
282
395
  const styles = ({ theme: t, css, rootSize }) => {
283
396
  const value$1 = (...values) => value(values, rootSize);
284
397
  const pxValue = (...values) => value(values, rootSize, 'px');
@@ -301,11 +414,15 @@ const styles = ({ theme: t, css, rootSize }) => {
301
414
  box-sizing: ${t.boxSizing};
302
415
  float: ${t.float};
303
416
 
304
- inset: ${t.inset};
305
- top: ${value$1(t.top, t.positionY)};
306
- bottom: ${value$1(t.bottom, t.positionY)};
307
- left: ${value$1(t.left, t.positionX)};
308
- right: ${value$1(t.right, t.positionX)};
417
+ ${insetShorthand(rootSize)({
418
+ top: t.top,
419
+ left: t.left,
420
+ bottom: t.bottom,
421
+ right: t.right,
422
+ x: t.insetX,
423
+ y: t.insetY,
424
+ full: t.inset,
425
+ })}
309
426
 
310
427
  width: ${value$1(t.width, t.size)};
311
428
  min-width: ${value$1(t.minWidth, t.minSize)};
@@ -318,17 +435,25 @@ const styles = ({ theme: t, css, rootSize }) => {
318
435
  /* ------------------------------------------------- */
319
436
  /* SPACING attributes */
320
437
  /* ------------------------------------------------- */
321
- margin: ${value$1(t.margin)};
322
- margin-top: ${value$1(t.marginTop, t.marginY)};
323
- margin-bottom: ${value$1(t.marginBottom, t.marginY)};
324
- margin-left: ${value$1(t.marginLeft, t.marginX)};
325
- margin-right: ${value$1(t.marginRight, t.marginX)};
326
-
327
- padding: ${value$1(t.padding)};
328
- padding-top: ${value$1(t.paddingTop, t.paddingY)};
329
- padding-bottom: ${value$1(t.paddingBottom, t.paddingY)};
330
- padding-left: ${value$1(t.paddingLeft, t.paddingX)};
331
- padding-right: ${value$1(t.paddingRight, t.paddingX)};
438
+ ${spacingShorthand('margin', rootSize)({
439
+ top: t.marginTop,
440
+ left: t.marginLeft,
441
+ bottom: t.marginBottom,
442
+ right: t.marginRight,
443
+ x: t.marginX,
444
+ y: t.marginY,
445
+ full: t.margin,
446
+ })};
447
+
448
+ ${spacingShorthand('padding', rootSize)({
449
+ top: t.paddingTop,
450
+ left: t.paddingLeft,
451
+ bottom: t.paddingBottom,
452
+ right: t.paddingRight,
453
+ x: t.paddingX,
454
+ y: t.paddingY,
455
+ full: t.padding,
456
+ })};
332
457
 
333
458
  /* ------------------------------------------------- */
334
459
  /* FLEX attributes */
@@ -576,5 +701,5 @@ const extendCss = (styles) => {
576
701
  return styles;
577
702
  };
578
703
 
579
- export { ALIGN_CONTENT_DIRECTION, ALIGN_CONTENT_MAP_X, ALIGN_CONTENT_MAP_Y, Provider, alignContent, breakpoints, createMediaQueries, extendCss, makeItResponsive, normalizeTheme, normalizeUnit, sortBreakpoints, stripUnit, styles, transformTheme, useWindowResize, value };
704
+ export { ALIGN_CONTENT_DIRECTION, ALIGN_CONTENT_MAP_X, ALIGN_CONTENT_MAP_Y, Provider, alignContent, breakpoints, createMediaQueries, extendCss, makeItResponsive, normalizeTheme, normalizeUnit, sortBreakpoints, stripUnit, styles, transformTheme, value };
580
705
  //# sourceMappingURL=vitus-labs-unistyle.browser.js.map