@pk-design/react-tailwind 1.10.3 → 1.11.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/cjs/components/SegmentedControl/SegmentedControl.js +6 -2
- package/dist/cjs/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/cjs/components/Toast/Toast.js +3 -1
- package/dist/cjs/components/Toast/Toast.js.map +1 -1
- package/dist/cjs/components/Toast/ToastProvider.js +10 -5
- package/dist/cjs/components/Toast/ToastProvider.js.map +1 -1
- package/dist/es/components/SegmentedControl/SegmentedControl.js +6 -2
- package/dist/es/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/es/components/Toast/Toast.js +3 -1
- package/dist/es/components/Toast/Toast.js.map +1 -1
- package/dist/es/components/Toast/ToastProvider.js +10 -5
- package/dist/es/components/Toast/ToastProvider.js.map +1 -1
- package/dist/react-tailwind.cjs.js +19 -9
- package/dist/react-tailwind.cjs.js.map +1 -1
- package/dist/react-tailwind.es.js +19 -9
- package/dist/react-tailwind.es.js.map +1 -1
- package/dist/types/components/Toast/Toast.types.d.ts +18 -2
- package/package.json +1 -1
|
@@ -4468,9 +4468,13 @@ const SegmentedControl = React.forwardRef((props, ref) => {
|
|
|
4468
4468
|
if (!isOptionDisabled) {
|
|
4469
4469
|
onChange(option.value);
|
|
4470
4470
|
}
|
|
4471
|
-
}, onKeyDown: (e) => handleKeyDown(e, index), className: buildClassName('inline-flex items-center justify-center gap-1.5 transition-all duration-150 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ui-primary-ring)]', SIZE_OPTION_CLASS[size],
|
|
4471
|
+
}, onKeyDown: (e) => handleKeyDown(e, index), className: buildClassName('inline-flex items-center justify-center gap-1.5 transition-all duration-150 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ui-primary-ring)]', SIZE_OPTION_CLASS[size],
|
|
4472
|
+
// Full width splits the row equally, so the width comes from the
|
|
4473
|
+
// row, not padding; tight side padding keeps labels on one line
|
|
4474
|
+
// on narrow screens.
|
|
4475
|
+
fullWidth ? 'min-w-0 flex-1 px-1.5' : '', isOptionDisabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer', isSelected
|
|
4472
4476
|
? 'bg-white text-[var(--ui-primary)] dark:bg-gray-700 dark:text-blue-400 shadow-xs font-semibold'
|
|
4473
|
-
: 'text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100'), "data-testid": `segmented-option-${option.value}`, children: [option.icon && (jsxRuntime.jsx("span", { className: buildClassName('shrink-0 inline-flex items-center justify-center', SIZE_ICON_CLASS[size]), children: option.icon })), jsxRuntime.jsx("span", { children: option.label })] }, option.value));
|
|
4477
|
+
: 'text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100'), "data-testid": `segmented-option-${option.value}`, children: [option.icon && (jsxRuntime.jsx("span", { className: buildClassName('shrink-0 inline-flex items-center justify-center', SIZE_ICON_CLASS[size]), children: option.icon })), jsxRuntime.jsx("span", { className: "min-w-0 truncate", children: option.label })] }, option.value));
|
|
4474
4478
|
}) }));
|
|
4475
4479
|
});
|
|
4476
4480
|
SegmentedControl.displayName = 'SegmentedControl';
|
|
@@ -4783,7 +4787,9 @@ const Toast = ({ id, title, message, type, variant = 'accent', action, icon, sho
|
|
|
4783
4787
|
const enterFrom = isTop ? 'opacity-0 -translate-y-3 scale-95' : 'opacity-0 translate-y-3 scale-95';
|
|
4784
4788
|
const leaveTo = isTop ? 'opacity-0 -translate-y-2 scale-95' : 'opacity-0 translate-y-2 scale-95';
|
|
4785
4789
|
const renderedIcon = icon !== null && icon !== void 0 ? icon : (variant === 'filled' ? filledIconMap[type] : iconMap[type]);
|
|
4786
|
-
return (jsxRuntime.jsx(react.Transition, { appear: true, show: true, enter: "transform transition duration-300 ease-out", enterFrom: enterFrom, enterTo: "opacity-100 translate-y-0 scale-100", leave: "transition duration-200 ease-in", leaveFrom: "opacity-100 translate-y-0 scale-100", leaveTo: leaveTo, children: jsxRuntime.jsxs("div", { role: "status", id: id.toString(), className: buildClassName(
|
|
4790
|
+
return (jsxRuntime.jsx(react.Transition, { appear: true, show: true, enter: "transform transition duration-300 ease-out", enterFrom: enterFrom, enterTo: "opacity-100 translate-y-0 scale-100", leave: "transition duration-200 ease-in", leaveFrom: "opacity-100 translate-y-0 scale-100", leaveTo: leaveTo, children: jsxRuntime.jsxs("div", { role: "status", id: id.toString(), className: buildClassName(
|
|
4791
|
+
// Never wider than the viewport minus a 16px gutter each side.
|
|
4792
|
+
'relative overflow-hidden flex items-start gap-3 rounded-xl px-4 py-3.5 min-w-[min(280px,calc(100vw-2rem))] max-w-[min(28rem,calc(100vw-2rem))] transition-all', variantStyleMap[variant][type], className), children: [jsxRuntime.jsx("div", { className: "shrink-0 mt-0.5", children: variant === 'filled' ? (renderedIcon) : (jsxRuntime.jsx(TextContent, { className: buildClassName(textColorMap[type]), children: renderedIcon })) }), jsxRuntime.jsxs("div", { className: "flex-1 flex flex-col gap-0.5", children: [title && (jsxRuntime.jsx("div", { className: buildClassName('font-semibold text-sm leading-snug', variant === 'filled' ? 'text-white' : 'text-gray-900 dark:text-gray-100'), children: title })), jsxRuntime.jsx("div", { className: buildClassName('text-sm font-medium leading-relaxed', variant === 'filled' ? 'text-white/95' : 'text-gray-700 dark:text-gray-300'), children: message }), action && (jsxRuntime.jsx("div", { className: "mt-1.5", children: jsxRuntime.jsx("button", { type: "button", onClick: action.onClick, className: buildClassName('text-xs font-semibold underline underline-offset-2 transition-opacity focus:outline-none', variant === 'filled'
|
|
4787
4793
|
? 'text-white hover:opacity-85'
|
|
4788
4794
|
: 'text-[var(--ui-primary)] hover:opacity-80'), children: action.label }) }))] }), jsxRuntime.jsx(Button, { onClick: onClose, "aria-label": "Close toast", className: buildClassName('shrink-0 mt-0.5 opacity-60 hover:opacity-100 focus-visible:opacity-100 transition', variant === 'filled' && 'text-white hover:text-white focus-visible:outline-current'), iconOnly: true, size: "xs", variant: "plain", theme: variant === 'filled' ? 'primary' : 'secondary', children: jsxRuntime.jsx(SvgX, { className: "size-4" }) }), showProgressBar && duration > 0 && (jsxRuntime.jsx("div", { className: "absolute bottom-0 left-0 right-0 h-1 bg-black/10 dark:bg-white/10 overflow-hidden", children: jsxRuntime.jsx("div", { className: buildClassName('h-full transition-all duration-75 ease-linear', variant === 'filled' ? 'bg-white/70' : progressBarColorMap[type]), style: { width: `${Math.max(0, progress)}%` } }) }))] }) }));
|
|
4789
4795
|
};
|
|
@@ -4801,11 +4807,15 @@ const placementClass = {
|
|
|
4801
4807
|
'top-right': 'top-20 right-6 items-end',
|
|
4802
4808
|
'top-left': 'top-20 left-6 items-start',
|
|
4803
4809
|
'top-center': 'top-20 left-1/2 -translate-x-1/2 items-center',
|
|
4804
|
-
|
|
4805
|
-
'bottom-
|
|
4806
|
-
'bottom-
|
|
4807
|
-
|
|
4808
|
-
|
|
4810
|
+
// Bottom placements clear the home indicator on notched phones (0 elsewhere).
|
|
4811
|
+
'bottom-right': 'bottom-[calc(1.5rem+env(safe-area-inset-bottom,0px))] right-6 items-end',
|
|
4812
|
+
'bottom-left': 'bottom-[calc(1.5rem+env(safe-area-inset-bottom,0px))] left-6 items-start',
|
|
4813
|
+
'bottom-center': 'bottom-[calc(1.5rem+env(safe-area-inset-bottom,0px))] left-1/2 -translate-x-1/2 items-center',
|
|
4814
|
+
};
|
|
4815
|
+
const ToastProvider = ({ children, placement: placementProp = 'top-right', maxToasts = 5, offset, className, }) => {
|
|
4816
|
+
const placement = useResponsiveValue(placementProp);
|
|
4817
|
+
const isTop = placement.startsWith('top');
|
|
4818
|
+
const edgeOffset = isTop ? offset === null || offset === void 0 ? void 0 : offset.top : offset === null || offset === void 0 ? void 0 : offset.bottom;
|
|
4809
4819
|
const [toasts, setToasts] = React.useState([]);
|
|
4810
4820
|
const [pausedIds, setPausedIds] = React.useState(new Set());
|
|
4811
4821
|
const metaRefs = React.useRef(new Map());
|
|
@@ -4926,7 +4936,7 @@ const ToastProvider = ({ children, placement = 'top-right', maxToasts = 5, class
|
|
|
4926
4936
|
dismiss: (id) => closeToast(id),
|
|
4927
4937
|
dismissAll: () => dismissAll(),
|
|
4928
4938
|
}), [showToast, closeToast, dismissAll]);
|
|
4929
|
-
return (jsxRuntime.jsxs(ToastContext.Provider, { value: { showToast, closeToast, toast: toastHelpers }, children: [children, jsxRuntime.jsx("div", { className: buildClassName('fixed z-[9999] flex flex-col gap-3 pointer-events-none', placementClass[placement], className), children: toasts.map((toastItem) => (jsxRuntime.jsx("div", { className: "pointer-events-auto", onMouseEnter: () => handleMouseEnter(toastItem), onMouseLeave: () => handleMouseLeave(toastItem), children: jsxRuntime.jsx(Toast, { ...toastItem, isPaused: pausedIds.has(toastItem.id), isTop:
|
|
4939
|
+
return (jsxRuntime.jsxs(ToastContext.Provider, { value: { showToast, closeToast, toast: toastHelpers }, children: [children, jsxRuntime.jsx("div", { className: buildClassName('fixed z-[9999] flex flex-col gap-3 pointer-events-none', placementClass[placement], className), style: edgeOffset ? (isTop ? { top: edgeOffset } : { bottom: edgeOffset }) : undefined, "data-testid": "toast-container", "data-placement": placement, children: toasts.map((toastItem) => (jsxRuntime.jsx("div", { className: "pointer-events-auto", onMouseEnter: () => handleMouseEnter(toastItem), onMouseLeave: () => handleMouseLeave(toastItem), children: jsxRuntime.jsx(Toast, { ...toastItem, isPaused: pausedIds.has(toastItem.id), isTop: isTop, onClose: () => closeToast(toastItem.id) }) }, toastItem.id))) })] }));
|
|
4930
4940
|
};
|
|
4931
4941
|
ToastProvider.displayName = 'ToastProvider';
|
|
4932
4942
|
|