@thednp/color-picker 1.0.0 → 2.0.0-alpha1

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.
Files changed (88) hide show
  1. package/.eslintrc.cjs +199 -0
  2. package/.lgtm.yml +9 -0
  3. package/.prettierrc.json +15 -0
  4. package/.stylelintrc.json +236 -0
  5. package/LICENSE +0 -0
  6. package/README.md +63 -80
  7. package/compile.js +48 -0
  8. package/cypress/downloads/downloads.htm +0 -0
  9. package/cypress/e2e/color-palette.cy.ts +128 -0
  10. package/cypress/e2e/color-picker.cy.ts +920 -0
  11. package/cypress/fixtures/colorNamesFrench.js +3 -0
  12. package/cypress/fixtures/componentLabelsFrench.js +21 -0
  13. package/cypress/fixtures/format.js +3 -0
  14. package/cypress/fixtures/getCEMarkup.js +29 -0
  15. package/cypress/fixtures/getMarkup.js +28 -0
  16. package/cypress/fixtures/getRandomInt.js +6 -0
  17. package/cypress/fixtures/sampleWebcolors.js +18 -0
  18. package/cypress/fixtures/testSample.js +8 -0
  19. package/cypress/plugins/esbuild-istanbul.ts +50 -0
  20. package/cypress/plugins/tsCompile.ts +34 -0
  21. package/cypress/support/commands.ts +0 -0
  22. package/cypress/support/e2e.ts +21 -0
  23. package/cypress/test.html +23 -0
  24. package/cypress.config.ts +29 -0
  25. package/dist/css/color-picker.css +15 -39
  26. package/dist/css/color-picker.min.css +2 -2
  27. package/dist/css/color-picker.rtl.css +15 -39
  28. package/dist/css/color-picker.rtl.min.css +2 -2
  29. package/dist/js/color-picker.cjs +8 -0
  30. package/dist/js/color-picker.cjs.map +1 -0
  31. package/dist/js/color-picker.d.ts +278 -0
  32. package/dist/js/color-picker.js +5 -3583
  33. package/dist/js/color-picker.js.map +1 -0
  34. package/dist/js/color-picker.mjs +2631 -0
  35. package/dist/js/color-picker.mjs.map +1 -0
  36. package/dts.config.ts +15 -0
  37. package/package.json +64 -74
  38. package/src/scss/_variables.scss +0 -1
  39. package/src/scss/color-picker.rtl.scss +4 -0
  40. package/src/scss/color-picker.scss +75 -39
  41. package/src/ts/colorPalette.ts +89 -0
  42. package/src/{js/color-picker.js → ts/index.ts} +492 -502
  43. package/src/ts/interface/colorPickerLabels.ts +20 -0
  44. package/src/ts/interface/colorPickerOptions.ts +11 -0
  45. package/src/ts/interface/paletteOptions.ts +6 -0
  46. package/src/ts/util/colorNames.ts +21 -0
  47. package/src/{js/util/colorPickerLabels.js → ts/util/colorPickerLabels.ts} +4 -2
  48. package/src/ts/util/getColorControls.ts +90 -0
  49. package/src/{js/util/getColorForm.js → ts/util/getColorForm.ts} +28 -18
  50. package/src/{js/util/getColorMenu.js → ts/util/getColorMenu.ts} +21 -30
  51. package/src/ts/util/isValidJSON.ts +19 -0
  52. package/src/{js/util/setMarkup.js → ts/util/setMarkup.ts} +57 -48
  53. package/src/{js/util/vHidden.js → ts/util/vHidden.ts} +0 -0
  54. package/tsconfig.json +29 -0
  55. package/vite.config.ts +34 -0
  56. package/dist/js/color-esm.js +0 -1167
  57. package/dist/js/color-esm.min.js +0 -2
  58. package/dist/js/color-palette-esm.js +0 -1238
  59. package/dist/js/color-palette-esm.min.js +0 -2
  60. package/dist/js/color-palette.js +0 -1246
  61. package/dist/js/color-palette.min.js +0 -2
  62. package/dist/js/color-picker-element-esm.js +0 -3739
  63. package/dist/js/color-picker-element-esm.min.js +0 -2
  64. package/dist/js/color-picker-element.js +0 -3747
  65. package/dist/js/color-picker-element.min.js +0 -2
  66. package/dist/js/color-picker-esm.js +0 -3578
  67. package/dist/js/color-picker-esm.min.js +0 -2
  68. package/dist/js/color-picker.min.js +0 -2
  69. package/dist/js/color.js +0 -1175
  70. package/dist/js/color.min.js +0 -2
  71. package/src/js/color-palette.js +0 -75
  72. package/src/js/color-picker-element.js +0 -110
  73. package/src/js/color.js +0 -1107
  74. package/src/js/index.js +0 -3
  75. package/src/js/util/colorNames.js +0 -6
  76. package/src/js/util/getColorControls.js +0 -103
  77. package/src/js/util/isValidJSON.js +0 -13
  78. package/src/js/util/nonColors.js +0 -5
  79. package/src/js/util/roundPart.js +0 -9
  80. package/src/js/util/setCSSProperties.js +0 -12
  81. package/src/js/util/tabindex.js +0 -3
  82. package/src/js/util/toggleCEAttr.js +0 -70
  83. package/src/js/util/version.js +0 -6
  84. package/src/js/version.js +0 -6
  85. package/types/cp.d.ts +0 -544
  86. package/types/index.d.ts +0 -48
  87. package/types/source/source.ts +0 -5
  88. package/types/source/types.d.ts +0 -92
