@hjmds/react 1.30.0 → 1.31.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/dist/auth-screen.d.ts +18 -3
- package/dist/auth-screen.d.ts.map +1 -1
- package/dist/auth-screen.js +22 -6
- package/dist/auth-screen.js.map +1 -1
- package/dist/bottom-navigation.d.ts +7 -0
- package/dist/bottom-navigation.d.ts.map +1 -1
- package/dist/bottom-navigation.js +64 -8
- package/dist/bottom-navigation.js.map +1 -1
- package/dist/carousel.d.ts +29 -1
- package/dist/carousel.d.ts.map +1 -1
- package/dist/carousel.js +27 -3
- package/dist/carousel.js.map +1 -1
- package/dist/display.d.ts +8 -2
- package/dist/display.d.ts.map +1 -1
- package/dist/display.js +12 -7
- package/dist/display.js.map +1 -1
- package/dist/evidence.d.ts +1 -1
- package/dist/evidence.js +1 -1
- package/dist/evidence.js.map +1 -1
- package/dist/forms.d.ts.map +1 -1
- package/dist/forms.js +2 -1
- package/dist/forms.js.map +1 -1
- package/dist/image-choice.d.ts +5 -0
- package/dist/image-choice.d.ts.map +1 -1
- package/dist/image-choice.js +4 -3
- package/dist/image-choice.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/internal/field-error.d.ts +19 -0
- package/dist/internal/field-error.d.ts.map +1 -0
- package/dist/internal/field-error.js +19 -0
- package/dist/internal/field-error.js.map +1 -0
- package/dist/internal/initial-focus.d.ts.map +1 -1
- package/dist/internal/initial-focus.js +49 -7
- package/dist/internal/initial-focus.js.map +1 -1
- package/dist/internal/media-album.d.ts +49 -0
- package/dist/internal/media-album.d.ts.map +1 -0
- package/dist/internal/media-album.js +31 -0
- package/dist/internal/media-album.js.map +1 -0
- package/dist/internal/message-reactions.d.ts +28 -2
- package/dist/internal/message-reactions.d.ts.map +1 -1
- package/dist/internal/message-reactions.js +21 -5
- package/dist/internal/message-reactions.js.map +1 -1
- package/dist/layout.d.ts +19 -3
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +10 -3
- package/dist/layout.js.map +1 -1
- package/dist/navigation.d.ts +3 -1
- package/dist/navigation.d.ts.map +1 -1
- package/dist/navigation.js +4 -2
- package/dist/navigation.js.map +1 -1
- package/dist/number-field.d.ts.map +1 -1
- package/dist/number-field.js +2 -1
- package/dist/number-field.js.map +1 -1
- package/dist/overlays.d.ts +65 -0
- package/dist/overlays.d.ts.map +1 -1
- package/dist/overlays.js +36 -3
- package/dist/overlays.js.map +1 -1
- package/dist/public-exports.generated.d.ts +7 -0
- package/dist/public-exports.generated.d.ts.map +1 -1
- package/dist/public-exports.generated.js +21 -0
- package/dist/public-exports.generated.js.map +1 -1
- package/dist/screen-flows.d.ts +104 -12
- package/dist/screen-flows.d.ts.map +1 -1
- package/dist/screen-flows.js +87 -18
- package/dist/screen-flows.js.map +1 -1
- package/dist/screens.d.ts +59 -8
- package/dist/screens.d.ts.map +1 -1
- package/dist/screens.js +57 -15
- package/dist/screens.js.map +1 -1
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +2 -1
- package/dist/select.js.map +1 -1
- package/dist/selection.d.ts.map +1 -1
- package/dist/selection.js +3 -2
- package/dist/selection.js.map +1 -1
- package/dist/steps.d.ts +11 -1
- package/dist/steps.d.ts.map +1 -1
- package/dist/steps.js +11 -6
- package/dist/steps.js.map +1 -1
- package/dist/styles.css +139 -20
- package/dist/styles.layered.css +139 -20
- package/dist/supplemental-display.d.ts.map +1 -1
- package/dist/supplemental-display.js +2 -48
- package/dist/supplemental-display.js.map +1 -1
- package/dist/theme.d.ts.map +1 -1
- package/dist/theme.js +1 -0
- package/dist/theme.js.map +1 -1
- package/package.json +3 -3
|
@@ -10,6 +10,20 @@ import { getTopModal, subscribeModalClose } from "../modal.js";
|
|
|
10
10
|
const InitialFocusContext = createContext(null);
|
|
11
11
|
/** Layer of the enclosing HJM overlay; null on the page itself. A ScreenLayout inside a sheet uses the sheet's. */
|
|
12
12
|
const ModalLayerContext = createContext(null);
|
|
13
|
+
/**
|
|
14
|
+
* Screen scopes rendered inside an HJM overlay, keyed by that overlay's layer. Their fields register with the screen,
|
|
15
|
+
* not the overlay, so the overlay's activation asks them for the entry field instead of focusing its first control
|
|
16
|
+
* over them (BurnTok search: a ScreenLayout in a Sheet left focus on the close button, 2026-10-18).
|
|
17
|
+
*/
|
|
18
|
+
const nestedScopes = new WeakMap();
|
|
19
|
+
/**
|
|
20
|
+
* Product modals (not on the HJM stack) layered above the scope. A product modal that contains the scope's own fields
|
|
21
|
+
* wraps the screen rather than covering it, so it does not block (BurnTok search overlay, 2026-10-18).
|
|
22
|
+
*/
|
|
23
|
+
function productModalAbove(fields) {
|
|
24
|
+
return [...document.querySelectorAll('[aria-modal="true"], dialog[open]')]
|
|
25
|
+
.some(modal => !fields.some(field => modal.contains(field)));
|
|
26
|
+
}
|
|
13
27
|
function isEditable(element) {
|
|
14
28
|
return element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement || element instanceof HTMLSelectElement
|
|
15
29
|
|| (element instanceof HTMLElement && element.isContentEditable);
|
|
@@ -28,11 +42,18 @@ export function useInitialFocusScope({ mode, active = true, layer: ownLayer }) {
|
|
|
28
42
|
const scope = useMemo(() => {
|
|
29
43
|
const s = state.current;
|
|
30
44
|
const blocked = () => {
|
|
45
|
+
const own = layer?.current ?? null;
|
|
46
|
+
// Inside an HJM overlay that is not on the stack yet: its activation runs this scope's entry (`nestedScopes`).
|
|
47
|
+
if (layer !== null && own === null)
|
|
48
|
+
return true;
|
|
31
49
|
const top = getTopModal();
|
|
32
50
|
if (top)
|
|
33
|
-
return top !==
|
|
34
|
-
// A product's own modal
|
|
35
|
-
|
|
51
|
+
return top !== own;
|
|
52
|
+
// A product's own modal above the page still covers it; overlay content is portaled outside product markup.
|
|
53
|
+
if (layer !== null)
|
|
54
|
+
return false;
|
|
55
|
+
const fields = [...s.entries].map(entry => entry.element()).filter((element) => element !== null);
|
|
56
|
+
return productModalAbove(fields);
|
|
36
57
|
};
|
|
37
58
|
const dispatch = (event) => {
|
|
38
59
|
const candidates = [...s.entries].map(entry => ({ entry, order: entry.order, preference: entry.preference, focusable: entry.focusable() }));
|
|
@@ -67,17 +88,29 @@ export function useInitialFocusScope({ mode, active = true, layer: ownLayer }) {
|
|
|
67
88
|
return () => { s.entries.delete(entry); s.fresh.delete(entry); };
|
|
68
89
|
},
|
|
69
90
|
};
|
|
91
|
+
const settle = () => { s.phase = "settled"; };
|
|
70
92
|
const enter = (explicit) => {
|
|
71
93
|
s.fresh.clear();
|
|
72
94
|
dispatch({ kind: "activate" });
|
|
95
|
+
const nested = overlay && layer ? [...(nestedScopes.get(layer) ?? [])] : [];
|
|
73
96
|
if (explicit) {
|
|
74
|
-
|
|
97
|
+
settle();
|
|
98
|
+
for (const scope of nested)
|
|
99
|
+
scope.settle();
|
|
75
100
|
return null;
|
|
76
101
|
}
|
|
77
|
-
|
|
102
|
+
const own = dispatch({ kind: "enter" });
|
|
103
|
+
if (own)
|
|
104
|
+
return own;
|
|
105
|
+
for (const scope of nested) {
|
|
106
|
+
const target = scope.enter();
|
|
107
|
+
if (target)
|
|
108
|
+
return target;
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
78
111
|
};
|
|
79
|
-
return { registry, layer, dispatch, focus, enter };
|
|
80
|
-
}, [layer]);
|
|
112
|
+
return { registry, layer, dispatch, focus, enter, settle };
|
|
113
|
+
}, [layer, overlay]);
|
|
81
114
|
useEffect(() => {
|
|
82
115
|
if (!active) {
|
|
83
116
|
scope.dispatch({ kind: "deactivate" });
|
|
@@ -89,6 +122,14 @@ export function useInitialFocusScope({ mode, active = true, layer: ownLayer }) {
|
|
|
89
122
|
if (!overlay)
|
|
90
123
|
queueMicrotask(() => { if (!cancelled)
|
|
91
124
|
scope.focus(scope.enter(false)); });
|
|
125
|
+
// A screen inside an overlay that activates later enters when the overlay does (see `enter`).
|
|
126
|
+
let nested;
|
|
127
|
+
const nestedEntry = { enter: () => scope.enter(false), settle: scope.settle };
|
|
128
|
+
if (!overlay && scope.layer) {
|
|
129
|
+
nested = nestedScopes.get(scope.layer) ?? new Set();
|
|
130
|
+
nestedScopes.set(scope.layer, nested);
|
|
131
|
+
nested.add(nestedEntry);
|
|
132
|
+
}
|
|
92
133
|
const interact = () => { scope.dispatch({ kind: "interact" }); };
|
|
93
134
|
const events = ["pointerdown", "keydown", "wheel", "touchstart"];
|
|
94
135
|
for (const type of events)
|
|
@@ -97,6 +138,7 @@ export function useInitialFocusScope({ mode, active = true, layer: ownLayer }) {
|
|
|
97
138
|
const unsubscribe = subscribeModalClose(() => scope.focus(scope.dispatch({ kind: "unblock" })));
|
|
98
139
|
return () => {
|
|
99
140
|
cancelled = true;
|
|
141
|
+
nested?.delete(nestedEntry);
|
|
100
142
|
for (const type of events)
|
|
101
143
|
document.removeEventListener(type, interact, true);
|
|
102
144
|
unsubscribe();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initial-focus.js","sourceRoot":"","sources":["../../src/internal/initial-focus.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAiG,MAAM,yCAAyC,CAAC;AAC3K,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAkC,MAAM,OAAO,CAAC;AAC/H,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAoB,MAAM,aAAa,CAAC;AAOjF;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,aAAa,CAAkB,IAAI,CAAC,CAAC;AACjE,mHAAmH;AACnH,MAAM,iBAAiB,GAAG,aAAa,CAAuB,IAAI,CAAC,CAAC;AAEpE,SAAS,UAAU,CAAC,OAAuB;IACzC,OAAO,OAAO,YAAY,gBAAgB,IAAI,OAAO,YAAY,mBAAmB,IAAI,OAAO,YAAY,iBAAiB;WACvH,CAAC,OAAO,YAAY,WAAW,IAAI,OAAO,CAAC,iBAAiB,CAA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C,iHAAiH;QACjH,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC;QACvC,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC,SAAS,EAAE,CAAC;QACvC,OAAO,QAAQ,CAAC,QAAQ,CAAC;YACvB,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO;YAChE,4DAA4D;YAC5D,SAAS,EAAE,GAAG,EAAE,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,OAA0D,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;SACzJ,EAAE,OAAO,CAAC,CAAC;IACd,CAAC,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import { resolveEntryFocus, type EntryFocusEvent, type EntryFocusPhase, type InitialFocusCandidate, type InitialFocusMode } from \"@hjmds/design-contracts/screen-patterns\";\nimport { createContext, useContext, useEffect, useLayoutEffect, useMemo, useRef, type ReactNode, type RefObject } from \"react\";\nimport { getTopModal, subscribeModalClose, type ActiveModal } from \"../modal.js\";\n\ntype Entry = { order: number; preference: boolean | undefined; element(): HTMLElement | null; focusable(): boolean };\ntype Registry = { nextOrder(): number; register(entry: Entry, mounted: boolean): () => void };\n/** The overlay's own entry on the shared modal stack while it is active (set by `useModalFocus`). */\nexport type ModalLayerRef = { current: ActiveModal | null };\n\n/**\n * Nearest screen/overlay scope that chooses the field focused on entry (rules: screen-patterns `resolveEntryFocus`,\n * shared with Native). Fields register by context, the same model as Native, instead of the scope querying the DOM; a\n * scope with mode \"none\" still owns its fields so they never reach an outer scope.\n */\nconst InitialFocusContext = createContext<Registry | null>(null);\n/** Layer of the enclosing HJM overlay; null on the page itself. A ScreenLayout inside a sheet uses the sheet's. */\nconst ModalLayerContext = createContext<ModalLayerRef | null>(null);\n\nfunction isEditable(element: Element | null): boolean {\n return element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement || element instanceof HTMLSelectElement\n || (element instanceof HTMLElement && element.isContentEditable);\n}\n\ntype Candidate = InitialFocusCandidate & { entry: Entry };\nexport type InitialFocusScopeHandle = Readonly<{\n registry: Registry;\n layer: ModalLayerRef | null;\n /**\n * Overlays only: runs entry when the modal activates and returns the field for `useModalFocus` to focus. `explicit`\n * means the overlay already has an `initialFocusRef`, so entry settles without choosing a field.\n */\n enter(explicit: boolean): HTMLElement | null;\n}>;\n\n/**\n * Screen scopes enter on mount (Web has no enter transition to wait for); overlays pass `layer` and enter through\n * `useModalFocus`. User pointer, key, wheel or touch input while no modal is above the scope ends the entry window.\n */\nexport function useInitialFocusScope({ mode, active = true, layer: ownLayer }: { mode: InitialFocusMode; active?: boolean; layer?: ModalLayerRef }): InitialFocusScopeHandle {\n const inherited = useContext(ModalLayerContext);\n const layer = ownLayer ?? inherited;\n const overlay = ownLayer !== undefined;\n const modeRef = useRef(mode); modeRef.current = mode;\n const state = useRef({ phase: \"inactive\" as EntryFocusPhase, entries: new Set<Entry>(), fresh: new Set<Entry>(), counter: 0, flushQueued: false });\n\n const scope = useMemo(() => {\n const s = state.current;\n const blocked = () => {\n const top = getTopModal();\n if (top) return top !== (layer?.current ?? null);\n // A product's own modal (not on the HJM stack) still covers the page.\n return layer === null && document.querySelector('[aria-modal=\"true\"], dialog[open]') !== null;\n };\n const dispatch = (event: EntryFocusEvent<Candidate> | { kind: \"register\"; entry: Entry }): HTMLElement | null => {\n const candidates: Candidate[] = [...s.entries].map(entry => ({ entry, order: entry.order, preference: entry.preference, focusable: entry.focusable() }));\n const resolved = event.kind === \"register\" && \"entry\" in event\n ? { kind: \"register\" as const, field: candidates.find(candidate => candidate.entry === event.entry)! }\n : event as EntryFocusEvent<Candidate>;\n const result = resolveEntryFocus(s.phase, resolved, { mode: modeRef.current, candidates, blocked: blocked(), textEntryFocused: isEditable(document.activeElement) });\n s.phase = result.phase;\n return result.target?.entry.element() ?? null;\n };\n const focus = (target: HTMLElement | null) => target?.focus({ preventScroll: true });\n // Fields mounting in one commit are judged together.\n const flush = () => {\n s.flushQueued = false;\n const fresh = [...s.fresh].filter(entry => s.entries.has(entry)).sort((a, b) => a.order - b.order);\n s.fresh.clear();\n const field = fresh.find(entry => entry.preference === true) ?? fresh[0];\n if (field) focus(dispatch({ kind: \"register\", entry: field }));\n };\n const registry: Registry = {\n nextOrder: () => s.counter++,\n register(entry, mounted) {\n s.entries.add(entry);\n if (mounted) { s.fresh.add(entry); if (!s.flushQueued) { s.flushQueued = true; queueMicrotask(flush); } }\n return () => { s.entries.delete(entry); s.fresh.delete(entry); };\n },\n };\n const enter = (explicit: boolean) => {\n s.fresh.clear();\n dispatch({ kind: \"activate\" });\n if (explicit) { s.phase = \"settled\"; return null; }\n return dispatch({ kind: \"enter\" });\n };\n return { registry, layer, dispatch, focus, enter };\n }, [layer]);\n\n useEffect(() => {\n if (!active) { scope.dispatch({ kind: \"deactivate\" }); return undefined; }\n // After every effect of this commit, so a modal opening in the same commit (an app-root consent dialog) is\n // already on the stack and blocks entry instead of taking focus away and handing it back later.\n let cancelled = false;\n if (!overlay) queueMicrotask(() => { if (!cancelled) scope.focus(scope.enter(false)); });\n const interact = () => { scope.dispatch({ kind: \"interact\" }); };\n const events = [\"pointerdown\", \"keydown\", \"wheel\", \"touchstart\"] as const;\n for (const type of events) document.addEventListener(type, interact, true);\n // A modal above closed (after its return focus ran): retry a pending entry.\n const unsubscribe = subscribeModalClose(() => scope.focus(scope.dispatch({ kind: \"unblock\" })));\n return () => {\n cancelled = true;\n for (const type of events) document.removeEventListener(type, interact, true);\n unsubscribe();\n scope.dispatch({ kind: \"deactivate\" });\n };\n }, [active, overlay, scope]);\n\n return useMemo(() => ({ registry: scope.registry, layer: scope.layer, enter: scope.enter }), [scope]);\n}\n\nexport function InitialFocusProvider({ scope, children }: { scope: InitialFocusScopeHandle; children: ReactNode }) {\n return <ModalLayerContext.Provider value={scope.layer}><InitialFocusContext.Provider value={scope.registry}>{children}</InitialFocusContext.Provider></ModalLayerContext.Provider>;\n}\n\n/** Screen scope: focuses the chosen field on mount, never over a field the user is in or under an open modal. */\nexport function InitialFocusScope({ mode, children }: { mode: InitialFocusMode; children: ReactNode }) {\n const scope = useInitialFocusScope({ mode });\n return <InitialFocusProvider scope={scope}>{children}</InitialFocusProvider>;\n}\n\n/** Registers a text field with the nearest scope. `preference` is the field's public `initialFocusTarget`. */\nexport function useInitialFocusTarget(element: RefObject<HTMLElement | null>, preference: boolean | undefined) {\n const registry = useContext(InitialFocusContext);\n // Tree order is fixed at first registration, so changing `preference` later does not move the field to the end.\n const order = useRef<number | null>(null);\n useLayoutEffect(() => {\n if (!registry) return undefined;\n // Only the first registration of this field instance counts as \"appeared\"; a later `preference` change does not.\n const mounted = order.current === null;\n order.current ??= registry.nextOrder();\n return registry.register({\n order: order.current, preference, element: () => element.current,\n // Disabled and read-only fields are never focused on entry.\n focusable: () => { const node = element.current as (HTMLInputElement | HTMLTextAreaElement | null); return !!node && !node.disabled && !node.readOnly; },\n }, mounted);\n }, [registry, preference, element]);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"initial-focus.js","sourceRoot":"","sources":["../../src/internal/initial-focus.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAiG,MAAM,yCAAyC,CAAC;AAC3K,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAkC,MAAM,OAAO,CAAC;AAC/H,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAoB,MAAM,aAAa,CAAC;AAOjF;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,aAAa,CAAkB,IAAI,CAAC,CAAC;AACjE,mHAAmH;AACnH,MAAM,iBAAiB,GAAG,aAAa,CAAuB,IAAI,CAAC,CAAC;AAGpE;;;;GAI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AC,CAAC;IACd,CAAC,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import { resolveEntryFocus, type EntryFocusEvent, type EntryFocusPhase, type InitialFocusCandidate, type InitialFocusMode } from \"@hjmds/design-contracts/screen-patterns\";\nimport { createContext, useContext, useEffect, useLayoutEffect, useMemo, useRef, type ReactNode, type RefObject } from \"react\";\nimport { getTopModal, subscribeModalClose, type ActiveModal } from \"../modal.js\";\n\ntype Entry = { order: number; preference: boolean | undefined; element(): HTMLElement | null; focusable(): boolean };\ntype Registry = { nextOrder(): number; register(entry: Entry, mounted: boolean): () => void };\n/** The overlay's own entry on the shared modal stack while it is active (set by `useModalFocus`). */\nexport type ModalLayerRef = { current: ActiveModal | null };\n\n/**\n * Nearest screen/overlay scope that chooses the field focused on entry (rules: screen-patterns `resolveEntryFocus`,\n * shared with Native). Fields register by context, the same model as Native, instead of the scope querying the DOM; a\n * scope with mode \"none\" still owns its fields so they never reach an outer scope.\n */\nconst InitialFocusContext = createContext<Registry | null>(null);\n/** Layer of the enclosing HJM overlay; null on the page itself. A ScreenLayout inside a sheet uses the sheet's. */\nconst ModalLayerContext = createContext<ModalLayerRef | null>(null);\n\ntype NestedScope = { enter(): HTMLElement | null; settle(): void };\n/**\n * Screen scopes rendered inside an HJM overlay, keyed by that overlay's layer. Their fields register with the screen,\n * not the overlay, so the overlay's activation asks them for the entry field instead of focusing its first control\n * over them (BurnTok search: a ScreenLayout in a Sheet left focus on the close button, 2026-10-18).\n */\nconst nestedScopes = new WeakMap<ModalLayerRef, Set<NestedScope>>();\n\n/**\n * Product modals (not on the HJM stack) layered above the scope. A product modal that contains the scope's own fields\n * wraps the screen rather than covering it, so it does not block (BurnTok search overlay, 2026-10-18).\n */\nfunction productModalAbove(fields: readonly HTMLElement[]): boolean {\n return [...document.querySelectorAll('[aria-modal=\"true\"], dialog[open]')]\n .some(modal => !fields.some(field => modal.contains(field)));\n}\n\nfunction isEditable(element: Element | null): boolean {\n return element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement || element instanceof HTMLSelectElement\n || (element instanceof HTMLElement && element.isContentEditable);\n}\n\ntype Candidate = InitialFocusCandidate & { entry: Entry };\nexport type InitialFocusScopeHandle = Readonly<{\n registry: Registry;\n layer: ModalLayerRef | null;\n /**\n * Overlays only: runs entry when the modal activates and returns the field for `useModalFocus` to focus. `explicit`\n * means the overlay already has an `initialFocusRef`, so entry settles without choosing a field.\n */\n enter(explicit: boolean): HTMLElement | null;\n}>;\n\n/**\n * Screen scopes enter on mount (Web has no enter transition to wait for); overlays pass `layer` and enter through\n * `useModalFocus`. User pointer, key, wheel or touch input while no modal is above the scope ends the entry window.\n */\nexport function useInitialFocusScope({ mode, active = true, layer: ownLayer }: { mode: InitialFocusMode; active?: boolean; layer?: ModalLayerRef }): InitialFocusScopeHandle {\n const inherited = useContext(ModalLayerContext);\n const layer = ownLayer ?? inherited;\n const overlay = ownLayer !== undefined;\n const modeRef = useRef(mode); modeRef.current = mode;\n const state = useRef({ phase: \"inactive\" as EntryFocusPhase, entries: new Set<Entry>(), fresh: new Set<Entry>(), counter: 0, flushQueued: false });\n\n const scope = useMemo(() => {\n const s = state.current;\n const blocked = () => {\n const own = layer?.current ?? null;\n // Inside an HJM overlay that is not on the stack yet: its activation runs this scope's entry (`nestedScopes`).\n if (layer !== null && own === null) return true;\n const top = getTopModal();\n if (top) return top !== own;\n // A product's own modal above the page still covers it; overlay content is portaled outside product markup.\n if (layer !== null) return false;\n const fields = [...s.entries].map(entry => entry.element()).filter((element): element is HTMLElement => element !== null);\n return productModalAbove(fields);\n };\n const dispatch = (event: EntryFocusEvent<Candidate> | { kind: \"register\"; entry: Entry }): HTMLElement | null => {\n const candidates: Candidate[] = [...s.entries].map(entry => ({ entry, order: entry.order, preference: entry.preference, focusable: entry.focusable() }));\n const resolved = event.kind === \"register\" && \"entry\" in event\n ? { kind: \"register\" as const, field: candidates.find(candidate => candidate.entry === event.entry)! }\n : event as EntryFocusEvent<Candidate>;\n const result = resolveEntryFocus(s.phase, resolved, { mode: modeRef.current, candidates, blocked: blocked(), textEntryFocused: isEditable(document.activeElement) });\n s.phase = result.phase;\n return result.target?.entry.element() ?? null;\n };\n const focus = (target: HTMLElement | null) => target?.focus({ preventScroll: true });\n // Fields mounting in one commit are judged together.\n const flush = () => {\n s.flushQueued = false;\n const fresh = [...s.fresh].filter(entry => s.entries.has(entry)).sort((a, b) => a.order - b.order);\n s.fresh.clear();\n const field = fresh.find(entry => entry.preference === true) ?? fresh[0];\n if (field) focus(dispatch({ kind: \"register\", entry: field }));\n };\n const registry: Registry = {\n nextOrder: () => s.counter++,\n register(entry, mounted) {\n s.entries.add(entry);\n if (mounted) { s.fresh.add(entry); if (!s.flushQueued) { s.flushQueued = true; queueMicrotask(flush); } }\n return () => { s.entries.delete(entry); s.fresh.delete(entry); };\n },\n };\n const settle = () => { s.phase = \"settled\"; };\n const enter = (explicit: boolean) => {\n s.fresh.clear();\n dispatch({ kind: \"activate\" });\n const nested = overlay && layer ? [...(nestedScopes.get(layer) ?? [])] : [];\n if (explicit) { settle(); for (const scope of nested) scope.settle(); return null; }\n const own = dispatch({ kind: \"enter\" });\n if (own) return own;\n for (const scope of nested) { const target = scope.enter(); if (target) return target; }\n return null;\n };\n return { registry, layer, dispatch, focus, enter, settle };\n }, [layer, overlay]);\n\n useEffect(() => {\n if (!active) { scope.dispatch({ kind: \"deactivate\" }); return undefined; }\n // After every effect of this commit, so a modal opening in the same commit (an app-root consent dialog) is\n // already on the stack and blocks entry instead of taking focus away and handing it back later.\n let cancelled = false;\n if (!overlay) queueMicrotask(() => { if (!cancelled) scope.focus(scope.enter(false)); });\n // A screen inside an overlay that activates later enters when the overlay does (see `enter`).\n let nested: Set<NestedScope> | undefined;\n const nestedEntry: NestedScope = { enter: () => scope.enter(false), settle: scope.settle };\n if (!overlay && scope.layer) {\n nested = nestedScopes.get(scope.layer) ?? new Set();\n nestedScopes.set(scope.layer, nested);\n nested.add(nestedEntry);\n }\n const interact = () => { scope.dispatch({ kind: \"interact\" }); };\n const events = [\"pointerdown\", \"keydown\", \"wheel\", \"touchstart\"] as const;\n for (const type of events) document.addEventListener(type, interact, true);\n // A modal above closed (after its return focus ran): retry a pending entry.\n const unsubscribe = subscribeModalClose(() => scope.focus(scope.dispatch({ kind: \"unblock\" })));\n return () => {\n cancelled = true;\n nested?.delete(nestedEntry);\n for (const type of events) document.removeEventListener(type, interact, true);\n unsubscribe();\n scope.dispatch({ kind: \"deactivate\" });\n };\n }, [active, overlay, scope]);\n\n return useMemo(() => ({ registry: scope.registry, layer: scope.layer, enter: scope.enter }), [scope]);\n}\n\nexport function InitialFocusProvider({ scope, children }: { scope: InitialFocusScopeHandle; children: ReactNode }) {\n return <ModalLayerContext.Provider value={scope.layer}><InitialFocusContext.Provider value={scope.registry}>{children}</InitialFocusContext.Provider></ModalLayerContext.Provider>;\n}\n\n/** Screen scope: focuses the chosen field on mount, never over a field the user is in or under an open modal. */\nexport function InitialFocusScope({ mode, children }: { mode: InitialFocusMode; children: ReactNode }) {\n const scope = useInitialFocusScope({ mode });\n return <InitialFocusProvider scope={scope}>{children}</InitialFocusProvider>;\n}\n\n/** Registers a text field with the nearest scope. `preference` is the field's public `initialFocusTarget`. */\nexport function useInitialFocusTarget(element: RefObject<HTMLElement | null>, preference: boolean | undefined) {\n const registry = useContext(InitialFocusContext);\n // Tree order is fixed at first registration, so changing `preference` later does not move the field to the end.\n const order = useRef<number | null>(null);\n useLayoutEffect(() => {\n if (!registry) return undefined;\n // Only the first registration of this field instance counts as \"appeared\"; a later `preference` change does not.\n const mounted = order.current === null;\n order.current ??= registry.nextOrder();\n return registry.register({\n order: order.current, preference, element: () => element.current,\n // Disabled and read-only fields are never focused on entry.\n focusable: () => { const node = element.current as (HTMLInputElement | HTMLTextAreaElement | null); return !!node && !node.disabled && !node.readOnly; },\n }, mounted);\n }, [registry, preference, element]);\n}\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
type MediaAlbumBase = Readonly<{
|
|
3
|
+
/** Number of photos in the set; at least one. */
|
|
4
|
+
count: number;
|
|
5
|
+
/**
|
|
6
|
+
* Draws one page. HJM calls it only for the page on screen, so the product can fetch, authorize and decode that
|
|
7
|
+
* photo alone instead of mounting every image in the set.
|
|
8
|
+
*/
|
|
9
|
+
renderPage(index: number): ReactNode;
|
|
10
|
+
/** Localized accessible name of a page, e.g. "Photo 2 of 5". */
|
|
11
|
+
pageLabel(index: number, count: number): string;
|
|
12
|
+
/** Localized accessible names of the previous/next icon buttons. */
|
|
13
|
+
previousLabel: string;
|
|
14
|
+
nextLabel: string;
|
|
15
|
+
/** Page frame width / height. Defaults to `mediaAlbumRecipe.defaultAspectRatio` (square). */
|
|
16
|
+
aspectRatio?: number;
|
|
17
|
+
/** Opens the shown page (viewer); without it the page is a static image. */
|
|
18
|
+
onPress?(index: number): void;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Paged photo set (2026-10-18). Products own image sources, authorization and the viewer; HJM owns the frame,
|
|
22
|
+
* the counter row and which page is mounted. Controlled with `index` + `onIndexChange`, or uncontrolled from
|
|
23
|
+
* `defaultIndex`.
|
|
24
|
+
*/
|
|
25
|
+
export type MediaAlbum = MediaAlbumBase & (Readonly<{
|
|
26
|
+
index: number;
|
|
27
|
+
onIndexChange(index: number): void;
|
|
28
|
+
defaultIndex?: never;
|
|
29
|
+
}> | Readonly<{
|
|
30
|
+
index?: never;
|
|
31
|
+
defaultIndex?: number;
|
|
32
|
+
onIndexChange?(index: number): void;
|
|
33
|
+
}>);
|
|
34
|
+
/**
|
|
35
|
+
* Hosts keep the page state so every copy of the album they render (the message and its hold-menu preview) shows
|
|
36
|
+
* the same page. Called unconditionally; `album` may be absent.
|
|
37
|
+
*/
|
|
38
|
+
export declare function useMediaAlbumIndex(album: MediaAlbum | undefined): readonly [number, (index: number) => void];
|
|
39
|
+
export declare function MediaAlbumView({ album, index, onIndexChange, width, radius, className }: Readonly<{
|
|
40
|
+
album: MediaAlbum;
|
|
41
|
+
index: number;
|
|
42
|
+
onIndexChange(index: number): void;
|
|
43
|
+
/** Host media width (chat `mediaWidth`, comment `mediaMaxWidth`); the album never grows past its container. */
|
|
44
|
+
width: number;
|
|
45
|
+
radius: number;
|
|
46
|
+
className?: string;
|
|
47
|
+
}>): import("react").JSX.Element;
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=media-album.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-album.d.ts","sourceRoot":"","sources":["../../src/internal/media-album.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAMrE,KAAK,cAAc,GAAG,QAAQ,CAAC;IAC7B,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,gEAAgE;IAChE,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAChD,oEAAoE;IACpE,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,6FAA6F;IAC7F,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,OAAO,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,CACtC,QAAQ,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,YAAY,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC,GACrF,QAAQ,CAAC;IAAE,KAAK,CAAC,EAAE,KAAK,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CAC1F,CAAC;AAEF;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,CAS5G;AAED,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,QAAQ,CAAC;IACjG,KAAK,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrE,+GAA+G;IAC/G,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CACnD,CAAC,+BAgBD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { mediaAlbumRecipe, resolveMediaAlbumIndex, validateMediaAlbum } from "@hjmds/design-contracts/screen-patterns";
|
|
4
|
+
import { IconButton } from "../actions.js";
|
|
5
|
+
import { Text } from "../layout.js";
|
|
6
|
+
import { Icon } from "../supplemental-display.js";
|
|
7
|
+
/**
|
|
8
|
+
* Hosts keep the page state so every copy of the album they render (the message and its hold-menu preview) shows
|
|
9
|
+
* the same page. Called unconditionally; `album` may be absent.
|
|
10
|
+
*/
|
|
11
|
+
export function useMediaAlbumIndex(album) {
|
|
12
|
+
const [own, setOwn] = useState(album?.defaultIndex ?? 0);
|
|
13
|
+
if (!album)
|
|
14
|
+
return [0, setOwn];
|
|
15
|
+
if (album.index !== undefined) {
|
|
16
|
+
validateMediaAlbum(album.count, album.index);
|
|
17
|
+
return [album.index, album.onIndexChange];
|
|
18
|
+
}
|
|
19
|
+
const current = resolveMediaAlbumIndex(album.count, own);
|
|
20
|
+
return [current, (next) => { setOwn(next); album.onIndexChange?.(next); }];
|
|
21
|
+
}
|
|
22
|
+
export function MediaAlbumView({ album, index, onIndexChange, width, radius, className }) {
|
|
23
|
+
validateMediaAlbum(album.count, index);
|
|
24
|
+
const label = album.pageLabel(index, album.count);
|
|
25
|
+
const frame = { aspectRatio: album.aspectRatio ?? mediaAlbumRecipe.defaultAspectRatio, borderRadius: radius };
|
|
26
|
+
const page = album.renderPage(index);
|
|
27
|
+
return _jsxs("div", { className: ["hjm-media-album", className].filter(Boolean).join(" "), style: { inlineSize: width, gap: mediaAlbumRecipe.controlGap }, children: [album.onPress
|
|
28
|
+
? _jsx("button", { type: "button", className: "hjm-media-album__page", "aria-label": label, style: frame, onClick: () => album.onPress?.(index), children: page })
|
|
29
|
+
: _jsx("div", { role: "img", "aria-label": label, className: "hjm-media-album__page", style: frame, children: page }), album.count > 1 ? _jsxs("div", { className: "hjm-media-album__controls", children: [_jsx(IconButton, { label: album.previousLabel, tone: "ghost", size: mediaAlbumRecipe.controlSize, edge: "start", disabled: index === 0, onClick: () => onIndexChange(index - 1), children: _jsx(Icon, { name: "chevronStart" }) }), _jsxs(Text, { variant: "caption", "aria-live": "polite", children: [index + 1, "/", album.count] }), _jsx(IconButton, { label: album.nextLabel, tone: "ghost", size: mediaAlbumRecipe.controlSize, edge: "end", disabled: index === album.count - 1, onClick: () => onIndexChange(index + 1), children: _jsx(Icon, { name: "chevronEnd" }) })] }) : null] });
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=media-album.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-album.js","sourceRoot":"","sources":["../../src/internal/media-album.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAsC,MAAM,OAAO,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,kB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,EAAE,IAAI,EAAC,OAAO,EAAC,IAAI,EAAE,gBAAgB,CAAC,WAAW,EAAE,IAAI,EAAC,KAAK,EAAC,QAAQ,EAAE,KAAK,KAAK,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,GAAG,CAAC,CAAC,YAAE,KAAC,IAAI,IAAC,IAAI,EAAC,YAAY,GAAG,GAAa,IACjN,CAAC,CAAC,CAAC,IAAI,IACT,CAAC;AACT,CAAC","sourcesContent":["import { useState, type CSSProperties, type ReactNode } from \"react\";\nimport { mediaAlbumRecipe, resolveMediaAlbumIndex, validateMediaAlbum } from \"@hjmds/design-contracts/screen-patterns\";\nimport { IconButton } from \"../actions.js\";\nimport { Text } from \"../layout.js\";\nimport { Icon } from \"../supplemental-display.js\";\n\ntype MediaAlbumBase = Readonly<{\n /** Number of photos in the set; at least one. */\n count: number;\n /**\n * Draws one page. HJM calls it only for the page on screen, so the product can fetch, authorize and decode that\n * photo alone instead of mounting every image in the set.\n */\n renderPage(index: number): ReactNode;\n /** Localized accessible name of a page, e.g. \"Photo 2 of 5\". */\n pageLabel(index: number, count: number): string;\n /** Localized accessible names of the previous/next icon buttons. */\n previousLabel: string;\n nextLabel: string;\n /** Page frame width / height. Defaults to `mediaAlbumRecipe.defaultAspectRatio` (square). */\n aspectRatio?: number;\n /** Opens the shown page (viewer); without it the page is a static image. */\n onPress?(index: number): void;\n}>;\n\n/**\n * Paged photo set (2026-10-18). Products own image sources, authorization and the viewer; HJM owns the frame,\n * the counter row and which page is mounted. Controlled with `index` + `onIndexChange`, or uncontrolled from\n * `defaultIndex`.\n */\nexport type MediaAlbum = MediaAlbumBase & (\n | Readonly<{ index: number; onIndexChange(index: number): void; defaultIndex?: never }>\n | Readonly<{ index?: never; defaultIndex?: number; onIndexChange?(index: number): void }>\n);\n\n/**\n * Hosts keep the page state so every copy of the album they render (the message and its hold-menu preview) shows\n * the same page. Called unconditionally; `album` may be absent.\n */\nexport function useMediaAlbumIndex(album: MediaAlbum | undefined): readonly [number, (index: number) => void] {\n const [own, setOwn] = useState(album?.defaultIndex ?? 0);\n if (!album) return [0, setOwn];\n if (album.index !== undefined) {\n validateMediaAlbum(album.count, album.index);\n return [album.index, album.onIndexChange];\n }\n const current = resolveMediaAlbumIndex(album.count, own);\n return [current, (next: number) => { setOwn(next); album.onIndexChange?.(next); }];\n}\n\nexport function MediaAlbumView({ album, index, onIndexChange, width, radius, className }: Readonly<{\n album: MediaAlbum; index: number; onIndexChange(index: number): void;\n /** Host media width (chat `mediaWidth`, comment `mediaMaxWidth`); the album never grows past its container. */\n width: number; radius: number; className?: string;\n}>) {\n validateMediaAlbum(album.count, index);\n const label = album.pageLabel(index, album.count);\n const frame = { aspectRatio: album.aspectRatio ?? mediaAlbumRecipe.defaultAspectRatio, borderRadius: radius } as CSSProperties;\n const page = album.renderPage(index);\n return <div className={[\"hjm-media-album\", className].filter(Boolean).join(\" \")} style={{ inlineSize: width, gap: mediaAlbumRecipe.controlGap }}>\n {album.onPress\n ? <button type=\"button\" className=\"hjm-media-album__page\" aria-label={label} style={frame} onClick={() => album.onPress?.(index)}>{page}</button>\n : <div role=\"img\" aria-label={label} className=\"hjm-media-album__page\" style={frame}>{page}</div>}\n {album.count > 1 ? <div className=\"hjm-media-album__controls\">\n {/* Same counter presentation as CarouselMotion navigation=\"counter\"; logical chevrons mirror in RTL. */}\n <IconButton label={album.previousLabel} tone=\"ghost\" size={mediaAlbumRecipe.controlSize} edge=\"start\" disabled={index === 0} onClick={() => onIndexChange(index - 1)}><Icon name=\"chevronStart\" /></IconButton>\n <Text variant=\"caption\" aria-live=\"polite\">{index + 1}/{album.count}</Text>\n <IconButton label={album.nextLabel} tone=\"ghost\" size={mediaAlbumRecipe.controlSize} edge=\"end\" disabled={index === album.count - 1} onClick={() => onIndexChange(index + 1)}><Icon name=\"chevronEnd\" /></IconButton>\n </div> : null}\n </div>;\n}\n"]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { type ReactNode } from "react";
|
|
1
|
+
import { type ReactNode, type Ref } from "react";
|
|
2
|
+
import { type ChatReactionSummaryItem } from "@hjmds/design-contracts/screen-patterns";
|
|
3
|
+
import type { MenuItemTone } from "@hjmds/design-contracts/recipes";
|
|
2
4
|
import { type ReactionPickerProps } from "../reaction-picker.js";
|
|
3
5
|
/** One row of the hold menu. Products supply copy and icons; HJM owns order, size and tone. */
|
|
4
6
|
export type MessageMenuAction = Readonly<{
|
|
@@ -8,6 +10,11 @@ export type MessageMenuAction = Readonly<{
|
|
|
8
10
|
onPress(): void;
|
|
9
11
|
disabled?: boolean; /** Shows › for rows that open a further list. */
|
|
10
12
|
submenu?: boolean;
|
|
13
|
+
/** Same vocabulary as Menu items: `danger` for destructive rows such as delete (default `neutral`). */ tone?: MenuItemTone;
|
|
14
|
+
}>;
|
|
15
|
+
/** Lets the owning message open the same hold menu from its reaction summary. */
|
|
16
|
+
export type MessageReactionsHandle = Readonly<{
|
|
17
|
+
open(): void;
|
|
11
18
|
}>;
|
|
12
19
|
type Props = ReactionPickerProps & Readonly<{
|
|
13
20
|
closeLabel: string;
|
|
@@ -35,8 +42,27 @@ type Props = ReactionPickerProps & Readonly<{
|
|
|
35
42
|
disabled?: boolean;
|
|
36
43
|
icon?: ReactNode;
|
|
37
44
|
}>;
|
|
45
|
+
menuRef?: Ref<MessageReactionsHandle>;
|
|
38
46
|
}>;
|
|
39
47
|
/** Chat-specific trigger translation; Popover retains collision, focus, Escape and outside dismissal. */
|
|
40
|
-
export declare function MessageReactions({ children, closeLabel, menuAction, interactiveContent, triggerClassName, replyAction, menuTitle, menuActions, reportAction, ...picker }: Props): import("react").JSX.Element;
|
|
48
|
+
export declare function MessageReactions({ children, closeLabel, menuAction, interactiveContent, triggerClassName, replyAction, menuTitle, menuActions, reportAction, menuRef, ...picker }: Props): import("react").JSX.Element;
|
|
49
|
+
/** ChatMessage strips its summary before spreading the rest into the hold menu. */
|
|
50
|
+
export declare function omitReactionSummary<T extends Readonly<{
|
|
51
|
+
summary?: unknown;
|
|
52
|
+
}>>({ summary: _summary, ...rest }: T): Omit<T, "summary">;
|
|
53
|
+
/**
|
|
54
|
+
* Current reactions as one button beside the time; pressing it opens the hold menu (the press target and its name
|
|
55
|
+
* are the whole pill, so per-emoji parts are hidden from assistive tech). The pill shows the brand border when the
|
|
56
|
+
* reader's own reaction is among the items.
|
|
57
|
+
*/
|
|
58
|
+
export declare function ReactionSummaryButton({ label, items, selected, disabled, onPress }: Readonly<{
|
|
59
|
+
label: string;
|
|
60
|
+
items: readonly (ChatReactionSummaryItem & Readonly<{
|
|
61
|
+
showCount: boolean;
|
|
62
|
+
}>)[];
|
|
63
|
+
selected: string | null;
|
|
64
|
+
disabled: boolean;
|
|
65
|
+
onPress(): void;
|
|
66
|
+
}>): import("react").JSX.Element;
|
|
41
67
|
export {};
|
|
42
68
|
//# sourceMappingURL=message-reactions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-reactions.d.ts","sourceRoot":"","sources":["../../src/internal/message-reactions.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"message-reactions.d.ts","sourceRoot":"","sources":["../../src/internal/message-reactions.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoD,KAAK,SAAS,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AACnG,OAAO,EAA0C,KAAK,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAC/H,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAGpE,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjF,+FAA+F;AAC/F,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,CAAC;IAAC,OAAO,IAAI,IAAI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BAAgB,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAwB,EAAE,gBAA6C,EAAE,WAAW,EAAE,SAAS,EAAE,WAAgB,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,EAAE,KAAK,+BAwChO;AAED,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,QAAQ,CAAC;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,CAEpI;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,QAAQ,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,CAAC,uBAAuB,GAAG,QAAQ,CAAC;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,OAAO,IAAI,IAAI,CAAA;CAAE,CAAC,+BAO5P"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef, useState } from "react";
|
|
3
|
-
import { screenPatternRecipe } from "@hjmds/design-contracts/screen-patterns";
|
|
2
|
+
import { useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
3
|
+
import { chatMessageRecipe, screenPatternRecipe } from "@hjmds/design-contracts/screen-patterns";
|
|
4
4
|
import { Text } from "../layout.js";
|
|
5
5
|
import { Popover } from "../popover.js";
|
|
6
6
|
import { ReactionPicker } from "../reaction-picker.js";
|
|
7
7
|
/** Chat-specific trigger translation; Popover retains collision, focus, Escape and outside dismissal. */
|
|
8
|
-
export function MessageReactions({ children, closeLabel, menuAction, interactiveContent = false, triggerClassName = "hjm-chat-message__bubble", replyAction, menuTitle, menuActions = [], reportAction, ...picker }) {
|
|
8
|
+
export function MessageReactions({ children, closeLabel, menuAction, interactiveContent = false, triggerClassName = "hjm-chat-message__bubble", replyAction, menuTitle, menuActions = [], reportAction, menuRef, ...picker }) {
|
|
9
9
|
// Reply leads and report trails; legacy single menuAction keeps its place before report.
|
|
10
10
|
const rows = [
|
|
11
11
|
...(replyAction ? [{ id: "reply", ...replyAction }] : []),
|
|
12
12
|
...menuActions,
|
|
13
13
|
...(menuAction ? [{ id: "menu", ...menuAction }] : []),
|
|
14
|
-
...(reportAction ? [{ id: "report", ...reportAction,
|
|
14
|
+
...(reportAction ? [{ id: "report", ...reportAction, tone: "danger" }] : []),
|
|
15
15
|
];
|
|
16
16
|
const [open, setOpen] = useState(false);
|
|
17
17
|
const press = useRef(null);
|
|
@@ -24,6 +24,8 @@ export function MessageReactions({ children, closeLabel, menuAction, interactive
|
|
|
24
24
|
cancel();
|
|
25
25
|
setOpen(false);
|
|
26
26
|
} }, [picker.disabled]);
|
|
27
|
+
useImperativeHandle(menuRef, () => ({ open: () => { if (!picker.disabled)
|
|
28
|
+
setOpen(true); } }), [picker.disabled]);
|
|
27
29
|
return _jsxs(Popover, { open: open && !picker.disabled, onOpenChange: (next) => { if (!next)
|
|
28
30
|
setOpen(false); }, title: picker.label, closeLabel: closeLabel, descriptor: { placement: "top", align: "start" }, className: "hjm-message-reactions", trigger: _jsx("div", { className: triggerClassName, tabIndex: picker.disabled ? -1 : 0, role: interactiveContent ? "group" : "button", "aria-label": picker.label, "aria-disabled": picker.disabled, onContextMenu: event => { event.preventDefault(); cancel(); if (!picker.disabled)
|
|
29
31
|
setOpen(true); },
|
|
@@ -44,6 +46,20 @@ export function MessageReactions({ children, closeLabel, menuAction, interactive
|
|
|
44
46
|
event.preventDefault();
|
|
45
47
|
event.stopPropagation();
|
|
46
48
|
held.current = false;
|
|
47
|
-
} }, children: children }), children: [picker.options.length ? _jsx(ReactionPicker, { ...picker, layout: "strip", onValueChange: value => { picker.onValueChange(value); setOpen(false); } }) : null, menuTitle || rows.length ? _jsxs("div", { className: "hjm-message-menu", children: [menuTitle ? _jsx(Text, { variant: "caption", tone: "muted", className: "hjm-message-menu__title", children: menuTitle }) : null, rows.map(row => _jsxs("button", { type: "button", className: "hjm-message-menu__item", "data-tone": row.danger ? "danger" : undefined, disabled: row.disabled, onClick: () => { setOpen(false); row.onPress(); }, children: [row.icon ? _jsx("span", { className: "hjm-message-menu__icon", "aria-hidden": "true", children: row.icon }) : null, _jsx("span", { className: "hjm-message-menu__label", children: row.label }), row.submenu ? _jsx("span", { className: "hjm-message-menu__chevron", "aria-hidden": "true", children: "\u203A" }) : null] }, row.id))] }) : null] });
|
|
49
|
+
} }, children: children }), children: [picker.options.length ? _jsx(ReactionPicker, { ...picker, layout: "strip", onValueChange: value => { picker.onValueChange(value); setOpen(false); } }) : null, menuTitle || rows.length ? _jsxs("div", { className: "hjm-message-menu", children: [menuTitle ? _jsx(Text, { variant: "caption", tone: "muted", className: "hjm-message-menu__title", children: menuTitle }) : null, rows.map(row => _jsxs("button", { type: "button", className: "hjm-message-menu__item", "data-tone": row.tone === "danger" ? "danger" : undefined, disabled: row.disabled, onClick: () => { setOpen(false); row.onPress(); }, children: [row.icon ? _jsx("span", { className: "hjm-message-menu__icon", "aria-hidden": "true", children: row.icon }) : null, _jsx("span", { className: "hjm-message-menu__label", children: row.label }), row.submenu ? _jsx("span", { className: "hjm-message-menu__chevron", "aria-hidden": "true", children: "\u203A" }) : null] }, row.id))] }) : null] });
|
|
50
|
+
}
|
|
51
|
+
/** ChatMessage strips its summary before spreading the rest into the hold menu. */
|
|
52
|
+
export function omitReactionSummary({ summary: _summary, ...rest }) {
|
|
53
|
+
return rest;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Current reactions as one button beside the time; pressing it opens the hold menu (the press target and its name
|
|
57
|
+
* are the whole pill, so per-emoji parts are hidden from assistive tech). The pill shows the brand border when the
|
|
58
|
+
* reader's own reaction is among the items.
|
|
59
|
+
*/
|
|
60
|
+
export function ReactionSummaryButton({ label, items, selected, disabled, onPress }) {
|
|
61
|
+
const r = chatMessageRecipe.reactionSummary;
|
|
62
|
+
const mine = items.some(item => item.id === selected);
|
|
63
|
+
return _jsx("button", { type: "button", className: "hjm-chat-message__reaction-summary", "aria-label": label, disabled: disabled, "data-selected": mine || undefined, onClick: onPress, style: { minBlockSize: r.minHeight, paddingInline: r.paddingInline, gap: r.itemGap }, children: items.map(item => _jsxs("span", { "aria-hidden": "true", style: { display: "inline-flex", alignItems: "center", gap: r.emojiGap }, children: [_jsx("span", { children: item.emoji }), item.showCount ? _jsx(Text, { as: "span", variant: "caption", children: item.count }) : null] }, item.id)) });
|
|
48
64
|
}
|
|
49
65
|
//# sourceMappingURL=message-reactions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-reactions.js","sourceRoot":"","sources":["../../src/internal/message-reactions.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,cAAc,EAA4B,MAAM,uBAAuB,CAAC;AAWjF,yGAAyG;AACzG,MAAM,UAAU,gBAAgB,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,GAAC,KAAK,EAAE,gBAAgB,GAAG,0BAA0B,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,GAAG,EAAE,EAAE,YAAY,EAAE,GAAG,MAAM,EAAS;IACtN,yFAAyF;IACzF,MAAM,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-patterns\";\nimport { Text } from \"../layout.js\";\nimport { Popover } from \"../popover.js\";\nimport { ReactionPicker, type ReactionPickerProps } from \"../reaction-picker.js\";\n\n/** One row of the hold menu. Products supply copy and icons; HJM owns order, size and tone. */\nexport type MessageMenuAction = Readonly<{ id: string; label: string; icon?: ReactNode; onPress(): void; disabled?: boolean; /** Shows › for rows that open a further list. */ submenu?: boolean }>;\ntype Props = ReactionPickerProps & Readonly<{ closeLabel: string; menuAction?: Readonly<{label:string;onPress():void;disabled?:boolean}>; children: ReactNode; interactiveContent?:boolean; /** Comments reuse the hold menu without chat bubble styling. */ triggerClassName?: string;\n replyAction?: Readonly<{label:string;onPress():void;disabled?:boolean;icon?:ReactNode}>;\n /** Shown above the actions, e.g. the exact send time that a run only shows once. */\n menuTitle?: string;\n menuActions?: readonly MessageMenuAction[];\n /** Always last and in the danger tone, matching the measured reference menu (2026-10-16). */\n reportAction?: Readonly<{label:string;onPress():void;disabled?:boolean;icon?:ReactNode}> }>;\n/** Chat-specific trigger translation; Popover retains collision, focus, Escape and outside dismissal. */\nexport function MessageReactions({ children, closeLabel, menuAction, interactiveContent=false, triggerClassName = \"hjm-chat-message__bubble\", replyAction, menuTitle, menuActions = [], reportAction, ...picker }: Props) {\n // Reply leads and report trails; legacy single menuAction keeps its place before report.\n const rows: (MessageMenuAction & { danger?: boolean })[] = [\n ...(replyAction ? [{ id: \"reply\", ...replyAction }] : []),\n ...menuActions,\n ...(menuAction ? [{ id: \"menu\", ...menuAction }] : []),\n ...(reportAction ? [{ id: \"report\", ...reportAction, danger: true }] : []),\n ];\n const [open, setOpen] = useState(false);\n const press = useRef<{ timer: ReturnType<typeof setTimeout>; x: number; y: number } | null>(null);\n const held = useRef(false);\n const cancel = () => { if (press.current) clearTimeout(press.current.timer); press.current = null; };\n useEffect(() => () => { if (press.current) clearTimeout(press.current.timer); }, []);\n useEffect(() => { if (picker.disabled) { cancel(); setOpen(false); } }, [picker.disabled]);\n return <Popover open={open && !picker.disabled} onOpenChange={(next) => { if (!next) setOpen(false); }} title={picker.label} closeLabel={closeLabel}\n descriptor={{ placement: \"top\", align: \"start\" }} className=\"hjm-message-reactions\" trigger={<div\n className={triggerClassName} tabIndex={picker.disabled ? -1 : 0} role={interactiveContent?\"group\":\"button\"} aria-label={picker.label} aria-disabled={picker.disabled}\n onContextMenu={event => { event.preventDefault(); cancel(); if (!picker.disabled) setOpen(true); }}\n // Only the bubble itself opens reactions: with interactiveContent, Enter/Space on a nested\n // link or button must keep its native activation instead of being swallowed here.\n onKeyDown={event => { if (event.target === event.currentTarget && (event.key === \"Enter\" || event.key === \" \") && !picker.disabled) { event.preventDefault(); setOpen(true); } }}\n onPointerDown={event => {\n if (picker.disabled || event.button !== 0 || (event.target as HTMLElement).closest(\"button,a,input,textarea\")) return;\n cancel(); held.current = false;\n const { clientX: x, clientY: y } = event;\n press.current = { x, y, timer: setTimeout(() => { held.current = true; press.current = null; setOpen(true); }, screenPatternRecipe.reactionHoldMs) };\n }}\n onPointerMove={event => { const start = press.current; if (start && Math.hypot(event.clientX - start.x, event.clientY - start.y) > screenPatternRecipe.reactionMoveTolerance) cancel(); }}\n onPointerCancel={cancel} onPointerLeave={cancel} onPointerUp={cancel}\n onClickCapture={event => { if (held.current) { event.preventDefault(); event.stopPropagation(); held.current = false; } }}\n >{children}</div>}>\n {/* Action-only menus (comments, 2026-10-16 reference) pass no options and show no strip. */}\n {picker.options.length ? <ReactionPicker {...picker} layout=\"strip\" onValueChange={value => { picker.onValueChange(value); setOpen(false); }} /> : null}\n {menuTitle || rows.length ? <div className=\"hjm-message-menu\">\n {menuTitle ? <Text variant=\"caption\" tone=\"muted\" className=\"hjm-message-menu__title\">{menuTitle}</Text> : null}\n {rows.map(row => <button key={row.id} type=\"button\" className=\"hjm-message-menu__item\" data-tone={row.danger ? \"danger\" : undefined} disabled={row.disabled} onClick={() => { setOpen(false); row.onPress(); }}>\n {row.icon ? <span className=\"hjm-message-menu__icon\" aria-hidden=\"true\">{row.icon}</span> : null}<span className=\"hjm-message-menu__label\">{row.label}</span>{row.submenu ? <span className=\"hjm-message-menu__chevron\" aria-hidden=\"true\">›</span> : null}</button>)}\n </div> : null}\n </Popover>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"message-reactions.js","sourceRoot":"","sources":["../../src/internal/message-reactions.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAA4B,MAAM,OAAO,CAAC;AACnG,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAgC,MAAM,yCAAyC,CAAC;AAE/H,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,cAAc,EAA4B,MAAM,uBAAuB,CAAC;AAejF,yGAAyG;AACzG,MAAM,UAAU,gBAAgB,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,GAAC,KAAK,EAAE,gBAAgB,GAAG,0BAA0B,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,GAAG,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,MAAM,EAAS;IAC/N,yFAAyF;IACzF,MAAM,IAAI,GAAwB;QAChC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,GAAG,WAAW;QACd,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,YAAY,EAAE,IAAI,EAAE,QAAiB,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAA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,eAAe,CAAC;IAC5C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC;IACtD,OAAO,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,oCAAoC,gBAAa,KAAK,EAAE,QAAQ,EAAE,QAAQ,mBAAiB,IAAI,IAAI,SAAS,EAAE,OAAO,EAAE,OAAO,EACnK,KAAK,EAAE,EAAE,YAAY,EAAE,CAAC,CAAC,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,YACnF,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,+BAAgC,MAAM,EAAC,KAAK,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,aAAE,yBAAO,IAAI,CAAC,KAAK,GAAQ,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,EAAE,EAAC,MAAM,EAAC,OAAO,EAAC,SAAS,YAAE,IAAI,CAAC,KAAK,GAAQ,CAAC,CAAC,CAAC,IAAI,KAA7M,IAAI,CAAC,EAAE,CAA8M,CAAC,GAC7O,CAAC;AACZ,CAAC","sourcesContent":["import { useEffect, useImperativeHandle, useRef, useState, type ReactNode, type Ref } from \"react\";\nimport { chatMessageRecipe, screenPatternRecipe, type ChatReactionSummaryItem } from \"@hjmds/design-contracts/screen-patterns\";\nimport type { MenuItemTone } from \"@hjmds/design-contracts/recipes\";\nimport { Text } from \"../layout.js\";\nimport { Popover } from \"../popover.js\";\nimport { ReactionPicker, type ReactionPickerProps } from \"../reaction-picker.js\";\n\n/** One row of the hold menu. Products supply copy and icons; HJM owns order, size and tone. */\nexport type MessageMenuAction = Readonly<{ id: string; label: string; icon?: ReactNode; onPress(): void; disabled?: boolean; /** Shows › for rows that open a further list. */ submenu?: boolean;\n /** Same vocabulary as Menu items: `danger` for destructive rows such as delete (default `neutral`). */ tone?: MenuItemTone }>;\n/** Lets the owning message open the same hold menu from its reaction summary. */\nexport type MessageReactionsHandle = Readonly<{ open(): void }>;\ntype Props = ReactionPickerProps & Readonly<{ closeLabel: string; menuAction?: Readonly<{label:string;onPress():void;disabled?:boolean}>; children: ReactNode; interactiveContent?:boolean; /** Comments reuse the hold menu without chat bubble styling. */ triggerClassName?: string;\n replyAction?: Readonly<{label:string;onPress():void;disabled?:boolean;icon?:ReactNode}>;\n /** Shown above the actions, e.g. the exact send time that a run only shows once. */\n menuTitle?: string;\n menuActions?: readonly MessageMenuAction[];\n /** Always last and in the danger tone, matching the measured reference menu (2026-10-16). */\n reportAction?: Readonly<{label:string;onPress():void;disabled?:boolean;icon?:ReactNode}>;\n menuRef?: Ref<MessageReactionsHandle> }>;\n/** Chat-specific trigger translation; Popover retains collision, focus, Escape and outside dismissal. */\nexport function MessageReactions({ children, closeLabel, menuAction, interactiveContent=false, triggerClassName = \"hjm-chat-message__bubble\", replyAction, menuTitle, menuActions = [], reportAction, menuRef, ...picker }: Props) {\n // Reply leads and report trails; legacy single menuAction keeps its place before report.\n const rows: MessageMenuAction[] = [\n ...(replyAction ? [{ id: \"reply\", ...replyAction }] : []),\n ...menuActions,\n ...(menuAction ? [{ id: \"menu\", ...menuAction }] : []),\n ...(reportAction ? [{ id: \"report\", ...reportAction, tone: \"danger\" as const }] : []),\n ];\n const [open, setOpen] = useState(false);\n const press = useRef<{ timer: ReturnType<typeof setTimeout>; x: number; y: number } | null>(null);\n const held = useRef(false);\n const cancel = () => { if (press.current) clearTimeout(press.current.timer); press.current = null; };\n useEffect(() => () => { if (press.current) clearTimeout(press.current.timer); }, []);\n useEffect(() => { if (picker.disabled) { cancel(); setOpen(false); } }, [picker.disabled]);\n useImperativeHandle(menuRef, () => ({ open: () => { if (!picker.disabled) setOpen(true); } }), [picker.disabled]);\n return <Popover open={open && !picker.disabled} onOpenChange={(next) => { if (!next) setOpen(false); }} title={picker.label} closeLabel={closeLabel}\n descriptor={{ placement: \"top\", align: \"start\" }} className=\"hjm-message-reactions\" trigger={<div\n className={triggerClassName} tabIndex={picker.disabled ? -1 : 0} role={interactiveContent?\"group\":\"button\"} aria-label={picker.label} aria-disabled={picker.disabled}\n onContextMenu={event => { event.preventDefault(); cancel(); if (!picker.disabled) setOpen(true); }}\n // Only the bubble itself opens reactions: with interactiveContent, Enter/Space on a nested\n // link or button must keep its native activation instead of being swallowed here.\n onKeyDown={event => { if (event.target === event.currentTarget && (event.key === \"Enter\" || event.key === \" \") && !picker.disabled) { event.preventDefault(); setOpen(true); } }}\n onPointerDown={event => {\n if (picker.disabled || event.button !== 0 || (event.target as HTMLElement).closest(\"button,a,input,textarea\")) return;\n cancel(); held.current = false;\n const { clientX: x, clientY: y } = event;\n press.current = { x, y, timer: setTimeout(() => { held.current = true; press.current = null; setOpen(true); }, screenPatternRecipe.reactionHoldMs) };\n }}\n onPointerMove={event => { const start = press.current; if (start && Math.hypot(event.clientX - start.x, event.clientY - start.y) > screenPatternRecipe.reactionMoveTolerance) cancel(); }}\n onPointerCancel={cancel} onPointerLeave={cancel} onPointerUp={cancel}\n onClickCapture={event => { if (held.current) { event.preventDefault(); event.stopPropagation(); held.current = false; } }}\n >{children}</div>}>\n {/* Action-only menus (comments, 2026-10-16 reference) pass no options and show no strip. */}\n {picker.options.length ? <ReactionPicker {...picker} layout=\"strip\" onValueChange={value => { picker.onValueChange(value); setOpen(false); }} /> : null}\n {menuTitle || rows.length ? <div className=\"hjm-message-menu\">\n {menuTitle ? <Text variant=\"caption\" tone=\"muted\" className=\"hjm-message-menu__title\">{menuTitle}</Text> : null}\n {rows.map(row => <button key={row.id} type=\"button\" className=\"hjm-message-menu__item\" data-tone={row.tone === \"danger\" ? \"danger\" : undefined} disabled={row.disabled} onClick={() => { setOpen(false); row.onPress(); }}>\n {row.icon ? <span className=\"hjm-message-menu__icon\" aria-hidden=\"true\">{row.icon}</span> : null}<span className=\"hjm-message-menu__label\">{row.label}</span>{row.submenu ? <span className=\"hjm-message-menu__chevron\" aria-hidden=\"true\">›</span> : null}</button>)}\n </div> : null}\n </Popover>;\n}\n\n/** ChatMessage strips its summary before spreading the rest into the hold menu. */\nexport function omitReactionSummary<T extends Readonly<{ summary?: unknown }>>({ summary: _summary, ...rest }: T): Omit<T, \"summary\"> {\n return rest;\n}\n\n/**\n * Current reactions as one button beside the time; pressing it opens the hold menu (the press target and its name\n * are the whole pill, so per-emoji parts are hidden from assistive tech). The pill shows the brand border when the\n * reader's own reaction is among the items.\n */\nexport function ReactionSummaryButton({ label, items, selected, disabled, onPress }: Readonly<{ label: string; items: readonly (ChatReactionSummaryItem & Readonly<{ showCount: boolean }>)[]; selected: string | null; disabled: boolean; onPress(): void }>) {\n const r = chatMessageRecipe.reactionSummary;\n const mine = items.some(item => item.id === selected);\n return <button type=\"button\" className=\"hjm-chat-message__reaction-summary\" aria-label={label} disabled={disabled} data-selected={mine || undefined} onClick={onPress}\n style={{ minBlockSize: r.minHeight, paddingInline: r.paddingInline, gap: r.itemGap }}>\n {items.map(item => <span key={item.id} aria-hidden=\"true\" style={{ display: \"inline-flex\", alignItems: \"center\", gap: r.emojiGap }}><span>{item.emoji}</span>{item.showCount ? <Text as=\"span\" variant=\"caption\">{item.count}</Text> : null}</span>)}\n </button>;\n}\n"]}
|
package/dist/layout.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { type ContainerGutter, type ContainerSize } from "@hjmds/design-contract
|
|
|
4
4
|
import { type LayoutSidebarRole } from "@hjmds/design-contracts/components/layout";
|
|
5
5
|
import { type SurfacePadding, type SurfaceRadius, type SurfaceTone } from "@hjmds/design-contracts/recipes/base";
|
|
6
6
|
import { type StackAlign, type StackAxis, type StackGap, type StackJustify, type TextEmphasis, type TextTone } from "@hjmds/design-contracts/recipes";
|
|
7
|
-
import { type FontRole, type TextVariant } from "@hjmds/design-contracts/foundations";
|
|
7
|
+
import { type FontRole, type NumericVariant, type TextVariant } from "@hjmds/design-contracts/foundations";
|
|
8
8
|
import { type AnchorHTMLAttributes, type HTMLAttributes, type ReactElement, type ReactNode, type Ref } from "react";
|
|
9
9
|
import type { HjmCompositionStyleProp } from "./composition-style.js";
|
|
10
10
|
export type { SurfacePadding, SurfaceRadius, SurfaceTone, } from "@hjmds/design-contracts/recipes/base";
|
|
@@ -62,24 +62,40 @@ export declare const Layout: import("react").ForwardRefExoticComponent<Omit<HTML
|
|
|
62
62
|
/** Canonical layout-only placement on the root element. Controlled visual keys are excluded. */
|
|
63
63
|
layoutStyle?: HjmCompositionStyleProp;
|
|
64
64
|
}> & import("react").RefAttributes<HTMLDivElement>>;
|
|
65
|
-
export type TextProps = Omit<HTMLAttributes<HTMLElement>, "children"> & Readonly<{
|
|
65
|
+
export type TextProps = Omit<HTMLAttributes<HTMLElement>, "children" | "color"> & Readonly<{
|
|
66
66
|
children: ReactNode;
|
|
67
67
|
as?: "span" | "p" | "div" | "strong" | "small";
|
|
68
68
|
variant?: TextVariant;
|
|
69
69
|
/** Overrides the variant family role; never changes its semantic element or metrics. */
|
|
70
70
|
fontRole?: FontRole;
|
|
71
71
|
tone?: TextTone;
|
|
72
|
+
/**
|
|
73
|
+
* Product-owned color role (team, sentiment, chart series) replacing the `tone` color while the HJM variant
|
|
74
|
+
* metrics and font face stay. Mirrors Native, where dropping to a raw text host lost the face (2026-10-18).
|
|
75
|
+
* Replaces the legacy HTML `color` attribute type, which no browser applies to text. Contrast is the product's.
|
|
76
|
+
*/
|
|
77
|
+
color?: string;
|
|
78
|
+
/** Digit spacing; `tabular` keeps changing numbers (scores, timers, counts) from shifting the layout. */
|
|
79
|
+
numeric?: NumericVariant;
|
|
72
80
|
emphasis?: TextEmphasis;
|
|
73
81
|
/** Canonical layout-only placement. Controlled visual keys are excluded. */
|
|
74
82
|
layoutStyle?: HjmCompositionStyleProp;
|
|
75
83
|
}>;
|
|
76
|
-
export declare const Text: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLElement>, "children"> & Readonly<{
|
|
84
|
+
export declare const Text: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLElement>, "color" | "children"> & Readonly<{
|
|
77
85
|
children: ReactNode;
|
|
78
86
|
as?: "span" | "p" | "div" | "strong" | "small";
|
|
79
87
|
variant?: TextVariant;
|
|
80
88
|
/** Overrides the variant family role; never changes its semantic element or metrics. */
|
|
81
89
|
fontRole?: FontRole;
|
|
82
90
|
tone?: TextTone;
|
|
91
|
+
/**
|
|
92
|
+
* Product-owned color role (team, sentiment, chart series) replacing the `tone` color while the HJM variant
|
|
93
|
+
* metrics and font face stay. Mirrors Native, where dropping to a raw text host lost the face (2026-10-18).
|
|
94
|
+
* Replaces the legacy HTML `color` attribute type, which no browser applies to text. Contrast is the product's.
|
|
95
|
+
*/
|
|
96
|
+
color?: string;
|
|
97
|
+
/** Digit spacing; `tabular` keeps changing numbers (scores, timers, counts) from shifting the layout. */
|
|
98
|
+
numeric?: NumericVariant;
|
|
83
99
|
emphasis?: TextEmphasis;
|
|
84
100
|
/** Canonical layout-only placement. Controlled visual keys are excluded. */
|
|
85
101
|
layoutStyle?: HjmCompositionStyleProp;
|
package/dist/layout.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.tsx"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,OAAO,EACb,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,sCAAsC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E,MAAM,CAAC;IACtB,4EAA4E;IAC9E,WAAW,CAAC,EAAE,uBAAuB,CAAC;CACzC,CAAC,CAAC;AAEH,eAAO,MAAM,IAAI;;;;;eATF,SAAS;IACpB,gFAAgF;kBAClE,MAAM;IACpB,2EAA2E;qBAC1D,MAAM;IACrB,4EAA4E;kBAChE,uBAAuB;mDAyDvC,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,GAChF,QAAQ,CAAC;IACP,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,gGAAgG;IAChG,WAAW,CAAC,EAAE,uBAAuB,CAAC;CACvC,CAAC,CAAC;AAEL,+EAA+E;AAC/E,eAAO,MAAM,OAAO;YAVR,SAAS;kBACH,SAAS;aACd,SAAS;cACR,SAAS;mBACJ,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;IAChC,gGAAgG;kBAClF,uBAAuB;gDAuCvC,CAAC;AAEH,YAAY,EAAE,OAAO,EAAE,CAAC;AACxB,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/layout.js
CHANGED
|
@@ -9,7 +9,7 @@ import { resolveContainerDescriptor, } from "@hjmds/design-contracts/components/
|
|
|
9
9
|
import { layoutRecipe, validateLayoutWebDescriptor, } from "@hjmds/design-contracts/components/layout";
|
|
10
10
|
import { surfaceDefaults, surfaceGeometry, surfaceRecipe, } from "@hjmds/design-contracts/recipes/base";
|
|
11
11
|
import { resolveTextDefaultWeight, stackRecipe, textRecipe, } from "@hjmds/design-contracts/recipes";
|
|
12
|
-
import { resolveTextFontRole, typography } from "@hjmds/design-contracts/foundations";
|
|
12
|
+
import { numeric as numericVariants, resolveTextFontRole, typography } from "@hjmds/design-contracts/foundations";
|
|
13
13
|
import { createElement, forwardRef, useId, useRef, } from "react";
|
|
14
14
|
import { classNames, composeRefs, useElementWidth, useWindowWidth, } from "./internal.js";
|
|
15
15
|
function hasRegionContent(content) {
|
|
@@ -94,7 +94,7 @@ export const Layout = forwardRef(function Layout({ children, header, footer, sid
|
|
|
94
94
|
...mainStyle,
|
|
95
95
|
}, children: children }), hasFooter ? (_jsx("footer", { ...restFooterProps, className: classNames("hjm-layout__footer", footerClassName), children: footer })) : null] }));
|
|
96
96
|
});
|
|
97
|
-
export const Text = forwardRef(function Text({ as = "span", variant = textRecipe.defaults.variant, fontRole, tone = textRecipe.defaults.tone, emphasis: suppliedEmphasis, className, layoutStyle, style, ...props }, ref) {
|
|
97
|
+
export const Text = forwardRef(function Text({ as = "span", variant = textRecipe.defaults.variant, fontRole, tone = textRecipe.defaults.tone, color, numeric, emphasis: suppliedEmphasis, className, layoutStyle, style, ...props }, ref) {
|
|
98
98
|
const profile = useDesignProfileDefaults();
|
|
99
99
|
const emphasis = suppliedEmphasis ?? textRecipe.defaults.emphasis;
|
|
100
100
|
const defaultWeight = suppliedEmphasis === undefined
|
|
@@ -110,7 +110,14 @@ export const Text = forwardRef(function Text({ as = "span", variant = textRecipe
|
|
|
110
110
|
"data-emphasis": emphasis,
|
|
111
111
|
// The variant default weight goes first so caller `style`/placement win, matching Native's style order
|
|
112
112
|
// (it used to be spread last and overrode an explicit style weight under a profile).
|
|
113
|
-
|
|
113
|
+
"data-numeric": numeric,
|
|
114
|
+
style: {
|
|
115
|
+
...(defaultWeight === undefined ? {} : { fontWeight: defaultWeight }),
|
|
116
|
+
...(color === undefined ? {} : { color }),
|
|
117
|
+
...(numeric === undefined ? {} : { fontVariantNumeric: numericVariants[numeric] }),
|
|
118
|
+
...style,
|
|
119
|
+
...layoutStyle,
|
|
120
|
+
},
|
|
114
121
|
});
|
|
115
122
|
});
|
|
116
123
|
export const Surface = forwardRef(function Surface({ as = "div", tone = surfaceDefaults.tone, bordered, padding = surfaceDefaults.padding, radius = surfaceDefaults.radius, className, layoutStyle, style, ...props }, ref) {
|