@impulse-ui-native/color-picker 9.1.1 → 10.0.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/dist/components/alpha-input.d.mts +1 -2
- package/dist/components/alpha-slider.d.mts +1 -2
- package/dist/components/apply.d.mts +1 -2
- package/dist/components/cancel.d.mts +1 -2
- package/dist/components/channel-input.d.mts +1 -2
- package/dist/components/color-picker.d.mts +1 -2
- package/dist/components/color-picker.js +2 -1
- package/dist/components/color-picker.js.map +1 -1
- package/dist/components/gradient.d.mts +1 -2
- package/dist/components/gradient.js +16 -11
- package/dist/components/gradient.js.map +1 -1
- package/dist/components/hex-input.d.mts +1 -2
- package/dist/components/hex-input.js +2 -1
- package/dist/components/hex-input.js.map +1 -1
- package/dist/components/hue-slider.d.mts +1 -2
- package/dist/components/index.d.mts +12 -13
- package/dist/components/motion-gradient.d.mts +1 -2
- package/dist/components/motion-gradient.js +2 -1
- package/dist/components/motion-gradient.js.map +1 -1
- package/dist/components/motion-surface.d.mts +1 -2
- package/dist/components/preset.d.mts +1 -2
- package/dist/components/preview.d.mts +1 -2
- package/dist/components/root.d.mts +1 -2
- package/dist/components/spectrum.d.mts +1 -2
- package/dist/components/swatch.d.mts +1 -2
- package/dist/constants/motion.constants.d.mts +1 -1
- package/dist/hooks/use-spectrum-interaction.hook.d.mts +28 -2
- package/dist/index.d.mts +0 -1
- package/package.json +16 -16
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
import { ColorPickerAlphaInputProps } from '../types/color-picker.types.mjs';
|
|
4
3
|
import '@impulse-ui-native/primitives';
|
|
5
4
|
import '@impulse-ui-native/theme';
|
|
6
5
|
import '../types/color.types.mjs';
|
|
7
6
|
|
|
8
|
-
declare const ColorPickerAlphaInput: react.MemoExoticComponent<({ label, }: ColorPickerAlphaInputProps) =>
|
|
7
|
+
declare const ColorPickerAlphaInput: react.MemoExoticComponent<({ label, }: ColorPickerAlphaInputProps) => react.JSX.Element>;
|
|
9
8
|
|
|
10
9
|
export { ColorPickerAlphaInput };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
|
|
4
|
-
declare const ColorPickerAlphaSlider: react.MemoExoticComponent<() =>
|
|
3
|
+
declare const ColorPickerAlphaSlider: react.MemoExoticComponent<() => react.JSX.Element>;
|
|
5
4
|
|
|
6
5
|
export { ColorPickerAlphaSlider };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
import { ColorPickerActionProps } from '../types/color-picker.types.mjs';
|
|
4
3
|
import '@impulse-ui-native/primitives';
|
|
5
4
|
import '@impulse-ui-native/theme';
|
|
6
5
|
import '../types/color.types.mjs';
|
|
7
6
|
|
|
8
|
-
declare const ColorPickerApply: react.MemoExoticComponent<({ disabled, loading, onPress, ...props }: ColorPickerActionProps) =>
|
|
7
|
+
declare const ColorPickerApply: react.MemoExoticComponent<({ disabled, loading, onPress, ...props }: ColorPickerActionProps) => react.JSX.Element>;
|
|
9
8
|
|
|
10
9
|
export { ColorPickerApply };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
import { ColorPickerActionProps } from '../types/color-picker.types.mjs';
|
|
4
3
|
import '@impulse-ui-native/primitives';
|
|
5
4
|
import '@impulse-ui-native/theme';
|
|
6
5
|
import '../types/color.types.mjs';
|
|
7
6
|
|
|
8
|
-
declare const ColorPickerCancel: react.MemoExoticComponent<({ disabled, loading, onPress, ...props }: ColorPickerActionProps) =>
|
|
7
|
+
declare const ColorPickerCancel: react.MemoExoticComponent<({ disabled, loading, onPress, ...props }: ColorPickerActionProps) => react.JSX.Element>;
|
|
9
8
|
|
|
10
9
|
export { ColorPickerCancel };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
import { ColorPickerChannelInputProps } from '../types/color-picker.types.mjs';
|
|
4
3
|
import '@impulse-ui-native/primitives';
|
|
5
4
|
import '@impulse-ui-native/theme';
|
|
6
5
|
import '../types/color.types.mjs';
|
|
7
6
|
|
|
8
|
-
declare const ColorPickerChannelInput: react.MemoExoticComponent<({ channel, label, }: ColorPickerChannelInputProps) =>
|
|
7
|
+
declare const ColorPickerChannelInput: react.MemoExoticComponent<({ channel, label, }: ColorPickerChannelInputProps) => react.JSX.Element>;
|
|
9
8
|
|
|
10
9
|
export { ColorPickerChannelInput };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
import { ColorPickerProps } from '../types/color-picker.types.mjs';
|
|
4
3
|
import '@impulse-ui-native/primitives';
|
|
5
4
|
import '@impulse-ui-native/theme';
|
|
6
5
|
import '../types/color.types.mjs';
|
|
7
6
|
|
|
8
|
-
declare const ColorPickerComponent: react.MemoExoticComponent<({ showAlpha, showPresets, presets, presetsLabel, commitMode, ...props }: ColorPickerProps) =>
|
|
7
|
+
declare const ColorPickerComponent: react.MemoExoticComponent<({ showAlpha, showPresets, presets, presetsLabel, commitMode, ...props }: ColorPickerProps) => react.JSX.Element>;
|
|
9
8
|
|
|
10
9
|
export { ColorPickerComponent };
|
|
@@ -25,6 +25,7 @@ const ColorPickerComponent = memo(function ColorPicker({
|
|
|
25
25
|
const tokens = useComponentsTokens().colorPicker;
|
|
26
26
|
const styles = useThemedStyles(themedStyles);
|
|
27
27
|
const palette = presets ?? tokens.presets;
|
|
28
|
+
const hasPresets = showPresets && palette.length > 0;
|
|
28
29
|
return /* @__PURE__ */ jsxs(ColorPickerRoot, { ...props, commitMode, children: [
|
|
29
30
|
/* @__PURE__ */ jsx(Typography.Title4, { color: tokens.labelColor, children: "Choose color" }),
|
|
30
31
|
/* @__PURE__ */ jsx(ColorPickerSpectrum, {}),
|
|
@@ -46,7 +47,7 @@ const ColorPickerComponent = memo(function ColorPicker({
|
|
|
46
47
|
/* @__PURE__ */ jsx(View, { style: styles.field, children: /* @__PURE__ */ jsx(ColorPickerChannelInput, { channel: "g", label: "G" }) }),
|
|
47
48
|
/* @__PURE__ */ jsx(View, { style: styles.field, children: /* @__PURE__ */ jsx(ColorPickerChannelInput, { channel: "b", label: "B" }) })
|
|
48
49
|
] }),
|
|
49
|
-
|
|
50
|
+
hasPresets ? /* @__PURE__ */ jsxs(View, { gap: tokens.presetsLabelGap, children: [
|
|
50
51
|
/* @__PURE__ */ jsx(Typography.Label, { children: presetsLabel }),
|
|
51
52
|
/* @__PURE__ */ jsx(View, { style: styles.palette, children: palette.map((preset, index) => /* @__PURE__ */ jsx(
|
|
52
53
|
ColorPickerPresetEntry,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/color-picker.tsx"],"sourcesContent":["import { memo } from \"react\";\nimport { StyleSheet } from \"react-native\";\n\nimport type { AppTheme } from \"@impulse-ui-native/theme\";\nimport { Typography, View } from \"@impulse-ui-native/primitives\";\nimport { useComponentsTokens, useThemedStyles } from \"@impulse-ui-native/theme\";\n\nimport type { ColorPickerProps } from \"../types\";\nimport { ColorPickerAlphaInput } from \"./alpha-input\";\nimport { ColorPickerAlphaSlider } from \"./alpha-slider\";\nimport { ColorPickerApply } from \"./apply\";\nimport { ColorPickerCancel } from \"./cancel\";\nimport { ColorPickerChannelInput } from \"./channel-input\";\nimport { ColorPickerHexInput } from \"./hex-input\";\nimport { ColorPickerHueSlider } from \"./hue-slider\";\nimport { ColorPickerPresetEntry } from \"./preset\";\nimport { ColorPickerPreview } from \"./preview\";\nimport { ColorPickerRoot } from \"./root\";\nimport { ColorPickerSpectrum } from \"./spectrum\";\n\nexport const ColorPickerComponent = memo(function ColorPicker({\n showAlpha = true,\n showPresets = true,\n presets,\n presetsLabel = \"Theme colors\",\n commitMode = \"immediate\",\n ...props\n}: ColorPickerProps) {\n const tokens = useComponentsTokens().colorPicker;\n const styles = useThemedStyles(themedStyles);\n const palette = presets ?? tokens.presets;\n\n return (\n <ColorPickerRoot {...props} commitMode={commitMode}>\n <Typography.Title4 color={tokens.labelColor}>\n Choose color\n </Typography.Title4>\n <ColorPickerSpectrum />\n <View gap={tokens.sliderLabelGap}>\n <Typography.Caption>Hue</Typography.Caption>\n <ColorPickerHueSlider />\n </View>\n {showAlpha ? (\n <View gap={tokens.sliderLabelGap}>\n <Typography.Caption>Opacity</Typography.Caption>\n <ColorPickerAlphaSlider />\n </View>\n ) : null}\n <View style={styles.row}>\n <ColorPickerPreview />\n <View style={styles.field}>\n <ColorPickerHexInput label=\"HEX\" />\n </View>\n {showAlpha ? (\n <View style={styles.alphaField}>\n <ColorPickerAlphaInput label=\"Opacity (%)\" />\n </View>\n ) : null}\n </View>\n <View style={styles.row}>\n <View style={styles.field}>\n <ColorPickerChannelInput channel=\"r\" label=\"R\" />\n </View>\n <View style={styles.field}>\n <ColorPickerChannelInput channel=\"g\" label=\"G\" />\n </View>\n <View style={styles.field}>\n <ColorPickerChannelInput channel=\"b\" label=\"B\" />\n </View>\n </View>\n {
|
|
1
|
+
{"version":3,"sources":["../../src/components/color-picker.tsx"],"sourcesContent":["import { memo } from \"react\";\nimport { StyleSheet } from \"react-native\";\n\nimport type { AppTheme } from \"@impulse-ui-native/theme\";\nimport { Typography, View } from \"@impulse-ui-native/primitives\";\nimport { useComponentsTokens, useThemedStyles } from \"@impulse-ui-native/theme\";\n\nimport type { ColorPickerProps } from \"../types\";\nimport { ColorPickerAlphaInput } from \"./alpha-input\";\nimport { ColorPickerAlphaSlider } from \"./alpha-slider\";\nimport { ColorPickerApply } from \"./apply\";\nimport { ColorPickerCancel } from \"./cancel\";\nimport { ColorPickerChannelInput } from \"./channel-input\";\nimport { ColorPickerHexInput } from \"./hex-input\";\nimport { ColorPickerHueSlider } from \"./hue-slider\";\nimport { ColorPickerPresetEntry } from \"./preset\";\nimport { ColorPickerPreview } from \"./preview\";\nimport { ColorPickerRoot } from \"./root\";\nimport { ColorPickerSpectrum } from \"./spectrum\";\n\nexport const ColorPickerComponent = memo(function ColorPicker({\n showAlpha = true,\n showPresets = true,\n presets,\n presetsLabel = \"Theme colors\",\n commitMode = \"immediate\",\n ...props\n}: ColorPickerProps) {\n const tokens = useComponentsTokens().colorPicker;\n const styles = useThemedStyles(themedStyles);\n const palette = presets ?? tokens.presets;\n\n const hasPresets = showPresets && palette.length > 0;\n\n return (\n <ColorPickerRoot {...props} commitMode={commitMode}>\n <Typography.Title4 color={tokens.labelColor}>\n Choose color\n </Typography.Title4>\n <ColorPickerSpectrum />\n <View gap={tokens.sliderLabelGap}>\n <Typography.Caption>Hue</Typography.Caption>\n <ColorPickerHueSlider />\n </View>\n {showAlpha ? (\n <View gap={tokens.sliderLabelGap}>\n <Typography.Caption>Opacity</Typography.Caption>\n <ColorPickerAlphaSlider />\n </View>\n ) : null}\n <View style={styles.row}>\n <ColorPickerPreview />\n <View style={styles.field}>\n <ColorPickerHexInput label=\"HEX\" />\n </View>\n {showAlpha ? (\n <View style={styles.alphaField}>\n <ColorPickerAlphaInput label=\"Opacity (%)\" />\n </View>\n ) : null}\n </View>\n <View style={styles.row}>\n <View style={styles.field}>\n <ColorPickerChannelInput channel=\"r\" label=\"R\" />\n </View>\n <View style={styles.field}>\n <ColorPickerChannelInput channel=\"g\" label=\"G\" />\n </View>\n <View style={styles.field}>\n <ColorPickerChannelInput channel=\"b\" label=\"B\" />\n </View>\n </View>\n {hasPresets ? (\n <View gap={tokens.presetsLabelGap}>\n <Typography.Label>{presetsLabel}</Typography.Label>\n <View style={styles.palette}>\n {palette.map((preset, index) => (\n <ColorPickerPresetEntry\n key={preset.label + index}\n preset={preset}\n />\n ))}\n </View>\n </View>\n ) : null}\n {commitMode === \"confirm\" ? (\n <View style={styles.row}>\n <ColorPickerCancel style={styles.action}>Cancel</ColorPickerCancel>\n <ColorPickerApply style={styles.action}>Apply color</ColorPickerApply>\n </View>\n ) : null}\n </ColorPickerRoot>\n );\n});\n\nfunction themedStyles(theme: AppTheme) {\n const tokens = theme.components.colorPicker;\n\n return StyleSheet.create({\n row: { flexDirection: \"row\", alignItems: \"flex-end\", gap: tokens.rowGap },\n field: { flex: 1, minWidth: 0 },\n alphaField: { flex: tokens.alphaFieldFlex, minWidth: 0 },\n palette: { flexDirection: \"row\", flexWrap: \"wrap\", gap: tokens.presetsGap },\n action: { flex: 1 },\n });\n}\n"],"mappings":"AAoCM,cAIA,YAJA;AApCN,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAG3B,SAAS,YAAY,YAAY;AACjC,SAAS,qBAAqB,uBAAuB;AAGrD,SAAS,6BAA6B;AACtC,SAAS,8BAA8B;AACvC,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAClC,SAAS,+BAA+B;AACxC,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AACrC,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAChC,SAAS,2BAA2B;AAE7B,MAAM,uBAAuB,KAAK,SAAS,YAAY;AAAA,EAC5D,YAAY;AAAA,EACZ,cAAc;AAAA,EACd;AAAA,EACA,eAAe;AAAA,EACf,aAAa;AAAA,EACb,GAAG;AACL,GAAqB;AACnB,QAAM,SAAS,oBAAoB,EAAE;AACrC,QAAM,SAAS,gBAAgB,YAAY;AAC3C,QAAM,UAAU,WAAW,OAAO;AAElC,QAAM,aAAa,eAAe,QAAQ,SAAS;AAEnD,SACE,qBAAC,mBAAiB,GAAG,OAAO,YAC1B;AAAA,wBAAC,WAAW,QAAX,EAAkB,OAAO,OAAO,YAAY,0BAE7C;AAAA,IACA,oBAAC,uBAAoB;AAAA,IACrB,qBAAC,QAAK,KAAK,OAAO,g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AC;AAED,SAAS,aAAa,OAAiB;AACrC,QAAM,SAAS,MAAM,WAAW;AAEhC,SAAO,WAAW,OAAO;AAAA,IACvB,KAAK,EAAE,eAAe,OAAO,YAAY,YAAY,KAAK,OAAO,OAAO;AAAA,IACxE,OAAO,EAAE,MAAM,GAAG,UAAU,EAAE;AAAA,IAC9B,YAAY,EAAE,MAAM,OAAO,gBAAgB,UAAU,EAAE;AAAA,IACvD,SAAS,EAAE,eAAe,OAAO,UAAU,QAAQ,KAAK,OAAO,WAAW;AAAA,IAC1E,QAAQ,EAAE,MAAM,EAAE;AAAA,EACpB,CAAC;AACH;","names":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
import { ColorGradientProps } from '../types/color-gradient.types.mjs';
|
|
4
3
|
|
|
5
|
-
declare const ColorGradient: react.MemoExoticComponent<({ colors, checkerboard, vertical, }: ColorGradientProps) =>
|
|
4
|
+
declare const ColorGradient: react.MemoExoticComponent<({ colors, checkerboard, vertical, }: ColorGradientProps) => react.JSX.Element>;
|
|
6
5
|
|
|
7
6
|
export { ColorGradient };
|
|
@@ -26,6 +26,8 @@ const ColorGradient = memo(function ColorGradient2({
|
|
|
26
26
|
}),
|
|
27
27
|
[colors]
|
|
28
28
|
);
|
|
29
|
+
const checkerFill = "url(#" + id + "-checker)";
|
|
30
|
+
const gradientFill = "url(#" + id + ")";
|
|
29
31
|
return /* @__PURE__ */ jsxs(Svg, { width: "100%", height: "100%", children: [
|
|
30
32
|
/* @__PURE__ */ jsxs(Defs, { children: [
|
|
31
33
|
/* @__PURE__ */ jsx(
|
|
@@ -36,15 +38,18 @@ const ColorGradient = memo(function ColorGradient2({
|
|
|
36
38
|
y1: "0%",
|
|
37
39
|
x2: vertical ? "0%" : "100%",
|
|
38
40
|
y2: vertical ? "100%" : "0%",
|
|
39
|
-
children: stops.map((stop, index) =>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
children: stops.map((stop, index) => {
|
|
42
|
+
const offset = index / Math.max(1, stops.length - 1);
|
|
43
|
+
return /* @__PURE__ */ jsx(
|
|
44
|
+
Stop,
|
|
45
|
+
{
|
|
46
|
+
offset,
|
|
47
|
+
stopColor: stop.color,
|
|
48
|
+
stopOpacity: stop.opacity
|
|
49
|
+
},
|
|
50
|
+
index
|
|
51
|
+
);
|
|
52
|
+
})
|
|
48
53
|
}
|
|
49
54
|
),
|
|
50
55
|
checkerboard ? /* @__PURE__ */ jsxs(
|
|
@@ -85,8 +90,8 @@ const ColorGradient = memo(function ColorGradient2({
|
|
|
85
90
|
}
|
|
86
91
|
) : null
|
|
87
92
|
] }),
|
|
88
|
-
checkerboard ? /* @__PURE__ */ jsx(Rect, { width: "100%", height: "100%", fill:
|
|
89
|
-
/* @__PURE__ */ jsx(Rect, { width: "100%", height: "100%", fill:
|
|
93
|
+
checkerboard ? /* @__PURE__ */ jsx(Rect, { width: "100%", height: "100%", fill: checkerFill }) : null,
|
|
94
|
+
/* @__PURE__ */ jsx(Rect, { width: "100%", height: "100%", fill: gradientFill })
|
|
90
95
|
] });
|
|
91
96
|
});
|
|
92
97
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/gradient.tsx"],"sourcesContent":["import { memo, useId, useMemo } from \"react\";\nimport Svg, {\n Defs,\n LinearGradient,\n Pattern,\n Rect,\n Stop,\n} from \"react-native-svg\";\n\nimport { useComponentsTokens } from \"@impulse-ui-native/theme\";\n\nimport type { ColorGradientProps } from \"../types/color-gradient.types\";\nimport { parseHexColor, rgbaToHex } from \"../utils/color.utils\";\n\nexport const ColorGradient = memo(function ColorGradient({\n colors,\n checkerboard = false,\n vertical = false,\n}: ColorGradientProps) {\n const id = useId().replace(/:/g, \"\");\n const tokens = useComponentsTokens().colorPicker;\n const stops = useMemo(\n () =>\n colors.map((color) => {\n const rgba = parseHexColor(color);\n\n return {\n color: rgba ? rgbaToHex({ ...rgba, a: 1 }) : color,\n opacity: rgba?.a ?? 1,\n };\n }),\n [colors],\n );\n\n return (\n <Svg width=\"100%\" height=\"100%\">\n <Defs>\n <LinearGradient\n id={id}\n x1=\"0%\"\n y1=\"0%\"\n x2={vertical ? \"0%\" : \"100%\"}\n y2={vertical ? \"100%\" : \"0%\"}\n >\n {stops.map((stop, index) =>
|
|
1
|
+
{"version":3,"sources":["../../src/components/gradient.tsx"],"sourcesContent":["import { memo, useId, useMemo } from \"react\";\nimport Svg, {\n Defs,\n LinearGradient,\n Pattern,\n Rect,\n Stop,\n} from \"react-native-svg\";\n\nimport { useComponentsTokens } from \"@impulse-ui-native/theme\";\n\nimport type { ColorGradientProps } from \"../types/color-gradient.types\";\nimport { parseHexColor, rgbaToHex } from \"../utils/color.utils\";\n\nexport const ColorGradient = memo(function ColorGradient({\n colors,\n checkerboard = false,\n vertical = false,\n}: ColorGradientProps) {\n const id = useId().replace(/:/g, \"\");\n const tokens = useComponentsTokens().colorPicker;\n const stops = useMemo(\n () =>\n colors.map((color) => {\n const rgba = parseHexColor(color);\n\n return {\n color: rgba ? rgbaToHex({ ...rgba, a: 1 }) : color,\n opacity: rgba?.a ?? 1,\n };\n }),\n [colors],\n );\n\n const checkerFill = \"url(#\" + id + \"-checker)\";\n const gradientFill = \"url(#\" + id + \")\";\n\n return (\n <Svg width=\"100%\" height=\"100%\">\n <Defs>\n <LinearGradient\n id={id}\n x1=\"0%\"\n y1=\"0%\"\n x2={vertical ? \"0%\" : \"100%\"}\n y2={vertical ? \"100%\" : \"0%\"}\n >\n {stops.map((stop, index) => {\n const offset = index / Math.max(1, stops.length - 1);\n\n return (\n <Stop\n key={index}\n offset={offset}\n stopColor={stop.color}\n stopOpacity={stop.opacity}\n />\n );\n })}\n </LinearGradient>\n {checkerboard ? (\n <Pattern\n id={id + \"-checker\"}\n width={tokens.checkerSize * 2}\n height={tokens.checkerSize * 2}\n patternUnits=\"userSpaceOnUse\"\n >\n <Rect\n width={tokens.checkerSize * 2}\n height={tokens.checkerSize * 2}\n fill={tokens.checkerLightColor}\n />\n <Rect\n width={tokens.checkerSize}\n height={tokens.checkerSize}\n fill={tokens.checkerDarkColor}\n />\n <Rect\n x={tokens.checkerSize}\n y={tokens.checkerSize}\n width={tokens.checkerSize}\n height={tokens.checkerSize}\n fill={tokens.checkerDarkColor}\n />\n </Pattern>\n ) : null}\n </Defs>\n {checkerboard ? (\n <Rect width=\"100%\" height=\"100%\" fill={checkerFill} />\n ) : null}\n <Rect width=\"100%\" height=\"100%\" fill={gradientFill} />\n </Svg>\n );\n});\n"],"mappings":"AAmDc,cAUJ,YAVI;AAnDd,SAAS,MAAM,OAAO,eAAe;AACrC,OAAO;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,2BAA2B;AAGpC,SAAS,eAAe,iBAAiB;AAElC,MAAM,gBAAgB,KAAK,SAASA,eAAc;AAAA,EACvD;AAAA,EACA,eAAe;AAAA,EACf,WAAW;AACb,GAAuB;AACrB,QAAM,KAAK,MAAM,EAAE,QAAQ,MAAM,EAAE;AACnC,QAAM,SAAS,oBAAoB,EAAE;AACrC,QAAM,QAAQ;AAAA,IACZ,MACE,OAAO,IAAI,CAAC,UAAU;AACpB,YAAM,OAAO,cAAc,KAAK;AAEhC,aAAO;AAAA,QACL,OAAO,OAAO,UAAU,EAAE,GAAG,MAAM,GAAG,EAAE,CAAC,IAAI;AAAA,QAC7C,SAAS,MAAM,KAAK;AAAA,MACtB;AAAA,IACF,CAAC;AAAA,IACH,CAAC,MAAM;AAAA,EACT;AAEA,QAAM,cAAc,UAAU,KAAK;AACnC,QAAM,eAAe,UAAU,KAAK;AAEpC,SACE,qBAAC,OAAI,OAAM,QAAO,QAAO,QACvB;AAAA,yBAAC,QACC;AAAA;AAAA,QAAC;AAAA;AAAA,UACC;AAAA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|
3
2
|
import { ColorPickerHexInputProps } from '../types/color-input.types.mjs';
|
|
4
3
|
import '@impulse-ui-native/input';
|
|
5
4
|
|
|
6
|
-
declare const ColorPickerHexInput: react.MemoExoticComponent<({ disabled: disabledProp, onBlur, onSubmitEditing, error, ...props }: ColorPickerHexInputProps) =>
|
|
5
|
+
declare const ColorPickerHexInput: react.MemoExoticComponent<({ disabled: disabledProp, onBlur, onSubmitEditing, error, ...props }: ColorPickerHexInputProps) => react.JSX.Element>;
|
|
7
6
|
|
|
8
7
|
export { ColorPickerHexInput };
|
|
@@ -36,6 +36,7 @@ const ColorPickerHexInput = memo(function ColorPickerHexInput2({
|
|
|
36
36
|
input.onCommit();
|
|
37
37
|
onSubmitEditing?.(event);
|
|
38
38
|
});
|
|
39
|
+
const inputError = error ?? (input.invalid ? "Enter a valid hex color" : void 0);
|
|
39
40
|
return /* @__PURE__ */ jsx(
|
|
40
41
|
Input,
|
|
41
42
|
{
|
|
@@ -49,7 +50,7 @@ const ColorPickerHexInput = memo(function ColorPickerHexInput2({
|
|
|
49
50
|
onChangeText: input.onChangeText,
|
|
50
51
|
onBlur: handleBlur,
|
|
51
52
|
onSubmitEditing: handleSubmit,
|
|
52
|
-
error:
|
|
53
|
+
error: inputError
|
|
53
54
|
}
|
|
54
55
|
);
|
|
55
56
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/hex-input.tsx"],"sourcesContent":["import { memo } from \"react\";\n\nimport { useEventCallback } from \"@impulse-ui-native/core\";\nimport { Input } from \"@impulse-ui-native/input\";\n\nimport type { ColorPickerHexInputProps } from \"../types/color-input.types\";\nimport { useColorInput } from \"../hooks/use-color-input.hook\";\nimport { useColorPickerContext } from \"../hooks/use-color-picker-context.hook\";\nimport { parseHexColor, rgbaToHex } from \"../utils/color.utils\";\n\nexport const ColorPickerHexInput = memo(function ColorPickerHexInput({\n disabled: disabledProp,\n onBlur,\n onSubmitEditing,\n error,\n ...props\n}: ColorPickerHexInputProps) {\n const {\n value,\n disabled: rootDisabled,\n size,\n setColor,\n resetKey,\n } = useColorPickerContext();\n const disabled = rootDisabled || disabledProp === true;\n const commit = useEventCallback((text: string): string | undefined => {\n const parsed = parseHexColor(text);\n\n if (!parsed || !setColor(text)) {\n return undefined;\n }\n\n return rgbaToHex(parsed);\n });\n const input = useColorInput({ value, disabled, commit, resetKey });\n const handleBlur = useEventCallback<\n NonNullable<ColorPickerHexInputProps[\"onBlur\"]>\n >((event) => {\n input.onCommit();\n onBlur?.(event);\n });\n const handleSubmit = useEventCallback<\n NonNullable<ColorPickerHexInputProps[\"onSubmitEditing\"]>\n >((event) => {\n input.onCommit();\n onSubmitEditing?.(event);\n });\n\n return (\n <Input\n size={size}\n autoCapitalize=\"characters\"\n autoCorrect={false}\n maxLength={9}\n {...props}\n disabled={disabled}\n value={input.text}\n onChangeText={input.onChangeText}\n onBlur={handleBlur}\n onSubmitEditing={handleSubmit}\n error={
|
|
1
|
+
{"version":3,"sources":["../../src/components/hex-input.tsx"],"sourcesContent":["import { memo } from \"react\";\n\nimport { useEventCallback } from \"@impulse-ui-native/core\";\nimport { Input } from \"@impulse-ui-native/input\";\n\nimport type { ColorPickerHexInputProps } from \"../types/color-input.types\";\nimport { useColorInput } from \"../hooks/use-color-input.hook\";\nimport { useColorPickerContext } from \"../hooks/use-color-picker-context.hook\";\nimport { parseHexColor, rgbaToHex } from \"../utils/color.utils\";\n\nexport const ColorPickerHexInput = memo(function ColorPickerHexInput({\n disabled: disabledProp,\n onBlur,\n onSubmitEditing,\n error,\n ...props\n}: ColorPickerHexInputProps) {\n const {\n value,\n disabled: rootDisabled,\n size,\n setColor,\n resetKey,\n } = useColorPickerContext();\n const disabled = rootDisabled || disabledProp === true;\n const commit = useEventCallback((text: string): string | undefined => {\n const parsed = parseHexColor(text);\n\n if (!parsed || !setColor(text)) {\n return undefined;\n }\n\n return rgbaToHex(parsed);\n });\n const input = useColorInput({ value, disabled, commit, resetKey });\n const handleBlur = useEventCallback<\n NonNullable<ColorPickerHexInputProps[\"onBlur\"]>\n >((event) => {\n input.onCommit();\n onBlur?.(event);\n });\n const handleSubmit = useEventCallback<\n NonNullable<ColorPickerHexInputProps[\"onSubmitEditing\"]>\n >((event) => {\n input.onCommit();\n onSubmitEditing?.(event);\n });\n\n const inputError =\n error ?? (input.invalid ? \"Enter a valid hex color\" : undefined);\n\n return (\n <Input\n size={size}\n autoCapitalize=\"characters\"\n autoCorrect={false}\n maxLength={9}\n {...props}\n disabled={disabled}\n value={input.text}\n onChangeText={input.onChangeText}\n onBlur={handleBlur}\n onSubmitEditing={handleSubmit}\n error={inputError}\n />\n );\n});\n"],"mappings":"AAoDI;AApDJ,SAAS,YAAY;AAErB,SAAS,wBAAwB;AACjC,SAAS,aAAa;AAGtB,SAAS,qBAAqB;AAC9B,SAAS,6BAA6B;AACtC,SAAS,eAAe,iBAAiB;AAElC,MAAM,sBAAsB,KAAK,SAASA,qBAAoB;AAAA,EACnE,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAA6B;AAC3B,QAAM;AAAA,IACJ;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,sBAAsB;AAC1B,QAAM,WAAW,gBAAgB,iBAAiB;AAClD,QAAM,SAAS,iBAAiB,CAAC,SAAqC;AACpE,UAAM,SAAS,cAAc,IAAI;AAEjC,QAAI,CAAC,UAAU,CAAC,SAAS,IAAI,GAAG;AAC9B,aAAO;AAAA,IACT;AAEA,WAAO,UAAU,MAAM;AAAA,EACzB,CAAC;AACD,QAAM,QAAQ,cAAc,EAAE,OAAO,UAAU,QAAQ,SAAS,CAAC;AACjE,QAAM,aAAa,iBAEjB,CAAC,UAAU;AACX,UAAM,SAAS;AACf,aAAS,KAAK;AAAA,EAChB,CAAC;AACD,QAAM,eAAe,iBAEnB,CAAC,UAAU;AACX,UAAM,SAAS;AACf,sBAAkB,KAAK;AAAA,EACzB,CAAC;AAED,QAAM,aACJ,UAAU,MAAM,UAAU,4BAA4B;AAExD,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,gBAAe;AAAA,MACf,aAAa;AAAA,MACb,WAAW;AAAA,MACV,GAAG;AAAA,MACJ;AAAA,MACA,OAAO,MAAM;AAAA,MACb,cAAc,MAAM;AAAA,MACpB,QAAQ;AAAA,MACR,iBAAiB;AAAA,MACjB,OAAO;AAAA;AAAA,EACT;AAEJ,CAAC;","names":["ColorPickerHexInput"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
|
|
4
|
-
declare const ColorPickerHueSlider: react.MemoExoticComponent<() =>
|
|
3
|
+
declare const ColorPickerHueSlider: react.MemoExoticComponent<() => react.JSX.Element>;
|
|
5
4
|
|
|
6
5
|
export { ColorPickerHueSlider };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as _impulse_ui_native_primitives from '@impulse-ui-native/primitives';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
import * as react from 'react';
|
|
4
3
|
import { ColorPickerProps, ColorPickerRootProps, ColorPickerChannelInputProps, ColorPickerAlphaInputProps, ColorPickerSwatchProps, ColorPickerActionProps } from '../types/color-picker.types.mjs';
|
|
5
4
|
import { ColorPickerHexInputProps } from '../types/color-input.types.mjs';
|
|
@@ -8,19 +7,19 @@ import '@impulse-ui-native/theme';
|
|
|
8
7
|
import '@impulse-ui-native/input';
|
|
9
8
|
|
|
10
9
|
declare const ColorPicker: react.NamedExoticComponent<ColorPickerProps> & {
|
|
11
|
-
readonly type: ({ showAlpha, showPresets, presets, presetsLabel, commitMode, ...props }: ColorPickerProps) =>
|
|
10
|
+
readonly type: ({ showAlpha, showPresets, presets, presetsLabel, commitMode, ...props }: ColorPickerProps) => react.JSX.Element;
|
|
12
11
|
} & {
|
|
13
|
-
Root: react.MemoExoticComponent<({ children, style, value, defaultValue, onChange, disabled, size, commitMode, ...props }: ColorPickerRootProps) =>
|
|
14
|
-
Spectrum: react.MemoExoticComponent<() =>
|
|
15
|
-
HueSlider: react.MemoExoticComponent<() =>
|
|
16
|
-
AlphaSlider: react.MemoExoticComponent<() =>
|
|
17
|
-
Preview: react.MemoExoticComponent<({ style, children, ...props }: _impulse_ui_native_primitives.ViewProps) =>
|
|
18
|
-
HexInput: react.MemoExoticComponent<({ disabled: disabledProp, onBlur, onSubmitEditing, error, ...props }: ColorPickerHexInputProps) =>
|
|
19
|
-
ChannelInput: react.MemoExoticComponent<({ channel, label, }: ColorPickerChannelInputProps) =>
|
|
20
|
-
AlphaInput: react.MemoExoticComponent<({ label, }: ColorPickerAlphaInputProps) =>
|
|
21
|
-
Swatch: react.MemoExoticComponent<({ color, children, disabled: disabledProp, style, onPress, ...props }: ColorPickerSwatchProps) =>
|
|
22
|
-
Apply: react.MemoExoticComponent<({ disabled, loading, onPress, ...props }: ColorPickerActionProps) =>
|
|
23
|
-
Cancel: react.MemoExoticComponent<({ disabled, loading, onPress, ...props }: ColorPickerActionProps) =>
|
|
12
|
+
Root: react.MemoExoticComponent<({ children, style, value, defaultValue, onChange, disabled, size, commitMode, ...props }: ColorPickerRootProps) => react.JSX.Element>;
|
|
13
|
+
Spectrum: react.MemoExoticComponent<() => react.JSX.Element>;
|
|
14
|
+
HueSlider: react.MemoExoticComponent<() => react.JSX.Element>;
|
|
15
|
+
AlphaSlider: react.MemoExoticComponent<() => react.JSX.Element>;
|
|
16
|
+
Preview: react.MemoExoticComponent<({ style, children, ...props }: _impulse_ui_native_primitives.ViewProps) => react.JSX.Element>;
|
|
17
|
+
HexInput: react.MemoExoticComponent<({ disabled: disabledProp, onBlur, onSubmitEditing, error, ...props }: ColorPickerHexInputProps) => react.JSX.Element>;
|
|
18
|
+
ChannelInput: react.MemoExoticComponent<({ channel, label, }: ColorPickerChannelInputProps) => react.JSX.Element>;
|
|
19
|
+
AlphaInput: react.MemoExoticComponent<({ label, }: ColorPickerAlphaInputProps) => react.JSX.Element>;
|
|
20
|
+
Swatch: react.MemoExoticComponent<({ color, children, disabled: disabledProp, style, onPress, ...props }: ColorPickerSwatchProps) => react.JSX.Element>;
|
|
21
|
+
Apply: react.MemoExoticComponent<({ disabled, loading, onPress, ...props }: ColorPickerActionProps) => react.JSX.Element>;
|
|
22
|
+
Cancel: react.MemoExoticComponent<({ disabled, loading, onPress, ...props }: ColorPickerActionProps) => react.JSX.Element>;
|
|
24
23
|
};
|
|
25
24
|
|
|
26
25
|
export { ColorPicker };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
import { ColorMotionSurfaceProps } from '../types/color-motion.types.mjs';
|
|
4
3
|
import 'react-native-reanimated';
|
|
5
4
|
import '../types/color.types.mjs';
|
|
6
5
|
|
|
7
|
-
declare const ColorMotionGradient: react.MemoExoticComponent<({ rgba, }: ColorMotionSurfaceProps) =>
|
|
6
|
+
declare const ColorMotionGradient: react.MemoExoticComponent<({ rgba, }: ColorMotionSurfaceProps) => react.JSX.Element>;
|
|
8
7
|
|
|
9
8
|
export { ColorMotionGradient };
|
|
@@ -16,6 +16,7 @@ const ColorMotionGradient = memo(function ColorMotionGradient2({
|
|
|
16
16
|
const rectProps = useAnimatedProps(() => ({
|
|
17
17
|
color: rgbaToNativeColor(rgba.get(), true)
|
|
18
18
|
}));
|
|
19
|
+
const gradientFill = "url(#" + id + ")";
|
|
19
20
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
20
21
|
/* @__PURE__ */ jsx(ColorGradient, { colors: TransparentStops, checkerboard: true }),
|
|
21
22
|
/* @__PURE__ */ jsxs(
|
|
@@ -31,7 +32,7 @@ const ColorMotionGradient = memo(function ColorMotionGradient2({
|
|
|
31
32
|
/* @__PURE__ */ jsx(Stop, { offset: 0, stopColor: "#FFFFFF", stopOpacity: 0 }),
|
|
32
33
|
/* @__PURE__ */ jsx(Stop, { offset: 1, stopColor: "#FFFFFF", stopOpacity: 1 })
|
|
33
34
|
] }),
|
|
34
|
-
/* @__PURE__ */ jsx(Mask, { id: id + "-mask", x: "0%", y: "0%", width: "100%", height: "100%", children: /* @__PURE__ */ jsx(Rect, { width: "100%", height: "100%", fill:
|
|
35
|
+
/* @__PURE__ */ jsx(Mask, { id: id + "-mask", x: "0%", y: "0%", width: "100%", height: "100%", children: /* @__PURE__ */ jsx(Rect, { width: "100%", height: "100%", fill: gradientFill }) })
|
|
35
36
|
] }),
|
|
36
37
|
/* @__PURE__ */ jsx(
|
|
37
38
|
AnimatedColorRect,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/motion-gradient.tsx"],"sourcesContent":["import { memo, useId } from \"react\";\nimport { StyleSheet } from \"react-native\";\nimport { useAnimatedProps } from \"react-native-reanimated\";\nimport Svg, { Defs, LinearGradient, Mask, Rect, Stop } from \"react-native-svg\";\n\nimport type { ColorMotionSurfaceProps } from \"../types/color-motion.types\";\nimport {\n AnimatedColorRect,\n TransparentStops,\n} from \"../constants/motion.constants\";\nimport { rgbaToNativeColor } from \"../utils/color.utils\";\nimport { ColorGradient } from \"./gradient\";\n\nexport const ColorMotionGradient = memo(function ColorMotionGradient({\n rgba,\n}: ColorMotionSurfaceProps) {\n const id = useId().replace(/:/g, \"\");\n const rectProps = useAnimatedProps(() => ({\n color: rgbaToNativeColor(rgba.get(), true),\n }));\n\n return (\n <>\n <ColorGradient colors={TransparentStops} checkerboard />\n <Svg\n pointerEvents=\"none\"\n width=\"100%\"\n height=\"100%\"\n style={StyleSheet.absoluteFill}\n >\n <Defs>\n <LinearGradient id={id} x1=\"0%\" x2=\"100%\" y1=\"0%\" y2=\"0%\">\n <Stop offset={0} stopColor=\"#FFFFFF\" stopOpacity={0} />\n <Stop offset={1} stopColor=\"#FFFFFF\" stopOpacity={1} />\n </LinearGradient>\n <Mask id={id + \"-mask\"} x=\"0%\" y=\"0%\" width=\"100%\" height=\"100%\">\n <Rect width=\"100%\" height=\"100%\" fill={
|
|
1
|
+
{"version":3,"sources":["../../src/components/motion-gradient.tsx"],"sourcesContent":["import { memo, useId } from \"react\";\nimport { StyleSheet } from \"react-native\";\nimport { useAnimatedProps } from \"react-native-reanimated\";\nimport Svg, { Defs, LinearGradient, Mask, Rect, Stop } from \"react-native-svg\";\n\nimport type { ColorMotionSurfaceProps } from \"../types/color-motion.types\";\nimport {\n AnimatedColorRect,\n TransparentStops,\n} from \"../constants/motion.constants\";\nimport { rgbaToNativeColor } from \"../utils/color.utils\";\nimport { ColorGradient } from \"./gradient\";\n\nexport const ColorMotionGradient = memo(function ColorMotionGradient({\n rgba,\n}: ColorMotionSurfaceProps) {\n const id = useId().replace(/:/g, \"\");\n const rectProps = useAnimatedProps(() => ({\n color: rgbaToNativeColor(rgba.get(), true),\n }));\n\n const gradientFill = \"url(#\" + id + \")\";\n\n return (\n <>\n <ColorGradient colors={TransparentStops} checkerboard />\n <Svg\n pointerEvents=\"none\"\n width=\"100%\"\n height=\"100%\"\n style={StyleSheet.absoluteFill}\n >\n <Defs>\n <LinearGradient id={id} x1=\"0%\" x2=\"100%\" y1=\"0%\" y2=\"0%\">\n <Stop offset={0} stopColor=\"#FFFFFF\" stopOpacity={0} />\n <Stop offset={1} stopColor=\"#FFFFFF\" stopOpacity={1} />\n </LinearGradient>\n <Mask id={id + \"-mask\"} x=\"0%\" y=\"0%\" width=\"100%\" height=\"100%\">\n <Rect width=\"100%\" height=\"100%\" fill={gradientFill} />\n </Mask>\n </Defs>\n <AnimatedColorRect\n fill=\"currentColor\"\n width=\"100%\"\n height=\"100%\"\n mask={\"url(#\" + id + \"-mask)\"}\n animatedProps={rectProps}\n />\n </Svg>\n </>\n );\n});\n"],"mappings":"AAwBI,mBACE,KAQI,YATN;AAxBJ,SAAS,MAAM,aAAa;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AACjC,OAAO,OAAO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
|
3
2
|
import { ColorMotionSurfaceProps } from '../types/color-motion.types.mjs';
|
|
4
3
|
import 'react-native-reanimated';
|
|
5
4
|
import '../types/color.types.mjs';
|
|
6
5
|
|
|
7
|
-
declare const ColorMotionSurface: react.MemoExoticComponent<({ rgba, }: ColorMotionSurfaceProps) =>
|
|
6
|
+
declare const ColorMotionSurface: react.MemoExoticComponent<({ rgba, }: ColorMotionSurfaceProps) => react.JSX.Element>;
|
|
8
7
|
|
|
9
8
|
export { ColorMotionSurface };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
import { ColorPickerPresetEntryProps } from '../types/color-picker-internal.types.mjs';
|
|
4
3
|
import 'react-native-reanimated';
|
|
5
4
|
import '@impulse-ui-native/theme';
|
|
6
5
|
import '../types/color.types.mjs';
|
|
7
6
|
|
|
8
|
-
declare const ColorPickerPresetEntry: react.MemoExoticComponent<({ preset, }: ColorPickerPresetEntryProps) =>
|
|
7
|
+
declare const ColorPickerPresetEntry: react.MemoExoticComponent<({ preset, }: ColorPickerPresetEntryProps) => react.JSX.Element>;
|
|
9
8
|
|
|
10
9
|
export { ColorPickerPresetEntry };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
import { ViewProps } from '@impulse-ui-native/primitives';
|
|
4
3
|
|
|
5
|
-
declare const ColorPickerPreview: react.MemoExoticComponent<({ style, children, ...props }: ViewProps) =>
|
|
4
|
+
declare const ColorPickerPreview: react.MemoExoticComponent<({ style, children, ...props }: ViewProps) => react.JSX.Element>;
|
|
6
5
|
|
|
7
6
|
export { ColorPickerPreview };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
import { ColorPickerRootProps } from '../types/color-picker.types.mjs';
|
|
4
3
|
import '@impulse-ui-native/primitives';
|
|
5
4
|
import '@impulse-ui-native/theme';
|
|
6
5
|
import '../types/color.types.mjs';
|
|
7
6
|
|
|
8
|
-
declare const ColorPickerRoot: react.MemoExoticComponent<({ children, style, value, defaultValue, onChange, disabled, size, commitMode, ...props }: ColorPickerRootProps) =>
|
|
7
|
+
declare const ColorPickerRoot: react.MemoExoticComponent<({ children, style, value, defaultValue, onChange, disabled, size, commitMode, ...props }: ColorPickerRootProps) => react.JSX.Element>;
|
|
9
8
|
|
|
10
9
|
export { ColorPickerRoot };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
|
|
4
|
-
declare const ColorPickerSpectrum: react.MemoExoticComponent<() =>
|
|
3
|
+
declare const ColorPickerSpectrum: react.MemoExoticComponent<() => react.JSX.Element>;
|
|
5
4
|
|
|
6
5
|
export { ColorPickerSpectrum };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
import { ColorPickerSwatchProps } from '../types/color-picker.types.mjs';
|
|
4
3
|
import '@impulse-ui-native/primitives';
|
|
5
4
|
import '@impulse-ui-native/theme';
|
|
6
5
|
import '../types/color.types.mjs';
|
|
7
6
|
|
|
8
|
-
declare const ColorPickerSwatch: react.MemoExoticComponent<({ color, children, disabled: disabledProp, style, onPress, ...props }: ColorPickerSwatchProps) =>
|
|
7
|
+
declare const ColorPickerSwatch: react.MemoExoticComponent<({ color, children, disabled: disabledProp, style, onPress, ...props }: ColorPickerSwatchProps) => react.JSX.Element>;
|
|
9
8
|
|
|
10
9
|
export { ColorPickerSwatch };
|
|
@@ -4,6 +4,6 @@ import { Rect } from 'react-native-svg';
|
|
|
4
4
|
|
|
5
5
|
declare const TransparentStops: readonly string[];
|
|
6
6
|
declare const SaturationStops: readonly string[];
|
|
7
|
-
declare const AnimatedColorRect: react_native_reanimated_lib_typescript_createAnimatedComponent.AnimatedComponentType<Readonly<react_native_svg.RectProps | Readonly<react_native_svg.RectProps>>, typeof Rect>;
|
|
7
|
+
declare const AnimatedColorRect: react_native_reanimated_lib_typescript_createAnimatedComponent.AnimatedComponentType<Readonly<react_native_svg.RectProps | Readonly<react_native_svg.RectProps>>, typeof Rect, object>;
|
|
8
8
|
|
|
9
9
|
export { AnimatedColorRect, SaturationStops, TransparentStops };
|
|
@@ -1,11 +1,37 @@
|
|
|
1
1
|
import * as react_native_reanimated_lib_typescript_hook_commonTypes from 'react-native-reanimated/lib/typescript/hook/commonTypes';
|
|
2
|
+
import * as react_native from 'react-native';
|
|
2
3
|
import * as react_native_gesture_handler_lib_typescript_handlers_gestures_panGesture from 'react-native-gesture-handler/lib/typescript/handlers/gestures/panGesture';
|
|
3
|
-
import { LayoutChangeEvent } from 'react-native';
|
|
4
4
|
import { SpectrumInteractionOptions } from '../types/spectrum.types.mjs';
|
|
5
5
|
|
|
6
6
|
declare function useSpectrumInteraction({ disabled, onChange, onChangeWorklet, onComplete, saturation, brightness, }: SpectrumInteractionOptions): {
|
|
7
7
|
gesture: react_native_gesture_handler_lib_typescript_handlers_gestures_panGesture.PanGesture;
|
|
8
|
-
handleLayout: (event:
|
|
8
|
+
handleLayout: (event: Readonly<{
|
|
9
|
+
bubbles: boolean | undefined;
|
|
10
|
+
cancelable: boolean | undefined;
|
|
11
|
+
currentTarget: number | react_native.HostInstance;
|
|
12
|
+
defaultPrevented: boolean | undefined;
|
|
13
|
+
dispatchConfig: Readonly<{
|
|
14
|
+
registrationName: string;
|
|
15
|
+
}>;
|
|
16
|
+
eventPhase: number | undefined;
|
|
17
|
+
preventDefault: () => void;
|
|
18
|
+
isDefaultPrevented: () => boolean;
|
|
19
|
+
stopPropagation: () => void;
|
|
20
|
+
isPropagationStopped: () => boolean;
|
|
21
|
+
isTrusted: boolean | undefined;
|
|
22
|
+
nativeEvent: Readonly<{
|
|
23
|
+
layout: Readonly<{
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
}>;
|
|
29
|
+
}>;
|
|
30
|
+
persist: () => void;
|
|
31
|
+
target: (number | undefined) | react_native.HostInstance;
|
|
32
|
+
timeStamp: number;
|
|
33
|
+
type: string | undefined;
|
|
34
|
+
}>) => void;
|
|
9
35
|
indicatorStyle: react_native_reanimated_lib_typescript_hook_commonTypes.AnimatedStyleHandle<{
|
|
10
36
|
transform: ({
|
|
11
37
|
translateX: number;
|
package/dist/index.d.mts
CHANGED
|
@@ -4,6 +4,5 @@ export { ColorPickerActionProps, ColorPickerAlphaInputProps, ColorPickerChannelI
|
|
|
4
4
|
export { ColorPickerPreset } from '@impulse-ui-native/theme';
|
|
5
5
|
export { ColorPickerHexInputProps } from './types/color-input.types.mjs';
|
|
6
6
|
import '@impulse-ui-native/primitives';
|
|
7
|
-
import 'react/jsx-runtime';
|
|
8
7
|
import 'react';
|
|
9
8
|
import '@impulse-ui-native/input';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@impulse-ui-native/color-picker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "Modular spectrum color picker with custom hex/RGB entry and theme presets for React Native.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"source": "src/index.ts",
|
|
14
14
|
"module": "dist/index.js",
|
|
15
15
|
"types": "dist/index.d.mts",
|
|
16
|
-
"react-native": "
|
|
16
|
+
"react-native": "dist/index.js",
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
19
19
|
"types": "./dist/index.d.mts",
|
|
20
|
-
"react-native": "./
|
|
20
|
+
"react-native": "./dist/index.js",
|
|
21
21
|
"import": "./dist/index.js"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
@@ -28,24 +28,24 @@
|
|
|
28
28
|
],
|
|
29
29
|
"sideEffects": false,
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@impulse-ui-native/
|
|
32
|
-
"@impulse-ui-native/
|
|
33
|
-
"@impulse-ui-native/
|
|
34
|
-
"@impulse-ui-native/
|
|
35
|
-
"@impulse-ui-native/
|
|
36
|
-
"@impulse-ui-native/
|
|
31
|
+
"@impulse-ui-native/icon": "10.0.0",
|
|
32
|
+
"@impulse-ui-native/core": "10.0.0",
|
|
33
|
+
"@impulse-ui-native/primitives": "10.0.0",
|
|
34
|
+
"@impulse-ui-native/theme": "10.0.0",
|
|
35
|
+
"@impulse-ui-native/slider": "10.0.0",
|
|
36
|
+
"@impulse-ui-native/input": "10.0.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@types/react": "~19.
|
|
39
|
+
"@types/react": "~19.3.0",
|
|
40
40
|
"eslint": "^9.38.0",
|
|
41
41
|
"prettier": "^3.6.2",
|
|
42
|
-
"react": "19.
|
|
43
|
-
"react-native": "0.
|
|
42
|
+
"react": "19.3.0",
|
|
43
|
+
"react-native": "0.88.0",
|
|
44
44
|
"typescript": "~6.0.3",
|
|
45
|
-
"react-native-svg": "15.
|
|
46
|
-
"react-native-gesture-handler": "~
|
|
47
|
-
"react-native-reanimated": "4.
|
|
48
|
-
"react-native-worklets": "0.
|
|
45
|
+
"react-native-svg": "15.16.0",
|
|
46
|
+
"react-native-gesture-handler": "~3.3.0",
|
|
47
|
+
"react-native-reanimated": "4.7.1",
|
|
48
|
+
"react-native-worklets": "0.13.0",
|
|
49
49
|
"@impulse-ui-native/eslint-config": "1.0.0",
|
|
50
50
|
"@impulse-ui-native/prettier-config": "1.0.0",
|
|
51
51
|
"@impulse-ui-native/tsconfig": "1.0.0"
|