package/.eslintrc.cjs ADDED
@@ -0,0 +1,199 @@
1
+ module.exports = {
2
+ env: {
3
+ browser: true,
4
+ es6: true,
5
+ },
6
+ extends: ['plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/recommended-requiring-type-checking'],
7
+ parser: '@typescript-eslint/parser',
8
+ parserOptions: {
9
+ project: 'tsconfig.json',
10
+ sourceType: 'module',
11
+ },
12
+ plugins: [
13
+ 'eslint-plugin-jsdoc',
14
+ 'eslint-plugin-prefer-arrow',
15
+ // "eslint-plugin-react",
16
+ '@typescript-eslint',
17
+ 'prettier',
18
+ ],
19
+ root: true,
20
+ rules: {
21
+ 'prettier/prettier': 'error',
22
+ '@typescript-eslint/adjacent-overload-signatures': 'error',
23
+ '@typescript-eslint/array-type': [
24
+ 'error',
25
+ {
26
+ default: 'array',
27
+ },
28
+ ],
29
+ '@typescript-eslint/ban-types': [
30
+ 'error',
31
+ {
32
+ types: {
33
+ Object: {
34
+ message: 'Avoid using the `Object` type. Did you mean `object`?',
35
+ },
36
+ Function: {
37
+ message: 'Avoid using the `Function` type. Prefer a specific function type, like `() => void`.',
38
+ },
39
+ Boolean: {
40
+ message: 'Avoid using the `Boolean` type. Did you mean `boolean`?',
41
+ },
42
+ Number: {
43
+ message: 'Avoid using the `Number` type. Did you mean `number`?',
44
+ },
45
+ String: {
46
+ message: 'Avoid using the `String` type. Did you mean `string`?',
47
+ },
48
+ Symbol: {
49
+ message: 'Avoid using the `Symbol` type. Did you mean `symbol`?',
50
+ },
51
+ },
52
+ },
53
+ ],
54
+ '@typescript-eslint/unbound-method': 'off',
55
+ '@typescript-eslint/consistent-type-assertions': 'error',
56
+ '@typescript-eslint/dot-notation': 'error',
57
+ '@typescript-eslint/explicit-function-return-type': 'off',
58
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
59
+ '@typescript-eslint/indent': 'off',
60
+ '@typescript-eslint/member-delimiter-style': [
61
+ 'off',
62
+ {
63
+ multiline: {
64
+ delimiter: 'none',
65
+ requireLast: true,
66
+ },
67
+ singleline: {
68
+ delimiter: 'semi',
69
+ requireLast: false,
70
+ },
71
+ },
72
+ ],
73
+ '@typescript-eslint/naming-convention': 'off', // error
74
+ '@typescript-eslint/no-empty-function': 'error',
75
+ '@typescript-eslint/no-empty-interface': 'error',
76
+ '@typescript-eslint/no-explicit-any': 'off',
77
+ '@typescript-eslint/no-misused-new': 'error',
78
+ '@typescript-eslint/no-namespace': 'error',
79
+ '@typescript-eslint/no-parameter-properties': 'off',
80
+ '@typescript-eslint/no-shadow': [
81
+ 'error',
82
+ {
83
+ hoist: 'all',
84
+ },
85
+ ],
86
+ '@typescript-eslint/no-unused-expressions': 'error',
87
+ '@typescript-eslint/no-use-before-define': 'off',
88
+ '@typescript-eslint/no-var-requires': 'error',
89
+ '@typescript-eslint/prefer-for-of': 'error',
90
+ '@typescript-eslint/prefer-function-type': 'error',
91
+ '@typescript-eslint/prefer-namespace-keyword': 'error',
92
+ '@typescript-eslint/quotes': 'off',
93
+ '@typescript-eslint/semi': ['off', null],
94
+ '@typescript-eslint/triple-slash-reference': [
95
+ 'error',
96
+ {
97
+ path: 'always',
98
+ types: 'prefer-import',
99
+ lib: 'always',
100
+ },
101
+ ],
102
+ '@typescript-eslint/type-annotation-spacing': 'off',
103
+ '@typescript-eslint/typedef': 'off',
104
+ '@typescript-eslint/unified-signatures': 'error',
105
+ 'arrow-parens': ['off', 'always'],
106
+ 'brace-style': ['off', 'off'],
107
+ 'comma-dangle': 'off',
108
+ complexity: 'off',
109
+ 'constructor-super': 'error',
110
+ 'dot-notation': 'off',
111
+ 'eol-last': 'off',
112
+ eqeqeq: ['error', 'smart'],
113
+ 'guard-for-in': 'error',
114
+ 'id-denylist': [
115
+ 'error',
116
+ 'any',
117
+ 'Number',
118
+ 'number',
119
+ 'String',
120
+ 'string',
121
+ 'Boolean',
122
+ 'boolean',
123
+ 'Undefined',
124
+ 'undefined',
125
+ ],
126
+ 'id-match': 'error',
127
+ indent: 'off',
128
+ 'jsdoc/check-alignment': 'error',
129
+ 'jsdoc/check-indentation': 'error',
130
+ 'jsdoc/newline-after-description': 'error',
131
+ 'linebreak-style': 'off',
132
+ 'max-classes-per-file': ['error', 1],
133
+ 'max-len': 'off',
134
+ 'new-parens': 'off',
135
+ 'newline-per-chained-call': 'off',
136
+ 'no-bitwise': 'error',
137
+ 'no-caller': 'error',
138
+ 'no-cond-assign': 'error',
139
+ 'no-console': 'error',
140
+ 'no-debugger': 'error',
141
+ 'no-empty': 'error',
142
+ 'no-empty-function': 'off',
143
+ 'no-eval': 'error',
144
+ 'no-extra-semi': 'off',
145
+ 'no-fallthrough': 'off',
146
+ 'no-invalid-this': 'off',
147
+ 'no-irregular-whitespace': 'off',
148
+ 'no-multiple-empty-lines': 'off',
149
+ 'no-new-wrappers': 'error',
150
+ 'no-shadow': 'off',
151
+ 'no-throw-literal': 'error',
152
+ 'no-trailing-spaces': 'off',
153
+ 'no-undef-init': 'error',
154
+ 'no-underscore-dangle': 'off',
155
+ 'no-unsafe-finally': 'error',
156
+ 'no-unused-expressions': 'off',
157
+ 'no-unused-labels': 'error',
158
+ 'no-use-before-define': 'off',
159
+ 'no-var': 'error',
160
+ 'object-shorthand': 'error',
161
+ 'one-var': ['error', 'never'],
162
+ 'padded-blocks': [
163
+ 'off',
164
+ {
165
+ blocks: 'never',
166
+ },
167
+ {
168
+ allowSingleLineBlocks: true,
169
+ },
170
+ ],
171
+ 'prefer-arrow/prefer-arrow-functions': 'error',
172
+ 'prefer-const': 'error',
173
+ 'quote-props': 'off',
174
+ quotes: 'off',
175
+ radix: 'error',
176
+ // "react/jsx-curly-spacing": "off",
177
+ // "react/jsx-equals-spacing": "off",
178
+ // "react/jsx-tag-spacing": [
179
+ // "off",
180
+ // {
181
+ // "afterOpening": "allow",
182
+ // "closingSlash": "allow"
183
+ // }
184
+ // ],
185
+ // "react/jsx-wrap-multilines": "off",
186
+ semi: 'off',
187
+ 'space-before-function-paren': 'off',
188
+ 'space-in-parens': ['off', 'never'],
189
+ 'spaced-comment': [
190
+ 'error',
191
+ 'always',
192
+ {
193
+ markers: ['/'],
194
+ },
195
+ ],
196
+ 'use-isnan': 'error',
197
+ 'valid-typeof': 'off',
198
+ },
199
+ };
package/.lgtm.yml ADDED
@@ -0,0 +1,9 @@
1
+ extraction:
2
+ typescript:
3
+ index:
4
+ exclude:
5
+ - coverage
6
+ - cypress
7
+ - docs
8
+ - experiments
9
+ - node_modules
@@ -0,0 +1,15 @@
1
+ {
2
+ "arrowParens": "avoid",
3
+ "bracketSpacing": true,
4
+ "endOfLine": "lf",
5
+ "bracketSameLine": false,
6
+ "jsxSingleQuote": false,
7
+ "printWidth": 120,
8
+ "proseWrap": "preserve",
9
+ "quoteProps": "as-needed",
10
+ "semi": true,
11
+ "singleQuote": true,
12
+ "tabWidth": 2,
13
+ "trailingComma": "all",
14
+ "useTabs": false
15
+ }
@@ -0,0 +1,236 @@
1
+ {
2
+ "plugins": [
3
+ "stylelint-scss",
4
+ "stylelint-order"
5
+ ],
6
+ "extends": ["stylelint-config-standard-scss"],
7
+ "rules": {
8
+ "color-named": "never",
9
+ "declaration-block-no-duplicate-properties": true,
10
+ "no-descending-specificity": null,
11
+ "color-function-notation": null,
12
+ "block-no-empty": true,
13
+ "color-hex-length": "short",
14
+ "color-no-invalid-hex": true,
15
+ "max-nesting-depth": 4,
16
+ "selector-max-compound-selectors": 5,
17
+ "order/properties-order": [
18
+ "position",
19
+ "top",
20
+ "right",
21
+ "bottom",
22
+ "left",
23
+ "z-index",
24
+ "box-sizing",
25
+ "display",
26
+ "flex",
27
+ "flex-align",
28
+ "flex-basis",
29
+ "flex-direction",
30
+ "flex-wrap",
31
+ "flex-flow",
32
+ "flex-grow",
33
+ "flex-order",
34
+ "flex-pack",
35
+ "align-items",
36
+ "align-self",
37
+ "justify-content",
38
+ "float",
39
+ "width",
40
+ "min-width",
41
+ "max-width",
42
+ "height",
43
+ "min-height",
44
+ "max-height",
45
+ "padding",
46
+ "padding-top",
47
+ "padding-right",
48
+ "padding-bottom",
49
+ "padding-left",
50
+ "margin",
51
+ "margin-top",
52
+ "margin-right",
53
+ "margin-bottom",
54
+ "margin-left",
55
+ "overflow",
56
+ "overflow-x",
57
+ "overflow-y",
58
+ "-webkit-overflow-scrolling",
59
+ "-ms-overflow-style",
60
+ "clip",
61
+ "clear",
62
+ "font",
63
+ "font-family",
64
+ "font-size",
65
+ "font-style",
66
+ "font-weight",
67
+ "font-variant",
68
+ "font-size-adjust",
69
+ "font-stretch",
70
+ "font-effect",
71
+ "font-emphasize",
72
+ "font-emphasize-position",
73
+ "font-emphasize-style",
74
+ "font-smooth",
75
+ "hyphens",
76
+ "line-height",
77
+ "color",
78
+ "text-align",
79
+ "text-align-last",
80
+ "text-emphasis",
81
+ "text-emphasis-color",
82
+ "text-emphasis-style",
83
+ "text-emphasis-position",
84
+ "text-decoration",
85
+ "text-indent",
86
+ "text-justify",
87
+ "text-outline",
88
+ "text-overflow",
89
+ "text-overflow-ellipsis",
90
+ "text-overflow-mode",
91
+ "text-shadow",
92
+ "text-transform",
93
+ "text-wrap",
94
+ "-webkit-text-size-adjust",
95
+ "-ms-text-size-adjust",
96
+ "letter-spacing",
97
+ "word-break",
98
+ "word-spacing",
99
+ "word-wrap",
100
+ "overflow-wrap",
101
+ "tab-size",
102
+ "white-space",
103
+ "vertical-align",
104
+ "list-style",
105
+ "list-style-position",
106
+ "list-style-type",
107
+ "list-style-image",
108
+ "pointer-events",
109
+ "touch-action",
110
+ "cursor",
111
+ "visibility",
112
+ "zoom",
113
+ "table-layout",
114
+ "empty-cells",
115
+ "caption-side",
116
+ "border-spacing",
117
+ "border-collapse",
118
+ "content",
119
+ "quotes",
120
+ "counter-reset",
121
+ "counter-increment",
122
+ "resize",
123
+ "user-select",
124
+ "nav-index",
125
+ "nav-up",
126
+ "nav-right",
127
+ "nav-down",
128
+ "nav-left",
129
+ "background",
130
+ "background-color",
131
+ "background-image",
132
+ "filter",
133
+ "background-repeat",
134
+ "background-attachment",
135
+ "background-position",
136
+ "background-position-x",
137
+ "background-position-y",
138
+ "background-clip",
139
+ "background-origin",
140
+ "background-size",
141
+ "border",
142
+ "border-color",
143
+ "border-style",
144
+ "border-width",
145
+ "border-top",
146
+ "border-top-color",
147
+ "border-top-style",
148
+ "border-top-width",
149
+ "border-right",
150
+ "border-right-color",
151
+ "border-right-style",
152
+ "border-right-width",
153
+ "border-bottom",
154
+ "border-bottom-color",
155
+ "border-bottom-style",
156
+ "border-bottom-width",
157
+ "border-left",
158
+ "border-left-color",
159
+ "border-left-style",
160
+ "border-left-width",
161
+ "border-radius",
162
+ "border-top-left-radius",
163
+ "border-top-right-radius",
164
+ "border-bottom-right-radius",
165
+ "border-bottom-left-radius",
166
+ "border-image",
167
+ "border-image-source",
168
+ "border-image-slice",
169
+ "border-image-width",
170
+ "border-image-outset",
171
+ "border-image-repeat",
172
+ "outline",
173
+ "outline-width",
174
+ "outline-style",
175
+ "outline-color",
176
+ "outline-offset",
177
+ "box-shadow",
178
+ "opacity",
179
+ "-ms-interpolation-mode",
180
+ "transition",
181
+ "transition-delay",
182
+ "transition-timing-function",
183
+ "transition-duration",
184
+ "transition-property",
185
+ "transform",
186
+ "transform-origin",
187
+ "animation",
188
+ "animation-name",
189
+ "animation-duration",
190
+ "animation-play-state",
191
+ "animation-timing-function",
192
+ "animation-delay",
193
+ "animation-iteration-count",
194
+ "animation-direction"
195
+ ],
196
+ "function-url-no-scheme-relative": true,
197
+ "function-url-quotes": "always",
198
+ "length-zero-no-unit": true,
199
+ "property-no-unknown": true,
200
+ "property-no-vendor-prefix": true,
201
+ "scss/dollar-variable-colon-space-before": "never",
202
+ "scss/selector-no-redundant-nesting-selector": true,
203
+ "shorthand-property-no-redundant-values": true,
204
+ "unit-allowed-list": [
205
+ "ch",
206
+ "em",
207
+ "ex",
208
+ "rem",
209
+ "cm",
210
+ "in",
211
+ "mm",
212
+ "pc",
213
+ "pt",
214
+ "px",
215
+ "q",
216
+ "vh",
217
+ "vw",
218
+ "vmin",
219
+ "vmax",
220
+ "fr",
221
+ "deg",
222
+ "grad",
223
+ "rad",
224
+ "turn",
225
+ "ms",
226
+ "s",
227
+ "Hz",
228
+ "kHz",
229
+ "dpi",
230
+ "dpcm",
231
+ "dppx",
232
+ "%"
233
+ ],
234
+ "value-no-vendor-prefix": true
235
+ }
236
+ }
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
@@ -1,129 +1,112 @@
1
- # ColorPicker [![Coverage Status](https://coveralls.io/repos/github/thednp/color-picker/badge.svg?branch=main)](https://coveralls.io/github/thednp/color-picker?branch=main) ![cypress version](https://img.shields.io/badge/cypress-9.6.0-brightgreen) ![typescript version](https://img.shields.io/badge/typescript-4.5.2-brightgreen) [![ci](https://github.com/thednp/color-picker/actions/workflows/ci.yml/badge.svg)](https://github.com/thednp/color-picker/actions/workflows/ci.yml)
1
+ ## ColorPicker
2
2
 
