@polastack/design-system 0.1.23 → 0.1.24
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/index.d.ts +4 -1
- package/dist/index.js +78 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -390,7 +390,10 @@ declare const progressVariants: (props?: ({
|
|
|
390
390
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
391
391
|
interface ProgressProps extends React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>, VariantProps<typeof progressVariants> {
|
|
392
392
|
showLabel?: boolean | ((value: number | null | undefined) => React.ReactNode);
|
|
393
|
-
|
|
393
|
+
/** @default 'right' */
|
|
394
|
+
labelPosition?: 'right' | 'top' | 'floating';
|
|
395
|
+
/** Show a dot marker at the progress edge */
|
|
396
|
+
showMarker?: boolean;
|
|
394
397
|
}
|
|
395
398
|
declare const Progress: React.ForwardRefExoticComponent<ProgressProps & React.RefAttributes<HTMLDivElement>>;
|
|
396
399
|
|
package/dist/index.js
CHANGED
|
@@ -1849,6 +1849,27 @@ var progressIndicatorVariants = cva11(
|
|
|
1849
1849
|
}
|
|
1850
1850
|
}
|
|
1851
1851
|
);
|
|
1852
|
+
var floatingBubbleVariants = {
|
|
1853
|
+
default: "bg-primary-600 dark:bg-primary-400",
|
|
1854
|
+
success: "bg-success-600 dark:bg-success-400",
|
|
1855
|
+
warning: "bg-warning-600 dark:bg-warning-400",
|
|
1856
|
+
error: "bg-error-600 dark:bg-error-400",
|
|
1857
|
+
info: "bg-info-600 dark:bg-info-400"
|
|
1858
|
+
};
|
|
1859
|
+
var floatingArrowVariants = {
|
|
1860
|
+
default: "border-t-primary-600 dark:border-t-primary-400",
|
|
1861
|
+
success: "border-t-success-600 dark:border-t-success-400",
|
|
1862
|
+
warning: "border-t-warning-600 dark:border-t-warning-400",
|
|
1863
|
+
error: "border-t-error-600 dark:border-t-error-400",
|
|
1864
|
+
info: "border-t-info-600 dark:border-t-info-400"
|
|
1865
|
+
};
|
|
1866
|
+
var markerVariants = {
|
|
1867
|
+
default: "border-primary-500",
|
|
1868
|
+
success: "border-success-500",
|
|
1869
|
+
warning: "border-warning-500",
|
|
1870
|
+
error: "border-error-500",
|
|
1871
|
+
info: "border-info-500"
|
|
1872
|
+
};
|
|
1852
1873
|
var Progress = React27.forwardRef(
|
|
1853
1874
|
({
|
|
1854
1875
|
className,
|
|
@@ -1858,11 +1879,16 @@ var Progress = React27.forwardRef(
|
|
|
1858
1879
|
max = 100,
|
|
1859
1880
|
showLabel,
|
|
1860
1881
|
labelPosition = "right",
|
|
1882
|
+
showMarker,
|
|
1861
1883
|
...props
|
|
1862
1884
|
}, ref) => {
|
|
1863
1885
|
const isIndeterminate = value === null || value === void 0;
|
|
1864
1886
|
const clampedValue = isIndeterminate ? null : Math.min(max, Math.max(0, value));
|
|
1887
|
+
const percent = isIndeterminate ? 0 : clampedValue / max * 100;
|
|
1888
|
+
const resolvedVariant = variant ?? "default";
|
|
1865
1889
|
const labelContent = showLabel ? typeof showLabel === "function" ? showLabel(clampedValue) : isIndeterminate ? null : `${Math.round(clampedValue)}%` : null;
|
|
1890
|
+
const isFloating = labelPosition === "floating" && labelContent && !isIndeterminate;
|
|
1891
|
+
const hasMarker = showMarker && !isIndeterminate;
|
|
1866
1892
|
const bar = /* @__PURE__ */ jsx26(
|
|
1867
1893
|
ProgressPrimitive.Root,
|
|
1868
1894
|
{
|
|
@@ -1880,11 +1906,62 @@ var Progress = React27.forwardRef(
|
|
|
1880
1906
|
indeterminate: isIndeterminate
|
|
1881
1907
|
})
|
|
1882
1908
|
),
|
|
1883
|
-
style: isIndeterminate ? void 0 : { width: `${
|
|
1909
|
+
style: isIndeterminate ? void 0 : { width: `${percent}%` }
|
|
1884
1910
|
}
|
|
1885
1911
|
)
|
|
1886
1912
|
}
|
|
1887
1913
|
);
|
|
1914
|
+
if (isFloating || hasMarker) {
|
|
1915
|
+
return /* @__PURE__ */ jsxs10("div", { className: "relative", children: [
|
|
1916
|
+
isFloating && /* @__PURE__ */ jsx26(
|
|
1917
|
+
"div",
|
|
1918
|
+
{
|
|
1919
|
+
className: "absolute bottom-full mb-2 transition-[left] duration-normal ease-default",
|
|
1920
|
+
style: { left: `${percent}%` },
|
|
1921
|
+
"aria-hidden": "true",
|
|
1922
|
+
children: /* @__PURE__ */ jsxs10("div", { className: "relative -translate-x-1/2", children: [
|
|
1923
|
+
/* @__PURE__ */ jsx26(
|
|
1924
|
+
"span",
|
|
1925
|
+
{
|
|
1926
|
+
className: cn(
|
|
1927
|
+
"block rounded-md px-2 py-0.5 text-xs font-semibold tabular-nums text-white whitespace-nowrap shadow-sm",
|
|
1928
|
+
floatingBubbleVariants[resolvedVariant]
|
|
1929
|
+
),
|
|
1930
|
+
children: labelContent
|
|
1931
|
+
}
|
|
1932
|
+
),
|
|
1933
|
+
/* @__PURE__ */ jsx26(
|
|
1934
|
+
"div",
|
|
1935
|
+
{
|
|
1936
|
+
className: cn(
|
|
1937
|
+
"mx-auto h-0 w-0 border-x-4 border-t-4 border-x-transparent",
|
|
1938
|
+
floatingArrowVariants[resolvedVariant]
|
|
1939
|
+
)
|
|
1940
|
+
}
|
|
1941
|
+
)
|
|
1942
|
+
] })
|
|
1943
|
+
}
|
|
1944
|
+
),
|
|
1945
|
+
bar,
|
|
1946
|
+
hasMarker && /* @__PURE__ */ jsx26(
|
|
1947
|
+
"div",
|
|
1948
|
+
{
|
|
1949
|
+
className: "absolute top-1/2 -translate-y-1/2 transition-[left] duration-normal ease-default pointer-events-none",
|
|
1950
|
+
style: { left: `${percent}%` },
|
|
1951
|
+
"aria-hidden": "true",
|
|
1952
|
+
children: /* @__PURE__ */ jsx26(
|
|
1953
|
+
"div",
|
|
1954
|
+
{
|
|
1955
|
+
className: cn(
|
|
1956
|
+
"h-3.5 w-3.5 -translate-x-1/2 rounded-full border-2 bg-white shadow-sm dark:bg-[var(--color-surface-raised)]",
|
|
1957
|
+
markerVariants[resolvedVariant]
|
|
1958
|
+
)
|
|
1959
|
+
}
|
|
1960
|
+
)
|
|
1961
|
+
}
|
|
1962
|
+
)
|
|
1963
|
+
] });
|
|
1964
|
+
}
|
|
1888
1965
|
if (!labelContent) return bar;
|
|
1889
1966
|
if (labelPosition === "top") {
|
|
1890
1967
|
return /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-1.5", children: [
|