@molecule/app-color-picker-react 4.0.0 → 4.1.0
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/README.md +5 -3
- package/dist/ColorPicker.d.ts.map +1 -1
- package/dist/ColorPicker.js +11 -3
- package/package.json +9 -7
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-11-
|
|
6
|
+
Generated: 2026-11-25T09:54:54.493Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-color-picker-react
|
|
@@ -33,7 +33,7 @@ function StrokeColorField() {
|
|
|
33
33
|
## Installation
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
npm install @molecule/app-color-picker-react @molecule/app-i18n @molecule/app-react @molecule/app-ui react
|
|
36
|
+
npm install @molecule/app-color-picker-react @molecule/app-i18n @molecule/app-react @molecule/app-ui @molecule/app-ui-react react
|
|
37
37
|
npm install -D @types/react
|
|
38
38
|
```
|
|
39
39
|
|
|
@@ -195,7 +195,8 @@ Peer dependencies:
|
|
|
195
195
|
|
|
196
196
|
- `@molecule/app-i18n` ^1.0.1
|
|
197
197
|
- `@molecule/app-react` ^4.0.0
|
|
198
|
-
- `@molecule/app-ui` ^1.0
|
|
198
|
+
- `@molecule/app-ui` ^1.9.0
|
|
199
|
+
- `@molecule/app-ui-react` ^4.7.0
|
|
199
200
|
- `react` ^18.0.0 || ^19.0.0
|
|
200
201
|
|
|
201
202
|
### Runtime Dependencies
|
|
@@ -203,6 +204,7 @@ Peer dependencies:
|
|
|
203
204
|
- `@molecule/app-i18n`
|
|
204
205
|
- `@molecule/app-react`
|
|
205
206
|
- `@molecule/app-ui`
|
|
207
|
+
- `@molecule/app-ui-react`
|
|
206
208
|
- `react`
|
|
207
209
|
|
|
208
210
|
## Translations
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPicker.d.ts","sourceRoot":"","sources":["../src/ColorPicker.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,QAAQ,EACR,SAAS,EACT,SAAS,GACV,EAAE,gBAAgB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"ColorPicker.d.ts","sourceRoot":"","sources":["../src/ColorPicker.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,QAAQ,EACR,SAAS,EACT,SAAS,GACV,EAAE,gBAAgB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAyLtC"}
|
package/dist/ColorPicker.js
CHANGED
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { useTranslation } from '@molecule/app-react';
|
|
4
4
|
import { getClassMap } from '@molecule/app-ui';
|
|
5
|
+
import { Box, RangeField, Text, TextField } from '@molecule/app-ui-react/elements';
|
|
5
6
|
import { hexToRgb, hsvToRgb, isValidHex, rgbToHex, rgbToHsv } from './conversions.js';
|
|
6
7
|
/**
|
|
7
8
|
* Controlled color picker — HSV (hue + saturation + value) sliders, RGB
|
|
@@ -81,9 +82,16 @@ export function ColorPicker({ value, onChange, dataMolId, className, }) {
|
|
|
81
82
|
cursor: 'pointer',
|
|
82
83
|
};
|
|
83
84
|
const wrapperClass = cm.cn(cm.flex({ direction: 'col', gap: 'sm' }), className);
|
|
84
|
-
|
|
85
|
+
// Literal keys per channel — every key a `t` call can produce must be a
|
|
86
|
+
// literal the i18n gate can see, so the three channels are spelled out.
|
|
87
|
+
const channelLabels = {
|
|
88
|
+
r: t('colorPicker.r', {}, { defaultValue: 'Red' }),
|
|
89
|
+
g: t('colorPicker.g', {}, { defaultValue: 'Green' }),
|
|
90
|
+
b: t('colorPicker.b', {}, { defaultValue: 'Blue' }),
|
|
91
|
+
};
|
|
92
|
+
return (_jsxs(Box, { as: "div", className: wrapperClass, "data-mol-id": dataMolId ?? 'color-picker', role: "group", "aria-label": t('colorPicker.group', {}, { defaultValue: 'Color picker' }), children: [_jsxs(Box, { as: "div", className: cm.flex({ align: 'center', gap: 'sm' }), children: [_jsx(Box, { as: "span", "aria-hidden": true, webStyle: swatchStyle, "data-mol-id": "color-picker-swatch" }), _jsx(TextField, { as: "input", type: "text", value: hexShown, onValueChange: setHexDraft, onBlur: () => commitHex(hexShown), onKeyDown: (e) => {
|
|
85
93
|
if (e.key === 'Enter') {
|
|
86
|
-
commitHex(
|
|
94
|
+
commitHex(hexShown);
|
|
87
95
|
}
|
|
88
|
-
}, "aria-label": t('colorPicker.hex', {}, { defaultValue: 'HEX color' }), "data-mol-id": "color-picker-hex", spellCheck: false, maxLength: 7,
|
|
96
|
+
}, "aria-label": t('colorPicker.hex', {}, { defaultValue: 'HEX color' }), "data-mol-id": "color-picker-hex", spellCheck: false, maxLength: 7, webStyle: { fontFamily: 'monospace', padding: '0.3rem 0.5rem' } })] }), _jsxs(Box, { as: "label", className: cm.cn(cm.textSize('xs'), cm.flex({ direction: 'col', gap: 'xs' })), children: [_jsx(Text, { as: "span", children: t('colorPicker.hue', {}, { defaultValue: 'Hue' }) }), _jsx(RangeField, { type: "range", min: 0, max: 360, step: 1, value: Math.round(hsv.h), onValueChange: (h) => emitFromHsv({ h }), "aria-label": t('colorPicker.hue', {}, { defaultValue: 'Hue' }), "data-mol-id": "color-picker-hue", webStyle: { ...sliderBase, background: hueGradient } })] }), _jsxs(Box, { as: "label", className: cm.cn(cm.textSize('xs'), cm.flex({ direction: 'col', gap: 'xs' })), children: [_jsx(Text, { as: "span", children: t('colorPicker.saturation', {}, { defaultValue: 'Saturation' }) }), _jsx(RangeField, { type: "range", min: 0, max: 100, step: 1, value: Math.round(hsv.s * 100), onValueChange: (s) => emitFromHsv({ s: s / 100 }), "aria-label": t('colorPicker.saturation', {}, { defaultValue: 'Saturation' }), "data-mol-id": "color-picker-saturation", webStyle: sliderBase })] }), _jsxs(Box, { as: "label", className: cm.cn(cm.textSize('xs'), cm.flex({ direction: 'col', gap: 'xs' })), children: [_jsx(Text, { as: "span", children: t('colorPicker.value', {}, { defaultValue: 'Value' }) }), _jsx(RangeField, { type: "range", min: 0, max: 100, step: 1, value: Math.round(hsv.v * 100), onValueChange: (v) => emitFromHsv({ v: v / 100 }), "aria-label": t('colorPicker.value', {}, { defaultValue: 'Value' }), "data-mol-id": "color-picker-value", webStyle: sliderBase })] }), _jsx(Box, { as: "div", className: cm.flex({ gap: 'sm' }), children: ['r', 'g', 'b'].map((channel) => (_jsxs(Box, { as: "label", className: cm.cn(cm.textSize('xs'), cm.flex({ direction: 'col', gap: 'xs' })), webStyle: { flex: 1 }, children: [_jsx(Text, { as: "span", children: channelLabels[channel] }), _jsx(TextField, { as: "input", type: "number", min: 0, max: 255, step: 1, value: String(rgb[channel]), onValueChange: (text) => emitFromRgb({ [channel]: Number(text) }), "aria-label": channelLabels[channel], "data-mol-id": `color-picker-${channel}`, webStyle: { padding: '0.3rem 0.5rem' } })] }, channel))) })] }));
|
|
89
97
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-color-picker-react",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "HSV slider + RGB sliders + HEX input — controlled color picker for design canvases, photo editors, animation tools",
|
|
5
5
|
"homepage": "https://www.molecule.dev/packages/app-color-picker-react",
|
|
6
6
|
"type": "module",
|
|
@@ -38,20 +38,22 @@
|
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@molecule/app-i18n": "^1.0.1",
|
|
40
40
|
"@molecule/app-react": "^4.0.0",
|
|
41
|
-
"@molecule/app-ui": "^1.0
|
|
41
|
+
"@molecule/app-ui": "^1.9.0",
|
|
42
|
+
"@molecule/app-ui-react": "^4.7.0",
|
|
42
43
|
"react": "^18.0.0 || ^19.0.0"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
|
-
"@molecule/app-i18n": "1.
|
|
46
|
-
"@molecule/app-react": "4.
|
|
47
|
-
"@molecule/app-ui": "1.
|
|
48
|
-
"@molecule/app-ui-
|
|
46
|
+
"@molecule/app-i18n": "1.3.0",
|
|
47
|
+
"@molecule/app-react": "4.17.0",
|
|
48
|
+
"@molecule/app-ui": "1.13.0",
|
|
49
|
+
"@molecule/app-ui-react": "4.11.0",
|
|
50
|
+
"@molecule/app-ui-tailwind": "1.5.1",
|
|
49
51
|
"@testing-library/dom": "10.4.2",
|
|
50
52
|
"@testing-library/react": "16.3.3",
|
|
51
53
|
"@types/node": "26.6.5",
|
|
52
54
|
"@types/react": "19.3.0",
|
|
53
55
|
"@types/react-dom": "19.3.0",
|
|
54
|
-
"jsdom": "
|
|
56
|
+
"jsdom": "31.0.1",
|
|
55
57
|
"react": "19.3.1",
|
|
56
58
|
"react-dom": "19.3.1",
|
|
57
59
|
"typescript": "6.0.3",
|