@tamagui/tooltip 1.114.4 → 1.115.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.
@@ -0,0 +1,228 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
32
+ var Tooltip_exports = {};
33
+ __export(Tooltip_exports, {
34
+ Tooltip: () => Tooltip2,
35
+ TooltipGroup: () => TooltipGroup
36
+ });
37
+ module.exports = __toCommonJS(Tooltip_exports);
38
+ var import_polyfill_dev = require("@tamagui/polyfill-dev"),
39
+ import_react = require("@floating-ui/react"),
40
+ import_core = require("@tamagui/core"),
41
+ import_floating = require("@tamagui/floating"),
42
+ import_get_token = require("@tamagui/get-token"),
43
+ import_helpers = require("@tamagui/helpers"),
44
+ import_popover = require("@tamagui/popover"),
45
+ import_popper = require("@tamagui/popper"),
46
+ import_use_controllable_state = require("@tamagui/use-controllable-state"),
47
+ React = __toESM(require("react")),
48
+ import_jsx_runtime = require("react/jsx-runtime");
49
+ const TOOLTIP_SCOPE = "tooltip",
50
+ TooltipContent = import_popper.PopperContentFrame.extractable(React.forwardRef(({
51
+ __scopeTooltip,
52
+ ...props
53
+ }, ref) => {
54
+ const preventAnimation = React.useContext(PreventTooltipAnimationContext),
55
+ popper = (0, import_popper.usePopperContext)(__scopeTooltip || TOOLTIP_SCOPE),
56
+ padding = props.unstyled ? void 0 : props.padding ?? props.size ?? popper.size ?? (0, import_get_token.getSize)("$true", {
57
+ shift: -2
58
+ });
59
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_popover.PopoverContent, {
60
+ __scopePopover: __scopeTooltip || TOOLTIP_SCOPE,
61
+ componentName: "Tooltip",
62
+ disableRemoveScroll: !0,
63
+ disableFocusScope: !0,
64
+ ...(!props.unstyled && {
65
+ padding
66
+ }),
67
+ ref,
68
+ ...props,
69
+ ...(preventAnimation && {
70
+ animation: null
71
+ })
72
+ });
73
+ })),
74
+ TooltipArrow = React.forwardRef((props, ref) => {
75
+ const {
76
+ __scopeTooltip,
77
+ ...rest
78
+ } = props;
79
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_popover.PopoverArrow, {
80
+ __scopePopper: __scopeTooltip || TOOLTIP_SCOPE,
81
+ componentName: "Tooltip",
82
+ ref,
83
+ ...rest
84
+ });
85
+ }),
86
+ PreventTooltipAnimationContext = React.createContext(!1),
87
+ TooltipGroup = ({
88
+ children,
89
+ delay,
90
+ preventAnimation = !1,
91
+ timeoutMs
92
+ }) => /* @__PURE__ */(0, import_jsx_runtime.jsx)(PreventTooltipAnimationContext.Provider, {
93
+ value: preventAnimation,
94
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react.FloatingDelayGroup, {
95
+ timeoutMs,
96
+ delay: React.useMemo(() => delay, [JSON.stringify(delay)]),
97
+ children
98
+ })
99
+ }),
100
+ TooltipComponent = React.forwardRef(function (props, ref) {
101
+ const {
102
+ children,
103
+ delay: delayProp,
104
+ restMs = typeof delayProp > "u" ? 500 : typeof delayProp == "number" ? delayProp : 0,
105
+ onOpenChange: onOpenChangeProp,
106
+ focus,
107
+ open: openProp,
108
+ disableAutoCloseOnScroll,
109
+ __scopeTooltip,
110
+ ...restProps
111
+ } = props,
112
+ triggerRef = React.useRef(null),
113
+ [hasCustomAnchor, setHasCustomAnchor] = React.useState(!1),
114
+ {
115
+ delay: delayGroup,
116
+ setCurrentId
117
+ } = (0, import_react.useDelayGroupContext)(),
118
+ delay = delayProp ?? delayGroup,
119
+ [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
120
+ prop: openProp,
121
+ defaultProp: !1,
122
+ onChange: onOpenChangeProp
123
+ }),
124
+ id = props.groupId,
125
+ onOpenChange = (0, import_core.useEvent)(open2 => {
126
+ open2 && setCurrentId(id), setOpen(open2);
127
+ });
128
+ React.useEffect(() => {
129
+ if (!open || disableAutoCloseOnScroll || typeof document > "u") return;
130
+ const openIt = () => {
131
+ setOpen(!1);
132
+ };
133
+ return document.documentElement.addEventListener("scroll", openIt), () => {
134
+ document.documentElement.removeEventListener("scroll", openIt);
135
+ };
136
+ }, [open, disableAutoCloseOnScroll]);
137
+ const useFloatingFn = props2 => {
138
+ const floating = (0, import_react.useFloating)({
139
+ ...props2,
140
+ open,
141
+ onOpenChange
142
+ }),
143
+ {
144
+ delay: delayContext
145
+ } = (0, import_react.useDelayGroup)(floating.context, {
146
+ id
147
+ }),
148
+ {
149
+ getReferenceProps,
150
+ getFloatingProps
151
+ } = (0, import_react.useInteractions)([(0, import_react.useHover)(floating.context, {
152
+ delay: delay ?? delayContext,
153
+ restMs
154
+ }), (0, import_react.useFocus)(floating.context, focus), (0, import_react.useRole)(floating.context, {
155
+ role: "tooltip"
156
+ }), (0, import_react.useDismiss)(floating.context)]);
157
+ return {
158
+ ...floating,
159
+ open,
160
+ getReferenceProps,
161
+ getFloatingProps
162
+ };
163
+ },
164
+ useFloatingContext = React.useCallback(useFloatingFn, [id, delay, open, restMs, focus ? JSON.stringify(focus) : 0]),
165
+ onCustomAnchorAdd = React.useCallback(() => setHasCustomAnchor(!0), []),
166
+ onCustomAnchorRemove = React.useCallback(() => setHasCustomAnchor(!1), []),
167
+ contentId = React.useId(),
168
+ smallerSize = props.unstyled ? null : (0, import_get_token.getSize)("$true", {
169
+ shift: -2,
170
+ bounds: [0]
171
+ });
172
+ return (
173
+ // TODO: FloatingOverrideContext might also need to be scoped
174
+ /* @__PURE__ */
175
+ (0, import_jsx_runtime.jsx)(import_floating.FloatingOverrideContext.Provider, {
176
+ value: useFloatingContext,
177
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_popper.Popper, {
178
+ __scopePopper: __scopeTooltip || TOOLTIP_SCOPE,
179
+ size: smallerSize?.key,
180
+ allowFlip: !0,
181
+ stayInFrame: !0,
182
+ ...restProps,
183
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_popover.PopoverContext.Provider, {
184
+ contentId,
185
+ triggerRef,
186
+ sheetBreakpoint: !1,
187
+ open,
188
+ scope: __scopeTooltip || TOOLTIP_SCOPE,
189
+ onOpenChange: setOpen,
190
+ onOpenToggle: voidFn,
191
+ hasCustomAnchor,
192
+ onCustomAnchorAdd,
193
+ onCustomAnchorRemove,
194
+ children
195
+ })
196
+ })
197
+ })
198
+ );
199
+ }),
200
+ TooltipTrigger = React.forwardRef(function (props, ref) {
201
+ const {
202
+ __scopeTooltip,
203
+ ...rest
204
+ } = props;
205
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_popover.PopoverTrigger, {
206
+ ...rest,
207
+ __scopePopover: __scopeTooltip || TOOLTIP_SCOPE,
208
+ ref
209
+ });
210
+ }),
211
+ TooltipAnchor = React.forwardRef(function (props, ref) {
212
+ const {
213
+ __scopeTooltip,
214
+ ...rest
215
+ } = props;
216
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_popover.PopoverAnchor, {
217
+ ...rest,
218
+ __scopePopover: __scopeTooltip || TOOLTIP_SCOPE,
219
+ ref
220
+ });
221
+ }),
222
+ Tooltip2 = (0, import_helpers.withStaticProperties)(TooltipComponent, {
223
+ Anchor: TooltipAnchor,
224
+ Arrow: TooltipArrow,
225
+ Content: TooltipContent,
226
+ Trigger: TooltipTrigger
227
+ }),
228
+ voidFn = () => {};
@@ -0,0 +1,35 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var Tooltip_native_exports = {};
22
+ __export(Tooltip_native_exports, {
23
+ Tooltip: () => Tooltip
24
+ });
25
+ module.exports = __toCommonJS(Tooltip_native_exports);
26
+ var import_helpers = require("@tamagui/helpers");
27
+ const RenderChildren = props => props.children,
28
+ RenderNull = props => null,
29
+ Tooltip = (0, import_helpers.withStaticProperties)(RenderChildren, {
30
+ Anchor: RenderChildren,
31
+ Arrow: RenderNull,
32
+ Close: RenderNull,
33
+ Content: RenderNull,
34
+ Trigger: RenderChildren
35
+ });
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Tooltip.native.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAqC;AAKrC,MAAM,iBAAiB,CAAC,UACf,MAAM,UAGT,aAAa,CAAC,UACX,MAGI,cAAU,qCAAqB,gBAAgB;AAAA,EAC1D,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AACX,CAAC;",
5
+ "names": []
6
+ }
@@ -0,0 +1,102 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
32
+ var TooltipSimple_exports = {};
33
+ __export(TooltipSimple_exports, {
34
+ TooltipSimple: () => TooltipSimple
35
+ });
36
+ module.exports = __toCommonJS(TooltipSimple_exports);
37
+ var import_get_token = require("@tamagui/get-token"),
38
+ import_text = require("@tamagui/text"),
39
+ React = __toESM(require("react")),
40
+ import_Tooltip = require("./Tooltip.cjs"),
41
+ import_jsx_runtime = require("react/jsx-runtime");
42
+ const TooltipSimple = React.forwardRef(({
43
+ label,
44
+ children,
45
+ contentProps,
46
+ disabled,
47
+ ...tooltipProps
48
+ }, ref) => {
49
+ const child = React.Children.only(children);
50
+ return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_Tooltip.Tooltip, {
51
+ disableRTL: !0,
52
+ offset: 15,
53
+ restMs: 40,
54
+ delay: 40,
55
+ ...tooltipProps,
56
+ ...(disabled ? {
57
+ open: !1
58
+ } : null),
59
+ children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_Tooltip.Tooltip.Trigger, {
60
+ ...(typeof label == "string" && {
61
+ "aria-label": label
62
+ }),
63
+ asChild: "except-style",
64
+ children: ref && React.isValidElement(child) ? React.cloneElement(child, {
65
+ ref
66
+ }) : child
67
+ }), /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_Tooltip.Tooltip.Content, {
68
+ zIndex: 1e9,
69
+ enterStyle: {
70
+ x: 0,
71
+ y: -4,
72
+ opacity: 0,
73
+ scale: 0.96
74
+ },
75
+ exitStyle: {
76
+ x: 0,
77
+ y: -4,
78
+ opacity: 0,
79
+ scale: 0.96
80
+ },
81
+ x: 0,
82
+ scale: 1,
83
+ y: 0,
84
+ elevation: "$0.5",
85
+ opacity: 1,
86
+ paddingVertical: (0, import_get_token.getSpace)(tooltipProps.size || "$true", {
87
+ shift: -4
88
+ }),
89
+ animateOnly: ["transform", "opacity"],
90
+ animation: ["quicker", {
91
+ opacity: {
92
+ overshootClamping: !0
93
+ }
94
+ }],
95
+ ...contentProps,
96
+ children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_Tooltip.Tooltip.Arrow, {}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_text.Paragraph, {
97
+ size: "$3",
98
+ children: label
99
+ })]
100
+ })]
101
+ });
102
+ });
@@ -0,0 +1,27 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var TooltipSimple_native_exports = {};
22
+ __export(TooltipSimple_native_exports, {
23
+ TooltipSimple: () => TooltipSimple
24
+ });
25
+ module.exports = __toCommonJS(TooltipSimple_native_exports);
26
+ const RenderChildren = props => props.children,
27
+ TooltipSimple = RenderChildren;
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/TooltipSimple.native.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,iBAAiB,CAAC,UACf,MAAM,UAGF,gBAAgB;",
5
+ "names": []
6
+ }
@@ -0,0 +1,19 @@
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") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
+ get: () => from[key],
8
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
+ });
10
+ return to;
11
+ },
12
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
14
+ value: !0
15
+ }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ __reExport(src_exports, require("./Tooltip.cjs"), module.exports);
19
+ __reExport(src_exports, require("./TooltipSimple.cjs"), module.exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/tooltip",
3
- "version": "1.114.4",
3
+ "version": "1.115.1",
4
4
  "sideEffects": [
5
5
  "*.css"
6
6
  ],
@@ -29,29 +29,30 @@
29
29
  "react-native": "./dist/cjs/index.native.js",
30
30
  "types": "./types/index.d.ts",
31
31
  "import": "./dist/esm/index.mjs",
32
- "require": "./dist/cjs/index.js"
32
+ "require": "./dist/cjs/index.cjs",
33
+ "default": "./dist/cjs/index.native.js"
33
34
  }
