@tamagui/linear-gradient 1.0.4

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.
Files changed (111) hide show
  1. package/dist/cjs/BubbleSelect.js +44 -0
  2. package/dist/cjs/BubbleSelect.js.map +7 -0
  3. package/dist/cjs/LinearGradient.js +74 -0
  4. package/dist/cjs/LinearGradient.js.map +7 -0
  5. package/dist/cjs/Select.js +480 -0
  6. package/dist/cjs/Select.js.map +7 -0
  7. package/dist/cjs/SelectContent.js +76 -0
  8. package/dist/cjs/SelectContent.js.map +7 -0
  9. package/dist/cjs/SelectContent.native.js +31 -0
  10. package/dist/cjs/SelectContent.native.js.map +7 -0
  11. package/dist/cjs/SelectImpl.js +301 -0
  12. package/dist/cjs/SelectImpl.js.map +7 -0
  13. package/dist/cjs/SelectImpl.native.js +37 -0
  14. package/dist/cjs/SelectImpl.native.js.map +7 -0
  15. package/dist/cjs/SelectScrollButton.js +161 -0
  16. package/dist/cjs/SelectScrollButton.js.map +7 -0
  17. package/dist/cjs/SelectScrollButton.native.js +32 -0
  18. package/dist/cjs/SelectScrollButton.native.js.map +7 -0
  19. package/dist/cjs/SelectViewport.js +126 -0
  20. package/dist/cjs/SelectViewport.js.map +7 -0
  21. package/dist/cjs/SelectViewport.native.js +62 -0
  22. package/dist/cjs/SelectViewport.native.js.map +7 -0
  23. package/dist/cjs/constants.js +47 -0
  24. package/dist/cjs/constants.js.map +7 -0
  25. package/dist/cjs/context.js +49 -0
  26. package/dist/cjs/context.js.map +7 -0
  27. package/dist/cjs/index.js +19 -0
  28. package/dist/cjs/index.js.map +7 -0
  29. package/dist/cjs/linear-gradient.js +29 -0
  30. package/dist/cjs/linear-gradient.js.map +7 -0
  31. package/dist/cjs/types.js +17 -0
  32. package/dist/cjs/types.js.map +7 -0
  33. package/dist/cjs/useSelectBreakpointActive.js +39 -0
  34. package/dist/cjs/useSelectBreakpointActive.js.map +7 -0
  35. package/dist/esm/BubbleSelect.js +25 -0
  36. package/dist/esm/BubbleSelect.js.map +7 -0
  37. package/dist/esm/LinearGradient.js +51 -0
  38. package/dist/esm/LinearGradient.js.map +7 -0
  39. package/dist/esm/Select.js +452 -0
  40. package/dist/esm/Select.js.map +7 -0
  41. package/dist/esm/SelectContent.js +52 -0
  42. package/dist/esm/SelectContent.js.map +7 -0
  43. package/dist/esm/SelectContent.native.js +7 -0
  44. package/dist/esm/SelectContent.native.js.map +7 -0
  45. package/dist/esm/SelectImpl.js +286 -0
  46. package/dist/esm/SelectImpl.js.map +7 -0
  47. package/dist/esm/SelectImpl.native.js +13 -0
  48. package/dist/esm/SelectImpl.native.js.map +7 -0
  49. package/dist/esm/SelectScrollButton.js +130 -0
  50. package/dist/esm/SelectScrollButton.js.map +7 -0
  51. package/dist/esm/SelectScrollButton.native.js +7 -0
  52. package/dist/esm/SelectScrollButton.native.js.map +7 -0
  53. package/dist/esm/SelectViewport.js +95 -0
  54. package/dist/esm/SelectViewport.js.map +7 -0
  55. package/dist/esm/SelectViewport.native.js +32 -0
  56. package/dist/esm/SelectViewport.native.js.map +7 -0
  57. package/dist/esm/constants.js +17 -0
  58. package/dist/esm/constants.js.map +7 -0
  59. package/dist/esm/context.js +21 -0
  60. package/dist/esm/context.js.map +7 -0
  61. package/dist/esm/index.js +2 -0
  62. package/dist/esm/index.js.map +7 -0
  63. package/dist/esm/linear-gradient.js +5 -0
  64. package/dist/esm/linear-gradient.js.map +7 -0
  65. package/dist/esm/types.js +1 -0
  66. package/dist/esm/types.js.map +7 -0
  67. package/dist/esm/useSelectBreakpointActive.js +14 -0
  68. package/dist/esm/useSelectBreakpointActive.js.map +7 -0
  69. package/dist/jsx/BubbleSelect.js +25 -0
  70. package/dist/jsx/BubbleSelect.js.map +7 -0
  71. package/dist/jsx/LinearGradient.js +39 -0
  72. package/dist/jsx/LinearGradient.js.map +7 -0
  73. package/dist/jsx/Select.js +326 -0
  74. package/dist/jsx/Select.js.map +7 -0
  75. package/dist/jsx/SelectContent.js +30 -0
  76. package/dist/jsx/SelectContent.js.map +7 -0
  77. package/dist/jsx/SelectContent.native.js +7 -0
  78. package/dist/jsx/SelectContent.native.js.map +7 -0
  79. package/dist/jsx/SelectImpl.js +259 -0
  80. package/dist/jsx/SelectImpl.js.map +7 -0
  81. package/dist/jsx/SelectImpl.native.js +10 -0
  82. package/dist/jsx/SelectImpl.native.js.map +7 -0
  83. package/dist/jsx/SelectScrollButton.js +103 -0
  84. package/dist/jsx/SelectScrollButton.js.map +7 -0
  85. package/dist/jsx/SelectScrollButton.native.js +7 -0
  86. package/dist/jsx/SelectScrollButton.native.js.map +7 -0
  87. package/dist/jsx/SelectViewport.js +73 -0
  88. package/dist/jsx/SelectViewport.js.map +7 -0
  89. package/dist/jsx/SelectViewport.native.js +18 -0
  90. package/dist/jsx/SelectViewport.native.js.map +7 -0
  91. package/dist/jsx/constants.js +17 -0
  92. package/dist/jsx/constants.js.map +7 -0
  93. package/dist/jsx/context.js +15 -0
  94. package/dist/jsx/context.js.map +7 -0
  95. package/dist/jsx/index.js +2 -0
  96. package/dist/jsx/index.js.map +7 -0
  97. package/dist/jsx/linear-gradient.js +5 -0
  98. package/dist/jsx/linear-gradient.js.map +7 -0
  99. package/dist/jsx/types.js +1 -0
  100. package/dist/jsx/types.js.map +7 -0
  101. package/dist/jsx/useSelectBreakpointActive.js +14 -0
  102. package/dist/jsx/useSelectBreakpointActive.js.map +7 -0
  103. package/package.json +43 -0
  104. package/src/LinearGradient.tsx +64 -0
  105. package/src/index.ts +1 -0
  106. package/src/linear-gradient.d.ts +3 -0
  107. package/src/linear-gradient.d.ts.map +1 -0
  108. package/src/linear-gradient.ts +2 -0
  109. package/types/LinearGradient.d.ts +10 -0
  110. package/types/index.d.ts +2 -0
  111. package/types/linear-gradient.d.ts +3 -0
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
18
+ mod
19
+ ));
20
+ var import_react_use_previous = require("@radix-ui/react-use-previous");
21
+ var import_compose_refs = require("@tamagui/compose-refs");
22
+ var React = __toESM(require("react"));
23
+ const BubbleSelect = React.forwardRef((props, forwardedRef) => {
24
+ const { value, ...selectProps } = props;
25
+ const ref = React.useRef(null);
26
+ const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref);
27
+ const prevValue = (0, import_react_use_previous.usePrevious)(value);
28
+ React.useEffect(() => {
29
+ const select = ref.current;
30
+ const selectProto = window.HTMLSelectElement.prototype;
31
+ const descriptor = Object.getOwnPropertyDescriptor(
32
+ selectProto,
33
+ "value"
34
+ );
35
+ const setValue = descriptor.set;
36
+ if (prevValue !== value && setValue) {
37
+ const event = new Event("change", { bubbles: true });
38
+ setValue.call(select, value);
39
+ select.dispatchEvent(event);
40
+ }
41
+ }, [prevValue, value]);
42
+ return null;
43
+ });
44
+ //# sourceMappingURL=BubbleSelect.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/BubbleSelect.tsx"],
4
+ "sourcesContent": ["import { usePrevious } from '@radix-ui/react-use-previous'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport * as React from 'react'\n\n/* -----------------------------------------------------------------------------------------------*/\nconst BubbleSelect = React.forwardRef<\n HTMLSelectElement,\n React.ComponentPropsWithoutRef<'select'>\n>((props, forwardedRef) => {\n const { value, ...selectProps } = props\n const ref = React.useRef<HTMLSelectElement>(null)\n const composedRefs = useComposedRefs(forwardedRef, ref)\n const prevValue = usePrevious(value)\n\n // Bubble value change to parents (e.g form change event)\n React.useEffect(() => {\n const select = ref.current!\n const selectProto = window.HTMLSelectElement.prototype\n const descriptor = Object.getOwnPropertyDescriptor(\n selectProto,\n 'value',\n ) as PropertyDescriptor\n const setValue = descriptor.set\n if (prevValue !== value && setValue) {\n const event = new Event('change', { bubbles: true })\n setValue.call(select, value)\n select.dispatchEvent(event)\n }\n }, [prevValue, value])\n\n /**\n * We purposefully use a `select` here to support form autofill as much\n * as possible.\n *\n * We purposefully do not add the `value` attribute here to allow the value\n * to be set programatically and bubble to any parent form `onChange` event.\n * Adding the `value` will cause React to consider the programatic\n * dispatch a duplicate and it will get swallowed.\n *\n * We use `VisuallyHidden` rather than `display: \"none\"` because Safari autofill\n * won't work otherwise.\n */\n // TODO\n return null\n // return (\n // <VisuallyHidden asChild>\n // <select {...selectProps} ref={composedRefs} defaultValue={value} />\n // </VisuallyHidden>\n // )\n})\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA,gCAA4B;AAC5B,0BAAgC;AAChC,YAAuB;AAGvB,MAAM,eAAe,MAAM,WAGzB,CAAC,OAAO,iBAAiB;AACzB,QAAM,EAAE,UAAU,YAAY,IAAI;AAClC,QAAM,MAAM,MAAM,OAA0B,IAAI;AAChD,QAAM,mBAAe,qCAAgB,cAAc,GAAG;AACtD,QAAM,gBAAY,uCAAY,KAAK;AAGnC,QAAM,UAAU,MAAM;AACpB,UAAM,SAAS,IAAI;AACnB,UAAM,cAAc,OAAO,kBAAkB;AAC7C,UAAM,aAAa,OAAO;AAAA,MACxB;AAAA,MACA;AAAA,IACF;AACA,UAAM,WAAW,WAAW;AAC5B,QAAI,cAAc,SAAS,UAAU;AACnC,YAAM,QAAQ,IAAI,MAAM,UAAU,EAAE,SAAS,KAAK,CAAC;AACnD,eAAS,KAAK,QAAQ,KAAK;AAC3B,aAAO,cAAc,KAAK;AAAA,IAC5B;AAAA,EACF,GAAG,CAAC,WAAW,KAAK,CAAC;AAerB,SAAO;AAMT,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var LinearGradient_exports = {};
26
+ __export(LinearGradient_exports, {
27
+ LinearGradient: () => LinearGradient
28
+ });
29
+ module.exports = __toCommonJS(LinearGradient_exports);
30
+ var import_jsx_runtime = require("react/jsx-runtime");
31
+ var import_core = require("@tamagui/core");
32
+ var import_stacks = require("@tamagui/stacks");
33
+ var React = __toESM(require("react"));
34
+ var import_react_native = require("react-native");
35
+ var import_linear_gradient = require("./linear-gradient");
36
+ const LinearGradient = import_stacks.YStack.extractable(
37
+ (0, import_core.themeable)(
38
+ React.forwardRef((props, ref) => {
39
+ const { start, end, colors: colorsProp, locations, children, ...stackProps } = props;
40
+ const colors = useThemeColors(colorsProp || []);
41
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LinearGradientFrame, {
42
+ ref,
43
+ ...stackProps,
44
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_linear_gradient.LinearGradient, {
45
+ start,
46
+ end,
47
+ colors,
48
+ locations,
49
+ style: import_react_native.StyleSheet.absoluteFill,
50
+ children
51
+ })
52
+ });
53
+ })
54
+ )
55
+ );
56
+ const LinearGradientFrame = (0, import_core.styled)(import_stacks.YStack, {
57
+ name: "LinearGradient",
58
+ overflow: "hidden",
59
+ position: "relative"
60
+ });
61
+ const useThemeColors = (colors) => {
62
+ const theme = (0, import_core.useTheme)();
63
+ return colors.map((color) => {
64
+ if (color[0] === "$") {
65
+ return (0, import_core.getVariable)(theme[color] || color);
66
+ }
67
+ return color;
68
+ });
69
+ };
70
+ // Annotate the CommonJS export names for ESM import in node:
71
+ 0 && (module.exports = {
72
+ LinearGradient
73
+ });
74
+ //# sourceMappingURL=LinearGradient.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/LinearGradient.tsx"],
4
+ "sourcesContent": ["import {\n ColorTokens,\n ThemeTokens,\n getVariable,\n styled,\n themeable,\n useTheme,\n} from '@tamagui/core'\nimport { YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { StyleSheet, View } from 'react-native'\n\nimport {\n LinearGradient as ExpoLinearGradient,\n LinearGradientProps as ExpoLinearGradientProps,\n} from './linear-gradient'\n\n//\nexport type LinearGradientProps = Omit<ExpoLinearGradientProps, 'colors'> &\n Omit<YStackProps, 'children' | keyof ExpoLinearGradientProps> & {\n colors?: (ColorTokens | ThemeTokens | (string & {}))[]\n }\n\nexport const LinearGradient: React.ForwardRefExoticComponent<\n LinearGradientProps & React.RefAttributes<HTMLElement | View>\n> = YStack.extractable(\n themeable(\n React.forwardRef((props: LinearGradientProps, ref) => {\n const { start, end, colors: colorsProp, locations, children, ...stackProps } = props\n const colors = useThemeColors(colorsProp || [])\n return (\n // @ts-ignore\n <LinearGradientFrame ref={ref} {...stackProps}>\n <ExpoLinearGradient\n start={start}\n end={end}\n colors={colors}\n locations={locations}\n style={StyleSheet.absoluteFill}\n >\n {children}\n </ExpoLinearGradient>\n </LinearGradientFrame>\n )\n })\n )\n) as any\n\nconst LinearGradientFrame = styled(YStack, {\n name: 'LinearGradient',\n overflow: 'hidden',\n position: 'relative',\n})\n\n// resolve tamagui theme values\nconst useThemeColors = (colors: string[]) => {\n const theme = useTheme()\n return colors.map((color) => {\n if (color[0] === '$') {\n return getVariable(theme[color] || color)\n }\n return color\n })\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiCU;AAjCV,kBAOO;AACP,oBAAoC;AACpC,YAAuB;AACvB,0BAAiC;AAEjC,6BAGO;AAQA,MAAM,iBAET,qBAAO;AAAA,MACT;AAAA,IACE,MAAM,WAAW,CAAC,OAA4B,QAAQ;AACpD,YAAM,EAAE,OAAO,KAAK,QAAQ,YAAY,WAAW,aAAa,WAAW,IAAI;AAC/E,YAAM,SAAS,eAAe,cAAc,CAAC,CAAC;AAC9C,aAEE,4CAAC;AAAA,QAAoB;AAAA,QAAW,GAAG;AAAA,QACjC,sDAAC,uBAAAA,gBAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,OAAO,+BAAW;AAAA,UAEjB;AAAA,SACH;AAAA,OACF;AAAA,IAEJ,CAAC;AAAA,EACH;AACF;AAEA,MAAM,0BAAsB,oBAAO,sBAAQ;AAAA,EACzC,MAAM;AAAA,EACN,UAAU;AAAA,EACV,UAAU;AACZ,CAAC;AAGD,MAAM,iBAAiB,CAAC,WAAqB;AAC3C,QAAM,YAAQ,sBAAS;AACvB,SAAO,OAAO,IAAI,CAAC,UAAU;AAC3B,QAAI,MAAM,OAAO,KAAK;AACpB,iBAAO,yBAAY,MAAM,UAAU,KAAK;AAAA,IAC1C;AACA,WAAO;AAAA,EACT,CAAC;AACH;",
6
+ "names": ["ExpoLinearGradient"]
7
+ }
@@ -0,0 +1,480 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var Select_exports = {};
26
+ __export(Select_exports, {
27
+ Select: () => Select,
28
+ SelectGroupFrame: () => SelectGroupFrame,
29
+ SelectIcon: () => SelectIcon,
30
+ SelectItem: () => SelectItem,
31
+ SelectItemTextFrame: () => SelectItemTextFrame,
32
+ SelectSeparator: () => SelectSeparator,
33
+ SelectTrigger: () => SelectTrigger
34
+ });
35
+ module.exports = __toCommonJS(Select_exports);
36
+ var import_jsx_runtime = require("react/jsx-runtime");
37
+ var import_adapt = require("@tamagui/adapt");
38
+ var import_compose_refs = require("@tamagui/compose-refs");
39
+ var import_core = require("@tamagui/core");
40
+ var import_core2 = require("@tamagui/core");
41
+ var import_core3 = require("@tamagui/core");
42
+ var import_list_item = require("@tamagui/list-item");
43
+ var import_portal = require("@tamagui/portal");
44
+ var import_separator = require("@tamagui/separator");
45
+ var import_sheet = require("@tamagui/sheet");
46
+ var import_stacks = require("@tamagui/stacks");
47
+ var import_text = require("@tamagui/text");
48
+ var import_use_controllable_state = require("@tamagui/use-controllable-state");
49
+ var React = __toESM(require("react"));
50
+ var import_constants = require("./constants");
51
+ var import_context = require("./context");
52
+ var import_SelectContent = require("./SelectContent");
53
+ var import_SelectImpl = require("./SelectImpl");
54
+ var import_SelectScrollButton = require("./SelectScrollButton");
55
+ var import_SelectViewport = require("./SelectViewport");
56
+ var import_useSelectBreakpointActive = require("./useSelectBreakpointActive");
57
+ const TRIGGER_NAME = "SelectTrigger";
58
+ const SelectTrigger = React.forwardRef(
59
+ (props, forwardedRef) => {
60
+ const {
61
+ __scopeSelect,
62
+ disabled = false,
63
+ "aria-labelledby": ariaLabelledby,
64
+ ...triggerProps
65
+ } = props;
66
+ const context = (0, import_context.useSelectContext)(TRIGGER_NAME, __scopeSelect);
67
+ const labelledBy = ariaLabelledby;
68
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_list_item.ListItem, {
69
+ componentName: TRIGGER_NAME,
70
+ backgrounded: true,
71
+ radiused: true,
72
+ hoverTheme: true,
73
+ pressTheme: true,
74
+ focusTheme: true,
75
+ focusable: true,
76
+ borderWidth: 1,
77
+ size: context.size,
78
+ "aria-expanded": context.open,
79
+ "aria-autocomplete": "none",
80
+ "aria-labelledby": labelledBy,
81
+ dir: context.dir,
82
+ disabled,
83
+ "data-disabled": disabled ? "" : void 0,
84
+ ...triggerProps,
85
+ ref: forwardedRef,
86
+ ...process.env.TAMAGUI_TARGET === "web" && context.interactions ? context.interactions.getReferenceProps() : {
87
+ onPress() {
88
+ context.setOpen(!context.open);
89
+ }
90
+ }
91
+ });
92
+ }
93
+ );
94
+ SelectTrigger.displayName = TRIGGER_NAME;
95
+ const VALUE_NAME = "SelectValue";
96
+ const SelectValueFrame = (0, import_core2.styled)(import_text.Paragraph, {
97
+ name: VALUE_NAME,
98
+ selectable: false
99
+ });
100
+ const SelectValue = SelectValueFrame.extractable(
101
+ React.forwardRef(
102
+ ({
103
+ __scopeSelect,
104
+ children: childrenProp,
105
+ placeholder
106
+ }, forwardedRef) => {
107
+ const context = (0, import_context.useSelectContext)(VALUE_NAME, __scopeSelect);
108
+ const { onValueNodeHasChildrenChange } = context;
109
+ const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.onValueNodeChange);
110
+ const children = childrenProp ?? context.selectedItem;
111
+ const hasChildren = !!children;
112
+ const selectValueChildren = context.value === void 0 && placeholder !== void 0 ? placeholder : children;
113
+ (0, import_core2.useIsomorphicLayoutEffect)(() => {
114
+ onValueNodeHasChildrenChange(hasChildren);
115
+ }, [onValueNodeHasChildrenChange, hasChildren]);
116
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectValueFrame, {
117
+ size: context.size,
118
+ ref: composedRefs,
119
+ pointerEvents: "none",
120
+ children: selectValueChildren
121
+ });
122
+ }
123
+ )
124
+ );
125
+ SelectValue.displayName = VALUE_NAME;
126
+ const SelectIcon = (0, import_core2.styled)(import_stacks.XStack, {
127
+ name: "SelectIcon",
128
+ "aria-hidden": true,
129
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_text.Paragraph, {
130
+ children: "\u25BC"
131
+ })
132
+ });
133
+ const ITEM_NAME = "SelectItem";
134
+ const [SelectItemContextProvider, useSelectItemContext] = (0, import_context.createSelectContext)(ITEM_NAME);
135
+ const SelectItem = React.forwardRef(
136
+ (props, forwardedRef) => {
137
+ const {
138
+ __scopeSelect,
139
+ value,
140
+ disabled = false,
141
+ textValue: textValueProp,
142
+ index,
143
+ ...itemProps
144
+ } = props;
145
+ const context = (0, import_context.useSelectContext)(ITEM_NAME, __scopeSelect);
146
+ const isSelected = context.value === value;
147
+ const textId = (0, import_core3.useId)();
148
+ const {
149
+ selectedIndex,
150
+ setSelectedIndex,
151
+ listRef,
152
+ open,
153
+ setOpen,
154
+ onChange,
155
+ setActiveIndex,
156
+ allowMouseUpRef,
157
+ allowSelectRef,
158
+ setValueAtIndex,
159
+ selectTimeoutRef,
160
+ dataRef
161
+ } = context;
162
+ const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, (node) => {
163
+ if (!import_core.isWeb)
164
+ return;
165
+ if (node instanceof HTMLElement) {
166
+ if (listRef) {
167
+ listRef.current[index] = node;
168
+ }
169
+ }
170
+ });
171
+ React.useEffect(() => {
172
+ setValueAtIndex(index, value);
173
+ }, [index, setValueAtIndex, value]);
174
+ function handleSelect() {
175
+ setSelectedIndex(index);
176
+ onChange(value);
177
+ setOpen(false);
178
+ }
179
+ const selectItemProps = context.interactions ? context.interactions.getItemProps({
180
+ onTouchStart() {
181
+ allowSelectRef.current = true;
182
+ allowMouseUpRef.current = false;
183
+ },
184
+ onKeyDown(event) {
185
+ if (event.key === "Enter" || event.key === " " && !(dataRef == null ? void 0 : dataRef.current.typing)) {
186
+ event.preventDefault();
187
+ handleSelect();
188
+ } else {
189
+ allowSelectRef.current = true;
190
+ }
191
+ },
192
+ onClick() {
193
+ if (allowSelectRef.current) {
194
+ setSelectedIndex(index);
195
+ setOpen(false);
196
+ }
197
+ },
198
+ onMouseUp() {
199
+ if (!allowMouseUpRef.current) {
200
+ return;
201
+ }
202
+ if (allowSelectRef.current) {
203
+ handleSelect();
204
+ }
205
+ clearTimeout(selectTimeoutRef.current);
206
+ selectTimeoutRef.current = setTimeout(() => {
207
+ allowSelectRef.current = true;
208
+ });
209
+ }
210
+ }) : {
211
+ onPress: handleSelect
212
+ };
213
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItemContextProvider, {
214
+ scope: __scopeSelect,
215
+ value,
216
+ textId: textId || "",
217
+ isSelected,
218
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_list_item.ListItem, {
219
+ backgrounded: true,
220
+ pressTheme: true,
221
+ cursor: "",
222
+ focusTheme: true,
223
+ outlineWidth: 0,
224
+ componentName: ITEM_NAME,
225
+ ref: composedRefs,
226
+ "aria-labelledby": textId,
227
+ "aria-selected": isSelected,
228
+ "data-state": isSelected ? "active" : "inactive",
229
+ "aria-disabled": disabled || void 0,
230
+ "data-disabled": disabled ? "" : void 0,
231
+ tabIndex: disabled ? void 0 : -1,
232
+ size: context.size,
233
+ ...itemProps,
234
+ ...selectItemProps
235
+ })
236
+ });
237
+ }
238
+ );
239
+ SelectItem.displayName = ITEM_NAME;
240
+ const ITEM_TEXT_NAME = "SelectItemText";
241
+ const SelectItemTextFrame = (0, import_core2.styled)(import_text.SizableText, {
242
+ name: ITEM_TEXT_NAME,
243
+ selectable: false
244
+ });
245
+ const SelectItemText = React.forwardRef(
246
+ (props, forwardedRef) => {
247
+ const { __scopeSelect, className, ...itemTextProps } = props;
248
+ const context = (0, import_context.useSelectContext)(ITEM_TEXT_NAME, __scopeSelect);
249
+ const itemContext = useSelectItemContext(ITEM_TEXT_NAME, __scopeSelect);
250
+ const ref = React.useRef(null);
251
+ const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref);
252
+ const isSelected = Boolean(itemContext.isSelected && context.valueNode);
253
+ const contents = React.useMemo(
254
+ () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItemTextFrame, {
255
+ className,
256
+ size: context.size,
257
+ id: itemContext.textId,
258
+ ...itemTextProps,
259
+ ref: composedRefs
260
+ }),
261
+ [props, context.size, className, itemContext.textId]
262
+ );
263
+ React.useEffect(() => {
264
+ if (isSelected) {
265
+ context.setSelectedItem(contents);
266
+ }
267
+ }, [isSelected, contents]);
268
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
269
+ children: contents
270
+ });
271
+ }
272
+ );
273
+ SelectItemText.displayName = ITEM_TEXT_NAME;
274
+ const ITEM_INDICATOR_NAME = "SelectItemIndicator";
275
+ const SelectItemIndicatorFrame = (0, import_core2.styled)(import_stacks.XStack, {
276
+ name: ITEM_TEXT_NAME
277
+ });
278
+ const SelectItemIndicator = React.forwardRef(
279
+ (props, forwardedRef) => {
280
+ const { __scopeSelect, ...itemIndicatorProps } = props;
281
+ const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
282
+ return itemContext.isSelected ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItemIndicatorFrame, {
283
+ "aria-hidden": true,
284
+ ...itemIndicatorProps,
285
+ ref: forwardedRef
286
+ }) : null;
287
+ }
288
+ );
289
+ SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
290
+ const GROUP_NAME = "SelectGroup";
291
+ const [SelectGroupContextProvider, useSelectGroupContext] = (0, import_context.createSelectContext)(GROUP_NAME);
292
+ const SelectGroupFrame = (0, import_core2.styled)(import_stacks.YStack, {
293
+ name: GROUP_NAME,
294
+ width: "100%"
295
+ });
296
+ const SelectGroup = React.forwardRef(
297
+ (props, forwardedRef) => {
298
+ const { __scopeSelect, ...groupProps } = props;
299
+ const groupId = (0, import_core3.useId)();
300
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectGroupContextProvider, {
301
+ scope: __scopeSelect,
302
+ id: groupId || "",
303
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectGroupFrame, {
304
+ role: "group",
305
+ "aria-labelledby": groupId,
306
+ ...groupProps,
307
+ ref: forwardedRef
308
+ })
309
+ });
310
+ }
311
+ );
312
+ SelectGroup.displayName = GROUP_NAME;
313
+ const LABEL_NAME = "SelectLabel";
314
+ const SelectLabel = React.forwardRef(
315
+ (props, forwardedRef) => {
316
+ const { __scopeSelect, ...labelProps } = props;
317
+ const context = (0, import_context.useSelectContext)(LABEL_NAME, __scopeSelect);
318
+ const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
319
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_list_item.ListItem, {
320
+ componentName: LABEL_NAME,
321
+ fontWeight: "800",
322
+ id: groupContext.id,
323
+ size: context.size,
324
+ ...labelProps,
325
+ ref: forwardedRef
326
+ });
327
+ }
328
+ );
329
+ SelectLabel.displayName = LABEL_NAME;
330
+ const SelectSeparator = (0, import_core2.styled)(import_separator.Separator, {
331
+ name: "SelectSeparator"
332
+ });
333
+ const SelectSheetController = (props) => {
334
+ const context = (0, import_context.useSelectContext)("SelectSheetController", props.__scopeSelect);
335
+ const showSheet = (0, import_useSelectBreakpointActive.useShowSelectSheet)(context);
336
+ const breakpointActive = (0, import_useSelectBreakpointActive.useSelectBreakpointActive)(context.sheetBreakpoint);
337
+ const getShowSheet = (0, import_core2.useGet)(showSheet);
338
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sheet.SheetController, {
339
+ onOpenChange: (val) => {
340
+ if (getShowSheet()) {
341
+ props.onOpenChange(val);
342
+ }
343
+ },
344
+ open: context.open,
345
+ hidden: breakpointActive === false,
346
+ children: props.children
347
+ });
348
+ };
349
+ const SelectSheetImpl = (props) => {
350
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
351
+ children: props.children
352
+ });
353
+ };
354
+ const Select = (0, import_core2.withStaticProperties)(
355
+ (props) => {
356
+ const {
357
+ __scopeSelect,
358
+ children,
359
+ open: openProp,
360
+ defaultOpen,
361
+ onOpenChange,
362
+ value: valueProp,
363
+ defaultValue,
364
+ onValueChange,
365
+ size: sizeProp = "$4",
366
+ dir
367
+ } = props;
368
+ const id = (0, import_core3.useId)();
369
+ const scopeKey = __scopeSelect ? Object.keys(__scopeSelect)[0] ?? id : id;
370
+ const { when, AdaptProvider } = (0, import_adapt.useAdaptParent)({
371
+ Contents: React.useCallback(
372
+ () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalHost, {
373
+ name: `${scopeKey}SheetContents`
374
+ }),
375
+ [scopeKey]
376
+ )
377
+ });
378
+ const sheetBreakpoint = when;
379
+ const isSheet = (0, import_useSelectBreakpointActive.useSelectBreakpointActive)(sheetBreakpoint);
380
+ const SelectImpl = isSheet || !import_core.isWeb ? SelectSheetImpl : import_SelectImpl.SelectInlineImpl;
381
+ const forceUpdate = React.useReducer(() => ({}), {})[1];
382
+ const [selectedItem, setSelectedItem] = React.useState(null);
383
+ const [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
384
+ prop: openProp,
385
+ defaultProp: defaultOpen || false,
386
+ onChange: onOpenChange,
387
+ strategy: "most-recent-wins"
388
+ });
389
+ const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
390
+ prop: valueProp,
391
+ defaultProp: defaultValue || "",
392
+ onChange: onValueChange,
393
+ strategy: "most-recent-wins",
394
+ transition: true
395
+ });
396
+ const [activeIndex, setActiveIndex] = React.useState(null);
397
+ const selectedIndexRef = React.useRef(null);
398
+ const activeIndexRef = React.useRef(null);
399
+ const listContentRef = React.useRef([]);
400
+ const [selectedIndex, setSelectedIndex] = React.useState(
401
+ Math.max(0, listContentRef.current.indexOf(value))
402
+ );
403
+ const [valueNode, setValueNode] = React.useState(null);
404
+ const [valueNodeHasChildren, setValueNodeHasChildren] = React.useState(false);
405
+ (0, import_core2.useIsomorphicLayoutEffect)(() => {
406
+ selectedIndexRef.current = selectedIndex;
407
+ activeIndexRef.current = activeIndex;
408
+ });
409
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AdaptProvider, {
410
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_context.SelectProvider, {
411
+ dir,
412
+ blockSelection: false,
413
+ size: sizeProp,
414
+ fallback: false,
415
+ selectedItem,
416
+ setSelectedItem,
417
+ forceUpdate,
418
+ valueNode,
419
+ onValueNodeChange: setValueNode,
420
+ onValueNodeHasChildrenChange: setValueNodeHasChildren,
421
+ valueNodeHasChildren,
422
+ scopeKey,
423
+ sheetBreakpoint,
424
+ scope: __scopeSelect,
425
+ setValueAtIndex: (index, value2) => {
426
+ listContentRef.current[index] = value2;
427
+ },
428
+ activeIndex,
429
+ onChange: setValue,
430
+ selectedIndex,
431
+ setActiveIndex,
432
+ setOpen,
433
+ setSelectedIndex,
434
+ value,
435
+ open,
436
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectSheetController, {
437
+ onOpenChange: setOpen,
438
+ __scopeSelect,
439
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectImpl, {
440
+ activeIndexRef,
441
+ listContentRef,
442
+ selectedIndexRef,
443
+ ...props,
444
+ open,
445
+ value,
446
+ children
447
+ })
448
+ })
449
+ })
450
+ });
451
+ },
452
+ {
453
+ Adapt: import_adapt.Adapt,
454
+ Content: import_SelectContent.SelectContent,
455
+ Group: SelectGroup,
456
+ Icon: SelectIcon,
457
+ Item: SelectItem,
458
+ ItemIndicator: SelectItemIndicator,
459
+ ItemText: SelectItemText,
460
+ Label: SelectLabel,
461
+ ScrollDownButton: import_SelectScrollButton.SelectScrollDownButton,
462
+ ScrollUpButton: import_SelectScrollButton.SelectScrollUpButton,
463
+ Trigger: SelectTrigger,
464
+ Value: SelectValue,
465
+ Viewport: import_SelectViewport.SelectViewport,
466
+ Sheet: import_sheet.ControlledSheet
467
+ }
468
+ );
469
+ Select.displayName = import_constants.SELECT_NAME;
470
+ // Annotate the CommonJS export names for ESM import in node:
471
+ 0 && (module.exports = {
472
+ Select,
473
+ SelectGroupFrame,
474
+ SelectIcon,
475
+ SelectItem,
476
+ SelectItemTextFrame,
477
+ SelectSeparator,
478
+ SelectTrigger
479
+ });
480
+ //# sourceMappingURL=Select.js.map