@dloizides/ui-media 0.3.0 → 0.4.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 +4 -0
- package/dist/framing.d.mts +13 -19
- package/dist/framing.d.ts +13 -19
- package/dist/framing.js +17 -16
- package/dist/framing.js.map +1 -1
- package/dist/framing.mjs +17 -16
- package/dist/framing.mjs.map +1 -1
- package/dist/index.d.mts +59 -24
- package/dist/index.d.ts +59 -24
- package/dist/index.js +108 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +108 -54
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DEFAULT_PHOTO_FRAMING, clampFraming } from '@dloizides/site-template-kit/framing';
|
|
2
2
|
export { DEFAULT_PHOTO_FRAMING, PHOTO_FRAMING_BOUNDS, clampFraming, isDefaultFraming } from '@dloizides/site-template-kit/framing';
|
|
3
3
|
import { useState, useRef, useEffect, useCallback, useMemo } from 'react';
|
|
4
|
-
import { StyleSheet, View, Text, useWindowDimensions } from 'react-native';
|
|
4
|
+
import { StyleSheet, View, Text, useWindowDimensions, Image } from 'react-native';
|
|
5
5
|
import { Button, IconButton } from '@dloizides/ui-buttons';
|
|
6
6
|
import { useUi } from '@dloizides/ui-feedback';
|
|
7
7
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
8
|
-
import { LAYOUT_COLLAPSE_BREAKPOINT } from '@dloizides/ui-layout';
|
|
8
|
+
import { MIN_TARGET_PX, LAYOUT_COLLAPSE_BREAKPOINT } from '@dloizides/ui-layout';
|
|
9
9
|
|
|
10
10
|
// src/framing/photoFraming.ts
|
|
11
11
|
var framingToTransform = (framing) => [
|
|
@@ -15,30 +15,31 @@ var framingToTransform = (framing) => [
|
|
|
15
15
|
];
|
|
16
16
|
|
|
17
17
|
// src/framing/FramingAction.ts
|
|
18
|
-
var FramingAction = {
|
|
19
|
-
ZoomIn
|
|
20
|
-
ZoomOut
|
|
21
|
-
MoveUp
|
|
22
|
-
MoveDown
|
|
23
|
-
MoveLeft
|
|
24
|
-
MoveRight
|
|
25
|
-
Reset
|
|
26
|
-
|
|
18
|
+
var FramingAction = /* @__PURE__ */ ((FramingAction2) => {
|
|
19
|
+
FramingAction2["ZoomIn"] = "zoomIn";
|
|
20
|
+
FramingAction2["ZoomOut"] = "zoomOut";
|
|
21
|
+
FramingAction2["MoveUp"] = "moveUp";
|
|
22
|
+
FramingAction2["MoveDown"] = "moveDown";
|
|
23
|
+
FramingAction2["MoveLeft"] = "moveLeft";
|
|
24
|
+
FramingAction2["MoveRight"] = "moveRight";
|
|
25
|
+
FramingAction2["Reset"] = "reset";
|
|
26
|
+
return FramingAction2;
|
|
27
|
+
})(FramingAction || {});
|
|
27
28
|
|
|
28
29
|
// src/framing/stepFraming.ts
|
|
29
30
|
var PHOTO_FRAMING_STEPS = Object.freeze({ offsetPct: 5, scale: 0.1 });
|
|
30
31
|
var PRECISION = 1e3;
|
|
31
32
|
var round = (n) => Math.round(n * PRECISION) / PRECISION;
|
|
32
33
|
var DIRECTIONS = {
|
|
33
|
-
[
|
|
34
|
-
[
|
|
35
|
-
[
|
|
36
|
-
[
|
|
37
|
-
[
|
|
38
|
-
[
|
|
34
|
+
["zoomIn" /* ZoomIn */]: [0, 0, 1],
|
|
35
|
+
["zoomOut" /* ZoomOut */]: [0, 0, -1],
|
|
36
|
+
["moveUp" /* MoveUp */]: [0, -1, 0],
|
|
37
|
+
["moveDown" /* MoveDown */]: [0, 1, 0],
|
|
38
|
+
["moveLeft" /* MoveLeft */]: [-1, 0, 0],
|
|
39
|
+
["moveRight" /* MoveRight */]: [1, 0, 0]
|
|
39
40
|
};
|
|
40
41
|
function stepFraming(current, action, steps = PHOTO_FRAMING_STEPS) {
|
|
41
|
-
if (action ===
|
|
42
|
+
if (action === "reset" /* Reset */) return DEFAULT_PHOTO_FRAMING;
|
|
42
43
|
const base = clampFraming(current);
|
|
43
44
|
const [dx, dy, ds] = DIRECTIONS[action];
|
|
44
45
|
return clampFraming({
|
|
@@ -54,12 +55,13 @@ function canStepFraming(current, action, steps = PHOTO_FRAMING_STEPS) {
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
// src/ImagePickerButton/ImagePickerStatus.ts
|
|
57
|
-
var ImagePickerStatus = {
|
|
58
|
-
Idle
|
|
59
|
-
Uploading
|
|
60
|
-
Error
|
|
61
|
-
Done
|
|
62
|
-
|
|
58
|
+
var ImagePickerStatus = /* @__PURE__ */ ((ImagePickerStatus2) => {
|
|
59
|
+
ImagePickerStatus2["Idle"] = "idle";
|
|
60
|
+
ImagePickerStatus2["Uploading"] = "uploading";
|
|
61
|
+
ImagePickerStatus2["Error"] = "error";
|
|
62
|
+
ImagePickerStatus2["Done"] = "done";
|
|
63
|
+
return ImagePickerStatus2;
|
|
64
|
+
})(ImagePickerStatus || {});
|
|
63
65
|
var DEFAULT_IMAGE_ACCEPT = "image/*";
|
|
64
66
|
function pickWebImage(accept = DEFAULT_IMAGE_ACCEPT) {
|
|
65
67
|
if (typeof document === "undefined") return Promise.resolve(null);
|
|
@@ -80,7 +82,7 @@ function useImageUpload({
|
|
|
80
82
|
onUploaded
|
|
81
83
|
}) {
|
|
82
84
|
const [status, setStatus] = useState(
|
|
83
|
-
hasImage ?
|
|
85
|
+
hasImage ? "done" /* Done */ : "idle" /* Idle */
|
|
84
86
|
);
|
|
85
87
|
const busy = useRef(false);
|
|
86
88
|
const mounted = useRef(true);
|
|
@@ -100,11 +102,11 @@ function useImageUpload({
|
|
|
100
102
|
try {
|
|
101
103
|
const file = await pickFile();
|
|
102
104
|
if (file === null) return;
|
|
103
|
-
settle(
|
|
105
|
+
settle("uploading" /* Uploading */);
|
|
104
106
|
uploaded = { result: await upload(file) };
|
|
105
|
-
settle(
|
|
107
|
+
settle("done" /* Done */);
|
|
106
108
|
} catch (error) {
|
|
107
|
-
settle(
|
|
109
|
+
settle("error" /* Error */);
|
|
108
110
|
onError?.(error);
|
|
109
111
|
} finally {
|
|
110
112
|
busy.current = false;
|
|
@@ -115,11 +117,11 @@ function useImageUpload({
|
|
|
115
117
|
}
|
|
116
118
|
function resolvePickerView(status, labels) {
|
|
117
119
|
switch (status) {
|
|
118
|
-
case
|
|
120
|
+
case "uploading" /* Uploading */:
|
|
119
121
|
return { buttonLabel: labels.uploading, variant: "outline", statusText: null, isError: false };
|
|
120
|
-
case
|
|
122
|
+
case "error" /* Error */:
|
|
121
123
|
return { buttonLabel: labels.retry, variant: "danger", statusText: labels.error, isError: true };
|
|
122
|
-
case
|
|
124
|
+
case "done" /* Done */:
|
|
123
125
|
return { buttonLabel: labels.replace, variant: "outline", statusText: labels.done, isError: false };
|
|
124
126
|
default:
|
|
125
127
|
return { buttonLabel: labels.pick, variant: "primary", statusText: null, isError: false };
|
|
@@ -152,7 +154,7 @@ function ImagePickerButton({
|
|
|
152
154
|
onUploaded
|
|
153
155
|
});
|
|
154
156
|
const view = useMemo(() => resolvePickerView(status, labels), [status, labels]);
|
|
155
|
-
const isUploading = status ===
|
|
157
|
+
const isUploading = status === "uploading" /* Uploading */;
|
|
156
158
|
const statusColor = view.isError ? theme.semantic.error["500"] : theme.colors.textSecondary;
|
|
157
159
|
return /* @__PURE__ */ jsxs(View, { style: styles.root, testID, children: [
|
|
158
160
|
/* @__PURE__ */ jsx(
|
|
@@ -180,7 +182,7 @@ function ImagePickerButton({
|
|
|
180
182
|
) : null
|
|
181
183
|
] });
|
|
182
184
|
}
|
|
183
|
-
var TARGET =
|
|
185
|
+
var TARGET = MIN_TARGET_PX;
|
|
184
186
|
var GAP = 8;
|
|
185
187
|
var SECTION_GAP = 16;
|
|
186
188
|
var HEADING_SIZE = 13;
|
|
@@ -188,13 +190,13 @@ var READOUT_MIN_WIDTH = 56;
|
|
|
188
190
|
var READOUT_SIZE = 15;
|
|
189
191
|
var PERCENT = 100;
|
|
190
192
|
var DEFAULT_GLYPHS = {
|
|
191
|
-
[
|
|
192
|
-
[
|
|
193
|
-
[
|
|
194
|
-
[
|
|
195
|
-
[
|
|
196
|
-
[
|
|
197
|
-
[
|
|
193
|
+
["zoomIn" /* ZoomIn */]: "+",
|
|
194
|
+
["zoomOut" /* ZoomOut */]: "\u2212",
|
|
195
|
+
["moveUp" /* MoveUp */]: "\u2191",
|
|
196
|
+
["moveDown" /* MoveDown */]: "\u2193",
|
|
197
|
+
["moveLeft" /* MoveLeft */]: "\u2190",
|
|
198
|
+
["moveRight" /* MoveRight */]: "\u2192",
|
|
199
|
+
["reset" /* Reset */]: "\u21BA"
|
|
198
200
|
};
|
|
199
201
|
var styles2 = StyleSheet.create({
|
|
200
202
|
root: { gap: SECTION_GAP },
|
|
@@ -232,26 +234,26 @@ var FramingControls = ({
|
|
|
232
234
|
/* @__PURE__ */ jsxs(View, { style: styles2.section, children: [
|
|
233
235
|
/* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: [styles2.heading, heading], children: labels.size }),
|
|
234
236
|
/* @__PURE__ */ jsxs(View, { style: styles2.row, children: [
|
|
235
|
-
control(
|
|
237
|
+
control("zoomOut" /* ZoomOut */),
|
|
236
238
|
/* @__PURE__ */ jsx(Text, { style: [styles2.readout, { color: theme.colors.text }], testID: `${testID}-scale`, children: labels.scaleValue(Math.round(framing.scale * PERCENT)) }),
|
|
237
|
-
control(
|
|
239
|
+
control("zoomIn" /* ZoomIn */)
|
|
238
240
|
] })
|
|
239
241
|
] }),
|
|
240
242
|
/* @__PURE__ */ jsxs(View, { style: styles2.section, children: [
|
|
241
243
|
/* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: [styles2.heading, heading], children: labels.position }),
|
|
242
244
|
/* @__PURE__ */ jsxs(View, { style: styles2.row, children: [
|
|
243
245
|
/* @__PURE__ */ jsx(View, { style: styles2.spacer }),
|
|
244
|
-
control(
|
|
246
|
+
control("moveUp" /* MoveUp */),
|
|
245
247
|
/* @__PURE__ */ jsx(View, { style: styles2.spacer })
|
|
246
248
|
] }),
|
|
247
249
|
/* @__PURE__ */ jsxs(View, { style: styles2.row, children: [
|
|
248
|
-
control(
|
|
249
|
-
control(
|
|
250
|
-
control(
|
|
250
|
+
control("moveLeft" /* MoveLeft */),
|
|
251
|
+
control("reset" /* Reset */),
|
|
252
|
+
control("moveRight" /* MoveRight */)
|
|
251
253
|
] }),
|
|
252
254
|
/* @__PURE__ */ jsxs(View, { style: styles2.row, children: [
|
|
253
255
|
/* @__PURE__ */ jsx(View, { style: styles2.spacer }),
|
|
254
|
-
control(
|
|
256
|
+
control("moveDown" /* MoveDown */),
|
|
255
257
|
/* @__PURE__ */ jsx(View, { style: styles2.spacer })
|
|
256
258
|
] })
|
|
257
259
|
] })
|
|
@@ -259,12 +261,13 @@ var FramingControls = ({
|
|
|
259
261
|
};
|
|
260
262
|
|
|
261
263
|
// src/PhotoFramingEditor/PhotoAnchor.ts
|
|
262
|
-
var PhotoAnchor = {
|
|
263
|
-
Center
|
|
264
|
-
Bottom
|
|
265
|
-
|
|
264
|
+
var PhotoAnchor = /* @__PURE__ */ ((PhotoAnchor3) => {
|
|
265
|
+
PhotoAnchor3["Center"] = "center";
|
|
266
|
+
PhotoAnchor3["Bottom"] = "bottom";
|
|
267
|
+
return PhotoAnchor3;
|
|
268
|
+
})(PhotoAnchor || {});
|
|
266
269
|
function resolvePhotoAnchor(anchor) {
|
|
267
|
-
return anchor ===
|
|
270
|
+
return anchor === "bottom" /* Bottom */ ? { justifyContent: "flex-end", objectPosition: "center bottom" } : { justifyContent: "center", objectPosition: "center center" };
|
|
268
271
|
}
|
|
269
272
|
var GAP2 = 16;
|
|
270
273
|
var styles3 = StyleSheet.create({
|
|
@@ -282,7 +285,7 @@ var PhotoFramingEditor = ({
|
|
|
282
285
|
steps,
|
|
283
286
|
renderGlyph,
|
|
284
287
|
disabled = false,
|
|
285
|
-
anchor =
|
|
288
|
+
anchor = "center" /* Center */
|
|
286
289
|
}) => {
|
|
287
290
|
const { width } = useWindowDimensions();
|
|
288
291
|
const wide = width >= LAYOUT_COLLAPSE_BREAKPOINT;
|
|
@@ -317,6 +320,57 @@ var PhotoFramingEditor = ({
|
|
|
317
320
|
] });
|
|
318
321
|
};
|
|
319
322
|
|
|
320
|
-
|
|
323
|
+
// src/AnchoredPhoto/resolveAnchoredPhotoLayout.ts
|
|
324
|
+
function resolveAnchoredPhotoLayout(anchor, aspectRatio) {
|
|
325
|
+
const { justifyContent } = resolvePhotoAnchor(anchor);
|
|
326
|
+
const usable = aspectRatio !== null && Number.isFinite(aspectRatio) && aspectRatio > 0;
|
|
327
|
+
return { justifyContent, aspectRatio: usable ? aspectRatio : null };
|
|
328
|
+
}
|
|
329
|
+
function useImageAspectRatio(uri) {
|
|
330
|
+
const [measured, setMeasured] = useState(null);
|
|
331
|
+
useEffect(() => {
|
|
332
|
+
if (uri === "") return void 0;
|
|
333
|
+
let active = true;
|
|
334
|
+
Image.getSize(
|
|
335
|
+
uri,
|
|
336
|
+
(width, height) => {
|
|
337
|
+
if (active && width > 0 && height > 0) setMeasured({ uri, ratio: width / height });
|
|
338
|
+
},
|
|
339
|
+
() => void 0
|
|
340
|
+
);
|
|
341
|
+
return () => {
|
|
342
|
+
active = false;
|
|
343
|
+
};
|
|
344
|
+
}, [uri]);
|
|
345
|
+
return measured?.uri === uri ? measured.ratio : null;
|
|
346
|
+
}
|
|
347
|
+
var styles4 = StyleSheet.create({
|
|
348
|
+
frame: { ...StyleSheet.absoluteFillObject, alignItems: "center" },
|
|
349
|
+
fill: { height: "100%", width: "100%" },
|
|
350
|
+
sized: { maxHeight: "100%", width: "100%" }
|
|
351
|
+
});
|
|
352
|
+
var AnchoredPhoto = ({
|
|
353
|
+
uri,
|
|
354
|
+
anchor = "center" /* Center */,
|
|
355
|
+
framing,
|
|
356
|
+
style,
|
|
357
|
+
accessibilityLabel,
|
|
358
|
+
testID
|
|
359
|
+
}) => {
|
|
360
|
+
const layout = resolveAnchoredPhotoLayout(anchor, useImageAspectRatio(uri));
|
|
361
|
+
const transform = framingToTransform(clampFraming(framing));
|
|
362
|
+
const imageStyle = layout.aspectRatio === null ? styles4.fill : [styles4.sized, { aspectRatio: layout.aspectRatio }];
|
|
363
|
+
return /* @__PURE__ */ jsx(View, { style: [styles4.frame, { justifyContent: layout.justifyContent, transform }, style], testID, children: /* @__PURE__ */ jsx(
|
|
364
|
+
Image,
|
|
365
|
+
{
|
|
366
|
+
accessibilityLabel,
|
|
367
|
+
resizeMode: "contain",
|
|
368
|
+
source: { uri },
|
|
369
|
+
style: imageStyle
|
|
370
|
+
}
|
|
371
|
+
) });
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
export { AnchoredPhoto, DEFAULT_IMAGE_ACCEPT, FramingAction, ImagePickerButton, ImagePickerStatus, PHOTO_FRAMING_STEPS, PhotoAnchor, PhotoFramingEditor, canStepFraming, framingToTransform, pickWebImage, resolveAnchoredPhotoLayout, resolvePhotoAnchor, resolvePickerView, stepFraming, useImageAspectRatio, useImageUpload };
|
|
321
375
|
//# sourceMappingURL=index.mjs.map
|
|
322
376
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/framing/photoFraming.ts","../src/framing/FramingAction.ts","../src/framing/stepFraming.ts","../src/ImagePickerButton/ImagePickerStatus.ts","../src/ImagePickerButton/useImageUpload.ts","../src/ImagePickerButton/ImagePickerButton.tsx","../src/PhotoFramingEditor/FramingControls.tsx","../src/PhotoFramingEditor/PhotoAnchor.ts","../src/PhotoFramingEditor/PhotoFramingEditor.tsx"],"names":["useCallback","styles","StyleSheet","useUi","jsx","Text","jsxs","View","GAP","useMemo"],"mappings":";;;;;;;;;;AAiCO,IAAM,kBAAA,GAAqB,CAAC,OAAA,KAAiD;AAAA,EAClF,EAAE,UAAA,EAAY,CAAA,EAAG,OAAA,CAAQ,CAAC,CAAA,CAAA,CAAA,EAAI;AAAA,EAC9B,EAAE,UAAA,EAAY,CAAA,EAAG,OAA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A;AACF,GAAA,EACF,CAAA;AAEJ","file":"index.mjs","sourcesContent":["/**\n * Photo framing: the `{x, y, scale}` an organiser sets on a performer card.\n *\n * The bounds, default, clamp and identity check come from\n * `@dloizides/site-template-kit/framing` — the same module the kefi-landings\n * renderer builds its `--photo-tf` CSS from (KEFI-PEOPLE-1 T12 \"Organizer people\n * editor: shared photo framing\"). One copy, so the editor can never offer a value\n * the landing page would silently clamp away.\n *\n * That subpath imports nothing (no ajv, no JSON Schema), so this file stays\n * framework-free: it backs the `@dloizides/ui-media/framing` subpath.\n */\nimport type { PhotoFraming } from '@dloizides/site-template-kit/framing';\n\nexport {\n PHOTO_FRAMING_BOUNDS,\n DEFAULT_PHOTO_FRAMING,\n clampFraming,\n isDefaultFraming,\n} from '@dloizides/site-template-kit/framing';\nexport type { PhotoFraming, PhotoFramingInput } from '@dloizides/site-template-kit/framing';\n\n/**\n * An RN `transform` array. Percent translates are relative to the element\n * itself on RN-web, matching the landing page's CSS `translate(x%, y%) scale(s)`.\n * Typed locally so this module stays free of a react-native import.\n */\nexport type PhotoFramingTransform = [\n { translateX: `${number}%` },\n { translateY: `${number}%` },\n { scale: number },\n];\n\nexport const framingToTransform = (framing: PhotoFraming): PhotoFramingTransform => [\n { translateX: `${framing.x}%` },\n { translateY: `${framing.y}%` },\n { scale: framing.scale },\n];\n","/**\n * The seven controls of the framing editor. An `as const` object rather than a\n * TS `const enum`: a const enum shipped in a .d.ts cannot be read by consumers\n * compiled with `isolatedModules` (every Expo / Babel portal).\n */\nexport const FramingAction = {\n ZoomIn: 'zoomIn',\n ZoomOut: 'zoomOut',\n MoveUp: 'moveUp',\n MoveDown: 'moveDown',\n MoveLeft: 'moveLeft',\n MoveRight: 'moveRight',\n Reset: 'reset',\n} as const;\n\nexport type FramingAction = (typeof FramingAction)[keyof typeof FramingAction];\n","import { FramingAction } from './FramingAction';\nimport type { PhotoFraming, PhotoFramingInput } from './photoFraming';\nimport { DEFAULT_PHOTO_FRAMING, clampFraming } from './photoFraming';\n\n/** How far one press moves or zooms. */\nexport interface PhotoFramingSteps {\n /** Nudge per press, % of the card. */\n offsetPct: number;\n /** Zoom per press, as a scale delta. */\n scale: number;\n}\n\nexport const PHOTO_FRAMING_STEPS: PhotoFramingSteps = Object.freeze({ offsetPct: 5, scale: 0.1 });\n\n/** Three decimals, the same precision the landing page writes into its CSS. */\nconst PRECISION = 1000;\nconst round = (n: number): number => Math.round(n * PRECISION) / PRECISION;\n\ntype MoveAction = Exclude<FramingAction, typeof FramingAction.Reset>;\n\n/** [x, y, scale] direction of each non-reset action. */\nconst DIRECTIONS: Record<MoveAction, readonly [number, number, number]> = {\n [FramingAction.ZoomIn]: [0, 0, 1],\n [FramingAction.ZoomOut]: [0, 0, -1],\n [FramingAction.MoveUp]: [0, -1, 0],\n [FramingAction.MoveDown]: [0, 1, 0],\n [FramingAction.MoveLeft]: [-1, 0, 0],\n [FramingAction.MoveRight]: [1, 0, 0],\n};\n\n/**\n * Applies one control press. The result is always clamped and rounded, so ten\n * presses of +0.1 land on exactly 2, not 1.9999999999999998.\n */\nexport function stepFraming(\n current: PhotoFramingInput | null | undefined,\n action: FramingAction,\n steps: PhotoFramingSteps = PHOTO_FRAMING_STEPS,\n): PhotoFraming {\n if (action === FramingAction.Reset) return DEFAULT_PHOTO_FRAMING;\n const base = clampFraming(current);\n const [dx, dy, ds] = DIRECTIONS[action];\n return clampFraming({\n x: round(base.x + dx * steps.offsetPct),\n y: round(base.y + dy * steps.offsetPct),\n scale: round(base.scale + ds * steps.scale),\n });\n}\n\n/** False when the press would change nothing (at a bound, or reset on the default). */\nexport function canStepFraming(\n current: PhotoFramingInput | null | undefined,\n action: FramingAction,\n steps: PhotoFramingSteps = PHOTO_FRAMING_STEPS,\n): boolean {\n const base = clampFraming(current);\n const next = stepFraming(base, action, steps);\n return next.x !== base.x || next.y !== base.y || next.scale !== base.scale;\n}\n","/**\n * The four states of an image upload slot (KEFI-PEOPLE-1 design board \"upload\n * slot\"). An `as const` object, not a `const enum`, so Babel / isolatedModules\n * consumers can read it from the published .d.ts.\n */\nexport const ImagePickerStatus = {\n Idle: 'idle',\n Uploading: 'uploading',\n Error: 'error',\n Done: 'done',\n} as const;\n\nexport type ImagePickerStatus = (typeof ImagePickerStatus)[keyof typeof ImagePickerStatus];\n","import { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { ImagePickerStatus } from './ImagePickerStatus';\n\nexport const DEFAULT_IMAGE_ACCEPT = 'image/*';\n\n/**\n * Opens the browser's file dialog for ONE file. Resolves `null` on cancel, and\n * where there is no DOM (native) — a native consumer passes its own `pickFile`.\n */\nexport function pickWebImage(accept: string = DEFAULT_IMAGE_ACCEPT): Promise<File | null> {\n if (typeof document === 'undefined') return Promise.resolve(null);\n return new Promise((resolve) => {\n const input = document.createElement('input');\n input.type = 'file';\n input.accept = accept;\n input.addEventListener('change', () => resolve(input.files?.[0] ?? null), { once: true });\n input.addEventListener('cancel', () => resolve(null), { once: true });\n input.click();\n });\n}\n\nexport interface UseImageUploadOptions<TFile, TResult = void> {\n /** Consumer-owned transport. Resolve = stored; reject = error state. No network code lives here. */\n upload: (file: TFile) => Promise<TResult>;\n /** Given what `upload` resolved with (e.g. the stored URL), once the slot is `done`. */\n onUploaded?: (result: TResult) => void;\n /** Picks one file; `null` means the user cancelled. */\n pickFile: () => Promise<TFile | null>;\n /** Start in `done` when the slot already holds an image. */\n hasImage?: boolean;\n /** Told about a failed pick or upload (logging / toasts). */\n onError?: (error: unknown) => void;\n}\n\nexport interface ImageUploadState {\n status: ImagePickerStatus;\n /** Pick then upload. A second call while one is in flight is ignored. */\n pick: () => Promise<void>;\n}\n\n/**\n * The upload slot's state machine: idle -> uploading -> done | error, and from\n * done or error back to uploading on the next pick. A cancelled pick leaves the\n * state as it was, so cancelling \"Replace\" does not wipe a finished upload.\n */\nexport function useImageUpload<TFile, TResult = void>({\n upload,\n pickFile,\n hasImage = false,\n onError,\n onUploaded,\n}: UseImageUploadOptions<TFile, TResult>): ImageUploadState {\n const [status, setStatus] = useState<ImagePickerStatus>(\n hasImage ? ImagePickerStatus.Done : ImagePickerStatus.Idle,\n );\n const busy = useRef(false);\n const mounted = useRef(true);\n\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n\n const settle = useCallback((next: ImagePickerStatus): void => {\n if (mounted.current) setStatus(next);\n }, []);\n\n const pick = useCallback(async (): Promise<void> => {\n if (busy.current) return;\n busy.current = true;\n // Boxed so a falsy / void result still counts as uploaded.\n let uploaded: { result: TResult } | null = null;\n try {\n const file = await pickFile();\n if (file === null) return;\n settle(ImagePickerStatus.Uploading);\n uploaded = { result: await upload(file) };\n settle(ImagePickerStatus.Done);\n } catch (error) {\n settle(ImagePickerStatus.Error);\n onError?.(error);\n } finally {\n busy.current = false;\n }\n // Outside the try: a throwing consumer callback must not repaint a stored upload as failed.\n if (uploaded !== null) onUploaded?.(uploaded.result);\n }, [pickFile, upload, onError, onUploaded, settle]);\n\n return { status, pick };\n}\n","/**\r\n * ImagePickerButton — one upload slot: pick an image, hand it to the consumer's\r\n * `upload` function, show idle / uploading / error / done.\r\n *\r\n * No network code and no copy of its own: the transport is a prop and every\r\n * string arrives through `labels`, so each portal passes its FM() keys.\r\n */\r\nimport React, { useCallback, useMemo } from 'react';\r\n\r\nimport { StyleSheet, Text, View } from 'react-native';\r\n\r\nimport { Button } from '@dloizides/ui-buttons';\r\nimport type { ButtonVariant } from '@dloizides/ui-buttons';\r\nimport { useUi } from '@dloizides/ui-feedback';\r\n\r\nimport { ImagePickerStatus } from './ImagePickerStatus';\r\nimport { DEFAULT_IMAGE_ACCEPT, pickWebImage, useImageUpload } from './useImageUpload';\r\n\r\nexport interface ImagePickerLabels {\r\n /** Button, idle: \"Add photo\". */\r\n pick: string;\r\n /** Button, uploading: \"Uploading...\". */\r\n uploading: string;\r\n /** Button, done: \"Replace photo\". */\r\n replace: string;\r\n /** Button, error: \"Try again\". */\r\n retry: string;\r\n /** Status line after a successful upload: \"Photo saved\". */\r\n done: string;\r\n /** Status line after a failure: \"Upload failed\". */\r\n error: string;\r\n /** Accessibility hint for the button: \"Opens a file picker to choose an image\". */\r\n hint: string;\r\n}\r\n\r\nexport interface ImagePickerButtonProps<TFile = File, TResult = void> {\r\n /** Consumer transport; whatever it resolves with (e.g. the stored URL) goes to `onUploaded`. */\r\n upload: (file: TFile) => Promise<TResult>;\r\n /** Called with `upload`'s result once the slot is `done`. */\r\n onUploaded?: (result: TResult) => void;\r\n labels: ImagePickerLabels;\r\n testID: string;\r\n /** Defaults to the browser file dialog. Native consumers pass their own picker. */\r\n pickFile?: () => Promise<TFile | null>;\r\n /** `accept` for the default web picker. Default `image/*`. */\r\n accept?: string;\r\n /** Start in the `done` state (the slot already has an image). */\r\n hasImage?: boolean;\r\n onError?: (error: unknown) => void;\r\n disabled?: boolean;\r\n}\r\n\r\nexport interface PickerView {\r\n buttonLabel: string;\r\n variant: ButtonVariant;\r\n statusText: string | null;\r\n /** Paint the status line in the theme's error colour. */\r\n isError: boolean;\r\n}\r\n\r\n/** Pure status -> copy/variant mapping (unit-tested; the component only paints it). */\r\nexport function resolvePickerView(status: ImagePickerStatus, labels: ImagePickerLabels): PickerView {\r\n switch (status) {\r\n case ImagePickerStatus.Uploading:\r\n return { buttonLabel: labels.uploading, variant: 'outline', statusText: null, isError: false };\r\n case ImagePickerStatus.Error:\r\n return { buttonLabel: labels.retry, variant: 'danger', statusText: labels.error, isError: true };\r\n case ImagePickerStatus.Done:\r\n return { buttonLabel: labels.replace, variant: 'outline', statusText: labels.done, isError: false };\r\n default:\r\n return { buttonLabel: labels.pick, variant: 'primary', statusText: null, isError: false };\r\n }\r\n}\r\n\r\nconst STATUS_GAP = 6;\r\nconst STATUS_FONT_SIZE = 13;\r\n\r\nconst styles = StyleSheet.create({\r\n root: { alignItems: 'flex-start', gap: STATUS_GAP },\r\n status: { fontSize: STATUS_FONT_SIZE },\r\n});\r\n\r\nexport function ImagePickerButton<TFile = File, TResult = void>({\r\n upload,\r\n onUploaded,\r\n labels,\r\n testID,\r\n pickFile,\r\n accept = DEFAULT_IMAGE_ACCEPT,\r\n hasImage,\r\n onError,\r\n disabled = false,\r\n}: ImagePickerButtonProps<TFile, TResult>): React.ReactElement {\r\n const { theme } = useUi();\r\n // The default picker yields a DOM File; a consumer with another TFile supplies `pickFile`.\r\n const webPick = useCallback(() => pickWebImage(accept) as Promise<TFile | null>, [accept]);\r\n const { status, pick } = useImageUpload<TFile, TResult>({\r\n upload,\r\n pickFile: pickFile ?? webPick,\r\n hasImage,\r\n onError,\r\n onUploaded,\r\n });\r\n const view = useMemo(() => resolvePickerView(status, labels), [status, labels]);\r\n const isUploading = status === ImagePickerStatus.Uploading;\r\n const statusColor = view.isError ? theme.semantic.error['500'] : theme.colors.textSecondary;\r\n\r\n return (\r\n <View style={styles.root} testID={testID}>\r\n <Button\r\n accessibilityHint={labels.hint}\r\n accessibilityLabel={view.buttonLabel}\r\n autoLoading={false}\r\n disabled={disabled || isUploading}\r\n label={view.buttonLabel}\r\n loading={isUploading}\r\n testID={`${testID}-button`}\r\n variant={view.variant}\r\n onPress={pick}\r\n />\r\n {view.statusText !== null ? (\r\n <Text\r\n accessibilityLiveRegion=\"polite\"\r\n style={[styles.status, { color: statusColor }]}\r\n testID={`${testID}-status`}\r\n >\r\n {view.statusText}\r\n </Text>\r\n ) : null}\r\n </View>\r\n );\r\n}\r\n","/**\n * The editor's controls: a zoom stepper (minus, readout, plus) and a 3x3\n * position d-pad with reset in the middle. Every control is a 44px ui-buttons\n * IconButton, disabled when the press would change nothing (at a bound).\n */\nimport React from 'react';\n\nimport { StyleSheet, Text, View } from 'react-native';\n\nimport { IconButton } from '@dloizides/ui-buttons';\nimport { useUi } from '@dloizides/ui-feedback';\n\nimport { FramingAction } from '../framing/FramingAction';\nimport type { PhotoFraming } from '../framing/photoFraming';\nimport type { PhotoFramingSteps } from '../framing/stepFraming';\nimport { canStepFraming } from '../framing/stepFraming';\nimport type { PhotoFramingLabels } from './types';\n\n/** WCAG AA touch target; IconButton `md` is this size, the d-pad spacers match it. */\nconst TARGET = 44;\nconst GAP = 8;\nconst SECTION_GAP = 16;\nconst HEADING_SIZE = 13;\nconst READOUT_MIN_WIDTH = 56;\nconst READOUT_SIZE = 15;\nconst PERCENT = 100;\n\nconst DEFAULT_GLYPHS: Record<FramingAction, string> = {\n [FramingAction.ZoomIn]: '+',\n [FramingAction.ZoomOut]: '−',\n [FramingAction.MoveUp]: '↑',\n [FramingAction.MoveDown]: '↓',\n [FramingAction.MoveLeft]: '←',\n [FramingAction.MoveRight]: '→',\n [FramingAction.Reset]: '↺',\n};\n\nconst styles = StyleSheet.create({\n root: { gap: SECTION_GAP },\n section: { gap: GAP },\n heading: { fontSize: HEADING_SIZE, fontWeight: '600' },\n row: { flexDirection: 'row', alignItems: 'center', gap: GAP },\n readout: { minWidth: READOUT_MIN_WIDTH, textAlign: 'center', fontSize: READOUT_SIZE },\n spacer: { width: TARGET, height: TARGET },\n});\n\ninterface FramingControlsProps {\n framing: PhotoFraming;\n steps?: PhotoFramingSteps;\n labels: PhotoFramingLabels;\n onAction: (action: FramingAction) => void;\n renderGlyph?: (action: FramingAction, color: string, size: number) => React.ReactNode;\n disabled: boolean;\n testID: string;\n}\n\nexport const FramingControls = ({\n framing,\n steps,\n labels,\n onAction,\n renderGlyph,\n disabled,\n testID,\n}: FramingControlsProps): React.ReactElement => {\n const { theme } = useUi();\n\n const control = (action: FramingAction): React.ReactElement => (\n <IconButton\n accessibilityHint={labels.actions[action].hint}\n actionLabel={labels.actions[action].label}\n autoLoading={false}\n disabled={disabled || !canStepFraming(framing, action, steps)}\n renderIcon={(color, size) =>\n renderGlyph ? (\n renderGlyph(action, color, size)\n ) : (\n <Text accessible={false} style={{ color, fontSize: size }}>\n {DEFAULT_GLYPHS[action]}\n </Text>\n )\n }\n showLabel={false}\n testID={`${testID}-${action}`}\n onPress={() => onAction(action)}\n />\n );\n const heading = { color: theme.colors.textSecondary };\n\n return (\n <View style={styles.root}>\n <View style={styles.section}>\n <Text accessibilityRole=\"header\" style={[styles.heading, heading]}>\n {labels.size}\n </Text>\n <View style={styles.row}>\n {control(FramingAction.ZoomOut)}\n <Text style={[styles.readout, { color: theme.colors.text }]} testID={`${testID}-scale`}>\n {labels.scaleValue(Math.round(framing.scale * PERCENT))}\n </Text>\n {control(FramingAction.ZoomIn)}\n </View>\n </View>\n <View style={styles.section}>\n <Text accessibilityRole=\"header\" style={[styles.heading, heading]}>\n {labels.position}\n </Text>\n <View style={styles.row}>\n <View style={styles.spacer} />\n {control(FramingAction.MoveUp)}\n <View style={styles.spacer} />\n </View>\n <View style={styles.row}>\n {control(FramingAction.MoveLeft)}\n {control(FramingAction.Reset)}\n {control(FramingAction.MoveRight)}\n </View>\n <View style={styles.row}>\n <View style={styles.spacer} />\n {control(FramingAction.MoveDown)}\n <View style={styles.spacer} />\n </View>\n </View>\n </View>\n );\n};\n","/**\n * Where the photo sits inside the preview frame. `Bottom` matches a kefi-landings\n * cut-out (`.amb-photo img`: 4:5, `object-fit: contain`, `object-position: center\n * bottom`) — feet on the floor of the card. An `as const` object rather than a TS\n * `const enum` for the same isolatedModules reason as FramingAction.\n */\nexport const PhotoAnchor = {\n Center: 'center',\n Bottom: 'bottom',\n} as const;\n\nexport type PhotoAnchor = (typeof PhotoAnchor)[keyof typeof PhotoAnchor];\n\nexport interface PhotoAnchorLayout {\n /** Applied to the editor's preview column: where the consumer's card sits vertically. */\n justifyContent: 'center' | 'flex-end';\n /** CSS `object-position` the consumer spreads onto its `<img>` / RN-web image. */\n objectPosition: 'center center' | 'center bottom';\n}\n\n/** Pure anchor -> layout mapping (unit-tested; the editor only applies it). */\nexport function resolvePhotoAnchor(anchor: PhotoAnchor): PhotoAnchorLayout {\n return anchor === PhotoAnchor.Bottom\n ? { justifyContent: 'flex-end', objectPosition: 'center bottom' }\n : { justifyContent: 'center', objectPosition: 'center center' };\n}\n","/**\n * PhotoFramingEditor — the KEFI-PEOPLE-1 \"A2\" framing screen: a live preview of\n * the consumer's own card (render prop) beside a zoom stepper and a position\n * d-pad. The value is `{x, y, scale}`, clamped to PHOTO_FRAMING_BOUNDS, the same\n * rules the public landing page applies — the preview is what ships.\n *\n * Narrow first: preview stacked over the controls; from ui-layout's\n * LAYOUT_COLLAPSE_BREAKPOINT up they sit side by side.\n */\nimport React, { useCallback, useMemo } from 'react';\n\nimport { StyleSheet, View, useWindowDimensions } from 'react-native';\n\nimport { LAYOUT_COLLAPSE_BREAKPOINT } from '@dloizides/ui-layout';\n\nimport type { FramingAction } from '../framing/FramingAction';\nimport { clampFraming, framingToTransform } from '../framing/photoFraming';\nimport { stepFraming } from '../framing/stepFraming';\nimport { FramingControls } from './FramingControls';\nimport { PhotoAnchor, resolvePhotoAnchor } from './PhotoAnchor';\nimport type { PhotoFramingEditorProps } from './types';\n\nconst GAP = 16;\n\nconst styles = StyleSheet.create({\n root: { flexDirection: 'column', gap: GAP, alignItems: 'stretch' },\n rootWide: { flexDirection: 'row', alignItems: 'flex-start' },\n preview: { alignItems: 'center', overflow: 'hidden' },\n previewWide: { flexShrink: 1 },\n});\n\nexport const PhotoFramingEditor = ({\n value,\n onChange,\n renderPreview,\n labels,\n testID,\n steps,\n renderGlyph,\n disabled = false,\n anchor = PhotoAnchor.Center,\n}: PhotoFramingEditorProps): React.ReactElement => {\n const { width } = useWindowDimensions();\n const wide = width >= LAYOUT_COLLAPSE_BREAKPOINT;\n const framing = useMemo(() => clampFraming(value), [value]);\n const transform = useMemo(() => framingToTransform(framing), [framing]);\n const anchorLayout = useMemo(() => resolvePhotoAnchor(anchor), [anchor]);\n\n const onAction = useCallback(\n (action: FramingAction): void => onChange(stepFraming(framing, action, steps)),\n [framing, onChange, steps],\n );\n\n return (\n <View style={[styles.root, wide ? styles.rootWide : null]} testID={testID}>\n <View\n style={[styles.preview, { justifyContent: anchorLayout.justifyContent }, wide ? styles.previewWide : null]}\n testID={`${testID}-preview`}\n >\n {renderPreview({ framing, transform, anchor, objectPosition: anchorLayout.objectPosition })}\n </View>\n <FramingControls\n disabled={disabled}\n framing={framing}\n labels={labels}\n renderGlyph={renderGlyph}\n steps={steps}\n testID={testID}\n onAction={onAction}\n />\n </View>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/framing/photoFraming.ts","../src/framing/FramingAction.ts","../src/framing/stepFraming.ts","../src/ImagePickerButton/ImagePickerStatus.ts","../src/ImagePickerButton/useImageUpload.ts","../src/ImagePickerButton/ImagePickerButton.tsx","../src/PhotoFramingEditor/FramingControls.tsx","../src/PhotoFramingEditor/PhotoAnchor.ts","../src/PhotoFramingEditor/PhotoFramingEditor.tsx","../src/AnchoredPhoto/resolveAnchoredPhotoLayout.ts","../src/AnchoredPhoto/useImageAspectRatio.ts","../src/AnchoredPhoto/AnchoredPhoto.tsx"],"names":["FramingAction","ImagePickerStatus","useCallback","styles","StyleSheet","useUi","jsx","Text","jsxs","View","PhotoAnchor","GAP","useMemo","useState","useEffect","Image"],"mappings":";;;;;;;;;;AAgCO,IAAM,kBAAA,GAAqB,CAAC,OAAA,KAAiD;AAAA,EAClF,EAAE,UAAA,EAAY,CAAA,EAAG,OAAA,CAAQ,CAAC,CAAA,CAAA,CAAA,EAAI;AAAA,EAC9B,EAAE,UAAA,EAAY,CAAA,EAAG,OAAA,CAAQ,CAAC,CAAA,CAAA,CAAA,EAAI;AAAA,EAC9B,EAAE,KAAA,EAAO,OAAA,CAAQ,KAAA;AACnB;;;ACnCO,IAAW,aAAA,qBAAAA,cAAAA,KAAX;AACL,EAAAA,eAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,eAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,eAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,eAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,eAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,eAAA,WAAA,CAAA,GAAY,WAAA;AACZ,EAAAA,eAAA,OAAA,CAAA,GAAQ,OAAA;AAPQ,E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AAM,UAAA,GAAa,MAAA,CAAO,WAAA,KAAgB,IAAA,GACtCD,OAAAA,CAAO,IAAA,GACP,CAACA,OAAAA,CAAO,KAAA,EAAO,EAAE,WAAA,EAAa,MAAA,CAAO,aAAa,CAAA;AAEtD,EAAA,uBACEG,GAAAA,CAACG,IAAAA,EAAA,EAAK,KAAA,EAAO,CAACN,OAAAA,CAAO,KAAA,EAAO,EAAE,cAAA,EAAgB,OAAO,cAAA,EAAgB,SAAA,IAAa,KAAK,CAAA,EAAG,QACxF,QAAA,kBAAAG,GAAAA;AAAA,IAACS,KAAAA;AAAA,IAAA;AAAA,MACC,kBAAA;AAAA,MACA,UAAA,EAAW,SAAA;AAAA,MACX,MAAA,EAAQ,EAAE,GAAA,EAAI;AAAA,MACd,KAAA,EAAO;AAAA;AAAA,GACT,EACF,CAAA;AAEJ","file":"index.mjs","sourcesContent":["/**\n * Photo framing: the `{x, y, scale}` an editor sets on a photo card.\n *\n * The bounds, default, clamp and identity check come from\n * `@dloizides/site-template-kit/framing` — the same module the static landing\n * renderer builds its `--photo-tf` CSS from. One copy, so the editor can never offer a value\n * the landing page would silently clamp away.\n *\n * That subpath imports nothing (no ajv, no JSON Schema), so this file stays\n * framework-free: it backs the `@dloizides/ui-media/framing` subpath.\n */\nimport type { PhotoFraming } from '@dloizides/site-template-kit/framing';\n\nexport {\n PHOTO_FRAMING_BOUNDS,\n DEFAULT_PHOTO_FRAMING,\n clampFraming,\n isDefaultFraming,\n} from '@dloizides/site-template-kit/framing';\nexport type { PhotoFraming, PhotoFramingInput } from '@dloizides/site-template-kit/framing';\n\n/**\n * An RN `transform` array. Percent translates are relative to the element\n * itself on RN-web, matching the landing page's CSS `translate(x%, y%) scale(s)`.\n * Typed locally so this module stays free of a react-native import.\n */\nexport type PhotoFramingTransform = [\n { translateX: `${number}%` },\n { translateY: `${number}%` },\n { scale: number },\n];\n\nexport const framingToTransform = (framing: PhotoFraming): PhotoFramingTransform => [\n { translateX: `${framing.x}%` },\n { translateY: `${framing.y}%` },\n { scale: framing.scale },\n];\n","/** The seven controls of the framing editor. */\nexport const enum FramingAction {\n ZoomIn = 'zoomIn',\n ZoomOut = 'zoomOut',\n MoveUp = 'moveUp',\n MoveDown = 'moveDown',\n MoveLeft = 'moveLeft',\n MoveRight = 'moveRight',\n Reset = 'reset',\n}\n","import { FramingAction } from './FramingAction';\nimport type { PhotoFraming, PhotoFramingInput } from './photoFraming';\nimport { DEFAULT_PHOTO_FRAMING, clampFraming } from './photoFraming';\n\n/** How far one press moves or zooms. */\nexport interface PhotoFramingSteps {\n /** Nudge per press, % of the card. */\n offsetPct: number;\n /** Zoom per press, as a scale delta. */\n scale: number;\n}\n\nexport const PHOTO_FRAMING_STEPS: PhotoFramingSteps = Object.freeze({ offsetPct: 5, scale: 0.1 });\n\n/** Three decimals, the same precision the landing page writes into its CSS. */\nconst PRECISION = 1000;\nconst round = (n: number): number => Math.round(n * PRECISION) / PRECISION;\n\ntype MoveAction = Exclude<FramingAction, FramingAction.Reset>;\n\n/** [x, y, scale] direction of each non-reset action. */\nconst DIRECTIONS: Record<MoveAction, readonly [number, number, number]> = {\n [FramingAction.ZoomIn]: [0, 0, 1],\n [FramingAction.ZoomOut]: [0, 0, -1],\n [FramingAction.MoveUp]: [0, -1, 0],\n [FramingAction.MoveDown]: [0, 1, 0],\n [FramingAction.MoveLeft]: [-1, 0, 0],\n [FramingAction.MoveRight]: [1, 0, 0],\n};\n\n/**\n * Applies one control press. The result is always clamped and rounded, so ten\n * presses of +0.1 land on exactly 2, not 1.9999999999999998.\n */\nexport function stepFraming(\n current: PhotoFramingInput | null | undefined,\n action: FramingAction,\n steps: PhotoFramingSteps = PHOTO_FRAMING_STEPS,\n): PhotoFraming {\n if (action === FramingAction.Reset) return DEFAULT_PHOTO_FRAMING;\n const base = clampFraming(current);\n const [dx, dy, ds] = DIRECTIONS[action];\n return clampFraming({\n x: round(base.x + dx * steps.offsetPct),\n y: round(base.y + dy * steps.offsetPct),\n scale: round(base.scale + ds * steps.scale),\n });\n}\n\n/** False when the press would change nothing (at a bound, or reset on the default). */\nexport function canStepFraming(\n current: PhotoFramingInput | null | undefined,\n action: FramingAction,\n steps: PhotoFramingSteps = PHOTO_FRAMING_STEPS,\n): boolean {\n const base = clampFraming(current);\n const next = stepFraming(base, action, steps);\n return next.x !== base.x || next.y !== base.y || next.scale !== base.scale;\n}\n","/** The four states of an image upload slot. */\nexport const enum ImagePickerStatus {\n Idle = 'idle',\n Uploading = 'uploading',\n Error = 'error',\n Done = 'done',\n}\n","import { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { ImagePickerStatus } from './ImagePickerStatus';\n\nexport const DEFAULT_IMAGE_ACCEPT = 'image/*';\n\n/**\n * Opens the browser's file dialog for ONE file. Resolves `null` on cancel, and\n * where there is no DOM (native) — a native consumer passes its own `pickFile`.\n */\nexport function pickWebImage(accept: string = DEFAULT_IMAGE_ACCEPT): Promise<File | null> {\n if (typeof document === 'undefined') return Promise.resolve(null);\n return new Promise((resolve) => {\n const input = document.createElement('input');\n input.type = 'file';\n input.accept = accept;\n input.addEventListener('change', () => resolve(input.files?.[0] ?? null), { once: true });\n input.addEventListener('cancel', () => resolve(null), { once: true });\n input.click();\n });\n}\n\nexport interface UseImageUploadOptions<TFile, TResult = void> {\n /** Consumer-owned transport. Resolve = stored; reject = error state. No network code lives here. */\n upload: (file: TFile) => Promise<TResult>;\n /** Given what `upload` resolved with (e.g. the stored URL), once the slot is `done`. */\n onUploaded?: (result: TResult) => void;\n /** Picks one file; `null` means the user cancelled. */\n pickFile: () => Promise<TFile | null>;\n /** Start in `done` when the slot already holds an image. */\n hasImage?: boolean;\n /** Told about a failed pick or upload (logging / toasts). */\n onError?: (error: unknown) => void;\n}\n\nexport interface ImageUploadState {\n status: ImagePickerStatus;\n /** Pick then upload. A second call while one is in flight is ignored. */\n pick: () => Promise<void>;\n}\n\n/**\n * The upload slot's state machine: idle -> uploading -> done | error, and from\n * done or error back to uploading on the next pick. A cancelled pick leaves the\n * state as it was, so cancelling \"Replace\" does not wipe a finished upload.\n */\nexport function useImageUpload<TFile, TResult = void>({\n upload,\n pickFile,\n hasImage = false,\n onError,\n onUploaded,\n}: UseImageUploadOptions<TFile, TResult>): ImageUploadState {\n const [status, setStatus] = useState<ImagePickerStatus>(\n hasImage ? ImagePickerStatus.Done : ImagePickerStatus.Idle,\n );\n const busy = useRef(false);\n const mounted = useRef(true);\n\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n\n const settle = useCallback((next: ImagePickerStatus): void => {\n if (mounted.current) setStatus(next);\n }, []);\n\n const pick = useCallback(async (): Promise<void> => {\n if (busy.current) return;\n busy.current = true;\n // Boxed so a falsy / void result still counts as uploaded.\n let uploaded: { result: TResult } | null = null;\n try {\n const file = await pickFile();\n if (file === null) return;\n settle(ImagePickerStatus.Uploading);\n uploaded = { result: await upload(file) };\n settle(ImagePickerStatus.Done);\n } catch (error) {\n settle(ImagePickerStatus.Error);\n onError?.(error);\n } finally {\n busy.current = false;\n }\n // Outside the try: a throwing consumer callback must not repaint a stored upload as failed.\n if (uploaded !== null) onUploaded?.(uploaded.result);\n }, [pickFile, upload, onError, onUploaded, settle]);\n\n return { status, pick };\n}\n","/**\r\n * ImagePickerButton — one upload slot: pick an image, hand it to the consumer's\r\n * `upload` function, show idle / uploading / error / done.\r\n *\r\n * No network code and no copy of its own: the transport is a prop and every\r\n * string arrives through `labels`, so each portal passes its FM() keys.\r\n */\r\nimport React, { useCallback, useMemo } from 'react';\r\n\r\nimport { StyleSheet, Text, View } from 'react-native';\r\n\r\nimport { Button } from '@dloizides/ui-buttons';\r\nimport type { ButtonVariant } from '@dloizides/ui-buttons';\r\nimport { useUi } from '@dloizides/ui-feedback';\r\n\r\nimport { ImagePickerStatus } from './ImagePickerStatus';\r\nimport { DEFAULT_IMAGE_ACCEPT, pickWebImage, useImageUpload } from './useImageUpload';\r\n\r\nexport interface ImagePickerLabels {\r\n /** Button, idle: \"Add photo\". */\r\n pick: string;\r\n /** Button, uploading: \"Uploading...\". */\r\n uploading: string;\r\n /** Button, done: \"Replace photo\". */\r\n replace: string;\r\n /** Button, error: \"Try again\". */\r\n retry: string;\r\n /** Status line after a successful upload: \"Photo saved\". */\r\n done: string;\r\n /** Status line after a failure: \"Upload failed\". */\r\n error: string;\r\n /** Accessibility hint for the button: \"Opens a file picker to choose an image\". */\r\n hint: string;\r\n}\r\n\r\nexport interface ImagePickerButtonProps<TFile = File, TResult = void> {\r\n /** Consumer transport; whatever it resolves with (e.g. the stored URL) goes to `onUploaded`. */\r\n upload: (file: TFile) => Promise<TResult>;\r\n /** Called with `upload`'s result once the slot is `done`. */\r\n onUploaded?: (result: TResult) => void;\r\n labels: ImagePickerLabels;\r\n testID: string;\r\n /** Defaults to the browser file dialog. Native consumers pass their own picker. */\r\n pickFile?: () => Promise<TFile | null>;\r\n /** `accept` for the default web picker. Default `image/*`. */\r\n accept?: string;\r\n /** Start in the `done` state (the slot already has an image). */\r\n hasImage?: boolean;\r\n onError?: (error: unknown) => void;\r\n disabled?: boolean;\r\n}\r\n\r\nexport interface PickerView {\r\n buttonLabel: string;\r\n variant: ButtonVariant;\r\n statusText: string | null;\r\n /** Paint the status line in the theme's error colour. */\r\n isError: boolean;\r\n}\r\n\r\n/** Pure status -> copy/variant mapping (unit-tested; the component only paints it). */\r\nexport function resolvePickerView(status: ImagePickerStatus, labels: ImagePickerLabels): PickerView {\r\n switch (status) {\r\n case ImagePickerStatus.Uploading:\r\n return { buttonLabel: labels.uploading, variant: 'outline', statusText: null, isError: false };\r\n case ImagePickerStatus.Error:\r\n return { buttonLabel: labels.retry, variant: 'danger', statusText: labels.error, isError: true };\r\n case ImagePickerStatus.Done:\r\n return { buttonLabel: labels.replace, variant: 'outline', statusText: labels.done, isError: false };\r\n default:\r\n return { buttonLabel: labels.pick, variant: 'primary', statusText: null, isError: false };\r\n }\r\n}\r\n\r\nconst STATUS_GAP = 6;\r\nconst STATUS_FONT_SIZE = 13;\r\n\r\nconst styles = StyleSheet.create({\r\n root: { alignItems: 'flex-start', gap: STATUS_GAP },\r\n status: { fontSize: STATUS_FONT_SIZE },\r\n});\r\n\r\nexport function ImagePickerButton<TFile = File, TResult = void>({\r\n upload,\r\n onUploaded,\r\n labels,\r\n testID,\r\n pickFile,\r\n accept = DEFAULT_IMAGE_ACCEPT,\r\n hasImage,\r\n onError,\r\n disabled = false,\r\n}: ImagePickerButtonProps<TFile, TResult>): React.ReactElement {\r\n const { theme } = useUi();\r\n // The default picker yields a DOM File; a consumer with another TFile supplies `pickFile`.\r\n const webPick = useCallback(() => pickWebImage(accept) as Promise<TFile | null>, [accept]);\r\n const { status, pick } = useImageUpload<TFile, TResult>({\r\n upload,\r\n pickFile: pickFile ?? webPick,\r\n hasImage,\r\n onError,\r\n onUploaded,\r\n });\r\n const view = useMemo(() => resolvePickerView(status, labels), [status, labels]);\r\n const isUploading = status === ImagePickerStatus.Uploading;\r\n const statusColor = view.isError ? theme.semantic.error['500'] : theme.colors.textSecondary;\r\n\r\n return (\r\n <View style={styles.root} testID={testID}>\r\n <Button\r\n accessibilityHint={labels.hint}\r\n accessibilityLabel={view.buttonLabel}\r\n autoLoading={false}\r\n disabled={disabled || isUploading}\r\n label={view.buttonLabel}\r\n loading={isUploading}\r\n testID={`${testID}-button`}\r\n variant={view.variant}\r\n onPress={pick}\r\n />\r\n {view.statusText !== null ? (\r\n <Text\r\n accessibilityLiveRegion=\"polite\"\r\n style={[styles.status, { color: statusColor }]}\r\n testID={`${testID}-status`}\r\n >\r\n {view.statusText}\r\n </Text>\r\n ) : null}\r\n </View>\r\n );\r\n}\r\n","/**\n * The editor's controls: a zoom stepper (minus, readout, plus) and a 3x3\n * position d-pad with reset in the middle. Every control is a 44px ui-buttons\n * IconButton, disabled when the press would change nothing (at a bound).\n */\nimport React from 'react';\n\nimport { StyleSheet, Text, View } from 'react-native';\n\nimport { IconButton } from '@dloizides/ui-buttons';\nimport { useUi } from '@dloizides/ui-feedback';\nimport { MIN_TARGET_PX } from '@dloizides/ui-layout';\n\nimport { FramingAction } from '../framing/FramingAction';\nimport type { PhotoFraming } from '../framing/photoFraming';\nimport type { PhotoFramingSteps } from '../framing/stepFraming';\nimport { canStepFraming } from '../framing/stepFraming';\nimport type { PhotoFramingLabels } from './types';\n\n/** IconButton `md` is ui-layout's minimum hit box; the d-pad spacers match it. */\nconst TARGET = MIN_TARGET_PX;\nconst GAP = 8;\nconst SECTION_GAP = 16;\nconst HEADING_SIZE = 13;\nconst READOUT_MIN_WIDTH = 56;\nconst READOUT_SIZE = 15;\nconst PERCENT = 100;\n\nconst DEFAULT_GLYPHS: Record<FramingAction, string> = {\n [FramingAction.ZoomIn]: '+',\n [FramingAction.ZoomOut]: '−',\n [FramingAction.MoveUp]: '↑',\n [FramingAction.MoveDown]: '↓',\n [FramingAction.MoveLeft]: '←',\n [FramingAction.MoveRight]: '→',\n [FramingAction.Reset]: '↺',\n};\n\nconst styles = StyleSheet.create({\n root: { gap: SECTION_GAP },\n section: { gap: GAP },\n heading: { fontSize: HEADING_SIZE, fontWeight: '600' },\n row: { flexDirection: 'row', alignItems: 'center', gap: GAP },\n readout: { minWidth: READOUT_MIN_WIDTH, textAlign: 'center', fontSize: READOUT_SIZE },\n spacer: { width: TARGET, height: TARGET },\n});\n\ninterface FramingControlsProps {\n framing: PhotoFraming;\n steps?: PhotoFramingSteps;\n labels: PhotoFramingLabels;\n onAction: (action: FramingAction) => void;\n renderGlyph?: (action: FramingAction, color: string, size: number) => React.ReactNode;\n disabled: boolean;\n testID: string;\n}\n\nexport const FramingControls = ({\n framing,\n steps,\n labels,\n onAction,\n renderGlyph,\n disabled,\n testID,\n}: FramingControlsProps): React.ReactElement => {\n const { theme } = useUi();\n\n const control = (action: FramingAction): React.ReactElement => (\n <IconButton\n accessibilityHint={labels.actions[action].hint}\n actionLabel={labels.actions[action].label}\n autoLoading={false}\n disabled={disabled || !canStepFraming(framing, action, steps)}\n renderIcon={(color, size) =>\n renderGlyph ? (\n renderGlyph(action, color, size)\n ) : (\n <Text accessible={false} style={{ color, fontSize: size }}>\n {DEFAULT_GLYPHS[action]}\n </Text>\n )\n }\n showLabel={false}\n testID={`${testID}-${action}`}\n onPress={() => onAction(action)}\n />\n );\n const heading = { color: theme.colors.textSecondary };\n\n return (\n <View style={styles.root}>\n <View style={styles.section}>\n <Text accessibilityRole=\"header\" style={[styles.heading, heading]}>\n {labels.size}\n </Text>\n <View style={styles.row}>\n {control(FramingAction.ZoomOut)}\n <Text style={[styles.readout, { color: theme.colors.text }]} testID={`${testID}-scale`}>\n {labels.scaleValue(Math.round(framing.scale * PERCENT))}\n </Text>\n {control(FramingAction.ZoomIn)}\n </View>\n </View>\n <View style={styles.section}>\n <Text accessibilityRole=\"header\" style={[styles.heading, heading]}>\n {labels.position}\n </Text>\n <View style={styles.row}>\n <View style={styles.spacer} />\n {control(FramingAction.MoveUp)}\n <View style={styles.spacer} />\n </View>\n <View style={styles.row}>\n {control(FramingAction.MoveLeft)}\n {control(FramingAction.Reset)}\n {control(FramingAction.MoveRight)}\n </View>\n <View style={styles.row}>\n <View style={styles.spacer} />\n {control(FramingAction.MoveDown)}\n <View style={styles.spacer} />\n </View>\n </View>\n </View>\n );\n};\n","/**\n * Where the photo sits inside its frame. `Bottom` is for cut-out portraits\n * (`object-fit: contain; object-position: center bottom`): feet on the floor of\n * the card.\n */\nexport const enum PhotoAnchor {\n Center = 'center',\n Bottom = 'bottom',\n}\n\nexport interface PhotoAnchorLayout {\n /** Applied to the editor's preview column: where the consumer's card sits vertically. */\n justifyContent: 'center' | 'flex-end';\n /** CSS `object-position` the consumer spreads onto its `<img>` / RN-web image. */\n objectPosition: 'center center' | 'center bottom';\n}\n\n/** Pure anchor -> layout mapping (unit-tested; the editor only applies it). */\nexport function resolvePhotoAnchor(anchor: PhotoAnchor): PhotoAnchorLayout {\n return anchor === PhotoAnchor.Bottom\n ? { justifyContent: 'flex-end', objectPosition: 'center bottom' }\n : { justifyContent: 'center', objectPosition: 'center center' };\n}\n","/**\n * PhotoFramingEditor — a photo framing screen: a live preview of\n * the consumer's own card (render prop) beside a zoom stepper and a position\n * d-pad. The value is `{x, y, scale}`, clamped to PHOTO_FRAMING_BOUNDS, the same\n * rules the public landing page applies — the preview is what ships.\n *\n * Narrow first: preview stacked over the controls; from ui-layout's\n * LAYOUT_COLLAPSE_BREAKPOINT up they sit side by side.\n */\nimport React, { useCallback, useMemo } from 'react';\n\nimport { StyleSheet, View, useWindowDimensions } from 'react-native';\n\nimport { LAYOUT_COLLAPSE_BREAKPOINT } from '@dloizides/ui-layout';\n\nimport type { FramingAction } from '../framing/FramingAction';\nimport { clampFraming, framingToTransform } from '../framing/photoFraming';\nimport { stepFraming } from '../framing/stepFraming';\nimport { FramingControls } from './FramingControls';\nimport { PhotoAnchor, resolvePhotoAnchor } from './PhotoAnchor';\nimport type { PhotoFramingEditorProps } from './types';\n\nconst GAP = 16;\n\nconst styles = StyleSheet.create({\n root: { flexDirection: 'column', gap: GAP, alignItems: 'stretch' },\n rootWide: { flexDirection: 'row', alignItems: 'flex-start' },\n preview: { alignItems: 'center', overflow: 'hidden' },\n previewWide: { flexShrink: 1 },\n});\n\nexport const PhotoFramingEditor = ({\n value,\n onChange,\n renderPreview,\n labels,\n testID,\n steps,\n renderGlyph,\n disabled = false,\n anchor = PhotoAnchor.Center,\n}: PhotoFramingEditorProps): React.ReactElement => {\n const { width } = useWindowDimensions();\n const wide = width >= LAYOUT_COLLAPSE_BREAKPOINT;\n const framing = useMemo(() => clampFraming(value), [value]);\n const transform = useMemo(() => framingToTransform(framing), [framing]);\n const anchorLayout = useMemo(() => resolvePhotoAnchor(anchor), [anchor]);\n\n const onAction = useCallback(\n (action: FramingAction): void => onChange(stepFraming(framing, action, steps)),\n [framing, onChange, steps],\n );\n\n return (\n <View style={[styles.root, wide ? styles.rootWide : null]} testID={testID}>\n <View\n style={[styles.preview, { justifyContent: anchorLayout.justifyContent }, wide ? styles.previewWide : null]}\n testID={`${testID}-preview`}\n >\n {renderPreview({ framing, transform, anchor, objectPosition: anchorLayout.objectPosition })}\n </View>\n <FramingControls\n disabled={disabled}\n framing={framing}\n labels={labels}\n renderGlyph={renderGlyph}\n steps={steps}\n testID={testID}\n onAction={onAction}\n />\n </View>\n );\n};\n","import { PhotoAnchor, resolvePhotoAnchor } from '../PhotoFramingEditor/PhotoAnchor';\nimport type { PhotoAnchorLayout } from '../PhotoFramingEditor/PhotoAnchor';\n\nexport interface AnchoredPhotoLayout {\n /** Main-axis placement of the photo inside its full-box frame. */\n justifyContent: PhotoAnchorLayout['justifyContent'];\n /**\n * `null` = fill the box (size unknown yet, image stays centred by `contain`);\n * a number = size the image to that width / height so the frame can anchor it.\n */\n aspectRatio: number | null;\n}\n\n/** Pure anchor + measured aspect -> layout (unit-tested; AnchoredPhoto only paints it). */\nexport function resolveAnchoredPhotoLayout(\n anchor: PhotoAnchor,\n aspectRatio: number | null,\n): AnchoredPhotoLayout {\n const { justifyContent } = resolvePhotoAnchor(anchor);\n const usable = aspectRatio !== null && Number.isFinite(aspectRatio) && aspectRatio > 0;\n return { justifyContent, aspectRatio: usable ? aspectRatio : null };\n}\n","/**\n * Natural width / height of a remote image, or null until it is known (or the\n * size lookup fails). AnchoredPhoto needs it to anchor a contained photo: RN-web's\n * Image paints a centred background, so `object-position` cannot move it, but an\n * element sized to the photo's own aspect can be pushed to an edge by flexbox.\n */\nimport { useEffect, useState } from 'react';\n\nimport { Image } from 'react-native';\n\nexport function useImageAspectRatio(uri: string): number | null {\n const [measured, setMeasured] = useState<{ uri: string; ratio: number } | null>(null);\n\n useEffect(() => {\n if (uri === '') return undefined;\n let active = true;\n Image.getSize(\n uri,\n (width, height) => {\n if (active && width > 0 && height > 0) setMeasured({ uri, ratio: width / height });\n },\n () => undefined,\n );\n return () => {\n active = false;\n };\n }, [uri]);\n\n return measured?.uri === uri ? measured.ratio : null;\n}\n","/**\n * AnchoredPhoto — a contained photo that fills its parent box, framed by a\n * `{x, y, scale}` value and anchored to the centre or the bottom edge.\n *\n * Why not `object-position`: RN-web's Image paints a centred background image,\n * so `center bottom` has no effect. Instead the image is sized to its own aspect\n * ratio (measured with `Image.getSize`) and pushed down by flexbox. The framing\n * transform sits on a full-box layer, so its percentages mean the same as the\n * CSS `translate(x%, y%) scale(s)` a static page applies to its `<img>`.\n *\n * The parent owns the box (aspect, radius, background, empty state); this renders\n * only the photo layer. No strings of its own: `accessibilityLabel` is a prop.\n */\nimport React from 'react';\n\nimport { Image, StyleSheet, View } from 'react-native';\nimport type { StyleProp, ViewStyle } from 'react-native';\n\nimport { clampFraming, framingToTransform } from '../framing/photoFraming';\nimport type { PhotoFramingInput } from '../framing/photoFraming';\nimport { PhotoAnchor } from '../PhotoFramingEditor/PhotoAnchor';\nimport { resolveAnchoredPhotoLayout } from './resolveAnchoredPhotoLayout';\nimport { useImageAspectRatio } from './useImageAspectRatio';\n\nexport interface AnchoredPhotoProps {\n uri: string;\n /** `bottom` for cut-out portraits. Default `center`. */\n anchor?: PhotoAnchor;\n /** Stored or live framing; clamped before use, so raw config is safe. */\n framing?: PhotoFramingInput | null;\n /** Extra style for the full-box frame layer. */\n style?: StyleProp<ViewStyle>;\n accessibilityLabel: string;\n testID?: string;\n}\n\nconst styles = StyleSheet.create({\n frame: { ...StyleSheet.absoluteFillObject, alignItems: 'center' },\n fill: { height: '100%', width: '100%' },\n sized: { maxHeight: '100%', width: '100%' },\n});\n\nexport const AnchoredPhoto = ({\n uri,\n anchor = PhotoAnchor.Center,\n framing,\n style,\n accessibilityLabel,\n testID,\n}: AnchoredPhotoProps): React.ReactElement => {\n const layout = resolveAnchoredPhotoLayout(anchor, useImageAspectRatio(uri));\n const transform = framingToTransform(clampFraming(framing));\n const imageStyle = layout.aspectRatio === null\n ? styles.fill\n : [styles.sized, { aspectRatio: layout.aspectRatio }];\n\n return (\n <View style={[styles.frame, { justifyContent: layout.justifyContent, transform }, style]} testID={testID}>\n <Image\n accessibilityLabel={accessibilityLabel}\n resizeMode=\"contain\"\n source={{ uri }}\n style={imageStyle}\n />\n </View>\n );\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dloizides/ui-media",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Themable React Native (RN-web) media controls: ImagePickerButton (idle/uploading/error/done around a consumer-supplied upload function) and PhotoFramingEditor (live frame preview, size stepper, position d-pad). The framing bounds and clamp are also exported from the framework-free '@dloizides/ui-media/framing' subpath. Part of the dloizides.com shared UI kit.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|