@xaui/native 0.9.1-alpha.38 → 0.9.1-alpha.39
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/chunk-2EGR4LWD.js +145 -0
- package/dist/chunk-37L7YGZV.cjs +425 -0
- package/dist/chunk-64MXEVT3.js +66 -0
- package/dist/{chunk-RAWGK2XK.cjs → chunk-76XDVA24.cjs} +43 -133
- package/dist/{chunk-Q3MQ7S2D.cjs → chunk-7KLBTMXV.cjs} +6 -4
- package/dist/chunk-EKS3W46M.cjs +66 -0
- package/dist/{chunk-ZF6KIHXH.js → chunk-GJSFKH4L.js} +15 -20
- package/dist/{chunk-ZNZ7HVRW.js → chunk-JKP4TPIL.js} +51 -217
- package/dist/chunk-LUPCPLND.cjs +145 -0
- package/dist/chunk-XAFP5JLK.js +425 -0
- package/dist/components/accordion/index.cjs +3 -2
- package/dist/components/accordion/index.js +2 -1
- package/dist/components/badge/index.d.cts +1 -1
- package/dist/components/badge/index.d.ts +1 -1
- package/dist/components/popover/index.cjs +37 -0
- package/dist/components/popover/index.d.cts +254 -0
- package/dist/components/popover/index.d.ts +254 -0
- package/dist/components/popover/index.js +37 -0
- package/dist/components/select/index.cjs +4 -2
- package/dist/components/select/index.d.cts +14 -25
- package/dist/components/select/index.d.ts +14 -25
- package/dist/components/select/index.js +3 -1
- package/dist/index.cjs +42 -5
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +44 -7
- package/dist/placement-DHa0Rrh1.d.cts +38 -0
- package/dist/placement-DHa0Rrh1.d.ts +38 -0
- package/dist/system/index.cjs +16 -2
- package/dist/system/index.d.cts +38 -2
- package/dist/system/index.d.ts +38 -2
- package/dist/system/index.js +15 -1
- package/package.json +11 -1
- /package/dist/{chunk-OJCCV65P.cjs → chunk-GGW43Q37.cjs} +0 -0
- /package/dist/{chunk-MESKS6AI.js → chunk-WHJTBTYM.js} +0 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PortalContext
|
|
3
|
+
} from "./chunk-2PMXMKS5.js";
|
|
4
|
+
|
|
5
|
+
// src/hooks/use-anchored-position.ts
|
|
6
|
+
import { useCallback, useContext, useState } from "react";
|
|
7
|
+
import { useWindowDimensions } from "react-native";
|
|
8
|
+
|
|
9
|
+
// src/utils/placement.ts
|
|
10
|
+
var OPPOSITE = {
|
|
11
|
+
top: "bottom",
|
|
12
|
+
bottom: "top",
|
|
13
|
+
start: "end",
|
|
14
|
+
end: "start"
|
|
15
|
+
};
|
|
16
|
+
function axisOf(placement) {
|
|
17
|
+
return placement === "top" || placement === "bottom" ? "vertical" : "horizontal";
|
|
18
|
+
}
|
|
19
|
+
function resolvePlacement(input) {
|
|
20
|
+
const { anchor, content, window, offset, alignOffset, insets } = input;
|
|
21
|
+
const available = window.width - insets.start - insets.end;
|
|
22
|
+
const width = Math.min(resolveWidth(input), Math.max(available, 0));
|
|
23
|
+
const placement = choosePlacement(input);
|
|
24
|
+
const room = Math.max(roomFor(placement, input), 0);
|
|
25
|
+
const vertical = axisOf(placement) === "vertical";
|
|
26
|
+
const maxHeight = vertical ? room : Math.max(window.height - insets.top - insets.bottom, 0);
|
|
27
|
+
const height = Math.min(content.height, maxHeight);
|
|
28
|
+
const top = clamp(
|
|
29
|
+
vertical ? placement === "bottom" ? anchor.y + anchor.height + offset : anchor.y - offset - height : alignedCross(input, height) + alignOffset,
|
|
30
|
+
insets.top,
|
|
31
|
+
Math.max(window.height - insets.bottom - height, insets.top)
|
|
32
|
+
);
|
|
33
|
+
const start = clamp(
|
|
34
|
+
vertical ? alignedCross(input, width) + alignOffset : placement === "end" ? anchor.x + anchor.width + offset : anchor.x - offset - width,
|
|
35
|
+
insets.start,
|
|
36
|
+
Math.max(window.width - insets.end - width, insets.start)
|
|
37
|
+
);
|
|
38
|
+
return { top, start, width, maxHeight, placement };
|
|
39
|
+
}
|
|
40
|
+
function resolveWidth(input) {
|
|
41
|
+
const { width, anchor, content, placement, window, insets } = input;
|
|
42
|
+
if (width === "trigger") {
|
|
43
|
+
return axisOf(placement) === "vertical" ? anchor.width : content.width;
|
|
44
|
+
}
|
|
45
|
+
if (width === "full") return Math.max(window.width - insets.start - insets.end, 0);
|
|
46
|
+
if (width === "content-fit") return content.width;
|
|
47
|
+
return width;
|
|
48
|
+
}
|
|
49
|
+
function choosePlacement(input) {
|
|
50
|
+
const { placement, avoidCollisions, content } = input;
|
|
51
|
+
if (!avoidCollisions) return placement;
|
|
52
|
+
const wanted = axisOf(placement) === "vertical" ? content.height : content.width;
|
|
53
|
+
if (roomFor(placement, input) >= wanted) return placement;
|
|
54
|
+
const other = OPPOSITE[placement];
|
|
55
|
+
return roomFor(other, input) > roomFor(placement, input) ? other : placement;
|
|
56
|
+
}
|
|
57
|
+
function roomFor(placement, input) {
|
|
58
|
+
const { anchor, window, offset, insets } = input;
|
|
59
|
+
switch (placement) {
|
|
60
|
+
case "bottom":
|
|
61
|
+
return window.height - insets.bottom - (anchor.y + anchor.height) - offset;
|
|
62
|
+
case "top":
|
|
63
|
+
return anchor.y - insets.top - offset;
|
|
64
|
+
case "end":
|
|
65
|
+
return window.width - insets.end - (anchor.x + anchor.width) - offset;
|
|
66
|
+
case "start":
|
|
67
|
+
return anchor.x - insets.start - offset;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function alignedCross({ align, anchor, placement }, size) {
|
|
71
|
+
const vertical = axisOf(placement) === "vertical";
|
|
72
|
+
const origin = vertical ? anchor.x : anchor.y;
|
|
73
|
+
const extent = vertical ? anchor.width : anchor.height;
|
|
74
|
+
if (align === "start") return origin;
|
|
75
|
+
if (align === "end") return origin + extent - size;
|
|
76
|
+
return origin + (extent - size) / 2;
|
|
77
|
+
}
|
|
78
|
+
function clamp(value, min, max) {
|
|
79
|
+
return Math.min(Math.max(value, min), max);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// src/hooks/use-anchored-position.ts
|
|
83
|
+
function useAnchoredPosition({
|
|
84
|
+
anchor,
|
|
85
|
+
isOpen,
|
|
86
|
+
onLayout,
|
|
87
|
+
...options
|
|
88
|
+
}) {
|
|
89
|
+
const window = useWindowDimensions();
|
|
90
|
+
const origin = useContext(PortalContext)?.origin ?? ZERO;
|
|
91
|
+
const [measured, setMeasured] = useState(null);
|
|
92
|
+
const onContentLayout = useCallback(
|
|
93
|
+
(event) => {
|
|
94
|
+
onLayout?.(event);
|
|
95
|
+
const { width, height } = event.nativeEvent.layout;
|
|
96
|
+
setMeasured(
|
|
97
|
+
(current) => current !== null && current.width === width && current.height === height ? current : { width, height }
|
|
98
|
+
);
|
|
99
|
+
},
|
|
100
|
+
[onLayout]
|
|
101
|
+
);
|
|
102
|
+
if (!isOpen && measured !== null) setMeasured(null);
|
|
103
|
+
const local = anchor && {
|
|
104
|
+
...anchor,
|
|
105
|
+
x: anchor.x - origin.x,
|
|
106
|
+
y: anchor.y - origin.y
|
|
107
|
+
};
|
|
108
|
+
const position = local && measured ? resolvePlacement({
|
|
109
|
+
anchor: local,
|
|
110
|
+
content: measured,
|
|
111
|
+
window: {
|
|
112
|
+
width: window.width - origin.x,
|
|
113
|
+
height: window.height - origin.y
|
|
114
|
+
},
|
|
115
|
+
...options
|
|
116
|
+
}) : null;
|
|
117
|
+
return {
|
|
118
|
+
position,
|
|
119
|
+
onContentLayout,
|
|
120
|
+
measuringStyle: {
|
|
121
|
+
// Invisible, and at the start of the host, so the reader never sees the panel at
|
|
122
|
+
// the wrong place during the frame it is being measured in.
|
|
123
|
+
opacity: 0,
|
|
124
|
+
top: 0,
|
|
125
|
+
start: 0,
|
|
126
|
+
...measuringWidth(options, local?.width, window)
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function measuringWidth({
|
|
131
|
+
width,
|
|
132
|
+
maxWidth,
|
|
133
|
+
insets
|
|
134
|
+
}, anchorWidth, window) {
|
|
135
|
+
const screen = Math.max(window.width - insets.start - insets.end, 0);
|
|
136
|
+
if (width === "trigger") return { width: anchorWidth };
|
|
137
|
+
if (width === "full") return { width: screen };
|
|
138
|
+
if (typeof width === "number") return { width };
|
|
139
|
+
return { maxWidth: Math.min(maxWidth ?? Number.POSITIVE_INFINITY, screen) };
|
|
140
|
+
}
|
|
141
|
+
var ZERO = { x: 0, y: 0 };
|
|
142
|
+
|
|
143
|
+
export {
|
|
144
|
+
useAnchoredPosition
|
|
145
|
+
};
|
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkLUPCPLNDcjs = require('./chunk-LUPCPLND.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkWDDXU3OHcjs = require('./chunk-WDDXU3OH.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunkEKS3W46Mcjs = require('./chunk-EKS3W46M.cjs');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
var _chunkWFEMJCXOcjs = require('./chunk-WFEMJCXO.cjs');
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
var _chunk7EIHHOHPcjs = require('./chunk-7EIHHOHP.cjs');
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
var _chunkTGMVEHV7cjs = require('./chunk-TGMVEHV7.cjs');
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
var _chunk7DPL3ZDScjs = require('./chunk-7DPL3ZDS.cjs');
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
var _chunk7GHM4GKLcjs = require('./chunk-7GHM4GKL.cjs');
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
var _chunkFNEUOBCVcjs = require('./chunk-FNEUOBCV.cjs');
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
var _chunk57SJ4LJFcjs = require('./chunk-57SJ4LJF.cjs');
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
var _chunkTK44VBIEcjs = require('./chunk-TK44VBIE.cjs');
|
|
38
|
+
|
|
39
|
+
// src/components/popover/popover-close.tsx
|
|
40
|
+
var _react = require('react');
|
|
41
|
+
|
|
42
|
+
// src/components/popover/popover.context.ts
|
|
43
|
+
var [PopoverProvider, usePopover] = _chunk7GHM4GKLcjs.createSlotContext.call(void 0, "Popover");
|
|
44
|
+
|
|
45
|
+
// src/components/popover/popover-close.tsx
|
|
46
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
47
|
+
var PopoverClose = _react.forwardRef.call(void 0,
|
|
48
|
+
function PopoverClose2({
|
|
49
|
+
children,
|
|
50
|
+
asChild = false,
|
|
51
|
+
accessibilityRole = "button",
|
|
52
|
+
style,
|
|
53
|
+
onPress,
|
|
54
|
+
onPressIn,
|
|
55
|
+
onPressOut,
|
|
56
|
+
...props
|
|
57
|
+
}, ref) {
|
|
58
|
+
const { close } = usePopover();
|
|
59
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
60
|
+
const [isPressed, press] = _chunk7DPL3ZDScjs.usePressState.call(void 0, { onPressIn, onPressOut });
|
|
61
|
+
const handlePress = _react.useCallback.call(void 0,
|
|
62
|
+
(event) => {
|
|
63
|
+
_optionalChain([onPress, 'optionalCall', _ => _(event)]);
|
|
64
|
+
close();
|
|
65
|
+
},
|
|
66
|
+
[close, onPress]
|
|
67
|
+
);
|
|
68
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
69
|
+
_chunkTGMVEHV7cjs.PressableFeedback,
|
|
70
|
+
{
|
|
71
|
+
ref,
|
|
72
|
+
isPressed,
|
|
73
|
+
asChild,
|
|
74
|
+
accessibilityRole,
|
|
75
|
+
...rest,
|
|
76
|
+
style: [
|
|
77
|
+
styleProps,
|
|
78
|
+
typeof style === "function" ? style({ pressed: isPressed }) : style
|
|
79
|
+
],
|
|
80
|
+
onPress: handlePress,
|
|
81
|
+
onPressIn: press.onPressIn,
|
|
82
|
+
onPressOut: press.onPressOut,
|
|
83
|
+
children
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
PopoverClose.displayName = "XAUI.Popover.Close";
|
|
89
|
+
|
|
90
|
+
// src/components/popover/popover-content.tsx
|
|
91
|
+
|
|
92
|
+
var _reactnativereanimated = require('react-native-reanimated'); var _reactnativereanimated2 = _interopRequireDefault(_reactnativereanimated);
|
|
93
|
+
|
|
94
|
+
// src/components/popover/popover.recipe.ts
|
|
95
|
+
var SLOTS = ["trigger", "overlay", "content", "title", "description"];
|
|
96
|
+
function popoverMeasure(fontSize) {
|
|
97
|
+
return fontSize * 13;
|
|
98
|
+
}
|
|
99
|
+
var popoverRecipe = _chunkFNEUOBCVcjs.createRecipe.call(void 0, {
|
|
100
|
+
slots: SLOTS,
|
|
101
|
+
base: (theme) => ({
|
|
102
|
+
overlay: { position: "absolute", top: 0, bottom: 0, start: 0, end: 0 },
|
|
103
|
+
content: {
|
|
104
|
+
position: "absolute",
|
|
105
|
+
backgroundColor: theme.colors.overlay,
|
|
106
|
+
// HeroUI's twelve by sixteen: a panel is read, not scanned, so it is wider-padded
|
|
107
|
+
// than it is tall-padded.
|
|
108
|
+
paddingVertical: theme.spacing(3),
|
|
109
|
+
paddingHorizontal: theme.spacing(4),
|
|
110
|
+
// Their `--radius-3xl` on a base of 8 is 24 points; our base is 12, so the same 24
|
|
111
|
+
// is `2xl`. Reading their key rather than their number puts a pill on it.
|
|
112
|
+
borderRadius: theme.radius["2xl"],
|
|
113
|
+
borderCurve: "continuous",
|
|
114
|
+
gap: theme.spacing(1.5),
|
|
115
|
+
...theme.shadows.overlay
|
|
116
|
+
},
|
|
117
|
+
title: {
|
|
118
|
+
fontFamily: theme.fontFamilies.body,
|
|
119
|
+
fontWeight: theme.fontWeights.medium,
|
|
120
|
+
fontSize: theme.fontSizes.lg,
|
|
121
|
+
lineHeight: theme.lineHeights.lg,
|
|
122
|
+
color: theme.colors.overlayForeground
|
|
123
|
+
},
|
|
124
|
+
description: {
|
|
125
|
+
fontFamily: theme.fontFamilies.body,
|
|
126
|
+
fontSize: theme.fontSizes.md,
|
|
127
|
+
lineHeight: theme.lineHeights.md,
|
|
128
|
+
color: theme.colors.muted
|
|
129
|
+
}
|
|
130
|
+
}),
|
|
131
|
+
variantTokens: { default: {} },
|
|
132
|
+
variants: { radius: _chunkFNEUOBCVcjs.radiusAxis.call(void 0, "content") },
|
|
133
|
+
states: {
|
|
134
|
+
disabled: (theme) => ({ trigger: { opacity: theme.opacity.disabled } })
|
|
135
|
+
},
|
|
136
|
+
defaultVariants: { variant: "default" }
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// src/components/popover/popover-content.tsx
|
|
140
|
+
|
|
141
|
+
var DEFAULT_OFFSET = 9;
|
|
142
|
+
var DEFAULT_INSETS = {
|
|
143
|
+
top: 12,
|
|
144
|
+
bottom: 12,
|
|
145
|
+
start: 12,
|
|
146
|
+
end: 12
|
|
147
|
+
};
|
|
148
|
+
var PopoverContent = _react.forwardRef.call(void 0,
|
|
149
|
+
function PopoverContent2({
|
|
150
|
+
children,
|
|
151
|
+
placement = "bottom",
|
|
152
|
+
align = "center",
|
|
153
|
+
width = "content-fit",
|
|
154
|
+
offset = DEFAULT_OFFSET,
|
|
155
|
+
alignOffset = 0,
|
|
156
|
+
avoidCollisions = true,
|
|
157
|
+
insets,
|
|
158
|
+
style,
|
|
159
|
+
onLayout,
|
|
160
|
+
...props
|
|
161
|
+
}, ref) {
|
|
162
|
+
const context = usePopover();
|
|
163
|
+
const { contentStyle, isOpen, anchor } = context;
|
|
164
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
165
|
+
const theme = _chunk57SJ4LJFcjs.useXAUITheme.call(void 0, );
|
|
166
|
+
const { position, onContentLayout, measuringStyle } = _chunkLUPCPLNDcjs.useAnchoredPosition.call(void 0, {
|
|
167
|
+
anchor,
|
|
168
|
+
isOpen,
|
|
169
|
+
placement,
|
|
170
|
+
align,
|
|
171
|
+
width,
|
|
172
|
+
offset,
|
|
173
|
+
alignOffset,
|
|
174
|
+
avoidCollisions,
|
|
175
|
+
insets: { ...DEFAULT_INSETS, ...insets },
|
|
176
|
+
maxWidth: popoverMeasure(theme.fontSizes.md),
|
|
177
|
+
onLayout
|
|
178
|
+
});
|
|
179
|
+
if (!isOpen || anchor === null) return null;
|
|
180
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkWDDXU3OHcjs.Portal, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PopoverProvider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
181
|
+
_reactnativereanimated2.default.View,
|
|
182
|
+
{
|
|
183
|
+
ref,
|
|
184
|
+
entering: position ? _chunkEKS3W46Mcjs.anchoredEntering.call(void 0, position.placement) : void 0,
|
|
185
|
+
exiting: position ? _chunkEKS3W46Mcjs.anchoredExiting.call(void 0, position.placement) : void 0,
|
|
186
|
+
onLayout: onContentLayout,
|
|
187
|
+
...rest,
|
|
188
|
+
style: [
|
|
189
|
+
contentStyle,
|
|
190
|
+
position === null ? measuringStyle : {
|
|
191
|
+
top: position.top,
|
|
192
|
+
start: position.start,
|
|
193
|
+
width: position.width,
|
|
194
|
+
maxHeight: position.maxHeight
|
|
195
|
+
},
|
|
196
|
+
styleProps,
|
|
197
|
+
style
|
|
198
|
+
],
|
|
199
|
+
children
|
|
200
|
+
},
|
|
201
|
+
_nullishCoalesce(_optionalChain([position, 'optionalAccess', _2 => _2.placement]), () => ( "measuring"))
|
|
202
|
+
) }) });
|
|
203
|
+
}
|
|
204
|
+
);
|
|
205
|
+
PopoverContent.displayName = "XAUI.Popover.Content";
|
|
206
|
+
|
|
207
|
+
// src/components/popover/popover-description.tsx
|
|
208
|
+
|
|
209
|
+
var _reactnative = require('react-native');
|
|
210
|
+
|
|
211
|
+
var PopoverDescription = _react.forwardRef.call(void 0,
|
|
212
|
+
function PopoverDescription2({ children, style, ...props }, ref) {
|
|
213
|
+
const { descriptionStyle } = usePopover();
|
|
214
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
215
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.Text, { ref, ...rest, style: [descriptionStyle, styleProps, style], children });
|
|
216
|
+
}
|
|
217
|
+
);
|
|
218
|
+
PopoverDescription.displayName = "XAUI.Popover.Description";
|
|
219
|
+
|
|
220
|
+
// src/components/popover/popover-overlay.tsx
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
var AnimatedPressable = _reactnativereanimated2.default.createAnimatedComponent(_reactnative.Pressable);
|
|
226
|
+
var PopoverOverlay = _react.forwardRef.call(void 0,
|
|
227
|
+
function PopoverOverlay2({ children, isDismissable = true, style, ...props }, ref) {
|
|
228
|
+
const context = usePopover();
|
|
229
|
+
const { overlayStyle, isOpen, close } = context;
|
|
230
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
231
|
+
if (!isOpen) return null;
|
|
232
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkWDDXU3OHcjs.Portal, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PopoverProvider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
233
|
+
AnimatedPressable,
|
|
234
|
+
{
|
|
235
|
+
ref,
|
|
236
|
+
entering: _chunkEKS3W46Mcjs.overlayEntering,
|
|
237
|
+
exiting: _chunkEKS3W46Mcjs.overlayExiting,
|
|
238
|
+
accessibilityRole: "none",
|
|
239
|
+
importantForAccessibility: "no",
|
|
240
|
+
onPress: isDismissable ? close : void 0,
|
|
241
|
+
...rest,
|
|
242
|
+
style: [overlayStyle, styleProps, style],
|
|
243
|
+
children
|
|
244
|
+
}
|
|
245
|
+
) }) });
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
PopoverOverlay.displayName = "XAUI.Popover.Overlay";
|
|
249
|
+
|
|
250
|
+
// src/components/popover/popover-title.tsx
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
var PopoverTitle = _react.forwardRef.call(void 0,
|
|
255
|
+
function PopoverTitle2({ children, accessibilityRole = "header", style, ...props }, ref) {
|
|
256
|
+
const { titleStyle } = usePopover();
|
|
257
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
258
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
259
|
+
_reactnative.Text,
|
|
260
|
+
{
|
|
261
|
+
ref,
|
|
262
|
+
accessibilityRole,
|
|
263
|
+
...rest,
|
|
264
|
+
style: [titleStyle, styleProps, style],
|
|
265
|
+
children
|
|
266
|
+
}
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
PopoverTitle.displayName = "XAUI.Popover.Title";
|
|
271
|
+
|
|
272
|
+
// src/components/popover/popover-trigger.tsx
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
// src/hooks/use-anchor-ref.ts
|
|
276
|
+
|
|
277
|
+
function useAnchorRef({ isOpen, onAnchor, onLayout }) {
|
|
278
|
+
const node = _react.useRef.call(void 0, null);
|
|
279
|
+
const latest = _react.useRef.call(void 0, onAnchor);
|
|
280
|
+
latest.current = onAnchor;
|
|
281
|
+
const measure = _react.useCallback.call(void 0, () => {
|
|
282
|
+
_optionalChain([node, 'access', _3 => _3.current, 'optionalAccess', _4 => _4.measureInWindow, 'call', _5 => _5((x, y, width, height) => {
|
|
283
|
+
latest.current({ x, y, width, height });
|
|
284
|
+
})]);
|
|
285
|
+
}, []);
|
|
286
|
+
const handleLayout = _react.useCallback.call(void 0,
|
|
287
|
+
(event) => {
|
|
288
|
+
_optionalChain([onLayout, 'optionalCall', _6 => _6(event)]);
|
|
289
|
+
measure();
|
|
290
|
+
},
|
|
291
|
+
[measure, onLayout]
|
|
292
|
+
);
|
|
293
|
+
_react.useEffect.call(void 0, () => {
|
|
294
|
+
if (isOpen) measure();
|
|
295
|
+
}, [isOpen, measure]);
|
|
296
|
+
return { node, measure, onLayout: handleLayout };
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// src/components/popover/popover-trigger.tsx
|
|
300
|
+
|
|
301
|
+
var PopoverTrigger = _react.forwardRef.call(void 0,
|
|
302
|
+
function PopoverTrigger2({
|
|
303
|
+
children,
|
|
304
|
+
asChild = false,
|
|
305
|
+
accessibilityRole = "button",
|
|
306
|
+
accessibilityState,
|
|
307
|
+
style,
|
|
308
|
+
onLayout,
|
|
309
|
+
onPress,
|
|
310
|
+
onPressIn,
|
|
311
|
+
onPressOut,
|
|
312
|
+
...props
|
|
313
|
+
}, ref) {
|
|
314
|
+
const { triggerStyle, isOpen, isDisabled, toggle, setAnchor } = usePopover();
|
|
315
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
316
|
+
const [isPressed, press] = _chunk7DPL3ZDScjs.usePressState.call(void 0, { onPressIn, onPressOut });
|
|
317
|
+
const anchor = useAnchorRef({ isOpen, onAnchor: setAnchor, onLayout });
|
|
318
|
+
const refs = _chunkWFEMJCXOcjs.useMergedRef.call(void 0, anchor.node, ref);
|
|
319
|
+
const handlePress = _react.useCallback.call(void 0,
|
|
320
|
+
(event) => {
|
|
321
|
+
_optionalChain([onPress, 'optionalCall', _7 => _7(event)]);
|
|
322
|
+
anchor.measure();
|
|
323
|
+
toggle();
|
|
324
|
+
},
|
|
325
|
+
[anchor, onPress, toggle]
|
|
326
|
+
);
|
|
327
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
328
|
+
_chunkTGMVEHV7cjs.PressableFeedback,
|
|
329
|
+
{
|
|
330
|
+
ref: refs,
|
|
331
|
+
isPressed,
|
|
332
|
+
isDisabled,
|
|
333
|
+
asChild,
|
|
334
|
+
accessibilityRole,
|
|
335
|
+
accessibilityState: {
|
|
336
|
+
disabled: isDisabled,
|
|
337
|
+
expanded: isOpen,
|
|
338
|
+
...accessibilityState
|
|
339
|
+
},
|
|
340
|
+
...rest,
|
|
341
|
+
onLayout: anchor.onLayout,
|
|
342
|
+
style: [
|
|
343
|
+
triggerStyle,
|
|
344
|
+
styleProps,
|
|
345
|
+
typeof style === "function" ? style({ pressed: isPressed }) : style
|
|
346
|
+
],
|
|
347
|
+
onPress: handlePress,
|
|
348
|
+
onPressIn: press.onPressIn,
|
|
349
|
+
onPressOut: press.onPressOut,
|
|
350
|
+
children
|
|
351
|
+
}
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
);
|
|
355
|
+
PopoverTrigger.displayName = "XAUI.Popover.Trigger";
|
|
356
|
+
|
|
357
|
+
// src/components/popover/popover.tsx
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
function Popover({
|
|
361
|
+
children,
|
|
362
|
+
radius,
|
|
363
|
+
isOpen: controlledOpen,
|
|
364
|
+
defaultOpen = false,
|
|
365
|
+
onOpenChange,
|
|
366
|
+
isDisabled = false
|
|
367
|
+
}) {
|
|
368
|
+
const theme = _chunk57SJ4LJFcjs.useXAUITheme.call(void 0, );
|
|
369
|
+
const [anchor, setAnchor] = _react.useState.call(void 0, null);
|
|
370
|
+
const [isOpen, setOpen] = _chunk7EIHHOHPcjs.useControllableState.call(void 0, {
|
|
371
|
+
value: controlledOpen,
|
|
372
|
+
defaultValue: defaultOpen,
|
|
373
|
+
onChange: onOpenChange
|
|
374
|
+
});
|
|
375
|
+
const styles = popoverRecipe.resolve({
|
|
376
|
+
theme,
|
|
377
|
+
selection: { radius },
|
|
378
|
+
states: { disabled: isDisabled }
|
|
379
|
+
});
|
|
380
|
+
const open = _react.useCallback.call(void 0, () => setOpen(true), [setOpen]);
|
|
381
|
+
const close = _react.useCallback.call(void 0, () => setOpen(false), [setOpen]);
|
|
382
|
+
const toggle = _react.useCallback.call(void 0, () => setOpen((current) => !current), [setOpen]);
|
|
383
|
+
const context = _react.useMemo.call(void 0,
|
|
384
|
+
() => ({
|
|
385
|
+
triggerStyle: styles.trigger,
|
|
386
|
+
overlayStyle: styles.overlay,
|
|
387
|
+
contentStyle: styles.content,
|
|
388
|
+
titleStyle: styles.title,
|
|
389
|
+
descriptionStyle: styles.description,
|
|
390
|
+
isOpen,
|
|
391
|
+
isDisabled,
|
|
392
|
+
open,
|
|
393
|
+
close,
|
|
394
|
+
toggle,
|
|
395
|
+
anchor,
|
|
396
|
+
setAnchor
|
|
397
|
+
}),
|
|
398
|
+
[styles, isOpen, isDisabled, open, close, toggle, anchor]
|
|
399
|
+
);
|
|
400
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PopoverProvider, { value: context, children });
|
|
401
|
+
}
|
|
402
|
+
Popover.displayName = "XAUI.Popover.Root";
|
|
403
|
+
|
|
404
|
+
// src/components/popover/index.ts
|
|
405
|
+
var Popover2 = Object.assign(Popover, {
|
|
406
|
+
Trigger: PopoverTrigger,
|
|
407
|
+
Overlay: PopoverOverlay,
|
|
408
|
+
Content: PopoverContent,
|
|
409
|
+
Title: PopoverTitle,
|
|
410
|
+
Description: PopoverDescription,
|
|
411
|
+
Close: PopoverClose
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
exports.usePopover = usePopover; exports.PopoverClose = PopoverClose; exports.popoverRecipe = popoverRecipe; exports.PopoverContent = PopoverContent; exports.PopoverDescription = PopoverDescription; exports.PopoverOverlay = PopoverOverlay; exports.PopoverTitle = PopoverTitle; exports.PopoverTrigger = PopoverTrigger; exports.Popover = Popover; exports.Popover2 = Popover2;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// src/system/anchored/anchored-motion.ts
|
|
2
|
+
import { Easing, Keyframe } from "react-native-reanimated";
|
|
3
|
+
var ENTER_MS = 200;
|
|
4
|
+
var EXIT_MS = 150;
|
|
5
|
+
var TRAVEL = 8;
|
|
6
|
+
function anchoredEntering(placement) {
|
|
7
|
+
const [x, y] = travel(placement);
|
|
8
|
+
return new Keyframe({
|
|
9
|
+
0: {
|
|
10
|
+
opacity: 0,
|
|
11
|
+
transform: [{ translateX: x }, { translateY: y }, { scale: 0.95 }]
|
|
12
|
+
},
|
|
13
|
+
100: {
|
|
14
|
+
opacity: 1,
|
|
15
|
+
transform: [{ translateX: 0 }, { translateY: 0 }, { scale: 1 }],
|
|
16
|
+
easing: Easing.out(Easing.cubic)
|
|
17
|
+
}
|
|
18
|
+
}).duration(ENTER_MS);
|
|
19
|
+
}
|
|
20
|
+
function anchoredExiting(placement) {
|
|
21
|
+
const [x, y] = travel(placement);
|
|
22
|
+
return new Keyframe({
|
|
23
|
+
0: {
|
|
24
|
+
opacity: 1,
|
|
25
|
+
transform: [{ translateX: 0 }, { translateY: 0 }, { scale: 1 }]
|
|
26
|
+
},
|
|
27
|
+
100: {
|
|
28
|
+
opacity: 0,
|
|
29
|
+
transform: [{ translateX: x }, { translateY: y }, { scale: 0.95 }],
|
|
30
|
+
easing: Easing.in(Easing.cubic)
|
|
31
|
+
}
|
|
32
|
+
}).duration(EXIT_MS);
|
|
33
|
+
}
|
|
34
|
+
function travel(placement) {
|
|
35
|
+
switch (placement) {
|
|
36
|
+
case "bottom":
|
|
37
|
+
return [0, -TRAVEL];
|
|
38
|
+
case "top":
|
|
39
|
+
return [0, TRAVEL];
|
|
40
|
+
case "end":
|
|
41
|
+
return [-TRAVEL, 0];
|
|
42
|
+
case "start":
|
|
43
|
+
return [TRAVEL, 0];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
var overlayEntering = new Keyframe({
|
|
47
|
+
0: { opacity: 0 },
|
|
48
|
+
100: { opacity: 1 }
|
|
49
|
+
}).duration(ENTER_MS);
|
|
50
|
+
var overlayExiting = new Keyframe({
|
|
51
|
+
0: { opacity: 1 },
|
|
52
|
+
100: { opacity: 0 }
|
|
53
|
+
}).duration(EXIT_MS);
|
|
54
|
+
|
|
55
|
+
// src/system/anchored/indicator-spring.ts
|
|
56
|
+
var INDICATOR_SPRING = { damping: 140, stiffness: 1e3, mass: 4 };
|
|
57
|
+
var INDICATOR_ROTATION = [0, -180];
|
|
58
|
+
|
|
59
|
+
export {
|
|
60
|
+
anchoredEntering,
|
|
61
|
+
anchoredExiting,
|
|
62
|
+
overlayEntering,
|
|
63
|
+
overlayExiting,
|
|
64
|
+
INDICATOR_SPRING,
|
|
65
|
+
INDICATOR_ROTATION
|
|
66
|
+
};
|