@darthrapid/react-native-color-picker 0.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.
Files changed (65) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +160 -0
  3. package/lib/module/components/color-picker.js +214 -0
  4. package/lib/module/components/color-picker.js.map +1 -0
  5. package/lib/module/components/hue-strip.js +113 -0
  6. package/lib/module/components/hue-strip.js.map +1 -0
  7. package/lib/module/components/picker-panel.js +121 -0
  8. package/lib/module/components/picker-panel.js.map +1 -0
  9. package/lib/module/components/picker-tab.js +38 -0
  10. package/lib/module/components/picker-tab.js.map +1 -0
  11. package/lib/module/components/recent-tab.js +89 -0
  12. package/lib/module/components/recent-tab.js.map +1 -0
  13. package/lib/module/components/sat-bright-pad.js +171 -0
  14. package/lib/module/components/sat-bright-pad.js.map +1 -0
  15. package/lib/module/components/tab-bar.js +41 -0
  16. package/lib/module/components/tab-bar.js.map +1 -0
  17. package/lib/module/components/values-tab.js +161 -0
  18. package/lib/module/components/values-tab.js.map +1 -0
  19. package/lib/module/index.js +4 -0
  20. package/lib/module/index.js.map +1 -0
  21. package/lib/module/package.json +1 -0
  22. package/lib/module/shared/const.js +43 -0
  23. package/lib/module/shared/const.js.map +1 -0
  24. package/lib/module/types/misc.js +4 -0
  25. package/lib/module/types/misc.js.map +1 -0
  26. package/lib/module/utils/colors.js +52 -0
  27. package/lib/module/utils/colors.js.map +1 -0
  28. package/lib/typescript/package.json +1 -0
  29. package/lib/typescript/src/components/color-picker.d.ts +37 -0
  30. package/lib/typescript/src/components/color-picker.d.ts.map +1 -0
  31. package/lib/typescript/src/components/hue-strip.d.ts +10 -0
  32. package/lib/typescript/src/components/hue-strip.d.ts.map +1 -0
  33. package/lib/typescript/src/components/picker-panel.d.ts +32 -0
  34. package/lib/typescript/src/components/picker-panel.d.ts.map +1 -0
  35. package/lib/typescript/src/components/picker-tab.d.ts +17 -0
  36. package/lib/typescript/src/components/picker-tab.d.ts.map +1 -0
  37. package/lib/typescript/src/components/recent-tab.d.ts +12 -0
  38. package/lib/typescript/src/components/recent-tab.d.ts.map +1 -0
  39. package/lib/typescript/src/components/sat-bright-pad.d.ts +14 -0
  40. package/lib/typescript/src/components/sat-bright-pad.d.ts.map +1 -0
  41. package/lib/typescript/src/components/tab-bar.d.ts +11 -0
  42. package/lib/typescript/src/components/tab-bar.d.ts.map +1 -0
  43. package/lib/typescript/src/components/values-tab.d.ts +17 -0
  44. package/lib/typescript/src/components/values-tab.d.ts.map +1 -0
  45. package/lib/typescript/src/index.d.ts +3 -0
  46. package/lib/typescript/src/index.d.ts.map +1 -0
  47. package/lib/typescript/src/shared/const.d.ts +33 -0
  48. package/lib/typescript/src/shared/const.d.ts.map +1 -0
  49. package/lib/typescript/src/types/misc.d.ts +21 -0
  50. package/lib/typescript/src/types/misc.d.ts.map +1 -0
  51. package/lib/typescript/src/utils/colors.d.ts +14 -0
  52. package/lib/typescript/src/utils/colors.d.ts.map +1 -0
  53. package/package.json +123 -0
  54. package/src/components/color-picker.tsx +290 -0
  55. package/src/components/hue-strip.tsx +134 -0
  56. package/src/components/picker-panel.tsx +176 -0
  57. package/src/components/picker-tab.tsx +48 -0
  58. package/src/components/recent-tab.tsx +90 -0
  59. package/src/components/sat-bright-pad.tsx +158 -0
  60. package/src/components/tab-bar.tsx +59 -0
  61. package/src/components/values-tab.tsx +166 -0
  62. package/src/index.tsx +2 -0
  63. package/src/shared/const.ts +43 -0
  64. package/src/types/misc.ts +24 -0
  65. package/src/utils/colors.ts +57 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Martin Rapčan
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,160 @@
1
+ # @darthrapid/react-native-simple-color-picker
2
+
3
+ Lightweight HSB color picker for React Native with modal/inline modes, tabs, and i18n support. Pure JS, Expo compatible.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add @darthrapid/react-native-simple-color-picker
9
+ ```
10
+
11
+ ### Peer dependency
12
+
13
+ ```bash
14
+ bun add react-native-svg
15
+ ```
16
+
17
+ ## Basic Usage
18
+
19
+ By default, renders as a small color swatch. Tap it to open the picker modal.
20
+
21
+ ```tsx
22
+ import { useState } from "react";
23
+ import { ColorPicker } from "@darthrapid/react-native-simple-color-picker";
24
+
25
+ export default function App() {
26
+ const [color, setColor] = useState("#007AFF");
27
+
28
+ return <ColorPicker value={color} onChange={setColor} />;
29
+ }
30
+ ```
31
+
32
+ ## Inline Mode
33
+
34
+ Renders the picker directly in your layout without a modal — adapts to parent width.
35
+
36
+ ```tsx
37
+ <ColorPicker value={color} onChange={setColor} inline />
38
+ ```
39
+
40
+ ## Tabs
41
+
42
+ The picker has 3 tabs — only selected ones are shown:
43
+
44
+ ```tsx
45
+ // All (default)
46
+ <ColorPicker tabs={["picker", "values", "recent"]} />
47
+
48
+ // Picker and values only
49
+ <ColorPicker tabs={["picker", "values"]} />
50
+
51
+ // Picker only — tab bar is hidden
52
+ <ColorPicker tabs={["picker"]} />
53
+ ```
54
+
55
+ | Tab | Content |
56
+ |---|---|
57
+ | `picker` | Saturation/brightness pad + hue slider |
58
+ | `values` | Hex input, RGB and HSB values |
59
+ | `recent` | Saved colors grid with "Clear All" |
60
+
61
+ ## i18n / Custom Labels
62
+
63
+ ```tsx
64
+ <ColorPicker
65
+ labels={{
66
+ picker: "Výber",
67
+ values: "Hodnoty",
68
+ recent: "Uložené",
69
+ save: "Uložiť",
70
+ savedColors: "Uložené farby",
71
+ clearAll: "Vymazať všetko",
72
+ noSavedColors: "Žiadne uložené farby",
73
+ noSavedColorsHint: "Klikni \"Uložiť\" pre pridanie farieb",
74
+ }}
75
+ />
76
+ ```
77
+
78
+ Only pass the labels you want to override — the rest stays English by default.
79
+
80
+ ## Light / Dark Theme
81
+
82
+ ```tsx
83
+ <ColorPicker theme="dark" /> // default
84
+ <ColorPicker theme="light" />
85
+ ```
86
+
87
+ ## Props
88
+
89
+ | Prop | Type | Default | Description |
90
+ |---|---|---|---|
91
+ | `value` | `string` | `"#007AFF"` | Current color (hex) |
92
+ | `onChange` | `(hex: string) => void` | – | Called when color changes |
93
+ | `tabs` | `TabId[]` | `["picker", "values", "recent"]` | Which tabs to show |
94
+ | `maxRecentColors` | `number` | `16` | Max number of saved colors |
95
+ | `panelWidth` | `number \| string` | `"100%"` | Panel width in modal mode. Ignored when `inline` |
96
+ | `hueStripHeight` | `number` | `28` | Hue slider height |
97
+ | `theme` | `"light" \| "dark"` | `"dark"` | Color theme |
98
+ | `disabled` | `boolean` | `false` | Disables touch input |
99
+ | `style` | `ViewStyle` | – | Style for the picker panel |
100
+ | `swatchSize` | `number` | `48` | Swatch trigger size |
101
+ | `swatchBorderRadius` | `number` | `12` | Swatch border radius |
102
+ | `swatchStyle` | `ViewStyle` | – | Style for the swatch trigger |
103
+ | `inline` | `boolean` | `false` | Renders picker inline without modal |
104
+ | `labels` | `ColorPickerLabels` | – | Custom labels (i18n) |
105
+ | `modalStyle` | `ViewStyle` | – | Style for the modal overlay wrapper |
106
+
107
+ ## Ref API
108
+
109
+ ```tsx
110
+ import { useRef } from "react";
111
+ import { ColorPicker, type ColorPickerRef } from "@darthrapid/react-native-simple-color-picker";
112
+
113
+ const ref = useRef<ColorPickerRef>(null);
114
+
115
+ <ColorPicker ref={ref} value={color} onChange={setColor} />
116
+ ```
117
+
118
+ | Method | Description |
119
+ |---|---|
120
+ | `getColor()` | Returns current color as hex string |
121
+ | `setColor(hex)` | Sets color programmatically |
122
+ | `clearRecent()` | Clears saved colors |
123
+ | `open()` | Opens the modal (no-op when `inline`) |
124
+ | `close()` | Closes the modal (no-op when `inline`) |
125
+
126
+ ## Examples
127
+
128
+ ### Custom swatch size
129
+
130
+ ```tsx
131
+ <ColorPicker
132
+ value={color}
133
+ onChange={setColor}
134
+ swatchSize={40}
135
+ swatchBorderRadius={8}
136
+ />
137
+ ```
138
+
139
+ ### Full width modal
140
+
141
+ ```tsx
142
+ <ColorPicker value={color} onChange={setColor} panelWidth="100%" />
143
+ ```
144
+
145
+ ### Fixed width modal
146
+
147
+ ```tsx
148
+ <ColorPicker value={color} onChange={setColor} panelWidth={350} />
149
+ ```
150
+
151
+ ### Programmatic control
152
+
153
+ ```tsx
154
+ ref.current?.setColor("#FF3B30");
155
+ ref.current?.open();
156
+ ```
157
+
158
+ ## License
159
+
160
+ MIT
@@ -0,0 +1,214 @@
1
+ "use strict";
2
+
3
+ import React, { useCallback, useImperativeHandle, useRef, useState } from "react";
4
+ import { Modal, Pressable } from "react-native";
5
+ import { PickerPanel } from "./picker-panel.js";
6
+ import { DEFAULT_LABELS, themes } from "../shared/const.js";
7
+ import { getContrastColor, hexToHsb, hsbToHex, isValidHex } from "../utils/colors.js";
8
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
9
+ export const ColorPicker = /*#__PURE__*/React.forwardRef(({
10
+ value = "#007AFF",
11
+ onChange,
12
+ tabs = ["picker", "values", "recent"],
13
+ maxRecentColors = 16,
14
+ panelWidth = "100%",
15
+ hueStripHeight = 28,
16
+ theme: themeName = "dark",
17
+ disabled = false,
18
+ style,
19
+ swatchSize = 48,
20
+ swatchBorderRadius = 12,
21
+ swatchStyle,
22
+ inline = false,
23
+ labels: userLabels,
24
+ modalStyle
25
+ }, ref) => {
26
+ const t = themes[themeName];
27
+ const labels = {
28
+ ...DEFAULT_LABELS,
29
+ ...userLabels
30
+ };
31
+ const initial = hexToHsb(value);
32
+ const [hue, setHue] = useState(initial.h);
33
+ const [sat, setSat] = useState(initial.s);
34
+ const [bright, setBright] = useState(initial.b);
35
+ const [hexInput, setHexInput] = useState(value.toUpperCase());
36
+ const [recentColors, setRecentColors] = useState([]);
37
+ const [modalVisible, setModalVisible] = useState(false);
38
+ const currentHex = hsbToHex(hue, sat, bright);
39
+ const contrastColor = getContrastColor(currentHex);
40
+
41
+ // Refs for stable handler closures
42
+ const hueRef = useRef(hue);
43
+ const satRef = useRef(sat);
44
+ const brightRef = useRef(bright);
45
+ hueRef.current = hue;
46
+ satRef.current = sat;
47
+ brightRef.current = bright;
48
+
49
+ // Sync hex input display — only update when NOT focused
50
+ const hexInputFocusedRef = useRef(false);
51
+ const currentHexRef = useRef(currentHex);
52
+ currentHexRef.current = currentHex;
53
+ if (!hexInputFocusedRef.current && hexInput !== currentHex.toUpperCase()) {
54
+ setHexInput(currentHex.toUpperCase());
55
+ }
56
+
57
+ // Sync from external value prop — only when parent actually changes value
58
+ const lastExternalValue = useRef(value);
59
+ if (value !== lastExternalValue.current) {
60
+ lastExternalValue.current = value;
61
+ if (isValidHex(value)) {
62
+ const hsb = hexToHsb(value);
63
+ // Only update if actually different to avoid loops
64
+ if (hsb.h !== hue || hsb.s !== sat || hsb.b !== bright) {
65
+ setHue(hsb.h);
66
+ setSat(hsb.s);
67
+ setBright(hsb.b);
68
+ }
69
+ }
70
+ }
71
+ const notifyChange = useCallback((h, s, b) => {
72
+ const hex = hsbToHex(h, s, b);
73
+ lastExternalValue.current = hex; // prevent sync-back
74
+ onChange?.(hex);
75
+ }, [onChange]);
76
+ const addToRecent = useCallback(hex => {
77
+ setRecentColors(prev => {
78
+ const filtered = prev.filter(c => c !== hex);
79
+ return [hex, ...filtered].slice(0, maxRecentColors);
80
+ });
81
+ }, [maxRecentColors]);
82
+ const handleHueChange = useCallback(h => {
83
+ setHue(h);
84
+ notifyChange(h, satRef.current, brightRef.current);
85
+ }, [notifyChange]);
86
+ const handleSatBrightChange = useCallback(({
87
+ s,
88
+ b
89
+ }) => {
90
+ setSat(s);
91
+ setBright(b);
92
+ notifyChange(hueRef.current, s, b);
93
+ }, [notifyChange]);
94
+ const handleHexSubmit = useCallback(() => {
95
+ const clean = hexInput.startsWith("#") ? hexInput : `#${hexInput}`;
96
+ if (isValidHex(clean)) {
97
+ const hsb = hexToHsb(clean);
98
+ setHue(hsb.h);
99
+ setSat(hsb.s);
100
+ setBright(hsb.b);
101
+ notifyChange(hsb.h, hsb.s, hsb.b);
102
+ addToRecent(clean);
103
+ } else {
104
+ setHexInput(currentHex.toUpperCase());
105
+ }
106
+ }, [hexInput, currentHex, notifyChange, addToRecent]);
107
+ const handleRecentSelect = useCallback(hex => {
108
+ const hsb = hexToHsb(hex);
109
+ setHue(hsb.h);
110
+ setSat(hsb.s);
111
+ setBright(hsb.b);
112
+ notifyChange(hsb.h, hsb.s, hsb.b);
113
+ }, [notifyChange]);
114
+ useImperativeHandle(ref, () => ({
115
+ getColor: () => currentHex,
116
+ setColor: hex => {
117
+ if (!isValidHex(hex)) return;
118
+ const hsb = hexToHsb(hex);
119
+ setHue(hsb.h);
120
+ setSat(hsb.s);
121
+ setBright(hsb.b);
122
+ lastExternalValue.current = hex;
123
+ notifyChange(hsb.h, hsb.s, hsb.b);
124
+ },
125
+ clearRecent: () => setRecentColors([]),
126
+ open: () => setModalVisible(true),
127
+ close: () => setModalVisible(false)
128
+ }), [currentHex, notifyChange]);
129
+ const panelProps = {
130
+ hue,
131
+ sat,
132
+ bright,
133
+ currentHex,
134
+ contrastColor,
135
+ hexInput,
136
+ recentColors,
137
+ tabs,
138
+ hueStripHeight,
139
+ disabled,
140
+ t,
141
+ labels,
142
+ onHueChange: handleHueChange,
143
+ onSatBrightChange: handleSatBrightChange,
144
+ onHexInputChange: setHexInput,
145
+ onHexSubmit: handleHexSubmit,
146
+ onHexInputFocus: () => {
147
+ hexInputFocusedRef.current = true;
148
+ },
149
+ onHexInputBlur: () => {
150
+ hexInputFocusedRef.current = false;
151
+ },
152
+ onSaveRecent: () => addToRecent(currentHex),
153
+ onRecentSelect: handleRecentSelect,
154
+ onClearRecent: () => setRecentColors([])
155
+ };
156
+ if (inline) {
157
+ return /*#__PURE__*/_jsx(PickerPanel, {
158
+ ...panelProps,
159
+ style: style
160
+ });
161
+ }
162
+ return /*#__PURE__*/_jsxs(_Fragment, {
163
+ children: [/*#__PURE__*/_jsx(Pressable, {
164
+ onPress: () => setModalVisible(true),
165
+ disabled: disabled,
166
+ style: [{
167
+ width: swatchSize,
168
+ height: swatchSize,
169
+ borderRadius: swatchBorderRadius,
170
+ backgroundColor: currentHex,
171
+ borderWidth: 2,
172
+ borderColor: t.border,
173
+ shadowColor: "#000",
174
+ shadowOffset: {
175
+ width: 0,
176
+ height: 2
177
+ },
178
+ shadowOpacity: 0.15,
179
+ shadowRadius: 4,
180
+ elevation: 3
181
+ }, swatchStyle]
182
+ }), /*#__PURE__*/_jsx(Modal, {
183
+ visible: modalVisible,
184
+ transparent: true,
185
+ animationType: "fade",
186
+ onRequestClose: () => setModalVisible(false),
187
+ children: /*#__PURE__*/_jsx(Pressable, {
188
+ onPress: () => setModalVisible(false),
189
+ style: [{
190
+ flex: 1,
191
+ backgroundColor: t.overlay,
192
+ justifyContent: "center",
193
+ alignItems: "center",
194
+ padding: 20
195
+ }, modalStyle],
196
+ children: /*#__PURE__*/_jsx(Pressable, {
197
+ onPress: () => {},
198
+ style: {
199
+ width: "100%",
200
+ alignItems: "center"
201
+ },
202
+ children: /*#__PURE__*/_jsx(PickerPanel, {
203
+ ...panelProps,
204
+ style: [{
205
+ width: panelWidth
206
+ }, style]
207
+ })
208
+ })
209
+ })
210
+ })]
211
+ });
212
+ });
213
+ ColorPicker.displayName = "ColorPicker";
214
+ //# sourceMappingURL=color-picker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","useImperativeHandle","useRef","useState","Modal","Pressable","PickerPanel","DEFAULT_LABELS","themes","getContrastColor","hexToHsb","hsbToHex","isValidHex","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ColorPicker","forwardRef","value","onChange","tabs","maxRecentColors","panelWidth","hueStripHeight","theme","themeName","disabled","style","swatchSize","swatchBorderRadius","swatchStyle","inline","labels","userLabels","modalStyle","ref","t","initial","hue","setHue","h","sat","setSat","s","bright","setBright","b","hexInput","setHexInput","toUpperCase","recentColors","setRecentColors","modalVisible","setModalVisible","currentHex","contrastColor","hueRef","satRef","brightRef","current","hexInputFocusedRef","currentHexRef","lastExternalValue","hsb","notifyChange","hex","addToRecent","prev","filtered","filter","c","slice","handleHueChange","handleSatBrightChange","handleHexSubmit","clean","startsWith","handleRecentSelect","getColor","setColor","clearRecent","open","close","panelProps","onHueChange","onSatBrightChange","onHexInputChange","onHexSubmit","onHexInputFocus","onHexInputBlur","onSaveRecent","onRecentSelect","onClearRecent","children","onPress","width","height","borderRadius","backgroundColor","borderWidth","borderColor","border","shadowColor","shadowOffset","shadowOpacity","shadowRadius","elevation","visible","transparent","animationType","onRequestClose","flex","overlay","justifyContent","alignItems","padding","displayName"],"sourceRoot":"../../../src","sources":["components/color-picker.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IACVC,WAAW,EACXC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,SACEC,KAAK,EACLC,SAAS,QAIJ,cAAc;AACrB,SAASC,WAAW,QAAQ,mBAAgB;AAE5C,SAASC,cAAc,EAAEC,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,eAEFlF,IAAA,CAACT,SAAS;UACR4F,OAAO,EAAEA,CAAA,KAAM,CAAC,CAAE;UAClBnE,KAAK,EAAE;YAAEoE,KAAK,EAAE,MAAM;YAAEmB,UAAU,EAAE;UAAS,CAAE;UAAArB,QAAA,eAE/ClF,IAAA,CAACR,WAAW;YAAA,GACNgF,UAAU;YACdxD,KAAK,EAAE,CAAC;cAAEoE,KAAK,EAAEzE;YAAW,CAAC,EAAEK,KAAK;UAAE,CACvC;QAAC,CACO;MAAC,CACH;IAAC,CACP,CAAC;EAAA,CACR,CAAC;AAEP,CACF,CAAC;AAEDX,WAAW,CAACoG,WAAW,GAAG,aAAa","ignoreList":[]}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+
3
+ import React, { useCallback, useRef, useState } from "react";
4
+ import { PanResponder, View } from "react-native";
5
+ import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
6
+ import { hsbToHex } from "../utils/colors.js";
7
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
8
+ export function HueStrip({
9
+ hue,
10
+ height,
11
+ disabled,
12
+ thumbBorder,
13
+ onChange
14
+ }) {
15
+ const containerRef = useRef(null);
16
+ const originXRef = useRef(0);
17
+ const widthRef = useRef(0);
18
+ const disabledRef = useRef(disabled);
19
+ const onChangeRef = useRef(onChange);
20
+ disabledRef.current = disabled;
21
+ onChangeRef.current = onChange;
22
+ const [layoutWidth, setLayoutWidth] = useState(0);
23
+ const calcHue = useCallback(pageX => {
24
+ const w = widthRef.current;
25
+ if (w === 0) return 0;
26
+ const x = Math.max(0, Math.min(pageX - originXRef.current, w));
27
+ return Math.round(x / w * 360);
28
+ }, []);
29
+ const panResponder = useRef(PanResponder.create({
30
+ onStartShouldSetPanResponder: () => !disabledRef.current,
31
+ onStartShouldSetPanResponderCapture: () => !disabledRef.current,
32
+ onMoveShouldSetPanResponder: () => !disabledRef.current,
33
+ onMoveShouldSetPanResponderCapture: () => !disabledRef.current,
34
+ onPanResponderTerminationRequest: () => false,
35
+ onPanResponderGrant: evt => {
36
+ const {
37
+ pageX
38
+ } = evt.nativeEvent;
39
+ containerRef.current?.measure((_x, _y, w, _h, ox) => {
40
+ originXRef.current = ox;
41
+ widthRef.current = w;
42
+ onChangeRef.current(calcHue(pageX));
43
+ });
44
+ },
45
+ onPanResponderMove: evt => {
46
+ onChangeRef.current(calcHue(evt.nativeEvent.pageX));
47
+ }
48
+ })).current;
49
+ const hueColors = ["#FF0000", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FF0000"];
50
+ const thumbLeft = layoutWidth > 0 ? hue / 360 * layoutWidth : 0;
51
+ const thumbSize = height + 6;
52
+ return /*#__PURE__*/_jsx(View, {
53
+ ref: containerRef,
54
+ onLayout: e => {
55
+ const w = e.nativeEvent.layout.width;
56
+ setLayoutWidth(w);
57
+ widthRef.current = w;
58
+ },
59
+ style: {
60
+ width: "100%",
61
+ height,
62
+ overflow: "visible"
63
+ },
64
+ ...panResponder.panHandlers,
65
+ children: layoutWidth > 0 && /*#__PURE__*/_jsxs(_Fragment, {
66
+ children: [/*#__PURE__*/_jsxs(Svg, {
67
+ width: layoutWidth,
68
+ height: height,
69
+ children: [/*#__PURE__*/_jsx(Defs, {
70
+ children: /*#__PURE__*/_jsx(LinearGradient, {
71
+ id: "hueGrad",
72
+ x1: "0",
73
+ y1: "0",
74
+ x2: "1",
75
+ y2: "0",
76
+ children: hueColors.map((color, i) => /*#__PURE__*/_jsx(Stop, {
77
+ offset: `${i / (hueColors.length - 1) * 100}%`,
78
+ stopColor: color
79
+ }, i))
80
+ })
81
+ }), /*#__PURE__*/_jsx(Rect, {
82
+ x: "0",
83
+ y: "0",
84
+ width: layoutWidth,
85
+ height: height,
86
+ rx: height / 2,
87
+ fill: "url(#hueGrad)"
88
+ })]
89
+ }), /*#__PURE__*/_jsx(View, {
90
+ style: {
91
+ position: "absolute",
92
+ left: thumbLeft - thumbSize / 2,
93
+ top: -3,
94
+ width: thumbSize,
95
+ height: thumbSize,
96
+ borderRadius: thumbSize / 2,
97
+ borderWidth: 3,
98
+ borderColor: thumbBorder,
99
+ backgroundColor: hsbToHex(hue, 100, 100),
100
+ shadowColor: "#000",
101
+ shadowOffset: {
102
+ width: 0,
103
+ height: 2
104
+ },
105
+ shadowOpacity: 0.3,
106
+ shadowRadius: 4,
107
+ elevation: 5
108
+ }
109
+ })]
110
+ })
111
+ });
112
+ }
113
+ //# sourceMappingURL=hue-strip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","useRef","useState","PanResponder","View","Svg","Defs","LinearGradient","Rect","Stop","hsbToHex","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","HueStrip","hue","height","disabled","thumbBorder","onChange","containerRef","originXRef","widthRef","disabledRef","onChangeRef","current","layoutWidth","setLayoutWidth","calcHue","pageX","w","x","Math","max","min","round","panResponder","create","onStartShouldSetPanResponder","onStartShouldSetPanResponderCapture","onMoveShouldSetPanResponder","onMoveShouldSetPanResponderCapture","onPanResponderTerminationRequest","onPanResponderGrant","evt","nativeEvent","measure","_x","_y","_h","ox","onPanResponderMove","hueColors","thumbLeft","thumbSize","ref","onLayout","e","layout","width","style","overflow","panHandlers","children","id","x1","y1","x2","y2","map","color","i","offset","length","stopColor","y","rx","fill","position","left","top","borderRadius","borderWidth","borderColor","backgroundColor","shadowColor","shadowOffset","shadowOpacity","shadowRadius","elevation"],"sourceRoot":"../../../src","sources":["components/hue-strip.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IACVC,WAAW,EACXC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,SACEC,YAAY,EACZC,IAAI,QACC,cAAc;AACrB,OAAOC,GAAG,IAAIC,IAAI,EAAEC,cAAc,EAAEC,IAAI,EAAEC,IAAI,QAAQ,kBAAkB;AACxE,SAASC,QAAQ,QAAQ,oBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAA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AAE,GAAG,EAAE,GAAG,CAAC;UACxCsE,WAAW,EAAE,MAAM;UACnBC,YAAY,EAAE;YAAE3B,KAAK,EAAE,CAAC;YAAE3C,MAAM,EAAE;UAAE,CAAC;UACrCuE,aAAa,EAAE,GAAG;UAClBC,YAAY,EAAE,CAAC;UACfC,SAAS,EAAE;QACb;MAAE,CACH,CAAC;IAAA,CACF;EACH,CACG,CAAC;AAEX","ignoreList":[]}
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+
3
+ import { useState } from "react";
4
+ import { Pressable, Text, View } from "react-native";
5
+ import { PickerTab } from "./picker-tab.js";
6
+ import { RecentTab } from "./recent-tab.js";
7
+ import { TabBar } from "./tab-bar.js";
8
+ import { ValuesTab } from "./values-tab.js";
9
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
+ export function PickerPanel({
11
+ hue,
12
+ sat,
13
+ bright,
14
+ currentHex,
15
+ contrastColor,
16
+ hexInput,
17
+ recentColors,
18
+ tabs,
19
+ hueStripHeight,
20
+ disabled,
21
+ t,
22
+ onHueChange,
23
+ onSatBrightChange,
24
+ onHexInputChange,
25
+ onHexSubmit,
26
+ onHexInputFocus,
27
+ onHexInputBlur,
28
+ onSaveRecent,
29
+ onRecentSelect,
30
+ onClearRecent,
31
+ labels,
32
+ style
33
+ }) {
34
+ const [activeTab, setActiveTab] = useState(tabs[0]);
35
+ return /*#__PURE__*/_jsxs(View, {
36
+ style: [{
37
+ backgroundColor: t.background,
38
+ borderRadius: 20,
39
+ overflow: "hidden"
40
+ }, style],
41
+ children: [/*#__PURE__*/_jsx(View, {
42
+ style: {
43
+ height: 64,
44
+ backgroundColor: currentHex,
45
+ justifyContent: "flex-end",
46
+ paddingHorizontal: 16,
47
+ paddingBottom: 12
48
+ },
49
+ children: /*#__PURE__*/_jsxs(View, {
50
+ style: {
51
+ flexDirection: "row",
52
+ alignItems: "center",
53
+ justifyContent: "space-between"
54
+ },
55
+ children: [/*#__PURE__*/_jsx(Text, {
56
+ style: {
57
+ fontSize: 18,
58
+ fontWeight: "700",
59
+ color: contrastColor,
60
+ fontVariant: ["tabular-nums"],
61
+ letterSpacing: 0.5
62
+ },
63
+ children: currentHex.toUpperCase()
64
+ }), /*#__PURE__*/_jsx(Pressable, {
65
+ onPress: onSaveRecent,
66
+ style: ({
67
+ pressed
68
+ }) => ({
69
+ backgroundColor: pressed ? contrastColor === "#FFFFFF" ? "rgba(255,255,255,0.5)" : "rgba(0,0,0,0.3)" : contrastColor === "#FFFFFF" ? "rgba(255,255,255,0.2)" : "rgba(0,0,0,0.1)",
70
+ paddingHorizontal: 12,
71
+ paddingVertical: 5,
72
+ borderRadius: 8
73
+ }),
74
+ children: /*#__PURE__*/_jsx(Text, {
75
+ style: {
76
+ color: contrastColor,
77
+ fontSize: 12,
78
+ fontWeight: "600"
79
+ },
80
+ children: labels.save
81
+ })
82
+ })]
83
+ })
84
+ }), tabs.length > 1 && /*#__PURE__*/_jsx(TabBar, {
85
+ tabs: tabs,
86
+ active: activeTab,
87
+ onSelect: setActiveTab,
88
+ t: t,
89
+ labels: labels
90
+ }), activeTab === "picker" && /*#__PURE__*/_jsx(PickerTab, {
91
+ hue: hue,
92
+ sat: sat,
93
+ bright: bright,
94
+ hueStripHeight: hueStripHeight,
95
+ disabled: disabled,
96
+ t: t,
97
+ onHueChange: onHueChange,
98
+ onSatBrightChange: onSatBrightChange
99
+ }), activeTab === "values" && /*#__PURE__*/_jsx(ValuesTab, {
100
+ hue: hue,
101
+ sat: sat,
102
+ bright: bright,
103
+ currentHex: currentHex,
104
+ hexInput: hexInput,
105
+ disabled: disabled,
106
+ t: t,
107
+ onHexInputChange: onHexInputChange,
108
+ onHexSubmit: onHexSubmit,
109
+ onHexInputFocus: onHexInputFocus,
110
+ onHexInputBlur: onHexInputBlur
111
+ }), activeTab === "recent" && /*#__PURE__*/_jsx(RecentTab, {
112
+ recentColors: recentColors,
113
+ disabled: disabled,
114
+ t: t,
115
+ labels: labels,
116
+ onSelect: onRecentSelect,
117
+ onClear: onClearRecent
118
+ })]
119
+ });
120
+ }
121
+ //# sourceMappingURL=picker-panel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useState","Pressable","Text","View","PickerTab","RecentTab","TabBar","ValuesTab","jsx","_jsx","jsxs","_jsxs","PickerPanel","hue","sat","bright","currentHex","contrastColor","hexInput","recentColors","tabs","hueStripHeight","disabled","t","onHueChange","onSatBrightChange","onHexInputChange","onHexSubmit","onHexInputFocus","onHexInputBlur","onSaveRecent","onRecentSelect","onClearRecent","labels","style","activeTab","setActiveTab","backgroundColor","background","borderRadius","overflow","children","height","justifyContent","paddingHorizontal","paddingBottom","flexDirection","alignItems","fontSize","fontWeight","color","fontVariant","letterSpacing","toUpperCase","onPress","pressed","paddingVertical","save","length","active","onSelect","onClear"],"sourceRoot":"../../../src","sources":["components/picker-panel.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,OAAO;AAChC,SACEC,SAAS,EACTC,IAAI,EACJC,IAAI,QAGC,cAAc;AAErB,SAASC,SAAS,QAAQ,iBAAc;AACxC,SAASC,SAAS,QAAQ,iBAAc;AACxC,SAASC,MAAM,QAAQ,cAAW;AAClC,SAASC,SAAS,QAAQ,iBAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AA2BzC,OAAO,SAASC,WAAWA,CAAC;EAC1BC,GAAG;EACHC,GAAG;EACHC,MAAM;EACNC,UAAU;EACVC,aAAa;EACbC,QAAQ;EACRC,YAAY;EACZC,IAAI;EACJC,cAAc;EACdC,QAAQ;EACRC,CAAC;EACDC,WAAW;EACXC,iBAAiB;EACjBC,gBAAgB;EAChBC,WAAW;EACXC,eAAe;EACfC,cAAc;EACdC,YAAY;EACZC,cAAc;EACdC,aAAa;EACbC,MAAM;EACNC;AACgB,CAAC,EAAE;EACnB,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGpC,QAAQ,CAAQoB,IAAI,CAAC,CAAC,CAAE,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