@tamagui/select 1.116.0 → 1.116.2
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/BubbleSelect.js +34 -0
- package/dist/cjs/Select.js +325 -0
- package/dist/cjs/SelectContent.js +45 -0
- package/dist/cjs/SelectImpl.js +224 -0
- package/dist/cjs/SelectItem.js +142 -0
- package/dist/cjs/SelectItemText.js +62 -0
- package/dist/cjs/SelectScrollButton.js +105 -0
- package/dist/cjs/SelectTrigger.js +84 -0
- package/dist/cjs/SelectViewport.js +111 -0
- package/dist/cjs/constants.js +27 -0
- package/dist/cjs/context.js +35 -0
- package/dist/cjs/index.js +16 -0
- package/dist/cjs/types.js +14 -0
- package/dist/cjs/useSelectBreakpointActive.js +25 -0
- package/package.json +23 -23
- package/dist/cjs/SelectContent.native.cjs +0 -28
- package/dist/cjs/SelectContent.native.cjs.map +0 -6
- package/dist/cjs/SelectImpl.native.cjs +0 -29
- package/dist/cjs/SelectImpl.native.cjs.map +0 -6
- package/dist/cjs/SelectScrollButton.native.cjs +0 -28
- package/dist/cjs/SelectScrollButton.native.cjs.map +0 -6
- package/dist/cjs/SelectViewport.native.cjs +0 -55
- package/dist/cjs/SelectViewport.native.cjs.map +0 -6
- /package/dist/cjs/{BubbleSelect.cjs.map → BubbleSelect.js.map} +0 -0
- /package/dist/cjs/{Select.cjs.map → Select.js.map} +0 -0
- /package/dist/cjs/{SelectContent.cjs.map → SelectContent.js.map} +0 -0
- /package/dist/cjs/{SelectImpl.cjs.map → SelectImpl.js.map} +0 -0
- /package/dist/cjs/{SelectItem.cjs.map → SelectItem.js.map} +0 -0
- /package/dist/cjs/{SelectItemText.cjs.map → SelectItemText.js.map} +0 -0
- /package/dist/cjs/{SelectScrollButton.cjs.map → SelectScrollButton.js.map} +0 -0
- /package/dist/cjs/{SelectTrigger.cjs.map → SelectTrigger.js.map} +0 -0
- /package/dist/cjs/{SelectViewport.cjs.map → SelectViewport.js.map} +0 -0
- /package/dist/cjs/{constants.cjs.map → constants.js.map} +0 -0
- /package/dist/cjs/{context.cjs.map → context.js.map} +0 -0
- /package/dist/cjs/{index.cjs.map → index.js.map} +0 -0
- /package/dist/cjs/{types.cjs.map → types.js.map} +0 -0
- /package/dist/cjs/{useSelectBreakpointActive.cjs.map → useSelectBreakpointActive.js.map} +0 -0
|
@@ -0,0 +1,142 @@
|
|
|
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 SelectItem_exports = {};
|
|
24
|
+
__export(SelectItem_exports, {
|
|
25
|
+
SelectItem: () => SelectItem,
|
|
26
|
+
SelectItemContextProvider: () => SelectItemContextProvider,
|
|
27
|
+
useSelectItemContext: () => useSelectItemContext
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(SelectItem_exports);
|
|
30
|
+
var import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_list_item = require("@tamagui/list-item"), React = __toESM(require("react")), import_context = require("./context"), import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
const ITEM_NAME = "SelectItem", [SelectItemContextProvider, useSelectItemContext] = (0, import_context.createSelectContext)(ITEM_NAME), SelectItem = import_list_item.ListItemFrame.styleable(
|
|
32
|
+
function(props, forwardedRef) {
|
|
33
|
+
const {
|
|
34
|
+
__scopeSelect,
|
|
35
|
+
value,
|
|
36
|
+
disabled = !1,
|
|
37
|
+
textValue: textValueProp,
|
|
38
|
+
index,
|
|
39
|
+
...restProps
|
|
40
|
+
} = props, { props: listItemProps } = (0, import_list_item.useListItem)({
|
|
41
|
+
...!props.unstyled && {
|
|
42
|
+
ellipse: !0
|
|
43
|
+
},
|
|
44
|
+
...restProps
|
|
45
|
+
}), context = (0, import_context.useSelectItemParentContext)(ITEM_NAME, __scopeSelect), {
|
|
46
|
+
setSelectedIndex,
|
|
47
|
+
listRef,
|
|
48
|
+
setOpen,
|
|
49
|
+
onChange,
|
|
50
|
+
activeIndexSubscribe,
|
|
51
|
+
valueSubscribe,
|
|
52
|
+
allowMouseUpRef,
|
|
53
|
+
allowSelectRef,
|
|
54
|
+
setValueAtIndex,
|
|
55
|
+
selectTimeoutRef,
|
|
56
|
+
dataRef,
|
|
57
|
+
interactions,
|
|
58
|
+
shouldRenderWebNative,
|
|
59
|
+
size,
|
|
60
|
+
onActiveChange,
|
|
61
|
+
initialValue
|
|
62
|
+
} = context, [isSelected, setSelected] = React.useState(initialValue === value);
|
|
63
|
+
React.useEffect(() => activeIndexSubscribe((i) => {
|
|
64
|
+
index === i && (onActiveChange(value, index), listRef?.current[index]?.focus());
|
|
65
|
+
}), [index]), React.useEffect(() => valueSubscribe((val) => {
|
|
66
|
+
setSelected(val === value);
|
|
67
|
+
}), [value]);
|
|
68
|
+
const textId = React.useId(), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, (node) => {
|
|
69
|
+
import_constants.isWeb && node instanceof HTMLElement && listRef && (listRef.current[index] = node);
|
|
70
|
+
});
|
|
71
|
+
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
72
|
+
setValueAtIndex(index, value);
|
|
73
|
+
}, [index, setValueAtIndex, value]);
|
|
74
|
+
function handleSelect() {
|
|
75
|
+
setSelectedIndex(index), onChange(value), setOpen(!1);
|
|
76
|
+
}
|
|
77
|
+
const selectItemProps = React.useMemo(() => interactions ? interactions.getItemProps({
|
|
78
|
+
onTouchMove() {
|
|
79
|
+
allowSelectRef.current = !0, allowMouseUpRef.current = !1;
|
|
80
|
+
},
|
|
81
|
+
onTouchEnd() {
|
|
82
|
+
allowSelectRef.current = !1, allowMouseUpRef.current = !0;
|
|
83
|
+
},
|
|
84
|
+
onKeyDown(event) {
|
|
85
|
+
event.key === "Enter" || event.key === " " && !dataRef?.current.typing ? (event.preventDefault(), handleSelect()) : allowSelectRef.current = !0;
|
|
86
|
+
},
|
|
87
|
+
onClick() {
|
|
88
|
+
allowSelectRef.current && handleSelect();
|
|
89
|
+
},
|
|
90
|
+
onMouseUp() {
|
|
91
|
+
allowMouseUpRef.current && (allowSelectRef.current && handleSelect(), clearTimeout(selectTimeoutRef.current), selectTimeoutRef.current = setTimeout(() => {
|
|
92
|
+
allowSelectRef.current = !0;
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
}) : {
|
|
96
|
+
onPress: handleSelect
|
|
97
|
+
}, [handleSelect]);
|
|
98
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
99
|
+
SelectItemContextProvider,
|
|
100
|
+
{
|
|
101
|
+
scope: __scopeSelect,
|
|
102
|
+
value,
|
|
103
|
+
textId: textId || "",
|
|
104
|
+
isSelected,
|
|
105
|
+
children: shouldRenderWebNative ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value, children: props.children }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
106
|
+
import_list_item.ListItemFrame,
|
|
107
|
+
{
|
|
108
|
+
tag: "div",
|
|
109
|
+
componentName: ITEM_NAME,
|
|
110
|
+
ref: composedRefs,
|
|
111
|
+
"aria-labelledby": textId,
|
|
112
|
+
"aria-selected": isSelected,
|
|
113
|
+
"data-state": isSelected ? "active" : "inactive",
|
|
114
|
+
"aria-disabled": disabled || void 0,
|
|
115
|
+
"data-disabled": disabled ? "" : void 0,
|
|
116
|
+
tabIndex: disabled ? void 0 : -1,
|
|
117
|
+
...!props.unstyled && {
|
|
118
|
+
backgrounded: !0,
|
|
119
|
+
pressTheme: !0,
|
|
120
|
+
hoverTheme: !0,
|
|
121
|
+
focusTheme: !0,
|
|
122
|
+
cursor: "default",
|
|
123
|
+
size,
|
|
124
|
+
outlineOffset: -0.5,
|
|
125
|
+
focusVisibleStyle: {
|
|
126
|
+
outlineColor: "$outlineColor",
|
|
127
|
+
outlineWidth: 1,
|
|
128
|
+
outlineStyle: "solid"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
...listItemProps,
|
|
132
|
+
...selectItemProps
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
disableTheme: !0
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
//# sourceMappingURL=SelectItem.js.map
|
|
@@ -0,0 +1,62 @@
|
|
|
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 SelectItemText_exports = {};
|
|
24
|
+
__export(SelectItemText_exports, {
|
|
25
|
+
ITEM_TEXT_NAME: () => ITEM_TEXT_NAME,
|
|
26
|
+
SelectItemText: () => SelectItemText,
|
|
27
|
+
SelectItemTextFrame: () => SelectItemTextFrame
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(SelectItemText_exports);
|
|
30
|
+
var import_compose_refs = require("@tamagui/compose-refs"), import_core = require("@tamagui/core"), import_text = require("@tamagui/text"), React = __toESM(require("react")), import_context = require("./context"), import_SelectItem = require("./SelectItem"), import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
const ITEM_TEXT_NAME = "SelectItemText", SelectItemTextFrame = (0, import_core.styled)(import_text.SizableText, {
|
|
32
|
+
name: ITEM_TEXT_NAME,
|
|
33
|
+
variants: {
|
|
34
|
+
unstyled: {
|
|
35
|
+
false: {
|
|
36
|
+
userSelect: "none",
|
|
37
|
+
color: "$color",
|
|
38
|
+
ellipse: !0
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
defaultVariants: {
|
|
43
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
44
|
+
}
|
|
45
|
+
}), SelectItemText = SelectItemTextFrame.styleable(function(props, forwardedRef) {
|
|
46
|
+
const { __scopeSelect, className, ...itemTextProps } = props, context = (0, import_context.useSelectContext)(ITEM_TEXT_NAME, __scopeSelect), itemParentContext = (0, import_context.useSelectItemParentContext)(ITEM_TEXT_NAME, __scopeSelect), ref = React.useRef(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref), itemContext = (0, import_SelectItem.useSelectItemContext)(ITEM_TEXT_NAME, __scopeSelect), contents = React.useRef();
|
|
47
|
+
return contents.current = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
48
|
+
SelectItemTextFrame,
|
|
49
|
+
{
|
|
50
|
+
className,
|
|
51
|
+
size: itemParentContext.size,
|
|
52
|
+
id: itemContext.textId,
|
|
53
|
+
...itemTextProps,
|
|
54
|
+
ref: composedRefs
|
|
55
|
+
}
|
|
56
|
+
), React.useEffect(() => {
|
|
57
|
+
itemParentContext.initialValue === itemContext.value && !context.selectedIndex && context.setSelectedItem(contents.current);
|
|
58
|
+
}, []), React.useEffect(() => itemParentContext.valueSubscribe((val) => {
|
|
59
|
+
val === itemContext.value && context.setSelectedItem(contents.current);
|
|
60
|
+
}), [itemContext.value]), itemParentContext.shouldRenderWebNative ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: props.children }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: contents.current });
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=SelectItemText.js.map
|
|
@@ -0,0 +1,105 @@
|
|
|
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 SelectScrollButton_exports = {};
|
|
24
|
+
__export(SelectScrollButton_exports, {
|
|
25
|
+
SelectScrollDownButton: () => SelectScrollDownButton,
|
|
26
|
+
SelectScrollUpButton: () => SelectScrollUpButton
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(SelectScrollButton_exports);
|
|
29
|
+
var import_react = require("@floating-ui/react"), import_compose_refs = require("@tamagui/compose-refs"), import_stacks = require("@tamagui/stacks"), React = __toESM(require("react")), import_react_dom = require("react-dom"), import_context = require("./context"), import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
+
const SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton", SelectScrollUpButton = React.forwardRef((props, forwardedRef) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
31
|
+
SelectScrollButtonImpl,
|
|
32
|
+
{
|
|
33
|
+
componentName: SCROLL_UP_BUTTON_NAME,
|
|
34
|
+
...props,
|
|
35
|
+
dir: "up",
|
|
36
|
+
ref: forwardedRef
|
|
37
|
+
}
|
|
38
|
+
));
|
|
39
|
+
SelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;
|
|
40
|
+
const SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton", SelectScrollDownButton = React.forwardRef((props, forwardedRef) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
41
|
+
SelectScrollButtonImpl,
|
|
42
|
+
{
|
|
43
|
+
componentName: SCROLL_DOWN_BUTTON_NAME,
|
|
44
|
+
...props,
|
|
45
|
+
dir: "down",
|
|
46
|
+
ref: forwardedRef
|
|
47
|
+
}
|
|
48
|
+
));
|
|
49
|
+
SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
|
|
50
|
+
const SelectScrollButtonImpl = React.memo(
|
|
51
|
+
React.forwardRef(
|
|
52
|
+
(props, forwardedRef) => {
|
|
53
|
+
const { __scopeSelect, dir, componentName, ...scrollIndicatorProps } = props, { forceUpdate, open, fallback, setScrollTop, setInnerOffset, ...context } = (0, import_context.useSelectContext)(componentName, __scopeSelect), floatingRef = context.floatingContext?.refs.floating, statusRef = React.useRef("idle"), isVisible = context[dir === "down" ? "canScrollDown" : "canScrollUp"], frameRef = React.useRef(), { x, y, refs, strategy } = (0, import_react.useFloating)({
|
|
54
|
+
open: open && isVisible,
|
|
55
|
+
strategy: "fixed",
|
|
56
|
+
elements: {
|
|
57
|
+
reference: floatingRef?.current
|
|
58
|
+
},
|
|
59
|
+
placement: dir === "up" ? "top" : "bottom",
|
|
60
|
+
middleware: [(0, import_react.offset)(({ rects }) => -rects.floating.height)],
|
|
61
|
+
whileElementsMounted: (...args) => (0, import_react.autoUpdate)(...args, { animationFrame: !0 })
|
|
62
|
+
}), composedRef = (0, import_compose_refs.useComposedRefs)(forwardedRef, refs.setFloating);
|
|
63
|
+
if (!isVisible)
|
|
64
|
+
return null;
|
|
65
|
+
const onScroll = (amount) => {
|
|
66
|
+
const floating = floatingRef;
|
|
67
|
+
floating && (fallback ? floating.current && (floating.current.scrollTop -= amount, (0, import_react_dom.flushSync)(() => setScrollTop(floating.current?.scrollTop ?? 0))) : (0, import_react_dom.flushSync)(() => setInnerOffset((value) => value - amount)));
|
|
68
|
+
};
|
|
69
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
70
|
+
import_stacks.YStack,
|
|
71
|
+
{
|
|
72
|
+
ref: composedRef,
|
|
73
|
+
componentName,
|
|
74
|
+
"aria-hidden": !0,
|
|
75
|
+
...scrollIndicatorProps,
|
|
76
|
+
zIndex: 1e3,
|
|
77
|
+
position: strategy,
|
|
78
|
+
left: x || 0,
|
|
79
|
+
top: y || 0,
|
|
80
|
+
width: `calc(${(floatingRef?.current?.offsetWidth ?? 0) - 2}px)`,
|
|
81
|
+
onPointerEnter: () => {
|
|
82
|
+
statusRef.current = "active";
|
|
83
|
+
let prevNow = Date.now();
|
|
84
|
+
function frame() {
|
|
85
|
+
const element = floatingRef?.current;
|
|
86
|
+
if (element) {
|
|
87
|
+
const currentNow = Date.now(), msElapsed = currentNow - prevNow;
|
|
88
|
+
prevNow = currentNow;
|
|
89
|
+
const pixelsToScroll = msElapsed / 2, remainingPixels = dir === "up" ? element.scrollTop : element.scrollHeight - element.clientHeight - element.scrollTop, scrollRemaining = dir === "up" ? element.scrollTop - pixelsToScroll > 0 : element.scrollTop + pixelsToScroll < element.scrollHeight - element.clientHeight;
|
|
90
|
+
onScroll(
|
|
91
|
+
dir === "up" ? Math.min(pixelsToScroll, remainingPixels) : Math.max(-pixelsToScroll, -remainingPixels)
|
|
92
|
+
), scrollRemaining && (frameRef.current = requestAnimationFrame(frame));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
cancelAnimationFrame(frameRef.current), frameRef.current = requestAnimationFrame(frame);
|
|
96
|
+
},
|
|
97
|
+
onPointerLeave: () => {
|
|
98
|
+
statusRef.current = "idle", cancelAnimationFrame(frameRef.current);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
);
|
|
105
|
+
//# sourceMappingURL=SelectScrollButton.js.map
|
|
@@ -0,0 +1,84 @@
|
|
|
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 SelectTrigger_exports = {};
|
|
24
|
+
__export(SelectTrigger_exports, {
|
|
25
|
+
SelectTrigger: () => SelectTrigger
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(SelectTrigger_exports);
|
|
28
|
+
var import_compose_refs = require("@tamagui/compose-refs"), import_core = require("@tamagui/core"), import_list_item = require("@tamagui/list-item"), React = __toESM(require("react")), import_context = require("./context"), import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
+
const TRIGGER_NAME = "SelectTrigger", isPointerCoarse = import_core.isWeb && import_core.isClient ? window.matchMedia("(pointer:coarse)").matches : !0, SelectTrigger = React.forwardRef(
|
|
30
|
+
function(props, forwardedRef) {
|
|
31
|
+
const { __scopeSelect, disabled = !1, unstyled = !1, ...triggerProps } = props, context = (0, import_context.useSelectContext)(TRIGGER_NAME, __scopeSelect), itemParentContext = (0, import_context.useSelectItemParentContext)(TRIGGER_NAME, __scopeSelect), composedRefs = (0, import_compose_refs.useComposedRefs)(
|
|
32
|
+
forwardedRef,
|
|
33
|
+
context.floatingContext?.refs.setReference
|
|
34
|
+
);
|
|
35
|
+
return itemParentContext.shouldRenderWebNative ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
36
|
+
import_list_item.ListItem,
|
|
37
|
+
{
|
|
38
|
+
componentName: TRIGGER_NAME,
|
|
39
|
+
unstyled,
|
|
40
|
+
tag: "button",
|
|
41
|
+
type: "button",
|
|
42
|
+
id: itemParentContext.id,
|
|
43
|
+
...!unstyled && {
|
|
44
|
+
backgrounded: !0,
|
|
45
|
+
radiused: !0,
|
|
46
|
+
hoverTheme: !0,
|
|
47
|
+
pressTheme: !0,
|
|
48
|
+
focusable: !0,
|
|
49
|
+
focusVisibleStyle: {
|
|
50
|
+
outlineStyle: "solid",
|
|
51
|
+
outlineWidth: 2,
|
|
52
|
+
outlineColor: "$outlineColor"
|
|
53
|
+
},
|
|
54
|
+
borderWidth: 1,
|
|
55
|
+
size: itemParentContext.size
|
|
56
|
+
},
|
|
57
|
+
"aria-expanded": context.open,
|
|
58
|
+
"aria-autocomplete": "none",
|
|
59
|
+
dir: context.dir,
|
|
60
|
+
disabled,
|
|
61
|
+
"data-disabled": disabled ? "" : void 0,
|
|
62
|
+
...triggerProps,
|
|
63
|
+
ref: composedRefs,
|
|
64
|
+
...itemParentContext.interactions ? {
|
|
65
|
+
...itemParentContext.interactions.getReferenceProps(),
|
|
66
|
+
...isPointerCoarse ? {
|
|
67
|
+
onPress() {
|
|
68
|
+
itemParentContext.setOpen(!context.open);
|
|
69
|
+
}
|
|
70
|
+
} : {
|
|
71
|
+
onMouseDown() {
|
|
72
|
+
context.floatingContext?.update(), itemParentContext.setOpen(!context.open);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} : {
|
|
76
|
+
onPress() {
|
|
77
|
+
itemParentContext.setOpen(!context.open);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
//# sourceMappingURL=SelectTrigger.js.map
|
|
@@ -0,0 +1,111 @@
|
|
|
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)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var SelectViewport_exports = {};
|
|
16
|
+
__export(SelectViewport_exports, {
|
|
17
|
+
SelectViewport: () => SelectViewport,
|
|
18
|
+
SelectViewportFrame: () => SelectViewportFrame
|
|
19
|
+
});
|
|
20
|
+
module.exports = __toCommonJS(SelectViewport_exports);
|
|
21
|
+
var import_react = require("@floating-ui/react"), import_adapt = require("@tamagui/adapt"), import_animate_presence = require("@tamagui/animate-presence"), import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_core = require("@tamagui/core"), import_stacks = require("@tamagui/stacks"), import_constants2 = require("./constants"), import_context = require("./context"), import_jsx_runtime = require("react/jsx-runtime");
|
|
22
|
+
const SelectViewportFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
23
|
+
name: import_constants2.VIEWPORT_NAME,
|
|
24
|
+
variants: {
|
|
25
|
+
unstyled: {
|
|
26
|
+
false: {
|
|
27
|
+
size: "$2",
|
|
28
|
+
backgroundColor: "$background",
|
|
29
|
+
elevate: !0,
|
|
30
|
+
bordered: !0,
|
|
31
|
+
userSelect: "none",
|
|
32
|
+
outlineWidth: 0
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
size: {
|
|
36
|
+
"...size": (val, { tokens }) => ({
|
|
37
|
+
borderRadius: tokens.radius[val] ?? val
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
defaultVariants: {
|
|
42
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
43
|
+
}
|
|
44
|
+
}), SelectViewport = SelectViewportFrame.styleable(
|
|
45
|
+
function(props, forwardedRef) {
|
|
46
|
+
const { __scopeSelect, children, disableScroll, ...viewportProps } = props, context = (0, import_context.useSelectContext)(import_constants2.VIEWPORT_NAME, __scopeSelect), itemContext = (0, import_context.useSelectItemParentContext)(import_constants2.VIEWPORT_NAME, __scopeSelect), isAdapted = (0, import_adapt.useAdaptIsActive)();
|
|
47
|
+
if ((0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
48
|
+
context.update && context.update();
|
|
49
|
+
}, [isAdapted]), itemContext.shouldRenderWebNative)
|
|
50
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
51
|
+
if (isAdapted || !import_constants.isWeb)
|
|
52
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_adapt.AdaptPortalContents, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
53
|
+
import_context.ForwardSelectContext,
|
|
54
|
+
{
|
|
55
|
+
__scopeSelect,
|
|
56
|
+
itemContext,
|
|
57
|
+
context,
|
|
58
|
+
children
|
|
59
|
+
}
|
|
60
|
+
) });
|
|
61
|
+
if (!itemContext.interactions)
|
|
62
|
+
return process.env.NODE_ENV === "development" && console.warn("No interactions provided to Select, potentially missing Adapt"), null;
|
|
63
|
+
const {
|
|
64
|
+
style,
|
|
65
|
+
// remove this, it was set to "Select" always
|
|
66
|
+
className,
|
|
67
|
+
...floatingProps
|
|
68
|
+
} = itemContext.interactions.getFloatingProps(), composedRefs = (0, import_compose_refs.composeRefs)(
|
|
69
|
+
forwardedRef,
|
|
70
|
+
context.floatingContext?.refs.setFloating
|
|
71
|
+
);
|
|
72
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
73
|
+
!disableScroll && !props.unstyled && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
74
|
+
"style",
|
|
75
|
+
{
|
|
76
|
+
dangerouslySetInnerHTML: {
|
|
77
|
+
__html: selectViewportCSS
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, { children: context.open ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.FloatingFocusManager, { context: context.floatingContext, modal: !1, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
82
|
+
SelectViewportFrame,
|
|
83
|
+
{
|
|
84
|
+
size: itemContext.size,
|
|
85
|
+
role: "presentation",
|
|
86
|
+
...viewportProps,
|
|
87
|
+
...style,
|
|
88
|
+
...floatingProps,
|
|
89
|
+
...!props.unstyled && {
|
|
90
|
+
overflowY: disableScroll ? void 0 : style.overflow ?? "auto"
|
|
91
|
+
},
|
|
92
|
+
ref: composedRefs,
|
|
93
|
+
children
|
|
94
|
+
},
|
|
95
|
+
"select-viewport"
|
|
96
|
+
) }) : null }),
|
|
97
|
+
!context.open && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { display: "none" }, children: props.children })
|
|
98
|
+
] });
|
|
99
|
+
}
|
|
100
|
+
), selectViewportCSS = `
|
|
101
|
+
.is_SelectViewport {
|
|
102
|
+
scrollbar-width: none;
|
|
103
|
+
-webkit-overflow-scrolling: touch;
|
|
104
|
+
overscroll-behavior: contain;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.is_SelectViewport::-webkit-scrollbar{
|
|
108
|
+
display:none
|
|
109
|
+
}
|
|
110
|
+
`;
|
|
111
|
+
//# sourceMappingURL=SelectViewport.js.map
|
|
@@ -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)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var constants_exports = {};
|
|
16
|
+
__export(constants_exports, {
|
|
17
|
+
FALLBACK_THRESHOLD: () => FALLBACK_THRESHOLD,
|
|
18
|
+
MIN_HEIGHT: () => MIN_HEIGHT,
|
|
19
|
+
SCROLL_ARROW_THRESHOLD: () => SCROLL_ARROW_THRESHOLD,
|
|
20
|
+
SCROLL_ARROW_VELOCITY: () => SCROLL_ARROW_VELOCITY,
|
|
21
|
+
SELECT_NAME: () => SELECT_NAME,
|
|
22
|
+
VIEWPORT_NAME: () => VIEWPORT_NAME,
|
|
23
|
+
WINDOW_PADDING: () => WINDOW_PADDING
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(constants_exports);
|
|
26
|
+
const SELECT_NAME = "Select", WINDOW_PADDING = 8, SCROLL_ARROW_VELOCITY = 8, SCROLL_ARROW_THRESHOLD = 8, MIN_HEIGHT = 80, FALLBACK_THRESHOLD = 16, VIEWPORT_NAME = "SelectViewport";
|
|
27
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -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)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var context_exports = {};
|
|
16
|
+
__export(context_exports, {
|
|
17
|
+
ForwardSelectContext: () => ForwardSelectContext,
|
|
18
|
+
SelectItemParentProvider: () => SelectItemParentProvider,
|
|
19
|
+
SelectProvider: () => SelectProvider,
|
|
20
|
+
createSelectContext: () => createSelectContext,
|
|
21
|
+
createSelectItemParentContext: () => createSelectItemParentContext,
|
|
22
|
+
createSelectItemParentScope: () => createSelectItemParentScope,
|
|
23
|
+
createSelectScope: () => createSelectScope,
|
|
24
|
+
useSelectContext: () => useSelectContext,
|
|
25
|
+
useSelectItemParentContext: () => useSelectItemParentContext
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(context_exports);
|
|
28
|
+
var import_create_context = require("@tamagui/create-context"), import_constants = require("./constants"), import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
+
const [createSelectContext, createSelectScope] = (0, import_create_context.createContextScope)(import_constants.SELECT_NAME), [SelectProvider, useSelectContext] = createSelectContext(import_constants.SELECT_NAME), [createSelectItemParentContext, createSelectItemParentScope] = (0, import_create_context.createContextScope)(import_constants.SELECT_NAME), [SelectItemParentProvider, useSelectItemParentContext] = createSelectContext(import_constants.SELECT_NAME), ForwardSelectContext = ({
|
|
30
|
+
__scopeSelect,
|
|
31
|
+
context,
|
|
32
|
+
itemContext,
|
|
33
|
+
children
|
|
34
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectProvider, { isInSheet: !0, scope: __scopeSelect, ...context, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItemParentProvider, { scope: __scopeSelect, ...itemContext, children }) });
|
|
35
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
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("./Select"), module.exports);
|
|
15
|
+
__reExport(src_exports, require("./context"), module.exports);
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
};
|
|
11
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
+
var types_exports = {};
|
|
13
|
+
module.exports = __toCommonJS(types_exports);
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
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)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var useSelectBreakpointActive_exports = {};
|
|
16
|
+
__export(useSelectBreakpointActive_exports, {
|
|
17
|
+
useShowSelectSheet: () => useShowSelectSheet
|
|
18
|
+
});
|
|
19
|
+
module.exports = __toCommonJS(useSelectBreakpointActive_exports);
|
|
20
|
+
var import_adapt = require("@tamagui/adapt");
|
|
21
|
+
const useShowSelectSheet = (context) => {
|
|
22
|
+
const breakpointActive = (0, import_adapt.useAdaptIsActive)();
|
|
23
|
+
return context.open === !1 ? !1 : breakpointActive;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=useSelectBreakpointActive.js.map
|