@ezpg/app-ui 0.9.0 → 0.10.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/CHANGELOG.md +6 -0
- package/lib/module/adjust/adjust-template.js +92 -0
- package/lib/module/adjust/adjust-template.js.map +1 -0
- package/lib/module/adjust/color-adjust-note.js +67 -0
- package/lib/module/adjust/color-adjust-note.js.map +1 -0
- package/lib/module/adjust/color-track.js +132 -0
- package/lib/module/adjust/color-track.js.map +1 -0
- package/lib/module/adjust/dial-strip.js +126 -0
- package/lib/module/adjust/dial-strip.js.map +1 -0
- package/lib/module/adjust/hsl.js +29 -0
- package/lib/module/adjust/hsl.js.map +1 -0
- package/lib/module/adjust/index.js +9 -0
- package/lib/module/adjust/index.js.map +1 -0
- package/lib/module/adjust/scrub-ruler.js +159 -0
- package/lib/module/adjust/scrub-ruler.js.map +1 -0
- package/lib/module/adjust.js +4 -0
- package/lib/module/adjust.js.map +1 -0
- package/lib/typescript/src/adjust/adjust-template.d.ts +13 -0
- package/lib/typescript/src/adjust/adjust-template.d.ts.map +1 -0
- package/lib/typescript/src/adjust/color-adjust-note.d.ts +10 -0
- package/lib/typescript/src/adjust/color-adjust-note.d.ts.map +1 -0
- package/lib/typescript/src/adjust/color-track.d.ts +12 -0
- package/lib/typescript/src/adjust/color-track.d.ts.map +1 -0
- package/lib/typescript/src/adjust/dial-strip.d.ts +16 -0
- package/lib/typescript/src/adjust/dial-strip.d.ts.map +1 -0
- package/lib/typescript/src/adjust/hsl.d.ts +4 -0
- package/lib/typescript/src/adjust/hsl.d.ts.map +1 -0
- package/lib/typescript/src/adjust/index.d.ts +7 -0
- package/lib/typescript/src/adjust/index.d.ts.map +1 -0
- package/lib/typescript/src/adjust/scrub-ruler.d.ts +13 -0
- package/lib/typescript/src/adjust/scrub-ruler.d.ts.map +1 -0
- package/lib/typescript/src/adjust.d.ts +2 -0
- package/lib/typescript/src/adjust.d.ts.map +1 -0
- package/package.json +6 -1
- package/src/adjust/adjust-template.tsx +89 -0
- package/src/adjust/color-adjust-note.tsx +61 -0
- package/src/adjust/color-track.tsx +140 -0
- package/src/adjust/dial-strip.tsx +142 -0
- package/src/adjust/hsl.ts +37 -0
- package/src/adjust/index.ts +9 -0
- package/src/adjust/scrub-ruler.tsx +160 -0
- package/src/adjust.tsx +1 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useMemo, useRef } from 'react';
|
|
4
|
+
import { PanResponder, View } from 'react-native';
|
|
5
|
+
import { Text } from "../components/text/text.js";
|
|
6
|
+
import { useTheme } from "../theme/theme-provider.js";
|
|
7
|
+
import { makeStyles } from "../utils/styles.js";
|
|
8
|
+
import { clamp } from "./hsl.js";
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
const MINOR = 3;
|
|
11
|
+
const TICK = 2;
|
|
12
|
+
const useStyles = makeStyles(t => ({
|
|
13
|
+
root: {
|
|
14
|
+
height: t.controlSize.lg,
|
|
15
|
+
marginHorizontal: t.layout.screenX,
|
|
16
|
+
overflow: 'hidden'
|
|
17
|
+
},
|
|
18
|
+
ticks: {
|
|
19
|
+
position: 'absolute',
|
|
20
|
+
top: t.space[2],
|
|
21
|
+
left: '50%',
|
|
22
|
+
flexDirection: 'row',
|
|
23
|
+
alignItems: 'flex-end'
|
|
24
|
+
},
|
|
25
|
+
tick: {
|
|
26
|
+
width: TICK,
|
|
27
|
+
height: t.space[2],
|
|
28
|
+
backgroundColor: t.colors.input
|
|
29
|
+
},
|
|
30
|
+
major: {
|
|
31
|
+
height: t.space[4],
|
|
32
|
+
backgroundColor: t.colors.mutedForeground
|
|
33
|
+
},
|
|
34
|
+
zero: {
|
|
35
|
+
height: t.space[5],
|
|
36
|
+
backgroundColor: t.colors.foreground
|
|
37
|
+
},
|
|
38
|
+
needle: {
|
|
39
|
+
position: 'absolute',
|
|
40
|
+
left: '50%',
|
|
41
|
+
top: t.space[1],
|
|
42
|
+
width: TICK,
|
|
43
|
+
marginLeft: -TICK / 2,
|
|
44
|
+
height: t.space[6] + t.space[1],
|
|
45
|
+
borderRadius: t.radius.sm,
|
|
46
|
+
backgroundColor: t.colors.primary
|
|
47
|
+
},
|
|
48
|
+
ends: {
|
|
49
|
+
position: 'absolute',
|
|
50
|
+
left: 0,
|
|
51
|
+
right: 0,
|
|
52
|
+
bottom: 0,
|
|
53
|
+
flexDirection: 'row',
|
|
54
|
+
justifyContent: 'space-between'
|
|
55
|
+
}
|
|
56
|
+
}));
|
|
57
|
+
export function ScrubRuler({
|
|
58
|
+
value,
|
|
59
|
+
min = -2,
|
|
60
|
+
max = 2,
|
|
61
|
+
onChange,
|
|
62
|
+
startLabel,
|
|
63
|
+
endLabel,
|
|
64
|
+
accessibilityLabel,
|
|
65
|
+
style
|
|
66
|
+
}) {
|
|
67
|
+
const t = useTheme();
|
|
68
|
+
const s = useStyles();
|
|
69
|
+
const step = t.space[8];
|
|
70
|
+
const gap = (step - TICK * (MINOR + 1)) / (MINOR + 1);
|
|
71
|
+
const latest = useRef({
|
|
72
|
+
value,
|
|
73
|
+
onChange,
|
|
74
|
+
min,
|
|
75
|
+
max
|
|
76
|
+
});
|
|
77
|
+
latest.current = {
|
|
78
|
+
value,
|
|
79
|
+
onChange,
|
|
80
|
+
min,
|
|
81
|
+
max
|
|
82
|
+
};
|
|
83
|
+
const start = useRef(value);
|
|
84
|
+
const pan = useMemo(() => PanResponder.create({
|
|
85
|
+
onStartShouldSetPanResponder: () => true,
|
|
86
|
+
onMoveShouldSetPanResponder: (_, g) => Math.abs(g.dx) > Math.abs(g.dy),
|
|
87
|
+
onPanResponderTerminationRequest: () => false,
|
|
88
|
+
onPanResponderGrant: () => {
|
|
89
|
+
start.current = latest.current.value;
|
|
90
|
+
},
|
|
91
|
+
onPanResponderMove: (_, g) => {
|
|
92
|
+
const {
|
|
93
|
+
onChange: change,
|
|
94
|
+
min: lo,
|
|
95
|
+
max: hi,
|
|
96
|
+
value: now
|
|
97
|
+
} = latest.current;
|
|
98
|
+
const next = clamp(start.current - Math.round(g.dx / step), lo, hi);
|
|
99
|
+
if (next !== now) change(next);
|
|
100
|
+
}
|
|
101
|
+
}), [step]);
|
|
102
|
+
const ticks = [];
|
|
103
|
+
for (let v = min; v <= max; v += 1) {
|
|
104
|
+
ticks.push(/*#__PURE__*/_jsx(View, {
|
|
105
|
+
style: [s.tick, v === 0 ? s.zero : s.major, v < max && {
|
|
106
|
+
marginRight: gap
|
|
107
|
+
}]
|
|
108
|
+
}, `m${v}`));
|
|
109
|
+
if (v < max) {
|
|
110
|
+
for (let j = 0; j < MINOR; j += 1) {
|
|
111
|
+
ticks.push(/*#__PURE__*/_jsx(View, {
|
|
112
|
+
style: [s.tick, {
|
|
113
|
+
marginRight: gap
|
|
114
|
+
}]
|
|
115
|
+
}, `${v}-${j}`));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
120
|
+
...pan.panHandlers,
|
|
121
|
+
accessible: true,
|
|
122
|
+
accessibilityRole: "adjustable",
|
|
123
|
+
accessibilityLabel: accessibilityLabel,
|
|
124
|
+
accessibilityValue: {
|
|
125
|
+
min,
|
|
126
|
+
max,
|
|
127
|
+
now: value
|
|
128
|
+
},
|
|
129
|
+
accessibilityActions: [{
|
|
130
|
+
name: 'increment'
|
|
131
|
+
}, {
|
|
132
|
+
name: 'decrement'
|
|
133
|
+
}],
|
|
134
|
+
onAccessibilityAction: e => onChange(clamp(value + (e.nativeEvent.actionName === 'increment' ? 1 : -1), min, max)),
|
|
135
|
+
style: [s.root, style],
|
|
136
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
137
|
+
style: [s.ticks, {
|
|
138
|
+
transform: [{
|
|
139
|
+
translateX: -(value - min) * step - TICK / 2
|
|
140
|
+
}]
|
|
141
|
+
}],
|
|
142
|
+
children: ticks
|
|
143
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
144
|
+
style: s.needle
|
|
145
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
146
|
+
style: s.ends,
|
|
147
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
148
|
+
variant: "caption",
|
|
149
|
+
tone: "muted",
|
|
150
|
+
children: startLabel ?? ''
|
|
151
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
152
|
+
variant: "caption",
|
|
153
|
+
tone: "muted",
|
|
154
|
+
children: endLabel ?? ''
|
|
155
|
+
})]
|
|
156
|
+
})]
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=scrub-ruler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useMemo","useRef","PanResponder","View","Text","useTheme","makeStyles","clamp","jsx","_jsx","jsxs","_jsxs","MINOR","TICK","useStyles","t","root","height","controlSize","lg","marginHorizontal","layout","screenX","overflow","ticks","position","top","space","left","flexDirection","alignItems","tick","width","backgroundColor","colors","input","major","mutedForeground","zero","foreground","needle","marginLeft","borderRadius","radius","sm","primary","ends","right","bottom","justifyContent","ScrubRuler","value","min","max","onChange","startLabel","endLabel","accessibilityLabel","style","s","step","gap","latest","current","start","pan","create","onStartShouldSetPanResponder","onMoveShouldSetPanResponder","_","g","Math","abs","dx","dy","onPanResponderTerminationRequest","onPanResponderGrant","onPanResponderMove","change","lo","hi","now","next","round","v","push","marginRight","j","panHandlers","accessible","accessibilityRole","accessibilityValue","accessibilityActions","name","onAccessibilityAction","e","nativeEvent","actionName","children","transform","translateX","variant","tone"],"sourceRoot":"../../../src","sources":["adjust/scrub-ruler.tsx"],"mappings":";;AAAA,SAASA,OAAO,EAAEC,MAAM,QAAQ,OAAO;AACvC,SACEC,YAAY,EACZC,IAAI,QAGC,cAAc;AACrB,SAASC,IAAI,QAAQ,4BAAyB;AAC9C,SAASC,QAAQ,QAAQ,4BAAyB;AAClD,SAASC,UAAU,QAAQ,oBAAiB;AAC5C,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,IAAI;MAACuD,KAAK,EAAEC,CAAC,CAACb,IAAK;MAAAoD,QAAA,gBAClBzF,IAAA,CAACL,IAAI;QAACiG,OAAO,EAAC,SAAS;QAACC,IAAI,EAAC,OAAO;QAAAJ,QAAA,EACjC3C,UAAU,IAAI;MAAE,CACb,CAAC,eACP9C,IAAA,CAACL,IAAI;QAACiG,OAAO,EAAC,SAAS;QAACC,IAAI,EAAC,OAAO;QAAAJ,QAAA,EACjC1C,QAAQ,IAAI;MAAE,CACX,CAAC;IAAA,CACH,CAAC;EAAA,CACH,CAAC;AAEX","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["adjust.tsx"],"mappings":";;AAAA,cAAc,mBAAgB","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type TemplateAction } from '../templates/parts.js';
|
|
3
|
+
export type AdjustTemplateProps = {
|
|
4
|
+
preview: ReactNode;
|
|
5
|
+
label?: string;
|
|
6
|
+
compareLabel?: string;
|
|
7
|
+
onCompareChange?: (comparing: boolean) => void;
|
|
8
|
+
controls: ReactNode;
|
|
9
|
+
primaryAction: TemplateAction;
|
|
10
|
+
bottomInset?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare function AdjustTemplate({ preview, label, compareLabel, onCompareChange, controls, primaryAction, bottomInset, }: AdjustTemplateProps): import("react").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=adjust-template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adjust-template.d.ts","sourceRoot":"","sources":["../../../../src/adjust/adjust-template.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,uBAAoB,CAAC;AAIpE,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,SAAS,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/C,QAAQ,EAAE,SAAS,CAAC;IACpB,aAAa,EAAE,cAAc,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAkCF,wBAAgB,cAAc,CAAC,EAC7B,OAAO,EACP,KAAK,EACL,YAAuB,EACvB,eAAe,EACf,QAAQ,EACR,aAAa,EACb,WAAe,GAChB,EAAE,mBAAmB,+BA8BrB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
2
|
+
export type ColorAdjustNoteProps = {
|
|
3
|
+
original: string;
|
|
4
|
+
applied: string;
|
|
5
|
+
title: string;
|
|
6
|
+
detail?: string;
|
|
7
|
+
style?: StyleProp<ViewStyle>;
|
|
8
|
+
};
|
|
9
|
+
export declare function ColorAdjustNote({ original, applied, title, detail, style, }: ColorAdjustNoteProps): import("react").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=color-adjust-note.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-adjust-note.d.ts","sourceRoot":"","sources":["../../../../src/adjust/color-adjust-note.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAIpE,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AAkBF,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,OAAO,EACP,KAAK,EACL,MAAM,EACN,KAAK,GACN,EAAE,oBAAoB,+BA0BtB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
2
|
+
export type ColorTrackProps = {
|
|
3
|
+
kind: 'hue' | 'saturation';
|
|
4
|
+
hue: number;
|
|
5
|
+
saturation: number;
|
|
6
|
+
lightness?: number;
|
|
7
|
+
onChange: (value: number) => void;
|
|
8
|
+
label: string;
|
|
9
|
+
style?: StyleProp<ViewStyle>;
|
|
10
|
+
};
|
|
11
|
+
export declare function ColorTrack({ kind, hue, saturation, lightness, onChange, label, style, }: ColorTrackProps): import("react").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=color-track.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-track.d.ts","sourceRoot":"","sources":["../../../../src/adjust/color-track.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAOtB,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,KAAK,GAAG,YAAY,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AAgBF,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,GAAG,EACH,UAAU,EACV,SAAc,EACd,QAAQ,EACR,KAAK,EACL,KAAK,GACN,EAAE,eAAe,+BA6FjB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
2
|
+
export type DialItem = {
|
|
3
|
+
key: string;
|
|
4
|
+
label: string;
|
|
5
|
+
value?: number;
|
|
6
|
+
max?: number;
|
|
7
|
+
color?: string;
|
|
8
|
+
};
|
|
9
|
+
export type DialStripProps = {
|
|
10
|
+
items: readonly DialItem[];
|
|
11
|
+
selected: string;
|
|
12
|
+
onSelect: (key: string) => void;
|
|
13
|
+
style?: StyleProp<ViewStyle>;
|
|
14
|
+
};
|
|
15
|
+
export declare function DialStrip({ items, selected, onSelect, style, }: DialStripProps): import("react").JSX.Element;
|
|
16
|
+
//# sourceMappingURL=dial-strip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dial-strip.d.ts","sourceRoot":"","sources":["../../../../src/adjust/dial-strip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAOhF,MAAM,MAAM,QAAQ,GAAG;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AA+EF,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,KAAK,GACN,EAAE,cAAc,+BAqChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hsl.d.ts","sourceRoot":"","sources":["../../../../src/adjust/hsl.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAYhE;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAkB9D;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAErE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { AdjustTemplate, type AdjustTemplateProps } from './adjust-template.js';
|
|
2
|
+
export { ColorAdjustNote, type ColorAdjustNoteProps, } from './color-adjust-note.js';
|
|
3
|
+
export { ColorTrack, type ColorTrackProps } from './color-track.js';
|
|
4
|
+
export { DialStrip, type DialItem, type DialStripProps } from './dial-strip.js';
|
|
5
|
+
export { ScrubRuler, type ScrubRulerProps } from './scrub-ruler.js';
|
|
6
|
+
export { hexToHsl, hslToHex } from './hsl.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adjust/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,sBAAmB,CAAC;AAC7E,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,GAC1B,MAAM,wBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAe,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAc,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAe,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAO,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
2
|
+
export type ScrubRulerProps = {
|
|
3
|
+
value: number;
|
|
4
|
+
min?: number;
|
|
5
|
+
max?: number;
|
|
6
|
+
onChange: (value: number) => void;
|
|
7
|
+
startLabel?: string;
|
|
8
|
+
endLabel?: string;
|
|
9
|
+
accessibilityLabel: string;
|
|
10
|
+
style?: StyleProp<ViewStyle>;
|
|
11
|
+
};
|
|
12
|
+
export declare function ScrubRuler({ value, min, max, onChange, startLabel, endLabel, accessibilityLabel, style, }: ScrubRulerProps): import("react").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=scrub-ruler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrub-ruler.d.ts","sourceRoot":"","sources":["../../../../src/adjust/scrub-ruler.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAMtB,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AAyCF,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,GAAQ,EACR,GAAO,EACP,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,kBAAkB,EAClB,KAAK,GACN,EAAE,eAAe,+BAwFjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adjust.d.ts","sourceRoot":"","sources":["../../../src/adjust.tsx"],"names":[],"mappings":"AAAA,cAAc,mBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ezpg/app-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "React Native UI components for EZPG partner apps",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
"types": "./lib/typescript/src/charts.d.ts",
|
|
16
16
|
"default": "./lib/module/charts.js"
|
|
17
17
|
},
|
|
18
|
+
"./adjust": {
|
|
19
|
+
"ezpg-app-ui-source": "./src/adjust.tsx",
|
|
20
|
+
"types": "./lib/typescript/src/adjust.d.ts",
|
|
21
|
+
"default": "./lib/module/adjust.js"
|
|
22
|
+
},
|
|
18
23
|
"./sortable": {
|
|
19
24
|
"ezpg-app-ui-source": "./src/sortable.tsx",
|
|
20
25
|
"types": "./lib/typescript/src/sortable.d.ts",
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { Text } from '../components/text/text';
|
|
4
|
+
import { PressableBase } from '../internal/pressable-base';
|
|
5
|
+
import { BottomBar, type TemplateAction } from '../templates/parts';
|
|
6
|
+
import { useTheme } from '../theme/theme-provider';
|
|
7
|
+
import { makeStyles } from '../utils/styles';
|
|
8
|
+
|
|
9
|
+
export type AdjustTemplateProps = {
|
|
10
|
+
preview: ReactNode;
|
|
11
|
+
label?: string;
|
|
12
|
+
compareLabel?: string;
|
|
13
|
+
onCompareChange?: (comparing: boolean) => void;
|
|
14
|
+
controls: ReactNode;
|
|
15
|
+
primaryAction: TemplateAction;
|
|
16
|
+
bottomInset?: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const useStyles = makeStyles((t) => ({
|
|
20
|
+
root: { flex: 1, backgroundColor: t.colors.background },
|
|
21
|
+
stage: {
|
|
22
|
+
flex: 1,
|
|
23
|
+
minHeight: 0,
|
|
24
|
+
backgroundColor: t.colors.muted,
|
|
25
|
+
overflow: 'hidden',
|
|
26
|
+
},
|
|
27
|
+
label: {
|
|
28
|
+
position: 'absolute',
|
|
29
|
+
alignSelf: 'center',
|
|
30
|
+
bottom: t.space[2],
|
|
31
|
+
paddingHorizontal: t.space[2],
|
|
32
|
+
paddingVertical: t.space[1],
|
|
33
|
+
borderRadius: t.radius.sm,
|
|
34
|
+
backgroundColor: t.colors.foreground,
|
|
35
|
+
opacity: 0.72,
|
|
36
|
+
},
|
|
37
|
+
compare: {
|
|
38
|
+
position: 'absolute',
|
|
39
|
+
top: t.space[2],
|
|
40
|
+
right: t.space[3],
|
|
41
|
+
paddingHorizontal: t.space[3],
|
|
42
|
+
paddingVertical: t.space[1],
|
|
43
|
+
borderRadius: t.radius.full,
|
|
44
|
+
borderWidth: 1,
|
|
45
|
+
borderColor: t.colors.border,
|
|
46
|
+
backgroundColor: t.colors.background,
|
|
47
|
+
},
|
|
48
|
+
controls: { paddingTop: t.layout.groupGap, gap: t.layout.groupGap },
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
export function AdjustTemplate({
|
|
52
|
+
preview,
|
|
53
|
+
label,
|
|
54
|
+
compareLabel = '원래와 비교',
|
|
55
|
+
onCompareChange,
|
|
56
|
+
controls,
|
|
57
|
+
primaryAction,
|
|
58
|
+
bottomInset = 0,
|
|
59
|
+
}: AdjustTemplateProps) {
|
|
60
|
+
const t = useTheme();
|
|
61
|
+
const s = useStyles();
|
|
62
|
+
return (
|
|
63
|
+
<View style={s.root}>
|
|
64
|
+
<View style={s.stage}>
|
|
65
|
+
{preview}
|
|
66
|
+
{label ? (
|
|
67
|
+
<View style={s.label} pointerEvents="none">
|
|
68
|
+
<Text variant="caption" style={{ color: t.colors.background }}>
|
|
69
|
+
{label}
|
|
70
|
+
</Text>
|
|
71
|
+
</View>
|
|
72
|
+
) : null}
|
|
73
|
+
{onCompareChange ? (
|
|
74
|
+
<PressableBase
|
|
75
|
+
onPressIn={() => onCompareChange(true)}
|
|
76
|
+
onPressOut={() => onCompareChange(false)}
|
|
77
|
+
accessibilityRole="button"
|
|
78
|
+
accessibilityLabel={compareLabel}
|
|
79
|
+
style={s.compare}
|
|
80
|
+
>
|
|
81
|
+
<Text variant="caption">{compareLabel}</Text>
|
|
82
|
+
</PressableBase>
|
|
83
|
+
) : null}
|
|
84
|
+
</View>
|
|
85
|
+
<View style={s.controls}>{controls}</View>
|
|
86
|
+
<BottomBar primaryAction={primaryAction} bottomInset={bottomInset} />
|
|
87
|
+
</View>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { View, type StyleProp, type ViewStyle } from 'react-native';
|
|
2
|
+
import { Text } from '../components/text/text';
|
|
3
|
+
import { makeStyles } from '../utils/styles';
|
|
4
|
+
|
|
5
|
+
export type ColorAdjustNoteProps = {
|
|
6
|
+
original: string;
|
|
7
|
+
applied: string;
|
|
8
|
+
title: string;
|
|
9
|
+
detail?: string;
|
|
10
|
+
style?: StyleProp<ViewStyle>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const useStyles = makeStyles((t) => ({
|
|
14
|
+
root: {
|
|
15
|
+
flexDirection: 'row',
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
gap: t.space[2],
|
|
18
|
+
marginHorizontal: t.layout.screenX,
|
|
19
|
+
paddingHorizontal: t.space[3],
|
|
20
|
+
paddingVertical: t.space[2],
|
|
21
|
+
borderRadius: t.radius.lg,
|
|
22
|
+
borderWidth: 1,
|
|
23
|
+
borderColor: t.colors.border,
|
|
24
|
+
},
|
|
25
|
+
sw: { width: t.space[5], height: t.space[5], borderRadius: t.radius.sm },
|
|
26
|
+
text: { flex: 1 },
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
export function ColorAdjustNote({
|
|
30
|
+
original,
|
|
31
|
+
applied,
|
|
32
|
+
title,
|
|
33
|
+
detail,
|
|
34
|
+
style,
|
|
35
|
+
}: ColorAdjustNoteProps) {
|
|
36
|
+
const s = useStyles();
|
|
37
|
+
const changed = original.toUpperCase() !== applied.toUpperCase();
|
|
38
|
+
return (
|
|
39
|
+
<View
|
|
40
|
+
style={[s.root, style]}
|
|
41
|
+
accessible
|
|
42
|
+
accessibilityLabel={[title, detail].filter(Boolean).join(', ')}
|
|
43
|
+
>
|
|
44
|
+
{changed ? (
|
|
45
|
+
<>
|
|
46
|
+
<View style={[s.sw, { backgroundColor: original }]} />
|
|
47
|
+
<Text variant="caption" tone="muted">
|
|
48
|
+
→
|
|
49
|
+
</Text>
|
|
50
|
+
</>
|
|
51
|
+
) : null}
|
|
52
|
+
<View style={[s.sw, { backgroundColor: applied }]} />
|
|
53
|
+
<Text variant="caption" style={s.text} numberOfLines={2}>
|
|
54
|
+
<Text variant="caption" weight="semibold">
|
|
55
|
+
{title}
|
|
56
|
+
</Text>
|
|
57
|
+
{detail ? ` · ${detail}` : ''}
|
|
58
|
+
</Text>
|
|
59
|
+
</View>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { useMemo, useRef, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
PanResponder,
|
|
4
|
+
View,
|
|
5
|
+
type LayoutChangeEvent,
|
|
6
|
+
type StyleProp,
|
|
7
|
+
type ViewStyle,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import Svg, { Defs, LinearGradient, Rect, Stop } from 'react-native-svg';
|
|
10
|
+
import { Text } from '../components/text/text';
|
|
11
|
+
import { useTheme } from '../theme/theme-provider';
|
|
12
|
+
import { makeStyles } from '../utils/styles';
|
|
13
|
+
import { clamp, hslToHex } from './hsl';
|
|
14
|
+
|
|
15
|
+
export type ColorTrackProps = {
|
|
16
|
+
kind: 'hue' | 'saturation';
|
|
17
|
+
hue: number;
|
|
18
|
+
saturation: number;
|
|
19
|
+
lightness?: number;
|
|
20
|
+
onChange: (value: number) => void;
|
|
21
|
+
label: string;
|
|
22
|
+
style?: StyleProp<ViewStyle>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const useStyles = makeStyles((t) => ({
|
|
26
|
+
root: { gap: t.space[2], paddingHorizontal: t.layout.screenX },
|
|
27
|
+
track: { height: t.space[8], justifyContent: 'center' },
|
|
28
|
+
knob: {
|
|
29
|
+
position: 'absolute',
|
|
30
|
+
width: t.space[8],
|
|
31
|
+
height: t.space[8],
|
|
32
|
+
borderRadius: t.radius.full,
|
|
33
|
+
borderWidth: 3,
|
|
34
|
+
borderColor: t.colors.background,
|
|
35
|
+
boxShadow: t.shadow.md,
|
|
36
|
+
},
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
export function ColorTrack({
|
|
40
|
+
kind,
|
|
41
|
+
hue,
|
|
42
|
+
saturation,
|
|
43
|
+
lightness = 45,
|
|
44
|
+
onChange,
|
|
45
|
+
label,
|
|
46
|
+
style,
|
|
47
|
+
}: ColorTrackProps) {
|
|
48
|
+
const t = useTheme();
|
|
49
|
+
const s = useStyles();
|
|
50
|
+
const [width, setWidth] = useState(0);
|
|
51
|
+
const max = kind === 'hue' ? 360 : 100;
|
|
52
|
+
const value = kind === 'hue' ? hue : saturation;
|
|
53
|
+
const latest = useRef({ width, onChange, max });
|
|
54
|
+
latest.current = { width, onChange, max };
|
|
55
|
+
const pan = useMemo(
|
|
56
|
+
() =>
|
|
57
|
+
PanResponder.create({
|
|
58
|
+
onStartShouldSetPanResponder: () => true,
|
|
59
|
+
onMoveShouldSetPanResponder: () => true,
|
|
60
|
+
onPanResponderTerminationRequest: () => false,
|
|
61
|
+
onPanResponderGrant: (e) => pick(e.nativeEvent.locationX),
|
|
62
|
+
onPanResponderMove: (e) => pick(e.nativeEvent.locationX),
|
|
63
|
+
}),
|
|
64
|
+
[]
|
|
65
|
+
);
|
|
66
|
+
function pick(x: number) {
|
|
67
|
+
const { width: w, onChange: change, max: m } = latest.current;
|
|
68
|
+
if (w > 0) change(Math.round(clamp(x / w, 0, 1) * m));
|
|
69
|
+
}
|
|
70
|
+
const stops =
|
|
71
|
+
kind === 'hue'
|
|
72
|
+
? Array.from({ length: 13 }, (_, i) =>
|
|
73
|
+
hslToHex(i * 30, saturation, lightness)
|
|
74
|
+
)
|
|
75
|
+
: [hslToHex(hue, 0, lightness), hslToHex(hue, 100, lightness)];
|
|
76
|
+
const knob = t.space[8];
|
|
77
|
+
const step = kind === 'hue' ? 10 : 5;
|
|
78
|
+
return (
|
|
79
|
+
<View style={[s.root, style]}>
|
|
80
|
+
<Text variant="caption" tone="muted">
|
|
81
|
+
{label}
|
|
82
|
+
</Text>
|
|
83
|
+
<View
|
|
84
|
+
{...pan.panHandlers}
|
|
85
|
+
onLayout={(e: LayoutChangeEvent) =>
|
|
86
|
+
setWidth(e.nativeEvent.layout.width)
|
|
87
|
+
}
|
|
88
|
+
accessible
|
|
89
|
+
accessibilityRole="adjustable"
|
|
90
|
+
accessibilityLabel={label}
|
|
91
|
+
accessibilityValue={{ min: 0, max, now: value }}
|
|
92
|
+
accessibilityActions={[{ name: 'increment' }, { name: 'decrement' }]}
|
|
93
|
+
onAccessibilityAction={(e) =>
|
|
94
|
+
onChange(
|
|
95
|
+
clamp(
|
|
96
|
+
value + (e.nativeEvent.actionName === 'increment' ? step : -step),
|
|
97
|
+
0,
|
|
98
|
+
max
|
|
99
|
+
)
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
style={s.track}
|
|
103
|
+
>
|
|
104
|
+
{width > 0 ? (
|
|
105
|
+
<Svg width={width} height={knob} pointerEvents="none">
|
|
106
|
+
<Defs>
|
|
107
|
+
<LinearGradient id={`g-${kind}`} x1="0" y1="0" x2="1" y2="0">
|
|
108
|
+
{stops.map((c, i) => (
|
|
109
|
+
<Stop key={i} offset={i / (stops.length - 1)} stopColor={c} />
|
|
110
|
+
))}
|
|
111
|
+
</LinearGradient>
|
|
112
|
+
</Defs>
|
|
113
|
+
<Rect
|
|
114
|
+
x={0}
|
|
115
|
+
y={0}
|
|
116
|
+
width={width}
|
|
117
|
+
height={knob}
|
|
118
|
+
rx={knob / 2}
|
|
119
|
+
fill={`url(#g-${kind})`}
|
|
120
|
+
/>
|
|
121
|
+
</Svg>
|
|
122
|
+
) : null}
|
|
123
|
+
<View
|
|
124
|
+
pointerEvents="none"
|
|
125
|
+
style={[
|
|
126
|
+
s.knob,
|
|
127
|
+
{
|
|
128
|
+
left: clamp(
|
|
129
|
+
(value / max) * width - knob / 2,
|
|
130
|
+
0,
|
|
131
|
+
Math.max(0, width - knob)
|
|
132
|
+
),
|
|
133
|
+
backgroundColor: hslToHex(hue, saturation, lightness),
|
|
134
|
+
},
|
|
135
|
+
]}
|
|
136
|
+
/>
|
|
137
|
+
</View>
|
|
138
|
+
</View>
|
|
139
|
+
);
|
|
140
|
+
}
|