@pyreon/unistyle 0.11.5 → 0.11.6

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/README.md +39 -34
  2. package/lib/index.d.ts +13 -8
  3. package/lib/index.js +9 -4
  4. package/package.json +24 -24
  5. package/src/__tests__/alignContent.test.ts +57 -57
  6. package/src/__tests__/borderRadius.test.ts +40 -40
  7. package/src/__tests__/camelToKebab.test.ts +23 -23
  8. package/src/__tests__/context.test.ts +28 -28
  9. package/src/__tests__/createMediaQueries.test.ts +21 -21
  10. package/src/__tests__/edge.test.ts +76 -76
  11. package/src/__tests__/enrichTheme.test.ts +13 -13
  12. package/src/__tests__/index.test.ts +31 -31
  13. package/src/__tests__/makeItResponsive.test.ts +32 -32
  14. package/src/__tests__/processDescriptor.test.ts +107 -107
  15. package/src/__tests__/responsive.test.ts +66 -66
  16. package/src/__tests__/styles.test.ts +52 -52
  17. package/src/__tests__/units.test.ts +63 -63
  18. package/src/context.tsx +11 -6
  19. package/src/enrichTheme.ts +3 -3
  20. package/src/index.ts +11 -11
  21. package/src/responsive/createMediaQueries.ts +4 -4
  22. package/src/responsive/index.ts +14 -14
  23. package/src/responsive/makeItResponsive.ts +9 -9
  24. package/src/responsive/normalizeTheme.ts +2 -2
  25. package/src/responsive/transformTheme.ts +2 -2
  26. package/src/styles/alignContent.ts +14 -14
  27. package/src/styles/extendCss.ts +4 -4
  28. package/src/styles/index.ts +6 -6
  29. package/src/styles/shorthands/borderRadius.ts +6 -6
  30. package/src/styles/shorthands/edge.ts +29 -29
  31. package/src/styles/shorthands/index.ts +4 -4
  32. package/src/styles/styles/index.ts +6 -6
  33. package/src/styles/styles/processDescriptor.ts +31 -31
  34. package/src/styles/styles/propertyMap.ts +326 -326
  35. package/src/styles/styles/utils.ts +4 -4
  36. package/src/types.ts +155 -155
  37. package/src/units/index.ts +6 -6
  38. package/src/units/stripUnit.ts +1 -1
  39. package/src/units/value.ts +20 -20
  40. package/src/units/values.ts +18 -18
@@ -1,8 +1,8 @@
1
- import { describe, expect, it } from "vitest"
2
- import styles from "../styles/styles/index"
1
+ import { describe, expect, it } from 'vitest'
2
+ import styles from '../styles/styles/index'
3
3
 
