ngx-color 7.0.2 → 7.3.1
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/alpha/alpha-picker.component.d.ts +8 -0
- package/alpha/ngx-color-alpha.d.ts +2 -1
- package/alpha/package.json +6 -10
- package/alpha/public_api.d.ts +1 -0
- package/alpha.component.d.ts +9 -0
- package/block/block-swatches.component.d.ts +13 -8
- package/block/block.component.d.ts +9 -0
- package/block/ngx-color-block.d.ts +2 -2
- package/block/package.json +6 -10
- package/block/public_api.d.ts +2 -0
- package/checkboard.component.d.ts +7 -0
- package/chrome/chrome-fields.component.d.ts +3 -0
- package/chrome/chrome.component.d.ts +9 -0
- package/chrome/ngx-color-chrome.d.ts +2 -2
- package/chrome/package.json +6 -10
- package/chrome/public_api.d.ts +2 -0
- package/circle/circle-swatch.component.d.ts +3 -0
- package/circle/circle.component.d.ts +9 -0
- package/circle/ngx-color-circle.d.ts +2 -2
- package/circle/package.json +9 -10
- package/circle/public_api.d.ts +2 -0
- package/color-wrap.component.d.ts +27 -2
- package/compact/compact-color.component.d.ts +3 -0
- package/compact/compact-fields.component.d.ts +3 -0
- package/compact/compact.component.d.ts +10 -0
- package/compact/ngx-color-compact.d.ts +2 -3
- package/compact/package.json +6 -10
- package/compact/public_api.d.ts +3 -0
- package/coordinates.directive.d.ts +6 -0
- package/editable-input.component.d.ts +7 -0
- package/esm2020/alpha/alpha-picker.component.mjs +116 -0
- package/esm2020/alpha/ngx-color-alpha.mjs +5 -0
- package/esm2020/alpha/public_api.mjs +2 -0
- package/esm2020/alpha.component.mjs +186 -0
- package/esm2020/block/block-swatches.component.mjs +74 -0
- package/esm2020/block/block.component.mjs +199 -0
- package/esm2020/block/ngx-color-block.mjs +5 -0
- package/esm2020/block/public_api.mjs +3 -0
- package/esm2020/checkboard.component.mjs +66 -0
- package/esm2020/chrome/chrome-fields.component.mjs +356 -0
- package/esm2020/chrome/chrome.component.mjs +249 -0
- package/esm2020/chrome/ngx-color-chrome.mjs +5 -0
- package/esm2020/chrome/public_api.mjs +3 -0
- package/esm2020/circle/circle-swatch.component.mjs +85 -0
- package/esm2020/circle/circle.component.mjs +148 -0
- package/esm2020/circle/ngx-color-circle.mjs +5 -0
- package/esm2020/circle/public_api.mjs +3 -0
- package/esm2020/color-wrap.component.mjs +163 -0
- package/esm2020/compact/compact-color.component.mjs +91 -0
- package/esm2020/compact/compact-fields.component.mjs +186 -0
- package/esm2020/compact/compact.component.mjs +177 -0
- package/esm2020/compact/ngx-color-compact.mjs +5 -0
- package/esm2020/compact/public_api.mjs +4 -0
- package/esm2020/coordinates.directive.mjs +104 -0
- package/esm2020/editable-input.component.mjs +217 -0
- package/esm2020/github/github-swatch.component.mjs +67 -0
- package/esm2020/github/github.component.mjs +179 -0
- package/esm2020/github/ngx-color-github.mjs +5 -0
- package/esm2020/github/public_api.mjs +3 -0
- package/esm2020/helpers/checkboard.mjs +33 -0
- package/esm2020/helpers/color.interfaces.mjs +2 -0
- package/esm2020/helpers/color.mjs +60 -0
- package/esm2020/hue/hue-picker.component.mjs +113 -0
- package/esm2020/hue/ngx-color-hue.mjs +5 -0
- package/esm2020/hue/public_api.mjs +2 -0
- package/esm2020/hue.component.mjs +165 -0
- package/esm2020/material/material.component.mjs +211 -0
- package/esm2020/material/ngx-color-material.mjs +5 -0
- package/esm2020/material/public_api.mjs +2 -0
- package/esm2020/ngx-color.mjs +5 -0
- package/esm2020/photoshop/ngx-color-photoshop.mjs +5 -0
- package/esm2020/photoshop/photoshop-button.component.mjs +63 -0
- package/esm2020/photoshop/photoshop-fields.component.mjs +241 -0
- package/esm2020/photoshop/photoshop-previews.component.mjs +68 -0
- package/esm2020/photoshop/photoshop.component.mjs +258 -0
- package/esm2020/photoshop/public_api.mjs +5 -0
- package/esm2020/public_api.mjs +14 -0
- package/esm2020/raised.component.mjs +89 -0
- package/esm2020/saturation.component.mjs +136 -0
- package/esm2020/shade/ngx-color-shade.mjs +5 -0
- package/esm2020/shade/public_api.mjs +2 -0
- package/esm2020/shade/shade-picker.component.mjs +105 -0
- package/esm2020/shade.component.mjs +165 -0
- package/esm2020/sketch/ngx-color-sketch.mjs +5 -0
- package/esm2020/sketch/public_api.mjs +4 -0
- package/esm2020/sketch/sketch-fields.component.mjs +243 -0
- package/esm2020/sketch/sketch-preset-colors.component.mjs +98 -0
- package/esm2020/sketch/sketch.component.mjs +283 -0
- package/esm2020/slider/ngx-color-slider.mjs +5 -0
- package/esm2020/slider/public_api.mjs +4 -0
- package/esm2020/slider/slider-swatch.component.mjs +80 -0
- package/esm2020/slider/slider-swatches.component.mjs +135 -0
- package/esm2020/slider/slider.component.mjs +116 -0
- package/esm2020/swatch.component.mjs +125 -0
- package/esm2020/swatches/ngx-color-swatches.mjs +5 -0
- package/esm2020/swatches/public_api.mjs +4 -0
- package/esm2020/swatches/swatches-color.component.mjs +123 -0
- package/esm2020/swatches/swatches-group.component.mjs +64 -0
- package/esm2020/swatches/swatches.component.mjs +258 -0
- package/esm2020/twitter/ngx-color-twitter.mjs +5 -0
- package/esm2020/twitter/public_api.mjs +2 -0
- package/esm2020/twitter/twitter.component.mjs +255 -0
- package/fesm2015/ngx-color-alpha.mjs +123 -0
- package/fesm2015/ngx-color-alpha.mjs.map +1 -0
- package/fesm2015/ngx-color-block.mjs +275 -0
- package/fesm2015/ngx-color-block.mjs.map +1 -0
- package/fesm2015/ngx-color-chrome.mjs +606 -0
- package/fesm2015/ngx-color-chrome.mjs.map +1 -0
- package/fesm2015/ngx-color-circle.mjs +237 -0
- package/fesm2015/ngx-color-circle.mjs.map +1 -0
- package/fesm2015/ngx-color-compact.mjs +451 -0
- package/fesm2015/ngx-color-compact.mjs.map +1 -0
- package/fesm2015/ngx-color-github.mjs +250 -0
- package/fesm2015/ngx-color-github.mjs.map +1 -0
- package/fesm2015/ngx-color-hue.mjs +120 -0
- package/fesm2015/ngx-color-hue.mjs.map +1 -0
- package/fesm2015/ngx-color-material.mjs +218 -0
- package/fesm2015/ngx-color-material.mjs.map +1 -0
- package/fesm2015/ngx-color-photoshop.mjs +626 -0
- package/fesm2015/ngx-color-photoshop.mjs.map +1 -0
- package/fesm2015/ngx-color-shade.mjs +112 -0
- package/fesm2015/ngx-color-shade.mjs.map +1 -0
- package/fesm2015/ngx-color-sketch.mjs +620 -0
- package/fesm2015/ngx-color-sketch.mjs.map +1 -0
- package/fesm2015/ngx-color-slider.mjs +331 -0
- package/fesm2015/ngx-color-slider.mjs.map +1 -0
- package/fesm2015/ngx-color-swatches.mjs +441 -0
- package/fesm2015/ngx-color-swatches.mjs.map +1 -0
- package/fesm2015/ngx-color-twitter.mjs +262 -0
- package/fesm2015/ngx-color-twitter.mjs.map +1 -0
- package/fesm2015/ngx-color.mjs +1461 -0
- package/fesm2015/ngx-color.mjs.map +1 -0
- package/fesm2020/ngx-color-alpha.mjs +123 -0
- package/fesm2020/ngx-color-alpha.mjs.map +1 -0
- package/fesm2020/ngx-color-block.mjs +275 -0
- package/fesm2020/ngx-color-block.mjs.map +1 -0
- package/fesm2020/ngx-color-chrome.mjs +606 -0
- package/fesm2020/ngx-color-chrome.mjs.map +1 -0
- package/fesm2020/ngx-color-circle.mjs +237 -0
- package/fesm2020/ngx-color-circle.mjs.map +1 -0
- package/fesm2020/ngx-color-compact.mjs +451 -0
- package/fesm2020/ngx-color-compact.mjs.map +1 -0
- package/fesm2020/ngx-color-github.mjs +250 -0
- package/fesm2020/ngx-color-github.mjs.map +1 -0
- package/fesm2020/ngx-color-hue.mjs +120 -0
- package/fesm2020/ngx-color-hue.mjs.map +1 -0
- package/fesm2020/ngx-color-material.mjs +218 -0
- package/fesm2020/ngx-color-material.mjs.map +1 -0
- package/fesm2020/ngx-color-photoshop.mjs +626 -0
- package/fesm2020/ngx-color-photoshop.mjs.map +1 -0
- package/fesm2020/ngx-color-shade.mjs +112 -0
- package/fesm2020/ngx-color-shade.mjs.map +1 -0
- package/fesm2020/ngx-color-sketch.mjs +620 -0
- package/fesm2020/ngx-color-sketch.mjs.map +1 -0
- package/fesm2020/ngx-color-slider.mjs +331 -0
- package/fesm2020/ngx-color-slider.mjs.map +1 -0
- package/fesm2020/ngx-color-swatches.mjs +441 -0
- package/fesm2020/ngx-color-swatches.mjs.map +1 -0
- package/fesm2020/ngx-color-twitter.mjs +262 -0
- package/fesm2020/ngx-color-twitter.mjs.map +1 -0
- package/fesm2020/ngx-color.mjs +1466 -0
- package/fesm2020/ngx-color.mjs.map +1 -0
- package/github/github-swatch.component.d.ts +3 -0
- package/github/github.component.d.ts +9 -0
- package/github/ngx-color-github.d.ts +2 -2
- package/github/package.json +6 -10
- package/github/public_api.d.ts +2 -0
- package/hue/hue-picker.component.d.ts +8 -0
- package/hue/ngx-color-hue.d.ts +2 -1
- package/hue/package.json +6 -10
- package/hue/public_api.d.ts +1 -0
- package/hue.component.d.ts +8 -0
- package/material/material.component.d.ts +8 -0
- package/material/ngx-color-material.d.ts +2 -1
- package/material/package.json +6 -10
- package/material/public_api.d.ts +1 -0
- package/ngx-color.d.ts +1 -0
- package/package.json +137 -14
- package/photoshop/ngx-color-photoshop.d.ts +2 -4
- package/photoshop/package.json +6 -10
- package/photoshop/photoshop-button.component.d.ts +3 -0
- package/photoshop/photoshop-fields.component.d.ts +3 -0
- package/photoshop/photoshop-previews.component.d.ts +3 -0
- package/photoshop/photoshop.component.d.ts +11 -0
- package/photoshop/public_api.d.ts +4 -0
- package/raised.component.d.ts +7 -0
- package/saturation.component.d.ts +8 -0
- package/shade/ngx-color-shade.d.ts +2 -1
- package/shade/package.json +6 -10
- package/shade/public_api.d.ts +1 -0
- package/shade/shade-picker.component.d.ts +8 -0
- package/shade.component.d.ts +8 -0
- package/sketch/ngx-color-sketch.d.ts +2 -3
- package/sketch/package.json +6 -10
- package/sketch/public_api.d.ts +3 -0
- package/sketch/sketch-fields.component.d.ts +3 -0
- package/sketch/sketch-preset-colors.component.d.ts +3 -0
- package/sketch/sketch.component.d.ts +10 -0
- package/slider/ngx-color-slider.d.ts +2 -3
- package/slider/package.json +6 -10
- package/slider/public_api.d.ts +3 -0
- package/slider/slider-swatch.component.d.ts +3 -0
- package/slider/slider-swatches.component.d.ts +3 -0
- package/slider/slider.component.d.ts +10 -0
- package/swatch.component.d.ts +8 -0
- package/swatches/ngx-color-swatches.d.ts +2 -3
- package/swatches/package.json +9 -10
- package/swatches/public_api.d.ts +3 -0
- package/swatches/swatches-color.component.d.ts +3 -0
- package/swatches/swatches-group.component.d.ts +3 -0
- package/swatches/swatches.component.d.ts +10 -0
- package/twitter/ngx-color-twitter.d.ts +2 -1
- package/twitter/package.json +6 -10
- package/twitter/public_api.d.ts +1 -0
- package/twitter/twitter.component.d.ts +8 -0
- package/LICENSE +0 -21
- package/README.md +0 -280
- package/alpha/bundles/ngx-color-alpha.umd.js +0 -387
- package/alpha/bundles/ngx-color-alpha.umd.js.map +0 -1
- package/alpha/esm2015/alpha-picker.component.js +0 -72
- package/alpha/esm2015/ngx-color-alpha.js +0 -5
- package/alpha/fesm2015/ngx-color-alpha.js +0 -79
- package/alpha/fesm2015/ngx-color-alpha.js.map +0 -1
- package/alpha/ngx-color-alpha.metadata.json +0 -1
- package/block/bundles/ngx-color-block.umd.js +0 -455
- package/block/bundles/ngx-color-block.umd.js.map +0 -1
- package/block/esm2015/block-swatches.component.js +0 -58
- package/block/esm2015/block.component.js +0 -139
- package/block/esm2015/ngx-color-block.js +0 -6
- package/block/fesm2015/ngx-color-block.js +0 -202
- package/block/fesm2015/ngx-color-block.js.map +0 -1
- package/block/ngx-color-block.metadata.json +0 -1
- package/bundles/ngx-color.umd.js +0 -953
- package/bundles/ngx-color.umd.js.map +0 -1
- package/chrome/bundles/ngx-color-chrome.umd.js +0 -526
- package/chrome/bundles/ngx-color-chrome.umd.js.map +0 -1
- package/chrome/esm2015/chrome-fields.component.js +0 -255
- package/chrome/esm2015/chrome.component.js +0 -161
- package/chrome/esm2015/ngx-color-chrome.js +0 -6
- package/chrome/fesm2015/ngx-color-chrome.js +0 -420
- package/chrome/fesm2015/ngx-color-chrome.js.map +0 -1
- package/chrome/ngx-color-chrome.metadata.json +0 -1
- package/circle/bundles/ngx-color-circle.umd.js +0 -452
- package/circle/bundles/ngx-color-circle.umd.js.map +0 -1
- package/circle/esm2015/circle-swatch.component.js +0 -63
- package/circle/esm2015/circle.component.js +0 -97
- package/circle/esm2015/ngx-color-circle.js +0 -6
- package/circle/fesm2015/ngx-color-circle.js +0 -165
- package/circle/fesm2015/ngx-color-circle.js.map +0 -1
- package/circle/ngx-color-circle.metadata.json +0 -1
- package/compact/bundles/ngx-color-compact.umd.js +0 -562
- package/compact/bundles/ngx-color-compact.umd.js.map +0 -1
- package/compact/esm2015/compact-color.component.js +0 -70
- package/compact/esm2015/compact-fields.component.js +0 -142
- package/compact/esm2015/compact.component.js +0 -123
- package/compact/esm2015/ngx-color-compact.js +0 -7
- package/compact/fesm2015/ngx-color-compact.js +0 -336
- package/compact/fesm2015/ngx-color-compact.js.map +0 -1
- package/compact/ngx-color-compact.metadata.json +0 -1
- package/esm2015/alpha.component.js +0 -156
- package/esm2015/checkboard.component.js +0 -52
- package/esm2015/color-wrap.component.js +0 -82
- package/esm2015/coordinates.directive.js +0 -85
- package/esm2015/editable-input.component.js +0 -183
- package/esm2015/helpers/checkboard.js +0 -33
- package/esm2015/helpers/color.interfaces.js +0 -2
- package/esm2015/helpers/color.js +0 -60
- package/esm2015/hue.component.js +0 -140
- package/esm2015/ngx-color.js +0 -5
- package/esm2015/public_api.js +0 -14
- package/esm2015/raised.component.js +0 -73
- package/esm2015/saturation.component.js +0 -111
- package/esm2015/shade.component.js +0 -127
- package/esm2015/swatch.component.js +0 -85
- package/fesm2015/ngx-color.js +0 -1166
- package/fesm2015/ngx-color.js.map +0 -1
- package/github/bundles/ngx-color-github.umd.js +0 -430
- package/github/bundles/ngx-color-github.umd.js.map +0 -1
- package/github/esm2015/github-swatch.component.js +0 -48
- package/github/esm2015/github.component.js +0 -134
- package/github/esm2015/ngx-color-github.js +0 -6
- package/github/fesm2015/ngx-color-github.js +0 -187
- package/github/fesm2015/ngx-color-github.js.map +0 -1
- package/github/ngx-color-github.metadata.json +0 -1
- package/hue/bundles/ngx-color-hue.umd.js +0 -390
- package/hue/bundles/ngx-color-hue.umd.js.map +0 -1
- package/hue/esm2015/hue-picker.component.js +0 -70
- package/hue/esm2015/ngx-color-hue.js +0 -5
- package/hue/fesm2015/ngx-color-hue.js +0 -77
- package/hue/fesm2015/ngx-color-hue.js.map +0 -1
- package/hue/ngx-color-hue.metadata.json +0 -1
- package/material/bundles/ngx-color-material.umd.js +0 -438
- package/material/bundles/ngx-color-material.umd.js.map +0 -1
- package/material/esm2015/material.component.js +0 -149
- package/material/esm2015/ngx-color-material.js +0 -5
- package/material/fesm2015/ngx-color-material.js +0 -156
- package/material/fesm2015/ngx-color-material.js.map +0 -1
- package/material/ngx-color-material.metadata.json +0 -1
- package/ngx-color.metadata.json +0 -1
- package/photoshop/bundles/ngx-color-photoshop.umd.js +0 -554
- package/photoshop/bundles/ngx-color-photoshop.umd.js.map +0 -1
- package/photoshop/esm2015/ngx-color-photoshop.js +0 -8
- package/photoshop/esm2015/photoshop-button.component.js +0 -50
- package/photoshop/esm2015/photoshop-fields.component.js +0 -180
- package/photoshop/esm2015/photoshop-previews.component.js +0 -53
- package/photoshop/esm2015/photoshop.component.js +0 -169
- package/photoshop/fesm2015/ngx-color-photoshop.js +0 -452
- package/photoshop/fesm2015/ngx-color-photoshop.js.map +0 -1
- package/photoshop/ngx-color-photoshop.metadata.json +0 -1
- package/shade/bundles/ngx-color-shade.umd.js +0 -382
- package/shade/bundles/ngx-color-shade.umd.js.map +0 -1
- package/shade/esm2015/ngx-color-shade.js +0 -5
- package/shade/esm2015/shade-picker.component.js +0 -63
- package/shade/fesm2015/ngx-color-shade.js +0 -70
- package/shade/fesm2015/ngx-color-shade.js.map +0 -1
- package/shade/ngx-color-shade.metadata.json +0 -1
- package/sketch/bundles/ngx-color-sketch.umd.js +0 -568
- package/sketch/bundles/ngx-color-sketch.umd.js.map +0 -1
- package/sketch/esm2015/ngx-color-sketch.js +0 -7
- package/sketch/esm2015/sketch-fields.component.js +0 -181
- package/sketch/esm2015/sketch-preset-colors.component.js +0 -76
- package/sketch/esm2015/sketch.component.js +0 -191
- package/sketch/fesm2015/ngx-color-sketch.js +0 -450
- package/sketch/fesm2015/ngx-color-sketch.js.map +0 -1
- package/sketch/ngx-color-sketch.metadata.json +0 -1
- package/slider/bundles/ngx-color-slider.umd.js +0 -453
- package/slider/bundles/ngx-color-slider.umd.js.map +0 -1
- package/slider/esm2015/ngx-color-slider.js +0 -7
- package/slider/esm2015/slider-swatch.component.js +0 -65
- package/slider/esm2015/slider-swatches.component.js +0 -84
- package/slider/esm2015/slider.component.js +0 -69
- package/slider/fesm2015/ngx-color-slider.js +0 -221
- package/slider/fesm2015/ngx-color-slider.js.map +0 -1
- package/slider/ngx-color-slider.metadata.json +0 -1
- package/swatches/bundles/ngx-color-swatches.umd.js +0 -595
- package/swatches/bundles/ngx-color-swatches.umd.js.map +0 -1
- package/swatches/esm2015/ngx-color-swatches.js +0 -7
- package/swatches/esm2015/swatches-color.component.js +0 -90
- package/swatches/esm2015/swatches-group.component.js +0 -42
- package/swatches/esm2015/swatches.component.js +0 -205
- package/swatches/fesm2015/ngx-color-swatches.js +0 -339
- package/swatches/fesm2015/ngx-color-swatches.js.map +0 -1
- package/swatches/ngx-color-swatches.metadata.json +0 -1
- package/twitter/bundles/ngx-color-twitter.umd.js +0 -416
- package/twitter/bundles/ngx-color-twitter.umd.js.map +0 -1
- package/twitter/esm2015/ngx-color-twitter.js +0 -5
- package/twitter/esm2015/twitter.component.js +0 -195
- package/twitter/fesm2015/ngx-color-twitter.js +0 -202
- package/twitter/fesm2015/ngx-color-twitter.js.map +0 -1
- package/twitter/ngx-color-twitter.metadata.json +0 -1
@@ -0,0 +1,1466 @@
|
|
1
|
+
import * as i2 from '@angular/common';
|
2
|
+
import { CommonModule } from '@angular/common';
|
3
|
+
import * as i0 from '@angular/core';
|
4
|
+
import { Component, ChangeDetectionStrategy, Input, NgModule, Directive, Output, HostListener, EventEmitter, isDevMode, forwardRef } from '@angular/core';
|
5
|
+
import { Subject, Subscription, fromEvent } from 'rxjs';
|
6
|
+
import { distinctUntilChanged, debounceTime, tap } from 'rxjs/operators';
|
7
|
+
import { TinyColor } from '@ctrl/tinycolor';
|
8
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
9
|
+
|
10
|
+
const checkboardCache = {};
|
11
|
+
function render(c1, c2, size) {
|
12
|
+
if (typeof document === 'undefined') {
|
13
|
+
return null;
|
14
|
+
}
|
15
|
+
const canvas = document.createElement('canvas');
|
16
|
+
canvas.width = size * 2;
|
17
|
+
canvas.height = size * 2;
|
18
|
+
const ctx = canvas.getContext('2d');
|
19
|
+
if (!ctx) {
|
20
|
+
return null;
|
21
|
+
} // If no context can be found, return early.
|
22
|
+
ctx.fillStyle = c1;
|
23
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
24
|
+
ctx.fillStyle = c2;
|
25
|
+
ctx.fillRect(0, 0, size, size);
|
26
|
+
ctx.translate(size, size);
|
27
|
+
ctx.fillRect(0, 0, size, size);
|
28
|
+
return canvas.toDataURL();
|
29
|
+
}
|
30
|
+
function getCheckerboard(c1, c2, size) {
|
31
|
+
const key = `${c1}-${c2}-${size}`;
|
32
|
+
if (checkboardCache[key]) {
|
33
|
+
return checkboardCache[key];
|
34
|
+
}
|
35
|
+
const checkboard = render(c1, c2, size);
|
36
|
+
if (!checkboard) {
|
37
|
+
return null;
|
38
|
+
}
|
39
|
+
checkboardCache[key] = checkboard;
|
40
|
+
return checkboard;
|
41
|
+
}
|
42
|
+
|
43
|
+
class CheckboardComponent {
|
44
|
+
constructor() {
|
45
|
+
this.white = 'transparent';
|
46
|
+
this.size = 8;
|
47
|
+
this.grey = 'rgba(0,0,0,.08)';
|
48
|
+
}
|
49
|
+
ngOnInit() {
|
50
|
+
const background = getCheckerboard(this.white, this.grey, this.size);
|
51
|
+
this.gridStyles = {
|
52
|
+
borderRadius: this.borderRadius,
|
53
|
+
boxShadow: this.boxShadow,
|
54
|
+
background: `url(${background}) center left`,
|
55
|
+
};
|
56
|
+
}
|
57
|
+
}
|
58
|
+
CheckboardComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CheckboardComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
59
|
+
CheckboardComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: CheckboardComponent, selector: "color-checkboard", inputs: { white: "white", size: "size", grey: "grey", boxShadow: "boxShadow", borderRadius: "borderRadius" }, ngImport: i0, template: `<div class="grid" [ngStyle]="gridStyles"></div>`, isInline: true, styles: [".grid{top:0px;right:0px;bottom:0px;left:0px;position:absolute}\n"], directives: [{ type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
60
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CheckboardComponent, decorators: [{
|
61
|
+
type: Component,
|
62
|
+
args: [{
|
63
|
+
selector: 'color-checkboard',
|
64
|
+
template: `<div class="grid" [ngStyle]="gridStyles"></div>`,
|
65
|
+
styles: [
|
66
|
+
`
|
67
|
+
.grid {
|
68
|
+
top: 0px;
|
69
|
+
right: 0px;
|
70
|
+
bottom: 0px;
|
71
|
+
left: 0px;
|
72
|
+
position: absolute;
|
73
|
+
}
|
74
|
+
`,
|
75
|
+
],
|
76
|
+
preserveWhitespaces: false,
|
77
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
78
|
+
}]
|
79
|
+
}], propDecorators: { white: [{
|
80
|
+
type: Input
|
81
|
+
}], size: [{
|
82
|
+
type: Input
|
83
|
+
}], grey: [{
|
84
|
+
type: Input
|
85
|
+
}], boxShadow: [{
|
86
|
+
type: Input
|
87
|
+
}], borderRadius: [{
|
88
|
+
type: Input
|
89
|
+
}] } });
|
90
|
+
class CheckboardModule {
|
91
|
+
}
|
92
|
+
CheckboardModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CheckboardModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
93
|
+
CheckboardModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CheckboardModule, declarations: [CheckboardComponent], imports: [CommonModule], exports: [CheckboardComponent] });
|
94
|
+
CheckboardModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CheckboardModule, imports: [[CommonModule]] });
|
95
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CheckboardModule, decorators: [{
|
96
|
+
type: NgModule,
|
97
|
+
args: [{
|
98
|
+
declarations: [CheckboardComponent],
|
99
|
+
exports: [CheckboardComponent],
|
100
|
+
imports: [CommonModule],
|
101
|
+
}]
|
102
|
+
}] });
|
103
|
+
|
104
|
+
class CoordinatesDirective {
|
105
|
+
constructor(el) {
|
106
|
+
this.el = el;
|
107
|
+
this.coordinatesChange = new Subject();
|
108
|
+
this.mousechange = new Subject();
|
109
|
+
this.mouseListening = false;
|
110
|
+
}
|
111
|
+
mousemove($event, x, y, isTouch = false) {
|
112
|
+
if (this.mouseListening) {
|
113
|
+
$event.preventDefault();
|
114
|
+
this.mousechange.next({ $event, x, y, isTouch });
|
115
|
+
}
|
116
|
+
}
|
117
|
+
mouseup() {
|
118
|
+
this.mouseListening = false;
|
119
|
+
}
|
120
|
+
mousedown($event, x, y, isTouch = false) {
|
121
|
+
$event.preventDefault();
|
122
|
+
this.mouseListening = true;
|
123
|
+
this.mousechange.next({ $event, x, y, isTouch });
|
124
|
+
}
|
125
|
+
ngOnInit() {
|
126
|
+
this.sub = this.mousechange
|
127
|
+
.pipe(
|
128
|
+
// limit times it is updated for the same area
|
129
|
+
distinctUntilChanged((p, q) => p.x === q.x && p.y === q.y))
|
130
|
+
.subscribe(n => this.handleChange(n.x, n.y, n.$event, n.isTouch));
|
131
|
+
}
|
132
|
+
ngOnDestroy() {
|
133
|
+
this.sub.unsubscribe();
|
134
|
+
}
|
135
|
+
handleChange(x, y, $event, isTouch) {
|
136
|
+
const containerWidth = this.el.nativeElement.clientWidth;
|
137
|
+
const containerHeight = this.el.nativeElement.clientHeight;
|
138
|
+
const left = x -
|
139
|
+
(this.el.nativeElement.getBoundingClientRect().left + window.pageXOffset);
|
140
|
+
let top = y - this.el.nativeElement.getBoundingClientRect().top;
|
141
|
+
if (!isTouch) {
|
142
|
+
top = top - window.pageYOffset;
|
143
|
+
}
|
144
|
+
this.coordinatesChange.next({
|
145
|
+
x,
|
146
|
+
y,
|
147
|
+
top,
|
148
|
+
left,
|
149
|
+
containerWidth,
|
150
|
+
containerHeight,
|
151
|
+
$event,
|
152
|
+
});
|
153
|
+
}
|
154
|
+
}
|
155
|
+
CoordinatesDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CoordinatesDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
156
|
+
CoordinatesDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: CoordinatesDirective, selector: "[ngx-color-coordinates]", outputs: { coordinatesChange: "coordinatesChange" }, host: { listeners: { "window:mousemove": "mousemove($event,$event.pageX,$event.pageY)", "window:touchmove": "mousemove($event,$event.touches[0].clientX,$event.touches[0].clientY,true)", "window:mouseup": "mouseup()", "window:touchend": "mouseup()", "mousedown": "mousedown($event,$event.pageX,$event.pageY)", "touchstart": "mousedown($event,$event.touches[0].clientX,$event.touches[0].clientY,true)" } }, ngImport: i0 });
|
157
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CoordinatesDirective, decorators: [{
|
158
|
+
type: Directive,
|
159
|
+
args: [{ selector: '[ngx-color-coordinates]' }]
|
160
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { coordinatesChange: [{
|
161
|
+
type: Output
|
162
|
+
}], mousemove: [{
|
163
|
+
type: HostListener,
|
164
|
+
args: ['window:mousemove', ['$event', '$event.pageX', '$event.pageY']]
|
165
|
+
}, {
|
166
|
+
type: HostListener,
|
167
|
+
args: ['window:touchmove', [
|
168
|
+
'$event',
|
169
|
+
'$event.touches[0].clientX',
|
170
|
+
'$event.touches[0].clientY',
|
171
|
+
'true',
|
172
|
+
]]
|
173
|
+
}], mouseup: [{
|
174
|
+
type: HostListener,
|
175
|
+
args: ['window:mouseup']
|
176
|
+
}, {
|
177
|
+
type: HostListener,
|
178
|
+
args: ['window:touchend']
|
179
|
+
}], mousedown: [{
|
180
|
+
type: HostListener,
|
181
|
+
args: ['mousedown', ['$event', '$event.pageX', '$event.pageY']]
|
182
|
+
}, {
|
183
|
+
type: HostListener,
|
184
|
+
args: ['touchstart', [
|
185
|
+
'$event',
|
186
|
+
'$event.touches[0].clientX',
|
187
|
+
'$event.touches[0].clientY',
|
188
|
+
'true',
|
189
|
+
]]
|
190
|
+
}] } });
|
191
|
+
class CoordinatesModule {
|
192
|
+
}
|
193
|
+
CoordinatesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CoordinatesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
194
|
+
CoordinatesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CoordinatesModule, declarations: [CoordinatesDirective], exports: [CoordinatesDirective] });
|
195
|
+
CoordinatesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CoordinatesModule });
|
196
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: CoordinatesModule, decorators: [{
|
197
|
+
type: NgModule,
|
198
|
+
args: [{
|
199
|
+
declarations: [CoordinatesDirective],
|
200
|
+
exports: [CoordinatesDirective],
|
201
|
+
}]
|
202
|
+
}] });
|
203
|
+
|
204
|
+
class AlphaComponent {
|
205
|
+
constructor() {
|
206
|
+
this.direction = 'horizontal';
|
207
|
+
this.onChange = new EventEmitter();
|
208
|
+
}
|
209
|
+
ngOnChanges() {
|
210
|
+
if (this.direction === 'vertical') {
|
211
|
+
this.pointerLeft = 0;
|
212
|
+
this.pointerTop = this.rgb.a * 100;
|
213
|
+
this.gradient = {
|
214
|
+
background: `linear-gradient(to bottom, rgba(${this.rgb.r},${this.rgb.g},${this.rgb.b}, 0) 0%,
|
215
|
+
rgba(${this.rgb.r},${this.rgb.g},${this.rgb.b}, 1) 100%)`,
|
216
|
+
};
|
217
|
+
}
|
218
|
+
else {
|
219
|
+
this.gradient = {
|
220
|
+
background: `linear-gradient(to right, rgba(${this.rgb.r},${this.rgb.g},${this.rgb.b}, 0) 0%,
|
221
|
+
rgba(${this.rgb.r},${this.rgb.g},${this.rgb.b}, 1) 100%)`,
|
222
|
+
};
|
223
|
+
this.pointerLeft = this.rgb.a * 100;
|
224
|
+
}
|
225
|
+
}
|
226
|
+
handleChange({ top, left, containerHeight, containerWidth, $event }) {
|
227
|
+
let data;
|
228
|
+
if (this.direction === 'vertical') {
|
229
|
+
let a;
|
230
|
+
if (top < 0) {
|
231
|
+
a = 0;
|
232
|
+
}
|
233
|
+
else if (top > containerHeight) {
|
234
|
+
a = 1;
|
235
|
+
}
|
236
|
+
else {
|
237
|
+
a = Math.round(top * 100 / containerHeight) / 100;
|
238
|
+
}
|
239
|
+
if (this.hsl.a !== a) {
|
240
|
+
data = {
|
241
|
+
h: this.hsl.h,
|
242
|
+
s: this.hsl.s,
|
243
|
+
l: this.hsl.l,
|
244
|
+
a,
|
245
|
+
source: 'rgb',
|
246
|
+
};
|
247
|
+
}
|
248
|
+
}
|
249
|
+
else {
|
250
|
+
let a;
|
251
|
+
if (left < 0) {
|
252
|
+
a = 0;
|
253
|
+
}
|
254
|
+
else if (left > containerWidth) {
|
255
|
+
a = 1;
|
256
|
+
}
|
257
|
+
else {
|
258
|
+
a = Math.round(left * 100 / containerWidth) / 100;
|
259
|
+
}
|
260
|
+
if (this.hsl.a !== a) {
|
261
|
+
data = {
|
262
|
+
h: this.hsl.h,
|
263
|
+
s: this.hsl.s,
|
264
|
+
l: this.hsl.l,
|
265
|
+
a,
|
266
|
+
source: 'rgb',
|
267
|
+
};
|
268
|
+
}
|
269
|
+
}
|
270
|
+
if (!data) {
|
271
|
+
return;
|
272
|
+
}
|
273
|
+
this.onChange.emit({ data, $event });
|
274
|
+
}
|
275
|
+
}
|
276
|
+
AlphaComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AlphaComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
277
|
+
AlphaComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: AlphaComponent, selector: "color-alpha", inputs: { hsl: "hsl", rgb: "rgb", pointer: "pointer", shadow: "shadow", radius: "radius", direction: "direction" }, outputs: { onChange: "onChange" }, usesOnChanges: true, ngImport: i0, template: `
|
278
|
+
<div class="alpha" [style.border-radius]="radius">
|
279
|
+
<div class="alpha-checkboard">
|
280
|
+
<color-checkboard></color-checkboard>
|
281
|
+
</div>
|
282
|
+
<div class="alpha-gradient" [ngStyle]="gradient" [style.box-shadow]="shadow" [style.border-radius]="radius"></div>
|
283
|
+
<div ngx-color-coordinates (coordinatesChange)="handleChange($event)" class="alpha-container color-alpha-{{direction}}">
|
284
|
+
<div class="alpha-pointer" [style.left.%]="pointerLeft" [style.top.%]="pointerTop">
|
285
|
+
<div class="alpha-slider" [ngStyle]="pointer"></div>
|
286
|
+
</div>
|
287
|
+
</div>
|
288
|
+
</div>
|
289
|
+
`, isInline: true, styles: [".alpha{position:absolute;top:0;bottom:0;left:0;right:0}.alpha-checkboard{position:absolute;top:0;bottom:0;left:0;right:0;overflow:hidden}.alpha-gradient{position:absolute;top:0;bottom:0;left:0;right:0}.alpha-container{position:relative;height:100%;margin:0 3px}.alpha-pointer{position:absolute}.alpha-slider{width:4px;border-radius:1px;height:8px;box-shadow:0 0 2px #0009;background:#fff;margin-top:1px;transform:translate(-2px)}\n"], components: [{ type: CheckboardComponent, selector: "color-checkboard", inputs: ["white", "size", "grey", "boxShadow", "borderRadius"] }], directives: [{ type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: CoordinatesDirective, selector: "[ngx-color-coordinates]", outputs: ["coordinatesChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
290
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AlphaComponent, decorators: [{
|
291
|
+
type: Component,
|
292
|
+
args: [{
|
293
|
+
selector: 'color-alpha',
|
294
|
+
template: `
|
295
|
+
<div class="alpha" [style.border-radius]="radius">
|
296
|
+
<div class="alpha-checkboard">
|
297
|
+
<color-checkboard></color-checkboard>
|
298
|
+
</div>
|
299
|
+
<div class="alpha-gradient" [ngStyle]="gradient" [style.box-shadow]="shadow" [style.border-radius]="radius"></div>
|
300
|
+
<div ngx-color-coordinates (coordinatesChange)="handleChange($event)" class="alpha-container color-alpha-{{direction}}">
|
301
|
+
<div class="alpha-pointer" [style.left.%]="pointerLeft" [style.top.%]="pointerTop">
|
302
|
+
<div class="alpha-slider" [ngStyle]="pointer"></div>
|
303
|
+
</div>
|
304
|
+
</div>
|
305
|
+
</div>
|
306
|
+
`,
|
307
|
+
styles: [
|
308
|
+
`
|
309
|
+
.alpha {
|
310
|
+
position: absolute;
|
311
|
+
top: 0;
|
312
|
+
bottom: 0;
|
313
|
+
left: 0;
|
314
|
+
right: 0;
|
315
|
+
}
|
316
|
+
.alpha-checkboard {
|
317
|
+
position: absolute;
|
318
|
+
top: 0;
|
319
|
+
bottom: 0;
|
320
|
+
left: 0;
|
321
|
+
right: 0;
|
322
|
+
overflow: hidden;
|
323
|
+
}
|
324
|
+
.alpha-gradient {
|
325
|
+
position: absolute;
|
326
|
+
top: 0;
|
327
|
+
bottom: 0;
|
328
|
+
left: 0;
|
329
|
+
right: 0;
|
330
|
+
}
|
331
|
+
.alpha-container {
|
332
|
+
position: relative;
|
333
|
+
height: 100%;
|
334
|
+
margin: 0 3px;
|
335
|
+
}
|
336
|
+
.alpha-pointer {
|
337
|
+
position: absolute;
|
338
|
+
}
|
339
|
+
.alpha-slider {
|
340
|
+
width: 4px;
|
341
|
+
border-radius: 1px;
|
342
|
+
height: 8px;
|
343
|
+
box-shadow: 0 0 2px rgba(0, 0, 0, .6);
|
344
|
+
background: #fff;
|
345
|
+
margin-top: 1px;
|
346
|
+
transform: translateX(-2px);
|
347
|
+
}
|
348
|
+
`,
|
349
|
+
],
|
350
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
351
|
+
preserveWhitespaces: false,
|
352
|
+
}]
|
353
|
+
}], propDecorators: { hsl: [{
|
354
|
+
type: Input
|
355
|
+
}], rgb: [{
|
356
|
+
type: Input
|
357
|
+
}], pointer: [{
|
358
|
+
type: Input
|
359
|
+
}], shadow: [{
|
360
|
+
type: Input
|
361
|
+
}], radius: [{
|
362
|
+
type: Input
|
363
|
+
}], direction: [{
|
364
|
+
type: Input
|
365
|
+
}], onChange: [{
|
366
|
+
type: Output
|
367
|
+
}] } });
|
368
|
+
class AlphaModule {
|
369
|
+
}
|
370
|
+
AlphaModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AlphaModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
371
|
+
AlphaModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AlphaModule, declarations: [AlphaComponent], imports: [CommonModule, CheckboardModule, CoordinatesModule], exports: [AlphaComponent] });
|
372
|
+
AlphaModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AlphaModule, imports: [[CommonModule, CheckboardModule, CoordinatesModule]] });
|
373
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AlphaModule, decorators: [{
|
374
|
+
type: NgModule,
|
375
|
+
args: [{
|
376
|
+
declarations: [AlphaComponent],
|
377
|
+
exports: [AlphaComponent],
|
378
|
+
imports: [CommonModule, CheckboardModule, CoordinatesModule],
|
379
|
+
}]
|
380
|
+
}] });
|
381
|
+
|
382
|
+
function simpleCheckForValidColor(data) {
|
383
|
+
const keysToCheck = ['r', 'g', 'b', 'a', 'h', 's', 'l', 'v'];
|
384
|
+
let checked = 0;
|
385
|
+
let passed = 0;
|
386
|
+
keysToCheck.forEach(letter => {
|
387
|
+
if (!data[letter]) {
|
388
|
+
return;
|
389
|
+
}
|
390
|
+
checked += 1;
|
391
|
+
if (!isNaN(data[letter])) {
|
392
|
+
passed += 1;
|
393
|
+
}
|
394
|
+
if (letter === 's' || letter === 'l') {
|
395
|
+
const percentPatt = /^\d+%$/;
|
396
|
+
if (percentPatt.test(data[letter])) {
|
397
|
+
passed += 1;
|
398
|
+
}
|
399
|
+
}
|
400
|
+
});
|
401
|
+
return checked === passed ? data : false;
|
402
|
+
}
|
403
|
+
function toState(data, oldHue, disableAlpha) {
|
404
|
+
const color = data.hex ? new TinyColor(data.hex) : new TinyColor(data);
|
405
|
+
if (disableAlpha) {
|
406
|
+
color.setAlpha(1);
|
407
|
+
}
|
408
|
+
const hsl = color.toHsl();
|
409
|
+
const hsv = color.toHsv();
|
410
|
+
const rgb = color.toRgb();
|
411
|
+
const hex = color.toHex();
|
412
|
+
if (hsl.s === 0) {
|
413
|
+
hsl.h = oldHue || 0;
|
414
|
+
hsv.h = oldHue || 0;
|
415
|
+
}
|
416
|
+
const transparent = hex === '000000' && rgb.a === 0;
|
417
|
+
return {
|
418
|
+
hsl,
|
419
|
+
hex: transparent ? 'transparent' : color.toHexString(),
|
420
|
+
rgb,
|
421
|
+
hsv,
|
422
|
+
oldHue: data.h || oldHue || hsl.h,
|
423
|
+
source: data.source,
|
424
|
+
};
|
425
|
+
}
|
426
|
+
function isValidHex(hex) {
|
427
|
+
return new TinyColor(hex).isValid;
|
428
|
+
}
|
429
|
+
function getContrastingColor(data) {
|
430
|
+
if (!data) {
|
431
|
+
return '#fff';
|
432
|
+
}
|
433
|
+
const col = toState(data);
|
434
|
+
if (col.hex === 'transparent') {
|
435
|
+
return 'rgba(0,0,0,0.4)';
|
436
|
+
}
|
437
|
+
const yiq = (col.rgb.r * 299 + col.rgb.g * 587 + col.rgb.b * 114) / 1000;
|
438
|
+
return yiq >= 128 ? '#000' : '#fff';
|
439
|
+
}
|
440
|
+
|
441
|
+
var ColorMode;
|
442
|
+
(function (ColorMode) {
|
443
|
+
ColorMode["HEX"] = "hex";
|
444
|
+
ColorMode["HSL"] = "hsl";
|
445
|
+
ColorMode["HSV"] = "hsv";
|
446
|
+
ColorMode["RGB"] = "rgb";
|
447
|
+
})(ColorMode || (ColorMode = {}));
|
448
|
+
class ColorWrap {
|
449
|
+
constructor() {
|
450
|
+
/**
|
451
|
+
* Descriptors the return color format if the component is used with two-way binding
|
452
|
+
*/
|
453
|
+
this.mode = ColorMode.HEX;
|
454
|
+
this.color = {
|
455
|
+
h: 250,
|
456
|
+
s: 0.5,
|
457
|
+
l: 0.2,
|
458
|
+
a: 1,
|
459
|
+
};
|
460
|
+
this.colorChange = new EventEmitter();
|
461
|
+
this.onChange = new EventEmitter();
|
462
|
+
this.onChangeComplete = new EventEmitter();
|
463
|
+
this.onSwatchHover = new EventEmitter();
|
464
|
+
this._onChangeCompleteSubscription = new Subscription();
|
465
|
+
this._onSwatchHoverSubscription = new Subscription();
|
466
|
+
}
|
467
|
+
ngOnInit() {
|
468
|
+
this.changes = this.onChange
|
469
|
+
.pipe(debounceTime(100), tap(event => {
|
470
|
+
this.onChangeComplete.emit(event);
|
471
|
+
switch (this.mode) {
|
472
|
+
case ColorMode.HEX:
|
473
|
+
this.colorChange.emit(event.color.hex);
|
474
|
+
break;
|
475
|
+
case ColorMode.HSL:
|
476
|
+
this.colorChange.emit(event.color.hsl);
|
477
|
+
break;
|
478
|
+
case ColorMode.HSV:
|
479
|
+
this.colorChange.emit(event.color.hsv);
|
480
|
+
break;
|
481
|
+
case ColorMode.RGB:
|
482
|
+
this.colorChange.emit(event.color.rgb);
|
483
|
+
break;
|
484
|
+
default:
|
485
|
+
const msg = `The mode '${this.mode}' is not supported`;
|
486
|
+
if (isDevMode()) {
|
487
|
+
throw new Error(msg);
|
488
|
+
}
|
489
|
+
else {
|
490
|
+
console.warn(msg);
|
491
|
+
}
|
492
|
+
break;
|
493
|
+
}
|
494
|
+
}))
|
495
|
+
.subscribe();
|
496
|
+
this.setState(toState(this.color, 0));
|
497
|
+
this.currentColor = this.hex;
|
498
|
+
}
|
499
|
+
ngOnChanges() {
|
500
|
+
this.setState(toState(this.color, this.oldHue));
|
501
|
+
}
|
502
|
+
ngOnDestroy() {
|
503
|
+
this.changes?.unsubscribe();
|
504
|
+
this._onChangeCompleteSubscription.unsubscribe();
|
505
|
+
this._onSwatchHoverSubscription.unsubscribe();
|
506
|
+
}
|
507
|
+
setState(data) {
|
508
|
+
this.oldHue = data.oldHue;
|
509
|
+
this.hsl = data.hsl;
|
510
|
+
this.hsv = data.hsv;
|
511
|
+
this.rgb = data.rgb;
|
512
|
+
this.hex = data.hex;
|
513
|
+
this.source = data.source;
|
514
|
+
this.afterValidChange();
|
515
|
+
}
|
516
|
+
handleChange(data, $event) {
|
517
|
+
const isValidColor = simpleCheckForValidColor(data);
|
518
|
+
if (isValidColor) {
|
519
|
+
const color = toState(data, data.h || this.oldHue, this.disableAlpha);
|
520
|
+
this.setState(color);
|
521
|
+
this.onChange.emit({ color, $event });
|
522
|
+
this.afterValidChange();
|
523
|
+
}
|
524
|
+
}
|
525
|
+
/** hook for components after a complete change */
|
526
|
+
afterValidChange() { }
|
527
|
+
handleSwatchHover(data, $event) {
|
528
|
+
const isValidColor = simpleCheckForValidColor(data);
|
529
|
+
if (isValidColor) {
|
530
|
+
const color = toState(data, data.h || this.oldHue);
|
531
|
+
this.setState(color);
|
532
|
+
this.onSwatchHover.emit({ color, $event });
|
533
|
+
}
|
534
|
+
}
|
535
|
+
registerOnChange(fn) {
|
536
|
+
this._onChangeCompleteSubscription.add(this.onChangeComplete.pipe(tap(event => fn(event.color.hex))).subscribe());
|
537
|
+
}
|
538
|
+
registerOnTouched(fn) {
|
539
|
+
this._onSwatchHoverSubscription.add(this.onSwatchHover.pipe(tap(() => fn())).subscribe());
|
540
|
+
}
|
541
|
+
setDisabledState(isDisabled) { }
|
542
|
+
writeValue(hex) {
|
543
|
+
this.color = hex;
|
544
|
+
}
|
545
|
+
}
|
546
|
+
ColorWrap.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ColorWrap, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
547
|
+
ColorWrap.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: ColorWrap, selector: "color-wrap", inputs: { className: "className", mode: "mode", color: "color" }, outputs: { colorChange: "colorChange", onChange: "onChange", onChangeComplete: "onChangeComplete", onSwatchHover: "onSwatchHover" }, providers: [
|
548
|
+
{
|
549
|
+
provide: NG_VALUE_ACCESSOR,
|
550
|
+
useExisting: forwardRef(() => ColorWrap),
|
551
|
+
multi: true,
|
552
|
+
}
|
553
|
+
], usesOnChanges: true, ngImport: i0, template: ``, isInline: true });
|
554
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ColorWrap, decorators: [{
|
555
|
+
type: Component,
|
556
|
+
args: [{
|
557
|
+
// create seletor base for test override property
|
558
|
+
selector: 'color-wrap',
|
559
|
+
template: ``,
|
560
|
+
providers: [
|
561
|
+
{
|
562
|
+
provide: NG_VALUE_ACCESSOR,
|
563
|
+
useExisting: forwardRef(() => ColorWrap),
|
564
|
+
multi: true,
|
565
|
+
}
|
566
|
+
]
|
567
|
+
}]
|
568
|
+
}], propDecorators: { className: [{
|
569
|
+
type: Input
|
570
|
+
}], mode: [{
|
571
|
+
type: Input
|
572
|
+
}], color: [{
|
573
|
+
type: Input
|
574
|
+
}], colorChange: [{
|
575
|
+
type: Output
|
576
|
+
}], onChange: [{
|
577
|
+
type: Output
|
578
|
+
}], onChangeComplete: [{
|
579
|
+
type: Output
|
580
|
+
}], onSwatchHover: [{
|
581
|
+
type: Output
|
582
|
+
}] } });
|
583
|
+
class ColorWrapModule {
|
584
|
+
}
|
585
|
+
ColorWrapModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ColorWrapModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
586
|
+
ColorWrapModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ColorWrapModule, declarations: [ColorWrap], imports: [CommonModule], exports: [ColorWrap] });
|
587
|
+
ColorWrapModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ColorWrapModule, imports: [[CommonModule]] });
|
588
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ColorWrapModule, decorators: [{
|
589
|
+
type: NgModule,
|
590
|
+
args: [{
|
591
|
+
declarations: [ColorWrap],
|
592
|
+
exports: [ColorWrap],
|
593
|
+
imports: [CommonModule],
|
594
|
+
}]
|
595
|
+
}] });
|
596
|
+
|
597
|
+
let nextUniqueId = 0;
|
598
|
+
class EditableInputComponent {
|
599
|
+
constructor() {
|
600
|
+
this.placeholder = '';
|
601
|
+
this.onChange = new EventEmitter();
|
602
|
+
this.focus = false;
|
603
|
+
this.uniqueId = `editableInput-${++nextUniqueId}`;
|
604
|
+
}
|
605
|
+
ngOnInit() {
|
606
|
+
this.wrapStyle = this.style && this.style.wrap ? this.style.wrap : {};
|
607
|
+
this.inputStyle = this.style && this.style.input ? this.style.input : {};
|
608
|
+
this.labelStyle = this.style && this.style.label ? this.style.label : {};
|
609
|
+
if (this.dragLabel) {
|
610
|
+
this.labelStyle.cursor = 'ew-resize';
|
611
|
+
}
|
612
|
+
}
|
613
|
+
handleFocus($event) {
|
614
|
+
this.focus = true;
|
615
|
+
}
|
616
|
+
handleFocusOut($event) {
|
617
|
+
this.focus = false;
|
618
|
+
this.currentValue = this.blurValue;
|
619
|
+
}
|
620
|
+
handleKeydown($event) {
|
621
|
+
// In case `e.target.value` is a percentage remove the `%` character
|
622
|
+
// and update accordingly with a percentage
|
623
|
+
// https://github.com/casesandberg/react-color/issues/383
|
624
|
+
const stringValue = String($event.target.value);
|
625
|
+
const isPercentage = stringValue.indexOf('%') > -1;
|
626
|
+
const num = Number(stringValue.replace(/%/g, ''));
|
627
|
+
if (isNaN(num)) {
|
628
|
+
return;
|
629
|
+
}
|
630
|
+
const amount = this.arrowOffset || 1;
|
631
|
+
// Up
|
632
|
+
if ($event.keyCode === 38) {
|
633
|
+
if (this.label) {
|
634
|
+
this.onChange.emit({
|
635
|
+
data: { [this.label]: num + amount },
|
636
|
+
$event,
|
637
|
+
});
|
638
|
+
}
|
639
|
+
else {
|
640
|
+
this.onChange.emit({ data: num + amount, $event });
|
641
|
+
}
|
642
|
+
if (isPercentage) {
|
643
|
+
this.currentValue = `${num + amount}%`;
|
644
|
+
}
|
645
|
+
else {
|
646
|
+
this.currentValue = num + amount;
|
647
|
+
}
|
648
|
+
}
|
649
|
+
// Down
|
650
|
+
if ($event.keyCode === 40) {
|
651
|
+
if (this.label) {
|
652
|
+
this.onChange.emit({
|
653
|
+
data: { [this.label]: num - amount },
|
654
|
+
$event,
|
655
|
+
});
|
656
|
+
}
|
657
|
+
else {
|
658
|
+
this.onChange.emit({ data: num - amount, $event });
|
659
|
+
}
|
660
|
+
if (isPercentage) {
|
661
|
+
this.currentValue = `${num - amount}%`;
|
662
|
+
}
|
663
|
+
else {
|
664
|
+
this.currentValue = num - amount;
|
665
|
+
}
|
666
|
+
}
|
667
|
+
}
|
668
|
+
handleKeyup($event) {
|
669
|
+
if ($event.keyCode === 40 || $event.keyCode === 38) {
|
670
|
+
return;
|
671
|
+
}
|
672
|
+
if (`${this.currentValue}` === $event.target.value) {
|
673
|
+
return;
|
674
|
+
}
|
675
|
+
if (this.label) {
|
676
|
+
this.onChange.emit({
|
677
|
+
data: { [this.label]: $event.target.value },
|
678
|
+
$event,
|
679
|
+
});
|
680
|
+
}
|
681
|
+
else {
|
682
|
+
this.onChange.emit({ data: $event.target.value, $event });
|
683
|
+
}
|
684
|
+
}
|
685
|
+
ngOnChanges() {
|
686
|
+
if (!this.focus) {
|
687
|
+
this.currentValue = String(this.value).toUpperCase();
|
688
|
+
this.blurValue = String(this.value).toUpperCase();
|
689
|
+
}
|
690
|
+
else {
|
691
|
+
this.blurValue = String(this.value).toUpperCase();
|
692
|
+
}
|
693
|
+
}
|
694
|
+
ngOnDestroy() {
|
695
|
+
this.unsubscribe();
|
696
|
+
}
|
697
|
+
subscribe() {
|
698
|
+
this.mousemove = fromEvent(document, 'mousemove').subscribe((ev) => this.handleDrag(ev));
|
699
|
+
this.mouseup = fromEvent(document, 'mouseup').subscribe(() => this.unsubscribe());
|
700
|
+
}
|
701
|
+
unsubscribe() {
|
702
|
+
if (this.mousemove) {
|
703
|
+
this.mousemove.unsubscribe();
|
704
|
+
}
|
705
|
+
if (this.mouseup) {
|
706
|
+
this.mouseup.unsubscribe();
|
707
|
+
}
|
708
|
+
}
|
709
|
+
handleMousedown($event) {
|
710
|
+
if (this.dragLabel) {
|
711
|
+
$event.preventDefault();
|
712
|
+
this.handleDrag($event);
|
713
|
+
this.subscribe();
|
714
|
+
}
|
715
|
+
}
|
716
|
+
handleDrag($event) {
|
717
|
+
if (this.dragLabel) {
|
718
|
+
const newValue = Math.round(this.value + $event.movementX);
|
719
|
+
if (newValue >= 0 && newValue <= this.dragMax) {
|
720
|
+
this.onChange.emit({ data: { [this.label]: newValue }, $event });
|
721
|
+
}
|
722
|
+
}
|
723
|
+
}
|
724
|
+
}
|
725
|
+
EditableInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EditableInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
726
|
+
EditableInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: EditableInputComponent, selector: "color-editable-input", inputs: { style: "style", label: "label", value: "value", arrowOffset: "arrowOffset", dragLabel: "dragLabel", dragMax: "dragMax", placeholder: "placeholder" }, outputs: { onChange: "onChange" }, usesOnChanges: true, ngImport: i0, template: `
|
727
|
+
<div class="wrap" [ngStyle]="wrapStyle">
|
728
|
+
<input
|
729
|
+
[ngStyle]="inputStyle"
|
730
|
+
spellCheck="false"
|
731
|
+
[value]="currentValue"
|
732
|
+
[placeholder]="placeholder"
|
733
|
+
(keydown)="handleKeydown($event)"
|
734
|
+
(keyup)="handleKeyup($event)"
|
735
|
+
(focus)="handleFocus($event)"
|
736
|
+
(focusout)="handleFocusOut($event)"
|
737
|
+
[attr.aria-labelledby]="uniqueId"
|
738
|
+
/>
|
739
|
+
<span [id]="uniqueId" *ngIf="label" [ngStyle]="labelStyle" (mousedown)="handleMousedown($event)">
|
740
|
+
{{ label }}
|
741
|
+
</span>
|
742
|
+
</div>
|
743
|
+
`, isInline: true, styles: [":host{display:flex}.wrap{position:relative}\n"], directives: [{ type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
744
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EditableInputComponent, decorators: [{
|
745
|
+
type: Component,
|
746
|
+
args: [{
|
747
|
+
selector: 'color-editable-input',
|
748
|
+
template: `
|
749
|
+
<div class="wrap" [ngStyle]="wrapStyle">
|
750
|
+
<input
|
751
|
+
[ngStyle]="inputStyle"
|
752
|
+
spellCheck="false"
|
753
|
+
[value]="currentValue"
|
754
|
+
[placeholder]="placeholder"
|
755
|
+
(keydown)="handleKeydown($event)"
|
756
|
+
(keyup)="handleKeyup($event)"
|
757
|
+
(focus)="handleFocus($event)"
|
758
|
+
(focusout)="handleFocusOut($event)"
|
759
|
+
[attr.aria-labelledby]="uniqueId"
|
760
|
+
/>
|
761
|
+
<span [id]="uniqueId" *ngIf="label" [ngStyle]="labelStyle" (mousedown)="handleMousedown($event)">
|
762
|
+
{{ label }}
|
763
|
+
</span>
|
764
|
+
</div>
|
765
|
+
`,
|
766
|
+
styles: [
|
767
|
+
`
|
768
|
+
:host {
|
769
|
+
display: flex;
|
770
|
+
}
|
771
|
+
.wrap {
|
772
|
+
position: relative;
|
773
|
+
}
|
774
|
+
`,
|
775
|
+
],
|
776
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
777
|
+
}]
|
778
|
+
}], propDecorators: { style: [{
|
779
|
+
type: Input
|
780
|
+
}], label: [{
|
781
|
+
type: Input
|
782
|
+
}], value: [{
|
783
|
+
type: Input
|
784
|
+
}], arrowOffset: [{
|
785
|
+
type: Input
|
786
|
+
}], dragLabel: [{
|
787
|
+
type: Input
|
788
|
+
}], dragMax: [{
|
789
|
+
type: Input
|
790
|
+
}], placeholder: [{
|
791
|
+
type: Input
|
792
|
+
}], onChange: [{
|
793
|
+
type: Output
|
794
|
+
}] } });
|
795
|
+
class EditableInputModule {
|
796
|
+
}
|
797
|
+
EditableInputModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EditableInputModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
798
|
+
EditableInputModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EditableInputModule, declarations: [EditableInputComponent], imports: [CommonModule], exports: [EditableInputComponent] });
|
799
|
+
EditableInputModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EditableInputModule, imports: [[CommonModule]] });
|
800
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EditableInputModule, decorators: [{
|
801
|
+
type: NgModule,
|
802
|
+
args: [{
|
803
|
+
declarations: [EditableInputComponent],
|
804
|
+
exports: [EditableInputComponent],
|
805
|
+
imports: [CommonModule],
|
806
|
+
}]
|
807
|
+
}] });
|
808
|
+
|
809
|
+
class HueComponent {
|
810
|
+
constructor() {
|
811
|
+
this.hidePointer = false;
|
812
|
+
this.direction = 'horizontal';
|
813
|
+
this.onChange = new EventEmitter();
|
814
|
+
this.left = '0px';
|
815
|
+
this.top = '';
|
816
|
+
}
|
817
|
+
ngOnChanges() {
|
818
|
+
if (this.direction === 'horizontal') {
|
819
|
+
this.left = `${this.hsl.h * 100 / 360}%`;
|
820
|
+
}
|
821
|
+
else {
|
822
|
+
this.top = `${-(this.hsl.h * 100 / 360) + 100}%`;
|
823
|
+
}
|
824
|
+
}
|
825
|
+
handleChange({ top, left, containerHeight, containerWidth, $event }) {
|
826
|
+
let data;
|
827
|
+
if (this.direction === 'vertical') {
|
828
|
+
let h;
|
829
|
+
if (top < 0) {
|
830
|
+
h = 359;
|
831
|
+
}
|
832
|
+
else if (top > containerHeight) {
|
833
|
+
h = 0;
|
834
|
+
}
|
835
|
+
else {
|
836
|
+
const percent = -(top * 100 / containerHeight) + 100;
|
837
|
+
h = 360 * percent / 100;
|
838
|
+
}
|
839
|
+
if (this.hsl.h !== h) {
|
840
|
+
data = {
|
841
|
+
h,
|
842
|
+
s: this.hsl.s,
|
843
|
+
l: this.hsl.l,
|
844
|
+
a: this.hsl.a,
|
845
|
+
source: 'rgb',
|
846
|
+
};
|
847
|
+
}
|
848
|
+
}
|
849
|
+
else {
|
850
|
+
let h;
|
851
|
+
if (left < 0) {
|
852
|
+
h = 0;
|
853
|
+
}
|
854
|
+
else if (left > containerWidth) {
|
855
|
+
h = 359;
|
856
|
+
}
|
857
|
+
else {
|
858
|
+
const percent = left * 100 / containerWidth;
|
859
|
+
h = 360 * percent / 100;
|
860
|
+
}
|
861
|
+
if (this.hsl.h !== h) {
|
862
|
+
data = {
|
863
|
+
h,
|
864
|
+
s: this.hsl.s,
|
865
|
+
l: this.hsl.l,
|
866
|
+
a: this.hsl.a,
|
867
|
+
source: 'rgb',
|
868
|
+
};
|
869
|
+
}
|
870
|
+
}
|
871
|
+
if (!data) {
|
872
|
+
return;
|
873
|
+
}
|
874
|
+
this.onChange.emit({ data, $event });
|
875
|
+
}
|
876
|
+
}
|
877
|
+
HueComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: HueComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
878
|
+
HueComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: HueComponent, selector: "color-hue", inputs: { hsl: "hsl", pointer: "pointer", radius: "radius", shadow: "shadow", hidePointer: "hidePointer", direction: "direction" }, outputs: { onChange: "onChange" }, usesOnChanges: true, ngImport: i0, template: `
|
879
|
+
<div class="color-hue color-hue-{{direction}}" [style.border-radius.px]="radius" [style.box-shadow]="shadow">
|
880
|
+
<div ngx-color-coordinates (coordinatesChange)="handleChange($event)" class="color-hue-container">
|
881
|
+
<div class="color-hue-pointer" [style.left]="left" [style.top]="top" *ngIf="!hidePointer">
|
882
|
+
<div class="color-hue-slider" [ngStyle]="pointer"></div>
|
883
|
+
</div>
|
884
|
+
</div>
|
885
|
+
</div>
|
886
|
+
`, isInline: true, styles: [".color-hue{position:absolute;top:0;bottom:0;left:0;right:0}.color-hue-container{margin:0 2px;position:relative;height:100%}.color-hue-pointer{position:absolute}.color-hue-slider{margin-top:1px;width:4px;border-radius:1px;height:8px;box-shadow:0 0 2px #0009;background:#fff;transform:translate(-2px)}.color-hue-horizontal{background:linear-gradient(to right,#f00 0%,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,#f00 100%)}.color-hue-vertical{background:linear-gradient(to top,#f00 0%,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,#f00 100%)}\n"], directives: [{ type: CoordinatesDirective, selector: "[ngx-color-coordinates]", outputs: ["coordinatesChange"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
887
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: HueComponent, decorators: [{
|
888
|
+
type: Component,
|
889
|
+
args: [{
|
890
|
+
selector: 'color-hue',
|
891
|
+
template: `
|
892
|
+
<div class="color-hue color-hue-{{direction}}" [style.border-radius.px]="radius" [style.box-shadow]="shadow">
|
893
|
+
<div ngx-color-coordinates (coordinatesChange)="handleChange($event)" class="color-hue-container">
|
894
|
+
<div class="color-hue-pointer" [style.left]="left" [style.top]="top" *ngIf="!hidePointer">
|
895
|
+
<div class="color-hue-slider" [ngStyle]="pointer"></div>
|
896
|
+
</div>
|
897
|
+
</div>
|
898
|
+
</div>
|
899
|
+
`,
|
900
|
+
styles: [
|
901
|
+
`
|
902
|
+
.color-hue {
|
903
|
+
position: absolute;
|
904
|
+
top: 0;
|
905
|
+
bottom: 0;
|
906
|
+
left: 0;
|
907
|
+
right: 0;
|
908
|
+
}
|
909
|
+
.color-hue-container {
|
910
|
+
margin: 0 2px;
|
911
|
+
position: relative;
|
912
|
+
height: 100%;
|
913
|
+
}
|
914
|
+
.color-hue-pointer {
|
915
|
+
position: absolute;
|
916
|
+
}
|
917
|
+
.color-hue-slider {
|
918
|
+
margin-top: 1px;
|
919
|
+
width: 4px;
|
920
|
+
border-radius: 1px;
|
921
|
+
height: 8px;
|
922
|
+
box-shadow: 0 0 2px rgba(0, 0, 0, .6);
|
923
|
+
background: #fff;
|
924
|
+
transform: translateX(-2px);
|
925
|
+
}
|
926
|
+
.color-hue-horizontal {
|
927
|
+
background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0
|
928
|
+
33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
|
929
|
+
}
|
930
|
+
.color-hue-vertical {
|
931
|
+
background: linear-gradient(to top, #f00 0%, #ff0 17%, #0f0 33%,
|
932
|
+
#0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
|
933
|
+
}
|
934
|
+
`,
|
935
|
+
],
|
936
|
+
preserveWhitespaces: false,
|
937
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
938
|
+
}]
|
939
|
+
}], propDecorators: { hsl: [{
|
940
|
+
type: Input
|
941
|
+
}], pointer: [{
|
942
|
+
type: Input
|
943
|
+
}], radius: [{
|
944
|
+
type: Input
|
945
|
+
}], shadow: [{
|
946
|
+
type: Input
|
947
|
+
}], hidePointer: [{
|
948
|
+
type: Input
|
949
|
+
}], direction: [{
|
950
|
+
type: Input
|
951
|
+
}], onChange: [{
|
952
|
+
type: Output
|
953
|
+
}] } });
|
954
|
+
class HueModule {
|
955
|
+
}
|
956
|
+
HueModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: HueModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
957
|
+
HueModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: HueModule, declarations: [HueComponent], imports: [CommonModule, CoordinatesModule], exports: [HueComponent] });
|
958
|
+
HueModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: HueModule, imports: [[CommonModule, CoordinatesModule]] });
|
959
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: HueModule, decorators: [{
|
960
|
+
type: NgModule,
|
961
|
+
args: [{
|
962
|
+
declarations: [HueComponent],
|
963
|
+
exports: [HueComponent],
|
964
|
+
imports: [CommonModule, CoordinatesModule],
|
965
|
+
}]
|
966
|
+
}] });
|
967
|
+
|
968
|
+
class RaisedComponent {
|
969
|
+
constructor() {
|
970
|
+
this.zDepth = 1;
|
971
|
+
this.radius = 1;
|
972
|
+
this.background = '#fff';
|
973
|
+
}
|
974
|
+
}
|
975
|
+
RaisedComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RaisedComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
976
|
+
RaisedComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: RaisedComponent, selector: "color-raised", inputs: { zDepth: "zDepth", radius: "radius", background: "background" }, ngImport: i0, template: `
|
977
|
+
<div class="raised-wrap">
|
978
|
+
<div class="raised-bg zDepth-{{zDepth}}" [style.background]="background"></div>
|
979
|
+
<div class="raised-content">
|
980
|
+
<ng-content></ng-content>
|
981
|
+
</div>
|
982
|
+
</div>
|
983
|
+
`, isInline: true, styles: [".raised-wrap{position:relative;display:inline-block}.raised-bg{position:absolute;top:0px;right:0px;bottom:0px;left:0px}.raised-content{position:relative}.zDepth-0{box-shadow:none}.zDepth-1{box-shadow:0 2px 10px #0000001f,0 2px 5px #00000029}.zDepth-2{box-shadow:0 6px 20px #00000030,0 8px 17px #0003}.zDepth-3{box-shadow:0 17px 50px #00000030,0 12px 15px #0000003d}.zDepth-4{box-shadow:0 25px 55px #00000036,0 16px 28px #00000038}.zDepth-5{box-shadow:0 40px 77px #00000038,0 27px 24px #0003}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
984
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RaisedComponent, decorators: [{
|
985
|
+
type: Component,
|
986
|
+
args: [{
|
987
|
+
selector: 'color-raised',
|
988
|
+
template: `
|
989
|
+
<div class="raised-wrap">
|
990
|
+
<div class="raised-bg zDepth-{{zDepth}}" [style.background]="background"></div>
|
991
|
+
<div class="raised-content">
|
992
|
+
<ng-content></ng-content>
|
993
|
+
</div>
|
994
|
+
</div>
|
995
|
+
`,
|
996
|
+
styles: [`
|
997
|
+
.raised-wrap {
|
998
|
+
position: relative;
|
999
|
+
display: inline-block;
|
1000
|
+
}
|
1001
|
+
.raised-bg {
|
1002
|
+
position: absolute;
|
1003
|
+
top: 0px;
|
1004
|
+
right: 0px;
|
1005
|
+
bottom: 0px;
|
1006
|
+
left: 0px;
|
1007
|
+
}
|
1008
|
+
.raised-content {
|
1009
|
+
position: relative;
|
1010
|
+
}
|
1011
|
+
.zDepth-0 {
|
1012
|
+
box-shadow: none;
|
1013
|
+
}
|
1014
|
+
.zDepth-1 {
|
1015
|
+
box-shadow: 0 2px 10px rgba(0,0,0,.12), 0 2px 5px rgba(0,0,0,.16);
|
1016
|
+
}
|
1017
|
+
.zDepth-2 {
|
1018
|
+
box-shadow: 0 6px 20px rgba(0,0,0,.19), 0 8px 17px rgba(0,0,0,.2);
|
1019
|
+
}
|
1020
|
+
.zDepth-3 {
|
1021
|
+
box-shadow: 0 17px 50px rgba(0,0,0,.19), 0 12px 15px rgba(0,0,0,.24);
|
1022
|
+
}
|
1023
|
+
.zDepth-4 {
|
1024
|
+
box-shadow: 0 25px 55px rgba(0,0,0,.21), 0 16px 28px rgba(0,0,0,.22);
|
1025
|
+
}
|
1026
|
+
.zDepth-5 {
|
1027
|
+
box-shadow: 0 40px 77px rgba(0,0,0,.22), 0 27px 24px rgba(0,0,0,.2);
|
1028
|
+
}
|
1029
|
+
`],
|
1030
|
+
preserveWhitespaces: false,
|
1031
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
1032
|
+
}]
|
1033
|
+
}], propDecorators: { zDepth: [{
|
1034
|
+
type: Input
|
1035
|
+
}], radius: [{
|
1036
|
+
type: Input
|
1037
|
+
}], background: [{
|
1038
|
+
type: Input
|
1039
|
+
}] } });
|
1040
|
+
class RaisedModule {
|
1041
|
+
}
|
1042
|
+
RaisedModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RaisedModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1043
|
+
RaisedModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RaisedModule, declarations: [RaisedComponent], imports: [CommonModule], exports: [RaisedComponent] });
|
1044
|
+
RaisedModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RaisedModule, imports: [[CommonModule]] });
|
1045
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RaisedModule, decorators: [{
|
1046
|
+
type: NgModule,
|
1047
|
+
args: [{
|
1048
|
+
declarations: [RaisedComponent],
|
1049
|
+
exports: [RaisedComponent],
|
1050
|
+
imports: [CommonModule],
|
1051
|
+
}]
|
1052
|
+
}] });
|
1053
|
+
|
1054
|
+
class SaturationComponent {
|
1055
|
+
constructor() {
|
1056
|
+
this.onChange = new EventEmitter();
|
1057
|
+
}
|
1058
|
+
ngOnChanges() {
|
1059
|
+
this.background = `hsl(${this.hsl.h}, 100%, 50%)`;
|
1060
|
+
this.pointerTop = -(this.hsv.v * 100) + 1 + 100 + '%';
|
1061
|
+
this.pointerLeft = this.hsv.s * 100 + '%';
|
1062
|
+
}
|
1063
|
+
handleChange({ top, left, containerHeight, containerWidth, $event }) {
|
1064
|
+
if (left < 0) {
|
1065
|
+
left = 0;
|
1066
|
+
}
|
1067
|
+
else if (left > containerWidth) {
|
1068
|
+
left = containerWidth;
|
1069
|
+
}
|
1070
|
+
else if (top < 0) {
|
1071
|
+
top = 0;
|
1072
|
+
}
|
1073
|
+
else if (top > containerHeight) {
|
1074
|
+
top = containerHeight;
|
1075
|
+
}
|
1076
|
+
const saturation = left / containerWidth;
|
1077
|
+
let bright = -(top / containerHeight) + 1;
|
1078
|
+
bright = bright > 0 ? bright : 0;
|
1079
|
+
bright = bright > 1 ? 1 : bright;
|
1080
|
+
const data = {
|
1081
|
+
h: this.hsl.h,
|
1082
|
+
s: saturation,
|
1083
|
+
v: bright,
|
1084
|
+
a: this.hsl.a,
|
1085
|
+
source: 'hsva',
|
1086
|
+
};
|
1087
|
+
this.onChange.emit({ data, $event });
|
1088
|
+
}
|
1089
|
+
}
|
1090
|
+
SaturationComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SaturationComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
1091
|
+
SaturationComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: SaturationComponent, selector: "color-saturation", inputs: { hsl: "hsl", hsv: "hsv", radius: "radius", pointer: "pointer", circle: "circle" }, outputs: { onChange: "onChange" }, usesOnChanges: true, ngImport: i0, template: `
|
1092
|
+
<div class="color-saturation" ngx-color-coordinates (coordinatesChange)="handleChange($event)" [style.background]="background">
|
1093
|
+
<div class="saturation-white">
|
1094
|
+
<div class="saturation-black"></div>
|
1095
|
+
<div class="saturation-pointer" [ngStyle]="pointer" [style.top]="pointerTop" [style.left]="pointerLeft">
|
1096
|
+
<div class="saturation-circle" [ngStyle]="circle"></div>
|
1097
|
+
</div>
|
1098
|
+
</div>
|
1099
|
+
</div>
|
1100
|
+
`, isInline: true, styles: [".saturation-white{background:linear-gradient(to right,#fff,rgba(255,255,255,0));position:absolute;top:0;bottom:0;left:0;right:0}.saturation-black{background:linear-gradient(to top,#000,rgba(0,0,0,0));position:absolute;top:0;bottom:0;left:0;right:0}.color-saturation{position:absolute;top:0;bottom:0;left:0;right:0}.saturation-pointer{position:absolute;cursor:default}.saturation-circle{width:4px;height:4px;box-shadow:0 0 0 1.5px #fff,inset 0 0 1px 1px #0000004d,0 0 1px 2px #0006;border-radius:50%;cursor:hand;transform:translate(-2px,-4px)}\n"], directives: [{ type: CoordinatesDirective, selector: "[ngx-color-coordinates]", outputs: ["coordinatesChange"] }, { type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
1101
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SaturationComponent, decorators: [{
|
1102
|
+
type: Component,
|
1103
|
+
args: [{
|
1104
|
+
selector: 'color-saturation',
|
1105
|
+
template: `
|
1106
|
+
<div class="color-saturation" ngx-color-coordinates (coordinatesChange)="handleChange($event)" [style.background]="background">
|
1107
|
+
<div class="saturation-white">
|
1108
|
+
<div class="saturation-black"></div>
|
1109
|
+
<div class="saturation-pointer" [ngStyle]="pointer" [style.top]="pointerTop" [style.left]="pointerLeft">
|
1110
|
+
<div class="saturation-circle" [ngStyle]="circle"></div>
|
1111
|
+
</div>
|
1112
|
+
</div>
|
1113
|
+
</div>
|
1114
|
+
`,
|
1115
|
+
styles: [
|
1116
|
+
`
|
1117
|
+
.saturation-white {
|
1118
|
+
background: linear-gradient(to right, #fff, rgba(255,255,255,0));
|
1119
|
+
position: absolute;
|
1120
|
+
top: 0;
|
1121
|
+
bottom: 0;
|
1122
|
+
left: 0;
|
1123
|
+
right: 0;
|
1124
|
+
}
|
1125
|
+
.saturation-black {
|
1126
|
+
background: linear-gradient(to top, #000, rgba(0,0,0,0));
|
1127
|
+
position: absolute;
|
1128
|
+
top: 0;
|
1129
|
+
bottom: 0;
|
1130
|
+
left: 0;
|
1131
|
+
right: 0;
|
1132
|
+
}
|
1133
|
+
.color-saturation {
|
1134
|
+
position: absolute;
|
1135
|
+
top: 0;
|
1136
|
+
bottom: 0;
|
1137
|
+
left: 0;
|
1138
|
+
right: 0;
|
1139
|
+
}
|
1140
|
+
.saturation-pointer {
|
1141
|
+
position: absolute;
|
1142
|
+
cursor: default;
|
1143
|
+
}
|
1144
|
+
.saturation-circle {
|
1145
|
+
width: 4px;
|
1146
|
+
height: 4px;
|
1147
|
+
box-shadow: 0 0 0 1.5px #fff, inset 0 0 1px 1px rgba(0,0,0,.3), 0 0 1px 2px rgba(0,0,0,.4);
|
1148
|
+
border-radius: 50%;
|
1149
|
+
cursor: hand;
|
1150
|
+
transform: translate(-2px, -4px);
|
1151
|
+
}
|
1152
|
+
`,
|
1153
|
+
],
|
1154
|
+
preserveWhitespaces: false,
|
1155
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
1156
|
+
}]
|
1157
|
+
}], propDecorators: { hsl: [{
|
1158
|
+
type: Input
|
1159
|
+
}], hsv: [{
|
1160
|
+
type: Input
|
1161
|
+
}], radius: [{
|
1162
|
+
type: Input
|
1163
|
+
}], pointer: [{
|
1164
|
+
type: Input
|
1165
|
+
}], circle: [{
|
1166
|
+
type: Input
|
1167
|
+
}], onChange: [{
|
1168
|
+
type: Output
|
1169
|
+
}] } });
|
1170
|
+
class SaturationModule {
|
1171
|
+
}
|
1172
|
+
SaturationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SaturationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1173
|
+
SaturationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SaturationModule, declarations: [SaturationComponent], imports: [CommonModule, CoordinatesModule], exports: [SaturationComponent] });
|
1174
|
+
SaturationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SaturationModule, imports: [[CommonModule, CoordinatesModule]] });
|
1175
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SaturationModule, decorators: [{
|
1176
|
+
type: NgModule,
|
1177
|
+
args: [{
|
1178
|
+
declarations: [SaturationComponent],
|
1179
|
+
exports: [SaturationComponent],
|
1180
|
+
imports: [CommonModule, CoordinatesModule],
|
1181
|
+
}]
|
1182
|
+
}] });
|
1183
|
+
|
1184
|
+
class SwatchComponent {
|
1185
|
+
constructor() {
|
1186
|
+
this.style = {};
|
1187
|
+
this.focusStyle = {};
|
1188
|
+
this.onClick = new EventEmitter();
|
1189
|
+
this.onHover = new EventEmitter();
|
1190
|
+
this.divStyles = {};
|
1191
|
+
this.focusStyles = {};
|
1192
|
+
this.inFocus = false;
|
1193
|
+
}
|
1194
|
+
ngOnInit() {
|
1195
|
+
this.divStyles = {
|
1196
|
+
background: this.color,
|
1197
|
+
...this.style,
|
1198
|
+
};
|
1199
|
+
}
|
1200
|
+
currentStyles() {
|
1201
|
+
this.focusStyles = {
|
1202
|
+
...this.divStyles,
|
1203
|
+
...this.focusStyle,
|
1204
|
+
};
|
1205
|
+
return this.focus || this.inFocus ? this.focusStyles : this.divStyles;
|
1206
|
+
}
|
1207
|
+
handleFocusOut() {
|
1208
|
+
this.inFocus = false;
|
1209
|
+
}
|
1210
|
+
handleFocus() {
|
1211
|
+
this.inFocus = true;
|
1212
|
+
}
|
1213
|
+
handleHover(hex, $event) {
|
1214
|
+
this.onHover.emit({ hex, $event });
|
1215
|
+
}
|
1216
|
+
handleClick(hex, $event) {
|
1217
|
+
this.onClick.emit({ hex, $event });
|
1218
|
+
}
|
1219
|
+
}
|
1220
|
+
SwatchComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SwatchComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
1221
|
+
SwatchComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: SwatchComponent, selector: "color-swatch", inputs: { color: "color", style: "style", focusStyle: "focusStyle", focus: "focus" }, outputs: { onClick: "onClick", onHover: "onHover" }, ngImport: i0, template: `
|
1222
|
+
<div
|
1223
|
+
class="swatch"
|
1224
|
+
[ngStyle]="currentStyles()"
|
1225
|
+
[attr.title]="color"
|
1226
|
+
(click)="handleClick(color, $event)"
|
1227
|
+
(keydown.enter)="handleClick(color, $event)"
|
1228
|
+
(focus)="handleFocus()"
|
1229
|
+
(blur)="handleFocusOut()"
|
1230
|
+
(mouseover)="handleHover(color, $event)"
|
1231
|
+
tabindex="0"
|
1232
|
+
>
|
1233
|
+
<ng-content></ng-content>
|
1234
|
+
<color-checkboard
|
1235
|
+
*ngIf="color === 'transparent'"
|
1236
|
+
boxShadow="inset 0 0 0 1px rgba(0,0,0,0.1)"
|
1237
|
+
></color-checkboard>
|
1238
|
+
</div>
|
1239
|
+
`, isInline: true, styles: [".swatch{outline:none;height:100%;width:100%;cursor:pointer;position:relative}\n"], components: [{ type: CheckboardComponent, selector: "color-checkboard", inputs: ["white", "size", "grey", "boxShadow", "borderRadius"] }], directives: [{ type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
1240
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SwatchComponent, decorators: [{
|
1241
|
+
type: Component,
|
1242
|
+
args: [{
|
1243
|
+
selector: 'color-swatch',
|
1244
|
+
template: `
|
1245
|
+
<div
|
1246
|
+
class="swatch"
|
1247
|
+
[ngStyle]="currentStyles()"
|
1248
|
+
[attr.title]="color"
|
1249
|
+
(click)="handleClick(color, $event)"
|
1250
|
+
(keydown.enter)="handleClick(color, $event)"
|
1251
|
+
(focus)="handleFocus()"
|
1252
|
+
(blur)="handleFocusOut()"
|
1253
|
+
(mouseover)="handleHover(color, $event)"
|
1254
|
+
tabindex="0"
|
1255
|
+
>
|
1256
|
+
<ng-content></ng-content>
|
1257
|
+
<color-checkboard
|
1258
|
+
*ngIf="color === 'transparent'"
|
1259
|
+
boxShadow="inset 0 0 0 1px rgba(0,0,0,0.1)"
|
1260
|
+
></color-checkboard>
|
1261
|
+
</div>
|
1262
|
+
`,
|
1263
|
+
styles: [
|
1264
|
+
`
|
1265
|
+
.swatch {
|
1266
|
+
outline: none;
|
1267
|
+
height: 100%;
|
1268
|
+
width: 100%;
|
1269
|
+
cursor: pointer;
|
1270
|
+
position: relative;
|
1271
|
+
}
|
1272
|
+
`,
|
1273
|
+
],
|
1274
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
1275
|
+
}]
|
1276
|
+
}], propDecorators: { color: [{
|
1277
|
+
type: Input
|
1278
|
+
}], style: [{
|
1279
|
+
type: Input
|
1280
|
+
}], focusStyle: [{
|
1281
|
+
type: Input
|
1282
|
+
}], focus: [{
|
1283
|
+
type: Input
|
1284
|
+
}], onClick: [{
|
1285
|
+
type: Output
|
1286
|
+
}], onHover: [{
|
1287
|
+
type: Output
|
1288
|
+
}] } });
|
1289
|
+
class SwatchModule {
|
1290
|
+
}
|
1291
|
+
SwatchModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SwatchModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1292
|
+
SwatchModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SwatchModule, declarations: [SwatchComponent], imports: [CommonModule, CheckboardModule], exports: [SwatchComponent] });
|
1293
|
+
SwatchModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SwatchModule, imports: [[CommonModule, CheckboardModule]] });
|
1294
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SwatchModule, decorators: [{
|
1295
|
+
type: NgModule,
|
1296
|
+
args: [{
|
1297
|
+
declarations: [SwatchComponent],
|
1298
|
+
exports: [SwatchComponent],
|
1299
|
+
imports: [CommonModule, CheckboardModule],
|
1300
|
+
}]
|
1301
|
+
}] });
|
1302
|
+
|
1303
|
+
class ShadeComponent {
|
1304
|
+
constructor() {
|
1305
|
+
this.onChange = new EventEmitter();
|
1306
|
+
}
|
1307
|
+
ngOnChanges() {
|
1308
|
+
this.gradient = {
|
1309
|
+
background: `linear-gradient(to right,
|
1310
|
+
hsl(${this.hsl.h}, 90%, 55%),
|
1311
|
+
#000)`,
|
1312
|
+
};
|
1313
|
+
const hsv = new TinyColor(this.hsl).toHsv();
|
1314
|
+
this.pointerLeft = 100 - (hsv.v * 100);
|
1315
|
+
}
|
1316
|
+
handleChange({ left, containerWidth, $event }) {
|
1317
|
+
let data;
|
1318
|
+
let v;
|
1319
|
+
if (left < 0) {
|
1320
|
+
v = 0;
|
1321
|
+
}
|
1322
|
+
else if (left > containerWidth) {
|
1323
|
+
v = 1;
|
1324
|
+
}
|
1325
|
+
else {
|
1326
|
+
v = Math.round((left * 100) / containerWidth) / 100;
|
1327
|
+
}
|
1328
|
+
const hsv = new TinyColor(this.hsl).toHsv();
|
1329
|
+
if (hsv.v !== v) {
|
1330
|
+
data = {
|
1331
|
+
h: this.hsl.h,
|
1332
|
+
s: 100,
|
1333
|
+
v: 1 - v,
|
1334
|
+
l: this.hsl.l,
|
1335
|
+
a: this.hsl.a,
|
1336
|
+
source: 'rgb',
|
1337
|
+
};
|
1338
|
+
}
|
1339
|
+
if (!data) {
|
1340
|
+
return;
|
1341
|
+
}
|
1342
|
+
this.onChange.emit({ data, $event });
|
1343
|
+
}
|
1344
|
+
}
|
1345
|
+
ShadeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ShadeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
1346
|
+
ShadeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: ShadeComponent, selector: "color-shade", inputs: { hsl: "hsl", rgb: "rgb", pointer: "pointer", shadow: "shadow", radius: "radius" }, outputs: { onChange: "onChange" }, usesOnChanges: true, ngImport: i0, template: `
|
1347
|
+
<div class="shade" [style.border-radius]="radius">
|
1348
|
+
<div
|
1349
|
+
class="shade-gradient"
|
1350
|
+
[ngStyle]="gradient"
|
1351
|
+
[style.box-shadow]="shadow"
|
1352
|
+
[style.border-radius]="radius"
|
1353
|
+
></div>
|
1354
|
+
<div
|
1355
|
+
ngx-color-coordinates
|
1356
|
+
(coordinatesChange)="handleChange($event)"
|
1357
|
+
class="shade-container"
|
1358
|
+
>
|
1359
|
+
<div
|
1360
|
+
class="shade-pointer"
|
1361
|
+
[style.left.%]="pointerLeft"
|
1362
|
+
[style.top.%]="pointerTop"
|
1363
|
+
>
|
1364
|
+
<div class="shade-slider" [ngStyle]="pointer"></div>
|
1365
|
+
</div>
|
1366
|
+
</div>
|
1367
|
+
</div>
|
1368
|
+
`, isInline: true, styles: [".shade{position:absolute;top:0;bottom:0;left:0;right:0}.shade-gradient{position:absolute;top:0;bottom:0;left:0;right:0}.shade-container{position:relative;height:100%;margin:0 3px}.shade-pointer{position:absolute}.shade-slider{width:4px;border-radius:1px;height:8px;box-shadow:0 0 2px #0009;background:#fff;margin-top:1px;transform:translate(-2px)}\n"], directives: [{ type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: CoordinatesDirective, selector: "[ngx-color-coordinates]", outputs: ["coordinatesChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
1369
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ShadeComponent, decorators: [{
|
1370
|
+
type: Component,
|
1371
|
+
args: [{
|
1372
|
+
selector: 'color-shade',
|
1373
|
+
template: `
|
1374
|
+
<div class="shade" [style.border-radius]="radius">
|
1375
|
+
<div
|
1376
|
+
class="shade-gradient"
|
1377
|
+
[ngStyle]="gradient"
|
1378
|
+
[style.box-shadow]="shadow"
|
1379
|
+
[style.border-radius]="radius"
|
1380
|
+
></div>
|
1381
|
+
<div
|
1382
|
+
ngx-color-coordinates
|
1383
|
+
(coordinatesChange)="handleChange($event)"
|
1384
|
+
class="shade-container"
|
1385
|
+
>
|
1386
|
+
<div
|
1387
|
+
class="shade-pointer"
|
1388
|
+
[style.left.%]="pointerLeft"
|
1389
|
+
[style.top.%]="pointerTop"
|
1390
|
+
>
|
1391
|
+
<div class="shade-slider" [ngStyle]="pointer"></div>
|
1392
|
+
</div>
|
1393
|
+
</div>
|
1394
|
+
</div>
|
1395
|
+
`,
|
1396
|
+
styles: [
|
1397
|
+
`
|
1398
|
+
.shade {
|
1399
|
+
position: absolute;
|
1400
|
+
top: 0;
|
1401
|
+
bottom: 0;
|
1402
|
+
left: 0;
|
1403
|
+
right: 0;
|
1404
|
+
}
|
1405
|
+
.shade-gradient {
|
1406
|
+
position: absolute;
|
1407
|
+
top: 0;
|
1408
|
+
bottom: 0;
|
1409
|
+
left: 0;
|
1410
|
+
right: 0;
|
1411
|
+
}
|
1412
|
+
.shade-container {
|
1413
|
+
position: relative;
|
1414
|
+
height: 100%;
|
1415
|
+
margin: 0 3px;
|
1416
|
+
}
|
1417
|
+
.shade-pointer {
|
1418
|
+
position: absolute;
|
1419
|
+
}
|
1420
|
+
.shade-slider {
|
1421
|
+
width: 4px;
|
1422
|
+
border-radius: 1px;
|
1423
|
+
height: 8px;
|
1424
|
+
box-shadow: 0 0 2px rgba(0, 0, 0, .6);
|
1425
|
+
background: #fff;
|
1426
|
+
margin-top: 1px;
|
1427
|
+
transform: translateX(-2px);
|
1428
|
+
}
|
1429
|
+
`,
|
1430
|
+
],
|
1431
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
1432
|
+
preserveWhitespaces: false,
|
1433
|
+
}]
|
1434
|
+
}], propDecorators: { hsl: [{
|
1435
|
+
type: Input
|
1436
|
+
}], rgb: [{
|
1437
|
+
type: Input
|
1438
|
+
}], pointer: [{
|
1439
|
+
type: Input
|
1440
|
+
}], shadow: [{
|
1441
|
+
type: Input
|
1442
|
+
}], radius: [{
|
1443
|
+
type: Input
|
1444
|
+
}], onChange: [{
|
1445
|
+
type: Output
|
1446
|
+
}] } });
|
1447
|
+
class ShadeModule {
|
1448
|
+
}
|
1449
|
+
ShadeModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ShadeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1450
|
+
ShadeModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ShadeModule, declarations: [ShadeComponent], imports: [CommonModule, CoordinatesModule], exports: [ShadeComponent] });
|
1451
|
+
ShadeModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ShadeModule, imports: [[CommonModule, CoordinatesModule]] });
|
1452
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ShadeModule, decorators: [{
|
1453
|
+
type: NgModule,
|
1454
|
+
args: [{
|
1455
|
+
declarations: [ShadeComponent],
|
1456
|
+
exports: [ShadeComponent],
|
1457
|
+
imports: [CommonModule, CoordinatesModule],
|
1458
|
+
}]
|
1459
|
+
}] });
|
1460
|
+
|
1461
|
+
/**
|
1462
|
+
* Generated bundle index. Do not edit.
|
1463
|
+
*/
|
1464
|
+
|
1465
|
+
export { AlphaComponent, AlphaModule, CheckboardComponent, CheckboardModule, ColorMode, ColorWrap, ColorWrapModule, CoordinatesDirective, CoordinatesModule, EditableInputComponent, EditableInputModule, HueComponent, HueModule, RaisedComponent, RaisedModule, SaturationComponent, SaturationModule, ShadeComponent, ShadeModule, SwatchComponent, SwatchModule, getCheckerboard, getContrastingColor, isValidHex, render, simpleCheckForValidColor, toState };
|
1466
|
+
//# sourceMappingURL=ngx-color.mjs.map
|