3
- The feature rich **ColorPicker** component for the modern web built with TypeScript definitions, WAI-ARIA compliant and lots of goodies. In addition, it features its own version of [TinyColor](https://github.com/bgrins/TinyColor) called simply `Color`.
3
+ [![Coverage Status](https://coveralls.io/repos/github/thednp/color-picker/badge.svg)](https://coveralls.io/github/thednp/color-picker)
4
+ [![ci](https://github.com/thednp/color-picker/actions/workflows/ci.yml/badge.svg)](https://github.com/thednp/color-picker/actions/workflows/ci.yml)
5
+ [![jsDeliver](https://img.shields.io/jsdelivr/npm/hw/@thednp/color-picker)](https://www.jsdelivr.com/package/npm/@thednp/color-picker)
6
+ [![NPM Version](https://img.shields.io/npm/v/@thednp/color-picker.svg)](https://www.npmjs.com/package/@thednp/color-picker)
7
+ [![typescript version](https://img.shields.io/badge/typescript-5.0.3-brightgreen)](https://www.typescriptlang.org/)
8
+ [![eslint version](https://img.shields.io/badge/eslint-8.37.0-brightgreen)](https://github.com/eslint)
9
+ [![prettier version](https://img.shields.io/badge/prettier-2.8.7-brightgreen)](https://prettier.io/)
10
+ [![cypress version](https://img.shields.io/badge/cypress-12.9.0-brightgreen)](https://cypress.io/)
11
+ [![vite version](https://img.shields.io/badge/vite-4.3.9-brightgreen)](https://github.com/vitejs)
4
12
 
5
- [![image](./docs/img/color-picker.png)](http://thednp.github.io/color-picker)
13
+ The feature rich **ColorPicker** component for the modern web sourced with TypeScript, Cypress tested, WAI-ARIA compliant and lots of goodies. In addition, it features its own version of [TinyColor](https://github.com/bgrins/TinyColor) called simply [Color](http://github.com/thednp/color).
6
14
 
15
+ **ColorPicker** can use existing colour palettes or generate custom ones via DATA API configuration. If you want to play, check out [this codepen](https://codepen.io/thednp/pen/WNdRWPN) I've setup for you. Have fun!
7
16
 
8
- [![NPM Version](https://img.shields.io/npm/v/@thednp/color-picker.svg?style=flat-square)](https://www.npmjs.com/package/@thednp/color-picker)
9
- [![NPM Downloads](https://img.shields.io/npm/dm/@thednp/color-picker.svg?style=flat-square)](http://npm-stat.com/charts.html?package=@thednp/color-picker)
10
- [![Bundle Size](https://img.shields.io/bundlephobia/minzip/@thednp/color-picker?style=flat-square)](https://bundlephobia.com/package/@thednp/color-picker)
11
- [![jsDeliver](https://data.jsdelivr.com/v1/package/npm/@thednp/color-picker/badge)](https://www.jsdelivr.com/package/npm/@thednp/color-picker)
17
+ [![image](./docs/img/color-picker.png)](http://thednp.github.io/color-picker)
12
18
 
13
- **ColorPicker** can use existing colour palettes or generate custom ones via DATA API configuration. If you want to play, check out [this codepen](https://codepen.io/thednp/pen/WNdRWPN) I've setup for you. Have fun!
19
+ ## Highlights
14
20
 
21
+ - Accessibility Focus for WAI-ARIA compliance
22
+ - ES6+ sources with TypeScript definitions
23
+ - Framework agnostic and flexible design
24
+ - Supporting HEX(a), RGB(a), HSL(a) and HWB, the last three also in CSS4 Color Module flavours
25
+ - Supports keyboard and touch events
26
+ - Automatic repositioning of the popup dropdown on show / window scroll
27
+ - SCSS sources with minimal style required
28
+ - Right To Left Languages Supported
29
+ - light footprint, `10kb` in size when minified and gZipped
15
30
 
16
- # Highlights
17
- * Accessibility Focus for WAI-ARIA compliance
18
- * ES6+ sources with TypeScript definitions
19
- * Framework agnostic and flexible design
20
- * Supporting HEX(a), RGB(a), HSL(a) and HWB, the last three also in CSS4 Color Module flavours
21
- * Supports keyboard and touch events
22
- * Automatic repositioning of the popup dropdown on show / window scroll
23
- * SCSS sources with minimal style required
24
- * Right To Left Languages Supported
25
- * light footprint, `10kb` in size when minified and gZipped
31
+ ## Wiki
26
32
 
27
- # Wiki
28
33
  For an in depth guide on all things **ColorPicker**, check out the wiki pages:
29
- * [Home](https://github.com/thednp/color-picker/wiki) - the **ColorPicker** wiki home.
30
- * [NPM](https://github.com/thednp/color-picker/wiki/NPM) - quick installation guide.
31
- * [CDN Link](https://github.com/thednp/color-picker/wiki/CDN) - quick implementation guide.
32
- * [Usage](https://github.com/thednp/color-picker/wiki/Usage) - an in-depth browser usage.
33
- * [ES6+](https://github.com/thednp/color-picker/wiki/ES6) - your usual quick ES6+ guide.
34
- * [Node.js](https://github.com/thednp/color-picker/wiki/Node.js) - is this a thing?
35
34
 
36
- **Note** - the wiki pages are still under construction.
35
+ - [Home](https://github.com/thednp/color-picker/wiki) - the **ColorPicker** wiki home.
36
+ - [NPM](https://github.com/thednp/color-picker/wiki/NPM) - quick installation guide.
37
+ - [CDN Link](https://github.com/thednp/color-picker/wiki/CDN) - quick implementation guide.
38
+ - [Usage](https://github.com/thednp/color-picker/wiki/Usage) - an in-depth browser usage.
39
+ - [ES6+](https://github.com/thednp/color-picker/wiki/ES6) - your usual quick ES6+ guide.
40
+ - [Node.js](https://github.com/thednp/color-picker/wiki/Node.js) - is this a thing?
41
+
42
+ ## NPM
37
43
 
38
- # NPM
39
44
  You can install **ColorPicker** through NPM:
40
45
 
41
46
  ```
42
47
  $ npm install @thednp/color-picker
43
48
  ```
44
49
 
45
- # Browser Usage
50
+ ## Browser Usage
51
+
46
52
  Download the [latest package](https://github.com/thednp/color-picker/archive/master.zip). unpack and inspect the contents. You need to copy the `color-picker.js` and `color-picker.css` or their minified variations to your app `assets` folders as follows.
47
53
  Link the required CSS in your document `<head>` tag
54
+
48
55
  ```html
49
- <link href="../assets/css/color-picker.css" rel="stylesheet">
56
+ <link href="../assets/css/color-picker.css" rel="stylesheet" />
50
57
  ```
51
58
 
52
- Link the required JS in your document `<body>` tag, though it should work in the `<head>` as well
59
+ Link the required JS in your document `<body>` tag, though it should work in the `<head>` as well
60
+
53
61
  ```html
54
62
  <script src="../assets/js/color-picker.js"></script>
55
63
  ```
56
- OR use the `ColorPickerElement` custom element:
57
- ```html
58
- <script src="../assets/js/color-picker-element.js"></script>
59
- ```
60
- OR use the `ColorPickerElement` custom element ESM module:
61
- ```html
62
- <script type="module" src="../assets/js/color-picker-element-esm.js"></script>
63
- ```
64
64
 
65
- If you don't want to use the custom element, you can initialize the function for your elements at the end of your `<body>` tag
65
+ Now you can initialize the function for your elements at the end of your `<body>` tag
66
+
66
67
  ```html
67
68
  <script>
68
- var myPicker = new ColorPicker('input.SELECTOR');
69
+ var myPicker = new ColorPicker('input.SELECTOR');
69
70
  </script>
70
71
  ```
71
72
 
72
73
  To use the DATA-API, you can provide for instance the `data-format="hex"`, and other specific attributes like so:
74
+
73
75
  ```html
74
76
  <label for="myPicker">Color Label</label>
75
77
  <div class="color-picker">
76
- <input id="myPicker" name="myPicker" data-function="color-picker" data-format="hex" data-color-presets="red,green,blue" class="color-preview" value="#069">
78
+ <input
79
+ id="myPicker"
80
+ name="myPicker"
81
+ data-function="color-picker"
82
+ data-format="hex"
83
+ data-color-presets="red,green,blue"
84
+ class="color-preview"
85
+ value="#069"
86
+ />
77
87
  </div>
78
88
  ```
79
- The `data-function="color-picker"` attribute is useful for mass initialization, [check this usage section of the wiki](https://github.com/thednp/color-picker/wiki/Usage#initialize-multiple-targets).
80
89
 
81
- Alternatively you can use the `ColorPickerElement` custom element, the `data-function="color-picker"` attribute is no longer required:
82
- ```html
83
- <label for="myPicker">Colour Field Label</label>
84
- <color-picker data-format="rgb" data-color-keywords="#069:default,#111:revert">
85
- <input id="myPicker" name="myPicker" class="color-preview" value="#069">
86
- </color-picker>
87
-
88
- <script type="module" src="../path-to/color-picker-element-esm.js"></script>
89
- ```
90
- As shown in the above example, all DATA API attributes for instance configuration are to be used on your **custom element**.
90
+ The `data-function="color-picker"` attribute is useful for mass initialization, [check this usage section of the wiki](https://github.com/thednp/color-picker/wiki/Usage#initialize-multiple-targets).
91
91
 
92
+ ## Initialize INPUT
92
93
 
93
- # Initialize INPUT
94
94
  ```javascript
95
95
  import ColorPicker from '@thednp/color-picker';
96
96
 
97
- let myPicker = new ColorPicker('#myPicker');
97
+ const myPicker = new ColorPicker('#myPicker');
98
98
  ```
99
99
 
100
- # Initialize Custom Element
101
- ```javascript
102
- import ColorPickerElement from '@thednp/color-picker/src/color-picker-element';
103
-
104
- // initialize the CustomElement
105
- const myPicker = new ColorPickerElement();
106
- // set DATA API
107
- myPicker.setAttribute('data-format', 'hsl');
108
- myPicker.setAttribute('data-id', 'ADD_YOUR_UNIQUE_ID');
109
- myPicker.setAttribute('data-value', 'rgb(150 0 150 / 0.8)');
110
- myPicker.setAttribute('data-label', 'Color Picker Element Label');
111
- myPicker.setAttribute('data-color-keywords', 'false');
112
-
113
- // append, connectedCallback() is triggered
114
- document.body.append(myPicker);
115
- ```
116
- Other configuration options apply, see [the API Guide](https://github.com/thednp/color-picker/wiki/API).
100
+ ## Thanks
117
101
 
102
+ - Dimitris Grammatikogiannis for his [initial project](https://codepen.io/dgrammatiko/pen/zLvXwR) as well as testing and contributions
103
+ - Serhii Kulykov for his [Vanilla Colorful](https://github.com/web-padawan/vanilla-colorful)
104
+ - Brian Grinstead for his [TinyColor](https://github.com/bgrins/TinyColor)
105
+ - Jonathan Neal for his [convert-colors](https://github.com/jonathantneal/convert-colors)
106
+ - Peter Dematté for his [colorPicker](http://www.dematte.at/colorPicker/)
107
+ - Ștefan Petre at eyecon for his [colorPicker](https://www.eyecon.ro/colorpicker/)
108
+ - Brian Teeman for his [patience](https://github.com/joomla/joomla-cms/pull/35639)
118
109
 
119
- # Thanks
120
- * Dimitris Grammatikogiannis for his [initial project](https://codepen.io/dgrammatiko/pen/zLvXwR) as well as testing and contributions
121
- * Serhii Kulykov for his [Vanilla Colorful](https://github.com/web-padawan/vanilla-colorful)
122
- * Brian Grinstead for his [TinyColor](https://github.com/bgrins/TinyColor)
123
- * Jonathan Neal for his [convert-colors](https://github.com/jonathantneal/convert-colors)
124
- * Peter Dematté for his [colorPicker](http://www.dematte.at/colorPicker/)
125
- * Ștefan Petre at eyecon for his [colorPicker](https://www.eyecon.ro/colorpicker/)
126
- * Brian Teeman for his [patience](https://github.com/joomla/joomla-cms/pull/35639)
110
+ ## License
127
111
 
128
- # License
129
112
  **ColorPicker** is released under the [MIT License](https://github.com/thednp/color-picker/blob/master/LICENSE).