@multiplatform.one/components 0.7.4 → 0.7.9
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/panels/SimplePopover/SimplePopover.stories.js +5 -38
- package/dist/cjs/panels/SimplePopover/SimplePopover.stories.js.map +1 -1
- package/dist/cjs/panels/SimplePopover/SimplePopover.stories.native.js +6 -38
- package/dist/cjs/panels/SimplePopover/SimplePopover.stories.native.js.map +1 -1
- package/dist/cjs/panels/SimplePopover/index.js +14 -23
- package/dist/cjs/panels/SimplePopover/index.js.map +2 -2
- package/dist/cjs/panels/SimplePopover/index.native.js +15 -23
- package/dist/cjs/panels/SimplePopover/index.native.js.map +2 -2
- package/dist/esm/panels/SimplePopover/SimplePopover.stories.js +6 -38
- package/dist/esm/panels/SimplePopover/SimplePopover.stories.js.map +1 -1
- package/dist/esm/panels/SimplePopover/SimplePopover.stories.native.js +7 -38
- package/dist/esm/panels/SimplePopover/SimplePopover.stories.native.js.map +1 -1
- package/dist/esm/panels/SimplePopover/index.js +13 -22
- package/dist/esm/panels/SimplePopover/index.js.map +1 -1
- package/dist/esm/panels/SimplePopover/index.native.js +14 -22
- package/dist/esm/panels/SimplePopover/index.native.js.map +1 -1
- package/dist/jsx/panels/SimplePopover/SimplePopover.stories.js +6 -21
- package/dist/jsx/panels/SimplePopover/SimplePopover.stories.js.map +1 -1
- package/dist/jsx/panels/SimplePopover/SimplePopover.stories.native.js +6 -21
- package/dist/jsx/panels/SimplePopover/SimplePopover.stories.native.js.map +1 -1
- package/dist/jsx/panels/SimplePopover/index.js +13 -19
- package/dist/jsx/panels/SimplePopover/index.js.map +1 -1
- package/dist/jsx/panels/SimplePopover/index.native.js +13 -19
- package/dist/jsx/panels/SimplePopover/index.native.js.map +1 -1
- package/package.json +2 -2
- package/src/panels/SimplePopover/SimplePopover.stories.tsx +6 -44
- package/src/panels/SimplePopover/index.tsx +26 -59
- package/types/panels/SimplePopover/SimplePopover.stories.d.ts +0 -1
- package/types/panels/SimplePopover/SimplePopover.stories.d.ts.map +1 -1
- package/types/panels/SimplePopover/index.d.ts +6 -13
- package/types/panels/SimplePopover/index.d.ts.map +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/panels/SimplePopover/index.tsx"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": "AAsBA,SAAS,OAAO,eAAe;AAC/B,OAAO,WAAW;AA4CZ,cAIE,YAJF;AA7BC,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAuB;AACrB,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,EAAK;AAE5C,WAAS,cAAc,GAAG;AACxB,IAAK,mBACL,QAAQ,EAAI,GACR,cAAc,aAAW,cAAc,UAAU,CAAC,GAClD,cAAc,aAAW,aAAa,UAAU,CAAC;AAAA,EACvD;AAEA,WAAS,eAAe,GAAG;AACzB,IAAK,oBACL,QAAQ,EAAK,GACT,cAAc,cAAY,aAAa,WAAW,CAAC,GACnD,cAAc,cAAY,aAAa,WAAW,CAAC;AAAA,EACzD;AAEA,SACE,qBAAC,WAAQ,MAAK,MAAK,WAAS,IAAC,MAAY,cAAc,SAAU,GAAG,OAClE;AAAA,wBAAC,QAAQ,SAAR,EAAgB,SAAO,IAAE,GAAG,cAAc,WAAW,eAAe,YAAY,gBAC9E,mBACH;AAAA,IACA,oBAAC,SAAM,MAAK,MAAK,UAAS,SACxB,+BAAC,QAAQ,OAAR,EAAc,OAAK,IAAC,uBAAqB,IACxC;AAAA,0BAAC,QAAQ,MAAM,OAAd,EAAoB,SAAQ,MAAK,cAAc,MAAM,QAAQ,EAAI,GAChE,8BAAC,MAAM,UAAN,EAAe,GAClB;AAAA,MACA,oBAAC,QAAQ,MAAM,SAAd,EAAsB;AAAA,OACzB,GACF;AAAA,IACA;AAAA,MAAC,QAAQ;AAAA,MAAR;AAAA,QACC,aAAa;AAAA,QACb,aAAY;AAAA,QACZ,YAAY,EAAE,GAAG,GAAG,GAAG,KAAK,SAAS,EAAE;AAAA,QACvC,WAAY,iBAAgD,SAA/B,EAAE,GAAG,GAAG,GAAG,KAAK,SAAS,EAAE;AAAA,QACxD,GAAG;AAAA,QACH,GAAG;AAAA,QACH,SAAS;AAAA,QACT,WACG,iBASG,SARA;AAAA,UACE;AAAA,UACA;AAAA,YACE,SAAS;AAAA,cACP,mBAAmB;AAAA,YACrB;AAAA,UACF;AAAA,QACF;AAAA,QAGN,SAAO;AAAA,QACP,IAAI;AAAA,QACH,GAAG;AAAA,QACJ,WAAW;AAAA,QACX,YAAY;AAAA,QAEX;AAAA,mBAAS,oBAAC,QAAQ,OAAR,EAAc,aAAa,GAAG,aAAY,gBAAgB,GAAG,YAAY;AAAA,UACnF;AAAA;AAAA;AAAA,IACH;AAAA,KACF;AAEJ;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
import { Adapt, Popover
|
|
1
|
+
import { Adapt, Popover } from "tamagui";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { YStack } from "tamagui";
|
|
4
|
-
const SimplePopoverTrigger = React.forwardRef((props, forwardedRef) => {
|
|
5
|
-
const context = usePopoverContext(), composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef), trigger = /* @__PURE__ */ React.createElement(
|
|
6
|
-
View,
|
|
7
|
-
{
|
|
8
|
-
"aria-haspopup": "dialog",
|
|
9
|
-
"aria-expanded": context.open,
|
|
10
|
-
"data-state": getState(context.open),
|
|
11
|
-
...props,
|
|
12
|
-
ref: composedTriggerRef
|
|
13
|
-
}
|
|
14
|
-
);
|
|
15
|
-
return context.hasCustomAnchor ? trigger : /* @__PURE__ */ React.createElement(PopperAnchor, { asChild: !0 }, trigger);
|
|
16
|
-
});
|
|
17
3
|
function SimplePopover({
|
|
18
4
|
children,
|
|
19
5
|
contentStyle,
|
|
@@ -22,10 +8,17 @@ function SimplePopover({
|
|
|
22
8
|
arrow = !0,
|
|
23
9
|
triggerOnHover,
|
|
24
10
|
closeOnHoverOut,
|
|
11
|
+
trigger,
|
|
25
12
|
...props
|
|
26
13
|
}) {
|
|
27
|
-
const [open, setOpen] = React.useState(!1)
|
|
28
|
-
|
|
14
|
+
const [open, setOpen] = React.useState(!1);
|
|
15
|
+
function handleHoverIn(e) {
|
|
16
|
+
triggerOnHover && (setOpen(!0), contentStyle?.onHoverIn && contentStyle?.onHoverIn(e), triggerStyle?.onHoverIn && triggerStyle.onHoverIn(e));
|
|
17
|
+
}
|
|
18
|
+
function handleHoverOut(e) {
|
|
19
|
+
closeOnHoverOut && (setOpen(!1), contentStyle?.onHoverOut && contentStyle.onHoverOut(e), triggerStyle?.onHoverOut && triggerStyle.onHoverOut(e));
|
|
20
|
+
}
|
|
21
|
+
return /* @__PURE__ */ React.createElement(Popover, { size: "$5", allowFlip: !0, open, onOpenChange: setOpen, ...props }, /* @__PURE__ */ React.createElement(Popover.Trigger, { asChild: !0, ...triggerStyle, onHoverIn: handleHoverIn, onHoverOut: handleHoverOut }, trigger), /* @__PURE__ */ React.createElement(Adapt, { when: "sm", platform: "touch" }, /* @__PURE__ */ React.createElement(Popover.Sheet, { modal: !0, dismissOnSnapToBottom: !0 }, /* @__PURE__ */ React.createElement(Popover.Sheet.Frame, { padding: "$4", onMouseEnter: () => setOpen(!0) }, /* @__PURE__ */ React.createElement(Adapt.Contents, null)), /* @__PURE__ */ React.createElement(Popover.Sheet.Overlay, null))), /* @__PURE__ */ React.createElement(
|
|
29
22
|
Popover.Content,
|
|
30
23
|
{
|
|
31
24
|
borderWidth: 1,
|
|
@@ -44,17 +37,16 @@ function SimplePopover({
|
|
|
44
37
|
}
|
|
45
38
|
],
|
|
46
39
|
elevate: !0,
|
|
47
|
-
onHoverIn: triggerOnHover ? () => setOpen(!0) : void 0,
|
|
48
|
-
onHoverOut: triggerOnHover || closeOnHoverOut ? () => setOpen(!1) : void 0,
|
|
49
40
|
zi: 9999999999,
|
|
50
|
-
...contentStyle
|
|
41
|
+
...contentStyle,
|
|
42
|
+
onHoverIn: handleHoverIn,
|
|
43
|
+
onHoverOut: handleHoverOut
|
|
51
44
|
},
|
|
52
45
|
arrow && /* @__PURE__ */ React.createElement(Popover.Arrow, { borderWidth: 1, borderColor: "$borderColor", ...arrowStyle }),
|
|
53
46
|
children
|
|
54
47
|
));
|
|
55
48
|
}
|
|
56
49
|
export {
|
|
57
|
-
SimplePopover
|
|
58
|
-
SimplePopoverTrigger
|
|
50
|
+
SimplePopover
|
|
59
51
|
};
|
|
60
52
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/panels/SimplePopover/index.tsx"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": "AAsBA,SAAS,OAAO,eAAe;AAC/B,OAAO,WAAW;AAeX,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAuB;AACrB,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,EAAK;AAE5C,WAAS,cAAc,GAAG;AACxB,IAAK,mBACL,QAAQ,EAAI,GACR,cAAc,aAAW,cAAc,UAAU,CAAC,GAClD,cAAc,aAAW,aAAa,UAAU,CAAC;AAAA,EACvD;AAEA,WAAS,eAAe,GAAG;AACzB,IAAK,oBACL,QAAQ,EAAK,GACT,cAAc,cAAY,aAAa,WAAW,CAAC,GACnD,cAAc,cAAY,aAAa,WAAW,CAAC;AAAA,EACzD;AAEA,SACE,oCAAC,WAAQ,MAAK,MAAK,WAAS,IAAC,MAAY,cAAc,SAAU,GAAG,SAClE,oCAAC,QAAQ,SAAR,EAAgB,SAAO,IAAE,GAAG,cAAc,WAAW,eAAe,YAAY,kBAC9E,OACH,GACA,oCAAC,SAAM,MAAK,MAAK,UAAS,WACxB,oCAAC,QAAQ,OAAR,EAAc,OAAK,IAAC,uBAAqB,MACxC,oCAAC,QAAQ,MAAM,OAAd,EAAoB,SAAQ,MAAK,cAAc,MAAM,QAAQ,EAAI,KAChE,oCAAC,MAAM,UAAN,IAAe,CAClB,GACA,oCAAC,QAAQ,MAAM,SAAd,IAAsB,CACzB,CACF,GACA;AAAA,IAAC,QAAQ;AAAA,IAAR;AAAA,MACC,aAAa;AAAA,MACb,aAAY;AAAA,MACZ,YAAY,EAAE,GAAG,GAAG,GAAG,KAAK,SAAS,EAAE;AAAA,MACvC,WAAY,iBAAgD,SAA/B,EAAE,GAAG,GAAG,GAAG,KAAK,SAAS,EAAE;AAAA,MACxD,GAAG;AAAA,MACH,GAAG;AAAA,MACH,SAAS;AAAA,MACT,WACG,iBASG,SARA;AAAA,QACE;AAAA,QACA;AAAA,UACE,SAAS;AAAA,YACP,mBAAmB;AAAA,UACrB;AAAA,QACF;AAAA,MACF;AAAA,MAGN,SAAO;AAAA,MACP,IAAI;AAAA,MACH,GAAG;AAAA,MACJ,WAAW;AAAA,MACX,YAAY;AAAA;AAAA,IAEX,SAAS,oCAAC,QAAQ,OAAR,EAAc,aAAa,GAAG,aAAY,gBAAgB,GAAG,YAAY;AAAA,IACnF;AAAA,EACH,CACF;AAEJ;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
import { SimplePopover } from "./index";
|
|
3
|
-
import { Text, YStack, XStack, Switch,
|
|
3
|
+
import { Text, YStack, XStack, Switch, Label, Button } from "tamagui";
|
|
4
4
|
const meta = {
|
|
5
5
|
title: "panels/SimplePopover",
|
|
6
6
|
component: SimplePopover,
|
|
7
7
|
parameters: { status: { type: "beta" } }
|
|
8
|
-
}, main = () => <SimplePopover><YStack><Text>popover content</Text></YStack></SimplePopover>, closeOnHoverOut = () => <SimplePopover
|
|
9
|
-
closeOnHoverOut
|
|
10
|
-
><YStack><Text>popover content will close on hoverOut</Text></YStack></SimplePopover>;
|
|
8
|
+
}, main = () => <SimplePopover trigger={<Button>Click here to get a Popover</Button>}><YStack><Text>popover content</Text></YStack></SimplePopover>, closeOnHoverOut = () => <SimplePopover trigger={<Button>click here</Button>} closeOnHoverOut><YStack><Text>popover content will close on hoverOut</Text></YStack></SimplePopover>;
|
|
11
9
|
function Open() {
|
|
12
10
|
return <SimplePopover
|
|
11
|
+
trigger={<Button>hover on it to get Popover</Button>}
|
|
13
12
|
triggerOnHover
|
|
14
13
|
arrow={!1}
|
|
15
14
|
triggerStyle={{ als: "center", ai: "center" }}
|
|
15
|
+
closeOnHoverOut
|
|
16
16
|
><YStack>{[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((i) => <Text key={i}>{i}</Text>)}</YStack></SimplePopover>;
|
|
17
17
|
}
|
|
18
18
|
const openOnHover = () => <XStack jc="space-around">
|
|
@@ -23,29 +23,14 @@ const openOnHover = () => <XStack jc="space-around">
|
|
|
23
23
|
return <YStack space>
|
|
24
24
|
<Label>change the switch to get popover</Label>
|
|
25
25
|
<Switch checked={props.open} onCheckedChange={setOpen} />
|
|
26
|
-
<SimplePopover
|
|
27
|
-
open={open}
|
|
28
|
-
onOpenChange={setOpen}
|
|
29
|
-
><Text>Conditional popover</Text></SimplePopover>
|
|
26
|
+
<SimplePopover open={open} onOpenChange={setOpen} trigger={<Button>Popup will open here</Button>}><Text>Conditional popover</Text></SimplePopover>
|
|
30
27
|
</YStack>;
|
|
31
|
-
}, openOnChangingTheCondition = (args) => <OnCondition {...args}
|
|
32
|
-
const [open, setOpen] = useState(!1), [inputVal, setInputVal] = useState("");
|
|
33
|
-
function handleInput(val) {
|
|
34
|
-
setOpen(val === "show"), setInputVal(val);
|
|
35
|
-
}
|
|
36
|
-
return <YStack space><SimplePopover
|
|
37
|
-
open={open}
|
|
38
|
-
onOpenChange={setOpen}
|
|
39
|
-
triggerElement={<YStack><Input value={inputVal} onChangeText={handleInput} placeholder="type show to get popup" /></YStack>}
|
|
40
|
-
arrow={!0}
|
|
41
|
-
><Text>Conditional popover</Text></SimplePopover></YStack>;
|
|
42
|
-
}, openOnAnyCondition = (args) => <ConditionalPopover {...args} />;
|
|
28
|
+
}, openOnChangingTheCondition = (args) => <OnCondition {...args} />;
|
|
43
29
|
var SimplePopover_stories_default = meta;
|
|
44
30
|
export {
|
|
45
31
|
closeOnHoverOut,
|
|
46
32
|
SimplePopover_stories_default as default,
|
|
47
33
|
main,
|
|
48
|
-
openOnAnyCondition,
|
|
49
34
|
openOnChangingTheCondition,
|
|
50
35
|
openOnHover
|
|
51
36
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/panels/SimplePopover/SimplePopover.stories.tsx"],
|
|
4
|
-
"mappings": "AAqBA,SAAgB,gBAAgB;AAChC,SAAS,qBAAqB;AAC9B,SAAS,MAAM,QAAQ,QAAQ,
|
|
4
|
+
"mappings": "AAqBA,SAAgB,gBAAgB;AAChC,SAAS,qBAAqB;AAC9B,SAAS,MAAM,QAAQ,QAAQ,QAAe,OAAO,cAAc;AAGnE,MAAM,OAAa;AAAA,EACjB,OAAO;AAAA,EACP,WAAW;AAAA,EACX,YAAY,EAAE,QAAQ,EAAE,MAAM,OAAO,EAAE;AACzC,GAEa,OAAO,MAClB,CAAC,cAAc,SAAS,CAAC,OAAO,2BAA2B,EAAlC,SACvB,CAAC,OACC,CAAC,KAAK,eAAe,EAApB,KACH,EAFC,OAGH,EAJC,gBAOU,kBAAkB,MAC7B,CAAC,cAAc,SAAS,CAAC,OAAO,UAAU,EAAjB,SAA4B,gBACnD,CAAC,OACC,CAAC,KAAK,sCAAsC,EAA3C,KACH,EAFC,OAGH,EAJC;AAOH,SAAS,OAAO;AACd,SACE,CAAC;AAAA,IACC,SAAS,CAAC,OAAO,0BAA0B,EAAjC;AAAA,IACV;AAAA,IACA,OAAO;AAAA,IACP,cAAc,EAAE,KAAK,UAAU,IAAI,SAAS;AAAA,IAC5C;AAAA,GAEA,CAAC,QACE,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE,EAAE,IAAI,CAAC,MACpC,CAAC,KAAK,KAAK,IAAI,EAAE,EAAhB,KACF,EACH,EAJC,OAKH,EAZC;AAcL;AAEO,MAAM,cAAc,MACzB,CAAC,OAAO,GAAG;AAAA,EACT,CAAC,KAAK;AAAA,EACN,CAAC,KAAK;AACR,EAHC,SAMG,cAAc,CAAC,UAAU;AAC7B,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,EAAK;AACtC,SACE,CAAC,OAAO;AAAA,IACN,CAAC,MAAM,gCAAgC,EAAtC;AAAA,IACD,CAAC,OAAO,SAAS,MAAM,MAAM,iBAAiB,SAAS;AAAA,IACvD,CAAC,cAAc,MAAM,MAAM,cAAc,SAAS,SAAS,CAAC,OAAO,oBAAoB,EAA3B,SAC1D,CAAC,KAAK,mBAAmB,EAAxB,KACH,EAFC;AAAA,EAGH,EANC;AAQL,GAEa,6BAA6B,CAAC,SAAS,CAAC,gBAAgB,MAAM;AAE3E,IAAO,gCAAQ;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
import { SimplePopover } from "./index";
|
|
3
|
-
import { Text, YStack, XStack, Switch,
|
|
3
|
+
import { Text, YStack, XStack, Switch, Label, Button } from "tamagui";
|
|
4
4
|
const meta = {
|
|
5
5
|
title: "panels/SimplePopover",
|
|
6
6
|
component: SimplePopover,
|
|
7
7
|
parameters: { status: { type: "beta" } }
|
|
8
|
-
}, main = () => <SimplePopover><YStack><Text>popover content</Text></YStack></SimplePopover>, closeOnHoverOut = () => <SimplePopover
|
|
9
|
-
closeOnHoverOut
|
|
10
|
-
><YStack><Text>popover content will close on hoverOut</Text></YStack></SimplePopover>;
|
|
8
|
+
}, main = () => <SimplePopover trigger={<Button>Click here to get a Popover</Button>}><YStack><Text>popover content</Text></YStack></SimplePopover>, closeOnHoverOut = () => <SimplePopover trigger={<Button>click here</Button>} closeOnHoverOut><YStack><Text>popover content will close on hoverOut</Text></YStack></SimplePopover>;
|
|
11
9
|
function Open() {
|
|
12
10
|
return <SimplePopover
|
|
11
|
+
trigger={<Button>hover on it to get Popover</Button>}
|
|
13
12
|
triggerOnHover
|
|
14
13
|
arrow={!1}
|
|
15
14
|
triggerStyle={{ als: "center", ai: "center" }}
|
|
15
|
+
closeOnHoverOut
|
|
16
16
|
><YStack>{[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((i) => <Text key={i}>{i}</Text>)}</YStack></SimplePopover>;
|
|
17
17
|
}
|
|
18
18
|
const openOnHover = () => <XStack jc="space-around">
|
|
@@ -23,29 +23,14 @@ const openOnHover = () => <XStack jc="space-around">
|
|
|
23
23
|
return <YStack space>
|
|
24
24
|
<Label>change the switch to get popover</Label>
|
|
25
25
|
<Switch checked={props.open} onCheckedChange={setOpen} />
|
|
26
|
-
<SimplePopover
|
|
27
|
-
open={open}
|
|
28
|
-
onOpenChange={setOpen}
|
|
29
|
-
><Text>Conditional popover</Text></SimplePopover>
|
|
26
|
+
<SimplePopover open={open} onOpenChange={setOpen} trigger={<Button>Popup will open here</Button>}><Text>Conditional popover</Text></SimplePopover>
|
|
30
27
|
</YStack>;
|
|
31
|
-
}, openOnChangingTheCondition = (args) => <OnCondition {...args}
|
|
32
|
-
const [open, setOpen] = useState(!1), [inputVal, setInputVal] = useState("");
|
|
33
|
-
function handleInput(val) {
|
|
34
|
-
setOpen(val === "show"), setInputVal(val);
|
|
35
|
-
}
|
|
36
|
-
return <YStack space><SimplePopover
|
|
37
|
-
open={open}
|
|
38
|
-
onOpenChange={setOpen}
|
|
39
|
-
triggerElement={<YStack><Input value={inputVal} onChangeText={handleInput} placeholder="type show to get popup" /></YStack>}
|
|
40
|
-
arrow={!0}
|
|
41
|
-
><Text>Conditional popover</Text></SimplePopover></YStack>;
|
|
42
|
-
}, openOnAnyCondition = (args) => <ConditionalPopover {...args} />;
|
|
28
|
+
}, openOnChangingTheCondition = (args) => <OnCondition {...args} />;
|
|
43
29
|
var SimplePopover_stories_default = meta;
|
|
44
30
|
export {
|
|
45
31
|
closeOnHoverOut,
|
|
46
32
|
SimplePopover_stories_default as default,
|
|
47
33
|
main,
|
|
48
|
-
openOnAnyCondition,
|
|
49
34
|
openOnChangingTheCondition,
|
|
50
35
|
openOnHover
|
|
51
36
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/panels/SimplePopover/SimplePopover.stories.tsx"],
|
|
4
|
-
"mappings": "AAqBA,SAAgB,gBAAgB;AAChC,SAAS,qBAAqB;AAC9B,SAAS,MAAM,QAAQ,QAAQ,
|
|
4
|
+
"mappings": "AAqBA,SAAgB,gBAAgB;AAChC,SAAS,qBAAqB;AAC9B,SAAS,MAAM,QAAQ,QAAQ,QAAe,OAAO,cAAc;AAGnE,MAAM,OAAa;AAAA,EACjB,OAAO;AAAA,EACP,WAAW;AAAA,EACX,YAAY,EAAE,QAAQ,EAAE,MAAM,OAAO,EAAE;AACzC,GAEa,OAAO,MAClB,CAAC,cAAc,SAAS,CAAC,OAAO,2BAA2B,EAAlC,SACvB,CAAC,OACC,CAAC,KAAK,eAAe,EAApB,KACH,EAFC,OAGH,EAJC,gBAOU,kBAAkB,MAC7B,CAAC,cAAc,SAAS,CAAC,OAAO,UAAU,EAAjB,SAA4B,gBACnD,CAAC,OACC,CAAC,KAAK,sCAAsC,EAA3C,KACH,EAFC,OAGH,EAJC;AAOH,SAAS,OAAO;AACd,SACE,CAAC;AAAA,IACC,SAAS,CAAC,OAAO,0BAA0B,EAAjC;AAAA,IACV;AAAA,IACA,OAAO;AAAA,IACP,cAAc,EAAE,KAAK,UAAU,IAAI,SAAS;AAAA,IAC5C;AAAA,GAEA,CAAC,QACE,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE,EAAE,IAAI,CAAC,MACpC,CAAC,KAAK,KAAK,IAAI,EAAE,EAAhB,KACF,EACH,EAJC,OAKH,EAZC;AAcL;AAEO,MAAM,cAAc,MACzB,CAAC,OAAO,GAAG;AAAA,EACT,CAAC,KAAK;AAAA,EACN,CAAC,KAAK;AACR,EAHC,SAMG,cAAc,CAAC,UAAU;AAC7B,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,EAAK;AACtC,SACE,CAAC,OAAO;AAAA,IACN,CAAC,MAAM,gCAAgC,EAAtC;AAAA,IACD,CAAC,OAAO,SAAS,MAAM,MAAM,iBAAiB,SAAS;AAAA,IACvD,CAAC,cAAc,MAAM,MAAM,cAAc,SAAS,SAAS,CAAC,OAAO,oBAAoB,EAA3B,SAC1D,CAAC,KAAK,mBAAmB,EAAxB,KACH,EAFC;AAAA,EAGH,EANC;AAQL,GAEa,6BAA6B,CAAC,SAAS,CAAC,gBAAgB,MAAM;AAE3E,IAAO,gCAAQ;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import { Adapt, Popover
|
|
1
|
+
import { Adapt, Popover } from "tamagui";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { YStack } from "tamagui";
|
|
4
|
-
const SimplePopoverTrigger = React.forwardRef((props, forwardedRef) => {
|
|
5
|
-
const context = usePopoverContext(), composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef), trigger = <View
|
|
6
|
-
aria-haspopup="dialog"
|
|
7
|
-
aria-expanded={context.open}
|
|
8
|
-
data-state={getState(context.open)}
|
|
9
|
-
{...props}
|
|
10
|
-
ref={composedTriggerRef}
|
|
11
|
-
/>;
|
|
12
|
-
return context.hasCustomAnchor ? trigger : <PopperAnchor asChild>{trigger}</PopperAnchor>;
|
|
13
|
-
});
|
|
14
3
|
function SimplePopover({
|
|
15
4
|
children,
|
|
16
5
|
contentStyle,
|
|
@@ -19,12 +8,18 @@ function SimplePopover({
|
|
|
19
8
|
arrow = !0,
|
|
20
9
|
triggerOnHover,
|
|
21
10
|
closeOnHoverOut,
|
|
11
|
+
trigger,
|
|
22
12
|
...props
|
|
23
13
|
}) {
|
|
24
|
-
const [open, setOpen] = React.useState(!1)
|
|
14
|
+
const [open, setOpen] = React.useState(!1);
|
|
15
|
+
function handleHoverIn(e) {
|
|
16
|
+
triggerOnHover && (setOpen(!0), contentStyle?.onHoverIn && contentStyle?.onHoverIn(e), triggerStyle?.onHoverIn && triggerStyle.onHoverIn(e));
|
|
17
|
+
}
|
|
18
|
+
function handleHoverOut(e) {
|
|
19
|
+
closeOnHoverOut && (setOpen(!1), contentStyle?.onHoverOut && contentStyle.onHoverOut(e), triggerStyle?.onHoverOut && triggerStyle.onHoverOut(e));
|
|
20
|
+
}
|
|
25
21
|
return <Popover size="$5" allowFlip open={open} onOpenChange={setOpen} {...props}>
|
|
26
|
-
|
|
27
|
-
{!trigger && "triggerElement" in props && "open" in props && <SimplePopoverTrigger asChild>{props.triggerElement}</SimplePopoverTrigger>}
|
|
22
|
+
<Popover.Trigger asChild {...triggerStyle} onHoverIn={handleHoverIn} onHoverOut={handleHoverOut}>{trigger}</Popover.Trigger>
|
|
28
23
|
<Adapt when="sm" platform="touch"><Popover.Sheet modal dismissOnSnapToBottom>
|
|
29
24
|
<Popover.Sheet.Frame padding="$4" onMouseEnter={() => setOpen(!0)}><Adapt.Contents /></Popover.Sheet.Frame>
|
|
30
25
|
<Popover.Sheet.Overlay />
|
|
@@ -46,10 +41,10 @@ function SimplePopover({
|
|
|
46
41
|
}
|
|
47
42
|
]}
|
|
48
43
|
elevate
|
|
49
|
-
onHoverIn={triggerOnHover ? () => setOpen(!0) : void 0}
|
|
50
|
-
onHoverOut={triggerOnHover || closeOnHoverOut ? () => setOpen(!1) : void 0}
|
|
51
44
|
zi={9999999999}
|
|
52
45
|
{...contentStyle}
|
|
46
|
+
onHoverIn={handleHoverIn}
|
|
47
|
+
onHoverOut={handleHoverOut}
|
|
53
48
|
>
|
|
54
49
|
{arrow && <Popover.Arrow borderWidth={1} borderColor="$borderColor" {...arrowStyle} />}
|
|
55
50
|
{children}
|
|
@@ -57,7 +52,6 @@ function SimplePopover({
|
|
|
57
52
|
</Popover>;
|
|
58
53
|
}
|
|
59
54
|
export {
|
|
60
|
-
SimplePopover
|
|
61
|
-
SimplePopoverTrigger
|
|
55
|
+
SimplePopover
|
|
62
56
|
};
|
|
63
57
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/panels/SimplePopover/index.tsx"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": "AAsBA,SAAS,OAAO,eAAe;AAC/B,OAAO,WAAW;AAeX,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAuB;AACrB,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,EAAK;AAE5C,WAAS,cAAc,GAAG;AACxB,IAAK,mBACL,QAAQ,EAAI,GACR,cAAc,aAAW,cAAc,UAAU,CAAC,GAClD,cAAc,aAAW,aAAa,UAAU,CAAC;AAAA,EACvD;AAEA,WAAS,eAAe,GAAG;AACzB,IAAK,oBACL,QAAQ,EAAK,GACT,cAAc,cAAY,aAAa,WAAW,CAAC,GACnD,cAAc,cAAY,aAAa,WAAW,CAAC;AAAA,EACzD;AAEA,SACE,CAAC,QAAQ,KAAK,KAAK,UAAU,MAAM,MAAM,cAAc,aAAa;AAAA,IAClE,CAAC,QAAQ,QAAQ,YAAY,cAAc,WAAW,eAAe,YAAY,iBAC9E,QACH,EAFC,QAAQ;AAAA,IAGT,CAAC,MAAM,KAAK,KAAK,SAAS,QACxB,CAAC,QAAQ,MAAM,MAAM;AAAA,MACnB,CAAC,QAAQ,MAAM,MAAM,QAAQ,KAAK,cAAc,MAAM,QAAQ,EAAI,GAChE,CAAC,MAAM,SAAS,EAClB,EAFC,QAAQ,MAAM;AAAA,MAGf,CAAC,QAAQ,MAAM,QAAQ;AAAA,IACzB,EALC,QAAQ,MAMX,EAPC;AAAA,IAQD,CAAC,QAAQ;AAAA,MACP,aAAa;AAAA,MACb,YAAY;AAAA,MACZ,YAAY,EAAE,GAAG,GAAG,GAAG,KAAK,SAAS,EAAE;AAAA,MACvC,WAAY,iBAAgD,SAA/B,EAAE,GAAG,GAAG,GAAG,KAAK,SAAS,EAAE;AAAA,MACxD,GAAG;AAAA,MACH,GAAG;AAAA,MACH,SAAS;AAAA,MACT,WACG,iBASG,SARA;AAAA,QACE;AAAA,QACA;AAAA,UACE,SAAS;AAAA,YACP,mBAAmB;AAAA,UACrB;AAAA,QACF;AAAA,MACF;AAAA,MAGN;AAAA,MACA,IAAI;AAAA,UACA;AAAA,MACJ,WAAW;AAAA,MACX,YAAY;AAAA;AAAA,OAEX,SAAS,CAAC,QAAQ,MAAM,aAAa,GAAG,YAAY,mBAAmB,YAAY;AAAA,OACnF;AAAA,IACH,EA5BC,QAAQ;AAAA,EA6BX,EAzCC;AA2CL;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import { Adapt, Popover
|
|
1
|
+
import { Adapt, Popover } from "tamagui";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { YStack } from "tamagui";
|
|
4
|
-
const SimplePopoverTrigger = React.forwardRef((props, forwardedRef) => {
|
|
5
|
-
const context = usePopoverContext(), composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef), trigger = <View
|
|
6
|
-
aria-haspopup="dialog"
|
|
7
|
-
aria-expanded={context.open}
|
|
8
|
-
data-state={getState(context.open)}
|
|
9
|
-
{...props}
|
|
10
|
-
ref={composedTriggerRef}
|
|
11
|
-
/>;
|
|
12
|
-
return context.hasCustomAnchor ? trigger : <PopperAnchor asChild>{trigger}</PopperAnchor>;
|
|
13
|
-
});
|
|
14
3
|
function SimplePopover({
|
|
15
4
|
children,
|
|
16
5
|
contentStyle,
|
|
@@ -19,12 +8,18 @@ function SimplePopover({
|
|
|
19
8
|
arrow = !0,
|
|
20
9
|
triggerOnHover,
|
|
21
10
|
closeOnHoverOut,
|
|
11
|
+
trigger,
|
|
22
12
|
...props
|
|
23
13
|
}) {
|
|
24
|
-
const [open, setOpen] = React.useState(!1)
|
|
14
|
+
const [open, setOpen] = React.useState(!1);
|
|
15
|
+
function handleHoverIn(e) {
|
|
16
|
+
triggerOnHover && (setOpen(!0), contentStyle != null && contentStyle.onHoverIn && (contentStyle == null || contentStyle.onHoverIn(e)), triggerStyle != null && triggerStyle.onHoverIn && triggerStyle.onHoverIn(e));
|
|
17
|
+
}
|
|
18
|
+
function handleHoverOut(e) {
|
|
19
|
+
closeOnHoverOut && (setOpen(!1), contentStyle != null && contentStyle.onHoverOut && contentStyle.onHoverOut(e), triggerStyle != null && triggerStyle.onHoverOut && triggerStyle.onHoverOut(e));
|
|
20
|
+
}
|
|
25
21
|
return <Popover size="$5" allowFlip open={open} onOpenChange={setOpen} {...props}>
|
|
26
|
-
|
|
27
|
-
{!trigger && "triggerElement" in props && "open" in props && <SimplePopoverTrigger asChild>{props.triggerElement}</SimplePopoverTrigger>}
|
|
22
|
+
<Popover.Trigger asChild {...triggerStyle} onHoverIn={handleHoverIn} onHoverOut={handleHoverOut}>{trigger}</Popover.Trigger>
|
|
28
23
|
<Adapt when="sm" platform="touch"><Popover.Sheet modal dismissOnSnapToBottom>
|
|
29
24
|
<Popover.Sheet.Frame padding="$4" onMouseEnter={() => setOpen(!0)}><Adapt.Contents /></Popover.Sheet.Frame>
|
|
30
25
|
<Popover.Sheet.Overlay />
|
|
@@ -46,10 +41,10 @@ function SimplePopover({
|
|
|
46
41
|
}
|
|
47
42
|
]}
|
|
48
43
|
elevate
|
|
49
|
-
onHoverIn={triggerOnHover ? () => setOpen(!0) : void 0}
|
|
50
|
-
onHoverOut={triggerOnHover || closeOnHoverOut ? () => setOpen(!1) : void 0}
|
|
51
44
|
zi={9999999999}
|
|
52
45
|
{...contentStyle}
|
|
46
|
+
onHoverIn={handleHoverIn}
|
|
47
|
+
onHoverOut={handleHoverOut}
|
|
53
48
|
>
|
|
54
49
|
{arrow && <Popover.Arrow borderWidth={1} borderColor="$borderColor" {...arrowStyle} />}
|
|
55
50
|
{children}
|
|
@@ -57,7 +52,6 @@ function SimplePopover({
|
|
|
57
52
|
</Popover>;
|
|
58
53
|
}
|
|
59
54
|
export {
|
|
60
|
-
SimplePopover
|
|
61
|
-
SimplePopoverTrigger
|
|
55
|
+
SimplePopover
|
|
62
56
|
};
|
|
63
57
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/panels/SimplePopover/index.tsx"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": "AAsBA,SAAS,OAAO,eAAe;AAC/B,OAAO,WAAW;AAeX,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAuB;AACrB,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,EAAK;AAE5C,WAAS,cAAc,GAAG;AACxB,IAAK,mBACL,QAAQ,EAAI,GACR,qCAAc,cAAW,qCAAc,UAAU,KACjD,qCAAc,aAAW,aAAa,UAAU,CAAC;AAAA,EACvD;AAEA,WAAS,eAAe,GAAG;AACzB,IAAK,oBACL,QAAQ,EAAK,GACT,qCAAc,cAAY,aAAa,WAAW,CAAC,GACnD,qCAAc,cAAY,aAAa,WAAW,CAAC;AAAA,EACzD;AAEA,SACE,CAAC,QAAQ,KAAK,KAAK,UAAU,MAAM,MAAM,cAAc,aAAa;AAAA,IAClE,CAAC,QAAQ,QAAQ,YAAY,cAAc,WAAW,eAAe,YAAY,iBAC9E,QACH,EAFC,QAAQ;AAAA,IAGT,CAAC,MAAM,KAAK,KAAK,SAAS,QACxB,CAAC,QAAQ,MAAM,MAAM;AAAA,MACnB,CAAC,QAAQ,MAAM,MAAM,QAAQ,KAAK,cAAc,MAAM,QAAQ,EAAI,GAChE,CAAC,MAAM,SAAS,EAClB,EAFC,QAAQ,MAAM;AAAA,MAGf,CAAC,QAAQ,MAAM,QAAQ;AAAA,IACzB,EALC,QAAQ,MAMX,EAPC;AAAA,IAQD,CAAC,QAAQ;AAAA,MACP,aAAa;AAAA,MACb,YAAY;AAAA,MACZ,YAAY,EAAE,GAAG,GAAG,GAAG,KAAK,SAAS,EAAE;AAAA,MACvC,WAAY,iBAAgD,SAA/B,EAAE,GAAG,GAAG,GAAG,KAAK,SAAS,EAAE;AAAA,MACxD,GAAG;AAAA,MACH,GAAG;AAAA,MACH,SAAS;AAAA,MACT,WACG,iBASG,SARA;AAAA,QACE;AAAA,QACA;AAAA,UACE,SAAS;AAAA,YACP,mBAAmB;AAAA,UACrB;AAAA,QACF;AAAA,MACF;AAAA,MAGN;AAAA,MACA,IAAI;AAAA,UACA;AAAA,MACJ,WAAW;AAAA,MACX,YAAY;AAAA;AAAA,OAEX,SAAS,CAAC,QAAQ,MAAM,aAAa,GAAG,YAAY,mBAAmB,YAAY;AAAA,OACnF;AAAA,IACH,EA5BC,QAAQ;AAAA,EA6BX,EAzCC;AA2CL;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/components",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.9",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"moti": "^0.27.0",
|
|
76
76
|
"react-native-reanimated": "3.5.4",
|
|
77
77
|
"solito": "^4.1.3",
|
|
78
|
-
"ui": "
|
|
78
|
+
"ui": "0.0.3"
|
|
79
79
|
},
|
|
80
80
|
"jest": {
|
|
81
81
|
"testRegex": "((/(tests|__tests__)((/|/[^_.\n][^/\n]*(/[^_.\n][^/\n]+)*/)[^_.\n][^/\n]*))|((/|/.*/)(([^_.\n][^/\n]*.(spec|test))|(spec|test)))).[jt]sx?$",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
import React, { useState } from 'react';
|
|
23
23
|
import { SimplePopover } from './index';
|
|
24
|
-
import { Text, YStack, XStack, Switch, Input, Label } from 'tamagui';
|
|
24
|
+
import { Text, YStack, XStack, Switch, Input, Label, Button } from 'tamagui';
|
|
25
25
|
import type { Meta } from '@storybook/react';
|
|
26
26
|
|
|
27
27
|
const meta: Meta = {
|
|
@@ -31,9 +31,7 @@ const meta: Meta = {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
export const main = () => (
|
|
34
|
-
<SimplePopover
|
|
35
|
-
// trigger={<Button>Click here to get a Popover</Button>}
|
|
36
|
-
>
|
|
34
|
+
<SimplePopover trigger={<Button>Click here to get a Popover</Button>}>
|
|
37
35
|
<YStack>
|
|
38
36
|
<Text>popover content</Text>
|
|
39
37
|
</YStack>
|
|
@@ -41,10 +39,7 @@ export const main = () => (
|
|
|
41
39
|
);
|
|
42
40
|
|
|
43
41
|
export const closeOnHoverOut = () => (
|
|
44
|
-
<SimplePopover
|
|
45
|
-
// trigger={<Button>click here</Button>}
|
|
46
|
-
closeOnHoverOut
|
|
47
|
-
>
|
|
42
|
+
<SimplePopover trigger={<Button>click here</Button>} closeOnHoverOut>
|
|
48
43
|
<YStack>
|
|
49
44
|
<Text>popover content will close on hoverOut</Text>
|
|
50
45
|
</YStack>
|
|
@@ -54,10 +49,11 @@ export const closeOnHoverOut = () => (
|
|
|
54
49
|
function Open() {
|
|
55
50
|
return (
|
|
56
51
|
<SimplePopover
|
|
57
|
-
|
|
52
|
+
trigger={<Button>hover on it to get Popover</Button>}
|
|
58
53
|
triggerOnHover
|
|
59
54
|
arrow={false}
|
|
60
55
|
triggerStyle={{ als: 'center', ai: 'center' }}
|
|
56
|
+
closeOnHoverOut
|
|
61
57
|
>
|
|
62
58
|
<YStack>
|
|
63
59
|
{[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((i) => (
|
|
@@ -81,11 +77,7 @@ const OnCondition = (props) => {
|
|
|
81
77
|
<YStack space>
|
|
82
78
|
<Label>change the switch to get popover</Label>
|
|
83
79
|
<Switch checked={props.open} onCheckedChange={setOpen} />
|
|
84
|
-
<SimplePopover
|
|
85
|
-
open={open}
|
|
86
|
-
onOpenChange={setOpen}
|
|
87
|
-
// trigger={<Button>Popup will open here</Button>}
|
|
88
|
-
>
|
|
80
|
+
<SimplePopover open={open} onOpenChange={setOpen} trigger={<Button>Popup will open here</Button>}>
|
|
89
81
|
<Text>Conditional popover</Text>
|
|
90
82
|
</SimplePopover>
|
|
91
83
|
</YStack>
|
|
@@ -94,34 +86,4 @@ const OnCondition = (props) => {
|
|
|
94
86
|
|
|
95
87
|
export const openOnChangingTheCondition = (args) => <OnCondition {...args} />;
|
|
96
88
|
|
|
97
|
-
const ConditionalPopover = () => {
|
|
98
|
-
const [open, setOpen] = useState(false);
|
|
99
|
-
const [inputVal, setInputVal] = useState('');
|
|
100
|
-
|
|
101
|
-
function handleInput(val) {
|
|
102
|
-
if (val === 'show') setOpen(true);
|
|
103
|
-
else setOpen(false);
|
|
104
|
-
setInputVal(val);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return (
|
|
108
|
-
<YStack space>
|
|
109
|
-
<SimplePopover
|
|
110
|
-
open={open}
|
|
111
|
-
onOpenChange={setOpen}
|
|
112
|
-
triggerElement={
|
|
113
|
-
<YStack>
|
|
114
|
-
<Input value={inputVal} onChangeText={handleInput} placeholder="type show to get popup" />
|
|
115
|
-
</YStack>
|
|
116
|
-
}
|
|
117
|
-
arrow={true}
|
|
118
|
-
>
|
|
119
|
-
<Text>Conditional popover</Text>
|
|
120
|
-
</SimplePopover>
|
|
121
|
-
</YStack>
|
|
122
|
-
);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
export const openOnAnyCondition = (args) => <ConditionalPopover {...args} />;
|
|
126
|
-
|
|
127
89
|
export default meta;
|
|
@@ -19,55 +19,22 @@
|
|
|
19
19
|
* limitations under the License.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import type {
|
|
23
|
-
|
|
24
|
-
PopoverContentProps,
|
|
25
|
-
PopoverProps,
|
|
26
|
-
PopoverTriggerProps,
|
|
27
|
-
StackProps,
|
|
28
|
-
TamaguiElement,
|
|
29
|
-
YStackProps,
|
|
30
|
-
} from 'tamagui';
|
|
31
|
-
import { Adapt, Popover, PopperAnchor, View, getState, useComposedRefs, usePopoverContext } from 'tamagui';
|
|
22
|
+
import type { PopoverArrowProps, PopoverContentProps, PopoverProps, PopoverTriggerProps } from 'tamagui';
|
|
23
|
+
import { Adapt, Popover } from 'tamagui';
|
|
32
24
|
import React from 'react';
|
|
33
25
|
import type { ReactNode } from 'react';
|
|
34
|
-
import { YStack } from 'tamagui';
|
|
35
26
|
|
|
36
|
-
export
|
|
27
|
+
export type SimplePopoverProps = PopoverProps & {
|
|
37
28
|
contentStyle?: PopoverContentProps;
|
|
38
29
|
arrowStyle?: PopoverArrowProps;
|
|
39
|
-
triggerStyle?:
|
|
30
|
+
triggerStyle?: PopoverTriggerProps;
|
|
40
31
|
triggerOnHover?: boolean;
|
|
41
32
|
closeOnHoverOut?: boolean;
|
|
42
33
|
arrow?: boolean;
|
|
43
34
|
open?: boolean;
|
|
44
35
|
setOpen?: (open: boolean) => void;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
export interface PopoverOpen {
|
|
48
|
-
triggerElement: ReactNode;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export type ExclusiveTriggerProps = PopoverTriggerProps | PopoverOpen;
|
|
52
|
-
|
|
53
|
-
export type SimplePopoverProps = PopoverProps & PopoverCustomProps & ExclusiveTriggerProps;
|
|
54
|
-
|
|
55
|
-
export const SimplePopoverTrigger = React.forwardRef<TamaguiElement, StackProps>((props: StackProps, forwardedRef) => {
|
|
56
|
-
const context = usePopoverContext();
|
|
57
|
-
const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
|
|
58
|
-
|
|
59
|
-
const trigger = (
|
|
60
|
-
<View
|
|
61
|
-
aria-haspopup="dialog"
|
|
62
|
-
aria-expanded={context.open}
|
|
63
|
-
data-state={getState(context.open)}
|
|
64
|
-
{...props}
|
|
65
|
-
ref={composedTriggerRef}
|
|
66
|
-
/>
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
return context.hasCustomAnchor ? trigger : <PopperAnchor asChild>{trigger}</PopperAnchor>;
|
|
70
|
-
});
|
|
36
|
+
trigger: ReactNode;
|
|
37
|
+
};
|
|
71
38
|
|
|
72
39
|
export function SimplePopover({
|
|
73
40
|
children,
|
|
@@ -77,30 +44,30 @@ export function SimplePopover({
|
|
|
77
44
|
arrow = true,
|
|
78
45
|
triggerOnHover,
|
|
79
46
|
closeOnHoverOut,
|
|
47
|
+
trigger,
|
|
80
48
|
...props
|
|
81
49
|
}: SimplePopoverProps) {
|
|
82
50
|
const [open, setOpen] = React.useState(false);
|
|
83
|
-
|
|
51
|
+
|
|
52
|
+
function handleHoverIn(e) {
|
|
53
|
+
if (!triggerOnHover) return;
|
|
54
|
+
setOpen(true);
|
|
55
|
+
if (contentStyle?.onHoverIn) contentStyle?.onHoverIn(e);
|
|
56
|
+
if (triggerStyle?.onHoverIn) triggerStyle.onHoverIn(e);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function handleHoverOut(e) {
|
|
60
|
+
if (!closeOnHoverOut) return;
|
|
61
|
+
setOpen(false);
|
|
62
|
+
if (contentStyle?.onHoverOut) contentStyle.onHoverOut(e);
|
|
63
|
+
if (triggerStyle?.onHoverOut) triggerStyle.onHoverOut(e);
|
|
64
|
+
}
|
|
84
65
|
|
|
85
66
|
return (
|
|
86
67
|
<Popover size="$5" allowFlip open={open} onOpenChange={setOpen} {...props}>
|
|
87
|
-
{
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
<Popover.Trigger asChild>
|
|
91
|
-
{triggerOnHover ? (
|
|
92
|
-
<YStack onHoverIn={() => setOpen(true)} onHoverOut={() => setOpen(false)} {...triggerStyle}>
|
|
93
|
-
{props.trigger}
|
|
94
|
-
</YStack>
|
|
95
|
-
) : (
|
|
96
|
-
props.trigger
|
|
97
|
-
)}
|
|
98
|
-
</Popover.Trigger>
|
|
99
|
-
) as any)}
|
|
100
|
-
{!trigger && 'triggerElement' in props && 'open' in props && (
|
|
101
|
-
<SimplePopoverTrigger asChild>{props.triggerElement}</SimplePopoverTrigger>
|
|
102
|
-
)}
|
|
103
|
-
|
|
68
|
+
<Popover.Trigger asChild {...triggerStyle} onHoverIn={handleHoverIn} onHoverOut={handleHoverOut}>
|
|
69
|
+
{trigger}
|
|
70
|
+
</Popover.Trigger>
|
|
104
71
|
<Adapt when="sm" platform="touch">
|
|
105
72
|
<Popover.Sheet modal dismissOnSnapToBottom>
|
|
106
73
|
<Popover.Sheet.Frame padding="$4" onMouseEnter={() => setOpen(true)}>
|
|
@@ -130,10 +97,10 @@ export function SimplePopover({
|
|
|
130
97
|
: undefined
|
|
131
98
|
}
|
|
132
99
|
elevate
|
|
133
|
-
onHoverIn={triggerOnHover ? () => setOpen(true) : undefined}
|
|
134
|
-
onHoverOut={triggerOnHover || closeOnHoverOut ? () => setOpen(false) : undefined}
|
|
135
100
|
zi={9999999999}
|
|
136
101
|
{...contentStyle}
|
|
102
|
+
onHoverIn={handleHoverIn}
|
|
103
|
+
onHoverOut={handleHoverOut}
|
|
137
104
|
>
|
|
138
105
|
{arrow && <Popover.Arrow borderWidth={1} borderColor="$borderColor" {...arrowStyle} />}
|
|
139
106
|
{children}
|
|
@@ -25,6 +25,5 @@ export declare const main: () => React.JSX.Element;
|
|
|
25
25
|
export declare const closeOnHoverOut: () => React.JSX.Element;
|
|
26
26
|
export declare const openOnHover: () => React.JSX.Element;
|
|
27
27
|
export declare const openOnChangingTheCondition: (args: any) => React.JSX.Element;
|
|
28
|
-
export declare const openOnAnyCondition: (args: any) => React.JSX.Element;
|
|
29
28
|
export default meta;
|
|
30
29
|
//# sourceMappingURL=SimplePopover.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimplePopover.stories.d.ts","sourceRoot":"","sources":["../../../src/panels/SimplePopover/SimplePopover.stories.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,QAAA,MAAM,IAAI,EAAE,IAIX,CAAC;AAEF,eAAO,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"SimplePopover.stories.d.ts","sourceRoot":"","sources":["../../../src/panels/SimplePopover/SimplePopover.stories.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,QAAA,MAAM,IAAI,EAAE,IAIX,CAAC;AAEF,eAAO,MAAM,IAAI,yBAMhB,CAAC;AAEF,eAAO,MAAM,eAAe,yBAM3B,CAAC;AAoBF,eAAO,MAAM,WAAW,yBAKvB,CAAC;AAeF,eAAO,MAAM,0BAA0B,kCAAsC,CAAC;AAE9E,eAAe,IAAI,CAAC"}
|