34
35
  },
35
36
  "dependencies": {
36
37
  "@floating-ui/react": "^0.26.24",
37
- "@tamagui/compose-refs": "1.114.4",
38
- "@tamagui/core": "1.114.4",
39
- "@tamagui/create-context": "1.114.4",
40
- "@tamagui/floating": "1.114.4",
41
- "@tamagui/get-token": "1.114.4",
42
- "@tamagui/helpers": "1.114.4",
43
- "@tamagui/polyfill-dev": "1.114.4",
44
- "@tamagui/popover": "1.114.4",
45
- "@tamagui/popper": "1.114.4",
46
- "@tamagui/stacks": "1.114.4",
47
- "@tamagui/text": "1.114.4",
48
- "@tamagui/use-controllable-state": "1.114.4"
38
+ "@tamagui/compose-refs": "1.115.1",
39
+ "@tamagui/core": "1.115.1",
40
+ "@tamagui/create-context": "1.115.1",
41
+ "@tamagui/floating": "1.115.1",
42
+ "@tamagui/get-token": "1.115.1",
43
+ "@tamagui/helpers": "1.115.1",
44
+ "@tamagui/polyfill-dev": "1.115.1",
45
+ "@tamagui/popover": "1.115.1",
46
+ "@tamagui/popper": "1.115.1",
47
+ "@tamagui/stacks": "1.115.1",
48
+ "@tamagui/text": "1.115.1",
49
+ "@tamagui/use-controllable-state": "1.115.1"
49
50
  },
