@thednp/color-picker 1.0.1 → 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.
- package/.eslintrc.cjs +199 -0
- package/.lgtm.yml +9 -0
- package/.prettierrc.json +15 -0
- package/.stylelintrc.json +236 -0
- package/LICENSE +0 -0
- package/README.md +54 -72
- package/compile.js +48 -0
- package/cypress/downloads/downloads.htm +0 -0
- package/cypress/e2e/color-palette.cy.ts +128 -0
- package/cypress/e2e/color-picker.cy.ts +920 -0
- package/cypress/fixtures/colorNamesFrench.js +3 -0
- package/cypress/fixtures/componentLabelsFrench.js +21 -0
- package/cypress/fixtures/format.js +3 -0
- package/cypress/fixtures/getCEMarkup.js +29 -0
- package/cypress/fixtures/getMarkup.js +28 -0
- package/cypress/fixtures/getRandomInt.js +6 -0
- package/cypress/fixtures/sampleWebcolors.js +18 -0
- package/cypress/fixtures/testSample.js +8 -0
- package/cypress/plugins/esbuild-istanbul.ts +50 -0
- package/cypress/plugins/tsCompile.ts +34 -0
- package/cypress/support/commands.ts +0 -0
- package/cypress/support/e2e.ts +21 -0
- package/cypress/test.html +23 -0
- package/cypress.config.ts +29 -0
- package/dist/css/color-picker.css +14 -38
- package/dist/css/color-picker.min.css +2 -2
- package/dist/css/color-picker.rtl.css +14 -38
- package/dist/css/color-picker.rtl.min.css +2 -2
- package/dist/js/color-picker.cjs +8 -0
- package/dist/js/color-picker.cjs.map +1 -0
- package/dist/js/color-picker.d.ts +278 -0
- package/dist/js/color-picker.js +5 -3570
- package/dist/js/color-picker.js.map +1 -0
- package/dist/js/color-picker.mjs +2631 -0
- package/dist/js/color-picker.mjs.map +1 -0
- package/dts.config.ts +15 -0
- package/package.json +64 -74
- package/src/scss/_variables.scss +0 -1
- package/src/scss/color-picker.rtl.scss +4 -0
- package/src/scss/color-picker.scss +74 -38
- package/src/ts/colorPalette.ts +89 -0
- package/src/{js/color-picker.js → ts/index.ts} +489 -486
- package/src/ts/interface/colorPickerLabels.ts +20 -0
- package/src/ts/interface/colorPickerOptions.ts +11 -0
- package/src/ts/interface/paletteOptions.ts +6 -0
- package/src/ts/util/colorNames.ts +21 -0
- package/src/{js/util/colorPickerLabels.js → ts/util/colorPickerLabels.ts} +4 -2
- package/src/ts/util/getColorControls.ts +90 -0
- package/src/{js/util/getColorForm.js → ts/util/getColorForm.ts} +28 -18
- package/src/{js/util/getColorMenu.js → ts/util/getColorMenu.ts} +21 -30
- package/src/ts/util/isValidJSON.ts +19 -0
- package/src/{js/util/setMarkup.js → ts/util/setMarkup.ts} +57 -48
- package/src/{js/util/vHidden.js → ts/util/vHidden.ts} +0 -0
- package/tsconfig.json +29 -0
- package/vite.config.ts +34 -0
- package/dist/js/color-esm.js +0 -1164
- package/dist/js/color-esm.min.js +0 -2
- package/dist/js/color-palette-esm.js +0 -1235
- package/dist/js/color-palette-esm.min.js +0 -2
- package/dist/js/color-palette.js +0 -1243
- package/dist/js/color-palette.min.js +0 -2
- package/dist/js/color-picker-element-esm.js +0 -3718
- package/dist/js/color-picker-element-esm.min.js +0 -2
- package/dist/js/color-picker-element.js +0 -3726
- package/dist/js/color-picker-element.min.js +0 -2
- package/dist/js/color-picker-esm.js +0 -3565
- package/dist/js/color-picker-esm.min.js +0 -2
- package/dist/js/color-picker.min.js +0 -2
- package/dist/js/color.js +0 -1172
- package/dist/js/color.min.js +0 -2
- package/src/js/color-palette.js +0 -75
- package/src/js/color-picker-element.js +0 -107
- package/src/js/color.js +0 -1104
- package/src/js/index.js +0 -8
- package/src/js/util/colorNames.js +0 -6
- package/src/js/util/getColorControls.js +0 -103
- package/src/js/util/isValidJSON.js +0 -13
- package/src/js/util/nonColors.js +0 -5
- package/src/js/util/roundPart.js +0 -9
- package/src/js/util/setCSSProperties.js +0 -12
- package/src/js/util/tabindex.js +0 -3
- package/src/js/util/toggleCEAttr.js +0 -70
- package/src/js/util/version.js +0 -5
- package/src/js/version.js +0 -5
- package/types/cp.d.ts +0 -558
- package/types/index.d.ts +0 -44
- package/types/source/source.ts +0 -4
- 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
package/.prettierrc.json
ADDED
@@ -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,42 +1,46 @@
|
|
1
1
|
## ColorPicker
|
2
|
+
|
2
3
|
[](https://coveralls.io/github/thednp/color-picker)
|
3
4
|
[](https://github.com/thednp/color-picker/actions/workflows/ci.yml)
|
4
|
-
[](https://www.npmjs.com/package/@thednp/color-picker)
|
5
|
-
[](http://npm-stat.com/charts.html?package=@thednp/color-picker)
|
6
5
|
[](https://www.jsdelivr.com/package/npm/@thednp/color-picker)
|
7
|
-
](https://www.npmjs.com/package/@thednp/color-picker)
|
7
|
+
[](https://www.typescriptlang.org/)
|
8
|
+
[](https://github.com/eslint)
|
9
|
+
[](https://prettier.io/)
|
10
|
+
[](https://cypress.io/)
|
11
|
+
[](https://github.com/vitejs)
|
9
12
|
|
10
|
-
The feature rich **ColorPicker** component for the modern web
|
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).
|
11
14
|
|
12
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!
|
13
16
|
|
14
17
|
[](http://thednp.github.io/color-picker)
|
15
18
|
|
16
|
-
|
17
19
|
## Highlights
|
18
|
-
* Accessibility Focus for WAI-ARIA compliance
|
19
|
-
* ES6+ sources with TypeScript definitions
|
20
|
-
* Framework agnostic and flexible design
|
21
|
-
* Supporting HEX(a), RGB(a), HSL(a) and HWB, the last three also in CSS4 Color Module flavours
|
22
|
-
* Supports keyboard and touch events
|
23
|
-
* Automatic repositioning of the popup dropdown on show / window scroll
|
24
|
-
* SCSS sources with minimal style required
|
25
|
-
* Right To Left Languages Supported
|
26
|
-
* light footprint, `10kb` in size when minified and gZipped
|
27
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
|
28
30
|
|
29
31
|
## Wiki
|
32
|
+
|
30
33
|
For an in depth guide on all things **ColorPicker**, check out the wiki pages:
|
31
|
-
* [Home](https://github.com/thednp/color-picker/wiki) - the **ColorPicker** wiki home.
|
32
|
-
* [NPM](https://github.com/thednp/color-picker/wiki/NPM) - quick installation guide.
|
33
|
-
* [CDN Link](https://github.com/thednp/color-picker/wiki/CDN) - quick implementation guide.
|
34
|
-
* [Usage](https://github.com/thednp/color-picker/wiki/Usage) - an in-depth browser usage.
|
35
|
-
* [ES6+](https://github.com/thednp/color-picker/wiki/ES6) - your usual quick ES6+ guide.
|
36
|
-
* [Node.js](https://github.com/thednp/color-picker/wiki/Node.js) - is this a thing?
|
37
34
|
|
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?
|
38
41
|
|
39
42
|
## NPM
|
43
|
+
|
40
44
|
You can install **ColorPicker** through NPM:
|
41
45
|
|
42
46
|
```
|
@@ -44,87 +48,65 @@ $ npm install @thednp/color-picker
|
|
44
48
|
```
|
45
49
|
|
46
50
|
## Browser Usage
|
51
|
+
|
47
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.
|
48
53
|
Link the required CSS in your document `<head>` tag
|
54
|
+
|
49
55
|
```html
|
50
|
-
<link href="../assets/css/color-picker.css" rel="stylesheet"
|
56
|
+
<link href="../assets/css/color-picker.css" rel="stylesheet" />
|
51
57
|
```
|
52
58
|
|
53
|
-
Link the required JS in your document
|
59
|
+
Link the required JS in your document `<body>` tag, though it should work in the `<head>` as well
|
60
|
+
|
54
61
|
```html
|
55
62
|
<script src="../assets/js/color-picker.js"></script>
|
56
63
|
```
|
57
|
-
OR use the `ColorPickerElement` custom element:
|
58
|
-
```html
|
59
|
-
<script src="../assets/js/color-picker-element.js"></script>
|
60
|
-
```
|
61
|
-
OR use the `ColorPickerElement` custom element ESM module:
|
62
|
-
```html
|
63
|
-
<script type="module" src="../assets/js/color-picker-element-esm.js"></script>
|
64
|
-
```
|
65
64
|
|
66
|
-
|
65
|
+
Now you can initialize the function for your elements at the end of your `<body>` tag
|
66
|
+
|
67
67
|
```html
|
68
68
|
<script>
|
69
|
-
var myPicker = new ColorPicker('input.SELECTOR');
|
69
|
+
var myPicker = new ColorPicker('input.SELECTOR');
|
70
70
|
</script>
|
71
71
|
```
|
72
72
|
|
73
73
|
To use the DATA-API, you can provide for instance the `data-format="hex"`, and other specific attributes like so:
|
74
|
+
|
74
75
|
```html
|
75
76
|
<label for="myPicker">Color Label</label>
|
76
77
|
<div class="color-picker">
|
77
|
-
<input
|
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
|
+
/>
|
78
87
|
</div>
|
79
88
|
```
|
80
|
-
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).
|
81
|
-
|
82
|
-
Alternatively you can use the `ColorPickerElement` custom element, the `data-function="color-picker"` attribute is no longer required:
|
83
|
-
```html
|
84
|
-
<label for="myPicker">Colour Field Label</label>
|
85
|
-
<color-picker data-format="rgb" data-color-keywords="#069:default,#111:revert">
|
86
|
-
<input id="myPicker" name="myPicker" class="color-preview" value="#069">
|
87
|
-
</color-picker>
|
88
|
-
|
89
|
-
<script type="module" src="../path-to/color-picker-element-esm.js"></script>
|
90
|
-
```
|
91
|
-
As shown in the above example, all DATA API attributes for instance configuration are to be used on your **custom element**.
|
92
89
|
|
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).
|
93
91
|
|
94
92
|
## Initialize INPUT
|
93
|
+
|
95
94
|
```javascript
|
96
95
|
import ColorPicker from '@thednp/color-picker';
|
97
96
|
|
98
97
|
const myPicker = new ColorPicker('#myPicker');
|
99
98
|
```
|
100
99
|
|
101
|
-
## Initialize Custom Element
|
102
|
-
```javascript
|
103
|
-
import ColorPickerElement from '@thednp/color-picker/src/color-picker-element';
|
104
|
-
|
105
|
-
// initialize the CustomElement
|
106
|
-
const myPicker = new ColorPickerElement();
|
107
|
-
// set DATA API
|
108
|
-
myPicker.setAttribute('data-format', 'hsl');
|
109
|
-
myPicker.setAttribute('data-id', 'ADD_YOUR_UNIQUE_ID');
|
110
|
-
myPicker.setAttribute('data-value', 'rgb(150 0 150 / 0.8)');
|
111
|
-
myPicker.setAttribute('data-label', 'Color Picker Element Label');
|
112
|
-
myPicker.setAttribute('data-color-keywords', 'false');
|
113
|
-
|
114
|
-
// append, connectedCallback() is triggered
|
115
|
-
document.body.append(myPicker);
|
116
|
-
```
|
117
|
-
Other configuration options apply, see [the API Guide](https://github.com/thednp/color-picker/wiki/API).
|
118
|
-
|
119
|
-
|
120
100
|
## Thanks
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
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)
|
128
109
|
|
129
110
|
## License
|
111
|
+
|
130
112
|
**ColorPicker** is released under the [MIT License](https://github.com/thednp/color-picker/blob/master/LICENSE).
|