@codeleap/styles 4.3.1 → 4.3.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/styles",
3
- "version": "4.3.1",
3
+ "version": "4.3.3",
4
4
  "main": "src/index.ts",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -9,7 +9,7 @@
9
9
  "directory": "packages/styles"
10
10
  },
11
11
  "devDependencies": {
12
- "@codeleap/config": "4.3.1",
12
+ "@codeleap/config": "4.3.3",
13
13
  "ts-node-dev": "1.1.8"
14
14
  },
15
15
  "scripts": {
@@ -28,6 +28,7 @@
28
28
  "@fastify/deepmerge": "1.3.0",
29
29
  "js-sha256": "0.11.0",
30
30
  "lz-string": "^1.5.0",
31
+ "rfdc": "^1.4.1",
31
32
  "zustand": "4.5.0"
32
33
  }
33
34
  }
package/package.json.bak CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/styles",
3
- "version": "4.3.1",
3
+ "version": "4.3.3",
4
4
  "main": "src/index.ts",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -28,6 +28,7 @@
28
28
  "@fastify/deepmerge": "1.3.0",
29
29
  "js-sha256": "0.11.0",
30
30
  "lz-string": "^1.5.0",
31
+ "rfdc": "^1.4.1",
31
32
  "zustand": "4.5.0"
32
33
  }
33
34
  }
@@ -5,10 +5,13 @@ import deepmerge from '@fastify/deepmerge'
5
5
  import { MultiplierFunction } from './spacing'
6
6
  import { defaultVariants } from './defaultVariants'
7
7
  import { dynamicVariants } from './dynamicVariants'
8
- import { ignoredStyleKeys, isSpacingKey } from './utils'
8
+ import { capitalize, ignoredStyleKeys, isSpacingKey } from './utils'
9
9
  import { StyleCache } from './StyleCache'
10
10
  import { minifier } from './minifier'
11
11
  import { StateStorage } from 'zustand/middleware'
12
+ import rfdc from 'rfdc'
13
+
14
+ const deepClone = rfdc()
12
15
 
13
16
  export class CodeleapStyleRegistry {
14
17
  stylesheets: Record<string, VariantStyleSheet> = {}
@@ -369,8 +372,6 @@ export class CodeleapStyleRegistry {
369
372
  return this.mergeStylesWithCache([defaultStyle], cache.key)
370
373
  }
371
374
 
372
- const isStyleObject = typeof style === 'object' && !isStyleArray
373
-
374
375
  if (typeof style === 'string') {
375
376
  const computedVariantStyle = this.computeVariantStyle(componentName, [style])
376
377
 
@@ -380,6 +381,8 @@ export class CodeleapStyleRegistry {
380
381
  )
381
382
  }
382
383
 
384
+ const isStyleObject = typeof style === 'object' && !isStyleArray
385
+
383
386
  if (isStyleObject) {
384
387
  const { isComposition, composition } = this.isCompositionStyle(registeredComponent, style)
385
388
 
@@ -521,17 +524,7 @@ export class CodeleapStyleRegistry {
521
524
  }
522
525
 
523
526
  private copyStyle(style: any) {
524
- let copiedStyle = null
525
-
526
- if (Array.isArray(style)) {
527
- copiedStyle = [...style]
528
- } else if (typeof style == 'object') {
529
- copiedStyle = { ...style }
530
- } else {
531
- copiedStyle = style
532
- }
533
-
534
- return copiedStyle
527
+ return deepClone(style)
535
528
  }
536
529
 
537
530
  createStyles<K extends string = string>(styles: Record<K, StyleProp<AnyRecord, ''>> | ((theme: ITheme) => Record<K, StyleProp<AnyRecord, ''>>)): Record<K, ICSS> {
@@ -565,4 +558,16 @@ export class CodeleapStyleRegistry {
565
558
  },
566
559
  })
567
560
  }
561
+
562
+ prefixStyle(prefix: string, style: any) {
563
+ const entries = Object.entries(style).map(e => {
564
+ const [key, value] = e
565
+
566
+ const elementKey = capitalize(key)
567
+
568
+ return [`${prefix}${elementKey}`, value]
569
+ })
570
+
571
+ return Object.fromEntries(entries)
572
+ }
568
573
  }