@spark-ui/tailwind-plugins 2.10.12 → 2.10.14

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.10.14](https://github.com/adevinta/spark/compare/@spark-ui/tailwind-plugins@2.10.13...@spark-ui/tailwind-plugins@2.10.14) (2023-06-01)
7
+
8
+ **Note:** Version bump only for package @spark-ui/tailwind-plugins
9
+
10
+ ## [2.10.13](https://github.com/adevinta/spark/compare/@spark-ui/tailwind-plugins@2.10.12...@spark-ui/tailwind-plugins@2.10.13) (2023-06-01)
11
+
12
+ **Note:** Version bump only for package @spark-ui/tailwind-plugins
13
+
6
14
  ## [2.10.12](https://github.com/adevinta/spark/compare/@spark-ui/tailwind-plugins@2.10.11...@spark-ui/tailwind-plugins@2.10.12) (2023-05-26)
7
15
 
8
16
  **Note:** Version bump only for package @spark-ui/tailwind-plugins
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spark-ui/tailwind-plugins",
3
- "version": "2.10.12",
3
+ "version": "2.10.14",
4
4
  "description": "Spark Tailwind plugins",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -23,5 +23,5 @@
23
23
  },
24
24
  "homepage": "https://sparkui.vercel.app",
25
25
  "license": "MIT",
26
- "gitHead": "4b26172028b2bd2b83ce1728eaa5170bf25d0afe"
26
+ "gitHead": "6c0c93a7fea372a3ac07244d50ba654dcc4107ed"
27
27
  }
