@multiplatform.one/components 0.7.8 → 0.7.10
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/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +3 -1
- package/dist/cjs/index.native.js.map +1 -1
- 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/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.native.js +1 -0
- package/dist/esm/index.native.js.map +1 -1
- 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/index.js +1 -0
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.native.js +1 -0
- package/dist/jsx/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/index.ts +22 -0
- package/src/panels/SimplePopover/SimplePopover.stories.tsx +6 -44
- package/src/panels/SimplePopover/index.tsx +26 -59
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- 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
|
@@ -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}
|
package/types/index.d.ts
CHANGED
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqBA,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
|
|
@@ -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"}
|
|
@@ -18,26 +18,19 @@
|
|
|
18
18
|
* See the License for the specific language governing permissions and
|
|
19
19
|
* limitations under the License.
|
|
20
20
|
*/
|
|
21
|
-
import type { PopoverArrowProps, PopoverContentProps, PopoverProps, PopoverTriggerProps
|
|
21
|
+
import type { PopoverArrowProps, PopoverContentProps, PopoverProps, PopoverTriggerProps } from 'tamagui';
|
|
22
22
|
import React from 'react';
|
|
23
23
|
import type { ReactNode } from 'react';
|
|
24
|
-
export
|
|
24
|
+
export type SimplePopoverProps = PopoverProps & {
|
|
25
25
|
contentStyle?: PopoverContentProps;
|
|
26
26
|
arrowStyle?: PopoverArrowProps;
|
|
27
|
-
triggerStyle?:
|
|
27
|
+
triggerStyle?: PopoverTriggerProps;
|
|
28
28
|
triggerOnHover?: boolean;
|
|
29
29
|
closeOnHoverOut?: boolean;
|
|
30
30
|
arrow?: boolean;
|
|
31
31
|
open?: boolean;
|
|
32
32
|
setOpen?: (open: boolean) => void;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
export type ExclusiveTriggerProps = PopoverTriggerProps | PopoverOpen;
|
|
38
|
-
export type SimplePopoverProps = PopoverProps & PopoverCustomProps & ExclusiveTriggerProps;
|
|
39
|
-
export declare const SimplePopoverTrigger: React.ForwardRefExoticComponent<Omit<import("react-native").ViewProps, "style" | "display" | "children" | ("onLayout" | keyof import("react-native").GestureResponderHandlers)> & import("@tamagui/web").ExtendBaseStackProps & import("@tamagui/web").WebOnlyPressEvents & import("@tamagui/web").TamaguiComponentPropsBaseBase & {
|
|
40
|
-
style?: import("@tamagui/web").StyleProp<import("react-native").ViewStyle | React.CSSProperties | (React.CSSProperties & import("react-native").ViewStyle)>;
|
|
41
|
-
} & import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>> & import("@tamagui/web").PseudoProps<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>>> & import("@tamagui/web").MediaProps<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>> & import("@tamagui/web").PseudoProps<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>>>> & React.RefAttributes<TamaguiElement>>;
|
|
42
|
-
export declare function SimplePopover({ children, contentStyle, triggerStyle, arrowStyle, arrow, triggerOnHover, closeOnHoverOut, ...props }: SimplePopoverProps): React.JSX.Element;
|
|
33
|
+
trigger: ReactNode;
|
|
34
|
+
};
|
|
35
|
+
export declare function SimplePopover({ children, contentStyle, triggerStyle, arrowStyle, arrow, triggerOnHover, closeOnHoverOut, trigger, ...props }: SimplePopoverProps): React.JSX.Element;
|
|
43
36
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/panels/SimplePopover/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/panels/SimplePopover/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEzG,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG;IAC9C,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAClC,OAAO,EAAE,SAAS,CAAC;CACpB,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,KAAY,EACZ,cAAc,EACd,eAAe,EACf,OAAO,EACP,GAAG,KAAK,EACT,EAAE,kBAAkB,qBA6DpB"}
|