@multiplatform.one/forms 7.57.0 → 7.59.0
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/AdaptivePopup/index.cjs +5 -1
- package/dist/cjs/AdaptivePopup/index.native.js +5 -1
- package/dist/cjs/AdaptivePopup/index.native.js.map +1 -1
- package/dist/cjs/Button/index.cjs +2 -1
- package/dist/cjs/Button/index.native.js +2 -1
- package/dist/cjs/Button/index.native.js.map +1 -1
- package/dist/cjs/FloatingPanel/compactFace.cjs +38 -0
- package/dist/cjs/FloatingPanel/compactFace.native.js +42 -0
- package/dist/cjs/FloatingPanel/compactFace.native.js.map +1 -0
- package/dist/cjs/FloatingPanel/index.cjs +38 -9
- package/dist/cjs/FloatingPanel/index.native.js +160 -6
- package/dist/cjs/FloatingPanel/index.native.js.map +1 -1
- package/dist/cjs/FloatingPanel/pointAnchor.cjs +22 -0
- package/dist/cjs/FloatingPanel/pointAnchor.native.js +23 -0
- package/dist/cjs/FloatingPanel/pointAnchor.native.js.map +1 -1
- package/dist/cjs/InputParts/index.cjs +13 -7
- package/dist/cjs/InputParts/index.native.js +13 -7
- package/dist/cjs/InputParts/index.native.js.map +1 -1
- package/dist/cjs/fields/Checkbox/Checkbox.cjs +24 -14
- package/dist/cjs/fields/Checkbox/Checkbox.native.js +38 -22
- package/dist/cjs/fields/Checkbox/Checkbox.native.js.map +1 -1
- package/dist/cjs/fields/RadioGroup/index.cjs +6 -1
- package/dist/cjs/fields/RadioGroup/index.native.js +6 -1
- package/dist/cjs/fields/RadioGroup/index.native.js.map +1 -1
- package/dist/cjs/fields/Select/InlineChoices.cjs +148 -0
- package/dist/cjs/fields/Select/InlineChoices.native.js +163 -0
- package/dist/cjs/fields/Select/InlineChoices.native.js.map +1 -0
- package/dist/cjs/fields/Select/index.cjs +79 -17
- package/dist/cjs/fields/Select/index.native.js +92 -17
- package/dist/cjs/fields/Select/index.native.js.map +1 -1
- package/dist/cjs/fields/Select/shouldInlineChoices.cjs +37 -0
- package/dist/cjs/fields/Select/shouldInlineChoices.native.js +43 -0
- package/dist/cjs/fields/Select/shouldInlineChoices.native.js.map +1 -0
- package/dist/cjs/fields/Switch/index.cjs +22 -10
- package/dist/cjs/fields/Switch/index.native.js +28 -14
- package/dist/cjs/fields/Switch/index.native.js.map +1 -1
- package/dist/cjs/shared/choiceRowPress.cjs +46 -0
- package/dist/cjs/shared/choiceRowPress.native.js +50 -0
- package/dist/cjs/shared/choiceRowPress.native.js.map +1 -0
- package/dist/cjs/shared/overlayStack.cjs +4 -0
- package/dist/cjs/shared/overlayStack.native.js +4 -0
- package/dist/cjs/shared/overlayStack.native.js.map +1 -1
- package/dist/esm/AdaptivePopup/index.mjs +6 -2
- package/dist/esm/AdaptivePopup/index.mjs.map +1 -1
- package/dist/esm/AdaptivePopup/index.native.js +6 -2
- package/dist/esm/AdaptivePopup/index.native.js.map +1 -1
- package/dist/esm/Button/index.mjs +3 -2
- package/dist/esm/Button/index.mjs.map +1 -1
- package/dist/esm/Button/index.native.js +3 -2
- package/dist/esm/Button/index.native.js.map +1 -1
- package/dist/esm/FloatingPanel/compactFace.mjs +11 -0
- package/dist/esm/FloatingPanel/compactFace.mjs.map +1 -0
- package/dist/esm/FloatingPanel/compactFace.native.js +12 -0
- package/dist/esm/FloatingPanel/compactFace.native.js.map +1 -0
- package/dist/esm/FloatingPanel/index.mjs +40 -11
- package/dist/esm/FloatingPanel/index.mjs.map +1 -1
- package/dist/esm/FloatingPanel/index.native.js +162 -8
- package/dist/esm/FloatingPanel/index.native.js.map +1 -1
- package/dist/esm/FloatingPanel/pointAnchor.mjs +22 -1
- package/dist/esm/FloatingPanel/pointAnchor.mjs.map +1 -1
- package/dist/esm/FloatingPanel/pointAnchor.native.js +23 -1
- package/dist/esm/FloatingPanel/pointAnchor.native.js.map +1 -1
- package/dist/esm/InputParts/index.mjs +13 -7
- package/dist/esm/InputParts/index.mjs.map +1 -1
- package/dist/esm/InputParts/index.native.js +13 -7
- package/dist/esm/InputParts/index.native.js.map +1 -1
- package/dist/esm/fields/Checkbox/Checkbox.mjs +24 -14
- package/dist/esm/fields/Checkbox/Checkbox.mjs.map +1 -1
- package/dist/esm/fields/Checkbox/Checkbox.native.js +38 -22
- package/dist/esm/fields/Checkbox/Checkbox.native.js.map +1 -1
- package/dist/esm/fields/RadioGroup/index.mjs +6 -1
- package/dist/esm/fields/RadioGroup/index.mjs.map +1 -1
- package/dist/esm/fields/RadioGroup/index.native.js +6 -1
- package/dist/esm/fields/RadioGroup/index.native.js.map +1 -1
- package/dist/esm/fields/Select/InlineChoices.mjs +123 -0
- package/dist/esm/fields/Select/InlineChoices.mjs.map +1 -0
- package/dist/esm/fields/Select/InlineChoices.native.js +135 -0
- package/dist/esm/fields/Select/InlineChoices.native.js.map +1 -0
- package/dist/esm/fields/Select/index.mjs +82 -20
- package/dist/esm/fields/Select/index.mjs.map +1 -1
- package/dist/esm/fields/Select/index.native.js +95 -20
- package/dist/esm/fields/Select/index.native.js.map +1 -1
- package/dist/esm/fields/Select/shouldInlineChoices.mjs +11 -0
- package/dist/esm/fields/Select/shouldInlineChoices.mjs.map +1 -0
- package/dist/esm/fields/Select/shouldInlineChoices.native.js +14 -0
- package/dist/esm/fields/Select/shouldInlineChoices.native.js.map +1 -0
- package/dist/esm/fields/Switch/index.mjs +22 -10
- package/dist/esm/fields/Switch/index.mjs.map +1 -1
- package/dist/esm/fields/Switch/index.native.js +28 -14
- package/dist/esm/fields/Switch/index.native.js.map +1 -1
- package/dist/esm/shared/choiceRowPress.mjs +20 -0
- package/dist/esm/shared/choiceRowPress.mjs.map +1 -0
- package/dist/esm/shared/choiceRowPress.native.js +21 -0
- package/dist/esm/shared/choiceRowPress.native.js.map +1 -0
- package/dist/esm/shared/overlayStack.mjs +4 -1
- package/dist/esm/shared/overlayStack.mjs.map +1 -1
- package/dist/esm/shared/overlayStack.native.js +4 -1
- package/dist/esm/shared/overlayStack.native.js.map +1 -1
- package/dist/jsx/AdaptivePopup/index.mjs +6 -2
- package/dist/jsx/AdaptivePopup/index.mjs.map +1 -1
- package/dist/jsx/AdaptivePopup/index.native.js +5 -1
- package/dist/jsx/AdaptivePopup/index.native.js.map +1 -1
- package/dist/jsx/Button/index.mjs +3 -2
- package/dist/jsx/Button/index.mjs.map +1 -1
- package/dist/jsx/Button/index.native.js +2 -1
- package/dist/jsx/Button/index.native.js.map +1 -1
- package/dist/jsx/FloatingPanel/compactFace.mjs +11 -0
- package/dist/jsx/FloatingPanel/compactFace.mjs.map +1 -0
- package/dist/jsx/FloatingPanel/compactFace.native.js +42 -0
- package/dist/jsx/FloatingPanel/compactFace.native.js.map +1 -0
- package/dist/jsx/FloatingPanel/index.mjs +40 -11
- package/dist/jsx/FloatingPanel/index.mjs.map +1 -1
- package/dist/jsx/FloatingPanel/index.native.js +160 -6
- package/dist/jsx/FloatingPanel/index.native.js.map +1 -1
- package/dist/jsx/FloatingPanel/pointAnchor.mjs +22 -1
- package/dist/jsx/FloatingPanel/pointAnchor.mjs.map +1 -1
- package/dist/jsx/FloatingPanel/pointAnchor.native.js +23 -0
- package/dist/jsx/FloatingPanel/pointAnchor.native.js.map +1 -1
- package/dist/jsx/InputParts/index.mjs +13 -7
- package/dist/jsx/InputParts/index.mjs.map +1 -1
- package/dist/jsx/InputParts/index.native.js +13 -7
- package/dist/jsx/InputParts/index.native.js.map +1 -1
- package/dist/jsx/fields/Checkbox/Checkbox.mjs +24 -14
- package/dist/jsx/fields/Checkbox/Checkbox.mjs.map +1 -1
- package/dist/jsx/fields/Checkbox/Checkbox.native.js +38 -22
- package/dist/jsx/fields/Checkbox/Checkbox.native.js.map +1 -1
- package/dist/jsx/fields/RadioGroup/index.mjs +6 -1
- package/dist/jsx/fields/RadioGroup/index.mjs.map +1 -1
- package/dist/jsx/fields/RadioGroup/index.native.js +6 -1
- package/dist/jsx/fields/RadioGroup/index.native.js.map +1 -1
- package/dist/jsx/fields/Select/InlineChoices.mjs +123 -0
- package/dist/jsx/fields/Select/InlineChoices.mjs.map +1 -0
- package/dist/jsx/fields/Select/InlineChoices.native.js +163 -0
- package/dist/jsx/fields/Select/InlineChoices.native.js.map +1 -0
- package/dist/jsx/fields/Select/index.mjs +82 -20
- package/dist/jsx/fields/Select/index.mjs.map +1 -1
- package/dist/jsx/fields/Select/index.native.js +92 -17
- package/dist/jsx/fields/Select/index.native.js.map +1 -1
- package/dist/jsx/fields/Select/shouldInlineChoices.mjs +11 -0
- package/dist/jsx/fields/Select/shouldInlineChoices.mjs.map +1 -0
- package/dist/jsx/fields/Select/shouldInlineChoices.native.js +43 -0
- package/dist/jsx/fields/Select/shouldInlineChoices.native.js.map +1 -0
- package/dist/jsx/fields/Switch/index.mjs +22 -10
- package/dist/jsx/fields/Switch/index.mjs.map +1 -1
- package/dist/jsx/fields/Switch/index.native.js +28 -14
- package/dist/jsx/fields/Switch/index.native.js.map +1 -1
- package/dist/jsx/shared/choiceRowPress.mjs +20 -0
- package/dist/jsx/shared/choiceRowPress.mjs.map +1 -0
- package/dist/jsx/shared/choiceRowPress.native.js +50 -0
- package/dist/jsx/shared/choiceRowPress.native.js.map +1 -0
- package/dist/jsx/shared/overlayStack.mjs +4 -1
- package/dist/jsx/shared/overlayStack.mjs.map +1 -1
- package/dist/jsx/shared/overlayStack.native.js +4 -0
- package/dist/jsx/shared/overlayStack.native.js.map +1 -1
- package/package.json +8 -8
- package/src/AdaptivePopup/index.tsx +6 -1
- package/src/Button/Button.controlTiers.spec.tsx +29 -0
- package/src/Button/index.tsx +3 -1
- package/src/FloatingPanel/FloatingPanel.compactFace.spec.tsx +187 -0
- package/src/FloatingPanel/FloatingPanel.menuFace.native.spec.tsx +195 -0
- package/src/FloatingPanel/compactFace.spec.ts +40 -0
- package/src/FloatingPanel/compactFace.ts +32 -0
- package/src/FloatingPanel/index.native.tsx +178 -4
- package/src/FloatingPanel/index.tsx +55 -11
- package/src/FloatingPanel/pointAnchor.spec.ts +80 -0
- package/src/FloatingPanel/pointAnchor.ts +52 -0
- package/src/InputParts/index.tsx +18 -7
- package/src/fields/Checkbox/Checkbox.native.spec.tsx +44 -0
- package/src/fields/Checkbox/Checkbox.tsx +31 -18
- package/src/fields/DatePicker/columnFit.spec.tsx +85 -0
- package/src/fields/RadioGroup/RadioGroup.native.spec.tsx +65 -0
- package/src/fields/RadioGroup/RadioGroup.stories.tsx +49 -0
- package/src/fields/RadioGroup/index.tsx +14 -2
- package/src/fields/Select/InlineChoices.tsx +156 -0
- package/src/fields/Select/index.tsx +100 -45
- package/src/fields/Select/shouldInlineChoices.spec.ts +25 -0
- package/src/fields/Select/shouldInlineChoices.ts +22 -0
- package/src/fields/Switch/Switch.rowPress.native.spec.tsx +69 -0
- package/src/fields/Switch/index.tsx +29 -11
- package/src/fields/pickerRows.spec.tsx +2 -0
- package/src/overlayGround.spec.ts +181 -0
- package/src/shared/choiceRowPress.ts +40 -0
- package/src/shared/overlayStack.tsx +5 -0
- package/types/AdaptivePopup/index.d.ts.map +1 -1
- package/types/Button/index.d.ts.map +1 -1
- package/types/FloatingPanel/compactFace.d.ts +21 -0
- package/types/FloatingPanel/compactFace.d.ts.map +1 -0
- package/types/FloatingPanel/index.d.ts +10 -0
- package/types/FloatingPanel/index.d.ts.map +1 -1
- package/types/FloatingPanel/index.native.d.ts +8 -1
- package/types/FloatingPanel/index.native.d.ts.map +1 -1
- package/types/FloatingPanel/pointAnchor.d.ts +29 -0
- package/types/FloatingPanel/pointAnchor.d.ts.map +1 -1
- package/types/InputParts/index.d.ts.map +1 -1
- package/types/fields/Checkbox/Checkbox.d.ts.map +1 -1
- package/types/fields/Checkbox/index.d.ts +3 -3
- package/types/fields/RadioGroup/index.d.ts.map +1 -1
- package/types/fields/Select/InlineChoices.d.ts +29 -0
- package/types/fields/Select/InlineChoices.d.ts.map +1 -0
- package/types/fields/Select/index.d.ts +6 -0
- package/types/fields/Select/index.d.ts.map +1 -1
- package/types/fields/Select/shouldInlineChoices.d.ts +16 -0
- package/types/fields/Select/shouldInlineChoices.d.ts.map +1 -0
- package/types/fields/Switch/index.d.ts.map +1 -1
- package/types/shared/choiceRowPress.d.ts +40 -0
- package/types/shared/choiceRowPress.d.ts.map +1 -0
- package/types/shared/overlayStack.d.ts +2 -0
- package/types/shared/overlayStack.d.ts.map +1 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { hairline, IconSlot, keyboardFocusRingProps } from "@multiplatform.one/theme";
|
|
2
|
+
import { CheckIcon } from "@phosphor-icons/react";
|
|
3
|
+
import { useRef } from "react";
|
|
4
|
+
import { Pressable } from "react-native-web";
|
|
5
|
+
import { isWeb, Text, View, XStack, YStack } from "tamagui";
|
|
6
|
+
import { useFieldDescribedBy } from "../../fieldLayout.mjs";
|
|
7
|
+
import { formCommonColors, formInputColors } from "../../shared/colorRamps.mjs";
|
|
8
|
+
import { choiceItemA11y } from "../../shared/nativeA11y.mjs";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
const nextKeys = /* @__PURE__ */new Set(["ArrowDown", "ArrowRight"]);
|
|
11
|
+
const previousKeys = /* @__PURE__ */new Set(["ArrowUp", "ArrowLeft"]);
|
|
12
|
+
function InlineChoices({
|
|
13
|
+
options,
|
|
14
|
+
value,
|
|
15
|
+
onValueChange,
|
|
16
|
+
onBlur,
|
|
17
|
+
disabled,
|
|
18
|
+
id,
|
|
19
|
+
labelledBy,
|
|
20
|
+
"aria-label": ariaLabel,
|
|
21
|
+
knobProps,
|
|
22
|
+
markColor
|
|
23
|
+
}) {
|
|
24
|
+
const describedBy = useFieldDescribedBy();
|
|
25
|
+
const rowsRef = useRef([]);
|
|
26
|
+
const textColor = knobProps.textAccentColor;
|
|
27
|
+
const selectedIndex = options.findIndex(option => option.value === value);
|
|
28
|
+
const tabStop = selectedIndex >= 0 ? selectedIndex : 0;
|
|
29
|
+
const choose = index => {
|
|
30
|
+
const option = options[index];
|
|
31
|
+
if (disabled || !option || option.value === value) return;
|
|
32
|
+
onValueChange(option.value);
|
|
33
|
+
};
|
|
34
|
+
const onKeyDown = index => event => {
|
|
35
|
+
const step = nextKeys.has(event.key) ? 1 : previousKeys.has(event.key) ? -1 : 0;
|
|
36
|
+
if (step) {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
const next = (index + step + options.length) % options.length;
|
|
39
|
+
rowsRef.current[next]?.focus();
|
|
40
|
+
choose(next);
|
|
41
|
+
} else if (event.key === " " || event.key === "Enter") {
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
choose(index);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const rowContent = (option, index, selected) => /* @__PURE__ */jsxs(XStack, {
|
|
47
|
+
alignItems: "center",
|
|
48
|
+
height: knobProps.menuRow.minHeight,
|
|
49
|
+
paddingHorizontal: knobProps.panelPadding.padding,
|
|
50
|
+
...knobProps.gap,
|
|
51
|
+
...(index === 0 ? void 0 : hairline.top),
|
|
52
|
+
borderColor: formCommonColors.divider,
|
|
53
|
+
pointerEvents: "none",
|
|
54
|
+
children: [/* @__PURE__ */jsx(View, {
|
|
55
|
+
flexShrink: 0,
|
|
56
|
+
alignItems: "center",
|
|
57
|
+
justifyContent: "center",
|
|
58
|
+
minWidth: 18,
|
|
59
|
+
children: /* @__PURE__ */jsx(IconSlot, {
|
|
60
|
+
icon: option.icon,
|
|
61
|
+
color: textColor
|
|
62
|
+
})
|
|
63
|
+
}), /* @__PURE__ */jsx(Text, {
|
|
64
|
+
fontFamily: knobProps.body.fontFamily,
|
|
65
|
+
fontWeight: knobProps.body.fontWeight,
|
|
66
|
+
color: textColor,
|
|
67
|
+
numberOfLines: 1,
|
|
68
|
+
flex: 1,
|
|
69
|
+
children: option.label
|
|
70
|
+
}), selected ? /* @__PURE__ */jsx(CheckIcon, {
|
|
71
|
+
size: 14,
|
|
72
|
+
weight: "bold",
|
|
73
|
+
color: markColor
|
|
74
|
+
}) : null]
|
|
75
|
+
});
|
|
76
|
+
return /* @__PURE__ */jsx(YStack, {
|
|
77
|
+
id,
|
|
78
|
+
role: "radiogroup",
|
|
79
|
+
"aria-labelledby": labelledBy,
|
|
80
|
+
"aria-label": labelledBy ? void 0 : ariaLabel,
|
|
81
|
+
"aria-describedby": describedBy,
|
|
82
|
+
"aria-disabled": disabled || void 0,
|
|
83
|
+
"data-testid": "select-inline-choices",
|
|
84
|
+
...knobProps.borderRadius,
|
|
85
|
+
borderColor: formInputColors.border.base,
|
|
86
|
+
backgroundColor: formInputColors.background.base,
|
|
87
|
+
overflow: "hidden",
|
|
88
|
+
width: "100%",
|
|
89
|
+
children: options.map((option, index) => {
|
|
90
|
+
const selected = option.value === value;
|
|
91
|
+
if (isWeb) {
|
|
92
|
+
return /* @__PURE__ */jsx(View, {
|
|
93
|
+
ref: node => {
|
|
94
|
+
rowsRef.current[index] = node;
|
|
95
|
+
},
|
|
96
|
+
role: "radio",
|
|
97
|
+
"aria-checked": selected,
|
|
98
|
+
"aria-disabled": disabled || void 0,
|
|
99
|
+
tabIndex: !disabled && index === tabStop ? 0 : -1,
|
|
100
|
+
cursor: disabled ? "default" : "pointer",
|
|
101
|
+
onPress: () => choose(index),
|
|
102
|
+
onKeyDown: onKeyDown(index),
|
|
103
|
+
onBlur,
|
|
104
|
+
outlineWidth: 0,
|
|
105
|
+
focusVisibleStyle: keyboardFocusRingProps,
|
|
106
|
+
children: rowContent(option, index, selected)
|
|
107
|
+
}, option.value);
|
|
108
|
+
}
|
|
109
|
+
return /* @__PURE__ */jsx(Pressable, {
|
|
110
|
+
...choiceItemA11y({
|
|
111
|
+
name: option.label,
|
|
112
|
+
selected,
|
|
113
|
+
disabled: !!disabled
|
|
114
|
+
}),
|
|
115
|
+
disabled,
|
|
116
|
+
onPress: () => choose(index),
|
|
117
|
+
children: rowContent(option, index, selected)
|
|
118
|
+
}, option.value);
|
|
119
|
+
})
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
export { InlineChoices };
|
|
123
|
+
//# sourceMappingURL=InlineChoices.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["hairline","IconSlot","keyboardFocusRingProps","CheckIcon","useRef","Pressable","isWeb","Text","View","XStack","YStack","useFieldDescribedBy","formCommonColors","formInputColors","choiceItemA11y","jsx","jsxs","nextKeys","Set","previousKeys","InlineChoices","options","value","onValueChange","onBlur","disabled","id","labelledBy","ariaLabel","knobProps","markColor","describedBy","rowsRef","textColor","textAccentColor","selectedIndex","findIndex","option","tabStop","choose","index","onKeyDown","event","step","has","key","preventDefault","next","length","current","focus","rowContent","selected","alignItems","height","menuRow","minHeight","paddingHorizontal","panelPadding","padding","gap","top","borderColor","divider","pointerEvents","children","flexShrink","justifyContent","minWidth","icon","color","fontFamily","body","fontWeight","numberOfLines","flex","label","size","weight","role","borderRadius","border","base","backgroundColor","background","overflow","width","map","ref","node","tabIndex","cursor","onPress","outlineWidth","focusVisibleStyle","name"],"sources":["../../../../src/fields/Select/InlineChoices.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAA,EAAUC,QAAA,EAAUC,sBAAA,QAA8B;AAC3D,SAASC,SAAA,QAAiB;AAC1B,SAASC,MAAA,QAAkD;AAC3D,SAASC,SAAA,QAAiB;AAC1B,SAASC,KAAA,EAAOC,IAAA,EAAMC,IAAA,EAAMC,MAAA,EAAQC,MAAA,QAAc;AAClD,SAASC,mBAAA,QAA2B;AACpC,SAASC,gBAAA,EAAkBC,eAAA,QAAuB;AAClD,SAASC,cAAA,QAAsB;AAuE3B,SAUIC,GAAA,EAVJC,IAAA;AAhDJ,MAAMC,QAAA,GAAW,mBAAIC,GAAA,CAAI,CAAC,aAAa,YAAY,CAAC;AACpD,MAAMC,YAAA,GAAe,mBAAID,GAAA,CAAI,CAAC,WAAW,WAAW,CAAC;AAS9C,SAASE,cAAc;EAC5BC,OAAA;EACAC,KAAA;EACAC,aAAA;EACAC,MAAA;EACAC,QAAA;EACAC,EAAA;EACAC,UAAA;EACA,cAAcC,SAAA;EACdC,SAAA;EACAC;AACF,GAAuB;EACrB,MAAM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
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var InlineChoices_exports = {};
|
|
26
|
+
__export(InlineChoices_exports, {
|
|
27
|
+
InlineChoices: () => InlineChoices
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(InlineChoices_exports);
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
var import_theme = require("@multiplatform.one/theme");
|
|
32
|
+
var import_react = require("@phosphor-icons/react");
|
|
33
|
+
var import_react2 = require("react");
|
|
34
|
+
var import_react_native = require("react-native");
|
|
35
|
+
var import_tamagui = require("tamagui");
|
|
36
|
+
var import_fieldLayout = require("../../fieldLayout.native.js");
|
|
37
|
+
var import_colorRamps = require("../../shared/colorRamps.native.js");
|
|
38
|
+
var import_nativeA11y = require("../../shared/nativeA11y.native.js");
|
|
39
|
+
var nextKeys = /* @__PURE__ */new Set(["ArrowDown", "ArrowRight"]);
|
|
40
|
+
var previousKeys = /* @__PURE__ */new Set(["ArrowUp", "ArrowLeft"]);
|
|
41
|
+
function InlineChoices(param) {
|
|
42
|
+
var {
|
|
43
|
+
options,
|
|
44
|
+
value,
|
|
45
|
+
onValueChange,
|
|
46
|
+
onBlur,
|
|
47
|
+
disabled,
|
|
48
|
+
id,
|
|
49
|
+
labelledBy,
|
|
50
|
+
"aria-label": ariaLabel,
|
|
51
|
+
knobProps,
|
|
52
|
+
markColor
|
|
53
|
+
} = param;
|
|
54
|
+
var describedBy = (0, import_fieldLayout.useFieldDescribedBy)();
|
|
55
|
+
var rowsRef = (0, import_react2.useRef)([]);
|
|
56
|
+
var textColor = knobProps.textAccentColor;
|
|
57
|
+
var selectedIndex = options.findIndex(function (option) {
|
|
58
|
+
return option.value === value;
|
|
59
|
+
});
|
|
60
|
+
var tabStop = selectedIndex >= 0 ? selectedIndex : 0;
|
|
61
|
+
var choose = function choose2(index) {
|
|
62
|
+
var option = options[index];
|
|
63
|
+
if (disabled || !option || option.value === value) return;
|
|
64
|
+
onValueChange(option.value);
|
|
65
|
+
};
|
|
66
|
+
var onKeyDown = function onKeyDown2(index) {
|
|
67
|
+
return function (event) {
|
|
68
|
+
var step = nextKeys.has(event.key) ? 1 : previousKeys.has(event.key) ? -1 : 0;
|
|
69
|
+
if (step) {
|
|
70
|
+
var _rowsRef_current_next;
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
var next = (index + step + options.length) % options.length;
|
|
73
|
+
(_rowsRef_current_next = rowsRef.current[next]) === null || _rowsRef_current_next === void 0 ? void 0 : _rowsRef_current_next.focus();
|
|
74
|
+
choose(next);
|
|
75
|
+
} else if (event.key === " " || event.key === "Enter") {
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
choose(index);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
var rowContent = function rowContent2(option, index, selected) {
|
|
82
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.XStack, {
|
|
83
|
+
alignItems: "center",
|
|
84
|
+
height: knobProps.menuRow.minHeight,
|
|
85
|
+
paddingHorizontal: knobProps.panelPadding.padding,
|
|
86
|
+
...knobProps.gap,
|
|
87
|
+
...(index === 0 ? void 0 : import_theme.hairline.top),
|
|
88
|
+
borderColor: import_colorRamps.formCommonColors.divider,
|
|
89
|
+
pointerEvents: "none",
|
|
90
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.View, {
|
|
91
|
+
flexShrink: 0,
|
|
92
|
+
alignItems: "center",
|
|
93
|
+
justifyContent: "center",
|
|
94
|
+
minWidth: 18,
|
|
95
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_theme.IconSlot, {
|
|
96
|
+
icon: option.icon,
|
|
97
|
+
color: textColor
|
|
98
|
+
})
|
|
99
|
+
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.Text, {
|
|
100
|
+
fontFamily: knobProps.body.fontFamily,
|
|
101
|
+
fontWeight: knobProps.body.fontWeight,
|
|
102
|
+
color: textColor,
|
|
103
|
+
numberOfLines: 1,
|
|
104
|
+
flex: 1,
|
|
105
|
+
children: option.label
|
|
106
|
+
}), selected ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react.CheckIcon, {
|
|
107
|
+
size: 14,
|
|
108
|
+
weight: "bold",
|
|
109
|
+
color: markColor
|
|
110
|
+
}) : null]
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
|
|
114
|
+
id,
|
|
115
|
+
role: "radiogroup",
|
|
116
|
+
"aria-labelledby": labelledBy,
|
|
117
|
+
"aria-label": labelledBy ? void 0 : ariaLabel,
|
|
118
|
+
"aria-describedby": describedBy,
|
|
119
|
+
"aria-disabled": disabled || void 0,
|
|
120
|
+
"data-testid": "select-inline-choices",
|
|
121
|
+
...knobProps.borderRadius,
|
|
122
|
+
borderColor: import_colorRamps.formInputColors.border.base,
|
|
123
|
+
backgroundColor: import_colorRamps.formInputColors.background.base,
|
|
124
|
+
overflow: "hidden",
|
|
125
|
+
width: "100%",
|
|
126
|
+
children: options.map(function (option, index) {
|
|
127
|
+
var selected = option.value === value;
|
|
128
|
+
if (import_tamagui.isWeb) {
|
|
129
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.View, {
|
|
130
|
+
ref: function ref(node) {
|
|
131
|
+
rowsRef.current[index] = node;
|
|
132
|
+
},
|
|
133
|
+
role: "radio",
|
|
134
|
+
"aria-checked": selected,
|
|
135
|
+
"aria-disabled": disabled || void 0,
|
|
136
|
+
tabIndex: !disabled && index === tabStop ? 0 : -1,
|
|
137
|
+
cursor: disabled ? "default" : "pointer",
|
|
138
|
+
onPress: function onPress() {
|
|
139
|
+
return choose(index);
|
|
140
|
+
},
|
|
141
|
+
onKeyDown: onKeyDown(index),
|
|
142
|
+
onBlur,
|
|
143
|
+
outlineWidth: 0,
|
|
144
|
+
focusVisibleStyle: import_theme.keyboardFocusRingProps,
|
|
145
|
+
children: rowContent(option, index, selected)
|
|
146
|
+
}, option.value);
|
|
147
|
+
}
|
|
148
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.Pressable, {
|
|
149
|
+
...(0, import_nativeA11y.choiceItemA11y)({
|
|
150
|
+
name: option.label,
|
|
151
|
+
selected,
|
|
152
|
+
disabled: !!disabled
|
|
153
|
+
}),
|
|
154
|
+
disabled,
|
|
155
|
+
onPress: function onPress() {
|
|
156
|
+
return choose(index);
|
|
157
|
+
},
|
|
158
|
+
children: rowContent(option, index, selected)
|
|
159
|
+
}, option.value);
|
|
160
|
+
})
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=InlineChoices.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","InlineChoices_exports","InlineChoices","module","exports","import_jsx_runtime","require","import_theme","import_react","import_react2","import_react_native","import_tamagui","import_fieldLayout","import_colorRamps","import_nativeA11y","nextKeys","Set","previousKeys","param","options","onValueChange","onBlur","disabled","id","labelledBy","ariaLabel","knobProps","markColor","describedBy","useFieldDescribedBy","rowsRef","useRef","textColor","textAccentColor","selectedIndex","findIndex","option","tabStop","choose","choose2","index","onKeyDown","onKeyDown2","event","step","has","_rowsRef_current_next","preventDefault","next","length","current","focus","rowContent","rowContent2","selected","jsxs","XStack","alignItems","height","menuRow","minHeight","paddingHorizontal","panelPadding","padding","gap","hairline","top","borderColor","formCommonColors","divider","pointerEvents","children","jsx","View","flexShrink","justifyContent","minWidth","IconSlot","icon","color","Text","fontFamily","body","fontWeight","numberOfLines","flex","label","CheckIcon","size","weight","YStack","role","borderRadius","formInputColors","border","base","backgroundColor","background","overflow","width","map","isWeb","ref","node"],"sources":["../../../../src/fields/Select/InlineChoices.tsx"],"sourcesContent":[null],"mappings":"AAAA,YAAS;;AACT,IAAAA,SAAS,GAAAC,MAAA,CAAAC,cAAiB;AAC1B,IAAAC,gBAAS,GAAkDF,MAAA,CAAAG,wBAAA;AAC3D,IAAAC,iBAAS,GAAAJ,MAAiB,CAAAK,mBAAA;AAC1B,IAAAC,YAAgB,GAAAN,MAAM,CAAAO,SAAM,CAAQC,cAAc;AAClD,IAAAC,QAAS,GAAAA,CAAAC,MAAA,EAAAC,GAAA;EACT,SAASC,IAAA,IAAAD,GAAA,EACTZ,SAAS,CAAAW,MAAA,EAAAE,IAAA;IAAAC,GAAsB,EAAAF,GAAA,CAAAC,IAAA;IAAAE,UAAA;EAAA;AAuE3B;AAhDJ,IAAAC,WAAM,GAAWA,CAAAC,EAAA,EAAAC,IAAA,EAAAC,MAAA,EAAIC,IAAI,KAAC;EAC1B,IAAMF,IAAA,WAAeA,IAA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CAAAmE,GAAA,EAAA7D,cAAA,CAAA+E,MAAA;IAAAnE,EAAA;IAEgBoE,IAAA;IAAA,iBAfvB,EAAAnE,UAAA;IAAA,YAgBd,EAAAA,UAAA,YAAAC,SAAA;IAAA,kBAEJ,EAAAG,WAAA;IACA,eACE,EAAAN,QAAA;IAAA,aAAC;IAAA,GAAAI,SAAA,CAAAkE,YAAA;IAAAzB,WAEK,EAAAtD,iBAAiB,CAAAgF,eAAa,CAAAC,MAAO,CAAAC,IAAU;IAAsBC,eACzE,EAAAnF,iBAAA,CAAAgF,eAAA,CAAAI,UAAA,CAAAF,IAAA;IAAAG,QACA,UAAS;IAAkBC,KAAA,QAE1B;IAAkC5B,QAAA,EAAApD,OAAA,CAAAiF,GAAA,WAAAhE,MAAA,EAAAI,KAAA;MAAA,IAL9Bc,QAAO,GAAAlB,MAAA,CAAApC,KAAA,KAAAA,KAAA;MAAA,IAMdW,cAAA,CAAA0F,KAAA;QAEH,0BAAAhG,kBAAA,CAAAmE,GAAA,EAAA7D,cAAA,CAAA8D,IAAA;UAAA6B,GAAA,WAAAA,IAAAC,IAAA;YACHzE,OAAA,CAAAoB,OAAA,CAAAV,KAAA,IAAA+D,IAAA;UAEJ","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useTouchSurface } from "@multiplatform.one/theme";
|
|
2
|
-
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, memo } from "react";
|
|
1
|
+
import { IconSlot, useTouchSurface } from "@multiplatform.one/theme";
|
|
2
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, memo } from "react";
|
|
3
3
|
import { CaretDownIcon, CheckIcon } from "@phosphor-icons/react";
|
|
4
4
|
import { useClick, useDismiss, useInteractions, useListNavigation, useRole, useTypeahead, FloatingFocusManager } from "@floating-ui/react";
|
|
5
5
|
import { ensureKeyboardModalityTracking, keyboardFocusRingProps, menuRowFrame, sizeRecipeForToken, useGlyphColor, wasKeyboardFocus, transitionProps, Text as HouseText } from "@multiplatform.one/theme";
|
|
@@ -16,13 +16,16 @@ import { warnSelectTooFewOptions } from "../../shared/devWarn.mjs";
|
|
|
16
16
|
import { getFieldError, getFieldHeight, mergeFieldHandler, useFormField, useResolvedValidators } from "../../shared/utils.mjs";
|
|
17
17
|
import { ScrollArrow } from "../../shared/floatingList.mjs";
|
|
18
18
|
import { FloatingPanel, useFloatingPanel, panelViewportPadding, useViewportGtSm } from "../../FloatingPanel/index.mjs";
|
|
19
|
+
import { pickerCompactFace, resolveCompactFace } from "../../FloatingPanel/compactFace.mjs";
|
|
19
20
|
import { PanelPortal } from "../../FloatingPanel/PanelPortal.mjs";
|
|
20
|
-
import { useOverlayZIndex } from "../../shared/overlayStack.mjs";
|
|
21
|
+
import { useInsideOverlay, useOverlayZIndex } from "../../shared/overlayStack.mjs";
|
|
21
22
|
import { useDragScroll } from "../../shared/useDragScroll.mjs";
|
|
22
23
|
import { useIsInTableCell } from "../../shared/tableCellContext.mjs";
|
|
23
24
|
import { t } from "../../shared/t.mjs";
|
|
24
25
|
import { orderOptionsBySelected } from "../selectedOrder.mjs";
|
|
25
26
|
import { shouldUseIosNativeSelect } from "../nativeSelect.mjs";
|
|
27
|
+
import { InlineChoices } from "./InlineChoices.mjs";
|
|
28
|
+
import { shouldInlineChoices } from "./shouldInlineChoices.mjs";
|
|
26
29
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
27
30
|
const actionSheetIOS = ReactNative.ActionSheetIOS;
|
|
28
31
|
const selectOutlineRest = {
|
|
@@ -47,9 +50,10 @@ const SelectRow = styled(View, {
|
|
|
47
50
|
// Do not put outlineWidth here — Tamagui maps these onto mouse :focus and
|
|
48
51
|
// they beat instance ring props. Rows paint the ring via selectItemRingProps.
|
|
49
52
|
variants: {
|
|
53
|
+
// LC-262: the accent check alone marks the chosen row, never a grey fill.
|
|
50
54
|
selected: {
|
|
51
55
|
true: {
|
|
52
|
-
backgroundColor:
|
|
56
|
+
backgroundColor: "transparent",
|
|
53
57
|
borderRadius: 0
|
|
54
58
|
},
|
|
55
59
|
false: {
|
|
@@ -70,6 +74,21 @@ const SelectRow = styled(View, {
|
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
76
|
});
|
|
77
|
+
function OptionGlyph({
|
|
78
|
+
icon,
|
|
79
|
+
color
|
|
80
|
+
}) {
|
|
81
|
+
return /* @__PURE__ */jsx(View, {
|
|
82
|
+
flexShrink: 0,
|
|
83
|
+
alignItems: "center",
|
|
84
|
+
justifyContent: "center",
|
|
85
|
+
minWidth: 18,
|
|
86
|
+
children: /* @__PURE__ */jsx(IconSlot, {
|
|
87
|
+
icon,
|
|
88
|
+
color
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
}
|
|
73
92
|
function GroupHeader(props) {
|
|
74
93
|
return /* @__PURE__ */jsx(HouseText, {
|
|
75
94
|
paddingHorizontal: "$3",
|
|
@@ -267,7 +286,7 @@ const SelectItem = memo(function SelectItem2({
|
|
|
267
286
|
role: "option",
|
|
268
287
|
tabIndex: -1,
|
|
269
288
|
selected: isSelected,
|
|
270
|
-
active: isActive,
|
|
289
|
+
active: Boolean(isActive) && ctx.kbNav,
|
|
271
290
|
"aria-selected": isSelected,
|
|
272
291
|
"data-state": isSelected ? "active" : "inactive",
|
|
273
292
|
height: ctx.knobProps.menuRow.minHeight,
|
|
@@ -276,15 +295,18 @@ const SelectItem = memo(function SelectItem2({
|
|
|
276
295
|
onMouseEnter: () => setActiveIndex(index),
|
|
277
296
|
...(suppressHover ? {
|
|
278
297
|
hoverStyle: {
|
|
279
|
-
backgroundColor: isActive ? formInputColors.background.focus :
|
|
298
|
+
backgroundColor: isActive ? formInputColors.background.focus : "transparent"
|
|
280
299
|
}
|
|
281
300
|
} : {
|
|
282
301
|
hoverStyle: {
|
|
283
|
-
backgroundColor:
|
|
302
|
+
backgroundColor: formInputColors.background.focus
|
|
284
303
|
}
|
|
285
304
|
}),
|
|
286
305
|
...transitionProps(ctx.knobProps.motion.control),
|
|
287
|
-
children: [/* @__PURE__ */jsx(
|
|
306
|
+
children: [option.icon ? /* @__PURE__ */jsx(OptionGlyph, {
|
|
307
|
+
icon: option.icon,
|
|
308
|
+
color: ctx.textColor
|
|
309
|
+
}) : null, /* @__PURE__ */jsx(Text, {
|
|
288
310
|
fontFamily: ctx.knobProps.body.fontFamily,
|
|
289
311
|
fontWeight: ctx.knobProps.body.fontWeight,
|
|
290
312
|
color: ctx.textColor,
|
|
@@ -928,6 +950,9 @@ function NativeSelectCore({
|
|
|
928
950
|
dismissible,
|
|
929
951
|
native
|
|
930
952
|
}) {
|
|
953
|
+
const insideOverlay = useInsideOverlay();
|
|
954
|
+
const compactFace = pickerCompactFace(options.length);
|
|
955
|
+
const asMenu = resolveCompactFace(compactFace, insideOverlay) === "menu";
|
|
931
956
|
const hydrationTouch = useTouchSurface();
|
|
932
957
|
const describedBy = useFieldDescribedBy();
|
|
933
958
|
const fieldA11y = useFieldA11y();
|
|
@@ -1067,16 +1092,19 @@ function NativeSelectCore({
|
|
|
1067
1092
|
onPointerDown: isWeb ? () => setKbNav(false) : void 0,
|
|
1068
1093
|
...(isWeb ? selectItemRingProps(active, kbNav) : void 0),
|
|
1069
1094
|
hoverStyle: activeIndex != null ? {
|
|
1070
|
-
backgroundColor: active ? formInputColors.background.focus :
|
|
1095
|
+
backgroundColor: active ? formInputColors.background.focus : "transparent"
|
|
1071
1096
|
} : {
|
|
1072
|
-
backgroundColor:
|
|
1097
|
+
backgroundColor: formInputColors.background.focus
|
|
1073
1098
|
},
|
|
1074
|
-
backgroundColor: active
|
|
1099
|
+
backgroundColor: active && kbNav ? formInputColors.background.focus : "transparent",
|
|
1075
1100
|
pressStyle: {
|
|
1076
1101
|
backgroundColor: formInputColors.background.focus
|
|
1077
1102
|
},
|
|
1078
1103
|
pointerEvents: isWeb ? void 0 : "none",
|
|
1079
|
-
children: [/* @__PURE__ */jsx(
|
|
1104
|
+
children: [option.icon ? /* @__PURE__ */jsx(OptionGlyph, {
|
|
1105
|
+
icon: option.icon,
|
|
1106
|
+
color: textColor
|
|
1107
|
+
}) : null, /* @__PURE__ */jsx(Text, {
|
|
1080
1108
|
fontFamily: knobProps.body.fontFamily,
|
|
1081
1109
|
fontWeight: knobProps.body.fontWeight,
|
|
1082
1110
|
color: textColor,
|
|
@@ -1101,7 +1129,7 @@ function NativeSelectCore({
|
|
|
1101
1129
|
})]
|
|
1102
1130
|
});
|
|
1103
1131
|
const triggerValueText = multiple ? selectedValues.length > 0 ? selectedValues.map(getLabel).join(", ") : placeholder : selectedOption?.label ?? placeholder;
|
|
1104
|
-
if (shouldUseIosNativeSelect({
|
|
1132
|
+
if (!asMenu && shouldUseIosNativeSelect({
|
|
1105
1133
|
native,
|
|
1106
1134
|
multiple,
|
|
1107
1135
|
isWeb,
|
|
@@ -1178,6 +1206,7 @@ function NativeSelectCore({
|
|
|
1178
1206
|
if (!val) onBlur?.();
|
|
1179
1207
|
},
|
|
1180
1208
|
sheet: true,
|
|
1209
|
+
compactFace,
|
|
1181
1210
|
triggerA11y: {
|
|
1182
1211
|
label: ariaLabel ?? fieldA11y?.label,
|
|
1183
1212
|
value: triggerValueText,
|
|
@@ -1270,6 +1299,9 @@ function NativeSelectCore({
|
|
|
1270
1299
|
children: listContent
|
|
1271
1300
|
});
|
|
1272
1301
|
}
|
|
1302
|
+
const subscribeNothing = () => () => {};
|
|
1303
|
+
const clientSnapshot = () => true;
|
|
1304
|
+
const serverSnapshot = () => false;
|
|
1273
1305
|
function Select({
|
|
1274
1306
|
name,
|
|
1275
1307
|
form: formProp,
|
|
@@ -1316,15 +1348,27 @@ function Select({
|
|
|
1316
1348
|
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
|
|
1317
1349
|
const isControlled = value !== void 0;
|
|
1318
1350
|
const hasLabel = Boolean(label);
|
|
1319
|
-
warnSelectTooFewOptions({
|
|
1320
|
-
count: options?.length ?? 0,
|
|
1321
|
-
multiple,
|
|
1322
|
-
component: "Select",
|
|
1323
|
-
id
|
|
1324
|
-
});
|
|
1325
1351
|
const viewportGtSm = useViewportGtSm();
|
|
1352
|
+
const insideOverlay = useInsideOverlay();
|
|
1326
1353
|
const effectiveGtSm = typeof window !== "undefined" ? viewportGtSm : false;
|
|
1327
|
-
const
|
|
1354
|
+
const hydrated = useSyncExternalStore(subscribeNothing, clientSnapshot, serverSnapshot);
|
|
1355
|
+
const compactMenu = hydrated && resolveCompactFace(pickerCompactFace(options?.length ?? 0), insideOverlay) === "menu";
|
|
1356
|
+
const shouldUseSheet = !isWeb || !effectiveGtSm && !compactMenu;
|
|
1357
|
+
const inTableCell = useIsInTableCell();
|
|
1358
|
+
const inline = !inTableCell && shouldInlineChoices({
|
|
1359
|
+
insideOverlay,
|
|
1360
|
+
multiple,
|
|
1361
|
+
options
|
|
1362
|
+
});
|
|
1363
|
+
if (!inline) {
|
|
1364
|
+
warnSelectTooFewOptions({
|
|
1365
|
+
count: options?.length ?? 0,
|
|
1366
|
+
multiple,
|
|
1367
|
+
component: "Select",
|
|
1368
|
+
id
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
const markColor = useSelectedMarkColor();
|
|
1328
1372
|
if (skeleton) {
|
|
1329
1373
|
return /* @__PURE__ */jsxs(InputParts, {
|
|
1330
1374
|
size: sizeProp || knobProps.sizeToken,
|
|
@@ -1374,6 +1418,24 @@ function Select({
|
|
|
1374
1418
|
};
|
|
1375
1419
|
const renderSelectContent = (selectValue, handleValueChange, handleBlur) => {
|
|
1376
1420
|
if (readOnly) return renderReadOnly(selectValue);
|
|
1421
|
+
if (inline) {
|
|
1422
|
+
return /* @__PURE__ */jsx(InlineChoices, {
|
|
1423
|
+
options,
|
|
1424
|
+
value: typeof selectValue === "string" ? selectValue : void 0,
|
|
1425
|
+
onValueChange: val => {
|
|
1426
|
+
if (disabled) return;
|
|
1427
|
+
handleValueChange?.(val);
|
|
1428
|
+
emitValueChange(val);
|
|
1429
|
+
},
|
|
1430
|
+
onBlur: handleBlur,
|
|
1431
|
+
disabled,
|
|
1432
|
+
id,
|
|
1433
|
+
labelledBy: hasLabel ? `${id}-label` : void 0,
|
|
1434
|
+
"aria-label": ariaLabel,
|
|
1435
|
+
knobProps,
|
|
1436
|
+
markColor
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1377
1439
|
const SelectCore = shouldUseSheet ? NativeSelectCore : FloatingSelectCore;
|
|
1378
1440
|
return /* @__PURE__ */jsx(SelectCore, {
|
|
1379
1441
|
options,
|