@g9tm/lynxcontrols 2.5.17 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/catalog/cards/G9Tooltip.md +17 -0
- package/catalog/catalog.json +306 -1
- package/catalog/index.md +2 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/popover/index.d.ts +1 -0
- package/dist/popover/index.d.ts.map +1 -1
- package/dist/popover/index.jsx +1 -0
- package/dist/popover/tooltip.d.ts +48 -0
- package/dist/popover/tooltip.d.ts.map +1 -0
- package/dist/popover/tooltip.jsx +77 -0
- package/package.json +2 -2
- package/skills/g9-lynx-app/references/catalog-index.md +1 -1
- package/skills/g9-lynx-app/references/components/popover.md +18 -0
package/dist/popover/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { G9ActionSheet, type G9ActionSheetProps, G9ContextMenu, type G9ContextMenuProps, G9Menu, type G9MenuItem, G9MenuList, type G9MenuListProps, type G9MenuProps, type G9OpenPopover, G9OverlayRoot, G9Popover, type G9PopoverProps, g9Popovers, useG9OpenOverlay, } from './popover.js';
|
|
2
2
|
export { computePopoverPosition, type G9Placement, type G9PopoverPosition, type G9PopoverPositionInput, } from './position.js';
|
|
3
|
+
export { G9_TOOLTIP_DEFAULT_HIDE_MS, G9Tooltip, type G9TooltipProps, useG9Tooltip, } from './tooltip.js';
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/popover/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,EACvB,aAAa,EACb,KAAK,kBAAkB,EACvB,MAAM,EACN,KAAK,UAAU,EACf,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,aAAa,EACb,SAAS,EACT,KAAK,cAAc,EACnB,UAAU,EACV,gBAAgB,GACjB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,sBAAsB,EACtB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,GAC5B,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/popover/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,EACvB,aAAa,EACb,KAAK,kBAAkB,EACvB,MAAM,EACN,KAAK,UAAU,EACf,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,aAAa,EACb,SAAS,EACT,KAAK,cAAc,EACnB,UAAU,EACV,gBAAgB,GACjB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,sBAAsB,EACtB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,GAC5B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,0BAA0B,EAC1B,SAAS,EACT,KAAK,cAAc,EACnB,YAAY,GACb,MAAM,WAAW,CAAC"}
|
package/dist/popover/index.jsx
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { G9ActionSheet, G9ContextMenu, G9Menu, G9MenuList, G9OverlayRoot, G9Popover, g9Popovers, useG9OpenOverlay } from "./popover.jsx";
|
|
2
2
|
export { computePopoverPosition } from "./position.jsx";
|
|
3
|
+
export { G9Tooltip, G9_TOOLTIP_DEFAULT_HIDE_MS, useG9Tooltip } from "./tooltip.jsx";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type ReactNode } from '@lynx-js/react';
|
|
2
|
+
import type { NodesRef } from '@lynx-js/types';
|
|
3
|
+
import type { G9AnchorRect } from '../anchor/registry.js';
|
|
4
|
+
import type { G9Placement } from './position.js';
|
|
5
|
+
/** How long a tooltip stays when nothing closes it first (ms). */
|
|
6
|
+
export declare const G9_TOOLTIP_DEFAULT_HIDE_MS = 4000;
|
|
7
|
+
/** Props of {@link G9Tooltip}. */
|
|
8
|
+
export interface G9TooltipProps {
|
|
9
|
+
readonly open: boolean;
|
|
10
|
+
readonly onClose: () => void;
|
|
11
|
+
/** The text of the bubble (one or more lines). */
|
|
12
|
+
readonly text: string;
|
|
13
|
+
/** The `id` of the control it explains (any control registered as an anchor)… */
|
|
14
|
+
readonly anchorId?: string;
|
|
15
|
+
/** …or a rect… */
|
|
16
|
+
readonly anchorRect?: G9AnchorRect;
|
|
17
|
+
/** …or an element ref's node. */
|
|
18
|
+
readonly anchorNode?: NodesRef | null;
|
|
19
|
+
/**
|
|
20
|
+
* Draw the bubble IN PLACE, inside the control it explains (rendered as that control's last child, absolutely placed
|
|
21
|
+
* above it), instead of in the host's popup layer. For a control inside a G9 sheet: Lynx paints a sheet (a fixed
|
|
22
|
+
* element) above every in-flow layer, the popup layer included, so a popup-layer bubble over a sheet is hidden behind
|
|
23
|
+
* it. The parent must be positioned (`position: relative`); no anchor props are needed.
|
|
24
|
+
*/
|
|
25
|
+
readonly inline?: boolean;
|
|
26
|
+
/** `inline`: which end of the control the bubble lines up with (default `'start'`, the reading start). */
|
|
27
|
+
readonly align?: 'start' | 'end';
|
|
28
|
+
/** Default `'top'`; flips below when there is no room above. */
|
|
29
|
+
readonly placement?: G9Placement;
|
|
30
|
+
/** Closes by itself after this many ms (default {@link G9_TOOLTIP_DEFAULT_HIDE_MS}); `0` = only a tap closes it. */
|
|
31
|
+
readonly autoHideMs?: number;
|
|
32
|
+
readonly id?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A short explanation pointing at a control (a value a card leaves out, shown on a tap): drawn in the popup
|
|
36
|
+
* layer like {@link G9Popover} — measured, placed above the control and flipped or clamped into the window — as a compact
|
|
37
|
+
* inverse-surface bubble. It closes by itself after `autoHideMs`, on a tap anywhere, or on Back. Toggle it from the
|
|
38
|
+
* control with {@link useG9Tooltip}, so a second tap on the control closes it.
|
|
39
|
+
*/
|
|
40
|
+
export declare function G9Tooltip(props: G9TooltipProps): ReactNode;
|
|
41
|
+
/** Open / close / toggle state for a {@link G9Tooltip}: a tap on its control calls `toggle`. */
|
|
42
|
+
export declare function useG9Tooltip(): {
|
|
43
|
+
readonly open: boolean;
|
|
44
|
+
readonly show: () => void;
|
|
45
|
+
readonly close: () => void;
|
|
46
|
+
readonly toggle: () => void;
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../src/popover/tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAoC,MAAM,gBAAgB,CAAC;AAClF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAoB9C,kEAAkE;AAClE,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,kCAAkC;AAClC,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;IAC7B,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,kBAAkB;IAClB,QAAQ,CAAC,UAAU,CAAC,EAAE,YAAY,CAAC;IACnC,iCAAiC;IACjC,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IACtC;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,0GAA0G;IAC1G,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IACjC,gEAAgE;IAChE,QAAQ,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC;IACjC,oHAAoH;IACpH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,CA6C1D;AAED,gGAAgG;AAChG,wBAAgB,YAAY,IAAI;IAC9B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;CAC7B,CAMA"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from "@lynx-js/react";
|
|
2
|
+
import { useG9Direction } from "../provider/hooks.jsx";
|
|
3
|
+
import { G9Popover } from "./popover.jsx";
|
|
4
|
+
const BUBBLE = {
|
|
5
|
+
minWidth: '0px',
|
|
6
|
+
maxWidth: '280px',
|
|
7
|
+
borderRadius: '10px',
|
|
8
|
+
borderWidth: '0px',
|
|
9
|
+
backgroundColor: 'var(--g9-inverse-surface)'
|
|
10
|
+
};
|
|
11
|
+
const TEXT = {
|
|
12
|
+
padding: '8px 12px',
|
|
13
|
+
fontFamily: 'var(--g9-font-text)',
|
|
14
|
+
fontSize: '13px',
|
|
15
|
+
lineHeight: '18px',
|
|
16
|
+
color: 'var(--g9-inverse-on-surface)'
|
|
17
|
+
};
|
|
18
|
+
const G9_TOOLTIP_DEFAULT_HIDE_MS = 4000;
|
|
19
|
+
function G9Tooltip(props) {
|
|
20
|
+
var _props_autoHideMs, _props_placement;
|
|
21
|
+
const { open, onClose } = props;
|
|
22
|
+
const hideMs = null != (_props_autoHideMs = props.autoHideMs) ? _props_autoHideMs : G9_TOOLTIP_DEFAULT_HIDE_MS;
|
|
23
|
+
const dir = useG9Direction();
|
|
24
|
+
useEffect(()=>{
|
|
25
|
+
if (!open || hideMs <= 0) return;
|
|
26
|
+
const timer = setTimeout(onClose, hideMs);
|
|
27
|
+
return ()=>clearTimeout(timer);
|
|
28
|
+
}, [
|
|
29
|
+
open,
|
|
30
|
+
hideMs,
|
|
31
|
+
onClose
|
|
32
|
+
]);
|
|
33
|
+
if (props.inline) {
|
|
34
|
+
var _props_align;
|
|
35
|
+
if (!open) return null;
|
|
36
|
+
return <view {...void 0 !== props.id ? {
|
|
37
|
+
id: props.id
|
|
38
|
+
} : {}} accessibility-label={props.text} style={{
|
|
39
|
+
...BUBBLE,
|
|
40
|
+
position: 'absolute',
|
|
41
|
+
bottom: '100%',
|
|
42
|
+
marginBottom: '6px',
|
|
43
|
+
zIndex: 10,
|
|
44
|
+
...(null != (_props_align = props.align) ? _props_align : 'start') === 'start' === ('rtl' === dir) ? {
|
|
45
|
+
right: '0px'
|
|
46
|
+
} : {
|
|
47
|
+
left: '0px'
|
|
48
|
+
}
|
|
49
|
+
}}>
|
|
50
|
+
<text style={TEXT}>{props.text}</text>
|
|
51
|
+
</view>;
|
|
52
|
+
}
|
|
53
|
+
return <G9Popover open={open} onClose={onClose} {...void 0 !== props.anchorId ? {
|
|
54
|
+
anchorId: props.anchorId
|
|
55
|
+
} : {}} {...void 0 !== props.anchorRect ? {
|
|
56
|
+
anchorRect: props.anchorRect
|
|
57
|
+
} : {}} {...void 0 !== props.anchorNode ? {
|
|
58
|
+
anchorNode: props.anchorNode
|
|
59
|
+
} : {}} placement={null != (_props_placement = props.placement) ? _props_placement : 'top'} offset={6} style={BUBBLE} accessibilityLabel={props.text} {...void 0 !== props.id ? {
|
|
60
|
+
id: props.id
|
|
61
|
+
} : {}}>
|
|
62
|
+
<text style={TEXT}>{props.text}</text>
|
|
63
|
+
</G9Popover>;
|
|
64
|
+
}
|
|
65
|
+
function useG9Tooltip() {
|
|
66
|
+
const [open, setOpen] = useState(false);
|
|
67
|
+
const show = useCallback(()=>setOpen(true), []);
|
|
68
|
+
const close = useCallback(()=>setOpen(false), []);
|
|
69
|
+
const toggle = useCallback(()=>setOpen((o)=>!o), []);
|
|
70
|
+
return {
|
|
71
|
+
open,
|
|
72
|
+
show,
|
|
73
|
+
close,
|
|
74
|
+
toggle
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export { G9Tooltip, G9_TOOLTIP_DEFAULT_HIDE_MS, useG9Tooltip };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@g9tm/lynxcontrols",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "ReactLynx controls and overlay infrastructure: provider/host, sheets, popups, toasts, fields, buttons, pickers, tab view, tab bar, edge panel, swipe rows.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -234,7 +234,7 @@
|
|
|
234
234
|
"build": "rslib build"
|
|
235
235
|
},
|
|
236
236
|
"dependencies": {
|
|
237
|
-
"@g9tm/lynxcontrols-foundation": "2.
|
|
237
|
+
"@g9tm/lynxcontrols-foundation": "2.6.1"
|
|
238
238
|
},
|
|
239
239
|
"peerDependencies": {
|
|
240
240
|
"@lynx-js/react": ">=0.129.3 <0.130.0",
|
|
@@ -53,7 +53,7 @@ Generated from the installed packages' catalogs (`<package>/catalog`): one line
|
|
|
53
53
|
- `@g9tm/lynxcontrols/orb`: G9FloatingOrb, G9HoldButton → `components/orb.md`
|
|
54
54
|
- `@g9tm/lynxcontrols/pickers`: DateTimeSheetBody, G9ComboBox, G9DateTimePicker, G9DayStepper, G9Picker, G9TimeSpanPicker, G9WheelColumn, PickerField, PickerSheetHeader, SelectionValueIcon, TimeSpanSheetBody → `components/pickers.md`
|
|
55
55
|
- `@g9tm/lynxcontrols/plus-button`: G9PlusButton → `components/plus-button.md`
|
|
56
|
-
- `@g9tm/lynxcontrols/popover`: G9ActionSheet, G9ContextMenu, G9Menu, G9MenuList, G9OverlayRoot, G9Popover → `components/popover.md`
|
|
56
|
+
- `@g9tm/lynxcontrols/popover`: G9ActionSheet, G9ContextMenu, G9Menu, G9MenuList, G9OverlayRoot, G9Popover, G9Tooltip → `components/popover.md`
|
|
57
57
|
- `@g9tm/lynxcontrols/popup`: G9PopupDragHandle, G9PopupView, PopupFrame, PopupInputForm → `components/popup.md`
|
|
58
58
|
- `@g9tm/lynxcontrols/provider`: G9Activity, G9DirectionScope, G9KeepAlive, G9Provider → `components/provider.md`
|
|
59
59
|
- `@g9tm/lynxcontrols/range-slider`: G9RangeSlider, G9StepSlider → `components/range-slider.md`
|
|
@@ -94,3 +94,21 @@ Props:
|
|
|
94
94
|
- `anchorRect?`: object
|
|
95
95
|
|
|
96
96
|
Example: `<G9Popover onClose={() => {}} open />`
|
|
97
|
+
|
|
98
|
+
# G9Tooltip
|
|
99
|
+
|
|
100
|
+
`import { G9Tooltip } from '@g9tm/lynxcontrols/popover';`
|
|
101
|
+
|
|
102
|
+
A short explanation pointing at a control (a value a card leaves out, shown on a tap): drawn in the popup layer like `G9Popover` — measured, placed above the control and flipped or clamped into the window — as a compact
|
|
103
|
+
|
|
104
|
+
Props:
|
|
105
|
+
- `onClose`: () => void
|
|
106
|
+
- `open`: boolean
|
|
107
|
+
- `text`: string
|
|
108
|
+
- `placement?`: 'end' | 'start' | 'top' | 'bottom' | 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end' | 'start-start' | 'start-end' | 'end-start' | 'end-end' = "top"
|
|
109
|
+
- `align?`: 'end' | 'start'
|
|
110
|
+
- `anchorId?`: string
|
|
111
|
+
- `anchorNode?`: object
|
|
112
|
+
- `anchorRect?`: object
|
|
113
|
+
|
|
114
|
+
Example: `<G9Tooltip onClose={() => {}} open text="Label" />`
|