react-ui-suite 1.1.4 → 1.1.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.
|
@@ -1,12 +1,30 @@
|
|
|
1
|
-
.rui-tab-group {
|
|
2
|
-
display: flex;
|
|
3
|
-
width: 100%;
|
|
4
|
-
height: 100%;
|
|
5
|
-
|
|
6
|
-
--rui-tab-
|
|
7
|
-
--rui-tab-radius:
|
|
8
|
-
--rui-tab-
|
|
9
|
-
|
|
1
|
+
.rui-tab-group {
|
|
2
|
+
display: flex;
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 100%;
|
|
5
|
+
position: relative;
|
|
6
|
+
--rui-tab-border: 1px;
|
|
7
|
+
--rui-tab-panel-radius: 15px;
|
|
8
|
+
--rui-tab-radius: 10px;
|
|
9
|
+
--rui-tab-min-main: 32px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.rui-tab-group__measure {
|
|
13
|
+
position: fixed;
|
|
14
|
+
left: 0;
|
|
15
|
+
top: 0;
|
|
16
|
+
visibility: hidden;
|
|
17
|
+
pointer-events: none;
|
|
18
|
+
z-index: -1;
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
gap: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.rui-tab-group__measure .rui-tab-group__tab {
|
|
24
|
+
flex: 0 0 auto !important;
|
|
25
|
+
width: auto !important;
|
|
26
|
+
height: auto !important;
|
|
27
|
+
}
|
|
10
28
|
|
|
11
29
|
.rui-tab-group[data-position="top"],
|
|
12
30
|
.rui-tab-group[data-position="bottom"] {
|
|
@@ -70,20 +88,21 @@
|
|
|
70
88
|
justify-content: flex-end;
|
|
71
89
|
}
|
|
72
90
|
|
|
73
|
-
.rui-tab-group__tab {
|
|
74
|
-
border: var(--rui-tab-border) solid var(--rui-color-border);
|
|
75
|
-
background-color: var(--rui-color-surface-muted);
|
|
76
|
-
position: relative;
|
|
91
|
+
.rui-tab-group__tab {
|
|
92
|
+
border: var(--rui-tab-border) solid var(--rui-color-border);
|
|
93
|
+
background-color: var(--rui-color-surface-muted);
|
|
94
|
+
position: relative;
|
|
77
95
|
padding: 5px;
|
|
78
96
|
font-weight: 500;
|
|
79
97
|
display: inline-flex;
|
|
80
98
|
align-items: center;
|
|
81
99
|
justify-content: center;
|
|
82
100
|
transform: none;
|
|
83
|
-
min-width: 0;
|
|
84
|
-
min-height: 0;
|
|
85
|
-
flex: 0 0 auto;
|
|
86
|
-
|
|
101
|
+
min-width: 0;
|
|
102
|
+
min-height: 0;
|
|
103
|
+
flex: 0 0 auto;
|
|
104
|
+
overflow: hidden;
|
|
105
|
+
}
|
|
87
106
|
|
|
88
107
|
.rui-tab-group__scroll {
|
|
89
108
|
border: var(--rui-tab-border) solid var(--rui-color-border);
|
|
@@ -108,12 +127,19 @@
|
|
|
108
127
|
line-height: 1;
|
|
109
128
|
}
|
|
110
129
|
|
|
111
|
-
.rui-tab-group__label {
|
|
112
|
-
display: inline-flex;
|
|
113
|
-
align-items: center;
|
|
114
|
-
justify-content: center;
|
|
115
|
-
line-height: 1;
|
|
116
|
-
|
|
130
|
+
.rui-tab-group__label {
|
|
131
|
+
display: inline-flex;
|
|
132
|
+
align-items: center;
|
|
133
|
+
justify-content: center;
|
|
134
|
+
line-height: 1;
|
|
135
|
+
white-space: normal;
|
|
136
|
+
overflow: hidden;
|
|
137
|
+
overflow-wrap: normal;
|
|
138
|
+
word-break: normal;
|
|
139
|
+
hyphens: none;
|
|
140
|
+
max-width: 100%;
|
|
141
|
+
max-height: 100%;
|
|
142
|
+
}
|
|
117
143
|
|
|
118
144
|
.rui-tab-group__tab.is-active {
|
|
119
145
|
background-color: var(--rui-color-surface);
|
|
@@ -205,10 +231,10 @@
|
|
|
205
231
|
border-bottom-right-radius: var(--rui-tab-radius);
|
|
206
232
|
}
|
|
207
233
|
|
|
208
|
-
.rui-tab-group[data-rotation="vertical"] .rui-tab-group__label {
|
|
209
|
-
writing-mode: vertical-rl;
|
|
210
|
-
text-orientation: mixed;
|
|
211
|
-
}
|
|
234
|
+
.rui-tab-group[data-rotation="vertical"] .rui-tab-group__label {
|
|
235
|
+
writing-mode: vertical-rl;
|
|
236
|
+
text-orientation: mixed;
|
|
237
|
+
}
|
|
212
238
|
|
|
213
239
|
.rui-tab-group[data-position="top"][data-rotation="vertical"] .rui-tab-group__label {
|
|
214
240
|
transform: rotate(180deg);
|
package/dist/index.js
CHANGED
|
@@ -1016,7 +1016,16 @@ var Dropdown = React6.forwardRef(
|
|
|
1016
1016
|
ref: chevronRef,
|
|
1017
1017
|
type: "button",
|
|
1018
1018
|
"aria-label": isOpen ? "Close" : "Open",
|
|
1019
|
-
|
|
1019
|
+
onPointerDown: (event) => {
|
|
1020
|
+
if (!onChevronClick) return;
|
|
1021
|
+
if (event.button !== 0) return;
|
|
1022
|
+
event.preventDefault();
|
|
1023
|
+
onChevronClick();
|
|
1024
|
+
},
|
|
1025
|
+
onClick: (event) => {
|
|
1026
|
+
if (!onChevronClick || event.detail !== 0) return;
|
|
1027
|
+
onChevronClick();
|
|
1028
|
+
},
|
|
1020
1029
|
className: buttonClasses,
|
|
1021
1030
|
disabled: !!disabled,
|
|
1022
1031
|
children: /* @__PURE__ */ jsx8(
|
|
@@ -1635,10 +1644,7 @@ function InnerCombobox({
|
|
|
1635
1644
|
openList();
|
|
1636
1645
|
return;
|
|
1637
1646
|
}
|
|
1638
|
-
|
|
1639
|
-
var _a2;
|
|
1640
|
-
return (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
|
|
1641
|
-
});
|
|
1647
|
+
setOpen(false);
|
|
1642
1648
|
},
|
|
1643
1649
|
children: isEffectivelyOpen && /* @__PURE__ */ jsx11(
|
|
1644
1650
|
Popover,
|
|
@@ -3860,7 +3866,7 @@ function StackedList({ items, dense, className, ...rest }) {
|
|
|
3860
3866
|
|
|
3861
3867
|
// components/TabGroup/TabGroup.tsx
|
|
3862
3868
|
import React21 from "react";
|
|
3863
|
-
import "./TabGroup-
|
|
3869
|
+
import "./TabGroup-3NH74LET.css";
|
|
3864
3870
|
import { Fragment as Fragment2, jsx as jsx25, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
3865
3871
|
function TabGroup({
|
|
3866
3872
|
align = "start",
|
|
@@ -3876,11 +3882,16 @@ function TabGroup({
|
|
|
3876
3882
|
var _a, _b;
|
|
3877
3883
|
const rootRef = React21.useRef(null);
|
|
3878
3884
|
const tabStripRef = React21.useRef(null);
|
|
3885
|
+
const measureRef = React21.useRef(null);
|
|
3879
3886
|
const idBase = React21.useId();
|
|
3880
3887
|
const [effectiveFill, setEffectiveFill] = React21.useState(fill);
|
|
3881
3888
|
const [availableMain, setAvailableMain] = React21.useState(0);
|
|
3882
|
-
const [
|
|
3889
|
+
const [cssMinMain, setCssMinMain] = React21.useState(32);
|
|
3890
|
+
const [contentMinMain, setContentMinMain] = React21.useState(0);
|
|
3883
3891
|
const count = tabs.length;
|
|
3892
|
+
const isVertical = position === "left" || position === "right";
|
|
3893
|
+
const minMain = Math.max(cssMinMain, contentMinMain);
|
|
3894
|
+
const partialMainSize = Math.max(Number.isFinite(size) ? size : 0, minMain);
|
|
3884
3895
|
const clampIndex = React21.useCallback(
|
|
3885
3896
|
(i) => {
|
|
3886
3897
|
if (count <= 0) {
|
|
@@ -3923,14 +3934,16 @@ function TabGroup({
|
|
|
3923
3934
|
const radius = parseFloat(computed.getPropertyValue("--rui-tab-panel-radius")) || 0;
|
|
3924
3935
|
const border = parseFloat(computed.getPropertyValue("--rui-tab-border")) || 0;
|
|
3925
3936
|
const minMainValue = parseFloat(computed.getPropertyValue("--rui-tab-min-main")) || 32;
|
|
3937
|
+
const effectiveMinMain = Math.max(minMainValue, contentMinMain);
|
|
3926
3938
|
const wiggle = border * 2 + 1;
|
|
3927
3939
|
const available = position === "top" || position === "bottom" ? rect.width : rect.height;
|
|
3928
|
-
const
|
|
3929
|
-
const
|
|
3940
|
+
const requiredPerTab = Math.max(size != null ? size : 0, effectiveMinMain);
|
|
3941
|
+
const required = requiredPerTab * tabs.length;
|
|
3942
|
+
const slots2 = effectiveMinMain > 0 ? Math.floor(available / effectiveMinMain) : tabs.length;
|
|
3930
3943
|
const hasOverflowControls = slots2 < tabs.length;
|
|
3931
3944
|
const shouldFill = available - 2 * radius - wiggle <= required;
|
|
3932
3945
|
setEffectiveFill(shouldFill || hasOverflowControls ? "full" : "partial");
|
|
3933
|
-
}, [fill, position, size, tabs.length]);
|
|
3946
|
+
}, [contentMinMain, fill, position, size, tabs.length]);
|
|
3934
3947
|
React21.useLayoutEffect(() => {
|
|
3935
3948
|
if (fill === "full") {
|
|
3936
3949
|
setEffectiveFill("full");
|
|
@@ -3945,14 +3958,43 @@ function TabGroup({
|
|
|
3945
3958
|
observer.observe(node);
|
|
3946
3959
|
return () => observer.disconnect();
|
|
3947
3960
|
}, [fill, updateEffectiveFill]);
|
|
3948
|
-
const isVertical = position === "left" || position === "right";
|
|
3949
3961
|
React21.useLayoutEffect(() => {
|
|
3950
3962
|
const root = rootRef.current;
|
|
3951
3963
|
if (!root) return;
|
|
3952
3964
|
const computed = getComputedStyle(root);
|
|
3953
3965
|
const cssMin = parseFloat(computed.getPropertyValue("--rui-tab-min-main"));
|
|
3954
|
-
|
|
3966
|
+
setCssMinMain(Number.isFinite(cssMin) && cssMin > 0 ? cssMin : 32);
|
|
3955
3967
|
}, [position]);
|
|
3968
|
+
React21.useLayoutEffect(() => {
|
|
3969
|
+
const node = measureRef.current;
|
|
3970
|
+
if (!node) return;
|
|
3971
|
+
const measure = () => {
|
|
3972
|
+
const sampleTab = node.querySelector(".rui-tab-group__tab");
|
|
3973
|
+
const labels = Array.from(node.querySelectorAll(".rui-tab-group__label"));
|
|
3974
|
+
if (!sampleTab || labels.length === 0) {
|
|
3975
|
+
setContentMinMain(0);
|
|
3976
|
+
return;
|
|
3977
|
+
}
|
|
3978
|
+
const tabStyle = getComputedStyle(sampleTab);
|
|
3979
|
+
const paddingMain = isVertical ? (parseFloat(tabStyle.paddingTop) || 0) + (parseFloat(tabStyle.paddingBottom) || 0) : (parseFloat(tabStyle.paddingLeft) || 0) + (parseFloat(tabStyle.paddingRight) || 0);
|
|
3980
|
+
const borderMain = isVertical ? (parseFloat(tabStyle.borderTopWidth) || 0) + (parseFloat(tabStyle.borderBottomWidth) || 0) : (parseFloat(tabStyle.borderLeftWidth) || 0) + (parseFloat(tabStyle.borderRightWidth) || 0);
|
|
3981
|
+
let largestLabelMain = 0;
|
|
3982
|
+
for (const label of labels) {
|
|
3983
|
+
const rect = label.getBoundingClientRect();
|
|
3984
|
+
const labelMain = isVertical ? rect.height : rect.width;
|
|
3985
|
+
if (labelMain > largestLabelMain) {
|
|
3986
|
+
largestLabelMain = labelMain;
|
|
3987
|
+
}
|
|
3988
|
+
}
|
|
3989
|
+
const next = Math.ceil(largestLabelMain + paddingMain + borderMain);
|
|
3990
|
+
setContentMinMain((prev) => prev === next ? prev : next);
|
|
3991
|
+
};
|
|
3992
|
+
measure();
|
|
3993
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
3994
|
+
const observer = new ResizeObserver(() => measure());
|
|
3995
|
+
observer.observe(node);
|
|
3996
|
+
return () => observer.disconnect();
|
|
3997
|
+
}, [isVertical, position, rotation, tabs]);
|
|
3956
3998
|
React21.useLayoutEffect(() => {
|
|
3957
3999
|
const node = tabStripRef.current;
|
|
3958
4000
|
if (!node) return;
|
|
@@ -3968,7 +4010,8 @@ function TabGroup({
|
|
|
3968
4010
|
}, [isVertical]);
|
|
3969
4011
|
const slots = availableMain > 0 && minMain > 0 ? Math.floor(availableMain / minMain) : count;
|
|
3970
4012
|
const overflow = slots < count;
|
|
3971
|
-
const
|
|
4013
|
+
const layoutSlots = overflow ? Math.max(3, slots) : Math.max(1, slots);
|
|
4014
|
+
const windowSize = overflow ? Math.max(1, layoutSlots - 2) : count;
|
|
3972
4015
|
const maxStart = Math.max(0, count - windowSize);
|
|
3973
4016
|
const [startIndex, setStartIndex] = React21.useState(0);
|
|
3974
4017
|
React21.useEffect(() => {
|
|
@@ -3988,9 +4031,9 @@ function TabGroup({
|
|
|
3988
4031
|
});
|
|
3989
4032
|
}, [currentActive, overflow, windowSize]);
|
|
3990
4033
|
const visibleTabs = overflow ? tabs.slice(startIndex, startIndex + windowSize) : tabs;
|
|
3991
|
-
const slotSize = overflow &&
|
|
4034
|
+
const slotSize = overflow && layoutSlots > 0 ? availableMain / layoutSlots : 0;
|
|
3992
4035
|
const overflowMainStyle = overflow && slotSize > 0 ? isVertical ? { height: slotSize } : { width: slotSize } : void 0;
|
|
3993
|
-
const mainStyle = overflow ? overflowMainStyle : effectiveFill === "partial" ? isVertical ? { height:
|
|
4036
|
+
const mainStyle = overflow ? overflowMainStyle : effectiveFill === "partial" ? isVertical ? { height: partialMainSize } : { width: partialMainSize } : void 0;
|
|
3994
4037
|
const scrollLabels = isVertical ? { back: "Scroll tabs up", forward: "Scroll tabs down" } : { back: "Scroll tabs left", forward: "Scroll tabs right" };
|
|
3995
4038
|
const scrollMainStyle = overflowMainStyle;
|
|
3996
4039
|
const panelId = `${idBase}-panel`;
|
|
@@ -4125,7 +4168,7 @@ function TabGroup({
|
|
|
4125
4168
|
children: (_b = (_a = tabs[currentActive]) == null ? void 0 : _a.content) != null ? _b : null
|
|
4126
4169
|
}
|
|
4127
4170
|
);
|
|
4128
|
-
return /* @__PURE__ */
|
|
4171
|
+
return /* @__PURE__ */ jsxs23(
|
|
4129
4172
|
"div",
|
|
4130
4173
|
{
|
|
4131
4174
|
ref: rootRef,
|
|
@@ -4136,13 +4179,16 @@ function TabGroup({
|
|
|
4136
4179
|
"data-requested-fill": fill,
|
|
4137
4180
|
"data-rotation": rotation,
|
|
4138
4181
|
"data-overflow": overflow ? "true" : "false",
|
|
4139
|
-
children:
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4182
|
+
children: [
|
|
4183
|
+
/* @__PURE__ */ jsx25("div", { ref: measureRef, className: "rui-tab-group__measure", "aria-hidden": "true", children: tabs.map((tab, index) => /* @__PURE__ */ jsx25("button", { type: "button", className: "rui-tab-group__tab", children: /* @__PURE__ */ jsx25("span", { className: "rui-tab-group__label", children: tab.label }) }, index)) }),
|
|
4184
|
+
tabsFirst ? /* @__PURE__ */ jsxs23(Fragment2, { children: [
|
|
4185
|
+
tabList,
|
|
4186
|
+
panel
|
|
4187
|
+
] }) : /* @__PURE__ */ jsxs23(Fragment2, { children: [
|
|
4188
|
+
panel,
|
|
4189
|
+
tabList
|
|
4190
|
+
] })
|
|
4191
|
+
]
|
|
4146
4192
|
}
|
|
4147
4193
|
);
|
|
4148
4194
|
}
|