@sproutsocial/seeds-react-menu 1.11.3 → 1.11.5
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +18 -0
- package/dist/esm/v3/index.js +44 -9
- package/dist/esm/v3/index.js.map +1 -1
- package/dist/v3/index.js +44 -9
- package/dist/v3/index.js.map +1 -1
- package/package.json +9 -9
- package/src/v3/Common/SelectStyles.tsx +1 -0
- package/src/v3/Common/VirtualizedComboboxList.tsx +23 -1
- package/src/v3/Common/sentinels.ts +17 -0
- package/src/v3/SingleSearchableSelect.stories.tsx +21 -0
- package/src/v3/SingleSearchableSelect.tsx +32 -9
package/.turbo/turbo-build.log
CHANGED
|
@@ -9,27 +9,27 @@ $ tsup --dts
|
|
|
9
9
|
[34mCJS[39m Build start
|
|
10
10
|
[34mESM[39m Build start
|
|
11
11
|
[32mCJS[39m [1mdist/index.js [22m[32m92.62 KB[39m
|
|
12
|
-
[32mCJS[39m [1mdist/v3/index.js [22m[32m92.22 KB[39m
|
|
13
12
|
[32mCJS[39m [1mdist/v2/index.js [22m[32m73.18 KB[39m
|
|
13
|
+
[32mCJS[39m [1mdist/v3/index.js [22m[32m93.61 KB[39m
|
|
14
14
|
[32mCJS[39m [1mdist/index.js.map [22m[32m180.20 KB[39m
|
|
15
|
-
[32mCJS[39m [1mdist/v3/index.js.map [22m[32m158.32 KB[39m
|
|
16
15
|
[32mCJS[39m [1mdist/v2/index.js.map [22m[32m152.19 KB[39m
|
|
17
|
-
[32mCJS[39m
|
|
16
|
+
[32mCJS[39m [1mdist/v3/index.js.map [22m[32m161.54 KB[39m
|
|
17
|
+
[32mCJS[39m ⚡️ Build success in 72ms
|
|
18
|
+
[32mESM[39m [1mdist/esm/v2/index.js [22m[32m62.63 KB[39m
|
|
18
19
|
[32mESM[39m [1mdist/esm/index.js [22m[32m73.57 KB[39m
|
|
19
20
|
[32mESM[39m [1mdist/esm/chunk-ROQATIB7.js [22m[32m9.15 KB[39m
|
|
20
|
-
[32mESM[39m [1mdist/esm/
|
|
21
|
-
[32mESM[39m [1mdist/esm/
|
|
21
|
+
[32mESM[39m [1mdist/esm/v3/index.js [22m[32m82.46 KB[39m
|
|
22
|
+
[32mESM[39m [1mdist/esm/v2/index.js.map [22m[32m132.57 KB[39m
|
|
22
23
|
[32mESM[39m [1mdist/esm/index.js.map [22m[32m156.22 KB[39m
|
|
23
24
|
[32mESM[39m [1mdist/esm/chunk-ROQATIB7.js.map [22m[32m22.93 KB[39m
|
|
24
|
-
[32mESM[39m [1mdist/esm/
|
|
25
|
-
[32mESM[39m
|
|
26
|
-
[32mESM[39m ⚡️ Build success in 94ms
|
|
25
|
+
[32mESM[39m [1mdist/esm/v3/index.js.map [22m[32m161.58 KB[39m
|
|
26
|
+
[32mESM[39m ⚡️ Build success in 74ms
|
|
27
27
|
[34mDTS[39m Build start
|
|
28
|
-
[32mDTS[39m ⚡️ Build success in
|
|
28
|
+
[32mDTS[39m ⚡️ Build success in 7371ms
|
|
29
29
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m39.08 KB[39m
|
|
30
30
|
[32mDTS[39m [1mdist/v2/index.d.ts [22m[32m5.55 KB[39m
|
|
31
31
|
[32mDTS[39m [1mdist/v3/index.d.ts [22m[32m17.65 KB[39m
|
|
32
32
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m39.08 KB[39m
|
|
33
33
|
[32mDTS[39m [1mdist/v2/index.d.mts [22m[32m5.55 KB[39m
|
|
34
34
|
[32mDTS[39m [1mdist/v3/index.d.mts [22m[32m17.65 KB[39m
|
|
35
|
-
Done in
|
|
35
|
+
Done in 8.16s.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @sproutsocial/seeds-react-menu
|
|
2
2
|
|
|
3
|
+
## 1.11.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @sproutsocial/seeds-react-icon@2.3.4
|
|
8
|
+
- @sproutsocial/seeds-react-button@2.0.2
|
|
9
|
+
- @sproutsocial/seeds-react-checkbox@1.3.30
|
|
10
|
+
- @sproutsocial/seeds-react-input@1.5.13
|
|
11
|
+
- @sproutsocial/seeds-react-switch@1.2.29
|
|
12
|
+
- @sproutsocial/seeds-react-token-input@1.4.35
|
|
13
|
+
- @sproutsocial/seeds-react-popout@2.4.35
|
|
14
|
+
|
|
15
|
+
## 1.11.4
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 1094671: ADd placeholder for single searchable select
|
|
20
|
+
|
|
3
21
|
## 1.11.3
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/esm/v3/index.js
CHANGED
|
@@ -140,6 +140,7 @@ var Field = styled2.div`
|
|
|
140
140
|
display: flex;
|
|
141
141
|
flex-direction: column;
|
|
142
142
|
gap: ${({ theme }) => theme.space[200]};
|
|
143
|
+
width: 100%;
|
|
143
144
|
`;
|
|
144
145
|
var SelectLabel = styled2(Select2.Label)`
|
|
145
146
|
font-size: ${({ theme }) => theme.typography[200].fontSize};
|
|
@@ -1078,6 +1079,16 @@ var ComboboxItem_default = ComboboxItem2;
|
|
|
1078
1079
|
import * as React7 from "react";
|
|
1079
1080
|
import { Combobox as Combobox2 } from "@base-ui/react/combobox";
|
|
1080
1081
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
1082
|
+
|
|
1083
|
+
// src/v3/Common/sentinels.ts
|
|
1084
|
+
function makePlaceholderSentinel(label) {
|
|
1085
|
+
return { __placeholder: true, label };
|
|
1086
|
+
}
|
|
1087
|
+
function isPlaceholderSentinel(v) {
|
|
1088
|
+
return typeof v === "object" && v !== null && "__placeholder" in v;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
// src/v3/Common/VirtualizedComboboxList.tsx
|
|
1081
1092
|
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1082
1093
|
var ITEM_HEIGHT = 32;
|
|
1083
1094
|
function isGroupHeaderSentinel(v) {
|
|
@@ -1139,7 +1150,7 @@ function VirtualizedComboboxList({
|
|
|
1139
1150
|
style: { position: "relative", width: "100%", height: totalSize },
|
|
1140
1151
|
children: virtualizer.getVirtualItems().map((virtualItem) => {
|
|
1141
1152
|
const row = filteredItems[virtualItem.index];
|
|
1142
|
-
if (
|
|
1153
|
+
if (row == null) return null;
|
|
1143
1154
|
const baseStyle = {
|
|
1144
1155
|
position: "absolute",
|
|
1145
1156
|
top: 0,
|
|
@@ -1148,6 +1159,22 @@ function VirtualizedComboboxList({
|
|
|
1148
1159
|
transform: `translateY(${virtualItem.start}px)`,
|
|
1149
1160
|
boxSizing: "border-box"
|
|
1150
1161
|
};
|
|
1162
|
+
if (isPlaceholderSentinel(row)) {
|
|
1163
|
+
return /* @__PURE__ */ jsx7(
|
|
1164
|
+
ComboboxItem_default,
|
|
1165
|
+
{
|
|
1166
|
+
index: virtualItem.index,
|
|
1167
|
+
"data-index": virtualItem.index,
|
|
1168
|
+
value: row,
|
|
1169
|
+
itemId: "placeholder",
|
|
1170
|
+
label: row.label,
|
|
1171
|
+
inputType,
|
|
1172
|
+
style: baseStyle,
|
|
1173
|
+
ref: virtualizer.measureElement
|
|
1174
|
+
},
|
|
1175
|
+
"placeholder"
|
|
1176
|
+
);
|
|
1177
|
+
}
|
|
1151
1178
|
if (isSelectAllSentinel(row)) {
|
|
1152
1179
|
const selectedCount = selectedArray.length;
|
|
1153
1180
|
const totalCount = data.length;
|
|
@@ -1206,6 +1233,7 @@ function VirtualizedComboboxList({
|
|
|
1206
1233
|
value: item,
|
|
1207
1234
|
itemId: String(item.id),
|
|
1208
1235
|
label: itemToString(item),
|
|
1236
|
+
disabled: item.disabled,
|
|
1209
1237
|
inputType,
|
|
1210
1238
|
renderItem: renderItem ? () => renderItem(item) : () => itemToString(item),
|
|
1211
1239
|
style: baseStyle,
|
|
@@ -1733,9 +1761,10 @@ function SingleSearchableSelect(props) {
|
|
|
1733
1761
|
);
|
|
1734
1762
|
const value = isControlled ? idToItem(selectedItemId) : internalValue;
|
|
1735
1763
|
function handleValueChange(newItem) {
|
|
1736
|
-
|
|
1764
|
+
const realItem = newItem == null || isPlaceholderSentinel(newItem) ? null : newItem;
|
|
1765
|
+
if (!isControlled) setInternalValue(realItem);
|
|
1737
1766
|
if (onSelectedItemIdChange) {
|
|
1738
|
-
onSelectedItemIdChange(
|
|
1767
|
+
onSelectedItemIdChange(realItem ? realItem.id : null);
|
|
1739
1768
|
}
|
|
1740
1769
|
}
|
|
1741
1770
|
const groups = React10.useMemo(
|
|
@@ -1751,9 +1780,14 @@ function SingleSearchableSelect(props) {
|
|
|
1751
1780
|
value,
|
|
1752
1781
|
disabled: props.disabled,
|
|
1753
1782
|
onValueChange: handleValueChange,
|
|
1754
|
-
itemToStringLabel: itemToString,
|
|
1755
|
-
isItemEqualToValue: (a, b) =>
|
|
1756
|
-
|
|
1783
|
+
itemToStringLabel: (item) => isPlaceholderSentinel(item) ? item.label : itemToString(item),
|
|
1784
|
+
isItemEqualToValue: (a, b) => {
|
|
1785
|
+
if (isPlaceholderSentinel(a) && isPlaceholderSentinel(b)) return true;
|
|
1786
|
+
if (isPlaceholderSentinel(a)) return b == null;
|
|
1787
|
+
if (isPlaceholderSentinel(b)) return a == null;
|
|
1788
|
+
return a != null && b != null && a.id === b.id;
|
|
1789
|
+
},
|
|
1790
|
+
items: isVirtualized ? includePlaceholderItem ? [makePlaceholderSentinel(placeholder), ...data] : data : groups ?? (isChildrenMode ? void 0 : data),
|
|
1757
1791
|
virtualized: isVirtualized,
|
|
1758
1792
|
open,
|
|
1759
1793
|
onOpenChange: setOpen,
|
|
@@ -1772,7 +1806,7 @@ function SingleSearchableSelect(props) {
|
|
|
1772
1806
|
} : void 0,
|
|
1773
1807
|
children: [
|
|
1774
1808
|
/* @__PURE__ */ jsxs8(SearchableSelectTrigger, { id, children: [
|
|
1775
|
-
/* @__PURE__ */ jsx10(SearchableSelectPlaceholder, { children: /* @__PURE__ */ jsx10(Combobox5.Value, { placeholder, children: value ? renderSelection ? renderSelection(value) : itemToString(value) :
|
|
1809
|
+
/* @__PURE__ */ jsx10(SearchableSelectPlaceholder, { children: /* @__PURE__ */ jsx10(Combobox5.Value, { placeholder, children: value ? renderSelection ? renderSelection(value) : itemToString(value) : placeholder }) }),
|
|
1776
1810
|
/* @__PURE__ */ jsx10(SearchableSelectTriggerIcon, { children: /* @__PURE__ */ jsx10(StyledChevron, { "data-chevron": true, children: /* @__PURE__ */ jsx10(ChevronIcon, {}) }) })
|
|
1777
1811
|
] }),
|
|
1778
1812
|
/* @__PURE__ */ jsx10(Combobox5.Portal, { container: portalContainer, children: /* @__PURE__ */ jsx10(ComboboxPositioner, { sideOffset: 4, children: /* @__PURE__ */ jsxs8(
|
|
@@ -1833,9 +1867,10 @@ function SingleSearchableSelect(props) {
|
|
|
1833
1867
|
includePlaceholderItem && /* @__PURE__ */ jsx10(
|
|
1834
1868
|
ComboboxItem_default,
|
|
1835
1869
|
{
|
|
1836
|
-
value:
|
|
1870
|
+
value: makePlaceholderSentinel(placeholder),
|
|
1837
1871
|
itemId: "placeholder",
|
|
1838
|
-
label: placeholder
|
|
1872
|
+
label: placeholder,
|
|
1873
|
+
inputType
|
|
1839
1874
|
},
|
|
1840
1875
|
"placeholder"
|
|
1841
1876
|
),
|