@leafer-ui/external 1.6.1 → 1.6.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": "@leafer-ui/external",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "description": "@leafer-ui/external",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,9 +22,9 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.6.1"
25
+ "@leafer/core": "1.6.3"
26
26
  },
27
27
  "devDependencies": {
28
- "@leafer-ui/interface": "1.6.1"
28
+ "@leafer-ui/interface": "1.6.3"
29
29
  }
30
30
  }
package/src/color.ts ADDED
@@ -0,0 +1,28 @@
1
+ export function hasTransparent(color?: string): boolean {
2
+
3
+ if (!color || color.length === 7 || color.length === 4) return false
4
+ if (color === 'transparent') return true // transparent keyword
5
+
6
+ const first = color[0]
7
+
8
+ if (first === '#') {
9
+
10
+ // hex
11
+ switch (color.length) {
12
+ case 5: return color[4] !== 'f' && color[4] !== 'F' // #RGBA
13
+ case 9: return (color[7] !== 'f' && color[7] !== 'F') || (color[8] !== 'f' && color[8] !== 'F') // #RRGGBBAA
14
+ }
15
+
16
+ } else if (first === 'r' || first === 'h') {
17
+
18
+ // rgba(...) or hsla(...)
19
+ if (color[3] === 'a') {
20
+ const i = color.lastIndexOf(',')
21
+ if (i > -1) return parseFloat(color.slice(i + 1)) < 1
22
+ }
23
+
24
+ }
25
+
26
+ return false
27
+
28
+ }
package/src/index.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  // Implemented in partner
2
2
  import { IPaintModule, IPaintImageModule, IPaintGradientModule, IEffectModule, ITextConvertModule, IExportModule, IColorConvertModule, IPathArrowModule, IStateModule, IUnitData, ITransitionModule, ITransitionFunction, IFilterModule } from "@leafer-ui/interface"
3
3
  import { Plugin } from '@leafer/core'
4
+ import { hasTransparent } from './color'
4
5
 
5
6
 
6
7
  export const TextConvert = {} as ITextConvertModule
7
8
 
8
- export const ColorConvert = {} as IColorConvertModule
9
+ export const ColorConvert = {
10
+ hasTransparent
11
+ } as IColorConvertModule
9
12
 
10
13
  export const UnitConvert = {
11
14
  number(value: number | IUnitData, percentRefer?: number): number {