@thednp/color-picker 2.0.2 → 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 +369 -332
- package/dist/js/color-picker.mjs.map +1 -1
- package/package.json +36 -44
- 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/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 -1237
- 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/test/color-palette.test.ts +0 -137
- package/test/color-picker.test.ts +0 -705
- package/test/fixtures/colorNamesFrench.js +0 -3
- package/test/fixtures/componentLabelsFrench.js +0 -21
- package/test/fixtures/format.js +0 -3
- package/test/fixtures/getMarkup.js +0 -36
- package/test/fixtures/getRandomInt.js +0 -6
- package/test/fixtures/sampleWebcolors.js +0 -18
- package/test/fixtures/swipe.ts +0 -33
- package/test/fixtures/testSample.js +0 -8
- package/test/fixtures/write.ts +0 -37
- package/tsconfig.json +0 -47
- package/vite.config.mts +0 -27
- package/vitest.config-ui.ts +0 -26
- package/vitest.config.ts +0 -26
@@ -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;
|
package/test/fixtures/format.js
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
import testSample from "./testSample";
|
2
|
-
import getRandomInt from "./getRandomInt";
|
3
|
-
|
4
|
-
export default function getMarkup(id, format) {
|
5
|
-
const set = testSample[getRandomInt(0,3)];
|
6
|
-
const value = set[format];
|
7
|
-
|
8
|
-
const container = document.createElement('div');
|
9
|
-
|
10
|
-
const label = document.createElement('label');
|
11
|
-
label.setAttribute('for', `color-picker-${id}`);
|
12
|
-
label.innerText = `Color Picker Test`;
|
13
|
-
|
14
|
-
const cpWrapper = document.createElement('div');
|
15
|
-
cpWrapper.className = 'color-picker';
|
16
|
-
|
17
|
-
const input = document.createElement('input');
|
18
|
-
input.type = 'text';
|
19
|
-
input.id = `color-picker-${id}`;
|
20
|
-
input.className = 'btn-appearance color-preview';
|
21
|
-
input.setAttribute('value', value);
|
22
|
-
input.setAttribute('autocomplete', "off");
|
23
|
-
input.setAttribute('spellcheck', "false");
|
24
|
-
input.setAttribute('data-format', format);
|
25
|
-
|
26
|
-
const a = document.createElement('a');
|
27
|
-
a.setAttribute('href', '#');
|
28
|
-
a.innerText = 'Some link';
|
29
|
-
a.className = 'my-link';
|
30
|
-
a.style = 'position: absolute; top: 0px; right:0; opacity: 0.015';
|
31
|
-
|
32
|
-
cpWrapper.append(input);
|
33
|
-
container.append(label, cpWrapper, a);
|
34
|
-
|
35
|
-
return { container, set, value};
|
36
|
-
}
|
@@ -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;
|
package/test/fixtures/swipe.ts
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Triggers a number of pointer events for a given target and
|
3
|
-
* an array of coordinates.
|
4
|
-
* @param target the element to dispatch the pointer event(s)
|
5
|
-
* @param points an array of [clientX, clientY] coordinates
|
6
|
-
* @param offset an optional offset object of { x, y } coordinates
|
7
|
-
*/
|
8
|
-
const swipe = <T extends HTMLElement = HTMLElement>(target: T, points: [number, number][], offset?: { x: number, y: number }) => {
|
9
|
-
const rect = target.getBoundingClientRect();
|
10
|
-
const offsetX = Number.isInteger(offset?.x) ? offset!.x : rect.left;
|
11
|
-
const offsetY = Number.isInteger(offset?.y) ? offset!.y : rect.top;
|
12
|
-
if (points.length === 1) points.push([0,0]);
|
13
|
-
|
14
|
-
points.forEach(([x,y], i) => {
|
15
|
-
// first is a pointerdown, last is a pointerup and all pointermove in between
|
16
|
-
const ev = i === 0 ? 'pointerdown' : i === points.length - 1 ? 'pointerup' : 'pointermove';
|
17
|
-
const point = new PointerEvent(ev, {
|
18
|
-
clientX: x + offsetX, clientY: y + offsetY,
|
19
|
-
pressure: 1,
|
20
|
-
bubbles: true, // Whether the event should bubble up the DOM
|
21
|
-
cancelable: true, // Whether the event can be canceled
|
22
|
-
pointerId: 0, // The ID of the pointer (e.g., a touch point)
|
23
|
-
pointerType: "touch", // The type of pointer (e.g., touch or mouse)
|
24
|
-
width: 1, // The width of the pointer (in pixels)
|
25
|
-
height: 1, // The height of the pointer (in pixels)
|
26
|
-
isPrimary: true, // Whether this is the primary pointer (true) or not (false)
|
27
|
-
});
|
28
|
-
target.dispatchEvent(point);
|
29
|
-
target.offsetWidth;
|
30
|
-
});
|
31
|
-
};
|
32
|
-
|
33
|
-
export default swipe;
|
@@ -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;
|
package/test/fixtures/write.ts
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* A simple utility to type text into input elements.
|
3
|
-
* It will split the string provided and replace spaces with Space keyboard key
|
4
|
-
* and will trigger a dispatch for each keyboard key found in the string.
|
5
|
-
* @param target A button, input element or editable element
|
6
|
-
* @param value the text to type
|
7
|
-
*
|
8
|
-
* @example
|
9
|
-
* write(target, "hsl 150 0 0")
|
10
|
-
* write(target, "hslSpace150Space0Space0Enter")
|
11
|
-
*/
|
12
|
-
const write = <T extends HTMLElement = HTMLElement>(target: T, value: string) => {
|
13
|
-
const text = value.trim();
|
14
|
-
|
15
|
-
target.focus();
|
16
|
-
if (target instanceof HTMLInputElement) target.select();
|
17
|
-
if (['Space', 'Enter'].some(x => text === x) && target.tagName === 'BUTTON') {
|
18
|
-
target.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
19
|
-
// target.dispatchEvent(new KeyboardEvent('keyup', { key: text, code: text, bubbles: true }));
|
20
|
-
} else {
|
21
|
-
if (target instanceof HTMLInputElement) {
|
22
|
-
const newValue = text.replace(/Enter/g, '').replace(/Space/g, ' ');
|
23
|
-
target.setAttribute('value', newValue);
|
24
|
-
target.value = newValue;
|
25
|
-
target.offsetWidth;
|
26
|
-
// console.log(newValue)
|
27
|
-
// target.dispatchEvent(new KeyboardEvent('input', { bubbles: true }));
|
28
|
-
if (text.endsWith('Enter')) {
|
29
|
-
target.dispatchEvent(new Event('change', { bubbles: true }));
|
30
|
-
// target.dispatchEvent(new KeyboardEvent('keyup', { key: "Enter", code: "Enter", bubbles: true }));
|
31
|
-
}
|
32
|
-
|
33
|
-
}
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
export default write;
|
package/tsconfig.json
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
{
|
2
|
-
// https://janessagarrow.com/blog/typescript-and-esbuild/
|
3
|
-
"compilerOptions": {
|
4
|
-
"lib": [
|
5
|
-
"DOM",
|
6
|
-
"ESNext",
|
7
|
-
"DOM.Iterable"
|
8
|
-
],
|
9
|
-
// "types": ["vite", "vite/client", "@thednp/shorty", "@thednp/color"],
|
10
|
-
"rootDir": "./",
|
11
|
-
"baseUrl": "./",
|
12
|
-
"module": "ESNext",
|
13
|
-
"target": "ESNext",
|
14
|
-
"moduleResolution": "Bundler",
|
15
|
-
"allowJs": true,
|
16
|
-
"forceConsistentCasingInFileNames": true,
|
17
|
-
"useDefineForClassFields": true,
|
18
|
-
"strict": true,
|
19
|
-
"sourceMap": true,
|
20
|
-
"resolveJsonModule": true,
|
21
|
-
"esModuleInterop": true,
|
22
|
-
"isolatedModules": true,
|
23
|
-
"noUnusedLocals": true,
|
24
|
-
"noUnusedParameters": true,
|
25
|
-
"noImplicitReturns": true,
|
26
|
-
"removeComments": false,
|
27
|
-
"allowSyntheticDefaultImports": true,
|
28
|
-
"noEmit": true,
|
29
|
-
"skipLibCheck": true, // allows dts-bundle-generator to import from package.json
|
30
|
-
"paths": {
|
31
|
-
"~/*": [
|
32
|
-
"./src/*"
|
33
|
-
],
|
34
|
-
}
|
35
|
-
},
|
36
|
-
"include": [
|
37
|
-
"src/*",
|
38
|
-
"src/**/*",
|
39
|
-
"test/**/*"
|
40
|
-
],
|
41
|
-
"exclude": [
|
42
|
-
"node_modules",
|
43
|
-
"experiments",
|
44
|
-
"coverage",
|
45
|
-
"dist"
|
46
|
-
],
|
47
|
-
}
|
package/vite.config.mts
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
import { resolve } from 'node:path';
|
2
|
-
import { defineConfig } from 'vite';
|
3
|
-
|
4
|
-
const NAME = 'ColorPicker';
|
5
|
-
|
6
|
-
const fileName = {
|
7
|
-
es: `color-picker.mjs`,
|
8
|
-
cjs: `color-picker.cjs`,
|
9
|
-
iife: `color-picker.js`,
|
10
|
-
};
|
11
|
-
|
12
|
-
export default defineConfig({
|
13
|
-
base: './',
|
14
|
-
build: {
|
15
|
-
emptyOutDir: true,
|
16
|
-
outDir: 'dist/js',
|
17
|
-
lib: {
|
18
|
-
entry: resolve(__dirname, 'src/ts/index.ts'),
|
19
|
-
name: NAME,
|
20
|
-
formats: ['es', 'cjs', 'iife'],
|
21
|
-
fileName: (format: string) => fileName[format],
|
22
|
-
},
|
23
|
-
sourcemap: true,
|
24
|
-
target: "ESNext",
|
25
|
-
},
|
26
|
-
});
|
27
|
-
|
package/vitest.config-ui.ts
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
import { defineConfig } from "vitest/config";
|
2
|
-
import { resolve } from 'node:path';
|
3
|
-
|
4
|
-
export default defineConfig({
|
5
|
-
resolve: {
|
6
|
-
alias: {
|
7
|
-
"~": resolve(__dirname, "src"),
|
8
|
-
},
|
9
|
-
},
|
10
|
-
test: {
|
11
|
-
css: true,
|
12
|
-
globals: true,
|
13
|
-
coverage: {
|
14
|
-
provider: "istanbul",
|
15
|
-
reporter: ["html", "text", "lcov"],
|
16
|
-
enabled: true,
|
17
|
-
include: ["src/**/*.{ts,tsx}"],
|
18
|
-
},
|
19
|
-
browser: {
|
20
|
-
// provider: 'webdriverio', // or 'webdriverio'
|
21
|
-
enabled: true,
|
22
|
-
headless: false,
|
23
|
-
name: 'chromium', // browser name is required
|
24
|
-
},
|
25
|
-
},
|
26
|
-
});
|
package/vitest.config.ts
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
import { defineConfig } from "vitest/config";
|
2
|
-
import { resolve } from 'node:path';
|
3
|
-
|
4
|
-
export default defineConfig({
|
5
|
-
resolve: {
|
6
|
-
alias: {
|
7
|
-
"~": resolve(__dirname, "src"),
|
8
|
-
},
|
9
|
-
},
|
10
|
-
test: {
|
11
|
-
css: true,
|
12
|
-
globals: true,
|
13
|
-
coverage: {
|
14
|
-
provider: "istanbul",
|
15
|
-
reporter: ["html", "text", "lcov"],
|
16
|
-
enabled: true,
|
17
|
-
include: ["src/**/*.{ts,tsx}"],
|
18
|
-
},
|
19
|
-
browser: {
|
20
|
-
provider: 'playwright', // or 'webdriverio'
|
21
|
-
enabled: true,
|
22
|
-
headless: true,
|
23
|
-
name: 'chromium', // browser name is required
|
24
|
-
},
|
25
|
-
},
|
26
|
-
});
|