@swan-io/lake 13.9.2 → 13.9.3
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/package.json +1 -1
- package/src/components/LakeSelect.js +28 -29
package/package.json
CHANGED
|
@@ -119,8 +119,7 @@ const styles = StyleSheet.create({
|
|
|
119
119
|
flexGrow: 1,
|
|
120
120
|
flexShrink: 1,
|
|
121
121
|
marginHorizontal: 16,
|
|
122
|
-
|
|
123
|
-
marginTop: 4,
|
|
122
|
+
marginTop: 16,
|
|
124
123
|
},
|
|
125
124
|
filterInput: {
|
|
126
125
|
...texts.regular,
|
|
@@ -235,32 +234,32 @@ export const LakeSelect = ({ ref, title, items, valueStyle, size, color = "curre
|
|
|
235
234
|
styles.itemText,
|
|
236
235
|
styles.selectPlaceholder,
|
|
237
236
|
isSmall && styles.selectSmallPlaceholder,
|
|
238
|
-
], children: placeholder !== null && placeholder !== void 0 ? placeholder : " " }))] }), _jsx(Fill, { minWidth: 8 }), !disabled && (_jsx(Icon, { color: colors.gray[900], name: visible ? "chevron-up-filled" : "chevron-down-filled", size: 16 }))] })] })) }), !hideErrors && (_jsx(LakeText, { variant: "smallRegular", color: colors.negative[500], style: styles.errorText, children: error !== null && error !== void 0 ? error : " " })),
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
237
|
+
], children: placeholder !== null && placeholder !== void 0 ? placeholder : " " }))] }), _jsx(Fill, { minWidth: 8 }), !disabled && (_jsx(Icon, { color: colors.gray[900], name: visible ? "chevron-up-filled" : "chevron-down-filled", size: 16 }))] })] })) }), !hideErrors && (_jsx(LakeText, { variant: "smallRegular", color: colors.negative[500], style: styles.errorText, children: error !== null && error !== void 0 ? error : " " })), _jsxs(Popover, { role: "listbox", matchReferenceWidth: matchReferenceWidth, matchReferenceMinWidth: matchReferenceMinWidth, onDismiss: close, referenceRef: inputRef, returnFocus: true, visible: visible, children: [hasSearch ? ListHeaderComponent : undefined, _jsxs(View, { style: styles.list, children: [isNotNullish(title) && (_jsxs(_Fragment, { children: [_jsx(LakeText, { variant: "semibold", color: colors.gray[900], style: styles.selectListTitle, children: title }), _jsx(Separator, {})] })), _jsx(FlatList, { role: "list", data: filteredItems, ref: listRef, contentContainerStyle: styles.listContent, onKeyDown: (event) => {
|
|
238
|
+
var _a;
|
|
239
|
+
const { key } = event.nativeEvent;
|
|
240
|
+
if (key === "ArrowDown" || key === "ArrowUp") {
|
|
241
|
+
event.preventDefault();
|
|
242
|
+
if (isNotNullish(event.currentTarget)) {
|
|
243
|
+
const focusableElements = getFocusableElements(event.currentTarget);
|
|
244
|
+
const current = focusableElements.indexOf(event.target);
|
|
245
|
+
const nextIndex = key === "ArrowDown" ? current + 1 : current - 1;
|
|
246
|
+
(_a = focusableElements[nextIndex]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
247
|
+
}
|
|
248
248
|
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
} }), typeof PopoverFooter === "function" ? PopoverFooter({ close }) : PopoverFooter] }) })] }));
|
|
249
|
+
}, keyExtractor: (_, index) => `select-item-${index}`, renderItem: ({ item, index }) => {
|
|
250
|
+
const isSelected = value === item.value;
|
|
251
|
+
const disablement = disabledItems.find(({ value }) => value === item.value);
|
|
252
|
+
const content = renderItem != null ? (renderItem(item, isSelected)) : (_jsxs(_Fragment, { children: [isNotNullish(item.icon) && (_jsxs(_Fragment, { children: [item.icon, _jsx(Space, { width: 12 })] })), _jsx(LakeText, { color: colors.gray[900], numberOfLines: 1, style: [styles.itemText, isSelected && styles.selected], children: item.name })] }));
|
|
253
|
+
return (_jsx(LakeTooltip, { placement: "right", content: disablement === null || disablement === void 0 ? void 0 : disablement.message, disabled: isNullishOrEmpty(disablement === null || disablement === void 0 ? void 0 : disablement.message), children: _jsxs(Pressable, { ref: element => {
|
|
254
|
+
listItemRefs.current[index] = element;
|
|
255
|
+
}, onKeyDown: onKeyDown, disabled: isNotNullish(disablement), style: ({ hovered, focused }) => [
|
|
256
|
+
styles.item,
|
|
257
|
+
(hovered || isSelected) && styles.itemHighlighted,
|
|
258
|
+
focused && styles.itemFocused,
|
|
259
|
+
isNotNullish(disablement) && styles.itemDisabled,
|
|
260
|
+
], role: "option", "aria-selected": true, onPress: () => {
|
|
261
|
+
onValueChange(item.value);
|
|
262
|
+
close();
|
|
263
|
+
}, children: [content, _jsx(Fill, { minWidth: 12 }), isSelected && (_jsx(Icon, { color: colors.positive[500], name: "checkmark-filled", size: 14 }))] }) }));
|
|
264
|
+
} }), typeof PopoverFooter === "function" ? PopoverFooter({ close }) : PopoverFooter] })] })] }));
|
|
266
265
|
};
|