@tamagui/select 3.0.0-beta.924.1 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Select.cjs +23 -25
- package/dist/cjs/Select.native.cjs +27 -26
- package/dist/cjs/Select.native.js +27 -26
- package/dist/cjs/Select.native.js.map +1 -1
- package/dist/cjs/SelectImpl.cjs +67 -63
- package/dist/cjs/SelectItem.cjs +49 -60
- package/dist/cjs/SelectItem.native.cjs +51 -79
- package/dist/cjs/SelectItem.native.js +51 -79
- package/dist/cjs/SelectItem.native.js.map +1 -1
- package/dist/cjs/SelectScrollButton.cjs +9 -25
- package/dist/cjs/SelectTrigger.cjs +22 -5
- package/dist/cjs/SelectTrigger.native.cjs +15 -5
- package/dist/cjs/SelectTrigger.native.js +15 -5
- package/dist/cjs/SelectTrigger.native.js.map +1 -1
- package/dist/cjs/SelectViewport.cjs +29 -32
- package/dist/cjs/SelectViewport.native.cjs +2 -2
- package/dist/cjs/SelectViewport.native.js +2 -2
- package/dist/cjs/SelectViewport.native.js.map +1 -1
- package/dist/cjs/selectionController.cjs +15 -5
- package/dist/cjs/selectionController.native.cjs +20 -15
- package/dist/cjs/selectionController.native.js +20 -15
- package/dist/cjs/selectionController.native.js.map +1 -1
- package/dist/esm/Select.mjs +27 -28
- package/dist/esm/Select.mjs.map +1 -1
- package/dist/esm/Select.native.js +31 -29
- package/dist/esm/Select.native.js.map +1 -1
- package/dist/esm/SelectImpl.mjs +68 -64
- package/dist/esm/SelectImpl.mjs.map +1 -1
- package/dist/esm/SelectItem.mjs +50 -61
- package/dist/esm/SelectItem.mjs.map +1 -1
- package/dist/esm/SelectItem.native.js +52 -80
- package/dist/esm/SelectItem.native.js.map +1 -1
- package/dist/esm/SelectScrollButton.mjs +10 -26
- package/dist/esm/SelectScrollButton.mjs.map +1 -1
- package/dist/esm/SelectTrigger.mjs +16 -5
- package/dist/esm/SelectTrigger.mjs.map +1 -1
- package/dist/esm/SelectTrigger.native.js +15 -4
- package/dist/esm/SelectTrigger.native.js.map +1 -1
- package/dist/esm/SelectViewport.mjs +30 -33
- package/dist/esm/SelectViewport.mjs.map +1 -1
- package/dist/esm/SelectViewport.native.js +3 -3
- package/dist/esm/SelectViewport.native.js.map +1 -1
- package/dist/esm/selectionController.mjs +15 -5
- package/dist/esm/selectionController.mjs.map +1 -1
- package/dist/esm/selectionController.native.js +20 -15
- package/dist/esm/selectionController.native.js.map +1 -1
- package/dist/jsx/Select.mjs +27 -28
- package/dist/jsx/Select.mjs.map +1 -1
- package/dist/jsx/Select.native.cjs +27 -26
- package/dist/jsx/Select.native.js +27 -26
- package/dist/jsx/Select.native.js.map +1 -1
- package/dist/jsx/SelectImpl.mjs +68 -64
- package/dist/jsx/SelectImpl.mjs.map +1 -1
- package/dist/jsx/SelectItem.mjs +50 -61
- package/dist/jsx/SelectItem.mjs.map +1 -1
- package/dist/jsx/SelectItem.native.cjs +51 -79
- package/dist/jsx/SelectItem.native.js +51 -79
- package/dist/jsx/SelectItem.native.js.map +1 -1
- package/dist/jsx/SelectScrollButton.mjs +10 -26
- package/dist/jsx/SelectScrollButton.mjs.map +1 -1
- package/dist/jsx/SelectTrigger.mjs +16 -5
- package/dist/jsx/SelectTrigger.mjs.map +1 -1
- package/dist/jsx/SelectTrigger.native.cjs +15 -5
- package/dist/jsx/SelectTrigger.native.js +15 -5
- package/dist/jsx/SelectTrigger.native.js.map +1 -1
- package/dist/jsx/SelectViewport.mjs +30 -33
- package/dist/jsx/SelectViewport.mjs.map +1 -1
- package/dist/jsx/SelectViewport.native.cjs +2 -2
- package/dist/jsx/SelectViewport.native.js +2 -2
- package/dist/jsx/SelectViewport.native.js.map +1 -1
- package/dist/jsx/selectionController.mjs +15 -5
- package/dist/jsx/selectionController.mjs.map +1 -1
- package/dist/jsx/selectionController.native.cjs +20 -15
- package/dist/jsx/selectionController.native.js +20 -15
- package/dist/jsx/selectionController.native.js.map +1 -1
- package/package.json +30 -29
- package/src/Select.tsx +41 -41
- package/src/SelectImpl.tsx +107 -95
- package/src/SelectItem.tsx +66 -91
- package/src/SelectScrollButton.tsx +14 -32
- package/src/SelectTrigger.tsx +19 -2
- package/src/SelectViewport.native.tsx +4 -4
- package/src/SelectViewport.tsx +34 -30
- package/src/selectionController.ts +20 -5
- package/src/types.tsx +26 -22
- package/types/Select.d.ts +42 -81
- package/types/Select.d.ts.map +1 -1
- package/types/SelectImpl.d.ts.map +1 -1
- package/types/SelectItem.d.ts +3 -5
- package/types/SelectItem.d.ts.map +1 -1
- package/types/SelectItemText.d.ts +3 -5
- package/types/SelectItemText.d.ts.map +1 -1
- package/types/SelectScrollButton.d.ts +5 -9
- package/types/SelectScrollButton.d.ts.map +1 -1
- package/types/SelectScrollButton.native.d.ts +5 -9
- package/types/SelectScrollButton.native.d.ts.map +1 -1
- package/types/SelectTrigger.d.ts +3 -5
- package/types/SelectTrigger.d.ts.map +1 -1
- package/types/SelectViewport.d.ts +4 -9
- package/types/SelectViewport.d.ts.map +1 -1
- package/types/SelectViewport.native.d.ts +4 -9
- package/types/SelectViewport.native.d.ts.map +1 -1
- package/types/selectionController.d.ts +2 -0
- package/types/selectionController.d.ts.map +1 -1
- package/types/types.d.ts +30 -22
- package/types/types.d.ts.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectTrigger.native.js","names":[],"sources":["jsx/SelectTrigger.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n\tfor (var name in all) __defProp(target, name, {\n\t\tget: all[name],\n\t\tenumerable: true\n\t});\n};\nvar __copyProps = (to, from, except, desc) => {\n\tif (from && typeof from === \"object\" || typeof from === \"function\") {\n\t\tfor (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {\n\t\t\tget: () => from[key],\n\t\t\tenumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable\n\t\t});\n\t}\n\treturn to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n\t// If the importer is in node compatibility mode or this is not an ESM\n\t// file that has been converted to a CommonJS file using a Babel-\n\t// compatible transform (i.e. \"__esModule\" has not been set), then set\n\t// \"default\" to the CommonJS \"module.exports\" for node compatibility.\n\tisNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", {\n\t\tvalue: mod,\n\t\tenumerable: true\n\t}) : target,\n\tmod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar SelectTrigger_exports = {};\n__export(SelectTrigger_exports, {\n\tSelectTrigger: () => SelectTrigger,\n\tSelectTriggerFrame: () => SelectTriggerFrame\n});\nmodule.exports = __toCommonJS(SelectTrigger_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_compose_refs = require(\"@tamagui/compose-refs\");\nvar import_constants = require(\"@tamagui/constants\");\nvar import_core = require(\"@tamagui/core\");\nvar import_helpers = require(\"@tamagui/helpers\");\
|
|
1
|
+
{"version":3,"file":"SelectTrigger.native.js","names":[],"sources":["jsx/SelectTrigger.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n\tfor (var name in all) __defProp(target, name, {\n\t\tget: all[name],\n\t\tenumerable: true\n\t});\n};\nvar __copyProps = (to, from, except, desc) => {\n\tif (from && typeof from === \"object\" || typeof from === \"function\") {\n\t\tfor (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {\n\t\t\tget: () => from[key],\n\t\t\tenumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable\n\t\t});\n\t}\n\treturn to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n\t// If the importer is in node compatibility mode or this is not an ESM\n\t// file that has been converted to a CommonJS file using a Babel-\n\t// compatible transform (i.e. \"__esModule\" has not been set), then set\n\t// \"default\" to the CommonJS \"module.exports\" for node compatibility.\n\tisNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", {\n\t\tvalue: mod,\n\t\tenumerable: true\n\t}) : target,\n\tmod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar SelectTrigger_exports = {};\n__export(SelectTrigger_exports, {\n\tSelectTrigger: () => SelectTrigger,\n\tSelectTriggerFrame: () => SelectTriggerFrame\n});\nmodule.exports = __toCommonJS(SelectTrigger_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_compose_refs = require(\"@tamagui/compose-refs\");\nvar import_constants = require(\"@tamagui/constants\");\nvar import_core = require(\"@tamagui/core\");\nvar import_helpers = require(\"@tamagui/helpers\");\nvar React = __toESM(require(\"react\"), 1);\nvar import_context = require(\"./context\");\nvar SelectTriggerFrame = (0, import_core.styled)(import_core.View, {\n\tdisplayName: \"SelectTrigger\",\n\talignItems: \"center\",\n\tflexDirection: \"row\",\n\trender: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(\"button\", { type: \"button\" })\n});\nvar SelectTrigger = (0, import_core.createStyledHOC)(SelectTriggerFrame, function SelectTrigger2(props, forwardedRef) {\n\tvar _context_floatingContext;\n\tvar { scope, disabled = false, ...triggerProps } = props;\n\tvar context = (0, import_context.useSelectContext)(scope);\n\tvar itemParentContext = (0, import_context.useSelectItemParentContext)(scope);\n\tvar composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, (_context_floatingContext = context.floatingContext) === null || _context_floatingContext === void 0 ? void 0 : _context_floatingContext.refs.setReference);\n\tvar pressIsTouch = React.useRef(false);\n\tif (itemParentContext.shouldRenderWebNative) return null;\n\tvar toggleOpen = function(event) {\n\t\tvar reason = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : \"trigger-press\";\n\t\tif (!disabled) itemParentContext.requestOpenChange(!context.open, (0, import_core.createChangeEventDetails)(reason, (event === null || event === void 0 ? void 0 : event.nativeEvent) || event, event === null || event === void 0 ? void 0 : event.currentTarget));\n\t};\n\tvar interactionProps = {\n\t\t...triggerProps,\n\t\t...import_constants.isWeb ? {\n\t\t\tonMouseDown: (0, import_helpers.composeEventHandlers)(triggerProps.onMouseDown, function(event) {\n\t\t\t\tpressIsTouch.current = event.type === \"touchstart\";\n\t\t\t\tif (pressIsTouch.current) return;\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttoggleOpen(event);\n\t\t\t}),\n\t\t\tonPress: (0, import_helpers.composeEventHandlers)(triggerProps.onPress, function(event) {\n\t\t\t\tif (!pressIsTouch.current) return;\n\t\t\t\tpressIsTouch.current = false;\n\t\t\t\ttoggleOpen(event);\n\t\t\t})\n\t\t} : { onPress: (0, import_helpers.composeEventHandlers)(triggerProps.onPress, toggleOpen) },\n\t\tonKeyDown: (0, import_helpers.composeEventHandlers)(triggerProps.onKeyDown, function(event) {\n\t\t\tif (event.key === \"Enter\" || event.key === \" \") {\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttoggleOpen(event, \"keyboard\");\n\t\t\t}\n\t\t})\n\t};\n\treturn /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectTriggerFrame, {\n\t\ttype: \"button\",\n\t\tid: itemParentContext.id,\n\t\trole: \"combobox\",\n\t\t\"aria-haspopup\": \"listbox\",\n\t\t\"aria-expanded\": context.open,\n\t\t\"aria-autocomplete\": \"none\",\n\t\taccessibilityRole: import_constants.isWeb ? void 0 : \"button\",\n\t\taccessibilityState: import_constants.isWeb ? void 0 : {\n\t\t\texpanded: context.open,\n\t\t\tdisabled\n\t\t},\n\t\tdir: context.dir,\n\t\tdisabled,\n\t\t\"data-disabled\": disabled ? \"\" : void 0,\n\t\t...interactionProps,\n\t\tref: composedRefs\n\t});\n});\n//# sourceMappingURL=SelectTrigger.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC/B,KAAK,IAAI,QAAQ,KAAK,UAAU,QAAQ,MAAM;EAC7C,KAAK,IAAI;EACT,YAAY;CACb,CAAC;AACF;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC7C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EACnE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GAAG,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QAAQ,UAAU,IAAI,KAAK;GAC9G,WAAW,KAAK;GAChB,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAC3D,CAAC;CACF;CACA,OAAO;AACR;AACA,IAAI,WAAW,KAAK,YAAY,YAAY,SAAS,OAAO,OAAO,SAAS,aAAa,GAAG,CAAC,IAAI,CAAC,GAAG,YAKpG,cAAc,CAAC,OAAO,CAAC,IAAI,aAAa,UAAU,QAAQ,WAAW;CACpE,OAAO;CACP,YAAY;AACb,CAAC,IAAI,QACL,GACD;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,wBAAwB,CAAC;AAC7B,SAAS,uBAAuB;CAC/B,qBAAqB;CACrB,0BAA0B;AAC3B,CAAC;AACD,OAAO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,CAAC;CACnQ;CACA,IAAI,mBAAmB;EACtB,GAAG;EACH,GAAG,iBAAiB,QAAQ;GAC3B,cAAc,GAAG,eAAe,qBAAoB,CAAE,aAAa,aAAa,SAAS,OAAO;IAC/F,aAAa,UAAU,MAAM,SAAS;IACtC,IAAI,aAAa,SAAS;IAC1B,MAAM,eAAe;IACrB,WAAW,KAAK;GACjB,CAAC;GACD,UAAU,GAAG,eAAe,qBAAoB,CAAE,aAAa,SAAS,SAAS,OAAO;IACvF,IAAI,CAAC,aAAa,SAAS;IAC3B,aAAa,UAAU;IACvB,WAAW,KAAK;GACjB,CAAC;EACF,IAAI,EAAE,UAAU,GAAG,eAAe,qBAAoB,CAAE,aAAa,SAAS,UAAU,EAAE;EAC1F,YAAY,GAAG,eAAe,qBAAoB,CAAE,aAAa,WAAW,SAAS,OAAO;GAC3F,IAAI,MAAM,QAAQ,WAAW,MAAM,QAAQ,KAAK;IAC/C,MAAM,eAAe;IACrB,WAAW,OAAO,UAAU;GAC7B;EACD,CAAC;CACF;CACA,OAAuB,iBAAC,GAAG,mBAAmB,IAAG,CAAE,oBAAoB;EACtE,MAAM;EACN,IAAI,kBAAkB;EACtB,MAAM;EACN,iBAAiB;EACjB,iBAAiB,QAAQ;EACzB,qBAAqB;EACrB,mBAAmB,iBAAiB,QAAQ,KAAK,IAAI;EACrD,oBAAoB,iBAAiB,QAAQ,KAAK,IAAI;GACrD,UAAU,QAAQ;GAClB;EACD;EACA,KAAK,QAAQ;EACb;EACA,iBAAiB,WAAW,KAAK,KAAK;EACtC,GAAG;EACH,KAAK;CACN,CAAC;AACF,CAAC"}
|
|
@@ -2,10 +2,9 @@ import { AdaptPortalContents, useAdaptIsActive } from "@tamagui/adapt";
|
|
|
2
2
|
import { AnimatePresence } from "@tamagui/animate-presence";
|
|
3
3
|
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
4
4
|
import { isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
5
|
-
import { View, createStyledHOC, styled } from "@tamagui/core";
|
|
5
|
+
import { View, createStyledHOC, splitStyleProps, styled } from "@tamagui/core";
|
|
6
6
|
import { needsPortalRepropagation } from "@tamagui/portal";
|
|
7
7
|
import { YStack } from "@tamagui/stacks";
|
|
8
|
-
import { startTransition } from "@tamagui/start-transition";
|
|
9
8
|
import * as React from "react";
|
|
10
9
|
import { VIEWPORT_NAME } from "./constants.mjs";
|
|
11
10
|
import { ForwardSelectContext, useSelectContext, useSelectItemParentContext } from "./context.mjs";
|
|
@@ -17,6 +16,10 @@ const SelectViewportFrame = styled(View, {
|
|
|
17
16
|
position: "relative"
|
|
18
17
|
});
|
|
19
18
|
const needsRepropagation = needsPortalRepropagation();
|
|
19
|
+
const getSheetFrameProps = (props) => {
|
|
20
|
+
const { className, style, "data-tamagui-hoc-class": _hocClassNames, ...rest } = props;
|
|
21
|
+
return splitStyleProps(rest)[1];
|
|
22
|
+
};
|
|
20
23
|
const SelectViewport = createStyledHOC(SelectViewportFrame, function SelectViewport2(props, forwardedRef) {
|
|
21
24
|
const { scope, children, disableScroll, ...viewportProps } = props;
|
|
22
25
|
const context = useSelectContext(scope);
|
|
@@ -24,19 +27,9 @@ const SelectViewport = createStyledHOC(SelectViewportFrame, function SelectViewp
|
|
|
24
27
|
const isAdapted = useAdaptIsActive(context.adaptScope);
|
|
25
28
|
const viewportRef = React.useRef(null);
|
|
26
29
|
const registeredItemCount = itemContext.registry.getItems().length;
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (!context.open) return;
|
|
31
|
-
if (lazyMounted) return;
|
|
32
|
-
startTransition(() => {
|
|
33
|
-
setLazyMounted(true);
|
|
34
|
-
});
|
|
35
|
-
}, [
|
|
36
|
-
context.lazyMount,
|
|
37
|
-
context.open,
|
|
38
|
-
lazyMounted
|
|
39
|
-
]);
|
|
30
|
+
const hasOpenedRef = React.useRef(!context.lazyMount);
|
|
31
|
+
if (context.open) hasOpenedRef.current = true;
|
|
32
|
+
const lazyMounted = hasOpenedRef.current;
|
|
40
33
|
React.useEffect(() => {
|
|
41
34
|
if (!isWeb || !isAdapted || !context.open) return;
|
|
42
35
|
const frame = requestAnimationFrame(() => {
|
|
@@ -46,7 +39,6 @@ const SelectViewport = createStyledHOC(SelectViewportFrame, function SelectViewp
|
|
|
46
39
|
});
|
|
47
40
|
return () => cancelAnimationFrame(frame);
|
|
48
41
|
}, [
|
|
49
|
-
context.activeIndex,
|
|
50
42
|
context.open,
|
|
51
43
|
isAdapted,
|
|
52
44
|
registeredItemCount
|
|
@@ -58,11 +50,11 @@ const SelectViewport = createStyledHOC(SelectViewportFrame, function SelectViewp
|
|
|
58
50
|
}
|
|
59
51
|
}, [isAdapted]);
|
|
60
52
|
React.useEffect(() => {
|
|
61
|
-
if (context.lazyMount &&
|
|
53
|
+
if (context.lazyMount && context.open && context.update) {
|
|
62
54
|
const frame = requestAnimationFrame(context.update);
|
|
63
55
|
return () => cancelAnimationFrame(frame);
|
|
64
56
|
}
|
|
65
|
-
}, [
|
|
57
|
+
}, [context.open, registeredItemCount]);
|
|
66
58
|
if (itemContext.shouldRenderWebNative) {
|
|
67
59
|
return /* @__PURE__ */ jsx(YStack, {
|
|
68
60
|
position: "relative",
|
|
@@ -70,8 +62,9 @@ const SelectViewport = createStyledHOC(SelectViewportFrame, function SelectViewp
|
|
|
70
62
|
});
|
|
71
63
|
}
|
|
72
64
|
if (isAdapted || !isWeb) {
|
|
65
|
+
const frameProps = isAdapted ? getSheetFrameProps(viewportProps) : viewportProps;
|
|
73
66
|
let content = /* @__PURE__ */ jsx(SelectViewportFrame, {
|
|
74
|
-
...
|
|
67
|
+
...frameProps,
|
|
75
68
|
...isWeb ? getSelectListboxProps(itemContext.mode) : {},
|
|
76
69
|
"data-select-viewport": "",
|
|
77
70
|
ref: composedRefs,
|
|
@@ -89,23 +82,27 @@ const SelectViewport = createStyledHOC(SelectViewportFrame, function SelectViewp
|
|
|
89
82
|
children: content
|
|
90
83
|
});
|
|
91
84
|
}
|
|
92
|
-
if (!
|
|
85
|
+
if (!context.interactions) {
|
|
93
86
|
return null;
|
|
94
87
|
}
|
|
95
|
-
const
|
|
88
|
+
const floatingProps = context.interactions.getFloatingProps();
|
|
96
89
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
97
90
|
!disableScroll && /* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: selectViewportCSS } }),
|
|
98
|
-
/* @__PURE__ */ jsx(AnimatePresence, {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
91
|
+
/* @__PURE__ */ jsx(AnimatePresence, {
|
|
92
|
+
presenceAffectsLayout: false,
|
|
93
|
+
children: context.open ? /* @__PURE__ */ jsx(SelectViewportFrame, {
|
|
94
|
+
"data-select-viewport": "",
|
|
95
|
+
...isWeb && { "data-state": context.open ? "open" : "closed" },
|
|
96
|
+
...viewportProps,
|
|
97
|
+
...context.floatingPosition,
|
|
98
|
+
outlineWidth: 0,
|
|
99
|
+
...floatingProps,
|
|
100
|
+
...getSelectListboxProps(itemContext.mode),
|
|
101
|
+
overflowY: disableScroll ? void 0 : "auto",
|
|
102
|
+
ref: composedRefs,
|
|
103
|
+
children: lazyMounted ? children : null
|
|
104
|
+
}, "select-viewport") : null
|
|
105
|
+
}),
|
|
109
106
|
!context.open && !(context.lazyMount && context.renderValue) && lazyMounted && /* @__PURE__ */ jsx("div", {
|
|
110
107
|
style: { display: "none" },
|
|
111
108
|
children
|
|
@@ -116,7 +113,7 @@ const selectViewportCSS = `
|
|
|
116
113
|
[data-select-viewport] {
|
|
117
114
|
scrollbar-width: none;
|
|
118
115
|
-webkit-overflow-scrolling: touch;
|
|
119
|
-
overscroll-behavior:
|
|
116
|
+
overscroll-behavior: none;
|
|
120
117
|
}
|
|
121
118
|
|
|
122
119
|
[data-select-viewport]::-webkit-scrollbar{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectViewport.js","names":[],"sources":["jsx/SelectViewport.js"],"sourcesContent":["import { AdaptPortalContents, useAdaptIsActive } from \"@tamagui/adapt\";\nimport { AnimatePresence } from \"@tamagui/animate-presence\";\nimport { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { isWeb, useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createStyledHOC, styled, View } from \"@tamagui/core\";\nimport { needsPortalRepropagation } from \"@tamagui/portal\";\nimport { YStack } from \"@tamagui/stacks\";\nimport
|
|
1
|
+
{"version":3,"file":"SelectViewport.js","names":[],"sources":["jsx/SelectViewport.js"],"sourcesContent":["import { AdaptPortalContents, useAdaptIsActive } from \"@tamagui/adapt\";\nimport { AnimatePresence } from \"@tamagui/animate-presence\";\nimport { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { isWeb, useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createStyledHOC, splitStyleProps, styled, View } from \"@tamagui/core\";\nimport { needsPortalRepropagation } from \"@tamagui/portal\";\nimport { YStack } from \"@tamagui/stacks\";\nimport * as React from \"react\";\nimport { VIEWPORT_NAME } from \"./constants\";\nimport {\n ForwardSelectContext,\n useSelectContext,\n useSelectItemParentContext\n} from \"./context\";\nimport { getSelectListboxProps } from \"./selectionController\";\nimport { Fragment, jsx, jsxs } from \"react/jsx-runtime\";\nconst SelectViewportFrame = styled(View, {\n displayName: VIEWPORT_NAME,\n position: \"relative\"\n});\nconst needsRepropagation = needsPortalRepropagation();\nconst getSheetFrameProps = (props) => {\n const { className, style, \"data-tamagui-hoc-class\": _hocClassNames, ...rest } = props;\n return splitStyleProps(rest)[1];\n};\nconst SelectViewport = createStyledHOC(\n SelectViewportFrame,\n function SelectViewport2(props, forwardedRef) {\n const { scope, children, disableScroll, ...viewportProps } = props;\n const context = useSelectContext(scope);\n const itemContext = useSelectItemParentContext(scope);\n const isAdapted = useAdaptIsActive(context.adaptScope);\n const viewportRef = React.useRef(null);\n const registeredItemCount = itemContext.registry.getItems().length;\n const hasOpenedRef = React.useRef(!context.lazyMount);\n if (context.open) hasOpenedRef.current = true;\n const lazyMounted = hasOpenedRef.current;\n React.useEffect(() => {\n if (!isWeb || !isAdapted || !context.open) return;\n const frame = requestAnimationFrame(() => {\n const index = context.activeIndexRef.current ?? itemContext.registry.firstEnabledIndex();\n const activeItem = viewportRef.current?.querySelector(\n '[role=\"option\"][tabindex=\"0\"]'\n ) ?? (index >= 0 ? itemContext.listRef?.current[index] : null);\n activeItem?.focus();\n });\n return () => cancelAnimationFrame(frame);\n }, [context.open, isAdapted, registeredItemCount]);\n const composedRefs = useComposedRefs(\n // @ts-ignore react 19 ref type mismatch\n forwardedRef,\n viewportRef,\n context.floatingContext?.refs.setFloating\n );\n useIsomorphicLayoutEffect(() => {\n if (context.update) {\n context.update();\n }\n }, [isAdapted]);\n React.useEffect(() => {\n if (context.lazyMount && context.open && context.update) {\n const frame = requestAnimationFrame(context.update);\n return () => cancelAnimationFrame(frame);\n }\n }, [context.open, registeredItemCount]);\n if (itemContext.shouldRenderWebNative) {\n return /* @__PURE__ */ jsx(YStack, { position: \"relative\", children });\n }\n if (isAdapted || !isWeb) {\n const frameProps = isAdapted ? getSheetFrameProps(viewportProps) : viewportProps;\n let content = /* @__PURE__ */ jsx(\n SelectViewportFrame,\n {\n ...frameProps,\n ...isWeb ? getSelectListboxProps(itemContext.mode) : {},\n \"data-select-viewport\": \"\",\n ref: composedRefs,\n children: lazyMounted ? children : null\n }\n );\n if (needsRepropagation) {\n content = /* @__PURE__ */ jsx(ForwardSelectContext, { itemContext, context, children: content });\n }\n return /* @__PURE__ */ jsx(AdaptPortalContents, { scope: context.adaptScope, children: content });\n }\n if (!context.interactions) {\n return null;\n }\n const floatingProps = context.interactions.getFloatingProps();\n return /* @__PURE__ */ jsxs(Fragment, { children: [\n !disableScroll && /* @__PURE__ */ jsx(\n \"style\",\n {\n dangerouslySetInnerHTML: {\n __html: selectViewportCSS\n }\n }\n ),\n /* @__PURE__ */ jsx(AnimatePresence, { presenceAffectsLayout: false, children: context.open ? /* @__PURE__ */ jsx(\n SelectViewportFrame,\n {\n \"data-select-viewport\": \"\",\n ...isWeb && {\n \"data-state\": context.open ? \"open\" : \"closed\"\n },\n ...viewportProps,\n ...context.floatingPosition,\n outlineWidth: 0,\n ...floatingProps,\n ...getSelectListboxProps(itemContext.mode),\n overflowY: disableScroll ? void 0 : \"auto\",\n ref: composedRefs,\n children: lazyMounted ? children : null\n },\n \"select-viewport\"\n ) : null }),\n !context.open && !(context.lazyMount && context.renderValue) && lazyMounted && /* @__PURE__ */ jsx(\"div\", { style: { display: \"none\" }, children })\n ] });\n }\n);\nconst selectViewportCSS = `\n[data-select-viewport] {\n scrollbar-width: none;\n -webkit-overflow-scrolling: touch;\n overscroll-behavior: none;\n}\n\n[data-select-viewport]::-webkit-scrollbar{\n display:none\n}\n`;\nexport {\n SelectViewport,\n SelectViewportFrame\n};\n//# sourceMappingURL=SelectViewport.js.map\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAM,sBAAsB,OAAO,MAAM;CACvC,aAAa;CACb,UAAU;AACZ,CAAC;AACD,MAAM,qBAAqB,yBAAyB;AACpD,MAAM,sBAAsB,UAAU;CACpC,MAAM,EAAE,WAAW,OAAO,0BAA0B,gBAAgB,GAAG,SAAS;CAChF,OAAO,gBAAgB,IAAI,CAAC,CAAC;AAC/B;AACA,MAAM,iBAAiB,gBACrB,qBACA,SAAS,gBAAgB,OAAO,cAAc;CAC5C,MAAM,EAAE,OAAO,UAAU,eAAe,GAAG,kBAAkB;CAC7D,MAAM,UAAU,iBAAiB,KAAK;CACtC,MAAM,cAAc,2BAA2B,KAAK;CACpD,MAAM,YAAY,iBAAiB,QAAQ,UAAU;CACrD,MAAM,cAAc,MAAM,OAAO,IAAI;CACrC,MAAM,sBAAsB,YAAY,SAAS,SAAS,CAAC,CAAC;CAC5D,MAAM,eAAe,MAAM,OAAO,CAAC,QAAQ,SAAS;CACpD,I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Q,CAAC;CAClG;CACA,IAAI,CAAC,QAAQ,cAAc;EACzB,OAAO;CACT;CACA,MAAM,gBAAgB,QAAQ,aAAa,iBAAiB;CAC5D,OAAuB,qBAAK,UAAU,EAAE,UAAU;EAChD,CAAC,iBAAiC,oBAChC,SACA,EACE,yBAAyB,EACvB,QAAQ,kBACV,EACF,CACF;EACgB,oBAAI,iBAAiB;GAAE,uBAAuB;GAAO,UAAU,QAAQ,OAAuB,oBAC5G,qBACA;IACE,wBAAwB;IACxB,GAAG,SAAS,EACV,cAAc,QAAQ,OAAO,SAAS,SACxC;IACA,GAAG;IACH,GAAG,QAAQ;IACX,cAAc;IACd,GAAG;IACH,GAAG,sBAAsB,YAAY,IAAI;IACzC,WAAW,gBAAgB,KAAK,IAAI;IACpC,KAAK;IACL,UAAU,cAAc,WAAW;GACrC,GACA,iBACF,IAAI;EAAK,CAAC;EACV,CAAC,QAAQ,QAAQ,EAAE,QAAQ,aAAa,QAAQ,gBAAgB,eAA+B,oBAAI,OAAO;GAAE,OAAO,EAAE,SAAS,OAAO;GAAG;EAAS,CAAC;CACpJ,EAAE,CAAC;AACL,CACF;AACA,MAAM,oBAAoB"}
|
|
@@ -40,14 +40,14 @@ var SelectViewport = (0, import_core.createStyledHOC)(SelectViewportFrame, funct
|
|
|
40
40
|
var context = (0, import_context.useSelectContext)(scope);
|
|
41
41
|
var itemParentContext = (0, import_context.useSelectItemParentContext)(scope);
|
|
42
42
|
var themeName = (0, import_core.useThemeName)();
|
|
43
|
-
var adaptContext = (0, import_adapt.useAdaptContext)();
|
|
43
|
+
var adaptContext = (0, import_adapt.useAdaptContext)(context.adaptScope);
|
|
44
44
|
var isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope);
|
|
45
45
|
var contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, {
|
|
46
46
|
name: themeName,
|
|
47
47
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_context.ForwardSelectContext, {
|
|
48
48
|
itemContext: itemParentContext,
|
|
49
49
|
context,
|
|
50
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_adapt.
|
|
50
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_adapt.ProvideAdaptContext, {
|
|
51
51
|
...adaptContext,
|
|
52
52
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectViewportFrame, {
|
|
53
53
|
...viewportProps,
|
|
@@ -40,14 +40,14 @@ var SelectViewport = (0, import_core.createStyledHOC)(SelectViewportFrame, funct
|
|
|
40
40
|
var context = (0, import_context.useSelectContext)(scope);
|
|
41
41
|
var itemParentContext = (0, import_context.useSelectItemParentContext)(scope);
|
|
42
42
|
var themeName = (0, import_core.useThemeName)();
|
|
43
|
-
var adaptContext = (0, import_adapt.useAdaptContext)();
|
|
43
|
+
var adaptContext = (0, import_adapt.useAdaptContext)(context.adaptScope);
|
|
44
44
|
var isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope);
|
|
45
45
|
var contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, {
|
|
46
46
|
name: themeName,
|
|
47
47
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_context.ForwardSelectContext, {
|
|
48
48
|
itemContext: itemParentContext,
|
|
49
49
|
context,
|
|
50
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_adapt.
|
|
50
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_adapt.ProvideAdaptContext, {
|
|
51
51
|
...adaptContext,
|
|
52
52
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectViewportFrame, {
|
|
53
53
|
...viewportProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectViewport.native.js","names":[],"sources":["jsx/SelectViewport.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar SelectViewport_native_exports = {};\n__export(SelectViewport_native_exports, {\n SelectViewport: () => SelectViewport,\n SelectViewportFrame: () => SelectViewportFrame\n});\nmodule.exports = __toCommonJS(SelectViewport_native_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_adapt = require(\"@tamagui/adapt\");\nvar import_core = require(\"@tamagui/core\");\nvar import_constants = require(\"./constants\");\nvar import_context = require(\"./context\");\nvar SelectViewportFrame = (0, import_core.styled)(import_core.View, {\n displayName: import_constants.VIEWPORT_NAME,\n position: \"relative\"\n});\nvar SelectViewport = (0, import_core.createStyledHOC)(SelectViewportFrame, function SelectViewport2(props, forwardedRef) {\n var { scope, children, disableScroll: _disableScroll, ...viewportProps } = props;\n var context = (0, import_context.useSelectContext)(scope);\n var itemParentContext = (0, import_context.useSelectItemParentContext)(scope);\n var themeName = (0, import_core.useThemeName)();\n var adaptContext = (0, import_adapt.useAdaptContext)();\n var isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope);\n var contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, {\n name: themeName,\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_context.ForwardSelectContext, {\n itemContext: itemParentContext,\n context,\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_adapt.
|
|
1
|
+
{"version":3,"file":"SelectViewport.native.js","names":[],"sources":["jsx/SelectViewport.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar SelectViewport_native_exports = {};\n__export(SelectViewport_native_exports, {\n SelectViewport: () => SelectViewport,\n SelectViewportFrame: () => SelectViewportFrame\n});\nmodule.exports = __toCommonJS(SelectViewport_native_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_adapt = require(\"@tamagui/adapt\");\nvar import_core = require(\"@tamagui/core\");\nvar import_constants = require(\"./constants\");\nvar import_context = require(\"./context\");\nvar SelectViewportFrame = (0, import_core.styled)(import_core.View, {\n displayName: import_constants.VIEWPORT_NAME,\n position: \"relative\"\n});\nvar SelectViewport = (0, import_core.createStyledHOC)(SelectViewportFrame, function SelectViewport2(props, forwardedRef) {\n var { scope, children, disableScroll: _disableScroll, ...viewportProps } = props;\n var context = (0, import_context.useSelectContext)(scope);\n var itemParentContext = (0, import_context.useSelectItemParentContext)(scope);\n var themeName = (0, import_core.useThemeName)();\n var adaptContext = (0, import_adapt.useAdaptContext)(context.adaptScope);\n var isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope);\n var contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Theme, {\n name: themeName,\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_context.ForwardSelectContext, {\n itemContext: itemParentContext,\n context,\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_adapt.ProvideAdaptContext, {\n ...adaptContext,\n children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectViewportFrame, {\n ...viewportProps,\n ref: forwardedRef,\n children\n })\n })\n })\n });\n if (!context.open) {\n if (context.lazyMount && context.renderValue) return null;\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectViewportFrame, {\n display: \"none\",\n children: contents\n });\n }\n return isAdapted ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_adapt.AdaptPortalContents, {\n scope: context.adaptScope,\n children: contents\n }) : contents;\n});\nSelectViewport.displayName = import_constants.VIEWPORT_NAME;\n//# sourceMappingURL=SelectViewport.native.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gCAAgC,CAAC;AACrC,SAAS,+BAA+B;CACtC,sBAAsB;CACtB,2BAA2B;AAC7B,CAAC;AAC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CACA,OAAO,YAA4B,iBAAC,GAAG,mBAAmB,IAAG,CAAE,aAAa,qBAAqB;EAC/F,OAAO,QAAQ;EACf,UAAU;CACZ,CAAC,IAAI;AACP,CAAC;AACD,eAAe,cAAc,iBAAiB"}
|
|
@@ -16,13 +16,24 @@ function createSelectItemRegistry(onChange) {
|
|
|
16
16
|
const explicitTextValues = /* @__PURE__ */ new Map();
|
|
17
17
|
const itemNodes = /* @__PURE__ */ new Map();
|
|
18
18
|
const listeners = /* @__PURE__ */ new Set();
|
|
19
|
+
let indexByValue = null;
|
|
19
20
|
const notify = () => {
|
|
21
|
+
indexByValue = null;
|
|
20
22
|
onChange?.();
|
|
21
23
|
listeners.forEach((listener) => listener());
|
|
22
24
|
};
|
|
23
25
|
const getItems = () => items;
|
|
24
26
|
const getItem = (value) => items.find((item) => item.value === value);
|
|
25
|
-
const getIndex = (value) =>
|
|
27
|
+
const getIndex = (value) => {
|
|
28
|
+
if (!indexByValue) {
|
|
29
|
+
indexByValue = /* @__PURE__ */ new Map();
|
|
30
|
+
items.forEach((item, index) => {
|
|
31
|
+
if (!indexByValue.has(item.value)) indexByValue.set(item.value, index);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return indexByValue.get(value) ?? -1;
|
|
35
|
+
};
|
|
36
|
+
const getNodes = () => items.map((item) => itemNodes.get(item.id) ?? null);
|
|
26
37
|
const getRegisteredLabel = (value) => {
|
|
27
38
|
const registrations = labelRegistrations.get(value);
|
|
28
39
|
if (!registrations?.size) return void 0;
|
|
@@ -45,7 +56,6 @@ function createSelectItemRegistry(onChange) {
|
|
|
45
56
|
if (changed) notify();
|
|
46
57
|
};
|
|
47
58
|
const syncNodeOrder = () => {
|
|
48
|
-
const previousOrder = items.map((item) => item.id);
|
|
49
59
|
items.sort((a, b) => {
|
|
50
60
|
const aNode = itemNodes.get(a.id);
|
|
51
61
|
const bNode = itemNodes.get(b.id);
|
|
@@ -57,9 +67,6 @@ function createSelectItemRegistry(onChange) {
|
|
|
57
67
|
if (position & 2) return 1;
|
|
58
68
|
return 0;
|
|
59
69
|
});
|
|
60
|
-
if (items.some((item, index) => item.id !== previousOrder[index])) {
|
|
61
|
-
notify();
|
|
62
|
-
}
|
|
63
70
|
};
|
|
64
71
|
const registerItem = (item) => {
|
|
65
72
|
const id = Symbol(item.value);
|
|
@@ -99,12 +106,14 @@ function createSelectItemRegistry(onChange) {
|
|
|
99
106
|
notify();
|
|
100
107
|
},
|
|
101
108
|
setNode(node) {
|
|
109
|
+
if ((itemNodes.get(id) ?? null) === (node ?? null)) return;
|
|
102
110
|
if (node) {
|
|
103
111
|
itemNodes.set(id, node);
|
|
104
112
|
syncNodeOrder();
|
|
105
113
|
} else {
|
|
106
114
|
itemNodes.delete(id);
|
|
107
115
|
}
|
|
116
|
+
notify();
|
|
108
117
|
},
|
|
109
118
|
unregister() {
|
|
110
119
|
const index = items.findIndex((current) => current.id === id);
|
|
@@ -179,6 +188,7 @@ function createSelectItemRegistry(onChange) {
|
|
|
179
188
|
getItems,
|
|
180
189
|
getItem,
|
|
181
190
|
getIndex,
|
|
191
|
+
getNodes,
|
|
182
192
|
firstEnabledIndex,
|
|
183
193
|
nextEnabledIndex,
|
|
184
194
|
findTypeaheadIndex,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectionController.js","names":[],"sources":["jsx/selectionController.js"],"sourcesContent":["function getSelectLabelText(label) {\n if (typeof label === \"string\" || typeof label === \"number\") {\n return String(label);\n }\n if (Array.isArray(label)) {\n return label.map(getSelectLabelText).join(\"\");\n }\n if (label && typeof label === \"object\" && \"props\" in label) {\n return getSelectLabelText(label.props?.children);\n }\n return \"\";\n}\nfunction createSelectItemRegistry(onChange) {\n const items = [];\n const labelRegistrations = /* @__PURE__ */ new Map();\n const explicitTextValues = /* @__PURE__ */ new Map();\n const itemNodes = /* @__PURE__ */ new Map();\n const listeners = /* @__PURE__ */ new Set();\n const notify = () => {\n onChange?.();\n listeners.forEach((listener) => listener());\n };\n const getItems = () => items;\n const getItem = (value) => items.find((item) => item.value === value);\n const getIndex = (value) => items.findIndex((item) => item.value === value);\n const getRegisteredLabel = (value) => {\n const registrations = labelRegistrations.get(value);\n if (!registrations?.size) return void 0;\n const values = Array.from(registrations.values());\n return values[values.length - 1];\n };\n const applyRegisteredLabel = (value) => {\n const registeredLabel = getRegisteredLabel(value);\n let changed = false;\n for (const item of items) {\n if (item.value !== value) continue;\n const nextLabel = registeredLabel?.label;\n const nextTextValue = explicitTextValues.get(item.id) || registeredLabel?.textValue;\n if (item.label !== nextLabel || item.textValue !== nextTextValue) {\n item.label = nextLabel;\n item.textValue = nextTextValue;\n changed = true;\n }\n }\n if (changed) notify();\n };\n const syncNodeOrder = () => {\n const previousOrder = items.map((item) => item.id);\n items.sort((a, b) => {\n const aNode = itemNodes.get(a.id);\n const bNode = itemNodes.get(b.id);\n if (!aNode || !bNode || typeof aNode.compareDocumentPosition !== \"function\") {\n return 0;\n }\n const position = aNode.compareDocumentPosition(bNode);\n if (position & 4) return -1;\n if (position & 2) return 1;\n return 0;\n });\n if (items.some((item, index) => item.id !== previousOrder[index])) {\n notify();\n }\n };\n const registerItem = (item) => {\n const id = Symbol(item.value);\n const registeredLabel = getRegisteredLabel(item.value);\n const registeredItem = {\n ...item,\n ...registeredLabel,\n textValue: item.textValue ?? registeredLabel?.textValue,\n id\n };\n explicitTextValues.set(id, item.textValue);\n items.push(registeredItem);\n notify();\n return {\n id,\n update(next) {\n const index = items.findIndex((current2) => current2.id === id);\n if (index < 0) return;\n const current = items[index];\n if (\"textValue\" in next) {\n explicitTextValues.set(id, next.textValue);\n }\n const nextItem = { ...current, ...next };\n if (next.value !== void 0 && next.value !== current.value) {\n const nextLabel = getRegisteredLabel(next.value);\n nextItem.label = nextLabel?.label;\n }\n const explicitTextValue = explicitTextValues.get(id);\n nextItem.textValue = explicitTextValue || getSelectLabelText(nextItem.label) || (nextItem.label ? nextItem.value : void 0);\n const changed = Object.entries(next).some(\n ([key, value]) => current[key] !== value\n );\n const textValueChanged = current.textValue !== nextItem.textValue;\n if (!changed && !textValueChanged) return;\n items[index] = nextItem;\n notify();\n },\n setNode(node) {\n if (node) {\n itemNodes.set(id, node);\n syncNodeOrder();\n } else {\n itemNodes.delete(id);\n }\n },\n unregister() {\n const index = items.findIndex((current) => current.id === id);\n if (index < 0) return;\n items.splice(index, 1);\n explicitTextValues.delete(id);\n itemNodes.delete(id);\n notify();\n }\n };\n };\n const registerLabel = (value, label, textValue) => {\n const id = Symbol(value);\n const normalizedTextValue = textValue || getSelectLabelText(label) || value;\n const registrations = labelRegistrations.get(value) ?? (() => {\n const next = /* @__PURE__ */ new Map();\n labelRegistrations.set(value, next);\n return next;\n })();\n registrations.set(id, { label, textValue: normalizedTextValue });\n applyRegisteredLabel(value);\n return () => {\n registrations.delete(id);\n if (!registrations.size) {\n labelRegistrations.delete(value);\n }\n applyRegisteredLabel(value);\n };\n };\n const firstEnabledIndex = () => items.findIndex((item) => !item.disabled);\n const nextEnabledIndex = (fromIndex, direction) => {\n if (!items.length) return -1;\n if (fromIndex == null || fromIndex < 0 || fromIndex >= items.length) {\n if (direction === 1) return firstEnabledIndex();\n for (let index = items.length - 1; index >= 0; index--) {\n if (!items[index].disabled) return index;\n }\n return -1;\n }\n for (let offset = 1; offset <= items.length; offset++) {\n const index = (fromIndex + direction * offset + items.length) % items.length;\n if (!items[index]?.disabled) return index;\n }\n return -1;\n };\n const findTypeaheadIndex = (search, fromIndex) => {\n const normalizedSearch = search.trim().toLocaleLowerCase();\n if (!normalizedSearch) return -1;\n const start = fromIndex == null || fromIndex < 0 ? -1 : fromIndex;\n for (let offset = 1; offset <= items.length; offset++) {\n const index = (start + offset) % items.length;\n const item = items[index];\n const label = item.textValue || getSelectLabelText(item.label) || item.value;\n if (!item.disabled && label.toLocaleLowerCase().startsWith(normalizedSearch)) {\n return index;\n }\n }\n return -1;\n };\n return {\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n registerItem,\n registerLabel,\n getItems,\n getItem,\n getIndex,\n firstEnabledIndex,\n nextEnabledIndex,\n findTypeaheadIndex,\n getDisabledIndices: () => items.flatMap((item, index) => item.disabled ? [index] : []),\n getTypeaheadLabels: () => items.map((item) => item.textValue || getSelectLabelText(item.label) || item.value)\n };\n}\nfunction normalizeSelectSelection(mode, value) {\n if (mode === \"single\") {\n return typeof value === \"string\" ? value : \"\";\n }\n const values = Array.isArray(value) ? value : [];\n return [...new Set(values)];\n}\nfunction selectedValuesFromSelection(mode, value) {\n const normalized = normalizeSelectSelection(mode, value);\n return mode === \"multiple\" ? normalized : normalized ? [normalized] : [];\n}\nfunction createSelectSelectionController({\n mode: initialMode,\n value: initialValue,\n registry\n}) {\n let mode = initialMode;\n let value = normalizeSelectSelection(mode, initialValue);\n let activeIndex = null;\n const selectedValues = () => selectedValuesFromSelection(mode, value);\n const setMode = (nextMode) => {\n if (mode === nextMode) return value;\n mode = nextMode;\n value = normalizeSelectSelection(mode, value);\n return value;\n };\n const setValue = (nextValue) => {\n value = normalizeSelectSelection(mode, nextValue);\n return value;\n };\n const isSelected = (itemValue) => selectedValues().includes(itemValue);\n const toggle = (itemValue) => {\n const item = registry.getItem(itemValue);\n if (!item || item.disabled) return value;\n if (mode === \"single\") {\n value = itemValue;\n return value;\n }\n const current = selectedValues();\n value = current.includes(itemValue) ? current.filter((currentValue) => currentValue !== itemValue) : [...current, itemValue];\n return value;\n };\n const selectionAnchor = () => {\n const values = selectedValues();\n for (let index = values.length - 1; index >= 0; index--) {\n const item = registry.getItem(values[index]);\n if (item) return item;\n }\n const firstEnabledIndex = registry.firstEnabledIndex();\n return firstEnabledIndex < 0 ? void 0 : registry.getItems()[firstEnabledIndex];\n };\n const selectionAnchorIndex = () => {\n const anchor = selectionAnchor();\n return anchor ? registry.getIndex(anchor.value) : -1;\n };\n const initialActiveIndex = () => {\n const anchorIndex = selectionAnchorIndex();\n const anchor = anchorIndex < 0 ? void 0 : registry.getItems()[anchorIndex];\n return anchor && !anchor.disabled ? anchorIndex : registry.firstEnabledIndex();\n };\n const moveActive = (direction) => {\n const nextIndex = registry.nextEnabledIndex(activeIndex, direction);\n activeIndex = nextIndex < 0 ? null : nextIndex;\n return activeIndex == null ? void 0 : registry.getItems()[activeIndex];\n };\n return {\n registry,\n get mode() {\n return mode;\n },\n get value() {\n return value;\n },\n get activeIndex() {\n return activeIndex;\n },\n get activeItem() {\n return activeIndex == null ? void 0 : registry.getItems()[activeIndex];\n },\n get shouldCloseOnSelect() {\n return mode === \"single\";\n },\n setMode,\n setValue,\n isSelected,\n toggle,\n selectionAnchor,\n selectionAnchorIndex,\n initialActiveIndex,\n setActiveIndex(index) {\n activeIndex = index;\n },\n moveActive\n };\n}\nfunction getSelectListboxProps(mode) {\n return {\n role: \"listbox\",\n \"aria-multiselectable\": mode === \"multiple\" ? true : void 0\n };\n}\nfunction getSelectOptionProps(mode, selected, disabled, platform) {\n if (platform === \"native\") {\n return {\n accessibilityRole: mode === \"multiple\" ? \"checkbox\" : \"button\",\n accessibilityState: {\n selected: mode === \"single\" ? selected : void 0,\n checked: mode === \"multiple\" ? selected : void 0,\n disabled\n }\n };\n }\n return {\n role: \"option\",\n \"aria-selected\": selected,\n \"aria-disabled\": disabled || void 0\n };\n}\nexport {\n createSelectItemRegistry,\n createSelectSelectionController,\n getSelectLabelText,\n getSelectListboxProps,\n getSelectOptionProps,\n normalizeSelectSelection,\n selectedValuesFromSelection\n};\n//# sourceMappingURL=selectionController.js.map\n"],"mappings":";AAAA,SAAS,mBAAmB,OAAO;CACjC,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU;EAC1D,OAAO,OAAO,KAAK;CACrB;CACA,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxB,OAAO,MAAM,IAAI,kBAAkB,CAAC,CAAC,KAAK,EAAE;CAC9C;CACA,IAAI,SAAS,OAAO,UAAU,YAAY,WAAW,OAAO;EAC1D,OAAO,mBAAmB,MAAM,OAAO,QAAQ;CACjD;CAC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,OAAO,WAAW,cAAc,SAAS,kBAAkB;CAC/E;CACA,MAAM,cAAc,cAAc;EAChC,MAAM,YAAY,SAAS,iBAAiB,aAAa,SAAS;EAClE,cAAc,YAAY,IAAI,OAAO;EACrC,OAAO,eAAe,OAAO,KAAK,IAAI,SAAS,SAAS,CAAC,CAAC;CAC5D;CACA,OAAO;EACL;EACA,IAAI,OAAO;GACT,OAAO;EACT;EACA,IAAI,QAAQ;GACV,OAAO;EACT;EACA,IAAI,cAAc;GAChB,OAAO;EACT;EACA,IAAI,aAAa;GACf,OAAO,eAAe,OAAO,KAAK,IAAI,SAAS,SAAS,CAAC,CAAC;EAC5D;EACA,IAAI,sBAAsB;GACxB,OAAO,SAAS;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAAe,OAAO;GACpB,cAAc;EAChB;EACA;CACF;AACF;AACA,SAAS,sBAAsB,MAAM;CACnC,OAAO;EACL,MAAM;EACN,wBAAwB,SAAS,aAAa,OAAO,KAAK;CAC5D;AACF;AACA,SAAS,qBAAqB,MAAM,UAAU,UAAU,UAAU;CAChE,IAAI,aAAa,UAAU;EACzB,OAAO;GACL,mBAAmB,SAAS,aAAa,aAAa;GACtD,oBAAoB;IAClB,UAAU,SAAS,WAAW,WAAW,KAAK;IAC9C,SAAS,SAAS,aAAa,WAAW,KAAK;IAC/C;GACF;EACF;CACF;CACA,OAAO;EACL,MAAM;EACN,iBAAiB;EACjB,iBAAiB,YAAY,KAAK;CACpC;AACF"}
|
|
1
|
+
{"version":3,"file":"selectionController.js","names":[],"sources":["jsx/selectionController.js"],"sourcesContent":["function getSelectLabelText(label) {\n if (typeof label === \"string\" || typeof label === \"number\") {\n return String(label);\n }\n if (Array.isArray(label)) {\n return label.map(getSelectLabelText).join(\"\");\n }\n if (label && typeof label === \"object\" && \"props\" in label) {\n return getSelectLabelText(label.props?.children);\n }\n return \"\";\n}\nfunction createSelectItemRegistry(onChange) {\n const items = [];\n const labelRegistrations = /* @__PURE__ */ new Map();\n const explicitTextValues = /* @__PURE__ */ new Map();\n const itemNodes = /* @__PURE__ */ new Map();\n const listeners = /* @__PURE__ */ new Set();\n let indexByValue = null;\n const notify = () => {\n indexByValue = null;\n onChange?.();\n listeners.forEach((listener) => listener());\n };\n const getItems = () => items;\n const getItem = (value) => items.find((item) => item.value === value);\n const getIndex = (value) => {\n if (!indexByValue) {\n indexByValue = /* @__PURE__ */ new Map();\n items.forEach((item, index) => {\n if (!indexByValue.has(item.value)) indexByValue.set(item.value, index);\n });\n }\n return indexByValue.get(value) ?? -1;\n };\n const getNodes = () => items.map((item) => itemNodes.get(item.id) ?? null);\n const getRegisteredLabel = (value) => {\n const registrations = labelRegistrations.get(value);\n if (!registrations?.size) return void 0;\n const values = Array.from(registrations.values());\n return values[values.length - 1];\n };\n const applyRegisteredLabel = (value) => {\n const registeredLabel = getRegisteredLabel(value);\n let changed = false;\n for (const item of items) {\n if (item.value !== value) continue;\n const nextLabel = registeredLabel?.label;\n const nextTextValue = explicitTextValues.get(item.id) || registeredLabel?.textValue;\n if (item.label !== nextLabel || item.textValue !== nextTextValue) {\n item.label = nextLabel;\n item.textValue = nextTextValue;\n changed = true;\n }\n }\n if (changed) notify();\n };\n const syncNodeOrder = () => {\n items.sort((a, b) => {\n const aNode = itemNodes.get(a.id);\n const bNode = itemNodes.get(b.id);\n if (!aNode || !bNode || typeof aNode.compareDocumentPosition !== \"function\") {\n return 0;\n }\n const position = aNode.compareDocumentPosition(bNode);\n if (position & 4) return -1;\n if (position & 2) return 1;\n return 0;\n });\n };\n const registerItem = (item) => {\n const id = Symbol(item.value);\n const registeredLabel = getRegisteredLabel(item.value);\n const registeredItem = {\n ...item,\n ...registeredLabel,\n textValue: item.textValue ?? registeredLabel?.textValue,\n id\n };\n explicitTextValues.set(id, item.textValue);\n items.push(registeredItem);\n notify();\n return {\n id,\n update(next) {\n const index = items.findIndex((current2) => current2.id === id);\n if (index < 0) return;\n const current = items[index];\n if (\"textValue\" in next) {\n explicitTextValues.set(id, next.textValue);\n }\n const nextItem = { ...current, ...next };\n if (next.value !== void 0 && next.value !== current.value) {\n const nextLabel = getRegisteredLabel(next.value);\n nextItem.label = nextLabel?.label;\n }\n const explicitTextValue = explicitTextValues.get(id);\n nextItem.textValue = explicitTextValue || getSelectLabelText(nextItem.label) || (nextItem.label ? nextItem.value : void 0);\n const changed = Object.entries(next).some(\n ([key, value]) => current[key] !== value\n );\n const textValueChanged = current.textValue !== nextItem.textValue;\n if (!changed && !textValueChanged) return;\n items[index] = nextItem;\n notify();\n },\n setNode(node) {\n if ((itemNodes.get(id) ?? null) === (node ?? null)) return;\n if (node) {\n itemNodes.set(id, node);\n syncNodeOrder();\n } else {\n itemNodes.delete(id);\n }\n notify();\n },\n unregister() {\n const index = items.findIndex((current) => current.id === id);\n if (index < 0) return;\n items.splice(index, 1);\n explicitTextValues.delete(id);\n itemNodes.delete(id);\n notify();\n }\n };\n };\n const registerLabel = (value, label, textValue) => {\n const id = Symbol(value);\n const normalizedTextValue = textValue || getSelectLabelText(label) || value;\n const registrations = labelRegistrations.get(value) ?? (() => {\n const next = /* @__PURE__ */ new Map();\n labelRegistrations.set(value, next);\n return next;\n })();\n registrations.set(id, { label, textValue: normalizedTextValue });\n applyRegisteredLabel(value);\n return () => {\n registrations.delete(id);\n if (!registrations.size) {\n labelRegistrations.delete(value);\n }\n applyRegisteredLabel(value);\n };\n };\n const firstEnabledIndex = () => items.findIndex((item) => !item.disabled);\n const nextEnabledIndex = (fromIndex, direction) => {\n if (!items.length) return -1;\n if (fromIndex == null || fromIndex < 0 || fromIndex >= items.length) {\n if (direction === 1) return firstEnabledIndex();\n for (let index = items.length - 1; index >= 0; index--) {\n if (!items[index].disabled) return index;\n }\n return -1;\n }\n for (let offset = 1; offset <= items.length; offset++) {\n const index = (fromIndex + direction * offset + items.length) % items.length;\n if (!items[index]?.disabled) return index;\n }\n return -1;\n };\n const findTypeaheadIndex = (search, fromIndex) => {\n const normalizedSearch = search.trim().toLocaleLowerCase();\n if (!normalizedSearch) return -1;\n const start = fromIndex == null || fromIndex < 0 ? -1 : fromIndex;\n for (let offset = 1; offset <= items.length; offset++) {\n const index = (start + offset) % items.length;\n const item = items[index];\n const label = item.textValue || getSelectLabelText(item.label) || item.value;\n if (!item.disabled && label.toLocaleLowerCase().startsWith(normalizedSearch)) {\n return index;\n }\n }\n return -1;\n };\n return {\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n registerItem,\n registerLabel,\n getItems,\n getItem,\n getIndex,\n getNodes,\n firstEnabledIndex,\n nextEnabledIndex,\n findTypeaheadIndex,\n getDisabledIndices: () => items.flatMap((item, index) => item.disabled ? [index] : []),\n getTypeaheadLabels: () => items.map((item) => item.textValue || getSelectLabelText(item.label) || item.value)\n };\n}\nfunction normalizeSelectSelection(mode, value) {\n if (mode === \"single\") {\n return typeof value === \"string\" ? value : \"\";\n }\n const values = Array.isArray(value) ? value : [];\n return [...new Set(values)];\n}\nfunction selectedValuesFromSelection(mode, value) {\n const normalized = normalizeSelectSelection(mode, value);\n return mode === \"multiple\" ? normalized : normalized ? [normalized] : [];\n}\nfunction createSelectSelectionController({\n mode: initialMode,\n value: initialValue,\n registry\n}) {\n let mode = initialMode;\n let value = normalizeSelectSelection(mode, initialValue);\n let activeIndex = null;\n const selectedValues = () => selectedValuesFromSelection(mode, value);\n const setMode = (nextMode) => {\n if (mode === nextMode) return value;\n mode = nextMode;\n value = normalizeSelectSelection(mode, value);\n return value;\n };\n const setValue = (nextValue) => {\n value = normalizeSelectSelection(mode, nextValue);\n return value;\n };\n const isSelected = (itemValue) => selectedValues().includes(itemValue);\n const toggle = (itemValue) => {\n const item = registry.getItem(itemValue);\n if (!item || item.disabled) return value;\n if (mode === \"single\") {\n value = itemValue;\n return value;\n }\n const current = selectedValues();\n value = current.includes(itemValue) ? current.filter((currentValue) => currentValue !== itemValue) : [...current, itemValue];\n return value;\n };\n const selectionAnchor = () => {\n const values = selectedValues();\n for (let index = values.length - 1; index >= 0; index--) {\n const item = registry.getItem(values[index]);\n if (item) return item;\n }\n const firstEnabledIndex = registry.firstEnabledIndex();\n return firstEnabledIndex < 0 ? void 0 : registry.getItems()[firstEnabledIndex];\n };\n const selectionAnchorIndex = () => {\n const anchor = selectionAnchor();\n return anchor ? registry.getIndex(anchor.value) : -1;\n };\n const initialActiveIndex = () => {\n const anchorIndex = selectionAnchorIndex();\n const anchor = anchorIndex < 0 ? void 0 : registry.getItems()[anchorIndex];\n return anchor && !anchor.disabled ? anchorIndex : registry.firstEnabledIndex();\n };\n const moveActive = (direction) => {\n const nextIndex = registry.nextEnabledIndex(activeIndex, direction);\n activeIndex = nextIndex < 0 ? null : nextIndex;\n return activeIndex == null ? void 0 : registry.getItems()[activeIndex];\n };\n return {\n registry,\n get mode() {\n return mode;\n },\n get value() {\n return value;\n },\n get activeIndex() {\n return activeIndex;\n },\n get activeItem() {\n return activeIndex == null ? void 0 : registry.getItems()[activeIndex];\n },\n get shouldCloseOnSelect() {\n return mode === \"single\";\n },\n setMode,\n setValue,\n isSelected,\n toggle,\n selectionAnchor,\n selectionAnchorIndex,\n initialActiveIndex,\n setActiveIndex(index) {\n activeIndex = index;\n },\n moveActive\n };\n}\nfunction getSelectListboxProps(mode) {\n return {\n role: \"listbox\",\n \"aria-multiselectable\": mode === \"multiple\" ? true : void 0\n };\n}\nfunction getSelectOptionProps(mode, selected, disabled, platform) {\n if (platform === \"native\") {\n return {\n accessibilityRole: mode === \"multiple\" ? \"checkbox\" : \"button\",\n accessibilityState: {\n selected: mode === \"single\" ? selected : void 0,\n checked: mode === \"multiple\" ? selected : void 0,\n disabled\n }\n };\n }\n return {\n role: \"option\",\n \"aria-selected\": selected,\n \"aria-disabled\": disabled || void 0\n };\n}\nexport {\n createSelectItemRegistry,\n createSelectSelectionController,\n getSelectLabelText,\n getSelectListboxProps,\n getSelectOptionProps,\n normalizeSelectSelection,\n selectedValuesFromSelection\n};\n//# sourceMappingURL=selectionController.js.map\n"],"mappings":";AAA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O;GACL,mBAAmB,SAAS,aAAa,aAAa;GACtD,oBAAoB;IAClB,UAAU,SAAS,WAAW,WAAW,KAAK;IAC9C,SAAS,SAAS,aAAa,WAAW,KAAK;IAC/C;GACF;EACF;CACF;CACA,OAAO;EACL,MAAM;EACN,iBAAiB;EACjB,iBAAiB,YAAY,KAAK;CACpC;AACF"}
|
|
@@ -31,10 +31,6 @@ __export(selectionController_exports, {
|
|
|
31
31
|
selectedValuesFromSelection: () => selectedValuesFromSelection
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(selectionController_exports);
|
|
34
|
-
function _type_of(obj) {
|
|
35
|
-
"@swc/helpers - typeof";
|
|
36
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
37
|
-
}
|
|
38
34
|
function getSelectLabelText(label) {
|
|
39
35
|
if (typeof label === "string" || typeof label === "number") {
|
|
40
36
|
return String(label);
|
|
@@ -42,7 +38,7 @@ function getSelectLabelText(label) {
|
|
|
42
38
|
if (Array.isArray(label)) {
|
|
43
39
|
return label.map(getSelectLabelText).join("");
|
|
44
40
|
}
|
|
45
|
-
if (label &&
|
|
41
|
+
if (label && typeof label === "object" && "props" in label) {
|
|
46
42
|
var _label_props;
|
|
47
43
|
return getSelectLabelText((_label_props = label.props) === null || _label_props === void 0 ? void 0 : _label_props.children);
|
|
48
44
|
}
|
|
@@ -54,7 +50,9 @@ function createSelectItemRegistry(onChange) {
|
|
|
54
50
|
var explicitTextValues = /* @__PURE__ */ new Map();
|
|
55
51
|
var itemNodes = /* @__PURE__ */ new Map();
|
|
56
52
|
var listeners = /* @__PURE__ */ new Set();
|
|
53
|
+
var indexByValue = null;
|
|
57
54
|
var notify = function() {
|
|
55
|
+
indexByValue = null;
|
|
58
56
|
onChange === null || onChange === void 0 ? void 0 : onChange();
|
|
59
57
|
listeners.forEach(function(listener) {
|
|
60
58
|
return listener();
|
|
@@ -69,8 +67,19 @@ function createSelectItemRegistry(onChange) {
|
|
|
69
67
|
});
|
|
70
68
|
};
|
|
71
69
|
var getIndex = function(value) {
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
if (!indexByValue) {
|
|
71
|
+
indexByValue = /* @__PURE__ */ new Map();
|
|
72
|
+
items.forEach(function(item, index) {
|
|
73
|
+
if (!indexByValue.has(item.value)) indexByValue.set(item.value, index);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
var _indexByValue_get;
|
|
77
|
+
return (_indexByValue_get = indexByValue.get(value)) !== null && _indexByValue_get !== void 0 ? _indexByValue_get : -1;
|
|
78
|
+
};
|
|
79
|
+
var getNodes = function() {
|
|
80
|
+
return items.map(function(item) {
|
|
81
|
+
var _itemNodes_get;
|
|
82
|
+
return (_itemNodes_get = itemNodes.get(item.id)) !== null && _itemNodes_get !== void 0 ? _itemNodes_get : null;
|
|
74
83
|
});
|
|
75
84
|
};
|
|
76
85
|
var getRegisteredLabel = function(value) {
|
|
@@ -112,9 +121,6 @@ function createSelectItemRegistry(onChange) {
|
|
|
112
121
|
if (changed) notify();
|
|
113
122
|
};
|
|
114
123
|
var syncNodeOrder = function() {
|
|
115
|
-
var previousOrder = items.map(function(item) {
|
|
116
|
-
return item.id;
|
|
117
|
-
});
|
|
118
124
|
items.sort(function(a, b) {
|
|
119
125
|
var aNode = itemNodes.get(a.id);
|
|
120
126
|
var bNode = itemNodes.get(b.id);
|
|
@@ -126,11 +132,6 @@ function createSelectItemRegistry(onChange) {
|
|
|
126
132
|
if (position & 2) return 1;
|
|
127
133
|
return 0;
|
|
128
134
|
});
|
|
129
|
-
if (items.some(function(item, index) {
|
|
130
|
-
return item.id !== previousOrder[index];
|
|
131
|
-
})) {
|
|
132
|
-
notify();
|
|
133
|
-
}
|
|
134
135
|
};
|
|
135
136
|
var registerItem = function(item) {
|
|
136
137
|
var id = Symbol(item.value);
|
|
@@ -176,12 +177,15 @@ function createSelectItemRegistry(onChange) {
|
|
|
176
177
|
notify();
|
|
177
178
|
},
|
|
178
179
|
setNode(node) {
|
|
180
|
+
var _itemNodes_get;
|
|
181
|
+
if (((_itemNodes_get = itemNodes.get(id)) !== null && _itemNodes_get !== void 0 ? _itemNodes_get : null) === (node !== null && node !== void 0 ? node : null)) return;
|
|
179
182
|
if (node) {
|
|
180
183
|
itemNodes.set(id, node);
|
|
181
184
|
syncNodeOrder();
|
|
182
185
|
} else {
|
|
183
186
|
itemNodes.delete(id);
|
|
184
187
|
}
|
|
188
|
+
notify();
|
|
185
189
|
},
|
|
186
190
|
unregister() {
|
|
187
191
|
var index = items.findIndex(function(current) {
|
|
@@ -264,6 +268,7 @@ function createSelectItemRegistry(onChange) {
|
|
|
264
268
|
getItems,
|
|
265
269
|
getItem,
|
|
266
270
|
getIndex,
|
|
271
|
+
getNodes,
|
|
267
272
|
firstEnabledIndex,
|
|
268
273
|
nextEnabledIndex,
|
|
269
274
|
findTypeaheadIndex,
|
|
@@ -31,10 +31,6 @@ __export(selectionController_exports, {
|
|
|
31
31
|
selectedValuesFromSelection: () => selectedValuesFromSelection
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(selectionController_exports);
|
|
34
|
-
function _type_of(obj) {
|
|
35
|
-
"@swc/helpers - typeof";
|
|
36
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
37
|
-
}
|
|
38
34
|
function getSelectLabelText(label) {
|
|
39
35
|
if (typeof label === "string" || typeof label === "number") {
|
|
40
36
|
return String(label);
|
|
@@ -42,7 +38,7 @@ function getSelectLabelText(label) {
|
|
|
42
38
|
if (Array.isArray(label)) {
|
|
43
39
|
return label.map(getSelectLabelText).join("");
|
|
44
40
|
}
|
|
45
|
-
if (label &&
|
|
41
|
+
if (label && typeof label === "object" && "props" in label) {
|
|
46
42
|
var _label_props;
|
|
47
43
|
return getSelectLabelText((_label_props = label.props) === null || _label_props === void 0 ? void 0 : _label_props.children);
|
|
48
44
|
}
|
|
@@ -54,7 +50,9 @@ function createSelectItemRegistry(onChange) {
|
|
|
54
50
|
var explicitTextValues = /* @__PURE__ */ new Map();
|
|
55
51
|
var itemNodes = /* @__PURE__ */ new Map();
|
|
56
52
|
var listeners = /* @__PURE__ */ new Set();
|
|
53
|
+
var indexByValue = null;
|
|
57
54
|
var notify = function() {
|
|
55
|
+
indexByValue = null;
|
|
58
56
|
onChange === null || onChange === void 0 ? void 0 : onChange();
|
|
59
57
|
listeners.forEach(function(listener) {
|
|
60
58
|
return listener();
|
|
@@ -69,8 +67,19 @@ function createSelectItemRegistry(onChange) {
|
|
|
69
67
|
});
|
|
70
68
|
};
|
|
71
69
|
var getIndex = function(value) {
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
if (!indexByValue) {
|
|
71
|
+
indexByValue = /* @__PURE__ */ new Map();
|
|
72
|
+
items.forEach(function(item, index) {
|
|
73
|
+
if (!indexByValue.has(item.value)) indexByValue.set(item.value, index);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
var _indexByValue_get;
|
|
77
|
+
return (_indexByValue_get = indexByValue.get(value)) !== null && _indexByValue_get !== void 0 ? _indexByValue_get : -1;
|
|
78
|
+
};
|
|
79
|
+
var getNodes = function() {
|
|
80
|
+
return items.map(function(item) {
|
|
81
|
+
var _itemNodes_get;
|
|
82
|
+
return (_itemNodes_get = itemNodes.get(item.id)) !== null && _itemNodes_get !== void 0 ? _itemNodes_get : null;
|
|
74
83
|
});
|
|
75
84
|
};
|
|
76
85
|
var getRegisteredLabel = function(value) {
|
|
@@ -112,9 +121,6 @@ function createSelectItemRegistry(onChange) {
|
|
|
112
121
|
if (changed) notify();
|
|
113
122
|
};
|
|
114
123
|
var syncNodeOrder = function() {
|
|
115
|
-
var previousOrder = items.map(function(item) {
|
|
116
|
-
return item.id;
|
|
117
|
-
});
|
|
118
124
|
items.sort(function(a, b) {
|
|
119
125
|
var aNode = itemNodes.get(a.id);
|
|
120
126
|
var bNode = itemNodes.get(b.id);
|
|
@@ -126,11 +132,6 @@ function createSelectItemRegistry(onChange) {
|
|
|
126
132
|
if (position & 2) return 1;
|
|
127
133
|
return 0;
|
|
128
134
|
});
|
|
129
|
-
if (items.some(function(item, index) {
|
|
130
|
-
return item.id !== previousOrder[index];
|
|
131
|
-
})) {
|
|
132
|
-
notify();
|
|
133
|
-
}
|
|
134
135
|
};
|
|
135
136
|
var registerItem = function(item) {
|
|
136
137
|
var id = Symbol(item.value);
|
|
@@ -176,12 +177,15 @@ function createSelectItemRegistry(onChange) {
|
|
|
176
177
|
notify();
|
|
177
178
|
},
|
|
178
179
|
setNode(node) {
|
|
180
|
+
var _itemNodes_get;
|
|
181
|
+
if (((_itemNodes_get = itemNodes.get(id)) !== null && _itemNodes_get !== void 0 ? _itemNodes_get : null) === (node !== null && node !== void 0 ? node : null)) return;
|
|
179
182
|
if (node) {
|
|
180
183
|
itemNodes.set(id, node);
|
|
181
184
|
syncNodeOrder();
|
|
182
185
|
} else {
|
|
183
186
|
itemNodes.delete(id);
|
|
184
187
|
}
|
|
188
|
+
notify();
|
|
185
189
|
},
|
|
186
190
|
unregister() {
|
|
187
191
|
var index = items.findIndex(function(current) {
|
|
@@ -264,6 +268,7 @@ function createSelectItemRegistry(onChange) {
|
|
|
264
268
|
getItems,
|
|
265
269
|
getItem,
|
|
266
270
|
getIndex,
|
|
271
|
+
getNodes,
|
|
267
272
|
firstEnabledIndex,
|
|
268
273
|
nextEnabledIndex,
|
|
269
274
|
findTypeaheadIndex,
|