@@ -16,9 +16,7 @@ function getCSSVariableDeclarations(_theme, htmlFontSize) {
16
16
 
17
17
  function traverse(theme, paths = []) {
18
18
  Object.entries(theme).forEach(([key, value]) => {
19
- if (isObject(value)) {
20
- return traverse(value, paths.concat(key))
21
- }
19
+ if (isObject(value)) return traverse(value, paths.concat(key))
22
20
 
23
21
  if (isStringOrNumber(value)) {
24
22
  const getFormattedValue = () => {
@@ -28,9 +26,7 @@ function getCSSVariableDeclarations(_theme, htmlFontSize) {
28
26
  return `${red} ${green} ${blue}`
29
27
  }
30
28
 
31
- if (/rem$/gi.test(value)) {
32
- return getRemEquivalentValue(value, htmlFontSize)
33
- }
29
+ if (/rem$/gi.test(value)) return getRemEquivalentValue(value, htmlFontSize)
34
30
 
35
31
  return value
36
32
  }
@@ -22,8 +22,8 @@ function getCSSVariableReferences(_theme) {
22
22
 
23
23
  const { fontSize, colors, screens } = tailwindCategoryKeys
24
24
 
25
- /* eslint-disable complexity */
26
25
  function traverse(theme, paths = []) {
26
+ /* eslint-disable-next-line complexity */
27
27
  Object.entries(theme).forEach(([key, value]) => {
28
28
  // 👀 see: https://tailwindcss.com/docs/font-size#providing-a-default-line-height
29
29
  if (isObject(value) && !paths.length && key === fontSize) {
@@ -64,13 +64,8 @@ function getCSSVariableReferences(_theme) {
64
64
 
65
65
  if (isObject(value)) {
66
66
  Object.keys(value).forEach(k => {
67
- if (k === DEFAULT_KEY) {
68
- return
69
- }
70
-
71
- if (!isObject(value[k]) && !isCamelCase(k)) {
72
- return
73
- }
67
+ if (k === DEFAULT_KEY) return
68
+ if (!isObject(value[k]) && !isCamelCase(k)) return
74
69
 
75
70
  const tmp = value[k]
76
71
  delete value[k]
@@ -89,9 +84,8 @@ function getCSSVariableReferences(_theme) {
89
84
  if (isColorValue && isHex(value)) {
90
85
  return `rgb(var(--${paths.join('-')}-${key}) / <alpha-value>)`
91
86
  }
92
- if (isScreenValue) {
93
- return String(value).toLowerCase()
94
- }
87
+
88
+ if (isScreenValue) return String(value).toLowerCase()
95
89
 
96
90
  return `var(--${paths.join('-')}-${key.toLowerCase()})`
97
91
  })()
@@ -6,7 +6,7 @@ const match6or8Hex = `#?[${hexCharacters}]{6}([${hexCharacters}]{2})?`
6
6
  const nonHexChars = new RegExp(`[^#${hexCharacters}]`, 'gi')
7
7
  const validHexSize = new RegExp(`^${match3or4Hex}$|^${match6or8Hex}$`, 'i')
8
8
 
9
- /* eslint-disable complexity */
9
+ /* eslint-disable-next-line complexity */
10
10
  function hexRgb(hex, options = {}) {
11
11
  if (typeof hex !== 'string' || nonHexChars.test(hex) || !validHexSize.test(hex)) {
12
12
  throw new TypeError('Expected a valid hex string')
@@ -40,18 +40,15 @@ module.exports = plugin.withOptions(
40
40
 
41
41
  const { htmlFontSize = 16, themes } = opts
42
42
 
43
- if (!themes.default) {
44
- throw new Error(missingDefaultThemeErrorMsg)
45
- }
43
+ if (!themes.default) throw new Error(missingDefaultThemeErrorMsg)
46
44
 
47
45
  const { missingItems, additionalItems } = retrieveArrayDifferences({
48
46
  ref: getAllObjectKeys(themeUtils.defaultTheme),
49
47
  comp: getAllObjectKeys(themes.default),
50
48
  })
51
49
 
52
- if (missingItems.length) {
53
- throw new Error(missingItemsErrorMsg('default', missingItems))
54
- }
50
+ if (missingItems.length) throw new Error(missingItemsErrorMsg('default', missingItems))
51
+
55
52
  if (additionalItems.length) {
56
53
  throw new Error(additionalItemsErrorMsg('default', additionalItems))
57
54
  }
@@ -61,21 +58,17 @@ module.exports = plugin.withOptions(
61
58
  })
62
59
 
63
60
  Object.entries(themes).forEach(([key, value]) => {
64
- if (key === 'default') {
65
- return
66
- }
61
+ if (key === 'default') return
67
62
 
63
+ /* eslint-disable-next-line @typescript-eslint/no-shadow */
68
64
  const { missingItems, additionalItems } = retrieveArrayDifferences({
69
65
  ref: getAllObjectKeys(themeUtils.defaultTheme),
70
66
  comp: getAllObjectKeys(value),
71
67
  })
72
68
 
73
- if (missingItems.length) {
74
- throw new Error(missingItemsErrorMsg(key, missingItems))
75
- }
76
- if (additionalItems.length) {
77
- throw new Error(additionalItemsErrorMsg(key, additionalItems))
78
- }
69
+ if (missingItems.length) throw new Error(missingItemsErrorMsg(key, missingItems))
70
+
71
+ if (additionalItems.length) throw new Error(additionalItemsErrorMsg(key, additionalItems))
79
72
 
80
73
  addBase({
81
74
  [`[data-theme="${key}"]`]: getObjectDifferences(
@@ -92,9 +85,7 @@ module.exports = plugin.withOptions(
92
85
 
93
86
  const { themes } = opts
94
87
 
95
- if (!themes.default) {
96
- throw new Error(missingDefaultThemeErrorMsg)
97
- }
88
+ if (!themes.default) throw new Error(missingDefaultThemeErrorMsg)
98
89
 
99
90
  return { theme: getCSSVariableReferences(themes.default) }
100
91
  }
@@ -7,9 +7,7 @@ function isStringOrNumber(value) {
7
7
  }
8
8
 
9
9
  function isHex(value) {
10
- if (typeof value === 'number') {
11
- return false
12
- }
10
+ if (typeof value === 'number') return false
13
11
 
14
12
  const regexp = /^#[0-9a-fA-F]+$/
15
13
 
@@ -44,9 +42,7 @@ const doubleHyphensRegex = /(?<!var\()--+/g
44
42
  function getAllObjectKeys(obj, path = '') {
45
43
  return Object.keys(obj).flatMap(key => {
46
44
  const newPath = path ? `${path}.${key}` : key
47
- if (isObject(obj[key])) {
48
- return getAllObjectKeys(obj[key], newPath)
49
- }
45
+ if (isObject(obj[key])) return getAllObjectKeys(obj[key], newPath)
50
46
 
51
47
  return newPath
52
48
  })
@@ -72,9 +68,8 @@ function getObjectDifferences(reference, comparison) {
72
68
  const diffObj = {}
73
69
 
74
70
  Object.keys(comparison).forEach(key => {
75
- if (reference[key] === comparison[key]) {
76
- return
77
- }
71
+ if (reference[key] === comparison[key]) return
72
+
78
73
  diffObj[key] = comparison[key]
79
74
  })
80
75