@ecohouse/ui 0.1.53 → 0.1.55
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/index.cjs +267 -128
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +267 -128
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Avatar/Avatar.stories.tsx +8 -0
- package/src/components/Avatar/Avatar.tsx +103 -8
- package/src/components/Avatar/index.ts +1 -1
- package/src/components/LanguageSwitcher/LanguageSwitcher.tsx +45 -25
- package/src/components/Select/Select.tsx +163 -105
- package/src/components/index.ts +1 -1
- package/src/index.ts +1 -0
- package/src/theme/colors.test.ts +2 -1
- package/src/theme/colors.ts +2 -1
package/dist/index.js
CHANGED
|
@@ -27555,7 +27555,7 @@ var require_react_dom_development = __commonJS({
|
|
|
27555
27555
|
return root2;
|
|
27556
27556
|
}
|
|
27557
27557
|
var ReactVersion = "18.3.1";
|
|
27558
|
-
function
|
|
27558
|
+
function createPortal4(children, containerInfo, implementation) {
|
|
27559
27559
|
var key = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null;
|
|
27560
27560
|
{
|
|
27561
27561
|
checkKeyStringCoercion(key);
|
|
@@ -28411,7 +28411,7 @@ var require_react_dom_development = __commonJS({
|
|
|
28411
28411
|
if (!isValidContainer(container)) {
|
|
28412
28412
|
throw new Error("Target container is not a DOM element.");
|
|
28413
28413
|
}
|
|
28414
|
-
return
|
|
28414
|
+
return createPortal4(children, container, null, key);
|
|
28415
28415
|
}
|
|
28416
28416
|
function renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) {
|
|
28417
28417
|
return unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback);
|
|
@@ -28535,9 +28535,10 @@ var colors = {
|
|
|
28535
28535
|
whiteAlpha40: "#FFFFFF66",
|
|
28536
28536
|
whiteAlpha20: "#FFFFFF33",
|
|
28537
28537
|
whiteAlpha1: "#FFFFFF03",
|
|
28538
|
+
whiteAlpha5: "#FFFFFF0D",
|
|
28538
28539
|
whiteAlpha6: "#FFFFFF0F",
|
|
28540
|
+
whiteAlpha7: "#FFFFFF12",
|
|
28539
28541
|
whiteAlpha10: "#FFFFFF1A",
|
|
28540
|
-
whiteAlpha5: "#FFFFFF0D",
|
|
28541
28542
|
dark: "#090909",
|
|
28542
28543
|
red: "#A63E3E",
|
|
28543
28544
|
lightGrey: "#B7B7B7",
|
|
@@ -31295,10 +31296,19 @@ function BrandLogo({
|
|
|
31295
31296
|
);
|
|
31296
31297
|
}
|
|
31297
31298
|
var IMAGE_SIZE = 48;
|
|
31299
|
+
var CONTAINER_HEIGHT = 56;
|
|
31298
31300
|
var CONTAINER_RADIUS = 71;
|
|
31299
31301
|
var CHEVRON_SIZE = 20;
|
|
31300
31302
|
var FALLBACK_ICON_SIZE = 20;
|
|
31301
31303
|
var MENU_RADIUS = 16;
|
|
31304
|
+
var triggerWebBlurStyle = Platform.OS === "web" ? {
|
|
31305
|
+
backdropFilter: "blur(40px)",
|
|
31306
|
+
WebkitBackdropFilter: "blur(40px)"
|
|
31307
|
+
} : {};
|
|
31308
|
+
var menuWebBlurStyle = Platform.OS === "web" ? {
|
|
31309
|
+
backdropFilter: "blur(40px)",
|
|
31310
|
+
WebkitBackdropFilter: "blur(40px)"
|
|
31311
|
+
} : {};
|
|
31302
31312
|
var Avatar = forwardRef(function Avatar2({
|
|
31303
31313
|
name,
|
|
31304
31314
|
email,
|
|
@@ -31306,6 +31316,7 @@ var Avatar = forwardRef(function Avatar2({
|
|
|
31306
31316
|
onPress,
|
|
31307
31317
|
disabled = false,
|
|
31308
31318
|
showChevron = true,
|
|
31319
|
+
variant = "light",
|
|
31309
31320
|
menuItems,
|
|
31310
31321
|
open: openProp,
|
|
31311
31322
|
defaultOpen = false,
|
|
@@ -31327,6 +31338,7 @@ var Avatar = forwardRef(function Avatar2({
|
|
|
31327
31338
|
const isOpenControlled = typeof openProp === "boolean";
|
|
31328
31339
|
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
31329
31340
|
const isOpen = hasMenu && (isOpenControlled ? openProp : uncontrolledOpen);
|
|
31341
|
+
const isLightVariant = variant === "light";
|
|
31330
31342
|
useApplyWebClassName(containerRef, className);
|
|
31331
31343
|
const setOpen = useCallback(
|
|
31332
31344
|
(next) => {
|
|
@@ -31396,7 +31408,13 @@ var Avatar = forwardRef(function Avatar2({
|
|
|
31396
31408
|
accessibilityRole: isInteractive ? "button" : void 0,
|
|
31397
31409
|
accessibilityLabel: resolvedAccessibilityLabel,
|
|
31398
31410
|
accessibilityState: isInteractive ? { disabled, expanded: hasMenu ? isOpen : void 0 } : void 0,
|
|
31399
|
-
style: [
|
|
31411
|
+
style: [
|
|
31412
|
+
styles6.root,
|
|
31413
|
+
isLightVariant ? styles6.rootLight : styles6.rootDark,
|
|
31414
|
+
isLightVariant && triggerWebBlurStyle,
|
|
31415
|
+
disabled && styles6.disabled,
|
|
31416
|
+
style
|
|
31417
|
+
],
|
|
31400
31418
|
children: [
|
|
31401
31419
|
/* @__PURE__ */ jsx(View, { style: styles6.imageWrap, children: hasImage ? /* @__PURE__ */ jsx(
|
|
31402
31420
|
Image,
|
|
@@ -31405,30 +31423,71 @@ var Avatar = forwardRef(function Avatar2({
|
|
|
31405
31423
|
style: styles6.image,
|
|
31406
31424
|
onError: () => setImageFailed(true)
|
|
31407
31425
|
}
|
|
31408
|
-
) : /* @__PURE__ */ jsx(
|
|
31426
|
+
) : /* @__PURE__ */ jsx(
|
|
31427
|
+
View,
|
|
31428
|
+
{
|
|
31429
|
+
style: [
|
|
31430
|
+
styles6.imageFallback,
|
|
31431
|
+
isLightVariant ? styles6.imageFallbackLight : styles6.imageFallbackDark
|
|
31432
|
+
],
|
|
31433
|
+
children: /* @__PURE__ */ jsx(
|
|
31434
|
+
UserIcon,
|
|
31435
|
+
{
|
|
31436
|
+
size: FALLBACK_ICON_SIZE,
|
|
31437
|
+
color: isLightVariant ? colors.white : colors.primary
|
|
31438
|
+
}
|
|
31439
|
+
)
|
|
31440
|
+
}
|
|
31441
|
+
) }),
|
|
31409
31442
|
/* @__PURE__ */ jsxs(View, { style: styles6.textColumn, children: [
|
|
31410
31443
|
/* @__PURE__ */ jsx(Text, { style: styles6.name, numberOfLines: 1, children: name }),
|
|
31411
|
-
email ? /* @__PURE__ */ jsx(
|
|
31444
|
+
email ? /* @__PURE__ */ jsx(
|
|
31445
|
+
Text,
|
|
31446
|
+
{
|
|
31447
|
+
style: [styles6.email, isLightVariant ? styles6.emailLight : styles6.emailDark],
|
|
31448
|
+
numberOfLines: 1,
|
|
31449
|
+
children: email
|
|
31450
|
+
}
|
|
31451
|
+
) : null
|
|
31412
31452
|
] }),
|
|
31413
|
-
showChevron ? /* @__PURE__ */ jsx(View, { style: [styles6.chevronSlot, isOpen && styles6.chevronOpen], children: /* @__PURE__ */ jsx(
|
|
31453
|
+
showChevron ? /* @__PURE__ */ jsx(View, { style: [styles6.chevronSlot, isOpen && styles6.chevronOpen], children: /* @__PURE__ */ jsx(
|
|
31454
|
+
ChevronDownIcon,
|
|
31455
|
+
{
|
|
31456
|
+
size: CHEVRON_SIZE,
|
|
31457
|
+
color: isLightVariant ? colors.white : isOpen ? colors.primary : colors.grey100
|
|
31458
|
+
}
|
|
31459
|
+
) }) : null
|
|
31414
31460
|
]
|
|
31415
31461
|
}
|
|
31416
31462
|
),
|
|
31417
|
-
hasMenu && isOpen ? /* @__PURE__ */ jsx(
|
|
31418
|
-
|
|
31419
|
-
|
|
31420
|
-
|
|
31421
|
-
|
|
31422
|
-
|
|
31423
|
-
|
|
31424
|
-
|
|
31425
|
-
|
|
31426
|
-
|
|
31427
|
-
|
|
31428
|
-
|
|
31429
|
-
|
|
31430
|
-
|
|
31431
|
-
|
|
31463
|
+
hasMenu && isOpen ? /* @__PURE__ */ jsx(
|
|
31464
|
+
View,
|
|
31465
|
+
{
|
|
31466
|
+
style: [
|
|
31467
|
+
styles6.menu,
|
|
31468
|
+
isLightVariant ? styles6.menuLight : styles6.menuDark,
|
|
31469
|
+
isLightVariant && menuWebBlurStyle,
|
|
31470
|
+
menuWidth != null && { right: void 0, width: menuWidth }
|
|
31471
|
+
],
|
|
31472
|
+
children: resolvedMenuItems.map((item) => {
|
|
31473
|
+
const itemKey = item.key ?? item.label;
|
|
31474
|
+
return /* @__PURE__ */ jsx(
|
|
31475
|
+
MenuItem,
|
|
31476
|
+
{
|
|
31477
|
+
icon: item.icon,
|
|
31478
|
+
label: item.label,
|
|
31479
|
+
disabled: item.disabled,
|
|
31480
|
+
backgroundColor: item.backgroundColor,
|
|
31481
|
+
hoverColor: item.hoverColor ?? (isLightVariant ? colors.whiteAlpha7 : void 0),
|
|
31482
|
+
labelStyle: item.labelStyle,
|
|
31483
|
+
onPress: () => handleItemPress(item),
|
|
31484
|
+
style: isLightVariant ? item.backgroundColor ? styles6.emphasizedMenuItem : styles6.menuItem : void 0
|
|
31485
|
+
},
|
|
31486
|
+
itemKey
|
|
31487
|
+
);
|
|
31488
|
+
})
|
|
31489
|
+
}
|
|
31490
|
+
) : null
|
|
31432
31491
|
] });
|
|
31433
31492
|
});
|
|
31434
31493
|
var styles6 = StyleSheet.create({
|
|
@@ -31440,6 +31499,7 @@ var styles6 = StyleSheet.create({
|
|
|
31440
31499
|
zIndex: 20
|
|
31441
31500
|
},
|
|
31442
31501
|
root: {
|
|
31502
|
+
height: CONTAINER_HEIGHT,
|
|
31443
31503
|
flexDirection: "row",
|
|
31444
31504
|
alignItems: "center",
|
|
31445
31505
|
alignSelf: "flex-start",
|
|
@@ -31448,7 +31508,12 @@ var styles6 = StyleSheet.create({
|
|
|
31448
31508
|
paddingBottom: 4,
|
|
31449
31509
|
paddingLeft: 4,
|
|
31450
31510
|
paddingRight: 12,
|
|
31451
|
-
borderRadius: CONTAINER_RADIUS
|
|
31511
|
+
borderRadius: CONTAINER_RADIUS
|
|
31512
|
+
},
|
|
31513
|
+
rootLight: {
|
|
31514
|
+
backgroundColor: colors.whiteAlpha5
|
|
31515
|
+
},
|
|
31516
|
+
rootDark: {
|
|
31452
31517
|
backgroundColor: colors.grey700
|
|
31453
31518
|
},
|
|
31454
31519
|
disabled: {
|
|
@@ -31469,7 +31534,15 @@ var styles6 = StyleSheet.create({
|
|
|
31469
31534
|
width: IMAGE_SIZE,
|
|
31470
31535
|
height: IMAGE_SIZE,
|
|
31471
31536
|
alignItems: "center",
|
|
31472
|
-
justifyContent: "center"
|
|
31537
|
+
justifyContent: "center"
|
|
31538
|
+
},
|
|
31539
|
+
imageFallbackLight: {
|
|
31540
|
+
borderRadius: IMAGE_SIZE / 2,
|
|
31541
|
+
backgroundColor: "transparent",
|
|
31542
|
+
borderWidth: 1,
|
|
31543
|
+
borderColor: colors.whiteAlpha10
|
|
31544
|
+
},
|
|
31545
|
+
imageFallbackDark: {
|
|
31473
31546
|
backgroundColor: colors.grey600
|
|
31474
31547
|
},
|
|
31475
31548
|
textColumn: {
|
|
@@ -31482,7 +31555,12 @@ var styles6 = StyleSheet.create({
|
|
|
31482
31555
|
color: colors.white
|
|
31483
31556
|
},
|
|
31484
31557
|
email: {
|
|
31485
|
-
...avatarTypography.email
|
|
31558
|
+
...avatarTypography.email
|
|
31559
|
+
},
|
|
31560
|
+
emailLight: {
|
|
31561
|
+
color: colors.whiteAlpha60
|
|
31562
|
+
},
|
|
31563
|
+
emailDark: {
|
|
31486
31564
|
color: colors.grey0
|
|
31487
31565
|
},
|
|
31488
31566
|
chevronSlot: {
|
|
@@ -31504,7 +31582,15 @@ var styles6 = StyleSheet.create({
|
|
|
31504
31582
|
zIndex: 10,
|
|
31505
31583
|
borderRadius: MENU_RADIUS,
|
|
31506
31584
|
padding: 8,
|
|
31507
|
-
gap: 8
|
|
31585
|
+
gap: 8
|
|
31586
|
+
},
|
|
31587
|
+
menuLight: {
|
|
31588
|
+
borderWidth: 1,
|
|
31589
|
+
borderColor: colors.whiteAlpha10,
|
|
31590
|
+
backgroundColor: colors.whiteAlpha5,
|
|
31591
|
+
overflow: "hidden"
|
|
31592
|
+
},
|
|
31593
|
+
menuDark: {
|
|
31508
31594
|
backgroundColor: colors.grey700,
|
|
31509
31595
|
...Platform.select({
|
|
31510
31596
|
web: {
|
|
@@ -31514,6 +31600,16 @@ var styles6 = StyleSheet.create({
|
|
|
31514
31600
|
elevation: 8
|
|
31515
31601
|
}
|
|
31516
31602
|
})
|
|
31603
|
+
},
|
|
31604
|
+
menuItem: {
|
|
31605
|
+
height: 32,
|
|
31606
|
+
minHeight: 32,
|
|
31607
|
+
paddingVertical: 6
|
|
31608
|
+
},
|
|
31609
|
+
emphasizedMenuItem: {
|
|
31610
|
+
height: 46,
|
|
31611
|
+
minHeight: 46,
|
|
31612
|
+
paddingVertical: 11
|
|
31517
31613
|
}
|
|
31518
31614
|
});
|
|
31519
31615
|
var IMAGE_SIZE2 = 32;
|
|
@@ -33523,6 +33619,7 @@ var defaultLanguageOptions = [
|
|
|
33523
33619
|
];
|
|
33524
33620
|
var CONTROL_WIDTH = 96;
|
|
33525
33621
|
var CONTROL_HEIGHT = 35;
|
|
33622
|
+
var MENU_WIDTH = 90;
|
|
33526
33623
|
var ICON_SIZE9 = 16;
|
|
33527
33624
|
var ICON_BUTTON_SIZE2 = 32;
|
|
33528
33625
|
var ICON_MENU_WIDTH = 67;
|
|
@@ -33530,6 +33627,10 @@ var ICON_MENU_HEIGHT = 129;
|
|
|
33530
33627
|
var ICON_MENU_TOP = 39;
|
|
33531
33628
|
var ITEM_HEIGHT = 35;
|
|
33532
33629
|
var ACTIVE_ITEM_BACKGROUND = "#E38E5E12";
|
|
33630
|
+
var menuWebBlurStyle2 = Platform.OS === "web" ? {
|
|
33631
|
+
backdropFilter: "blur(40px)",
|
|
33632
|
+
WebkitBackdropFilter: "blur(40px)"
|
|
33633
|
+
} : {};
|
|
33533
33634
|
var LanguageSwitcher = forwardRef(
|
|
33534
33635
|
function LanguageSwitcher2({
|
|
33535
33636
|
options = defaultLanguageOptions,
|
|
@@ -33634,7 +33735,7 @@ var LanguageSwitcher = forwardRef(
|
|
|
33634
33735
|
onHoverOut: () => setTriggerHovered(false),
|
|
33635
33736
|
style: ({ pressed }) => [
|
|
33636
33737
|
isIconVariant ? styles22.triggerIcon : styles22.trigger,
|
|
33637
|
-
!isIconVariant && (triggerHovered || pressed
|
|
33738
|
+
!isIconVariant && (triggerHovered || pressed) && styles22.triggerActive
|
|
33638
33739
|
],
|
|
33639
33740
|
children: [
|
|
33640
33741
|
/* @__PURE__ */ jsx(GlobeIcon, { size: ICON_SIZE9, color: colors.white, strokeWidth: isIconVariant ? 1.5 : 2 }),
|
|
@@ -33648,7 +33749,11 @@ var LanguageSwitcher = forwardRef(
|
|
|
33648
33749
|
isOpen && options.length > 0 ? /* @__PURE__ */ jsx(
|
|
33649
33750
|
View,
|
|
33650
33751
|
{
|
|
33651
|
-
style: [
|
|
33752
|
+
style: [
|
|
33753
|
+
styles22.menu,
|
|
33754
|
+
!isIconVariant && menuWebBlurStyle2,
|
|
33755
|
+
isIconVariant ? styles22.menuIcon : styles22.menuDefault
|
|
33756
|
+
],
|
|
33652
33757
|
accessibilityRole: "menu",
|
|
33653
33758
|
children: options.map((option) => {
|
|
33654
33759
|
const selected = option.value === selectedValue;
|
|
@@ -33663,15 +33768,15 @@ var LanguageSwitcher = forwardRef(
|
|
|
33663
33768
|
onHoverOut: () => setHoveredValue(null),
|
|
33664
33769
|
style: ({ pressed }) => [
|
|
33665
33770
|
styles22.item,
|
|
33666
|
-
isIconVariant ? styles22.itemIcon :
|
|
33771
|
+
isIconVariant ? styles22.itemIcon : styles22.itemDefault,
|
|
33667
33772
|
selected ? isIconVariant ? styles22.itemSelectedIcon : styles22.itemSelected : (hoveredValue === option.value || pressed) && styles22.itemHovered
|
|
33668
33773
|
],
|
|
33669
|
-
children: /* @__PURE__ */ jsx(
|
|
33774
|
+
children: ({ pressed }) => /* @__PURE__ */ jsx(
|
|
33670
33775
|
Text,
|
|
33671
33776
|
{
|
|
33672
33777
|
style: [
|
|
33673
33778
|
styles22.itemLabel,
|
|
33674
|
-
selected
|
|
33779
|
+
(selected || hoveredValue === option.value || pressed) && styles22.itemLabelActive
|
|
33675
33780
|
],
|
|
33676
33781
|
children: option.label
|
|
33677
33782
|
}
|
|
@@ -33756,10 +33861,14 @@ var styles22 = StyleSheet.create({
|
|
|
33756
33861
|
},
|
|
33757
33862
|
menuDefault: {
|
|
33758
33863
|
top: CONTROL_HEIGHT + 8,
|
|
33759
|
-
left:
|
|
33760
|
-
width:
|
|
33761
|
-
|
|
33762
|
-
|
|
33864
|
+
left: (CONTROL_WIDTH - MENU_WIDTH) / 2,
|
|
33865
|
+
width: MENU_WIDTH,
|
|
33866
|
+
height: 129,
|
|
33867
|
+
gap: 4,
|
|
33868
|
+
backgroundColor: colors.whiteAlpha5,
|
|
33869
|
+
borderWidth: 1,
|
|
33870
|
+
borderColor: colors.whiteAlpha10,
|
|
33871
|
+
borderRadius: 16
|
|
33763
33872
|
},
|
|
33764
33873
|
menuIcon: {
|
|
33765
33874
|
top: ICON_MENU_TOP,
|
|
@@ -33787,11 +33896,15 @@ var styles22 = StyleSheet.create({
|
|
|
33787
33896
|
width: 51,
|
|
33788
33897
|
alignSelf: "stretch"
|
|
33789
33898
|
},
|
|
33899
|
+
itemDefault: {
|
|
33900
|
+
width: 74,
|
|
33901
|
+
alignSelf: "center"
|
|
33902
|
+
},
|
|
33790
33903
|
itemHovered: {
|
|
33791
|
-
backgroundColor: colors.
|
|
33904
|
+
backgroundColor: colors.whiteAlpha7
|
|
33792
33905
|
},
|
|
33793
33906
|
itemSelected: {
|
|
33794
|
-
backgroundColor: colors.
|
|
33907
|
+
backgroundColor: colors.whiteAlpha7
|
|
33795
33908
|
},
|
|
33796
33909
|
itemSelectedIcon: {
|
|
33797
33910
|
backgroundColor: ACTIVE_ITEM_BACKGROUND
|
|
@@ -33799,13 +33912,10 @@ var styles22 = StyleSheet.create({
|
|
|
33799
33912
|
itemLabel: {
|
|
33800
33913
|
...languageSwitcherTypography,
|
|
33801
33914
|
...Platform.select({ web: { fontFamily: `${fonts.sans}, sans-serif` } }),
|
|
33802
|
-
color: colors.
|
|
33803
|
-
},
|
|
33804
|
-
itemLabelSelected: {
|
|
33805
|
-
color: colors.primary
|
|
33915
|
+
color: colors.whiteAlpha60
|
|
33806
33916
|
},
|
|
33807
|
-
|
|
33808
|
-
color: colors.
|
|
33917
|
+
itemLabelActive: {
|
|
33918
|
+
color: colors.white
|
|
33809
33919
|
}
|
|
33810
33920
|
});
|
|
33811
33921
|
var ICON_SIZE10 = 25.63181;
|
|
@@ -36208,6 +36318,9 @@ var styles32 = StyleSheet.create({
|
|
|
36208
36318
|
color: colors.red
|
|
36209
36319
|
}
|
|
36210
36320
|
});
|
|
36321
|
+
|
|
36322
|
+
// src/components/Select/Select.tsx
|
|
36323
|
+
var import_react_dom3 = __toESM(require_react_dom());
|
|
36211
36324
|
var DEFAULT_WIDTH4 = 308;
|
|
36212
36325
|
var TRIGGER_HEIGHT2 = 44;
|
|
36213
36326
|
var TRIGGER_RADIUS2 = 60;
|
|
@@ -36217,6 +36330,9 @@ var ITEM_RADIUS2 = 12;
|
|
|
36217
36330
|
var ICON_SIZE13 = 20;
|
|
36218
36331
|
var CHIP_GAP = 6;
|
|
36219
36332
|
var FALLBACK_ELLIPSIS_WIDTH = 20;
|
|
36333
|
+
var WEB_MENU_Z_INDEX = 600;
|
|
36334
|
+
var WEB_VIEWPORT_PADDING = 8;
|
|
36335
|
+
var WEB_MENU_GAP = 8;
|
|
36220
36336
|
function itemBackground(state) {
|
|
36221
36337
|
switch (state) {
|
|
36222
36338
|
case "hover":
|
|
@@ -36363,6 +36479,7 @@ var Select = forwardRef(
|
|
|
36363
36479
|
const valueProp = props.value;
|
|
36364
36480
|
const rootRef = useRef(null);
|
|
36365
36481
|
const triggerRef = useRef(null);
|
|
36482
|
+
const menuRef = useRef(null);
|
|
36366
36483
|
const searchInputRef = useRef(null);
|
|
36367
36484
|
const setRootRef = useMemo(() => mergeRefs(rootRef, forwardedRef), [forwardedRef]);
|
|
36368
36485
|
const isOpenControlled = typeof openProp === "boolean";
|
|
@@ -36378,6 +36495,7 @@ var Select = forwardRef(
|
|
|
36378
36495
|
const [hoveredValue, setHoveredValue] = useState(null);
|
|
36379
36496
|
const [menuAlignEnd, setMenuAlignEnd] = useState(false);
|
|
36380
36497
|
const [menuPlaceAbove, setMenuPlaceAbove] = useState(false);
|
|
36498
|
+
const [webMenuPosition, setWebMenuPosition] = useState(null);
|
|
36381
36499
|
const selectedValues = useMemo(() => {
|
|
36382
36500
|
const current = isValueControlled ? valueProp : multiple ? uncontrolledMultiple : uncontrolledSingle;
|
|
36383
36501
|
return toArray(current);
|
|
@@ -36431,6 +36549,7 @@ var Select = forwardRef(
|
|
|
36431
36549
|
setHoveredValue(null);
|
|
36432
36550
|
setMenuAlignEnd(false);
|
|
36433
36551
|
setMenuPlaceAbove(false);
|
|
36552
|
+
setWebMenuPosition(null);
|
|
36434
36553
|
onSearchChange?.("");
|
|
36435
36554
|
}
|
|
36436
36555
|
},
|
|
@@ -36442,15 +36561,18 @@ var Select = forwardRef(
|
|
|
36442
36561
|
const trigger = triggerRef.current;
|
|
36443
36562
|
const rect = trigger?.getBoundingClientRect?.();
|
|
36444
36563
|
if (!rect) return;
|
|
36445
|
-
const viewportPadding = 8;
|
|
36446
|
-
const gap = 8;
|
|
36447
36564
|
const menuWidth = Math.max(rect.width, resolvedMenuWidth ?? 0);
|
|
36448
|
-
const overflowsRight = rect.left + menuWidth > window.innerWidth -
|
|
36565
|
+
const overflowsRight = rect.left + menuWidth > window.innerWidth - WEB_VIEWPORT_PADDING;
|
|
36449
36566
|
setMenuAlignEnd(overflowsRight);
|
|
36450
|
-
const spaceBelow = window.innerHeight -
|
|
36451
|
-
const spaceAbove = rect.top -
|
|
36452
|
-
const needsAbove = estimatedMenuHeight +
|
|
36567
|
+
const spaceBelow = window.innerHeight - WEB_VIEWPORT_PADDING - rect.bottom;
|
|
36568
|
+
const spaceAbove = rect.top - WEB_VIEWPORT_PADDING;
|
|
36569
|
+
const needsAbove = estimatedMenuHeight + WEB_MENU_GAP > spaceBelow && spaceAbove > spaceBelow;
|
|
36453
36570
|
setMenuPlaceAbove(needsAbove);
|
|
36571
|
+
const available = Math.max(0, (needsAbove ? spaceAbove : spaceBelow) - WEB_MENU_GAP);
|
|
36572
|
+
const maxHeight = Math.min(estimatedMenuHeight, Math.max(available, TRIGGER_HEIGHT2));
|
|
36573
|
+
const left = overflowsRight ? Math.max(WEB_VIEWPORT_PADDING, rect.right - menuWidth) : Math.min(rect.left, window.innerWidth - WEB_VIEWPORT_PADDING - menuWidth);
|
|
36574
|
+
const top = needsAbove ? Math.max(WEB_VIEWPORT_PADDING, rect.top - WEB_MENU_GAP - maxHeight) : rect.bottom + WEB_MENU_GAP;
|
|
36575
|
+
setWebMenuPosition({ top, left, width: menuWidth, maxHeight });
|
|
36454
36576
|
};
|
|
36455
36577
|
updateMenuPlacement();
|
|
36456
36578
|
window.addEventListener("resize", updateMenuPlacement);
|
|
@@ -36467,11 +36589,12 @@ var Select = forwardRef(
|
|
|
36467
36589
|
useEffect(() => {
|
|
36468
36590
|
if (Platform.OS !== "web" || !isOpen) return;
|
|
36469
36591
|
const handlePointerDown = (event) => {
|
|
36470
|
-
const root = rootRef.current;
|
|
36471
36592
|
const target = event.target;
|
|
36472
|
-
if (
|
|
36473
|
-
|
|
36474
|
-
|
|
36593
|
+
if (!(target instanceof Node)) return;
|
|
36594
|
+
const root = rootRef.current;
|
|
36595
|
+
const menu = menuRef.current;
|
|
36596
|
+
if (root?.contains?.(target) || menu?.contains?.(target)) return;
|
|
36597
|
+
setOpen(false);
|
|
36475
36598
|
};
|
|
36476
36599
|
document.addEventListener("mousedown", handlePointerDown);
|
|
36477
36600
|
document.addEventListener("touchstart", handlePointerDown);
|
|
@@ -36585,7 +36708,7 @@ var Select = forwardRef(
|
|
|
36585
36708
|
]);
|
|
36586
36709
|
const leftIconNode = renderStatefulIcon(leftIcon, UserIcon, {
|
|
36587
36710
|
size: ICON_SIZE13,
|
|
36588
|
-
color: error ? colors.red : colors.primary
|
|
36711
|
+
color: error ? colors.red : isOpen ? colors.primary : colors.grey100
|
|
36589
36712
|
});
|
|
36590
36713
|
const hasLeftIcon = showLeftIcon || leftIcon != null;
|
|
36591
36714
|
const triggerBorderColor = error ? colors.redMuted : isOpen ? colors.primaryMuted : colors.grey700;
|
|
@@ -36594,6 +36717,95 @@ var Select = forwardRef(
|
|
|
36594
36717
|
const hintColor = error ? colors.red : colors.grey100;
|
|
36595
36718
|
const singleLabel = selectedOptions[0]?.label ?? placeholder;
|
|
36596
36719
|
const resolvedAccessibilityLabel = accessibilityLabel ?? (typeof label === "string" ? label : void 0);
|
|
36720
|
+
const optionListMaxHeight = Platform.OS === "web" && webMenuPosition != null ? Math.max(43, webMenuPosition.maxHeight - (24 + (showSearch ? 48 : 0))) : resolvedOptionListMaxHeight;
|
|
36721
|
+
const menuNode = isOpen ? /* @__PURE__ */ jsxs(
|
|
36722
|
+
View,
|
|
36723
|
+
{
|
|
36724
|
+
ref: menuRef,
|
|
36725
|
+
style: [
|
|
36726
|
+
styles33.menu,
|
|
36727
|
+
Platform.OS === "web" && webMenuPosition != null ? {
|
|
36728
|
+
position: "fixed",
|
|
36729
|
+
top: webMenuPosition.top,
|
|
36730
|
+
left: webMenuPosition.left,
|
|
36731
|
+
width: webMenuPosition.width,
|
|
36732
|
+
minWidth: webMenuPosition.width,
|
|
36733
|
+
maxHeight: webMenuPosition.maxHeight,
|
|
36734
|
+
zIndex: WEB_MENU_Z_INDEX,
|
|
36735
|
+
marginTop: 0,
|
|
36736
|
+
marginBottom: 0
|
|
36737
|
+
} : Platform.OS === "web" ? { position: "fixed", opacity: 0, pointerEvents: "none" } : [
|
|
36738
|
+
menuAlignEnd ? styles33.menuAlignEnd : styles33.menuAlignStart,
|
|
36739
|
+
menuPlaceAbove ? styles33.menuAbove : styles33.menuBelow
|
|
36740
|
+
],
|
|
36741
|
+
menuStyle
|
|
36742
|
+
],
|
|
36743
|
+
children: [
|
|
36744
|
+
showSearch ? /* @__PURE__ */ jsxs(View, { style: styles33.searchField, children: [
|
|
36745
|
+
/* @__PURE__ */ jsx(View, { style: styles33.iconSlot, children: /* @__PURE__ */ jsx(SearchIcon, { size: ICON_SIZE13, color: colors.grey100 }) }),
|
|
36746
|
+
/* @__PURE__ */ jsx(
|
|
36747
|
+
TextInput,
|
|
36748
|
+
{
|
|
36749
|
+
ref: searchInputRef,
|
|
36750
|
+
value: searchQuery,
|
|
36751
|
+
onChangeText: handleSearchChange,
|
|
36752
|
+
editable: !disabled,
|
|
36753
|
+
placeholder: searchPlaceholder,
|
|
36754
|
+
placeholderTextColor: colors.grey100,
|
|
36755
|
+
style: [
|
|
36756
|
+
styles33.searchInput,
|
|
36757
|
+
Platform.OS === "web" ? styles33.searchInputWeb : null,
|
|
36758
|
+
Platform.OS === "android" ? styles33.searchInputAndroid : null
|
|
36759
|
+
],
|
|
36760
|
+
accessibilityLabel: searchPlaceholder
|
|
36761
|
+
}
|
|
36762
|
+
)
|
|
36763
|
+
] }) : null,
|
|
36764
|
+
/* @__PURE__ */ jsxs(
|
|
36765
|
+
ScrollView,
|
|
36766
|
+
{
|
|
36767
|
+
style: [styles33.optionList, { maxHeight: optionListMaxHeight }],
|
|
36768
|
+
contentContainerStyle: styles33.optionListContent,
|
|
36769
|
+
keyboardShouldPersistTaps: "handled",
|
|
36770
|
+
showsVerticalScrollIndicator: false,
|
|
36771
|
+
children: [
|
|
36772
|
+
loading ? /* @__PURE__ */ jsx(View, { style: styles33.statusRow, children: /* @__PURE__ */ jsx(Text, { style: styles33.statusText, children: "Loading..." }) }) : filteredOptions.length === 0 ? /* @__PURE__ */ jsx(View, { style: styles33.statusRow, children: /* @__PURE__ */ jsx(Text, { style: styles33.statusText, children: emptyText }) }) : null,
|
|
36773
|
+
!loading && filteredOptions.map((option) => {
|
|
36774
|
+
const isSelected = selectedValues.includes(option.value);
|
|
36775
|
+
const isHovered = hoveredValue === option.value;
|
|
36776
|
+
const visualState = isSelected ? "selected" : isHovered ? "hover" : "default";
|
|
36777
|
+
return /* @__PURE__ */ jsxs(
|
|
36778
|
+
Pressable,
|
|
36779
|
+
{
|
|
36780
|
+
onPress: () => handleSelect(option.value),
|
|
36781
|
+
disabled,
|
|
36782
|
+
onHoverIn: () => setHoveredValue(option.value),
|
|
36783
|
+
onHoverOut: () => setHoveredValue((current) => current === option.value ? null : current),
|
|
36784
|
+
onPressIn: () => setHoveredValue(option.value),
|
|
36785
|
+
onPressOut: () => setHoveredValue((current) => current === option.value ? null : current),
|
|
36786
|
+
accessibilityRole: multiple ? "checkbox" : "button",
|
|
36787
|
+
accessibilityState: { selected: isSelected, checked: isSelected, disabled },
|
|
36788
|
+
style: [
|
|
36789
|
+
styles33.item,
|
|
36790
|
+
{
|
|
36791
|
+
backgroundColor: itemBackground(visualState)
|
|
36792
|
+
}
|
|
36793
|
+
],
|
|
36794
|
+
children: [
|
|
36795
|
+
multiple ? /* @__PURE__ */ jsx(View, { style: [styles33.itemCheckbox, { pointerEvents: "none" }], children: /* @__PURE__ */ jsx(Checkbox, { value: isSelected, variant: "light" }) }) : null,
|
|
36796
|
+
/* @__PURE__ */ jsx(Text, { style: styles33.itemLabel, numberOfLines: 1, children: option.label })
|
|
36797
|
+
]
|
|
36798
|
+
},
|
|
36799
|
+
option.value
|
|
36800
|
+
);
|
|
36801
|
+
})
|
|
36802
|
+
]
|
|
36803
|
+
}
|
|
36804
|
+
)
|
|
36805
|
+
]
|
|
36806
|
+
}
|
|
36807
|
+
) : null;
|
|
36808
|
+
const webMenuPortal = Platform.OS === "web" && isOpen && typeof document !== "undefined" ? (0, import_react_dom3.createPortal)(menuNode, document.body) : null;
|
|
36597
36809
|
return /* @__PURE__ */ jsxs(
|
|
36598
36810
|
View,
|
|
36599
36811
|
{
|
|
@@ -36634,80 +36846,7 @@ var Select = forwardRef(
|
|
|
36634
36846
|
]
|
|
36635
36847
|
}
|
|
36636
36848
|
),
|
|
36637
|
-
|
|
36638
|
-
View,
|
|
36639
|
-
{
|
|
36640
|
-
style: [
|
|
36641
|
-
styles33.menu,
|
|
36642
|
-
menuAlignEnd ? styles33.menuAlignEnd : styles33.menuAlignStart,
|
|
36643
|
-
menuPlaceAbove ? styles33.menuAbove : styles33.menuBelow,
|
|
36644
|
-
menuStyle
|
|
36645
|
-
],
|
|
36646
|
-
children: [
|
|
36647
|
-
showSearch ? /* @__PURE__ */ jsxs(View, { style: styles33.searchField, children: [
|
|
36648
|
-
/* @__PURE__ */ jsx(View, { style: styles33.iconSlot, children: /* @__PURE__ */ jsx(SearchIcon, { size: ICON_SIZE13, color: colors.grey100 }) }),
|
|
36649
|
-
/* @__PURE__ */ jsx(
|
|
36650
|
-
TextInput,
|
|
36651
|
-
{
|
|
36652
|
-
ref: searchInputRef,
|
|
36653
|
-
value: searchQuery,
|
|
36654
|
-
onChangeText: handleSearchChange,
|
|
36655
|
-
editable: !disabled,
|
|
36656
|
-
placeholder: searchPlaceholder,
|
|
36657
|
-
placeholderTextColor: colors.grey100,
|
|
36658
|
-
style: [
|
|
36659
|
-
styles33.searchInput,
|
|
36660
|
-
Platform.OS === "web" ? styles33.searchInputWeb : null,
|
|
36661
|
-
Platform.OS === "android" ? styles33.searchInputAndroid : null
|
|
36662
|
-
],
|
|
36663
|
-
accessibilityLabel: searchPlaceholder
|
|
36664
|
-
}
|
|
36665
|
-
)
|
|
36666
|
-
] }) : null,
|
|
36667
|
-
/* @__PURE__ */ jsxs(
|
|
36668
|
-
ScrollView,
|
|
36669
|
-
{
|
|
36670
|
-
style: [styles33.optionList, { maxHeight: resolvedOptionListMaxHeight }],
|
|
36671
|
-
contentContainerStyle: styles33.optionListContent,
|
|
36672
|
-
keyboardShouldPersistTaps: "handled",
|
|
36673
|
-
showsVerticalScrollIndicator: false,
|
|
36674
|
-
children: [
|
|
36675
|
-
loading ? /* @__PURE__ */ jsx(View, { style: styles33.statusRow, children: /* @__PURE__ */ jsx(Text, { style: styles33.statusText, children: "Loading..." }) }) : filteredOptions.length === 0 ? /* @__PURE__ */ jsx(View, { style: styles33.statusRow, children: /* @__PURE__ */ jsx(Text, { style: styles33.statusText, children: emptyText }) }) : null,
|
|
36676
|
-
!loading && filteredOptions.map((option) => {
|
|
36677
|
-
const isSelected = selectedValues.includes(option.value);
|
|
36678
|
-
const isHovered = hoveredValue === option.value;
|
|
36679
|
-
const visualState = isSelected ? "selected" : isHovered ? "hover" : "default";
|
|
36680
|
-
return /* @__PURE__ */ jsxs(
|
|
36681
|
-
Pressable,
|
|
36682
|
-
{
|
|
36683
|
-
onPress: () => handleSelect(option.value),
|
|
36684
|
-
disabled,
|
|
36685
|
-
onHoverIn: () => setHoveredValue(option.value),
|
|
36686
|
-
onHoverOut: () => setHoveredValue((current) => current === option.value ? null : current),
|
|
36687
|
-
onPressIn: () => setHoveredValue(option.value),
|
|
36688
|
-
onPressOut: () => setHoveredValue((current) => current === option.value ? null : current),
|
|
36689
|
-
accessibilityRole: multiple ? "checkbox" : "button",
|
|
36690
|
-
accessibilityState: { selected: isSelected, checked: isSelected, disabled },
|
|
36691
|
-
style: [
|
|
36692
|
-
styles33.item,
|
|
36693
|
-
{
|
|
36694
|
-
backgroundColor: itemBackground(visualState)
|
|
36695
|
-
}
|
|
36696
|
-
],
|
|
36697
|
-
children: [
|
|
36698
|
-
multiple ? /* @__PURE__ */ jsx(View, { style: [styles33.itemCheckbox, { pointerEvents: "none" }], children: /* @__PURE__ */ jsx(Checkbox, { value: isSelected, variant: "light" }) }) : null,
|
|
36699
|
-
/* @__PURE__ */ jsx(Text, { style: styles33.itemLabel, numberOfLines: 1, children: option.label })
|
|
36700
|
-
]
|
|
36701
|
-
},
|
|
36702
|
-
option.value
|
|
36703
|
-
);
|
|
36704
|
-
})
|
|
36705
|
-
]
|
|
36706
|
-
}
|
|
36707
|
-
)
|
|
36708
|
-
]
|
|
36709
|
-
}
|
|
36710
|
-
) : null
|
|
36849
|
+
Platform.OS === "web" ? webMenuPortal : menuNode
|
|
36711
36850
|
] }),
|
|
36712
36851
|
showHint && hint ? /* @__PURE__ */ jsx(Text, { style: [styles33.hint, { color: hintColor }], children: hint }) : null
|
|
36713
36852
|
]
|