@molecule/app-exif-panel-angular 0.0.0-stage → 0.0.1-stage
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/LICENSE +202 -0
- package/README.md +542 -2
- package/dist/exif-panel.component.d.ts +121 -0
- package/dist/exif-panel.component.d.ts.map +1 -0
- package/dist/exif-panel.component.js +341 -0
- package/dist/exif-panel.component.js.map +1 -0
- package/dist/format-parts.d.ts +47 -0
- package/dist/format-parts.d.ts.map +1 -0
- package/dist/format-parts.js +88 -0
- package/dist/format-parts.js.map +1 -0
- package/dist/format.d.ts +93 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +164 -0
- package/dist/format.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +68 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/package.json +72 -4
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ExifPanel component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { Component } from '@angular/core';
|
|
7
|
+
import { useLocale, useTranslation } from '@molecule/app-angular';
|
|
8
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
9
|
+
import { buildMapLink, formatCamera, formatGps, formatTimestamp } from './format.js';
|
|
10
|
+
import { formatApertureNumber, formatFocalLengthNumber, formatIsoNumber, formatShutterNumber, } from './format-parts.js';
|
|
11
|
+
import * as i0 from "@angular/core";
|
|
12
|
+
const _forTrack0 = ($index, $item) => $item.molId;
|
|
13
|
+
function ExifPanel_For_7_Conditional_4_Template(rf, ctx) { if (rf & 1) {
|
|
14
|
+
i0.ɵɵdomElementStart(0, "a", 6);
|
|
15
|
+
i0.ɵɵtext(1);
|
|
16
|
+
i0.ɵɵdomElementEnd();
|
|
17
|
+
} if (rf & 2) {
|
|
18
|
+
const row_r1 = i0.ɵɵnextContext().$implicit;
|
|
19
|
+
const ctx_r1 = i0.ɵɵnextContext();
|
|
20
|
+
i0.ɵɵclassMap(ctx_r1.linkClasses());
|
|
21
|
+
i0.ɵɵdomProperty("href", row_r1.href, i0.ɵɵsanitizeUrl);
|
|
22
|
+
i0.ɵɵadvance();
|
|
23
|
+
i0.ɵɵtextInterpolate(row_r1.value);
|
|
24
|
+
} }
|
|
25
|
+
function ExifPanel_For_7_Conditional_5_Template(rf, ctx) { if (rf & 1) {
|
|
26
|
+
i0.ɵɵtext(0);
|
|
27
|
+
} if (rf & 2) {
|
|
28
|
+
const row_r1 = i0.ɵɵnextContext().$implicit;
|
|
29
|
+
i0.ɵɵtextInterpolate1(" ", row_r1.value, " ");
|
|
30
|
+
} }
|
|
31
|
+
function ExifPanel_For_7_Template(rf, ctx) { if (rf & 1) {
|
|
32
|
+
i0.ɵɵdomElementStart(0, "div")(1, "dt");
|
|
33
|
+
i0.ɵɵtext(2);
|
|
34
|
+
i0.ɵɵdomElementEnd();
|
|
35
|
+
i0.ɵɵdomElementStart(3, "dd");
|
|
36
|
+
i0.ɵɵconditionalCreate(4, ExifPanel_For_7_Conditional_4_Template, 2, 4, "a", 5)(5, ExifPanel_For_7_Conditional_5_Template, 1, 1);
|
|
37
|
+
i0.ɵɵdomElementEnd()();
|
|
38
|
+
} if (rf & 2) {
|
|
39
|
+
const row_r1 = ctx.$implicit;
|
|
40
|
+
const ctx_r1 = i0.ɵɵnextContext();
|
|
41
|
+
i0.ɵɵclassMap(ctx_r1.rowClasses());
|
|
42
|
+
i0.ɵɵattribute("data-mol-id", row_r1.molId);
|
|
43
|
+
i0.ɵɵadvance();
|
|
44
|
+
i0.ɵɵclassMap(ctx_r1.labelClasses());
|
|
45
|
+
i0.ɵɵadvance();
|
|
46
|
+
i0.ɵɵtextInterpolate(row_r1.label);
|
|
47
|
+
i0.ɵɵadvance();
|
|
48
|
+
i0.ɵɵclassMap(ctx_r1.valueClasses());
|
|
49
|
+
i0.ɵɵadvance();
|
|
50
|
+
i0.ɵɵconditional(row_r1.href ? 4 : 5);
|
|
51
|
+
} }
|
|
52
|
+
/**
|
|
53
|
+
* ExifPanel component.
|
|
54
|
+
*
|
|
55
|
+
* A structured renderer for already-parsed EXIF metadata — camera, lens,
|
|
56
|
+
* exposure (aperture + shutter + ISO + focal length), GPS (with optional map
|
|
57
|
+
* link), and capture timestamp. Empty / undefined fields are silently
|
|
58
|
+
* skipped.
|
|
59
|
+
*
|
|
60
|
+
* The host IS the outer `<aside>` (`aside[mol-exif-panel]`), matching React's
|
|
61
|
+
* root exactly. This is the Angular counterpart of
|
|
62
|
+
* `@molecule/app-exif-panel-react`: the same props (React names), the same
|
|
63
|
+
* ClassMap tokens, and the same DOM for the same input. All user-facing text
|
|
64
|
+
* resolves through `useTranslation()` — the exposure notations as
|
|
65
|
+
* `exifPanel.value.*` keys — and the capture timestamp formats in the app's
|
|
66
|
+
* active locale (`useLocale()`).
|
|
67
|
+
*/
|
|
68
|
+
export class ExifPanel {
|
|
69
|
+
/** Parsed EXIF metadata. */
|
|
70
|
+
exif = {};
|
|
71
|
+
/** Compact mode: smaller type and tighter spacing (React's `compact = false`). */
|
|
72
|
+
compact;
|
|
73
|
+
/** Whether to render the GPS row (React's `showGps = true`). */
|
|
74
|
+
showGps;
|
|
75
|
+
/** Optional heading override. */
|
|
76
|
+
heading;
|
|
77
|
+
/** Extra classes appended to the panel root. */
|
|
78
|
+
className;
|
|
79
|
+
/** The current class map. */
|
|
80
|
+
cm = getClassMap();
|
|
81
|
+
/** The binding's translation function (React's `useTranslation()`). */
|
|
82
|
+
i18n = useTranslation();
|
|
83
|
+
/** The app's active locale (React's `useLocale()`); re-formats the timestamp on a switch. */
|
|
84
|
+
activeLocale = useLocale();
|
|
85
|
+
/**
|
|
86
|
+
* Whether compact mode is on, with React's `false` default.
|
|
87
|
+
* @returns The effective compact flag.
|
|
88
|
+
*/
|
|
89
|
+
compactMode() {
|
|
90
|
+
return this.compact ?? false;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Whether the GPS row renders, with React's `true` default.
|
|
94
|
+
* @returns The effective `showGps` flag.
|
|
95
|
+
*/
|
|
96
|
+
gpsShown() {
|
|
97
|
+
return this.showGps ?? true;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The wrapper class list (React's `cm.cn(cm.surface, className)`).
|
|
101
|
+
* @returns The class string.
|
|
102
|
+
*/
|
|
103
|
+
classes() {
|
|
104
|
+
return this.cm.cn(this.cm.surface, this.className);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The header class list.
|
|
108
|
+
* @returns The class string.
|
|
109
|
+
*/
|
|
110
|
+
headerClasses() {
|
|
111
|
+
const pad = this.compactMode() ? 3 : 4;
|
|
112
|
+
return this.cm.cn(this.cm.sp('px', pad), this.cm.sp('py', pad), this.cm.borderB);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The eyebrow class list.
|
|
116
|
+
* @returns The class string.
|
|
117
|
+
*/
|
|
118
|
+
eyebrowClasses() {
|
|
119
|
+
return this.cm.cn(this.cm.textSize('xs'), this.cm.fontWeight('medium'), this.cm.textMuted);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The heading class list.
|
|
123
|
+
* @returns The class string.
|
|
124
|
+
*/
|
|
125
|
+
headingClasses() {
|
|
126
|
+
return this.cm.cn(this.cm.textSize(this.compactMode() ? 'sm' : 'base'), this.cm.fontWeight('bold'));
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* The label-value row class list.
|
|
130
|
+
* @returns The class string.
|
|
131
|
+
*/
|
|
132
|
+
rowClasses() {
|
|
133
|
+
const compact = this.compactMode();
|
|
134
|
+
return this.cm.cn(this.cm.flex({ align: 'start', justify: 'between', gap: compact ? 'sm' : 'md' }), this.cm.sp('px', compact ? 3 : 4), this.cm.sp('py', compact ? 2 : 3), this.cm.borderB);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The `<dt>` label class list.
|
|
138
|
+
* @returns The class string.
|
|
139
|
+
*/
|
|
140
|
+
labelClasses() {
|
|
141
|
+
return this.cm.cn(this.cm.textSize(this.compactMode() ? 'xs' : 'sm'), this.cm.fontWeight('medium'), this.cm.textMuted);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The `<dd>` value class list.
|
|
145
|
+
* @returns The class string.
|
|
146
|
+
*/
|
|
147
|
+
valueClasses() {
|
|
148
|
+
return this.cm.cn(this.cm.textSize(this.compactMode() ? 'sm' : 'base'), this.cm.textRight);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The map-link class list.
|
|
152
|
+
* @returns The class string.
|
|
153
|
+
*/
|
|
154
|
+
linkClasses() {
|
|
155
|
+
return this.cm.cn(this.cm.link);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The panel's `aria-label`.
|
|
159
|
+
* @returns The translated label.
|
|
160
|
+
*/
|
|
161
|
+
ariaLabel() {
|
|
162
|
+
return this.i18n.t('exifPanel.aria.region', {}, { defaultValue: 'EXIF metadata' });
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The eyebrow text above the heading.
|
|
166
|
+
* @returns The translated text.
|
|
167
|
+
*/
|
|
168
|
+
eyebrowText() {
|
|
169
|
+
return this.i18n.t('exifPanel.eyebrow', {}, { defaultValue: 'Frame metadata' });
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The heading, honouring a custom override.
|
|
173
|
+
* @returns The heading text.
|
|
174
|
+
*/
|
|
175
|
+
headingText() {
|
|
176
|
+
return this.heading ?? this.i18n.t('exifPanel.heading', {}, { defaultValue: 'EXIF' });
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Build every row the current EXIF object renders, in React's order.
|
|
180
|
+
* @returns The non-empty rows.
|
|
181
|
+
*/
|
|
182
|
+
rows() {
|
|
183
|
+
const exif = this.exif;
|
|
184
|
+
const camera = formatCamera(exif.make, exif.model);
|
|
185
|
+
const lens = exif.lensModel?.trim() || null;
|
|
186
|
+
const apertureDigits = formatApertureNumber(exif.fNumber);
|
|
187
|
+
const shutterDigits = formatShutterNumber(exif.exposureTime);
|
|
188
|
+
const isoDigits = formatIsoNumber(exif.iso);
|
|
189
|
+
const focalDigits = formatFocalLengthNumber(exif.focalLength);
|
|
190
|
+
const focal35Digits = formatFocalLengthNumber(exif.focalLength35mm);
|
|
191
|
+
// Each notation's digits render through t() (`exifPanel.value.*`), so a
|
|
192
|
+
// locale re-words the unit around them; the ` · ` join is punctuation.
|
|
193
|
+
const apertureText = apertureDigits === null
|
|
194
|
+
? null
|
|
195
|
+
: this.i18n.t('exifPanel.value.aperture', { value: apertureDigits }, {
|
|
196
|
+
defaultValue: 'f/{{value}}',
|
|
197
|
+
});
|
|
198
|
+
const shutterText = shutterDigits === null
|
|
199
|
+
? null
|
|
200
|
+
: this.i18n.t('exifPanel.value.shutter', { value: shutterDigits }, {
|
|
201
|
+
defaultValue: '{{value}} s',
|
|
202
|
+
});
|
|
203
|
+
const isoText = isoDigits === null
|
|
204
|
+
? null
|
|
205
|
+
: this.i18n.t('exifPanel.value.iso', { value: isoDigits }, { defaultValue: 'ISO {{value}}' });
|
|
206
|
+
const focalText = focalDigits === null
|
|
207
|
+
? null
|
|
208
|
+
: this.i18n.t('exifPanel.value.focalLength', { value: focalDigits }, {
|
|
209
|
+
defaultValue: '{{value}} mm',
|
|
210
|
+
});
|
|
211
|
+
const focal35Text = focal35Digits === null
|
|
212
|
+
? null
|
|
213
|
+
: this.i18n.t('exifPanel.value.focalLength', { value: focal35Digits }, {
|
|
214
|
+
defaultValue: '{{value}} mm',
|
|
215
|
+
});
|
|
216
|
+
const exposureParts = [apertureText, shutterText, isoText, focalText].filter((v) => v !== null);
|
|
217
|
+
const gpsText = this.gpsShown() ? formatGps(exif.gpsLatitude, exif.gpsLongitude) : null;
|
|
218
|
+
const mapHref = this.gpsShown() ? buildMapLink(exif.gpsLatitude, exif.gpsLongitude) : null;
|
|
219
|
+
const timestamp = formatTimestamp(exif.dateTimeOriginal, this.activeLocale());
|
|
220
|
+
const software = exif.software?.trim() || null;
|
|
221
|
+
const copyright = exif.copyright?.trim() || null;
|
|
222
|
+
const out = [];
|
|
223
|
+
if (camera)
|
|
224
|
+
out.push({
|
|
225
|
+
molId: 'exif-panel-row-camera',
|
|
226
|
+
label: this.i18n.t('exifPanel.camera', {}, { defaultValue: 'Camera' }),
|
|
227
|
+
value: camera,
|
|
228
|
+
});
|
|
229
|
+
if (lens)
|
|
230
|
+
out.push({
|
|
231
|
+
molId: 'exif-panel-row-lens',
|
|
232
|
+
label: this.i18n.t('exifPanel.lens', {}, { defaultValue: 'Lens' }),
|
|
233
|
+
value: lens,
|
|
234
|
+
});
|
|
235
|
+
if (exposureParts.length > 0)
|
|
236
|
+
out.push({
|
|
237
|
+
molId: 'exif-panel-row-exposure',
|
|
238
|
+
label: this.i18n.t('exifPanel.exposure', {}, { defaultValue: 'Exposure' }),
|
|
239
|
+
value: exposureParts.join(' · '),
|
|
240
|
+
});
|
|
241
|
+
if (focal35Text && focal35Text !== focalText)
|
|
242
|
+
out.push({
|
|
243
|
+
molId: 'exif-panel-row-focal35',
|
|
244
|
+
label: this.i18n.t('exifPanel.focalLength35mm', {}, { defaultValue: '35 mm equivalent' }),
|
|
245
|
+
value: focal35Text,
|
|
246
|
+
});
|
|
247
|
+
if (gpsText)
|
|
248
|
+
out.push({
|
|
249
|
+
molId: 'exif-panel-row-gps',
|
|
250
|
+
label: this.i18n.t('exifPanel.gps', {}, { defaultValue: 'GPS' }),
|
|
251
|
+
value: gpsText,
|
|
252
|
+
...(mapHref ? { href: mapHref } : {}),
|
|
253
|
+
});
|
|
254
|
+
if (timestamp)
|
|
255
|
+
out.push({
|
|
256
|
+
molId: 'exif-panel-row-timestamp',
|
|
257
|
+
label: this.i18n.t('exifPanel.timestamp', {}, { defaultValue: 'Captured' }),
|
|
258
|
+
value: timestamp,
|
|
259
|
+
});
|
|
260
|
+
if (software)
|
|
261
|
+
out.push({
|
|
262
|
+
molId: 'exif-panel-row-software',
|
|
263
|
+
label: this.i18n.t('exifPanel.software', {}, { defaultValue: 'Software' }),
|
|
264
|
+
value: software,
|
|
265
|
+
});
|
|
266
|
+
if (copyright)
|
|
267
|
+
out.push({
|
|
268
|
+
molId: 'exif-panel-row-copyright',
|
|
269
|
+
label: this.i18n.t('exifPanel.copyright', {}, { defaultValue: 'Copyright' }),
|
|
270
|
+
value: copyright,
|
|
271
|
+
});
|
|
272
|
+
return out;
|
|
273
|
+
}
|
|
274
|
+
static ɵfac = function ExifPanel_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ExifPanel)(); };
|
|
275
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ExifPanel, selectors: [["aside", "mol-exif-panel", ""]], hostVars: 4, hostBindings: function ExifPanel_HostBindings(rf, ctx) { if (rf & 2) {
|
|
276
|
+
i0.ɵɵattribute("data-mol-id", "exif-panel")("aria-label", ctx.ariaLabel());
|
|
277
|
+
i0.ɵɵclassMap(ctx.classes());
|
|
278
|
+
} }, inputs: { exif: "exif", compact: "compact", showGps: "showGps", heading: "heading", className: "className" }, decls: 8, vars: 8, consts: [["data-mol-id", "exif-panel-header"], ["data-mol-id", "exif-panel-eyebrow"], ["data-mol-id", "exif-panel-heading"], ["data-mol-id", "exif-panel-list"], [3, "class"], ["target", "_blank", "rel", "noreferrer noopener", "data-mol-id", "exif-panel-map-link", 3, "href", "class"], ["target", "_blank", "rel", "noreferrer noopener", "data-mol-id", "exif-panel-map-link", 3, "href"]], template: function ExifPanel_Template(rf, ctx) { if (rf & 1) {
|
|
279
|
+
i0.ɵɵdomElementStart(0, "header", 0)(1, "p", 1);
|
|
280
|
+
i0.ɵɵtext(2);
|
|
281
|
+
i0.ɵɵdomElementEnd();
|
|
282
|
+
i0.ɵɵdomElementStart(3, "h3", 2);
|
|
283
|
+
i0.ɵɵtext(4);
|
|
284
|
+
i0.ɵɵdomElementEnd()();
|
|
285
|
+
i0.ɵɵdomElementStart(5, "dl", 3);
|
|
286
|
+
i0.ɵɵrepeaterCreate(6, ExifPanel_For_7_Template, 6, 9, "div", 4, _forTrack0);
|
|
287
|
+
i0.ɵɵdomElementEnd();
|
|
288
|
+
} if (rf & 2) {
|
|
289
|
+
i0.ɵɵclassMap(ctx.headerClasses());
|
|
290
|
+
i0.ɵɵadvance();
|
|
291
|
+
i0.ɵɵclassMap(ctx.eyebrowClasses());
|
|
292
|
+
i0.ɵɵadvance();
|
|
293
|
+
i0.ɵɵtextInterpolate(ctx.eyebrowText());
|
|
294
|
+
i0.ɵɵadvance();
|
|
295
|
+
i0.ɵɵclassMap(ctx.headingClasses());
|
|
296
|
+
i0.ɵɵadvance();
|
|
297
|
+
i0.ɵɵtextInterpolate(ctx.headingText());
|
|
298
|
+
i0.ɵɵadvance(2);
|
|
299
|
+
i0.ɵɵrepeater(ctx.rows());
|
|
300
|
+
} }, encapsulation: 2 });
|
|
301
|
+
}
|
|
302
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ExifPanel, [{
|
|
303
|
+
type: Component,
|
|
304
|
+
args: [{
|
|
305
|
+
selector: 'aside[mol-exif-panel]',
|
|
306
|
+
standalone: true,
|
|
307
|
+
inputs: ['exif', 'compact', 'showGps', 'heading', 'className'],
|
|
308
|
+
host: {
|
|
309
|
+
'[class]': 'classes()',
|
|
310
|
+
'[attr.data-mol-id]': '"exif-panel"',
|
|
311
|
+
'[attr.aria-label]': 'ariaLabel()',
|
|
312
|
+
},
|
|
313
|
+
template: `<header data-mol-id="exif-panel-header" [class]="headerClasses()">
|
|
314
|
+
<p data-mol-id="exif-panel-eyebrow" [class]="eyebrowClasses()">{{ eyebrowText() }}</p>
|
|
315
|
+
<h3 data-mol-id="exif-panel-heading" [class]="headingClasses()">{{ headingText() }}</h3>
|
|
316
|
+
</header>
|
|
317
|
+
<dl data-mol-id="exif-panel-list">
|
|
318
|
+
@for (row of rows(); track row.molId) {
|
|
319
|
+
<div [attr.data-mol-id]="row.molId" [class]="rowClasses()">
|
|
320
|
+
<dt [class]="labelClasses()">{{ row.label }}</dt>
|
|
321
|
+
<dd [class]="valueClasses()">
|
|
322
|
+
@if (row.href) {
|
|
323
|
+
<a
|
|
324
|
+
[href]="row.href"
|
|
325
|
+
target="_blank"
|
|
326
|
+
rel="noreferrer noopener"
|
|
327
|
+
data-mol-id="exif-panel-map-link"
|
|
328
|
+
[class]="linkClasses()"
|
|
329
|
+
>{{ row.value }}</a
|
|
330
|
+
>
|
|
331
|
+
} @else {
|
|
332
|
+
{{ row.value }}
|
|
333
|
+
}
|
|
334
|
+
</dd>
|
|
335
|
+
</div>
|
|
336
|
+
}
|
|
337
|
+
</dl>`,
|
|
338
|
+
}]
|
|
339
|
+
}], null, null); })();
|
|
340
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ExifPanel, { className: "ExifPanel", filePath: "exif-panel.component.ts", lineNumber: 84 }); })();
|
|
341
|
+
//# sourceMappingURL=exif-panel.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exif-panel.component.js","sourceRoot":"","sources":["../src/exif-panel.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,EAAE,WAAW,EAAmB,MAAM,kBAAkB,CAAA;AAE/D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACpF,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,eAAe,EACf,mBAAmB,GACpB,MAAM,mBAAmB,CAAA;;;;IAkDZ,+BAMG;IAAA,YAAe;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SAAS;eAAC;gBACT,QAAQ,EAAE,uBAAuB;gBACjC,UAAU,EAAE,IAAI;gBAChB,MAAM,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC;gBAC9D,IAAI,EAAE;oBACJ,SAAS,EAAE,WAAW;oBACtB,oBAAoB,EAAE,cAAc;oBACpC,mBAAmB,EAAE,aAAa;iBACnC;gBACD,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;UAwBF;aACT;;kFACY,SAAS"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The number part of each EXIF notation, without its prefix or unit.
|
|
3
|
+
*
|
|
4
|
+
* `format.ts` joins these digits with the canonical English prefix / unit
|
|
5
|
+
* (`f/`, `s`, `ISO`, `mm`) for callers that want the plain notation. The
|
|
6
|
+
* components instead pass them to `t()` as the `{{value}}` of an
|
|
7
|
+
* `exifPanel.value.*` key, so a locale re-words the unit around the digits
|
|
8
|
+
* (Japanese `{{value}}秒`) while the digits stay this helper's.
|
|
9
|
+
*
|
|
10
|
+
* Internal to the panel — not part of the package's public exports.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* The f-number of an aperture as digits, without the `f/`.
|
|
16
|
+
*
|
|
17
|
+
* @param fNumber - The aperture value (e.g. `2.8`, `5.6`, `8`).
|
|
18
|
+
* @returns A digit string like `"2.8"` or `"8"`, or `null` when the input
|
|
19
|
+
* is missing / invalid.
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatApertureNumber(fNumber: number | undefined): string | null;
|
|
22
|
+
/**
|
|
23
|
+
* A shutter / exposure time as digits, without the `s`. Sub-second times
|
|
24
|
+
* render as a `1/x` reciprocal with the denominator rounded; longer
|
|
25
|
+
* exposures stay in seconds.
|
|
26
|
+
*
|
|
27
|
+
* @param seconds - Exposure time in seconds.
|
|
28
|
+
* @returns A digit string like `"1/125"`, `"2.5"` or `"30"`, or `null`
|
|
29
|
+
* when the input is missing / invalid.
|
|
30
|
+
*/
|
|
31
|
+
export declare function formatShutterNumber(seconds: number | undefined): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* An ISO sensitivity as digits, without the `ISO` prefix.
|
|
34
|
+
*
|
|
35
|
+
* @param iso - The ISO value (e.g. `100`, `1600`).
|
|
36
|
+
* @returns A digit string like `"1600"`, or `null` when missing.
|
|
37
|
+
*/
|
|
38
|
+
export declare function formatIsoNumber(iso: number | undefined): string | null;
|
|
39
|
+
/**
|
|
40
|
+
* A focal length as digits, without the `mm`.
|
|
41
|
+
*
|
|
42
|
+
* @param mm - Focal length in millimetres.
|
|
43
|
+
* @returns A digit string like `"50"` or `"35.5"`, or `null` when the
|
|
44
|
+
* input is missing / invalid.
|
|
45
|
+
*/
|
|
46
|
+
export declare function formatFocalLengthNumber(mm: number | undefined): string | null;
|
|
47
|
+
//# sourceMappingURL=format-parts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-parts.d.ts","sourceRoot":"","sources":["../src/format-parts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA0BH;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAG/E;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAM9E;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAGtE;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAG7E"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The number part of each EXIF notation, without its prefix or unit.
|
|
3
|
+
*
|
|
4
|
+
* `format.ts` joins these digits with the canonical English prefix / unit
|
|
5
|
+
* (`f/`, `s`, `ISO`, `mm`) for callers that want the plain notation. The
|
|
6
|
+
* components instead pass them to `t()` as the `{{value}}` of an
|
|
7
|
+
* `exifPanel.value.*` key, so a locale re-words the unit around the digits
|
|
8
|
+
* (Japanese `{{value}}秒`) while the digits stay this helper's.
|
|
9
|
+
*
|
|
10
|
+
* Internal to the panel — not part of the package's public exports.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* The digits of a quantity rounded to one decimal, a whole number's
|
|
16
|
+
* trailing `.0` dropped.
|
|
17
|
+
*
|
|
18
|
+
* @param value - A validated, positive quantity.
|
|
19
|
+
* @returns Its digit text, e.g. `"2.8"`, `"50"`.
|
|
20
|
+
*/
|
|
21
|
+
const digits = (value) => {
|
|
22
|
+
const rounded = Math.round(value * 10) / 10;
|
|
23
|
+
return Number.isInteger(rounded) ? String(rounded) : rounded.toFixed(1);
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The guard every quantity shares: a finite number above zero.
|
|
27
|
+
*
|
|
28
|
+
* @param value - The raw EXIF quantity.
|
|
29
|
+
* @returns The number, or `null` when it is missing / invalid.
|
|
30
|
+
*/
|
|
31
|
+
const positive = (value) => {
|
|
32
|
+
if (value === undefined || value === null)
|
|
33
|
+
return null;
|
|
34
|
+
if (!Number.isFinite(value) || value <= 0)
|
|
35
|
+
return null;
|
|
36
|
+
return value;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The f-number of an aperture as digits, without the `f/`.
|
|
40
|
+
*
|
|
41
|
+
* @param fNumber - The aperture value (e.g. `2.8`, `5.6`, `8`).
|
|
42
|
+
* @returns A digit string like `"2.8"` or `"8"`, or `null` when the input
|
|
43
|
+
* is missing / invalid.
|
|
44
|
+
*/
|
|
45
|
+
export function formatApertureNumber(fNumber) {
|
|
46
|
+
const value = positive(fNumber);
|
|
47
|
+
return value === null ? null : digits(value);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A shutter / exposure time as digits, without the `s`. Sub-second times
|
|
51
|
+
* render as a `1/x` reciprocal with the denominator rounded; longer
|
|
52
|
+
* exposures stay in seconds.
|
|
53
|
+
*
|
|
54
|
+
* @param seconds - Exposure time in seconds.
|
|
55
|
+
* @returns A digit string like `"1/125"`, `"2.5"` or `"30"`, or `null`
|
|
56
|
+
* when the input is missing / invalid.
|
|
57
|
+
*/
|
|
58
|
+
export function formatShutterNumber(seconds) {
|
|
59
|
+
const value = positive(seconds);
|
|
60
|
+
if (value === null)
|
|
61
|
+
return null;
|
|
62
|
+
if (value >= 1)
|
|
63
|
+
return digits(value);
|
|
64
|
+
// Round the reciprocal denominator to nearest integer for sub-second.
|
|
65
|
+
return `1/${Math.round(1 / value)}`;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* An ISO sensitivity as digits, without the `ISO` prefix.
|
|
69
|
+
*
|
|
70
|
+
* @param iso - The ISO value (e.g. `100`, `1600`).
|
|
71
|
+
* @returns A digit string like `"1600"`, or `null` when missing.
|
|
72
|
+
*/
|
|
73
|
+
export function formatIsoNumber(iso) {
|
|
74
|
+
const value = positive(iso);
|
|
75
|
+
return value === null ? null : String(Math.round(value));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A focal length as digits, without the `mm`.
|
|
79
|
+
*
|
|
80
|
+
* @param mm - Focal length in millimetres.
|
|
81
|
+
* @returns A digit string like `"50"` or `"35.5"`, or `null` when the
|
|
82
|
+
* input is missing / invalid.
|
|
83
|
+
*/
|
|
84
|
+
export function formatFocalLengthNumber(mm) {
|
|
85
|
+
const value = positive(mm);
|
|
86
|
+
return value === null ? null : digits(value);
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=format-parts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-parts.js","sourceRoot":"","sources":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;AACrC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,GAAuB;IACrD,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;IAC3B,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;AAC1D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,EAAsB;IAC5D,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC1B,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC9C,CAAC"}
|
package/dist/format.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure string-formatting helpers for EXIF values.
|
|
3
|
+
*
|
|
4
|
+
* Kept separate from the React component so they can be unit-tested
|
|
5
|
+
* without a DOM and reused by callers that want the formatted strings
|
|
6
|
+
* for non-rendering purposes (alt text, share captions, etc.).
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Format an aperture f-number as `f/N` with one decimal place dropped
|
|
12
|
+
* when whole.
|
|
13
|
+
*
|
|
14
|
+
* @param fNumber - The aperture value (e.g. `2.8`, `5.6`, `8`).
|
|
15
|
+
* @returns A display string like `"f/2.8"` or `"f/8"`, or `null` when
|
|
16
|
+
* the input is missing / invalid.
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatAperture(fNumber: number | undefined): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Format a shutter / exposure time in seconds as a human-readable
|
|
21
|
+
* string. Sub-second times are rendered as a `1/x s` reciprocal with
|
|
22
|
+
* the denominator rounded; longer exposures stay in seconds.
|
|
23
|
+
*
|
|
24
|
+
* @param seconds - Exposure time in seconds.
|
|
25
|
+
* @returns A display string like `"1/125 s"` or `"2 s"`, or `null` when
|
|
26
|
+
* the input is missing / invalid.
|
|
27
|
+
*/
|
|
28
|
+
export declare function formatShutter(seconds: number | undefined): string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Format an ISO sensitivity as `ISO N`.
|
|
31
|
+
*
|
|
32
|
+
* @param iso - The ISO value (e.g. `100`, `1600`).
|
|
33
|
+
* @returns A display string like `"ISO 1600"`, or `null` when missing.
|
|
34
|
+
*/
|
|
35
|
+
export declare function formatIso(iso: number | undefined): string | null;
|
|
36
|
+
/**
|
|
37
|
+
* Format a focal length value as `N mm`.
|
|
38
|
+
*
|
|
39
|
+
* @param mm - Focal length in millimetres.
|
|
40
|
+
* @returns A display string like `"50 mm"`, or `null` when missing.
|
|
41
|
+
*/
|
|
42
|
+
export declare function formatFocalLength(mm: number | undefined): string | null;
|
|
43
|
+
/**
|
|
44
|
+
* Format a single GPS coordinate (latitude or longitude) as
|
|
45
|
+
* deg/min/sec with a hemisphere suffix.
|
|
46
|
+
*
|
|
47
|
+
* @param value - Signed decimal degrees.
|
|
48
|
+
* @param axis - Which axis the value represents — picks `N`/`S` vs `E`/`W`.
|
|
49
|
+
* @returns A string like `"37° 25' 19.07" N"`, or `null` when missing.
|
|
50
|
+
*/
|
|
51
|
+
export declare function formatDms(value: number | undefined, axis: 'lat' | 'lon'): string | null;
|
|
52
|
+
/**
|
|
53
|
+
* Format a GPS coordinate pair as a single deg/min/sec string.
|
|
54
|
+
*
|
|
55
|
+
* @param latitude - Latitude in signed decimal degrees.
|
|
56
|
+
* @param longitude - Longitude in signed decimal degrees.
|
|
57
|
+
* @returns A combined string like `"37° 25' 19.07" N, 122° 5' 4.16" W"`,
|
|
58
|
+
* or `null` if either value is missing.
|
|
59
|
+
*/
|
|
60
|
+
export declare function formatGps(latitude: number | undefined, longitude: number | undefined): string | null;
|
|
61
|
+
/**
|
|
62
|
+
* Build an OpenStreetMap link URL for a GPS coordinate pair.
|
|
63
|
+
*
|
|
64
|
+
* @param latitude - Latitude in signed decimal degrees.
|
|
65
|
+
* @param longitude - Longitude in signed decimal degrees.
|
|
66
|
+
* @returns An `https://www.openstreetmap.org/?...` URL, or `null` when
|
|
67
|
+
* either input is missing.
|
|
68
|
+
*/
|
|
69
|
+
export declare function buildMapLink(latitude: number | undefined, longitude: number | undefined): string | null;
|
|
70
|
+
/**
|
|
71
|
+
* Format an EXIF capture timestamp. Accepts `Date`, ISO string, or
|
|
72
|
+
* epoch milliseconds and renders via `toLocaleString` so the result
|
|
73
|
+
* respects the given locale and the host environment's timezone — pass
|
|
74
|
+
* the app's active locale so the text follows a locale switch.
|
|
75
|
+
*
|
|
76
|
+
* @param value - The timestamp value pulled from EXIF.
|
|
77
|
+
* @param locale - The locale to format in (an `Intl` locale code); the
|
|
78
|
+
* host environment's locale when omitted.
|
|
79
|
+
* @returns A locale-formatted date/time string, or `null` when missing
|
|
80
|
+
* or unparseable.
|
|
81
|
+
*/
|
|
82
|
+
export declare function formatTimestamp(value: Date | string | number | undefined, locale?: string): string | null;
|
|
83
|
+
/**
|
|
84
|
+
* Compose camera make + model into a single `"Make Model"` string,
|
|
85
|
+
* collapsing duplication when the model already starts with the make
|
|
86
|
+
* (Sony often does this).
|
|
87
|
+
*
|
|
88
|
+
* @param make - Camera manufacturer.
|
|
89
|
+
* @param model - Camera model.
|
|
90
|
+
* @returns The combined label, or `null` when both inputs are missing.
|
|
91
|
+
*/
|
|
92
|
+
export declare function formatCamera(make: string | undefined, model: string | undefined): string | null;
|
|
93
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AASH;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAGzE;AAED;;;;;;;;GAQG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