4
4
  const mockCss = (strings: TemplateStringsArray, ...vals: any[]) => {
5
- let r = ""
5
+ let r = ''
6
6
  for (let i = 0; i < strings.length; i++) {
7
7
  r += strings[i]
8
8
  if (i < vals.length) r += String(vals[i])
@@ -10,110 +10,110 @@ const mockCss = (strings: TemplateStringsArray, ...vals: any[]) => {
10
10
  return r
11
11
  }
12
12
 
13
- describe("styles", () => {
14
- it("empty theme returns empty string (all fragments are empty)", () => {
13
+ describe('styles', () => {
14
+ it('empty theme returns empty string (all fragments are empty)', () => {
15
15
  const result = styles({ theme: {}, css: mockCss, rootSize: 16 })
16
- expect(result).toBe("")
16
+ expect(result).toBe('')
17
17
  })
18
18
 
19
- it("single simple property: color", () => {
20
- const result = styles({ theme: { color: "red" }, css: mockCss, rootSize: 16 })
21
- expect(result).toContain("color: red;")
19
+ it('single simple property: color', () => {
20
+ const result = styles({ theme: { color: 'red' }, css: mockCss, rootSize: 16 })
21
+ expect(result).toContain('color: red;')
22
22
  })
23
23
 
24
- it("simple property: display", () => {
25
- const result = styles({ theme: { display: "flex" }, css: mockCss, rootSize: 16 })
26
- expect(result).toContain("display: flex;")
24
+ it('simple property: display', () => {
25
+ const result = styles({ theme: { display: 'flex' }, css: mockCss, rootSize: 16 })
26
+ expect(result).toContain('display: flex;')
27
27
  })
28
28
 
29
- it("convert property: width converts via value() with rootSize", () => {
29
+ it('convert property: width converts via value() with rootSize', () => {
30
30
  // width is a convert_fallback with keys ["width", "size"]
31
31
  // 160 / 16 = 10rem
32
32
  const result = styles({ theme: { width: 160 }, css: mockCss, rootSize: 16 })
33
- expect(result).toContain("width:")
34
- expect(result).toContain("10rem")
33
+ expect(result).toContain('width:')
34
+ expect(result).toContain('10rem')
35
35
  })
36
36
 
37
- it("convert property: fontSize", () => {
37
+ it('convert property: fontSize', () => {
38
38
  // 32 / 16 = 2rem
39
39
  const result = styles({ theme: { fontSize: 32 }, css: mockCss, rootSize: 16 })
40
- expect(result).toContain("font-size:")
41
- expect(result).toContain("2rem")
40
+ expect(result).toContain('font-size:')
41
+ expect(result).toContain('2rem')
42
42
  })
43
43
 
44
- it("edge property: margin generates margin shorthand", () => {
44
+ it('edge property: margin generates margin shorthand', () => {
45
45
  // margin 16 / 16 = 1rem
46
46
  const result = styles({ theme: { margin: 16 }, css: mockCss, rootSize: 16 })
47
- expect(result).toContain("margin:")
48
- expect(result).toContain("1rem")
47
+ expect(result).toContain('margin:')
48
+ expect(result).toContain('1rem')
49
49
  })
50
50
 
51
- it("edge property: padding", () => {
51
+ it('edge property: padding', () => {
52
52
  const result = styles({ theme: { padding: 8 }, css: mockCss, rootSize: 16 })
53
- expect(result).toContain("padding:")
54
- expect(result).toContain("0.5rem")
53
+ expect(result).toContain('padding:')
54
+ expect(result).toContain('0.5rem')
55
55
  })
56
56
 
57
- it("border radius: borderRadius generates border-radius", () => {
57
+ it('border radius: borderRadius generates border-radius', () => {
58
58
  // 8 / 16 = 0.5rem
59
59
  const result = styles({ theme: { borderRadius: 8 }, css: mockCss, rootSize: 16 })
60
- expect(result).toContain("border-radius:")
61
- expect(result).toContain("0.5rem")
60
+ expect(result).toContain('border-radius:')
61
+ expect(result).toContain('0.5rem')
62
62
  })
63
63
 
64
- it("multiple properties combined", () => {
64
+ it('multiple properties combined', () => {
65
65
  const result = styles({
66
- theme: { color: "blue", display: "flex", fontSize: 16 },
66
+ theme: { color: 'blue', display: 'flex', fontSize: 16 },
67
67
  css: mockCss,
68
68
  rootSize: 16,
69
69
  })
70
- expect(result).toContain("color: blue;")
71
- expect(result).toContain("display: flex;")
72
- expect(result).toContain("font-size: 1rem;")
70
+ expect(result).toContain('color: blue;')
71
+ expect(result).toContain('display: flex;')
72
+ expect(result).toContain('font-size: 1rem;')
73
73
  })
74
74
 
75
- it("special property: fullScreen", () => {
75
+ it('special property: fullScreen', () => {
76
76
  const result = styles({ theme: { fullScreen: true }, css: mockCss, rootSize: 16 })
77
- expect(result).toContain("position: fixed;")
78
- expect(result).toContain("top: 0;")
79
- expect(result).toContain("left: 0;")
80
- expect(result).toContain("right: 0;")
81
- expect(result).toContain("bottom: 0;")
77
+ expect(result).toContain('position: fixed;')
78
+ expect(result).toContain('top: 0;')
79
+ expect(result).toContain('left: 0;')
80
+ expect(result).toContain('right: 0;')
81
+ expect(result).toContain('bottom: 0;')
82
82
  })
83
83
 
84
- it("special property: fullScreen false produces no output", () => {
84
+ it('special property: fullScreen false produces no output', () => {
85
85
  const result = styles({ theme: { fullScreen: false }, css: mockCss, rootSize: 16 })
86
- expect(result).not.toContain("position: fixed;")
86
+ expect(result).not.toContain('position: fixed;')
87
87
  })
88
88
 
89
- it("special property: backgroundImage", () => {
89
+ it('special property: backgroundImage', () => {
90
90
  const result = styles({
91
- theme: { backgroundImage: "https://example.com/img.png" },
91
+ theme: { backgroundImage: 'https://example.com/img.png' },
92
92
  css: mockCss,
93
93
  rootSize: 16,
94
94
  })
95
- expect(result).toContain("background-image: url(https://example.com/img.png);")
95
+ expect(result).toContain('background-image: url(https://example.com/img.png);')
96
96
  })
97
97
 
98
- it("special property: hideEmpty", () => {
98
+ it('special property: hideEmpty', () => {
99
99
  const result = styles({ theme: { hideEmpty: true }, css: mockCss, rootSize: 16 })
100
- expect(result).toContain("&:empty { display: none; }")
100
+ expect(result).toContain('&:empty { display: none; }')
101
101
  })
102
102
 
103
- it("special property: clearFix", () => {
103
+ it('special property: clearFix', () => {
104
104
  const result = styles({ theme: { clearFix: true }, css: mockCss, rootSize: 16 })
105
105
  expect(result).toContain('&::after { clear: both; content: ""; display: table; }')
106
106
  })
107
107
 
108
- it("string values for convert properties pass through", () => {
109
- const result = styles({ theme: { width: "50%" }, css: mockCss, rootSize: 16 })
110
- expect(result).toContain("width: 50%;")
108
+ it('string values for convert properties pass through', () => {
109
+ const result = styles({ theme: { width: '50%' }, css: mockCss, rootSize: 16 })
110
+ expect(result).toContain('width: 50%;')
111
111
  })
112
112
 
113
- it("uses default rootSize when not provided", () => {
113
+ it('uses default rootSize when not provided', () => {
114
114
  // default rootSize is undefined, value() defaults to 16
115
115
  const result = styles({ theme: { fontSize: 32 }, css: mockCss })
116
- expect(result).toContain("font-size:")
117
- expect(result).toContain("2rem")
116
+ expect(result).toContain('font-size:')
117
+ expect(result).toContain('2rem')
118
118
  })
119
119
  })
@@ -1,134 +1,134 @@
1
- import { describe, expect, it } from "vitest"
2
- import stripUnit from "../units/stripUnit"
3
- import value from "../units/value"
4
- import values from "../units/values"
1
+ import { describe, expect, it } from 'vitest'
2
+ import stripUnit from '../units/stripUnit'
3
+ import value from '../units/value'
4
+ import values from '../units/values'
5
5
 
6
- describe("stripUnit", () => {
7
- it("strips px unit and returns number", () => {
8
- expect(stripUnit("16px")).toBe(16)
6
+ describe('stripUnit', () => {
7
+ it('strips px unit and returns number', () => {
8
+ expect(stripUnit('16px')).toBe(16)
9
9
  })
10
10
 
11
- it("strips rem unit and returns number", () => {
12
- expect(stripUnit("1.5rem")).toBe(1.5)
11
+ it('strips rem unit and returns number', () => {
12
+ expect(stripUnit('1.5rem')).toBe(1.5)
13
13
  })
14
14
 
15
- it("strips em unit and returns number", () => {
16
- expect(stripUnit("2em")).toBe(2)
15
+ it('strips em unit and returns number', () => {
16
+ expect(stripUnit('2em')).toBe(2)
17
17
  })
18
18
 
19
- it("strips % and returns number", () => {
20
- expect(stripUnit("50%")).toBe(50)
19
+ it('strips % and returns number', () => {
20
+ expect(stripUnit('50%')).toBe(50)
21
21
  })
22
22
 
23
- it("handles negative values", () => {
24
- expect(stripUnit("-10px")).toBe(-10)
23
+ it('handles negative values', () => {
24
+ expect(stripUnit('-10px')).toBe(-10)
25
25
  })
26
26
 
27
- it("handles decimal values", () => {
28
- expect(stripUnit("0.5rem")).toBe(0.5)
27
+ it('handles decimal values', () => {
28
+ expect(stripUnit('0.5rem')).toBe(0.5)
29
29
  })
30
30
 
31
- it("returns original string for non-numeric strings", () => {
32
- expect(stripUnit("auto")).toBe("auto")
31
+ it('returns original string for non-numeric strings', () => {
32
+ expect(stripUnit('auto')).toBe('auto')
33
33
  })
34
34
 
35
- it("passes through numbers", () => {
35
+ it('passes through numbers', () => {
36
36
  expect(stripUnit(42)).toBe(42)
37
37
  })
38
38
 
39
- describe("with unitReturn=true", () => {
40
- it("returns [value, unit] tuple for px", () => {
41
- expect(stripUnit("16px", true)).toEqual([16, "px"])
39
+ describe('with unitReturn=true', () => {
40
+ it('returns [value, unit] tuple for px', () => {
41
+ expect(stripUnit('16px', true)).toEqual([16, 'px'])
42
42
  })
43
43
 
44
- it("returns [value, unit] tuple for rem", () => {
45
- expect(stripUnit("2rem", true)).toEqual([2, "rem"])
44
+ it('returns [value, unit] tuple for rem', () => {
45
+ expect(stripUnit('2rem', true)).toEqual([2, 'rem'])
46
46
  })
47
47
 
48
- it("returns [value, unit] tuple for %", () => {
49
- expect(stripUnit("50%", true)).toEqual([50, "%"])
48
+ it('returns [value, unit] tuple for %', () => {
49
+ expect(stripUnit('50%', true)).toEqual([50, '%'])
50
50
  })
51
51
 
52
- it("returns [value, unit] tuple for em", () => {
53
- expect(stripUnit("1.5em", true)).toEqual([1.5, "em"])
52
+ it('returns [value, unit] tuple for em', () => {
53
+ expect(stripUnit('1.5em', true)).toEqual([1.5, 'em'])
54
54
  })
55
55
 
56
- it("returns [value, empty string] for unitless number string", () => {
57
- expect(stripUnit("42", true)).toEqual([42, ""])
56
+ it('returns [value, empty string] for unitless number string', () => {
57
+ expect(stripUnit('42', true)).toEqual([42, ''])
58
58
  })
59
59
 
60
- it("returns [number, undefined] for number input", () => {
60
+ it('returns [number, undefined] for number input', () => {
61
61
  expect(stripUnit(42, true)).toEqual([42, undefined])
62
62
  })
63
63
  })
64
64
  })
65
65
 
66
- describe("value", () => {
67
- it("returns string values as-is", () => {
68
- expect(value("50%")).toBe("50%")
69
- expect(value("2em")).toBe("2em")
70
- expect(value("100vh")).toBe("100vh")
66
+ describe('value', () => {
67
+ it('returns string values as-is', () => {
68
+ expect(value('50%')).toBe('50%')
69
+ expect(value('2em')).toBe('2em')
70
+ expect(value('100vh')).toBe('100vh')
71
71
  })
72
72
 
73
- it("returns 0 as-is", () => {
73
+ it('returns 0 as-is', () => {
74
74
  expect(value(0)).toBe(0)
75
75
  })
76
76
 
77
- it("returns null for null/undefined", () => {
77
+ it('returns null for null/undefined', () => {
78
78
  expect(value(null)).toBeNull()
79
79
  expect(value(undefined)).toBeNull()
80
80
  })
81
81
 
82
- it("converts unitless numbers to rem by default (divides by rootSize)", () => {
82
+ it('converts unitless numbers to rem by default (divides by rootSize)', () => {
83
83
  // 16 / 16 = 1rem
84
- expect(value(16)).toBe("1rem")
84
+ expect(value(16)).toBe('1rem')
85
85
  // 32 / 16 = 2rem
86
- expect(value(32)).toBe("2rem")
86
+ expect(value(32)).toBe('2rem')
87
87
  })
88
88
 
89
- it("converts px values to rem", () => {
90
- expect(value("16px")).toBe("1rem")
91
- expect(value("32px")).toBe("2rem")
89
+ it('converts px values to rem', () => {
90
+ expect(value('16px')).toBe('1rem')
91
+ expect(value('32px')).toBe('2rem')
92
92
  })
93
93
 
94
- it("respects custom rootSize", () => {
94
+ it('respects custom rootSize', () => {
95
95
  // 20 / 10 = 2rem
96
- expect(value(20, 10)).toBe("2rem")
96
+ expect(value(20, 10)).toBe('2rem')
97
97
  })
98
98
 
99
- it("respects outputUnit=px for unitless numbers", () => {
100
- expect(value(16, 16, "px")).toBe("16px")
99
+ it('respects outputUnit=px for unitless numbers', () => {
100
+ expect(value(16, 16, 'px')).toBe('16px')
101
101
  })
102
102
  })
103
103
 
104
- describe("values", () => {
105
- it("returns the first defined value converted", () => {
106
- expect(values([undefined, null, 16])).toBe("1rem")
104
+ describe('values', () => {
105
+ it('returns the first defined value converted', () => {
106
+ expect(values([undefined, null, 16])).toBe('1rem')
107
107
  })
108
108
 
109
- it("returns the first value if defined", () => {
110
- expect(values([32, 16])).toBe("2rem")
109
+ it('returns the first value if defined', () => {
110
+ expect(values([32, 16])).toBe('2rem')
111
111
  })
112
112
 
113
- it("passes through string values", () => {
114
- expect(values(["50%"])).toBe("50%")
113
+ it('passes through string values', () => {
114
+ expect(values(['50%'])).toBe('50%')
115
115
  })
116
116
 
117
- it("returns null when all values are null/undefined", () => {
117
+ it('returns null when all values are null/undefined', () => {
118
118
  expect(values([undefined, null])).toBeNull()
119
119
  })
120
120
 
121
- it("returns 0 for zero value", () => {
121
+ it('returns 0 for zero value', () => {
122
122
  expect(values([0])).toBe(0)
123
123
  })
124
124
 
125
- it("joins array values with spaces", () => {
125
+ it('joins array values with spaces', () => {
126
126
  const result = values([[16, 32]])
127
- expect(result).toContain("1rem")
128
- expect(result).toContain("2rem")
127
+ expect(result).toContain('1rem')
128
+ expect(result).toContain('2rem')
129
129
  })
130
130
 
131
- it("respects rootSize parameter", () => {
132
- expect(values([20], 10)).toBe("2rem")
131
+ it('respects rootSize parameter', () => {
132
+ expect(values([20], 10)).toBe('2rem')
133
133
  })
134
134
  })
package/src/context.tsx CHANGED
@@ -1,9 +1,9 @@
1
- import type { VNode } from "@pyreon/core"
2
- import { provide } from "@pyreon/core"
3
- import { ThemeContext } from "@pyreon/styler"
4
- import { Provider as CoreProvider, context } from "@pyreon/ui-core"
5
- import type { PyreonTheme } from "./enrichTheme"
6
- import { enrichTheme } from "./enrichTheme"
1
+ import type { VNode } from '@pyreon/core'
2
+ import { provide } from '@pyreon/core'
3
+ import { ThemeContext } from '@pyreon/styler'
4
+ import { Provider as CoreProvider, context } from '@pyreon/ui-core'
5
+ import type { PyreonTheme } from './enrichTheme'
6
+ import { enrichTheme } from './enrichTheme'
7
7
 
8
8
  export type TProvider = {
9
9
  theme: PyreonTheme
@@ -11,9 +11,14 @@ export type TProvider = {
11
11
  }
12
12
 
13
13
  /**
14
+ * @internal Low-level provider — use `PyreonUI` from `@pyreon/ui-core` instead.
15
+ *
14
16
  * Unistyle Provider — wraps the core Provider and enriches the theme
15
17
  * with pre-computed sorted breakpoints and media-query tagged-template
16
18
  * helpers consumed by `makeItResponsive`.
19
+ *
20
+ * @deprecated Prefer `<PyreonUI theme={theme} mode="light">` which handles
21
+ * all three context layers (styler, core, mode) in one component.
17
22
  */
18
23
  function Provider(props: TProvider): VNode | null {
19
24
  const { theme, children } = props
@@ -1,5 +1,5 @@
1
- import { config, isEmpty } from "@pyreon/ui-core"
2
- import { createMediaQueries, sortBreakpoints } from "./responsive"
1
+ import { config, isEmpty } from '@pyreon/ui-core'
2
+ import { createMediaQueries, sortBreakpoints } from './responsive'
3
3
 
4
4
  export type PyreonTheme = {
5
5
  rootSize?: number
@@ -24,7 +24,7 @@ export type PyreonTheme = {
24
24
  */
25
25
  export function enrichTheme<T extends PyreonTheme>(
26
26
  theme: T,
27
- ): T & Required<Pick<PyreonTheme, "__PYREON__">> {
27
+ ): T & Required<Pick<PyreonTheme, '__PYREON__'>> {
28
28
  const { breakpoints, rootSize = 16 } = theme
29
29
 
30
30
  const sortedBreakpoints =
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { TProvider } from "./context"
2
- import Provider, { context } from "./context"
3
- import type { PyreonTheme } from "./enrichTheme"
4
- import { enrichTheme } from "./enrichTheme"
1
+ import type { TProvider } from './context'
2
+ import Provider, { context } from './context'
3
+ import type { PyreonTheme } from './enrichTheme'
4
+ import { enrichTheme } from './enrichTheme'
5
5
  import type {
6
6
  Breakpoints,
7
7
  CreateMediaQueries,
@@ -10,7 +10,7 @@ import type {
10
10
  NormalizeTheme,
11
11
  SortBreakpoints,
12
12
  TransformTheme,
13
- } from "./responsive"
13
+ } from './responsive'
14
14
  import {
15
15
  breakpoints,
16
16
  createMediaQueries,
@@ -18,7 +18,7 @@ import {
18
18
  normalizeTheme,
19
19
  sortBreakpoints,
20
20
  transformTheme,
21
- } from "./responsive"
21
+ } from './responsive'
22
22
  import type {
23
23
  AlignContent,
24
24
  AlignContentAlignXKeys,
@@ -27,7 +27,7 @@ import type {
27
27
  ExtendCss,
28
28
  Styles,
29
29
  StylesTheme,
30
- } from "./styles"
30
+ } from './styles'
31
31
  import {
32
32
  ALIGN_CONTENT_DIRECTION,
33
33
  ALIGN_CONTENT_MAP_X,
@@ -35,10 +35,10 @@ import {
35
35
  alignContent,
36
36
  extendCss,
37
37
  styles,
38
- } from "./styles"
39
- import type { BrowserColors, Color, Defaults, PropertyValue, UnitValue } from "./types"
40
- import type { StripUnit, Value, Values } from "./units"
41
- import { stripUnit, value, values } from "./units"
38
+ } from './styles'
39
+ import type { BrowserColors, Color, Defaults, PropertyValue, UnitValue } from './types'
40
+ import type { StripUnit, Value, Values } from './units'
41
+ import { stripUnit, value, values } from './units'
42
42
 
43
43
  export type {
44
44
  AlignContent,
@@ -30,10 +30,10 @@ const createMediaQueries: CreateMediaQueries = ((props: {
30
30
  const emSize = breakpointValue / rootSize
31
31
 
32
32
  acc[key] = (...args: [TemplateStringsArray, ...any[]]) => css`
33
- @media only screen and (min-width: ${emSize}em) {
34
- ${css(...args)};
35
- }
36
- `
33
+ @media only screen and (min-width: ${emSize}em) {
34
+ ${css(...args)};
35
+ }
36
+ `
37
37
  }
38
38
 
39
39
  return acc
@@ -1,14 +1,14 @@
1
- export type { Breakpoints } from "./breakpoints"
2
- export { default as breakpoints } from "./breakpoints"
3
- export type { CreateMediaQueries } from "./createMediaQueries"
4
- export { default as createMediaQueries } from "./createMediaQueries"
5
- export type { MakeItResponsive, MakeItResponsiveStyles } from "./makeItResponsive"
6
- export { default as makeItResponsive } from "./makeItResponsive"
7
- export type { NormalizeTheme } from "./normalizeTheme"
8
- export { default as normalizeTheme } from "./normalizeTheme"
9
- export type { OptimizeTheme } from "./optimizeTheme"
10
- export { default as optimizeTheme } from "./optimizeTheme"
11
- export type { SortBreakpoints } from "./sortBreakpoints"
12
- export { default as sortBreakpoints } from "./sortBreakpoints"
13
- export type { TransformTheme } from "./transformTheme"
14
- export { default as transformTheme } from "./transformTheme"
1
+ export type { Breakpoints } from './breakpoints'
2
+ export { default as breakpoints } from './breakpoints'
3
+ export type { CreateMediaQueries } from './createMediaQueries'
4
+ export { default as createMediaQueries } from './createMediaQueries'
5
+ export type { MakeItResponsive, MakeItResponsiveStyles } from './makeItResponsive'
6
+ export { default as makeItResponsive } from './makeItResponsive'
7
+ export type { NormalizeTheme } from './normalizeTheme'
8
+ export { default as normalizeTheme } from './normalizeTheme'
9
+ export type { OptimizeTheme } from './optimizeTheme'
10
+ export { default as optimizeTheme } from './optimizeTheme'
11
+ export type { SortBreakpoints } from './sortBreakpoints'
12
+ export { default as sortBreakpoints } from './sortBreakpoints'
13
+ export type { TransformTheme } from './transformTheme'
14
+ export { default as transformTheme } from './transformTheme'
@@ -1,9 +1,9 @@
1
- import { isEmpty } from "@pyreon/ui-core"
2
- import type createMediaQueries from "./createMediaQueries"
3
- import normalizeTheme from "./normalizeTheme"
4
- import optimizeTheme from "./optimizeTheme"
5
- import type sortBreakpoints from "./sortBreakpoints"
6
- import transformTheme from "./transformTheme"
1
+ import { isEmpty } from '@pyreon/ui-core'
2
+ import type createMediaQueries from './createMediaQueries'
3
+ import normalizeTheme from './normalizeTheme'
4
+ import optimizeTheme from './optimizeTheme'
5
+ import type sortBreakpoints from './sortBreakpoints'
6
+ import transformTheme from './transformTheme'
7
7
 
8
8
  type Css = (strings: TemplateStringsArray, ...values: any[]) => any
9
9
 
@@ -51,11 +51,11 @@ const themeCache = new WeakMap<
51
51
  >()
52
52
 
53
53
  const makeItResponsive: MakeItResponsive =
54
- ({ theme: customTheme, key = "", css, styles, normalize = true }) =>
54
+ ({ theme: customTheme, key = '', css, styles, normalize = true }) =>
55
55
  ({ theme = {}, ...props }) => {
56
56
  const internalTheme = customTheme || props[key]
57
57
 
58
- if (isEmpty(internalTheme)) return ""
58
+ if (isEmpty(internalTheme)) return ''
59
59
 
60
60
  const { rootSize, breakpoints, __PYREON__, ...restTheme } = theme as Theme
61
61
 
@@ -105,7 +105,7 @@ const makeItResponsive: MakeItResponsive =
105
105
  return sortedBreakpoints.map((item: string) => {
106
106
  const breakpointTheme = optimizedTheme[item]
107
107
 
108
- if (!breakpointTheme || !media) return ""
108
+ if (!breakpointTheme || !media) return ''
109
109
 
110
110
  const result = renderStyles(breakpointTheme)
111
111
 
@@ -31,7 +31,7 @@ const handleObjectCb =
31
31
  const handleValueCb = (value: unknown) => () => value
32
32
 
33
33
  const shouldNormalize = (props: Record<string, any>) =>
34
- Object.values(props).some((item) => typeof item === "object" || Array.isArray(item))
34
+ Object.values(props).some((item) => typeof item === 'object' || Array.isArray(item))
35
35
 
36
36
  export type NormalizeTheme = ({
37
37
  theme,
@@ -52,7 +52,7 @@ const normalizeTheme: NormalizeTheme = ({ theme, breakpoints }) => {
52
52
 
53
53
  if (Array.isArray(value)) {
54
54
  result[key] = getBpValues(handleArrayCb(value as (string | number)[]))
55
- } else if (typeof value === "object") {
55
+ } else if (typeof value === 'object') {
56
56
  result[key] = getBpValues(handleObjectCb(value as Record<string, any>))
57
57
  } else {
58
58
  result[key] = getBpValues(handleValueCb(value))
@@ -1,4 +1,4 @@
1
- import { isEmpty, set } from "@pyreon/ui-core"
1
+ import { isEmpty, set } from '@pyreon/ui-core'
2
2
 
3
3
  const removeUnexpectedKeys = (obj: Record<string, unknown>, keys: string[]) => {
4
4
  const result: Record<string, unknown> = {}
@@ -31,7 +31,7 @@ const transformTheme: TransformTheme = ({ theme, breakpoints }) => {
31
31
  if (indexBreakpoint == null) return
32
32
  set(result, [indexBreakpoint, key], child)
33
33
  })
34
- } else if (typeof value === "object" && value !== null) {
34
+ } else if (typeof value === 'object' && value !== null) {
35
35
  Object.entries(value).forEach(([childKey, childValue]) => {
36
36
  set(result, [childKey, key], childValue)
37
37
  })