@dloizides/ui-layout 1.15.0 → 1.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/dist/index.d.mts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +14 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.15.1
|
|
4
|
+
|
|
5
|
+
- **Fix (`CopyableId` truncated the value with room to spare).** 1.15.0 gave the value wrapper
|
|
6
|
+
`flexShrink: 1`, which makes it SHRINK-WRAP its content — so the width the component measures to
|
|
7
|
+
decide how much to show was derived from the very string it was computing: truncate → wrapper
|
|
8
|
+
narrows → re-measure smaller → truncate harder. Verified in Chrome via `apps/ui-showcase`: a
|
|
9
|
+
506px-wide container and a 306px one rendered the SAME 196px string, i.e. a 36-character GUID was
|
|
10
|
+
cut to 26 characters with ~300px going unused.
|
|
11
|
+
|
|
12
|
+
The wrapper is now `flex: 1`, so it fills the row's leftover width and its size is independent of
|
|
13
|
+
its content. Re-verified at four widths: 520px and 320px now render the full 36-character GUID
|
|
14
|
+
untruncated; 200px and 120px middle-truncate with both ends intact, and nothing overflows.
|
|
15
|
+
|
|
16
|
+
This is the SAME failure mode `useAvailableWidth` documents for `TruncatedText` (measure the
|
|
17
|
+
parent, never the element, or the output feeds back into the input) — reintroduced one level up
|
|
18
|
+
by the new wrapper. Unit tests cannot catch it: the truncation helpers are pure and passed
|
|
19
|
+
throughout, and jsdom reports zero widths, so only a real browser shows it.
|
|
20
|
+
|
|
21
|
+
- **New: `CopyableId` accepts `style`** for its outer container. Hosts need this to give the
|
|
22
|
+
control a width that does not derive from its own content (a `flexBasis`, a `width`, or
|
|
23
|
+
`flex: 1`) — without one, a shrink-to-fit parent reintroduces the feedback loop above at the
|
|
24
|
+
host level. Documented on the prop.
|
|
25
|
+
|
|
3
26
|
## 1.15.0
|
|
4
27
|
|
|
5
28
|
- **New: `CopyableId`** — show a long machine identifier (a GUID, a reference, a correlation id)
|
package/dist/index.d.mts
CHANGED
|
@@ -377,7 +377,16 @@ interface CopyableIdProps {
|
|
|
377
377
|
value: string;
|
|
378
378
|
/** Optional eyebrow above the value (e.g. "Screening ID"). Pass pre-localized. */
|
|
379
379
|
label?: string;
|
|
380
|
-
/**
|
|
380
|
+
/**
|
|
381
|
+
* Style for the outer container.
|
|
382
|
+
*
|
|
383
|
+
* Hosts should give this a width that does NOT derive from its own content — a `flexBasis`, a
|
|
384
|
+
* `width`, or `flex: 1`. The component measures its container to decide how much of the value
|
|
385
|
+
* to show, so a shrink-to-fit parent makes the available width depend on the string being
|
|
386
|
+
* computed, and the id renders clipped with space to spare.
|
|
387
|
+
*/
|
|
388
|
+
style?: StyleProp<ViewStyle>;
|
|
389
|
+
/** Base testID; the copy control is `${testID}-copy` and the value `${testID}-value`. */
|
|
381
390
|
testID: string;
|
|
382
391
|
/** Accessible name for the value itself. Pass pre-localized; falls back to the raw value. */
|
|
383
392
|
accessibilityLabel?: string;
|
|
@@ -387,7 +396,7 @@ interface CopyableIdProps {
|
|
|
387
396
|
*/
|
|
388
397
|
writer?: (text: string) => void | Promise<void>;
|
|
389
398
|
}
|
|
390
|
-
declare const CopyableId: ({ value, label, testID, accessibilityLabel, writer, }: CopyableIdProps) => React.ReactElement;
|
|
399
|
+
declare const CopyableId: ({ value, label, style, testID, accessibilityLabel, writer, }: CopyableIdProps) => React.ReactElement;
|
|
391
400
|
|
|
392
401
|
/**
|
|
393
402
|
* The three states a copy affordance can be in. Its own file per the repo's
|
package/dist/index.d.ts
CHANGED
|
@@ -377,7 +377,16 @@ interface CopyableIdProps {
|
|
|
377
377
|
value: string;
|
|
378
378
|
/** Optional eyebrow above the value (e.g. "Screening ID"). Pass pre-localized. */
|
|
379
379
|
label?: string;
|
|
380
|
-
/**
|
|
380
|
+
/**
|
|
381
|
+
* Style for the outer container.
|
|
382
|
+
*
|
|
383
|
+
* Hosts should give this a width that does NOT derive from its own content — a `flexBasis`, a
|
|
384
|
+
* `width`, or `flex: 1`. The component measures its container to decide how much of the value
|
|
385
|
+
* to show, so a shrink-to-fit parent makes the available width depend on the string being
|
|
386
|
+
* computed, and the id renders clipped with space to spare.
|
|
387
|
+
*/
|
|
388
|
+
style?: StyleProp<ViewStyle>;
|
|
389
|
+
/** Base testID; the copy control is `${testID}-copy` and the value `${testID}-value`. */
|
|
381
390
|
testID: string;
|
|
382
391
|
/** Accessible name for the value itself. Pass pre-localized; falls back to the raw value. */
|
|
383
392
|
accessibilityLabel?: string;
|
|
@@ -387,7 +396,7 @@ interface CopyableIdProps {
|
|
|
387
396
|
*/
|
|
388
397
|
writer?: (text: string) => void | Promise<void>;
|
|
389
398
|
}
|
|
390
|
-
declare const CopyableId: ({ value, label, testID, accessibilityLabel, writer, }: CopyableIdProps) => React.ReactElement;
|
|
399
|
+
declare const CopyableId: ({ value, label, style, testID, accessibilityLabel, writer, }: CopyableIdProps) => React.ReactElement;
|
|
391
400
|
|
|
392
401
|
/**
|
|
393
402
|
* The three states a copy affordance can be in. Its own file per the repo's
|
package/dist/index.js
CHANGED
|
@@ -1386,11 +1386,19 @@ var styles13 = reactNative.StyleSheet.create({
|
|
|
1386
1386
|
row: { flexDirection: "row", alignItems: "center", gap: ROW_GAP },
|
|
1387
1387
|
/**
|
|
1388
1388
|
* The truncation width comes from this wrapper, not from the row: `TruncatedText` measures its
|
|
1389
|
-
* PARENT (see `useAvailableWidth`), and the row also holds the button.
|
|
1390
|
-
*
|
|
1391
|
-
*
|
|
1389
|
+
* PARENT (see `useAvailableWidth`), and the row also holds the copy button.
|
|
1390
|
+
*
|
|
1391
|
+
* `flex: 1` IS LOAD-BEARING — do not weaken it to `flexShrink: 1`. A shrink-only wrapper
|
|
1392
|
+
* SHRINK-WRAPS its content, which makes the measured parent width depend on the very string we
|
|
1393
|
+
* are computing: truncate -> wrapper narrows -> re-measure smaller -> truncate harder. Verified
|
|
1394
|
+
* in Chrome: with `flexShrink: 1` a 506px-wide container and a 306px one both rendered the SAME
|
|
1395
|
+
* 196px string, i.e. the id was cut short with 300px of room going spare. `flex: 1` makes the
|
|
1396
|
+
* wrapper fill the row's leftover width instead, so its size is independent of what we put in
|
|
1397
|
+
* it — the same reason `useAvailableWidth` measures the parent and not the element.
|
|
1398
|
+
*
|
|
1399
|
+
* `minWidth: 0` is what actually permits a flex child to go below its content width.
|
|
1392
1400
|
*/
|
|
1393
|
-
valueWrap: {
|
|
1401
|
+
valueWrap: { flex: 1, minWidth: 0 },
|
|
1394
1402
|
value: { fontSize: VALUE_FONT_SIZE, fontWeight: "600" },
|
|
1395
1403
|
action: {
|
|
1396
1404
|
fontSize: ACTION_FONT_SIZE,
|
|
@@ -1417,6 +1425,7 @@ function useActionState(status) {
|
|
|
1417
1425
|
var CopyableId = ({
|
|
1418
1426
|
value,
|
|
1419
1427
|
label,
|
|
1428
|
+
style,
|
|
1420
1429
|
testID,
|
|
1421
1430
|
accessibilityLabel,
|
|
1422
1431
|
writer
|
|
@@ -1425,7 +1434,7 @@ var CopyableId = ({
|
|
|
1425
1434
|
const { colors } = theme;
|
|
1426
1435
|
const { status, copy } = useCopyToClipboard(value, writer);
|
|
1427
1436
|
const action = useActionState(status);
|
|
1428
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles13.cell, testID, children: [
|
|
1437
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles13.cell, style], testID, children: [
|
|
1429
1438
|
label !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles13.label, { color: colors.textSecondary }], children: label }),
|
|
1430
1439
|
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles13.row, children: [
|
|
1431
1440
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles13.valueWrap, children: /* @__PURE__ */ jsxRuntime.jsx(
|