@dloizides/ui-layout 1.12.2 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/dist/index.d.mts +107 -1
- package/dist/index.d.ts +107 -1
- package/dist/index.js +209 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +204 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.15.0
|
|
4
|
+
|
|
5
|
+
- **New: `CopyableId`** — show a long machine identifier (a GUID, a reference, a correlation id)
|
|
6
|
+
so a human can both READ enough of it to tell two apart and TAKE it in one action. Composes the
|
|
7
|
+
existing `TruncatedText`, so the middle-truncation work is reused rather than re-derived.
|
|
8
|
+
|
|
9
|
+
Driven by the AML console needing to surface a screening ID an analyst can copy and re-screen
|
|
10
|
+
with, but it is deliberately domain-free: every portal has identifiers it currently either hides
|
|
11
|
+
or dumps raw into a table cell.
|
|
12
|
+
|
|
13
|
+
Three things this gets right that a naive copy button does not:
|
|
14
|
+
|
|
15
|
+
1. **It copies the FULL value, never the display string.** A truncated GUID that a user
|
|
16
|
+
hand-selects yields `3f2a9c81…d4e7`, ellipsis and all, which silently fails wherever it is
|
|
17
|
+
pasted. Showing a truncated identifier with no copy affordance is strictly WORSE than not
|
|
18
|
+
showing it. The full value is always the accessible name and the web tooltip.
|
|
19
|
+
2. **Middle truncation, not tail.** Two GUIDs from one table share a prefix far more often than
|
|
20
|
+
intuition suggests, and `numberOfLines={1}` renders them IDENTICALLY. The tail is what tells
|
|
21
|
+
them apart, so both ends survive.
|
|
22
|
+
3. **A failed copy is SHOWN, not swallowed.** `navigator.clipboard` is not merely unreliable —
|
|
23
|
+
it is `undefined` outside a secure context, which is how every staging box and LAN preview in
|
|
24
|
+
this fleet is served, i.e. exactly where people hand-test. `copyText` therefore falls back to
|
|
25
|
+
`document.execCommand` over an off-screen textarea, and returns a boolean rather than
|
|
26
|
+
assuming. On total failure the control renders a distinct `common.copyFailed` state; a silent
|
|
27
|
+
failure would leave the user believing they hold an identifier they do not.
|
|
28
|
+
|
|
29
|
+
The status is carried in the control's accessible **NAME**, not its hint, because
|
|
30
|
+
`accessibilityHint` is dropped by react-native-web and never reaches the DOM — a screen-reader
|
|
31
|
+
user would otherwise get no confirmation at all.
|
|
32
|
+
|
|
33
|
+
No native clipboard dependency is taken. Hosts on React Native inject a `writer`
|
|
34
|
+
(`Clipboard.setString`); an injected writer that throws falls through to the DOM paths.
|
|
35
|
+
|
|
36
|
+
New `LAYOUT_I18N` keys — hosts binding a missing-key guard to that map (as aml-v2 does) will
|
|
37
|
+
fail their catalog test until these are defined: `common.copy`, `common.copyHint`,
|
|
38
|
+
`common.copied`, `common.copyFailed`, `common.copyableIdHint`.
|
|
39
|
+
|
|
3
40
|
## 1.12.2
|
|
4
41
|
|
|
5
42
|
- **Fix (`TruncatedText` STILL did not middle-truncate; 1.12.1's fix was the wrong mechanism).**
|
package/dist/index.d.mts
CHANGED
|
@@ -352,6 +352,100 @@ declare function truncateMiddle(value: string, maxChars: number): string;
|
|
|
352
352
|
*/
|
|
353
353
|
declare function formatUrlForDisplay(value: string): string;
|
|
354
354
|
|
|
355
|
+
/**
|
|
356
|
+
* CopyableId — show a long machine identifier (a GUID, a reference, a correlation id) so a human
|
|
357
|
+
* can both READ enough of it to tell two apart, and TAKE it in one action.
|
|
358
|
+
*
|
|
359
|
+
* WHY MIDDLE TRUNCATION AND NOT `numberOfLines={1}`: two GUIDs from the same table share a
|
|
360
|
+
* prefix far more often than intuition suggests, and tail-truncation renders them IDENTICALLY —
|
|
361
|
+
* `3f2a9c81-…`. The tail is what distinguishes them, so both ends must survive. That is exactly
|
|
362
|
+
* what `TruncatedText` already solves for URLs, so this composes it rather than re-deriving it.
|
|
363
|
+
*
|
|
364
|
+
* WHY A COPY BUTTON IS NOT OPTIONAL POLISH: an ID exists to be pasted somewhere else — into a
|
|
365
|
+
* re-screen, a support ticket, a SQL console. Displaying a truncated GUID with no copy affordance
|
|
366
|
+
* is strictly WORSE than not showing it, because what is on screen is not the value: hand-select
|
|
367
|
+
* it and you get `3f2a9c81…d4e7`, ellipsis and all, which silently fails wherever it is pasted.
|
|
368
|
+
* The full value is therefore always the accessible name and the web tooltip, and the button
|
|
369
|
+
* copies the full value, never the display string.
|
|
370
|
+
*
|
|
371
|
+
* FAILURE IS SHOWN, NOT SWALLOWED: see `copyText` — clipboard writes really do fail on plain
|
|
372
|
+
* http, which is how staging is served. A silent failure would hand the analyst a false belief.
|
|
373
|
+
*/
|
|
374
|
+
|
|
375
|
+
interface CopyableIdProps {
|
|
376
|
+
/** The full identifier. Always what gets copied, and always the accessible name / tooltip. */
|
|
377
|
+
value: string;
|
|
378
|
+
/** Optional eyebrow above the value (e.g. "Screening ID"). Pass pre-localized. */
|
|
379
|
+
label?: string;
|
|
380
|
+
/** Base testID; the copy control is `${testID}-copy` and the status text `${testID}-status`. */
|
|
381
|
+
testID: string;
|
|
382
|
+
/** Accessible name for the value itself. Pass pre-localized; falls back to the raw value. */
|
|
383
|
+
accessibilityLabel?: string;
|
|
384
|
+
/**
|
|
385
|
+
* Platform clipboard writer, for hosts that have one (React Native). Omit on web — the DOM
|
|
386
|
+
* paths in `copyText` cover it.
|
|
387
|
+
*/
|
|
388
|
+
writer?: (text: string) => void | Promise<void>;
|
|
389
|
+
}
|
|
390
|
+
declare const CopyableId: ({ value, label, testID, accessibilityLabel, writer, }: CopyableIdProps) => React.ReactElement;
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* The three states a copy affordance can be in. Its own file per the repo's
|
|
394
|
+
* "one exported enum per file" rule.
|
|
395
|
+
*
|
|
396
|
+
* `Failed` is a first-class state on purpose. Clipboard writes genuinely fail in the browser —
|
|
397
|
+
* a non-secure context (plain http, which is how every staging box and LAN preview is served)
|
|
398
|
+
* has no `navigator.clipboard` at all, and even on https the Permissions API can reject. A
|
|
399
|
+
* control that swallowed that would leave the analyst believing they hold an ID they do not,
|
|
400
|
+
* and they would only find out after pasting the WRONG thing into a re-screen.
|
|
401
|
+
*/
|
|
402
|
+
declare const enum CopyStatus {
|
|
403
|
+
Idle = "idle",
|
|
404
|
+
Copied = "copied",
|
|
405
|
+
Failed = "failed"
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/** How long the "Copied!"/"Copy failed" confirmation stays up before reverting to idle. */
|
|
409
|
+
declare const COPY_FEEDBACK_MS = 2000;
|
|
410
|
+
interface CopyToClipboard {
|
|
411
|
+
status: CopyStatus;
|
|
412
|
+
/** Fire-and-forget: performs the write and drives `status`. Safe to pass straight to onPress. */
|
|
413
|
+
copy: () => void;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* @param value the text to copy
|
|
417
|
+
* @param writer optional platform clipboard writer (see `copyText`)
|
|
418
|
+
*/
|
|
419
|
+
declare function useCopyToClipboard(value: string, writer?: (text: string) => void | Promise<void>): CopyToClipboard;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Write a string to the system clipboard, reporting honestly whether it worked.
|
|
423
|
+
*
|
|
424
|
+
* THREE PATHS, IN ORDER, BECAUSE THE OBVIOUS ONE IS NOT ENOUGH:
|
|
425
|
+
*
|
|
426
|
+
* 1. `navigator.clipboard.writeText` — the modern API. It is gated on a SECURE CONTEXT, so it is
|
|
427
|
+
* simply `undefined` on plain http. Every staging box and LAN preview in this fleet is served
|
|
428
|
+
* over http, which means the happy path is missing exactly where people test. It can also
|
|
429
|
+
* reject at call time (permission denied, document not focused), so the promise is caught, not
|
|
430
|
+
* assumed.
|
|
431
|
+
* 2. `document.execCommand('copy')` over an off-screen textarea — deprecated, but it is
|
|
432
|
+
* synchronous, needs no permission, and works in non-secure contexts. It is the reason a copy
|
|
433
|
+
* button behaves the same on http staging as on https prod.
|
|
434
|
+
* 3. Neither available (React Native, or a hostile browser) — return `false`. The caller then
|
|
435
|
+
* shows a visible failure instead of a fake "Copied!". A host that wants real native clipboard
|
|
436
|
+
* support injects its own writer rather than this package taking a native dependency.
|
|
437
|
+
*
|
|
438
|
+
* Returns `true` only when a write actually succeeded.
|
|
439
|
+
*/
|
|
440
|
+
/**
|
|
441
|
+
* Copy `value`, returning whether it landed on the clipboard.
|
|
442
|
+
*
|
|
443
|
+
* `writer` lets a host inject a platform clipboard (React Native's `Clipboard.setString`, say)
|
|
444
|
+
* without this package depending on one. An injected writer that throws falls through to the DOM
|
|
445
|
+
* paths rather than failing outright.
|
|
446
|
+
*/
|
|
447
|
+
declare function copyText(value: string, writer?: (text: string) => void | Promise<void>): Promise<boolean>;
|
|
448
|
+
|
|
355
449
|
declare function useFocusTrap(containerRef: RefObject<View | null>, enabled: boolean): void;
|
|
356
450
|
|
|
357
451
|
/** Default testIDs — match the apps' existing values so Playwright selectors keep working. */
|
|
@@ -408,6 +502,18 @@ declare const LAYOUT_I18N: {
|
|
|
408
502
|
readonly upgradePromptCtaHint: "settings.billing.upgradePrompt.ctaHint";
|
|
409
503
|
readonly upgradePromptDismiss: "settings.billing.upgradePrompt.dismiss";
|
|
410
504
|
readonly upgradePromptDismissHint: "settings.billing.upgradePrompt.dismissHint";
|
|
505
|
+
/** `CopyableId`: the copy control's label in each of its three states, plus its hint. */
|
|
506
|
+
readonly copy: "common.copy";
|
|
507
|
+
readonly copyHint: "common.copyHint";
|
|
508
|
+
readonly copied: "common.copied";
|
|
509
|
+
/**
|
|
510
|
+
* Shown when the clipboard write genuinely failed — non-secure context, denied permission.
|
|
511
|
+
* This string reaching a user is CORRECT behaviour, not a defect: the alternative is them
|
|
512
|
+
* believing they hold an identifier they do not.
|
|
513
|
+
*/
|
|
514
|
+
readonly copyFailed: "common.copyFailed";
|
|
515
|
+
/** `CopyableId`: hint on the value itself, explaining it is shortened for display. */
|
|
516
|
+
readonly copyableIdHint: "common.copyableIdHint";
|
|
411
517
|
};
|
|
412
518
|
|
|
413
|
-
export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingProps, LAYOUT_I18N, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, formatUrlForDisplay, truncateMiddle, useFocusTrap };
|
|
519
|
+
export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, COPY_FEEDBACK_MS, CopyStatus, type CopyToClipboard, CopyableId, type CopyableIdProps, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingProps, LAYOUT_I18N, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, copyText, formatUrlForDisplay, truncateMiddle, useCopyToClipboard, useFocusTrap };
|
package/dist/index.d.ts
CHANGED
|
@@ -352,6 +352,100 @@ declare function truncateMiddle(value: string, maxChars: number): string;
|
|
|
352
352
|
*/
|
|
353
353
|
declare function formatUrlForDisplay(value: string): string;
|
|
354
354
|
|
|
355
|
+
/**
|
|
356
|
+
* CopyableId — show a long machine identifier (a GUID, a reference, a correlation id) so a human
|
|
357
|
+
* can both READ enough of it to tell two apart, and TAKE it in one action.
|
|
358
|
+
*
|
|
359
|
+
* WHY MIDDLE TRUNCATION AND NOT `numberOfLines={1}`: two GUIDs from the same table share a
|
|
360
|
+
* prefix far more often than intuition suggests, and tail-truncation renders them IDENTICALLY —
|
|
361
|
+
* `3f2a9c81-…`. The tail is what distinguishes them, so both ends must survive. That is exactly
|
|
362
|
+
* what `TruncatedText` already solves for URLs, so this composes it rather than re-deriving it.
|
|
363
|
+
*
|
|
364
|
+
* WHY A COPY BUTTON IS NOT OPTIONAL POLISH: an ID exists to be pasted somewhere else — into a
|
|
365
|
+
* re-screen, a support ticket, a SQL console. Displaying a truncated GUID with no copy affordance
|
|
366
|
+
* is strictly WORSE than not showing it, because what is on screen is not the value: hand-select
|
|
367
|
+
* it and you get `3f2a9c81…d4e7`, ellipsis and all, which silently fails wherever it is pasted.
|
|
368
|
+
* The full value is therefore always the accessible name and the web tooltip, and the button
|
|
369
|
+
* copies the full value, never the display string.
|
|
370
|
+
*
|
|
371
|
+
* FAILURE IS SHOWN, NOT SWALLOWED: see `copyText` — clipboard writes really do fail on plain
|
|
372
|
+
* http, which is how staging is served. A silent failure would hand the analyst a false belief.
|
|
373
|
+
*/
|
|
374
|
+
|
|
375
|
+
interface CopyableIdProps {
|
|
376
|
+
/** The full identifier. Always what gets copied, and always the accessible name / tooltip. */
|
|
377
|
+
value: string;
|
|
378
|
+
/** Optional eyebrow above the value (e.g. "Screening ID"). Pass pre-localized. */
|
|
379
|
+
label?: string;
|
|
380
|
+
/** Base testID; the copy control is `${testID}-copy` and the status text `${testID}-status`. */
|
|
381
|
+
testID: string;
|
|
382
|
+
/** Accessible name for the value itself. Pass pre-localized; falls back to the raw value. */
|
|
383
|
+
accessibilityLabel?: string;
|
|
384
|
+
/**
|
|
385
|
+
* Platform clipboard writer, for hosts that have one (React Native). Omit on web — the DOM
|
|
386
|
+
* paths in `copyText` cover it.
|
|
387
|
+
*/
|
|
388
|
+
writer?: (text: string) => void | Promise<void>;
|
|
389
|
+
}
|
|
390
|
+
declare const CopyableId: ({ value, label, testID, accessibilityLabel, writer, }: CopyableIdProps) => React.ReactElement;
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* The three states a copy affordance can be in. Its own file per the repo's
|
|
394
|
+
* "one exported enum per file" rule.
|
|
395
|
+
*
|
|
396
|
+
* `Failed` is a first-class state on purpose. Clipboard writes genuinely fail in the browser —
|
|
397
|
+
* a non-secure context (plain http, which is how every staging box and LAN preview is served)
|
|
398
|
+
* has no `navigator.clipboard` at all, and even on https the Permissions API can reject. A
|
|
399
|
+
* control that swallowed that would leave the analyst believing they hold an ID they do not,
|
|
400
|
+
* and they would only find out after pasting the WRONG thing into a re-screen.
|
|
401
|
+
*/
|
|
402
|
+
declare const enum CopyStatus {
|
|
403
|
+
Idle = "idle",
|
|
404
|
+
Copied = "copied",
|
|
405
|
+
Failed = "failed"
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/** How long the "Copied!"/"Copy failed" confirmation stays up before reverting to idle. */
|
|
409
|
+
declare const COPY_FEEDBACK_MS = 2000;
|
|
410
|
+
interface CopyToClipboard {
|
|
411
|
+
status: CopyStatus;
|
|
412
|
+
/** Fire-and-forget: performs the write and drives `status`. Safe to pass straight to onPress. */
|
|
413
|
+
copy: () => void;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* @param value the text to copy
|
|
417
|
+
* @param writer optional platform clipboard writer (see `copyText`)
|
|
418
|
+
*/
|
|
419
|
+
declare function useCopyToClipboard(value: string, writer?: (text: string) => void | Promise<void>): CopyToClipboard;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Write a string to the system clipboard, reporting honestly whether it worked.
|
|
423
|
+
*
|
|
424
|
+
* THREE PATHS, IN ORDER, BECAUSE THE OBVIOUS ONE IS NOT ENOUGH:
|
|
425
|
+
*
|
|
426
|
+
* 1. `navigator.clipboard.writeText` — the modern API. It is gated on a SECURE CONTEXT, so it is
|
|
427
|
+
* simply `undefined` on plain http. Every staging box and LAN preview in this fleet is served
|
|
428
|
+
* over http, which means the happy path is missing exactly where people test. It can also
|
|
429
|
+
* reject at call time (permission denied, document not focused), so the promise is caught, not
|
|
430
|
+
* assumed.
|
|
431
|
+
* 2. `document.execCommand('copy')` over an off-screen textarea — deprecated, but it is
|
|
432
|
+
* synchronous, needs no permission, and works in non-secure contexts. It is the reason a copy
|
|
433
|
+
* button behaves the same on http staging as on https prod.
|
|
434
|
+
* 3. Neither available (React Native, or a hostile browser) — return `false`. The caller then
|
|
435
|
+
* shows a visible failure instead of a fake "Copied!". A host that wants real native clipboard
|
|
436
|
+
* support injects its own writer rather than this package taking a native dependency.
|
|
437
|
+
*
|
|
438
|
+
* Returns `true` only when a write actually succeeded.
|
|
439
|
+
*/
|
|
440
|
+
/**
|
|
441
|
+
* Copy `value`, returning whether it landed on the clipboard.
|
|
442
|
+
*
|
|
443
|
+
* `writer` lets a host inject a platform clipboard (React Native's `Clipboard.setString`, say)
|
|
444
|
+
* without this package depending on one. An injected writer that throws falls through to the DOM
|
|
445
|
+
* paths rather than failing outright.
|
|
446
|
+
*/
|
|
447
|
+
declare function copyText(value: string, writer?: (text: string) => void | Promise<void>): Promise<boolean>;
|
|
448
|
+
|
|
355
449
|
declare function useFocusTrap(containerRef: RefObject<View | null>, enabled: boolean): void;
|
|
356
450
|
|
|
357
451
|
/** Default testIDs — match the apps' existing values so Playwright selectors keep working. */
|
|
@@ -408,6 +502,18 @@ declare const LAYOUT_I18N: {
|
|
|
408
502
|
readonly upgradePromptCtaHint: "settings.billing.upgradePrompt.ctaHint";
|
|
409
503
|
readonly upgradePromptDismiss: "settings.billing.upgradePrompt.dismiss";
|
|
410
504
|
readonly upgradePromptDismissHint: "settings.billing.upgradePrompt.dismissHint";
|
|
505
|
+
/** `CopyableId`: the copy control's label in each of its three states, plus its hint. */
|
|
506
|
+
readonly copy: "common.copy";
|
|
507
|
+
readonly copyHint: "common.copyHint";
|
|
508
|
+
readonly copied: "common.copied";
|
|
509
|
+
/**
|
|
510
|
+
* Shown when the clipboard write genuinely failed — non-secure context, denied permission.
|
|
511
|
+
* This string reaching a user is CORRECT behaviour, not a defect: the alternative is them
|
|
512
|
+
* believing they hold an identifier they do not.
|
|
513
|
+
*/
|
|
514
|
+
readonly copyFailed: "common.copyFailed";
|
|
515
|
+
/** `CopyableId`: hint on the value itself, explaining it is shortened for display. */
|
|
516
|
+
readonly copyableIdHint: "common.copyableIdHint";
|
|
411
517
|
};
|
|
412
518
|
|
|
413
|
-
export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingProps, LAYOUT_I18N, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, formatUrlForDisplay, truncateMiddle, useFocusTrap };
|
|
519
|
+
export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, COPY_FEEDBACK_MS, CopyStatus, type CopyToClipboard, CopyableId, type CopyableIdProps, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingProps, LAYOUT_I18N, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, copyText, formatUrlForDisplay, truncateMiddle, useCopyToClipboard, useFocusTrap };
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,10 @@ var React8 = require('react');
|
|
|
4
4
|
var reactNative = require('react-native');
|
|
5
5
|
var uiFeedback = require('@dloizides/ui-feedback');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var a11y = require('@dloizides/a11y');
|
|
7
8
|
var reactDom = require('react-dom');
|
|
8
9
|
var uiIcons = require('@dloizides/ui-icons');
|
|
10
|
+
var rnWebHooks = require('@dloizides/rn-web-hooks');
|
|
9
11
|
|
|
10
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
13
|
|
|
@@ -66,7 +68,19 @@ var LAYOUT_I18N = {
|
|
|
66
68
|
upgradePromptCta: "settings.billing.upgradePrompt.cta",
|
|
67
69
|
upgradePromptCtaHint: "settings.billing.upgradePrompt.ctaHint",
|
|
68
70
|
upgradePromptDismiss: "settings.billing.upgradePrompt.dismiss",
|
|
69
|
-
upgradePromptDismissHint: "settings.billing.upgradePrompt.dismissHint"
|
|
71
|
+
upgradePromptDismissHint: "settings.billing.upgradePrompt.dismissHint",
|
|
72
|
+
/** `CopyableId`: the copy control's label in each of its three states, plus its hint. */
|
|
73
|
+
copy: "common.copy",
|
|
74
|
+
copyHint: "common.copyHint",
|
|
75
|
+
copied: "common.copied",
|
|
76
|
+
/**
|
|
77
|
+
* Shown when the clipboard write genuinely failed — non-secure context, denied permission.
|
|
78
|
+
* This string reaching a user is CORRECT behaviour, not a defect: the alternative is them
|
|
79
|
+
* believing they hold an identifier they do not.
|
|
80
|
+
*/
|
|
81
|
+
copyFailed: "common.copyFailed",
|
|
82
|
+
/** `CopyableId`: hint on the value itself, explaining it is shortened for display. */
|
|
83
|
+
copyableIdHint: "common.copyableIdHint"
|
|
70
84
|
};
|
|
71
85
|
var styles2 = reactNative.StyleSheet.create({
|
|
72
86
|
heading: {
|
|
@@ -670,7 +684,6 @@ function useResolvedDropdownVariant(explicit) {
|
|
|
670
684
|
const { width } = reactNative.useWindowDimensions();
|
|
671
685
|
return resolveDropdownVariant(explicit, width, reactNative.Platform.OS);
|
|
672
686
|
}
|
|
673
|
-
var IS_WEB3 = reactNative.Platform.OS === "web";
|
|
674
687
|
var BORDER_RADIUS3 = 8;
|
|
675
688
|
var BORDER_WIDTH4 = 1;
|
|
676
689
|
var BODY_FONT_SIZE2 = 14;
|
|
@@ -679,21 +692,8 @@ var MODAL_MIN_WIDTH = 200;
|
|
|
679
692
|
var MODAL_MAX_HEIGHT = 300;
|
|
680
693
|
var CONTAINER_PADDING_H = 12;
|
|
681
694
|
var CONTAINER_PADDING_V = 10;
|
|
682
|
-
var SR_ONLY_SIZE = 1;
|
|
683
|
-
var SR_ONLY_OFFSET = -1;
|
|
684
|
-
function buildHintProps(hint, hintId) {
|
|
685
|
-
return IS_WEB3 ? { "aria-describedby": hintId } : { accessibilityHint: hint };
|
|
686
|
-
}
|
|
687
695
|
var styles8 = reactNative.StyleSheet.create({
|
|
688
696
|
anchor: { position: "relative" },
|
|
689
|
-
srOnly: {
|
|
690
|
-
position: "absolute",
|
|
691
|
-
width: SR_ONLY_SIZE,
|
|
692
|
-
height: SR_ONLY_SIZE,
|
|
693
|
-
margin: SR_ONLY_OFFSET,
|
|
694
|
-
padding: 0,
|
|
695
|
-
overflow: "hidden"
|
|
696
|
-
},
|
|
697
697
|
container: {
|
|
698
698
|
borderWidth: BORDER_WIDTH4,
|
|
699
699
|
borderRadius: BORDER_RADIUS3,
|
|
@@ -731,7 +731,13 @@ var ModalDropdown = ({
|
|
|
731
731
|
const resolvedVariant = useResolvedDropdownVariant(variant);
|
|
732
732
|
const isMenu = resolvedVariant === "menu" /* Menu */;
|
|
733
733
|
const [isOpen, setIsOpen] = React8.useState(false);
|
|
734
|
-
const
|
|
734
|
+
const { a11yProps, hintNode } = a11y.useA11y({
|
|
735
|
+
label: accessibilityLabel,
|
|
736
|
+
hint: accessibilityHint,
|
|
737
|
+
role: "button",
|
|
738
|
+
state: { expanded: isOpen },
|
|
739
|
+
testID
|
|
740
|
+
});
|
|
735
741
|
const anchorRef = React8.useRef(null);
|
|
736
742
|
const dialogRef = React8.useRef(null);
|
|
737
743
|
useFocusTrap(dialogRef, isOpen && !isMenu);
|
|
@@ -782,22 +788,10 @@ var ModalDropdown = ({
|
|
|
782
788
|
);
|
|
783
789
|
const keyExtractor = React8.useCallback((item) => String(item.value), []);
|
|
784
790
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: anchorStyle, children: [
|
|
785
|
-
/* @__PURE__ */ jsxRuntime.
|
|
786
|
-
reactNative.
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
...buildHintProps(accessibilityHint, hintId),
|
|
790
|
-
accessibilityLabel,
|
|
791
|
-
accessibilityRole: "button",
|
|
792
|
-
accessibilityState: { expanded: isOpen },
|
|
793
|
-
"aria-expanded": isOpen,
|
|
794
|
-
style: containerStyle,
|
|
795
|
-
testID,
|
|
796
|
-
onPress: handleToggle,
|
|
797
|
-
children: renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles8.selectedText, { color: colors.text }], children: selectedLabel })
|
|
798
|
-
}
|
|
799
|
-
),
|
|
800
|
-
IS_WEB3 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { nativeID: hintId, style: styles8.srOnly, testID: `${testID}-hint`, children: accessibilityHint }) : null,
|
|
791
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.TouchableOpacity, { ...a11yProps, style: containerStyle, onPress: handleToggle, children: [
|
|
792
|
+
renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles8.selectedText, { color: colors.text }], children: selectedLabel }),
|
|
793
|
+
hintNode
|
|
794
|
+
] }),
|
|
801
795
|
isMenu && isOpen ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
802
796
|
InlineMenu,
|
|
803
797
|
{
|
|
@@ -926,12 +920,8 @@ function enableAndroidLayoutAnimationOnce() {
|
|
|
926
920
|
setter(true);
|
|
927
921
|
}
|
|
928
922
|
}
|
|
929
|
-
function prefersReducedMotion() {
|
|
930
|
-
if (reactNative.Platform.OS !== "web" || typeof window === "undefined" || typeof window.matchMedia !== "function") return false;
|
|
931
|
-
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
932
|
-
}
|
|
933
923
|
function animateNextLayout() {
|
|
934
|
-
if (prefersReducedMotion()) return;
|
|
924
|
+
if (rnWebHooks.prefersReducedMotion()) return;
|
|
935
925
|
enableAndroidLayoutAnimationOnce();
|
|
936
926
|
const configure = reactNative.LayoutAnimation.configureNext;
|
|
937
927
|
if (typeof configure !== "function") return;
|
|
@@ -1055,10 +1045,6 @@ var styles11 = reactNative.StyleSheet.create({
|
|
|
1055
1045
|
});
|
|
1056
1046
|
var ACTIVATION_KEYS = ["Enter", " ", "Spacebar"];
|
|
1057
1047
|
var INSTANT_DURATION_MS = 0;
|
|
1058
|
-
function prefersReducedMotion2() {
|
|
1059
|
-
if (reactNative.Platform.OS !== "web" || typeof window === "undefined" || typeof window.matchMedia !== "function") return false;
|
|
1060
|
-
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1061
|
-
}
|
|
1062
1048
|
var AccordionItem = ({
|
|
1063
1049
|
id,
|
|
1064
1050
|
title,
|
|
@@ -1080,14 +1066,15 @@ var AccordionItem = ({
|
|
|
1080
1066
|
const bodyTestID = `${headerTestID}-body`;
|
|
1081
1067
|
const chevronTestID = `${headerTestID}-chevron`;
|
|
1082
1068
|
const [rotation] = React8.useState(() => new reactNative.Animated.Value(expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED));
|
|
1069
|
+
const reducedMotion = rnWebHooks.useReducedMotion();
|
|
1083
1070
|
React8.useEffect(() => {
|
|
1084
1071
|
reactNative.Animated.timing(rotation, {
|
|
1085
1072
|
toValue: expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED,
|
|
1086
|
-
duration:
|
|
1073
|
+
duration: reducedMotion ? INSTANT_DURATION_MS : ROTATE_DURATION_MS,
|
|
1087
1074
|
easing: reactNative.Easing.out(reactNative.Easing.ease),
|
|
1088
1075
|
useNativeDriver: reactNative.Platform.OS !== "web"
|
|
1089
1076
|
}).start();
|
|
1090
|
-
}, [expanded, rotation]);
|
|
1077
|
+
}, [expanded, rotation, reducedMotion]);
|
|
1091
1078
|
const rotate = rotation.interpolate({
|
|
1092
1079
|
inputRange: [ROTATE_COLLAPSED, ROTATE_EXPANDED],
|
|
1093
1080
|
outputRange: [COLLAPSED_DEG, boxed ? BOXED_EXPANDED_DEG : PLAIN_EXPANDED_DEG]
|
|
@@ -1205,7 +1192,7 @@ function formatUrlForDisplay(value) {
|
|
|
1205
1192
|
return trimmed.length > 0 ? trimmed : value;
|
|
1206
1193
|
}
|
|
1207
1194
|
var UNMEASURED = 0;
|
|
1208
|
-
var
|
|
1195
|
+
var IS_WEB3 = reactNative.Platform.OS === "web";
|
|
1209
1196
|
function measureParentInnerWidth(node) {
|
|
1210
1197
|
const parent = node.parentElement;
|
|
1211
1198
|
if (parent === null) return UNMEASURED;
|
|
@@ -1217,12 +1204,12 @@ function useAvailableWidth() {
|
|
|
1217
1204
|
const [width, setWidth] = React8.useState(UNMEASURED);
|
|
1218
1205
|
const nodeRef = React8.useRef(null);
|
|
1219
1206
|
const measureRef = React8.useCallback((node) => {
|
|
1220
|
-
if (!
|
|
1207
|
+
if (!IS_WEB3) return;
|
|
1221
1208
|
nodeRef.current = node;
|
|
1222
1209
|
if (nodeRef.current !== null) setWidth(measureParentInnerWidth(nodeRef.current));
|
|
1223
1210
|
}, []);
|
|
1224
1211
|
React8.useEffect(() => {
|
|
1225
|
-
if (!
|
|
1212
|
+
if (!IS_WEB3) return void 0;
|
|
1226
1213
|
const remeasure = () => {
|
|
1227
1214
|
const node = nodeRef.current;
|
|
1228
1215
|
if (node !== null) setWidth(measureParentInnerWidth(node));
|
|
@@ -1231,7 +1218,7 @@ function useAvailableWidth() {
|
|
|
1231
1218
|
return () => window.removeEventListener("resize", remeasure);
|
|
1232
1219
|
}, []);
|
|
1233
1220
|
const onLayout = React8.useCallback((event) => {
|
|
1234
|
-
if (
|
|
1221
|
+
if (IS_WEB3) return;
|
|
1235
1222
|
setWidth(event.nativeEvent.layout.width);
|
|
1236
1223
|
}, []);
|
|
1237
1224
|
return { width, measureRef, onLayout };
|
|
@@ -1297,8 +1284,181 @@ var TruncatedText = ({
|
|
|
1297
1284
|
);
|
|
1298
1285
|
};
|
|
1299
1286
|
|
|
1287
|
+
// src/CopyableId/CopyStatus.ts
|
|
1288
|
+
var CopyStatus = /* @__PURE__ */ ((CopyStatus2) => {
|
|
1289
|
+
CopyStatus2["Idle"] = "idle";
|
|
1290
|
+
CopyStatus2["Copied"] = "copied";
|
|
1291
|
+
CopyStatus2["Failed"] = "failed";
|
|
1292
|
+
return CopyStatus2;
|
|
1293
|
+
})(CopyStatus || {});
|
|
1294
|
+
|
|
1295
|
+
// src/CopyableId/copyText.ts
|
|
1296
|
+
var OFFSCREEN_POSITION = "-9999px";
|
|
1297
|
+
function hasDom() {
|
|
1298
|
+
return typeof document !== "undefined" && document.body !== null;
|
|
1299
|
+
}
|
|
1300
|
+
function copyViaExecCommand(value) {
|
|
1301
|
+
if (!hasDom()) return false;
|
|
1302
|
+
const area = document.createElement("textarea");
|
|
1303
|
+
area.value = value;
|
|
1304
|
+
area.readOnly = true;
|
|
1305
|
+
area.setAttribute("aria-hidden", "true");
|
|
1306
|
+
area.style.position = "fixed";
|
|
1307
|
+
area.style.top = OFFSCREEN_POSITION;
|
|
1308
|
+
area.style.left = OFFSCREEN_POSITION;
|
|
1309
|
+
area.style.opacity = "0";
|
|
1310
|
+
document.body.appendChild(area);
|
|
1311
|
+
try {
|
|
1312
|
+
area.select();
|
|
1313
|
+
area.setSelectionRange(0, value.length);
|
|
1314
|
+
return document.execCommand("copy");
|
|
1315
|
+
} catch {
|
|
1316
|
+
return false;
|
|
1317
|
+
} finally {
|
|
1318
|
+
document.body.removeChild(area);
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
function hasAsyncClipboard() {
|
|
1322
|
+
return typeof navigator !== "undefined" && typeof navigator.clipboard?.writeText === "function";
|
|
1323
|
+
}
|
|
1324
|
+
async function copyText(value, writer) {
|
|
1325
|
+
if (value === "") return false;
|
|
1326
|
+
if (writer !== void 0) {
|
|
1327
|
+
try {
|
|
1328
|
+
await writer(value);
|
|
1329
|
+
return true;
|
|
1330
|
+
} catch {
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
if (hasAsyncClipboard()) {
|
|
1334
|
+
try {
|
|
1335
|
+
await navigator.clipboard.writeText(value);
|
|
1336
|
+
return true;
|
|
1337
|
+
} catch {
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
return copyViaExecCommand(value);
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
// src/CopyableId/useCopyToClipboard.ts
|
|
1344
|
+
var COPY_FEEDBACK_MS = 2e3;
|
|
1345
|
+
function useCopyToClipboard(value, writer) {
|
|
1346
|
+
const [status, setStatus] = React8.useState("idle" /* Idle */);
|
|
1347
|
+
const timerRef = React8.useRef(null);
|
|
1348
|
+
const mountedRef = React8.useRef(true);
|
|
1349
|
+
React8.useEffect(() => {
|
|
1350
|
+
mountedRef.current = true;
|
|
1351
|
+
return () => {
|
|
1352
|
+
mountedRef.current = false;
|
|
1353
|
+
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
1354
|
+
};
|
|
1355
|
+
}, []);
|
|
1356
|
+
const copy = React8.useCallback(() => {
|
|
1357
|
+
void (async () => {
|
|
1358
|
+
const ok = await copyText(value, writer);
|
|
1359
|
+
if (!mountedRef.current) return;
|
|
1360
|
+
setStatus(ok ? "copied" /* Copied */ : "failed" /* Failed */);
|
|
1361
|
+
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
1362
|
+
timerRef.current = setTimeout(() => {
|
|
1363
|
+
if (mountedRef.current) setStatus("idle" /* Idle */);
|
|
1364
|
+
}, COPY_FEEDBACK_MS);
|
|
1365
|
+
})();
|
|
1366
|
+
}, [value, writer]);
|
|
1367
|
+
return { status, copy };
|
|
1368
|
+
}
|
|
1369
|
+
var LABEL_FONT_SIZE = 11;
|
|
1370
|
+
var VALUE_FONT_SIZE = 12;
|
|
1371
|
+
var ACTION_FONT_SIZE = 12;
|
|
1372
|
+
var ROW_GAP = 8;
|
|
1373
|
+
var CELL_GAP = 2;
|
|
1374
|
+
var LABEL_LETTER_SPACING = 0.4;
|
|
1375
|
+
var ACTION_PADDING_H = 6;
|
|
1376
|
+
var ACTION_PADDING_V = 2;
|
|
1377
|
+
var ACTION_RADIUS = 6;
|
|
1378
|
+
var styles13 = reactNative.StyleSheet.create({
|
|
1379
|
+
cell: { gap: CELL_GAP },
|
|
1380
|
+
label: {
|
|
1381
|
+
fontSize: LABEL_FONT_SIZE,
|
|
1382
|
+
fontWeight: "700",
|
|
1383
|
+
letterSpacing: LABEL_LETTER_SPACING,
|
|
1384
|
+
textTransform: "uppercase"
|
|
1385
|
+
},
|
|
1386
|
+
row: { flexDirection: "row", alignItems: "center", gap: ROW_GAP },
|
|
1387
|
+
/**
|
|
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. `minWidth: 0` is what
|
|
1390
|
+
* actually lets a flex child shrink below its content width — without it the row just grows and
|
|
1391
|
+
* nothing ever truncates.
|
|
1392
|
+
*/
|
|
1393
|
+
valueWrap: { flexShrink: 1, minWidth: 0 },
|
|
1394
|
+
value: { fontSize: VALUE_FONT_SIZE, fontWeight: "600" },
|
|
1395
|
+
action: {
|
|
1396
|
+
fontSize: ACTION_FONT_SIZE,
|
|
1397
|
+
fontWeight: "600",
|
|
1398
|
+
paddingHorizontal: ACTION_PADDING_H,
|
|
1399
|
+
paddingVertical: ACTION_PADDING_V,
|
|
1400
|
+
borderRadius: ACTION_RADIUS
|
|
1401
|
+
}
|
|
1402
|
+
});
|
|
1403
|
+
var TONE_STEP = "500";
|
|
1404
|
+
function useActionState(status) {
|
|
1405
|
+
const { theme } = uiFeedback.useUi();
|
|
1406
|
+
return React8.useMemo(() => {
|
|
1407
|
+
const primary = theme.palette.primary[TONE_STEP];
|
|
1408
|
+
if (status === "copied" /* Copied */) {
|
|
1409
|
+
return { key: LAYOUT_I18N.copied, color: theme.semantic.success?.[TONE_STEP] ?? primary };
|
|
1410
|
+
}
|
|
1411
|
+
if (status === "failed" /* Failed */) {
|
|
1412
|
+
return { key: LAYOUT_I18N.copyFailed, color: theme.semantic.error[TONE_STEP] };
|
|
1413
|
+
}
|
|
1414
|
+
return { key: LAYOUT_I18N.copy, color: primary };
|
|
1415
|
+
}, [status, theme]);
|
|
1416
|
+
}
|
|
1417
|
+
var CopyableId = ({
|
|
1418
|
+
value,
|
|
1419
|
+
label,
|
|
1420
|
+
testID,
|
|
1421
|
+
accessibilityLabel,
|
|
1422
|
+
writer
|
|
1423
|
+
}) => {
|
|
1424
|
+
const { theme, t } = uiFeedback.useUi();
|
|
1425
|
+
const { colors } = theme;
|
|
1426
|
+
const { status, copy } = useCopyToClipboard(value, writer);
|
|
1427
|
+
const action = useActionState(status);
|
|
1428
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles13.cell, testID, children: [
|
|
1429
|
+
label !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles13.label, { color: colors.textSecondary }], children: label }),
|
|
1430
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles13.row, children: [
|
|
1431
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles13.valueWrap, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1432
|
+
TruncatedText,
|
|
1433
|
+
{
|
|
1434
|
+
value,
|
|
1435
|
+
style: [styles13.value, { color: colors.text }],
|
|
1436
|
+
testID: `${testID}-value`,
|
|
1437
|
+
accessibilityLabel: accessibilityLabel ?? value,
|
|
1438
|
+
accessibilityHint: t(LAYOUT_I18N.copyableIdHint)
|
|
1439
|
+
}
|
|
1440
|
+
) }),
|
|
1441
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1442
|
+
reactNative.Text,
|
|
1443
|
+
{
|
|
1444
|
+
onPress: copy,
|
|
1445
|
+
accessibilityRole: "button",
|
|
1446
|
+
accessibilityLabel: t(action.key),
|
|
1447
|
+
accessibilityHint: t(LAYOUT_I18N.copyHint),
|
|
1448
|
+
testID: `${testID}-copy`,
|
|
1449
|
+
style: [styles13.action, { color: action.color }],
|
|
1450
|
+
children: t(action.key)
|
|
1451
|
+
}
|
|
1452
|
+
)
|
|
1453
|
+
] })
|
|
1454
|
+
] });
|
|
1455
|
+
};
|
|
1456
|
+
|
|
1300
1457
|
exports.Accordion = Accordion;
|
|
1301
1458
|
exports.AccordionItem = AccordionItem;
|
|
1459
|
+
exports.COPY_FEEDBACK_MS = COPY_FEEDBACK_MS;
|
|
1460
|
+
exports.CopyStatus = CopyStatus;
|
|
1461
|
+
exports.CopyableId = CopyableId;
|
|
1302
1462
|
exports.DEFAULT_BILLING_ROUTE = DEFAULT_BILLING_ROUTE;
|
|
1303
1463
|
exports.DropdownVariant = DropdownVariant;
|
|
1304
1464
|
exports.ELLIPSIS = ELLIPSIS;
|
|
@@ -1312,8 +1472,10 @@ exports.SegmentedControl = SegmentedControl;
|
|
|
1312
1472
|
exports.StatusBadge = StatusBadge;
|
|
1313
1473
|
exports.TruncatedText = TruncatedText;
|
|
1314
1474
|
exports.UpgradePrompt = UpgradePrompt;
|
|
1475
|
+
exports.copyText = copyText;
|
|
1315
1476
|
exports.formatUrlForDisplay = formatUrlForDisplay;
|
|
1316
1477
|
exports.truncateMiddle = truncateMiddle;
|
|
1478
|
+
exports.useCopyToClipboard = useCopyToClipboard;
|
|
1317
1479
|
exports.useFocusTrap = useFocusTrap;
|
|
1318
1480
|
//# sourceMappingURL=index.js.map
|
|
1319
1481
|
//# sourceMappingURL=index.js.map
|