@sproutsocial/seeds-react-tree 0.4.1 → 0.4.4
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 +9 -9
- package/CHANGELOG.md +33 -0
- package/dist/esm/index.js +106 -281
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +106 -281
- package/dist/index.js.map +1 -1
- package/dist/tree.css +318 -0
- package/package.json +12 -11
- package/src/Common/TreeSearchableSelectBase.tsx +36 -119
- package/src/Tree.stories.tsx +26 -0
- package/src/Tree.tsx +4 -4
- package/src/TreeCombobox.tsx +17 -71
- package/src/TreeItem.tsx +33 -22
- package/src/__tests__/Tree.test.tsx +61 -0
- package/src/cn.ts +28 -0
- package/src/tree.css +318 -0
- package/src/TreeStyles.tsx +0 -115
package/dist/index.js
CHANGED
|
@@ -138,105 +138,23 @@ function useTreeState(opts) {
|
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
// src/
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
gap: ${({ theme }) => theme.space[300]};
|
|
156
|
-
padding: ${({ theme }) => theme.space[300]};
|
|
157
|
-
padding-left: ${({ theme, $level }) => `calc(${theme.space[300]} + ${$level - 1} * ${theme.space[400]})`};
|
|
158
|
-
border-radius: ${({ theme }) => theme.radii[400]};
|
|
159
|
-
cursor: pointer;
|
|
160
|
-
user-select: none;
|
|
161
|
-
background: transparent;
|
|
162
|
-
transition: background-color ${({ theme }) => theme.duration.fast}
|
|
163
|
-
${({ theme }) => theme.easing.ease_in};
|
|
164
|
-
|
|
165
|
-
&:hover {
|
|
166
|
-
background: ${({ theme }) => theme.colors.listItem.background.hover};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
${({ $selected, theme }) => $selected && import_styled_components.css`
|
|
170
|
-
background: ${theme.colors.listItem.background.hover};
|
|
171
|
-
font-weight: ${theme.fontWeights.semibold};
|
|
172
|
-
`}
|
|
173
|
-
|
|
174
|
-
${({ $disabled }) => $disabled && import_styled_components.css`
|
|
175
|
-
opacity: 0.4;
|
|
176
|
-
cursor: not-allowed;
|
|
177
|
-
pointer-events: none;
|
|
178
|
-
`}
|
|
179
|
-
`;
|
|
180
|
-
var TreeItemEl = import_styled_components.default.li`
|
|
181
|
-
list-style: none;
|
|
182
|
-
outline: none;
|
|
183
|
-
|
|
184
|
-
/*
|
|
185
|
-
* Tree rows stack tightly, so the standard outset Seeds focusRing bleeds
|
|
186
|
-
* into adjacent rows. Use an inset outline so the ring is drawn just inside
|
|
187
|
-
* the row's edge and never overlaps siblings or children.
|
|
188
|
-
*
|
|
189
|
-
* The same ring is drawn when [data-treeitem-active] is set so combobox
|
|
190
|
-
* hosts that drive the tree via aria-activedescendant (no real DOM focus)
|
|
191
|
-
* still get a visible "active" indicator on the row.
|
|
192
|
-
*/
|
|
193
|
-
&:focus-visible > ${TreeItemRow}, &[data-treeitem-active] > ${TreeItemRow} {
|
|
194
|
-
outline: 2px solid
|
|
195
|
-
${({ theme }) => theme.colors.button.primary.background.base};
|
|
196
|
-
outline-offset: -2px;
|
|
197
|
-
}
|
|
198
|
-
`;
|
|
199
|
-
var TreeItemGroup = import_styled_components.default.ul`
|
|
200
|
-
list-style: none;
|
|
201
|
-
margin: 0;
|
|
202
|
-
padding: 0;
|
|
203
|
-
`;
|
|
204
|
-
var TreeItemLabel = import_styled_components.default.span`
|
|
205
|
-
flex: 1;
|
|
206
|
-
min-width: 0;
|
|
207
|
-
overflow: hidden;
|
|
208
|
-
text-overflow: ellipsis;
|
|
209
|
-
white-space: nowrap;
|
|
210
|
-
`;
|
|
211
|
-
var TreeItemIcon = import_styled_components.default.span`
|
|
212
|
-
display: inline-flex;
|
|
213
|
-
align-items: center;
|
|
214
|
-
flex-shrink: 0;
|
|
215
|
-
`;
|
|
216
|
-
var TreeItemChevron = import_styled_components.default.button.attrs({
|
|
217
|
-
type: "button",
|
|
218
|
-
tabIndex: -1
|
|
219
|
-
})`
|
|
220
|
-
display: inline-flex;
|
|
221
|
-
align-items: center;
|
|
222
|
-
justify-content: center;
|
|
223
|
-
flex-shrink: 0;
|
|
224
|
-
width: ${({ theme }) => theme.space[500]};
|
|
225
|
-
height: ${({ theme }) => theme.space[500]};
|
|
226
|
-
padding: 0;
|
|
227
|
-
border: none;
|
|
228
|
-
background: transparent;
|
|
229
|
-
color: ${({ theme }) => theme.colors.icon.base};
|
|
230
|
-
cursor: pointer;
|
|
231
|
-
border-radius: ${({ theme }) => theme.radii[300]};
|
|
232
|
-
transition: transform ${({ theme }) => theme.duration.fast}
|
|
233
|
-
${({ theme }) => theme.easing.ease_in};
|
|
234
|
-
transform: ${({ $expanded }) => $expanded ? "rotate(0deg)" : "rotate(-90deg)"};
|
|
235
|
-
|
|
236
|
-
&:hover {
|
|
237
|
-
background: ${({ theme }) => theme.colors.listItem.background.hover};
|
|
141
|
+
// src/cn.ts
|
|
142
|
+
function cn(...inputs) {
|
|
143
|
+
const classes = [];
|
|
144
|
+
for (const input of inputs) {
|
|
145
|
+
if (!input) continue;
|
|
146
|
+
if (typeof input === "string") {
|
|
147
|
+
classes.push(input);
|
|
148
|
+
} else if (typeof input === "object") {
|
|
149
|
+
for (const [key, value] of Object.entries(input)) {
|
|
150
|
+
if (value) {
|
|
151
|
+
classes.push(key);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
238
155
|
}
|
|
239
|
-
|
|
156
|
+
return classes.join(" ");
|
|
157
|
+
}
|
|
240
158
|
|
|
241
159
|
// src/Tree.tsx
|
|
242
160
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -325,12 +243,12 @@ var Tree = React.forwardRef(function Tree2(props, forwardedRef) {
|
|
|
325
243
|
]
|
|
326
244
|
);
|
|
327
245
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TreeContext.Provider, { value: ctxValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TreeItemContext.Provider, { value: { level: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
328
|
-
|
|
246
|
+
"ul",
|
|
329
247
|
{
|
|
330
248
|
ref: innerRef,
|
|
331
249
|
role: "tree",
|
|
332
250
|
id,
|
|
333
|
-
className,
|
|
251
|
+
className: cn("seeds-tree", className),
|
|
334
252
|
"aria-label": ariaLabel,
|
|
335
253
|
"aria-labelledby": ariaLabelledBy,
|
|
336
254
|
"aria-multiselectable": selectionMode === "multiple" ? true : void 0,
|
|
@@ -613,9 +531,10 @@ function TreeItem(props) {
|
|
|
613
531
|
const groupId = `${id}__group`;
|
|
614
532
|
const labelId = `${id}__label`;
|
|
615
533
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
616
|
-
|
|
534
|
+
"li",
|
|
617
535
|
{
|
|
618
536
|
ref: itemRef,
|
|
537
|
+
className: "seeds-tree-item",
|
|
619
538
|
id: treeItemDomId(id),
|
|
620
539
|
role: "treeitem",
|
|
621
540
|
"data-treeitem-id": id,
|
|
@@ -654,26 +573,32 @@ function TreeItem(props) {
|
|
|
654
573
|
},
|
|
655
574
|
children: [
|
|
656
575
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
657
|
-
|
|
576
|
+
"div",
|
|
658
577
|
{
|
|
659
578
|
"data-treeitem-row": true,
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
579
|
+
className: cn("seeds-tree-item-row", {
|
|
580
|
+
selected: isSelected,
|
|
581
|
+
disabled
|
|
582
|
+
}),
|
|
583
|
+
style: { "--tree-level": level },
|
|
663
584
|
children: [
|
|
664
585
|
ctx.renderSelectionIndicator && !(ctx.selectableNodes === "leaves" && hasChildren) ? ctx.renderSelectionIndicator({
|
|
665
586
|
selected: isSelected,
|
|
666
587
|
disabled,
|
|
667
588
|
selectionMode
|
|
668
589
|
}) : null,
|
|
669
|
-
icon != null ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
670
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
590
|
+
icon != null ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "seeds-tree-item-icon", "aria-hidden": true, children: icon }) : null,
|
|
591
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "seeds-tree-item-label", id: labelId, children: label }),
|
|
671
592
|
hasChildren ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
672
|
-
|
|
593
|
+
"button",
|
|
673
594
|
{
|
|
595
|
+
type: "button",
|
|
596
|
+
tabIndex: -1,
|
|
674
597
|
"data-tree-chevron": true,
|
|
675
598
|
"aria-hidden": true,
|
|
676
|
-
|
|
599
|
+
className: cn("seeds-tree-item-chevron", {
|
|
600
|
+
expanded: isExpanded
|
|
601
|
+
}),
|
|
677
602
|
onClick: handleChevronClick,
|
|
678
603
|
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_seeds_react_icon.Icon, { name: "chevron-down-outline", size: "small" })
|
|
679
604
|
}
|
|
@@ -681,7 +606,16 @@ function TreeItem(props) {
|
|
|
681
606
|
]
|
|
682
607
|
}
|
|
683
608
|
),
|
|
684
|
-
hasChildren ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
609
|
+
hasChildren ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
610
|
+
"ul",
|
|
611
|
+
{
|
|
612
|
+
className: "seeds-tree-item-group",
|
|
613
|
+
role: "group",
|
|
614
|
+
id: groupId,
|
|
615
|
+
hidden: !isExpanded,
|
|
616
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TreeItemContext.Provider, { value: { level: level + 1 }, children })
|
|
617
|
+
}
|
|
618
|
+
) : null
|
|
685
619
|
]
|
|
686
620
|
}
|
|
687
621
|
);
|
|
@@ -690,9 +624,7 @@ TreeItem.displayName = "TreeItem";
|
|
|
690
624
|
|
|
691
625
|
// src/TreeCombobox.tsx
|
|
692
626
|
var React3 = __toESM(require("react"));
|
|
693
|
-
var import_styled_components2 = __toESM(require("styled-components"));
|
|
694
627
|
var import_seeds_react_icon2 = require("@sproutsocial/seeds-react-icon");
|
|
695
|
-
var import_seeds_react_mixins = require("@sproutsocial/seeds-react-mixins");
|
|
696
628
|
|
|
697
629
|
// src/Common/filterTree.ts
|
|
698
630
|
function filterTree(items, query) {
|
|
@@ -721,58 +653,6 @@ function filterTree(items, query) {
|
|
|
721
653
|
|
|
722
654
|
// src/TreeCombobox.tsx
|
|
723
655
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
724
|
-
var Root = import_styled_components2.default.div`
|
|
725
|
-
display: flex;
|
|
726
|
-
flex-direction: column;
|
|
727
|
-
flex: 1;
|
|
728
|
-
min-height: 0;
|
|
729
|
-
`;
|
|
730
|
-
var SearchSection = import_styled_components2.default.div`
|
|
731
|
-
padding: ${({ theme }) => theme.space[300]};
|
|
732
|
-
border-bottom: 1px solid ${({ theme }) => theme.colors.container.border.base};
|
|
733
|
-
flex-shrink: 0;
|
|
734
|
-
`;
|
|
735
|
-
var InputGroup = import_styled_components2.default.div`
|
|
736
|
-
display: flex;
|
|
737
|
-
align-items: center;
|
|
738
|
-
gap: ${({ theme }) => theme.space[200]};
|
|
739
|
-
padding: ${({ theme }) => theme.space[200]} ${({ theme }) => theme.space[300]};
|
|
740
|
-
border-radius: ${({ theme }) => theme.radii[500]};
|
|
741
|
-
border: 1px solid ${({ theme }) => theme.colors.container.border.base};
|
|
742
|
-
background: ${({ theme }) => theme.colors.container.background.base};
|
|
743
|
-
color: ${({ theme }) => theme.colors.icon.base};
|
|
744
|
-
|
|
745
|
-
&:focus-within {
|
|
746
|
-
${import_seeds_react_mixins.focusRing}
|
|
747
|
-
}
|
|
748
|
-
`;
|
|
749
|
-
var ComboboxInput = import_styled_components2.default.input`
|
|
750
|
-
flex: 1;
|
|
751
|
-
border: none;
|
|
752
|
-
background: transparent;
|
|
753
|
-
outline: none;
|
|
754
|
-
font-family: ${({ theme }) => theme.fontFamily};
|
|
755
|
-
font-size: ${({ theme }) => theme.typography[200].fontSize};
|
|
756
|
-
line-height: ${({ theme }) => theme.typography[200].lineHeight};
|
|
757
|
-
color: ${({ theme }) => theme.colors.text.body};
|
|
758
|
-
|
|
759
|
-
&::placeholder {
|
|
760
|
-
color: ${({ theme }) => theme.colors.text.subtext};
|
|
761
|
-
}
|
|
762
|
-
`;
|
|
763
|
-
var ListSection = import_styled_components2.default.div`
|
|
764
|
-
padding: ${({ theme }) => theme.space[200]};
|
|
765
|
-
overflow: auto;
|
|
766
|
-
flex: 1;
|
|
767
|
-
min-height: 0;
|
|
768
|
-
`;
|
|
769
|
-
var EmptyState = import_styled_components2.default.div`
|
|
770
|
-
padding: ${({ theme }) => `${theme.space[300]} ${theme.space[350]}`};
|
|
771
|
-
text-align: center;
|
|
772
|
-
color: ${({ theme }) => theme.colors.text.subtext};
|
|
773
|
-
font-size: ${({ theme }) => theme.typography[200].fontSize};
|
|
774
|
-
line-height: ${({ theme }) => theme.typography[200].lineHeight};
|
|
775
|
-
`;
|
|
776
656
|
var NAV_KEYS = /* @__PURE__ */ new Set([
|
|
777
657
|
"ArrowDown",
|
|
778
658
|
"ArrowUp",
|
|
@@ -883,12 +763,13 @@ function TreeCombobox(props) {
|
|
|
883
763
|
}
|
|
884
764
|
}, [focusedId]);
|
|
885
765
|
const showEmpty = visibleItems.length === 0;
|
|
886
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
887
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
766
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: cn("seeds-tree-combobox", className), children: [
|
|
767
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "seeds-tree-combobox-search", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "seeds-tree-combobox-input-group", children: [
|
|
888
768
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_seeds_react_icon2.Icon, { name: "magnifying-glass-outline", size: "small", "aria-hidden": true }),
|
|
889
769
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
890
|
-
|
|
770
|
+
"input",
|
|
891
771
|
{
|
|
772
|
+
className: "seeds-tree-combobox-input",
|
|
892
773
|
type: "text",
|
|
893
774
|
role: "combobox",
|
|
894
775
|
id,
|
|
@@ -906,7 +787,7 @@ function TreeCombobox(props) {
|
|
|
906
787
|
}
|
|
907
788
|
)
|
|
908
789
|
] }) }),
|
|
909
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
790
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "seeds-tree-combobox-list", children: [
|
|
910
791
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
911
792
|
Tree,
|
|
912
793
|
{
|
|
@@ -928,7 +809,15 @@ function TreeCombobox(props) {
|
|
|
928
809
|
children: visibleItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TreeNode, { item }, item.id))
|
|
929
810
|
}
|
|
930
811
|
),
|
|
931
|
-
showEmpty ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
812
|
+
showEmpty ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
813
|
+
"div",
|
|
814
|
+
{
|
|
815
|
+
className: "seeds-tree-combobox-empty",
|
|
816
|
+
role: "status",
|
|
817
|
+
"aria-live": "polite",
|
|
818
|
+
children: emptyText
|
|
819
|
+
}
|
|
820
|
+
) : null
|
|
932
821
|
] })
|
|
933
822
|
] });
|
|
934
823
|
}
|
|
@@ -950,9 +839,7 @@ var React5 = __toESM(require("react"));
|
|
|
950
839
|
|
|
951
840
|
// src/Common/TreeSearchableSelectBase.tsx
|
|
952
841
|
var React4 = __toESM(require("react"));
|
|
953
|
-
var import_styled_components3 = __toESM(require("styled-components"));
|
|
954
842
|
var import_seeds_react_icon3 = require("@sproutsocial/seeds-react-icon");
|
|
955
|
-
var import_seeds_react_mixins2 = require("@sproutsocial/seeds-react-mixins");
|
|
956
843
|
var import_v2 = require("@sproutsocial/seeds-react-popout/v2");
|
|
957
844
|
|
|
958
845
|
// src/Common/flattenTree.ts
|
|
@@ -970,95 +857,14 @@ function flattenTreeItems(items) {
|
|
|
970
857
|
|
|
971
858
|
// src/Common/TreeSearchableSelectBase.tsx
|
|
972
859
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
973
|
-
var invalidStyles = import_styled_components3.css`
|
|
974
|
-
border-color: ${({ theme }) => theme.colors.form.border.error};
|
|
975
|
-
`;
|
|
976
|
-
var Trigger = import_styled_components3.default.button`
|
|
977
|
-
display: flex;
|
|
978
|
-
align-items: center;
|
|
979
|
-
justify-content: space-between;
|
|
980
|
-
gap: ${({ theme }) => theme.space[300]};
|
|
981
|
-
padding: ${({ theme }) => theme.space[200]} ${({ theme }) => theme.space[350]};
|
|
982
|
-
min-width: 160px;
|
|
983
|
-
width: ${({ $fullWidth }) => $fullWidth ? "100%" : "auto"};
|
|
984
|
-
border-radius: ${({ theme }) => theme.radii[500]};
|
|
985
|
-
border: 1px solid ${({ theme }) => theme.colors.form.border.base};
|
|
986
|
-
background: ${({ theme }) => theme.colors.form.background.base};
|
|
987
|
-
font-family: ${({ theme }) => theme.fontFamily};
|
|
988
|
-
font-size: ${({ theme }) => theme.typography[200].fontSize};
|
|
989
|
-
line-height: ${({ theme }) => theme.typography[200].lineHeight};
|
|
990
|
-
color: ${({ theme }) => theme.colors.text.body};
|
|
991
|
-
text-align: left;
|
|
992
|
-
cursor: default;
|
|
993
|
-
outline: none;
|
|
994
|
-
user-select: none;
|
|
995
|
-
transition: border-color ${({ theme }) => theme.duration.fast}
|
|
996
|
-
${({ theme }) => theme.easing.ease_in},
|
|
997
|
-
box-shadow ${({ theme }) => theme.duration.fast}
|
|
998
|
-
${({ theme }) => theme.easing.ease_in};
|
|
999
|
-
|
|
1000
|
-
&:focus-visible {
|
|
1001
|
-
${import_seeds_react_mixins2.focusRing}
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
&[aria-disabled="true"],
|
|
1005
|
-
&:disabled {
|
|
1006
|
-
opacity: 0.4;
|
|
1007
|
-
cursor: not-allowed;
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
${({ $isInvalid }) => $isInvalid && invalidStyles}
|
|
1011
|
-
`;
|
|
1012
|
-
var TriggerLabel = import_styled_components3.default.span`
|
|
1013
|
-
flex: 1;
|
|
1014
|
-
min-width: 0;
|
|
1015
|
-
overflow: hidden;
|
|
1016
|
-
text-overflow: ellipsis;
|
|
1017
|
-
white-space: nowrap;
|
|
1018
|
-
`;
|
|
1019
|
-
var PlaceholderText = import_styled_components3.default.span`
|
|
1020
|
-
color: ${({ theme }) => theme.colors.text.subtext};
|
|
1021
|
-
`;
|
|
1022
|
-
var Chevron = import_styled_components3.default.span`
|
|
1023
|
-
display: inline-flex;
|
|
1024
|
-
align-items: center;
|
|
1025
|
-
color: ${({ theme }) => theme.colors.icon.base};
|
|
1026
|
-
transition: transform ${({ theme }) => theme.duration.fast}
|
|
1027
|
-
${({ theme }) => theme.easing.ease_in};
|
|
1028
|
-
${({ $open }) => $open && import_styled_components3.css`
|
|
1029
|
-
transform: rotate(-180deg);
|
|
1030
|
-
`}
|
|
1031
|
-
`;
|
|
1032
|
-
var HiddenInput = import_styled_components3.default.input`
|
|
1033
|
-
clip-path: inset(50%);
|
|
1034
|
-
overflow: hidden;
|
|
1035
|
-
white-space: nowrap;
|
|
1036
|
-
border: 0;
|
|
1037
|
-
padding: 0;
|
|
1038
|
-
width: 1px;
|
|
1039
|
-
height: 1px;
|
|
1040
|
-
margin: -1px;
|
|
1041
|
-
position: fixed;
|
|
1042
|
-
top: 0;
|
|
1043
|
-
left: 0;
|
|
1044
|
-
`;
|
|
1045
|
-
var PopoutContent = import_styled_components3.default.div`
|
|
1046
|
-
display: flex;
|
|
1047
|
-
flex-direction: column;
|
|
1048
|
-
/* Width sizes to content within bounds: at least the trigger width, never */
|
|
1049
|
-
/* wider than the available viewport space. Shallow popups stay flush with */
|
|
1050
|
-
/* the trigger; deeply nested trees expand horizontally as needed. */
|
|
1051
|
-
min-width: var(--radix-popover-trigger-width);
|
|
1052
|
-
max-width: var(--radix-popper-available-width);
|
|
1053
|
-
/* Height caps at 400px (or available viewport) so a popup with many */
|
|
1054
|
-
/* expanded branches scrolls vertically instead of growing off-screen. */
|
|
1055
|
-
max-height: min(var(--radix-popper-available-height), 400px);
|
|
1056
|
-
width: ${({ $width }) => $width === void 0 ? "max-content" : typeof $width === "number" ? `${$width}px` : $width};
|
|
1057
|
-
`;
|
|
1058
860
|
var MAX_INLINE_LABELS = 3;
|
|
861
|
+
function popoutWidth(width) {
|
|
862
|
+
if (width === void 0) return void 0;
|
|
863
|
+
return typeof width === "number" ? `${width}px` : width;
|
|
864
|
+
}
|
|
1059
865
|
function defaultRenderTrigger(selected, placeholder) {
|
|
1060
866
|
if (selected.length === 0) {
|
|
1061
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
867
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "seeds-tree-select-placeholder", children: placeholder });
|
|
1062
868
|
}
|
|
1063
869
|
if (selected.length <= MAX_INLINE_LABELS) {
|
|
1064
870
|
return selected.map((s) => s.label).join(", ");
|
|
@@ -1124,8 +930,9 @@ function TreeSearchableSelectBase(props) {
|
|
|
1124
930
|
const primaryInputId = id && primaryInputName == null ? `${id}-hidden-input` : void 0;
|
|
1125
931
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
1126
932
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1127
|
-
|
|
933
|
+
"input",
|
|
1128
934
|
{
|
|
935
|
+
className: "seeds-tree-select-hidden-input",
|
|
1129
936
|
type: "text",
|
|
1130
937
|
id: primaryInputId,
|
|
1131
938
|
name: primaryInputName,
|
|
@@ -1161,33 +968,44 @@ function TreeSearchableSelectBase(props) {
|
|
|
1161
968
|
event.preventDefault();
|
|
1162
969
|
}
|
|
1163
970
|
},
|
|
1164
|
-
content: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1165
|
-
|
|
971
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
972
|
+
"div",
|
|
1166
973
|
{
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
974
|
+
className: "seeds-tree-select-popout",
|
|
975
|
+
id: popupId,
|
|
976
|
+
style: {
|
|
977
|
+
"--tree-select-width": popoutWidth(contentWidth)
|
|
978
|
+
},
|
|
979
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
980
|
+
TreeCombobox,
|
|
981
|
+
{
|
|
982
|
+
"aria-label": "Search",
|
|
983
|
+
items,
|
|
984
|
+
placeholder: searchPlaceholder,
|
|
985
|
+
emptyText,
|
|
986
|
+
query,
|
|
987
|
+
onQueryChange: setQuery,
|
|
988
|
+
selectionMode,
|
|
989
|
+
selectableNodes,
|
|
990
|
+
selected: selectedIds,
|
|
991
|
+
onSelectionChange: handleSelectionChange,
|
|
992
|
+
renderSelectionIndicator,
|
|
993
|
+
defaultExpanded,
|
|
994
|
+
expanded,
|
|
995
|
+
onExpandedChange
|
|
996
|
+
}
|
|
997
|
+
)
|
|
1181
998
|
}
|
|
1182
|
-
)
|
|
999
|
+
),
|
|
1183
1000
|
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1184
|
-
|
|
1001
|
+
"button",
|
|
1185
1002
|
{
|
|
1003
|
+
className: cn("seeds-tree-select-trigger", className, {
|
|
1004
|
+
"full-width": fullWidth,
|
|
1005
|
+
invalid: !!isInvalid
|
|
1006
|
+
}),
|
|
1186
1007
|
type: "button",
|
|
1187
1008
|
id,
|
|
1188
|
-
className,
|
|
1189
|
-
$isInvalid: isInvalid,
|
|
1190
|
-
$fullWidth: fullWidth,
|
|
1191
1009
|
disabled,
|
|
1192
1010
|
role: "combobox",
|
|
1193
1011
|
"aria-haspopup": "dialog",
|
|
@@ -1199,8 +1017,15 @@ function TreeSearchableSelectBase(props) {
|
|
|
1199
1017
|
"aria-invalid": isInvalid || void 0,
|
|
1200
1018
|
"aria-required": required || void 0,
|
|
1201
1019
|
children: [
|
|
1202
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1203
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1020
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "seeds-tree-select-trigger-label", children: triggerContent }),
|
|
1021
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1022
|
+
"span",
|
|
1023
|
+
{
|
|
1024
|
+
className: cn("seeds-tree-select-chevron", { open }),
|
|
1025
|
+
"aria-hidden": true,
|
|
1026
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_seeds_react_icon3.Icon, { name: "chevron-down-outline", size: "small" })
|
|
1027
|
+
}
|
|
1028
|
+
)
|
|
1204
1029
|
]
|
|
1205
1030
|
}
|
|
1206
1031
|
)
|