@thednp/color-picker 2.0.1 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +25 -14
- package/dist/css/color-picker.css +3 -6
- package/dist/css/color-picker.css.map +1 -0
- package/dist/css/color-picker.min.css +1 -2
- package/dist/css/color-picker.min.css.map +1 -0
- package/dist/css/color-picker.rtl.css +3 -6
- package/dist/css/color-picker.rtl.css.map +1 -0
- package/dist/css/color-picker.rtl.min.css +1 -2
- package/dist/css/color-picker.rtl.min.css.map +1 -0
- package/dist/js/color-picker.cjs +2 -2
- package/dist/js/color-picker.cjs.map +1 -1
- package/dist/js/color-picker.d.ts +307 -300
- package/dist/js/color-picker.js +2 -2
- package/dist/js/color-picker.js.map +1 -1
- package/dist/js/color-picker.mjs +423 -382
- package/dist/js/color-picker.mjs.map +1 -1
- package/package.json +39 -50
- package/.eslintrc.cjs +0 -199
- package/.lgtm.yml +0 -9
- package/.prettierrc.json +0 -15
- package/.stylelintrc.json +0 -236
- package/compile.cjs +0 -51
- package/cypress/e2e/color-palette.cy.ts +0 -128
- package/cypress/e2e/color-picker.cy.ts +0 -909
- package/cypress/fixtures/colorNamesFrench.js +0 -3
- package/cypress/fixtures/componentLabelsFrench.js +0 -21
- package/cypress/fixtures/format.js +0 -3
- package/cypress/fixtures/getMarkup.js +0 -35
- package/cypress/fixtures/getRandomInt.js +0 -6
- package/cypress/fixtures/sampleWebcolors.js +0 -18
- package/cypress/fixtures/testSample.js +0 -8
- package/cypress/plugins/esbuild-istanbul.ts +0 -50
- package/cypress/plugins/tsCompile.ts +0 -34
- package/cypress/support/commands.ts +0 -0
- package/cypress/support/e2e.ts +0 -21
- package/cypress/test.html +0 -23
- package/cypress.config.ts +0 -30
- package/dts.config.ts +0 -15
- package/src/scss/_variables.scss +0 -6
- package/src/scss/color-picker.rtl.scss +0 -27
- package/src/scss/color-picker.scss +0 -536
- package/src/ts/colorPalette.ts +0 -89
- package/src/ts/index.ts +0 -1236
- package/src/ts/interface/ColorNames.ts +0 -20
- package/src/ts/interface/colorPickerLabels.ts +0 -20
- package/src/ts/interface/colorPickerOptions.ts +0 -11
- package/src/ts/interface/paletteOptions.ts +0 -6
- package/src/ts/util/colorNames.ts +0 -21
- package/src/ts/util/colorPickerLabels.ts +0 -24
- package/src/ts/util/getColorControls.ts +0 -90
- package/src/ts/util/getColorForm.ts +0 -75
- package/src/ts/util/getColorMenu.ts +0 -83
- package/src/ts/util/isValidJSON.ts +0 -19
- package/src/ts/util/setMarkup.ts +0 -130
- package/src/ts/util/vHidden.ts +0 -2
- package/tsconfig.json +0 -29
- package/vite.config.mts +0 -35
@@ -1,21 +0,0 @@
|
|
1
|
-
const componentLabelsFrench = {
|
2
|
-
pickerLabel: "Couleur Sélection",
|
3
|
-
appearanceLabel: "Apparence de la couleur",
|
4
|
-
valueLabel: "Valeur de couleur",
|
5
|
-
toggleLabel: "Sélectionner la couleur",
|
6
|
-
presetsLabel: "Préréglages de couleur",
|
7
|
-
defaultsLabel: "Couleur par défaut",
|
8
|
-
formatLabel: "Format",
|
9
|
-
alphaLabel: "Alpha",
|
10
|
-
hexLabel: "Hexadécimal",
|
11
|
-
hueLabel: "Nuance",
|
12
|
-
whitenessLabel: "Blancheur",
|
13
|
-
blacknessLabel: "Noirceur",
|
14
|
-
saturationLabel: "Saturation",
|
15
|
-
lightnessLabel: "Légèreté",
|
16
|
-
redLabel: "Rouge",
|
17
|
-
greenLabel: "Vert",
|
18
|
-
blueLabel: "Bleu",
|
19
|
-
};
|
20
|
-
|
21
|
-
export default componentLabelsFrench;
|
@@ -1,35 +0,0 @@
|
|
1
|
-
import testSample from "./testSample";
|
2
|
-
import getRandomInt from "./getRandomInt";
|
3
|
-
|
4
|
-
export default function getMarkup(body, id, format) {
|
5
|
-
const set = testSample[getRandomInt(0,3)];
|
6
|
-
const value = set[format];
|
7
|
-
|
8
|
-
const label = document.createElement('label');
|
9
|
-
label.setAttribute('for', `color-picker-${id}`);
|
10
|
-
label.innerText = `Color Picker Test`;
|
11
|
-
|
12
|
-
const cpWrapper = document.createElement('div');
|
13
|
-
cpWrapper.className = 'color-picker';
|
14
|
-
|
15
|
-
const input = document.createElement('input');
|
16
|
-
input.type = 'text';
|
17
|
-
input.id = `color-picker-${id}`;
|
18
|
-
input.className = 'btn-appearance color-preview';
|
19
|
-
input.setAttribute('value', value);
|
20
|
-
input.setAttribute('autocomplete', "off");
|
21
|
-
input.setAttribute('spellcheck', "false");
|
22
|
-
input.setAttribute('data-format', format);
|
23
|
-
|
24
|
-
const a = document.createElement('a');
|
25
|
-
a.setAttribute('href', '#');
|
26
|
-
a.innerText = 'Some link';
|
27
|
-
a.className = 'my-link';
|
28
|
-
a.style = 'position: absolute; top: 20px; opacity: 0.015';
|
29
|
-
// body.append(a);
|
30
|
-
cpWrapper.append(input);
|
31
|
-
if (body) {
|
32
|
-
body.append(label, cpWrapper, a);
|
33
|
-
}
|
34
|
-
return {set, value};
|
35
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
const sampleWebcolors = [
|
2
|
-
{name:"white",rgb:"rgb(255, 255, 255)",hex:"#ffffff",hsl:"hsl(0, 0%, 100%)",hsl4:"hsl(0deg 0% 100%)",hwb:"hwb(0deg 100% 0%)",hsv:{h:0,s:0,v:1,a:1}},
|
3
|
-
{name:"black",rgb:"rgb(0, 0, 0)",hex:"#000000",hsl:"hsl(0, 0%, 0%)",hsl4:"hsl(0deg 0% 0%)",hwb:"hwb(0deg 0% 100%)",hsv:{h:0,s:0,v:0,a:1}},
|
4
|
-
{name:"yellow",rgb:"rgb(255, 255, 0)",hex:"#ffff00",hsl:"hsl(60, 100%, 50%)",hsl4:"hsl(60deg 100% 50%)",hwb:"hwb(60deg 0% 0%)",hsv: {h: 0.167, s: 1, v: 1, a: 1}},
|
5
|
-
{name:"green",rgb:"rgb(0, 128, 0)",hex:"#008000",hsl:"hsl(120, 100%, 25%)",hsl4:"hsl(120deg 100% 25%)",hwb:"hwb(120deg 0% 50%)",hsv: {h: 0.333, s: 1, v: 0.502, a: 1}},
|
6
|
-
{name:"red",rgb:"rgb(255, 0, 0)",hex:"#ff0000",hsl:"hsl(0, 100%, 50%)",hsl4:"hsl(0deg 100% 50%)",hwb:"hwb(0deg 0% 0%)",hsv:{h:0,s:1,v:1,a:1}},
|
7
|
-
{name:"pink",rgb:"rgb(255, 192, 203)",hex:"#ffc0cb",hsl:"hsl(350, 100%, 88%)",hsl4:"hsl(350deg 100% 88%)",hwb:"hwb(350deg 75% 0%)",hsv:{h:0.971,s:0.247,v:1,a:1}},
|
8
|
-
{name:"brown",rgb:"rgb(165, 42, 42)",hex:"#a52a2a",hsl:"hsl(0, 59%, 41%)",hsl4:"hsl(0deg 59% 41%)",hwb:"hwb(0deg 16% 35%)",hsv:{h:0,s:0.745,v:0.647,a:1}},
|
9
|
-
{name:"orange",rgb:"rgb(255, 165, 0)",hex:"#ffa500",hsl:"hsl(39, 100%, 50%)",hsl4:"hsl(39deg 100% 50%)",hwb:"hwb(39deg 0% 0%)",hsv:{h:0.108,s:1,v:1,a:1}},
|
10
|
-
{name:"darkorange",rgb:"rgb(255, 140, 0)",hex:"#ff8c00",hsl:"hsl(33, 100%, 50%)",hsl4:"hsl(33deg 100% 50%)",hwb:"hwb(33deg 0% 0%)",hsv:{h:0.092,s:1,v:1,a:1}},
|
11
|
-
{name:"cyan",rgb:"rgb(0, 255, 255)",hex:"#00ffff",hsl:"hsl(180, 100%, 50%)",hsl4:"hsl(180deg 100% 50%)",hwb:"hwb(180deg 0% 0%)",hsv:{h:0.5,s:1,v:1,a:1}},
|
12
|
-
{name:"yellow",rgb:"rgb(255, 255, 0)",hex:"#ffff00",hsl:"hsl(60, 100%, 50%)",hsl4:"hsl(60deg 100% 50%)",hwb:"hwb(60deg 0% 0%)",hsv:{h:0.167,s:1,v:1,a:1}},
|
13
|
-
{name:"navy",rgb:"rgb(0, 0, 128)",hex:"#000080",hsl:"hsl(240, 100%, 25%)",hsl4:"hsl(240deg 100% 25%)",hwb:"hwb(240deg 0% 50%)",hsv:{h:0.667,s:1,v:0.502,a:1}},
|
14
|
-
{name:"orchid",rgb:"rgb(218, 112, 214)",hex:"#da70d6",hsl:"hsl(302, 59%, 65%)",hsl4:"hsl(302deg 59% 65%)",hwb:"hwb(302deg 44% 15%)",hsv:{h: 0.84, s: 0.486, v: 0.855, a: 1}},
|
15
|
-
{name:"indigo",rgb:"rgb(75, 0, 130)",hex:"#4b0082",hsl:"hsl(275, 100%, 25%)",hsl4:"hsl(275deg 100% 25%)",hwb:"hwb(275deg 0% 49%)",hsv:{h: 0.763, s: 1, v: 0.51, a: 1}},
|
16
|
-
];
|
17
|
-
|
18
|
-
export default sampleWebcolors;
|
@@ -1,8 +0,0 @@
|
|
1
|
-
const testSample = [
|
2
|
-
{name: 'red', hex: '#f00', rgb: 'rgb(255, 0, 0)', hsl: 'hsl(0, 100%, 50%)', hwb: 'hwb(0deg 0% 0%)'},
|
3
|
-
{name: 'lime', hex: '#0f0', rgb: 'rgb(0, 255, 0)', hsl: 'hsl(120, 100%, 50%)', hwb: 'hwb(120deg 0% 0%)'},
|
4
|
-
{name: 'blue', hex: '#00f', rgb: 'rgb(0, 0, 255)', hsl: 'hsl(240, 100%, 50%)', hwb: 'hwb(240deg 0% 0%)'},
|
5
|
-
{name: 'pink', hex: '#f0f', rgb: 'rgb(255, 0, 255)', hsl: 'hsl(300, 100%, 50%)', hwb: 'hwb(300deg 0% 0%)'},
|
6
|
-
];
|
7
|
-
|
8
|
-
export default testSample;
|
@@ -1,50 +0,0 @@
|
|
1
|
-
// sources
|
2
|
-
// * https://github.com/enketo/enketo-express/blob/master/tools/esbuild-plugin-istanbul.js
|
3
|
-
'use strict';
|
4
|
-
import esbuild from 'esbuild';
|
5
|
-
import { promises } from 'fs';
|
6
|
-
import { createInstrumenter } from 'istanbul-lib-instrument';
|
7
|
-
import { extname, sep } from 'path';
|
8
|
-
import tsCompile from './tsCompile';
|
9
|
-
|
10
|
-
// import Cypress settings
|
11
|
-
const sourceFolder = 'src';
|
12
|
-
const [name] = process.cwd().split(sep).slice(-1);
|
13
|
-
|
14
|
-
const sourceFilter = `${name}${sep}${sourceFolder}`;
|
15
|
-
const instrumenter = createInstrumenter({
|
16
|
-
compact: false,
|
17
|
-
esModules: true,
|
18
|
-
preserveComments: true,
|
19
|
-
autoWrap: true,
|
20
|
-
});
|
21
|
-
|
22
|
-
const createEsbuildIstanbulPlugin = (): esbuild.Plugin => {
|
23
|
-
return {
|
24
|
-
name: 'istanbul',
|
25
|
-
setup(build: esbuild.PluginBuild) {
|
26
|
-
build.onLoad(
|
27
|
-
{ filter: /\.(ts|tsx)$/ },
|
28
|
-
async ({ path }: esbuild.OnLoadArgs): Promise<{ contents: string } & Record<string, any>> => {
|
29
|
-
|
30
|
-
if (!path.includes(sourceFilter)) {
|
31
|
-
// console.log("> compiling typescript %s for output build", path);
|
32
|
-
const contents = await promises.readFile(path, 'utf8');
|
33
|
-
return {
|
34
|
-
contents: ['.ts', '.tsx'].includes(extname(path)) ? tsCompile(path).outputText : contents,
|
35
|
-
};
|
36
|
-
}
|
37
|
-
|
38
|
-
// console.log("🧡 instrumenting %s for output coverage", path);
|
39
|
-
const { outputText, sourceMap } = tsCompile(path);
|
40
|
-
|
41
|
-
return {
|
42
|
-
contents: instrumenter.instrumentSync(outputText, path, sourceMap),
|
43
|
-
};
|
44
|
-
},
|
45
|
-
);
|
46
|
-
},
|
47
|
-
};
|
48
|
-
};
|
49
|
-
|
50
|
-
export default createEsbuildIstanbulPlugin;
|
@@ -1,34 +0,0 @@
|
|
1
|
-
// compile.ts
|
2
|
-
import TypeScript from 'typescript';
|
3
|
-
import { basename } from 'path';
|
4
|
-
import { RawSourceMap } from 'source-map';
|
5
|
-
import { readFileSync } from 'fs';
|
6
|
-
|
7
|
-
export default function tsCompile(
|
8
|
-
path: string,
|
9
|
-
ops?: Partial<TypeScript.TranspileOptions>,
|
10
|
-
): TypeScript.TranspileOutput & { sourceMap: RawSourceMap } {
|
11
|
-
// Default options -- you could also perform a merge, or use the project tsconfig.json
|
12
|
-
const options: TypeScript.TranspileOptions = Object.assign(
|
13
|
-
{
|
14
|
-
compilerOptions: {
|
15
|
-
allowJs: true,
|
16
|
-
esModuleInterop: true,
|
17
|
-
removeComments: false,
|
18
|
-
target: 99, // ESNext
|
19
|
-
allowSyntheticDefaultImports: true,
|
20
|
-
isolatedModules: true,
|
21
|
-
noEmitHelpers: true,
|
22
|
-
sourceMap: true,
|
23
|
-
} as Partial<TypeScript.CompilerOptions>,
|
24
|
-
},
|
25
|
-
ops,
|
26
|
-
);
|
27
|
-
const contents = readFileSync(path, { encoding: 'utf8' });
|
28
|
-
const { outputText, sourceMapText } = TypeScript.transpileModule(contents, options);
|
29
|
-
const sourceMap: RawSourceMap = JSON.parse(sourceMapText || '');
|
30
|
-
sourceMap.file = basename(path);
|
31
|
-
sourceMap.sources = [basename(path)];
|
32
|
-
|
33
|
-
return { outputText, sourceMap, sourceMapText };
|
34
|
-
}
|
File without changes
|
package/cypress/support/e2e.ts
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
// ***********************************************************
|
2
|
-
// This example support/index.js is processed and
|
3
|
-
// loaded automatically before your test files.
|
4
|
-
//
|
5
|
-
// This is a great place to put global configuration and
|
6
|
-
// behavior that modifies Cypress.
|
7
|
-
//
|
8
|
-
// You can change the location of this file or turn off
|
9
|
-
// automatically serving support files with the
|
10
|
-
// 'supportFile' configuration option.
|
11
|
-
//
|
12
|
-
// You can read more here:
|
13
|
-
// https://on.cypress.io/configuration
|
14
|
-
// ***********************************************************
|
15
|
-
|
16
|
-
// Import commands.js using ES2015 syntax:
|
17
|
-
// require('./commands')
|
18
|
-
import './commands'
|
19
|
-
|
20
|
-
// Alternatively you can use CommonJS syntax:
|
21
|
-
import '@cypress/code-coverage/support'
|
package/cypress/test.html
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="UTF-8">
|
5
|
-
<title>ColorPicker Testing Page</title>
|
6
|
-
<meta name="description" content="A modern and fully featured color picker web component">
|
7
|
-
<meta name="keywords" content="color, picker, colorpicker, web component, hwb, hex, rgb, hsl, hsv">
|
8
|
-
<link id="styles" rel="stylesheet" href="../dist/css/color-picker.css">
|
9
|
-
<style>
|
10
|
-
body { padding: 65vh 0 65vh 0; margin: 0 auto; width: 60vw; font-family: sans-serif }
|
11
|
-
color-picker, .color-picker {
|
12
|
-
margin: 0 0 2.5rem;
|
13
|
-
--dropdown-transition: none;
|
14
|
-
--btn-transition: none;
|
15
|
-
--options-transition: none;
|
16
|
-
}
|
17
|
-
label { margin: 0.5rem 0;display: block;}
|
18
|
-
body > a { position: absolute; top: 50%; left: 1rem; /* color: white !important clip: 0px 0px 0px 0px; height:0; width: 0 */ }
|
19
|
-
</style>
|
20
|
-
</head>
|
21
|
-
<body>
|
22
|
-
</body>
|
23
|
-
</html>
|
package/cypress.config.ts
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
import { defineConfig } from "cypress";
|
2
|
-
import createBundler from "@bahmutov/cypress-esbuild-preprocessor";
|
3
|
-
import createEsbuildIstanbulPlugin from "./cypress/plugins/esbuild-istanbul";
|
4
|
-
import codeCoverageTask from "@cypress/code-coverage/task";
|
5
|
-
|
6
|
-
async function setupNodeEvents(
|
7
|
-
on: Cypress.PluginEvents,
|
8
|
-
config: Cypress.PluginConfigOptions
|
9
|
-
): Promise<Cypress.PluginConfigOptions> {
|
10
|
-
codeCoverageTask(on, config);
|
11
|
-
|
12
|
-
on(
|
13
|
-
"file:preprocessor",
|
14
|
-
createBundler({
|
15
|
-
plugins: [createEsbuildIstanbulPlugin()],
|
16
|
-
})
|
17
|
-
);
|
18
|
-
|
19
|
-
// Make sure to return the config object as it might have been modified by the plugin.
|
20
|
-
return config;
|
21
|
-
}
|
22
|
-
|
23
|
-
export default defineConfig({
|
24
|
-
e2e: {
|
25
|
-
specPattern: "cypress/e2e/**/*.{js,jsx,ts,tsx}",
|
26
|
-
supportFile: "cypress/support/e2e.ts",
|
27
|
-
video: false,
|
28
|
-
setupNodeEvents,
|
29
|
-
},
|
30
|
-
});
|
package/dts.config.ts
DELETED
package/src/scss/_variables.scss
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
@import "color-picker";
|
2
|
-
|
3
|
-
[dir="rtl"] {
|
4
|
-
.color-preview { text-align: right; }
|
5
|
-
|
6
|
-
.menu-toggle {
|
7
|
-
right: auto; left: 0;
|
8
|
-
border-radius: .25rem 0 0 .25rem;
|
9
|
-
}
|
10
|
-
|
11
|
-
.color-dropdown.picker {
|
12
|
-
right: 0; left: auto;
|
13
|
-
}
|
14
|
-
|
15
|
-
.color-dropdown.menu {
|
16
|
-
right: auto; left: 0;
|
17
|
-
}
|
18
|
-
|
19
|
-
.color-control + .color-control {
|
20
|
-
margin-right: .5rem;
|
21
|
-
margin-left: 0;
|
22
|
-
}
|
23
|
-
|
24
|
-
.color-options.scrollable {
|
25
|
-
margin: 0 0 0 -.5rem;
|
26
|
-
}
|
27
|
-
}
|