@thednp/color-picker 0.0.1-alpha1 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +63 -26
  3. package/dist/css/color-picker.css +504 -337
  4. package/dist/css/color-picker.min.css +2 -0
  5. package/dist/css/color-picker.rtl.css +529 -0
  6. package/dist/css/color-picker.rtl.min.css +2 -0
  7. package/dist/js/color-picker-element-esm.js +3851 -2
  8. package/dist/js/color-picker-element-esm.min.js +2 -0
  9. package/dist/js/color-picker-element.js +2086 -1278
  10. package/dist/js/color-picker-element.min.js +2 -2
  11. package/dist/js/color-picker-esm.js +3742 -0
  12. package/dist/js/color-picker-esm.min.js +2 -0
  13. package/dist/js/color-picker.js +2030 -1286
  14. package/dist/js/color-picker.min.js +2 -2
  15. package/package.json +18 -9
  16. package/src/js/color-palette.js +71 -0
  17. package/src/js/color-picker-element.js +62 -16
  18. package/src/js/color-picker.js +734 -618
  19. package/src/js/color.js +621 -358
  20. package/src/js/index.js +0 -9
  21. package/src/js/util/colorNames.js +2 -152
  22. package/src/js/util/colorPickerLabels.js +22 -0
  23. package/src/js/util/getColorControls.js +103 -0
  24. package/src/js/util/getColorForm.js +26 -19
  25. package/src/js/util/getColorMenu.js +88 -0
  26. package/src/js/util/isValidJSON.js +13 -0
  27. package/src/js/util/nonColors.js +5 -0
  28. package/src/js/util/roundPart.js +9 -0
  29. package/src/js/util/setCSSProperties.js +12 -0
  30. package/src/js/util/tabindex.js +3 -0
  31. package/src/js/util/templates.js +1 -0
  32. package/src/scss/color-picker.rtl.scss +23 -0
  33. package/src/scss/color-picker.scss +449 -0
  34. package/types/cp.d.ts +263 -162
  35. package/types/index.d.ts +9 -2
  36. package/types/source/source.ts +2 -1
  37. package/types/source/types.d.ts +28 -5
  38. package/dist/js/color-picker.esm.js +0 -2998
  39. package/dist/js/color-picker.esm.min.js +0 -2
  40. package/src/js/util/getColorControl.js +0 -49
  41. package/src/js/util/init.js +0 -14
package/types/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export as namespace CP;
2
- export {Color, ColorPicker, ColorPickerElement};
2
+ export {Color, ColorPicker, ColorPalette, ColorPickerElement};
3
3
 
4
4
  export {
5
5
  HSL,
@@ -8,16 +8,19 @@ export {
8
8
  RGBA,
9
9
  HSV,
10
10
  HSVA,
11
+ HWB,
12
+ HWBA,
13
+ ColorPickerOptions,
11
14
  ColorObject,
12
15
  ColorFormats,
13
16
  ColorInput,
14
- ColorOptions,
15
17
  GetInstance,
16
18
  InitCallback,
17
19
  } from './source/types';
18
20
 
19
21
  import './cp';
20
22
  import { default as Color } from "color-picker/src/js/color";
23
+ import { default as ColorPalette } from "color-picker/src/js/color-palette";
21
24
  import { default as ColorPicker } from "color-picker/src/js/color-picker";
22
25
  import { default as ColorPickerElement } from "color-picker/src/js/color-picker-element";
23
26
 
@@ -29,6 +32,10 @@ declare module "@thednp/color-picker/src/js/color" {
29
32
  export default Color;
30
33
  }
31
34
 
35
+ declare module "@thednp/color-picker/src/js/color-palette" {
36
+ export default ColorPalette;
37
+ }
38
+
32
39
  declare module "@thednp/color-picker/src/js/color-picker" {
33
40
  export default ColorPicker;
34
41
  }
@@ -1,4 +1,5 @@
1
1
  // export { default as Color } from "../../types/source/types";
2
2
  export { default as Color } from "../../src/js/color";
3
+ export { default as ColorPalette } from "../../src/js/color-palette";
3
4
  export { default as ColorPicker } from "../../src/js/color-picker";
4
- export { default as ColorPickerElement } from "../../src/js/color-picker-element";
5
+ export { default as ColorPickerElement } from "../../src/js/color-picker-element";
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * A `Color` compatible object.
3
3
  */
4
- export interface ColorObject {
4
+ export interface ColorObject {
5
5
  r: number;
6
6
  g: number;
7
7
  b: number;
@@ -59,9 +59,32 @@ export interface HSVA extends HSV {
59
59
  a: number;
60
60
  }
61
61
 
62
- export interface ColorOptions { format: ColorFormats; }
63
- export type ColorInput = string | number | RGB | RGBA | HSL | HSLA | HSV | HSVA | ColorObject;
64
- export type ColorFormats = string | 'rgb' | 'hex' | 'hex3' | 'hex6' | 'hsl' | 'hsv';
62
+ /**
63
+ * The HWB model describes colors in terms of
64
+ * hue, whiteness, and blackness.
65
+ * @link https://www.w3.org/TR/css-color-4/#hwb-to-rgb
66
+ * @link http://alvyray.com/Papers/CG/hwb2rgb.htm
67
+ */
68
+ export interface HWB {
69
+ h: number;
70
+ w: number;
71
+ b: number;
72
+ }
73
+
74
+ export interface HWBA extends HWB {
75
+ a: number;
76
+ }
77
+
78
+ export interface ColorPickerOptions {
79
+ colorLabels?: string[];
80
+ componentLabels?: Record<string, string>;
81
+ format?: ColorFormats;
82
+ colorPresets?: string[];
83
+ colorKeywords?: string[];
84
+ }
85
+
86
+ export type ColorInput = string | number | RGB | RGBA | HSL | HSLA | HSV | HSVA | HWB | ColorObject;
87
+ export type ColorFormats = string | 'rgb' | 'hex' | 'hex3' | 'hex4' | 'hex6' | 'hex8' | 'hsl' | 'hsv' | 'hwb';
65
88
 
66
89
  export type GetInstance<T> = (element: string | HTMLInputElement) => T | null;
67
- export type InitCallback<T> = (element: string | HTMLInputElement, config?: ColorOptions) => T;
90
+ export type InitCallback<T> = (element: string | HTMLInputElement) => T;