@tamagui/tooltip 1.0.0-beta.6
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/cjs/Tooltip.js +169 -0
- package/dist/cjs/Tooltip.js.map +7 -0
- package/dist/cjs/index.js +18 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/esm/Tooltip.js +135 -0
- package/dist/esm/Tooltip.js.map +7 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/jsx/Tooltip.js +105 -0
- package/dist/jsx/index.js +1 -0
- package/package.json +48 -0
- package/types/Tooltip.d.ts +71 -0
- package/types/Tooltip.d.ts.map +1 -0
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
+
};
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
+
}
|
|
47
|
+
return to;
|
|
48
|
+
};
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
50
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
51
|
+
var Tooltip_exports = {};
|
|
52
|
+
__export(Tooltip_exports, {
|
|
53
|
+
Tooltip: () => Tooltip,
|
|
54
|
+
TooltipGroup: () => TooltipGroup,
|
|
55
|
+
TooltipSimple: () => TooltipSimple
|
|
56
|
+
});
|
|
57
|
+
module.exports = __toCommonJS(Tooltip_exports);
|
|
58
|
+
var import_polyfill_dev = require("@tamagui/polyfill-dev");
|
|
59
|
+
var import_react_dom_interactions = require("@floating-ui/react-dom-interactions");
|
|
60
|
+
var import_core = require("@tamagui/core");
|
|
61
|
+
var import_popover = require("@tamagui/popover");
|
|
62
|
+
var import_popper = require("@tamagui/popper");
|
|
63
|
+
var import_text = require("@tamagui/text");
|
|
64
|
+
var React = __toESM(require("react"));
|
|
65
|
+
const TooltipContent = React.forwardRef((props, ref) => {
|
|
66
|
+
return /* @__PURE__ */ React.createElement(import_popover.PopoverContent, __spreadValues({
|
|
67
|
+
pointerEvents: "none",
|
|
68
|
+
ref
|
|
69
|
+
}, props));
|
|
70
|
+
});
|
|
71
|
+
const TooltipGroup = import_react_dom_interactions.FloatingDelayGroup;
|
|
72
|
+
const Tooltip = (0, import_core.withStaticProperties)((props) => {
|
|
73
|
+
const _a = props, { __scopePopover, children, restMs = 500, delay: delayProp } = _a, restProps = __objRest(_a, ["__scopePopover", "children", "restMs", "delay"]);
|
|
74
|
+
const popperScope = (0, import_popover.usePopoverScope)(__scopePopover);
|
|
75
|
+
const triggerRef = React.useRef(null);
|
|
76
|
+
const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);
|
|
77
|
+
const { delay: delayGroup, setCurrentId } = (0, import_react_dom_interactions.useDelayGroupContext)();
|
|
78
|
+
const delay = delayProp ?? delayGroup;
|
|
79
|
+
const [open, setOpen] = React.useState(false);
|
|
80
|
+
const id = props.groupId;
|
|
81
|
+
const onOpenChange = React.useCallback((open2) => {
|
|
82
|
+
var _a2;
|
|
83
|
+
setOpen(open2);
|
|
84
|
+
if (open2) {
|
|
85
|
+
setCurrentId(id);
|
|
86
|
+
}
|
|
87
|
+
(_a2 = props.onOpenChange) == null ? void 0 : _a2.call(props, open2);
|
|
88
|
+
}, [id, setCurrentId]);
|
|
89
|
+
const useFloatingFn = /* @__PURE__ */ __name((props2) => {
|
|
90
|
+
const floating = (0, import_react_dom_interactions.useFloating)(__spreadProps(__spreadValues({}, props2), {
|
|
91
|
+
open,
|
|
92
|
+
onOpenChange
|
|
93
|
+
}));
|
|
94
|
+
const { getReferenceProps, getFloatingProps } = (0, import_react_dom_interactions.useInteractions)([
|
|
95
|
+
(0, import_react_dom_interactions.useHover)(floating.context, { delay, restMs }),
|
|
96
|
+
(0, import_react_dom_interactions.useFocus)(floating.context),
|
|
97
|
+
(0, import_react_dom_interactions.useRole)(floating.context, { role: "tooltip" }),
|
|
98
|
+
(0, import_react_dom_interactions.useDismiss)(floating.context),
|
|
99
|
+
(0, import_react_dom_interactions.useDelayGroup)(floating.context, { id })
|
|
100
|
+
]);
|
|
101
|
+
return __spreadProps(__spreadValues({}, floating), {
|
|
102
|
+
getReferenceProps,
|
|
103
|
+
getFloatingProps
|
|
104
|
+
});
|
|
105
|
+
}, "useFloatingFn");
|
|
106
|
+
const useFloatingContext = React.useCallback(useFloatingFn, [id, delay, open]);
|
|
107
|
+
const voidFn = React.useCallback(() => {
|
|
108
|
+
}, [setOpen]);
|
|
109
|
+
return /* @__PURE__ */ React.createElement(import_popper.FloatingOverrideContext.Provider, {
|
|
110
|
+
value: useFloatingContext
|
|
111
|
+
}, /* @__PURE__ */ React.createElement(import_popper.Popper, __spreadValues(__spreadValues({
|
|
112
|
+
size: "$2"
|
|
113
|
+
}, popperScope), restProps), /* @__PURE__ */ React.createElement(import_popover.__PopoverProviderInternal, {
|
|
114
|
+
scope: __scopePopover,
|
|
115
|
+
contentId: (0, import_core.useId)(),
|
|
116
|
+
triggerRef,
|
|
117
|
+
open,
|
|
118
|
+
onOpenChange: setOpen,
|
|
119
|
+
onOpenToggle: voidFn,
|
|
120
|
+
hasCustomAnchor,
|
|
121
|
+
onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(true), []),
|
|
122
|
+
onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(false), []),
|
|
123
|
+
modal: true
|
|
124
|
+
}, children)));
|
|
125
|
+
}, {
|
|
126
|
+
Anchor: import_popover.PopoverAnchor,
|
|
127
|
+
Arrow: import_popover.PopoverArrow,
|
|
128
|
+
Close: import_popover.PopoverClose,
|
|
129
|
+
Content: TooltipContent,
|
|
130
|
+
Trigger: import_popover.PopoverTrigger
|
|
131
|
+
});
|
|
132
|
+
Tooltip.displayName = "Tooltip";
|
|
133
|
+
const TooltipSimple = /* @__PURE__ */ __name((_a) => {
|
|
134
|
+
var _b = _a, {
|
|
135
|
+
label,
|
|
136
|
+
children,
|
|
137
|
+
contentProps
|
|
138
|
+
} = _b, tooltipProps = __objRest(_b, [
|
|
139
|
+
"label",
|
|
140
|
+
"children",
|
|
141
|
+
"contentProps"
|
|
142
|
+
]);
|
|
143
|
+
return /* @__PURE__ */ React.createElement(TooltipGroup, {
|
|
144
|
+
delay: { open: 3e3, close: 100 }
|
|
145
|
+
}, /* @__PURE__ */ React.createElement(Tooltip, __spreadValues({}, tooltipProps), /* @__PURE__ */ React.createElement(Tooltip.Trigger, null, children), /* @__PURE__ */ React.createElement(Tooltip.Content, __spreadValues({
|
|
146
|
+
enterStyle: { x: 0, y: -10, opacity: 0, scale: 0.9 },
|
|
147
|
+
exitStyle: { x: 0, y: -10, opacity: 0, scale: 0.9 },
|
|
148
|
+
x: 0,
|
|
149
|
+
scale: 1,
|
|
150
|
+
y: 0,
|
|
151
|
+
elevation: "$1",
|
|
152
|
+
opacity: 1,
|
|
153
|
+
animation: [
|
|
154
|
+
"bouncy",
|
|
155
|
+
{
|
|
156
|
+
opacity: {
|
|
157
|
+
overshootClamping: true
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
}, contentProps), /* @__PURE__ */ React.createElement(Tooltip.Arrow, null), /* @__PURE__ */ React.createElement(import_text.Paragraph, null, label))));
|
|
162
|
+
}, "TooltipSimple");
|
|
163
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
164
|
+
0 && (module.exports = {
|
|
165
|
+
Tooltip,
|
|
166
|
+
TooltipGroup,
|
|
167
|
+
TooltipSimple
|
|
168
|
+
});
|
|
169
|
+
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Tooltip.tsx"],
|
|
4
|
+
"sourcesContent": ["import '@tamagui/polyfill-dev'\n\nimport {\n FloatingDelayGroup,\n useDelayGroup,\n useDelayGroupContext,\n useDismiss,\n useFloating,\n useFocus,\n useHover,\n useInteractions,\n useRole,\n} from '@floating-ui/react-dom-interactions'\nimport { useId, withStaticProperties } from '@tamagui/core'\nimport { ScopedProps } from '@tamagui/create-context'\nimport {\n PopoverAnchor,\n PopoverArrow,\n PopoverClose,\n PopoverContent,\n PopoverContentProps,\n PopoverTrigger,\n __PopoverProviderInternal,\n usePopoverScope,\n} from '@tamagui/popover'\nimport { FloatingOverrideContext, Popper, PopperProps, UseFloatingFn } from '@tamagui/popper'\nimport { SizableStackProps } from '@tamagui/stacks'\nimport { Paragraph } from '@tamagui/text'\nimport * as React from 'react'\n\nconst TooltipContent = React.forwardRef((props: PopoverContentProps, ref: any) => {\n return <PopoverContent pointerEvents=\"none\" ref={ref} {...props} />\n})\n\nexport type TooltipProps = PopperProps & {\n children?: React.ReactNode\n onOpenChange?: (open: boolean) => void\n groupId?: string\n restMs?: number\n delay?:\n | number\n | {\n open?: number\n close?: number\n }\n}\n\nexport const TooltipGroup = FloatingDelayGroup\n\nexport const Tooltip = withStaticProperties(\n ((props: ScopedProps<TooltipProps, 'Popover'>) => {\n const { __scopePopover, children, restMs = 500, delay: delayProp, ...restProps } = props\n const popperScope = usePopoverScope(__scopePopover)\n const triggerRef = React.useRef<HTMLButtonElement>(null)\n const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false)\n const { delay: delayGroup, setCurrentId } = useDelayGroupContext()\n const delay = delayProp ?? delayGroup\n const [open, setOpen] = React.useState(false)\n const id = props.groupId\n\n const onOpenChange = React.useCallback(\n (open) => {\n setOpen(open)\n if (open) {\n setCurrentId(id)\n }\n props.onOpenChange?.(open)\n },\n [id, setCurrentId]\n )\n\n const useFloatingFn: UseFloatingFn = (props) => {\n const floating = useFloating({\n ...props,\n open,\n onOpenChange,\n })\n const { getReferenceProps, getFloatingProps } = useInteractions([\n useHover(floating.context, { delay, restMs }),\n useFocus(floating.context),\n useRole(floating.context, { role: 'tooltip' }),\n useDismiss(floating.context),\n useDelayGroup(floating.context, { id }),\n ])\n return {\n ...floating,\n getReferenceProps,\n getFloatingProps,\n } as any\n }\n\n const useFloatingContext = React.useCallback(useFloatingFn, [id, delay, open])\n\n const voidFn = React.useCallback(() => {}, [setOpen])\n\n return (\n <FloatingOverrideContext.Provider value={useFloatingContext}>\n {/* default tooltip to a smaller size */}\n <Popper size=\"$2\" {...popperScope} {...restProps}>\n <__PopoverProviderInternal\n scope={__scopePopover}\n contentId={useId()}\n triggerRef={triggerRef}\n open={open}\n onOpenChange={setOpen}\n onOpenToggle={voidFn}\n hasCustomAnchor={hasCustomAnchor}\n onCustomAnchorAdd={React.useCallback(() => setHasCustomAnchor(true), [])}\n onCustomAnchorRemove={React.useCallback(() => setHasCustomAnchor(false), [])}\n modal\n >\n {children}\n </__PopoverProviderInternal>\n </Popper>\n </FloatingOverrideContext.Provider>\n )\n }) as React.FC<TooltipProps>,\n {\n Anchor: PopoverAnchor,\n Arrow: PopoverArrow,\n Close: PopoverClose,\n Content: TooltipContent,\n Trigger: PopoverTrigger,\n }\n)\n\nTooltip.displayName = 'Tooltip'\n\nexport type TooltipSimpleProps = TooltipProps & {\n label?: React.ReactNode\n children?: React.ReactNode\n contentProps?: SizableStackProps\n}\n\nexport const TooltipSimple: React.FC<TooltipSimpleProps> = ({\n label,\n children,\n contentProps,\n ...tooltipProps\n}) => {\n return (\n <TooltipGroup delay={{ open: 3000, close: 100 }}>\n <Tooltip {...tooltipProps}>\n <Tooltip.Trigger>{children}</Tooltip.Trigger>\n <Tooltip.Content\n enterStyle={{ x: 0, y: -10, opacity: 0, scale: 0.9 }}\n exitStyle={{ x: 0, y: -10, opacity: 0, scale: 0.9 }}\n x={0}\n scale={1}\n y={0}\n elevation=\"$1\"\n opacity={1}\n animation={[\n 'bouncy',\n {\n opacity: {\n overshootClamping: true,\n },\n },\n ]}\n {...contentProps}\n >\n <Tooltip.Arrow />\n <Paragraph>{label}</Paragraph>\n </Tooltip.Content>\n </Tooltip>\n </TooltipGroup>\n )\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAO;AAEP,oCAUO;AACP,kBAA4C;AAE5C,qBASO;AACP,oBAA4E;AAE5E,kBAA0B;AAC1B,YAAuB;AAEvB,MAAM,iBAAiB,MAAM,WAAW,CAAC,OAA4B,QAAa;AAChF,SAAO,oCAAC;AAAA,IAAe,eAAc;AAAA,IAAO;AAAA,KAAc,MAAO;AACnE,CAAC;AAeM,MAAM,eAAe;AAErB,MAAM,UAAU,sCACpB,CAAC,UAAgD;AAChD,QAAmF,YAA3E,kBAAgB,UAAU,SAAS,KAAK,OAAO,cAA4B,IAAd,sBAAc,IAAd,CAA7D,kBAAgB,YAAU,UAAc;AAChD,QAAM,cAAc,oCAAgB,cAAc;AAClD,QAAM,aAAa,MAAM,OAA0B,IAAI;AACvD,QAAM,CAAC,iBAAiB,sBAAsB,MAAM,SAAS,KAAK;AAClE,QAAM,EAAE,OAAO,YAAY,iBAAiB,wDAAqB;AACjE,QAAM,QAAQ,aAAa;AAC3B,QAAM,CAAC,MAAM,WAAW,MAAM,SAAS,KAAK;AAC5C,QAAM,KAAK,MAAM;AAEjB,QAAM,eAAe,MAAM,YACzB,CAAC,UAAS;AA7DhB;AA8DQ,YAAQ,KAAI;AACZ,QAAI,OAAM;AACR,mBAAa,EAAE;AAAA,IACjB;AACA,iBAAM,iBAAN,gCAAqB;AAAA,EACvB,GACA,CAAC,IAAI,YAAY,CACnB;AAEA,QAAM,gBAA+B,wBAAC,WAAU;AAC9C,UAAM,WAAW,+CAAY,iCACxB,SADwB;AAAA,MAE3B;AAAA,MACA;AAAA,IACF,EAAC;AACD,UAAM,EAAE,mBAAmB,qBAAqB,mDAAgB;AAAA,MAC9D,4CAAS,SAAS,SAAS,EAAE,OAAO,OAAO,CAAC;AAAA,MAC5C,4CAAS,SAAS,OAAO;AAAA,MACzB,2CAAQ,SAAS,SAAS,EAAE,MAAM,UAAU,CAAC;AAAA,MAC7C,8CAAW,SAAS,OAAO;AAAA,MAC3B,iDAAc,SAAS,SAAS,EAAE,GAAG,CAAC;AAAA,IACxC,CAAC;AACD,WAAO,iCACF,WADE;AAAA,MAEL;AAAA,MACA;AAAA,IACF;AAAA,EACF,GAlBqC;AAoBrC,QAAM,qBAAqB,MAAM,YAAY,eAAe,CAAC,IAAI,OAAO,IAAI,CAAC;AAE7E,QAAM,SAAS,MAAM,YAAY,MAAM;AAAA,EAAC,GAAG,CAAC,OAAO,CAAC;AAEpD,SACE,oCAAC,sCAAwB,UAAxB;AAAA,IAAiC,OAAO;AAAA,KAEvC,oCAAC;AAAA,IAAO,MAAK;AAAA,KAAS,cAAiB,YACrC,oCAAC;AAAA,IACC,OAAO;AAAA,IACP,WAAW,uBAAM;AAAA,IACjB;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,cAAc;AAAA,IACd;AAAA,IACA,mBAAmB,MAAM,YAAY,MAAM,mBAAmB,IAAI,GAAG,CAAC,CAAC;AAAA,IACvE,sBAAsB,MAAM,YAAY,MAAM,mBAAmB,KAAK,GAAG,CAAC,CAAC;AAAA,IAC3E,OAAK;AAAA,KAEJ,QACH,CACF,CACF;AAEJ,GACA;AAAA,EACE,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AACX,CACF;AAEA,QAAQ,cAAc;AAQf,MAAM,gBAA8C,wBAAC,OAKtD;AALsD,eAC1D;AAAA;AAAA,IACA;AAAA,IACA;AAAA,MAH0D,IAIvD,yBAJuD,IAIvD;AAAA,IAHH;AAAA,IACA;AAAA,IACA;AAAA;AAGA,SACE,oCAAC;AAAA,IAAa,OAAO,EAAE,MAAM,KAAM,OAAO,IAAI;AAAA,KAC5C,oCAAC,4BAAY,eACX,oCAAC,QAAQ,SAAR,MAAiB,QAAS,GAC3B,oCAAC,QAAQ,SAAR;AAAA,IACC,YAAY,EAAE,GAAG,GAAG,GAAG,KAAK,SAAS,GAAG,OAAO,IAAI;AAAA,IACnD,WAAW,EAAE,GAAG,GAAG,GAAG,KAAK,SAAS,GAAG,OAAO,IAAI;AAAA,IAClD,GAAG;AAAA,IACH,OAAO;AAAA,IACP,GAAG;AAAA,IACH,WAAU;AAAA,IACV,SAAS;AAAA,IACT,WAAW;AAAA,MACT;AAAA,MACA;AAAA,QACE,SAAS;AAAA,UACP,mBAAmB;AAAA,QACrB;AAAA,MACF;AAAA,IACF;AAAA,KACI,eAEJ,oCAAC,QAAQ,OAAR,IAAc,GACf,oCAAC,6BAAW,KAAM,CACpB,CACF,CACF;AAEJ,GAlC2D;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var src_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(src_exports);
|
|
17
|
+
__reExport(src_exports, require("./Tooltip"), module.exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import "@tamagui/polyfill-dev";
|
|
4
|
+
import {
|
|
5
|
+
FloatingDelayGroup,
|
|
6
|
+
useDelayGroup,
|
|
7
|
+
useDelayGroupContext,
|
|
8
|
+
useDismiss,
|
|
9
|
+
useFloating,
|
|
10
|
+
useFocus,
|
|
11
|
+
useHover,
|
|
12
|
+
useInteractions,
|
|
13
|
+
useRole
|
|
14
|
+
} from "@floating-ui/react-dom-interactions";
|
|
15
|
+
import { useId, withStaticProperties } from "@tamagui/core";
|
|
16
|
+
import {
|
|
17
|
+
PopoverAnchor,
|
|
18
|
+
PopoverArrow,
|
|
19
|
+
PopoverClose,
|
|
20
|
+
PopoverContent,
|
|
21
|
+
PopoverTrigger,
|
|
22
|
+
__PopoverProviderInternal,
|
|
23
|
+
usePopoverScope
|
|
24
|
+
} from "@tamagui/popover";
|
|
25
|
+
import { FloatingOverrideContext, Popper } from "@tamagui/popper";
|
|
26
|
+
import { Paragraph } from "@tamagui/text";
|
|
27
|
+
import * as React from "react";
|
|
28
|
+
const TooltipContent = React.forwardRef((props, ref) => {
|
|
29
|
+
return /* @__PURE__ */ React.createElement(PopoverContent, {
|
|
30
|
+
pointerEvents: "none",
|
|
31
|
+
ref,
|
|
32
|
+
...props
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
const TooltipGroup = FloatingDelayGroup;
|
|
36
|
+
const Tooltip = withStaticProperties((props) => {
|
|
37
|
+
const { __scopePopover, children, restMs = 500, delay: delayProp, ...restProps } = props;
|
|
38
|
+
const popperScope = usePopoverScope(__scopePopover);
|
|
39
|
+
const triggerRef = React.useRef(null);
|
|
40
|
+
const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);
|
|
41
|
+
const { delay: delayGroup, setCurrentId } = useDelayGroupContext();
|
|
42
|
+
const delay = delayProp != null ? delayProp : delayGroup;
|
|
43
|
+
const [open, setOpen] = React.useState(false);
|
|
44
|
+
const id = props.groupId;
|
|
45
|
+
const onOpenChange = React.useCallback((open2) => {
|
|
46
|
+
var _a;
|
|
47
|
+
setOpen(open2);
|
|
48
|
+
if (open2) {
|
|
49
|
+
setCurrentId(id);
|
|
50
|
+
}
|
|
51
|
+
(_a = props.onOpenChange) == null ? void 0 : _a.call(props, open2);
|
|
52
|
+
}, [id, setCurrentId]);
|
|
53
|
+
const useFloatingFn = /* @__PURE__ */ __name((props2) => {
|
|
54
|
+
const floating = useFloating({
|
|
55
|
+
...props2,
|
|
56
|
+
open,
|
|
57
|
+
onOpenChange
|
|
58
|
+
});
|
|
59
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
60
|
+
useHover(floating.context, { delay, restMs }),
|
|
61
|
+
useFocus(floating.context),
|
|
62
|
+
useRole(floating.context, { role: "tooltip" }),
|
|
63
|
+
useDismiss(floating.context),
|
|
64
|
+
useDelayGroup(floating.context, { id })
|
|
65
|
+
]);
|
|
66
|
+
return {
|
|
67
|
+
...floating,
|
|
68
|
+
getReferenceProps,
|
|
69
|
+
getFloatingProps
|
|
70
|
+
};
|
|
71
|
+
}, "useFloatingFn");
|
|
72
|
+
const useFloatingContext = React.useCallback(useFloatingFn, [id, delay, open]);
|
|
73
|
+
const voidFn = React.useCallback(() => {
|
|
74
|
+
}, [setOpen]);
|
|
75
|
+
return /* @__PURE__ */ React.createElement(FloatingOverrideContext.Provider, {
|
|
76
|
+
value: useFloatingContext
|
|
77
|
+
}, /* @__PURE__ */ React.createElement(Popper, {
|
|
78
|
+
size: "$2",
|
|
79
|
+
...popperScope,
|
|
80
|
+
...restProps
|
|
81
|
+
}, /* @__PURE__ */ React.createElement(__PopoverProviderInternal, {
|
|
82
|
+
scope: __scopePopover,
|
|
83
|
+
contentId: useId(),
|
|
84
|
+
triggerRef,
|
|
85
|
+
open,
|
|
86
|
+
onOpenChange: setOpen,
|
|
87
|
+
onOpenToggle: voidFn,
|
|
88
|
+
hasCustomAnchor,
|
|
89
|
+
onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(true), []),
|
|
90
|
+
onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(false), []),
|
|
91
|
+
modal: true
|
|
92
|
+
}, children)));
|
|
93
|
+
}, {
|
|
94
|
+
Anchor: PopoverAnchor,
|
|
95
|
+
Arrow: PopoverArrow,
|
|
96
|
+
Close: PopoverClose,
|
|
97
|
+
Content: TooltipContent,
|
|
98
|
+
Trigger: PopoverTrigger
|
|
99
|
+
});
|
|
100
|
+
Tooltip.displayName = "Tooltip";
|
|
101
|
+
const TooltipSimple = /* @__PURE__ */ __name(({
|
|
102
|
+
label,
|
|
103
|
+
children,
|
|
104
|
+
contentProps,
|
|
105
|
+
...tooltipProps
|
|
106
|
+
}) => {
|
|
107
|
+
return /* @__PURE__ */ React.createElement(TooltipGroup, {
|
|
108
|
+
delay: { open: 3e3, close: 100 }
|
|
109
|
+
}, /* @__PURE__ */ React.createElement(Tooltip, {
|
|
110
|
+
...tooltipProps
|
|
111
|
+
}, /* @__PURE__ */ React.createElement(Tooltip.Trigger, null, children), /* @__PURE__ */ React.createElement(Tooltip.Content, {
|
|
112
|
+
enterStyle: { x: 0, y: -10, opacity: 0, scale: 0.9 },
|
|
113
|
+
exitStyle: { x: 0, y: -10, opacity: 0, scale: 0.9 },
|
|
114
|
+
x: 0,
|
|
115
|
+
scale: 1,
|
|
116
|
+
y: 0,
|
|
117
|
+
elevation: "$1",
|
|
118
|
+
opacity: 1,
|
|
119
|
+
animation: [
|
|
120
|
+
"bouncy",
|
|
121
|
+
{
|
|
122
|
+
opacity: {
|
|
123
|
+
overshootClamping: true
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
...contentProps
|
|
128
|
+
}, /* @__PURE__ */ React.createElement(Tooltip.Arrow, null), /* @__PURE__ */ React.createElement(Paragraph, null, label))));
|
|
129
|
+
}, "TooltipSimple");
|
|
130
|
+
export {
|
|
131
|
+
Tooltip,
|
|
132
|
+
TooltipGroup,
|
|
133
|
+
TooltipSimple
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Tooltip.tsx"],
|
|
4
|
+
"sourcesContent": ["import '@tamagui/polyfill-dev'\n\nimport {\n FloatingDelayGroup,\n useDelayGroup,\n useDelayGroupContext,\n useDismiss,\n useFloating,\n useFocus,\n useHover,\n useInteractions,\n useRole,\n} from '@floating-ui/react-dom-interactions'\nimport { useId, withStaticProperties } from '@tamagui/core'\nimport { ScopedProps } from '@tamagui/create-context'\nimport {\n PopoverAnchor,\n PopoverArrow,\n PopoverClose,\n PopoverContent,\n PopoverContentProps,\n PopoverTrigger,\n __PopoverProviderInternal,\n usePopoverScope,\n} from '@tamagui/popover'\nimport { FloatingOverrideContext, Popper, PopperProps, UseFloatingFn } from '@tamagui/popper'\nimport { SizableStackProps } from '@tamagui/stacks'\nimport { Paragraph } from '@tamagui/text'\nimport * as React from 'react'\n\nconst TooltipContent = React.forwardRef((props: PopoverContentProps, ref: any) => {\n return <PopoverContent pointerEvents=\"none\" ref={ref} {...props} />\n})\n\nexport type TooltipProps = PopperProps & {\n children?: React.ReactNode\n onOpenChange?: (open: boolean) => void\n groupId?: string\n restMs?: number\n delay?:\n | number\n | {\n open?: number\n close?: number\n }\n}\n\nexport const TooltipGroup = FloatingDelayGroup\n\nexport const Tooltip = withStaticProperties(\n ((props: ScopedProps<TooltipProps, 'Popover'>) => {\n const { __scopePopover, children, restMs = 500, delay: delayProp, ...restProps } = props\n const popperScope = usePopoverScope(__scopePopover)\n const triggerRef = React.useRef<HTMLButtonElement>(null)\n const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false)\n const { delay: delayGroup, setCurrentId } = useDelayGroupContext()\n const delay = delayProp ?? delayGroup\n const [open, setOpen] = React.useState(false)\n const id = props.groupId\n\n const onOpenChange = React.useCallback(\n (open) => {\n setOpen(open)\n if (open) {\n setCurrentId(id)\n }\n props.onOpenChange?.(open)\n },\n [id, setCurrentId]\n )\n\n const useFloatingFn: UseFloatingFn = (props) => {\n const floating = useFloating({\n ...props,\n open,\n onOpenChange,\n })\n const { getReferenceProps, getFloatingProps } = useInteractions([\n useHover(floating.context, { delay, restMs }),\n useFocus(floating.context),\n useRole(floating.context, { role: 'tooltip' }),\n useDismiss(floating.context),\n useDelayGroup(floating.context, { id }),\n ])\n return {\n ...floating,\n getReferenceProps,\n getFloatingProps,\n } as any\n }\n\n const useFloatingContext = React.useCallback(useFloatingFn, [id, delay, open])\n\n const voidFn = React.useCallback(() => {}, [setOpen])\n\n return (\n <FloatingOverrideContext.Provider value={useFloatingContext}>\n {/* default tooltip to a smaller size */}\n <Popper size=\"$2\" {...popperScope} {...restProps}>\n <__PopoverProviderInternal\n scope={__scopePopover}\n contentId={useId()}\n triggerRef={triggerRef}\n open={open}\n onOpenChange={setOpen}\n onOpenToggle={voidFn}\n hasCustomAnchor={hasCustomAnchor}\n onCustomAnchorAdd={React.useCallback(() => setHasCustomAnchor(true), [])}\n onCustomAnchorRemove={React.useCallback(() => setHasCustomAnchor(false), [])}\n modal\n >\n {children}\n </__PopoverProviderInternal>\n </Popper>\n </FloatingOverrideContext.Provider>\n )\n }) as React.FC<TooltipProps>,\n {\n Anchor: PopoverAnchor,\n Arrow: PopoverArrow,\n Close: PopoverClose,\n Content: TooltipContent,\n Trigger: PopoverTrigger,\n }\n)\n\nTooltip.displayName = 'Tooltip'\n\nexport type TooltipSimpleProps = TooltipProps & {\n label?: React.ReactNode\n children?: React.ReactNode\n contentProps?: SizableStackProps\n}\n\nexport const TooltipSimple: React.FC<TooltipSimpleProps> = ({\n label,\n children,\n contentProps,\n ...tooltipProps\n}) => {\n return (\n <TooltipGroup delay={{ open: 3000, close: 100 }}>\n <Tooltip {...tooltipProps}>\n <Tooltip.Trigger>{children}</Tooltip.Trigger>\n <Tooltip.Content\n enterStyle={{ x: 0, y: -10, opacity: 0, scale: 0.9 }}\n exitStyle={{ x: 0, y: -10, opacity: 0, scale: 0.9 }}\n x={0}\n scale={1}\n y={0}\n elevation=\"$1\"\n opacity={1}\n animation={[\n 'bouncy',\n {\n opacity: {\n overshootClamping: true,\n },\n },\n ]}\n {...contentProps}\n >\n <Tooltip.Arrow />\n <Paragraph>{label}</Paragraph>\n </Tooltip.Content>\n </Tooltip>\n </TooltipGroup>\n )\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import "@tamagui/polyfill-dev";
|
|
4
|
+
import {
|
|
5
|
+
FloatingDelayGroup,
|
|
6
|
+
useDelayGroup,
|
|
7
|
+
useDelayGroupContext,
|
|
8
|
+
useDismiss,
|
|
9
|
+
useFloating,
|
|
10
|
+
useFocus,
|
|
11
|
+
useHover,
|
|
12
|
+
useInteractions,
|
|
13
|
+
useRole
|
|
14
|
+
} from "@floating-ui/react-dom-interactions";
|
|
15
|
+
import { useId, withStaticProperties } from "@tamagui/core";
|
|
16
|
+
import {
|
|
17
|
+
PopoverAnchor,
|
|
18
|
+
PopoverArrow,
|
|
19
|
+
PopoverClose,
|
|
20
|
+
PopoverContent,
|
|
21
|
+
PopoverTrigger,
|
|
22
|
+
__PopoverProviderInternal,
|
|
23
|
+
usePopoverScope
|
|
24
|
+
} from "@tamagui/popover";
|
|
25
|
+
import { FloatingOverrideContext, Popper } from "@tamagui/popper";
|
|
26
|
+
import { Paragraph } from "@tamagui/text";
|
|
27
|
+
import * as React from "react";
|
|
28
|
+
const TooltipContent = React.forwardRef((props, ref) => {
|
|
29
|
+
return <PopoverContent pointerEvents="none" ref={ref} {...props} />;
|
|
30
|
+
});
|
|
31
|
+
const TooltipGroup = FloatingDelayGroup;
|
|
32
|
+
const Tooltip = withStaticProperties((props) => {
|
|
33
|
+
const { __scopePopover, children, restMs = 500, delay: delayProp, ...restProps } = props;
|
|
34
|
+
const popperScope = usePopoverScope(__scopePopover);
|
|
35
|
+
const triggerRef = React.useRef(null);
|
|
36
|
+
const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);
|
|
37
|
+
const { delay: delayGroup, setCurrentId } = useDelayGroupContext();
|
|
38
|
+
const delay = delayProp != null ? delayProp : delayGroup;
|
|
39
|
+
const [open, setOpen] = React.useState(false);
|
|
40
|
+
const id = props.groupId;
|
|
41
|
+
const onOpenChange = React.useCallback((open2) => {
|
|
42
|
+
var _a;
|
|
43
|
+
setOpen(open2);
|
|
44
|
+
if (open2) {
|
|
45
|
+
setCurrentId(id);
|
|
46
|
+
}
|
|
47
|
+
(_a = props.onOpenChange) == null ? void 0 : _a.call(props, open2);
|
|
48
|
+
}, [id, setCurrentId]);
|
|
49
|
+
const useFloatingFn = /* @__PURE__ */ __name((props2) => {
|
|
50
|
+
const floating = useFloating({
|
|
51
|
+
...props2,
|
|
52
|
+
open,
|
|
53
|
+
onOpenChange
|
|
54
|
+
});
|
|
55
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
56
|
+
useHover(floating.context, { delay, restMs }),
|
|
57
|
+
useFocus(floating.context),
|
|
58
|
+
useRole(floating.context, { role: "tooltip" }),
|
|
59
|
+
useDismiss(floating.context),
|
|
60
|
+
useDelayGroup(floating.context, { id })
|
|
61
|
+
]);
|
|
62
|
+
return {
|
|
63
|
+
...floating,
|
|
64
|
+
getReferenceProps,
|
|
65
|
+
getFloatingProps
|
|
66
|
+
};
|
|
67
|
+
}, "useFloatingFn");
|
|
68
|
+
const useFloatingContext = React.useCallback(useFloatingFn, [id, delay, open]);
|
|
69
|
+
const voidFn = React.useCallback(() => {
|
|
70
|
+
}, [setOpen]);
|
|
71
|
+
return <FloatingOverrideContext.Provider value={useFloatingContext}><Popper size="$2" {...popperScope} {...restProps}><__PopoverProviderInternal scope={__scopePopover} contentId={useId()} triggerRef={triggerRef} open={open} onOpenChange={setOpen} onOpenToggle={voidFn} hasCustomAnchor={hasCustomAnchor} onCustomAnchorAdd={React.useCallback(() => setHasCustomAnchor(true), [])} onCustomAnchorRemove={React.useCallback(() => setHasCustomAnchor(false), [])} modal>{children}</__PopoverProviderInternal></Popper></FloatingOverrideContext.Provider>;
|
|
72
|
+
}, {
|
|
73
|
+
Anchor: PopoverAnchor,
|
|
74
|
+
Arrow: PopoverArrow,
|
|
75
|
+
Close: PopoverClose,
|
|
76
|
+
Content: TooltipContent,
|
|
77
|
+
Trigger: PopoverTrigger
|
|
78
|
+
});
|
|
79
|
+
Tooltip.displayName = "Tooltip";
|
|
80
|
+
const TooltipSimple = /* @__PURE__ */ __name(({
|
|
81
|
+
label,
|
|
82
|
+
children,
|
|
83
|
+
contentProps,
|
|
84
|
+
...tooltipProps
|
|
85
|
+
}) => {
|
|
86
|
+
return <TooltipGroup delay={{ open: 3e3, close: 100 }}><Tooltip {...tooltipProps}>
|
|
87
|
+
<Tooltip.Trigger>{children}</Tooltip.Trigger>
|
|
88
|
+
<Tooltip.Content enterStyle={{ x: 0, y: -10, opacity: 0, scale: 0.9 }} exitStyle={{ x: 0, y: -10, opacity: 0, scale: 0.9 }} x={0} scale={1} y={0} elevation="$1" opacity={1} animation={[
|
|
89
|
+
"bouncy",
|
|
90
|
+
{
|
|
91
|
+
opacity: {
|
|
92
|
+
overshootClamping: true
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
]} {...contentProps}>
|
|
96
|
+
<Tooltip.Arrow />
|
|
97
|
+
<Paragraph>{label}</Paragraph>
|
|
98
|
+
</Tooltip.Content>
|
|
99
|
+
</Tooltip></TooltipGroup>;
|
|
100
|
+
}, "TooltipSimple");
|
|
101
|
+
export {
|
|
102
|
+
Tooltip,
|
|
103
|
+
TooltipGroup,
|
|
104
|
+
TooltipSimple
|
|
105
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Tooltip";
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tamagui/tooltip",
|
|
3
|
+
"version": "1.0.0-beta.6",
|
|
4
|
+
"sideEffects": true,
|
|
5
|
+
"source": "src/index.ts",
|
|
6
|
+
"typings": "types",
|
|
7
|
+
"main": "dist/cjs",
|
|
8
|
+
"module": "dist/esm",
|
|
9
|
+
"module:jsx": "dist/jsx",
|
|
10
|
+
"files": [
|
|
11
|
+
"types",
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tamagui-build",
|
|
16
|
+
"watch": "tamagui-build --watch",
|
|
17
|
+
"clean": "tamagui-build clean",
|
|
18
|
+
"clean:build": "tamagui-build clean:build"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@floating-ui/react-dom-interactions": "^0.4.0",
|
|
22
|
+
"@tamagui/compose-refs": "^1.0.0-beta.6",
|
|
23
|
+
"@tamagui/core": "^1.0.0-beta.6",
|
|
24
|
+
"@tamagui/create-context": "^1.0.0-beta.6",
|
|
25
|
+
"@tamagui/polyfill-dev": "^1.0.0-beta.6",
|
|
26
|
+
"@tamagui/popover": "^1.0.0-beta.6",
|
|
27
|
+
"@tamagui/popper": "^1.0.0-beta.6",
|
|
28
|
+
"@tamagui/stacks": "^1.0.0-beta.6",
|
|
29
|
+
"@tamagui/text": "^1.0.0-beta.6",
|
|
30
|
+
"@tamagui/use-controllable-state": "^1.0.0-beta.6"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"react": "*",
|
|
34
|
+
"react-dom": "*",
|
|
35
|
+
"react-native": "*"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@tamagui/build": "^1.0.0-beta.6",
|
|
39
|
+
"@types/react-dom": "^18.0.3",
|
|
40
|
+
"@types/react-native": "^0.67.3",
|
|
41
|
+
"react": "*",
|
|
42
|
+
"react-dom": "*",
|
|
43
|
+
"react-native": "*"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import '@tamagui/polyfill-dev';
|
|
2
|
+
import { PopperProps } from '@tamagui/popper';
|
|
3
|
+
import { SizableStackProps } from '@tamagui/stacks';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
export declare type TooltipProps = PopperProps & {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
onOpenChange?: (open: boolean) => void;
|
|
8
|
+
groupId?: string;
|
|
9
|
+
restMs?: number;
|
|
10
|
+
delay?: number | {
|
|
11
|
+
open?: number;
|
|
12
|
+
close?: number;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare const TooltipGroup: ({ children, delay, }: {
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
delay: number | Partial<{
|
|
18
|
+
open: number;
|
|
19
|
+
close: number;
|
|
20
|
+
}>;
|
|
21
|
+
}) => JSX.Element;
|
|
22
|
+
export declare const Tooltip: React.FC<TooltipProps> & {
|
|
23
|
+
Anchor: React.ForwardRefExoticComponent<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{}, "elevation" | "fullscreen"> & {
|
|
24
|
+
fullscreen?: boolean | undefined;
|
|
25
|
+
elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
26
|
+
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{}, "elevation" | "fullscreen"> & {
|
|
27
|
+
fullscreen?: boolean | undefined;
|
|
28
|
+
elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
29
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{}, "elevation" | "fullscreen"> & {
|
|
30
|
+
fullscreen?: boolean | undefined;
|
|
31
|
+
elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
32
|
+
}>> & React.RefAttributes<HTMLElement | import("react-native").View>>;
|
|
33
|
+
Arrow: React.ForwardRefExoticComponent<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{}, "elevation" | "fullscreen"> & {
|
|
34
|
+
fullscreen?: boolean | undefined;
|
|
35
|
+
elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
36
|
+
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{}, "elevation" | "fullscreen"> & {
|
|
37
|
+
fullscreen?: boolean | undefined;
|
|
38
|
+
elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
39
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{}, "elevation" | "fullscreen"> & {
|
|
40
|
+
fullscreen?: boolean | undefined;
|
|
41
|
+
elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
42
|
+
}>> & React.RefAttributes<HTMLElement | import("react-native").View>>;
|
|
43
|
+
Close: React.ForwardRefExoticComponent<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{}, "elevation" | "fullscreen"> & {
|
|
44
|
+
fullscreen?: boolean | undefined;
|
|
45
|
+
elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
46
|
+
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{}, "elevation" | "fullscreen"> & {
|
|
47
|
+
fullscreen?: boolean | undefined;
|
|
48
|
+
elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
49
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{}, "elevation" | "fullscreen"> & {
|
|
50
|
+
fullscreen?: boolean | undefined;
|
|
51
|
+
elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
52
|
+
}>> & React.RefAttributes<HTMLElement | import("react-native").View>>;
|
|
53
|
+
Content: React.ForwardRefExoticComponent<import("@tamagui/popover").PopoverContentTypeProps & React.RefAttributes<unknown>>;
|
|
54
|
+
Trigger: React.ForwardRefExoticComponent<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{}, "elevation" | "fullscreen"> & {
|
|
55
|
+
fullscreen?: boolean | undefined;
|
|
56
|
+
elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
57
|
+
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{}, "elevation" | "fullscreen"> & {
|
|
58
|
+
fullscreen?: boolean | undefined;
|
|
59
|
+
elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
60
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{}, "elevation" | "fullscreen"> & {
|
|
61
|
+
fullscreen?: boolean | undefined;
|
|
62
|
+
elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
63
|
+
}>> & React.RefAttributes<HTMLElement | import("react-native").View>>;
|
|
64
|
+
};
|
|
65
|
+
export declare type TooltipSimpleProps = TooltipProps & {
|
|
66
|
+
label?: React.ReactNode;
|
|
67
|
+
children?: React.ReactNode;
|
|
68
|
+
contentProps?: SizableStackProps;
|
|
69
|
+
};
|
|
70
|
+
export declare const TooltipSimple: React.FC<TooltipSimpleProps>;
|
|
71
|
+
//# sourceMappingURL=Tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../src/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAA;AAyB9B,OAAO,EAAmC,WAAW,EAAiB,MAAM,iBAAiB,CAAA;AAC7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAEnD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,oBAAY,YAAY,GAAG,WAAW,GAAG;IACvC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACtC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EACF,MAAM,GACN;QACE,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;CACN,CAAA;AAED,eAAO,MAAM,YAAY;;;;;;iBAAqB,CAAA;AAE9C,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2EnB,CAAA;AAID,oBAAY,kBAAkB,GAAG,YAAY,GAAG;IAC9C,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,YAAY,CAAC,EAAE,iBAAiB,CAAA;CACjC,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAkCtD,CAAA"}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
|