50
51
  "peerDependencies": {
51
52
  "react": "*"
52
53
  },
53
54
  "devDependencies": {
54
- "@tamagui/build": "1.114.4",
55
+ "@tamagui/build": "1.115.1",
55
56
  "react": "^18.2.0 || ^19.0.0",
56
57
  "react-native": "0.74.1"
57
58
  },
@@ -1,183 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var Tooltip_exports = {};
24
- __export(Tooltip_exports, {
25
- Tooltip: () => Tooltip2,
26
- TooltipGroup: () => TooltipGroup
27
- });
28
- module.exports = __toCommonJS(Tooltip_exports);
29
- var import_polyfill_dev = require("@tamagui/polyfill-dev"), import_react = require("@floating-ui/react"), import_core = require("@tamagui/core"), import_floating = require("@tamagui/floating"), import_get_token = require("@tamagui/get-token"), import_helpers = require("@tamagui/helpers"), import_popover = require("@tamagui/popover"), import_popper = require("@tamagui/popper"), import_use_controllable_state = require("@tamagui/use-controllable-state"), React = __toESM(require("react")), import_jsx_runtime = require("react/jsx-runtime");
30
- const TOOLTIP_SCOPE = "tooltip", TooltipContent = import_popper.PopperContentFrame.extractable(
31
- React.forwardRef(
32
- ({ __scopeTooltip, ...props }, ref) => {
33
- const preventAnimation = React.useContext(PreventTooltipAnimationContext), popper = (0, import_popper.usePopperContext)(__scopeTooltip || TOOLTIP_SCOPE), padding = props.unstyled ? void 0 : props.padding ?? props.size ?? popper.size ?? (0, import_get_token.getSize)("$true", {
34
- shift: -2
35
- });
36
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
37
- import_popover.PopoverContent,
38
- {
39
- __scopePopover: __scopeTooltip || TOOLTIP_SCOPE,
40
- componentName: "Tooltip",
41
- disableRemoveScroll: !0,
42
- disableFocusScope: !0,
43
- ...!props.unstyled && {
44
- padding
45
- },
46
- ref,
47
- ...props,
48
- ...preventAnimation && {
49
- animation: null
50
- }
51
- }
52
- );
53
- }
54
- )
55
- ), TooltipArrow = React.forwardRef(
56
- (props, ref) => {
57
- const { __scopeTooltip, ...rest } = props;
58
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
59
- import_popover.PopoverArrow,
60
- {
61
- __scopePopper: __scopeTooltip || TOOLTIP_SCOPE,
62
- componentName: "Tooltip",
63
- ref,
64
- ...rest
65
- }
66
- );
67
- }
68
- ), PreventTooltipAnimationContext = React.createContext(!1), TooltipGroup = ({
69
- children,
70
- delay,
71
- preventAnimation = !1,
72
- timeoutMs
73
- }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PreventTooltipAnimationContext.Provider, { value: preventAnimation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
74
- import_react.FloatingDelayGroup,
75
- {
76
- timeoutMs,
77
- delay: React.useMemo(() => delay, [JSON.stringify(delay)]),
78
- children
79
- }
80
- ) }), TooltipComponent = React.forwardRef(function(props, ref) {
81
- const {
82
- children,
83
- delay: delayProp,
84
- restMs = typeof delayProp > "u" ? 500 : typeof delayProp == "number" ? delayProp : 0,
85
- onOpenChange: onOpenChangeProp,
86
- focus,
87
- open: openProp,
88
- disableAutoCloseOnScroll,
89
- __scopeTooltip,
90
- ...restProps
91
- } = props, triggerRef = React.useRef(null), [hasCustomAnchor, setHasCustomAnchor] = React.useState(!1), { delay: delayGroup, setCurrentId } = (0, import_react.useDelayGroupContext)(), delay = delayProp ?? delayGroup, [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
92
- prop: openProp,
93
- defaultProp: !1,
94
- onChange: onOpenChangeProp
95
- }), id = props.groupId, onOpenChange = (0, import_core.useEvent)((open2) => {
96
- open2 && setCurrentId(id), setOpen(open2);
97
- });
98
- React.useEffect(() => {
99
- if (!open || disableAutoCloseOnScroll || typeof document > "u") return;
100
- const openIt = () => {
101
- setOpen(!1);
102
- };
103
- return document.documentElement.addEventListener("scroll", openIt), () => {
104
- document.documentElement.removeEventListener("scroll", openIt);
105
- };
106
- }, [open, disableAutoCloseOnScroll]);
107
- const useFloatingFn = (props2) => {
108
- const floating = (0, import_react.useFloating)({
109
- ...props2,
110
- open,
111
- onOpenChange
112
- }), { delay: delayContext } = (0, import_react.useDelayGroup)(floating.context, { id }), { getReferenceProps, getFloatingProps } = (0, import_react.useInteractions)([
113
- (0, import_react.useHover)(floating.context, { delay: delay ?? delayContext, restMs }),
114
- (0, import_react.useFocus)(floating.context, focus),
115
- (0, import_react.useRole)(floating.context, { role: "tooltip" }),
116
- (0, import_react.useDismiss)(floating.context)
117
- ]);
118
- return {
119
- ...floating,
120
- open,
121
- getReferenceProps,
122
- getFloatingProps
123
- };
124
- }, useFloatingContext = React.useCallback(useFloatingFn, [
125
- id,
126
- delay,
127
- open,
128
- restMs,
129
- focus ? JSON.stringify(focus) : 0
130
- ]), onCustomAnchorAdd = React.useCallback(() => setHasCustomAnchor(!0), []), onCustomAnchorRemove = React.useCallback(() => setHasCustomAnchor(!1), []), contentId = React.useId(), smallerSize = props.unstyled ? null : (0, import_get_token.getSize)("$true", {
131
- shift: -2,
132
- bounds: [0]
133
- });
134
- return (
135
- // TODO: FloatingOverrideContext might also need to be scoped
136
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_floating.FloatingOverrideContext.Provider, { value: useFloatingContext, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
137
- import_popper.Popper,
138
- {
139
- __scopePopper: __scopeTooltip || TOOLTIP_SCOPE,
140
- size: smallerSize?.key,
141
- allowFlip: !0,
142
- stayInFrame: !0,
143
- ...restProps,
144
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
145
- import_popover.PopoverContext.Provider,
146
- {
147
- contentId,
148
- triggerRef,
149
- sheetBreakpoint: !1,
150
- open,
151
- scope: __scopeTooltip || TOOLTIP_SCOPE,
152
- onOpenChange: setOpen,
153
- onOpenToggle: voidFn,
154
- hasCustomAnchor,
155
- onCustomAnchorAdd,
156
- onCustomAnchorRemove,
157
- children
158
- }
159
- )
160
- }
161
- ) })
162
- );
163
- }), TooltipTrigger = React.forwardRef(function(props, ref) {
164
- const { __scopeTooltip, ...rest } = props;
165
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
166
- import_popover.PopoverTrigger,
167
- {
168
- ...rest,
169
- __scopePopover: __scopeTooltip || TOOLTIP_SCOPE,
170
- ref
171
- }
172
- );
173
- }), TooltipAnchor = React.forwardRef(function(props, ref) {
174
- const { __scopeTooltip, ...rest } = props;
175
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popover.PopoverAnchor, { ...rest, __scopePopover: __scopeTooltip || TOOLTIP_SCOPE, ref });
176
- }), Tooltip2 = (0, import_helpers.withStaticProperties)(TooltipComponent, {
177
- Anchor: TooltipAnchor,
178
- Arrow: TooltipArrow,
179
- Content: TooltipContent,
180
- Trigger: TooltipTrigger
181
- }), voidFn = () => {
182
- };
183
- //# sourceMappingURL=Tooltip.js.map
@@ -1,87 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var TooltipSimple_exports = {};
24
- __export(TooltipSimple_exports, {
25
- TooltipSimple: () => TooltipSimple
26
- });
27
- module.exports = __toCommonJS(TooltipSimple_exports);
28
- var import_get_token = require("@tamagui/get-token"), import_text = require("@tamagui/text"), React = __toESM(require("react")), import_Tooltip = require("./Tooltip"), import_jsx_runtime = require("react/jsx-runtime");
29
- const TooltipSimple = React.forwardRef(
30
- ({ label, children, contentProps, disabled, ...tooltipProps }, ref) => {
31
- const child = React.Children.only(children);
32
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
33
- import_Tooltip.Tooltip,
34
- {
35
- disableRTL: !0,
36
- offset: 15,
37
- restMs: 40,
38
- delay: 40,
39
- ...tooltipProps,
40
- ...disabled ? { open: !1 } : null,
41
- children: [
42
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
43
- import_Tooltip.Tooltip.Trigger,
44
- {
45
- ...typeof label == "string" && {
46
- "aria-label": label
47
- },
48
- asChild: "except-style",
49
- children: ref && React.isValidElement(child) ? React.cloneElement(child, { ref }) : child
50
- }
51
- ),
52
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
53
- import_Tooltip.Tooltip.Content,
54
- {
55
- zIndex: 1e9,
56
- enterStyle: { x: 0, y: -4, opacity: 0, scale: 0.96 },
57
- exitStyle: { x: 0, y: -4, opacity: 0, scale: 0.96 },
58
- x: 0,
59
- scale: 1,
60
- y: 0,
61
- elevation: "$0.5",
62
- opacity: 1,
63
- paddingVertical: (0, import_get_token.getSpace)(tooltipProps.size || "$true", {
64
- shift: -4
65
- }),
66
- animateOnly: ["transform", "opacity"],
67
- animation: [
68
- "quicker",
69
- {
70
- opacity: {
71
- overshootClamping: !0
72
- }
73
- }
74
- ],
75
- ...contentProps,
76
- children: [
77
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Tooltip.Tooltip.Arrow, {}),
78
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_text.Paragraph, { size: "$3", children: label })
79
- ]
80
- }
81
- )
82
- ]
83
- }
84
- );
85
- }
86
- );
87
- //# sourceMappingURL=TooltipSimple.js.map
package/dist/cjs/index.js DELETED
@@ -1,16 +0,0 @@
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
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
- return to;
10
- }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
- var src_exports = {};
13
- module.exports = __toCommonJS(src_exports);
14
- __reExport(src_exports, require("./Tooltip"), module.exports);
15
- __reExport(src_exports, require("./TooltipSimple"), module.exports);
16
- //# sourceMappingURL=index.js.map
File without changes
File without changes