sales-frontend-design-system 0.0.138 → 0.0.139
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/button/button.module.scss +5 -0
- package/dist/index.cjs.js +26 -19
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +26 -19
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -1591,11 +1591,12 @@ const ComboBoxItem = ({
|
|
|
1591
1591
|
validator,
|
|
1592
1592
|
value,
|
|
1593
1593
|
onValueChange,
|
|
1594
|
+
inputMode = "none",
|
|
1594
1595
|
...props
|
|
1595
1596
|
}) => {
|
|
1596
1597
|
const inputRef = React.useRef(null);
|
|
1597
1598
|
const { errorState, setForceUpdate } = useFormValidator({ validator, name });
|
|
1598
|
-
const { disabled, error, readOnly, size, ...rest } = useFieldControl(props);
|
|
1599
|
+
const { disabled, error, readOnly = true, size, ...rest } = useFieldControl(props);
|
|
1599
1600
|
const { handleClick, handleKeyDown } = usePreventInteraction({ disabled, readOnly });
|
|
1600
1601
|
const handleKeyDownEvent = (e) => {
|
|
1601
1602
|
if (e.key === " " || e.key === "Enter") {
|
|
@@ -1620,6 +1621,7 @@ const ComboBoxItem = ({
|
|
|
1620
1621
|
type: type ?? "text",
|
|
1621
1622
|
name,
|
|
1622
1623
|
readOnly,
|
|
1624
|
+
inputMode,
|
|
1623
1625
|
onClick: handleClick(handleOnClick),
|
|
1624
1626
|
onKeyDown: handleKeyDown(handleKeyDownEvent),
|
|
1625
1627
|
role: "combobox",
|
|
@@ -3402,7 +3404,6 @@ const TabRoot = ({ ref, ...props }) => {
|
|
|
3402
3404
|
const { className, children, scroll, onValueChange, variant, size, defaultValue, ...rest } = props;
|
|
3403
3405
|
const tabProps = useTab(props);
|
|
3404
3406
|
const containerRef = React.useRef(null);
|
|
3405
|
-
const prevValueRef = React.useRef(null);
|
|
3406
3407
|
const [underlineStyle, setUnderlineStyle] = React.useState({ left: 0, width: 0 });
|
|
3407
3408
|
const updateUnderlinePosition = React.useCallback(() => {
|
|
3408
3409
|
if (variant === "sub" && containerRef.current && tabProps.value) {
|
|
@@ -3434,30 +3435,36 @@ const TabRoot = ({ ref, ...props }) => {
|
|
|
3434
3435
|
if (scroll === "scrollable" && containerRef.current && tabProps.value) {
|
|
3435
3436
|
const container = containerRef.current;
|
|
3436
3437
|
const activeTab = container.querySelector(`[data-value="${tabProps.value}"]`);
|
|
3437
|
-
const prevTab = prevValueRef.current ? container.querySelector(`[data-value="${prevValueRef.current}"]`) : null;
|
|
3438
3438
|
if (activeTab) {
|
|
3439
3439
|
const containerRect = container.getBoundingClientRect();
|
|
3440
3440
|
const tabRect = activeTab.getBoundingClientRect();
|
|
3441
|
-
const
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3441
|
+
const shiftAmount = container.clientWidth * 0.2;
|
|
3442
|
+
const currentScroll = container.scrollLeft;
|
|
3443
|
+
const maxScroll = container.scrollWidth - container.clientWidth;
|
|
3444
|
+
const isHiddenLeft = tabRect.left < containerRect.left;
|
|
3445
|
+
const isHiddenRight = tabRect.right > containerRect.right;
|
|
3446
|
+
let newScroll;
|
|
3447
|
+
if (isHiddenLeft) {
|
|
3448
|
+
newScroll = Math.max(0, activeTab.offsetLeft - shiftAmount);
|
|
3449
|
+
} else if (isHiddenRight) {
|
|
3450
|
+
newScroll = Math.min(
|
|
3451
|
+
maxScroll,
|
|
3452
|
+
activeTab.offsetLeft + activeTab.offsetWidth + shiftAmount - container.clientWidth
|
|
3453
|
+
);
|
|
3454
|
+
} else {
|
|
3455
|
+
const tabCenter = tabRect.left + tabRect.width / 2;
|
|
3456
|
+
const containerCenter = containerRect.left + containerRect.width / 2;
|
|
3457
|
+
if (tabCenter < containerCenter) {
|
|
3458
|
+
newScroll = Math.max(0, currentScroll - shiftAmount);
|
|
3452
3459
|
} else {
|
|
3453
|
-
|
|
3454
|
-
left: activeTab.offsetLeft + activeTab.offsetWidth + scrollPadding - container.clientWidth,
|
|
3455
|
-
behavior: "smooth"
|
|
3456
|
-
});
|
|
3460
|
+
newScroll = Math.min(maxScroll, currentScroll + shiftAmount);
|
|
3457
3461
|
}
|
|
3458
3462
|
}
|
|
3463
|
+
container.scrollTo({
|
|
3464
|
+
left: newScroll,
|
|
3465
|
+
behavior: "smooth"
|
|
3466
|
+
});
|
|
3459
3467
|
}
|
|
3460
|
-
prevValueRef.current = tabProps.value;
|
|
3461
3468
|
}
|
|
3462
3469
|
}, [tabProps.value, scroll]);
|
|
3463
3470
|
return /* @__PURE__ */ jsxRuntime.jsx(TabRootContext.Provider, { value: tabProps, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx$h("tab-container", `tab-container-variant-${props.variant}`), children: /* @__PURE__ */ jsxRuntime.jsx("div", { role: "tablist", ref, className: cx$h("tab-root", className), ...rest, children: /* @__PURE__ */ jsxRuntime.jsxs(
|