@senvenli/react 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action/fab.d.ts +7 -0
- package/dist/action/fab.js +22 -3
- package/dist/action/fab.js.map +1 -1
- package/dist/collection/data-table.d.ts +1 -1
- package/dist/collection/data-table.js +2 -2
- package/dist/collection/data-table.js.map +1 -1
- package/dist/collection/table.d.ts +7 -2
- package/dist/collection/table.js +17 -7
- package/dist/collection/table.js.map +1 -1
- package/dist/i18n.d.ts +8 -0
- package/dist/i18n.js +18 -1
- package/dist/i18n.js.map +1 -1
- package/dist/navigation/index.d.ts +2 -2
- package/dist/navigation/index.js +1 -1
- package/dist/navigation/index.js.map +1 -1
- package/dist/navigation/sidebar.d.ts +18 -0
- package/dist/navigation/sidebar.js +26 -2
- package/dist/navigation/sidebar.js.map +1 -1
- package/dist/overlay/floating.js +4 -1
- package/dist/overlay/floating.js.map +1 -1
- package/dist/overlay/index.d.ts +2 -0
- package/dist/overlay/index.js +2 -1
- package/dist/overlay/index.js.map +1 -1
- package/dist/overlay/tour.d.ts +88 -0
- package/dist/overlay/tour.js +302 -0
- package/dist/overlay/tour.js.map +1 -0
- package/manifests/data-table.json +1 -1
- package/manifests/index.json +2 -1
- package/manifests/sidebar.json +55 -2
- package/manifests/table.json +2 -2
- package/package.json +2 -2
- package/dist/action/files.d.ts +0 -70
- package/dist/action/files.js +0 -156
- package/dist/action/files.js.map +0 -1
- package/dist/action/theme-toggle.d.ts +0 -43
- package/dist/action/theme-toggle.js +0 -259
- package/dist/action/theme-toggle.js.map +0 -1
- package/dist/display/image-crop.d.ts +0 -106
- package/dist/display/image-crop.js +0 -117
- package/dist/display/image-crop.js.map +0 -1
- package/dist/display/image-cropper.d.ts +0 -68
- package/dist/display/image-cropper.js +0 -284
- package/dist/display/image-cropper.js.map +0 -1
- package/dist/display/lozenge.d.ts +0 -30
- package/dist/display/lozenge.js +0 -55
- package/dist/display/lozenge.js.map +0 -1
- package/dist/display/scroll-area.d.ts +0 -29
- package/dist/display/scroll-area.js +0 -95
- package/dist/display/scroll-area.js.map +0 -1
- package/dist/feedback/cooldown.d.ts +0 -17
- package/dist/feedback/cooldown.js +0 -59
- package/dist/feedback/cooldown.js.map +0 -1
- package/dist/feedback/status-dot.d.ts +0 -23
- package/dist/feedback/status-dot.js +0 -37
- package/dist/feedback/status-dot.js.map +0 -1
- package/dist/form/input-otp.d.ts +0 -35
- package/dist/form/input-otp.js +0 -83
- package/dist/form/input-otp.js.map +0 -1
- package/dist/layout/auth-form-layout.d.ts +0 -71
- package/dist/layout/auth-form-layout.js +0 -61
- package/dist/layout/auth-form-layout.js.map +0 -1
- package/dist/layout/auth-layout.d.ts +0 -59
- package/dist/layout/auth-layout.js +0 -26
- package/dist/layout/auth-layout.js.map +0 -1
- package/dist/layout/pressable.d.ts +0 -40
- package/dist/layout/pressable.js +0 -65
- package/dist/layout/pressable.js.map +0 -1
- package/dist/layout/reset-sent-card.d.ts +0 -39
- package/dist/layout/reset-sent-card.js +0 -22
- package/dist/layout/reset-sent-card.js.map +0 -1
- package/dist/navigation/dock.d.ts +0 -27
- package/dist/navigation/dock.js +0 -47
- package/dist/navigation/dock.js.map +0 -1
- package/dist/navigation/footer.d.ts +0 -43
- package/dist/navigation/footer.js +0 -43
- package/dist/navigation/footer.js.map +0 -1
- package/dist/navigation/language-names.d.ts +0 -19
- package/dist/navigation/language-names.js +0 -79
- package/dist/navigation/language-names.js.map +0 -1
- package/dist/navigation/language-switcher.d.ts +0 -55
- package/dist/navigation/language-switcher.js +0 -53
- package/dist/navigation/language-switcher.js.map +0 -1
- package/dist/navigation/panel-header.d.ts +0 -37
- package/dist/navigation/panel-header.js +0 -50
- package/dist/navigation/panel-header.js.map +0 -1
- package/dist/navigation/toolbar.d.ts +0 -37
- package/dist/navigation/toolbar.js +0 -334
- package/dist/navigation/toolbar.js.map +0 -1
- package/dist/overlay/command-palette.d.ts +0 -53
- package/dist/overlay/command-palette.js +0 -130
- package/dist/overlay/command-palette.js.map +0 -1
- package/dist/overlay/overlay.d.ts +0 -299
- package/dist/overlay/overlay.js +0 -558
- package/dist/overlay/overlay.js.map +0 -1
- package/dist/selection/radio-card.d.ts +0 -31
- package/dist/selection/radio-card.js +0 -29
- package/dist/selection/radio-card.js.map +0 -1
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { Slider as AriaSlider, SliderThumb, SliderTrack, useLocale } from "react-aria-components";
|
|
5
|
-
import { cn } from "../utils.js";
|
|
6
|
-
import { Button } from "../action/button.js";
|
|
7
|
-
import { formatFileSize } from "../action/files.js";
|
|
8
|
-
import { ColorSwatchPicker } from "../color/color.js";
|
|
9
|
-
import { cancelLabel, colorBlackLabel, colorLightGreyLabel, colorWhiteLabel, cropAspectLabel, cropBackgroundLabel, cropCenteredLabel, cropContainLabel, cropCoverLabel, cropFitLabel, cropHelpLabel, cropKeepsAlphaLabel, cropLoadFailedLabel, cropOutputLabel, cropPositionLabel, cropRotateLeftLabel, cropRotateRightLabel, cropSaveFailedLabel, cropSaveLabel, cropSmallLabel, cropStatusLabel, cropTooLargeLabel, cropZoomInLabel, cropZoomLabel, cropZoomOutLabel, intlLocale, } from "../i18n.js";
|
|
10
|
-
import { SegmentedControl } from "../navigation/tabs.js";
|
|
11
|
-
import { SLIDER_FILL, SLIDER_RAIL, SLIDER_THUMB, SLIDER_TRACK } from "../selection/styles.js";
|
|
12
|
-
import { IconGlyph } from "./icon.js";
|
|
13
|
-
import { MAX_ZOOM, MIN_ZOOM, clampZoom, cropRegion, drawCrop, encodeWithin, extensionOf, hasAlpha, outputSize, rotatedSize, } from "./image-crop.js";
|
|
14
|
-
const STAGE_ASPECT = 16 / 10;
|
|
15
|
-
const FRAME_INSET = 0.06;
|
|
16
|
-
const ZOOM_STEP = 0.1;
|
|
17
|
-
/** Fixed paper and light grey: the frame and checkerboard draw on the photo, not on a theme surface. */
|
|
18
|
-
const CHECKER = "repeating-conic-gradient(#ebe9e6 0 25%, #fcfcfb 0 50%) 0 0 / 16px 16px";
|
|
19
|
-
const SWATCHES = ["#ffffff", "#ebe9e6", "#0e0c09"];
|
|
20
|
-
const TYPE_NAMES = { "image/jpeg": "JPEG", "image/png": "PNG", "image/webp": "WebP" };
|
|
21
|
-
/** The image behind `src`, decoded; an object URL for a file, revoked when it changes. */
|
|
22
|
-
function useSourceImage(src) {
|
|
23
|
-
const [state, setState] = React.useState({});
|
|
24
|
-
React.useEffect(() => {
|
|
25
|
-
const url = typeof src === "string" ? src : URL.createObjectURL(src);
|
|
26
|
-
let live = true;
|
|
27
|
-
setState({ url });
|
|
28
|
-
const image = new Image();
|
|
29
|
-
image.decoding = "async";
|
|
30
|
-
// A URL from a CDN must not taint the canvas, or the crop could never be read back.
|
|
31
|
-
if (typeof src === "string" && !/^(data|blob):/.test(src))
|
|
32
|
-
image.crossOrigin = "anonymous";
|
|
33
|
-
image.onload = () => live && setState({ url, loaded: { image, width: image.naturalWidth, height: image.naturalHeight } });
|
|
34
|
-
image.onerror = () => live && setState({ url, failed: true });
|
|
35
|
-
image.src = url;
|
|
36
|
-
return () => {
|
|
37
|
-
live = false;
|
|
38
|
-
if (typeof src !== "string")
|
|
39
|
-
URL.revokeObjectURL(url);
|
|
40
|
-
};
|
|
41
|
-
}, [src]);
|
|
42
|
-
return state;
|
|
43
|
-
}
|
|
44
|
-
/** The element's width in whole px, following resizes. */
|
|
45
|
-
function useWidth() {
|
|
46
|
-
const [element, setElement] = React.useState(null);
|
|
47
|
-
const [width, setWidth] = React.useState(0);
|
|
48
|
-
React.useLayoutEffect(() => {
|
|
49
|
-
if (!element)
|
|
50
|
-
return;
|
|
51
|
-
setWidth(Math.floor(element.getBoundingClientRect().width));
|
|
52
|
-
if (typeof ResizeObserver === "undefined")
|
|
53
|
-
return;
|
|
54
|
-
const observer = new ResizeObserver(([entry]) => setWidth(Math.floor(entry.contentRect.width)));
|
|
55
|
-
observer.observe(element);
|
|
56
|
-
return () => observer.disconnect();
|
|
57
|
-
}, [element]);
|
|
58
|
-
return [setElement, width, element];
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Frames one picked image to the shape a surface needs (a 16:9 cover photo, a square logo) and hands
|
|
62
|
-
* back the cropped file at the source's own pixel density: never upscaled, only scaled down to
|
|
63
|
-
* `maxOutputSize`. In `contain`, the empty area takes `background` when the output has no
|
|
64
|
-
* alpha, white by default, never black. A sunken stage dims what falls outside a white frame
|
|
65
|
-
* with thirds guides; the toolbar holds the shapes, zoom, rotation and fit. The frame is one focusable
|
|
66
|
-
* group: arrows move the image (Shift for 10%), + and − zoom, [ and ] rotate, and each change is announced.
|
|
67
|
-
* The toolbar mirrors in RTL; the image and the arrows never do.
|
|
68
|
-
*/
|
|
69
|
-
export function ImageCropper({ src, label, aspectRatio = 16 / 9, aspectPresets, fit: fitProp = "cover", background: backgroundProp = "#ffffff", outputType = "image/jpeg", quality = 0.9, maxBytes, minimumQuality, maxOutputSize = 4096, minOutputSize, fileName, onCrop, onCancel, }) {
|
|
70
|
-
const { locale } = useLocale();
|
|
71
|
-
const source = useSourceImage(src);
|
|
72
|
-
const presets = aspectPresets && aspectPresets.length > 1 ? aspectPresets : undefined;
|
|
73
|
-
const [presetId, setPresetId] = React.useState(presets?.[0]?.id);
|
|
74
|
-
const preset = presets?.find((item) => item.id === presetId) ?? presets?.[0];
|
|
75
|
-
const [fit, setFit] = React.useState(preset?.fit ?? fitProp);
|
|
76
|
-
const [background, setBackground] = React.useState(backgroundProp);
|
|
77
|
-
// Props changed later win again: a new fit or background from the surface.
|
|
78
|
-
React.useEffect(() => setFit(preset?.fit ?? fitProp), [fitProp]); // preset changes set fit themselves
|
|
79
|
-
React.useEffect(() => setBackground(backgroundProp), [backgroundProp]);
|
|
80
|
-
// `true` a failed save; "too-large" a crop over `maxBytes` at the lowest quality allowed.
|
|
81
|
-
const [saveError, setSaveError] = React.useState(false);
|
|
82
|
-
const [rotation, setRotation] = React.useState(0);
|
|
83
|
-
const [zoom, setZoom] = React.useState(1);
|
|
84
|
-
const [center, setCenter] = React.useState(null);
|
|
85
|
-
const [status, setStatus] = React.useState("");
|
|
86
|
-
const [saving, setSaving] = React.useState(false);
|
|
87
|
-
const [stageRef, stageWidth, stageElement] = useWidth();
|
|
88
|
-
const helpId = React.useId();
|
|
89
|
-
const loaded = source.loaded;
|
|
90
|
-
// A new picture starts afresh: upright, whole, centred.
|
|
91
|
-
React.useEffect(() => {
|
|
92
|
-
setRotation(0);
|
|
93
|
-
setZoom(1);
|
|
94
|
-
setCenter(null);
|
|
95
|
-
setStatus("");
|
|
96
|
-
setSaveError(false);
|
|
97
|
-
}, [source.url]);
|
|
98
|
-
const turned = loaded ? rotatedSize(loaded.width, loaded.height, rotation) : { width: 1, height: 1 };
|
|
99
|
-
const shape = preset ? preset.aspectRatio : aspectRatio;
|
|
100
|
-
const aspect = shape === "free" ? turned.width / turned.height : shape;
|
|
101
|
-
const centerX = center?.x ?? turned.width / 2;
|
|
102
|
-
const centerY = center?.y ?? turned.height / 2;
|
|
103
|
-
const region = cropRegion(turned, aspect, fit, { zoom, centerX, centerY });
|
|
104
|
-
const size = outputSize(region, { maxOutputSize, minOutputSize });
|
|
105
|
-
// The warning is about the source, not the zoom: shown when even the whole fit is under the surface's size.
|
|
106
|
-
const sourceTooSmall = outputSize(cropRegion(turned, aspect, fit, { zoom: 1, centerX, centerY }), { maxOutputSize, minOutputSize }).small;
|
|
107
|
-
const alpha = hasAlpha(outputType);
|
|
108
|
-
// The frame inside the stage: the largest rectangle of the crop's shape, inset from the edges.
|
|
109
|
-
const stageHeight = Math.round(stageWidth / STAGE_ASPECT);
|
|
110
|
-
const roomWidth = stageWidth * (1 - 2 * FRAME_INSET);
|
|
111
|
-
const roomHeight = stageHeight * (1 - 2 * FRAME_INSET);
|
|
112
|
-
const frameWidth = Math.min(roomWidth, roomHeight * aspect);
|
|
113
|
-
const frameHeight = frameWidth / aspect;
|
|
114
|
-
const frameLeft = (stageWidth - frameWidth) / 2;
|
|
115
|
-
const frameTop = (stageHeight - frameHeight) / 2;
|
|
116
|
-
const scale = region.width > 0 ? frameWidth / region.width : 0;
|
|
117
|
-
const percent = React.useMemo(() => new Intl.NumberFormat(intlLocale(locale), { style: "percent", maximumFractionDigits: 0 }), [locale]);
|
|
118
|
-
const describe = (nextZoom, x, y, dims = turned) => {
|
|
119
|
-
const across = x / dims.width;
|
|
120
|
-
const down = y / dims.height;
|
|
121
|
-
const position = Math.abs(across - 0.5) < 0.005 && Math.abs(down - 0.5) < 0.005 ? cropCenteredLabel(locale) : cropPositionLabel(locale, percent.format(across), percent.format(down));
|
|
122
|
-
return cropStatusLabel(locale, percent.format(nextZoom), position);
|
|
123
|
-
};
|
|
124
|
-
// The latest position, ahead of React's render: several keys or wheel ticks in one task each build on the
|
|
125
|
-
// one before instead of the same rendered state.
|
|
126
|
-
const live = React.useRef({ zoom, x: centerX, y: centerY, rotation });
|
|
127
|
-
live.current = { zoom, x: centerX, y: centerY, rotation };
|
|
128
|
-
const turnedFor = (turn) => (loaded ? rotatedSize(loaded.width, loaded.height, turn) : turned);
|
|
129
|
-
// Every change keeps the centre where the region can be, then says where things are.
|
|
130
|
-
const apply = (next, announce = true) => {
|
|
131
|
-
const base = live.current;
|
|
132
|
-
const nextRotation = next.rotation ?? base.rotation;
|
|
133
|
-
const nextTurned = turnedFor(nextRotation);
|
|
134
|
-
const nextAspect = shape === "free" ? nextTurned.width / nextTurned.height : shape;
|
|
135
|
-
const nextZoom = clampZoom(next.zoom ?? base.zoom);
|
|
136
|
-
const settled = cropRegion(nextTurned, nextAspect, fit, { zoom: nextZoom, centerX: next.x ?? base.x, centerY: next.y ?? base.y });
|
|
137
|
-
const x = settled.left + settled.width / 2;
|
|
138
|
-
const y = settled.top + settled.height / 2;
|
|
139
|
-
live.current = { zoom: nextZoom, x, y, rotation: nextRotation };
|
|
140
|
-
setZoom(nextZoom);
|
|
141
|
-
setCenter({ x, y });
|
|
142
|
-
if (next.rotation !== undefined)
|
|
143
|
-
setRotation(nextRotation);
|
|
144
|
-
if (announce)
|
|
145
|
-
setStatus(describe(nextZoom, x, y, nextTurned));
|
|
146
|
-
};
|
|
147
|
-
const zoomBy = (delta, announce = true) => apply({ zoom: live.current.zoom + delta }, announce);
|
|
148
|
-
const nudge = (dx, dy) => {
|
|
149
|
-
const size = turnedFor(live.current.rotation);
|
|
150
|
-
apply({ x: live.current.x - dx * size.width, y: live.current.y - dy * size.height });
|
|
151
|
-
};
|
|
152
|
-
const rotate = (turn) => {
|
|
153
|
-
const next = ((((live.current.rotation + turn) % 360) + 360) % 360);
|
|
154
|
-
// The new shape starts centred.
|
|
155
|
-
const nextTurned = turnedFor(next);
|
|
156
|
-
apply({ rotation: next, x: nextTurned.width / 2, y: nextTurned.height / 2 });
|
|
157
|
-
};
|
|
158
|
-
const onKeyDown = (event) => {
|
|
159
|
-
// Browser zoom (Ctrl/Cmd with + and −) and other shortcuts stay the browser's.
|
|
160
|
-
if (event.ctrlKey || event.metaKey || event.altKey)
|
|
161
|
-
return;
|
|
162
|
-
const step = event.shiftKey ? 0.1 : 0.01;
|
|
163
|
-
// Spatial, so never mirrored in RTL: the image moves the way the arrow points.
|
|
164
|
-
const moves = { ArrowLeft: [-step, 0], ArrowRight: [step, 0], ArrowUp: [0, -step], ArrowDown: [0, step] };
|
|
165
|
-
if (moves[event.key])
|
|
166
|
-
nudge(...moves[event.key]);
|
|
167
|
-
else if (event.key === "+" || event.key === "=")
|
|
168
|
-
zoomBy(ZOOM_STEP);
|
|
169
|
-
else if (event.key === "-" || event.key === "_")
|
|
170
|
-
zoomBy(-ZOOM_STEP);
|
|
171
|
-
else if (event.key === "[")
|
|
172
|
-
rotate(-90);
|
|
173
|
-
else if (event.key === "]")
|
|
174
|
-
rotate(90);
|
|
175
|
-
else
|
|
176
|
-
return;
|
|
177
|
-
event.preventDefault();
|
|
178
|
-
};
|
|
179
|
-
// Pointer: drag moves, the wheel zooms.
|
|
180
|
-
const drag = React.useRef(null);
|
|
181
|
-
const onPointerDown = (event) => {
|
|
182
|
-
if (!loaded || event.button !== 0)
|
|
183
|
-
return;
|
|
184
|
-
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
185
|
-
drag.current = { x: event.clientX, y: event.clientY, centerX, centerY };
|
|
186
|
-
};
|
|
187
|
-
const onPointerMove = (event) => {
|
|
188
|
-
if (!drag.current || scale <= 0)
|
|
189
|
-
return;
|
|
190
|
-
apply({ x: drag.current.centerX - (event.clientX - drag.current.x) / scale, y: drag.current.centerY - (event.clientY - drag.current.y) / scale }, false);
|
|
191
|
-
};
|
|
192
|
-
const onPointerUp = () => {
|
|
193
|
-
if (drag.current)
|
|
194
|
-
setStatus(describe(live.current.zoom, live.current.x, live.current.y, turnedFor(live.current.rotation)));
|
|
195
|
-
drag.current = null;
|
|
196
|
-
};
|
|
197
|
-
// The wheel zooms in proportion to how far it turns (a trackpad sends many small steps) and never scrolls
|
|
198
|
-
// the page underneath: React's wheel listener is passive, so this one is native.
|
|
199
|
-
const wheelRef = React.useRef(() => { });
|
|
200
|
-
wheelRef.current = (event) => {
|
|
201
|
-
if (!loaded || event.deltaY === 0)
|
|
202
|
-
return;
|
|
203
|
-
const pixels = event.deltaMode === 1 ? event.deltaY * 16 : event.deltaMode === 2 ? event.deltaY * 400 : event.deltaY;
|
|
204
|
-
const zoomingIn = pixels < 0;
|
|
205
|
-
// At a limit in the wheel's direction the page scrolls on, as it does over any other part of it.
|
|
206
|
-
if ((zoomingIn && live.current.zoom >= MAX_ZOOM) || (!zoomingIn && live.current.zoom <= MIN_ZOOM))
|
|
207
|
-
return;
|
|
208
|
-
event.preventDefault();
|
|
209
|
-
zoomBy(Math.max(-0.5, Math.min(0.5, -pixels / 500)), false);
|
|
210
|
-
};
|
|
211
|
-
React.useEffect(() => {
|
|
212
|
-
if (!stageElement)
|
|
213
|
-
return;
|
|
214
|
-
const onWheel = (event) => wheelRef.current(event);
|
|
215
|
-
stageElement.addEventListener("wheel", onWheel, { passive: false });
|
|
216
|
-
return () => stageElement.removeEventListener("wheel", onWheel);
|
|
217
|
-
}, [stageElement]);
|
|
218
|
-
const save = async () => {
|
|
219
|
-
if (!loaded)
|
|
220
|
-
return;
|
|
221
|
-
setSaving(true);
|
|
222
|
-
setSaveError(false);
|
|
223
|
-
try {
|
|
224
|
-
const canvas = document.createElement("canvas");
|
|
225
|
-
canvas.width = size.width;
|
|
226
|
-
canvas.height = size.height;
|
|
227
|
-
const context = canvas.getContext("2d");
|
|
228
|
-
if (!context)
|
|
229
|
-
throw new Error("canvas-unavailable");
|
|
230
|
-
drawCrop(context, loaded.image, loaded, region, size, { rotation, outputType, background });
|
|
231
|
-
const encoded = await encodeWithin((step) => new Promise((resolve) => canvas.toBlob(resolve, outputType, step)), {
|
|
232
|
-
outputType,
|
|
233
|
-
quality,
|
|
234
|
-
minimumQuality,
|
|
235
|
-
maxBytes,
|
|
236
|
-
});
|
|
237
|
-
if (!encoded.fits) {
|
|
238
|
-
setSaveError("too-large");
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
const blob = encoded.blob;
|
|
242
|
-
const base = fileName ?? (typeof src !== "string" && "name" in src ? String(src.name).replace(/\.[^.]+$/, "") : "image");
|
|
243
|
-
await onCrop(new File([blob], `${base}.${extensionOf(outputType)}`, { type: outputType }), { width: size.width, height: size.height, type: outputType });
|
|
244
|
-
}
|
|
245
|
-
catch {
|
|
246
|
-
// No canvas, a tainted canvas (a cross-origin image), a canvas too large for the device, or the app's
|
|
247
|
-
// own save failing: say so and keep the crop, so it can be tried again.
|
|
248
|
-
setSaveError(true);
|
|
249
|
-
}
|
|
250
|
-
finally {
|
|
251
|
-
setSaving(false);
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
const showBackground = fit === "contain" && !alpha;
|
|
255
|
-
const swatches = [...new Set([...SWATCHES, backgroundProp.toLowerCase()])].map((value) => ({
|
|
256
|
-
value,
|
|
257
|
-
name: value === "#ffffff" ? colorWhiteLabel(locale) : value === "#ebe9e6" ? colorLightGreyLabel(locale) : value === "#0e0c09" ? colorBlackLabel(locale) : value,
|
|
258
|
-
}));
|
|
259
|
-
const sizeText = `${size.width} × ${size.height} px`;
|
|
260
|
-
return (_jsxs("div", { "data-slot": "image-cropper", className: "flex min-w-0 flex-col gap-ds-150", children: [_jsxs("div", { ref: stageRef,
|
|
261
|
-
// Spatial: the photo and its frame never mirror; logical classes inside resolve as left and right.
|
|
262
|
-
dir: "ltr", "data-slot": "image-cropper-stage", className: "relative w-full touch-none overflow-hidden rounded-ds-large bg-ds-surface-sunken select-none",
|
|
263
|
-
// Whole pixels once measured: a fractional height would shift everything below it off the pixel grid.
|
|
264
|
-
style: stageWidth > 0 ? { height: stageHeight } : { aspectRatio: String(STAGE_ASPECT) }, onPointerDown: onPointerDown, onPointerMove: onPointerMove, onPointerUp: onPointerUp, onPointerCancel: onPointerUp, children: [source.failed && (_jsx("p", { "data-slot": "image-cropper-error", role: "alert", className: "absolute inset-0 m-0 grid place-items-center p-ds-300 text-center text-body text-ds-text-subtle", children: cropLoadFailedLabel(locale) })), loaded && stageWidth > 0 && (_jsxs(_Fragment, { children: [_jsx("div", { "aria-hidden": true, "data-slot": "image-cropper-fill", className: "absolute", style: { left: frameLeft, top: frameTop, width: frameWidth, height: frameHeight, background: alpha ? CHECKER : background } }), _jsx("div", { "aria-hidden": true, "data-slot": "image-cropper-image", className: "absolute", style: { left: frameLeft - region.left * scale, top: frameTop - region.top * scale, width: turned.width * scale, height: turned.height * scale }, children: _jsx("img", { src: source.url, alt: "", draggable: false, className: "absolute start-1/2 top-1/2 max-w-none", style: { width: loaded.width * scale, height: loaded.height * scale, transform: `translate(-50%, -50%) rotate(${rotation}deg)` } }) })] })), _jsxs("div", { role: "group", "aria-label": label, "aria-describedby": helpId, tabIndex: loaded ? 0 : -1, "data-slot": "image-cropper-frame", onKeyDown: onKeyDown, className: "absolute border border-[#fcfcfb] outline-hidden focus-visible:inset-ring-2 focus-visible:inset-ring-ds-border-focused",
|
|
265
|
-
// The blanket dims everything outside the frame.
|
|
266
|
-
style: { left: frameLeft, top: frameTop, width: frameWidth, height: frameHeight, boxShadow: "0 0 0 9999px var(--ds-blanket)" }, children: [_jsx("span", { "aria-hidden": true, className: "absolute inset-y-0 start-1/3 w-px bg-[#fcfcfb]/40" }), _jsx("span", { "aria-hidden": true, className: "absolute inset-y-0 start-2/3 w-px bg-[#fcfcfb]/40" }), _jsx("span", { "aria-hidden": true, className: "absolute inset-x-0 top-1/3 h-px bg-[#fcfcfb]/40" }), _jsx("span", { "aria-hidden": true, className: "absolute inset-x-0 top-2/3 h-px bg-[#fcfcfb]/40" }), ["-start-1.5 -top-1.5", "-end-1.5 -top-1.5", "-start-1.5 -bottom-1.5", "-end-1.5 -bottom-1.5"].map((corner) => (_jsx("span", { "aria-hidden": true, "data-slot": "image-cropper-handle", className: cn("absolute size-3 rounded-[2px] bg-[#fcfcfb] shadow-ds-raised", corner) }, corner)))] }), _jsx("span", { id: helpId, className: "sr-only", children: cropHelpLabel(locale) }), _jsx("span", { role: "status", "data-slot": "image-cropper-status", className: "sr-only", children: status })] }), _jsxs("div", { "data-slot": "image-cropper-toolbar", className: "flex flex-wrap items-center gap-ds-150", children: [presets && (_jsx(SegmentedControl, { label: cropAspectLabel(locale), items: presets.map((item) => ({ id: item.id, label: item.label })), value: preset?.id, onChange: (id) => {
|
|
267
|
-
const next = presets.find((item) => item.id === id);
|
|
268
|
-
setPresetId(String(id));
|
|
269
|
-
if (next?.fit)
|
|
270
|
-
setFit(next.fit);
|
|
271
|
-
setCenter(null);
|
|
272
|
-
setZoom(1);
|
|
273
|
-
} })), _jsxs("div", { "data-slot": "image-cropper-zoom", className: "flex min-w-48 flex-1 items-center gap-ds-100", children: [_jsx(Button, { size: "small", variant: "subtle", iconOnly: true, iconBefore: "minus", "aria-label": cropZoomOutLabel(locale), isDisabled: !loaded || zoom <= MIN_ZOOM, onPress: () => zoomBy(-ZOOM_STEP) }), _jsx(AriaSlider, { "aria-label": cropZoomLabel(locale), minValue: MIN_ZOOM, maxValue: MAX_ZOOM,
|
|
274
|
-
// Fine enough that a wheel or keyboard zoom is always a value the slider can show.
|
|
275
|
-
step: 0.01, value: zoom, onChange: (value) => apply({ zoom: value }, false), onChangeEnd: () => setStatus(describe(live.current.zoom, live.current.x, live.current.y, turnedFor(live.current.rotation))), isDisabled: !loaded, formatOptions: { style: "percent" }, "data-slot": "image-cropper-zoom-slider", className: "min-w-24 flex-1", children: _jsx(SliderTrack, { className: SLIDER_TRACK, children: ({ state }) => (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, className: SLIDER_RAIL }), _jsx("span", { "aria-hidden": true, className: SLIDER_FILL, style: { insetInlineStart: 0, insetInlineEnd: `${100 - state.getThumbPercent(0) * 100}%` } }), _jsx(SliderThumb, { className: SLIDER_THUMB })] })) }) }), _jsx(Button, { size: "small", variant: "subtle", iconOnly: true, iconBefore: "plus", "aria-label": cropZoomInLabel(locale), isDisabled: !loaded || zoom >= MAX_ZOOM, onPress: () => zoomBy(ZOOM_STEP) }), _jsx("span", { "data-slot": "image-cropper-zoom-value", className: "w-12 text-body-small tabular-nums text-ds-text-subtle", children: percent.format(zoom) })] }), _jsx("span", { "aria-hidden": true, className: "h-5 w-px bg-ds-border" }), _jsx(Button, { size: "small", variant: "subtle", iconOnly: true, iconBefore: "rotate-ccw", "aria-label": cropRotateLeftLabel(locale), isDisabled: !loaded, onPress: () => rotate(-90) }), _jsx(Button, { size: "small", variant: "subtle", iconOnly: true, iconBefore: "rotate-cw", "aria-label": cropRotateRightLabel(locale), isDisabled: !loaded, onPress: () => rotate(90) }), presets && (_jsx(SegmentedControl, { label: cropFitLabel(locale), items: [
|
|
276
|
-
{ id: "cover", label: cropCoverLabel(locale) },
|
|
277
|
-
{ id: "contain", label: cropContainLabel(locale) },
|
|
278
|
-
], value: fit, onChange: (value) => {
|
|
279
|
-
setFit(value);
|
|
280
|
-
setCenter(null);
|
|
281
|
-
setZoom(1);
|
|
282
|
-
} }))] }), showBackground && (_jsx(ColorSwatchPicker, { label: cropBackgroundLabel(locale), items: swatches, value: background.toLowerCase(), onChange: setBackground })), _jsxs("div", { "data-slot": "image-cropper-meta", className: "flex flex-col gap-ds-050 text-body-small tabular-nums", children: [loaded && (_jsxs("span", { className: "text-ds-text-subtlest", children: [cropOutputLabel(locale, sizeText, TYPE_NAMES[outputType]), alpha && fit === "contain" ? ` (${cropKeepsAlphaLabel(locale)})` : ""] })), loaded && sourceTooSmall && (_jsxs("span", { "data-slot": "image-cropper-warning", className: "flex items-center gap-ds-050 text-ds-text-warning", children: [_jsx(IconGlyph, { name: "triangle-alert", size: "small" }), cropSmallLabel(locale, String(turned.width), sizeText)] }))] }), saveError && (_jsxs("p", { role: "alert", "data-slot": "image-cropper-save-error", "data-reason": saveError === "too-large" ? "too-large" : undefined, className: "m-0 flex items-center gap-ds-050 text-body-small text-ds-text-danger", children: [_jsx(IconGlyph, { name: "circle-alert", size: "small" }), saveError === "too-large" && maxBytes ? cropTooLargeLabel(locale, formatFileSize(maxBytes, intlLocale(locale))) : cropSaveFailedLabel(locale)] })), _jsxs("div", { "data-slot": "image-cropper-actions", className: "flex flex-wrap justify-end gap-ds-100", children: [onCancel && _jsx(Button, { onPress: onCancel, children: cancelLabel(locale) }), _jsx(Button, { variant: "primary", isPending: saving, isDisabled: !loaded, onPress: () => void save(), children: cropSaveLabel(locale) })] })] }));
|
|
283
|
-
}
|
|
284
|
-
//# sourceMappingURL=image-cropper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image-cropper.js","sourceRoot":"","sources":["../../src/display/image-cropper.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,WAAW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ACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Slider as AriaSlider, SliderThumb, SliderTrack, useLocale } from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { Button } from \"../action/button\";\nimport { formatFileSize } from \"../action/files\";\nimport { ColorSwatchPicker } from \"../color/color\";\nimport {\n cancelLabel,\n colorBlackLabel,\n colorLightGreyLabel,\n colorWhiteLabel,\n cropAspectLabel,\n cropBackgroundLabel,\n cropCenteredLabel,\n cropContainLabel,\n cropCoverLabel,\n cropFitLabel,\n cropHelpLabel,\n cropKeepsAlphaLabel,\n cropLoadFailedLabel,\n cropOutputLabel,\n cropPositionLabel,\n cropRotateLeftLabel,\n cropRotateRightLabel,\n cropSaveFailedLabel,\n cropSaveLabel,\n cropSmallLabel,\n cropStatusLabel,\n cropTooLargeLabel,\n cropZoomInLabel,\n cropZoomLabel,\n cropZoomOutLabel,\n intlLocale,\n} from \"../i18n\";\nimport { SegmentedControl } from \"../navigation/tabs\";\nimport { SLIDER_FILL, SLIDER_RAIL, SLIDER_THUMB, SLIDER_TRACK } from \"../selection/styles\";\nimport { IconGlyph } from \"./icon\";\nimport {\n MAX_ZOOM,\n MIN_ZOOM,\n clampZoom,\n cropRegion,\n drawCrop,\n encodeWithin,\n extensionOf,\n hasAlpha,\n outputSize,\n rotatedSize,\n type CropFit,\n type CropOutputType,\n type CropRotation,\n} from \"./image-crop\";\n\nexport type ImageCropperAspect = number | \"free\";\n\nexport type ImageCropperPreset = {\n id: string;\n /** \"Cover 16:9\". */\n label: string;\n aspectRatio: ImageCropperAspect;\n /** The fit this surface uses; the cropper's `fit` otherwise. */\n fit?: CropFit;\n};\n\nexport type ImageCropperResult = { width: number; height: number; type: CropOutputType };\n\nexport type ImageCropperProps = {\n /**\n * The picked file (from FileTrigger, already checked for size and type), or an image URL. A URL from\n * another origin is loaded with CORS so the crop can be read back: its server must send\n * `Access-Control-Allow-Origin`, or the image does not open (rather than failing later at save).\n */\n src: Blob | string;\n /** What is being cropped (\"Cover photo\"); names the crop frame. */\n label: string;\n /** 16:9 by default; `\"free\"` keeps the image's own shape. Ignored when presets are given. */\n aspectRatio?: ImageCropperAspect;\n /** Two or more shapes to choose from (a segmented control); the first is selected. */\n aspectPresets?: readonly ImageCropperPreset[];\n /** `cover` (default) fills the frame; `contain` fits the whole image and leaves empty area. */\n fit?: CropFit;\n /** The empty area's colour in `contain` when the output has no alpha (JPEG). White by default. */\n background?: string;\n /** `image/jpeg` by default. PNG and WebP keep transparency. */\n outputType?: CropOutputType;\n /** 0–1, for JPEG and WebP. 0.9 by default. */\n quality?: number;\n /**\n * The largest file the surface takes, in bytes. A JPEG or WebP\n * over it is encoded again at a quality 0.1 lower each time, down to `minimumQuality`; when even that is over, or\n * a PNG is, nothing is handed to `onCrop` and the cropper says the image is over the limit (a smaller crop, by\n * zooming in, or another image fits).\n */\n maxBytes?: number;\n /** The lowest quality `maxBytes` may step down to (0.9 keeps a hero or slide sharp). 0.1 by default; at most `quality`. */\n minimumQuality?: number;\n /**\n * The output's long edge in px at most (a surface's size, 2560 for a full-width photo): larger crops scale down,\n * never up. 4096 by default, so a 48 MP phone photo stays within every browser's canvas limit.\n */\n maxOutputSize?: number;\n /** Under this long edge the warning shows; it never blocks. */\n minOutputSize?: number;\n /** The output file's name without extension; the source file's name by default. */\n fileName?: string;\n onCrop: (file: File, result: ImageCropperResult) => unknown;\n onCancel?: () => void;\n};\n\nconst STAGE_ASPECT = 16 / 10;\nconst FRAME_INSET = 0.06;\nconst ZOOM_STEP = 0.1;\n/** Fixed paper and light grey: the frame and checkerboard draw on the photo, not on a theme surface. */\nconst CHECKER = \"repeating-conic-gradient(#ebe9e6 0 25%, #fcfcfb 0 50%) 0 0 / 16px 16px\";\nconst SWATCHES = [\"#ffffff\", \"#ebe9e6\", \"#0e0c09\"] as const;\nconst TYPE_NAMES: Record<CropOutputType, string> = { \"image/jpeg\": \"JPEG\", \"image/png\": \"PNG\", \"image/webp\": \"WebP\" };\n\ntype Loaded = { image: HTMLImageElement; width: number; height: number };\n\n/** The image behind `src`, decoded; an object URL for a file, revoked when it changes. */\nfunction useSourceImage(src: Blob | string) {\n const [state, setState] = React.useState<{ url?: string; loaded?: Loaded; failed?: boolean }>({});\n React.useEffect(() => {\n const url = typeof src === \"string\" ? src : URL.createObjectURL(src);\n let live = true;\n setState({ url });\n const image = new Image();\n image.decoding = \"async\";\n // A URL from a CDN must not taint the canvas, or the crop could never be read back.\n if (typeof src === \"string\" && !/^(data|blob):/.test(src)) image.crossOrigin = \"anonymous\";\n image.onload = () => live && setState({ url, loaded: { image, width: image.naturalWidth, height: image.naturalHeight } });\n image.onerror = () => live && setState({ url, failed: true });\n image.src = url;\n return () => {\n live = false;\n if (typeof src !== \"string\") URL.revokeObjectURL(url);\n };\n }, [src]);\n return state;\n}\n\n/** The element's width in whole px, following resizes. */\nfunction useWidth() {\n const [element, setElement] = React.useState<HTMLElement | null>(null);\n const [width, setWidth] = React.useState(0);\n React.useLayoutEffect(() => {\n if (!element) return;\n setWidth(Math.floor(element.getBoundingClientRect().width));\n if (typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(([entry]) => setWidth(Math.floor(entry!.contentRect.width)));\n observer.observe(element);\n return () => observer.disconnect();\n }, [element]);\n return [setElement, width, element] as const;\n}\n\n/**\n * Frames one picked image to the shape a surface needs (a 16:9 cover photo, a square logo) and hands\n * back the cropped file at the source's own pixel density: never upscaled, only scaled down to\n * `maxOutputSize`. In `contain`, the empty area takes `background` when the output has no\n * alpha, white by default, never black. A sunken stage dims what falls outside a white frame\n * with thirds guides; the toolbar holds the shapes, zoom, rotation and fit. The frame is one focusable\n * group: arrows move the image (Shift for 10%), + and − zoom, [ and ] rotate, and each change is announced.\n * The toolbar mirrors in RTL; the image and the arrows never do.\n */\nexport function ImageCropper({\n src,\n label,\n aspectRatio = 16 / 9,\n aspectPresets,\n fit: fitProp = \"cover\",\n background: backgroundProp = \"#ffffff\",\n outputType = \"image/jpeg\",\n quality = 0.9,\n maxBytes,\n minimumQuality,\n maxOutputSize = 4096,\n minOutputSize,\n fileName,\n onCrop,\n onCancel,\n}: ImageCropperProps) {\n const { locale } = useLocale();\n const source = useSourceImage(src);\n const presets = aspectPresets && aspectPresets.length > 1 ? aspectPresets : undefined;\n const [presetId, setPresetId] = React.useState(presets?.[0]?.id);\n const preset = presets?.find((item) => item.id === presetId) ?? presets?.[0];\n const [fit, setFit] = React.useState<CropFit>(preset?.fit ?? fitProp);\n const [background, setBackground] = React.useState(backgroundProp);\n // Props changed later win again: a new fit or background from the surface.\n React.useEffect(() => setFit(preset?.fit ?? fitProp), [fitProp]); // preset changes set fit themselves\n React.useEffect(() => setBackground(backgroundProp), [backgroundProp]);\n // `true` a failed save; \"too-large\" a crop over `maxBytes` at the lowest quality allowed.\n const [saveError, setSaveError] = React.useState<boolean | \"too-large\">(false);\n const [rotation, setRotation] = React.useState<CropRotation>(0);\n const [zoom, setZoom] = React.useState(1);\n const [center, setCenter] = React.useState<{ x: number; y: number } | null>(null);\n const [status, setStatus] = React.useState(\"\");\n const [saving, setSaving] = React.useState(false);\n const [stageRef, stageWidth, stageElement] = useWidth();\n const helpId = React.useId();\n\n const loaded = source.loaded;\n // A new picture starts afresh: upright, whole, centred.\n React.useEffect(() => {\n setRotation(0);\n setZoom(1);\n setCenter(null);\n setStatus(\"\");\n setSaveError(false);\n }, [source.url]);\n const turned = loaded ? rotatedSize(loaded.width, loaded.height, rotation) : { width: 1, height: 1 };\n const shape = preset ? preset.aspectRatio : aspectRatio;\n const aspect = shape === \"free\" ? turned.width / turned.height : shape;\n const centerX = center?.x ?? turned.width / 2;\n const centerY = center?.y ?? turned.height / 2;\n const region = cropRegion(turned, aspect, fit, { zoom, centerX, centerY });\n const size = outputSize(region, { maxOutputSize, minOutputSize });\n // The warning is about the source, not the zoom: shown when even the whole fit is under the surface's size.\n const sourceTooSmall = outputSize(cropRegion(turned, aspect, fit, { zoom: 1, centerX, centerY }), { maxOutputSize, minOutputSize }).small;\n const alpha = hasAlpha(outputType);\n\n // The frame inside the stage: the largest rectangle of the crop's shape, inset from the edges.\n const stageHeight = Math.round(stageWidth / STAGE_ASPECT);\n const roomWidth = stageWidth * (1 - 2 * FRAME_INSET);\n const roomHeight = stageHeight * (1 - 2 * FRAME_INSET);\n const frameWidth = Math.min(roomWidth, roomHeight * aspect);\n const frameHeight = frameWidth / aspect;\n const frameLeft = (stageWidth - frameWidth) / 2;\n const frameTop = (stageHeight - frameHeight) / 2;\n const scale = region.width > 0 ? frameWidth / region.width : 0;\n\n const percent = React.useMemo(() => new Intl.NumberFormat(intlLocale(locale), { style: \"percent\", maximumFractionDigits: 0 }), [locale]);\n const describe = (nextZoom: number, x: number, y: number, dims: { width: number; height: number } = turned) => {\n const across = x / dims.width;\n const down = y / dims.height;\n const position = Math.abs(across - 0.5) < 0.005 && Math.abs(down - 0.5) < 0.005 ? cropCenteredLabel(locale) : cropPositionLabel(locale, percent.format(across), percent.format(down));\n return cropStatusLabel(locale, percent.format(nextZoom), position);\n };\n\n // The latest position, ahead of React's render: several keys or wheel ticks in one task each build on the\n // one before instead of the same rendered state.\n const live = React.useRef({ zoom, x: centerX, y: centerY, rotation });\n live.current = { zoom, x: centerX, y: centerY, rotation };\n const turnedFor = (turn: CropRotation) => (loaded ? rotatedSize(loaded.width, loaded.height, turn) : turned);\n\n // Every change keeps the centre where the region can be, then says where things are.\n const apply = (next: { zoom?: number; x?: number; y?: number; rotation?: CropRotation }, announce = true) => {\n const base = live.current;\n const nextRotation = next.rotation ?? base.rotation;\n const nextTurned = turnedFor(nextRotation);\n const nextAspect = shape === \"free\" ? nextTurned.width / nextTurned.height : shape;\n const nextZoom = clampZoom(next.zoom ?? base.zoom);\n const settled = cropRegion(nextTurned, nextAspect, fit, { zoom: nextZoom, centerX: next.x ?? base.x, centerY: next.y ?? base.y });\n const x = settled.left + settled.width / 2;\n const y = settled.top + settled.height / 2;\n live.current = { zoom: nextZoom, x, y, rotation: nextRotation };\n setZoom(nextZoom);\n setCenter({ x, y });\n if (next.rotation !== undefined) setRotation(nextRotation);\n if (announce) setStatus(describe(nextZoom, x, y, nextTurned));\n };\n const zoomBy = (delta: number, announce = true) => apply({ zoom: live.current.zoom + delta }, announce);\n const nudge = (dx: number, dy: number) => {\n const size = turnedFor(live.current.rotation);\n apply({ x: live.current.x - dx * size.width, y: live.current.y - dy * size.height });\n };\n const rotate = (turn: 90 | -90) => {\n const next = ((((live.current.rotation + turn) % 360) + 360) % 360) as CropRotation;\n // The new shape starts centred.\n const nextTurned = turnedFor(next);\n apply({ rotation: next, x: nextTurned.width / 2, y: nextTurned.height / 2 });\n };\n\n const onKeyDown = (event: React.KeyboardEvent) => {\n // Browser zoom (Ctrl/Cmd with + and −) and other shortcuts stay the browser's.\n if (event.ctrlKey || event.metaKey || event.altKey) return;\n const step = event.shiftKey ? 0.1 : 0.01;\n // Spatial, so never mirrored in RTL: the image moves the way the arrow points.\n const moves: Record<string, [number, number]> = { ArrowLeft: [-step, 0], ArrowRight: [step, 0], ArrowUp: [0, -step], ArrowDown: [0, step] };\n if (moves[event.key]) nudge(...moves[event.key]!);\n else if (event.key === \"+\" || event.key === \"=\") zoomBy(ZOOM_STEP);\n else if (event.key === \"-\" || event.key === \"_\") zoomBy(-ZOOM_STEP);\n else if (event.key === \"[\") rotate(-90);\n else if (event.key === \"]\") rotate(90);\n else return;\n event.preventDefault();\n };\n\n // Pointer: drag moves, the wheel zooms.\n const drag = React.useRef<{ x: number; y: number; centerX: number; centerY: number } | null>(null);\n const onPointerDown = (event: React.PointerEvent) => {\n if (!loaded || event.button !== 0) return;\n (event.currentTarget as HTMLElement).setPointerCapture?.(event.pointerId);\n drag.current = { x: event.clientX, y: event.clientY, centerX, centerY };\n };\n const onPointerMove = (event: React.PointerEvent) => {\n if (!drag.current || scale <= 0) return;\n apply({ x: drag.current.centerX - (event.clientX - drag.current.x) / scale, y: drag.current.centerY - (event.clientY - drag.current.y) / scale }, false);\n };\n const onPointerUp = () => {\n if (drag.current) setStatus(describe(live.current.zoom, live.current.x, live.current.y, turnedFor(live.current.rotation)));\n drag.current = null;\n };\n\n // The wheel zooms in proportion to how far it turns (a trackpad sends many small steps) and never scrolls\n // the page underneath: React's wheel listener is passive, so this one is native.\n const wheelRef = React.useRef<(event: WheelEvent) => void>(() => {});\n wheelRef.current = (event: WheelEvent) => {\n if (!loaded || event.deltaY === 0) return;\n const pixels = event.deltaMode === 1 ? event.deltaY * 16 : event.deltaMode === 2 ? event.deltaY * 400 : event.deltaY;\n const zoomingIn = pixels < 0;\n // At a limit in the wheel's direction the page scrolls on, as it does over any other part of it.\n if ((zoomingIn && live.current.zoom >= MAX_ZOOM) || (!zoomingIn && live.current.zoom <= MIN_ZOOM)) return;\n event.preventDefault();\n zoomBy(Math.max(-0.5, Math.min(0.5, -pixels / 500)), false);\n };\n React.useEffect(() => {\n if (!stageElement) return;\n const onWheel = (event: WheelEvent) => wheelRef.current(event);\n stageElement.addEventListener(\"wheel\", onWheel, { passive: false });\n return () => stageElement.removeEventListener(\"wheel\", onWheel);\n }, [stageElement]);\n\n const save = async () => {\n if (!loaded) return;\n setSaving(true);\n setSaveError(false);\n try {\n const canvas = document.createElement(\"canvas\");\n canvas.width = size.width;\n canvas.height = size.height;\n const context = canvas.getContext(\"2d\");\n if (!context) throw new Error(\"canvas-unavailable\");\n drawCrop(context, loaded.image, loaded, region, size, { rotation, outputType, background });\n const encoded = await encodeWithin((step) => new Promise<Blob | null>((resolve) => canvas.toBlob(resolve, outputType, step)), {\n outputType,\n quality,\n minimumQuality,\n maxBytes,\n });\n if (!encoded.fits) {\n setSaveError(\"too-large\");\n return;\n }\n const blob = encoded.blob;\n const base = fileName ?? (typeof src !== \"string\" && \"name\" in src ? String((src as File).name).replace(/\\.[^.]+$/, \"\") : \"image\");\n await onCrop(new File([blob], `${base}.${extensionOf(outputType)}`, { type: outputType }), { width: size.width, height: size.height, type: outputType });\n } catch {\n // No canvas, a tainted canvas (a cross-origin image), a canvas too large for the device, or the app's\n // own save failing: say so and keep the crop, so it can be tried again.\n setSaveError(true);\n } finally {\n setSaving(false);\n }\n };\n\n const showBackground = fit === \"contain\" && !alpha;\n const swatches = [...new Set<string>([...SWATCHES, backgroundProp.toLowerCase()])].map((value) => ({\n value,\n name: value === \"#ffffff\" ? colorWhiteLabel(locale) : value === \"#ebe9e6\" ? colorLightGreyLabel(locale) : value === \"#0e0c09\" ? colorBlackLabel(locale) : value,\n }));\n const sizeText = `${size.width} × ${size.height} px`;\n\n return (\n <div data-slot=\"image-cropper\" className=\"flex min-w-0 flex-col gap-ds-150\">\n <div\n ref={stageRef}\n // Spatial: the photo and its frame never mirror; logical classes inside resolve as left and right.\n dir=\"ltr\"\n data-slot=\"image-cropper-stage\"\n className=\"relative w-full touch-none overflow-hidden rounded-ds-large bg-ds-surface-sunken select-none\"\n // Whole pixels once measured: a fractional height would shift everything below it off the pixel grid.\n style={stageWidth > 0 ? { height: stageHeight } : { aspectRatio: String(STAGE_ASPECT) }}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerUp}\n >\n {source.failed && (\n <p data-slot=\"image-cropper-error\" role=\"alert\" className=\"absolute inset-0 m-0 grid place-items-center p-ds-300 text-center text-body text-ds-text-subtle\">\n {cropLoadFailedLabel(locale)}\n </p>\n )}\n {loaded && stageWidth > 0 && (\n <>\n {/* What the empty area of the output will be: kept transparent (checkerboard) or the background. */}\n <div\n aria-hidden\n data-slot=\"image-cropper-fill\"\n className=\"absolute\"\n style={{ left: frameLeft, top: frameTop, width: frameWidth, height: frameHeight, background: alpha ? CHECKER : background }}\n />\n <div\n aria-hidden\n data-slot=\"image-cropper-image\"\n className=\"absolute\"\n style={{ left: frameLeft - region.left * scale, top: frameTop - region.top * scale, width: turned.width * scale, height: turned.height * scale }}\n >\n <img\n src={source.url}\n alt=\"\"\n draggable={false}\n className=\"absolute start-1/2 top-1/2 max-w-none\"\n style={{ width: loaded.width * scale, height: loaded.height * scale, transform: `translate(-50%, -50%) rotate(${rotation}deg)` }}\n />\n </div>\n </>\n )}\n <div\n role=\"group\"\n aria-label={label}\n aria-describedby={helpId}\n tabIndex={loaded ? 0 : -1}\n data-slot=\"image-cropper-frame\"\n onKeyDown={onKeyDown}\n className=\"absolute border border-[#fcfcfb] outline-hidden focus-visible:inset-ring-2 focus-visible:inset-ring-ds-border-focused\"\n // The blanket dims everything outside the frame.\n style={{ left: frameLeft, top: frameTop, width: frameWidth, height: frameHeight, boxShadow: \"0 0 0 9999px var(--ds-blanket)\" }}\n >\n {/* Rule-of-thirds guides, paper at 40%. */}\n <span aria-hidden className=\"absolute inset-y-0 start-1/3 w-px bg-[#fcfcfb]/40\" />\n <span aria-hidden className=\"absolute inset-y-0 start-2/3 w-px bg-[#fcfcfb]/40\" />\n <span aria-hidden className=\"absolute inset-x-0 top-1/3 h-px bg-[#fcfcfb]/40\" />\n <span aria-hidden className=\"absolute inset-x-0 top-2/3 h-px bg-[#fcfcfb]/40\" />\n {([\"-start-1.5 -top-1.5\", \"-end-1.5 -top-1.5\", \"-start-1.5 -bottom-1.5\", \"-end-1.5 -bottom-1.5\"] as const).map((corner) => (\n <span key={corner} aria-hidden data-slot=\"image-cropper-handle\" className={cn(\"absolute size-3 rounded-[2px] bg-[#fcfcfb] shadow-ds-raised\", corner)} />\n ))}\n </div>\n <span id={helpId} className=\"sr-only\">\n {cropHelpLabel(locale)}\n </span>\n <span role=\"status\" data-slot=\"image-cropper-status\" className=\"sr-only\">\n {status}\n </span>\n </div>\n\n <div data-slot=\"image-cropper-toolbar\" className=\"flex flex-wrap items-center gap-ds-150\">\n {presets && (\n <SegmentedControl\n label={cropAspectLabel(locale)}\n items={presets.map((item) => ({ id: item.id, label: item.label }))}\n value={preset?.id}\n onChange={(id) => {\n const next = presets.find((item) => item.id === id);\n setPresetId(String(id));\n if (next?.fit) setFit(next.fit);\n setCenter(null);\n setZoom(1);\n }}\n />\n )}\n <div data-slot=\"image-cropper-zoom\" className=\"flex min-w-48 flex-1 items-center gap-ds-100\">\n <Button size=\"small\" variant=\"subtle\" iconOnly iconBefore=\"minus\" aria-label={cropZoomOutLabel(locale)} isDisabled={!loaded || zoom <= MIN_ZOOM} onPress={() => zoomBy(-ZOOM_STEP)} />\n <AriaSlider\n aria-label={cropZoomLabel(locale)}\n minValue={MIN_ZOOM}\n maxValue={MAX_ZOOM}\n // Fine enough that a wheel or keyboard zoom is always a value the slider can show.\n step={0.01}\n value={zoom}\n onChange={(value) => apply({ zoom: value as number }, false)}\n onChangeEnd={() => setStatus(describe(live.current.zoom, live.current.x, live.current.y, turnedFor(live.current.rotation)))}\n isDisabled={!loaded}\n formatOptions={{ style: \"percent\" }}\n data-slot=\"image-cropper-zoom-slider\"\n className=\"min-w-24 flex-1\"\n >\n <SliderTrack className={SLIDER_TRACK}>\n {({ state }) => (\n <>\n <span aria-hidden className={SLIDER_RAIL} />\n <span aria-hidden className={SLIDER_FILL} style={{ insetInlineStart: 0, insetInlineEnd: `${100 - state.getThumbPercent(0) * 100}%` }} />\n <SliderThumb className={SLIDER_THUMB} />\n </>\n )}\n </SliderTrack>\n </AriaSlider>\n <Button size=\"small\" variant=\"subtle\" iconOnly iconBefore=\"plus\" aria-label={cropZoomInLabel(locale)} isDisabled={!loaded || zoom >= MAX_ZOOM} onPress={() => zoomBy(ZOOM_STEP)} />\n <span data-slot=\"image-cropper-zoom-value\" className=\"w-12 text-body-small tabular-nums text-ds-text-subtle\">\n {percent.format(zoom)}\n </span>\n </div>\n <span aria-hidden className=\"h-5 w-px bg-ds-border\" />\n <Button size=\"small\" variant=\"subtle\" iconOnly iconBefore=\"rotate-ccw\" aria-label={cropRotateLeftLabel(locale)} isDisabled={!loaded} onPress={() => rotate(-90)} />\n <Button size=\"small\" variant=\"subtle\" iconOnly iconBefore=\"rotate-cw\" aria-label={cropRotateRightLabel(locale)} isDisabled={!loaded} onPress={() => rotate(90)} />\n {presets && (\n <SegmentedControl\n label={cropFitLabel(locale)}\n items={[\n { id: \"cover\", label: cropCoverLabel(locale) },\n { id: \"contain\", label: cropContainLabel(locale) },\n ]}\n value={fit}\n onChange={(value) => {\n setFit(value as CropFit);\n setCenter(null);\n setZoom(1);\n }}\n />\n )}\n </div>\n\n {showBackground && (\n <ColorSwatchPicker label={cropBackgroundLabel(locale)} items={swatches} value={background.toLowerCase()} onChange={setBackground} />\n )}\n\n <div data-slot=\"image-cropper-meta\" className=\"flex flex-col gap-ds-050 text-body-small tabular-nums\">\n {loaded && (\n <span className=\"text-ds-text-subtlest\">\n {cropOutputLabel(locale, sizeText, TYPE_NAMES[outputType])}\n {alpha && fit === \"contain\" ? ` (${cropKeepsAlphaLabel(locale)})` : \"\"}\n </span>\n )}\n {loaded && sourceTooSmall && (\n <span data-slot=\"image-cropper-warning\" className=\"flex items-center gap-ds-050 text-ds-text-warning\">\n <IconGlyph name=\"triangle-alert\" size=\"small\" />\n {cropSmallLabel(locale, String(turned.width), sizeText)}\n </span>\n )}\n </div>\n\n {saveError && (\n <p\n role=\"alert\"\n data-slot=\"image-cropper-save-error\"\n data-reason={saveError === \"too-large\" ? \"too-large\" : undefined}\n className=\"m-0 flex items-center gap-ds-050 text-body-small text-ds-text-danger\"\n >\n <IconGlyph name=\"circle-alert\" size=\"small\" />\n {saveError === \"too-large\" && maxBytes ? cropTooLargeLabel(locale, formatFileSize(maxBytes, intlLocale(locale))) : cropSaveFailedLabel(locale)}\n </p>\n )}\n\n <div data-slot=\"image-cropper-actions\" className=\"flex flex-wrap justify-end gap-ds-100\">\n {onCancel && <Button onPress={onCancel}>{cancelLabel(locale)}</Button>}\n <Button variant=\"primary\" isPending={saving} isDisabled={!loaded} onPress={() => void save()}>\n {cropSaveLabel(locale)}\n </Button>\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
export type LozengeTone = "neutral" | "information" | "brand" | "success" | "warning" | "danger";
|
|
3
|
-
/** `subtle` and `bold` are pills; `plain` is a dot and the word, for a live system state (online, syncing). */
|
|
4
|
-
export type LozengeAppearance = "subtle" | "bold" | "plain";
|
|
5
|
-
type Base = {
|
|
6
|
-
/**
|
|
7
|
-
* One meaning per tone: information (Approved, In progress) · brand (Featured) · success
|
|
8
|
-
* (Completed, Available, Paid) · warning (Payment pending, Under review) · danger (Canceled,
|
|
9
|
-
* Failed, Overdue) · neutral (Draft, Inactive).
|
|
10
|
-
*/
|
|
11
|
-
tone?: LozengeTone;
|
|
12
|
-
/** `bold` for the one status on the screen that needs attention now; `plain` for a live system state. */
|
|
13
|
-
appearance?: LozengeAppearance;
|
|
14
|
-
/** A 6px dot inside a pill (subtle or bold), for live states. `plain` always has its dot. */
|
|
15
|
-
hasDot?: boolean;
|
|
16
|
-
/** `plain` only: a 3px halo for a state that is active right now (connected, syncing). */
|
|
17
|
-
isLive?: boolean;
|
|
18
|
-
};
|
|
19
|
-
export type LozengeProps = Base & ({
|
|
20
|
-
/** The status word, sentence case ("Payment pending"); the word carries the meaning, never the colour. */
|
|
21
|
-
children: React.ReactNode;
|
|
22
|
-
"aria-label"?: never;
|
|
23
|
-
} | {
|
|
24
|
-
children?: never;
|
|
25
|
-
/** `plain` only, where a visible word is impossible (a dense table cell with its own column header). */
|
|
26
|
-
"aria-label": string;
|
|
27
|
-
});
|
|
28
|
-
/** The status of a record, or a live state, in one or two words. Not interactive; never inside a button. */
|
|
29
|
-
export declare function Lozenge({ children, tone, appearance, hasDot, isLive, "aria-label": ariaLabel }: LozengeProps): React.JSX.Element;
|
|
30
|
-
export {};
|
package/dist/display/lozenge.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { cn } from "../utils.js";
|
|
4
|
-
const SUBTLE = {
|
|
5
|
-
neutral: "bg-ds-background-neutral text-ds-text-subtle",
|
|
6
|
-
information: "bg-ds-background-information text-ds-text-information",
|
|
7
|
-
brand: "bg-ds-background-brand-subtle text-ds-text-brand",
|
|
8
|
-
success: "bg-ds-background-success text-ds-text-success",
|
|
9
|
-
warning: "bg-ds-background-warning text-ds-text-warning",
|
|
10
|
-
danger: "bg-ds-background-danger text-ds-text-danger",
|
|
11
|
-
};
|
|
12
|
-
const BOLD = {
|
|
13
|
-
neutral: "bg-ds-background-neutral-bold text-ds-text-inverse",
|
|
14
|
-
information: "bg-ds-background-information-bold text-ds-text-on-bold",
|
|
15
|
-
brand: "bg-ds-background-brand-bold text-ds-text-on-brand",
|
|
16
|
-
success: "bg-ds-background-success-bold text-ds-text-on-bold",
|
|
17
|
-
warning: "bg-ds-background-warning-bold text-ds-text-on-warning",
|
|
18
|
-
danger: "bg-ds-background-danger-bold text-ds-text-on-danger",
|
|
19
|
-
};
|
|
20
|
-
// `plain`: the 8px dot in the tone's icon color; the word stays in the body color.
|
|
21
|
-
const DOT = {
|
|
22
|
-
neutral: "bg-ds-icon-subtle",
|
|
23
|
-
information: "bg-ds-icon-information",
|
|
24
|
-
brand: "bg-ds-icon-brand",
|
|
25
|
-
success: "bg-ds-icon-success",
|
|
26
|
-
warning: "bg-ds-icon-warning",
|
|
27
|
-
danger: "bg-ds-icon-danger",
|
|
28
|
-
};
|
|
29
|
-
// The live halo sits in the tone's status background.
|
|
30
|
-
const HALO = {
|
|
31
|
-
neutral: "ring-ds-background-neutral",
|
|
32
|
-
information: "ring-ds-background-information",
|
|
33
|
-
brand: "ring-ds-background-brand-subtle",
|
|
34
|
-
success: "ring-ds-background-success",
|
|
35
|
-
warning: "ring-ds-background-warning",
|
|
36
|
-
danger: "ring-ds-background-danger",
|
|
37
|
-
};
|
|
38
|
-
/** The status of a record, or a live state, in one or two words. Not interactive; never inside a button. */
|
|
39
|
-
export function Lozenge({ children, tone = "neutral", appearance = "subtle", hasDot, isLive, "aria-label": ariaLabel }) {
|
|
40
|
-
if (appearance === "plain") {
|
|
41
|
-
// null, false and "" are no word either.
|
|
42
|
-
const hasWord = children != null && children !== false && children !== "";
|
|
43
|
-
const dot = (_jsx("span", { "data-slot": "lozenge-dot", "aria-hidden": true, className: cn("size-ds-100 shrink-0 rounded-ds-full", DOT[tone], isLive && cn("ring-3", HALO[tone])) }));
|
|
44
|
-
if (!hasWord) {
|
|
45
|
-
return (
|
|
46
|
-
// A named image with a label; without one it only decorates, never an unnamed image.
|
|
47
|
-
_jsx("span", { role: ariaLabel ? "img" : undefined, "aria-label": ariaLabel, "aria-hidden": ariaLabel ? undefined : true, "data-slot": "lozenge", "data-tone": tone, "data-appearance": "plain", "data-live": isLive || undefined, className: "inline-flex items-center", children: dot }));
|
|
48
|
-
}
|
|
49
|
-
return (
|
|
50
|
-
// The halo is a shadow and takes no space, so a live dot gets the wider gap to keep the word clear of it.
|
|
51
|
-
_jsxs("span", { "data-slot": "lozenge", "data-tone": tone, "data-appearance": "plain", "data-live": isLive || undefined, className: cn("inline-flex items-center text-body text-ds-text", isLive ? "gap-ds-100" : "gap-ds-075"), children: [dot, _jsx("span", { "data-slot": "lozenge-label", children: children })] }));
|
|
52
|
-
}
|
|
53
|
-
return (_jsxs("span", { "data-slot": "lozenge", "data-tone": tone, "data-appearance": appearance, className: cn("inline-flex h-5 shrink-0 items-center gap-ds-050 rounded-ds-xsmall px-ds-075 text-body-small font-medium whitespace-nowrap", appearance === "bold" ? BOLD[tone] : SUBTLE[tone]), children: [hasDot && _jsx("span", { "data-slot": "lozenge-dot", "aria-hidden": true, className: "size-1.5 rounded-ds-full bg-current" }), children] }));
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=lozenge.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lozenge.js","sourceRoot":"","sources":["../../src/display/lozenge.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAM9B,MAAM,MAAM,GAAgC;IAC1C,OA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AM,IAAI,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAI,CACnJ,CAAC;QACF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO;YACL,qFAAqF;YACrF,eACE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,gBACvB,SAAS,iBACR,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,eAC/B,SAAS,eACR,IAAI,qBACC,OAAO,eACZ,MAAM,IAAI,SAAS,EAC9B,SAAS,EAAC,0BAA0B,YAEnC,GAAG,GACC,CACR,CAAC;QACJ,CAAC;QACD,OAAO;QACL,0GAA0G;QAC1G,6BACY,SAAS,eACR,IAAI,qBACC,OAAO,eACZ,MAAM,IAAI,SAAS,EAC9B,SAAS,EAAE,EAAE,CAAC,iDAAiD,EAAE,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,aAErG,GAAG,EACJ,4BAAgB,eAAe,YAAE,QAAQ,GAAQ,IAC5C,CACR,CAAC;IACJ,CAAC;IACD,OAAO,CACL,6BACY,SAAS,eACR,IAAI,qBACE,UAAU,EAC3B,SAAS,EAAE,EAAE,CACX,4HAA4H,EAC5H,UAAU,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAClD,aAEA,MAAM,IAAI,4BAAgB,aAAa,uBAAa,SAAS,EAAC,qCAAqC,GAAG,EACtG,QAAQ,IACJ,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport { cn } from \"../utils\";\n\nexport type LozengeTone = \"neutral\" | \"information\" | \"brand\" | \"success\" | \"warning\" | \"danger\";\n/** `subtle` and `bold` are pills; `plain` is a dot and the word, for a live system state (online, syncing). */\nexport type LozengeAppearance = \"subtle\" | \"bold\" | \"plain\";\n\nconst SUBTLE: Record<LozengeTone, string> = {\n neutral: \"bg-ds-background-neutral text-ds-text-subtle\",\n information: \"bg-ds-background-information text-ds-text-information\",\n brand: \"bg-ds-background-brand-subtle text-ds-text-brand\",\n success: \"bg-ds-background-success text-ds-text-success\",\n warning: \"bg-ds-background-warning text-ds-text-warning\",\n danger: \"bg-ds-background-danger text-ds-text-danger\",\n};\nconst BOLD: Record<LozengeTone, string> = {\n neutral: \"bg-ds-background-neutral-bold text-ds-text-inverse\",\n information: \"bg-ds-background-information-bold text-ds-text-on-bold\",\n brand: \"bg-ds-background-brand-bold text-ds-text-on-brand\",\n success: \"bg-ds-background-success-bold text-ds-text-on-bold\",\n warning: \"bg-ds-background-warning-bold text-ds-text-on-warning\",\n danger: \"bg-ds-background-danger-bold text-ds-text-on-danger\",\n};\n// `plain`: the 8px dot in the tone's icon color; the word stays in the body color.\nconst DOT: Record<LozengeTone, string> = {\n neutral: \"bg-ds-icon-subtle\",\n information: \"bg-ds-icon-information\",\n brand: \"bg-ds-icon-brand\",\n success: \"bg-ds-icon-success\",\n warning: \"bg-ds-icon-warning\",\n danger: \"bg-ds-icon-danger\",\n};\n// The live halo sits in the tone's status background.\nconst HALO: Record<LozengeTone, string> = {\n neutral: \"ring-ds-background-neutral\",\n information: \"ring-ds-background-information\",\n brand: \"ring-ds-background-brand-subtle\",\n success: \"ring-ds-background-success\",\n warning: \"ring-ds-background-warning\",\n danger: \"ring-ds-background-danger\",\n};\n\ntype Base = {\n /**\n * One meaning per tone: information (Approved, In progress) · brand (Featured) · success\n * (Completed, Available, Paid) · warning (Payment pending, Under review) · danger (Canceled,\n * Failed, Overdue) · neutral (Draft, Inactive).\n */\n tone?: LozengeTone;\n /** `bold` for the one status on the screen that needs attention now; `plain` for a live system state. */\n appearance?: LozengeAppearance;\n /** A 6px dot inside a pill (subtle or bold), for live states. `plain` always has its dot. */\n hasDot?: boolean;\n /** `plain` only: a 3px halo for a state that is active right now (connected, syncing). */\n isLive?: boolean;\n};\n\nexport type LozengeProps = Base &\n (\n | {\n /** The status word, sentence case (\"Payment pending\"); the word carries the meaning, never the colour. */\n children: React.ReactNode;\n \"aria-label\"?: never;\n }\n | {\n children?: never;\n /** `plain` only, where a visible word is impossible (a dense table cell with its own column header). */\n \"aria-label\": string;\n }\n );\n\n/** The status of a record, or a live state, in one or two words. Not interactive; never inside a button. */\nexport function Lozenge({ children, tone = \"neutral\", appearance = \"subtle\", hasDot, isLive, \"aria-label\": ariaLabel }: LozengeProps) {\n if (appearance === \"plain\") {\n // null, false and \"\" are no word either.\n const hasWord = children != null && children !== false && children !== \"\";\n const dot = (\n <span data-slot=\"lozenge-dot\" aria-hidden className={cn(\"size-ds-100 shrink-0 rounded-ds-full\", DOT[tone], isLive && cn(\"ring-3\", HALO[tone]))} />\n );\n if (!hasWord) {\n return (\n // A named image with a label; without one it only decorates, never an unnamed image.\n <span\n role={ariaLabel ? \"img\" : undefined}\n aria-label={ariaLabel}\n aria-hidden={ariaLabel ? undefined : true}\n data-slot=\"lozenge\"\n data-tone={tone}\n data-appearance=\"plain\"\n data-live={isLive || undefined}\n className=\"inline-flex items-center\"\n >\n {dot}\n </span>\n );\n }\n return (\n // The halo is a shadow and takes no space, so a live dot gets the wider gap to keep the word clear of it.\n <span\n data-slot=\"lozenge\"\n data-tone={tone}\n data-appearance=\"plain\"\n data-live={isLive || undefined}\n className={cn(\"inline-flex items-center text-body text-ds-text\", isLive ? \"gap-ds-100\" : \"gap-ds-075\")}\n >\n {dot}\n <span data-slot=\"lozenge-label\">{children}</span>\n </span>\n );\n }\n return (\n <span\n data-slot=\"lozenge\"\n data-tone={tone}\n data-appearance={appearance}\n className={cn(\n \"inline-flex h-5 shrink-0 items-center gap-ds-050 rounded-ds-xsmall px-ds-075 text-body-small font-medium whitespace-nowrap\",\n appearance === \"bold\" ? BOLD[tone] : SUBTLE[tone],\n )}\n >\n {hasDot && <span data-slot=\"lozenge-dot\" aria-hidden className=\"size-1.5 rounded-ds-full bg-current\" />}\n {children}\n </span>\n );\n}\n"]}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
export type ScrollAreaProps = {
|
|
3
|
-
children: React.ReactNode;
|
|
4
|
-
/** Names the region; screen readers announce it when focus enters. */
|
|
5
|
-
"aria-label": string;
|
|
6
|
-
/** The region's height limit ("320px", 320, "60vh"); for horizontal areas, set the width on the parent. */
|
|
7
|
-
maxHeight?: number | string;
|
|
8
|
-
/**
|
|
9
|
-
* Fills the parent's height and scrolls inside it, for a pane in a flex column or a grid
|
|
10
|
-
* row that is given its height: a conversation's messages between its header and the reply box, a list
|
|
11
|
-
* beside it. The parent must give the area a definite height (`min-h-0` on a flex or grid child).
|
|
12
|
-
* Leave `maxHeight` out when filling.
|
|
13
|
-
*/
|
|
14
|
-
fill?: boolean;
|
|
15
|
-
orientation?: "vertical" | "horizontal" | "both";
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* A fixed-size region with its own native scroll (never hijacked) and the
|
|
19
|
-
* scrollbar contract (thin, a ds-border-bold thumb), plus an overflow
|
|
20
|
-
* shadow on each edge where content continues. When it holds nothing
|
|
21
|
-
* focusable it becomes a focusable region itself, so keyboard users can
|
|
22
|
-
* scroll it with the arrow keys.
|
|
23
|
-
*
|
|
24
|
-
* Known deviation: the design's 6px thumb is drawn by the platform's thin
|
|
25
|
-
* scrollbar (about 8–11px); standard CSS cannot size it further without
|
|
26
|
-
* replacing native scrolling. With `orientation="both"` the edge shadows
|
|
27
|
-
* follow the vertical axis.
|
|
28
|
-
*/
|
|
29
|
-
export declare function ScrollArea({ children, "aria-label": ariaLabel, maxHeight, fill, orientation }: ScrollAreaProps): React.JSX.Element;
|