@shipfox/react-ui 0.32.0 → 0.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/alert/alert.d.ts +1 -1
- package/dist/components/alert/alert.js +1 -1
- package/dist/components/avatar/avatar.d.ts +1 -1
- package/dist/components/avatar/avatar.js +1 -1
- package/dist/components/command/command.d.ts +2 -2
- package/dist/components/command/command.js +1 -1
- package/dist/components/dashboard/components/charts/bar-chart.js +4 -0
- package/dist/components/dashboard/components/charts/chart-tooltip.js +1 -1
- package/dist/components/dashboard/components/charts/line-chart.js +4 -0
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu.js +1 -1
- package/dist/components/form/form.d.ts +1 -1
- package/dist/components/form/form.js +1 -1
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.js +0 -1
- package/dist/components/inline-tips/inline-tips.d.ts +1 -1
- package/dist/components/inline-tips/inline-tips.js +1 -1
- package/dist/components/modal/modal.d.ts +2 -2
- package/dist/components/modal/modal.js +1 -1
- package/dist/components/popover/popover.d.ts +1 -1
- package/dist/components/popover/popover.js +1 -1
- package/dist/components/select/select.d.ts +2 -2
- package/dist/components/select/select.js +1 -1
- package/dist/components/sheet/sheet.d.ts +2 -2
- package/dist/components/sheet/sheet.js +1 -1
- package/dist/components/shiny-text/shiny-text.d.ts +1 -1
- package/dist/components/shipql-editor/lexical/shipql-plugin.d.ts +1 -1
- package/dist/components/shipql-editor/lexical/shipql-plugin.js +2 -2
- package/dist/components/shipql-editor/suggestions/shipql-range-facet-panel.js +18 -15
- package/dist/components/shipql-editor/suggestions/types.d.ts +4 -2
- package/dist/components/table/table.d.ts +1 -1
- package/dist/components/table/table.js +1 -1
- package/dist/components/tabs/tabs.d.ts +1 -1
- package/dist/components/tabs/tabs.js +1 -1
- package/dist/components/toast/toast.d.ts +1 -1
- package/dist/components/toast/toast.js +1 -1
- package/dist/components/tooltip/tooltip.d.ts +1 -1
- package/dist/components/tooltip/tooltip.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/components/dropdown-input/dropdown-input.d.ts +0 -25
- package/dist/components/dropdown-input/dropdown-input.js +0 -188
- package/dist/components/dropdown-input/index.d.ts +0 -2
- package/dist/components/dropdown-input/index.js +0 -3
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button } from '../../components/button/index.js';
|
|
3
|
-
import { Input } from '../../components/input/index.js';
|
|
4
|
-
import { Popover, PopoverContent, PopoverTrigger } from '../../components/popover/index.js';
|
|
5
|
-
import { useCallback, useEffect, useRef } from 'react';
|
|
6
|
-
import { cn } from '../../utils/cn.js';
|
|
7
|
-
export function DropdownInput({ value, onValueChange, onSelect, items = [], emptyPlaceholder, open, onOpenChange, focusedIndex, onFocusedIndexChange, selectedItem, dropdownClassName, className, ...inputProps }) {
|
|
8
|
-
const inputRef = useRef(null);
|
|
9
|
-
const blurTimeoutRef = useRef(null);
|
|
10
|
-
const popoverContentRef = useRef(null);
|
|
11
|
-
const itemRefs = useRef([]);
|
|
12
|
-
const isDisabled = Boolean(inputProps.disabled);
|
|
13
|
-
const hasResults = items.length > 0;
|
|
14
|
-
const shouldShowDropdown = open && !isDisabled;
|
|
15
|
-
const handleOpenChange = useCallback((nextOpen)=>{
|
|
16
|
-
if (isDisabled) {
|
|
17
|
-
if (!nextOpen) onOpenChange(false);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
onOpenChange(nextOpen);
|
|
21
|
-
}, [
|
|
22
|
-
isDisabled,
|
|
23
|
-
onOpenChange
|
|
24
|
-
]);
|
|
25
|
-
const handleSelect = useCallback((item)=>{
|
|
26
|
-
onValueChange(item.label);
|
|
27
|
-
onSelect?.(item);
|
|
28
|
-
onOpenChange(false);
|
|
29
|
-
inputRef.current?.blur();
|
|
30
|
-
}, [
|
|
31
|
-
onValueChange,
|
|
32
|
-
onOpenChange,
|
|
33
|
-
onSelect
|
|
34
|
-
]);
|
|
35
|
-
const handleInputChange = useCallback((e)=>{
|
|
36
|
-
onValueChange(e.target.value);
|
|
37
|
-
onFocusedIndexChange(-1);
|
|
38
|
-
if (!open && !isDisabled) {
|
|
39
|
-
onOpenChange(true);
|
|
40
|
-
}
|
|
41
|
-
}, [
|
|
42
|
-
onValueChange,
|
|
43
|
-
onFocusedIndexChange,
|
|
44
|
-
open,
|
|
45
|
-
isDisabled,
|
|
46
|
-
onOpenChange
|
|
47
|
-
]);
|
|
48
|
-
const handleInputKeyDown = useCallback((e)=>{
|
|
49
|
-
if (!shouldShowDropdown || items.length === 0) return;
|
|
50
|
-
if (e.key === 'ArrowDown') {
|
|
51
|
-
e.preventDefault();
|
|
52
|
-
onFocusedIndexChange(focusedIndex < items.length - 1 ? focusedIndex + 1 : 0);
|
|
53
|
-
} else if (e.key === 'ArrowUp') {
|
|
54
|
-
e.preventDefault();
|
|
55
|
-
onFocusedIndexChange(focusedIndex > 0 ? focusedIndex - 1 : items.length - 1);
|
|
56
|
-
} else if (e.key === 'Enter' && focusedIndex >= 0) {
|
|
57
|
-
e.preventDefault();
|
|
58
|
-
const item = items[focusedIndex];
|
|
59
|
-
if (item) {
|
|
60
|
-
handleSelect(item);
|
|
61
|
-
}
|
|
62
|
-
} else if (e.key === 'Escape') {
|
|
63
|
-
e.preventDefault();
|
|
64
|
-
onOpenChange(false);
|
|
65
|
-
}
|
|
66
|
-
}, [
|
|
67
|
-
shouldShowDropdown,
|
|
68
|
-
items,
|
|
69
|
-
focusedIndex,
|
|
70
|
-
onFocusedIndexChange,
|
|
71
|
-
handleSelect,
|
|
72
|
-
onOpenChange
|
|
73
|
-
]);
|
|
74
|
-
const handleInputBlur = useCallback(()=>{
|
|
75
|
-
if (blurTimeoutRef.current) {
|
|
76
|
-
clearTimeout(blurTimeoutRef.current);
|
|
77
|
-
}
|
|
78
|
-
blurTimeoutRef.current = setTimeout(()=>{
|
|
79
|
-
const activeElement = document.activeElement;
|
|
80
|
-
const popoverContent = activeElement?.closest('[data-radix-popper-content-wrapper]');
|
|
81
|
-
if (!popoverContent) {
|
|
82
|
-
onOpenChange(false);
|
|
83
|
-
}
|
|
84
|
-
}, 200);
|
|
85
|
-
}, [
|
|
86
|
-
onOpenChange
|
|
87
|
-
]);
|
|
88
|
-
useEffect(()=>{
|
|
89
|
-
return ()=>{
|
|
90
|
-
if (blurTimeoutRef.current) {
|
|
91
|
-
clearTimeout(blurTimeoutRef.current);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}, []);
|
|
95
|
-
useEffect(()=>{
|
|
96
|
-
if (focusedIndex >= 0 && itemRefs.current[focusedIndex]) {
|
|
97
|
-
itemRefs.current[focusedIndex]?.scrollIntoView({
|
|
98
|
-
block: 'nearest'
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}, [
|
|
102
|
-
focusedIndex
|
|
103
|
-
]);
|
|
104
|
-
const handlePointerDownOutside = useCallback((e)=>{
|
|
105
|
-
const target = e.target;
|
|
106
|
-
if (target && popoverContentRef.current?.contains(target)) {
|
|
107
|
-
e.preventDefault();
|
|
108
|
-
}
|
|
109
|
-
}, []);
|
|
110
|
-
return /*#__PURE__*/ _jsxs(Popover, {
|
|
111
|
-
open: shouldShowDropdown,
|
|
112
|
-
onOpenChange: handleOpenChange,
|
|
113
|
-
children: [
|
|
114
|
-
/*#__PURE__*/ _jsx(PopoverTrigger, {
|
|
115
|
-
asChild: true,
|
|
116
|
-
children: /*#__PURE__*/ _jsx("div", {
|
|
117
|
-
className: "w-full",
|
|
118
|
-
children: /*#__PURE__*/ _jsx(Input, {
|
|
119
|
-
ref: inputRef,
|
|
120
|
-
value: value,
|
|
121
|
-
onChange: handleInputChange,
|
|
122
|
-
onKeyDown: handleInputKeyDown,
|
|
123
|
-
onBlur: handleInputBlur,
|
|
124
|
-
onFocus: ()=>{
|
|
125
|
-
if (blurTimeoutRef.current) {
|
|
126
|
-
clearTimeout(blurTimeoutRef.current);
|
|
127
|
-
blurTimeoutRef.current = null;
|
|
128
|
-
}
|
|
129
|
-
if (!open && !isDisabled && value.length > 0 && hasResults) {
|
|
130
|
-
onOpenChange(true);
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
className: className,
|
|
134
|
-
...inputProps
|
|
135
|
-
})
|
|
136
|
-
})
|
|
137
|
-
}),
|
|
138
|
-
/*#__PURE__*/ _jsx(PopoverContent, {
|
|
139
|
-
align: "start",
|
|
140
|
-
sideOffset: 8,
|
|
141
|
-
className: cn('w-(--radix-popover-trigger-width) rounded-8 bg-background-components-base p-4 shadow-tooltip', dropdownClassName),
|
|
142
|
-
onOpenAutoFocus: (e)=>e.preventDefault(),
|
|
143
|
-
onPointerDownOutside: handlePointerDownOutside,
|
|
144
|
-
onInteractOutside: handlePointerDownOutside,
|
|
145
|
-
children: /*#__PURE__*/ _jsx("div", {
|
|
146
|
-
ref: popoverContentRef,
|
|
147
|
-
className: "max-h-200 overflow-y-auto overscroll-contain scrollbar",
|
|
148
|
-
onWheel: (e)=>e.stopPropagation(),
|
|
149
|
-
onTouchStart: (e)=>e.stopPropagation(),
|
|
150
|
-
onTouchMove: (e)=>e.stopPropagation(),
|
|
151
|
-
children: hasResults ? /*#__PURE__*/ _jsxs("div", {
|
|
152
|
-
className: "flex flex-col gap-4 p-4",
|
|
153
|
-
children: [
|
|
154
|
-
/*#__PURE__*/ _jsx("div", {
|
|
155
|
-
className: "p-4 text-xs leading-20 text-foreground-neutral-muted",
|
|
156
|
-
children: "Select a repository"
|
|
157
|
-
}),
|
|
158
|
-
items.map((item, index)=>{
|
|
159
|
-
const isSelected = selectedItem?.id === item.id;
|
|
160
|
-
const isFocused = focusedIndex === index;
|
|
161
|
-
return /*#__PURE__*/ _jsx(Button, {
|
|
162
|
-
type: "button",
|
|
163
|
-
variant: "transparent",
|
|
164
|
-
ref: (el)=>{
|
|
165
|
-
itemRefs.current[index] = el;
|
|
166
|
-
},
|
|
167
|
-
onClick: ()=>handleSelect(item),
|
|
168
|
-
onMouseDown: (e)=>e.preventDefault(),
|
|
169
|
-
onMouseEnter: ()=>onFocusedIndexChange(index),
|
|
170
|
-
className: cn('!px-8 w-full text-left text-foreground-neutral-subtle', (isSelected || isFocused) && 'bg-background-components-hover text-foreground-neutral-base'),
|
|
171
|
-
children: /*#__PURE__*/ _jsx("span", {
|
|
172
|
-
className: "flex-1 truncate",
|
|
173
|
-
children: item.label
|
|
174
|
-
})
|
|
175
|
-
}, item.id);
|
|
176
|
-
})
|
|
177
|
-
]
|
|
178
|
-
}) : /*#__PURE__*/ _jsx("div", {
|
|
179
|
-
className: "p-4 text-xs leading-20 text-foreground-neutral-muted",
|
|
180
|
-
children: emptyPlaceholder ? emptyPlaceholder : null
|
|
181
|
-
})
|
|
182
|
-
})
|
|
183
|
-
})
|
|
184
|
-
]
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
//# sourceMappingURL=dropdown-input.js.map
|